@human-kit/ui 1.0.0-beta.5 → 1.0.0-beta.7
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 +19 -17
- package/dist/accordion/README.md +3 -3
- package/dist/accordion/types.d.ts +37 -23
- 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 +2 -2
- 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/button/README.md +1 -1
- package/dist/button/root/button-root.svelte +24 -10
- package/dist/button/root/button-root.svelte.d.ts +15 -10
- 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/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 +118 -40
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +17 -10
- 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/wheel-column/clock-wheel-column.svelte +1 -1
- package/dist/clock/wheel-column/clock-wheel-column.svelte.d.ts +1 -1
- package/dist/collapsible/README.md +3 -3
- package/dist/collapsible/types.d.ts +10 -7
- 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 +3 -3
- 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 +11 -8
- package/dist/combobox/list/combobox-listbox.svelte.d.ts +11 -8
- package/dist/combobox/popover/README.md +1 -1
- package/dist/combobox/root/README.md +24 -24
- package/dist/combobox/root/combobox.svelte +26 -17
- package/dist/combobox/root/combobox.svelte.d.ts +26 -17
- package/dist/combobox/status/README.md +1 -1
- 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 +4 -5
- package/dist/combobox/tag-remove/combobox-tag-remove.svelte.d.ts +4 -5
- package/dist/combobox/tags/README.md +1 -1
- package/dist/combobox/tags/combobox-tags.svelte +11 -11
- package/dist/combobox/tags/combobox-tags.svelte.d.ts +11 -11
- package/dist/combobox/trigger/README.md +7 -7
- package/dist/datepicker/README.md +4 -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 +1 -1
- 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/dialog/README.md +1 -1
- package/dist/dialog/close/dialog-close.svelte +3 -3
- package/dist/dialog/close/dialog-close.svelte.d.ts +3 -3
- package/dist/dialog/content/dialog-content.svelte +4 -4
- package/dist/dialog/content/dialog-content.svelte.d.ts +4 -4
- package/dist/dialog/description/dialog-description.svelte +3 -3
- package/dist/dialog/description/dialog-description.svelte.d.ts +3 -3
- 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/dialog-root.svelte +36 -11
- package/dist/dialog/root/dialog-root.svelte.d.ts +11 -9
- package/dist/dialog/title/dialog-title.svelte +3 -3
- package/dist/dialog/title/dialog-title.svelte.d.ts +3 -3
- package/dist/dialog/trigger/README.md +1 -1
- package/dist/drawer/README.md +3 -3
- package/dist/drawer/body/drawer-body.svelte +2 -2
- package/dist/drawer/body/drawer-body.svelte.d.ts +2 -2
- package/dist/drawer/close/drawer-close.svelte +3 -3
- package/dist/drawer/close/drawer-close.svelte.d.ts +3 -3
- package/dist/drawer/content/drawer-content.svelte +12 -9
- package/dist/drawer/content/drawer-content.svelte.d.ts +12 -9
- package/dist/drawer/description/drawer-description.svelte +3 -3
- package/dist/drawer/description/drawer-description.svelte.d.ts +3 -3
- package/dist/drawer/indent/drawer-indent-background.svelte +1 -1
- package/dist/drawer/indent/drawer-indent-background.svelte.d.ts +1 -1
- package/dist/drawer/indent/drawer-indent.svelte +2 -2
- package/dist/drawer/indent/drawer-indent.svelte.d.ts +2 -2
- package/dist/drawer/overlay/drawer-overlay.svelte +1 -1
- package/dist/drawer/overlay/drawer-overlay.svelte.d.ts +1 -1
- package/dist/drawer/portal/drawer-portal.svelte +1 -1
- package/dist/drawer/portal/drawer-portal.svelte.d.ts +1 -1
- package/dist/drawer/root/context.d.ts +1 -1
- package/dist/drawer/root/drawer-root.svelte +25 -23
- package/dist/drawer/root/drawer-root.svelte.d.ts +25 -23
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte +3 -3
- package/dist/drawer/swipe-area/drawer-swipe-area.svelte.d.ts +3 -3
- package/dist/drawer/title/drawer-title.svelte +3 -3
- package/dist/drawer/title/drawer-title.svelte.d.ts +3 -3
- package/dist/drawer/trigger/drawer-trigger.svelte +6 -6
- package/dist/drawer/trigger/drawer-trigger.svelte.d.ts +6 -6
- package/dist/drawer/viewport/drawer-viewport.svelte +2 -2
- package/dist/drawer/viewport/drawer-viewport.svelte.d.ts +2 -2
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte +1 -1
- package/dist/drawer/virtual-keyboard/drawer-virtual-keyboard-provider.svelte.d.ts +1 -1
- package/dist/dropzone/README.md +4 -6
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/input/input.svelte +6 -6
- package/dist/input/input.svelte.d.ts +6 -6
- package/dist/listbox/README.md +3 -10
- package/dist/listbox/item/listbox-item.svelte +24 -15
- 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 +1 -1
- package/dist/listbox/root/listbox.svelte +50 -38
- package/dist/listbox/root/listbox.svelte.d.ts +50 -38
- package/dist/locale-provider/README.md +1 -6
- package/dist/menu/README.md +6 -15
- package/dist/menu/content/menu-content.svelte +14 -10
- package/dist/menu/content/menu-content.svelte.d.ts +14 -10
- package/dist/menu/context-trigger/menu-context-trigger.svelte +8 -9
- package/dist/menu/context-trigger/menu-context-trigger.svelte.d.ts +8 -9
- 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/item/menu-item.svelte +11 -8
- package/dist/menu/item/menu-item.svelte.d.ts +11 -8
- package/dist/menu/overlay/menu-overlay.svelte +1 -1
- package/dist/menu/overlay/menu-overlay.svelte.d.ts +1 -1
- package/dist/menu/root/context.d.ts +6 -3
- 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/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/scrub-area-cursor/README.md +1 -1
- package/dist/popover/README.md +1 -1
- package/dist/popover/content/popover-content.svelte +19 -14
- package/dist/popover/content/popover-content.svelte.d.ts +19 -14
- package/dist/popover/overlay/popover-overlay.svelte +1 -1
- package/dist/popover/overlay/popover-overlay.svelte.d.ts +1 -1
- package/dist/popover/root/README.md +1 -1
- package/dist/popover/root/popover-root.svelte +13 -10
- package/dist/popover/root/popover-root.svelte.d.ts +13 -10
- package/dist/popover/trigger/README.md +1 -1
- package/dist/primitives/floating.d.ts +3 -3
- 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 +1 -0
- package/dist/primitives/index.js +1 -0
- package/dist/primitives/input-modality.d.ts +7 -0
- package/dist/primitives/input-modality.js +32 -5
- package/dist/primitives/scroll-lock.js +37 -8
- 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/switch/root/README.md +2 -2
- package/dist/switch/root/switch-root.svelte +32 -18
- package/dist/switch/root/switch-root.svelte.d.ts +23 -18
- 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 +15 -10
- package/dist/table/checkbox-indicator/README.md +1 -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/root/README.md +1 -1
- package/dist/table/root/table-root.svelte +29 -6
- package/dist/table/sort-trigger/README.md +1 -1
- package/dist/table/types.d.ts +21 -20
- package/dist/tabs/types.d.ts +6 -6
- 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/trigger/README.md +1 -1
- 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 +8 -10
- 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/types.d.ts +7 -6
- package/dist/transfer-list/README.md +6 -17
- package/dist/transfer-list/item/transfer-list-item.svelte +4 -4
- package/dist/transfer-list/item/transfer-list-item.svelte.d.ts +4 -4
- package/dist/transfer-list/list/transfer-list-list.svelte +12 -12
- package/dist/transfer-list/list/transfer-list-list.svelte.d.ts +12 -12
- package/dist/transfer-list/move/transfer-list-move-button.svelte +4 -4
- package/dist/transfer-list/move/transfer-list-move-button.svelte.d.ts +4 -4
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte +3 -3
- package/dist/transfer-list/move/transfer-list-reorder-button.svelte.d.ts +3 -3
- package/dist/transfer-list/root/transfer-list-root.svelte +23 -20
- package/dist/transfer-list/root/transfer-list-root.svelte.d.ts +23 -20
- package/dist/transfer-list/status/transfer-list-status.svelte +1 -1
- package/dist/transfer-list/status/transfer-list-status.svelte.d.ts +1 -1
- 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/types.d.ts +19 -10
- package/package.json +11 -1
|
@@ -8,33 +8,38 @@ import { type PopoverOpenChangeDetails } from '../root/context';
|
|
|
8
8
|
* Can be used inside Popover.Root (reads context) or standalone (props required).
|
|
9
9
|
*/
|
|
10
10
|
type PopoverContentProps = {
|
|
11
|
-
/**
|
|
11
|
+
/** The distance from the anchor element, on the main axis. */
|
|
12
12
|
offset?: number;
|
|
13
|
-
/**
|
|
13
|
+
/** The position against the anchor element. */
|
|
14
14
|
placement?: ExtendedPlacement;
|
|
15
|
-
/**
|
|
15
|
+
/** Moves the panel to the opposite side when the space is not sufficient. */
|
|
16
16
|
shouldFlip?: boolean;
|
|
17
|
-
/**
|
|
17
|
+
/** The element that gives the limits of the position. */
|
|
18
18
|
boundaryElement?: Element | null;
|
|
19
|
-
/**
|
|
19
|
+
/** The content of the popover. */
|
|
20
20
|
children?: Snippet;
|
|
21
|
-
/** CSS class
|
|
21
|
+
/** The CSS class names of the popover container. */
|
|
22
22
|
class?: string;
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Makes the popover non-modal. The user can then operate the page, the focus does not stay in
|
|
25
|
+
* the panel, and the page scrolls.
|
|
26
|
+
*/
|
|
24
27
|
nonModal?: boolean;
|
|
25
|
-
/**
|
|
28
|
+
/** Closes the popover when the user clicks outside it. */
|
|
26
29
|
shouldCloseOnInteractOutside?: boolean;
|
|
27
|
-
/**
|
|
30
|
+
/** Closes the popover when the user pushes the `Escape` key. */
|
|
28
31
|
shouldCloseOnEscape?: boolean;
|
|
29
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Closes the popover when the focus goes out of it. The default is true for a non-modal popover.
|
|
34
|
+
*/
|
|
30
35
|
shouldCloseOnBlur?: boolean;
|
|
31
|
-
/**
|
|
36
|
+
/** The element, or the selector of the element, that gets the focus first in the modal mode. */
|
|
32
37
|
initialFocus?: FocusTrapOptions['initialFocus'];
|
|
33
|
-
/**
|
|
38
|
+
/** The open state, when you use the part alone. */
|
|
34
39
|
open?: boolean;
|
|
35
|
-
/**
|
|
40
|
+
/** The reference to the trigger element, when you use the part alone. */
|
|
36
41
|
triggerRef?: HTMLElement | null;
|
|
37
|
-
/**
|
|
42
|
+
/** The component calls it when the open state changes, when you use the part alone. */
|
|
38
43
|
onOpenChange?: (open: boolean, details: PopoverOpenChangeDetails) => void;
|
|
39
44
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>;
|
|
40
45
|
declare const PopoverContent: import("svelte").Component<PopoverContentProps, {}, "">;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* keeping it mounted through its exit animation so it fades in step with the panel.
|
|
15
15
|
*/
|
|
16
16
|
type PopoverOverlayProps = {
|
|
17
|
-
/** CSS class
|
|
17
|
+
/** The CSS class names of the overlay. */
|
|
18
18
|
class?: string;
|
|
19
19
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
|
|
20
20
|
|
|
@@ -8,7 +8,7 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
8
8
|
* keeping it mounted through its exit animation so it fades in step with the panel.
|
|
9
9
|
*/
|
|
10
10
|
type PopoverOverlayProps = {
|
|
11
|
-
/** CSS class
|
|
11
|
+
/** The CSS class names of the overlay. */
|
|
12
12
|
class?: string;
|
|
13
13
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'class'>;
|
|
14
14
|
declare const PopoverOverlay: import("svelte").Component<PopoverOverlayProps, {}, "">;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
Name: `Popover.Root`
|
|
8
8
|
Description: Root state container that controls open state, trigger ref, and toggle/open/close actions.
|
|
9
9
|
|
|
10
|
-
- `open`: `boolean` (default: `undefined`) —
|
|
10
|
+
- `open`: `boolean` (default: `undefined`) — The open state. Supports `bind:open`.
|
|
11
11
|
- `defaultOpen`: `boolean` (default: `false`) — Initial open state in uncontrolled mode.
|
|
12
12
|
- `onOpenChange`: `(open: boolean, details) => void` (default: `undefined`) — Called whenever open state changes. `details` includes `reason`, optional `event`, `cancel()`, and `isCanceled`.
|
|
13
13
|
- `triggerRef`: `HTMLElement | null` (default: `null`) — Trigger reference. Supports `bind:triggerRef`.
|
|
@@ -21,23 +21,26 @@
|
|
|
21
21
|
* Provides context for Trigger and Content children.
|
|
22
22
|
*/
|
|
23
23
|
type PopoverRootProps = {
|
|
24
|
-
/**
|
|
24
|
+
/** The open state. By default it goes in the two directions: use `bind:open`. */
|
|
25
25
|
open?: boolean;
|
|
26
|
-
/**
|
|
26
|
+
/** The open state at the start, for when you give no `open`. */
|
|
27
27
|
defaultOpen?: boolean;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* Give your own code full control of the open state. The component stops to write back to
|
|
30
|
+
* `open`, and it reports only through `onOpenChange`. Thus the parent can refuse a change: the
|
|
31
|
+
* parent does not send the new value down. The default is off, because `bind:open` is the usual
|
|
32
|
+
* case and it needs the write-back.
|
|
33
|
+
*
|
|
34
|
+
* To refuse one change, use `details.cancel()`. That function works in the two modes.
|
|
34
35
|
*/
|
|
35
36
|
controlledOpen?: boolean;
|
|
36
|
-
/**
|
|
37
|
+
/** The component calls it when the open state changes. */
|
|
37
38
|
onOpenChange?: (open: boolean, details: PopoverOpenChangeDetails) => void;
|
|
38
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* The reference to the trigger element. Set it in your own code, or let Popover.Trigger set it.
|
|
41
|
+
*/
|
|
39
42
|
triggerRef?: HTMLElement | null;
|
|
40
|
-
/**
|
|
43
|
+
/** The children: the Trigger and the Content. */
|
|
41
44
|
children?: Snippet;
|
|
42
45
|
};
|
|
43
46
|
|
|
@@ -5,23 +5,26 @@ import { type PopoverOpenChangeDetails } from './context';
|
|
|
5
5
|
* Provides context for Trigger and Content children.
|
|
6
6
|
*/
|
|
7
7
|
type PopoverRootProps = {
|
|
8
|
-
/**
|
|
8
|
+
/** The open state. By default it goes in the two directions: use `bind:open`. */
|
|
9
9
|
open?: boolean;
|
|
10
|
-
/**
|
|
10
|
+
/** The open state at the start, for when you give no `open`. */
|
|
11
11
|
defaultOpen?: boolean;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
13
|
+
* Give your own code full control of the open state. The component stops to write back to
|
|
14
|
+
* `open`, and it reports only through `onOpenChange`. Thus the parent can refuse a change: the
|
|
15
|
+
* parent does not send the new value down. The default is off, because `bind:open` is the usual
|
|
16
|
+
* case and it needs the write-back.
|
|
17
|
+
*
|
|
18
|
+
* To refuse one change, use `details.cancel()`. That function works in the two modes.
|
|
18
19
|
*/
|
|
19
20
|
controlledOpen?: boolean;
|
|
20
|
-
/**
|
|
21
|
+
/** The component calls it when the open state changes. */
|
|
21
22
|
onOpenChange?: (open: boolean, details: PopoverOpenChangeDetails) => void;
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* The reference to the trigger element. Set it in your own code, or let Popover.Trigger set it.
|
|
25
|
+
*/
|
|
23
26
|
triggerRef?: HTMLElement | null;
|
|
24
|
-
/**
|
|
27
|
+
/** The children: the Trigger and the Content. */
|
|
25
28
|
children?: Snippet;
|
|
26
29
|
};
|
|
27
30
|
declare const PopoverRoot: import("svelte").Component<PopoverRootProps, {}, "open" | "triggerRef">;
|
|
@@ -9,6 +9,6 @@ Description: Button trigger part that wires itself as the trigger and toggles th
|
|
|
9
9
|
|
|
10
10
|
| Prop | Type | Default | Description |
|
|
11
11
|
| -------------- | ---------------------- | ----------- | -------------------------------------------------------------------------- |
|
|
12
|
-
| `children` | `Snippet` | `undefined` |
|
|
12
|
+
| `children` | `Snippet` | `undefined` | The content of the button. |
|
|
13
13
|
| `class` | `string` | `''` | CSS class names for the button. |
|
|
14
14
|
| `...restProps` | `HTMLButtonAttributes` | `-` | Additional native button attributes, excluding reserved trigger semantics. |
|
|
@@ -42,11 +42,11 @@ export type ExtendedPlacement = Placement | 'bottom left' | 'bottom right' | 'to
|
|
|
42
42
|
export type FloatingOptions = {
|
|
43
43
|
/** Offset along the main axis from the anchor. */
|
|
44
44
|
offset?: number;
|
|
45
|
-
/**
|
|
45
|
+
/** The position against the anchor element. */
|
|
46
46
|
placement?: ExtendedPlacement;
|
|
47
|
-
/**
|
|
47
|
+
/** Moves the panel to the opposite side when the space is not sufficient. */
|
|
48
48
|
shouldFlip?: boolean;
|
|
49
|
-
/**
|
|
49
|
+
/** The element that gives the limits of the position. */
|
|
50
50
|
boundaryElement?: Element | null;
|
|
51
51
|
/**
|
|
52
52
|
* Minimum gap kept between the floating element and the boundary edges, in
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keeps a `focusVisible` value honest while the element holds focus.
|
|
3
|
+
*
|
|
4
|
+
* `shouldShowFocusVisible` reads the modality at the moment it is called, so a component that
|
|
5
|
+
* only calls it from its focus handler holds a snapshot. A pointer press seeds `false`, and a
|
|
6
|
+
* key press after it flips the modality — and the `:focus-visible` of the browser — with nothing
|
|
7
|
+
* to tell the component. This subscribes for as long as the element has focus, and it re-reads
|
|
8
|
+
* on each change, which is what React Aria and Base UI do.
|
|
9
|
+
*/
|
|
10
|
+
export declare function watchFocusVisible(options: {
|
|
11
|
+
isFocused: () => boolean;
|
|
12
|
+
element: () => HTMLElement | null;
|
|
13
|
+
set: (focusVisible: boolean) => void;
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { shouldShowFocusVisible, subscribeInputModality } from './input-modality.js';
|
|
2
|
+
/**
|
|
3
|
+
* Keeps a `focusVisible` value honest while the element holds focus.
|
|
4
|
+
*
|
|
5
|
+
* `shouldShowFocusVisible` reads the modality at the moment it is called, so a component that
|
|
6
|
+
* only calls it from its focus handler holds a snapshot. A pointer press seeds `false`, and a
|
|
7
|
+
* key press after it flips the modality — and the `:focus-visible` of the browser — with nothing
|
|
8
|
+
* to tell the component. This subscribes for as long as the element has focus, and it re-reads
|
|
9
|
+
* on each change, which is what React Aria and Base UI do.
|
|
10
|
+
*/
|
|
11
|
+
export function watchFocusVisible(options) {
|
|
12
|
+
$effect(() => {
|
|
13
|
+
if (!options.isFocused())
|
|
14
|
+
return;
|
|
15
|
+
return subscribeInputModality(() => {
|
|
16
|
+
options.set(shouldShowFocusVisible(options.element()));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -6,5 +6,6 @@ export * from './scroll-lock.js';
|
|
|
6
6
|
export * from './aria-hide-outside.js';
|
|
7
7
|
export * from './click-outside.js';
|
|
8
8
|
export * from './input-modality.js';
|
|
9
|
+
export * from './focus-visible.svelte.js';
|
|
9
10
|
export * from './long-press.js';
|
|
10
11
|
export * from './swipe-gesture.js';
|
package/dist/primitives/index.js
CHANGED
|
@@ -7,5 +7,6 @@ export * from './scroll-lock.js';
|
|
|
7
7
|
export * from './aria-hide-outside.js';
|
|
8
8
|
export * from './click-outside.js';
|
|
9
9
|
export * from './input-modality.js';
|
|
10
|
+
export * from './focus-visible.svelte.js';
|
|
10
11
|
export * from './long-press.js';
|
|
11
12
|
export * from './swipe-gesture.js';
|
|
@@ -2,6 +2,13 @@ export type InputModality = 'keyboard' | 'pointer' | 'virtual';
|
|
|
2
2
|
export declare function initInputModality(target?: HTMLElement | null): void;
|
|
3
3
|
export declare function trackInteractionModality(event?: Event, target?: HTMLElement | null): void;
|
|
4
4
|
export declare function getInteractionModality(): InputModality;
|
|
5
|
+
/**
|
|
6
|
+
* Calls `listener` whenever the interaction modality changes, and returns the unsubscribe
|
|
7
|
+
* function. Components use it to re-read `shouldShowFocusVisible` for an element that already
|
|
8
|
+
* holds focus: the browser re-evaluates `:focus-visible` on its own, and this is what lets a
|
|
9
|
+
* component notice.
|
|
10
|
+
*/
|
|
11
|
+
export declare function subscribeInputModality(listener: (modality: InputModality) => void): () => void;
|
|
5
12
|
export declare function shouldShowFocusVisible(target: HTMLElement | null): boolean;
|
|
6
13
|
export declare function focusWithModality(target: HTMLElement, modality: InputModality, options?: FocusOptions): void;
|
|
7
14
|
export declare function resolveCloseInteractionModality(reason: string, event?: Event): InputModality;
|
|
@@ -8,6 +8,20 @@ let currentModality = 'virtual';
|
|
|
8
8
|
const RECENT_INPUT_WINDOW_MS = 50;
|
|
9
9
|
let lastInputEventTime = Number.NEGATIVE_INFINITY;
|
|
10
10
|
const listenedWindows = new WeakSet();
|
|
11
|
+
/**
|
|
12
|
+
* Notified whenever the modality changes. `data-focus-visible` is otherwise a snapshot taken
|
|
13
|
+
* when the element took focus, so a pointer press followed by a key press left the ring off
|
|
14
|
+
* while the browser had already flipped `:focus-visible` back on.
|
|
15
|
+
*/
|
|
16
|
+
const modalityListeners = new Set();
|
|
17
|
+
function setModality(next) {
|
|
18
|
+
if (currentModality === next)
|
|
19
|
+
return;
|
|
20
|
+
currentModality = next;
|
|
21
|
+
for (const listener of [...modalityListeners]) {
|
|
22
|
+
listener(next);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
11
25
|
let forcedFocusTarget = null;
|
|
12
26
|
let forcedFocusModality = null;
|
|
13
27
|
function isModifierOnlyKey(event) {
|
|
@@ -29,11 +43,11 @@ function ensureWindowListeners(win) {
|
|
|
29
43
|
lastInputEventTime = Date.now();
|
|
30
44
|
if (!isKeyboardModalityKey(event))
|
|
31
45
|
return;
|
|
32
|
-
|
|
46
|
+
setModality('keyboard');
|
|
33
47
|
};
|
|
34
48
|
const onPointerDown = () => {
|
|
35
49
|
lastInputEventTime = Date.now();
|
|
36
|
-
|
|
50
|
+
setModality('pointer');
|
|
37
51
|
};
|
|
38
52
|
const onFocusIn = (event) => {
|
|
39
53
|
// A programmatic focus with an explicit modality (`focusWithModality`) must keep it —
|
|
@@ -45,7 +59,7 @@ function ensureWindowListeners(win) {
|
|
|
45
59
|
return;
|
|
46
60
|
// No recent keyboard/pointer input: this focus move came from an assistive technology
|
|
47
61
|
// (or a script), so focus rings must show again.
|
|
48
|
-
|
|
62
|
+
setModality('virtual');
|
|
49
63
|
};
|
|
50
64
|
win.addEventListener('keydown', onKeyDown, true);
|
|
51
65
|
win.addEventListener('pointerdown', onPointerDown, true);
|
|
@@ -90,12 +104,25 @@ export function trackInteractionModality(event, target) {
|
|
|
90
104
|
initInputModality(target);
|
|
91
105
|
const inferred = inferModalityFromEvent(event);
|
|
92
106
|
if (inferred) {
|
|
93
|
-
|
|
107
|
+
setModality(inferred);
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
110
|
export function getInteractionModality() {
|
|
97
111
|
return currentModality;
|
|
98
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Calls `listener` whenever the interaction modality changes, and returns the unsubscribe
|
|
115
|
+
* function. Components use it to re-read `shouldShowFocusVisible` for an element that already
|
|
116
|
+
* holds focus: the browser re-evaluates `:focus-visible` on its own, and this is what lets a
|
|
117
|
+
* component notice.
|
|
118
|
+
*/
|
|
119
|
+
export function subscribeInputModality(listener) {
|
|
120
|
+
initInputModality();
|
|
121
|
+
modalityListeners.add(listener);
|
|
122
|
+
return () => {
|
|
123
|
+
modalityListeners.delete(listener);
|
|
124
|
+
};
|
|
125
|
+
}
|
|
99
126
|
export function shouldShowFocusVisible(target) {
|
|
100
127
|
if (!target)
|
|
101
128
|
return false;
|
|
@@ -111,7 +138,7 @@ export function focusWithModality(target, modality, options) {
|
|
|
111
138
|
// If it is consumed later, currentModality still preserves the same modality as fallback.
|
|
112
139
|
forcedFocusTarget = target;
|
|
113
140
|
forcedFocusModality = modality;
|
|
114
|
-
|
|
141
|
+
setModality(modality);
|
|
115
142
|
if (modality === 'pointer') {
|
|
116
143
|
const pointerFocusOptions = {
|
|
117
144
|
...(options ?? {}),
|
|
@@ -31,9 +31,27 @@ let originalRight = '';
|
|
|
31
31
|
let savedScrollX = 0;
|
|
32
32
|
let savedScrollY = 0;
|
|
33
33
|
// The overlay nodes whose inner scroll regions stay live while the background is
|
|
34
|
-
// frozen
|
|
35
|
-
//
|
|
36
|
-
|
|
34
|
+
// frozen, each with the number of registrations holding it there. The handlers
|
|
35
|
+
// need this list (rather than just the lock count) to tell an overlay-targeted
|
|
36
|
+
// scroll from a background one.
|
|
37
|
+
//
|
|
38
|
+
// Counted, not a plain Set, because one node can be registered twice: a modal
|
|
39
|
+
// `Popover.Content` carries `scrollLock` AND `allowScrollWithin`, and the second
|
|
40
|
+
// action's "off" state used to delete the entry the first one had just added —
|
|
41
|
+
// leaving the lock on with no live scroll region, so every wheel inside the
|
|
42
|
+
// panel was cancelled as if it were the background.
|
|
43
|
+
const overlayNodes = new Map();
|
|
44
|
+
function retainOverlay(node) {
|
|
45
|
+
overlayNodes.set(node, (overlayNodes.get(node) ?? 0) + 1);
|
|
46
|
+
}
|
|
47
|
+
function releaseOverlay(node) {
|
|
48
|
+
const remaining = (overlayNodes.get(node) ?? 0) - 1;
|
|
49
|
+
if (remaining > 0) {
|
|
50
|
+
overlayNodes.set(node, remaining);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
overlayNodes.delete(node);
|
|
54
|
+
}
|
|
37
55
|
function getScrollbarWidth() {
|
|
38
56
|
return window.innerWidth - document.documentElement.clientWidth;
|
|
39
57
|
}
|
|
@@ -51,7 +69,7 @@ function reservesStableGutter() {
|
|
|
51
69
|
function overlayContaining(target) {
|
|
52
70
|
if (!(target instanceof Node))
|
|
53
71
|
return null;
|
|
54
|
-
for (const node of overlayNodes) {
|
|
72
|
+
for (const node of overlayNodes.keys()) {
|
|
55
73
|
if (node.contains(target))
|
|
56
74
|
return node;
|
|
57
75
|
}
|
|
@@ -79,6 +97,10 @@ function scrollableWithin(target, root) {
|
|
|
79
97
|
function onWheel(event) {
|
|
80
98
|
if (!event.cancelable)
|
|
81
99
|
return;
|
|
100
|
+
// A wheel with Ctrl held is the browser's zoom gesture, not a scroll. Cancelling
|
|
101
|
+
// it took page zoom away from the user for as long as any overlay was open.
|
|
102
|
+
if (event.ctrlKey)
|
|
103
|
+
return;
|
|
82
104
|
const overlay = overlayContaining(event.target);
|
|
83
105
|
if (!overlay) {
|
|
84
106
|
// Background scroll — freeze it.
|
|
@@ -133,7 +155,7 @@ function removeEventBlockers() {
|
|
|
133
155
|
document.removeEventListener('touchmove', onTouchMove, { capture: true });
|
|
134
156
|
}
|
|
135
157
|
function lock(node) {
|
|
136
|
-
|
|
158
|
+
retainOverlay(node);
|
|
137
159
|
if (lockCount === 0) {
|
|
138
160
|
const body = document.body;
|
|
139
161
|
originalOverflow = body.style.overflow;
|
|
@@ -162,7 +184,7 @@ function lock(node) {
|
|
|
162
184
|
lockCount++;
|
|
163
185
|
}
|
|
164
186
|
function unlock(node) {
|
|
165
|
-
|
|
187
|
+
releaseOverlay(node);
|
|
166
188
|
lockCount--;
|
|
167
189
|
if (lockCount === 0) {
|
|
168
190
|
const body = document.body;
|
|
@@ -232,12 +254,19 @@ export function scrollLock(node, enabled = true) {
|
|
|
232
254
|
* ```
|
|
233
255
|
*/
|
|
234
256
|
export function allowScrollWithin(node, enabled = true) {
|
|
257
|
+
// Only ever releases what it took. Registering is counted, so an action that
|
|
258
|
+
// is off must not release a registration it never made — on a modal popover
|
|
259
|
+
// that entry belongs to `scrollLock`, on the very same node.
|
|
260
|
+
let registered = false;
|
|
235
261
|
const register = (on) => {
|
|
262
|
+
if (on === registered)
|
|
263
|
+
return;
|
|
264
|
+
registered = on;
|
|
236
265
|
if (on) {
|
|
237
|
-
|
|
266
|
+
retainOverlay(node);
|
|
238
267
|
}
|
|
239
268
|
else {
|
|
240
|
-
|
|
269
|
+
releaseOverlay(node);
|
|
241
270
|
}
|
|
242
271
|
};
|
|
243
272
|
register(enabled);
|
|
@@ -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;
|