@flipdish/ui-library 0.62.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -21
- package/dist/components/__internal__/listOption/listOption.styles.cjs +20 -0
- package/dist/components/__internal__/listOption/listOption.styles.cjs.map +1 -0
- package/dist/components/__internal__/listOption/listOption.styles.d.ts +16 -0
- package/dist/components/__internal__/listOption/listOption.styles.d.ts.map +1 -0
- package/dist/components/__internal__/listOption/listOption.styles.js +18 -0
- package/dist/components/__internal__/listOption/listOption.styles.js.map +1 -0
- package/dist/components/atoms/BackgroundPattern/components/Circle.cjs +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Circle.cjs.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Circle.d.ts +3 -3
- package/dist/components/atoms/BackgroundPattern/components/Circle.d.ts.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Circle.js +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Circle.js.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Grid.cjs +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Grid.cjs.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Grid.d.ts +3 -3
- package/dist/components/atoms/BackgroundPattern/components/Grid.d.ts.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Grid.js +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Grid.js.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.cjs +13 -8
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.cjs.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.d.ts +3 -3
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.d.ts.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.js +13 -8
- package/dist/components/atoms/BackgroundPattern/components/GridCheck.js.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Square.cjs +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Square.cjs.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Square.d.ts +3 -3
- package/dist/components/atoms/BackgroundPattern/components/Square.d.ts.map +1 -1
- package/dist/components/atoms/BackgroundPattern/components/Square.js +17 -12
- package/dist/components/atoms/BackgroundPattern/components/Square.js.map +1 -1
- package/dist/components/atoms/BackgroundPattern/index.cjs +5 -3
- package/dist/components/atoms/BackgroundPattern/index.cjs.map +1 -1
- package/dist/components/atoms/BackgroundPattern/index.d.ts +11 -11
- package/dist/components/atoms/BackgroundPattern/index.d.ts.map +1 -1
- package/dist/components/atoms/BackgroundPattern/index.js +5 -3
- package/dist/components/atoms/BackgroundPattern/index.js.map +1 -1
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.cjs +7 -3
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.cjs.map +1 -1
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.d.ts +4 -4
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.d.ts.map +1 -1
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.js +7 -3
- package/dist/components/atoms/BrandButtons/SocialButton/SocialButton.js.map +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.cjs +6 -3
- package/dist/components/atoms/Buttons/IconButton/IconButton.cjs.map +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.d.ts +4 -4
- package/dist/components/atoms/Buttons/IconButton/IconButton.d.ts.map +1 -1
- package/dist/components/atoms/Buttons/IconButton/IconButton.js +7 -4
- package/dist/components/atoms/Buttons/IconButton/IconButton.js.map +1 -1
- package/dist/components/atoms/Card/index.cjs +5 -3
- package/dist/components/atoms/Card/index.cjs.map +1 -1
- package/dist/components/atoms/Card/index.d.ts +3 -3
- package/dist/components/atoms/Card/index.d.ts.map +1 -1
- package/dist/components/atoms/Card/index.js +5 -3
- package/dist/components/atoms/Card/index.js.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts +1 -4
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.cjs +3 -3
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts +2 -7
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.js +4 -4
- package/dist/components/atoms/Checkboxes/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/atoms/Dot/index.cjs +5 -3
- package/dist/components/atoms/Dot/index.cjs.map +1 -1
- package/dist/components/atoms/Dot/index.d.ts +3 -3
- package/dist/components/atoms/Dot/index.d.ts.map +1 -1
- package/dist/components/atoms/Dot/index.js +5 -3
- package/dist/components/atoms/Dot/index.js.map +1 -1
- package/dist/components/atoms/FeaturedIcon/index.cjs +4 -3
- package/dist/components/atoms/FeaturedIcon/index.cjs.map +1 -1
- package/dist/components/atoms/FeaturedIcon/index.d.ts +2 -4
- package/dist/components/atoms/FeaturedIcon/index.d.ts.map +1 -1
- package/dist/components/atoms/FeaturedIcon/index.js +5 -4
- package/dist/components/atoms/FeaturedIcon/index.js.map +1 -1
- package/dist/components/atoms/Flag/index.cjs +10 -6
- package/dist/components/atoms/Flag/index.cjs.map +1 -1
- package/dist/components/atoms/Flag/index.d.ts +3 -3
- package/dist/components/atoms/Flag/index.d.ts.map +1 -1
- package/dist/components/atoms/Flag/index.js +12 -8
- package/dist/components/atoms/Flag/index.js.map +1 -1
- package/dist/components/atoms/FlipdishLogo/index.cjs +5 -3
- package/dist/components/atoms/FlipdishLogo/index.cjs.map +1 -1
- package/dist/components/atoms/FlipdishLogo/index.d.ts +3 -3
- package/dist/components/atoms/FlipdishLogo/index.d.ts.map +1 -1
- package/dist/components/atoms/FlipdishLogo/index.js +5 -3
- package/dist/components/atoms/FlipdishLogo/index.js.map +1 -1
- package/dist/components/atoms/Illustration/components/TextIllustration.cjs +7 -4
- package/dist/components/atoms/Illustration/components/TextIllustration.cjs.map +1 -1
- package/dist/components/atoms/Illustration/components/TextIllustration.d.ts +2 -3
- package/dist/components/atoms/Illustration/components/TextIllustration.d.ts.map +1 -1
- package/dist/components/atoms/Illustration/components/TextIllustration.js +7 -4
- package/dist/components/atoms/Illustration/components/TextIllustration.js.map +1 -1
- package/dist/components/atoms/Input/index.d.ts +2 -8
- package/dist/components/atoms/Input/index.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/Input/Input.cjs +4 -4
- package/dist/components/atoms/Inputs/Input/Input.cjs.map +1 -1
- package/dist/components/atoms/Inputs/Input/Input.d.ts +3 -11
- package/dist/components/atoms/Inputs/Input/Input.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/Input/Input.js +6 -6
- package/dist/components/atoms/Inputs/Input/Input.js.map +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.cjs +3 -2
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.cjs.map +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.d.ts +2 -7
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.js +3 -2
- package/dist/components/atoms/Inputs/SearchInput/SearchInput.js.map +1 -1
- package/dist/components/atoms/Inputs/TextArea/TextArea.cjs +7 -6
- package/dist/components/atoms/Inputs/TextArea/TextArea.cjs.map +1 -1
- package/dist/components/atoms/Inputs/TextArea/TextArea.d.ts +4 -13
- package/dist/components/atoms/Inputs/TextArea/TextArea.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/TextArea/TextArea.js +8 -7
- package/dist/components/atoms/Inputs/TextArea/TextArea.js.map +1 -1
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.cjs +5 -5
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.cjs.map +1 -1
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.d.ts +2 -7
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.js +6 -6
- package/dist/components/atoms/Inputs/TimeInput/TimeInput.js.map +1 -1
- package/dist/components/atoms/Inputs/components/HintText.cjs +4 -3
- package/dist/components/atoms/Inputs/components/HintText.cjs.map +1 -1
- package/dist/components/atoms/Inputs/components/HintText.d.ts +3 -8
- package/dist/components/atoms/Inputs/components/HintText.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/components/HintText.js +4 -3
- package/dist/components/atoms/Inputs/components/HintText.js.map +1 -1
- package/dist/components/atoms/Inputs/components/Label.cjs +4 -3
- package/dist/components/atoms/Inputs/components/Label.cjs.map +1 -1
- package/dist/components/atoms/Inputs/components/Label.d.ts +3 -8
- package/dist/components/atoms/Inputs/components/Label.d.ts.map +1 -1
- package/dist/components/atoms/Inputs/components/Label.js +4 -3
- package/dist/components/atoms/Inputs/components/Label.js.map +1 -1
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.cjs +35 -0
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.cjs.map +1 -0
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.d.ts +24 -0
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.js +33 -0
- package/dist/components/atoms/PhoneInput/components/PhoneInputCountrySelect.js.map +1 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs +100 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.cjs.map +1 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts +35 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js +98 -0
- package/dist/components/atoms/PhoneInput/hooks/usePhoneEntry.js.map +1 -0
- package/dist/components/atoms/PhoneInput/index.cjs +79 -0
- package/dist/components/atoms/PhoneInput/index.cjs.map +1 -0
- package/dist/components/atoms/PhoneInput/index.d.ts +48 -0
- package/dist/components/atoms/PhoneInput/index.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/index.js +77 -0
- package/dist/components/atoms/PhoneInput/index.js.map +1 -0
- package/dist/components/atoms/PhoneInput/phoneInput.types.d.ts +17 -0
- package/dist/components/atoms/PhoneInput/phoneInput.types.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs +304 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.cjs.map +1 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts +147 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.d.ts.map +1 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js +288 -0
- package/dist/components/atoms/PhoneInput/utilities/phoneInput.utils.js.map +1 -0
- package/dist/components/atoms/RadioButton/index.d.ts +1 -4
- package/dist/components/atoms/RadioButton/index.d.ts.map +1 -1
- package/dist/components/atoms/Radios/RadioButton/RadioButton.cjs +6 -4
- package/dist/components/atoms/Radios/RadioButton/RadioButton.cjs.map +1 -1
- package/dist/components/atoms/Radios/RadioButton/RadioButton.d.ts +2 -7
- package/dist/components/atoms/Radios/RadioButton/RadioButton.d.ts.map +1 -1
- package/dist/components/atoms/Radios/RadioButton/RadioButton.js +7 -5
- package/dist/components/atoms/Radios/RadioButton/RadioButton.js.map +1 -1
- package/dist/components/atoms/RatingStars/index.cjs +4 -3
- package/dist/components/atoms/RatingStars/index.cjs.map +1 -1
- package/dist/components/atoms/RatingStars/index.d.ts +3 -3
- package/dist/components/atoms/RatingStars/index.d.ts.map +1 -1
- package/dist/components/atoms/RatingStars/index.js +6 -5
- package/dist/components/atoms/RatingStars/index.js.map +1 -1
- package/dist/components/atoms/SearchInput/index.d.ts +1 -4
- package/dist/components/atoms/SearchInput/index.d.ts.map +1 -1
- package/dist/components/atoms/SocialButton/index.d.ts +1 -1
- package/dist/components/atoms/SocialButton/index.d.ts.map +1 -1
- package/dist/components/atoms/UtilityButton/index.cjs.map +1 -1
- package/dist/components/atoms/UtilityButton/index.d.ts +2 -2
- package/dist/components/atoms/UtilityButton/index.d.ts.map +1 -1
- package/dist/components/atoms/UtilityButton/index.js.map +1 -1
- package/dist/components/atoms/VerificationCodeInput/index.cjs +18 -18
- package/dist/components/atoms/VerificationCodeInput/index.cjs.map +1 -1
- package/dist/components/atoms/VerificationCodeInput/index.d.ts +10 -29
- package/dist/components/atoms/VerificationCodeInput/index.d.ts.map +1 -1
- package/dist/components/atoms/VerificationCodeInput/index.js +19 -19
- package/dist/components/atoms/VerificationCodeInput/index.js.map +1 -1
- package/dist/components/forms/Form/index.cjs +14 -11
- package/dist/components/forms/Form/index.cjs.map +1 -1
- package/dist/components/forms/Form/index.d.ts +9 -8
- package/dist/components/forms/Form/index.d.ts.map +1 -1
- package/dist/components/forms/Form/index.js +16 -13
- package/dist/components/forms/Form/index.js.map +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs +10 -1
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.cjs.map +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.d.ts.map +1 -1
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js +10 -1
- package/dist/components/forms/__internal__/formField/hooks/useFocusThroughSubmit.js.map +1 -1
- package/dist/components/forms/fields/FormPhoneInput/index.cjs +36 -0
- package/dist/components/forms/fields/FormPhoneInput/index.cjs.map +1 -0
- package/dist/components/forms/fields/FormPhoneInput/index.d.ts +19 -0
- package/dist/components/forms/fields/FormPhoneInput/index.d.ts.map +1 -0
- package/dist/components/forms/fields/FormPhoneInput/index.js +34 -0
- package/dist/components/forms/fields/FormPhoneInput/index.js.map +1 -0
- package/dist/components/forms/validation/index.cjs +25 -56
- package/dist/components/forms/validation/index.cjs.map +1 -1
- package/dist/components/forms/validation/index.d.ts +2 -12
- package/dist/components/forms/validation/index.d.ts.map +1 -1
- package/dist/components/forms/validation/index.js +1 -32
- package/dist/components/forms/validation/index.js.map +1 -1
- package/dist/components/forms/validation/phoneNumber/index.cjs +20 -0
- package/dist/components/forms/validation/phoneNumber/index.cjs.map +1 -0
- package/dist/components/forms/validation/phoneNumber/index.d.ts +14 -0
- package/dist/components/forms/validation/phoneNumber/index.d.ts.map +1 -0
- package/dist/components/forms/validation/phoneNumber/index.js +18 -0
- package/dist/components/forms/validation/phoneNumber/index.js.map +1 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs +34 -0
- package/dist/components/forms/validation/utilities/validation.utils.cjs.map +1 -1
- package/dist/components/forms/validation/utilities/validation.utils.d.ts +29 -1
- package/dist/components/forms/validation/utilities/validation.utils.d.ts.map +1 -1
- package/dist/components/forms/validation/utilities/validation.utils.js +33 -2
- package/dist/components/forms/validation/utilities/validation.utils.js.map +1 -1
- package/dist/components/forms/validation/validation.types.d.ts +10 -0
- package/dist/components/forms/validation/validation.types.d.ts.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.cjs +8 -6
- package/dist/components/molecules/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.d.ts +7 -5
- package/dist/components/molecules/ButtonGroup/index.d.ts.map +1 -1
- package/dist/components/molecules/ButtonGroup/index.js +12 -10
- package/dist/components/molecules/ButtonGroup/index.js.map +1 -1
- package/dist/components/molecules/EmptyState/index.cjs +33 -33
- package/dist/components/molecules/EmptyState/index.cjs.map +1 -1
- package/dist/components/molecules/EmptyState/index.d.ts +23 -24
- package/dist/components/molecules/EmptyState/index.d.ts.map +1 -1
- package/dist/components/molecules/EmptyState/index.js +36 -36
- package/dist/components/molecules/EmptyState/index.js.map +1 -1
- package/dist/components/molecules/Messaging/index.cjs +5 -3
- package/dist/components/molecules/Messaging/index.cjs.map +1 -1
- package/dist/components/molecules/Messaging/index.d.ts +3 -3
- package/dist/components/molecules/Messaging/index.d.ts.map +1 -1
- package/dist/components/molecules/Messaging/index.js +5 -3
- package/dist/components/molecules/Messaging/index.js.map +1 -1
- package/dist/components/molecules/SectionFooter/index.cjs +9 -6
- package/dist/components/molecules/SectionFooter/index.cjs.map +1 -1
- package/dist/components/molecules/SectionFooter/index.d.ts +5 -5
- package/dist/components/molecules/SectionFooter/index.d.ts.map +1 -1
- package/dist/components/molecules/SectionFooter/index.js +10 -7
- package/dist/components/molecules/SectionFooter/index.js.map +1 -1
- package/dist/components/molecules/SectionHeader/index.cjs +21 -15
- package/dist/components/molecules/SectionHeader/index.cjs.map +1 -1
- package/dist/components/molecules/SectionHeader/index.d.ts +11 -11
- package/dist/components/molecules/SectionHeader/index.d.ts.map +1 -1
- package/dist/components/molecules/SectionHeader/index.js +22 -16
- package/dist/components/molecules/SectionHeader/index.js.map +1 -1
- package/dist/components/molecules/Select/index.d.ts +2 -5
- package/dist/components/molecules/Select/index.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs +3 -2
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.d.ts +3 -3
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js +4 -3
- package/dist/components/molecules/Selects/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.cjs +5 -5
- package/dist/components/molecules/Selects/Select/Select.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.d.ts +3 -6
- package/dist/components/molecules/Selects/Select/Select.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/Select.js +6 -6
- package/dist/components/molecules/Selects/Select/Select.js.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs +7 -5
- package/dist/components/molecules/Selects/Select/components/Combobox.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.d.ts +3 -3
- package/dist/components/molecules/Selects/Select/components/Combobox.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Combobox.js +10 -8
- package/dist/components/molecules/Selects/Select/components/Combobox.js.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Popover.cjs +2 -3
- package/dist/components/molecules/Selects/Select/components/Popover.cjs.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Popover.d.ts.map +1 -1
- package/dist/components/molecules/Selects/Select/components/Popover.js +2 -3
- package/dist/components/molecules/Selects/Select/components/Popover.js.map +1 -1
- package/dist/components/molecules/Selects/components/SelectItem.cjs +2 -1
- package/dist/components/molecules/Selects/components/SelectItem.cjs.map +1 -1
- package/dist/components/molecules/Selects/components/SelectItem.d.ts.map +1 -1
- package/dist/components/molecules/Selects/components/SelectItem.js +2 -1
- package/dist/components/molecules/Selects/components/SelectItem.js.map +1 -1
- package/dist/components/molecules/Tabs/index.cjs +10 -7
- package/dist/components/molecules/Tabs/index.cjs.map +1 -1
- package/dist/components/molecules/Tabs/index.d.ts +12 -15
- package/dist/components/molecules/Tabs/index.d.ts.map +1 -1
- package/dist/components/molecules/Tabs/index.js +13 -10
- package/dist/components/molecules/Tabs/index.js.map +1 -1
- package/dist/components/molecules/Tags/Tag/Tag.cjs +4 -3
- package/dist/components/molecules/Tags/Tag/Tag.cjs.map +1 -1
- package/dist/components/molecules/Tags/Tag/Tag.d.ts +4 -3
- package/dist/components/molecules/Tags/Tag/Tag.d.ts.map +1 -1
- package/dist/components/molecules/Tags/Tag/Tag.js +5 -4
- package/dist/components/molecules/Tags/Tag/Tag.js.map +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.cjs +5 -3
- package/dist/components/molecules/Tags/TagGroup/TagGroup.cjs.map +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts +2 -3
- package/dist/components/molecules/Tags/TagGroup/TagGroup.d.ts.map +1 -1
- package/dist/components/molecules/Tags/TagGroup/TagGroup.js +6 -4
- package/dist/components/molecules/Tags/TagGroup/TagGroup.js.map +1 -1
- package/dist/components/molecules/TextArea/index.d.ts +1 -4
- package/dist/components/molecules/TextArea/index.d.ts.map +1 -1
- package/dist/components/organisms/Carousel/index.cjs +26 -14
- package/dist/components/organisms/Carousel/index.cjs.map +1 -1
- package/dist/components/organisms/Carousel/index.d.ts +8 -10
- package/dist/components/organisms/Carousel/index.d.ts.map +1 -1
- package/dist/components/organisms/Carousel/index.js +28 -16
- package/dist/components/organisms/Carousel/index.js.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs +3 -2
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts +2 -4
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js +4 -3
- package/dist/components/organisms/ColorPicker/components/ColorPickerField.js.map +1 -1
- package/dist/components/organisms/ColorPicker/index.cjs +3 -1
- package/dist/components/organisms/ColorPicker/index.cjs.map +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts +1 -1
- package/dist/components/organisms/ColorPicker/index.d.ts.map +1 -1
- package/dist/components/organisms/ColorPicker/index.js +7 -5
- package/dist/components/organisms/ColorPicker/index.js.map +1 -1
- package/dist/components/organisms/ColorPicker/providers/ColorPicker.provider.js +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs +5 -3
- package/dist/components/organisms/CommandMenu/components/CommandInput.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.d.ts +3 -5
- package/dist/components/organisms/CommandMenu/components/CommandInput.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/components/CommandInput.js +5 -3
- package/dist/components/organisms/CommandMenu/components/CommandInput.js.map +1 -1
- package/dist/components/organisms/CommandMenu/index.cjs +8 -6
- package/dist/components/organisms/CommandMenu/index.cjs.map +1 -1
- package/dist/components/organisms/CommandMenu/index.d.ts +4 -4
- package/dist/components/organisms/CommandMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/CommandMenu/index.js +9 -7
- package/dist/components/organisms/CommandMenu/index.js.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs +4 -2
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts +2 -4
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js +4 -2
- package/dist/components/organisms/DatePickers/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs +3 -2
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts +2 -4
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js +4 -3
- package/dist/components/organisms/DatePickers/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/organisms/DatePickers/RangeCalendar/RangeCalendar.js +2 -2
- package/dist/components/organisms/FileUpload/index.cjs +8 -6
- package/dist/components/organisms/FileUpload/index.cjs.map +1 -1
- package/dist/components/organisms/FileUpload/index.d.ts +7 -7
- package/dist/components/organisms/FileUpload/index.d.ts.map +1 -1
- package/dist/components/organisms/FileUpload/index.js +12 -10
- package/dist/components/organisms/FileUpload/index.js.map +1 -1
- package/dist/components/organisms/FilterBar/index.cjs +13 -9
- package/dist/components/organisms/FilterBar/index.cjs.map +1 -1
- package/dist/components/organisms/FilterBar/index.d.ts +7 -7
- package/dist/components/organisms/FilterBar/index.d.ts.map +1 -1
- package/dist/components/organisms/FilterBar/index.js +14 -10
- package/dist/components/organisms/FilterBar/index.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.cjs +4 -3
- package/dist/components/organisms/SidePanel/components/SidePanelContent.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.d.ts +12 -6
- package/dist/components/organisms/SidePanel/components/SidePanelContent.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelContent.js +4 -3
- package/dist/components/organisms/SidePanel/components/SidePanelContent.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.cjs +4 -3
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts +11 -6
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.js +4 -3
- package/dist/components/organisms/SidePanel/components/SidePanelFooter.js.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.cjs +12 -10
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.cjs.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.d.ts +8 -7
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.d.ts.map +1 -1
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.js +15 -13
- package/dist/components/organisms/SidePanel/components/SidePanelHeader.js.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.cjs +2 -1
- package/dist/components/organisms/SidebarNavigation/index.cjs.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.d.ts.map +1 -1
- package/dist/components/organisms/SidebarNavigation/index.js +2 -1
- package/dist/components/organisms/SidebarNavigation/index.js.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.cjs +8 -8
- package/dist/components/organisms/SlideoutMenu/index.cjs.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.d.ts +9 -18
- package/dist/components/organisms/SlideoutMenu/index.d.ts.map +1 -1
- package/dist/components/organisms/SlideoutMenu/index.js +9 -9
- package/dist/components/organisms/SlideoutMenu/index.js.map +1 -1
- package/dist/components/organisms/Table/index.cjs +15 -10
- package/dist/components/organisms/Table/index.cjs.map +1 -1
- package/dist/components/organisms/Table/index.d.ts +10 -19
- package/dist/components/organisms/Table/index.d.ts.map +1 -1
- package/dist/components/organisms/Table/index.js +18 -13
- package/dist/components/organisms/Table/index.js.map +1 -1
- package/dist/components/organisms/TextEditor/components/TextEditorExtensions.js +1 -1
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.cjs +5 -3
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.d.ts +2 -3
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.js +5 -3
- package/dist/components/organisms/TextEditor/components/TextEditorToolbar.js.map +1 -1
- package/dist/components/organisms/TextEditor/index.cjs +16 -9
- package/dist/components/organisms/TextEditor/index.cjs.map +1 -1
- package/dist/components/organisms/TextEditor/index.d.ts +7 -9
- package/dist/components/organisms/TextEditor/index.d.ts.map +1 -1
- package/dist/components/organisms/TextEditor/index.js +21 -14
- package/dist/components/organisms/TextEditor/index.js.map +1 -1
- package/dist/components/organisms/VideoPlayer/index.cjs +3 -2
- package/dist/components/organisms/VideoPlayer/index.cjs.map +1 -1
- package/dist/components/organisms/VideoPlayer/index.d.ts +1 -6
- package/dist/components/organisms/VideoPlayer/index.d.ts.map +1 -1
- package/dist/components/organisms/VideoPlayer/index.js +4 -3
- package/dist/components/organisms/VideoPlayer/index.js.map +1 -1
- package/dist/native/components/atoms/PhoneInput/index.d.ts +12 -0
- package/dist/native/components/forms/fields/FormPhoneInput/index.d.ts +12 -0
- package/dist/native/components/forms/validation/phoneNumber/index.d.ts +12 -0
- package/dist/utilities/__internal__/inertUtils/inert.utils.cjs +17 -0
- package/dist/utilities/__internal__/inertUtils/inert.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/inertUtils/inert.utils.d.ts +11 -0
- package/dist/utilities/__internal__/inertUtils/inert.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/inertUtils/inert.utils.js +17 -1
- package/dist/utilities/__internal__/inertUtils/inert.utils.js.map +1 -1
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs +20 -0
- package/dist/utilities/__internal__/refUtils/ref.utils.cjs.map +1 -1
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts +10 -1
- package/dist/utilities/__internal__/refUtils/ref.utils.d.ts.map +1 -1
- package/dist/utilities/__internal__/refUtils/ref.utils.js +20 -1
- package/dist/utilities/__internal__/refUtils/ref.utils.js.map +1 -1
- package/package.json +13 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { PhoneCountry, PhoneCountryCode } from '../phoneInput.types';
|
|
3
|
+
interface PhoneInputCountrySelectProps {
|
|
4
|
+
/** The chosen country. */
|
|
5
|
+
country: PhoneCountry;
|
|
6
|
+
/** Every country the field offers, in the order the list shows them. */
|
|
7
|
+
countries: PhoneCountry[];
|
|
8
|
+
/** Called with the country the user picks. */
|
|
9
|
+
onChange: (country: PhoneCountryCode) => void;
|
|
10
|
+
size: 'sm' | 'md' | 'lg';
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
/** Whether the field shows a label, which then also names the trigger, so two phone fields' triggers read apart. */
|
|
13
|
+
hasFieldLabel: boolean;
|
|
14
|
+
/** The bordered group around the trigger and the number, which the list lines up with and matches in width. */
|
|
15
|
+
groupRef: RefObject<HTMLDivElement | null>;
|
|
16
|
+
/** Ref for the list, which renders in a portal, so the field can tell focus moving into it from focus leaving. */
|
|
17
|
+
listRef: RefObject<HTMLDivElement | null>;
|
|
18
|
+
/** The field's resolved test id, which the trigger and each option derive theirs from. */
|
|
19
|
+
testId: string;
|
|
20
|
+
}
|
|
21
|
+
/** The country trigger at the start of a phone field, showing a flag and calling code, and the list of countries it opens. */
|
|
22
|
+
export declare const PhoneInputCountrySelect: ({ country, countries, onChange, size, isDisabled, hasFieldLabel, groupRef, listRef, testId, }: PhoneInputCountrySelectProps) => import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=PhoneInputCountrySelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhoneInputCountrySelect.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/components/PhoneInputCountrySelect.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQ1E,UAAU,4BAA4B;IACpC,0BAA0B;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,wEAAwE;IACxE,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,8CAA8C;IAC9C,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC9C,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oHAAoH;IACpH,aAAa,EAAE,OAAO,CAAC;IACvB,+GAA+G;IAC/G,QAAQ,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3C,kHAAkH;IAClH,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,0FAA0F;IAC1F,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,8HAA8H;AAC9H,eAAO,MAAM,uBAAuB,GAAI,+FAUrC,4BAA4B,gCAgF9B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ChevronDown, Check } from '@flipdish/ui-icons';
|
|
3
|
+
import { Flag } from '@flipdish/ui-library/components/atoms/Flag';
|
|
4
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
5
|
+
import { joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
6
|
+
import { useSlottedContext, LabelContext, Select, Button, SelectValue, ListBox, ListBoxItem } from 'react-aria-components';
|
|
7
|
+
import { listOptionStyles } from '../../../__internal__/listOption/listOption.styles.js';
|
|
8
|
+
import { ScrollClosingPopover } from '../../../__internal__/popover/ScrollClosingPopover.js';
|
|
9
|
+
|
|
10
|
+
const sizes = {
|
|
11
|
+
sm: { trigger: 'gap-1 py-2 pr-1 pl-3 text-sm', option: 'gap-2 p-2 pr-2.5 text-sm', check: 'size-4 stroke-[2.25px]' },
|
|
12
|
+
md: { trigger: 'gap-1 py-2 pr-1 pl-3 text-md', option: 'gap-2 p-2 pr-2.5 text-md', check: 'size-5' },
|
|
13
|
+
lg: { trigger: 'gap-1 py-2.5 pr-1 pl-3.5 text-md', option: 'gap-2 p-2.5 pl-2 text-md', check: 'size-5' },
|
|
14
|
+
};
|
|
15
|
+
/** The country trigger at the start of a phone field, showing a flag and calling code, and the list of countries it opens. */
|
|
16
|
+
const PhoneInputCountrySelect = ({ country, countries, onChange, size, isDisabled, hasFieldLabel, groupRef, listRef, testId, }) => {
|
|
17
|
+
// Read here, outside the select, where the context is the text field's own.
|
|
18
|
+
const fieldLabelId = useSlottedContext(LabelContext)?.id;
|
|
19
|
+
const handleSelectionChange = (key) => {
|
|
20
|
+
if (key !== null)
|
|
21
|
+
onChange(key);
|
|
22
|
+
};
|
|
23
|
+
return (jsxs(Select
|
|
24
|
+
// "Country code", not "Country", so it reads apart from an address's country field on the same page.
|
|
25
|
+
, { "aria-label": "Country code", "aria-labelledby": hasFieldLabel ? fieldLabelId : undefined, selectedKey: country.code, onSelectionChange: handleSelectionChange, isDisabled: isDisabled, className: "flex shrink-0 self-stretch", children: [jsxs(Button, { "data-testid": joinTestId(testId, 'country'), className: ({ isFocusVisible, isDisabled: isTriggerDisabled }) => cx('flex cursor-pointer items-center rounded-l-lg text-secondary outline-hidden', sizes[size].trigger, isFocusVisible && 'ring-2 ring-focus-ring ring-inset', isTriggerDisabled && 'cursor-not-allowed'), children: [jsxs(SelectValue, { className: "flex items-center gap-1.5 tabular-nums", children: [jsx(Flag, { code: country.code, size: "xs", label: "" }), jsx("span", { className: "sr-only", children: country.name }), "+", country.callingCode] }), jsx(ChevronDown, { "aria-hidden": "true", className: "size-4 shrink-0 stroke-[2.25px] text-fg-quaternary" })] }), jsx(ScrollClosingPopover
|
|
26
|
+
// Anchored to the whole field, not the trigger, so the list lines up with it and has room for a country's name.
|
|
27
|
+
, {
|
|
28
|
+
// Anchored to the whole field, not the trigger, so the list lines up with it and has room for a country's name.
|
|
29
|
+
triggerRef: groupRef, placement: "bottom start", containerPadding: 0, offset: 4, className: ({ isEntering, isExiting }) => cx('max-h-64! w-(--trigger-width) min-w-64', listOptionStyles.popover, isEntering && listOptionStyles.popoverEntering, isExiting && listOptionStyles.popoverExiting), children: jsx(ListBox, { ref: listRef, items: countries, className: "size-full outline-hidden", children: (option) => (jsx(ListBoxItem, { id: option.code, textValue: option.name, "data-testid": joinTestId(testId, `country-option-${option.code.toLowerCase()}`), className: cx(listOptionStyles.item, size === 'sm' ? 'px-1' : 'px-1.5'), children: ({ isFocused, isHovered, isSelected, isFocusVisible }) => (jsxs("div", { className: cx(listOptionStyles.row, sizes[size].option, (isFocused || isHovered || isSelected) && listOptionStyles.rowActive, isFocusVisible && listOptionStyles.rowFocusVisible), children: [jsx(Flag, { code: option.code, size: "xs", label: "" }), jsx("span", { className: "min-w-0 flex-1 truncate font-medium text-primary", children: option.name }), jsxs("span", { className: "text-tertiary tabular-nums", children: ["+", option.callingCode] }), isSelected && jsx(Check, { "aria-hidden": "true", className: cx('shrink-0 text-fg-brand-primary', sizes[size].check) })] })) })) }) })] }));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { PhoneInputCountrySelect };
|
|
33
|
+
//# sourceMappingURL=PhoneInputCountrySelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhoneInputCountrySelect.js","sources":["../../../../../src/components/atoms/PhoneInput/components/PhoneInputCountrySelect.tsx"],"sourcesContent":[null],"names":["_jsxs","AriaSelect","AriaButton","AriaSelectValue","_jsx","AriaListBox","AriaListBoxItem"],"mappings":";;;;;;;;;AAqBA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,0BAA0B,EAAE,KAAK,EAAE,wBAAwB,EAAE;AACpH,IAAA,EAAE,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE,MAAM,EAAE,0BAA0B,EAAE,KAAK,EAAE,QAAQ,EAAE;AACpG,IAAA,EAAE,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE,MAAM,EAAE,0BAA0B,EAAE,KAAK,EAAE,QAAQ,EAAE;CACzG;AAqBD;AACO,MAAM,uBAAuB,GAAG,CAAC,EACtC,OAAO,EACP,SAAS,EACT,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,aAAa,EACb,QAAQ,EACR,OAAO,EACP,MAAM,GACuB,KAAI;;IAEjC,MAAM,YAAY,GAAG,iBAAiB,CAAC,YAAY,CAAC,EAAE,EAAE;AACxD,IAAA,MAAM,qBAAqB,GAAG,CAAC,GAAe,KAAI;QAChD,IAAI,GAAG,KAAK,IAAI;YAAE,QAAQ,CAAC,GAAuB,CAAC;AACrD,IAAA,CAAC;IAED,QACEA,KAACC;;AAEY,MAAA,EAAA,YAAA,EAAA,cAAc,EAAA,iBAAA,EACR,aAAa,GAAG,YAAY,GAAG,SAAS,EACzD,WAAW,EAAE,OAAO,CAAC,IAAI,EACzB,iBAAiB,EAAE,qBAAqB,EACxC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAC,4BAA4B,EAAA,QAAA,EAAA,CAEtCD,IAAA,CAACE,MAAU,EAAA,EAAA,aAAA,EACI,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1C,SAAS,EAAE,CAAC,EAAE,cAAc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ils');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var phoneInput_utils = require('../utilities/phoneInput.utils.cjs');
|
|
6
|
+
|
|
7
|
+
const entryOf = (value, country, allowed) => {
|
|
8
|
+
// A value that is not an international number is shown as it came, and one with no digits, such as a note, keeps its text.
|
|
9
|
+
const entry = phoneInput_utils.fromInternational(value, country, allowed) ?? { country, text: phoneInput_utils.formatTyped(country, phoneInput_utils.significantChars(value)) || value };
|
|
10
|
+
return { ...entry, value };
|
|
11
|
+
};
|
|
12
|
+
const shownFor = (value, stored, reported, allowed) => {
|
|
13
|
+
if (stored.value === value)
|
|
14
|
+
return stored;
|
|
15
|
+
if (reported?.value === value)
|
|
16
|
+
return reported;
|
|
17
|
+
return entryOf(value, stored.country, allowed);
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Holds what a phone field shows, a country and a national number, beside the one international number it reports.
|
|
21
|
+
* The two are kept apart because the shown text carries what the value cannot, such as a trunk zero typed before any
|
|
22
|
+
* other digit, so it is rebuilt from the value only when the value changes from outside.
|
|
23
|
+
*
|
|
24
|
+
* @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
|
|
25
|
+
* @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
|
|
26
|
+
* gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
|
|
27
|
+
* calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
|
|
28
|
+
* field started with, as a form reset does.
|
|
29
|
+
*/
|
|
30
|
+
const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }) => {
|
|
31
|
+
const [value, setValue] = utils.useControlledState(valueProp, defaultValue ?? '', onChange);
|
|
32
|
+
// A controlled field resets to the value it mounted with, as react-aria's own fields do.
|
|
33
|
+
const [initialValue] = React.useState(value);
|
|
34
|
+
const [stored, setStored] = React.useState(() => entryOf(value, defaultCountry, allowed));
|
|
35
|
+
// What the field last reported, kept for an owner that hands the value back a render late: rebuilt from the value alone, the text would lose its trunk zero.
|
|
36
|
+
const [reported, setReported] = React.useState();
|
|
37
|
+
// Whether the field has settled on a country, by holding a number or by the user picking one; until then an empty field follows `defaultCountry`.
|
|
38
|
+
const [isCountrySettled, setIsCountrySettled] = React.useState(value !== '');
|
|
39
|
+
let shown = shownFor(value, stored, reported, allowed);
|
|
40
|
+
// Once the owner holds the reported value, `stored` keeps its text; a report kept past that would bring the old edit back after a reset to that value.
|
|
41
|
+
const isAcknowledged = value === reported?.value;
|
|
42
|
+
// A value from outside, such as a loaded record or a reset, ends the edit the report belonged to; one still as it was before the edit does not.
|
|
43
|
+
const isReplaced = shown !== stored && value !== reported?.from;
|
|
44
|
+
if (reported && (isAcknowledged || isReplaced))
|
|
45
|
+
setReported(undefined);
|
|
46
|
+
// A number set from outside settles the country as typing does; the number a reset is replacing, still held by a late owner, does not.
|
|
47
|
+
if (!isCountrySettled && shown.value !== '' && value !== reported?.from)
|
|
48
|
+
setIsCountrySettled(true);
|
|
49
|
+
if (!isCountrySettled && shown.text === '' && shown.value === '' && shown.country !== defaultCountry)
|
|
50
|
+
shown = { ...shown, country: defaultCountry };
|
|
51
|
+
if (shown !== stored)
|
|
52
|
+
setStored(shown);
|
|
53
|
+
const show = (entry) => {
|
|
54
|
+
const next = { ...entry, value: phoneInput_utils.toInternational(entry) };
|
|
55
|
+
setStored(next);
|
|
56
|
+
setReported({ ...next, from: value });
|
|
57
|
+
if (next.value !== value)
|
|
58
|
+
setValue(next.value);
|
|
59
|
+
};
|
|
60
|
+
const type = (edit) => {
|
|
61
|
+
const { significant, position } = phoneInput_utils.editedDigits(edit);
|
|
62
|
+
const entry = phoneInput_utils.entryFor(shown.country, significant, position, allowed);
|
|
63
|
+
// A calling code still being typed stays as written, and the number the field reports stands until it is whole.
|
|
64
|
+
if (!entry) {
|
|
65
|
+
setStored({ ...shown, text: edit.next, isPending: true });
|
|
66
|
+
return edit.caret;
|
|
67
|
+
}
|
|
68
|
+
if (entry.text !== '' || entry.country !== shown.country)
|
|
69
|
+
setIsCountrySettled(true);
|
|
70
|
+
show(entry);
|
|
71
|
+
return phoneInput_utils.caretAfter(entry.text, entry.position);
|
|
72
|
+
};
|
|
73
|
+
const chooseCountry = (country) => {
|
|
74
|
+
setIsCountrySettled(true);
|
|
75
|
+
// A half-typed calling code has not touched the value, so the digits to keep are the ones the value holds.
|
|
76
|
+
const base = shown.isPending ? entryOf(value, shown.country, allowed) : shown;
|
|
77
|
+
const typed = phoneInput_utils.significantChars(base.text);
|
|
78
|
+
// Only the national number moves, without the old trunk prefix, as if typed in the new country; a lone trunk zero moves as typed.
|
|
79
|
+
const international = phoneInput_utils.toInternational(base) || (typed.startsWith('+') ? typed : '');
|
|
80
|
+
const digits = international ? phoneInput_utils.nationalDigits(international) : typed;
|
|
81
|
+
show({ country, text: phoneInput_utils.formatTyped(country, digits) });
|
|
82
|
+
};
|
|
83
|
+
const settle = () => {
|
|
84
|
+
if (shown.isPending)
|
|
85
|
+
setStored(entryOf(value, shown.country, allowed));
|
|
86
|
+
};
|
|
87
|
+
const reset = () => {
|
|
88
|
+
const initial = defaultValue ?? initialValue;
|
|
89
|
+
const entry = entryOf(initial, defaultCountry, allowed);
|
|
90
|
+
// Reported first, as an edit is, so a late owner or a React 18 legacy root cannot rebuild the entry from the number being replaced.
|
|
91
|
+
setReported({ ...entry, from: value });
|
|
92
|
+
setStored(entry);
|
|
93
|
+
setValue(initial);
|
|
94
|
+
setIsCountrySettled(initial !== '');
|
|
95
|
+
};
|
|
96
|
+
return { country: shown.country, text: shown.text, value, type, chooseCountry, settle, reset };
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.usePhoneEntry = usePhoneEntry;
|
|
100
|
+
//# sourceMappingURL=usePhoneEntry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneEntry.cjs","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"sourcesContent":[null],"names":["fromInternational","formatTyped","significantChars","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AAM,GAAG,MAAK;QAClB,IAAI,KAAK,CAAC,SAAS;AAAE,YAAA,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACxE,IAAA,CAAC;IAED,MAAM,KAAK,GAAG,MAAK;AACjB,QAAA,MAAM,OAAO,GAAG,YAAY,IAAI,YAAY;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC;;QAEvD,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC;QAChB,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,mBAAmB,CAAC,OAAO,KAAK,EAAE,CAAC;AACrC,IAAA,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE;AAChG;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { PhoneCountryCode } from '../phoneInput.types';
|
|
2
|
+
import { type PhoneEdit } from '../utilities/phoneInput.utils';
|
|
3
|
+
export interface PhoneEntryOptions {
|
|
4
|
+
/** The international number, when the field is controlled. */
|
|
5
|
+
value?: string;
|
|
6
|
+
/** The international number the field starts with, when it is not. */
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** Called with the international number as it changes. */
|
|
9
|
+
onChange?: (value: string) => void;
|
|
10
|
+
/** The country an empty field shows, and follows as it changes, until the field first holds a number or the user picks a country. */
|
|
11
|
+
defaultCountry: PhoneCountryCode;
|
|
12
|
+
/** The countries the field offers, when the app restricts them. */
|
|
13
|
+
allowed?: readonly PhoneCountryCode[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Holds what a phone field shows, a country and a national number, beside the one international number it reports.
|
|
17
|
+
* The two are kept apart because the shown text carries what the value cannot, such as a trunk zero typed before any
|
|
18
|
+
* other digit, so it is rebuilt from the value only when the value changes from outside.
|
|
19
|
+
*
|
|
20
|
+
* @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
|
|
21
|
+
* @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
|
|
22
|
+
* gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
|
|
23
|
+
* calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
|
|
24
|
+
* field started with, as a form reset does.
|
|
25
|
+
*/
|
|
26
|
+
export declare const usePhoneEntry: ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }: PhoneEntryOptions) => {
|
|
27
|
+
country: import("libphonenumber-js/min").CountryCode;
|
|
28
|
+
text: string;
|
|
29
|
+
value: string;
|
|
30
|
+
type: (edit: PhoneEdit) => number;
|
|
31
|
+
chooseCountry: (country: PhoneCountryCode) => void;
|
|
32
|
+
settle: () => void;
|
|
33
|
+
reset: () => void;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=usePhoneEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePhoneEntry.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/PhoneInput/hooks/usePhoneEntry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAc,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAOL,KAAK,SAAS,EAGf,MAAM,+BAA+B,CAAC;AAEvC,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,qIAAqI;IACrI,cAAc,EAAE,gBAAgB,CAAC;IACjC,mEAAmE;IACnE,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACvC;AA0BD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GAAI,uEAAuE,iBAAiB;;;;iBA4BhG,SAAS,KAAG,MAAM;6BAaN,gBAAgB;;;CA0BjD,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useControlledState } from '@react-stately/utils';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { fromInternational, formatTyped, significantChars, toInternational, nationalDigits, editedDigits, entryFor, caretAfter } from '../utilities/phoneInput.utils.js';
|
|
4
|
+
|
|
5
|
+
const entryOf = (value, country, allowed) => {
|
|
6
|
+
// A value that is not an international number is shown as it came, and one with no digits, such as a note, keeps its text.
|
|
7
|
+
const entry = fromInternational(value, country, allowed) ?? { country, text: formatTyped(country, significantChars(value)) || value };
|
|
8
|
+
return { ...entry, value };
|
|
9
|
+
};
|
|
10
|
+
const shownFor = (value, stored, reported, allowed) => {
|
|
11
|
+
if (stored.value === value)
|
|
12
|
+
return stored;
|
|
13
|
+
if (reported?.value === value)
|
|
14
|
+
return reported;
|
|
15
|
+
return entryOf(value, stored.country, allowed);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Holds what a phone field shows, a country and a national number, beside the one international number it reports.
|
|
19
|
+
* The two are kept apart because the shown text carries what the value cannot, such as a trunk zero typed before any
|
|
20
|
+
* other digit, so it is rebuilt from the value only when the value changes from outside.
|
|
21
|
+
*
|
|
22
|
+
* @param options The field's value, its change handler, the country to start on and any limit on the countries offered.
|
|
23
|
+
* @returns The `country` and `text` to show, the international `value`, `type` to apply an edit to the text, which
|
|
24
|
+
* gives back where the cursor belongs, `chooseCountry` to switch country and keep the digits, `settle` to drop a
|
|
25
|
+
* calling code left half typed when the user leaves the field, and `reset` to return to the number and country the
|
|
26
|
+
* field started with, as a form reset does.
|
|
27
|
+
*/
|
|
28
|
+
const usePhoneEntry = ({ value: valueProp, defaultValue, onChange, defaultCountry, allowed }) => {
|
|
29
|
+
const [value, setValue] = useControlledState(valueProp, defaultValue ?? '', onChange);
|
|
30
|
+
// A controlled field resets to the value it mounted with, as react-aria's own fields do.
|
|
31
|
+
const [initialValue] = useState(value);
|
|
32
|
+
const [stored, setStored] = useState(() => entryOf(value, defaultCountry, allowed));
|
|
33
|
+
// What the field last reported, kept for an owner that hands the value back a render late: rebuilt from the value alone, the text would lose its trunk zero.
|
|
34
|
+
const [reported, setReported] = useState();
|
|
35
|
+
// Whether the field has settled on a country, by holding a number or by the user picking one; until then an empty field follows `defaultCountry`.
|
|
36
|
+
const [isCountrySettled, setIsCountrySettled] = useState(value !== '');
|
|
37
|
+
let shown = shownFor(value, stored, reported, allowed);
|
|
38
|
+
// Once the owner holds the reported value, `stored` keeps its text; a report kept past that would bring the old edit back after a reset to that value.
|
|
39
|
+
const isAcknowledged = value === reported?.value;
|
|
40
|
+
// A value from outside, such as a loaded record or a reset, ends the edit the report belonged to; one still as it was before the edit does not.
|
|
41
|
+
const isReplaced = shown !== stored && value !== reported?.from;
|
|
42
|
+
if (reported && (isAcknowledged || isReplaced))
|
|
43
|
+
setReported(undefined);
|
|
44
|
+
// A number set from outside settles the country as typing does; the number a reset is replacing, still held by a late owner, does not.
|
|
45
|
+
if (!isCountrySettled && shown.value !== '' && value !== reported?.from)
|
|
46
|
+
setIsCountrySettled(true);
|
|
47
|
+
if (!isCountrySettled && shown.text === '' && shown.value === '' && shown.country !== defaultCountry)
|
|
48
|
+
shown = { ...shown, country: defaultCountry };
|
|
49
|
+
if (shown !== stored)
|
|
50
|
+
setStored(shown);
|
|
51
|
+
const show = (entry) => {
|
|
52
|
+
const next = { ...entry, value: toInternational(entry) };
|
|
53
|
+
setStored(next);
|
|
54
|
+
setReported({ ...next, from: value });
|
|
55
|
+
if (next.value !== value)
|
|
56
|
+
setValue(next.value);
|
|
57
|
+
};
|
|
58
|
+
const type = (edit) => {
|
|
59
|
+
const { significant, position } = editedDigits(edit);
|
|
60
|
+
const entry = entryFor(shown.country, significant, position, allowed);
|
|
61
|
+
// A calling code still being typed stays as written, and the number the field reports stands until it is whole.
|
|
62
|
+
if (!entry) {
|
|
63
|
+
setStored({ ...shown, text: edit.next, isPending: true });
|
|
64
|
+
return edit.caret;
|
|
65
|
+
}
|
|
66
|
+
if (entry.text !== '' || entry.country !== shown.country)
|
|
67
|
+
setIsCountrySettled(true);
|
|
68
|
+
show(entry);
|
|
69
|
+
return caretAfter(entry.text, entry.position);
|
|
70
|
+
};
|
|
71
|
+
const chooseCountry = (country) => {
|
|
72
|
+
setIsCountrySettled(true);
|
|
73
|
+
// A half-typed calling code has not touched the value, so the digits to keep are the ones the value holds.
|
|
74
|
+
const base = shown.isPending ? entryOf(value, shown.country, allowed) : shown;
|
|
75
|
+
const typed = significantChars(base.text);
|
|
76
|
+
// Only the national number moves, without the old trunk prefix, as if typed in the new country; a lone trunk zero moves as typed.
|
|
77
|
+
const international = toInternational(base) || (typed.startsWith('+') ? typed : '');
|
|
78
|
+
const digits = international ? nationalDigits(international) : typed;
|
|
79
|
+
show({ country, text: formatTyped(country, digits) });
|
|
80
|
+
};
|
|
81
|
+
const settle = () => {
|
|
82
|
+
if (shown.isPending)
|
|
83
|
+
setStored(entryOf(value, shown.country, allowed));
|
|
84
|
+
};
|
|
85
|
+
const reset = () => {
|
|
86
|
+
const initial = defaultValue ?? initialValue;
|
|
87
|
+
const entry = entryOf(initial, defaultCountry, allowed);
|
|
88
|
+
// Reported first, as an edit is, so a late owner or a React 18 legacy root cannot rebuild the entry from the number being replaced.
|
|
89
|
+
setReported({ ...entry, from: value });
|
|
90
|
+
setStored(entry);
|
|
91
|
+
setValue(initial);
|
|
92
|
+
setIsCountrySettled(initial !== '');
|
|
93
|
+
};
|
|
94
|
+
return { country: shown.country, text: shown.text, value, type, chooseCountry, settle, reset };
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { usePhoneEntry };
|
|
98
|
+
//# sourceMappingURL=usePhoneEntry.js.map
|
|
@@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C,EAAE,CAAC;AACvD,IAAA,CAAC;IAED,MAAM,MAAM,GAAG,MAAK;QAClB,IAAI,KAAK,CAAC,SAAS;AAAE,YAAA,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AACxE,IAAA,CAAC;IAED,MAAM,KAAK,GAAG,MAAK;AACjB,QAAA,MAAM,OAAO,GAAG,YAAY,IAAI,YAAY;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC;;QAEvD,WAAW,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACtC,SAAS,CAAC,KAAK,CAAC;QAChB,QAAQ,CAAC,OAAO,CAAC;AACjB,QAAA,mBAAmB,CAAC,OAAO,KAAK,EAAE,CAAC;AACrC,IAAA,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE;AAChG;;"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var uiIcons = require('@flipdish/ui-icons');
|
|
5
|
+
var Inputs = require('@flipdish/ui-library/components/atoms/Inputs');
|
|
6
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
7
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
8
|
+
var utils = require('@react-aria/utils');
|
|
9
|
+
var React = require('react');
|
|
10
|
+
var reactAriaComponents = require('react-aria-components');
|
|
11
|
+
var PhoneInputCountrySelect = require('./components/PhoneInputCountrySelect.cjs');
|
|
12
|
+
var usePhoneEntry = require('./hooks/usePhoneEntry.cjs');
|
|
13
|
+
var phoneInput_utils = require('./utilities/phoneInput.utils.cjs');
|
|
14
|
+
|
|
15
|
+
const sizes = {
|
|
16
|
+
sm: { input: 'py-2 pr-3 pl-1.5 text-sm', invalid: 'pr-9', icon: 'right-3' },
|
|
17
|
+
md: { input: 'py-2 pr-3 pl-1.5 text-md', invalid: 'pr-9', icon: 'right-3' },
|
|
18
|
+
lg: { input: 'py-2.5 pr-3.5 pl-1.5 text-md', invalid: 'pr-9.5', icon: 'right-3.5' },
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A phone number field with a country picker: the user chooses a country and types the number the way it is written
|
|
22
|
+
* there, and the field reports one international number. Reach for it wherever a phone number is collected; it needs
|
|
23
|
+
* the optional `libphonenumber-js` package.
|
|
24
|
+
*
|
|
25
|
+
* @summary phone number field with a country picker
|
|
26
|
+
*/
|
|
27
|
+
const PhoneInput = React.forwardRef(({ label, hint, size = 'md', value: valueProp, defaultValue, onChange, defaultCountry, countries: allowedCountries, onCountryChange, onBlur, groupRef: groupRefProp, placeholder, hideRequiredIndicator, name, autoComplete = 'tel', className, 'data-testid': dataTestId, ...props }, ref) => {
|
|
28
|
+
const rootTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'phone-input', rootName: 'phone-input' });
|
|
29
|
+
const { locale } = reactAriaComponents.useLocale();
|
|
30
|
+
// Keyed on the codes, so an array written inline, new each render, does not rebuild the list.
|
|
31
|
+
const countriesKey = allowedCountries?.join(',');
|
|
32
|
+
const allowed = React.useMemo(() => phoneInput_utils.offeredCountries(countriesKey), [countriesKey]);
|
|
33
|
+
const options = React.useMemo(() => phoneInput_utils.countryOptions(locale, allowed), [locale, allowed]);
|
|
34
|
+
const { country, text, value, type, chooseCountry, settle, reset } = usePhoneEntry.usePhoneEntry({
|
|
35
|
+
value: valueProp,
|
|
36
|
+
defaultValue,
|
|
37
|
+
onChange,
|
|
38
|
+
defaultCountry: phoneInput_utils.startingCountry(defaultCountry, locale, allowed),
|
|
39
|
+
allowed,
|
|
40
|
+
});
|
|
41
|
+
const chosen = React.useMemo(() => phoneInput_utils.countryOptions(locale, [country])[0], [locale, country]);
|
|
42
|
+
const groupRef = React.useRef(null);
|
|
43
|
+
const mergedGroupRef = React.useMemo(() => utils.mergeRefs(groupRef, groupRefProp), [groupRefProp]);
|
|
44
|
+
const listRef = React.useRef(null);
|
|
45
|
+
const inputRef = React.useRef(null);
|
|
46
|
+
const mergedRef = React.useMemo(() => utils.mergeRefs(inputRef, ref), [ref]);
|
|
47
|
+
// The text field resets only the text it is handed, so the number, the country and the posted value reset here.
|
|
48
|
+
utils.useFormReset(inputRef, undefined, reset);
|
|
49
|
+
// Reformatting moves the text under the cursor, and the browser then drops it at the end: put back beside the digit it was at.
|
|
50
|
+
const caret = React.useRef(null);
|
|
51
|
+
const handleChange = (event) => {
|
|
52
|
+
const { value: next, selectionStart } = event.target;
|
|
53
|
+
const { inputType } = event.nativeEvent;
|
|
54
|
+
caret.current = type({ previous: text, next, caret: selectionStart ?? next.length, inputType });
|
|
55
|
+
};
|
|
56
|
+
React.useLayoutEffect(() => {
|
|
57
|
+
if (caret.current === null)
|
|
58
|
+
return;
|
|
59
|
+
inputRef.current?.setSelectionRange(caret.current, caret.current);
|
|
60
|
+
caret.current = null;
|
|
61
|
+
});
|
|
62
|
+
// Moving between the number, the trigger and its list stays inside the field; the list renders in a portal, so it is checked apart.
|
|
63
|
+
const handleBlur = (event) => {
|
|
64
|
+
if (phoneInput_utils.isFocusInside(event.relatedTarget, [groupRef.current, listRef.current]))
|
|
65
|
+
return;
|
|
66
|
+
settle();
|
|
67
|
+
onBlur?.(event);
|
|
68
|
+
};
|
|
69
|
+
const handleCountryChange = (code) => {
|
|
70
|
+
chooseCountry(code);
|
|
71
|
+
onCountryChange?.(code);
|
|
72
|
+
};
|
|
73
|
+
const { isDisabled, isReadOnly } = props;
|
|
74
|
+
return (jsxRuntime.jsx(Inputs.TextField, { ...props, value: text, type: "tel", autoComplete: autoComplete, size: size, "data-testid": rootTestId, className: className, children: ({ isInvalid, isRequired }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [label && (jsxRuntime.jsx(Inputs.Label, { isRequired: hideRequiredIndicator ? false : isRequired, isInvalid: isInvalid, children: label })), jsxRuntime.jsxs(reactAriaComponents.Group, { ref: mergedGroupRef, onBlur: handleBlur, isDisabled: isDisabled, isInvalid: isInvalid, className: ({ isFocusWithin }) => cx.cx('group/input relative flex w-full flex-row items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary transition-shadow duration-100 ease-linear ring-inset', isFocusWithin && !isDisabled && 'ring-2 ring-brand', isDisabled && 'cursor-not-allowed opacity-50', isInvalid && 'ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error'), children: [jsxRuntime.jsx(PhoneInputCountrySelect.PhoneInputCountrySelect, { country: chosen, countries: options, onChange: handleCountryChange, size: size, isDisabled: isDisabled || isReadOnly, hasFieldLabel: Boolean(label), groupRef: groupRef, listRef: listRef, testId: rootTestId }), jsxRuntime.jsx(reactAriaComponents.Input, { ref: mergedRef, onChange: handleChange, placeholder: placeholder ?? phoneInput_utils.exampleNumber(country), "data-testid": testIdUtils.joinTestId(rootTestId, 'input'), className: cx.cx('m-0 w-full min-w-0 bg-transparent text-primary tabular-nums ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary disabled:cursor-not-allowed', sizes[size].input, isInvalid && sizes[size].invalid) }), isInvalid && (jsxRuntime.jsx(uiIcons.InfoCircle, { className: cx.cx('pointer-events-none absolute size-4 stroke-[2.25px] text-fg-error-secondary', sizes[size].icon) }))] }), hint && jsxRuntime.jsx(Inputs.HintText, { isInvalid: isInvalid, children: hint }), name && jsxRuntime.jsx("input", { type: "hidden", name: name, value: value, form: props.form, disabled: isDisabled })] })) }));
|
|
75
|
+
});
|
|
76
|
+
PhoneInput.displayName = 'PhoneInput';
|
|
77
|
+
|
|
78
|
+
exports.PhoneInput = PhoneInput;
|
|
79
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/PhoneInput/index.tsx"],"sourcesContent":[null],"names":["forwardRef","useResolvedTestId","useLocale","useMemo","offeredCountries","countryOptions","usePhoneEntry","startingCountry","useRef","mergeRefs","useFormReset","useLayoutEffect","isFocusInside","_jsx","TextField","_jsxs","_Fragment","Label","AriaGroup","cx","PhoneInputCountrySelect","AriaInput","exampleNumber","joinTestId","InfoCircle","HintText"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;AAC3E,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;AAC3E,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,8BAA8B,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE;CACpF;AAuDD;;;;;;AAMG;AACI,MAAM,UAAU,GAAGA,gBAAU,CAClC,CACE,EACE,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EACf,MAAM,EACN,QAAQ,EAAE,YAAY,EACtB,WAAW,EACX,qBAAqB,EACrB,IAAI,EACJ,YAAY,GAAG,KAAK,EACpB,SAAS,EACT,aAAa,EAAE,UAAU,EACzB,GAAG,KAAK,EACT,EACD,GAAG,KACD;AACF,IAAA,MAAM,UAAU,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC;AAC7G,IAAA,MAAM,EAAE,MAAM,EAAE,GAAGC,6BAAS,EAAE;;IAE9B,MAAM,YAAY,GAAG,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OAAO,CACjC,EAAA,CACD,EAED,SAAS,KACRN,cAAA,CAACW,kBAAU,EAAA,EAAC,SAAS,EAAEL,KAAE,CAAC,6EAA6E,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,CAC/H,CAAA,EAAA,CACS,EAEX,IAAI,IAAIN,cAAA,CAACY,eAAQ,IAAC,SAAS,EAAE,SAAS,EAAA,QAAA,EAAG,IAAI,EAAA,CAAY,EAGzD,IAAI,IAAIZ,cAAA,CAAA,OAAA,EAAA,EAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAA,CAAI,CAAA,EAAA,CACjG,CACJ,EAAA,CACS;AAEhB,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { CountryCode } from '@flipdish/ui-library/components/atoms/Flag';
|
|
2
|
+
import { type FocusEvent, type ReactNode, type Ref } from 'react';
|
|
3
|
+
import type { TextFieldProps as AriaTextFieldProps } from 'react-aria-components';
|
|
4
|
+
export interface PhoneInputProps extends Omit<AriaTextFieldProps, 'value' | 'defaultValue' | 'onChange' | 'type' | 'inputMode' | 'children' | 'validate' | 'pattern' | 'minLength' | 'maxLength' | 'onFocus' | 'onFocusChange'> {
|
|
5
|
+
/** Label text above the field; it names the number input. When omitted, pass `aria-label`. */
|
|
6
|
+
label?: string;
|
|
7
|
+
/** Helper text beneath the field, read out as its description; shown as the error message while the field is invalid. */
|
|
8
|
+
hint?: ReactNode;
|
|
9
|
+
/** Sets the field's height, padding and text size. */
|
|
10
|
+
size?: 'sm' | 'md' | 'lg';
|
|
11
|
+
/** The number in international form, such as `+353861234567`, when the field is controlled; `''` for none. */
|
|
12
|
+
value?: string;
|
|
13
|
+
/** The international number the field starts with, when it is not controlled. */
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
/** Called with the international number as it is typed, as far as it goes, and with `''` once it is cleared. */
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* The country an empty field shows until the user picks one, and follows while the field stays empty. Without it, the
|
|
19
|
+
* region the user's locale names, or Ireland; with `countries`, only a country in that list.
|
|
20
|
+
*/
|
|
21
|
+
defaultCountry?: CountryCode;
|
|
22
|
+
/**
|
|
23
|
+
* Limits the list to these countries; every country without it. Without `defaultCountry`, the field starts on the
|
|
24
|
+
* locale's region when it is listed, else on the first code given. A number from another country stays as written.
|
|
25
|
+
*/
|
|
26
|
+
countries?: readonly CountryCode[];
|
|
27
|
+
/** Called with the country the user picks from the list, after `onChange` has the number it gives. */
|
|
28
|
+
onCountryChange?: (country: CountryCode) => void;
|
|
29
|
+
/** Called once focus leaves the whole field: the number, the country trigger and its open list. */
|
|
30
|
+
onBlur?: (event: FocusEvent<Element>) => void;
|
|
31
|
+
/** Ref attached to the bordered group that holds the country trigger and the number. */
|
|
32
|
+
groupRef?: Ref<HTMLDivElement>;
|
|
33
|
+
/** Replaces the example number shown while the field is empty. */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
/** Hides the asterisk a required field shows beside its label. */
|
|
36
|
+
hideRequiredIndicator?: boolean;
|
|
37
|
+
/** Overrides the root `data-testid` (defaults to `fd-phone-input`). The country trigger, its options and the input derive theirs from it. */
|
|
38
|
+
'data-testid'?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A phone number field with a country picker: the user chooses a country and types the number the way it is written
|
|
42
|
+
* there, and the field reports one international number. Reach for it wherever a phone number is collected; it needs
|
|
43
|
+
* the optional `libphonenumber-js` package.
|
|
44
|
+
*
|
|
45
|
+
* @summary phone number field with a country picker
|
|
46
|
+
*/
|
|
47
|
+
export declare const PhoneInput: import("react").ForwardRefExoticComponent<PhoneInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/PhoneInput/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4CAA4C,CAAC;AAK9E,OAAO,EAAoB,KAAK,UAAU,EAAc,KAAK,SAAS,EAAE,KAAK,GAAG,EAAoC,MAAM,OAAO,CAAC;AAClI,OAAO,KAAK,EAAE,cAAc,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAclF,MAAM,WAAW,eACf,SAAQ,IAAI,CACV,kBAAkB,EAChB,OAAO,GACP,cAAc,GACd,UAAU,GACV,MAAM,GACN,WAAW,GACX,UAAU,GACV,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,GACX,SAAS,GACT,eAAe,CAClB;IACD,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yHAAyH;IACzH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,sDAAsD;IACtD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gHAAgH;IAChH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,cAAc,CAAC,EAAE,WAAW,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACnC,sGAAsG;IACtG,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACjD,mGAAmG;IACnG,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;IAC9C,wFAAwF;IACxF,QAAQ,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/B,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,6IAA6I;IAC7I,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,8GAwItB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { InfoCircle } from '@flipdish/ui-icons';
|
|
3
|
+
import { TextField, Label, HintText } from '@flipdish/ui-library/components/atoms/Inputs';
|
|
4
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
5
|
+
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
6
|
+
import { mergeRefs, useFormReset } from '@react-aria/utils';
|
|
7
|
+
import { forwardRef, useMemo, useRef, useLayoutEffect } from 'react';
|
|
8
|
+
import { useLocale, Group, Input } from 'react-aria-components';
|
|
9
|
+
import { PhoneInputCountrySelect } from './components/PhoneInputCountrySelect.js';
|
|
10
|
+
import { usePhoneEntry } from './hooks/usePhoneEntry.js';
|
|
11
|
+
import { offeredCountries, countryOptions, startingCountry, exampleNumber, isFocusInside } from './utilities/phoneInput.utils.js';
|
|
12
|
+
|
|
13
|
+
const sizes = {
|
|
14
|
+
sm: { input: 'py-2 pr-3 pl-1.5 text-sm', invalid: 'pr-9', icon: 'right-3' },
|
|
15
|
+
md: { input: 'py-2 pr-3 pl-1.5 text-md', invalid: 'pr-9', icon: 'right-3' },
|
|
16
|
+
lg: { input: 'py-2.5 pr-3.5 pl-1.5 text-md', invalid: 'pr-9.5', icon: 'right-3.5' },
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A phone number field with a country picker: the user chooses a country and types the number the way it is written
|
|
20
|
+
* there, and the field reports one international number. Reach for it wherever a phone number is collected; it needs
|
|
21
|
+
* the optional `libphonenumber-js` package.
|
|
22
|
+
*
|
|
23
|
+
* @summary phone number field with a country picker
|
|
24
|
+
*/
|
|
25
|
+
const PhoneInput = forwardRef(({ label, hint, size = 'md', value: valueProp, defaultValue, onChange, defaultCountry, countries: allowedCountries, onCountryChange, onBlur, groupRef: groupRefProp, placeholder, hideRequiredIndicator, name, autoComplete = 'tel', className, 'data-testid': dataTestId, ...props }, ref) => {
|
|
26
|
+
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'phone-input', rootName: 'phone-input' });
|
|
27
|
+
const { locale } = useLocale();
|
|
28
|
+
// Keyed on the codes, so an array written inline, new each render, does not rebuild the list.
|
|
29
|
+
const countriesKey = allowedCountries?.join(',');
|
|
30
|
+
const allowed = useMemo(() => offeredCountries(countriesKey), [countriesKey]);
|
|
31
|
+
const options = useMemo(() => countryOptions(locale, allowed), [locale, allowed]);
|
|
32
|
+
const { country, text, value, type, chooseCountry, settle, reset } = usePhoneEntry({
|
|
33
|
+
value: valueProp,
|
|
34
|
+
defaultValue,
|
|
35
|
+
onChange,
|
|
36
|
+
defaultCountry: startingCountry(defaultCountry, locale, allowed),
|
|
37
|
+
allowed,
|
|
38
|
+
});
|
|
39
|
+
const chosen = useMemo(() => countryOptions(locale, [country])[0], [locale, country]);
|
|
40
|
+
const groupRef = useRef(null);
|
|
41
|
+
const mergedGroupRef = useMemo(() => mergeRefs(groupRef, groupRefProp), [groupRefProp]);
|
|
42
|
+
const listRef = useRef(null);
|
|
43
|
+
const inputRef = useRef(null);
|
|
44
|
+
const mergedRef = useMemo(() => mergeRefs(inputRef, ref), [ref]);
|
|
45
|
+
// The text field resets only the text it is handed, so the number, the country and the posted value reset here.
|
|
46
|
+
useFormReset(inputRef, undefined, reset);
|
|
47
|
+
// Reformatting moves the text under the cursor, and the browser then drops it at the end: put back beside the digit it was at.
|
|
48
|
+
const caret = useRef(null);
|
|
49
|
+
const handleChange = (event) => {
|
|
50
|
+
const { value: next, selectionStart } = event.target;
|
|
51
|
+
const { inputType } = event.nativeEvent;
|
|
52
|
+
caret.current = type({ previous: text, next, caret: selectionStart ?? next.length, inputType });
|
|
53
|
+
};
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
if (caret.current === null)
|
|
56
|
+
return;
|
|
57
|
+
inputRef.current?.setSelectionRange(caret.current, caret.current);
|
|
58
|
+
caret.current = null;
|
|
59
|
+
});
|
|
60
|
+
// Moving between the number, the trigger and its list stays inside the field; the list renders in a portal, so it is checked apart.
|
|
61
|
+
const handleBlur = (event) => {
|
|
62
|
+
if (isFocusInside(event.relatedTarget, [groupRef.current, listRef.current]))
|
|
63
|
+
return;
|
|
64
|
+
settle();
|
|
65
|
+
onBlur?.(event);
|
|
66
|
+
};
|
|
67
|
+
const handleCountryChange = (code) => {
|
|
68
|
+
chooseCountry(code);
|
|
69
|
+
onCountryChange?.(code);
|
|
70
|
+
};
|
|
71
|
+
const { isDisabled, isReadOnly } = props;
|
|
72
|
+
return (jsx(TextField, { ...props, value: text, type: "tel", autoComplete: autoComplete, size: size, "data-testid": rootTestId, className: className, children: ({ isInvalid, isRequired }) => (jsxs(Fragment, { children: [label && (jsx(Label, { isRequired: hideRequiredIndicator ? false : isRequired, isInvalid: isInvalid, children: label })), jsxs(Group, { ref: mergedGroupRef, onBlur: handleBlur, isDisabled: isDisabled, isInvalid: isInvalid, className: ({ isFocusWithin }) => cx('group/input relative flex w-full flex-row items-center rounded-lg bg-primary shadow-xs ring-1 ring-primary transition-shadow duration-100 ease-linear ring-inset', isFocusWithin && !isDisabled && 'ring-2 ring-brand', isDisabled && 'cursor-not-allowed opacity-50', isInvalid && 'ring-error_subtle', isInvalid && isFocusWithin && 'ring-2 ring-error'), children: [jsx(PhoneInputCountrySelect, { country: chosen, countries: options, onChange: handleCountryChange, size: size, isDisabled: isDisabled || isReadOnly, hasFieldLabel: Boolean(label), groupRef: groupRef, listRef: listRef, testId: rootTestId }), jsx(Input, { ref: mergedRef, onChange: handleChange, placeholder: placeholder ?? exampleNumber(country), "data-testid": joinTestId(rootTestId, 'input'), className: cx('m-0 w-full min-w-0 bg-transparent text-primary tabular-nums ring-0 outline-hidden placeholder:text-placeholder autofill:rounded-lg autofill:text-primary disabled:cursor-not-allowed', sizes[size].input, isInvalid && sizes[size].invalid) }), isInvalid && (jsx(InfoCircle, { className: cx('pointer-events-none absolute size-4 stroke-[2.25px] text-fg-error-secondary', sizes[size].icon) }))] }), hint && jsx(HintText, { isInvalid: isInvalid, children: hint }), name && jsx("input", { type: "hidden", name: name, value: value, form: props.form, disabled: isDisabled })] })) }));
|
|
73
|
+
});
|
|
74
|
+
PhoneInput.displayName = 'PhoneInput';
|
|
75
|
+
|
|
76
|
+
export { PhoneInput };
|
|
77
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/PhoneInput/index.tsx"],"sourcesContent":[null],"names":["_jsx","_jsxs","_Fragment","AriaGroup","AriaInput"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,KAAK,GAAG;AACZ,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;AAC3E,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;AAC3E,IAAA,EAAE,EAAE,EAAE,KAAK,EAAE,8BAA8B,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE;CACpF;AAuDD;;;;;;AAMG;AACI,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,KAAK,EACL,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,KAAK,EAAE,SAAS,EAChB,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EACf,MAAM,EACN,QAAQ,EAAE,YAAY,EACtB,WAAW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AAA,EACR,GAAG,EAAE,SAAS,EACd,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAE,WAAW,IAAI,aAAa,CAAC,OAAO,CAAC,EAAA,aAAA,EACrC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,EAC5C,SAAS,EAAE,EAAE,CACX,sLAAsL,EACtL,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,EACjB,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CACjC,EAAA,CACD,EAED,SAAS,KACRJ,GAAA,CAAC,UAAU,EAAA,EAAC,SAAS,EAAE,EAAE,CAAC,6EAA6E,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAA,CAAI,CAC/H,CAAA,EAAA,CACS,EAEX,IAAI,IAAIA,GAAA,CAAC,QAAQ,IAAC,SAAS,EAAE,SAAS,EAAA,QAAA,EAAG,IAAI,EAAA,CAAY,EAGzD,IAAI,IAAIA,GAAA,CAAA,OAAA,EAAA,EAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAA,CAAI,CAAA,EAAA,CACjG,CACJ,EAAA,CACS;AAEhB,CAAC;AAGH,UAAU,CAAC,WAAW,GAAG,YAAY;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CountryCode } from 'libphonenumber-js/min';
|
|
2
|
+
/** A country the phone library has numbering rules for. */
|
|
3
|
+
export type PhoneCountryCode = CountryCode;
|
|
4
|
+
/** One row of the country list. */
|
|
5
|
+
export interface PhoneCountry {
|
|
6
|
+
code: PhoneCountryCode;
|
|
7
|
+
/** The country's name in the user's language. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** The digits dialled before the national number, without the plus. */
|
|
10
|
+
callingCode: string;
|
|
11
|
+
}
|
|
12
|
+
/** What the field shows: the chosen country and the number as typed, in that country's national format. */
|
|
13
|
+
export interface PhoneEntry {
|
|
14
|
+
country: PhoneCountryCode;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=phoneInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phoneInput.types.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/PhoneInput/phoneInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAE3C,mCAAmC;AACnC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,2GAA2G;AAC3G,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd"}
|