@adam-milo/ui 1.0.35 → 1.0.41
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 +217 -337
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -108
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +4 -103
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +4 -230
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +9 -325
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +11 -279
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +2 -150
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +5 -65
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +4 -71
- package/dist/index17.cjs +1 -1
- package/dist/index17.js +4 -125
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +8 -93
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +4 -42
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +2 -482
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +5 -169
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +11 -44
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +2 -38
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +2 -46
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +2 -118
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +7 -55
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +2 -45
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +2 -53
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +2 -55
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +2 -45
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +2 -72
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +10 -14
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +11 -332
- package/dist/index33.cjs +1 -0
- package/dist/index33.js +1 -0
- package/dist/index34.cjs +1 -0
- package/dist/index34.js +1 -0
- package/dist/index35.cjs +1 -0
- package/dist/index35.js +1 -0
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +1 -386
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +1 -16
- package/dist/index38.cjs +1 -0
- package/dist/index38.js +15 -0
- package/dist/index39.cjs +1 -0
- package/dist/index39.js +1 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +3 -70
- package/dist/index40.cjs +1 -0
- package/dist/index40.js +1 -0
- package/dist/index41.cjs +1 -0
- package/dist/index41.js +1 -0
- package/dist/index42.cjs +1 -0
- package/dist/index42.js +1 -0
- package/dist/index43.cjs +1 -0
- package/dist/index43.js +1 -0
- package/dist/index44.cjs +1 -0
- package/dist/index44.js +1 -0
- package/dist/index45.cjs +1 -0
- package/dist/index45.js +1 -0
- package/dist/index46.cjs +1 -0
- package/dist/index46.js +1 -0
- package/dist/index47.cjs +1 -0
- package/dist/index47.js +1 -0
- package/dist/index48.cjs +1 -0
- package/dist/index48.js +1 -0
- package/dist/index49.cjs +1 -0
- package/dist/index49.js +1 -0
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +2 -45
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +1 -9
- package/dist/index51.cjs +1 -0
- package/dist/index51.js +1 -0
- package/dist/index52.cjs +1 -0
- package/dist/index52.js +1 -0
- package/dist/index53.cjs +1 -0
- package/dist/index53.js +1 -0
- package/dist/index54.cjs +1 -0
- package/dist/index54.js +1 -0
- package/dist/index55.cjs +1 -0
- package/dist/index55.js +1 -0
- package/dist/index56.cjs +1 -0
- package/dist/index56.js +1 -0
- package/dist/index57.cjs +1 -0
- package/dist/index57.js +1 -0
- package/dist/index58.cjs +1 -0
- package/dist/index58.js +1 -0
- package/dist/index59.cjs +1 -0
- package/dist/index59.js +1 -0
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +2 -22
- package/dist/index60.cjs +1 -0
- package/dist/index60.js +1 -0
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +1 -21
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +1 -502
- package/dist/index63.cjs +1 -0
- package/dist/index63.js +1 -0
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +1 -11
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +5 -39
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +1 -64
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +1 -212
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +1 -14
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +2 -293
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +1 -61
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +1 -18
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +1 -129
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +4 -43
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +1 -99
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +1 -71
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +1 -36
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +3 -14
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +1 -17
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +1 -6
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +1 -297
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +2 -112
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +1 -25
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +1 -39
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +1 -625
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +2 -721
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +1 -154
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +1 -173
- package/dist/index86.cjs +1 -0
- package/dist/index86.js +1 -0
- package/dist/index87.cjs +1 -0
- package/dist/index87.js +1 -0
- package/dist/index88.cjs +1 -0
- package/dist/index88.js +1 -0
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -112
- package/dist/src/components/core/button/Button.component.d.ts +2 -35
- package/dist/src/components/core/button/Button.component.d.ts.map +1 -1
- package/dist/src/components/core/button/Button.styles.d.ts +5 -0
- package/dist/src/components/core/button/Button.styles.d.ts.map +1 -0
- package/dist/src/components/core/button/Button.types.d.ts +11 -0
- package/dist/src/components/core/button/Button.types.d.ts.map +1 -0
- package/dist/src/components/core/icon-button/IconButton.component.d.ts +2 -33
- package/dist/src/components/core/icon-button/IconButton.component.d.ts.map +1 -1
- package/dist/src/components/core/icon-button/IconButton.styles.d.ts +3 -0
- package/dist/src/components/core/icon-button/IconButton.styles.d.ts.map +1 -0
- package/dist/src/components/core/icon-button/IconButton.types.d.ts +12 -0
- package/dist/src/components/core/icon-button/IconButton.types.d.ts.map +1 -0
- package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts +2 -76
- package/dist/src/components/core/menu-icon-button/MenuIconButton.component.d.ts.map +1 -1
- package/dist/src/components/core/menu-icon-button/MenuIconButton.styles.d.ts +9 -0
- package/dist/src/components/core/menu-icon-button/MenuIconButton.styles.d.ts.map +1 -0
- package/dist/src/components/core/menu-icon-button/MenuIconButton.types.d.ts +11 -0
- package/dist/src/components/core/menu-icon-button/MenuIconButton.types.d.ts.map +1 -0
- package/dist/src/components/data-display/card/Card.component.d.ts +2 -34
- package/dist/src/components/data-display/card/Card.component.d.ts.map +1 -1
- package/dist/src/components/data-display/card/Card.styles.d.ts +12 -0
- package/dist/src/components/data-display/card/Card.styles.d.ts.map +1 -0
- package/dist/src/components/data-display/card/Card.types.d.ts +28 -0
- package/dist/src/components/data-display/card/Card.types.d.ts.map +1 -0
- package/dist/src/components/data-display/chip/Chip.component.d.ts +2 -33
- package/dist/src/components/data-display/chip/Chip.component.d.ts.map +1 -1
- package/dist/src/components/data-display/chip/Chip.styles.d.ts +24 -0
- package/dist/src/components/data-display/chip/Chip.styles.d.ts.map +1 -0
- package/dist/src/components/data-display/chip/Chip.types.d.ts +11 -0
- package/dist/src/components/data-display/chip/Chip.types.d.ts.map +1 -0
- package/dist/src/components/data-display/chip-group/ChipGroup.component.d.ts +2 -69
- package/dist/src/components/data-display/chip-group/ChipGroup.component.d.ts.map +1 -1
- package/dist/src/components/data-display/chip-group/ChipGroup.styles.d.ts +14 -0
- package/dist/src/components/data-display/chip-group/ChipGroup.styles.d.ts.map +1 -0
- package/dist/src/components/data-display/chip-group/ChipGroup.types.d.ts +21 -0
- package/dist/src/components/data-display/chip-group/ChipGroup.types.d.ts.map +1 -0
- package/dist/src/components/data-display/datatable/DataTable.component.d.ts +2 -22
- package/dist/src/components/data-display/datatable/DataTable.component.d.ts.map +1 -1
- package/dist/src/components/data-display/datatable/DataTable.styles.d.ts +10 -0
- package/dist/src/components/data-display/datatable/DataTable.styles.d.ts.map +1 -0
- package/dist/src/components/data-display/datatable/DataTable.types.d.ts +16 -0
- package/dist/src/components/data-display/datatable/DataTable.types.d.ts.map +1 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.component.d.ts +5 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.component.d.ts.map +1 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.styles.d.ts +5 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.styles.d.ts.map +1 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.types.d.ts +10 -0
- package/dist/src/components/feedback/ai-loader/AiLoader.types.d.ts.map +1 -0
- package/dist/src/components/feedback/alert/Alert.component.d.ts +2 -16
- package/dist/src/components/feedback/alert/Alert.component.d.ts.map +1 -1
- package/dist/src/components/feedback/alert/Alert.styles.d.ts +10 -0
- package/dist/src/components/feedback/alert/Alert.styles.d.ts.map +1 -0
- package/dist/src/components/feedback/alert/Alert.types.d.ts +10 -0
- package/dist/src/components/feedback/alert/Alert.types.d.ts.map +1 -0
- package/dist/src/components/feedback/spinner/Spinner.component.d.ts +2 -59
- package/dist/src/components/feedback/spinner/Spinner.component.d.ts.map +1 -1
- package/dist/src/components/feedback/spinner/Spinner.styles.d.ts +7 -0
- package/dist/src/components/feedback/spinner/Spinner.styles.d.ts.map +1 -0
- package/dist/src/components/feedback/spinner/Spinner.types.d.ts +14 -0
- package/dist/src/components/feedback/spinner/Spinner.types.d.ts.map +1 -0
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts +2 -44
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.types.d.ts +10 -0
- package/dist/src/components/forms/alphanumeric-input/AlphanumericInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/checkbox/Checkbox.component.d.ts +2 -99
- package/dist/src/components/forms/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/src/components/forms/checkbox/Checkbox.styles.d.ts +10 -0
- package/dist/src/components/forms/checkbox/Checkbox.styles.d.ts.map +1 -0
- package/dist/src/components/forms/checkbox/Checkbox.types.d.ts +17 -0
- package/dist/src/components/forms/checkbox/Checkbox.types.d.ts.map +1 -0
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts +2 -28
- package/dist/src/components/forms/email-input/EmailInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/email-input/EmailInput.types.d.ts +7 -0
- package/dist/src/components/forms/email-input/EmailInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/input/Input.component.d.ts +2 -107
- package/dist/src/components/forms/input/Input.component.d.ts.map +1 -1
- package/dist/src/components/forms/input/Input.styles.d.ts +13 -0
- package/dist/src/components/forms/input/Input.styles.d.ts.map +1 -0
- package/dist/src/components/forms/input/Input.types.d.ts +17 -0
- package/dist/src/components/forms/input/Input.types.d.ts.map +1 -0
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts +2 -41
- package/dist/src/components/forms/numeric-input/NumericInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/numeric-input/NumericInput.types.d.ts +9 -0
- package/dist/src/components/forms/numeric-input/NumericInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/otp-input/OTPInput.component.d.ts +2 -79
- package/dist/src/components/forms/otp-input/OTPInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/otp-input/OTPInput.styles.d.ts +12 -0
- package/dist/src/components/forms/otp-input/OTPInput.styles.d.ts.map +1 -0
- package/dist/src/components/forms/otp-input/OTPInput.types.d.ts +23 -0
- package/dist/src/components/forms/otp-input/OTPInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts +2 -25
- package/dist/src/components/forms/password-input/PasswordInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/password-input/PasswordInput.types.d.ts +6 -0
- package/dist/src/components/forms/password-input/PasswordInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts +2 -91
- package/dist/src/components/forms/phone-input/PhoneInput.component.d.ts.map +1 -1
- package/dist/src/components/forms/phone-input/PhoneInput.styles.d.ts +22 -0
- package/dist/src/components/forms/phone-input/PhoneInput.styles.d.ts.map +1 -0
- package/dist/src/components/forms/phone-input/PhoneInput.types.d.ts +19 -0
- package/dist/src/components/forms/phone-input/PhoneInput.types.d.ts.map +1 -0
- package/dist/src/components/forms/phone-input/countries.d.ts +3 -79
- package/dist/src/components/forms/phone-input/countries.d.ts.map +1 -1
- package/dist/src/components/forms/phone-input/countries.types.d.ts +12 -0
- package/dist/src/components/forms/phone-input/countries.types.d.ts.map +1 -0
- package/dist/src/components/forms/radio/Radio.component.d.ts +2 -97
- package/dist/src/components/forms/radio/Radio.component.d.ts.map +1 -1
- package/dist/src/components/forms/radio/Radio.styles.d.ts +10 -0
- package/dist/src/components/forms/radio/Radio.styles.d.ts.map +1 -0
- package/dist/src/components/forms/radio/Radio.types.d.ts +16 -0
- package/dist/src/components/forms/radio/Radio.types.d.ts.map +1 -0
- package/dist/src/components/forms/select/Select.component.d.ts +2 -94
- package/dist/src/components/forms/select/Select.component.d.ts.map +1 -1
- package/dist/src/components/forms/select/Select.styles.d.ts +18 -0
- package/dist/src/components/forms/select/Select.styles.d.ts.map +1 -0
- package/dist/src/components/forms/select/Select.types.d.ts +34 -0
- package/dist/src/components/forms/select/Select.types.d.ts.map +1 -0
- package/dist/src/components/forms/toggle/Toggle.component.d.ts +2 -77
- package/dist/src/components/forms/toggle/Toggle.component.d.ts.map +1 -1
- package/dist/src/components/forms/toggle/Toggle.styles.d.ts +23 -0
- package/dist/src/components/forms/toggle/Toggle.styles.d.ts.map +1 -0
- package/dist/src/components/forms/toggle/Toggle.types.d.ts +14 -0
- package/dist/src/components/forms/toggle/Toggle.types.d.ts.map +1 -0
- package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts +2 -83
- package/dist/src/components/layout/auth-layout/AuthLayout.component.d.ts.map +1 -1
- package/dist/src/components/layout/auth-layout/AuthLayout.styles.d.ts +11 -0
- package/dist/src/components/layout/auth-layout/AuthLayout.styles.d.ts.map +1 -0
- package/dist/src/components/layout/auth-layout/AuthLayout.types.d.ts +16 -0
- package/dist/src/components/layout/auth-layout/AuthLayout.types.d.ts.map +1 -0
- package/dist/src/components/layout/container/Container.component.d.ts +2 -23
- package/dist/src/components/layout/container/Container.component.d.ts.map +1 -1
- package/dist/src/components/layout/container/Container.styles.d.ts +15 -0
- package/dist/src/components/layout/container/Container.styles.d.ts.map +1 -0
- package/dist/src/components/layout/container/Container.types.d.ts +9 -0
- package/dist/src/components/layout/container/Container.types.d.ts.map +1 -0
- package/dist/src/components/layout/divider/Divider.component.d.ts +2 -36
- package/dist/src/components/layout/divider/Divider.component.d.ts.map +1 -1
- package/dist/src/components/layout/divider/Divider.styles.d.ts +4 -0
- package/dist/src/components/layout/divider/Divider.styles.d.ts.map +1 -0
- package/dist/src/components/layout/divider/Divider.types.d.ts +11 -0
- package/dist/src/components/layout/divider/Divider.types.d.ts.map +1 -0
- package/dist/src/components/layout/grid/Grid.component.d.ts +2 -50
- package/dist/src/components/layout/grid/Grid.component.d.ts.map +1 -1
- package/dist/src/components/layout/grid/Grid.styles.d.ts +79 -0
- package/dist/src/components/layout/grid/Grid.styles.d.ts.map +1 -0
- package/dist/src/components/layout/grid/Grid.types.d.ts +15 -0
- package/dist/src/components/layout/grid/Grid.types.d.ts.map +1 -0
- package/dist/src/components/layout/stack/Stack.component.d.ts +2 -18
- package/dist/src/components/layout/stack/Stack.component.d.ts.map +1 -1
- package/dist/src/components/layout/stack/Stack.styles.d.ts +5 -0
- package/dist/src/components/layout/stack/Stack.styles.d.ts.map +1 -0
- package/dist/src/components/layout/stack/Stack.types.d.ts +12 -0
- package/dist/src/components/layout/stack/Stack.types.d.ts.map +1 -0
- package/dist/src/components/navigation/tabs/Tabs.component.d.ts +2 -38
- package/dist/src/components/navigation/tabs/Tabs.component.d.ts.map +1 -1
- package/dist/src/components/navigation/tabs/Tabs.styles.d.ts +4 -0
- package/dist/src/components/navigation/tabs/Tabs.styles.d.ts.map +1 -0
- package/dist/src/components/navigation/tabs/Tabs.types.d.ts +17 -0
- package/dist/src/components/navigation/tabs/Tabs.types.d.ts.map +1 -0
- package/dist/src/components/overlays/dialog/Dialog.component.d.ts +2 -55
- package/dist/src/components/overlays/dialog/Dialog.component.d.ts.map +1 -1
- package/dist/src/components/overlays/dialog/Dialog.styles.d.ts +20 -0
- package/dist/src/components/overlays/dialog/Dialog.styles.d.ts.map +1 -0
- package/dist/src/components/overlays/dialog/Dialog.types.d.ts +41 -0
- package/dist/src/components/overlays/dialog/Dialog.types.d.ts.map +1 -0
- package/dist/src/components/typography/heading/Heading.component.d.ts +2 -89
- package/dist/src/components/typography/heading/Heading.component.d.ts.map +1 -1
- package/dist/src/components/typography/heading/Heading.styles.d.ts +9 -0
- package/dist/src/components/typography/heading/Heading.styles.d.ts.map +1 -0
- package/dist/src/components/typography/heading/Heading.types.d.ts +19 -0
- package/dist/src/components/typography/heading/Heading.types.d.ts.map +1 -0
- package/dist/src/components/typography/link/Link.component.d.ts +2 -77
- package/dist/src/components/typography/link/Link.component.d.ts.map +1 -1
- package/dist/src/components/typography/link/Link.styles.d.ts +9 -0
- package/dist/src/components/typography/link/Link.styles.d.ts.map +1 -0
- package/dist/src/components/typography/link/Link.types.d.ts +17 -0
- package/dist/src/components/typography/link/Link.types.d.ts.map +1 -0
- package/dist/src/components/typography/text/Text.component.d.ts +4 -91
- package/dist/src/components/typography/text/Text.component.d.ts.map +1 -1
- package/dist/src/components/typography/text/Text.styles.d.ts +8 -0
- package/dist/src/components/typography/text/Text.styles.d.ts.map +1 -0
- package/dist/src/components/typography/text/Text.types.d.ts +20 -0
- package/dist/src/components/typography/text/Text.types.d.ts.map +1 -0
- package/dist/src/index.d.ts +5 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/styles.css +1 -0
- package/package.json +8 -13
- package/dist/index2.cjs +0 -1
- package/dist/index2.js +0 -40
- package/dist/style.css +0 -1
package/dist/index13.js
CHANGED
|
@@ -1,279 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
error,
|
|
13
|
-
helperText,
|
|
14
|
-
disabled = false,
|
|
15
|
-
autoFocus = false,
|
|
16
|
-
fullWidth = false,
|
|
17
|
-
centered = false,
|
|
18
|
-
type = "numeric",
|
|
19
|
-
required = false,
|
|
20
|
-
"data-cy": dataCy,
|
|
21
|
-
"data-testid": dataTestId
|
|
22
|
-
}, ref) => {
|
|
23
|
-
const generatedId = useId();
|
|
24
|
-
const errorId = `${generatedId}-error`;
|
|
25
|
-
const helperId = `${generatedId}-helper`;
|
|
26
|
-
const finalDataCy = dataCy || "otp-input";
|
|
27
|
-
const finalTestId = dataTestId || "otp-input";
|
|
28
|
-
const inputRefs = useRef([]);
|
|
29
|
-
const [otp, setOtp] = useState(
|
|
30
|
-
() => value.split("").slice(0, length).concat(Array(length).fill("")).slice(0, length)
|
|
31
|
-
);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const newOtp = value.split("").slice(0, length).concat(Array(length).fill("")).slice(0, length);
|
|
34
|
-
setOtp(newOtp);
|
|
35
|
-
}, [value, length]);
|
|
36
|
-
const isValidInput = useCallback(
|
|
37
|
-
(char) => {
|
|
38
|
-
if (type === "numeric") {
|
|
39
|
-
return /^\d$/.test(char);
|
|
40
|
-
}
|
|
41
|
-
return /^[a-zA-Z0-9]$/.test(char);
|
|
42
|
-
},
|
|
43
|
-
[type]
|
|
44
|
-
);
|
|
45
|
-
const updateOtp = useCallback(
|
|
46
|
-
(newOtp) => {
|
|
47
|
-
setOtp(newOtp);
|
|
48
|
-
const otpValue = newOtp.join("");
|
|
49
|
-
onChange == null ? void 0 : onChange(otpValue);
|
|
50
|
-
if (newOtp.every((digit) => digit !== "") && newOtp.length === length) {
|
|
51
|
-
onComplete == null ? void 0 : onComplete(otpValue);
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
[onChange, onComplete, length]
|
|
55
|
-
);
|
|
56
|
-
const focusInput = useCallback((index) => {
|
|
57
|
-
const input = inputRefs.current[index];
|
|
58
|
-
if (input) {
|
|
59
|
-
input.focus();
|
|
60
|
-
input.select();
|
|
61
|
-
}
|
|
62
|
-
}, []);
|
|
63
|
-
const handleChange = useCallback(
|
|
64
|
-
(index, e) => {
|
|
65
|
-
const inputValue = e.target.value;
|
|
66
|
-
if (inputValue.length === 1 && isValidInput(inputValue)) {
|
|
67
|
-
const newOtp = [...otp];
|
|
68
|
-
newOtp[index] = inputValue;
|
|
69
|
-
updateOtp(newOtp);
|
|
70
|
-
if (index < length - 1) {
|
|
71
|
-
focusInput(index + 1);
|
|
72
|
-
}
|
|
73
|
-
} else if (inputValue.length > 1) {
|
|
74
|
-
const chars = inputValue.split("").filter(isValidInput);
|
|
75
|
-
const newOtp = [...otp];
|
|
76
|
-
chars.forEach((char, i) => {
|
|
77
|
-
if (index + i < length) {
|
|
78
|
-
newOtp[index + i] = char;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
updateOtp(newOtp);
|
|
82
|
-
const nextEmptyIndex = newOtp.findIndex((d) => d === "");
|
|
83
|
-
focusInput(nextEmptyIndex === -1 ? length - 1 : nextEmptyIndex);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
[otp, length, isValidInput, updateOtp, focusInput]
|
|
87
|
-
);
|
|
88
|
-
const handleKeyDown = useCallback(
|
|
89
|
-
(index, e) => {
|
|
90
|
-
switch (e.key) {
|
|
91
|
-
case "Backspace":
|
|
92
|
-
e.preventDefault();
|
|
93
|
-
if (otp[index]) {
|
|
94
|
-
const newOtp = [...otp];
|
|
95
|
-
newOtp[index] = "";
|
|
96
|
-
updateOtp(newOtp);
|
|
97
|
-
} else if (index > 0) {
|
|
98
|
-
const newOtp = [...otp];
|
|
99
|
-
newOtp[index - 1] = "";
|
|
100
|
-
updateOtp(newOtp);
|
|
101
|
-
focusInput(index - 1);
|
|
102
|
-
}
|
|
103
|
-
break;
|
|
104
|
-
case "Delete":
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
if (otp[index]) {
|
|
107
|
-
const newOtp = [...otp];
|
|
108
|
-
newOtp[index] = "";
|
|
109
|
-
updateOtp(newOtp);
|
|
110
|
-
}
|
|
111
|
-
break;
|
|
112
|
-
case "ArrowLeft":
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
if (index > 0) {
|
|
115
|
-
focusInput(index - 1);
|
|
116
|
-
}
|
|
117
|
-
break;
|
|
118
|
-
case "ArrowRight":
|
|
119
|
-
e.preventDefault();
|
|
120
|
-
if (index < length - 1) {
|
|
121
|
-
focusInput(index + 1);
|
|
122
|
-
}
|
|
123
|
-
break;
|
|
124
|
-
case "Home":
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
focusInput(0);
|
|
127
|
-
break;
|
|
128
|
-
case "End":
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
focusInput(length - 1);
|
|
131
|
-
break;
|
|
132
|
-
default:
|
|
133
|
-
if (e.key.length === 1 && isValidInput(e.key)) {
|
|
134
|
-
e.preventDefault();
|
|
135
|
-
const newOtp = [...otp];
|
|
136
|
-
newOtp[index] = e.key;
|
|
137
|
-
updateOtp(newOtp);
|
|
138
|
-
if (index < length - 1) {
|
|
139
|
-
focusInput(index + 1);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
},
|
|
145
|
-
[otp, length, isValidInput, updateOtp, focusInput]
|
|
146
|
-
);
|
|
147
|
-
const handlePaste = useCallback(
|
|
148
|
-
(index, e) => {
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
const pastedData = e.clipboardData.getData("text");
|
|
151
|
-
const chars = pastedData.split("").filter(isValidInput);
|
|
152
|
-
if (chars.length === 0) return;
|
|
153
|
-
const newOtp = [...otp];
|
|
154
|
-
chars.forEach((char, i) => {
|
|
155
|
-
if (index + i < length) {
|
|
156
|
-
newOtp[index + i] = char;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
updateOtp(newOtp);
|
|
160
|
-
const nextEmptyIndex = newOtp.findIndex((d) => d === "");
|
|
161
|
-
focusInput(nextEmptyIndex === -1 ? length - 1 : nextEmptyIndex);
|
|
162
|
-
},
|
|
163
|
-
[otp, length, isValidInput, updateOtp, focusInput]
|
|
164
|
-
);
|
|
165
|
-
const handleFocus = useCallback((e) => {
|
|
166
|
-
e.target.select();
|
|
167
|
-
}, []);
|
|
168
|
-
useImperativeHandle(
|
|
169
|
-
ref,
|
|
170
|
-
() => ({
|
|
171
|
-
focus: () => {
|
|
172
|
-
const emptyIndex = otp.findIndex((d) => d === "");
|
|
173
|
-
focusInput(emptyIndex === -1 ? length - 1 : emptyIndex);
|
|
174
|
-
},
|
|
175
|
-
clear: () => {
|
|
176
|
-
const newOtp = Array(length).fill("");
|
|
177
|
-
updateOtp(newOtp);
|
|
178
|
-
focusInput(0);
|
|
179
|
-
},
|
|
180
|
-
getValue: () => otp.join("")
|
|
181
|
-
}),
|
|
182
|
-
[otp, length, focusInput, updateOtp]
|
|
183
|
-
);
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
if (autoFocus && !disabled) {
|
|
186
|
-
focusInput(0);
|
|
187
|
-
}
|
|
188
|
-
}, [autoFocus, disabled, focusInput]);
|
|
189
|
-
return /* @__PURE__ */ jsxs(
|
|
190
|
-
"div",
|
|
191
|
-
{
|
|
192
|
-
className: cn("otp-input-wrapper", fullWidth && "otp-input-wrapper--full-width"),
|
|
193
|
-
"data-cy": `${finalDataCy}-wrapper`,
|
|
194
|
-
"data-testid": `${finalTestId}-wrapper`,
|
|
195
|
-
children: [
|
|
196
|
-
label && /* @__PURE__ */ jsx(
|
|
197
|
-
"label",
|
|
198
|
-
{
|
|
199
|
-
className: cn(
|
|
200
|
-
"otp-input__label",
|
|
201
|
-
error && "otp-input__label--error",
|
|
202
|
-
disabled && "otp-input__label--disabled"
|
|
203
|
-
),
|
|
204
|
-
"data-cy": `${finalDataCy}-label`,
|
|
205
|
-
"data-testid": `${finalTestId}-label`,
|
|
206
|
-
children: label
|
|
207
|
-
}
|
|
208
|
-
),
|
|
209
|
-
/* @__PURE__ */ jsx(
|
|
210
|
-
"div",
|
|
211
|
-
{
|
|
212
|
-
className: cn("otp-input__container", centered && "otp-input__container--centered"),
|
|
213
|
-
role: "group",
|
|
214
|
-
"aria-label": label || "OTP Input",
|
|
215
|
-
"data-cy": `${finalDataCy}-container`,
|
|
216
|
-
"data-testid": `${finalTestId}-container`,
|
|
217
|
-
children: Array.from({ length }, (_, index) => /* @__PURE__ */ jsx(
|
|
218
|
-
"input",
|
|
219
|
-
{
|
|
220
|
-
ref: (el) => {
|
|
221
|
-
inputRefs.current[index] = el;
|
|
222
|
-
},
|
|
223
|
-
type: "text",
|
|
224
|
-
inputMode: type === "numeric" ? "numeric" : "text",
|
|
225
|
-
pattern: type === "numeric" ? "[0-9]*" : "[a-zA-Z0-9]*",
|
|
226
|
-
maxLength: 1,
|
|
227
|
-
value: otp[index] || "",
|
|
228
|
-
onChange: (e) => handleChange(index, e),
|
|
229
|
-
onKeyDown: (e) => handleKeyDown(index, e),
|
|
230
|
-
onPaste: (e) => handlePaste(index, e),
|
|
231
|
-
onFocus: handleFocus,
|
|
232
|
-
disabled,
|
|
233
|
-
required,
|
|
234
|
-
"aria-label": `Digit ${index + 1} of ${length}`,
|
|
235
|
-
"aria-invalid": error ? "true" : "false",
|
|
236
|
-
"aria-describedby": error ? errorId : helperText ? helperId : void 0,
|
|
237
|
-
className: cn(
|
|
238
|
-
"otp-input__digit",
|
|
239
|
-
otp[index] && "otp-input__digit--filled",
|
|
240
|
-
error && "otp-input__digit--error"
|
|
241
|
-
),
|
|
242
|
-
"data-cy": `${finalDataCy}-digit-${index}`,
|
|
243
|
-
"data-testid": `${finalTestId}-digit-${index}`,
|
|
244
|
-
autoComplete: "one-time-code"
|
|
245
|
-
},
|
|
246
|
-
index
|
|
247
|
-
))
|
|
248
|
-
}
|
|
249
|
-
),
|
|
250
|
-
error && /* @__PURE__ */ jsx(
|
|
251
|
-
"span",
|
|
252
|
-
{
|
|
253
|
-
id: errorId,
|
|
254
|
-
className: "otp-input__error",
|
|
255
|
-
role: "alert",
|
|
256
|
-
"data-cy": `${finalDataCy}-error`,
|
|
257
|
-
"data-testid": `${finalTestId}-error`,
|
|
258
|
-
children: error
|
|
259
|
-
}
|
|
260
|
-
),
|
|
261
|
-
helperText && !error && /* @__PURE__ */ jsx(
|
|
262
|
-
"span",
|
|
263
|
-
{
|
|
264
|
-
id: helperId,
|
|
265
|
-
className: "otp-input__helper",
|
|
266
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
267
|
-
"data-testid": `${finalTestId}-helper`,
|
|
268
|
-
children: helperText
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
]
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
OTPInput.displayName = "OTPInput";
|
|
277
|
-
export {
|
|
278
|
-
OTPInput
|
|
279
|
-
};
|
|
1
|
+
import{jsxs as e,jsx as a}from"react/jsx-runtime";import{forwardRef as t,useState as r,useId as n,useRef as o,useEffect as d,useCallback as l}from"react";import{cn as i}from"./index33.js";import{Icon as c}from"@adam-milo/icons";import{commonCountries as s,getPhoneMask as u,getPhoneDigits as p,formatPhoneNumber as m}from"./index34.js";import{allCountries as h,defaultCountries as y,defaultPhoneMask as f,getCountriesByDialCode as $,getCountryByCode as b,getCountryByDialCode as g,isValidPhoneLength as v,phoneMasks as x,searchCountries as w}from"./index34.js";import{labelStyles as N,triggerStyles as C,flagStyles as k,dialCodeStyles as D,dropdownStyles as E,optionFlagStyles as L,optionNameStyles as j,optionDialCodeStyles as I,optionSelectedStyles as q,optionHighlightedStyles as F,optionBaseStyles as M,errorStyles as S,helperStyles as A,inputStyles as K,containerIdleStyles as T,containerDisabledStyles as B,containerErrorStyles as U,containerFocusStyles as z,containerBaseStyles as P,wrapperFullWidthStyles as V,wrapperStyles as W}from"./index43.js";const G=t(({label:t,error:h,helperText:y,fullWidth:f=!0,value:$="",onChange:b,countryCode:g="US",onCountryChange:v,countries:x=s,enableFormatting:w=!0,onValidationChange:G,disabled:H,required:J,placeholder:O,id:Q,"data-cy":R,"data-testid":X,className:Y,onFocus:Z,onBlur:_,...ee},ae)=>{const[te,re]=r(!1),[ne,oe]=r(!1),[de,le]=r(0),ie=n(),ce=Q||ie,se=`${ce}-error`,ue=`${ce}-helper`,pe=`${ce}-listbox`,me=o(null),he=o(null),ye=o(null),fe=R||"phone-input",$e=X||"phone-input",be=x.find(e=>e.code===g)||x[0],ge=u(g),ve=O||ge.placeholder,xe=t&&J&&!t.includes("*")?`${t}*`:t;d(()=>{const e=e=>{me.current&&!me.current.contains(e.target)&&re(!1)};return te&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[te]);const we=l(e=>{v?.(e),re(!1),setTimeout(()=>{const e=me.current?.querySelector("input");e?.focus()},0)},[v]),Ne=l(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),le(e=>Math.min(e+1,x.length-1));break;case"ArrowUp":e.preventDefault(),le(e=>Math.max(e-1,0));break;case"Enter":case" ":e.preventDefault(),we(x[de]);break;case"Escape":e.preventDefault(),re(!1),ye.current?.focus();break;case"Tab":re(!1)}},[x,de,we]),Ce=H?"disabled":h?"error":ne||te?"focus":"idle";/* @__PURE__ */
|
|
2
|
+
return e("div",{ref:me,className:i(W,f&&V),"data-cy":`${fe}-wrapper`,"data-testid":`${$e}-wrapper`,children:[t&&/* @__PURE__ */a("label",{htmlFor:ce,className:N,"data-cy":`${fe}-label`,"data-testid":`${$e}-label`,children:xe}),
|
|
3
|
+
/* @__PURE__ */e("div",{className:i(P,"focus"===Ce&&z,"error"===Ce&&U,"disabled"===Ce&&B,"idle"===Ce&&T),"data-state":Ce,"data-cy":`${fe}-container`,"data-testid":`${$e}-container`,children:[
|
|
4
|
+
/* @__PURE__ */e("button",{ref:ye,type:"button",className:C,onClick:()=>!H&&re(!te),onKeyDown:e=>{if("Enter"===e.key||" "===e.key||"ArrowDown"===e.key){e.preventDefault(),re(!0);const a=x.findIndex(e=>e.code===g);le(-1===a?0:a)}},disabled:H,"aria-haspopup":"listbox","aria-expanded":te,"aria-controls":pe,"aria-label":`Select country. Current: ${be.name}`,"data-cy":`${fe}-country-trigger`,"data-testid":`${$e}-country-trigger`,children:[
|
|
5
|
+
/* @__PURE__ */a("span",{className:k,"data-cy":`${fe}-flag`,"data-testid":`${$e}-flag`,children:be.flag}),
|
|
6
|
+
/* @__PURE__ */a(c,{name:"ChevronDownIcon",size:"sm",color:ne||te?"clickable":"text",decorative:!0,"data-cy":`${fe}-chevron`})]}),
|
|
7
|
+
/* @__PURE__ */a("span",{className:D,"data-cy":`${fe}-dial-code`,"data-testid":`${$e}-dial-code`,children:be.dialCode}),
|
|
8
|
+
/* @__PURE__ */a("input",{ref:ae,id:ce,type:"tel",inputMode:"numeric",value:$,onChange:e=>{const a=e.target.value;if(w){const e=p(a).slice(0,ge.maxLength),t=m(e,g);b?.(t);const r=e.length===ge.maxLength;G?.(r)}else{const e=a.replace(/[^0-9]/g,"");b?.(e);const t=e.length===ge.maxLength;G?.(t)}},onFocus:e=>{oe(!0),Z?.(e)},onBlur:e=>{oe(!1),_?.(e)},placeholder:ve,disabled:H,required:J,className:i(K,Y),"aria-invalid":h?"true":"false","aria-required":J?"true":void 0,"aria-describedby":h?se:y?ue:void 0,"data-cy":fe,"data-testid":$e,...ee})]}),te&&/* @__PURE__ */a("div",{ref:he,id:pe,role:"listbox","aria-label":"Select country",className:E,tabIndex:-1,onKeyDown:Ne,"data-cy":`${fe}-dropdown`,"data-testid":`${$e}-dropdown`,children:x.map((t,r)=>/* @__PURE__ */e("div",{role:"option","aria-selected":t.code===g,className:i(M,r===de&&F,t.code===g&&q),onClick:()=>we(t),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),we(t))},onMouseEnter:()=>le(r),tabIndex:r===de?0:-1,"data-cy":`${fe}-option-${t.code.toLowerCase()}`,"data-testid":`${$e}-option-${t.code.toLowerCase()}`,children:[
|
|
9
|
+
/* @__PURE__ */a("span",{className:L,children:t.flag}),
|
|
10
|
+
/* @__PURE__ */a("span",{className:j,children:t.name}),
|
|
11
|
+
/* @__PURE__ */a("span",{className:I,children:t.dialCode})]},t.code))}),h&&/* @__PURE__ */a("span",{id:se,className:S,role:"alert","data-cy":`${fe}-error`,"data-testid":`${$e}-error`,children:h}),y&&!h&&/* @__PURE__ */a("span",{id:ue,className:A,"data-cy":`${fe}-helper`,"data-testid":`${$e}-helper`,children:y})]})});G.displayName="PhoneInput";export{G as PhoneInput,h as allCountries,s as commonCountries,y as defaultCountries,f as defaultPhoneMask,m as formatPhoneNumber,$ as getCountriesByDialCode,b as getCountryByCode,g as getCountryByDialCode,p as getPhoneDigits,u as getPhoneMask,v as isValidPhoneLength,x as phoneMasks,w as searchCountries};
|
package/dist/index14.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),a=require("./index33.cjs"),r=require("./index44.cjs"),l=t.forwardRef(({length:l=4,label:s,value:n="",onChange:c,onComplete:i,error:o,helperText:d,disabled:u=!1,autoFocus:p=!1,fullWidth:f=!1,centered:y=!1,type:b="numeric",required:h=!1,"data-cy":g,"data-testid":m},$)=>{const x=t.useId(),k=`${x}-error`,v=`${x}-helper`,D=g||"otp-input",S=m||"otp-input",j=t.useRef([]),[C,w]=t.useState(()=>n.split("").slice(0,l).concat(Array(l).fill("")).slice(0,l));t.useEffect(()=>{const e=n.split("").slice(0,l).concat(Array(l).fill("")).slice(0,l);w(e)},[n,l]);const A=t.useCallback(e=>"numeric"===b?/^\d$/.test(e):/^[a-zA-Z0-9]$/.test(e),[b]),I=t.useCallback(e=>{w(e);const t=e.join("");c?.(t),e.every(e=>""!==e)&&e.length===l&&i?.(t)},[c,i,l]),E=t.useCallback(e=>{const t=j.current[e];t&&(t.focus(),t.select())},[]),N=t.useCallback((e,t)=>{const a=t.target.value;if(1===a.length&&A(a)){const t=[...C];t[e]=a,I(t),e<l-1&&E(e+1)}else if(a.length>1){const t=a.split("").filter(A),r=[...C];t.forEach((t,a)=>{e+a<l&&(r[e+a]=t)}),I(r);const s=r.findIndex(e=>""===e);E(-1===s?l-1:s)}},[C,l,A,I,E]),q=t.useCallback((e,t)=>{switch(t.key){case"Backspace":if(t.preventDefault(),C[e]){const t=[...C];t[e]="",I(t)}else if(e>0){const t=[...C];t[e-1]="",I(t),E(e-1)}break;case"Delete":if(t.preventDefault(),C[e]){const t=[...C];t[e]="",I(t)}break;case"ArrowLeft":t.preventDefault(),e>0&&E(e-1);break;case"ArrowRight":t.preventDefault(),e<l-1&&E(e+1);break;case"Home":t.preventDefault(),E(0);break;case"End":t.preventDefault(),E(l-1);break;default:if(1===t.key.length&&A(t.key)){t.preventDefault();const a=[...C];a[e]=t.key,I(a),e<l-1&&E(e+1)}}},[C,l,A,I,E]),P=t.useCallback((e,t)=>{t.preventDefault();const a=t.clipboardData.getData("text").split("").filter(A);if(0===a.length)return;const r=[...C];a.forEach((t,a)=>{e+a<l&&(r[e+a]=t)}),I(r);const s=r.findIndex(e=>""===e);E(-1===s?l-1:s)},[C,l,A,I,E]),T=t.useCallback(e=>{e.target.select()},[]);return t.useImperativeHandle($,()=>({focus:()=>{const e=C.findIndex(e=>""===e);E(-1===e?l-1:e)},clear:()=>{const e=Array(l).fill("");I(e),E(0)},getValue:()=>C.join("")}),[C,l,E,I]),t.useEffect(()=>{p&&!u&&E(0)},[p,u,E]),e.jsxs("div",{className:a.cn(r.wrapperStyles,f&&r.wrapperFullWidthStyles),"data-cy":`${D}-wrapper`,"data-testid":`${S}-wrapper`,children:[s&&e.jsx("label",{className:a.cn(r.labelBaseStyles,o&&r.labelErrorStyles,u&&r.labelDisabledStyles),"data-cy":`${D}-label`,"data-testid":`${S}-label`,children:s}),e.jsx("div",{className:a.cn(r.containerBaseStyles,y&&r.containerCenteredStyles),role:"group","aria-label":s||"OTP Input","data-cy":`${D}-container`,"data-testid":`${S}-container`,children:Array.from({length:l},(t,s)=>e.jsx("input",{ref:e=>{j.current[s]=e},type:"text",inputMode:"numeric"===b?"numeric":"text",pattern:"numeric"===b?"[0-9]*":"[a-zA-Z0-9]*",maxLength:1,value:C[s]||"",onChange:e=>N(s,e),onKeyDown:e=>q(s,e),onPaste:e=>P(s,e),onFocus:T,disabled:u,required:h,"aria-label":`Digit ${s+1} of ${l}`,"aria-invalid":o?"true":"false","aria-describedby":o?k:d?v:void 0,className:a.cn(r.digitBaseStyles,o&&r.digitErrorStyles),"data-otp-digit":!0,"data-cy":`${D}-digit-${s}`,"data-testid":`${S}-digit-${s}`,autoComplete:"one-time-code"},s))}),o&&e.jsx("span",{id:k,className:r.errorStyles,role:"alert","data-cy":`${D}-error`,"data-testid":`${S}-error`,children:o}),d&&!o&&e.jsx("span",{id:v,className:r.helperStyles,"data-cy":`${D}-helper`,"data-testid":`${S}-helper`,children:d})]})});l.displayName="OTPInput",exports.OTPInput=l;
|
package/dist/index14.js
CHANGED
|
@@ -1,150 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { cn } from "./index31.js";
|
|
4
|
-
/* empty css */
|
|
5
|
-
const Toggle = forwardRef(
|
|
6
|
-
({
|
|
7
|
-
label,
|
|
8
|
-
labelPosition = "end",
|
|
9
|
-
helperText,
|
|
10
|
-
size = "md",
|
|
11
|
-
className,
|
|
12
|
-
id: providedId,
|
|
13
|
-
disabled,
|
|
14
|
-
checked,
|
|
15
|
-
defaultChecked,
|
|
16
|
-
"data-cy": dataCy,
|
|
17
|
-
"data-testid": dataTestId,
|
|
18
|
-
...props
|
|
19
|
-
}, ref) => {
|
|
20
|
-
const generatedId = useId();
|
|
21
|
-
const id = providedId || generatedId;
|
|
22
|
-
const helperId = `${id}-helper`;
|
|
23
|
-
const finalDataCy = dataCy || "toggle";
|
|
24
|
-
const finalTestId = dataTestId || "toggle";
|
|
25
|
-
const [isHovered, setIsHovered] = useState(false);
|
|
26
|
-
const internalRef = useRef(null);
|
|
27
|
-
const combinedRef = useCallback(
|
|
28
|
-
(element) => {
|
|
29
|
-
internalRef.current = element;
|
|
30
|
-
if (!ref) return;
|
|
31
|
-
if (typeof ref === "function") {
|
|
32
|
-
ref(element);
|
|
33
|
-
} else if ("current" in ref) {
|
|
34
|
-
ref.current = element;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[ref]
|
|
38
|
-
);
|
|
39
|
-
const handleMouseEnter = () => {
|
|
40
|
-
if (!disabled) {
|
|
41
|
-
setIsHovered(true);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const handleMouseLeave = () => {
|
|
45
|
-
setIsHovered(false);
|
|
46
|
-
};
|
|
47
|
-
return /* @__PURE__ */ jsxs(
|
|
48
|
-
"div",
|
|
49
|
-
{
|
|
50
|
-
className: cn(
|
|
51
|
-
"toggle-wrapper",
|
|
52
|
-
disabled && "toggle-wrapper--disabled",
|
|
53
|
-
`toggle-wrapper--${size}`
|
|
54
|
-
),
|
|
55
|
-
"data-cy": `${finalDataCy}-wrapper`,
|
|
56
|
-
"data-testid": `${finalTestId}-wrapper`,
|
|
57
|
-
children: [
|
|
58
|
-
/* @__PURE__ */ jsxs(
|
|
59
|
-
"label",
|
|
60
|
-
{
|
|
61
|
-
className: cn(
|
|
62
|
-
"toggle__container",
|
|
63
|
-
labelPosition === "start" && "toggle__container--label-start"
|
|
64
|
-
),
|
|
65
|
-
htmlFor: id,
|
|
66
|
-
onMouseEnter: handleMouseEnter,
|
|
67
|
-
onMouseLeave: handleMouseLeave,
|
|
68
|
-
children: [
|
|
69
|
-
label && labelPosition === "start" && /* @__PURE__ */ jsx(
|
|
70
|
-
"span",
|
|
71
|
-
{
|
|
72
|
-
className: "toggle__label",
|
|
73
|
-
"data-cy": `${finalDataCy}-label`,
|
|
74
|
-
"data-testid": `${finalTestId}-label`,
|
|
75
|
-
children: label
|
|
76
|
-
}
|
|
77
|
-
),
|
|
78
|
-
/* @__PURE__ */ jsx(
|
|
79
|
-
"input",
|
|
80
|
-
{
|
|
81
|
-
ref: combinedRef,
|
|
82
|
-
id,
|
|
83
|
-
type: "checkbox",
|
|
84
|
-
role: "switch",
|
|
85
|
-
checked,
|
|
86
|
-
defaultChecked,
|
|
87
|
-
className: cn("toggle__input", className),
|
|
88
|
-
"aria-describedby": helperText ? helperId : void 0,
|
|
89
|
-
"data-cy": finalDataCy,
|
|
90
|
-
"data-testid": finalTestId,
|
|
91
|
-
disabled,
|
|
92
|
-
...props
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
/* @__PURE__ */ jsx(
|
|
96
|
-
"span",
|
|
97
|
-
{
|
|
98
|
-
className: cn(
|
|
99
|
-
"toggle__track",
|
|
100
|
-
`toggle__track--${size}`,
|
|
101
|
-
isHovered && !disabled && "toggle__track--hover"
|
|
102
|
-
),
|
|
103
|
-
"data-cy": `${finalDataCy}-track`,
|
|
104
|
-
"data-testid": `${finalTestId}-track`,
|
|
105
|
-
"aria-hidden": "true",
|
|
106
|
-
children: /* @__PURE__ */ jsx(
|
|
107
|
-
"span",
|
|
108
|
-
{
|
|
109
|
-
className: cn(
|
|
110
|
-
"toggle__knob",
|
|
111
|
-
`toggle__knob--${size}`,
|
|
112
|
-
isHovered && !disabled && "toggle__knob--hover"
|
|
113
|
-
),
|
|
114
|
-
"data-cy": `${finalDataCy}-knob`,
|
|
115
|
-
"data-testid": `${finalTestId}-knob`
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
),
|
|
120
|
-
label && labelPosition === "end" && /* @__PURE__ */ jsx(
|
|
121
|
-
"span",
|
|
122
|
-
{
|
|
123
|
-
className: "toggle__label",
|
|
124
|
-
"data-cy": `${finalDataCy}-label`,
|
|
125
|
-
"data-testid": `${finalTestId}-label`,
|
|
126
|
-
children: label
|
|
127
|
-
}
|
|
128
|
-
)
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
),
|
|
132
|
-
helperText && /* @__PURE__ */ jsx(
|
|
133
|
-
"span",
|
|
134
|
-
{
|
|
135
|
-
id: helperId,
|
|
136
|
-
className: "toggle__helper",
|
|
137
|
-
"data-cy": `${finalDataCy}-helper`,
|
|
138
|
-
"data-testid": `${finalTestId}-helper`,
|
|
139
|
-
children: helperText
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
]
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
Toggle.displayName = "Toggle";
|
|
148
|
-
export {
|
|
149
|
-
Toggle
|
|
150
|
-
};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{forwardRef as a,useId as r,useRef as n,useState as i,useEffect as l,useCallback as c,useImperativeHandle as s}from"react";import{cn as o}from"./index33.js";import{errorStyles as d,helperStyles as p,labelDisabledStyles as u,labelErrorStyles as f,labelBaseStyles as m,digitErrorStyles as h,digitBaseStyles as y,containerCenteredStyles as g,containerBaseStyles as $,wrapperFullWidthStyles as b,wrapperStyles as v}from"./index44.js";const D=a(({length:a=4,label:D,value:x="",onChange:k,onComplete:A,error:N,helperText:w,disabled:j=!1,autoFocus:I=!1,fullWidth:C=!1,centered:E=!1,type:P="numeric",required:T=!1,"data-cy":q,"data-testid":z},F)=>{const L=r(),O=`${L}-error`,Z=`${L}-helper`,B=q||"otp-input",H=z||"otp-input",K=n([]),[M,R]=i(()=>x.split("").slice(0,a).concat(Array(a).fill("")).slice(0,a));l(()=>{const e=x.split("").slice(0,a).concat(Array(a).fill("")).slice(0,a);R(e)},[x,a]);const V=c(e=>"numeric"===P?/^\d$/.test(e):/^[a-zA-Z0-9]$/.test(e),[P]),W=c(e=>{R(e);const t=e.join("");k?.(t),e.every(e=>""!==e)&&e.length===a&&A?.(t)},[k,A,a]),G=c(e=>{const t=K.current[e];t&&(t.focus(),t.select())},[]),J=c((e,t)=>{const r=t.target.value;if(1===r.length&&V(r)){const t=[...M];t[e]=r,W(t),e<a-1&&G(e+1)}else if(r.length>1){const t=r.split("").filter(V),n=[...M];t.forEach((t,r)=>{e+r<a&&(n[e+r]=t)}),W(n);const i=n.findIndex(e=>""===e);G(-1===i?a-1:i)}},[M,a,V,W,G]),Q=c((e,t)=>{switch(t.key){case"Backspace":if(t.preventDefault(),M[e]){const t=[...M];t[e]="",W(t)}else if(e>0){const t=[...M];t[e-1]="",W(t),G(e-1)}break;case"Delete":if(t.preventDefault(),M[e]){const t=[...M];t[e]="",W(t)}break;case"ArrowLeft":t.preventDefault(),e>0&&G(e-1);break;case"ArrowRight":t.preventDefault(),e<a-1&&G(e+1);break;case"Home":t.preventDefault(),G(0);break;case"End":t.preventDefault(),G(a-1);break;default:if(1===t.key.length&&V(t.key)){t.preventDefault();const r=[...M];r[e]=t.key,W(r),e<a-1&&G(e+1)}}},[M,a,V,W,G]),S=c((e,t)=>{t.preventDefault();const r=t.clipboardData.getData("text").split("").filter(V);if(0===r.length)return;const n=[...M];r.forEach((t,r)=>{e+r<a&&(n[e+r]=t)}),W(n);const i=n.findIndex(e=>""===e);G(-1===i?a-1:i)},[M,a,V,W,G]),U=c(e=>{e.target.select()},[]);return s(F,()=>({focus:()=>{const e=M.findIndex(e=>""===e);G(-1===e?a-1:e)},clear:()=>{const e=Array(a).fill("");W(e),G(0)},getValue:()=>M.join("")}),[M,a,G,W]),l(()=>{I&&!j&&G(0)},[I,j,G]),/* @__PURE__ */e("div",{className:o(v,C&&b),"data-cy":`${B}-wrapper`,"data-testid":`${H}-wrapper`,children:[D&&/* @__PURE__ */t("label",{className:o(m,N&&f,j&&u),"data-cy":`${B}-label`,"data-testid":`${H}-label`,children:D}),
|
|
2
|
+
/* @__PURE__ */t("div",{className:o($,E&&g),role:"group","aria-label":D||"OTP Input","data-cy":`${B}-container`,"data-testid":`${H}-container`,children:Array.from({length:a},(e,r)=>/* @__PURE__ */t("input",{ref:e=>{K.current[r]=e},type:"text",inputMode:"numeric"===P?"numeric":"text",pattern:"numeric"===P?"[0-9]*":"[a-zA-Z0-9]*",maxLength:1,value:M[r]||"",onChange:e=>J(r,e),onKeyDown:e=>Q(r,e),onPaste:e=>S(r,e),onFocus:U,disabled:j,required:T,"aria-label":`Digit ${r+1} of ${a}`,"aria-invalid":N?"true":"false","aria-describedby":N?O:w?Z:void 0,className:o(y,N&&h),"data-otp-digit":!0,"data-cy":`${B}-digit-${r}`,"data-testid":`${H}-digit-${r}`,autoComplete:"one-time-code"},r))}),N&&/* @__PURE__ */t("span",{id:O,className:d,role:"alert","data-cy":`${B}-error`,"data-testid":`${H}-error`,children:N}),w&&!N&&/* @__PURE__ */t("span",{id:Z,className:p,"data-cy":`${B}-helper`,"data-testid":`${H}-helper`,children:w})]})});D.displayName="OTPInput";export{D as OTPInput};
|
package/dist/index15.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),t=require("./index33.cjs"),s=require("./index45.cjs"),l=a.forwardRef(({label:l,labelPosition:r="end",helperText:d,size:c="md",className:n,id:i,disabled:o,checked:p,defaultChecked:y,"data-cy":u,"data-testid":b,...h},S)=>{const k=a.useId(),x=i||k,m=`${x}-helper`,$=u||"toggle",j=b||"toggle",[g,N]=a.useState(!1),f=a.useRef(null),v=a.useCallback(e=>{f.current=e,S&&("function"==typeof S?S(e):"current"in S&&(S.current=e))},[S]);return e.jsxs("div",{className:t.cn(s.wrapperStyles,o&&s.wrapperDisabledStyles),"data-cy":`${$}-wrapper`,"data-testid":`${j}-wrapper`,children:[e.jsxs("label",{className:t.cn(s.labelContainerStyles,o&&"cursor-not-allowed","start"===r&&s.labelContainerReversedStyles),htmlFor:x,onMouseEnter:()=>{o||N(!0)},onMouseLeave:()=>{N(!1)},children:[l&&"start"===r&&e.jsx("span",{className:s.labelTextStyles,"data-cy":`${$}-label`,"data-testid":`${j}-label`,children:l}),e.jsx("input",{ref:v,id:x,type:"checkbox",role:"switch",checked:p,defaultChecked:y,className:t.cn(s.inputSrOnlyStyles,n),"aria-describedby":d?m:void 0,"data-cy":$,"data-testid":j,disabled:o,...h}),e.jsx("span",{className:t.cn(s.trackBaseStyles,s.trackSizeMap[c],g&&!o&&s.trackHoverStyles,g&&!o&&s.trackHoverCheckedStyles),"data-cy":`${$}-track`,"data-testid":`${j}-track`,"aria-hidden":"true",children:e.jsx("span",{className:t.cn(s.knobBaseStyles,s.knobSizeMap[c],g&&!o&&s.knobHoverShadowStyles),"data-cy":`${$}-knob`,"data-testid":`${j}-knob`})}),l&&"end"===r&&e.jsx("span",{className:s.labelTextStyles,"data-cy":`${$}-label`,"data-testid":`${j}-label`,children:l})]}),d&&e.jsx("span",{id:m,className:s.helperStyles,"data-cy":`${$}-helper`,"data-testid":`${j}-helper`,children:d})]})});l.displayName="Toggle",exports.Toggle=l;
|
package/dist/index15.js
CHANGED
|
@@ -1,65 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
const Tabs = TabsPrimitive.Root;
|
|
7
|
-
const TabsList = forwardRef(
|
|
8
|
-
({ className, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
9
|
-
const finalDataCy = dataCy || "tabs-list";
|
|
10
|
-
const finalTestId = dataTestId || "tabs-list";
|
|
11
|
-
return /* @__PURE__ */ jsx(
|
|
12
|
-
TabsPrimitive.List,
|
|
13
|
-
{
|
|
14
|
-
ref,
|
|
15
|
-
className: cn("tabs-list", className),
|
|
16
|
-
"data-cy": finalDataCy,
|
|
17
|
-
"data-testid": finalTestId,
|
|
18
|
-
...props
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
|
-
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
24
|
-
const TabsTrigger = forwardRef(
|
|
25
|
-
({ className, value, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
26
|
-
const finalDataCy = dataCy || (value ? `tabs-trigger-${value}` : "tabs-trigger");
|
|
27
|
-
const finalTestId = dataTestId || (value ? `tabs-trigger-${value}` : "tabs-trigger");
|
|
28
|
-
return /* @__PURE__ */ jsx(
|
|
29
|
-
TabsPrimitive.Trigger,
|
|
30
|
-
{
|
|
31
|
-
ref,
|
|
32
|
-
className: cn("tabs-trigger", className),
|
|
33
|
-
value,
|
|
34
|
-
"data-cy": finalDataCy,
|
|
35
|
-
"data-testid": finalTestId,
|
|
36
|
-
...props
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
);
|
|
41
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
42
|
-
const TabsContent = forwardRef(
|
|
43
|
-
({ className, value, "data-cy": dataCy, "data-testid": dataTestId, ...props }, ref) => {
|
|
44
|
-
const finalDataCy = dataCy || (value ? `tabs-content-${value}` : "tabs-content");
|
|
45
|
-
const finalTestId = dataTestId || (value ? `tabs-content-${value}` : "tabs-content");
|
|
46
|
-
return /* @__PURE__ */ jsx(
|
|
47
|
-
TabsPrimitive.Content,
|
|
48
|
-
{
|
|
49
|
-
ref,
|
|
50
|
-
className: cn("tabs-content", className),
|
|
51
|
-
value,
|
|
52
|
-
"data-cy": finalDataCy,
|
|
53
|
-
"data-testid": finalTestId,
|
|
54
|
-
...props
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
60
|
-
export {
|
|
61
|
-
Tabs,
|
|
62
|
-
TabsContent,
|
|
63
|
-
TabsList,
|
|
64
|
-
TabsTrigger
|
|
65
|
-
};
|
|
1
|
+
import{jsxs as e,jsx as a}from"react/jsx-runtime";import{forwardRef as t,useId as d,useState as r,useRef as s,useCallback as l}from"react";import{cn as c}from"./index33.js";import{labelTextStyles as i,helperStyles as n,inputSrOnlyStyles as o,knobHoverShadowStyles as p,knobSizeMap as m,knobBaseStyles as h,trackHoverCheckedStyles as b,trackHoverStyles as u,trackSizeMap as $,trackBaseStyles as y,labelContainerReversedStyles as N,labelContainerStyles as f,wrapperDisabledStyles as k,wrapperStyles as g}from"./index45.js";const x=t(({label:t,labelPosition:x="end",helperText:w,size:j="md",className:v,id:C,disabled:M,checked:T,defaultChecked:z,"data-cy":E,"data-testid":F,...L},P)=>{const q=d(),A=C||q,B=`${A}-helper`,D=E||"toggle",G=F||"toggle",[H,I]=r(!1),J=s(null),K=l(e=>{J.current=e,P&&("function"==typeof P?P(e):"current"in P&&(P.current=e))},[P]);/* @__PURE__ */
|
|
2
|
+
return e("div",{className:c(g,M&&k),"data-cy":`${D}-wrapper`,"data-testid":`${G}-wrapper`,children:[
|
|
3
|
+
/* @__PURE__ */e("label",{className:c(f,M&&"cursor-not-allowed","start"===x&&N),htmlFor:A,onMouseEnter:()=>{M||I(!0)},onMouseLeave:()=>{I(!1)},children:[t&&"start"===x&&/* @__PURE__ */a("span",{className:i,"data-cy":`${D}-label`,"data-testid":`${G}-label`,children:t}),
|
|
4
|
+
/* @__PURE__ */a("input",{ref:K,id:A,type:"checkbox",role:"switch",checked:T,defaultChecked:z,className:c(o,v),"aria-describedby":w?B:void 0,"data-cy":D,"data-testid":G,disabled:M,...L}),
|
|
5
|
+
/* @__PURE__ */a("span",{className:c(y,$[j],H&&!M&&u,H&&!M&&b),"data-cy":`${D}-track`,"data-testid":`${G}-track`,"aria-hidden":"true",children:/* @__PURE__ */a("span",{className:c(h,m[j],H&&!M&&p),"data-cy":`${D}-knob`,"data-testid":`${G}-knob`})}),t&&"end"===x&&/* @__PURE__ */a("span",{className:i,"data-cy":`${D}-label`,"data-testid":`${G}-label`,children:t})]}),w&&/* @__PURE__ */a("span",{id:B,className:n,"data-cy":`${D}-helper`,"data-testid":`${G}-helper`,children:w})]})});x.displayName="Toggle";export{x as Toggle};
|
package/dist/index16.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),e=require("react"),a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),e=require("react"),a=require("@radix-ui/react-tabs"),s=require("./index33.cjs"),r=require("./index46.cjs");function i(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const a in t)if("default"!==a){const s=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(e,a,s.get?s:{enumerable:!0,get:()=>t[a]})}return e.default=t,Object.freeze(e)}const n=i(a),c=n.Root,o=e.forwardRef(({className:e,"data-cy":a,"data-testid":i,...c},o)=>{const d=a||"tabs-list",l=i||"tabs-list";return t.jsx(n.List,{ref:o,className:s.cn(r.listStyles,e),"data-cy":d,"data-testid":l,...c})});o.displayName=n.List.displayName;const d=e.forwardRef(({className:e,value:a,"data-cy":i,"data-testid":c,...o},d)=>{const l=i||(a?`tabs-trigger-${a}`:"tabs-trigger"),u=c||(a?`tabs-trigger-${a}`:"tabs-trigger");return t.jsx(n.Trigger,{ref:d,className:s.cn(r.triggerStyles,e),value:a,"data-cy":l,"data-testid":u,...o})});d.displayName=n.Trigger.displayName;const l=e.forwardRef(({className:e,value:a,"data-cy":i,"data-testid":c,...o},d)=>{const l=i||(a?`tabs-content-${a}`:"tabs-content"),u=c||(a?`tabs-content-${a}`:"tabs-content");return t.jsx(n.Content,{ref:d,className:s.cn(r.contentStyles,e),value:a,"data-cy":l,"data-testid":u,...o})});l.displayName=n.Content.displayName,exports.Tabs=c,exports.TabsContent=l,exports.TabsList=o,exports.TabsTrigger=d;
|