@haiilo/catalyst 0.4.0 → 0.5.3

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 (248) hide show
  1. package/package.json +7 -6
  2. package/dist/catalyst/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  3. package/dist/catalyst/assets/fonts/DMSans-Bold.woff2 +0 -0
  4. package/dist/catalyst/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  5. package/dist/catalyst/assets/fonts/DMSans-Italic.woff2 +0 -0
  6. package/dist/catalyst/assets/fonts/DMSans-Medium.woff2 +0 -0
  7. package/dist/catalyst/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  8. package/dist/catalyst/assets/fonts/DMSans-Regular.woff2 +0 -0
  9. package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
  10. package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
  11. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
  12. package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  13. package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
  14. package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
  15. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
  16. package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  17. package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
  18. package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
  19. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
  20. package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  21. package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
  22. package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
  23. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
  24. package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  25. package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
  26. package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
  27. package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
  28. package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
  29. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
  30. package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
  31. package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
  32. package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
  33. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
  34. package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  35. package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
  36. package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
  37. package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
  38. package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
  39. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  40. package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  41. package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
  42. package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
  43. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
  44. package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  45. package/dist/catalyst/catalyst.css +0 -1
  46. package/dist/catalyst/catalyst.esm.js +0 -2
  47. package/dist/catalyst/catalyst.esm.js.map +0 -1
  48. package/dist/catalyst/index.cdn.js +0 -21
  49. package/dist/catalyst/index.esm.js +0 -2
  50. package/dist/catalyst/index.esm.js.map +0 -1
  51. package/dist/catalyst/p-89a97b7b.entry.js +0 -10
  52. package/dist/catalyst/p-89a97b7b.entry.js.map +0 -1
  53. package/dist/catalyst/p-ed826597.js +0 -2
  54. package/dist/catalyst/p-ed826597.js.map +0 -1
  55. package/dist/catalyst/p-ef0a8ae9.js +0 -2
  56. package/dist/catalyst/p-ef0a8ae9.js.map +0 -1
  57. package/dist/catalyst/p-f151cb13.js +0 -2
  58. package/dist/catalyst/p-f151cb13.js.map +0 -1
  59. package/dist/cjs/app-globals-7f2b1f8e.js +0 -173
  60. package/dist/cjs/app-globals-7f2b1f8e.js.map +0 -1
  61. package/dist/cjs/cat-alert_9.cjs.entry.js +0 -4557
  62. package/dist/cjs/cat-alert_9.cjs.entry.js.map +0 -1
  63. package/dist/cjs/cat-icon-registry-850c538c.js +0 -47
  64. package/dist/cjs/cat-icon-registry-850c538c.js.map +0 -1
  65. package/dist/cjs/catalyst.cjs.js +0 -24
  66. package/dist/cjs/catalyst.cjs.js.map +0 -1
  67. package/dist/cjs/index-c0881ae0.js +0 -1348
  68. package/dist/cjs/index-c0881ae0.js.map +0 -1
  69. package/dist/cjs/index.cjs.js +0 -11
  70. package/dist/cjs/index.cjs.js.map +0 -1
  71. package/dist/cjs/loader.cjs.js +0 -26
  72. package/dist/cjs/loader.cjs.js.map +0 -1
  73. package/dist/collection/assets/fonts/AzeretMono-Regular.woff2 +0 -0
  74. package/dist/collection/assets/fonts/DMSans-Bold.woff2 +0 -0
  75. package/dist/collection/assets/fonts/DMSans-BoldItalic.woff2 +0 -0
  76. package/dist/collection/assets/fonts/DMSans-Italic.woff2 +0 -0
  77. package/dist/collection/assets/fonts/DMSans-Medium.woff2 +0 -0
  78. package/dist/collection/assets/fonts/DMSans-MediumItalic.woff2 +0 -0
  79. package/dist/collection/assets/fonts/DMSans-Regular.woff2 +0 -0
  80. package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
  81. package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
  82. package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
  83. package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
  84. package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
  85. package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
  86. package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
  87. package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
  88. package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
  89. package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
  90. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
  91. package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
  92. package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
  93. package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
  94. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
  95. package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
  96. package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
  97. package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
  98. package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
  99. package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
  100. package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
  101. package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
  102. package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
  103. package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
  104. package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
  105. package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
  106. package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
  107. package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
  108. package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
  109. package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
  110. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
  111. package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
  112. package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
  113. package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
  114. package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
  115. package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
  116. package/dist/collection/collection-manifest.json +0 -21
  117. package/dist/collection/components/cat-alert/cat-alert.css +0 -57
  118. package/dist/collection/components/cat-alert/cat-alert.js +0 -50
  119. package/dist/collection/components/cat-alert/cat-alert.js.map +0 -1
  120. package/dist/collection/components/cat-badge/cat-badge.css +0 -154
  121. package/dist/collection/components/cat-badge/cat-badge.js +0 -142
  122. package/dist/collection/components/cat-badge/cat-badge.js.map +0 -1
  123. package/dist/collection/components/cat-button/cat-button.css +0 -323
  124. package/dist/collection/components/cat-button/cat-button.js +0 -591
  125. package/dist/collection/components/cat-button/cat-button.js.map +0 -1
  126. package/dist/collection/components/cat-icon/cat-icon-registry.js +0 -42
  127. package/dist/collection/components/cat-icon/cat-icon-registry.js.map +0 -1
  128. package/dist/collection/components/cat-icon/cat-icon.css +0 -50
  129. package/dist/collection/components/cat-icon/cat-icon.js +0 -90
  130. package/dist/collection/components/cat-icon/cat-icon.js.map +0 -1
  131. package/dist/collection/components/cat-menu/cat-menu.css +0 -33
  132. package/dist/collection/components/cat-menu/cat-menu.js +0 -184
  133. package/dist/collection/components/cat-menu/cat-menu.js.map +0 -1
  134. package/dist/collection/components/cat-scrollable/cat-scrollable.css +0 -69
  135. package/dist/collection/components/cat-scrollable/cat-scrollable.js +0 -309
  136. package/dist/collection/components/cat-scrollable/cat-scrollable.js.map +0 -1
  137. package/dist/collection/components/cat-skeleton/cat-skeleton.css +0 -177
  138. package/dist/collection/components/cat-skeleton/cat-skeleton.js +0 -131
  139. package/dist/collection/components/cat-skeleton/cat-skeleton.js.map +0 -1
  140. package/dist/collection/components/cat-spinner/cat-spinner.css +0 -63
  141. package/dist/collection/components/cat-spinner/cat-spinner.js +0 -65
  142. package/dist/collection/components/cat-spinner/cat-spinner.js.map +0 -1
  143. package/dist/collection/components/cat-tooltip/cat-tooltip.css +0 -37
  144. package/dist/collection/components/cat-tooltip/cat-tooltip.js +0 -254
  145. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +0 -1
  146. package/dist/collection/index.cdn.js +0 -21
  147. package/dist/collection/index.js +0 -2
  148. package/dist/collection/index.js.map +0 -1
  149. package/dist/collection/init.js +0 -9
  150. package/dist/collection/init.js.map +0 -1
  151. package/dist/collection/utils/breakpoints.js +0 -12
  152. package/dist/collection/utils/breakpoints.js.map +0 -1
  153. package/dist/collection/utils/first-tabbable.js +0 -6
  154. package/dist/collection/utils/first-tabbable.js.map +0 -1
  155. package/dist/collection/utils/is-touch-screen.js +0 -3
  156. package/dist/collection/utils/is-touch-screen.js.map +0 -1
  157. package/dist/collection/utils/media-matcher.js +0 -55
  158. package/dist/collection/utils/media-matcher.js.map +0 -1
  159. package/dist/collection/utils/platform.js +0 -50
  160. package/dist/collection/utils/platform.js.map +0 -1
  161. package/dist/collection/utils/utils.js +0 -4
  162. package/dist/collection/utils/utils.js.map +0 -1
  163. package/dist/components/cat-alert.d.ts +0 -11
  164. package/dist/components/cat-alert.js +0 -44
  165. package/dist/components/cat-alert.js.map +0 -1
  166. package/dist/components/cat-badge.d.ts +0 -11
  167. package/dist/components/cat-badge.js +0 -68
  168. package/dist/components/cat-badge.js.map +0 -1
  169. package/dist/components/cat-button.d.ts +0 -11
  170. package/dist/components/cat-button.js +0 -654
  171. package/dist/components/cat-button.js.map +0 -1
  172. package/dist/components/cat-icon-registry.js +0 -45
  173. package/dist/components/cat-icon-registry.js.map +0 -1
  174. package/dist/components/cat-icon.d.ts +0 -11
  175. package/dist/components/cat-icon.js +0 -8
  176. package/dist/components/cat-icon.js.map +0 -1
  177. package/dist/components/cat-icon2.js +0 -48
  178. package/dist/components/cat-icon2.js.map +0 -1
  179. package/dist/components/cat-menu.d.ts +0 -11
  180. package/dist/components/cat-menu.js +0 -870
  181. package/dist/components/cat-menu.js.map +0 -1
  182. package/dist/components/cat-scrollable.d.ts +0 -11
  183. package/dist/components/cat-scrollable.js +0 -1363
  184. package/dist/components/cat-scrollable.js.map +0 -1
  185. package/dist/components/cat-skeleton.d.ts +0 -11
  186. package/dist/components/cat-skeleton.js +0 -78
  187. package/dist/components/cat-skeleton.js.map +0 -1
  188. package/dist/components/cat-spinner.d.ts +0 -11
  189. package/dist/components/cat-spinner.js +0 -8
  190. package/dist/components/cat-spinner.js.map +0 -1
  191. package/dist/components/cat-spinner2.js +0 -41
  192. package/dist/components/cat-spinner2.js.map +0 -1
  193. package/dist/components/cat-tooltip.d.ts +0 -11
  194. package/dist/components/cat-tooltip.js +0 -154
  195. package/dist/components/cat-tooltip.js.map +0 -1
  196. package/dist/components/first-tabbable.js +0 -1495
  197. package/dist/components/first-tabbable.js.map +0 -1
  198. package/dist/components/index.d.ts +0 -26
  199. package/dist/components/index.js +0 -173
  200. package/dist/components/index.js.map +0 -1
  201. package/dist/esm/app-globals-8af9b2cf.js +0 -171
  202. package/dist/esm/app-globals-8af9b2cf.js.map +0 -1
  203. package/dist/esm/cat-alert_9.entry.js +0 -4545
  204. package/dist/esm/cat-alert_9.entry.js.map +0 -1
  205. package/dist/esm/cat-icon-registry-59da2e37.js +0 -45
  206. package/dist/esm/cat-icon-registry-59da2e37.js.map +0 -1
  207. package/dist/esm/catalyst.js +0 -22
  208. package/dist/esm/catalyst.js.map +0 -1
  209. package/dist/esm/index-0ff35bca.js +0 -1320
  210. package/dist/esm/index-0ff35bca.js.map +0 -1
  211. package/dist/esm/index.js +0 -3
  212. package/dist/esm/index.js.map +0 -1
  213. package/dist/esm/loader.js +0 -22
  214. package/dist/esm/loader.js.map +0 -1
  215. package/dist/esm/polyfills/core-js.js +0 -11
  216. package/dist/esm/polyfills/css-shim.js +0 -1
  217. package/dist/esm/polyfills/dom.js +0 -79
  218. package/dist/esm/polyfills/es5-html-element.js +0 -1
  219. package/dist/esm/polyfills/index.js +0 -34
  220. package/dist/esm/polyfills/system.js +0 -6
  221. package/dist/index.cjs.js +0 -1
  222. package/dist/index.js +0 -1
  223. package/dist/types/components/cat-alert/cat-alert.d.ts +0 -12
  224. package/dist/types/components/cat-badge/cat-badge.d.ts +0 -28
  225. package/dist/types/components/cat-button/cat-button.d.ts +0 -129
  226. package/dist/types/components/cat-icon/cat-icon-registry.d.ts +0 -15
  227. package/dist/types/components/cat-icon/cat-icon.d.ts +0 -23
  228. package/dist/types/components/cat-menu/cat-menu.d.ts +0 -31
  229. package/dist/types/components/cat-scrollable/cat-scrollable.d.ts +0 -50
  230. package/dist/types/components/cat-skeleton/cat-skeleton.d.ts +0 -28
  231. package/dist/types/components/cat-spinner/cat-spinner.d.ts +0 -15
  232. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +0 -46
  233. package/dist/types/components.d.ts +0 -552
  234. package/dist/types/index.d.ts +0 -2
  235. package/dist/types/init.d.ts +0 -1
  236. package/dist/types/stencil-public-runtime.d.ts +0 -1565
  237. package/dist/types/utils/breakpoints.d.ts +0 -7
  238. package/dist/types/utils/first-tabbable.d.ts +0 -4
  239. package/dist/types/utils/is-touch-screen.d.ts +0 -2
  240. package/dist/types/utils/media-matcher.d.ts +0 -13
  241. package/dist/types/utils/platform.d.ts +0 -18
  242. package/dist/types/utils/utils.d.ts +0 -1
  243. package/loader/cdn.js +0 -3
  244. package/loader/index.cjs.js +0 -3
  245. package/loader/index.d.ts +0 -12
  246. package/loader/index.es2017.js +0 -3
  247. package/loader/index.js +0 -4
  248. package/loader/package.json +0 -10
@@ -1,4545 +0,0 @@
1
- import { r as registerInstance, h, c as createEvent, H as Host, g as getElement } from './index-0ff35bca.js';
2
- import { C as CatIconRegistry } from './cat-icon-registry-59da2e37.js';
3
-
4
- const catAlertCss = ":host{display:block;margin-bottom:1rem}:host([hidden]){display:none}.cat-alert{font:inherit;color:rgb(var(--text));background-color:rgba(var(--bg), 0.1);box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);border-radius:0.25rem;padding:0.75rem 1rem;width:100%}::slotted(:last-child){margin-bottom:0 !important}.cat-alert-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.cat-alert-secondary{--bg:105, 118, 135;--text:0, 0, 0;--border:105, 118, 135}.cat-alert-success{--bg:0, 132, 88;--text:0, 132, 88;--border:0, 132, 88}.cat-alert-warning{--bg:255, 206, 128;--text:159, 97, 0;--border:159, 97, 0}.cat-alert-danger{--bg:217, 52, 13;--text:217, 52, 13;--border:217, 52, 13}";
5
-
6
- const CatAlert = class {
7
- constructor(hostRef) {
8
- registerInstance(this, hostRef);
9
- /**
10
- * The color palette of the alert.
11
- */
12
- this.color = 'primary';
13
- }
14
- render() {
15
- return (h("div", { part: "alert", class: {
16
- 'cat-alert': true,
17
- [`cat-alert-${this.color}`]: Boolean(this.color)
18
- } }, h("slot", null)));
19
- }
20
- };
21
- CatAlert.style = catAlertCss;
22
-
23
- const catBadgeCss = ":host{display:inline-flex;max-width:100%;vertical-align:baseline}:host([hidden]){display:none}.cat-badge{font:inherit;flex:1 1 auto;display:inline-flex;align-items:center;justify-content:center;border-radius:0.125rem;text-decoration:none;width:100%;box-sizing:border-box;line-height:1;white-space:nowrap}.cat-badge slot{display:inline-block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cat-badge-round{border-radius:10rem}.cat-badge-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.cat-badge-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--border), 0.2);color:rgb(var(--text))}.cat-badge-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--border:var(--cat-primary-text, 32, 127, 138)}.cat-badge-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--border:105, 118, 135}.cat-badge-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--border:0, 132, 88}.cat-badge-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--border:159, 97, 0}.cat-badge-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--border:217, 52, 13}.cat-badge-xs{height:0.75rem;min-width:0.75rem;font-size:0.75rem;padding:0 0.1875rem}.cat-badge-s{height:1rem;min-width:1rem;font-size:0.75rem;padding:0 0.25rem}.cat-badge-m{height:1.25rem;min-width:1.25rem;font-size:0.75rem;padding:0 0.3125rem}.cat-badge-l{height:1.5rem;min-width:1.5rem;font-size:0.875rem;padding:0 0.375rem}.cat-badge-xl{height:1.75rem;min-width:1.75rem;font-size:0.9375rem;padding:0 0.4375rem}.cat-badge-pulse.cat-badge-filled{animation:1.5s ease 0s infinite normal none running pulse}.cat-badge-pulse.cat-badge-outlined{animation:1.5s ease 0s infinite normal none running pulse-outlined}@keyframes pulse{0%{box-shadow:0 0 0 0 rgb(var(--bg))}70%{box-shadow:transparent 0 0 0 0.5rem}100%{box-shadow:transparent 0 0 0 0}}@keyframes pulse-outlined{0%{box-shadow:0 0 0 0 rgb(var(--bg)), inset 0 0 0 1px rgba(var(--border), 0.2)}70%{box-shadow:transparent 0 0 0 0.5rem, inset 0 0 0 1px rgba(var(--border), 0.2)}100%{box-shadow:transparent 0 0 0 0, inset 0 0 0 1px rgba(var(--border), 0.2)}}";
24
-
25
- const CatBadge = class {
26
- constructor(hostRef) {
27
- registerInstance(this, hostRef);
28
- /**
29
- * The rendering style of the badge.
30
- */
31
- this.variant = 'filled';
32
- /**
33
- * The color palette of the badge.
34
- */
35
- this.color = 'primary';
36
- /**
37
- * The size of the badge.
38
- */
39
- this.size = 'm';
40
- /**
41
- * Use round badge edges.
42
- */
43
- this.round = false;
44
- /**
45
- * Draw attention to the badge with a subtle animation.
46
- */
47
- this.pulse = false;
48
- }
49
- render() {
50
- return (h("span", { part: "badge", class: {
51
- 'cat-badge': true,
52
- 'cat-badge-round': this.round,
53
- 'cat-badge-pulse': this.pulse,
54
- [`cat-badge-${this.variant}`]: Boolean(this.variant),
55
- [`cat-badge-${this.color}`]: Boolean(this.color),
56
- [`cat-badge-${this.size}`]: Boolean(this.size)
57
- } }, h("slot", null)));
58
- }
59
- };
60
- CatBadge.style = catBadgeCss;
61
-
62
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
63
-
64
- function createCommonjsModule(fn, basedir, module) {
65
- return module = {
66
- path: basedir,
67
- exports: {},
68
- require: function (path, base) {
69
- return commonjsRequire();
70
- }
71
- }, fn(module, module.exports), module.exports;
72
- }
73
-
74
- function commonjsRequire () {
75
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
76
- }
77
-
78
- var loglevel = createCommonjsModule(function (module) {
79
- /*
80
- * loglevel - https://github.com/pimterry/loglevel
81
- *
82
- * Copyright (c) 2013 Tim Perry
83
- * Licensed under the MIT license.
84
- */
85
- (function (root, definition) {
86
- if (module.exports) {
87
- module.exports = definition();
88
- } else {
89
- root.log = definition();
90
- }
91
- }(commonjsGlobal, function () {
92
-
93
- // Slightly dubious tricks to cut down minimized file size
94
- var noop = function() {};
95
- var undefinedType = "undefined";
96
- var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && (
97
- /Trident\/|MSIE /.test(window.navigator.userAgent)
98
- );
99
-
100
- var logMethods = [
101
- "trace",
102
- "debug",
103
- "info",
104
- "warn",
105
- "error"
106
- ];
107
-
108
- // Cross-browser bind equivalent that works at least back to IE6
109
- function bindMethod(obj, methodName) {
110
- var method = obj[methodName];
111
- if (typeof method.bind === 'function') {
112
- return method.bind(obj);
113
- } else {
114
- try {
115
- return Function.prototype.bind.call(method, obj);
116
- } catch (e) {
117
- // Missing bind shim or IE8 + Modernizr, fallback to wrapping
118
- return function() {
119
- return Function.prototype.apply.apply(method, [obj, arguments]);
120
- };
121
- }
122
- }
123
- }
124
-
125
- // Trace() doesn't print the message in IE, so for that case we need to wrap it
126
- function traceForIE() {
127
- if (console.log) {
128
- if (console.log.apply) {
129
- console.log.apply(console, arguments);
130
- } else {
131
- // In old IE, native console methods themselves don't have apply().
132
- Function.prototype.apply.apply(console.log, [console, arguments]);
133
- }
134
- }
135
- if (console.trace) console.trace();
136
- }
137
-
138
- // Build the best logging method possible for this env
139
- // Wherever possible we want to bind, not wrap, to preserve stack traces
140
- function realMethod(methodName) {
141
- if (methodName === 'debug') {
142
- methodName = 'log';
143
- }
144
-
145
- if (typeof console === undefinedType) {
146
- return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
147
- } else if (methodName === 'trace' && isIE) {
148
- return traceForIE;
149
- } else if (console[methodName] !== undefined) {
150
- return bindMethod(console, methodName);
151
- } else if (console.log !== undefined) {
152
- return bindMethod(console, 'log');
153
- } else {
154
- return noop;
155
- }
156
- }
157
-
158
- // These private functions always need `this` to be set properly
159
-
160
- function replaceLoggingMethods(level, loggerName) {
161
- /*jshint validthis:true */
162
- for (var i = 0; i < logMethods.length; i++) {
163
- var methodName = logMethods[i];
164
- this[methodName] = (i < level) ?
165
- noop :
166
- this.methodFactory(methodName, level, loggerName);
167
- }
168
-
169
- // Define log.log as an alias for log.debug
170
- this.log = this.debug;
171
- }
172
-
173
- // In old IE versions, the console isn't present until you first open it.
174
- // We build realMethod() replacements here that regenerate logging methods
175
- function enableLoggingWhenConsoleArrives(methodName, level, loggerName) {
176
- return function () {
177
- if (typeof console !== undefinedType) {
178
- replaceLoggingMethods.call(this, level, loggerName);
179
- this[methodName].apply(this, arguments);
180
- }
181
- };
182
- }
183
-
184
- // By default, we use closely bound real methods wherever possible, and
185
- // otherwise we wait for a console to appear, and then try again.
186
- function defaultMethodFactory(methodName, level, loggerName) {
187
- /*jshint validthis:true */
188
- return realMethod(methodName) ||
189
- enableLoggingWhenConsoleArrives.apply(this, arguments);
190
- }
191
-
192
- function Logger(name, defaultLevel, factory) {
193
- var self = this;
194
- var currentLevel;
195
- defaultLevel = defaultLevel == null ? "WARN" : defaultLevel;
196
-
197
- var storageKey = "loglevel";
198
- if (typeof name === "string") {
199
- storageKey += ":" + name;
200
- } else if (typeof name === "symbol") {
201
- storageKey = undefined;
202
- }
203
-
204
- function persistLevelIfPossible(levelNum) {
205
- var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
206
-
207
- if (typeof window === undefinedType || !storageKey) return;
208
-
209
- // Use localStorage if available
210
- try {
211
- window.localStorage[storageKey] = levelName;
212
- return;
213
- } catch (ignore) {}
214
-
215
- // Use session cookie as fallback
216
- try {
217
- window.document.cookie =
218
- encodeURIComponent(storageKey) + "=" + levelName + ";";
219
- } catch (ignore) {}
220
- }
221
-
222
- function getPersistedLevel() {
223
- var storedLevel;
224
-
225
- if (typeof window === undefinedType || !storageKey) return;
226
-
227
- try {
228
- storedLevel = window.localStorage[storageKey];
229
- } catch (ignore) {}
230
-
231
- // Fallback to cookies if local storage gives us nothing
232
- if (typeof storedLevel === undefinedType) {
233
- try {
234
- var cookie = window.document.cookie;
235
- var location = cookie.indexOf(
236
- encodeURIComponent(storageKey) + "=");
237
- if (location !== -1) {
238
- storedLevel = /^([^;]+)/.exec(cookie.slice(location))[1];
239
- }
240
- } catch (ignore) {}
241
- }
242
-
243
- // If the stored level is not valid, treat it as if nothing was stored.
244
- if (self.levels[storedLevel] === undefined) {
245
- storedLevel = undefined;
246
- }
247
-
248
- return storedLevel;
249
- }
250
-
251
- function clearPersistedLevel() {
252
- if (typeof window === undefinedType || !storageKey) return;
253
-
254
- // Use localStorage if available
255
- try {
256
- window.localStorage.removeItem(storageKey);
257
- return;
258
- } catch (ignore) {}
259
-
260
- // Use session cookie as fallback
261
- try {
262
- window.document.cookie =
263
- encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
264
- } catch (ignore) {}
265
- }
266
-
267
- /*
268
- *
269
- * Public logger API - see https://github.com/pimterry/loglevel for details
270
- *
271
- */
272
-
273
- self.name = name;
274
-
275
- self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3,
276
- "ERROR": 4, "SILENT": 5};
277
-
278
- self.methodFactory = factory || defaultMethodFactory;
279
-
280
- self.getLevel = function () {
281
- return currentLevel;
282
- };
283
-
284
- self.setLevel = function (level, persist) {
285
- if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
286
- level = self.levels[level.toUpperCase()];
287
- }
288
- if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
289
- currentLevel = level;
290
- if (persist !== false) { // defaults to true
291
- persistLevelIfPossible(level);
292
- }
293
- replaceLoggingMethods.call(self, level, name);
294
- if (typeof console === undefinedType && level < self.levels.SILENT) {
295
- return "No console available for logging";
296
- }
297
- } else {
298
- throw "log.setLevel() called with invalid level: " + level;
299
- }
300
- };
301
-
302
- self.setDefaultLevel = function (level) {
303
- defaultLevel = level;
304
- if (!getPersistedLevel()) {
305
- self.setLevel(level, false);
306
- }
307
- };
308
-
309
- self.resetLevel = function () {
310
- self.setLevel(defaultLevel, false);
311
- clearPersistedLevel();
312
- };
313
-
314
- self.enableAll = function(persist) {
315
- self.setLevel(self.levels.TRACE, persist);
316
- };
317
-
318
- self.disableAll = function(persist) {
319
- self.setLevel(self.levels.SILENT, persist);
320
- };
321
-
322
- // Initialize with the right level
323
- var initialLevel = getPersistedLevel();
324
- if (initialLevel == null) {
325
- initialLevel = defaultLevel;
326
- }
327
- self.setLevel(initialLevel, false);
328
- }
329
-
330
- /*
331
- *
332
- * Top-level API
333
- *
334
- */
335
-
336
- var defaultLogger = new Logger();
337
-
338
- var _loggersByName = {};
339
- defaultLogger.getLogger = function getLogger(name) {
340
- if ((typeof name !== "symbol" && typeof name !== "string") || name === "") {
341
- throw new TypeError("You must supply a name when creating a logger.");
342
- }
343
-
344
- var logger = _loggersByName[name];
345
- if (!logger) {
346
- logger = _loggersByName[name] = new Logger(
347
- name, defaultLogger.getLevel(), defaultLogger.methodFactory);
348
- }
349
- return logger;
350
- };
351
-
352
- // Grab the current global log variable in case of overwrite
353
- var _log = (typeof window !== undefinedType) ? window.log : undefined;
354
- defaultLogger.noConflict = function() {
355
- if (typeof window !== undefinedType &&
356
- window.log === defaultLogger) {
357
- window.log = _log;
358
- }
359
-
360
- return defaultLogger;
361
- };
362
-
363
- defaultLogger.getLoggers = function getLoggers() {
364
- return _loggersByName;
365
- };
366
-
367
- // ES6 default export, for compatibility
368
- defaultLogger['default'] = defaultLogger;
369
-
370
- return defaultLogger;
371
- }));
372
- });
373
-
374
- const _breakpoints = ['xs', 's', 'm', 'l', 'xl'];
375
- const Breakpoints = {
376
- xs: '(max-width: 539.98px)',
377
- s: '(max-width: 767.98px)',
378
- m: '(max-width: 991.98px)',
379
- l: '(max-width: 1199.98px)',
380
- xl: '(max-width: 1399.98px)'
381
- };
382
- function isBreakpoint(value) {
383
- return typeof value === 'string' && _breakpoints.includes(value);
384
- }
385
-
386
- // https://github.com/angular/components/blob/master/src/cdk/platform/platform.ts
387
- // Whether the current platform supports the V8 Break Iterator. The V8 check
388
- // is necessary to detect all Blink based browsers.
389
- let hasV8BreakIterator;
390
- // We need a try/catch around the reference to `Intl`, because accessing it in some cases can
391
- // cause IE to throw. These cases are tied to particular versions of Windows and can happen if
392
- // the consumer is providing a polyfilled `Map`. See:
393
- // https://github.com/Microsoft/ChakraCore/issues/3189
394
- // https://github.com/angular/components/issues/15687
395
- try {
396
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
397
- hasV8BreakIterator = typeof Intl !== 'undefined' && Intl.v8BreakIterator;
398
- }
399
- catch (_a) {
400
- hasV8BreakIterator = false;
401
- }
402
- class Platform {
403
- constructor() {
404
- /** Whether the current browser is Microsoft Edge. */
405
- this.EDGE = /(edge)/i.test(navigator.userAgent);
406
- /** Whether the current rendering engine is Microsoft Trident. */
407
- this.TRIDENT = /(msie|trident)/i.test(navigator.userAgent);
408
- // EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
409
- /** Whether the current rendering engine is Blink. */
410
- this.BLINK =
411
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
412
- !!(window.chrome || hasV8BreakIterator) && typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT;
413
- // Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
414
- // ensure that Webkit runs standalone and is not used as another engine's base.
415
- /** Whether the current rendering engine is WebKit. */
416
- this.WEBKIT = /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
417
- /** Whether the current platform is Apple iOS. */
418
- this.IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
419
- // It's difficult to detect the plain Gecko engine, because most of the browsers identify
420
- // them self as Gecko-like browsers and modify the userAgent's according to that.
421
- // Since we only cover one explicit Firefox case, we can simply check for Firefox
422
- // instead of having an unstable check for Gecko.
423
- /** Whether the current browser is Firefox. */
424
- this.FIREFOX = /(firefox|minefield)/i.test(navigator.userAgent);
425
- /** Whether the current platform is Android. */
426
- // Trident on mobile adds the android platform to the userAgent to trick detections.
427
- this.ANDROID = /android/i.test(navigator.userAgent) && !this.TRIDENT;
428
- // Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
429
- // this and just place the Safari keyword in the userAgent. To be more safe about Safari every
430
- // Safari browser should also use Webkit as its layout engine.
431
- /** Whether the current browser is Safari. */
432
- this.SAFARI = /safari/i.test(navigator.userAgent) && this.WEBKIT;
433
- }
434
- }
435
-
436
- // https://github.com/angular/components/blob/master/src/cdk/layout/media-matcher.ts
437
- /** Global registry for all dynamically-created, injected media queries. */
438
- const mediaQueriesForWebkitCompatibility = new Set();
439
- /** Style tag that holds all of the dynamically-created media queries. */
440
- let mediaQueryStyleNode;
441
- /** A utility for calling matchMedia queries. */
442
- class MediaMatcher {
443
- constructor() {
444
- this._platform = new Platform();
445
- this._matchMedia = window.matchMedia.bind(window);
446
- }
447
- /**
448
- * Evaluates the given media query and returns the native MediaQueryList from which results
449
- * can be retrieved.
450
- * Confirms the layout engine will trigger for the selector query provided and returns the
451
- * MediaQueryList for the query provided.
452
- */
453
- matchMedia(query) {
454
- if (this._platform.WEBKIT || this._platform.BLINK) {
455
- createEmptyStyleRule(query);
456
- }
457
- return this._matchMedia(query);
458
- }
459
- }
460
- /**
461
- * Creates an empty stylesheet that is used to work around browser inconsistencies related to
462
- * `matchMedia`. At the time of writing, it handles the following cases:
463
- * 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`
464
- * to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.
465
- * 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules
466
- * inside the `@media` match existing elements on the page. We work around it by having one rule
467
- * targeting the `body`. See https://github.com/angular/components/issues/23546.
468
- */
469
- function createEmptyStyleRule(query) {
470
- if (mediaQueriesForWebkitCompatibility.has(query)) {
471
- return;
472
- }
473
- try {
474
- if (!mediaQueryStyleNode) {
475
- mediaQueryStyleNode = document.createElement('style');
476
- mediaQueryStyleNode.setAttribute('type', 'text/css');
477
- document.head.appendChild(mediaQueryStyleNode);
478
- }
479
- if (mediaQueryStyleNode.sheet) {
480
- mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);
481
- mediaQueriesForWebkitCompatibility.add(query);
482
- }
483
- }
484
- catch (e) {
485
- loglevel.error(e);
486
- }
487
- }
488
-
489
- const catButtonCss = ":host{display:inline-block;max-width:100%;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.cat-button{font:inherit;display:flex;align-items:center;justify-content:center;border:none;border-radius:0.25rem;text-decoration:none;width:100%;box-sizing:border-box;cursor:pointer;transition:color 0.13s linear, border-color 0.13s linear, background-color 0.13s linear, box-shadow 0.13s linear}.cat-button:focus-visible{outline:2px solid #0071ff;outline-offset:1px}.cat-button-ellipsed .cat-button-content{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cat-button-disabled{cursor:not-allowed;opacity:0.65;filter:grayscale(100%)}.cat-button-round{border-radius:10rem}.cat-button-loading{cursor:default}.cat-button-loading cat-spinner{position:absolute}.cat-button-loading>*:not(cat-spinner){visibility:hidden}.cat-button-filled{background-color:rgb(var(--bg));color:rgb(var(--fill));font-weight:600;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:greyscale}.cat-button-outlined{background-color:white;box-shadow:inset 0 0 0 1px rgba(var(--base), 0.2);color:rgb(var(--text))}.cat-button-outlined:hover:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.05)}.cat-button-outlined:active:not(.cat-button-disabled):not(.cat-button-loading){background-color:rgba(var(--base), 0.1)}.cat-button-text{background-color:transparent;color:rgb(var(--text));text-decoration:none}.cat-button-text:hover:not(.cat-button-disabled):not(.cat-button-loading){text-decoration:underline}.cat-button-primary{--bg:var(--cat-primary-bg, 32, 127, 138);--fill:var(--cat-primary-fill, 255, 255, 255);--text:var(--cat-primary-text, 32, 127, 138);--base:var(--cat-primary-text, 32, 127, 138)}.cat-button-primary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-hover, 28, 112, 122);--fill:var(--cat-primary-fill-hover, 255, 255, 255);--text:var(--cat-primary-text-hover, 28, 112, 122)}.cat-button-primary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:var(--cat-primary-bg-active, 25, 101, 110);--fill:var(--cat-primary-fill-active, 255, 255, 255);--text:var(--cat-primary-text-active, 25, 101, 110)}.cat-button-secondary{--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0;--base:105, 118, 135}.cat-button-secondary:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-secondary:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:105, 118, 135;--fill:255, 255, 255;--text:0, 0, 0}.cat-button-success{--bg:0, 132, 88;--fill:255, 255, 255;--text:0, 132, 88;--base:0, 132, 88}.cat-button-success:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 117, 78;--fill:255, 255, 255;--text:0, 117, 78}.cat-button-success:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:0, 105, 70;--fill:255, 255, 255;--text:0, 105, 70}.cat-button-warning{--bg:255, 206, 128;--fill:0, 0, 0;--text:159, 97, 0;--base:159, 97, 0}.cat-button-warning:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 214, 148;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-warning:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:255, 222, 168;--fill:0, 0, 0;--text:159, 97, 0}.cat-button-danger{--bg:217, 52, 13;--fill:255, 255, 255;--text:217, 52, 13;--base:217, 52, 13}.cat-button-danger:hover:not(.cat-button-disabled):not(.cat-button-loading){--bg:194, 46, 11;--fill:255, 255, 255;--text:194, 46, 11}.cat-button-danger:active:not(.cat-button-disabled):not(.cat-button-loading){--bg:174, 42, 10;--fill:255, 255, 255;--text:174, 42, 10}.cat-button-xs{min-width:1.5rem;padding:0.25rem 0.25rem;font-size:0.875rem;line-height:1rem}.cat-button-xs .cat-button-prefix{margin-right:0.25rem}.cat-button-xs .cat-button-suffix{margin-left:0.25rem}.cat-button-xs.cat-button-icon{width:1.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xs{padding-left:1rem;padding-right:1rem}.cat-button-s{min-width:2rem;padding:0.375rem 0.5rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-s .cat-button-prefix{margin-right:0.25rem}.cat-button-s .cat-button-suffix{margin-left:0.25rem}.cat-button-s cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-s.cat-button-icon{width:2rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-s{padding-left:1rem;padding-right:1rem}.cat-button-m{min-width:2.5rem;padding:0.625rem 0.75rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-m .cat-button-prefix{margin-right:0.25rem}.cat-button-m .cat-button-suffix{margin-left:0.25rem}.cat-button-m cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-m.cat-button-icon{width:2.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-m{padding-left:1rem;padding-right:1rem}.cat-button-l{min-width:3rem;padding:0.875rem 1rem;font-size:0.9375rem;line-height:1.25rem}.cat-button-l .cat-button-prefix{margin-right:0.25rem}.cat-button-l .cat-button-suffix{margin-left:0.25rem}.cat-button-l cat-icon{margin-top:-0.125rem;margin-bottom:-0.125rem}.cat-button-l.cat-button-icon{width:3rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-l{padding-left:1rem;padding-right:1rem}.cat-button-xl{min-width:3.5rem;padding:1rem 1.25rem;font-size:1.125rem;line-height:1.5rem}.cat-button-xl .cat-button-prefix{margin-right:0.25rem}.cat-button-xl .cat-button-suffix{margin-left:0.25rem}.cat-button-xl.cat-button-icon{width:3.5rem;padding-left:0;padding-right:0}:host-context(nav) .cat-button-xl{padding-left:1rem;padding-right:1rem}:host-context(nav){width:100%}:host-context(nav) .cat-button{box-shadow:none;border-radius:0}:host-context(nav) .cat-button:focus-visible{outline-offset:-2px}:host-context(nav) .cat-button-content{text-align:left}:host([hidden]){display:none}:host(.cat-text-left) .cat-button{justify-content:left}:host(.cat-text-right) .cat-button{justify-content:right}";
490
-
491
- const CatButton = class {
492
- constructor(hostRef) {
493
- registerInstance(this, hostRef);
494
- this.catClick = createEvent(this, "catClick", 7);
495
- this.catFocus = createEvent(this, "catFocus", 7);
496
- this.catBlur = createEvent(this, "catBlur", 7);
497
- this._iconOnly = true;
498
- /**
499
- * The rendering style of the button.
500
- */
501
- this.variant = 'outlined';
502
- /**
503
- * The color palette of the button.
504
- */
505
- this.color = 'secondary';
506
- /**
507
- * The size of the button.
508
- */
509
- this.size = 'm';
510
- /**
511
- * Specifies that the button should be disabled. A disabled button is unusable
512
- * and un-clickable. Corresponds with the native HTML disabled attribute.
513
- */
514
- this.disabled = false;
515
- /**
516
- * Displays the button in a loading state with a spinner. Just like a disabled
517
- * button, an inactive button is unusable and un-clickable. However, it
518
- * retains the current focus state.
519
- */
520
- this.loading = false;
521
- /**
522
- * Allows the button to submit a form.
523
- */
524
- this.submit = false;
525
- /**
526
- * Ellipse overflowing button content.
527
- */
528
- this.ellipsed = true;
529
- /**
530
- * Use round button edges.
531
- */
532
- this.round = false;
533
- /**
534
- * Hide the actual button content and only display the icon.
535
- */
536
- this.iconOnly = false;
537
- /**
538
- * Display the icon as a suffix.
539
- */
540
- this.iconSuffix = false;
541
- }
542
- onIconOnlyChanged(value) {
543
- var _a, _b;
544
- // teardown
545
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
546
- (_a = this.mediaQueryList) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this.mediaQueryListener);
547
- this.mediaQueryList = undefined;
548
- this.mediaQueryListener = undefined;
549
- // setup
550
- if (isBreakpoint(value)) {
551
- (_b = this.mediaMatcher) !== null && _b !== void 0 ? _b : (this.mediaMatcher = new MediaMatcher());
552
- this.mediaQueryList = this.mediaMatcher.matchMedia(Breakpoints[value]);
553
- this.mediaQueryListener = (event) => (this._iconOnly = event.matches);
554
- this.mediaQueryList.addEventListener('change', this.mediaQueryListener);
555
- this._iconOnly = this.mediaQueryList.matches;
556
- }
557
- else {
558
- this._iconOnly = value;
559
- }
560
- }
561
- componentWillLoad() {
562
- this.onIconOnlyChanged(this.iconOnly);
563
- }
564
- componentWillRender() {
565
- if (this.isIconButton && !this.a11yLabel) {
566
- loglevel.warn('[A11y] Missing ARIA label on icon button', this);
567
- }
568
- }
569
- haltDisabledEvents(event) {
570
- if (this.disabled || this.loading) {
571
- event.preventDefault();
572
- event.stopImmediatePropagation();
573
- }
574
- }
575
- /**
576
- * Sets focus on the button. Use this method instead of `button.focus()`.
577
- *
578
- * @param options An optional object providing options to control aspects of
579
- * the focusing process.
580
- */
581
- async setFocus(options) {
582
- this.button.focus(options);
583
- }
584
- render() {
585
- var _a;
586
- if (this.url) {
587
- return (h("a", { ref: el => (this.button = el), href: this.disabled ? undefined : this.url, target: this.urlTarget, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
588
- 'cat-button': true,
589
- 'cat-button-icon': this.isIconButton,
590
- 'cat-button-round': this.round,
591
- 'cat-button-loading': this.loading,
592
- 'cat-button-disabled': this.disabled,
593
- 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
594
- [`cat-button-${this.variant}`]: Boolean(this.variant),
595
- [`cat-button-${this.color}`]: Boolean(this.color),
596
- [`cat-button-${this.size}`]: Boolean(this.size)
597
- }, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
598
- }
599
- else {
600
- return (h("button", { ref: el => (this.button = el), type: this.submit ? 'submit' : 'button', name: this.name, value: this.value, disabled: this.disabled, "aria-disabled": this.disabled ? 'true' : null, "aria-label": this.a11yLabel, id: this.buttonId, part: "button", class: {
601
- 'cat-button': true,
602
- 'cat-button-icon': this.isIconButton,
603
- 'cat-button-round': (_a = this.round) !== null && _a !== void 0 ? _a : this.isIconButton,
604
- 'cat-button-loading': this.loading,
605
- 'cat-button-disabled': this.disabled,
606
- 'cat-button-ellipsed': this.ellipsed && !this.isIconButton,
607
- [`cat-button-${this.variant}`]: Boolean(this.variant),
608
- [`cat-button-${this.color}`]: Boolean(this.color),
609
- [`cat-button-${this.size}`]: Boolean(this.size)
610
- }, onClick: this.onClick.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }, this.content));
611
- }
612
- }
613
- get iconSize() {
614
- switch (this.size) {
615
- case 'xs':
616
- return 's';
617
- default:
618
- return 'l';
619
- }
620
- }
621
- get spinnerSize() {
622
- switch (this.size) {
623
- case 'xs':
624
- return 'xs';
625
- default:
626
- return 'm';
627
- }
628
- }
629
- get isIconButton() {
630
- return Boolean(this.icon) && this._iconOnly;
631
- }
632
- get hasPrefixIcon() {
633
- return Boolean(this.icon) && !this._iconOnly && !this.iconSuffix;
634
- }
635
- get hasSuffixIcon() {
636
- return Boolean(this.icon) && !this._iconOnly && this.iconSuffix;
637
- }
638
- get content() {
639
- return [
640
- this.hasPrefixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-prefix", part: "prefix" })) : null,
641
- this.isIconButton ? (h("cat-icon", { icon: this.icon, size: this.iconSize })) : (h("span", { class: "cat-button-content", part: "content" }, h("slot", null))),
642
- this.hasSuffixIcon ? (h("cat-icon", { icon: this.icon, size: this.iconSize, class: "cat-button-suffix", part: "suffix" })) : null,
643
- this.loading ? h("cat-spinner", { size: this.spinnerSize }) : null
644
- ];
645
- }
646
- onClick(event) {
647
- this.catClick.emit(event);
648
- }
649
- onFocus(event) {
650
- this.catFocus.emit(event);
651
- }
652
- onBlur(event) {
653
- this.catBlur.emit(event);
654
- }
655
- static get watchers() { return {
656
- "iconOnly": ["onIconOnlyChanged"]
657
- }; }
658
- };
659
- CatButton.style = catButtonCss;
660
-
661
- const catIconCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host([hidden]){display:none}span{display:inline-flex}svg{fill:currentColor;stroke:none;transform-origin:center center;width:1em;height:1em}.cat-icon-xs svg{font-size:0.75rem}.cat-icon-s svg{font-size:1rem}.cat-icon-m svg{font-size:1.25rem}.cat-icon-l svg{font-size:1.5rem}.cat-icon-xl svg{font-size:1.75rem}";
662
-
663
- const CatIcon = class {
664
- constructor(hostRef) {
665
- registerInstance(this, hostRef);
666
- this.iconRegistry = CatIconRegistry.getInstance();
667
- /**
668
- * The name of the icon.
669
- */
670
- this.icon = '';
671
- /**
672
- * The size of the icon.
673
- */
674
- this.size = 'm';
675
- }
676
- render() {
677
- return (h("span", { innerHTML: this.iconRegistry.getIcon(this.icon), "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', part: "icon", class: {
678
- [`cat-icon-${this.size}`]: this.size !== 'inline'
679
- } }));
680
- }
681
- };
682
- CatIcon.style = catIconCss;
683
-
684
- function getSide(placement) {
685
- return placement.split('-')[0];
686
- }
687
-
688
- function getAlignment(placement) {
689
- return placement.split('-')[1];
690
- }
691
-
692
- function getMainAxisFromPlacement(placement) {
693
- return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
694
- }
695
-
696
- function getLengthFromAxis(axis) {
697
- return axis === 'y' ? 'height' : 'width';
698
- }
699
-
700
- function computeCoordsFromPlacement(_ref, placement, rtl) {
701
- let {
702
- reference,
703
- floating
704
- } = _ref;
705
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
706
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
707
- const mainAxis = getMainAxisFromPlacement(placement);
708
- const length = getLengthFromAxis(mainAxis);
709
- const commonAlign = reference[length] / 2 - floating[length] / 2;
710
- const side = getSide(placement);
711
- const isVertical = mainAxis === 'x';
712
- let coords;
713
-
714
- switch (side) {
715
- case 'top':
716
- coords = {
717
- x: commonX,
718
- y: reference.y - floating.height
719
- };
720
- break;
721
-
722
- case 'bottom':
723
- coords = {
724
- x: commonX,
725
- y: reference.y + reference.height
726
- };
727
- break;
728
-
729
- case 'right':
730
- coords = {
731
- x: reference.x + reference.width,
732
- y: commonY
733
- };
734
- break;
735
-
736
- case 'left':
737
- coords = {
738
- x: reference.x - floating.width,
739
- y: commonY
740
- };
741
- break;
742
-
743
- default:
744
- coords = {
745
- x: reference.x,
746
- y: reference.y
747
- };
748
- }
749
-
750
- switch (getAlignment(placement)) {
751
- case 'start':
752
- coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
753
- break;
754
-
755
- case 'end':
756
- coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
757
- break;
758
- }
759
-
760
- return coords;
761
- }
762
-
763
- /**
764
- * Computes the `x` and `y` coordinates that will place the floating element
765
- * next to a reference element when it is given a certain positioning strategy.
766
- *
767
- * This export does not have any `platform` interface logic. You will need to
768
- * write one for the platform you are using Floating UI with.
769
- */
770
-
771
- const computePosition$1 = async (reference, floating, config) => {
772
- const {
773
- placement = 'bottom',
774
- strategy = 'absolute',
775
- middleware = [],
776
- platform
777
- } = config;
778
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
779
-
780
- let rects = await platform.getElementRects({
781
- reference,
782
- floating,
783
- strategy
784
- });
785
- let {
786
- x,
787
- y
788
- } = computeCoordsFromPlacement(rects, placement, rtl);
789
- let statefulPlacement = placement;
790
- let middlewareData = {};
791
-
792
- for (let i = 0; i < middleware.length; i++) {
793
-
794
- const {
795
- name,
796
- fn
797
- } = middleware[i];
798
- const {
799
- x: nextX,
800
- y: nextY,
801
- data,
802
- reset
803
- } = await fn({
804
- x,
805
- y,
806
- initialPlacement: placement,
807
- placement: statefulPlacement,
808
- strategy,
809
- middlewareData,
810
- rects,
811
- platform,
812
- elements: {
813
- reference,
814
- floating
815
- }
816
- });
817
- x = nextX != null ? nextX : x;
818
- y = nextY != null ? nextY : y;
819
- middlewareData = { ...middlewareData,
820
- [name]: { ...middlewareData[name],
821
- ...data
822
- }
823
- };
824
-
825
- if (reset) {
826
- if (typeof reset === 'object') {
827
- if (reset.placement) {
828
- statefulPlacement = reset.placement;
829
- }
830
-
831
- if (reset.rects) {
832
- rects = reset.rects === true ? await platform.getElementRects({
833
- reference,
834
- floating,
835
- strategy
836
- }) : reset.rects;
837
- }
838
-
839
- ({
840
- x,
841
- y
842
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
843
- }
844
-
845
- i = -1;
846
- continue;
847
- }
848
- }
849
-
850
- return {
851
- x,
852
- y,
853
- placement: statefulPlacement,
854
- strategy,
855
- middlewareData
856
- };
857
- };
858
-
859
- function expandPaddingObject(padding) {
860
- return {
861
- top: 0,
862
- right: 0,
863
- bottom: 0,
864
- left: 0,
865
- ...padding
866
- };
867
- }
868
-
869
- function getSideObjectFromPadding(padding) {
870
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
871
- top: padding,
872
- right: padding,
873
- bottom: padding,
874
- left: padding
875
- };
876
- }
877
-
878
- function rectToClientRect(rect) {
879
- return { ...rect,
880
- top: rect.y,
881
- left: rect.x,
882
- right: rect.x + rect.width,
883
- bottom: rect.y + rect.height
884
- };
885
- }
886
-
887
- /**
888
- * Resolves with an object of overflow side offsets that determine how much the
889
- * element is overflowing a given clipping boundary.
890
- * - positive = overflowing the boundary by that number of pixels
891
- * - negative = how many pixels left before it will overflow
892
- * - 0 = lies flush with the boundary
893
- * @see https://floating-ui.com/docs/detectOverflow
894
- */
895
- async function detectOverflow(middlewareArguments, options) {
896
- var _await$platform$isEle;
897
-
898
- if (options === void 0) {
899
- options = {};
900
- }
901
-
902
- const {
903
- x,
904
- y,
905
- platform,
906
- rects,
907
- elements,
908
- strategy
909
- } = middlewareArguments;
910
- const {
911
- boundary = 'clippingAncestors',
912
- rootBoundary = 'viewport',
913
- elementContext = 'floating',
914
- altBoundary = false,
915
- padding = 0
916
- } = options;
917
- const paddingObject = getSideObjectFromPadding(padding);
918
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
919
- const element = elements[altBoundary ? altContext : elementContext];
920
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
921
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
922
- boundary,
923
- rootBoundary,
924
- strategy
925
- }));
926
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
927
- rect: elementContext === 'floating' ? { ...rects.floating,
928
- x,
929
- y
930
- } : rects.reference,
931
- offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
932
- strategy
933
- }) : rects[elementContext]); // positive = overflowing the clipping rect
934
- // 0 or negative = within the clipping rect
935
-
936
- return {
937
- top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
938
- bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
939
- left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
940
- right: elementClientRect.right - clippingClientRect.right + paddingObject.right
941
- };
942
- }
943
-
944
- const hash$1 = {
945
- left: 'right',
946
- right: 'left',
947
- bottom: 'top',
948
- top: 'bottom'
949
- };
950
- function getOppositePlacement(placement) {
951
- return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
952
- }
953
-
954
- function getAlignmentSides(placement, rects, rtl) {
955
- if (rtl === void 0) {
956
- rtl = false;
957
- }
958
-
959
- const alignment = getAlignment(placement);
960
- const mainAxis = getMainAxisFromPlacement(placement);
961
- const length = getLengthFromAxis(mainAxis);
962
- let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
963
-
964
- if (rects.reference[length] > rects.floating[length]) {
965
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
966
- }
967
-
968
- return {
969
- main: mainAlignmentSide,
970
- cross: getOppositePlacement(mainAlignmentSide)
971
- };
972
- }
973
-
974
- const hash = {
975
- start: 'end',
976
- end: 'start'
977
- };
978
- function getOppositeAlignmentPlacement(placement) {
979
- return placement.replace(/start|end/g, matched => hash[matched]);
980
- }
981
-
982
- function getExpandedPlacements(placement) {
983
- const oppositePlacement = getOppositePlacement(placement);
984
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
985
- }
986
-
987
- /**
988
- * Changes the placement of the floating element to one that will fit if the
989
- * initially specified `placement` does not.
990
- * @see https://floating-ui.com/docs/flip
991
- */
992
- const flip = function (options) {
993
- if (options === void 0) {
994
- options = {};
995
- }
996
-
997
- return {
998
- name: 'flip',
999
- options,
1000
-
1001
- async fn(middlewareArguments) {
1002
- var _middlewareData$flip;
1003
-
1004
- const {
1005
- placement,
1006
- middlewareData,
1007
- rects,
1008
- initialPlacement,
1009
- platform,
1010
- elements
1011
- } = middlewareArguments;
1012
- const {
1013
- mainAxis: checkMainAxis = true,
1014
- crossAxis: checkCrossAxis = true,
1015
- fallbackPlacements: specifiedFallbackPlacements,
1016
- fallbackStrategy = 'bestFit',
1017
- flipAlignment = true,
1018
- ...detectOverflowOptions
1019
- } = options;
1020
- const side = getSide(placement);
1021
- const isBasePlacement = side === initialPlacement;
1022
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1023
- const placements = [initialPlacement, ...fallbackPlacements];
1024
- const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
1025
- const overflows = [];
1026
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1027
-
1028
- if (checkMainAxis) {
1029
- overflows.push(overflow[side]);
1030
- }
1031
-
1032
- if (checkCrossAxis) {
1033
- const {
1034
- main,
1035
- cross
1036
- } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1037
- overflows.push(overflow[main], overflow[cross]);
1038
- }
1039
-
1040
- overflowsData = [...overflowsData, {
1041
- placement,
1042
- overflows
1043
- }]; // One or more sides is overflowing
1044
-
1045
- if (!overflows.every(side => side <= 0)) {
1046
- var _middlewareData$flip$, _middlewareData$flip2;
1047
-
1048
- const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
1049
- const nextPlacement = placements[nextIndex];
1050
-
1051
- if (nextPlacement) {
1052
- // Try next placement and re-run the lifecycle
1053
- return {
1054
- data: {
1055
- index: nextIndex,
1056
- overflows: overflowsData
1057
- },
1058
- reset: {
1059
- placement: nextPlacement
1060
- }
1061
- };
1062
- }
1063
-
1064
- let resetPlacement = 'bottom';
1065
-
1066
- switch (fallbackStrategy) {
1067
- case 'bestFit':
1068
- {
1069
- var _overflowsData$map$so;
1070
-
1071
- const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
1072
-
1073
- if (placement) {
1074
- resetPlacement = placement;
1075
- }
1076
-
1077
- break;
1078
- }
1079
-
1080
- case 'initialPlacement':
1081
- resetPlacement = initialPlacement;
1082
- break;
1083
- }
1084
-
1085
- if (placement !== resetPlacement) {
1086
- return {
1087
- reset: {
1088
- placement: resetPlacement
1089
- }
1090
- };
1091
- }
1092
- }
1093
-
1094
- return {};
1095
- }
1096
-
1097
- };
1098
- };
1099
-
1100
- function convertValueToCoords(placement, rects, value, rtl) {
1101
- if (rtl === void 0) {
1102
- rtl = false;
1103
- }
1104
-
1105
- const side = getSide(placement);
1106
- const alignment = getAlignment(placement);
1107
- const isVertical = getMainAxisFromPlacement(placement) === 'x';
1108
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1109
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
1110
- const rawValue = typeof value === 'function' ? value({ ...rects,
1111
- placement
1112
- }) : value; // eslint-disable-next-line prefer-const
1113
-
1114
- let {
1115
- mainAxis,
1116
- crossAxis,
1117
- alignmentAxis
1118
- } = typeof rawValue === 'number' ? {
1119
- mainAxis: rawValue,
1120
- crossAxis: 0,
1121
- alignmentAxis: null
1122
- } : {
1123
- mainAxis: 0,
1124
- crossAxis: 0,
1125
- alignmentAxis: null,
1126
- ...rawValue
1127
- };
1128
-
1129
- if (alignment && typeof alignmentAxis === 'number') {
1130
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1131
- }
1132
-
1133
- return isVertical ? {
1134
- x: crossAxis * crossAxisMulti,
1135
- y: mainAxis * mainAxisMulti
1136
- } : {
1137
- x: mainAxis * mainAxisMulti,
1138
- y: crossAxis * crossAxisMulti
1139
- };
1140
- }
1141
- /**
1142
- * Displaces the floating element from its reference element.
1143
- * @see https://floating-ui.com/docs/offset
1144
- */
1145
-
1146
- const offset = function (value) {
1147
- if (value === void 0) {
1148
- value = 0;
1149
- }
1150
-
1151
- return {
1152
- name: 'offset',
1153
- options: value,
1154
-
1155
- async fn(middlewareArguments) {
1156
- const {
1157
- x,
1158
- y,
1159
- placement,
1160
- rects,
1161
- platform,
1162
- elements
1163
- } = middlewareArguments;
1164
- const diffCoords = convertValueToCoords(placement, rects, value, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1165
- return {
1166
- x: x + diffCoords.x,
1167
- y: y + diffCoords.y,
1168
- data: diffCoords
1169
- };
1170
- }
1171
-
1172
- };
1173
- };
1174
-
1175
- function isWindow(value) {
1176
- return (value == null ? void 0 : value.toString()) === '[object Window]';
1177
- }
1178
- function getWindow(node) {
1179
- if (node == null) {
1180
- return window;
1181
- }
1182
-
1183
- if (!isWindow(node)) {
1184
- const ownerDocument = node.ownerDocument;
1185
- return ownerDocument ? ownerDocument.defaultView || window : window;
1186
- }
1187
-
1188
- return node;
1189
- }
1190
-
1191
- function getComputedStyle$1(element) {
1192
- return getWindow(element).getComputedStyle(element);
1193
- }
1194
-
1195
- function getNodeName(node) {
1196
- return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
1197
- }
1198
-
1199
- function isHTMLElement(value) {
1200
- return value instanceof getWindow(value).HTMLElement;
1201
- }
1202
- function isElement(value) {
1203
- return value instanceof getWindow(value).Element;
1204
- }
1205
- function isNode(value) {
1206
- return value instanceof getWindow(value).Node;
1207
- }
1208
- function isShadowRoot(node) {
1209
- const OwnElement = getWindow(node).ShadowRoot;
1210
- return node instanceof OwnElement || node instanceof ShadowRoot;
1211
- }
1212
- function isOverflowElement(element) {
1213
- // Firefox wants us to check `-x` and `-y` variations as well
1214
- const {
1215
- overflow,
1216
- overflowX,
1217
- overflowY
1218
- } = getComputedStyle$1(element);
1219
- return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1220
- }
1221
- function isTableElement(element) {
1222
- return ['table', 'td', 'th'].includes(getNodeName(element));
1223
- }
1224
- function isContainingBlock(element) {
1225
- // TODO: Try and use feature detection here instead
1226
- const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
1227
- const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1228
- // create a containing block.
1229
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1230
-
1231
- return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
1232
- }
1233
- function isLayoutViewport() {
1234
- // Not Safari
1235
- return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent); // Feature detection for this fails in various ways
1236
- // • Always-visible scrollbar or not
1237
- // • Width of <html>, etc.
1238
- // const vV = win.visualViewport;
1239
- // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
1240
- }
1241
-
1242
- const min = Math.min;
1243
- const max = Math.max;
1244
- const round = Math.round;
1245
-
1246
- function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1247
- if (includeScale === void 0) {
1248
- includeScale = false;
1249
- }
1250
-
1251
- if (isFixedStrategy === void 0) {
1252
- isFixedStrategy = false;
1253
- }
1254
-
1255
- const clientRect = element.getBoundingClientRect();
1256
- let scaleX = 1;
1257
- let scaleY = 1;
1258
-
1259
- if (includeScale && isHTMLElement(element)) {
1260
- scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1261
- scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1262
- }
1263
-
1264
- const win = isElement(element) ? getWindow(element) : window;
1265
- const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1266
- const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
1267
- const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
1268
- const width = clientRect.width / scaleX;
1269
- const height = clientRect.height / scaleY;
1270
- return {
1271
- width,
1272
- height,
1273
- top: y,
1274
- right: x + width,
1275
- bottom: y + height,
1276
- left: x,
1277
- x,
1278
- y
1279
- };
1280
- }
1281
-
1282
- function getDocumentElement(node) {
1283
- return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1284
- }
1285
-
1286
- function getNodeScroll(element) {
1287
- if (isWindow(element)) {
1288
- return {
1289
- scrollLeft: element.pageXOffset,
1290
- scrollTop: element.pageYOffset
1291
- };
1292
- }
1293
-
1294
- return {
1295
- scrollLeft: element.scrollLeft,
1296
- scrollTop: element.scrollTop
1297
- };
1298
- }
1299
-
1300
- function getWindowScrollBarX(element) {
1301
- // If <html> has a CSS width greater than the viewport, then this will be
1302
- // incorrect for RTL.
1303
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1304
- }
1305
-
1306
- function isScaled(element) {
1307
- const rect = getBoundingClientRect(element);
1308
- return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1309
- }
1310
-
1311
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1312
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1313
- const documentElement = getDocumentElement(offsetParent);
1314
- const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
1315
- let scroll = {
1316
- scrollLeft: 0,
1317
- scrollTop: 0
1318
- };
1319
- const offsets = {
1320
- x: 0,
1321
- y: 0
1322
- };
1323
-
1324
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1325
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1326
- scroll = getNodeScroll(offsetParent);
1327
- }
1328
-
1329
- if (isHTMLElement(offsetParent)) {
1330
- const offsetRect = getBoundingClientRect(offsetParent, true);
1331
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1332
- offsets.y = offsetRect.y + offsetParent.clientTop;
1333
- } else if (documentElement) {
1334
- offsets.x = getWindowScrollBarX(documentElement);
1335
- }
1336
- }
1337
-
1338
- return {
1339
- x: rect.left + scroll.scrollLeft - offsets.x,
1340
- y: rect.top + scroll.scrollTop - offsets.y,
1341
- width: rect.width,
1342
- height: rect.height
1343
- };
1344
- }
1345
-
1346
- function getParentNode(node) {
1347
- if (getNodeName(node) === 'html') {
1348
- return node;
1349
- }
1350
-
1351
- return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1352
- // @ts-ignore
1353
- node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1354
- node.parentNode || ( // DOM Element detected
1355
- isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1356
- getDocumentElement(node) // fallback
1357
-
1358
- );
1359
- }
1360
-
1361
- function getTrueOffsetParent(element) {
1362
- if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1363
- return null;
1364
- }
1365
-
1366
- return element.offsetParent;
1367
- }
1368
-
1369
- function getContainingBlock(element) {
1370
- let currentNode = getParentNode(element);
1371
-
1372
- if (isShadowRoot(currentNode)) {
1373
- currentNode = currentNode.host;
1374
- }
1375
-
1376
- while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
1377
- if (isContainingBlock(currentNode)) {
1378
- return currentNode;
1379
- } else {
1380
- currentNode = currentNode.parentNode;
1381
- }
1382
- }
1383
-
1384
- return null;
1385
- } // Gets the closest ancestor positioned element. Handles some edge cases,
1386
- // such as table ancestors and cross browser bugs.
1387
-
1388
-
1389
- function getOffsetParent(element) {
1390
- const window = getWindow(element);
1391
- let offsetParent = getTrueOffsetParent(element);
1392
-
1393
- while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1394
- offsetParent = getTrueOffsetParent(offsetParent);
1395
- }
1396
-
1397
- if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1398
- return window;
1399
- }
1400
-
1401
- return offsetParent || getContainingBlock(element) || window;
1402
- }
1403
-
1404
- function getDimensions(element) {
1405
- if (isHTMLElement(element)) {
1406
- return {
1407
- width: element.offsetWidth,
1408
- height: element.offsetHeight
1409
- };
1410
- }
1411
-
1412
- const rect = getBoundingClientRect(element);
1413
- return {
1414
- width: rect.width,
1415
- height: rect.height
1416
- };
1417
- }
1418
-
1419
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1420
- let {
1421
- rect,
1422
- offsetParent,
1423
- strategy
1424
- } = _ref;
1425
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
1426
- const documentElement = getDocumentElement(offsetParent);
1427
-
1428
- if (offsetParent === documentElement) {
1429
- return rect;
1430
- }
1431
-
1432
- let scroll = {
1433
- scrollLeft: 0,
1434
- scrollTop: 0
1435
- };
1436
- const offsets = {
1437
- x: 0,
1438
- y: 0
1439
- };
1440
-
1441
- if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1442
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1443
- scroll = getNodeScroll(offsetParent);
1444
- }
1445
-
1446
- if (isHTMLElement(offsetParent)) {
1447
- const offsetRect = getBoundingClientRect(offsetParent, true);
1448
- offsets.x = offsetRect.x + offsetParent.clientLeft;
1449
- offsets.y = offsetRect.y + offsetParent.clientTop;
1450
- } // This doesn't appear to be need to be negated.
1451
- // else if (documentElement) {
1452
- // offsets.x = getWindowScrollBarX(documentElement);
1453
- // }
1454
-
1455
- }
1456
-
1457
- return { ...rect,
1458
- x: rect.x - scroll.scrollLeft + offsets.x,
1459
- y: rect.y - scroll.scrollTop + offsets.y
1460
- };
1461
- }
1462
-
1463
- function getViewportRect(element, strategy) {
1464
- const win = getWindow(element);
1465
- const html = getDocumentElement(element);
1466
- const visualViewport = win.visualViewport;
1467
- let width = html.clientWidth;
1468
- let height = html.clientHeight;
1469
- let x = 0;
1470
- let y = 0;
1471
-
1472
- if (visualViewport) {
1473
- width = visualViewport.width;
1474
- height = visualViewport.height;
1475
- const layoutViewport = isLayoutViewport();
1476
-
1477
- if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1478
- x = visualViewport.offsetLeft;
1479
- y = visualViewport.offsetTop;
1480
- }
1481
- }
1482
-
1483
- return {
1484
- width,
1485
- height,
1486
- x,
1487
- y
1488
- };
1489
- }
1490
-
1491
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1492
-
1493
- function getDocumentRect(element) {
1494
- var _element$ownerDocumen;
1495
-
1496
- const html = getDocumentElement(element);
1497
- const scroll = getNodeScroll(element);
1498
- const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1499
- const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1500
- const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1501
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1502
- const y = -scroll.scrollTop;
1503
-
1504
- if (getComputedStyle$1(body || html).direction === 'rtl') {
1505
- x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1506
- }
1507
-
1508
- return {
1509
- width,
1510
- height,
1511
- x,
1512
- y
1513
- };
1514
- }
1515
-
1516
- function getNearestOverflowAncestor(node) {
1517
- const parentNode = getParentNode(node);
1518
-
1519
- if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1520
- // @ts-ignore assume body is always available
1521
- return node.ownerDocument.body;
1522
- }
1523
-
1524
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1525
- return parentNode;
1526
- }
1527
-
1528
- return getNearestOverflowAncestor(parentNode);
1529
- }
1530
-
1531
- function getOverflowAncestors(node, list) {
1532
- var _node$ownerDocument;
1533
-
1534
- if (list === void 0) {
1535
- list = [];
1536
- }
1537
-
1538
- const scrollableAncestor = getNearestOverflowAncestor(node);
1539
- const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1540
- const win = getWindow(scrollableAncestor);
1541
- const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1542
- const updatedList = list.concat(target);
1543
- return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1544
- updatedList.concat(getOverflowAncestors(getParentNode(target)));
1545
- }
1546
-
1547
- function contains(parent, child) {
1548
- const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1549
-
1550
- if (parent.contains(child)) {
1551
- return true;
1552
- } // then fallback to custom implementation with Shadow DOM support
1553
- else if (rootNode && isShadowRoot(rootNode)) {
1554
- let next = child;
1555
-
1556
- do {
1557
- // use `===` replace node.isSameNode()
1558
- if (next && parent === next) {
1559
- return true;
1560
- } // @ts-ignore: need a better way to handle this...
1561
-
1562
-
1563
- next = next.parentNode || next.host;
1564
- } while (next);
1565
- }
1566
-
1567
- return false;
1568
- }
1569
-
1570
- function getInnerBoundingClientRect(element, strategy) {
1571
- const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1572
- const top = clientRect.top + element.clientTop;
1573
- const left = clientRect.left + element.clientLeft;
1574
- return {
1575
- top,
1576
- left,
1577
- x: left,
1578
- y: top,
1579
- right: left + element.clientWidth,
1580
- bottom: top + element.clientHeight,
1581
- width: element.clientWidth,
1582
- height: element.clientHeight
1583
- };
1584
- }
1585
-
1586
- function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1587
- if (clippingParent === 'viewport') {
1588
- return rectToClientRect(getViewportRect(element, strategy));
1589
- }
1590
-
1591
- if (isElement(clippingParent)) {
1592
- return getInnerBoundingClientRect(clippingParent, strategy);
1593
- }
1594
-
1595
- return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1596
- } // A "clipping ancestor" is an overflowable container with the characteristic of
1597
- // clipping (or hiding) overflowing elements with a position different from
1598
- // `initial`
1599
-
1600
-
1601
- function getClippingAncestors(element) {
1602
- const clippingAncestors = getOverflowAncestors(element);
1603
- const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1604
- const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1605
-
1606
- if (!isElement(clipperElement)) {
1607
- return [];
1608
- } // @ts-ignore isElement check ensures we return Array<Element>
1609
-
1610
-
1611
- return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1612
- } // Gets the maximum area that the element is visible in due to any number of
1613
- // clipping ancestors
1614
-
1615
-
1616
- function getClippingRect(_ref) {
1617
- let {
1618
- element,
1619
- boundary,
1620
- rootBoundary,
1621
- strategy
1622
- } = _ref;
1623
- const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1624
- const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1625
- const firstClippingAncestor = clippingAncestors[0];
1626
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1627
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1628
- accRect.top = max(rect.top, accRect.top);
1629
- accRect.right = min(rect.right, accRect.right);
1630
- accRect.bottom = min(rect.bottom, accRect.bottom);
1631
- accRect.left = max(rect.left, accRect.left);
1632
- return accRect;
1633
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1634
- return {
1635
- width: clippingRect.right - clippingRect.left,
1636
- height: clippingRect.bottom - clippingRect.top,
1637
- x: clippingRect.left,
1638
- y: clippingRect.top
1639
- };
1640
- }
1641
-
1642
- const platform = {
1643
- getClippingRect,
1644
- convertOffsetParentRelativeRectToViewportRelativeRect,
1645
- isElement,
1646
- getDimensions,
1647
- getOffsetParent,
1648
- getDocumentElement,
1649
- getElementRects: _ref => {
1650
- let {
1651
- reference,
1652
- floating,
1653
- strategy
1654
- } = _ref;
1655
- return {
1656
- reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1657
- floating: { ...getDimensions(floating),
1658
- x: 0,
1659
- y: 0
1660
- }
1661
- };
1662
- },
1663
- getClientRects: element => Array.from(element.getClientRects()),
1664
- isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1665
- };
1666
-
1667
- /**
1668
- * Automatically updates the position of the floating element when necessary.
1669
- * @see https://floating-ui.com/docs/autoUpdate
1670
- */
1671
- function autoUpdate(reference, floating, update, options) {
1672
- if (options === void 0) {
1673
- options = {};
1674
- }
1675
-
1676
- const {
1677
- ancestorScroll: _ancestorScroll = true,
1678
- ancestorResize: _ancestorResize = true,
1679
- elementResize: _elementResize = true,
1680
- animationFrame = false
1681
- } = options;
1682
- let cleanedUp = false;
1683
- const ancestorScroll = _ancestorScroll && !animationFrame;
1684
- const ancestorResize = _ancestorResize && !animationFrame;
1685
- const elementResize = _elementResize && !animationFrame;
1686
- const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1687
- ancestors.forEach(ancestor => {
1688
- ancestorScroll && ancestor.addEventListener('scroll', update, {
1689
- passive: true
1690
- });
1691
- ancestorResize && ancestor.addEventListener('resize', update);
1692
- });
1693
- let observer = null;
1694
-
1695
- if (elementResize) {
1696
- observer = new ResizeObserver(update);
1697
- isElement(reference) && observer.observe(reference);
1698
- observer.observe(floating);
1699
- }
1700
-
1701
- let frameId;
1702
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1703
-
1704
- if (animationFrame) {
1705
- frameLoop();
1706
- }
1707
-
1708
- function frameLoop() {
1709
- if (cleanedUp) {
1710
- return;
1711
- }
1712
-
1713
- const nextRefRect = getBoundingClientRect(reference);
1714
-
1715
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1716
- update();
1717
- }
1718
-
1719
- prevRefRect = nextRefRect;
1720
- frameId = requestAnimationFrame(frameLoop);
1721
- }
1722
-
1723
- return () => {
1724
- var _observer;
1725
-
1726
- cleanedUp = true;
1727
- ancestors.forEach(ancestor => {
1728
- ancestorScroll && ancestor.removeEventListener('scroll', update);
1729
- ancestorResize && ancestor.removeEventListener('resize', update);
1730
- });
1731
- (_observer = observer) == null ? void 0 : _observer.disconnect();
1732
- observer = null;
1733
-
1734
- if (animationFrame) {
1735
- cancelAnimationFrame(frameId);
1736
- }
1737
- };
1738
- }
1739
-
1740
- /**
1741
- * Computes the `x` and `y` coordinates that will place the floating element
1742
- * next to a reference element when it is given a certain CSS positioning
1743
- * strategy.
1744
- */
1745
-
1746
- const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1747
- platform,
1748
- ...options
1749
- });
1750
-
1751
- /*!
1752
- * tabbable 5.3.1
1753
- * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
1754
- */
1755
- 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'];
1756
- var candidateSelector = /* #__PURE__ */candidateSelectors.join(',');
1757
- var NoElement = typeof Element === 'undefined';
1758
- var matches = NoElement ? function () {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
1759
- var getRootNode = !NoElement && Element.prototype.getRootNode ? function (element) {
1760
- return element.getRootNode();
1761
- } : function (element) {
1762
- return element.ownerDocument;
1763
- };
1764
- /**
1765
- * @param {Element} el container to check in
1766
- * @param {boolean} includeContainer add container to check
1767
- * @param {(node: Element) => boolean} filter filter candidates
1768
- * @returns {Element[]}
1769
- */
1770
-
1771
- var getCandidates = function getCandidates(el, includeContainer, filter) {
1772
- var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
1773
-
1774
- if (includeContainer && matches.call(el, candidateSelector)) {
1775
- candidates.unshift(el);
1776
- }
1777
-
1778
- candidates = candidates.filter(filter);
1779
- return candidates;
1780
- };
1781
- /**
1782
- * @callback GetShadowRoot
1783
- * @param {Element} element to check for shadow root
1784
- * @returns {ShadowRoot|boolean} ShadowRoot if available or boolean indicating if a shadowRoot is attached but not available.
1785
- */
1786
-
1787
- /**
1788
- * @typedef {Object} CandidatesScope
1789
- * @property {Element} scope contains inner candidates
1790
- * @property {Element[]} candidates
1791
- */
1792
-
1793
- /**
1794
- * @typedef {Object} IterativeOptions
1795
- * @property {GetShadowRoot|boolean} getShadowRoot true if shadow support is enabled; falsy if not;
1796
- * if a function, implies shadow support is enabled and either returns the shadow root of an element
1797
- * or a boolean stating if it has an undisclosed shadow root
1798
- * @property {(node: Element) => boolean} filter filter candidates
1799
- * @property {boolean} flatten if true then result will flatten any CandidatesScope into the returned list
1800
- */
1801
-
1802
- /**
1803
- * @param {Element[]} elements list of element containers to match candidates from
1804
- * @param {boolean} includeContainer add container list to check
1805
- * @param {IterativeOptions} options
1806
- * @returns {Array.<Element|CandidatesScope>}
1807
- */
1808
-
1809
-
1810
- var getCandidatesIteratively = function getCandidatesIteratively(elements, includeContainer, options) {
1811
- var candidates = [];
1812
- var elementsToCheck = Array.from(elements);
1813
-
1814
- while (elementsToCheck.length) {
1815
- var element = elementsToCheck.shift();
1816
-
1817
- if (element.tagName === 'SLOT') {
1818
- // add shadow dom slot scope (slot itself cannot be focusable)
1819
- var assigned = element.assignedElements();
1820
- var content = assigned.length ? assigned : element.children;
1821
- var nestedCandidates = getCandidatesIteratively(content, true, options);
1822
-
1823
- if (options.flatten) {
1824
- candidates.push.apply(candidates, nestedCandidates);
1825
- } else {
1826
- candidates.push({
1827
- scope: element,
1828
- candidates: nestedCandidates
1829
- });
1830
- }
1831
- } else {
1832
- // check candidate element
1833
- var validCandidate = matches.call(element, candidateSelector);
1834
-
1835
- if (validCandidate && options.filter(element) && (includeContainer || !elements.includes(element))) {
1836
- candidates.push(element);
1837
- } // iterate over shadow content if possible
1838
-
1839
-
1840
- var shadowRoot = element.shadowRoot || // check for an undisclosed shadow
1841
- typeof options.getShadowRoot === 'function' && options.getShadowRoot(element);
1842
-
1843
- if (shadowRoot) {
1844
- // add shadow dom scope IIF a shadow root node was given; otherwise, an undisclosed
1845
- // shadow exists, so look at light dom children as fallback BUT create a scope for any
1846
- // child candidates found because they're likely slotted elements (elements that are
1847
- // children of the web component element (which has the shadow), in the light dom, but
1848
- // slotted somewhere _inside_ the undisclosed shadow) -- the scope is created below,
1849
- // _after_ we return from this recursive call
1850
- var _nestedCandidates = getCandidatesIteratively(shadowRoot === true ? element.children : shadowRoot.children, true, options);
1851
-
1852
- if (options.flatten) {
1853
- candidates.push.apply(candidates, _nestedCandidates);
1854
- } else {
1855
- candidates.push({
1856
- scope: element,
1857
- candidates: _nestedCandidates
1858
- });
1859
- }
1860
- } else {
1861
- // there's not shadow so just dig into the element's (light dom) children
1862
- // __without__ giving the element special scope treatment
1863
- elementsToCheck.unshift.apply(elementsToCheck, element.children);
1864
- }
1865
- }
1866
- }
1867
-
1868
- return candidates;
1869
- };
1870
-
1871
- var getTabindex = function getTabindex(node, isScope) {
1872
- if (node.tabIndex < 0) {
1873
- // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
1874
- // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
1875
- // yet they are still part of the regular tab order; in FF, they get a default
1876
- // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
1877
- // order, consider their tab index to be 0.
1878
- // Also browsers do not return `tabIndex` correctly for contentEditable nodes;
1879
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
1880
- //
1881
- // isScope is positive for custom element with shadow root or slot that by default
1882
- // have tabIndex -1, but need to be sorted by document order in order for their
1883
- // content to be inserted in the correct position
1884
- if ((isScope || /^(AUDIO|VIDEO|DETAILS)$/.test(node.tagName) || node.isContentEditable) && isNaN(parseInt(node.getAttribute('tabindex'), 10))) {
1885
- return 0;
1886
- }
1887
- }
1888
-
1889
- return node.tabIndex;
1890
- };
1891
-
1892
- var sortOrderedTabbables = function sortOrderedTabbables(a, b) {
1893
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
1894
- };
1895
-
1896
- var isInput = function isInput(node) {
1897
- return node.tagName === 'INPUT';
1898
- };
1899
-
1900
- var isHiddenInput = function isHiddenInput(node) {
1901
- return isInput(node) && node.type === 'hidden';
1902
- };
1903
-
1904
- var isDetailsWithSummary = function isDetailsWithSummary(node) {
1905
- var r = node.tagName === 'DETAILS' && Array.prototype.slice.apply(node.children).some(function (child) {
1906
- return child.tagName === 'SUMMARY';
1907
- });
1908
- return r;
1909
- };
1910
-
1911
- var getCheckedRadio = function getCheckedRadio(nodes, form) {
1912
- for (var i = 0; i < nodes.length; i++) {
1913
- if (nodes[i].checked && nodes[i].form === form) {
1914
- return nodes[i];
1915
- }
1916
- }
1917
- };
1918
-
1919
- var isTabbableRadio = function isTabbableRadio(node) {
1920
- if (!node.name) {
1921
- return true;
1922
- }
1923
-
1924
- var radioScope = node.form || getRootNode(node);
1925
-
1926
- var queryRadios = function queryRadios(name) {
1927
- return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
1928
- };
1929
-
1930
- var radioSet;
1931
-
1932
- if (typeof window !== 'undefined' && typeof window.CSS !== 'undefined' && typeof window.CSS.escape === 'function') {
1933
- radioSet = queryRadios(window.CSS.escape(node.name));
1934
- } else {
1935
- try {
1936
- radioSet = queryRadios(node.name);
1937
- } catch (err) {
1938
- // eslint-disable-next-line no-console
1939
- 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);
1940
- return false;
1941
- }
1942
- }
1943
-
1944
- var checked = getCheckedRadio(radioSet, node.form);
1945
- return !checked || checked === node;
1946
- };
1947
-
1948
- var isRadio = function isRadio(node) {
1949
- return isInput(node) && node.type === 'radio';
1950
- };
1951
-
1952
- var isNonTabbableRadio = function isNonTabbableRadio(node) {
1953
- return isRadio(node) && !isTabbableRadio(node);
1954
- };
1955
-
1956
- var isZeroArea = function isZeroArea(node) {
1957
- var _node$getBoundingClie = node.getBoundingClientRect(),
1958
- width = _node$getBoundingClie.width,
1959
- height = _node$getBoundingClie.height;
1960
-
1961
- return width === 0 && height === 0;
1962
- };
1963
-
1964
- var isHidden = function isHidden(node, _ref) {
1965
- var displayCheck = _ref.displayCheck,
1966
- getShadowRoot = _ref.getShadowRoot;
1967
-
1968
- if (getComputedStyle(node).visibility === 'hidden') {
1969
- return true;
1970
- }
1971
-
1972
- var isDirectSummary = matches.call(node, 'details>summary:first-of-type');
1973
- var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
1974
-
1975
- if (matches.call(nodeUnderDetails, 'details:not([open]) *')) {
1976
- return true;
1977
- }
1978
-
1979
- if (!displayCheck || displayCheck === 'full') {
1980
- if (typeof getShadowRoot === 'function') {
1981
- // figure out if we should consider the node to be in an undisclosed shadow and use the
1982
- // 'non-zero-area' fallback
1983
- var originalNode = node;
1984
-
1985
- while (node) {
1986
- var parentElement = node.parentElement;
1987
- var rootNode = getRootNode(node);
1988
-
1989
- if (parentElement && !parentElement.shadowRoot && getShadowRoot(parentElement) === true // check if there's an undisclosed shadow
1990
- ) {
1991
- // node has an undisclosed shadow which means we can only treat it as a black box, so we
1992
- // fall back to a non-zero-area test
1993
- return isZeroArea(node);
1994
- } else if (node.assignedSlot) {
1995
- // iterate up slot
1996
- node = node.assignedSlot;
1997
- } else if (!parentElement && rootNode !== node.ownerDocument) {
1998
- // cross shadow boundary
1999
- node = rootNode.host;
2000
- } else {
2001
- // iterate up normal dom
2002
- node = parentElement;
2003
- }
2004
- }
2005
-
2006
- node = originalNode;
2007
- } // else, `getShadowRoot` might be true, but all that does is enable shadow DOM support
2008
- // (i.e. it does not also presume that all nodes might have undisclosed shadows); or
2009
- // it might be a falsy value, which means shadow DOM support is disabled
2010
- // didn't find it sitting in an undisclosed shadow (or shadows are disabled) so now we
2011
- // can just test to see if it would normally be visible or not
2012
- // this works wherever the node is: if there's at least one client rect, it's
2013
- // somehow displayed; it also covers the CSS 'display: contents' case where the
2014
- // node itself is hidden in place of its contents; and there's no need to search
2015
- // up the hierarchy either
2016
-
2017
-
2018
- return !node.getClientRects().length;
2019
- } else if (displayCheck === 'non-zero-area') {
2020
- return isZeroArea(node);
2021
- }
2022
-
2023
- return false;
2024
- }; // form fields (nested) inside a disabled fieldset are not focusable/tabbable
2025
- // unless they are in the _first_ <legend> element of the top-most disabled
2026
- // fieldset
2027
-
2028
-
2029
- var isDisabledFromFieldset = function isDisabledFromFieldset(node) {
2030
- if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(node.tagName)) {
2031
- var parentNode = node.parentElement; // check if `node` is contained in a disabled <fieldset>
2032
-
2033
- while (parentNode) {
2034
- if (parentNode.tagName === 'FIELDSET' && parentNode.disabled) {
2035
- // look for the first <legend> among the children of the disabled <fieldset>
2036
- for (var i = 0; i < parentNode.children.length; i++) {
2037
- var child = parentNode.children.item(i); // when the first <legend> (in document order) is found
2038
-
2039
- if (child.tagName === 'LEGEND') {
2040
- // if its parent <fieldset> is not nested in another disabled <fieldset>,
2041
- // return whether `node` is a descendant of its first <legend>
2042
- return matches.call(parentNode, 'fieldset[disabled] *') ? true : !child.contains(node);
2043
- }
2044
- } // the disabled <fieldset> containing `node` has no <legend>
2045
-
2046
-
2047
- return true;
2048
- }
2049
-
2050
- parentNode = parentNode.parentElement;
2051
- }
2052
- } // else, node's tabbable/focusable state should not be affected by a fieldset's
2053
- // enabled/disabled state
2054
-
2055
-
2056
- return false;
2057
- };
2058
-
2059
- var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable(options, node) {
2060
- if (node.disabled || isHiddenInput(node) || isHidden(node, options) || // For a details element with a summary, the summary element gets the focus
2061
- isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
2062
- return false;
2063
- }
2064
-
2065
- return true;
2066
- };
2067
-
2068
- var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable(options, node) {
2069
- if (isNonTabbableRadio(node) || getTabindex(node) < 0 || !isNodeMatchingSelectorFocusable(options, node)) {
2070
- return false;
2071
- }
2072
-
2073
- return true;
2074
- };
2075
- /**
2076
- * @param {Array.<Element|CandidatesScope>} candidates
2077
- * @returns Element[]
2078
- */
2079
-
2080
-
2081
- var sortByOrder = function sortByOrder(candidates) {
2082
- var regularTabbables = [];
2083
- var orderedTabbables = [];
2084
- candidates.forEach(function (item, i) {
2085
- var isScope = !!item.scope;
2086
- var element = isScope ? item.scope : item;
2087
- var candidateTabindex = getTabindex(element, isScope);
2088
- var elements = isScope ? sortByOrder(item.candidates) : element;
2089
-
2090
- if (candidateTabindex === 0) {
2091
- isScope ? regularTabbables.push.apply(regularTabbables, elements) : regularTabbables.push(element);
2092
- } else {
2093
- orderedTabbables.push({
2094
- documentOrder: i,
2095
- tabIndex: candidateTabindex,
2096
- item: item,
2097
- isScope: isScope,
2098
- content: elements
2099
- });
2100
- }
2101
- });
2102
- return orderedTabbables.sort(sortOrderedTabbables).reduce(function (acc, sortable) {
2103
- sortable.isScope ? acc.push.apply(acc, sortable.content) : acc.push(sortable.content);
2104
- return acc;
2105
- }, []).concat(regularTabbables);
2106
- };
2107
-
2108
- var tabbable = function tabbable(el, options) {
2109
- options = options || {};
2110
- var candidates;
2111
-
2112
- if (options.getShadowRoot) {
2113
- candidates = getCandidatesIteratively([el], options.includeContainer, {
2114
- filter: isNodeMatchingSelectorTabbable.bind(null, options),
2115
- flatten: false,
2116
- getShadowRoot: options.getShadowRoot
2117
- });
2118
- } else {
2119
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
2120
- }
2121
-
2122
- return sortByOrder(candidates);
2123
- };
2124
-
2125
- var focusable = function focusable(el, options) {
2126
- options = options || {};
2127
- var candidates;
2128
-
2129
- if (options.getShadowRoot) {
2130
- candidates = getCandidatesIteratively([el], options.includeContainer, {
2131
- filter: isNodeMatchingSelectorFocusable.bind(null, options),
2132
- flatten: true,
2133
- getShadowRoot: options.getShadowRoot
2134
- });
2135
- } else {
2136
- candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorFocusable.bind(null, options));
2137
- }
2138
-
2139
- return candidates;
2140
- };
2141
-
2142
- var isTabbable = function isTabbable(node, options) {
2143
- options = options || {};
2144
-
2145
- if (!node) {
2146
- throw new Error('No node provided');
2147
- }
2148
-
2149
- if (matches.call(node, candidateSelector) === false) {
2150
- return false;
2151
- }
2152
-
2153
- return isNodeMatchingSelectorTabbable(options, node);
2154
- };
2155
-
2156
- var focusableCandidateSelector = /* #__PURE__ */candidateSelectors.concat('iframe').join(',');
2157
-
2158
- var isFocusable = function isFocusable(node, options) {
2159
- options = options || {};
2160
-
2161
- if (!node) {
2162
- throw new Error('No node provided');
2163
- }
2164
-
2165
- if (matches.call(node, focusableCandidateSelector) === false) {
2166
- return false;
2167
- }
2168
-
2169
- return isNodeMatchingSelectorFocusable(options, node);
2170
- };
2171
-
2172
- /*!
2173
- * focus-trap 6.8.1
2174
- * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
2175
- */
2176
-
2177
- function ownKeys(object, enumerableOnly) {
2178
- var keys = Object.keys(object);
2179
-
2180
- if (Object.getOwnPropertySymbols) {
2181
- var symbols = Object.getOwnPropertySymbols(object);
2182
- enumerableOnly && (symbols = symbols.filter(function (sym) {
2183
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2184
- })), keys.push.apply(keys, symbols);
2185
- }
2186
-
2187
- return keys;
2188
- }
2189
-
2190
- function _objectSpread2(target) {
2191
- for (var i = 1; i < arguments.length; i++) {
2192
- var source = null != arguments[i] ? arguments[i] : {};
2193
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
2194
- _defineProperty(target, key, source[key]);
2195
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
2196
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2197
- });
2198
- }
2199
-
2200
- return target;
2201
- }
2202
-
2203
- function _defineProperty(obj, key, value) {
2204
- if (key in obj) {
2205
- Object.defineProperty(obj, key, {
2206
- value: value,
2207
- enumerable: true,
2208
- configurable: true,
2209
- writable: true
2210
- });
2211
- } else {
2212
- obj[key] = value;
2213
- }
2214
-
2215
- return obj;
2216
- }
2217
-
2218
- var activeFocusTraps = function () {
2219
- var trapQueue = [];
2220
- return {
2221
- activateTrap: function activateTrap(trap) {
2222
- if (trapQueue.length > 0) {
2223
- var activeTrap = trapQueue[trapQueue.length - 1];
2224
-
2225
- if (activeTrap !== trap) {
2226
- activeTrap.pause();
2227
- }
2228
- }
2229
-
2230
- var trapIndex = trapQueue.indexOf(trap);
2231
-
2232
- if (trapIndex === -1) {
2233
- trapQueue.push(trap);
2234
- } else {
2235
- // move this existing trap to the front of the queue
2236
- trapQueue.splice(trapIndex, 1);
2237
- trapQueue.push(trap);
2238
- }
2239
- },
2240
- deactivateTrap: function deactivateTrap(trap) {
2241
- var trapIndex = trapQueue.indexOf(trap);
2242
-
2243
- if (trapIndex !== -1) {
2244
- trapQueue.splice(trapIndex, 1);
2245
- }
2246
-
2247
- if (trapQueue.length > 0) {
2248
- trapQueue[trapQueue.length - 1].unpause();
2249
- }
2250
- }
2251
- };
2252
- }();
2253
-
2254
- var isSelectableInput = function isSelectableInput(node) {
2255
- return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
2256
- };
2257
-
2258
- var isEscapeEvent = function isEscapeEvent(e) {
2259
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
2260
- };
2261
-
2262
- var isTabEvent = function isTabEvent(e) {
2263
- return e.key === 'Tab' || e.keyCode === 9;
2264
- };
2265
-
2266
- var delay = function delay(fn) {
2267
- return setTimeout(fn, 0);
2268
- }; // Array.find/findIndex() are not supported on IE; this replicates enough
2269
- // of Array.findIndex() for our needs
2270
-
2271
-
2272
- var findIndex = function findIndex(arr, fn) {
2273
- var idx = -1;
2274
- arr.every(function (value, i) {
2275
- if (fn(value)) {
2276
- idx = i;
2277
- return false; // break
2278
- }
2279
-
2280
- return true; // next
2281
- });
2282
- return idx;
2283
- };
2284
- /**
2285
- * Get an option's value when it could be a plain value, or a handler that provides
2286
- * the value.
2287
- * @param {*} value Option's value to check.
2288
- * @param {...*} [params] Any parameters to pass to the handler, if `value` is a function.
2289
- * @returns {*} The `value`, or the handler's returned value.
2290
- */
2291
-
2292
-
2293
- var valueOrHandler = function valueOrHandler(value) {
2294
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
2295
- params[_key - 1] = arguments[_key];
2296
- }
2297
-
2298
- return typeof value === 'function' ? value.apply(void 0, params) : value;
2299
- };
2300
-
2301
- var getActualTarget = function getActualTarget(event) {
2302
- // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
2303
- // shadow host. However, event.target.composedPath() will be an array of
2304
- // nodes "clicked" from inner-most (the actual element inside the shadow) to
2305
- // outer-most (the host HTML document). If we have access to composedPath(),
2306
- // then use its first element; otherwise, fall back to event.target (and
2307
- // this only works for an _open_ shadow DOM; otherwise,
2308
- // composedPath()[0] === event.target always).
2309
- return event.target.shadowRoot && typeof event.composedPath === 'function' ? event.composedPath()[0] : event.target;
2310
- };
2311
-
2312
- var createFocusTrap = function createFocusTrap(elements, userOptions) {
2313
- // SSR: a live trap shouldn't be created in this type of environment so this
2314
- // should be safe code to execute if the `document` option isn't specified
2315
- var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
2316
-
2317
- var config = _objectSpread2({
2318
- returnFocusOnDeactivate: true,
2319
- escapeDeactivates: true,
2320
- delayInitialFocus: true
2321
- }, userOptions);
2322
-
2323
- var state = {
2324
- // containers given to createFocusTrap()
2325
- // @type {Array<HTMLElement>}
2326
- containers: [],
2327
- // list of objects identifying tabbable nodes in `containers` in the trap
2328
- // NOTE: it's possible that a group has no tabbable nodes if nodes get removed while the trap
2329
- // is active, but the trap should never get to a state where there isn't at least one group
2330
- // with at least one tabbable node in it (that would lead to an error condition that would
2331
- // result in an error being thrown)
2332
- // @type {Array<{
2333
- // container: HTMLElement,
2334
- // tabbableNodes: Array<HTMLElement>, // empty if none
2335
- // focusableNodes: Array<HTMLElement>, // empty if none
2336
- // firstTabbableNode: HTMLElement|null,
2337
- // lastTabbableNode: HTMLElement|null,
2338
- // nextTabbableNode: (node: HTMLElement, forward: boolean) => HTMLElement|undefined
2339
- // }>}
2340
- containerGroups: [],
2341
- // same order/length as `containers` list
2342
- // references to objects in `containerGroups`, but only those that actually have
2343
- // tabbable nodes in them
2344
- // NOTE: same order as `containers` and `containerGroups`, but __not necessarily__
2345
- // the same length
2346
- tabbableGroups: [],
2347
- nodeFocusedBeforeActivation: null,
2348
- mostRecentlyFocusedNode: null,
2349
- active: false,
2350
- paused: false,
2351
- // timer ID for when delayInitialFocus is true and initial focus in this trap
2352
- // has been delayed during activation
2353
- delayInitialFocusTimer: undefined
2354
- };
2355
- 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
2356
-
2357
- /**
2358
- * Gets a configuration option value.
2359
- * @param {Object|undefined} configOverrideOptions If true, and option is defined in this set,
2360
- * value will be taken from this object. Otherwise, value will be taken from base configuration.
2361
- * @param {string} optionName Name of the option whose value is sought.
2362
- * @param {string|undefined} [configOptionName] Name of option to use __instead of__ `optionName`
2363
- * IIF `configOverrideOptions` is not defined. Otherwise, `optionName` is used.
2364
- */
2365
-
2366
- var getOption = function getOption(configOverrideOptions, optionName, configOptionName) {
2367
- return configOverrideOptions && configOverrideOptions[optionName] !== undefined ? configOverrideOptions[optionName] : config[configOptionName || optionName];
2368
- };
2369
- /**
2370
- * Finds the index of the container that contains the element.
2371
- * @param {HTMLElement} element
2372
- * @returns {number} Index of the container in either `state.containers` or
2373
- * `state.containerGroups` (the order/length of these lists are the same); -1
2374
- * if the element isn't found.
2375
- */
2376
-
2377
-
2378
- var findContainerIndex = function findContainerIndex(element) {
2379
- // NOTE: search `containerGroups` because it's possible a group contains no tabbable
2380
- // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
2381
- // and we still need to find the element in there
2382
- return state.containerGroups.findIndex(function (_ref) {
2383
- var container = _ref.container,
2384
- tabbableNodes = _ref.tabbableNodes;
2385
- return container.contains(element) || // fall back to explicit tabbable search which will take into consideration any
2386
- // web components if the `tabbableOptions.getShadowRoot` option was used for
2387
- // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
2388
- // look inside web components even if open)
2389
- tabbableNodes.find(function (node) {
2390
- return node === element;
2391
- });
2392
- });
2393
- };
2394
- /**
2395
- * Gets the node for the given option, which is expected to be an option that
2396
- * can be either a DOM node, a string that is a selector to get a node, `false`
2397
- * (if a node is explicitly NOT given), or a function that returns any of these
2398
- * values.
2399
- * @param {string} optionName
2400
- * @returns {undefined | false | HTMLElement | SVGElement} Returns
2401
- * `undefined` if the option is not specified; `false` if the option
2402
- * resolved to `false` (node explicitly not given); otherwise, the resolved
2403
- * DOM node.
2404
- * @throws {Error} If the option is set, not `false`, and is not, or does not
2405
- * resolve to a node.
2406
- */
2407
-
2408
-
2409
- var getNodeForOption = function getNodeForOption(optionName) {
2410
- var optionValue = config[optionName];
2411
-
2412
- if (typeof optionValue === 'function') {
2413
- for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2414
- params[_key2 - 1] = arguments[_key2];
2415
- }
2416
-
2417
- optionValue = optionValue.apply(void 0, params);
2418
- }
2419
-
2420
- if (!optionValue) {
2421
- if (optionValue === undefined || optionValue === false) {
2422
- return optionValue;
2423
- } // else, empty string (invalid), null (invalid), 0 (invalid)
2424
-
2425
-
2426
- throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
2427
- }
2428
-
2429
- var node = optionValue; // could be HTMLElement, SVGElement, or non-empty string at this point
2430
-
2431
- if (typeof optionValue === 'string') {
2432
- node = doc.querySelector(optionValue); // resolve to node, or null if fails
2433
-
2434
- if (!node) {
2435
- throw new Error("`".concat(optionName, "` as selector refers to no known node"));
2436
- }
2437
- }
2438
-
2439
- return node;
2440
- };
2441
-
2442
- var getInitialFocusNode = function getInitialFocusNode() {
2443
- var node = getNodeForOption('initialFocus'); // false explicitly indicates we want no initialFocus at all
2444
-
2445
- if (node === false) {
2446
- return false;
2447
- }
2448
-
2449
- if (node === undefined) {
2450
- // option not specified: use fallback options
2451
- if (findContainerIndex(doc.activeElement) >= 0) {
2452
- node = doc.activeElement;
2453
- } else {
2454
- var firstTabbableGroup = state.tabbableGroups[0];
2455
- var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode; // NOTE: `fallbackFocus` option function cannot return `false` (not supported)
2456
-
2457
- node = firstTabbableNode || getNodeForOption('fallbackFocus');
2458
- }
2459
- }
2460
-
2461
- if (!node) {
2462
- throw new Error('Your focus-trap needs to have at least one focusable element');
2463
- }
2464
-
2465
- return node;
2466
- };
2467
-
2468
- var updateTabbableNodes = function updateTabbableNodes() {
2469
- state.containerGroups = state.containers.map(function (container) {
2470
- var tabbableNodes = tabbable(container, config.tabbableOptions); // NOTE: if we have tabbable nodes, we must have focusable nodes; focusable nodes
2471
- // are a superset of tabbable nodes
2472
-
2473
- var focusableNodes = focusable(container, config.tabbableOptions);
2474
- return {
2475
- container: container,
2476
- tabbableNodes: tabbableNodes,
2477
- focusableNodes: focusableNodes,
2478
- firstTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[0] : null,
2479
- lastTabbableNode: tabbableNodes.length > 0 ? tabbableNodes[tabbableNodes.length - 1] : null,
2480
-
2481
- /**
2482
- * Finds the __tabbable__ node that follows the given node in the specified direction,
2483
- * in this container, if any.
2484
- * @param {HTMLElement} node
2485
- * @param {boolean} [forward] True if going in forward tab order; false if going
2486
- * in reverse.
2487
- * @returns {HTMLElement|undefined} The next tabbable node, if any.
2488
- */
2489
- nextTabbableNode: function nextTabbableNode(node) {
2490
- var forward = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2491
- // NOTE: If tabindex is positive (in order to manipulate the tab order separate
2492
- // from the DOM order), this __will not work__ because the list of focusableNodes,
2493
- // while it contains tabbable nodes, does not sort its nodes in any order other
2494
- // than DOM order, because it can't: Where would you place focusable (but not
2495
- // tabbable) nodes in that order? They have no order, because they aren't tabbale...
2496
- // Support for positive tabindex is already broken and hard to manage (possibly
2497
- // not supportable, TBD), so this isn't going to make things worse than they
2498
- // already are, and at least makes things better for the majority of cases where
2499
- // tabindex is either 0/unset or negative.
2500
- // FYI, positive tabindex issue: https://github.com/focus-trap/focus-trap/issues/375
2501
- var nodeIdx = focusableNodes.findIndex(function (n) {
2502
- return n === node;
2503
- });
2504
-
2505
- if (nodeIdx < 0) {
2506
- return undefined;
2507
- }
2508
-
2509
- if (forward) {
2510
- return focusableNodes.slice(nodeIdx + 1).find(function (n) {
2511
- return isTabbable(n, config.tabbableOptions);
2512
- });
2513
- }
2514
-
2515
- return focusableNodes.slice(0, nodeIdx).reverse().find(function (n) {
2516
- return isTabbable(n, config.tabbableOptions);
2517
- });
2518
- }
2519
- };
2520
- });
2521
- state.tabbableGroups = state.containerGroups.filter(function (group) {
2522
- return group.tabbableNodes.length > 0;
2523
- }); // throw if no groups have tabbable nodes and we don't have a fallback focus node either
2524
-
2525
- if (state.tabbableGroups.length <= 0 && !getNodeForOption('fallbackFocus') // returning false not supported for this option
2526
- ) {
2527
- throw new Error('Your focus-trap must have at least one container with at least one tabbable node in it at all times');
2528
- }
2529
- };
2530
-
2531
- var tryFocus = function tryFocus(node) {
2532
- if (node === false) {
2533
- return;
2534
- }
2535
-
2536
- if (node === doc.activeElement) {
2537
- return;
2538
- }
2539
-
2540
- if (!node || !node.focus) {
2541
- tryFocus(getInitialFocusNode());
2542
- return;
2543
- }
2544
-
2545
- node.focus({
2546
- preventScroll: !!config.preventScroll
2547
- });
2548
- state.mostRecentlyFocusedNode = node;
2549
-
2550
- if (isSelectableInput(node)) {
2551
- node.select();
2552
- }
2553
- };
2554
-
2555
- var getReturnFocusNode = function getReturnFocusNode(previousActiveElement) {
2556
- var node = getNodeForOption('setReturnFocus', previousActiveElement);
2557
- return node ? node : node === false ? false : previousActiveElement;
2558
- }; // This needs to be done on mousedown and touchstart instead of click
2559
- // so that it precedes the focus event.
2560
-
2561
-
2562
- var checkPointerDown = function checkPointerDown(e) {
2563
- var target = getActualTarget(e);
2564
-
2565
- if (findContainerIndex(target) >= 0) {
2566
- // allow the click since it ocurred inside the trap
2567
- return;
2568
- }
2569
-
2570
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2571
- // immediately deactivate the trap
2572
- trap.deactivate({
2573
- // if, on deactivation, we should return focus to the node originally-focused
2574
- // when the trap was activated (or the configured `setReturnFocus` node),
2575
- // then assume it's also OK to return focus to the outside node that was
2576
- // just clicked, causing deactivation, as long as that node is focusable;
2577
- // if it isn't focusable, then return focus to the original node focused
2578
- // on activation (or the configured `setReturnFocus` node)
2579
- // NOTE: by setting `returnFocus: false`, deactivate() will do nothing,
2580
- // which will result in the outside click setting focus to the node
2581
- // that was clicked, whether it's focusable or not; by setting
2582
- // `returnFocus: true`, we'll attempt to re-focus the node originally-focused
2583
- // on activation (or the configured `setReturnFocus` node)
2584
- returnFocus: config.returnFocusOnDeactivate && !isFocusable(target, config.tabbableOptions)
2585
- });
2586
- return;
2587
- } // This is needed for mobile devices.
2588
- // (If we'll only let `click` events through,
2589
- // then on mobile they will be blocked anyways if `touchstart` is blocked.)
2590
-
2591
-
2592
- if (valueOrHandler(config.allowOutsideClick, e)) {
2593
- // allow the click outside the trap to take place
2594
- return;
2595
- } // otherwise, prevent the click
2596
-
2597
-
2598
- e.preventDefault();
2599
- }; // In case focus escapes the trap for some strange reason, pull it back in.
2600
-
2601
-
2602
- var checkFocusIn = function checkFocusIn(e) {
2603
- var target = getActualTarget(e);
2604
- var targetContained = findContainerIndex(target) >= 0; // In Firefox when you Tab out of an iframe the Document is briefly focused.
2605
-
2606
- if (targetContained || target instanceof Document) {
2607
- if (targetContained) {
2608
- state.mostRecentlyFocusedNode = target;
2609
- }
2610
- } else {
2611
- // escaped! pull it back in to where it just left
2612
- e.stopImmediatePropagation();
2613
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
2614
- }
2615
- }; // Hijack Tab events on the first and last focusable nodes of the trap,
2616
- // in order to prevent focus from escaping. If it escapes for even a
2617
- // moment it can end up scrolling the page and causing confusion so we
2618
- // kind of need to capture the action at the keydown phase.
2619
-
2620
-
2621
- var checkTab = function checkTab(e) {
2622
- var target = getActualTarget(e);
2623
- updateTabbableNodes();
2624
- var destinationNode = null;
2625
-
2626
- if (state.tabbableGroups.length > 0) {
2627
- // make sure the target is actually contained in a group
2628
- // NOTE: the target may also be the container itself if it's focusable
2629
- // with tabIndex='-1' and was given initial focus
2630
- var containerIndex = findContainerIndex(target);
2631
- var containerGroup = containerIndex >= 0 ? state.containerGroups[containerIndex] : undefined;
2632
-
2633
- if (containerIndex < 0) {
2634
- // target not found in any group: quite possible focus has escaped the trap,
2635
- // so bring it back in to...
2636
- if (e.shiftKey) {
2637
- // ...the last node in the last group
2638
- destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
2639
- } else {
2640
- // ...the first node in the first group
2641
- destinationNode = state.tabbableGroups[0].firstTabbableNode;
2642
- }
2643
- } else if (e.shiftKey) {
2644
- // REVERSE
2645
- // is the target the first tabbable node in a group?
2646
- var startOfGroupIndex = findIndex(state.tabbableGroups, function (_ref2) {
2647
- var firstTabbableNode = _ref2.firstTabbableNode;
2648
- return target === firstTabbableNode;
2649
- });
2650
-
2651
- if (startOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target, false))) {
2652
- // an exception case where the target is either the container itself, or
2653
- // a non-tabbable node that was given focus (i.e. tabindex is negative
2654
- // and user clicked on it or node was programmatically given focus)
2655
- // and is not followed by any other tabbable node, in which
2656
- // case, we should handle shift+tab as if focus were on the container's
2657
- // first tabbable node, and go to the last tabbable node of the LAST group
2658
- startOfGroupIndex = containerIndex;
2659
- }
2660
-
2661
- if (startOfGroupIndex >= 0) {
2662
- // YES: then shift+tab should go to the last tabbable node in the
2663
- // previous group (and wrap around to the last tabbable node of
2664
- // the LAST group if it's the first tabbable node of the FIRST group)
2665
- var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
2666
- var destinationGroup = state.tabbableGroups[destinationGroupIndex];
2667
- destinationNode = destinationGroup.lastTabbableNode;
2668
- }
2669
- } else {
2670
- // FORWARD
2671
- // is the target the last tabbable node in a group?
2672
- var lastOfGroupIndex = findIndex(state.tabbableGroups, function (_ref3) {
2673
- var lastTabbableNode = _ref3.lastTabbableNode;
2674
- return target === lastTabbableNode;
2675
- });
2676
-
2677
- if (lastOfGroupIndex < 0 && (containerGroup.container === target || isFocusable(target, config.tabbableOptions) && !isTabbable(target, config.tabbableOptions) && !containerGroup.nextTabbableNode(target))) {
2678
- // an exception case where the target is the container itself, or
2679
- // a non-tabbable node that was given focus (i.e. tabindex is negative
2680
- // and user clicked on it or node was programmatically given focus)
2681
- // and is not followed by any other tabbable node, in which
2682
- // case, we should handle tab as if focus were on the container's
2683
- // last tabbable node, and go to the first tabbable node of the FIRST group
2684
- lastOfGroupIndex = containerIndex;
2685
- }
2686
-
2687
- if (lastOfGroupIndex >= 0) {
2688
- // YES: then tab should go to the first tabbable node in the next
2689
- // group (and wrap around to the first tabbable node of the FIRST
2690
- // group if it's the last tabbable node of the LAST group)
2691
- var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
2692
-
2693
- var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
2694
- destinationNode = _destinationGroup.firstTabbableNode;
2695
- }
2696
- }
2697
- } else {
2698
- // NOTE: the fallbackFocus option does not support returning false to opt-out
2699
- destinationNode = getNodeForOption('fallbackFocus');
2700
- }
2701
-
2702
- if (destinationNode) {
2703
- e.preventDefault();
2704
- tryFocus(destinationNode);
2705
- } // else, let the browser take care of [shift+]tab and move the focus
2706
-
2707
- };
2708
-
2709
- var checkKey = function checkKey(e) {
2710
- if (isEscapeEvent(e) && valueOrHandler(config.escapeDeactivates, e) !== false) {
2711
- e.preventDefault();
2712
- trap.deactivate();
2713
- return;
2714
- }
2715
-
2716
- if (isTabEvent(e)) {
2717
- checkTab(e);
2718
- return;
2719
- }
2720
- };
2721
-
2722
- var checkClick = function checkClick(e) {
2723
- if (valueOrHandler(config.clickOutsideDeactivates, e)) {
2724
- return;
2725
- }
2726
-
2727
- var target = getActualTarget(e);
2728
-
2729
- if (findContainerIndex(target) >= 0) {
2730
- return;
2731
- }
2732
-
2733
- if (valueOrHandler(config.allowOutsideClick, e)) {
2734
- return;
2735
- }
2736
-
2737
- e.preventDefault();
2738
- e.stopImmediatePropagation();
2739
- }; //
2740
- // EVENT LISTENERS
2741
- //
2742
-
2743
-
2744
- var addListeners = function addListeners() {
2745
- if (!state.active) {
2746
- return;
2747
- } // There can be only one listening focus trap at a time
2748
-
2749
-
2750
- activeFocusTraps.activateTrap(trap); // Delay ensures that the focused element doesn't capture the event
2751
- // that caused the focus trap activation.
2752
-
2753
- state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function () {
2754
- tryFocus(getInitialFocusNode());
2755
- }) : tryFocus(getInitialFocusNode());
2756
- doc.addEventListener('focusin', checkFocusIn, true);
2757
- doc.addEventListener('mousedown', checkPointerDown, {
2758
- capture: true,
2759
- passive: false
2760
- });
2761
- doc.addEventListener('touchstart', checkPointerDown, {
2762
- capture: true,
2763
- passive: false
2764
- });
2765
- doc.addEventListener('click', checkClick, {
2766
- capture: true,
2767
- passive: false
2768
- });
2769
- doc.addEventListener('keydown', checkKey, {
2770
- capture: true,
2771
- passive: false
2772
- });
2773
- return trap;
2774
- };
2775
-
2776
- var removeListeners = function removeListeners() {
2777
- if (!state.active) {
2778
- return;
2779
- }
2780
-
2781
- doc.removeEventListener('focusin', checkFocusIn, true);
2782
- doc.removeEventListener('mousedown', checkPointerDown, true);
2783
- doc.removeEventListener('touchstart', checkPointerDown, true);
2784
- doc.removeEventListener('click', checkClick, true);
2785
- doc.removeEventListener('keydown', checkKey, true);
2786
- return trap;
2787
- }; //
2788
- // TRAP DEFINITION
2789
- //
2790
-
2791
-
2792
- trap = {
2793
- activate: function activate(activateOptions) {
2794
- if (state.active) {
2795
- return this;
2796
- }
2797
-
2798
- var onActivate = getOption(activateOptions, 'onActivate');
2799
- var onPostActivate = getOption(activateOptions, 'onPostActivate');
2800
- var checkCanFocusTrap = getOption(activateOptions, 'checkCanFocusTrap');
2801
-
2802
- if (!checkCanFocusTrap) {
2803
- updateTabbableNodes();
2804
- }
2805
-
2806
- state.active = true;
2807
- state.paused = false;
2808
- state.nodeFocusedBeforeActivation = doc.activeElement;
2809
-
2810
- if (onActivate) {
2811
- onActivate();
2812
- }
2813
-
2814
- var finishActivation = function finishActivation() {
2815
- if (checkCanFocusTrap) {
2816
- updateTabbableNodes();
2817
- }
2818
-
2819
- addListeners();
2820
-
2821
- if (onPostActivate) {
2822
- onPostActivate();
2823
- }
2824
- };
2825
-
2826
- if (checkCanFocusTrap) {
2827
- checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
2828
- return this;
2829
- }
2830
-
2831
- finishActivation();
2832
- return this;
2833
- },
2834
- deactivate: function deactivate(deactivateOptions) {
2835
- if (!state.active) {
2836
- return this;
2837
- }
2838
-
2839
- clearTimeout(state.delayInitialFocusTimer); // noop if undefined
2840
-
2841
- state.delayInitialFocusTimer = undefined;
2842
- removeListeners();
2843
- state.active = false;
2844
- state.paused = false;
2845
- activeFocusTraps.deactivateTrap(trap);
2846
- var onDeactivate = getOption(deactivateOptions, 'onDeactivate');
2847
- var onPostDeactivate = getOption(deactivateOptions, 'onPostDeactivate');
2848
- var checkCanReturnFocus = getOption(deactivateOptions, 'checkCanReturnFocus');
2849
-
2850
- if (onDeactivate) {
2851
- onDeactivate();
2852
- }
2853
-
2854
- var returnFocus = getOption(deactivateOptions, 'returnFocus', 'returnFocusOnDeactivate');
2855
-
2856
- var finishDeactivation = function finishDeactivation() {
2857
- delay(function () {
2858
- if (returnFocus) {
2859
- tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
2860
- }
2861
-
2862
- if (onPostDeactivate) {
2863
- onPostDeactivate();
2864
- }
2865
- });
2866
- };
2867
-
2868
- if (returnFocus && checkCanReturnFocus) {
2869
- checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
2870
- return this;
2871
- }
2872
-
2873
- finishDeactivation();
2874
- return this;
2875
- },
2876
- pause: function pause() {
2877
- if (state.paused || !state.active) {
2878
- return this;
2879
- }
2880
-
2881
- state.paused = true;
2882
- removeListeners();
2883
- return this;
2884
- },
2885
- unpause: function unpause() {
2886
- if (!state.paused || !state.active) {
2887
- return this;
2888
- }
2889
-
2890
- state.paused = false;
2891
- updateTabbableNodes();
2892
- addListeners();
2893
- return this;
2894
- },
2895
- updateContainerElements: function updateContainerElements(containerElements) {
2896
- var elementsAsArray = [].concat(containerElements).filter(Boolean);
2897
- state.containers = elementsAsArray.map(function (element) {
2898
- return typeof element === 'string' ? doc.querySelector(element) : element;
2899
- });
2900
-
2901
- if (state.active) {
2902
- updateTabbableNodes();
2903
- }
2904
-
2905
- return this;
2906
- }
2907
- }; // initialize container elements
2908
-
2909
- trap.updateContainerElements(elements);
2910
- return trap;
2911
- };
2912
-
2913
- const firstTabbable = (container) => {
2914
- return (container ? tabbable(container, { includeContainer: true, getShadowRoot: true }) : []).shift();
2915
- };
2916
-
2917
- const catMenuCss = ":host{display:inline-block}:host([hidden]){display:none}.content{padding-top:0.5rem;padding-bottom:0.5rem;position:absolute;background:white;display:none;overflow:auto;-webkit-overflow-scrolling:touch;min-width:8rem;max-width:16rem;min-height:2rem;max-height:calc(100vh - 48px);box-shadow:0 1px 4px 0 rgba(16, 29, 48, 0.2);border-radius:0.25rem}";
2918
-
2919
- let nextUniqueId$1 = 0;
2920
- const CatMenu = class {
2921
- constructor(hostRef) {
2922
- registerInstance(this, hostRef);
2923
- this.catOpen = createEvent(this, "catOpen", 7);
2924
- this.catClose = createEvent(this, "catClose", 7);
2925
- this.id = nextUniqueId$1++;
2926
- /**
2927
- * The placement of the menu.
2928
- */
2929
- this.placement = 'bottom-start';
2930
- }
2931
- clickHandler(event) {
2932
- var _a;
2933
- // hide menu on button click
2934
- if (this.content && event.composedPath().includes(this.content)) {
2935
- (_a = this.trap) === null || _a === void 0 ? void 0 : _a.deactivate();
2936
- this.hide();
2937
- }
2938
- }
2939
- componentDidLoad() {
2940
- var _a, _b, _c, _d, _e;
2941
- this.trigger = firstTabbable(this.triggerSlot);
2942
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-haspopup', 'true');
2943
- (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.setAttribute('aria-expanded', 'false');
2944
- (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.setAttribute('aria-controls', this.contentId);
2945
- (_d = this.content) === null || _d === void 0 ? void 0 : _d.setAttribute('id', this.contentId);
2946
- if (this.trigger && this.content) {
2947
- (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('click', () => this.show());
2948
- autoUpdate(this.trigger, this.content, () => this.update());
2949
- }
2950
- this.keyListener = event => {
2951
- if (this.content && ['ArrowDown', 'ArrowUp'].includes(event.key)) {
2952
- const targetElements = tabbable(this.content, { includeContainer: false, getShadowRoot: true });
2953
- const activeElement = firstTabbable(document.activeElement);
2954
- const activeIdx = activeElement ? targetElements.indexOf(activeElement) : -1;
2955
- const activeOff = event.key === 'ArrowDown' ? 1 : -1;
2956
- const targetIdx = activeIdx < 0 ? 0 : (activeIdx + activeOff + targetElements.length) % targetElements.length;
2957
- targetElements[targetIdx].focus();
2958
- event.preventDefault();
2959
- }
2960
- };
2961
- document.addEventListener('keydown', this.keyListener);
2962
- }
2963
- disconnectedCallback() {
2964
- if (this.keyListener) {
2965
- document.removeEventListener('keydown', this.keyListener);
2966
- }
2967
- }
2968
- render() {
2969
- return (h(Host, null, h("slot", { name: "trigger", ref: el => (this.triggerSlot = el) }), h("div", { class: "content", ref: el => (this.content = el) }, h("slot", { name: "content" }))));
2970
- }
2971
- get contentId() {
2972
- return `cat-menu-${this.id}`;
2973
- }
2974
- show() {
2975
- var _a;
2976
- if (this.content) {
2977
- this.content.style.display = 'block';
2978
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'true');
2979
- this.catOpen.emit();
2980
- this.trap = this.trap
2981
- ? this.trap.updateContainerElements(this.content)
2982
- : createFocusTrap(this.content, {
2983
- tabbableOptions: {
2984
- getShadowRoot: true
2985
- },
2986
- allowOutsideClick: true,
2987
- clickOutsideDeactivates: event => !this.content || !event.composedPath().includes(this.content),
2988
- onPostDeactivate: () => this.hide()
2989
- });
2990
- this.trap.activate();
2991
- }
2992
- }
2993
- hide() {
2994
- var _a;
2995
- if (this.content) {
2996
- this.content.style.display = '';
2997
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', 'false');
2998
- this.catClose.emit();
2999
- }
3000
- }
3001
- update() {
3002
- if (this.trigger && this.content) {
3003
- computePosition(this.trigger, this.content, {
3004
- placement: this.placement,
3005
- middleware: [offset(CatMenu.OFFSET), flip()]
3006
- }).then(({ x, y }) => {
3007
- if (this.content) {
3008
- Object.assign(this.content.style, {
3009
- left: `${x}px`,
3010
- top: `${y}px`
3011
- });
3012
- }
3013
- });
3014
- }
3015
- }
3016
- };
3017
- CatMenu.OFFSET = 4;
3018
- CatMenu.style = catMenuCss;
3019
-
3020
- function isFunction(value) {
3021
- return typeof value === 'function';
3022
- }
3023
-
3024
- function createErrorClass(createImpl) {
3025
- const _super = (instance) => {
3026
- Error.call(instance);
3027
- instance.stack = new Error().stack;
3028
- };
3029
- const ctorFunc = createImpl(_super);
3030
- ctorFunc.prototype = Object.create(Error.prototype);
3031
- ctorFunc.prototype.constructor = ctorFunc;
3032
- return ctorFunc;
3033
- }
3034
-
3035
- const UnsubscriptionError = createErrorClass((_super) => function UnsubscriptionErrorImpl(errors) {
3036
- _super(this);
3037
- this.message = errors
3038
- ? `${errors.length} errors occurred during unsubscription:
3039
- ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}`
3040
- : '';
3041
- this.name = 'UnsubscriptionError';
3042
- this.errors = errors;
3043
- });
3044
-
3045
- function arrRemove(arr, item) {
3046
- if (arr) {
3047
- const index = arr.indexOf(item);
3048
- 0 <= index && arr.splice(index, 1);
3049
- }
3050
- }
3051
-
3052
- class Subscription {
3053
- constructor(initialTeardown) {
3054
- this.initialTeardown = initialTeardown;
3055
- this.closed = false;
3056
- this._parentage = null;
3057
- this._finalizers = null;
3058
- }
3059
- unsubscribe() {
3060
- let errors;
3061
- if (!this.closed) {
3062
- this.closed = true;
3063
- const { _parentage } = this;
3064
- if (_parentage) {
3065
- this._parentage = null;
3066
- if (Array.isArray(_parentage)) {
3067
- for (const parent of _parentage) {
3068
- parent.remove(this);
3069
- }
3070
- }
3071
- else {
3072
- _parentage.remove(this);
3073
- }
3074
- }
3075
- const { initialTeardown: initialFinalizer } = this;
3076
- if (isFunction(initialFinalizer)) {
3077
- try {
3078
- initialFinalizer();
3079
- }
3080
- catch (e) {
3081
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
3082
- }
3083
- }
3084
- const { _finalizers } = this;
3085
- if (_finalizers) {
3086
- this._finalizers = null;
3087
- for (const finalizer of _finalizers) {
3088
- try {
3089
- execFinalizer(finalizer);
3090
- }
3091
- catch (err) {
3092
- errors = errors !== null && errors !== void 0 ? errors : [];
3093
- if (err instanceof UnsubscriptionError) {
3094
- errors = [...errors, ...err.errors];
3095
- }
3096
- else {
3097
- errors.push(err);
3098
- }
3099
- }
3100
- }
3101
- }
3102
- if (errors) {
3103
- throw new UnsubscriptionError(errors);
3104
- }
3105
- }
3106
- }
3107
- add(teardown) {
3108
- var _a;
3109
- if (teardown && teardown !== this) {
3110
- if (this.closed) {
3111
- execFinalizer(teardown);
3112
- }
3113
- else {
3114
- if (teardown instanceof Subscription) {
3115
- if (teardown.closed || teardown._hasParent(this)) {
3116
- return;
3117
- }
3118
- teardown._addParent(this);
3119
- }
3120
- (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
3121
- }
3122
- }
3123
- }
3124
- _hasParent(parent) {
3125
- const { _parentage } = this;
3126
- return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
3127
- }
3128
- _addParent(parent) {
3129
- const { _parentage } = this;
3130
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
3131
- }
3132
- _removeParent(parent) {
3133
- const { _parentage } = this;
3134
- if (_parentage === parent) {
3135
- this._parentage = null;
3136
- }
3137
- else if (Array.isArray(_parentage)) {
3138
- arrRemove(_parentage, parent);
3139
- }
3140
- }
3141
- remove(teardown) {
3142
- const { _finalizers } = this;
3143
- _finalizers && arrRemove(_finalizers, teardown);
3144
- if (teardown instanceof Subscription) {
3145
- teardown._removeParent(this);
3146
- }
3147
- }
3148
- }
3149
- Subscription.EMPTY = (() => {
3150
- const empty = new Subscription();
3151
- empty.closed = true;
3152
- return empty;
3153
- })();
3154
- const EMPTY_SUBSCRIPTION = Subscription.EMPTY;
3155
- function isSubscription(value) {
3156
- return (value instanceof Subscription ||
3157
- (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
3158
- }
3159
- function execFinalizer(finalizer) {
3160
- if (isFunction(finalizer)) {
3161
- finalizer();
3162
- }
3163
- else {
3164
- finalizer.unsubscribe();
3165
- }
3166
- }
3167
-
3168
- const config = {
3169
- onUnhandledError: null,
3170
- onStoppedNotification: null,
3171
- Promise: undefined,
3172
- useDeprecatedSynchronousErrorHandling: false,
3173
- useDeprecatedNextContext: false,
3174
- };
3175
-
3176
- const timeoutProvider = {
3177
- setTimeout(handler, timeout, ...args) {
3178
- const { delegate } = timeoutProvider;
3179
- if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
3180
- return delegate.setTimeout(handler, timeout, ...args);
3181
- }
3182
- return setTimeout(handler, timeout, ...args);
3183
- },
3184
- clearTimeout(handle) {
3185
- const { delegate } = timeoutProvider;
3186
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
3187
- },
3188
- delegate: undefined,
3189
- };
3190
-
3191
- function reportUnhandledError(err) {
3192
- timeoutProvider.setTimeout(() => {
3193
- const { onUnhandledError } = config;
3194
- if (onUnhandledError) {
3195
- onUnhandledError(err);
3196
- }
3197
- else {
3198
- throw err;
3199
- }
3200
- });
3201
- }
3202
-
3203
- function noop() { }
3204
-
3205
- const COMPLETE_NOTIFICATION = (() => createNotification('C', undefined, undefined))();
3206
- function errorNotification(error) {
3207
- return createNotification('E', undefined, error);
3208
- }
3209
- function nextNotification(value) {
3210
- return createNotification('N', value, undefined);
3211
- }
3212
- function createNotification(kind, value, error) {
3213
- return {
3214
- kind,
3215
- value,
3216
- error,
3217
- };
3218
- }
3219
-
3220
- function errorContext(cb) {
3221
- {
3222
- cb();
3223
- }
3224
- }
3225
-
3226
- class Subscriber extends Subscription {
3227
- constructor(destination) {
3228
- super();
3229
- this.isStopped = false;
3230
- if (destination) {
3231
- this.destination = destination;
3232
- if (isSubscription(destination)) {
3233
- destination.add(this);
3234
- }
3235
- }
3236
- else {
3237
- this.destination = EMPTY_OBSERVER;
3238
- }
3239
- }
3240
- static create(next, error, complete) {
3241
- return new SafeSubscriber(next, error, complete);
3242
- }
3243
- next(value) {
3244
- if (this.isStopped) {
3245
- handleStoppedNotification(nextNotification(value), this);
3246
- }
3247
- else {
3248
- this._next(value);
3249
- }
3250
- }
3251
- error(err) {
3252
- if (this.isStopped) {
3253
- handleStoppedNotification(errorNotification(err), this);
3254
- }
3255
- else {
3256
- this.isStopped = true;
3257
- this._error(err);
3258
- }
3259
- }
3260
- complete() {
3261
- if (this.isStopped) {
3262
- handleStoppedNotification(COMPLETE_NOTIFICATION, this);
3263
- }
3264
- else {
3265
- this.isStopped = true;
3266
- this._complete();
3267
- }
3268
- }
3269
- unsubscribe() {
3270
- if (!this.closed) {
3271
- this.isStopped = true;
3272
- super.unsubscribe();
3273
- this.destination = null;
3274
- }
3275
- }
3276
- _next(value) {
3277
- this.destination.next(value);
3278
- }
3279
- _error(err) {
3280
- try {
3281
- this.destination.error(err);
3282
- }
3283
- finally {
3284
- this.unsubscribe();
3285
- }
3286
- }
3287
- _complete() {
3288
- try {
3289
- this.destination.complete();
3290
- }
3291
- finally {
3292
- this.unsubscribe();
3293
- }
3294
- }
3295
- }
3296
- const _bind = Function.prototype.bind;
3297
- function bind(fn, thisArg) {
3298
- return _bind.call(fn, thisArg);
3299
- }
3300
- class ConsumerObserver {
3301
- constructor(partialObserver) {
3302
- this.partialObserver = partialObserver;
3303
- }
3304
- next(value) {
3305
- const { partialObserver } = this;
3306
- if (partialObserver.next) {
3307
- try {
3308
- partialObserver.next(value);
3309
- }
3310
- catch (error) {
3311
- handleUnhandledError(error);
3312
- }
3313
- }
3314
- }
3315
- error(err) {
3316
- const { partialObserver } = this;
3317
- if (partialObserver.error) {
3318
- try {
3319
- partialObserver.error(err);
3320
- }
3321
- catch (error) {
3322
- handleUnhandledError(error);
3323
- }
3324
- }
3325
- else {
3326
- handleUnhandledError(err);
3327
- }
3328
- }
3329
- complete() {
3330
- const { partialObserver } = this;
3331
- if (partialObserver.complete) {
3332
- try {
3333
- partialObserver.complete();
3334
- }
3335
- catch (error) {
3336
- handleUnhandledError(error);
3337
- }
3338
- }
3339
- }
3340
- }
3341
- class SafeSubscriber extends Subscriber {
3342
- constructor(observerOrNext, error, complete) {
3343
- super();
3344
- let partialObserver;
3345
- if (isFunction(observerOrNext) || !observerOrNext) {
3346
- partialObserver = {
3347
- next: observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined,
3348
- error: error !== null && error !== void 0 ? error : undefined,
3349
- complete: complete !== null && complete !== void 0 ? complete : undefined,
3350
- };
3351
- }
3352
- else {
3353
- let context;
3354
- if (this && config.useDeprecatedNextContext) {
3355
- context = Object.create(observerOrNext);
3356
- context.unsubscribe = () => this.unsubscribe();
3357
- partialObserver = {
3358
- next: observerOrNext.next && bind(observerOrNext.next, context),
3359
- error: observerOrNext.error && bind(observerOrNext.error, context),
3360
- complete: observerOrNext.complete && bind(observerOrNext.complete, context),
3361
- };
3362
- }
3363
- else {
3364
- partialObserver = observerOrNext;
3365
- }
3366
- }
3367
- this.destination = new ConsumerObserver(partialObserver);
3368
- }
3369
- }
3370
- function handleUnhandledError(error) {
3371
- {
3372
- reportUnhandledError(error);
3373
- }
3374
- }
3375
- function defaultErrorHandler(err) {
3376
- throw err;
3377
- }
3378
- function handleStoppedNotification(notification, subscriber) {
3379
- const { onStoppedNotification } = config;
3380
- onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
3381
- }
3382
- const EMPTY_OBSERVER = {
3383
- closed: true,
3384
- next: noop,
3385
- error: defaultErrorHandler,
3386
- complete: noop,
3387
- };
3388
-
3389
- const observable = (() => (typeof Symbol === 'function' && Symbol.observable) || '@@observable')();
3390
-
3391
- function identity(x) {
3392
- return x;
3393
- }
3394
-
3395
- function pipeFromArray(fns) {
3396
- if (fns.length === 0) {
3397
- return identity;
3398
- }
3399
- if (fns.length === 1) {
3400
- return fns[0];
3401
- }
3402
- return function piped(input) {
3403
- return fns.reduce((prev, fn) => fn(prev), input);
3404
- };
3405
- }
3406
-
3407
- class Observable {
3408
- constructor(subscribe) {
3409
- if (subscribe) {
3410
- this._subscribe = subscribe;
3411
- }
3412
- }
3413
- lift(operator) {
3414
- const observable = new Observable();
3415
- observable.source = this;
3416
- observable.operator = operator;
3417
- return observable;
3418
- }
3419
- subscribe(observerOrNext, error, complete) {
3420
- const subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
3421
- errorContext(() => {
3422
- const { operator, source } = this;
3423
- subscriber.add(operator
3424
- ?
3425
- operator.call(subscriber, source)
3426
- : source
3427
- ?
3428
- this._subscribe(subscriber)
3429
- :
3430
- this._trySubscribe(subscriber));
3431
- });
3432
- return subscriber;
3433
- }
3434
- _trySubscribe(sink) {
3435
- try {
3436
- return this._subscribe(sink);
3437
- }
3438
- catch (err) {
3439
- sink.error(err);
3440
- }
3441
- }
3442
- forEach(next, promiseCtor) {
3443
- promiseCtor = getPromiseCtor(promiseCtor);
3444
- return new promiseCtor((resolve, reject) => {
3445
- const subscriber = new SafeSubscriber({
3446
- next: (value) => {
3447
- try {
3448
- next(value);
3449
- }
3450
- catch (err) {
3451
- reject(err);
3452
- subscriber.unsubscribe();
3453
- }
3454
- },
3455
- error: reject,
3456
- complete: resolve,
3457
- });
3458
- this.subscribe(subscriber);
3459
- });
3460
- }
3461
- _subscribe(subscriber) {
3462
- var _a;
3463
- return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
3464
- }
3465
- [observable]() {
3466
- return this;
3467
- }
3468
- pipe(...operations) {
3469
- return pipeFromArray(operations)(this);
3470
- }
3471
- toPromise(promiseCtor) {
3472
- promiseCtor = getPromiseCtor(promiseCtor);
3473
- return new promiseCtor((resolve, reject) => {
3474
- let value;
3475
- this.subscribe((x) => (value = x), (err) => reject(err), () => resolve(value));
3476
- });
3477
- }
3478
- }
3479
- Observable.create = (subscribe) => {
3480
- return new Observable(subscribe);
3481
- };
3482
- function getPromiseCtor(promiseCtor) {
3483
- var _a;
3484
- return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
3485
- }
3486
- function isObserver(value) {
3487
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
3488
- }
3489
- function isSubscriber(value) {
3490
- return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
3491
- }
3492
-
3493
- function hasLift(source) {
3494
- return isFunction(source === null || source === void 0 ? void 0 : source.lift);
3495
- }
3496
- function operate(init) {
3497
- return (source) => {
3498
- if (hasLift(source)) {
3499
- return source.lift(function (liftedSource) {
3500
- try {
3501
- return init(liftedSource, this);
3502
- }
3503
- catch (err) {
3504
- this.error(err);
3505
- }
3506
- });
3507
- }
3508
- throw new TypeError('Unable to lift unknown Observable type');
3509
- };
3510
- }
3511
-
3512
- function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
3513
- return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
3514
- }
3515
- class OperatorSubscriber extends Subscriber {
3516
- constructor(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
3517
- super(destination);
3518
- this.onFinalize = onFinalize;
3519
- this.shouldUnsubscribe = shouldUnsubscribe;
3520
- this._next = onNext
3521
- ? function (value) {
3522
- try {
3523
- onNext(value);
3524
- }
3525
- catch (err) {
3526
- destination.error(err);
3527
- }
3528
- }
3529
- : super._next;
3530
- this._error = onError
3531
- ? function (err) {
3532
- try {
3533
- onError(err);
3534
- }
3535
- catch (err) {
3536
- destination.error(err);
3537
- }
3538
- finally {
3539
- this.unsubscribe();
3540
- }
3541
- }
3542
- : super._error;
3543
- this._complete = onComplete
3544
- ? function () {
3545
- try {
3546
- onComplete();
3547
- }
3548
- catch (err) {
3549
- destination.error(err);
3550
- }
3551
- finally {
3552
- this.unsubscribe();
3553
- }
3554
- }
3555
- : super._complete;
3556
- }
3557
- unsubscribe() {
3558
- var _a;
3559
- if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
3560
- const { closed } = this;
3561
- super.unsubscribe();
3562
- !closed && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
3563
- }
3564
- }
3565
- }
3566
-
3567
- const ObjectUnsubscribedError = createErrorClass((_super) => function ObjectUnsubscribedErrorImpl() {
3568
- _super(this);
3569
- this.name = 'ObjectUnsubscribedError';
3570
- this.message = 'object unsubscribed';
3571
- });
3572
-
3573
- class Subject extends Observable {
3574
- constructor() {
3575
- super();
3576
- this.closed = false;
3577
- this.currentObservers = null;
3578
- this.observers = [];
3579
- this.isStopped = false;
3580
- this.hasError = false;
3581
- this.thrownError = null;
3582
- }
3583
- lift(operator) {
3584
- const subject = new AnonymousSubject(this, this);
3585
- subject.operator = operator;
3586
- return subject;
3587
- }
3588
- _throwIfClosed() {
3589
- if (this.closed) {
3590
- throw new ObjectUnsubscribedError();
3591
- }
3592
- }
3593
- next(value) {
3594
- errorContext(() => {
3595
- this._throwIfClosed();
3596
- if (!this.isStopped) {
3597
- if (!this.currentObservers) {
3598
- this.currentObservers = Array.from(this.observers);
3599
- }
3600
- for (const observer of this.currentObservers) {
3601
- observer.next(value);
3602
- }
3603
- }
3604
- });
3605
- }
3606
- error(err) {
3607
- errorContext(() => {
3608
- this._throwIfClosed();
3609
- if (!this.isStopped) {
3610
- this.hasError = this.isStopped = true;
3611
- this.thrownError = err;
3612
- const { observers } = this;
3613
- while (observers.length) {
3614
- observers.shift().error(err);
3615
- }
3616
- }
3617
- });
3618
- }
3619
- complete() {
3620
- errorContext(() => {
3621
- this._throwIfClosed();
3622
- if (!this.isStopped) {
3623
- this.isStopped = true;
3624
- const { observers } = this;
3625
- while (observers.length) {
3626
- observers.shift().complete();
3627
- }
3628
- }
3629
- });
3630
- }
3631
- unsubscribe() {
3632
- this.isStopped = this.closed = true;
3633
- this.observers = this.currentObservers = null;
3634
- }
3635
- get observed() {
3636
- var _a;
3637
- return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
3638
- }
3639
- _trySubscribe(subscriber) {
3640
- this._throwIfClosed();
3641
- return super._trySubscribe(subscriber);
3642
- }
3643
- _subscribe(subscriber) {
3644
- this._throwIfClosed();
3645
- this._checkFinalizedStatuses(subscriber);
3646
- return this._innerSubscribe(subscriber);
3647
- }
3648
- _innerSubscribe(subscriber) {
3649
- const { hasError, isStopped, observers } = this;
3650
- if (hasError || isStopped) {
3651
- return EMPTY_SUBSCRIPTION;
3652
- }
3653
- this.currentObservers = null;
3654
- observers.push(subscriber);
3655
- return new Subscription(() => {
3656
- this.currentObservers = null;
3657
- arrRemove(observers, subscriber);
3658
- });
3659
- }
3660
- _checkFinalizedStatuses(subscriber) {
3661
- const { hasError, thrownError, isStopped } = this;
3662
- if (hasError) {
3663
- subscriber.error(thrownError);
3664
- }
3665
- else if (isStopped) {
3666
- subscriber.complete();
3667
- }
3668
- }
3669
- asObservable() {
3670
- const observable = new Observable();
3671
- observable.source = this;
3672
- return observable;
3673
- }
3674
- }
3675
- Subject.create = (destination, source) => {
3676
- return new AnonymousSubject(destination, source);
3677
- };
3678
- class AnonymousSubject extends Subject {
3679
- constructor(destination, source) {
3680
- super();
3681
- this.destination = destination;
3682
- this.source = source;
3683
- }
3684
- next(value) {
3685
- var _a, _b;
3686
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
3687
- }
3688
- error(err) {
3689
- var _a, _b;
3690
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
3691
- }
3692
- complete() {
3693
- var _a, _b;
3694
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
3695
- }
3696
- _subscribe(subscriber) {
3697
- var _a, _b;
3698
- return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
3699
- }
3700
- }
3701
-
3702
- const EMPTY = new Observable((subscriber) => subscriber.complete());
3703
-
3704
- function isScheduler(value) {
3705
- return value && isFunction(value.schedule);
3706
- }
3707
-
3708
- function last(arr) {
3709
- return arr[arr.length - 1];
3710
- }
3711
- function popScheduler(args) {
3712
- return isScheduler(last(args)) ? args.pop() : undefined;
3713
- }
3714
- function popNumber(args, defaultValue) {
3715
- return typeof last(args) === 'number' ? args.pop() : defaultValue;
3716
- }
3717
-
3718
- /******************************************************************************
3719
- Copyright (c) Microsoft Corporation.
3720
-
3721
- Permission to use, copy, modify, and/or distribute this software for any
3722
- purpose with or without fee is hereby granted.
3723
-
3724
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
3725
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
3726
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
3727
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
3728
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
3729
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
3730
- PERFORMANCE OF THIS SOFTWARE.
3731
- ***************************************************************************** */
3732
-
3733
- function __awaiter(thisArg, _arguments, P, generator) {
3734
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3735
- return new (P || (P = Promise))(function (resolve, reject) {
3736
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3737
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3738
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3739
- step((generator = generator.apply(thisArg, _arguments || [])).next());
3740
- });
3741
- }
3742
-
3743
- function __values(o) {
3744
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3745
- if (m) return m.call(o);
3746
- if (o && typeof o.length === "number") return {
3747
- next: function () {
3748
- if (o && i >= o.length) o = void 0;
3749
- return { value: o && o[i++], done: !o };
3750
- }
3751
- };
3752
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
3753
- }
3754
-
3755
- function __await(v) {
3756
- return this instanceof __await ? (this.v = v, this) : new __await(v);
3757
- }
3758
-
3759
- function __asyncGenerator(thisArg, _arguments, generator) {
3760
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3761
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
3762
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
3763
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
3764
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
3765
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
3766
- function fulfill(value) { resume("next", value); }
3767
- function reject(value) { resume("throw", value); }
3768
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
3769
- }
3770
-
3771
- function __asyncValues(o) {
3772
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3773
- var m = o[Symbol.asyncIterator], i;
3774
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
3775
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
3776
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
3777
- }
3778
-
3779
- const isArrayLike = ((x) => x && typeof x.length === 'number' && typeof x !== 'function');
3780
-
3781
- function isPromise(value) {
3782
- return isFunction(value === null || value === void 0 ? void 0 : value.then);
3783
- }
3784
-
3785
- function isInteropObservable(input) {
3786
- return isFunction(input[observable]);
3787
- }
3788
-
3789
- function isAsyncIterable(obj) {
3790
- return Symbol.asyncIterator && isFunction(obj === null || obj === void 0 ? void 0 : obj[Symbol.asyncIterator]);
3791
- }
3792
-
3793
- function createInvalidObservableTypeError(input) {
3794
- return new TypeError(`You provided ${input !== null && typeof input === 'object' ? 'an invalid object' : `'${input}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`);
3795
- }
3796
-
3797
- function getSymbolIterator() {
3798
- if (typeof Symbol !== 'function' || !Symbol.iterator) {
3799
- return '@@iterator';
3800
- }
3801
- return Symbol.iterator;
3802
- }
3803
- const iterator = getSymbolIterator();
3804
-
3805
- function isIterable(input) {
3806
- return isFunction(input === null || input === void 0 ? void 0 : input[iterator]);
3807
- }
3808
-
3809
- function readableStreamLikeToAsyncGenerator(readableStream) {
3810
- return __asyncGenerator(this, arguments, function* readableStreamLikeToAsyncGenerator_1() {
3811
- const reader = readableStream.getReader();
3812
- try {
3813
- while (true) {
3814
- const { value, done } = yield __await(reader.read());
3815
- if (done) {
3816
- return yield __await(void 0);
3817
- }
3818
- yield yield __await(value);
3819
- }
3820
- }
3821
- finally {
3822
- reader.releaseLock();
3823
- }
3824
- });
3825
- }
3826
- function isReadableStreamLike(obj) {
3827
- return isFunction(obj === null || obj === void 0 ? void 0 : obj.getReader);
3828
- }
3829
-
3830
- function innerFrom(input) {
3831
- if (input instanceof Observable) {
3832
- return input;
3833
- }
3834
- if (input != null) {
3835
- if (isInteropObservable(input)) {
3836
- return fromInteropObservable(input);
3837
- }
3838
- if (isArrayLike(input)) {
3839
- return fromArrayLike(input);
3840
- }
3841
- if (isPromise(input)) {
3842
- return fromPromise(input);
3843
- }
3844
- if (isAsyncIterable(input)) {
3845
- return fromAsyncIterable(input);
3846
- }
3847
- if (isIterable(input)) {
3848
- return fromIterable(input);
3849
- }
3850
- if (isReadableStreamLike(input)) {
3851
- return fromReadableStreamLike(input);
3852
- }
3853
- }
3854
- throw createInvalidObservableTypeError(input);
3855
- }
3856
- function fromInteropObservable(obj) {
3857
- return new Observable((subscriber) => {
3858
- const obs = obj[observable]();
3859
- if (isFunction(obs.subscribe)) {
3860
- return obs.subscribe(subscriber);
3861
- }
3862
- throw new TypeError('Provided object does not correctly implement Symbol.observable');
3863
- });
3864
- }
3865
- function fromArrayLike(array) {
3866
- return new Observable((subscriber) => {
3867
- for (let i = 0; i < array.length && !subscriber.closed; i++) {
3868
- subscriber.next(array[i]);
3869
- }
3870
- subscriber.complete();
3871
- });
3872
- }
3873
- function fromPromise(promise) {
3874
- return new Observable((subscriber) => {
3875
- promise
3876
- .then((value) => {
3877
- if (!subscriber.closed) {
3878
- subscriber.next(value);
3879
- subscriber.complete();
3880
- }
3881
- }, (err) => subscriber.error(err))
3882
- .then(null, reportUnhandledError);
3883
- });
3884
- }
3885
- function fromIterable(iterable) {
3886
- return new Observable((subscriber) => {
3887
- for (const value of iterable) {
3888
- subscriber.next(value);
3889
- if (subscriber.closed) {
3890
- return;
3891
- }
3892
- }
3893
- subscriber.complete();
3894
- });
3895
- }
3896
- function fromAsyncIterable(asyncIterable) {
3897
- return new Observable((subscriber) => {
3898
- process(asyncIterable, subscriber).catch((err) => subscriber.error(err));
3899
- });
3900
- }
3901
- function fromReadableStreamLike(readableStream) {
3902
- return fromAsyncIterable(readableStreamLikeToAsyncGenerator(readableStream));
3903
- }
3904
- function process(asyncIterable, subscriber) {
3905
- var asyncIterable_1, asyncIterable_1_1;
3906
- var e_1, _a;
3907
- return __awaiter(this, void 0, void 0, function* () {
3908
- try {
3909
- for (asyncIterable_1 = __asyncValues(asyncIterable); asyncIterable_1_1 = yield asyncIterable_1.next(), !asyncIterable_1_1.done;) {
3910
- const value = asyncIterable_1_1.value;
3911
- subscriber.next(value);
3912
- if (subscriber.closed) {
3913
- return;
3914
- }
3915
- }
3916
- }
3917
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3918
- finally {
3919
- try {
3920
- if (asyncIterable_1_1 && !asyncIterable_1_1.done && (_a = asyncIterable_1.return)) yield _a.call(asyncIterable_1);
3921
- }
3922
- finally { if (e_1) throw e_1.error; }
3923
- }
3924
- subscriber.complete();
3925
- });
3926
- }
3927
-
3928
- function executeSchedule(parentSubscription, scheduler, work, delay = 0, repeat = false) {
3929
- const scheduleSubscription = scheduler.schedule(function () {
3930
- work();
3931
- if (repeat) {
3932
- parentSubscription.add(this.schedule(null, delay));
3933
- }
3934
- else {
3935
- this.unsubscribe();
3936
- }
3937
- }, delay);
3938
- parentSubscription.add(scheduleSubscription);
3939
- if (!repeat) {
3940
- return scheduleSubscription;
3941
- }
3942
- }
3943
-
3944
- function observeOn(scheduler, delay = 0) {
3945
- return operate((source, subscriber) => {
3946
- source.subscribe(createOperatorSubscriber(subscriber, (value) => executeSchedule(subscriber, scheduler, () => subscriber.next(value), delay), () => executeSchedule(subscriber, scheduler, () => subscriber.complete(), delay), (err) => executeSchedule(subscriber, scheduler, () => subscriber.error(err), delay)));
3947
- });
3948
- }
3949
-
3950
- function subscribeOn(scheduler, delay = 0) {
3951
- return operate((source, subscriber) => {
3952
- subscriber.add(scheduler.schedule(() => source.subscribe(subscriber), delay));
3953
- });
3954
- }
3955
-
3956
- function scheduleObservable(input, scheduler) {
3957
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
3958
- }
3959
-
3960
- function schedulePromise(input, scheduler) {
3961
- return innerFrom(input).pipe(subscribeOn(scheduler), observeOn(scheduler));
3962
- }
3963
-
3964
- function scheduleArray(input, scheduler) {
3965
- return new Observable((subscriber) => {
3966
- let i = 0;
3967
- return scheduler.schedule(function () {
3968
- if (i === input.length) {
3969
- subscriber.complete();
3970
- }
3971
- else {
3972
- subscriber.next(input[i++]);
3973
- if (!subscriber.closed) {
3974
- this.schedule();
3975
- }
3976
- }
3977
- });
3978
- });
3979
- }
3980
-
3981
- function scheduleIterable(input, scheduler) {
3982
- return new Observable((subscriber) => {
3983
- let iterator$1;
3984
- executeSchedule(subscriber, scheduler, () => {
3985
- iterator$1 = input[iterator]();
3986
- executeSchedule(subscriber, scheduler, () => {
3987
- let value;
3988
- let done;
3989
- try {
3990
- ({ value, done } = iterator$1.next());
3991
- }
3992
- catch (err) {
3993
- subscriber.error(err);
3994
- return;
3995
- }
3996
- if (done) {
3997
- subscriber.complete();
3998
- }
3999
- else {
4000
- subscriber.next(value);
4001
- }
4002
- }, 0, true);
4003
- });
4004
- return () => isFunction(iterator$1 === null || iterator$1 === void 0 ? void 0 : iterator$1.return) && iterator$1.return();
4005
- });
4006
- }
4007
-
4008
- function scheduleAsyncIterable(input, scheduler) {
4009
- if (!input) {
4010
- throw new Error('Iterable cannot be null');
4011
- }
4012
- return new Observable((subscriber) => {
4013
- executeSchedule(subscriber, scheduler, () => {
4014
- const iterator = input[Symbol.asyncIterator]();
4015
- executeSchedule(subscriber, scheduler, () => {
4016
- iterator.next().then((result) => {
4017
- if (result.done) {
4018
- subscriber.complete();
4019
- }
4020
- else {
4021
- subscriber.next(result.value);
4022
- }
4023
- });
4024
- }, 0, true);
4025
- });
4026
- });
4027
- }
4028
-
4029
- function scheduleReadableStreamLike(input, scheduler) {
4030
- return scheduleAsyncIterable(readableStreamLikeToAsyncGenerator(input), scheduler);
4031
- }
4032
-
4033
- function scheduled(input, scheduler) {
4034
- if (input != null) {
4035
- if (isInteropObservable(input)) {
4036
- return scheduleObservable(input, scheduler);
4037
- }
4038
- if (isArrayLike(input)) {
4039
- return scheduleArray(input, scheduler);
4040
- }
4041
- if (isPromise(input)) {
4042
- return schedulePromise(input, scheduler);
4043
- }
4044
- if (isAsyncIterable(input)) {
4045
- return scheduleAsyncIterable(input, scheduler);
4046
- }
4047
- if (isIterable(input)) {
4048
- return scheduleIterable(input, scheduler);
4049
- }
4050
- if (isReadableStreamLike(input)) {
4051
- return scheduleReadableStreamLike(input, scheduler);
4052
- }
4053
- }
4054
- throw createInvalidObservableTypeError(input);
4055
- }
4056
-
4057
- function from(input, scheduler) {
4058
- return scheduler ? scheduled(input, scheduler) : innerFrom(input);
4059
- }
4060
-
4061
- function map(project, thisArg) {
4062
- return operate((source, subscriber) => {
4063
- let index = 0;
4064
- source.subscribe(createOperatorSubscriber(subscriber, (value) => {
4065
- subscriber.next(project.call(thisArg, value, index++));
4066
- }));
4067
- });
4068
- }
4069
-
4070
- const { isArray } = Array;
4071
- function callOrApply(fn, args) {
4072
- return isArray(args) ? fn(...args) : fn(args);
4073
- }
4074
- function mapOneOrManyArgs(fn) {
4075
- return map(args => callOrApply(fn, args));
4076
- }
4077
-
4078
- function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
4079
- const buffer = [];
4080
- let active = 0;
4081
- let index = 0;
4082
- let isComplete = false;
4083
- const checkComplete = () => {
4084
- if (isComplete && !buffer.length && !active) {
4085
- subscriber.complete();
4086
- }
4087
- };
4088
- const outerNext = (value) => (active < concurrent ? doInnerSub(value) : buffer.push(value));
4089
- const doInnerSub = (value) => {
4090
- expand && subscriber.next(value);
4091
- active++;
4092
- let innerComplete = false;
4093
- innerFrom(project(value, index++)).subscribe(createOperatorSubscriber(subscriber, (innerValue) => {
4094
- onBeforeNext === null || onBeforeNext === void 0 ? void 0 : onBeforeNext(innerValue);
4095
- if (expand) {
4096
- outerNext(innerValue);
4097
- }
4098
- else {
4099
- subscriber.next(innerValue);
4100
- }
4101
- }, () => {
4102
- innerComplete = true;
4103
- }, undefined, () => {
4104
- if (innerComplete) {
4105
- try {
4106
- active--;
4107
- while (buffer.length && active < concurrent) {
4108
- const bufferedValue = buffer.shift();
4109
- if (innerSubScheduler) {
4110
- executeSchedule(subscriber, innerSubScheduler, () => doInnerSub(bufferedValue));
4111
- }
4112
- else {
4113
- doInnerSub(bufferedValue);
4114
- }
4115
- }
4116
- checkComplete();
4117
- }
4118
- catch (err) {
4119
- subscriber.error(err);
4120
- }
4121
- }
4122
- }));
4123
- };
4124
- source.subscribe(createOperatorSubscriber(subscriber, outerNext, () => {
4125
- isComplete = true;
4126
- checkComplete();
4127
- }));
4128
- return () => {
4129
- additionalFinalizer === null || additionalFinalizer === void 0 ? void 0 : additionalFinalizer();
4130
- };
4131
- }
4132
-
4133
- function mergeMap(project, resultSelector, concurrent = Infinity) {
4134
- if (isFunction(resultSelector)) {
4135
- return mergeMap((a, i) => map((b, ii) => resultSelector(a, b, i, ii))(innerFrom(project(a, i))), concurrent);
4136
- }
4137
- else if (typeof resultSelector === 'number') {
4138
- concurrent = resultSelector;
4139
- }
4140
- return operate((source, subscriber) => mergeInternals(source, subscriber, project, concurrent));
4141
- }
4142
-
4143
- function mergeAll(concurrent = Infinity) {
4144
- return mergeMap(identity, concurrent);
4145
- }
4146
-
4147
- const nodeEventEmitterMethods = ['addListener', 'removeListener'];
4148
- const eventTargetMethods = ['addEventListener', 'removeEventListener'];
4149
- const jqueryMethods = ['on', 'off'];
4150
- function fromEvent(target, eventName, options, resultSelector) {
4151
- if (isFunction(options)) {
4152
- resultSelector = options;
4153
- options = undefined;
4154
- }
4155
- if (resultSelector) {
4156
- return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
4157
- }
4158
- const [add, remove] = isEventTarget(target)
4159
- ? eventTargetMethods.map((methodName) => (handler) => target[methodName](eventName, handler, options))
4160
- :
4161
- isNodeStyleEventEmitter(target)
4162
- ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName))
4163
- : isJQueryStyleEventEmitter(target)
4164
- ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName))
4165
- : [];
4166
- if (!add) {
4167
- if (isArrayLike(target)) {
4168
- return mergeMap((subTarget) => fromEvent(subTarget, eventName, options))(innerFrom(target));
4169
- }
4170
- }
4171
- if (!add) {
4172
- throw new TypeError('Invalid event target');
4173
- }
4174
- return new Observable((subscriber) => {
4175
- const handler = (...args) => subscriber.next(1 < args.length ? args : args[0]);
4176
- add(handler);
4177
- return () => remove(handler);
4178
- });
4179
- }
4180
- function toCommonHandlerRegistry(target, eventName) {
4181
- return (methodName) => (handler) => target[methodName](eventName, handler);
4182
- }
4183
- function isNodeStyleEventEmitter(target) {
4184
- return isFunction(target.addListener) && isFunction(target.removeListener);
4185
- }
4186
- function isJQueryStyleEventEmitter(target) {
4187
- return isFunction(target.on) && isFunction(target.off);
4188
- }
4189
- function isEventTarget(target) {
4190
- return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
4191
- }
4192
-
4193
- function merge(...args) {
4194
- const scheduler = popScheduler(args);
4195
- const concurrent = popNumber(args, Infinity);
4196
- const sources = args;
4197
- return !sources.length
4198
- ?
4199
- EMPTY
4200
- : sources.length === 1
4201
- ?
4202
- innerFrom(sources[0])
4203
- :
4204
- mergeAll(concurrent)(from(sources, scheduler));
4205
- }
4206
-
4207
- function filter(predicate, thisArg) {
4208
- return operate((source, subscriber) => {
4209
- let index = 0;
4210
- source.subscribe(createOperatorSubscriber(subscriber, (value) => predicate.call(thisArg, value, index++) && subscriber.next(value)));
4211
- });
4212
- }
4213
-
4214
- function distinctUntilChanged(comparator, keySelector = identity) {
4215
- comparator = comparator !== null && comparator !== void 0 ? comparator : defaultCompare;
4216
- return operate((source, subscriber) => {
4217
- let previousKey;
4218
- let first = true;
4219
- source.subscribe(createOperatorSubscriber(subscriber, (value) => {
4220
- const currentKey = keySelector(value);
4221
- if (first || !comparator(previousKey, currentKey)) {
4222
- first = false;
4223
- previousKey = currentKey;
4224
- subscriber.next(value);
4225
- }
4226
- }));
4227
- });
4228
- }
4229
- function defaultCompare(a, b) {
4230
- return a === b;
4231
- }
4232
-
4233
- function takeUntil(notifier) {
4234
- return operate((source, subscriber) => {
4235
- innerFrom(notifier).subscribe(createOperatorSubscriber(subscriber, () => subscriber.complete(), noop));
4236
- !subscriber.closed && source.subscribe(subscriber);
4237
- });
4238
- }
4239
-
4240
- const catScrollableCss = ":host{overflow:hidden;position:relative;display:flex}:host([hidden]){display:none}.shadow-bottom,.shadow-right,.shadow-left,.shadow-top{position:absolute;transition:box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1)}.shadow-top{z-index:2;width:100%;top:0}.shadow-left{z-index:4;height:100%;left:0}.shadow-right{z-index:4;height:100%;right:0}.shadow-bottom{z-index:2;width:100%;bottom:0}.scrollable-wrapper{position:absolute;top:0;left:0;right:0;bottom:0;pointer-events:none}.scrollable-wrapper.cat-scrollable-top .shadow-top,.scrollable-wrapper.cat-scrollable-bottom .shadow-bottom,.scrollable-wrapper.cat-scrollable-left .shadow-left,.scrollable-wrapper.cat-scrollable-right .shadow-right{box-shadow:0 0 4px 1px rgba(16, 29, 48, 0.2)}.scrollable-content{overflow:hidden;white-space:nowrap}.scrollable-content.scroll-x{overflow-x:auto}.scrollable-content.scroll-y{overflow-y:auto}.scrollable-content.no-overscroll{overscroll-behavior:contain}";
4241
-
4242
- const CatScrollable = class {
4243
- constructor(hostRef) {
4244
- registerInstance(this, hostRef);
4245
- this.scrolledTop = createEvent(this, "scrolledTop", 7);
4246
- this.scrolledLeft = createEvent(this, "scrolledLeft", 7);
4247
- this.scrolledRight = createEvent(this, "scrolledRight", 7);
4248
- this.scrolledBottom = createEvent(this, "scrolledBottom", 7);
4249
- this.init = new Subject();
4250
- this.destroyed = new Subject();
4251
- /** Flags to enable/disable scroll shadowX. */
4252
- this.shadowX = true;
4253
- /** Flags to enable/disable scroll shadowY. */
4254
- this.shadowY = true;
4255
- /** Flags to enable/disable overflowX. */
4256
- this.overflowX = true;
4257
- /** Flags to enable/disable overflowY. */
4258
- this.overflowY = true;
4259
- /** Flag to enable/disable overscroll behavior. */
4260
- this.overscroll = true;
4261
- /**
4262
- * Flag to fire an initial event after content initialization.
4263
- */
4264
- this.scrolledInit = true;
4265
- /**
4266
- * Buffer to be used to calculate the scroll distance.
4267
- */
4268
- this.scrolledBuffer = 0;
4269
- }
4270
- componentDidRender() {
4271
- if (this.scrollElement) {
4272
- this.scrolled = fromEvent(this.scrollElement, 'scroll').pipe(takeUntil(this.destroyed));
4273
- }
4274
- this.attachEmitter('left', this.scrolledLeft, this.scrolledBuffer);
4275
- this.attachEmitter('right', this.scrolledRight, this.scrolledBuffer);
4276
- this.attachEmitter('bottom', this.scrolledBottom, this.scrolledBuffer);
4277
- this.attachEmitter('top', this.scrolledTop, this.scrolledBuffer);
4278
- merge(this.init, this.scrolled)
4279
- .pipe(map(() => ({
4280
- top: this.getScrollOffset('top') > 0,
4281
- left: this.getScrollOffset('left') > 0,
4282
- right: this.getScrollOffset('right') > 0,
4283
- bottom: this.getScrollOffset('bottom') > 0
4284
- })), distinctUntilChanged(), takeUntil(this.destroyed))
4285
- .subscribe(({ top, left, right, bottom }) => {
4286
- this.toggleClass('cat-scrollable-top', top);
4287
- this.toggleClass('cat-scrollable-left', left);
4288
- this.toggleClass('cat-scrollable-right', right);
4289
- this.toggleClass('cat-scrollable-bottom', bottom);
4290
- });
4291
- }
4292
- componentDidLoad() {
4293
- if (this.scrolledInit) {
4294
- this.init.next();
4295
- }
4296
- }
4297
- disconnectedCallback() {
4298
- this.init.complete();
4299
- this.destroyed.next();
4300
- this.destroyed.complete();
4301
- }
4302
- render() {
4303
- return [
4304
- h("div", { class: "scrollable-wrapper", ref: el => (this.scrollWrapperElement = el) }, this.shadowY && h("div", { class: "shadow-top" }), this.shadowX && h("div", { class: "shadow-left" }), this.shadowX && h("div", { class: "shadow-right" }), this.shadowY && h("div", { class: "shadow-bottom" })),
4305
- h("div", { ref: el => (this.scrollElement = el), class: {
4306
- 'scrollable-content': true,
4307
- 'scroll-x': this.overflowX,
4308
- 'scroll-y': this.overflowY,
4309
- 'no-overscroll': !this.overscroll
4310
- } }, h("slot", null))
4311
- ];
4312
- }
4313
- attachEmitter(from, emitter, buffer) {
4314
- merge(this.init, this.scrolled)
4315
- .pipe(map(() => this.getScrollOffset(from)))
4316
- .pipe(map(offset => offset <= buffer))
4317
- .pipe(distinctUntilChanged())
4318
- .pipe(filter(isLower => isLower))
4319
- .pipe(takeUntil(this.destroyed))
4320
- .subscribe(() => emitter.emit());
4321
- }
4322
- getScrollOffset(from) {
4323
- if (this.scrollElement) {
4324
- switch (from) {
4325
- case 'top':
4326
- return this.scrollElement.scrollTop;
4327
- case 'left':
4328
- return this.scrollElement.scrollLeft;
4329
- case 'right':
4330
- return this.scrollElement.scrollWidth - this.scrollElement.clientWidth - this.scrollElement.scrollLeft;
4331
- case 'bottom':
4332
- return this.scrollElement.scrollHeight - this.scrollElement.clientHeight - this.scrollElement.scrollTop;
4333
- default:
4334
- return 0;
4335
- }
4336
- }
4337
- return 0;
4338
- }
4339
- toggleClass(name, value) {
4340
- var _a, _b;
4341
- if (value) {
4342
- (_a = this.scrollWrapperElement) === null || _a === void 0 ? void 0 : _a.classList.add(name);
4343
- }
4344
- else {
4345
- (_b = this.scrollWrapperElement) === null || _b === void 0 ? void 0 : _b.classList.remove(name);
4346
- }
4347
- }
4348
- get el() { return getElement(this); }
4349
- };
4350
- CatScrollable.style = catScrollableCss;
4351
-
4352
- const catSkeletonCss = ":host{display:flex;flex-direction:column;position:relative;--background:#ebecf0;--highlight:#d7dbe0;--speed:2s}:host([variant=square]),:host([variant=circle]){display:inline-flex}:host([hidden]){display:none}:host([variant=head]){margin-bottom:0.5rem}:host([variant=body]){margin-bottom:1rem}.cat-skeleton{display:block;border-radius:0.25rem;background:var(--background)}.cat-skeleton-circle{border-radius:10rem}.cat-skeleton-xs.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 1.5rem)}.cat-skeleton-xs.cat-skeleton-square,.cat-skeleton-xs.cat-skeleton-circle{width:var(--width, 1.5rem);height:var(--height, 1.5rem)}.cat-skeleton-xs.cat-skeleton-head,.cat-skeleton-xs.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-xs.cat-skeleton-head{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.cat-skeleton-xs.cat-skeleton-body{height:calc(0.75rem - 4px);margin:calc((1rem - 0.75rem + 4px) * 0.5) 0}.cat-skeleton-s.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2rem)}.cat-skeleton-s.cat-skeleton-square,.cat-skeleton-s.cat-skeleton-circle{width:var(--width, 2rem);height:var(--height, 2rem)}.cat-skeleton-s.cat-skeleton-head,.cat-skeleton-s.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-s.cat-skeleton-head{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.cat-skeleton-s.cat-skeleton-body{height:calc(0.875rem - 4px);margin:calc((1rem - 0.875rem + 4px) * 0.5) 0}.cat-skeleton-m.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 2.5rem)}.cat-skeleton-m.cat-skeleton-square,.cat-skeleton-m.cat-skeleton-circle{width:var(--width, 2.5rem);height:var(--height, 2.5rem)}.cat-skeleton-m.cat-skeleton-head,.cat-skeleton-m.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-m.cat-skeleton-head{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.cat-skeleton-m.cat-skeleton-body{height:calc(0.9375rem - 4px);margin:calc((1.25rem - 0.9375rem + 4px) * 0.5) 0}.cat-skeleton-l.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3rem)}.cat-skeleton-l.cat-skeleton-square,.cat-skeleton-l.cat-skeleton-circle{width:var(--width, 3rem);height:var(--height, 3rem)}.cat-skeleton-l.cat-skeleton-head,.cat-skeleton-l.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-l.cat-skeleton-head{height:calc(1.5rem - 4px);margin:calc((1.75rem - 1.5rem + 4px) * 0.5) 0}.cat-skeleton-l.cat-skeleton-body{height:calc(1.125rem - 4px);margin:calc((1.5rem - 1.125rem + 4px) * 0.5) 0}.cat-skeleton-xl.cat-skeleton-rectangle{width:var(--width, 100%);height:var(--height, 3.5rem)}.cat-skeleton-xl.cat-skeleton-square,.cat-skeleton-xl.cat-skeleton-circle{width:var(--width, 3.5rem);height:var(--height, 3.5rem)}.cat-skeleton-xl.cat-skeleton-head,.cat-skeleton-xl.cat-skeleton-body{width:var(--width, var(--line-width, 100%))}.cat-skeleton-xl.cat-skeleton-head{height:calc(1.75rem - 4px);margin:calc((2rem - 1.75rem + 4px) * 0.5) 0}.cat-skeleton-xl.cat-skeleton-body{height:calc(1.25rem - 4px);margin:calc((1.5rem - 1.25rem + 4px) * 0.5) 0}.cat-skeleton-sheen{background:linear-gradient(90deg, var(--background) 33%, var(--highlight) 50%, var(--background) 66%) var(--background);background-size:300% 100%;animation:sheen var(--speed) ease-in-out infinite}.cat-skeleton-pulse{position:relative;overflow:hidden}.cat-skeleton-pulse::before{content:\"\";display:block;position:absolute;width:100%;height:100%;background-color:var(--highlight);animation:var(--speed) ease-in-out 0.5s infinite normal none running pulse;opacity:0}@keyframes sheen{0%{background-position:right}}@keyframes pulse{50%{opacity:1}}";
4353
-
4354
- const CatSkeleton = class {
4355
- constructor(hostRef) {
4356
- registerInstance(this, hostRef);
4357
- /**
4358
- * The animation style of the skeleton.
4359
- */
4360
- this.effect = 'sheen';
4361
- /**
4362
- * The rendering style of the skeleton.
4363
- */
4364
- this.variant = 'rectangle';
4365
- /**
4366
- * The size of the skeleton. If the variant is set to "head", the size values
4367
- * "xs" to "xl" translate to the head levels `h1` to `h5`.
4368
- */
4369
- this.size = 'm';
4370
- }
4371
- render() {
4372
- return (h(Host, null, Array.from(Array(this.count)).map(() => (h("div", { style: this.style, class: {
4373
- 'cat-skeleton': true,
4374
- [`cat-skeleton-${this.effect}`]: Boolean(this.effect),
4375
- [`cat-skeleton-${this.variant}`]: Boolean(this.variant),
4376
- [`cat-skeleton-${this.size}`]: Boolean(this.size)
4377
- } })))));
4378
- }
4379
- get count() {
4380
- switch (this.variant) {
4381
- case 'head':
4382
- return Math.max(1, this.lines || 1);
4383
- case 'body':
4384
- return Math.max(1, this.lines || 3);
4385
- default:
4386
- return 1;
4387
- }
4388
- }
4389
- get style() {
4390
- return this.variant === 'head' || this.variant === 'body'
4391
- ? {
4392
- '--line-width': `${this.random(50, 100)}%`
4393
- }
4394
- : undefined;
4395
- }
4396
- random(min, max) {
4397
- return Math.floor(Math.random() * (max - min + 1) + min);
4398
- }
4399
- };
4400
- CatSkeleton.style = catSkeletonCss;
4401
-
4402
- const catSpinnerCss = ":host{display:inline-flex;vertical-align:middle;-webkit-user-select:none;-ms-user-select:none;user-select:none;}:host[hidden]{display:none}span{display:inline-flex}svg{fill:none;stroke:currentColor;stroke-dasharray:135px;stroke-dashoffset:95px;stroke-linecap:round;stroke-width:5px;transform-origin:center center;animation:cat-spinner 0.75s cubic-bezier(0.4, 0.15, 0.6, 0.85) infinite;width:1em;height:1em}.cat-spinner-xs svg{font-size:0.75rem}.cat-spinner-s svg{font-size:1rem}.cat-spinner-m svg{font-size:1.25rem}.cat-spinner-l svg{font-size:1.5rem}.cat-spinner-xl svg{font-size:1.75rem}@keyframes cat-spinner{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}";
4403
-
4404
- const CatSpinner = class {
4405
- constructor(hostRef) {
4406
- registerInstance(this, hostRef);
4407
- /**
4408
- * The size of the spinner.
4409
- */
4410
- this.size = 'm';
4411
- }
4412
- render() {
4413
- return (h("span", { "aria-label": this.a11yLabel, "aria-hidden": this.a11yLabel ? null : 'true', class: {
4414
- [`cat-spinner-${this.size}`]: this.size !== 'inline'
4415
- } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 48 48" }, h("circle", { cx: "24", cy: "24", r: "21.5" }))));
4416
- }
4417
- };
4418
- CatSpinner.style = catSpinnerCss;
4419
-
4420
- const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
4421
-
4422
- const catTooltipCss = ":host{display:contents}:host([hidden]){display:none}.tooltip{position:absolute;font-size:0.875rem;line-height:1rem;padding:0.25rem;background-color:rgba(0, 0, 0, 0.7);border-radius:0.125rem;color:white;white-space:nowrap;transition:0.13s linear;visibility:hidden;opacity:0}.tooltip-show{opacity:1;visibility:visible}.tooltip-trigger{display:inline-block}.tooltip-trigger:focus{outline:none}";
4423
-
4424
- let nextUniqueId = 0;
4425
- const CatTooltip = class {
4426
- constructor(hostRef) {
4427
- registerInstance(this, hostRef);
4428
- this.id = `cat-tooltip-${nextUniqueId++}`;
4429
- /**
4430
- * The content of the tooltip.
4431
- */
4432
- this.content = '';
4433
- /**
4434
- * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,
4435
- * and invisible. Corresponds with the native HTML disabled attribute.
4436
- */
4437
- this.disabled = false;
4438
- /**
4439
- * The placement of the tooltip.
4440
- */
4441
- this.placement = 'top';
4442
- /**
4443
- * The delay time for showing tooltip in ms.
4444
- */
4445
- this.showDelay = 1000;
4446
- /**
4447
- * The delay time for hiding tooltip in ms.
4448
- */
4449
- this.hideDelay = 0;
4450
- /**
4451
- * The duration of tap to show the tooltip.
4452
- */
4453
- this.longTouchDuration = 1000;
4454
- }
4455
- handleKeyDown({ key }) {
4456
- key === 'Escape' && this.hideListener();
4457
- }
4458
- componentDidLoad() {
4459
- var _a, _b, _c, _d, _e, _f, _g;
4460
- this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;
4461
- if (!this.isTabbable) {
4462
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.setAttribute('tabindex', '0');
4463
- }
4464
- if (this.trigger && this.tooltip) {
4465
- autoUpdate(this.trigger, this.tooltip, () => this.update());
4466
- }
4467
- if (isTouchDevice) {
4468
- (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.addEventListener('touchstart', this.touchStartListener.bind(this));
4469
- (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('touchend', this.touchEndListener.bind(this));
4470
- }
4471
- else {
4472
- (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.addEventListener('focusin', this.showListener.bind(this));
4473
- (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.addEventListener('focusout', this.hideListener.bind(this));
4474
- (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseenter', this.showListener.bind(this));
4475
- (_g = this.trigger) === null || _g === void 0 ? void 0 : _g.addEventListener('mouseleave', this.hideListener.bind(this));
4476
- }
4477
- }
4478
- disconnectedCallback() {
4479
- var _a, _b, _c, _d, _e, _f;
4480
- if (isTouchDevice) {
4481
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('touchstart', this.touchStartListener.bind(this));
4482
- (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('touchend', this.touchEndListener.bind(this));
4483
- }
4484
- else {
4485
- (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseenter', this.showListener.bind(this));
4486
- (_d = this.trigger) === null || _d === void 0 ? void 0 : _d.removeEventListener('mouseleave', this.hideListener.bind(this));
4487
- (_e = this.trigger) === null || _e === void 0 ? void 0 : _e.removeEventListener('focusin', this.showListener.bind(this));
4488
- (_f = this.trigger) === null || _f === void 0 ? void 0 : _f.removeEventListener('focusout', this.hideListener.bind(this));
4489
- }
4490
- }
4491
- render() {
4492
- return (h(Host, null, h("div", { ref: el => (this.triggerElement = el), "aria-describedby": this.id, class: "tooltip-trigger" }, h("slot", null)), this.content && !this.disabled && (h("div", { ref: el => (this.tooltip = el), id: this.id, class: "tooltip" }, this.content))));
4493
- }
4494
- get isTabbable() {
4495
- return firstTabbable(this.trigger);
4496
- }
4497
- update() {
4498
- if (this.trigger && this.tooltip) {
4499
- computePosition(this.trigger, this.tooltip, {
4500
- placement: this.placement,
4501
- middleware: [offset(CatTooltip.OFFSET), flip()]
4502
- }).then(({ x, y }) => {
4503
- if (this.tooltip) {
4504
- Object.assign(this.tooltip.style, {
4505
- left: `${Math.max(0, x)}px`,
4506
- top: `${y}px`
4507
- });
4508
- }
4509
- });
4510
- }
4511
- }
4512
- showListener() {
4513
- window.clearTimeout(this.hideTimeout);
4514
- this.showTimeout = window.setTimeout(() => {
4515
- var _a, _b;
4516
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.focus();
4517
- (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.add('tooltip-show');
4518
- }, this.showDelay);
4519
- }
4520
- hideListener() {
4521
- window.clearTimeout(this.showTimeout);
4522
- this.hideTimeout = window.setTimeout(() => {
4523
- var _a, _b;
4524
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.blur();
4525
- (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.remove('tooltip-show');
4526
- }, this.hideDelay);
4527
- }
4528
- touchStartListener() {
4529
- this.touchTimeout = window.setTimeout(() => {
4530
- var _a;
4531
- (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
4532
- }, this.longTouchDuration);
4533
- }
4534
- touchEndListener() {
4535
- var _a;
4536
- window.clearTimeout(this.touchTimeout);
4537
- (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
4538
- }
4539
- };
4540
- CatTooltip.OFFSET = 4;
4541
- CatTooltip.style = catTooltipCss;
4542
-
4543
- export { CatAlert as cat_alert, CatBadge as cat_badge, CatButton as cat_button, CatIcon as cat_icon, CatMenu as cat_menu, CatScrollable as cat_scrollable, CatSkeleton as cat_skeleton, CatSpinner as cat_spinner, CatTooltip as cat_tooltip };
4544
-
4545
- //# sourceMappingURL=cat-alert_9.entry.js.map