@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/select/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/select/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSwitchRoot.d.ts","sourceRoot":"","sources":["../../../src/switch/createSwitchRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAS1C,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,YAAY,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,sGA8DhF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { ISwitchComponentType } from './types';
|
|
3
|
+
export type { ISwitchProps, ISwitchComponentType, IInterfaceSwitchProps } from './types';
|
|
4
|
+
export declare function createSwitch<T, R = unknown>({ Root, }: {
|
|
5
|
+
Root: React.ComponentType<T>;
|
|
6
|
+
}): ISwitchComponentType<T, R>;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/switch/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEzF,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,EAC3C,IAAI,GACL,EAAE;IACD,IAAI,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAC9B,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAK7B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface IInterfaceSwitchProps {
|
|
3
|
+
/**
|
|
4
|
+
* Callback invoked when the switch value changes.
|
|
5
|
+
*/
|
|
6
|
+
onValueChange?: (value: boolean) => void;
|
|
7
|
+
/**
|
|
8
|
+
* If true, set the Switch to the checked state.
|
|
9
|
+
*/
|
|
10
|
+
isChecked?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The current value of the switch.
|
|
13
|
+
*/
|
|
14
|
+
value?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* If true, the switch will be disabled.
|
|
17
|
+
*/
|
|
18
|
+
isDisabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* If true, the switch will be disabled.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* If true, the checkbox will be initially checked.
|
|
25
|
+
*/
|
|
26
|
+
defaultValue?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* If true, set the switch to the invalid state.
|
|
29
|
+
*/
|
|
30
|
+
isInvalid?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the switch will be hovered.
|
|
33
|
+
*/
|
|
34
|
+
isHovered?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export type ISwitchComponentType<T, R = unknown> = React.ForwardRefExoticComponent<React.PropsWithoutRef<T & IInterfaceSwitchProps> & React.RefAttributes<R>>;
|
|
37
|
+
export type ISwitchProps = IInterfaceSwitchProps;
|
|
38
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/switch/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,yBAAyB,CAChF,KAAK,CAAC,eAAe,CAAC,CAAC,GAAG,qBAAqB,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAC1E,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
type CreatePortalFn = (children: React.ReactNode, container: Element) => React.ReactPortal;
|
|
3
|
+
/**
|
|
4
|
+
* A reference to `ReactDOM.createPortal` on web, `undefined` on native.
|
|
5
|
+
*
|
|
6
|
+
* Loaded lazily via `require` so that native bundles never reference
|
|
7
|
+
* `react-dom`, which would cause a build error on native platforms.
|
|
8
|
+
*/
|
|
9
|
+
export declare const createPortalFn: CreatePortalFn | undefined;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=createPortal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPortal.d.ts","sourceRoot":"","sources":["../../../src/utils/createPortal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,KAAK,KAAK,CAAC,WAAW,CAAC;AAE3F;;;;;GAKG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,GAAG,SAQ1C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataAttributes.web.d.ts","sourceRoot":"","sources":["../../../src/utils/dataAttributes.web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,KAAK,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG;IACzE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CAC3C,
|
|
1
|
+
{"version":3,"file":"dataAttributes.web.d.ts","sourceRoot":"","sources":["../../../src/utils/dataAttributes.web.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,KAAK,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG;IACzE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC;CAC3C,CAQA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cdx-ui/primitives",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.40",
|
|
4
4
|
"main": "lib/commonjs/index.js",
|
|
5
5
|
"module": "lib/module/index.js",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -25,7 +25,12 @@
|
|
|
25
25
|
"targets": [
|
|
26
26
|
"commonjs",
|
|
27
27
|
"module",
|
|
28
|
-
|
|
28
|
+
[
|
|
29
|
+
"typescript",
|
|
30
|
+
{
|
|
31
|
+
"project": "tsconfig.build.json"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
29
34
|
]
|
|
30
35
|
},
|
|
31
36
|
"peerDependencies": {
|
|
@@ -46,9 +51,13 @@
|
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
54
|
+
"@react-aria/visually-hidden": "3.8.30",
|
|
55
|
+
"@react-native-aria/checkbox": "0.2.10",
|
|
49
56
|
"@react-native-aria/focus": "^0.2.9",
|
|
50
57
|
"@react-native-aria/interactions": "^0.2.16",
|
|
51
|
-
"@
|
|
58
|
+
"@react-stately/checkbox": "3.7.4",
|
|
59
|
+
"@react-stately/toggle": "3.9.4",
|
|
60
|
+
"@cdx-ui/utils": "0.0.1-alpha.40"
|
|
52
61
|
},
|
|
53
62
|
"devDependencies": {
|
|
54
63
|
"@types/react": "*",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import type { IAvatarBadgeProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createAvatarBadge = <T,>(BaseBadge: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef<unknown, IAvatarBadgeProps>(({ children, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<BaseBadge ref={ref} {...(props as T)}>
|
|
9
|
+
{children}
|
|
10
|
+
</BaseBadge>
|
|
11
|
+
);
|
|
12
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarIconProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarIcon = <T,>(BaseIcon: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarIconProps>(({ children, style, ...props }, ref) => {
|
|
8
|
+
const { imageLoaded, imageError } = useAvatarContext();
|
|
9
|
+
const visible = !imageLoaded || imageError;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<BaseIcon ref={ref} style={[style, !visible && { opacity: 0 }]} {...(props as T)}>
|
|
13
|
+
{children}
|
|
14
|
+
</BaseIcon>
|
|
15
|
+
);
|
|
16
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useEffect, useMemo } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarImageProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarImage = <T,>(BaseImage: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarImageProps>(({ src, source, onLoad, onError, ...props }, ref) => {
|
|
8
|
+
const { imageError, setImageLoaded, setImageError } = useAvatarContext();
|
|
9
|
+
|
|
10
|
+
const resolvedSource = useMemo(() => (src ? { uri: src } : source), [src, source]);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!resolvedSource) {
|
|
14
|
+
setImageError(true);
|
|
15
|
+
} else {
|
|
16
|
+
setImageError(false);
|
|
17
|
+
setImageLoaded(false);
|
|
18
|
+
}
|
|
19
|
+
}, [resolvedSource, setImageError, setImageLoaded]);
|
|
20
|
+
|
|
21
|
+
if (!resolvedSource || imageError) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BaseImage
|
|
27
|
+
ref={ref}
|
|
28
|
+
source={resolvedSource}
|
|
29
|
+
onLoad={(e: unknown) => {
|
|
30
|
+
setImageLoaded(true);
|
|
31
|
+
(onLoad as (e: unknown) => void)?.(e);
|
|
32
|
+
}}
|
|
33
|
+
onError={(e: unknown) => {
|
|
34
|
+
setImageError(true);
|
|
35
|
+
(onError as (e: unknown) => void)?.(e);
|
|
36
|
+
}}
|
|
37
|
+
{...(props as T)}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useMemo, useState } from 'react';
|
|
3
|
+
import { AvatarProvider } from './context';
|
|
4
|
+
import type { IAvatarProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createAvatarRoot = <T,>(BaseAvatar: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, IAvatarProps>(({ children, ...props }, ref) => {
|
|
8
|
+
const [imageLoaded, setImageLoaded] = useState(false);
|
|
9
|
+
const [imageError, setImageError] = useState(false);
|
|
10
|
+
|
|
11
|
+
const contextValue = useMemo(
|
|
12
|
+
() => ({ imageLoaded, imageError, setImageLoaded, setImageError }),
|
|
13
|
+
[imageLoaded, imageError],
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<AvatarProvider value={contextValue}>
|
|
18
|
+
<BaseAvatar ref={ref} role="img" accessibilityRole="image" {...(props as T)}>
|
|
19
|
+
{children}
|
|
20
|
+
</BaseAvatar>
|
|
21
|
+
</AvatarProvider>
|
|
22
|
+
);
|
|
23
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useAvatarContext } from './context';
|
|
4
|
+
import type { IAvatarTextProps } from './types';
|
|
5
|
+
|
|
6
|
+
function getInitials(name: string): string {
|
|
7
|
+
const words = name.trim().split(/\s+/);
|
|
8
|
+
let result = '';
|
|
9
|
+
for (const word of words) {
|
|
10
|
+
if (word.length > 0) {
|
|
11
|
+
result += word.charAt(0);
|
|
12
|
+
}
|
|
13
|
+
if (result.length >= 2) break;
|
|
14
|
+
}
|
|
15
|
+
return result.toUpperCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const createAvatarText = <T,>(BaseText: React.ComponentType<T>) =>
|
|
19
|
+
forwardRef<unknown, IAvatarTextProps>(({ children, style, ...props }, ref) => {
|
|
20
|
+
const { imageLoaded, imageError } = useAvatarContext();
|
|
21
|
+
const visible = !imageLoaded || imageError;
|
|
22
|
+
|
|
23
|
+
const text = typeof children === 'string' ? getInitials(children) : children;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<BaseText ref={ref} style={[style, !visible && { opacity: 0 }]} {...(props as T)}>
|
|
27
|
+
{text}
|
|
28
|
+
</BaseText>
|
|
29
|
+
);
|
|
30
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createAvatarBadge } from './createAvatarBadge';
|
|
3
|
+
import { createAvatarIcon } from './createAvatarIcon';
|
|
4
|
+
import { createAvatarText } from './createAvatarText';
|
|
5
|
+
import { createAvatarImage } from './createAvatarImage';
|
|
6
|
+
import { createAvatarRoot } from './createAvatarRoot';
|
|
7
|
+
import type { IAvatarComponentType } from './types';
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
IAvatarBadgeProps,
|
|
11
|
+
IAvatarComponentType,
|
|
12
|
+
IAvatarIconProps,
|
|
13
|
+
IAvatarTextProps,
|
|
14
|
+
IAvatarImageProps,
|
|
15
|
+
IAvatarProps,
|
|
16
|
+
} from './types';
|
|
17
|
+
|
|
18
|
+
export function createAvatar<Root, Image, Text, Icon, Badge>(BaseComponents: {
|
|
19
|
+
Root: React.ComponentType<Root>;
|
|
20
|
+
Image: React.ComponentType<Image>;
|
|
21
|
+
Text: React.ComponentType<Text>;
|
|
22
|
+
Icon: React.ComponentType<Icon>;
|
|
23
|
+
Badge: React.ComponentType<Badge>;
|
|
24
|
+
}) {
|
|
25
|
+
const Avatar = createAvatarRoot(BaseComponents.Root);
|
|
26
|
+
const AvatarImage = createAvatarImage(BaseComponents.Image);
|
|
27
|
+
const Text = createAvatarText(BaseComponents.Text);
|
|
28
|
+
const AvatarIcon = createAvatarIcon(BaseComponents.Icon);
|
|
29
|
+
const Badge = createAvatarBadge(BaseComponents.Badge);
|
|
30
|
+
|
|
31
|
+
Avatar.displayName = 'AvatarPrimitive';
|
|
32
|
+
AvatarImage.displayName = 'AvatarPrimitive.Image';
|
|
33
|
+
Text.displayName = 'AvatarPrimitive.Text';
|
|
34
|
+
AvatarIcon.displayName = 'AvatarPrimitive.Icon';
|
|
35
|
+
Badge.displayName = 'AvatarPrimitive.Badge';
|
|
36
|
+
|
|
37
|
+
return Object.assign(Avatar, {
|
|
38
|
+
Image: AvatarImage,
|
|
39
|
+
Text,
|
|
40
|
+
Icon: AvatarIcon,
|
|
41
|
+
Badge,
|
|
42
|
+
}) as unknown as IAvatarComponentType<Root, Image, Text, Icon, Badge>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { ImageProps, TextProps, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// AVATAR ROOT
|
|
5
|
+
// =============================================================================
|
|
6
|
+
|
|
7
|
+
export interface IAvatarProps extends ViewProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// AVATAR IMAGE
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export interface IAvatarImageProps extends Omit<ImageProps, 'source'> {
|
|
16
|
+
/** Image source — URI string or RN ImageSourcePropType */
|
|
17
|
+
src?: string;
|
|
18
|
+
source?: ImageProps['source'];
|
|
19
|
+
alt?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// =============================================================================
|
|
23
|
+
// AVATAR FALLBACK TEXT
|
|
24
|
+
// =============================================================================
|
|
25
|
+
|
|
26
|
+
export interface IAvatarTextProps extends TextProps {
|
|
27
|
+
/** Full name — initials will be derived automatically */
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// AVATAR ICON (fallback icon — hidden when image loads)
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
export interface IAvatarIconProps extends ViewProps {
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// =============================================================================
|
|
40
|
+
// AVATAR BADGE
|
|
41
|
+
// =============================================================================
|
|
42
|
+
|
|
43
|
+
export interface IAvatarBadgeProps extends ViewProps {
|
|
44
|
+
children?: React.ReactNode;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// =============================================================================
|
|
48
|
+
// CONTEXT
|
|
49
|
+
// =============================================================================
|
|
50
|
+
|
|
51
|
+
export interface IAvatarContextValue {
|
|
52
|
+
imageLoaded: boolean;
|
|
53
|
+
imageError: boolean;
|
|
54
|
+
setImageLoaded: (loaded: boolean) => void;
|
|
55
|
+
setImageError: (error: boolean) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// COMPOUND COMPONENT TYPE
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
export type IAvatarComponentType<Root, Image, Text, Icon, Badge> = React.ForwardRefExoticComponent<
|
|
63
|
+
React.RefAttributes<Root> & React.PropsWithoutRef<Root> & IAvatarProps
|
|
64
|
+
> & {
|
|
65
|
+
Image: React.ForwardRefExoticComponent<
|
|
66
|
+
React.RefAttributes<Image> & React.PropsWithoutRef<Image> & IAvatarImageProps
|
|
67
|
+
>;
|
|
68
|
+
Text: React.ForwardRefExoticComponent<
|
|
69
|
+
React.RefAttributes<Text> & React.PropsWithoutRef<Text> & IAvatarTextProps
|
|
70
|
+
>;
|
|
71
|
+
Icon: React.ForwardRefExoticComponent<
|
|
72
|
+
React.RefAttributes<Icon> & React.PropsWithoutRef<Icon> & IAvatarIconProps
|
|
73
|
+
>;
|
|
74
|
+
Badge: React.ForwardRefExoticComponent<
|
|
75
|
+
React.RefAttributes<Badge> & React.PropsWithoutRef<Badge> & IAvatarBadgeProps
|
|
76
|
+
>;
|
|
77
|
+
};
|
package/src/button/context.tsx
CHANGED
|
@@ -3,9 +3,10 @@ import { forwardRef, useMemo } from 'react';
|
|
|
3
3
|
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
|
+
import type { InteractionState } from '../types';
|
|
6
7
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
8
|
import { ButtonProvider } from './context';
|
|
8
|
-
import type { IButtonProps
|
|
9
|
+
import type { IButtonProps } from './types';
|
|
9
10
|
|
|
10
11
|
export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
11
12
|
forwardRef(
|
|
@@ -37,7 +38,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
37
38
|
hover: isHoveredProp || isHovered,
|
|
38
39
|
focus: isFocusedProp || isFocused,
|
|
39
40
|
active: isActiveProp || isActive,
|
|
40
|
-
disabled: isDisabled,
|
|
41
|
+
disabled: !!isDisabled,
|
|
41
42
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
42
43
|
};
|
|
43
44
|
}, [
|
|
@@ -61,7 +62,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
61
62
|
hover: isHoveredProp || isHovered,
|
|
62
63
|
focus: isFocusedProp || isFocused,
|
|
63
64
|
active: isActiveProp || isActive,
|
|
64
|
-
disabled: isDisabled,
|
|
65
|
+
disabled: !!isDisabled,
|
|
65
66
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
66
67
|
})}
|
|
67
68
|
disabled={isDisabled}
|
|
@@ -90,7 +91,7 @@ export const createButtonRoot = <T,>(BaseButton: React.ComponentType<T>) =>
|
|
|
90
91
|
hover: isHoveredProp || isHovered,
|
|
91
92
|
focus: isFocusedProp || isFocused,
|
|
92
93
|
active: isActiveProp || isActive,
|
|
93
|
-
disabled: isDisabled,
|
|
94
|
+
disabled: !!isDisabled,
|
|
94
95
|
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
95
96
|
})
|
|
96
97
|
: children}
|
package/src/button/index.tsx
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import { createButtonRoot } from './createButtonRoot';
|
|
3
2
|
import { createButtonGroup } from './createButtonGroup';
|
|
4
3
|
import { createButtonIcon } from './createButtonIcon';
|
|
4
|
+
import { createButtonRoot } from './createButtonRoot';
|
|
5
5
|
import { createButtonSpinner } from './createButtonSpinner';
|
|
6
6
|
import { createButtonText } from './createButtonText';
|
|
7
7
|
import type { IButtonComponentType } from './types';
|
|
8
8
|
|
|
9
9
|
export type { IButtonProps } from './types';
|
|
10
|
+
export { useButtonContext } from './context';
|
|
10
11
|
|
|
11
12
|
export function createButton<
|
|
12
13
|
ButtonProps,
|
|
@@ -16,32 +17,31 @@ export function createButton<
|
|
|
16
17
|
IconProps,
|
|
17
18
|
ButtonRef = unknown,
|
|
18
19
|
TextRef = unknown,
|
|
19
|
-
>({
|
|
20
|
-
Root,
|
|
21
|
-
Text,
|
|
22
|
-
Group,
|
|
23
|
-
Spinner,
|
|
24
|
-
Icon,
|
|
25
|
-
}: {
|
|
20
|
+
>(BaseComponents: {
|
|
26
21
|
Root: React.ComponentType<ButtonProps>;
|
|
27
22
|
Text: React.ComponentType<TextProps>;
|
|
28
23
|
Group: React.ComponentType<GroupProps>;
|
|
29
24
|
Spinner: React.ComponentType<SpinnerProps>;
|
|
30
25
|
Icon: React.ComponentType<IconProps>;
|
|
31
26
|
}) {
|
|
32
|
-
const Button = createButtonRoot(Root)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
const Button = createButtonRoot(BaseComponents.Root);
|
|
28
|
+
const Text = createButtonText(BaseComponents.Text);
|
|
29
|
+
const Group = createButtonGroup(BaseComponents.Group);
|
|
30
|
+
const Spinner = createButtonSpinner(BaseComponents.Spinner);
|
|
31
|
+
const Icon = createButtonIcon(BaseComponents.Icon);
|
|
37
32
|
|
|
38
|
-
Button.displayName = '
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
Button.displayName = 'ButtonPrimitive';
|
|
34
|
+
Text.displayName = 'ButtonPrimitive.Text';
|
|
35
|
+
Group.displayName = 'ButtonPrimitive.Group';
|
|
36
|
+
Spinner.displayName = 'ButtonPrimitive.Spinner';
|
|
37
|
+
Icon.displayName = 'ButtonPrimitive.Icon';
|
|
43
38
|
|
|
44
|
-
return Button
|
|
39
|
+
return Object.assign(Button, {
|
|
40
|
+
Text,
|
|
41
|
+
Group,
|
|
42
|
+
Spinner,
|
|
43
|
+
Icon,
|
|
44
|
+
}) as IButtonComponentType<
|
|
45
45
|
ButtonProps,
|
|
46
46
|
GroupProps,
|
|
47
47
|
SpinnerProps,
|
package/src/button/types.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import type { PropsWithoutRef, ReactElement, ReactNode, RefAttributes } from 'react';
|
|
2
2
|
import type { PressableProps, ViewProps } from 'react-native';
|
|
3
3
|
|
|
4
|
-
export interface InteractionState {
|
|
5
|
-
hover: boolean;
|
|
6
|
-
focus: boolean;
|
|
7
|
-
active: boolean;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
focusVisible: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
4
|
export interface InterfaceButtonProps extends PressableProps {
|
|
13
5
|
/**
|
|
14
6
|
* If true, the button will be in hovered state.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createContext } from '@cdx-ui/utils';
|
|
3
|
+
import type { ICheckboxContextValue } from './types';
|
|
4
|
+
|
|
5
|
+
export const [CheckboxProvider, useCheckboxContext] =
|
|
6
|
+
createContext<ICheckboxContextValue>('CheckboxContext');
|
|
7
|
+
|
|
8
|
+
interface ICheckboxGroupState {
|
|
9
|
+
isReadOnly: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
isSelected: (value: string) => boolean;
|
|
12
|
+
addValue: (value: string) => void;
|
|
13
|
+
removeValue: (value: string) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const CheckboxGroupContext = React.createContext<{
|
|
17
|
+
state: ICheckboxGroupState;
|
|
18
|
+
} | null>(null);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
import { useCheckboxGroup } from '@react-native-aria/checkbox';
|
|
4
|
+
import { useCheckboxGroupState } from '@react-stately/checkbox';
|
|
5
|
+
import { CheckboxGroupContext } from './context';
|
|
6
|
+
import type { ICheckboxGroupProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const createCheckboxGroup = <T,>(BaseCheckboxGroup: React.ComponentType<T>) =>
|
|
9
|
+
forwardRef(({ children, ...props }: ICheckboxGroupProps, ref?: React.Ref<T>) => {
|
|
10
|
+
const state = useCheckboxGroupState({
|
|
11
|
+
...props,
|
|
12
|
+
validationState: props.isInvalid ? 'invalid' : 'valid',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { groupProps } = useCheckboxGroup(
|
|
16
|
+
{
|
|
17
|
+
...props,
|
|
18
|
+
'aria-label': props['aria-label'],
|
|
19
|
+
},
|
|
20
|
+
state,
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
const formControlContext = useFormControlContext();
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<CheckboxGroupContext.Provider value={{ state: { ...formControlContext, ...state } }}>
|
|
27
|
+
<BaseCheckboxGroup {...groupProps} {...props} ref={ref}>
|
|
28
|
+
{children}
|
|
29
|
+
</BaseCheckboxGroup>
|
|
30
|
+
</CheckboxGroupContext.Provider>
|
|
31
|
+
);
|
|
32
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { useCheckboxContext } from './context';
|
|
3
|
+
import type { ICheckboxIconProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createCheckboxIcon = <T,>(BaseCheckboxIcon: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef<unknown, ICheckboxIconProps>(({ children, forceMount = false, ...props }, ref) => {
|
|
7
|
+
const { isChecked, isIndeterminate } = useCheckboxContext();
|
|
8
|
+
|
|
9
|
+
if (forceMount || isChecked || isIndeterminate) {
|
|
10
|
+
return (
|
|
11
|
+
<BaseCheckboxIcon {...(props as T)} ref={ref}>
|
|
12
|
+
{children}
|
|
13
|
+
</BaseCheckboxIcon>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return null;
|
|
18
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import { useCheckboxContext } from './context';
|
|
4
|
+
import type { ICheckboxIndicatorProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createCheckboxIndicator = <T,>(BaseCheckboxIndicator: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef<unknown, ICheckboxIndicatorProps & { 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
|
+
<BaseCheckboxIndicator
|
|
23
|
+
className={className}
|
|
24
|
+
{...dataAttributes({
|
|
25
|
+
hover: isHovered,
|
|
26
|
+
checked: isChecked,
|
|
27
|
+
disabled: isDisabled,
|
|
28
|
+
focusVisible: isFocusVisible,
|
|
29
|
+
invalid: isInvalid,
|
|
30
|
+
readOnly: isReadOnly,
|
|
31
|
+
active: isPressed,
|
|
32
|
+
focused: isFocused,
|
|
33
|
+
indeterminate: isIndeterminate,
|
|
34
|
+
slot: 'checkbox-indicator',
|
|
35
|
+
})}
|
|
36
|
+
{...(props as T)}
|
|
37
|
+
ref={ref}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</BaseCheckboxIndicator>
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|