@m3e/core 1.0.6 → 1.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/a11y.js +1420 -1033
- package/dist/a11y.js.map +1 -1
- package/dist/a11y.min.js +10 -23
- package/dist/a11y.min.js.map +1 -1
- package/dist/anchoring.js +2 -8
- package/dist/anchoring.js.map +1 -1
- package/dist/anchoring.min.js +1 -1
- package/dist/anchoring.min.js.map +1 -1
- package/dist/custom-elements.json +4231 -4024
- package/dist/html-custom-data.json +0 -5
- package/dist/index.js +4007 -3561
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +9 -480
- package/dist/index.min.js.map +1 -1
- package/dist/src/a11y/list-key/ListKeyManager.d.ts +11 -0
- package/dist/src/a11y/list-key/ListKeyManager.d.ts.map +1 -1
- package/dist/src/anchoring/positionAnchor.d.ts +2 -2
- package/dist/src/anchoring/positionAnchor.d.ts.map +1 -1
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/RippleElement.d.ts +0 -5
- package/dist/src/shared/primitives/RippleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/SlideElement.d.ts.map +1 -1
- package/dist/src/shared/utils/generateClipPaths.d.ts +8 -0
- package/dist/src/shared/utils/generateClipPaths.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +1 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -1
- package/package.json +1 -15
package/dist/a11y.js
CHANGED
|
@@ -18,33 +18,30 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
18
18
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
19
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
20
|
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
46
|
-
var e = new Error(message);
|
|
47
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
23
|
+
|
|
24
|
+
function __decorate(decorators, target, key, desc) {
|
|
25
|
+
var c = arguments.length,
|
|
26
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
27
|
+
d;
|
|
28
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
29
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
30
|
+
}
|
|
31
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
32
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
+
}
|
|
36
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
37
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
38
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
39
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
40
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
41
|
+
}
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
48
45
|
};
|
|
49
46
|
|
|
50
47
|
/** The modifier keys. */
|
|
@@ -53,120 +50,120 @@ const ModifierKeys = ["alt", "shift", "ctrl", "meta"];
|
|
|
53
50
|
/** Specifies known key code values. */
|
|
54
51
|
var KeyCode;
|
|
55
52
|
(function (KeyCode) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
53
|
+
KeyCode[KeyCode["Backspace"] = 8] = "Backspace";
|
|
54
|
+
KeyCode[KeyCode["Tab"] = 9] = "Tab";
|
|
55
|
+
KeyCode[KeyCode["Enter"] = 13] = "Enter";
|
|
56
|
+
KeyCode[KeyCode["Shift"] = 16] = "Shift";
|
|
57
|
+
KeyCode[KeyCode["Ctrl"] = 17] = "Ctrl";
|
|
58
|
+
KeyCode[KeyCode["Alt"] = 18] = "Alt";
|
|
59
|
+
KeyCode[KeyCode["PauseBreak"] = 19] = "PauseBreak";
|
|
60
|
+
KeyCode[KeyCode["CapsLock"] = 20] = "CapsLock";
|
|
61
|
+
KeyCode[KeyCode["Escape"] = 27] = "Escape";
|
|
62
|
+
KeyCode[KeyCode["Space"] = 32] = "Space";
|
|
63
|
+
KeyCode[KeyCode["PageUp"] = 33] = "PageUp";
|
|
64
|
+
KeyCode[KeyCode["PageDown"] = 34] = "PageDown";
|
|
65
|
+
KeyCode[KeyCode["End"] = 35] = "End";
|
|
66
|
+
KeyCode[KeyCode["Home"] = 36] = "Home";
|
|
67
|
+
KeyCode[KeyCode["LeftArrow"] = 37] = "LeftArrow";
|
|
68
|
+
KeyCode[KeyCode["UpArrow"] = 38] = "UpArrow";
|
|
69
|
+
KeyCode[KeyCode["RightArrow"] = 39] = "RightArrow";
|
|
70
|
+
KeyCode[KeyCode["DownArrow"] = 40] = "DownArrow";
|
|
71
|
+
KeyCode[KeyCode["Insert"] = 45] = "Insert";
|
|
72
|
+
KeyCode[KeyCode["Delete"] = 46] = "Delete";
|
|
73
|
+
KeyCode[KeyCode["Zero"] = 48] = "Zero";
|
|
74
|
+
KeyCode[KeyCode["ClosedParen"] = 48] = "ClosedParen";
|
|
75
|
+
KeyCode[KeyCode["One"] = 49] = "One";
|
|
76
|
+
KeyCode[KeyCode["ExclamationMark"] = 49] = "ExclamationMark";
|
|
77
|
+
KeyCode[KeyCode["Two"] = 50] = "Two";
|
|
78
|
+
KeyCode[KeyCode["AtSign"] = 50] = "AtSign";
|
|
79
|
+
KeyCode[KeyCode["Three"] = 51] = "Three";
|
|
80
|
+
KeyCode[KeyCode["PoundSign"] = 51] = "PoundSign";
|
|
81
|
+
KeyCode[KeyCode["Hash"] = 51] = "Hash";
|
|
82
|
+
KeyCode[KeyCode["Four"] = 52] = "Four";
|
|
83
|
+
KeyCode[KeyCode["DollarSign"] = 52] = "DollarSign";
|
|
84
|
+
KeyCode[KeyCode["Five"] = 53] = "Five";
|
|
85
|
+
KeyCode[KeyCode["PercentSign"] = 53] = "PercentSign";
|
|
86
|
+
KeyCode[KeyCode["Six"] = 54] = "Six";
|
|
87
|
+
KeyCode[KeyCode["Caret"] = 54] = "Caret";
|
|
88
|
+
KeyCode[KeyCode["Hat"] = 54] = "Hat";
|
|
89
|
+
KeyCode[KeyCode["Seven"] = 55] = "Seven";
|
|
90
|
+
KeyCode[KeyCode["Ampersand"] = 55] = "Ampersand";
|
|
91
|
+
KeyCode[KeyCode["Eight"] = 56] = "Eight";
|
|
92
|
+
KeyCode[KeyCode["Star"] = 56] = "Star";
|
|
93
|
+
KeyCode[KeyCode["Asterik"] = 56] = "Asterik";
|
|
94
|
+
KeyCode[KeyCode["Nine"] = 57] = "Nine";
|
|
95
|
+
KeyCode[KeyCode["OpenParen"] = 57] = "OpenParen";
|
|
96
|
+
KeyCode[KeyCode["A"] = 65] = "A";
|
|
97
|
+
KeyCode[KeyCode["B"] = 66] = "B";
|
|
98
|
+
KeyCode[KeyCode["C"] = 67] = "C";
|
|
99
|
+
KeyCode[KeyCode["D"] = 68] = "D";
|
|
100
|
+
KeyCode[KeyCode["E"] = 69] = "E";
|
|
101
|
+
KeyCode[KeyCode["F"] = 70] = "F";
|
|
102
|
+
KeyCode[KeyCode["G"] = 71] = "G";
|
|
103
|
+
KeyCode[KeyCode["H"] = 72] = "H";
|
|
104
|
+
KeyCode[KeyCode["I"] = 73] = "I";
|
|
105
|
+
KeyCode[KeyCode["J"] = 74] = "J";
|
|
106
|
+
KeyCode[KeyCode["K"] = 75] = "K";
|
|
107
|
+
KeyCode[KeyCode["L"] = 76] = "L";
|
|
108
|
+
KeyCode[KeyCode["M"] = 77] = "M";
|
|
109
|
+
KeyCode[KeyCode["N"] = 78] = "N";
|
|
110
|
+
KeyCode[KeyCode["O"] = 79] = "O";
|
|
111
|
+
KeyCode[KeyCode["P"] = 80] = "P";
|
|
112
|
+
KeyCode[KeyCode["Q"] = 81] = "Q";
|
|
113
|
+
KeyCode[KeyCode["R"] = 82] = "R";
|
|
114
|
+
KeyCode[KeyCode["S"] = 83] = "S";
|
|
115
|
+
KeyCode[KeyCode["T"] = 84] = "T";
|
|
116
|
+
KeyCode[KeyCode["U"] = 85] = "U";
|
|
117
|
+
KeyCode[KeyCode["V"] = 86] = "V";
|
|
118
|
+
KeyCode[KeyCode["W"] = 87] = "W";
|
|
119
|
+
KeyCode[KeyCode["X"] = 88] = "X";
|
|
120
|
+
KeyCode[KeyCode["Y"] = 89] = "Y";
|
|
121
|
+
KeyCode[KeyCode["Z"] = 90] = "Z";
|
|
122
|
+
KeyCode[KeyCode["LeftWindowKey"] = 91] = "LeftWindowKey";
|
|
123
|
+
KeyCode[KeyCode["RightWindowKey"] = 92] = "RightWindowKey";
|
|
124
|
+
KeyCode[KeyCode["SelectKey"] = 93] = "SelectKey";
|
|
125
|
+
KeyCode[KeyCode["Numpad0"] = 96] = "Numpad0";
|
|
126
|
+
KeyCode[KeyCode["Numpad1"] = 97] = "Numpad1";
|
|
127
|
+
KeyCode[KeyCode["Numpad2"] = 98] = "Numpad2";
|
|
128
|
+
KeyCode[KeyCode["Numpad3"] = 99] = "Numpad3";
|
|
129
|
+
KeyCode[KeyCode["Numpad4"] = 100] = "Numpad4";
|
|
130
|
+
KeyCode[KeyCode["Numpad5"] = 101] = "Numpad5";
|
|
131
|
+
KeyCode[KeyCode["Numpad6"] = 102] = "Numpad6";
|
|
132
|
+
KeyCode[KeyCode["Numpad7"] = 103] = "Numpad7";
|
|
133
|
+
KeyCode[KeyCode["Numpad8"] = 104] = "Numpad8";
|
|
134
|
+
KeyCode[KeyCode["Numpad9"] = 105] = "Numpad9";
|
|
135
|
+
KeyCode[KeyCode["Multiply"] = 106] = "Multiply";
|
|
136
|
+
KeyCode[KeyCode["Add"] = 107] = "Add";
|
|
137
|
+
KeyCode[KeyCode["Subtract"] = 109] = "Subtract";
|
|
138
|
+
KeyCode[KeyCode["DecimalPoint"] = 110] = "DecimalPoint";
|
|
139
|
+
KeyCode[KeyCode["Divide"] = 111] = "Divide";
|
|
140
|
+
KeyCode[KeyCode["F1"] = 112] = "F1";
|
|
141
|
+
KeyCode[KeyCode["F2"] = 113] = "F2";
|
|
142
|
+
KeyCode[KeyCode["F3"] = 114] = "F3";
|
|
143
|
+
KeyCode[KeyCode["F4"] = 115] = "F4";
|
|
144
|
+
KeyCode[KeyCode["F5"] = 116] = "F5";
|
|
145
|
+
KeyCode[KeyCode["F6"] = 117] = "F6";
|
|
146
|
+
KeyCode[KeyCode["F7"] = 118] = "F7";
|
|
147
|
+
KeyCode[KeyCode["F8"] = 119] = "F8";
|
|
148
|
+
KeyCode[KeyCode["F9"] = 120] = "F9";
|
|
149
|
+
KeyCode[KeyCode["F10"] = 121] = "F10";
|
|
150
|
+
KeyCode[KeyCode["F11"] = 122] = "F11";
|
|
151
|
+
KeyCode[KeyCode["F12"] = 123] = "F12";
|
|
152
|
+
KeyCode[KeyCode["NumLock"] = 144] = "NumLock";
|
|
153
|
+
KeyCode[KeyCode["ScrollLock"] = 145] = "ScrollLock";
|
|
154
|
+
KeyCode[KeyCode["SemiColon"] = 186] = "SemiColon";
|
|
155
|
+
KeyCode[KeyCode["Equals"] = 187] = "Equals";
|
|
156
|
+
KeyCode[KeyCode["Comma"] = 188] = "Comma";
|
|
157
|
+
KeyCode[KeyCode["Dash"] = 189] = "Dash";
|
|
158
|
+
KeyCode[KeyCode["Period"] = 190] = "Period";
|
|
159
|
+
KeyCode[KeyCode["UnderScore"] = 189] = "UnderScore";
|
|
160
|
+
KeyCode[KeyCode["PlusSign"] = 187] = "PlusSign";
|
|
161
|
+
KeyCode[KeyCode["ForwardSlash"] = 191] = "ForwardSlash";
|
|
162
|
+
KeyCode[KeyCode["Tilde"] = 192] = "Tilde";
|
|
163
|
+
KeyCode[KeyCode["GraveAccent"] = 192] = "GraveAccent";
|
|
164
|
+
KeyCode[KeyCode["OpenBracket"] = 219] = "OpenBracket";
|
|
165
|
+
KeyCode[KeyCode["ClosedBracket"] = 221] = "ClosedBracket";
|
|
166
|
+
KeyCode[KeyCode["Quote"] = 222] = "Quote";
|
|
170
167
|
})(KeyCode || (KeyCode = {}));
|
|
171
168
|
|
|
172
169
|
/**
|
|
@@ -175,7 +172,7 @@ var KeyCode;
|
|
|
175
172
|
* @returns {number} The key code for `e`.
|
|
176
173
|
*/
|
|
177
174
|
function getKeyCode(e) {
|
|
178
|
-
|
|
175
|
+
return e.which || e.charCode || e.keyCode;
|
|
179
176
|
}
|
|
180
177
|
|
|
181
178
|
/**
|
|
@@ -185,7 +182,7 @@ function getKeyCode(e) {
|
|
|
185
182
|
* @returns {boolean} A value indicating whether a modifier key is pressed.
|
|
186
183
|
*/
|
|
187
184
|
function hasModifierKey(e, ...modifiers) {
|
|
188
|
-
|
|
185
|
+
return modifiers.length ? modifiers.some(x => e[`${x}Key`]) : e.altKey || e.shiftKey || e.ctrlKey || e.metaKey;
|
|
189
186
|
}
|
|
190
187
|
|
|
191
188
|
/**
|
|
@@ -195,7 +192,7 @@ function hasModifierKey(e, ...modifiers) {
|
|
|
195
192
|
* @returns {boolean} A value indicating whether `modifiers` are allowed.
|
|
196
193
|
*/
|
|
197
194
|
function isModifierAllowed(e, ...modifiers) {
|
|
198
|
-
|
|
195
|
+
return ModifierKeys.every(x => !hasModifierKey(e, x) || modifiers.includes(x));
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
/**
|
|
@@ -203,39 +200,395 @@ function isModifierAllowed(e, ...modifiers) {
|
|
|
203
200
|
* Copyright 2017 Google LLC
|
|
204
201
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
205
202
|
*/
|
|
206
|
-
const t$1=t=>(e,o)=>
|
|
203
|
+
const t$1 = t => (e, o) => {
|
|
204
|
+
void 0 !== o ? o.addInitializer(() => {
|
|
205
|
+
customElements.define(t, e);
|
|
206
|
+
}) : customElements.define(t, e);
|
|
207
|
+
};
|
|
207
208
|
|
|
208
209
|
/**
|
|
209
210
|
* @license
|
|
210
211
|
* Copyright 2019 Google LLC
|
|
211
212
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
212
213
|
*/
|
|
213
|
-
const t
|
|
214
|
+
const t = globalThis,
|
|
215
|
+
e$3 = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
|
|
216
|
+
s = Symbol(),
|
|
217
|
+
o$2 = new WeakMap();
|
|
218
|
+
let n$2 = class n {
|
|
219
|
+
constructor(t, e, o) {
|
|
220
|
+
if (this._$cssResult$ = true, o !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
221
|
+
this.cssText = t, this.t = e;
|
|
222
|
+
}
|
|
223
|
+
get styleSheet() {
|
|
224
|
+
let t = this.o;
|
|
225
|
+
const s = this.t;
|
|
226
|
+
if (e$3 && void 0 === t) {
|
|
227
|
+
const e = void 0 !== s && 1 === s.length;
|
|
228
|
+
e && (t = o$2.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$2.set(s, t));
|
|
229
|
+
}
|
|
230
|
+
return t;
|
|
231
|
+
}
|
|
232
|
+
toString() {
|
|
233
|
+
return this.cssText;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
const r$2 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
|
|
237
|
+
S = (s, o) => {
|
|
238
|
+
if (e$3) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
|
|
239
|
+
const o = document.createElement("style"),
|
|
240
|
+
n = t.litNonce;
|
|
241
|
+
void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
c$1 = e$3 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
|
|
245
|
+
let e = "";
|
|
246
|
+
for (const s of t.cssRules) e += s.cssText;
|
|
247
|
+
return r$2(e);
|
|
248
|
+
})(t) : t;
|
|
214
249
|
|
|
215
250
|
/**
|
|
216
251
|
* @license
|
|
217
252
|
* Copyright 2017 Google LLC
|
|
218
253
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
219
|
-
*/
|
|
254
|
+
*/
|
|
255
|
+
const {
|
|
256
|
+
is: i,
|
|
257
|
+
defineProperty: e$2,
|
|
258
|
+
getOwnPropertyDescriptor: h,
|
|
259
|
+
getOwnPropertyNames: r$1,
|
|
260
|
+
getOwnPropertySymbols: o$1,
|
|
261
|
+
getPrototypeOf: n$1
|
|
262
|
+
} = Object,
|
|
263
|
+
a = globalThis,
|
|
264
|
+
c = a.trustedTypes,
|
|
265
|
+
l = c ? c.emptyScript : "",
|
|
266
|
+
p = a.reactiveElementPolyfillSupport,
|
|
267
|
+
d = (t, s) => t,
|
|
268
|
+
u = {
|
|
269
|
+
toAttribute(t, s) {
|
|
270
|
+
switch (s) {
|
|
271
|
+
case Boolean:
|
|
272
|
+
t = t ? l : null;
|
|
273
|
+
break;
|
|
274
|
+
case Object:
|
|
275
|
+
case Array:
|
|
276
|
+
t = null == t ? t : JSON.stringify(t);
|
|
277
|
+
}
|
|
278
|
+
return t;
|
|
279
|
+
},
|
|
280
|
+
fromAttribute(t, s) {
|
|
281
|
+
let i = t;
|
|
282
|
+
switch (s) {
|
|
283
|
+
case Boolean:
|
|
284
|
+
i = null !== t;
|
|
285
|
+
break;
|
|
286
|
+
case Number:
|
|
287
|
+
i = null === t ? null : Number(t);
|
|
288
|
+
break;
|
|
289
|
+
case Object:
|
|
290
|
+
case Array:
|
|
291
|
+
try {
|
|
292
|
+
i = JSON.parse(t);
|
|
293
|
+
} catch (t) {
|
|
294
|
+
i = null;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return i;
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
f = (t, s) => !i(t, s),
|
|
301
|
+
b = {
|
|
302
|
+
attribute: true,
|
|
303
|
+
type: String,
|
|
304
|
+
converter: u,
|
|
305
|
+
reflect: false,
|
|
306
|
+
useDefault: false,
|
|
307
|
+
hasChanged: f
|
|
308
|
+
};
|
|
309
|
+
Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= new WeakMap();
|
|
310
|
+
class y extends HTMLElement {
|
|
311
|
+
static addInitializer(t) {
|
|
312
|
+
this._$Ei(), (this.l ??= []).push(t);
|
|
313
|
+
}
|
|
314
|
+
static get observedAttributes() {
|
|
315
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
316
|
+
}
|
|
317
|
+
static createProperty(t, s = b) {
|
|
318
|
+
if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
|
|
319
|
+
const i = Symbol(),
|
|
320
|
+
h = this.getPropertyDescriptor(t, i, s);
|
|
321
|
+
void 0 !== h && e$2(this.prototype, t, h);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
static getPropertyDescriptor(t, s, i) {
|
|
325
|
+
const {
|
|
326
|
+
get: e,
|
|
327
|
+
set: r
|
|
328
|
+
} = h(this.prototype, t) ?? {
|
|
329
|
+
get() {
|
|
330
|
+
return this[s];
|
|
331
|
+
},
|
|
332
|
+
set(t) {
|
|
333
|
+
this[s] = t;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
return {
|
|
337
|
+
get: e,
|
|
338
|
+
set(s) {
|
|
339
|
+
const h = e?.call(this);
|
|
340
|
+
r?.call(this, s), this.requestUpdate(t, h, i);
|
|
341
|
+
},
|
|
342
|
+
configurable: true,
|
|
343
|
+
enumerable: true
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
static getPropertyOptions(t) {
|
|
347
|
+
return this.elementProperties.get(t) ?? b;
|
|
348
|
+
}
|
|
349
|
+
static _$Ei() {
|
|
350
|
+
if (this.hasOwnProperty(d("elementProperties"))) return;
|
|
351
|
+
const t = n$1(this);
|
|
352
|
+
t.finalize(), void 0 !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
353
|
+
}
|
|
354
|
+
static finalize() {
|
|
355
|
+
if (this.hasOwnProperty(d("finalized"))) return;
|
|
356
|
+
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
|
|
357
|
+
const t = this.properties,
|
|
358
|
+
s = [...r$1(t), ...o$1(t)];
|
|
359
|
+
for (const i of s) this.createProperty(i, t[i]);
|
|
360
|
+
}
|
|
361
|
+
const t = this[Symbol.metadata];
|
|
362
|
+
if (null !== t) {
|
|
363
|
+
const s = litPropertyMetadata.get(t);
|
|
364
|
+
if (void 0 !== s) for (const [t, i] of s) this.elementProperties.set(t, i);
|
|
365
|
+
}
|
|
366
|
+
this._$Eh = new Map();
|
|
367
|
+
for (const [t, s] of this.elementProperties) {
|
|
368
|
+
const i = this._$Eu(t, s);
|
|
369
|
+
void 0 !== i && this._$Eh.set(i, t);
|
|
370
|
+
}
|
|
371
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
372
|
+
}
|
|
373
|
+
static finalizeStyles(s) {
|
|
374
|
+
const i = [];
|
|
375
|
+
if (Array.isArray(s)) {
|
|
376
|
+
const e = new Set(s.flat(1 / 0).reverse());
|
|
377
|
+
for (const s of e) i.unshift(c$1(s));
|
|
378
|
+
} else void 0 !== s && i.push(c$1(s));
|
|
379
|
+
return i;
|
|
380
|
+
}
|
|
381
|
+
static _$Eu(t, s) {
|
|
382
|
+
const i = s.attribute;
|
|
383
|
+
return false === i ? void 0 : "string" == typeof i ? i : "string" == typeof t ? t.toLowerCase() : void 0;
|
|
384
|
+
}
|
|
385
|
+
constructor() {
|
|
386
|
+
super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
|
|
387
|
+
}
|
|
388
|
+
_$Ev() {
|
|
389
|
+
this._$ES = new Promise(t => this.enableUpdating = t), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(t => t(this));
|
|
390
|
+
}
|
|
391
|
+
addController(t) {
|
|
392
|
+
(this._$EO ??= new Set()).add(t), void 0 !== this.renderRoot && this.isConnected && t.hostConnected?.();
|
|
393
|
+
}
|
|
394
|
+
removeController(t) {
|
|
395
|
+
this._$EO?.delete(t);
|
|
396
|
+
}
|
|
397
|
+
_$E_() {
|
|
398
|
+
const t = new Map(),
|
|
399
|
+
s = this.constructor.elementProperties;
|
|
400
|
+
for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
|
|
401
|
+
t.size > 0 && (this._$Ep = t);
|
|
402
|
+
}
|
|
403
|
+
createRenderRoot() {
|
|
404
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
405
|
+
return S(t, this.constructor.elementStyles), t;
|
|
406
|
+
}
|
|
407
|
+
connectedCallback() {
|
|
408
|
+
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.());
|
|
409
|
+
}
|
|
410
|
+
enableUpdating(t) {}
|
|
411
|
+
disconnectedCallback() {
|
|
412
|
+
this._$EO?.forEach(t => t.hostDisconnected?.());
|
|
413
|
+
}
|
|
414
|
+
attributeChangedCallback(t, s, i) {
|
|
415
|
+
this._$AK(t, i);
|
|
416
|
+
}
|
|
417
|
+
_$ET(t, s) {
|
|
418
|
+
const i = this.constructor.elementProperties.get(t),
|
|
419
|
+
e = this.constructor._$Eu(t, i);
|
|
420
|
+
if (void 0 !== e && true === i.reflect) {
|
|
421
|
+
const h = (void 0 !== i.converter?.toAttribute ? i.converter : u).toAttribute(s, i.type);
|
|
422
|
+
this._$Em = t, null == h ? this.removeAttribute(e) : this.setAttribute(e, h), this._$Em = null;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
_$AK(t, s) {
|
|
426
|
+
const i = this.constructor,
|
|
427
|
+
e = i._$Eh.get(t);
|
|
428
|
+
if (void 0 !== e && this._$Em !== e) {
|
|
429
|
+
const t = i.getPropertyOptions(e),
|
|
430
|
+
h = "function" == typeof t.converter ? {
|
|
431
|
+
fromAttribute: t.converter
|
|
432
|
+
} : void 0 !== t.converter?.fromAttribute ? t.converter : u;
|
|
433
|
+
this._$Em = e;
|
|
434
|
+
const r = h.fromAttribute(s, t.type);
|
|
435
|
+
this[e] = r ?? this._$Ej?.get(e) ?? r, this._$Em = null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
requestUpdate(t, s, i) {
|
|
439
|
+
if (void 0 !== t) {
|
|
440
|
+
const e = this.constructor,
|
|
441
|
+
h = this[t];
|
|
442
|
+
if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
|
|
443
|
+
this.C(t, s, i);
|
|
444
|
+
}
|
|
445
|
+
false === this.isUpdatePending && (this._$ES = this._$EP());
|
|
446
|
+
}
|
|
447
|
+
C(t, s, {
|
|
448
|
+
useDefault: i,
|
|
449
|
+
reflect: e,
|
|
450
|
+
wrapped: h
|
|
451
|
+
}, r) {
|
|
452
|
+
i && !(this._$Ej ??= new Map()).has(t) && (this._$Ej.set(t, r ?? s ?? this[t]), true !== h || void 0 !== r) || (this._$AL.has(t) || (this.hasUpdated || i || (s = void 0), this._$AL.set(t, s)), true === e && this._$Em !== t && (this._$Eq ??= new Set()).add(t));
|
|
453
|
+
}
|
|
454
|
+
async _$EP() {
|
|
455
|
+
this.isUpdatePending = true;
|
|
456
|
+
try {
|
|
457
|
+
await this._$ES;
|
|
458
|
+
} catch (t) {
|
|
459
|
+
Promise.reject(t);
|
|
460
|
+
}
|
|
461
|
+
const t = this.scheduleUpdate();
|
|
462
|
+
return null != t && (await t), !this.isUpdatePending;
|
|
463
|
+
}
|
|
464
|
+
scheduleUpdate() {
|
|
465
|
+
return this.performUpdate();
|
|
466
|
+
}
|
|
467
|
+
performUpdate() {
|
|
468
|
+
if (!this.isUpdatePending) return;
|
|
469
|
+
if (!this.hasUpdated) {
|
|
470
|
+
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
|
|
471
|
+
for (const [t, s] of this._$Ep) this[t] = s;
|
|
472
|
+
this._$Ep = void 0;
|
|
473
|
+
}
|
|
474
|
+
const t = this.constructor.elementProperties;
|
|
475
|
+
if (t.size > 0) for (const [s, i] of t) {
|
|
476
|
+
const {
|
|
477
|
+
wrapped: t
|
|
478
|
+
} = i,
|
|
479
|
+
e = this[s];
|
|
480
|
+
true !== t || this._$AL.has(s) || void 0 === e || this.C(s, void 0, i, e);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
let t = false;
|
|
484
|
+
const s = this._$AL;
|
|
485
|
+
try {
|
|
486
|
+
t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(t => t.hostUpdate?.()), this.update(s)) : this._$EM();
|
|
487
|
+
} catch (s) {
|
|
488
|
+
throw t = false, this._$EM(), s;
|
|
489
|
+
}
|
|
490
|
+
t && this._$AE(s);
|
|
491
|
+
}
|
|
492
|
+
willUpdate(t) {}
|
|
493
|
+
_$AE(t) {
|
|
494
|
+
this._$EO?.forEach(t => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t);
|
|
495
|
+
}
|
|
496
|
+
_$EM() {
|
|
497
|
+
this._$AL = new Map(), this.isUpdatePending = false;
|
|
498
|
+
}
|
|
499
|
+
get updateComplete() {
|
|
500
|
+
return this.getUpdateComplete();
|
|
501
|
+
}
|
|
502
|
+
getUpdateComplete() {
|
|
503
|
+
return this._$ES;
|
|
504
|
+
}
|
|
505
|
+
shouldUpdate(t) {
|
|
506
|
+
return true;
|
|
507
|
+
}
|
|
508
|
+
update(t) {
|
|
509
|
+
this._$Eq &&= this._$Eq.forEach(t => this._$ET(t, this[t])), this._$EM();
|
|
510
|
+
}
|
|
511
|
+
updated(t) {}
|
|
512
|
+
firstUpdated(t) {}
|
|
513
|
+
}
|
|
514
|
+
y.elementStyles = [], y.shadowRootOptions = {
|
|
515
|
+
mode: "open"
|
|
516
|
+
}, y[d("elementProperties")] = new Map(), y[d("finalized")] = new Map(), p?.({
|
|
517
|
+
ReactiveElement: y
|
|
518
|
+
}), (a.reactiveElementVersions ??= []).push("2.1.1");
|
|
220
519
|
|
|
221
520
|
/**
|
|
222
521
|
* @license
|
|
223
522
|
* Copyright 2017 Google LLC
|
|
224
523
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
225
|
-
*/
|
|
524
|
+
*/
|
|
525
|
+
const o = {
|
|
526
|
+
attribute: true,
|
|
527
|
+
type: String,
|
|
528
|
+
converter: u,
|
|
529
|
+
reflect: false,
|
|
530
|
+
hasChanged: f
|
|
531
|
+
},
|
|
532
|
+
r = (t = o, e, r) => {
|
|
533
|
+
const {
|
|
534
|
+
kind: n,
|
|
535
|
+
metadata: i
|
|
536
|
+
} = r;
|
|
537
|
+
let s = globalThis.litPropertyMetadata.get(i);
|
|
538
|
+
if (void 0 === s && globalThis.litPropertyMetadata.set(i, s = new Map()), "setter" === n && ((t = Object.create(t)).wrapped = true), s.set(r.name, t), "accessor" === n) {
|
|
539
|
+
const {
|
|
540
|
+
name: o
|
|
541
|
+
} = r;
|
|
542
|
+
return {
|
|
543
|
+
set(r) {
|
|
544
|
+
const n = e.get.call(this);
|
|
545
|
+
e.set.call(this, r), this.requestUpdate(o, n, t);
|
|
546
|
+
},
|
|
547
|
+
init(e) {
|
|
548
|
+
return void 0 !== e && this.C(o, void 0, t, e), e;
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
if ("setter" === n) {
|
|
553
|
+
const {
|
|
554
|
+
name: o
|
|
555
|
+
} = r;
|
|
556
|
+
return function (r) {
|
|
557
|
+
const n = this[o];
|
|
558
|
+
e.call(this, r), this.requestUpdate(o, n, t);
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
throw Error("Unsupported decorator location: " + n);
|
|
562
|
+
};
|
|
563
|
+
function n(t) {
|
|
564
|
+
return (e, o) => "object" == typeof o ? r(t, e, o) : ((t, e, o) => {
|
|
565
|
+
const r = e.hasOwnProperty(o);
|
|
566
|
+
return e.constructor.createProperty(o, t), r ? Object.getOwnPropertyDescriptor(e, o) : void 0;
|
|
567
|
+
})(t, e, o);
|
|
568
|
+
}
|
|
226
569
|
|
|
227
570
|
/**
|
|
228
571
|
* @license
|
|
229
572
|
* Copyright 2017 Google LLC
|
|
230
573
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
231
574
|
*/
|
|
232
|
-
const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
|
|
575
|
+
const e$1 = (e, t, c) => (c.configurable = true, c.enumerable = true, Reflect.decorate && "object" != typeof t && Object.defineProperty(e, t, c), c);
|
|
233
576
|
|
|
234
577
|
/**
|
|
235
578
|
* @license
|
|
236
579
|
* Copyright 2017 Google LLC
|
|
237
580
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
238
|
-
*/
|
|
581
|
+
*/
|
|
582
|
+
function e(e, r) {
|
|
583
|
+
return (n, s, i) => {
|
|
584
|
+
const o = t => t.renderRoot?.querySelector(e) ?? null;
|
|
585
|
+
return e$1(n, s, {
|
|
586
|
+
get() {
|
|
587
|
+
return o(this);
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
};
|
|
591
|
+
}
|
|
239
592
|
|
|
240
593
|
/**
|
|
241
594
|
* Determines whether an object has keys for a given type.
|
|
@@ -245,7 +598,7 @@ const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"obj
|
|
|
245
598
|
* @returns {boolean} Whether `value` has all `keys`.
|
|
246
599
|
*/
|
|
247
600
|
function hasKeys(value, ...keys) {
|
|
248
|
-
|
|
601
|
+
return typeof value === "object" && value !== null && keys.every(x => x in value);
|
|
249
602
|
}
|
|
250
603
|
|
|
251
604
|
/**
|
|
@@ -254,7 +607,7 @@ function hasKeys(value, ...keys) {
|
|
|
254
607
|
* @returns {value is DisabledMixin} Whether `value` is a `DisabledMixin`.
|
|
255
608
|
*/
|
|
256
609
|
function isDisabledMixin(value) {
|
|
257
|
-
|
|
610
|
+
return hasKeys(value, "disabled");
|
|
258
611
|
}
|
|
259
612
|
/**
|
|
260
613
|
* Mixin to augment an element with behavior that supports a disabled state.
|
|
@@ -264,27 +617,28 @@ function isDisabledMixin(value) {
|
|
|
264
617
|
* @returns {Constructor<DisabledMixin> & T} A constructor that implements `DisabledMixin`.
|
|
265
618
|
*/
|
|
266
619
|
function Disabled(base, reflect = true) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
/** @inheritdoc */
|
|
277
|
-
update(changedProperties) {
|
|
278
|
-
super.update(changedProperties);
|
|
279
|
-
if (changedProperties.has("disabled") && this.role && this.role !== "none" && this.role !== "presentation") {
|
|
280
|
-
this.ariaDisabled = this.disabled ? "true" : null;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
620
|
+
class _DisabledMixin extends base {
|
|
621
|
+
constructor() {
|
|
622
|
+
super(...arguments);
|
|
623
|
+
/**
|
|
624
|
+
* Whether the element is disabled.
|
|
625
|
+
* @default false
|
|
626
|
+
*/
|
|
627
|
+
this.disabled = false;
|
|
283
628
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
629
|
+
/** @inheritdoc */
|
|
630
|
+
update(changedProperties) {
|
|
631
|
+
super.update(changedProperties);
|
|
632
|
+
if (changedProperties.has("disabled") && this.role && this.role !== "none" && this.role !== "presentation") {
|
|
633
|
+
this.ariaDisabled = this.disabled ? "true" : null;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
__decorate([n({
|
|
638
|
+
type: Boolean,
|
|
639
|
+
reflect: reflect
|
|
640
|
+
})], _DisabledMixin.prototype, "disabled", void 0);
|
|
641
|
+
return _DisabledMixin;
|
|
288
642
|
}
|
|
289
643
|
|
|
290
644
|
var _ListManager_items, _ListManager_activeItem, _ListManager_onActiveItemChangeCallback;
|
|
@@ -293,59 +647,64 @@ var _ListManager_items, _ListManager_activeItem, _ListManager_onActiveItemChange
|
|
|
293
647
|
* @template T The type of managed item.
|
|
294
648
|
*/
|
|
295
649
|
class ListManager {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
650
|
+
constructor() {
|
|
651
|
+
/** @private */_ListManager_items.set(this, new Array());
|
|
652
|
+
/** @private */
|
|
653
|
+
_ListManager_activeItem.set(this, null);
|
|
654
|
+
/** @private */
|
|
655
|
+
_ListManager_onActiveItemChangeCallback.set(this, void 0);
|
|
656
|
+
}
|
|
657
|
+
/** The items being managed. */
|
|
658
|
+
get items() {
|
|
659
|
+
return __classPrivateFieldGet(this, _ListManager_items, "f");
|
|
660
|
+
}
|
|
661
|
+
/** The active item. */
|
|
662
|
+
get activeItem() {
|
|
663
|
+
return __classPrivateFieldGet(this, _ListManager_activeItem, "f");
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Sets the items to manage.
|
|
667
|
+
* @param {Array<T>} items The new items.
|
|
668
|
+
* @returns {{ added: ReadonlyArray<T>; removed: ReadonlyArray<T> }} An object specifying added and removed items.
|
|
669
|
+
*/
|
|
670
|
+
setItems(items) {
|
|
671
|
+
const removed = this.items.filter(x => !items.includes(x));
|
|
672
|
+
const added = items.filter(x => !this.items.includes(x));
|
|
673
|
+
__classPrivateFieldSet(this, _ListManager_items, items, "f");
|
|
674
|
+
if (this.activeItem && !this.items.includes(this.activeItem)) {
|
|
675
|
+
this.updateActiveItem(null);
|
|
676
|
+
}
|
|
677
|
+
return {
|
|
678
|
+
added,
|
|
679
|
+
removed
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Sets the active item.
|
|
684
|
+
* @param {T | null | undefined} item The new active item.
|
|
685
|
+
*/
|
|
686
|
+
setActiveItem(item) {
|
|
687
|
+
if (this.activeItem !== item) {
|
|
688
|
+
this.updateActiveItem(item);
|
|
689
|
+
__classPrivateFieldGet(this, _ListManager_onActiveItemChangeCallback, "f")?.call(this);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* Updates the active item.
|
|
694
|
+
* @param {T | null | undefined} item The active item.
|
|
695
|
+
*/
|
|
696
|
+
updateActiveItem(item) {
|
|
697
|
+
__classPrivateFieldSet(this, _ListManager_activeItem, item ?? null, "f");
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Configures the list manager with a callback invoked when an item is activated.
|
|
701
|
+
* @param {() => void} callback The callback invoked when an item is activated.
|
|
702
|
+
* @returns {ListManager<T>} The configured list manager.
|
|
703
|
+
*/
|
|
704
|
+
onActiveItemChange(callback) {
|
|
705
|
+
__classPrivateFieldSet(this, _ListManager_onActiveItemChangeCallback, callback, "f");
|
|
706
|
+
return this;
|
|
707
|
+
}
|
|
349
708
|
}
|
|
350
709
|
_ListManager_items = new WeakMap(), _ListManager_activeItem = new WeakMap(), _ListManager_onActiveItemChangeCallback = new WeakMap();
|
|
351
710
|
|
|
@@ -366,84 +725,90 @@ const typeaheadLabel = Symbol("typeaheadLabel");
|
|
|
366
725
|
* @returns A value indicating whether `value` is an `TypeaheadItem`.
|
|
367
726
|
*/
|
|
368
727
|
function isTypeaheadItem(value) {
|
|
369
|
-
|
|
728
|
+
return hasKeys(value, typeaheadLabel);
|
|
370
729
|
}
|
|
371
730
|
/**
|
|
372
731
|
* Implements typeahead functionality which selects items based on keyboard input.
|
|
373
732
|
* @template T The type of `TypeaheadItem`.
|
|
374
733
|
*/
|
|
375
734
|
class Typeahead {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
735
|
+
/**
|
|
736
|
+
* Initializes a new instance of this class.
|
|
737
|
+
* @param {TypeaheadOptions<T>} options Options that control typeahead behavior.
|
|
738
|
+
*/
|
|
739
|
+
constructor(options) {
|
|
740
|
+
_Typeahead_instances.add(this);
|
|
741
|
+
/** @private */
|
|
742
|
+
_Typeahead_debounceInterval.set(this, void 0);
|
|
743
|
+
/** @private */
|
|
744
|
+
_Typeahead_timeoutId.set(this, -1);
|
|
745
|
+
/** @private */
|
|
746
|
+
_Typeahead_callback.set(this, void 0);
|
|
747
|
+
/** @private */
|
|
748
|
+
_Typeahead_skipPredicate.set(this, void 0);
|
|
749
|
+
/** @private */
|
|
750
|
+
_Typeahead_pressedKeys.set(this, new Array());
|
|
751
|
+
/** @private */
|
|
752
|
+
_Typeahead_selectedIndex.set(this, -1);
|
|
753
|
+
/** @private */
|
|
754
|
+
_Typeahead_items.set(this, []);
|
|
755
|
+
__classPrivateFieldSet(this, _Typeahead_debounceInterval, options.debounceInterval ?? 200, "f");
|
|
756
|
+
__classPrivateFieldSet(this, _Typeahead_callback, options.callback, "f");
|
|
757
|
+
__classPrivateFieldSet(this, _Typeahead_skipPredicate, options.skipPredicate, "f");
|
|
758
|
+
}
|
|
759
|
+
/** A value indicating whether the user is currently typing. */
|
|
760
|
+
get isTyping() {
|
|
761
|
+
return __classPrivateFieldGet(this, _Typeahead_pressedKeys, "f").length > 0;
|
|
762
|
+
}
|
|
763
|
+
/**
|
|
764
|
+
* Sets the items to search.
|
|
765
|
+
* @param {readonly T[]} items The items to search.
|
|
766
|
+
*/
|
|
767
|
+
setItems(items) {
|
|
768
|
+
__classPrivateFieldSet(this, _Typeahead_items, items, "f");
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Sets the index of the selected item.
|
|
772
|
+
* @param {number} index The index of the selected item.
|
|
773
|
+
*/
|
|
774
|
+
setSelectedIndex(index) {
|
|
775
|
+
__classPrivateFieldSet(this, _Typeahead_selectedIndex, index, "f");
|
|
776
|
+
}
|
|
777
|
+
/** Resets the stored sequence of typed characters. */
|
|
778
|
+
reset() {
|
|
779
|
+
__classPrivateFieldGet(this, _Typeahead_pressedKeys, "f").length = 0;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Sets the selected item depending on the key event passed in.
|
|
783
|
+
* @param {KeyboardEvent} e The keyboard event to be used for determining which element should be active.
|
|
784
|
+
*/
|
|
785
|
+
onKeyDown(e) {
|
|
786
|
+
if (e.key && e.key.length === 1) {
|
|
787
|
+
__classPrivateFieldGet(this, _Typeahead_instances, "m", _Typeahead_appendKey).call(this, e.key);
|
|
788
|
+
} else {
|
|
789
|
+
const keycode = getKeyCode(e);
|
|
790
|
+
if (keycode >= KeyCode.A && keycode <= KeyCode.Z || keycode >= KeyCode.Zero && keycode <= KeyCode.Nine) {
|
|
791
|
+
__classPrivateFieldGet(this, _Typeahead_instances, "m", _Typeahead_appendKey).call(this, String.fromCharCode(keycode));
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
}
|
|
430
795
|
}
|
|
431
796
|
_Typeahead_debounceInterval = new WeakMap(), _Typeahead_timeoutId = new WeakMap(), _Typeahead_callback = new WeakMap(), _Typeahead_skipPredicate = new WeakMap(), _Typeahead_pressedKeys = new WeakMap(), _Typeahead_selectedIndex = new WeakMap(), _Typeahead_items = new WeakMap(), _Typeahead_instances = new WeakSet(), _Typeahead_appendKey = function _Typeahead_appendKey(key) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
797
|
+
__classPrivateFieldGet(this, _Typeahead_pressedKeys, "f").push(key.toLocaleUpperCase());
|
|
798
|
+
clearTimeout(__classPrivateFieldGet(this, _Typeahead_timeoutId, "f"));
|
|
799
|
+
__classPrivateFieldSet(this, _Typeahead_timeoutId, setTimeout(() => __classPrivateFieldGet(this, _Typeahead_instances, "m", _Typeahead_searchItems).call(this), __classPrivateFieldGet(this, _Typeahead_debounceInterval, "f")), "f");
|
|
435
800
|
}, _Typeahead_searchItems = function _Typeahead_searchItems() {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
801
|
+
const term = __classPrivateFieldGet(this, _Typeahead_pressedKeys, "f").join("");
|
|
802
|
+
for (let i = 1; i < __classPrivateFieldGet(this, _Typeahead_items, "f").length + 1; i++) {
|
|
803
|
+
const index = (__classPrivateFieldGet(this, _Typeahead_selectedIndex, "f") + i) % __classPrivateFieldGet(this, _Typeahead_items, "f").length;
|
|
804
|
+
const item = __classPrivateFieldGet(this, _Typeahead_items, "f")[index];
|
|
805
|
+
const label = item[typeaheadLabel]?.().toLocaleUpperCase().trim();
|
|
806
|
+
if (!__classPrivateFieldGet(this, _Typeahead_skipPredicate, "f")?.call(this, item) && label?.indexOf(term) === 0) {
|
|
807
|
+
__classPrivateFieldGet(this, _Typeahead_callback, "f").call(this, item);
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
this.reset();
|
|
447
812
|
};
|
|
448
813
|
|
|
449
814
|
/**
|
|
@@ -460,290 +825,301 @@ var _ListKeyManager_instances, _ListKeyManager_typeahead, _ListKeyManager_findFi
|
|
|
460
825
|
* @template T The type of managed item.
|
|
461
826
|
*/
|
|
462
827
|
class ListKeyManager extends ListManager {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
* Whether the active item will wrap to the other end of
|
|
469
|
-
* list when there are no more items in the given direction.
|
|
470
|
-
* @default false
|
|
471
|
-
*/
|
|
472
|
-
this.wrap = false;
|
|
473
|
-
/**
|
|
474
|
-
* Whether to activate the first and last items respectively when
|
|
475
|
-
* the `HOME` or `END` key is pressed.
|
|
476
|
-
* @default false
|
|
477
|
-
*/
|
|
478
|
-
this.homeAndEnd = false;
|
|
479
|
-
/**
|
|
480
|
-
* Whether to activate every 10th (or configured) first/last item
|
|
481
|
-
* in the up/down direction when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
482
|
-
* @default false
|
|
483
|
-
*/
|
|
484
|
-
this.pageUpAndDown = false;
|
|
485
|
-
/**
|
|
486
|
-
* The number of items to skip when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
487
|
-
* @default 10
|
|
488
|
-
*/
|
|
489
|
-
this.pageDelta = 10;
|
|
490
|
-
/**
|
|
491
|
-
* Whether to the list is oriented vertically.
|
|
492
|
-
* @default false
|
|
493
|
-
*/
|
|
494
|
-
this.vertical = false;
|
|
495
|
-
/** The allowed modifier keys.
|
|
496
|
-
* @default []
|
|
497
|
-
*/
|
|
498
|
-
this.allowedModifiers = [];
|
|
499
|
-
/**
|
|
500
|
-
* A function used to skip items.
|
|
501
|
-
* @param {T} item The item to test.
|
|
502
|
-
* @returns {boolean} Whether `item` should be skipped.
|
|
503
|
-
*/
|
|
504
|
-
this.skipPredicate = (item) => isDisabledMixin(item) && item.disabled;
|
|
505
|
-
}
|
|
506
|
-
/** @inheritdoc */
|
|
507
|
-
setItems(items) {
|
|
508
|
-
__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f")?.setItems(items);
|
|
509
|
-
return super.setItems(items);
|
|
510
|
-
}
|
|
511
|
-
/** @inheritdoc */
|
|
512
|
-
updateActiveItem(item) {
|
|
513
|
-
super.updateActiveItem(item);
|
|
514
|
-
if (__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f")) {
|
|
515
|
-
__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f").setSelectedIndex(item ? this.items.indexOf(item) : -1);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
828
|
+
constructor() {
|
|
829
|
+
super(...arguments);
|
|
830
|
+
_ListKeyManager_instances.add(this);
|
|
831
|
+
/** @private */
|
|
832
|
+
_ListKeyManager_typeahead.set(this, void 0);
|
|
518
833
|
/**
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
834
|
+
* Whether the active item will wrap to the other end of
|
|
835
|
+
* list when there are no more items in the given direction.
|
|
836
|
+
* @default false
|
|
523
837
|
*/
|
|
524
|
-
|
|
525
|
-
this.homeAndEnd = enabled;
|
|
526
|
-
return this;
|
|
527
|
-
}
|
|
838
|
+
this.wrap = false;
|
|
528
839
|
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
* @
|
|
532
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
840
|
+
* Whether to activate the first and last items respectively when
|
|
841
|
+
* the `HOME` or `END` key is pressed.
|
|
842
|
+
* @default false
|
|
533
843
|
*/
|
|
534
|
-
|
|
535
|
-
this.pageUpAndDown = enabled;
|
|
536
|
-
this.pageDelta = pageDelta;
|
|
537
|
-
return this;
|
|
538
|
-
}
|
|
844
|
+
this.homeAndEnd = false;
|
|
539
845
|
/**
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
846
|
+
* Whether to activate every 10th (or configured) first/last item
|
|
847
|
+
* in the up/down direction when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
848
|
+
* @default false
|
|
544
849
|
*/
|
|
545
|
-
|
|
546
|
-
this.wrap = enabled;
|
|
547
|
-
return this;
|
|
548
|
-
}
|
|
850
|
+
this.pageUpAndDown = false;
|
|
549
851
|
/**
|
|
550
|
-
*
|
|
551
|
-
* @
|
|
552
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
852
|
+
* The number of items to skip when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
853
|
+
* @default 10
|
|
553
854
|
*/
|
|
554
|
-
|
|
555
|
-
this.vertical = enabled;
|
|
556
|
-
return this;
|
|
557
|
-
}
|
|
855
|
+
this.pageDelta = 10;
|
|
558
856
|
/**
|
|
559
|
-
*
|
|
560
|
-
* @
|
|
561
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
857
|
+
* Whether to the list is oriented vertically.
|
|
858
|
+
* @default false
|
|
562
859
|
*/
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Configures whether typeahead is enabled.
|
|
569
|
-
* @param {boolean} [enabled = true] Whether typeahead is enabled.
|
|
570
|
-
* @returns {ListKeyManager<T>} The configured key manager.
|
|
860
|
+
this.vertical = false;
|
|
861
|
+
/** The allowed modifier keys.
|
|
862
|
+
* @default []
|
|
571
863
|
*/
|
|
572
|
-
|
|
573
|
-
if (enabled) {
|
|
574
|
-
__classPrivateFieldSet(this, _ListKeyManager_typeahead, new Typeahead({ callback: (item) => this.setActiveItem(item) }), "f");
|
|
575
|
-
}
|
|
576
|
-
else {
|
|
577
|
-
__classPrivateFieldSet(this, _ListKeyManager_typeahead, undefined, "f");
|
|
578
|
-
}
|
|
579
|
-
return this;
|
|
580
|
-
}
|
|
864
|
+
this.allowedModifiers = [];
|
|
581
865
|
/**
|
|
582
|
-
*
|
|
583
|
-
* @param
|
|
584
|
-
* @returns {
|
|
866
|
+
* A function used to skip items.
|
|
867
|
+
* @param {T} item The item to test.
|
|
868
|
+
* @returns {boolean} Whether `item` should be skipped.
|
|
585
869
|
*/
|
|
586
|
-
|
|
587
|
-
this.skipPredicate = skipPredicate;
|
|
588
|
-
return this;
|
|
589
|
-
}
|
|
870
|
+
this.skipPredicate = item => isDisabledMixin(item) && item.disabled;
|
|
590
871
|
/**
|
|
591
|
-
*
|
|
592
|
-
* @
|
|
872
|
+
* The directionality.
|
|
873
|
+
* @default "ltr"
|
|
593
874
|
*/
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
875
|
+
this.directionality = "ltr";
|
|
876
|
+
}
|
|
877
|
+
/** @inheritdoc */
|
|
878
|
+
setItems(items) {
|
|
879
|
+
__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f")?.setItems(items);
|
|
880
|
+
return super.setItems(items);
|
|
881
|
+
}
|
|
882
|
+
/** @inheritdoc */
|
|
883
|
+
updateActiveItem(item) {
|
|
884
|
+
super.updateActiveItem(item);
|
|
885
|
+
if (__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f")) {
|
|
886
|
+
__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f").setSelectedIndex(item ? this.items.indexOf(item) : -1);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Configures the key manager to activate the first and last items respectively when the `HOME` or `END` key is pressed.
|
|
891
|
+
* @param {boolean} [enabled = true] Whether to activate the first and last items respectively when
|
|
892
|
+
* the `HOME` or `END` key is pressed.
|
|
893
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
894
|
+
*/
|
|
895
|
+
withHomeAndEnd(enabled = true) {
|
|
896
|
+
this.homeAndEnd = enabled;
|
|
897
|
+
return this;
|
|
898
|
+
}
|
|
899
|
+
/**
|
|
900
|
+
* Configures the key manager to page up and down when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
901
|
+
* @param {boolean} [enabled = true] Whether to activate page up and down when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
902
|
+
* @param {number} [pageDelta=10] The number of items to skip when the `PAGEUP` or `PAGEDOWN` key is pressed.
|
|
903
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
904
|
+
*/
|
|
905
|
+
withPageUpAndDown(enabled = true, pageDelta = 10) {
|
|
906
|
+
this.pageUpAndDown = enabled;
|
|
907
|
+
this.pageDelta = pageDelta;
|
|
908
|
+
return this;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* Configures wrapping mode, which determines whether the active item will wrap to the other end of list when there are no more items in the given direction.
|
|
912
|
+
* @param {boolean} [enabled = true] Whether the active item will wrap to the other end of
|
|
913
|
+
* list when there are no more items in the given direction.
|
|
914
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
915
|
+
*/
|
|
916
|
+
withWrap(enabled = true) {
|
|
917
|
+
this.wrap = enabled;
|
|
918
|
+
return this;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Configures whether to move the selection vertically.
|
|
922
|
+
* @param {boolean} [enabled = true] Whether to move selection vertically.
|
|
923
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
924
|
+
*/
|
|
925
|
+
withVerticalOrientation(enabled = true) {
|
|
926
|
+
this.vertical = enabled;
|
|
927
|
+
return this;
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Configured allowed modifier keys.
|
|
931
|
+
* @param {ModifierKey[]} modifiers The allowed modifier keys.
|
|
932
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
933
|
+
*/
|
|
934
|
+
withAllowedModifiers(...modifiers) {
|
|
935
|
+
this.allowedModifiers = modifiers;
|
|
936
|
+
return this;
|
|
937
|
+
}
|
|
938
|
+
/**
|
|
939
|
+
* Configures whether typeahead is enabled.
|
|
940
|
+
* @param {boolean} [enabled = true] Whether typeahead is enabled.
|
|
941
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
942
|
+
*/
|
|
943
|
+
withTypeahead(enabled = true) {
|
|
944
|
+
if (enabled) {
|
|
945
|
+
__classPrivateFieldSet(this, _ListKeyManager_typeahead, new Typeahead({
|
|
946
|
+
callback: item => this.setActiveItem(item)
|
|
947
|
+
}), "f");
|
|
948
|
+
} else {
|
|
949
|
+
__classPrivateFieldSet(this, _ListKeyManager_typeahead, undefined, "f");
|
|
950
|
+
}
|
|
951
|
+
return this;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Configures a function used to test whether an item should be skipped.
|
|
955
|
+
* @param skipPredicate A function used to determine whether an item should be skipped.
|
|
956
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
957
|
+
*/
|
|
958
|
+
withSkipPredicate(skipPredicate) {
|
|
959
|
+
this.skipPredicate = skipPredicate;
|
|
960
|
+
return this;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* Configures the directionality.
|
|
964
|
+
* @param {"ltr" | "rtl"} directionality The directionality.
|
|
965
|
+
* @returns {ListKeyManager<T>} The configured key manager.
|
|
966
|
+
*/
|
|
967
|
+
withDirectionality(directionality) {
|
|
968
|
+
this.directionality = directionality;
|
|
969
|
+
return this;
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Sets the active item depending on the key event passed in.
|
|
973
|
+
* @param {KeyboardEvent} e The keyboard event to be used for determining which element should be active.
|
|
974
|
+
*/
|
|
975
|
+
onKeyDown(e) {
|
|
976
|
+
if (e.defaultPrevented) return;
|
|
977
|
+
const modifierAllowed = isModifierAllowed(e, ...this.allowedModifiers);
|
|
978
|
+
switch (e.key) {
|
|
979
|
+
case "Left":
|
|
980
|
+
case "ArrowLeft":
|
|
981
|
+
if (modifierAllowed && !this.vertical) {
|
|
982
|
+
e.preventDefault();
|
|
983
|
+
const prev = this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPrevious).call(this) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNext).call(this);
|
|
984
|
+
if (prev) {
|
|
985
|
+
this.setActiveItem(prev);
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
break;
|
|
989
|
+
case "Up":
|
|
990
|
+
case "ArrowUp":
|
|
991
|
+
if (modifierAllowed) {
|
|
992
|
+
e.preventDefault();
|
|
993
|
+
const prev = this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPrevious).call(this) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNext).call(this);
|
|
994
|
+
if (prev) {
|
|
995
|
+
this.setActiveItem(prev);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
break;
|
|
999
|
+
case "Right":
|
|
1000
|
+
case "ArrowRight":
|
|
1001
|
+
if (modifierAllowed && !this.vertical) {
|
|
1002
|
+
e.preventDefault();
|
|
1003
|
+
const next = this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNext).call(this) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPrevious).call(this);
|
|
1004
|
+
if (next) {
|
|
1005
|
+
this.setActiveItem(next);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
break;
|
|
1009
|
+
case "Down":
|
|
1010
|
+
case "ArrowDown":
|
|
1011
|
+
if (modifierAllowed) {
|
|
1012
|
+
e.preventDefault();
|
|
1013
|
+
const next = this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNext).call(this) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPrevious).call(this);
|
|
1014
|
+
if (next) {
|
|
1015
|
+
this.setActiveItem(next);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
break;
|
|
1019
|
+
case "Home":
|
|
1020
|
+
if (modifierAllowed && this.homeAndEnd) {
|
|
1021
|
+
e.preventDefault();
|
|
1022
|
+
const first = __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findFirst).call(this);
|
|
1023
|
+
if (first) {
|
|
1024
|
+
this.setActiveItem(first);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
break;
|
|
1028
|
+
case "End":
|
|
1029
|
+
if (modifierAllowed && this.homeAndEnd) {
|
|
1030
|
+
e.preventDefault();
|
|
1031
|
+
const last = __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findLast).call(this);
|
|
1032
|
+
if (last) {
|
|
1033
|
+
this.setActiveItem(last);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
break;
|
|
1037
|
+
case "PageUp":
|
|
1038
|
+
if (modifierAllowed && this.pageUpAndDown) {
|
|
1039
|
+
e.preventDefault();
|
|
1040
|
+
const prev = (this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPreviousByIndex) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNextByIndex))(this.activeItem ? Math.max(0, this.items.indexOf(this.activeItem) - this.pageDelta) : 0);
|
|
1041
|
+
if (prev) {
|
|
1042
|
+
this.setActiveItem(prev);
|
|
1043
|
+
}
|
|
682
1044
|
}
|
|
1045
|
+
break;
|
|
1046
|
+
case "PageDown":
|
|
1047
|
+
if (modifierAllowed && this.pageUpAndDown) {
|
|
1048
|
+
e.preventDefault();
|
|
1049
|
+
const next = (this.directionality === "ltr" ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findNextByIndex) : __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findPreviousByIndex))(this.activeItem ? Math.min(this.items.length - 1, this.items.indexOf(this.activeItem) + this.pageDelta) : this.items.length - 1);
|
|
1050
|
+
if (next) {
|
|
1051
|
+
this.setActiveItem(next);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
break;
|
|
1055
|
+
default:
|
|
1056
|
+
if (modifierAllowed || hasModifierKey(e, "shift")) {
|
|
1057
|
+
__classPrivateFieldGet(this, _ListKeyManager_typeahead, "f")?.onKeyDown(e);
|
|
1058
|
+
}
|
|
1059
|
+
break;
|
|
683
1060
|
}
|
|
1061
|
+
}
|
|
684
1062
|
}
|
|
685
1063
|
_ListKeyManager_typeahead = new WeakMap(), _ListKeyManager_instances = new WeakSet(), _ListKeyManager_findFirst = function _ListKeyManager_findFirst() {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
return null;
|
|
1064
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1065
|
+
if (this.items[i] === this.activeItem) break;
|
|
1066
|
+
const test = this.items[i];
|
|
1067
|
+
if (!this.skipPredicate(test)) {
|
|
1068
|
+
return test;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
return null;
|
|
695
1072
|
}, _ListKeyManager_findLast = function _ListKeyManager_findLast() {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return null;
|
|
1073
|
+
for (let i = this.items.length - 1; i >= 0; i--) {
|
|
1074
|
+
if (this.items[i] === this.activeItem) break;
|
|
1075
|
+
const test = this.items[i];
|
|
1076
|
+
if (!this.skipPredicate(test)) {
|
|
1077
|
+
return test;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
return null;
|
|
705
1081
|
}, _ListKeyManager_findNext = function _ListKeyManager_findNext() {
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
break;
|
|
1082
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1083
|
+
if (this.items[i] === this.activeItem) {
|
|
1084
|
+
for (let j = i + 1; j < this.items.length; j++) {
|
|
1085
|
+
const test = this.items[j];
|
|
1086
|
+
if (!this.skipPredicate(test)) {
|
|
1087
|
+
return test;
|
|
715
1088
|
}
|
|
1089
|
+
}
|
|
1090
|
+
break;
|
|
716
1091
|
}
|
|
717
|
-
|
|
1092
|
+
}
|
|
1093
|
+
return this.wrap ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findFirst).call(this) : null;
|
|
718
1094
|
}, _ListKeyManager_findPrevious = function _ListKeyManager_findPrevious() {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
break;
|
|
1095
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1096
|
+
if (this.items[i] === this.activeItem) {
|
|
1097
|
+
for (let j = i - 1; j >= 0; j--) {
|
|
1098
|
+
const test = this.items[j];
|
|
1099
|
+
if (!this.skipPredicate(test)) {
|
|
1100
|
+
return test;
|
|
728
1101
|
}
|
|
1102
|
+
}
|
|
1103
|
+
break;
|
|
729
1104
|
}
|
|
730
|
-
|
|
1105
|
+
}
|
|
1106
|
+
return this.wrap ? __classPrivateFieldGet(this, _ListKeyManager_instances, "m", _ListKeyManager_findLast).call(this) : null;
|
|
731
1107
|
}, _ListKeyManager_findPreviousByIndex = function _ListKeyManager_findPreviousByIndex(index) {
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}
|
|
1108
|
+
for (let i = index; i >= 0; i--) {
|
|
1109
|
+
const test = this.items[i];
|
|
1110
|
+
if (!this.skipPredicate(test)) {
|
|
1111
|
+
return test;
|
|
737
1112
|
}
|
|
738
|
-
|
|
1113
|
+
}
|
|
1114
|
+
return null;
|
|
739
1115
|
}, _ListKeyManager_findNextByIndex = function _ListKeyManager_findNextByIndex(index) {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
}
|
|
1116
|
+
for (let i = index; i < this.items.length; i++) {
|
|
1117
|
+
const test = this.items[i];
|
|
1118
|
+
if (!this.skipPredicate(test)) {
|
|
1119
|
+
return test;
|
|
745
1120
|
}
|
|
746
|
-
|
|
1121
|
+
}
|
|
1122
|
+
return null;
|
|
747
1123
|
};
|
|
748
1124
|
|
|
749
1125
|
var _FocusKeyManager_focusOptions;
|
|
@@ -752,24 +1128,25 @@ var _FocusKeyManager_focusOptions;
|
|
|
752
1128
|
* @template T The type of managed item.
|
|
753
1129
|
*/
|
|
754
1130
|
class FocusKeyManager extends ListKeyManager {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
1131
|
+
constructor() {
|
|
1132
|
+
super(...arguments);
|
|
1133
|
+
/** @private */
|
|
1134
|
+
_FocusKeyManager_focusOptions.set(this, void 0);
|
|
1135
|
+
}
|
|
1136
|
+
/** @inheritdoc */
|
|
1137
|
+
setActiveItem(item) {
|
|
1138
|
+
super.setActiveItem(item);
|
|
1139
|
+
item?.focus(__classPrivateFieldGet(this, _FocusKeyManager_focusOptions, "f"));
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Configures the key manager with options used to focus items.
|
|
1143
|
+
* @param {FocusOptions} options Options used to focus items.
|
|
1144
|
+
* @returns {FocusKeyManager<T>} The configured key manager.
|
|
1145
|
+
*/
|
|
1146
|
+
withOptions(options) {
|
|
1147
|
+
__classPrivateFieldSet(this, _FocusKeyManager_focusOptions, options, "f");
|
|
1148
|
+
return this;
|
|
1149
|
+
}
|
|
773
1150
|
}
|
|
774
1151
|
_FocusKeyManager_focusOptions = new WeakMap();
|
|
775
1152
|
|
|
@@ -779,7 +1156,7 @@ _FocusKeyManager_focusOptions = new WeakMap();
|
|
|
779
1156
|
* @returns Whether `value` is a `CheckedMixin`.
|
|
780
1157
|
*/
|
|
781
1158
|
function isCheckedMixin(value) {
|
|
782
|
-
|
|
1159
|
+
return hasKeys(value, "checked");
|
|
783
1160
|
}
|
|
784
1161
|
|
|
785
1162
|
/**
|
|
@@ -788,7 +1165,7 @@ function isCheckedMixin(value) {
|
|
|
788
1165
|
* @returns Whether `value` is a `SelectedMixin`.
|
|
789
1166
|
*/
|
|
790
1167
|
function isSelectedMixin(value) {
|
|
791
|
-
|
|
1168
|
+
return hasKeys(value, "selected");
|
|
792
1169
|
}
|
|
793
1170
|
|
|
794
1171
|
/**
|
|
@@ -797,7 +1174,7 @@ function isSelectedMixin(value) {
|
|
|
797
1174
|
* @return {boolean} Whether `element` is checked or selected.
|
|
798
1175
|
*/
|
|
799
1176
|
function isCheckedOrSelected(element) {
|
|
800
|
-
|
|
1177
|
+
return isCheckedMixin(element) && element.checked || isSelectedMixin(element) && element.selected;
|
|
801
1178
|
}
|
|
802
1179
|
/**
|
|
803
1180
|
* Sets the checked or selected state of an element.
|
|
@@ -805,12 +1182,11 @@ function isCheckedOrSelected(element) {
|
|
|
805
1182
|
* @param {boolean} checkedOrSelected The checked or selected state.
|
|
806
1183
|
*/
|
|
807
1184
|
function checkOrSelect(element, checkedOrSelected) {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
1185
|
+
if (isCheckedMixin(element)) {
|
|
1186
|
+
element.checked = checkedOrSelected;
|
|
1187
|
+
} else {
|
|
1188
|
+
element.selected = checkedOrSelected;
|
|
1189
|
+
}
|
|
814
1190
|
}
|
|
815
1191
|
|
|
816
1192
|
var _RovingTabIndexManager_disableRovingTabIndex;
|
|
@@ -819,50 +1195,51 @@ var _RovingTabIndexManager_disableRovingTabIndex;
|
|
|
819
1195
|
* @template T The type of managed item.
|
|
820
1196
|
*/
|
|
821
1197
|
class RovingTabIndexManager extends FocusKeyManager {
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
1198
|
+
constructor() {
|
|
1199
|
+
super(...arguments);
|
|
1200
|
+
/** @private */
|
|
1201
|
+
_RovingTabIndexManager_disableRovingTabIndex.set(this, false);
|
|
1202
|
+
}
|
|
1203
|
+
/** @inheritdoc */
|
|
1204
|
+
updateActiveItem(item) {
|
|
1205
|
+
super.updateActiveItem(item);
|
|
1206
|
+
if (!__classPrivateFieldGet(this, _RovingTabIndexManager_disableRovingTabIndex, "f")) {
|
|
1207
|
+
item?.setAttribute("tabindex", "0");
|
|
1208
|
+
for (const other of this.items) {
|
|
1209
|
+
if (other !== item && other.hasAttribute("tabindex")) {
|
|
1210
|
+
other.setAttribute("tabindex", "-1");
|
|
836
1211
|
}
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
/** @inheritdoc */
|
|
1216
|
+
setItems(items) {
|
|
1217
|
+
const result = super.setItems(items);
|
|
1218
|
+
if (!__classPrivateFieldGet(this, _RovingTabIndexManager_disableRovingTabIndex, "f")) {
|
|
1219
|
+
for (const added of result.added) {
|
|
1220
|
+
if (added !== this.activeItem && !this.skipPredicate(added)) {
|
|
1221
|
+
added.setAttribute("tabindex", "-1");
|
|
847
1222
|
}
|
|
848
|
-
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
return result;
|
|
1226
|
+
}
|
|
1227
|
+
/**
|
|
1228
|
+
* Configures whether roving tab index is disabled.
|
|
1229
|
+
* @param {boolean} [disabled=true] Whether the roving tab index is disabled.
|
|
1230
|
+
* @returns {RovingTabIndexManager<T>} The configured roving tab index manager.
|
|
1231
|
+
*/
|
|
1232
|
+
disableRovingTabIndex(disabled = true) {
|
|
1233
|
+
if (disabled !== __classPrivateFieldGet(this, _RovingTabIndexManager_disableRovingTabIndex, "f")) {
|
|
1234
|
+
__classPrivateFieldSet(this, _RovingTabIndexManager_disableRovingTabIndex, disabled, "f");
|
|
1235
|
+
for (const item of this.items) {
|
|
1236
|
+
if (!this.skipPredicate(item)) {
|
|
1237
|
+
item?.setAttribute("tabindex", __classPrivateFieldGet(this, _RovingTabIndexManager_disableRovingTabIndex, "f") || item === this.activeItem ? "0" : "-1");
|
|
863
1238
|
}
|
|
864
|
-
|
|
1239
|
+
}
|
|
865
1240
|
}
|
|
1241
|
+
return this;
|
|
1242
|
+
}
|
|
866
1243
|
}
|
|
867
1244
|
_RovingTabIndexManager_disableRovingTabIndex = new WeakMap();
|
|
868
1245
|
|
|
@@ -872,37 +1249,44 @@ var _RadioKeyManager_disabled;
|
|
|
872
1249
|
* @template T The type of managed item.
|
|
873
1250
|
*/
|
|
874
1251
|
class RadioKeyManager extends RovingTabIndexManager {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
1252
|
+
constructor() {
|
|
1253
|
+
super(...arguments);
|
|
1254
|
+
/** @private */
|
|
1255
|
+
_RadioKeyManager_disabled.set(this, false);
|
|
1256
|
+
}
|
|
1257
|
+
/** A value indicating whether managed items are disabled. */
|
|
1258
|
+
get disabled() {
|
|
1259
|
+
return __classPrivateFieldGet(this, _RadioKeyManager_disabled, "f");
|
|
1260
|
+
}
|
|
1261
|
+
set disabled(value) {
|
|
1262
|
+
__classPrivateFieldSet(this, _RadioKeyManager_disabled, value, "f");
|
|
1263
|
+
this.items.forEach(x => x.disabled = value);
|
|
1264
|
+
}
|
|
1265
|
+
/** @inheritdoc */
|
|
1266
|
+
setItems(items) {
|
|
1267
|
+
if (this.disabled) {
|
|
1268
|
+
items.forEach(x => x.disabled = true);
|
|
1269
|
+
}
|
|
1270
|
+
const {
|
|
1271
|
+
added,
|
|
1272
|
+
removed
|
|
1273
|
+
} = super.setItems(items);
|
|
1274
|
+
if (added.length > 0 || removed.length > 0) {
|
|
1275
|
+
if (!this.activeItem) {
|
|
1276
|
+
this.updateActiveItem(added.find(x => !this.skipPredicate(x)) ?? null);
|
|
1277
|
+
}
|
|
1278
|
+
if (this.activeItem && (this.activeItem.disabled || !isCheckedOrSelected(this.activeItem))) {
|
|
1279
|
+
const checked = added.find(x => !this.skipPredicate(x) && isCheckedOrSelected(x));
|
|
1280
|
+
if (checked) {
|
|
1281
|
+
this.updateActiveItem(checked);
|
|
891
1282
|
}
|
|
892
|
-
|
|
893
|
-
if (added.length > 0 || removed.length > 0) {
|
|
894
|
-
if (!this.activeItem) {
|
|
895
|
-
this.updateActiveItem(added.find((x) => !this.skipPredicate(x)) ?? null);
|
|
896
|
-
}
|
|
897
|
-
if (this.activeItem && (this.activeItem.disabled || !isCheckedOrSelected(this.activeItem))) {
|
|
898
|
-
const checked = added.find((x) => !this.skipPredicate(x) && isCheckedOrSelected(x));
|
|
899
|
-
if (checked) {
|
|
900
|
-
this.updateActiveItem(checked);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
return { added, removed };
|
|
1283
|
+
}
|
|
905
1284
|
}
|
|
1285
|
+
return {
|
|
1286
|
+
added,
|
|
1287
|
+
removed
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
906
1290
|
}
|
|
907
1291
|
_RadioKeyManager_disabled = new WeakMap();
|
|
908
1292
|
|
|
@@ -914,111 +1298,119 @@ const selectionManager = Symbol("selectionManager");
|
|
|
914
1298
|
* @template T The type of managed item.
|
|
915
1299
|
*/
|
|
916
1300
|
class SelectionManager extends RadioKeyManager {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
1301
|
+
constructor() {
|
|
1302
|
+
super(...arguments);
|
|
1303
|
+
_SelectionManager_instances.add(this);
|
|
1304
|
+
/** @private */
|
|
1305
|
+
_SelectionManager_onSelectedItemsChangeCallback.set(this, void 0);
|
|
1306
|
+
/** @private */
|
|
1307
|
+
_SelectionManager_selectedItems.set(this, new Array());
|
|
1308
|
+
/** @private */
|
|
1309
|
+
_SelectionManager_multi.set(this, false);
|
|
1310
|
+
}
|
|
1311
|
+
/** A value indicating whether multiple items can be selected. */
|
|
1312
|
+
get multi() {
|
|
1313
|
+
return __classPrivateFieldGet(this, _SelectionManager_multi, "f");
|
|
1314
|
+
}
|
|
1315
|
+
set multi(value) {
|
|
1316
|
+
__classPrivateFieldSet(this, _SelectionManager_multi, value, "f");
|
|
1317
|
+
__classPrivateFieldGet(this, _SelectionManager_instances, "m", _SelectionManager_enforceSingleSelect).call(this, true);
|
|
1318
|
+
}
|
|
1319
|
+
/** The selected items. */
|
|
1320
|
+
get selectedItems() {
|
|
1321
|
+
return __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f");
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Selects or deselects the item based on the item's checked or selected state.
|
|
1325
|
+
* @param {T} item The item whose selection state has changed.
|
|
1326
|
+
*/
|
|
1327
|
+
notifySelectionChange(item) {
|
|
1328
|
+
if (this.items.includes(item)) {
|
|
1329
|
+
if (isCheckedOrSelected(item)) {
|
|
1330
|
+
this.select(item);
|
|
1331
|
+
} else {
|
|
1332
|
+
this.deselect(item);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Deselects the specified item.
|
|
1338
|
+
* @param {T} item The item to deselect.
|
|
1339
|
+
*/
|
|
1340
|
+
deselect(item) {
|
|
1341
|
+
if (this.items.includes(item)) {
|
|
1342
|
+
if (isCheckedOrSelected(item)) {
|
|
1343
|
+
checkOrSelect(item, false);
|
|
1344
|
+
}
|
|
1345
|
+
const index = __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").indexOf(item);
|
|
1346
|
+
if (index >= 0) {
|
|
1347
|
+
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").splice(index, 1);
|
|
1348
|
+
__classPrivateFieldGet(this, _SelectionManager_onSelectedItemsChangeCallback, "f")?.call(this);
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Updates the selected item.
|
|
1354
|
+
* @param {T | null | undefined} item The selected item.
|
|
1355
|
+
* @param {boolean} [activate=true] A value indicating whether to activate the item.
|
|
1356
|
+
*/
|
|
1357
|
+
select(item, activate = true) {
|
|
1358
|
+
if (!item || this.items.includes(item)) {
|
|
1359
|
+
if (!this.multi) {
|
|
1360
|
+
for (const selected of __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f")) {
|
|
1361
|
+
if (selected !== item) {
|
|
1362
|
+
checkOrSelect(selected, false);
|
|
1363
|
+
}
|
|
964
1364
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
select(item, activate = true) {
|
|
972
|
-
if (!item || this.items.includes(item)) {
|
|
973
|
-
if (!this.multi) {
|
|
974
|
-
for (const selected of __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f")) {
|
|
975
|
-
if (selected !== item) {
|
|
976
|
-
checkOrSelect(selected, false);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").length = 0;
|
|
980
|
-
}
|
|
981
|
-
if (item) {
|
|
982
|
-
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").push(item);
|
|
983
|
-
if (!isCheckedOrSelected(item)) {
|
|
984
|
-
checkOrSelect(item, true);
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
if (activate) {
|
|
988
|
-
this.updateActiveItem(item);
|
|
989
|
-
}
|
|
990
|
-
__classPrivateFieldGet(this, _SelectionManager_onSelectedItemsChangeCallback, "f")?.call(this);
|
|
1365
|
+
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").length = 0;
|
|
1366
|
+
}
|
|
1367
|
+
if (item) {
|
|
1368
|
+
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").push(item);
|
|
1369
|
+
if (!isCheckedOrSelected(item)) {
|
|
1370
|
+
checkOrSelect(item, true);
|
|
991
1371
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1372
|
+
}
|
|
1373
|
+
if (activate) {
|
|
1374
|
+
this.updateActiveItem(item);
|
|
1375
|
+
}
|
|
1376
|
+
__classPrivateFieldGet(this, _SelectionManager_onSelectedItemsChangeCallback, "f")?.call(this);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
/** @inheritdoc */
|
|
1380
|
+
setItems(items) {
|
|
1381
|
+
const {
|
|
1382
|
+
added,
|
|
1383
|
+
removed
|
|
1384
|
+
} = super.setItems(items);
|
|
1385
|
+
__classPrivateFieldSet(this, _SelectionManager_selectedItems, __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").filter(x => !removed.includes(x)), "f");
|
|
1386
|
+
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").push(...added.filter(x => isCheckedOrSelected(x)));
|
|
1387
|
+
__classPrivateFieldGet(this, _SelectionManager_instances, "m", _SelectionManager_enforceSingleSelect).call(this);
|
|
1388
|
+
__classPrivateFieldGet(this, _SelectionManager_onSelectedItemsChangeCallback, "f")?.call(this);
|
|
1389
|
+
return {
|
|
1390
|
+
added,
|
|
1391
|
+
removed
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Configures the selection manager with a callback invoked when selected items change.
|
|
1396
|
+
* @param {() => void} callback The callback invoked when selected items change.
|
|
1397
|
+
* @returns {SelectionManager<T>} The configured selection manager.
|
|
1398
|
+
*/
|
|
1399
|
+
onSelectedItemsChange(callback) {
|
|
1400
|
+
__classPrivateFieldSet(this, _SelectionManager_onSelectedItemsChangeCallback, callback, "f");
|
|
1401
|
+
return this;
|
|
1402
|
+
}
|
|
1011
1403
|
}
|
|
1012
1404
|
_SelectionManager_onSelectedItemsChangeCallback = new WeakMap(), _SelectionManager_selectedItems = new WeakMap(), _SelectionManager_multi = new WeakMap(), _SelectionManager_instances = new WeakSet(), _SelectionManager_enforceSingleSelect = function _SelectionManager_enforceSingleSelect(emit = false) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
}
|
|
1405
|
+
if (!this.multi && __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").length > 1) {
|
|
1406
|
+
for (let i = 1; i < __classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").length; i++) {
|
|
1407
|
+
checkOrSelect(__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f")[i], false);
|
|
1408
|
+
}
|
|
1409
|
+
__classPrivateFieldGet(this, _SelectionManager_selectedItems, "f").length = 1;
|
|
1410
|
+
if (emit) {
|
|
1411
|
+
__classPrivateFieldGet(this, _SelectionManager_onSelectedItemsChangeCallback, "f")?.call(this);
|
|
1021
1412
|
}
|
|
1413
|
+
}
|
|
1022
1414
|
};
|
|
1023
1415
|
|
|
1024
1416
|
/**
|
|
@@ -1036,7 +1428,7 @@ _SelectionManager_onSelectedItemsChangeCallback = new WeakMap(), _SelectionManag
|
|
|
1036
1428
|
* @returns {string[]} a list of IDs referenced by `element` for `attribute`.
|
|
1037
1429
|
*/
|
|
1038
1430
|
function getAriaReferenceIds(element, attribute) {
|
|
1039
|
-
|
|
1431
|
+
return element.getAttribute(attribute)?.match(/\S+/g) ?? [];
|
|
1040
1432
|
}
|
|
1041
1433
|
/**
|
|
1042
1434
|
* Adds an ID to the list of IDs referenced by an element for a given ARIA attribute.
|
|
@@ -1045,12 +1437,12 @@ function getAriaReferenceIds(element, attribute) {
|
|
|
1045
1437
|
* @param {string} id The ID to add.
|
|
1046
1438
|
*/
|
|
1047
1439
|
function addAriaReferencedId(element, attribute, id) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1440
|
+
id = id.trim();
|
|
1441
|
+
const ids = getAriaReferenceIds(element, attribute);
|
|
1442
|
+
if (!ids.some(existingId => existingId.trim() === id)) {
|
|
1443
|
+
ids.push(id);
|
|
1444
|
+
element.setAttribute(attribute, ids.join(" "));
|
|
1445
|
+
}
|
|
1054
1446
|
}
|
|
1055
1447
|
/**
|
|
1056
1448
|
* Removes an ID from a list of IDs referenced by an element for the specified ARIA attribute.
|
|
@@ -1059,14 +1451,13 @@ function addAriaReferencedId(element, attribute, id) {
|
|
|
1059
1451
|
* @param {string} id The ID to remove.
|
|
1060
1452
|
*/
|
|
1061
1453
|
function removeAriaReferencedId(element, attribute, id) {
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
}
|
|
1454
|
+
id = id.trim();
|
|
1455
|
+
const ids = getAriaReferenceIds(element, attribute).filter(val => val !== id);
|
|
1456
|
+
if (ids.length > 0) {
|
|
1457
|
+
element.setAttribute(attribute, ids.join(" "));
|
|
1458
|
+
} else {
|
|
1459
|
+
element.removeAttribute(attribute);
|
|
1460
|
+
}
|
|
1070
1461
|
}
|
|
1071
1462
|
|
|
1072
1463
|
/**
|
|
@@ -1074,18 +1465,18 @@ function removeAriaReferencedId(element, attribute, id) {
|
|
|
1074
1465
|
* @param {CSSStyleDeclaration} style The style of the element to visually hide.
|
|
1075
1466
|
*/
|
|
1076
1467
|
function visuallyHide(style) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1468
|
+
style.position = "absolute";
|
|
1469
|
+
style.appearance = "none";
|
|
1470
|
+
style.visibility = "hidden";
|
|
1471
|
+
style.border = "0";
|
|
1472
|
+
style.outline = "0";
|
|
1473
|
+
style.overflow = "hidden";
|
|
1474
|
+
style.left = "0";
|
|
1475
|
+
style.height = "1px";
|
|
1476
|
+
style.width = "1px";
|
|
1477
|
+
style.margin = "-1px";
|
|
1478
|
+
style.padding = "0";
|
|
1479
|
+
style.whiteSpace = "nowrap";
|
|
1089
1480
|
}
|
|
1090
1481
|
|
|
1091
1482
|
/**
|
|
@@ -1099,134 +1490,141 @@ function visuallyHide(style) {
|
|
|
1099
1490
|
var _a$2, _M3eAriaDescriber_nextId, _M3eAriaDescriber_messageContainers, _M3eAriaDescriber_createMessageContainer, _M3eAriaDescriber_createMessageElement;
|
|
1100
1491
|
/** Utility for generating visually hidden elements that convey descriptive messages using `aria-describedby`. */
|
|
1101
1492
|
class M3eAriaDescriber {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1493
|
+
/**
|
|
1494
|
+
* Adds an `aria-describedby` reference to a hidden element that contains the message.
|
|
1495
|
+
* @param {Element} element The element for which to provide a visually hidden description.
|
|
1496
|
+
* @param {string} message The message used to describe `element`.
|
|
1497
|
+
* @param {string} [role="tooltip"] The ARIA role of the message.
|
|
1498
|
+
*/
|
|
1499
|
+
static describe(element, message, role = "tooltip") {
|
|
1500
|
+
if (isServer) {
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1503
|
+
const rootNode = element.getRootNode();
|
|
1504
|
+
if (!(rootNode instanceof ShadowRoot || rootNode instanceof Document)) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
let container = __classPrivateFieldGet(this, _a$2, "f", _M3eAriaDescriber_messageContainers).get(rootNode);
|
|
1508
|
+
if (!container) {
|
|
1509
|
+
container = {
|
|
1510
|
+
containerElement: __classPrivateFieldGet(this, _a$2, "m", _M3eAriaDescriber_createMessageContainer).call(this),
|
|
1511
|
+
messageRegistry: new Map()
|
|
1512
|
+
};
|
|
1513
|
+
// Append to body if document, otherwise, append as a child of shadow root.
|
|
1514
|
+
(rootNode instanceof Document ? rootNode.body : rootNode).appendChild(container.containerElement);
|
|
1515
|
+
__classPrivateFieldGet(this, _a$2, "f", _M3eAriaDescriber_messageContainers).set(rootNode, container);
|
|
1516
|
+
}
|
|
1517
|
+
const key = `${role}:${message}`;
|
|
1518
|
+
let entry = container.messageRegistry.get(key);
|
|
1519
|
+
if (!entry) {
|
|
1520
|
+
entry = {
|
|
1521
|
+
messageElement: __classPrivateFieldGet(this, _a$2, "m", _M3eAriaDescriber_createMessageElement).call(this, message, role),
|
|
1522
|
+
count: 0
|
|
1523
|
+
};
|
|
1524
|
+
container.containerElement.appendChild(entry.messageElement);
|
|
1525
|
+
container.messageRegistry.set(key, entry);
|
|
1526
|
+
}
|
|
1527
|
+
entry.count++;
|
|
1528
|
+
addAriaReferencedId(element, "aria-describedby", entry.messageElement.id);
|
|
1529
|
+
}
|
|
1530
|
+
/**
|
|
1531
|
+
* Removes an `aria-describedby` reference to a hidden element that contains the message.
|
|
1532
|
+
* @param {Element} element The element from which to remove a visually hidden description.
|
|
1533
|
+
* @param {string} message The message used to describe `element`.
|
|
1534
|
+
* @param {string} [role="tooltip"] The ARIA role of the message.
|
|
1535
|
+
*/
|
|
1536
|
+
static removeDescription(element, message, role = "tooltip") {
|
|
1537
|
+
if (isServer) {
|
|
1538
|
+
return;
|
|
1539
|
+
}
|
|
1540
|
+
const rootNode = element.getRootNode();
|
|
1541
|
+
const container = __classPrivateFieldGet(this, _a$2, "f", _M3eAriaDescriber_messageContainers).get(rootNode);
|
|
1542
|
+
if (!container) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
const key = `${role}:${message}`;
|
|
1546
|
+
const entry = container.messageRegistry.get(key);
|
|
1547
|
+
if (!entry) {
|
|
1548
|
+
return;
|
|
1549
|
+
}
|
|
1550
|
+
entry.count--;
|
|
1551
|
+
removeAriaReferencedId(element, "aria-describedby", entry.messageElement.id);
|
|
1552
|
+
// If there are no more elements referencing the message, remove it from the DOM.
|
|
1553
|
+
if (entry.count <= 0) {
|
|
1554
|
+
entry.messageElement.remove();
|
|
1555
|
+
container.messageRegistry.delete(key);
|
|
1556
|
+
}
|
|
1557
|
+
// If there are no more registered messages, remove the container from the DOM.
|
|
1558
|
+
if (container.messageRegistry.size == 0) {
|
|
1559
|
+
container.containerElement?.remove();
|
|
1560
|
+
__classPrivateFieldGet(this, _a$2, "f", _M3eAriaDescriber_messageContainers).delete(rootNode);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1169
1563
|
}
|
|
1170
1564
|
_a$2 = M3eAriaDescriber, _M3eAriaDescriber_createMessageContainer = function _M3eAriaDescriber_createMessageContainer() {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1565
|
+
const messageContainer = document.createElement("div");
|
|
1566
|
+
messageContainer.classList.add("m3e-describedby-message-container");
|
|
1567
|
+
visuallyHide(messageContainer.style);
|
|
1568
|
+
return messageContainer;
|
|
1175
1569
|
}, _M3eAriaDescriber_createMessageElement = function _M3eAriaDescriber_createMessageElement(message, role) {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1570
|
+
var _b, _c;
|
|
1571
|
+
const messageElement = document.createElement("span");
|
|
1572
|
+
messageElement.id = `m3e-describedby-message-${__classPrivateFieldSet(this, _a$2, (_c = __classPrivateFieldGet(this, _a$2, "f", _M3eAriaDescriber_nextId), _b = _c++, _c), "f", _M3eAriaDescriber_nextId), _b}`;
|
|
1573
|
+
messageElement.role = role;
|
|
1574
|
+
messageElement.ariaAtomic = "true";
|
|
1575
|
+
messageElement.innerText = message.trim();
|
|
1576
|
+
return messageElement;
|
|
1577
|
+
};
|
|
1578
|
+
/** @private */
|
|
1579
|
+
_M3eAriaDescriber_nextId = {
|
|
1580
|
+
value: 0
|
|
1581
|
+
};
|
|
1582
|
+
/** @private */
|
|
1583
|
+
_M3eAriaDescriber_messageContainers = {
|
|
1584
|
+
value: new Map()
|
|
1183
1585
|
};
|
|
1184
|
-
/** @private */ _M3eAriaDescriber_nextId = { value: 0 };
|
|
1185
|
-
/** @private */ _M3eAriaDescriber_messageContainers = { value: new Map() };
|
|
1186
1586
|
globalThis.M3eAriaDescriber = M3eAriaDescriber;
|
|
1187
1587
|
|
|
1188
1588
|
var _a$1, _M3eInteractivityChecker_cannotFocusParent;
|
|
1189
1589
|
/** Utility for checking the interactivity of an element, such as whether it is focusable. */
|
|
1190
1590
|
class M3eInteractivityChecker {
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
return elements;
|
|
1226
|
-
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Determines whether a given element can receive focus.
|
|
1593
|
+
* @param {Element} element The element to test.
|
|
1594
|
+
* @param {readonly Element[]} [parents = undefined] The known parent elements to test. The default value is `undefined`.
|
|
1595
|
+
* @returns {boolean} Whether `element` can receive focus.
|
|
1596
|
+
*/
|
|
1597
|
+
static isFocusable(element, parents) {
|
|
1598
|
+
if (element.matches(":is(button,input,select,textarea,object,:is(a,area)[href],[tabindex],[contenteditable=true]):not(:disabled,[disabled])")) {
|
|
1599
|
+
return !__classPrivateFieldGet(this, _a$1, "m", _M3eInteractivityChecker_cannotFocusParent).call(this, parents);
|
|
1600
|
+
}
|
|
1601
|
+
if (!element.localName.includes("-") || !element.matches(":not(:disabled,[disabled])") || element.getAttribute("aria-disabled") === "true") {
|
|
1602
|
+
return false;
|
|
1603
|
+
}
|
|
1604
|
+
if (element.shadowRoot?.delegatesFocus) {
|
|
1605
|
+
return !__classPrivateFieldGet(this, _a$1, "m", _M3eInteractivityChecker_cannotFocusParent).call(this, parents);
|
|
1606
|
+
}
|
|
1607
|
+
return false;
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Finds interactive elements that descend from the specified element.
|
|
1611
|
+
* @param {HTMLElement} element The `HTMLElement` to search.
|
|
1612
|
+
* @returns {HTMLElement[]} The interactive elements that descend from `element`.
|
|
1613
|
+
*/
|
|
1614
|
+
static findInteractiveElements(element) {
|
|
1615
|
+
const elements = new Array();
|
|
1616
|
+
const walker = element.ownerDocument.createTreeWalker(element, NodeFilter.SHOW_ELEMENT);
|
|
1617
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1618
|
+
const element = walker.currentNode;
|
|
1619
|
+
if (this.isFocusable(element)) {
|
|
1620
|
+
elements.push(element);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return elements;
|
|
1624
|
+
}
|
|
1227
1625
|
}
|
|
1228
1626
|
_a$1 = M3eInteractivityChecker, _M3eInteractivityChecker_cannotFocusParent = function _M3eInteractivityChecker_cannotFocusParent(parents) {
|
|
1229
|
-
|
|
1627
|
+
return parents?.some(x => x.matches(":is([aria-hidden='true'],:disabled,[disabled])")) ?? false;
|
|
1230
1628
|
};
|
|
1231
1629
|
globalThis.M3eInteractivityChecker = M3eInteractivityChecker;
|
|
1232
1630
|
|
|
@@ -1240,102 +1638,77 @@ var _M3eFocusTrapElement_instances, _M3eFocusTrapElement_onFocus, _M3eFocusTrapE
|
|
|
1240
1638
|
* @attr disabled - Disables the focus trap.
|
|
1241
1639
|
*/
|
|
1242
1640
|
let M3eFocusTrapElement = class M3eFocusTrapElement extends Disabled(LitElement) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
tabindex="0"
|
|
1253
|
-
aria-hidden="true"
|
|
1254
|
-
@focus="${__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_onFocus)}"
|
|
1255
|
-
></div>`;
|
|
1256
|
-
return html `${trap}<slot></slot>${trap}`;
|
|
1257
|
-
}
|
|
1641
|
+
constructor() {
|
|
1642
|
+
super(...arguments);
|
|
1643
|
+
_M3eFocusTrapElement_instances.add(this);
|
|
1644
|
+
}
|
|
1645
|
+
/** @inheritdoc */
|
|
1646
|
+
render() {
|
|
1647
|
+
const trap = html`<div class="trap" .inert="${this.disabled}" tabindex="0" aria-hidden="true" @focus="${__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_onFocus)}"></div>`;
|
|
1648
|
+
return html`${trap}<slot></slot>${trap}`;
|
|
1649
|
+
}
|
|
1258
1650
|
};
|
|
1259
1651
|
_M3eFocusTrapElement_instances = new WeakSet();
|
|
1260
1652
|
_M3eFocusTrapElement_onFocus = function _M3eFocusTrapElement_onFocus(e) {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1653
|
+
const [first, last] = __classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_getFirstAndLastFocusableChild).call(this);
|
|
1654
|
+
const isFirst = e?.target === this._firstTrap;
|
|
1655
|
+
const fromFirst = e.relatedTarget === first;
|
|
1656
|
+
const fromLast = e.relatedTarget === last;
|
|
1657
|
+
const fromOutside = !fromFirst && !fromLast;
|
|
1658
|
+
if (!isFirst && fromLast || isFirst && fromOutside) {
|
|
1659
|
+
first?.focus();
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
if (isFirst && fromFirst || !isFirst && fromOutside) {
|
|
1663
|
+
last?.focus();
|
|
1664
|
+
}
|
|
1273
1665
|
};
|
|
1274
1666
|
_M3eFocusTrapElement_getFirstAndLastFocusableChild = function _M3eFocusTrapElement_getFirstAndLastFocusableChild() {
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
});
|
|
1285
|
-
return [first, last];
|
|
1667
|
+
let first = null;
|
|
1668
|
+
let last = null;
|
|
1669
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, this, [], (element, parents) => {
|
|
1670
|
+
if (M3eInteractivityChecker.isFocusable(element, parents) && element instanceof HTMLElement && element.tabIndex >= 0) {
|
|
1671
|
+
first = first ?? element;
|
|
1672
|
+
last = element;
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
return [first, last];
|
|
1286
1676
|
};
|
|
1287
1677
|
_M3eFocusTrapElement_walkTree = function _M3eFocusTrapElement_walkTree(root, parents, callback) {
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, element, parents, callback);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1678
|
+
parents = [...parents, root];
|
|
1679
|
+
for (const node of root.childNodes) {
|
|
1680
|
+
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
1681
|
+
const element = node;
|
|
1682
|
+
callback(element, parents);
|
|
1683
|
+
if (element.shadowRoot) {
|
|
1684
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkShadowRoot).call(this, element, parents, callback);
|
|
1685
|
+
} else if (element instanceof HTMLSlotElement) {
|
|
1686
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkSlot).call(this, element, parents, callback);
|
|
1687
|
+
} else if (element.hasChildNodes()) {
|
|
1688
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, element, parents, callback);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1304
1691
|
};
|
|
1305
1692
|
_M3eFocusTrapElement_walkShadowRoot = function _M3eFocusTrapElement_walkShadowRoot(root, parents, callback) {
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, element, parents, callback);
|
|
1314
|
-
}
|
|
1693
|
+
for (const node of root.shadowRoot?.childNodes ?? []) {
|
|
1694
|
+
if (node.nodeType !== Node.ELEMENT_NODE) continue;
|
|
1695
|
+
const element = node;
|
|
1696
|
+
callback(element, parents);
|
|
1697
|
+
if (!element.hasChildNodes()) continue;
|
|
1698
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, element, parents, callback);
|
|
1699
|
+
}
|
|
1315
1700
|
};
|
|
1316
1701
|
_M3eFocusTrapElement_walkSlot = function _M3eFocusTrapElement_walkSlot(slot, parents, callback) {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
}
|
|
1702
|
+
for (const node of slot.assignedElements()) {
|
|
1703
|
+
callback(node, parents);
|
|
1704
|
+
if (!node.hasChildNodes()) continue;
|
|
1705
|
+
__classPrivateFieldGet(this, _M3eFocusTrapElement_instances, "m", _M3eFocusTrapElement_walkTree).call(this, node, parents, callback);
|
|
1706
|
+
}
|
|
1323
1707
|
};
|
|
1324
1708
|
/** The styles of the element. */
|
|
1325
|
-
M3eFocusTrapElement.styles = css
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1329
|
-
.trap {
|
|
1330
|
-
outline: none;
|
|
1331
|
-
}
|
|
1332
|
-
`;
|
|
1333
|
-
__decorate([
|
|
1334
|
-
e(".trap")
|
|
1335
|
-
], M3eFocusTrapElement.prototype, "_firstTrap", void 0);
|
|
1336
|
-
M3eFocusTrapElement = __decorate([
|
|
1337
|
-
t$1("m3e-focus-trap")
|
|
1338
|
-
], M3eFocusTrapElement);
|
|
1709
|
+
M3eFocusTrapElement.styles = css`:host { display: contents; } .trap { outline: none; }`;
|
|
1710
|
+
__decorate([e(".trap")], M3eFocusTrapElement.prototype, "_firstTrap", void 0);
|
|
1711
|
+
M3eFocusTrapElement = __decorate([t$1("m3e-focus-trap")], M3eFocusTrapElement);
|
|
1339
1712
|
|
|
1340
1713
|
/**
|
|
1341
1714
|
* Adapted from Angular Material CDK Live Announcer
|
|
@@ -1348,71 +1721,85 @@ M3eFocusTrapElement = __decorate([
|
|
|
1348
1721
|
var _a, _M3eLiveAnnouncer_nextId, _M3eLiveAnnouncer_liveElement, _M3eLiveAnnouncer_previousTimeout, _M3eLiveAnnouncer_currentPromise, _M3eLiveAnnouncer_currentResolve, _M3eLiveAnnouncer_createLiveElement;
|
|
1349
1722
|
/** Utility for announcing messages to screen readers. */
|
|
1350
1723
|
class M3eLiveAnnouncer {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
}
|
|
1724
|
+
static announce(message, ...args) {
|
|
1725
|
+
if (isServer) {
|
|
1726
|
+
return Promise.resolve();
|
|
1727
|
+
}
|
|
1728
|
+
__classPrivateFieldSet(this, _a, __classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement) ?? __classPrivateFieldGet(this, _a, "m", _M3eLiveAnnouncer_createLiveElement).call(this), "f", _M3eLiveAnnouncer_liveElement);
|
|
1729
|
+
let politeness;
|
|
1730
|
+
let duration;
|
|
1731
|
+
if (args.length === 1 && typeof args[0] === "number") {
|
|
1732
|
+
duration = args[0];
|
|
1733
|
+
} else {
|
|
1734
|
+
[politeness, duration] = args;
|
|
1735
|
+
}
|
|
1736
|
+
this.clear();
|
|
1737
|
+
clearTimeout(__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_previousTimeout));
|
|
1738
|
+
__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement).setAttribute("aria-live", politeness ?? "polite");
|
|
1739
|
+
for (const modal of document.querySelectorAll("m3e-dialog")) {
|
|
1740
|
+
addAriaReferencedId(modal, "aria-owns", __classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement).id);
|
|
1741
|
+
}
|
|
1742
|
+
__classPrivateFieldSet(this, _a, __classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_currentPromise) ?? new Promise(resolve => __classPrivateFieldSet(this, _a, resolve, "f", _M3eLiveAnnouncer_currentResolve)), "f", _M3eLiveAnnouncer_currentPromise);
|
|
1743
|
+
clearTimeout(__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_previousTimeout));
|
|
1744
|
+
__classPrivateFieldSet(this, _a, setTimeout(() => {
|
|
1745
|
+
if (!__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement)) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement).textContent = message;
|
|
1749
|
+
if (duration !== undefined) {
|
|
1750
|
+
__classPrivateFieldSet(this, _a, setTimeout(() => this.clear(), duration), "f", _M3eLiveAnnouncer_previousTimeout);
|
|
1751
|
+
}
|
|
1752
|
+
__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_currentResolve)?.call(this);
|
|
1753
|
+
__classPrivateFieldSet(this, _a, __classPrivateFieldSet(this, _a, undefined, "f", _M3eLiveAnnouncer_currentResolve), "f", _M3eLiveAnnouncer_currentPromise);
|
|
1754
|
+
}, 100), "f", _M3eLiveAnnouncer_previousTimeout);
|
|
1755
|
+
return __classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_currentPromise);
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Clears the current text from the announcer element. Can be used to prevent
|
|
1759
|
+
* screen readers from reading the text out again while the user is going
|
|
1760
|
+
* through page landmarks.
|
|
1761
|
+
*/
|
|
1762
|
+
static clear() {
|
|
1763
|
+
if (__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement)) {
|
|
1764
|
+
__classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_liveElement).textContent = "";
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1395
1767
|
}
|
|
1396
1768
|
_a = M3eLiveAnnouncer, _M3eLiveAnnouncer_createLiveElement = function _M3eLiveAnnouncer_createLiveElement() {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1769
|
+
var _b, _c;
|
|
1770
|
+
const prev = document.getElementsByClassName("m3e-live-announcer");
|
|
1771
|
+
for (let i = 0; i < prev.length; i++) {
|
|
1772
|
+
prev[i].remove();
|
|
1773
|
+
}
|
|
1774
|
+
const liveAnnouncer = document.createElement("div");
|
|
1775
|
+
liveAnnouncer.classList.add("m3e-live-announcer");
|
|
1776
|
+
liveAnnouncer.setAttribute("aria-atomic", "true");
|
|
1777
|
+
liveAnnouncer.setAttribute("aria-live", "polite");
|
|
1778
|
+
liveAnnouncer.id = `m3e-live-announcer-${__classPrivateFieldSet(this, _a, (_c = __classPrivateFieldGet(this, _a, "f", _M3eLiveAnnouncer_nextId), _b = _c++, _c), "f", _M3eLiveAnnouncer_nextId), _b}`;
|
|
1779
|
+
visuallyHide(liveAnnouncer.style);
|
|
1780
|
+
document.body.append(liveAnnouncer);
|
|
1781
|
+
return liveAnnouncer;
|
|
1782
|
+
};
|
|
1783
|
+
/** @private */
|
|
1784
|
+
_M3eLiveAnnouncer_nextId = {
|
|
1785
|
+
value: 0
|
|
1786
|
+
};
|
|
1787
|
+
/** @private */
|
|
1788
|
+
_M3eLiveAnnouncer_liveElement = {
|
|
1789
|
+
value: void 0
|
|
1790
|
+
};
|
|
1791
|
+
/** @private */
|
|
1792
|
+
_M3eLiveAnnouncer_previousTimeout = {
|
|
1793
|
+
value: void 0
|
|
1794
|
+
};
|
|
1795
|
+
/** @private */
|
|
1796
|
+
_M3eLiveAnnouncer_currentPromise = {
|
|
1797
|
+
value: void 0
|
|
1798
|
+
};
|
|
1799
|
+
/** @private */
|
|
1800
|
+
_M3eLiveAnnouncer_currentResolve = {
|
|
1801
|
+
value: void 0
|
|
1410
1802
|
};
|
|
1411
|
-
/** @private */ _M3eLiveAnnouncer_nextId = { value: 0 };
|
|
1412
|
-
/** @private */ _M3eLiveAnnouncer_liveElement = { value: void 0 };
|
|
1413
|
-
/** @private */ _M3eLiveAnnouncer_previousTimeout = { value: void 0 };
|
|
1414
|
-
/** @private */ _M3eLiveAnnouncer_currentPromise = { value: void 0 };
|
|
1415
|
-
/** @private */ _M3eLiveAnnouncer_currentResolve = { value: void 0 };
|
|
1416
1803
|
globalThis.M3eLiveAnnouncer = M3eLiveAnnouncer;
|
|
1417
1804
|
|
|
1418
1805
|
export { FocusKeyManager, KeyCode, ListKeyManager, ListManager, M3eAriaDescriber, M3eFocusTrapElement, M3eInteractivityChecker, M3eLiveAnnouncer, ModifierKeys, RadioKeyManager, RovingTabIndexManager, SelectionManager, Typeahead, addAriaReferencedId, getAriaReferenceIds, getKeyCode, hasModifierKey, isModifierAllowed, isTypeaheadItem, removeAriaReferencedId, selectionManager, typeaheadLabel };
|