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