@cdx-ui/primitives 0.0.1-alpha.3 → 0.0.1-alpha.30
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/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/form-control/createFormError.js +41 -0
- package/lib/commonjs/form-control/createFormError.js.map +1 -0
- package/lib/commonjs/form-control/createFormErrorIcon.js +18 -0
- package/lib/commonjs/form-control/createFormErrorIcon.js.map +1 -0
- package/lib/commonjs/form-control/createFormErrorText.js +18 -0
- package/lib/commonjs/form-control/createFormErrorText.js.map +1 -0
- package/lib/commonjs/form-control/createFormField.js +35 -0
- package/lib/commonjs/form-control/createFormField.js.map +1 -0
- package/lib/commonjs/form-control/createFormHelper.js +41 -0
- package/lib/commonjs/form-control/createFormHelper.js.map +1 -0
- package/lib/commonjs/form-control/createFormHelperText.js +18 -0
- package/lib/commonjs/form-control/createFormHelperText.js.map +1 -0
- package/lib/commonjs/form-control/createFormLabel.js +38 -0
- package/lib/commonjs/form-control/createFormLabel.js.map +1 -0
- package/lib/commonjs/form-control/createFormRoot.js +21 -0
- package/lib/commonjs/form-control/createFormRoot.js.map +1 -0
- package/lib/commonjs/form-control/index.js +53 -0
- package/lib/commonjs/form-control/index.js.map +1 -0
- package/lib/commonjs/form-control/types.js +6 -0
- package/lib/commonjs/form-control/types.js.map +1 -0
- package/lib/commonjs/index.js +82 -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/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/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/form-control/createFormError.js +35 -0
- package/lib/module/form-control/createFormError.js.map +1 -0
- package/lib/module/form-control/createFormErrorIcon.js +13 -0
- package/lib/module/form-control/createFormErrorIcon.js.map +1 -0
- package/lib/module/form-control/createFormErrorText.js +13 -0
- package/lib/module/form-control/createFormErrorText.js.map +1 -0
- package/lib/module/form-control/createFormField.js +29 -0
- package/lib/module/form-control/createFormField.js.map +1 -0
- package/lib/module/form-control/createFormHelper.js +35 -0
- package/lib/module/form-control/createFormHelper.js.map +1 -0
- package/lib/module/form-control/createFormHelperText.js +13 -0
- package/lib/module/form-control/createFormHelperText.js.map +1 -0
- package/lib/module/form-control/createFormLabel.js +33 -0
- package/lib/module/form-control/createFormLabel.js.map +1 -0
- package/lib/module/form-control/createFormRoot.js +15 -0
- package/lib/module/form-control/createFormRoot.js.map +1 -0
- package/lib/module/form-control/index.js +49 -0
- package/lib/module/form-control/index.js.map +1 -0
- package/lib/module/form-control/types.js +4 -0
- package/lib/module/form-control/types.js.map +1 -0
- package/lib/module/index.js +8 -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/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/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/form-control/createFormError.d.ts +5 -0
- package/lib/typescript/form-control/createFormError.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormErrorIcon.d.ts +5 -0
- package/lib/typescript/form-control/createFormErrorIcon.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormErrorText.d.ts +5 -0
- package/lib/typescript/form-control/createFormErrorText.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormField.d.ts +6 -0
- package/lib/typescript/form-control/createFormField.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormHelper.d.ts +5 -0
- package/lib/typescript/form-control/createFormHelper.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormHelperText.d.ts +5 -0
- package/lib/typescript/form-control/createFormHelperText.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormLabel.d.ts +8 -0
- package/lib/typescript/form-control/createFormLabel.d.ts.map +1 -0
- package/lib/typescript/form-control/createFormRoot.d.ts +6 -0
- package/lib/typescript/form-control/createFormRoot.d.ts.map +1 -0
- package/lib/typescript/form-control/index.d.ts +14 -0
- package/lib/typescript/form-control/index.d.ts.map +1 -0
- package/lib/typescript/form-control/types.d.ts +73 -0
- package/lib/typescript/form-control/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +9 -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/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/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 +9 -9
- 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/form-control/createFormError.tsx +32 -0
- package/src/form-control/createFormErrorIcon.tsx +9 -0
- package/src/form-control/createFormErrorText.tsx +9 -0
- package/src/form-control/createFormField.tsx +27 -0
- package/src/form-control/createFormHelper.tsx +28 -0
- package/src/form-control/createFormHelperText.tsx +9 -0
- package/src/form-control/createFormLabel.tsx +30 -0
- package/src/form-control/createFormRoot.tsx +13 -0
- package/src/form-control/index.tsx +71 -0
- package/src/form-control/types.tsx +92 -0
- package/src/index.ts +9 -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/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/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,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
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useCallback, useId, useMemo } from 'react';
|
|
3
|
+
import { useControllableState } from '@cdx-ui/utils';
|
|
4
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
+
import { DialogProvider } from './context';
|
|
6
|
+
import type { IDialogRootProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const createDialogRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
9
|
+
forwardRef(
|
|
10
|
+
(
|
|
11
|
+
{
|
|
12
|
+
open: openProp,
|
|
13
|
+
onOpenChange,
|
|
14
|
+
defaultOpen = false,
|
|
15
|
+
closeOnBackdropPress = true,
|
|
16
|
+
closeOnEscKey = true,
|
|
17
|
+
role = 'dialog',
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}: IDialogRootProps,
|
|
21
|
+
ref?: React.Ref<T>,
|
|
22
|
+
) => {
|
|
23
|
+
const [open, setOpenState] = useControllableState<boolean>({
|
|
24
|
+
prop: openProp,
|
|
25
|
+
defaultProp: defaultOpen,
|
|
26
|
+
onChange: onOpenChange,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const setOpen = useCallback(
|
|
30
|
+
(newOpen: boolean) => {
|
|
31
|
+
setOpenState(newOpen);
|
|
32
|
+
},
|
|
33
|
+
[setOpenState],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const id = useId();
|
|
37
|
+
const nativeID = `dialog-${id}`;
|
|
38
|
+
|
|
39
|
+
const contextValue = useMemo(
|
|
40
|
+
() => ({
|
|
41
|
+
open: open ?? false,
|
|
42
|
+
onOpenChange: setOpen,
|
|
43
|
+
closeOnBackdropPress,
|
|
44
|
+
closeOnEscKey,
|
|
45
|
+
nativeID,
|
|
46
|
+
role,
|
|
47
|
+
}),
|
|
48
|
+
[open, setOpen, closeOnBackdropPress, closeOnEscKey, nativeID, role],
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<DialogProvider value={contextValue}>
|
|
53
|
+
<BaseRoot
|
|
54
|
+
ref={ref}
|
|
55
|
+
{...(props as T)}
|
|
56
|
+
{...dataAttributes({
|
|
57
|
+
slot: 'dialog',
|
|
58
|
+
state: open ? 'open' : 'closed',
|
|
59
|
+
})}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</BaseRoot>
|
|
63
|
+
</DialogProvider>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogTitleProps } from './types';
|
|
3
|
+
|
|
4
|
+
export const createDialogTitle = <T,>(BaseTitle: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, IDialogTitleProps>(({ children, ...props }, ref) => {
|
|
6
|
+
return (
|
|
7
|
+
<BaseTitle ref={ref} {...(props as T)}>
|
|
8
|
+
{children}
|
|
9
|
+
</BaseTitle>
|
|
10
|
+
);
|
|
11
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IDialogTriggerProps } from './types';
|
|
3
|
+
import { useDialog } from './context';
|
|
4
|
+
|
|
5
|
+
export const createDialogTrigger = <T,>(BaseTrigger: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef(
|
|
7
|
+
({ asChild = false, children, onPress, ...props }: IDialogTriggerProps, ref?: React.Ref<T>) => {
|
|
8
|
+
const { onOpenChange } = useDialog();
|
|
9
|
+
|
|
10
|
+
const handlePress = (e?: any) => {
|
|
11
|
+
onPress?.(e);
|
|
12
|
+
onOpenChange(true);
|
|
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
|
+
<BaseTrigger ref={ref} {...(props as T)} onPress={handlePress}>
|
|
23
|
+
{children}
|
|
24
|
+
</BaseTrigger>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createDialogRoot } from './createDialogRoot';
|
|
3
|
+
import { createDialogTrigger } from './createDialogTrigger';
|
|
4
|
+
import { createDialogContent } from './createDialogContent';
|
|
5
|
+
import { createDialogHeader } from './createDialogHeader';
|
|
6
|
+
import { createDialogTitle } from './createDialogTitle';
|
|
7
|
+
import { createDialogDescription } from './createDialogDescription';
|
|
8
|
+
import { createDialogBody } from './createDialogBody';
|
|
9
|
+
import { createDialogFooter } from './createDialogFooter';
|
|
10
|
+
import { createDialogClose } from './createDialogClose';
|
|
11
|
+
import { DialogProvider, useDialog } from './context';
|
|
12
|
+
import type { IDialogComponentType } from './types';
|
|
13
|
+
|
|
14
|
+
export { DialogProvider, useDialog };
|
|
15
|
+
export type {
|
|
16
|
+
IDialogContextType,
|
|
17
|
+
IDialogRootProps,
|
|
18
|
+
IDialogTriggerProps,
|
|
19
|
+
IDialogContentProps,
|
|
20
|
+
IDialogOverlayProps,
|
|
21
|
+
IDialogHeaderProps,
|
|
22
|
+
IDialogTitleProps,
|
|
23
|
+
IDialogDescriptionProps,
|
|
24
|
+
IDialogBodyProps,
|
|
25
|
+
IDialogFooterProps,
|
|
26
|
+
IDialogCloseProps,
|
|
27
|
+
} from './types';
|
|
28
|
+
|
|
29
|
+
export function createDialog<
|
|
30
|
+
RootProps,
|
|
31
|
+
TriggerProps,
|
|
32
|
+
ContentProps,
|
|
33
|
+
OverlayProps,
|
|
34
|
+
HeaderProps,
|
|
35
|
+
TitleProps,
|
|
36
|
+
DescriptionProps,
|
|
37
|
+
BodyProps,
|
|
38
|
+
FooterProps,
|
|
39
|
+
CloseProps,
|
|
40
|
+
>(BaseComponents: {
|
|
41
|
+
Root: React.ComponentType<RootProps>;
|
|
42
|
+
Trigger: React.ComponentType<TriggerProps>;
|
|
43
|
+
Content: React.ComponentType<ContentProps>;
|
|
44
|
+
Overlay: React.ComponentType<OverlayProps>;
|
|
45
|
+
Header: React.ComponentType<HeaderProps>;
|
|
46
|
+
Title: React.ComponentType<TitleProps>;
|
|
47
|
+
Description: React.ComponentType<DescriptionProps>;
|
|
48
|
+
Body: React.ComponentType<BodyProps>;
|
|
49
|
+
Footer: React.ComponentType<FooterProps>;
|
|
50
|
+
Close: React.ComponentType<CloseProps>;
|
|
51
|
+
}) {
|
|
52
|
+
const Root = createDialogRoot(BaseComponents.Root);
|
|
53
|
+
const Trigger = createDialogTrigger(BaseComponents.Trigger);
|
|
54
|
+
const Content = createDialogContent(BaseComponents.Content, BaseComponents.Overlay);
|
|
55
|
+
const Header = createDialogHeader(BaseComponents.Header);
|
|
56
|
+
const Title = createDialogTitle(BaseComponents.Title);
|
|
57
|
+
const Description = createDialogDescription(BaseComponents.Description);
|
|
58
|
+
const Body = createDialogBody(BaseComponents.Body);
|
|
59
|
+
const Footer = createDialogFooter(BaseComponents.Footer);
|
|
60
|
+
const Close = createDialogClose(BaseComponents.Close);
|
|
61
|
+
|
|
62
|
+
Root.displayName = 'DialogPrimitive.Root';
|
|
63
|
+
Trigger.displayName = 'DialogPrimitive.Trigger';
|
|
64
|
+
Content.displayName = 'DialogPrimitive.Content';
|
|
65
|
+
Header.displayName = 'DialogPrimitive.Header';
|
|
66
|
+
Title.displayName = 'DialogPrimitive.Title';
|
|
67
|
+
Description.displayName = 'DialogPrimitive.Description';
|
|
68
|
+
Body.displayName = 'DialogPrimitive.Body';
|
|
69
|
+
Footer.displayName = 'DialogPrimitive.Footer';
|
|
70
|
+
Close.displayName = 'DialogPrimitive.Close';
|
|
71
|
+
|
|
72
|
+
return Object.assign(Root, {
|
|
73
|
+
Root,
|
|
74
|
+
Trigger,
|
|
75
|
+
Content,
|
|
76
|
+
Header,
|
|
77
|
+
Title,
|
|
78
|
+
Description,
|
|
79
|
+
Body,
|
|
80
|
+
Footer,
|
|
81
|
+
Close,
|
|
82
|
+
}) as IDialogComponentType<
|
|
83
|
+
RootProps,
|
|
84
|
+
TriggerProps,
|
|
85
|
+
ContentProps,
|
|
86
|
+
HeaderProps,
|
|
87
|
+
TitleProps,
|
|
88
|
+
DescriptionProps,
|
|
89
|
+
BodyProps,
|
|
90
|
+
FooterProps,
|
|
91
|
+
CloseProps
|
|
92
|
+
>;
|
|
93
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PropsWithoutRef, RefAttributes } from 'react';
|
|
2
|
+
import type { PressableProps, TextProps, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface IDialogContextType {
|
|
5
|
+
readonly open: boolean;
|
|
6
|
+
readonly onOpenChange: (open: boolean) => void;
|
|
7
|
+
readonly closeOnBackdropPress: boolean;
|
|
8
|
+
readonly closeOnEscKey: boolean;
|
|
9
|
+
readonly nativeID: string;
|
|
10
|
+
readonly role: 'dialog' | 'alertdialog';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IDialogRootProps {
|
|
14
|
+
readonly open?: boolean;
|
|
15
|
+
readonly onOpenChange?: (open: boolean) => void;
|
|
16
|
+
readonly defaultOpen?: boolean;
|
|
17
|
+
readonly closeOnBackdropPress?: boolean;
|
|
18
|
+
readonly closeOnEscKey?: boolean;
|
|
19
|
+
readonly role?: 'dialog' | 'alertdialog';
|
|
20
|
+
readonly children: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IDialogTriggerProps extends PressableProps {
|
|
24
|
+
readonly asChild?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IDialogContentProps extends ViewProps {
|
|
28
|
+
readonly forceMount?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface IDialogOverlayProps extends PressableProps {}
|
|
32
|
+
|
|
33
|
+
export interface IDialogHeaderProps extends ViewProps {}
|
|
34
|
+
|
|
35
|
+
export interface IDialogTitleProps extends TextProps {}
|
|
36
|
+
|
|
37
|
+
export interface IDialogDescriptionProps extends TextProps {}
|
|
38
|
+
|
|
39
|
+
export interface IDialogBodyProps extends ViewProps {}
|
|
40
|
+
|
|
41
|
+
export interface IDialogFooterProps extends ViewProps {}
|
|
42
|
+
|
|
43
|
+
export interface IDialogCloseProps extends PressableProps {
|
|
44
|
+
readonly asChild?: boolean;
|
|
45
|
+
readonly accessibilityLabel?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type IDialogComponentType<
|
|
49
|
+
RootProps,
|
|
50
|
+
TriggerProps,
|
|
51
|
+
ContentProps,
|
|
52
|
+
HeaderProps,
|
|
53
|
+
TitleProps,
|
|
54
|
+
DescriptionProps,
|
|
55
|
+
BodyProps,
|
|
56
|
+
FooterProps,
|
|
57
|
+
CloseProps,
|
|
58
|
+
ContentRef = unknown,
|
|
59
|
+
TriggerRef = unknown,
|
|
60
|
+
CloseRef = unknown,
|
|
61
|
+
> = React.ForwardRefExoticComponent<
|
|
62
|
+
PropsWithoutRef<RootProps & IDialogRootProps> & RefAttributes<unknown>
|
|
63
|
+
> & {
|
|
64
|
+
Trigger: React.ForwardRefExoticComponent<
|
|
65
|
+
PropsWithoutRef<TriggerProps & IDialogTriggerProps> & RefAttributes<TriggerRef>
|
|
66
|
+
>;
|
|
67
|
+
Content: React.ForwardRefExoticComponent<
|
|
68
|
+
PropsWithoutRef<ContentProps & IDialogContentProps> & RefAttributes<ContentRef>
|
|
69
|
+
>;
|
|
70
|
+
Header: React.ForwardRefExoticComponent<
|
|
71
|
+
PropsWithoutRef<HeaderProps & IDialogHeaderProps> & RefAttributes<unknown>
|
|
72
|
+
>;
|
|
73
|
+
Title: React.ForwardRefExoticComponent<
|
|
74
|
+
PropsWithoutRef<TitleProps & IDialogTitleProps> & RefAttributes<unknown>
|
|
75
|
+
>;
|
|
76
|
+
Description: React.ForwardRefExoticComponent<
|
|
77
|
+
PropsWithoutRef<DescriptionProps & IDialogDescriptionProps> & RefAttributes<unknown>
|
|
78
|
+
>;
|
|
79
|
+
Body: React.ForwardRefExoticComponent<
|
|
80
|
+
PropsWithoutRef<BodyProps & IDialogBodyProps> & RefAttributes<unknown>
|
|
81
|
+
>;
|
|
82
|
+
Footer: React.ForwardRefExoticComponent<
|
|
83
|
+
PropsWithoutRef<FooterProps & IDialogFooterProps> & RefAttributes<unknown>
|
|
84
|
+
>;
|
|
85
|
+
Close: React.ForwardRefExoticComponent<
|
|
86
|
+
PropsWithoutRef<CloseProps & IDialogCloseProps> & RefAttributes<CloseRef>
|
|
87
|
+
>;
|
|
88
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
|
|
4
|
+
export const createFormError = <T,>(BaseFormError: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => {
|
|
6
|
+
const { isInvalid, feedbackId, setHasFeedbackText } = useFormControlContext();
|
|
7
|
+
|
|
8
|
+
const visible = Boolean(isInvalid && children);
|
|
9
|
+
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (!visible) {
|
|
12
|
+
setHasFeedbackText?.(false);
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
setHasFeedbackText?.(true);
|
|
16
|
+
return () => {
|
|
17
|
+
setHasFeedbackText?.(false);
|
|
18
|
+
};
|
|
19
|
+
}, [setHasFeedbackText, visible]);
|
|
20
|
+
|
|
21
|
+
return visible ? (
|
|
22
|
+
<BaseFormError
|
|
23
|
+
ref={ref}
|
|
24
|
+
{...(props as T)}
|
|
25
|
+
id={feedbackId}
|
|
26
|
+
accessibilityRole="alert"
|
|
27
|
+
accessibilityLiveRegion="assertive"
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</BaseFormError>
|
|
31
|
+
) : null;
|
|
32
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
export const createFormErrorIcon = <T,>(BaseFormErrorIcon: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
|
|
6
|
+
<BaseFormErrorIcon ref={ref} {...(props as T)}>
|
|
7
|
+
{children}
|
|
8
|
+
</BaseFormErrorIcon>
|
|
9
|
+
));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
export const createFormErrorText = <T,>(BaseFormErrorText: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
|
|
6
|
+
<BaseFormErrorText ref={ref} {...(props as T)}>
|
|
7
|
+
{children}
|
|
8
|
+
</BaseFormErrorText>
|
|
9
|
+
));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlRoot, FormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
4
|
+
import type { IFormFieldProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createFormField = <T,>(BaseFormField: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef(
|
|
8
|
+
({ children, ...props }: IFormFieldProps & { children?: React.ReactNode }, ref?: unknown) => {
|
|
9
|
+
const { htmlProps, ...context } = useFormControlRoot(props);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<FormControlContext.Provider value={context}>
|
|
13
|
+
<BaseFormField
|
|
14
|
+
ref={ref}
|
|
15
|
+
{...(htmlProps as T)}
|
|
16
|
+
{...dataAttributes({
|
|
17
|
+
disabled: context.isDisabled,
|
|
18
|
+
invalid: context.isInvalid,
|
|
19
|
+
required: context.isRequired,
|
|
20
|
+
})}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</BaseFormField>
|
|
24
|
+
</FormControlContext.Provider>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
|
|
4
|
+
export const createFormHelper = <T,>(BaseFormHelper: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => {
|
|
6
|
+
const { helpTextId, setHasHelpText, isInvalid } = useFormControlContext();
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
if (isInvalid) {
|
|
10
|
+
setHasHelpText?.(false);
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
setHasHelpText?.(true);
|
|
14
|
+
return () => {
|
|
15
|
+
setHasHelpText?.(false);
|
|
16
|
+
};
|
|
17
|
+
}, [setHasHelpText, isInvalid]);
|
|
18
|
+
|
|
19
|
+
if (isInvalid) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<BaseFormHelper ref={ref} {...(props as T)} id={helpTextId}>
|
|
25
|
+
{children}
|
|
26
|
+
</BaseFormHelper>
|
|
27
|
+
);
|
|
28
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
export const createFormHelperText = <T,>(BaseFormHelperText: React.ComponentType<T>) =>
|
|
5
|
+
forwardRef<unknown, { children?: React.ReactNode }>(({ children, ...props }, ref) => (
|
|
6
|
+
<BaseFormHelperText ref={ref} {...(props as T)}>
|
|
7
|
+
{children}
|
|
8
|
+
</BaseFormHelperText>
|
|
9
|
+
));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { useFormControlContext } from '@cdx-ui/utils';
|
|
4
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
+
import type { IFormLabelProps } from './types';
|
|
6
|
+
|
|
7
|
+
export const createFormLabel = <T,>({ Label: BaseFormLabel }: { Label: React.ComponentType<T> }) =>
|
|
8
|
+
forwardRef<unknown, IFormLabelProps & { children?: React.ReactNode }>(
|
|
9
|
+
({ children, htmlFor: htmlForProp, requiredIndicator, ...props }, ref) => {
|
|
10
|
+
const field = useFormControlContext();
|
|
11
|
+
const fieldId = field.id;
|
|
12
|
+
const labelId = field.labelId;
|
|
13
|
+
|
|
14
|
+
/** Must match `useFormControl` default: `props.id ?? \`${field.id}-input\``. */
|
|
15
|
+
const htmlFor = htmlForProp ?? (fieldId ? `${fieldId}-input` : undefined);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<BaseFormLabel
|
|
19
|
+
ref={ref}
|
|
20
|
+
{...(props as T)}
|
|
21
|
+
id={labelId}
|
|
22
|
+
htmlFor={htmlFor}
|
|
23
|
+
{...dataAttributes({ invalid: field.isInvalid, required: field.isRequired })}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
{field.isRequired ? requiredIndicator : null}
|
|
27
|
+
</BaseFormLabel>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IFormProps } from './types';
|
|
3
|
+
|
|
4
|
+
// TODO: Handle web submission (button type submit)
|
|
5
|
+
|
|
6
|
+
export const createFormRoot = <T,>(BaseFormRoot: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef(
|
|
8
|
+
({ children, ...props }: IFormProps & { children?: React.ReactNode }, ref?: unknown) => (
|
|
9
|
+
<BaseFormRoot ref={ref} {...(props as T)}>
|
|
10
|
+
{children}
|
|
11
|
+
</BaseFormRoot>
|
|
12
|
+
),
|
|
13
|
+
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createFormError } from './createFormError';
|
|
3
|
+
import { createFormErrorText } from './createFormErrorText';
|
|
4
|
+
import { createFormErrorIcon } from './createFormErrorIcon';
|
|
5
|
+
import { createFormField } from './createFormField';
|
|
6
|
+
import { createFormHelper } from './createFormHelper';
|
|
7
|
+
import { createFormHelperText } from './createFormHelperText';
|
|
8
|
+
import { createFormLabel } from './createFormLabel';
|
|
9
|
+
import { createFormRoot } from './createFormRoot';
|
|
10
|
+
import type { IFormComponentType } from './types';
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
IFormProps,
|
|
14
|
+
IFormFieldProps,
|
|
15
|
+
IFormLabelProps,
|
|
16
|
+
IFormHelperProps,
|
|
17
|
+
IFormHelperTextProps,
|
|
18
|
+
IFormErrorProps,
|
|
19
|
+
IFormErrorTextProps,
|
|
20
|
+
IFormErrorIconProps,
|
|
21
|
+
IFormComponentType,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
export function createForm<Root, Field, Error, ErrorText, ErrorIcon, Label, Helper, HelperText>({
|
|
25
|
+
Root,
|
|
26
|
+
Field,
|
|
27
|
+
Error,
|
|
28
|
+
ErrorText,
|
|
29
|
+
ErrorIcon,
|
|
30
|
+
Label,
|
|
31
|
+
Helper,
|
|
32
|
+
HelperText,
|
|
33
|
+
}: {
|
|
34
|
+
Root: React.ComponentType<Root>;
|
|
35
|
+
Field: React.ComponentType<Field>;
|
|
36
|
+
Error: React.ComponentType<Error>;
|
|
37
|
+
ErrorText: React.ComponentType<ErrorText>;
|
|
38
|
+
ErrorIcon: React.ComponentType<ErrorIcon>;
|
|
39
|
+
Label: React.ComponentType<Label>;
|
|
40
|
+
Helper: React.ComponentType<Helper>;
|
|
41
|
+
HelperText: React.ComponentType<HelperText>;
|
|
42
|
+
}) {
|
|
43
|
+
const FormRoot = createFormRoot(Root);
|
|
44
|
+
FormRoot.displayName = 'FormPrimitive';
|
|
45
|
+
|
|
46
|
+
const FormField = createFormField(Field);
|
|
47
|
+
FormField.displayName = 'FormPrimitive.Field';
|
|
48
|
+
const FormLabel = createFormLabel({ Label });
|
|
49
|
+
const FormHelper = createFormHelper(Helper);
|
|
50
|
+
const FormHelperText = createFormHelperText(HelperText);
|
|
51
|
+
const FormError = createFormError(Error);
|
|
52
|
+
const FormErrorText = createFormErrorText(ErrorText);
|
|
53
|
+
const FormErrorIcon = createFormErrorIcon(ErrorIcon);
|
|
54
|
+
|
|
55
|
+
FormLabel.displayName = 'FormPrimitive.Label';
|
|
56
|
+
FormHelper.displayName = 'FormPrimitive.Helper';
|
|
57
|
+
FormHelperText.displayName = 'FormPrimitive.HelperText';
|
|
58
|
+
FormError.displayName = 'FormPrimitive.Error';
|
|
59
|
+
FormErrorText.displayName = 'FormPrimitive.ErrorText';
|
|
60
|
+
FormErrorIcon.displayName = 'FormPrimitive.ErrorIcon';
|
|
61
|
+
|
|
62
|
+
return Object.assign(FormRoot, {
|
|
63
|
+
Field: FormField,
|
|
64
|
+
Label: FormLabel,
|
|
65
|
+
Helper: FormHelper,
|
|
66
|
+
HelperText: FormHelperText,
|
|
67
|
+
Error: FormError,
|
|
68
|
+
ErrorText: FormErrorText,
|
|
69
|
+
ErrorIcon: FormErrorIcon,
|
|
70
|
+
}) as IFormComponentType<Root, Field, Error, ErrorText, ErrorIcon, Label, Helper, HelperText>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { TextProps, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for the Form container (`<form>` on web, `<View>` on RN).
|
|
6
|
+
* Does NOT provide field-level context — use `Form.Field` for that.
|
|
7
|
+
*
|
|
8
|
+
* Web-only submit props (`onSubmit`, `action`, `method`) belong in the
|
|
9
|
+
* platform-specific base component (`FormRoot.web.tsx`), not here.
|
|
10
|
+
*/
|
|
11
|
+
export interface IFormProps {}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props for a single form field (`Form.Field`).
|
|
15
|
+
* Provides field-level context (name, validation state, ids) to children.
|
|
16
|
+
*
|
|
17
|
+
* **Initial focus:** use `autoFocus` on `Input.Field` (or your control). `TextInput` / DOM
|
|
18
|
+
* inputs support it natively. Do not rely on `Form.Field` for autofocus — it does not forward
|
|
19
|
+
* to a single child.
|
|
20
|
+
*
|
|
21
|
+
* **Submit UX:** "focus first invalid on error" needs form-level validation state; not built in yet.
|
|
22
|
+
*/
|
|
23
|
+
export interface IFormFieldProps extends ViewProps {
|
|
24
|
+
/** Unique id for this field. Auto-generated if not provided. */
|
|
25
|
+
readonly id?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Field name for form submission. Passed through context so child inputs
|
|
28
|
+
* automatically receive it as their `name` attribute for `FormData` support.
|
|
29
|
+
*/
|
|
30
|
+
readonly name?: string;
|
|
31
|
+
/** If true, the field is marked as invalid. Controls error visibility. */
|
|
32
|
+
readonly isInvalid?: boolean;
|
|
33
|
+
/** If true, the field is marked as required. Shows asterisk on label. */
|
|
34
|
+
readonly isRequired?: boolean;
|
|
35
|
+
/** If true, the field is disabled. */
|
|
36
|
+
readonly isDisabled?: boolean;
|
|
37
|
+
/** If true, the field is read-only. */
|
|
38
|
+
readonly isReadOnly?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IFormLabelProps extends TextProps {
|
|
42
|
+
/**
|
|
43
|
+
* Associates the label with a control `id` on web (`<label htmlFor>`).
|
|
44
|
+
* If omitted, defaults to the same id `Input.Field` gets from form context: `fieldId + "-input"`.
|
|
45
|
+
*/
|
|
46
|
+
readonly htmlFor?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Element to render after the label text when the field is required.
|
|
49
|
+
* Rendered by the primitive (which owns the form-control context) so the
|
|
50
|
+
* styled layer never needs to read `FormControlContext` across packages.
|
|
51
|
+
*/
|
|
52
|
+
readonly requiredIndicator?: React.ReactNode;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IFormHelperProps extends ViewProps {}
|
|
56
|
+
|
|
57
|
+
export interface IFormHelperTextProps extends TextProps {}
|
|
58
|
+
|
|
59
|
+
export interface IFormErrorProps extends ViewProps {}
|
|
60
|
+
|
|
61
|
+
export interface IFormErrorTextProps extends TextProps {}
|
|
62
|
+
|
|
63
|
+
export interface IFormErrorIconProps extends ViewProps {}
|
|
64
|
+
|
|
65
|
+
export type IFormComponentType<
|
|
66
|
+
Root,
|
|
67
|
+
Field,
|
|
68
|
+
Error,
|
|
69
|
+
ErrorText,
|
|
70
|
+
ErrorIcon,
|
|
71
|
+
Label,
|
|
72
|
+
Helper,
|
|
73
|
+
HelperText,
|
|
74
|
+
> = React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFormProps> & {
|
|
75
|
+
Field: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Field> & IFormFieldProps>;
|
|
76
|
+
Label: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Label> & IFormLabelProps>;
|
|
77
|
+
Helper: React.ForwardRefExoticComponent<
|
|
78
|
+
InnerForwardRefExoticComponent<Helper> & IFormHelperProps
|
|
79
|
+
>;
|
|
80
|
+
HelperText: React.ForwardRefExoticComponent<
|
|
81
|
+
InnerForwardRefExoticComponent<HelperText> & IFormHelperTextProps
|
|
82
|
+
>;
|
|
83
|
+
Error: React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Error> & IFormErrorProps>;
|
|
84
|
+
ErrorText: React.ForwardRefExoticComponent<
|
|
85
|
+
InnerForwardRefExoticComponent<ErrorText> & IFormErrorTextProps
|
|
86
|
+
>;
|
|
87
|
+
ErrorIcon: React.ForwardRefExoticComponent<
|
|
88
|
+
InnerForwardRefExoticComponent<ErrorIcon> & IFormErrorIconProps
|
|
89
|
+
>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
export * from './avatar';
|
|
1
2
|
export * from './button';
|
|
3
|
+
export * from './checkbox';
|
|
4
|
+
export * from './dialog';
|
|
5
|
+
export * from './form-control';
|
|
2
6
|
export * from './input';
|
|
7
|
+
export * from './link';
|
|
8
|
+
export { type EdgeInsets, OverlayInsetsProvider } from './overlay';
|
|
3
9
|
export * from './select';
|
|
4
|
-
export
|
|
10
|
+
export * from './switch';
|
|
11
|
+
export type { InteractionState } from './types';
|
|
12
|
+
export { dataAttributes } from './utils/dataAttributes';
|