@human-kit/ui 1.0.0-beta.7 → 1.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FOCUS_STATE_CONTRACT.md +15 -4
- package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
- 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/combobox/popover/combobox-popover.svelte +4 -56
- package/dist/dialog/root/dialog-root.svelte +15 -2
- package/dist/drawer/root/drawer-root.svelte +15 -2
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/internal/localized-strings.d.ts +72 -0
- package/dist/internal/localized-strings.js +72 -0
- package/dist/internal/number-precision.d.ts +9 -0
- package/dist/internal/number-precision.js +27 -0
- package/dist/menu/root/focus-state.d.ts +2 -2
- package/dist/menu/root/focus-state.js +8 -32
- package/dist/menu/root/menu-state.svelte.js +5 -1
- package/dist/numberfield/root/number-utils.js +1 -20
- package/dist/popover/root/focus-state.d.ts +2 -2
- package/dist/popover/root/focus-state.js +7 -34
- 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 +6 -0
- package/dist/primitives/floating.js +26 -5
- package/dist/primitives/focus-trap.d.ts +2 -0
- package/dist/primitives/focus-trap.js +7 -1
- package/dist/primitives/keyboard-navigation.d.ts +6 -0
- package/dist/primitives/keyboard-navigation.js +2 -1
- package/dist/primitives/presence.svelte.js +6 -1
- 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/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/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/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 +454 -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/package.json +41 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAnchorAttributes, HTMLAttributes, HTMLButtonAttributes, HTMLOlAttributes } from 'svelte/elements';
|
|
3
|
+
export type { BreadcrumbsContext } from './root/context.js';
|
|
4
|
+
export type BreadcrumbsRootProps = Omit<HTMLAttributes<HTMLElement>, 'children' | 'class'> & {
|
|
5
|
+
/** `Breadcrumbs.List`. */
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
/** The CSS class names of the element. */
|
|
8
|
+
class?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The name of the landmark. Without it, the name is "Breadcrumb" in the locale of
|
|
11
|
+
* `LocaleProvider`. Give one when the page has two sets of breadcrumbs.
|
|
12
|
+
*/
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The count of items past which the middle of the trail folds behind a `Breadcrumbs.Ellipsis`.
|
|
16
|
+
* The first item and the last `maxItems - 1` stay in view. Without it, every item is in view.
|
|
17
|
+
*/
|
|
18
|
+
maxItems?: number;
|
|
19
|
+
/** True once the user unfolds the trail. Use `bind:expanded` to read it, or to fold it again. */
|
|
20
|
+
expanded?: boolean;
|
|
21
|
+
/** Called when the trail unfolds or folds. */
|
|
22
|
+
onExpandedChange?: (expanded: boolean) => void;
|
|
23
|
+
/** The `<nav>` element. Use `bind:element` to read it. */
|
|
24
|
+
element?: HTMLElement | null;
|
|
25
|
+
};
|
|
26
|
+
export type BreadcrumbsListProps = Omit<HTMLOlAttributes, 'children' | 'class' | 'role'> & {
|
|
27
|
+
/** The items. */
|
|
28
|
+
children?: Snippet;
|
|
29
|
+
/** The CSS class names of the element. */
|
|
30
|
+
class?: string;
|
|
31
|
+
/** The `<ol>` element. Use `bind:element` to read it. */
|
|
32
|
+
element?: HTMLOListElement | null;
|
|
33
|
+
};
|
|
34
|
+
export type BreadcrumbsItemProps = Omit<HTMLAttributes<HTMLLIElement>, 'children' | 'class'> & {
|
|
35
|
+
/** `Breadcrumbs.Link`, and a `Breadcrumbs.Separator` after it. */
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
/** The CSS class names of the element. */
|
|
38
|
+
class?: string;
|
|
39
|
+
/** The `<li>` element. Use `bind:element` to read it. */
|
|
40
|
+
element?: HTMLLIElement | null;
|
|
41
|
+
};
|
|
42
|
+
export type BreadcrumbsLinkProps = Omit<HTMLAnchorAttributes, 'children' | 'class' | 'href' | 'aria-current' | 'aria-disabled'> & {
|
|
43
|
+
/** The text of the link. */
|
|
44
|
+
children?: Snippet;
|
|
45
|
+
/** The CSS class names of the element. */
|
|
46
|
+
class?: string;
|
|
47
|
+
/** The address of the page. Without it, the link is plain text. */
|
|
48
|
+
href?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Marks the page the user is on. The link gets `aria-current="page"`. Set it on the last
|
|
51
|
+
* item: a screen reader user then knows where the trail ends.
|
|
52
|
+
*/
|
|
53
|
+
current?: boolean;
|
|
54
|
+
/** Takes the link out of use: it keeps its text, and it loses its `href` and its tab stop. */
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
/** The `<a>` element, or the `<span>` without an `href`. Use `bind:element` to read it. */
|
|
57
|
+
element?: HTMLAnchorElement | HTMLSpanElement | null;
|
|
58
|
+
};
|
|
59
|
+
export type BreadcrumbsEllipsisProps = Omit<HTMLButtonAttributes, 'children' | 'class' | 'type' | 'aria-label'> & {
|
|
60
|
+
/** The content of the button. Three dots without children. */
|
|
61
|
+
children?: Snippet;
|
|
62
|
+
/** The CSS class names of the button. */
|
|
63
|
+
class?: string;
|
|
64
|
+
/** The CSS class names of the `<li>` around the button. */
|
|
65
|
+
itemClass?: string;
|
|
66
|
+
/** The sign after the button, such as a `Breadcrumbs.Separator`. */
|
|
67
|
+
separator?: Snippet;
|
|
68
|
+
/** The name of the button. Without it, "Show N more pages" in the locale of `LocaleProvider`. */
|
|
69
|
+
'aria-label'?: string;
|
|
70
|
+
/** The button element, while the trail is folded. Use `bind:element` to read it. */
|
|
71
|
+
element?: HTMLButtonElement | null;
|
|
72
|
+
};
|
|
73
|
+
export type BreadcrumbsSeparatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'aria-hidden'> & {
|
|
74
|
+
/** The sign between two items. A slash without children. */
|
|
75
|
+
children?: Snippet;
|
|
76
|
+
/** The CSS class names of the element. */
|
|
77
|
+
class?: string;
|
|
78
|
+
/** The `<span>` element. Use `bind:element` to read it. */
|
|
79
|
+
element?: HTMLSpanElement | null;
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useComboBoxContext } from '../root/context';
|
|
4
4
|
import { Popover } from '../../popover';
|
|
5
5
|
import { focusWithModality, type InputModality } from '../../primitives/input-modality';
|
|
6
|
+
import { containWheel } from '../../primitives/contain-wheel';
|
|
6
7
|
import type { PopoverOpenChangeDetails } from '../../popover/root/context';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -98,65 +99,12 @@
|
|
|
98
99
|
};
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const isScrollingUp = deltaY < 0;
|
|
104
|
-
const canScrollDown = element.scrollTop < element.scrollHeight - element.clientHeight;
|
|
105
|
-
const canScrollUp = element.scrollTop > 0;
|
|
106
|
-
|
|
107
|
-
return (isScrollingDown && canScrollDown) || (isScrollingUp && canScrollUp);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function isScrollableElement(element: HTMLElement) {
|
|
111
|
-
const { overflowY } = getComputedStyle(element);
|
|
112
|
-
return (
|
|
113
|
-
['auto', 'scroll', 'overlay'].includes(overflowY) &&
|
|
114
|
-
element.scrollHeight > element.clientHeight
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function hasScrollableDescendantForWheel(
|
|
119
|
-
boundary: HTMLElement,
|
|
120
|
-
target: EventTarget | null,
|
|
121
|
-
deltaY: number
|
|
122
|
-
) {
|
|
123
|
-
let current =
|
|
124
|
-
target instanceof HTMLElement ? target : target instanceof Node ? target.parentElement : null;
|
|
125
|
-
|
|
126
|
-
while (current) {
|
|
127
|
-
if (isScrollableElement(current) && canElementScrollInDirection(current, deltaY)) {
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
if (current === boundary) {
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
current = current.parentElement;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Prevent wheel/scroll events from propagating to the page
|
|
143
|
-
* This keeps the page from scrolling when scrolling over the popover
|
|
144
|
-
* But allows internal scrolling when either the popover or a descendant owns overflow
|
|
145
|
-
*/
|
|
102
|
+
// The page must not scroll under the popover, and a scroll of the page closes it. The
|
|
103
|
+
// wheel scrolls the panel, or a scrollable element inside it, while one of them can move.
|
|
146
104
|
function handleWheel(event: WheelEvent) {
|
|
147
105
|
const element = event.currentTarget as HTMLElement;
|
|
148
106
|
if (!element) return;
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
hasScrollableDescendantForWheel(element, event.target, event.deltaY) ||
|
|
152
|
-
(isScrollableElement(element) && canElementScrollInDirection(element, event.deltaY))
|
|
153
|
-
) {
|
|
154
|
-
event.stopPropagation();
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
event.preventDefault();
|
|
159
|
-
event.stopPropagation();
|
|
107
|
+
containWheel(event, element);
|
|
160
108
|
}
|
|
161
109
|
|
|
162
110
|
$effect(() => {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { tick, untrack, type Snippet } from 'svelte';
|
|
3
3
|
import { setDialogContext, type DialogContext } from './context';
|
|
4
4
|
import type { DialogStateHelpers } from './types';
|
|
5
|
+
import { focusFellToBody } from '../../primitives/trigger-focus-state';
|
|
5
6
|
import {
|
|
6
7
|
focusWithModality,
|
|
7
8
|
resolveCloseInteractionModality
|
|
@@ -95,8 +96,20 @@
|
|
|
95
96
|
*/
|
|
96
97
|
function restoreFocusTo(
|
|
97
98
|
target: HTMLElement,
|
|
98
|
-
modality: ReturnType<typeof resolveCloseInteractionModality
|
|
99
|
+
modality: ReturnType<typeof resolveCloseInteractionModality>,
|
|
100
|
+
reason: string = 'imperative-action'
|
|
99
101
|
) {
|
|
102
|
+
// An outside press moves the focus after this runs: the browser sends it to the
|
|
103
|
+
// pressed element, and to the body when that element takes no focus — which is every
|
|
104
|
+
// element outside a modal, since the page is inert. A restore made now is undone a
|
|
105
|
+
// moment later, so it waits a frame and then fills the gap the press left.
|
|
106
|
+
if (reason === 'outside-press') {
|
|
107
|
+
requestAnimationFrame(() => {
|
|
108
|
+
if (!target.isConnected || !focusFellToBody()) return;
|
|
109
|
+
focusWithModality(target, modality);
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
100
113
|
focusWithModality(target, modality);
|
|
101
114
|
if (document.activeElement === target) return;
|
|
102
115
|
|
|
@@ -113,7 +126,7 @@
|
|
|
113
126
|
// back down) — don't steal focus while the dialog is still open.
|
|
114
127
|
if (!wasOpen || isOpen) return;
|
|
115
128
|
if (triggerRef) {
|
|
116
|
-
restoreFocusTo(triggerRef, resolveCloseInteractionModality(reason, event));
|
|
129
|
+
restoreFocusTo(triggerRef, resolveCloseInteractionModality(reason, event), reason);
|
|
117
130
|
}
|
|
118
131
|
}
|
|
119
132
|
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
DrawerStateHelpers
|
|
15
15
|
} from './types';
|
|
16
16
|
import type { DrawerHandle } from './handle.svelte';
|
|
17
|
+
import { focusFellToBody } from '../../primitives/trigger-focus-state';
|
|
17
18
|
import {
|
|
18
19
|
focusWithModality,
|
|
19
20
|
resolveCloseInteractionModality
|
|
@@ -184,8 +185,20 @@
|
|
|
184
185
|
*/
|
|
185
186
|
function restoreFocusTo(
|
|
186
187
|
target: HTMLElement,
|
|
187
|
-
modality: ReturnType<typeof resolveCloseInteractionModality
|
|
188
|
+
modality: ReturnType<typeof resolveCloseInteractionModality>,
|
|
189
|
+
reason: string = 'imperative-action'
|
|
188
190
|
) {
|
|
191
|
+
// An outside press moves the focus after this runs: the browser sends it to the
|
|
192
|
+
// pressed element, and to the body when that element takes no focus — which is every
|
|
193
|
+
// element outside a modal, since the page is inert. A restore made now is undone a
|
|
194
|
+
// moment later, so it waits a frame and then fills the gap the press left.
|
|
195
|
+
if (reason === 'outside-press') {
|
|
196
|
+
requestAnimationFrame(() => {
|
|
197
|
+
if (!target.isConnected || !focusFellToBody()) return;
|
|
198
|
+
focusWithModality(target, modality);
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
189
202
|
focusWithModality(target, modality);
|
|
190
203
|
if (document.activeElement === target) return;
|
|
191
204
|
|
|
@@ -205,7 +218,7 @@
|
|
|
205
218
|
// whichever one happened to register itself last.
|
|
206
219
|
const restoreTarget = handle?.trigger ?? triggerRef;
|
|
207
220
|
if (restoreTarget) {
|
|
208
|
-
restoreFocusTo(restoreTarget, resolveCloseInteractionModality(reason, event));
|
|
221
|
+
restoreFocusTo(restoreTarget, resolveCloseInteractionModality(reason, event), reason);
|
|
209
222
|
}
|
|
210
223
|
}
|
|
211
224
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { Accordion } from './accordion/index.js';
|
|
2
2
|
export { Autocomplete } from './autocomplete/index.js';
|
|
3
|
+
export { Avatar } from './avatar/index.js';
|
|
4
|
+
export { Breadcrumbs } from './breadcrumbs/index.js';
|
|
3
5
|
export { Button } from './button/index.js';
|
|
4
6
|
export { Checkbox } from './checkbox/index.js';
|
|
5
7
|
export { CheckboxGroup } from './checkbox-group/index.js';
|
|
@@ -16,27 +18,36 @@ export { ListBox } from './listbox/index.js';
|
|
|
16
18
|
export { Menu } from './menu/index.js';
|
|
17
19
|
export { NumberField } from './numberfield/index.js';
|
|
18
20
|
export { Popover } from './popover/index.js';
|
|
21
|
+
export { Progress } from './progress/index.js';
|
|
19
22
|
export { RadioGroup } from './radio-group/index.js';
|
|
23
|
+
export { Select } from './select/index.js';
|
|
24
|
+
export { Slider } from './slider/index.js';
|
|
20
25
|
export { Switch } from './switch/index.js';
|
|
26
|
+
export { Tooltip } from './tooltip/index.js';
|
|
21
27
|
export { Table } from './table/index.js';
|
|
22
28
|
export { Tabs } from './tabs/index.js';
|
|
29
|
+
export { Toast } from './toast/index.js';
|
|
23
30
|
export { Toggle } from './toggle/index.js';
|
|
24
31
|
export { ToggleGroup } from './toggle-group/index.js';
|
|
25
32
|
export { TransferList } from './transfer-list/index.js';
|
|
26
33
|
export { Tree } from './tree/index.js';
|
|
27
34
|
export { default as Input } from './input/index.js';
|
|
28
35
|
export { default as Label } from './label/index.js';
|
|
36
|
+
export { default as Separator } from './separator/index.js';
|
|
29
37
|
export { default as Dropzone } from './dropzone/index.js';
|
|
30
38
|
export { default as LocaleProvider } from './locale-provider/index.js';
|
|
31
39
|
export { Portal } from './portal/index.js';
|
|
32
40
|
export { OverflowRow, type OverflowRowState } from './overflow-row/index.js';
|
|
33
41
|
export { default as TextArea } from './textarea/index.js';
|
|
34
42
|
export * from './locale-provider/index.js';
|
|
43
|
+
export type { SeparatorOrientation, SeparatorProps } from './separator/index.js';
|
|
35
44
|
export * from './accordion/index.js';
|
|
36
45
|
export * from './autocomplete/index.js';
|
|
37
46
|
export * from './button/index.js';
|
|
38
47
|
export * from './checkbox/index.js';
|
|
39
48
|
export * from './checkbox-group/index.js';
|
|
49
|
+
export * from './avatar/index.js';
|
|
50
|
+
export * from './breadcrumbs/index.js';
|
|
40
51
|
export * from './collapsible/index.js';
|
|
41
52
|
export * from './combobox/index.js';
|
|
42
53
|
export * from './calendar/index.js';
|
|
@@ -51,10 +62,15 @@ export * from './listbox/index.js';
|
|
|
51
62
|
export * from './menu/index.js';
|
|
52
63
|
export * from './numberfield/index.js';
|
|
53
64
|
export * from './popover/index.js';
|
|
65
|
+
export * from './progress/index.js';
|
|
54
66
|
export * from './radio-group/index.js';
|
|
67
|
+
export * from './select/index.js';
|
|
68
|
+
export * from './slider/index.js';
|
|
55
69
|
export * from './switch/index.js';
|
|
70
|
+
export * from './tooltip/index.js';
|
|
56
71
|
export * from './table/index.js';
|
|
57
72
|
export * from './tabs/index.js';
|
|
73
|
+
export * from './toast/index.js';
|
|
58
74
|
export * from './toggle/index.js';
|
|
59
75
|
export * from './toggle-group/index.js';
|
|
60
76
|
export * from './transfer-list/index.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// Components (namespace exports)
|
|
3
3
|
export { Accordion } from './accordion/index.js';
|
|
4
4
|
export { Autocomplete } from './autocomplete/index.js';
|
|
5
|
+
export { Avatar } from './avatar/index.js';
|
|
6
|
+
export { Breadcrumbs } from './breadcrumbs/index.js';
|
|
5
7
|
export { Button } from './button/index.js';
|
|
6
8
|
export { Checkbox } from './checkbox/index.js';
|
|
7
9
|
export { CheckboxGroup } from './checkbox-group/index.js';
|
|
@@ -18,10 +20,15 @@ export { ListBox } from './listbox/index.js';
|
|
|
18
20
|
export { Menu } from './menu/index.js';
|
|
19
21
|
export { NumberField } from './numberfield/index.js';
|
|
20
22
|
export { Popover } from './popover/index.js';
|
|
23
|
+
export { Progress } from './progress/index.js';
|
|
21
24
|
export { RadioGroup } from './radio-group/index.js';
|
|
25
|
+
export { Select } from './select/index.js';
|
|
26
|
+
export { Slider } from './slider/index.js';
|
|
22
27
|
export { Switch } from './switch/index.js';
|
|
28
|
+
export { Tooltip } from './tooltip/index.js';
|
|
23
29
|
export { Table } from './table/index.js';
|
|
24
30
|
export { Tabs } from './tabs/index.js';
|
|
31
|
+
export { Toast } from './toast/index.js';
|
|
25
32
|
export { Toggle } from './toggle/index.js';
|
|
26
33
|
export { ToggleGroup } from './toggle-group/index.js';
|
|
27
34
|
export { TransferList } from './transfer-list/index.js';
|
|
@@ -29,6 +36,7 @@ export { Tree } from './tree/index.js';
|
|
|
29
36
|
// Simple components
|
|
30
37
|
export { default as Input } from './input/index.js';
|
|
31
38
|
export { default as Label } from './label/index.js';
|
|
39
|
+
export { default as Separator } from './separator/index.js';
|
|
32
40
|
export { default as Dropzone } from './dropzone/index.js';
|
|
33
41
|
export { default as LocaleProvider } from './locale-provider/index.js';
|
|
34
42
|
export { Portal } from './portal/index.js';
|
|
@@ -41,6 +49,8 @@ export * from './autocomplete/index.js';
|
|
|
41
49
|
export * from './button/index.js';
|
|
42
50
|
export * from './checkbox/index.js';
|
|
43
51
|
export * from './checkbox-group/index.js';
|
|
52
|
+
export * from './avatar/index.js';
|
|
53
|
+
export * from './breadcrumbs/index.js';
|
|
44
54
|
export * from './collapsible/index.js';
|
|
45
55
|
export * from './combobox/index.js';
|
|
46
56
|
export * from './calendar/index.js';
|
|
@@ -55,10 +65,15 @@ export * from './listbox/index.js';
|
|
|
55
65
|
export * from './menu/index.js';
|
|
56
66
|
export * from './numberfield/index.js';
|
|
57
67
|
export * from './popover/index.js';
|
|
68
|
+
export * from './progress/index.js';
|
|
58
69
|
export * from './radio-group/index.js';
|
|
70
|
+
export * from './select/index.js';
|
|
71
|
+
export * from './slider/index.js';
|
|
59
72
|
export * from './switch/index.js';
|
|
73
|
+
export * from './tooltip/index.js';
|
|
60
74
|
export * from './table/index.js';
|
|
61
75
|
export * from './tabs/index.js';
|
|
76
|
+
export * from './toast/index.js';
|
|
62
77
|
export * from './toggle/index.js';
|
|
63
78
|
export * from './toggle-group/index.js';
|
|
64
79
|
export * from './transfer-list/index.js';
|
|
@@ -24,6 +24,30 @@ declare const LOCALIZED_STRINGS: {
|
|
|
24
24
|
readonly de: "Vorherige Seite";
|
|
25
25
|
readonly it: "Pagina precedente";
|
|
26
26
|
};
|
|
27
|
+
readonly 'select.placeholder': {
|
|
28
|
+
readonly en: "Select an option";
|
|
29
|
+
readonly es: "Seleccione una opción";
|
|
30
|
+
readonly pt: "Selecione uma opção";
|
|
31
|
+
readonly fr: "Sélectionnez une option";
|
|
32
|
+
readonly de: "Option auswählen";
|
|
33
|
+
readonly it: "Seleziona un’opzione";
|
|
34
|
+
};
|
|
35
|
+
readonly 'slider.minimum': {
|
|
36
|
+
readonly en: "Minimum";
|
|
37
|
+
readonly es: "Mínimo";
|
|
38
|
+
readonly pt: "Mínimo";
|
|
39
|
+
readonly fr: "Minimum";
|
|
40
|
+
readonly de: "Minimum";
|
|
41
|
+
readonly it: "Minimo";
|
|
42
|
+
};
|
|
43
|
+
readonly 'slider.maximum': {
|
|
44
|
+
readonly en: "Maximum";
|
|
45
|
+
readonly es: "Máximo";
|
|
46
|
+
readonly pt: "Máximo";
|
|
47
|
+
readonly fr: "Maximum";
|
|
48
|
+
readonly de: "Maximum";
|
|
49
|
+
readonly it: "Massimo";
|
|
50
|
+
};
|
|
27
51
|
readonly 'datePicker.calendar': {
|
|
28
52
|
readonly en: "Calendar";
|
|
29
53
|
readonly es: "Calendario";
|
|
@@ -304,6 +328,30 @@ declare const LOCALIZED_STRINGS: {
|
|
|
304
328
|
readonly de: "{count} Elemente nach {label} verschoben";
|
|
305
329
|
readonly it: "{count} elementi spostati in {label}";
|
|
306
330
|
};
|
|
331
|
+
readonly 'avatar.more': {
|
|
332
|
+
readonly en: "{count} more";
|
|
333
|
+
readonly es: "{count} más";
|
|
334
|
+
readonly pt: "{count} mais";
|
|
335
|
+
readonly fr: "{count} de plus";
|
|
336
|
+
readonly de: "{count} weitere";
|
|
337
|
+
readonly it: "{count} altri";
|
|
338
|
+
};
|
|
339
|
+
readonly 'breadcrumbs.label': {
|
|
340
|
+
readonly en: "Breadcrumb";
|
|
341
|
+
readonly es: "Ruta de navegación";
|
|
342
|
+
readonly pt: "Trilha de navegação";
|
|
343
|
+
readonly fr: "Fil d'Ariane";
|
|
344
|
+
readonly de: "Brotkrumennavigation";
|
|
345
|
+
readonly it: "Percorso di navigazione";
|
|
346
|
+
};
|
|
347
|
+
readonly 'breadcrumbs.showMore': {
|
|
348
|
+
readonly en: "Show {count} more pages";
|
|
349
|
+
readonly es: "Mostrar {count} páginas más";
|
|
350
|
+
readonly pt: "Mostrar mais {count} páginas";
|
|
351
|
+
readonly fr: "Afficher {count} pages de plus";
|
|
352
|
+
readonly de: "{count} weitere Seiten anzeigen";
|
|
353
|
+
readonly it: "Mostra altre {count} pagine";
|
|
354
|
+
};
|
|
307
355
|
readonly 'segment.empty': {
|
|
308
356
|
readonly en: "Empty";
|
|
309
357
|
readonly es: "Vacío";
|
|
@@ -312,6 +360,30 @@ declare const LOCALIZED_STRINGS: {
|
|
|
312
360
|
readonly de: "Leer";
|
|
313
361
|
readonly it: "Vuoto";
|
|
314
362
|
};
|
|
363
|
+
readonly 'toast.notifications': {
|
|
364
|
+
readonly en: "Notifications";
|
|
365
|
+
readonly es: "Notificaciones";
|
|
366
|
+
readonly pt: "Notificações";
|
|
367
|
+
readonly fr: "Notifications";
|
|
368
|
+
readonly de: "Benachrichtigungen";
|
|
369
|
+
readonly it: "Notifiche";
|
|
370
|
+
};
|
|
371
|
+
readonly 'toast.oneNotification': {
|
|
372
|
+
readonly en: "1 notification";
|
|
373
|
+
readonly es: "1 notificación";
|
|
374
|
+
readonly pt: "1 notificação";
|
|
375
|
+
readonly fr: "1 notification";
|
|
376
|
+
readonly de: "1 Benachrichtigung";
|
|
377
|
+
readonly it: "1 notifica";
|
|
378
|
+
};
|
|
379
|
+
readonly 'toast.multipleNotifications': {
|
|
380
|
+
readonly en: "{count} notifications";
|
|
381
|
+
readonly es: "{count} notificaciones";
|
|
382
|
+
readonly pt: "{count} notificações";
|
|
383
|
+
readonly fr: "{count} notifications";
|
|
384
|
+
readonly de: "{count} Benachrichtigungen";
|
|
385
|
+
readonly it: "{count} notifiche";
|
|
386
|
+
};
|
|
315
387
|
};
|
|
316
388
|
export type LocalizedStringKey = keyof typeof LOCALIZED_STRINGS;
|
|
317
389
|
export declare function resolveLocalizedString(locale: string | undefined, key: LocalizedStringKey, params?: Record<string, string | number>): string;
|
|
@@ -24,6 +24,30 @@ const LOCALIZED_STRINGS = {
|
|
|
24
24
|
de: 'Vorherige Seite',
|
|
25
25
|
it: 'Pagina precedente'
|
|
26
26
|
},
|
|
27
|
+
'select.placeholder': {
|
|
28
|
+
en: 'Select an option',
|
|
29
|
+
es: 'Seleccione una opción',
|
|
30
|
+
pt: 'Selecione uma opção',
|
|
31
|
+
fr: 'Sélectionnez une option',
|
|
32
|
+
de: 'Option auswählen',
|
|
33
|
+
it: 'Seleziona un’opzione'
|
|
34
|
+
},
|
|
35
|
+
'slider.minimum': {
|
|
36
|
+
en: 'Minimum',
|
|
37
|
+
es: 'Mínimo',
|
|
38
|
+
pt: 'Mínimo',
|
|
39
|
+
fr: 'Minimum',
|
|
40
|
+
de: 'Minimum',
|
|
41
|
+
it: 'Minimo'
|
|
42
|
+
},
|
|
43
|
+
'slider.maximum': {
|
|
44
|
+
en: 'Maximum',
|
|
45
|
+
es: 'Máximo',
|
|
46
|
+
pt: 'Máximo',
|
|
47
|
+
fr: 'Maximum',
|
|
48
|
+
de: 'Maximum',
|
|
49
|
+
it: 'Massimo'
|
|
50
|
+
},
|
|
27
51
|
'datePicker.calendar': {
|
|
28
52
|
en: 'Calendar',
|
|
29
53
|
es: 'Calendario',
|
|
@@ -304,6 +328,30 @@ const LOCALIZED_STRINGS = {
|
|
|
304
328
|
de: '{count} Elemente nach {label} verschoben',
|
|
305
329
|
it: '{count} elementi spostati in {label}'
|
|
306
330
|
},
|
|
331
|
+
'avatar.more': {
|
|
332
|
+
en: '{count} more',
|
|
333
|
+
es: '{count} más',
|
|
334
|
+
pt: '{count} mais',
|
|
335
|
+
fr: '{count} de plus',
|
|
336
|
+
de: '{count} weitere',
|
|
337
|
+
it: '{count} altri'
|
|
338
|
+
},
|
|
339
|
+
'breadcrumbs.label': {
|
|
340
|
+
en: 'Breadcrumb',
|
|
341
|
+
es: 'Ruta de navegación',
|
|
342
|
+
pt: 'Trilha de navegação',
|
|
343
|
+
fr: "Fil d'Ariane",
|
|
344
|
+
de: 'Brotkrumennavigation',
|
|
345
|
+
it: 'Percorso di navigazione'
|
|
346
|
+
},
|
|
347
|
+
'breadcrumbs.showMore': {
|
|
348
|
+
en: 'Show {count} more pages',
|
|
349
|
+
es: 'Mostrar {count} páginas más',
|
|
350
|
+
pt: 'Mostrar mais {count} páginas',
|
|
351
|
+
fr: 'Afficher {count} pages de plus',
|
|
352
|
+
de: '{count} weitere Seiten anzeigen',
|
|
353
|
+
it: 'Mostra altre {count} pagine'
|
|
354
|
+
},
|
|
307
355
|
'segment.empty': {
|
|
308
356
|
en: 'Empty',
|
|
309
357
|
es: 'Vacío',
|
|
@@ -311,6 +359,30 @@ const LOCALIZED_STRINGS = {
|
|
|
311
359
|
fr: 'Vide',
|
|
312
360
|
de: 'Leer',
|
|
313
361
|
it: 'Vuoto'
|
|
362
|
+
},
|
|
363
|
+
'toast.notifications': {
|
|
364
|
+
en: 'Notifications',
|
|
365
|
+
es: 'Notificaciones',
|
|
366
|
+
pt: 'Notificações',
|
|
367
|
+
fr: 'Notifications',
|
|
368
|
+
de: 'Benachrichtigungen',
|
|
369
|
+
it: 'Notifiche'
|
|
370
|
+
},
|
|
371
|
+
'toast.oneNotification': {
|
|
372
|
+
en: '1 notification',
|
|
373
|
+
es: '1 notificación',
|
|
374
|
+
pt: '1 notificação',
|
|
375
|
+
fr: '1 notification',
|
|
376
|
+
de: '1 Benachrichtigung',
|
|
377
|
+
it: '1 notifica'
|
|
378
|
+
},
|
|
379
|
+
'toast.multipleNotifications': {
|
|
380
|
+
en: '{count} notifications',
|
|
381
|
+
es: '{count} notificaciones',
|
|
382
|
+
pt: '{count} notificações',
|
|
383
|
+
fr: '{count} notifications',
|
|
384
|
+
de: '{count} Benachrichtigungen',
|
|
385
|
+
it: '{count} notifiche'
|
|
314
386
|
}
|
|
315
387
|
};
|
|
316
388
|
function resolveLanguage(locale) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decimal digits of a number, also for a number written with an exponent: `1e-7` has 7.
|
|
3
|
+
*/
|
|
4
|
+
export declare function decimalPlaces(value: number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Rounds a number to a count of decimal digits, and removes the float error of an arithmetic
|
|
7
|
+
* step: `0.1 + 0.2` at one digit is `0.3`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function roundToPrecision(value: number, precision: number): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The decimal digits of a number, also for a number written with an exponent: `1e-7` has 7.
|
|
3
|
+
*/
|
|
4
|
+
export function decimalPlaces(value) {
|
|
5
|
+
if (!Number.isFinite(value))
|
|
6
|
+
return 0;
|
|
7
|
+
const text = value.toString().toLowerCase();
|
|
8
|
+
if (!text.includes('e')) {
|
|
9
|
+
return text.split('.')[1]?.length ?? 0;
|
|
10
|
+
}
|
|
11
|
+
const [coefficient, exponentText] = text.split('e');
|
|
12
|
+
const exponent = Number(exponentText);
|
|
13
|
+
const coefficientDecimals = coefficient.split('.')[1]?.length ?? 0;
|
|
14
|
+
return Math.max(0, coefficientDecimals - exponent);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Rounds a number to a count of decimal digits, and removes the float error of an arithmetic
|
|
18
|
+
* step: `0.1 + 0.2` at one digit is `0.3`.
|
|
19
|
+
*/
|
|
20
|
+
export function roundToPrecision(value, precision) {
|
|
21
|
+
const factor = 10 ** Math.min(precision, 12);
|
|
22
|
+
// Round on the absolute value and reapply the sign so ties resolve
|
|
23
|
+
// away from zero symmetrically: 0.025 → 0.03 and -0.025 → -0.03
|
|
24
|
+
// (Math.round alone rounds -0.025 toward +Infinity, giving -0.02).
|
|
25
|
+
const rounded = Math.round((Math.abs(value) + Number.EPSILON) * factor) / factor;
|
|
26
|
+
return value < 0 ? -rounded : rounded;
|
|
27
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MenuInternalCloseReason } from './context';
|
|
2
|
-
|
|
2
|
+
import { addTriggerBlurCleanup, clearTriggerFocusState } from '../../primitives/trigger-focus-state';
|
|
3
|
+
export { addTriggerBlurCleanup, clearTriggerFocusState };
|
|
3
4
|
export declare function applyTriggerCloseFocusState(trigger: HTMLElement, reason: MenuInternalCloseReason, event?: Event): void;
|
|
4
|
-
export declare function addTriggerBlurCleanup(trigger: HTMLElement, once?: boolean): () => void;
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { applyTriggerCloseFocusState as applyTriggerCloseFocusStateShared, addTriggerBlurCleanup, clearTriggerFocusState } from '../../primitives/trigger-focus-state';
|
|
2
|
+
export { addTriggerBlurCleanup, clearTriggerFocusState };
|
|
3
|
+
// Every reason the menu schedules returns the focus to the trigger, except an outside press:
|
|
4
|
+
// there the shared primitive returns it only when the press left the focus on nothing.
|
|
5
|
+
// 'submenu-back' (ArrowLeft) styles the submenu trigger exactly like an Escape.
|
|
6
6
|
export function applyTriggerCloseFocusState(trigger, reason, event) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (reason === 'outside-press' || reason === 'escape-key' || reason === 'submenu-back') {
|
|
11
|
-
trigger.dataset.focused = 'true';
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
delete trigger.dataset.focused;
|
|
15
|
-
}
|
|
16
|
-
if (closeModality === 'keyboard') {
|
|
17
|
-
trigger.dataset.focusVisible = 'true';
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
delete trigger.dataset.focusVisible;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export function addTriggerBlurCleanup(trigger, once = false) {
|
|
24
|
-
const handleBlur = () => {
|
|
25
|
-
clearTriggerFocusState(trigger);
|
|
26
|
-
if (once) {
|
|
27
|
-
trigger.removeEventListener('blur', handleBlur);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
trigger.addEventListener('blur', handleBlur);
|
|
31
|
-
return () => {
|
|
32
|
-
trigger.removeEventListener('blur', handleBlur);
|
|
33
|
-
};
|
|
7
|
+
applyTriggerCloseFocusStateShared(trigger, reason, event, {
|
|
8
|
+
refocus: reason !== 'outside-press'
|
|
9
|
+
});
|
|
34
10
|
}
|
|
@@ -120,7 +120,11 @@ export function createMenuState(options) {
|
|
|
120
120
|
const triggerRef = options.getTriggerRef();
|
|
121
121
|
if (!triggerRef)
|
|
122
122
|
return;
|
|
123
|
-
|
|
123
|
+
// An outside press is handled by the root menu alone: the focus state decides whether
|
|
124
|
+
// the press left the focus on nothing, and a submenu trigger sits inside content that
|
|
125
|
+
// is already closing.
|
|
126
|
+
const outsidePressOnRoot = reason === 'outside-press' && options.parent === null;
|
|
127
|
+
if (!TRIGGER_REFOCUS_REASONS.includes(reason) && !outsidePressOnRoot)
|
|
124
128
|
return;
|
|
125
129
|
// The INTERNAL reason drives the trigger focus visuals ('submenu-back' styles like an
|
|
126
130
|
// Escape); only the reason reported to consumers is canonicalized.
|