keystra 0.0.0-stage → 0.1.1
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/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +78 -2
- package/dist/chunk-2BLQUBG7.js +816 -0
- package/dist/chunk-77GGU3AX.js +135 -0
- package/dist/chunk-KDOJARJD.js +29 -0
- package/dist/chunk-LYYUOTBP.js +125 -0
- package/dist/chunk-S5YVXIMA.js +61 -0
- package/dist/chunk-SSIKGDD4.js +255 -0
- package/dist/chunk-U7YK6PPT.js +1729 -0
- package/dist/chunk-XFNYIPOW.js +253 -0
- package/dist/chunk-ZOJRXXQN.js +308 -0
- package/dist/core.cjs +2861 -0
- package/dist/core.d.cts +41 -0
- package/dist/core.d.ts +41 -0
- package/dist/core.js +7 -0
- package/dist/engine-COPfXXTp.d.ts +229 -0
- package/dist/engine-DcbkGRgz.d.cts +229 -0
- package/dist/focus.cjs +374 -0
- package/dist/focus.d.cts +74 -0
- package/dist/focus.d.ts +74 -0
- package/dist/focus.js +2 -0
- package/dist/index-IZkcWAXP.d.cts +395 -0
- package/dist/index-IZkcWAXP.d.ts +395 -0
- package/dist/index.cjs +3745 -0
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.global.js +1 -0
- package/dist/index.js +9 -0
- package/dist/layout-C2-n8aUI.d.ts +17 -0
- package/dist/layout-CBzD-87D.d.cts +17 -0
- package/dist/navigation.cjs +293 -0
- package/dist/navigation.d.cts +33 -0
- package/dist/navigation.d.ts +33 -0
- package/dist/navigation.js +2 -0
- package/dist/patterns.cjs +3505 -0
- package/dist/patterns.d.cts +12 -0
- package/dist/patterns.d.ts +12 -0
- package/dist/patterns.js +7 -0
- package/dist/roving-focus-CT7Dm6di.d.ts +63 -0
- package/dist/roving-focus-ZQ0v7hLe.d.cts +63 -0
- package/dist/selection.cjs +266 -0
- package/dist/selection.d.cts +43 -0
- package/dist/selection.d.ts +43 -0
- package/dist/selection.js +2 -0
- package/dist/utils-CkveVeIJ.d.cts +18 -0
- package/dist/utils-JmPZTlys.d.ts +18 -0
- package/dist/utils.cjs +195 -0
- package/dist/utils.d.cts +3 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +2 -0
- package/package.json +147 -4
package/dist/focus.cjs
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/dom.ts
|
|
4
|
+
var DISABLED_SELECTOR_DEFAULT = "[disabled],[aria-disabled='true']";
|
|
5
|
+
function isDisabled(element, selector = DISABLED_SELECTOR_DEFAULT) {
|
|
6
|
+
if (!selector) return false;
|
|
7
|
+
const html = element;
|
|
8
|
+
if (html.disabled === true) return true;
|
|
9
|
+
if (element.getAttribute("aria-disabled") === "true") return true;
|
|
10
|
+
if (selector === DISABLED_SELECTOR_DEFAULT) return element.hasAttribute("disabled");
|
|
11
|
+
try {
|
|
12
|
+
return element.matches(selector);
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function isHidden(element) {
|
|
18
|
+
const html = element;
|
|
19
|
+
const probe = html;
|
|
20
|
+
if (typeof probe.checkVisibility === "function") {
|
|
21
|
+
try {
|
|
22
|
+
return !probe.checkVisibility.call(html, { checkOpacity: false, checkVisibilityCSS: true });
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let node = html;
|
|
27
|
+
while (node && node.nodeType === 1) {
|
|
28
|
+
if (node.hidden === true) return true;
|
|
29
|
+
if (node.style && node.style.display === "none") return true;
|
|
30
|
+
node = node.parentElement;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
function focusElement(element, preventScroll = true) {
|
|
35
|
+
if (typeof element.focus !== "function") return false;
|
|
36
|
+
try {
|
|
37
|
+
element.focus({ preventScroll });
|
|
38
|
+
} catch {
|
|
39
|
+
try {
|
|
40
|
+
element.focus();
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function contains(parent, child) {
|
|
48
|
+
if (!parent || !child) return false;
|
|
49
|
+
if (parent === child) return true;
|
|
50
|
+
if (typeof parent.contains === "function") return parent.contains(child);
|
|
51
|
+
let node = child;
|
|
52
|
+
while (node) {
|
|
53
|
+
if (node === parent) return true;
|
|
54
|
+
node = node.parentNode;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
var idCounter = 0;
|
|
59
|
+
function ensureId(element, prefix) {
|
|
60
|
+
const existing = element.id;
|
|
61
|
+
if (existing) return existing;
|
|
62
|
+
idCounter += 1;
|
|
63
|
+
const generated = `${prefix}-${idCounter}`;
|
|
64
|
+
element.id = generated;
|
|
65
|
+
return generated;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/focus/roving-focus.ts
|
|
69
|
+
var RovingTabindex = class {
|
|
70
|
+
constructor(options = {}) {
|
|
71
|
+
this.current = /* @__PURE__ */ new WeakMap();
|
|
72
|
+
this.originals = /* @__PURE__ */ new Map();
|
|
73
|
+
this.active = null;
|
|
74
|
+
this.respectNegative = options.respectNegative !== false;
|
|
75
|
+
this.disabled = options.disabled === true;
|
|
76
|
+
}
|
|
77
|
+
get activeElement() {
|
|
78
|
+
return this.active;
|
|
79
|
+
}
|
|
80
|
+
sync(element, others) {
|
|
81
|
+
if (this.disabled) return;
|
|
82
|
+
const desired = element ? this.desiredFor(element) : null;
|
|
83
|
+
for (let i = 0; i < others.length; i++) {
|
|
84
|
+
const item = others[i];
|
|
85
|
+
if (item === element) continue;
|
|
86
|
+
this.write(item, "-1");
|
|
87
|
+
}
|
|
88
|
+
this.active = element;
|
|
89
|
+
if (element && desired !== null) this.write(element, desired);
|
|
90
|
+
this.forgetDetached(others.length);
|
|
91
|
+
}
|
|
92
|
+
move(element) {
|
|
93
|
+
if (this.disabled) return;
|
|
94
|
+
const desired = this.desiredFor(element);
|
|
95
|
+
if (this.active && this.active !== element) this.write(this.active, "-1");
|
|
96
|
+
this.active = element;
|
|
97
|
+
this.write(element, desired);
|
|
98
|
+
}
|
|
99
|
+
forgetDetached(live) {
|
|
100
|
+
if (this.originals.size <= live) return;
|
|
101
|
+
for (const element of this.originals.keys()) {
|
|
102
|
+
if (!element.isConnected) this.originals.delete(element);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
authoredTabStop(items) {
|
|
106
|
+
for (let i = 0; i < items.length; i++) {
|
|
107
|
+
const item = items[i];
|
|
108
|
+
const authored = this.originals.has(item) ? this.originals.get(item) : item.getAttribute("tabindex");
|
|
109
|
+
if (authored === "0") return item;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
apply(element) {
|
|
114
|
+
if (this.disabled) return;
|
|
115
|
+
this.active = element;
|
|
116
|
+
if (element) this.write(element, this.desiredFor(element));
|
|
117
|
+
}
|
|
118
|
+
desiredFor(element) {
|
|
119
|
+
if (this.respectNegative) {
|
|
120
|
+
const authored = this.originals.has(element) ? this.originals.get(element) : element.getAttribute("tabindex");
|
|
121
|
+
if (authored === "-1") return "-1";
|
|
122
|
+
}
|
|
123
|
+
return "0";
|
|
124
|
+
}
|
|
125
|
+
write(element, value) {
|
|
126
|
+
if (this.current.get(element) === value) return;
|
|
127
|
+
if (!this.originals.has(element)) this.originals.set(element, element.getAttribute("tabindex"));
|
|
128
|
+
element.setAttribute("tabindex", value);
|
|
129
|
+
this.current.set(element, value);
|
|
130
|
+
}
|
|
131
|
+
restore() {
|
|
132
|
+
for (const [element, value] of this.originals) {
|
|
133
|
+
if (value === null) element.removeAttribute("tabindex");
|
|
134
|
+
else element.setAttribute("tabindex", value);
|
|
135
|
+
this.current.delete(element);
|
|
136
|
+
}
|
|
137
|
+
this.originals.clear();
|
|
138
|
+
this.active = null;
|
|
139
|
+
}
|
|
140
|
+
get touched() {
|
|
141
|
+
return this.originals.size;
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// src/focus/focus-manager.ts
|
|
146
|
+
var FocusManager = class {
|
|
147
|
+
constructor(options = {}) {
|
|
148
|
+
this.items = [];
|
|
149
|
+
this.activeElement = null;
|
|
150
|
+
this.activeIndex = -1;
|
|
151
|
+
this.outsideElement = null;
|
|
152
|
+
this.lastInsideElement = null;
|
|
153
|
+
this.lastKnownIndex = 0;
|
|
154
|
+
this.cleared = false;
|
|
155
|
+
this.started = false;
|
|
156
|
+
this.container = null;
|
|
157
|
+
this.markedOption = null;
|
|
158
|
+
this.options = options;
|
|
159
|
+
this.virtual = options.virtual === true;
|
|
160
|
+
const roving = options.roving;
|
|
161
|
+
this.rovingEnabled = roving !== false && (typeof roving !== "object" || roving.enabled !== false);
|
|
162
|
+
this.roving = new RovingTabindex({
|
|
163
|
+
disabled: !this.rovingEnabled,
|
|
164
|
+
respectNegative: typeof roving === "object" ? roving.force !== true : true
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
get element() {
|
|
168
|
+
return this.activeElement;
|
|
169
|
+
}
|
|
170
|
+
get index() {
|
|
171
|
+
return this.activeIndex;
|
|
172
|
+
}
|
|
173
|
+
get focusedIndex() {
|
|
174
|
+
if (this.activeIndex < 0) return -1;
|
|
175
|
+
if (this.virtual) return this.activeIndex;
|
|
176
|
+
if (typeof document === "undefined") return this.activeIndex;
|
|
177
|
+
const active = document.activeElement;
|
|
178
|
+
const current = this.activeElement;
|
|
179
|
+
if (!current) return -1;
|
|
180
|
+
if (active === current) return this.activeIndex;
|
|
181
|
+
if (active && contains(current, active)) return this.activeIndex;
|
|
182
|
+
return -1;
|
|
183
|
+
}
|
|
184
|
+
get previousElement() {
|
|
185
|
+
return this.outsideElement;
|
|
186
|
+
}
|
|
187
|
+
get lastFocused() {
|
|
188
|
+
return this.lastInsideElement;
|
|
189
|
+
}
|
|
190
|
+
sync(items, container) {
|
|
191
|
+
const previous = this.activeElement;
|
|
192
|
+
if (this.activeIndex >= 0) this.lastKnownIndex = this.activeIndex;
|
|
193
|
+
this.items = items;
|
|
194
|
+
if (container !== void 0) this.container = container;
|
|
195
|
+
if (previous) {
|
|
196
|
+
const index = items.indexOf(previous);
|
|
197
|
+
if (index !== -1 && this.isUsable(previous)) {
|
|
198
|
+
this.activeIndex = index;
|
|
199
|
+
this.promote(previous, items);
|
|
200
|
+
return index;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
const fromDocument = previous || !this.cleared ? this.readActiveFromDocument(container) : -1;
|
|
204
|
+
if (fromDocument >= 0) {
|
|
205
|
+
const element = items[fromDocument];
|
|
206
|
+
this.activeElement = element;
|
|
207
|
+
this.activeIndex = fromDocument;
|
|
208
|
+
this.lastInsideElement = element;
|
|
209
|
+
this.lastKnownIndex = fromDocument;
|
|
210
|
+
this.promote(element, items);
|
|
211
|
+
return fromDocument;
|
|
212
|
+
}
|
|
213
|
+
this.activeElement = null;
|
|
214
|
+
this.activeIndex = -1;
|
|
215
|
+
let candidate = null;
|
|
216
|
+
if (previous && items.length > 0) {
|
|
217
|
+
const previousIndex = this.lastKnownIndex;
|
|
218
|
+
candidate = items[Math.min(previousIndex, items.length - 1)] ?? items[0] ?? null;
|
|
219
|
+
} else if (!this.started && items.length > 0) {
|
|
220
|
+
candidate = this.roving.authoredTabStop(items) ?? items[0] ?? null;
|
|
221
|
+
const index = candidate ? items.indexOf(candidate) : -1;
|
|
222
|
+
if (index > 0 && candidate && this.isUsable(candidate)) {
|
|
223
|
+
this.activeElement = candidate;
|
|
224
|
+
this.activeIndex = index;
|
|
225
|
+
this.lastInsideElement = candidate;
|
|
226
|
+
this.lastKnownIndex = index;
|
|
227
|
+
}
|
|
228
|
+
} else {
|
|
229
|
+
candidate = items[0] ?? null;
|
|
230
|
+
}
|
|
231
|
+
this.started = true;
|
|
232
|
+
this.promote(candidate, items);
|
|
233
|
+
return this.activeIndex;
|
|
234
|
+
}
|
|
235
|
+
promote(element, items) {
|
|
236
|
+
this.roving.sync(this.virtual ? null : element, items);
|
|
237
|
+
this.writeActiveDescendant(this.virtual ? element : null);
|
|
238
|
+
}
|
|
239
|
+
writeActiveDescendant(element) {
|
|
240
|
+
if (!this.virtual) return;
|
|
241
|
+
this.markOption(element);
|
|
242
|
+
const owner = this.options.descendantOwner?.() ?? null;
|
|
243
|
+
if (!owner) return;
|
|
244
|
+
if (!element) {
|
|
245
|
+
if (owner.hasAttribute("aria-activedescendant")) owner.removeAttribute("aria-activedescendant");
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const id = ensureId(element, "keystra-item");
|
|
249
|
+
if (owner.getAttribute("aria-activedescendant") !== id) {
|
|
250
|
+
owner.setAttribute("aria-activedescendant", id);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
markOption(element) {
|
|
254
|
+
if (this.markedOption === element) return;
|
|
255
|
+
if (this.markedOption) this.markedOption.setAttribute("aria-selected", "false");
|
|
256
|
+
this.markedOption = element?.getAttribute("role") === "option" ? element : null;
|
|
257
|
+
if (this.markedOption) this.markedOption.setAttribute("aria-selected", "true");
|
|
258
|
+
}
|
|
259
|
+
observe(element, container) {
|
|
260
|
+
if (!element) return;
|
|
261
|
+
if (container && !contains(container, element)) return;
|
|
262
|
+
const index = this.items.indexOf(element);
|
|
263
|
+
if (index === -1) return;
|
|
264
|
+
const item = this.items[index];
|
|
265
|
+
this.activeElement = item;
|
|
266
|
+
this.activeIndex = index;
|
|
267
|
+
this.lastInsideElement = item;
|
|
268
|
+
this.lastKnownIndex = index;
|
|
269
|
+
if (!this.virtual) this.roving.apply(item);
|
|
270
|
+
this.writeActiveDescendant(item);
|
|
271
|
+
}
|
|
272
|
+
focusIndex(index, action = null, preventScroll, moveFocus = true) {
|
|
273
|
+
const items = this.items;
|
|
274
|
+
if (index < 0 || index >= items.length) return null;
|
|
275
|
+
const element = items[index];
|
|
276
|
+
if (!this.isUsable(element)) return null;
|
|
277
|
+
const previous = this.activeElement;
|
|
278
|
+
if (previous && previous !== element) {
|
|
279
|
+
const previousIndex = items.indexOf(previous);
|
|
280
|
+
if (previousIndex !== -1) this.options.onBlur?.(previous, previousIndex);
|
|
281
|
+
}
|
|
282
|
+
this.captureOutside(previous);
|
|
283
|
+
this.activeElement = element;
|
|
284
|
+
this.activeIndex = index;
|
|
285
|
+
this.cleared = false;
|
|
286
|
+
this.lastInsideElement = element;
|
|
287
|
+
this.lastKnownIndex = index;
|
|
288
|
+
if (this.virtual) this.writeActiveDescendant(element);
|
|
289
|
+
else this.roving.move(element);
|
|
290
|
+
if (moveFocus && !this.virtual) {
|
|
291
|
+
focusElement(element, preventScroll ?? this.options.preventScroll !== false);
|
|
292
|
+
}
|
|
293
|
+
this.options.onFocus?.(element, index, action);
|
|
294
|
+
return element;
|
|
295
|
+
}
|
|
296
|
+
setActiveIndex(index) {
|
|
297
|
+
const element = index >= 0 ? this.items[index] ?? null : null;
|
|
298
|
+
this.activeElement = element;
|
|
299
|
+
this.activeIndex = element ? index : -1;
|
|
300
|
+
if (element) {
|
|
301
|
+
this.cleared = false;
|
|
302
|
+
this.lastInsideElement = element;
|
|
303
|
+
this.lastKnownIndex = index;
|
|
304
|
+
} else {
|
|
305
|
+
this.cleared = index < 0;
|
|
306
|
+
}
|
|
307
|
+
this.promote(element ?? this.items[0] ?? null, this.items);
|
|
308
|
+
}
|
|
309
|
+
focusElement(element, action = null) {
|
|
310
|
+
if (!element) return false;
|
|
311
|
+
const index = this.items.indexOf(element);
|
|
312
|
+
if (index === -1) return false;
|
|
313
|
+
return this.focusIndex(index, action) !== null;
|
|
314
|
+
}
|
|
315
|
+
restore() {
|
|
316
|
+
const target = this.outsideElement;
|
|
317
|
+
if (target && typeof target.focus === "function" && !isHidden(target) && !isDisabled(target)) {
|
|
318
|
+
focusElement(target, this.options.preventScroll !== false);
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
if (this.virtual) return false;
|
|
322
|
+
if (this.lastInsideElement && this.items.indexOf(this.lastInsideElement) !== -1) {
|
|
323
|
+
return this.focusElement(this.lastInsideElement);
|
|
324
|
+
}
|
|
325
|
+
return this.focusIndex(this.activeIndex) !== null;
|
|
326
|
+
}
|
|
327
|
+
remember(element) {
|
|
328
|
+
if (element) this.outsideElement = element;
|
|
329
|
+
}
|
|
330
|
+
clear() {
|
|
331
|
+
this.activeElement = null;
|
|
332
|
+
this.activeIndex = -1;
|
|
333
|
+
this.items = [];
|
|
334
|
+
this.lastInsideElement = null;
|
|
335
|
+
this.lastKnownIndex = 0;
|
|
336
|
+
}
|
|
337
|
+
dispose() {
|
|
338
|
+
this.writeActiveDescendant(null);
|
|
339
|
+
this.roving.restore();
|
|
340
|
+
this.clear();
|
|
341
|
+
this.outsideElement = null;
|
|
342
|
+
}
|
|
343
|
+
isUsable(element) {
|
|
344
|
+
if (!element) return false;
|
|
345
|
+
if (isDisabled(element, this.options.disabledSelector ?? null)) return false;
|
|
346
|
+
if (this.options.skipHidden !== false && isHidden(element)) return false;
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
captureOutside(current) {
|
|
350
|
+
if (typeof document === "undefined") return;
|
|
351
|
+
const active = document.activeElement;
|
|
352
|
+
if (!active || active === document.body || active === document.documentElement) return;
|
|
353
|
+
if (current && active === current) return;
|
|
354
|
+
if (this.items.indexOf(active) !== -1) return;
|
|
355
|
+
if (this.container && contains(this.container, active)) return;
|
|
356
|
+
this.outsideElement = active;
|
|
357
|
+
}
|
|
358
|
+
readActiveFromDocument(container) {
|
|
359
|
+
if (typeof document === "undefined") return -1;
|
|
360
|
+
const active = document.activeElement;
|
|
361
|
+
if (!active || active === document.body) return -1;
|
|
362
|
+
const index = this.items.indexOf(active);
|
|
363
|
+
if (index !== -1) return index;
|
|
364
|
+
if (container) {
|
|
365
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
366
|
+
if (contains(this.items[i], active)) return i;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return -1;
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
exports.FocusManager = FocusManager;
|
|
374
|
+
exports.RovingTabindex = RovingTabindex;
|
package/dist/focus.d.cts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z as RovingOptions, K as KeyAction } from './index-IZkcWAXP.cjs';
|
|
2
|
+
|
|
3
|
+
interface RovingTabindexOptions {
|
|
4
|
+
readonly respectNegative?: boolean;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare class RovingTabindex<T extends Element = HTMLElement> {
|
|
8
|
+
private readonly current;
|
|
9
|
+
private readonly originals;
|
|
10
|
+
private active;
|
|
11
|
+
private readonly respectNegative;
|
|
12
|
+
private readonly disabled;
|
|
13
|
+
constructor(options?: RovingTabindexOptions);
|
|
14
|
+
get activeElement(): T | null;
|
|
15
|
+
sync(element: T | null, others: readonly T[]): void;
|
|
16
|
+
move(element: T): void;
|
|
17
|
+
private forgetDetached;
|
|
18
|
+
authoredTabStop(items: readonly T[]): T | null;
|
|
19
|
+
apply(element: T | null): void;
|
|
20
|
+
private desiredFor;
|
|
21
|
+
private write;
|
|
22
|
+
restore(): void;
|
|
23
|
+
get touched(): number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface FocusManagerOptions<T extends Element = HTMLElement> {
|
|
27
|
+
readonly roving?: boolean | RovingOptions;
|
|
28
|
+
readonly preventScroll?: boolean;
|
|
29
|
+
readonly disabledSelector?: string | null;
|
|
30
|
+
readonly skipHidden?: boolean;
|
|
31
|
+
readonly onFocus?: (element: T, index: number, action: KeyAction | null) => void;
|
|
32
|
+
readonly onBlur?: (element: T, index: number) => void;
|
|
33
|
+
readonly virtual?: boolean;
|
|
34
|
+
readonly descendantOwner?: (() => Element | null) | null;
|
|
35
|
+
}
|
|
36
|
+
declare class FocusManager<T extends Element = HTMLElement> {
|
|
37
|
+
readonly roving: RovingTabindex<T>;
|
|
38
|
+
private items;
|
|
39
|
+
private activeElement;
|
|
40
|
+
private activeIndex;
|
|
41
|
+
private outsideElement;
|
|
42
|
+
private lastInsideElement;
|
|
43
|
+
private lastKnownIndex;
|
|
44
|
+
private cleared;
|
|
45
|
+
private started;
|
|
46
|
+
private readonly rovingEnabled;
|
|
47
|
+
private readonly options;
|
|
48
|
+
private readonly virtual;
|
|
49
|
+
private container;
|
|
50
|
+
private markedOption;
|
|
51
|
+
constructor(options?: FocusManagerOptions<T>);
|
|
52
|
+
get element(): T | null;
|
|
53
|
+
get index(): number;
|
|
54
|
+
get focusedIndex(): number;
|
|
55
|
+
get previousElement(): HTMLElement | null;
|
|
56
|
+
get lastFocused(): T | null;
|
|
57
|
+
sync(items: readonly T[], container?: Element | null): number;
|
|
58
|
+
private promote;
|
|
59
|
+
private writeActiveDescendant;
|
|
60
|
+
private markOption;
|
|
61
|
+
observe(element: Element | null, container: Element | null): void;
|
|
62
|
+
focusIndex(index: number, action?: KeyAction | null, preventScroll?: boolean, moveFocus?: boolean): T | null;
|
|
63
|
+
setActiveIndex(index: number): void;
|
|
64
|
+
focusElement(element: T | null, action?: KeyAction | null): boolean;
|
|
65
|
+
restore(): boolean;
|
|
66
|
+
remember(element: HTMLElement | null): void;
|
|
67
|
+
clear(): void;
|
|
68
|
+
dispose(): void;
|
|
69
|
+
private isUsable;
|
|
70
|
+
private captureOutside;
|
|
71
|
+
private readActiveFromDocument;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { FocusManager, type FocusManagerOptions, RovingTabindex, type RovingTabindexOptions };
|
package/dist/focus.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { z as RovingOptions, K as KeyAction } from './index-IZkcWAXP.js';
|
|
2
|
+
|
|
3
|
+
interface RovingTabindexOptions {
|
|
4
|
+
readonly respectNegative?: boolean;
|
|
5
|
+
readonly disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare class RovingTabindex<T extends Element = HTMLElement> {
|
|
8
|
+
private readonly current;
|
|
9
|
+
private readonly originals;
|
|
10
|
+
private active;
|
|
11
|
+
private readonly respectNegative;
|
|
12
|
+
private readonly disabled;
|
|
13
|
+
constructor(options?: RovingTabindexOptions);
|
|
14
|
+
get activeElement(): T | null;
|
|
15
|
+
sync(element: T | null, others: readonly T[]): void;
|
|
16
|
+
move(element: T): void;
|
|
17
|
+
private forgetDetached;
|
|
18
|
+
authoredTabStop(items: readonly T[]): T | null;
|
|
19
|
+
apply(element: T | null): void;
|
|
20
|
+
private desiredFor;
|
|
21
|
+
private write;
|
|
22
|
+
restore(): void;
|
|
23
|
+
get touched(): number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface FocusManagerOptions<T extends Element = HTMLElement> {
|
|
27
|
+
readonly roving?: boolean | RovingOptions;
|
|
28
|
+
readonly preventScroll?: boolean;
|
|
29
|
+
readonly disabledSelector?: string | null;
|
|
30
|
+
readonly skipHidden?: boolean;
|
|
31
|
+
readonly onFocus?: (element: T, index: number, action: KeyAction | null) => void;
|
|
32
|
+
readonly onBlur?: (element: T, index: number) => void;
|
|
33
|
+
readonly virtual?: boolean;
|
|
34
|
+
readonly descendantOwner?: (() => Element | null) | null;
|
|
35
|
+
}
|
|
36
|
+
declare class FocusManager<T extends Element = HTMLElement> {
|
|
37
|
+
readonly roving: RovingTabindex<T>;
|
|
38
|
+
private items;
|
|
39
|
+
private activeElement;
|
|
40
|
+
private activeIndex;
|
|
41
|
+
private outsideElement;
|
|
42
|
+
private lastInsideElement;
|
|
43
|
+
private lastKnownIndex;
|
|
44
|
+
private cleared;
|
|
45
|
+
private started;
|
|
46
|
+
private readonly rovingEnabled;
|
|
47
|
+
private readonly options;
|
|
48
|
+
private readonly virtual;
|
|
49
|
+
private container;
|
|
50
|
+
private markedOption;
|
|
51
|
+
constructor(options?: FocusManagerOptions<T>);
|
|
52
|
+
get element(): T | null;
|
|
53
|
+
get index(): number;
|
|
54
|
+
get focusedIndex(): number;
|
|
55
|
+
get previousElement(): HTMLElement | null;
|
|
56
|
+
get lastFocused(): T | null;
|
|
57
|
+
sync(items: readonly T[], container?: Element | null): number;
|
|
58
|
+
private promote;
|
|
59
|
+
private writeActiveDescendant;
|
|
60
|
+
private markOption;
|
|
61
|
+
observe(element: Element | null, container: Element | null): void;
|
|
62
|
+
focusIndex(index: number, action?: KeyAction | null, preventScroll?: boolean, moveFocus?: boolean): T | null;
|
|
63
|
+
setActiveIndex(index: number): void;
|
|
64
|
+
focusElement(element: T | null, action?: KeyAction | null): boolean;
|
|
65
|
+
restore(): boolean;
|
|
66
|
+
remember(element: HTMLElement | null): void;
|
|
67
|
+
clear(): void;
|
|
68
|
+
dispose(): void;
|
|
69
|
+
private isUsable;
|
|
70
|
+
private captureOutside;
|
|
71
|
+
private readActiveFromDocument;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { FocusManager, type FocusManagerOptions, RovingTabindex, type RovingTabindexOptions };
|
package/dist/focus.js
ADDED