@content-blocks/js 0.7.0 → 0.7.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 (113) hide show
  1. package/dist/cjs/content-accordion_11.cjs.entry.js +45 -1545
  2. package/dist/cjs/content-accordion_11.cjs.entry.js.map +1 -1
  3. package/dist/cjs/content-blocks.cjs.js +1 -1
  4. package/dist/cjs/content-carousel.cjs.entry.js +6 -5
  5. package/dist/cjs/content-carousel.cjs.entry.js.map +1 -1
  6. package/dist/cjs/content-navigation-block.cjs.entry.js +41 -24
  7. package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -1
  8. package/dist/cjs/focus-trap.esm-a1e3774c.js +1509 -0
  9. package/dist/cjs/focus-trap.esm-a1e3774c.js.map +1 -0
  10. package/dist/cjs/index-f38d389e.js +5224 -0
  11. package/dist/cjs/index-f38d389e.js.map +1 -0
  12. package/dist/cjs/loader.cjs.js +1 -1
  13. package/dist/cjs/{swiper-4fade542.js → swiper-e5a68ae2.js} +68 -469
  14. package/dist/cjs/swiper-e5a68ae2.js.map +1 -0
  15. package/dist/cjs/utils-c04e978e.js +457 -0
  16. package/dist/cjs/utils-c04e978e.js.map +1 -0
  17. package/dist/cjs/window-resize-service-ac5c2012.js.map +1 -1
  18. package/dist/collection/components/content-carousel/content-carousel.js +5 -4
  19. package/dist/collection/components/content-carousel/content-carousel.js.map +1 -1
  20. package/dist/collection/components/content-navigation-block/content-navigation-block.css +55 -13
  21. package/dist/collection/components/content-navigation-block/content-navigation-block.js +51 -24
  22. package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -1
  23. package/dist/collection/components/content-overlay/content-overlay.css +11 -6
  24. package/dist/collection/components/content-overlay/content-overlay.js +69 -34
  25. package/dist/collection/components/content-overlay/content-overlay.js.map +1 -1
  26. package/dist/collection/elements/content-image/content-image.js +4 -4
  27. package/dist/collection/elements/content-image/content-image.js.map +1 -1
  28. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.css +4 -3
  29. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js +37 -0
  30. package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +1 -1
  31. package/dist/collection/formatters/content-spacer/content-spacer.css +3 -4
  32. package/dist/collection/formatters/content-spacer/content-spacer.js +13 -5
  33. package/dist/collection/formatters/content-spacer/content-spacer.js.map +1 -1
  34. package/dist/collection/services/window-resize-service.js.map +1 -1
  35. package/dist/collection/stories/ContentNavigationBlock.stories.js +1 -1
  36. package/dist/collection/stories/ContentNavigationBlock.stories.js.map +1 -1
  37. package/dist/collection/stories/ContentTextBlock.stories.js +5 -5
  38. package/dist/collection/stories/ContentTextBlock.stories.js.map +1 -1
  39. package/dist/collection/stories/FullPageExample.stories.js +164 -214
  40. package/dist/collection/stories/FullPageExample.stories.js.map +1 -1
  41. package/dist/components/content-carousel.js +5 -4
  42. package/dist/components/content-carousel.js.map +1 -1
  43. package/dist/components/content-grid-formatter2.js +9 -1
  44. package/dist/components/content-grid-formatter2.js.map +1 -1
  45. package/dist/components/content-image.js +4 -4
  46. package/dist/components/content-image.js.map +1 -1
  47. package/dist/components/content-navigation-block.js +48 -25
  48. package/dist/components/content-navigation-block.js.map +1 -1
  49. package/dist/components/content-overlay.js +32 -1538
  50. package/dist/components/content-overlay.js.map +1 -1
  51. package/dist/components/content-spacer.js +3 -3
  52. package/dist/components/content-spacer.js.map +1 -1
  53. package/dist/components/focus-trap.esm.js +1507 -0
  54. package/dist/components/focus-trap.esm.js.map +1 -0
  55. package/dist/components/index2.js +5200 -0
  56. package/dist/components/index2.js.map +1 -0
  57. package/dist/components/swiper.js +1 -402
  58. package/dist/components/swiper.js.map +1 -1
  59. package/dist/components/utils2.js +433 -0
  60. package/dist/components/utils2.js.map +1 -0
  61. package/dist/components/window-resize-service.js.map +1 -1
  62. package/dist/content-blocks/content-blocks.esm.js +1 -1
  63. package/dist/content-blocks/content-blocks.esm.js.map +1 -1
  64. package/dist/content-blocks/p-75ac85e9.js +2 -0
  65. package/dist/content-blocks/p-75ac85e9.js.map +1 -0
  66. package/dist/content-blocks/p-7ff352fe.entry.js +2 -0
  67. package/dist/content-blocks/p-7ff352fe.entry.js.map +1 -0
  68. package/dist/content-blocks/p-878dc806.js +10 -0
  69. package/dist/content-blocks/p-878dc806.js.map +1 -0
  70. package/dist/content-blocks/p-97c4ca9d.js +2 -0
  71. package/dist/content-blocks/p-97c4ca9d.js.map +1 -0
  72. package/dist/content-blocks/{p-271fb304.entry.js → p-cbc1dd73.entry.js} +2 -2
  73. package/dist/content-blocks/p-cbc1dd73.entry.js.map +1 -0
  74. package/dist/content-blocks/p-cfb4593f.js.map +1 -1
  75. package/dist/content-blocks/p-e2907508.js +2 -0
  76. package/dist/content-blocks/p-e2907508.js.map +1 -0
  77. package/dist/content-blocks/p-ef45f146.entry.js +2 -0
  78. package/dist/content-blocks/p-ef45f146.entry.js.map +1 -0
  79. package/dist/esm/content-accordion_11.entry.js +45 -1545
  80. package/dist/esm/content-accordion_11.entry.js.map +1 -1
  81. package/dist/esm/content-blocks.js +1 -1
  82. package/dist/esm/content-carousel.entry.js +6 -5
  83. package/dist/esm/content-carousel.entry.js.map +1 -1
  84. package/dist/esm/content-navigation-block.entry.js +41 -24
  85. package/dist/esm/content-navigation-block.entry.js.map +1 -1
  86. package/dist/esm/focus-trap.esm-49c9613c.js +1507 -0
  87. package/dist/esm/focus-trap.esm-49c9613c.js.map +1 -0
  88. package/dist/esm/index-d9f353de.js +5200 -0
  89. package/dist/esm/index-d9f353de.js.map +1 -0
  90. package/dist/esm/loader.js +1 -1
  91. package/dist/esm/{swiper-3e7be625.js → swiper-3394f7fd.js} +2 -403
  92. package/dist/esm/swiper-3394f7fd.js.map +1 -0
  93. package/dist/esm/utils-075121ec.js +433 -0
  94. package/dist/esm/utils-075121ec.js.map +1 -0
  95. package/dist/esm/window-resize-service-f40ec51c.js.map +1 -1
  96. package/dist/types/components/content-carousel/content-carousel.d.ts +3 -3
  97. package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +11 -0
  98. package/dist/types/components/content-overlay/content-overlay.d.ts +9 -0
  99. package/dist/types/components.d.ts +34 -2
  100. package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +8 -1
  101. package/dist/types/formatters/content-spacer/content-spacer.d.ts +2 -1
  102. package/dist/types/stories/ContentNavigationBlock.stories.d.ts +1 -3
  103. package/dist/types/stories/ContentTextBlock.stories.d.ts +1 -7
  104. package/package.json +2 -2
  105. package/dist/cjs/swiper-4fade542.js.map +0 -1
  106. package/dist/content-blocks/p-10819bfa.js +0 -2
  107. package/dist/content-blocks/p-10819bfa.js.map +0 -1
  108. package/dist/content-blocks/p-24657e66.entry.js +0 -10
  109. package/dist/content-blocks/p-24657e66.entry.js.map +0 -1
  110. package/dist/content-blocks/p-271fb304.entry.js.map +0 -1
  111. package/dist/content-blocks/p-6a177aef.entry.js +0 -2
  112. package/dist/content-blocks/p-6a177aef.entry.js.map +0 -1
  113. package/dist/esm/swiper-3e7be625.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-e848c048.js';
2
2
  import { W as WindowResizeService } from './window-resize-service-f40ec51c.js';
3
3
  import { g as getCurrentValue } from './utils-4f78228e.js';
4
+ import { c as createFocusTrap } from './focus-trap.esm-49c9613c.js';
4
5
  import './BehaviorSubject-bc7e0e99.js';
5
6
 
6
7
  const contentAccordionCss = "*{box-sizing:border-box}content-accordion{display:block}content-accordion>button{display:block;width:100%;padding:0;border:none;font:inherit;color:inherit;background-color:transparent;cursor:pointer}content-accordion[expanded]>.content-accordion__reveal{display:block}content-accordion>.content-accordion__reveal{display:none}";
@@ -114,7 +115,7 @@ const ContentButton = class {
114
115
  };
115
116
  ContentButton.style = contentButtonCss;
116
117
 
117
- const contentGridFormatterCss = "*{box-sizing:border-box}content-grid-formatter{width:100%;overflow:auto}content-grid-formatter *{box-sizing:border-box}content-grid-formatter[type=grid]{display:grid;grid-template-columns:repeat(var(--columns), 1fr);column-gap:var(--column-gap)}content-grid-formatter[type=flex]{display:flex;align-items:var(--align-items);justify-content:var(--justify-content);flex-wrap:wrap}content-grid-formatter[type=flex]>*{overflow:auto;flex:0 0 auto;width:calc(100% / var(--columns))}content-grid-formatter>[flex-shrink=true]{width:auto;flex-shrink:1}content-grid-formatter[flex-shrink=true]>*{flex-shrink:1}content-grid-formatter[flex-grow=true]>*{flex-grow:1}content-grid-formatter>[flex-grow=true]{width:auto;flex-grow:1}";
118
+ const contentGridFormatterCss = "*{box-sizing:border-box}content-grid-formatter{width:100%;overflow:auto;align-items:var(--align-items, flex-start);justify-content:var(--justify-content)}content-grid-formatter *{box-sizing:border-box}content-grid-formatter[type=grid]{display:grid;grid-template-columns:repeat(var(--columns), 1fr);column-gap:var(--column-gap, 0);row-gap:var(--row-gap, 0)}content-grid-formatter[type=flex]{display:flex;flex-wrap:wrap}content-grid-formatter[type=flex]>*{overflow:auto;flex:0 0 auto;width:calc(100% / var(--columns))}content-grid-formatter>[flex-shrink=true]{width:auto;flex-shrink:1}content-grid-formatter[flex-shrink=true]>*{flex-shrink:1}content-grid-formatter[flex-grow=true]>*{flex-grow:1}content-grid-formatter>[flex-grow=true]{width:auto;flex-grow:1}";
118
119
 
119
120
  const ContentGridFormatter = class {
120
121
  constructor(hostRef) {
@@ -128,6 +129,7 @@ const ContentGridFormatter = class {
128
129
  this.horizontal = 'space-between';
129
130
  this.columns = '1';
130
131
  this.columnGap = '0';
132
+ this.rowGap = '0';
131
133
  this.activeClassString = undefined;
132
134
  this.inlineStyle = {};
133
135
  }
@@ -145,6 +147,7 @@ const ContentGridFormatter = class {
145
147
  WindowResizeService.registerProp(this.flexShrink).subscribe(newValue => (this.flexShrink = newValue)),
146
148
  WindowResizeService.registerProp(this.flexGrow).subscribe(newValue => (this.flexGrow = newValue)),
147
149
  WindowResizeService.registerProp(this.columns).subscribe(newValue => {
150
+ console.log(this.hostElement, this.columns);
148
151
  this.columns = newValue;
149
152
  this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { '--columns': newValue });
150
153
  }),
@@ -152,12 +155,17 @@ const ContentGridFormatter = class {
152
155
  this.columnGap = newValue;
153
156
  this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { '--column-gap': newValue });
154
157
  }),
158
+ WindowResizeService.registerProp(this.rowGap).subscribe(newValue => {
159
+ this.rowGap = newValue;
160
+ this.inlineStyle = Object.assign(Object.assign({}, this.inlineStyle), { '--row-gap': newValue });
161
+ }),
155
162
  WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = newValue)),
156
163
  ]);
157
164
  }
158
165
  render() {
159
166
  return (h(Host, { class: this.classString, style: this.inlineStyle }, h("slot", null)));
160
167
  }
168
+ get hostElement() { return getElement(this); }
161
169
  };
162
170
  ContentGridFormatter.style = contentGridFormatterCss;
163
171
 
@@ -251,9 +259,9 @@ const ContentImage = class {
251
259
  });
252
260
  }, {
253
261
  root: null,
254
- // rootMargin: `${Math.max(100, window.innerHeight * 0.95)}px`,
255
- rootMargin: `0px`,
256
- threshold: 0.1,
262
+ rootMargin: `${Math.max(100, window.innerHeight * 1)}px`,
263
+ // rootMargin: `0px`,
264
+ threshold: 0,
257
265
  });
258
266
  observer.observe(this.hostElement);
259
267
  }
@@ -271,7 +279,7 @@ const ContentImage = class {
271
279
  }
272
280
  }
273
281
  render() {
274
- return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif ? (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.pictureImageSrc : null, type: this.videoType }))) : (h("img", { width: this.width, height: this.height, src: this.pictureImageSrc, alt: this.alt }))));
282
+ return (h(Host, { class: `${this.activeLazyLoadClass} ${this.classString}`, style: this.inlineStyle, content: this.showContent }, this.hasMediaContent && (h("div", { class: "content-image__media-content" }, h("slot", { name: "mediaContent" }))), this.showVideoAsGif && (h("video", { autoplay: true, muted: true, loop: true, preload: "none", playsinline: true, width: this.width, height: this.height }, h("source", { src: this.lazyLoadIsComplete ? this.pictureImageSrc : null, type: this.videoType }))), this.pictureImageSrc && !this.showVideoAsGif && h("img", { width: this.width, height: this.height, src: this.pictureImageSrc, alt: this.alt })));
275
283
  }
276
284
  get hostElement() { return getElement(this); }
277
285
  static get watchers() { return {
@@ -311,1510 +319,6 @@ const ContentLine = class {
311
319
  };
312
320
  ContentLine.style = contentLineCss;
313
321
 
314
- /*!
315
- * tabbable 6.2.0
316
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
317
- */
318
- // NOTE: separate `:not()` selectors has broader browser support than the newer
319
- // `:not([inert], [inert] *)` (Feb 2023)
320
- // CAREFUL: JSDom does not support `:not([inert] *)` as a selector; using it causes
321
- // the entire query to fail, resulting in no nodes found, which will break a lot
322
- // of things... so we have to rely on JS to identify nodes inside an inert container
323
- var candidateSelectors = ['input:not([inert])', 'select:not([inert])', 'textarea:not([inert])', 'a[href]:not([inert])', 'button:not([inert])', '[tabindex]:not(slot):not([inert])', 'audio[controls]:not([inert])', 'video[controls]:not([inert])', '[contenteditable]:not([contenteditable="false"]):not([inert])', 'details>summary:first-of-type:not([inert])', 'details:not([inert])'];
324
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
325
- var NoElement = typeof Element === 'undefined';
326
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
327
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
328
- var _element$getRootNode;
329
- return element === null || element === void 0 ? void 0 : (_element$getRootNode = element.getRootNode) === null || _element$getRootNode === void 0 ? void 0 : _element$getRootNode.call(element);
330
- } : function (element) {
331
- return element === null || element === void 0 ? void 0 : element.ownerDocument;
332
- };
333
-
334
- /**
335
- * Determines if a node is inert or in an inert ancestor.
336
- * @param {Element} [node]
337
- * @param {boolean} [lookUp] If true and `node` is not inert, looks up at ancestors to
338
- * see if any of them are inert. If false, only `node` itself is considered.
339
- * @returns {boolean} True if inert itself or by way of being in an inert ancestor.
340
- * False if `node` is falsy.
341
- */
342
- var isInert = function isInert(node, lookUp) {
343
- var _node$getAttribute;
344
- if (lookUp === void 0) {
345
- lookUp = true;
346
- }
347
- // CAREFUL: JSDom does not support inert at all, so we can't use the `HTMLElement.inert`
348
- // JS API property; we have to check the attribute, which can either be empty or 'true';
349
- // if it's `null` (not specified) or 'false', it's an active element
350
- var inertAtt = node === null || node === void 0 ? void 0 : (_node$getAttribute = node.getAttribute) === null || _node$getAttribute === void 0 ? void 0 : _node$getAttribute.call(node, 'inert');
351
- var inert = inertAtt === '' || inertAtt === 'true';
352
-
353
- // NOTE: this could also be handled with `node.matches('[inert], :is([inert] *)')`
354
- // if it weren't for `matches()` not being a function on shadow roots; the following
355
- // code works for any kind of node
356
- // CAREFUL: JSDom does not appear to support certain selectors like `:not([inert] *)`
357
- // so it likely would not support `:is([inert] *)` either...
358
- var result = inert || lookUp && node && isInert(node.parentNode); // recursive
359
-
360
- return result;
361
- };
362
-
363
- /**
364
- * Determines if a node's content is editable.
365
- * @param {Element} [node]
366
- * @returns True if it's content-editable; false if it's not or `node` is falsy.
367
- */
368
- var isContentEditable = function isContentEditable(node) {
369
- var _node$getAttribute2;
370
- // CAREFUL: JSDom does not support the `HTMLElement.isContentEditable` API so we have
371
- // to use the attribute directly to check for this, which can either be empty or 'true';
372
- // if it's `null` (not specified) or 'false', it's a non-editable element
373
- var attValue = node === null || node === void 0 ? void 0 : (_node$getAttribute2 = node.getAttribute) === null || _node$getAttribute2 === void 0 ? void 0 : _node$getAttribute2.call(node, 'contenteditable');
374
- return attValue === '' || attValue === 'true';
375
- };
376
-
377
- /**
378
- * @param {Element} el container to check in
379
- * @param {boolean} includeContainer add container to check
380
- * @param {(node: Element) => boolean} filter filter candidates
381
- * @returns {Element[]}
382
- */
383
- var getCandidates = function getCandidates(el, includeContainer, filter) {
384
- // even if `includeContainer=false`, we still have to check it for inertness because
385
- // if it's inert, all its children are inert
386
- if (isInert(el)) {
387
- return [];
388
- }
389
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
390
- if (includeContainer && matches.call(el, candidateSelector)) {
391
- candidates.unshift(el);
392
- }
393
- candidates = candidates.filter(filter);
394
- return candidates;
395
- };
396
-
397
- /**
398
- * @callback GetShadowRoot
399
- * @param {Element} element to check for shadow root
400
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
401
- */
402
-
403
- /**
404
- * @callback ShadowRootFilter
405
- * @param {Element} shadowHostNode the element which contains shadow content
406
- * @returns {boolean} true if a shadow root could potentially contain valid candidates.
407
- */
408
-
409
- /**
410
- * @typedef {Object} CandidateScope
411
- * @property {Element} scopeParent contains inner candidates
412
- * @property {Element[]} candidates list of candidates found in the scope parent
413
- */
414
-
415
- /**
416
- * @typedef {Object} IterativeOptions
417
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
418
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
419
- * or a boolean stating if it has an undisclosed shadow root
420
- * @property {(node: Element) => boolean} filter filter candidates
421
- * @property {boolean} flatten if true then result will flatten any CandidateScope into the returned list
422
- * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
423
- */
424
-
425
- /**
426
- * @param {Element[]} elements list of element containers to match candidates from
427
- * @param {boolean} includeContainer add container list to check
428
- * @param {IterativeOptions} options
429
- * @returns {Array.<Element|CandidateScope>}
430
- */
431
- var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
432
- var candidates = [];
433
- var elementsToCheck = Array.from(elements);
434
- while (elementsToCheck.length) {
435
- var element = elementsToCheck.shift();
436
- if (isInert(element, false)) {
437
- // no need to look up since we're drilling down
438
- // anything inside this container will also be inert
439
- continue;
440
- }
441
- if (element.tagName === 'SLOT') {
442
- // add shadow dom slot scope (slot itself cannot be focusable)
443
- var assigned = element.assignedElements();
444
- var content = assigned.length ? assigned : element.children;
445
- var nestedCandidates = getCandidatesIteratively(content, true, options);
446
- if (options.flatten) {
447
- candidates.push.apply(candidates, nestedCandidates);
448
- } else {
449
- candidates.push({
450
- scopeParent: element,
451
- candidates: nestedCandidates
452
- });
453
- }
454
- } else {
455
- // check candidate element
456
- var validCandidate = matches.call(element, candidateSelector);
457
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
458
- candidates.push(element);
459
- }
460
-
461
- // iterate over shadow content if possible
462
- var shadowRoot = element.shadowRoot ||
463
- // check for an undisclosed shadow
464
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
465
-
466
- // no inert look up because we're already drilling down and checking for inertness
467
- // on the way down, so all containers to this root node should have already been
468
- // vetted as non-inert
469
- var validShadowRoot = !isInert(shadowRoot, false) && (!options.shadowRootFilter || options.shadowRootFilter(element));
470
- if (shadowRoot && validShadowRoot) {
471
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
472
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
473
- // child candidates found because they're likely slotted elements (elements that are
474
- // children of the web component element (which has the shadow), in the light dom, but
475
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
476
- // _after_ we return from this recursive call
477
- var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
478
- if (options.flatten) {
479
- candidates.push.apply(candidates, _nestedCandidates);
480
- } else {
481
- candidates.push({
482
- scopeParent: element,
483
- candidates: _nestedCandidates
484
- });
485
- }
486
- } else {
487
- // there's not shadow so just dig into the element's (light dom) children
488
- // __without__ giving the element special scope treatment
489
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
490
- }
491
- }
492
- }
493
- return candidates;
494
- };
495
-
496
- /**
497
- * @private
498
- * Determines if the node has an explicitly specified `tabindex` attribute.
499
- * @param {HTMLElement} node
500
- * @returns {boolean} True if so; false if not.
501
- */
502
- var hasTabIndex = function hasTabIndex(node) {
503
- return !isNaN(parseInt(node.getAttribute('tabindex'), 10));
504
- };
505
-
506
- /**
507
- * Determine the tab index of a given node.
508
- * @param {HTMLElement} node
509
- * @returns {number} Tab order (negative, 0, or positive number).
510
- * @throws {Error} If `node` is falsy.
511
- */
512
- var getTabIndex = function getTabIndex(node) {
513
- if (!node) {
514
- throw new Error('No node provided');
515
- }
516
- if (node.tabIndex < 0) {
517
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
518
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
519
- // yet they are still part of the regular tab order; in FF, they get a default
520
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
521
- // order, consider their tab index to be 0.
522
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
523
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
524
- if ((/^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || isContentEditable(node)) && !hasTabIndex(node)) {
525
- return 0;
526
- }
527
- }
528
- return node.tabIndex;
529
- };
530
-
531
- /**
532
- * Determine the tab index of a given node __for sort order purposes__.
533
- * @param {HTMLElement} node
534
- * @param {boolean} [isScope] True for a custom element with shadow root or slot that, by default,
535
- * has tabIndex -1, but needs to be sorted by document order in order for its content to be
536
- * inserted into the correct sort position.
537
- * @returns {number} Tab order (negative, 0, or positive number).
538
- */
539
- var getSortOrderTabIndex = function getSortOrderTabIndex(node, isScope) {
540
- var tabIndex = getTabIndex(node);
541
- if (tabIndex < 0 && isScope && !hasTabIndex(node)) {
542
- return 0;
543
- }
544
- return tabIndex;
545
- };
546
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
547
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
548
- };
549
- var isInput = function isInput(node) {
550
- return node.tagName === 'INPUT';
551
- };
552
- var isHiddenInput = function isHiddenInput(node) {
553
- return isInput(node) && node.type === 'hidden';
554
- };
555
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
556
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
557
- return child.tagName === 'SUMMARY';
558
- });
559
- return r;
560
- };
561
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
562
- for (var i = 0; i < nodes.length; i++) {
563
- if (nodes[i].checked && nodes[i].form === form) {
564
- return nodes[i];
565
- }
566
- }
567
- };
568
- var isTabbableRadio = function isTabbableRadio(node) {
569
- if (!node.name) {
570
- return true;
571
- }
572
- var radioScope = node.form || getRootNode(node);
573
- var queryRadios = function queryRadios(name) {
574
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
575
- };
576
- var radioSet;
577
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
578
- radioSet = queryRadios(window.CSS.escape(node.name));
579
- } else {
580
- try {
581
- radioSet = queryRadios(node.name);
582
- } catch (err) {
583
- // eslint-disable-next-line no-console
584
- console.error('Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s', err.message);
585
- return false;
586
- }
587
- }
588
- var checked = getCheckedRadio(radioSet, node.form);
589
- return !checked || checked === node;
590
- };
591
- var isRadio = function isRadio(node) {
592
- return isInput(node) && node.type === 'radio';
593
- };
594
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
595
- return isRadio(node) && !isTabbableRadio(node);
596
- };
597
-
598
- // determines if a node is ultimately attached to the window's document
599
- var isNodeAttached = function isNodeAttached(node) {
600
- var _nodeRoot;
601
- // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
602
- // (but NOT _the_ document; see second 'If' comment below for more).
603
- // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
604
- // is attached, and the one we need to check if it's in the document or not (because the
605
- // shadow, and all nodes it contains, is never considered in the document since shadows
606
- // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
607
- // is hidden, or is not in the document itself but is detached, it will affect the shadow's
608
- // visibility, including all the nodes it contains). The host could be any normal node,
609
- // or a custom element (i.e. web component). Either way, that's the one that is considered
610
- // part of the document, not the shadow root, nor any of its children (i.e. the node being
611
- // tested).
612
- // To further complicate things, we have to look all the way up until we find a shadow HOST
613
- // that is attached (or find none) because the node might be in nested shadows...
614
- // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
615
- // document (per the docs) and while it's a Document-type object, that document does not
616
- // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
617
- // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
618
- // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
619
- // node is actually detached.
620
- // NOTE: If `nodeRootHost` or `node` happens to be the `document` itself (which is possible
621
- // if a tabbable/focusable node was quickly added to the DOM, focused, and then removed
622
- // from the DOM as in https://github.com/focus-trap/focus-trap-react/issues/905), then
623
- // `ownerDocument` will be `null`, hence the optional chaining on it.
624
- var nodeRoot = node && getRootNode(node);
625
- var nodeRootHost = (_nodeRoot = nodeRoot) === null || _nodeRoot === void 0 ? void 0 : _nodeRoot.host;
626
-
627
- // in some cases, a detached node will return itself as the root instead of a document or
628
- // shadow root object, in which case, we shouldn't try to look further up the host chain
629
- var attached = false;
630
- if (nodeRoot && nodeRoot !== node) {
631
- var _nodeRootHost, _nodeRootHost$ownerDo, _node$ownerDocument;
632
- attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && (_nodeRootHost$ownerDo = _nodeRootHost.ownerDocument) !== null && _nodeRootHost$ownerDo !== void 0 && _nodeRootHost$ownerDo.contains(nodeRootHost) || node !== null && node !== void 0 && (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 && _node$ownerDocument.contains(node));
633
- while (!attached && nodeRootHost) {
634
- var _nodeRoot2, _nodeRootHost2, _nodeRootHost2$ownerD;
635
- // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
636
- // which means we need to get the host's host and check if that parent host is contained
637
- // in (i.e. attached to) the document
638
- nodeRoot = getRootNode(nodeRootHost);
639
- nodeRootHost = (_nodeRoot2 = nodeRoot) === null || _nodeRoot2 === void 0 ? void 0 : _nodeRoot2.host;
640
- attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && (_nodeRootHost2$ownerD = _nodeRootHost2.ownerDocument) !== null && _nodeRootHost2$ownerD !== void 0 && _nodeRootHost2$ownerD.contains(nodeRootHost));
641
- }
642
- }
643
- return attached;
644
- };
645
- var isZeroArea = function isZeroArea(node) {
646
- var _node$getBoundingClie = node.getBoundingClientRect(),
647
- width = _node$getBoundingClie.width,
648
- height = _node$getBoundingClie.height;
649
- return width === 0 && height === 0;
650
- };
651
- var isHidden = function isHidden(node, _ref) {
652
- var displayCheck = _ref.displayCheck,
653
- getShadowRoot = _ref.getShadowRoot;
654
- // NOTE: visibility will be `undefined` if node is detached from the document
655
- // (see notes about this further down), which means we will consider it visible
656
- // (this is legacy behavior from a very long way back)
657
- // NOTE: we check this regardless of `displayCheck="none"` because this is a
658
- // _visibility_ check, not a _display_ check
659
- if (getComputedStyle(node).visibility === 'hidden') {
660
- return true;
661
- }
662
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
663
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
664
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
665
- return true;
666
- }
667
- if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
668
- if (typeof getShadowRoot === 'function') {
669
- // figure out if we should consider the node to be in an undisclosed shadow and use the
670
- // 'non-zero-area' fallback
671
- var originalNode = node;
672
- while (node) {
673
- var parentElement = node.parentElement;
674
- var rootNode = getRootNode(node);
675
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
676
- ) {
677
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
678
- // fall back to a non-zero-area test
679
- return isZeroArea(node);
680
- } else if (node.assignedSlot) {
681
- // iterate up slot
682
- node = node.assignedSlot;
683
- } else if (!parentElement && rootNode !== node.ownerDocument) {
684
- // cross shadow boundary
685
- node = rootNode.host;
686
- } else {
687
- // iterate up normal dom
688
- node = parentElement;
689
- }
690
- }
691
- node = originalNode;
692
- }
693
- // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
694
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
695
- // it might be a falsy value, which means shadow DOM support is disabled
696
-
697
- // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
698
- // now we can just test to see if it would normally be visible or not, provided it's
699
- // attached to the main document.
700
- // NOTE: We must consider case where node is inside a shadow DOM and given directly to
701
- // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
702
-
703
- if (isNodeAttached(node)) {
704
- // this works wherever the node is: if there's at least one client rect, it's
705
- // somehow displayed; it also covers the CSS 'display: contents' case where the
706
- // node itself is hidden in place of its contents; and there's no need to search
707
- // up the hierarchy either
708
- return !node.getClientRects().length;
709
- }
710
-
711
- // Else, the node isn't attached to the document, which means the `getClientRects()`
712
- // API will __always__ return zero rects (this can happen, for example, if React
713
- // is used to render nodes onto a detached tree, as confirmed in this thread:
714
- // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
715
- //
716
- // It also means that even window.getComputedStyle(node).display will return `undefined`
717
- // because styles are only computed for nodes that are in the document.
718
- //
719
- // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
720
- // somehow. Though it was never stated officially, anyone who has ever used tabbable
721
- // APIs on nodes in detached containers has actually implicitly used tabbable in what
722
- // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
723
- // considering __everything__ to be visible because of the innability to determine styles.
724
- //
725
- // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
726
- // nodes as visible with the 'none' fallback.__
727
- if (displayCheck !== 'legacy-full') {
728
- return true; // hidden
729
- }
730
- // else, fallback to 'none' mode and consider the node visible
731
- } else if (displayCheck === 'non-zero-area') {
732
- // NOTE: Even though this tests that the node's client rect is non-zero to determine
733
- // whether it's displayed, and that a detached node will __always__ have a zero-area
734
- // client rect, we don't special-case for whether the node is attached or not. In
735
- // this mode, we do want to consider nodes that have a zero area to be hidden at all
736
- // times, and that includes attached or not.
737
- return isZeroArea(node);
738
- }
739
-
740
- // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
741
- // it's visible
742
- return false;
743
- };
744
-
745
- // form fields (nested) inside a disabled fieldset are not focusable/tabbable
746
- // unless they are in the _first_ <legend> element of the top-most disabled
747
- // fieldset
748
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
749
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
750
- var parentNode = node.parentElement;
751
- // check if `node` is contained in a disabled <fieldset>
752
- while (parentNode) {
753
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
754
- // look for the first <legend> among the children of the disabled <fieldset>
755
- for (var i = 0; i < parentNode.children.length; i++) {
756
- var child = parentNode.children.item(i);
757
- // when the first <legend> (in document order) is found
758
- if (child.tagName === 'LEGEND') {
759
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
760
- // return whether `node` is a descendant of its first <legend>
761
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
762
- }
763
- }
764
- // the disabled <fieldset> containing `node` has no <legend>
765
- return true;
766
- }
767
- parentNode = parentNode.parentElement;
768
- }
769
- }
770
-
771
- // else, node's tabbable/focusable state should not be affected by a fieldset's
772
- // enabled/disabled state
773
- return false;
774
- };
775
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
776
- if (node.disabled ||
777
- // we must do an inert look up to filter out any elements inside an inert ancestor
778
- // because we're limited in the type of selectors we can use in JSDom (see related
779
- // note related to `candidateSelectors`)
780
- isInert(node) || isHiddenInput(node) || isHidden(node, options) ||
781
- // For a details element with a summary, the summary element gets the focus
782
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
783
- return false;
784
- }
785
- return true;
786
- };
787
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
788
- if (isNonTabbableRadio(node) || getTabIndex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
789
- return false;
790
- }
791
- return true;
792
- };
793
- var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
794
- var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
795
- if (isNaN(tabIndex) || tabIndex >= 0) {
796
- return true;
797
- }
798
- // If a custom element has an explicit negative tabindex,
799
- // browsers will not allow tab targeting said element's children.
800
- return false;
801
- };
802
-
803
- /**
804
- * @param {Array.<Element|CandidateScope>} candidates
805
- * @returns Element[]
806
- */
807
- var sortByOrder = function sortByOrder(candidates) {
808
- var regularTabbables = [];
809
- var orderedTabbables = [];
810
- candidates.forEach(function (item, i) {
811
- var isScope = !!item.scopeParent;
812
- var element = isScope ? item.scopeParent : item;
813
- var candidateTabindex = getSortOrderTabIndex(element, isScope);
814
- var elements = isScope ? sortByOrder(item.candidates) : element;
815
- if (candidateTabindex === 0) {
816
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
817
- } else {
818
- orderedTabbables.push({
819
- documentOrder: i,
820
- tabIndex: candidateTabindex,
821
- item: item,
822
- isScope: isScope,
823
- content: elements
824
- });
825
- }
826
- });
827
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
828
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
829
- return acc;
830
- }, []).concat(regularTabbables);
831
- };
832
- var tabbable = function tabbable(container, options) {
833
- options = options || {};
834
- var candidates;
835
- if (options.getShadowRoot) {
836
- candidates = getCandidatesIteratively([container], options.includeContainer, {
837
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
838
- flatten: false,
839
- getShadowRoot: options.getShadowRoot,
840
- shadowRootFilter: isValidShadowRootTabbable
841
- });
842
- } else {
843
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
844
- }
845
- return sortByOrder(candidates);
846
- };
847
- var focusable = function focusable(container, options) {
848
- options = options || {};
849
- var candidates;
850
- if (options.getShadowRoot) {
851
- candidates = getCandidatesIteratively([container], options.includeContainer, {
852
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
853
- flatten: true,
854
- getShadowRoot: options.getShadowRoot
855
- });
856
- } else {
857
- candidates = getCandidates(container, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
858
- }
859
- return candidates;
860
- };
861
- var isTabbable = function isTabbable(node, options) {
862
- options = options || {};
863
- if (!node) {
864
- throw new Error('No node provided');
865
- }
866
- if (matches.call(node, candidateSelector) === false) {
867
- return false;
868
- }
869
- return isNodeMatchingSelectorTabbable(options, node);
870
- };
871
- var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
872
- var isFocusable = function isFocusable(node, options) {
873
- options = options || {};
874
- if (!node) {
875
- throw new Error('No node provided');
876
- }
877
- if (matches.call(node, focusableCandidateSelector) === false) {
878
- return false;
879
- }
880
- return isNodeMatchingSelectorFocusable(options, node);
881
- };
882
-
883
- /*!
884
- * focus-trap 7.5.4
885
- * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
886
- */
887
-
888
- function ownKeys(e, r) {
889
- var t = Object.keys(e);
890
- if (Object.getOwnPropertySymbols) {
891
- var o = Object.getOwnPropertySymbols(e);
892
- r && (o = o.filter(function (r) {
893
- return Object.getOwnPropertyDescriptor(e, r).enumerable;
894
- })), t.push.apply(t, o);
895
- }
896
- return t;
897
- }
898
- function _objectSpread2(e) {
899
- for (var r = 1; r < arguments.length; r++) {
900
- var t = null != arguments[r] ? arguments[r] : {};
901
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
902
- _defineProperty(e, r, t[r]);
903
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
904
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
905
- });
906
- }
907
- return e;
908
- }
909
- function _defineProperty(obj, key, value) {
910
- key = _toPropertyKey(key);
911
- if (key in obj) {
912
- Object.defineProperty(obj, key, {
913
- value: value,
914
- enumerable: true,
915
- configurable: true,
916
- writable: true
917
- });
918
- } else {
919
- obj[key] = value;
920
- }
921
- return obj;
922
- }
923
- function _toPrimitive(input, hint) {
924
- if (typeof input !== "object" || input === null) return input;
925
- var prim = input[Symbol.toPrimitive];
926
- if (prim !== undefined) {
927
- var res = prim.call(input, hint || "default");
928
- if (typeof res !== "object") return res;
929
- throw new TypeError("@@toPrimitive must return a primitive value.");
930
- }
931
- return (hint === "string" ? String : Number)(input);
932
- }
933
- function _toPropertyKey(arg) {
934
- var key = _toPrimitive(arg, "string");
935
- return typeof key === "symbol" ? key : String(key);
936
- }
937
-
938
- var activeFocusTraps = {
939
- activateTrap: function activateTrap(trapStack, trap) {
940
- if (trapStack.length > 0) {
941
- var activeTrap = trapStack[trapStack.length - 1];
942
- if (activeTrap !== trap) {
943
- activeTrap.pause();
944
- }
945
- }
946
- var trapIndex = trapStack.indexOf(trap);
947
- if (trapIndex === -1) {
948
- trapStack.push(trap);
949
- } else {
950
- // move this existing trap to the front of the queue
951
- trapStack.splice(trapIndex, 1);
952
- trapStack.push(trap);
953
- }
954
- },
955
- deactivateTrap: function deactivateTrap(trapStack, trap) {
956
- var trapIndex = trapStack.indexOf(trap);
957
- if (trapIndex !== -1) {
958
- trapStack.splice(trapIndex, 1);
959
- }
960
- if (trapStack.length > 0) {
961
- trapStack[trapStack.length - 1].unpause();
962
- }
963
- }
964
- };
965
- var isSelectableInput = function isSelectableInput(node) {
966
- return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
967
- };
968
- var isEscapeEvent = function isEscapeEvent(e) {
969
- return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
970
- };
971
- var isTabEvent = function isTabEvent(e) {
972
- return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
973
- };
974
-
975
- // checks for TAB by default
976
- var isKeyForward = function isKeyForward(e) {
977
- return isTabEvent(e) && !e.shiftKey;
978
- };
979
-
980
- // checks for SHIFT+TAB by default
981
- var isKeyBackward = function isKeyBackward(e) {
982
- return isTabEvent(e) && e.shiftKey;
983
- };
984
- var delay = function delay(fn) {
985
- return setTimeout(fn, 0);
986
- };
987
-
988
- // Array.find/findIndex() are not supported on IE; this replicates enough
989
- // of Array.findIndex() for our needs
990
- var findIndex = function findIndex(arr, fn) {
991
- var idx = -1;
992
- arr.every(function (value, i) {
993
- if (fn(value)) {
994
- idx = i;
995
- return false; // break
996
- }
997
-
998
- return true; // next
999
- });
1000
-
1001
- return idx;
1002
- };
1003
-
1004
- /**
1005
- * Get an option's value when it could be a plain value, or a handler that provides
1006
- * the value.
1007
- * @param {*} value Option's value to check.
1008
- * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
1009
- * @returns {*} The `value`, or the handler's returned value.
1010
- */
1011
- var valueOrHandler = function valueOrHandler(value) {
1012
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1013
- params[_key - 1] = arguments[_key];
1014
- }
1015
- return typeof value === 'function' ? value.apply(void 0, params) : value;
1016
- };
1017
- var getActualTarget = function getActualTarget(event) {
1018
- // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
1019
- // shadow host. However, event.target.composedPath() will be an array of
1020
- // nodes "clicked" from inner-most (the actual element inside the shadow) to
1021
- // outer-most (the host HTML document). If we have access to composedPath(),
1022
- // then use its first element; otherwise, fall back to event.target (and
1023
- // this only works for an _open_ shadow DOM; otherwise,
1024
- // composedPath()[0] === event.target always).
1025
- return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
1026
- };
1027
-
1028
- // NOTE: this must be _outside_ `createFocusTrap()` to make sure all traps in this
1029
- // current instance use the same stack if `userOptions.trapStack` isn't specified
1030
- var internalTrapStack = [];
1031
- var createFocusTrap = function createFocusTrap(elements, userOptions) {
1032
- // SSR: a live trap shouldn't be created in this type of environment so this
1033
- // should be safe code to execute if the `document` option isn't specified
1034
- var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
1035
- var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
1036
- var config = _objectSpread2({
1037
- returnFocusOnDeactivate: true,
1038
- escapeDeactivates: true,
1039
- delayInitialFocus: true,
1040
- isKeyForward: isKeyForward,
1041
- isKeyBackward: isKeyBackward
1042
- }, userOptions);
1043
- var state = {
1044
- // containers given to createFocusTrap()
1045
- // @type {Array<HTMLElement>}
1046
- containers: [],
1047
- // list of objects identifying tabbable nodes in `containers` in the trap
1048
- // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
1049
- // is active, but the trap should never get to a state where there isn't at least one group
1050
- // with at least one tabbable node in it (that would lead to an error condition that would
1051
- // result in an error being thrown)
1052
- // @type {Array<{
1053
- // container: HTMLElement,
1054
- // tabbableNodes: Array<HTMLElement>, // empty if none
1055
- // focusableNodes: Array<HTMLElement>, // empty if none
1056
- // posTabIndexesFound: boolean,
1057
- // firstTabbableNode: HTMLElement|undefined,
1058
- // lastTabbableNode: HTMLElement|undefined,
1059
- // firstDomTabbableNode: HTMLElement|undefined,
1060
- // lastDomTabbableNode: HTMLElement|undefined,
1061
- // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
1062
- // }>}
1063
- containerGroups: [],
1064
- // same order/length as `containers` list
1065
-
1066
- // references to objects in `containerGroups`, but only those that actually have
1067
- // tabbable nodes in them
1068
- // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
1069
- // the same length
1070
- tabbableGroups: [],
1071
- nodeFocusedBeforeActivation: null,
1072
- mostRecentlyFocusedNode: null,
1073
- active: false,
1074
- paused: false,
1075
- // timer ID for when delayInitialFocus is true and initial focus in this trap
1076
- // has been delayed during activation
1077
- delayInitialFocusTimer: undefined,
1078
- // the most recent KeyboardEvent for the configured nav key (typically [SHIFT+]TAB), if any
1079
- recentNavEvent: undefined
1080
- };
1081
- var trap; // eslint-disable-line prefer-const -- some private functions reference it, and its methods reference private functions, so we must declare here and define later
1082
-
1083
- /**
1084
- * Gets a configuration option value.
1085
- * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
1086
- * value will be taken from this object. Otherwise, value will be taken from base configuration.
1087
- * @param {string} optionName Name of the option whose value is sought.
1088
- * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
1089
- * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
1090
- */
1091
- var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
1092
- return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
1093
- };
1094
-
1095
- /**
1096
- * Finds the index of the container that contains the element.
1097
- * @param {HTMLElement} element
1098
- * @param {Event} [event] If available, and `element` isn't directly found in any container,
1099
- * the event's composed path is used to see if includes any known trap containers in the
1100
- * case where the element is inside a Shadow DOM.
1101
- * @returns {number} Index of the container in either `state.containers` or
1102
- * `state.containerGroups` (the order/length of these lists are the same); -1
1103
- * if the element isn't found.
1104
- */
1105
- var findContainerIndex = function findContainerIndex(element, event) {
1106
- var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
1107
- // NOTE: search `containerGroups` because it's possible a group contains no tabbable
1108
- // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
1109
- // and we still need to find the element in there
1110
- return state.containerGroups.findIndex(function (_ref) {
1111
- var container = _ref.container,
1112
- tabbableNodes = _ref.tabbableNodes;
1113
- return container.contains(element) || ( // fall back to explicit tabbable search which will take into consideration any
1114
- // web components if the `tabbableOptions.getShadowRoot` option was used for
1115
- // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
1116
- // look inside web components even if open)
1117
- composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
1118
- return node === element;
1119
- });
1120
- });
1121
- };
1122
-
1123
- /**
1124
- * Gets the node for the given option, which is expected to be an option that
1125
- * can be either a DOM node, a string that is a selector to get a node, `false`
1126
- * (if a node is explicitly NOT given), or a function that returns any of these
1127
- * values.
1128
- * @param {string} optionName
1129
- * @returns {undefined | false | HTMLElement | SVGElement} Returns
1130
- * `undefined` if the option is not specified; `false` if the option
1131
- * resolved to `false` (node explicitly not given); otherwise, the resolved
1132
- * DOM node.
1133
- * @throws {Error} If the option is set, not `false`, and is not, or does not
1134
- * resolve to a node.
1135
- */
1136
- var getNodeForOption = function getNodeForOption(optionName) {
1137
- var optionValue = config[optionName];
1138
- if (typeof optionValue === 'function') {
1139
- for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1140
- params[_key2 - 1] = arguments[_key2];
1141
- }
1142
- optionValue = optionValue.apply(void 0, params);
1143
- }
1144
- if (optionValue === true) {
1145
- optionValue = undefined; // use default value
1146
- }
1147
-
1148
- if (!optionValue) {
1149
- if (optionValue === undefined || optionValue === false) {
1150
- return optionValue;
1151
- }
1152
- // else, empty string (invalid), null (invalid), 0 (invalid)
1153
-
1154
- throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
1155
- }
1156
- var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
1157
-
1158
- if (typeof optionValue === 'string') {
1159
- node = doc.querySelector(optionValue); // resolve to node, or null if fails
1160
- if (!node) {
1161
- throw new Error("`".concat(optionName, "` as selector refers to no known node"));
1162
- }
1163
- }
1164
- return node;
1165
- };
1166
- var getInitialFocusNode = function getInitialFocusNode() {
1167
- var node = getNodeForOption('initialFocus');
1168
-
1169
- // false explicitly indicates we want no initialFocus at all
1170
- if (node === false) {
1171
- return false;
1172
- }
1173
- if (node === undefined || !isFocusable(node, config.tabbableOptions)) {
1174
- // option not specified nor focusable: use fallback options
1175
- if (findContainerIndex(doc.activeElement) >= 0) {
1176
- node = doc.activeElement;
1177
- } else {
1178
- var firstTabbableGroup = state.tabbableGroups[0];
1179
- var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
1180
-
1181
- // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
1182
- node = firstTabbableNode || getNodeForOption('fallbackFocus');
1183
- }
1184
- }
1185
- if (!node) {
1186
- throw new Error('Your focus-trap needs to have at least one focusable element');
1187
- }
1188
- return node;
1189
- };
1190
- var updateTabbableNodes = function updateTabbableNodes() {
1191
- state.containerGroups = state.containers.map(function (container) {
1192
- var tabbableNodes = tabbable(container, config.tabbableOptions);
1193
-
1194
- // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
1195
- // are a superset of tabbable nodes since nodes with negative `tabindex` attributes
1196
- // are focusable but not tabbable
1197
- var focusableNodes = focusable(container, config.tabbableOptions);
1198
- var firstTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[0] : undefined;
1199
- var lastTabbableNode = tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : undefined;
1200
- var firstDomTabbableNode = focusableNodes.find(function (node) {
1201
- return isTabbable(node);
1202
- });
1203
- var lastDomTabbableNode = focusableNodes.slice().reverse().find(function (node) {
1204
- return isTabbable(node);
1205
- });
1206
- var posTabIndexesFound = !!tabbableNodes.find(function (node) {
1207
- return getTabIndex(node) > 0;
1208
- });
1209
- return {
1210
- container: container,
1211
- tabbableNodes: tabbableNodes,
1212
- focusableNodes: focusableNodes,
1213
- /** True if at least one node with positive `tabindex` was found in this container. */
1214
- posTabIndexesFound: posTabIndexesFound,
1215
- /** First tabbable node in container, __tabindex__ order; `undefined` if none. */
1216
- firstTabbableNode: firstTabbableNode,
1217
- /** Last tabbable node in container, __tabindex__ order; `undefined` if none. */
1218
- lastTabbableNode: lastTabbableNode,
1219
- // NOTE: DOM order is NOT NECESSARILY "document position" order, but figuring that out
1220
- // would require more than just https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition
1221
- // because that API doesn't work with Shadow DOM as well as it should (@see
1222
- // https://github.com/whatwg/dom/issues/320) and since this first/last is only needed, so far,
1223
- // to address an edge case related to positive tabindex support, this seems like a much easier,
1224
- // "close enough most of the time" alternative for positive tabindexes which should generally
1225
- // be avoided anyway...
1226
- /** First tabbable node in container, __DOM__ order; `undefined` if none. */
1227
- firstDomTabbableNode: firstDomTabbableNode,
1228
- /** Last tabbable node in container, __DOM__ order; `undefined` if none. */
1229
- lastDomTabbableNode: lastDomTabbableNode,
1230
- /**
1231
- * Finds the __tabbable__ node that follows the given node in the specified direction,
1232
- * in this container, if any.
1233
- * @param {HTMLElement} node
1234
- * @param {boolean} [forward] True if going in forward tab order; false if going
1235
- * in reverse.
1236
- * @returns {HTMLElement|undefined} The next tabbable node, if any.
1237
- */
1238
- nextTabbableNode: function nextTabbableNode(node) {
1239
- var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1240
- var nodeIdx = tabbableNodes.indexOf(node);
1241
- if (nodeIdx < 0) {
1242
- // either not tabbable nor focusable, or was focused but not tabbable (negative tabindex):
1243
- // since `node` should at least have been focusable, we assume that's the case and mimic
1244
- // what browsers do, which is set focus to the next node in __document position order__,
1245
- // regardless of positive tabindexes, if any -- and for reasons explained in the NOTE
1246
- // above related to `firstDomTabbable` and `lastDomTabbable` properties, we fall back to
1247
- // basic DOM order
1248
- if (forward) {
1249
- return focusableNodes.slice(focusableNodes.indexOf(node) + 1).find(function (el) {
1250
- return isTabbable(el);
1251
- });
1252
- }
1253
- return focusableNodes.slice(0, focusableNodes.indexOf(node)).reverse().find(function (el) {
1254
- return isTabbable(el);
1255
- });
1256
- }
1257
- return tabbableNodes[nodeIdx + (forward ? 1 : -1)];
1258
- }
1259
- };
1260
- });
1261
- state.tabbableGroups = state.containerGroups.filter(function (group) {
1262
- return group.tabbableNodes.length > 0;
1263
- });
1264
-
1265
- // throw if no groups have tabbable nodes and we don't have a fallback focus node either
1266
- if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
1267
- ) {
1268
- throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
1269
- }
1270
-
1271
- // NOTE: Positive tabindexes are only properly supported in single-container traps because
1272
- // doing it across multiple containers where tabindexes could be all over the place
1273
- // would require Tabbable to support multiple containers, would require additional
1274
- // specialized Shadow DOM support, and would require Tabbable's multi-container support
1275
- // to look at those containers in document position order rather than user-provided
1276
- // order (as they are treated in Focus-trap, for legacy reasons). See discussion on
1277
- // https://github.com/focus-trap/focus-trap/issues/375 for more details.
1278
- if (state.containerGroups.find(function (g) {
1279
- return g.posTabIndexesFound;
1280
- }) && state.containerGroups.length > 1) {
1281
- throw new Error("At least one node with a positive tabindex was found in one of your focus-trap's multiple containers. Positive tabindexes are only supported in single-container focus-traps.");
1282
- }
1283
- };
1284
-
1285
- /**
1286
- * Gets the current activeElement. If it's a web-component and has open shadow-root
1287
- * it will recursively search inside shadow roots for the "true" activeElement.
1288
- *
1289
- * @param {Document | ShadowRoot} el
1290
- *
1291
- * @returns {HTMLElement} The element that currently has the focus
1292
- **/
1293
- var getActiveElement = function getActiveElement(el) {
1294
- var activeElement = el.activeElement;
1295
- if (!activeElement) {
1296
- return;
1297
- }
1298
- if (activeElement.shadowRoot && activeElement.shadowRoot.activeElement !== null) {
1299
- return getActiveElement(activeElement.shadowRoot);
1300
- }
1301
- return activeElement;
1302
- };
1303
- var tryFocus = function tryFocus(node) {
1304
- if (node === false) {
1305
- return;
1306
- }
1307
- if (node === getActiveElement(document)) {
1308
- return;
1309
- }
1310
- if (!node || !node.focus) {
1311
- tryFocus(getInitialFocusNode());
1312
- return;
1313
- }
1314
- node.focus({
1315
- preventScroll: !!config.preventScroll
1316
- });
1317
- // NOTE: focus() API does not trigger focusIn event so set MRU node manually
1318
- state.mostRecentlyFocusedNode = node;
1319
- if (isSelectableInput(node)) {
1320
- node.select();
1321
- }
1322
- };
1323
- var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
1324
- var node = getNodeForOption('setReturnFocus', previousActiveElement);
1325
- return node ? node : node === false ? false : previousActiveElement;
1326
- };
1327
-
1328
- /**
1329
- * Finds the next node (in either direction) where focus should move according to a
1330
- * keyboard focus-in event.
1331
- * @param {Object} params
1332
- * @param {Node} [params.target] Known target __from which__ to navigate, if any.
1333
- * @param {KeyboardEvent|FocusEvent} [params.event] Event to use if `target` isn't known (event
1334
- * will be used to determine the `target`). Ignored if `target` is specified.
1335
- * @param {boolean} [params.isBackward] True if focus should move backward.
1336
- * @returns {Node|undefined} The next node, or `undefined` if a next node couldn't be
1337
- * determined given the current state of the trap.
1338
- */
1339
- var findNextNavNode = function findNextNavNode(_ref2) {
1340
- var target = _ref2.target,
1341
- event = _ref2.event,
1342
- _ref2$isBackward = _ref2.isBackward,
1343
- isBackward = _ref2$isBackward === void 0 ? false : _ref2$isBackward;
1344
- target = target || getActualTarget(event);
1345
- updateTabbableNodes();
1346
- var destinationNode = null;
1347
- if (state.tabbableGroups.length > 0) {
1348
- // make sure the target is actually contained in a group
1349
- // NOTE: the target may also be the container itself if it's focusable
1350
- // with tabIndex='-1' and was given initial focus
1351
- var containerIndex = findContainerIndex(target, event);
1352
- var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
1353
- if (containerIndex < 0) {
1354
- // target not found in any group: quite possible focus has escaped the trap,
1355
- // so bring it back into...
1356
- if (isBackward) {
1357
- // ...the last node in the last group
1358
- destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
1359
- } else {
1360
- // ...the first node in the first group
1361
- destinationNode = state.tabbableGroups[0].firstTabbableNode;
1362
- }
1363
- } else if (isBackward) {
1364
- // REVERSE
1365
-
1366
- // is the target the first tabbable node in a group?
1367
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
1368
- var firstTabbableNode = _ref3.firstTabbableNode;
1369
- return target === firstTabbableNode;
1370
- });
1371
- if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
1372
- // an exception case where the target is either the container itself, or
1373
- // a non-tabbable node that was given focus (i.e. tabindex is negative
1374
- // and user clicked on it or node was programmatically given focus)
1375
- // and is not followed by any other tabbable node, in which
1376
- // case, we should handle shift+tab as if focus were on the container's
1377
- // first tabbable node, and go to the last tabbable node of the LAST group
1378
- startOfGroupIndex = containerIndex;
1379
- }
1380
- if (startOfGroupIndex >= 0) {
1381
- // YES: then shift+tab should go to the last tabbable node in the
1382
- // previous group (and wrap around to the last tabbable node of
1383
- // the LAST group if it's the first tabbable node of the FIRST group)
1384
- var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
1385
- var destinationGroup = state.tabbableGroups[destinationGroupIndex];
1386
- destinationNode = getTabIndex(target) >= 0 ? destinationGroup.lastTabbableNode : destinationGroup.lastDomTabbableNode;
1387
- } else if (!isTabEvent(event)) {
1388
- // user must have customized the nav keys so we have to move focus manually _within_
1389
- // the active group: do this based on the order determined by tabbable()
1390
- destinationNode = containerGroup.nextTabbableNode(target, false);
1391
- }
1392
- } else {
1393
- // FORWARD
1394
-
1395
- // is the target the last tabbable node in a group?
1396
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref4) {
1397
- var lastTabbableNode = _ref4.lastTabbableNode;
1398
- return target === lastTabbableNode;
1399
- });
1400
- if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
1401
- // an exception case where the target is the container itself, or
1402
- // a non-tabbable node that was given focus (i.e. tabindex is negative
1403
- // and user clicked on it or node was programmatically given focus)
1404
- // and is not followed by any other tabbable node, in which
1405
- // case, we should handle tab as if focus were on the container's
1406
- // last tabbable node, and go to the first tabbable node of the FIRST group
1407
- lastOfGroupIndex = containerIndex;
1408
- }
1409
- if (lastOfGroupIndex >= 0) {
1410
- // YES: then tab should go to the first tabbable node in the next
1411
- // group (and wrap around to the first tabbable node of the FIRST
1412
- // group if it's the last tabbable node of the LAST group)
1413
- var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
1414
- var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
1415
- destinationNode = getTabIndex(target) >= 0 ? _destinationGroup.firstTabbableNode : _destinationGroup.firstDomTabbableNode;
1416
- } else if (!isTabEvent(event)) {
1417
- // user must have customized the nav keys so we have to move focus manually _within_
1418
- // the active group: do this based on the order determined by tabbable()
1419
- destinationNode = containerGroup.nextTabbableNode(target);
1420
- }
1421
- }
1422
- } else {
1423
- // no groups available
1424
- // NOTE: the fallbackFocus option does not support returning false to opt-out
1425
- destinationNode = getNodeForOption('fallbackFocus');
1426
- }
1427
- return destinationNode;
1428
- };
1429
-
1430
- // This needs to be done on mousedown and touchstart instead of click
1431
- // so that it precedes the focus event.
1432
- var checkPointerDown = function checkPointerDown(e) {
1433
- var target = getActualTarget(e);
1434
- if (findContainerIndex(target, e) >= 0) {
1435
- // allow the click since it ocurred inside the trap
1436
- return;
1437
- }
1438
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1439
- // immediately deactivate the trap
1440
- trap.deactivate({
1441
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
1442
- // which will result in the outside click setting focus to the node
1443
- // that was clicked (and if not focusable, to "nothing"); by setting
1444
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
1445
- // on activation (or the configured `setReturnFocus` node), whether the
1446
- // outside click was on a focusable node or not
1447
- returnFocus: config.returnFocusOnDeactivate
1448
- });
1449
- return;
1450
- }
1451
-
1452
- // This is needed for mobile devices.
1453
- // (If we'll only let `click` events through,
1454
- // then on mobile they will be blocked anyways if `touchstart` is blocked.)
1455
- if (valueOrHandler(config.allowOutsideClick, e)) {
1456
- // allow the click outside the trap to take place
1457
- return;
1458
- }
1459
-
1460
- // otherwise, prevent the click
1461
- e.preventDefault();
1462
- };
1463
-
1464
- // In case focus escapes the trap for some strange reason, pull it back in.
1465
- // NOTE: the focusIn event is NOT cancelable, so if focus escapes, it may cause unexpected
1466
- // scrolling if the node that got focused was out of view; there's nothing we can do to
1467
- // prevent that from happening by the time we discover that focus escaped
1468
- var checkFocusIn = function checkFocusIn(event) {
1469
- var target = getActualTarget(event);
1470
- var targetContained = findContainerIndex(target, event) >= 0;
1471
-
1472
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
1473
- if (targetContained || target instanceof Document) {
1474
- if (targetContained) {
1475
- state.mostRecentlyFocusedNode = target;
1476
- }
1477
- } else {
1478
- // escaped! pull it back in to where it just left
1479
- event.stopImmediatePropagation();
1480
-
1481
- // focus will escape if the MRU node had a positive tab index and user tried to nav forward;
1482
- // it will also escape if the MRU node had a 0 tab index and user tried to nav backward
1483
- // toward a node with a positive tab index
1484
- var nextNode; // next node to focus, if we find one
1485
- var navAcrossContainers = true;
1486
- if (state.mostRecentlyFocusedNode) {
1487
- if (getTabIndex(state.mostRecentlyFocusedNode) > 0) {
1488
- // MRU container index must be >=0 otherwise we wouldn't have it as an MRU node...
1489
- var mruContainerIdx = findContainerIndex(state.mostRecentlyFocusedNode);
1490
- // there MAY not be any tabbable nodes in the container if there are at least 2 containers
1491
- // and the MRU node is focusable but not tabbable (focus-trap requires at least 1 container
1492
- // with at least one tabbable node in order to function, so this could be the other container
1493
- // with nothing tabbable in it)
1494
- var tabbableNodes = state.containerGroups[mruContainerIdx].tabbableNodes;
1495
- if (tabbableNodes.length > 0) {
1496
- // MRU tab index MAY not be found if the MRU node is focusable but not tabbable
1497
- var mruTabIdx = tabbableNodes.findIndex(function (node) {
1498
- return node === state.mostRecentlyFocusedNode;
1499
- });
1500
- if (mruTabIdx >= 0) {
1501
- if (config.isKeyForward(state.recentNavEvent)) {
1502
- if (mruTabIdx + 1 < tabbableNodes.length) {
1503
- nextNode = tabbableNodes[mruTabIdx + 1];
1504
- navAcrossContainers = false;
1505
- }
1506
- // else, don't wrap within the container as focus should move to next/previous
1507
- // container
1508
- } else {
1509
- if (mruTabIdx - 1 >= 0) {
1510
- nextNode = tabbableNodes[mruTabIdx - 1];
1511
- navAcrossContainers = false;
1512
- }
1513
- // else, don't wrap within the container as focus should move to next/previous
1514
- // container
1515
- }
1516
- // else, don't find in container order without considering direction too
1517
- }
1518
- }
1519
- // else, no tabbable nodes in that container (which means we must have at least one other
1520
- // container with at least one tabbable node in it, otherwise focus-trap would've thrown
1521
- // an error the last time updateTabbableNodes() was run): find next node among all known
1522
- // containers
1523
- } else {
1524
- // check to see if there's at least one tabbable node with a positive tab index inside
1525
- // the trap because focus seems to escape when navigating backward from a tabbable node
1526
- // with tabindex=0 when this is the case (instead of wrapping to the tabbable node with
1527
- // the greatest positive tab index like it should)
1528
- if (!state.containerGroups.some(function (g) {
1529
- return g.tabbableNodes.some(function (n) {
1530
- return getTabIndex(n) > 0;
1531
- });
1532
- })) {
1533
- // no containers with tabbable nodes with positive tab indexes which means the focus
1534
- // escaped for some other reason and we should just execute the fallback to the
1535
- // MRU node or initial focus node, if any
1536
- navAcrossContainers = false;
1537
- }
1538
- }
1539
- } else {
1540
- // no MRU node means we're likely in some initial condition when the trap has just
1541
- // been activated and initial focus hasn't been given yet, in which case we should
1542
- // fall through to trying to focus the initial focus node, which is what should
1543
- // happen below at this point in the logic
1544
- navAcrossContainers = false;
1545
- }
1546
- if (navAcrossContainers) {
1547
- nextNode = findNextNavNode({
1548
- // move FROM the MRU node, not event-related node (which will be the node that is
1549
- // outside the trap causing the focus escape we're trying to fix)
1550
- target: state.mostRecentlyFocusedNode,
1551
- isBackward: config.isKeyBackward(state.recentNavEvent)
1552
- });
1553
- }
1554
- if (nextNode) {
1555
- tryFocus(nextNode);
1556
- } else {
1557
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
1558
- }
1559
- }
1560
- state.recentNavEvent = undefined; // clear
1561
- };
1562
-
1563
- // Hijack key nav events on the first and last focusable nodes of the trap,
1564
- // in order to prevent focus from escaping. If it escapes for even a
1565
- // moment it can end up scrolling the page and causing confusion so we
1566
- // kind of need to capture the action at the keydown phase.
1567
- var checkKeyNav = function checkKeyNav(event) {
1568
- var isBackward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1569
- state.recentNavEvent = event;
1570
- var destinationNode = findNextNavNode({
1571
- event: event,
1572
- isBackward: isBackward
1573
- });
1574
- if (destinationNode) {
1575
- if (isTabEvent(event)) {
1576
- // since tab natively moves focus, we wouldn't have a destination node unless we
1577
- // were on the edge of a container and had to move to the next/previous edge, in
1578
- // which case we want to prevent default to keep the browser from moving focus
1579
- // to where it normally would
1580
- event.preventDefault();
1581
- }
1582
- tryFocus(destinationNode);
1583
- }
1584
- // else, let the browser take care of [shift+]tab and move the focus
1585
- };
1586
-
1587
- var checkKey = function checkKey(event) {
1588
- if (isEscapeEvent(event) && valueOrHandler(config.escapeDeactivates, event) !== false) {
1589
- event.preventDefault();
1590
- trap.deactivate();
1591
- return;
1592
- }
1593
- if (config.isKeyForward(event) || config.isKeyBackward(event)) {
1594
- checkKeyNav(event, config.isKeyBackward(event));
1595
- }
1596
- };
1597
- var checkClick = function checkClick(e) {
1598
- var target = getActualTarget(e);
1599
- if (findContainerIndex(target, e) >= 0) {
1600
- return;
1601
- }
1602
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
1603
- return;
1604
- }
1605
- if (valueOrHandler(config.allowOutsideClick, e)) {
1606
- return;
1607
- }
1608
- e.preventDefault();
1609
- e.stopImmediatePropagation();
1610
- };
1611
-
1612
- //
1613
- // EVENT LISTENERS
1614
- //
1615
-
1616
- var addListeners = function addListeners() {
1617
- if (!state.active) {
1618
- return;
1619
- }
1620
-
1621
- // There can be only one listening focus trap at a time
1622
- activeFocusTraps.activateTrap(trapStack, trap);
1623
-
1624
- // Delay ensures that the focused element doesn't capture the event
1625
- // that caused the focus trap activation.
1626
- state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
1627
- tryFocus(getInitialFocusNode());
1628
- }) : tryFocus(getInitialFocusNode());
1629
- doc.addEventListener('focusin', checkFocusIn, true);
1630
- doc.addEventListener('mousedown', checkPointerDown, {
1631
- capture: true,
1632
- passive: false
1633
- });
1634
- doc.addEventListener('touchstart', checkPointerDown, {
1635
- capture: true,
1636
- passive: false
1637
- });
1638
- doc.addEventListener('click', checkClick, {
1639
- capture: true,
1640
- passive: false
1641
- });
1642
- doc.addEventListener('keydown', checkKey, {
1643
- capture: true,
1644
- passive: false
1645
- });
1646
- return trap;
1647
- };
1648
- var removeListeners = function removeListeners() {
1649
- if (!state.active) {
1650
- return;
1651
- }
1652
- doc.removeEventListener('focusin', checkFocusIn, true);
1653
- doc.removeEventListener('mousedown', checkPointerDown, true);
1654
- doc.removeEventListener('touchstart', checkPointerDown, true);
1655
- doc.removeEventListener('click', checkClick, true);
1656
- doc.removeEventListener('keydown', checkKey, true);
1657
- return trap;
1658
- };
1659
-
1660
- //
1661
- // MUTATION OBSERVER
1662
- //
1663
-
1664
- var checkDomRemoval = function checkDomRemoval(mutations) {
1665
- var isFocusedNodeRemoved = mutations.some(function (mutation) {
1666
- var removedNodes = Array.from(mutation.removedNodes);
1667
- return removedNodes.some(function (node) {
1668
- return node === state.mostRecentlyFocusedNode;
1669
- });
1670
- });
1671
-
1672
- // If the currently focused is removed then browsers will move focus to the
1673
- // <body> element. If this happens, try to move focus back into the trap.
1674
- if (isFocusedNodeRemoved) {
1675
- tryFocus(getInitialFocusNode());
1676
- }
1677
- };
1678
-
1679
- // Use MutationObserver - if supported - to detect if focused node is removed
1680
- // from the DOM.
1681
- var mutationObserver = typeof window !== 'undefined' && 'MutationObserver' in window ? new MutationObserver(checkDomRemoval) : undefined;
1682
- var updateObservedNodes = function updateObservedNodes() {
1683
- if (!mutationObserver) {
1684
- return;
1685
- }
1686
- mutationObserver.disconnect();
1687
- if (state.active && !state.paused) {
1688
- state.containers.map(function (container) {
1689
- mutationObserver.observe(container, {
1690
- subtree: true,
1691
- childList: true
1692
- });
1693
- });
1694
- }
1695
- };
1696
-
1697
- //
1698
- // TRAP DEFINITION
1699
- //
1700
-
1701
- trap = {
1702
- get active() {
1703
- return state.active;
1704
- },
1705
- get paused() {
1706
- return state.paused;
1707
- },
1708
- activate: function activate(activateOptions) {
1709
- if (state.active) {
1710
- return this;
1711
- }
1712
- var onActivate = getOption(activateOptions, 'onActivate');
1713
- var onPostActivate = getOption(activateOptions, 'onPostActivate');
1714
- var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
1715
- if (!checkCanFocusTrap) {
1716
- updateTabbableNodes();
1717
- }
1718
- state.active = true;
1719
- state.paused = false;
1720
- state.nodeFocusedBeforeActivation = doc.activeElement;
1721
- onActivate === null || onActivate === void 0 || onActivate();
1722
- var finishActivation = function finishActivation() {
1723
- if (checkCanFocusTrap) {
1724
- updateTabbableNodes();
1725
- }
1726
- addListeners();
1727
- updateObservedNodes();
1728
- onPostActivate === null || onPostActivate === void 0 || onPostActivate();
1729
- };
1730
- if (checkCanFocusTrap) {
1731
- checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
1732
- return this;
1733
- }
1734
- finishActivation();
1735
- return this;
1736
- },
1737
- deactivate: function deactivate(deactivateOptions) {
1738
- if (!state.active) {
1739
- return this;
1740
- }
1741
- var options = _objectSpread2({
1742
- onDeactivate: config.onDeactivate,
1743
- onPostDeactivate: config.onPostDeactivate,
1744
- checkCanReturnFocus: config.checkCanReturnFocus
1745
- }, deactivateOptions);
1746
- clearTimeout(state.delayInitialFocusTimer); // noop if undefined
1747
- state.delayInitialFocusTimer = undefined;
1748
- removeListeners();
1749
- state.active = false;
1750
- state.paused = false;
1751
- updateObservedNodes();
1752
- activeFocusTraps.deactivateTrap(trapStack, trap);
1753
- var onDeactivate = getOption(options, 'onDeactivate');
1754
- var onPostDeactivate = getOption(options, 'onPostDeactivate');
1755
- var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
1756
- var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
1757
- onDeactivate === null || onDeactivate === void 0 || onDeactivate();
1758
- var finishDeactivation = function finishDeactivation() {
1759
- delay(function () {
1760
- if (returnFocus) {
1761
- tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
1762
- }
1763
- onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
1764
- });
1765
- };
1766
- if (returnFocus && checkCanReturnFocus) {
1767
- checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
1768
- return this;
1769
- }
1770
- finishDeactivation();
1771
- return this;
1772
- },
1773
- pause: function pause(pauseOptions) {
1774
- if (state.paused || !state.active) {
1775
- return this;
1776
- }
1777
- var onPause = getOption(pauseOptions, 'onPause');
1778
- var onPostPause = getOption(pauseOptions, 'onPostPause');
1779
- state.paused = true;
1780
- onPause === null || onPause === void 0 || onPause();
1781
- removeListeners();
1782
- updateObservedNodes();
1783
- onPostPause === null || onPostPause === void 0 || onPostPause();
1784
- return this;
1785
- },
1786
- unpause: function unpause(unpauseOptions) {
1787
- if (!state.paused || !state.active) {
1788
- return this;
1789
- }
1790
- var onUnpause = getOption(unpauseOptions, 'onUnpause');
1791
- var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');
1792
- state.paused = false;
1793
- onUnpause === null || onUnpause === void 0 || onUnpause();
1794
- updateTabbableNodes();
1795
- addListeners();
1796
- updateObservedNodes();
1797
- onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
1798
- return this;
1799
- },
1800
- updateContainerElements: function updateContainerElements(containerElements) {
1801
- var elementsAsArray = [].concat(containerElements).filter(Boolean);
1802
- state.containers = elementsAsArray.map(function (element) {
1803
- return typeof element === 'string' ? doc.querySelector(element) : element;
1804
- });
1805
- if (state.active) {
1806
- updateTabbableNodes();
1807
- }
1808
- updateObservedNodes();
1809
- return this;
1810
- }
1811
- };
1812
-
1813
- // initialize container elements
1814
- trap.updateContainerElements(elements);
1815
- return trap;
1816
- };
1817
-
1818
322
  /**
1819
323
  * @namespace aria
1820
324
  */
@@ -2249,7 +753,7 @@ aria.replaceDialog = function (newDialogId, newFocusAfterClosed, newFocusFirst)
2249
753
  }; // end replaceDialog
2250
754
  window.aria = aria;
2251
755
 
2252
- const contentOverlayCss = "*{box-sizing:border-box}.content-block-overlay-container{position:relative;display:block;height:100%}content-overlay{display:none;position:relative;flex:0}content-overlay .content-overlay__content>*[slot=content]{height:100%;overflow:auto}content-overlay.content-overlay-active{display:block}content-overlay[vertical=left]{align-items:flex-start}content-overlay[vertical=center]{align-items:center}content-overlay[vertical=right]{align-items:flex-end}content-overlay[vertical=top]{justify-content:flex-start}content-overlay[vertical=center]{justify-content:center}content-overlay[vertical=bottom]{justify-content:flex-end}content-overlay .content-overlay-background{background:rgba(255, 255, 255, 0.8);bottom:0;display:none;top:0;z-index:100000;right:0;left:0}content-overlay .content-overlay-background.active{display:block}content-overlay .content-overlay__header{display:flex;align-items:center}content-overlay .content-overlay__close{order:2;margin-left:auto;cursor:pointer;z-index:1;appearance:none;background:none;border:none;min-width:16px}content-overlay.content-overlay--fullscreen .content-overlay-background{position:fixed}content-overlay.content-overlay--absolute{position:absolute;box-sizing:border-box;z-index:100000;height:100%;width:100%;top:0;left:0}content-overlay.content-overlay--absolute .content-overlay-background{position:absolute}content-overlay.content-overlay--absolute .content-overlay__content,content-overlay.content-overlay--fullscreen .content-overlay__content{flex:1;overflow:hidden}content-overlay [role=dialog]{display:flex;flex-direction:column;height:100%;justify-content:flex-start}content-overlay [role=dialog].hidden{display:none}body.has-dialog{overflow:hidden}";
756
+ const contentOverlayCss = "*{box-sizing:border-box}.content-block-overlay-container{position:relative;display:block;height:100%}content-overlay{display:none;position:relative;flex:0}content-overlay .content-overlay__content>*[slot=content]{height:100%;overflow:auto}content-overlay.content-overlay-active{display:block}content-overlay[vertical=left]{align-items:flex-start}content-overlay[vertical=center]{align-items:center}content-overlay[vertical=right]{align-items:flex-end}content-overlay[vertical=top]{justify-content:flex-start}content-overlay[vertical=center]{justify-content:center}content-overlay[vertical=bottom]{justify-content:flex-end}content-overlay .content-overlay-background{background:rgba(255, 255, 255, 0.8);bottom:0;display:none;top:0;z-index:100000;right:0;left:0}content-overlay .content-overlay-background.active{display:block}content-overlay .content-overlay__header{display:flex;align-items:center}content-overlay .content-overlay__close{order:2;margin-left:auto;cursor:pointer;z-index:1;appearance:none;background:none;border:none;min-width:16px}content-overlay[position=fixed] .content-overlay-background{position:fixed}content-overlay[position=absolute]{position:absolute;box-sizing:border-box;z-index:100000;height:100%;width:100%;left:0}content-overlay[position=absolute] .content-overlay-background{position:static}content-overlay[position=absolute] .content-overlay__content,content-overlay[position=fixed] .content-overlay__content{flex:1;overflow:hidden}content-overlay [role=dialog]{display:flex;flex-direction:column;height:100%;justify-content:flex-start}content-overlay [role=dialog].hidden{display:none}content-overlay[full-screen=true]{height:100%}content-overlay[full-screen=true] .content-overlay-background{height:100%}body.has-dialog{overflow:hidden}";
2253
757
 
2254
758
  const ContentOverlay = class {
2255
759
  constructor(hostRef) {
@@ -2262,6 +766,7 @@ const ContentOverlay = class {
2262
766
  this.horizontal = 'center';
2263
767
  this.vertical = 'center';
2264
768
  this.closeTitle = 'Close Overlay';
769
+ this.position = 'fixed';
2265
770
  this.isActive = false;
2266
771
  this.activeClass = '';
2267
772
  this.classString = '';
@@ -2272,6 +777,7 @@ const ContentOverlay = class {
2272
777
  }
2273
778
  onContentBlockActivated(event) {
2274
779
  if (this.hostElement.getAttribute('id') === event.detail.getAttribute('id')) {
780
+ console.log('activate');
2275
781
  event.preventDefault();
2276
782
  if (!this.isActive) {
2277
783
  this.openOverlay();
@@ -2282,37 +788,36 @@ const ContentOverlay = class {
2282
788
  }
2283
789
  }
2284
790
  async openOverlay() {
2285
- // if (this.isActive) {
2286
- // return false;
2287
- // }
2288
791
  this.isActive = true;
2289
792
  if (!this.originalMarkup) {
2290
- this.originalMarkup = this.contentSlot.querySelector('[slot="content"]').innerHTML;
793
+ this.originalMarkup = this.contentSlot.innerHTML;
2291
794
  }
2292
795
  if (this.target) {
2293
- let targetElement = document.getElementById(this.target);
796
+ let targetElement = document.querySelector(this.target);
2294
797
  if (targetElement) {
2295
798
  targetElement.classList.add('content-block-overlay-container');
2296
799
  targetElement.appendChild(this.hostElement);
2297
800
  }
801
+ // } else if (this.isFullScreen) {
802
+ // if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {
803
+ // document.body.appendChild(this.hostElement);
804
+ // }
2298
805
  }
2299
- else if (this.isFullScreen) {
2300
- if (document.querySelectorAll(`#${this.hostElement.getAttribute('id')}`).length === 1) {
2301
- document.body.appendChild(this.hostElement);
2302
- }
2303
- }
2304
- if (this.contentSlot) {
806
+ if (this.originalMarkup) {
2305
807
  this.contentSlot.innerHTML = this.originalMarkup;
2306
- this.setComputedActiveClass();
2307
- if (this.isFullScreen) {
2308
- this.focusTrap = createFocusTrap(this.hostElement, {
2309
- fallbackFocus: this.hostElement,
2310
- onDeactivate: () => {
2311
- this.isActive = false;
2312
- this.setComputedActiveClass();
2313
- },
2314
- });
808
+ if (this.contentSlot.children[0] === this.contentSlot.querySelector('script[slot="content"][type="text/template"]')) {
809
+ this.contentSlot.innerHTML = this.contentSlot.children[0].innerHTML;
2315
810
  }
811
+ this.setComputedActiveClass();
812
+ this.focusTrap = createFocusTrap(this.hostElement, {
813
+ fallbackFocus: this.hostElement,
814
+ allowOutsideClick: true,
815
+ clickOutsideDeactivates: true,
816
+ onDeactivate: () => {
817
+ this.isActive = false;
818
+ this.setComputedActiveClass();
819
+ },
820
+ });
2316
821
  }
2317
822
  this.contentOverlayActivated.emit(this.hostElement);
2318
823
  }
@@ -2330,23 +835,16 @@ const ContentOverlay = class {
2330
835
  }
2331
836
  }
2332
837
  setComputedActiveClass() {
2333
- let positioningValue = 'static';
2334
- if (this.target) {
2335
- positioningValue = 'absolute';
2336
- }
2337
- if (this.isFullScreen) {
2338
- positioningValue = 'fullscreen';
2339
- }
2340
- this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${positioningValue}`;
838
+ this.activeClass = `content-overlay ${this.isActive ? 'content-overlay-active' : 'content-overlay-inactive'} content-overlay--${this.position}`;
2341
839
  }
2342
840
  componentWillLoad() {
2343
- this.contentElement = this.hostElement.querySelector('.js-content-overlay-content');
2344
841
  WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = `${newValue}`));
842
+ WindowResizeService.registerProp(this.position).subscribe(newValue => (this.position = newValue));
2345
843
  WindowResizeService.registerProp(this.horizontal).subscribe(newValue => this.hostElement.setAttribute('horizontal', newValue));
2346
844
  WindowResizeService.registerProp(this.vertical).subscribe(newValue => this.hostElement.setAttribute('vertical', newValue));
2347
845
  WindowResizeService.registerProp(this.fullScreen).subscribe(newValue => {
2348
- if (!this.target)
2349
- this.isFullScreen = newValue === 'true';
846
+ this.fullScreen = newValue;
847
+ this.isFullScreen = newValue === 'true';
2350
848
  });
2351
849
  WindowResizeService.registerProp(this.open).subscribe(newValue => {
2352
850
  this.hostElement.setAttribute('open', newValue);
@@ -2358,7 +856,9 @@ const ContentOverlay = class {
2358
856
  this.closeOverlay();
2359
857
  }
2360
858
  render() {
2361
- return (h(Host, { class: `${this.activeClass} ${this.classString}` }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => this.closeOverlayButtonClicked(e), class: "content-overlay__close", title: this.closeTitle }, !this.hasCloseButton && (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "16", height: "16", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))), h("slot", { name: "closeButton" })), h("slot", { name: "header" })), h("div", { class: "content-overlay__content", ref: (el) => (this.contentSlot = el) }, h("slot", { name: "content" })))))));
859
+ return (h(Host, { class: `${this.activeClass} ${this.classString}`, position: this.position }, h("div", { class: "content-block-overlay-container" }, h("div", { class: `content-overlay-background ${this.isActive ? 'active' : ''}` }, h("div", { ref: element => (this.dialogElement = element), role: "dialog", "aria-modal": "true", class: this.isActive ? 'active' : 'hidden', "aria-expanded": this.isActive }, h("div", { class: "content-overlay__header" }, h("button", { onClick: e => {
860
+ this.closeOverlayButtonClicked(e);
861
+ }, class: "content-overlay__close", title: this.closeTitle }, !this.hasCloseButton && (h("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "16", height: "16", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "currentColor" }, h("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M6 18 18 6M6 6l12 12" }))), h("slot", { name: "closeButton" })), h("slot", { name: "header" })), h("div", { class: "content-overlay__content", ref: (el) => (this.contentSlot = el) }, h("slot", { name: "content" }), h("slot", null)))))));
2362
862
  }
2363
863
  componentDidRender() {
2364
864
  if (this.open === 'true') {
@@ -2377,7 +877,7 @@ const ContentOverlay = class {
2377
877
  };
2378
878
  ContentOverlay.style = contentOverlayCss;
2379
879
 
2380
- const contentSpacerCss = "*{box-sizing:border-box}content-spacer{display:block;width:100%;height:auto}content-spacer[full-height=true]{height:100%}content-spacer[text-align=left]{text-align:left}content-spacer[text-align=center]{text-align:center}content-spacer[text-align=right]{text-align:right}content-spacer[horizontal=left]{margin-left:0;margin-right:auto}content-spacer[horizontal=center]{margin-left:auto;margin-right:auto}content-spacer[horizontal=right]{margin-left:auto;margin-right:0}content-spacer[vertical]{display:flex;flex-direction:column}content-spacer[vertical=top]{justify-content:flex-start}content-spacer[vertical=center]{justify-content:center}content-spacer[vertical=bottom]{justify-content:flex-end}";
880
+ const contentSpacerCss = "*{box-sizing:border-box}content-spacer{display:block;width:100%;height:auto}content-spacer[full-height=true]{height:100%}content-spacer[text-align=left]{text-align:left}content-spacer[text-align=center]{text-align:center}content-spacer[text-align=right]{text-align:right}content-spacer[horizontal=left]{margin-left:0;margin-right:auto}content-spacer[horizontal=center]{margin-left:auto;margin-right:auto}content-spacer[horizontal=right]{margin-left:auto;margin-right:0}content-spacer[vertical=top]{display:flex;justify-content:flex-start}content-spacer[vertical=center]{display:flex;justify-content:center}content-spacer[vertical=bottom]{display:flex;justify-content:flex-end}";
2381
881
 
2382
882
  const ContentSpacingWrapper = class {
2383
883
  constructor(hostRef) {
@@ -2388,7 +888,7 @@ const ContentSpacingWrapper = class {
2388
888
  this.fullHeight = 'false';
2389
889
  this.textAlign = 'default';
2390
890
  this.horizontal = 'default';
2391
- this.vertical = 'top';
891
+ this.vertical = '';
2392
892
  this.topOffset = '0';
2393
893
  this.bottomOffset = '0';
2394
894
  this.leftOffset = '0';
@@ -2418,7 +918,7 @@ const ContentSpacingWrapper = class {
2418
918
  WindowResizeService.registerProp(this.classes).subscribe(newValue => (this.classString = newValue));
2419
919
  }
2420
920
  render() {
2421
- return (h(Host, { class: this.classString, style: this.inlineStyle }, h("slot", { name: "content" }), h("slot", null)));
921
+ return (h(Host, { class: this.classString, style: this.inlineStyle }, h("div", { class: "content-spacer__content" }, h("slot", { name: "content" }), h("slot", null))));
2422
922
  }
2423
923
  };
2424
924
  ContentSpacingWrapper.style = contentSpacerCss;