give
/
src
/
DonationForms
/
resources
/
registrars
/
templates
/
fields
/
utils
/
autoCompleteAttr.js
autoCompleteAttr.js
28 lines
| 1 | /** |
| 2 | * User agents sometimes have features for helping users fill forms in, for example prefilling |
| 3 | * the user's address based on earlier user input. The autocomplete content attribute can be |
| 4 | * used to hint to the user agent how to, or indeed whether to, provide such a feature. |
| 5 | * |
| 6 | * @since 4.3.0 |
| 7 | * |
| 8 | * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill |
| 9 | */ |
| 10 | export default function autoCompleteAttr(inputName) { |
| 11 | const autoCompleteMapping = { |
| 12 | company: 'organization', |
| 13 | honorific: 'honorific-prefix', |
| 14 | firstName: 'given-name', |
| 15 | lastName: 'family-name', |
| 16 | email: 'email', |
| 17 | phone: 'tel', |
| 18 | country: 'country', |
| 19 | address1: 'address-line1', |
| 20 | address2: 'address-line2', |
| 21 | city: 'address-level2', |
| 22 | state: 'address-level1', |
| 23 | zip: 'postal-code', |
| 24 | }; |
| 25 | |
| 26 | return autoCompleteMapping[inputName]; |
| 27 | } |
| 28 |