@lion/ui 0.8.5 → 0.8.7

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.
Files changed (105) hide show
  1. package/components/calendar/src/LionCalendar.js +5 -1
  2. package/components/combobox/test/lion-combobox.test.js +13 -11
  3. package/components/core/src/ScopedElementsMixin.js +2 -2
  4. package/components/core/test/ScopedElementsMixin.test.js +34 -1
  5. package/components/core/test/SlotMixin.test.js +19 -33
  6. package/components/core/test-helpers/isActiveElement.js +14 -0
  7. package/components/dialog/test/lion-dialog.test.js +6 -5
  8. package/components/form/test/lion-form.test.js +20 -18
  9. package/components/form-core/test/lion-field.test.js +15 -14
  10. package/components/form-core/test-suites/NativeTextFieldMixin.suite.js +8 -6
  11. package/components/form-core/test-suites/ValidateMixin.suite.js +7 -7
  12. package/components/form-integrations/test/dialog-integrations.test.js +6 -5
  13. package/components/input-datepicker/test/lion-input-datepicker.test.js +25 -1
  14. package/components/overlays/src/OverlayController.js +25 -1
  15. package/components/overlays/src/OverlayMixin.js +17 -4
  16. package/components/overlays/src/utils/adopt-styles.js +3 -3
  17. package/components/overlays/src/utils/contain-focus.js +1 -1
  18. package/components/overlays/test/OverlayController.test.js +46 -13
  19. package/components/overlays/test/utils-tests/contain-focus.test.js +21 -16
  20. package/components/select-rich/test/lion-select-rich.test.js +15 -17
  21. package/components/switch/test/lion-switch.test.js +7 -6
  22. package/custom-elements.json +157 -7
  23. package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
  24. package/dist-types/components/combobox/test/lion-combobox.test.d.ts.map +1 -1
  25. package/dist-types/components/{overlays/src/utils/get-deep-active-element.d.ts → core/src/getDeepActiveElement.d.ts} +1 -1
  26. package/dist-types/components/core/src/getDeepActiveElement.d.ts.map +1 -0
  27. package/dist-types/components/core/test/SlotMixin.test.d.ts.map +1 -1
  28. package/dist-types/components/core/test-helpers/isActiveElement.d.ts +13 -0
  29. package/dist-types/components/core/test-helpers/isActiveElement.d.ts.map +1 -0
  30. package/dist-types/components/dialog/test/lion-dialog.test.d.ts.map +1 -1
  31. package/dist-types/components/form/test/lion-form.test.d.ts.map +1 -1
  32. package/dist-types/components/form-core/test/lion-field.test.d.ts +2 -2
  33. package/dist-types/components/form-core/test/lion-field.test.d.ts.map +1 -1
  34. package/dist-types/components/form-core/test-suites/NativeTextFieldMixin.suite.d.ts +2 -2
  35. package/dist-types/components/form-core/test-suites/NativeTextFieldMixin.suite.d.ts.map +1 -1
  36. package/dist-types/components/form-integrations/test/dialog-integrations.test.d.ts.map +1 -1
  37. package/dist-types/components/overlays/src/OverlayController.d.ts +2 -0
  38. package/dist-types/components/overlays/src/OverlayController.d.ts.map +1 -1
  39. package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
  40. package/dist-types/components/overlays/test/OverlayController.test.d.ts.map +1 -1
  41. package/dist-types/components/select-rich/test/lion-select-rich.test.d.ts +2 -2
  42. package/dist-types/components/select-rich/test/lion-select-rich.test.d.ts.map +1 -1
  43. package/dist-types/components/switch/test/lion-switch.test.d.ts +1 -1
  44. package/dist-types/components/switch/test/lion-switch.test.d.ts.map +1 -1
  45. package/dist-types/exports/overlays.d.ts +2 -2
  46. package/dist-types/tsconfig.tsbuildinfo +1 -1
  47. package/docs/components/checkbox-group/overview.md +2 -2
  48. package/docs/components/collapsible/overview.md +1 -1
  49. package/docs/components/combobox/overview.md +1 -1
  50. package/docs/components/combobox/use-cases.md +1 -1
  51. package/docs/components/dialog/overview.md +1 -1
  52. package/docs/components/fieldset/overview.md +5 -5
  53. package/docs/components/form/overview.md +3 -3
  54. package/docs/components/form/use-cases.md +157 -8
  55. package/docs/components/icon/use-cases.md +1 -1
  56. package/docs/components/input/overview.md +1 -1
  57. package/docs/components/input-amount/overview.md +3 -3
  58. package/docs/components/input-date/overview.md +3 -3
  59. package/docs/components/input-datepicker/overview.md +5 -5
  60. package/docs/components/input-email/overview.md +2 -2
  61. package/docs/components/input-file/overview.md +1 -1
  62. package/docs/components/input-iban/overview.md +2 -2
  63. package/docs/components/input-range/overview.md +2 -2
  64. package/docs/components/input-stepper/overview.md +1 -1
  65. package/docs/components/input-tel/overview.md +1 -1
  66. package/docs/components/input-tel/use-cases.md +6 -6
  67. package/docs/components/input-tel-dropdown/overview.md +1 -1
  68. package/docs/components/listbox/use-cases.md +1 -1
  69. package/docs/components/radio-group/overview.md +3 -3
  70. package/docs/components/select/use-cases.md +1 -1
  71. package/docs/components/select-rich/use-cases.md +1 -1
  72. package/docs/components/tabs/examples.md +1 -1
  73. package/docs/fundamentals/index.md +4 -4
  74. package/docs/fundamentals/node-tools/providence-analytics/overview.md +42 -139
  75. package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
  76. package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
  77. package/docs/fundamentals/rationales/accessibility.md +1 -1
  78. package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
  79. package/docs/fundamentals/systems/core/overview.md +1 -1
  80. package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
  81. package/docs/fundamentals/systems/form/model-value.md +1 -1
  82. package/docs/fundamentals/systems/form/overview.md +28 -28
  83. package/docs/fundamentals/systems/form/validate.md +2 -2
  84. package/docs/fundamentals/systems/localize/overview.md +4 -4
  85. package/docs/fundamentals/systems/overlays/configuration.md +2 -2
  86. package/docs/fundamentals/systems/overlays/overview.md +5 -5
  87. package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
  88. package/docs/fundamentals/tools/helpers/overview.md +1 -1
  89. package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
  90. package/docs/guides/how-to/create-a-custom-field.md +5 -5
  91. package/docs/guides/how-to/create-a-form.md +4 -4
  92. package/docs/guides/how-to/extend-a-native-input.md +2 -2
  93. package/docs/guides/index.md +8 -8
  94. package/docs/guides/principles/index.md +5 -5
  95. package/docs/guides/principles/styling.md +1 -1
  96. package/exports/overlays.js +3 -2
  97. package/overlays.js +3 -2
  98. package/package.json +1 -1
  99. package/dist-types/components/overlays/src/utils/get-deep-active-element.d.ts.map +0 -1
  100. package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +0 -68
  101. package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +0 -111
  102. package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +0 -69
  103. package/docs/fundamentals/node-tools/providence-analytics/assets/_mermaid.svg.js +0 -1226
  104. package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +0 -22
  105. /package/components/{overlays/src/utils/get-deep-active-element.js → core/src/getDeepActiveElement.js} +0 -0
@@ -182,11 +182,13 @@ export const OverlayMixinImplementation = superclass =>
182
182
  this._setupOverlayCtrl();
183
183
  }
184
184
 
185
- disconnectedCallback() {
185
+ async disconnectedCallback() {
186
186
  super.disconnectedCallback();
187
- if (this._overlayCtrl) {
188
- this._teardownOverlayCtrl();
189
- }
187
+
188
+ if (!this._overlayCtrl) return;
189
+ if (await this.#isMovingInDom()) return;
190
+
191
+ this._teardownOverlayCtrl();
190
192
  }
191
193
 
192
194
  /**
@@ -253,6 +255,7 @@ export const OverlayMixinImplementation = superclass =>
253
255
  _teardownOverlayCtrl() {
254
256
  this._teardownOpenCloseListeners();
255
257
  this.__teardownSyncFromOverlayController();
258
+
256
259
  /** @type {OverlayController} */
257
260
  (this._overlayCtrl).teardown();
258
261
  }
@@ -387,5 +390,15 @@ export const OverlayMixinImplementation = superclass =>
387
390
  ctrl._popper.update();
388
391
  }
389
392
  }
393
+
394
+ /**
395
+ * When we're moving around in dom, disconnectedCallback gets called.
396
+ * Before we decide to teardown, let's wait to see if we were not just moving nodes around.
397
+ * @return {Promise<boolean>}
398
+ */
399
+ async #isMovingInDom() {
400
+ await this.updateComplete;
401
+ return this.isConnected;
402
+ }
390
403
  };
391
404
  export const OverlayMixin = dedupeMixin(OverlayMixinImplementation);
@@ -25,7 +25,7 @@ export const _adoptStyleUtils = {
25
25
  adoptStyles: undefined,
26
26
  };
27
27
 
28
- const styleCache = new Map();
28
+ const styleCache = new WeakMap();
29
29
 
30
30
  /**
31
31
  * @param {CSSStyleSheet} cssStyleSheet
@@ -81,10 +81,10 @@ function adoptStyleWhenAdoptedStylesheetsNotSupported(
81
81
  */
82
82
  function handleCache(renderRoot, style, { teardown = false } = {}) {
83
83
  let haltFurtherExecution = false;
84
- if (!styleCache.has(renderRoot)) {
84
+ if (renderRoot && !styleCache.has(renderRoot)) {
85
85
  styleCache.set(renderRoot, []);
86
86
  }
87
- const addedStylesForRoot = styleCache.get(renderRoot);
87
+ const addedStylesForRoot = styleCache.get(renderRoot) ?? [];
88
88
  const foundStyle = addedStylesForRoot.find(
89
89
  (/** @type {import("lit").CSSResultOrNative} */ addedStyle) => style === addedStyle,
90
90
  );
@@ -6,7 +6,7 @@
6
6
  * and contains several bugs on IE11.
7
7
  */
8
8
 
9
- import { getDeepActiveElement } from './get-deep-active-element.js';
9
+ import { getDeepActiveElement } from '../../../core/src/getDeepActiveElement.js';
10
10
  import { getFocusableElements } from './get-focusable-elements.js';
11
11
  import { deepContains } from './deep-contains.js';
12
12
  import { keyCodes } from './key-codes.js';
@@ -12,6 +12,7 @@ import {
12
12
  html,
13
13
  } from '@open-wc/testing';
14
14
 
15
+ import { isActiveElement } from '../../core/test-helpers/isActiveElement.js';
15
16
  import { createShadowHost } from '../test-helpers/createShadowHost.js';
16
17
  import { _adoptStyleUtils } from '../src/utils/adopt-styles.js';
17
18
  import { simulateTab } from '../src/utils/simulate-tab.js';
@@ -36,6 +37,14 @@ async function mimicEscapePress(element) {
36
37
  await aTimeout(0);
37
38
  }
38
39
 
40
+ /**
41
+ * @param {OverlayController} ctrlToFind
42
+ * @returns {boolean}
43
+ */
44
+ function isRegisteredOnManager(ctrlToFind) {
45
+ return Boolean(ctrlToFind.manager?.list?.find(ctrl => ctrlToFind === ctrl));
46
+ }
47
+
39
48
  /**
40
49
  * Make sure that all browsers serialize html in a similar way
41
50
  * (Firefox tends to output empty style attrs)
@@ -275,8 +284,18 @@ describe('OverlayController', () => {
275
284
  });
276
285
  });
277
286
 
278
- // TODO: Add teardown feature tests
279
- describe('Teardown', () => {});
287
+ // TODO: Add more teardown feature tests
288
+ describe('Teardown', () => {
289
+ it('unregisters itself from overlayManager', async () => {
290
+ const ctrl = new OverlayController(withGlobalTestConfig());
291
+
292
+ expect(isRegisteredOnManager(ctrl)).to.be.true;
293
+
294
+ ctrl.teardown();
295
+
296
+ expect(isRegisteredOnManager(ctrl)).to.be.false;
297
+ });
298
+ });
280
299
 
281
300
  describe('Node Configuration', () => {
282
301
  describe('Content', async () => {
@@ -556,7 +575,8 @@ describe('OverlayController', () => {
556
575
  trapsKeyboardFocus: true,
557
576
  });
558
577
  await ctrl.show();
559
- expect(ctrl.contentNode).to.equal(document.activeElement);
578
+
579
+ expect(isActiveElement(ctrl.contentNode)).to.be.true;
560
580
  });
561
581
 
562
582
  it('keeps focus within the overlay e.g. you can not tab out by accident', async () => {
@@ -1092,6 +1112,19 @@ describe('OverlayController', () => {
1092
1112
 
1093
1113
  expect(ctrl.isShown).to.be.true;
1094
1114
  });
1115
+
1116
+ it('hides when window is blurred (useful for iframes)', async () => {
1117
+ const ctrl = new OverlayController({
1118
+ ...withGlobalTestConfig(),
1119
+ hidesOnOutsideClick: true,
1120
+ });
1121
+ await ctrl.show();
1122
+
1123
+ window.dispatchEvent(new Event('blur'));
1124
+ await aTimeout(0);
1125
+
1126
+ expect(ctrl.isShown).to.be.false;
1127
+ });
1095
1128
  });
1096
1129
 
1097
1130
  describe('elementToFocusAfterHide', () => {
@@ -1108,10 +1141,10 @@ describe('OverlayController', () => {
1108
1141
  await ctrl.show();
1109
1142
  const input = /** @type {HTMLInputElement} */ (contentNode.querySelector('input'));
1110
1143
  input.focus();
1111
- expect(document.activeElement).to.equal(input);
1144
+ expect(isActiveElement(input)).to.be.true;
1112
1145
 
1113
1146
  await ctrl.hide();
1114
- expect(document.activeElement).to.equal(document.body);
1147
+ expect(isActiveElement(document.body)).to.be.true;
1115
1148
  });
1116
1149
 
1117
1150
  it('supports elementToFocusAfterHide option to focus it when hiding', async () => {
@@ -1128,10 +1161,10 @@ describe('OverlayController', () => {
1128
1161
  await ctrl.show();
1129
1162
  const textarea = /** @type {HTMLTextAreaElement} */ (contentNode.querySelector('textarea'));
1130
1163
  textarea.focus();
1131
- expect(document.activeElement).to.equal(textarea);
1164
+ expect(isActiveElement(textarea)).to.be.true;
1132
1165
 
1133
1166
  await ctrl.hide();
1134
- expect(document.activeElement).to.equal(input);
1167
+ expect(isActiveElement(input)).to.be.true;
1135
1168
  expect(isInViewport(input)).to.be.true;
1136
1169
  });
1137
1170
 
@@ -1156,10 +1189,10 @@ describe('OverlayController', () => {
1156
1189
  await ctrl.show();
1157
1190
  const textarea = /** @type {HTMLTextAreaElement} */ (contentNode.querySelector('textarea'));
1158
1191
  textarea.focus();
1159
- expect(document.activeElement).to.equal(textarea);
1192
+ expect(isActiveElement(textarea)).to.be.true;
1160
1193
 
1161
1194
  await ctrl.hide();
1162
- expect(document.activeElement).to.equal(input);
1195
+ expect(isActiveElement(input)).to.be.true;
1163
1196
 
1164
1197
  document.body.removeChild(shadowHost);
1165
1198
  });
@@ -1177,10 +1210,10 @@ describe('OverlayController', () => {
1177
1210
  await ctrl.show();
1178
1211
  // an outside element has taken over focus
1179
1212
  outsideButton.focus();
1180
- expect(document.activeElement).to.equal(outsideButton);
1213
+ expect(isActiveElement(outsideButton)).to.be.true;
1181
1214
 
1182
1215
  await ctrl.hide();
1183
- expect(document.activeElement).to.equal(outsideButton);
1216
+ expect(isActiveElement(outsideButton)).to.be.true;
1184
1217
  });
1185
1218
 
1186
1219
  it('allows to set elementToFocusAfterHide on show', async () => {
@@ -1199,10 +1232,10 @@ describe('OverlayController', () => {
1199
1232
  await ctrl.show(input);
1200
1233
  const textarea = /** @type {HTMLTextAreaElement} */ (contentNode.querySelector('textarea'));
1201
1234
  textarea.focus();
1202
- expect(document.activeElement).to.equal(textarea);
1235
+ expect(isActiveElement(textarea)).to.be.true;
1203
1236
 
1204
1237
  await ctrl.hide();
1205
- expect(document.activeElement).to.equal(input);
1238
+ expect(isActiveElement(input)).to.be.true;
1206
1239
  });
1207
1240
  });
1208
1241
 
@@ -1,11 +1,12 @@
1
1
  /* eslint-disable lit-a11y/no-autofocus */
2
2
  import { expect, fixture, nextFrame } from '@open-wc/testing';
3
- import { html } from 'lit/static-html.js';
3
+ import { getFocusableElements } from '@lion/ui/overlays.js';
4
4
  import { renderLitAsNode } from '@lion/ui/helpers.js';
5
- import { getDeepActiveElement, getFocusableElements } from '@lion/ui/overlays.js';
5
+ import { html } from 'lit/static-html.js';
6
6
 
7
- import { keyCodes } from '../../src/utils/key-codes.js';
7
+ import { isActiveElement } from '../../../core/test-helpers/isActiveElement.js';
8
8
  import { containFocus } from '../../src/utils/contain-focus.js';
9
+ import { keyCodes } from '../../src/utils/key-codes.js';
9
10
 
10
11
  function simulateTabWithinContainFocus() {
11
12
  const event = new CustomEvent('keydown', { detail: 0, bubbles: true });
@@ -87,7 +88,7 @@ describe('containFocus()', () => {
87
88
  const root = /** @type {HTMLElement} */ (document.getElementById('rootElement'));
88
89
  const { disconnect } = containFocus(root);
89
90
 
90
- expect(getDeepActiveElement()).to.equal(root);
91
+ expect(isActiveElement(root, { deep: true })).to.be.true;
91
92
  expect(root.getAttribute('tabindex')).to.equal('-1');
92
93
  expect(root.style.getPropertyValue('outline-style')).to.equal('none');
93
94
 
@@ -99,7 +100,7 @@ describe('containFocus()', () => {
99
100
  const el = /** @type {HTMLElement} */ (document.querySelector('input[autofocus]'));
100
101
  const { disconnect } = containFocus(el);
101
102
 
102
- expect(getDeepActiveElement()).to.equal(el);
103
+ expect(isActiveElement(el, { deep: true })).to.be.true;
103
104
 
104
105
  disconnect();
105
106
  });
@@ -113,7 +114,7 @@ describe('containFocus()', () => {
113
114
  /** @type {HTMLElement} */ (document.getElementById('outside-1')).focus();
114
115
 
115
116
  simulateTabWithinContainFocus();
116
- expect(getDeepActiveElement()).to.equal(focusableElements[0]);
117
+ expect(isActiveElement(focusableElements[0], { deep: true })).to.be.true;
117
118
 
118
119
  disconnect();
119
120
  });
@@ -127,7 +128,7 @@ describe('containFocus()', () => {
127
128
  focusableElements[focusableElements.length - 1].focus();
128
129
 
129
130
  simulateTabWithinContainFocus();
130
- expect(getDeepActiveElement()).to.equal(focusableElements[0]);
131
+ expect(isActiveElement(focusableElements[0], { deep: true })).to.be.true;
131
132
 
132
133
  disconnect();
133
134
  });
@@ -146,7 +147,7 @@ describe('containFocus()', () => {
146
147
  * actual tab key press. So the best we can do is if we didn't redirect focus
147
148
  * to the first element.
148
149
  */
149
- expect(getDeepActiveElement()).to.equal(focusableElements[2]);
150
+ expect(isActiveElement(focusableElements[2], { deep: true })).to.be.true;
150
151
 
151
152
  disconnect();
152
153
  });
@@ -158,9 +159,10 @@ describe('containFocus()', () => {
158
159
  const { disconnect } = containFocus(root);
159
160
 
160
161
  focusableElements[2].focus();
161
- expect(getDeepActiveElement()).to.equal(focusableElements[2]);
162
+ expect(isActiveElement(focusableElements[2], { deep: true })).to.be.true;
163
+
162
164
  document.body.click(); // this does not cause focusout event :( doesn't seem possible to mock
163
- expect(getDeepActiveElement()).to.equal(root);
165
+ expect(isActiveElement(root, { deep: true })).to.be.true;
164
166
 
165
167
  disconnect();
166
168
  });
@@ -185,11 +187,12 @@ describe('containFocus()', () => {
185
187
 
186
188
  // Simulate tab in window
187
189
  simulateTabInWindow(/** @type {HTMLElement} */ (document.getElementById('outside-1')));
188
- expect(getDeepActiveElement()).to.equal(focusableElements[0]);
190
+ expect(isActiveElement(focusableElements[0], { deep: true })).to.be.true;
189
191
 
190
192
  // Simulate shift+tab in window
191
193
  simulateTabInWindow(/** @type {HTMLElement} */ (document.getElementById('outside-2')));
192
- expect(getDeepActiveElement()).to.equal(focusableElements[focusableElements.length - 1]);
194
+ expect(isActiveElement(focusableElements[focusableElements.length - 1], { deep: true })).to.be
195
+ .true;
193
196
 
194
197
  disconnect();
195
198
  });
@@ -202,11 +205,12 @@ describe('containFocus()', () => {
202
205
 
203
206
  // Simulate tab in window
204
207
  simulateTabInWindow(/** @type {HTMLElement} */ (document.getElementById('outside-1')));
205
- expect(getDeepActiveElement()).to.equal(focusableElements[0]);
208
+ expect(isActiveElement(focusableElements[0], { deep: true })).to.be.true;
206
209
 
207
210
  // Simulate shift+tab in window
208
211
  simulateTabInWindow(/** @type {HTMLElement} */ (document.getElementById('outside-2')));
209
- expect(getDeepActiveElement()).to.equal(focusableElements[focusableElements.length - 1]);
212
+ expect(isActiveElement(focusableElements[focusableElements.length - 1], { deep: true })).to.be
213
+ .true;
210
214
 
211
215
  disconnect();
212
216
  });
@@ -219,11 +223,12 @@ describe('containFocus()', () => {
219
223
 
220
224
  // Simulate tab in window
221
225
  simulateTabInWindow(focusableElements[0]);
222
- expect(getDeepActiveElement()).to.equal(focusableElements[0]);
226
+ expect(isActiveElement(focusableElements[0], { deep: true })).to.be.true;
223
227
 
224
228
  // Simulate shift+tab in window
225
229
  simulateTabInWindow(focusableElements[focusableElements.length - 1]);
226
- expect(getDeepActiveElement()).to.equal(focusableElements[focusableElements.length - 1]);
230
+ expect(isActiveElement(focusableElements[focusableElements.length - 1], { deep: true })).to.be
231
+ .true;
227
232
 
228
233
  disconnect();
229
234
  });
@@ -1,30 +1,28 @@
1
- import { LitElement } from 'lit';
2
- import { LionOption } from '@lion/ui/listbox.js';
3
- import { OverlayController } from '@lion/ui/overlays.js';
4
- import { mimicClick } from '@lion/ui/overlays-test-helpers.js';
5
1
  import { LionSelectInvoker, LionSelectRich } from '@lion/ui/select-rich.js';
6
-
7
- import '@lion/ui/define/lion-option.js';
8
- import '@lion/ui/define/lion-listbox.js';
2
+ import { getSelectRichMembers } from '@lion/ui/select-rich-test-helpers.js';
3
+ import { mimicClick } from '@lion/ui/overlays-test-helpers.js';
4
+ import { OverlayController } from '@lion/ui/overlays.js';
5
+ import { LionOption } from '@lion/ui/listbox.js';
9
6
  import '@lion/ui/define/lion-select-rich.js';
7
+ import '@lion/ui/define/lion-listbox.js';
8
+ import '@lion/ui/define/lion-option.js';
9
+ import { LitElement } from 'lit';
10
10
  import {
11
+ fixture as _fixture,
12
+ unsafeStatic,
13
+ nextFrame,
11
14
  aTimeout,
12
15
  defineCE,
13
16
  expect,
14
- fixture as _fixture,
15
17
  html,
16
- nextFrame,
17
- unsafeStatic,
18
18
  } from '@open-wc/testing';
19
- import { getSelectRichMembers } from '@lion/ui/select-rich-test-helpers.js';
20
19
 
21
- /**
22
- * @typedef {import('../../listbox/src/LionOptions.js').LionOptions} LionOptions
23
- * @typedef {import('../../listbox/types/ListboxMixinTypes.js').ListboxHost} ListboxHost
24
- * @typedef {import('../../form-core/types/FormControlMixinTypes.js').FormControlHost} FormControlHost
25
- */
20
+ import { isActiveElement } from '../../core/test-helpers/isActiveElement.js';
26
21
 
27
22
  /**
23
+ * @typedef {import('../../form-core/types/FormControlMixinTypes.js').FormControlHost} FormControlHost
24
+ * @typedef {import('../../listbox/types/ListboxMixinTypes.js').ListboxHost} ListboxHost
25
+ * @typedef {import('../../listbox/src/LionOptions.js').LionOptions} LionOptions
28
26
  * @typedef {import('lit').TemplateResult} TemplateResult
29
27
  */
30
28
 
@@ -478,7 +476,7 @@ describe('lion-select-rich', () => {
478
476
 
479
477
  el.opened = true;
480
478
  await el.updateComplete;
481
- expect(document.activeElement).to.equal(_listboxNode);
479
+ expect(isActiveElement(_listboxNode)).to.be.true;
482
480
 
483
481
  el.opened = false;
484
482
  await el.updateComplete;
@@ -1,16 +1,17 @@
1
+ import { getFormControlMembers } from '@lion/ui/form-core-test-helpers.js';
1
2
  import { expect, fixture as _fixture } from '@open-wc/testing';
2
- import { html } from 'lit/static-html.js';
3
- import sinon from 'sinon';
4
3
  import { Validator } from '@lion/ui/form-core.js';
5
4
  import { LionSwitch } from '@lion/ui/switch.js';
6
- import { getFormControlMembers } from '@lion/ui/form-core-test-helpers.js';
7
-
5
+ import { html } from 'lit/static-html.js';
8
6
  import '@lion/ui/define/lion-switch.js';
7
+ import sinon from 'sinon';
8
+
9
+ import { isActiveElement } from '../../core/test-helpers/isActiveElement.js';
9
10
 
10
11
  /**
11
12
  * @typedef {import('../src/LionSwitchButton.js').LionSwitchButton} LionSwitchButton
12
- * @typedef {import('lit').TemplateResult} TemplateResult
13
13
  * @typedef {import('@lion/ui/types/form-core.js').FormControlHost} FormControlHost
14
+ * @typedef {import('lit').TemplateResult} TemplateResult
14
15
  */
15
16
 
16
17
  const IsTrue = class extends Validator {
@@ -60,7 +61,7 @@ describe('lion-switch', () => {
60
61
  const { _inputNode, _labelNode } = getSwitchMembers(el);
61
62
 
62
63
  _labelNode.click();
63
- expect(document.activeElement).to.equal(_inputNode);
64
+ expect(isActiveElement(_inputNode)).to.be.true;
64
65
  });
65
66
 
66
67
  it('clicking the label should not focus the toggle button when disabled', async () => {
@@ -1812,7 +1812,7 @@
1812
1812
  "name": "getDeepActiveElement",
1813
1813
  "declaration": {
1814
1814
  "name": "getDeepActiveElement",
1815
- "module": "../components/overlays/src/utils/get-deep-active-element.js"
1815
+ "module": "../components/core/src/getDeepActiveElement.js"
1816
1816
  }
1817
1817
  },
1818
1818
  {
@@ -1825,17 +1825,17 @@
1825
1825
  },
1826
1826
  {
1827
1827
  "kind": "js",
1828
- "name": "setSiblingsInert",
1828
+ "name": "unsetSiblingsInert",
1829
1829
  "declaration": {
1830
- "name": "setSiblingsInert",
1830
+ "name": "unsetSiblingsInert",
1831
1831
  "module": "../components/overlays/src/utils/inert-siblings.js"
1832
1832
  }
1833
1833
  },
1834
1834
  {
1835
1835
  "kind": "js",
1836
- "name": "unsetSiblingsInert",
1836
+ "name": "setSiblingsInert",
1837
1837
  "declaration": {
1838
- "name": "unsetSiblingsInert",
1838
+ "name": "setSiblingsInert",
1839
1839
  "module": "../components/overlays/src/utils/inert-siblings.js"
1840
1840
  }
1841
1841
  },
@@ -15291,6 +15291,21 @@
15291
15291
  },
15292
15292
  "privacy": "public"
15293
15293
  },
15294
+ {
15295
+ "kind": "method",
15296
+ "name": "#isMovingInDom",
15297
+ "privacy": "private",
15298
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
15299
+ "return": {
15300
+ "type": {
15301
+ "text": "Promise<boolean>"
15302
+ }
15303
+ },
15304
+ "inheritedFrom": {
15305
+ "name": "OverlayMixin",
15306
+ "module": "components/overlays/src/OverlayMixin.js"
15307
+ }
15308
+ },
15294
15309
  {
15295
15310
  "kind": "field",
15296
15311
  "name": "opened",
@@ -19632,6 +19647,21 @@
19632
19647
  },
19633
19648
  "privacy": "public"
19634
19649
  },
19650
+ {
19651
+ "kind": "method",
19652
+ "name": "#isMovingInDom",
19653
+ "privacy": "private",
19654
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
19655
+ "return": {
19656
+ "type": {
19657
+ "text": "Promise<boolean>"
19658
+ }
19659
+ },
19660
+ "inheritedFrom": {
19661
+ "name": "OverlayMixin",
19662
+ "module": "components/overlays/src/OverlayMixin.js"
19663
+ }
19664
+ },
19635
19665
  {
19636
19666
  "kind": "field",
19637
19667
  "name": "opened",
@@ -74364,6 +74394,21 @@
74364
74394
  },
74365
74395
  "privacy": "public"
74366
74396
  },
74397
+ {
74398
+ "kind": "method",
74399
+ "name": "#isMovingInDom",
74400
+ "privacy": "private",
74401
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
74402
+ "return": {
74403
+ "type": {
74404
+ "text": "Promise<boolean>"
74405
+ }
74406
+ },
74407
+ "inheritedFrom": {
74408
+ "name": "OverlayMixin",
74409
+ "module": "components/overlays/src/OverlayMixin.js"
74410
+ }
74411
+ },
74367
74412
  {
74368
74413
  "kind": "field",
74369
74414
  "name": "opened",
@@ -115096,6 +115141,11 @@
115096
115141
  "description": "Allows to dynamically change the overlay configuration. Needed in case the\npresentation of the overlay changes depending on screen size.\nNote that this method is the only allowed way to update a configuration of an\nOverlayController instance.",
115097
115142
  "privacy": "public"
115098
115143
  },
115144
+ {
115145
+ "kind": "method",
115146
+ "name": "#isRegisteredOnManager",
115147
+ "privacy": "private"
115148
+ },
115099
115149
  {
115100
115150
  "kind": "method",
115101
115151
  "name": "__validateConfiguration",
@@ -115838,6 +115888,17 @@
115838
115888
  "name": "repositionOverlay",
115839
115889
  "description": "Sometimes it's needed to recompute Popper position of an overlay, for instance when we have\nan opened combobox and the surrounding context changes (the space consumed by the textbox\nincreases vertically)"
115840
115890
  },
115891
+ {
115892
+ "kind": "method",
115893
+ "name": "#isMovingInDom",
115894
+ "privacy": "private",
115895
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
115896
+ "return": {
115897
+ "type": {
115898
+ "text": "Promise<boolean>"
115899
+ }
115900
+ }
115901
+ },
115841
115902
  {
115842
115903
  "kind": "field",
115843
115904
  "name": "opened",
@@ -116228,6 +116289,21 @@
116228
116289
  "module": "components/overlays/src/OverlayMixin.js"
116229
116290
  }
116230
116291
  },
116292
+ {
116293
+ "kind": "method",
116294
+ "name": "#isMovingInDom",
116295
+ "privacy": "private",
116296
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
116297
+ "return": {
116298
+ "type": {
116299
+ "text": "Promise<boolean>"
116300
+ }
116301
+ },
116302
+ "inheritedFrom": {
116303
+ "name": "OverlayMixin",
116304
+ "module": "components/overlays/src/OverlayMixin.js"
116305
+ }
116306
+ },
116231
116307
  {
116232
116308
  "kind": "field",
116233
116309
  "name": "opened",
@@ -116527,7 +116603,7 @@
116527
116603
  },
116528
116604
  {
116529
116605
  "kind": "javascript-module",
116530
- "path": "components/overlays/src/utils/get-deep-active-element.js",
116606
+ "path": "components/core/src/getDeepActiveElement.js",
116531
116607
  "declarations": [
116532
116608
  {
116533
116609
  "kind": "function",
@@ -116546,7 +116622,7 @@
116546
116622
  "name": "getDeepActiveElement",
116547
116623
  "declaration": {
116548
116624
  "name": "getDeepActiveElement",
116549
- "module": "components/overlays/src/utils/get-deep-active-element.js"
116625
+ "module": "components/core/src/getDeepActiveElement.js"
116550
116626
  }
116551
116627
  }
116552
116628
  ]
@@ -123891,6 +123967,21 @@
123891
123967
  },
123892
123968
  "privacy": "public"
123893
123969
  },
123970
+ {
123971
+ "kind": "method",
123972
+ "name": "#isMovingInDom",
123973
+ "privacy": "private",
123974
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
123975
+ "return": {
123976
+ "type": {
123977
+ "text": "Promise<boolean>"
123978
+ }
123979
+ },
123980
+ "inheritedFrom": {
123981
+ "name": "OverlayMixin",
123982
+ "module": "components/overlays/src/OverlayMixin.js"
123983
+ }
123984
+ },
123894
123985
  {
123895
123986
  "kind": "field",
123896
123987
  "name": "opened",
@@ -138053,6 +138144,21 @@
138053
138144
  },
138054
138145
  "privacy": "public"
138055
138146
  },
138147
+ {
138148
+ "kind": "method",
138149
+ "name": "#isMovingInDom",
138150
+ "privacy": "private",
138151
+ "description": "When we're moving around in dom, disconnectedCallback gets called.\nBefore we decide to teardown, let's wait to see if we were not just moving nodes around.",
138152
+ "return": {
138153
+ "type": {
138154
+ "text": "Promise<boolean>"
138155
+ }
138156
+ },
138157
+ "inheritedFrom": {
138158
+ "name": "OverlayMixin",
138159
+ "module": "components/overlays/src/OverlayMixin.js"
138160
+ }
138161
+ },
138056
138162
  {
138057
138163
  "kind": "field",
138058
138164
  "name": "opened",
@@ -142617,6 +142723,50 @@
142617
142723
  }
142618
142724
  ]
142619
142725
  },
142726
+ {
142727
+ "kind": "javascript-module",
142728
+ "path": "components/core/test-helpers/isActiveElement.js",
142729
+ "declarations": [
142730
+ {
142731
+ "kind": "function",
142732
+ "name": "isActiveElement",
142733
+ "parameters": [
142734
+ {
142735
+ "name": "el",
142736
+ "type": {
142737
+ "text": "Element"
142738
+ }
142739
+ },
142740
+ {
142741
+ "name": "{ deep = false }",
142742
+ "default": "{}"
142743
+ },
142744
+ {
142745
+ "name": "opts",
142746
+ "type": {
142747
+ "text": "{deep?: boolean}"
142748
+ }
142749
+ }
142750
+ ],
142751
+ "description": "Readable alternative for `expect(el).to.equal(document.activeElement);`.\nWhile this is readable by itself, it makes Web Test Runner hang completely in many occasions.\nTherefore it's better to write:\n`expect(isActiveElement(el)).to.be.true;`",
142752
+ "return": {
142753
+ "type": {
142754
+ "text": "boolean"
142755
+ }
142756
+ }
142757
+ }
142758
+ ],
142759
+ "exports": [
142760
+ {
142761
+ "kind": "js",
142762
+ "name": "isActiveElement",
142763
+ "declaration": {
142764
+ "name": "isActiveElement",
142765
+ "module": "components/core/test-helpers/isActiveElement.js"
142766
+ }
142767
+ }
142768
+ ]
142769
+ },
142620
142770
  {
142621
142771
  "kind": "javascript-module",
142622
142772
  "path": "components/form-core/src/utils/getAriaElementsInRightDomOrder.js",