@patternfly/pfe-core 2.4.0 → 3.0.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/README.md +0 -1
- package/controllers/cascade-controller.d.ts +6 -0
- package/controllers/cascade-controller.js +5 -3
- package/controllers/cascade-controller.js.map +1 -1
- package/controllers/floating-dom-controller.d.ts +2 -2
- package/controllers/floating-dom-controller.js +84 -81
- package/controllers/floating-dom-controller.js.map +1 -1
- package/controllers/internals-controller.d.ts +86 -41
- package/controllers/internals-controller.js +322 -36
- package/controllers/internals-controller.js.map +1 -1
- package/controllers/light-dom-controller.js.map +1 -1
- package/controllers/listbox-controller.d.ts +58 -0
- package/controllers/listbox-controller.js +250 -0
- package/controllers/listbox-controller.js.map +1 -0
- package/controllers/logger.d.ts +27 -3
- package/controllers/logger.js +50 -9
- package/controllers/logger.js.map +1 -1
- package/controllers/overflow-controller.d.ts +10 -3
- package/controllers/overflow-controller.js +75 -44
- package/controllers/overflow-controller.js.map +1 -1
- package/controllers/perf-controller.js.map +1 -1
- package/controllers/property-observer-controller.js +2 -3
- package/controllers/property-observer-controller.js.map +1 -1
- package/controllers/roving-tabindex-controller.d.ts +42 -24
- package/controllers/roving-tabindex-controller.js +167 -140
- package/controllers/roving-tabindex-controller.js.map +1 -1
- package/controllers/scroll-spy-controller.js +91 -93
- package/controllers/scroll-spy-controller.js.map +1 -1
- package/controllers/slot-controller.d.ts +18 -20
- package/controllers/slot-controller.js +89 -91
- package/controllers/slot-controller.js.map +1 -1
- package/controllers/style-controller.js.map +1 -1
- package/controllers/tabs-aria-controller.d.ts +29 -0
- package/controllers/tabs-aria-controller.js +95 -0
- package/controllers/tabs-aria-controller.js.map +1 -0
- package/controllers/timestamp-controller.js +68 -70
- package/controllers/timestamp-controller.js.map +1 -1
- package/core.d.ts +3 -0
- package/core.js.map +1 -1
- package/custom-elements.json +3245 -1317
- package/decorators/bound.js.map +1 -1
- package/decorators/cascades.d.ts +1 -0
- package/decorators/cascades.js +1 -0
- package/decorators/cascades.js.map +1 -1
- package/decorators/deprecation.js.map +1 -1
- package/decorators/initializer.js.map +1 -1
- package/decorators/observed.js.map +1 -1
- package/decorators/time.js.map +1 -1
- package/decorators/trace.js.map +1 -1
- package/functions/containsDeep.d.ts +6 -0
- package/functions/containsDeep.js +21 -0
- package/functions/containsDeep.js.map +1 -0
- package/functions/context.d.ts +9 -0
- package/functions/context.js +17 -0
- package/functions/context.js.map +1 -0
- package/functions/debounce.js.map +1 -1
- package/functions/isElementInView.js.map +1 -1
- package/package.json +7 -4
- package/functions/deprecatedCustomEvent.d.ts +0 -5
- package/functions/deprecatedCustomEvent.js +0 -12
- package/functions/deprecatedCustomEvent.js.map +0 -1
|
@@ -1,68 +1,354 @@
|
|
|
1
|
+
var _InternalsController_instances, _InternalsController_polyfillDisabledPseudo;
|
|
2
|
+
import { __classPrivateFieldGet, __decorate } from "tslib";
|
|
1
3
|
function isARIAMixinProp(key) {
|
|
2
4
|
return key === 'role' || key.startsWith('aria');
|
|
3
5
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const protos = new WeakMap();
|
|
7
|
+
let constructingAllowed = false;
|
|
8
|
+
/** reactively forward the internals object's aria mixin prototype */
|
|
9
|
+
function aria(target, key) {
|
|
10
|
+
if (!protos.has(target)) {
|
|
11
|
+
protos.set(target, new Set());
|
|
12
|
+
}
|
|
13
|
+
if (protos.get(target).has(key)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!isARIAMixinProp(key)) {
|
|
17
|
+
throw new Error('@aria can only be called on ARIAMixin properties');
|
|
18
|
+
}
|
|
19
|
+
// typescript experimental decorator
|
|
20
|
+
Object.defineProperty(target, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: false,
|
|
23
|
+
get() {
|
|
24
|
+
// @ts-expect-error: because i'm bad, i'm bad
|
|
25
|
+
return this.attach()[key];
|
|
26
|
+
},
|
|
27
|
+
set(value) {
|
|
28
|
+
// @ts-expect-error: shamone!
|
|
29
|
+
this.attach()[key] = value;
|
|
30
|
+
this.host.requestUpdate();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
protos.get(target).add(key);
|
|
34
|
+
}
|
|
35
|
+
function getLabelText(label) {
|
|
36
|
+
if (label.hidden) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const ariaLabel = label.getAttribute?.('aria-label');
|
|
41
|
+
return ariaLabel ?? label.textContent;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class InternalsController {
|
|
45
|
+
static of(host, options) {
|
|
46
|
+
constructingAllowed = true;
|
|
47
|
+
// implement the singleton pattern
|
|
48
|
+
// using a public static constructor method is much easier to manage,
|
|
49
|
+
// due to the quirks of our typescript config
|
|
50
|
+
const instance = InternalsController.instances.get(host) ??
|
|
51
|
+
new InternalsController(host, options);
|
|
52
|
+
instance.initializeOptions(options);
|
|
53
|
+
constructingAllowed = false;
|
|
54
|
+
return instance;
|
|
55
|
+
}
|
|
7
56
|
/** True when the control is disabled via it's containing fieldset element */
|
|
8
57
|
get formDisabled() {
|
|
9
|
-
return this.
|
|
58
|
+
return this.element?.matches(':disabled') || this._formDisabled;
|
|
10
59
|
}
|
|
11
|
-
static { this.protos = new WeakMap(); }
|
|
12
60
|
get labels() {
|
|
13
|
-
return this
|
|
61
|
+
return this.internals.labels;
|
|
14
62
|
}
|
|
15
63
|
get validity() {
|
|
16
|
-
return this
|
|
64
|
+
return this.internals.validity;
|
|
65
|
+
}
|
|
66
|
+
/** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */
|
|
67
|
+
get computedLabelText() {
|
|
68
|
+
return this.internals.ariaLabel ||
|
|
69
|
+
Array.from(this.internals.labels)
|
|
70
|
+
.reduce((acc, label) => `${acc}${getLabelText(label)}`, '');
|
|
71
|
+
}
|
|
72
|
+
get element() {
|
|
73
|
+
return this.host instanceof HTMLElement ? this.host : this.options?.getHTMLElement?.();
|
|
17
74
|
}
|
|
18
75
|
constructor(host, options) {
|
|
76
|
+
_InternalsController_instances.add(this);
|
|
19
77
|
this.host = host;
|
|
20
|
-
this
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
78
|
+
this.options = options;
|
|
79
|
+
this.role = null;
|
|
80
|
+
this.ariaActivedescendant = null;
|
|
81
|
+
this.ariaAtomic = null;
|
|
82
|
+
this.ariaAutoComplete = null;
|
|
83
|
+
this.ariaBusy = null;
|
|
84
|
+
this.ariaChecked = null;
|
|
85
|
+
this.ariaColCount = null;
|
|
86
|
+
this.ariaColIndex = null;
|
|
87
|
+
this.ariaColIndexText = null;
|
|
88
|
+
this.ariaColSpan = null;
|
|
89
|
+
this.ariaCurrent = null;
|
|
90
|
+
this.ariaDescription = null;
|
|
91
|
+
this.ariaDisabled = null;
|
|
92
|
+
this.ariaExpanded = null;
|
|
93
|
+
this.ariaHasPopup = null;
|
|
94
|
+
this.ariaHidden = null;
|
|
95
|
+
this.ariaInvalid = null;
|
|
96
|
+
this.ariaKeyShortcuts = null;
|
|
97
|
+
this.ariaLabel = null;
|
|
98
|
+
this.ariaLevel = null;
|
|
99
|
+
this.ariaLive = null;
|
|
100
|
+
this.ariaModal = null;
|
|
101
|
+
this.ariaMultiLine = null;
|
|
102
|
+
this.ariaMultiSelectable = null;
|
|
103
|
+
this.ariaOrientation = null;
|
|
104
|
+
this.ariaPlaceholder = null;
|
|
105
|
+
this.ariaPosInSet = null;
|
|
106
|
+
this.ariaPressed = null;
|
|
107
|
+
this.ariaReadOnly = null;
|
|
108
|
+
this.ariaRequired = null;
|
|
109
|
+
this.ariaRoleDescription = null;
|
|
110
|
+
this.ariaRowCount = null;
|
|
111
|
+
this.ariaRowIndex = null;
|
|
112
|
+
this.ariaRowIndexText = null;
|
|
113
|
+
this.ariaRowSpan = null;
|
|
114
|
+
this.ariaSelected = null;
|
|
115
|
+
this.ariaSetSize = null;
|
|
116
|
+
this.ariaSort = null;
|
|
117
|
+
this.ariaValueMax = null;
|
|
118
|
+
this.ariaValueMin = null;
|
|
119
|
+
this.ariaValueNow = null;
|
|
120
|
+
this.ariaValueText = null;
|
|
121
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
122
|
+
this.ariaActiveDescendantElement = null;
|
|
123
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
124
|
+
this.ariaControlsElements = null;
|
|
125
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
126
|
+
this.ariaDescribedByElements = null;
|
|
127
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
128
|
+
this.ariaDetailsElements = null;
|
|
129
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
130
|
+
this.ariaErrorMessageElements = null;
|
|
131
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
132
|
+
this.ariaFlowToElements = null;
|
|
133
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
134
|
+
this.ariaLabelledByElements = null;
|
|
135
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
136
|
+
this.ariaOwnsElements = null;
|
|
137
|
+
this._formDisabled = false;
|
|
138
|
+
if (!constructingAllowed) {
|
|
139
|
+
throw new Error('InternalsController must be constructed with `InternalsController.for()`');
|
|
140
|
+
}
|
|
141
|
+
if (!this.element) {
|
|
142
|
+
throw new Error('InternalsController must be instantiated with an HTMLElement or a `getHTMLElement` function');
|
|
41
143
|
}
|
|
42
|
-
|
|
144
|
+
this.attach();
|
|
145
|
+
this.initializeOptions(options);
|
|
146
|
+
InternalsController.instances.set(host, this);
|
|
147
|
+
__classPrivateFieldGet(this, _InternalsController_instances, "m", _InternalsController_polyfillDisabledPseudo).call(this);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Typescript (with experimental decorators) will compile the class
|
|
151
|
+
* such that the order of operations is:
|
|
152
|
+
* 1. set up constructor parameter fields
|
|
153
|
+
* 2. run decorated field setters with initializers as the value
|
|
154
|
+
* 3. run the rest of the constructor
|
|
155
|
+
* Because of that, `this.internals` may not be available in the decorator setter
|
|
156
|
+
* so we cheat here with nullish coalescing assignment operator `??=`;
|
|
157
|
+
*/
|
|
158
|
+
attach() {
|
|
159
|
+
this.internals ?? (this.internals = this.element.attachInternals());
|
|
160
|
+
return this.internals;
|
|
161
|
+
}
|
|
162
|
+
initializeOptions(options) {
|
|
163
|
+
var _a;
|
|
164
|
+
this.options ?? (this.options = options ?? {});
|
|
165
|
+
const { getHTMLElement, ...aria } = this.options;
|
|
166
|
+
(_a = this.options).getHTMLElement ?? (_a.getHTMLElement = getHTMLElement);
|
|
167
|
+
for (const [key, val] of Object.entries(aria)) {
|
|
43
168
|
if (isARIAMixinProp(key)) {
|
|
44
169
|
this[key] = val;
|
|
45
170
|
}
|
|
46
171
|
}
|
|
47
172
|
}
|
|
48
173
|
setFormValue(...args) {
|
|
49
|
-
return this
|
|
174
|
+
return this.internals.setFormValue(...args);
|
|
50
175
|
}
|
|
51
176
|
setValidity(...args) {
|
|
52
|
-
return this
|
|
177
|
+
return this.internals.setValidity(...args);
|
|
53
178
|
}
|
|
54
179
|
checkValidity(...args) {
|
|
55
|
-
return this
|
|
180
|
+
return this.internals.checkValidity(...args);
|
|
56
181
|
}
|
|
57
182
|
reportValidity(...args) {
|
|
58
|
-
return this
|
|
183
|
+
return this.internals.reportValidity(...args);
|
|
59
184
|
}
|
|
60
185
|
submit() {
|
|
61
|
-
this
|
|
186
|
+
this.internals.form?.requestSubmit();
|
|
62
187
|
}
|
|
63
188
|
reset() {
|
|
64
|
-
this
|
|
189
|
+
this.internals.form?.reset();
|
|
65
190
|
}
|
|
66
191
|
}
|
|
67
|
-
|
|
192
|
+
_InternalsController_instances = new WeakSet(), _InternalsController_polyfillDisabledPseudo = function _InternalsController_polyfillDisabledPseudo() {
|
|
193
|
+
// START polyfill-disabled
|
|
194
|
+
// We need to polyfill :disabled
|
|
195
|
+
// see https://github.com/calebdwilliams/element-internals-polyfill/issues/88
|
|
196
|
+
const orig = this.element.formDisabledCallback;
|
|
197
|
+
this.element.formDisabledCallback = disabled => {
|
|
198
|
+
this._formDisabled = disabled;
|
|
199
|
+
orig?.call(this.host, disabled);
|
|
200
|
+
// END polyfill-disabled
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
InternalsController.instances = new WeakMap();
|
|
204
|
+
__decorate([
|
|
205
|
+
aria
|
|
206
|
+
], InternalsController.prototype, "role", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
aria
|
|
209
|
+
], InternalsController.prototype, "ariaActivedescendant", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
aria
|
|
212
|
+
], InternalsController.prototype, "ariaAtomic", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
aria
|
|
215
|
+
], InternalsController.prototype, "ariaAutoComplete", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
aria
|
|
218
|
+
], InternalsController.prototype, "ariaBusy", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
aria
|
|
221
|
+
], InternalsController.prototype, "ariaChecked", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
aria
|
|
224
|
+
], InternalsController.prototype, "ariaColCount", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
aria
|
|
227
|
+
], InternalsController.prototype, "ariaColIndex", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
aria
|
|
230
|
+
], InternalsController.prototype, "ariaColIndexText", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
aria
|
|
233
|
+
], InternalsController.prototype, "ariaColSpan", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
aria
|
|
236
|
+
], InternalsController.prototype, "ariaCurrent", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
aria
|
|
239
|
+
], InternalsController.prototype, "ariaDescription", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
aria
|
|
242
|
+
], InternalsController.prototype, "ariaDisabled", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
aria
|
|
245
|
+
], InternalsController.prototype, "ariaExpanded", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
aria
|
|
248
|
+
], InternalsController.prototype, "ariaHasPopup", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
aria
|
|
251
|
+
], InternalsController.prototype, "ariaHidden", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
aria
|
|
254
|
+
], InternalsController.prototype, "ariaInvalid", void 0);
|
|
255
|
+
__decorate([
|
|
256
|
+
aria
|
|
257
|
+
], InternalsController.prototype, "ariaKeyShortcuts", void 0);
|
|
258
|
+
__decorate([
|
|
259
|
+
aria
|
|
260
|
+
], InternalsController.prototype, "ariaLabel", void 0);
|
|
261
|
+
__decorate([
|
|
262
|
+
aria
|
|
263
|
+
], InternalsController.prototype, "ariaLevel", void 0);
|
|
264
|
+
__decorate([
|
|
265
|
+
aria
|
|
266
|
+
], InternalsController.prototype, "ariaLive", void 0);
|
|
267
|
+
__decorate([
|
|
268
|
+
aria
|
|
269
|
+
], InternalsController.prototype, "ariaModal", void 0);
|
|
270
|
+
__decorate([
|
|
271
|
+
aria
|
|
272
|
+
], InternalsController.prototype, "ariaMultiLine", void 0);
|
|
273
|
+
__decorate([
|
|
274
|
+
aria
|
|
275
|
+
], InternalsController.prototype, "ariaMultiSelectable", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
aria
|
|
278
|
+
], InternalsController.prototype, "ariaOrientation", void 0);
|
|
279
|
+
__decorate([
|
|
280
|
+
aria
|
|
281
|
+
], InternalsController.prototype, "ariaPlaceholder", void 0);
|
|
282
|
+
__decorate([
|
|
283
|
+
aria
|
|
284
|
+
], InternalsController.prototype, "ariaPosInSet", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
aria
|
|
287
|
+
], InternalsController.prototype, "ariaPressed", void 0);
|
|
288
|
+
__decorate([
|
|
289
|
+
aria
|
|
290
|
+
], InternalsController.prototype, "ariaReadOnly", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
aria
|
|
293
|
+
], InternalsController.prototype, "ariaRequired", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
aria
|
|
296
|
+
], InternalsController.prototype, "ariaRoleDescription", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
aria
|
|
299
|
+
], InternalsController.prototype, "ariaRowCount", void 0);
|
|
300
|
+
__decorate([
|
|
301
|
+
aria
|
|
302
|
+
], InternalsController.prototype, "ariaRowIndex", void 0);
|
|
303
|
+
__decorate([
|
|
304
|
+
aria
|
|
305
|
+
], InternalsController.prototype, "ariaRowIndexText", void 0);
|
|
306
|
+
__decorate([
|
|
307
|
+
aria
|
|
308
|
+
], InternalsController.prototype, "ariaRowSpan", void 0);
|
|
309
|
+
__decorate([
|
|
310
|
+
aria
|
|
311
|
+
], InternalsController.prototype, "ariaSelected", void 0);
|
|
312
|
+
__decorate([
|
|
313
|
+
aria
|
|
314
|
+
], InternalsController.prototype, "ariaSetSize", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
aria
|
|
317
|
+
], InternalsController.prototype, "ariaSort", void 0);
|
|
318
|
+
__decorate([
|
|
319
|
+
aria
|
|
320
|
+
], InternalsController.prototype, "ariaValueMax", void 0);
|
|
321
|
+
__decorate([
|
|
322
|
+
aria
|
|
323
|
+
], InternalsController.prototype, "ariaValueMin", void 0);
|
|
324
|
+
__decorate([
|
|
325
|
+
aria
|
|
326
|
+
], InternalsController.prototype, "ariaValueNow", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
aria
|
|
329
|
+
], InternalsController.prototype, "ariaValueText", void 0);
|
|
330
|
+
__decorate([
|
|
331
|
+
aria
|
|
332
|
+
], InternalsController.prototype, "ariaActiveDescendantElement", void 0);
|
|
333
|
+
__decorate([
|
|
334
|
+
aria
|
|
335
|
+
], InternalsController.prototype, "ariaControlsElements", void 0);
|
|
336
|
+
__decorate([
|
|
337
|
+
aria
|
|
338
|
+
], InternalsController.prototype, "ariaDescribedByElements", void 0);
|
|
339
|
+
__decorate([
|
|
340
|
+
aria
|
|
341
|
+
], InternalsController.prototype, "ariaDetailsElements", void 0);
|
|
342
|
+
__decorate([
|
|
343
|
+
aria
|
|
344
|
+
], InternalsController.prototype, "ariaErrorMessageElements", void 0);
|
|
345
|
+
__decorate([
|
|
346
|
+
aria
|
|
347
|
+
], InternalsController.prototype, "ariaFlowToElements", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
aria
|
|
350
|
+
], InternalsController.prototype, "ariaLabelledByElements", void 0);
|
|
351
|
+
__decorate([
|
|
352
|
+
aria
|
|
353
|
+
], InternalsController.prototype, "ariaOwnsElements", void 0);
|
|
68
354
|
//# sourceMappingURL=internals-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internals-controller.js","sourceRoot":"","sources":["internals-controller.ts"],"names":[],"mappings":"AAEA,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,MAAa,mBAAmB;IA0C9B,UAAU,CAAmB;IAE7B,aAAa,GAAG,KAAK,CAAC;IAEtB,6EAA6E;IAC7E,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC;IAC9D,CAAC;aAEM,WAAM,GAAG,IAAI,OAAO,EAAE,CAAC;IAE9B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAChC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,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WAAW,CAAC,GAAG,IAAiD;QAC9D,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC;IAED,aAAa,CAAC,GAAG,IAAmD;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,cAAc,CAAC,GAAG,IAAoD;QACpE,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC;IACxC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;IAChC,CAAC;;SAvHU,mBAAmB","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nfunction isARIAMixinProp(key: string): key is keyof ARIAMixin {\n return key === 'role' || key.startsWith('aria');\n}\n\nexport class InternalsController implements ReactiveController, ARIAMixin {\n declare role: ARIAMixin['role'];\n declare ariaAtomic: ARIAMixin['ariaAtomic'];\n declare ariaAutoComplete: ARIAMixin['ariaAutoComplete'];\n declare ariaBusy: ARIAMixin['ariaBusy'];\n declare ariaChecked: ARIAMixin['ariaChecked'];\n declare ariaColCount: ARIAMixin['ariaColCount'];\n declare ariaColIndex: ARIAMixin['ariaColIndex'];\n declare ariaColIndexText: string | null;\n declare ariaColSpan: ARIAMixin['ariaColSpan'];\n declare ariaCurrent: ARIAMixin['ariaCurrent'];\n declare ariaDisabled: ARIAMixin['ariaDisabled'];\n declare ariaExpanded: ARIAMixin['ariaExpanded'];\n declare ariaHasPopup: ARIAMixin['ariaHasPopup'];\n declare ariaHidden: ARIAMixin['ariaHidden'];\n declare ariaInvalid: ARIAMixin['ariaInvalid'];\n declare ariaKeyShortcuts: ARIAMixin['ariaKeyShortcuts'];\n declare ariaLabel: ARIAMixin['ariaLabel'];\n declare ariaLevel: ARIAMixin['ariaLevel'];\n declare ariaLive: ARIAMixin['ariaLive'];\n declare ariaModal: ARIAMixin['ariaModal'];\n declare ariaMultiLine: ARIAMixin['ariaMultiLine'];\n declare ariaMultiSelectable: ARIAMixin['ariaMultiSelectable'];\n declare ariaOrientation: ARIAMixin['ariaOrientation'];\n declare ariaPlaceholder: ARIAMixin['ariaPlaceholder'];\n declare ariaPosInSet: ARIAMixin['ariaPosInSet'];\n declare ariaPressed: ARIAMixin['ariaPressed'];\n declare ariaReadOnly: ARIAMixin['ariaReadOnly'];\n declare ariaRequired: ARIAMixin['ariaRequired'];\n declare ariaRoleDescription: ARIAMixin['ariaRoleDescription'];\n declare ariaRowCount: ARIAMixin['ariaRowCount'];\n declare ariaRowIndex: ARIAMixin['ariaRowIndex'];\n declare ariaRowIndexText: string | null;\n declare ariaRowSpan: ARIAMixin['ariaRowSpan'];\n declare ariaSelected: ARIAMixin['ariaSelected'];\n declare ariaSetSize: ARIAMixin['ariaSetSize'];\n declare ariaSort: ARIAMixin['ariaSort'];\n declare ariaValueMax: ARIAMixin['ariaValueMax'];\n declare ariaValueMin: ARIAMixin['ariaValueMin'];\n declare ariaValueNow: ARIAMixin['ariaValueNow'];\n declare ariaValueText: ARIAMixin['ariaValueText'];\n\n #internals: ElementInternals;\n\n #formDisabled = false;\n\n /** True when the control is disabled via it's containing fieldset element */\n get formDisabled() {\n return this.host.matches(':disabled') || this.#formDisabled;\n }\n\n static protos = new WeakMap();\n\n get labels() {\n return this.#internals.labels;\n }\n\n get validity() {\n return this.#internals.validity;\n }\n\n constructor(\n public host: ReactiveControllerHost & HTMLElement,\n options?: Partial<ARIAMixin>\n ) {\n this.#internals = host.attachInternals();\n // We need to polyfill :disabled\n // see https://github.com/calebdwilliams/element-internals-polyfill/issues/88\n const orig = (host as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback;\n (host as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback = disabled => {\n this.#formDisabled = disabled;\n orig?.call(host, disabled);\n };\n // proxy the internals object's aria prototype\n for (const key of Object.keys(Object.getPrototypeOf(this.#internals))) {\n if (isARIAMixinProp(key)) {\n Object.defineProperty(this, key, {\n get() {\n return this.#internals[key];\n },\n set(value) {\n this.#internals[key] = value;\n this.host.requestUpdate();\n }\n });\n }\n }\n\n for (const [key, val] of Object.entries(options ?? {})) {\n if (isARIAMixinProp(key)) {\n this[key] = val;\n }\n }\n }\n\n hostConnected?(): void\n\n setFormValue(...args: Parameters<ElementInternals['setFormValue']>) {\n return this.#internals.setFormValue(...args);\n }\n\n setValidity(...args: Parameters<ElementInternals['setValidity']>) {\n return this.#internals.setValidity(...args);\n }\n\n checkValidity(...args: Parameters<ElementInternals['checkValidity']>) {\n return this.#internals.checkValidity(...args);\n }\n\n reportValidity(...args: Parameters<ElementInternals['reportValidity']>) {\n return this.#internals.reportValidity(...args);\n }\n\n submit() {\n this.#internals.form?.requestSubmit();\n }\n\n reset() {\n this.#internals.form?.reset();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internals-controller.js","sourceRoot":"","sources":["internals-controller.ts"],"names":[],"mappings":";;AAEA,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;AAE7B,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAMhC,qEAAqE;AACrE,SAAS,IAAI,CACX,MAA2B,EAC3B,GAA8B;IAE9B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;QA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IAAI;mEAA+C;AAE9C;IAAL,IAAI;6DAAyC","sourcesContent":["import type { ReactiveController, ReactiveControllerHost } from 'lit';\n\nfunction isARIAMixinProp(key: string): key is keyof ARIAMixin {\n return key === 'role' || key.startsWith('aria');\n}\n\nconst protos = new WeakMap();\n\nlet constructingAllowed = false;\n\ninterface InternalsControllerOptions extends Partial<ARIAMixin> {\n getHTMLElement?(): HTMLElement;\n}\n\n/** reactively forward the internals object's aria mixin prototype */\nfunction aria(\n target: InternalsController,\n key: keyof InternalsController,\n) {\n if (!protos.has(target)) {\n protos.set(target, new Set());\n }\n if (protos.get(target).has(key)) {\n return;\n }\n if (!isARIAMixinProp(key)) {\n throw new Error('@aria can only be called on ARIAMixin properties');\n }\n // typescript experimental decorator\n Object.defineProperty(target, key, {\n enumerable: true,\n configurable: false,\n get(this: InternalsController) {\n // @ts-expect-error: because i'm bad, i'm bad\n return this.attach()[key];\n },\n set(this: InternalsController, value: string | null) {\n // @ts-expect-error: shamone!\n this.attach()[key] = value;\n this.host.requestUpdate();\n }\n });\n protos.get(target).add(key);\n}\n\nfunction getLabelText(label: HTMLElement) {\n if (label.hidden) {\n return '';\n } else {\n const ariaLabel = label.getAttribute?.('aria-label');\n return ariaLabel ?? label.textContent;\n }\n}\n\nexport class InternalsController implements ReactiveController, ARIAMixin {\n private static instances = new WeakMap<ReactiveControllerHost, InternalsController>();\n\n declare readonly form: ElementInternals['form'];\n declare readonly shadowRoot: ElementInternals['shadowRoot'];\n\n // https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states\n declare readonly states: unknown;\n declare readonly willValidate: ElementInternals['willValidate'];\n declare readonly validationMessage: ElementInternals['validationMessage'];\n\n public static of(host: ReactiveControllerHost, options?: InternalsControllerOptions): InternalsController {\n constructingAllowed = true;\n // implement the singleton pattern\n // using a public static constructor method is much easier to manage,\n // due to the quirks of our typescript config\n const instance: InternalsController =\n InternalsController.instances.get(host) ??\n new InternalsController(host, options);\n instance.initializeOptions(options);\n constructingAllowed = false;\n return instance;\n }\n\n @aria role: string | null = null;\n\n @aria ariaActivedescendant: string | null = null;\n @aria ariaAtomic: string | null = null;\n @aria ariaAutoComplete: string | null = null;\n @aria ariaBusy: string | null = null;\n @aria ariaChecked: string | null = null;\n @aria ariaColCount: string | null = null;\n @aria ariaColIndex: string | null = null;\n @aria ariaColIndexText: string | null = null;\n @aria ariaColSpan: string | null = null;\n @aria ariaCurrent: string | null = null;\n @aria ariaDescription: string | null = null;\n @aria ariaDisabled: string | null = null;\n @aria ariaExpanded: string | null = null;\n @aria ariaHasPopup: string | null = null;\n @aria ariaHidden: string | null = null;\n @aria ariaInvalid: string | null = null;\n @aria ariaKeyShortcuts: string | null = null;\n @aria ariaLabel: string | null = null;\n @aria ariaLevel: string | null = null;\n @aria ariaLive: string | null = null;\n @aria ariaModal: string | null = null;\n @aria ariaMultiLine: string | null = null;\n @aria ariaMultiSelectable: string | null = null;\n @aria ariaOrientation: string | null = null;\n @aria ariaPlaceholder: string | null = null;\n @aria ariaPosInSet: string | null = null;\n @aria ariaPressed: string | null = null;\n @aria ariaReadOnly: string | null = null;\n @aria ariaRequired: string | null = null;\n @aria ariaRoleDescription: string | null = null;\n @aria ariaRowCount: string | null = null;\n @aria ariaRowIndex: string | null = null;\n @aria ariaRowIndexText: string | null = null;\n @aria ariaRowSpan: string | null = null;\n @aria ariaSelected: string | null = null;\n @aria ariaSetSize: string | null = null;\n @aria ariaSort: string | null = null;\n @aria ariaValueMax: string | null = null;\n @aria ariaValueMin: string | null = null;\n @aria ariaValueNow: string | null = null;\n @aria ariaValueText: string | null = null;\n\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaActiveDescendantElement: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaControlsElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaDescribedByElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaDetailsElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaErrorMessageElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaFlowToElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaLabelledByElements: Element | null = null;\n /** WARNING: be careful of cross-root ARIA browser support */\n @aria ariaOwnsElements: Element | null = null;\n\n /** True when the control is disabled via it's containing fieldset element */\n get formDisabled() {\n return this.element?.matches(':disabled') || this._formDisabled;\n }\n\n get labels() {\n return this.internals.labels;\n }\n\n get validity() {\n return this.internals.validity;\n }\n\n /** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */\n get computedLabelText() {\n return this.internals.ariaLabel ||\n Array.from(this.internals.labels as NodeListOf<HTMLElement>)\n .reduce((acc, label) =>\n `${acc}${getLabelText(label)}`, '');\n }\n\n private get element() {\n return this.host instanceof HTMLElement ? this.host : this.options?.getHTMLElement?.();\n }\n\n private internals!: ElementInternals;\n\n private _formDisabled = false;\n\n private constructor(\n public host: ReactiveControllerHost,\n private options?: InternalsControllerOptions,\n ) {\n if (!constructingAllowed) {\n throw new Error('InternalsController must be constructed with `InternalsController.for()`');\n }\n if (!this.element) {\n throw new Error('InternalsController must be instantiated with an HTMLElement or a `getHTMLElement` function');\n }\n this.attach();\n this.initializeOptions(options);\n InternalsController.instances.set(host, this);\n this.#polyfillDisabledPseudo();\n }\n\n /**\n * We need to polyfill :disabled\n * see https://github.com/calebdwilliams/element-internals-polyfill/issues/88\n */\n #polyfillDisabledPseudo() {\n // START polyfill-disabled\n // We need to polyfill :disabled\n // see https://github.com/calebdwilliams/element-internals-polyfill/issues/88\n const orig = (this.element as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback;\n (this.element as HTMLElement & { formDisabledCallback?(disabled: boolean): void }).formDisabledCallback = disabled => {\n this._formDisabled = disabled;\n orig?.call(this.host, disabled);\n // END polyfill-disabled\n };\n }\n\n /**\n * Typescript (with experimental decorators) will compile the class\n * such that the order of operations is:\n * 1. set up constructor parameter fields\n * 2. run decorated field setters with initializers as the value\n * 3. run the rest of the constructor\n * Because of that, `this.internals` may not be available in the decorator setter\n * so we cheat here with nullish coalescing assignment operator `??=`;\n */\n private attach() {\n this.internals ??= this.element!.attachInternals();\n return this.internals;\n }\n\n private initializeOptions(options?: Partial<ARIAMixin>) {\n this.options ??= options ?? {};\n const { getHTMLElement, ...aria } = this.options;\n this.options.getHTMLElement ??= getHTMLElement;\n for (const [key, val] of Object.entries(aria)) {\n if (isARIAMixinProp(key)) {\n this[key] = val;\n }\n }\n }\n\n hostConnected?(): void\n\n setFormValue(...args: Parameters<ElementInternals['setFormValue']>) {\n return this.internals.setFormValue(...args);\n }\n\n setValidity(...args: Parameters<ElementInternals['setValidity']>) {\n return this.internals.setValidity(...args);\n }\n\n checkValidity(...args: Parameters<ElementInternals['checkValidity']>) {\n return this.internals.checkValidity(...args);\n }\n\n reportValidity(...args: Parameters<ElementInternals['reportValidity']>) {\n return this.internals.reportValidity(...args);\n }\n\n submit() {\n this.internals.form?.requestSubmit();\n }\n\n reset() {\n this.internals.form?.reset();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light-dom-controller.js","sourceRoot":"","sources":["light-dom-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOrC,MAAM,OAAO,kBAAkB;IAK7B,YAAoB,IAAqB,EAAE,WAAuB,EAAU,OAAiB;QAAzE,SAAI,GAAJ,IAAI,CAAiB;QAAmC,YAAO,GAAP,OAAO,CAAU;QAC3F,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,EAAE,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,aAAa,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AQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE;gBACjE,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,OAA+B,CAChD,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,CAAC,CAAC,CACP,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAC7B,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAChD,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { ReactiveController, ReactiveElement } from 'lit';\n\nimport { Logger } from './logger.js';\n\nexport interface Options {\n observe?: boolean | MutationObserverInit;\n emptyWarning?: string;\n}\n\nexport class LightDOMController implements ReactiveController {\n private mo: MutationObserver;\n private logger: Logger;\n private initializer: () => void;\n\n constructor(private host: ReactiveElement, initializer: () => void, private options?: Options) {\n this.initializer = initializer.bind(host);\n this.mo = new MutationObserver(this.initializer);\n this.logger = new Logger(this.host);\n host.addController(this);\n }\n\n hostConnected() {\n if (this.hasLightDOM()) {\n this.initializer();\n } else if (this.options?.emptyWarning) {\n this.logger.warn(this.options?.emptyWarning);\n }\n\n this.initObserver();\n }\n\n hostDisconnected() {\n this.mo.disconnect();\n }\n\n private initObserver() {\n if (this.options?.observe ?? true) {\n // Use the provided options, or their defaults\n this.mo.observe(\n this.host,\n typeof this.options?.observe !== 'object' ? { childList: true }\n : this.options?.observe as MutationObserverInit\n );\n }\n }\n\n /**\n * Returns a boolean statement of whether or not this component contains any light DOM.\n */\n hasLightDOM(): boolean {\n return !!(\n this.host.children.length > 0 ||\n (this.host.textContent ?? '').trim().length > 0\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
export interface ListboxAccessibilityController<Item extends HTMLElement> extends ReactiveController {
|
|
3
|
+
items: Item[];
|
|
4
|
+
activeItem?: Item;
|
|
5
|
+
nextItem?: Item;
|
|
6
|
+
prevItem?: Item;
|
|
7
|
+
firstItem?: Item;
|
|
8
|
+
lastItem?: Item;
|
|
9
|
+
updateItems(items: Item[]): void;
|
|
10
|
+
setActiveItem(item: Item): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Filtering, multiselect, and orientation options for listbox
|
|
14
|
+
*/
|
|
15
|
+
export interface ListboxConfigOptions<T extends HTMLElement> {
|
|
16
|
+
multi?: boolean;
|
|
17
|
+
a11yController: ListboxAccessibilityController<T>;
|
|
18
|
+
getHTMLElement(): HTMLElement | null;
|
|
19
|
+
requestSelect(option: T, force?: boolean): boolean;
|
|
20
|
+
isSelected(option: T): boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Implements listbox semantics and accesibility. As there are two recognized
|
|
24
|
+
* patterns for implementing keyboard interactions with listbox patterns,
|
|
25
|
+
* provide a secondary controller (either RovingTabindexController or
|
|
26
|
+
* ActiveDescendantController) to complete the implementation.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ListboxController<Item extends HTMLElement> implements ReactiveController {
|
|
29
|
+
#private;
|
|
30
|
+
host: ReactiveControllerHost;
|
|
31
|
+
private _options;
|
|
32
|
+
private static instances;
|
|
33
|
+
static of<Item extends HTMLElement>(host: ReactiveControllerHost, options: ListboxConfigOptions<Item>): ListboxController<Item>;
|
|
34
|
+
private constructor();
|
|
35
|
+
/** Whether listbox is disabled */
|
|
36
|
+
disabled: boolean;
|
|
37
|
+
/** Current active descendant in listbox */
|
|
38
|
+
get activeItem(): Item | undefined;
|
|
39
|
+
get nextItem(): Item | undefined;
|
|
40
|
+
get options(): Item[];
|
|
41
|
+
/**
|
|
42
|
+
* array of options which are selected
|
|
43
|
+
*/
|
|
44
|
+
get selectedOptions(): Item[];
|
|
45
|
+
get value(): Item | Item[];
|
|
46
|
+
private get element();
|
|
47
|
+
hostConnected(): Promise<void>;
|
|
48
|
+
hostUpdated(): void;
|
|
49
|
+
hostDisconnected(): void;
|
|
50
|
+
/**
|
|
51
|
+
* sets the listbox value based on selected options
|
|
52
|
+
*/
|
|
53
|
+
setValue(value: Item | Item[]): void;
|
|
54
|
+
/**
|
|
55
|
+
* register's the host's Item elements as listbox controller items
|
|
56
|
+
*/
|
|
57
|
+
setOptions(options: Item[]): void;
|
|
58
|
+
}
|