@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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Platform,
|
|
7
7
|
type TextInputKeyPressEvent,
|
|
8
8
|
} from 'react-native';
|
|
9
|
-
import { mergeRefs, useFormControl } from '@cdx-ui/utils';
|
|
9
|
+
import { mergeRefs, useFormControl, useFormControlContext } from '@cdx-ui/utils';
|
|
10
10
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
11
11
|
import { useInputContext } from './context';
|
|
12
12
|
import type { IInputProps } from './types';
|
|
@@ -18,7 +18,8 @@ export const createInputField = <T,>(BaseInputField: React.ComponentType<T>) =>
|
|
|
18
18
|
children,
|
|
19
19
|
onKeyPress,
|
|
20
20
|
type = 'text',
|
|
21
|
-
|
|
21
|
+
accessibilityLabel,
|
|
22
|
+
'aria-label': ariaLabelProp,
|
|
22
23
|
secureTextEntry,
|
|
23
24
|
editable,
|
|
24
25
|
disabled,
|
|
@@ -46,15 +47,22 @@ export const createInputField = <T,>(BaseInputField: React.ComponentType<T>) =>
|
|
|
46
47
|
id: props.id,
|
|
47
48
|
});
|
|
48
49
|
|
|
50
|
+
const field = useFormControlContext();
|
|
51
|
+
|
|
49
52
|
const handleFocus = (focusState: boolean, callback: any) => {
|
|
50
53
|
setIsFocused(focusState);
|
|
51
54
|
callback();
|
|
52
55
|
};
|
|
53
56
|
|
|
54
|
-
const mergedRef =
|
|
57
|
+
const mergedRef =
|
|
58
|
+
Platform.OS === 'web'
|
|
59
|
+
? mergeRefs(ref, inputFieldRef)
|
|
60
|
+
: mergeRefs(ref, inputFieldRef, field.inputRef);
|
|
55
61
|
|
|
56
62
|
const isEffectivelyDisabled = isDisabled || inputProps.disabled;
|
|
57
63
|
|
|
64
|
+
const ariaLabel = accessibilityLabel ?? ariaLabelProp;
|
|
65
|
+
|
|
58
66
|
const editableProp = useMemo(() => {
|
|
59
67
|
if (editable !== undefined) {
|
|
60
68
|
return editable;
|
|
@@ -64,6 +72,7 @@ export const createInputField = <T,>(BaseInputField: React.ComponentType<T>) =>
|
|
|
64
72
|
|
|
65
73
|
return (
|
|
66
74
|
<BaseInputField
|
|
75
|
+
{...inputProps}
|
|
67
76
|
{...(props as T)}
|
|
68
77
|
type={type}
|
|
69
78
|
{...dataAttributes({
|
|
@@ -78,6 +87,7 @@ export const createInputField = <T,>(BaseInputField: React.ComponentType<T>) =>
|
|
|
78
87
|
disabled={isEffectivelyDisabled}
|
|
79
88
|
secureTextEntry={secureTextEntry || type === 'password'}
|
|
80
89
|
accessible
|
|
90
|
+
accessibilityLabel={ariaLabel}
|
|
81
91
|
aria-label={ariaLabel}
|
|
82
92
|
aria-required={isRequired || inputProps.required}
|
|
83
93
|
aria-invalid={isInvalid || inputProps['aria-invalid']}
|
package/src/input/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import { createInputField } from './createInputField';
|
|
2
|
-
import { createInputIcon } from './createInputIcon';
|
|
3
3
|
import { createInputRoot } from './createInputRoot';
|
|
4
4
|
import { createInputSlot } from './createInputSlot';
|
|
5
5
|
import type { IInputComponentType } from './types';
|
|
@@ -12,40 +12,27 @@ export type {
|
|
|
12
12
|
IInputSlotProps,
|
|
13
13
|
} from './types';
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export function createInput<
|
|
16
16
|
RootProps,
|
|
17
|
-
IconProps,
|
|
18
17
|
SlotProps,
|
|
19
18
|
FieldProps,
|
|
20
19
|
RootRef = unknown,
|
|
21
20
|
FieldRef = unknown,
|
|
22
|
-
>({
|
|
23
|
-
Root,
|
|
24
|
-
Icon,
|
|
25
|
-
Slot,
|
|
26
|
-
Field,
|
|
27
|
-
}: {
|
|
21
|
+
>(BaseComponents: {
|
|
28
22
|
Root: React.ComponentType<RootProps>;
|
|
29
|
-
Icon: React.ComponentType<IconProps>;
|
|
30
23
|
Slot: React.ComponentType<SlotProps>;
|
|
31
24
|
Field: React.ComponentType<FieldProps>;
|
|
32
|
-
})
|
|
33
|
-
const Input = createInputRoot(Root)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Input.Field = createInputField(Field);
|
|
25
|
+
}) {
|
|
26
|
+
const Input = createInputRoot(BaseComponents.Root);
|
|
27
|
+
const Slot = createInputSlot(BaseComponents.Slot);
|
|
28
|
+
const Field = createInputField(BaseComponents.Field);
|
|
37
29
|
|
|
38
|
-
Input.displayName = '
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Input.Field.displayName = 'Input.Field';
|
|
30
|
+
Input.displayName = 'InputPrimitive';
|
|
31
|
+
Slot.displayName = 'InputPrimitive.Slot';
|
|
32
|
+
Field.displayName = 'InputPrimitive.Field';
|
|
42
33
|
|
|
43
|
-
return Input
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
RootRef,
|
|
49
|
-
FieldRef
|
|
50
|
-
>;
|
|
51
|
-
};
|
|
34
|
+
return Object.assign(Input, {
|
|
35
|
+
Slot,
|
|
36
|
+
Field,
|
|
37
|
+
}) as IInputComponentType<RootProps, SlotProps, FieldProps, RootRef, FieldRef>;
|
|
38
|
+
}
|
package/src/input/types.ts
CHANGED
|
@@ -93,7 +93,6 @@ export interface IInputSlotProps extends ViewProps {
|
|
|
93
93
|
|
|
94
94
|
export type IInputComponentType<
|
|
95
95
|
RootProps,
|
|
96
|
-
IconProps,
|
|
97
96
|
SlotProps,
|
|
98
97
|
FieldProps,
|
|
99
98
|
RootRef = unknown,
|
|
@@ -101,9 +100,6 @@ export type IInputComponentType<
|
|
|
101
100
|
> = React.ForwardRefExoticComponent<
|
|
102
101
|
React.PropsWithoutRef<RootProps & IInputFieldProps> & React.RefAttributes<RootRef>
|
|
103
102
|
> & {
|
|
104
|
-
Icon: React.ForwardRefExoticComponent<
|
|
105
|
-
React.PropsWithoutRef<IconProps> & React.RefAttributes<unknown>
|
|
106
|
-
>;
|
|
107
103
|
Slot: React.ForwardRefExoticComponent<
|
|
108
104
|
React.PropsWithoutRef<SlotProps & IInputSlotProps> & React.RefAttributes<unknown>
|
|
109
105
|
>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
+
import type { LinkAction } from './types';
|
|
3
|
+
|
|
4
|
+
export interface LinkConfig {
|
|
5
|
+
/**
|
|
6
|
+
* Global navigation handler for `<Link>` instances whose `href` passes the
|
|
7
|
+
* `shouldNavigate` check. Called with the `href` and the per-instance `action`.
|
|
8
|
+
*
|
|
9
|
+
* @param href - The URL or path to navigate to.
|
|
10
|
+
* @param action - Navigation intent from the per-instance `action` prop:
|
|
11
|
+
* `'navigate'` (default) — smart navigation, avoids duplicates.
|
|
12
|
+
* `'push'` — always pushes a new entry onto the stack.
|
|
13
|
+
* `'replace'` — replaces the current entry without stacking.
|
|
14
|
+
*/
|
|
15
|
+
navigate: (href: string, action: LinkAction) => void | Promise<void>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Optional predicate evaluated at **render time** to decide whether the
|
|
19
|
+
* provider should handle a given `href`.
|
|
20
|
+
*
|
|
21
|
+
* - Returns `true` → the provider's `navigate` is called on press;
|
|
22
|
+
* on web the native `<a href>` is **removed** so the browser doesn't
|
|
23
|
+
* follow the link.
|
|
24
|
+
* - Returns `false` → the provider is bypassed; on web the `<a href>` is
|
|
25
|
+
* preserved (cmd-click, SEO, etc.); on native `Linking.openURL` is used.
|
|
26
|
+
*
|
|
27
|
+
* Defaults to `() => true` when omitted (all hrefs go through the provider).
|
|
28
|
+
*/
|
|
29
|
+
shouldNavigate?: (href: string) => boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const LinkConfigContext = createContext<LinkConfig | undefined>(undefined);
|
|
33
|
+
|
|
34
|
+
export function LinkProvider({
|
|
35
|
+
navigate,
|
|
36
|
+
shouldNavigate,
|
|
37
|
+
children,
|
|
38
|
+
}: LinkConfig & { children: ReactNode }) {
|
|
39
|
+
return (
|
|
40
|
+
<LinkConfigContext.Provider value={{ navigate, shouldNavigate }}>
|
|
41
|
+
{children}
|
|
42
|
+
</LinkConfigContext.Provider>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
LinkProvider.displayName = 'LinkProvider';
|
|
47
|
+
|
|
48
|
+
export function useLinkConfig(): LinkConfig | undefined {
|
|
49
|
+
return useContext(LinkConfigContext);
|
|
50
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
3
|
+
import { useFocusRing, useFocus } from '@react-native-aria/focus';
|
|
4
|
+
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
5
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { useLink } from './useLink';
|
|
7
|
+
import type { ILinkProps } from './types';
|
|
8
|
+
|
|
9
|
+
export const createLink = <RootT, R = unknown>({ Root }: { Root: React.ComponentType<RootT> }) =>
|
|
10
|
+
forwardRef(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
children,
|
|
14
|
+
isHovered: isHoveredProp,
|
|
15
|
+
isPressed: isPressedProp,
|
|
16
|
+
isFocused: isFocusedProp,
|
|
17
|
+
isFocusVisible: isFocusVisibleProp,
|
|
18
|
+
href,
|
|
19
|
+
onPress,
|
|
20
|
+
action,
|
|
21
|
+
webProps,
|
|
22
|
+
...props
|
|
23
|
+
}: ILinkProps,
|
|
24
|
+
ref: React.ForwardedRef<R>,
|
|
25
|
+
) => {
|
|
26
|
+
const { isFocused, focusProps } = useFocus();
|
|
27
|
+
const { isFocusVisible, focusProps: focusRingProps } = useFocusRing() as {
|
|
28
|
+
isFocusVisible: boolean;
|
|
29
|
+
focusProps: typeof focusProps;
|
|
30
|
+
};
|
|
31
|
+
const { pressProps, isPressed } = usePress({});
|
|
32
|
+
const { isHovered, hoverProps } = useHover();
|
|
33
|
+
|
|
34
|
+
const { linkProps } = useLink({
|
|
35
|
+
href,
|
|
36
|
+
onPress,
|
|
37
|
+
action,
|
|
38
|
+
webProps,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const interactionAttrs = dataAttributes({
|
|
42
|
+
hover: isHoveredProp || isHovered,
|
|
43
|
+
focus: isFocusedProp || isFocused,
|
|
44
|
+
active: isPressedProp || isPressed,
|
|
45
|
+
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Root
|
|
50
|
+
ref={ref}
|
|
51
|
+
{...interactionAttrs}
|
|
52
|
+
{...linkProps}
|
|
53
|
+
{...(props as RootT)}
|
|
54
|
+
onPressIn={composeEventHandlers(props?.onPressIn, pressProps.onPressIn)}
|
|
55
|
+
onPressOut={composeEventHandlers(props?.onPressOut, pressProps.onPressOut)}
|
|
56
|
+
onHoverIn={composeEventHandlers(props?.onHoverIn, hoverProps.onHoverIn)}
|
|
57
|
+
onHoverOut={composeEventHandlers(props?.onHoverOut, hoverProps.onHoverOut)}
|
|
58
|
+
onFocus={composeEventHandlers(
|
|
59
|
+
composeEventHandlers(props?.onFocus, focusProps.onFocus),
|
|
60
|
+
focusRingProps.onFocus,
|
|
61
|
+
)}
|
|
62
|
+
onBlur={composeEventHandlers(
|
|
63
|
+
composeEventHandlers(props?.onBlur, focusProps.onBlur),
|
|
64
|
+
focusRingProps.onBlur,
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</Root>
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { GestureResponderEvent, PressableProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Navigation action forwarded to the `LinkProvider.navigate` callback.
|
|
6
|
+
*
|
|
7
|
+
* - `'navigate'` — (default) Smart navigation. In React Navigation this
|
|
8
|
+
* avoids duplicating a screen that is already in the stack. In expo-router
|
|
9
|
+
* it maps to `router.navigate()`.
|
|
10
|
+
* - `'push'` — Always pushes a new screen onto the navigation stack,
|
|
11
|
+
* even if the destination is already present.
|
|
12
|
+
* - `'replace'` — Replaces the current screen without adding to the stack.
|
|
13
|
+
* Useful for post-login redirects or wizard flows.
|
|
14
|
+
*/
|
|
15
|
+
export type LinkAction = 'navigate' | 'push' | 'replace';
|
|
16
|
+
|
|
17
|
+
export interface ILinkProps extends PressableProps {
|
|
18
|
+
/**
|
|
19
|
+
* URL that should be opened on Link press
|
|
20
|
+
*/
|
|
21
|
+
href?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Callback that will be invoked on Link press
|
|
24
|
+
*/
|
|
25
|
+
onPress?: ((event?: GestureResponderEvent) => void) | null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Navigation action forwarded to the `LinkProvider`.
|
|
28
|
+
* Defaults to `'navigate'`.
|
|
29
|
+
*/
|
|
30
|
+
action?: LinkAction;
|
|
31
|
+
isPressed?: boolean;
|
|
32
|
+
isHovered?: boolean;
|
|
33
|
+
isFocused?: boolean;
|
|
34
|
+
isFocusVisible?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* HTML anchor attributes applied only on web. Ignored on native platforms.
|
|
37
|
+
* `target`, `rel`, and `download` are forwarded via react-native-web's `hrefAttrs`.
|
|
38
|
+
*/
|
|
39
|
+
webProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface IUseLinkProp {
|
|
43
|
+
href?: string;
|
|
44
|
+
onPress: ((event?: GestureResponderEvent) => void) | null | undefined;
|
|
45
|
+
action?: LinkAction;
|
|
46
|
+
webProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Linking, Platform } from 'react-native';
|
|
2
|
+
import type { AccessibilityRole, GestureResponderEvent } from 'react-native';
|
|
3
|
+
import { useLinkConfig } from './LinkProvider';
|
|
4
|
+
import type { IUseLinkProp } from './types';
|
|
5
|
+
|
|
6
|
+
function defaultNavigate(href: string): void {
|
|
7
|
+
Linking.canOpenURL(href)
|
|
8
|
+
.then((supported) => {
|
|
9
|
+
if (supported) return Linking.openURL(href);
|
|
10
|
+
console.warn(`Cannot open URL: ${href}`);
|
|
11
|
+
})
|
|
12
|
+
.catch((err: unknown) => console.error('Failed to open URL', err));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useLink(props: IUseLinkProp) {
|
|
16
|
+
const { href, onPress, action = 'navigate', webProps } = props;
|
|
17
|
+
const config = useLinkConfig();
|
|
18
|
+
|
|
19
|
+
const providerHandles = !!config && !!href && (config.shouldNavigate?.(href) ?? true);
|
|
20
|
+
|
|
21
|
+
let platformLinkProps = {};
|
|
22
|
+
|
|
23
|
+
if (Platform.OS === 'web') {
|
|
24
|
+
platformLinkProps = {
|
|
25
|
+
href: providerHandles ? undefined : href,
|
|
26
|
+
hrefAttrs: webProps,
|
|
27
|
+
onPress: (event: GestureResponderEvent) => {
|
|
28
|
+
onPress?.(event);
|
|
29
|
+
if (providerHandles) void config.navigate(href, action);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
} else {
|
|
33
|
+
platformLinkProps = {
|
|
34
|
+
onPress: (event: GestureResponderEvent) => {
|
|
35
|
+
onPress?.(event);
|
|
36
|
+
if (href) {
|
|
37
|
+
if (providerHandles) {
|
|
38
|
+
void config.navigate(href, action);
|
|
39
|
+
} else {
|
|
40
|
+
defaultNavigate(href);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
linkProps: {
|
|
49
|
+
...platformLinkProps,
|
|
50
|
+
role: 'link' as AccessibilityRole,
|
|
51
|
+
accessible: true,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -3,20 +3,13 @@ import {
|
|
|
3
3
|
Modal,
|
|
4
4
|
Platform,
|
|
5
5
|
Pressable,
|
|
6
|
-
type StyleProp,
|
|
7
6
|
StyleSheet,
|
|
7
|
+
View,
|
|
8
|
+
type StyleProp,
|
|
8
9
|
type ViewStyle,
|
|
9
10
|
} from 'react-native';
|
|
10
11
|
import Animated, { type EntryOrExitLayoutType } from 'react-native-reanimated';
|
|
11
|
-
|
|
12
|
-
let createPortalFn:
|
|
13
|
-
| ((children: React.ReactNode, container: Element) => React.ReactPortal)
|
|
14
|
-
| undefined;
|
|
15
|
-
if (Platform.OS === 'web') {
|
|
16
|
-
try {
|
|
17
|
-
createPortalFn = require('react-dom').createPortal;
|
|
18
|
-
} catch {}
|
|
19
|
-
}
|
|
12
|
+
import { createPortalFn } from '../utils/createPortal';
|
|
20
13
|
|
|
21
14
|
export interface OverlayContainerProps {
|
|
22
15
|
onDismiss: () => void;
|
|
@@ -30,7 +23,11 @@ export interface OverlayContainerProps {
|
|
|
30
23
|
* Cross-platform overlay container.
|
|
31
24
|
*
|
|
32
25
|
* - Web: renders children into a `createPortal` at `document.body` with
|
|
33
|
-
* `position: fixed` and `zIndex: 50`.
|
|
26
|
+
* `position: fixed` and `zIndex: 50`. Uses a plain `View` rather than
|
|
27
|
+
* Reanimated's `Animated.View` because Reanimated's layout animations
|
|
28
|
+
* (`entering`/`exiting`) rely on `require()` calls that break silently
|
|
29
|
+
* in Vite production bundles, leaving elements stuck at opacity 0.
|
|
30
|
+
* See: https://github.com/software-mansion/react-native-reanimated/issues/6775
|
|
34
31
|
* - Native: renders children inside a transparent `<Modal>` with a
|
|
35
32
|
* backdrop `<Pressable>` that calls `onDismiss` on press.
|
|
36
33
|
*
|
|
@@ -46,13 +43,7 @@ export function OverlayContainer({
|
|
|
46
43
|
}: Readonly<OverlayContainerProps>) {
|
|
47
44
|
if (Platform.OS === 'web' && createPortalFn) {
|
|
48
45
|
return createPortalFn(
|
|
49
|
-
<
|
|
50
|
-
entering={entering}
|
|
51
|
-
exiting={exiting}
|
|
52
|
-
style={[{ position: 'fixed' as any, zIndex: 50 }, style]}
|
|
53
|
-
>
|
|
54
|
-
{children}
|
|
55
|
-
</Animated.View>,
|
|
46
|
+
<View style={[{ position: 'fixed' as any, zIndex: 50 }, style]}>{children}</View>,
|
|
56
47
|
document.body,
|
|
57
48
|
);
|
|
58
49
|
}
|
package/src/overlay/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { OverlayContainer } from './OverlayContainer';
|
|
|
2
2
|
export type { OverlayContainerProps } from './OverlayContainer';
|
|
3
3
|
export { useAnchorPosition, type AnchorLayout } from './useAnchorPosition';
|
|
4
4
|
export { useDismissOverlay } from './useDismissOverlay';
|
|
5
|
+
export { useEscapeKey } from './useEscapeKey';
|
|
5
6
|
export {
|
|
6
7
|
useOverlayPosition,
|
|
7
8
|
type OverlayPosition,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* No-op on native — Escape key dismissal is not applicable.
|
|
5
|
+
* Native uses the system back gesture / hardware button via Modal.
|
|
6
|
+
*/
|
|
7
|
+
export function useEscapeKey(_open: boolean, _onEscape: () => void) {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Closes an overlay when the user presses the Escape key.
|
|
5
|
+
* Web-only — native platforms use Modal's `onRequestClose` for back/dismiss.
|
|
6
|
+
*/
|
|
7
|
+
export function useEscapeKey(open: boolean, onEscape: () => void) {
|
|
8
|
+
const onEscapeRef = useRef(onEscape);
|
|
9
|
+
onEscapeRef.current = onEscape;
|
|
10
|
+
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!open) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
17
|
+
if (e.key === 'Escape') {
|
|
18
|
+
onEscapeRef.current();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
23
|
+
return () => {
|
|
24
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
25
|
+
};
|
|
26
|
+
}, [open]);
|
|
27
|
+
}
|
package/src/select/context.tsx
CHANGED
|
@@ -1,56 +1,21 @@
|
|
|
1
|
-
import { createContext
|
|
2
|
-
import type { InteractionState
|
|
1
|
+
import { createContext } from '@cdx-ui/utils';
|
|
2
|
+
import type { InteractionState } from '../types';
|
|
3
|
+
import type { SelectContextValue, SelectItemInteractionState } from './types';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
items: [],
|
|
7
|
-
setOpen: () => {},
|
|
8
|
-
value: undefined,
|
|
9
|
-
onValueChange: () => {},
|
|
10
|
-
disabled: false,
|
|
11
|
-
required: false,
|
|
12
|
-
invalid: false,
|
|
13
|
-
readOnly: false,
|
|
14
|
-
native: false,
|
|
15
|
-
triggerRef: { current: null },
|
|
16
|
-
contentId: '',
|
|
17
|
-
triggerId: '',
|
|
18
|
-
activeValue: undefined,
|
|
19
|
-
setActiveValue: () => {}, // TODO: Is this needed? At the very least it could be moved to SelectContent
|
|
20
|
-
accessibilityLabel: undefined,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const SelectContext = createContext<SelectContextValue>(defaultContextValue);
|
|
24
|
-
|
|
25
|
-
export const useSelectContext = () => useContext(SelectContext);
|
|
5
|
+
export const [SelectProvider, useSelectContext] =
|
|
6
|
+
createContext<SelectContextValue>('SelectContext');
|
|
26
7
|
|
|
27
8
|
/**
|
|
28
9
|
* Propagates the trigger's interaction state (hover, focus, active, etc.) to
|
|
29
10
|
* child components like SelectValue and SelectIcon so they can apply matching
|
|
30
11
|
* data-attribute styles.
|
|
31
12
|
*/
|
|
32
|
-
export const
|
|
33
|
-
|
|
34
|
-
focus: false,
|
|
35
|
-
active: false,
|
|
36
|
-
disabled: false,
|
|
37
|
-
focusVisible: false,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const useSelectTriggerContext = () => useContext(SelectTriggerContext);
|
|
13
|
+
export const [SelectTriggerProvider, useSelectTriggerContext] =
|
|
14
|
+
createContext<InteractionState>('SelectTriggerContext');
|
|
41
15
|
|
|
42
16
|
/**
|
|
43
17
|
* Propagates the item's interaction and selection state (hover, focus, active,
|
|
44
18
|
* highlighted, checked, etc.) to child components like SelectItemLabel.
|
|
45
19
|
*/
|
|
46
|
-
export const
|
|
47
|
-
|
|
48
|
-
focus: false,
|
|
49
|
-
active: false,
|
|
50
|
-
disabled: false,
|
|
51
|
-
focusVisible: false,
|
|
52
|
-
highlighted: false,
|
|
53
|
-
checked: false,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const useSelectItemContext = () => useContext(SelectItemContext);
|
|
20
|
+
export const [SelectItemProvider, useSelectItemContext] =
|
|
21
|
+
createContext<SelectItemInteractionState>('SelectItemContext');
|
|
@@ -4,7 +4,7 @@ import { composeEventHandlers } from '@cdx-ui/utils';
|
|
|
4
4
|
import { useFocus, useFocusRing } from '@react-native-aria/focus';
|
|
5
5
|
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
6
6
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
|
-
import {
|
|
7
|
+
import { SelectItemProvider, useSelectContext } from './context';
|
|
8
8
|
import type { ISelectItemProps } from './types';
|
|
9
9
|
|
|
10
10
|
export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
@@ -74,7 +74,7 @@ export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
|
74
74
|
);
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<
|
|
77
|
+
<SelectItemProvider value={interactionState}>
|
|
78
78
|
<BaseItem
|
|
79
79
|
ref={ref}
|
|
80
80
|
role="option"
|
|
@@ -115,7 +115,7 @@ export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
|
115
115
|
>
|
|
116
116
|
{children}
|
|
117
117
|
</BaseItem>
|
|
118
|
-
</
|
|
118
|
+
</SelectItemProvider>
|
|
119
119
|
);
|
|
120
120
|
},
|
|
121
121
|
);
|
|
@@ -2,7 +2,7 @@ import type React from 'react';
|
|
|
2
2
|
import { forwardRef, useCallback, useId, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { useControllableState, useFormControl } from '@cdx-ui/utils';
|
|
4
4
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
-
import {
|
|
5
|
+
import { SelectProvider } from './context';
|
|
6
6
|
import type { ISelectProps } from './types';
|
|
7
7
|
|
|
8
8
|
export const createSelectRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
@@ -68,9 +68,11 @@ export const createSelectRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
|
68
68
|
const [activeValue, setActiveValue] = useState<string | undefined>(undefined);
|
|
69
69
|
|
|
70
70
|
const triggerRef = useRef<any>(null);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const
|
|
71
|
+
const reactId = useId();
|
|
72
|
+
/** Align with `useFormControl` default id (`${field.id}-input`) when inside `Form.Field`. */
|
|
73
|
+
const triggerId = formControlProps.id ?? `select-trigger-${reactId}`;
|
|
74
|
+
const contentId = `select-content-${reactId}`;
|
|
75
|
+
const ariaDescribedBy = formControlProps['aria-describedby'];
|
|
74
76
|
|
|
75
77
|
const contextValue = useMemo(
|
|
76
78
|
() => ({
|
|
@@ -90,6 +92,7 @@ export const createSelectRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
|
90
92
|
activeValue,
|
|
91
93
|
setActiveValue,
|
|
92
94
|
accessibilityLabel,
|
|
95
|
+
ariaDescribedBy,
|
|
93
96
|
}),
|
|
94
97
|
[
|
|
95
98
|
open,
|
|
@@ -106,11 +109,12 @@ export const createSelectRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
|
106
109
|
triggerId,
|
|
107
110
|
activeValue,
|
|
108
111
|
accessibilityLabel,
|
|
112
|
+
ariaDescribedBy,
|
|
109
113
|
],
|
|
110
114
|
);
|
|
111
115
|
|
|
112
116
|
return (
|
|
113
|
-
<
|
|
117
|
+
<SelectProvider value={contextValue}>
|
|
114
118
|
<BaseRoot
|
|
115
119
|
ref={ref}
|
|
116
120
|
{...(props as T)}
|
|
@@ -124,7 +128,7 @@ export const createSelectRoot = <T,>(BaseRoot: React.ComponentType<T>) =>
|
|
|
124
128
|
>
|
|
125
129
|
{children}
|
|
126
130
|
</BaseRoot>
|
|
127
|
-
</
|
|
131
|
+
</SelectProvider>
|
|
128
132
|
);
|
|
129
133
|
},
|
|
130
134
|
);
|