@covalent/components 6.0.1 → 6.0.2
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/action-ribbon.mjs +9 -7
- package/alert.mjs +13 -11
- package/app-shell.mjs +10 -4
- package/aria-property.mjs +41 -0
- package/base-element.mjs +28 -0
- package/button.mjs +180 -13
- package/card.mjs +3 -3
- package/check-list-item.mjs +92 -14
- package/checkbox.mjs +26 -14
- package/circular-progress.mjs +144 -10
- package/class-map.mjs +62 -0
- package/code-snippet.mjs +6 -5
- package/covalent.mjs +2 -2
- package/covalent.umd.js +3339 -137
- package/dialog.mjs +750 -15
- package/directive-helpers.mjs +11 -0
- package/drawer.mjs +26 -15
- package/empty-state.mjs +4 -4
- package/event-options.mjs +14 -0
- package/form-element.mjs +50 -0
- package/foundation.mjs +152 -0
- package/foundation2.mjs +60 -0
- package/icon-button.mjs +130 -15
- package/icon-check-toggle.mjs +18 -8
- package/icon-radio-toggle.mjs +29 -18
- package/icon.mjs +19 -13
- package/if-defined.mjs +10 -0
- package/inert.esm.mjs +640 -0
- package/linear-progress.mjs +178 -15
- package/list-expansion.mjs +33 -22
- package/list-item.mjs +19 -20
- package/list.mjs +26 -13
- package/menu.mjs +32 -13
- package/mwc-checkbox-base.mjs +198 -0
- package/mwc-checkbox.css.mjs +10 -0
- package/mwc-drawer-base.mjs +335 -0
- package/mwc-icon.mjs +26 -0
- package/mwc-line-ripple-directive.mjs +653 -0
- package/mwc-list-base.mjs +840 -0
- package/mwc-list-item-base.mjs +202 -0
- package/mwc-list-item.css.mjs +17 -0
- package/mwc-menu-base.mjs +1145 -0
- package/mwc-radio-base.mjs +528 -0
- package/mwc-radio.css.mjs +10 -0
- package/mwc-slider.css.mjs +956 -0
- package/mwc-tab-base.mjs +694 -0
- package/mwc-top-app-bar-base.mjs +380 -0
- package/nav-list-item.mjs +28 -20
- package/observer.mjs +32 -0
- package/package.json +9 -2
- package/property.mjs +20 -0
- package/query-assigned-elements.mjs +615 -0
- package/query-assigned-nodes.mjs +17 -0
- package/query.mjs +25 -0
- package/radio-list-item.mjs +93 -12
- package/radio.mjs +28 -15
- package/ripple-handlers.mjs +761 -0
- package/select.mjs +1257 -15
- package/side-sheet.mjs +21 -16
- package/slider-range.mjs +438 -11
- package/slider.mjs +253 -13
- package/snackbar.mjs +456 -15
- package/src/action-ribbon/action-ribbon-base.d.ts +30 -0
- package/src/action-ribbon/action-ribbon-base.d.ts.map +1 -0
- package/src/action-ribbon/action-ribbon.d.ts +15 -0
- package/src/action-ribbon/action-ribbon.d.ts.map +1 -0
- package/src/alert/alert-base.d.ts +31 -0
- package/src/alert/alert-base.d.ts.map +1 -0
- package/src/alert/alert.d.ts +15 -0
- package/src/alert/alert.d.ts.map +1 -0
- package/src/app-shell/app-shell.d.ts +26 -0
- package/src/app-shell/app-shell.d.ts.map +1 -0
- package/src/button/button.d.ts +10 -0
- package/src/button/button.d.ts.map +1 -0
- package/src/card/card-base.d.ts +25 -0
- package/src/card/card-base.d.ts.map +1 -0
- package/src/card/card.d.ts +10 -0
- package/src/card/card.d.ts.map +1 -0
- package/src/checkbox/checkbox.d.ts +10 -0
- package/src/checkbox/checkbox.d.ts.map +1 -0
- package/src/chips/chip-base.d.ts +52 -0
- package/src/chips/chip-base.d.ts.map +1 -0
- package/src/chips/chip-set-base.d.ts +33 -0
- package/src/chips/chip-set-base.d.ts.map +1 -0
- package/src/chips/chip-set.d.ts +15 -0
- package/src/chips/chip-set.d.ts.map +1 -0
- package/src/chips/chip.d.ts +15 -0
- package/src/chips/chip.d.ts.map +1 -0
- package/src/chips/foundation.d.ts +60 -0
- package/src/chips/foundation.d.ts.map +1 -0
- package/src/circular-progress/circular-progress.d.ts +10 -0
- package/src/circular-progress/circular-progress.d.ts.map +1 -0
- package/src/code-snippet/code-snippet.d.ts +21 -0
- package/src/code-snippet/code-snippet.d.ts.map +1 -0
- package/src/dialog/dialog.d.ts +10 -0
- package/src/dialog/dialog.d.ts.map +1 -0
- package/src/drawer/drawer.d.ts +10 -0
- package/src/drawer/drawer.d.ts.map +1 -0
- package/src/empty-state/empty-state.d.ts +16 -0
- package/src/empty-state/empty-state.d.ts.map +1 -0
- package/src/formfield/formfield.d.ts +10 -0
- package/src/formfield/formfield.d.ts.map +1 -0
- package/src/icon/icon.d.ts +10 -0
- package/src/icon/icon.d.ts.map +1 -0
- package/src/icon-button/icon-button.d.ts +10 -0
- package/src/icon-button/icon-button.d.ts.map +1 -0
- package/src/icon-checkbox/icon-check-toggle.d.ts +15 -0
- package/src/icon-checkbox/icon-check-toggle.d.ts.map +1 -0
- package/src/icon-radio/icon-radio-toggle.d.ts +14 -0
- package/src/icon-radio/icon-radio-toggle.d.ts.map +1 -0
- package/src/index.d.ts +3 -0
- package/src/index.d.ts.map +1 -0
- package/src/linear-progress/linear-progress.d.ts +10 -0
- package/src/linear-progress/linear-progress.d.ts.map +1 -0
- package/src/list/check-list-item.d.ts +10 -0
- package/src/list/check-list-item.d.ts.map +1 -0
- package/src/list/list-expansion.d.ts +18 -0
- package/src/list/list-expansion.d.ts.map +1 -0
- package/src/list/list-item.d.ts +12 -0
- package/src/list/list-item.d.ts.map +1 -0
- package/src/list/list.d.ts +10 -0
- package/src/list/list.d.ts.map +1 -0
- package/src/list/nav-list-item.d.ts +12 -0
- package/src/list/nav-list-item.d.ts.map +1 -0
- package/src/list/radio-list-item.d.ts +10 -0
- package/src/list/radio-list-item.d.ts.map +1 -0
- package/src/menu/menu.d.ts +10 -0
- package/src/menu/menu.d.ts.map +1 -0
- package/src/radio/radio.d.ts +10 -0
- package/src/radio/radio.d.ts.map +1 -0
- package/src/select/select.d.ts +10 -0
- package/src/select/select.d.ts.map +1 -0
- package/src/side-sheet/side-sheet.d.ts +18 -0
- package/src/side-sheet/side-sheet.d.ts.map +1 -0
- package/src/slider/slider-range.d.ts +10 -0
- package/src/slider/slider-range.d.ts.map +1 -0
- package/src/slider/slider.d.ts +10 -0
- package/src/slider/slider.d.ts.map +1 -0
- package/src/snackbar/snackbar.d.ts +10 -0
- package/src/snackbar/snackbar.d.ts.map +1 -0
- package/src/status-header/status-header-base.d.ts +9 -0
- package/src/status-header/status-header-base.d.ts.map +1 -0
- package/src/status-header/status-header-item.d.ts +17 -0
- package/src/status-header/status-header-item.d.ts.map +1 -0
- package/src/status-header/status-header.d.ts +15 -0
- package/src/status-header/status-header.d.ts.map +1 -0
- package/src/switch/switch.d.ts +10 -0
- package/src/switch/switch.d.ts.map +1 -0
- package/src/tab/tab-bar.d.ts +10 -0
- package/src/tab/tab-bar.d.ts.map +1 -0
- package/src/tab/tab.d.ts +10 -0
- package/src/tab/tab.d.ts.map +1 -0
- package/src/text-lockup/text-lockup.d.ts +17 -0
- package/src/text-lockup/text-lockup.d.ts.map +1 -0
- package/src/textarea/textarea.d.ts +10 -0
- package/src/textarea/textarea.d.ts.map +1 -0
- package/src/textfield/textfield.d.ts +10 -0
- package/src/textfield/textfield.d.ts.map +1 -0
- package/src/toolbar/toolbar.d.ts +10 -0
- package/src/toolbar/toolbar.d.ts.map +1 -0
- package/src/tooltip/tooltip.d.ts +27 -0
- package/src/tooltip/tooltip.d.ts.map +1 -0
- package/src/top-app-bar/top-app-bar-fixed.d.ts +10 -0
- package/src/top-app-bar/top-app-bar-fixed.d.ts.map +1 -0
- package/src/top-app-bar/top-app-bar.d.ts +10 -0
- package/src/top-app-bar/top-app-bar.d.ts.map +1 -0
- package/src/tree-list/tree-list-item.d.ts +16 -0
- package/src/tree-list/tree-list-item.d.ts.map +1 -0
- package/src/tree-list/tree-list.d.ts +11 -0
- package/src/tree-list/tree-list.d.ts.map +1 -0
- package/src/typography/typography.d.ts +12 -0
- package/src/typography/typography.d.ts.map +1 -0
- package/state.mjs +12 -0
- package/status-header-item.mjs +16 -16
- package/status-header.mjs +5 -5
- package/style-map.mjs +40 -0
- package/switch.mjs +531 -15
- package/tab-bar.mjs +1030 -13
- package/tab.mjs +29 -15
- package/text-lockup.mjs +8 -8
- package/textarea.mjs +111 -16
- package/textfield.mjs +34 -18
- package/textfield2.mjs +929 -2
- package/toolbar.mjs +8 -3
- package/tooltip.mjs +1153 -96
- package/top-app-bar-fixed.mjs +78 -18
- package/top-app-bar.mjs +19 -15
- package/top-app-bar2.mjs +9 -2
- package/tree-list-item.mjs +3 -3
- package/tree-list.mjs +6 -7
- package/tslib.es6.mjs +82 -0
- package/typography.mjs +8 -8
- package/utils.mjs +52 -0
package/inert.esm.mjs
ADDED
@@ -0,0 +1,640 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2016 Google Inc. All rights reserved.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
(() => {
|
18
|
+
var E, m, N;
|
19
|
+
const l = Symbol(), g = Symbol(), I = Symbol(), v = Symbol(), S = Symbol(), T = Symbol(), u = Symbol(), t = Symbol(), e = Symbol(), i = Symbol(), r = Symbol(), a = Symbol(), f = Symbol();
|
20
|
+
class _ {
|
21
|
+
constructor() {
|
22
|
+
this[E] = [], this[m] = [], this[N] = /* @__PURE__ */ new Set();
|
23
|
+
}
|
24
|
+
destructor() {
|
25
|
+
this[e](this[I]);
|
26
|
+
const n = this;
|
27
|
+
n[l] = null, n[I] = null, n[g] = null;
|
28
|
+
}
|
29
|
+
get top() {
|
30
|
+
const n = this[l];
|
31
|
+
return n[n.length - 1] || null;
|
32
|
+
}
|
33
|
+
push(n) {
|
34
|
+
!n || n === this.top || (this.remove(n), this[T](n), this[l].push(n));
|
35
|
+
}
|
36
|
+
remove(n) {
|
37
|
+
const o = this[l].indexOf(n);
|
38
|
+
return o === -1 ? !1 : (this[l].splice(o, 1), o === this[l].length && this[T](this.top), !0);
|
39
|
+
}
|
40
|
+
pop() {
|
41
|
+
const n = this.top;
|
42
|
+
return n && this.remove(n), n;
|
43
|
+
}
|
44
|
+
has(n) {
|
45
|
+
return this[l].indexOf(n) !== -1;
|
46
|
+
}
|
47
|
+
/**
|
48
|
+
* Sets `inert` to all document elements except the new top element, its
|
49
|
+
* parents, and its distributed content.
|
50
|
+
*/
|
51
|
+
[(E = l, m = I, N = g, T)](n) {
|
52
|
+
const o = this[g], s = this[I];
|
53
|
+
if (!n) {
|
54
|
+
this[e](s), o.clear(), this[I] = [];
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
const d = this[i](n);
|
58
|
+
if (d[d.length - 1].parentNode !== document.body)
|
59
|
+
throw Error("Non-connected element cannot be a blocking element");
|
60
|
+
this[I] = d;
|
61
|
+
const b = this[r](n);
|
62
|
+
if (!s.length) {
|
63
|
+
this[t](d, b, o);
|
64
|
+
return;
|
65
|
+
}
|
66
|
+
let c = s.length - 1, h = d.length - 1;
|
67
|
+
for (; c > 0 && h > 0 && s[c] === d[h]; )
|
68
|
+
c--, h--;
|
69
|
+
s[c] !== d[h] && this[u](s[c], d[h]), c > 0 && this[e](s.slice(0, c)), h > 0 && this[t](d.slice(0, h), b, null);
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Swaps inertness between two sibling elements.
|
73
|
+
* Sets the property `inert` over the attribute since the inert spec
|
74
|
+
* doesn't specify if it should be reflected.
|
75
|
+
* https://html.spec.whatwg.org/multipage/interaction.html#inert
|
76
|
+
*/
|
77
|
+
[u](n, o) {
|
78
|
+
const s = n[v];
|
79
|
+
this[a](n) && !n.inert && (n.inert = !0, s.add(n)), s.has(o) && (o.inert = !1, s.delete(o)), o[S] = n[S], o[v] = s, n[S] = void 0, n[v] = void 0;
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Restores original inertness to the siblings of the elements.
|
83
|
+
* Sets the property `inert` over the attribute since the inert spec
|
84
|
+
* doesn't specify if it should be reflected.
|
85
|
+
* https://html.spec.whatwg.org/multipage/interaction.html#inert
|
86
|
+
*/
|
87
|
+
[e](n) {
|
88
|
+
for (const o of n) {
|
89
|
+
o[S].disconnect(), o[S] = void 0;
|
90
|
+
const d = o[v];
|
91
|
+
for (const b of d)
|
92
|
+
b.inert = !1;
|
93
|
+
o[v] = void 0;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
/**
|
97
|
+
* Inerts the siblings of the elements except the elements to skip. Stores
|
98
|
+
* the inerted siblings into the element's symbol `_siblingsToRestore`.
|
99
|
+
* Pass `toKeepInert` to collect the already inert elements.
|
100
|
+
* Sets the property `inert` over the attribute since the inert spec
|
101
|
+
* doesn't specify if it should be reflected.
|
102
|
+
* https://html.spec.whatwg.org/multipage/interaction.html#inert
|
103
|
+
*/
|
104
|
+
[t](n, o, s) {
|
105
|
+
for (const d of n) {
|
106
|
+
const b = d.parentNode, c = b.children, h = /* @__PURE__ */ new Set();
|
107
|
+
for (let R = 0; R < c.length; R++) {
|
108
|
+
const M = c[R];
|
109
|
+
M === d || !this[a](M) || o && o.has(M) || (s && M.inert ? s.add(M) : (M.inert = !0, h.add(M)));
|
110
|
+
}
|
111
|
+
d[v] = h;
|
112
|
+
const k = new MutationObserver(this[f].bind(this));
|
113
|
+
d[S] = k;
|
114
|
+
let p = b;
|
115
|
+
const y = p;
|
116
|
+
y.__shady && y.host && (p = y.host), k.observe(p, {
|
117
|
+
childList: !0
|
118
|
+
});
|
119
|
+
}
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Handles newly added/removed nodes by toggling their inertness.
|
123
|
+
* It also checks if the current top Blocking Element has been removed,
|
124
|
+
* notifying and removing it.
|
125
|
+
*/
|
126
|
+
[f](n) {
|
127
|
+
const o = this[I], s = this[g];
|
128
|
+
for (const d of n) {
|
129
|
+
const b = d.target.host || d.target, c = b === document.body ? o.length : o.indexOf(b), h = o[c - 1], k = h[v];
|
130
|
+
for (let p = 0; p < d.removedNodes.length; p++) {
|
131
|
+
const y = d.removedNodes[p];
|
132
|
+
if (y === h) {
|
133
|
+
console.info("Detected removal of the top Blocking Element."), this.pop();
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
k.has(y) && (y.inert = !1, k.delete(y));
|
137
|
+
}
|
138
|
+
for (let p = 0; p < d.addedNodes.length; p++) {
|
139
|
+
const y = d.addedNodes[p];
|
140
|
+
this[a](y) && (s && y.inert ? s.add(y) : (y.inert = !0, k.add(y)));
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
/**
|
145
|
+
* Returns if the element is inertable.
|
146
|
+
*/
|
147
|
+
[a](n) {
|
148
|
+
return /^(style|template|script)$/.test(n.localName) === !1;
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Returns the list of newParents of an element, starting from element
|
152
|
+
* (included) up to `document.body` (excluded).
|
153
|
+
*/
|
154
|
+
[i](n) {
|
155
|
+
const o = [];
|
156
|
+
let s = n;
|
157
|
+
for (; s && s !== document.body; ) {
|
158
|
+
if (s.nodeType === Node.ELEMENT_NODE && o.push(s), s.assignedSlot) {
|
159
|
+
for (; s = s.assignedSlot; )
|
160
|
+
o.push(s);
|
161
|
+
s = o.pop();
|
162
|
+
continue;
|
163
|
+
}
|
164
|
+
s = s.parentNode || s.host;
|
165
|
+
}
|
166
|
+
return o;
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* Returns the distributed children of the element's shadow root.
|
170
|
+
* Returns null if the element doesn't have a shadow root.
|
171
|
+
*/
|
172
|
+
[r](n) {
|
173
|
+
const o = n.shadowRoot;
|
174
|
+
if (!o)
|
175
|
+
return null;
|
176
|
+
const s = /* @__PURE__ */ new Set();
|
177
|
+
let d, b, c;
|
178
|
+
const h = o.querySelectorAll("slot");
|
179
|
+
if (h.length && h[0].assignedNodes)
|
180
|
+
for (d = 0; d < h.length; d++)
|
181
|
+
for (c = h[d].assignedNodes({
|
182
|
+
flatten: !0
|
183
|
+
}), b = 0; b < c.length; b++)
|
184
|
+
c[b].nodeType === Node.ELEMENT_NODE && s.add(c[b]);
|
185
|
+
return s;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
document.$blockingElements = new _();
|
189
|
+
})();
|
190
|
+
var A = function() {
|
191
|
+
function E(m, N) {
|
192
|
+
for (var l = 0; l < N.length; l++) {
|
193
|
+
var g = N[l];
|
194
|
+
g.enumerable = g.enumerable || !1, g.configurable = !0, "value" in g && (g.writable = !0), Object.defineProperty(m, g.key, g);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return function(m, N, l) {
|
198
|
+
return N && E(m.prototype, N), l && E(m, l), m;
|
199
|
+
};
|
200
|
+
}();
|
201
|
+
function x(E, m) {
|
202
|
+
if (!(E instanceof m))
|
203
|
+
throw new TypeError("Cannot call a class as a function");
|
204
|
+
}
|
205
|
+
(function() {
|
206
|
+
if (typeof window > "u")
|
207
|
+
return;
|
208
|
+
var E = Array.prototype.slice, m = Element.prototype.matches || Element.prototype.msMatchesSelector, N = ["a[href]", "area[href]", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", "button:not([disabled])", "details", "summary", "iframe", "object", "embed", "[contenteditable]"].join(","), l = function() {
|
209
|
+
function u(t, e) {
|
210
|
+
x(this, u), this._inertManager = e, this._rootElement = t, this._managedNodes = /* @__PURE__ */ new Set(), this._rootElement.hasAttribute("aria-hidden") ? this._savedAriaHidden = this._rootElement.getAttribute("aria-hidden") : this._savedAriaHidden = null, this._rootElement.setAttribute("aria-hidden", "true"), this._makeSubtreeUnfocusable(this._rootElement), this._observer = new MutationObserver(this._onMutation.bind(this)), this._observer.observe(this._rootElement, { attributes: !0, childList: !0, subtree: !0 });
|
211
|
+
}
|
212
|
+
return A(u, [{
|
213
|
+
key: "destructor",
|
214
|
+
value: function() {
|
215
|
+
this._observer.disconnect(), this._rootElement && (this._savedAriaHidden !== null ? this._rootElement.setAttribute("aria-hidden", this._savedAriaHidden) : this._rootElement.removeAttribute("aria-hidden")), this._managedNodes.forEach(function(e) {
|
216
|
+
this._unmanageNode(e.node);
|
217
|
+
}, this), this._observer = /** @type {?} */
|
218
|
+
null, this._rootElement = /** @type {?} */
|
219
|
+
null, this._managedNodes = /** @type {?} */
|
220
|
+
null, this._inertManager = /** @type {?} */
|
221
|
+
null;
|
222
|
+
}
|
223
|
+
/**
|
224
|
+
* @return {!Set<!InertNode>} A copy of this InertRoot's managed nodes set.
|
225
|
+
*/
|
226
|
+
}, {
|
227
|
+
key: "_makeSubtreeUnfocusable",
|
228
|
+
/**
|
229
|
+
* @param {!Node} startNode
|
230
|
+
*/
|
231
|
+
value: function(e) {
|
232
|
+
var i = this;
|
233
|
+
v(e, function(_) {
|
234
|
+
return i._visitNode(_);
|
235
|
+
});
|
236
|
+
var r = document.activeElement;
|
237
|
+
if (!document.body.contains(e)) {
|
238
|
+
for (var a = e, f = void 0; a; ) {
|
239
|
+
if (a.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
240
|
+
f = /** @type {!ShadowRoot} */
|
241
|
+
a;
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
a = a.parentNode;
|
245
|
+
}
|
246
|
+
f && (r = f.activeElement);
|
247
|
+
}
|
248
|
+
e.contains(r) && (r.blur(), r === document.activeElement && document.body.focus());
|
249
|
+
}
|
250
|
+
/**
|
251
|
+
* @param {!Node} node
|
252
|
+
*/
|
253
|
+
}, {
|
254
|
+
key: "_visitNode",
|
255
|
+
value: function(e) {
|
256
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
257
|
+
var i = (
|
258
|
+
/** @type {!HTMLElement} */
|
259
|
+
e
|
260
|
+
);
|
261
|
+
i !== this._rootElement && i.hasAttribute("inert") && this._adoptInertRoot(i), (m.call(i, N) || i.hasAttribute("tabindex")) && this._manageNode(i);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
/**
|
265
|
+
* Register the given node with this InertRoot and with InertManager.
|
266
|
+
* @param {!Node} node
|
267
|
+
*/
|
268
|
+
}, {
|
269
|
+
key: "_manageNode",
|
270
|
+
value: function(e) {
|
271
|
+
var i = this._inertManager.register(e, this);
|
272
|
+
this._managedNodes.add(i);
|
273
|
+
}
|
274
|
+
/**
|
275
|
+
* Unregister the given node with this InertRoot and with InertManager.
|
276
|
+
* @param {!Node} node
|
277
|
+
*/
|
278
|
+
}, {
|
279
|
+
key: "_unmanageNode",
|
280
|
+
value: function(e) {
|
281
|
+
var i = this._inertManager.deregister(e, this);
|
282
|
+
i && this._managedNodes.delete(i);
|
283
|
+
}
|
284
|
+
/**
|
285
|
+
* Unregister the entire subtree starting at `startNode`.
|
286
|
+
* @param {!Node} startNode
|
287
|
+
*/
|
288
|
+
}, {
|
289
|
+
key: "_unmanageSubtree",
|
290
|
+
value: function(e) {
|
291
|
+
var i = this;
|
292
|
+
v(e, function(r) {
|
293
|
+
return i._unmanageNode(r);
|
294
|
+
});
|
295
|
+
}
|
296
|
+
/**
|
297
|
+
* If a descendant node is found with an `inert` attribute, adopt its managed nodes.
|
298
|
+
* @param {!HTMLElement} node
|
299
|
+
*/
|
300
|
+
}, {
|
301
|
+
key: "_adoptInertRoot",
|
302
|
+
value: function(e) {
|
303
|
+
var i = this._inertManager.getInertRoot(e);
|
304
|
+
i || (this._inertManager.setInert(e, !0), i = this._inertManager.getInertRoot(e)), i.managedNodes.forEach(function(r) {
|
305
|
+
this._manageNode(r.node);
|
306
|
+
}, this);
|
307
|
+
}
|
308
|
+
/**
|
309
|
+
* Callback used when mutation observer detects subtree additions, removals, or attribute changes.
|
310
|
+
* @param {!Array<!MutationRecord>} records
|
311
|
+
* @param {!MutationObserver} self
|
312
|
+
*/
|
313
|
+
}, {
|
314
|
+
key: "_onMutation",
|
315
|
+
value: function(e, i) {
|
316
|
+
e.forEach(function(r) {
|
317
|
+
var a = (
|
318
|
+
/** @type {!HTMLElement} */
|
319
|
+
r.target
|
320
|
+
);
|
321
|
+
if (r.type === "childList")
|
322
|
+
E.call(r.addedNodes).forEach(function(_) {
|
323
|
+
this._makeSubtreeUnfocusable(_);
|
324
|
+
}, this), E.call(r.removedNodes).forEach(function(_) {
|
325
|
+
this._unmanageSubtree(_);
|
326
|
+
}, this);
|
327
|
+
else if (r.type === "attributes") {
|
328
|
+
if (r.attributeName === "tabindex")
|
329
|
+
this._manageNode(a);
|
330
|
+
else if (a !== this._rootElement && r.attributeName === "inert" && a.hasAttribute("inert")) {
|
331
|
+
this._adoptInertRoot(a);
|
332
|
+
var f = this._inertManager.getInertRoot(a);
|
333
|
+
this._managedNodes.forEach(function(_) {
|
334
|
+
a.contains(_.node) && f._manageNode(_.node);
|
335
|
+
});
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}, this);
|
339
|
+
}
|
340
|
+
}, {
|
341
|
+
key: "managedNodes",
|
342
|
+
get: function() {
|
343
|
+
return new Set(this._managedNodes);
|
344
|
+
}
|
345
|
+
/** @return {boolean} */
|
346
|
+
}, {
|
347
|
+
key: "hasSavedAriaHidden",
|
348
|
+
get: function() {
|
349
|
+
return this._savedAriaHidden !== null;
|
350
|
+
}
|
351
|
+
/** @param {?string} ariaHidden */
|
352
|
+
}, {
|
353
|
+
key: "savedAriaHidden",
|
354
|
+
set: function(e) {
|
355
|
+
this._savedAriaHidden = e;
|
356
|
+
},
|
357
|
+
get: function() {
|
358
|
+
return this._savedAriaHidden;
|
359
|
+
}
|
360
|
+
}]), u;
|
361
|
+
}(), g = function() {
|
362
|
+
function u(t, e) {
|
363
|
+
x(this, u), this._node = t, this._overrodeFocusMethod = !1, this._inertRoots = /* @__PURE__ */ new Set([e]), this._savedTabIndex = null, this._destroyed = !1, this.ensureUntabbable();
|
364
|
+
}
|
365
|
+
return A(u, [{
|
366
|
+
key: "destructor",
|
367
|
+
value: function() {
|
368
|
+
if (this._throwIfDestroyed(), this._node && this._node.nodeType === Node.ELEMENT_NODE) {
|
369
|
+
var e = (
|
370
|
+
/** @type {!HTMLElement} */
|
371
|
+
this._node
|
372
|
+
);
|
373
|
+
this._savedTabIndex !== null ? e.setAttribute("tabindex", this._savedTabIndex) : e.removeAttribute("tabindex"), this._overrodeFocusMethod && delete e.focus;
|
374
|
+
}
|
375
|
+
this._node = /** @type {?} */
|
376
|
+
null, this._inertRoots = /** @type {?} */
|
377
|
+
null, this._destroyed = !0;
|
378
|
+
}
|
379
|
+
/**
|
380
|
+
* @type {boolean} Whether this object is obsolete because the managed node is no longer inert.
|
381
|
+
* If the object has been destroyed, any attempt to access it will cause an exception.
|
382
|
+
*/
|
383
|
+
}, {
|
384
|
+
key: "_throwIfDestroyed",
|
385
|
+
/**
|
386
|
+
* Throw if user tries to access destroyed InertNode.
|
387
|
+
*/
|
388
|
+
value: function() {
|
389
|
+
if (this.destroyed)
|
390
|
+
throw new Error("Trying to access destroyed InertNode");
|
391
|
+
}
|
392
|
+
/** @return {boolean} */
|
393
|
+
}, {
|
394
|
+
key: "ensureUntabbable",
|
395
|
+
/** Save the existing tabindex value and make the node untabbable and unfocusable */
|
396
|
+
value: function() {
|
397
|
+
if (this.node.nodeType === Node.ELEMENT_NODE) {
|
398
|
+
var e = (
|
399
|
+
/** @type {!HTMLElement} */
|
400
|
+
this.node
|
401
|
+
);
|
402
|
+
if (m.call(e, N)) {
|
403
|
+
if (
|
404
|
+
/** @type {!HTMLElement} */
|
405
|
+
e.tabIndex === -1 && this.hasSavedTabIndex
|
406
|
+
)
|
407
|
+
return;
|
408
|
+
e.hasAttribute("tabindex") && (this._savedTabIndex = /** @type {!HTMLElement} */
|
409
|
+
e.tabIndex), e.setAttribute("tabindex", "-1"), e.nodeType === Node.ELEMENT_NODE && (e.focus = function() {
|
410
|
+
}, this._overrodeFocusMethod = !0);
|
411
|
+
} else
|
412
|
+
e.hasAttribute("tabindex") && (this._savedTabIndex = /** @type {!HTMLElement} */
|
413
|
+
e.tabIndex, e.removeAttribute("tabindex"));
|
414
|
+
}
|
415
|
+
}
|
416
|
+
/**
|
417
|
+
* Add another inert root to this inert node's set of managing inert roots.
|
418
|
+
* @param {!InertRoot} inertRoot
|
419
|
+
*/
|
420
|
+
}, {
|
421
|
+
key: "addInertRoot",
|
422
|
+
value: function(e) {
|
423
|
+
this._throwIfDestroyed(), this._inertRoots.add(e);
|
424
|
+
}
|
425
|
+
/**
|
426
|
+
* Remove the given inert root from this inert node's set of managing inert roots.
|
427
|
+
* If the set of managing inert roots becomes empty, this node is no longer inert,
|
428
|
+
* so the object should be destroyed.
|
429
|
+
* @param {!InertRoot} inertRoot
|
430
|
+
*/
|
431
|
+
}, {
|
432
|
+
key: "removeInertRoot",
|
433
|
+
value: function(e) {
|
434
|
+
this._throwIfDestroyed(), this._inertRoots.delete(e), this._inertRoots.size === 0 && this.destructor();
|
435
|
+
}
|
436
|
+
}, {
|
437
|
+
key: "destroyed",
|
438
|
+
get: function() {
|
439
|
+
return (
|
440
|
+
/** @type {!InertNode} */
|
441
|
+
this._destroyed
|
442
|
+
);
|
443
|
+
}
|
444
|
+
}, {
|
445
|
+
key: "hasSavedTabIndex",
|
446
|
+
get: function() {
|
447
|
+
return this._savedTabIndex !== null;
|
448
|
+
}
|
449
|
+
/** @return {!Node} */
|
450
|
+
}, {
|
451
|
+
key: "node",
|
452
|
+
get: function() {
|
453
|
+
return this._throwIfDestroyed(), this._node;
|
454
|
+
}
|
455
|
+
/** @param {?number} tabIndex */
|
456
|
+
}, {
|
457
|
+
key: "savedTabIndex",
|
458
|
+
set: function(e) {
|
459
|
+
this._throwIfDestroyed(), this._savedTabIndex = e;
|
460
|
+
},
|
461
|
+
get: function() {
|
462
|
+
return this._throwIfDestroyed(), this._savedTabIndex;
|
463
|
+
}
|
464
|
+
}]), u;
|
465
|
+
}(), I = function() {
|
466
|
+
function u(t) {
|
467
|
+
if (x(this, u), !t)
|
468
|
+
throw new Error("Missing required argument; InertManager needs to wrap a document.");
|
469
|
+
this._document = t, this._managedNodes = /* @__PURE__ */ new Map(), this._inertRoots = /* @__PURE__ */ new Map(), this._observer = new MutationObserver(this._watchForInert.bind(this)), S(t.head || t.body || t.documentElement), t.readyState === "loading" ? t.addEventListener("DOMContentLoaded", this._onDocumentLoaded.bind(this)) : this._onDocumentLoaded();
|
470
|
+
}
|
471
|
+
return A(u, [{
|
472
|
+
key: "setInert",
|
473
|
+
value: function(e, i) {
|
474
|
+
if (i) {
|
475
|
+
if (this._inertRoots.has(e))
|
476
|
+
return;
|
477
|
+
var r = new l(e, this);
|
478
|
+
if (e.setAttribute("inert", ""), this._inertRoots.set(e, r), !this._document.body.contains(e))
|
479
|
+
for (var a = e.parentNode; a; )
|
480
|
+
a.nodeType === 11 && S(a), a = a.parentNode;
|
481
|
+
} else {
|
482
|
+
if (!this._inertRoots.has(e))
|
483
|
+
return;
|
484
|
+
var f = this._inertRoots.get(e);
|
485
|
+
f.destructor(), this._inertRoots.delete(e), e.removeAttribute("inert");
|
486
|
+
}
|
487
|
+
}
|
488
|
+
/**
|
489
|
+
* Get the InertRoot object corresponding to the given inert root element, if any.
|
490
|
+
* @param {!Node} element
|
491
|
+
* @return {!InertRoot|undefined}
|
492
|
+
*/
|
493
|
+
}, {
|
494
|
+
key: "getInertRoot",
|
495
|
+
value: function(e) {
|
496
|
+
return this._inertRoots.get(e);
|
497
|
+
}
|
498
|
+
/**
|
499
|
+
* Register the given InertRoot as managing the given node.
|
500
|
+
* In the case where the node has a previously existing inert root, this inert root will
|
501
|
+
* be added to its set of inert roots.
|
502
|
+
* @param {!Node} node
|
503
|
+
* @param {!InertRoot} inertRoot
|
504
|
+
* @return {!InertNode} inertNode
|
505
|
+
*/
|
506
|
+
}, {
|
507
|
+
key: "register",
|
508
|
+
value: function(e, i) {
|
509
|
+
var r = this._managedNodes.get(e);
|
510
|
+
return r !== void 0 ? r.addInertRoot(i) : r = new g(e, i), this._managedNodes.set(e, r), r;
|
511
|
+
}
|
512
|
+
/**
|
513
|
+
* De-register the given InertRoot as managing the given inert node.
|
514
|
+
* Removes the inert root from the InertNode's set of managing inert roots, and remove the inert
|
515
|
+
* node from the InertManager's set of managed nodes if it is destroyed.
|
516
|
+
* If the node is not currently managed, this is essentially a no-op.
|
517
|
+
* @param {!Node} node
|
518
|
+
* @param {!InertRoot} inertRoot
|
519
|
+
* @return {?InertNode} The potentially destroyed InertNode associated with this node, if any.
|
520
|
+
*/
|
521
|
+
}, {
|
522
|
+
key: "deregister",
|
523
|
+
value: function(e, i) {
|
524
|
+
var r = this._managedNodes.get(e);
|
525
|
+
return r ? (r.removeInertRoot(i), r.destroyed && this._managedNodes.delete(e), r) : null;
|
526
|
+
}
|
527
|
+
/**
|
528
|
+
* Callback used when document has finished loading.
|
529
|
+
*/
|
530
|
+
}, {
|
531
|
+
key: "_onDocumentLoaded",
|
532
|
+
value: function() {
|
533
|
+
var e = E.call(this._document.querySelectorAll("[inert]"));
|
534
|
+
e.forEach(function(i) {
|
535
|
+
this.setInert(i, !0);
|
536
|
+
}, this), this._observer.observe(this._document.body || this._document.documentElement, { attributes: !0, subtree: !0, childList: !0 });
|
537
|
+
}
|
538
|
+
/**
|
539
|
+
* Callback used when mutation observer detects attribute changes.
|
540
|
+
* @param {!Array<!MutationRecord>} records
|
541
|
+
* @param {!MutationObserver} self
|
542
|
+
*/
|
543
|
+
}, {
|
544
|
+
key: "_watchForInert",
|
545
|
+
value: function(e, i) {
|
546
|
+
var r = this;
|
547
|
+
e.forEach(function(a) {
|
548
|
+
switch (a.type) {
|
549
|
+
case "childList":
|
550
|
+
E.call(a.addedNodes).forEach(function(w) {
|
551
|
+
if (w.nodeType === Node.ELEMENT_NODE) {
|
552
|
+
var n = E.call(w.querySelectorAll("[inert]"));
|
553
|
+
m.call(w, "[inert]") && n.unshift(w), n.forEach(function(o) {
|
554
|
+
this.setInert(o, !0);
|
555
|
+
}, r);
|
556
|
+
}
|
557
|
+
}, r);
|
558
|
+
break;
|
559
|
+
case "attributes":
|
560
|
+
if (a.attributeName !== "inert")
|
561
|
+
return;
|
562
|
+
var f = (
|
563
|
+
/** @type {!HTMLElement} */
|
564
|
+
a.target
|
565
|
+
), _ = f.hasAttribute("inert");
|
566
|
+
r.setInert(f, _);
|
567
|
+
break;
|
568
|
+
}
|
569
|
+
}, this);
|
570
|
+
}
|
571
|
+
}]), u;
|
572
|
+
}();
|
573
|
+
function v(u, t, e) {
|
574
|
+
if (u.nodeType == Node.ELEMENT_NODE) {
|
575
|
+
var i = (
|
576
|
+
/** @type {!HTMLElement} */
|
577
|
+
u
|
578
|
+
);
|
579
|
+
t && t(i);
|
580
|
+
var r = (
|
581
|
+
/** @type {!HTMLElement} */
|
582
|
+
i.shadowRoot
|
583
|
+
);
|
584
|
+
if (r) {
|
585
|
+
v(r, t);
|
586
|
+
return;
|
587
|
+
}
|
588
|
+
if (i.localName == "content") {
|
589
|
+
for (var a = (
|
590
|
+
/** @type {!HTMLContentElement} */
|
591
|
+
i
|
592
|
+
), f = a.getDistributedNodes ? a.getDistributedNodes() : [], _ = 0; _ < f.length; _++)
|
593
|
+
v(f[_], t);
|
594
|
+
return;
|
595
|
+
}
|
596
|
+
if (i.localName == "slot") {
|
597
|
+
for (var w = (
|
598
|
+
/** @type {!HTMLSlotElement} */
|
599
|
+
i
|
600
|
+
), n = w.assignedNodes ? w.assignedNodes({ flatten: !0 }) : [], o = 0; o < n.length; o++)
|
601
|
+
v(n[o], t);
|
602
|
+
return;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
for (var s = u.firstChild; s != null; )
|
606
|
+
v(s, t), s = s.nextSibling;
|
607
|
+
}
|
608
|
+
function S(u) {
|
609
|
+
if (!u.querySelector("style#inert-style, link#inert-style")) {
|
610
|
+
var t = document.createElement("style");
|
611
|
+
t.setAttribute("id", "inert-style"), t.textContent = `
|
612
|
+
[inert] {
|
613
|
+
pointer-events: none;
|
614
|
+
cursor: default;
|
615
|
+
}
|
616
|
+
|
617
|
+
[inert], [inert] * {
|
618
|
+
-webkit-user-select: none;
|
619
|
+
-moz-user-select: none;
|
620
|
+
-ms-user-select: none;
|
621
|
+
user-select: none;
|
622
|
+
}
|
623
|
+
`, u.appendChild(t);
|
624
|
+
}
|
625
|
+
}
|
626
|
+
if (!HTMLElement.prototype.hasOwnProperty("inert")) {
|
627
|
+
var T = new I(document);
|
628
|
+
Object.defineProperty(HTMLElement.prototype, "inert", {
|
629
|
+
enumerable: !0,
|
630
|
+
/** @this {!HTMLElement} */
|
631
|
+
get: function() {
|
632
|
+
return this.hasAttribute("inert");
|
633
|
+
},
|
634
|
+
/** @this {!HTMLElement} */
|
635
|
+
set: function(t) {
|
636
|
+
T.setInert(this, t);
|
637
|
+
}
|
638
|
+
});
|
639
|
+
}
|
640
|
+
})();
|