Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add autoComplete option for elements #207

Merged
merged 7 commits into from Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/elements/constants.ts
Expand Up @@ -28,11 +28,14 @@ const CARD_BRANDS = [

const CARD_ICON_POSITIONS = ['left', 'right', 'none'] as const;

const AUTOCOMPLETE_VALUES = ['off', 'on'] as const;

export {
ELEMENTS_INIT_ERROR_MESSAGE,
ELEMENTS_NOM_DOM_ERROR_MESSAGE,
ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE,
ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE,
CARD_BRANDS,
CARD_ICON_POSITIONS,
AUTOCOMPLETE_VALUES,
};
9 changes: 8 additions & 1 deletion src/types/elements/options.ts
@@ -1,3 +1,4 @@
import { AutoCompleteValue } from './shared';
import type { ElementStyle } from './styles';

const ELEMENTS_TYPES = [
Expand Down Expand Up @@ -28,6 +29,7 @@ interface SanitizedElementOptions {
ariaLabel?: string;
iconPosition?: string;
cardBrand?: string;
autoComplete?: string;
}

type ElementOptions = ElementInternalOptions & SanitizedElementOptions;
Expand All @@ -38,7 +40,12 @@ interface TransformOption {
transform?: Transform;
}

type CustomizableElementOptions = Pick<ElementOptions, 'style' | 'disabled'>;
interface AutoCompleteOption {
autoComplete?: AutoCompleteValue;
}

type CustomizableElementOptions = Pick<ElementOptions, 'style' | 'disabled'> &
AutoCompleteOption;

type CreateCardElementOptions = CustomizableElementOptions;

Expand Down
12 changes: 11 additions & 1 deletion src/types/elements/shared.ts
@@ -1,4 +1,8 @@
import { CARD_BRANDS, CARD_ICON_POSITIONS } from '@/elements/constants';
import {
AUTOCOMPLETE_VALUES,
CARD_BRANDS,
CARD_ICON_POSITIONS,
} from '@/elements/constants';

type FieldErrorType = 'incomplete' | 'invalid';

Expand Down Expand Up @@ -37,6 +41,11 @@ type Brand = typeof CARD_BRANDS[number];
*/
type CardIconPosition = typeof CARD_ICON_POSITIONS[number];

/**
* Values for the element input autocomplete attribute
*/
type AutoCompleteValue = typeof AUTOCOMPLETE_VALUES[number];

export type {
FieldErrorType,
ConfigErrorType,
Expand All @@ -47,4 +56,5 @@ export type {
PropertyError,
Brand,
CardIconPosition,
AutoCompleteValue,
};