@haiilo/catalyst 0.5.0 → 0.5.4

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