keyborg 1.0.0 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- 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 -129
- package/dist/keyborg.esm.js.map +1 -1
- package/package.json +35 -13
- package/dist/keyborg.cjs.development.js +0 -502
- 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,39 +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
74
|
*/
|
|
76
75
|
|
|
77
76
|
function nativeFocus(element) {
|
|
78
|
-
|
|
77
|
+
const focus = element.focus;
|
|
79
78
|
|
|
80
79
|
if (focus.__keyborgNativeFocus) {
|
|
81
80
|
focus.__keyborgNativeFocus.call(element);
|
|
@@ -88,13 +87,13 @@ function nativeFocus(element) {
|
|
|
88
87
|
*/
|
|
89
88
|
|
|
90
89
|
function setupFocusEvent(win) {
|
|
91
|
-
|
|
90
|
+
const kwin = win;
|
|
92
91
|
|
|
93
92
|
if (!_canOverrideNativeFocus) {
|
|
94
93
|
_canOverrideNativeFocus = canOverrideNativeFocus(kwin);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
|
|
96
|
+
const origFocus = kwin.HTMLElement.prototype.focus;
|
|
98
97
|
|
|
99
98
|
if (origFocus.__keyborgNativeFocus) {
|
|
100
99
|
// Already set up.
|
|
@@ -102,19 +101,19 @@ function setupFocusEvent(win) {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
kwin.HTMLElement.prototype.focus = focus;
|
|
105
|
-
|
|
106
|
-
focusInHandler:
|
|
104
|
+
const data = kwin.__keyborgData = {
|
|
105
|
+
focusInHandler: e => {
|
|
107
106
|
var _a;
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
const target = e.target;
|
|
110
109
|
|
|
111
110
|
if (!target) {
|
|
112
111
|
return;
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
const event = document.createEvent("HTMLEvents");
|
|
116
115
|
event.initEvent(KEYBORG_FOCUSIN, true, true);
|
|
117
|
-
|
|
116
|
+
const details = {
|
|
118
117
|
relatedTarget: e.relatedTarget || undefined
|
|
119
118
|
};
|
|
120
119
|
|
|
@@ -127,14 +126,15 @@ function setupFocusEvent(win) {
|
|
|
127
126
|
target.dispatchEvent(event);
|
|
128
127
|
}
|
|
129
128
|
};
|
|
130
|
-
kwin.document.addEventListener(
|
|
129
|
+
kwin.document.addEventListener("focusin", kwin.__keyborgData.focusInHandler, true);
|
|
131
130
|
|
|
132
131
|
function focus() {
|
|
133
|
-
|
|
132
|
+
const keyborgNativeFocusEvent = kwin.__keyborgData;
|
|
134
133
|
|
|
135
134
|
if (keyborgNativeFocusEvent) {
|
|
136
135
|
keyborgNativeFocusEvent.lastFocusedProgrammatically = new WeakRefInstance(this);
|
|
137
|
-
}
|
|
136
|
+
} // eslint-disable-next-line prefer-rest-params
|
|
137
|
+
|
|
138
138
|
|
|
139
139
|
return origFocus.apply(this, arguments);
|
|
140
140
|
}
|
|
@@ -147,13 +147,13 @@ function setupFocusEvent(win) {
|
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
149
|
function disposeFocusEvent(win) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
150
|
+
const kwin = win;
|
|
151
|
+
const proto = kwin.HTMLElement.prototype;
|
|
152
|
+
const origFocus = proto.focus.__keyborgNativeFocus;
|
|
153
|
+
const keyborgNativeFocusEvent = kwin.__keyborgData;
|
|
154
154
|
|
|
155
155
|
if (keyborgNativeFocusEvent) {
|
|
156
|
-
kwin.document.removeEventListener(
|
|
156
|
+
kwin.document.removeEventListener("focusin", keyborgNativeFocusEvent.focusInHandler, true);
|
|
157
157
|
delete kwin.__keyborgData;
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -169,7 +169,7 @@ function disposeFocusEvent(win) {
|
|
|
169
169
|
function getLastFocusedProgrammatically(win) {
|
|
170
170
|
var _a;
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
const keyborgNativeFocusEvent = win.__keyborgData;
|
|
173
173
|
return keyborgNativeFocusEvent ? ((_a = keyborgNativeFocusEvent.lastFocusedProgrammatically) === null || _a === void 0 ? void 0 : _a.deref()) || null : undefined;
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -177,50 +177,49 @@ function getLastFocusedProgrammatically(win) {
|
|
|
177
177
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
178
178
|
* Licensed under the MIT License.
|
|
179
179
|
*/
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
const KeyTab = 9;
|
|
181
|
+
const KeyEsc = 27;
|
|
182
|
+
const _dismissTimeout = 500; // When Esc is pressed and the focused is not moved
|
|
183
183
|
// during _dismissTimeout time, dismiss the keyboard
|
|
184
184
|
// navigation mode.
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
let _lastId = 0;
|
|
187
187
|
/**
|
|
188
188
|
* Source of truth for all the keyborg core instances and the current keyboard navigation state
|
|
189
189
|
*/
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
class KeyborgState {
|
|
192
|
+
constructor() {
|
|
193
193
|
this.__keyborgCoreRefs = {};
|
|
194
194
|
this._isNavigatingWithKeyboard = false;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
add(keyborg) {
|
|
198
|
+
const id = keyborg.id;
|
|
199
199
|
|
|
200
200
|
if (!(id in this.__keyborgCoreRefs)) {
|
|
201
201
|
this.__keyborgCoreRefs[id] = new WeakRefInstance(keyborg);
|
|
202
202
|
}
|
|
203
|
-
}
|
|
203
|
+
}
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
remove(id) {
|
|
206
206
|
delete this.__keyborgCoreRefs[id];
|
|
207
207
|
|
|
208
208
|
if (Object.keys(this.__keyborgCoreRefs).length === 0) {
|
|
209
209
|
this._isNavigatingWithKeyboard = false;
|
|
210
210
|
}
|
|
211
|
-
}
|
|
211
|
+
}
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
setVal(isNavigatingWithKeyboard) {
|
|
214
214
|
if (this._isNavigatingWithKeyboard === isNavigatingWithKeyboard) {
|
|
215
215
|
return;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
this._isNavigatingWithKeyboard = isNavigatingWithKeyboard;
|
|
219
219
|
|
|
220
|
-
for (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
var keyborg = ref.deref();
|
|
220
|
+
for (const id of Object.keys(this.__keyborgCoreRefs)) {
|
|
221
|
+
const ref = this.__keyborgCoreRefs[id];
|
|
222
|
+
const keyborg = ref.deref();
|
|
224
223
|
|
|
225
224
|
if (keyborg) {
|
|
226
225
|
keyborg.update(isNavigatingWithKeyboard);
|
|
@@ -228,30 +227,27 @@ var KeyborgState = /*#__PURE__*/function () {
|
|
|
228
227
|
this.remove(id);
|
|
229
228
|
}
|
|
230
229
|
}
|
|
231
|
-
}
|
|
230
|
+
}
|
|
232
231
|
|
|
233
|
-
|
|
232
|
+
getVal() {
|
|
234
233
|
return this._isNavigatingWithKeyboard;
|
|
235
|
-
}
|
|
234
|
+
}
|
|
236
235
|
|
|
237
|
-
|
|
238
|
-
}();
|
|
236
|
+
}
|
|
239
237
|
|
|
240
|
-
|
|
238
|
+
const _state = /*#__PURE__*/new KeyborgState();
|
|
241
239
|
/**
|
|
242
240
|
* Manages a collection of Keyborg instances in a window/document and updates keyborg state
|
|
243
241
|
*/
|
|
244
242
|
|
|
245
243
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
var _this = this;
|
|
249
|
-
|
|
244
|
+
class KeyborgCore {
|
|
245
|
+
constructor(win) {
|
|
250
246
|
this._isMouseUsed = false;
|
|
251
247
|
|
|
252
|
-
this._onFocusIn =
|
|
253
|
-
if (
|
|
254
|
-
|
|
248
|
+
this._onFocusIn = e => {
|
|
249
|
+
if (this._isMouseUsed) {
|
|
250
|
+
this._isMouseUsed = false;
|
|
255
251
|
return;
|
|
256
252
|
}
|
|
257
253
|
|
|
@@ -259,7 +255,7 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
259
255
|
return;
|
|
260
256
|
}
|
|
261
257
|
|
|
262
|
-
|
|
258
|
+
const details = e.details;
|
|
263
259
|
|
|
264
260
|
if (!details.relatedTarget) {
|
|
265
261
|
return;
|
|
@@ -274,44 +270,44 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
274
270
|
_state.setVal(true);
|
|
275
271
|
};
|
|
276
272
|
|
|
277
|
-
this._onMouseDown =
|
|
273
|
+
this._onMouseDown = e => {
|
|
278
274
|
if (e.buttons === 0 || e.clientX === 0 && e.clientY === 0 && e.screenX === 0 && e.screenY === 0) {
|
|
279
275
|
// This is most likely an event triggered by the screen reader to perform
|
|
280
276
|
// an action on an element, do not dismiss the keyboard navigation mode.
|
|
281
277
|
return;
|
|
282
278
|
}
|
|
283
279
|
|
|
284
|
-
|
|
280
|
+
this._isMouseUsed = true;
|
|
285
281
|
|
|
286
282
|
_state.setVal(false);
|
|
287
283
|
};
|
|
288
284
|
|
|
289
|
-
this._onKeyDown =
|
|
290
|
-
|
|
285
|
+
this._onKeyDown = e => {
|
|
286
|
+
const isNavigatingWithKeyboard = _state.getVal();
|
|
291
287
|
|
|
292
288
|
if (!isNavigatingWithKeyboard && e.keyCode === KeyTab) {
|
|
293
289
|
_state.setVal(true);
|
|
294
290
|
} else if (isNavigatingWithKeyboard && e.keyCode === KeyEsc) {
|
|
295
|
-
|
|
291
|
+
this._scheduleDismiss();
|
|
296
292
|
}
|
|
297
293
|
};
|
|
298
294
|
|
|
299
|
-
this.id =
|
|
295
|
+
this.id = "c" + ++_lastId;
|
|
300
296
|
this._win = win;
|
|
301
|
-
|
|
297
|
+
const doc = win.document;
|
|
302
298
|
doc.addEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
|
|
303
299
|
|
|
304
|
-
doc.addEventListener(
|
|
300
|
+
doc.addEventListener("mousedown", this._onMouseDown, true); // Capture!
|
|
305
301
|
|
|
306
|
-
win.addEventListener(
|
|
302
|
+
win.addEventListener("keydown", this._onKeyDown, true); // Capture!
|
|
307
303
|
|
|
308
304
|
setupFocusEvent(win);
|
|
309
305
|
|
|
310
306
|
_state.add(this);
|
|
311
307
|
}
|
|
312
308
|
|
|
313
|
-
|
|
314
|
-
|
|
309
|
+
dispose() {
|
|
310
|
+
const win = this._win;
|
|
315
311
|
|
|
316
312
|
if (win) {
|
|
317
313
|
if (this._dismissTimer) {
|
|
@@ -320,44 +316,41 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
320
316
|
}
|
|
321
317
|
|
|
322
318
|
disposeFocusEvent(win);
|
|
323
|
-
|
|
319
|
+
const doc = win.document;
|
|
324
320
|
doc.removeEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
|
|
325
321
|
|
|
326
|
-
doc.removeEventListener(
|
|
322
|
+
doc.removeEventListener("mousedown", this._onMouseDown, true); // Capture!
|
|
327
323
|
|
|
328
|
-
win.removeEventListener(
|
|
324
|
+
win.removeEventListener("keydown", this._onKeyDown, true); // Capture!
|
|
329
325
|
|
|
330
326
|
delete this._win;
|
|
331
327
|
|
|
332
328
|
_state.remove(this.id);
|
|
333
329
|
}
|
|
334
|
-
}
|
|
330
|
+
}
|
|
335
331
|
|
|
336
|
-
|
|
332
|
+
isDisposed() {
|
|
337
333
|
return !!this._win;
|
|
338
|
-
}
|
|
334
|
+
}
|
|
339
335
|
/**
|
|
340
336
|
* Updates all keyborg instances with the keyboard navigation state
|
|
341
337
|
*/
|
|
342
338
|
|
|
343
339
|
|
|
344
|
-
|
|
340
|
+
update(isNavigatingWithKeyboard) {
|
|
345
341
|
var _a, _b;
|
|
346
342
|
|
|
347
|
-
|
|
343
|
+
const keyborgs = (_b = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg) === null || _b === void 0 ? void 0 : _b.refs;
|
|
348
344
|
|
|
349
345
|
if (keyborgs) {
|
|
350
|
-
for (
|
|
351
|
-
var id = _c[_i];
|
|
346
|
+
for (const id of Object.keys(keyborgs)) {
|
|
352
347
|
Keyborg.update(keyborgs[id], isNavigatingWithKeyboard);
|
|
353
348
|
}
|
|
354
349
|
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
KeyborgCore.prototype._scheduleDismiss = function () {
|
|
358
|
-
var _this = this;
|
|
350
|
+
}
|
|
359
351
|
|
|
360
|
-
|
|
352
|
+
_scheduleDismiss() {
|
|
353
|
+
const win = this._win;
|
|
361
354
|
|
|
362
355
|
if (win) {
|
|
363
356
|
if (this._dismissTimer) {
|
|
@@ -365,35 +358,32 @@ var KeyborgCore = /*#__PURE__*/function () {
|
|
|
365
358
|
this._dismissTimer = undefined;
|
|
366
359
|
}
|
|
367
360
|
|
|
368
|
-
|
|
369
|
-
this._dismissTimer = win.setTimeout(
|
|
370
|
-
|
|
371
|
-
|
|
361
|
+
const was = win.document.activeElement;
|
|
362
|
+
this._dismissTimer = win.setTimeout(() => {
|
|
363
|
+
this._dismissTimer = undefined;
|
|
364
|
+
const cur = win.document.activeElement;
|
|
372
365
|
|
|
373
|
-
if (
|
|
366
|
+
if (was && cur && was === cur) {
|
|
374
367
|
// Esc was pressed, currently focused element hasn't changed.
|
|
375
368
|
// Just dismiss the keyboard navigation mode.
|
|
376
369
|
_state.setVal(false);
|
|
377
370
|
}
|
|
378
371
|
}, _dismissTimeout);
|
|
379
372
|
}
|
|
380
|
-
}
|
|
373
|
+
}
|
|
381
374
|
|
|
382
|
-
|
|
383
|
-
}();
|
|
375
|
+
}
|
|
384
376
|
/**
|
|
385
377
|
* Used to determine the keyboard navigation state
|
|
386
378
|
*/
|
|
387
379
|
|
|
388
380
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
var _a;
|
|
392
|
-
|
|
381
|
+
class Keyborg {
|
|
382
|
+
constructor(win) {
|
|
393
383
|
this._cb = [];
|
|
394
|
-
this._id =
|
|
384
|
+
this._id = "k" + ++_lastId;
|
|
395
385
|
this._win = win;
|
|
396
|
-
|
|
386
|
+
const current = win.__keyborg;
|
|
397
387
|
|
|
398
388
|
if (current) {
|
|
399
389
|
this._core = current.core;
|
|
@@ -402,88 +392,88 @@ var Keyborg = /*#__PURE__*/function () {
|
|
|
402
392
|
this._core = new KeyborgCore(win);
|
|
403
393
|
win.__keyborg = {
|
|
404
394
|
core: this._core,
|
|
405
|
-
refs:
|
|
395
|
+
refs: {
|
|
396
|
+
[this._id]: this
|
|
397
|
+
}
|
|
406
398
|
};
|
|
407
399
|
}
|
|
408
400
|
}
|
|
409
401
|
|
|
410
|
-
|
|
402
|
+
static create(win) {
|
|
411
403
|
return new Keyborg(win);
|
|
412
|
-
}
|
|
404
|
+
}
|
|
413
405
|
|
|
414
|
-
|
|
406
|
+
static dispose(instance) {
|
|
415
407
|
instance.dispose();
|
|
416
|
-
}
|
|
408
|
+
}
|
|
417
409
|
/**
|
|
418
410
|
* Updates all subscribed callbacks with the keyboard navigation state
|
|
419
411
|
*/
|
|
420
412
|
|
|
421
413
|
|
|
422
|
-
|
|
423
|
-
instance._cb.forEach(
|
|
424
|
-
|
|
425
|
-
});
|
|
426
|
-
};
|
|
414
|
+
static update(instance, isNavigatingWithKeyboard) {
|
|
415
|
+
instance._cb.forEach(callback => callback(isNavigatingWithKeyboard));
|
|
416
|
+
}
|
|
427
417
|
|
|
428
|
-
|
|
418
|
+
dispose() {
|
|
429
419
|
var _a;
|
|
430
420
|
|
|
431
|
-
|
|
421
|
+
const current = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg;
|
|
432
422
|
|
|
433
423
|
if (current === null || current === void 0 ? void 0 : current.refs[this._id]) {
|
|
434
424
|
delete current.refs[this._id];
|
|
435
425
|
|
|
436
426
|
if (Object.keys(current.refs).length === 0) {
|
|
437
|
-
current.core.dispose();
|
|
427
|
+
current.core.dispose(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
428
|
+
|
|
438
429
|
delete this._win.__keyborg;
|
|
439
430
|
}
|
|
440
|
-
} else if (process.env.NODE_ENV
|
|
431
|
+
} else if (process.env.NODE_ENV === 'development') {
|
|
441
432
|
console.error("Keyborg instance " + this._id + " is being disposed incorrectly.");
|
|
442
433
|
}
|
|
443
434
|
|
|
444
435
|
this._cb = [];
|
|
445
436
|
delete this._core;
|
|
446
437
|
delete this._win;
|
|
447
|
-
}
|
|
438
|
+
}
|
|
448
439
|
/**
|
|
449
440
|
* @returns Whether the user is navigating with keyboard
|
|
450
441
|
*/
|
|
451
442
|
|
|
452
443
|
|
|
453
|
-
|
|
444
|
+
isNavigatingWithKeyboard() {
|
|
454
445
|
return _state.getVal();
|
|
455
|
-
}
|
|
446
|
+
}
|
|
456
447
|
/**
|
|
457
448
|
* @param callback - Called when the keyboard navigation state changes
|
|
458
449
|
*/
|
|
459
450
|
|
|
460
451
|
|
|
461
|
-
|
|
452
|
+
subscribe(callback) {
|
|
462
453
|
this._cb.push(callback);
|
|
463
|
-
}
|
|
454
|
+
}
|
|
464
455
|
/**
|
|
465
456
|
* @param callback - Registered with subscribe
|
|
466
457
|
*/
|
|
467
458
|
|
|
468
459
|
|
|
469
|
-
|
|
470
|
-
|
|
460
|
+
unsubscribe(callback) {
|
|
461
|
+
const index = this._cb.indexOf(callback);
|
|
471
462
|
|
|
472
463
|
if (index >= 0) {
|
|
473
464
|
this._cb.splice(index, 1);
|
|
474
465
|
}
|
|
475
|
-
}
|
|
466
|
+
}
|
|
476
467
|
/**
|
|
477
468
|
* Manually set the keyboard navigtion state
|
|
478
469
|
*/
|
|
479
470
|
|
|
480
471
|
|
|
481
|
-
|
|
472
|
+
setVal(isNavigatingWithKeyboard) {
|
|
482
473
|
_state.setVal(isNavigatingWithKeyboard);
|
|
483
|
-
}
|
|
474
|
+
}
|
|
484
475
|
|
|
485
|
-
|
|
486
|
-
}();
|
|
476
|
+
}
|
|
487
477
|
function createKeyborg(win) {
|
|
488
478
|
return Keyborg.create(win);
|
|
489
479
|
}
|
|
@@ -491,5 +481,11 @@ function disposeKeyborg(instance) {
|
|
|
491
481
|
Keyborg.dispose(instance);
|
|
492
482
|
}
|
|
493
483
|
|
|
494
|
-
|
|
484
|
+
/*!
|
|
485
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
486
|
+
* Licensed under the MIT License.
|
|
487
|
+
*/
|
|
488
|
+
const version = "1.1.0-alpha.2";
|
|
489
|
+
|
|
490
|
+
export { KEYBORG_FOCUSIN, Keyborg, createKeyborg, disposeKeyborg, getLastFocusedProgrammatically, nativeFocus, version };
|
|
495
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.2",
|
|
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"
|
|
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": "9f5a6bb26e1444e3672ba217b8f7181857325e12"
|
|
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
|
}
|