]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types(jsx): improve autocomplete type (#14237)
authorrzzf <cszhjh@gmail.com>
Mon, 19 Jan 2026 01:03:37 +0000 (09:03 +0800)
committerGitHub <noreply@github.com>
Mon, 19 Jan 2026 01:03:37 +0000 (09:03 +0800)
packages/runtime-dom/src/jsx.ts

index e15095b1ec2c4033517096b8728614d41b95ea19..5d4e7c629a092d979a41f9f584816d0cdbf27a09 100644 (file)
@@ -561,10 +561,72 @@ export type InputTypeHTMLAttribute =
   | 'week'
   | (string & {})
 
+type AutoFillAddressKind = 'billing' | 'shipping'
+type AutoFillBase = '' | 'off' | 'on'
+type AutoFillContactField =
+  | 'email'
+  | 'tel'
+  | 'tel-area-code'
+  | 'tel-country-code'
+  | 'tel-extension'
+  | 'tel-local'
+  | 'tel-local-prefix'
+  | 'tel-local-suffix'
+  | 'tel-national'
+type AutoFillContactKind = 'home' | 'mobile' | 'work'
+type AutoFillCredentialField = 'webauthn'
+type AutoFillNormalField =
+  | 'additional-name'
+  | 'address-level1'
+  | 'address-level2'
+  | 'address-level3'
+  | 'address-level4'
+  | 'address-line1'
+  | 'address-line2'
+  | 'address-line3'
+  | 'bday-day'
+  | 'bday-month'
+  | 'bday-year'
+  | 'cc-csc'
+  | 'cc-exp'
+  | 'cc-exp-month'
+  | 'cc-exp-year'
+  | 'cc-family-name'
+  | 'cc-given-name'
+  | 'cc-name'
+  | 'cc-number'
+  | 'cc-type'
+  | 'country'
+  | 'country-name'
+  | 'current-password'
+  | 'family-name'
+  | 'given-name'
+  | 'honorific-prefix'
+  | 'honorific-suffix'
+  | 'name'
+  | 'new-password'
+  | 'one-time-code'
+  | 'organization'
+  | 'postal-code'
+  | 'street-address'
+  | 'transaction-amount'
+  | 'transaction-currency'
+  | 'username'
+type OptionalPrefixToken<T extends string> = `${T} ` | ''
+type OptionalPostfixToken<T extends string> = ` ${T}` | ''
+type AutoFillField =
+  | AutoFillNormalField
+  | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`
+type AutoFillSection = `section-${string}`
+type AutoFill =
+  | AutoFillBase
+  | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<AutoFillAddressKind>}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`
+export type InputAutoCompleteAttribute = AutoFill | (string & {})
+
 export interface InputHTMLAttributes extends HTMLAttributes {
   accept?: string | undefined
   alt?: string | undefined
-  autocomplete?: string | undefined
+  autocomplete?: InputAutoCompleteAttribute | undefined
   autofocus?: Booleanish | undefined
   capture?: boolean | 'user' | 'environment' | undefined // https://www.w3.org/tr/html-media-capture/#the-capture-attribute
   checked?: Booleanish | any[] | Set<any> | undefined // for IDE v-model multi-checkbox support