@human-kit/ui 1.0.0-beta.0 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -16
- package/dist/FOCUS_STATE_CONTRACT.md +18 -4
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
- package/dist/accordion/README.md +3 -3
- package/dist/accordion/root/accordion-root.svelte +15 -3
- package/dist/accordion/root/context.svelte.js +4 -4
- package/dist/accordion/types.d.ts +40 -19
- package/dist/autocomplete/README.md +6 -7
- package/dist/autocomplete/empty/autocomplete-empty.svelte +1 -1
- package/dist/autocomplete/empty/autocomplete-empty.svelte.d.ts +1 -1
- package/dist/autocomplete/input/autocomplete-input.svelte +3 -3
- package/dist/autocomplete/input/autocomplete-input.svelte.d.ts +3 -3
- package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte +2 -2
- package/dist/autocomplete/item-indicator/autocomplete-item-indicator.svelte.d.ts +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte +2 -2
- package/dist/autocomplete/list/autocomplete-list.svelte.d.ts +11 -3
- package/dist/autocomplete/root/autocomplete.svelte +7 -7
- package/dist/autocomplete/root/autocomplete.svelte.d.ts +7 -7
- package/dist/autocomplete/status/autocomplete-status.svelte +1 -1
- package/dist/autocomplete/status/autocomplete-status.svelte.d.ts +1 -1
- package/dist/avatar/README.md +52 -0
- package/dist/avatar/count/avatar-count.svelte +56 -0
- package/dist/avatar/count/avatar-count.svelte.d.ts +4 -0
- package/dist/avatar/fallback/avatar-fallback.svelte +67 -0
- package/dist/avatar/fallback/avatar-fallback.svelte.d.ts +4 -0
- package/dist/avatar/group/avatar-group.svelte +65 -0
- package/dist/avatar/group/avatar-group.svelte.d.ts +4 -0
- package/dist/avatar/group/context.d.ts +15 -0
- package/dist/avatar/group/context.js +15 -0
- package/dist/avatar/image/avatar-image.svelte +104 -0
- package/dist/avatar/image/avatar-image.svelte.d.ts +4 -0
- package/dist/avatar/index.d.ts +22 -0
- package/dist/avatar/index.js +10 -0
- package/dist/avatar/index.parts.d.ts +5 -0
- package/dist/avatar/index.parts.js +5 -0
- package/dist/avatar/root/avatar-root.svelte +79 -0
- package/dist/avatar/root/avatar-root.svelte.d.ts +4 -0
- package/dist/avatar/root/context.d.ts +14 -0
- package/dist/avatar/root/context.js +15 -0
- package/dist/avatar/types.d.ts +84 -0
- package/dist/avatar/types.js +1 -0
- package/dist/breadcrumbs/README.md +65 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +62 -0
- package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte.d.ts +4 -0
- package/dist/breadcrumbs/index.d.ts +23 -0
- package/dist/breadcrumbs/index.js +10 -0
- package/dist/breadcrumbs/index.parts.d.ts +6 -0
- package/dist/breadcrumbs/index.parts.js +6 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte +42 -0
- package/dist/breadcrumbs/item/breadcrumbs-item.svelte.d.ts +4 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte +47 -0
- package/dist/breadcrumbs/link/breadcrumbs-link.svelte.d.ts +4 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte +31 -0
- package/dist/breadcrumbs/list/breadcrumbs-list.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte +112 -0
- package/dist/breadcrumbs/root/breadcrumbs-root.svelte.d.ts +4 -0
- package/dist/breadcrumbs/root/context.d.ts +19 -0
- package/dist/breadcrumbs/root/context.js +15 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte +35 -0
- package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte.d.ts +4 -0
- package/dist/breadcrumbs/types.d.ts +80 -0
- package/dist/breadcrumbs/types.js +1 -0
- package/dist/button/README.md +1 -1
- package/dist/button/root/button-root.svelte +37 -7
- package/dist/button/root/button-root.svelte.d.ts +19 -4
- package/dist/calendar/README.md +3 -3
- package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
- package/dist/calendar/grid-header/calendar-grid-header.svelte +3 -4
- package/dist/calendar/grid-header/calendar-grid-header.svelte.d.ts +3 -4
- package/dist/calendar/root/calendar-root.svelte +8 -2
- package/dist/calendar/root/calendar-root.svelte.d.ts +8 -2
- package/dist/calendar/root/context.svelte.js +8 -2
- package/dist/calendar/trigger-next/README.md +1 -1
- package/dist/calendar/trigger-previous/README.md +1 -1
- package/dist/checkbox/README.md +1 -1
- package/dist/checkbox/indicator/README.md +1 -1
- package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
- package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
- package/dist/checkbox/root/README.md +2 -2
- package/dist/checkbox/root/checkbox-root.svelte +133 -38
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +21 -1
- package/dist/checkbox-group/README.md +95 -0
- package/dist/checkbox-group/index.d.ts +15 -0
- package/dist/checkbox-group/index.js +6 -0
- package/dist/checkbox-group/index.parts.d.ts +4 -0
- package/dist/checkbox-group/index.parts.js +7 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
- package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
- package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
- package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
- package/dist/checkbox-group/root/context.svelte.js +251 -0
- package/dist/checkbox-group/types.d.ts +57 -0
- package/dist/checkbox-group/types.js +1 -0
- package/dist/clock/README.md +3 -3
- package/dist/clock/axis/README.md +1 -1
- package/dist/clock/root/README.md +1 -1
- package/dist/clock/root/create-time-selection-state.svelte.d.ts +5 -0
- package/dist/clock/root/create-time-selection-state.svelte.js +113 -10
- package/dist/clock/root/wheel-options.d.ts +7 -3
- package/dist/clock/root/wheel-options.js +7 -15
- package/dist/clock/wheel-column/clock-wheel-column.svelte +10 -2
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +2 -1
- package/dist/collapsible/README.md +3 -3
- package/dist/collapsible/root/collapsible-root.svelte +9 -4
- package/dist/collapsible/types.d.ts +13 -1
- package/dist/combobox/README.md +2 -2
- package/dist/combobox/button/README.md +6 -6
- package/dist/combobox/input/README.md +1 -1
- package/dist/combobox/input/combobox-input.svelte +15 -4
- package/dist/combobox/input/combobox-input.svelte.d.ts +3 -3
- package/dist/combobox/item/combobox-listboxitem.svelte +4 -2
- package/dist/combobox/item/combobox-listboxitem.svelte.d.ts +4 -2
- package/dist/combobox/item-indicator/README.md +1 -1
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte +2 -2
- package/dist/combobox/item-indicator/combobox-item-indicator.svelte.d.ts +2 -2
- package/dist/combobox/list/combobox-listbox.svelte +98 -3
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +28 -3
- package/dist/combobox/popover/README.md +1 -1
- package/dist/combobox/popover/combobox-popover.svelte +4 -56
- package/dist/combobox/root/README.md +24 -24
- package/dist/combobox/root/combobox.svelte +138 -56
- package/dist/combobox/root/combobox.svelte.d.ts +31 -11
- package/dist/combobox/root/context.d.ts +12 -0
- package/dist/combobox/status/README.md +3 -3
- package/dist/combobox/status/combobox-status.svelte +1 -1
- package/dist/combobox/status/combobox-status.svelte.d.ts +1 -1
- package/dist/combobox/tag/README.md +1 -1
- package/dist/combobox/tag/combobox-tag.svelte +1 -1
- package/dist/combobox/tag/combobox-tag.svelte.d.ts +1 -1
- package/dist/combobox/tag-remove/README.md +1 -1
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte +14 -3
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +7 -1
- package/dist/combobox/tags/README.md +1 -1
- package/dist/combobox/tags/combobox-tags.svelte +15 -12
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +12 -10
- package/dist/combobox/trigger/README.md +7 -7
- package/dist/combobox/trigger/combobox-trigger.svelte +4 -1
- package/dist/datepicker/README.md +5 -4
- package/dist/datepicker/input/date-picker-input.svelte +3 -4
- package/dist/datepicker/input/date-picker-input.svelte.d.ts +3 -4
- package/dist/datepicker/root/date-picker-root.svelte +38 -2
- package/dist/datepicker/root/date-picker-root.svelte.d.ts +2 -0
- package/dist/datepicker/root/draft-evaluation.d.ts +7 -0
- package/dist/datepicker/root/draft-evaluation.js +2 -2
- package/dist/datepicker/trigger/README.md +1 -1
- package/dist/daterangepicker/README.md +3 -3
- package/dist/daterangepicker/input/date-range-picker-input.svelte +3 -4
- package/dist/daterangepicker/input/date-range-picker-input.svelte.d.ts +3 -4
- package/dist/daterangepicker/root/date-range-picker-root.svelte +19 -1
- package/dist/daterangepicker/root/date-range-picker-root.svelte.d.ts +2 -0
- package/dist/dialog/README.md +10 -2
- package/dist/dialog/close/dialog-close.svelte +57 -0
- package/dist/dialog/close/dialog-close.svelte.d.ts +19 -0
- package/dist/dialog/content/dialog-content.svelte +6 -4
- package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
- package/dist/dialog/description/dialog-description.svelte +46 -0
- package/dist/dialog/description/dialog-description.svelte.d.ts +20 -0
- package/dist/dialog/index.d.ts +9 -0
- package/dist/dialog/index.js +3 -0
- package/dist/dialog/index.parts.d.ts +3 -0
- package/dist/dialog/index.parts.js +3 -0
- package/dist/dialog/overlay/dialog-overlay.svelte +1 -1
- package/dist/dialog/overlay/dialog-overlay.svelte.d.ts +1 -1
- package/dist/dialog/portal/dialog-portal.svelte +1 -1
- package/dist/dialog/portal/dialog-portal.svelte.d.ts +1 -1
- package/dist/dialog/root/README.md +1 -1
- package/dist/dialog/root/context.d.ts +8 -0
- package/dist/dialog/root/dialog-root.svelte +100 -20
- package/dist/dialog/root/dialog-root.svelte.d.ts +15 -6
- package/dist/dialog/root/dialog-stack.d.ts +6 -22
- package/dist/dialog/root/dialog-stack.js +4 -33
- package/dist/dialog/title/dialog-title.svelte +43 -0
- package/dist/dialog/title/dialog-title.svelte.d.ts +21 -0
- package/dist/dialog/trigger/README.md +1 -1
- package/dist/drawer/README.md +111 -0
- package/dist/drawer/body/drawer-body.svelte +47 -0
- package/dist/drawer/body/drawer-body.svelte.d.ts +32 -0
- package/dist/drawer/close/drawer-close.svelte +52 -0
- package/dist/drawer/close/drawer-close.svelte.d.ts +20 -0
- package/dist/drawer/content/drawer-content.svelte +600 -0
- package/dist/drawer/content/drawer-content.svelte.d.ts +31 -0
- package/dist/drawer/description/drawer-description.svelte +40 -0
- package/dist/drawer/description/drawer-description.svelte.d.ts +20 -0
- package/dist/drawer/indent/drawer-indent-background.svelte +36 -0
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +17 -0
- package/dist/drawer/indent/drawer-indent.svelte +59 -0
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +32 -0
- package/dist/drawer/index.d.ts +49 -0
- package/dist/drawer/index.js +25 -0
- package/dist/drawer/index.parts.d.ts +14 -0
- package/dist/drawer/index.parts.js +15 -0
- package/dist/drawer/overlay/drawer-overlay.svelte +67 -0
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +12 -0
- package/dist/drawer/portal/drawer-portal.svelte +57 -0
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +13 -0
- package/dist/drawer/root/context.d.ts +81 -0
- package/dist/drawer/root/context.js +20 -0
- package/dist/drawer/root/drawer-root.svelte +348 -0
- package/dist/drawer/root/drawer-root.svelte.d.ts +79 -0
- package/dist/drawer/root/drawer-stack.svelte.d.ts +73 -0
- package/dist/drawer/root/drawer-stack.svelte.js +113 -0
- package/dist/drawer/root/handle.svelte.d.ts +39 -0
- package/dist/drawer/root/handle.svelte.js +64 -0
- package/dist/drawer/root/keyboard-context.d.ts +13 -0
- package/dist/drawer/root/keyboard-context.js +8 -0
- package/dist/drawer/root/presence-context.d.ts +22 -0
- package/dist/drawer/root/presence-context.js +8 -0
- package/dist/drawer/root/snap-points.d.ts +68 -0
- package/dist/drawer/root/snap-points.js +120 -0
- package/dist/drawer/root/starting-style.svelte.d.ts +18 -0
- package/dist/drawer/root/starting-style.svelte.js +38 -0
- package/dist/drawer/root/types.d.ts +36 -0
- package/dist/drawer/root/types.js +1 -0
- package/dist/drawer/root/viewport-context.d.ts +2 -0
- package/dist/drawer/root/viewport-context.js +16 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +143 -0
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +22 -0
- package/dist/drawer/title/drawer-title.svelte +37 -0
- package/dist/drawer/title/drawer-title.svelte.d.ts +21 -0
- package/dist/drawer/trigger/drawer-trigger.svelte +90 -0
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +41 -0
- package/dist/drawer/viewport/drawer-viewport.svelte +69 -0
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +15 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +88 -0
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +29 -0
- package/dist/dropzone/README.md +4 -6
- package/dist/hooks/use-virtual-focus.svelte.d.ts +9 -0
- package/dist/hooks/use-virtual-focus.svelte.js +7 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -0
- package/dist/input/input.svelte +6 -6
- package/dist/input/input.svelte.d.ts +6 -6
- package/dist/internal/environment.d.ts +11 -0
- package/dist/internal/environment.js +14 -0
- package/dist/internal/localized-strings.d.ts +152 -0
- package/dist/internal/localized-strings.js +152 -0
- package/dist/internal/number-precision.d.ts +9 -0
- package/dist/internal/number-precision.js +27 -0
- package/dist/listbox/README.md +20 -1
- package/dist/listbox/item/listbox-item.svelte +43 -18
- package/dist/listbox/item/listbox-item.svelte.d.ts +24 -15
- package/dist/listbox/root/README.md +1 -1
- package/dist/listbox/root/context.d.ts +56 -1
- package/dist/listbox/root/context.js +118 -1
- package/dist/listbox/root/listbox.svelte +400 -27
- package/dist/listbox/root/listbox.svelte.d.ts +73 -16
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +41 -4
- package/dist/menu/content/menu-content.svelte +31 -14
- package/dist/menu/content/menu-content.svelte.d.ts +14 -9
- package/dist/menu/context-trigger/menu-context-trigger.svelte +194 -0
- package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +35 -0
- package/dist/menu/group/menu-group-label.svelte +1 -1
- package/dist/menu/group/menu-group-label.svelte.d.ts +1 -1
- package/dist/menu/index.d.ts +4 -1
- package/dist/menu/index.js +1 -0
- package/dist/menu/index.parts.d.ts +1 -0
- package/dist/menu/index.parts.js +1 -0
- package/dist/menu/item/menu-item.svelte +11 -8
- package/dist/menu/item/menu-item.svelte.d.ts +11 -8
- package/dist/menu/overlay/menu-overlay.svelte +2 -2
- package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
- package/dist/menu/root/context.d.ts +24 -3
- package/dist/menu/root/focus-state.d.ts +2 -2
- package/dist/menu/root/focus-state.js +8 -32
- package/dist/menu/root/menu-root.svelte +14 -8
- package/dist/menu/root/menu-root.svelte.d.ts +14 -8
- package/dist/menu/root/menu-state.svelte.d.ts +1 -1
- package/dist/menu/root/menu-state.svelte.js +24 -1
- package/dist/menu/separator/menu-separator.svelte +1 -1
- package/dist/menu/separator/menu-separator.svelte.d.ts +1 -1
- package/dist/menu/submenu/menu-submenu-root.svelte +10 -7
- package/dist/menu/submenu/menu-submenu-root.svelte.d.ts +10 -7
- package/dist/numberfield/root/README.md +1 -1
- package/dist/numberfield/root/number-field-root.svelte +2 -1
- package/dist/numberfield/root/number-utils.js +1 -20
- package/dist/numberfield/scrub-area-cursor/README.md +1 -1
- package/dist/popover/README.md +1 -1
- package/dist/popover/content/popover-content.svelte +22 -16
- package/dist/popover/content/popover-content.svelte.d.ts +19 -14
- package/dist/popover/overlay/popover-overlay.svelte +2 -2
- package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
- package/dist/popover/root/README.md +1 -1
- package/dist/popover/root/focus-state.d.ts +2 -2
- package/dist/popover/root/focus-state.js +7 -34
- package/dist/popover/root/popover-root.svelte +29 -14
- package/dist/popover/root/popover-root.svelte.d.ts +16 -5
- package/dist/popover/trigger/README.md +1 -1
- package/dist/primitives/aria-hide-outside.d.ts +13 -0
- package/dist/primitives/aria-hide-outside.js +7 -1
- package/dist/primitives/contain-wheel.d.ts +9 -0
- package/dist/primitives/contain-wheel.js +41 -0
- package/dist/primitives/floating.d.ts +49 -8
- package/dist/primitives/floating.js +75 -7
- package/dist/primitives/focus-trap.d.ts +2 -0
- package/dist/primitives/focus-trap.js +7 -1
- package/dist/primitives/focus-visible.svelte.d.ts +14 -0
- package/dist/primitives/focus-visible.svelte.js +19 -0
- package/dist/primitives/index.d.ts +3 -0
- package/dist/primitives/index.js +3 -0
- package/dist/primitives/input-modality.d.ts +7 -0
- package/dist/primitives/input-modality.js +32 -5
- package/dist/primitives/keyboard-navigation.d.ts +29 -5
- package/dist/primitives/keyboard-navigation.js +27 -17
- package/dist/primitives/layer-stack.d.ts +29 -0
- package/dist/primitives/layer-stack.js +35 -0
- package/dist/primitives/list-virtualizer.d.ts +75 -0
- package/dist/primitives/list-virtualizer.js +59 -0
- package/dist/primitives/long-press.d.ts +59 -0
- package/dist/primitives/long-press.js +142 -0
- package/dist/primitives/presence.svelte.js +6 -1
- package/dist/primitives/scroll-lock.d.ts +47 -3
- package/dist/primitives/scroll-lock.js +191 -9
- package/dist/primitives/swipe-gesture.d.ts +126 -0
- package/dist/primitives/swipe-gesture.js +351 -0
- package/dist/primitives/text.d.ts +8 -0
- package/dist/primitives/text.js +13 -0
- package/dist/primitives/trigger-focus-state.d.ts +29 -0
- package/dist/primitives/trigger-focus-state.js +57 -0
- package/dist/progress/README.md +54 -0
- package/dist/progress/index.d.ts +21 -0
- package/dist/progress/index.js +9 -0
- package/dist/progress/index.parts.d.ts +5 -0
- package/dist/progress/index.parts.js +5 -0
- package/dist/progress/indicator/progress-indicator.svelte +37 -0
- package/dist/progress/indicator/progress-indicator.svelte.d.ts +4 -0
- package/dist/progress/label/progress-label.svelte +34 -0
- package/dist/progress/label/progress-label.svelte.d.ts +4 -0
- package/dist/progress/root/context.d.ts +26 -0
- package/dist/progress/root/context.js +15 -0
- package/dist/progress/root/progress-root.svelte +136 -0
- package/dist/progress/root/progress-root.svelte.d.ts +4 -0
- package/dist/progress/root/progress-utils.d.ts +12 -0
- package/dist/progress/root/progress-utils.js +41 -0
- package/dist/progress/track/progress-track.svelte +27 -0
- package/dist/progress/track/progress-track.svelte.d.ts +4 -0
- package/dist/progress/types.d.ts +81 -0
- package/dist/progress/types.js +1 -0
- package/dist/progress/value/progress-value.svelte +36 -0
- package/dist/progress/value/progress-value.svelte.d.ts +4 -0
- package/dist/radio-group/README.md +103 -0
- package/dist/radio-group/index.d.ts +18 -0
- package/dist/radio-group/index.js +9 -0
- package/dist/radio-group/index.parts.d.ts +4 -0
- package/dist/radio-group/index.parts.js +4 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
- package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
- package/dist/radio-group/item/context.d.ts +18 -0
- package/dist/radio-group/item/context.js +15 -0
- package/dist/radio-group/item/radio-group-item.svelte +377 -0
- package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
- package/dist/radio-group/label/radio-group-label.svelte +37 -0
- package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
- package/dist/radio-group/root/context.svelte.d.ts +57 -0
- package/dist/radio-group/root/context.svelte.js +284 -0
- package/dist/radio-group/root/radio-group-root.svelte +193 -0
- package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
- package/dist/radio-group/types.d.ts +50 -0
- package/dist/radio-group/types.js +1 -0
- package/dist/select/README.md +129 -0
- package/dist/select/index.d.ts +30 -0
- package/dist/select/index.js +16 -0
- package/dist/select/index.parts.d.ts +8 -0
- package/dist/select/index.parts.js +9 -0
- package/dist/select/item/select-item.svelte +68 -0
- package/dist/select/item/select-item.svelte.d.ts +10 -0
- package/dist/select/item-indicator/select-item-indicator.svelte +55 -0
- package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +4 -0
- package/dist/select/label/select-label.svelte +46 -0
- package/dist/select/label/select-label.svelte.d.ts +4 -0
- package/dist/select/list/select-list.svelte +241 -0
- package/dist/select/list/select-list.svelte.d.ts +62 -0
- package/dist/select/popover/select-popover.svelte +80 -0
- package/dist/select/popover/select-popover.svelte.d.ts +9 -0
- package/dist/select/root/context.d.ts +106 -0
- package/dist/select/root/context.js +22 -0
- package/dist/select/root/select-root.svelte +544 -0
- package/dist/select/root/select-root.svelte.d.ts +25 -0
- package/dist/select/trigger/select-trigger.svelte +192 -0
- package/dist/select/trigger/select-trigger.svelte.d.ts +4 -0
- package/dist/select/types.d.ts +133 -0
- package/dist/select/types.js +1 -0
- package/dist/select/value/select-value.svelte +61 -0
- package/dist/select/value/select-value.svelte.d.ts +4 -0
- package/dist/separator/README.md +35 -0
- package/dist/separator/index.d.ts +7 -0
- package/dist/separator/index.js +3 -0
- package/dist/separator/separator.svelte +254 -0
- package/dist/separator/separator.svelte.d.ts +45 -0
- package/dist/separator/types.d.ts +1 -0
- package/dist/separator/types.js +1 -0
- package/dist/slider/README.md +61 -0
- package/dist/slider/fill/slider-fill.svelte +40 -0
- package/dist/slider/fill/slider-fill.svelte.d.ts +4 -0
- package/dist/slider/index.d.ts +9 -0
- package/dist/slider/index.js +8 -0
- package/dist/slider/index.parts.d.ts +6 -0
- package/dist/slider/index.parts.js +6 -0
- package/dist/slider/label/slider-label.svelte +44 -0
- package/dist/slider/label/slider-label.svelte.d.ts +4 -0
- package/dist/slider/output/slider-output.svelte +46 -0
- package/dist/slider/output/slider-output.svelte.d.ts +4 -0
- package/dist/slider/root/context.d.ts +106 -0
- package/dist/slider/root/context.js +15 -0
- package/dist/slider/root/slider-root.svelte +545 -0
- package/dist/slider/root/slider-root.svelte.d.ts +4 -0
- package/dist/slider/root/slider-utils.d.ts +57 -0
- package/dist/slider/root/slider-utils.js +88 -0
- package/dist/slider/thumb/slider-thumb.svelte +276 -0
- package/dist/slider/thumb/slider-thumb.svelte.d.ts +4 -0
- package/dist/slider/track/slider-track.svelte +60 -0
- package/dist/slider/track/slider-track.svelte.d.ts +4 -0
- package/dist/slider/types.d.ts +144 -0
- package/dist/slider/types.js +1 -0
- package/dist/switch/root/README.md +2 -2
- package/dist/switch/root/switch-root.svelte +49 -21
- package/dist/switch/root/switch-root.svelte.d.ts +26 -14
- package/dist/switch/thumb/switch-thumb.svelte +1 -1
- package/dist/switch/thumb/switch-thumb.svelte.d.ts +1 -1
- package/dist/table/README.md +16 -9
- package/dist/table/body/table-body.svelte +84 -9
- package/dist/table/cell/table-cell.svelte +27 -10
- package/dist/table/checkbox/table-checkbox.svelte +3 -0
- package/dist/table/checkbox-indicator/README.md +1 -1
- package/dist/table/column/table-column.svelte +5 -1
- package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
- package/dist/table/column-resizer/README.md +2 -2
- package/dist/table/column-resizer/table-column-resizer.svelte +1 -5
- package/dist/table/index.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/interactive-cell/table-interactive-cell.svelte +26 -10
- package/dist/table/root/README.md +1 -1
- package/dist/table/root/context.svelte.d.ts +17 -0
- package/dist/table/root/context.svelte.js +212 -66
- package/dist/table/root/table-root.svelte +36 -6
- package/dist/table/row/table-row.svelte +14 -14
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/sort-trigger/table-sort-trigger.svelte +5 -1
- package/dist/table/types.d.ts +32 -14
- package/dist/tabs/root/tabs-root.svelte +20 -6
- package/dist/tabs/types.d.ts +9 -0
- package/dist/timepicker/README.md +3 -2
- package/dist/timepicker/input/README.md +1 -1
- package/dist/timepicker/input/time-picker-input.svelte +66 -5
- package/dist/timepicker/input/time-picker-input.svelte.d.ts +18 -1
- package/dist/timepicker/root/README.md +1 -1
- package/dist/timepicker/root/time-picker-root.svelte +11 -0
- package/dist/timepicker/root/time-picker-root.svelte.d.ts +2 -0
- package/dist/timepicker/trigger/README.md +1 -1
- package/dist/toast/README.md +75 -0
- package/dist/toast/action/toast-action.svelte +42 -0
- package/dist/toast/action/toast-action.svelte.d.ts +4 -0
- package/dist/toast/close/toast-close.svelte +41 -0
- package/dist/toast/close/toast-close.svelte.d.ts +4 -0
- package/dist/toast/content/toast-content.svelte +24 -0
- package/dist/toast/content/toast-content.svelte.d.ts +4 -0
- package/dist/toast/description/toast-description.svelte +41 -0
- package/dist/toast/description/toast-description.svelte.d.ts +4 -0
- package/dist/toast/index.d.ts +34 -0
- package/dist/toast/index.js +15 -0
- package/dist/toast/index.parts.d.ts +9 -0
- package/dist/toast/index.parts.js +9 -0
- package/dist/toast/positioner/toast-positioner.svelte +75 -0
- package/dist/toast/positioner/toast-positioner.svelte.d.ts +4 -0
- package/dist/toast/provider/context.d.ts +36 -0
- package/dist/toast/provider/context.js +22 -0
- package/dist/toast/provider/toast-manager.svelte.d.ts +113 -0
- package/dist/toast/provider/toast-manager.svelte.js +210 -0
- package/dist/toast/provider/toast-provider.svelte +98 -0
- package/dist/toast/provider/toast-provider.svelte.d.ts +4 -0
- package/dist/toast/root/context.d.ts +18 -0
- package/dist/toast/root/context.js +15 -0
- package/dist/toast/root/toast-root.svelte +296 -0
- package/dist/toast/root/toast-root.svelte.d.ts +4 -0
- package/dist/toast/title/toast-title.svelte +38 -0
- package/dist/toast/title/toast-title.svelte.d.ts +4 -0
- package/dist/toast/types.d.ts +100 -0
- package/dist/toast/types.js +1 -0
- package/dist/toast/viewport/toast-viewport.svelte +389 -0
- package/dist/toast/viewport/toast-viewport.svelte.d.ts +4 -0
- package/dist/toggle/README.md +1 -1
- package/dist/toggle/root/toggle-root.svelte +28 -0
- package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
- package/dist/toggle-group/README.md +12 -4
- package/dist/toggle-group/index.d.ts +2 -0
- package/dist/toggle-group/index.parts.d.ts +1 -0
- package/dist/toggle-group/index.parts.js +4 -0
- package/dist/toggle-group/root/context.svelte.d.ts +1 -1
- package/dist/toggle-group/root/context.svelte.js +24 -8
- package/dist/toggle-group/root/toggle-group-root.svelte +24 -4
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte +13 -0
- package/dist/toggle-group/root/toggle-group-teardown-order-child.svelte.d.ts +7 -0
- package/dist/toggle-group/types.d.ts +9 -0
- package/dist/tooltip/README.md +53 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte +36 -0
- package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +4 -0
- package/dist/tooltip/content/tooltip-content.svelte +148 -0
- package/dist/tooltip/content/tooltip-content.svelte.d.ts +4 -0
- package/dist/tooltip/index.d.ts +8 -0
- package/dist/tooltip/index.js +7 -0
- package/dist/tooltip/index.parts.d.ts +5 -0
- package/dist/tooltip/index.parts.js +5 -0
- package/dist/tooltip/provider/tooltip-provider.svelte +36 -0
- package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +4 -0
- package/dist/tooltip/root/context.d.ts +46 -0
- package/dist/tooltip/root/context.js +22 -0
- package/dist/tooltip/root/safe-polygon.d.ts +26 -0
- package/dist/tooltip/root/safe-polygon.js +66 -0
- package/dist/tooltip/root/tooltip-group.d.ts +26 -0
- package/dist/tooltip/root/tooltip-group.js +41 -0
- package/dist/tooltip/root/tooltip-root.svelte +461 -0
- package/dist/tooltip/root/tooltip-root.svelte.d.ts +4 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte +52 -0
- package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +4 -0
- package/dist/tooltip/types.d.ts +105 -0
- package/dist/tooltip/types.js +1 -0
- package/dist/transfer-list/README.md +110 -0
- package/dist/transfer-list/index.d.ts +33 -0
- package/dist/transfer-list/index.js +18 -0
- package/dist/transfer-list/index.parts.d.ts +9 -0
- package/dist/transfer-list/index.parts.js +10 -0
- package/dist/transfer-list/item/transfer-list-item.svelte +74 -0
- package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +35 -0
- package/dist/transfer-list/list/transfer-list-list.svelte +162 -0
- package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +56 -0
- package/dist/transfer-list/list/transfer-list-source.svelte +13 -0
- package/dist/transfer-list/list/transfer-list-source.svelte.d.ts +36 -0
- package/dist/transfer-list/list/transfer-list-target.svelte +14 -0
- package/dist/transfer-list/list/transfer-list-target.svelte.d.ts +36 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-all.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte +103 -0
- package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +25 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-down.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-selected.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte +14 -0
- package/dist/transfer-list/move/transfer-list-move-up.svelte.d.ts +10 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte +83 -0
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +21 -0
- package/dist/transfer-list/root/context.d.ts +70 -0
- package/dist/transfer-list/root/context.js +24 -0
- package/dist/transfer-list/root/transfer-list-root.svelte +345 -0
- package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +68 -0
- package/dist/transfer-list/root/types.d.ts +22 -0
- package/dist/transfer-list/root/types.js +4 -0
- package/dist/transfer-list/status/transfer-list-status.svelte +70 -0
- package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +15 -0
- package/dist/tree/README.md +3 -3
- package/dist/tree/checkbox-indicator/README.md +1 -1
- package/dist/tree/root/README.md +1 -1
- package/dist/tree/root/context.svelte.js +6 -0
- package/dist/tree/root/tree-root.svelte +22 -8
- package/dist/tree/types.d.ts +23 -1
- package/package.json +282 -224
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ProgressStatus } from './progress-utils';
|
|
2
|
+
export type ProgressOrientation = 'horizontal' | 'vertical';
|
|
3
|
+
export type ProgressContext = {
|
|
4
|
+
/** The id of the root element. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** The value, held in the range. `null` while the progress is indeterminate. */
|
|
7
|
+
value: number | null;
|
|
8
|
+
min: number;
|
|
9
|
+
max: number;
|
|
10
|
+
/** The position in the range, from 0 to 100. `null` while the progress is indeterminate. */
|
|
11
|
+
percent: number | null;
|
|
12
|
+
status: ProgressStatus;
|
|
13
|
+
orientation: ProgressOrientation;
|
|
14
|
+
/** The value as text, for the user. Empty while the progress is indeterminate. */
|
|
15
|
+
formattedValue: string;
|
|
16
|
+
/** The text a screen reader gets for the value. */
|
|
17
|
+
valueText: string | undefined;
|
|
18
|
+
/** The ids of the registered labels, for `aria-labelledby`. */
|
|
19
|
+
labelledBy: string | undefined;
|
|
20
|
+
/** Registers a label id; the returned function unregisters it. */
|
|
21
|
+
registerLabel: (id: string) => () => void;
|
|
22
|
+
};
|
|
23
|
+
export declare function setProgressContext(context: ProgressContext): void;
|
|
24
|
+
export declare function getProgressContext(): ProgressContext | undefined;
|
|
25
|
+
export declare function useProgressContext(part?: string): ProgressContext;
|
|
26
|
+
export type { ProgressStatus };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol('progress');
|
|
3
|
+
export function setProgressContext(context) {
|
|
4
|
+
setContext(KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getProgressContext() {
|
|
7
|
+
return getContext(KEY);
|
|
8
|
+
}
|
|
9
|
+
export function useProgressContext(part = 'Progress') {
|
|
10
|
+
const context = getProgressContext();
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error(`${part} must be used within Progress.Root.`);
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { readable } from 'svelte/store';
|
|
4
|
+
import { useLocaleContextOptional } from '../../locale-provider/context';
|
|
5
|
+
import type { ProgressRootProps } from '../types.js';
|
|
6
|
+
import { setProgressContext, type ProgressContext } from './context';
|
|
7
|
+
import {
|
|
8
|
+
clampProgressValue,
|
|
9
|
+
formatProgressValue,
|
|
10
|
+
getProgressPercent,
|
|
11
|
+
getProgressStatus,
|
|
12
|
+
normalizeProgressValue
|
|
13
|
+
} from './progress-utils';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Progress.Root — the status of a task that takes time.
|
|
17
|
+
*
|
|
18
|
+
* It is the `role="progressbar"` element, and it holds the numbers for the parts in it. A
|
|
19
|
+
* screen reader reads its name and its value; it does not read the parts. The value is
|
|
20
|
+
* `aria-valuenow` with `aria-valuetext`, or nothing at all while the end of the task is not
|
|
21
|
+
* known: a number for an indeterminate progress would be a lie.
|
|
22
|
+
*/
|
|
23
|
+
const generatedId = $props.id();
|
|
24
|
+
|
|
25
|
+
let {
|
|
26
|
+
id: idProp,
|
|
27
|
+
value: valueProp,
|
|
28
|
+
min = 0,
|
|
29
|
+
max = 100,
|
|
30
|
+
format,
|
|
31
|
+
getValueText,
|
|
32
|
+
'aria-valuetext': ariaValueTextProp,
|
|
33
|
+
'aria-labelledby': ariaLabelledBy,
|
|
34
|
+
orientation = 'horizontal',
|
|
35
|
+
children,
|
|
36
|
+
class: className = '',
|
|
37
|
+
element = $bindable<HTMLDivElement | null>(null),
|
|
38
|
+
context = $bindable(),
|
|
39
|
+
...restProps
|
|
40
|
+
}: ProgressRootProps = $props();
|
|
41
|
+
|
|
42
|
+
const instanceId = untrack(() => idProp) ?? generatedId;
|
|
43
|
+
|
|
44
|
+
const localeContext = useLocaleContextOptional();
|
|
45
|
+
const emptyLocaleStore = readable<string | undefined>(undefined);
|
|
46
|
+
const localeStore = localeContext?.locale ?? emptyLocaleStore;
|
|
47
|
+
|
|
48
|
+
let rootRef: HTMLDivElement | null = $state(null);
|
|
49
|
+
let labelIds = $state<string[]>([]);
|
|
50
|
+
|
|
51
|
+
const rawValue = $derived(normalizeProgressValue(valueProp));
|
|
52
|
+
const value = $derived(rawValue === null ? null : clampProgressValue(rawValue, min, max));
|
|
53
|
+
const percent = $derived(rawValue === null ? null : getProgressPercent(rawValue, min, max));
|
|
54
|
+
const status = $derived(getProgressStatus(rawValue, min, max));
|
|
55
|
+
const formattedValue = $derived(formatProgressValue(rawValue, min, max, $localeStore, format));
|
|
56
|
+
const valueText = $derived.by(() => {
|
|
57
|
+
if (value === null) return undefined;
|
|
58
|
+
if (ariaValueTextProp !== undefined) return ariaValueTextProp;
|
|
59
|
+
if (getValueText) return getValueText(formattedValue, value);
|
|
60
|
+
return formattedValue;
|
|
61
|
+
});
|
|
62
|
+
const labelledBy = $derived(
|
|
63
|
+
ariaLabelledBy ?? (labelIds.length > 0 ? labelIds.join(' ') : undefined)
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const progress: ProgressContext = {
|
|
67
|
+
get id() {
|
|
68
|
+
return instanceId;
|
|
69
|
+
},
|
|
70
|
+
get value() {
|
|
71
|
+
return value;
|
|
72
|
+
},
|
|
73
|
+
get min() {
|
|
74
|
+
return min;
|
|
75
|
+
},
|
|
76
|
+
get max() {
|
|
77
|
+
return max;
|
|
78
|
+
},
|
|
79
|
+
get percent() {
|
|
80
|
+
return percent;
|
|
81
|
+
},
|
|
82
|
+
get status() {
|
|
83
|
+
return status;
|
|
84
|
+
},
|
|
85
|
+
get orientation() {
|
|
86
|
+
return orientation;
|
|
87
|
+
},
|
|
88
|
+
get formattedValue() {
|
|
89
|
+
return formattedValue;
|
|
90
|
+
},
|
|
91
|
+
get valueText() {
|
|
92
|
+
return valueText;
|
|
93
|
+
},
|
|
94
|
+
get labelledBy() {
|
|
95
|
+
return labelledBy;
|
|
96
|
+
},
|
|
97
|
+
// `untrack` because the caller registers from an effect: reading `labelIds` here would
|
|
98
|
+
// make that effect depend on what it writes, and the pair would run without end.
|
|
99
|
+
registerLabel(id: string) {
|
|
100
|
+
untrack(() => {
|
|
101
|
+
labelIds = [...labelIds, id];
|
|
102
|
+
});
|
|
103
|
+
return () =>
|
|
104
|
+
untrack(() => {
|
|
105
|
+
labelIds = labelIds.filter((candidate) => candidate !== id);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
setProgressContext(progress);
|
|
111
|
+
context = progress;
|
|
112
|
+
|
|
113
|
+
$effect(() => {
|
|
114
|
+
element = rootRef;
|
|
115
|
+
});
|
|
116
|
+
</script>
|
|
117
|
+
|
|
118
|
+
<div
|
|
119
|
+
{...restProps}
|
|
120
|
+
bind:this={rootRef}
|
|
121
|
+
id={instanceId}
|
|
122
|
+
role="progressbar"
|
|
123
|
+
aria-labelledby={labelledBy}
|
|
124
|
+
aria-valuemin={min}
|
|
125
|
+
aria-valuemax={max}
|
|
126
|
+
aria-valuenow={value ?? undefined}
|
|
127
|
+
aria-valuetext={valueText}
|
|
128
|
+
class={className}
|
|
129
|
+
data-progress-root="true"
|
|
130
|
+
data-orientation={orientation}
|
|
131
|
+
data-progressing={status === 'progressing' || undefined}
|
|
132
|
+
data-complete={status === 'complete' || undefined}
|
|
133
|
+
data-indeterminate={status === 'indeterminate' || undefined}
|
|
134
|
+
>
|
|
135
|
+
{@render children?.()}
|
|
136
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ProgressStatus = 'progressing' | 'complete' | 'indeterminate';
|
|
2
|
+
/** A finite number is a value. Anything else keeps the progress indeterminate. */
|
|
3
|
+
export declare function normalizeProgressValue(value: number | null | undefined): number | null;
|
|
4
|
+
export declare function clampProgressValue(value: number, min: number, max: number): number;
|
|
5
|
+
/** The position of a value in the range, from 0 to 100. An empty range reads as 0. */
|
|
6
|
+
export declare function getProgressPercent(value: number, min: number, max: number): number;
|
|
7
|
+
export declare function getProgressStatus(value: number | null, min: number, max: number): ProgressStatus;
|
|
8
|
+
/**
|
|
9
|
+
* The text for a value. With `format`, it is the value in that format. Without it, it is the
|
|
10
|
+
* position in the range as a percentage: `31%` for 31 of 100, and for 62 of 200.
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatProgressValue(value: number | null, min: number, max: number, locale: string | undefined, format: Intl.NumberFormatOptions | undefined): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A finite number is a value. Anything else keeps the progress indeterminate. */
|
|
2
|
+
export function normalizeProgressValue(value) {
|
|
3
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
4
|
+
}
|
|
5
|
+
export function clampProgressValue(value, min, max) {
|
|
6
|
+
if (max < min)
|
|
7
|
+
return min;
|
|
8
|
+
return Math.min(max, Math.max(min, value));
|
|
9
|
+
}
|
|
10
|
+
/** The position of a value in the range, from 0 to 100. An empty range reads as 0. */
|
|
11
|
+
export function getProgressPercent(value, min, max) {
|
|
12
|
+
const span = max - min;
|
|
13
|
+
if (!(span > 0))
|
|
14
|
+
return 0;
|
|
15
|
+
const percent = ((clampProgressValue(value, min, max) - min) / span) * 100;
|
|
16
|
+
return Math.min(100, Math.max(0, percent));
|
|
17
|
+
}
|
|
18
|
+
export function getProgressStatus(value, min, max) {
|
|
19
|
+
if (value === null)
|
|
20
|
+
return 'indeterminate';
|
|
21
|
+
return clampProgressValue(value, min, max) >= max ? 'complete' : 'progressing';
|
|
22
|
+
}
|
|
23
|
+
function createFormatter(locale, options) {
|
|
24
|
+
try {
|
|
25
|
+
return new Intl.NumberFormat(locale, options);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return new Intl.NumberFormat(undefined, options);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The text for a value. With `format`, it is the value in that format. Without it, it is the
|
|
33
|
+
* position in the range as a percentage: `31%` for 31 of 100, and for 62 of 200.
|
|
34
|
+
*/
|
|
35
|
+
export function formatProgressValue(value, min, max, locale, format) {
|
|
36
|
+
if (value === null)
|
|
37
|
+
return '';
|
|
38
|
+
if (format)
|
|
39
|
+
return createFormatter(locale, format).format(clampProgressValue(value, min, max));
|
|
40
|
+
return createFormatter(locale, { style: 'percent' }).format(getProgressPercent(value, min, max) / 100);
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressTrackProps } from '../types.js';
|
|
3
|
+
import { useProgressContext } from '../root/context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Progress.Track — the full length of the task. The indicator fills a part of it.
|
|
7
|
+
*
|
|
8
|
+
* It is `position: relative` with `overflow: hidden`, thus the indicator takes its place in
|
|
9
|
+
* it with an inset, and an animated indeterminate indicator stays in it.
|
|
10
|
+
*/
|
|
11
|
+
let { children, class: className = '', style, ...restProps }: ProgressTrackProps = $props();
|
|
12
|
+
|
|
13
|
+
const progress = useProgressContext('Progress.Track');
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
{...restProps}
|
|
18
|
+
class={className}
|
|
19
|
+
style="position: relative; overflow: hidden;{style ? ` ${style}` : ''}"
|
|
20
|
+
data-progress-track="true"
|
|
21
|
+
data-orientation={progress.orientation}
|
|
22
|
+
data-progressing={progress.status === 'progressing' || undefined}
|
|
23
|
+
data-complete={progress.status === 'complete' || undefined}
|
|
24
|
+
data-indeterminate={progress.status === 'indeterminate' || undefined}
|
|
25
|
+
>
|
|
26
|
+
{@render children?.()}
|
|
27
|
+
</div>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { ProgressContext, ProgressOrientation, ProgressStatus } from './root/context.js';
|
|
4
|
+
export type { ProgressContext, ProgressOrientation, ProgressStatus } from './root/context.js';
|
|
5
|
+
export type ProgressRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'aria-valuenow' | 'aria-valuemin' | 'aria-valuemax'> & {
|
|
6
|
+
/**
|
|
7
|
+
* The progress of the task, between `min` and `max`. `null` makes the progress indeterminate:
|
|
8
|
+
* the task runs, and its end is not known. A value out of the range is held at the near end.
|
|
9
|
+
*/
|
|
10
|
+
value: number | null;
|
|
11
|
+
/** The value at the start of the task. */
|
|
12
|
+
min?: number;
|
|
13
|
+
/** The value at the end of the task. The progress is complete when the value reaches it. */
|
|
14
|
+
max?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The format of the value as text. Without it, the text is the position in the range as a
|
|
17
|
+
* percentage. Give the options of `Intl.NumberFormat` to show the value itself, in a unit.
|
|
18
|
+
*/
|
|
19
|
+
format?: Intl.NumberFormatOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Makes the text a screen reader gets for the value. It gets the formatted text and the value.
|
|
22
|
+
* Without it, the screen reader gets the formatted text.
|
|
23
|
+
*/
|
|
24
|
+
getValueText?: (formattedValue: string, value: number | null) => string;
|
|
25
|
+
/**
|
|
26
|
+
* The text a screen reader gets for the value. It wins over `getValueText`. It has no effect
|
|
27
|
+
* while the progress is indeterminate: without a number, a text for the number is nothing.
|
|
28
|
+
*/
|
|
29
|
+
'aria-valuetext'?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The direction of the bar. It sets `data-orientation` for your styles, and it tells the
|
|
32
|
+
* indicator which side to fill from.
|
|
33
|
+
*/
|
|
34
|
+
orientation?: ProgressOrientation;
|
|
35
|
+
/** The parts of the progress bar. */
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
/** The CSS class names of the element. */
|
|
38
|
+
class?: string;
|
|
39
|
+
/** The id of the root element. The component makes one when you give none. */
|
|
40
|
+
id?: string;
|
|
41
|
+
/** The root element. Use `bind:element` to read it. */
|
|
42
|
+
element?: HTMLDivElement | null;
|
|
43
|
+
/**
|
|
44
|
+
* The state of the progress. Use `bind:context` to read `percent`, `status` and
|
|
45
|
+
* `formattedValue` for a shape of your own, such as a ring.
|
|
46
|
+
*/
|
|
47
|
+
context?: ProgressContext;
|
|
48
|
+
};
|
|
49
|
+
export type ProgressLabelProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'id'> & {
|
|
50
|
+
/** The name of the task. */
|
|
51
|
+
children?: Snippet;
|
|
52
|
+
/** The CSS class names of the element. */
|
|
53
|
+
class?: string;
|
|
54
|
+
/** The id of the label element. The component makes one when you give none. */
|
|
55
|
+
id?: string;
|
|
56
|
+
};
|
|
57
|
+
export type ProgressTrackProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
58
|
+
/** The indicator. */
|
|
59
|
+
children?: Snippet;
|
|
60
|
+
/** The CSS class names of the element. */
|
|
61
|
+
class?: string;
|
|
62
|
+
};
|
|
63
|
+
export type ProgressIndicatorProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
|
|
64
|
+
/** Content inside the indicator, such as a stripe. */
|
|
65
|
+
children?: Snippet;
|
|
66
|
+
/** The CSS class names of the element. */
|
|
67
|
+
class?: string;
|
|
68
|
+
};
|
|
69
|
+
export type ProgressValueState = {
|
|
70
|
+
/** The value as text. Empty while the progress is indeterminate. */
|
|
71
|
+
formattedValue: string;
|
|
72
|
+
/** The value, held in the range. `null` while the progress is indeterminate. */
|
|
73
|
+
value: number | null;
|
|
74
|
+
status: ProgressStatus;
|
|
75
|
+
};
|
|
76
|
+
export type ProgressValueProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
77
|
+
/** The content in place of the formatted text. It gets the text, the value and the status. */
|
|
78
|
+
children?: Snippet<[ProgressValueState]>;
|
|
79
|
+
/** The CSS class names of the element. */
|
|
80
|
+
class?: string;
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ProgressValueProps } from '../types.js';
|
|
3
|
+
import { useProgressContext } from '../root/context';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Progress.Value — the value as text, for the user.
|
|
7
|
+
*
|
|
8
|
+
* It is `aria-hidden`: the screen reader already gets the value from the progress bar, thus a
|
|
9
|
+
* second copy would read twice. Give it children to shape the text; without them, it shows
|
|
10
|
+
* the formatted value, and nothing while the progress is indeterminate.
|
|
11
|
+
*/
|
|
12
|
+
let { children, class: className = '', ...restProps }: ProgressValueProps = $props();
|
|
13
|
+
|
|
14
|
+
const progress = useProgressContext('Progress.Value');
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<span
|
|
18
|
+
{...restProps}
|
|
19
|
+
class={className}
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
data-progress-value="true"
|
|
22
|
+
data-orientation={progress.orientation}
|
|
23
|
+
data-progressing={progress.status === 'progressing' || undefined}
|
|
24
|
+
data-complete={progress.status === 'complete' || undefined}
|
|
25
|
+
data-indeterminate={progress.status === 'indeterminate' || undefined}
|
|
26
|
+
>
|
|
27
|
+
{#if children}
|
|
28
|
+
{@render children({
|
|
29
|
+
formattedValue: progress.formattedValue,
|
|
30
|
+
value: progress.value,
|
|
31
|
+
status: progress.status
|
|
32
|
+
})}
|
|
33
|
+
{:else}
|
|
34
|
+
{progress.formattedValue}
|
|
35
|
+
{/if}
|
|
36
|
+
</span>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# RadioGroup
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
`RadioGroup` coordinates a set of `RadioGroup.Item` buttons as one field. It holds a single value, and
|
|
6
|
+
it shares a `name` for form submission. It also spreads group-wide disabled, read-only and required
|
|
7
|
+
state, and it controls the roving focus the pattern asks for.
|
|
8
|
+
|
|
9
|
+
## Anatomy
|
|
10
|
+
|
|
11
|
+
- `RadioGroup.Root`
|
|
12
|
+
- `RadioGroup.Label`
|
|
13
|
+
- `RadioGroup.Item`
|
|
14
|
+
- `RadioGroup.Indicator`
|
|
15
|
+
|
|
16
|
+
```svelte
|
|
17
|
+
<RadioGroup.Root name="size" defaultValue="medium">
|
|
18
|
+
<RadioGroup.Label>Size</RadioGroup.Label>
|
|
19
|
+
<RadioGroup.Item value="small">
|
|
20
|
+
<RadioGroup.Indicator>x</RadioGroup.Indicator>
|
|
21
|
+
Small
|
|
22
|
+
</RadioGroup.Item>
|
|
23
|
+
<RadioGroup.Item value="medium">
|
|
24
|
+
<RadioGroup.Indicator>x</RadioGroup.Indicator>
|
|
25
|
+
Medium
|
|
26
|
+
</RadioGroup.Item>
|
|
27
|
+
</RadioGroup.Root>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage guidelines
|
|
31
|
+
|
|
32
|
+
- Use `bind:value` to hand the group your state, or plain `value` + `onChange` to own it yourself.
|
|
33
|
+
There is no flag to declare which: supplying `value` makes it the source of truth either way, and
|
|
34
|
+
`onChange` always reports.
|
|
35
|
+
- A parent that holds `value` and refuses a change — it sends no new value down — still sees the
|
|
36
|
+
group move. The group then goes back to the value of the parent at the next render.
|
|
37
|
+
- Give the group a `name` to submit the answer as one field.
|
|
38
|
+
- Every `RadioGroup.Item` must provide a unique `value`, and it must sit inside a `RadioGroup.Root`. A
|
|
39
|
+
radio on its own has nothing to answer, and the component reports that rather than guessing.
|
|
40
|
+
|
|
41
|
+
## API reference
|
|
42
|
+
|
|
43
|
+
`RadioGroup.Root` supports:
|
|
44
|
+
|
|
45
|
+
- `value?: string | null`
|
|
46
|
+
- `defaultValue?: string | null`
|
|
47
|
+
- `onChange?: (value: string) => void`
|
|
48
|
+
- `name?: string`
|
|
49
|
+
- `form?: string`
|
|
50
|
+
- `disabled?: boolean`
|
|
51
|
+
- `readonly?: boolean`
|
|
52
|
+
- `required?: boolean`
|
|
53
|
+
- `orientation?: 'horizontal' | 'vertical'`
|
|
54
|
+
- `context?: RadioGroupContext`
|
|
55
|
+
- `children?: Snippet`
|
|
56
|
+
- `...restProps: HTMLAttributes<HTMLDivElement>`
|
|
57
|
+
|
|
58
|
+
`RadioGroup.Item` supports `value` (required), `disabled`, `children`, `class`, `element` and the
|
|
59
|
+
usual `HTMLAttributes<HTMLSpanElement>`. It makes a span with `role="radio"` and a hidden radio
|
|
60
|
+
input for the form.
|
|
61
|
+
|
|
62
|
+
`RadioGroup.Indicator` supports `forceMount`. It is in the DOM only while its radio is checked.
|
|
63
|
+
|
|
64
|
+
`RadioGroup.Label` supports `children`, `class`, `id` and the usual `HTMLAttributes<HTMLSpanElement>`.
|
|
65
|
+
It renders a span, and it registers its id with the group as `aria-labelledby`.
|
|
66
|
+
|
|
67
|
+
## Accessibility
|
|
68
|
+
|
|
69
|
+
- `RadioGroup.Root` renders `role="radiogroup"`, with `aria-orientation`, `aria-required`,
|
|
70
|
+
`aria-disabled` and `aria-readonly`. That role supports all four, which the plain `group` role of
|
|
71
|
+
a checkbox group does not.
|
|
72
|
+
- Give the group an accessible name with `RadioGroup.Label`, or with `aria-label` on the root for a
|
|
73
|
+
name the user does not see. Two labels read as one name, in the order they appear. An
|
|
74
|
+
`aria-labelledby` that the caller gives stands, thus an element of your own wins.
|
|
75
|
+
- `RadioGroup.Label` renders a span, and not a `<label>`: a `<label>` names one control, thus it
|
|
76
|
+
cannot name a set.
|
|
77
|
+
- The id reaches the group through the context. The server cannot do that: the group tag is
|
|
78
|
+
already written when the label registers. Thus `aria-labelledby` appears at hydration. Give
|
|
79
|
+
`aria-label` as well when the name must be there on the first paint.
|
|
80
|
+
- The group holds **one** tab stop, on the checked radio, and on the first enabled radio while
|
|
81
|
+
nothing is checked. Thus Tab enters the group where the user left it, and Tab leaves the group
|
|
82
|
+
rather than walking through it.
|
|
83
|
+
- The arrow keys move the focus **and** the selection, and they wrap at both ends. `Home` and `End`
|
|
84
|
+
jump to the bounds. Both axes work in either orientation, the way a native radio group does.
|
|
85
|
+
- `Space` selects the focused radio. `Enter` does not: it submits the form of a native radio.
|
|
86
|
+
- `aria-readonly` and `aria-required` are on the group, and never on an item: the `radio` role
|
|
87
|
+
does not support them.
|
|
88
|
+
- Give each radio an accessible name with its content, `aria-label` or `aria-labelledby`.
|
|
89
|
+
|
|
90
|
+
## Notes
|
|
91
|
+
|
|
92
|
+
- There is no unselecting. The platform gives the user no way to take a radio answer back, so a
|
|
93
|
+
second press on the selected radio reports nothing.
|
|
94
|
+
- A radio that leaves a mounted group keeps its value in the group. Its hidden input goes with it,
|
|
95
|
+
so the form stops submitting that answer, which is what a native radio group does. A parent
|
|
96
|
+
that holds the value keeps it. The group gives the tab stop to the first enabled radio.
|
|
97
|
+
- Values are strings only. A radio carries its value on a native `<input>`, which stores it as a
|
|
98
|
+
string. A number would thus let `value={1}` miss a radio declared as `value="1"`.
|
|
99
|
+
- Both parts show each visual state in `data-*` attributes: `data-checked`, `data-unchecked`,
|
|
100
|
+
`data-pressed`, `data-disabled`, `data-readonly`, `data-required`, `data-focused` and
|
|
101
|
+
`data-focus-visible`.
|
|
102
|
+
- The selection follows the focus. This is the rule that parts a radio group from every other group
|
|
103
|
+
in this library. In a `ToggleGroup` or a `CheckboxGroup` the arrows only move.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComponentProps } from 'svelte';
|
|
2
|
+
import type RadioGroupIndicatorComponent from './indicator/radio-group-indicator.svelte';
|
|
3
|
+
import type RadioGroupLabelComponent from './label/radio-group-label.svelte';
|
|
4
|
+
import type RadioGroupItemComponent from './item/radio-group-item.svelte';
|
|
5
|
+
import type RadioGroupRootComponent from './root/radio-group-root.svelte';
|
|
6
|
+
export * as RadioGroup from './index.parts.js';
|
|
7
|
+
export { default as RadioGroupRoot } from './root/radio-group-root.svelte';
|
|
8
|
+
export { default as RadioGroupLabel } from './label/radio-group-label.svelte';
|
|
9
|
+
export { default as RadioGroupItem } from './item/radio-group-item.svelte';
|
|
10
|
+
export { default as RadioGroupIndicator } from './indicator/radio-group-indicator.svelte';
|
|
11
|
+
export type RadioGroupRootProps = ComponentProps<typeof RadioGroupRootComponent>;
|
|
12
|
+
export type RadioGroupLabelProps = ComponentProps<typeof RadioGroupLabelComponent>;
|
|
13
|
+
export type RadioGroupItemProps = ComponentProps<typeof RadioGroupItemComponent>;
|
|
14
|
+
export type RadioGroupIndicatorProps = ComponentProps<typeof RadioGroupIndicatorComponent>;
|
|
15
|
+
export { createRadioGroupContext, getRadioGroupContext, setRadioGroupContext, useRadioGroupContext, type CreateRadioGroupContextOptions, type RadioGroupContext, type RadioGroupOrientation, type RadioGroupValue } from './root/context.svelte';
|
|
16
|
+
export { getRadioGroupItemContext, setRadioGroupItemContext, useRadioGroupItemContext, type RadioGroupItemContext, type RadioGroupItemState } from './item/context.js';
|
|
17
|
+
import * as RadioGroupParts from './index.parts.js';
|
|
18
|
+
export default RadioGroupParts;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as RadioGroup from './index.parts.js';
|
|
2
|
+
export { default as RadioGroupRoot } from './root/radio-group-root.svelte';
|
|
3
|
+
export { default as RadioGroupLabel } from './label/radio-group-label.svelte';
|
|
4
|
+
export { default as RadioGroupItem } from './item/radio-group-item.svelte';
|
|
5
|
+
export { default as RadioGroupIndicator } from './indicator/radio-group-indicator.svelte';
|
|
6
|
+
export { createRadioGroupContext, getRadioGroupContext, setRadioGroupContext, useRadioGroupContext } from './root/context.svelte';
|
|
7
|
+
export { getRadioGroupItemContext, setRadioGroupItemContext, useRadioGroupItemContext } from './item/context.js';
|
|
8
|
+
import * as RadioGroupParts from './index.parts.js';
|
|
9
|
+
export default RadioGroupParts;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Root } from './root/radio-group-root.svelte';
|
|
2
|
+
export { default as Label } from './label/radio-group-label.svelte';
|
|
3
|
+
export { default as Item } from './item/radio-group-item.svelte';
|
|
4
|
+
export { default as Indicator } from './indicator/radio-group-indicator.svelte';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as Root } from './root/radio-group-root.svelte';
|
|
2
|
+
export { default as Label } from './label/radio-group-label.svelte';
|
|
3
|
+
export { default as Item } from './item/radio-group-item.svelte';
|
|
4
|
+
export { default as Indicator } from './indicator/radio-group-indicator.svelte';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { useRadioGroupItemContext } from '../item/context';
|
|
5
|
+
|
|
6
|
+
type RadioGroupIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
7
|
+
/** Keeps the indicator in the DOM while the radio is not checked, for exit animations. */
|
|
8
|
+
forceMount?: boolean;
|
|
9
|
+
/** The mark itself. */
|
|
10
|
+
children?: Snippet;
|
|
11
|
+
class?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
forceMount = false,
|
|
16
|
+
children,
|
|
17
|
+
class: className = '',
|
|
18
|
+
...restProps
|
|
19
|
+
}: RadioGroupIndicatorProps = $props();
|
|
20
|
+
|
|
21
|
+
const radio = useRadioGroupItemContext();
|
|
22
|
+
const visible = $derived(radio.isChecked);
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
{#if forceMount || visible}
|
|
26
|
+
<span
|
|
27
|
+
{...restProps}
|
|
28
|
+
data-radio-group-indicator="true"
|
|
29
|
+
data-checked={radio.isChecked || undefined}
|
|
30
|
+
data-unchecked={!radio.isChecked || undefined}
|
|
31
|
+
data-pressed={radio.pressed || undefined}
|
|
32
|
+
data-disabled={radio.isDisabled || undefined}
|
|
33
|
+
data-readonly={radio.isReadOnly || undefined}
|
|
34
|
+
data-required={radio.required || undefined}
|
|
35
|
+
data-focused={radio.focused || undefined}
|
|
36
|
+
data-focus-visible={radio.focusVisible || undefined}
|
|
37
|
+
hidden={forceMount && !visible}
|
|
38
|
+
aria-hidden={forceMount && !visible ? 'true' : undefined}
|
|
39
|
+
class={className}
|
|
40
|
+
>
|
|
41
|
+
{@render children?.()}
|
|
42
|
+
</span>
|
|
43
|
+
{/if}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type RadioGroupIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
|
|
4
|
+
/** Keeps the indicator in the DOM while the radio is not checked, for exit animations. */
|
|
5
|
+
forceMount?: boolean;
|
|
6
|
+
/** The mark itself. */
|
|
7
|
+
children?: Snippet;
|
|
8
|
+
class?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const RadioGroupIndicator: import("svelte").Component<RadioGroupIndicatorProps, {}, "">;
|
|
11
|
+
type RadioGroupIndicator = ReturnType<typeof RadioGroupIndicator>;
|
|
12
|
+
export default RadioGroupIndicator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type RadioGroupItemState = 'checked' | 'unchecked';
|
|
2
|
+
export type RadioGroupItemContext = {
|
|
3
|
+
id: string;
|
|
4
|
+
inputId: string;
|
|
5
|
+
value: string;
|
|
6
|
+
state: RadioGroupItemState;
|
|
7
|
+
pressed: boolean;
|
|
8
|
+
isChecked: boolean;
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
isReadOnly: boolean;
|
|
11
|
+
required: boolean;
|
|
12
|
+
focused: boolean;
|
|
13
|
+
focusVisible: boolean;
|
|
14
|
+
select: (event?: Event) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function setRadioGroupItemContext(context: RadioGroupItemContext): void;
|
|
17
|
+
export declare function getRadioGroupItemContext(): RadioGroupItemContext | undefined;
|
|
18
|
+
export declare function useRadioGroupItemContext(): RadioGroupItemContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const RADIO_GROUP_ITEM_CONTEXT_KEY = Symbol('radio-group-item');
|
|
3
|
+
export function setRadioGroupItemContext(context) {
|
|
4
|
+
setContext(RADIO_GROUP_ITEM_CONTEXT_KEY, context);
|
|
5
|
+
}
|
|
6
|
+
export function getRadioGroupItemContext() {
|
|
7
|
+
return getContext(RADIO_GROUP_ITEM_CONTEXT_KEY);
|
|
8
|
+
}
|
|
9
|
+
export function useRadioGroupItemContext() {
|
|
10
|
+
const context = getRadioGroupItemContext();
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error('Radio components must be used within RadioGroup.Item.');
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
}
|