@cdx-ui/primitives 0.0.1-alpha.9 → 0.0.1-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/lib/commonjs/avatar/context.js +11 -0
- package/lib/commonjs/avatar/context.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarBadge.js +20 -0
- package/lib/commonjs/avatar/createAvatarBadge.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarIcon.js +30 -0
- package/lib/commonjs/avatar/createAvatarIcon.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarImage.js +51 -0
- package/lib/commonjs/avatar/createAvatarImage.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarRoot.js +34 -0
- package/lib/commonjs/avatar/createAvatarRoot.js.map +1 -0
- package/lib/commonjs/avatar/createAvatarText.js +42 -0
- package/lib/commonjs/avatar/createAvatarText.js.map +1 -0
- package/lib/commonjs/avatar/index.js +30 -0
- package/lib/commonjs/avatar/index.js.map +1 -0
- package/lib/commonjs/avatar/types.js +6 -0
- package/lib/commonjs/avatar/types.js.map +1 -0
- package/lib/commonjs/button/index.js +25 -19
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/checkbox/createCheckboxIcon.js +3 -2
- package/lib/commonjs/checkbox/createCheckboxIcon.js.map +1 -1
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +2 -0
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/commonjs/checkbox/index.js +19 -21
- package/lib/commonjs/checkbox/index.js.map +1 -1
- package/lib/commonjs/dialog/context.js +11 -0
- package/lib/commonjs/dialog/context.js.map +1 -0
- package/lib/commonjs/dialog/createDialogBody.js +21 -0
- package/lib/commonjs/dialog/createDialogBody.js.map +1 -0
- package/lib/commonjs/dialog/createDialogClose.js +37 -0
- package/lib/commonjs/dialog/createDialogClose.js.map +1 -0
- package/lib/commonjs/dialog/createDialogContent.js +141 -0
- package/lib/commonjs/dialog/createDialogContent.js.map +1 -0
- package/lib/commonjs/dialog/createDialogDescription.js +30 -0
- package/lib/commonjs/dialog/createDialogDescription.js.map +1 -0
- package/lib/commonjs/dialog/createDialogFooter.js +21 -0
- package/lib/commonjs/dialog/createDialogFooter.js.map +1 -0
- package/lib/commonjs/dialog/createDialogHeader.js +21 -0
- package/lib/commonjs/dialog/createDialogHeader.js.map +1 -0
- package/lib/commonjs/dialog/createDialogRoot.js +54 -0
- package/lib/commonjs/dialog/createDialogRoot.js.map +1 -0
- package/lib/commonjs/dialog/createDialogTitle.js +21 -0
- package/lib/commonjs/dialog/createDialogTitle.js.map +1 -0
- package/lib/commonjs/dialog/createDialogTrigger.js +37 -0
- package/lib/commonjs/dialog/createDialogTrigger.js.map +1 -0
- package/lib/commonjs/dialog/index.js +60 -0
- package/lib/commonjs/dialog/index.js.map +1 -0
- package/lib/commonjs/dialog/types.js +6 -0
- package/lib/commonjs/dialog/types.js.map +1 -0
- package/lib/commonjs/field/createFieldError.js +41 -0
- package/lib/commonjs/field/createFieldError.js.map +1 -0
- package/lib/commonjs/field/createFieldErrorIcon.js +18 -0
- package/lib/commonjs/field/createFieldErrorIcon.js.map +1 -0
- package/lib/commonjs/field/createFieldErrorText.js +18 -0
- package/lib/commonjs/field/createFieldErrorText.js.map +1 -0
- package/lib/commonjs/field/createFieldHelper.js +41 -0
- package/lib/commonjs/field/createFieldHelper.js.map +1 -0
- package/lib/commonjs/field/createFieldHelperText.js +18 -0
- package/lib/commonjs/field/createFieldHelperText.js.map +1 -0
- package/lib/commonjs/field/createFieldLabel.js +36 -0
- package/lib/commonjs/field/createFieldLabel.js.map +1 -0
- package/lib/commonjs/field/createFieldRoot.js +35 -0
- package/lib/commonjs/field/createFieldRoot.js.map +1 -0
- package/lib/commonjs/field/index.js +46 -0
- package/lib/commonjs/field/index.js.map +1 -0
- package/lib/commonjs/field/types.js +6 -0
- package/lib/commonjs/field/types.js.map +1 -0
- package/lib/commonjs/form/createFormRoot.js +21 -0
- package/lib/commonjs/form/createFormRoot.js.map +1 -0
- package/lib/commonjs/form/index.js +15 -0
- package/lib/commonjs/form/index.js.map +1 -0
- package/lib/commonjs/form/types.js +6 -0
- package/lib/commonjs/form/types.js.map +1 -0
- package/lib/commonjs/index.js +105 -1
- 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/list-item/context.js +11 -0
- package/lib/commonjs/list-item/context.js.map +1 -0
- package/lib/commonjs/list-item/createListItemContent.js +30 -0
- package/lib/commonjs/list-item/createListItemContent.js.map +1 -0
- package/lib/commonjs/list-item/createListItemDescription.js +25 -0
- package/lib/commonjs/list-item/createListItemDescription.js.map +1 -0
- package/lib/commonjs/list-item/createListItemLeadingSlot.js +34 -0
- package/lib/commonjs/list-item/createListItemLeadingSlot.js.map +1 -0
- package/lib/commonjs/list-item/createListItemMeta.js +25 -0
- package/lib/commonjs/list-item/createListItemMeta.js.map +1 -0
- package/lib/commonjs/list-item/createListItemRoot.js +142 -0
- package/lib/commonjs/list-item/createListItemRoot.js.map +1 -0
- package/lib/commonjs/list-item/createListItemSectionHeader.js +54 -0
- package/lib/commonjs/list-item/createListItemSectionHeader.js.map +1 -0
- package/lib/commonjs/list-item/createListItemTitle.js +25 -0
- package/lib/commonjs/list-item/createListItemTitle.js.map +1 -0
- package/lib/commonjs/list-item/createListItemTrailingSlot.js +28 -0
- package/lib/commonjs/list-item/createListItemTrailingSlot.js.map +1 -0
- package/lib/commonjs/list-item/index.js +55 -0
- package/lib/commonjs/list-item/index.js.map +1 -0
- package/lib/commonjs/list-item/types.js +6 -0
- package/lib/commonjs/list-item/types.js.map +1 -0
- package/lib/commonjs/otp-input/context.js +14 -0
- package/lib/commonjs/otp-input/context.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js +29 -0
- package/lib/commonjs/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputField.js +104 -0
- package/lib/commonjs/otp-input/createOtpInputField.js.map +1 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js +136 -0
- package/lib/commonjs/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/commonjs/otp-input/index.js +48 -0
- package/lib/commonjs/otp-input/index.js.map +1 -0
- package/lib/commonjs/otp-input/types.js +6 -0
- package/lib/commonjs/otp-input/types.js.map +1 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js +73 -0
- package/lib/commonjs/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/commonjs/otp-input/utils/filterValue.js +46 -0
- package/lib/commonjs/otp-input/utils/filterValue.js.map +1 -0
- package/lib/commonjs/overlay/OverlayContainer.js +8 -11
- package/lib/commonjs/overlay/OverlayContainer.js.map +1 -1
- package/lib/commonjs/overlay/index.js +7 -0
- package/lib/commonjs/overlay/index.js.map +1 -1
- package/lib/commonjs/overlay/useEscapeKey.js +14 -0
- package/lib/commonjs/overlay/useEscapeKey.js.map +1 -0
- package/lib/commonjs/overlay/useEscapeKey.web.js +30 -0
- package/lib/commonjs/overlay/useEscapeKey.web.js.map +1 -0
- package/lib/commonjs/progress/context.js +11 -0
- package/lib/commonjs/progress/context.js.map +1 -0
- package/lib/commonjs/progress/createProgressIndicator.js +42 -0
- package/lib/commonjs/progress/createProgressIndicator.js.map +1 -0
- package/lib/commonjs/progress/createProgressRoot.js +96 -0
- package/lib/commonjs/progress/createProgressRoot.js.map +1 -0
- package/lib/commonjs/progress/index.js +25 -0
- package/lib/commonjs/progress/index.js.map +1 -0
- package/lib/commonjs/progress/types.js +6 -0
- package/lib/commonjs/progress/types.js.map +1 -0
- package/lib/commonjs/select/context.js +8 -43
- package/lib/commonjs/select/context.js.map +1 -1
- package/lib/commonjs/select/createSelectItem.js +1 -1
- package/lib/commonjs/select/createSelectItem.js.map +1 -1
- package/lib/commonjs/select/createSelectRoot.js +9 -6
- package/lib/commonjs/select/createSelectRoot.js.map +1 -1
- package/lib/commonjs/select/createSelectTrigger.js +53 -12
- package/lib/commonjs/select/createSelectTrigger.js.map +1 -1
- package/lib/commonjs/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/index.js +19 -19
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/checkbox/createCheckboxIcon.js +3 -2
- package/lib/module/checkbox/createCheckboxIcon.js.map +1 -1
- package/lib/module/checkbox/createCheckboxRoot.web.js +2 -0
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +1 -1
- package/lib/module/checkbox/index.js +18 -19
- package/lib/module/checkbox/index.js.map +1 -1
- package/lib/module/dialog/context.js +5 -0
- package/lib/module/dialog/context.js.map +1 -0
- package/lib/module/dialog/createDialogBody.js +15 -0
- package/lib/module/dialog/createDialogBody.js.map +1 -0
- package/lib/module/dialog/createDialogClose.js +31 -0
- package/lib/module/dialog/createDialogClose.js.map +1 -0
- package/lib/module/dialog/createDialogContent.js +136 -0
- package/lib/module/dialog/createDialogContent.js.map +1 -0
- package/lib/module/dialog/createDialogDescription.js +24 -0
- package/lib/module/dialog/createDialogDescription.js.map +1 -0
- package/lib/module/dialog/createDialogFooter.js +15 -0
- package/lib/module/dialog/createDialogFooter.js.map +1 -0
- package/lib/module/dialog/createDialogHeader.js +15 -0
- package/lib/module/dialog/createDialogHeader.js.map +1 -0
- package/lib/module/dialog/createDialogRoot.js +49 -0
- package/lib/module/dialog/createDialogRoot.js.map +1 -0
- package/lib/module/dialog/createDialogTitle.js +15 -0
- package/lib/module/dialog/createDialogTitle.js.map +1 -0
- package/lib/module/dialog/createDialogTrigger.js +31 -0
- package/lib/module/dialog/createDialogTrigger.js.map +1 -0
- package/lib/module/dialog/index.js +45 -0
- package/lib/module/dialog/index.js.map +1 -0
- package/lib/module/dialog/types.js +4 -0
- package/lib/module/dialog/types.js.map +1 -0
- package/lib/module/field/createFieldError.js +35 -0
- package/lib/module/field/createFieldError.js.map +1 -0
- package/lib/module/field/createFieldErrorIcon.js +13 -0
- package/lib/module/field/createFieldErrorIcon.js.map +1 -0
- package/lib/module/field/createFieldErrorText.js +13 -0
- package/lib/module/field/createFieldErrorText.js.map +1 -0
- package/lib/module/field/createFieldHelper.js +35 -0
- package/lib/module/field/createFieldHelper.js.map +1 -0
- package/lib/module/field/createFieldHelperText.js +13 -0
- package/lib/module/field/createFieldHelperText.js.map +1 -0
- package/lib/module/field/createFieldLabel.js +31 -0
- package/lib/module/field/createFieldLabel.js.map +1 -0
- package/lib/module/field/createFieldRoot.js +29 -0
- package/lib/module/field/createFieldRoot.js.map +1 -0
- package/lib/module/field/index.js +42 -0
- package/lib/module/field/index.js.map +1 -0
- package/lib/module/field/types.js +4 -0
- package/lib/module/field/types.js.map +1 -0
- package/lib/module/form/createFormRoot.js +15 -0
- package/lib/module/form/createFormRoot.js.map +1 -0
- package/lib/module/form/index.js +11 -0
- package/lib/module/form/index.js.map +1 -0
- package/lib/module/form/types.js +4 -0
- package/lib/module/form/types.js.map +1 -0
- package/lib/module/index.js +9 -0
- 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/list-item/context.js +5 -0
- package/lib/module/list-item/context.js.map +1 -0
- package/lib/module/list-item/createListItemContent.js +24 -0
- package/lib/module/list-item/createListItemContent.js.map +1 -0
- package/lib/module/list-item/createListItemDescription.js +19 -0
- package/lib/module/list-item/createListItemDescription.js.map +1 -0
- package/lib/module/list-item/createListItemLeadingSlot.js +28 -0
- package/lib/module/list-item/createListItemLeadingSlot.js.map +1 -0
- package/lib/module/list-item/createListItemMeta.js +19 -0
- package/lib/module/list-item/createListItemMeta.js.map +1 -0
- package/lib/module/list-item/createListItemRoot.js +136 -0
- package/lib/module/list-item/createListItemRoot.js.map +1 -0
- package/lib/module/list-item/createListItemSectionHeader.js +48 -0
- package/lib/module/list-item/createListItemSectionHeader.js.map +1 -0
- package/lib/module/list-item/createListItemTitle.js +19 -0
- package/lib/module/list-item/createListItemTitle.js.map +1 -0
- package/lib/module/list-item/createListItemTrailingSlot.js +22 -0
- package/lib/module/list-item/createListItemTrailingSlot.js.map +1 -0
- package/lib/module/list-item/index.js +39 -0
- package/lib/module/list-item/index.js.map +1 -0
- package/lib/module/list-item/types.js +4 -0
- package/lib/module/list-item/types.js.map +1 -0
- package/lib/module/otp-input/context.js +6 -0
- package/lib/module/otp-input/context.js.map +1 -0
- package/lib/module/otp-input/createOtpInputCell.js +24 -0
- package/lib/module/otp-input/createOtpInputCell.js.map +1 -0
- package/lib/module/otp-input/createOtpInputField.js +99 -0
- package/lib/module/otp-input/createOtpInputField.js.map +1 -0
- package/lib/module/otp-input/createOtpInputRoot.js +131 -0
- package/lib/module/otp-input/createOtpInputRoot.js.map +1 -0
- package/lib/module/otp-input/index.js +20 -0
- package/lib/module/otp-input/index.js.map +1 -0
- package/lib/module/otp-input/types.js +4 -0
- package/lib/module/otp-input/types.js.map +1 -0
- package/lib/module/otp-input/utils/applyValueChange.js +69 -0
- package/lib/module/otp-input/utils/applyValueChange.js.map +1 -0
- package/lib/module/otp-input/utils/filterValue.js +40 -0
- package/lib/module/otp-input/utils/filterValue.js.map +1 -0
- package/lib/module/overlay/OverlayContainer.js +8 -11
- package/lib/module/overlay/OverlayContainer.js.map +1 -1
- package/lib/module/overlay/index.js +1 -0
- package/lib/module/overlay/index.js.map +1 -1
- package/lib/module/overlay/useEscapeKey.js +10 -0
- package/lib/module/overlay/useEscapeKey.js.map +1 -0
- package/lib/module/overlay/useEscapeKey.web.js +27 -0
- package/lib/module/overlay/useEscapeKey.web.js.map +1 -0
- package/lib/module/progress/context.js +5 -0
- package/lib/module/progress/context.js.map +1 -0
- package/lib/module/progress/createProgressIndicator.js +37 -0
- package/lib/module/progress/createProgressIndicator.js.map +1 -0
- package/lib/module/progress/createProgressRoot.js +91 -0
- package/lib/module/progress/createProgressRoot.js.map +1 -0
- package/lib/module/progress/index.js +15 -0
- package/lib/module/progress/index.js.map +1 -0
- package/lib/module/progress/types.js +4 -0
- package/lib/module/progress/types.js.map +1 -0
- package/lib/module/select/context.js +4 -42
- package/lib/module/select/context.js.map +1 -1
- package/lib/module/select/createSelectItem.js +2 -2
- package/lib/module/select/createSelectItem.js.map +1 -1
- package/lib/module/select/createSelectRoot.js +10 -7
- package/lib/module/select/createSelectRoot.js.map +1 -1
- package/lib/module/select/createSelectTrigger.js +56 -15
- package/lib/module/select/createSelectTrigger.js.map +1 -1
- package/lib/module/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/index.d.ts +2 -1
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/checkbox/context.d.ts +2 -2
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +1 -1
- package/lib/typescript/checkbox/index.d.ts +3 -2
- package/lib/typescript/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +8 -3
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -1
- package/lib/typescript/dialog/context.d.ts +6 -0
- package/lib/typescript/dialog/context.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogBody.d.ts +4 -0
- package/lib/typescript/dialog/createDialogBody.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogClose.d.ts +4 -0
- package/lib/typescript/dialog/createDialogClose.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogContent.d.ts +4 -0
- package/lib/typescript/dialog/createDialogContent.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogDescription.d.ts +4 -0
- package/lib/typescript/dialog/createDialogDescription.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogFooter.d.ts +4 -0
- package/lib/typescript/dialog/createDialogFooter.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogHeader.d.ts +4 -0
- package/lib/typescript/dialog/createDialogHeader.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogRoot.d.ts +4 -0
- package/lib/typescript/dialog/createDialogRoot.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogTitle.d.ts +4 -0
- package/lib/typescript/dialog/createDialogTitle.d.ts.map +1 -0
- package/lib/typescript/dialog/createDialogTrigger.d.ts +4 -0
- package/lib/typescript/dialog/createDialogTrigger.d.ts.map +1 -0
- package/lib/typescript/dialog/index.d.ts +18 -0
- package/lib/typescript/dialog/index.d.ts.map +1 -0
- package/lib/typescript/dialog/types.d.ts +52 -0
- package/lib/typescript/dialog/types.d.ts.map +1 -0
- package/lib/typescript/field/createFieldError.d.ts +5 -0
- package/lib/typescript/field/createFieldError.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorIcon.d.ts.map +1 -0
- package/lib/typescript/field/createFieldErrorText.d.ts +5 -0
- package/lib/typescript/field/createFieldErrorText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelper.d.ts +5 -0
- package/lib/typescript/field/createFieldHelper.d.ts.map +1 -0
- package/lib/typescript/field/createFieldHelperText.d.ts +5 -0
- package/lib/typescript/field/createFieldHelperText.d.ts.map +1 -0
- package/lib/typescript/field/createFieldLabel.d.ts +6 -0
- package/lib/typescript/field/createFieldLabel.d.ts.map +1 -0
- package/lib/typescript/field/createFieldRoot.d.ts +6 -0
- package/lib/typescript/field/createFieldRoot.d.ts.map +1 -0
- package/lib/typescript/field/index.d.ts +13 -0
- package/lib/typescript/field/index.d.ts.map +1 -0
- package/lib/typescript/field/types.d.ts +63 -0
- package/lib/typescript/field/types.d.ts.map +1 -0
- package/lib/typescript/form/createFormRoot.d.ts +4 -0
- package/lib/typescript/form/createFormRoot.d.ts.map +1 -0
- package/lib/typescript/form/index.d.ts +6 -0
- package/lib/typescript/form/index.d.ts.map +1 -0
- package/lib/typescript/form/types.d.ts +14 -0
- package/lib/typescript/form/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +9 -0
- 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/list-item/context.d.ts +6 -0
- package/lib/typescript/list-item/context.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemContent.d.ts +3 -0
- package/lib/typescript/list-item/createListItemContent.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemDescription.d.ts +3 -0
- package/lib/typescript/list-item/createListItemDescription.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts +4 -0
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemMeta.d.ts +3 -0
- package/lib/typescript/list-item/createListItemMeta.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemRoot.d.ts +4 -0
- package/lib/typescript/list-item/createListItemRoot.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts +4 -0
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemTitle.d.ts +3 -0
- package/lib/typescript/list-item/createListItemTitle.d.ts.map +1 -0
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts +3 -0
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts.map +1 -0
- package/lib/typescript/list-item/index.d.ts +16 -0
- package/lib/typescript/list-item/index.d.ts.map +1 -0
- package/lib/typescript/list-item/types.d.ts +86 -0
- package/lib/typescript/list-item/types.d.ts.map +1 -0
- package/lib/typescript/otp-input/context.d.ts +10 -0
- package/lib/typescript/otp-input/context.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputCell.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputField.d.ts.map +1 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts +4 -0
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts.map +1 -0
- package/lib/typescript/otp-input/index.d.ts +11 -0
- package/lib/typescript/otp-input/index.d.ts.map +1 -0
- package/lib/typescript/otp-input/types.d.ts +75 -0
- package/lib/typescript/otp-input/types.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts +10 -0
- package/lib/typescript/otp-input/utils/applyValueChange.d.ts.map +1 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts +7 -0
- package/lib/typescript/otp-input/utils/filterValue.d.ts.map +1 -0
- package/lib/typescript/overlay/OverlayContainer.d.ts +5 -1
- package/lib/typescript/overlay/OverlayContainer.d.ts.map +1 -1
- package/lib/typescript/overlay/index.d.ts +1 -0
- package/lib/typescript/overlay/index.d.ts.map +1 -1
- package/lib/typescript/overlay/useEscapeKey.d.ts +6 -0
- package/lib/typescript/overlay/useEscapeKey.d.ts.map +1 -0
- package/lib/typescript/overlay/useEscapeKey.web.d.ts +6 -0
- package/lib/typescript/overlay/useEscapeKey.web.d.ts.map +1 -0
- package/lib/typescript/progress/context.d.ts +13 -0
- package/lib/typescript/progress/context.d.ts.map +1 -0
- package/lib/typescript/progress/createProgressIndicator.d.ts +3 -0
- package/lib/typescript/progress/createProgressIndicator.d.ts.map +1 -0
- package/lib/typescript/progress/createProgressRoot.d.ts +4 -0
- package/lib/typescript/progress/createProgressRoot.d.ts.map +1 -0
- package/lib/typescript/progress/index.d.ts +10 -0
- package/lib/typescript/progress/index.d.ts.map +1 -0
- package/lib/typescript/progress/types.d.ts +25 -0
- package/lib/typescript/progress/types.d.ts.map +1 -0
- package/lib/typescript/select/context.d.ts +14 -7
- package/lib/typescript/select/context.d.ts.map +1 -1
- package/lib/typescript/select/createSelectRoot.d.ts.map +1 -1
- package/lib/typescript/select/createSelectTrigger.d.ts +2 -7
- package/lib/typescript/select/createSelectTrigger.d.ts.map +1 -1
- package/lib/typescript/select/types.d.ts +4 -1
- package/lib/typescript/select/types.d.ts.map +1 -1
- 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 +8 -3
- package/src/avatar/context.tsx +5 -0
- package/src/avatar/createAvatarBadge.tsx +12 -0
- package/src/avatar/createAvatarIcon.tsx +16 -0
- package/src/avatar/createAvatarImage.tsx +40 -0
- package/src/avatar/createAvatarRoot.tsx +23 -0
- package/src/avatar/createAvatarText.tsx +30 -0
- package/src/avatar/index.ts +43 -0
- package/src/avatar/types.ts +77 -0
- package/src/button/index.tsx +19 -19
- package/src/checkbox/createCheckboxIcon.tsx +2 -2
- package/src/checkbox/createCheckboxRoot.web.tsx +2 -0
- package/src/checkbox/index.ts +20 -20
- package/src/dialog/context.tsx +4 -0
- package/src/dialog/createDialogBody.tsx +11 -0
- package/src/dialog/createDialogClose.tsx +27 -0
- package/src/dialog/createDialogContent.tsx +122 -0
- package/src/dialog/createDialogDescription.tsx +20 -0
- package/src/dialog/createDialogFooter.tsx +11 -0
- package/src/dialog/createDialogHeader.tsx +11 -0
- package/src/dialog/createDialogRoot.tsx +66 -0
- package/src/dialog/createDialogTitle.tsx +11 -0
- package/src/dialog/createDialogTrigger.tsx +27 -0
- package/src/dialog/index.tsx +93 -0
- package/src/dialog/types.ts +88 -0
- package/src/field/createFieldError.tsx +32 -0
- package/src/field/createFieldErrorIcon.tsx +9 -0
- package/src/field/createFieldErrorText.tsx +9 -0
- package/src/field/createFieldHelper.tsx +28 -0
- package/src/field/createFieldHelperText.tsx +9 -0
- package/src/field/createFieldLabel.tsx +30 -0
- package/src/field/createFieldRoot.tsx +27 -0
- package/src/field/index.tsx +68 -0
- package/src/field/types.tsx +78 -0
- package/src/form/createFormRoot.tsx +13 -0
- package/src/form/index.tsx +12 -0
- package/src/form/types.tsx +16 -0
- package/src/index.ts +9 -0
- 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/list-item/context.tsx +5 -0
- package/src/list-item/createListItemContent.tsx +23 -0
- package/src/list-item/createListItemDescription.tsx +19 -0
- package/src/list-item/createListItemLeadingSlot.tsx +30 -0
- package/src/list-item/createListItemMeta.tsx +17 -0
- package/src/list-item/createListItemRoot.tsx +163 -0
- package/src/list-item/createListItemSectionHeader.tsx +53 -0
- package/src/list-item/createListItemTitle.tsx +17 -0
- package/src/list-item/createListItemTrailingSlot.tsx +21 -0
- package/src/list-item/index.ts +88 -0
- package/src/list-item/types.ts +122 -0
- package/src/otp-input/context.tsx +8 -0
- package/src/otp-input/createOtpInputCell.tsx +22 -0
- package/src/otp-input/createOtpInputField.tsx +98 -0
- package/src/otp-input/createOtpInputRoot.tsx +179 -0
- package/src/otp-input/index.tsx +34 -0
- package/src/otp-input/types.ts +92 -0
- package/src/otp-input/utils/applyValueChange.ts +56 -0
- package/src/otp-input/utils/filterValue.ts +37 -0
- package/src/overlay/OverlayContainer.tsx +9 -18
- package/src/overlay/index.ts +1 -0
- package/src/overlay/useEscapeKey.ts +7 -0
- package/src/overlay/useEscapeKey.web.ts +27 -0
- package/src/progress/context.tsx +13 -0
- package/src/progress/createProgressIndicator.tsx +35 -0
- package/src/progress/createProgressRoot.tsx +109 -0
- package/src/progress/index.ts +28 -0
- package/src/progress/types.ts +37 -0
- package/src/select/context.tsx +9 -44
- package/src/select/createSelectItem.tsx +3 -3
- package/src/select/createSelectRoot.tsx +10 -6
- package/src/select/createSelectTrigger.tsx +62 -36
- package/src/select/types.ts +4 -1
- 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,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 { IFieldLabelProps } from './types';
|
|
6
|
+
|
|
7
|
+
export const createFieldLabel = <T,>(BaseFormLabel: React.ComponentType<T>) =>
|
|
8
|
+
forwardRef<unknown, IFieldLabelProps & { 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,27 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { useFormControlRoot, FormControlContext } from '@cdx-ui/utils';
|
|
3
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
4
|
+
import type { IFieldRootProps } from './types';
|
|
5
|
+
|
|
6
|
+
export const createFieldRoot = <T,>(BaseFormField: React.ComponentType<T>) =>
|
|
7
|
+
forwardRef(
|
|
8
|
+
({ children, ...props }: IFieldRootProps & { 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,68 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createFieldError } from './createFieldError';
|
|
3
|
+
import { createFieldErrorIcon } from './createFieldErrorIcon';
|
|
4
|
+
import { createFieldErrorText } from './createFieldErrorText';
|
|
5
|
+
import { createFieldRoot } from './createFieldRoot';
|
|
6
|
+
import { createFieldHelper } from './createFieldHelper';
|
|
7
|
+
import { createFieldHelperText } from './createFieldHelperText';
|
|
8
|
+
import { createFieldLabel } from './createFieldLabel';
|
|
9
|
+
import type { IFieldComponentType } from './types';
|
|
10
|
+
|
|
11
|
+
export type {
|
|
12
|
+
IFieldRootProps,
|
|
13
|
+
IFieldLabelProps,
|
|
14
|
+
IFieldHelperProps,
|
|
15
|
+
IFieldHelperTextProps,
|
|
16
|
+
IFieldErrorProps,
|
|
17
|
+
IFieldErrorTextProps,
|
|
18
|
+
IFieldErrorIconProps,
|
|
19
|
+
IFieldComponentType,
|
|
20
|
+
} from './types';
|
|
21
|
+
|
|
22
|
+
export function createField<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>({
|
|
23
|
+
Root,
|
|
24
|
+
Label,
|
|
25
|
+
Helper,
|
|
26
|
+
HelperText,
|
|
27
|
+
Error,
|
|
28
|
+
ErrorText,
|
|
29
|
+
ErrorIcon,
|
|
30
|
+
}: {
|
|
31
|
+
Root: React.ComponentType<Root>;
|
|
32
|
+
Label: React.ComponentType<Label>;
|
|
33
|
+
Helper: React.ComponentType<Helper>;
|
|
34
|
+
HelperText: React.ComponentType<HelperText>;
|
|
35
|
+
Error: React.ComponentType<Error>;
|
|
36
|
+
ErrorText: React.ComponentType<ErrorText>;
|
|
37
|
+
ErrorIcon: React.ComponentType<ErrorIcon>;
|
|
38
|
+
}) {
|
|
39
|
+
const FieldRoot = createFieldRoot(Root);
|
|
40
|
+
FieldRoot.displayName = 'FieldPrimitive';
|
|
41
|
+
|
|
42
|
+
const FieldLabel = createFieldLabel(Label);
|
|
43
|
+
FieldLabel.displayName = 'FieldPrimitive.Label';
|
|
44
|
+
|
|
45
|
+
const FieldHelper = createFieldHelper(Helper);
|
|
46
|
+
FieldHelper.displayName = 'FieldPrimitive.Helper';
|
|
47
|
+
|
|
48
|
+
const FieldHelperText = createFieldHelperText(HelperText);
|
|
49
|
+
FieldHelperText.displayName = 'FieldPrimitive.HelperText';
|
|
50
|
+
|
|
51
|
+
const FieldError = createFieldError(Error);
|
|
52
|
+
FieldError.displayName = 'FieldPrimitive.Error';
|
|
53
|
+
|
|
54
|
+
const FieldErrorText = createFieldErrorText(ErrorText);
|
|
55
|
+
FieldErrorText.displayName = 'FieldPrimitive.ErrorText';
|
|
56
|
+
|
|
57
|
+
const FieldErrorIcon = createFieldErrorIcon(ErrorIcon);
|
|
58
|
+
FieldErrorIcon.displayName = 'FieldPrimitive.ErrorIcon';
|
|
59
|
+
|
|
60
|
+
return Object.assign(FieldRoot, {
|
|
61
|
+
Label: FieldLabel,
|
|
62
|
+
Helper: FieldHelper,
|
|
63
|
+
HelperText: FieldHelperText,
|
|
64
|
+
Error: FieldError,
|
|
65
|
+
ErrorText: FieldErrorText,
|
|
66
|
+
ErrorIcon: FieldErrorIcon,
|
|
67
|
+
}) as IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon>;
|
|
68
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { TextProps, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Props for a single form field (`Form.Field`).
|
|
6
|
+
* Provides field-level context (name, validation state, ids) to children.
|
|
7
|
+
*
|
|
8
|
+
* **Initial focus:** use `autoFocus` on `Input.Field` (or your control). `TextInput` / DOM
|
|
9
|
+
* inputs support it natively. Do not rely on `Form.Field` for autofocus — it does not forward
|
|
10
|
+
* to a single child.
|
|
11
|
+
*
|
|
12
|
+
* **Submit UX:** "focus first invalid on error" needs form-level validation state; not built in yet.
|
|
13
|
+
*/
|
|
14
|
+
export interface IFieldRootProps extends ViewProps {
|
|
15
|
+
/** Unique id for this field. Auto-generated if not provided. */
|
|
16
|
+
readonly id?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Field name for form submission. Passed through context so child inputs
|
|
19
|
+
* automatically receive it as their `name` attribute for `FormData` support.
|
|
20
|
+
*/
|
|
21
|
+
readonly name?: string;
|
|
22
|
+
/** If true, the field is marked as invalid. Controls error visibility. */
|
|
23
|
+
readonly isInvalid?: boolean;
|
|
24
|
+
/** If true, the field is marked as required. Shows asterisk on label. */
|
|
25
|
+
readonly isRequired?: boolean;
|
|
26
|
+
/** If true, the field is disabled. */
|
|
27
|
+
readonly isDisabled?: boolean;
|
|
28
|
+
/** If true, the field is read-only. */
|
|
29
|
+
readonly isReadOnly?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IFieldLabelProps extends TextProps {
|
|
33
|
+
/**
|
|
34
|
+
* Associates the label with a control `id` on web (`<label htmlFor>`).
|
|
35
|
+
* If omitted, defaults to the same id `Input.Field` gets from form context: `fieldId + "-input"`.
|
|
36
|
+
*/
|
|
37
|
+
readonly htmlFor?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Element to render after the label text when the field is required.
|
|
40
|
+
* Rendered by the primitive (which owns the form-control context) so the
|
|
41
|
+
* styled layer never needs to read `FormControlContext` across packages.
|
|
42
|
+
*/
|
|
43
|
+
readonly requiredIndicator?: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface IFieldHelperProps extends ViewProps {}
|
|
47
|
+
|
|
48
|
+
export interface IFieldHelperTextProps extends TextProps {}
|
|
49
|
+
|
|
50
|
+
export interface IFieldErrorProps extends ViewProps {}
|
|
51
|
+
|
|
52
|
+
export interface IFieldErrorTextProps extends TextProps {}
|
|
53
|
+
|
|
54
|
+
export interface IFieldErrorIconProps extends ViewProps {}
|
|
55
|
+
|
|
56
|
+
export type IFieldComponentType<Root, Label, Helper, HelperText, Error, ErrorText, ErrorIcon> =
|
|
57
|
+
React.ForwardRefExoticComponent<InnerForwardRefExoticComponent<Root> & IFieldRootProps> & {
|
|
58
|
+
Label: React.ForwardRefExoticComponent<
|
|
59
|
+
InnerForwardRefExoticComponent<Label> & IFieldLabelProps
|
|
60
|
+
>;
|
|
61
|
+
Helper: React.ForwardRefExoticComponent<
|
|
62
|
+
InnerForwardRefExoticComponent<Helper> & IFieldHelperProps
|
|
63
|
+
>;
|
|
64
|
+
HelperText: React.ForwardRefExoticComponent<
|
|
65
|
+
InnerForwardRefExoticComponent<HelperText> & IFieldHelperTextProps
|
|
66
|
+
>;
|
|
67
|
+
Error: React.ForwardRefExoticComponent<
|
|
68
|
+
InnerForwardRefExoticComponent<Error> & IFieldErrorProps
|
|
69
|
+
>;
|
|
70
|
+
ErrorText: React.ForwardRefExoticComponent<
|
|
71
|
+
InnerForwardRefExoticComponent<ErrorText> & IFieldErrorTextProps
|
|
72
|
+
>;
|
|
73
|
+
ErrorIcon: React.ForwardRefExoticComponent<
|
|
74
|
+
InnerForwardRefExoticComponent<ErrorIcon> & IFieldErrorIconProps
|
|
75
|
+
>;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import type { IFormRootProps, IFormComponentType } from './types';
|
|
3
|
+
|
|
4
|
+
// TODO: Handle web submission (button type submit)
|
|
5
|
+
|
|
6
|
+
export const createFormRoot = <T,>(BaseFormRoot: React.ComponentType<T>): IFormComponentType<T> =>
|
|
7
|
+
forwardRef(
|
|
8
|
+
({ children, ...props }: IFormRootProps & { children?: React.ReactNode }, ref?: unknown) => (
|
|
9
|
+
<BaseFormRoot ref={ref} {...(props as T)}>
|
|
10
|
+
{children}
|
|
11
|
+
</BaseFormRoot>
|
|
12
|
+
),
|
|
13
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createFormRoot } from './createFormRoot';
|
|
3
|
+
|
|
4
|
+
export type { IFormRootProps, IFormComponentType } from './types';
|
|
5
|
+
|
|
6
|
+
export function createForm<Root>({ Root }: { Root: React.ComponentType<Root> }) {
|
|
7
|
+
const FormRoot = createFormRoot(Root);
|
|
8
|
+
|
|
9
|
+
FormRoot.displayName = 'FormPrimitive';
|
|
10
|
+
|
|
11
|
+
return FormRoot;
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props for the Form container (`<form>` on web, `<View>` on RN).
|
|
5
|
+
* Does NOT provide field-level context — use `Form.Field` for that.
|
|
6
|
+
*
|
|
7
|
+
* Web-only submit props (`onSubmit`, `action`, `method`) belong in the
|
|
8
|
+
* platform-specific base component (`FormRoot.web.tsx`), not here.
|
|
9
|
+
*/
|
|
10
|
+
export interface IFormRootProps {}
|
|
11
|
+
|
|
12
|
+
export type IFormComponentType<Root> = React.ForwardRefExoticComponent<
|
|
13
|
+
InnerForwardRefExoticComponent<Root> & IFormRootProps
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
type InnerForwardRefExoticComponent<T> = React.PropsWithoutRef<T> & React.RefAttributes<unknown>;
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
export * from './avatar';
|
|
1
2
|
export * from './button';
|
|
2
3
|
export * from './checkbox';
|
|
4
|
+
export * from './dialog';
|
|
5
|
+
export * from './field';
|
|
6
|
+
export * from './form';
|
|
3
7
|
export * from './input';
|
|
8
|
+
export * from './otp-input';
|
|
9
|
+
export * from './link';
|
|
10
|
+
export * from './list-item';
|
|
4
11
|
export { type EdgeInsets, OverlayInsetsProvider } from './overlay';
|
|
5
12
|
export * from './select';
|
|
6
13
|
export * from './switch';
|
|
14
|
+
export * from './progress';
|
|
7
15
|
export type { InteractionState } from './types';
|
|
16
|
+
export { dataAttributes } from './utils/dataAttributes';
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemContentProps } from './types';
|
|
4
|
+
|
|
5
|
+
const contentStyle = {
|
|
6
|
+
flex: 1,
|
|
7
|
+
flexDirection: 'column' as const,
|
|
8
|
+
minWidth: 0,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const createListItemContent = <T,>(Base: React.ComponentType<T>) =>
|
|
12
|
+
forwardRef(({ children, style, ...props }: IListItemContentProps, ref: React.Ref<unknown>) => (
|
|
13
|
+
<Base
|
|
14
|
+
{...(props as T)}
|
|
15
|
+
{...dataAttributes({
|
|
16
|
+
slot: 'list-item-content',
|
|
17
|
+
})}
|
|
18
|
+
ref={ref as React.Ref<T>}
|
|
19
|
+
style={[contentStyle, style]}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</Base>
|
|
23
|
+
));
|