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