@cdx-ui/primitives 0.0.1-beta.9 → 0.0.1-beta.90
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 +67 -32
- package/lib/commonjs/CLAUDE.md +84 -0
- package/lib/commonjs/avatar/AvatarRoot.js +38 -0
- package/lib/commonjs/avatar/AvatarRoot.js.map +1 -0
- package/lib/commonjs/avatar/index.js +14 -24
- package/lib/commonjs/avatar/index.js.map +1 -1
- package/lib/commonjs/button/ButtonRoot.js +85 -0
- package/lib/commonjs/button/ButtonRoot.js.map +1 -0
- package/lib/commonjs/button/index.js +7 -24
- package/lib/commonjs/button/index.js.map +1 -1
- package/lib/commonjs/checkbox/CheckboxGroup.js +52 -0
- package/lib/commonjs/checkbox/CheckboxGroup.js.map +1 -0
- package/lib/commonjs/checkbox/CheckboxRoot.js +103 -0
- package/lib/commonjs/checkbox/CheckboxRoot.js.map +1 -0
- package/lib/commonjs/checkbox/CheckboxRoot.web.js +94 -0
- package/lib/commonjs/checkbox/CheckboxRoot.web.js.map +1 -0
- package/lib/commonjs/checkbox/index.js +21 -24
- package/lib/commonjs/checkbox/index.js.map +1 -1
- package/lib/commonjs/chip/ChipRoot.js +147 -0
- package/lib/commonjs/chip/ChipRoot.js.map +1 -0
- package/lib/commonjs/chip/context.js +11 -0
- package/lib/commonjs/chip/context.js.map +1 -0
- package/lib/commonjs/chip/index.js +20 -0
- package/lib/commonjs/chip/index.js.map +1 -0
- package/lib/commonjs/chip/types.js.map +1 -0
- package/lib/commonjs/dialog/DialogClose.js +32 -0
- package/lib/commonjs/dialog/DialogClose.js.map +1 -0
- package/lib/commonjs/dialog/DialogPopup.js +161 -0
- package/lib/commonjs/dialog/DialogPopup.js.map +1 -0
- package/lib/commonjs/dialog/DialogRoot.js +57 -0
- package/lib/commonjs/dialog/DialogRoot.js.map +1 -0
- package/lib/commonjs/dialog/DialogTrigger.js +32 -0
- package/lib/commonjs/dialog/DialogTrigger.js.map +1 -0
- package/lib/commonjs/dialog/index.js +28 -41
- package/lib/commonjs/dialog/index.js.map +1 -1
- package/lib/commonjs/field/FieldLabel.js +48 -0
- package/lib/commonjs/field/FieldLabel.js.map +1 -0
- package/lib/commonjs/field/FieldLabel.web.js +60 -0
- package/lib/commonjs/field/FieldLabel.web.js.map +1 -0
- package/lib/commonjs/field/FieldRoot.js +38 -0
- package/lib/commonjs/field/FieldRoot.js.map +1 -0
- package/lib/commonjs/field/index.js +14 -40
- package/lib/commonjs/field/index.js.map +1 -1
- package/lib/commonjs/form/FormRoot.js +25 -0
- package/lib/commonjs/form/FormRoot.js.map +1 -0
- package/lib/commonjs/form/FormRoot.web.js +27 -0
- package/lib/commonjs/form/FormRoot.web.js.map +1 -0
- package/lib/commonjs/form/index.js +7 -9
- package/lib/commonjs/form/index.js.map +1 -1
- package/lib/commonjs/full-window-overlay/index.js +47 -0
- package/lib/commonjs/full-window-overlay/index.js.map +1 -0
- package/lib/commonjs/full-window-overlay/index.web.js +19 -0
- package/lib/commonjs/full-window-overlay/index.web.js.map +1 -0
- package/lib/commonjs/index.js +122 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/input/InputField.android.js +98 -0
- package/lib/commonjs/input/InputField.android.js.map +1 -0
- package/lib/commonjs/input/InputField.js +92 -0
- package/lib/commonjs/input/InputField.js.map +1 -0
- package/lib/commonjs/input/InputField.web.js +131 -0
- package/lib/commonjs/input/InputField.web.js.map +1 -0
- package/lib/commonjs/input/InputRoot.js +84 -0
- package/lib/commonjs/input/InputRoot.js.map +1 -0
- package/lib/commonjs/input/index.js +21 -16
- package/lib/commonjs/input/index.js.map +1 -1
- package/lib/commonjs/link/LinkRoot.js +88 -0
- package/lib/commonjs/link/LinkRoot.js.map +1 -0
- package/lib/commonjs/link/context.js +11 -0
- package/lib/commonjs/link/context.js.map +1 -0
- package/lib/commonjs/link/index.js +16 -3
- package/lib/commonjs/link/index.js.map +1 -1
- package/lib/commonjs/list-item/ListItemRoot.js +149 -0
- package/lib/commonjs/list-item/ListItemRoot.js.map +1 -0
- package/lib/commonjs/list-item/context.js.map +1 -1
- package/lib/commonjs/list-item/index.js +7 -36
- package/lib/commonjs/list-item/index.js.map +1 -1
- package/lib/commonjs/otp-input/OtpInputField.js +120 -0
- package/lib/commonjs/otp-input/OtpInputField.js.map +1 -0
- package/lib/commonjs/otp-input/index.js +39 -16
- package/lib/commonjs/otp-input/index.js.map +1 -1
- package/lib/commonjs/otp-input/useOtpInput.js +120 -0
- package/lib/commonjs/otp-input/useOtpInput.js.map +1 -0
- package/lib/commonjs/overlay/useDismissOverlay.js +0 -2
- package/lib/commonjs/overlay/useDismissOverlay.js.map +1 -1
- package/lib/commonjs/overlay/useEscapeKey.js +0 -2
- package/lib/commonjs/overlay/useEscapeKey.js.map +1 -1
- package/lib/commonjs/portal/index.js +17 -0
- package/lib/commonjs/portal/index.js.map +1 -0
- package/lib/commonjs/portal/portal.js +110 -0
- package/lib/commonjs/portal/portal.js.map +1 -0
- package/lib/commonjs/progress-bar/ProgressBarIndicator.js +45 -0
- package/lib/commonjs/progress-bar/ProgressBarIndicator.js.map +1 -0
- package/lib/commonjs/progress-bar/ProgressBarRoot.js +100 -0
- package/lib/commonjs/progress-bar/ProgressBarRoot.js.map +1 -0
- package/lib/commonjs/progress-bar/context.js.map +1 -0
- package/lib/commonjs/progress-bar/index.js +27 -0
- package/lib/commonjs/progress-bar/index.js.map +1 -0
- package/lib/commonjs/progress-bar/types.js +6 -0
- package/lib/commonjs/progress-bar/types.js.map +1 -0
- package/lib/commonjs/radio/RadioGroup.js +74 -0
- package/lib/commonjs/radio/RadioGroup.js.map +1 -0
- package/lib/commonjs/radio/RadioRoot.js +99 -0
- package/lib/commonjs/radio/RadioRoot.js.map +1 -0
- package/lib/commonjs/radio/RadioRoot.web.js +91 -0
- package/lib/commonjs/radio/RadioRoot.web.js.map +1 -0
- package/lib/commonjs/radio/context.js +14 -0
- package/lib/commonjs/radio/context.js.map +1 -0
- package/lib/commonjs/radio/index.js +27 -0
- package/lib/commonjs/radio/index.js.map +1 -0
- package/lib/commonjs/radio/types.js +6 -0
- package/lib/commonjs/radio/types.js.map +1 -0
- package/lib/commonjs/radio/useRadioRoot.js +64 -0
- package/lib/commonjs/radio/useRadioRoot.js.map +1 -0
- package/lib/commonjs/select/SelectContent.js +105 -0
- package/lib/commonjs/select/SelectContent.js.map +1 -0
- package/lib/commonjs/select/SelectItem.js +104 -0
- package/lib/commonjs/select/SelectItem.js.map +1 -0
- package/lib/commonjs/select/SelectRoot.js +105 -0
- package/lib/commonjs/select/SelectRoot.js.map +1 -0
- package/lib/commonjs/select/SelectTrigger.js +72 -0
- package/lib/commonjs/select/SelectTrigger.js.map +1 -0
- package/lib/commonjs/select/SelectTrigger.web.js +175 -0
- package/lib/commonjs/select/SelectTrigger.web.js.map +1 -0
- package/lib/commonjs/select/context.js +3 -12
- package/lib/commonjs/select/context.js.map +1 -1
- package/lib/commonjs/select/index.js +41 -32
- package/lib/commonjs/select/index.js.map +1 -1
- package/lib/commonjs/select/useContentFocus.js +1 -1
- package/lib/commonjs/select/useSelectTrigger.js +206 -0
- package/lib/commonjs/select/useSelectTrigger.js.map +1 -0
- package/lib/commonjs/select/useSelectTrigger.web.js +192 -0
- package/lib/commonjs/select/useSelectTrigger.web.js.map +1 -0
- package/lib/commonjs/slot/index.js +141 -0
- package/lib/commonjs/slot/index.js.map +1 -0
- package/lib/commonjs/switch/index.js +7 -9
- package/lib/commonjs/switch/index.js.map +1 -1
- package/lib/commonjs/switch/useSwitch.js +81 -0
- package/lib/commonjs/switch/useSwitch.js.map +1 -0
- package/lib/commonjs/tile/TileGroup.js +111 -0
- package/lib/commonjs/tile/TileGroup.js.map +1 -0
- package/lib/commonjs/tile/TileRoot.js +129 -0
- package/lib/commonjs/tile/TileRoot.js.map +1 -0
- package/lib/commonjs/tile/context.js +30 -0
- package/lib/commonjs/tile/context.js.map +1 -0
- package/lib/commonjs/tile/index.js +33 -0
- package/lib/commonjs/tile/index.js.map +1 -0
- package/lib/commonjs/tile/types.js +6 -0
- package/lib/commonjs/tile/types.js.map +1 -0
- package/lib/commonjs/toast/ToastRoot.js +41 -0
- package/lib/commonjs/toast/ToastRoot.js.map +1 -0
- package/lib/commonjs/toast/context.js +11 -0
- package/lib/commonjs/toast/context.js.map +1 -0
- package/lib/commonjs/toast/index.js +26 -0
- package/lib/commonjs/toast/index.js.map +1 -0
- package/lib/commonjs/toast/types.js +6 -0
- package/lib/commonjs/toast/types.js.map +1 -0
- package/lib/commonjs/utils/dataAttributes.js +12 -25
- package/lib/commonjs/utils/dataAttributes.js.map +1 -1
- package/lib/commonjs/utils/dataAttributes.web.js +25 -0
- package/lib/commonjs/utils/dataAttributes.web.js.map +1 -1
- package/lib/commonjs/utils/domDataAttributes.js +64 -0
- package/lib/commonjs/utils/domDataAttributes.js.map +1 -0
- package/lib/module/CLAUDE.md +84 -0
- package/lib/module/avatar/AvatarRoot.js +34 -0
- package/lib/module/avatar/AvatarRoot.js.map +1 -0
- package/lib/module/avatar/index.js +2 -23
- package/lib/module/avatar/index.js.map +1 -1
- package/lib/module/button/ButtonRoot.js +81 -0
- package/lib/module/button/ButtonRoot.js.map +1 -0
- package/lib/module/button/index.js +1 -23
- package/lib/module/button/index.js.map +1 -1
- package/lib/module/checkbox/CheckboxGroup.js +48 -0
- package/lib/module/checkbox/CheckboxGroup.js.map +1 -0
- package/lib/module/checkbox/CheckboxRoot.js +99 -0
- package/lib/module/checkbox/CheckboxRoot.js.map +1 -0
- package/lib/module/checkbox/CheckboxRoot.web.js +90 -0
- package/lib/module/checkbox/CheckboxRoot.web.js.map +1 -0
- package/lib/module/checkbox/index.js +3 -23
- package/lib/module/checkbox/index.js.map +1 -1
- package/lib/module/chip/ChipRoot.js +142 -0
- package/lib/module/chip/ChipRoot.js.map +1 -0
- package/lib/module/chip/context.js +5 -0
- package/lib/module/chip/context.js.map +1 -0
- package/lib/module/chip/index.js +5 -0
- package/lib/module/chip/index.js.map +1 -0
- package/lib/module/chip/types.js.map +1 -0
- package/lib/module/dialog/DialogClose.js +28 -0
- package/lib/module/dialog/DialogClose.js.map +1 -0
- package/lib/module/dialog/DialogPopup.js +157 -0
- package/lib/module/dialog/DialogPopup.js.map +1 -0
- package/lib/module/dialog/DialogRoot.js +53 -0
- package/lib/module/dialog/DialogRoot.js.map +1 -0
- package/lib/module/dialog/DialogTrigger.js +28 -0
- package/lib/module/dialog/DialogTrigger.js.map +1 -0
- package/lib/module/dialog/index.js +5 -42
- package/lib/module/dialog/index.js.map +1 -1
- package/lib/module/field/FieldLabel.js +44 -0
- package/lib/module/field/FieldLabel.js.map +1 -0
- package/lib/module/field/FieldLabel.web.js +55 -0
- package/lib/module/field/FieldLabel.web.js.map +1 -0
- package/lib/module/field/FieldRoot.js +34 -0
- package/lib/module/field/FieldRoot.js.map +1 -0
- package/lib/module/field/index.js +2 -39
- package/lib/module/field/index.js.map +1 -1
- package/lib/module/form/FormRoot.js +21 -0
- package/lib/module/form/FormRoot.js.map +1 -0
- package/lib/module/form/FormRoot.web.js +22 -0
- package/lib/module/form/FormRoot.web.js.map +1 -0
- package/lib/module/form/index.js +1 -8
- package/lib/module/form/index.js.map +1 -1
- package/lib/module/full-window-overlay/index.js +43 -0
- package/lib/module/full-window-overlay/index.js.map +1 -0
- package/lib/module/full-window-overlay/index.web.js +15 -0
- package/lib/module/full-window-overlay/index.web.js.map +1 -0
- package/lib/module/index.js +11 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/input/InputField.android.js +94 -0
- package/lib/module/input/InputField.android.js.map +1 -0
- package/lib/module/input/InputField.js +88 -0
- package/lib/module/input/InputField.js.map +1 -0
- package/lib/module/input/InputField.web.js +126 -0
- package/lib/module/input/InputField.web.js.map +1 -0
- package/lib/module/input/InputRoot.js +80 -0
- package/lib/module/input/InputRoot.js.map +1 -0
- package/lib/module/input/index.js +3 -15
- package/lib/module/input/index.js.map +1 -1
- package/lib/module/link/LinkRoot.js +84 -0
- package/lib/module/link/LinkRoot.js.map +1 -0
- package/lib/module/link/context.js +5 -0
- package/lib/module/link/context.js.map +1 -0
- package/lib/module/link/index.js +2 -1
- package/lib/module/link/index.js.map +1 -1
- package/lib/module/list-item/ListItemRoot.js +144 -0
- package/lib/module/list-item/ListItemRoot.js.map +1 -0
- package/lib/module/list-item/context.js.map +1 -1
- package/lib/module/list-item/index.js +1 -35
- package/lib/module/list-item/index.js.map +1 -1
- package/lib/module/otp-input/OtpInputField.js +116 -0
- package/lib/module/otp-input/OtpInputField.js.map +1 -0
- package/lib/module/otp-input/index.js +3 -15
- package/lib/module/otp-input/index.js.map +1 -1
- package/lib/module/otp-input/useOtpInput.js +116 -0
- package/lib/module/otp-input/useOtpInput.js.map +1 -0
- package/lib/module/overlay/useDismissOverlay.js +0 -2
- package/lib/module/overlay/useDismissOverlay.js.map +1 -1
- package/lib/module/overlay/useEscapeKey.js +0 -2
- package/lib/module/overlay/useEscapeKey.js.map +1 -1
- package/lib/module/portal/index.js +4 -0
- package/lib/module/portal/index.js.map +1 -0
- package/lib/module/portal/portal.js +103 -0
- package/lib/module/portal/portal.js.map +1 -0
- package/lib/module/progress-bar/ProgressBarIndicator.js +41 -0
- package/lib/module/progress-bar/ProgressBarIndicator.js.map +1 -0
- package/lib/module/progress-bar/ProgressBarRoot.js +96 -0
- package/lib/module/progress-bar/ProgressBarRoot.js.map +1 -0
- package/lib/module/progress-bar/context.js.map +1 -0
- package/lib/module/progress-bar/index.js +6 -0
- package/lib/module/progress-bar/index.js.map +1 -0
- package/lib/module/progress-bar/types.js +4 -0
- package/lib/module/progress-bar/types.js.map +1 -0
- package/lib/module/radio/RadioGroup.js +70 -0
- package/lib/module/radio/RadioGroup.js.map +1 -0
- package/lib/module/radio/RadioRoot.js +95 -0
- package/lib/module/radio/RadioRoot.js.map +1 -0
- package/lib/module/radio/RadioRoot.web.js +87 -0
- package/lib/module/radio/RadioRoot.web.js.map +1 -0
- package/lib/module/radio/context.js +7 -0
- package/lib/module/radio/context.js.map +1 -0
- package/lib/module/radio/index.js +6 -0
- package/lib/module/radio/index.js.map +1 -0
- package/lib/module/radio/types.js +4 -0
- package/lib/module/radio/types.js.map +1 -0
- package/lib/module/radio/useRadioRoot.js +60 -0
- package/lib/module/radio/useRadioRoot.js.map +1 -0
- package/lib/module/select/SelectContent.js +100 -0
- package/lib/module/select/SelectContent.js.map +1 -0
- package/lib/module/select/SelectItem.js +100 -0
- package/lib/module/select/SelectItem.js.map +1 -0
- package/lib/module/select/SelectRoot.js +101 -0
- package/lib/module/select/SelectRoot.js.map +1 -0
- package/lib/module/select/SelectTrigger.js +67 -0
- package/lib/module/select/SelectTrigger.js.map +1 -0
- package/lib/module/select/SelectTrigger.web.js +170 -0
- package/lib/module/select/SelectTrigger.web.js.map +1 -0
- package/lib/module/select/context.js +1 -8
- package/lib/module/select/context.js.map +1 -1
- package/lib/module/select/index.js +5 -31
- package/lib/module/select/index.js.map +1 -1
- package/lib/module/select/useContentFocus.js +1 -1
- package/lib/module/select/useSelectTrigger.js +202 -0
- package/lib/module/select/useSelectTrigger.js.map +1 -0
- package/lib/module/select/useSelectTrigger.web.js +188 -0
- package/lib/module/select/useSelectTrigger.web.js.map +1 -0
- package/lib/module/slot/index.js +135 -0
- package/lib/module/slot/index.js.map +1 -0
- package/lib/module/switch/index.js +1 -8
- package/lib/module/switch/index.js.map +1 -1
- package/lib/module/switch/useSwitch.js +77 -0
- package/lib/module/switch/useSwitch.js.map +1 -0
- package/lib/module/tile/TileGroup.js +107 -0
- package/lib/module/tile/TileGroup.js.map +1 -0
- package/lib/module/tile/TileRoot.js +125 -0
- package/lib/module/tile/TileRoot.js.map +1 -0
- package/lib/module/tile/context.js +21 -0
- package/lib/module/tile/context.js.map +1 -0
- package/lib/module/tile/index.js +6 -0
- package/lib/module/tile/index.js.map +1 -0
- package/lib/module/tile/types.js +4 -0
- package/lib/module/tile/types.js.map +1 -0
- package/lib/module/toast/ToastRoot.js +37 -0
- package/lib/module/toast/ToastRoot.js.map +1 -0
- package/lib/module/toast/context.js +5 -0
- package/lib/module/toast/context.js.map +1 -0
- package/lib/module/toast/index.js +5 -0
- package/lib/module/toast/index.js.map +1 -0
- package/lib/module/toast/types.js +4 -0
- package/lib/module/toast/types.js.map +1 -0
- package/lib/module/utils/dataAttributes.js +4 -22
- package/lib/module/utils/dataAttributes.js.map +1 -1
- package/lib/module/utils/dataAttributes.web.js +24 -0
- package/lib/module/utils/dataAttributes.web.js.map +1 -1
- package/lib/module/utils/domDataAttributes.js +59 -0
- package/lib/module/utils/domDataAttributes.js.map +1 -0
- package/lib/typescript/avatar/AvatarRoot.d.ts +8 -0
- package/lib/typescript/avatar/AvatarRoot.d.ts.map +1 -0
- package/lib/typescript/avatar/index.d.ts +3 -10
- package/lib/typescript/avatar/index.d.ts.map +1 -1
- package/lib/typescript/avatar/types.d.ts +1 -17
- package/lib/typescript/avatar/types.d.ts.map +1 -1
- package/lib/typescript/button/ButtonRoot.d.ts +9 -0
- package/lib/typescript/button/ButtonRoot.d.ts.map +1 -0
- package/lib/typescript/button/index.d.ts +1 -9
- package/lib/typescript/button/index.d.ts.map +1 -1
- package/lib/typescript/button/types.d.ts +1 -34
- package/lib/typescript/button/types.d.ts.map +1 -1
- package/lib/typescript/checkbox/CheckboxGroup.d.ts +9 -0
- package/lib/typescript/checkbox/CheckboxGroup.d.ts.map +1 -0
- package/lib/typescript/checkbox/CheckboxRoot.d.ts +6 -0
- package/lib/typescript/checkbox/CheckboxRoot.d.ts.map +1 -0
- package/lib/typescript/checkbox/CheckboxRoot.web.d.ts +6 -0
- package/lib/typescript/checkbox/CheckboxRoot.web.d.ts.map +1 -0
- package/lib/typescript/checkbox/index.d.ts +4 -10
- package/lib/typescript/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/checkbox/types.d.ts +0 -17
- package/lib/typescript/checkbox/types.d.ts.map +1 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts +3 -1
- package/lib/typescript/checkbox/useCheckboxRoot.d.ts.map +1 -1
- package/lib/typescript/chip/ChipRoot.d.ts +7 -0
- package/lib/typescript/chip/ChipRoot.d.ts.map +1 -0
- package/lib/typescript/chip/context.d.ts +6 -0
- package/lib/typescript/chip/context.d.ts.map +1 -0
- package/lib/typescript/chip/index.d.ts +4 -0
- package/lib/typescript/chip/index.d.ts.map +1 -0
- package/lib/typescript/chip/types.d.ts +16 -0
- package/lib/typescript/chip/types.d.ts.map +1 -0
- package/lib/typescript/dialog/DialogClose.d.ts +5 -0
- package/lib/typescript/dialog/DialogClose.d.ts.map +1 -0
- package/lib/typescript/dialog/DialogPopup.d.ts +14 -0
- package/lib/typescript/dialog/DialogPopup.d.ts.map +1 -0
- package/lib/typescript/dialog/DialogRoot.d.ts +7 -0
- package/lib/typescript/dialog/DialogRoot.d.ts.map +1 -0
- package/lib/typescript/dialog/DialogTrigger.d.ts +5 -0
- package/lib/typescript/dialog/DialogTrigger.d.ts.map +1 -0
- package/lib/typescript/dialog/index.d.ts +6 -17
- package/lib/typescript/dialog/index.d.ts.map +1 -1
- package/lib/typescript/dialog/types.d.ts +14 -25
- package/lib/typescript/dialog/types.d.ts.map +1 -1
- package/lib/typescript/field/FieldLabel.d.ts +12 -0
- package/lib/typescript/field/FieldLabel.d.ts.map +1 -0
- package/lib/typescript/field/FieldLabel.web.d.ts +24 -0
- package/lib/typescript/field/FieldLabel.web.d.ts.map +1 -0
- package/lib/typescript/field/FieldRoot.d.ts +8 -0
- package/lib/typescript/field/FieldRoot.d.ts.map +1 -0
- package/lib/typescript/field/index.d.ts +3 -12
- package/lib/typescript/field/index.d.ts.map +1 -1
- package/lib/typescript/field/types.d.ts +0 -20
- package/lib/typescript/field/types.d.ts.map +1 -1
- package/lib/typescript/form/FormRoot.d.ts +8 -0
- package/lib/typescript/form/FormRoot.d.ts.map +1 -0
- package/lib/typescript/form/FormRoot.web.d.ts +8 -0
- package/lib/typescript/form/FormRoot.web.d.ts.map +1 -0
- package/lib/typescript/form/index.d.ts +2 -5
- package/lib/typescript/form/index.d.ts.map +1 -1
- package/lib/typescript/form/types.d.ts +8 -9
- package/lib/typescript/form/types.d.ts.map +1 -1
- package/lib/typescript/full-window-overlay/index.d.ts +46 -0
- package/lib/typescript/full-window-overlay/index.d.ts.map +1 -0
- package/lib/typescript/full-window-overlay/index.web.d.ts +29 -0
- package/lib/typescript/full-window-overlay/index.web.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +11 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/input/InputField.android.d.ts +5 -0
- package/lib/typescript/input/InputField.android.d.ts.map +1 -0
- package/lib/typescript/input/InputField.d.ts +5 -0
- package/lib/typescript/input/InputField.d.ts.map +1 -0
- package/lib/typescript/input/InputField.web.d.ts +6 -0
- package/lib/typescript/input/InputField.web.d.ts.map +1 -0
- package/lib/typescript/input/InputRoot.d.ts +5 -0
- package/lib/typescript/input/InputRoot.d.ts.map +1 -0
- package/lib/typescript/input/index.d.ts +4 -8
- package/lib/typescript/input/index.d.ts.map +1 -1
- package/lib/typescript/input/types.d.ts +20 -39
- package/lib/typescript/input/types.d.ts.map +1 -1
- package/lib/typescript/link/LinkRoot.d.ts +9 -0
- package/lib/typescript/link/LinkRoot.d.ts.map +1 -0
- package/lib/typescript/link/context.d.ts +10 -0
- package/lib/typescript/link/context.d.ts.map +1 -0
- package/lib/typescript/link/index.d.ts +3 -1
- package/lib/typescript/link/index.d.ts.map +1 -1
- package/lib/typescript/link/types.d.ts +1 -0
- package/lib/typescript/link/types.d.ts.map +1 -1
- package/lib/typescript/list-item/ListItemRoot.d.ts +7 -0
- package/lib/typescript/list-item/ListItemRoot.d.ts.map +1 -0
- package/lib/typescript/list-item/context.d.ts +3 -3
- package/lib/typescript/list-item/context.d.ts.map +1 -1
- package/lib/typescript/list-item/index.d.ts +2 -14
- package/lib/typescript/list-item/index.d.ts.map +1 -1
- package/lib/typescript/list-item/types.d.ts +5 -59
- package/lib/typescript/list-item/types.d.ts.map +1 -1
- package/lib/typescript/otp-input/OtpInputField.d.ts +19 -0
- package/lib/typescript/otp-input/OtpInputField.d.ts.map +1 -0
- package/lib/typescript/otp-input/index.d.ts +4 -8
- package/lib/typescript/otp-input/index.d.ts.map +1 -1
- package/lib/typescript/otp-input/types.d.ts +0 -9
- package/lib/typescript/otp-input/types.d.ts.map +1 -1
- package/lib/typescript/otp-input/useOtpInput.d.ts +19 -0
- package/lib/typescript/otp-input/useOtpInput.d.ts.map +1 -0
- package/lib/typescript/overlay/useDismissOverlay.d.ts.map +1 -1
- package/lib/typescript/overlay/useEscapeKey.d.ts.map +1 -1
- package/lib/typescript/portal/index.d.ts +2 -0
- package/lib/typescript/portal/index.d.ts.map +1 -0
- package/lib/typescript/portal/portal.d.ts +25 -0
- package/lib/typescript/portal/portal.d.ts.map +1 -0
- package/lib/typescript/progress-bar/ProgressBarIndicator.d.ts +6 -0
- package/lib/typescript/progress-bar/ProgressBarIndicator.d.ts.map +1 -0
- package/lib/typescript/progress-bar/ProgressBarRoot.d.ts +6 -0
- package/lib/typescript/progress-bar/ProgressBarRoot.d.ts.map +1 -0
- package/lib/typescript/progress-bar/context.d.ts.map +1 -0
- package/lib/typescript/progress-bar/index.d.ts +6 -0
- package/lib/typescript/progress-bar/index.d.ts.map +1 -0
- package/lib/typescript/progress-bar/types.d.ts +22 -0
- package/lib/typescript/progress-bar/types.d.ts.map +1 -0
- package/lib/typescript/radio/RadioGroup.d.ts +9 -0
- package/lib/typescript/radio/RadioGroup.d.ts.map +1 -0
- package/lib/typescript/radio/RadioRoot.d.ts +6 -0
- package/lib/typescript/radio/RadioRoot.d.ts.map +1 -0
- package/lib/typescript/radio/RadioRoot.web.d.ts +6 -0
- package/lib/typescript/radio/RadioRoot.web.d.ts.map +1 -0
- package/lib/typescript/radio/context.d.ts +21 -0
- package/lib/typescript/radio/context.d.ts.map +1 -0
- package/lib/typescript/radio/index.d.ts +5 -0
- package/lib/typescript/radio/index.d.ts.map +1 -0
- package/lib/typescript/radio/types.d.ts +43 -0
- package/lib/typescript/radio/types.d.ts.map +1 -0
- package/lib/typescript/radio/useRadioRoot.d.ts +151 -0
- package/lib/typescript/radio/useRadioRoot.d.ts.map +1 -0
- package/lib/typescript/select/SelectContent.d.ts +9 -0
- package/lib/typescript/select/SelectContent.d.ts.map +1 -0
- package/lib/typescript/select/SelectItem.d.ts +8 -0
- package/lib/typescript/select/SelectItem.d.ts.map +1 -0
- package/lib/typescript/select/SelectRoot.d.ts +8 -0
- package/lib/typescript/select/SelectRoot.d.ts.map +1 -0
- package/lib/typescript/select/SelectTrigger.d.ts +9 -0
- package/lib/typescript/select/SelectTrigger.d.ts.map +1 -0
- package/lib/typescript/select/SelectTrigger.web.d.ts +13 -0
- package/lib/typescript/select/SelectTrigger.web.d.ts.map +1 -0
- package/lib/typescript/select/context.d.ts +1 -11
- package/lib/typescript/select/context.d.ts.map +1 -1
- package/lib/typescript/select/index.d.ts +6 -12
- package/lib/typescript/select/index.d.ts.map +1 -1
- package/lib/typescript/select/types.d.ts +1 -9
- package/lib/typescript/select/types.d.ts.map +1 -1
- package/lib/typescript/select/useContentFocus.d.ts +1 -1
- package/lib/typescript/select/useSelectTrigger.d.ts +77 -0
- package/lib/typescript/select/useSelectTrigger.d.ts.map +1 -0
- package/lib/typescript/select/useSelectTrigger.web.d.ts +16 -0
- package/lib/typescript/select/useSelectTrigger.web.d.ts.map +1 -0
- package/lib/typescript/slot/index.d.ts +8 -0
- package/lib/typescript/slot/index.d.ts.map +1 -0
- package/lib/typescript/switch/index.d.ts +2 -6
- package/lib/typescript/switch/index.d.ts.map +1 -1
- package/lib/typescript/switch/types.d.ts +35 -6
- package/lib/typescript/switch/types.d.ts.map +1 -1
- package/lib/typescript/switch/useSwitch.d.ts +20 -0
- package/lib/typescript/switch/useSwitch.d.ts.map +1 -0
- package/lib/typescript/tile/TileGroup.d.ts +5 -0
- package/lib/typescript/tile/TileGroup.d.ts.map +1 -0
- package/lib/typescript/tile/TileRoot.d.ts +5 -0
- package/lib/typescript/tile/TileRoot.d.ts.map +1 -0
- package/lib/typescript/tile/context.d.ts +9 -0
- package/lib/typescript/tile/context.d.ts.map +1 -0
- package/lib/typescript/tile/index.d.ts +5 -0
- package/lib/typescript/tile/index.d.ts.map +1 -0
- package/lib/typescript/tile/types.d.ts +108 -0
- package/lib/typescript/tile/types.d.ts.map +1 -0
- package/lib/typescript/toast/ToastRoot.d.ts +7 -0
- package/lib/typescript/toast/ToastRoot.d.ts.map +1 -0
- package/lib/typescript/toast/context.d.ts +6 -0
- package/lib/typescript/toast/context.d.ts.map +1 -0
- package/lib/typescript/toast/index.d.ts +3 -0
- package/lib/typescript/toast/index.d.ts.map +1 -0
- package/lib/typescript/toast/types.d.ts +16 -0
- package/lib/typescript/toast/types.d.ts.map +1 -0
- package/lib/typescript/utils/dataAttributes.d.ts +4 -10
- package/lib/typescript/utils/dataAttributes.d.ts.map +1 -1
- package/lib/typescript/utils/dataAttributes.web.d.ts +16 -0
- package/lib/typescript/utils/dataAttributes.web.d.ts.map +1 -1
- package/lib/typescript/utils/domDataAttributes.d.ts +28 -0
- package/lib/typescript/utils/domDataAttributes.d.ts.map +1 -0
- package/package.json +5 -2
- package/src/CLAUDE.md +84 -0
- package/src/avatar/AvatarRoot.tsx +39 -0
- package/src/avatar/index.ts +3 -43
- package/src/avatar/types.ts +1 -47
- package/src/button/ButtonRoot.tsx +115 -0
- package/src/button/index.ts +3 -0
- package/src/button/types.ts +1 -52
- package/src/checkbox/CheckboxGroup.tsx +50 -0
- package/src/checkbox/CheckboxRoot.tsx +102 -0
- package/src/checkbox/CheckboxRoot.web.tsx +92 -0
- package/src/checkbox/index.ts +4 -42
- package/src/checkbox/types.ts +1 -32
- package/src/chip/ChipRoot.tsx +168 -0
- package/src/chip/context.tsx +4 -0
- package/src/chip/index.ts +3 -0
- package/src/chip/types.ts +20 -0
- package/src/dialog/DialogClose.tsx +26 -0
- package/src/dialog/DialogPopup.tsx +162 -0
- package/src/dialog/DialogRoot.tsx +72 -0
- package/src/dialog/DialogTrigger.tsx +26 -0
- package/src/dialog/index.tsx +6 -87
- package/src/dialog/types.ts +14 -57
- package/src/field/FieldLabel.tsx +43 -0
- package/src/field/FieldLabel.web.tsx +71 -0
- package/src/field/FieldRoot.tsx +39 -0
- package/src/field/index.tsx +3 -68
- package/src/field/types.tsx +0 -34
- package/src/form/FormRoot.tsx +18 -0
- package/src/form/FormRoot.web.tsx +17 -0
- package/src/form/index.tsx +2 -12
- package/src/form/types.tsx +9 -11
- package/src/full-window-overlay/index.tsx +65 -0
- package/src/full-window-overlay/index.web.tsx +32 -0
- package/src/index.ts +15 -2
- package/src/input/InputField.android.tsx +107 -0
- package/src/input/InputField.tsx +100 -0
- package/src/input/InputField.web.tsx +141 -0
- package/src/input/InputRoot.tsx +104 -0
- package/src/input/index.tsx +4 -38
- package/src/input/types.ts +21 -53
- package/src/link/LinkRoot.tsx +108 -0
- package/src/link/context.tsx +10 -0
- package/src/link/index.tsx +3 -1
- package/src/link/types.ts +1 -0
- package/src/list-item/ListItemRoot.tsx +183 -0
- package/src/list-item/context.tsx +2 -2
- package/src/list-item/index.ts +1 -80
- package/src/list-item/types.ts +5 -89
- package/src/otp-input/OtpInputField.tsx +122 -0
- package/src/otp-input/index.ts +16 -0
- package/src/otp-input/types.ts +0 -23
- package/src/otp-input/useOtpInput.ts +156 -0
- package/src/overlay/useDismissOverlay.ts +0 -2
- package/src/overlay/useEscapeKey.ts +0 -2
- package/src/portal/index.ts +1 -0
- package/src/portal/portal.tsx +116 -0
- package/src/progress-bar/ProgressBarIndicator.tsx +34 -0
- package/src/progress-bar/ProgressBarRoot.tsx +117 -0
- package/src/progress-bar/index.ts +5 -0
- package/src/progress-bar/types.ts +24 -0
- package/src/radio/RadioGroup.tsx +85 -0
- package/src/radio/RadioRoot.tsx +98 -0
- package/src/radio/RadioRoot.web.tsx +90 -0
- package/src/radio/context.tsx +21 -0
- package/src/radio/index.ts +5 -0
- package/src/radio/types.ts +45 -0
- package/src/radio/useRadioRoot.ts +69 -0
- package/src/select/SelectContent.tsx +120 -0
- package/src/select/SelectItem.tsx +139 -0
- package/src/select/SelectRoot.tsx +154 -0
- package/src/select/SelectTrigger.tsx +82 -0
- package/src/select/SelectTrigger.web.tsx +238 -0
- package/src/select/context.tsx +1 -10
- package/src/select/index.ts +17 -0
- package/src/select/types.ts +1 -32
- package/src/select/useContentFocus.ts +1 -1
- package/src/select/useSelectTrigger.ts +345 -0
- package/src/select/useSelectTrigger.web.ts +267 -0
- package/src/slot/index.tsx +162 -0
- package/src/switch/index.ts +7 -16
- package/src/switch/types.ts +35 -10
- package/src/switch/useSwitch.ts +75 -0
- package/src/tile/TileGroup.tsx +137 -0
- package/src/tile/TileRoot.tsx +137 -0
- package/src/tile/context.tsx +23 -0
- package/src/tile/index.ts +18 -0
- package/src/tile/types.ts +121 -0
- package/src/toast/ToastRoot.tsx +39 -0
- package/src/toast/context.tsx +4 -0
- package/src/toast/index.ts +2 -0
- package/src/toast/types.ts +17 -0
- package/src/uniwind.d.ts +1 -0
- package/src/utils/dataAttributes.ts +7 -25
- package/src/utils/dataAttributes.web.ts +24 -0
- package/src/utils/domDataAttributes.ts +63 -0
- package/lib/commonjs/avatar/createAvatarBadge.js +0 -20
- package/lib/commonjs/avatar/createAvatarBadge.js.map +0 -1
- package/lib/commonjs/avatar/createAvatarIcon.js +0 -30
- package/lib/commonjs/avatar/createAvatarIcon.js.map +0 -1
- package/lib/commonjs/avatar/createAvatarImage.js +0 -51
- package/lib/commonjs/avatar/createAvatarImage.js.map +0 -1
- package/lib/commonjs/avatar/createAvatarRoot.js +0 -34
- package/lib/commonjs/avatar/createAvatarRoot.js.map +0 -1
- package/lib/commonjs/avatar/createAvatarText.js +0 -42
- package/lib/commonjs/avatar/createAvatarText.js.map +0 -1
- package/lib/commonjs/button/createButtonGroup.js +0 -80
- package/lib/commonjs/button/createButtonGroup.js.map +0 -1
- package/lib/commonjs/button/createButtonIcon.js +0 -18
- package/lib/commonjs/button/createButtonIcon.js.map +0 -1
- package/lib/commonjs/button/createButtonRoot.js +0 -81
- package/lib/commonjs/button/createButtonRoot.js.map +0 -1
- package/lib/commonjs/button/createButtonSpinner.js +0 -34
- package/lib/commonjs/button/createButtonSpinner.js.map +0 -1
- package/lib/commonjs/button/createButtonText.js +0 -38
- package/lib/commonjs/button/createButtonText.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxGroup.js +0 -44
- package/lib/commonjs/checkbox/createCheckboxGroup.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxIcon.js +0 -29
- package/lib/commonjs/checkbox/createCheckboxIcon.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxIndicator.js +0 -47
- package/lib/commonjs/checkbox/createCheckboxIndicator.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxLabel.js +0 -46
- package/lib/commonjs/checkbox/createCheckboxLabel.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxRoot.js +0 -99
- package/lib/commonjs/checkbox/createCheckboxRoot.js.map +0 -1
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js +0 -90
- package/lib/commonjs/checkbox/createCheckboxRoot.web.js.map +0 -1
- package/lib/commonjs/dialog/createDialogBody.js +0 -21
- package/lib/commonjs/dialog/createDialogBody.js.map +0 -1
- package/lib/commonjs/dialog/createDialogClose.js +0 -37
- package/lib/commonjs/dialog/createDialogClose.js.map +0 -1
- package/lib/commonjs/dialog/createDialogContent.js +0 -141
- package/lib/commonjs/dialog/createDialogContent.js.map +0 -1
- package/lib/commonjs/dialog/createDialogDescription.js +0 -30
- package/lib/commonjs/dialog/createDialogDescription.js.map +0 -1
- package/lib/commonjs/dialog/createDialogFooter.js +0 -21
- package/lib/commonjs/dialog/createDialogFooter.js.map +0 -1
- package/lib/commonjs/dialog/createDialogHeader.js +0 -21
- package/lib/commonjs/dialog/createDialogHeader.js.map +0 -1
- package/lib/commonjs/dialog/createDialogRoot.js +0 -54
- package/lib/commonjs/dialog/createDialogRoot.js.map +0 -1
- package/lib/commonjs/dialog/createDialogTitle.js +0 -21
- package/lib/commonjs/dialog/createDialogTitle.js.map +0 -1
- package/lib/commonjs/dialog/createDialogTrigger.js +0 -37
- package/lib/commonjs/dialog/createDialogTrigger.js.map +0 -1
- package/lib/commonjs/field/createFieldError.js +0 -41
- package/lib/commonjs/field/createFieldError.js.map +0 -1
- package/lib/commonjs/field/createFieldErrorIcon.js +0 -18
- package/lib/commonjs/field/createFieldErrorIcon.js.map +0 -1
- package/lib/commonjs/field/createFieldErrorText.js +0 -18
- package/lib/commonjs/field/createFieldErrorText.js.map +0 -1
- package/lib/commonjs/field/createFieldHelper.js +0 -41
- package/lib/commonjs/field/createFieldHelper.js.map +0 -1
- package/lib/commonjs/field/createFieldHelperText.js +0 -18
- package/lib/commonjs/field/createFieldHelperText.js.map +0 -1
- package/lib/commonjs/field/createFieldLabel.js +0 -36
- package/lib/commonjs/field/createFieldLabel.js.map +0 -1
- package/lib/commonjs/field/createFieldRoot.js +0 -35
- package/lib/commonjs/field/createFieldRoot.js.map +0 -1
- package/lib/commonjs/form/createFormRoot.js +0 -21
- package/lib/commonjs/form/createFormRoot.js.map +0 -1
- package/lib/commonjs/input/createInputField.js +0 -95
- package/lib/commonjs/input/createInputField.js.map +0 -1
- package/lib/commonjs/input/createInputRoot.js +0 -82
- package/lib/commonjs/input/createInputRoot.js.map +0 -1
- package/lib/commonjs/input/createInputSlot.js +0 -44
- package/lib/commonjs/input/createInputSlot.js.map +0 -1
- package/lib/commonjs/link/createLink.js +0 -74
- package/lib/commonjs/link/createLink.js.map +0 -1
- package/lib/commonjs/list-item/createListItemContent.js +0 -30
- package/lib/commonjs/list-item/createListItemContent.js.map +0 -1
- package/lib/commonjs/list-item/createListItemDescription.js +0 -25
- package/lib/commonjs/list-item/createListItemDescription.js.map +0 -1
- package/lib/commonjs/list-item/createListItemLeadingSlot.js +0 -34
- package/lib/commonjs/list-item/createListItemLeadingSlot.js.map +0 -1
- package/lib/commonjs/list-item/createListItemMeta.js +0 -25
- package/lib/commonjs/list-item/createListItemMeta.js.map +0 -1
- package/lib/commonjs/list-item/createListItemRoot.js +0 -142
- package/lib/commonjs/list-item/createListItemRoot.js.map +0 -1
- package/lib/commonjs/list-item/createListItemSectionHeader.js +0 -54
- package/lib/commonjs/list-item/createListItemSectionHeader.js.map +0 -1
- package/lib/commonjs/list-item/createListItemTitle.js +0 -25
- package/lib/commonjs/list-item/createListItemTitle.js.map +0 -1
- package/lib/commonjs/list-item/createListItemTrailingSlot.js +0 -28
- package/lib/commonjs/list-item/createListItemTrailingSlot.js.map +0 -1
- package/lib/commonjs/otp-input/createOtpInputCell.js +0 -29
- package/lib/commonjs/otp-input/createOtpInputCell.js.map +0 -1
- package/lib/commonjs/otp-input/createOtpInputField.js +0 -104
- package/lib/commonjs/otp-input/createOtpInputField.js.map +0 -1
- package/lib/commonjs/otp-input/createOtpInputRoot.js +0 -136
- package/lib/commonjs/otp-input/createOtpInputRoot.js.map +0 -1
- package/lib/commonjs/progress/context.js.map +0 -1
- package/lib/commonjs/progress/createProgressIndicator.js +0 -42
- package/lib/commonjs/progress/createProgressIndicator.js.map +0 -1
- package/lib/commonjs/progress/createProgressRoot.js +0 -96
- package/lib/commonjs/progress/createProgressRoot.js.map +0 -1
- package/lib/commonjs/progress/index.js +0 -25
- package/lib/commonjs/progress/index.js.map +0 -1
- package/lib/commonjs/progress/types.js.map +0 -1
- package/lib/commonjs/select/createSelectContent.js +0 -102
- package/lib/commonjs/select/createSelectContent.js.map +0 -1
- package/lib/commonjs/select/createSelectIcon.js +0 -41
- package/lib/commonjs/select/createSelectIcon.js.map +0 -1
- package/lib/commonjs/select/createSelectItem.js +0 -101
- package/lib/commonjs/select/createSelectItem.js.map +0 -1
- package/lib/commonjs/select/createSelectItemLabel.js +0 -41
- package/lib/commonjs/select/createSelectItemLabel.js.map +0 -1
- package/lib/commonjs/select/createSelectRoot.js +0 -102
- package/lib/commonjs/select/createSelectRoot.js.map +0 -1
- package/lib/commonjs/select/createSelectTrigger.js +0 -179
- package/lib/commonjs/select/createSelectTrigger.js.map +0 -1
- package/lib/commonjs/select/createSelectValue.js +0 -53
- package/lib/commonjs/select/createSelectValue.js.map +0 -1
- package/lib/commonjs/switch/createSwitchRoot.js +0 -73
- package/lib/commonjs/switch/createSwitchRoot.js.map +0 -1
- package/lib/module/avatar/createAvatarBadge.js +0 -15
- package/lib/module/avatar/createAvatarBadge.js.map +0 -1
- package/lib/module/avatar/createAvatarIcon.js +0 -25
- package/lib/module/avatar/createAvatarIcon.js.map +0 -1
- package/lib/module/avatar/createAvatarImage.js +0 -46
- package/lib/module/avatar/createAvatarImage.js.map +0 -1
- package/lib/module/avatar/createAvatarRoot.js +0 -29
- package/lib/module/avatar/createAvatarRoot.js.map +0 -1
- package/lib/module/avatar/createAvatarText.js +0 -37
- package/lib/module/avatar/createAvatarText.js.map +0 -1
- package/lib/module/button/createButtonGroup.js +0 -74
- package/lib/module/button/createButtonGroup.js.map +0 -1
- package/lib/module/button/createButtonIcon.js +0 -13
- package/lib/module/button/createButtonIcon.js.map +0 -1
- package/lib/module/button/createButtonRoot.js +0 -76
- package/lib/module/button/createButtonRoot.js.map +0 -1
- package/lib/module/button/createButtonSpinner.js +0 -29
- package/lib/module/button/createButtonSpinner.js.map +0 -1
- package/lib/module/button/createButtonText.js +0 -33
- package/lib/module/button/createButtonText.js.map +0 -1
- package/lib/module/checkbox/createCheckboxGroup.js +0 -39
- package/lib/module/checkbox/createCheckboxGroup.js.map +0 -1
- package/lib/module/checkbox/createCheckboxIcon.js +0 -24
- package/lib/module/checkbox/createCheckboxIcon.js.map +0 -1
- package/lib/module/checkbox/createCheckboxIndicator.js +0 -42
- package/lib/module/checkbox/createCheckboxIndicator.js.map +0 -1
- package/lib/module/checkbox/createCheckboxLabel.js +0 -41
- package/lib/module/checkbox/createCheckboxLabel.js.map +0 -1
- package/lib/module/checkbox/createCheckboxRoot.js +0 -94
- package/lib/module/checkbox/createCheckboxRoot.js.map +0 -1
- package/lib/module/checkbox/createCheckboxRoot.web.js +0 -85
- package/lib/module/checkbox/createCheckboxRoot.web.js.map +0 -1
- package/lib/module/dialog/createDialogBody.js +0 -15
- package/lib/module/dialog/createDialogBody.js.map +0 -1
- package/lib/module/dialog/createDialogClose.js +0 -31
- package/lib/module/dialog/createDialogClose.js.map +0 -1
- package/lib/module/dialog/createDialogContent.js +0 -136
- package/lib/module/dialog/createDialogContent.js.map +0 -1
- package/lib/module/dialog/createDialogDescription.js +0 -24
- package/lib/module/dialog/createDialogDescription.js.map +0 -1
- package/lib/module/dialog/createDialogFooter.js +0 -15
- package/lib/module/dialog/createDialogFooter.js.map +0 -1
- package/lib/module/dialog/createDialogHeader.js +0 -15
- package/lib/module/dialog/createDialogHeader.js.map +0 -1
- package/lib/module/dialog/createDialogRoot.js +0 -49
- package/lib/module/dialog/createDialogRoot.js.map +0 -1
- package/lib/module/dialog/createDialogTitle.js +0 -15
- package/lib/module/dialog/createDialogTitle.js.map +0 -1
- package/lib/module/dialog/createDialogTrigger.js +0 -31
- package/lib/module/dialog/createDialogTrigger.js.map +0 -1
- package/lib/module/field/createFieldError.js +0 -35
- package/lib/module/field/createFieldError.js.map +0 -1
- package/lib/module/field/createFieldErrorIcon.js +0 -13
- package/lib/module/field/createFieldErrorIcon.js.map +0 -1
- package/lib/module/field/createFieldErrorText.js +0 -13
- package/lib/module/field/createFieldErrorText.js.map +0 -1
- package/lib/module/field/createFieldHelper.js +0 -35
- package/lib/module/field/createFieldHelper.js.map +0 -1
- package/lib/module/field/createFieldHelperText.js +0 -13
- package/lib/module/field/createFieldHelperText.js.map +0 -1
- package/lib/module/field/createFieldLabel.js +0 -31
- package/lib/module/field/createFieldLabel.js.map +0 -1
- package/lib/module/field/createFieldRoot.js +0 -29
- package/lib/module/field/createFieldRoot.js.map +0 -1
- package/lib/module/form/createFormRoot.js +0 -15
- package/lib/module/form/createFormRoot.js.map +0 -1
- package/lib/module/input/createInputField.js +0 -90
- package/lib/module/input/createInputField.js.map +0 -1
- package/lib/module/input/createInputRoot.js +0 -76
- package/lib/module/input/createInputRoot.js.map +0 -1
- package/lib/module/input/createInputSlot.js +0 -39
- package/lib/module/input/createInputSlot.js.map +0 -1
- package/lib/module/link/createLink.js +0 -68
- package/lib/module/link/createLink.js.map +0 -1
- package/lib/module/list-item/createListItemContent.js +0 -24
- package/lib/module/list-item/createListItemContent.js.map +0 -1
- package/lib/module/list-item/createListItemDescription.js +0 -19
- package/lib/module/list-item/createListItemDescription.js.map +0 -1
- package/lib/module/list-item/createListItemLeadingSlot.js +0 -28
- package/lib/module/list-item/createListItemLeadingSlot.js.map +0 -1
- package/lib/module/list-item/createListItemMeta.js +0 -19
- package/lib/module/list-item/createListItemMeta.js.map +0 -1
- package/lib/module/list-item/createListItemRoot.js +0 -136
- package/lib/module/list-item/createListItemRoot.js.map +0 -1
- package/lib/module/list-item/createListItemSectionHeader.js +0 -48
- package/lib/module/list-item/createListItemSectionHeader.js.map +0 -1
- package/lib/module/list-item/createListItemTitle.js +0 -19
- package/lib/module/list-item/createListItemTitle.js.map +0 -1
- package/lib/module/list-item/createListItemTrailingSlot.js +0 -22
- package/lib/module/list-item/createListItemTrailingSlot.js.map +0 -1
- package/lib/module/otp-input/createOtpInputCell.js +0 -24
- package/lib/module/otp-input/createOtpInputCell.js.map +0 -1
- package/lib/module/otp-input/createOtpInputField.js +0 -99
- package/lib/module/otp-input/createOtpInputField.js.map +0 -1
- package/lib/module/otp-input/createOtpInputRoot.js +0 -131
- package/lib/module/otp-input/createOtpInputRoot.js.map +0 -1
- package/lib/module/progress/context.js.map +0 -1
- package/lib/module/progress/createProgressIndicator.js +0 -37
- package/lib/module/progress/createProgressIndicator.js.map +0 -1
- package/lib/module/progress/createProgressRoot.js +0 -91
- package/lib/module/progress/createProgressRoot.js.map +0 -1
- package/lib/module/progress/index.js +0 -15
- package/lib/module/progress/index.js.map +0 -1
- package/lib/module/progress/types.js.map +0 -1
- package/lib/module/select/createSelectContent.js +0 -97
- package/lib/module/select/createSelectContent.js.map +0 -1
- package/lib/module/select/createSelectIcon.js +0 -36
- package/lib/module/select/createSelectIcon.js.map +0 -1
- package/lib/module/select/createSelectItem.js +0 -96
- package/lib/module/select/createSelectItem.js.map +0 -1
- package/lib/module/select/createSelectItemLabel.js +0 -36
- package/lib/module/select/createSelectItemLabel.js.map +0 -1
- package/lib/module/select/createSelectRoot.js +0 -97
- package/lib/module/select/createSelectRoot.js.map +0 -1
- package/lib/module/select/createSelectTrigger.js +0 -174
- package/lib/module/select/createSelectTrigger.js.map +0 -1
- package/lib/module/select/createSelectValue.js +0 -48
- package/lib/module/select/createSelectValue.js.map +0 -1
- package/lib/module/switch/createSwitchRoot.js +0 -67
- package/lib/module/switch/createSwitchRoot.js.map +0 -1
- package/lib/typescript/avatar/createAvatarBadge.d.ts +0 -4
- package/lib/typescript/avatar/createAvatarBadge.d.ts.map +0 -1
- package/lib/typescript/avatar/createAvatarIcon.d.ts +0 -4
- package/lib/typescript/avatar/createAvatarIcon.d.ts.map +0 -1
- package/lib/typescript/avatar/createAvatarImage.d.ts +0 -4
- package/lib/typescript/avatar/createAvatarImage.d.ts.map +0 -1
- package/lib/typescript/avatar/createAvatarRoot.d.ts +0 -4
- package/lib/typescript/avatar/createAvatarRoot.d.ts.map +0 -1
- package/lib/typescript/avatar/createAvatarText.d.ts +0 -4
- package/lib/typescript/avatar/createAvatarText.d.ts.map +0 -1
- package/lib/typescript/button/createButtonGroup.d.ts +0 -4
- package/lib/typescript/button/createButtonGroup.d.ts.map +0 -1
- package/lib/typescript/button/createButtonIcon.d.ts +0 -2
- package/lib/typescript/button/createButtonIcon.d.ts.map +0 -1
- package/lib/typescript/button/createButtonRoot.d.ts +0 -6
- package/lib/typescript/button/createButtonRoot.d.ts.map +0 -1
- package/lib/typescript/button/createButtonSpinner.d.ts +0 -4
- package/lib/typescript/button/createButtonSpinner.d.ts.map +0 -1
- package/lib/typescript/button/createButtonText.d.ts +0 -4
- package/lib/typescript/button/createButtonText.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts +0 -3
- package/lib/typescript/checkbox/createCheckboxGroup.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts +0 -3
- package/lib/typescript/checkbox/createCheckboxIcon.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts +0 -5
- package/lib/typescript/checkbox/createCheckboxIndicator.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts +0 -5
- package/lib/typescript/checkbox/createCheckboxLabel.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts +0 -2
- package/lib/typescript/checkbox/createCheckboxRoot.d.ts.map +0 -1
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts +0 -2
- package/lib/typescript/checkbox/createCheckboxRoot.web.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogBody.d.ts +0 -4
- package/lib/typescript/dialog/createDialogBody.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogClose.d.ts +0 -4
- package/lib/typescript/dialog/createDialogClose.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogContent.d.ts +0 -4
- package/lib/typescript/dialog/createDialogContent.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogDescription.d.ts +0 -4
- package/lib/typescript/dialog/createDialogDescription.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogFooter.d.ts +0 -4
- package/lib/typescript/dialog/createDialogFooter.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogHeader.d.ts +0 -4
- package/lib/typescript/dialog/createDialogHeader.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogRoot.d.ts +0 -4
- package/lib/typescript/dialog/createDialogRoot.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogTitle.d.ts +0 -4
- package/lib/typescript/dialog/createDialogTitle.d.ts.map +0 -1
- package/lib/typescript/dialog/createDialogTrigger.d.ts +0 -4
- package/lib/typescript/dialog/createDialogTrigger.d.ts.map +0 -1
- package/lib/typescript/field/createFieldError.d.ts +0 -5
- package/lib/typescript/field/createFieldError.d.ts.map +0 -1
- package/lib/typescript/field/createFieldErrorIcon.d.ts +0 -5
- package/lib/typescript/field/createFieldErrorIcon.d.ts.map +0 -1
- package/lib/typescript/field/createFieldErrorText.d.ts +0 -5
- package/lib/typescript/field/createFieldErrorText.d.ts.map +0 -1
- package/lib/typescript/field/createFieldHelper.d.ts +0 -5
- package/lib/typescript/field/createFieldHelper.d.ts.map +0 -1
- package/lib/typescript/field/createFieldHelperText.d.ts +0 -5
- package/lib/typescript/field/createFieldHelperText.d.ts.map +0 -1
- package/lib/typescript/field/createFieldLabel.d.ts +0 -6
- package/lib/typescript/field/createFieldLabel.d.ts.map +0 -1
- package/lib/typescript/field/createFieldRoot.d.ts +0 -6
- package/lib/typescript/field/createFieldRoot.d.ts.map +0 -1
- package/lib/typescript/form/createFormRoot.d.ts +0 -4
- package/lib/typescript/form/createFormRoot.d.ts.map +0 -1
- package/lib/typescript/input/createInputField.d.ts +0 -4
- package/lib/typescript/input/createInputField.d.ts.map +0 -1
- package/lib/typescript/input/createInputRoot.d.ts +0 -4
- package/lib/typescript/input/createInputRoot.d.ts.map +0 -1
- package/lib/typescript/input/createInputSlot.d.ts +0 -4
- package/lib/typescript/input/createInputSlot.d.ts.map +0 -1
- package/lib/typescript/link/createLink.d.ts +0 -6
- package/lib/typescript/link/createLink.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemContent.d.ts +0 -3
- package/lib/typescript/list-item/createListItemContent.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemDescription.d.ts +0 -3
- package/lib/typescript/list-item/createListItemDescription.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts +0 -4
- package/lib/typescript/list-item/createListItemLeadingSlot.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemMeta.d.ts +0 -3
- package/lib/typescript/list-item/createListItemMeta.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemRoot.d.ts +0 -4
- package/lib/typescript/list-item/createListItemRoot.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts +0 -4
- package/lib/typescript/list-item/createListItemSectionHeader.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemTitle.d.ts +0 -3
- package/lib/typescript/list-item/createListItemTitle.d.ts.map +0 -1
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts +0 -3
- package/lib/typescript/list-item/createListItemTrailingSlot.d.ts.map +0 -1
- package/lib/typescript/otp-input/createOtpInputCell.d.ts +0 -4
- package/lib/typescript/otp-input/createOtpInputCell.d.ts.map +0 -1
- package/lib/typescript/otp-input/createOtpInputField.d.ts +0 -4
- package/lib/typescript/otp-input/createOtpInputField.d.ts.map +0 -1
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts +0 -4
- package/lib/typescript/otp-input/createOtpInputRoot.d.ts.map +0 -1
- package/lib/typescript/progress/context.d.ts.map +0 -1
- package/lib/typescript/progress/createProgressIndicator.d.ts +0 -3
- package/lib/typescript/progress/createProgressIndicator.d.ts.map +0 -1
- package/lib/typescript/progress/createProgressRoot.d.ts +0 -4
- package/lib/typescript/progress/createProgressRoot.d.ts.map +0 -1
- package/lib/typescript/progress/index.d.ts +0 -10
- package/lib/typescript/progress/index.d.ts.map +0 -1
- package/lib/typescript/progress/types.d.ts +0 -25
- package/lib/typescript/progress/types.d.ts.map +0 -1
- package/lib/typescript/select/createSelectContent.d.ts +0 -4
- package/lib/typescript/select/createSelectContent.d.ts.map +0 -1
- package/lib/typescript/select/createSelectIcon.d.ts +0 -2
- package/lib/typescript/select/createSelectIcon.d.ts.map +0 -1
- package/lib/typescript/select/createSelectItem.d.ts +0 -6
- package/lib/typescript/select/createSelectItem.d.ts.map +0 -1
- package/lib/typescript/select/createSelectItemLabel.d.ts +0 -4
- package/lib/typescript/select/createSelectItemLabel.d.ts.map +0 -1
- package/lib/typescript/select/createSelectRoot.d.ts +0 -4
- package/lib/typescript/select/createSelectRoot.d.ts.map +0 -1
- package/lib/typescript/select/createSelectTrigger.d.ts +0 -7
- package/lib/typescript/select/createSelectTrigger.d.ts.map +0 -1
- package/lib/typescript/select/createSelectValue.d.ts +0 -4
- package/lib/typescript/select/createSelectValue.d.ts.map +0 -1
- package/lib/typescript/switch/createSwitchRoot.d.ts +0 -3
- package/lib/typescript/switch/createSwitchRoot.d.ts.map +0 -1
- package/src/avatar/createAvatarBadge.tsx +0 -12
- package/src/avatar/createAvatarIcon.tsx +0 -16
- package/src/avatar/createAvatarImage.tsx +0 -40
- package/src/avatar/createAvatarRoot.tsx +0 -23
- package/src/avatar/createAvatarText.tsx +0 -30
- package/src/button/createButtonGroup.tsx +0 -88
- package/src/button/createButtonIcon.tsx +0 -8
- package/src/button/createButtonRoot.tsx +0 -102
- package/src/button/createButtonSpinner.tsx +0 -20
- package/src/button/createButtonText.tsx +0 -22
- package/src/button/index.tsx +0 -53
- package/src/checkbox/createCheckboxGroup.tsx +0 -32
- package/src/checkbox/createCheckboxIcon.tsx +0 -18
- package/src/checkbox/createCheckboxIndicator.tsx +0 -43
- package/src/checkbox/createCheckboxLabel.tsx +0 -42
- package/src/checkbox/createCheckboxRoot.tsx +0 -100
- package/src/checkbox/createCheckboxRoot.web.tsx +0 -79
- package/src/dialog/createDialogBody.tsx +0 -11
- package/src/dialog/createDialogClose.tsx +0 -27
- package/src/dialog/createDialogContent.tsx +0 -122
- package/src/dialog/createDialogDescription.tsx +0 -20
- package/src/dialog/createDialogFooter.tsx +0 -11
- package/src/dialog/createDialogHeader.tsx +0 -11
- package/src/dialog/createDialogRoot.tsx +0 -66
- package/src/dialog/createDialogTitle.tsx +0 -11
- package/src/dialog/createDialogTrigger.tsx +0 -27
- package/src/field/createFieldError.tsx +0 -32
- package/src/field/createFieldErrorIcon.tsx +0 -9
- package/src/field/createFieldErrorText.tsx +0 -9
- package/src/field/createFieldHelper.tsx +0 -28
- package/src/field/createFieldHelperText.tsx +0 -9
- package/src/field/createFieldLabel.tsx +0 -30
- package/src/field/createFieldRoot.tsx +0 -27
- package/src/form/createFormRoot.tsx +0 -13
- package/src/input/createInputField.tsx +0 -114
- package/src/input/createInputRoot.tsx +0 -92
- package/src/input/createInputSlot.tsx +0 -39
- package/src/link/createLink.tsx +0 -71
- package/src/list-item/createListItemContent.tsx +0 -23
- package/src/list-item/createListItemDescription.tsx +0 -19
- package/src/list-item/createListItemLeadingSlot.tsx +0 -30
- package/src/list-item/createListItemMeta.tsx +0 -17
- package/src/list-item/createListItemRoot.tsx +0 -163
- package/src/list-item/createListItemSectionHeader.tsx +0 -53
- package/src/list-item/createListItemTitle.tsx +0 -17
- package/src/list-item/createListItemTrailingSlot.tsx +0 -21
- package/src/otp-input/createOtpInputCell.tsx +0 -22
- package/src/otp-input/createOtpInputField.tsx +0 -98
- package/src/otp-input/createOtpInputRoot.tsx +0 -179
- package/src/otp-input/index.tsx +0 -34
- package/src/progress/createProgressIndicator.tsx +0 -35
- package/src/progress/createProgressRoot.tsx +0 -109
- package/src/progress/index.ts +0 -28
- package/src/progress/types.ts +0 -37
- package/src/select/createSelectContent.tsx +0 -115
- package/src/select/createSelectIcon.tsx +0 -27
- package/src/select/createSelectItem.tsx +0 -121
- package/src/select/createSelectItemLabel.tsx +0 -30
- package/src/select/createSelectRoot.tsx +0 -134
- package/src/select/createSelectTrigger.tsx +0 -218
- package/src/select/createSelectValue.tsx +0 -38
- package/src/select/index.tsx +0 -73
- package/src/switch/createSwitchRoot.tsx +0 -72
- /package/lib/commonjs/{progress → chip}/types.js +0 -0
- /package/lib/commonjs/{progress → progress-bar}/context.js +0 -0
- /package/lib/module/{progress → chip}/types.js +0 -0
- /package/lib/module/{progress → progress-bar}/context.js +0 -0
- /package/lib/typescript/{progress → progress-bar}/context.d.ts +0 -0
- /package/src/{progress → progress-bar}/context.tsx +0 -0
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
|
|
3
|
-
import type { TextInput } from 'react-native';
|
|
4
|
-
import { useFormControlContext } from '@cdx-ui/utils';
|
|
5
|
-
import { applyOtpInputChange } from './utils/applyValueChange';
|
|
6
|
-
import { OtpCellIndexProvider, OtpInputProvider } from './context';
|
|
7
|
-
import { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
|
|
8
|
-
import type { IOtpInputRootProps } from './types';
|
|
9
|
-
|
|
10
|
-
export const createOtpInputRoot = <RootProps,>(
|
|
11
|
-
BaseRoot: React.ComponentType<RootProps>,
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- slot components are generic across design systems
|
|
13
|
-
OtpCell: React.ComponentType<any>,
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
-
OtpField: React.ComponentType<any>,
|
|
16
|
-
) =>
|
|
17
|
-
forwardRef<unknown, IOtpInputRootProps & RootProps>(
|
|
18
|
-
(
|
|
19
|
-
{
|
|
20
|
-
cellCount,
|
|
21
|
-
value,
|
|
22
|
-
onChangeText,
|
|
23
|
-
onComplete,
|
|
24
|
-
isDisabled: isDisabledProp,
|
|
25
|
-
isInvalid: isInvalidProp,
|
|
26
|
-
isReadOnly: isReadOnlyProp,
|
|
27
|
-
smsOtpAutofill = true,
|
|
28
|
-
filterInput,
|
|
29
|
-
allowedCharacters,
|
|
30
|
-
characterPattern,
|
|
31
|
-
getCellProps,
|
|
32
|
-
cellTestIdPrefix,
|
|
33
|
-
accessibilityLabel: rootAccessibilityLabel,
|
|
34
|
-
...rest
|
|
35
|
-
},
|
|
36
|
-
ref,
|
|
37
|
-
) => {
|
|
38
|
-
const form = useFormControlContext();
|
|
39
|
-
const isDisabled = isDisabledProp ?? form.isDisabled ?? false;
|
|
40
|
-
const isInvalid = isInvalidProp ?? form.isInvalid ?? false;
|
|
41
|
-
const isReadOnly = isReadOnlyProp ?? form.isReadOnly ?? false;
|
|
42
|
-
|
|
43
|
-
const fieldRefs = useRef<(TextInput | null)[]>([]);
|
|
44
|
-
const focusAfterApply = useRef<number | null>(null);
|
|
45
|
-
const prevLenRef = useRef(value.length);
|
|
46
|
-
const prevValueRef = useRef(value);
|
|
47
|
-
|
|
48
|
-
const filter = useMemo(() => {
|
|
49
|
-
if (filterInput) {
|
|
50
|
-
return filterInput;
|
|
51
|
-
}
|
|
52
|
-
if (allowedCharacters !== undefined) {
|
|
53
|
-
return filterAllowedCharacters(allowedCharacters);
|
|
54
|
-
}
|
|
55
|
-
if (characterPattern !== undefined) {
|
|
56
|
-
return filterByRegExp(characterPattern);
|
|
57
|
-
}
|
|
58
|
-
return filterDigits;
|
|
59
|
-
}, [filterInput, allowedCharacters, characterPattern]);
|
|
60
|
-
|
|
61
|
-
const setFieldRef = useCallback((index: number, el: TextInput | null) => {
|
|
62
|
-
fieldRefs.current[index] = el;
|
|
63
|
-
}, []);
|
|
64
|
-
|
|
65
|
-
const focusCell = useCallback(
|
|
66
|
-
(index: number) => {
|
|
67
|
-
const safe = Math.max(0, Math.min(index, cellCount - 1));
|
|
68
|
-
fieldRefs.current[safe]?.focus();
|
|
69
|
-
},
|
|
70
|
-
[cellCount],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const handleFieldChange = useCallback(
|
|
74
|
-
(index: number, text: string) => {
|
|
75
|
-
const { nextValue, focusIndex } = applyOtpInputChange(
|
|
76
|
-
value,
|
|
77
|
-
index,
|
|
78
|
-
text,
|
|
79
|
-
cellCount,
|
|
80
|
-
filter,
|
|
81
|
-
);
|
|
82
|
-
if (nextValue !== value) {
|
|
83
|
-
onChangeText(nextValue);
|
|
84
|
-
}
|
|
85
|
-
focusAfterApply.current = focusIndex;
|
|
86
|
-
},
|
|
87
|
-
[cellCount, filter, onChangeText, value],
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const handleFieldKeyPress = useCallback(
|
|
91
|
-
(index: number, key: string) => {
|
|
92
|
-
if (key !== 'Backspace') {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const char = index < value.length ? value[index] : '';
|
|
96
|
-
if (!char && index > 0) {
|
|
97
|
-
focusCell(index - 1);
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
[focusCell, value],
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
useLayoutEffect(() => {
|
|
104
|
-
if (focusAfterApply.current !== null) {
|
|
105
|
-
const i = focusAfterApply.current;
|
|
106
|
-
focusAfterApply.current = null;
|
|
107
|
-
fieldRefs.current[i]?.focus();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
const prevLen = prevLenRef.current;
|
|
113
|
-
const prevVal = prevValueRef.current;
|
|
114
|
-
const isFull = value.length === cellCount;
|
|
115
|
-
const becameFullByLength = isFull && prevLen < cellCount;
|
|
116
|
-
const correctedWhileFull = isFull && prevLen === cellCount && prevVal !== value;
|
|
117
|
-
|
|
118
|
-
if (becameFullByLength || correctedWhileFull) {
|
|
119
|
-
onComplete?.();
|
|
120
|
-
}
|
|
121
|
-
prevLenRef.current = value.length;
|
|
122
|
-
prevValueRef.current = value;
|
|
123
|
-
}, [cellCount, onComplete, value]);
|
|
124
|
-
|
|
125
|
-
const contextValue = useMemo(
|
|
126
|
-
() => ({
|
|
127
|
-
cellCount,
|
|
128
|
-
value,
|
|
129
|
-
isDisabled,
|
|
130
|
-
isInvalid,
|
|
131
|
-
isReadOnly,
|
|
132
|
-
smsOtpAutofill,
|
|
133
|
-
filter,
|
|
134
|
-
getCellProps,
|
|
135
|
-
cellTestIdPrefix,
|
|
136
|
-
rootAccessibilityLabel,
|
|
137
|
-
setFieldRef,
|
|
138
|
-
handleFieldChange,
|
|
139
|
-
handleFieldKeyPress,
|
|
140
|
-
}),
|
|
141
|
-
[
|
|
142
|
-
cellCount,
|
|
143
|
-
value,
|
|
144
|
-
isDisabled,
|
|
145
|
-
isInvalid,
|
|
146
|
-
isReadOnly,
|
|
147
|
-
smsOtpAutofill,
|
|
148
|
-
filter,
|
|
149
|
-
getCellProps,
|
|
150
|
-
cellTestIdPrefix,
|
|
151
|
-
rootAccessibilityLabel,
|
|
152
|
-
setFieldRef,
|
|
153
|
-
handleFieldChange,
|
|
154
|
-
handleFieldKeyPress,
|
|
155
|
-
],
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
// Hermes drops outer-scope closure vars from its environment record when
|
|
159
|
-
// they are only referenced inside a nested callback (Array.from). Using a
|
|
160
|
-
// for-loop keeps OtpCell/OtpField references in the render function's own
|
|
161
|
-
// scope, avoiding the Hermes closure-capture bug.
|
|
162
|
-
const cells: React.ReactElement[] = [];
|
|
163
|
-
for (let i = 0; i < cellCount; i++) {
|
|
164
|
-
cells.push(
|
|
165
|
-
<OtpCellIndexProvider key={i} value={{ cellIndex: i }}>
|
|
166
|
-
<OtpCell>
|
|
167
|
-
<OtpField />
|
|
168
|
-
</OtpCell>
|
|
169
|
-
</OtpCellIndexProvider>,
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return (
|
|
174
|
-
<BaseRoot ref={ref as React.Ref<unknown>} {...(rest as RootProps)}>
|
|
175
|
-
<OtpInputProvider value={contextValue}>{cells}</OtpInputProvider>
|
|
176
|
-
</BaseRoot>
|
|
177
|
-
);
|
|
178
|
-
},
|
|
179
|
-
);
|
package/src/otp-input/index.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { createOtpInputCell } from './createOtpInputCell';
|
|
3
|
-
import { createOtpInputField } from './createOtpInputField';
|
|
4
|
-
import { createOtpInputRoot } from './createOtpInputRoot';
|
|
5
|
-
import type { IOtpInputComponentType } from './types';
|
|
6
|
-
|
|
7
|
-
export { applyOtpInputChange } from './utils/applyValueChange';
|
|
8
|
-
export { filterAllowedCharacters, filterByRegExp, filterDigits } from './utils/filterValue';
|
|
9
|
-
export type * from './types';
|
|
10
|
-
|
|
11
|
-
export function createOtpInput<
|
|
12
|
-
RootProps,
|
|
13
|
-
CellProps,
|
|
14
|
-
FieldProps,
|
|
15
|
-
RootRef = unknown,
|
|
16
|
-
FieldRef = unknown,
|
|
17
|
-
>(BaseComponents: {
|
|
18
|
-
Root: React.ComponentType<RootProps>;
|
|
19
|
-
Cell: React.ComponentType<CellProps>;
|
|
20
|
-
Field: React.ComponentType<FieldProps>;
|
|
21
|
-
}) {
|
|
22
|
-
const Cell = createOtpInputCell(BaseComponents.Cell);
|
|
23
|
-
const Field = createOtpInputField(BaseComponents.Field);
|
|
24
|
-
const Root = createOtpInputRoot(BaseComponents.Root, Cell, Field);
|
|
25
|
-
|
|
26
|
-
Root.displayName = 'OtpInputPrimitive';
|
|
27
|
-
Cell.displayName = 'OtpInputPrimitive.Cell';
|
|
28
|
-
Field.displayName = 'OtpInputPrimitive.Field';
|
|
29
|
-
|
|
30
|
-
return Object.assign(Root, {
|
|
31
|
-
Cell,
|
|
32
|
-
Field,
|
|
33
|
-
}) as IOtpInputComponentType<RootProps, CellProps, FieldProps, RootRef, FieldRef>;
|
|
34
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, useMemo, type PropsWithoutRef } from 'react';
|
|
3
|
-
import type { ViewStyle } from 'react-native';
|
|
4
|
-
import { dataAttributes } from '../utils/dataAttributes';
|
|
5
|
-
import { useProgressContext } from './context';
|
|
6
|
-
|
|
7
|
-
type PercentString = `${number}%`;
|
|
8
|
-
|
|
9
|
-
export const createProgressIndicator = <T, R = unknown>(BaseIndicator: React.ComponentType<T>) =>
|
|
10
|
-
forwardRef<R, PropsWithoutRef<T>>((props, ref) => {
|
|
11
|
-
const { style, ...rest } = props as PropsWithoutRef<T> & { style?: object };
|
|
12
|
-
const { percent, state, max, value } = useProgressContext();
|
|
13
|
-
|
|
14
|
-
const filledStyle = useMemo((): ViewStyle => {
|
|
15
|
-
const pct = `${String(percent)}%` as PercentString;
|
|
16
|
-
return { width: pct, height: '100%' };
|
|
17
|
-
}, [percent]);
|
|
18
|
-
|
|
19
|
-
const dataAttrs = dataAttributes({
|
|
20
|
-
state,
|
|
21
|
-
value: value === null ? undefined : String(value),
|
|
22
|
-
max: String(max),
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<BaseIndicator
|
|
27
|
-
ref={ref as React.Ref<R>}
|
|
28
|
-
{...({
|
|
29
|
-
...rest,
|
|
30
|
-
...dataAttrs,
|
|
31
|
-
style: [filledStyle, style],
|
|
32
|
-
} as T)}
|
|
33
|
-
/>
|
|
34
|
-
);
|
|
35
|
-
});
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, useMemo, type PropsWithoutRef } from 'react';
|
|
3
|
-
import { dataAttributes } from '../utils/dataAttributes';
|
|
4
|
-
import { ProgressProvider } from './context';
|
|
5
|
-
import type { InterfaceProgressProps, ProgressDataState } from './types';
|
|
6
|
-
|
|
7
|
-
function clamp(n: number, min: number, max: number): number {
|
|
8
|
-
return Math.min(max, Math.max(min, n));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function resolveState(
|
|
12
|
-
value: number | null,
|
|
13
|
-
max: number,
|
|
14
|
-
clamped: number | null,
|
|
15
|
-
): ProgressDataState {
|
|
16
|
-
if (value === null) {
|
|
17
|
-
return 'indeterminate';
|
|
18
|
-
}
|
|
19
|
-
if (max <= 0) {
|
|
20
|
-
return 'complete';
|
|
21
|
-
}
|
|
22
|
-
if (clamped !== null && clamped >= max) {
|
|
23
|
-
return 'complete';
|
|
24
|
-
}
|
|
25
|
-
return 'loading';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function defaultGetValueLabel(value: number, max: number): string {
|
|
29
|
-
if (max <= 0) {
|
|
30
|
-
return '0%';
|
|
31
|
-
}
|
|
32
|
-
return `${String(Math.round((value / max) * 100))}%`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const createProgressRoot = <T, R = unknown>(BaseRoot: React.ComponentType<T>) =>
|
|
36
|
-
forwardRef<R, PropsWithoutRef<T> & InterfaceProgressProps>((props, ref) => {
|
|
37
|
-
const {
|
|
38
|
-
value: valueProp = 0,
|
|
39
|
-
max: maxProp = 100,
|
|
40
|
-
getValueLabel = defaultGetValueLabel,
|
|
41
|
-
children,
|
|
42
|
-
accessibilityRole = 'progressbar',
|
|
43
|
-
accessibilityValue: accessibilityValueProp,
|
|
44
|
-
role = 'progressbar',
|
|
45
|
-
...restProps
|
|
46
|
-
} = props;
|
|
47
|
-
const max = maxProp > 0 ? maxProp : 0;
|
|
48
|
-
const isIndeterminate = valueProp === null;
|
|
49
|
-
const clampedValue =
|
|
50
|
-
valueProp === null ? null : clamp(Number.isFinite(valueProp) ? valueProp : 0, 0, max);
|
|
51
|
-
|
|
52
|
-
const percent = useMemo(() => {
|
|
53
|
-
if (clampedValue === null || max <= 0) {
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
return (clampedValue / max) * 100;
|
|
57
|
-
}, [clampedValue, max]);
|
|
58
|
-
|
|
59
|
-
const state = useMemo(
|
|
60
|
-
() => resolveState(valueProp, max, clampedValue),
|
|
61
|
-
[valueProp, max, clampedValue],
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const contextValue = useMemo(
|
|
65
|
-
() => ({
|
|
66
|
-
value: clampedValue,
|
|
67
|
-
max,
|
|
68
|
-
percent,
|
|
69
|
-
state,
|
|
70
|
-
}),
|
|
71
|
-
[clampedValue, max, percent, state],
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const dataAttrs = dataAttributes({
|
|
75
|
-
state,
|
|
76
|
-
value: clampedValue === null ? undefined : String(clampedValue),
|
|
77
|
-
max: String(max),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const accessibilityValue = useMemo(() => {
|
|
81
|
-
if (accessibilityValueProp !== undefined) {
|
|
82
|
-
return accessibilityValueProp;
|
|
83
|
-
}
|
|
84
|
-
if (isIndeterminate || clampedValue === null) {
|
|
85
|
-
return { min: 0, max, text: 'Indeterminate' };
|
|
86
|
-
}
|
|
87
|
-
return {
|
|
88
|
-
min: 0,
|
|
89
|
-
max,
|
|
90
|
-
now: clampedValue,
|
|
91
|
-
text: getValueLabel(clampedValue, max),
|
|
92
|
-
};
|
|
93
|
-
}, [accessibilityValueProp, isIndeterminate, clampedValue, max, getValueLabel]);
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<ProgressProvider value={contextValue}>
|
|
97
|
-
<BaseRoot
|
|
98
|
-
ref={ref as React.Ref<R>}
|
|
99
|
-
{...(restProps as T)}
|
|
100
|
-
role={role}
|
|
101
|
-
accessibilityRole={accessibilityRole}
|
|
102
|
-
accessibilityValue={accessibilityValue}
|
|
103
|
-
{...dataAttrs}
|
|
104
|
-
>
|
|
105
|
-
{children}
|
|
106
|
-
</BaseRoot>
|
|
107
|
-
</ProgressProvider>
|
|
108
|
-
);
|
|
109
|
-
});
|
package/src/progress/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { createProgressIndicator } from './createProgressIndicator';
|
|
3
|
-
import { createProgressRoot } from './createProgressRoot';
|
|
4
|
-
import type { IProgressComponentType } from './types';
|
|
5
|
-
|
|
6
|
-
export type { IProgressProps, IProgressComponentType, ProgressDataState } from './types';
|
|
7
|
-
export type { ProgressContextValue } from './context';
|
|
8
|
-
export { useProgressContext } from './context';
|
|
9
|
-
|
|
10
|
-
export function createProgress<
|
|
11
|
-
RootProps,
|
|
12
|
-
IndicatorProps,
|
|
13
|
-
RootRef = unknown,
|
|
14
|
-
IndicatorRef = unknown,
|
|
15
|
-
>(components: {
|
|
16
|
-
Root: React.ComponentType<RootProps>;
|
|
17
|
-
Indicator: React.ComponentType<IndicatorProps>;
|
|
18
|
-
}) {
|
|
19
|
-
const Progress = createProgressRoot<RootProps, RootRef>(components.Root);
|
|
20
|
-
const Indicator = createProgressIndicator<IndicatorProps, IndicatorRef>(components.Indicator);
|
|
21
|
-
|
|
22
|
-
Progress.displayName = 'ProgressPrimitive';
|
|
23
|
-
Indicator.displayName = 'ProgressPrimitive.Indicator';
|
|
24
|
-
|
|
25
|
-
return Object.assign(Progress, {
|
|
26
|
-
Indicator,
|
|
27
|
-
}) as IProgressComponentType<RootProps, IndicatorProps, RootRef, IndicatorRef>;
|
|
28
|
-
}
|
package/src/progress/types.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ForwardRefExoticComponent, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
|
|
2
|
-
import type { ViewProps } from 'react-native';
|
|
3
|
-
|
|
4
|
-
export type ProgressDataState = 'complete' | 'indeterminate' | 'loading';
|
|
5
|
-
|
|
6
|
-
export interface InterfaceProgressProps extends Omit<ViewProps, 'children'> {
|
|
7
|
-
/**
|
|
8
|
-
* Current value in the range [0, max], or `null` for indeterminate progress.
|
|
9
|
-
* Omit or use a number for determinate progress; default is `0`.
|
|
10
|
-
*/
|
|
11
|
-
readonly value?: number | null;
|
|
12
|
-
/**
|
|
13
|
-
* Maximum value (minimum is always 0).
|
|
14
|
-
* @default 100
|
|
15
|
-
*/
|
|
16
|
-
readonly max?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Optional label for `accessibilityValue.text` when determinate.
|
|
19
|
-
*/
|
|
20
|
-
readonly getValueLabel?: (value: number, max: number) => string;
|
|
21
|
-
readonly children?: ReactNode;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type IProgressComponentType<
|
|
25
|
-
RootProps,
|
|
26
|
-
IndicatorProps,
|
|
27
|
-
RootRef = unknown,
|
|
28
|
-
IndicatorRef = unknown,
|
|
29
|
-
> = ForwardRefExoticComponent<
|
|
30
|
-
PropsWithoutRef<RootProps & InterfaceProgressProps> & RefAttributes<RootRef>
|
|
31
|
-
> & {
|
|
32
|
-
Indicator: ForwardRefExoticComponent<
|
|
33
|
-
PropsWithoutRef<IndicatorProps> & RefAttributes<IndicatorRef>
|
|
34
|
-
>;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type IProgressProps = InterfaceProgressProps;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, useCallback, useRef } from 'react';
|
|
3
|
-
import { Platform, ScrollView } from 'react-native';
|
|
4
|
-
import { FadeIn, FadeOut } from 'react-native-reanimated';
|
|
5
|
-
import { composeEventHandlers, mergeRefs } from '@cdx-ui/utils';
|
|
6
|
-
import {
|
|
7
|
-
OverlayContainer,
|
|
8
|
-
useAnchorPosition,
|
|
9
|
-
useDismissOverlay,
|
|
10
|
-
useOverlayPosition,
|
|
11
|
-
} from '../overlay';
|
|
12
|
-
import { dataAttributes } from '../utils/dataAttributes';
|
|
13
|
-
import { useSelectContext } from './context';
|
|
14
|
-
import type { ISelectContentProps } from './types';
|
|
15
|
-
import { useContentFocus } from './useContentFocus';
|
|
16
|
-
import { useListboxNavigation } from './useListboxNavigation';
|
|
17
|
-
|
|
18
|
-
export const createSelectContent = <T,>(BaseContent: React.ComponentType<T>) =>
|
|
19
|
-
forwardRef(
|
|
20
|
-
(
|
|
21
|
-
{ children, enteringAnimation, exitingAnimation, ...props }: ISelectContentProps,
|
|
22
|
-
ref?: any,
|
|
23
|
-
) => {
|
|
24
|
-
const {
|
|
25
|
-
open,
|
|
26
|
-
setOpen,
|
|
27
|
-
contentId,
|
|
28
|
-
triggerId,
|
|
29
|
-
activeValue,
|
|
30
|
-
setActiveValue,
|
|
31
|
-
value,
|
|
32
|
-
onValueChange,
|
|
33
|
-
native,
|
|
34
|
-
triggerRef,
|
|
35
|
-
items,
|
|
36
|
-
} = useSelectContext();
|
|
37
|
-
|
|
38
|
-
const contentRef = useRef<HTMLElement | null>(null);
|
|
39
|
-
|
|
40
|
-
const focusOnMount = useCallback((node: HTMLElement) => {
|
|
41
|
-
contentRef.current = node;
|
|
42
|
-
if (node && Platform.OS === 'web') {
|
|
43
|
-
requestAnimationFrame(() => {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
node.focus?.();
|
|
46
|
-
}, 100);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}, []);
|
|
50
|
-
|
|
51
|
-
const mergedRef = mergeRefs(ref, focusOnMount);
|
|
52
|
-
|
|
53
|
-
const dismiss = () => setOpen(false);
|
|
54
|
-
|
|
55
|
-
const anchorLayout = useAnchorPosition(triggerRef, open);
|
|
56
|
-
const position = useOverlayPosition(anchorLayout);
|
|
57
|
-
|
|
58
|
-
useDismissOverlay(open, contentRef, [triggerRef], dismiss);
|
|
59
|
-
|
|
60
|
-
const { handleKeyDown } = useListboxNavigation({
|
|
61
|
-
items,
|
|
62
|
-
activeValue,
|
|
63
|
-
setActiveValue,
|
|
64
|
-
onSelect: (val) => {
|
|
65
|
-
onValueChange(val);
|
|
66
|
-
setOpen(false);
|
|
67
|
-
},
|
|
68
|
-
onDismiss: dismiss,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
useContentFocus({
|
|
72
|
-
open,
|
|
73
|
-
triggerRef,
|
|
74
|
-
items,
|
|
75
|
-
value,
|
|
76
|
-
setActiveValue,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
if (native || !open || !position) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const webProps =
|
|
84
|
-
Platform.OS === 'web'
|
|
85
|
-
? {
|
|
86
|
-
onKeyDown: composeEventHandlers((props as any).onKeyDown, handleKeyDown),
|
|
87
|
-
tabIndex: -1,
|
|
88
|
-
}
|
|
89
|
-
: {};
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<OverlayContainer
|
|
93
|
-
onDismiss={dismiss}
|
|
94
|
-
entering={enteringAnimation ?? FadeIn.duration(150)}
|
|
95
|
-
exiting={exitingAnimation ?? FadeOut.duration(100)}
|
|
96
|
-
style={position.style}
|
|
97
|
-
>
|
|
98
|
-
<BaseContent
|
|
99
|
-
ref={mergedRef}
|
|
100
|
-
role="listbox"
|
|
101
|
-
id={contentId}
|
|
102
|
-
aria-labelledby={triggerId}
|
|
103
|
-
{...dataAttributes({
|
|
104
|
-
state: 'open',
|
|
105
|
-
slot: 'select-content',
|
|
106
|
-
})}
|
|
107
|
-
{...(props as T)}
|
|
108
|
-
{...webProps}
|
|
109
|
-
>
|
|
110
|
-
<ScrollView scrollEventThrottle={16}>{children}</ScrollView>
|
|
111
|
-
</BaseContent>
|
|
112
|
-
</OverlayContainer>
|
|
113
|
-
);
|
|
114
|
-
},
|
|
115
|
-
);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
2
|
-
import { dataAttributes } from '../utils/dataAttributes';
|
|
3
|
-
import { useSelectContext, useSelectTriggerContext } from './context';
|
|
4
|
-
|
|
5
|
-
export const createSelectIcon = <T,>(BaseIcon: React.ComponentType<T>) =>
|
|
6
|
-
forwardRef((props: any, ref?: any) => {
|
|
7
|
-
const { hover, focus, active, disabled, focusVisible } = useSelectTriggerContext();
|
|
8
|
-
const { required, invalid, readOnly } = useSelectContext();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<BaseIcon
|
|
12
|
-
ref={ref}
|
|
13
|
-
{...dataAttributes({
|
|
14
|
-
hover,
|
|
15
|
-
focus,
|
|
16
|
-
active,
|
|
17
|
-
disabled,
|
|
18
|
-
focusVisible,
|
|
19
|
-
required,
|
|
20
|
-
invalid,
|
|
21
|
-
readonly: readOnly,
|
|
22
|
-
slot: 'select-icon',
|
|
23
|
-
})}
|
|
24
|
-
{...(props as T)}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
});
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import { forwardRef, useCallback, useMemo } from 'react';
|
|
3
|
-
import { composeEventHandlers } from '@cdx-ui/utils';
|
|
4
|
-
import { useFocus, useFocusRing } from '@react-native-aria/focus';
|
|
5
|
-
import { useHover, usePress } from '@react-native-aria/interactions';
|
|
6
|
-
import { dataAttributes } from '../utils/dataAttributes';
|
|
7
|
-
import { SelectItemProvider, useSelectContext } from './context';
|
|
8
|
-
import type { ISelectItemProps } from './types';
|
|
9
|
-
|
|
10
|
-
export const createSelectItem = <T,>(BaseItem: React.ComponentType<T>) =>
|
|
11
|
-
forwardRef(
|
|
12
|
-
(
|
|
13
|
-
{
|
|
14
|
-
children,
|
|
15
|
-
value: itemValue,
|
|
16
|
-
disabled: disabledProp = false,
|
|
17
|
-
isHovered: isHoveredProp,
|
|
18
|
-
isActive: isActiveProp,
|
|
19
|
-
isFocused: isFocusedProp,
|
|
20
|
-
isFocusVisible: isFocusVisibleProp,
|
|
21
|
-
isDisabled: isDisabledProp,
|
|
22
|
-
...props
|
|
23
|
-
}: Omit<ISelectItemProps, 'children'> & { children?: React.ReactNode },
|
|
24
|
-
ref?: any,
|
|
25
|
-
) => {
|
|
26
|
-
const {
|
|
27
|
-
value: selectedValue,
|
|
28
|
-
onValueChange,
|
|
29
|
-
setOpen,
|
|
30
|
-
activeValue,
|
|
31
|
-
contentId,
|
|
32
|
-
disabled: contextDisabled,
|
|
33
|
-
} = useSelectContext();
|
|
34
|
-
|
|
35
|
-
const disabled = contextDisabled || !!disabledProp || !!isDisabledProp;
|
|
36
|
-
const checked = selectedValue === itemValue;
|
|
37
|
-
const highlighted = activeValue === itemValue;
|
|
38
|
-
|
|
39
|
-
const { isFocusVisible, focusProps: focusRingProps }: any = useFocusRing();
|
|
40
|
-
const { pressProps, isPressed: isActive } = usePress({ isDisabled: disabled });
|
|
41
|
-
const { isFocused, focusProps } = useFocus();
|
|
42
|
-
const { isHovered, hoverProps }: any = useHover();
|
|
43
|
-
|
|
44
|
-
const handlePress = useCallback(() => {
|
|
45
|
-
if (!disabled) {
|
|
46
|
-
onValueChange(itemValue);
|
|
47
|
-
setOpen(false);
|
|
48
|
-
}
|
|
49
|
-
}, [disabled, itemValue, onValueChange, setOpen]);
|
|
50
|
-
|
|
51
|
-
const interactionState = useMemo(
|
|
52
|
-
() => ({
|
|
53
|
-
hover: isHoveredProp || isHovered,
|
|
54
|
-
focus: isFocusedProp || isFocused,
|
|
55
|
-
active: isActiveProp || isActive,
|
|
56
|
-
disabled: !!disabled,
|
|
57
|
-
focusVisible: isFocusVisibleProp || isFocusVisible,
|
|
58
|
-
highlighted,
|
|
59
|
-
checked,
|
|
60
|
-
}),
|
|
61
|
-
[
|
|
62
|
-
isHoveredProp,
|
|
63
|
-
isHovered,
|
|
64
|
-
isFocusedProp,
|
|
65
|
-
isFocused,
|
|
66
|
-
isActiveProp,
|
|
67
|
-
isActive,
|
|
68
|
-
disabled,
|
|
69
|
-
isFocusVisibleProp,
|
|
70
|
-
isFocusVisible,
|
|
71
|
-
highlighted,
|
|
72
|
-
checked,
|
|
73
|
-
],
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<SelectItemProvider value={interactionState}>
|
|
78
|
-
<BaseItem
|
|
79
|
-
ref={ref}
|
|
80
|
-
role="option"
|
|
81
|
-
id={`${contentId}-option-${itemValue}`}
|
|
82
|
-
aria-selected={checked}
|
|
83
|
-
aria-disabled={disabled}
|
|
84
|
-
{...dataAttributes({
|
|
85
|
-
hover: interactionState.hover,
|
|
86
|
-
focus: interactionState.focus,
|
|
87
|
-
active: interactionState.active,
|
|
88
|
-
disabled: interactionState.disabled,
|
|
89
|
-
focusVisible: interactionState.focusVisible,
|
|
90
|
-
highlighted: interactionState.highlighted,
|
|
91
|
-
state: checked ? 'checked' : 'unchecked',
|
|
92
|
-
slot: 'select-item',
|
|
93
|
-
})}
|
|
94
|
-
disabled={disabled}
|
|
95
|
-
{...(props as T)}
|
|
96
|
-
onPress={composeEventHandlers(props?.onPress, handlePress)}
|
|
97
|
-
onPressIn={composeEventHandlers(props?.onPressIn, pressProps.onPressIn)}
|
|
98
|
-
onPressOut={composeEventHandlers(props?.onPressOut, pressProps.onPressOut)}
|
|
99
|
-
onHoverIn={composeEventHandlers(props?.onHoverIn, hoverProps.onHoverIn)}
|
|
100
|
-
onHoverOut={composeEventHandlers(props?.onHoverOut, hoverProps.onHoverOut)}
|
|
101
|
-
onFocus={composeEventHandlers(
|
|
102
|
-
composeEventHandlers(
|
|
103
|
-
props?.onFocus as (...args: unknown[]) => unknown,
|
|
104
|
-
focusProps.onFocus,
|
|
105
|
-
),
|
|
106
|
-
focusRingProps.onFocus,
|
|
107
|
-
)}
|
|
108
|
-
onBlur={composeEventHandlers(
|
|
109
|
-
composeEventHandlers(
|
|
110
|
-
props?.onBlur as (...args: unknown[]) => unknown,
|
|
111
|
-
focusProps.onBlur,
|
|
112
|
-
),
|
|
113
|
-
focusRingProps.onBlur,
|
|
114
|
-
)}
|
|
115
|
-
>
|
|
116
|
-
{children}
|
|
117
|
-
</BaseItem>
|
|
118
|
-
</SelectItemProvider>
|
|
119
|
-
);
|
|
120
|
-
},
|
|
121
|
-
);
|