@human-kit/ui 1.0.0-beta.4 → 1.0.0-beta.6
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-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 +15 -10
- package/dist/button/root/button-root.svelte.d.ts +15 -10
- package/dist/calendar/README.md +3 -3
- 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/root/README.md +2 -2
- package/dist/checkbox/root/checkbox-root.svelte +12 -10
- package/dist/checkbox/root/checkbox-root.svelte.d.ts +12 -10
- 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/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/scroll-lock.js +37 -8
- package/dist/switch/root/README.md +2 -2
- package/dist/switch/root/switch-root.svelte +23 -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-resizer/README.md +2 -2
- package/dist/table/root/README.md +1 -1
- 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 +58 -5
- package/dist/timepicker/input/time-picker-input.svelte.d.ts +10 -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-group/README.md +6 -0
- package/dist/toggle-group/root/context.svelte.d.ts +1 -1
- package/dist/toggle-group/root/context.svelte.js +20 -11
- package/dist/toggle-group/root/toggle-group-root.svelte +20 -15
- 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 -9
- 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 +1 -1
|
@@ -9,21 +9,27 @@
|
|
|
9
9
|
* Provides context for Trigger and Content children.
|
|
10
10
|
*/
|
|
11
11
|
type MenuRootProps = {
|
|
12
|
-
/**
|
|
12
|
+
/** The open state. */
|
|
13
13
|
open?: boolean;
|
|
14
|
-
/**
|
|
14
|
+
/** The open state at the start, for when the component controls the state. */
|
|
15
15
|
defaultOpen?: boolean;
|
|
16
|
-
/**
|
|
16
|
+
/** The component calls it when the open state changes. */
|
|
17
17
|
onOpenChange?: (open: boolean, details: MenuOpenChangeDetails) => void;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* At the last item, the arrow keys move the focus to the first item, and at the first item, to
|
|
20
|
+
* the last one.
|
|
21
|
+
*/
|
|
19
22
|
loop?: boolean;
|
|
20
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Starts the typeahead. When the user types, the focus moves to an item that agrees with the
|
|
25
|
+
* text.
|
|
26
|
+
*/
|
|
21
27
|
typeahead?: boolean;
|
|
22
|
-
/**
|
|
28
|
+
/** Closes the menu when the user selects an item. An item can replace this value. */
|
|
23
29
|
closeOnSelect?: boolean;
|
|
24
|
-
/**
|
|
30
|
+
/** The reference to the trigger element. Set it in your own code, or let Menu.Trigger set it. */
|
|
25
31
|
triggerRef?: HTMLElement | null;
|
|
26
|
-
/**
|
|
32
|
+
/** The children: the Trigger and the Content. */
|
|
27
33
|
children?: Snippet;
|
|
28
34
|
};
|
|
29
35
|
|
|
@@ -5,21 +5,27 @@ import { type MenuOpenChangeDetails } from './context';
|
|
|
5
5
|
* Provides context for Trigger and Content children.
|
|
6
6
|
*/
|
|
7
7
|
type MenuRootProps = {
|
|
8
|
-
/**
|
|
8
|
+
/** The open state. */
|
|
9
9
|
open?: boolean;
|
|
10
|
-
/**
|
|
10
|
+
/** The open state at the start, for when the component controls the state. */
|
|
11
11
|
defaultOpen?: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/** The component calls it when the open state changes. */
|
|
13
13
|
onOpenChange?: (open: boolean, details: MenuOpenChangeDetails) => void;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* At the last item, the arrow keys move the focus to the first item, and at the first item, to
|
|
16
|
+
* the last one.
|
|
17
|
+
*/
|
|
15
18
|
loop?: boolean;
|
|
16
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Starts the typeahead. When the user types, the focus moves to an item that agrees with the
|
|
21
|
+
* text.
|
|
22
|
+
*/
|
|
17
23
|
typeahead?: boolean;
|
|
18
|
-
/**
|
|
24
|
+
/** Closes the menu when the user selects an item. An item can replace this value. */
|
|
19
25
|
closeOnSelect?: boolean;
|
|
20
|
-
/**
|
|
26
|
+
/** The reference to the trigger element. Set it in your own code, or let Menu.Trigger set it. */
|
|
21
27
|
triggerRef?: HTMLElement | null;
|
|
22
|
-
/**
|
|
28
|
+
/** The children: the Trigger and the Content. */
|
|
23
29
|
children?: Snippet;
|
|
24
30
|
};
|
|
25
31
|
declare const MenuRoot: import("svelte").Component<MenuRootProps, {}, "open" | "triggerRef">;
|
|
@@ -4,7 +4,7 @@ export type CreateMenuStateOptions = {
|
|
|
4
4
|
getOpen: () => boolean | undefined;
|
|
5
5
|
/** Writes the open value back to the bindable prop. */
|
|
6
6
|
setOpen: (value: boolean) => void;
|
|
7
|
-
/**
|
|
7
|
+
/** The open state at the start, for when the component controls the state. */
|
|
8
8
|
defaultOpen: boolean;
|
|
9
9
|
/** Reads the current open-change callback. */
|
|
10
10
|
getOnOpenChange?: () => ((open: boolean, details: MenuOpenChangeDetails) => void) | undefined;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Menu.Separator - A visual divider between menu items (role="separator").
|
|
6
6
|
*/
|
|
7
7
|
type MenuSeparatorProps = {
|
|
8
|
-
/**
|
|
8
|
+
/** The orientation of the separator. */
|
|
9
9
|
orientation?: 'horizontal' | 'vertical';
|
|
10
10
|
class?: string;
|
|
11
11
|
element?: HTMLElement | null;
|
|
@@ -3,7 +3,7 @@ import type { HTMLAttributes } from 'svelte/elements';
|
|
|
3
3
|
* Menu.Separator - A visual divider between menu items (role="separator").
|
|
4
4
|
*/
|
|
5
5
|
type MenuSeparatorProps = {
|
|
6
|
-
/**
|
|
6
|
+
/** The orientation of the separator. */
|
|
7
7
|
orientation?: 'horizontal' | 'vertical';
|
|
8
8
|
class?: string;
|
|
9
9
|
element?: HTMLElement | null;
|
|
@@ -9,19 +9,22 @@
|
|
|
9
9
|
* Must be used inside a parent Menu.Content.
|
|
10
10
|
*/
|
|
11
11
|
type MenuSubmenuRootProps = {
|
|
12
|
-
/**
|
|
12
|
+
/** The open state. */
|
|
13
13
|
open?: boolean;
|
|
14
|
-
/**
|
|
14
|
+
/** The open state at the start, for when the component controls the state. */
|
|
15
15
|
defaultOpen?: boolean;
|
|
16
|
-
/**
|
|
16
|
+
/** The component calls it when the open state changes. */
|
|
17
17
|
onOpenChange?: (open: boolean, details: MenuOpenChangeDetails) => void;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* At the last item, the arrow keys move the focus to the first item. The default comes from the
|
|
20
|
+
* menu above it.
|
|
21
|
+
*/
|
|
19
22
|
loop?: boolean;
|
|
20
|
-
/**
|
|
23
|
+
/** Starts the typeahead. The default comes from the menu above it. */
|
|
21
24
|
typeahead?: boolean;
|
|
22
|
-
/**
|
|
25
|
+
/** Closes the menu when the user selects an item. The default comes from the menu above it. */
|
|
23
26
|
closeOnSelect?: boolean;
|
|
24
|
-
/**
|
|
27
|
+
/** The reference to the submenu trigger element. */
|
|
25
28
|
triggerRef?: HTMLElement | null;
|
|
26
29
|
children?: Snippet;
|
|
27
30
|
};
|
|
@@ -5,19 +5,22 @@ import { type MenuOpenChangeDetails } from '../root/context';
|
|
|
5
5
|
* Must be used inside a parent Menu.Content.
|
|
6
6
|
*/
|
|
7
7
|
type MenuSubmenuRootProps = {
|
|
8
|
-
/**
|
|
8
|
+
/** The open state. */
|
|
9
9
|
open?: boolean;
|
|
10
|
-
/**
|
|
10
|
+
/** The open state at the start, for when the component controls the state. */
|
|
11
11
|
defaultOpen?: boolean;
|
|
12
|
-
/**
|
|
12
|
+
/** The component calls it when the open state changes. */
|
|
13
13
|
onOpenChange?: (open: boolean, details: MenuOpenChangeDetails) => void;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* At the last item, the arrow keys move the focus to the first item. The default comes from the
|
|
16
|
+
* menu above it.
|
|
17
|
+
*/
|
|
15
18
|
loop?: boolean;
|
|
16
|
-
/**
|
|
19
|
+
/** Starts the typeahead. The default comes from the menu above it. */
|
|
17
20
|
typeahead?: boolean;
|
|
18
|
-
/**
|
|
21
|
+
/** Closes the menu when the user selects an item. The default comes from the menu above it. */
|
|
19
22
|
closeOnSelect?: boolean;
|
|
20
|
-
/**
|
|
23
|
+
/** The reference to the submenu trigger element. */
|
|
21
24
|
triggerRef?: HTMLElement | null;
|
|
22
25
|
children?: Snippet;
|
|
23
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NumberField.Root
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Holds the numeric value, the text in the input, the locale, the steps, and the validation state. It gives the shared context to each NumberField part.
|
|
4
4
|
|
|
5
5
|
Use `bind:value` for two-way state. When `name` is provided, Root renders a hidden form input containing the raw numeric value.
|
|
6
6
|
|
|
@@ -4,4 +4,4 @@ Decorative cursor content displayed by consumers while scrubbing.
|
|
|
4
4
|
|
|
5
5
|
It renders `aria-hidden="true"` and mirrors NumberField state through `data-*` attributes.
|
|
6
6
|
|
|
7
|
-
It is
|
|
7
|
+
It is only a visual element. It does not use pointer lock, it is not a virtual cursor, and it does not move the native pointer. Write its styles and its position yourself, usually with `data-scrubbing`, when you want a cursor during the drag.
|
package/dist/popover/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
- `onOpenChange(open, details)`
|
|
19
19
|
- `details.reason`: `trigger-press | imperative-action | none | escape-key | outside-press | focus-out | close-press`
|
|
20
20
|
- `details.event?`: native event that triggered the change when available
|
|
21
|
-
- `details.cancel()`:
|
|
21
|
+
- `details.cancel()`: stops the change of the open state
|
|
22
22
|
- `details.isCanceled`: reflects cancellation state inside the callback
|
|
23
23
|
|
|
24
24
|
## Anatomy
|
|
@@ -29,34 +29,39 @@
|
|
|
29
29
|
* Can be used inside Popover.Root (reads context) or standalone (props required).
|
|
30
30
|
*/
|
|
31
31
|
type PopoverContentProps = {
|
|
32
|
-
/**
|
|
32
|
+
/** The distance from the anchor element, on the main axis. */
|
|
33
33
|
offset?: number;
|
|
34
|
-
/**
|
|
34
|
+
/** The position against the anchor element. */
|
|
35
35
|
placement?: ExtendedPlacement;
|
|
36
|
-
/**
|
|
36
|
+
/** Moves the panel to the opposite side when the space is not sufficient. */
|
|
37
37
|
shouldFlip?: boolean;
|
|
38
|
-
/**
|
|
38
|
+
/** The element that gives the limits of the position. */
|
|
39
39
|
boundaryElement?: Element | null;
|
|
40
|
-
/**
|
|
40
|
+
/** The content of the popover. */
|
|
41
41
|
children?: Snippet;
|
|
42
|
-
/** CSS class
|
|
42
|
+
/** The CSS class names of the popover container. */
|
|
43
43
|
class?: string;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Makes the popover non-modal. The user can then operate the page, the focus does not stay in
|
|
46
|
+
* the panel, and the page scrolls.
|
|
47
|
+
*/
|
|
45
48
|
nonModal?: boolean;
|
|
46
|
-
/**
|
|
49
|
+
/** Closes the popover when the user clicks outside it. */
|
|
47
50
|
shouldCloseOnInteractOutside?: boolean;
|
|
48
|
-
/**
|
|
51
|
+
/** Closes the popover when the user pushes the `Escape` key. */
|
|
49
52
|
shouldCloseOnEscape?: boolean;
|
|
50
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Closes the popover when the focus goes out of it. The default is true for a non-modal popover.
|
|
55
|
+
*/
|
|
51
56
|
shouldCloseOnBlur?: boolean;
|
|
52
|
-
/**
|
|
57
|
+
/** The element, or the selector of the element, that gets the focus first in the modal mode. */
|
|
53
58
|
initialFocus?: FocusTrapOptions['initialFocus'];
|
|
54
59
|
// Standalone mode props (used when not inside Popover.Root)
|
|
55
|
-
/**
|
|
60
|
+
/** The open state, when you use the part alone. */
|
|
56
61
|
open?: boolean;
|
|
57
|
-
/**
|
|
62
|
+
/** The reference to the trigger element, when you use the part alone. */
|
|
58
63
|
triggerRef?: HTMLElement | null;
|
|
59
|
-
/**
|
|
64
|
+
/** The component calls it when the open state changes, when you use the part alone. */
|
|
60
65
|
onOpenChange?: (open: boolean, details: PopoverOpenChangeDetails) => void;
|
|
61
66
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'children'>;
|
|
62
67
|
|
|
@@ -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
|
|
@@ -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);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
### Switch.Root
|
|
6
6
|
|
|
7
7
|
Name: `Switch.Root`
|
|
8
|
-
Description:
|
|
8
|
+
Description: The root of a boolean switch. It holds the checked state and the focus, and it keeps the hidden input correct.
|
|
9
9
|
|
|
10
10
|
| Prop | Type | Default | Description |
|
|
11
11
|
| ----------------- | --------------------------------- | ------------- | ---------------------------------------------------------- |
|
|
@@ -20,7 +20,7 @@ Description: Interactive boolean switch root that owns checked, focus, and hidde
|
|
|
20
20
|
| `readonly` | `boolean` | `false` | Allows focus but blocks user-driven state changes. |
|
|
21
21
|
| `required` | `boolean` | `false` | Marks the hidden input as required and exposes data state. |
|
|
22
22
|
| `children` | `Snippet` | `undefined` | Composed switch parts such as `Switch.Thumb`. |
|
|
23
|
-
| `class` | `string` | `''` | CSS class names
|
|
23
|
+
| `class` | `string` | `''` | The CSS class names of the root element. |
|
|
24
24
|
| `...restProps` | `HTMLAttributes<HTMLSpanElement>` | `-` | Additional attributes forwarded to the switch root span. |
|
|
25
25
|
|
|
26
26
|
### Context utilities
|
|
@@ -21,42 +21,47 @@
|
|
|
21
21
|
| 'onkeydown'
|
|
22
22
|
| 'value'
|
|
23
23
|
> & {
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* The id of the hidden input, thus a `label[for]` element can point at the switch. If you give
|
|
26
|
+
* none, the component makes one.
|
|
27
|
+
*/
|
|
25
28
|
id?: string;
|
|
26
|
-
/**
|
|
29
|
+
/** A bindable reference to the root element. */
|
|
27
30
|
element?: HTMLSpanElement | null;
|
|
28
|
-
/**
|
|
31
|
+
/** The name that the form submits while the switch is on. */
|
|
29
32
|
name?: string;
|
|
30
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The value that the form submits while the switch is on. It does not change the visual state.
|
|
35
|
+
*/
|
|
31
36
|
value?: string;
|
|
32
|
-
/**
|
|
37
|
+
/** The id of the form of the hidden input. */
|
|
33
38
|
form?: string;
|
|
34
|
-
/**
|
|
39
|
+
/** The checked state. By default it goes in the two directions: use `bind:checked`. */
|
|
35
40
|
checked?: boolean;
|
|
36
|
-
/**
|
|
41
|
+
/** The checked state at the start, for when you give no `checked`. */
|
|
37
42
|
defaultChecked?: boolean;
|
|
38
43
|
/**
|
|
39
|
-
*
|
|
40
|
-
* and
|
|
41
|
-
* not
|
|
42
|
-
*
|
|
44
|
+
* Give your own code full control of the state. The component stops to write back to `checked`,
|
|
45
|
+
* and it reports only through `onCheckedChange`. Thus the parent can refuse a change: the parent
|
|
46
|
+
* does not send the new value down. The default is off, because `bind:checked` is the usual case
|
|
47
|
+
* and it needs the write-back.
|
|
43
48
|
*/
|
|
44
49
|
controlledChecked?: boolean;
|
|
45
|
-
/**
|
|
50
|
+
/** The component calls it when the user changes the switch. */
|
|
46
51
|
onCheckedChange?: (checked: boolean) => void;
|
|
47
|
-
/**
|
|
52
|
+
/** Stops the interaction with the switch and removes it from the focus order. */
|
|
48
53
|
disabled?: boolean;
|
|
49
|
-
/** Keeps the switch focusable
|
|
54
|
+
/** Keeps the switch focusable, but stops the changes of the state. */
|
|
50
55
|
readonly?: boolean;
|
|
51
|
-
/**
|
|
56
|
+
/** Makes the hidden input required for the form validation. */
|
|
52
57
|
required?: boolean;
|
|
53
58
|
children?: Snippet;
|
|
54
59
|
class?: string;
|
|
55
|
-
/**
|
|
60
|
+
/** The accessible name, for when the user sees no name. */
|
|
56
61
|
'aria-label'?: string;
|
|
57
|
-
/**
|
|
62
|
+
/** The id of the element that gives the switch its name. */
|
|
58
63
|
'aria-labelledby'?: string;
|
|
59
|
-
/**
|
|
64
|
+
/** Replaces the default position in the tab order. */
|
|
60
65
|
tabindex?: number;
|
|
61
66
|
onclick?: HTMLAttributes<HTMLSpanElement>['onclick'];
|
|
62
67
|
onkeydown?: HTMLAttributes<HTMLSpanElement>['onkeydown'];
|