Skip to content

Commit 0596a5f

Browse files
authored
types(jsx): improve autocomplete type (#14237)
1 parent 19cc7e2 commit 0596a5f

1 file changed

Lines changed: 63 additions & 1 deletion

File tree

  • packages/runtime-dom/src

packages/runtime-dom/src/jsx.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,72 @@ export type InputTypeHTMLAttribute =
561561
| 'week'
562562
| (string & {})
563563

564+
type AutoFillAddressKind = 'billing' | 'shipping'
565+
type AutoFillBase = '' | 'off' | 'on'
566+
type AutoFillContactField =
567+
| 'email'
568+
| 'tel'
569+
| 'tel-area-code'
570+
| 'tel-country-code'
571+
| 'tel-extension'
572+
| 'tel-local'
573+
| 'tel-local-prefix'
574+
| 'tel-local-suffix'
575+
| 'tel-national'
576+
type AutoFillContactKind = 'home' | 'mobile' | 'work'
577+
type AutoFillCredentialField = 'webauthn'
578+
type AutoFillNormalField =
579+
| 'additional-name'
580+
| 'address-level1'
581+
| 'address-level2'
582+
| 'address-level3'
583+
| 'address-level4'
584+
| 'address-line1'
585+
| 'address-line2'
586+
| 'address-line3'
587+
| 'bday-day'
588+
| 'bday-month'
589+
| 'bday-year'
590+
| 'cc-csc'
591+
| 'cc-exp'
592+
| 'cc-exp-month'
593+
| 'cc-exp-year'
594+
| 'cc-family-name'
595+
| 'cc-given-name'
596+
| 'cc-name'
597+
| 'cc-number'
598+
| 'cc-type'
599+
| 'country'
600+
| 'country-name'
601+
| 'current-password'
602+
| 'family-name'
603+
| 'given-name'
604+
| 'honorific-prefix'
605+
| 'honorific-suffix'
606+
| 'name'
607+
| 'new-password'
608+
| 'one-time-code'
609+
| 'organization'
610+
| 'postal-code'
611+
| 'street-address'
612+
| 'transaction-amount'
613+
| 'transaction-currency'
614+
| 'username'
615+
type OptionalPrefixToken<T extends string> = `${T} ` | ''
616+
type OptionalPostfixToken<T extends string> = ` ${T}` | ''
617+
type AutoFillField =
618+
| AutoFillNormalField
619+
| `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`
620+
type AutoFillSection = `section-${string}`
621+
type AutoFill =
622+
| AutoFillBase
623+
| `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<AutoFillAddressKind>}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`
624+
export type InputAutoCompleteAttribute = AutoFill | (string & {})
625+
564626
export interface InputHTMLAttributes extends HTMLAttributes {
565627
accept?: string | undefined
566628
alt?: string | undefined
567-
autocomplete?: string | undefined
629+
autocomplete?: InputAutoCompleteAttribute | undefined
568630
autofocus?: Booleanish | undefined
569631
capture?: boolean | 'user' | 'environment' | undefined // https://www.w3.org/tr/html-media-capture/#the-capture-attribute
570632
checked?: Booleanish | any[] | Set<any> | undefined // for IDE v-model multi-checkbox support

0 commit comments

Comments
 (0)