@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,19 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemDescriptionProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createListItemDescription = <T,>(Base: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef(
|
|
7
|
+
({ children, style, ...props }: IListItemDescriptionProps, ref: React.Ref<unknown>) => (
|
|
8
|
+
<Base
|
|
9
|
+
{...(props as T)}
|
|
10
|
+
{...dataAttributes({
|
|
11
|
+
slot: 'list-item-description',
|
|
12
|
+
})}
|
|
13
|
+
ref={ref as React.Ref<T>}
|
|
14
|
+
style={style}
|
|
15
|
+
>
|
|
16
|
+
{children}
|
|
17
|
+
</Base>
|
|
18
|
+
),
|
|
19
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemLeadingSlotProps } from './types';
|
|
4
|
+
|
|
5
|
+
const shrinkZero = { flexShrink: 0 as const };
|
|
6
|
+
|
|
7
|
+
export const createListItemLeadingSlot = <T,>(Base: React.ComponentType<T>) =>
|
|
8
|
+
forwardRef(
|
|
9
|
+
(
|
|
10
|
+
{ 'aria-hidden': ariaHidden, style, children, ...props }: IListItemLeadingSlotProps,
|
|
11
|
+
ref: React.Ref<unknown>,
|
|
12
|
+
) => {
|
|
13
|
+
const accessibilityElementsHidden = ariaHidden !== false;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Base
|
|
17
|
+
{...(props as T)}
|
|
18
|
+
{...dataAttributes({
|
|
19
|
+
slot: 'list-item-leading',
|
|
20
|
+
})}
|
|
21
|
+
accessibilityElementsHidden={accessibilityElementsHidden}
|
|
22
|
+
aria-hidden={ariaHidden}
|
|
23
|
+
ref={ref as React.Ref<T>}
|
|
24
|
+
style={[shrinkZero, style]}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</Base>
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemMetaProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createListItemMeta = <T,>(Base: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef(({ children, style, ...props }: IListItemMetaProps, ref: React.Ref<unknown>) => (
|
|
7
|
+
<Base
|
|
8
|
+
{...(props as T)}
|
|
9
|
+
{...dataAttributes({
|
|
10
|
+
slot: 'list-item-meta',
|
|
11
|
+
})}
|
|
12
|
+
ref={ref as React.Ref<T>}
|
|
13
|
+
style={style}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</Base>
|
|
17
|
+
));
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
2
|
+
import type { PressableProps } from 'react-native';
|
|
3
|
+
import { composeEventHandlers, mergeRefs } from '@cdx-ui/utils';
|
|
4
|
+
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
5
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
6
|
+
import { ListItemProvider } from './context';
|
|
7
|
+
import type { IListItemProps, IListItemPressablePassthrough } from './types';
|
|
8
|
+
|
|
9
|
+
function listItemRootDataAttrs(
|
|
10
|
+
size: IListItemProps['size'],
|
|
11
|
+
surface: IListItemProps['surface'],
|
|
12
|
+
showSeparator: boolean | undefined,
|
|
13
|
+
crossAlign: IListItemProps['crossAlign'],
|
|
14
|
+
) {
|
|
15
|
+
return dataAttributes({
|
|
16
|
+
slot: 'list-item',
|
|
17
|
+
size: size ?? 'default',
|
|
18
|
+
surface: surface ?? 'default',
|
|
19
|
+
separator: showSeparator ?? true,
|
|
20
|
+
crossAlign: crossAlign ?? 'center',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function rowStyleForCrossAlign(crossAlign: IListItemProps['crossAlign']) {
|
|
25
|
+
return {
|
|
26
|
+
flexDirection: 'row' as const,
|
|
27
|
+
alignSelf: 'stretch' as const,
|
|
28
|
+
alignItems: crossAlign === 'start' ? ('flex-start' as const) : ('center' as const),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const createListItemRoot = <V, P>(
|
|
33
|
+
BaseView: React.ComponentType<V>,
|
|
34
|
+
BasePressable: React.ComponentType<P>,
|
|
35
|
+
) =>
|
|
36
|
+
forwardRef(
|
|
37
|
+
(
|
|
38
|
+
{
|
|
39
|
+
asChild = false,
|
|
40
|
+
children,
|
|
41
|
+
onPress,
|
|
42
|
+
size = 'default',
|
|
43
|
+
surface = 'default',
|
|
44
|
+
showSeparator = true,
|
|
45
|
+
crossAlign = 'center',
|
|
46
|
+
disabled = false,
|
|
47
|
+
style,
|
|
48
|
+
...restProps
|
|
49
|
+
}: IListItemProps,
|
|
50
|
+
ref: React.Ref<unknown>,
|
|
51
|
+
) => {
|
|
52
|
+
const asChildInteractive = asChild && !!onPress && React.isValidElement(children);
|
|
53
|
+
const isPressableRoot = !!onPress && !asChildInteractive;
|
|
54
|
+
|
|
55
|
+
const pressState = usePress({
|
|
56
|
+
isDisabled: !isPressableRoot || disabled,
|
|
57
|
+
});
|
|
58
|
+
const isPressed = pressState.isPressed;
|
|
59
|
+
const pressProps = pressState.pressProps as Pick<PressableProps, 'onPressIn' | 'onPressOut'>;
|
|
60
|
+
const { hoverProps, isHovered } = useHover();
|
|
61
|
+
|
|
62
|
+
const slotAttrs = listItemRootDataAttrs(size, surface, showSeparator, crossAlign);
|
|
63
|
+
|
|
64
|
+
const contextValue = useMemo(
|
|
65
|
+
() => ({
|
|
66
|
+
isPressed: isPressableRoot ? isPressed : false,
|
|
67
|
+
isHovered,
|
|
68
|
+
isDisabled: disabled,
|
|
69
|
+
crossAlign: crossAlign ?? 'center',
|
|
70
|
+
}),
|
|
71
|
+
[isPressableRoot, isPressed, isHovered, disabled, crossAlign],
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
if (asChildInteractive) {
|
|
75
|
+
const child = children as React.ReactElement<Record<string, unknown>>;
|
|
76
|
+
|
|
77
|
+
const mergedOnPress = composeEventHandlers(
|
|
78
|
+
child.props.onPress as IListItemProps['onPress'],
|
|
79
|
+
onPress,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const childDisabled = !!(child.props as { disabled?: boolean }).disabled;
|
|
83
|
+
|
|
84
|
+
const resolvedDisabled = disabled || childDisabled;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<ListItemProvider
|
|
88
|
+
value={{
|
|
89
|
+
isPressed: false,
|
|
90
|
+
isHovered: false,
|
|
91
|
+
isDisabled: resolvedDisabled,
|
|
92
|
+
crossAlign: crossAlign ?? 'center',
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
{React.cloneElement(child, {
|
|
96
|
+
...restProps,
|
|
97
|
+
...slotAttrs,
|
|
98
|
+
...dataAttributes({
|
|
99
|
+
active: false,
|
|
100
|
+
hovered: false,
|
|
101
|
+
disabled: resolvedDisabled,
|
|
102
|
+
}),
|
|
103
|
+
...(resolvedDisabled && { accessibilityState: { disabled: true } }),
|
|
104
|
+
disabled: resolvedDisabled,
|
|
105
|
+
onPress: resolvedDisabled ? undefined : mergedOnPress,
|
|
106
|
+
ref: mergeRefs(ref, child.props.ref as React.Ref<unknown>),
|
|
107
|
+
style: [rowStyleForCrossAlign(crossAlign), style, child.props.style],
|
|
108
|
+
})}
|
|
109
|
+
</ListItemProvider>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (isPressableRoot) {
|
|
114
|
+
const interactionAttrs = dataAttributes({
|
|
115
|
+
active: isPressed,
|
|
116
|
+
hovered: isHovered,
|
|
117
|
+
disabled,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const {
|
|
121
|
+
onPressIn: onPressInProp,
|
|
122
|
+
onPressOut: onPressOutProp,
|
|
123
|
+
onHoverIn: onHoverInProp,
|
|
124
|
+
onHoverOut: onHoverOutProp,
|
|
125
|
+
} = restProps as IListItemPressablePassthrough;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<ListItemProvider value={contextValue}>
|
|
129
|
+
<BasePressable
|
|
130
|
+
{...(restProps as P)}
|
|
131
|
+
{...slotAttrs}
|
|
132
|
+
{...interactionAttrs}
|
|
133
|
+
{...(disabled && { accessibilityState: { disabled: true } })}
|
|
134
|
+
disabled={disabled}
|
|
135
|
+
ref={ref as React.Ref<P>}
|
|
136
|
+
style={[rowStyleForCrossAlign(crossAlign), style]}
|
|
137
|
+
onPress={disabled ? undefined : onPress}
|
|
138
|
+
onPressIn={composeEventHandlers(onPressInProp, pressProps.onPressIn)}
|
|
139
|
+
onPressOut={composeEventHandlers(onPressOutProp, pressProps.onPressOut)}
|
|
140
|
+
onHoverIn={composeEventHandlers(onHoverInProp, hoverProps.onHoverIn)}
|
|
141
|
+
onHoverOut={composeEventHandlers(onHoverOutProp, hoverProps.onHoverOut)}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</BasePressable>
|
|
145
|
+
</ListItemProvider>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<ListItemProvider value={contextValue}>
|
|
151
|
+
<BaseView
|
|
152
|
+
{...(restProps as V)}
|
|
153
|
+
{...slotAttrs}
|
|
154
|
+
{...(disabled ? dataAttributes({ disabled: true }) : undefined)}
|
|
155
|
+
ref={ref as React.Ref<V>}
|
|
156
|
+
style={[rowStyleForCrossAlign(crossAlign), style]}
|
|
157
|
+
>
|
|
158
|
+
{children}
|
|
159
|
+
</BaseView>
|
|
160
|
+
</ListItemProvider>
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
4
|
+
import type { IListItemSectionHeaderProps } from './types';
|
|
5
|
+
|
|
6
|
+
const row = {
|
|
7
|
+
flexDirection: 'row' as const,
|
|
8
|
+
alignItems: 'center' as const,
|
|
9
|
+
justifyContent: 'space-between' as const,
|
|
10
|
+
gap: 8,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const labelCell = {
|
|
14
|
+
flex: 1,
|
|
15
|
+
minWidth: 0,
|
|
16
|
+
/** Keeps the label column from stretching to a taller trailing sibling (e.g. Chip). */
|
|
17
|
+
alignSelf: 'center' as const,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const trailingCell = {
|
|
21
|
+
flexShrink: 0,
|
|
22
|
+
/** Prevents the trailing slot from stretching vertically and “filling” the row. */
|
|
23
|
+
alignSelf: 'center' as const,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const createListItemSectionHeader = <T,>(Base: React.ComponentType<T>) =>
|
|
27
|
+
forwardRef(
|
|
28
|
+
(
|
|
29
|
+
{
|
|
30
|
+
children,
|
|
31
|
+
trailing,
|
|
32
|
+
showDivider = true,
|
|
33
|
+
style,
|
|
34
|
+
accessibilityRole = 'header',
|
|
35
|
+
...props
|
|
36
|
+
}: IListItemSectionHeaderProps,
|
|
37
|
+
ref: React.Ref<unknown>,
|
|
38
|
+
) => (
|
|
39
|
+
<Base
|
|
40
|
+
{...(props as T)}
|
|
41
|
+
{...dataAttributes({
|
|
42
|
+
slot: 'list-section-header',
|
|
43
|
+
divider: showDivider,
|
|
44
|
+
})}
|
|
45
|
+
accessibilityRole={accessibilityRole}
|
|
46
|
+
ref={ref as React.Ref<T>}
|
|
47
|
+
style={[row, style]}
|
|
48
|
+
>
|
|
49
|
+
<View style={labelCell}>{children}</View>
|
|
50
|
+
{trailing ? <View style={trailingCell}>{trailing}</View> : null}
|
|
51
|
+
</Base>
|
|
52
|
+
),
|
|
53
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemTitleProps } from './types';
|
|
4
|
+
|
|
5
|
+
export const createListItemTitle = <T,>(Base: React.ComponentType<T>) =>
|
|
6
|
+
forwardRef(({ children, style, ...props }: IListItemTitleProps, ref: React.Ref<unknown>) => (
|
|
7
|
+
<Base
|
|
8
|
+
{...(props as T)}
|
|
9
|
+
{...dataAttributes({
|
|
10
|
+
slot: 'list-item-title',
|
|
11
|
+
})}
|
|
12
|
+
ref={ref as React.Ref<T>}
|
|
13
|
+
style={style}
|
|
14
|
+
>
|
|
15
|
+
{children}
|
|
16
|
+
</Base>
|
|
17
|
+
));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
+
import type { IListItemTrailingSlotProps } from './types';
|
|
4
|
+
|
|
5
|
+
const shrinkZero = { flexShrink: 0 as const };
|
|
6
|
+
|
|
7
|
+
export const createListItemTrailingSlot = <T,>(Base: React.ComponentType<T>) =>
|
|
8
|
+
forwardRef(
|
|
9
|
+
({ children, style, ...props }: IListItemTrailingSlotProps, ref: React.Ref<unknown>) => (
|
|
10
|
+
<Base
|
|
11
|
+
{...(props as T)}
|
|
12
|
+
{...dataAttributes({
|
|
13
|
+
slot: 'list-item-trailing',
|
|
14
|
+
})}
|
|
15
|
+
ref={ref as React.Ref<T>}
|
|
16
|
+
style={[shrinkZero, style]}
|
|
17
|
+
>
|
|
18
|
+
{children}
|
|
19
|
+
</Base>
|
|
20
|
+
),
|
|
21
|
+
);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { createListItemContent } from './createListItemContent';
|
|
3
|
+
import { createListItemDescription } from './createListItemDescription';
|
|
4
|
+
import { createListItemLeadingSlot } from './createListItemLeadingSlot';
|
|
5
|
+
import { createListItemMeta } from './createListItemMeta';
|
|
6
|
+
import { createListItemRoot } from './createListItemRoot';
|
|
7
|
+
import { createListItemSectionHeader } from './createListItemSectionHeader';
|
|
8
|
+
import { createListItemTitle } from './createListItemTitle';
|
|
9
|
+
import { createListItemTrailingSlot } from './createListItemTrailingSlot';
|
|
10
|
+
import type { IListItemComponentType } from './types';
|
|
11
|
+
|
|
12
|
+
export type {
|
|
13
|
+
IListItemComponentType,
|
|
14
|
+
IListItemContentProps,
|
|
15
|
+
IListItemContextValue,
|
|
16
|
+
IListItemDescriptionProps,
|
|
17
|
+
IListItemLeadingSlotProps,
|
|
18
|
+
IListItemMetaProps,
|
|
19
|
+
IListItemPressablePassthrough,
|
|
20
|
+
IListItemProps,
|
|
21
|
+
IListItemSectionHeaderProps,
|
|
22
|
+
IListItemTitleProps,
|
|
23
|
+
IListItemTrailingSlotProps,
|
|
24
|
+
ListItemCrossAlign,
|
|
25
|
+
ListItemSize,
|
|
26
|
+
ListItemSurface,
|
|
27
|
+
} from './types';
|
|
28
|
+
|
|
29
|
+
export { ListItemProvider, useListItemContext } from './context';
|
|
30
|
+
|
|
31
|
+
export function createListItem<
|
|
32
|
+
ViewComponent,
|
|
33
|
+
PressableComponent,
|
|
34
|
+
LeadingSlot,
|
|
35
|
+
Content,
|
|
36
|
+
Title,
|
|
37
|
+
Description,
|
|
38
|
+
Meta,
|
|
39
|
+
TrailingSlot,
|
|
40
|
+
SectionHeader,
|
|
41
|
+
>(BaseComponents: {
|
|
42
|
+
View: React.ComponentType<ViewComponent>;
|
|
43
|
+
Pressable: React.ComponentType<PressableComponent>;
|
|
44
|
+
LeadingSlot: React.ComponentType<LeadingSlot>;
|
|
45
|
+
Content: React.ComponentType<Content>;
|
|
46
|
+
Title: React.ComponentType<Title>;
|
|
47
|
+
Description: React.ComponentType<Description>;
|
|
48
|
+
Meta: React.ComponentType<Meta>;
|
|
49
|
+
TrailingSlot: React.ComponentType<TrailingSlot>;
|
|
50
|
+
SectionHeader: React.ComponentType<SectionHeader>;
|
|
51
|
+
}) {
|
|
52
|
+
const ListItem = createListItemRoot(BaseComponents.View, BaseComponents.Pressable);
|
|
53
|
+
const LeadingSlot = createListItemLeadingSlot(BaseComponents.LeadingSlot);
|
|
54
|
+
const Content = createListItemContent(BaseComponents.Content);
|
|
55
|
+
const Title = createListItemTitle(BaseComponents.Title);
|
|
56
|
+
const Description = createListItemDescription(BaseComponents.Description);
|
|
57
|
+
const Meta = createListItemMeta(BaseComponents.Meta);
|
|
58
|
+
const TrailingSlot = createListItemTrailingSlot(BaseComponents.TrailingSlot);
|
|
59
|
+
const SectionHeader = createListItemSectionHeader(BaseComponents.SectionHeader);
|
|
60
|
+
|
|
61
|
+
ListItem.displayName = 'ListItemPrimitive';
|
|
62
|
+
LeadingSlot.displayName = 'ListItemPrimitive.LeadingSlot';
|
|
63
|
+
Content.displayName = 'ListItemPrimitive.Content';
|
|
64
|
+
Title.displayName = 'ListItemPrimitive.Title';
|
|
65
|
+
Description.displayName = 'ListItemPrimitive.Description';
|
|
66
|
+
Meta.displayName = 'ListItemPrimitive.Meta';
|
|
67
|
+
TrailingSlot.displayName = 'ListItemPrimitive.TrailingSlot';
|
|
68
|
+
SectionHeader.displayName = 'ListItemPrimitive.SectionHeader';
|
|
69
|
+
|
|
70
|
+
return Object.assign(ListItem, {
|
|
71
|
+
LeadingSlot,
|
|
72
|
+
Content,
|
|
73
|
+
Title,
|
|
74
|
+
Description,
|
|
75
|
+
Meta,
|
|
76
|
+
TrailingSlot,
|
|
77
|
+
SectionHeader,
|
|
78
|
+
}) as IListItemComponentType<
|
|
79
|
+
ViewComponent | PressableComponent,
|
|
80
|
+
LeadingSlot,
|
|
81
|
+
Content,
|
|
82
|
+
Title,
|
|
83
|
+
Description,
|
|
84
|
+
Meta,
|
|
85
|
+
TrailingSlot,
|
|
86
|
+
SectionHeader
|
|
87
|
+
>;
|
|
88
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
2
|
+
import type { PressableProps, TextProps, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type ListItemSize = 'default' | 'compact';
|
|
5
|
+
|
|
6
|
+
export type ListItemSurface = 'default' | 'negative';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Cross-axis alignment for the row (`flex-direction: row`).
|
|
10
|
+
* - **center**: Leading, content, and trailing are vertically centered (typical transactions).
|
|
11
|
+
* - **start**: Top-aligned — use when trailing text should align with the title row (e.g. branch distance “2.04 mi”) or status chips sit above a tall content stack.
|
|
12
|
+
*/
|
|
13
|
+
export type ListItemCrossAlign = 'center' | 'start';
|
|
14
|
+
|
|
15
|
+
export type IListItemPressablePassthrough = Partial<
|
|
16
|
+
Pick<PressableProps, 'onPressIn' | 'onPressOut' | 'onHoverIn' | 'onHoverOut'>
|
|
17
|
+
>;
|
|
18
|
+
|
|
19
|
+
export interface IListItemProps extends ViewProps, IListItemPressablePassthrough {
|
|
20
|
+
/**
|
|
21
|
+
* Disables press handling when the root is pressable (maps to Pressable `disabled`).
|
|
22
|
+
*/
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* When set (and `asChild` is not used), root renders as pressable with interaction props.
|
|
26
|
+
*/
|
|
27
|
+
onPress?: PressableProps['onPress'];
|
|
28
|
+
/**
|
|
29
|
+
* Vertical density; mapped at styled layer via `data-size`.
|
|
30
|
+
* @default 'default'
|
|
31
|
+
*/
|
|
32
|
+
size?: ListItemSize;
|
|
33
|
+
/**
|
|
34
|
+
* Semantic row surface (e.g. canceled transaction); mapped via `data-surface`.
|
|
35
|
+
* @default 'default'
|
|
36
|
+
*/
|
|
37
|
+
surface?: ListItemSurface;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the row shows a bottom separator; mapped via `data-separator`.
|
|
40
|
+
* @default true
|
|
41
|
+
*/
|
|
42
|
+
showSeparator?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Vertical alignment of leading / content / trailing along the row cross axis.
|
|
45
|
+
* @default 'center'
|
|
46
|
+
*/
|
|
47
|
+
crossAlign?: ListItemCrossAlign;
|
|
48
|
+
/**
|
|
49
|
+
* Merge interaction props onto a single child instead of rendering the default pressable root.
|
|
50
|
+
* Intended for use with `onPress`.
|
|
51
|
+
*/
|
|
52
|
+
asChild?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IListItemContextValue {
|
|
56
|
+
isPressed: boolean;
|
|
57
|
+
isHovered: boolean;
|
|
58
|
+
isDisabled: boolean;
|
|
59
|
+
crossAlign: ListItemCrossAlign;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface IListItemLeadingSlotProps extends ViewProps {
|
|
63
|
+
/**
|
|
64
|
+
* Decorative leading content defaults to hidden from the accessibility tree.
|
|
65
|
+
* Set to `false` when the leading region contains meaningful controls.
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
'aria-hidden'?: boolean;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type IListItemContentProps = ViewProps;
|
|
72
|
+
|
|
73
|
+
export type IListItemTitleProps = TextProps;
|
|
74
|
+
|
|
75
|
+
export type IListItemDescriptionProps = TextProps;
|
|
76
|
+
|
|
77
|
+
export type IListItemMetaProps = TextProps;
|
|
78
|
+
|
|
79
|
+
export type IListItemTrailingSlotProps = ViewProps;
|
|
80
|
+
|
|
81
|
+
export interface IListItemSectionHeaderProps extends ViewProps {
|
|
82
|
+
/** Primary section label (e.g. date heading). */
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
/** Optional right-aligned adornment (e.g. section Chip). */
|
|
85
|
+
trailing?: ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Whether to expose the top divider marker for styling (`data-divider`).
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
showDivider?: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type IListItemComponentType<
|
|
94
|
+
RootRef,
|
|
95
|
+
LeadingSlot,
|
|
96
|
+
Content,
|
|
97
|
+
Title,
|
|
98
|
+
Description,
|
|
99
|
+
Meta,
|
|
100
|
+
TrailingSlot,
|
|
101
|
+
SectionHeader,
|
|
102
|
+
> = ForwardRefExoticComponent<RefAttributes<RootRef> & IListItemProps> & {
|
|
103
|
+
LeadingSlot: ForwardRefExoticComponent<
|
|
104
|
+
RefAttributes<LeadingSlot> & PropsWithoutRef<LeadingSlot> & IListItemLeadingSlotProps
|
|
105
|
+
>;
|
|
106
|
+
Content: ForwardRefExoticComponent<
|
|
107
|
+
RefAttributes<Content> & PropsWithoutRef<Content> & IListItemContentProps
|
|
108
|
+
>;
|
|
109
|
+
Title: ForwardRefExoticComponent<
|
|
110
|
+
RefAttributes<Title> & PropsWithoutRef<Title> & IListItemTitleProps
|
|
111
|
+
>;
|
|
112
|
+
Description: ForwardRefExoticComponent<
|
|
113
|
+
RefAttributes<Description> & PropsWithoutRef<Description> & IListItemDescriptionProps
|
|
114
|
+
>;
|
|
115
|
+
Meta: ForwardRefExoticComponent<RefAttributes<Meta> & PropsWithoutRef<Meta> & IListItemMetaProps>;
|
|
116
|
+
TrailingSlot: ForwardRefExoticComponent<
|
|
117
|
+
RefAttributes<TrailingSlot> & PropsWithoutRef<TrailingSlot> & IListItemTrailingSlotProps
|
|
118
|
+
>;
|
|
119
|
+
SectionHeader: ForwardRefExoticComponent<
|
|
120
|
+
RefAttributes<SectionHeader> & PropsWithoutRef<SectionHeader> & IListItemSectionHeaderProps
|
|
121
|
+
>;
|
|
122
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createContext } from '@cdx-ui/utils';
|
|
2
|
+
import type { OtpInputCellIndexContextValue, OtpInputContextValue } from './types';
|
|
3
|
+
|
|
4
|
+
export const [OtpInputProvider, useOtpInputContext] =
|
|
5
|
+
createContext<OtpInputContextValue>('OtpInputContext');
|
|
6
|
+
|
|
7
|
+
export const [OtpCellIndexProvider, useOtpCellIndexContext] =
|
|
8
|
+
createContext<OtpInputCellIndexContextValue>('OtpCellIndexContext');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { PropsWithChildren } from 'react';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { useOtpInputContext } from './context';
|
|
5
|
+
import type { IOtpInputCellProps } from './types';
|
|
6
|
+
|
|
7
|
+
export const createOtpInputCell = <T,>(BaseCell: React.ComponentType<T>) =>
|
|
8
|
+
forwardRef<unknown, PropsWithChildren<IOtpInputCellProps & T>>(({ children, ...props }, ref) => {
|
|
9
|
+
const { isDisabled, isInvalid, isReadOnly } = useOtpInputContext();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<BaseCell
|
|
13
|
+
ref={ref}
|
|
14
|
+
isDisabled={isDisabled}
|
|
15
|
+
isInvalid={isInvalid}
|
|
16
|
+
isReadOnly={isReadOnly}
|
|
17
|
+
{...(props as T)}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</BaseCell>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { Platform, type TextInput, type TextInputKeyPressEvent } from 'react-native';
|
|
4
|
+
import { mergeRefs } from '@cdx-ui/utils';
|
|
5
|
+
import { useOtpCellIndexContext, useOtpInputContext } from './context';
|
|
6
|
+
import type { IOtpInputFieldProps } from './types';
|
|
7
|
+
|
|
8
|
+
export const createOtpInputField = <T,>(BaseField: React.ComponentType<T>) =>
|
|
9
|
+
forwardRef<TextInput, IOtpInputFieldProps & Omit<T, keyof IOtpInputFieldProps>>((props, ref) => {
|
|
10
|
+
const { cellIndex } = useOtpCellIndexContext();
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
cellCount,
|
|
14
|
+
isDisabled,
|
|
15
|
+
isReadOnly,
|
|
16
|
+
smsOtpAutofill,
|
|
17
|
+
getCellProps,
|
|
18
|
+
cellTestIdPrefix,
|
|
19
|
+
rootAccessibilityLabel,
|
|
20
|
+
setFieldRef,
|
|
21
|
+
handleFieldChange,
|
|
22
|
+
handleFieldKeyPress,
|
|
23
|
+
} = useOtpInputContext();
|
|
24
|
+
|
|
25
|
+
const char = cellIndex < value.length ? (value[cellIndex] ?? '') : '';
|
|
26
|
+
const extra = getCellProps?.(cellIndex) ?? {};
|
|
27
|
+
|
|
28
|
+
const accessibilityLabel = useMemo(() => {
|
|
29
|
+
const fromExtra = extra.accessibilityLabel;
|
|
30
|
+
if (typeof fromExtra === 'string' && fromExtra !== '') {
|
|
31
|
+
return fromExtra;
|
|
32
|
+
}
|
|
33
|
+
if (rootAccessibilityLabel) {
|
|
34
|
+
return `${rootAccessibilityLabel}, ${String(cellIndex + 1)} of ${String(cellCount)}`;
|
|
35
|
+
}
|
|
36
|
+
return `OTP digit ${String(cellIndex + 1)} of ${String(cellCount)}`;
|
|
37
|
+
}, [cellCount, cellIndex, extra.accessibilityLabel, rootAccessibilityLabel]);
|
|
38
|
+
|
|
39
|
+
const autofillProps = useMemo(() => {
|
|
40
|
+
if (!smsOtpAutofill || cellIndex !== 0) {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
return Platform.select<Record<string, unknown>>({
|
|
44
|
+
web: { autoComplete: 'one-time-code' },
|
|
45
|
+
ios: { textContentType: 'oneTimeCode' },
|
|
46
|
+
android: { autoComplete: 'sms-otp' },
|
|
47
|
+
default: {},
|
|
48
|
+
});
|
|
49
|
+
}, [cellIndex, smsOtpAutofill]);
|
|
50
|
+
|
|
51
|
+
const editable = !(isDisabled || isReadOnly);
|
|
52
|
+
|
|
53
|
+
const { style: extraStyle, accessibilityLabel: _omitExtraA11y, ...extraRest } = extra;
|
|
54
|
+
void _omitExtraA11y;
|
|
55
|
+
const {
|
|
56
|
+
style: incomingStyle,
|
|
57
|
+
value: _omitValue,
|
|
58
|
+
defaultValue: _omitDefault,
|
|
59
|
+
onChangeText: _omitOnChange,
|
|
60
|
+
...incomingRest
|
|
61
|
+
} = props as IOtpInputFieldProps;
|
|
62
|
+
void _omitValue;
|
|
63
|
+
void _omitDefault;
|
|
64
|
+
void _omitOnChange;
|
|
65
|
+
|
|
66
|
+
// Default digit OTP (`number-pad`). Root `getCellProps` is spread after and may override `keyboardType`.
|
|
67
|
+
return (
|
|
68
|
+
<BaseField
|
|
69
|
+
ref={mergeRefs(ref, (el: TextInput | null) => {
|
|
70
|
+
setFieldRef(cellIndex, el);
|
|
71
|
+
})}
|
|
72
|
+
accessibilityLabel={accessibilityLabel}
|
|
73
|
+
aria-label={accessibilityLabel}
|
|
74
|
+
accessible
|
|
75
|
+
autoFocus={cellIndex === 0 && editable && value.length === 0}
|
|
76
|
+
editable={editable}
|
|
77
|
+
keyboardType="number-pad"
|
|
78
|
+
returnKeyType="done"
|
|
79
|
+
selectTextOnFocus
|
|
80
|
+
testID={
|
|
81
|
+
cellTestIdPrefix
|
|
82
|
+
? `${cellTestIdPrefix}:${String(cellIndex)}:textField:changeText`
|
|
83
|
+
: undefined
|
|
84
|
+
}
|
|
85
|
+
value={char}
|
|
86
|
+
onChangeText={(text: string) => {
|
|
87
|
+
handleFieldChange(cellIndex, text);
|
|
88
|
+
}}
|
|
89
|
+
onKeyPress={(e: TextInputKeyPressEvent) => {
|
|
90
|
+
handleFieldKeyPress(cellIndex, e.nativeEvent.key);
|
|
91
|
+
}}
|
|
92
|
+
{...autofillProps}
|
|
93
|
+
{...(extraRest as object)}
|
|
94
|
+
{...(incomingRest as T)}
|
|
95
|
+
style={[extraStyle, incomingStyle]}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
});
|