@cdx-ui/primitives 0.0.1-alpha.4 → 0.0.1-alpha.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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,42 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import { useCheckboxContext } from './context';
|
|
4
|
+
import type { ICheckboxLabelProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createCheckboxLabel = <T,>(BaseCheckboxLabel: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, ICheckboxLabelProps & { className?: string }>(
|
|
8
|
+
({ children, className, ...props }, ref) => {
|
|
9
|
+
const {
|
|
10
|
+
isChecked,
|
|
11
|
+
isDisabled,
|
|
12
|
+
isHovered,
|
|
13
|
+
isInvalid,
|
|
14
|
+
isReadOnly,
|
|
15
|
+
isPressed,
|
|
16
|
+
isFocused,
|
|
17
|
+
isIndeterminate,
|
|
18
|
+
isFocusVisible,
|
|
19
|
+
} = useCheckboxContext();
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<BaseCheckboxLabel
|
|
23
|
+
className={className}
|
|
24
|
+
{...dataAttributes({
|
|
25
|
+
hover: isHovered,
|
|
26
|
+
checked: isChecked,
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
focusVisible: isFocusVisible,
|
|
29
|
+
invalid: isInvalid,
|
|
30
|
+
readOnly: isReadOnly,
|
|
31
|
+
pressed: isPressed,
|
|
32
|
+
focused: isFocused,
|
|
33
|
+
indeterminate: isIndeterminate,
|
|
34
|
+
})}
|
|
35
|
+
{...(props as T)}
|
|
36
|
+
ref={ref}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</BaseCheckboxLabel>
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
3
|
+
import { useFocus } from '@react-native-aria/focus';
|
|
4
|
+
import { usePress } from '@react-native-aria/interactions';
|
|
5
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { CheckboxProvider } from './context';
|
|
7
|
+
import type { ICheckboxProps } from './types';
|
|
8
|
+
import { useCheckboxRoot } from './useCheckboxRoot';
|
|
9
|
+
|
|
10
|
+
export const createCheckboxRoot = <T,>(BaseCheckbox: React.ComponentType<T>) =>
|
|
11
|
+
forwardRef(
|
|
12
|
+
(
|
|
13
|
+
{
|
|
14
|
+
onPressIn,
|
|
15
|
+
onPressOut,
|
|
16
|
+
onHoverIn,
|
|
17
|
+
onHoverOut,
|
|
18
|
+
onFocus,
|
|
19
|
+
onBlur,
|
|
20
|
+
children,
|
|
21
|
+
...props
|
|
22
|
+
}: ICheckboxProps,
|
|
23
|
+
ref?: React.Ref<T>,
|
|
24
|
+
) => {
|
|
25
|
+
const {
|
|
26
|
+
isHovered: isHoveredProp,
|
|
27
|
+
isChecked: isCheckedProp,
|
|
28
|
+
isDisabled: isDisabledProp,
|
|
29
|
+
isInvalid: isInvalidProp,
|
|
30
|
+
isReadOnly: isReadOnlyProp,
|
|
31
|
+
isPressed: isPressedProp,
|
|
32
|
+
isFocused: isFocusedProp,
|
|
33
|
+
isIndeterminate: isIndeterminateProp,
|
|
34
|
+
isFocusVisible,
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
combinedProps,
|
|
39
|
+
isInvalid,
|
|
40
|
+
isReadOnly,
|
|
41
|
+
isIndeterminate,
|
|
42
|
+
groupItemInputProps,
|
|
43
|
+
isChecked,
|
|
44
|
+
isDisabled,
|
|
45
|
+
isHovered,
|
|
46
|
+
hoverProps,
|
|
47
|
+
mergedRef,
|
|
48
|
+
} = useCheckboxRoot(props, ref);
|
|
49
|
+
|
|
50
|
+
const { focusProps, isFocused } = useFocus();
|
|
51
|
+
|
|
52
|
+
const { pressProps, isPressed } = usePress({
|
|
53
|
+
isDisabled: isDisabled || isDisabledProp,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<BaseCheckbox
|
|
58
|
+
disabled={isDisabled || isDisabledProp}
|
|
59
|
+
{...pressProps}
|
|
60
|
+
{...(combinedProps as T)}
|
|
61
|
+
{...groupItemInputProps}
|
|
62
|
+
ref={mergedRef}
|
|
63
|
+
role="checkbox"
|
|
64
|
+
onPressIn={composeEventHandlers(onPressIn, pressProps.onPressIn)}
|
|
65
|
+
onPressOut={composeEventHandlers(onPressOut, pressProps.onPressOut)}
|
|
66
|
+
onHoverIn={composeEventHandlers(onHoverIn, hoverProps.onHoverIn)}
|
|
67
|
+
onHoverOut={composeEventHandlers(onHoverOut, hoverProps.onHoverOut)}
|
|
68
|
+
onFocus={composeEventHandlers(composeEventHandlers(onFocus, focusProps.onFocus))}
|
|
69
|
+
onBlur={composeEventHandlers(composeEventHandlers(onBlur, focusProps.onBlur))}
|
|
70
|
+
{...dataAttributes({
|
|
71
|
+
checked: isChecked || isCheckedProp,
|
|
72
|
+
disabled: isDisabled || isDisabledProp,
|
|
73
|
+
hover: isHovered || isHoveredProp,
|
|
74
|
+
invalid: isInvalid || isInvalidProp,
|
|
75
|
+
readonly: isReadOnly || isReadOnlyProp,
|
|
76
|
+
active: isPressed,
|
|
77
|
+
focus: isFocused,
|
|
78
|
+
indeterminate: isIndeterminate || isIndeterminateProp,
|
|
79
|
+
focusVisible: isFocusVisible,
|
|
80
|
+
})}
|
|
81
|
+
>
|
|
82
|
+
<CheckboxProvider
|
|
83
|
+
value={{
|
|
84
|
+
isChecked: isChecked || isCheckedProp,
|
|
85
|
+
isDisabled: isDisabled || isDisabledProp,
|
|
86
|
+
isHovered: isHovered || isHoveredProp,
|
|
87
|
+
isInvalid: isInvalid || isInvalidProp,
|
|
88
|
+
isReadOnly: isReadOnly || isReadOnlyProp,
|
|
89
|
+
isPressed: isPressed || isPressedProp,
|
|
90
|
+
isFocused: isFocused || isFocusedProp,
|
|
91
|
+
isIndeterminate: isIndeterminate || isIndeterminateProp,
|
|
92
|
+
isFocusVisible,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</CheckboxProvider>
|
|
97
|
+
</BaseCheckbox>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
3
|
+
import { useFocusRing } from '@react-native-aria/focus';
|
|
4
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
+
import { CheckboxProvider } from './context';
|
|
6
|
+
import type { ICheckboxProps } from './types';
|
|
7
|
+
import { useCheckboxRoot } from './useCheckboxRoot';
|
|
8
|
+
|
|
9
|
+
// TODO: Label is taking focus on keyboard navigation
|
|
10
|
+
|
|
11
|
+
export const createCheckboxRoot = <T,>(BaseCheckbox: React.ComponentType<T>) =>
|
|
12
|
+
forwardRef(({ children, ...props }: ICheckboxProps, ref?: React.Ref<T>) => {
|
|
13
|
+
const {
|
|
14
|
+
isHovered: isHoveredProp,
|
|
15
|
+
isFocusVisible: isFocusVisibleProp,
|
|
16
|
+
isChecked: isCheckedProp,
|
|
17
|
+
isDisabled: isDisabledProp,
|
|
18
|
+
isInvalid: isInvalidProp,
|
|
19
|
+
isReadOnly: isReadOnlyProp,
|
|
20
|
+
isIndeterminate: isIndeterminateProp,
|
|
21
|
+
isFocused,
|
|
22
|
+
isPressed,
|
|
23
|
+
} = props;
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
combinedProps,
|
|
27
|
+
isInvalid,
|
|
28
|
+
isReadOnly,
|
|
29
|
+
isIndeterminate,
|
|
30
|
+
groupItemInputProps,
|
|
31
|
+
isChecked,
|
|
32
|
+
isDisabled,
|
|
33
|
+
isHovered,
|
|
34
|
+
mergedRef,
|
|
35
|
+
inputRef,
|
|
36
|
+
} = useCheckboxRoot(props, ref, { useInputRefForAria: true });
|
|
37
|
+
|
|
38
|
+
const { focusProps, isFocusVisible } = useFocusRing();
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<BaseCheckbox
|
|
42
|
+
{...(combinedProps as T)}
|
|
43
|
+
ref={mergedRef}
|
|
44
|
+
role="label"
|
|
45
|
+
// eslint-disable-next-line react-native-a11y/has-valid-accessibility-role
|
|
46
|
+
accessibilityRole="label"
|
|
47
|
+
{...dataAttributes({
|
|
48
|
+
checked: isChecked || isCheckedProp,
|
|
49
|
+
disabled: isDisabled || isDisabledProp,
|
|
50
|
+
hover: isHovered || isHoveredProp,
|
|
51
|
+
invalid: isInvalid || isInvalidProp,
|
|
52
|
+
readonly: isReadOnly || isReadOnlyProp,
|
|
53
|
+
active: isPressed,
|
|
54
|
+
focus: isFocused,
|
|
55
|
+
indeterminate: isIndeterminate || isIndeterminateProp,
|
|
56
|
+
focusVisible: isFocusVisible,
|
|
57
|
+
})}
|
|
58
|
+
>
|
|
59
|
+
<CheckboxProvider
|
|
60
|
+
value={{
|
|
61
|
+
isChecked: isChecked || isCheckedProp,
|
|
62
|
+
isDisabled: isDisabled || isDisabledProp,
|
|
63
|
+
isFocusVisible: isFocusVisible || isFocusVisibleProp,
|
|
64
|
+
isHovered: isHovered || isHoveredProp,
|
|
65
|
+
isInvalid: isInvalid || isInvalidProp,
|
|
66
|
+
isReadOnly: isReadOnly || isReadOnlyProp,
|
|
67
|
+
isIndeterminate: isIndeterminate || isIndeterminateProp,
|
|
68
|
+
isPressed,
|
|
69
|
+
isFocused,
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<VisuallyHidden>
|
|
73
|
+
<input {...groupItemInputProps} {...focusProps} ref={inputRef} />
|
|
74
|
+
</VisuallyHidden>
|
|
75
|
+
{children}
|
|
76
|
+
</CheckboxProvider>
|
|
77
|
+
</BaseCheckbox>
|
|
78
|
+
);
|
|
79
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createCheckboxGroup } from './createCheckboxGroup';
|
|
3
|
+
import { createCheckboxIcon } from './createCheckboxIcon';
|
|
4
|
+
import { createCheckboxIndicator } from './createCheckboxIndicator';
|
|
5
|
+
import { createCheckboxLabel } from './createCheckboxLabel';
|
|
6
|
+
import { createCheckboxRoot } from './createCheckboxRoot';
|
|
7
|
+
import type { ICheckboxComponentType } from './types';
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
ICheckboxComponentType,
|
|
11
|
+
ICheckboxGroupProps,
|
|
12
|
+
ICheckboxIconProps,
|
|
13
|
+
ICheckboxIndicatorProps,
|
|
14
|
+
ICheckboxLabelProps,
|
|
15
|
+
ICheckboxProps,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
export function createCheckbox<Root, Indicator, Icon, Label, Group>(BaseComponents: {
|
|
19
|
+
Root: React.ComponentType<Root>;
|
|
20
|
+
Indicator: React.ComponentType<Indicator>;
|
|
21
|
+
Icon: React.ComponentType<Icon>;
|
|
22
|
+
Label: React.ComponentType<Label>;
|
|
23
|
+
Group: React.ComponentType<Group>;
|
|
24
|
+
}) {
|
|
25
|
+
const Checkbox = createCheckboxRoot(BaseComponents.Root);
|
|
26
|
+
const Indicator = createCheckboxIndicator(BaseComponents.Indicator);
|
|
27
|
+
const Icon = createCheckboxIcon(BaseComponents.Icon);
|
|
28
|
+
const Label = createCheckboxLabel(BaseComponents.Label);
|
|
29
|
+
const Group = createCheckboxGroup(BaseComponents.Group);
|
|
30
|
+
|
|
31
|
+
Checkbox.displayName = 'CheckboxPrimitive';
|
|
32
|
+
Indicator.displayName = 'CheckboxPrimitive.Indicator';
|
|
33
|
+
Icon.displayName = 'CheckboxPrimitive.Icon';
|
|
34
|
+
Label.displayName = 'CheckboxPrimitive.Label';
|
|
35
|
+
Group.displayName = 'CheckboxPrimitive.Group';
|
|
36
|
+
|
|
37
|
+
return Object.assign(Checkbox, {
|
|
38
|
+
Indicator,
|
|
39
|
+
Icon,
|
|
40
|
+
Label,
|
|
41
|
+
Group,
|
|
42
|
+
}) as ICheckboxComponentType<Root, Indicator, Icon, Label, Group>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { PressableProps } from 'react-native';
|
|
2
|
+
export interface InterfaceCheckbox extends PressableProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange?: (isSelected: boolean) => void;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
defaultIsChecked?: boolean;
|
|
7
|
+
isChecked?: boolean;
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
isInvalid?: boolean;
|
|
10
|
+
isReadOnly?: boolean;
|
|
11
|
+
isHovered?: boolean;
|
|
12
|
+
isFocused?: boolean;
|
|
13
|
+
isPressed?: boolean;
|
|
14
|
+
isRequired?: boolean;
|
|
15
|
+
isIndeterminate?: boolean;
|
|
16
|
+
isFocusVisible?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ICheckboxGroupProps {
|
|
20
|
+
value: string[];
|
|
21
|
+
onChange?: (values: string[]) => void;
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
isInvalid?: boolean;
|
|
25
|
+
isReadOnly?: boolean;
|
|
26
|
+
isRequired?: boolean;
|
|
27
|
+
'aria-label'?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ICheckboxComponentType<Root, Indicator, Icon, Label, Group> =
|
|
31
|
+
React.ForwardRefExoticComponent<
|
|
32
|
+
React.RefAttributes<Root> & React.PropsWithoutRef<Root> & InterfaceCheckbox
|
|
33
|
+
> & {
|
|
34
|
+
Indicator: React.ForwardRefExoticComponent<
|
|
35
|
+
React.RefAttributes<Indicator> & React.PropsWithoutRef<Indicator> & ICheckboxIndicatorProps
|
|
36
|
+
>;
|
|
37
|
+
Icon: React.ForwardRefExoticComponent<
|
|
38
|
+
React.RefAttributes<Icon> & React.PropsWithoutRef<Icon> & ICheckboxIconProps
|
|
39
|
+
>;
|
|
40
|
+
Label: React.ForwardRefExoticComponent<
|
|
41
|
+
React.RefAttributes<Label> & React.PropsWithoutRef<Label> & ICheckboxLabelProps
|
|
42
|
+
>;
|
|
43
|
+
Group: React.ForwardRefExoticComponent<
|
|
44
|
+
React.RefAttributes<Group> & React.PropsWithoutRef<Group> & ICheckboxGroupProps
|
|
45
|
+
>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export interface ICheckboxIndicatorProps {
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ICheckboxIconProps {
|
|
53
|
+
children?: React.ReactNode;
|
|
54
|
+
/** Render the icon even when unchecked */
|
|
55
|
+
forceMount?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ICheckboxLabelProps {
|
|
59
|
+
children?: React.ReactNode;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type ICheckboxProps = InterfaceCheckbox;
|
|
63
|
+
|
|
64
|
+
export interface ICheckboxContextValue {
|
|
65
|
+
isChecked?: boolean;
|
|
66
|
+
isDisabled?: boolean;
|
|
67
|
+
isHovered?: boolean;
|
|
68
|
+
isInvalid?: boolean;
|
|
69
|
+
isReadOnly?: boolean;
|
|
70
|
+
isPressed?: boolean;
|
|
71
|
+
isFocused?: boolean;
|
|
72
|
+
isIndeterminate?: boolean;
|
|
73
|
+
isFocusVisible?: boolean;
|
|
74
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useContext, useRef } from 'react';
|
|
2
|
+
import { mergeRefs, useFormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
import { useCheckbox } from '@react-native-aria/checkbox';
|
|
4
|
+
import { useHover } from '@react-native-aria/interactions';
|
|
5
|
+
import { useToggleState } from '@react-stately/toggle';
|
|
6
|
+
import { CheckboxGroupContext } from './context';
|
|
7
|
+
import type { ICheckboxProps } from './types';
|
|
8
|
+
|
|
9
|
+
interface UseCheckboxRootOptions {
|
|
10
|
+
useInputRefForAria?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useCheckboxRoot(
|
|
14
|
+
props: ICheckboxProps,
|
|
15
|
+
ref?: React.Ref<unknown>,
|
|
16
|
+
{ useInputRefForAria = false }: UseCheckboxRootOptions = {},
|
|
17
|
+
) {
|
|
18
|
+
const formControlContext = useFormControlContext();
|
|
19
|
+
|
|
20
|
+
const { isInvalid, isReadOnly, isIndeterminate, ...combinedProps } = {
|
|
21
|
+
...formControlContext,
|
|
22
|
+
...props,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const checkboxGroupContext = useContext(CheckboxGroupContext);
|
|
26
|
+
|
|
27
|
+
const state = useToggleState({
|
|
28
|
+
...combinedProps,
|
|
29
|
+
defaultSelected: props.defaultIsChecked,
|
|
30
|
+
isSelected: props.isChecked,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const rootRef = useRef(null);
|
|
34
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
35
|
+
const mergedRootRef = mergeRefs(ref as any, rootRef as any);
|
|
36
|
+
const ariaLabel = combinedProps['aria-label'] || combinedProps.value || 'Checkbox';
|
|
37
|
+
|
|
38
|
+
const groupToggleState = useToggleState(
|
|
39
|
+
checkboxGroupContext
|
|
40
|
+
? {
|
|
41
|
+
isReadOnly: isReadOnly || checkboxGroupContext.state.isReadOnly,
|
|
42
|
+
isSelected: checkboxGroupContext.state.isSelected(combinedProps.value),
|
|
43
|
+
onChange(isSelected: boolean) {
|
|
44
|
+
if (isSelected) {
|
|
45
|
+
checkboxGroupContext.state.addValue(combinedProps.value);
|
|
46
|
+
} else {
|
|
47
|
+
checkboxGroupContext.state.removeValue(combinedProps.value);
|
|
48
|
+
}
|
|
49
|
+
combinedProps.onChange?.(isSelected);
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: { isSelected: false },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const { inputProps: groupItemInputProps } = useCheckbox(
|
|
56
|
+
{
|
|
57
|
+
...combinedProps,
|
|
58
|
+
'aria-label': ariaLabel,
|
|
59
|
+
...(checkboxGroupContext && {
|
|
60
|
+
isReadOnly: isReadOnly || checkboxGroupContext.state.isReadOnly,
|
|
61
|
+
isDisabled: combinedProps.isDisabled || checkboxGroupContext.state.isDisabled,
|
|
62
|
+
}),
|
|
63
|
+
} as any,
|
|
64
|
+
checkboxGroupContext ? groupToggleState : state,
|
|
65
|
+
(useInputRefForAria ? inputRef : rootRef) as any,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const { checked: isChecked, disabled: isDisabled } = groupItemInputProps;
|
|
69
|
+
|
|
70
|
+
const { hoverProps, isHovered } = useHover({}, rootRef);
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
combinedProps,
|
|
74
|
+
isInvalid,
|
|
75
|
+
isReadOnly,
|
|
76
|
+
isIndeterminate,
|
|
77
|
+
groupItemInputProps,
|
|
78
|
+
isChecked,
|
|
79
|
+
isDisabled,
|
|
80
|
+
isHovered,
|
|
81
|
+
hoverProps,
|
|
82
|
+
mergedRef: mergedRootRef,
|
|
83
|
+
inputRef,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogBodyProps } from './types';
|
|
3
|
+
|
|
4
|
+
export const createDialogBody = <T,>(BaseBody: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, IDialogBodyProps>(({ children, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<BaseBody ref={ref} {...(props as T)}>
|
|
8
|
+
{children}
|
|
9
|
+
</BaseBody>
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogCloseProps } from './types';
|
|
3
|
+
import { useDialog } from './context';
|
|
4
|
+
|
|
5
|
+
export const createDialogClose = <T,>(BaseClose: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef<unknown, IDialogCloseProps>(
|
|
7
|
+
({ asChild = false, children, onPress, ...props }, ref) => {
|
|
8
|
+
const { onOpenChange } = useDialog();
|
|
9
|
+
|
|
10
|
+
const handlePress = (e?: any) => {
|
|
11
|
+
onPress?.(e);
|
|
12
|
+
onOpenChange(false);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (asChild && React.isValidElement(children)) {
|
|
16
|
+
return React.cloneElement(children as React.ReactElement<any>, {
|
|
17
|
+
onPress: handlePress,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<BaseClose ref={ref} {...(props as T)} onPress={handlePress}>
|
|
23
|
+
{children}
|
|
24
|
+
</BaseClose>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useCallback } from 'react';
|
|
3
|
+
import { Modal, Platform, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { FocusScope } from '@react-native-aria/focus';
|
|
5
|
+
import { useEscapeKey } from '../overlay';
|
|
6
|
+
import { createPortalFn } from '../utils/createPortal';
|
|
7
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
8
|
+
import { useDialog } from './context';
|
|
9
|
+
import type { IDialogContentProps } from './types';
|
|
10
|
+
|
|
11
|
+
export const createDialogContent = <ContentProps, OverlayProps>(
|
|
12
|
+
BaseContent: React.ComponentType<ContentProps>,
|
|
13
|
+
BaseOverlay: React.ComponentType<OverlayProps>,
|
|
14
|
+
) =>
|
|
15
|
+
forwardRef(({ children, forceMount = false, ...props }: IDialogContentProps, ref?: any) => {
|
|
16
|
+
const { open, onOpenChange, closeOnBackdropPress, closeOnEscKey, nativeID, role } = useDialog();
|
|
17
|
+
|
|
18
|
+
const handleClose = useCallback(() => {
|
|
19
|
+
onOpenChange(false);
|
|
20
|
+
}, [onOpenChange]);
|
|
21
|
+
|
|
22
|
+
useEscapeKey(open && closeOnEscKey, handleClose);
|
|
23
|
+
|
|
24
|
+
if (!(open || forceMount)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const overlayProps = {
|
|
29
|
+
...(closeOnBackdropPress ? { onPress: handleClose } : {}),
|
|
30
|
+
accessible: false,
|
|
31
|
+
importantForAccessibility: 'no-hide-descendants' as const,
|
|
32
|
+
...dataAttributes({ slot: 'dialog-overlay' }),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const contentSlotAttrs = dataAttributes({
|
|
36
|
+
slot: 'dialog-content',
|
|
37
|
+
state: open ? 'open' : 'closed',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const ariaProps = {
|
|
41
|
+
role,
|
|
42
|
+
'aria-modal': true,
|
|
43
|
+
'aria-labelledby': `${nativeID}-title`,
|
|
44
|
+
'aria-describedby': `${nativeID}-description`,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
if (Platform.OS === 'web' && createPortalFn) {
|
|
48
|
+
return createPortalFn(
|
|
49
|
+
<FocusScope contain={open} restoreFocus autoFocus={open}>
|
|
50
|
+
<View
|
|
51
|
+
style={{
|
|
52
|
+
position: 'fixed' as any,
|
|
53
|
+
inset: 0 as any,
|
|
54
|
+
zIndex: 50,
|
|
55
|
+
display: 'flex' as any,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
<BaseOverlay {...(overlayProps as any)} />
|
|
61
|
+
<BaseContent
|
|
62
|
+
ref={ref}
|
|
63
|
+
{...contentSlotAttrs}
|
|
64
|
+
{...(props as ContentProps)}
|
|
65
|
+
{...ariaProps}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</BaseContent>
|
|
69
|
+
</View>
|
|
70
|
+
</FocusScope>,
|
|
71
|
+
document.body,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Native layout uses two layers to support both backdrop dismiss and
|
|
76
|
+
// scrollable body content. The overlay Pressable fills the Modal via
|
|
77
|
+
// absolute positioning and handles backdrop taps. A second absolute-fill
|
|
78
|
+
// View with pointerEvents="box-none" centers the content panel — "box-none"
|
|
79
|
+
// lets taps outside the panel pass through to the overlay while allowing
|
|
80
|
+
// the panel and its children to receive touches normally.
|
|
81
|
+
//
|
|
82
|
+
// Critically, the content panel must NOT claim the JS touch responder
|
|
83
|
+
// (e.g. via onStartShouldSetResponder). Doing so triggers React Native's
|
|
84
|
+
// blockNativeResponder, which suppresses the native UIScrollView /
|
|
85
|
+
// ScrollView pan gesture recognizer and breaks any ScrollView inside
|
|
86
|
+
// Dialog.Body.
|
|
87
|
+
//
|
|
88
|
+
// Static StyleSheet used here because these are structural layout concerns
|
|
89
|
+
// of the primitive's modal chrome — not themeable styles. They must remain
|
|
90
|
+
// stable regardless of the styled layer's className.
|
|
91
|
+
return (
|
|
92
|
+
<Modal visible={open} transparent statusBarTranslucent onRequestClose={handleClose}>
|
|
93
|
+
<FocusScope contain={open} restoreFocus autoFocus={open}>
|
|
94
|
+
<View style={styles.fill}>
|
|
95
|
+
<BaseOverlay {...(overlayProps as any)} />
|
|
96
|
+
<View style={styles.center} pointerEvents="box-none">
|
|
97
|
+
<BaseContent
|
|
98
|
+
ref={ref}
|
|
99
|
+
{...contentSlotAttrs}
|
|
100
|
+
{...(props as ContentProps)}
|
|
101
|
+
{...ariaProps}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</BaseContent>
|
|
105
|
+
</View>
|
|
106
|
+
</View>
|
|
107
|
+
</FocusScope>
|
|
108
|
+
</Modal>
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Structural layout for the native Modal chrome. These are not themeable —
|
|
113
|
+
// they position the overlay and centering layers that the primitive manages
|
|
114
|
+
// internally. Matches the pattern in OverlayContainer.tsx.
|
|
115
|
+
const styles = StyleSheet.create({
|
|
116
|
+
fill: { flex: 1 },
|
|
117
|
+
center: {
|
|
118
|
+
...StyleSheet.absoluteFillObject,
|
|
119
|
+
alignItems: 'center',
|
|
120
|
+
justifyContent: 'center',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import { useDialog } from './context';
|
|
4
|
+
import type { IDialogDescriptionProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createDialogDescription = <T,>(BaseDescription: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IDialogDescriptionProps>(({ children, ...props }, ref) => {
|
|
8
|
+
const { nativeID } = useDialog();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<BaseDescription
|
|
12
|
+
ref={ref}
|
|
13
|
+
nativeID={`${nativeID}-description`}
|
|
14
|
+
{...(props as T)}
|
|
15
|
+
{...dataAttributes({ slot: 'dialog-description' })}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</BaseDescription>
|
|
19
|
+
);
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogFooterProps } from './types';
|
|
3
|
+
|
|
4
|
+
export const createDialogFooter = <T,>(BaseFooter: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, IDialogFooterProps>(({ children, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<BaseFooter ref={ref} {...(props as T)}>
|
|
8
|
+
{children}
|
|
9
|
+
</BaseFooter>
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogHeaderProps } from './types';
|
|
3
|
+
|
|
4
|
+
export const createDialogHeader = <T,>(BaseHeader: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, IDialogHeaderProps>(({ children, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<BaseHeader ref={ref} {...(props as T)}>
|
|
8
|
+
{children}
|
|
9
|
+
</BaseHeader>
|
|
10
|
+
);
|
|
11
|
+
});
|