keyborg 1.0.7 → 1.1.0-alpha.3
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 +66 -0
- package/dist/FocusEvent.d.ts +0 -4
- package/dist/Keyborg.d.ts +1 -1
- package/dist/WeakRefInstance.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +498 -5
- package/dist/{keyborg.cjs.development.js.map → index.js.map} +1 -1
- package/dist/keyborg.esm.js +125 -133
- package/dist/keyborg.esm.js.map +1 -1
- package/package.json +35 -13
- package/dist/keyborg.cjs.development.js +0 -506
- package/dist/keyborg.cjs.production.min.js +0 -2
- package/dist/keyborg.cjs.production.min.js.map +0 -1
package/dist/keyborg.esm.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
// IE11 compat, checks if WeakRef is supported
|
|
6
|
-
|
|
6
|
+
const _canUseWeakRef = typeof WeakRef !== "undefined";
|
|
7
7
|
/**
|
|
8
8
|
* WeakRef wrapper around a HTMLElement that also supports IE11
|
|
9
9
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef}
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (_canUseWeakRef) {
|
|
13
|
+
class WeakRefInstance {
|
|
14
|
+
constructor(instance) {
|
|
15
|
+
if (_canUseWeakRef && typeof instance === "object") {
|
|
16
16
|
this._weakRef = new WeakRef(instance);
|
|
17
17
|
} else {
|
|
18
18
|
this._instance = instance;
|
|
@@ -23,10 +23,10 @@ var WeakRefInstance = /*#__PURE__*/function () {
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
deref() {
|
|
27
27
|
var _a, _b, _c;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
let instance;
|
|
30
30
|
|
|
31
31
|
if (this._weakRef) {
|
|
32
32
|
instance = (_a = this._weakRef) === null || _a === void 0 ? void 0 : _a.deref();
|
|
@@ -43,43 +43,38 @@ var WeakRefInstance = /*#__PURE__*/function () {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
return instance;
|
|
46
|
-
}
|
|
46
|
+
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
}();
|
|
48
|
+
}
|
|
50
49
|
|
|
51
50
|
/*!
|
|
52
51
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
53
52
|
* Licensed under the MIT License.
|
|
54
53
|
*/
|
|
55
|
-
|
|
54
|
+
const KEYBORG_FOCUSIN = "keyborg:focusin";
|
|
56
55
|
|
|
57
56
|
function canOverrideNativeFocus(win) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const HTMLElement = win.HTMLElement;
|
|
58
|
+
const origFocus = HTMLElement.prototype.focus;
|
|
59
|
+
let isCustomFocusCalled = false;
|
|
61
60
|
|
|
62
61
|
HTMLElement.prototype.focus = function focus() {
|
|
63
62
|
isCustomFocusCalled = true;
|
|
64
63
|
};
|
|
65
64
|
|
|
66
|
-
|
|
65
|
+
const btn = win.document.createElement("button");
|
|
67
66
|
btn.focus();
|
|
68
67
|
HTMLElement.prototype.focus = origFocus;
|
|
69
68
|
return isCustomFocusCalled;
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
let _canOverrideNativeFocus = false;
|
|
73
72
|
/**
|
|
74
73
|
* Guarantees that the native `focus` will be used
|
|
75
|
-
* Use this when trying to simulate a native keyboard focus since it does not
|
|
76
|
-
* the programmatic focus flag.
|
|
77
|
-
*
|
|
78
|
-
* ⚠️⚠️ This focus will always activate the keyboard navigation state.
|
|
79
74
|
*/
|
|
80
75
|
|
|
81
76
|
function nativeFocus(element) {
|
|
82
|
-
|
|
77
|
+
const focus = element.focus;
|
|
83
78
|
|
|
84
79
|
if (focus.__keyborgNativeFocus) {
|
|
85
80
|
focus.__keyborgNativeFocus.call(element);
|
|
@@ -92,13 +87,13 @@ function nativeFocus(element) {
|
|
|
92
87
|
*/
|
|
93
88
|
|
|
94
89
|
function setupFocusEvent(win) {
|
|
95
|
-
|
|
90
|
+
const kwin = win;
|
|
96
91
|
|
|
97
92
|
if (!_canOverrideNativeFocus) {
|
|
98
93
|
_canOverrideNativeFocus = canOverrideNativeFocus(kwin);
|
|
99
94
|
}
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
const origFocus = kwin.HTMLElement.prototype.focus;
|
|
102
97
|
|
|
103
98
|
if (origFocus.__keyborgNativeFocus) {
|
|
104
99
|
// Already set up.
|
|
@@ -106,19 +101,19 @@ function setupFocusEvent(win) {
|
|
|
106
101
|
}
|
|
107
102
|
|
|
108
103
|
kwin.HTMLElement.prototype.focus = focus;
|
|
109
|
-
|
|
110
|
-
focusInHandler:
|
|
104
|
+
const data = kwin.__keyborgData = {
|
|
105
|
+
focusInHandler: e => {
|
|
111
106
|
var _a;
|
|
112
107
|
|
|
113
|
-
|
|
108
|
+
const target = e.target;
|
|
114
109
|
|
|
115
110
|
if (!target) {
|
|
116
111
|
return;
|
|
117
112
|
}
|
|
118
113
|
|
|
119
|
-
|
|
114
|
+
const event = document.createEvent("HTMLEvents");
|
|
120
115
|
event.initEvent(KEYBORG_FOCUSIN, true, true);
|
|
121
|
-
|
|
116
|
+
const details = {
|
|
122
117
|
relatedTarget: e.relatedTarget || undefined
|
|
123
118
|
};
|
|
124
119
|
|
|
@@ -131,14 +126,15 @@ function setupFocusEvent(win) {
|
|
|
131
126
|
target.dispatchEvent(event);
|
|
132
127
|
}
|
|
133
128
|
};
|
|
134
|
-
kwin.document.addEventListener(
|
|
129
|
+
kwin.document.addEventListener("focusin", kwin.__keyborgData.focusInHandler, true);
|
|
135
130
|
|
|
136
131
|
function focus() {
|
|
137
|
-
|
|
132
|
+
const keyborgNativeFocusEvent = kwin.__keyborgData;
|
|
138
133
|
|
|
139
134
|
if (keyborgNativeFocusEvent) {
|
|
140
135
|
keyborgNativeFocusEvent.lastFocusedProgrammatically = new WeakRefInstance(this);
|
|
141
|
-
}
|
|
136
|
+
} // eslint-disable-next-line prefer-rest-params
|
|
137
|
+
|
|
142
138
|
|
|
143
139
|
return origFocus.apply(this, arguments);
|
|
144
140
|
}
|
|
@@ -151,13 +147,13 @@ function setupFocusEvent(win) {
|
|
|
151
147
|
*/
|
|
152
148
|
|
|
153
149
|
function disposeFocusEvent(win) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
const kwin = win;
|
|
151
|
+
const proto = kwin.HTMLElement.prototype;
|
|
152
|
+
const origFocus = proto.focus.__keyborgNativeFocus;
|
|
153
|
+
const keyborgNativeFocusEvent = kwin.__keyborgData;
|
|
158
154
|
|
|
159
155
|
if (keyborgNativeFocusEvent) {
|
|
160
|
-
kwin.document.removeEventListener(
|
|
156
|
+
kwin.document.removeEventListener("focusin", keyborgNativeFocusEvent.focusInHandler, true);
|
|
161
157
|
delete kwin.__keyborgData;
|
|
162
158
|
}
|
|
163
159
|
|
|
@@ -173,7 +169,7 @@ function disposeFocusEvent(win) {
|
|
|
173
169
|
function getLastFocusedProgrammatically(win) {
|
|
174
170
|
var _a;
|
|
175
171
|
|
|
176
|
-
|
|
172
|
+
const keyborgNativeFocusEvent = win.__keyborgData;
|
|
177
173
|
return keyborgNativeFocusEvent ? ((_a = keyborgNativeFocusEvent.lastFocusedProgrammatically) === null || _a === void 0 ? void 0 : _a.deref()) || null : undefined;
|
|
178
174
|
}
|
|
179
175
|
|
|
@@ -181,50 +177,49 @@ function getLastFocusedProgrammatically(win) {
|
|
|
181
177
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
182
178
|
* Licensed under the MIT License.
|
|
183
179
|
*/
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
const KeyTab = 9;
|
|
181
|
+
const KeyEsc = 27;
|
|
182
|
+
const _dismissTimeout = 500; // When Esc is pressed and the focused is not moved
|
|
187
183
|
// during _dismissTimeout time, dismiss the keyboard
|
|
188
184
|
// navigation mode.
|
|
189
185
|
|
|
190
|
-
|
|
186
|
+
let _lastId = 0;
|
|
191
187
|
/**
|
|
192
188
|
* Source of truth for all the keyborg core instances and the current keyboard navigation state
|
|
193
189
|
*/
|
|
194
190
|
|
|
195
|
-
|
|
196
|
-
|
|
191
|
+
class KeyborgState {
|
|
192
|
+
constructor() {
|
|
197
193
|
this.__keyborgCoreRefs = {};
|
|
198
194
|
this._isNavigatingWithKeyboard = false;
|
|
199
195
|
}
|
|
200
196
|
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
add(keyborg) {
|
|
198
|
+
const id = keyborg.id;
|
|
203
199
|
|
|
204
200
|
if (!(id in this.__keyborgCoreRefs)) {
|
|
205
201
|
this.__keyborgCoreRefs[id] = new WeakRefInstance(keyborg);
|
|
206
202
|
}
|
|
207
|
-
}
|
|
203
|
+
}
|
|
208
204
|
|
|
209
|
-
|
|
205
|
+
remove(id) {
|
|
210
206
|
delete this.__keyborgCoreRefs[id];
|
|
211
207
|
|
|
212
208
|
if (Object.keys(this.__keyborgCoreRefs).length === 0) {
|
|
213
209
|
this._isNavigatingWithKeyboard = false;
|
|
214
210
|
}
|
|
215
|
-
}
|
|
211
|
+
}
|
|
216
212
|
|
|
217
|
-
|
|
213
|
+
setVal(isNavigatingWithKeyboard) {
|
|
218
214
|
if (this._isNavigatingWithKeyboard === isNavigatingWithKeyboard) {
|
|
219
215
|
return;
|
|
220
216
|
}
|
|
221
217
|
|
|
222
218
|
this._isNavigatingWithKeyboard = isNavigatingWithKeyboard;
|
|
223
219
|
|
|
224
|
-
for (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var keyborg = ref.deref();
|
|
220
|
+
for (const id of Object.keys(this.__keyborgCoreRefs)) {
|
|
221
|
+
const ref = this.__keyborgCoreRefs[id];
|
|
222
|
+
const keyborg = ref.deref();
|
|
228
223
|
|
|
229
224
|
if (keyborg) {
|
|
230
225
|
keyborg.update(isNavigatingWithKeyboard);
|
|
@@ -232,30 +227,27 @@ var KeyborgState = /*#__PURE__*/function () {
|
|
|
232
227
|
this.remove(id);
|
|
233
228
|
}
|
|
234
229
|
}
|
|
235
|
-
}
|
|
230
|
+
}
|
|
236
231
|
|
|
237
|
-
|
|
232
|
+
getVal() {
|
|
238
233
|
return this._isNavigatingWithKeyboard;
|
|
239
|
-
}
|
|
234
|
+
}
|
|
240
235
|
|
|
241
|
-
|
|
242
|
-
}();
|
|
236
|
+
}
|
|
243
237
|
|
|
244
|
-
|
|
238
|
+
const _state = /*#__PURE__*/new KeyborgState();
|
|
245
239
|
/**
|
|
246
240
|
* Manages a collection of Keyborg instances in a window/document and updates keyborg state
|
|
247
241
|
*/
|
|
248
242
|
|
|
249
243
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
var _this = this;
|
|
253
|
-
|
|
244
|
+
class KeyborgCore {
|
|
245
|
+
constructor(win) {
|
|
254
246
|
this._isMouseUsed = false;
|
|
255
247
|
|
|
256
|
-
this._onFocusIn =
|
|
257
|
-
if (
|
|
258
|
-
|
|
248
|
+
this._onFocusIn = e => {
|
|
249
|
+
if (this._isMouseUsed) {
|
|
250
|
+
this._isMouseUsed = false;
|
|
259
251
|
return;
|
|
260
252
|
}
|
|
261
253
|
|
|
@@ -263,7 +255,7 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
263
255
|
return;
|
|
264
256
|
}
|
|
265
257
|
|
|
266
|
-
|
|
258
|
+
const details = e.details;
|
|
267
259
|
|
|
268
260
|
if (!details.relatedTarget) {
|
|
269
261
|
return;
|
|
@@ -278,44 +270,44 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
278
270
|
_state.setVal(true);
|
|
279
271
|
};
|
|
280
272
|
|
|
281
|
-
this._onMouseDown =
|
|
273
|
+
this._onMouseDown = e => {
|
|
282
274
|
if (e.buttons === 0 || e.clientX === 0 && e.clientY === 0 && e.screenX === 0 && e.screenY === 0) {
|
|
283
275
|
// This is most likely an event triggered by the screen reader to perform
|
|
284
276
|
// an action on an element, do not dismiss the keyboard navigation mode.
|
|
285
277
|
return;
|
|
286
278
|
}
|
|
287
279
|
|
|
288
|
-
|
|
280
|
+
this._isMouseUsed = true;
|
|
289
281
|
|
|
290
282
|
_state.setVal(false);
|
|
291
283
|
};
|
|
292
284
|
|
|
293
|
-
this._onKeyDown =
|
|
294
|
-
|
|
285
|
+
this._onKeyDown = e => {
|
|
286
|
+
const isNavigatingWithKeyboard = _state.getVal();
|
|
295
287
|
|
|
296
288
|
if (!isNavigatingWithKeyboard && e.keyCode === KeyTab) {
|
|
297
289
|
_state.setVal(true);
|
|
298
290
|
} else if (isNavigatingWithKeyboard && e.keyCode === KeyEsc) {
|
|
299
|
-
|
|
291
|
+
this._scheduleDismiss();
|
|
300
292
|
}
|
|
301
293
|
};
|
|
302
294
|
|
|
303
|
-
this.id =
|
|
295
|
+
this.id = "c" + ++_lastId;
|
|
304
296
|
this._win = win;
|
|
305
|
-
|
|
297
|
+
const doc = win.document;
|
|
306
298
|
doc.addEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
|
|
307
299
|
|
|
308
|
-
doc.addEventListener(
|
|
300
|
+
doc.addEventListener("mousedown", this._onMouseDown, true); // Capture!
|
|
309
301
|
|
|
310
|
-
win.addEventListener(
|
|
302
|
+
win.addEventListener("keydown", this._onKeyDown, true); // Capture!
|
|
311
303
|
|
|
312
304
|
setupFocusEvent(win);
|
|
313
305
|
|
|
314
306
|
_state.add(this);
|
|
315
307
|
}
|
|
316
308
|
|
|
317
|
-
|
|
318
|
-
|
|
309
|
+
dispose() {
|
|
310
|
+
const win = this._win;
|
|
319
311
|
|
|
320
312
|
if (win) {
|
|
321
313
|
if (this._dismissTimer) {
|
|
@@ -324,44 +316,41 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
324
316
|
}
|
|
325
317
|
|
|
326
318
|
disposeFocusEvent(win);
|
|
327
|
-
|
|
319
|
+
const doc = win.document;
|
|
328
320
|
doc.removeEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
|
|
329
321
|
|
|
330
|
-
doc.removeEventListener(
|
|
322
|
+
doc.removeEventListener("mousedown", this._onMouseDown, true); // Capture!
|
|
331
323
|
|
|
332
|
-
win.removeEventListener(
|
|
324
|
+
win.removeEventListener("keydown", this._onKeyDown, true); // Capture!
|
|
333
325
|
|
|
334
326
|
delete this._win;
|
|
335
327
|
|
|
336
328
|
_state.remove(this.id);
|
|
337
329
|
}
|
|
338
|
-
}
|
|
330
|
+
}
|
|
339
331
|
|
|
340
|
-
|
|
332
|
+
isDisposed() {
|
|
341
333
|
return !!this._win;
|
|
342
|
-
}
|
|
334
|
+
}
|
|
343
335
|
/**
|
|
344
336
|
* Updates all keyborg instances with the keyboard navigation state
|
|
345
337
|
*/
|
|
346
338
|
|
|
347
339
|
|
|
348
|
-
|
|
340
|
+
update(isNavigatingWithKeyboard) {
|
|
349
341
|
var _a, _b;
|
|
350
342
|
|
|
351
|
-
|
|
343
|
+
const keyborgs = (_b = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg) === null || _b === void 0 ? void 0 : _b.refs;
|
|
352
344
|
|
|
353
345
|
if (keyborgs) {
|
|
354
|
-
for (
|
|
355
|
-
var id = _c[_i];
|
|
346
|
+
for (const id of Object.keys(keyborgs)) {
|
|
356
347
|
Keyborg.update(keyborgs[id], isNavigatingWithKeyboard);
|
|
357
348
|
}
|
|
358
349
|
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
KeyborgCore.prototype._scheduleDismiss = function () {
|
|
362
|
-
var _this = this;
|
|
350
|
+
}
|
|
363
351
|
|
|
364
|
-
|
|
352
|
+
_scheduleDismiss() {
|
|
353
|
+
const win = this._win;
|
|
365
354
|
|
|
366
355
|
if (win) {
|
|
367
356
|
if (this._dismissTimer) {
|
|
@@ -369,35 +358,32 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
369
358
|
this._dismissTimer = undefined;
|
|
370
359
|
}
|
|
371
360
|
|
|
372
|
-
|
|
373
|
-
this._dismissTimer = win.setTimeout(
|
|
374
|
-
|
|
375
|
-
|
|
361
|
+
const was = win.document.activeElement;
|
|
362
|
+
this._dismissTimer = win.setTimeout(() => {
|
|
363
|
+
this._dismissTimer = undefined;
|
|
364
|
+
const cur = win.document.activeElement;
|
|
376
365
|
|
|
377
|
-
if (
|
|
366
|
+
if (was && cur && was === cur) {
|
|
378
367
|
// Esc was pressed, currently focused element hasn't changed.
|
|
379
368
|
// Just dismiss the keyboard navigation mode.
|
|
380
369
|
_state.setVal(false);
|
|
381
370
|
}
|
|
382
371
|
}, _dismissTimeout);
|
|
383
372
|
}
|
|
384
|
-
}
|
|
373
|
+
}
|
|
385
374
|
|
|
386
|
-
|
|
387
|
-
}();
|
|
375
|
+
}
|
|
388
376
|
/**
|
|
389
377
|
* Used to determine the keyboard navigation state
|
|
390
378
|
*/
|
|
391
379
|
|
|
392
380
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
var _a;
|
|
396
|
-
|
|
381
|
+
class Keyborg {
|
|
382
|
+
constructor(win) {
|
|
397
383
|
this._cb = [];
|
|
398
|
-
this._id =
|
|
384
|
+
this._id = "k" + ++_lastId;
|
|
399
385
|
this._win = win;
|
|
400
|
-
|
|
386
|
+
const current = win.__keyborg;
|
|
401
387
|
|
|
402
388
|
if (current) {
|
|
403
389
|
this._core = current.core;
|
|
@@ -406,88 +392,88 @@ var Keyborg = /*#__PURE__*/function () {
|
|
|
406
392
|
this._core = new KeyborgCore(win);
|
|
407
393
|
win.__keyborg = {
|
|
408
394
|
core: this._core,
|
|
409
|
-
refs:
|
|
395
|
+
refs: {
|
|
396
|
+
[this._id]: this
|
|
397
|
+
}
|
|
410
398
|
};
|
|
411
399
|
}
|
|
412
400
|
}
|
|
413
401
|
|
|
414
|
-
|
|
402
|
+
static create(win) {
|
|
415
403
|
return new Keyborg(win);
|
|
416
|
-
}
|
|
404
|
+
}
|
|
417
405
|
|
|
418
|
-
|
|
406
|
+
static dispose(instance) {
|
|
419
407
|
instance.dispose();
|
|
420
|
-
}
|
|
408
|
+
}
|
|
421
409
|
/**
|
|
422
410
|
* Updates all subscribed callbacks with the keyboard navigation state
|
|
423
411
|
*/
|
|
424
412
|
|
|
425
413
|
|
|
426
|
-
|
|
427
|
-
instance._cb.forEach(
|
|
428
|
-
|
|
429
|
-
});
|
|
430
|
-
};
|
|
414
|
+
static update(instance, isNavigatingWithKeyboard) {
|
|
415
|
+
instance._cb.forEach(callback => callback(isNavigatingWithKeyboard));
|
|
416
|
+
}
|
|
431
417
|
|
|
432
|
-
|
|
418
|
+
dispose() {
|
|
433
419
|
var _a;
|
|
434
420
|
|
|
435
|
-
|
|
421
|
+
const current = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg;
|
|
436
422
|
|
|
437
423
|
if (current === null || current === void 0 ? void 0 : current.refs[this._id]) {
|
|
438
424
|
delete current.refs[this._id];
|
|
439
425
|
|
|
440
426
|
if (Object.keys(current.refs).length === 0) {
|
|
441
|
-
current.core.dispose();
|
|
427
|
+
current.core.dispose(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
428
|
+
|
|
442
429
|
delete this._win.__keyborg;
|
|
443
430
|
}
|
|
444
|
-
} else if (process.env.NODE_ENV
|
|
431
|
+
} else if (process.env.NODE_ENV === 'development') {
|
|
445
432
|
console.error("Keyborg instance " + this._id + " is being disposed incorrectly.");
|
|
446
433
|
}
|
|
447
434
|
|
|
448
435
|
this._cb = [];
|
|
449
436
|
delete this._core;
|
|
450
437
|
delete this._win;
|
|
451
|
-
}
|
|
438
|
+
}
|
|
452
439
|
/**
|
|
453
440
|
* @returns Whether the user is navigating with keyboard
|
|
454
441
|
*/
|
|
455
442
|
|
|
456
443
|
|
|
457
|
-
|
|
444
|
+
isNavigatingWithKeyboard() {
|
|
458
445
|
return _state.getVal();
|
|
459
|
-
}
|
|
446
|
+
}
|
|
460
447
|
/**
|
|
461
448
|
* @param callback - Called when the keyboard navigation state changes
|
|
462
449
|
*/
|
|
463
450
|
|
|
464
451
|
|
|
465
|
-
|
|
452
|
+
subscribe(callback) {
|
|
466
453
|
this._cb.push(callback);
|
|
467
|
-
}
|
|
454
|
+
}
|
|
468
455
|
/**
|
|
469
456
|
* @param callback - Registered with subscribe
|
|
470
457
|
*/
|
|
471
458
|
|
|
472
459
|
|
|
473
|
-
|
|
474
|
-
|
|
460
|
+
unsubscribe(callback) {
|
|
461
|
+
const index = this._cb.indexOf(callback);
|
|
475
462
|
|
|
476
463
|
if (index >= 0) {
|
|
477
464
|
this._cb.splice(index, 1);
|
|
478
465
|
}
|
|
479
|
-
}
|
|
466
|
+
}
|
|
480
467
|
/**
|
|
481
468
|
* Manually set the keyboard navigtion state
|
|
482
469
|
*/
|
|
483
470
|
|
|
484
471
|
|
|
485
|
-
|
|
472
|
+
setVal(isNavigatingWithKeyboard) {
|
|
486
473
|
_state.setVal(isNavigatingWithKeyboard);
|
|
487
|
-
}
|
|
474
|
+
}
|
|
488
475
|
|
|
489
|
-
|
|
490
|
-
}();
|
|
476
|
+
}
|
|
491
477
|
function createKeyborg(win) {
|
|
492
478
|
return Keyborg.create(win);
|
|
493
479
|
}
|
|
@@ -495,5 +481,11 @@ function disposeKeyborg(instance) {
|
|
|
495
481
|
Keyborg.dispose(instance);
|
|
496
482
|
}
|
|
497
483
|
|
|
498
|
-
|
|
484
|
+
/*!
|
|
485
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
486
|
+
* Licensed under the MIT License.
|
|
487
|
+
*/
|
|
488
|
+
const version = "1.1.0-alpha.3";
|
|
489
|
+
|
|
490
|
+
export { KEYBORG_FOCUSIN, Keyborg, createKeyborg, disposeKeyborg, getLastFocusedProgrammatically, nativeFocus, version };
|
|
499
491
|
//# sourceMappingURL=keyborg.esm.js.map
|
package/dist/keyborg.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyborg.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"keyborg.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keyborg",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-alpha.3",
|
|
4
4
|
"description": "Keyboard Navigation Detection for Web",
|
|
5
5
|
"author": "Marat Abdullin <marata@microsoft.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,22 +13,44 @@
|
|
|
13
13
|
],
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/microsoft/
|
|
16
|
+
"url": "git+https://github.com/microsoft/keyborg"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "npm run tslint && npm run clean && tsdx build",
|
|
20
19
|
"clean": "rimraf dist",
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
20
|
+
"build": "npm run clean && rollup -c",
|
|
21
|
+
"bundle-size": "npm run build && bundle-size measure",
|
|
22
|
+
"format": "prettier --check .",
|
|
23
|
+
"format:fix": "prettier --write .",
|
|
24
|
+
"lint": "eslint src/",
|
|
25
|
+
"lint:fix": "eslint src/ --fix",
|
|
26
|
+
"prepublishOnly": "npm run lint && npm run format && npm run build",
|
|
27
|
+
"release": "release-it --verbose"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
26
|
-
"
|
|
30
|
+
"@babel/core": "^7.16.0",
|
|
31
|
+
"@babel/preset-env": "^7.16.4",
|
|
32
|
+
"@babel/preset-typescript": "^7.12.7",
|
|
33
|
+
"@fluentui/bundle-size": "^1.1.3",
|
|
34
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
35
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
36
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
37
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
38
|
+
"@rollup/plugin-replace": "^3.0.0",
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^5.4.0",
|
|
40
|
+
"@typescript-eslint/parser": "^5.4.0",
|
|
41
|
+
"babel-plugin-annotate-pure-calls": "^0.4.0",
|
|
42
|
+
"ci-info": "^3.3.0",
|
|
43
|
+
"eslint": "^8.2.0",
|
|
44
|
+
"eslint-config-prettier": "^8.3.0",
|
|
45
|
+
"eslint-plugin-header": "^3.1.1",
|
|
46
|
+
"eslint-plugin-import": "^2.25.3",
|
|
47
|
+
"node-fetch": "^2.6.6",
|
|
48
|
+
"prettier": "^2.4.1",
|
|
49
|
+
"release-it": "^14.11.8",
|
|
27
50
|
"rimraf": "^3.0.2",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"typescript": "^4.2
|
|
32
|
-
}
|
|
33
|
-
"gitHead": "4cee6ea0ac8205619806c53440c76446235faed9"
|
|
51
|
+
"rollup": "^2.60.1",
|
|
52
|
+
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
53
|
+
"rollup-plugin-typescript2": "^0.31.1",
|
|
54
|
+
"typescript": "^4.5.2"
|
|
55
|
+
}
|
|
34
56
|
}
|