@cdx-ui/primitives 0.0.1-alpha.4 → 0.0.1-alpha.40
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/createButtonRoot.js +3 -3
- package/lib/commonjs/button/createButtonRoot.js.map +1 -1
- package/lib/commonjs/button/index.js +25 -19
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/checkbox/context.js +14 -0
- package/lib/commonjs/checkbox/context.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxGroup.js +44 -0
- package/lib/commonjs/checkbox/createCheckboxGroup.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxIcon.js +29 -0
- package/lib/commonjs/checkbox/createCheckboxIcon.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxIndicator.js +47 -0
- package/lib/commonjs/checkbox/createCheckboxIndicator.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxLabel.js +46 -0
- package/lib/commonjs/checkbox/createCheckboxLabel.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.js +99 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.js.map +1 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +90 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +1 -0
- package/lib/commonjs/checkbox/index.js +30 -0
- package/lib/commonjs/checkbox/index.js.map +1 -0
- package/lib/commonjs/checkbox/types.js +6 -0
- package/lib/commonjs/checkbox/types.js.map +1 -0
- package/lib/commonjs/checkbox/useCheckboxRoot.js +82 -0
- package/lib/commonjs/checkbox/useCheckboxRoot.js.map +1 -0
- 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 +118 -2
- 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/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/switch/createSwitchRoot.js +73 -0
- package/lib/commonjs/switch/createSwitchRoot.js.map +1 -0
- package/lib/commonjs/switch/index.js +15 -0
- package/lib/commonjs/switch/index.js.map +1 -0
- package/lib/commonjs/switch/types.js +6 -0
- package/lib/commonjs/switch/types.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- 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/createButtonRoot.js +3 -3
- package/lib/module/button/createButtonRoot.js.map +1 -1
- package/lib/module/button/index.js +19 -19
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/checkbox/context.js +7 -0
- package/lib/module/checkbox/context.js.map +1 -0
- package/lib/module/checkbox/createCheckboxGroup.js +39 -0
- package/lib/module/checkbox/createCheckboxGroup.js.map +1 -0
- package/lib/module/checkbox/createCheckboxIcon.js +24 -0
- package/lib/module/checkbox/createCheckboxIcon.js.map +1 -0
- package/lib/module/checkbox/createCheckboxIndicator.js +42 -0
- package/lib/module/checkbox/createCheckboxIndicator.js.map +1 -0
- package/lib/module/checkbox/createCheckboxLabel.js +41 -0
- package/lib/module/checkbox/createCheckboxLabel.js.map +1 -0
- package/lib/module/checkbox/createCheckboxRoot.js +94 -0
- package/lib/module/checkbox/createCheckboxRoot.js.map +1 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js +85 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +1 -0
- package/lib/module/checkbox/index.js +26 -0
- package/lib/module/checkbox/index.js.map +1 -0
- package/lib/module/checkbox/types.js +4 -0
- package/lib/module/checkbox/types.js.map +1 -0
- package/lib/module/checkbox/useCheckboxRoot.js +78 -0
- package/lib/module/checkbox/useCheckboxRoot.js.map +1 -0
- 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 +11 -1
- 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/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/switch/createSwitchRoot.js +67 -0
- package/lib/module/switch/createSwitchRoot.js.map +1 -0
- package/lib/module/switch/index.js +11 -0
- package/lib/module/switch/index.js.map +1 -0
- package/lib/module/switch/types.js +4 -0
- package/lib/module/switch/types.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- 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/context.d.ts +1 -1
- package/lib/typescript/button/context.d.ts.map +1 -1
- package/lib/typescript/button/createButtonRoot.d.ts +1 -1
- package/lib/typescript/button/createButtonRoot.d.ts.map +1 -1
- package/lib/typescript/button/index.d.ts +2 -1
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/button/types.d.ts +0 -7
- package/lib/typescript/button/types.d.ts.map +1 -1
- package/lib/typescript/checkbox/context.d.ts +18 -0
- package/lib/typescript/checkbox/context.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts +3 -0
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts +3 -0
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts +5 -0
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts +5 -0
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts +2 -0
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts.map +1 -0
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts +2 -0
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +1 -0
- package/lib/typescript/checkbox/index.d.ts +11 -0
- package/lib/typescript/checkbox/index.d.ts.map +1 -0
- package/lib/typescript/checkbox/types.d.ts +57 -0
- package/lib/typescript/checkbox/types.d.ts.map +1 -0
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +152 -0
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -0
- 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 +12 -1
- 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/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 +5 -7
- package/lib/typescript/select/types.d.ts.map +1 -1
- package/lib/typescript/switch/createSwitchRoot.d.ts +3 -0
- package/lib/typescript/switch/createSwitchRoot.d.ts.map +1 -0
- package/lib/typescript/switch/index.d.ts +7 -0
- package/lib/typescript/switch/index.d.ts.map +1 -0
- package/lib/typescript/switch/types.d.ts +38 -0
- package/lib/typescript/switch/types.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +8 -0
- package/lib/typescript/types.d.ts.map +1 -0
- 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 +12 -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/context.tsx +1 -1
- package/src/button/createButtonRoot.tsx +5 -4
- package/src/button/index.tsx +19 -19
- package/src/button/types.ts +0 -8
- package/src/checkbox/context.tsx +18 -0
- package/src/checkbox/createCheckboxGroup.tsx +32 -0
- package/src/checkbox/createCheckboxIcon.tsx +18 -0
- package/src/checkbox/createCheckboxIndicator.tsx +43 -0
- package/src/checkbox/createCheckboxLabel.tsx +42 -0
- package/src/checkbox/createCheckboxRoot.tsx +100 -0
- package/src/checkbox/createCheckboxRoot.web.tsx +79 -0
- package/src/checkbox/index.ts +43 -0
- package/src/checkbox/types.ts +74 -0
- package/src/checkbox/useCheckboxRoot.ts +85 -0
- 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 +12 -1
- 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/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 +5 -10
- package/src/switch/createSwitchRoot.tsx +72 -0
- package/src/switch/index.ts +16 -0
- package/src/switch/types.ts +42 -0
- package/src/types.ts +7 -0
- 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,34 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createOtpInputCell } from './createOtpInputCell';
|
|
3
|
+
import { createOtpInputField } from './createOtpInputField';
|
|
4
|
+
import { createOtpInputRoot } from './createOtpInputRoot';
|
|
5
|
+
import type { IOtpInputComponentType } from './types';
|
|
6
|
+
|
|
7
|
+
export { applyOtpInputChange } from './utils/applyValueChange';
|
|
8
|
+
export { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
|
|
9
|
+
export type * from './types';
|
|
10
|
+
|
|
11
|
+
export function createOtpInput<
|
|
12
|
+
RootProps,
|
|
13
|
+
CellProps,
|
|
14
|
+
FieldProps,
|
|
15
|
+
RootRef = unknown,
|
|
16
|
+
FieldRef = unknown,
|
|
17
|
+
>(BaseComponents: {
|
|
18
|
+
Root: React.ComponentType<RootProps>;
|
|
19
|
+
Cell: React.ComponentType<CellProps>;
|
|
20
|
+
Field: React.ComponentType<FieldProps>;
|
|
21
|
+
}) {
|
|
22
|
+
const Cell = createOtpInputCell(BaseComponents.Cell);
|
|
23
|
+
const Field = createOtpInputField(BaseComponents.Field);
|
|
24
|
+
const Root = createOtpInputRoot(BaseComponents.Root, Cell, Field);
|
|
25
|
+
|
|
26
|
+
Root.displayName = 'OtpInputPrimitive';
|
|
27
|
+
Cell.displayName = 'OtpInputPrimitive.Cell';
|
|
28
|
+
Field.displayName = 'OtpInputPrimitive.Field';
|
|
29
|
+
|
|
30
|
+
return Object.assign(Root, {
|
|
31
|
+
Cell,
|
|
32
|
+
Field,
|
|
33
|
+
}) as IOtpInputComponentType<RootProps, CellProps, FieldProps, RootRef, FieldRef>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { TextInputProps, ViewProps } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export interface IOtpInputRootProps extends ViewProps {
|
|
6
|
+
/** Number of OTP cells (fixed). */
|
|
7
|
+
cellCount: number;
|
|
8
|
+
/** Controlled value: characters in order, length 0..`cellCount` (prefix fill). */
|
|
9
|
+
value: string;
|
|
10
|
+
onChangeText: (value: string) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Called when the code is ready to verify again:
|
|
13
|
+
* - `value` becomes full (`length === cellCount`) after being shorter, or
|
|
14
|
+
* - `value` stays full but the string changes (user corrected a digit without dropping below full length).
|
|
15
|
+
* Does not fire on mount when `value` is already full and unchanged, nor on re-renders with the same full `value`.
|
|
16
|
+
*/
|
|
17
|
+
onComplete?: () => void;
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
isInvalid?: boolean;
|
|
20
|
+
isReadOnly?: boolean;
|
|
21
|
+
/** When false, no SMS / Web OTP autofill hints on the first cell. @default true */
|
|
22
|
+
smsOtpAutofill?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Override default digit-only filtering.
|
|
25
|
+
* Takes priority over `allowedCharacters` and `characterPattern` when truthy.
|
|
26
|
+
* Does not change the default `keyboardType` (`number-pad`); use `getCellProps` if the allowed
|
|
27
|
+
* character set needs a different keyboard.
|
|
28
|
+
*/
|
|
29
|
+
filterInput?: (input: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Keep only characters present in this string (treated as a set of code units).
|
|
32
|
+
* Used when `filterInput` is not provided. Takes priority over `characterPattern`.
|
|
33
|
+
* Default keyboard remains numeric; use `getCellProps` to set `keyboardType` when allowing letters/symbols.
|
|
34
|
+
*/
|
|
35
|
+
allowedCharacters?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Keep only characters matching this pattern (tested per code unit).
|
|
38
|
+
* Used when neither `filterInput` nor `allowedCharacters` is provided.
|
|
39
|
+
* Default keyboard remains numeric; use `getCellProps` to set `keyboardType` for non-digit input.
|
|
40
|
+
*/
|
|
41
|
+
characterPattern?: RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* Spread onto each cell after built-in field props (including `keyboardType="number-pad"`),
|
|
44
|
+
* so consumers can override `keyboardType`, `autoCapitalize`, etc. for non-digit OTPs.
|
|
45
|
+
*/
|
|
46
|
+
getCellProps?: (index: number) => Partial<TextInputProps>;
|
|
47
|
+
/** Optional prefix for `testID` on each field: `${cellTestIdPrefix}:${index}:...` */
|
|
48
|
+
cellTestIdPrefix?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface IOtpInputCellProps extends ViewProps {
|
|
52
|
+
children?: ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type IOtpInputFieldProps = TextInputProps;
|
|
56
|
+
|
|
57
|
+
export interface OtpInputCellIndexContextValue {
|
|
58
|
+
cellIndex: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface OtpInputContextValue {
|
|
62
|
+
cellCount: number;
|
|
63
|
+
value: string;
|
|
64
|
+
isDisabled: boolean;
|
|
65
|
+
isInvalid: boolean;
|
|
66
|
+
isReadOnly: boolean;
|
|
67
|
+
smsOtpAutofill: boolean;
|
|
68
|
+
filter: (input: string) => string;
|
|
69
|
+
getCellProps?: (index: number) => Partial<TextInputProps>;
|
|
70
|
+
cellTestIdPrefix?: string;
|
|
71
|
+
rootAccessibilityLabel?: string;
|
|
72
|
+
setFieldRef: (index: number, el: import('react-native').TextInput | null) => void;
|
|
73
|
+
handleFieldChange: (index: number, text: string) => void;
|
|
74
|
+
handleFieldKeyPress: (index: number, key: string) => void;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export type IOtpInputComponentType<
|
|
78
|
+
RootProps,
|
|
79
|
+
CellProps,
|
|
80
|
+
FieldProps,
|
|
81
|
+
RootRef = unknown,
|
|
82
|
+
FieldRef = unknown,
|
|
83
|
+
> = React.ForwardRefExoticComponent<
|
|
84
|
+
React.PropsWithoutRef<RootProps & IOtpInputRootProps> & React.RefAttributes<RootRef>
|
|
85
|
+
> & {
|
|
86
|
+
Cell: React.ForwardRefExoticComponent<
|
|
87
|
+
React.PropsWithoutRef<CellProps & IOtpInputCellProps> & React.RefAttributes<unknown>
|
|
88
|
+
>;
|
|
89
|
+
Field: React.ForwardRefExoticComponent<
|
|
90
|
+
React.PropsWithoutRef<FieldProps & IOtpInputFieldProps> & React.RefAttributes<FieldRef>
|
|
91
|
+
>;
|
|
92
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure OTP value transition for a controlled prefix string (no explicit empty slots).
|
|
3
|
+
* - Single-character edits use index-based replace/append (no reorder).
|
|
4
|
+
* - Multi-character input (paste/autofill) writes at `index` forward, then packs left.
|
|
5
|
+
*/
|
|
6
|
+
export function applyOtpInputChange(
|
|
7
|
+
value: string,
|
|
8
|
+
index: number,
|
|
9
|
+
rawText: string,
|
|
10
|
+
cellCount: number,
|
|
11
|
+
filter: (input: string) => string,
|
|
12
|
+
): { nextValue: string; focusIndex: number } {
|
|
13
|
+
const text = filter(rawText);
|
|
14
|
+
|
|
15
|
+
if (text.length === 0) {
|
|
16
|
+
if (index < value.length) {
|
|
17
|
+
const next = (value.slice(0, index) + value.slice(index + 1)).slice(0, cellCount);
|
|
18
|
+
return { nextValue: next, focusIndex: Math.max(0, index - 1) };
|
|
19
|
+
}
|
|
20
|
+
return { nextValue: value, 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 { nextValue: next, focusIndex: Math.min(index + 1, cellCount - 1) };
|
|
27
|
+
}
|
|
28
|
+
if (value.length < cellCount) {
|
|
29
|
+
if (index === value.length) {
|
|
30
|
+
const next = (value + text).slice(0, cellCount);
|
|
31
|
+
return { nextValue: next, focusIndex: Math.min(next.length, cellCount - 1) };
|
|
32
|
+
}
|
|
33
|
+
const arr = Array.from({ length: cellCount }, (_, i) => (i < value.length ? value[i] : ''));
|
|
34
|
+
arr[index] = text;
|
|
35
|
+
const next = arr
|
|
36
|
+
.filter((c) => c)
|
|
37
|
+
.join('')
|
|
38
|
+
.slice(0, cellCount);
|
|
39
|
+
return { nextValue: next, focusIndex: Math.min(index + 1, cellCount - 1) };
|
|
40
|
+
}
|
|
41
|
+
const next = (value.slice(0, index) + text + value.slice(index + 1)).slice(0, cellCount);
|
|
42
|
+
return { nextValue: next, focusIndex: Math.min(index + 1, cellCount - 1) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const arr = Array.from({ length: cellCount }, (_, i) => (i < value.length ? value[i] : ''));
|
|
46
|
+
for (let k = 0; k < text.length && index + k < cellCount; k++) {
|
|
47
|
+
arr[index + k] = text.charAt(k);
|
|
48
|
+
}
|
|
49
|
+
const next = arr
|
|
50
|
+
.filter((c) => c)
|
|
51
|
+
.join('')
|
|
52
|
+
.slice(0, cellCount);
|
|
53
|
+
const lastWritten = Math.min(index + text.length - 1, cellCount - 1);
|
|
54
|
+
const focusIndex = Math.min(Math.max(lastWritten, next.length - 1), cellCount - 1);
|
|
55
|
+
return { nextValue: next, focusIndex: Math.max(0, focusIndex) };
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Strip to digits (default OTP behavior). */
|
|
2
|
+
export function filterDigits(input: string): string {
|
|
3
|
+
return input.replace(/\D/g, '');
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Keep only characters present in `allowed` (treat as a set of UTF-16 code units). */
|
|
7
|
+
export function filterAllowedCharacters(allowed: string) {
|
|
8
|
+
const allowedSet = new Set<string>();
|
|
9
|
+
for (let i = 0; i < allowed.length; i++) {
|
|
10
|
+
allowedSet.add(allowed.charAt(i));
|
|
11
|
+
}
|
|
12
|
+
return (input: string) => {
|
|
13
|
+
let out = '';
|
|
14
|
+
for (let i = 0; i < input.length; i++) {
|
|
15
|
+
const ch = input.charAt(i);
|
|
16
|
+
if (allowedSet.has(ch)) {
|
|
17
|
+
out += ch;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Keep only characters matching `re` (tested per UTF-16 code unit). */
|
|
25
|
+
export function filterByRegExp(re: RegExp) {
|
|
26
|
+
return (input: string) => {
|
|
27
|
+
let out = '';
|
|
28
|
+
for (let i = 0; i < input.length; i++) {
|
|
29
|
+
const ch = input.charAt(i);
|
|
30
|
+
re.lastIndex = 0;
|
|
31
|
+
if (re.test(ch)) {
|
|
32
|
+
out += ch;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return out;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -3,20 +3,13 @@ import {
|
|
|
3
3
|
Modal,
|
|
4
4
|
Platform,
|
|
5
5
|
Pressable,
|
|
6
|
-
type StyleProp,
|
|
7
6
|
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
type StyleProp,
|
|
8
9
|
type ViewStyle,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import Animated, { type EntryOrExitLayoutType } from 'react-native-reanimated';
|
|
11
|
-
|
|
12
|
-
let createPortalFn:
|
|
13
|
-
| ((children: React.ReactNode, container: Element) => React.ReactPortal)
|
|
14
|
-
| undefined;
|
|
15
|
-
if (Platform.OS === 'web') {
|
|
16
|
-
try {
|
|
17
|
-
createPortalFn = require('react-dom').createPortal;
|
|
18
|
-
} catch {}
|
|
19
|
-
}
|
|
12
|
+
import { createPortalFn } from '../utils/createPortal';
|
|
20
13
|
|
|
21
14
|
export interface OverlayContainerProps {
|
|
22
15
|
onDismiss: () => void;
|
|
@@ -30,7 +23,11 @@ export interface OverlayContainerProps {
|
|
|
30
23
|
* Cross-platform overlay container.
|
|
31
24
|
*
|
|
32
25
|
* - Web: renders children into a `createPortal` at `document.body` with
|
|
33
|
-
* `position: fixed` and `zIndex: 50`.
|
|
26
|
+
* `position: fixed` and `zIndex: 50`. Uses a plain `View` rather than
|
|
27
|
+
* Reanimated's `Animated.View` because Reanimated's layout animations
|
|
28
|
+
* (`entering`/`exiting`) rely on `require()` calls that break silently
|
|
29
|
+
* in Vite production bundles, leaving elements stuck at opacity 0.
|
|
30
|
+
* See: https://github.com/software-mansion/react-native-reanimated/issues/6775
|
|
34
31
|
* - Native: renders children inside a transparent `<Modal>` with a
|
|
35
32
|
* backdrop `<Pressable>` that calls `onDismiss` on press.
|
|
36
33
|
*
|
|
@@ -46,13 +43,7 @@ export function OverlayContainer({
|
|
|
46
43
|
}: Readonly<OverlayContainerProps>) {
|
|
47
44
|
if (Platform.OS === 'web' && createPortalFn) {
|
|
48
45
|
return createPortalFn(
|
|
49
|
-
<
|
|
50
|
-
entering={entering}
|
|
51
|
-
exiting={exiting}
|
|
52
|
-
style={[{ position: 'fixed' as any, zIndex: 50 }, style]}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</Animated.View>,
|
|
46
|
+
<View style={[{ position: 'fixed' as any, zIndex: 50 }, style]}>{children}</View>,
|
|
56
47
|
document.body,
|
|
57
48
|
);
|
|
58
49
|
}
|
package/src/overlay/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { OverlayContainer } from './OverlayContainer';
|
|
|
2
2
|
export type { OverlayContainerProps } from './OverlayContainer';
|
|
3
3
|
export { useAnchorPosition, type AnchorLayout } from './useAnchorPosition';
|
|
4
4
|
export { useDismissOverlay } from './useDismissOverlay';
|
|
5
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
5
6
|
export {
|
|
6
7
|
useOverlayPosition,
|
|
7
8
|
type OverlayPosition,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* No-op on native — Escape key dismissal is not applicable.
|
|
5
|
+
* Native uses the system back gesture / hardware button via Modal.
|
|
6
|
+
*/
|
|
7
|
+
export function useEscapeKey(_open: boolean, _onEscape: () => void) {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Closes an overlay when the user presses the Escape key.
|
|
5
|
+
* Web-only — native platforms use Modal's `onRequestClose` for back/dismiss.
|
|
6
|
+
*/
|
|
7
|
+
export function useEscapeKey(open: boolean, onEscape: () => void) {
|
|
8
|
+
const onEscapeRef = useRef(onEscape);
|
|
9
|
+
onEscapeRef.current = onEscape;
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!open) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
17
|
+
if (e.key === 'Escape') {
|
|
18
|
+
onEscapeRef.current();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
23
|
+
return () => {
|
|
24
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
25
|
+
};
|
|
26
|
+
}, [open]);
|
|
27
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext } from '@cdx-ui/utils';
|
|
2
|
+
import type { ProgressDataState } from './types';
|
|
3
|
+
|
|
4
|
+
export interface ProgressContextValue {
|
|
5
|
+
/** Clamped value in [0, max], or null when indeterminate */
|
|
6
|
+
readonly value: number | null;
|
|
7
|
+
readonly max: number;
|
|
8
|
+
readonly percent: number;
|
|
9
|
+
readonly state: ProgressDataState;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const [ProgressProvider, useProgressContext] =
|
|
13
|
+
createContext<ProgressContextValue>('ProgressContext');
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useMemo, type PropsWithoutRef } from 'react';
|
|
3
|
+
import type { ViewStyle } from 'react-native';
|
|
4
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
+
import { useProgressContext } from './context';
|
|
6
|
+
|
|
7
|
+
type PercentString = `${number}%`;
|
|
8
|
+
|
|
9
|
+
export const createProgressIndicator = <T, R = unknown>(BaseIndicator: React.ComponentType<T>) =>
|
|
10
|
+
forwardRef<R, PropsWithoutRef<T>>((props, ref) => {
|
|
11
|
+
const { style, ...rest } = props as PropsWithoutRef<T> & { style?: object };
|
|
12
|
+
const { percent, state, max, value } = useProgressContext();
|
|
13
|
+
|
|
14
|
+
const filledStyle = useMemo((): ViewStyle => {
|
|
15
|
+
const pct = `${String(percent)}%` as PercentString;
|
|
16
|
+
return { width: pct, height: '100%' };
|
|
17
|
+
}, [percent]);
|
|
18
|
+
|
|
19
|
+
const dataAttrs = dataAttributes({
|
|
20
|
+
state,
|
|
21
|
+
value: value === null ? undefined : String(value),
|
|
22
|
+
max: String(max),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BaseIndicator
|
|
27
|
+
ref={ref as React.Ref<R>}
|
|
28
|
+
{...({
|
|
29
|
+
...rest,
|
|
30
|
+
...dataAttrs,
|
|
31
|
+
style: [filledStyle, style],
|
|
32
|
+
} as T)}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useMemo, type PropsWithoutRef } from 'react';
|
|
3
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
4
|
+
import { ProgressProvider } from './context';
|
|
5
|
+
import type { InterfaceProgressProps, ProgressDataState } from './types';
|
|
6
|
+
|
|
7
|
+
function clamp(n: number, min: number, max: number): number {
|
|
8
|
+
return Math.min(max, Math.max(min, n));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function resolveState(
|
|
12
|
+
value: number | null,
|
|
13
|
+
max: number,
|
|
14
|
+
clamped: number | null,
|
|
15
|
+
): ProgressDataState {
|
|
16
|
+
if (value === null) {
|
|
17
|
+
return 'indeterminate';
|
|
18
|
+
}
|
|
19
|
+
if (max <= 0) {
|
|
20
|
+
return 'complete';
|
|
21
|
+
}
|
|
22
|
+
if (clamped !== null && clamped >= max) {
|
|
23
|
+
return 'complete';
|
|
24
|
+
}
|
|
25
|
+
return 'loading';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function defaultGetValueLabel(value: number, max: number): string {
|
|
29
|
+
if (max <= 0) {
|
|
30
|
+
return '0%';
|
|
31
|
+
}
|
|
32
|
+
return `${String(Math.round((value / max) * 100))}%`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const createProgressRoot = <T, R = unknown>(BaseRoot: React.ComponentType<T>) =>
|
|
36
|
+
forwardRef<R, PropsWithoutRef<T> & InterfaceProgressProps>((props, ref) => {
|
|
37
|
+
const {
|
|
38
|
+
value: valueProp = 0,
|
|
39
|
+
max: maxProp = 100,
|
|
40
|
+
getValueLabel = defaultGetValueLabel,
|
|
41
|
+
children,
|
|
42
|
+
accessibilityRole = 'progressbar',
|
|
43
|
+
accessibilityValue: accessibilityValueProp,
|
|
44
|
+
role = 'progressbar',
|
|
45
|
+
...restProps
|
|
46
|
+
} = props;
|
|
47
|
+
const max = maxProp > 0 ? maxProp : 0;
|
|
48
|
+
const isIndeterminate = valueProp === null;
|
|
49
|
+
const clampedValue =
|
|
50
|
+
valueProp === null ? null : clamp(Number.isFinite(valueProp) ? valueProp : 0, 0, max);
|
|
51
|
+
|
|
52
|
+
const percent = useMemo(() => {
|
|
53
|
+
if (clampedValue === null || max <= 0) {
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
return (clampedValue / max) * 100;
|
|
57
|
+
}, [clampedValue, max]);
|
|
58
|
+
|
|
59
|
+
const state = useMemo(
|
|
60
|
+
() => resolveState(valueProp, max, clampedValue),
|
|
61
|
+
[valueProp, max, clampedValue],
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const contextValue = useMemo(
|
|
65
|
+
() => ({
|
|
66
|
+
value: clampedValue,
|
|
67
|
+
max,
|
|
68
|
+
percent,
|
|
69
|
+
state,
|
|
70
|
+
}),
|
|
71
|
+
[clampedValue, max, percent, state],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const dataAttrs = dataAttributes({
|
|
75
|
+
state,
|
|
76
|
+
value: clampedValue === null ? undefined : String(clampedValue),
|
|
77
|
+
max: String(max),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const accessibilityValue = useMemo(() => {
|
|
81
|
+
if (accessibilityValueProp !== undefined) {
|
|
82
|
+
return accessibilityValueProp;
|
|
83
|
+
}
|
|
84
|
+
if (isIndeterminate || clampedValue === null) {
|
|
85
|
+
return { min: 0, max, text: 'Indeterminate' };
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
min: 0,
|
|
89
|
+
max,
|
|
90
|
+
now: clampedValue,
|
|
91
|
+
text: getValueLabel(clampedValue, max),
|
|
92
|
+
};
|
|
93
|
+
}, [accessibilityValueProp, isIndeterminate, clampedValue, max, getValueLabel]);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<ProgressProvider value={contextValue}>
|
|
97
|
+
<BaseRoot
|
|
98
|
+
ref={ref as React.Ref<R>}
|
|
99
|
+
{...(restProps as T)}
|
|
100
|
+
role={role}
|
|
101
|
+
accessibilityRole={accessibilityRole}
|
|
102
|
+
accessibilityValue={accessibilityValue}
|
|
103
|
+
{...dataAttrs}
|
|
104
|
+
>
|
|
105
|
+
{children}
|
|
106
|
+
</BaseRoot>
|
|
107
|
+
</ProgressProvider>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createProgressIndicator } from './createProgressIndicator';
|
|
3
|
+
import { createProgressRoot } from './createProgressRoot';
|
|
4
|
+
import type { IProgressComponentType } from './types';
|
|
5
|
+
|
|
6
|
+
export type { IProgressProps, IProgressComponentType, ProgressDataState } from './types';
|
|
7
|
+
export type { ProgressContextValue } from './context';
|
|
8
|
+
export { useProgressContext } from './context';
|
|
9
|
+
|
|
10
|
+
export function createProgress<
|
|
11
|
+
RootProps,
|
|
12
|
+
IndicatorProps,
|
|
13
|
+
RootRef = unknown,
|
|
14
|
+
IndicatorRef = unknown,
|
|
15
|
+
>(components: {
|
|
16
|
+
Root: React.ComponentType<RootProps>;
|
|
17
|
+
Indicator: React.ComponentType<IndicatorProps>;
|
|
18
|
+
}) {
|
|
19
|
+
const Progress = createProgressRoot<RootProps, RootRef>(components.Root);
|
|
20
|
+
const Indicator = createProgressIndicator<IndicatorProps, IndicatorRef>(components.Indicator);
|
|
21
|
+
|
|
22
|
+
Progress.displayName = 'ProgressPrimitive';
|
|
23
|
+
Indicator.displayName = 'ProgressPrimitive.Indicator';
|
|
24
|
+
|
|
25
|
+
return Object.assign(Progress, {
|
|
26
|
+
Indicator,
|
|
27
|
+
}) as IProgressComponentType<RootProps, IndicatorProps, RootRef, IndicatorRef>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type ProgressDataState = 'complete' | 'indeterminate' | 'loading';
|
|
5
|
+
|
|
6
|
+
export interface InterfaceProgressProps extends Omit<ViewProps, 'children'> {
|
|
7
|
+
/**
|
|
8
|
+
* Current value in the range [0, max], or `null` for indeterminate progress.
|
|
9
|
+
* Omit or use a number for determinate progress; default is `0`.
|
|
10
|
+
*/
|
|
11
|
+
readonly value?: number | null;
|
|
12
|
+
/**
|
|
13
|
+
* Maximum value (minimum is always 0).
|
|
14
|
+
* @default 100
|
|
15
|
+
*/
|
|
16
|
+
readonly max?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Optional label for `accessibilityValue.text` when determinate.
|
|
19
|
+
*/
|
|
20
|
+
readonly getValueLabel?: (value: number, max: number) => string;
|
|
21
|
+
readonly children?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type IProgressComponentType<
|
|
25
|
+
RootProps,
|
|
26
|
+
IndicatorProps,
|
|
27
|
+
RootRef = unknown,
|
|
28
|
+
IndicatorRef = unknown,
|
|
29
|
+
> = ForwardRefExoticComponent<
|
|
30
|
+
PropsWithoutRef<RootProps & InterfaceProgressProps> & RefAttributes<RootRef>
|
|
31
|
+
> & {
|
|
32
|
+
Indicator: ForwardRefExoticComponent<
|
|
33
|
+
PropsWithoutRef<IndicatorProps> & RefAttributes<IndicatorRef>
|
|
34
|
+
>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type IProgressProps = InterfaceProgressProps;
|
package/src/select/context.tsx
CHANGED
|
@@ -1,56 +1,21 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
import type { InteractionState
|
|
1
|
+
import { createContext } from '@cdx-ui/utils';
|
|
2
|
+
import type { InteractionState } from '../types';
|
|
3
|
+
import type { SelectContextValue, SelectItemInteractionState } from './types';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
items: [],
|
|
7
|
-
setOpen: () => {},
|
|
8
|
-
value: undefined,
|
|
9
|
-
onValueChange: () => {},
|
|
10
|
-
disabled: false,
|
|
11
|
-
required: false,
|
|
12
|
-
invalid: false,
|
|
13
|
-
readOnly: false,
|
|
14
|
-
native: false,
|
|
15
|
-
triggerRef: { current: null },
|
|
16
|
-
contentId: '',
|
|
17
|
-
triggerId: '',
|
|
18
|
-
activeValue: undefined,
|
|
19
|
-
setActiveValue: () => {}, // TODO: Is this needed? At the very least it could be moved to SelectContent
|
|
20
|
-
accessibilityLabel: undefined,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const SelectContext = createContext<SelectContextValue>(defaultContextValue);
|
|
24
|
-
|
|
25
|
-
export const useSelectContext = () => useContext(SelectContext);
|
|
5
|
+
export const [SelectProvider, useSelectContext] =
|
|
6
|
+
createContext<SelectContextValue>('SelectContext');
|
|
26
7
|
|
|
27
8
|
/**
|
|
28
9
|
* Propagates the trigger's interaction state (hover, focus, active, etc.) to
|
|
29
10
|
* child components like SelectValue and SelectIcon so they can apply matching
|
|
30
11
|
* data-attribute styles.
|
|
31
12
|
*/
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
focus: false,
|
|
35
|
-
active: false,
|
|
36
|
-
disabled: false,
|
|
37
|
-
focusVisible: false,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const useSelectTriggerContext = () => useContext(SelectTriggerContext);
|
|
13
|
+
export const [SelectTriggerProvider, useSelectTriggerContext] =
|
|
14
|
+
createContext<InteractionState>('SelectTriggerContext');
|
|
41
15
|
|
|
42
16
|
/**
|
|
43
17
|
* Propagates the item's interaction and selection state (hover, focus, active,
|
|
44
18
|
* highlighted, checked, etc.) to child components like SelectItemLabel.
|
|
45
19
|
*/
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
focus: false,
|
|
49
|
-
active: false,
|
|
50
|
-
disabled: false,
|
|
51
|
-
focusVisible: false,
|
|
52
|
-
highlighted: false,
|
|
53
|
-
checked: false,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const useSelectItemContext = () => useContext(SelectItemContext);
|
|
20
|
+
export const [SelectItemProvider, useSelectItemContext] =
|
|
21
|
+
createContext<SelectItemInteractionState>('SelectItemContext');
|
|
@@ -4,7 +4,7 @@ import { composeEventHandlers } from '@cdx-ui/utils';
|
|
|
4
4
|
import { useFocus, useFocusRing } from '@react-native-aria/focus';
|
|
5
5
|
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
6
6
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
|
-
import {
|
|
7
|
+
import { SelectItemProvider, useSelectContext } from './context';
|
|
8
8
|
import type { ISelectItemProps } from './types';
|
|
9
9
|
|
|
10
10
|
export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
@@ -74,7 +74,7 @@ export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<
|
|
77
|
+
<SelectItemProvider value={interactionState}>
|
|
78
78
|
<BaseItem
|
|
79
79
|
ref={ref}
|
|
80
80
|
role="option"
|
|
@@ -115,7 +115,7 @@ export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
|
115
115
|
>
|
|
116
116
|
{children}
|
|
117
117
|
</BaseItem>
|
|
118
|
-
</
|
|
118
|
+
</SelectItemProvider>
|
|
119
119
|
);
|
|
120
120
|
},
|
|
121
121
|
);
|