keyborg 2.4.0-canary.0 → 2.4.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.
@@ -1,16 +1,6 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- // IE11 compat, checks if WeakRef is supported
6
- const _canUseWeakRef = typeof WeakRef !== "undefined";
7
- /**
8
- * WeakRef wrapper around a HTMLElement that also supports IE11
9
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef}
10
- * @internal
11
- */
12
-
13
- class WeakRefInstance {
1
+ // src/WeakRefInstance.ts
2
+ var _canUseWeakRef = typeof WeakRef !== "undefined";
3
+ var WeakRefInstance = class {
14
4
  constructor(instance) {
15
5
  if (_canUseWeakRef && typeof instance === "object") {
16
6
  this._weakRef = new WeakRef(instance);
@@ -18,122 +8,89 @@ class WeakRefInstance {
18
8
  this._instance = instance;
19
9
  }
20
10
  }
21
- /**
22
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref}
11
+ /**
12
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef/deref}
23
13
  */
24
-
25
-
26
14
  deref() {
27
- var _a, _b, _c;
28
-
15
+ var _a, _b;
29
16
  let instance;
30
-
31
17
  if (this._weakRef) {
32
- instance = (_a = this._weakRef) === null || _a === void 0 ? void 0 : _a.deref();
33
-
18
+ instance = (_a = this._weakRef) == null ? void 0 : _a.deref();
34
19
  if (!instance) {
35
20
  delete this._weakRef;
36
21
  }
37
22
  } else {
38
23
  instance = this._instance;
39
-
40
- if ((_c = (_b = instance) === null || _b === void 0 ? void 0 : _b.isDisposed) === null || _c === void 0 ? void 0 : _c.call(_b)) {
24
+ if ((_b = instance == null ? void 0 : instance.isDisposed) == null ? void 0 : _b.call(instance)) {
41
25
  delete this._instance;
42
26
  }
43
27
  }
44
-
45
28
  return instance;
46
29
  }
30
+ };
47
31
 
48
- }
49
-
50
- /*!
51
- * Copyright (c) Microsoft Corporation. All rights reserved.
52
- * Licensed under the MIT License.
53
- */
54
- const KEYBORG_FOCUSIN = "keyborg:focusin";
55
-
32
+ // src/FocusEvent.ts
33
+ var KEYBORG_FOCUSIN = "keyborg:focusin";
56
34
  function canOverrideNativeFocus(win) {
57
35
  const HTMLElement = win.HTMLElement;
58
36
  const origFocus = HTMLElement.prototype.focus;
59
37
  let isCustomFocusCalled = false;
60
-
61
38
  HTMLElement.prototype.focus = function focus() {
62
39
  isCustomFocusCalled = true;
63
40
  };
64
-
65
41
  const btn = win.document.createElement("button");
66
42
  btn.focus();
67
43
  HTMLElement.prototype.focus = origFocus;
68
44
  return isCustomFocusCalled;
69
45
  }
70
-
71
- let _canOverrideNativeFocus = false;
72
- /**
73
- * Guarantees that the native `focus` will be used
74
- */
75
-
46
+ var _canOverrideNativeFocus = false;
76
47
  function nativeFocus(element) {
77
48
  const focus = element.focus;
78
-
79
49
  if (focus.__keyborgNativeFocus) {
80
50
  focus.__keyborgNativeFocus.call(element);
81
51
  } else {
82
52
  element.focus();
83
53
  }
84
54
  }
85
- /**
86
- * Overrides the native `focus` and setups the keyborg focus event
87
- */
88
-
89
55
  function setupFocusEvent(win) {
90
56
  const kwin = win;
91
-
92
57
  if (!_canOverrideNativeFocus) {
93
58
  _canOverrideNativeFocus = canOverrideNativeFocus(kwin);
94
59
  }
95
-
96
60
  const origFocus = kwin.HTMLElement.prototype.focus;
97
-
98
61
  if (origFocus.__keyborgNativeFocus) {
99
- // Already set up.
100
62
  return;
101
63
  }
102
-
103
64
  kwin.HTMLElement.prototype.focus = focus;
104
-
105
- const focusOutShadowRootHandler = e => {
65
+ const focusOutShadowRootHandler = (e) => {
106
66
  const relatedTarget = e.relatedTarget;
107
- const currentTarget = e.currentTarget; // cleanup polyfill event handlers once focus leaves the shadow root
108
-
67
+ const currentTarget = e.currentTarget;
109
68
  if (!currentTarget.contains(relatedTarget)) {
110
- currentTarget.removeEventListener("focusin", focusInHandler);
111
- currentTarget.removeEventListener("focusout", focusOutShadowRootHandler);
69
+ currentTarget.removeEventListener("focusin", focusInHandler, true);
70
+ currentTarget.removeEventListener(
71
+ "focusout",
72
+ focusOutShadowRootHandler,
73
+ true
74
+ );
112
75
  }
113
76
  };
114
-
115
- const focusInHandler = e => {
77
+ const focusInHandler = (e) => {
116
78
  var _a;
117
-
118
- let target = e.target;
119
-
79
+ const target = e.target;
120
80
  if (!target) {
121
81
  return;
122
82
  }
123
-
124
83
  if (target.shadowRoot) {
125
- // https://bugs.chromium.org/p/chromium/issues/detail?id=1512028
126
- // focusin events don't bubble up through an open shadow root once focus is inside
127
- // once focus moves into a shadow root - we drop the same focusin handler there
128
- // keyborg's custom event will still bubble up since it is composed
129
- // event handlers should be cleaned up once focus leaves the shadow root
130
- target.shadowRoot.addEventListener("focusin", focusInHandler);
131
- target.shadowRoot.addEventListener("focusout", focusOutShadowRootHandler);
132
- target = e.composedPath()[0];
84
+ target.shadowRoot.addEventListener("focusin", focusInHandler, true);
85
+ target.shadowRoot.addEventListener(
86
+ "focusout",
87
+ focusOutShadowRootHandler,
88
+ true
89
+ );
90
+ return;
133
91
  }
134
-
135
92
  const details = {
136
- relatedTarget: e.relatedTarget || undefined
93
+ relatedTarget: e.relatedTarget || void 0
137
94
  };
138
95
  const event = new CustomEvent(KEYBORG_FOCUSIN, {
139
96
  cancelable: true,
@@ -141,113 +98,84 @@ function setupFocusEvent(win) {
141
98
  // Allows the event to bubble past an open shadow root
142
99
  composed: true,
143
100
  detail: details
144
- }); // Tabster (and other users) can still use the legacy details field - keeping for backwards compat
145
-
101
+ });
146
102
  event.details = details;
147
-
148
103
  if (_canOverrideNativeFocus || data.lastFocusedProgrammatically) {
149
- details.isFocusedProgrammatically = target === ((_a = data.lastFocusedProgrammatically) === null || _a === void 0 ? void 0 : _a.deref());
150
- data.lastFocusedProgrammatically = undefined;
104
+ details.isFocusedProgrammatically = target === ((_a = data.lastFocusedProgrammatically) == null ? void 0 : _a.deref());
105
+ data.lastFocusedProgrammatically = void 0;
151
106
  }
152
-
153
107
  target.dispatchEvent(event);
154
108
  };
155
-
156
109
  const data = kwin.__keyborgData = {
157
110
  focusInHandler
158
111
  };
159
- kwin.document.addEventListener("focusin", kwin.__keyborgData.focusInHandler, true);
160
-
112
+ kwin.document.addEventListener(
113
+ "focusin",
114
+ kwin.__keyborgData.focusInHandler,
115
+ true
116
+ );
161
117
  function focus() {
162
118
  const keyborgNativeFocusEvent = kwin.__keyborgData;
163
-
164
119
  if (keyborgNativeFocusEvent) {
165
- keyborgNativeFocusEvent.lastFocusedProgrammatically = new WeakRefInstance(this);
166
- } // eslint-disable-next-line prefer-rest-params
167
-
168
-
120
+ keyborgNativeFocusEvent.lastFocusedProgrammatically = new WeakRefInstance(
121
+ this
122
+ );
123
+ }
169
124
  return origFocus.apply(this, arguments);
170
125
  }
171
-
172
126
  focus.__keyborgNativeFocus = origFocus;
173
127
  }
174
- /**
175
- * Removes keyborg event listeners and custom focus override
176
- * @param win The window that stores keyborg focus events
177
- */
178
-
179
128
  function disposeFocusEvent(win) {
180
129
  const kwin = win;
181
130
  const proto = kwin.HTMLElement.prototype;
182
131
  const origFocus = proto.focus.__keyborgNativeFocus;
183
132
  const keyborgNativeFocusEvent = kwin.__keyborgData;
184
-
185
133
  if (keyborgNativeFocusEvent) {
186
- kwin.document.removeEventListener("focusin", keyborgNativeFocusEvent.focusInHandler, true);
134
+ kwin.document.removeEventListener(
135
+ "focusin",
136
+ keyborgNativeFocusEvent.focusInHandler,
137
+ true
138
+ );
187
139
  delete kwin.__keyborgData;
188
140
  }
189
-
190
141
  if (origFocus) {
191
142
  proto.focus = origFocus;
192
143
  }
193
144
  }
194
- /**
195
- * @param win The window that stores keyborg focus events
196
- * @returns The last element focused with element.focus()
197
- */
198
-
199
145
  function getLastFocusedProgrammatically(win) {
200
146
  var _a;
201
-
202
147
  const keyborgNativeFocusEvent = win.__keyborgData;
203
- return keyborgNativeFocusEvent ? ((_a = keyborgNativeFocusEvent.lastFocusedProgrammatically) === null || _a === void 0 ? void 0 : _a.deref()) || null : undefined;
148
+ return keyborgNativeFocusEvent ? ((_a = keyborgNativeFocusEvent.lastFocusedProgrammatically) == null ? void 0 : _a.deref()) || null : void 0;
204
149
  }
205
150
 
206
- /*!
207
- * Copyright (c) Microsoft Corporation. All rights reserved.
208
- * Licensed under the MIT License.
209
- */
210
- const _dismissTimeout = 500; // When a key from dismissKeys is pressed and the focus is not moved
211
- // during _dismissTimeout time, dismiss the keyboard navigation mode.
212
-
213
- let _lastId = 0;
214
- /**
215
- * Source of truth for all the keyborg core instances and the current keyboard navigation state
216
- */
217
-
218
- class KeyborgState {
151
+ // src/Keyborg.ts
152
+ var _dismissTimeout = 500;
153
+ var _lastId = 0;
154
+ var KeyborgState = class {
219
155
  constructor() {
220
156
  this.__keyborgCoreRefs = {};
221
157
  this._isNavigatingWithKeyboard = false;
222
158
  }
223
-
224
159
  add(keyborg) {
225
160
  const id = keyborg.id;
226
-
227
161
  if (!(id in this.__keyborgCoreRefs)) {
228
162
  this.__keyborgCoreRefs[id] = new WeakRefInstance(keyborg);
229
163
  }
230
164
  }
231
-
232
165
  remove(id) {
233
166
  delete this.__keyborgCoreRefs[id];
234
-
235
167
  if (Object.keys(this.__keyborgCoreRefs).length === 0) {
236
168
  this._isNavigatingWithKeyboard = false;
237
169
  }
238
170
  }
239
-
240
171
  setVal(isNavigatingWithKeyboard) {
241
172
  if (this._isNavigatingWithKeyboard === isNavigatingWithKeyboard) {
242
173
  return;
243
174
  }
244
-
245
175
  this._isNavigatingWithKeyboard = isNavigatingWithKeyboard;
246
-
247
176
  for (const id of Object.keys(this.__keyborgCoreRefs)) {
248
177
  const ref = this.__keyborgCoreRefs[id];
249
178
  const keyborg = ref.deref();
250
-
251
179
  if (keyborg) {
252
180
  keyborg.update(isNavigatingWithKeyboard);
253
181
  } else {
@@ -255,207 +183,154 @@ class KeyborgState {
255
183
  }
256
184
  }
257
185
  }
258
-
259
186
  getVal() {
260
187
  return this._isNavigatingWithKeyboard;
261
188
  }
262
-
263
- }
264
-
265
- const _state = /*#__PURE__*/new KeyborgState();
266
- /**
267
- * Manages a collection of Keyborg instances in a window/document and updates keyborg state
268
- */
269
-
270
-
271
- class KeyborgCore {
189
+ };
190
+ var _state = new KeyborgState();
191
+ var KeyborgCore = class {
272
192
  constructor(win, props) {
273
- this._onFocusIn = e => {
274
- // When the focus is moved not programmatically and without keydown events,
275
- // it is likely that the focus is moved by screen reader (as it might swallow
276
- // the events when the screen reader shortcuts are used). The screen reader
277
- // usage is keyboard navigation.
193
+ this._onFocusIn = (e) => {
278
194
  if (this._isMouseUsedTimer) {
279
- // There was a mouse event recently.
280
195
  return;
281
196
  }
282
-
283
197
  if (_state.getVal()) {
284
198
  return;
285
199
  }
286
-
287
200
  const details = e.detail;
288
-
289
201
  if (!details.relatedTarget) {
290
202
  return;
291
203
  }
292
-
293
- if (details.isFocusedProgrammatically || details.isFocusedProgrammatically === undefined) {
294
- // The element is focused programmatically, or the programmatic focus detection
295
- // is not working.
204
+ if (details.isFocusedProgrammatically || details.isFocusedProgrammatically === void 0) {
296
205
  return;
297
206
  }
298
-
299
207
  _state.setVal(true);
300
208
  };
301
-
302
- this._onMouseDown = e => {
209
+ this._onMouseDown = (e) => {
303
210
  if (e.buttons === 0 || e.clientX === 0 && e.clientY === 0 && e.screenX === 0 && e.screenY === 0) {
304
- // This is most likely an event triggered by the screen reader to perform
305
- // an action on an element, do not dismiss the keyboard navigation mode.
306
211
  return;
307
212
  }
308
-
309
213
  const win = this._win;
310
-
311
214
  if (win) {
312
215
  if (this._isMouseUsedTimer) {
313
216
  win.clearTimeout(this._isMouseUsedTimer);
314
217
  }
315
-
316
218
  this._isMouseUsedTimer = win.setTimeout(() => {
317
219
  delete this._isMouseUsedTimer;
318
- }, 1000); // Keeping the indication of the mouse usage for some time.
220
+ }, 1e3);
319
221
  }
320
-
321
222
  _state.setVal(false);
322
223
  };
323
-
324
- this._onKeyDown = e => {
325
- var _a, _b;
326
-
224
+ this._onKeyDown = (e) => {
327
225
  const isNavigatingWithKeyboard = _state.getVal();
328
-
329
- const keyCode = e.keyCode;
330
- const triggerKeys = this._triggerKeys;
331
-
332
- if (!isNavigatingWithKeyboard && (!triggerKeys || triggerKeys.has(keyCode))) {
333
- const activeElement = (_a = this._win) === null || _a === void 0 ? void 0 : _a.document.activeElement;
334
-
335
- if (activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.contentEditable === "true")) {
336
- // We're inside an input, textarea or contenteditable, it's not
337
- // keyboard navigation, it is text editing scenario.
338
- return;
226
+ if (isNavigatingWithKeyboard) {
227
+ if (this._shouldDismissKeyboardNavigation(e)) {
228
+ this._scheduleDismiss();
229
+ }
230
+ } else {
231
+ if (this._shouldTriggerKeyboardNavigation(e)) {
232
+ _state.setVal(true);
339
233
  }
340
-
341
- _state.setVal(true);
342
- } else if (isNavigatingWithKeyboard && ((_b = this._dismissKeys) === null || _b === void 0 ? void 0 : _b.has(keyCode))) {
343
- this._scheduleDismiss();
344
234
  }
345
235
  };
346
-
347
236
  this.id = "c" + ++_lastId;
348
237
  this._win = win;
349
238
  const doc = win.document;
350
-
351
239
  if (props) {
352
240
  const triggerKeys = props.triggerKeys;
353
241
  const dismissKeys = props.dismissKeys;
354
-
355
- if (triggerKeys === null || triggerKeys === void 0 ? void 0 : triggerKeys.length) {
242
+ if (triggerKeys == null ? void 0 : triggerKeys.length) {
356
243
  this._triggerKeys = new Set(triggerKeys);
357
244
  }
358
-
359
- if (dismissKeys === null || dismissKeys === void 0 ? void 0 : dismissKeys.length) {
245
+ if (dismissKeys == null ? void 0 : dismissKeys.length) {
360
246
  this._dismissKeys = new Set(dismissKeys);
361
247
  }
362
248
  }
363
-
364
- doc.addEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
365
-
366
- doc.addEventListener("mousedown", this._onMouseDown, true); // Capture!
367
-
368
- win.addEventListener("keydown", this._onKeyDown, true); // Capture!
369
-
249
+ doc.addEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true);
250
+ doc.addEventListener("mousedown", this._onMouseDown, true);
251
+ win.addEventListener("keydown", this._onKeyDown, true);
370
252
  setupFocusEvent(win);
371
-
372
253
  _state.add(this);
373
254
  }
374
-
375
255
  dispose() {
376
256
  const win = this._win;
377
-
378
257
  if (win) {
379
258
  if (this._isMouseUsedTimer) {
380
259
  win.clearTimeout(this._isMouseUsedTimer);
381
- this._isMouseUsedTimer = undefined;
260
+ this._isMouseUsedTimer = void 0;
382
261
  }
383
-
384
262
  if (this._dismissTimer) {
385
263
  win.clearTimeout(this._dismissTimer);
386
- this._dismissTimer = undefined;
264
+ this._dismissTimer = void 0;
387
265
  }
388
-
389
266
  disposeFocusEvent(win);
390
267
  const doc = win.document;
391
- doc.removeEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true); // Capture!
392
-
393
- doc.removeEventListener("mousedown", this._onMouseDown, true); // Capture!
394
-
395
- win.removeEventListener("keydown", this._onKeyDown, true); // Capture!
396
-
268
+ doc.removeEventListener(KEYBORG_FOCUSIN, this._onFocusIn, true);
269
+ doc.removeEventListener("mousedown", this._onMouseDown, true);
270
+ win.removeEventListener("keydown", this._onKeyDown, true);
397
271
  delete this._win;
398
-
399
272
  _state.remove(this.id);
400
273
  }
401
274
  }
402
-
403
275
  isDisposed() {
404
276
  return !!this._win;
405
277
  }
406
- /**
407
- * Updates all keyborg instances with the keyboard navigation state
278
+ /**
279
+ * Updates all keyborg instances with the keyboard navigation state
408
280
  */
409
-
410
-
411
281
  update(isNavigatingWithKeyboard) {
412
282
  var _a, _b;
413
-
414
- const keyborgs = (_b = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg) === null || _b === void 0 ? void 0 : _b.refs;
415
-
283
+ const keyborgs = (_b = (_a = this._win) == null ? void 0 : _a.__keyborg) == null ? void 0 : _b.refs;
416
284
  if (keyborgs) {
417
285
  for (const id of Object.keys(keyborgs)) {
418
286
  Keyborg.update(keyborgs[id], isNavigatingWithKeyboard);
419
287
  }
420
288
  }
421
289
  }
422
-
290
+ /**
291
+ * @returns whether the keyboard event should trigger keyboard navigation mode
292
+ */
293
+ _shouldTriggerKeyboardNavigation(e) {
294
+ var _a;
295
+ if (e.key === "Tab") {
296
+ return true;
297
+ }
298
+ const activeElement = (_a = this._win) == null ? void 0 : _a.document.activeElement;
299
+ const isTriggerKey = !this._triggerKeys || this._triggerKeys.has(e.keyCode);
300
+ const isEditable = activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA" || activeElement.isContentEditable);
301
+ return isTriggerKey && !isEditable;
302
+ }
303
+ /**
304
+ * @returns whether the keyboard event should dismiss keyboard navigation mode
305
+ */
306
+ _shouldDismissKeyboardNavigation(e) {
307
+ var _a;
308
+ return (_a = this._dismissKeys) == null ? void 0 : _a.has(e.keyCode);
309
+ }
423
310
  _scheduleDismiss() {
424
311
  const win = this._win;
425
-
426
312
  if (win) {
427
313
  if (this._dismissTimer) {
428
314
  win.clearTimeout(this._dismissTimer);
429
- this._dismissTimer = undefined;
315
+ this._dismissTimer = void 0;
430
316
  }
431
-
432
317
  const was = win.document.activeElement;
433
318
  this._dismissTimer = win.setTimeout(() => {
434
- this._dismissTimer = undefined;
319
+ this._dismissTimer = void 0;
435
320
  const cur = win.document.activeElement;
436
-
437
321
  if (was && cur && was === cur) {
438
- // Esc was pressed, currently focused element hasn't changed.
439
- // Just dismiss the keyboard navigation mode.
440
322
  _state.setVal(false);
441
323
  }
442
324
  }, _dismissTimeout);
443
325
  }
444
326
  }
445
-
446
- }
447
- /**
448
- * Used to determine the keyboard navigation state
449
- */
450
-
451
-
452
- class Keyborg {
327
+ };
328
+ var Keyborg = class _Keyborg {
453
329
  constructor(win, props) {
454
330
  this._cb = [];
455
331
  this._id = "k" + ++_lastId;
456
332
  this._win = win;
457
333
  const current = win.__keyborg;
458
-
459
334
  if (current) {
460
335
  this._core = current.core;
461
336
  current.refs[this._id] = this;
@@ -463,88 +338,68 @@ class Keyborg {
463
338
  this._core = new KeyborgCore(win, props);
464
339
  win.__keyborg = {
465
340
  core: this._core,
466
- refs: {
467
- [this._id]: this
468
- }
341
+ refs: { [this._id]: this }
469
342
  };
470
343
  }
471
344
  }
472
-
473
345
  static create(win, props) {
474
- return new Keyborg(win, props);
346
+ return new _Keyborg(win, props);
475
347
  }
476
-
477
348
  static dispose(instance) {
478
349
  instance.dispose();
479
350
  }
480
- /**
481
- * Updates all subscribed callbacks with the keyboard navigation state
351
+ /**
352
+ * Updates all subscribed callbacks with the keyboard navigation state
482
353
  */
483
-
484
-
485
354
  static update(instance, isNavigatingWithKeyboard) {
486
- instance._cb.forEach(callback => callback(isNavigatingWithKeyboard));
355
+ instance._cb.forEach((callback) => callback(isNavigatingWithKeyboard));
487
356
  }
488
-
489
357
  dispose() {
490
358
  var _a;
491
-
492
- const current = (_a = this._win) === null || _a === void 0 ? void 0 : _a.__keyborg;
493
-
494
- if (current === null || current === void 0 ? void 0 : current.refs[this._id]) {
359
+ const current = (_a = this._win) == null ? void 0 : _a.__keyborg;
360
+ if (current == null ? void 0 : current.refs[this._id]) {
495
361
  delete current.refs[this._id];
496
-
497
362
  if (Object.keys(current.refs).length === 0) {
498
- current.core.dispose(); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
499
-
363
+ current.core.dispose();
500
364
  delete this._win.__keyborg;
501
365
  }
502
- } else if (process.env.NODE_ENV === 'development') {
503
- console.error("Keyborg instance " + this._id + " is being disposed incorrectly.");
366
+ } else if (process.env.NODE_ENV !== "production") {
367
+ console.error(
368
+ `Keyborg instance ${this._id} is being disposed incorrectly.`
369
+ );
504
370
  }
505
-
506
371
  this._cb = [];
507
372
  delete this._core;
508
373
  delete this._win;
509
374
  }
510
- /**
511
- * @returns Whether the user is navigating with keyboard
375
+ /**
376
+ * @returns Whether the user is navigating with keyboard
512
377
  */
513
-
514
-
515
378
  isNavigatingWithKeyboard() {
516
379
  return _state.getVal();
517
380
  }
518
- /**
519
- * @param callback - Called when the keyboard navigation state changes
381
+ /**
382
+ * @param callback - Called when the keyboard navigation state changes
520
383
  */
521
-
522
-
523
384
  subscribe(callback) {
524
385
  this._cb.push(callback);
525
386
  }
526
- /**
527
- * @param callback - Registered with subscribe
387
+ /**
388
+ * @param callback - Registered with subscribe
528
389
  */
529
-
530
-
531
390
  unsubscribe(callback) {
532
391
  const index = this._cb.indexOf(callback);
533
-
534
392
  if (index >= 0) {
535
393
  this._cb.splice(index, 1);
536
394
  }
537
395
  }
538
- /**
539
- * Manually set the keyboard navigtion state
396
+ /**
397
+ * Manually set the keyboard navigtion state
540
398
  */
541
-
542
-
543
399
  setVal(isNavigatingWithKeyboard) {
544
400
  _state.setVal(isNavigatingWithKeyboard);
545
401
  }
546
-
547
- }
402
+ };
548
403
  function createKeyborg(win, props) {
549
404
  return Keyborg.create(win, props);
550
405
  }
@@ -552,11 +407,18 @@ function disposeKeyborg(instance) {
552
407
  Keyborg.dispose(instance);
553
408
  }
554
409
 
555
- /*!
556
- * Copyright (c) Microsoft Corporation. All rights reserved.
557
- * Licensed under the MIT License.
410
+ // src/index.ts
411
+ var version = "2.4.1";
412
+ export {
413
+ KEYBORG_FOCUSIN,
414
+ createKeyborg,
415
+ disposeKeyborg,
416
+ getLastFocusedProgrammatically,
417
+ nativeFocus,
418
+ version
419
+ };
420
+ /*!
421
+ * Copyright (c) Microsoft Corporation. All rights reserved.
422
+ * Licensed under the MIT License.
558
423
  */
559
- const version = "2.4.0-canary.0";
560
-
561
- export { KEYBORG_FOCUSIN, Keyborg, createKeyborg, disposeKeyborg, getLastFocusedProgrammatically, nativeFocus, version };
562
- //# sourceMappingURL=keyborg.esm.js.map
424
+ //# sourceMappingURL=index.js.map