@luzmo/lucero 1.0.1-alpha.18 → 1.0.1-alpha.19

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 (275) hide show
  1. package/components/NumberFormatter-DewVDY5w.cjs +18 -0
  2. package/components/NumberFormatter-DgOUVrge.js +136 -0
  3. package/components/NumberParser-Dik4a0h-.cjs +18 -0
  4. package/components/NumberParser-ci9J5EKv.js +173 -0
  5. package/components/accordion/index.cjs +6 -183
  6. package/components/accordion/index.js +88 -136
  7. package/components/action-bar/index.cjs +4 -85
  8. package/components/action-bar/index.js +50 -72
  9. package/components/action-button/index.cjs +3 -205
  10. package/components/action-button/index.js +93 -167
  11. package/components/action-group/index.cjs +1 -7
  12. package/components/action-group/index.js +8 -12
  13. package/components/action-group-C54IxNZk.cjs +20 -0
  14. package/components/action-group-C9dsPJg-.js +258 -0
  15. package/components/action-menu/index.cjs +11 -91
  16. package/components/action-menu/index.js +47 -66
  17. package/components/async-directive-BwIAw5tB.js +82 -0
  18. package/components/async-directive-DLz6JB0v.cjs +22 -0
  19. package/components/avatar/index.cjs +3 -63
  20. package/components/avatar/index.js +42 -54
  21. package/components/{focusable-selectors-D0t_5P7C.cjs → base-BjTwmyRF.cjs} +5 -16
  22. package/components/base-CFWO09N1.js +684 -0
  23. package/components/base-Cy0MQrPT.cjs +40 -0
  24. package/components/base-D76d76ww.js +26 -0
  25. package/components/button/index.cjs +2 -134
  26. package/components/button/index.js +72 -106
  27. package/components/button-base-B8bWcklV.js +144 -0
  28. package/components/button-base-tf95Lyl4.cjs +25 -0
  29. package/components/button-group/index.cjs +1 -45
  30. package/components/button-group/index.js +25 -37
  31. package/components/calendar/index.cjs +1 -632
  32. package/components/calendar/index.js +7 -637
  33. package/components/checkbox/index.cjs +4 -111
  34. package/components/checkbox/index.js +53 -98
  35. package/components/checkbox-mixin-BOTvuPEu.js +70 -0
  36. package/components/checkbox-mixin-BVPpXtsq.cjs +27 -0
  37. package/components/class-map-CGfNk3Ee.js +51 -0
  38. package/components/class-map-D-Y-hsN5.cjs +22 -0
  39. package/components/clear-button-CuPbWwZY.cjs +18 -0
  40. package/components/clear-button-DzZ5ulBW.js +53 -0
  41. package/components/close-button-BTo4yrFR.cjs +18 -0
  42. package/components/close-button-CuQdsez5.js +51 -0
  43. package/components/color-area/index.cjs +13 -440
  44. package/components/color-area/index.js +187 -322
  45. package/components/color-controller-B0uX6Zso.js +3230 -0
  46. package/components/color-controller-CoUL5f9K.cjs +18 -0
  47. package/components/color-field/index.cjs +2 -95
  48. package/components/color-field/index.js +41 -77
  49. package/components/color-handle/index.cjs +3 -64
  50. package/components/color-handle/index.js +37 -58
  51. package/components/color-loupe/index.cjs +1 -7
  52. package/components/color-loupe/index.js +8 -12
  53. package/components/color-loupe-CrM2DVY3.cjs +56 -0
  54. package/components/color-loupe-DmQe3SpP.js +81 -0
  55. package/components/color-menu/index.cjs +12 -217
  56. package/components/color-menu/index.js +93 -187
  57. package/components/color-palette/index.cjs +1 -89
  58. package/components/color-palette/index.js +51 -78
  59. package/components/color-palette-group/index.cjs +3 -259
  60. package/components/color-palette-group/index.js +105 -193
  61. package/components/color-picker/index.cjs +6 -114
  62. package/components/color-picker/index.js +72 -92
  63. package/components/color-slider/index.cjs +1 -585
  64. package/components/color-slider/index.js +7 -590
  65. package/components/condition-attribute-with-id-DrQYZzFS.cjs +18 -0
  66. package/components/condition-attribute-with-id-Dv4lSRbe.js +31 -0
  67. package/components/date-time-picker/index.cjs +31 -1357
  68. package/components/date-time-picker/index.js +637 -951
  69. package/components/{dependency-manger-XHpQjFgK.js → dependency-manger-CO-VPlqq.js} +14 -24
  70. package/components/dependency-manger-uthev62E.cjs +18 -0
  71. package/components/directive-C7oCP5Bh.cjs +22 -0
  72. package/components/directive-helpers-D4KMv2dC.js +62 -0
  73. package/components/directive-helpers-t-TVum7J.cjs +22 -0
  74. package/components/{slottable-request-event-CANixJnR.cjs → directive-oAbCiebi.js} +25 -14
  75. package/components/divider/index.cjs +1 -54
  76. package/components/divider/index.js +30 -49
  77. package/components/divider.module-DDvBo9zo.cjs +18 -0
  78. package/components/divider.module-DoQWQEIJ.js +21 -0
  79. package/components/element-resolution-BvRLGqIU.cjs +18 -0
  80. package/components/element-resolution-FCUT-wql.js +91 -0
  81. package/components/field-group/index.cjs +1 -7
  82. package/components/field-group/index.js +8 -12
  83. package/components/field-group-5WQMBOk4.cjs +23 -0
  84. package/components/field-group-D4B0IOdA.js +66 -0
  85. package/components/field-label/index.cjs +1 -7
  86. package/components/field-label/index.js +8 -12
  87. package/components/field-label-DxmPiC5p.js +106 -0
  88. package/components/field-label-Dz9kisdW.cjs +25 -0
  89. package/components/flow-D-0MTYCm.js +527 -0
  90. package/components/flow-DM3dNAKs.cjs +30 -0
  91. package/components/focus-group-DHeTq18L.js +218 -0
  92. package/components/focus-group-DnxZUBhQ.cjs +18 -0
  93. package/components/focus-visible-BvScGDCE.js +74 -0
  94. package/components/focus-visible-D4BXb5RB.cjs +18 -0
  95. package/components/focusable-B_KwfEec.cjs +18 -0
  96. package/components/focusable-C5JjRZmT.js +153 -0
  97. package/components/{focusable-selectors-IltOAOd9.js → focusable-selectors-B4YgbghQ.js} +4 -7
  98. package/components/focusable-selectors-BgFlyFcY.cjs +18 -0
  99. package/components/icon/index.cjs +1 -90
  100. package/components/icon/index.js +46 -74
  101. package/components/if-defined-DULpqYwi.js +27 -0
  102. package/components/if-defined-DaXWqfzc.cjs +22 -0
  103. package/components/index-CNK8wHXu.cjs +57 -0
  104. package/components/index-Cf6G4q52.js +1490 -0
  105. package/components/index-D3ICqC7S.js +1174 -0
  106. package/components/index-hqVbNKYy.cjs +113 -0
  107. package/components/index.cjs +1 -174
  108. package/components/index.js +172 -174
  109. package/components/infield-button/index.cjs +2 -46
  110. package/components/infield-button/index.js +30 -41
  111. package/components/label/index.cjs +1 -37
  112. package/components/label/index.js +24 -36
  113. package/components/{language-resolution-BSGJAWiQ.js → language-resolution-B-wjV5bb.js} +17 -21
  114. package/components/language-resolution-EUER43cg.cjs +18 -0
  115. package/components/like-anchor-Bu3pXbjT.cjs +32 -0
  116. package/components/like-anchor-DCFJN0LV.js +69 -0
  117. package/components/luzmo-icons-CiSek5iM.js +229 -0
  118. package/components/luzmo-icons-CtA-TJPd.cjs +29 -0
  119. package/components/manage-help-text-CHfMLzSa.js +92 -0
  120. package/components/manage-help-text-DNqdEkTA.cjs +30 -0
  121. package/components/menu/index.cjs +29 -1297
  122. package/components/menu/index.js +499 -954
  123. package/components/multi-language-field/index.cjs +2 -132
  124. package/components/multi-language-field/index.js +88 -118
  125. package/components/mutation-controller-DH7YOCyj.js +52 -0
  126. package/components/mutation-controller-DkOMCW-c.cjs +22 -0
  127. package/components/number-field/index.cjs +10 -613
  128. package/components/number-field/index.js +243 -442
  129. package/components/observe-slot-presence-CmVi0zTc.js +68 -0
  130. package/components/observe-slot-presence-bc9chhsi.cjs +18 -0
  131. package/components/observe-slot-text-C3moTjwy.js +87 -0
  132. package/components/observe-slot-text-D2VAEFSd.cjs +18 -0
  133. package/components/options/index.cjs +60 -693
  134. package/components/options/index.js +953 -519
  135. package/components/overlay/index.cjs +21 -367
  136. package/components/overlay/index.js +189 -273
  137. package/components/overlay-B3ajDLLq.cjs +47 -0
  138. package/components/overlay-CUKs69yr.js +2745 -0
  139. package/components/{pending-state-CXbe-Xul.js → pending-state-B2wWssTo.js} +13 -28
  140. package/components/pending-state-bJr-nEJl.cjs +26 -0
  141. package/components/picker/index.cjs +1 -9
  142. package/components/picker/index.js +11 -15
  143. package/components/picker-C0LvseZe.cjs +123 -0
  144. package/components/picker-W1qNmtsh.js +461 -0
  145. package/components/picker-button/index.cjs +4 -56
  146. package/components/picker-button/index.js +34 -45
  147. package/components/{condition-attribute-with-id-Cn815e9W.js → platform-BM-uMWpX.js} +49 -24
  148. package/components/platform-BiXhwqk3.cjs +18 -0
  149. package/components/popover/index.cjs +1 -7
  150. package/components/popover/index.js +8 -12
  151. package/components/popover-fwJeZHMQ.cjs +30 -0
  152. package/components/popover-iD8f5Jkp.js +67 -0
  153. package/components/progress-circle/index.cjs +1 -7
  154. package/components/progress-circle/index.js +8 -12
  155. package/components/progress-circle-DZxaMe8L.cjs +33 -0
  156. package/components/progress-circle-USIIU1up.js +97 -0
  157. package/components/query-BL-TJj7K.cjs +22 -0
  158. package/components/query-D_KR_GUc.js +51 -0
  159. package/components/query-assigned-elements-DjfhL1cl.js +36 -0
  160. package/components/query-assigned-elements-DsKsfk7G.cjs +22 -0
  161. package/components/query-assigned-nodes-BcKWmGzy.cjs +22 -0
  162. package/components/query-assigned-nodes-C76XVPWY.js +36 -0
  163. package/components/radio/index.cjs +2 -244
  164. package/components/radio/index.js +110 -192
  165. package/components/{random-id-BEc6QIUL.js → random-id-ByCz1xaq.js} +3 -3
  166. package/components/random-id-CqvckpWe.cjs +18 -0
  167. package/components/roving-tabindex-By_fCy_e.cjs +18 -0
  168. package/components/roving-tabindex-DOg4z6ZU.js +66 -0
  169. package/components/search/index.cjs +8 -115
  170. package/components/search/index.js +66 -96
  171. package/components/select/index.cjs +51 -720
  172. package/components/select/index.js +347 -563
  173. package/components/sized-mixin-CJbBHWRQ.js +63 -0
  174. package/components/sized-mixin-WPHH0a_D.cjs +18 -0
  175. package/components/slider/index.cjs +1 -119
  176. package/components/slider/index.js +1113 -100
  177. package/components/slottable-request-event-BfUUt1Mh.cjs +18 -0
  178. package/components/{slottable-request-event-D9WzrdWv.js → slottable-request-event-DggLA4Rx.js} +9 -12
  179. package/components/state-DwIwYPvt.js +29 -0
  180. package/components/state-vf0PJN3_.cjs +22 -0
  181. package/components/strategies-C6HsQpU2.cjs +18 -0
  182. package/components/strategies-CUMLHtQI.js +195 -0
  183. package/components/streaming-listener-BQ68fKMa.js +91 -0
  184. package/components/streaming-listener-DeGQYM-9.cjs +18 -0
  185. package/components/style-map-Bnhf_mVZ.js +53 -0
  186. package/components/style-map-DuMd5xlY.cjs +22 -0
  187. package/components/swatch/index.cjs +7 -436
  188. package/components/swatch/index.js +205 -350
  189. package/components/switch/index.cjs +2 -61
  190. package/components/switch/index.js +34 -51
  191. package/components/tabs/index.cjs +26 -693
  192. package/components/tabs/index.js +388 -521
  193. package/components/tags/index.cjs +4 -201
  194. package/components/tags/index.js +87 -152
  195. package/components/text-field/index.cjs +3 -49
  196. package/components/text-field/index.js +30 -44
  197. package/components/text-field-BkFPYo7S.cjs +85 -0
  198. package/components/text-field-C2n3rzCK.js +314 -0
  199. package/components/text-field.module-C2KVUJcX.js +21 -0
  200. package/components/text-field.module-DXhFA9G-.cjs +18 -0
  201. package/components/toast/index.cjs +12 -177
  202. package/components/toast/index.js +73 -145
  203. package/components/tooltip/index.cjs +6 -250
  204. package/components/tooltip/index.js +124 -177
  205. package/components/unit-input/index.cjs +8 -232
  206. package/components/unit-input/index.js +108 -201
  207. package/components/utils.cjs +1 -25
  208. package/components/utils.js +22 -22
  209. package/components/{random-id-BE6HA503.cjs → when-CDK1Tt5Y.js} +10 -7
  210. package/components/when-CDZyJPvd.cjs +22 -0
  211. package/package.json +1 -1
  212. package/components/action-group-DHp8RHDf.js +0 -392
  213. package/components/action-group-MPf19RPV.cjs +0 -391
  214. package/components/base-COw9n7UR.cjs +0 -119
  215. package/components/base-DmeVy0cq.js +0 -120
  216. package/components/button-base-7Ak55xFd.cjs +0 -206
  217. package/components/button-base-C3kf6BTK.js +0 -207
  218. package/components/checkbox-mixin-8cL-vfDy.js +0 -84
  219. package/components/checkbox-mixin-CE7dJj3J.cjs +0 -83
  220. package/components/clear-button-Co6oKSgl.js +0 -59
  221. package/components/clear-button-X_HDY2eH.cjs +0 -58
  222. package/components/close-button-DPBK6Kpu.cjs +0 -59
  223. package/components/close-button-Miw9ZjoJ.js +0 -60
  224. package/components/color-controller-BjDZaxhX.js +0 -491
  225. package/components/color-controller-C3c_vb2P.cjs +0 -490
  226. package/components/color-loupe-BQqNR8YD.cjs +0 -88
  227. package/components/color-loupe-B_DDFv8l.js +0 -89
  228. package/components/condition-attribute-with-id-DEc2Yjne.cjs +0 -43
  229. package/components/dependency-manger-CcIE1uvQ.cjs +0 -63
  230. package/components/divider.module-Cm5LcDRV.cjs +0 -20
  231. package/components/divider.module-DauH6k2_.js +0 -21
  232. package/components/element-resolution-DCsrhGZO.cjs +0 -112
  233. package/components/element-resolution-nMlmW4Jy.js +0 -113
  234. package/components/field-group-DNmY8W9v.cjs +0 -86
  235. package/components/field-group-DVdAWCQF.js +0 -87
  236. package/components/field-label-CKH9EXpR.cjs +0 -156
  237. package/components/field-label-Dpsecoc6.js +0 -157
  238. package/components/focus-group-BqDAk9Is.js +0 -337
  239. package/components/focus-group-DFzOlalL.cjs +0 -336
  240. package/components/focus-visible-B-B8-P9R.cjs +0 -104
  241. package/components/focus-visible-BUPRWlsh.js +0 -105
  242. package/components/focusable-BPrTcZPd.cjs +0 -262
  243. package/components/focusable-ChCLg1k4.js +0 -263
  244. package/components/language-resolution-iN9EImbb.cjs +0 -57
  245. package/components/like-anchor-D62faRNG.cjs +0 -79
  246. package/components/like-anchor-v3cJ9RWM.js +0 -80
  247. package/components/manage-help-text-BYx84zZR.cjs +0 -125
  248. package/components/manage-help-text-DOuMTGht.js +0 -126
  249. package/components/observe-slot-presence-9AwLGUQ_.cjs +0 -78
  250. package/components/observe-slot-presence-DcMdoumP.js +0 -79
  251. package/components/observe-slot-text-CSofZeeF.cjs +0 -104
  252. package/components/observe-slot-text-CjnkkBPn.js +0 -105
  253. package/components/overlay-CN8ISP1F.js +0 -2485
  254. package/components/overlay-LViy9VWM.cjs +0 -2484
  255. package/components/pending-state-e4RbXe9u.cjs +0 -75
  256. package/components/picker-DNde3awt.cjs +0 -672
  257. package/components/picker-PfUAF05y.js +0 -673
  258. package/components/platform-CxDar3Dn.cjs +0 -68
  259. package/components/platform-Cxn0WbyT.js +0 -69
  260. package/components/popover-BkbYhl3i.js +0 -74
  261. package/components/popover-BkgUf0kL.cjs +0 -74
  262. package/components/progress-circle-Hu_ivPHf.js +0 -133
  263. package/components/progress-circle-_Etqsj9f.cjs +0 -132
  264. package/components/roving-tabindex-AsmAh2In.cjs +0 -95
  265. package/components/roving-tabindex-DPF9NmrH.js +0 -96
  266. package/components/sized-mixin-DmkrNdWB.js +0 -80
  267. package/components/sized-mixin-UaTVa-AE.cjs +0 -79
  268. package/components/strategies-DlMlaSJR.cjs +0 -317
  269. package/components/strategies-DlPQoTFE.js +0 -318
  270. package/components/streaming-listener-D4sHaMub.cjs +0 -145
  271. package/components/streaming-listener-cAz5zJyk.js +0 -146
  272. package/components/text-field-11tcnftU.cjs +0 -338
  273. package/components/text-field-Chi9J2Cz.js +0 -339
  274. package/components/text-field.module-CMBS0jSL.js +0 -21
  275. package/components/text-field.module-DIJdV_sA.cjs +0 -20
@@ -1,2484 +0,0 @@
1
- /*! * Lucero - The design system for Luzmo.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
6
- * This license allows users with a current active Luzmo account to use Lucero.
7
- * This license terminates automatically if a user no longer has an active Luzmo account.
8
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
- * SOFTWARE.
17
- * */
18
- "use strict";
19
- var _a;
20
- const lit = require("lit");
21
- const decorators_js = require("lit/decorators.js");
22
- const ifDefined_js = require("lit/directives/if-defined.js");
23
- const styleMap_js = require("lit/directives/style-map.js");
24
- const randomId = require("./random-id-BE6HA503.cjs");
25
- const elementResolution = require("./element-resolution-DCsrhGZO.cjs");
26
- const base = require("./base-COw9n7UR.cjs");
27
- const focusableSelectors = require("./focusable-selectors-D0t_5P7C.cjs");
28
- const dom = require("@floating-ui/dom");
29
- const slottableRequestEvent = require("./slottable-request-event-CANixJnR.cjs");
30
- const conditionAttributeWithId = require("./condition-attribute-with-id-DEc2Yjne.cjs");
31
- const platform = require("./platform-CxDar3Dn.cjs");
32
- function restoreChildren(placeholderItems, srcElements, cleanupCallbacks = []) {
33
- for (const [index, srcElement] of srcElements.entries()) {
34
- const placeholderItem = placeholderItems[index];
35
- const parentElement = placeholderItem.parentElement || placeholderItem.getRootNode();
36
- if (cleanupCallbacks[index]) {
37
- cleanupCallbacks[index](srcElement);
38
- }
39
- if (parentElement && parentElement !== placeholderItem) {
40
- placeholderItem.replaceWith(srcElement);
41
- }
42
- delete placeholderItems[index];
43
- }
44
- return srcElements;
45
- }
46
- const reparentChildren = (srcElements, destination, {
47
- position,
48
- prepareCallback
49
- } = { position: "beforeend" }) => {
50
- let { length } = srcElements;
51
- if (length === 0) {
52
- return () => srcElements;
53
- }
54
- let step = 1;
55
- let index = 0;
56
- if (position === "afterbegin" || position === "afterend") {
57
- step = -1;
58
- index = length - 1;
59
- }
60
- const placeholderItems = new Array(length);
61
- const cleanupCallbacks = new Array(length);
62
- const placeholderTemplate = typeof document !== "undefined" ? document.createComment("placeholder for reparented element") : null;
63
- do {
64
- const srcElement = srcElements[index];
65
- if (prepareCallback) {
66
- cleanupCallbacks[index] = prepareCallback(srcElement);
67
- }
68
- placeholderItems[index] = placeholderTemplate.cloneNode();
69
- const parentElement = srcElement.parentElement || srcElement.getRootNode();
70
- if (parentElement && parentElement !== srcElement) {
71
- parentElement.replaceChild(placeholderItems[index], srcElement);
72
- }
73
- destination.insertAdjacentElement(position, srcElement);
74
- index += step;
75
- } while (--length > 0);
76
- return function() {
77
- return restoreChildren(placeholderItems, srcElements, cleanupCallbacks);
78
- };
79
- };
80
- const DEFAULT_WARMUP = 1e3;
81
- const DEFAULT_COOLDOWN = 1e3;
82
- class LuzmoOverlayTimer {
83
- constructor(options = {}) {
84
- this.warmUpDelay = DEFAULT_WARMUP;
85
- this.coolDownDelay = DEFAULT_COOLDOWN;
86
- this.isWarm = false;
87
- this.timeout = 0;
88
- Object.assign(this, options);
89
- }
90
- openTimer(component) {
91
- this.cancelCooldownTimer();
92
- if (!this.component || component !== this.component) {
93
- if (this.component) {
94
- this.close(this.component);
95
- this.cancelCooldownTimer();
96
- }
97
- this.component = component;
98
- if (this.isWarm) {
99
- return Promise.resolve(false);
100
- }
101
- this.promise = new Promise((resolve) => {
102
- this.resolve = resolve;
103
- this.timeout = typeof window !== "undefined" ? window.setTimeout(() => {
104
- if (this.resolve) {
105
- this.resolve(false);
106
- this.isWarm = true;
107
- }
108
- }, this.warmUpDelay) : 0;
109
- });
110
- return this.promise;
111
- } else if (this.promise) {
112
- return this.promise;
113
- }
114
- throw new Error("Inconsistent state");
115
- }
116
- close(component) {
117
- if (this.component && this.component === component) {
118
- this.resetCooldownTimer();
119
- if (this.timeout > 0) {
120
- clearTimeout(this.timeout);
121
- this.timeout = 0;
122
- }
123
- if (this.resolve) {
124
- this.resolve(true);
125
- delete this.resolve;
126
- }
127
- delete this.promise;
128
- delete this.component;
129
- }
130
- }
131
- resetCooldownTimer() {
132
- if (this.isWarm) {
133
- if (this.cooldownTimeout && typeof window !== "undefined") {
134
- window.clearTimeout(this.cooldownTimeout);
135
- }
136
- this.cooldownTimeout = typeof window !== "undefined" ? window.setTimeout(() => {
137
- this.isWarm = false;
138
- delete this.cooldownTimeout;
139
- }, this.coolDownDelay) : void 0;
140
- }
141
- }
142
- cancelCooldownTimer() {
143
- if (this.cooldownTimeout && typeof window !== "undefined") {
144
- window.clearTimeout(this.cooldownTimeout);
145
- }
146
- delete this.cooldownTimeout;
147
- }
148
- }
149
- const overlayTimer = new LuzmoOverlayTimer();
150
- const noop = () => {
151
- };
152
- const guaranteedAllTransitionend = (el, action, cb) => {
153
- const abortController = new AbortController();
154
- const runningTransitions = /* @__PURE__ */ new Map();
155
- const cleanup = () => {
156
- abortController.abort();
157
- cb();
158
- };
159
- let guarantee2;
160
- let guarantee3;
161
- const guarantee1 = requestAnimationFrame(() => {
162
- guarantee2 = requestAnimationFrame(() => {
163
- guarantee3 = requestAnimationFrame(() => {
164
- cleanup();
165
- });
166
- });
167
- });
168
- const handleTransitionend = (event) => {
169
- if (event.target !== el) {
170
- return;
171
- }
172
- runningTransitions.set(
173
- event.propertyName,
174
- runningTransitions.get(event.propertyName) - 1
175
- );
176
- if (!runningTransitions.get(event.propertyName)) {
177
- runningTransitions.delete(event.propertyName);
178
- }
179
- if (runningTransitions.size === 0) {
180
- cleanup();
181
- }
182
- };
183
- const handleTransitionrun = (event) => {
184
- if (event.target !== el) {
185
- return;
186
- }
187
- if (!runningTransitions.has(event.propertyName)) {
188
- runningTransitions.set(event.propertyName, 0);
189
- }
190
- runningTransitions.set(
191
- event.propertyName,
192
- runningTransitions.get(event.propertyName) + 1
193
- );
194
- cancelAnimationFrame(guarantee1);
195
- cancelAnimationFrame(guarantee2);
196
- cancelAnimationFrame(guarantee3);
197
- };
198
- el.addEventListener("transitionrun", handleTransitionrun, {
199
- signal: abortController.signal
200
- });
201
- el.addEventListener("transitionend", handleTransitionend, {
202
- signal: abortController.signal
203
- });
204
- el.addEventListener("transitioncancel", handleTransitionend, {
205
- signal: abortController.signal
206
- });
207
- action();
208
- };
209
- function nextFrame() {
210
- return new Promise((res) => requestAnimationFrame(() => res()));
211
- }
212
- class LuzmoAbstractOverlay extends base.LuzmoElement {
213
- constructor() {
214
- super(...arguments);
215
- this.dispose = noop;
216
- this.offset = 0;
217
- this.willPreventClose = false;
218
- }
219
- applyFocus(_targetOpenState, _focusEl) {
220
- return;
221
- }
222
- /* c8 ignore next 6 */
223
- get delayed() {
224
- return false;
225
- }
226
- set delayed(_delayed) {
227
- return;
228
- }
229
- /* c8 ignore next 6 */
230
- get disabled() {
231
- return false;
232
- }
233
- set disabled(_disabled) {
234
- return;
235
- }
236
- get elementResolver() {
237
- return this._elementResolver;
238
- }
239
- set elementResolver(controller) {
240
- this._elementResolver = controller;
241
- }
242
- /* c8 ignore next 3 */
243
- ensureOnDOM(_targetOpenState) {
244
- return;
245
- }
246
- /* c8 ignore next 5 */
247
- makeTransition(_targetOpenState) {
248
- return null;
249
- }
250
- manageDelay(_targetOpenState) {
251
- return;
252
- }
253
- /* c8 ignore next 3 */
254
- manageDialogOpen() {
255
- return;
256
- }
257
- /* c8 ignore next 3 */
258
- managePopoverOpen() {
259
- return;
260
- }
261
- /* c8 ignore next 3 */
262
- managePosition() {
263
- return;
264
- }
265
- /* c8 ignore next 6 */
266
- get open() {
267
- return false;
268
- }
269
- set open(_open) {
270
- return;
271
- }
272
- get placementController() {
273
- return this._placementController;
274
- }
275
- set placementController(controller) {
276
- this._placementController = controller;
277
- }
278
- requestSlottable() {
279
- }
280
- returnFocus() {
281
- return;
282
- }
283
- /* c8 ignore next 6 */
284
- get state() {
285
- return "closed";
286
- }
287
- set state(_state) {
288
- return;
289
- }
290
- /* c8 ignore next 3 */
291
- manuallyKeepOpen() {
292
- return;
293
- }
294
- static update() {
295
- const overlayUpdateEvent = new CustomEvent("luzmo-update-overlays", {
296
- bubbles: true,
297
- composed: true,
298
- cancelable: true
299
- });
300
- document.dispatchEvent(overlayUpdateEvent);
301
- }
302
- static async open(triggerOrContent, interactionOrOptions, content, optionsV1) {
303
- await Promise.resolve().then(() => overlay);
304
- const v2 = arguments.length === 2;
305
- const overlayContent = content || triggerOrContent;
306
- const overlay$1 = new this();
307
- let restored = false;
308
- const restoreContent = reparentChildren([overlayContent], overlay$1, {
309
- position: "beforeend",
310
- prepareCallback: (el) => {
311
- const slot = el.slot;
312
- el.removeAttribute("slot");
313
- return () => {
314
- el.slot = slot;
315
- };
316
- }
317
- });
318
- overlay$1.dispose = () => {
319
- overlay$1.addEventListener("luzmo-closed", () => {
320
- if (!restored) {
321
- restoreContent();
322
- restored = true;
323
- }
324
- requestAnimationFrame(() => {
325
- overlay$1.remove();
326
- });
327
- });
328
- overlay$1.open = false;
329
- overlay$1.dispose = noop;
330
- };
331
- const v1 = !v2 && overlayContent && optionsV1;
332
- if (v1) {
333
- const trigger = triggerOrContent;
334
- const interaction = interactionOrOptions;
335
- const options2 = optionsV1;
336
- LuzmoAbstractOverlay.applyOptions(overlay$1, {
337
- ...options2,
338
- delayed: options2.delayed || overlayContent.hasAttribute("delayed"),
339
- trigger: options2.virtualTrigger || trigger,
340
- type: interaction === "modal" ? "modal" : interaction === "hover" ? "hint" : "auto"
341
- });
342
- trigger.after(overlay$1);
343
- await overlay$1.updateComplete;
344
- overlay$1.open = true;
345
- return overlay$1.dispose;
346
- }
347
- const options = interactionOrOptions;
348
- overlay$1.append(overlayContent);
349
- LuzmoAbstractOverlay.applyOptions(overlay$1, {
350
- ...options,
351
- delayed: options.delayed || overlayContent.hasAttribute("delayed")
352
- });
353
- overlay$1.updateComplete.then(() => {
354
- overlay$1.open = true;
355
- });
356
- return overlay$1;
357
- }
358
- static applyOptions(overlay2, options) {
359
- overlay2.delayed = !!options.delayed;
360
- overlay2.receivesFocus = options.receivesFocus ?? "auto";
361
- overlay2.triggerElement = options.trigger || null;
362
- overlay2.type = options.type || "modal";
363
- overlay2.offset = options.offset ?? 0;
364
- overlay2.placement = options.placement;
365
- overlay2.willPreventClose = !!options.notImmediatelyClosable;
366
- }
367
- }
368
- const firstFocusableIn = (root) => {
369
- const firstFocusable = root.querySelector(
370
- focusableSelectors.userFocusableSelector
371
- );
372
- return firstFocusable;
373
- };
374
- const firstFocusableSlottedIn = (root) => {
375
- const firstFocusable = root.assignedElements().find((element) => element.matches(focusableSelectors.userFocusableSelector));
376
- return firstFocusable;
377
- };
378
- class BeforetoggleClosedEvent extends Event {
379
- constructor() {
380
- super("beforetoggle", {
381
- bubbles: false,
382
- composed: false
383
- });
384
- this.currentState = "open";
385
- this.newState = "closed";
386
- }
387
- }
388
- class BeforetoggleOpenEvent extends Event {
389
- constructor() {
390
- super("beforetoggle", {
391
- bubbles: false,
392
- composed: false
393
- });
394
- this.currentState = "closed";
395
- this.newState = "open";
396
- }
397
- }
398
- class OverlayStateEvent extends Event {
399
- constructor(type, overlay2, {
400
- publish,
401
- interaction,
402
- reason
403
- }) {
404
- super(type, {
405
- bubbles: publish,
406
- composed: publish
407
- });
408
- this.overlay = overlay2;
409
- this.detail = {
410
- interaction,
411
- reason
412
- };
413
- }
414
- }
415
- class VirtualTrigger {
416
- constructor(x, y) {
417
- this.x = 0;
418
- this.y = 0;
419
- this.x = x;
420
- this.y = y;
421
- }
422
- updateBoundingClientRect(x, y) {
423
- this.x = x;
424
- this.y = y;
425
- LuzmoAbstractOverlay.update();
426
- }
427
- getBoundingClientRect() {
428
- return {
429
- width: 0,
430
- height: 0,
431
- top: this.y,
432
- right: this.x,
433
- y: this.y,
434
- x: this.x,
435
- bottom: this.y,
436
- left: this.x,
437
- /* c8 ignore next 3 */
438
- toJSON() {
439
- return;
440
- }
441
- };
442
- }
443
- }
444
- function OverlayDialog(constructor) {
445
- class OverlayWithDialog extends constructor {
446
- async manageDialogOpen() {
447
- const targetOpenState = this.open;
448
- await nextFrame();
449
- await this.managePosition();
450
- if (this.open !== targetOpenState) {
451
- return;
452
- }
453
- const focusEl = await this.dialogMakeTransition(targetOpenState);
454
- if (this.open !== targetOpenState) {
455
- return;
456
- }
457
- await this.dialogApplyFocus(targetOpenState, focusEl);
458
- }
459
- dialogMakeTransition(targetOpenState) {
460
- let focusEl = null;
461
- const start = (el, index) => () => {
462
- el.open = targetOpenState;
463
- if (!targetOpenState) {
464
- const close = () => {
465
- el.removeEventListener("close", close);
466
- };
467
- el.addEventListener("close", close);
468
- }
469
- if (index > 0) {
470
- return;
471
- }
472
- const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
473
- this.dispatchEvent(new event());
474
- if (!targetOpenState) {
475
- return;
476
- }
477
- if (el.matches(focusableSelectors.userFocusableSelector)) {
478
- focusEl = el;
479
- }
480
- focusEl = focusEl || firstFocusableIn(el);
481
- if (!focusEl) {
482
- const childSlots = el.querySelectorAll("slot");
483
- childSlots.forEach((slot) => {
484
- if (!focusEl) {
485
- focusEl = firstFocusableSlottedIn(slot);
486
- }
487
- });
488
- }
489
- if (!this.isConnected || this.dialogEl.open) {
490
- return;
491
- }
492
- this.dialogEl.showModal();
493
- };
494
- const finish = (el, index) => () => {
495
- if (this.open !== targetOpenState) {
496
- return;
497
- }
498
- const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
499
- if (index > 0) {
500
- el.dispatchEvent(
501
- new OverlayStateEvent(eventName, this, {
502
- interaction: this.type,
503
- publish: false
504
- })
505
- );
506
- return;
507
- }
508
- if (!this.isConnected || targetOpenState !== this.open) {
509
- return;
510
- }
511
- const reportChange = async () => {
512
- const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
513
- this.dispatchEvent(
514
- new OverlayStateEvent(eventName, this, {
515
- interaction: this.type,
516
- publish: hasVirtualTrigger
517
- })
518
- );
519
- el.dispatchEvent(
520
- new OverlayStateEvent(eventName, this, {
521
- interaction: this.type,
522
- publish: false
523
- })
524
- );
525
- if (this.triggerElement && !hasVirtualTrigger) {
526
- this.triggerElement.dispatchEvent(
527
- new OverlayStateEvent(eventName, this, {
528
- interaction: this.type,
529
- publish: true
530
- })
531
- );
532
- }
533
- this.state = targetOpenState ? "opened" : "closed";
534
- this.returnFocus();
535
- await nextFrame();
536
- await nextFrame();
537
- if (targetOpenState === this.open && targetOpenState === false) {
538
- this.requestSlottable();
539
- }
540
- };
541
- if (!targetOpenState && this.dialogEl.open) {
542
- this.dialogEl.addEventListener(
543
- "close",
544
- () => {
545
- reportChange();
546
- },
547
- { once: true }
548
- );
549
- this.dialogEl.close();
550
- } else {
551
- reportChange();
552
- }
553
- };
554
- this.elements.forEach((el, index) => {
555
- guaranteedAllTransitionend(el, start(el, index), finish(el, index));
556
- });
557
- return focusEl;
558
- }
559
- dialogApplyFocus(targetOpenState, focusEl) {
560
- this.applyFocus(targetOpenState, focusEl);
561
- }
562
- }
563
- return OverlayWithDialog;
564
- }
565
- function OverlayNoPopover(constructor) {
566
- class OverlayWithNoPopover extends constructor {
567
- async managePopoverOpen() {
568
- await this.managePosition();
569
- }
570
- async manageDelay(targetOpenState) {
571
- if (targetOpenState === false || targetOpenState !== this.open) {
572
- overlayTimer.close(this);
573
- return;
574
- }
575
- if (this.delayed) {
576
- const cancelled = await overlayTimer.openTimer(this);
577
- if (cancelled) {
578
- this.open = !targetOpenState;
579
- }
580
- }
581
- }
582
- ensureOnDOM(_targetOpenState) {
583
- document.body.offsetHeight;
584
- }
585
- makeTransition(targetOpenState) {
586
- if (this.open !== targetOpenState) {
587
- return null;
588
- }
589
- let focusEl = null;
590
- const start = (el, index) => () => {
591
- if (targetOpenState !== this.open) {
592
- return;
593
- }
594
- el.open = targetOpenState;
595
- if (index === 0) {
596
- const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
597
- this.dispatchEvent(new event());
598
- }
599
- if (targetOpenState !== true) {
600
- return;
601
- }
602
- if (el.matches(focusableSelectors.userFocusableSelector)) {
603
- focusEl = el;
604
- }
605
- focusEl = focusEl || firstFocusableIn(el);
606
- if (focusEl) {
607
- return;
608
- }
609
- const childSlots = el.querySelectorAll("slot");
610
- childSlots.forEach((slot) => {
611
- if (!focusEl) {
612
- focusEl = firstFocusableSlottedIn(slot);
613
- }
614
- });
615
- };
616
- const finish = (el, index) => async () => {
617
- if (this.open !== targetOpenState) {
618
- return;
619
- }
620
- const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
621
- el.dispatchEvent(
622
- new OverlayStateEvent(eventName, this, {
623
- interaction: this.type
624
- })
625
- );
626
- if (index > 0) {
627
- return;
628
- }
629
- const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
630
- this.dispatchEvent(
631
- new OverlayStateEvent(eventName, this, {
632
- interaction: this.type,
633
- publish: hasVirtualTrigger
634
- })
635
- );
636
- if (this.triggerElement && !hasVirtualTrigger) {
637
- this.triggerElement.dispatchEvent(
638
- new OverlayStateEvent(eventName, this, {
639
- interaction: this.type,
640
- publish: true
641
- })
642
- );
643
- }
644
- this.state = targetOpenState ? "opened" : "closed";
645
- this.returnFocus();
646
- await nextFrame();
647
- await nextFrame();
648
- if (targetOpenState === this.open && targetOpenState === false) {
649
- this.requestSlottable();
650
- }
651
- };
652
- this.elements.forEach((el, index) => {
653
- guaranteedAllTransitionend(el, start(el, index), finish(el, index));
654
- });
655
- return focusEl;
656
- }
657
- }
658
- return OverlayWithNoPopover;
659
- }
660
- const supportsOverlayAuto = CSS.supports("(overlay: auto)");
661
- function isOpen(el) {
662
- let popoverOpen = false;
663
- try {
664
- popoverOpen = el.matches(":popover-open");
665
- } catch {
666
- }
667
- let open = false;
668
- try {
669
- open = el.matches(":open");
670
- } catch {
671
- }
672
- return popoverOpen || open;
673
- }
674
- function OverlayPopover(constructor) {
675
- class OverlayWithPopover extends constructor {
676
- async manageDelay(targetOpenState) {
677
- if (targetOpenState === false || targetOpenState !== this.open) {
678
- overlayTimer.close(this);
679
- return;
680
- }
681
- if (this.delayed) {
682
- const cancelled = await overlayTimer.openTimer(this);
683
- if (cancelled) {
684
- this.open = !targetOpenState;
685
- }
686
- }
687
- }
688
- /**
689
- * A popover should be hidden _after_ it is no longer on top-layer because
690
- * the position metrics will have changed from when it was originally positioned.
691
- */
692
- shouldHidePopover(targetOpenState) {
693
- if (targetOpenState && this.open !== targetOpenState) {
694
- return;
695
- }
696
- const update = async ({
697
- newState
698
- } = {}) => {
699
- if (newState === "open") {
700
- return;
701
- }
702
- await this.placementController.resetOverlayPosition();
703
- };
704
- if (!isOpen(this.dialogEl)) {
705
- update();
706
- return;
707
- }
708
- this.dialogEl.addEventListener("toggle", update, {
709
- once: true
710
- });
711
- }
712
- shouldShowPopover(targetOpenState) {
713
- let popoverOpen = false;
714
- try {
715
- popoverOpen = this.dialogEl.matches(":popover-open");
716
- } catch {
717
- }
718
- let open = false;
719
- try {
720
- open = this.dialogEl.matches(":open");
721
- } catch {
722
- }
723
- if (targetOpenState && this.open === targetOpenState && !popoverOpen && !open && this.isConnected) {
724
- this.dialogEl.showPopover();
725
- this.managePosition();
726
- }
727
- }
728
- async ensureOnDOM(targetOpenState) {
729
- if (!supportsOverlayAuto) {
730
- await this.shouldHidePopover(targetOpenState);
731
- }
732
- this.shouldShowPopover(targetOpenState);
733
- await nextFrame();
734
- }
735
- makeTransition(targetOpenState) {
736
- if (this.open !== targetOpenState) {
737
- return null;
738
- }
739
- let focusEl = null;
740
- const start = (el, index) => () => {
741
- el.open = targetOpenState;
742
- if (index === 0) {
743
- const event = targetOpenState ? BeforetoggleOpenEvent : BeforetoggleClosedEvent;
744
- this.dispatchEvent(new event());
745
- }
746
- if (!targetOpenState) {
747
- return;
748
- }
749
- if (el.matches(focusableSelectors.userFocusableSelector)) {
750
- focusEl = el;
751
- }
752
- focusEl = focusEl || firstFocusableIn(el);
753
- if (focusEl) {
754
- return;
755
- }
756
- const childSlots = el.querySelectorAll("slot");
757
- childSlots.forEach((slot) => {
758
- if (!focusEl) {
759
- focusEl = firstFocusableSlottedIn(slot);
760
- }
761
- });
762
- };
763
- const finish = (el, index) => () => {
764
- if (this.open !== targetOpenState) {
765
- return;
766
- }
767
- const eventName = targetOpenState ? "luzmo-opened" : "luzmo-closed";
768
- if (index > 0) {
769
- el.dispatchEvent(
770
- new OverlayStateEvent(eventName, this, {
771
- interaction: this.type,
772
- publish: false
773
- })
774
- );
775
- return;
776
- }
777
- const reportChange = async () => {
778
- if (this.open !== targetOpenState) {
779
- return;
780
- }
781
- await nextFrame();
782
- const hasVirtualTrigger = this.triggerElement instanceof VirtualTrigger;
783
- this.dispatchEvent(
784
- new OverlayStateEvent(eventName, this, {
785
- interaction: this.type,
786
- publish: hasVirtualTrigger
787
- })
788
- );
789
- el.dispatchEvent(
790
- new OverlayStateEvent(eventName, this, {
791
- interaction: this.type,
792
- publish: false
793
- })
794
- );
795
- if (this.triggerElement && !hasVirtualTrigger) {
796
- this.triggerElement.dispatchEvent(
797
- new OverlayStateEvent(eventName, this, {
798
- interaction: this.type,
799
- publish: true
800
- })
801
- );
802
- }
803
- this.state = targetOpenState ? "opened" : "closed";
804
- this.returnFocus();
805
- await nextFrame();
806
- await nextFrame();
807
- if (targetOpenState === this.open && targetOpenState === false) {
808
- this.requestSlottable();
809
- }
810
- };
811
- if (this.open !== targetOpenState) {
812
- return;
813
- }
814
- const open = isOpen(this.dialogEl);
815
- if (targetOpenState !== true && open && this.isConnected) {
816
- this.dialogEl.addEventListener(
817
- "beforetoggle",
818
- () => {
819
- reportChange();
820
- },
821
- { once: true }
822
- );
823
- this.dialogEl.hidePopover();
824
- } else {
825
- reportChange();
826
- }
827
- };
828
- this.elements.forEach((el, index) => {
829
- guaranteedAllTransitionend(el, start(el, index), finish(el, index));
830
- });
831
- return focusEl;
832
- }
833
- }
834
- return OverlayWithPopover;
835
- }
836
- const supportsPopover = typeof document !== "undefined" && "showPopover" in document.createElement("div");
837
- class OverlayStack {
838
- constructor() {
839
- this.root = typeof document === "undefined" ? null : document.body;
840
- this.stack = [];
841
- this.handleScroll = (event) => {
842
- if (typeof document !== "undefined" && event.target !== document && event.target !== document.documentElement && event.target !== document.body) {
843
- return;
844
- }
845
- this.stack.forEach((overlay2) => {
846
- if (overlay2.open) {
847
- if (overlay2.type === "auto" && overlay2.triggerElement instanceof HTMLElement && overlay2.triggerElement.closest(
848
- "luzmo-picker, luzmo-select, luzmo-action-menu"
849
- )) {
850
- event.stopPropagation();
851
- }
852
- if (typeof document !== "undefined") {
853
- document.dispatchEvent(
854
- new CustomEvent("luzmo-update-overlays", {
855
- bubbles: true,
856
- composed: true,
857
- cancelable: true
858
- })
859
- );
860
- }
861
- }
862
- });
863
- };
864
- this.handlePointerdown = (event) => {
865
- this.pointerdownPath = event.composedPath();
866
- this.lastOverlay = this.stack.at(-1);
867
- };
868
- this.handlePointerup = () => {
869
- const composedPath = this.pointerdownPath;
870
- this.pointerdownPath = void 0;
871
- if (this.stack.length === 0) {
872
- return;
873
- }
874
- if (!(composedPath == null ? void 0 : composedPath.length)) {
875
- return;
876
- }
877
- const lastOverlay = this.lastOverlay;
878
- this.lastOverlay = void 0;
879
- const lastIndex = this.stack.length - 1;
880
- const nonAncestorOverlays = this.stack.filter((overlay2, i) => {
881
- const inStack = composedPath.find(
882
- (el) => (
883
- // The Overlay is in the stack
884
- el === overlay2 || // The Overlay trigger is in the stack and the Overlay is a "hint"
885
- el === (overlay2 == null ? void 0 : overlay2.triggerElement) && (overlay2 == null ? void 0 : overlay2.type) === "hint" || // The last Overlay in the stack is not the last Overlay at `pointerdown` time and has a
886
- // `triggerInteraction` of "longpress", meaning it was opened by this poitner interaction
887
- i === lastIndex && overlay2 !== lastOverlay && overlay2.triggerInteraction === "longpress"
888
- )
889
- );
890
- return !inStack && !overlay2.shouldPreventClose() && overlay2.type !== "manual" && // Don't close if this overlay is modal and not on top of the overlay stack.
891
- !(overlay2.type === "modal" && lastOverlay !== overlay2);
892
- });
893
- nonAncestorOverlays.reverse();
894
- nonAncestorOverlays.forEach((overlay2) => {
895
- this.closeOverlay(overlay2);
896
- let parentToClose = overlay2.parentOverlayToForceClose;
897
- while (parentToClose) {
898
- this.closeOverlay(parentToClose);
899
- parentToClose = parentToClose.parentOverlayToForceClose;
900
- }
901
- });
902
- };
903
- this.handleBeforetoggle = (event) => {
904
- const { target, newState: open } = event;
905
- if (open === "open") {
906
- return;
907
- }
908
- this.closeOverlay(target);
909
- };
910
- this.handleKeydown = (event) => {
911
- if (event.code !== "Escape") {
912
- return;
913
- }
914
- if (this.stack.length === 0) {
915
- return;
916
- }
917
- const last = this.stack.at(-1);
918
- if ((last == null ? void 0 : last.type) === "page") {
919
- event.preventDefault();
920
- return;
921
- }
922
- if ((last == null ? void 0 : last.type) === "manual") {
923
- this.closeOverlay(last);
924
- return;
925
- }
926
- if (supportsPopover) {
927
- return;
928
- }
929
- if (!last) {
930
- return;
931
- }
932
- this.closeOverlay(last);
933
- };
934
- if (typeof document !== "undefined") {
935
- this.bindEvents();
936
- }
937
- }
938
- get document() {
939
- return this.root.ownerDocument || document;
940
- }
941
- bindEvents() {
942
- if (typeof document !== "undefined") {
943
- this.document.addEventListener("pointerdown", this.handlePointerdown);
944
- this.document.addEventListener("pointerup", this.handlePointerup);
945
- this.document.addEventListener("keydown", this.handleKeydown);
946
- this.document.addEventListener("scroll", this.handleScroll, {
947
- capture: true
948
- });
949
- }
950
- }
951
- closeOverlay(overlay2) {
952
- const overlayIndex = this.stack.indexOf(overlay2);
953
- if (overlayIndex !== -1) {
954
- this.stack.splice(overlayIndex, 1);
955
- }
956
- overlay2.open = false;
957
- }
958
- /**
959
- * Get an array of Overlays that all share the same trigger element.
960
- *
961
- * @param triggerElement {HTMLELement}
962
- * @returns
963
- */
964
- overlaysByTriggerElement(triggerElement) {
965
- return this.stack.filter(
966
- (overlay2) => overlay2.triggerElement === triggerElement
967
- );
968
- }
969
- /**
970
- * When overlays are added manage the open state of exisiting overlays appropriately:
971
- * - 'modal': should close other non-'modal' and non-'manual' overlays
972
- * - 'page': should close other non-'modal' and non-'manual' overlays
973
- * - 'auto': should close other 'auto' overlays and other 'hint' overlays, but not 'manual' overlays
974
- * - 'manual': shouldn't close other overlays
975
- * - 'hint': shouldn't close other overlays and give way to all other overlays on a trigger
976
- */
977
- add(overlay2) {
978
- if (this.stack.includes(overlay2)) {
979
- const overlayIndex = this.stack.indexOf(overlay2);
980
- if (overlayIndex !== -1) {
981
- this.stack.splice(overlayIndex, 1);
982
- this.stack.push(overlay2);
983
- }
984
- return;
985
- }
986
- if (overlay2.type === "auto" || overlay2.type === "modal" || overlay2.type === "page") {
987
- const queryPathEventName = "luzmo-overlay-query-path";
988
- const queryPathEvent = new Event(queryPathEventName, {
989
- composed: true,
990
- bubbles: true
991
- });
992
- overlay2.addEventListener(
993
- queryPathEventName,
994
- (event) => {
995
- const path = event.composedPath();
996
- this.stack.forEach((overlayEl) => {
997
- const inPath = path.find((el) => el === overlayEl);
998
- if (!inPath && overlayEl.type !== "manual" && overlayEl.type !== "modal") {
999
- this.closeOverlay(overlayEl);
1000
- }
1001
- });
1002
- },
1003
- { once: true }
1004
- );
1005
- overlay2.dispatchEvent(queryPathEvent);
1006
- } else if (overlay2.type === "hint") {
1007
- const hasPrevious = this.stack.some(
1008
- (overlayEl) => overlayEl.type !== "manual" && overlayEl.triggerElement && overlayEl.triggerElement === overlay2.triggerElement
1009
- );
1010
- if (hasPrevious) {
1011
- overlay2.open = false;
1012
- return;
1013
- }
1014
- this.stack.forEach((overlayEl) => {
1015
- if (overlayEl.type === "hint") {
1016
- this.closeOverlay(overlayEl);
1017
- }
1018
- });
1019
- }
1020
- requestAnimationFrame(() => {
1021
- this.stack.push(overlay2);
1022
- overlay2.addEventListener("beforetoggle", this.handleBeforetoggle, {
1023
- once: true
1024
- });
1025
- });
1026
- }
1027
- remove(overlay2) {
1028
- this.closeOverlay(overlay2);
1029
- }
1030
- }
1031
- const overlayStack = new OverlayStack();
1032
- const styles = ':host{display:contents;pointer-events:none;--luzmo-overlay-animation-distance: .5rem}:host(:has(> luzmo-tooltip)){--luzmo-overlay-animation-distance: var( --luzmo-tooltip-animation-distance, 4px )}.dialog{margin:0;border:0;background:none;padding:0;position:fixed;overflow:visible;opacity:1!important;box-sizing:border-box;max-height:calc(100vh - 16px);max-height:calc(100dvh - 16px);max-width:calc(100vw - 16px);height:auto;inset:auto;top:0;left:0;display:flex;--luzmo-overlay-open: true}.dialog:not([is-visible]){display:none}.dialog:focus{outline:none}dialog:modal{--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}:host(:not([open])) .dialog{--luzmo-overlay-open: false}.dialog::backdrop{display:none}.dialog:before{position:absolute;top:-999em;right:-999em;bottom:-999em;left:-999em;content:"";pointer-events:auto!important}.dialog:not(.not-immediately-closable):before{display:none}.dialog>div{width:100%}::slotted(*){pointer-events:auto;visibility:visible!important}::slotted(luzmo-popover){position:static}.dialog:not([actual-placement])[placement*=top]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:var(--luzmo-overlay-animation-distance)}.dialog:not([actual-placement])[placement*=right]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=bottom]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog:not([actual-placement])[placement*=left]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:var(--luzmo-overlay-animation-distance)}.dialog[actual-placement*=top]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:var(--luzmo-overlay-animation-distance)}.dialog[actual-placement*=right]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog[actual-placement*=bottom]{padding-block:var(--luzmo-overlay-animation-distance);margin-top:calc(-1 * var(--luzmo-overlay-animation-distance))}.dialog[actual-placement*=left]{padding-inline:var(--luzmo-overlay-animation-distance);margin-left:var(--luzmo-overlay-animation-distance)}slot[name=longpress-describedby-descriptor]{display:none}@supports selector(:open){.dialog{opacity:0}.dialog:open{opacity:1;--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}}@supports selector(:popover-open){.dialog{opacity:0}.dialog:popover-open{opacity:1;--luzmo-popover-filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, .15))}}@supports (overlay: auto){.dialog{display:none;transition:all var(--luzmo-overlay-animation-duration, .13s),translate 0s,display var(--luzmo-overlay-animation-duration, .13s);transition-behavior:allow-discrete}.dialog:popover-open,.dialog:modal{display:flex}}@supports (not selector(:open)) and (not selector(:popover-open)){:host:not([open]) .dialog{pointer-events:none}.dialog[actual-placement]{z-index:calc(var(--luzmo-overlay-z-index-base, 1000) + var(--luzmo-overlay-open-count))}}';
1033
- function roundByDPR(num) {
1034
- if (num === void 0) {
1035
- return 0;
1036
- }
1037
- const dpr = window.devicePixelRatio || 1;
1038
- return Math.round(num * dpr) / dpr;
1039
- }
1040
- const REQUIRED_DISTANCE_TO_EDGE = 8;
1041
- const MIN_OVERLAY_HEIGHT = 100;
1042
- const getFallbackPlacements = (placement) => {
1043
- const fallbacks = {
1044
- left: ["right", "bottom", "top"],
1045
- "left-start": ["right-start", "bottom", "top"],
1046
- "left-end": ["right-end", "bottom", "top"],
1047
- right: ["left", "bottom", "top"],
1048
- "right-start": ["left-start", "bottom", "top"],
1049
- "right-end": ["left-end", "bottom", "top"],
1050
- top: ["bottom", "left", "right"],
1051
- "top-start": ["bottom-start", "left", "right"],
1052
- "top-end": ["bottom-end", "left", "right"],
1053
- bottom: ["top", "left", "right"],
1054
- "bottom-start": ["top-start", "left", "right"],
1055
- "bottom-end": ["top-end", "left", "right"]
1056
- };
1057
- return fallbacks[placement] ?? [placement];
1058
- };
1059
- const placementUpdatedSymbol = Symbol("placement updated");
1060
- class PlacementController {
1061
- /**
1062
- * Creates an instance of the PlacementController.
1063
- *
1064
- * @param host - The host element that uses this controller.
1065
- */
1066
- constructor(host) {
1067
- this.originalPlacements = /* @__PURE__ */ new WeakMap();
1068
- this.allowPlacementUpdate = false;
1069
- this.closeForAncestorUpdate = () => {
1070
- if (!this.allowPlacementUpdate && this.options.type !== "modal" && this.cleanup) {
1071
- this.target.dispatchEvent(new Event("close", { bubbles: true }));
1072
- }
1073
- this.allowPlacementUpdate = false;
1074
- };
1075
- this.updatePlacement = () => {
1076
- this.computePlacement();
1077
- };
1078
- this.resetOverlayPosition = () => {
1079
- if (!this.target || !this.options) {
1080
- return;
1081
- }
1082
- this.clearOverlayPosition();
1083
- this.host.offsetHeight;
1084
- this.computePlacement();
1085
- };
1086
- this.host = host;
1087
- this.host.addController(this);
1088
- }
1089
- /**
1090
- * Places the overlay relative to the target element.
1091
- *
1092
- * This method sets up the necessary configurations and event listeners to manage the
1093
- * positioning and constraints of the overlay element.
1094
- *
1095
- * @param [target=this.target] - The target element for the overlay.
1096
- * @param [options=this.options] - The options for configuring the overlay placement.
1097
- * @returns A promise that resolves when the overlay has been placed.
1098
- */
1099
- placeOverlay(target = this.target, options = this.options) {
1100
- this.target = target;
1101
- this.options = options;
1102
- if (!target || !options) {
1103
- return;
1104
- }
1105
- const cleanupAncestorResize = dom.autoUpdate(
1106
- options.trigger,
1107
- target,
1108
- this.closeForAncestorUpdate,
1109
- {
1110
- ancestorResize: false,
1111
- elementResize: false,
1112
- layoutShift: false
1113
- }
1114
- );
1115
- const cleanupElementResize = dom.autoUpdate(
1116
- options.trigger,
1117
- target,
1118
- this.updatePlacement,
1119
- {
1120
- ancestorScroll: false
1121
- }
1122
- );
1123
- this.cleanup = () => {
1124
- var _a2;
1125
- (_a2 = this.host.elements) == null ? void 0 : _a2.forEach((element) => {
1126
- element.addEventListener(
1127
- "luzmo-closed",
1128
- () => {
1129
- const placement = this.originalPlacements.get(element);
1130
- if (placement) {
1131
- element.setAttribute("placement", placement);
1132
- }
1133
- this.originalPlacements.delete(element);
1134
- },
1135
- { once: true }
1136
- );
1137
- });
1138
- cleanupAncestorResize();
1139
- cleanupElementResize();
1140
- };
1141
- }
1142
- /**
1143
- * Computes the placement of the overlay relative to the target element.
1144
- *
1145
- * This method calculates the necessary positioning and constraints for the overlay element
1146
- * using various middleware functions. It updates the overlay's style and attributes based
1147
- * on the computed position.
1148
- *
1149
- * @returns A promise that resolves when the placement has been computed.
1150
- */
1151
- async computePlacement() {
1152
- var _a2, _b;
1153
- const { options, target } = this;
1154
- await (document.fonts ? document.fonts.ready : Promise.resolve());
1155
- const flipMiddleware = options.trigger instanceof HTMLElement ? dom.flip() : dom.flip({
1156
- padding: REQUIRED_DISTANCE_TO_EDGE,
1157
- fallbackPlacements: getFallbackPlacements(options.placement)
1158
- });
1159
- const [mainAxis = 0, crossAxis = 0] = Array.isArray(options == null ? void 0 : options.offset) ? options.offset : [options.offset, 0];
1160
- const tipElement = (_a2 = this.host.elements.find(
1161
- (el) => el.tipElement
1162
- )) == null ? void 0 : _a2.tipElement;
1163
- const middleware = [
1164
- dom.offset({
1165
- mainAxis,
1166
- crossAxis
1167
- }),
1168
- dom.shift({ padding: REQUIRED_DISTANCE_TO_EDGE }),
1169
- flipMiddleware,
1170
- dom.size({
1171
- padding: REQUIRED_DISTANCE_TO_EDGE,
1172
- apply: ({ availableWidth, availableHeight, rects: { floating } }) => {
1173
- const maxHeight = Math.max(
1174
- MIN_OVERLAY_HEIGHT,
1175
- Math.floor(availableHeight)
1176
- );
1177
- const actualHeight = floating.height;
1178
- this.initialHeight = this.isConstrained ? this.initialHeight || actualHeight : actualHeight;
1179
- this.isConstrained = actualHeight < this.initialHeight || maxHeight <= actualHeight;
1180
- const appliedHeight = this.isConstrained ? `${maxHeight}px` : "";
1181
- Object.assign(target.style, {
1182
- maxWidth: `${Math.floor(availableWidth)}px`,
1183
- maxHeight: appliedHeight
1184
- });
1185
- }
1186
- }),
1187
- ...tipElement ? [
1188
- dom.arrow({
1189
- element: tipElement,
1190
- padding: options.tipPadding || REQUIRED_DISTANCE_TO_EDGE
1191
- })
1192
- ] : []
1193
- ];
1194
- const { x, y, placement, middlewareData } = await dom.computePosition(
1195
- options.trigger,
1196
- target,
1197
- {
1198
- placement: options.placement,
1199
- middleware,
1200
- strategy: "fixed"
1201
- }
1202
- );
1203
- Object.assign(target.style, {
1204
- top: "0px",
1205
- left: "0px",
1206
- translate: `${roundByDPR(x)}px ${roundByDPR(y)}px`
1207
- });
1208
- target.setAttribute("actual-placement", placement);
1209
- (_b = this.host.elements) == null ? void 0 : _b.forEach((element) => {
1210
- if (!this.originalPlacements.has(element)) {
1211
- this.originalPlacements.set(
1212
- element,
1213
- element.getAttribute("placement")
1214
- );
1215
- }
1216
- element.setAttribute("placement", placement);
1217
- });
1218
- if (tipElement && middlewareData.arrow) {
1219
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
1220
- Object.assign(tipElement.style, {
1221
- top: placement.startsWith("right") || placement.startsWith("left") ? "0px" : "",
1222
- left: placement.startsWith("bottom") || placement.startsWith("top") ? "0px" : "",
1223
- translate: `${roundByDPR(arrowX)}px ${roundByDPR(arrowY)}px`
1224
- });
1225
- }
1226
- }
1227
- /**
1228
- * Clears the overlay's position styles.
1229
- *
1230
- * This method removes the max-height and max-width styles from the target element,
1231
- * and resets the initial height and constrained state of the overlay.
1232
- */
1233
- clearOverlayPosition() {
1234
- if (!this.target) {
1235
- return;
1236
- }
1237
- this.target.style.removeProperty("max-height");
1238
- this.target.style.removeProperty("max-width");
1239
- this.initialHeight = void 0;
1240
- this.isConstrained = false;
1241
- }
1242
- /**
1243
- * Lifecycle method called when the host element is connected to the DOM.
1244
- *
1245
- * This method sets up an event listener to reset the overlay's position when the 'luzmo-update-overlays' event is dispatched.
1246
- */
1247
- hostConnected() {
1248
- document.addEventListener(
1249
- "luzmo-update-overlays",
1250
- this.resetOverlayPosition
1251
- );
1252
- }
1253
- /**
1254
- * Lifecycle method called when the host element is updated.
1255
- *
1256
- * This method cleans up resources if the overlay is not open.
1257
- */
1258
- hostUpdated() {
1259
- var _a2;
1260
- if (!this.host.open) {
1261
- (_a2 = this.cleanup) == null ? void 0 : _a2.call(this);
1262
- this.cleanup = void 0;
1263
- }
1264
- }
1265
- /**
1266
- * Lifecycle method called when the host element is disconnected from the DOM.
1267
- *
1268
- * This method removes the event listener and cleans up resources.
1269
- */
1270
- hostDisconnected() {
1271
- var _a2;
1272
- (_a2 = this.cleanup) == null ? void 0 : _a2.call(this);
1273
- this.cleanup = void 0;
1274
- document.removeEventListener(
1275
- "luzmo-update-overlays",
1276
- this.resetOverlayPosition
1277
- );
1278
- }
1279
- }
1280
- var InteractionTypes = /* @__PURE__ */ ((InteractionTypes2) => {
1281
- InteractionTypes2["click"] = "click";
1282
- InteractionTypes2["hover"] = "hover";
1283
- InteractionTypes2["longpress"] = "longpress";
1284
- return InteractionTypes2;
1285
- })(InteractionTypes || {});
1286
- const lastInteractionType = Symbol("lastInteractionType");
1287
- const SAFARI_FOCUS_RING_CLASS = "remove-focus-ring-safari-hack";
1288
- class InteractionController {
1289
- constructor(target, { overlay: overlay2, isPersistent, handleOverlayReady }) {
1290
- this.target = target;
1291
- this.isLazilyOpen = false;
1292
- this.isPersistent = false;
1293
- this.isPersistent = !!isPersistent;
1294
- this.handleOverlayReady = handleOverlayReady;
1295
- if (this.isPersistent) {
1296
- this.init();
1297
- }
1298
- this.overlay = overlay2;
1299
- }
1300
- get activelyOpening() {
1301
- return false;
1302
- }
1303
- get open() {
1304
- var _a2;
1305
- return ((_a2 = this.overlay) == null ? void 0 : _a2.open) ?? this.isLazilyOpen;
1306
- }
1307
- /**
1308
- * Set `open` against the associated Overlay lazily.
1309
- */
1310
- set open(open) {
1311
- if (open === this.open) {
1312
- return;
1313
- }
1314
- this.isLazilyOpen = open;
1315
- if (this.overlay) {
1316
- this.overlay.open = open;
1317
- this.target[lastInteractionType] = this.type;
1318
- return;
1319
- }
1320
- if (!open) {
1321
- return;
1322
- }
1323
- customElements.whenDefined("luzmo-overlay").then(async () => {
1324
- const { LuzmoOverlay: LuzmoOverlay2 } = await Promise.resolve().then(() => overlay);
1325
- this.overlay = new LuzmoOverlay2();
1326
- this.overlay.open = true;
1327
- this.target[lastInteractionType] = this.type;
1328
- });
1329
- Promise.resolve().then(() => overlay);
1330
- }
1331
- get overlay() {
1332
- return this._overlay;
1333
- }
1334
- set overlay(overlay2) {
1335
- var _a2;
1336
- if (!overlay2) {
1337
- return;
1338
- }
1339
- if (this.overlay === overlay2) {
1340
- return;
1341
- }
1342
- if (this.overlay) {
1343
- this.overlay.removeController(this);
1344
- }
1345
- this._overlay = overlay2;
1346
- this.overlay.addController(this);
1347
- this.initOverlay();
1348
- this.prepareDescription(this.target);
1349
- (_a2 = this.handleOverlayReady) == null ? void 0 : _a2.call(this, this.overlay);
1350
- }
1351
- prepareDescription(_) {
1352
- }
1353
- releaseDescription() {
1354
- }
1355
- shouldCompleteOpen() {
1356
- }
1357
- /* c8 ignore next 3 */
1358
- init() {
1359
- }
1360
- /* c8 ignore next 3 */
1361
- initOverlay() {
1362
- }
1363
- abort() {
1364
- var _a2;
1365
- this.releaseDescription();
1366
- (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1367
- }
1368
- hostConnected() {
1369
- this.init();
1370
- }
1371
- hostDisconnected() {
1372
- if (!this.isPersistent) {
1373
- this.abort();
1374
- }
1375
- }
1376
- }
1377
- class ClickController extends InteractionController {
1378
- constructor() {
1379
- super(...arguments);
1380
- this.type = InteractionTypes.click;
1381
- this.preventNextToggle = false;
1382
- }
1383
- handleClick() {
1384
- if (!this.preventNextToggle) {
1385
- this.open = !this.open;
1386
- }
1387
- this.preventNextToggle = false;
1388
- }
1389
- handlePointerdown() {
1390
- this.preventNextToggle = this.open;
1391
- }
1392
- init() {
1393
- var _a2;
1394
- (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1395
- this.abortController = new AbortController();
1396
- const { signal } = this.abortController;
1397
- this.target.addEventListener("click", () => this.handleClick(), {
1398
- signal
1399
- });
1400
- this.target.addEventListener(
1401
- "pointerdown",
1402
- () => this.handlePointerdown(),
1403
- { signal }
1404
- );
1405
- }
1406
- }
1407
- const HOVER_DELAY = 300;
1408
- class HoverController extends InteractionController {
1409
- constructor() {
1410
- super(...arguments);
1411
- this.type = InteractionTypes.hover;
1412
- this.elementIds = [];
1413
- this.focusedin = false;
1414
- this.pointerentered = false;
1415
- }
1416
- handleKeyup(event) {
1417
- if (event.code === "Tab" || event.code === "Escape") {
1418
- this.open = true;
1419
- this.removeSafariFocusRingClass();
1420
- }
1421
- }
1422
- handleTargetFocusin() {
1423
- if (!this.target.matches(":focus-visible")) {
1424
- return;
1425
- }
1426
- if (platform.isWebKit() && this.target[lastInteractionType] === InteractionTypes.click) {
1427
- this.target.classList.add(SAFARI_FOCUS_RING_CLASS);
1428
- return;
1429
- }
1430
- this.open = true;
1431
- this.focusedin = true;
1432
- this.removeSafariFocusRingClass();
1433
- }
1434
- handleTargetFocusout() {
1435
- this.removeSafariFocusRingClass();
1436
- this.focusedin = false;
1437
- if (this.pointerentered) {
1438
- return;
1439
- }
1440
- this.open = false;
1441
- }
1442
- handleTargetPointerenter() {
1443
- var _a2;
1444
- if (this.hoverTimeout) {
1445
- clearTimeout(this.hoverTimeout);
1446
- this.hoverTimeout = void 0;
1447
- }
1448
- if ((_a2 = this.overlay) == null ? void 0 : _a2.disabled) {
1449
- return;
1450
- }
1451
- this.open = true;
1452
- this.pointerentered = true;
1453
- }
1454
- handleTargetPointerleave() {
1455
- this.doPointerleave();
1456
- }
1457
- // set a timeout once the pointer enters and the overlay is shown
1458
- // give the user time to enter the overlay
1459
- handleHostPointerenter() {
1460
- if (this.hoverTimeout) {
1461
- clearTimeout(this.hoverTimeout);
1462
- this.hoverTimeout = void 0;
1463
- }
1464
- }
1465
- handleHostPointerleave() {
1466
- this.doPointerleave();
1467
- }
1468
- prepareDescription() {
1469
- if (this.overlay.elements.length === 0) {
1470
- return;
1471
- }
1472
- const triggerRoot = this.target.getRootNode();
1473
- const contentRoot = this.overlay.elements[0].getRootNode();
1474
- const overlayRoot = this.overlay.getRootNode();
1475
- if (triggerRoot === overlayRoot) {
1476
- this.prepareOverlayRelativeDescription();
1477
- } else if (triggerRoot === contentRoot) {
1478
- this.prepareContentRelativeDescription();
1479
- }
1480
- }
1481
- prepareOverlayRelativeDescription() {
1482
- const releaseDescription = conditionAttributeWithId.conditionAttributeWithId(
1483
- this.target,
1484
- "aria-describedby",
1485
- [this.overlay.id]
1486
- );
1487
- this.releaseDescription = () => {
1488
- releaseDescription();
1489
- this.releaseDescription = noop;
1490
- };
1491
- }
1492
- prepareContentRelativeDescription() {
1493
- const elementIds = [];
1494
- const appliedIds = this.overlay.elements.map((el) => {
1495
- elementIds.push(el.id);
1496
- if (!el.id) {
1497
- el.id = `${this.overlay.tagName.toLowerCase()}-helper-${randomId.randomID()}`;
1498
- }
1499
- return el.id;
1500
- });
1501
- this.elementIds = elementIds;
1502
- const releaseDescription = conditionAttributeWithId.conditionAttributeWithId(
1503
- this.target,
1504
- "aria-describedby",
1505
- appliedIds
1506
- );
1507
- this.releaseDescription = () => {
1508
- releaseDescription();
1509
- this.overlay.elements.map((el, index) => {
1510
- el.id = this.elementIds[index];
1511
- });
1512
- this.releaseDescription = noop;
1513
- };
1514
- }
1515
- doPointerleave() {
1516
- this.pointerentered = false;
1517
- const triggerElement = this.target;
1518
- if (this.focusedin && triggerElement.matches(":focus-visible")) {
1519
- return;
1520
- }
1521
- this.hoverTimeout = setTimeout(() => {
1522
- this.open = false;
1523
- }, HOVER_DELAY);
1524
- }
1525
- init() {
1526
- var _a2;
1527
- (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1528
- this.abortController = new AbortController();
1529
- const { signal } = this.abortController;
1530
- this.target.addEventListener("keyup", (event) => this.handleKeyup(event), {
1531
- signal
1532
- });
1533
- this.target.addEventListener("focusin", () => this.handleTargetFocusin(), {
1534
- signal
1535
- });
1536
- this.target.addEventListener(
1537
- "focusout",
1538
- () => this.handleTargetFocusout(),
1539
- { signal }
1540
- );
1541
- this.target.addEventListener(
1542
- "pointerenter",
1543
- () => this.handleTargetPointerenter(),
1544
- { signal }
1545
- );
1546
- this.target.addEventListener(
1547
- "pointerleave",
1548
- () => this.handleTargetPointerleave(),
1549
- { signal }
1550
- );
1551
- if (this.overlay) {
1552
- this.initOverlay();
1553
- }
1554
- }
1555
- initOverlay() {
1556
- if (!this.abortController) {
1557
- return;
1558
- }
1559
- const { signal } = this.abortController;
1560
- this.overlay.addEventListener(
1561
- "pointerenter",
1562
- () => this.handleHostPointerenter(),
1563
- { signal }
1564
- );
1565
- this.overlay.addEventListener(
1566
- "pointerleave",
1567
- () => this.handleHostPointerleave(),
1568
- { signal }
1569
- );
1570
- }
1571
- removeSafariFocusRingClass() {
1572
- if (platform.isWebKit() && this.target.classList.contains(SAFARI_FOCUS_RING_CLASS))
1573
- this.target.classList.remove(SAFARI_FOCUS_RING_CLASS);
1574
- }
1575
- }
1576
- const longPressDuration = 300;
1577
- const LONGPRESS_INSTRUCTIONS = {
1578
- touch: "Double tap and long press for additional options",
1579
- keyboard: "Press Space or Alt+Down Arrow for additional options",
1580
- mouse: "Click and hold for additional options"
1581
- };
1582
- class LongpressController extends InteractionController {
1583
- constructor() {
1584
- super(...arguments);
1585
- this.type = InteractionTypes.longpress;
1586
- this.longpressState = null;
1587
- this.releaseDescription = noop;
1588
- this.handlePointerup = () => {
1589
- var _a2;
1590
- clearTimeout(this.timeout);
1591
- if (!this.target) {
1592
- return;
1593
- }
1594
- this.longpressState = ((_a2 = this.overlay) == null ? void 0 : _a2.state) === "opening" ? "pressed" : null;
1595
- document.removeEventListener("pointerup", this.handlePointerup);
1596
- document.removeEventListener("pointercancel", this.handlePointerup);
1597
- };
1598
- }
1599
- get activelyOpening() {
1600
- return this.longpressState === "opening" || this.longpressState === "pressed";
1601
- }
1602
- handleLongpress() {
1603
- this.open = true;
1604
- this.longpressState = this.longpressState === "potential" ? "opening" : "pressed";
1605
- }
1606
- handlePointerdown(event) {
1607
- if (!this.target) {
1608
- return;
1609
- }
1610
- if (event.button !== 0) {
1611
- return;
1612
- }
1613
- this.longpressState = "potential";
1614
- document.addEventListener("pointerup", this.handlePointerup);
1615
- document.addEventListener("pointercancel", this.handlePointerup);
1616
- const triggerHandlesLongpress = "holdAffordance" in this.target;
1617
- if (triggerHandlesLongpress) {
1618
- return;
1619
- }
1620
- this.timeout = setTimeout(() => {
1621
- if (!this.target) {
1622
- return;
1623
- }
1624
- this.target.dispatchEvent(
1625
- new CustomEvent("longpress", {
1626
- bubbles: true,
1627
- composed: true,
1628
- detail: {
1629
- source: "pointer"
1630
- }
1631
- })
1632
- );
1633
- }, longPressDuration);
1634
- }
1635
- handleKeydown(event) {
1636
- const { code, altKey } = event;
1637
- if (altKey && code === "ArrowDown") {
1638
- event.stopPropagation();
1639
- event.stopImmediatePropagation();
1640
- }
1641
- }
1642
- handleKeyup(event) {
1643
- const { code, altKey } = event;
1644
- if (code === "Space" || altKey && code === "ArrowDown") {
1645
- if (!this.target) {
1646
- return;
1647
- }
1648
- event.stopPropagation();
1649
- this.target.dispatchEvent(
1650
- new CustomEvent("longpress", {
1651
- bubbles: true,
1652
- composed: true,
1653
- detail: {
1654
- source: "keyboard"
1655
- }
1656
- })
1657
- );
1658
- setTimeout(() => {
1659
- this.longpressState = null;
1660
- });
1661
- }
1662
- }
1663
- prepareDescription(trigger) {
1664
- if (
1665
- // do not reapply until target is recycled
1666
- this.releaseDescription !== noop || // require "longpress content" to apply relationship
1667
- this.overlay.elements.length === 0
1668
- ) {
1669
- return;
1670
- }
1671
- const longpressDescription = document.createElement("div");
1672
- longpressDescription.id = `longpress-describedby-descriptor-${randomId.randomID()}`;
1673
- const messageType = platform.isIOS() || platform.isAndroid() ? "touch" : "keyboard";
1674
- longpressDescription.textContent = LONGPRESS_INSTRUCTIONS[messageType];
1675
- longpressDescription.slot = "longpress-describedby-descriptor";
1676
- const triggerParent = trigger.getRootNode();
1677
- const overlayParent = this.overlay.getRootNode();
1678
- if (triggerParent === overlayParent) {
1679
- this.overlay.append(longpressDescription);
1680
- } else {
1681
- longpressDescription.hidden = !("host" in triggerParent);
1682
- trigger.after(longpressDescription);
1683
- }
1684
- const releaseDescription = conditionAttributeWithId.conditionAttributeWithId(
1685
- trigger,
1686
- "aria-describedby",
1687
- [longpressDescription.id]
1688
- );
1689
- this.releaseDescription = () => {
1690
- releaseDescription();
1691
- longpressDescription.remove();
1692
- this.releaseDescription = noop;
1693
- };
1694
- }
1695
- shouldCompleteOpen() {
1696
- this.longpressState = this.longpressState === "pressed" ? null : this.longpressState;
1697
- }
1698
- init() {
1699
- var _a2;
1700
- (_a2 = this.abortController) == null ? void 0 : _a2.abort();
1701
- this.abortController = new AbortController();
1702
- const { signal } = this.abortController;
1703
- this.target.addEventListener("longpress", () => this.handleLongpress(), {
1704
- signal
1705
- });
1706
- this.target.addEventListener(
1707
- "pointerdown",
1708
- (event) => this.handlePointerdown(event),
1709
- { signal }
1710
- );
1711
- this.prepareDescription(this.target);
1712
- if (this.target.holdAffordance) {
1713
- return;
1714
- }
1715
- this.target.addEventListener(
1716
- "keydown",
1717
- (event) => this.handleKeydown(event),
1718
- { signal }
1719
- );
1720
- this.target.addEventListener(
1721
- "keyup",
1722
- (event) => this.handleKeyup(event),
1723
- { signal }
1724
- );
1725
- }
1726
- }
1727
- const strategies = {
1728
- click: ClickController,
1729
- longpress: LongpressController,
1730
- hover: HoverController
1731
- };
1732
- var __defProp = Object.defineProperty;
1733
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1734
- var __decorateClass = (decorators, target, key, kind) => {
1735
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
1736
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1737
- if (decorator = decorators[i])
1738
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
1739
- if (kind && result) __defProp(target, key, result);
1740
- return result;
1741
- };
1742
- const browserSupportsPopover = typeof document !== "undefined" && "showPopover" in document.createElement("div");
1743
- let ComputedOverlayBase = OverlayDialog(LuzmoAbstractOverlay);
1744
- ComputedOverlayBase = browserSupportsPopover ? OverlayPopover(ComputedOverlayBase) : OverlayNoPopover(ComputedOverlayBase);
1745
- const _LuzmoOverlay = (_a = class extends ComputedOverlayBase {
1746
- constructor() {
1747
- super(...arguments);
1748
- this._delayed = false;
1749
- this._disabled = false;
1750
- this.offset = 0;
1751
- this._open = false;
1752
- this.lastRequestSlottableState = false;
1753
- this.receivesFocus = "auto";
1754
- this._state = "closed";
1755
- this.triggerElement = null;
1756
- this.type = "auto";
1757
- this.wasOpen = false;
1758
- this.closeOnFocusOut = (event) => {
1759
- if (!event.relatedTarget) {
1760
- return;
1761
- }
1762
- const relationEvent = new Event("overlay-relation-query", {
1763
- bubbles: true,
1764
- composed: true
1765
- });
1766
- event.relatedTarget.addEventListener(relationEvent.type, (e) => {
1767
- const path = e.composedPath();
1768
- const isWithinOverlay = path.includes(this);
1769
- if (!isWithinOverlay) {
1770
- this.open = false;
1771
- }
1772
- });
1773
- event.relatedTarget.dispatchEvent(relationEvent);
1774
- };
1775
- }
1776
- get delayed() {
1777
- var _a2;
1778
- return ((_a2 = this.elements.at(-1)) == null ? void 0 : _a2.hasAttribute("delayed")) || this._delayed;
1779
- }
1780
- set delayed(delayed) {
1781
- this._delayed = delayed;
1782
- }
1783
- get disabled() {
1784
- return this._disabled;
1785
- }
1786
- set disabled(disabled) {
1787
- var _a2;
1788
- this._disabled = disabled;
1789
- if (disabled) {
1790
- (_a2 = this.strategy) == null ? void 0 : _a2.abort();
1791
- this.wasOpen = this.open;
1792
- this.open = false;
1793
- } else {
1794
- this.bindEvents();
1795
- this.open = this.open || this.wasOpen;
1796
- this.wasOpen = false;
1797
- }
1798
- }
1799
- /**
1800
- * Determines if the overlay has a non-virtual trigger element.
1801
- *
1802
- * @returns `true` if the trigger element is not a virtual trigger, otherwise `false`.
1803
- */
1804
- get hasNonVirtualTrigger() {
1805
- return !!this.triggerElement && !(this.triggerElement instanceof VirtualTrigger);
1806
- }
1807
- /**
1808
- * Provides an instance of the `PlacementController` for managing the positioning
1809
- * of the overlay relative to its trigger element.
1810
- *
1811
- * If the `PlacementController` instance does not already exist, it is created and
1812
- * assigned to the `_placementController` property.
1813
- *
1814
- * @protected
1815
- * @returns The `PlacementController` instance.
1816
- */
1817
- get placementController() {
1818
- if (!this._placementController) {
1819
- this._placementController = new PlacementController(this);
1820
- }
1821
- return this._placementController;
1822
- }
1823
- get open() {
1824
- return this._open;
1825
- }
1826
- set open(open) {
1827
- var _a2;
1828
- if (open && this.disabled) {
1829
- return;
1830
- }
1831
- if (open === this.open) {
1832
- return;
1833
- }
1834
- if (((_a2 = this.strategy) == null ? void 0 : _a2.activelyOpening) && !open) {
1835
- return;
1836
- }
1837
- this._open = open;
1838
- if (this.open) {
1839
- _a.openCount += 1;
1840
- }
1841
- this.requestUpdate("open", !this.open);
1842
- if (this.open) {
1843
- this.requestSlottable();
1844
- }
1845
- }
1846
- get state() {
1847
- return this._state;
1848
- }
1849
- set state(state2) {
1850
- var _a2;
1851
- if (state2 === this.state) {
1852
- return;
1853
- }
1854
- const oldState = this.state;
1855
- this._state = state2;
1856
- if (this.state === "opened" || this.state === "closed") {
1857
- (_a2 = this.strategy) == null ? void 0 : _a2.shouldCompleteOpen();
1858
- }
1859
- this.requestUpdate("state", oldState);
1860
- }
1861
- /**
1862
- * Provides an instance of the `ElementResolutionController` for managing the element
1863
- * that the overlay should be associated with. If the instance does not already exist,
1864
- * it is created and assigned to the `_elementResolver` property.
1865
- *
1866
- * @protected
1867
- * @returns The `ElementResolutionController` instance.
1868
- */
1869
- get elementResolver() {
1870
- if (!this._elementResolver) {
1871
- this._elementResolver = new elementResolution.ElementResolutionController(this);
1872
- }
1873
- return this._elementResolver;
1874
- }
1875
- /**
1876
- * Determines if the overlay uses a dialog.
1877
- * Returns `true` if the overlay type is "modal" or "page".
1878
- *
1879
- * @private
1880
- * @returns `true` if the overlay uses a dialog, otherwise `false`.
1881
- */
1882
- get usesDialog() {
1883
- return this.type === "modal" || this.type === "page";
1884
- }
1885
- /**
1886
- * Determines the value for the popover attribute based on the overlay type.
1887
- *
1888
- * @private
1889
- * @returns The popover value or undefined if not applicable.
1890
- */
1891
- get popoverValue() {
1892
- const hasPopoverAttribute = "popover" in this;
1893
- if (!hasPopoverAttribute) {
1894
- return void 0;
1895
- }
1896
- switch (this.type) {
1897
- case "modal":
1898
- case "page": {
1899
- return void 0;
1900
- }
1901
- case "hint": {
1902
- return "manual";
1903
- }
1904
- default: {
1905
- return this.type;
1906
- }
1907
- }
1908
- }
1909
- /**
1910
- * Determines if the overlay requires positioning based on its type and state.
1911
- *
1912
- * @protected
1913
- * @returns True if the overlay requires positioning, otherwise false.
1914
- */
1915
- get requiresPositioning() {
1916
- if (this.type === "page" || !this.open) {
1917
- return false;
1918
- }
1919
- if (!this.triggerElement || !this.placement && this.type !== "hint") {
1920
- return false;
1921
- }
1922
- return true;
1923
- }
1924
- /**
1925
- * Manages the positioning of the overlay relative to its trigger element.
1926
- *
1927
- * This method calculates the necessary parameters for positioning the overlay,
1928
- * such as offset, placement, and tip padding, and then delegates the actual
1929
- * positioning to the `PlacementController`.
1930
- *
1931
- * @protected
1932
- * @override
1933
- */
1934
- managePosition() {
1935
- if (!this.requiresPositioning || !this.open) {
1936
- return;
1937
- }
1938
- const offset = this.offset || 0;
1939
- const trigger = this.triggerElement;
1940
- const placement = this.placement || "right";
1941
- const tipPadding = this.tipPadding;
1942
- this.placementController.placeOverlay(this.dialogEl, {
1943
- offset,
1944
- placement,
1945
- tipPadding,
1946
- trigger,
1947
- type: this.type
1948
- });
1949
- }
1950
- /**
1951
- * Manages the process of opening the popover.
1952
- *
1953
- * This method handles the necessary steps to open the popover, including managing delays,
1954
- * ensuring the popover is in the DOM, making transitions, and applying focus.
1955
- *
1956
- * @protected
1957
- * @override
1958
- * @returns A promise that resolves when the popover has been fully opened.
1959
- */
1960
- async managePopoverOpen() {
1961
- super.managePopoverOpen();
1962
- const targetOpenState = this.open;
1963
- if (this.open !== targetOpenState) {
1964
- return;
1965
- }
1966
- await this.manageDelay(targetOpenState);
1967
- if (this.open !== targetOpenState) {
1968
- return;
1969
- }
1970
- if (this.triggerInteraction === "longpress") {
1971
- await nextFrame();
1972
- }
1973
- await this.ensureOnDOM(targetOpenState);
1974
- if (this.open !== targetOpenState) {
1975
- return;
1976
- }
1977
- const focusEl = await this.makeTransition(targetOpenState);
1978
- if (this.open !== targetOpenState) {
1979
- return;
1980
- }
1981
- await this.applyFocus(targetOpenState, focusEl);
1982
- }
1983
- /**
1984
- * Applies focus to the appropriate element after the popover has been opened.
1985
- *
1986
- * This method handles the focus management for the overlay, ensuring that the correct
1987
- * element receives focus based on the overlay's type and state.
1988
- *
1989
- * @protected
1990
- * @override
1991
- * @param targetOpenState - The target open state of the overlay.
1992
- * @param focusEl - The element to focus after opening the popover.
1993
- * @returns A promise that resolves when the focus has been applied.
1994
- */
1995
- async applyFocus(targetOpenState, focusEl) {
1996
- if (this.receivesFocus === "false" || this.type === "hint") {
1997
- return;
1998
- }
1999
- await nextFrame();
2000
- await nextFrame();
2001
- if (targetOpenState === this.open && !this.open) {
2002
- if (this.hasNonVirtualTrigger && this.contains(this.getRootNode().activeElement)) {
2003
- this.triggerElement.focus();
2004
- }
2005
- return;
2006
- }
2007
- focusEl == null ? void 0 : focusEl.focus();
2008
- }
2009
- /**
2010
- * Returns focus to the trigger element if the overlay is closed.
2011
- *
2012
- * This method ensures that focus is returned to the trigger element when the overlay is closed,
2013
- * unless the overlay is of type "hint" or the focus is already outside the overlay.
2014
- *
2015
- * @protected
2016
- * @override
2017
- */
2018
- returnFocus() {
2019
- var _a2;
2020
- if (this.open || this.type === "hint") {
2021
- return;
2022
- }
2023
- const getAncestors = () => {
2024
- var _a3, _b;
2025
- const ancestors = [];
2026
- let currentNode = typeof document !== "undefined" ? document.activeElement : null;
2027
- while ((_a3 = currentNode == null ? void 0 : currentNode.shadowRoot) == null ? void 0 : _a3.activeElement) {
2028
- currentNode = currentNode.shadowRoot.activeElement;
2029
- }
2030
- while (currentNode) {
2031
- const ancestor = currentNode.assignedSlot || currentNode.parentElement || ((_b = currentNode.getRootNode()) == null ? void 0 : _b.host);
2032
- if (ancestor) {
2033
- ancestors.push(ancestor);
2034
- }
2035
- currentNode = ancestor;
2036
- }
2037
- return ancestors;
2038
- };
2039
- if (this.receivesFocus !== "false" && !!((_a2 = this.triggerElement) == null ? void 0 : _a2.focus) && (this.contains(this.getRootNode().activeElement) || getAncestors().includes(this) || typeof document !== "undefined" && document.activeElement === document.body)) {
2040
- this.triggerElement.focus();
2041
- }
2042
- }
2043
- /**
2044
- * Manages the process of opening or closing the overlay.
2045
- *
2046
- * This method handles the necessary steps to open or close the overlay, including updating the state,
2047
- * managing the overlay stack, and handling focus events.
2048
- *
2049
- * @protected
2050
- * @param oldOpen - The previous open state of the overlay.
2051
- * @returns A promise that resolves when the overlay has been fully managed.
2052
- */
2053
- async manageOpen(oldOpen) {
2054
- if (!this.isConnected && this.open) {
2055
- return;
2056
- }
2057
- if (!this.hasUpdated) {
2058
- await this.updateComplete;
2059
- }
2060
- if (this.open) {
2061
- overlayStack.add(this);
2062
- if (this.willPreventClose) {
2063
- document.addEventListener(
2064
- "pointerup",
2065
- () => {
2066
- this.dialogEl.classList.toggle("not-immediately-closable", false);
2067
- this.willPreventClose = false;
2068
- },
2069
- { once: true }
2070
- );
2071
- this.dialogEl.classList.toggle("not-immediately-closable", true);
2072
- }
2073
- } else {
2074
- if (oldOpen) {
2075
- this.dispose();
2076
- }
2077
- overlayStack.remove(this);
2078
- }
2079
- if (this.open && this.state !== "opened") {
2080
- this.state = "opening";
2081
- } else if (!this.open && this.state !== "closed") {
2082
- this.state = "closing";
2083
- }
2084
- if (this.usesDialog) {
2085
- this.manageDialogOpen();
2086
- } else {
2087
- this.managePopoverOpen();
2088
- }
2089
- if (this.type === "auto") {
2090
- const listenerRoot = this.getRootNode();
2091
- if (this.open) {
2092
- listenerRoot.addEventListener("focusout", this.closeOnFocusOut, {
2093
- capture: true
2094
- });
2095
- } else {
2096
- listenerRoot.removeEventListener("focusout", this.closeOnFocusOut, {
2097
- capture: true
2098
- });
2099
- }
2100
- }
2101
- }
2102
- /**
2103
- * Binds event handling strategies to the overlay based on the specified trigger interaction.
2104
- *
2105
- * This method sets up the appropriate event handling strategy for the overlay, ensuring that
2106
- * it responds correctly to user interactions such as clicks, hovers, or long presses.
2107
- *
2108
- * @protected
2109
- */
2110
- bindEvents() {
2111
- var _a2;
2112
- (_a2 = this.strategy) == null ? void 0 : _a2.abort();
2113
- this.strategy = void 0;
2114
- if (!this.hasNonVirtualTrigger) {
2115
- return;
2116
- }
2117
- if (!this.triggerInteraction) {
2118
- return;
2119
- }
2120
- this.strategy = new strategies[this.triggerInteraction](
2121
- this.triggerElement,
2122
- {
2123
- overlay: this
2124
- }
2125
- );
2126
- }
2127
- /**
2128
- * Handles the `beforetoggle` event to manage the overlay's state.
2129
- *
2130
- * This method checks the new state of the event and calls `handleBrowserClose`
2131
- * if the new state is not 'open'.
2132
- *
2133
- * @protected
2134
- * @param event - The `beforetoggle` event with the new state.
2135
- */
2136
- handleBeforetoggle(event) {
2137
- if (event.newState !== "open") {
2138
- this.handleBrowserClose(event);
2139
- }
2140
- }
2141
- /**
2142
- * Handles the browser's close event to manage the overlay's state.
2143
- *
2144
- * This method stops the propagation of the event and closes the overlay if it is not
2145
- * actively opening. If the overlay is actively opening, it calls `manuallyKeepOpen`.
2146
- *
2147
- * @protected
2148
- * @param event - The browser's close event.
2149
- */
2150
- handleBrowserClose(event) {
2151
- var _a2;
2152
- event.stopPropagation();
2153
- if (!((_a2 = this.strategy) == null ? void 0 : _a2.activelyOpening)) {
2154
- this.open = false;
2155
- return;
2156
- }
2157
- this.manuallyKeepOpen();
2158
- }
2159
- /**
2160
- * Manually keeps the overlay open.
2161
- *
2162
- * This method sets the overlay to open, allows placement updates, and manages the open state.
2163
- *
2164
- * @public
2165
- * @override
2166
- */
2167
- manuallyKeepOpen() {
2168
- this.open = true;
2169
- this.placementController.allowPlacementUpdate = true;
2170
- this.manageOpen(false);
2171
- }
2172
- /**
2173
- * Handles the `slotchange` event to manage the overlay's state.
2174
- *
2175
- * This method checks if there are any elements in the slot. If there are no elements,
2176
- * it releases the description from the strategy. If there are elements and the trigger
2177
- * is non-virtual, it prepares the description for the trigger element.
2178
- *
2179
- * @protected
2180
- */
2181
- handleSlotchange() {
2182
- var _a2, _b;
2183
- if (this.elements.length === 0) {
2184
- (_a2 = this.strategy) == null ? void 0 : _a2.releaseDescription();
2185
- } else if (this.hasNonVirtualTrigger) {
2186
- (_b = this.strategy) == null ? void 0 : _b.prepareDescription(this.triggerElement);
2187
- }
2188
- }
2189
- /**
2190
- * Determines whether the overlay should prevent closing.
2191
- *
2192
- * This method checks the `willPreventClose` flag and resets it to `false`.
2193
- * It returns the value of the `willPreventClose` flag.
2194
- *
2195
- * @public
2196
- * @returns `true` if the overlay should prevent closing, otherwise `false`.
2197
- */
2198
- shouldPreventClose() {
2199
- const shouldPreventClose = this.willPreventClose;
2200
- this.willPreventClose = false;
2201
- return shouldPreventClose;
2202
- }
2203
- /**
2204
- * Requests slottable content for the overlay.
2205
- *
2206
- * This method dispatches a `SlottableRequestEvent` to request or remove slottable content
2207
- * based on the current open state of the overlay. It ensures that the same state is not
2208
- * dispatched twice in a row.
2209
- *
2210
- * @protected
2211
- * @override
2212
- */
2213
- requestSlottable() {
2214
- if (this.lastRequestSlottableState === this.open) {
2215
- return;
2216
- }
2217
- if (!this.open) {
2218
- document.body.offsetHeight;
2219
- }
2220
- this.dispatchEvent(
2221
- new slottableRequestEvent.SlottableRequestEvent(
2222
- "overlay-content",
2223
- this.open ? {} : slottableRequestEvent.removeSlottableRequest
2224
- )
2225
- );
2226
- this.lastRequestSlottableState = this.open;
2227
- }
2228
- /**
2229
- * Lifecycle method called before the component updates.
2230
- *
2231
- * This method handles various tasks before the component updates, such as setting an ID,
2232
- * managing the open state, resolving the trigger element, and binding events.
2233
- *
2234
- * @override
2235
- * @param changes - The properties that have changed.
2236
- */
2237
- willUpdate(changes) {
2238
- var _a2;
2239
- if (!this.hasAttribute("id")) {
2240
- this.setAttribute("id", `${this.tagName.toLowerCase()}-${randomId.randomID()}`);
2241
- }
2242
- if (changes.has("open") && (this.hasUpdated || this.open)) {
2243
- this.manageOpen(changes.get("open"));
2244
- }
2245
- if (changes.has("trigger")) {
2246
- const [id, interaction] = ((_a2 = this.trigger) == null ? void 0 : _a2.split("@")) || [];
2247
- this.elementResolver.selector = id ? `#${id}` : "";
2248
- this.triggerInteraction = interaction;
2249
- }
2250
- let oldTrigger = false;
2251
- if (changes.has(elementResolution.elementResolverUpdatedSymbol)) {
2252
- oldTrigger = this.triggerElement;
2253
- this.triggerElement = this.elementResolver.element;
2254
- }
2255
- if (changes.has("triggerElement")) {
2256
- oldTrigger = changes.get("triggerElement");
2257
- }
2258
- if (oldTrigger !== false) {
2259
- this.bindEvents();
2260
- }
2261
- }
2262
- /**
2263
- * Lifecycle method called after the component updates.
2264
- *
2265
- * This method handles various tasks after the component updates, such as updating the placement
2266
- * attribute, resetting the overlay position, and clearing the overlay position based on the state.
2267
- *
2268
- * @override
2269
- * @param changes - The properties that have changed.
2270
- */
2271
- updated(changes) {
2272
- super.updated(changes);
2273
- if (changes.has("placement")) {
2274
- if (this.placement) {
2275
- this.dialogEl.setAttribute("actual-placement", this.placement);
2276
- } else {
2277
- this.dialogEl.removeAttribute("actual-placement");
2278
- }
2279
- if (this.open && changes.get("placement") !== void 0) {
2280
- this.placementController.resetOverlayPosition();
2281
- }
2282
- }
2283
- if (changes.has("state") && this.state === "closed" && changes.get("state") !== void 0) {
2284
- this.placementController.clearOverlayPosition();
2285
- }
2286
- }
2287
- /**
2288
- * Renders the content of the overlay.
2289
- *
2290
- * This method returns a template result containing a slot element. The slot element
2291
- * listens for the `slotchange` event to manage the overlay's state.
2292
- *
2293
- * @protected
2294
- * @returns The template result containing the slot element.
2295
- */
2296
- renderContent() {
2297
- return lit.html` <slot @slotchange=${this.handleSlotchange}></slot> `;
2298
- }
2299
- /**
2300
- * Generates a style map for the dialog element.
2301
- *
2302
- * This method returns an object containing CSS custom properties for the dialog element.
2303
- * The `--luzmo-overlay-open-count` custom property is set to the current open count of overlays.
2304
- *
2305
- * @private
2306
- * @returns The style map for the dialog element.
2307
- */
2308
- get dialogStyleMap() {
2309
- return {
2310
- "--luzmo-overlay-open-count": _a.openCount.toString()
2311
- };
2312
- }
2313
- /**
2314
- * Renders the dialog element for the overlay.
2315
- *
2316
- * This method returns a template result containing a dialog element. The dialog element
2317
- * includes various attributes and event listeners to manage the overlay's state and behavior.
2318
- *
2319
- * @protected
2320
- * @returns The template result containing the dialog element.
2321
- */
2322
- renderDialog() {
2323
- return lit.html`
2324
- <dialog
2325
- class="dialog"
2326
- part="dialog"
2327
- placement=${ifDefined_js.ifDefined(
2328
- this.requiresPositioning ? this.placement || "right" : void 0
2329
- )}
2330
- style=${styleMap_js.styleMap(this.dialogStyleMap)}
2331
- @close=${this.handleBrowserClose}
2332
- @cancel=${this.handleBrowserClose}
2333
- @beforetoggle=${this.handleBeforetoggle}
2334
- ?is-visible=${this.state !== "closed"}
2335
- >
2336
- ${this.renderContent()}
2337
- </dialog>
2338
- `;
2339
- }
2340
- /**
2341
- * Renders the popover element for the overlay.
2342
- *
2343
- * This method returns a template result containing a div element styled as a popover.
2344
- * The popover element includes various attributes and event listeners to manage the overlay's state and behavior.
2345
- *
2346
- * @protected
2347
- * @returns The template result containing the popover element.
2348
- */
2349
- renderPopover() {
2350
- return lit.html`
2351
- <div
2352
- class="dialog"
2353
- part="dialog"
2354
- placement=${ifDefined_js.ifDefined(
2355
- this.requiresPositioning ? this.placement || "right" : void 0
2356
- )}
2357
- popover=${ifDefined_js.ifDefined(this.popoverValue)}
2358
- style=${styleMap_js.styleMap(this.dialogStyleMap)}
2359
- @beforetoggle=${this.handleBeforetoggle}
2360
- @close=${this.handleBrowserClose}
2361
- ?is-visible=${this.state !== "closed"}
2362
- >
2363
- ${this.renderContent()}
2364
- </div>
2365
- `;
2366
- }
2367
- /**
2368
- * Renders the overlay component.
2369
- *
2370
- * This method returns a template result containing either a dialog or popover element
2371
- * based on the overlay type. It also includes a slot for longpress descriptors.
2372
- *
2373
- * @override
2374
- * @returns The template result containing the overlay content.
2375
- */
2376
- render() {
2377
- const isDialog = this.type === "modal" || this.type === "page";
2378
- return lit.html`
2379
- ${isDialog ? this.renderDialog() : this.renderPopover()}
2380
- <slot name="longpress-describedby-descriptor"></slot>
2381
- `;
2382
- }
2383
- /**
2384
- * Lifecycle method called when the component is added to the DOM.
2385
- *
2386
- * This method sets up event listeners and binds events if the component has already updated.
2387
- *
2388
- * @override
2389
- */
2390
- connectedCallback() {
2391
- super.connectedCallback();
2392
- this.addEventListener("close", () => {
2393
- this.open = false;
2394
- });
2395
- if (this.hasUpdated) {
2396
- this.bindEvents();
2397
- }
2398
- }
2399
- /**
2400
- * Lifecycle method called when the component is removed from the DOM.
2401
- *
2402
- * This method releases the description from the strategy and updates the 'open' property.
2403
- *
2404
- * @override
2405
- */
2406
- disconnectedCallback() {
2407
- var _a2;
2408
- (_a2 = this.strategy) == null ? void 0 : _a2.releaseDescription();
2409
- this.open = false;
2410
- super.disconnectedCallback();
2411
- }
2412
- }, _a.styles = [lit.unsafeCSS(styles)], _a.openCount = 1, _a);
2413
- __decorateClass([
2414
- decorators_js.property({ type: Boolean })
2415
- ], _LuzmoOverlay.prototype, "delayed", 1);
2416
- __decorateClass([
2417
- decorators_js.query(".dialog")
2418
- ], _LuzmoOverlay.prototype, "dialogEl", 2);
2419
- __decorateClass([
2420
- decorators_js.property({ type: Boolean })
2421
- ], _LuzmoOverlay.prototype, "disabled", 1);
2422
- __decorateClass([
2423
- decorators_js.queryAssignedElements({
2424
- flatten: true,
2425
- selector: ':not([slot="longpress-describedby-descriptor"], slot)'
2426
- })
2427
- ], _LuzmoOverlay.prototype, "elements", 2);
2428
- __decorateClass([
2429
- decorators_js.property({ type: Number })
2430
- ], _LuzmoOverlay.prototype, "offset", 2);
2431
- __decorateClass([
2432
- decorators_js.property({ type: Boolean, reflect: true })
2433
- ], _LuzmoOverlay.prototype, "open", 1);
2434
- __decorateClass([
2435
- decorators_js.property()
2436
- ], _LuzmoOverlay.prototype, "placement", 2);
2437
- __decorateClass([
2438
- decorators_js.property({ attribute: "receives-focus" })
2439
- ], _LuzmoOverlay.prototype, "receivesFocus", 2);
2440
- __decorateClass([
2441
- decorators_js.query("slot")
2442
- ], _LuzmoOverlay.prototype, "slotEl", 2);
2443
- __decorateClass([
2444
- decorators_js.state()
2445
- ], _LuzmoOverlay.prototype, "state", 1);
2446
- __decorateClass([
2447
- decorators_js.property({ type: Number, attribute: "tip-padding" })
2448
- ], _LuzmoOverlay.prototype, "tipPadding", 2);
2449
- __decorateClass([
2450
- decorators_js.property()
2451
- ], _LuzmoOverlay.prototype, "trigger", 2);
2452
- __decorateClass([
2453
- decorators_js.property({ attribute: false })
2454
- ], _LuzmoOverlay.prototype, "triggerElement", 2);
2455
- __decorateClass([
2456
- decorators_js.property({ attribute: false })
2457
- ], _LuzmoOverlay.prototype, "triggerInteraction", 2);
2458
- __decorateClass([
2459
- decorators_js.property()
2460
- ], _LuzmoOverlay.prototype, "type", 2);
2461
- let LuzmoOverlay = _LuzmoOverlay;
2462
- const overlay = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2463
- __proto__: null,
2464
- LuzmoOverlay
2465
- }, Symbol.toStringTag, { value: "Module" }));
2466
- exports.ClickController = ClickController;
2467
- exports.HoverController = HoverController;
2468
- exports.InteractionController = InteractionController;
2469
- exports.InteractionTypes = InteractionTypes;
2470
- exports.LONGPRESS_INSTRUCTIONS = LONGPRESS_INSTRUCTIONS;
2471
- exports.LongpressController = LongpressController;
2472
- exports.LuzmoAbstractOverlay = LuzmoAbstractOverlay;
2473
- exports.LuzmoOverlay = LuzmoOverlay;
2474
- exports.PlacementController = PlacementController;
2475
- exports.SAFARI_FOCUS_RING_CLASS = SAFARI_FOCUS_RING_CLASS;
2476
- exports.VirtualTrigger = VirtualTrigger;
2477
- exports.guaranteedAllTransitionend = guaranteedAllTransitionend;
2478
- exports.lastInteractionType = lastInteractionType;
2479
- exports.nextFrame = nextFrame;
2480
- exports.noop = noop;
2481
- exports.overlay = overlay;
2482
- exports.overlayTimer = overlayTimer;
2483
- exports.placementUpdatedSymbol = placementUpdatedSymbol;
2484
- exports.strategies = strategies;