@aurodesignsystem/auro-library 5.14.0 → 5.14.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/bin/generateDocs.mjs +4 -210
  3. package/bin/generateDocs_index.mjs +4 -210
  4. package/dist/_chunks/chunk-2MOEVVSZ.mjs +308 -0
  5. package/dist/_chunks/chunk-H7YO7ERJ.mjs +69 -0
  6. package/dist/_chunks/chunk-JLCAYVRX.mjs +84 -0
  7. package/dist/_chunks/chunk-RKBXVLA5.mjs +5983 -0
  8. package/dist/_chunks/chunk-TDFKN2EP.mjs +38 -0
  9. package/dist/_chunks/chunk-UY4SIQT6.mjs +201 -0
  10. package/dist/_chunks/chunk-V7YBXHAI.mjs +32379 -0
  11. package/dist/bin/generateDocs.mjs +152 -0
  12. package/dist/bin/generateDocs_index.mjs +152 -0
  13. package/dist/build/generateDocs.mjs +18 -0
  14. package/dist/build/generateReadme.mjs +49 -0
  15. package/dist/build/generateWcaComponent.mjs +6657 -0
  16. package/dist/build/processors/defaultDocsProcessor.mjs +16 -0
  17. package/dist/build/processors/defaultDotGithubSync.mjs +12 -0
  18. package/dist/build/syncGithubFiles.mjs +18 -0
  19. package/dist/utils/auroTemplateFiller.mjs +8 -0
  20. package/dist/utils/sharedFileProcessorUtils.mjs +31 -0
  21. package/package.json +10 -5
  22. package/scripts/build/generateDocs.mjs +4 -24
  23. package/scripts/build/generateReadme.mjs +4 -60
  24. package/scripts/build/generateWcaComponent.mjs +4 -43
  25. package/scripts/build/postinstall.mjs +10 -10
  26. package/scripts/build/pre-commit.mjs +13 -7
  27. package/scripts/build/processors/defaultDocsProcessor.mjs +4 -83
  28. package/scripts/build/processors/defaultDotGithubSync.mjs +4 -83
  29. package/scripts/build/syncGithubFiles.mjs +4 -25
  30. package/scripts/runtime/floatingUI.mjs +2 -1
  31. package/scripts/runtime/generateUUID/generateUUID.mjs +41 -0
  32. package/scripts/runtime/generateUUID/index.mjs +1 -0
  33. package/scripts/utils/ansiColors.mjs +119 -0
  34. package/scripts/utils/auroLibraryUtils.mjs +87 -51
  35. package/scripts/utils/auroTemplateFiller.mjs +4 -178
  36. package/scripts/utils/logger.mjs +27 -16
  37. package/scripts/utils/sharedFileProcessorUtils.mjs +4 -270
  38. package/scripts/build/deprecatedProseToFieldPlugin.spec.js +0 -188
  39. package/scripts/runtime/ClickTracker/test/ClickTracker.test.js +0 -424
  40. package/scripts/runtime/FocusTrap/test/FocusTrap.test.js +0 -168
  41. package/scripts/runtime/Focusables/test/Focusables.test.js +0 -185
  42. package/scripts/runtime/dateUtilities/dateFormatter.test.js +0 -284
  43. package/scripts/runtime/dateUtilities/dateUtilities.test.js +0 -80
  44. package/scripts/runtime/floatingUI/test/floatingUI.test.js +0 -189
  45. package/scripts/runtime/floatingUI.test.js +0 -478
@@ -1,189 +0,0 @@
1
- import { expect } from "@open-wc/testing";
2
- import { html, render } from "lit";
3
- import sinon from "sinon";
4
- import AuroFloatingUI from "../../floatingUI.mjs";
5
-
6
- async function fixture(template) {
7
- const wrapper = document.createElement("div");
8
- render(template, wrapper);
9
- document.body.appendChild(wrapper);
10
- await new Promise((resolve) => setTimeout(resolve, 0));
11
- return wrapper.firstElementChild;
12
- }
13
-
14
- /**
15
- * Builds a minimal element stub that satisfies the properties AuroFloatingUI
16
- * reads during configure() and keyboard event handling.
17
- */
18
- function makeElement(trigger, bib) {
19
- return {
20
- trigger,
21
- bib,
22
- bibSizer: null,
23
- triggerChevron: null,
24
- shadowRoot: {
25
- querySelector: () => null,
26
- append: () => {},
27
- },
28
- behavior: "dropdown",
29
- disabled: false,
30
- isPopoverVisible: false,
31
- showing: false,
32
- noToggle: false,
33
- modal: false,
34
- disableEventShow: false,
35
- hoverToggle: false,
36
- focusShow: false,
37
- floaterConfig: null,
38
- cleanup: null,
39
- contains: () => false,
40
- dispatchEvent: () => {},
41
- getAttribute: () => null,
42
- setAttribute: () => {},
43
- querySelectorAll: () => [],
44
- style: {},
45
- };
46
- }
47
-
48
- describe("AuroFloatingUI keyboard gate (enableKeyboardHandling)", () => {
49
- let triggerEl;
50
- let bibEl;
51
- let elem;
52
- let floatingUi;
53
-
54
- beforeEach(async () => {
55
- triggerEl = await fixture(html`<button id="trigger">Toggle</button>`);
56
- bibEl = await fixture(html`<div id="bib"></div>`);
57
-
58
- elem = makeElement(triggerEl, bibEl);
59
- floatingUi = new AuroFloatingUI(elem, "dropdown");
60
- });
61
-
62
- afterEach(async () => {
63
- // Let any setTimeout(0) handlers (e.g. click listener setup in setupHideHandlers)
64
- // fire before cleanup so cleanupHideHandlers can remove them.
65
- await new Promise((resolve) => setTimeout(resolve, 10));
66
- document.expandedAuroFloater = null;
67
- document.expandedAuroFormkitDropdown = null;
68
- floatingUi?.disconnect();
69
- floatingUi = null;
70
- triggerEl?.parentNode?.remove();
71
- bibEl?.parentNode?.remove();
72
- sinon.restore();
73
- });
74
-
75
- describe("default behavior (enableKeyboardHandling = true)", () => {
76
- beforeEach(() => {
77
- floatingUi.configure(elem, "auro-dropdown", true);
78
- });
79
-
80
- it("Enter on the trigger calls handleClick()", () => {
81
- const spy = sinon.spy(floatingUi, "handleClick");
82
- triggerEl.dispatchEvent(
83
- new KeyboardEvent("keydown", {
84
- key: "Enter",
85
- bubbles: true,
86
- composed: true,
87
- }),
88
- );
89
- expect(spy.calledOnce).to.be.true;
90
- });
91
-
92
- it("Space on the trigger calls handleClick()", () => {
93
- const spy = sinon.spy(floatingUi, "handleClick");
94
- triggerEl.dispatchEvent(
95
- new KeyboardEvent("keydown", {
96
- key: " ",
97
- bubbles: true,
98
- composed: true,
99
- }),
100
- );
101
- expect(spy.calledOnce).to.be.true;
102
- });
103
-
104
- it("Escape dismisses when bib is visible", () => {
105
- elem.isPopoverVisible = true;
106
- floatingUi.showing = true;
107
- document.expandedAuroFloater = floatingUi;
108
- const spy = sinon.spy(floatingUi, "hideBib");
109
-
110
- // setupHideHandlers attaches the document keydown listener
111
- floatingUi.setupHideHandlers();
112
- document.dispatchEvent(
113
- new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
114
- );
115
-
116
- expect(spy.calledOnce).to.be.true;
117
- document.expandedAuroFloater = null;
118
- });
119
- });
120
-
121
- describe("keyboard disabled (enableKeyboardHandling = false)", () => {
122
- beforeEach(() => {
123
- floatingUi.configure(elem, "auro-dropdown", false);
124
- });
125
-
126
- it("Enter on the trigger does NOT call handleClick()", () => {
127
- const spy = sinon.spy(floatingUi, "handleClick");
128
- triggerEl.dispatchEvent(
129
- new KeyboardEvent("keydown", {
130
- key: "Enter",
131
- bubbles: true,
132
- composed: true,
133
- }),
134
- );
135
- expect(spy.called).to.be.false;
136
- });
137
-
138
- it("Space on the trigger does NOT call handleClick()", () => {
139
- const spy = sinon.spy(floatingUi, "handleClick");
140
- triggerEl.dispatchEvent(
141
- new KeyboardEvent("keydown", {
142
- key: " ",
143
- bubbles: true,
144
- composed: true,
145
- }),
146
- );
147
- expect(spy.called).to.be.false;
148
- });
149
-
150
- it("Escape does NOT dismiss the bib", () => {
151
- elem.isPopoverVisible = true;
152
- floatingUi.showing = true;
153
- document.expandedAuroFloater = floatingUi;
154
- const spy = sinon.spy(floatingUi, "hideBib");
155
-
156
- // setupHideHandlers should skip attaching the document keydown listener
157
- floatingUi.setupHideHandlers();
158
- document.dispatchEvent(
159
- new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
160
- );
161
-
162
- expect(spy.called).to.be.false;
163
- document.expandedAuroFloater = null;
164
- });
165
-
166
- it("click on the trigger still calls handleClick()", () => {
167
- const spy = sinon.spy(floatingUi, "handleClick");
168
- triggerEl.dispatchEvent(
169
- new MouseEvent("click", { bubbles: true, composed: true }),
170
- );
171
- expect(spy.calledOnce).to.be.true;
172
- });
173
- });
174
-
175
- describe("default argument", () => {
176
- it("omitting enableKeyboardHandling defaults to true (Enter still works)", () => {
177
- floatingUi.configure(elem, "auro-dropdown");
178
- const spy = sinon.spy(floatingUi, "handleClick");
179
- triggerEl.dispatchEvent(
180
- new KeyboardEvent("keydown", {
181
- key: "Enter",
182
- bubbles: true,
183
- composed: true,
184
- }),
185
- );
186
- expect(spy.calledOnce).to.be.true;
187
- });
188
- });
189
- });
@@ -1,478 +0,0 @@
1
- import { expect } from "@open-wc/testing";
2
- import sinon from "sinon";
3
- import AuroFloatingUI from "./floatingUI.mjs";
4
-
5
- describe("AuroFloatingUI", () => {
6
- let host;
7
- let bib;
8
- let floatingUI;
9
- let hideBibSpy;
10
-
11
- beforeEach(() => {
12
- host = document.createElement("div");
13
- bib = document.createElement("div");
14
- host.bib = bib;
15
- host.triggerChevron = document.createElement("span");
16
-
17
- document.body.append(host, bib);
18
-
19
- AuroFloatingUI.isMousePressed = false;
20
- floatingUI = new AuroFloatingUI(host, "dropdown");
21
- hideBibSpy = sinon.spy(floatingUI, "hideBib");
22
- });
23
-
24
- afterEach(() => {
25
- sinon.restore();
26
- AuroFloatingUI.isMousePressed = false;
27
- host?.remove();
28
- bib?.remove();
29
- });
30
-
31
- it("does not hide when the host matches focus-within", () => {
32
- const checkedSelectors = [];
33
-
34
- sinon.stub(host, "matches").callsFake((selector) => {
35
- checkedSelectors.push(selector);
36
-
37
- if (selector === ":focus") {
38
- return false;
39
- }
40
-
41
- if (selector === ":focus-within") {
42
- return true;
43
- }
44
-
45
- return false;
46
- });
47
-
48
- floatingUI.handleFocusLoss();
49
-
50
- expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
51
- expect(hideBibSpy.called).to.be.false;
52
- });
53
-
54
- it("does not hide when the host matches focus", () => {
55
- const checkedSelectors = [];
56
-
57
- sinon.stub(host, "matches").callsFake((selector) => {
58
- checkedSelectors.push(selector);
59
-
60
- if (selector === ":focus") {
61
- return true;
62
- }
63
-
64
- return false;
65
- });
66
-
67
- floatingUI.handleFocusLoss();
68
-
69
- expect(checkedSelectors).to.deep.equal([":focus"]);
70
- expect(hideBibSpy.called).to.be.false;
71
- });
72
-
73
- it("does not hide when the bib is fullscreen", () => {
74
- const checkedSelectors = [];
75
-
76
- bib.setAttribute("isfullscreen", "");
77
-
78
- sinon.stub(host, "matches").callsFake((selector) => {
79
- checkedSelectors.push(selector);
80
- return false;
81
- });
82
-
83
- floatingUI.handleFocusLoss();
84
-
85
- expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
86
- expect(hideBibSpy.called).to.be.false;
87
- });
88
-
89
- it("hides with a focus loss event when the host no longer has focus", () => {
90
- const checkedSelectors = [];
91
-
92
- sinon.stub(host, "matches").callsFake((selector) => {
93
- checkedSelectors.push(selector);
94
- return false;
95
- });
96
-
97
- floatingUI.handleFocusLoss();
98
-
99
- expect(checkedSelectors).to.deep.equal([":focus", ":focus-within"]);
100
- expect(hideBibSpy.calledOnceWithExactly("focusloss")).to.be.true;
101
- });
102
-
103
- it("no-ops safely when element is not set", () => {
104
- floatingUI.element = null;
105
-
106
- expect(() => floatingUI.showBib()).to.not.throw();
107
- expect(() => floatingUI.hideBib()).to.not.throw();
108
- expect(() => floatingUI.handleClick()).to.not.throw();
109
- expect(() => floatingUI.handleEvent(new Event("click"))).to.not.throw();
110
- expect(() => floatingUI.handleFocusLoss()).to.not.throw();
111
- expect(() => floatingUI.updateState()).to.not.throw();
112
- expect(() => floatingUI.configureBibStrategy("floating")).to.not.throw();
113
- expect(() => floatingUI.position()).to.not.throw();
114
- });
115
-
116
- it("does not enter a visible state when required DOM nodes are missing", () => {
117
- host.bib = null;
118
- host.isPopoverVisible = false;
119
-
120
- floatingUI.showBib();
121
-
122
- expect(floatingUI.showing).to.equal(false);
123
- expect(host.isPopoverVisible).to.equal(false);
124
- expect(document.expandedAuroFloater).to.not.equal(floatingUI);
125
- });
126
-
127
- it("returns an explicit positioning strategy when element is not set", () => {
128
- floatingUI.element = null;
129
-
130
- expect(floatingUI.getPositioningStrategy()).to.equal("floating");
131
- });
132
-
133
- it("restores pre-existing inline scroll styles after lock/unlock", () => {
134
- document.documentElement.style.scrollbarGutter = "auto";
135
- document.documentElement.style.overflow = "clip";
136
- document.body.style.overflow = "scroll";
137
- document.body.style.position = "sticky";
138
- document.body.style.top = "12px";
139
- document.body.style.width = "75%";
140
- const scrollToStub = sinon.stub(window, "scrollTo");
141
-
142
- floatingUI.lockScroll(true);
143
-
144
- expect(document.documentElement.style.scrollbarGutter).to.equal("stable");
145
- expect(document.documentElement.style.overflow).to.equal("hidden");
146
- expect(document.body.style.overflow).to.equal("hidden");
147
- expect(document.body.style.position).to.equal("fixed");
148
- expect(document.body.style.width).to.equal("100%");
149
-
150
- floatingUI.lockScroll(false);
151
-
152
- expect(document.documentElement.style.scrollbarGutter).to.equal("auto");
153
- expect(document.documentElement.style.overflow).to.equal("clip");
154
- expect(document.body.style.overflow).to.equal("scroll");
155
- expect(document.body.style.position).to.equal("sticky");
156
- expect(document.body.style.top).to.equal("12px");
157
- expect(document.body.style.width).to.equal("75%");
158
- expect(scrollToStub.calledOnceWithExactly(0, 0)).to.be.true;
159
- expect(floatingUI._boundTouchMoveHandler).to.equal(undefined);
160
- });
161
-
162
- it("prevents touch scroll when gesture is outside scrollable content", () => {
163
- floatingUI.lockTouchScroll(true);
164
-
165
- const preventDefault = sinon.spy();
166
- floatingUI._boundTouchMoveHandler({
167
- composedPath: () => [document.body],
168
- preventDefault,
169
- });
170
-
171
- expect(preventDefault.calledOnce).to.be.true;
172
- });
173
-
174
- it("allows touch scroll when gesture is inside scrollable content", () => {
175
- floatingUI.lockTouchScroll(true);
176
-
177
- const scrollable = document.createElement("div");
178
- Object.defineProperty(scrollable, "scrollHeight", {
179
- configurable: true,
180
- value: 200,
181
- });
182
- Object.defineProperty(scrollable, "clientHeight", {
183
- configurable: true,
184
- value: 100,
185
- });
186
-
187
- const preventDefault = sinon.spy();
188
- floatingUI._boundTouchMoveHandler({
189
- composedPath: () => [scrollable],
190
- preventDefault,
191
- });
192
-
193
- expect(preventDefault.called).to.be.false;
194
- });
195
- it("lockScroll sets _scrollLocked flag when locking", () => {
196
- floatingUI.lockScroll(true);
197
- expect(floatingUI._scrollLocked).to.be.true;
198
- floatingUI.lockScroll(false);
199
- expect(floatingUI._scrollLocked).to.be.false;
200
- });
201
-
202
- it("lockScroll saves scroll position when locking", () => {
203
- const originalScrollY = window.scrollY;
204
- floatingUI.lockScroll(true);
205
- expect(floatingUI._savedScrollY).to.equal(originalScrollY);
206
- });
207
-
208
- it("lockScroll restores scroll position when unlocking", () => {
209
- floatingUI.lockScroll(true);
210
- window.scrollTo(0, 500);
211
- floatingUI.lockScroll(false);
212
- // Note: scrollTo may not work in test environment, but the restoration logic is in place
213
- expect(floatingUI._scrollLocked).to.be.false;
214
- });
215
-
216
- it("lockTouchScroll creates event handler when locking", () => {
217
- expect(floatingUI._boundTouchMoveHandler).to.be.undefined;
218
- floatingUI.lockTouchScroll(true);
219
- expect(floatingUI._boundTouchMoveHandler).to.be.a("function");
220
- });
221
-
222
- it("lockTouchScroll removes event handler when unlocking", () => {
223
- floatingUI.lockTouchScroll(true);
224
- floatingUI.lockTouchScroll(false);
225
- expect(floatingUI._boundTouchMoveHandler).to.be.undefined;
226
- });
227
-
228
- it("lockTouchScroll prevents default on non-scrollable elements", () => {
229
- floatingUI.lockTouchScroll(true);
230
- const nonScrollable = document.createElement("div");
231
- const preventDefault = sinon.spy();
232
- const touchEvent = {
233
- composedPath: () => [nonScrollable],
234
- preventDefault,
235
- };
236
- floatingUI._boundTouchMoveHandler(touchEvent);
237
- expect(preventDefault.called).to.be.true;
238
- });
239
-
240
- it("lockTouchScroll allows touchmove on scrollable elements", () => {
241
- floatingUI.lockTouchScroll(true);
242
- const scrollable = document.createElement("div");
243
- Object.defineProperty(scrollable, "scrollHeight", {
244
- configurable: true,
245
- value: 200,
246
- });
247
- Object.defineProperty(scrollable, "clientHeight", {
248
- configurable: true,
249
- value: 100,
250
- });
251
- const preventDefault = sinon.spy();
252
- const touchEvent = {
253
- composedPath: () => [scrollable],
254
- preventDefault,
255
- };
256
- floatingUI._boundTouchMoveHandler(touchEvent);
257
- expect(preventDefault.called).to.be.false;
258
- });
259
-
260
- it("configureBibStrategy sets isfullscreen attribute for fullscreen", () => {
261
- host.bib = bib;
262
- host.isPopoverVisible = false;
263
- floatingUI.configureBibStrategy("fullscreen");
264
- expect(bib.getAttribute("isfullscreen")).to.equal("");
265
- expect(host.isBibFullscreen).to.be.true;
266
- });
267
-
268
- it("configureBibStrategy removes isfullscreen attribute for floating", () => {
269
- host.bib = bib;
270
- bib.setAttribute("isfullscreen", "");
271
- host.isBibFullscreen = true;
272
- floatingUI.configureBibStrategy("floating");
273
- expect(bib.hasAttribute("isfullscreen")).to.be.false;
274
- expect(host.isBibFullscreen).to.be.false;
275
- });
276
-
277
- it("getPositioningStrategy returns 'dialog' for dialog behavior without breakpoint", () => {
278
- floatingUI.behavior = "dialog";
279
- host.floaterConfig = {};
280
- const strategy = floatingUI.getPositioningStrategy();
281
- expect(strategy).to.equal("dialog");
282
- });
283
-
284
- it("getPositioningStrategy returns 'floating' for undefined behavior", () => {
285
- floatingUI.behavior = undefined;
286
- host.floaterConfig = {};
287
- const strategy = floatingUI.getPositioningStrategy();
288
- expect(strategy).to.equal("floating");
289
- });
290
-
291
- it("getPositioningStrategy returns 'floating' when element is missing", () => {
292
- floatingUI.element = null;
293
- const strategy = floatingUI.getPositioningStrategy();
294
- expect(strategy).to.equal("floating");
295
- });
296
- });
297
-
298
- describe("AuroFloatingUI modal Escape suppression (AB#1613688)", () => {
299
- let host;
300
- let bib;
301
- let floatingUI;
302
- let hideBibSpy;
303
-
304
- beforeEach(() => {
305
- host = document.createElement("div");
306
- bib = document.createElement("div");
307
- host.bib = bib;
308
- host.modal = true;
309
- host.isPopoverVisible = false;
310
- host.triggerChevron = document.createElement("span");
311
- document.body.append(host, bib);
312
-
313
- AuroFloatingUI.openingQueue = [];
314
- document.expandedAuroFloater = null;
315
-
316
- floatingUI = new AuroFloatingUI(host, "dialog");
317
- hideBibSpy = sinon.spy(floatingUI, "hideBib");
318
- });
319
-
320
- afterEach(() => {
321
- floatingUI.cleanupHideHandlers();
322
- sinon.restore();
323
- AuroFloatingUI.isMousePressed = false;
324
- AuroFloatingUI.openingQueue = [];
325
- document.expandedAuroFloater = null;
326
- host?.remove();
327
- bib?.remove();
328
- });
329
-
330
- it("registers a keydown handler and skips setupHideHandlers when modal=true", () => {
331
- const setupHideHandlersSpy = sinon.spy(floatingUI, "setupHideHandlers");
332
-
333
- floatingUI.showBib();
334
-
335
- expect(setupHideHandlersSpy.called).to.be.false;
336
- expect(floatingUI.keyDownHandler).to.be.a("function");
337
- expect(floatingUI.showing).to.be.true;
338
- });
339
-
340
- it("does not call hideBib when Escape is pressed while modal dialog is open", () => {
341
- floatingUI.showBib();
342
-
343
- document.dispatchEvent(
344
- new KeyboardEvent("keydown", {
345
- key: "Escape",
346
- bubbles: true,
347
- cancelable: true,
348
- }),
349
- );
350
-
351
- expect(hideBibSpy.called).to.be.false;
352
- });
353
-
354
- it("calls preventDefault on Escape keydown while modal dialog is open", () => {
355
- floatingUI.showBib();
356
-
357
- const escEvent = new KeyboardEvent("keydown", {
358
- key: "Escape",
359
- bubbles: true,
360
- cancelable: true,
361
- });
362
- const preventDefaultSpy = sinon.spy(escEvent, "preventDefault");
363
- document.dispatchEvent(escEvent);
364
-
365
- expect(preventDefaultSpy.calledOnce).to.be.true;
366
- });
367
-
368
- it("removes the modal Escape keydown handler via cleanupHideHandlers", () => {
369
- floatingUI.showBib();
370
- expect(floatingUI.keyDownHandler).to.be.a("function");
371
-
372
- floatingUI.cleanupHideHandlers();
373
- expect(floatingUI.keyDownHandler).to.be.null;
374
- });
375
- });
376
-
377
- describe("AuroFloatingUI.openingQueue and topOpeningFloatingUI", () => {
378
- let floatingUI1;
379
- let floatingUI2;
380
- let floatingUI3;
381
- let host1;
382
- let host2;
383
- let host3;
384
- let bib1;
385
- let bib2;
386
- let bib3;
387
-
388
- beforeEach(() => {
389
- AuroFloatingUI.openingQueue = [];
390
- document.expandedAuroFormkitDropdown = null;
391
- document.expandedAuroFloater = null;
392
-
393
- host1 = document.createElement("div");
394
- bib1 = document.createElement("div");
395
- host1.bib = bib1;
396
- host1.isPopoverVisible = false;
397
- document.body.append(host1, bib1);
398
- floatingUI1 = new AuroFloatingUI(host1, "dropdown");
399
-
400
- host2 = document.createElement("div");
401
- bib2 = document.createElement("div");
402
- host2.bib = bib2;
403
- host2.isPopoverVisible = false;
404
- document.body.append(host2, bib2);
405
- floatingUI2 = new AuroFloatingUI(host2, "dropdown");
406
-
407
- host3 = document.createElement("div");
408
- bib3 = document.createElement("div");
409
- host3.bib = bib3;
410
- host3.isPopoverVisible = false;
411
- document.body.append(host3, bib3);
412
- floatingUI3 = new AuroFloatingUI(host3, "dropdown");
413
- });
414
-
415
- afterEach(() => {
416
- AuroFloatingUI.openingQueue = [];
417
- document.expandedAuroFormkitDropdown = null;
418
- document.expandedAuroFloater = null;
419
- host1?.remove();
420
- host2?.remove();
421
- host3?.remove();
422
- bib1?.remove();
423
- bib2?.remove();
424
- bib3?.remove();
425
- sinon.restore();
426
- });
427
-
428
- it("can add instances to openingQueue", () => {
429
- AuroFloatingUI.openingQueue.push(floatingUI1);
430
- expect(AuroFloatingUI.openingQueue).to.include(floatingUI1);
431
- expect(AuroFloatingUI.openingQueue.length).to.equal(1);
432
- });
433
-
434
- it("maintains insertion order in openingQueue", () => {
435
- AuroFloatingUI.openingQueue.push(floatingUI1);
436
- AuroFloatingUI.openingQueue.push(floatingUI2);
437
- expect(AuroFloatingUI.openingQueue[0]).to.equal(floatingUI1);
438
- expect(AuroFloatingUI.openingQueue[1]).to.equal(floatingUI2);
439
- });
440
-
441
- it("can remove instances from openingQueue", () => {
442
- AuroFloatingUI.openingQueue.push(floatingUI1);
443
- AuroFloatingUI.openingQueue.push(floatingUI2);
444
- const index = AuroFloatingUI.openingQueue.indexOf(floatingUI1);
445
- AuroFloatingUI.openingQueue.splice(index, 1);
446
- expect(AuroFloatingUI.openingQueue).to.not.include(floatingUI1);
447
- expect(AuroFloatingUI.openingQueue).to.include(floatingUI2);
448
- });
449
-
450
- it("topOpeningFloatingUI returns global reference when visible", () => {
451
- document.expandedAuroFloater = floatingUI1;
452
- floatingUI1.element.isPopoverVisible = true;
453
- const topUI = AuroFloatingUI.topOpeningFloatingUI;
454
- expect(topUI).to.equal(floatingUI1);
455
- });
456
-
457
- it("topOpeningFloatingUI returns queue last entry when global ref is stale", () => {
458
- document.expandedAuroFloater = floatingUI1;
459
- floatingUI1.element.isPopoverVisible = false;
460
- AuroFloatingUI.openingQueue.push(floatingUI2);
461
- floatingUI2.element.isPopoverVisible = true;
462
- const topUI = AuroFloatingUI.topOpeningFloatingUI;
463
- expect(topUI).to.equal(floatingUI2);
464
- });
465
-
466
- it("topOpeningFloatingUI returns last entry from queue", () => {
467
- AuroFloatingUI.openingQueue.push(floatingUI1);
468
- AuroFloatingUI.openingQueue.push(floatingUI2);
469
- AuroFloatingUI.openingQueue.push(floatingUI3);
470
- const topUI = AuroFloatingUI.topOpeningFloatingUI;
471
- expect(topUI).to.equal(floatingUI3);
472
- });
473
-
474
- it("topOpeningFloatingUI returns null when queue is empty", () => {
475
- const topUI = AuroFloatingUI.topOpeningFloatingUI;
476
- expect(topUI).to.be.null;
477
- });
478
- });