@serendie/ui 2.0.0 → 2.1.0
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/components/CheckBox/CheckBox.js +36 -35
- package/dist/components/ChoiceBox/ChoiceBox.js +41 -41
- package/dist/components/DataTable/DataTableComponent.d.ts +3 -20
- package/dist/components/DataTable/DataTableComponent.js +38 -36
- package/dist/components/DataTable/table/HeaderCheckbox.js +29 -19
- package/dist/components/Search/Search.d.ts +3 -1
- package/dist/components/Search/Search.js +34 -33
- package/dist/components/Select/Select.d.ts +2 -1
- package/dist/components/Select/Select.js +47 -41
- package/dist/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/components/Tooltip/Tooltip.js +70 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/Tooltip/index.js +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -10
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +10 -12
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +16 -16
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/use-accordion.js +13 -20
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/use-avatar.js +14 -18
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/use-checkbox.js +22 -28
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +7 -9
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/use-collapsible.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/collection/list-collection.js +5 -0
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +17 -18
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox-item-context.js +5 -7
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/use-combobox.js +21 -45
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +10 -9
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +6 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/use-dialog.js +13 -22
- package/dist/node_modules/@ark-ui/react/dist/components/factory.js +26 -24
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +1 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +15 -13
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +13 -14
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu-option-item-props-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/menu/use-menu.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-ellipsis.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-next-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-prev-trigger.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/pagination-root.js +5 -4
- package/dist/node_modules/@ark-ui/react/dist/components/pagination/use-pagination.js +13 -19
- package/dist/node_modules/@ark-ui/react/dist/components/portal/portal.js +25 -16
- package/dist/node_modules/@ark-ui/react/dist/components/presence/split-presence-props.js +3 -2
- package/dist/node_modules/@ark-ui/react/dist/components/presence/use-presence.js +18 -18
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +1 -5
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/use-radio-group.js +14 -22
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +11 -12
- package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +20 -47
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -6
- package/dist/node_modules/@ark-ui/react/dist/components/switch/use-switch.js +20 -26
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +9 -8
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/use-tabs.js +14 -21
- package/dist/node_modules/@ark-ui/react/dist/components/toast/create-toaster.js +3 -7
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +28 -15
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow-tip.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-arrow.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-content.js +15 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-positioner.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-root.js +14 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/tooltip-trigger.js +13 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip-context.js +10 -0
- package/dist/node_modules/@ark-ui/react/dist/components/tooltip/use-tooltip.js +17 -0
- package/dist/node_modules/@ark-ui/react/dist/utils/compose-refs.js +13 -7
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +92 -90
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +230 -216
- package/dist/node_modules/@zag-js/accordion/dist/index.js +210 -227
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +49 -12
- package/dist/node_modules/@zag-js/avatar/dist/index.js +119 -134
- package/dist/node_modules/@zag-js/checkbox/dist/index.js +196 -197
- package/dist/node_modules/@zag-js/collapsible/dist/index.js +250 -198
- package/dist/node_modules/@zag-js/collection/dist/index.js +172 -179
- package/dist/node_modules/@zag-js/combobox/dist/index.js +1176 -1082
- package/dist/node_modules/@zag-js/core/dist/index.js +77 -496
- package/dist/node_modules/@zag-js/dialog/dist/index.js +243 -270
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +62 -60
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +465 -253
- package/dist/node_modules/@zag-js/focus-trap/dist/index.js +307 -0
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +48 -47
- package/dist/node_modules/@zag-js/interact-outside/dist/index.js +112 -80
- package/dist/node_modules/@zag-js/menu/dist/index.js +998 -884
- package/dist/node_modules/@zag-js/pagination/dist/index.js +207 -213
- package/dist/node_modules/@zag-js/popper/dist/index.js +130 -129
- package/dist/node_modules/@zag-js/presence/dist/index.js +139 -122
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +297 -302
- package/dist/node_modules/@zag-js/react/dist/index.js +255 -103
- package/dist/node_modules/@zag-js/remove-scroll/dist/index.js +18 -31
- package/dist/node_modules/@zag-js/select/dist/index.js +889 -885
- package/dist/node_modules/@zag-js/store/dist/index.js +98 -137
- package/dist/node_modules/@zag-js/switch/dist/index.js +199 -191
- package/dist/node_modules/@zag-js/tabs/dist/index.js +383 -386
- package/dist/node_modules/@zag-js/toast/dist/index.js +646 -633
- package/dist/node_modules/@zag-js/tooltip/dist/index.js +459 -0
- package/dist/node_modules/@zag-js/types/dist/index.js +6 -6
- package/dist/node_modules/@zag-js/utils/dist/index.js +112 -99
- package/dist/node_modules/proxy-compare/dist/index.js +4 -106
- package/dist/styles.css +1 -1
- package/package.json +5 -5
- package/dist/node_modules/@ark-ui/react/dist/utils/use-is-server.js +0 -10
- package/dist/node_modules/@zag-js/dom-event/dist/index.js +0 -130
- package/dist/node_modules/@zag-js/element-rect/dist/index.js +0 -32
- package/dist/node_modules/@zag-js/form-utils/dist/index.js +0 -51
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
- package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +0 -431
- package/dist/node_modules/klona/full/index.js +0 -21
- package/dist/node_modules/tabbable/dist/index.esm.js +0 -202
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { raf as O, getDocument as w, getTabbables as x, getFocusables as I, isTabbable as b, getTabIndex as v, addDomEvent as p, getEventTarget as N, isDocument as C, isFocusable as y, getActiveElement as D } from "../../dom-query/dist/index.js";
|
|
2
|
+
var k = Object.defineProperty, E = (e, a, n) => a in e ? k(e, a, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[a] = n, u = (e, a, n) => E(e, typeof a != "symbol" ? a + "" : a, n), m = {
|
|
3
|
+
activateTrap(e, a) {
|
|
4
|
+
if (e.length > 0) {
|
|
5
|
+
const t = e[e.length - 1];
|
|
6
|
+
t !== a && t.pause();
|
|
7
|
+
}
|
|
8
|
+
const n = e.indexOf(a);
|
|
9
|
+
n === -1 || e.splice(n, 1), e.push(a);
|
|
10
|
+
},
|
|
11
|
+
deactivateTrap(e, a) {
|
|
12
|
+
const n = e.indexOf(a);
|
|
13
|
+
n !== -1 && e.splice(n, 1), e.length > 0 && e[e.length - 1].unpause();
|
|
14
|
+
}
|
|
15
|
+
}, R = [], G = class {
|
|
16
|
+
constructor(e, a) {
|
|
17
|
+
u(this, "trapStack"), u(this, "config"), u(this, "doc"), u(this, "state", {
|
|
18
|
+
containers: [],
|
|
19
|
+
containerGroups: [],
|
|
20
|
+
tabbableGroups: [],
|
|
21
|
+
nodeFocusedBeforeActivation: null,
|
|
22
|
+
mostRecentlyFocusedNode: null,
|
|
23
|
+
active: !1,
|
|
24
|
+
paused: !1,
|
|
25
|
+
delayInitialFocusTimer: void 0,
|
|
26
|
+
recentNavEvent: void 0
|
|
27
|
+
}), u(this, "listenerCleanups", []), u(this, "handleFocus", (t) => {
|
|
28
|
+
const s = N(t), r = this.findContainerIndex(s, t) >= 0;
|
|
29
|
+
if (r || C(s))
|
|
30
|
+
r && (this.state.mostRecentlyFocusedNode = s);
|
|
31
|
+
else {
|
|
32
|
+
t.stopImmediatePropagation();
|
|
33
|
+
let i, c = !0;
|
|
34
|
+
if (this.state.mostRecentlyFocusedNode)
|
|
35
|
+
if (v(this.state.mostRecentlyFocusedNode) > 0) {
|
|
36
|
+
const h = this.findContainerIndex(this.state.mostRecentlyFocusedNode), { tabbableNodes: o } = this.state.containerGroups[h];
|
|
37
|
+
if (o.length > 0) {
|
|
38
|
+
const d = o.findIndex((l) => l === this.state.mostRecentlyFocusedNode);
|
|
39
|
+
d >= 0 && (this.config.isKeyForward(this.state.recentNavEvent) ? d + 1 < o.length && (i = o[d + 1], c = !1) : d - 1 >= 0 && (i = o[d - 1], c = !1));
|
|
40
|
+
}
|
|
41
|
+
} else
|
|
42
|
+
this.state.containerGroups.some((h) => h.tabbableNodes.some((o) => v(o) > 0)) || (c = !1);
|
|
43
|
+
else
|
|
44
|
+
c = !1;
|
|
45
|
+
c && (i = this.findNextNavNode({
|
|
46
|
+
// move FROM the MRU node, not event-related node (which will be the node that is
|
|
47
|
+
// outside the trap causing the focus escape we're trying to fix)
|
|
48
|
+
target: this.state.mostRecentlyFocusedNode,
|
|
49
|
+
isBackward: this.config.isKeyBackward(this.state.recentNavEvent)
|
|
50
|
+
})), i ? this.tryFocus(i) : this.tryFocus(this.state.mostRecentlyFocusedNode || this.getInitialFocusNode());
|
|
51
|
+
}
|
|
52
|
+
this.state.recentNavEvent = void 0;
|
|
53
|
+
}), u(this, "handlePointerDown", (t) => {
|
|
54
|
+
const s = N(t);
|
|
55
|
+
if (!(this.findContainerIndex(s, t) >= 0)) {
|
|
56
|
+
if (F(this.config.clickOutsideDeactivates, t)) {
|
|
57
|
+
this.deactivate({ returnFocus: this.config.returnFocusOnDeactivate });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
F(this.config.allowOutsideClick, t) || t.preventDefault();
|
|
61
|
+
}
|
|
62
|
+
}), u(this, "handleClick", (t) => {
|
|
63
|
+
const s = N(t);
|
|
64
|
+
this.findContainerIndex(s, t) >= 0 || F(this.config.clickOutsideDeactivates, t) || F(this.config.allowOutsideClick, t) || (t.preventDefault(), t.stopImmediatePropagation());
|
|
65
|
+
}), u(this, "handleTabKey", (t) => {
|
|
66
|
+
if (this.config.isKeyForward(t) || this.config.isKeyBackward(t)) {
|
|
67
|
+
this.state.recentNavEvent = t;
|
|
68
|
+
const s = this.config.isKeyBackward(t), r = this.findNextNavNode({ event: t, isBackward: s });
|
|
69
|
+
if (!r) return;
|
|
70
|
+
g(t) && t.preventDefault(), this.tryFocus(r);
|
|
71
|
+
}
|
|
72
|
+
}), u(this, "handleEscapeKey", (t) => {
|
|
73
|
+
B(t) && F(this.config.escapeDeactivates, t) !== !1 && (t.preventDefault(), this.deactivate());
|
|
74
|
+
}), u(this, "_mutationObserver"), u(this, "setupMutationObserver", () => {
|
|
75
|
+
const t = this.doc.defaultView || window;
|
|
76
|
+
this._mutationObserver = new t.MutationObserver((s) => {
|
|
77
|
+
s.some((i) => Array.from(i.removedNodes).some((h) => h === this.state.mostRecentlyFocusedNode)) && this.tryFocus(this.getInitialFocusNode());
|
|
78
|
+
});
|
|
79
|
+
}), u(this, "updateObservedNodes", () => {
|
|
80
|
+
var t;
|
|
81
|
+
(t = this._mutationObserver) == null || t.disconnect(), this.state.active && !this.state.paused && this.state.containers.map((s) => {
|
|
82
|
+
var r;
|
|
83
|
+
(r = this._mutationObserver) == null || r.observe(s, { subtree: !0, childList: !0 });
|
|
84
|
+
});
|
|
85
|
+
}), u(this, "getInitialFocusNode", () => {
|
|
86
|
+
let t = this.getNodeForOption("initialFocus", { hasFallback: !0 });
|
|
87
|
+
if (t === !1)
|
|
88
|
+
return !1;
|
|
89
|
+
if (t === void 0 || t && !y(t))
|
|
90
|
+
if (this.findContainerIndex(this.doc.activeElement) >= 0)
|
|
91
|
+
t = this.doc.activeElement;
|
|
92
|
+
else {
|
|
93
|
+
const s = this.state.tabbableGroups[0];
|
|
94
|
+
t = s && s.firstTabbableNode || this.getNodeForOption("fallbackFocus");
|
|
95
|
+
}
|
|
96
|
+
else t === null && (t = this.getNodeForOption("fallbackFocus"));
|
|
97
|
+
if (!t)
|
|
98
|
+
throw new Error("Your focus-trap needs to have at least one focusable element");
|
|
99
|
+
return t.isConnected || (t = this.getNodeForOption("fallbackFocus")), t;
|
|
100
|
+
}), u(this, "tryFocus", (t) => {
|
|
101
|
+
if (t !== !1 && t !== D(this.doc)) {
|
|
102
|
+
if (!t || !t.focus) {
|
|
103
|
+
this.tryFocus(this.getInitialFocusNode());
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
t.focus({ preventScroll: !!this.config.preventScroll }), this.state.mostRecentlyFocusedNode = t, K(t) && t.select();
|
|
107
|
+
}
|
|
108
|
+
}), u(this, "deactivate", (t) => {
|
|
109
|
+
if (!this.state.active) return this;
|
|
110
|
+
const s = {
|
|
111
|
+
onDeactivate: this.config.onDeactivate,
|
|
112
|
+
onPostDeactivate: this.config.onPostDeactivate,
|
|
113
|
+
checkCanReturnFocus: this.config.checkCanReturnFocus,
|
|
114
|
+
...t
|
|
115
|
+
};
|
|
116
|
+
clearTimeout(this.state.delayInitialFocusTimer), this.state.delayInitialFocusTimer = void 0, this.removeListeners(), this.state.active = !1, this.state.paused = !1, this.updateObservedNodes(), m.deactivateTrap(this.trapStack, this);
|
|
117
|
+
const r = this.getOption(s, "onDeactivate"), i = this.getOption(s, "onPostDeactivate"), c = this.getOption(s, "checkCanReturnFocus"), h = this.getOption(s, "returnFocus", "returnFocusOnDeactivate");
|
|
118
|
+
r == null || r();
|
|
119
|
+
const o = () => {
|
|
120
|
+
T(() => {
|
|
121
|
+
if (h) {
|
|
122
|
+
const d = this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);
|
|
123
|
+
this.tryFocus(d);
|
|
124
|
+
}
|
|
125
|
+
i == null || i();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
if (h && c) {
|
|
129
|
+
const d = this.getReturnFocusNode(this.state.nodeFocusedBeforeActivation);
|
|
130
|
+
return c(d).then(o, o), this;
|
|
131
|
+
}
|
|
132
|
+
return o(), this;
|
|
133
|
+
}), u(this, "pause", (t) => {
|
|
134
|
+
if (this.state.paused || !this.state.active)
|
|
135
|
+
return this;
|
|
136
|
+
const s = this.getOption(t, "onPause"), r = this.getOption(t, "onPostPause");
|
|
137
|
+
return this.state.paused = !0, s == null || s(), this.removeListeners(), this.updateObservedNodes(), r == null || r(), this;
|
|
138
|
+
}), u(this, "unpause", (t) => {
|
|
139
|
+
if (!this.state.paused || !this.state.active)
|
|
140
|
+
return this;
|
|
141
|
+
const s = this.getOption(t, "onUnpause"), r = this.getOption(t, "onPostUnpause");
|
|
142
|
+
return this.state.paused = !1, s == null || s(), this.updateTabbableNodes(), this.addListeners(), this.updateObservedNodes(), r == null || r(), this;
|
|
143
|
+
}), u(this, "updateContainerElements", (t) => (this.state.containers = Array.isArray(t) ? t.filter(Boolean) : [t].filter(Boolean), this.state.active && this.updateTabbableNodes(), this.updateObservedNodes(), this)), u(this, "getReturnFocusNode", (t) => {
|
|
144
|
+
const s = this.getNodeForOption("setReturnFocus", {
|
|
145
|
+
params: [t]
|
|
146
|
+
});
|
|
147
|
+
return s || (s === !1 ? !1 : t);
|
|
148
|
+
}), u(this, "getOption", (t, s, r) => t && t[s] !== void 0 ? t[s] : (
|
|
149
|
+
// @ts-expect-error
|
|
150
|
+
this.config[r || s]
|
|
151
|
+
)), u(this, "getNodeForOption", (t, { hasFallback: s = !1, params: r = [] } = {}) => {
|
|
152
|
+
let i = this.config[t];
|
|
153
|
+
if (typeof i == "function" && (i = i(...r)), i === !0 && (i = void 0), !i) {
|
|
154
|
+
if (i === void 0 || i === !1)
|
|
155
|
+
return i;
|
|
156
|
+
throw new Error(`\`${t}\` was specified but was not a node, or did not return a node`);
|
|
157
|
+
}
|
|
158
|
+
let c = i;
|
|
159
|
+
if (typeof i == "string") {
|
|
160
|
+
try {
|
|
161
|
+
c = this.doc.querySelector(i);
|
|
162
|
+
} catch (h) {
|
|
163
|
+
throw new Error(`\`${t}\` appears to be an invalid selector; error="${h.message}"`);
|
|
164
|
+
}
|
|
165
|
+
if (!c && !s)
|
|
166
|
+
throw new Error(`\`${t}\` as selector refers to no known node`);
|
|
167
|
+
}
|
|
168
|
+
return c;
|
|
169
|
+
}), u(this, "findNextNavNode", (t) => {
|
|
170
|
+
const { event: s, isBackward: r = !1 } = t, i = t.target || N(s);
|
|
171
|
+
this.updateTabbableNodes();
|
|
172
|
+
let c = null;
|
|
173
|
+
if (this.state.tabbableGroups.length > 0) {
|
|
174
|
+
const h = this.findContainerIndex(i, s), o = h >= 0 ? this.state.containerGroups[h] : void 0;
|
|
175
|
+
if (h < 0)
|
|
176
|
+
r ? c = this.state.tabbableGroups[this.state.tabbableGroups.length - 1].lastTabbableNode : c = this.state.tabbableGroups[0].firstTabbableNode;
|
|
177
|
+
else if (r) {
|
|
178
|
+
let d = this.state.tabbableGroups.findIndex(
|
|
179
|
+
({ firstTabbableNode: l }) => i === l
|
|
180
|
+
);
|
|
181
|
+
if (d < 0 && ((o == null ? void 0 : o.container) === i || y(i) && !b(i) && !(o != null && o.nextTabbableNode(i, !1))) && (d = h), d >= 0) {
|
|
182
|
+
const l = d === 0 ? this.state.tabbableGroups.length - 1 : d - 1, f = this.state.tabbableGroups[l];
|
|
183
|
+
c = v(i) >= 0 ? f.lastTabbableNode : f.lastDomTabbableNode;
|
|
184
|
+
} else g(s) || (c = o == null ? void 0 : o.nextTabbableNode(i, !1));
|
|
185
|
+
} else {
|
|
186
|
+
let d = this.state.tabbableGroups.findIndex(
|
|
187
|
+
({ lastTabbableNode: l }) => i === l
|
|
188
|
+
);
|
|
189
|
+
if (d < 0 && ((o == null ? void 0 : o.container) === i || y(i) && !b(i) && !(o != null && o.nextTabbableNode(i))) && (d = h), d >= 0) {
|
|
190
|
+
const l = d === this.state.tabbableGroups.length - 1 ? 0 : d + 1, f = this.state.tabbableGroups[l];
|
|
191
|
+
c = v(i) >= 0 ? f.firstTabbableNode : f.firstDomTabbableNode;
|
|
192
|
+
} else g(s) || (c = o == null ? void 0 : o.nextTabbableNode(i));
|
|
193
|
+
}
|
|
194
|
+
} else
|
|
195
|
+
c = this.getNodeForOption("fallbackFocus");
|
|
196
|
+
return c;
|
|
197
|
+
}), this.trapStack = a.trapStack || R;
|
|
198
|
+
const n = {
|
|
199
|
+
returnFocusOnDeactivate: !0,
|
|
200
|
+
escapeDeactivates: !0,
|
|
201
|
+
delayInitialFocus: !0,
|
|
202
|
+
isKeyForward(t) {
|
|
203
|
+
return g(t) && !t.shiftKey;
|
|
204
|
+
},
|
|
205
|
+
isKeyBackward(t) {
|
|
206
|
+
return g(t) && t.shiftKey;
|
|
207
|
+
},
|
|
208
|
+
...a
|
|
209
|
+
};
|
|
210
|
+
this.doc = n.document || w(Array.isArray(e) ? e[0] : e), this.config = n, this.updateContainerElements(e), this.setupMutationObserver();
|
|
211
|
+
}
|
|
212
|
+
get active() {
|
|
213
|
+
return this.state.active;
|
|
214
|
+
}
|
|
215
|
+
get paused() {
|
|
216
|
+
return this.state.paused;
|
|
217
|
+
}
|
|
218
|
+
findContainerIndex(e, a) {
|
|
219
|
+
const n = typeof (a == null ? void 0 : a.composedPath) == "function" ? a.composedPath() : void 0;
|
|
220
|
+
return this.state.containerGroups.findIndex(
|
|
221
|
+
({ container: t, tabbableNodes: s }) => t.contains(e) || (n == null ? void 0 : n.includes(t)) || s.find((r) => r === e)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
updateTabbableNodes() {
|
|
225
|
+
if (this.state.containerGroups = this.state.containers.map((e) => {
|
|
226
|
+
const a = x(e), n = I(e), t = a.length > 0 ? a[0] : void 0, s = a.length > 0 ? a[a.length - 1] : void 0, r = n.find((o) => b(o)), i = n.slice().reverse().find((o) => b(o)), c = !!a.find((o) => v(o) > 0);
|
|
227
|
+
function h(o, d = !0) {
|
|
228
|
+
const l = a.indexOf(o);
|
|
229
|
+
return l < 0 ? d ? n.slice(n.indexOf(o) + 1).find((f) => b(f)) : n.slice(0, n.indexOf(o)).reverse().find((f) => b(f)) : a[l + (d ? 1 : -1)];
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
container: e,
|
|
233
|
+
tabbableNodes: a,
|
|
234
|
+
focusableNodes: n,
|
|
235
|
+
posTabIndexesFound: c,
|
|
236
|
+
firstTabbableNode: t,
|
|
237
|
+
lastTabbableNode: s,
|
|
238
|
+
firstDomTabbableNode: r,
|
|
239
|
+
lastDomTabbableNode: i,
|
|
240
|
+
nextTabbableNode: h
|
|
241
|
+
};
|
|
242
|
+
}), this.state.tabbableGroups = this.state.containerGroups.filter((e) => e.tabbableNodes.length > 0), this.state.tabbableGroups.length <= 0 && !this.getNodeForOption("fallbackFocus"))
|
|
243
|
+
throw new Error(
|
|
244
|
+
"Your focus-trap must have at least one container with at least one tabbable node in it at all times"
|
|
245
|
+
);
|
|
246
|
+
if (this.state.containerGroups.find((e) => e.posTabIndexesFound) && this.state.containerGroups.length > 1)
|
|
247
|
+
throw new Error(
|
|
248
|
+
"At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps."
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
addListeners() {
|
|
252
|
+
if (this.state.active)
|
|
253
|
+
return m.activateTrap(this.trapStack, this), this.state.delayInitialFocusTimer = this.config.delayInitialFocus ? T(() => {
|
|
254
|
+
this.tryFocus(this.getInitialFocusNode());
|
|
255
|
+
}) : this.tryFocus(this.getInitialFocusNode()), this.listenerCleanups.push(
|
|
256
|
+
p(this.doc, "focusin", this.handleFocus, !0),
|
|
257
|
+
p(this.doc, "mousedown", this.handlePointerDown, { capture: !0, passive: !1 }),
|
|
258
|
+
p(this.doc, "touchstart", this.handlePointerDown, { capture: !0, passive: !1 }),
|
|
259
|
+
p(this.doc, "click", this.handleClick, { capture: !0, passive: !1 }),
|
|
260
|
+
p(this.doc, "keydown", this.handleTabKey, { capture: !0, passive: !1 }),
|
|
261
|
+
p(this.doc, "keydown", this.handleEscapeKey)
|
|
262
|
+
), this;
|
|
263
|
+
}
|
|
264
|
+
removeListeners() {
|
|
265
|
+
if (this.state.active)
|
|
266
|
+
return this.listenerCleanups.forEach((e) => e()), this.listenerCleanups = [], this;
|
|
267
|
+
}
|
|
268
|
+
activate(e) {
|
|
269
|
+
if (this.state.active)
|
|
270
|
+
return this;
|
|
271
|
+
const a = this.getOption(e, "onActivate"), n = this.getOption(e, "onPostActivate"), t = this.getOption(e, "checkCanFocusTrap");
|
|
272
|
+
t || this.updateTabbableNodes(), this.state.active = !0, this.state.paused = !1, this.state.nodeFocusedBeforeActivation = this.doc.activeElement || null, a == null || a();
|
|
273
|
+
const s = () => {
|
|
274
|
+
t && this.updateTabbableNodes(), this.addListeners(), this.updateObservedNodes(), n == null || n();
|
|
275
|
+
};
|
|
276
|
+
return t ? (t(this.state.containers.concat()).then(s, s), this) : (s(), this);
|
|
277
|
+
}
|
|
278
|
+
}, g = (e) => e.key === "Tab", F = (e, ...a) => typeof e == "function" ? e(...a) : e, B = (e) => !e.isComposing && e.key === "Escape", T = (e) => setTimeout(e, 0), K = (e) => e.localName === "input" && "select" in e && typeof e.select == "function";
|
|
279
|
+
function P(e, a = {}) {
|
|
280
|
+
let n;
|
|
281
|
+
const t = O(() => {
|
|
282
|
+
const s = typeof e == "function" ? e() : e;
|
|
283
|
+
if (s) {
|
|
284
|
+
n = new G(s, {
|
|
285
|
+
escapeDeactivates: !1,
|
|
286
|
+
allowOutsideClick: !0,
|
|
287
|
+
preventScroll: !0,
|
|
288
|
+
returnFocusOnDeactivate: !0,
|
|
289
|
+
delayInitialFocus: !1,
|
|
290
|
+
fallbackFocus: s,
|
|
291
|
+
...a,
|
|
292
|
+
document: w(s)
|
|
293
|
+
});
|
|
294
|
+
try {
|
|
295
|
+
n.activate();
|
|
296
|
+
} catch {
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
return function() {
|
|
301
|
+
n == null || n.deactivate(), t();
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
export {
|
|
305
|
+
G as FocusTrap,
|
|
306
|
+
P as trapFocus
|
|
307
|
+
};
|
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
import { getWindow as
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import { getWindow as d, getDocument as E, isVirtualClick as g, getEventTarget as L, isMac as F } from "../../dom-query/dist/index.js";
|
|
2
|
+
function T(e) {
|
|
3
|
+
return !(e.metaKey || !F() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var M = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
|
|
6
|
+
function H(e, r, n) {
|
|
7
|
+
const t = n ? L(n) : null, i = d(t);
|
|
8
|
+
return e = e || t instanceof i.HTMLInputElement && !M.has(t == null ? void 0 : t.type) || t instanceof i.HTMLTextAreaElement || t instanceof i.HTMLElement && t.isContentEditable, !(e && r === "keyboard" && n instanceof i.KeyboardEvent && !Reflect.has(K, n.key));
|
|
7
9
|
}
|
|
8
|
-
var
|
|
9
|
-
function H(t, r, e) {
|
|
10
|
-
var c;
|
|
11
|
-
const n = typeof window < "u" ? i(e == null ? void 0 : e.target).HTMLInputElement : HTMLInputElement, E = typeof window < "u" ? i(e == null ? void 0 : e.target).HTMLTextAreaElement : HTMLTextAreaElement, d = typeof window < "u" ? i(e == null ? void 0 : e.target).HTMLElement : HTMLElement, l = typeof window < "u" ? i(e == null ? void 0 : e.target).KeyboardEvent : KeyboardEvent;
|
|
12
|
-
return t = t || (e == null ? void 0 : e.target) instanceof n && !h.has((c = e == null ? void 0 : e.target) == null ? void 0 : c.type) || (e == null ? void 0 : e.target) instanceof E || (e == null ? void 0 : e.target) instanceof d && (e == null ? void 0 : e.target.isContentEditable), !(t && r === "keyboard" && e instanceof l && !Reflect.has(F, e.key));
|
|
13
|
-
}
|
|
14
|
-
var s = null, p = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), u = !1, m = !1, F = {
|
|
10
|
+
var s = null, v = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), u = !1, f = !1, K = {
|
|
15
11
|
Tab: !0,
|
|
16
12
|
Escape: !0
|
|
17
13
|
};
|
|
18
|
-
function
|
|
19
|
-
for (let
|
|
20
|
-
e
|
|
14
|
+
function c(e, r) {
|
|
15
|
+
for (let n of v)
|
|
16
|
+
n(e, r);
|
|
21
17
|
}
|
|
22
|
-
function
|
|
23
|
-
u = !0,
|
|
18
|
+
function l(e) {
|
|
19
|
+
u = !0, T(e) && (s = "keyboard", c("keyboard", e));
|
|
24
20
|
}
|
|
25
|
-
function o(
|
|
26
|
-
s = "pointer", (
|
|
21
|
+
function o(e) {
|
|
22
|
+
s = "pointer", (e.type === "mousedown" || e.type === "pointerdown") && (u = !0, c("pointer", e));
|
|
27
23
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
24
|
+
function b(e) {
|
|
25
|
+
g(e) && (u = !0, s = "virtual");
|
|
30
26
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
27
|
+
function w(e) {
|
|
28
|
+
const r = L(e);
|
|
29
|
+
r === d(r) || r === E(r) || (!u && !f && (s = "virtual", c("virtual", e)), u = !1, f = !1);
|
|
33
30
|
}
|
|
34
|
-
function
|
|
35
|
-
u = !1,
|
|
31
|
+
function k() {
|
|
32
|
+
u = !1, f = !0;
|
|
36
33
|
}
|
|
37
|
-
function
|
|
38
|
-
if (typeof window > "u" || a.get(
|
|
34
|
+
function V(e) {
|
|
35
|
+
if (typeof window > "u" || a.get(d(e)))
|
|
39
36
|
return;
|
|
40
|
-
const r =
|
|
41
|
-
let
|
|
42
|
-
|
|
43
|
-
s = "virtual",
|
|
44
|
-
}
|
|
37
|
+
const r = d(e), n = E(e);
|
|
38
|
+
let t = r.HTMLElement.prototype.focus;
|
|
39
|
+
function i() {
|
|
40
|
+
s = "virtual", c("virtual", null), u = !0, t.apply(this, arguments);
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(r.HTMLElement.prototype, "focus", {
|
|
43
|
+
configurable: !0,
|
|
44
|
+
value: i
|
|
45
|
+
}), n.addEventListener("keydown", l, !0), n.addEventListener("keyup", l, !0), n.addEventListener("click", b, !0), r.addEventListener("focus", w, !0), r.addEventListener("blur", k, !1), typeof r.PointerEvent < "u" ? (n.addEventListener("pointerdown", o, !0), n.addEventListener("pointermove", o, !0), n.addEventListener("pointerup", o, !0)) : (n.addEventListener("mousedown", o, !0), n.addEventListener("mousemove", o, !0), n.addEventListener("mouseup", o, !0)), r.addEventListener(
|
|
45
46
|
"beforeunload",
|
|
46
47
|
() => {
|
|
47
|
-
|
|
48
|
+
S(e);
|
|
48
49
|
},
|
|
49
50
|
{ once: !0 }
|
|
50
|
-
), a.set(r, { focus:
|
|
51
|
+
), a.set(r, { focus: t });
|
|
51
52
|
}
|
|
52
|
-
var
|
|
53
|
-
const
|
|
54
|
-
a.has(
|
|
53
|
+
var S = (e, r) => {
|
|
54
|
+
const n = d(e), t = E(e);
|
|
55
|
+
a.has(n) && (n.HTMLElement.prototype.focus = a.get(n).focus, t.removeEventListener("keydown", l, !0), t.removeEventListener("keyup", l, !0), t.removeEventListener("click", b, !0), n.removeEventListener("focus", w, !0), n.removeEventListener("blur", k, !1), typeof n.PointerEvent < "u" ? (t.removeEventListener("pointerdown", o, !0), t.removeEventListener("pointermove", o, !0), t.removeEventListener("pointerup", o, !0)) : (t.removeEventListener("mousedown", o, !0), t.removeEventListener("mousemove", o, !0), t.removeEventListener("mouseup", o, !0)), a.delete(n));
|
|
55
56
|
};
|
|
56
|
-
function
|
|
57
|
+
function y() {
|
|
57
58
|
return s === "keyboard";
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
const { isTextInput: r, autoFocus:
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
H(!!r,
|
|
60
|
+
function B(e = {}) {
|
|
61
|
+
const { isTextInput: r, autoFocus: n, onChange: t, root: i } = e;
|
|
62
|
+
V(i), t == null || t({ isFocusVisible: n || y(), modality: s });
|
|
63
|
+
const p = (m, h) => {
|
|
64
|
+
H(!!r, m, h) && (t == null || t({ isFocusVisible: y(), modality: m }));
|
|
64
65
|
};
|
|
65
|
-
return
|
|
66
|
-
|
|
66
|
+
return v.add(p), () => {
|
|
67
|
+
v.delete(p);
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
export {
|
|
70
|
-
|
|
71
|
+
y as isFocusVisible,
|
|
71
72
|
a as listenerMap,
|
|
72
|
-
|
|
73
|
+
B as trackFocusVisible
|
|
73
74
|
};
|