@cdx-ui/primitives 0.0.1-alpha.9 → 0.0.1-beta.10
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 +35 -0
- package/lib/commonjs/avatar/context.js +11 -0
- package/lib/commonjs/avatar/context.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarBadge.js +20 -0
- package/lib/commonjs/avatar/createAvatarBadge.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarIcon.js +30 -0
- package/lib/commonjs/avatar/createAvatarIcon.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarImage.js +51 -0
- package/lib/commonjs/avatar/createAvatarImage.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarRoot.js +34 -0
- package/lib/commonjs/avatar/createAvatarRoot.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarText.js +42 -0
- package/lib/commonjs/avatar/createAvatarText.js.map +1 -0
- package/lib/commonjs/avatar/index.js +30 -0
- package/lib/commonjs/avatar/index.js.map +1 -0
- package/lib/commonjs/avatar/types.js +6 -0
- package/lib/commonjs/avatar/types.js.map +1 -0
- package/lib/commonjs/button/index.js +25 -19
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/checkbox/createCheckboxIcon.js +3 -2
- package/lib/commonjs/checkbox/createCheckboxIcon.js.map +1 -1
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +2 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/commonjs/checkbox/index.js +19 -21
- package/lib/commonjs/checkbox/index.js.map +1 -1
- package/lib/commonjs/dialog/context.js +11 -0
- package/lib/commonjs/dialog/context.js.map +1 -0
- package/lib/commonjs/dialog/createDialogBody.js +21 -0
- package/lib/commonjs/dialog/createDialogBody.js.map +1 -0
- package/lib/commonjs/dialog/createDialogClose.js +37 -0
- package/lib/commonjs/dialog/createDialogClose.js.map +1 -0
- package/lib/commonjs/dialog/createDialogContent.js +141 -0
- package/lib/commonjs/dialog/createDialogContent.js.map +1 -0
- package/lib/commonjs/dialog/createDialogDescription.js +30 -0
- package/lib/commonjs/dialog/createDialogDescription.js.map +1 -0
- package/lib/commonjs/dialog/createDialogFooter.js +21 -0
- package/lib/commonjs/dialog/createDialogFooter.js.map +1 -0
- package/lib/commonjs/dialog/createDialogHeader.js +21 -0
- package/lib/commonjs/dialog/createDialogHeader.js.map +1 -0
- package/lib/commonjs/dialog/createDialogRoot.js +54 -0
- package/lib/commonjs/dialog/createDialogRoot.js.map +1 -0
- package/lib/commonjs/dialog/createDialogTitle.js +21 -0
- package/lib/commonjs/dialog/createDialogTitle.js.map +1 -0
- package/lib/commonjs/dialog/createDialogTrigger.js +37 -0
- package/lib/commonjs/dialog/createDialogTrigger.js.map +1 -0
- package/lib/commonjs/dialog/index.js +60 -0
- package/lib/commonjs/dialog/index.js.map +1 -0
- package/lib/commonjs/dialog/types.js +6 -0
- package/lib/commonjs/dialog/types.js.map +1 -0
- package/lib/commonjs/field/createFieldError.js +41 -0
- package/lib/commonjs/field/createFieldError.js.map +1 -0
- package/lib/commonjs/field/createFieldErrorIcon.js +18 -0
- package/lib/commonjs/field/createFieldErrorIcon.js.map +1 -0
- package/lib/commonjs/field/createFieldErrorText.js +18 -0
- package/lib/commonjs/field/createFieldErrorText.js.map +1 -0
- package/lib/commonjs/field/createFieldHelper.js +41 -0
- package/lib/commonjs/field/createFieldHelper.js.map +1 -0
- package/lib/commonjs/field/createFieldHelperText.js +18 -0
- package/lib/commonjs/field/createFieldHelperText.js.map +1 -0
- package/lib/commonjs/field/createFieldLabel.js +36 -0
- package/lib/commonjs/field/createFieldLabel.js.map +1 -0
- package/lib/commonjs/field/createFieldRoot.js +35 -0
- package/lib/commonjs/field/createFieldRoot.js.map +1 -0
- package/lib/commonjs/field/index.js +46 -0
- package/lib/commonjs/field/index.js.map +1 -0
- package/lib/commonjs/field/types.js +6 -0
- package/lib/commonjs/field/types.js.map +1 -0
- package/lib/commonjs/form/createFormRoot.js +21 -0
- package/lib/commonjs/form/createFormRoot.js.map +1 -0
- package/lib/commonjs/form/index.js +15 -0
- package/lib/commonjs/form/index.js.map +1 -0
- package/lib/commonjs/form/types.js +6 -0
- package/lib/commonjs/form/types.js.map +1 -0
- package/lib/commonjs/index.js +105 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/input/createInputField.js +7 -2
- package/lib/commonjs/input/createInputField.js.map +1 -1
- package/lib/commonjs/input/index.js +13 -19
- package/lib/commonjs/input/index.js.map +1 -1
- package/lib/commonjs/link/LinkProvider.js +28 -0
- package/lib/commonjs/link/LinkProvider.js.map +1 -0
- package/lib/commonjs/link/createLink.js +74 -0
- package/lib/commonjs/link/createLink.js.map +1 -0
- package/lib/commonjs/link/index.js +27 -0
- package/lib/commonjs/link/index.js.map +1 -0
- package/lib/commonjs/link/types.js +6 -0
- package/lib/commonjs/link/types.js.map +1 -0
- package/lib/commonjs/link/useLink.js +56 -0
- package/lib/commonjs/link/useLink.js.map +1 -0
- package/lib/commonjs/list-item/context.js +11 -0
- package/lib/commonjs/list-item/context.js.map +1 -0
- package/lib/commonjs/list-item/createListItemContent.js +30 -0
- package/lib/commonjs/list-item/createListItemContent.js.map +1 -0
- package/lib/commonjs/list-item/createListItemDescription.js +25 -0
- package/lib/commonjs/list-item/createListItemDescription.js.map +1 -0
- package/lib/commonjs/list-item/createListItemLeadingSlot.js +34 -0
- package/lib/commonjs/list-item/createListItemLeadingSlot.js.map +1 -0
- package/lib/commonjs/list-item/createListItemMeta.js +25 -0
- package/lib/commonjs/list-item/createListItemMeta.js.map +1 -0
- package/lib/commonjs/list-item/createListItemRoot.js +142 -0
- package/lib/commonjs/list-item/createListItemRoot.js.map +1 -0
- package/lib/commonjs/list-item/createListItemSectionHeader.js +54 -0
- package/lib/commonjs/list-item/createListItemSectionHeader.js.map +1 -0
- package/lib/commonjs/list-item/createListItemTitle.js +25 -0
- package/lib/commonjs/list-item/createListItemTitle.js.map +1 -0
- package/lib/commonjs/list-item/createListItemTrailingSlot.js +28 -0
- package/lib/commonjs/list-item/createListItemTrailingSlot.js.map +1 -0
- package/lib/commonjs/list-item/index.js +55 -0
- package/lib/commonjs/list-item/index.js.map +1 -0
- package/lib/commonjs/list-item/types.js +6 -0
- package/lib/commonjs/list-item/types.js.map +1 -0
- package/lib/commonjs/otp-input/context.js +14 -0
- package/lib/commonjs/otp-input/context.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js +29 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputField.js +104 -0
- package/lib/commonjs/otp-input/createOtpInputField.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js +136 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/commonjs/otp-input/index.js +48 -0
- package/lib/commonjs/otp-input/index.js.map +1 -0
- package/lib/commonjs/otp-input/types.js +6 -0
- package/lib/commonjs/otp-input/types.js.map +1 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js +73 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/commonjs/otp-input/utils/filterValue.js +46 -0
- package/lib/commonjs/otp-input/utils/filterValue.js.map +1 -0
- package/lib/commonjs/overlay/OverlayContainer.js +8 -11
- package/lib/commonjs/overlay/OverlayContainer.js.map +1 -1
- package/lib/commonjs/overlay/index.js +7 -0
- package/lib/commonjs/overlay/index.js.map +1 -1
- package/lib/commonjs/overlay/useEscapeKey.js +14 -0
- package/lib/commonjs/overlay/useEscapeKey.js.map +1 -0
- package/lib/commonjs/overlay/useEscapeKey.web.js +30 -0
- package/lib/commonjs/overlay/useEscapeKey.web.js.map +1 -0
- package/lib/commonjs/progress/context.js +11 -0
- package/lib/commonjs/progress/context.js.map +1 -0
- package/lib/commonjs/progress/createProgressIndicator.js +42 -0
- package/lib/commonjs/progress/createProgressIndicator.js.map +1 -0
- package/lib/commonjs/progress/createProgressRoot.js +96 -0
- package/lib/commonjs/progress/createProgressRoot.js.map +1 -0
- package/lib/commonjs/progress/index.js +25 -0
- package/lib/commonjs/progress/index.js.map +1 -0
- package/lib/commonjs/progress/types.js +6 -0
- package/lib/commonjs/progress/types.js.map +1 -0
- package/lib/commonjs/select/context.js +8 -43
- package/lib/commonjs/select/context.js.map +1 -1
- package/lib/commonjs/select/createSelectItem.js +1 -1
- package/lib/commonjs/select/createSelectItem.js.map +1 -1
- package/lib/commonjs/select/createSelectRoot.js +9 -6
- package/lib/commonjs/select/createSelectRoot.js.map +1 -1
- package/lib/commonjs/select/createSelectTrigger.js +53 -12
- package/lib/commonjs/select/createSelectTrigger.js.map +1 -1
- package/lib/commonjs/utils/createPortal.js +23 -0
- package/lib/commonjs/utils/createPortal.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.web.js +1 -4
- package/lib/commonjs/utils/dataAttributes.web.js.map +1 -1
- package/lib/module/avatar/context.js +5 -0
- package/lib/module/avatar/context.js.map +1 -0
- package/lib/module/{input/createInputIcon.js → avatar/createAvatarBadge.js} +3 -3
- package/lib/module/avatar/createAvatarBadge.js.map +1 -0
- package/lib/module/avatar/createAvatarIcon.js +25 -0
- package/lib/module/avatar/createAvatarIcon.js.map +1 -0
- package/lib/module/avatar/createAvatarImage.js +46 -0
- package/lib/module/avatar/createAvatarImage.js.map +1 -0
- package/lib/module/avatar/createAvatarRoot.js +29 -0
- package/lib/module/avatar/createAvatarRoot.js.map +1 -0
- package/lib/module/avatar/createAvatarText.js +37 -0
- package/lib/module/avatar/createAvatarText.js.map +1 -0
- package/lib/module/avatar/index.js +26 -0
- package/lib/module/avatar/index.js.map +1 -0
- package/lib/module/avatar/types.js +4 -0
- package/lib/module/avatar/types.js.map +1 -0
- package/lib/module/button/index.js +19 -19
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/checkbox/createCheckboxIcon.js +3 -2
- package/lib/module/checkbox/createCheckboxIcon.js.map +1 -1
- package/lib/module/checkbox/createCheckboxRoot.web.js +2 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/module/checkbox/index.js +18 -19
- package/lib/module/checkbox/index.js.map +1 -1
- package/lib/module/dialog/context.js +5 -0
- package/lib/module/dialog/context.js.map +1 -0
- package/lib/module/dialog/createDialogBody.js +15 -0
- package/lib/module/dialog/createDialogBody.js.map +1 -0
- package/lib/module/dialog/createDialogClose.js +31 -0
- package/lib/module/dialog/createDialogClose.js.map +1 -0
- package/lib/module/dialog/createDialogContent.js +136 -0
- package/lib/module/dialog/createDialogContent.js.map +1 -0
- package/lib/module/dialog/createDialogDescription.js +24 -0
- package/lib/module/dialog/createDialogDescription.js.map +1 -0
- package/lib/module/dialog/createDialogFooter.js +15 -0
- package/lib/module/dialog/createDialogFooter.js.map +1 -0
- package/lib/module/dialog/createDialogHeader.js +15 -0
- package/lib/module/dialog/createDialogHeader.js.map +1 -0
- package/lib/module/dialog/createDialogRoot.js +49 -0
- package/lib/module/dialog/createDialogRoot.js.map +1 -0
- package/lib/module/dialog/createDialogTitle.js +15 -0
- package/lib/module/dialog/createDialogTitle.js.map +1 -0
- package/lib/module/dialog/createDialogTrigger.js +31 -0
- package/lib/module/dialog/createDialogTrigger.js.map +1 -0
- package/lib/module/dialog/index.js +45 -0
- package/lib/module/dialog/index.js.map +1 -0
- package/lib/module/dialog/types.js +4 -0
- package/lib/module/dialog/types.js.map +1 -0
- package/lib/module/field/createFieldError.js +35 -0
- package/lib/module/field/createFieldError.js.map +1 -0
- package/lib/module/field/createFieldErrorIcon.js +13 -0
- package/lib/module/field/createFieldErrorIcon.js.map +1 -0
- package/lib/module/field/createFieldErrorText.js +13 -0
- package/lib/module/field/createFieldErrorText.js.map +1 -0
- package/lib/module/field/createFieldHelper.js +35 -0
- package/lib/module/field/createFieldHelper.js.map +1 -0
- package/lib/module/field/createFieldHelperText.js +13 -0
- package/lib/module/field/createFieldHelperText.js.map +1 -0
- package/lib/module/field/createFieldLabel.js +31 -0
- package/lib/module/field/createFieldLabel.js.map +1 -0
- package/lib/module/field/createFieldRoot.js +29 -0
- package/lib/module/field/createFieldRoot.js.map +1 -0
- package/lib/module/field/index.js +42 -0
- package/lib/module/field/index.js.map +1 -0
- package/lib/module/field/types.js +4 -0
- package/lib/module/field/types.js.map +1 -0
- package/lib/module/form/createFormRoot.js +15 -0
- package/lib/module/form/createFormRoot.js.map +1 -0
- package/lib/module/form/index.js +11 -0
- package/lib/module/form/index.js.map +1 -0
- package/lib/module/form/types.js +4 -0
- package/lib/module/form/types.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/input/createInputField.js +8 -3
- package/lib/module/input/createInputField.js.map +1 -1
- package/lib/module/input/index.js +12 -17
- package/lib/module/input/index.js.map +1 -1
- package/lib/module/link/LinkProvider.js +23 -0
- package/lib/module/link/LinkProvider.js.map +1 -0
- package/lib/module/link/createLink.js +68 -0
- package/lib/module/link/createLink.js.map +1 -0
- package/lib/module/link/index.js +6 -0
- package/lib/module/link/index.js.map +1 -0
- package/lib/module/link/types.js +4 -0
- package/lib/module/link/types.js.map +1 -0
- package/lib/module/link/useLink.js +52 -0
- package/lib/module/link/useLink.js.map +1 -0
- package/lib/module/list-item/context.js +5 -0
- package/lib/module/list-item/context.js.map +1 -0
- package/lib/module/list-item/createListItemContent.js +24 -0
- package/lib/module/list-item/createListItemContent.js.map +1 -0
- package/lib/module/list-item/createListItemDescription.js +19 -0
- package/lib/module/list-item/createListItemDescription.js.map +1 -0
- package/lib/module/list-item/createListItemLeadingSlot.js +28 -0
- package/lib/module/list-item/createListItemLeadingSlot.js.map +1 -0
- package/lib/module/list-item/createListItemMeta.js +19 -0
- package/lib/module/list-item/createListItemMeta.js.map +1 -0
- package/lib/module/list-item/createListItemRoot.js +136 -0
- package/lib/module/list-item/createListItemRoot.js.map +1 -0
- package/lib/module/list-item/createListItemSectionHeader.js +48 -0
- package/lib/module/list-item/createListItemSectionHeader.js.map +1 -0
- package/lib/module/list-item/createListItemTitle.js +19 -0
- package/lib/module/list-item/createListItemTitle.js.map +1 -0
- package/lib/module/list-item/createListItemTrailingSlot.js +22 -0
- package/lib/module/list-item/createListItemTrailingSlot.js.map +1 -0
- package/lib/module/list-item/index.js +39 -0
- package/lib/module/list-item/index.js.map +1 -0
- package/lib/module/list-item/types.js +4 -0
- package/lib/module/list-item/types.js.map +1 -0
- package/lib/module/otp-input/context.js +6 -0
- package/lib/module/otp-input/context.js.map +1 -0
- package/lib/module/otp-input/createOtpInputCell.js +24 -0
- package/lib/module/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/module/otp-input/createOtpInputField.js +99 -0
- package/lib/module/otp-input/createOtpInputField.js.map +1 -0
- package/lib/module/otp-input/createOtpInputRoot.js +131 -0
- package/lib/module/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/module/otp-input/index.js +20 -0
- package/lib/module/otp-input/index.js.map +1 -0
- package/lib/module/otp-input/types.js +4 -0
- package/lib/module/otp-input/types.js.map +1 -0
- package/lib/module/otp-input/utils/applyValueChange.js +69 -0
- package/lib/module/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/module/otp-input/utils/filterValue.js +40 -0
- package/lib/module/otp-input/utils/filterValue.js.map +1 -0
- package/lib/module/overlay/OverlayContainer.js +8 -11
- package/lib/module/overlay/OverlayContainer.js.map +1 -1
- package/lib/module/overlay/index.js +1 -0
- package/lib/module/overlay/index.js.map +1 -1
- package/lib/module/overlay/useEscapeKey.js +10 -0
- package/lib/module/overlay/useEscapeKey.js.map +1 -0
- package/lib/module/overlay/useEscapeKey.web.js +27 -0
- package/lib/module/overlay/useEscapeKey.web.js.map +1 -0
- package/lib/module/progress/context.js +5 -0
- package/lib/module/progress/context.js.map +1 -0
- package/lib/module/progress/createProgressIndicator.js +37 -0
- package/lib/module/progress/createProgressIndicator.js.map +1 -0
- package/lib/module/progress/createProgressRoot.js +91 -0
- package/lib/module/progress/createProgressRoot.js.map +1 -0
- package/lib/module/progress/index.js +15 -0
- package/lib/module/progress/index.js.map +1 -0
- package/lib/module/progress/types.js +4 -0
- package/lib/module/progress/types.js.map +1 -0
- package/lib/module/select/context.js +4 -42
- package/lib/module/select/context.js.map +1 -1
- package/lib/module/select/createSelectItem.js +2 -2
- package/lib/module/select/createSelectItem.js.map +1 -1
- package/lib/module/select/createSelectRoot.js +10 -7
- package/lib/module/select/createSelectRoot.js.map +1 -1
- package/lib/module/select/createSelectTrigger.js +56 -15
- package/lib/module/select/createSelectTrigger.js.map +1 -1
- package/lib/module/utils/createPortal.js +19 -0
- package/lib/module/utils/createPortal.js.map +1 -0
- package/lib/module/utils/dataAttributes.web.js +1 -4
- package/lib/module/utils/dataAttributes.web.js.map +1 -1
- package/lib/typescript/avatar/context.d.ts +6 -0
- package/lib/typescript/avatar/context.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarBadge.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarBadge.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarIcon.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarIcon.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarImage.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarImage.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarRoot.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarRoot.d.ts.map +1 -0
- package/lib/typescript/avatar/createAvatarText.d.ts +4 -0
- package/lib/typescript/avatar/createAvatarText.d.ts.map +1 -0
- package/lib/typescript/avatar/index.d.ts +11 -0
- package/lib/typescript/avatar/index.d.ts.map +1 -0
- package/lib/typescript/avatar/types.d.ts +33 -0
- package/lib/typescript/avatar/types.d.ts.map +1 -0
- package/lib/typescript/button/index.d.ts +2 -1
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/checkbox/context.d.ts +2 -2
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +1 -1
- package/lib/typescript/checkbox/index.d.ts +3 -2
- package/lib/typescript/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +8 -3
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -1
- package/lib/typescript/dialog/context.d.ts +6 -0
- package/lib/typescript/dialog/context.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogBody.d.ts +4 -0
- package/lib/typescript/dialog/createDialogBody.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogClose.d.ts +4 -0
- package/lib/typescript/dialog/createDialogClose.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogContent.d.ts +4 -0
- package/lib/typescript/dialog/createDialogContent.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogDescription.d.ts +4 -0
- package/lib/typescript/dialog/createDialogDescription.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogFooter.d.ts +4 -0
- package/lib/typescript/dialog/createDialogFooter.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogHeader.d.ts +4 -0
- package/lib/typescript/dialog/createDialogHeader.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogRoot.d.ts +4 -0
- package/lib/typescript/dialog/createDialogRoot.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogTitle.d.ts +4 -0
- package/lib/typescript/dialog/createDialogTitle.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogTrigger.d.ts +4 -0
- package/lib/typescript/dialog/createDialogTrigger.d.ts.map +1 -0
- package/lib/typescript/dialog/index.d.ts +18 -0
- package/lib/typescript/dialog/index.d.ts.map +1 -0
- package/lib/typescript/dialog/types.d.ts +52 -0
- package/lib/typescript/dialog/types.d.ts.map +1 -0
- package/lib/typescript/field/createFieldError.d.ts +5 -0
- package/lib/typescript/field/createFieldError.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorText.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelper.d.ts +5 -0
- package/lib/typescript/field/createFieldHelper.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelperText.d.ts +5 -0
- package/lib/typescript/field/createFieldHelperText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldLabel.d.ts +6 -0
- package/lib/typescript/field/createFieldLabel.d.ts.map +1 -0
- package/lib/typescript/field/createFieldRoot.d.ts +6 -0
- package/lib/typescript/field/createFieldRoot.d.ts.map +1 -0
- package/lib/typescript/field/index.d.ts +13 -0
- package/lib/typescript/field/index.d.ts.map +1 -0
- package/lib/typescript/field/types.d.ts +63 -0
- package/lib/typescript/field/types.d.ts.map +1 -0
- package/lib/typescript/form/createFormRoot.d.ts +4 -0
- package/lib/typescript/form/createFormRoot.d.ts.map +1 -0
- package/lib/typescript/form/index.d.ts +6 -0
- package/lib/typescript/form/index.d.ts.map +1 -0
- package/lib/typescript/form/types.d.ts +14 -0
- package/lib/typescript/form/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/input/createInputField.d.ts.map +1 -1
- package/lib/typescript/input/index.d.ts +3 -3
- package/lib/typescript/input/index.d.ts.map +1 -1
- package/lib/typescript/input/types.d.ts +1 -2
- package/lib/typescript/input/types.d.ts.map +1 -1
- package/lib/typescript/link/LinkProvider.d.ts +36 -0
- package/lib/typescript/link/LinkProvider.d.ts.map +1 -0
- package/lib/typescript/link/createLink.d.ts +6 -0
- package/lib/typescript/link/createLink.d.ts.map +1 -0
- package/lib/typescript/link/index.d.ts +6 -0
- package/lib/typescript/link/index.d.ts.map +1 -0
- package/lib/typescript/link/types.d.ts +45 -0
- package/lib/typescript/link/types.d.ts.map +1 -0
- package/lib/typescript/link/useLink.d.ts +9 -0
- package/lib/typescript/link/useLink.d.ts.map +1 -0
- package/lib/typescript/list-item/context.d.ts +6 -0
- package/lib/typescript/list-item/context.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemContent.d.ts +3 -0
- package/lib/typescript/list-item/createListItemContent.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemDescription.d.ts +3 -0
- package/lib/typescript/list-item/createListItemDescription.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts +4 -0
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemMeta.d.ts +3 -0
- package/lib/typescript/list-item/createListItemMeta.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemRoot.d.ts +4 -0
- package/lib/typescript/list-item/createListItemRoot.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts +4 -0
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemTitle.d.ts +3 -0
- package/lib/typescript/list-item/createListItemTitle.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts +3 -0
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts.map +1 -0
- package/lib/typescript/list-item/index.d.ts +16 -0
- package/lib/typescript/list-item/index.d.ts.map +1 -0
- package/lib/typescript/list-item/types.d.ts +86 -0
- package/lib/typescript/list-item/types.d.ts.map +1 -0
- package/lib/typescript/otp-input/context.d.ts +10 -0
- package/lib/typescript/otp-input/context.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts.map +1 -0
- package/lib/typescript/otp-input/index.d.ts +11 -0
- package/lib/typescript/otp-input/index.d.ts.map +1 -0
- package/lib/typescript/otp-input/types.d.ts +75 -0
- package/lib/typescript/otp-input/types.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts +10 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts +7 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts.map +1 -0
- package/lib/typescript/overlay/OverlayContainer.d.ts +5 -1
- package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -1
- package/lib/typescript/overlay/index.d.ts +1 -0
- package/lib/typescript/overlay/index.d.ts.map +1 -1
- package/lib/typescript/overlay/useEscapeKey.d.ts +6 -0
- package/lib/typescript/overlay/useEscapeKey.d.ts.map +1 -0
- package/lib/typescript/overlay/useEscapeKey.web.d.ts +6 -0
- package/lib/typescript/overlay/useEscapeKey.web.d.ts.map +1 -0
- package/lib/typescript/progress/context.d.ts +13 -0
- package/lib/typescript/progress/context.d.ts.map +1 -0
- package/lib/typescript/progress/createProgressIndicator.d.ts +3 -0
- package/lib/typescript/progress/createProgressIndicator.d.ts.map +1 -0
- package/lib/typescript/progress/createProgressRoot.d.ts +4 -0
- package/lib/typescript/progress/createProgressRoot.d.ts.map +1 -0
- package/lib/typescript/progress/index.d.ts +10 -0
- package/lib/typescript/progress/index.d.ts.map +1 -0
- package/lib/typescript/progress/types.d.ts +25 -0
- package/lib/typescript/progress/types.d.ts.map +1 -0
- package/lib/typescript/select/context.d.ts +14 -7
- package/lib/typescript/select/context.d.ts.map +1 -1
- package/lib/typescript/select/createSelectRoot.d.ts.map +1 -1
- package/lib/typescript/select/createSelectTrigger.d.ts +2 -7
- package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -1
- package/lib/typescript/select/types.d.ts +4 -1
- package/lib/typescript/select/types.d.ts.map +1 -1
- package/lib/typescript/utils/createPortal.d.ts +11 -0
- package/lib/typescript/utils/createPortal.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.web.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/avatar/context.tsx +5 -0
- package/src/avatar/createAvatarBadge.tsx +12 -0
- package/src/avatar/createAvatarIcon.tsx +16 -0
- package/src/avatar/createAvatarImage.tsx +40 -0
- package/src/avatar/createAvatarRoot.tsx +23 -0
- package/src/avatar/createAvatarText.tsx +30 -0
- package/src/avatar/index.ts +43 -0
- package/src/avatar/types.ts +77 -0
- package/src/button/index.tsx +19 -19
- package/src/checkbox/createCheckboxIcon.tsx +2 -2
- package/src/checkbox/createCheckboxRoot.web.tsx +2 -0
- package/src/checkbox/index.ts +20 -20
- package/src/dialog/context.tsx +4 -0
- package/src/dialog/createDialogBody.tsx +11 -0
- package/src/dialog/createDialogClose.tsx +27 -0
- package/src/dialog/createDialogContent.tsx +122 -0
- package/src/dialog/createDialogDescription.tsx +20 -0
- package/src/dialog/createDialogFooter.tsx +11 -0
- package/src/dialog/createDialogHeader.tsx +11 -0
- package/src/dialog/createDialogRoot.tsx +66 -0
- package/src/dialog/createDialogTitle.tsx +11 -0
- package/src/dialog/createDialogTrigger.tsx +27 -0
- package/src/dialog/index.tsx +93 -0
- package/src/dialog/types.ts +88 -0
- package/src/field/createFieldError.tsx +32 -0
- package/src/field/createFieldErrorIcon.tsx +9 -0
- package/src/field/createFieldErrorText.tsx +9 -0
- package/src/field/createFieldHelper.tsx +28 -0
- package/src/field/createFieldHelperText.tsx +9 -0
- package/src/field/createFieldLabel.tsx +30 -0
- package/src/field/createFieldRoot.tsx +27 -0
- package/src/field/index.tsx +68 -0
- package/src/field/types.tsx +78 -0
- package/src/form/createFormRoot.tsx +13 -0
- package/src/form/index.tsx +12 -0
- package/src/form/types.tsx +16 -0
- package/src/index.ts +9 -0
- package/src/input/createInputField.tsx +13 -3
- package/src/input/index.tsx +15 -28
- package/src/input/types.ts +0 -4
- package/src/link/LinkProvider.tsx +50 -0
- package/src/link/createLink.tsx +71 -0
- package/src/link/index.tsx +5 -0
- package/src/link/types.ts +47 -0
- package/src/link/useLink.ts +54 -0
- package/src/list-item/context.tsx +5 -0
- package/src/list-item/createListItemContent.tsx +23 -0
- package/src/list-item/createListItemDescription.tsx +19 -0
- package/src/list-item/createListItemLeadingSlot.tsx +30 -0
- package/src/list-item/createListItemMeta.tsx +17 -0
- package/src/list-item/createListItemRoot.tsx +163 -0
- package/src/list-item/createListItemSectionHeader.tsx +53 -0
- package/src/list-item/createListItemTitle.tsx +17 -0
- package/src/list-item/createListItemTrailingSlot.tsx +21 -0
- package/src/list-item/index.ts +88 -0
- package/src/list-item/types.ts +122 -0
- package/src/otp-input/context.tsx +8 -0
- package/src/otp-input/createOtpInputCell.tsx +22 -0
- package/src/otp-input/createOtpInputField.tsx +98 -0
- package/src/otp-input/createOtpInputRoot.tsx +179 -0
- package/src/otp-input/index.tsx +34 -0
- package/src/otp-input/types.ts +92 -0
- package/src/otp-input/utils/applyValueChange.ts +56 -0
- package/src/otp-input/utils/filterValue.ts +37 -0
- package/src/overlay/OverlayContainer.tsx +9 -18
- package/src/overlay/index.ts +1 -0
- package/src/overlay/useEscapeKey.ts +7 -0
- package/src/overlay/useEscapeKey.web.ts +27 -0
- package/src/progress/context.tsx +13 -0
- package/src/progress/createProgressIndicator.tsx +35 -0
- package/src/progress/createProgressRoot.tsx +109 -0
- package/src/progress/index.ts +28 -0
- package/src/progress/types.ts +37 -0
- package/src/select/context.tsx +9 -44
- package/src/select/createSelectItem.tsx +3 -3
- package/src/select/createSelectRoot.tsx +10 -6
- package/src/select/createSelectTrigger.tsx +62 -36
- package/src/select/types.ts +4 -1
- package/src/utils/createPortal.ts +20 -0
- package/src/utils/dataAttributes.web.ts +2 -4
- package/lib/commonjs/input/createInputIcon.js +0 -20
- package/lib/commonjs/input/createInputIcon.js.map +0 -1
- package/lib/module/input/createInputIcon.js.map +0 -1
- package/lib/typescript/input/createInputIcon.d.ts +0 -4
- package/lib/typescript/input/createInputIcon.d.ts.map +0 -1
- package/src/input/createInputIcon.tsx +0 -12
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createListItemContent } from './createListItemContent';
|
|
4
|
+
import { createListItemDescription } from './createListItemDescription';
|
|
5
|
+
import { createListItemLeadingSlot } from './createListItemLeadingSlot';
|
|
6
|
+
import { createListItemMeta } from './createListItemMeta';
|
|
7
|
+
import { createListItemRoot } from './createListItemRoot';
|
|
8
|
+
import { createListItemSectionHeader } from './createListItemSectionHeader';
|
|
9
|
+
import { createListItemTitle } from './createListItemTitle';
|
|
10
|
+
import { createListItemTrailingSlot } from './createListItemTrailingSlot';
|
|
11
|
+
export { ListItemProvider, useListItemContext } from './context';
|
|
12
|
+
export function createListItem(BaseComponents) {
|
|
13
|
+
const ListItem = createListItemRoot(BaseComponents.View, BaseComponents.Pressable);
|
|
14
|
+
const LeadingSlot = createListItemLeadingSlot(BaseComponents.LeadingSlot);
|
|
15
|
+
const Content = createListItemContent(BaseComponents.Content);
|
|
16
|
+
const Title = createListItemTitle(BaseComponents.Title);
|
|
17
|
+
const Description = createListItemDescription(BaseComponents.Description);
|
|
18
|
+
const Meta = createListItemMeta(BaseComponents.Meta);
|
|
19
|
+
const TrailingSlot = createListItemTrailingSlot(BaseComponents.TrailingSlot);
|
|
20
|
+
const SectionHeader = createListItemSectionHeader(BaseComponents.SectionHeader);
|
|
21
|
+
ListItem.displayName = 'ListItemPrimitive';
|
|
22
|
+
LeadingSlot.displayName = 'ListItemPrimitive.LeadingSlot';
|
|
23
|
+
Content.displayName = 'ListItemPrimitive.Content';
|
|
24
|
+
Title.displayName = 'ListItemPrimitive.Title';
|
|
25
|
+
Description.displayName = 'ListItemPrimitive.Description';
|
|
26
|
+
Meta.displayName = 'ListItemPrimitive.Meta';
|
|
27
|
+
TrailingSlot.displayName = 'ListItemPrimitive.TrailingSlot';
|
|
28
|
+
SectionHeader.displayName = 'ListItemPrimitive.SectionHeader';
|
|
29
|
+
return Object.assign(ListItem, {
|
|
30
|
+
LeadingSlot,
|
|
31
|
+
Content,
|
|
32
|
+
Title,
|
|
33
|
+
Description,
|
|
34
|
+
Meta,
|
|
35
|
+
TrailingSlot,
|
|
36
|
+
SectionHeader
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createListItemContent","createListItemDescription","createListItemLeadingSlot","createListItemMeta","createListItemRoot","createListItemSectionHeader","createListItemTitle","createListItemTrailingSlot","ListItemProvider","useListItemContext","createListItem","BaseComponents","ListItem","View","Pressable","LeadingSlot","Content","Title","Description","Meta","TrailingSlot","SectionHeader","displayName","Object","assign"],"sourceRoot":"../../../src","sources":["list-item/index.ts"],"mappings":";;AACA,SAASA,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,yBAAyB,QAAQ,6BAA6B;AACvE,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,2BAA2B,QAAQ,+BAA+B;AAC3E,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,0BAA0B,QAAQ,8BAA8B;AAoBzE,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,WAAW;AAEhE,OAAO,SAASC,cAAcA,CAU5BC,cAUD,EAAE;EACD,MAAMC,QAAQ,GAAGR,kBAAkB,CAACO,cAAc,CAACE,IAAI,EAAEF,cAAc,CAACG,SAAS,CAAC;EAClF,MAAMC,WAAW,GAAGb,yBAAyB,CAACS,cAAc,CAACI,WAAW,CAAC;EACzE,MAAMC,OAAO,GAAGhB,qBAAqB,CAACW,cAAc,CAACK,OAAO,CAAC;EAC7D,MAAMC,KAAK,GAAGX,mBAAmB,CAACK,cAAc,CAACM,KAAK,CAAC;EACvD,MAAMC,WAAW,GAAGjB,yBAAyB,CAACU,cAAc,CAACO,WAAW,CAAC;EACzE,MAAMC,IAAI,GAAGhB,kBAAkB,CAACQ,cAAc,CAACQ,IAAI,CAAC;EACpD,MAAMC,YAAY,GAAGb,0BAA0B,CAACI,cAAc,CAACS,YAAY,CAAC;EAC5E,MAAMC,aAAa,GAAGhB,2BAA2B,CAACM,cAAc,CAACU,aAAa,CAAC;EAE/ET,QAAQ,CAACU,WAAW,GAAG,mBAAmB;EAC1CP,WAAW,CAACO,WAAW,GAAG,+BAA+B;EACzDN,OAAO,CAACM,WAAW,GAAG,2BAA2B;EACjDL,KAAK,CAACK,WAAW,GAAG,yBAAyB;EAC7CJ,WAAW,CAACI,WAAW,GAAG,+BAA+B;EACzDH,IAAI,CAACG,WAAW,GAAG,wBAAwB;EAC3CF,YAAY,CAACE,WAAW,GAAG,gCAAgC;EAC3DD,aAAa,CAACC,WAAW,GAAG,iCAAiC;EAE7D,OAAOC,MAAM,CAACC,MAAM,CAACZ,QAAQ,EAAE;IAC7BG,WAAW;IACXC,OAAO;IACPC,KAAK;IACLC,WAAW;IACXC,IAAI;IACJC,YAAY;IACZC;EACF,CAAC,CAAC;AAUJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["list-item/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext } from '@cdx-ui/utils';
|
|
4
|
+
export const [OtpInputProvider, useOtpInputContext] = createContext('OtpInputContext');
|
|
5
|
+
export const [OtpCellIndexProvider, useOtpCellIndexContext] = createContext('OtpCellIndexContext');
|
|
6
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","OtpInputProvider","useOtpInputContext","OtpCellIndexProvider","useOtpCellIndexContext"],"sourceRoot":"../../../src","sources":["otp-input/context.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,eAAe;AAG7C,OAAO,MAAM,CAACC,gBAAgB,EAAEC,kBAAkB,CAAC,GACjDF,aAAa,CAAuB,iBAAiB,CAAC;AAExD,OAAO,MAAM,CAACG,oBAAoB,EAAEC,sBAAsB,CAAC,GACzDJ,aAAa,CAAgC,qBAAqB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { useOtpInputContext } from './context';
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export const createOtpInputCell = BaseCell => /*#__PURE__*/forwardRef(({
|
|
7
|
+
children,
|
|
8
|
+
...props
|
|
9
|
+
}, ref) => {
|
|
10
|
+
const {
|
|
11
|
+
isDisabled,
|
|
12
|
+
isInvalid,
|
|
13
|
+
isReadOnly
|
|
14
|
+
} = useOtpInputContext();
|
|
15
|
+
return /*#__PURE__*/_jsx(BaseCell, {
|
|
16
|
+
ref: ref,
|
|
17
|
+
isDisabled: isDisabled,
|
|
18
|
+
isInvalid: isInvalid,
|
|
19
|
+
isReadOnly: isReadOnly,
|
|
20
|
+
...props,
|
|
21
|
+
children: children
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=createOtpInputCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useOtpInputContext","jsx","_jsx","createOtpInputCell","BaseCell","children","props","ref","isDisabled","isInvalid","isReadOnly"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputCell.tsx"],"mappings":";;AAEA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAG/C,OAAO,MAAMC,kBAAkB,GAAQC,QAAgC,iBACrEL,UAAU,CAAqD,CAAC;EAAEM,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC9F,MAAM;IAAEC,UAAU;IAAEC,SAAS;IAAEC;EAAW,CAAC,GAAGV,kBAAkB,CAAC,CAAC;EAElE,oBACEE,IAAA,CAACE,QAAQ;IACPG,GAAG,EAAEA,GAAI;IACTC,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,UAAU,EAAEA,UAAW;IAAA,GAClBJ,KAAK;IAAAD,QAAA,EAETA;EAAQ,CACD,CAAC;AAEf,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useMemo } from 'react';
|
|
4
|
+
import { Platform } from 'react-native';
|
|
5
|
+
import { mergeRefs } from '@cdx-ui/utils';
|
|
6
|
+
import { useOtpCellIndexContext, useOtpInputContext } from './context';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export const createOtpInputField = BaseField => /*#__PURE__*/forwardRef((props, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
cellIndex
|
|
11
|
+
} = useOtpCellIndexContext();
|
|
12
|
+
const {
|
|
13
|
+
value,
|
|
14
|
+
cellCount,
|
|
15
|
+
isDisabled,
|
|
16
|
+
isReadOnly,
|
|
17
|
+
smsOtpAutofill,
|
|
18
|
+
getCellProps,
|
|
19
|
+
cellTestIdPrefix,
|
|
20
|
+
rootAccessibilityLabel,
|
|
21
|
+
setFieldRef,
|
|
22
|
+
handleFieldChange,
|
|
23
|
+
handleFieldKeyPress
|
|
24
|
+
} = useOtpInputContext();
|
|
25
|
+
const char = cellIndex < value.length ? value[cellIndex] ?? '' : '';
|
|
26
|
+
const extra = getCellProps?.(cellIndex) ?? {};
|
|
27
|
+
const accessibilityLabel = useMemo(() => {
|
|
28
|
+
const fromExtra = extra.accessibilityLabel;
|
|
29
|
+
if (typeof fromExtra === 'string' && fromExtra !== '') {
|
|
30
|
+
return fromExtra;
|
|
31
|
+
}
|
|
32
|
+
if (rootAccessibilityLabel) {
|
|
33
|
+
return `${rootAccessibilityLabel}, ${String(cellIndex + 1)} of ${String(cellCount)}`;
|
|
34
|
+
}
|
|
35
|
+
return `OTP digit ${String(cellIndex + 1)} of ${String(cellCount)}`;
|
|
36
|
+
}, [cellCount, cellIndex, extra.accessibilityLabel, rootAccessibilityLabel]);
|
|
37
|
+
const autofillProps = useMemo(() => {
|
|
38
|
+
if (!smsOtpAutofill || cellIndex !== 0) {
|
|
39
|
+
return {};
|
|
40
|
+
}
|
|
41
|
+
return Platform.select({
|
|
42
|
+
web: {
|
|
43
|
+
autoComplete: 'one-time-code'
|
|
44
|
+
},
|
|
45
|
+
ios: {
|
|
46
|
+
textContentType: 'oneTimeCode'
|
|
47
|
+
},
|
|
48
|
+
android: {
|
|
49
|
+
autoComplete: 'sms-otp'
|
|
50
|
+
},
|
|
51
|
+
default: {}
|
|
52
|
+
});
|
|
53
|
+
}, [cellIndex, smsOtpAutofill]);
|
|
54
|
+
const editable = !(isDisabled || isReadOnly);
|
|
55
|
+
const {
|
|
56
|
+
style: extraStyle,
|
|
57
|
+
accessibilityLabel: _omitExtraA11y,
|
|
58
|
+
...extraRest
|
|
59
|
+
} = extra;
|
|
60
|
+
void _omitExtraA11y;
|
|
61
|
+
const {
|
|
62
|
+
style: incomingStyle,
|
|
63
|
+
value: _omitValue,
|
|
64
|
+
defaultValue: _omitDefault,
|
|
65
|
+
onChangeText: _omitOnChange,
|
|
66
|
+
...incomingRest
|
|
67
|
+
} = props;
|
|
68
|
+
void _omitValue;
|
|
69
|
+
void _omitDefault;
|
|
70
|
+
void _omitOnChange;
|
|
71
|
+
|
|
72
|
+
// Default digit OTP (`number-pad`). Root `getCellProps` is spread after and may override `keyboardType`.
|
|
73
|
+
return /*#__PURE__*/_jsx(BaseField, {
|
|
74
|
+
ref: mergeRefs(ref, el => {
|
|
75
|
+
setFieldRef(cellIndex, el);
|
|
76
|
+
}),
|
|
77
|
+
accessibilityLabel: accessibilityLabel,
|
|
78
|
+
"aria-label": accessibilityLabel,
|
|
79
|
+
accessible: true,
|
|
80
|
+
autoFocus: cellIndex === 0 && editable && value.length === 0,
|
|
81
|
+
editable: editable,
|
|
82
|
+
keyboardType: "number-pad",
|
|
83
|
+
returnKeyType: "done",
|
|
84
|
+
selectTextOnFocus: true,
|
|
85
|
+
testID: cellTestIdPrefix ? `${cellTestIdPrefix}:${String(cellIndex)}:textField:changeText` : undefined,
|
|
86
|
+
value: char,
|
|
87
|
+
onChangeText: text => {
|
|
88
|
+
handleFieldChange(cellIndex, text);
|
|
89
|
+
},
|
|
90
|
+
onKeyPress: e => {
|
|
91
|
+
handleFieldKeyPress(cellIndex, e.nativeEvent.key);
|
|
92
|
+
},
|
|
93
|
+
...autofillProps,
|
|
94
|
+
...extraRest,
|
|
95
|
+
...incomingRest,
|
|
96
|
+
style: [extraStyle, incomingStyle]
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=createOtpInputField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useMemo","Platform","mergeRefs","useOtpCellIndexContext","useOtpInputContext","jsx","_jsx","createOtpInputField","BaseField","props","ref","cellIndex","value","cellCount","isDisabled","isReadOnly","smsOtpAutofill","getCellProps","cellTestIdPrefix","rootAccessibilityLabel","setFieldRef","handleFieldChange","handleFieldKeyPress","char","length","extra","accessibilityLabel","fromExtra","String","autofillProps","select","web","autoComplete","ios","textContentType","android","default","editable","style","extraStyle","_omitExtraA11y","extraRest","incomingStyle","_omitValue","defaultValue","_omitDefault","onChangeText","_omitOnChange","incomingRest","el","accessible","autoFocus","keyboardType","returnKeyType","selectTextOnFocus","testID","undefined","text","onKeyPress","e","nativeEvent","key"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputField.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAC3C,SAASC,QAAQ,QAAqD,cAAc;AACpF,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ,WAAW;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAGvE,OAAO,MAAMC,mBAAmB,GAAQC,SAAiC,iBACvET,UAAU,CAAsE,CAACU,KAAK,EAAEC,GAAG,KAAK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EAAGC,CAAyB,IAAK;MACzCrC,mBAAmB,CAACX,SAAS,EAAEgD,CAAC,CAACC,WAAW,CAACC,GAAG,CAAC;IACnD,CAAE;IAAA,GACEhC,aAAa;IAAA,GACZY,SAAS;IAAA,GACTO,YAAY;IACjBV,KAAK,EAAE,CAACC,UAAU,EAAEG,aAAa;EAAE,CACpC,CAAC;AAEN,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
5
|
+
import { applyOtpInputChange } from './utils/applyValueChange';
|
|
6
|
+
import { OtpCellIndexProvider, OtpInputProvider } from './context';
|
|
7
|
+
import { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export const createOtpInputRoot = (BaseRoot, OtpCell, OtpField) => /*#__PURE__*/forwardRef(({
|
|
10
|
+
cellCount,
|
|
11
|
+
value,
|
|
12
|
+
onChangeText,
|
|
13
|
+
onComplete,
|
|
14
|
+
isDisabled: isDisabledProp,
|
|
15
|
+
isInvalid: isInvalidProp,
|
|
16
|
+
isReadOnly: isReadOnlyProp,
|
|
17
|
+
smsOtpAutofill = true,
|
|
18
|
+
filterInput,
|
|
19
|
+
allowedCharacters,
|
|
20
|
+
characterPattern,
|
|
21
|
+
getCellProps,
|
|
22
|
+
cellTestIdPrefix,
|
|
23
|
+
accessibilityLabel: rootAccessibilityLabel,
|
|
24
|
+
...rest
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const form = useFormControlContext();
|
|
27
|
+
const isDisabled = isDisabledProp ?? form.isDisabled ?? false;
|
|
28
|
+
const isInvalid = isInvalidProp ?? form.isInvalid ?? false;
|
|
29
|
+
const isReadOnly = isReadOnlyProp ?? form.isReadOnly ?? false;
|
|
30
|
+
const fieldRefs = useRef([]);
|
|
31
|
+
const focusAfterApply = useRef(null);
|
|
32
|
+
const prevLenRef = useRef(value.length);
|
|
33
|
+
const prevValueRef = useRef(value);
|
|
34
|
+
const filter = useMemo(() => {
|
|
35
|
+
if (filterInput) {
|
|
36
|
+
return filterInput;
|
|
37
|
+
}
|
|
38
|
+
if (allowedCharacters !== undefined) {
|
|
39
|
+
return filterAllowedCharacters(allowedCharacters);
|
|
40
|
+
}
|
|
41
|
+
if (characterPattern !== undefined) {
|
|
42
|
+
return filterByRegExp(characterPattern);
|
|
43
|
+
}
|
|
44
|
+
return filterDigits;
|
|
45
|
+
}, [filterInput, allowedCharacters, characterPattern]);
|
|
46
|
+
const setFieldRef = useCallback((index, el) => {
|
|
47
|
+
fieldRefs.current[index] = el;
|
|
48
|
+
}, []);
|
|
49
|
+
const focusCell = useCallback(index => {
|
|
50
|
+
const safe = Math.max(0, Math.min(index, cellCount - 1));
|
|
51
|
+
fieldRefs.current[safe]?.focus();
|
|
52
|
+
}, [cellCount]);
|
|
53
|
+
const handleFieldChange = useCallback((index, text) => {
|
|
54
|
+
const {
|
|
55
|
+
nextValue,
|
|
56
|
+
focusIndex
|
|
57
|
+
} = applyOtpInputChange(value, index, text, cellCount, filter);
|
|
58
|
+
if (nextValue !== value) {
|
|
59
|
+
onChangeText(nextValue);
|
|
60
|
+
}
|
|
61
|
+
focusAfterApply.current = focusIndex;
|
|
62
|
+
}, [cellCount, filter, onChangeText, value]);
|
|
63
|
+
const handleFieldKeyPress = useCallback((index, key) => {
|
|
64
|
+
if (key !== 'Backspace') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const char = index < value.length ? value[index] : '';
|
|
68
|
+
if (!char && index > 0) {
|
|
69
|
+
focusCell(index - 1);
|
|
70
|
+
}
|
|
71
|
+
}, [focusCell, value]);
|
|
72
|
+
useLayoutEffect(() => {
|
|
73
|
+
if (focusAfterApply.current !== null) {
|
|
74
|
+
const i = focusAfterApply.current;
|
|
75
|
+
focusAfterApply.current = null;
|
|
76
|
+
fieldRefs.current[i]?.focus();
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
const prevLen = prevLenRef.current;
|
|
81
|
+
const prevVal = prevValueRef.current;
|
|
82
|
+
const isFull = value.length === cellCount;
|
|
83
|
+
const becameFullByLength = isFull && prevLen < cellCount;
|
|
84
|
+
const correctedWhileFull = isFull && prevLen === cellCount && prevVal !== value;
|
|
85
|
+
if (becameFullByLength || correctedWhileFull) {
|
|
86
|
+
onComplete?.();
|
|
87
|
+
}
|
|
88
|
+
prevLenRef.current = value.length;
|
|
89
|
+
prevValueRef.current = value;
|
|
90
|
+
}, [cellCount, onComplete, value]);
|
|
91
|
+
const contextValue = useMemo(() => ({
|
|
92
|
+
cellCount,
|
|
93
|
+
value,
|
|
94
|
+
isDisabled,
|
|
95
|
+
isInvalid,
|
|
96
|
+
isReadOnly,
|
|
97
|
+
smsOtpAutofill,
|
|
98
|
+
filter,
|
|
99
|
+
getCellProps,
|
|
100
|
+
cellTestIdPrefix,
|
|
101
|
+
rootAccessibilityLabel,
|
|
102
|
+
setFieldRef,
|
|
103
|
+
handleFieldChange,
|
|
104
|
+
handleFieldKeyPress
|
|
105
|
+
}), [cellCount, value, isDisabled, isInvalid, isReadOnly, smsOtpAutofill, filter, getCellProps, cellTestIdPrefix, rootAccessibilityLabel, setFieldRef, handleFieldChange, handleFieldKeyPress]);
|
|
106
|
+
|
|
107
|
+
// Hermes drops outer-scope closure vars from its environment record when
|
|
108
|
+
// they are only referenced inside a nested callback (Array.from). Using a
|
|
109
|
+
// for-loop keeps OtpCell/OtpField references in the render function's own
|
|
110
|
+
// scope, avoiding the Hermes closure-capture bug.
|
|
111
|
+
const cells = [];
|
|
112
|
+
for (let i = 0; i < cellCount; i++) {
|
|
113
|
+
cells.push(/*#__PURE__*/_jsx(OtpCellIndexProvider, {
|
|
114
|
+
value: {
|
|
115
|
+
cellIndex: i
|
|
116
|
+
},
|
|
117
|
+
children: /*#__PURE__*/_jsx(OtpCell, {
|
|
118
|
+
children: /*#__PURE__*/_jsx(OtpField, {})
|
|
119
|
+
})
|
|
120
|
+
}, i));
|
|
121
|
+
}
|
|
122
|
+
return /*#__PURE__*/_jsx(BaseRoot, {
|
|
123
|
+
ref: ref,
|
|
124
|
+
...rest,
|
|
125
|
+
children: /*#__PURE__*/_jsx(OtpInputProvider, {
|
|
126
|
+
value: contextValue,
|
|
127
|
+
children: cells
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=createOtpInputRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useFormControlContext","applyOtpInputChange","OtpCellIndexProvider","OtpInputProvider","filterAllowedCharacters","filterByRegExp","filterDigits","jsx","_jsx","createOtpInputRoot","BaseRoot","OtpCell","OtpField","cellCount","value","onChangeText","onComplete","isDisabled","isDisabledProp","isInvalid","isInvalidProp","isReadOnly","isReadOnlyProp","smsOtpAutofill","filterInput","allowedCharacters","characterPattern","getCellProps","cellTestIdPrefix","accessibilityLabel","rootAccessibilityLabel","rest","ref","form","fieldRefs","focusAfterApply","prevLenRef","length","prevValueRef","filter","undefined","setFieldRef","index","el","current","focusCell","safe","Math","max","min","focus","handleFieldChange","text","nextValue","focusIndex","handleFieldKeyPress","key","char","i","prevLen","prevVal","isFull","becameFullByLength","correctedWhileFull","contextValue","cells","push","cellIndex","children"],"sourceRoot":"../../../src","sources":["otp-input/createOtpInputRoot.tsx"],"mappings":";;AACA,SAASA,UAAU,EAAEC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAE5F,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,WAA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ACTC,KAAK,EACLG,UAAU,EACVE,SAAS,EACTE,UAAU,EACVE,cAAc,EACdgB,MAAM,EACNZ,YAAY,EACZC,gBAAgB,EAChBE,sBAAsB,EACtBW,WAAW,EACXU,iBAAiB,EACjBI,mBAAmB,CAEvB,CAAC;;EAED;EACA;EACA;EACA;EACA,MAAMU,KAA2B,GAAG,EAAE;EACtC,KAAK,IAAIP,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAG7C,SAAS,EAAE6C,CAAC,EAAE,EAAE;IAClCO,KAAK,CAACC,IAAI,cACR1D,IAAA,CAACN,oBAAoB;MAASY,KAAK,EAAE;QAAEqD,SAAS,EAAET;MAAE,CAAE;MAAAU,QAAA,eACpD5D,IAAA,CAACG,OAAO;QAAAyD,QAAA,eACN5D,IAAA,CAACI,QAAQ,IAAE;MAAC,CACL;IAAC,GAHe8C,CAIL,CACxB,CAAC;EACH;EAEA,oBACElD,IAAA,CAACE,QAAQ;IAACsB,GAAG,EAAEA,GAA0B;IAAA,GAAMD,IAAI;IAAAqC,QAAA,eACjD5D,IAAA,CAACL,gBAAgB;MAACW,KAAK,EAAEkD,YAAa;MAAAI,QAAA,EAAEH;IAAK,CAAmB;EAAC,CACzD,CAAC;AAEf,CACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createOtpInputCell } from './createOtpInputCell';
|
|
4
|
+
import { createOtpInputField } from './createOtpInputField';
|
|
5
|
+
import { createOtpInputRoot } from './createOtpInputRoot';
|
|
6
|
+
export { applyOtpInputChange } from './utils/applyValueChange';
|
|
7
|
+
export { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
|
|
8
|
+
export function createOtpInput(BaseComponents) {
|
|
9
|
+
const Cell = createOtpInputCell(BaseComponents.Cell);
|
|
10
|
+
const Field = createOtpInputField(BaseComponents.Field);
|
|
11
|
+
const Root = createOtpInputRoot(BaseComponents.Root, Cell, Field);
|
|
12
|
+
Root.displayName = 'OtpInputPrimitive';
|
|
13
|
+
Cell.displayName = 'OtpInputPrimitive.Cell';
|
|
14
|
+
Field.displayName = 'OtpInputPrimitive.Field';
|
|
15
|
+
return Object.assign(Root, {
|
|
16
|
+
Cell,
|
|
17
|
+
Field
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createOtpInputCell","createOtpInputField","createOtpInputRoot","applyOtpInputChange","filterAllowedCharacters","filterByRegExp","filterDigits","createOtpInput","BaseComponents","Cell","Field","Root","displayName","Object","assign"],"sourceRoot":"../../../src","sources":["otp-input/index.tsx"],"mappings":";;AACA,SAASA,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,mBAAmB,QAAQ,uBAAuB;AAC3D,SAASC,kBAAkB,QAAQ,sBAAsB;AAGzD,SAASC,mBAAmB,QAAQ,0BAA0B;AAC9D,SAASC,uBAAuB,EAAEC,cAAc,EAAEC,YAAY,QAAQ,qBAAqB;AAG3F,OAAO,SAASC,cAAcA,CAM5BC,cAID,EAAE;EACD,MAAMC,IAAI,GAAGT,kBAAkB,CAACQ,cAAc,CAACC,IAAI,CAAC;EACpD,MAAMC,KAAK,GAAGT,mBAAmB,CAACO,cAAc,CAACE,KAAK,CAAC;EACvD,MAAMC,IAAI,GAAGT,kBAAkB,CAACM,cAAc,CAACG,IAAI,EAAEF,IAAI,EAAEC,KAAK,CAAC;EAEjEC,IAAI,CAACC,WAAW,GAAG,mBAAmB;EACtCH,IAAI,CAACG,WAAW,GAAG,wBAAwB;EAC3CF,KAAK,CAACE,WAAW,GAAG,yBAAyB;EAE7C,OAAOC,MAAM,CAACC,MAAM,CAACH,IAAI,EAAE;IACzBF,IAAI;IACJC;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["otp-input/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pure OTP value transition for a controlled prefix string (no explicit empty slots).
|
|
5
|
+
* - Single-character edits use index-based replace/append (no reorder).
|
|
6
|
+
* - Multi-character input (paste/autofill) writes at `index` forward, then packs left.
|
|
7
|
+
*/
|
|
8
|
+
export function applyOtpInputChange(value, index, rawText, cellCount, filter) {
|
|
9
|
+
const text = filter(rawText);
|
|
10
|
+
if (text.length === 0) {
|
|
11
|
+
if (index < value.length) {
|
|
12
|
+
const next = (value.slice(0, index) + value.slice(index + 1)).slice(0, cellCount);
|
|
13
|
+
return {
|
|
14
|
+
nextValue: next,
|
|
15
|
+
focusIndex: Math.max(0, index - 1)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
nextValue: value,
|
|
20
|
+
focusIndex: index
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (text.length === 1) {
|
|
24
|
+
if (index < value.length) {
|
|
25
|
+
const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
|
|
26
|
+
return {
|
|
27
|
+
nextValue: next,
|
|
28
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (value.length < cellCount) {
|
|
32
|
+
if (index === value.length) {
|
|
33
|
+
const next = (value + text).slice(0, cellCount);
|
|
34
|
+
return {
|
|
35
|
+
nextValue: next,
|
|
36
|
+
focusIndex: Math.min(next.length, cellCount - 1)
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const arr = Array.from({
|
|
40
|
+
length: cellCount
|
|
41
|
+
}, (_, i) => i < value.length ? value[i] : '');
|
|
42
|
+
arr[index] = text;
|
|
43
|
+
const next = arr.filter(c => c).join('').slice(0, cellCount);
|
|
44
|
+
return {
|
|
45
|
+
nextValue: next,
|
|
46
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
|
|
50
|
+
return {
|
|
51
|
+
nextValue: next,
|
|
52
|
+
focusIndex: Math.min(index + 1, cellCount - 1)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const arr = Array.from({
|
|
56
|
+
length: cellCount
|
|
57
|
+
}, (_, i) => i < value.length ? value[i] : '');
|
|
58
|
+
for (let k = 0; k < text.length && index + k < cellCount; k++) {
|
|
59
|
+
arr[index + k] = text.charAt(k);
|
|
60
|
+
}
|
|
61
|
+
const next = arr.filter(c => c).join('').slice(0, cellCount);
|
|
62
|
+
const lastWritten = Math.min(index + text.length - 1, cellCount - 1);
|
|
63
|
+
const focusIndex = Math.min(Math.max(lastWritten, next.length - 1), cellCount - 1);
|
|
64
|
+
return {
|
|
65
|
+
nextValue: next,
|
|
66
|
+
focusIndex: Math.max(0, focusIndex)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=applyValueChange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["applyOtpInputChange","value","index","rawText","cellCount","filter","text","length","next","slice","nextValue","focusIndex","Math","max","min","arr","Array","from","_","i","c","join","k","charAt","lastWritten"],"sourceRoot":"../../../../src","sources":["otp-input/utils/applyValueChange.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,mBAAmBA,CACjCC,KAAa,EACbC,KAAa,EACbC,OAAe,EACfC,SAAiB,EACjBC,MAAiC,EACU;EAC3C,MAAMC,IAAI,GAAGD,MAAM,CAACF,OAAO,CAAC;EAE5B,IAAIG,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACrB,IAAIL,KAAK,GAAGD,KAAK,CAACM,MAAM,EAAE;MACxB,MAAMC,IAAI,GAAG,CAACP,KAAK,CAACQ,KAAK,CAAC,CAAC,EAAEP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,GAAGO,GAAG,CACbV,MAAM,CAAEe,CAAC,IAAKA,CAAC,CAAC,CAChBC,IAAI,CAAC,EAAE,CAAC,CACRZ,KAAK,CAAC,CAAC,EAAEL,SAAS,CAAC;EACtB,MAAMoB,WAAW,GAAGZ,IAAI,CAACE,GAAG,CAACZ,KAAK,GAAGI,IAAI,CAACC,MAAM,GAAG,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EACpE,MAAMO,UAAU,GAAGC,IAAI,CAACE,GAAG,CAACF,IAAI,CAACC,GAAG,CAACW,WAAW,EAAEhB,IAAI,CAACD,MAAM,GAAG,CAAC,CAAC,EAAEH,SAAS,GAAG,CAAC,CAAC;EAClF,OAAO;IAAEM,SAAS,EAAEF,IAAI;IAAEG,UAAU,EAAEC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEF,UAAU;EAAE,CAAC;AACjE","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/** Strip to digits (default OTP behavior). */
|
|
4
|
+
export function filterDigits(input) {
|
|
5
|
+
return input.replace(/\D/g, '');
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Keep only characters present in `allowed` (treat as a set of UTF-16 code units). */
|
|
9
|
+
export function filterAllowedCharacters(allowed) {
|
|
10
|
+
const allowedSet = new Set();
|
|
11
|
+
for (let i = 0; i < allowed.length; i++) {
|
|
12
|
+
allowedSet.add(allowed.charAt(i));
|
|
13
|
+
}
|
|
14
|
+
return input => {
|
|
15
|
+
let out = '';
|
|
16
|
+
for (let i = 0; i < input.length; i++) {
|
|
17
|
+
const ch = input.charAt(i);
|
|
18
|
+
if (allowedSet.has(ch)) {
|
|
19
|
+
out += ch;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Keep only characters matching `re` (tested per UTF-16 code unit). */
|
|
27
|
+
export function filterByRegExp(re) {
|
|
28
|
+
return input => {
|
|
29
|
+
let out = '';
|
|
30
|
+
for (let i = 0; i < input.length; i++) {
|
|
31
|
+
const ch = input.charAt(i);
|
|
32
|
+
re.lastIndex = 0;
|
|
33
|
+
if (re.test(ch)) {
|
|
34
|
+
out += ch;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=filterValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["filterDigits","input","replace","filterAllowedCharacters","allowed","allowedSet","Set","i","length","add","charAt","out","ch","has","filterByRegExp","re","lastIndex","test"],"sourceRoot":"../../../../src","sources":["otp-input/utils/filterValue.ts"],"mappings":";;AAAA;AACA,OAAO,SAASA,YAAYA,CAACC,KAAa,EAAU;EAClD,OAAOA,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;AACjC;;AAEA;AACA,OAAO,SAASC,uBAAuBA,CAACC,OAAe,EAAE;EACvD,MAAMC,UAAU,GAAG,IAAIC,GAAG,CAAS,CAAC;EACpC,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,OAAO,CAACI,MAAM,EAAED,CAAC,EAAE,EAAE;IACvCF,UAAU,CAACI,GAAG,CAACL,OAAO,CAACM,MAAM,CAACH,CAAC,CAAC,CAAC;EACnC;EACA,OAAQN,KAAa,IAAK;IACxB,IAAIU,GAAG,GAAG,EAAE;IACZ,KAAK,IAAIJ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,EAAED,CAAC,EAAE,EAAE;MACrC,MAAMK,EAAE,GAAGX,KAAK,CAACS,MAAM,CAACH,CAAC,CAAC;MAC1B,IAAIF,UAAU,CAACQ,GAAG,CAACD,EAAE,CAAC,EAAE;QACtBD,GAAG,IAAIC,EAAE;MACX;IACF;IACA,OAAOD,GAAG;EACZ,CAAC;AACH;;AAEA;AACA,OAAO,SAASG,cAAcA,CAACC,EAAU,EAAE;EACzC,OAAQd,KAAa,IAAK;IACxB,IAAIU,GAAG,GAAG,EAAE;IACZ,KAAK,IAAIJ,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,KAAK,CAACO,MAAM,EAAED,CAAC,EAAE,EAAE;MACrC,MAAMK,EAAE,GAAGX,KAAK,CAACS,MAAM,CAACH,CAAC,CAAC;MAC1BQ,EAAE,CAACC,SAAS,GAAG,CAAC;MAChB,IAAID,EAAE,CAACE,IAAI,CAACL,EAAE,CAAC,EAAE;QACfD,GAAG,IAAIC,EAAE;MACX;IACF;IACA,OAAOD,GAAG;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { Modal, Platform, Pressable, StyleSheet } from 'react-native';
|
|
3
|
+
import { Modal, Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
4
4
|
import Animated from 'react-native-reanimated';
|
|
5
|
+
import { createPortalFn } from '../utils/createPortal';
|
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
let createPortalFn;
|
|
7
|
-
if (Platform.OS === 'web') {
|
|
8
|
-
try {
|
|
9
|
-
createPortalFn = require('react-dom').createPortal;
|
|
10
|
-
} catch {}
|
|
11
|
-
}
|
|
12
7
|
/**
|
|
13
8
|
* Cross-platform overlay container.
|
|
14
9
|
*
|
|
15
10
|
* - Web: renders children into a `createPortal` at `document.body` with
|
|
16
|
-
* `position: fixed` and `zIndex: 50`.
|
|
11
|
+
* `position: fixed` and `zIndex: 50`. Uses a plain `View` rather than
|
|
12
|
+
* Reanimated's `Animated.View` because Reanimated's layout animations
|
|
13
|
+
* (`entering`/`exiting`) rely on `require()` calls that break silently
|
|
14
|
+
* in Vite production bundles, leaving elements stuck at opacity 0.
|
|
15
|
+
* See: https://github.com/software-mansion/react-native-reanimated/issues/6775
|
|
17
16
|
* - Native: renders children inside a transparent `<Modal>` with a
|
|
18
17
|
* backdrop `<Pressable>` that calls `onDismiss` on press.
|
|
19
18
|
*
|
|
@@ -28,9 +27,7 @@ export function OverlayContainer({
|
|
|
28
27
|
children
|
|
29
28
|
}) {
|
|
30
29
|
if (Platform.OS === 'web' && createPortalFn) {
|
|
31
|
-
return createPortalFn(/*#__PURE__*/_jsx(
|
|
32
|
-
entering: entering,
|
|
33
|
-
exiting: exiting,
|
|
30
|
+
return createPortalFn(/*#__PURE__*/_jsx(View, {
|
|
34
31
|
style: [{
|
|
35
32
|
position: 'fixed',
|
|
36
33
|
zIndex: 50
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","Platform","Pressable","StyleSheet","
|
|
1
|
+
{"version":3,"names":["Modal","Platform","Pressable","StyleSheet","View","Animated","createPortalFn","jsx","_jsx","jsxs","_jsxs","OverlayContainer","onDismiss","entering","exiting","style","children","OS","position","zIndex","document","body","visible","transparent","animationType","statusBarTranslucent","onRequestClose","absoluteFill","onPress","accessible","importantForAccessibility"],"sourceRoot":"../../../src","sources":["overlay/OverlayContainer.tsx"],"mappings":";;AACA,SACEA,KAAK,EACLC,QAAQ,EACRC,SAAS,EACTC,UAAU,EACVC,IAAI,QAGC,cAAc;AACrB,OAAOC,QAAQ,MAAsC,yBAAyB;AAC9E,SAASC,cAAc,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAUvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,SAAS;EACTC,QAAQ;EACRC,OAAO;EACPC,KAAK;EACLC;AAC+B,CAAC,EAAE;EAClC,IAAIf,QAAQ,CAACgB,EAAE,KAAK,KAAK,IAAIX,cAAc,EAAE;IAC3C,OAAOA,cAAc,cACnBE,IAAA,CAACJ,IAAI;MAACW,KAAK,EAAE,CAAC;QAAEG,QAAQ,EAAE,OAAc;QAAEC,MAAM,EAAE;MAAG,CAAC,EAAEJ,KAAK,CAAE;MAAAC,QAAA,EAAEA;IAAQ,CAAO,CAAC,EACjFI,QAAQ,CAACC,IACX,CAAC;EACH;EAEA,oBACEX,KAAA,CAACV,KAAK;IAACsB,OAAO;IAACC,WAAW;IAACC,aAAa,EAAC,MAAM;IAACC,oBAAoB;IAACC,cAAc,EAAEd,SAAU;IAAAI,QAAA,gBAC7FR,IAAA,CAACN,SAAS;MACRa,KAAK,EAAEZ,UAAU,CAACwB,YAAa;MAC/BC,OAAO,EAAEhB,SAAU;MACnBiB,UAAU,EAAE,KAAM;MAClBC,yBAAyB,EAAC;IAAqB,CAChD,CAAC,eACFtB,IAAA,CAACH,QAAQ,CAACD,IAAI;MACZS,QAAQ,EAAEA,QAAS;MACnBC,OAAO,EAAEA,OAAQ;MACjBC,KAAK,EAAE,CAAC;QAAEG,QAAQ,EAAE;MAAW,CAAC,EAAEH,KAAK,CAAE;MAAAC,QAAA,EAExCA;IAAQ,CACI,CAAC;EAAA,CACX,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
export { OverlayContainer } from './OverlayContainer';
|
|
4
4
|
export { useAnchorPosition } from './useAnchorPosition';
|
|
5
5
|
export { useDismissOverlay } from './useDismissOverlay';
|
|
6
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
6
7
|
export { useOverlayPosition, OverlayInsetsProvider } from './useOverlayPosition';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OverlayContainer","useAnchorPosition","useDismissOverlay","useOverlayPosition","OverlayInsetsProvider"],"sourceRoot":"../../../src","sources":["overlay/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,iBAAiB,QAA2B,qBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SACEC,kBAAkB,EAElBC,qBAAqB,QAEhB,sBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["OverlayContainer","useAnchorPosition","useDismissOverlay","useEscapeKey","useOverlayPosition","OverlayInsetsProvider"],"sourceRoot":"../../../src","sources":["overlay/index.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,iBAAiB,QAA2B,qBAAqB;AAC1E,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SACEC,kBAAkB,EAElBC,qBAAqB,QAEhB,sBAAsB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* No-op on native — Escape key dismissal is not applicable.
|
|
7
|
+
* Native uses the system back gesture / hardware button via Modal.
|
|
8
|
+
*/
|
|
9
|
+
export function useEscapeKey(_open, _onEscape) {}
|
|
10
|
+
//# sourceMappingURL=useEscapeKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEscapeKey","_open","_onEscape"],"sourceRoot":"../../../src","sources":["overlay/useEscapeKey.ts"],"mappings":";;AAAA;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASA,YAAYA,CAACC,KAAc,EAAEC,SAAqB,EAAE,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Closes an overlay when the user presses the Escape key.
|
|
7
|
+
* Web-only — native platforms use Modal's `onRequestClose` for back/dismiss.
|
|
8
|
+
*/
|
|
9
|
+
export function useEscapeKey(open, onEscape) {
|
|
10
|
+
const onEscapeRef = useRef(onEscape);
|
|
11
|
+
onEscapeRef.current = onEscape;
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!open) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const handleKeyDown = e => {
|
|
17
|
+
if (e.key === 'Escape') {
|
|
18
|
+
onEscapeRef.current();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
22
|
+
return () => {
|
|
23
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
24
|
+
};
|
|
25
|
+
}, [open]);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=useEscapeKey.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useEscapeKey","open","onEscape","onEscapeRef","current","handleKeyDown","e","key","document","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["overlay/useEscapeKey.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;;AAEzC;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,IAAa,EAAEC,QAAoB,EAAE;EAChE,MAAMC,WAAW,GAAGJ,MAAM,CAACG,QAAQ,CAAC;EACpCC,WAAW,CAACC,OAAO,GAAGF,QAAQ;EAE9BJ,SAAS,CAAC,MAAM;IACd,IAAI,CAACG,IAAI,EAAE;MACT;IACF;IAEA,MAAMI,aAAa,GAAIC,CAAgB,IAAK;MAC1C,IAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,EAAE;QACtBJ,WAAW,CAACC,OAAO,CAAC,CAAC;MACvB;IACF,CAAC;IAEDI,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAEJ,aAAa,CAAC;IACnD,OAAO,MAAM;MACXG,QAAQ,CAACE,mBAAmB,CAAC,SAAS,EAAEL,aAAa,CAAC;IACxD,CAAC;EACH,CAAC,EAAE,CAACJ,IAAI,CAAC,CAAC;AACZ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","ProgressProvider","useProgressContext"],"sourceRoot":"../../../src","sources":["progress/context.tsx"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,eAAe;AAW7C,OAAO,MAAM,CAACC,gBAAgB,EAAEC,kBAAkB,CAAC,GACjDF,aAAa,CAAuB,iBAAiB,CAAC","ignoreList":[]}
|