@serendie/ui 0.1.15 → 0.2.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/LICENSE +21 -0
- package/README.md +51 -9
- package/dist/components/{Accordion.d.ts → Accordion/Accordion.d.ts} +2 -2
- package/dist/components/{Accordion.js → Accordion/Accordion.js} +10 -10
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/AccordionGroup.js +4 -4
- package/dist/components/Avatar.js +4 -4
- package/dist/components/Badge.js +4 -4
- package/dist/components/Banner.js +4 -4
- package/dist/components/BottomNavigation.js +3 -3
- package/dist/components/BottomNavigationItem.js +4 -4
- package/dist/components/Button.js +10 -9
- package/dist/components/CheckBox.js +4 -4
- package/dist/components/ChoiceBox.js +10 -10
- package/dist/components/DashboardWidget.js +4 -4
- package/dist/components/Divider.js +4 -4
- package/dist/components/Drawer.js +4 -4
- package/dist/components/DropdownMenu.js +7 -6
- package/dist/components/IconButton.js +4 -4
- package/dist/components/ListItem.js +4 -4
- package/dist/components/ModalDialog.js +4 -4
- package/dist/components/NotificationBadge.js +4 -4
- package/dist/components/PasswordField.js +44 -0
- package/dist/components/ProgressIndicator.js +4 -4
- package/dist/components/RadioButton.js +4 -4
- package/dist/components/Search.js +6 -6
- package/dist/components/Select.js +4 -4
- package/dist/components/Switch.js +4 -4
- package/dist/components/TabItem.js +4 -4
- package/dist/components/Tabs.js +4 -4
- package/dist/components/TextArea.js +4 -4
- package/dist/components/TextField.js +4 -4
- package/dist/components/Toast.js +3 -3
- package/dist/components/TopAppBar.js +4 -4
- package/dist/index.d.ts +2 -1
- package/dist/index.js +81 -79
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-indicator.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item-trigger.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-item.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/accordion/accordion-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-fallback.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-image.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/avatar/avatar-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-control.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-hidden-input.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-label.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/checkbox/checkbox-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-content.js +8 -9
- package/dist/node_modules/@ark-ui/react/dist/components/collapsible/collapsible-root.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-control.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-input.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-group.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item-text.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-item.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-positioner.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/combobox/combobox-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-backdrop.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-close-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-content.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-description.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-positioner.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-root.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/dialog/dialog-title.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item-group.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-item.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-positioner.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-root.js +2 -3
- package/dist/node_modules/@ark-ui/react/dist/components/menu/menu-trigger.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-control.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-hidden-input.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item-text.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-item.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/radio-group/radio-group-root.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-content.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-control.js +6 -7
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-item.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-label.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-positioner.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-root.js +7 -7
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-trigger.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/select/select-value-text.js +5 -6
- package/dist/node_modules/@ark-ui/react/dist/components/select/use-select.js +35 -31
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-control.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-hidden-input.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-label.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-root.js +8 -9
- package/dist/node_modules/@ark-ui/react/dist/components/switch/switch-thumb.js +4 -5
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tab-list.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tab-trigger.js +3 -4
- package/dist/node_modules/@ark-ui/react/dist/components/tabs/tabs-root.js +10 -10
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toast-root.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toast-title.js +0 -1
- package/dist/node_modules/@ark-ui/react/dist/components/toast/toaster.js +4 -4
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +361 -303
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +229 -216
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +19 -19
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +39 -38
- package/dist/node_modules/@serendie/design-token/dist/panda-tokens.js +823 -20
- package/dist/node_modules/@serendie/design-token/dist/tokens.js +346 -25
- package/dist/node_modules/@zag-js/accordion/dist/index.js +12 -12
- package/dist/node_modules/@zag-js/aria-hidden/dist/index.js +13 -62
- package/dist/node_modules/@zag-js/avatar/dist/index.js +12 -10
- package/dist/node_modules/@zag-js/checkbox/dist/index.js +99 -92
- package/dist/node_modules/@zag-js/collapsible/dist/index.js +5 -5
- package/dist/node_modules/@zag-js/collection/dist/index.js +21 -21
- package/dist/node_modules/@zag-js/combobox/dist/index.js +30 -31
- package/dist/node_modules/@zag-js/core/dist/index.js +285 -320
- package/dist/node_modules/@zag-js/dialog/dist/index.js +56 -62
- package/dist/node_modules/@zag-js/dismissable/dist/index.js +3 -3
- package/dist/node_modules/@zag-js/dom-event/dist/index.js +88 -115
- package/dist/node_modules/@zag-js/dom-query/dist/index.js +2 -2
- package/dist/node_modules/@zag-js/focus-visible/dist/index.js +73 -0
- package/dist/node_modules/@zag-js/interact-outside/dist/index.js +33 -33
- package/dist/node_modules/@zag-js/menu/dist/index.js +81 -77
- package/dist/node_modules/@zag-js/popper/dist/index.js +86 -79
- package/dist/node_modules/@zag-js/radio-group/dist/index.js +116 -109
- package/dist/node_modules/@zag-js/react/dist/index.js +44 -43
- package/dist/node_modules/@zag-js/select/dist/index.js +203 -231
- package/dist/node_modules/@zag-js/store/dist/index.js +110 -110
- package/dist/node_modules/@zag-js/switch/dist/index.js +62 -55
- package/dist/node_modules/@zag-js/tabs/dist/index.js +64 -61
- package/dist/node_modules/@zag-js/toast/dist/index.js +174 -173
- package/dist/node_modules/@zag-js/utils/dist/index.js +93 -71
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +52 -0
- package/dist/node_modules/focus-trap/dist/focus-trap.esm.js +217 -219
- package/dist/preset.d.ts +807 -4
- package/dist/{ui/styled-system → styled-system}/css/css.js +5 -6
- package/dist/{ui/styled-system → styled-system}/css/cva.js +4 -4
- package/dist/{ui/styled-system → styled-system}/css/sva.js +3 -3
- package/dist/styled-system/jsx/is-valid-prop.js +6 -0
- package/dist/styles.css +1 -1
- package/dist/tokens/getToken.d.ts +324 -3
- package/dist/tokens/index.d.ts +806 -3
- package/package.json +31 -5
- package/styled-system/css/css.js +1 -1
- package/styled-system/jsx/is-valid-prop.js +1 -1
- package/styled-system/themes/theme-asagi.json +1 -1
- package/styled-system/themes/theme-kurikawa.json +1 -1
- package/styled-system/themes/theme-sumire.json +1 -1
- package/styled-system/themes/theme-tsutsuji.json +1 -1
- package/styled-system/tokens/index.js +1238 -54
- package/styled-system/tokens/tokens.d.ts +3 -3
- package/styled-system/types/conditions.d.ts +2 -2
- package/styled-system/types/prop-type.d.ts +1 -1
- package/dist/ui/styled-system/jsx/is-valid-prop.js +0 -6
- /package/dist/{ui/styled-system → styled-system}/css/conditions.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/css/cx.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/helpers.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/box.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/factory-helper.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/jsx/factory.js +0 -0
- /package/dist/{ui/styled-system → styled-system}/patterns/box.js +0 -0
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
import { isFocusable as G, tabbable as
|
|
1
|
+
import { isFocusable as G, tabbable as ne, focusable as ae, isTabbable as T, getTabIndex as K } from "../../tabbable/dist/index.esm.js";
|
|
2
2
|
/*!
|
|
3
|
-
* focus-trap 7.
|
|
3
|
+
* focus-trap 7.6.0
|
|
4
4
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
5
5
|
*/
|
|
6
|
-
function
|
|
6
|
+
function re(u, n, o) {
|
|
7
|
+
return (n = oe(n)) in u ? Object.defineProperty(u, n, {
|
|
8
|
+
value: o,
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
configurable: !0,
|
|
11
|
+
writable: !0
|
|
12
|
+
}) : u[n] = o, u;
|
|
13
|
+
}
|
|
14
|
+
function Q(u, n) {
|
|
7
15
|
var o = Object.keys(u);
|
|
8
16
|
if (Object.getOwnPropertySymbols) {
|
|
9
17
|
var i = Object.getOwnPropertySymbols(u);
|
|
10
|
-
|
|
18
|
+
n && (i = i.filter(function(m) {
|
|
11
19
|
return Object.getOwnPropertyDescriptor(u, m).enumerable;
|
|
12
20
|
})), o.push.apply(o, i);
|
|
13
21
|
}
|
|
14
22
|
return o;
|
|
15
23
|
}
|
|
16
|
-
function
|
|
17
|
-
for (var
|
|
18
|
-
var o = arguments[
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(u, Object.getOwnPropertyDescriptors(o)) :
|
|
24
|
+
function W(u) {
|
|
25
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
26
|
+
var o = arguments[n] != null ? arguments[n] : {};
|
|
27
|
+
n % 2 ? Q(Object(o), !0).forEach(function(i) {
|
|
28
|
+
re(u, i, o[i]);
|
|
29
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(u, Object.getOwnPropertyDescriptors(o)) : Q(Object(o)).forEach(function(i) {
|
|
22
30
|
Object.defineProperty(u, i, Object.getOwnPropertyDescriptor(o, i));
|
|
23
31
|
});
|
|
24
32
|
}
|
|
25
33
|
return u;
|
|
26
34
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
value: o,
|
|
30
|
-
enumerable: !0,
|
|
31
|
-
configurable: !0,
|
|
32
|
-
writable: !0
|
|
33
|
-
}) : u[a] = o, u;
|
|
34
|
-
}
|
|
35
|
-
function re(u, a) {
|
|
36
|
-
if (typeof u != "object" || u === null) return u;
|
|
35
|
+
function ie(u, n) {
|
|
36
|
+
if (typeof u != "object" || !u) return u;
|
|
37
37
|
var o = u[Symbol.toPrimitive];
|
|
38
38
|
if (o !== void 0) {
|
|
39
|
-
var i = o.call(u,
|
|
39
|
+
var i = o.call(u, n);
|
|
40
40
|
if (typeof i != "object") return i;
|
|
41
41
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
42
42
|
}
|
|
43
|
-
return (
|
|
43
|
+
return (n === "string" ? String : Number)(u);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
var
|
|
47
|
-
return typeof
|
|
45
|
+
function oe(u) {
|
|
46
|
+
var n = ie(u, "string");
|
|
47
|
+
return typeof n == "symbol" ? n : n + "";
|
|
48
48
|
}
|
|
49
|
-
var
|
|
50
|
-
activateTrap: function(
|
|
51
|
-
if (
|
|
52
|
-
var i =
|
|
49
|
+
var X = {
|
|
50
|
+
activateTrap: function(n, o) {
|
|
51
|
+
if (n.length > 0) {
|
|
52
|
+
var i = n[n.length - 1];
|
|
53
53
|
i !== o && i.pause();
|
|
54
54
|
}
|
|
55
|
-
var m =
|
|
56
|
-
m === -1 ||
|
|
55
|
+
var m = n.indexOf(o);
|
|
56
|
+
m === -1 || n.splice(m, 1), n.push(o);
|
|
57
57
|
},
|
|
58
|
-
deactivateTrap: function(
|
|
59
|
-
var i =
|
|
60
|
-
i !== -1 &&
|
|
58
|
+
deactivateTrap: function(n, o) {
|
|
59
|
+
var i = n.indexOf(o);
|
|
60
|
+
i !== -1 && n.splice(i, 1), n.length > 0 && n[n.length - 1].unpause();
|
|
61
61
|
}
|
|
62
|
-
},
|
|
63
|
-
return
|
|
64
|
-
},
|
|
65
|
-
return (
|
|
66
|
-
},
|
|
67
|
-
return (
|
|
68
|
-
},
|
|
69
|
-
return
|
|
70
|
-
},
|
|
71
|
-
return
|
|
72
|
-
},
|
|
73
|
-
return setTimeout(
|
|
74
|
-
},
|
|
62
|
+
}, ue = function(n) {
|
|
63
|
+
return n.tagName && n.tagName.toLowerCase() === "input" && typeof n.select == "function";
|
|
64
|
+
}, se = function(n) {
|
|
65
|
+
return (n == null ? void 0 : n.key) === "Escape" || (n == null ? void 0 : n.key) === "Esc" || (n == null ? void 0 : n.keyCode) === 27;
|
|
66
|
+
}, B = function(n) {
|
|
67
|
+
return (n == null ? void 0 : n.key) === "Tab" || (n == null ? void 0 : n.keyCode) === 9;
|
|
68
|
+
}, ce = function(n) {
|
|
69
|
+
return B(n) && !n.shiftKey;
|
|
70
|
+
}, le = function(n) {
|
|
71
|
+
return B(n) && n.shiftKey;
|
|
72
|
+
}, Z = function(n) {
|
|
73
|
+
return setTimeout(n, 0);
|
|
74
|
+
}, _ = function(n, o) {
|
|
75
75
|
var i = -1;
|
|
76
|
-
return
|
|
76
|
+
return n.every(function(m, s) {
|
|
77
77
|
return o(m) ? (i = s, !1) : !0;
|
|
78
78
|
}), i;
|
|
79
|
-
},
|
|
79
|
+
}, L = function(n) {
|
|
80
80
|
for (var o = arguments.length, i = new Array(o > 1 ? o - 1 : 0), m = 1; m < o; m++)
|
|
81
81
|
i[m - 1] = arguments[m];
|
|
82
|
-
return typeof
|
|
83
|
-
},
|
|
84
|
-
return
|
|
85
|
-
},
|
|
86
|
-
var i = (o == null ? void 0 : o.document) || document, m = (o == null ? void 0 : o.trapStack) ||
|
|
82
|
+
return typeof n == "function" ? n.apply(void 0, i) : n;
|
|
83
|
+
}, A = function(n) {
|
|
84
|
+
return n.target.shadowRoot && typeof n.composedPath == "function" ? n.composedPath()[0] : n.target;
|
|
85
|
+
}, fe = [], ve = function(n, o) {
|
|
86
|
+
var i = (o == null ? void 0 : o.document) || document, m = (o == null ? void 0 : o.trapStack) || fe, s = W({
|
|
87
87
|
returnFocusOnDeactivate: !0,
|
|
88
88
|
escapeDeactivates: !0,
|
|
89
89
|
delayInitialFocus: !0,
|
|
90
|
-
isKeyForward:
|
|
91
|
-
isKeyBackward:
|
|
92
|
-
}, o),
|
|
90
|
+
isKeyForward: ce,
|
|
91
|
+
isKeyBackward: le
|
|
92
|
+
}, o), a = {
|
|
93
93
|
// containers given to createFocusTrap()
|
|
94
94
|
// @type {Array<HTMLElement>}
|
|
95
95
|
containers: [],
|
|
@@ -125,62 +125,62 @@ var Q = {
|
|
|
125
125
|
delayInitialFocusTimer: void 0,
|
|
126
126
|
// the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
|
|
127
127
|
recentNavEvent: void 0
|
|
128
|
-
},
|
|
129
|
-
return
|
|
130
|
-
}, F = function(
|
|
131
|
-
var r = typeof (
|
|
132
|
-
return
|
|
128
|
+
}, y, h = function(e, t, r) {
|
|
129
|
+
return e && e[t] !== void 0 ? e[t] : s[r || t];
|
|
130
|
+
}, F = function(e, t) {
|
|
131
|
+
var r = typeof (t == null ? void 0 : t.composedPath) == "function" ? t.composedPath() : void 0;
|
|
132
|
+
return a.containerGroups.findIndex(function(c) {
|
|
133
133
|
var l = c.container, d = c.tabbableNodes;
|
|
134
|
-
return l.contains(
|
|
134
|
+
return l.contains(e) || // fall back to explicit tabbable search which will take into consideration any
|
|
135
135
|
// web components if the `tabbableOptions.getShadowRoot` option was used for
|
|
136
136
|
// the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
|
|
137
137
|
// look inside web components even if open)
|
|
138
138
|
(r == null ? void 0 : r.includes(l)) || d.find(function(v) {
|
|
139
|
-
return v ===
|
|
139
|
+
return v === e;
|
|
140
140
|
});
|
|
141
141
|
});
|
|
142
|
-
}, E = function(
|
|
143
|
-
var
|
|
144
|
-
if (typeof
|
|
142
|
+
}, E = function(e) {
|
|
143
|
+
var t = s[e];
|
|
144
|
+
if (typeof t == "function") {
|
|
145
145
|
for (var r = arguments.length, c = new Array(r > 1 ? r - 1 : 0), l = 1; l < r; l++)
|
|
146
146
|
c[l - 1] = arguments[l];
|
|
147
|
-
|
|
147
|
+
t = t.apply(void 0, c);
|
|
148
148
|
}
|
|
149
|
-
if (
|
|
150
|
-
if (
|
|
151
|
-
return
|
|
152
|
-
throw new Error("`".concat(
|
|
149
|
+
if (t === !0 && (t = void 0), !t) {
|
|
150
|
+
if (t === void 0 || t === !1)
|
|
151
|
+
return t;
|
|
152
|
+
throw new Error("`".concat(e, "` was specified but was not a node, or did not return a node"));
|
|
153
153
|
}
|
|
154
|
-
var d =
|
|
155
|
-
if (typeof
|
|
156
|
-
throw new Error("`".concat(
|
|
154
|
+
var d = t;
|
|
155
|
+
if (typeof t == "string" && (d = i.querySelector(t), !d))
|
|
156
|
+
throw new Error("`".concat(e, "` as selector refers to no known node"));
|
|
157
157
|
return d;
|
|
158
|
-
},
|
|
159
|
-
var
|
|
160
|
-
if (
|
|
158
|
+
}, k = function() {
|
|
159
|
+
var e = E("initialFocus");
|
|
160
|
+
if (e === !1)
|
|
161
161
|
return !1;
|
|
162
|
-
if (
|
|
162
|
+
if (e === void 0 || !G(e, s.tabbableOptions))
|
|
163
163
|
if (F(i.activeElement) >= 0)
|
|
164
|
-
|
|
164
|
+
e = i.activeElement;
|
|
165
165
|
else {
|
|
166
|
-
var
|
|
167
|
-
|
|
166
|
+
var t = a.tabbableGroups[0], r = t && t.firstTabbableNode;
|
|
167
|
+
e = r || E("fallbackFocus");
|
|
168
168
|
}
|
|
169
|
-
if (!
|
|
169
|
+
if (!e)
|
|
170
170
|
throw new Error("Your focus-trap needs to have at least one focusable element");
|
|
171
|
-
return
|
|
172
|
-
},
|
|
173
|
-
if (
|
|
174
|
-
var
|
|
171
|
+
return e;
|
|
172
|
+
}, P = function() {
|
|
173
|
+
if (a.containerGroups = a.containers.map(function(e) {
|
|
174
|
+
var t = ne(e, s.tabbableOptions), r = ae(e, s.tabbableOptions), c = t.length > 0 ? t[0] : void 0, l = t.length > 0 ? t[t.length - 1] : void 0, d = r.find(function(b) {
|
|
175
175
|
return T(b);
|
|
176
176
|
}), v = r.slice().reverse().find(function(b) {
|
|
177
177
|
return T(b);
|
|
178
|
-
}), p = !!
|
|
178
|
+
}), p = !!t.find(function(b) {
|
|
179
179
|
return K(b) > 0;
|
|
180
180
|
});
|
|
181
181
|
return {
|
|
182
|
-
container:
|
|
183
|
-
tabbableNodes:
|
|
182
|
+
container: e,
|
|
183
|
+
tabbableNodes: t,
|
|
184
184
|
focusableNodes: r,
|
|
185
185
|
/** True if at least one node with positive `tabindex` was found in this container. */
|
|
186
186
|
posTabIndexesFound: p,
|
|
@@ -208,74 +208,74 @@ var Q = {
|
|
|
208
208
|
* @returns {HTMLElement|undefined} The next tabbable node, if any.
|
|
209
209
|
*/
|
|
210
210
|
nextTabbableNode: function(N) {
|
|
211
|
-
var O = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0,
|
|
212
|
-
return
|
|
211
|
+
var O = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !0, w = t.indexOf(N);
|
|
212
|
+
return w < 0 ? O ? r.slice(r.indexOf(N) + 1).find(function(R) {
|
|
213
213
|
return T(R);
|
|
214
214
|
}) : r.slice(0, r.indexOf(N)).reverse().find(function(R) {
|
|
215
215
|
return T(R);
|
|
216
|
-
}) :
|
|
216
|
+
}) : t[w + (O ? 1 : -1)];
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
|
-
}),
|
|
220
|
-
return
|
|
221
|
-
}),
|
|
219
|
+
}), a.tabbableGroups = a.containerGroups.filter(function(e) {
|
|
220
|
+
return e.tabbableNodes.length > 0;
|
|
221
|
+
}), a.tabbableGroups.length <= 0 && !E("fallbackFocus"))
|
|
222
222
|
throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
|
|
223
|
-
if (
|
|
224
|
-
return
|
|
225
|
-
}) &&
|
|
223
|
+
if (a.containerGroups.find(function(e) {
|
|
224
|
+
return e.posTabIndexesFound;
|
|
225
|
+
}) && a.containerGroups.length > 1)
|
|
226
226
|
throw new Error("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.");
|
|
227
|
-
},
|
|
228
|
-
var
|
|
229
|
-
if (
|
|
230
|
-
return
|
|
231
|
-
},
|
|
232
|
-
if (
|
|
233
|
-
if (!
|
|
234
|
-
|
|
227
|
+
}, S = function(e) {
|
|
228
|
+
var t = e.activeElement;
|
|
229
|
+
if (t)
|
|
230
|
+
return t.shadowRoot && t.shadowRoot.activeElement !== null ? S(t.shadowRoot) : t;
|
|
231
|
+
}, g = function(e) {
|
|
232
|
+
if (e !== !1 && e !== S(document)) {
|
|
233
|
+
if (!e || !e.focus) {
|
|
234
|
+
g(k());
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
|
-
|
|
237
|
+
e.focus({
|
|
238
238
|
preventScroll: !!s.preventScroll
|
|
239
|
-
}),
|
|
239
|
+
}), a.mostRecentlyFocusedNode = e, ue(e) && e.select();
|
|
240
240
|
}
|
|
241
|
-
},
|
|
242
|
-
var
|
|
243
|
-
return
|
|
244
|
-
},
|
|
245
|
-
var
|
|
246
|
-
|
|
241
|
+
}, U = function(e) {
|
|
242
|
+
var t = E("setReturnFocus", e);
|
|
243
|
+
return t || (t === !1 ? !1 : e);
|
|
244
|
+
}, q = function(e) {
|
|
245
|
+
var t = e.target, r = e.event, c = e.isBackward, l = c === void 0 ? !1 : c;
|
|
246
|
+
t = t || A(r), P();
|
|
247
247
|
var d = null;
|
|
248
|
-
if (
|
|
249
|
-
var v = F(
|
|
248
|
+
if (a.tabbableGroups.length > 0) {
|
|
249
|
+
var v = F(t, r), p = v >= 0 ? a.containerGroups[v] : void 0;
|
|
250
250
|
if (v < 0)
|
|
251
|
-
l ? d =
|
|
251
|
+
l ? d = a.tabbableGroups[a.tabbableGroups.length - 1].lastTabbableNode : d = a.tabbableGroups[0].firstTabbableNode;
|
|
252
252
|
else if (l) {
|
|
253
|
-
var b =
|
|
253
|
+
var b = _(a.tabbableGroups, function(I) {
|
|
254
254
|
var x = I.firstTabbableNode;
|
|
255
|
-
return
|
|
255
|
+
return t === x;
|
|
256
256
|
});
|
|
257
|
-
if (b < 0 && (p.container ===
|
|
258
|
-
var N = b === 0 ?
|
|
259
|
-
d = K(
|
|
260
|
-
} else
|
|
257
|
+
if (b < 0 && (p.container === t || G(t, s.tabbableOptions) && !T(t, s.tabbableOptions) && !p.nextTabbableNode(t, !1)) && (b = v), b >= 0) {
|
|
258
|
+
var N = b === 0 ? a.tabbableGroups.length - 1 : b - 1, O = a.tabbableGroups[N];
|
|
259
|
+
d = K(t) >= 0 ? O.lastTabbableNode : O.lastDomTabbableNode;
|
|
260
|
+
} else B(r) || (d = p.nextTabbableNode(t, !1));
|
|
261
261
|
} else {
|
|
262
|
-
var
|
|
262
|
+
var w = _(a.tabbableGroups, function(I) {
|
|
263
263
|
var x = I.lastTabbableNode;
|
|
264
|
-
return
|
|
264
|
+
return t === x;
|
|
265
265
|
});
|
|
266
|
-
if (
|
|
267
|
-
var R =
|
|
268
|
-
d = K(
|
|
269
|
-
} else
|
|
266
|
+
if (w < 0 && (p.container === t || G(t, s.tabbableOptions) && !T(t, s.tabbableOptions) && !p.nextTabbableNode(t)) && (w = v), w >= 0) {
|
|
267
|
+
var R = w === a.tabbableGroups.length - 1 ? 0 : w + 1, J = a.tabbableGroups[R];
|
|
268
|
+
d = K(t) >= 0 ? J.firstTabbableNode : J.firstDomTabbableNode;
|
|
269
|
+
} else B(r) || (d = p.nextTabbableNode(t));
|
|
270
270
|
}
|
|
271
271
|
} else
|
|
272
272
|
d = E("fallbackFocus");
|
|
273
273
|
return d;
|
|
274
|
-
},
|
|
275
|
-
var
|
|
276
|
-
if (!(F(
|
|
277
|
-
if (
|
|
278
|
-
|
|
274
|
+
}, j = function(e) {
|
|
275
|
+
var t = A(e);
|
|
276
|
+
if (!(F(t, e) >= 0)) {
|
|
277
|
+
if (L(s.clickOutsideDeactivates, e)) {
|
|
278
|
+
y.deactivate({
|
|
279
279
|
// NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
|
|
280
280
|
// which will result in the outside click setting focus to the node
|
|
281
281
|
// that was clicked (and if not focusable, to "nothing"); by setting
|
|
@@ -286,148 +286,146 @@ var Q = {
|
|
|
286
286
|
});
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
|
|
289
|
+
L(s.allowOutsideClick, e) || e.preventDefault();
|
|
290
290
|
}
|
|
291
|
-
},
|
|
292
|
-
var
|
|
293
|
-
if (r ||
|
|
294
|
-
r && (
|
|
291
|
+
}, H = function(e) {
|
|
292
|
+
var t = A(e), r = F(t, e) >= 0;
|
|
293
|
+
if (r || t instanceof Document)
|
|
294
|
+
r && (a.mostRecentlyFocusedNode = t);
|
|
295
295
|
else {
|
|
296
|
-
|
|
296
|
+
e.stopImmediatePropagation();
|
|
297
297
|
var c, l = !0;
|
|
298
|
-
if (
|
|
299
|
-
if (K(
|
|
300
|
-
var d = F(
|
|
298
|
+
if (a.mostRecentlyFocusedNode)
|
|
299
|
+
if (K(a.mostRecentlyFocusedNode) > 0) {
|
|
300
|
+
var d = F(a.mostRecentlyFocusedNode), v = a.containerGroups[d].tabbableNodes;
|
|
301
301
|
if (v.length > 0) {
|
|
302
302
|
var p = v.findIndex(function(b) {
|
|
303
|
-
return b ===
|
|
303
|
+
return b === a.mostRecentlyFocusedNode;
|
|
304
304
|
});
|
|
305
|
-
p >= 0 && (s.isKeyForward(
|
|
305
|
+
p >= 0 && (s.isKeyForward(a.recentNavEvent) ? p + 1 < v.length && (c = v[p + 1], l = !1) : p - 1 >= 0 && (c = v[p - 1], l = !1));
|
|
306
306
|
}
|
|
307
307
|
} else
|
|
308
|
-
|
|
308
|
+
a.containerGroups.some(function(b) {
|
|
309
309
|
return b.tabbableNodes.some(function(N) {
|
|
310
310
|
return K(N) > 0;
|
|
311
311
|
});
|
|
312
312
|
}) || (l = !1);
|
|
313
313
|
else
|
|
314
314
|
l = !1;
|
|
315
|
-
l && (c =
|
|
315
|
+
l && (c = q({
|
|
316
316
|
// move FROM the MRU node, not event-related node (which will be the node that is
|
|
317
317
|
// outside the trap causing the focus escape we're trying to fix)
|
|
318
|
-
target:
|
|
319
|
-
isBackward: s.isKeyBackward(
|
|
320
|
-
})),
|
|
318
|
+
target: a.mostRecentlyFocusedNode,
|
|
319
|
+
isBackward: s.isKeyBackward(a.recentNavEvent)
|
|
320
|
+
})), g(c || a.mostRecentlyFocusedNode || k());
|
|
321
321
|
}
|
|
322
|
-
|
|
323
|
-
},
|
|
324
|
-
var
|
|
325
|
-
|
|
326
|
-
var r =
|
|
327
|
-
event:
|
|
328
|
-
isBackward:
|
|
322
|
+
a.recentNavEvent = void 0;
|
|
323
|
+
}, ee = function(e) {
|
|
324
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : !1;
|
|
325
|
+
a.recentNavEvent = e;
|
|
326
|
+
var r = q({
|
|
327
|
+
event: e,
|
|
328
|
+
isBackward: t
|
|
329
329
|
});
|
|
330
|
-
r && (
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
w(P());
|
|
344
|
-
}) : w(P()), i.addEventListener("focusin", q, !0), i.addEventListener("mousedown", A, {
|
|
330
|
+
r && (B(e) && e.preventDefault(), g(r));
|
|
331
|
+
}, M = function(e) {
|
|
332
|
+
(s.isKeyForward(e) || s.isKeyBackward(e)) && ee(e, s.isKeyBackward(e));
|
|
333
|
+
}, Y = function(e) {
|
|
334
|
+
se(e) && L(s.escapeDeactivates, e) !== !1 && (e.preventDefault(), y.deactivate());
|
|
335
|
+
}, V = function(e) {
|
|
336
|
+
var t = A(e);
|
|
337
|
+
F(t, e) >= 0 || L(s.clickOutsideDeactivates, e) || L(s.allowOutsideClick, e) || (e.preventDefault(), e.stopImmediatePropagation());
|
|
338
|
+
}, $ = function() {
|
|
339
|
+
if (a.active)
|
|
340
|
+
return X.activateTrap(m, y), a.delayInitialFocusTimer = s.delayInitialFocus ? Z(function() {
|
|
341
|
+
g(k());
|
|
342
|
+
}) : g(k()), i.addEventListener("focusin", H, !0), i.addEventListener("mousedown", j, {
|
|
345
343
|
capture: !0,
|
|
346
344
|
passive: !1
|
|
347
|
-
}), i.addEventListener("touchstart",
|
|
345
|
+
}), i.addEventListener("touchstart", j, {
|
|
348
346
|
capture: !0,
|
|
349
347
|
passive: !1
|
|
350
|
-
}), i.addEventListener("click",
|
|
348
|
+
}), i.addEventListener("click", V, {
|
|
351
349
|
capture: !0,
|
|
352
350
|
passive: !1
|
|
353
|
-
}), i.addEventListener("keydown",
|
|
351
|
+
}), i.addEventListener("keydown", M, {
|
|
354
352
|
capture: !0,
|
|
355
353
|
passive: !1
|
|
356
|
-
}),
|
|
357
|
-
},
|
|
358
|
-
if (
|
|
359
|
-
return i.removeEventListener("focusin",
|
|
360
|
-
},
|
|
361
|
-
var
|
|
354
|
+
}), i.addEventListener("keydown", Y), y;
|
|
355
|
+
}, z = function() {
|
|
356
|
+
if (a.active)
|
|
357
|
+
return i.removeEventListener("focusin", H, !0), i.removeEventListener("mousedown", j, !0), i.removeEventListener("touchstart", j, !0), i.removeEventListener("click", V, !0), i.removeEventListener("keydown", M, !0), i.removeEventListener("keydown", Y), y;
|
|
358
|
+
}, te = function(e) {
|
|
359
|
+
var t = e.some(function(r) {
|
|
362
360
|
var c = Array.from(r.removedNodes);
|
|
363
361
|
return c.some(function(l) {
|
|
364
|
-
return l ===
|
|
362
|
+
return l === a.mostRecentlyFocusedNode;
|
|
365
363
|
});
|
|
366
364
|
});
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
|
|
370
|
-
|
|
365
|
+
t && g(k());
|
|
366
|
+
}, C = typeof window < "u" && "MutationObserver" in window ? new MutationObserver(te) : void 0, D = function() {
|
|
367
|
+
C && (C.disconnect(), a.active && !a.paused && a.containers.map(function(e) {
|
|
368
|
+
C.observe(e, {
|
|
371
369
|
subtree: !0,
|
|
372
370
|
childList: !0
|
|
373
371
|
});
|
|
374
372
|
}));
|
|
375
373
|
};
|
|
376
|
-
return
|
|
374
|
+
return y = {
|
|
377
375
|
get active() {
|
|
378
|
-
return
|
|
376
|
+
return a.active;
|
|
379
377
|
},
|
|
380
378
|
get paused() {
|
|
381
|
-
return
|
|
379
|
+
return a.paused;
|
|
382
380
|
},
|
|
383
|
-
activate: function(
|
|
384
|
-
if (
|
|
381
|
+
activate: function(e) {
|
|
382
|
+
if (a.active)
|
|
385
383
|
return this;
|
|
386
|
-
var
|
|
387
|
-
c ||
|
|
384
|
+
var t = h(e, "onActivate"), r = h(e, "onPostActivate"), c = h(e, "checkCanFocusTrap");
|
|
385
|
+
c || P(), a.active = !0, a.paused = !1, a.nodeFocusedBeforeActivation = i.activeElement, t == null || t();
|
|
388
386
|
var l = function() {
|
|
389
|
-
c &&
|
|
387
|
+
c && P(), $(), D(), r == null || r();
|
|
390
388
|
};
|
|
391
|
-
return c ? (c(
|
|
389
|
+
return c ? (c(a.containers.concat()).then(l, l), this) : (l(), this);
|
|
392
390
|
},
|
|
393
|
-
deactivate: function(
|
|
394
|
-
if (!
|
|
391
|
+
deactivate: function(e) {
|
|
392
|
+
if (!a.active)
|
|
395
393
|
return this;
|
|
396
|
-
var
|
|
394
|
+
var t = W({
|
|
397
395
|
onDeactivate: s.onDeactivate,
|
|
398
396
|
onPostDeactivate: s.onPostDeactivate,
|
|
399
397
|
checkCanReturnFocus: s.checkCanReturnFocus
|
|
400
|
-
},
|
|
401
|
-
clearTimeout(
|
|
402
|
-
var r = h(
|
|
398
|
+
}, e);
|
|
399
|
+
clearTimeout(a.delayInitialFocusTimer), a.delayInitialFocusTimer = void 0, z(), a.active = !1, a.paused = !1, D(), X.deactivateTrap(m, y);
|
|
400
|
+
var r = h(t, "onDeactivate"), c = h(t, "onPostDeactivate"), l = h(t, "checkCanReturnFocus"), d = h(t, "returnFocus", "returnFocusOnDeactivate");
|
|
403
401
|
r == null || r();
|
|
404
402
|
var v = function() {
|
|
405
|
-
|
|
406
|
-
d &&
|
|
403
|
+
Z(function() {
|
|
404
|
+
d && g(U(a.nodeFocusedBeforeActivation)), c == null || c();
|
|
407
405
|
});
|
|
408
406
|
};
|
|
409
|
-
return d && l ? (l(
|
|
407
|
+
return d && l ? (l(U(a.nodeFocusedBeforeActivation)).then(v, v), this) : (v(), this);
|
|
410
408
|
},
|
|
411
|
-
pause: function(
|
|
412
|
-
if (
|
|
409
|
+
pause: function(e) {
|
|
410
|
+
if (a.paused || !a.active)
|
|
413
411
|
return this;
|
|
414
|
-
var
|
|
415
|
-
return
|
|
412
|
+
var t = h(e, "onPause"), r = h(e, "onPostPause");
|
|
413
|
+
return a.paused = !0, t == null || t(), z(), D(), r == null || r(), this;
|
|
416
414
|
},
|
|
417
|
-
unpause: function(
|
|
418
|
-
if (!
|
|
415
|
+
unpause: function(e) {
|
|
416
|
+
if (!a.paused || !a.active)
|
|
419
417
|
return this;
|
|
420
|
-
var
|
|
421
|
-
return
|
|
418
|
+
var t = h(e, "onUnpause"), r = h(e, "onPostUnpause");
|
|
419
|
+
return a.paused = !1, t == null || t(), P(), $(), D(), r == null || r(), this;
|
|
422
420
|
},
|
|
423
|
-
updateContainerElements: function(
|
|
424
|
-
var
|
|
425
|
-
return
|
|
421
|
+
updateContainerElements: function(e) {
|
|
422
|
+
var t = [].concat(e).filter(Boolean);
|
|
423
|
+
return a.containers = t.map(function(r) {
|
|
426
424
|
return typeof r == "string" ? i.querySelector(r) : r;
|
|
427
|
-
}),
|
|
425
|
+
}), a.active && P(), D(), this;
|
|
428
426
|
}
|
|
429
|
-
},
|
|
427
|
+
}, y.updateContainerElements(n), y;
|
|
430
428
|
};
|
|
431
429
|
export {
|
|
432
|
-
|
|
430
|
+
ve as createFocusTrap
|
|
433
431
|
};
|