@patternfly/pfe-core 2.4.1 → 4.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/activedescendant-controller.d.ts +99 -0
- package/controllers/activedescendant-controller.js +230 -0
- package/controllers/activedescendant-controller.js.map +1 -0
- package/controllers/at-focus-controller.d.ts +56 -0
- package/controllers/at-focus-controller.js +168 -0
- package/controllers/at-focus-controller.js.map +1 -0
- package/controllers/cascade-controller.d.ts +11 -0
- package/controllers/cascade-controller.js +10 -3
- package/controllers/cascade-controller.js.map +1 -1
- package/controllers/combobox-controller.d.ts +117 -0
- package/controllers/combobox-controller.js +611 -0
- package/controllers/combobox-controller.js.map +1 -0
- package/controllers/css-variable-controller.js +1 -1
- package/controllers/css-variable-controller.js.map +1 -1
- package/controllers/floating-dom-controller.d.ts +10 -3
- package/controllers/floating-dom-controller.js +93 -83
- package/controllers/floating-dom-controller.js.map +1 -1
- package/controllers/internals-controller.d.ts +104 -42
- package/controllers/internals-controller.js +354 -36
- package/controllers/internals-controller.js.map +1 -1
- package/controllers/light-dom-controller.js +2 -2
- package/controllers/light-dom-controller.js.map +1 -1
- package/controllers/listbox-controller.d.ts +143 -0
- package/controllers/listbox-controller.js +443 -0
- package/controllers/listbox-controller.js.map +1 -0
- package/controllers/logger.d.ts +33 -6
- package/controllers/logger.js +58 -13
- package/controllers/logger.js.map +1 -1
- package/controllers/overflow-controller.d.ts +10 -3
- package/controllers/overflow-controller.js +79 -44
- package/controllers/overflow-controller.js.map +1 -1
- package/controllers/perf-controller.js.map +1 -1
- package/controllers/property-observer-controller.d.ts +13 -16
- package/controllers/property-observer-controller.js +55 -27
- package/controllers/property-observer-controller.js.map +1 -1
- package/controllers/roving-tabindex-controller.d.ts +19 -50
- package/controllers/roving-tabindex-controller.js +64 -183
- package/controllers/roving-tabindex-controller.js.map +1 -1
- package/controllers/scroll-spy-controller.d.ts +4 -1
- package/controllers/scroll-spy-controller.js +94 -93
- package/controllers/scroll-spy-controller.js.map +1 -1
- package/controllers/slot-controller.d.ts +26 -19
- package/controllers/slot-controller.js +94 -83
- package/controllers/slot-controller.js.map +1 -1
- package/controllers/style-controller.js +3 -1
- package/controllers/style-controller.js.map +1 -1
- package/controllers/tabs-aria-controller.d.ts +31 -0
- package/controllers/tabs-aria-controller.js +97 -0
- package/controllers/tabs-aria-controller.js.map +1 -0
- package/controllers/test/combobox-controller.spec.d.ts +1 -0
- package/controllers/test/combobox-controller.spec.js +282 -0
- package/controllers/test/combobox-controller.spec.js.map +1 -0
- package/controllers/timestamp-controller.js +73 -70
- package/controllers/timestamp-controller.js.map +1 -1
- package/core.d.ts +3 -23
- package/core.js +1 -38
- package/core.js.map +1 -1
- package/custom-elements.json +7302 -2817
- package/decorators/bound.d.ts +3 -1
- package/decorators/bound.js +3 -1
- package/decorators/bound.js.map +1 -1
- package/decorators/cascades.d.ts +2 -0
- package/decorators/cascades.js +2 -0
- package/decorators/cascades.js.map +1 -1
- package/decorators/deprecation.d.ts +6 -5
- package/decorators/deprecation.js +6 -5
- package/decorators/deprecation.js.map +1 -1
- package/decorators/initializer.js.map +1 -1
- package/decorators/listen.d.ts +8 -0
- package/decorators/listen.js +22 -0
- package/decorators/listen.js.map +1 -0
- package/decorators/observed.d.ts +12 -16
- package/decorators/observed.js +39 -44
- package/decorators/observed.js.map +1 -1
- package/decorators/observes.d.ts +15 -0
- package/decorators/observes.js +30 -0
- package/decorators/observes.js.map +1 -0
- package/decorators/time.d.ts +1 -0
- package/decorators/time.js +6 -9
- package/decorators/time.js.map +1 -1
- package/decorators/trace.d.ts +4 -1
- package/decorators/trace.js +4 -1
- package/decorators/trace.js.map +1 -1
- package/decorators.d.ts +2 -0
- package/decorators.js +2 -0
- package/decorators.js.map +1 -1
- package/functions/arraysAreEquivalent.d.ts +9 -0
- package/functions/arraysAreEquivalent.js +28 -0
- package/functions/arraysAreEquivalent.js.map +1 -0
- package/functions/containsDeep.d.ts +8 -0
- package/functions/containsDeep.js +23 -0
- package/functions/containsDeep.js.map +1 -0
- package/functions/context.d.ts +8 -0
- package/functions/context.js +21 -0
- package/functions/context.js.map +1 -0
- package/functions/debounce.js.map +1 -1
- package/functions/isElementInView.d.ts +4 -6
- package/functions/isElementInView.js +9 -11
- package/functions/isElementInView.js.map +1 -1
- package/package.json +10 -4
- package/functions/deprecatedCustomEvent.d.ts +0 -5
- package/functions/deprecatedCustomEvent.js +0 -12
- package/functions/deprecatedCustomEvent.js.map +0 -1
|
@@ -1,68 +1,386 @@
|
|
|
1
|
+
var _InternalsController_instances, _InternalsController_polyfillDisabledPseudo;
|
|
2
|
+
import { __classPrivateFieldGet, __decorate } from "tslib";
|
|
3
|
+
import { isServer, } from 'lit';
|
|
1
4
|
function isARIAMixinProp(key) {
|
|
2
5
|
return key === 'role' || key.startsWith('aria');
|
|
3
6
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const protos = new WeakMap();
|
|
8
|
+
let constructingAllowed = false;
|
|
9
|
+
/**
|
|
10
|
+
* reactively forward the internals object's aria mixin prototype
|
|
11
|
+
* @param target
|
|
12
|
+
* @param key
|
|
13
|
+
*/
|
|
14
|
+
function aria(target, key) {
|
|
15
|
+
if (!protos.has(target)) {
|
|
16
|
+
protos.set(target, new Set());
|
|
17
|
+
}
|
|
18
|
+
if (protos.get(target).has(key)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!isARIAMixinProp(key)) {
|
|
22
|
+
throw new Error('@aria can only be called on ARIAMixin properties');
|
|
23
|
+
}
|
|
24
|
+
// typescript experimental decorator
|
|
25
|
+
Object.defineProperty(target, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
configurable: false,
|
|
28
|
+
get() {
|
|
29
|
+
// @ts-expect-error: because i'm bad, i'm bad
|
|
30
|
+
const internals = this.attachOrRetrieveInternals();
|
|
31
|
+
return internals[key];
|
|
32
|
+
},
|
|
33
|
+
set(value) {
|
|
34
|
+
// @ts-expect-error: ya know it!
|
|
35
|
+
const internals = this.attachOrRetrieveInternals();
|
|
36
|
+
// @ts-expect-error: shamone!
|
|
37
|
+
internals[key] = value;
|
|
38
|
+
this.host.requestUpdate();
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
protos.get(target).add(key);
|
|
42
|
+
}
|
|
43
|
+
function getLabelText(label) {
|
|
44
|
+
if (label.hidden) {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const ariaLabel = label.getAttribute?.('aria-label');
|
|
49
|
+
return ariaLabel ?? label.textContent;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class InternalsController {
|
|
53
|
+
static getLabels(host) {
|
|
54
|
+
return Array.from(this.instances.get(host)?.internals.labels ?? []);
|
|
55
|
+
}
|
|
56
|
+
static of(host, options) {
|
|
57
|
+
constructingAllowed = true;
|
|
58
|
+
// implement the singleton pattern
|
|
59
|
+
// using a public static constructor method is much easier to manage,
|
|
60
|
+
// due to the quirks of our typescript config
|
|
61
|
+
const instance = InternalsController.instances.get(host)
|
|
62
|
+
?? new InternalsController(host, options);
|
|
63
|
+
instance.initializeOptions(options);
|
|
64
|
+
constructingAllowed = false;
|
|
65
|
+
return instance;
|
|
66
|
+
}
|
|
7
67
|
/** True when the control is disabled via it's containing fieldset element */
|
|
8
68
|
get formDisabled() {
|
|
9
|
-
|
|
69
|
+
if (isServer) {
|
|
70
|
+
return this._formDisabled;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return this.element?.matches(':disabled') || this._formDisabled;
|
|
74
|
+
}
|
|
10
75
|
}
|
|
11
|
-
static { this.protos = new WeakMap(); }
|
|
12
76
|
get labels() {
|
|
13
|
-
return this
|
|
77
|
+
return this.internals.labels;
|
|
14
78
|
}
|
|
15
79
|
get validity() {
|
|
16
|
-
return this
|
|
80
|
+
return this.internals.validity;
|
|
81
|
+
}
|
|
82
|
+
/** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */
|
|
83
|
+
get computedLabelText() {
|
|
84
|
+
return this.internals.ariaLabel
|
|
85
|
+
|| Array.from(this.internals.labels)
|
|
86
|
+
.reduce((acc, label) => `${acc}${getLabelText(label)}`, '');
|
|
87
|
+
}
|
|
88
|
+
get element() {
|
|
89
|
+
if (isServer) {
|
|
90
|
+
// FIXME(bennyp): a little white lie, which may break
|
|
91
|
+
// when the controller is applied to non-lit frameworks.
|
|
92
|
+
return this.host;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return this.host instanceof HTMLElement ? this.host : this.options?.getHTMLElement?.();
|
|
96
|
+
}
|
|
17
97
|
}
|
|
18
98
|
constructor(host, options) {
|
|
99
|
+
_InternalsController_instances.add(this);
|
|
19
100
|
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
|
-
|
|
101
|
+
this.options = options;
|
|
102
|
+
this.role = null;
|
|
103
|
+
this.ariaActivedescendant = null;
|
|
104
|
+
this.ariaAtomic = null;
|
|
105
|
+
this.ariaAutoComplete = null;
|
|
106
|
+
this.ariaBusy = null;
|
|
107
|
+
this.ariaBrailleLabel = null;
|
|
108
|
+
this.ariaBrailleRoleDescription = null;
|
|
109
|
+
this.ariaChecked = null;
|
|
110
|
+
this.ariaColCount = null;
|
|
111
|
+
this.ariaColIndex = null;
|
|
112
|
+
this.ariaColIndexText = null;
|
|
113
|
+
this.ariaColSpan = null;
|
|
114
|
+
this.ariaCurrent = null;
|
|
115
|
+
this.ariaDescription = null;
|
|
116
|
+
this.ariaDisabled = null;
|
|
117
|
+
this.ariaExpanded = null;
|
|
118
|
+
this.ariaHasPopup = null;
|
|
119
|
+
this.ariaHidden = null;
|
|
120
|
+
this.ariaInvalid = null;
|
|
121
|
+
this.ariaKeyShortcuts = null;
|
|
122
|
+
this.ariaLabel = null;
|
|
123
|
+
this.ariaLevel = null;
|
|
124
|
+
this.ariaLive = null;
|
|
125
|
+
this.ariaModal = null;
|
|
126
|
+
this.ariaMultiLine = null;
|
|
127
|
+
this.ariaMultiSelectable = null;
|
|
128
|
+
this.ariaOrientation = null;
|
|
129
|
+
this.ariaPlaceholder = null;
|
|
130
|
+
this.ariaPosInSet = null;
|
|
131
|
+
this.ariaPressed = null;
|
|
132
|
+
this.ariaReadOnly = null;
|
|
133
|
+
this.ariaRequired = null;
|
|
134
|
+
this.ariaRoleDescription = null;
|
|
135
|
+
this.ariaRowCount = null;
|
|
136
|
+
this.ariaRowIndex = null;
|
|
137
|
+
this.ariaRowIndexText = null;
|
|
138
|
+
this.ariaRowSpan = null;
|
|
139
|
+
this.ariaSelected = null;
|
|
140
|
+
this.ariaSetSize = null;
|
|
141
|
+
this.ariaSort = null;
|
|
142
|
+
this.ariaValueMax = null;
|
|
143
|
+
this.ariaValueMin = null;
|
|
144
|
+
this.ariaValueNow = null;
|
|
145
|
+
this.ariaValueText = null;
|
|
146
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
147
|
+
this.ariaActiveDescendantElement = null;
|
|
148
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
149
|
+
this.ariaControlsElements = null;
|
|
150
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
151
|
+
this.ariaDescribedByElements = null;
|
|
152
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
153
|
+
this.ariaDetailsElements = null;
|
|
154
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
155
|
+
this.ariaErrorMessageElements = null;
|
|
156
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
157
|
+
this.ariaFlowToElements = null;
|
|
158
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
159
|
+
this.ariaLabelledByElements = null;
|
|
160
|
+
/** WARNING: be careful of cross-root ARIA browser support */
|
|
161
|
+
this.ariaOwnsElements = null;
|
|
162
|
+
this._formDisabled = false;
|
|
163
|
+
if (!constructingAllowed) {
|
|
164
|
+
throw new Error('InternalsController must be constructed with `InternalsController.for()`');
|
|
165
|
+
}
|
|
166
|
+
if (!this.element) {
|
|
167
|
+
throw new Error(`InternalsController must be instantiated with an HTMLElement or a \`getHTMLElement\` function`);
|
|
41
168
|
}
|
|
42
|
-
|
|
169
|
+
this.attachOrRetrieveInternals();
|
|
170
|
+
this.initializeOptions(options);
|
|
171
|
+
InternalsController.instances.set(host, this);
|
|
172
|
+
__classPrivateFieldGet(this, _InternalsController_instances, "m", _InternalsController_polyfillDisabledPseudo).call(this);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Typescript (with experimental decorators) will compile the class
|
|
176
|
+
* such that the order of operations is:
|
|
177
|
+
* 1. set up constructor parameter fields
|
|
178
|
+
* 2. run decorated field setters with initializers as the value
|
|
179
|
+
* 3. run the rest of the constructor
|
|
180
|
+
* Because of that, `this.internals` may not be available in the decorator setter
|
|
181
|
+
* so we cheat here with nullish coalescing assignment operator `??=`;
|
|
182
|
+
*/
|
|
183
|
+
attachOrRetrieveInternals() {
|
|
184
|
+
this.internals ?? (this.internals = this.element.attachInternals());
|
|
185
|
+
return this.internals;
|
|
186
|
+
}
|
|
187
|
+
initializeOptions(options) {
|
|
188
|
+
var _a;
|
|
189
|
+
this.options ?? (this.options = options ?? {});
|
|
190
|
+
const { getHTMLElement, ...aria } = this.options;
|
|
191
|
+
(_a = this.options).getHTMLElement ?? (_a.getHTMLElement = getHTMLElement);
|
|
192
|
+
for (const [key, val] of Object.entries(aria)) {
|
|
43
193
|
if (isARIAMixinProp(key)) {
|
|
44
194
|
this[key] = val;
|
|
45
195
|
}
|
|
46
196
|
}
|
|
47
197
|
}
|
|
48
198
|
setFormValue(...args) {
|
|
49
|
-
return this
|
|
199
|
+
return this.internals.setFormValue(...args);
|
|
50
200
|
}
|
|
51
201
|
setValidity(...args) {
|
|
52
|
-
return this
|
|
202
|
+
return this.internals.setValidity(...args);
|
|
53
203
|
}
|
|
54
204
|
checkValidity(...args) {
|
|
55
|
-
return this
|
|
205
|
+
return this.internals.checkValidity(...args);
|
|
56
206
|
}
|
|
57
207
|
reportValidity(...args) {
|
|
58
|
-
return this
|
|
208
|
+
return this.internals.reportValidity(...args);
|
|
59
209
|
}
|
|
60
210
|
submit() {
|
|
61
|
-
this
|
|
211
|
+
this.internals.form?.requestSubmit();
|
|
62
212
|
}
|
|
63
213
|
reset() {
|
|
64
|
-
this
|
|
214
|
+
this.internals.form?.reset();
|
|
65
215
|
}
|
|
66
216
|
}
|
|
67
|
-
|
|
217
|
+
_InternalsController_instances = new WeakSet(), _InternalsController_polyfillDisabledPseudo = function _InternalsController_polyfillDisabledPseudo() {
|
|
218
|
+
// START polyfill-disabled
|
|
219
|
+
// We need to polyfill :disabled
|
|
220
|
+
// see https://github.com/calebdwilliams/element-internals-polyfill/issues/88
|
|
221
|
+
const orig = this.element.formDisabledCallback;
|
|
222
|
+
this.element.formDisabledCallback = disabled => {
|
|
223
|
+
this._formDisabled = disabled;
|
|
224
|
+
orig?.call(this.host, disabled);
|
|
225
|
+
// END polyfill-disabled
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
InternalsController.instances = new WeakMap();
|
|
229
|
+
InternalsController.isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
230
|
+
__decorate([
|
|
231
|
+
aria
|
|
232
|
+
], InternalsController.prototype, "role", void 0);
|
|
233
|
+
__decorate([
|
|
234
|
+
aria
|
|
235
|
+
], InternalsController.prototype, "ariaActivedescendant", void 0);
|
|
236
|
+
__decorate([
|
|
237
|
+
aria
|
|
238
|
+
], InternalsController.prototype, "ariaAtomic", void 0);
|
|
239
|
+
__decorate([
|
|
240
|
+
aria
|
|
241
|
+
], InternalsController.prototype, "ariaAutoComplete", void 0);
|
|
242
|
+
__decorate([
|
|
243
|
+
aria
|
|
244
|
+
], InternalsController.prototype, "ariaBusy", void 0);
|
|
245
|
+
__decorate([
|
|
246
|
+
aria
|
|
247
|
+
], InternalsController.prototype, "ariaBrailleLabel", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
aria
|
|
250
|
+
], InternalsController.prototype, "ariaBrailleRoleDescription", void 0);
|
|
251
|
+
__decorate([
|
|
252
|
+
aria
|
|
253
|
+
], InternalsController.prototype, "ariaChecked", void 0);
|
|
254
|
+
__decorate([
|
|
255
|
+
aria
|
|
256
|
+
], InternalsController.prototype, "ariaColCount", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
aria
|
|
259
|
+
], InternalsController.prototype, "ariaColIndex", void 0);
|
|
260
|
+
__decorate([
|
|
261
|
+
aria
|
|
262
|
+
], InternalsController.prototype, "ariaColIndexText", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
aria
|
|
265
|
+
], InternalsController.prototype, "ariaColSpan", void 0);
|
|
266
|
+
__decorate([
|
|
267
|
+
aria
|
|
268
|
+
], InternalsController.prototype, "ariaCurrent", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
aria
|
|
271
|
+
], InternalsController.prototype, "ariaDescription", void 0);
|
|
272
|
+
__decorate([
|
|
273
|
+
aria
|
|
274
|
+
], InternalsController.prototype, "ariaDisabled", void 0);
|
|
275
|
+
__decorate([
|
|
276
|
+
aria
|
|
277
|
+
], InternalsController.prototype, "ariaExpanded", void 0);
|
|
278
|
+
__decorate([
|
|
279
|
+
aria
|
|
280
|
+
], InternalsController.prototype, "ariaHasPopup", void 0);
|
|
281
|
+
__decorate([
|
|
282
|
+
aria
|
|
283
|
+
], InternalsController.prototype, "ariaHidden", void 0);
|
|
284
|
+
__decorate([
|
|
285
|
+
aria
|
|
286
|
+
], InternalsController.prototype, "ariaInvalid", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
aria
|
|
289
|
+
], InternalsController.prototype, "ariaKeyShortcuts", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
aria
|
|
292
|
+
], InternalsController.prototype, "ariaLabel", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
aria
|
|
295
|
+
], InternalsController.prototype, "ariaLevel", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
aria
|
|
298
|
+
], InternalsController.prototype, "ariaLive", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
aria
|
|
301
|
+
], InternalsController.prototype, "ariaModal", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
aria
|
|
304
|
+
], InternalsController.prototype, "ariaMultiLine", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
aria
|
|
307
|
+
], InternalsController.prototype, "ariaMultiSelectable", void 0);
|
|
308
|
+
__decorate([
|
|
309
|
+
aria
|
|
310
|
+
], InternalsController.prototype, "ariaOrientation", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
aria
|
|
313
|
+
], InternalsController.prototype, "ariaPlaceholder", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
aria
|
|
316
|
+
], InternalsController.prototype, "ariaPosInSet", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
aria
|
|
319
|
+
], InternalsController.prototype, "ariaPressed", void 0);
|
|
320
|
+
__decorate([
|
|
321
|
+
aria
|
|
322
|
+
], InternalsController.prototype, "ariaReadOnly", void 0);
|
|
323
|
+
__decorate([
|
|
324
|
+
aria
|
|
325
|
+
], InternalsController.prototype, "ariaRequired", void 0);
|
|
326
|
+
__decorate([
|
|
327
|
+
aria
|
|
328
|
+
], InternalsController.prototype, "ariaRoleDescription", void 0);
|
|
329
|
+
__decorate([
|
|
330
|
+
aria
|
|
331
|
+
], InternalsController.prototype, "ariaRowCount", void 0);
|
|
332
|
+
__decorate([
|
|
333
|
+
aria
|
|
334
|
+
], InternalsController.prototype, "ariaRowIndex", void 0);
|
|
335
|
+
__decorate([
|
|
336
|
+
aria
|
|
337
|
+
], InternalsController.prototype, "ariaRowIndexText", void 0);
|
|
338
|
+
__decorate([
|
|
339
|
+
aria
|
|
340
|
+
], InternalsController.prototype, "ariaRowSpan", void 0);
|
|
341
|
+
__decorate([
|
|
342
|
+
aria
|
|
343
|
+
], InternalsController.prototype, "ariaSelected", void 0);
|
|
344
|
+
__decorate([
|
|
345
|
+
aria
|
|
346
|
+
], InternalsController.prototype, "ariaSetSize", void 0);
|
|
347
|
+
__decorate([
|
|
348
|
+
aria
|
|
349
|
+
], InternalsController.prototype, "ariaSort", void 0);
|
|
350
|
+
__decorate([
|
|
351
|
+
aria
|
|
352
|
+
], InternalsController.prototype, "ariaValueMax", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
aria
|
|
355
|
+
], InternalsController.prototype, "ariaValueMin", void 0);
|
|
356
|
+
__decorate([
|
|
357
|
+
aria
|
|
358
|
+
], InternalsController.prototype, "ariaValueNow", void 0);
|
|
359
|
+
__decorate([
|
|
360
|
+
aria
|
|
361
|
+
], InternalsController.prototype, "ariaValueText", void 0);
|
|
362
|
+
__decorate([
|
|
363
|
+
aria
|
|
364
|
+
], InternalsController.prototype, "ariaActiveDescendantElement", void 0);
|
|
365
|
+
__decorate([
|
|
366
|
+
aria
|
|
367
|
+
], InternalsController.prototype, "ariaControlsElements", void 0);
|
|
368
|
+
__decorate([
|
|
369
|
+
aria
|
|
370
|
+
], InternalsController.prototype, "ariaDescribedByElements", void 0);
|
|
371
|
+
__decorate([
|
|
372
|
+
aria
|
|
373
|
+
], InternalsController.prototype, "ariaDetailsElements", void 0);
|
|
374
|
+
__decorate([
|
|
375
|
+
aria
|
|
376
|
+
], InternalsController.prototype, "ariaErrorMessageElements", void 0);
|
|
377
|
+
__decorate([
|
|
378
|
+
aria
|
|
379
|
+
], InternalsController.prototype, "ariaFlowToElements", void 0);
|
|
380
|
+
__decorate([
|
|
381
|
+
aria
|
|
382
|
+
], InternalsController.prototype, "ariaLabelledByElements", void 0);
|
|
383
|
+
__decorate([
|
|
384
|
+
aria
|
|
385
|
+
], InternalsController.prototype, "ariaOwnsElements", void 0);
|
|
68
386
|
//# 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,CAAC;IAClC,CAAC;IAED,YACS,IAA0C,EACjD,OAA4B;QADrB,SAAI,GAAJ,IAAI,CAAsC;QAGjD,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;QACzC,gCAAgC;QAChC,6EAA6E;QAC7E,MAAM,IAAI,GAAI,IAAyE,CAAC,oBAAoB,CAAC;QAC5G,IAAyE,CAAC,oBAAoB,GAAG,QAAQ,CAAC,EAAE;YAC3G,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC;YAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,8CAA8C;QAC9C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EA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":["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":";;AAAA,OAAO,EACL,QAAQ,GAIT,MAAM,KAAK,CAAC;AAEb,SAAS,eAAe,CAAC,GAAW;IAClC,OAAO,GAAG,KAAK,MAAM,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAClD,CAAC;AAMD,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;AAE7B,IAAI,mBAAmB,GAAG,KAAK,CAAC;AAMhC;;;;GAIG;AACH,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;QAChC,OAAO;IACT,CAAC;IACD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,oCAAoC;IACpC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;QACjC,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,KAAK;QACnB,GAAG;YACD,6CAA6C;YAC7C,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;YACnD,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QACD,GAAG,CAA4B,KAAoB;YACjD,gCAAgC;YAChC,MAAM,SAAS,GAAG,IAAI,CAAC,yBAAyB,EAAE,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AAoC;AACnC;IAAL,IAAI;yDAAoC;AACnC;IAAL,IAAI;0DAAqC;AAGpC;IAAL,IAAI;wEAAoD;AAEnD;IAAL,IAAI;iEAA+C;AAE9C;IAAL,IAAI;oEAAkD;AAEjD;IAAL,IAAI;gEAA8C;AAE7C;IAAL,IAAI;qEAAmD;AAElD;IAAL,IAAI;+DAA6C;AAE5C;IAAL,IAAI;mEAAiD;AAEhD;IAAL,IAAI;6DAA2C","sourcesContent":["import {\n isServer,\n type ReactiveController,\n type ReactiveControllerHost,\n type LitElement,\n} from 'lit';\n\nfunction isARIAMixinProp(key: string): key is keyof ARIAMixin {\n return key === 'role' || key.startsWith('aria');\n}\n\ntype FACE = HTMLElement & {\n formDisabledCallback?(disabled: boolean): void;\n};\n\nconst protos = new WeakMap();\n\nlet constructingAllowed = false;\n\ninterface InternalsControllerOptions extends Partial<ARIAMixin> {\n getHTMLElement?(): HTMLElement;\n}\n\n/**\n * reactively forward the internals object's aria mixin prototype\n * @param target\n * @param key\n */\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 const internals = this.attachOrRetrieveInternals();\n return internals[key];\n },\n set(this: InternalsController, value: string | null) {\n // @ts-expect-error: ya know it!\n const internals = this.attachOrRetrieveInternals();\n // @ts-expect-error: shamone!\n internals[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 getLabels(host: ReactiveControllerHost): Element[] {\n return Array.from(this.instances.get(host)?.internals.labels ?? []) as Element[];\n }\n\n public static isSafari: boolean = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n\n public static of(\n host: ReactiveControllerHost,\n options?: InternalsControllerOptions,\n ): 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 ariaBrailleLabel: string | null = null;\n @aria ariaBrailleRoleDescription: 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(): boolean {\n if (isServer) {\n return this._formDisabled;\n } else {\n return this.element?.matches(':disabled') || this._formDisabled;\n }\n }\n\n get labels(): NodeList {\n return this.internals.labels;\n }\n\n get validity(): ValidityState {\n return this.internals.validity;\n }\n\n /** A best-attempt based on observed behaviour in FireFox 115 on fedora 38 */\n get computedLabelText(): string {\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 if (isServer) {\n // FIXME(bennyp): a little white lie, which may break\n // when the controller is applied to non-lit frameworks.\n return this.host as LitElement;\n } else {\n return this.host instanceof HTMLElement ? this.host : this.options?.getHTMLElement?.();\n }\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(\n `InternalsController must be instantiated with an HTMLElement or a \\`getHTMLElement\\` function`,\n );\n }\n this.attachOrRetrieveInternals();\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 FACE).formDisabledCallback;\n (this.element as FACE).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 attachOrRetrieveInternals() {\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 as keyof this] = val as this[keyof this];\n }\n }\n }\n\n hostConnected?(): void;\n\n setFormValue(...args: Parameters<ElementInternals['setFormValue']>): void {\n return this.internals.setFormValue(...args);\n }\n\n setValidity(...args: Parameters<ElementInternals['setValidity']>): void {\n return this.internals.setValidity(...args);\n }\n\n checkValidity(...args: Parameters<ElementInternals['checkValidity']>): boolean {\n return this.internals.checkValidity(...args);\n }\n\n reportValidity(...args: Parameters<ElementInternals['reportValidity']>): boolean {\n return this.internals.reportValidity(...args);\n }\n\n submit(): void {\n this.internals.form?.requestSubmit();\n }\n\n reset(): void {\n this.internals.form?.reset();\n }\n}\n\n/** @see https://w3c.github.io/aria/#ref-for-dom-ariamixin-ariaactivedescendantelement-1 */\ndeclare global {\n interface ARIAMixin {\n ariaActiveDescendantElement: Element | null;\n ariaControlsElements: readonly Element[] | null;\n ariaDescribedByElements: readonly Element[] | null;\n ariaDetailsElements: readonly Element[] | null;\n ariaErrorMessageElements: readonly Element[] | null;\n ariaFlowToElements: readonly Element[] | null;\n ariaLabelledByElements: readonly Element[] | null;\n ariaOwnsElements: readonly Element[] | null;\n }\n}\n"]}
|
|
@@ -31,8 +31,8 @@ export class LightDOMController {
|
|
|
31
31
|
* Returns a boolean statement of whether or not this component contains any light DOM.
|
|
32
32
|
*/
|
|
33
33
|
hasLightDOM() {
|
|
34
|
-
return !!(this.host.children.length > 0
|
|
35
|
-
(this.host.textContent ?? '').trim().length > 0);
|
|
34
|
+
return !!(this.host.children.length > 0
|
|
35
|
+
|| (this.host.textContent ?? '').trim().length > 0);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
//# sourceMappingURL=light-dom-controller.js.map
|
|
@@ -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,
|
|
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,YACU,IAAqB,EAC7B,WAAuB,EACf,OAA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I,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CACnD,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(\n private host: ReactiveElement,\n initializer: () => void,\n private options?: Options | undefined,\n ) {\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(): void {\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(): void {\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,143 @@
|
|
|
1
|
+
import type { ReactiveController, ReactiveControllerHost } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Options for listbox controller
|
|
4
|
+
*/
|
|
5
|
+
export interface ListboxControllerOptions<Item extends HTMLElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the listbox supports multiple selections.
|
|
8
|
+
*/
|
|
9
|
+
multi?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Optional callback to control the selection behavior of items. By default, ListboxController
|
|
12
|
+
* will set the `aria-selected` attribute. When overriding this option, it will call it on your
|
|
13
|
+
* element with the selected state.
|
|
14
|
+
* Callers **must** ensure that the correct ARIA state is set.
|
|
15
|
+
*/
|
|
16
|
+
setItemSelected?(item: Item, selected: boolean): void;
|
|
17
|
+
/**
|
|
18
|
+
* Optional predicate to ascertain whether a custom element item is disabled or not
|
|
19
|
+
* By default, if the item matches any of these conditions, it is considered disabled:
|
|
20
|
+
* 1. it's `disabled` DOM property is `true`
|
|
21
|
+
* 1. it has the `aria-disabled="true"` attribute
|
|
22
|
+
* 2. it has the `disabled` attribute present
|
|
23
|
+
* 3. it matches the `:disabled` pseudo selector
|
|
24
|
+
*/
|
|
25
|
+
isItemDisabled?(item: Item): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Predicate which determines if a given element is in fact an item
|
|
28
|
+
* instead of e.g a presentational divider. By default, elements must meet the following criteria
|
|
29
|
+
* 1. element a child of a listbox role,
|
|
30
|
+
* 2. element does not have role="presentation"
|
|
31
|
+
* 2. element is not an `<hr>`
|
|
32
|
+
* **NB**: When overriding, you must avoid outside references. This predicate must
|
|
33
|
+
* only consider the element itself, without reference to the host element's items array.
|
|
34
|
+
* @example ```js
|
|
35
|
+
* isItem: (item) => item instanceof MyCustomItem
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
isItem?(item: EventTarget | null): item is Item;
|
|
39
|
+
/**
|
|
40
|
+
* Function returning the item which currently has assistive technology focus.
|
|
41
|
+
* In most cases, this should be the `atFocusedItem` of an ATFocusController
|
|
42
|
+
* i.e. RovingTabindexController or ActivedescendantController.
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
getATFocusedItem(): Item | null;
|
|
46
|
+
/**
|
|
47
|
+
* Function returning the DOM node which is the direct parent of the item elements
|
|
48
|
+
* Defaults to the controller host.
|
|
49
|
+
* If the controller host is not an HTMLElement, this *must* be set
|
|
50
|
+
*/
|
|
51
|
+
getItemsContainer?(): HTMLElement | null;
|
|
52
|
+
/**
|
|
53
|
+
* Optional function returning an additional DOM node which controls the listbox, e.g.
|
|
54
|
+
* a combobox input.
|
|
55
|
+
*/
|
|
56
|
+
getControlsElements?(): HTMLElement[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @param item possible disabled item
|
|
60
|
+
* @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time
|
|
61
|
+
*/
|
|
62
|
+
export declare function isItem<Item extends HTMLElement>(item: EventTarget | null): item is Item;
|
|
63
|
+
/**
|
|
64
|
+
* This is a fib. aria-disabled might not be present on an element that uses internals,
|
|
65
|
+
* and the `disabled` attribute may not accurately represent the disabled state.
|
|
66
|
+
* short of patching the `attachInternals` constructor, it may not be possible at
|
|
67
|
+
* runtime to know with certainty that an arbitrary custom element is disabled or not.
|
|
68
|
+
* @param item possibly disabled item
|
|
69
|
+
* @package do not import this outside of `@patternfly/pfe-core`, it is subject to change at any time
|
|
70
|
+
*/
|
|
71
|
+
export declare function isItemDisabled<Item extends HTMLElement>(item: Item): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Implements listbox semantics and accesibility. As there are two recognized
|
|
74
|
+
* patterns for implementing keyboard interactions with listbox patterns,
|
|
75
|
+
* provide a secondary controller (either RovingTabindexController or
|
|
76
|
+
* ActiveDescendantController) to complete the implementation.
|
|
77
|
+
*
|
|
78
|
+
* @see https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_focus_vs_selection
|
|
79
|
+
*
|
|
80
|
+
* > Occasionally, it may appear as if two elements on the page have focus at the same time.
|
|
81
|
+
* > For example, in a multi-select list box, when an option is selected it may be greyed.
|
|
82
|
+
* > Yet, the focus indicator can still be moved to other options, which may also be selected.
|
|
83
|
+
* > Similarly, when a user activates a tab in a tablist, the selected state is set on the tab
|
|
84
|
+
* > and its visual appearance changes. However, the user can still navigate, moving the focus
|
|
85
|
+
* > indicator elsewhere on the page while the tab retains its selected appearance and state.
|
|
86
|
+
* >
|
|
87
|
+
* > Focus and selection are quite different. From the keyboard user's perspective,
|
|
88
|
+
* > focus is a pointer, like a mouse pointer; it tracks the path of navigation.
|
|
89
|
+
* > There is only one point of focus at any time and all operations take place at the
|
|
90
|
+
* > point of focus. On the other hand, selection is an operation that can be performed in
|
|
91
|
+
* > some widgets, such as list boxes, trees, and tablists. If a widget supports only single
|
|
92
|
+
* > selection, then only one item can be selected and very often the selected state will simply
|
|
93
|
+
* > follow the focus when focus is moved inside of the widget.
|
|
94
|
+
* > That is, in some widgets, moving focus may also perform the select operation.
|
|
95
|
+
* > However, if the widget supports multiple selection, then more than one item can be in a
|
|
96
|
+
* > selected state, and keys for moving focus do not perform selection. Some multi-select widgets
|
|
97
|
+
* > do support key commands that both move focus and change selection, but those keys are
|
|
98
|
+
* > different from the normal navigation keys. Finally, when focus leaves a widget that includes
|
|
99
|
+
* > a selected element, the selected state persists.
|
|
100
|
+
* >
|
|
101
|
+
* > From the developer's perspective, the difference is simple -- the focused element is the
|
|
102
|
+
* > active element (document.activeElement). Selected elements are elements that have
|
|
103
|
+
* > aria-selected="true".
|
|
104
|
+
* >
|
|
105
|
+
* > With respect to focus and the selected state, the most important considerations for designers
|
|
106
|
+
* > and developers are:
|
|
107
|
+
* >
|
|
108
|
+
* > - The visual focus indicator must always be visible.
|
|
109
|
+
* > - The selected state must be visually distinct from the focus indicator.
|
|
110
|
+
*/
|
|
111
|
+
export declare class ListboxController<Item extends HTMLElement> implements ReactiveController {
|
|
112
|
+
#private;
|
|
113
|
+
host: ReactiveControllerHost;
|
|
114
|
+
private static instances;
|
|
115
|
+
static of<Item extends HTMLElement>(host: ReactiveControllerHost, options: ListboxControllerOptions<Item>): ListboxController<Item>;
|
|
116
|
+
/** Whether listbox is disabled */
|
|
117
|
+
disabled: boolean;
|
|
118
|
+
get container(): HTMLElement;
|
|
119
|
+
get multi(): boolean;
|
|
120
|
+
set multi(v: boolean);
|
|
121
|
+
get items(): Item[];
|
|
122
|
+
/**
|
|
123
|
+
* register's the host's Item elements as listbox controller items
|
|
124
|
+
* sets aria-setsize and aria-posinset on items
|
|
125
|
+
* @param items items
|
|
126
|
+
*/
|
|
127
|
+
set items(items: Item[]);
|
|
128
|
+
/**
|
|
129
|
+
* sets the listbox value based on selected options
|
|
130
|
+
* @param selected item or items
|
|
131
|
+
*/
|
|
132
|
+
set selected(selected: Item[]);
|
|
133
|
+
/**
|
|
134
|
+
* array of options which are selected
|
|
135
|
+
*/
|
|
136
|
+
get selected(): Item[];
|
|
137
|
+
private constructor();
|
|
138
|
+
hostConnected(): Promise<void>;
|
|
139
|
+
hostUpdate(): void;
|
|
140
|
+
hostUpdated(): void;
|
|
141
|
+
hostDisconnected(): void;
|
|
142
|
+
isSelected(item: Item): boolean;
|
|
143
|
+
}
|