@wow-two-beta/ui 0.0.7 → 0.0.9
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/dist/actions/buttonGroup/ButtonGroup.d.ts +14 -0
- package/dist/actions/buttonGroup/ButtonGroup.d.ts.map +1 -0
- package/dist/actions/buttonGroup/index.d.ts +2 -0
- package/dist/actions/buttonGroup/index.d.ts.map +1 -0
- package/dist/actions/copyButton/CopyButton.d.ts +20 -0
- package/dist/actions/copyButton/CopyButton.d.ts.map +1 -0
- package/dist/actions/copyButton/index.d.ts +2 -0
- package/dist/actions/copyButton/index.d.ts.map +1 -0
- package/dist/actions/disclosureButton/DisclosureButton.d.ts +20 -0
- package/dist/actions/disclosureButton/DisclosureButton.d.ts.map +1 -0
- package/dist/actions/disclosureButton/index.d.ts +2 -0
- package/dist/actions/disclosureButton/index.d.ts.map +1 -0
- package/dist/actions/fab/FAB.d.ts +13 -0
- package/dist/actions/fab/FAB.d.ts.map +1 -0
- package/dist/actions/fab/FAB.variants.d.ts +130 -0
- package/dist/actions/fab/FAB.variants.d.ts.map +1 -0
- package/dist/actions/fab/index.d.ts +3 -0
- package/dist/actions/fab/index.d.ts.map +1 -0
- package/dist/actions/index.d.ts +8 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +4 -1
- package/dist/actions/overlayButton/OverlayButton.d.ts +16 -0
- package/dist/actions/overlayButton/OverlayButton.d.ts.map +1 -0
- package/dist/actions/overlayButton/OverlayButton.variants.d.ts +123 -0
- package/dist/actions/overlayButton/OverlayButton.variants.d.ts.map +1 -0
- package/dist/actions/overlayButton/index.d.ts +3 -0
- package/dist/actions/overlayButton/index.d.ts.map +1 -0
- package/dist/actions/segmentedControl/SegmentedControl.d.ts +9 -0
- package/dist/actions/segmentedControl/SegmentedControl.d.ts.map +1 -0
- package/dist/actions/segmentedControl/index.d.ts +2 -0
- package/dist/actions/segmentedControl/index.d.ts.map +1 -0
- package/dist/actions/toggleButton/ToggleButton.d.ts +16 -0
- package/dist/actions/toggleButton/ToggleButton.d.ts.map +1 -0
- package/dist/actions/toggleButton/ToggleButton.variants.d.ts +81 -0
- package/dist/actions/toggleButton/ToggleButton.variants.d.ts.map +1 -0
- package/dist/actions/toggleButton/index.d.ts +3 -0
- package/dist/actions/toggleButton/index.d.ts.map +1 -0
- package/dist/actions/toggleButtonGroup/ToggleButtonGroup.d.ts +25 -0
- package/dist/actions/toggleButtonGroup/ToggleButtonGroup.d.ts.map +1 -0
- package/dist/actions/toggleButtonGroup/index.d.ts +2 -0
- package/dist/actions/toggleButtonGroup/index.d.ts.map +1 -0
- package/dist/chunk-3KGYKBW6.js +697 -0
- package/dist/chunk-3KGYKBW6.js.map +1 -0
- package/dist/{chunk-6NYTRHP7.js → chunk-4P2TFUVW.js} +39 -5
- package/dist/chunk-4P2TFUVW.js.map +1 -0
- package/dist/chunk-55Y2JOBV.js +774 -0
- package/dist/chunk-55Y2JOBV.js.map +1 -0
- package/dist/{chunk-JCMV6IT4.js → chunk-CZ6FQILQ.js} +30 -5
- package/dist/chunk-CZ6FQILQ.js.map +1 -0
- package/dist/chunk-D5CHR6RX.js +423 -0
- package/dist/chunk-D5CHR6RX.js.map +1 -0
- package/dist/{chunk-77WSI427.js → chunk-KDXJQNB6.js} +9 -5
- package/dist/chunk-KDXJQNB6.js.map +1 -0
- package/dist/{chunk-SYG6ZE42.js → chunk-NKGNOOXJ.js} +116 -4
- package/dist/chunk-NKGNOOXJ.js.map +1 -0
- package/dist/chunk-RIW2V3N4.js +596 -0
- package/dist/chunk-RIW2V3N4.js.map +1 -0
- package/dist/chunk-SBVWECJP.js +2034 -0
- package/dist/chunk-SBVWECJP.js.map +1 -0
- package/dist/display/avatarGroup/AvatarGroup.d.ts +16 -0
- package/dist/display/avatarGroup/AvatarGroup.d.ts.map +1 -0
- package/dist/display/avatarGroup/index.d.ts +2 -0
- package/dist/display/avatarGroup/index.d.ts.map +1 -0
- package/dist/display/badgeOverlay/BadgeOverlay.d.ts +18 -0
- package/dist/display/badgeOverlay/BadgeOverlay.d.ts.map +1 -0
- package/dist/display/badgeOverlay/index.d.ts +2 -0
- package/dist/display/badgeOverlay/index.d.ts.map +1 -0
- package/dist/display/card/Card.d.ts +20 -0
- package/dist/display/card/Card.d.ts.map +1 -0
- package/dist/display/card/index.d.ts +2 -0
- package/dist/display/card/index.d.ts.map +1 -0
- package/dist/display/countBadge/CountBadge.d.ts +18 -0
- package/dist/display/countBadge/CountBadge.d.ts.map +1 -0
- package/dist/display/countBadge/index.d.ts +2 -0
- package/dist/display/countBadge/index.d.ts.map +1 -0
- package/dist/display/descriptionList/DescriptionList.d.ts +18 -0
- package/dist/display/descriptionList/DescriptionList.d.ts.map +1 -0
- package/dist/display/descriptionList/index.d.ts +2 -0
- package/dist/display/descriptionList/index.d.ts.map +1 -0
- package/dist/display/emptyState/EmptyState.d.ts +19 -0
- package/dist/display/emptyState/EmptyState.d.ts.map +1 -0
- package/dist/display/emptyState/index.d.ts +2 -0
- package/dist/display/emptyState/index.d.ts.map +1 -0
- package/dist/display/highlight/Highlight.d.ts +16 -0
- package/dist/display/highlight/Highlight.d.ts.map +1 -0
- package/dist/display/highlight/index.d.ts +2 -0
- package/dist/display/highlight/index.d.ts.map +1 -0
- package/dist/display/index.d.ts +15 -0
- package/dist/display/index.d.ts.map +1 -1
- package/dist/display/index.js +6 -2
- package/dist/display/infoRow/InfoRow.d.ts +16 -0
- package/dist/display/infoRow/InfoRow.d.ts.map +1 -0
- package/dist/display/infoRow/index.d.ts +2 -0
- package/dist/display/infoRow/index.d.ts.map +1 -0
- package/dist/display/keyboardShortcut/KeyboardShortcut.d.ts +13 -0
- package/dist/display/keyboardShortcut/KeyboardShortcut.d.ts.map +1 -0
- package/dist/display/keyboardShortcut/index.d.ts +2 -0
- package/dist/display/keyboardShortcut/index.d.ts.map +1 -0
- package/dist/display/notificationDot/NotificationDot.d.ts +15 -0
- package/dist/display/notificationDot/NotificationDot.d.ts.map +1 -0
- package/dist/display/notificationDot/index.d.ts +2 -0
- package/dist/display/notificationDot/index.d.ts.map +1 -0
- package/dist/display/sectionHeader/SectionHeader.d.ts +21 -0
- package/dist/display/sectionHeader/SectionHeader.d.ts.map +1 -0
- package/dist/display/sectionHeader/index.d.ts +2 -0
- package/dist/display/sectionHeader/index.d.ts.map +1 -0
- package/dist/display/snippet/Snippet.d.ts +15 -0
- package/dist/display/snippet/Snippet.d.ts.map +1 -0
- package/dist/display/snippet/index.d.ts +2 -0
- package/dist/display/snippet/index.d.ts.map +1 -0
- package/dist/display/stat/Stat.d.ts +22 -0
- package/dist/display/stat/Stat.d.ts.map +1 -0
- package/dist/display/stat/index.d.ts +2 -0
- package/dist/display/stat/index.d.ts.map +1 -0
- package/dist/display/status/Status.d.ts +14 -0
- package/dist/display/status/Status.d.ts.map +1 -0
- package/dist/display/status/index.d.ts +2 -0
- package/dist/display/status/index.d.ts.map +1 -0
- package/dist/display/tooltip/Tooltip.d.ts +25 -0
- package/dist/display/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/display/tooltip/index.d.ts +2 -0
- package/dist/display/tooltip/index.d.ts.map +1 -0
- package/dist/feedback/alert/Alert.d.ts +22 -0
- package/dist/feedback/alert/Alert.d.ts.map +1 -0
- package/dist/feedback/alert/index.d.ts +2 -0
- package/dist/feedback/alert/index.d.ts.map +1 -0
- package/dist/feedback/banner/Banner.d.ts +16 -0
- package/dist/feedback/banner/Banner.d.ts.map +1 -0
- package/dist/feedback/banner/index.d.ts +2 -0
- package/dist/feedback/banner/index.d.ts.map +1 -0
- package/dist/feedback/callout/Callout.d.ts +13 -0
- package/dist/feedback/callout/Callout.d.ts.map +1 -0
- package/dist/feedback/callout/index.d.ts +2 -0
- package/dist/feedback/callout/index.d.ts.map +1 -0
- package/dist/feedback/index.d.ts +10 -0
- package/dist/feedback/index.d.ts.map +1 -1
- package/dist/feedback/index.js +2 -1
- package/dist/feedback/inlineSpinner/InlineSpinner.d.ts +14 -0
- package/dist/feedback/inlineSpinner/InlineSpinner.d.ts.map +1 -0
- package/dist/feedback/inlineSpinner/index.d.ts +2 -0
- package/dist/feedback/inlineSpinner/index.d.ts.map +1 -0
- package/dist/feedback/loadingState/LoadingState.d.ts +15 -0
- package/dist/feedback/loadingState/LoadingState.d.ts.map +1 -0
- package/dist/feedback/loadingState/index.d.ts +2 -0
- package/dist/feedback/loadingState/index.d.ts.map +1 -0
- package/dist/feedback/meterBar/MeterBar.d.ts +18 -0
- package/dist/feedback/meterBar/MeterBar.d.ts.map +1 -0
- package/dist/feedback/meterBar/index.d.ts +2 -0
- package/dist/feedback/meterBar/index.d.ts.map +1 -0
- package/dist/feedback/progressSteps/ProgressSteps.d.ts +16 -0
- package/dist/feedback/progressSteps/ProgressSteps.d.ts.map +1 -0
- package/dist/feedback/progressSteps/index.d.ts +2 -0
- package/dist/feedback/progressSteps/index.d.ts.map +1 -0
- package/dist/feedback/statusIndicator/StatusIndicator.d.ts +17 -0
- package/dist/feedback/statusIndicator/StatusIndicator.d.ts.map +1 -0
- package/dist/feedback/statusIndicator/index.d.ts +2 -0
- package/dist/feedback/statusIndicator/index.d.ts.map +1 -0
- package/dist/feedback/toast/Toast.d.ts +16 -0
- package/dist/feedback/toast/Toast.d.ts.map +1 -0
- package/dist/feedback/toast/index.d.ts +2 -0
- package/dist/feedback/toast/index.d.ts.map +1 -0
- package/dist/feedback/trendIndicator/TrendIndicator.d.ts +18 -0
- package/dist/feedback/trendIndicator/TrendIndicator.d.ts.map +1 -0
- package/dist/feedback/trendIndicator/index.d.ts +2 -0
- package/dist/feedback/trendIndicator/index.d.ts.map +1 -0
- package/dist/forms/characterCount/CharacterCount.d.ts +15 -0
- package/dist/forms/characterCount/CharacterCount.d.ts.map +1 -0
- package/dist/forms/characterCount/index.d.ts +2 -0
- package/dist/forms/characterCount/index.d.ts.map +1 -0
- package/dist/forms/checkboxField/CheckboxField.d.ts +16 -0
- package/dist/forms/checkboxField/CheckboxField.d.ts.map +1 -0
- package/dist/forms/checkboxField/index.d.ts +2 -0
- package/dist/forms/checkboxField/index.d.ts.map +1 -0
- package/dist/forms/checkboxGroup/CheckboxGroup.d.ts +24 -0
- package/dist/forms/checkboxGroup/CheckboxGroup.d.ts.map +1 -0
- package/dist/forms/checkboxGroup/index.d.ts +2 -0
- package/dist/forms/checkboxGroup/index.d.ts.map +1 -0
- package/dist/forms/choiceCard/ChoiceCard.d.ts +17 -0
- package/dist/forms/choiceCard/ChoiceCard.d.ts.map +1 -0
- package/dist/forms/choiceCard/index.d.ts +2 -0
- package/dist/forms/choiceCard/index.d.ts.map +1 -0
- package/dist/forms/combobox/Combobox.d.ts +55 -0
- package/dist/forms/combobox/Combobox.d.ts.map +1 -0
- package/dist/forms/combobox/index.d.ts +2 -0
- package/dist/forms/combobox/index.d.ts.map +1 -0
- package/dist/forms/currencyInput/CurrencyInput.d.ts +11 -0
- package/dist/forms/currencyInput/CurrencyInput.d.ts.map +1 -0
- package/dist/forms/currencyInput/index.d.ts +2 -0
- package/dist/forms/currencyInput/index.d.ts.map +1 -0
- package/dist/forms/filePicker/FilePicker.d.ts +18 -0
- package/dist/forms/filePicker/FilePicker.d.ts.map +1 -0
- package/dist/forms/filePicker/index.d.ts +2 -0
- package/dist/forms/filePicker/index.d.ts.map +1 -0
- package/dist/forms/formField/FormField.d.ts +24 -0
- package/dist/forms/formField/FormField.d.ts.map +1 -0
- package/dist/forms/formField/index.d.ts +2 -0
- package/dist/forms/formField/index.d.ts.map +1 -0
- package/dist/forms/index.d.ts +21 -0
- package/dist/forms/index.d.ts.map +1 -1
- package/dist/forms/index.js +6 -4
- package/dist/forms/inputAddon/InputAddon.d.ts +16 -0
- package/dist/forms/inputAddon/InputAddon.d.ts.map +1 -0
- package/dist/forms/inputAddon/index.d.ts +2 -0
- package/dist/forms/inputAddon/index.d.ts.map +1 -0
- package/dist/forms/inputGroup/InputGroup.d.ts +11 -0
- package/dist/forms/inputGroup/InputGroup.d.ts.map +1 -0
- package/dist/forms/inputGroup/index.d.ts +2 -0
- package/dist/forms/inputGroup/index.d.ts.map +1 -0
- package/dist/forms/labeledInput/LabeledInput.d.ts +17 -0
- package/dist/forms/labeledInput/LabeledInput.d.ts.map +1 -0
- package/dist/forms/labeledInput/index.d.ts +2 -0
- package/dist/forms/labeledInput/index.d.ts.map +1 -0
- package/dist/forms/listbox/Listbox.d.ts +44 -0
- package/dist/forms/listbox/Listbox.d.ts.map +1 -0
- package/dist/forms/listbox/Listbox.variants.d.ts +58 -0
- package/dist/forms/listbox/Listbox.variants.d.ts.map +1 -0
- package/dist/forms/listbox/index.d.ts +2 -0
- package/dist/forms/listbox/index.d.ts.map +1 -0
- package/dist/forms/maskedInput/MaskedInput.d.ts +17 -0
- package/dist/forms/maskedInput/MaskedInput.d.ts.map +1 -0
- package/dist/forms/maskedInput/index.d.ts +2 -0
- package/dist/forms/maskedInput/index.d.ts.map +1 -0
- package/dist/forms/multiSelect/MultiSelect.d.ts +47 -0
- package/dist/forms/multiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/forms/multiSelect/index.d.ts +2 -0
- package/dist/forms/multiSelect/index.d.ts.map +1 -0
- package/dist/forms/passwordStrength/PasswordStrength.d.ts +15 -0
- package/dist/forms/passwordStrength/PasswordStrength.d.ts.map +1 -0
- package/dist/forms/passwordStrength/index.d.ts +2 -0
- package/dist/forms/passwordStrength/index.d.ts.map +1 -0
- package/dist/forms/percentInput/PercentInput.d.ts +8 -0
- package/dist/forms/percentInput/PercentInput.d.ts.map +1 -0
- package/dist/forms/percentInput/index.d.ts +2 -0
- package/dist/forms/percentInput/index.d.ts.map +1 -0
- package/dist/forms/pinInput/PinInput.d.ts +26 -0
- package/dist/forms/pinInput/PinInput.d.ts.map +1 -0
- package/dist/forms/pinInput/index.d.ts +2 -0
- package/dist/forms/pinInput/index.d.ts.map +1 -0
- package/dist/forms/radioField/RadioField.d.ts +12 -0
- package/dist/forms/radioField/RadioField.d.ts.map +1 -0
- package/dist/forms/radioField/index.d.ts +2 -0
- package/dist/forms/radioField/index.d.ts.map +1 -0
- package/dist/forms/radioGroup/RadioGroup.d.ts +19 -0
- package/dist/forms/radioGroup/RadioGroup.d.ts.map +1 -0
- package/dist/forms/radioGroup/index.d.ts +2 -0
- package/dist/forms/radioGroup/index.d.ts.map +1 -0
- package/dist/forms/select/Select.d.ts +55 -0
- package/dist/forms/select/Select.d.ts.map +1 -0
- package/dist/forms/select/Select.variants.d.ts +74 -0
- package/dist/forms/select/Select.variants.d.ts.map +1 -0
- package/dist/forms/select/index.d.ts +2 -0
- package/dist/forms/select/index.d.ts.map +1 -0
- package/dist/forms/switchField/SwitchField.d.ts +15 -0
- package/dist/forms/switchField/SwitchField.d.ts.map +1 -0
- package/dist/forms/switchField/index.d.ts +2 -0
- package/dist/forms/switchField/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -3
- package/dist/hooks/useClipboard.d.ts +21 -0
- package/dist/hooks/useClipboard.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -11
- package/dist/layout/cluster/Cluster.d.ts +13 -0
- package/dist/layout/cluster/Cluster.d.ts.map +1 -0
- package/dist/layout/cluster/index.d.ts +2 -0
- package/dist/layout/cluster/index.d.ts.map +1 -0
- package/dist/layout/frame/Frame.d.ts +17 -0
- package/dist/layout/frame/Frame.d.ts.map +1 -0
- package/dist/layout/frame/index.d.ts +2 -0
- package/dist/layout/frame/index.d.ts.map +1 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +1 -1
- package/dist/layout/inline/Inline.d.ts +13 -0
- package/dist/layout/inline/Inline.d.ts.map +1 -0
- package/dist/layout/inline/index.d.ts +2 -0
- package/dist/layout/inline/index.d.ts.map +1 -0
- package/dist/layout/twoColumn/TwoColumn.d.ts +19 -0
- package/dist/layout/twoColumn/TwoColumn.d.ts.map +1 -0
- package/dist/layout/twoColumn/index.d.ts +2 -0
- package/dist/layout/twoColumn/index.d.ts.map +1 -0
- package/dist/nav/breadcrumb/Breadcrumb.d.ts +18 -0
- package/dist/nav/breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/nav/breadcrumb/index.d.ts +2 -0
- package/dist/nav/breadcrumb/index.d.ts.map +1 -0
- package/dist/nav/contextMenu/ContextMenu.d.ts +31 -0
- package/dist/nav/contextMenu/ContextMenu.d.ts.map +1 -0
- package/dist/nav/contextMenu/index.d.ts +2 -0
- package/dist/nav/contextMenu/index.d.ts.map +1 -0
- package/dist/nav/dropdownMenu/DropdownMenu.d.ts +34 -0
- package/dist/nav/dropdownMenu/DropdownMenu.d.ts.map +1 -0
- package/dist/nav/dropdownMenu/index.d.ts +2 -0
- package/dist/nav/dropdownMenu/index.d.ts.map +1 -0
- package/dist/nav/index.d.ts +8 -0
- package/dist/nav/index.d.ts.map +1 -0
- package/dist/nav/index.js +12 -0
- package/dist/nav/index.js.map +1 -0
- package/dist/nav/menu/Menu.d.ts +38 -0
- package/dist/nav/menu/Menu.d.ts.map +1 -0
- package/dist/nav/menu/Menu.variants.d.ts +50 -0
- package/dist/nav/menu/Menu.variants.d.ts.map +1 -0
- package/dist/nav/menu/index.d.ts +3 -0
- package/dist/nav/menu/index.d.ts.map +1 -0
- package/dist/nav/menubar/Menubar.d.ts +40 -0
- package/dist/nav/menubar/Menubar.d.ts.map +1 -0
- package/dist/nav/menubar/Menubar.variants.d.ts +5 -0
- package/dist/nav/menubar/Menubar.variants.d.ts.map +1 -0
- package/dist/nav/menubar/index.d.ts +2 -0
- package/dist/nav/menubar/index.d.ts.map +1 -0
- package/dist/nav/navItem/NavItem.d.ts +22 -0
- package/dist/nav/navItem/NavItem.d.ts.map +1 -0
- package/dist/nav/navItem/index.d.ts +2 -0
- package/dist/nav/navItem/index.d.ts.map +1 -0
- package/dist/nav/pagination/Pagination.d.ts +19 -0
- package/dist/nav/pagination/Pagination.d.ts.map +1 -0
- package/dist/nav/pagination/index.d.ts +2 -0
- package/dist/nav/pagination/index.d.ts.map +1 -0
- package/dist/primitives/index.js +2 -4
- package/package.json +5 -1
- package/dist/chunk-62NXDB5V.js +0 -275
- package/dist/chunk-62NXDB5V.js.map +0 -1
- package/dist/chunk-6NYTRHP7.js.map +0 -1
- package/dist/chunk-77WSI427.js.map +0 -1
- package/dist/chunk-DBQ4VF2J.js +0 -318
- package/dist/chunk-DBQ4VF2J.js.map +0 -1
- package/dist/chunk-HVJVLK6B.js +0 -120
- package/dist/chunk-HVJVLK6B.js.map +0 -1
- package/dist/chunk-JCMV6IT4.js.map +0 -1
- package/dist/chunk-JTJEI6MF.js +0 -11
- package/dist/chunk-JTJEI6MF.js.map +0 -1
- package/dist/chunk-Q27NAHVB.js +0 -34
- package/dist/chunk-Q27NAHVB.js.map +0 -1
- package/dist/chunk-SYG6ZE42.js.map +0 -1
- package/dist/chunk-TDEEVNSD.js +0 -604
- package/dist/chunk-TDEEVNSD.js.map +0 -1
|
@@ -0,0 +1,2034 @@
|
|
|
1
|
+
import { useFormControl, FormControlProvider, Portal, AnchoredPositioner, DismissableLayer } from './chunk-CZ6FQILQ.js';
|
|
2
|
+
import { useControlled } from './chunk-4P2TFUVW.js';
|
|
3
|
+
import { useId } from './chunk-KDXJQNB6.js';
|
|
4
|
+
import { tv } from './chunk-BMBIZLO4.js';
|
|
5
|
+
import { Icon } from './chunk-TDX22OWF.js';
|
|
6
|
+
import { composeRefs } from './chunk-DN7WBRIV.js';
|
|
7
|
+
import { cn } from './chunk-KZ4VFY2T.js';
|
|
8
|
+
import * as React from 'react';
|
|
9
|
+
import { forwardRef, useRef, useImperativeHandle, useState, Children, isValidElement, cloneElement, useId as useId$1, createContext, useMemo, useCallback, useEffect, useContext } from 'react';
|
|
10
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
11
|
+
import { Minus, Plus, EyeOff, Eye, Search, X, Check, Upload, ChevronDown } from 'lucide-react';
|
|
12
|
+
import { FocusScope } from '@radix-ui/react-focus-scope';
|
|
13
|
+
|
|
14
|
+
var Label = forwardRef(
|
|
15
|
+
({ className, required, htmlFor, id, children, ...props }, ref) => {
|
|
16
|
+
const ctx = useFormControl();
|
|
17
|
+
const isRequired = required ?? ctx?.isRequired ?? false;
|
|
18
|
+
return /* @__PURE__ */ jsxs(
|
|
19
|
+
"label",
|
|
20
|
+
{
|
|
21
|
+
ref,
|
|
22
|
+
htmlFor: htmlFor ?? ctx?.id,
|
|
23
|
+
id: id ?? ctx?.labelId,
|
|
24
|
+
className: cn(
|
|
25
|
+
"text-sm font-medium text-foreground",
|
|
26
|
+
ctx?.isDisabled && "opacity-60",
|
|
27
|
+
className
|
|
28
|
+
),
|
|
29
|
+
...props,
|
|
30
|
+
children: [
|
|
31
|
+
children,
|
|
32
|
+
isRequired && /* @__PURE__ */ jsx("span", { className: "ml-0.5 text-destructive", "aria-hidden": "true", children: "*" })
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
Label.displayName = "Label";
|
|
39
|
+
var FormHelperText = forwardRef(
|
|
40
|
+
({ className, id, ...props }, ref) => {
|
|
41
|
+
const ctx = useFormControl();
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
"p",
|
|
44
|
+
{
|
|
45
|
+
ref,
|
|
46
|
+
id: id ?? ctx?.helperId,
|
|
47
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
48
|
+
...props
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
FormHelperText.displayName = "FormHelperText";
|
|
54
|
+
var FormErrorMessage = forwardRef(
|
|
55
|
+
({ className, id, ...props }, ref) => {
|
|
56
|
+
const ctx = useFormControl();
|
|
57
|
+
if (ctx && !ctx.isInvalid) return null;
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
59
|
+
"p",
|
|
60
|
+
{
|
|
61
|
+
ref,
|
|
62
|
+
id: id ?? ctx?.errorId,
|
|
63
|
+
role: "alert",
|
|
64
|
+
className: cn("text-sm text-destructive", className),
|
|
65
|
+
...props
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
FormErrorMessage.displayName = "FormErrorMessage";
|
|
71
|
+
var Fieldset = forwardRef(
|
|
72
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
73
|
+
"fieldset",
|
|
74
|
+
{
|
|
75
|
+
ref,
|
|
76
|
+
className: cn("m-0 min-w-0 border-0 p-0", className),
|
|
77
|
+
...props
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
Fieldset.displayName = "Fieldset";
|
|
82
|
+
var Legend = forwardRef(
|
|
83
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
84
|
+
"legend",
|
|
85
|
+
{
|
|
86
|
+
ref,
|
|
87
|
+
className: cn("mb-2 text-sm font-medium text-foreground", className),
|
|
88
|
+
...props
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
Legend.displayName = "Legend";
|
|
93
|
+
|
|
94
|
+
// src/forms/_styles.ts
|
|
95
|
+
var inputBaseVariants = tv({
|
|
96
|
+
base: "flex w-full rounded-md border bg-background text-foreground placeholder:text-subtle-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 read-only:bg-muted",
|
|
97
|
+
variants: {
|
|
98
|
+
size: {
|
|
99
|
+
sm: "h-8 px-2.5 text-sm",
|
|
100
|
+
md: "h-10 px-3 text-sm",
|
|
101
|
+
lg: "h-12 px-4 text-base"
|
|
102
|
+
},
|
|
103
|
+
state: {
|
|
104
|
+
default: "border-input hover:border-border-strong",
|
|
105
|
+
invalid: "border-destructive focus-visible:ring-destructive"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
defaultVariants: {
|
|
109
|
+
size: "md",
|
|
110
|
+
state: "default"
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
var TextInput = forwardRef(
|
|
114
|
+
({ className, size, state, id, disabled, required, readOnly, ...props }, ref) => {
|
|
115
|
+
const ctx = useFormControl();
|
|
116
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
117
|
+
return /* @__PURE__ */ jsx(
|
|
118
|
+
"input",
|
|
119
|
+
{
|
|
120
|
+
ref,
|
|
121
|
+
type: "text",
|
|
122
|
+
id: id ?? ctx?.id,
|
|
123
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
124
|
+
required: required ?? ctx?.isRequired,
|
|
125
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
126
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
127
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
128
|
+
className: cn(inputBaseVariants({ size, state: finalState }), className),
|
|
129
|
+
...props
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
);
|
|
134
|
+
TextInput.displayName = "TextInput";
|
|
135
|
+
var EmailInput = forwardRef(
|
|
136
|
+
({ className, size, state, id, disabled, required, readOnly, ...props }, ref) => {
|
|
137
|
+
const ctx = useFormControl();
|
|
138
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
139
|
+
return /* @__PURE__ */ jsx(
|
|
140
|
+
"input",
|
|
141
|
+
{
|
|
142
|
+
ref,
|
|
143
|
+
type: "email",
|
|
144
|
+
autoComplete: "email",
|
|
145
|
+
inputMode: "email",
|
|
146
|
+
spellCheck: false,
|
|
147
|
+
id: id ?? ctx?.id,
|
|
148
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
149
|
+
required: required ?? ctx?.isRequired,
|
|
150
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
151
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
152
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
153
|
+
className: cn(inputBaseVariants({ size, state: finalState }), className),
|
|
154
|
+
...props
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
EmailInput.displayName = "EmailInput";
|
|
160
|
+
var TelInput = forwardRef(
|
|
161
|
+
({ className, size, state, id, disabled, required, readOnly, ...props }, ref) => {
|
|
162
|
+
const ctx = useFormControl();
|
|
163
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
164
|
+
return /* @__PURE__ */ jsx(
|
|
165
|
+
"input",
|
|
166
|
+
{
|
|
167
|
+
ref,
|
|
168
|
+
type: "tel",
|
|
169
|
+
autoComplete: "tel",
|
|
170
|
+
inputMode: "tel",
|
|
171
|
+
id: id ?? ctx?.id,
|
|
172
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
173
|
+
required: required ?? ctx?.isRequired,
|
|
174
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
175
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
176
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
177
|
+
className: cn(inputBaseVariants({ size, state: finalState }), className),
|
|
178
|
+
...props
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
TelInput.displayName = "TelInput";
|
|
184
|
+
var UrlInput = forwardRef(
|
|
185
|
+
({ className, size, state, id, disabled, required, readOnly, ...props }, ref) => {
|
|
186
|
+
const ctx = useFormControl();
|
|
187
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
188
|
+
return /* @__PURE__ */ jsx(
|
|
189
|
+
"input",
|
|
190
|
+
{
|
|
191
|
+
ref,
|
|
192
|
+
type: "url",
|
|
193
|
+
autoComplete: "url",
|
|
194
|
+
inputMode: "url",
|
|
195
|
+
spellCheck: false,
|
|
196
|
+
id: id ?? ctx?.id,
|
|
197
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
198
|
+
required: required ?? ctx?.isRequired,
|
|
199
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
200
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
201
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
202
|
+
className: cn(inputBaseVariants({ size, state: finalState }), className),
|
|
203
|
+
...props
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
UrlInput.displayName = "UrlInput";
|
|
209
|
+
var NumberInput = forwardRef(
|
|
210
|
+
({ className, size, state, id, disabled, required, readOnly, step = 1, ...props }, forwardedRef) => {
|
|
211
|
+
const ctx = useFormControl();
|
|
212
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
213
|
+
const inputRef = useRef(null);
|
|
214
|
+
useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
215
|
+
const adjust = (direction) => {
|
|
216
|
+
const el = inputRef.current;
|
|
217
|
+
if (!el || typeof el.stepUp !== "function") return;
|
|
218
|
+
if (direction === 1) el.stepUp(step);
|
|
219
|
+
else el.stepDown(step);
|
|
220
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
221
|
+
el.dispatchEvent(new Event("change", { bubbles: true }));
|
|
222
|
+
};
|
|
223
|
+
const isDisabled = disabled ?? ctx?.isDisabled ?? false;
|
|
224
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
225
|
+
/* @__PURE__ */ jsx(
|
|
226
|
+
"input",
|
|
227
|
+
{
|
|
228
|
+
ref: inputRef,
|
|
229
|
+
type: "number",
|
|
230
|
+
inputMode: "decimal",
|
|
231
|
+
step,
|
|
232
|
+
id: id ?? ctx?.id,
|
|
233
|
+
disabled: isDisabled,
|
|
234
|
+
required: required ?? ctx?.isRequired,
|
|
235
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
236
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
237
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
238
|
+
className: cn(inputBaseVariants({ size, state: finalState }), "pr-12 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"),
|
|
239
|
+
...props
|
|
240
|
+
}
|
|
241
|
+
),
|
|
242
|
+
/* @__PURE__ */ jsxs("div", { className: "absolute right-1 top-1/2 flex -translate-y-1/2 items-center", children: [
|
|
243
|
+
/* @__PURE__ */ jsx(
|
|
244
|
+
"button",
|
|
245
|
+
{
|
|
246
|
+
type: "button",
|
|
247
|
+
disabled: isDisabled,
|
|
248
|
+
onClick: () => adjust(-1),
|
|
249
|
+
"aria-label": "Decrement",
|
|
250
|
+
className: "grid h-7 w-6 place-items-center rounded text-muted-foreground hover:bg-muted disabled:opacity-50",
|
|
251
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: Minus, size: 14 })
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ jsx(
|
|
255
|
+
"button",
|
|
256
|
+
{
|
|
257
|
+
type: "button",
|
|
258
|
+
disabled: isDisabled,
|
|
259
|
+
onClick: () => adjust(1),
|
|
260
|
+
"aria-label": "Increment",
|
|
261
|
+
className: "grid h-7 w-6 place-items-center rounded text-muted-foreground hover:bg-muted disabled:opacity-50",
|
|
262
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: Plus, size: 14 })
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
] })
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
NumberInput.displayName = "NumberInput";
|
|
270
|
+
var PasswordInput = forwardRef(
|
|
271
|
+
({
|
|
272
|
+
className,
|
|
273
|
+
size,
|
|
274
|
+
state,
|
|
275
|
+
id,
|
|
276
|
+
disabled,
|
|
277
|
+
required,
|
|
278
|
+
readOnly,
|
|
279
|
+
toggleable = true,
|
|
280
|
+
autoComplete = "current-password",
|
|
281
|
+
...props
|
|
282
|
+
}, ref) => {
|
|
283
|
+
const [visible, setVisible] = useState(false);
|
|
284
|
+
const ctx = useFormControl();
|
|
285
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
286
|
+
const isDisabled = disabled ?? ctx?.isDisabled ?? false;
|
|
287
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
288
|
+
/* @__PURE__ */ jsx(
|
|
289
|
+
"input",
|
|
290
|
+
{
|
|
291
|
+
ref,
|
|
292
|
+
type: visible ? "text" : "password",
|
|
293
|
+
autoComplete,
|
|
294
|
+
spellCheck: false,
|
|
295
|
+
id: id ?? ctx?.id,
|
|
296
|
+
disabled: isDisabled,
|
|
297
|
+
required: required ?? ctx?.isRequired,
|
|
298
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
299
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
300
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
301
|
+
className: cn(inputBaseVariants({ size, state: finalState }), toggleable && "pr-10"),
|
|
302
|
+
...props
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
toggleable && /* @__PURE__ */ jsx(
|
|
306
|
+
"button",
|
|
307
|
+
{
|
|
308
|
+
type: "button",
|
|
309
|
+
disabled: isDisabled,
|
|
310
|
+
onClick: () => setVisible((v) => !v),
|
|
311
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
312
|
+
"aria-pressed": visible,
|
|
313
|
+
className: "absolute right-1 top-1/2 grid h-8 w-8 -translate-y-1/2 place-items-center rounded text-muted-foreground hover:bg-muted disabled:opacity-50",
|
|
314
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: visible ? EyeOff : Eye, size: 16 })
|
|
315
|
+
}
|
|
316
|
+
)
|
|
317
|
+
] });
|
|
318
|
+
}
|
|
319
|
+
);
|
|
320
|
+
PasswordInput.displayName = "PasswordInput";
|
|
321
|
+
var SearchInput = forwardRef(
|
|
322
|
+
({
|
|
323
|
+
className,
|
|
324
|
+
size,
|
|
325
|
+
state,
|
|
326
|
+
id,
|
|
327
|
+
disabled,
|
|
328
|
+
required,
|
|
329
|
+
readOnly,
|
|
330
|
+
clearable = true,
|
|
331
|
+
onClear,
|
|
332
|
+
onChange,
|
|
333
|
+
defaultValue,
|
|
334
|
+
value,
|
|
335
|
+
...props
|
|
336
|
+
}, forwardedRef) => {
|
|
337
|
+
const ctx = useFormControl();
|
|
338
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
339
|
+
const isDisabled = disabled ?? ctx?.isDisabled ?? false;
|
|
340
|
+
const inputRef = useRef(null);
|
|
341
|
+
useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
342
|
+
const isControlled = value !== void 0;
|
|
343
|
+
const [uncontrolled, setUncontrolled] = useState(defaultValue ?? "");
|
|
344
|
+
const currentValue = isControlled ? value : uncontrolled;
|
|
345
|
+
const showClear = clearable && String(currentValue ?? "").length > 0;
|
|
346
|
+
const handleClear = () => {
|
|
347
|
+
const el = inputRef.current;
|
|
348
|
+
if (el) {
|
|
349
|
+
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set;
|
|
350
|
+
setter?.call(el, "");
|
|
351
|
+
el.dispatchEvent(new Event("input", { bubbles: true }));
|
|
352
|
+
el.focus();
|
|
353
|
+
}
|
|
354
|
+
if (!isControlled) setUncontrolled("");
|
|
355
|
+
onClear?.();
|
|
356
|
+
};
|
|
357
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
358
|
+
/* @__PURE__ */ jsx(
|
|
359
|
+
Icon,
|
|
360
|
+
{
|
|
361
|
+
icon: Search,
|
|
362
|
+
size: 16,
|
|
363
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 text-subtle-foreground"
|
|
364
|
+
}
|
|
365
|
+
),
|
|
366
|
+
/* @__PURE__ */ jsx(
|
|
367
|
+
"input",
|
|
368
|
+
{
|
|
369
|
+
ref: inputRef,
|
|
370
|
+
type: "search",
|
|
371
|
+
id: id ?? ctx?.id,
|
|
372
|
+
value: isControlled ? value : void 0,
|
|
373
|
+
defaultValue: !isControlled ? defaultValue : void 0,
|
|
374
|
+
onChange: (e) => {
|
|
375
|
+
if (!isControlled) setUncontrolled(e.target.value);
|
|
376
|
+
onChange?.(e);
|
|
377
|
+
},
|
|
378
|
+
disabled: isDisabled,
|
|
379
|
+
required: required ?? ctx?.isRequired,
|
|
380
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
381
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
382
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
383
|
+
className: cn(
|
|
384
|
+
inputBaseVariants({ size, state: finalState }),
|
|
385
|
+
"pl-9",
|
|
386
|
+
showClear && "pr-9",
|
|
387
|
+
"[&::-webkit-search-cancel-button]:appearance-none"
|
|
388
|
+
),
|
|
389
|
+
...props
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
showClear && /* @__PURE__ */ jsx(
|
|
393
|
+
"button",
|
|
394
|
+
{
|
|
395
|
+
type: "button",
|
|
396
|
+
disabled: isDisabled,
|
|
397
|
+
onClick: handleClear,
|
|
398
|
+
"aria-label": "Clear search",
|
|
399
|
+
className: "absolute right-1 top-1/2 grid h-8 w-8 -translate-y-1/2 place-items-center rounded text-subtle-foreground hover:bg-muted hover:text-muted-foreground",
|
|
400
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: X, size: 14 })
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
] });
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
SearchInput.displayName = "SearchInput";
|
|
407
|
+
var Textarea = forwardRef(
|
|
408
|
+
({ className, size, state, id, disabled, required, readOnly, rows = 3, ...props }, ref) => {
|
|
409
|
+
const ctx = useFormControl();
|
|
410
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
411
|
+
return /* @__PURE__ */ jsx(
|
|
412
|
+
"textarea",
|
|
413
|
+
{
|
|
414
|
+
ref,
|
|
415
|
+
rows,
|
|
416
|
+
id: id ?? ctx?.id,
|
|
417
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
418
|
+
required: required ?? ctx?.isRequired,
|
|
419
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
420
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
421
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
422
|
+
className: cn(
|
|
423
|
+
inputBaseVariants({ size, state: finalState }),
|
|
424
|
+
"h-auto resize-y py-2",
|
|
425
|
+
className
|
|
426
|
+
),
|
|
427
|
+
...props
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
);
|
|
432
|
+
Textarea.displayName = "Textarea";
|
|
433
|
+
var SIZE_CLASS = {
|
|
434
|
+
sm: "h-4 w-4",
|
|
435
|
+
md: "h-5 w-5",
|
|
436
|
+
lg: "h-6 w-6"
|
|
437
|
+
};
|
|
438
|
+
var Checkbox = forwardRef(
|
|
439
|
+
({ className, size = "md", indeterminate, id, disabled, required, checked, ...props }, ref) => {
|
|
440
|
+
const ctx = useFormControl();
|
|
441
|
+
const isDisabled = disabled ?? ctx?.isDisabled;
|
|
442
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("relative inline-flex shrink-0", SIZE_CLASS[size], className), children: [
|
|
443
|
+
/* @__PURE__ */ jsx(
|
|
444
|
+
"input",
|
|
445
|
+
{
|
|
446
|
+
ref,
|
|
447
|
+
type: "checkbox",
|
|
448
|
+
id: id ?? ctx?.id,
|
|
449
|
+
disabled: isDisabled,
|
|
450
|
+
required: required ?? ctx?.isRequired,
|
|
451
|
+
checked,
|
|
452
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
453
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
454
|
+
className: "peer absolute inset-0 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
455
|
+
...props
|
|
456
|
+
}
|
|
457
|
+
),
|
|
458
|
+
/* @__PURE__ */ jsx(
|
|
459
|
+
"span",
|
|
460
|
+
{
|
|
461
|
+
"aria-hidden": "true",
|
|
462
|
+
className: cn(
|
|
463
|
+
"pointer-events-none grid h-full w-full place-items-center rounded-sm border border-input bg-background text-primary-foreground transition-colors",
|
|
464
|
+
"peer-checked:border-primary peer-checked:bg-primary",
|
|
465
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1",
|
|
466
|
+
"peer-disabled:opacity-50",
|
|
467
|
+
indeterminate && "border-primary bg-primary"
|
|
468
|
+
),
|
|
469
|
+
children: indeterminate ? /* @__PURE__ */ jsx(Minus, { size: Math.round(SIZE_CLASS[size].length * 1.4), className: "h-3 w-3" }) : /* @__PURE__ */ jsx(Check, { className: "h-3 w-3 opacity-0 peer-checked:opacity-100" })
|
|
470
|
+
}
|
|
471
|
+
)
|
|
472
|
+
] });
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
Checkbox.displayName = "Checkbox";
|
|
476
|
+
var SIZE_CLASS2 = {
|
|
477
|
+
sm: "h-4 w-4",
|
|
478
|
+
md: "h-5 w-5",
|
|
479
|
+
lg: "h-6 w-6"
|
|
480
|
+
};
|
|
481
|
+
var Radio = forwardRef(
|
|
482
|
+
({ className, size = "md", id, disabled, required, ...props }, ref) => {
|
|
483
|
+
const ctx = useFormControl();
|
|
484
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("relative inline-flex shrink-0", SIZE_CLASS2[size], className), children: [
|
|
485
|
+
/* @__PURE__ */ jsx(
|
|
486
|
+
"input",
|
|
487
|
+
{
|
|
488
|
+
ref,
|
|
489
|
+
type: "radio",
|
|
490
|
+
id: id ?? ctx?.id,
|
|
491
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
492
|
+
required: required ?? ctx?.isRequired,
|
|
493
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
494
|
+
className: "peer absolute inset-0 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
495
|
+
...props
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
/* @__PURE__ */ jsx(
|
|
499
|
+
"span",
|
|
500
|
+
{
|
|
501
|
+
"aria-hidden": "true",
|
|
502
|
+
className: cn(
|
|
503
|
+
"pointer-events-none grid h-full w-full place-items-center rounded-full border border-input bg-background transition-colors",
|
|
504
|
+
"peer-checked:border-primary",
|
|
505
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1",
|
|
506
|
+
"peer-disabled:opacity-50"
|
|
507
|
+
),
|
|
508
|
+
children: /* @__PURE__ */ jsx("span", { className: "h-2 w-2 rounded-full bg-primary opacity-0 peer-checked:opacity-100" })
|
|
509
|
+
}
|
|
510
|
+
)
|
|
511
|
+
] });
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
Radio.displayName = "Radio";
|
|
515
|
+
var TRACK_CLASS = {
|
|
516
|
+
sm: "h-4 w-7",
|
|
517
|
+
md: "h-5 w-9",
|
|
518
|
+
lg: "h-6 w-11"
|
|
519
|
+
};
|
|
520
|
+
var THUMB_CLASS = {
|
|
521
|
+
sm: "h-3 w-3 peer-checked:translate-x-3",
|
|
522
|
+
md: "h-4 w-4 peer-checked:translate-x-4",
|
|
523
|
+
lg: "h-5 w-5 peer-checked:translate-x-5"
|
|
524
|
+
};
|
|
525
|
+
var Switch = forwardRef(
|
|
526
|
+
({ className, size = "md", id, disabled, required, ...props }, ref) => {
|
|
527
|
+
const ctx = useFormControl();
|
|
528
|
+
return /* @__PURE__ */ jsxs("span", { className: cn("relative inline-flex shrink-0", TRACK_CLASS[size], className), children: [
|
|
529
|
+
/* @__PURE__ */ jsx(
|
|
530
|
+
"input",
|
|
531
|
+
{
|
|
532
|
+
ref,
|
|
533
|
+
type: "checkbox",
|
|
534
|
+
role: "switch",
|
|
535
|
+
id: id ?? ctx?.id,
|
|
536
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
537
|
+
required: required ?? ctx?.isRequired,
|
|
538
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
539
|
+
className: "peer absolute inset-0 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed",
|
|
540
|
+
...props
|
|
541
|
+
}
|
|
542
|
+
),
|
|
543
|
+
/* @__PURE__ */ jsx(
|
|
544
|
+
"span",
|
|
545
|
+
{
|
|
546
|
+
"aria-hidden": "true",
|
|
547
|
+
className: cn(
|
|
548
|
+
"pointer-events-none flex h-full w-full items-center rounded-full bg-input px-0.5 transition-colors",
|
|
549
|
+
"peer-checked:bg-primary",
|
|
550
|
+
"peer-focus-visible:ring-2 peer-focus-visible:ring-ring peer-focus-visible:ring-offset-1",
|
|
551
|
+
"peer-disabled:opacity-50"
|
|
552
|
+
),
|
|
553
|
+
children: /* @__PURE__ */ jsx(
|
|
554
|
+
"span",
|
|
555
|
+
{
|
|
556
|
+
className: cn(
|
|
557
|
+
"rounded-full bg-background shadow-sm transition-transform duration-150",
|
|
558
|
+
THUMB_CLASS[size]
|
|
559
|
+
)
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
}
|
|
563
|
+
)
|
|
564
|
+
] });
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
Switch.displayName = "Switch";
|
|
568
|
+
var TRACK_CLASS2 = {
|
|
569
|
+
sm: "h-1",
|
|
570
|
+
md: "h-1.5",
|
|
571
|
+
lg: "h-2"
|
|
572
|
+
};
|
|
573
|
+
var Slider = forwardRef(
|
|
574
|
+
({ className, size = "md", id, disabled, required, min = 0, max = 100, ...props }, ref) => {
|
|
575
|
+
const ctx = useFormControl();
|
|
576
|
+
return /* @__PURE__ */ jsx(
|
|
577
|
+
"input",
|
|
578
|
+
{
|
|
579
|
+
ref,
|
|
580
|
+
type: "range",
|
|
581
|
+
id: id ?? ctx?.id,
|
|
582
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
583
|
+
required: required ?? ctx?.isRequired,
|
|
584
|
+
min,
|
|
585
|
+
max,
|
|
586
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
587
|
+
className: cn(
|
|
588
|
+
"w-full appearance-none bg-transparent disabled:cursor-not-allowed disabled:opacity-50",
|
|
589
|
+
// WebKit
|
|
590
|
+
"[&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:bg-muted",
|
|
591
|
+
`[&::-webkit-slider-runnable-track]:${TRACK_CLASS2[size]}`,
|
|
592
|
+
"[&::-webkit-slider-thumb]:mt-[-6px] [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-primary [&::-webkit-slider-thumb]:bg-background",
|
|
593
|
+
// Firefox
|
|
594
|
+
`[&::-moz-range-track]:${TRACK_CLASS2[size]}`,
|
|
595
|
+
"[&::-moz-range-track]:rounded-full [&::-moz-range-track]:bg-muted",
|
|
596
|
+
"[&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-primary [&::-moz-range-thumb]:bg-background",
|
|
597
|
+
"focus-visible:outline-none focus-visible:[&::-webkit-slider-thumb]:ring-2 focus-visible:[&::-webkit-slider-thumb]:ring-ring",
|
|
598
|
+
className
|
|
599
|
+
),
|
|
600
|
+
...props
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
}
|
|
604
|
+
);
|
|
605
|
+
Slider.displayName = "Slider";
|
|
606
|
+
var FormField = forwardRef(
|
|
607
|
+
({ label, helper, error, isRequired, isDisabled, isReadOnly, children, className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
608
|
+
FormControlProvider,
|
|
609
|
+
{
|
|
610
|
+
isInvalid: Boolean(error),
|
|
611
|
+
isRequired,
|
|
612
|
+
isDisabled,
|
|
613
|
+
isReadOnly,
|
|
614
|
+
children: /* @__PURE__ */ jsxs(
|
|
615
|
+
"div",
|
|
616
|
+
{
|
|
617
|
+
ref,
|
|
618
|
+
className: cn("flex flex-col gap-1.5", className),
|
|
619
|
+
...props,
|
|
620
|
+
children: [
|
|
621
|
+
label && /* @__PURE__ */ jsx(Label, { children: label }),
|
|
622
|
+
children,
|
|
623
|
+
error ? /* @__PURE__ */ jsx(FormErrorMessage, { children: error }) : helper && /* @__PURE__ */ jsx(FormHelperText, { children: helper })
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
);
|
|
630
|
+
FormField.displayName = "FormField";
|
|
631
|
+
var CheckboxField = forwardRef(
|
|
632
|
+
({ label, description, id, wrapperClassName, className, ...props }, ref) => {
|
|
633
|
+
const generated = useId();
|
|
634
|
+
const inputId = id ?? generated;
|
|
635
|
+
return /* @__PURE__ */ jsxs(
|
|
636
|
+
"label",
|
|
637
|
+
{
|
|
638
|
+
htmlFor: inputId,
|
|
639
|
+
className: cn("flex items-start gap-2.5 cursor-pointer", wrapperClassName),
|
|
640
|
+
children: [
|
|
641
|
+
/* @__PURE__ */ jsx(Checkbox, { ref, id: inputId, className, ...props }),
|
|
642
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-0.5 text-sm", children: [
|
|
643
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: label }),
|
|
644
|
+
description && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: description })
|
|
645
|
+
] })
|
|
646
|
+
]
|
|
647
|
+
}
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
);
|
|
651
|
+
CheckboxField.displayName = "CheckboxField";
|
|
652
|
+
var RadioField = forwardRef(
|
|
653
|
+
({ label, description, id, wrapperClassName, className, ...props }, ref) => {
|
|
654
|
+
const generated = useId();
|
|
655
|
+
const inputId = id ?? generated;
|
|
656
|
+
return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: cn("flex items-start gap-2.5 cursor-pointer", wrapperClassName), children: [
|
|
657
|
+
/* @__PURE__ */ jsx(Radio, { ref, id: inputId, className, ...props }),
|
|
658
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-0.5 text-sm", children: [
|
|
659
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: label }),
|
|
660
|
+
description && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: description })
|
|
661
|
+
] })
|
|
662
|
+
] });
|
|
663
|
+
}
|
|
664
|
+
);
|
|
665
|
+
RadioField.displayName = "RadioField";
|
|
666
|
+
var SwitchField = forwardRef(
|
|
667
|
+
({ label, description, side = "left", id, wrapperClassName, className, ...props }, ref) => {
|
|
668
|
+
const generated = useId();
|
|
669
|
+
const inputId = id ?? generated;
|
|
670
|
+
const text = /* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-0.5 text-sm", children: [
|
|
671
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: label }),
|
|
672
|
+
description && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: description })
|
|
673
|
+
] });
|
|
674
|
+
return /* @__PURE__ */ jsxs(
|
|
675
|
+
"label",
|
|
676
|
+
{
|
|
677
|
+
htmlFor: inputId,
|
|
678
|
+
className: cn(
|
|
679
|
+
"flex cursor-pointer items-start gap-3",
|
|
680
|
+
side === "right" && "flex-row-reverse justify-between",
|
|
681
|
+
wrapperClassName
|
|
682
|
+
),
|
|
683
|
+
children: [
|
|
684
|
+
/* @__PURE__ */ jsx(Switch, { ref, id: inputId, className, ...props }),
|
|
685
|
+
text
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
SwitchField.displayName = "SwitchField";
|
|
692
|
+
var CheckboxGroup = forwardRef(
|
|
693
|
+
({
|
|
694
|
+
legend,
|
|
695
|
+
value,
|
|
696
|
+
defaultValue,
|
|
697
|
+
onValueChange,
|
|
698
|
+
isDisabled,
|
|
699
|
+
orientation = "vertical",
|
|
700
|
+
className,
|
|
701
|
+
children,
|
|
702
|
+
...props
|
|
703
|
+
}, ref) => {
|
|
704
|
+
const [selected, setSelected] = useControlled({
|
|
705
|
+
controlled: value,
|
|
706
|
+
default: defaultValue ?? [],
|
|
707
|
+
onChange: onValueChange
|
|
708
|
+
});
|
|
709
|
+
const toggle = (v) => {
|
|
710
|
+
if (v === void 0) return;
|
|
711
|
+
setSelected(selected.includes(v) ? selected.filter((x) => x !== v) : [...selected, v]);
|
|
712
|
+
};
|
|
713
|
+
return /* @__PURE__ */ jsxs(Fieldset, { ref, disabled: isDisabled, className: cn(className), ...props, children: [
|
|
714
|
+
legend && /* @__PURE__ */ jsx(Legend, { children: legend }),
|
|
715
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap"), children: Children.map(children, (child) => {
|
|
716
|
+
if (!isValidElement(child)) return child;
|
|
717
|
+
const c = child;
|
|
718
|
+
const v = c.props.value;
|
|
719
|
+
return cloneElement(c, {
|
|
720
|
+
checked: v !== void 0 && selected.includes(v),
|
|
721
|
+
onChange: () => toggle(v)
|
|
722
|
+
});
|
|
723
|
+
}) })
|
|
724
|
+
] });
|
|
725
|
+
}
|
|
726
|
+
);
|
|
727
|
+
CheckboxGroup.displayName = "CheckboxGroup";
|
|
728
|
+
var RadioGroup = forwardRef(
|
|
729
|
+
({
|
|
730
|
+
legend,
|
|
731
|
+
name,
|
|
732
|
+
value,
|
|
733
|
+
defaultValue,
|
|
734
|
+
onValueChange,
|
|
735
|
+
isDisabled,
|
|
736
|
+
orientation = "vertical",
|
|
737
|
+
className,
|
|
738
|
+
children,
|
|
739
|
+
...props
|
|
740
|
+
}, ref) => {
|
|
741
|
+
const generatedName = useId$1();
|
|
742
|
+
const groupName = name ?? generatedName;
|
|
743
|
+
const [selected, setSelected] = useControlled({
|
|
744
|
+
controlled: value,
|
|
745
|
+
default: defaultValue ?? null,
|
|
746
|
+
onChange: onValueChange
|
|
747
|
+
});
|
|
748
|
+
return /* @__PURE__ */ jsxs(Fieldset, { ref, disabled: isDisabled, className: cn(className), ...props, children: [
|
|
749
|
+
legend && /* @__PURE__ */ jsx(Legend, { children: legend }),
|
|
750
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex gap-3", orientation === "vertical" ? "flex-col" : "flex-row flex-wrap"), children: Children.map(children, (child) => {
|
|
751
|
+
if (!isValidElement(child)) return child;
|
|
752
|
+
const c = child;
|
|
753
|
+
const v = c.props.value;
|
|
754
|
+
return cloneElement(c, {
|
|
755
|
+
name: groupName,
|
|
756
|
+
checked: v !== void 0 && selected === v,
|
|
757
|
+
onChange: () => setSelected(v ?? null)
|
|
758
|
+
});
|
|
759
|
+
}) })
|
|
760
|
+
] });
|
|
761
|
+
}
|
|
762
|
+
);
|
|
763
|
+
RadioGroup.displayName = "RadioGroup";
|
|
764
|
+
var SIZE = {
|
|
765
|
+
sm: "h-9 w-9 text-base",
|
|
766
|
+
md: "h-11 w-11 text-lg",
|
|
767
|
+
lg: "h-14 w-14 text-xl"
|
|
768
|
+
};
|
|
769
|
+
var PinInput = forwardRef(
|
|
770
|
+
({
|
|
771
|
+
length = 6,
|
|
772
|
+
value,
|
|
773
|
+
defaultValue,
|
|
774
|
+
onValueChange,
|
|
775
|
+
onComplete,
|
|
776
|
+
type = "numeric",
|
|
777
|
+
size = "md",
|
|
778
|
+
mask,
|
|
779
|
+
isDisabled,
|
|
780
|
+
className,
|
|
781
|
+
...props
|
|
782
|
+
}, ref) => {
|
|
783
|
+
const [val, setVal] = useControlled({
|
|
784
|
+
controlled: value,
|
|
785
|
+
default: defaultValue ?? "",
|
|
786
|
+
onChange: onValueChange
|
|
787
|
+
});
|
|
788
|
+
const cells = Array.from({ length }, (_, i) => val[i] ?? "");
|
|
789
|
+
const inputs = useRef([]);
|
|
790
|
+
const wrapperRef = useRef(null);
|
|
791
|
+
useImperativeHandle(ref, () => wrapperRef.current);
|
|
792
|
+
const isAllowed = (ch) => type === "numeric" ? /^[0-9]$/.test(ch) : /^[A-Za-z0-9]$/.test(ch);
|
|
793
|
+
const update = (next) => {
|
|
794
|
+
const trimmed = next.slice(0, length);
|
|
795
|
+
setVal(trimmed);
|
|
796
|
+
if (trimmed.length === length) onComplete?.(trimmed);
|
|
797
|
+
};
|
|
798
|
+
const handleChange = (i, raw) => {
|
|
799
|
+
const ch = raw.slice(-1);
|
|
800
|
+
if (ch && !isAllowed(ch)) return;
|
|
801
|
+
const arr = cells.slice();
|
|
802
|
+
arr[i] = ch;
|
|
803
|
+
const next = arr.join("").slice(0, length);
|
|
804
|
+
update(next);
|
|
805
|
+
if (ch && i < length - 1) inputs.current[i + 1]?.focus();
|
|
806
|
+
};
|
|
807
|
+
const handleKeyDown = (i, e) => {
|
|
808
|
+
if (e.key === "Backspace" && !cells[i] && i > 0) {
|
|
809
|
+
inputs.current[i - 1]?.focus();
|
|
810
|
+
} else if (e.key === "ArrowLeft" && i > 0) {
|
|
811
|
+
e.preventDefault();
|
|
812
|
+
inputs.current[i - 1]?.focus();
|
|
813
|
+
} else if (e.key === "ArrowRight" && i < length - 1) {
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
inputs.current[i + 1]?.focus();
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
const handlePaste = (e) => {
|
|
819
|
+
const pasted = e.clipboardData.getData("text").replace(/\s+/g, "");
|
|
820
|
+
const filtered = pasted.split("").filter(isAllowed).join("");
|
|
821
|
+
if (filtered) {
|
|
822
|
+
e.preventDefault();
|
|
823
|
+
update(filtered);
|
|
824
|
+
const focusIdx = Math.min(filtered.length, length - 1);
|
|
825
|
+
inputs.current[focusIdx]?.focus();
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
return /* @__PURE__ */ jsx("div", { ref: wrapperRef, className: cn("inline-flex gap-2", className), ...props, children: cells.map((ch, i) => /* @__PURE__ */ jsx(
|
|
829
|
+
"input",
|
|
830
|
+
{
|
|
831
|
+
ref: (el) => {
|
|
832
|
+
inputs.current[i] = el;
|
|
833
|
+
},
|
|
834
|
+
type: mask ? "password" : "text",
|
|
835
|
+
inputMode: type === "numeric" ? "numeric" : "text",
|
|
836
|
+
autoComplete: "one-time-code",
|
|
837
|
+
maxLength: 1,
|
|
838
|
+
disabled: isDisabled,
|
|
839
|
+
value: ch,
|
|
840
|
+
onChange: (e) => handleChange(i, e.target.value),
|
|
841
|
+
onKeyDown: (e) => handleKeyDown(i, e),
|
|
842
|
+
onPaste: handlePaste,
|
|
843
|
+
className: cn(
|
|
844
|
+
inputBaseVariants({ state: "default" }),
|
|
845
|
+
"text-center font-medium",
|
|
846
|
+
SIZE[size]
|
|
847
|
+
)
|
|
848
|
+
},
|
|
849
|
+
i
|
|
850
|
+
)) });
|
|
851
|
+
}
|
|
852
|
+
);
|
|
853
|
+
PinInput.displayName = "PinInput";
|
|
854
|
+
function applyMask(raw, mask) {
|
|
855
|
+
let out = "";
|
|
856
|
+
let r = 0;
|
|
857
|
+
for (let m = 0; m < mask.length && r < raw.length; m++) {
|
|
858
|
+
const tok = mask[m];
|
|
859
|
+
const ch = raw[r];
|
|
860
|
+
if (!tok || !ch) break;
|
|
861
|
+
if (tok === "#") {
|
|
862
|
+
if (/[0-9]/.test(ch)) {
|
|
863
|
+
out += ch;
|
|
864
|
+
r++;
|
|
865
|
+
} else {
|
|
866
|
+
r++;
|
|
867
|
+
m--;
|
|
868
|
+
}
|
|
869
|
+
} else if (tok === "A") {
|
|
870
|
+
if (/[A-Za-z]/.test(ch)) {
|
|
871
|
+
out += ch;
|
|
872
|
+
r++;
|
|
873
|
+
} else {
|
|
874
|
+
r++;
|
|
875
|
+
m--;
|
|
876
|
+
}
|
|
877
|
+
} else if (tok === "*") {
|
|
878
|
+
if (/[A-Za-z0-9]/.test(ch)) {
|
|
879
|
+
out += ch;
|
|
880
|
+
r++;
|
|
881
|
+
} else {
|
|
882
|
+
r++;
|
|
883
|
+
m--;
|
|
884
|
+
}
|
|
885
|
+
} else {
|
|
886
|
+
out += tok;
|
|
887
|
+
if (ch === tok) r++;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return out;
|
|
891
|
+
}
|
|
892
|
+
var MaskedInput = forwardRef(
|
|
893
|
+
({ className, size, state, mask, value, defaultValue, onValueChange, id, disabled, required, readOnly, ...props }, ref) => {
|
|
894
|
+
const ctx = useFormControl();
|
|
895
|
+
const finalState = state ?? (ctx?.isInvalid ? "invalid" : "default");
|
|
896
|
+
const [val, setVal] = useControlled({
|
|
897
|
+
controlled: value,
|
|
898
|
+
default: defaultValue ?? "",
|
|
899
|
+
onChange: onValueChange
|
|
900
|
+
});
|
|
901
|
+
return /* @__PURE__ */ jsx(
|
|
902
|
+
"input",
|
|
903
|
+
{
|
|
904
|
+
ref,
|
|
905
|
+
type: "text",
|
|
906
|
+
value: val,
|
|
907
|
+
onChange: (e) => setVal(applyMask(e.target.value, mask)),
|
|
908
|
+
id: id ?? ctx?.id,
|
|
909
|
+
disabled: disabled ?? ctx?.isDisabled,
|
|
910
|
+
required: required ?? ctx?.isRequired,
|
|
911
|
+
readOnly: readOnly ?? ctx?.isReadOnly,
|
|
912
|
+
"aria-invalid": ctx?.isInvalid || void 0,
|
|
913
|
+
"aria-describedby": ctx ? `${ctx.helperId} ${ctx.errorId}` : void 0,
|
|
914
|
+
className: cn(inputBaseVariants({ size, state: finalState }), className),
|
|
915
|
+
...props
|
|
916
|
+
}
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
);
|
|
920
|
+
MaskedInput.displayName = "MaskedInput";
|
|
921
|
+
var CurrencyInput = forwardRef(
|
|
922
|
+
({ symbol = "$", className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
923
|
+
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground", children: symbol }),
|
|
924
|
+
/* @__PURE__ */ jsx(NumberInput, { ref, ...props, className: "pl-7" })
|
|
925
|
+
] })
|
|
926
|
+
);
|
|
927
|
+
CurrencyInput.displayName = "CurrencyInput";
|
|
928
|
+
var PercentInput = forwardRef(
|
|
929
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
930
|
+
/* @__PURE__ */ jsx(NumberInput, { ref, ...props, className: "pr-16" }),
|
|
931
|
+
/* @__PURE__ */ jsx("span", { className: "pointer-events-none absolute right-12 top-1/2 -translate-y-1/2 text-sm text-muted-foreground", children: "%" })
|
|
932
|
+
] })
|
|
933
|
+
);
|
|
934
|
+
PercentInput.displayName = "PercentInput";
|
|
935
|
+
var CharacterCount = forwardRef(
|
|
936
|
+
({ value, max, showMax = true, className, ...props }, ref) => {
|
|
937
|
+
const over = value > max;
|
|
938
|
+
return /* @__PURE__ */ jsxs(
|
|
939
|
+
"div",
|
|
940
|
+
{
|
|
941
|
+
ref,
|
|
942
|
+
"aria-live": "polite",
|
|
943
|
+
className: cn(
|
|
944
|
+
"text-right text-xs",
|
|
945
|
+
over ? "text-destructive" : "text-muted-foreground",
|
|
946
|
+
className
|
|
947
|
+
),
|
|
948
|
+
...props,
|
|
949
|
+
children: [
|
|
950
|
+
value,
|
|
951
|
+
showMax && ` / ${max}`
|
|
952
|
+
]
|
|
953
|
+
}
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
);
|
|
957
|
+
CharacterCount.displayName = "CharacterCount";
|
|
958
|
+
var InputAddon = forwardRef(
|
|
959
|
+
({ leading, trailing, children, className, ...props }, ref) => /* @__PURE__ */ jsxs(
|
|
960
|
+
"div",
|
|
961
|
+
{
|
|
962
|
+
ref,
|
|
963
|
+
className: cn(
|
|
964
|
+
"inline-flex w-full items-stretch [&>*]:rounded-none",
|
|
965
|
+
"[&>*:first-child]:rounded-l-md [&>*:last-child]:rounded-r-md",
|
|
966
|
+
"[&>*:not(:first-child)]:-ml-px",
|
|
967
|
+
className
|
|
968
|
+
),
|
|
969
|
+
...props,
|
|
970
|
+
children: [
|
|
971
|
+
leading && /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 items-center border border-input bg-muted px-3 text-sm text-muted-foreground", children: leading }),
|
|
972
|
+
children,
|
|
973
|
+
trailing && /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 items-center border border-input bg-muted px-3 text-sm text-muted-foreground", children: trailing })
|
|
974
|
+
]
|
|
975
|
+
}
|
|
976
|
+
)
|
|
977
|
+
);
|
|
978
|
+
InputAddon.displayName = "InputAddon";
|
|
979
|
+
var InputGroup = forwardRef(
|
|
980
|
+
({ orientation = "horizontal", className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
981
|
+
"div",
|
|
982
|
+
{
|
|
983
|
+
ref,
|
|
984
|
+
className: cn(
|
|
985
|
+
"inline-flex w-full",
|
|
986
|
+
orientation === "horizontal" ? "flex-row" : "flex-col",
|
|
987
|
+
orientation === "horizontal" ? "[&>*]:rounded-none [&>*:first-child]:rounded-l-md [&>*:last-child]:rounded-r-md [&>*:not(:first-child)]:-ml-px" : "[&>*]:rounded-none [&>*:first-child]:rounded-t-md [&>*:last-child]:rounded-b-md [&>*:not(:first-child)]:-mt-px",
|
|
988
|
+
className
|
|
989
|
+
),
|
|
990
|
+
...props
|
|
991
|
+
}
|
|
992
|
+
)
|
|
993
|
+
);
|
|
994
|
+
InputGroup.displayName = "InputGroup";
|
|
995
|
+
var LabeledInput = forwardRef(
|
|
996
|
+
({ label, children, trailing, className, ...props }, ref) => {
|
|
997
|
+
const generated = useId();
|
|
998
|
+
const id = children.props.id ?? generated;
|
|
999
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex flex-col gap-1.5", className), ...props, children: [
|
|
1000
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
1001
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
1002
|
+
trailing && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: trailing })
|
|
1003
|
+
] }),
|
|
1004
|
+
React.cloneElement(children, { id })
|
|
1005
|
+
] });
|
|
1006
|
+
}
|
|
1007
|
+
);
|
|
1008
|
+
LabeledInput.displayName = "LabeledInput";
|
|
1009
|
+
var SIZE2 = {
|
|
1010
|
+
sm: "p-3 text-xs",
|
|
1011
|
+
md: "p-4 text-sm",
|
|
1012
|
+
lg: "p-5 text-base"
|
|
1013
|
+
};
|
|
1014
|
+
var ChoiceCard = forwardRef(
|
|
1015
|
+
({ label, description, icon, size = "md", id, className, ...props }, ref) => {
|
|
1016
|
+
const generated = useId();
|
|
1017
|
+
const inputId = id ?? generated;
|
|
1018
|
+
return /* @__PURE__ */ jsxs(
|
|
1019
|
+
"label",
|
|
1020
|
+
{
|
|
1021
|
+
htmlFor: inputId,
|
|
1022
|
+
className: cn(
|
|
1023
|
+
"group relative block cursor-pointer rounded-lg border border-input bg-card text-card-foreground transition-colors",
|
|
1024
|
+
"hover:border-border-strong has-[:checked]:border-primary has-[:checked]:bg-primary-soft/30",
|
|
1025
|
+
"has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring",
|
|
1026
|
+
SIZE2[size],
|
|
1027
|
+
className
|
|
1028
|
+
),
|
|
1029
|
+
children: [
|
|
1030
|
+
/* @__PURE__ */ jsx(Radio, { ref, id: inputId, className: "absolute right-3 top-3", ...props }),
|
|
1031
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 pr-7", children: [
|
|
1032
|
+
icon && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: icon }),
|
|
1033
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1034
|
+
/* @__PURE__ */ jsx("div", { className: "font-medium text-foreground", children: label }),
|
|
1035
|
+
description && /* @__PURE__ */ jsx("div", { className: "mt-0.5 text-muted-foreground", children: description })
|
|
1036
|
+
] })
|
|
1037
|
+
] })
|
|
1038
|
+
]
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
);
|
|
1043
|
+
ChoiceCard.displayName = "ChoiceCard";
|
|
1044
|
+
var LABELS = ["Too weak", "Weak", "Fair", "Strong", "Excellent"];
|
|
1045
|
+
var TONE = ["bg-destructive", "bg-destructive", "bg-warning", "bg-success", "bg-success"];
|
|
1046
|
+
function scorePassword(pw) {
|
|
1047
|
+
let score = 0;
|
|
1048
|
+
if (pw.length >= 8) score++;
|
|
1049
|
+
if (pw.length >= 12) score++;
|
|
1050
|
+
if (/[a-z]/.test(pw) && /[A-Z]/.test(pw)) score++;
|
|
1051
|
+
if (/\d/.test(pw)) score++;
|
|
1052
|
+
if (/[^A-Za-z0-9]/.test(pw)) score++;
|
|
1053
|
+
return Math.min(4, score);
|
|
1054
|
+
}
|
|
1055
|
+
var PasswordStrength = forwardRef(
|
|
1056
|
+
({ value, score, hideLabel, className, ...props }, ref) => {
|
|
1057
|
+
const s = score ?? (value.length === 0 ? 0 : scorePassword(value));
|
|
1058
|
+
const label = LABELS[s] ?? "";
|
|
1059
|
+
const tone = TONE[s] ?? "bg-destructive";
|
|
1060
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("flex flex-col gap-1", className), ...props, children: [
|
|
1061
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-1", "aria-hidden": "true", children: [0, 1, 2, 3].map((i) => /* @__PURE__ */ jsx(
|
|
1062
|
+
"div",
|
|
1063
|
+
{
|
|
1064
|
+
className: cn(
|
|
1065
|
+
"h-1 flex-1 rounded-full bg-muted transition-colors",
|
|
1066
|
+
i < s && tone
|
|
1067
|
+
)
|
|
1068
|
+
},
|
|
1069
|
+
i
|
|
1070
|
+
)) }),
|
|
1071
|
+
!hideLabel && value && /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: label })
|
|
1072
|
+
] });
|
|
1073
|
+
}
|
|
1074
|
+
);
|
|
1075
|
+
PasswordStrength.displayName = "PasswordStrength";
|
|
1076
|
+
var SIZE3 = {
|
|
1077
|
+
sm: "h-8 px-3 text-sm",
|
|
1078
|
+
md: "h-10 px-4 text-sm",
|
|
1079
|
+
lg: "h-12 px-6 text-base"
|
|
1080
|
+
};
|
|
1081
|
+
var FilePicker = forwardRef(
|
|
1082
|
+
({ label = "Choose file", onFilesChange, preview, size = "md", className, disabled, ...props }, ref) => {
|
|
1083
|
+
const inputRef = useRef(null);
|
|
1084
|
+
useImperativeHandle(ref, () => inputRef.current);
|
|
1085
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("inline-flex items-center gap-3", className), children: [
|
|
1086
|
+
/* @__PURE__ */ jsxs(
|
|
1087
|
+
"button",
|
|
1088
|
+
{
|
|
1089
|
+
type: "button",
|
|
1090
|
+
disabled,
|
|
1091
|
+
onClick: () => inputRef.current?.click(),
|
|
1092
|
+
className: cn(
|
|
1093
|
+
"inline-flex items-center gap-2 rounded-md border border-input bg-background font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
1094
|
+
SIZE3[size]
|
|
1095
|
+
),
|
|
1096
|
+
children: [
|
|
1097
|
+
/* @__PURE__ */ jsx(Icon, { icon: Upload, size: 16 }),
|
|
1098
|
+
label
|
|
1099
|
+
]
|
|
1100
|
+
}
|
|
1101
|
+
),
|
|
1102
|
+
/* @__PURE__ */ jsx(
|
|
1103
|
+
"input",
|
|
1104
|
+
{
|
|
1105
|
+
ref: inputRef,
|
|
1106
|
+
type: "file",
|
|
1107
|
+
disabled,
|
|
1108
|
+
className: "sr-only",
|
|
1109
|
+
onChange: (e) => onFilesChange?.(e.target.files),
|
|
1110
|
+
...props
|
|
1111
|
+
}
|
|
1112
|
+
),
|
|
1113
|
+
preview && /* @__PURE__ */ jsx("span", { className: "truncate text-sm text-muted-foreground", children: preview })
|
|
1114
|
+
] });
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
FilePicker.displayName = "FilePicker";
|
|
1118
|
+
|
|
1119
|
+
// src/forms/listbox/Listbox.variants.ts
|
|
1120
|
+
var listboxVariants = tv({
|
|
1121
|
+
base: "flex max-h-72 flex-col gap-0.5 overflow-y-auto rounded-md border border-border bg-popover p-1 text-sm text-popover-foreground shadow-md outline-none"
|
|
1122
|
+
});
|
|
1123
|
+
var listboxItemVariants = tv({
|
|
1124
|
+
base: "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none",
|
|
1125
|
+
variants: {
|
|
1126
|
+
state: {
|
|
1127
|
+
default: "text-popover-foreground",
|
|
1128
|
+
active: "bg-muted text-foreground",
|
|
1129
|
+
selected: "bg-primary-soft text-primary-soft-foreground",
|
|
1130
|
+
disabled: "pointer-events-none opacity-50"
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
defaultVariants: { state: "default" }
|
|
1134
|
+
});
|
|
1135
|
+
var listboxGroupLabelVariants = tv({
|
|
1136
|
+
base: "px-2 py-1.5 text-xs font-semibold text-muted-foreground"
|
|
1137
|
+
});
|
|
1138
|
+
var listboxSeparatorVariants = tv({
|
|
1139
|
+
base: "-mx-1 my-1 h-px bg-border"
|
|
1140
|
+
});
|
|
1141
|
+
var listboxEmptyVariants = tv({
|
|
1142
|
+
base: "px-2 py-6 text-center text-sm text-muted-foreground"
|
|
1143
|
+
});
|
|
1144
|
+
var ListboxContext = createContext(null);
|
|
1145
|
+
function useListboxContext() {
|
|
1146
|
+
const ctx = useContext(ListboxContext);
|
|
1147
|
+
if (!ctx) throw new Error("Listbox.Item / Group / Separator must be used inside <Listbox>");
|
|
1148
|
+
return ctx;
|
|
1149
|
+
}
|
|
1150
|
+
var Listbox = forwardRef(function Listbox2(props, ref) {
|
|
1151
|
+
const {
|
|
1152
|
+
multiple = false,
|
|
1153
|
+
value,
|
|
1154
|
+
defaultValue,
|
|
1155
|
+
onValueChange,
|
|
1156
|
+
disabled,
|
|
1157
|
+
className,
|
|
1158
|
+
children,
|
|
1159
|
+
onKeyDown,
|
|
1160
|
+
...rest
|
|
1161
|
+
} = props;
|
|
1162
|
+
const initial = defaultValue ?? (multiple ? [] : "");
|
|
1163
|
+
const [current, setCurrent] = useControlled({
|
|
1164
|
+
controlled: value,
|
|
1165
|
+
default: initial,
|
|
1166
|
+
onChange: onValueChange
|
|
1167
|
+
});
|
|
1168
|
+
const values = useMemo(
|
|
1169
|
+
() => Array.isArray(current) ? current : current ? [current] : [],
|
|
1170
|
+
[current]
|
|
1171
|
+
);
|
|
1172
|
+
const items = useRef([]);
|
|
1173
|
+
const [activeId, setActiveId] = useState(null);
|
|
1174
|
+
const registerItem = useCallback((entry) => {
|
|
1175
|
+
if (!items.current.some((i) => i.id === entry.id)) items.current.push(entry);
|
|
1176
|
+
}, []);
|
|
1177
|
+
const updateItem = useCallback((entry) => {
|
|
1178
|
+
const idx = items.current.findIndex((i) => i.id === entry.id);
|
|
1179
|
+
if (idx >= 0) items.current[idx] = entry;
|
|
1180
|
+
}, []);
|
|
1181
|
+
const unregisterItem = useCallback((id) => {
|
|
1182
|
+
items.current = items.current.filter((i) => i.id !== id);
|
|
1183
|
+
}, []);
|
|
1184
|
+
const onItemSelect = useCallback(
|
|
1185
|
+
(next) => {
|
|
1186
|
+
if (multiple) {
|
|
1187
|
+
const cur = Array.isArray(current) ? current : [];
|
|
1188
|
+
const has = cur.includes(next);
|
|
1189
|
+
setCurrent(has ? cur.filter((v) => v !== next) : [...cur, next]);
|
|
1190
|
+
} else {
|
|
1191
|
+
setCurrent(next);
|
|
1192
|
+
}
|
|
1193
|
+
},
|
|
1194
|
+
[multiple, current, setCurrent]
|
|
1195
|
+
);
|
|
1196
|
+
useEffect(() => {
|
|
1197
|
+
if (activeId) return;
|
|
1198
|
+
const firstSelected = items.current.find(
|
|
1199
|
+
(i) => !i.disabled && values.includes(i.value)
|
|
1200
|
+
);
|
|
1201
|
+
const firstEnabled = items.current.find((i) => !i.disabled);
|
|
1202
|
+
setActiveId((firstSelected ?? firstEnabled)?.id ?? null);
|
|
1203
|
+
}, []);
|
|
1204
|
+
const moveActive = useCallback(
|
|
1205
|
+
(direction, jump = 1) => {
|
|
1206
|
+
const list = items.current.filter((i) => !i.disabled);
|
|
1207
|
+
if (list.length === 0) return;
|
|
1208
|
+
const currentIdx = list.findIndex((i) => i.id === activeId);
|
|
1209
|
+
let nextIdx = currentIdx + direction * jump;
|
|
1210
|
+
if (currentIdx === -1) nextIdx = direction === 1 ? 0 : list.length - 1;
|
|
1211
|
+
if (nextIdx < 0) nextIdx = 0;
|
|
1212
|
+
if (nextIdx >= list.length) nextIdx = list.length - 1;
|
|
1213
|
+
const nextEntry = list[nextIdx];
|
|
1214
|
+
if (nextEntry) setActiveId(nextEntry.id);
|
|
1215
|
+
},
|
|
1216
|
+
[activeId]
|
|
1217
|
+
);
|
|
1218
|
+
const handleKeyDown = useCallback(
|
|
1219
|
+
(event) => {
|
|
1220
|
+
onKeyDown?.(event);
|
|
1221
|
+
if (event.defaultPrevented || disabled) return;
|
|
1222
|
+
switch (event.key) {
|
|
1223
|
+
case "ArrowDown":
|
|
1224
|
+
event.preventDefault();
|
|
1225
|
+
moveActive(1);
|
|
1226
|
+
break;
|
|
1227
|
+
case "ArrowUp":
|
|
1228
|
+
event.preventDefault();
|
|
1229
|
+
moveActive(-1);
|
|
1230
|
+
break;
|
|
1231
|
+
case "Home":
|
|
1232
|
+
event.preventDefault();
|
|
1233
|
+
moveActive(-1, items.current.length);
|
|
1234
|
+
break;
|
|
1235
|
+
case "End":
|
|
1236
|
+
event.preventDefault();
|
|
1237
|
+
moveActive(1, items.current.length);
|
|
1238
|
+
break;
|
|
1239
|
+
case "PageDown":
|
|
1240
|
+
event.preventDefault();
|
|
1241
|
+
moveActive(1, 10);
|
|
1242
|
+
break;
|
|
1243
|
+
case "PageUp":
|
|
1244
|
+
event.preventDefault();
|
|
1245
|
+
moveActive(-1, 10);
|
|
1246
|
+
break;
|
|
1247
|
+
case "Enter":
|
|
1248
|
+
case " ": {
|
|
1249
|
+
if (!activeId) return;
|
|
1250
|
+
const entry = items.current.find((i) => i.id === activeId);
|
|
1251
|
+
if (!entry || entry.disabled) return;
|
|
1252
|
+
event.preventDefault();
|
|
1253
|
+
onItemSelect(entry.value);
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
},
|
|
1258
|
+
[activeId, disabled, moveActive, onItemSelect, onKeyDown]
|
|
1259
|
+
);
|
|
1260
|
+
const ctx = useMemo(
|
|
1261
|
+
() => ({
|
|
1262
|
+
multiple,
|
|
1263
|
+
values,
|
|
1264
|
+
activeId,
|
|
1265
|
+
onItemSelect,
|
|
1266
|
+
registerItem: (e) => {
|
|
1267
|
+
const existing = items.current.find((i) => i.id === e.id);
|
|
1268
|
+
if (existing) updateItem(e);
|
|
1269
|
+
else registerItem(e);
|
|
1270
|
+
},
|
|
1271
|
+
unregisterItem,
|
|
1272
|
+
setActiveId
|
|
1273
|
+
}),
|
|
1274
|
+
[multiple, values, activeId, onItemSelect, registerItem, unregisterItem, updateItem]
|
|
1275
|
+
);
|
|
1276
|
+
return /* @__PURE__ */ jsx(ListboxContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
1277
|
+
"div",
|
|
1278
|
+
{
|
|
1279
|
+
ref,
|
|
1280
|
+
role: "listbox",
|
|
1281
|
+
tabIndex: disabled ? -1 : 0,
|
|
1282
|
+
"aria-multiselectable": multiple || void 0,
|
|
1283
|
+
"aria-activedescendant": activeId ?? void 0,
|
|
1284
|
+
"aria-disabled": disabled || void 0,
|
|
1285
|
+
onKeyDown: handleKeyDown,
|
|
1286
|
+
className: cn(listboxVariants(), className),
|
|
1287
|
+
...rest,
|
|
1288
|
+
children
|
|
1289
|
+
}
|
|
1290
|
+
) });
|
|
1291
|
+
});
|
|
1292
|
+
var ListboxItem = forwardRef(function ListboxItem2({ value, disabled = false, className, children, onClick, onPointerEnter, ...rest }, forwardedRef) {
|
|
1293
|
+
const ctx = useListboxContext();
|
|
1294
|
+
const id = useId$1();
|
|
1295
|
+
const ref = useRef(null);
|
|
1296
|
+
useEffect(() => {
|
|
1297
|
+
ctx.registerItem({ id, value, disabled, ref: ref.current });
|
|
1298
|
+
return () => ctx.unregisterItem(id);
|
|
1299
|
+
}, [ctx, id, value, disabled]);
|
|
1300
|
+
const isSelected = ctx.values.includes(value);
|
|
1301
|
+
const isActive = ctx.activeId === id;
|
|
1302
|
+
const state = disabled ? "disabled" : isSelected ? "selected" : isActive ? "active" : "default";
|
|
1303
|
+
const setRefs = (node) => {
|
|
1304
|
+
ref.current = node;
|
|
1305
|
+
if (typeof forwardedRef === "function") forwardedRef(node);
|
|
1306
|
+
else if (forwardedRef) forwardedRef.current = node;
|
|
1307
|
+
};
|
|
1308
|
+
return /* @__PURE__ */ jsxs(
|
|
1309
|
+
"div",
|
|
1310
|
+
{
|
|
1311
|
+
ref: setRefs,
|
|
1312
|
+
id,
|
|
1313
|
+
role: "option",
|
|
1314
|
+
"aria-selected": isSelected,
|
|
1315
|
+
"aria-disabled": disabled || void 0,
|
|
1316
|
+
"data-active": isActive ? "" : void 0,
|
|
1317
|
+
"data-selected": isSelected ? "" : void 0,
|
|
1318
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1319
|
+
onClick: (e) => {
|
|
1320
|
+
onClick?.(e);
|
|
1321
|
+
if (e.defaultPrevented || disabled) return;
|
|
1322
|
+
ctx.onItemSelect(value);
|
|
1323
|
+
},
|
|
1324
|
+
onPointerEnter: (e) => {
|
|
1325
|
+
onPointerEnter?.(e);
|
|
1326
|
+
if (!disabled) ctx.setActiveId(id);
|
|
1327
|
+
},
|
|
1328
|
+
className: cn(listboxItemVariants({ state }), className),
|
|
1329
|
+
...rest,
|
|
1330
|
+
children: [
|
|
1331
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children }),
|
|
1332
|
+
ctx.multiple && isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }),
|
|
1333
|
+
!ctx.multiple && isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 opacity-80" })
|
|
1334
|
+
]
|
|
1335
|
+
}
|
|
1336
|
+
);
|
|
1337
|
+
});
|
|
1338
|
+
function ListboxGroup({ label, children, className, ...rest }) {
|
|
1339
|
+
const labelId = useId$1();
|
|
1340
|
+
return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
|
|
1341
|
+
label && /* @__PURE__ */ jsx("div", { id: labelId, className: listboxGroupLabelVariants(), children: label }),
|
|
1342
|
+
children
|
|
1343
|
+
] });
|
|
1344
|
+
}
|
|
1345
|
+
function ListboxSeparator(props) {
|
|
1346
|
+
return /* @__PURE__ */ jsx("div", { role: "separator", className: listboxSeparatorVariants(), ...props });
|
|
1347
|
+
}
|
|
1348
|
+
function ListboxEmpty({ children, className, ...rest }) {
|
|
1349
|
+
return /* @__PURE__ */ jsx("div", { role: "presentation", className: cn(listboxEmptyVariants(), className), ...rest, children });
|
|
1350
|
+
}
|
|
1351
|
+
Listbox.Item = ListboxItem;
|
|
1352
|
+
Listbox.Group = ListboxGroup;
|
|
1353
|
+
Listbox.Separator = ListboxSeparator;
|
|
1354
|
+
Listbox.Empty = ListboxEmpty;
|
|
1355
|
+
|
|
1356
|
+
// src/forms/select/Select.variants.ts
|
|
1357
|
+
var selectTriggerVariants = tv({
|
|
1358
|
+
base: "flex w-full items-center justify-between gap-2 rounded-md border bg-background text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60 data-[state=open]:border-border-strong",
|
|
1359
|
+
variants: {
|
|
1360
|
+
size: {
|
|
1361
|
+
sm: "h-8 px-2.5 text-sm",
|
|
1362
|
+
md: "h-10 px-3 text-sm",
|
|
1363
|
+
lg: "h-12 px-4 text-base"
|
|
1364
|
+
},
|
|
1365
|
+
state: {
|
|
1366
|
+
default: "border-input hover:border-border-strong",
|
|
1367
|
+
invalid: "border-destructive focus-visible:ring-destructive"
|
|
1368
|
+
}
|
|
1369
|
+
},
|
|
1370
|
+
defaultVariants: {
|
|
1371
|
+
size: "md",
|
|
1372
|
+
state: "default"
|
|
1373
|
+
}
|
|
1374
|
+
});
|
|
1375
|
+
var SelectContext = createContext(null);
|
|
1376
|
+
function useSelectContext() {
|
|
1377
|
+
const ctx = useContext(SelectContext);
|
|
1378
|
+
if (!ctx) throw new Error("Select.* must be used inside <Select>");
|
|
1379
|
+
return ctx;
|
|
1380
|
+
}
|
|
1381
|
+
function Select({
|
|
1382
|
+
value,
|
|
1383
|
+
defaultValue,
|
|
1384
|
+
onValueChange,
|
|
1385
|
+
disabled = false,
|
|
1386
|
+
name,
|
|
1387
|
+
invalid,
|
|
1388
|
+
defaultOpen = false,
|
|
1389
|
+
open: openProp,
|
|
1390
|
+
onOpenChange,
|
|
1391
|
+
children
|
|
1392
|
+
}) {
|
|
1393
|
+
const [openState, setOpenState] = useControlled({
|
|
1394
|
+
controlled: openProp,
|
|
1395
|
+
default: defaultOpen,
|
|
1396
|
+
onChange: onOpenChange
|
|
1397
|
+
});
|
|
1398
|
+
const [valueState, setValueState] = useControlled({
|
|
1399
|
+
controlled: value,
|
|
1400
|
+
default: defaultValue ?? "",
|
|
1401
|
+
onChange: onValueChange
|
|
1402
|
+
});
|
|
1403
|
+
const triggerRef = useRef(null);
|
|
1404
|
+
const [labels, setLabels] = useState({});
|
|
1405
|
+
const registerLabel = useCallback((v, label) => {
|
|
1406
|
+
setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
|
|
1407
|
+
}, []);
|
|
1408
|
+
const unregisterLabel = useCallback((v) => {
|
|
1409
|
+
setLabels((prev) => {
|
|
1410
|
+
if (!(v in prev)) return prev;
|
|
1411
|
+
const next = { ...prev };
|
|
1412
|
+
delete next[v];
|
|
1413
|
+
return next;
|
|
1414
|
+
});
|
|
1415
|
+
}, []);
|
|
1416
|
+
const onSelect = useCallback(
|
|
1417
|
+
(next) => {
|
|
1418
|
+
setValueState(next);
|
|
1419
|
+
setOpenState(false);
|
|
1420
|
+
requestAnimationFrame(() => triggerRef.current?.focus());
|
|
1421
|
+
},
|
|
1422
|
+
[setValueState, setOpenState]
|
|
1423
|
+
);
|
|
1424
|
+
const ctx = useMemo(
|
|
1425
|
+
() => ({
|
|
1426
|
+
open: openState,
|
|
1427
|
+
setOpen: setOpenState,
|
|
1428
|
+
value: valueState,
|
|
1429
|
+
onSelect,
|
|
1430
|
+
triggerRef,
|
|
1431
|
+
labels,
|
|
1432
|
+
registerLabel,
|
|
1433
|
+
unregisterLabel,
|
|
1434
|
+
disabled,
|
|
1435
|
+
name,
|
|
1436
|
+
invalid
|
|
1437
|
+
}),
|
|
1438
|
+
[
|
|
1439
|
+
openState,
|
|
1440
|
+
setOpenState,
|
|
1441
|
+
valueState,
|
|
1442
|
+
onSelect,
|
|
1443
|
+
labels,
|
|
1444
|
+
registerLabel,
|
|
1445
|
+
unregisterLabel,
|
|
1446
|
+
disabled,
|
|
1447
|
+
name,
|
|
1448
|
+
invalid
|
|
1449
|
+
]
|
|
1450
|
+
);
|
|
1451
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: ctx, children });
|
|
1452
|
+
}
|
|
1453
|
+
var SelectTrigger = forwardRef(
|
|
1454
|
+
function SelectTrigger2({ size, state, className, onClick, children, ...rest }, forwardedRef) {
|
|
1455
|
+
const ctx = useSelectContext();
|
|
1456
|
+
const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
|
|
1457
|
+
return /* @__PURE__ */ jsxs(
|
|
1458
|
+
"button",
|
|
1459
|
+
{
|
|
1460
|
+
ref: composeRefs(forwardedRef, ctx.triggerRef),
|
|
1461
|
+
type: "button",
|
|
1462
|
+
"aria-haspopup": "listbox",
|
|
1463
|
+
"aria-expanded": ctx.open,
|
|
1464
|
+
"data-state": ctx.open ? "open" : "closed",
|
|
1465
|
+
disabled: ctx.disabled,
|
|
1466
|
+
onClick: (e) => {
|
|
1467
|
+
onClick?.(e);
|
|
1468
|
+
if (e.defaultPrevented) return;
|
|
1469
|
+
ctx.setOpen(!ctx.open);
|
|
1470
|
+
},
|
|
1471
|
+
className: cn(selectTriggerVariants({ size, state: triggerState }), className),
|
|
1472
|
+
...rest,
|
|
1473
|
+
children: [
|
|
1474
|
+
children ?? /* @__PURE__ */ jsx(SelectValue, {}),
|
|
1475
|
+
/* @__PURE__ */ jsx(
|
|
1476
|
+
ChevronDown,
|
|
1477
|
+
{
|
|
1478
|
+
className: cn(
|
|
1479
|
+
"h-4 w-4 text-muted-foreground transition-transform",
|
|
1480
|
+
ctx.open && "rotate-180"
|
|
1481
|
+
)
|
|
1482
|
+
}
|
|
1483
|
+
)
|
|
1484
|
+
]
|
|
1485
|
+
}
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
);
|
|
1489
|
+
function SelectValue({ placeholder, children }) {
|
|
1490
|
+
const ctx = useSelectContext();
|
|
1491
|
+
if (children) return /* @__PURE__ */ jsx("span", { className: "truncate", children });
|
|
1492
|
+
const label = ctx.value ? ctx.labels[ctx.value] ?? ctx.value : null;
|
|
1493
|
+
return /* @__PURE__ */ jsx("span", { className: cn("truncate", !label && "text-subtle-foreground"), children: label ?? placeholder });
|
|
1494
|
+
}
|
|
1495
|
+
function SelectContent({
|
|
1496
|
+
className,
|
|
1497
|
+
placement = "bottom",
|
|
1498
|
+
offset = 6,
|
|
1499
|
+
children
|
|
1500
|
+
}) {
|
|
1501
|
+
const ctx = useSelectContext();
|
|
1502
|
+
if (!ctx.open) return null;
|
|
1503
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [
|
|
1504
|
+
/* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
|
|
1505
|
+
DismissableLayer,
|
|
1506
|
+
{
|
|
1507
|
+
onEscape: () => ctx.setOpen(false),
|
|
1508
|
+
onOutsidePointerDown: (e) => {
|
|
1509
|
+
if (ctx.triggerRef.current?.contains(e.target)) return;
|
|
1510
|
+
ctx.setOpen(false);
|
|
1511
|
+
},
|
|
1512
|
+
children: /* @__PURE__ */ jsx(
|
|
1513
|
+
Listbox,
|
|
1514
|
+
{
|
|
1515
|
+
value: ctx.value,
|
|
1516
|
+
onValueChange: (v) => ctx.onSelect(v),
|
|
1517
|
+
className: cn("min-w-[var(--radix-anchor-width)]", className),
|
|
1518
|
+
style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
|
|
1519
|
+
children
|
|
1520
|
+
}
|
|
1521
|
+
)
|
|
1522
|
+
}
|
|
1523
|
+
) }) }),
|
|
1524
|
+
ctx.name && /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: ctx.value })
|
|
1525
|
+
] });
|
|
1526
|
+
}
|
|
1527
|
+
var SelectItem = forwardRef(function SelectItem2(props, ref) {
|
|
1528
|
+
const ctx = useSelectContext();
|
|
1529
|
+
useEffect(() => {
|
|
1530
|
+
ctx.registerLabel(props.value, props.children);
|
|
1531
|
+
return () => ctx.unregisterLabel(props.value);
|
|
1532
|
+
}, [ctx, props.value, props.children]);
|
|
1533
|
+
return /* @__PURE__ */ jsx(ListboxItem, { ref, ...props });
|
|
1534
|
+
});
|
|
1535
|
+
Select.Trigger = SelectTrigger;
|
|
1536
|
+
Select.Value = SelectValue;
|
|
1537
|
+
Select.Content = SelectContent;
|
|
1538
|
+
Select.Item = SelectItem;
|
|
1539
|
+
Select.Group = ListboxGroup;
|
|
1540
|
+
Select.Separator = ListboxSeparator;
|
|
1541
|
+
Select.Empty = ListboxEmpty;
|
|
1542
|
+
var MultiSelectContext = createContext(null);
|
|
1543
|
+
function useMultiSelectContext() {
|
|
1544
|
+
const ctx = useContext(MultiSelectContext);
|
|
1545
|
+
if (!ctx) throw new Error("MultiSelect.* must be used inside <MultiSelect>");
|
|
1546
|
+
return ctx;
|
|
1547
|
+
}
|
|
1548
|
+
function MultiSelect({
|
|
1549
|
+
value,
|
|
1550
|
+
defaultValue,
|
|
1551
|
+
onValueChange,
|
|
1552
|
+
disabled = false,
|
|
1553
|
+
name,
|
|
1554
|
+
invalid,
|
|
1555
|
+
defaultOpen = false,
|
|
1556
|
+
open: openProp,
|
|
1557
|
+
onOpenChange,
|
|
1558
|
+
children
|
|
1559
|
+
}) {
|
|
1560
|
+
const [openState, setOpenState] = useControlled({
|
|
1561
|
+
controlled: openProp,
|
|
1562
|
+
default: defaultOpen,
|
|
1563
|
+
onChange: onOpenChange
|
|
1564
|
+
});
|
|
1565
|
+
const [valuesState, setValuesState] = useControlled({
|
|
1566
|
+
controlled: value,
|
|
1567
|
+
default: defaultValue ?? [],
|
|
1568
|
+
onChange: onValueChange
|
|
1569
|
+
});
|
|
1570
|
+
const triggerRef = useRef(null);
|
|
1571
|
+
const [labels, setLabels] = useState({});
|
|
1572
|
+
const registerLabel = useCallback((v, label) => {
|
|
1573
|
+
setLabels((prev) => prev[v] === label ? prev : { ...prev, [v]: label });
|
|
1574
|
+
}, []);
|
|
1575
|
+
const unregisterLabel = useCallback((v) => {
|
|
1576
|
+
setLabels((prev) => {
|
|
1577
|
+
if (!(v in prev)) return prev;
|
|
1578
|
+
const next = { ...prev };
|
|
1579
|
+
delete next[v];
|
|
1580
|
+
return next;
|
|
1581
|
+
});
|
|
1582
|
+
}, []);
|
|
1583
|
+
const ctx = useMemo(
|
|
1584
|
+
() => ({
|
|
1585
|
+
open: openState,
|
|
1586
|
+
setOpen: setOpenState,
|
|
1587
|
+
values: valuesState,
|
|
1588
|
+
setValues: setValuesState,
|
|
1589
|
+
triggerRef,
|
|
1590
|
+
labels,
|
|
1591
|
+
registerLabel,
|
|
1592
|
+
unregisterLabel,
|
|
1593
|
+
disabled,
|
|
1594
|
+
name,
|
|
1595
|
+
invalid
|
|
1596
|
+
}),
|
|
1597
|
+
[
|
|
1598
|
+
openState,
|
|
1599
|
+
setOpenState,
|
|
1600
|
+
valuesState,
|
|
1601
|
+
setValuesState,
|
|
1602
|
+
labels,
|
|
1603
|
+
registerLabel,
|
|
1604
|
+
unregisterLabel,
|
|
1605
|
+
disabled,
|
|
1606
|
+
name,
|
|
1607
|
+
invalid
|
|
1608
|
+
]
|
|
1609
|
+
);
|
|
1610
|
+
return /* @__PURE__ */ jsx(MultiSelectContext.Provider, { value: ctx, children });
|
|
1611
|
+
}
|
|
1612
|
+
var MultiSelectTrigger = forwardRef(
|
|
1613
|
+
function MultiSelectTrigger2({ size, state, className, onClick, onKeyDown, children, ...rest }, forwardedRef) {
|
|
1614
|
+
const ctx = useMultiSelectContext();
|
|
1615
|
+
const triggerState = state ?? (ctx.invalid ? "invalid" : "default");
|
|
1616
|
+
return /* @__PURE__ */ jsxs(
|
|
1617
|
+
"button",
|
|
1618
|
+
{
|
|
1619
|
+
ref: composeRefs(forwardedRef, ctx.triggerRef),
|
|
1620
|
+
type: "button",
|
|
1621
|
+
"aria-haspopup": "listbox",
|
|
1622
|
+
"aria-expanded": ctx.open,
|
|
1623
|
+
"data-state": ctx.open ? "open" : "closed",
|
|
1624
|
+
disabled: ctx.disabled,
|
|
1625
|
+
onClick: (e) => {
|
|
1626
|
+
onClick?.(e);
|
|
1627
|
+
if (e.defaultPrevented) return;
|
|
1628
|
+
ctx.setOpen(!ctx.open);
|
|
1629
|
+
},
|
|
1630
|
+
onKeyDown: (e) => {
|
|
1631
|
+
onKeyDown?.(e);
|
|
1632
|
+
if (e.defaultPrevented) return;
|
|
1633
|
+
if (e.key === "Backspace" && ctx.values.length > 0) {
|
|
1634
|
+
ctx.setValues(ctx.values.slice(0, -1));
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
className: cn(
|
|
1638
|
+
selectTriggerVariants({ size, state: triggerState }),
|
|
1639
|
+
"h-auto min-h-10 flex-wrap py-1.5",
|
|
1640
|
+
className
|
|
1641
|
+
),
|
|
1642
|
+
...rest,
|
|
1643
|
+
children: [
|
|
1644
|
+
children ?? /* @__PURE__ */ jsx(MultiSelectTags, {}),
|
|
1645
|
+
/* @__PURE__ */ jsx(
|
|
1646
|
+
ChevronDown,
|
|
1647
|
+
{
|
|
1648
|
+
className: cn(
|
|
1649
|
+
"h-4 w-4 shrink-0 self-center text-muted-foreground transition-transform",
|
|
1650
|
+
ctx.open && "rotate-180"
|
|
1651
|
+
)
|
|
1652
|
+
}
|
|
1653
|
+
)
|
|
1654
|
+
]
|
|
1655
|
+
}
|
|
1656
|
+
);
|
|
1657
|
+
}
|
|
1658
|
+
);
|
|
1659
|
+
function MultiSelectTags({ placeholder }) {
|
|
1660
|
+
const ctx = useMultiSelectContext();
|
|
1661
|
+
if (ctx.values.length === 0) {
|
|
1662
|
+
return /* @__PURE__ */ jsx("span", { className: "text-subtle-foreground", children: placeholder });
|
|
1663
|
+
}
|
|
1664
|
+
return /* @__PURE__ */ jsx("span", { className: "flex flex-1 flex-wrap items-center gap-1", children: ctx.values.map((v) => /* @__PURE__ */ jsxs(
|
|
1665
|
+
"span",
|
|
1666
|
+
{
|
|
1667
|
+
className: "inline-flex items-center gap-1 rounded-sm bg-muted px-1.5 py-0.5 text-xs",
|
|
1668
|
+
children: [
|
|
1669
|
+
ctx.labels[v] ?? v,
|
|
1670
|
+
!ctx.disabled && /* @__PURE__ */ jsx(
|
|
1671
|
+
"span",
|
|
1672
|
+
{
|
|
1673
|
+
role: "button",
|
|
1674
|
+
tabIndex: -1,
|
|
1675
|
+
"aria-label": `Remove ${typeof ctx.labels[v] === "string" ? ctx.labels[v] : v}`,
|
|
1676
|
+
onClick: (e) => {
|
|
1677
|
+
e.stopPropagation();
|
|
1678
|
+
ctx.setValues(ctx.values.filter((x) => x !== v));
|
|
1679
|
+
},
|
|
1680
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
1681
|
+
className: "cursor-pointer rounded-sm p-0.5 hover:bg-border",
|
|
1682
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
1683
|
+
}
|
|
1684
|
+
)
|
|
1685
|
+
]
|
|
1686
|
+
},
|
|
1687
|
+
v
|
|
1688
|
+
)) });
|
|
1689
|
+
}
|
|
1690
|
+
function MultiSelectContent({
|
|
1691
|
+
className,
|
|
1692
|
+
placement = "bottom",
|
|
1693
|
+
offset = 6,
|
|
1694
|
+
children
|
|
1695
|
+
}) {
|
|
1696
|
+
const ctx = useMultiSelectContext();
|
|
1697
|
+
if (!ctx.open) return null;
|
|
1698
|
+
return /* @__PURE__ */ jsxs(Portal, { children: [
|
|
1699
|
+
/* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.triggerRef.current, placement, offset, children: /* @__PURE__ */ jsx(FocusScope, { asChild: true, trapped: true, loop: true, children: /* @__PURE__ */ jsx(
|
|
1700
|
+
DismissableLayer,
|
|
1701
|
+
{
|
|
1702
|
+
onEscape: () => {
|
|
1703
|
+
ctx.setOpen(false);
|
|
1704
|
+
requestAnimationFrame(() => ctx.triggerRef.current?.focus());
|
|
1705
|
+
},
|
|
1706
|
+
onOutsidePointerDown: (e) => {
|
|
1707
|
+
if (ctx.triggerRef.current?.contains(e.target)) return;
|
|
1708
|
+
ctx.setOpen(false);
|
|
1709
|
+
},
|
|
1710
|
+
children: /* @__PURE__ */ jsx(
|
|
1711
|
+
Listbox,
|
|
1712
|
+
{
|
|
1713
|
+
multiple: true,
|
|
1714
|
+
value: ctx.values,
|
|
1715
|
+
onValueChange: (v) => ctx.setValues(v),
|
|
1716
|
+
className: cn(className),
|
|
1717
|
+
style: ctx.triggerRef.current ? { minWidth: ctx.triggerRef.current.offsetWidth } : void 0,
|
|
1718
|
+
children
|
|
1719
|
+
}
|
|
1720
|
+
)
|
|
1721
|
+
}
|
|
1722
|
+
) }) }),
|
|
1723
|
+
ctx.name && ctx.values.map((v) => /* @__PURE__ */ jsx("input", { type: "hidden", name: ctx.name, value: v }, v))
|
|
1724
|
+
] });
|
|
1725
|
+
}
|
|
1726
|
+
var MultiSelectItem = forwardRef(
|
|
1727
|
+
function MultiSelectItem2(props, ref) {
|
|
1728
|
+
const ctx = useMultiSelectContext();
|
|
1729
|
+
useEffect(() => {
|
|
1730
|
+
ctx.registerLabel(props.value, props.children);
|
|
1731
|
+
return () => ctx.unregisterLabel(props.value);
|
|
1732
|
+
}, [ctx, props.value, props.children]);
|
|
1733
|
+
return /* @__PURE__ */ jsx(ListboxItem, { ref, ...props });
|
|
1734
|
+
}
|
|
1735
|
+
);
|
|
1736
|
+
MultiSelect.Trigger = MultiSelectTrigger;
|
|
1737
|
+
MultiSelect.Tags = MultiSelectTags;
|
|
1738
|
+
MultiSelect.Content = MultiSelectContent;
|
|
1739
|
+
MultiSelect.Item = MultiSelectItem;
|
|
1740
|
+
MultiSelect.Group = ListboxGroup;
|
|
1741
|
+
MultiSelect.Separator = ListboxSeparator;
|
|
1742
|
+
MultiSelect.Empty = ListboxEmpty;
|
|
1743
|
+
var ComboboxContext = createContext(null);
|
|
1744
|
+
function useComboboxContext() {
|
|
1745
|
+
const ctx = useContext(ComboboxContext);
|
|
1746
|
+
if (!ctx) throw new Error("Combobox.* must be used inside <Combobox>");
|
|
1747
|
+
return ctx;
|
|
1748
|
+
}
|
|
1749
|
+
function Combobox({
|
|
1750
|
+
value,
|
|
1751
|
+
defaultValue,
|
|
1752
|
+
onValueChange,
|
|
1753
|
+
inputValue,
|
|
1754
|
+
defaultInputValue,
|
|
1755
|
+
onInputChange,
|
|
1756
|
+
disabled = false,
|
|
1757
|
+
invalid,
|
|
1758
|
+
name,
|
|
1759
|
+
defaultOpen = false,
|
|
1760
|
+
open: openProp,
|
|
1761
|
+
onOpenChange,
|
|
1762
|
+
fillInputOnSelect = true,
|
|
1763
|
+
children
|
|
1764
|
+
}) {
|
|
1765
|
+
const [openState, setOpenState] = useControlled({
|
|
1766
|
+
controlled: openProp,
|
|
1767
|
+
default: defaultOpen,
|
|
1768
|
+
onChange: onOpenChange
|
|
1769
|
+
});
|
|
1770
|
+
const [valueState, setValueState] = useControlled({
|
|
1771
|
+
controlled: value,
|
|
1772
|
+
default: defaultValue ?? "",
|
|
1773
|
+
onChange: onValueChange
|
|
1774
|
+
});
|
|
1775
|
+
const [inputState, setInputState] = useControlled({
|
|
1776
|
+
controlled: inputValue,
|
|
1777
|
+
default: defaultInputValue ?? "",
|
|
1778
|
+
onChange: onInputChange
|
|
1779
|
+
});
|
|
1780
|
+
const itemsRef = useRef([]);
|
|
1781
|
+
const inputRef = useRef(null);
|
|
1782
|
+
const [activeId, setActiveId] = useState(null);
|
|
1783
|
+
const listboxId = useId$1();
|
|
1784
|
+
const registerItem = useCallback((entry) => {
|
|
1785
|
+
const idx = itemsRef.current.findIndex((i) => i.id === entry.id);
|
|
1786
|
+
if (idx >= 0) itemsRef.current[idx] = entry;
|
|
1787
|
+
else itemsRef.current.push(entry);
|
|
1788
|
+
}, []);
|
|
1789
|
+
const unregisterItem = useCallback((id) => {
|
|
1790
|
+
itemsRef.current = itemsRef.current.filter((i) => i.id !== id);
|
|
1791
|
+
}, []);
|
|
1792
|
+
const selectItem = useCallback(
|
|
1793
|
+
(entry, opts) => {
|
|
1794
|
+
setValueState(entry.value);
|
|
1795
|
+
if (fillInputOnSelect) {
|
|
1796
|
+
const text = typeof entry.label === "string" ? entry.label : entry.value;
|
|
1797
|
+
setInputState(text);
|
|
1798
|
+
}
|
|
1799
|
+
if (opts?.close ?? true) setOpenState(false);
|
|
1800
|
+
},
|
|
1801
|
+
[setValueState, setInputState, setOpenState, fillInputOnSelect]
|
|
1802
|
+
);
|
|
1803
|
+
const ctx = useMemo(
|
|
1804
|
+
() => ({
|
|
1805
|
+
open: openState,
|
|
1806
|
+
setOpen: setOpenState,
|
|
1807
|
+
value: valueState,
|
|
1808
|
+
setValue: setValueState,
|
|
1809
|
+
inputValue: inputState,
|
|
1810
|
+
setInputValue: setInputState,
|
|
1811
|
+
activeId,
|
|
1812
|
+
setActiveId,
|
|
1813
|
+
registerItem,
|
|
1814
|
+
unregisterItem,
|
|
1815
|
+
itemsRef,
|
|
1816
|
+
inputRef,
|
|
1817
|
+
listboxId,
|
|
1818
|
+
disabled,
|
|
1819
|
+
invalid,
|
|
1820
|
+
selectItem
|
|
1821
|
+
}),
|
|
1822
|
+
[
|
|
1823
|
+
openState,
|
|
1824
|
+
setOpenState,
|
|
1825
|
+
valueState,
|
|
1826
|
+
setValueState,
|
|
1827
|
+
inputState,
|
|
1828
|
+
setInputState,
|
|
1829
|
+
activeId,
|
|
1830
|
+
registerItem,
|
|
1831
|
+
unregisterItem,
|
|
1832
|
+
listboxId,
|
|
1833
|
+
disabled,
|
|
1834
|
+
invalid,
|
|
1835
|
+
selectItem
|
|
1836
|
+
]
|
|
1837
|
+
);
|
|
1838
|
+
return /* @__PURE__ */ jsxs(ComboboxContext.Provider, { value: ctx, children: [
|
|
1839
|
+
children,
|
|
1840
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: valueState })
|
|
1841
|
+
] });
|
|
1842
|
+
}
|
|
1843
|
+
var ComboboxInput = forwardRef(
|
|
1844
|
+
function ComboboxInput2({ className, size, state, onKeyDown, onFocus, ...rest }, forwardedRef) {
|
|
1845
|
+
const ctx = useComboboxContext();
|
|
1846
|
+
const inputState = state ?? (ctx.invalid ? "invalid" : "default");
|
|
1847
|
+
const moveActive = useCallback(
|
|
1848
|
+
(direction) => {
|
|
1849
|
+
const list = ctx.itemsRef.current.filter((i) => !i.disabled);
|
|
1850
|
+
if (list.length === 0) return;
|
|
1851
|
+
const idx = list.findIndex((i) => i.id === ctx.activeId);
|
|
1852
|
+
let nextIdx = idx + direction;
|
|
1853
|
+
if (idx === -1) nextIdx = direction === 1 ? 0 : list.length - 1;
|
|
1854
|
+
if (nextIdx < 0) nextIdx = list.length - 1;
|
|
1855
|
+
if (nextIdx >= list.length) nextIdx = 0;
|
|
1856
|
+
const next = list[nextIdx];
|
|
1857
|
+
if (next) ctx.setActiveId(next.id);
|
|
1858
|
+
},
|
|
1859
|
+
[ctx]
|
|
1860
|
+
);
|
|
1861
|
+
const handleKeyDown = (e) => {
|
|
1862
|
+
onKeyDown?.(e);
|
|
1863
|
+
if (e.defaultPrevented || ctx.disabled) return;
|
|
1864
|
+
switch (e.key) {
|
|
1865
|
+
case "ArrowDown":
|
|
1866
|
+
e.preventDefault();
|
|
1867
|
+
if (!ctx.open) ctx.setOpen(true);
|
|
1868
|
+
else moveActive(1);
|
|
1869
|
+
break;
|
|
1870
|
+
case "ArrowUp":
|
|
1871
|
+
e.preventDefault();
|
|
1872
|
+
if (!ctx.open) ctx.setOpen(true);
|
|
1873
|
+
else moveActive(-1);
|
|
1874
|
+
break;
|
|
1875
|
+
case "Home":
|
|
1876
|
+
if (ctx.open) {
|
|
1877
|
+
e.preventDefault();
|
|
1878
|
+
const first = ctx.itemsRef.current.find((i) => !i.disabled);
|
|
1879
|
+
if (first) ctx.setActiveId(first.id);
|
|
1880
|
+
}
|
|
1881
|
+
break;
|
|
1882
|
+
case "End":
|
|
1883
|
+
if (ctx.open) {
|
|
1884
|
+
e.preventDefault();
|
|
1885
|
+
const list = ctx.itemsRef.current.filter((i) => !i.disabled);
|
|
1886
|
+
const last = list[list.length - 1];
|
|
1887
|
+
if (last) ctx.setActiveId(last.id);
|
|
1888
|
+
}
|
|
1889
|
+
break;
|
|
1890
|
+
case "Enter": {
|
|
1891
|
+
if (!ctx.open || !ctx.activeId) return;
|
|
1892
|
+
const entry = ctx.itemsRef.current.find((i) => i.id === ctx.activeId);
|
|
1893
|
+
if (!entry || entry.disabled) return;
|
|
1894
|
+
e.preventDefault();
|
|
1895
|
+
ctx.selectItem(entry);
|
|
1896
|
+
break;
|
|
1897
|
+
}
|
|
1898
|
+
case "Escape":
|
|
1899
|
+
if (ctx.open) {
|
|
1900
|
+
e.preventDefault();
|
|
1901
|
+
ctx.setOpen(false);
|
|
1902
|
+
} else if (ctx.inputValue) {
|
|
1903
|
+
e.preventDefault();
|
|
1904
|
+
ctx.setInputValue("");
|
|
1905
|
+
ctx.setValue("");
|
|
1906
|
+
}
|
|
1907
|
+
break;
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
return /* @__PURE__ */ jsx(
|
|
1911
|
+
"input",
|
|
1912
|
+
{
|
|
1913
|
+
ref: composeRefs(forwardedRef, ctx.inputRef),
|
|
1914
|
+
type: "text",
|
|
1915
|
+
role: "combobox",
|
|
1916
|
+
"aria-expanded": ctx.open,
|
|
1917
|
+
"aria-controls": ctx.listboxId,
|
|
1918
|
+
"aria-activedescendant": ctx.activeId ?? void 0,
|
|
1919
|
+
"aria-autocomplete": "list",
|
|
1920
|
+
"aria-disabled": ctx.disabled || void 0,
|
|
1921
|
+
disabled: ctx.disabled,
|
|
1922
|
+
value: ctx.inputValue,
|
|
1923
|
+
onChange: (e) => {
|
|
1924
|
+
ctx.setInputValue(e.target.value);
|
|
1925
|
+
if (!ctx.open) ctx.setOpen(true);
|
|
1926
|
+
ctx.setActiveId(null);
|
|
1927
|
+
},
|
|
1928
|
+
onFocus: (e) => {
|
|
1929
|
+
onFocus?.(e);
|
|
1930
|
+
if (!ctx.open) ctx.setOpen(true);
|
|
1931
|
+
},
|
|
1932
|
+
onKeyDown: handleKeyDown,
|
|
1933
|
+
className: cn(inputBaseVariants({ size, state: inputState }), className),
|
|
1934
|
+
...rest
|
|
1935
|
+
}
|
|
1936
|
+
);
|
|
1937
|
+
}
|
|
1938
|
+
);
|
|
1939
|
+
function ComboboxContent({
|
|
1940
|
+
className,
|
|
1941
|
+
placement = "bottom",
|
|
1942
|
+
offset = 6,
|
|
1943
|
+
children
|
|
1944
|
+
}) {
|
|
1945
|
+
const ctx = useComboboxContext();
|
|
1946
|
+
if (!ctx.open) return null;
|
|
1947
|
+
return /* @__PURE__ */ jsx(Portal, { children: /* @__PURE__ */ jsx(AnchoredPositioner, { anchor: ctx.inputRef.current, placement, offset, children: /* @__PURE__ */ jsx(
|
|
1948
|
+
DismissableLayer,
|
|
1949
|
+
{
|
|
1950
|
+
onEscape: () => ctx.setOpen(false),
|
|
1951
|
+
onOutsidePointerDown: (e) => {
|
|
1952
|
+
if (ctx.inputRef.current?.contains(e.target)) return;
|
|
1953
|
+
ctx.setOpen(false);
|
|
1954
|
+
},
|
|
1955
|
+
children: /* @__PURE__ */ jsx(
|
|
1956
|
+
"div",
|
|
1957
|
+
{
|
|
1958
|
+
id: ctx.listboxId,
|
|
1959
|
+
role: "listbox",
|
|
1960
|
+
className: cn(listboxVariants(), className),
|
|
1961
|
+
style: ctx.inputRef.current ? { minWidth: ctx.inputRef.current.offsetWidth } : void 0,
|
|
1962
|
+
children
|
|
1963
|
+
}
|
|
1964
|
+
)
|
|
1965
|
+
}
|
|
1966
|
+
) }) });
|
|
1967
|
+
}
|
|
1968
|
+
var ComboboxItem = forwardRef(function ComboboxItem2({ value, disabled = false, className, children, onClick, onPointerEnter, ...rest }, forwardedRef) {
|
|
1969
|
+
const ctx = useComboboxContext();
|
|
1970
|
+
const id = useId$1();
|
|
1971
|
+
useEffect(() => {
|
|
1972
|
+
ctx.registerItem({ id, value, disabled, label: children });
|
|
1973
|
+
return () => ctx.unregisterItem(id);
|
|
1974
|
+
}, [ctx, id, value, disabled, children]);
|
|
1975
|
+
useEffect(() => {
|
|
1976
|
+
if (!ctx.activeId) {
|
|
1977
|
+
const list = ctx.itemsRef.current.filter((i) => !i.disabled);
|
|
1978
|
+
if (list[0]) ctx.setActiveId(list[0].id);
|
|
1979
|
+
}
|
|
1980
|
+
}, [ctx]);
|
|
1981
|
+
const isSelected = ctx.value === value;
|
|
1982
|
+
const isActive = ctx.activeId === id;
|
|
1983
|
+
const state = disabled ? "disabled" : isSelected ? "selected" : isActive ? "active" : "default";
|
|
1984
|
+
return /* @__PURE__ */ jsxs(
|
|
1985
|
+
"div",
|
|
1986
|
+
{
|
|
1987
|
+
ref: forwardedRef,
|
|
1988
|
+
id,
|
|
1989
|
+
role: "option",
|
|
1990
|
+
"aria-selected": isSelected,
|
|
1991
|
+
"aria-disabled": disabled || void 0,
|
|
1992
|
+
"data-active": isActive ? "" : void 0,
|
|
1993
|
+
"data-selected": isSelected ? "" : void 0,
|
|
1994
|
+
onClick: (e) => {
|
|
1995
|
+
onClick?.(e);
|
|
1996
|
+
if (e.defaultPrevented || disabled) return;
|
|
1997
|
+
ctx.selectItem({ id, value, disabled, label: children });
|
|
1998
|
+
},
|
|
1999
|
+
onPointerEnter: (e) => {
|
|
2000
|
+
onPointerEnter?.(e);
|
|
2001
|
+
if (!disabled) ctx.setActiveId(id);
|
|
2002
|
+
},
|
|
2003
|
+
className: cn(listboxItemVariants({ state }), className),
|
|
2004
|
+
...rest,
|
|
2005
|
+
children: [
|
|
2006
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children }),
|
|
2007
|
+
isSelected && /* @__PURE__ */ jsx(Check, { className: "h-4 w-4 opacity-80" })
|
|
2008
|
+
]
|
|
2009
|
+
}
|
|
2010
|
+
);
|
|
2011
|
+
});
|
|
2012
|
+
function ComboboxGroup({ label, children, className, ...rest }) {
|
|
2013
|
+
const labelId = useId$1();
|
|
2014
|
+
return /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": label ? labelId : void 0, className, ...rest, children: [
|
|
2015
|
+
label && /* @__PURE__ */ jsx("div", { id: labelId, className: listboxGroupLabelVariants(), children: label }),
|
|
2016
|
+
children
|
|
2017
|
+
] });
|
|
2018
|
+
}
|
|
2019
|
+
function ComboboxSeparator(props) {
|
|
2020
|
+
return /* @__PURE__ */ jsx("div", { role: "separator", className: listboxSeparatorVariants(), ...props });
|
|
2021
|
+
}
|
|
2022
|
+
function ComboboxEmpty({ children, className, ...rest }) {
|
|
2023
|
+
return /* @__PURE__ */ jsx("div", { role: "presentation", className: cn(listboxEmptyVariants(), className), ...rest, children });
|
|
2024
|
+
}
|
|
2025
|
+
Combobox.Input = ComboboxInput;
|
|
2026
|
+
Combobox.Content = ComboboxContent;
|
|
2027
|
+
Combobox.Item = ComboboxItem;
|
|
2028
|
+
Combobox.Group = ComboboxGroup;
|
|
2029
|
+
Combobox.Separator = ComboboxSeparator;
|
|
2030
|
+
Combobox.Empty = ComboboxEmpty;
|
|
2031
|
+
|
|
2032
|
+
export { CharacterCount, Checkbox, CheckboxField, CheckboxGroup, ChoiceCard, Combobox, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxSeparator, CurrencyInput, EmailInput, Fieldset, FilePicker, FormErrorMessage, FormField, FormHelperText, InputAddon, InputGroup, Label, LabeledInput, Legend, Listbox, ListboxEmpty, ListboxGroup, ListboxItem, ListboxSeparator, MaskedInput, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTags, MultiSelectTrigger, NumberInput, PasswordInput, PasswordStrength, PercentInput, PinInput, Radio, RadioField, RadioGroup, SearchInput, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Slider, Switch, SwitchField, TelInput, TextInput, Textarea, UrlInput };
|
|
2033
|
+
//# sourceMappingURL=chunk-SBVWECJP.js.map
|
|
2034
|
+
//# sourceMappingURL=chunk-SBVWECJP.js.map
|