@haiilo/catalyst 2.5.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/catalyst/catalyst.css +2411 -2
  2. package/dist/catalyst/catalyst.esm.js +1 -1
  3. package/dist/catalyst/catalyst.esm.js.map +1 -1
  4. package/dist/catalyst/index.cdn.js +1 -0
  5. package/dist/catalyst/p-1c6eace6.js +3 -0
  6. package/dist/catalyst/p-1c6eace6.js.map +1 -0
  7. package/dist/catalyst/p-d5ac868d.entry.js +10 -0
  8. package/dist/catalyst/p-d5ac868d.entry.js.map +1 -0
  9. package/dist/catalyst/scss/_variables.tokens.scss +2 -2
  10. package/dist/catalyst/scss/core/_dialog.scss +66 -0
  11. package/dist/catalyst/scss/core/_notification.scss +10 -10
  12. package/dist/catalyst/scss/core/_typography.scss +1 -1
  13. package/dist/catalyst/scss/index.scss +1 -0
  14. package/dist/catalyst/scss/utils/_media.mixins.scss +1 -0
  15. package/dist/cjs/cat-alert_24.cjs.entry.js +1361 -43
  16. package/dist/cjs/cat-alert_24.cjs.entry.js.map +1 -1
  17. package/dist/cjs/catalyst.cjs.js +2 -2
  18. package/dist/cjs/{index-e540e911.js → index-22e41d18.js} +1 -4
  19. package/dist/cjs/index-22e41d18.js.map +1 -0
  20. package/dist/cjs/loader.cjs.js +2 -2
  21. package/dist/collection/collection-manifest.json +0 -1
  22. package/dist/collection/components/cat-button/cat-button.js +23 -6
  23. package/dist/collection/components/cat-button/cat-button.js.map +1 -1
  24. package/dist/collection/components/cat-icon/cat-icon.js +21 -9
  25. package/dist/collection/components/cat-icon/cat-icon.js.map +1 -1
  26. package/dist/collection/components/cat-input/cat-input.css +10 -0
  27. package/dist/collection/components/cat-scrollable/cat-scrollable.js +18 -14
  28. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +1 -1
  29. package/dist/collection/components/cat-textarea/cat-textarea.css +5 -0
  30. package/dist/collection/index.cdn.js +1 -0
  31. package/dist/collection/scss/_variables.tokens.scss +2 -2
  32. package/dist/collection/scss/core/_dialog.scss +66 -0
  33. package/dist/collection/scss/core/_notification.scss +10 -10
  34. package/dist/collection/scss/core/_typography.scss +1 -1
  35. package/dist/collection/scss/index.scss +1 -0
  36. package/dist/collection/scss/utils/_media.mixins.scss +1 -0
  37. package/dist/components/cat-badge.js.map +1 -1
  38. package/dist/components/cat-button2.js +7 -6
  39. package/dist/components/cat-button2.js.map +1 -1
  40. package/dist/components/cat-card.js.map +1 -1
  41. package/dist/components/cat-dropdown2.js +759 -2
  42. package/dist/components/cat-dropdown2.js.map +1 -1
  43. package/dist/components/cat-icon2.js +2 -5
  44. package/dist/components/cat-icon2.js.map +1 -1
  45. package/dist/components/cat-input.js +1 -1
  46. package/dist/components/cat-input.js.map +1 -1
  47. package/dist/components/cat-scrollable2.js +241 -14
  48. package/dist/components/cat-scrollable2.js.map +1 -1
  49. package/dist/components/cat-select-demo.js +2 -2
  50. package/dist/components/cat-select2.js +2 -187
  51. package/dist/components/cat-select2.js.map +1 -1
  52. package/dist/components/cat-textarea.js +1 -1
  53. package/dist/components/cat-textarea.js.map +1 -1
  54. package/dist/components/index.d.ts +0 -1
  55. package/dist/components/index.js +0 -1
  56. package/dist/components/index.js.map +1 -1
  57. package/dist/esm/cat-alert_24.entry.js +1355 -37
  58. package/dist/esm/cat-alert_24.entry.js.map +1 -1
  59. package/dist/esm/catalyst.js +2 -2
  60. package/dist/esm/{index-c2a28ebb.js → index-7b85fb91.js} +1 -4
  61. package/dist/esm/index-7b85fb91.js.map +1 -0
  62. package/dist/esm/loader.js +2 -2
  63. package/dist/types/components/cat-button/cat-button.d.ts +5 -0
  64. package/dist/types/components/cat-icon/cat-icon.d.ts +5 -1
  65. package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +3 -0
  66. package/dist/types/components.d.ts +17 -26
  67. package/package.json +2 -2
  68. package/dist/catalyst/p-2fdb52c9.entry.js +0 -2
  69. package/dist/catalyst/p-2fdb52c9.entry.js.map +0 -1
  70. package/dist/catalyst/p-53a1db22.js +0 -3
  71. package/dist/catalyst/p-53a1db22.js.map +0 -1
  72. package/dist/catalyst/p-5bfc70e3.entry.js +0 -2
  73. package/dist/catalyst/p-5bfc70e3.entry.js.map +0 -1
  74. package/dist/catalyst/p-60a20ebe.js +0 -10
  75. package/dist/catalyst/p-60a20ebe.js.map +0 -1
  76. package/dist/cjs/cat-modal.cjs.entry.js +0 -74
  77. package/dist/cjs/cat-modal.cjs.entry.js.map +0 -1
  78. package/dist/cjs/first-tabbable-7966cf1c.js +0 -1288
  79. package/dist/cjs/first-tabbable-7966cf1c.js.map +0 -1
  80. package/dist/cjs/index-e540e911.js.map +0 -1
  81. package/dist/collection/components/cat-modal/cat-modal.css +0 -65
  82. package/dist/collection/components/cat-modal/cat-modal.js +0 -117
  83. package/dist/collection/components/cat-modal/cat-modal.js.map +0 -1
  84. package/dist/components/cat-modal.d.ts +0 -11
  85. package/dist/components/cat-modal.js +0 -111
  86. package/dist/components/cat-modal.js.map +0 -1
  87. package/dist/components/focus-trap.esm.js +0 -763
  88. package/dist/components/focus-trap.esm.js.map +0 -1
  89. package/dist/esm/cat-modal.entry.js +0 -70
  90. package/dist/esm/cat-modal.entry.js.map +0 -1
  91. package/dist/esm/first-tabbable-4a00de61.js +0 -1284
  92. package/dist/esm/first-tabbable-4a00de61.js.map +0 -1
  93. package/dist/esm/index-c2a28ebb.js.map +0 -1
  94. package/dist/types/components/cat-modal/cat-modal.d.ts +0 -20
@@ -2,9 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-e540e911.js');
5
+ const index = require('./index-22e41d18.js');
6
6
  const catIconRegistry = require('./cat-icon-registry-671af264.js');
7
- const firstTabbable = require('./first-tabbable-7966cf1c.js');
8
7
 
9
8
  function setAttributeDefault(host, attr, value) {
10
9
  if (!host.hostElement.hasAttribute(attr) && value != null) {
@@ -445,19 +444,19 @@ const CatButton = class {
445
444
  }
446
445
  }
447
446
  get isIconButton() {
448
- return Boolean(this.icon) && this._iconOnly;
447
+ return (Boolean(this.icon) || Boolean(this.iconSrc)) && this._iconOnly;
449
448
  }
450
449
  get hasPrefixIcon() {
451
- return Boolean(this.icon) && !this._iconOnly && !this.iconRight;
450
+ return (Boolean(this.icon) || Boolean(this.iconSrc)) && !this._iconOnly && !this.iconRight;
452
451
  }
453
452
  get hasSuffixIcon() {
454
- return Boolean(this.icon) && !this._iconOnly && this.iconRight;
453
+ return (Boolean(this.icon) || Boolean(this.iconSrc)) && !this._iconOnly && this.iconRight;
455
454
  }
456
455
  get content() {
457
456
  return [
458
- this.hasPrefixIcon ? index.h("cat-icon", { icon: this.icon, size: this.iconSize, part: "prefix" }) : null,
459
- this.isIconButton ? (index.h("cat-icon", { icon: this.icon, size: this.iconSize })) : (index.h("span", { class: "cat-button-content", part: "content" }, index.h("slot", null))),
460
- this.hasSuffixIcon ? index.h("cat-icon", { icon: this.icon, size: this.iconSize, part: "suffix" }) : null,
457
+ this.hasPrefixIcon ? (index.h("cat-icon", { icon: this.icon, iconSrc: this.iconSrc, size: this.iconSize, part: "prefix" })) : null,
458
+ this.isIconButton ? (index.h("cat-icon", { icon: this.icon, iconSrc: this.iconSrc, size: this.iconSize })) : (index.h("span", { class: "cat-button-content", part: "content" }, index.h("slot", null))),
459
+ this.hasSuffixIcon ? (index.h("cat-icon", { icon: this.icon, iconSrc: this.iconSrc, size: this.iconSize, part: "suffix" })) : null,
461
460
  this.loading ? index.h("cat-spinner", { size: this.spinnerSize }) : null
462
461
  ];
463
462
  }
@@ -1107,7 +1106,7 @@ function getWindow(node) {
1107
1106
  return node;
1108
1107
  }
1109
1108
 
1110
- function getComputedStyle(element) {
1109
+ function getComputedStyle$1(element) {
1111
1110
  return getWindow(element).getComputedStyle(element);
1112
1111
  }
1113
1112
 
@@ -1150,7 +1149,7 @@ function isOverflowElement(element) {
1150
1149
  overflowX,
1151
1150
  overflowY,
1152
1151
  display
1153
- } = getComputedStyle(element);
1152
+ } = getComputedStyle$1(element);
1154
1153
  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
1155
1154
  }
1156
1155
  function isTableElement(element) {
@@ -1159,7 +1158,7 @@ function isTableElement(element) {
1159
1158
  function isContainingBlock(element) {
1160
1159
  // TODO: Try and use feature detection here instead
1161
1160
  const isFirefox = /firefox/i.test(getUAString());
1162
- const css = getComputedStyle(element); // This is non-exhaustive but covers the most common CSS properties that
1161
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1163
1162
  // create a containing block.
1164
1163
  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1165
1164
 
@@ -1304,7 +1303,7 @@ function getParentNode(node) {
1304
1303
  }
1305
1304
 
1306
1305
  function getTrueOffsetParent(element) {
1307
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1306
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
1308
1307
  return null;
1309
1308
  }
1310
1309
 
@@ -1336,11 +1335,11 @@ function getOffsetParent(element) {
1336
1335
  const window = getWindow(element);
1337
1336
  let offsetParent = getTrueOffsetParent(element);
1338
1337
 
1339
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1338
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
1340
1339
  offsetParent = getTrueOffsetParent(offsetParent);
1341
1340
  }
1342
1341
 
1343
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1342
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1344
1343
  return window;
1345
1344
  }
1346
1345
 
@@ -1447,7 +1446,7 @@ function getDocumentRect(element) {
1447
1446
  let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1448
1447
  const y = -scroll.scrollTop;
1449
1448
 
1450
- if (getComputedStyle(body || html).direction === 'rtl') {
1449
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1451
1450
  x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1452
1451
  }
1453
1452
 
@@ -1518,7 +1517,7 @@ function getNearestParentCapableOfEscapingClipping(element, clippingAncestors) {
1518
1517
 
1519
1518
  while (currentNode && !isLastTraversableNode(currentNode) && // @ts-expect-error
1520
1519
  !clippingAncestors.includes(currentNode)) {
1521
- if (isElement(currentNode) && ['absolute', 'fixed'].includes(getComputedStyle(currentNode).position)) {
1520
+ if (isElement(currentNode) && ['absolute', 'fixed'].includes(getComputedStyle$1(currentNode).position)) {
1522
1521
  break;
1523
1522
  }
1524
1523
 
@@ -1633,7 +1632,7 @@ const platform = {
1633
1632
  };
1634
1633
  },
1635
1634
  getClientRects: element => Array.from(element.getClientRects()),
1636
- isRTL: element => getComputedStyle(element).direction === 'rtl'
1635
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1637
1636
  };
1638
1637
 
1639
1638
  /**
@@ -1725,6 +1724,1287 @@ const computePosition = (reference, floating, options) => computePosition$1(refe
1725
1724
  */
1726
1725
  const timeTransitionS = 125;
1727
1726
 
1727
+ /*!
1728
+ * tabbable 6.0.0
1729
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
1730
+ */
1731
+ var candidateSelectors = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]:not(slot)', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])', 'details>summary:first-of-type', 'details'];
1732
+ var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
1733
+ var NoElement = typeof Element === 'undefined';
1734
+ var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1735
+ var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
1736
+ return element.getRootNode();
1737
+ } : function (element) {
1738
+ return element.ownerDocument;
1739
+ };
1740
+ /**
1741
+ * @param {Element} el container to check in
1742
+ * @param {boolean} includeContainer add container to check
1743
+ * @param {(node: Element) => boolean} filter filter candidates
1744
+ * @returns {Element[]}
1745
+ */
1746
+
1747
+ var getCandidates = function getCandidates(el, includeContainer, filter) {
1748
+ var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
1749
+
1750
+ if (includeContainer && matches.call(el, candidateSelector)) {
1751
+ candidates.unshift(el);
1752
+ }
1753
+
1754
+ candidates = candidates.filter(filter);
1755
+ return candidates;
1756
+ };
1757
+ /**
1758
+ * @callback GetShadowRoot
1759
+ * @param {Element} element to check for shadow root
1760
+ * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
1761
+ */
1762
+
1763
+ /**
1764
+ * @callback ShadowRootFilter
1765
+ * @param {Element} shadowHostNode the element which contains shadow content
1766
+ * @returns {boolean} true if a shadow root could potentially contain valid candidates.
1767
+ */
1768
+
1769
+ /**
1770
+ * @typedef {Object} CandidatesScope
1771
+ * @property {Element} scope contains inner candidates
1772
+ * @property {Element[]} candidates
1773
+ */
1774
+
1775
+ /**
1776
+ * @typedef {Object} IterativeOptions
1777
+ * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
1778
+ * if a function, implies shadow support is enabled and either returns the shadow root of an element
1779
+ * or a boolean stating if it has an undisclosed shadow root
1780
+ * @property {(node: Element) => boolean} filter filter candidates
1781
+ * @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list
1782
+ * @property {ShadowRootFilter} shadowRootFilter filter shadow roots;
1783
+ */
1784
+
1785
+ /**
1786
+ * @param {Element[]} elements list of element containers to match candidates from
1787
+ * @param {boolean} includeContainer add container list to check
1788
+ * @param {IterativeOptions} options
1789
+ * @returns {Array.<Element|CandidatesScope>}
1790
+ */
1791
+
1792
+
1793
+ var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
1794
+ var candidates = [];
1795
+ var elementsToCheck = Array.from(elements);
1796
+
1797
+ while (elementsToCheck.length) {
1798
+ var element = elementsToCheck.shift();
1799
+
1800
+ if (element.tagName === 'SLOT') {
1801
+ // add shadow dom slot scope (slot itself cannot be focusable)
1802
+ var assigned = element.assignedElements();
1803
+ var content = assigned.length ? assigned : element.children;
1804
+ var nestedCandidates = getCandidatesIteratively(content, true, options);
1805
+
1806
+ if (options.flatten) {
1807
+ candidates.push.apply(candidates, nestedCandidates);
1808
+ } else {
1809
+ candidates.push({
1810
+ scope: element,
1811
+ candidates: nestedCandidates
1812
+ });
1813
+ }
1814
+ } else {
1815
+ // check candidate element
1816
+ var validCandidate = matches.call(element, candidateSelector);
1817
+
1818
+ if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
1819
+ candidates.push(element);
1820
+ } // iterate over shadow content if possible
1821
+
1822
+
1823
+ var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
1824
+ typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
1825
+ var validShadowRoot = !options.shadowRootFilter || options.shadowRootFilter(element);
1826
+
1827
+ if (shadowRoot && validShadowRoot) {
1828
+ // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
1829
+ // shadow exists, so look at light dom children as fallback BUT create a scope for any
1830
+ // child candidates found because they're likely slotted elements (elements that are
1831
+ // children of the web component element (which has the shadow), in the light dom, but
1832
+ // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
1833
+ // _after_ we return from this recursive call
1834
+ var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
1835
+
1836
+ if (options.flatten) {
1837
+ candidates.push.apply(candidates, _nestedCandidates);
1838
+ } else {
1839
+ candidates.push({
1840
+ scope: element,
1841
+ candidates: _nestedCandidates
1842
+ });
1843
+ }
1844
+ } else {
1845
+ // there's not shadow so just dig into the element's (light dom) children
1846
+ // __without__ giving the element special scope treatment
1847
+ elementsToCheck.unshift.apply(elementsToCheck, element.children);
1848
+ }
1849
+ }
1850
+ }
1851
+
1852
+ return candidates;
1853
+ };
1854
+
1855
+ var getTabindex = function getTabindex(node, isScope) {
1856
+ if (node.tabIndex < 0) {
1857
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
1858
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
1859
+ // yet they are still part of the regular tab order; in FF, they get a default
1860
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
1861
+ // order, consider their tab index to be 0.
1862
+ // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
1863
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
1864
+ //
1865
+ // isScope is positive for custom element with shadow root or slot that by default
1866
+ // have tabIndex -1, but need to be sorted by document order in order for their
1867
+ // content to be inserted in the correct position
1868
+ if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
1869
+ return 0;
1870
+ }
1871
+ }
1872
+
1873
+ return node.tabIndex;
1874
+ };
1875
+
1876
+ var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
1877
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
1878
+ };
1879
+
1880
+ var isInput = function isInput(node) {
1881
+ return node.tagName === 'INPUT';
1882
+ };
1883
+
1884
+ var isHiddenInput = function isHiddenInput(node) {
1885
+ return isInput(node) && node.type === 'hidden';
1886
+ };
1887
+
1888
+ var isDetailsWithSummary = function isDetailsWithSummary(node) {
1889
+ var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
1890
+ return child.tagName === 'SUMMARY';
1891
+ });
1892
+ return r;
1893
+ };
1894
+
1895
+ var getCheckedRadio = function getCheckedRadio(nodes, form) {
1896
+ for (var i = 0; i < nodes.length; i++) {
1897
+ if (nodes[i].checked && nodes[i].form === form) {
1898
+ return nodes[i];
1899
+ }
1900
+ }
1901
+ };
1902
+
1903
+ var isTabbableRadio = function isTabbableRadio(node) {
1904
+ if (!node.name) {
1905
+ return true;
1906
+ }
1907
+
1908
+ var radioScope = node.form || getRootNode(node);
1909
+
1910
+ var queryRadios = function queryRadios(name) {
1911
+ return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
1912
+ };
1913
+
1914
+ var radioSet;
1915
+
1916
+ if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
1917
+ radioSet = queryRadios(window.CSS.escape(node.name));
1918
+ } else {
1919
+ try {
1920
+ radioSet = queryRadios(node.name);
1921
+ } catch (err) {
1922
+ // eslint-disable-next-line no-console
1923
+ 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);
1924
+ return false;
1925
+ }
1926
+ }
1927
+
1928
+ var checked = getCheckedRadio(radioSet, node.form);
1929
+ return !checked || checked === node;
1930
+ };
1931
+
1932
+ var isRadio = function isRadio(node) {
1933
+ return isInput(node) && node.type === 'radio';
1934
+ };
1935
+
1936
+ var isNonTabbableRadio = function isNonTabbableRadio(node) {
1937
+ return isRadio(node) && !isTabbableRadio(node);
1938
+ }; // determines if a node is ultimately attached to the window's document
1939
+
1940
+
1941
+ var isNodeAttached = function isNodeAttached(node) {
1942
+ var _nodeRootHost;
1943
+
1944
+ // The root node is the shadow root if the node is in a shadow DOM; some document otherwise
1945
+ // (but NOT _the_ document; see second 'If' comment below for more).
1946
+ // If rootNode is shadow root, it'll have a host, which is the element to which the shadow
1947
+ // is attached, and the one we need to check if it's in the document or not (because the
1948
+ // shadow, and all nodes it contains, is never considered in the document since shadows
1949
+ // behave like self-contained DOMs; but if the shadow's HOST, which is part of the document,
1950
+ // is hidden, or is not in the document itself but is detached, it will affect the shadow's
1951
+ // visibility, including all the nodes it contains). The host could be any normal node,
1952
+ // or a custom element (i.e. web component). Either way, that's the one that is considered
1953
+ // part of the document, not the shadow root, nor any of its children (i.e. the node being
1954
+ // tested).
1955
+ // To further complicate things, we have to look all the way up until we find a shadow HOST
1956
+ // that is attached (or find none) because the node might be in nested shadows...
1957
+ // If rootNode is not a shadow root, it won't have a host, and so rootNode should be the
1958
+ // document (per the docs) and while it's a Document-type object, that document does not
1959
+ // appear to be the same as the node's `ownerDocument` for some reason, so it's safer
1960
+ // to ignore the rootNode at this point, and use `node.ownerDocument`. Otherwise,
1961
+ // using `rootNode.contains(node)` will _always_ be true we'll get false-positives when
1962
+ // node is actually detached.
1963
+ var nodeRootHost = getRootNode(node).host;
1964
+ var attached = !!((_nodeRootHost = nodeRootHost) !== null && _nodeRootHost !== void 0 && _nodeRootHost.ownerDocument.contains(nodeRootHost) || node.ownerDocument.contains(node));
1965
+
1966
+ while (!attached && nodeRootHost) {
1967
+ var _nodeRootHost2;
1968
+
1969
+ // since it's not attached and we have a root host, the node MUST be in a nested shadow DOM,
1970
+ // which means we need to get the host's host and check if that parent host is contained
1971
+ // in (i.e. attached to) the document
1972
+ nodeRootHost = getRootNode(nodeRootHost).host;
1973
+ attached = !!((_nodeRootHost2 = nodeRootHost) !== null && _nodeRootHost2 !== void 0 && _nodeRootHost2.ownerDocument.contains(nodeRootHost));
1974
+ }
1975
+
1976
+ return attached;
1977
+ };
1978
+
1979
+ var isZeroArea = function isZeroArea(node) {
1980
+ var _node$getBoundingClie = node.getBoundingClientRect(),
1981
+ width = _node$getBoundingClie.width,
1982
+ height = _node$getBoundingClie.height;
1983
+
1984
+ return width === 0 && height === 0;
1985
+ };
1986
+
1987
+ var isHidden = function isHidden(node, _ref) {
1988
+ var displayCheck = _ref.displayCheck,
1989
+ getShadowRoot = _ref.getShadowRoot;
1990
+
1991
+ // NOTE: visibility will be `undefined` if node is detached from the document
1992
+ // (see notes about this further down), which means we will consider it visible
1993
+ // (this is legacy behavior from a very long way back)
1994
+ // NOTE: we check this regardless of `displayCheck="none"` because this is a
1995
+ // _visibility_ check, not a _display_ check
1996
+ if (getComputedStyle(node).visibility === 'hidden') {
1997
+ return true;
1998
+ }
1999
+
2000
+ var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
2001
+ var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
2002
+
2003
+ if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
2004
+ return true;
2005
+ }
2006
+
2007
+ if (!displayCheck || displayCheck === 'full' || displayCheck === 'legacy-full') {
2008
+ if (typeof getShadowRoot === 'function') {
2009
+ // figure out if we should consider the node to be in an undisclosed shadow and use the
2010
+ // 'non-zero-area' fallback
2011
+ var originalNode = node;
2012
+
2013
+ while (node) {
2014
+ var parentElement = node.parentElement;
2015
+ var rootNode = getRootNode(node);
2016
+
2017
+ if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
2018
+ ) {
2019
+ // node has an undisclosed shadow which means we can only treat it as a black box, so we
2020
+ // fall back to a non-zero-area test
2021
+ return isZeroArea(node);
2022
+ } else if (node.assignedSlot) {
2023
+ // iterate up slot
2024
+ node = node.assignedSlot;
2025
+ } else if (!parentElement && rootNode !== node.ownerDocument) {
2026
+ // cross shadow boundary
2027
+ node = rootNode.host;
2028
+ } else {
2029
+ // iterate up normal dom
2030
+ node = parentElement;
2031
+ }
2032
+ }
2033
+
2034
+ node = originalNode;
2035
+ } // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
2036
+ // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
2037
+ // it might be a falsy value, which means shadow DOM support is disabled
2038
+ // Since we didn't find it sitting in an undisclosed shadow (or shadows are disabled)
2039
+ // now we can just test to see if it would normally be visible or not, provided it's
2040
+ // attached to the main document.
2041
+ // NOTE: We must consider case where node is inside a shadow DOM and given directly to
2042
+ // `isTabbable()` or `isFocusable()` -- regardless of `getShadowRoot` option setting.
2043
+
2044
+
2045
+ if (isNodeAttached(node)) {
2046
+ // this works wherever the node is: if there's at least one client rect, it's
2047
+ // somehow displayed; it also covers the CSS 'display: contents' case where the
2048
+ // node itself is hidden in place of its contents; and there's no need to search
2049
+ // up the hierarchy either
2050
+ return !node.getClientRects().length;
2051
+ } // Else, the node isn't attached to the document, which means the `getClientRects()`
2052
+ // API will __always__ return zero rects (this can happen, for example, if React
2053
+ // is used to render nodes onto a detached tree, as confirmed in this thread:
2054
+ // https://github.com/facebook/react/issues/9117#issuecomment-284228870)
2055
+ //
2056
+ // It also means that even window.getComputedStyle(node).display will return `undefined`
2057
+ // because styles are only computed for nodes that are in the document.
2058
+ //
2059
+ // NOTE: THIS HAS BEEN THE CASE FOR YEARS. It is not new, nor is it caused by tabbable
2060
+ // somehow. Though it was never stated officially, anyone who has ever used tabbable
2061
+ // APIs on nodes in detached containers has actually implicitly used tabbable in what
2062
+ // was later (as of v5.2.0 on Apr 9, 2021) called `displayCheck="none"` mode -- essentially
2063
+ // considering __everything__ to be visible because of the innability to determine styles.
2064
+ //
2065
+ // v6.0.0: As of this major release, the default 'full' option __no longer treats detached
2066
+ // nodes as visible with the 'none' fallback.__
2067
+
2068
+
2069
+ if (displayCheck !== 'legacy-full') {
2070
+ return true; // hidden
2071
+ } // else, fallback to 'none' mode and consider the node visible
2072
+
2073
+ } else if (displayCheck === 'non-zero-area') {
2074
+ // NOTE: Even though this tests that the node's client rect is non-zero to determine
2075
+ // whether it's displayed, and that a detached node will __always__ have a zero-area
2076
+ // client rect, we don't special-case for whether the node is attached or not. In
2077
+ // this mode, we do want to consider nodes that have a zero area to be hidden at all
2078
+ // times, and that includes attached or not.
2079
+ return isZeroArea(node);
2080
+ } // visible, as far as we can tell, or per current `displayCheck=none` mode, we assume
2081
+ // it's visible
2082
+
2083
+
2084
+ return false;
2085
+ }; // form fields (nested) inside a disabled fieldset are not focusable/tabbable
2086
+ // unless they are in the _first_ <legend> element of the top-most disabled
2087
+ // fieldset
2088
+
2089
+
2090
+ var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
2091
+ if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
2092
+ var parentNode = node.parentElement; // check if `node` is contained in a disabled <fieldset>
2093
+
2094
+ while (parentNode) {
2095
+ if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
2096
+ // look for the first <legend> among the children of the disabled <fieldset>
2097
+ for (var i = 0; i < parentNode.children.length; i++) {
2098
+ var child = parentNode.children.item(i); // when the first <legend> (in document order) is found
2099
+
2100
+ if (child.tagName === 'LEGEND') {
2101
+ // if its parent <fieldset> is not nested in another disabled <fieldset>,
2102
+ // return whether `node` is a descendant of its first <legend>
2103
+ return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
2104
+ }
2105
+ } // the disabled <fieldset> containing `node` has no <legend>
2106
+
2107
+
2108
+ return true;
2109
+ }
2110
+
2111
+ parentNode = parentNode.parentElement;
2112
+ }
2113
+ } // else, node's tabbable/focusable state should not be affected by a fieldset's
2114
+ // enabled/disabled state
2115
+
2116
+
2117
+ return false;
2118
+ };
2119
+
2120
+ var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
2121
+ if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
2122
+ isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
2123
+ return false;
2124
+ }
2125
+
2126
+ return true;
2127
+ };
2128
+
2129
+ var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
2130
+ if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
2131
+ return false;
2132
+ }
2133
+
2134
+ return true;
2135
+ };
2136
+
2137
+ var isValidShadowRootTabbable = function isValidShadowRootTabbable(shadowHostNode) {
2138
+ var tabIndex = parseInt(shadowHostNode.getAttribute('tabindex'), 10);
2139
+
2140
+ if (isNaN(tabIndex) || tabIndex >= 0) {
2141
+ return true;
2142
+ } // If a custom element has an explicit negative tabindex,
2143
+ // browsers will not allow tab targeting said element's children.
2144
+
2145
+
2146
+ return false;
2147
+ };
2148
+ /**
2149
+ * @param {Array.<Element|CandidatesScope>} candidates
2150
+ * @returns Element[]
2151
+ */
2152
+
2153
+
2154
+ var sortByOrder = function sortByOrder(candidates) {
2155
+ var regularTabbables = [];
2156
+ var orderedTabbables = [];
2157
+ candidates.forEach(function (item, i) {
2158
+ var isScope = !!item.scope;
2159
+ var element = isScope ? item.scope : item;
2160
+ var candidateTabindex = getTabindex(element, isScope);
2161
+ var elements = isScope ? sortByOrder(item.candidates) : element;
2162
+
2163
+ if (candidateTabindex === 0) {
2164
+ isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
2165
+ } else {
2166
+ orderedTabbables.push({
2167
+ documentOrder: i,
2168
+ tabIndex: candidateTabindex,
2169
+ item: item,
2170
+ isScope: isScope,
2171
+ content: elements
2172
+ });
2173
+ }
2174
+ });
2175
+ return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
2176
+ sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
2177
+ return acc;
2178
+ }, []).concat(regularTabbables);
2179
+ };
2180
+
2181
+ var tabbable = function tabbable(el, options) {
2182
+ options = options || {};
2183
+ var candidates;
2184
+
2185
+ if (options.getShadowRoot) {
2186
+ candidates = getCandidatesIteratively([el], options.includeContainer, {
2187
+ filter: isNodeMatchingSelectorTabbable.bind(null, options),
2188
+ flatten: false,
2189
+ getShadowRoot: options.getShadowRoot,
2190
+ shadowRootFilter: isValidShadowRootTabbable
2191
+ });
2192
+ } else {
2193
+ candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
2194
+ }
2195
+
2196
+ return sortByOrder(candidates);
2197
+ };
2198
+
2199
+ var focusable = function focusable(el, options) {
2200
+ options = options || {};
2201
+ var candidates;
2202
+
2203
+ if (options.getShadowRoot) {
2204
+ candidates = getCandidatesIteratively([el], options.includeContainer, {
2205
+ filter: isNodeMatchingSelectorFocusable.bind(null, options),
2206
+ flatten: true,
2207
+ getShadowRoot: options.getShadowRoot
2208
+ });
2209
+ } else {
2210
+ candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
2211
+ }
2212
+
2213
+ return candidates;
2214
+ };
2215
+
2216
+ var isTabbable = function isTabbable(node, options) {
2217
+ options = options || {};
2218
+
2219
+ if (!node) {
2220
+ throw new Error('No node provided');
2221
+ }
2222
+
2223
+ if (matches.call(node, candidateSelector) === false) {
2224
+ return false;
2225
+ }
2226
+
2227
+ return isNodeMatchingSelectorTabbable(options, node);
2228
+ };
2229
+
2230
+ var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
2231
+
2232
+ var isFocusable = function isFocusable(node, options) {
2233
+ options = options || {};
2234
+
2235
+ if (!node) {
2236
+ throw new Error('No node provided');
2237
+ }
2238
+
2239
+ if (matches.call(node, focusableCandidateSelector) === false) {
2240
+ return false;
2241
+ }
2242
+
2243
+ return isNodeMatchingSelectorFocusable(options, node);
2244
+ };
2245
+
2246
+ /*!
2247
+ * focus-trap 7.0.0
2248
+ * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
2249
+ */
2250
+
2251
+ function ownKeys(object, enumerableOnly) {
2252
+ var keys = Object.keys(object);
2253
+
2254
+ if (Object.getOwnPropertySymbols) {
2255
+ var symbols = Object.getOwnPropertySymbols(object);
2256
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
2257
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2258
+ })), keys.push.apply(keys, symbols);
2259
+ }
2260
+
2261
+ return keys;
2262
+ }
2263
+
2264
+ function _objectSpread2(target) {
2265
+ for (var i = 1; i < arguments.length; i++) {
2266
+ var source = null != arguments[i] ? arguments[i] : {};
2267
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
2268
+ _defineProperty(target, key, source[key]);
2269
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
2270
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2271
+ });
2272
+ }
2273
+
2274
+ return target;
2275
+ }
2276
+
2277
+ function _defineProperty(obj, key, value) {
2278
+ if (key in obj) {
2279
+ Object.defineProperty(obj, key, {
2280
+ value: value,
2281
+ enumerable: true,
2282
+ configurable: true,
2283
+ writable: true
2284
+ });
2285
+ } else {
2286
+ obj[key] = value;
2287
+ }
2288
+
2289
+ return obj;
2290
+ }
2291
+
2292
+ var activeFocusTraps = function () {
2293
+ var trapQueue = [];
2294
+ return {
2295
+ activateTrap: function activateTrap(trap) {
2296
+ if (trapQueue.length > 0) {
2297
+ var activeTrap = trapQueue[trapQueue.length - 1];
2298
+
2299
+ if (activeTrap !== trap) {
2300
+ activeTrap.pause();
2301
+ }
2302
+ }
2303
+
2304
+ var trapIndex = trapQueue.indexOf(trap);
2305
+
2306
+ if (trapIndex === -1) {
2307
+ trapQueue.push(trap);
2308
+ } else {
2309
+ // move this existing trap to the front of the queue
2310
+ trapQueue.splice(trapIndex, 1);
2311
+ trapQueue.push(trap);
2312
+ }
2313
+ },
2314
+ deactivateTrap: function deactivateTrap(trap) {
2315
+ var trapIndex = trapQueue.indexOf(trap);
2316
+
2317
+ if (trapIndex !== -1) {
2318
+ trapQueue.splice(trapIndex, 1);
2319
+ }
2320
+
2321
+ if (trapQueue.length > 0) {
2322
+ trapQueue[trapQueue.length - 1].unpause();
2323
+ }
2324
+ }
2325
+ };
2326
+ }();
2327
+
2328
+ var isSelectableInput = function isSelectableInput(node) {
2329
+ return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
2330
+ };
2331
+
2332
+ var isEscapeEvent = function isEscapeEvent(e) {
2333
+ return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
2334
+ };
2335
+
2336
+ var isTabEvent = function isTabEvent(e) {
2337
+ return e.key === 'Tab' || e.keyCode === 9;
2338
+ };
2339
+
2340
+ var delay$1 = function delay(fn) {
2341
+ return setTimeout(fn, 0);
2342
+ }; // Array.find/findIndex() are not supported on IE; this replicates enough
2343
+ // of Array.findIndex() for our needs
2344
+
2345
+
2346
+ var findIndex = function findIndex(arr, fn) {
2347
+ var idx = -1;
2348
+ arr.every(function (value, i) {
2349
+ if (fn(value)) {
2350
+ idx = i;
2351
+ return false; // break
2352
+ }
2353
+
2354
+ return true; // next
2355
+ });
2356
+ return idx;
2357
+ };
2358
+ /**
2359
+ * Get an option's value when it could be a plain value, or a handler that provides
2360
+ * the value.
2361
+ * @param {*} value Option's value to check.
2362
+ * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
2363
+ * @returns {*} The `value`, or the handler's returned value.
2364
+ */
2365
+
2366
+
2367
+ var valueOrHandler = function valueOrHandler(value) {
2368
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2369
+ params[_key - 1] = arguments[_key];
2370
+ }
2371
+
2372
+ return typeof value === 'function' ? value.apply(void 0, params) : value;
2373
+ };
2374
+
2375
+ var getActualTarget = function getActualTarget(event) {
2376
+ // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
2377
+ // shadow host. However, event.target.composedPath() will be an array of
2378
+ // nodes "clicked" from inner-most (the actual element inside the shadow) to
2379
+ // outer-most (the host HTML document). If we have access to composedPath(),
2380
+ // then use its first element; otherwise, fall back to event.target (and
2381
+ // this only works for an _open_ shadow DOM; otherwise,
2382
+ // composedPath()[0] === event.target always).
2383
+ return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
2384
+ };
2385
+
2386
+ var createFocusTrap = function createFocusTrap(elements, userOptions) {
2387
+ // SSR: a live trap shouldn't be created in this type of environment so this
2388
+ // should be safe code to execute if the `document` option isn't specified
2389
+ var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
2390
+
2391
+ var config = _objectSpread2({
2392
+ returnFocusOnDeactivate: true,
2393
+ escapeDeactivates: true,
2394
+ delayInitialFocus: true
2395
+ }, userOptions);
2396
+
2397
+ var state = {
2398
+ // containers given to createFocusTrap()
2399
+ // @type {Array<HTMLElement>}
2400
+ containers: [],
2401
+ // list of objects identifying tabbable nodes in `containers` in the trap
2402
+ // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
2403
+ // is active, but the trap should never get to a state where there isn't at least one group
2404
+ // with at least one tabbable node in it (that would lead to an error condition that would
2405
+ // result in an error being thrown)
2406
+ // @type {Array<{
2407
+ // container: HTMLElement,
2408
+ // tabbableNodes: Array<HTMLElement>, // empty if none
2409
+ // focusableNodes: Array<HTMLElement>, // empty if none
2410
+ // firstTabbableNode: HTMLElement|null,
2411
+ // lastTabbableNode: HTMLElement|null,
2412
+ // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
2413
+ // }>}
2414
+ containerGroups: [],
2415
+ // same order/length as `containers` list
2416
+ // references to objects in `containerGroups`, but only those that actually have
2417
+ // tabbable nodes in them
2418
+ // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
2419
+ // the same length
2420
+ tabbableGroups: [],
2421
+ nodeFocusedBeforeActivation: null,
2422
+ mostRecentlyFocusedNode: null,
2423
+ active: false,
2424
+ paused: false,
2425
+ // timer ID for when delayInitialFocus is true and initial focus in this trap
2426
+ // has been delayed during activation
2427
+ delayInitialFocusTimer: undefined
2428
+ };
2429
+ 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
2430
+
2431
+ /**
2432
+ * Gets a configuration option value.
2433
+ * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
2434
+ * value will be taken from this object. Otherwise, value will be taken from base configuration.
2435
+ * @param {string} optionName Name of the option whose value is sought.
2436
+ * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
2437
+ * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
2438
+ */
2439
+
2440
+ var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
2441
+ return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
2442
+ };
2443
+ /**
2444
+ * Finds the index of the container that contains the element.
2445
+ * @param {HTMLElement} element
2446
+ * @returns {number} Index of the container in either `state.containers` or
2447
+ * `state.containerGroups` (the order/length of these lists are the same); -1
2448
+ * if the element isn't found.
2449
+ */
2450
+
2451
+
2452
+ var findContainerIndex = function findContainerIndex(element) {
2453
+ // NOTE: search `containerGroups` because it's possible a group contains no tabbable
2454
+ // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
2455
+ // and we still need to find the element in there
2456
+ return state.containerGroups.findIndex(function (_ref) {
2457
+ var container = _ref.container,
2458
+ tabbableNodes = _ref.tabbableNodes;
2459
+ return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
2460
+ // web components if the `tabbableOptions.getShadowRoot` option was used for
2461
+ // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
2462
+ // look inside web components even if open)
2463
+ tabbableNodes.find(function (node) {
2464
+ return node === element;
2465
+ });
2466
+ });
2467
+ };
2468
+ /**
2469
+ * Gets the node for the given option, which is expected to be an option that
2470
+ * can be either a DOM node, a string that is a selector to get a node, `false`
2471
+ * (if a node is explicitly NOT given), or a function that returns any of these
2472
+ * values.
2473
+ * @param {string} optionName
2474
+ * @returns {undefined | false | HTMLElement | SVGElement} Returns
2475
+ * `undefined` if the option is not specified; `false` if the option
2476
+ * resolved to `false` (node explicitly not given); otherwise, the resolved
2477
+ * DOM node.
2478
+ * @throws {Error} If the option is set, not `false`, and is not, or does not
2479
+ * resolve to a node.
2480
+ */
2481
+
2482
+
2483
+ var getNodeForOption = function getNodeForOption(optionName) {
2484
+ var optionValue = config[optionName];
2485
+
2486
+ if (typeof optionValue === 'function') {
2487
+ for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2488
+ params[_key2 - 1] = arguments[_key2];
2489
+ }
2490
+
2491
+ optionValue = optionValue.apply(void 0, params);
2492
+ }
2493
+
2494
+ if (optionValue === true) {
2495
+ optionValue = undefined; // use default value
2496
+ }
2497
+
2498
+ if (!optionValue) {
2499
+ if (optionValue === undefined || optionValue === false) {
2500
+ return optionValue;
2501
+ } // else, empty string (invalid), null (invalid), 0 (invalid)
2502
+
2503
+
2504
+ throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
2505
+ }
2506
+
2507
+ var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
2508
+
2509
+ if (typeof optionValue === 'string') {
2510
+ node = doc.querySelector(optionValue); // resolve to node, or null if fails
2511
+
2512
+ if (!node) {
2513
+ throw new Error("`".concat(optionName, "` as selector refers to no known node"));
2514
+ }
2515
+ }
2516
+
2517
+ return node;
2518
+ };
2519
+
2520
+ var getInitialFocusNode = function getInitialFocusNode() {
2521
+ var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
2522
+
2523
+ if (node === false) {
2524
+ return false;
2525
+ }
2526
+
2527
+ if (node === undefined) {
2528
+ // option not specified: use fallback options
2529
+ if (findContainerIndex(doc.activeElement) >= 0) {
2530
+ node = doc.activeElement;
2531
+ } else {
2532
+ var firstTabbableGroup = state.tabbableGroups[0];
2533
+ var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
2534
+
2535
+ node = firstTabbableNode || getNodeForOption('fallbackFocus');
2536
+ }
2537
+ }
2538
+
2539
+ if (!node) {
2540
+ throw new Error('Your focus-trap needs to have at least one focusable element');
2541
+ }
2542
+
2543
+ return node;
2544
+ };
2545
+
2546
+ var updateTabbableNodes = function updateTabbableNodes() {
2547
+ state.containerGroups = state.containers.map(function (container) {
2548
+ var tabbableNodes = tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
2549
+ // are a superset of tabbable nodes
2550
+
2551
+ var focusableNodes = focusable(container, config.tabbableOptions);
2552
+ return {
2553
+ container: container,
2554
+ tabbableNodes: tabbableNodes,
2555
+ focusableNodes: focusableNodes,
2556
+ firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
2557
+ lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
2558
+
2559
+ /**
2560
+ * Finds the __tabbable__ node that follows the given node in the specified direction,
2561
+ * in this container, if any.
2562
+ * @param {HTMLElement} node
2563
+ * @param {boolean} [forward] True if going in forward tab order; false if going
2564
+ * in reverse.
2565
+ * @returns {HTMLElement|undefined} The next tabbable node, if any.
2566
+ */
2567
+ nextTabbableNode: function nextTabbableNode(node) {
2568
+ var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2569
+ // NOTE: If tabindex is positive (in order to manipulate the tab order separate
2570
+ // from the DOM order), this __will not work__ because the list of focusableNodes,
2571
+ // while it contains tabbable nodes, does not sort its nodes in any order other
2572
+ // than DOM order, because it can't: Where would you place focusable (but not
2573
+ // tabbable) nodes in that order? They have no order, because they aren't tabbale...
2574
+ // Support for positive tabindex is already broken and hard to manage (possibly
2575
+ // not supportable, TBD), so this isn't going to make things worse than they
2576
+ // already are, and at least makes things better for the majority of cases where
2577
+ // tabindex is either 0/unset or negative.
2578
+ // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
2579
+ var nodeIdx = focusableNodes.findIndex(function (n) {
2580
+ return n === node;
2581
+ });
2582
+
2583
+ if (nodeIdx < 0) {
2584
+ return undefined;
2585
+ }
2586
+
2587
+ if (forward) {
2588
+ return focusableNodes.slice(nodeIdx + 1).find(function (n) {
2589
+ return isTabbable(n, config.tabbableOptions);
2590
+ });
2591
+ }
2592
+
2593
+ return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
2594
+ return isTabbable(n, config.tabbableOptions);
2595
+ });
2596
+ }
2597
+ };
2598
+ });
2599
+ state.tabbableGroups = state.containerGroups.filter(function (group) {
2600
+ return group.tabbableNodes.length > 0;
2601
+ }); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
2602
+
2603
+ if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
2604
+ ) {
2605
+ throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
2606
+ }
2607
+ };
2608
+
2609
+ var tryFocus = function tryFocus(node) {
2610
+ if (node === false) {
2611
+ return;
2612
+ }
2613
+
2614
+ if (node === doc.activeElement) {
2615
+ return;
2616
+ }
2617
+
2618
+ if (!node || !node.focus) {
2619
+ tryFocus(getInitialFocusNode());
2620
+ return;
2621
+ }
2622
+
2623
+ node.focus({
2624
+ preventScroll: !!config.preventScroll
2625
+ });
2626
+ state.mostRecentlyFocusedNode = node;
2627
+
2628
+ if (isSelectableInput(node)) {
2629
+ node.select();
2630
+ }
2631
+ };
2632
+
2633
+ var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
2634
+ var node = getNodeForOption('setReturnFocus', previousActiveElement);
2635
+ return node ? node : node === false ? false : previousActiveElement;
2636
+ }; // This needs to be done on mousedown and touchstart instead of click
2637
+ // so that it precedes the focus event.
2638
+
2639
+
2640
+ var checkPointerDown = function checkPointerDown(e) {
2641
+ var target = getActualTarget(e);
2642
+
2643
+ if (findContainerIndex(target) >= 0) {
2644
+ // allow the click since it ocurred inside the trap
2645
+ return;
2646
+ }
2647
+
2648
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2649
+ // immediately deactivate the trap
2650
+ trap.deactivate({
2651
+ // if, on deactivation, we should return focus to the node originally-focused
2652
+ // when the trap was activated (or the configured `setReturnFocus` node),
2653
+ // then assume it's also OK to return focus to the outside node that was
2654
+ // just clicked, causing deactivation, as long as that node is focusable;
2655
+ // if it isn't focusable, then return focus to the original node focused
2656
+ // on activation (or the configured `setReturnFocus` node)
2657
+ // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
2658
+ // which will result in the outside click setting focus to the node
2659
+ // that was clicked, whether it's focusable or not; by setting
2660
+ // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
2661
+ // on activation (or the configured `setReturnFocus` node)
2662
+ returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
2663
+ });
2664
+ return;
2665
+ } // This is needed for mobile devices.
2666
+ // (If we'll only let `click` events through,
2667
+ // then on mobile they will be blocked anyways if `touchstart` is blocked.)
2668
+
2669
+
2670
+ if (valueOrHandler(config.allowOutsideClick, e)) {
2671
+ // allow the click outside the trap to take place
2672
+ return;
2673
+ } // otherwise, prevent the click
2674
+
2675
+
2676
+ e.preventDefault();
2677
+ }; // In case focus escapes the trap for some strange reason, pull it back in.
2678
+
2679
+
2680
+ var checkFocusIn = function checkFocusIn(e) {
2681
+ var target = getActualTarget(e);
2682
+ var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
2683
+
2684
+ if (targetContained || target instanceof Document) {
2685
+ if (targetContained) {
2686
+ state.mostRecentlyFocusedNode = target;
2687
+ }
2688
+ } else {
2689
+ // escaped! pull it back in to where it just left
2690
+ e.stopImmediatePropagation();
2691
+ tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
2692
+ }
2693
+ }; // Hijack Tab events on the first and last focusable nodes of the trap,
2694
+ // in order to prevent focus from escaping. If it escapes for even a
2695
+ // moment it can end up scrolling the page and causing confusion so we
2696
+ // kind of need to capture the action at the keydown phase.
2697
+
2698
+
2699
+ var checkTab = function checkTab(e) {
2700
+ var target = getActualTarget(e);
2701
+ updateTabbableNodes();
2702
+ var destinationNode = null;
2703
+
2704
+ if (state.tabbableGroups.length > 0) {
2705
+ // make sure the target is actually contained in a group
2706
+ // NOTE: the target may also be the container itself if it's focusable
2707
+ // with tabIndex='-1' and was given initial focus
2708
+ var containerIndex = findContainerIndex(target);
2709
+ var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
2710
+
2711
+ if (containerIndex < 0) {
2712
+ // target not found in any group: quite possible focus has escaped the trap,
2713
+ // so bring it back in to...
2714
+ if (e.shiftKey) {
2715
+ // ...the last node in the last group
2716
+ destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
2717
+ } else {
2718
+ // ...the first node in the first group
2719
+ destinationNode = state.tabbableGroups[0].firstTabbableNode;
2720
+ }
2721
+ } else if (e.shiftKey) {
2722
+ // REVERSE
2723
+ // is the target the first tabbable node in a group?
2724
+ var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
2725
+ var firstTabbableNode = _ref2.firstTabbableNode;
2726
+ return target === firstTabbableNode;
2727
+ });
2728
+
2729
+ if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
2730
+ // an exception case where the target is either the container itself, or
2731
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
2732
+ // and user clicked on it or node was programmatically given focus)
2733
+ // and is not followed by any other tabbable node, in which
2734
+ // case, we should handle shift+tab as if focus were on the container's
2735
+ // first tabbable node, and go to the last tabbable node of the LAST group
2736
+ startOfGroupIndex = containerIndex;
2737
+ }
2738
+
2739
+ if (startOfGroupIndex >= 0) {
2740
+ // YES: then shift+tab should go to the last tabbable node in the
2741
+ // previous group (and wrap around to the last tabbable node of
2742
+ // the LAST group if it's the first tabbable node of the FIRST group)
2743
+ var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
2744
+ var destinationGroup = state.tabbableGroups[destinationGroupIndex];
2745
+ destinationNode = destinationGroup.lastTabbableNode;
2746
+ }
2747
+ } else {
2748
+ // FORWARD
2749
+ // is the target the last tabbable node in a group?
2750
+ var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
2751
+ var lastTabbableNode = _ref3.lastTabbableNode;
2752
+ return target === lastTabbableNode;
2753
+ });
2754
+
2755
+ if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
2756
+ // an exception case where the target is the container itself, or
2757
+ // a non-tabbable node that was given focus (i.e. tabindex is negative
2758
+ // and user clicked on it or node was programmatically given focus)
2759
+ // and is not followed by any other tabbable node, in which
2760
+ // case, we should handle tab as if focus were on the container's
2761
+ // last tabbable node, and go to the first tabbable node of the FIRST group
2762
+ lastOfGroupIndex = containerIndex;
2763
+ }
2764
+
2765
+ if (lastOfGroupIndex >= 0) {
2766
+ // YES: then tab should go to the first tabbable node in the next
2767
+ // group (and wrap around to the first tabbable node of the FIRST
2768
+ // group if it's the last tabbable node of the LAST group)
2769
+ var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
2770
+
2771
+ var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
2772
+ destinationNode = _destinationGroup.firstTabbableNode;
2773
+ }
2774
+ }
2775
+ } else {
2776
+ // NOTE: the fallbackFocus option does not support returning false to opt-out
2777
+ destinationNode = getNodeForOption('fallbackFocus');
2778
+ }
2779
+
2780
+ if (destinationNode) {
2781
+ e.preventDefault();
2782
+ tryFocus(destinationNode);
2783
+ } // else, let the browser take care of [shift+]tab and move the focus
2784
+
2785
+ };
2786
+
2787
+ var checkKey = function checkKey(e) {
2788
+ if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
2789
+ e.preventDefault();
2790
+ trap.deactivate();
2791
+ return;
2792
+ }
2793
+
2794
+ if (isTabEvent(e)) {
2795
+ checkTab(e);
2796
+ return;
2797
+ }
2798
+ };
2799
+
2800
+ var checkClick = function checkClick(e) {
2801
+ var target = getActualTarget(e);
2802
+
2803
+ if (findContainerIndex(target) >= 0) {
2804
+ return;
2805
+ }
2806
+
2807
+ if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2808
+ return;
2809
+ }
2810
+
2811
+ if (valueOrHandler(config.allowOutsideClick, e)) {
2812
+ return;
2813
+ }
2814
+
2815
+ e.preventDefault();
2816
+ e.stopImmediatePropagation();
2817
+ }; //
2818
+ // EVENT LISTENERS
2819
+ //
2820
+
2821
+
2822
+ var addListeners = function addListeners() {
2823
+ if (!state.active) {
2824
+ return;
2825
+ } // There can be only one listening focus trap at a time
2826
+
2827
+
2828
+ activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
2829
+ // that caused the focus trap activation.
2830
+
2831
+ state.delayInitialFocusTimer = config.delayInitialFocus ? delay$1(function () {
2832
+ tryFocus(getInitialFocusNode());
2833
+ }) : tryFocus(getInitialFocusNode());
2834
+ doc.addEventListener('focusin', checkFocusIn, true);
2835
+ doc.addEventListener('mousedown', checkPointerDown, {
2836
+ capture: true,
2837
+ passive: false
2838
+ });
2839
+ doc.addEventListener('touchstart', checkPointerDown, {
2840
+ capture: true,
2841
+ passive: false
2842
+ });
2843
+ doc.addEventListener('click', checkClick, {
2844
+ capture: true,
2845
+ passive: false
2846
+ });
2847
+ doc.addEventListener('keydown', checkKey, {
2848
+ capture: true,
2849
+ passive: false
2850
+ });
2851
+ return trap;
2852
+ };
2853
+
2854
+ var removeListeners = function removeListeners() {
2855
+ if (!state.active) {
2856
+ return;
2857
+ }
2858
+
2859
+ doc.removeEventListener('focusin', checkFocusIn, true);
2860
+ doc.removeEventListener('mousedown', checkPointerDown, true);
2861
+ doc.removeEventListener('touchstart', checkPointerDown, true);
2862
+ doc.removeEventListener('click', checkClick, true);
2863
+ doc.removeEventListener('keydown', checkKey, true);
2864
+ return trap;
2865
+ }; //
2866
+ // TRAP DEFINITION
2867
+ //
2868
+
2869
+
2870
+ trap = {
2871
+ get active() {
2872
+ return state.active;
2873
+ },
2874
+
2875
+ get paused() {
2876
+ return state.paused;
2877
+ },
2878
+
2879
+ activate: function activate(activateOptions) {
2880
+ if (state.active) {
2881
+ return this;
2882
+ }
2883
+
2884
+ var onActivate = getOption(activateOptions, 'onActivate');
2885
+ var onPostActivate = getOption(activateOptions, 'onPostActivate');
2886
+ var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
2887
+
2888
+ if (!checkCanFocusTrap) {
2889
+ updateTabbableNodes();
2890
+ }
2891
+
2892
+ state.active = true;
2893
+ state.paused = false;
2894
+ state.nodeFocusedBeforeActivation = doc.activeElement;
2895
+
2896
+ if (onActivate) {
2897
+ onActivate();
2898
+ }
2899
+
2900
+ var finishActivation = function finishActivation() {
2901
+ if (checkCanFocusTrap) {
2902
+ updateTabbableNodes();
2903
+ }
2904
+
2905
+ addListeners();
2906
+
2907
+ if (onPostActivate) {
2908
+ onPostActivate();
2909
+ }
2910
+ };
2911
+
2912
+ if (checkCanFocusTrap) {
2913
+ checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
2914
+ return this;
2915
+ }
2916
+
2917
+ finishActivation();
2918
+ return this;
2919
+ },
2920
+ deactivate: function deactivate(deactivateOptions) {
2921
+ if (!state.active) {
2922
+ return this;
2923
+ }
2924
+
2925
+ var options = _objectSpread2({
2926
+ onDeactivate: config.onDeactivate,
2927
+ onPostDeactivate: config.onPostDeactivate,
2928
+ checkCanReturnFocus: config.checkCanReturnFocus
2929
+ }, deactivateOptions);
2930
+
2931
+ clearTimeout(state.delayInitialFocusTimer); // noop if undefined
2932
+
2933
+ state.delayInitialFocusTimer = undefined;
2934
+ removeListeners();
2935
+ state.active = false;
2936
+ state.paused = false;
2937
+ activeFocusTraps.deactivateTrap(trap);
2938
+ var onDeactivate = getOption(options, 'onDeactivate');
2939
+ var onPostDeactivate = getOption(options, 'onPostDeactivate');
2940
+ var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
2941
+ var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
2942
+
2943
+ if (onDeactivate) {
2944
+ onDeactivate();
2945
+ }
2946
+
2947
+ var finishDeactivation = function finishDeactivation() {
2948
+ delay$1(function () {
2949
+ if (returnFocus) {
2950
+ tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
2951
+ }
2952
+
2953
+ if (onPostDeactivate) {
2954
+ onPostDeactivate();
2955
+ }
2956
+ });
2957
+ };
2958
+
2959
+ if (returnFocus && checkCanReturnFocus) {
2960
+ checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
2961
+ return this;
2962
+ }
2963
+
2964
+ finishDeactivation();
2965
+ return this;
2966
+ },
2967
+ pause: function pause() {
2968
+ if (state.paused || !state.active) {
2969
+ return this;
2970
+ }
2971
+
2972
+ state.paused = true;
2973
+ removeListeners();
2974
+ return this;
2975
+ },
2976
+ unpause: function unpause() {
2977
+ if (!state.paused || !state.active) {
2978
+ return this;
2979
+ }
2980
+
2981
+ state.paused = false;
2982
+ updateTabbableNodes();
2983
+ addListeners();
2984
+ return this;
2985
+ },
2986
+ updateContainerElements: function updateContainerElements(containerElements) {
2987
+ var elementsAsArray = [].concat(containerElements).filter(Boolean);
2988
+ state.containers = elementsAsArray.map(function (element) {
2989
+ return typeof element === 'string' ? doc.querySelector(element) : element;
2990
+ });
2991
+
2992
+ if (state.active) {
2993
+ updateTabbableNodes();
2994
+ }
2995
+
2996
+ return this;
2997
+ }
2998
+ }; // initialize container elements
2999
+
3000
+ trap.updateContainerElements(elements);
3001
+ return trap;
3002
+ };
3003
+
3004
+ const firstTabbable = (container) => {
3005
+ return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
3006
+ };
3007
+
1728
3008
  const catDropdownCss = ":host{display:contents}:host([hidden]){display:none}::slotted(nav){padding-top:0.5rem;padding-bottom:0.5rem;min-width:8rem;max-width:16rem}.content{position:absolute;background:white;display:none;-webkit-overflow-scrolling:touch;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 0 0 1px rgb(var(--cat-border-color, 235, 236, 240)), 0 4px 6px -2px rgba(27, 31, 38, 0.03), 0 12px 16px -4px rgba(27, 31, 38, 0.08);border-radius:var(--cat-border-radius-m, 0.25rem);z-index:100;opacity:0;transition:transform 0.13s cubic-bezier(0.3, 0, 0.8, 0.15), opacity 0.13s cubic-bezier(0.3, 0, 0.8, 0.15)}.content[data-placement^=top]{transform:translateY(1rem)}.content[data-placement^=left]{transform:translateX(1rem)}.content[data-placement^=right]{transform:translateX(-1rem)}.content[data-placement^=bottom]{transform:translateY(-1rem)}.content.show{opacity:1;transform:translateX(0);transform:translateY(0);transition:transform 0.5s cubic-bezier(0.05, 0.7, 0.1, 1), opacity 0.5s cubic-bezier(0.05, 0.7, 0.1, 1)}.content.overflow-auto{overflow:auto}";
1729
3009
 
1730
3010
  let nextUniqueId$7 = 0;
@@ -1785,7 +3065,7 @@ const CatDropdown = class {
1785
3065
  this.catOpen.emit();
1786
3066
  this.trap = this.trap
1787
3067
  ? this.trap.updateContainerElements(this.content)
1788
- : firstTabbable.createFocusTrap(this.content, {
3068
+ : createFocusTrap(this.content, {
1789
3069
  tabbableOptions: {
1790
3070
  getShadowRoot: true
1791
3071
  },
@@ -1821,8 +3101,8 @@ const CatDropdown = class {
1821
3101
  componentDidLoad() {
1822
3102
  this.keyListener = event => {
1823
3103
  if (this.isOpen && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
1824
- const targetElements = firstTabbable.tabbable(this.content, { includeContainer: false, getShadowRoot: true });
1825
- const activeElement = firstTabbable.firstTabbable(document.activeElement);
3104
+ const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
3105
+ const activeElement = firstTabbable(document.activeElement);
1826
3106
  const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
1827
3107
  const activeOff = event.key === 'ArrowDown' ? 1 : -1;
1828
3108
  const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
@@ -1862,7 +3142,7 @@ const CatDropdown = class {
1862
3142
  : (_c = elem === null || elem === void 0 ? void 0 : elem.querySelector('[data-trigger]')) !== null && _c !== void 0 ? _c : undefined;
1863
3143
  }
1864
3144
  if (!trigger) {
1865
- trigger = firstTabbable.firstTabbable(this.triggerSlot);
3145
+ trigger = firstTabbable(this.triggerSlot);
1866
3146
  }
1867
3147
  if (!trigger) {
1868
3148
  throw new Error('Cannot find tabbable element. Use [data-trigger] to set the trigger.');
@@ -1931,17 +3211,13 @@ const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user
1931
3211
  const CatIcon = class {
1932
3212
  constructor(hostRef) {
1933
3213
  index.registerInstance(this, hostRef);
1934
- /**
1935
- * The name of the icon.
1936
- */
1937
- this.icon = '';
1938
3214
  /**
1939
3215
  * The size of the icon.
1940
3216
  */
1941
3217
  this.size = 'm';
1942
3218
  }
1943
3219
  render() {
1944
- return (index.h("span", { innerHTML: catIconRegistry.catIconRegistry.getIcon(this.icon), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
3220
+ return (index.h("span", { innerHTML: this.iconSrc || (this.icon ? catIconRegistry.catIconRegistry.getIcon(this.icon) : ''), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
1945
3221
  icon: true,
1946
3222
  [`icon-${this.size}`]: this.size !== 'inline'
1947
3223
  } }));
@@ -1949,7 +3225,7 @@ const CatIcon = class {
1949
3225
  };
1950
3226
  CatIcon.style = catIconCss;
1951
3227
 
1952
- const catInputCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column;color:rgb(var(--cat-hint-color, inherit))}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);margin-bottom:1rem}:host([hidden]){display:none}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);box-shadow:0 0 0 1px rgb(var(--cat-border-color-dark, 215, 219, 224));transition:box-shadow 0.13s linear}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px rgb(var(--cat-border-color-dark, 215, 219, 224))}.input-wrapper:not(.input-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}:host(.cat-error) .input-wrapper{box-shadow:0 0 0 1px rgb(var(--cat-danger-bg, 217, 52, 13))}:host(.cat-error) .input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px rgb(var(--cat-danger-bg, 217, 52, 13))}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-right:0.75rem}.text-suffix{border-left:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;align-items:center;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input.has-clearable{padding-right:1.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}";
3228
+ const catInputCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column;color:rgb(var(--cat-hint-color, inherit))}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);margin-bottom:1rem}:host([hidden]){display:none}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);box-shadow:0 0 0 1px rgb(var(--cat-border-color-dark, 215, 219, 224));transition:box-shadow 0.13s linear;}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px rgb(var(--cat-border-color-dark, 215, 219, 224))}.input-wrapper:not(.input-disabled):focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}.input-wrapper:has(input:-webkit-autofill),.input-wrapper:has(input:-webkit-autofill):hover,.input-wrapper:has(input:-webkit-autofill):focus{background-color:#e8f0fe}:host(.cat-error) .input-wrapper{box-shadow:0 0 0 1px rgb(var(--cat-danger-bg, 217, 52, 13))}:host(.cat-error) .input-wrapper:not(.input-disabled):hover{box-shadow:0 0 0 2px rgb(var(--cat-danger-bg, 217, 52, 13))}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-right:0.75rem}.text-suffix{border-left:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;align-items:center;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none;}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input.has-clearable{padding-right:1.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 9999px #e8f0fe inset}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}";
1953
3229
 
1954
3230
  let nextUniqueId$6 = 0;
1955
3231
  const CatInput = class {
@@ -3784,6 +5060,44 @@ function filter(predicate, thisArg) {
3784
5060
  });
3785
5061
  }
3786
5062
 
5063
+ function audit(durationSelector) {
5064
+ return operate((source, subscriber) => {
5065
+ let hasValue = false;
5066
+ let lastValue = null;
5067
+ let durationSubscriber = null;
5068
+ let isComplete = false;
5069
+ const endDuration = () => {
5070
+ durationSubscriber === null || durationSubscriber === void 0 ? void 0 : durationSubscriber.unsubscribe();
5071
+ durationSubscriber = null;
5072
+ if (hasValue) {
5073
+ hasValue = false;
5074
+ const value = lastValue;
5075
+ lastValue = null;
5076
+ subscriber.next(value);
5077
+ }
5078
+ isComplete && subscriber.complete();
5079
+ };
5080
+ const cleanupDuration = () => {
5081
+ durationSubscriber = null;
5082
+ isComplete && subscriber.complete();
5083
+ };
5084
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => {
5085
+ hasValue = true;
5086
+ lastValue = value;
5087
+ if (!durationSubscriber) {
5088
+ innerFrom(durationSelector(value)).subscribe((durationSubscriber = createOperatorSubscriber(subscriber, endDuration, cleanupDuration)));
5089
+ }
5090
+ }, () => {
5091
+ isComplete = true;
5092
+ (!hasValue || !durationSubscriber || durationSubscriber.closed) && subscriber.complete();
5093
+ }));
5094
+ });
5095
+ }
5096
+
5097
+ function auditTime(duration, scheduler = asyncScheduler) {
5098
+ return audit(() => timer(duration, scheduler));
5099
+ }
5100
+
3787
5101
  function catchError(selector) {
3788
5102
  return operate((source, subscriber) => {
3789
5103
  let innerSub = null;
@@ -4047,6 +5361,8 @@ const CatScrollable = class {
4047
5361
  this.scrolledBottom = index.createEvent(this, "scrolledBottom", 7);
4048
5362
  this.init = new Subject();
4049
5363
  this.destroyed = new Subject();
5364
+ this.resizedEntries = new Subject();
5365
+ this.resizedObserver = new ResizeObserver(entries => this.resizedEntries.next(entries));
4050
5366
  /** Flags to disable/enable scroll shadowX. */
4051
5367
  this.noShadowX = false;
4052
5368
  /** Flags to disable/enable scroll shadowY. */
@@ -4069,13 +5385,17 @@ const CatScrollable = class {
4069
5385
  componentDidRender() {
4070
5386
  if (this.scrollElement) {
4071
5387
  this.scrolled = fromEvent(this.scrollElement, 'scroll').pipe(takeUntil(this.destroyed));
5388
+ this.resizedObserver.observe(this.scrollElement);
5389
+ }
5390
+ if (this.scrollWrapperElement) {
5391
+ this.resizedObserver.observe(this.scrollWrapperElement);
4072
5392
  }
4073
- this.attachEmitter('left', this.scrolledLeft, this.scrolledBuffer);
4074
- this.attachEmitter('right', this.scrolledRight, this.scrolledBuffer);
4075
- this.attachEmitter('bottom', this.scrolledBottom, this.scrolledBuffer);
4076
- this.attachEmitter('top', this.scrolledTop, this.scrolledBuffer);
4077
- merge(this.init, this.scrolled)
4078
- .pipe(map(() => ({
5393
+ this.attachEmitter('left', this.scrolledLeft);
5394
+ this.attachEmitter('right', this.scrolledRight);
5395
+ this.attachEmitter('bottom', this.scrolledBottom);
5396
+ this.attachEmitter('top', this.scrolledTop);
5397
+ merge(this.init, this.scrolled, this.resizedEntries)
5398
+ .pipe(auditTime(CatScrollable.THROTTLE), map(() => ({
4079
5399
  top: this.getScrollOffset('top') > 0,
4080
5400
  left: this.getScrollOffset('left') > 0,
4081
5401
  right: this.getScrollOffset('right') > 0,
@@ -4097,6 +5417,7 @@ const CatScrollable = class {
4097
5417
  this.init.complete();
4098
5418
  this.destroyed.next();
4099
5419
  this.destroyed.complete();
5420
+ this.resizedObserver.disconnect();
4100
5421
  }
4101
5422
  render() {
4102
5423
  return [
@@ -4109,13 +5430,9 @@ const CatScrollable = class {
4109
5430
  } }, index.h("slot", null))
4110
5431
  ];
4111
5432
  }
4112
- attachEmitter(from, emitter, buffer) {
4113
- merge(this.init, this.scrolled)
4114
- .pipe(map(() => this.getScrollOffset(from)))
4115
- .pipe(map(offset => offset <= buffer))
4116
- .pipe(distinctUntilChanged())
4117
- .pipe(filter(isLower => isLower))
4118
- .pipe(takeUntil(this.destroyed))
5433
+ attachEmitter(from, emitter) {
5434
+ merge(this.init, this.scrolled, this.resizedEntries)
5435
+ .pipe(auditTime(CatScrollable.THROTTLE), map(() => this.getScrollOffset(from)), map(offset => offset <= this.scrolledBuffer), distinctUntilChanged(), filter(isLower => isLower), takeUntil(this.destroyed))
4119
5436
  .subscribe(() => emitter.emit());
4120
5437
  }
4121
5438
  getScrollOffset(from) {
@@ -4145,6 +5462,7 @@ const CatScrollable = class {
4145
5462
  }
4146
5463
  }
4147
5464
  };
5465
+ CatScrollable.THROTTLE = 50;
4148
5466
  CatScrollable.style = catScrollableCss;
4149
5467
 
4150
5468
  var GHOST_ELEMENT_ID = '__autosizeInputGhost';
@@ -6368,7 +7686,7 @@ CatTabs.style = catTabsCss;
6368
7686
 
6369
7687
  var e,t,n="function"==typeof Map?new Map:(e=[],t=[],{has:function(t){return e.indexOf(t)>-1},get:function(n){return t[e.indexOf(n)]},set:function(n,o){-1===e.indexOf(n)&&(e.push(n),t.push(o));},delete:function(n){var o=e.indexOf(n);o>-1&&(e.splice(o,1),t.splice(o,1));}}),o=function(e){return new Event(e,{bubbles:!0})};try{new Event("test");}catch(e){o=function(e){var t=document.createEvent("Event");return t.initEvent(e,!0,!1),t};}function r(e){var t=n.get(e);t&&t.destroy();}function i(e){var t=n.get(e);t&&t.update();}var l=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((l=function(e){return e}).destroy=function(e){return e},l.update=function(e){return e}):((l=function(e,t){return e&&Array.prototype.forEach.call(e.length?e:[e],function(e){return function(e){if(e&&e.nodeName&&"TEXTAREA"===e.nodeName&&!n.has(e)){var t,r=null,i=null,l=null,d=function(){e.clientWidth!==i&&c();},a=function(t){window.removeEventListener("resize",d,!1),e.removeEventListener("input",c,!1),e.removeEventListener("keyup",c,!1),e.removeEventListener("autosize:destroy",a,!1),e.removeEventListener("autosize:update",c,!1),Object.keys(t).forEach(function(n){e.style[n]=t[n];}),n.delete(e);}.bind(e,{height:e.style.height,resize:e.style.resize,overflowY:e.style.overflowY,overflowX:e.style.overflowX,wordWrap:e.style.wordWrap});e.addEventListener("autosize:destroy",a,!1),"onpropertychange"in e&&"oninput"in e&&e.addEventListener("keyup",c,!1),window.addEventListener("resize",d,!1),e.addEventListener("input",c,!1),e.addEventListener("autosize:update",c,!1),e.style.overflowX="hidden",e.style.wordWrap="break-word",n.set(e,{destroy:a,update:c}),"vertical"===(t=window.getComputedStyle(e,null)).resize?e.style.resize="none":"both"===t.resize&&(e.style.resize="horizontal"),r="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(r)&&(r=0),c();}function u(t){var n=e.style.width;e.style.width="0px",e.style.width=n,e.style.overflowY=t;}function s(){if(0!==e.scrollHeight){var t=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push({node:e.parentNode,scrollTop:e.parentNode.scrollTop}),e=e.parentNode;return t}(e),n=document.documentElement&&document.documentElement.scrollTop;e.style.height="",e.style.height=e.scrollHeight+r+"px",i=e.clientWidth,t.forEach(function(e){e.node.scrollTop=e.scrollTop;}),n&&(document.documentElement.scrollTop=n);}}function c(){s();var t=Math.round(parseFloat(e.style.height)),n=window.getComputedStyle(e,null),r="content-box"===n.boxSizing?Math.round(parseFloat(n.height)):e.offsetHeight;if(r<t?"hidden"===n.overflowY&&(u("scroll"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight):"hidden"!==n.overflowY&&(u("hidden"),s(),r="content-box"===n.boxSizing?Math.round(parseFloat(window.getComputedStyle(e,null).height)):e.offsetHeight),l!==r){l=r;var i=o("autosize:resized");try{e.dispatchEvent(i);}catch(e){}}}}(e)}),e}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],r),e},l.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],i),e});var d=l;
6370
7688
 
6371
- const catTextareaCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column;color:rgb(var(--cat-hint-color, inherit))}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}textarea{margin:0;padding:0.625rem 0.75rem;min-height:2.5rem;font:inherit;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);border:none;box-shadow:0 0 0 1px rgb(var(--cat-border-color-dark, 215, 219, 224));transition:box-shadow 0.13s linear;resize:vertical}textarea:disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));resize:none}textarea:hover:not(:disabled){box-shadow:0 0 0 2px rgb(var(--cat-border-color-dark, 215, 219, 224))}textarea:focus{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}textarea::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}";
7689
+ const catTextareaCss = ".hint-section{display:flex;gap:0.5rem;flex-direction:column;color:rgb(var(--cat-hint-color, inherit))}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){font-size:0.875rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);margin:0 !important}:host{display:flex;flex-direction:column;gap:0.5rem;font-size:0.9375rem;line-height:1.25rem;font-weight:var(--cat-font-weight-body, 400);margin-bottom:1rem}:host([hidden]){display:none}label{align-self:flex-start}label.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-optional{margin-left:0.25rem;font-size:0.75rem;line-height:1rem;font-weight:var(--cat-font-weight-body, 400);color:rgb(var(--cat-font-color-muted, 105, 118, 135))}textarea{margin:0;padding:0.625rem 0.75rem;min-height:2.5rem;font:inherit;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);border:none;box-shadow:0 0 0 1px rgb(var(--cat-border-color-dark, 215, 219, 224));transition:box-shadow 0.13s linear;resize:vertical;}textarea:disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 105, 118, 135));resize:none}textarea:hover:not(:disabled){box-shadow:0 0 0 2px rgb(var(--cat-border-color-dark, 215, 219, 224))}textarea:focus{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255))}textarea::placeholder{color:rgb(var(--cat-font-color-muted, 105, 118, 135))}textarea:-webkit-autofill,textarea:-webkit-autofill:hover,textarea:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 9999px #e8f0fe inset}";
6372
7690
 
6373
7691
  let nextUniqueId$2 = 0;
6374
7692
  const CatTextarea = class {
@@ -6605,7 +7923,7 @@ const CatTooltip = class {
6605
7923
  }
6606
7924
  componentDidLoad() {
6607
7925
  var _a, _b, _c, _d, _e, _f, _g;
6608
- this.trigger = firstTabbable.firstTabbable(this.triggerElement) || this.triggerElement;
7926
+ this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;
6609
7927
  if (!this.isTabbable) {
6610
7928
  (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
6611
7929
  }
@@ -6650,7 +7968,7 @@ const CatTooltip = class {
6650
7968
  } }, this.content)));
6651
7969
  }
6652
7970
  get isTabbable() {
6653
- return firstTabbable.firstTabbable(this.trigger);
7971
+ return firstTabbable(this.trigger);
6654
7972
  }
6655
7973
  update() {
6656
7974
  if (this.trigger && this.tooltip) {