@zanichelli/albe-web-components 19.1.3-RC3 → 19.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/{index-e84fb4e1.js → index-805390c8.js} +2 -2
  3. package/dist/cjs/{index-e84fb4e1.js.map → index-805390c8.js.map} +1 -1
  4. package/dist/cjs/index.cjs.js +1 -1
  5. package/dist/cjs/loader.cjs.js +1 -1
  6. package/dist/cjs/{utils-3dc316f8.js → utils-5148245a.js} +69 -24
  7. package/dist/cjs/utils-5148245a.js.map +1 -0
  8. package/dist/cjs/web-components-library.cjs.js +1 -1
  9. package/dist/cjs/z-app-header_12.cjs.entry.js +4 -6
  10. package/dist/cjs/z-app-header_12.cjs.entry.js.map +1 -1
  11. package/dist/cjs/z-book-card-deprecated.cjs.entry.js +1 -1
  12. package/dist/cjs/z-breadcrumb.cjs.entry.js +1 -1
  13. package/dist/cjs/z-combobox.cjs.entry.js +62 -50
  14. package/dist/cjs/z-combobox.cjs.entry.js.map +1 -1
  15. package/dist/cjs/z-menu.cjs.entry.js +1 -1
  16. package/dist/cjs/z-myz-card-info.cjs.entry.js +1 -1
  17. package/dist/cjs/z-myz-list-item.cjs.entry.js +1 -1
  18. package/dist/cjs/z-popover.cjs.entry.js +111 -42
  19. package/dist/cjs/z-popover.cjs.entry.js.map +1 -1
  20. package/dist/cjs/z-select.cjs.entry.js +28 -63
  21. package/dist/cjs/z-select.cjs.entry.js.map +1 -1
  22. package/dist/cjs/z-skip-to-content.cjs.entry.js +1 -1
  23. package/dist/cjs/z-slideshow.cjs.entry.js +1 -1
  24. package/dist/cjs/z-stepper-item.cjs.entry.js +3 -3
  25. package/dist/cjs/z-stepper-item.cjs.entry.js.map +1 -1
  26. package/dist/cjs/z-stepper.cjs.entry.js +1 -1
  27. package/dist/cjs/z-stepper.cjs.entry.js.map +1 -1
  28. package/dist/cjs/z-table.cjs.entry.js +2 -2
  29. package/dist/cjs/z-toggle-switch.cjs.entry.js +1 -1
  30. package/dist/cjs/z-tooltip.cjs.entry.js +1 -1
  31. package/dist/cjs/z-tooltip.cjs.entry.js.map +1 -1
  32. package/dist/cjs/z-tr.cjs.entry.js +2 -2
  33. package/dist/collection/components/list/z-list-group/index.js +2 -39
  34. package/dist/collection/components/list/z-list-group/index.js.map +1 -1
  35. package/dist/collection/components/z-combobox/index.js +63 -48
  36. package/dist/collection/components/z-combobox/index.js.map +1 -1
  37. package/dist/collection/components/z-combobox/styles.css +0 -6
  38. package/dist/collection/components/z-input-message/index.js +1 -1
  39. package/dist/collection/components/z-input-message/index.js.map +1 -1
  40. package/dist/collection/components/z-popover/index.js +111 -42
  41. package/dist/collection/components/z-popover/index.js.map +1 -1
  42. package/dist/collection/components/z-popover/index.stories.js +49 -0
  43. package/dist/collection/components/z-popover/index.stories.js.map +1 -1
  44. package/dist/collection/components/z-popover/styles.css +0 -16
  45. package/dist/collection/components/z-select/index.js +27 -62
  46. package/dist/collection/components/z-select/index.js.map +1 -1
  47. package/dist/collection/components/z-stepper/index.js +1 -1
  48. package/dist/collection/components/z-stepper/index.js.map +1 -1
  49. package/dist/collection/components/z-stepper-item/index.js +3 -3
  50. package/dist/collection/components/z-stepper-item/index.js.map +1 -1
  51. package/dist/collection/components/z-tooltip/styles.css +7 -6
  52. package/dist/collection/utils/utils.js +66 -22
  53. package/dist/collection/utils/utils.js.map +1 -1
  54. package/dist/components/index13.js +1 -1
  55. package/dist/components/index13.js.map +1 -1
  56. package/dist/components/index16.js +3 -7
  57. package/dist/components/index16.js.map +1 -1
  58. package/dist/components/index24.js +111 -42
  59. package/dist/components/index24.js.map +1 -1
  60. package/dist/components/index25.js +1 -1
  61. package/dist/components/utils.js +67 -23
  62. package/dist/components/utils.js.map +1 -1
  63. package/dist/components/z-combobox.js +65 -51
  64. package/dist/components/z-combobox.js.map +1 -1
  65. package/dist/components/z-select.js +27 -62
  66. package/dist/components/z-select.js.map +1 -1
  67. package/dist/components/z-stepper-item.js +3 -3
  68. package/dist/components/z-stepper-item.js.map +1 -1
  69. package/dist/components/z-stepper.js +1 -1
  70. package/dist/components/z-stepper.js.map +1 -1
  71. package/dist/components/z-tooltip.js +1 -1
  72. package/dist/components/z-tooltip.js.map +1 -1
  73. package/dist/esm/{index-92064825.js → index-8a9f6d27.js} +2 -2
  74. package/dist/esm/{index-92064825.js.map → index-8a9f6d27.js.map} +1 -1
  75. package/dist/esm/index.js +1 -1
  76. package/dist/esm/loader.js +1 -1
  77. package/dist/esm/{utils-6e2be2b6.js → utils-e66d94c3.js} +68 -24
  78. package/dist/esm/utils-e66d94c3.js.map +1 -0
  79. package/dist/esm/web-components-library.js +1 -1
  80. package/dist/esm/z-app-header_12.entry.js +4 -6
  81. package/dist/esm/z-app-header_12.entry.js.map +1 -1
  82. package/dist/esm/z-book-card-deprecated.entry.js +1 -1
  83. package/dist/esm/z-breadcrumb.entry.js +1 -1
  84. package/dist/esm/z-combobox.entry.js +62 -50
  85. package/dist/esm/z-combobox.entry.js.map +1 -1
  86. package/dist/esm/z-menu.entry.js +1 -1
  87. package/dist/esm/z-myz-card-info.entry.js +1 -1
  88. package/dist/esm/z-myz-list-item.entry.js +1 -1
  89. package/dist/esm/z-popover.entry.js +111 -42
  90. package/dist/esm/z-popover.entry.js.map +1 -1
  91. package/dist/esm/z-select.entry.js +28 -63
  92. package/dist/esm/z-select.entry.js.map +1 -1
  93. package/dist/esm/z-skip-to-content.entry.js +1 -1
  94. package/dist/esm/z-slideshow.entry.js +1 -1
  95. package/dist/esm/z-stepper-item.entry.js +3 -3
  96. package/dist/esm/z-stepper-item.entry.js.map +1 -1
  97. package/dist/esm/z-stepper.entry.js +1 -1
  98. package/dist/esm/z-stepper.entry.js.map +1 -1
  99. package/dist/esm/z-table.entry.js +2 -2
  100. package/dist/esm/z-toggle-switch.entry.js +1 -1
  101. package/dist/esm/z-tooltip.entry.js +1 -1
  102. package/dist/esm/z-tooltip.entry.js.map +1 -1
  103. package/dist/esm/z-tr.entry.js +2 -2
  104. package/dist/types/components/list/z-list-group/index.d.ts +0 -8
  105. package/dist/types/components/z-combobox/index.d.ts +8 -1
  106. package/dist/types/components/z-popover/index.d.ts +15 -4
  107. package/dist/types/components/z-popover/index.stories.d.ts +8 -0
  108. package/dist/types/components.d.ts +2 -18
  109. package/dist/types/utils/utils.d.ts +14 -8
  110. package/dist/web-components-library/index.esm.js +1 -1
  111. package/dist/web-components-library/{p-2bf54364.js → p-030257b3.js} +2 -2
  112. package/{www/build/p-8bd4a2aa.entry.js → dist/web-components-library/p-1844a4f4.entry.js} +2 -2
  113. package/dist/web-components-library/{p-539f99db.entry.js → p-19f5b6a9.entry.js} +2 -2
  114. package/dist/web-components-library/{p-ce6e18f9.entry.js → p-1c7550f9.entry.js} +2 -2
  115. package/dist/web-components-library/p-22ba2a17.entry.js +2 -0
  116. package/dist/web-components-library/p-22ba2a17.entry.js.map +1 -0
  117. package/dist/web-components-library/{p-28d83c86.entry.js → p-307c9c33.entry.js} +2 -2
  118. package/dist/web-components-library/p-334cba5d.entry.js +2 -0
  119. package/dist/web-components-library/p-334cba5d.entry.js.map +1 -0
  120. package/dist/web-components-library/p-33d2a5db.entry.js +2 -0
  121. package/dist/web-components-library/p-33d2a5db.entry.js.map +1 -0
  122. package/{www/build/p-2e0923bd.entry.js → dist/web-components-library/p-3f5aa623.entry.js} +2 -2
  123. package/dist/web-components-library/{p-ee223a82.entry.js → p-75e47ecf.entry.js} +2 -2
  124. package/dist/web-components-library/p-75e47ecf.entry.js.map +1 -0
  125. package/dist/web-components-library/{p-b3f1b5c1.entry.js → p-99210133.entry.js} +2 -2
  126. package/dist/web-components-library/p-b71a3f69.entry.js +2 -0
  127. package/dist/web-components-library/{p-6cff173f.entry.js.map → p-b71a3f69.entry.js.map} +1 -1
  128. package/dist/web-components-library/{p-7ceddb7a.entry.js → p-b7ec2cc4.entry.js} +2 -2
  129. package/dist/web-components-library/p-b7ec2cc4.entry.js.map +1 -0
  130. package/dist/web-components-library/{p-4aaf0172.entry.js → p-b96900bb.entry.js} +2 -2
  131. package/dist/web-components-library/{p-57314d68.entry.js → p-cc18a2b7.entry.js} +2 -2
  132. package/dist/web-components-library/p-cc18a2b7.entry.js.map +1 -0
  133. package/dist/web-components-library/p-d2035d26.entry.js +2 -0
  134. package/{www/build/p-5f94986f.entry.js → dist/web-components-library/p-daa1ffe9.entry.js} +2 -2
  135. package/dist/web-components-library/p-e6778114.js +2 -0
  136. package/dist/web-components-library/p-e6778114.js.map +1 -0
  137. package/{www/build/p-7194003a.entry.js → dist/web-components-library/p-e9e2ceb4.entry.js} +2 -2
  138. package/dist/web-components-library/web-components-library.esm.js +1 -1
  139. package/dist/web-components-library/web-components-library.esm.js.map +1 -1
  140. package/package.json +2 -3
  141. package/www/build/index.esm.js +1 -1
  142. package/www/build/{p-2bf54364.js → p-030257b3.js} +2 -2
  143. package/{dist/web-components-library/p-8bd4a2aa.entry.js → www/build/p-1844a4f4.entry.js} +2 -2
  144. package/www/build/{p-539f99db.entry.js → p-19f5b6a9.entry.js} +2 -2
  145. package/www/build/{p-ce6e18f9.entry.js → p-1c7550f9.entry.js} +2 -2
  146. package/www/build/p-22ba2a17.entry.js +2 -0
  147. package/www/build/p-22ba2a17.entry.js.map +1 -0
  148. package/www/build/{p-28d83c86.entry.js → p-307c9c33.entry.js} +2 -2
  149. package/www/build/p-334cba5d.entry.js +2 -0
  150. package/www/build/p-334cba5d.entry.js.map +1 -0
  151. package/www/build/p-33d2a5db.entry.js +2 -0
  152. package/www/build/p-33d2a5db.entry.js.map +1 -0
  153. package/{dist/web-components-library/p-2e0923bd.entry.js → www/build/p-3f5aa623.entry.js} +2 -2
  154. package/www/build/{p-ee223a82.entry.js → p-75e47ecf.entry.js} +2 -2
  155. package/www/build/p-75e47ecf.entry.js.map +1 -0
  156. package/www/build/p-7646bea0.js +2 -0
  157. package/www/build/{p-b3f1b5c1.entry.js → p-99210133.entry.js} +2 -2
  158. package/www/build/p-b71a3f69.entry.js +2 -0
  159. package/www/build/{p-6cff173f.entry.js.map → p-b71a3f69.entry.js.map} +1 -1
  160. package/www/build/{p-7ceddb7a.entry.js → p-b7ec2cc4.entry.js} +2 -2
  161. package/www/build/p-b7ec2cc4.entry.js.map +1 -0
  162. package/www/build/{p-4aaf0172.entry.js → p-b96900bb.entry.js} +2 -2
  163. package/www/build/{p-57314d68.entry.js → p-cc18a2b7.entry.js} +2 -2
  164. package/www/build/p-cc18a2b7.entry.js.map +1 -0
  165. package/www/build/p-d2035d26.entry.js +2 -0
  166. package/{dist/web-components-library/p-5f94986f.entry.js → www/build/p-daa1ffe9.entry.js} +2 -2
  167. package/www/build/p-e6778114.js +2 -0
  168. package/www/build/p-e6778114.js.map +1 -0
  169. package/{dist/web-components-library/p-7194003a.entry.js → www/build/p-e9e2ceb4.entry.js} +2 -2
  170. package/www/build/web-components-library.esm.js +1 -1
  171. package/www/build/web-components-library.esm.js.map +1 -1
  172. package/www/index.html +1 -1
  173. package/dist/cjs/utils-3dc316f8.js.map +0 -1
  174. package/dist/esm/utils-6e2be2b6.js.map +0 -1
  175. package/dist/web-components-library/p-57314d68.entry.js.map +0 -1
  176. package/dist/web-components-library/p-625e2cee.js +0 -2
  177. package/dist/web-components-library/p-625e2cee.js.map +0 -1
  178. package/dist/web-components-library/p-6cff173f.entry.js +0 -2
  179. package/dist/web-components-library/p-78146cef.entry.js +0 -2
  180. package/dist/web-components-library/p-78146cef.entry.js.map +0 -1
  181. package/dist/web-components-library/p-7ceddb7a.entry.js.map +0 -1
  182. package/dist/web-components-library/p-ac477ae7.entry.js +0 -2
  183. package/dist/web-components-library/p-ac477ae7.entry.js.map +0 -1
  184. package/dist/web-components-library/p-bc2fb71e.entry.js +0 -2
  185. package/dist/web-components-library/p-bc2fb71e.entry.js.map +0 -1
  186. package/dist/web-components-library/p-dc156429.entry.js +0 -2
  187. package/dist/web-components-library/p-ee223a82.entry.js.map +0 -1
  188. package/www/build/p-57314d68.entry.js.map +0 -1
  189. package/www/build/p-625e2cee.js +0 -2
  190. package/www/build/p-625e2cee.js.map +0 -1
  191. package/www/build/p-6cff173f.entry.js +0 -2
  192. package/www/build/p-78146cef.entry.js +0 -2
  193. package/www/build/p-78146cef.entry.js.map +0 -1
  194. package/www/build/p-7ceddb7a.entry.js.map +0 -1
  195. package/www/build/p-ac477ae7.entry.js +0 -2
  196. package/www/build/p-ac477ae7.entry.js.map +0 -1
  197. package/www/build/p-bc2fb71e.entry.js +0 -2
  198. package/www/build/p-bc2fb71e.entry.js.map +0 -1
  199. package/www/build/p-dc156429.entry.js +0 -2
  200. package/www/build/p-e13b193a.js +0 -2
  201. package/www/build/p-ee223a82.entry.js.map +0 -1
  202. /package/dist/web-components-library/{p-2bf54364.js.map → p-030257b3.js.map} +0 -0
  203. /package/dist/web-components-library/{p-8bd4a2aa.entry.js.map → p-1844a4f4.entry.js.map} +0 -0
  204. /package/dist/web-components-library/{p-539f99db.entry.js.map → p-19f5b6a9.entry.js.map} +0 -0
  205. /package/dist/web-components-library/{p-ce6e18f9.entry.js.map → p-1c7550f9.entry.js.map} +0 -0
  206. /package/dist/web-components-library/{p-28d83c86.entry.js.map → p-307c9c33.entry.js.map} +0 -0
  207. /package/dist/web-components-library/{p-2e0923bd.entry.js.map → p-3f5aa623.entry.js.map} +0 -0
  208. /package/dist/web-components-library/{p-b3f1b5c1.entry.js.map → p-99210133.entry.js.map} +0 -0
  209. /package/dist/web-components-library/{p-4aaf0172.entry.js.map → p-b96900bb.entry.js.map} +0 -0
  210. /package/dist/web-components-library/{p-dc156429.entry.js.map → p-d2035d26.entry.js.map} +0 -0
  211. /package/dist/web-components-library/{p-5f94986f.entry.js.map → p-daa1ffe9.entry.js.map} +0 -0
  212. /package/dist/web-components-library/{p-7194003a.entry.js.map → p-e9e2ceb4.entry.js.map} +0 -0
  213. /package/www/build/{p-2bf54364.js.map → p-030257b3.js.map} +0 -0
  214. /package/www/build/{p-8bd4a2aa.entry.js.map → p-1844a4f4.entry.js.map} +0 -0
  215. /package/www/build/{p-539f99db.entry.js.map → p-19f5b6a9.entry.js.map} +0 -0
  216. /package/www/build/{p-ce6e18f9.entry.js.map → p-1c7550f9.entry.js.map} +0 -0
  217. /package/www/build/{p-28d83c86.entry.js.map → p-307c9c33.entry.js.map} +0 -0
  218. /package/www/build/{p-2e0923bd.entry.js.map → p-3f5aa623.entry.js.map} +0 -0
  219. /package/www/build/{p-b3f1b5c1.entry.js.map → p-99210133.entry.js.map} +0 -0
  220. /package/www/build/{p-4aaf0172.entry.js.map → p-b96900bb.entry.js.map} +0 -0
  221. /package/www/build/{p-dc156429.entry.js.map → p-d2035d26.entry.js.map} +0 -0
  222. /package/www/build/{p-5f94986f.entry.js.map → p-daa1ffe9.entry.js.map} +0 -0
  223. /package/www/build/{p-7194003a.entry.js.map → p-e9e2ceb4.entry.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { Host, h } from "@stencil/core";
2
2
  import { Device, KeyboardCode, PopoverPosition } from "../../beans";
3
- import { containsElement, findScrollableParent, getDevice, isElementVisibleInContainer } from "../../utils/utils";
3
+ import { containsElement, findContainingBlockAncestor, getDevice, getParentElement, isElementVisibleInContainer, } from "../../utils/utils";
4
4
  /**
5
5
  * Popover component.
6
6
  * This component displays a popover bound to an element.
@@ -103,7 +103,11 @@ export class ZPopover {
103
103
  this.boundElement = this.bindTo;
104
104
  }
105
105
  else {
106
- this.boundElement = this.host.parentElement;
106
+ this.boundElement = getParentElement(this.host);
107
+ if (this.boundElement.tagName.toLowerCase() === "z-tooltip") {
108
+ // If the popover is used inside a tooltip without a specified `bindTo`, bind it to the parent of the tooltip.
109
+ this.boundElement = getParentElement(this.boundElement);
110
+ }
107
111
  }
108
112
  }
109
113
  /**
@@ -244,6 +248,28 @@ export class ZPopover {
244
248
  // Return a combined position (e.g., "bottom_right")
245
249
  return `${mainDirection}_${secondaryDirection}`;
246
250
  }
251
+ /**
252
+ * Find the nearest scrollable ancestor of an element to take as a reference for positioning.
253
+ * The ancestor is considered scrollable if it doesn't have `overflow` property set to `hidden` and its scroll size is bigger than its client size.
254
+ */
255
+ findScrollableAncestor(element) {
256
+ let parent = getParentElement(element);
257
+ while (parent) {
258
+ if (parent === element.ownerDocument.documentElement) {
259
+ return parent;
260
+ }
261
+ const style = window.getComputedStyle(parent);
262
+ const { overflow, overflowX, overflowY } = style;
263
+ const hasHiddenOverflow = overflow === "hidden" || overflowY === "hidden" || overflowX === "hidden";
264
+ const isScrollable = (parent.scrollHeight > parent.clientHeight && overflow !== "visible" && overflowY !== "visible") ||
265
+ (parent.scrollWidth > parent.clientWidth && overflow !== "visible" && overflowX !== "visible");
266
+ if (!hasHiddenOverflow && isScrollable) {
267
+ return parent;
268
+ }
269
+ parent = getParentElement(parent);
270
+ }
271
+ return element.ownerDocument.documentElement;
272
+ }
247
273
  /**
248
274
  * Calculate available space around the element bound with the popover, based on its nearest scrollable ancestor.
249
275
  *
@@ -263,19 +289,19 @@ export class ZPopover {
263
289
  return this.cachedAvailableSpace;
264
290
  }
265
291
  this.lastBoundRect = boundElementRect;
266
- const scrollableParent = findScrollableParent(this.boundElement);
267
- const scrollableParentRect = scrollableParent.getBoundingClientRect();
268
- const hasNestedScrollableParent = scrollableParent !== this.boundElement.ownerDocument.documentElement;
292
+ const scrollableAncestor = this.findScrollableAncestor(this.boundElement);
293
+ const scrollableAncestorRect = scrollableAncestor.getBoundingClientRect();
294
+ const isScrollableAncestorNested = scrollableAncestor !== this.boundElement.ownerDocument.documentElement;
269
295
  const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;
270
296
  const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;
271
297
  const safeSpace = 8; // extra space to avoid popover being too close to the edges
272
- // These deltas represent the offset between the scrollable parent and the viewport.
273
- // They are used to adjust the available space calculations when the scrollable parent is not the document or body,
274
- // to try to fit the popover inside the scrollable parent.
275
- const deltaTop = hasNestedScrollableParent ? scrollableParentRect.top : 0;
276
- const deltaRight = hasNestedScrollableParent ? documentWidth - scrollableParentRect.right : 0;
277
- const deltaBottom = hasNestedScrollableParent ? documentHeight - scrollableParentRect.bottom : 0;
278
- const deltaLeft = hasNestedScrollableParent ? scrollableParentRect.left : 0;
298
+ // These deltas represent the offset between the scrollable ancestor and the viewport.
299
+ // They are used to adjust the available space calculations when the scrollable ancestor is not the document or body,
300
+ // to try to fit the popover inside the scrollable ancestor.
301
+ const deltaTop = isScrollableAncestorNested ? scrollableAncestorRect.top : 0;
302
+ const deltaRight = isScrollableAncestorNested ? documentWidth - scrollableAncestorRect.right : 0;
303
+ const deltaBottom = isScrollableAncestorNested ? documentHeight - scrollableAncestorRect.bottom : 0;
304
+ const deltaLeft = isScrollableAncestorNested ? scrollableAncestorRect.left : 0;
279
305
  this.cachedAvailableSpace = {
280
306
  top: boundElementRect.top - deltaTop - safeSpace,
281
307
  right: documentWidth - boundElementRect.right - deltaRight - safeSpace,
@@ -284,66 +310,109 @@ export class ZPopover {
284
310
  };
285
311
  return this.cachedAvailableSpace;
286
312
  }
287
- /** Calculate the space around an element relative to the viewport. */
288
- calculateElementOffsets(element) {
289
- const elementRect = element.getBoundingClientRect();
290
- const viewportWidth = element.ownerDocument.documentElement.clientWidth;
291
- const viewportHeight = element.ownerDocument.documentElement.clientHeight;
313
+ /** Calculate the space around the bound element relative to the viewport. */
314
+ getBoundElementOffsets() {
315
+ const elementRect = this.boundElement.getBoundingClientRect();
316
+ const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;
317
+ const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;
292
318
  return {
293
319
  top: elementRect.top,
294
- right: viewportWidth - elementRect.right,
295
- bottom: viewportHeight - elementRect.bottom,
320
+ right: documentWidth - elementRect.right,
321
+ bottom: documentHeight - elementRect.bottom,
296
322
  left: elementRect.left,
297
323
  };
298
324
  }
299
- /** Apply positioning styles based on passed position. */
325
+ /** Compute positioning offsets in the appropriate coordinate space, accounting for transformed containing blocks and scroll. */
326
+ computePositionOffsets() {
327
+ const boundElementOffsets = this.getBoundElementOffsets();
328
+ const containingBlockAncestor = findContainingBlockAncestor(this.host);
329
+ const isDocumentElement = containingBlockAncestor === this.host.ownerDocument.documentElement;
330
+ if (isDocumentElement) {
331
+ return boundElementOffsets;
332
+ }
333
+ const containingBlockRect = containingBlockAncestor.getBoundingClientRect();
334
+ const containingBlockStyle = getComputedStyle(containingBlockAncestor);
335
+ /** Padding box of the containing block, accounting for borders. */
336
+ const paddingBox = {
337
+ top: containingBlockRect.top + parseFloat(containingBlockStyle.borderTopWidth),
338
+ right: containingBlockRect.right - parseFloat(containingBlockStyle.borderRightWidth),
339
+ bottom: containingBlockRect.bottom - parseFloat(containingBlockStyle.borderBottomWidth),
340
+ left: containingBlockRect.left + parseFloat(containingBlockStyle.borderLeftWidth),
341
+ };
342
+ const boundElementRect = this.boundElement.getBoundingClientRect();
343
+ /** Bound element offsets relative to the containing block padding box. */
344
+ const relativeOffsets = {
345
+ top: boundElementRect.top - paddingBox.top,
346
+ right: paddingBox.right - boundElementRect.right,
347
+ bottom: paddingBox.bottom - boundElementRect.bottom,
348
+ left: boundElementRect.left - paddingBox.left,
349
+ };
350
+ /** Account for scroll to keep the popover aligned while the containing block scrolls. */
351
+ return {
352
+ top: relativeOffsets.top + containingBlockAncestor.scrollTop,
353
+ right: relativeOffsets.right - containingBlockAncestor.scrollLeft,
354
+ bottom: relativeOffsets.bottom - containingBlockAncestor.scrollTop,
355
+ left: relativeOffsets.left + containingBlockAncestor.scrollLeft,
356
+ };
357
+ }
358
+ /** Apply positioning styles based on `position` parameter. */
300
359
  applyPositionStyles(position, availableSpace) {
301
360
  const boundElementWidth = this.boundElement.offsetWidth;
302
361
  const boundElementHeight = this.boundElement.offsetHeight;
303
- /** Distance between the popover and the bound element */
304
- const distanceFromBound = 8;
305
362
  const offsetModifier = this.offsetModifier;
306
363
  /** Distance between the arrow center and the popover edge. Needed to align the center of the arrow with the center of the bound element when `showArrow` and `center` are enabled. */
307
364
  const arrowModifier = this.showArrow && this.center ? 8 : 0;
308
365
  const hostStyle = this.host.style;
309
- const boundElementOffsets = this.calculateElementOffsets(this.boundElement);
366
+ /** Gap between the popover and the bound element. */
367
+ const distanceFromBound = parseInt(hostStyle.getPropertyValue("--space-unit")) || 8;
368
+ const positionOffsets = this.computePositionOffsets();
369
+ /**
370
+ * Precomputed bases to reduce repeated arithmetic in the switch below.
371
+ * They represent the bound element edges plus optional centering offsets.
372
+ */
373
+ const leftBase = positionOffsets.left + boundElementWidth * offsetModifier;
374
+ const rightBase = positionOffsets.right + boundElementWidth * offsetModifier;
375
+ const topBase = positionOffsets.top + boundElementHeight;
376
+ const bottomBase = positionOffsets.bottom + boundElementHeight;
377
+ const sideTopBase = positionOffsets.top + boundElementHeight * offsetModifier;
378
+ const sideBottomBase = positionOffsets.bottom + boundElementHeight * offsetModifier;
310
379
  let maxWidth;
311
380
  let maxHeight;
312
381
  switch (position) {
313
382
  case PopoverPosition.TOP:
314
383
  case PopoverPosition.TOP_RIGHT:
315
- hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;
316
- hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === PopoverPosition.TOP_RIGHT ? arrowModifier : 0)}px`;
384
+ hostStyle.bottom = `${bottomBase + distanceFromBound}px`;
385
+ hostStyle.left = `${leftBase - (position === PopoverPosition.TOP_RIGHT ? arrowModifier : 0)}px`;
317
386
  maxHeight = availableSpace.top - distanceFromBound;
318
387
  if (position === PopoverPosition.TOP_RIGHT) {
319
388
  maxWidth = availableSpace.right + boundElementWidth * offsetModifier;
320
389
  }
321
390
  break;
322
391
  case PopoverPosition.TOP_LEFT:
323
- hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;
324
- hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;
392
+ hostStyle.right = `${rightBase - arrowModifier}px`;
393
+ hostStyle.bottom = `${bottomBase + distanceFromBound}px`;
325
394
  maxWidth = availableSpace.left + boundElementWidth * offsetModifier;
326
395
  maxHeight = availableSpace.top - distanceFromBound;
327
396
  break;
328
397
  case PopoverPosition.BOTTOM:
329
398
  case PopoverPosition.BOTTOM_RIGHT:
330
- hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;
331
- hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === PopoverPosition.BOTTOM_RIGHT ? arrowModifier : 0)}px`;
399
+ hostStyle.top = `${topBase + distanceFromBound}px`;
400
+ hostStyle.left = `${leftBase - (position === PopoverPosition.BOTTOM_RIGHT ? arrowModifier : 0)}px`;
332
401
  maxHeight = availableSpace.bottom - distanceFromBound;
333
402
  if (position === PopoverPosition.BOTTOM_RIGHT) {
334
403
  maxWidth = availableSpace.right + boundElementWidth * offsetModifier;
335
404
  }
336
405
  break;
337
406
  case PopoverPosition.BOTTOM_LEFT:
338
- hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;
339
- hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;
407
+ hostStyle.top = `${topBase + distanceFromBound}px`;
408
+ hostStyle.right = `${rightBase - arrowModifier}px`;
340
409
  maxWidth = availableSpace.left + boundElementWidth * offsetModifier;
341
410
  maxHeight = availableSpace.bottom - distanceFromBound;
342
411
  break;
343
412
  case PopoverPosition.RIGHT:
344
413
  case PopoverPosition.RIGHT_BOTTOM:
345
- hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === PopoverPosition.RIGHT_BOTTOM ? arrowModifier : 0)}px`;
346
- hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;
414
+ hostStyle.top = `${sideTopBase - (position === PopoverPosition.RIGHT_BOTTOM ? arrowModifier : 0)}px`;
415
+ hostStyle.left = `${positionOffsets.left + boundElementWidth + distanceFromBound}px`;
347
416
  maxWidth = availableSpace.right - distanceFromBound;
348
417
  if (position === PopoverPosition.RIGHT) {
349
418
  maxHeight = availableSpace.top + availableSpace.bottom + boundElementHeight;
@@ -353,23 +422,23 @@ export class ZPopover {
353
422
  }
354
423
  break;
355
424
  case PopoverPosition.RIGHT_TOP:
356
- hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;
357
- hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;
425
+ hostStyle.bottom = `${sideBottomBase - arrowModifier}px`;
426
+ hostStyle.left = `${positionOffsets.left + boundElementWidth + distanceFromBound}px`;
358
427
  maxWidth = availableSpace.right - distanceFromBound;
359
428
  maxHeight = availableSpace.top + boundElementHeight * offsetModifier;
360
429
  break;
361
430
  case PopoverPosition.LEFT:
362
431
  case PopoverPosition.LEFT_BOTTOM:
363
- hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === PopoverPosition.LEFT_BOTTOM ? arrowModifier : 0)}px`;
364
- hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;
432
+ hostStyle.top = `${sideTopBase - (position === PopoverPosition.LEFT_BOTTOM ? arrowModifier : 0)}px`;
433
+ hostStyle.right = `${positionOffsets.right + boundElementWidth + distanceFromBound}px`;
365
434
  maxWidth = availableSpace.left - distanceFromBound;
366
435
  if (position === PopoverPosition.LEFT_BOTTOM) {
367
436
  maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;
368
437
  }
369
438
  break;
370
439
  case PopoverPosition.LEFT_TOP:
371
- hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;
372
- hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;
440
+ hostStyle.right = `${positionOffsets.right + boundElementWidth + distanceFromBound}px`;
441
+ hostStyle.bottom = `${sideBottomBase - arrowModifier}px`;
373
442
  maxWidth = availableSpace.left - distanceFromBound;
374
443
  maxHeight = availableSpace.top + boundElementHeight * offsetModifier;
375
444
  break;
@@ -387,7 +456,7 @@ export class ZPopover {
387
456
  if (!this.boundElement) {
388
457
  return;
389
458
  }
390
- if (!isElementVisibleInContainer(this.boundElement, findScrollableParent(this.boundElement))) {
459
+ if (!isElementVisibleInContainer(this.boundElement, this.findScrollableAncestor(this.boundElement))) {
391
460
  // If the bound element is not visible, hide the popover too
392
461
  this.open = false;
393
462
  return;
@@ -424,7 +493,7 @@ export class ZPopover {
424
493
  cancelAnimationFrame(this.animationFrameRequestId);
425
494
  }
426
495
  render() {
427
- return (h(Host, { key: 'aeb6c7ccabc279af16d9a957e732ad611612589f', "current-position": this.currentPosition }, h("slot", { key: '77fecb1bbfa49e1a8f97c078e7cef01a03420d9c' })));
496
+ return (h(Host, { key: 'a778d9679d27ca18fe92eab0f596a86cb904a49f', "current-position": this.currentPosition }, h("slot", { key: 'de51304770f9f501a10ca26232448a31482da68d' })));
428
497
  }
429
498
  static get is() { return "z-popover"; }
430
499
  static get encapsulation() { return "shadow"; }
@@ -476,7 +545,7 @@ export class ZPopover {
476
545
  "optional": false,
477
546
  "docs": {
478
547
  "tags": [],
479
- "text": "The open state of the popover."
548
+ "text": "The initial open state of the popover.\nInternal changes of this prop are emitted through the `openChange` event.\nMake sure to listen to that event if you need the updated state of the popover from the outside, to avoid inconsistent values."
480
549
  },
481
550
  "attribute": "open",
482
551
  "reflect": true,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAClE,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,SAAS,EAAE,2BAA2B,EAAC,MAAM,mBAAmB,CAAC;AAMhH;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,QAAQ;;QA8DnB,6CAA6C;QAC5B,mBAAc,GAAG,CAAC,CAAC;w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AAC,CAAC;IACrD,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,yEAAmB,IAAI,CAAC,eAAe;YAC1C,8DAAa,CACR,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA3iBD,gCAAgC;AACR,sBAAa,GAAsB;IACzD,eAAe,CAAC,GAAG;IACnB,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,KAAK;IACrB,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,MAAM;IACtB,eAAe,CAAC,WAAW;IAC3B,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,IAAI;IACpB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,WAAW;CACnB,AAb2B,CAa1B","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Prop, State, Watch, h} from \"@stencil/core\";\nimport {Device, KeyboardCode, PopoverPosition} from \"../../beans\";\nimport {containsElement, findScrollableParent, getDevice, isElementVisibleInContainer} from \"../../utils/utils\";\n\n/** Centering offset modifier. 0 for no offset, 0.5 for centering. */\ntype OffsetModifier = 0 | 0.5;\ntype Offsets = {top: number; right: number; bottom: number; left: number};\n\n/**\n * Popover component.\n * This component displays a popover bound to an element.\n * It supports various positions and can automatically adjust it based on available space, accounting for scrollable containers.\n *\n * Notes:\n * - If positioning has an odd behavior, consider manually adjusting the size of the slotted elements (using `width`, `height`, `max-width`, `max-height`, etc...) when its content is \"fluid\" (like text), because it can interfere with the position calculation (for example a long text on one single line can be bigger than the available space, letting the algorithm think the popover doesn't fits).\n *\n * @cssprop --z-popover-theme--surface - background color of the popover.\n * @cssprop --z-popover-theme--text - foreground color of the popover.\n * @cssprop --z-popover-padding - padding of the popover.\n * @cssprop --z-popover-shadow-filter - drop-shadow filter of the popover. Defaults to `drop-shadow(0 1px 2px var(--shadow-color-base))`.\n */\n@Component({\n tag: \"z-popover\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZPopover {\n /**\n * The preferred position to render the popover.\n * The popover will automatically search another position if not enough space is available for the preferred position.\n * If the preferred position is not available, it will try to find the best position starting from `TOP` and going clockwise.\n */\n @Prop({reflect: true, mutable: true})\n position?: PopoverPosition = PopoverPosition.TOP;\n\n /** The open state of the popover. */\n @Prop({reflect: true, mutable: true})\n open = false;\n\n /**\n * The selector or the element bound with the popover.\n * If string css selector is provided make sure to use a valid selector.\n */\n @Prop()\n bindTo?: string | HTMLElement;\n\n /** Whether to show popover's arrow. */\n @Prop({reflect: true})\n showArrow = false;\n\n /** Whether to center the popup on the main side (according to \"position\"). */\n @Prop({reflect: true})\n center = false;\n\n /**\n * If true, the popover can be closed by clicking outside of it or pressing the escape key.\n * Otherwise, it will be closed only programmatically (by setting `open` to `false`).\n */\n @Prop()\n closable = true;\n\n /**\n * The current position of the popover.\n * It differs from `position` only when calculated automatically for space reasons.\n */\n @State()\n currentPosition?: PopoverPosition;\n\n @Element() host: HTMLZPopoverElement;\n\n // Clockwise order of positions.\n private static readonly positionOrder: PopoverPosition[] = [\n PopoverPosition.TOP,\n PopoverPosition.TOP_RIGHT,\n PopoverPosition.TOP_LEFT,\n PopoverPosition.RIGHT,\n PopoverPosition.RIGHT_BOTTOM,\n PopoverPosition.RIGHT_TOP,\n PopoverPosition.BOTTOM,\n PopoverPosition.BOTTOM_LEFT,\n PopoverPosition.BOTTOM_RIGHT,\n PopoverPosition.LEFT,\n PopoverPosition.LEFT_TOP,\n PopoverPosition.LEFT_BOTTOM,\n ] as const;\n\n private animationFrameRequestId?: number;\n\n /** space tolerance for space calculations */\n private readonly spaceTolerance = 3;\n\n /** The element bound to the popover. */\n private boundElement?: HTMLElement;\n\n /** Cached available space around the bound element to avoid unnecessary recalculations */\n private cachedAvailableSpace?: Offsets;\n\n /** Last bounding rect of the bound element to detect changes and eventually invalidate the caches. */\n private lastBoundRect?: DOMRect;\n\n /** Fired when the position changes. */\n @Event()\n positionChange: EventEmitter;\n\n /** Open change event. */\n @Event()\n openChange: EventEmitter;\n\n @Listen(\"keyup\", {target: \"window\"})\n closePopoverWithKeyboard(e: KeyboardEvent): void {\n if (this.closable && e.key === KeyboardCode.ESC) {\n this.open = false;\n }\n }\n\n /**\n * Close the popover when clicking outside of its content.\n * Stop event propagation if the click was fired by popover's trigger element,\n * to prevent close and reopen glitches.\n */\n @Listen(\"click\", {target: \"body\", capture: true})\n handleOutsideClick(e: MouseEvent): void {\n const target = e.target as Element;\n if (!this.closable || !this.open || containsElement(this.host, target)) {\n return;\n }\n\n if (containsElement(this.boundElement, target)) {\n // stop propagation if the click was on the trigger element to prevent close and reopen glitches\n e.stopPropagation();\n }\n this.open = false;\n }\n\n @Watch(\"position\")\n validatePosition(newValue: PopoverPosition): void {\n if (!Object.values(PopoverPosition).includes(newValue as PopoverPosition) || newValue === PopoverPosition.AUTO) {\n newValue = PopoverPosition.TOP;\n this.position = newValue;\n }\n this.currentPosition = newValue;\n if (this.open) {\n this.setPosition();\n }\n }\n\n /** Setup popover behaviors when `open` changes. */\n @Watch(\"open\")\n onOpen(): void {\n cancelAnimationFrame(this.animationFrameRequestId);\n this.openChange.emit({open: this.open});\n if (!this.open) {\n Object.assign(this.host.style, {\n // Reset all positioning properties\n top: \"auto\",\n right: \"auto\",\n bottom: \"auto\",\n left: \"auto\",\n maxWidth: \"\",\n maxHeight: \"\",\n // Set initial visibility to hidden while calculating position...\n visibility: \"hidden\",\n });\n this.currentPosition = undefined;\n\n return;\n }\n\n const updatePositionLoop = (): void => {\n if (!this.open) {\n return;\n }\n\n this.setPosition();\n this.animationFrameRequestId = requestAnimationFrame(updatePositionLoop);\n };\n\n // call `setPosition` after a tick to ensure the DOM is ready and sizes are available\n setTimeout(() => {\n updatePositionLoop();\n }, 0);\n }\n\n @Watch(\"bindTo\")\n onBindingChange(): void {\n this.findBoundElement();\n }\n\n /** Returns the offset modifier to use in calculations to align the popover with the bound element. */\n private get offsetModifier(): OffsetModifier {\n return this.center ? 0.5 : 0;\n }\n\n private findBoundElement(): void {\n if (typeof this.bindTo === \"string\") {\n this.boundElement = this.host.ownerDocument.querySelector(this.bindTo) as HTMLElement;\n } else if (this.bindTo) {\n this.boundElement = this.bindTo;\n } else {\n this.boundElement = this.host.parentElement as HTMLElement;\n }\n }\n\n /**\n * Check if element has enough space to the right and left to be centered.\n * Used for `TOP` and `BOTTOM` position.\n * When `center` is not enabled, only one side needs to be checked and `RIGHT` is the default.\n */\n private hasCenteredHorizontalSpace(\n availableLeft: number,\n availableRight: number,\n hostWidth: number,\n boundElementWidth: number\n ): boolean {\n const requiredSideSpace = (hostWidth - boundElementWidth) * (1 - this.offsetModifier);\n\n if (!this.center) {\n return availableRight >= requiredSideSpace - this.spaceTolerance;\n }\n\n return (\n availableRight >= requiredSideSpace - this.spaceTolerance &&\n availableLeft >= requiredSideSpace - this.spaceTolerance\n );\n }\n\n /**\n * Check if element has enough space to the top and bottom to be centered.\n * Used for `RIGHT` and `LEFT` position.\n * When `center` is not enabled, only one side needs to be checked and `BOTTOM` is the default.\n */\n private hasCenteredVerticalSpace(\n availableTop: number,\n availableBottom: number,\n hostHeight: number,\n boundElementHeight: number\n ): boolean {\n const requiredSideSpace = (hostHeight - boundElementHeight) * (1 - this.offsetModifier);\n\n if (!this.center) {\n return availableBottom >= requiredSideSpace - this.spaceTolerance;\n }\n\n return (\n availableTop >= requiredSideSpace - this.spaceTolerance &&\n availableBottom >= requiredSideSpace - this.spaceTolerance\n );\n }\n\n /**\n * Check if there is enough space in the given direction to fit the popover.\n * Used for composed positions like TOP_RIGHT, LEFT_BOTTOM, etc.\n */\n private hasEnoughSideSpace(\n availableSpace: number,\n hostSize: number,\n boundElementSize: number,\n offsetModifier: OffsetModifier\n ): boolean {\n return availableSpace >= hostSize - boundElementSize * (1 - offsetModifier) - this.spaceTolerance;\n }\n\n /**\n * Given a desired position and available space around the bound element, returns the best position\n * that fits the popover, trying all positions if needed.\n * Takes into account offsetModifier for centering.\n * @param desiredPosition The desired position of the popover.\n * @param availableSpace The available space around the bound element.\n */\n private getOptimalPopoverPosition(desiredPosition: PopoverPosition, availableSpace: Offsets): PopoverPosition {\n const hostWidth = this.host.offsetWidth;\n const hostHeight = this.host.offsetHeight;\n const boundElementWidth = this.boundElement.getBoundingClientRect().width;\n const boundElementHeight = this.boundElement.getBoundingClientRect().height;\n const offsetModifier = this.offsetModifier;\n\n /** Check if there is enough space to fit the popover in the desired position */\n const fits = (pos: PopoverPosition): boolean => {\n switch (pos) {\n case PopoverPosition.TOP:\n return (\n availableSpace.top >= hostHeight - this.spaceTolerance &&\n this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth)\n );\n case PopoverPosition.TOP_RIGHT:\n return (\n availableSpace.top >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.TOP_LEFT:\n return (\n availableSpace.top >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.RIGHT:\n return (\n availableSpace.right >= hostWidth &&\n this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight)\n );\n case PopoverPosition.RIGHT_BOTTOM:\n return (\n availableSpace.right >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.RIGHT_TOP:\n return (\n availableSpace.right >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.BOTTOM:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth)\n );\n case PopoverPosition.BOTTOM_LEFT:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.BOTTOM_RIGHT:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.LEFT:\n return (\n availableSpace.left >= hostWidth &&\n this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight)\n );\n case PopoverPosition.LEFT_TOP:\n return (\n availableSpace.left >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.LEFT_BOTTOM:\n return (\n availableSpace.left >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier)\n );\n\n default:\n return false;\n }\n };\n\n // Check desired position first\n if (fits(desiredPosition)) {\n return desiredPosition;\n }\n\n // Find position index and create rotation starting from next position\n const positions = ZPopover.positionOrder;\n const startIndex = positions.indexOf(desiredPosition);\n\n if (startIndex === -1) {\n return desiredPosition; // fallback if position not found\n }\n\n // Try all other positions starting from the next one\n for (let i = 1; i < positions.length; i++) {\n const posIndex = (startIndex + i) % positions.length;\n const pos = positions[posIndex];\n if (fits(pos)) {\n return pos;\n }\n }\n\n return this.findBestFallbackPosition(availableSpace);\n }\n\n /** Find the best fallback position based on available space when no position fits perfectly. */\n private findBestFallbackPosition(availableSpace: Offsets): PopoverPosition {\n // Determine which horizontal and vertical direction has the most available space\n const bestHorizontalDirection =\n availableSpace.right >= availableSpace.left ? PopoverPosition.RIGHT : PopoverPosition.LEFT;\n\n const bestVerticalDirection =\n availableSpace.bottom >= availableSpace.top ? PopoverPosition.BOTTOM : PopoverPosition.TOP;\n\n // Choose the main direction based on which axis has more space overall\n const maxHorizontalSpace = Math.max(availableSpace.right, availableSpace.left);\n const maxVerticalSpace = Math.max(availableSpace.bottom, availableSpace.top);\n\n const mainDirection = maxVerticalSpace >= maxHorizontalSpace ? bestVerticalDirection : bestHorizontalDirection;\n\n // Decide if a secondary direction is needed\n // Only add a secondary direction if the difference between min and max in that axis is at least double\n let needsSecondaryDirection = false;\n\n if (mainDirection === bestVerticalDirection) {\n // If main direction is vertical, check horizontal space difference\n const minHorizontalSpace = Math.min(availableSpace.right, availableSpace.left);\n needsSecondaryDirection = maxHorizontalSpace >= minHorizontalSpace * 2;\n } else {\n // If main direction is horizontal, check vertical space difference\n const minVerticalSpace = Math.min(availableSpace.bottom, availableSpace.top);\n needsSecondaryDirection = maxVerticalSpace >= minVerticalSpace * 2;\n }\n\n if (!needsSecondaryDirection) {\n return mainDirection;\n }\n\n const secondaryDirection =\n mainDirection === bestVerticalDirection ? bestHorizontalDirection : bestVerticalDirection;\n\n // Return a combined position (e.g., \"bottom_right\")\n return `${mainDirection}_${secondaryDirection}` as PopoverPosition;\n }\n\n /**\n * Calculate available space around the element bound with the popover, based on its nearest scrollable ancestor.\n *\n * Calculations for `right` and `bottom` can be a little bit confusing because `boundingRect.right` and `bottom` may not be what you expect...\n * For more information see the explanation in the docs.\n * @link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#return_value\n */\n private calculateAvailableSpace(): Offsets {\n const boundElementRect = this.boundElement.getBoundingClientRect();\n\n if (\n this.lastBoundRect &&\n this.lastBoundRect.x === boundElementRect.x &&\n this.lastBoundRect.y === boundElementRect.y &&\n this.lastBoundRect.width === boundElementRect.width &&\n this.lastBoundRect.height === boundElementRect.height &&\n this.cachedAvailableSpace\n ) {\n // If the bound element's rect hasn't changed, return the cached rect\n return this.cachedAvailableSpace;\n }\n\n this.lastBoundRect = boundElementRect;\n const scrollableParent = findScrollableParent(this.boundElement);\n const scrollableParentRect = scrollableParent.getBoundingClientRect();\n const hasNestedScrollableParent = scrollableParent !== this.boundElement.ownerDocument.documentElement;\n const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;\n const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;\n const safeSpace = 8; // extra space to avoid popover being too close to the edges\n\n // These deltas represent the offset between the scrollable parent and the viewport.\n // They are used to adjust the available space calculations when the scrollable parent is not the document or body,\n // to try to fit the popover inside the scrollable parent.\n const deltaTop = hasNestedScrollableParent ? scrollableParentRect.top : 0;\n const deltaRight = hasNestedScrollableParent ? documentWidth - scrollableParentRect.right : 0;\n const deltaBottom = hasNestedScrollableParent ? documentHeight - scrollableParentRect.bottom : 0;\n const deltaLeft = hasNestedScrollableParent ? scrollableParentRect.left : 0;\n\n this.cachedAvailableSpace = {\n top: boundElementRect.top - deltaTop - safeSpace,\n right: documentWidth - boundElementRect.right - deltaRight - safeSpace,\n bottom: documentHeight - boundElementRect.bottom - deltaBottom - safeSpace,\n left: boundElementRect.left - deltaLeft - safeSpace,\n };\n\n return this.cachedAvailableSpace;\n }\n\n /** Calculate the space around an element relative to the viewport. */\n private calculateElementOffsets(element: HTMLElement): Offsets {\n const elementRect = element.getBoundingClientRect();\n const viewportWidth = element.ownerDocument.documentElement.clientWidth;\n const viewportHeight = element.ownerDocument.documentElement.clientHeight;\n\n return {\n top: elementRect.top,\n right: viewportWidth - elementRect.right,\n bottom: viewportHeight - elementRect.bottom,\n left: elementRect.left,\n };\n }\n\n /** Apply positioning styles based on passed position. */\n private applyPositionStyles(position: PopoverPosition, availableSpace: Offsets): void {\n const boundElementWidth = this.boundElement.offsetWidth;\n const boundElementHeight = this.boundElement.offsetHeight;\n /** Distance between the popover and the bound element */\n const distanceFromBound = 8;\n const offsetModifier = this.offsetModifier;\n /** Distance between the arrow center and the popover edge. Needed to align the center of the arrow with the center of the bound element when `showArrow` and `center` are enabled. */\n const arrowModifier = this.showArrow && this.center ? 8 : 0;\n const hostStyle = this.host.style;\n const boundElementOffsets = this.calculateElementOffsets(this.boundElement);\n\n let maxWidth: number;\n let maxHeight: number;\n\n switch (position) {\n case PopoverPosition.TOP:\n case PopoverPosition.TOP_RIGHT:\n hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;\n hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === PopoverPosition.TOP_RIGHT ? arrowModifier : 0)}px`;\n maxHeight = availableSpace.top - distanceFromBound;\n if (position === PopoverPosition.TOP_RIGHT) {\n maxWidth = availableSpace.right + boundElementWidth * offsetModifier;\n }\n break;\n\n case PopoverPosition.TOP_LEFT:\n hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;\n hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight}px`;\n maxWidth = availableSpace.left + boundElementWidth * offsetModifier;\n maxHeight = availableSpace.top - distanceFromBound;\n break;\n\n case PopoverPosition.BOTTOM:\n case PopoverPosition.BOTTOM_RIGHT:\n hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;\n hostStyle.left = `${boundElementOffsets.left + boundElementWidth * offsetModifier - (position === PopoverPosition.BOTTOM_RIGHT ? arrowModifier : 0)}px`;\n maxHeight = availableSpace.bottom - distanceFromBound;\n if (position === PopoverPosition.BOTTOM_RIGHT) {\n maxWidth = availableSpace.right + boundElementWidth * offsetModifier;\n }\n break;\n\n case PopoverPosition.BOTTOM_LEFT:\n hostStyle.top = `${boundElementOffsets.top + boundElementHeight}px`;\n hostStyle.right = `${boundElementOffsets.right + boundElementWidth * offsetModifier - arrowModifier}px`;\n maxWidth = availableSpace.left + boundElementWidth * offsetModifier;\n maxHeight = availableSpace.bottom - distanceFromBound;\n break;\n\n case PopoverPosition.RIGHT:\n case PopoverPosition.RIGHT_BOTTOM:\n hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === PopoverPosition.RIGHT_BOTTOM ? arrowModifier : 0)}px`;\n hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;\n maxWidth = availableSpace.right - distanceFromBound;\n if (position === PopoverPosition.RIGHT) {\n maxHeight = availableSpace.top + availableSpace.bottom + boundElementHeight;\n } else {\n maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;\n }\n break;\n\n case PopoverPosition.RIGHT_TOP:\n hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;\n hostStyle.left = `${boundElementOffsets.left + boundElementWidth}px`;\n maxWidth = availableSpace.right - distanceFromBound;\n maxHeight = availableSpace.top + boundElementHeight * offsetModifier;\n break;\n\n case PopoverPosition.LEFT:\n case PopoverPosition.LEFT_BOTTOM:\n hostStyle.top = `${boundElementOffsets.top + boundElementHeight * offsetModifier - (position === PopoverPosition.LEFT_BOTTOM ? arrowModifier : 0)}px`;\n hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;\n maxWidth = availableSpace.left - distanceFromBound;\n if (position === PopoverPosition.LEFT_BOTTOM) {\n maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;\n }\n break;\n\n case PopoverPosition.LEFT_TOP:\n hostStyle.right = `${boundElementOffsets.right + boundElementWidth}px`;\n hostStyle.bottom = `${boundElementOffsets.bottom + boundElementHeight * offsetModifier - arrowModifier}px`;\n maxWidth = availableSpace.left - distanceFromBound;\n maxHeight = availableSpace.top + boundElementHeight * offsetModifier;\n break;\n }\n\n if (getDevice() !== Device.MOBILE) {\n // Only force max sizes on non-mobile viewports\n Object.assign(hostStyle, {\n maxWidth: maxWidth ? `${maxWidth}px` : \"\",\n maxHeight: maxHeight ? `${maxHeight}px` : \"\",\n });\n }\n }\n\n /** Set the position of the popover. */\n private setPosition(): void {\n if (!this.boundElement) {\n return;\n }\n\n if (!isElementVisibleInContainer(this.boundElement, findScrollableParent(this.boundElement))) {\n // If the bound element is not visible, hide the popover too\n this.open = false;\n\n return;\n }\n\n Object.assign(this.host.style, {\n // Reset all positioning properties\n top: \"auto\",\n right: \"auto\",\n bottom: \"auto\",\n left: \"auto\",\n maxWidth: \"\",\n maxHeight: \"\",\n // Set initial visibility to hidden while calculating position...\n visibility: \"hidden\",\n });\n\n const availableSpace = this.calculateAvailableSpace();\n const position = this.getOptimalPopoverPosition(this.position, availableSpace);\n\n this.applyPositionStyles(position, availableSpace);\n this.currentPosition = position;\n this.positionChange.emit({position: this.currentPosition});\n\n // ...then restore the visibility\n this.host.style.visibility = \"visible\";\n }\n\n componentWillLoad(): void {\n this.validatePosition(this.position);\n }\n\n componentDidLoad(): void {\n this.findBoundElement();\n if (this.open) {\n this.onOpen();\n }\n }\n\n disconnectedCallback(): void {\n cancelAnimationFrame(this.animationFrameRequestId);\n }\n\n render(): HTMLZPopoverElement {\n return (\n <Host current-position={this.currentPosition}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/z-popover/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAC,MAAM,eAAe,CAAC;AAC3G,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,aAAa,CAAC;AAClE,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,SAAS,EACT,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;;;;;;GAYG;AAMH,MAAM,OAAO,QAAQ;;QAkEnB,6CAA6C;QAC5B,mBAAc,GAAG,CAAC,CAAC;wBA5DP,eAAe,CAAC,GAAG;oBAQzC,KAAK;;yBAWA,KAAK;sBAIR,KAAK;wBAOH,IAAI;;;IAkDf,wBAAwB,CAAC,CAAgB;QACvC,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,GAAG,EAAE,CAAC;YAChD,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED;;;;OAIG;I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AC;QAChB,CAAC;IACH,CAAC;IAED,oBAAoB;QAClB,oBAAoB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IACrD,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,yEAAmB,IAAI,CAAC,eAAe;YAC1C,8DAAa,CACR,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7nBD,gCAAgC;AACR,sBAAa,GAAsB;IACzD,eAAe,CAAC,GAAG;IACnB,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,KAAK;IACrB,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,SAAS;IACzB,eAAe,CAAC,MAAM;IACtB,eAAe,CAAC,WAAW;IAC3B,eAAe,CAAC,YAAY;IAC5B,eAAe,CAAC,IAAI;IACpB,eAAe,CAAC,QAAQ;IACxB,eAAe,CAAC,WAAW;CACnB,AAb2B,CAa1B","sourcesContent":["import {Component, Element, Event, EventEmitter, Host, Listen, Prop, State, Watch, h} from \"@stencil/core\";\nimport {Device, KeyboardCode, PopoverPosition} from \"../../beans\";\nimport {\n containsElement,\n findContainingBlockAncestor,\n getDevice,\n getParentElement,\n isElementVisibleInContainer,\n} from \"../../utils/utils\";\n\n/** Centering offset modifier. 0 for no offset, 0.5 for centering. */\ntype OffsetModifier = 0 | 0.5;\ntype Offsets = {top: number; right: number; bottom: number; left: number};\n\n/**\n * Popover component.\n * This component displays a popover bound to an element.\n * It supports various positions and can automatically adjust it based on available space, accounting for scrollable containers.\n *\n * Notes:\n * - If positioning has an odd behavior, consider manually adjusting the size of the slotted elements (using `width`, `height`, `max-width`, `max-height`, etc...) when its content is \"fluid\" (like text), because it can interfere with the position calculation (for example a long text on one single line can be bigger than the available space, letting the algorithm think the popover doesn't fits).\n *\n * @cssprop --z-popover-theme--surface - background color of the popover.\n * @cssprop --z-popover-theme--text - foreground color of the popover.\n * @cssprop --z-popover-padding - padding of the popover.\n * @cssprop --z-popover-shadow-filter - drop-shadow filter of the popover. Defaults to `drop-shadow(0 1px 2px var(--shadow-color-base))`.\n */\n@Component({\n tag: \"z-popover\",\n styleUrl: \"styles.css\",\n shadow: true,\n})\nexport class ZPopover {\n /**\n * The preferred position to render the popover.\n * The popover will automatically search another position if not enough space is available for the preferred position.\n * If the preferred position is not available, it will try to find the best position starting from `TOP` and going clockwise.\n */\n @Prop({reflect: true, mutable: true})\n position?: PopoverPosition = PopoverPosition.TOP;\n\n /**\n * The initial open state of the popover.\n * Internal changes of this prop are emitted through the `openChange` event.\n * Make sure to listen to that event if you need the updated state of the popover from the outside, to avoid inconsistent values.\n */\n @Prop({reflect: true, mutable: true})\n open = false;\n\n /**\n * The selector or the element bound with the popover.\n * If string css selector is provided make sure to use a valid selector.\n */\n @Prop()\n bindTo?: string | HTMLElement;\n\n /** Whether to show popover's arrow. */\n @Prop({reflect: true})\n showArrow = false;\n\n /** Whether to center the popup on the main side (according to \"position\"). */\n @Prop({reflect: true})\n center = false;\n\n /**\n * If true, the popover can be closed by clicking outside of it or pressing the escape key.\n * Otherwise, it will be closed only programmatically (by setting `open` to `false`).\n */\n @Prop()\n closable = true;\n\n /**\n * The current position of the popover.\n * It differs from `position` only when calculated automatically for space reasons.\n */\n @State()\n currentPosition?: PopoverPosition;\n\n @Element() host: HTMLZPopoverElement;\n\n // Clockwise order of positions.\n private static readonly positionOrder: PopoverPosition[] = [\n PopoverPosition.TOP,\n PopoverPosition.TOP_RIGHT,\n PopoverPosition.TOP_LEFT,\n PopoverPosition.RIGHT,\n PopoverPosition.RIGHT_BOTTOM,\n PopoverPosition.RIGHT_TOP,\n PopoverPosition.BOTTOM,\n PopoverPosition.BOTTOM_LEFT,\n PopoverPosition.BOTTOM_RIGHT,\n PopoverPosition.LEFT,\n PopoverPosition.LEFT_TOP,\n PopoverPosition.LEFT_BOTTOM,\n ] as const;\n\n private animationFrameRequestId?: number;\n\n /** space tolerance for space calculations */\n private readonly spaceTolerance = 3;\n\n /** The element bound to the popover. */\n private boundElement?: HTMLElement;\n\n /** Cached available space around the bound element to avoid unnecessary recalculations */\n private cachedAvailableSpace?: Offsets;\n\n /** Last bounding rect of the bound element to detect changes and eventually invalidate the caches. */\n private lastBoundRect?: DOMRect;\n\n /** Fired when the position changes. */\n @Event()\n positionChange: EventEmitter;\n\n /** Open change event. */\n @Event()\n openChange: EventEmitter;\n\n @Listen(\"keyup\", {target: \"window\"})\n closePopoverWithKeyboard(e: KeyboardEvent): void {\n if (this.closable && e.key === KeyboardCode.ESC) {\n this.open = false;\n }\n }\n\n /**\n * Close the popover when clicking outside of its content.\n * Stop event propagation if the click was fired by popover's trigger element,\n * to prevent close and reopen glitches.\n */\n @Listen(\"click\", {target: \"body\", capture: true})\n handleOutsideClick(e: MouseEvent): void {\n const target = e.target as Element;\n if (!this.closable || !this.open || containsElement(this.host, target)) {\n return;\n }\n\n if (containsElement(this.boundElement, target)) {\n // stop propagation if the click was on the trigger element to prevent close and reopen glitches\n e.stopPropagation();\n }\n this.open = false;\n }\n\n @Watch(\"position\")\n validatePosition(newValue: PopoverPosition): void {\n if (!Object.values(PopoverPosition).includes(newValue as PopoverPosition) || newValue === PopoverPosition.AUTO) {\n newValue = PopoverPosition.TOP;\n this.position = newValue;\n }\n this.currentPosition = newValue;\n if (this.open) {\n this.setPosition();\n }\n }\n\n /** Setup popover behaviors when `open` changes. */\n @Watch(\"open\")\n onOpen(): void {\n cancelAnimationFrame(this.animationFrameRequestId);\n this.openChange.emit({open: this.open});\n if (!this.open) {\n Object.assign(this.host.style, {\n // Reset all positioning properties\n top: \"auto\",\n right: \"auto\",\n bottom: \"auto\",\n left: \"auto\",\n maxWidth: \"\",\n maxHeight: \"\",\n // Set initial visibility to hidden while calculating position...\n visibility: \"hidden\",\n });\n this.currentPosition = undefined;\n\n return;\n }\n\n const updatePositionLoop = (): void => {\n if (!this.open) {\n return;\n }\n\n this.setPosition();\n this.animationFrameRequestId = requestAnimationFrame(updatePositionLoop);\n };\n\n // call `setPosition` after a tick to ensure the DOM is ready and sizes are available\n setTimeout(() => {\n updatePositionLoop();\n }, 0);\n }\n\n @Watch(\"bindTo\")\n onBindingChange(): void {\n this.findBoundElement();\n }\n\n /** Returns the offset modifier to use in calculations to align the popover with the bound element. */\n private get offsetModifier(): OffsetModifier {\n return this.center ? 0.5 : 0;\n }\n\n private findBoundElement(): void {\n if (typeof this.bindTo === \"string\") {\n this.boundElement = this.host.ownerDocument.querySelector(this.bindTo) as HTMLElement;\n } else if (this.bindTo) {\n this.boundElement = this.bindTo;\n } else {\n this.boundElement = getParentElement(this.host) as HTMLElement;\n if (this.boundElement.tagName.toLowerCase() === \"z-tooltip\") {\n // If the popover is used inside a tooltip without a specified `bindTo`, bind it to the parent of the tooltip.\n this.boundElement = getParentElement(this.boundElement) as HTMLElement;\n }\n }\n }\n\n /**\n * Check if element has enough space to the right and left to be centered.\n * Used for `TOP` and `BOTTOM` position.\n * When `center` is not enabled, only one side needs to be checked and `RIGHT` is the default.\n */\n private hasCenteredHorizontalSpace(\n availableLeft: number,\n availableRight: number,\n hostWidth: number,\n boundElementWidth: number\n ): boolean {\n const requiredSideSpace = (hostWidth - boundElementWidth) * (1 - this.offsetModifier);\n\n if (!this.center) {\n return availableRight >= requiredSideSpace - this.spaceTolerance;\n }\n\n return (\n availableRight >= requiredSideSpace - this.spaceTolerance &&\n availableLeft >= requiredSideSpace - this.spaceTolerance\n );\n }\n\n /**\n * Check if element has enough space to the top and bottom to be centered.\n * Used for `RIGHT` and `LEFT` position.\n * When `center` is not enabled, only one side needs to be checked and `BOTTOM` is the default.\n */\n private hasCenteredVerticalSpace(\n availableTop: number,\n availableBottom: number,\n hostHeight: number,\n boundElementHeight: number\n ): boolean {\n const requiredSideSpace = (hostHeight - boundElementHeight) * (1 - this.offsetModifier);\n\n if (!this.center) {\n return availableBottom >= requiredSideSpace - this.spaceTolerance;\n }\n\n return (\n availableTop >= requiredSideSpace - this.spaceTolerance &&\n availableBottom >= requiredSideSpace - this.spaceTolerance\n );\n }\n\n /**\n * Check if there is enough space in the given direction to fit the popover.\n * Used for composed positions like TOP_RIGHT, LEFT_BOTTOM, etc.\n */\n private hasEnoughSideSpace(\n availableSpace: number,\n hostSize: number,\n boundElementSize: number,\n offsetModifier: OffsetModifier\n ): boolean {\n return availableSpace >= hostSize - boundElementSize * (1 - offsetModifier) - this.spaceTolerance;\n }\n\n /**\n * Given a desired position and available space around the bound element, returns the best position\n * that fits the popover, trying all positions if needed.\n * Takes into account offsetModifier for centering.\n * @param desiredPosition The desired position of the popover.\n * @param availableSpace The available space around the bound element.\n */\n private getOptimalPopoverPosition(desiredPosition: PopoverPosition, availableSpace: Offsets): PopoverPosition {\n const hostWidth = this.host.offsetWidth;\n const hostHeight = this.host.offsetHeight;\n const boundElementWidth = this.boundElement.getBoundingClientRect().width;\n const boundElementHeight = this.boundElement.getBoundingClientRect().height;\n const offsetModifier = this.offsetModifier;\n\n /** Check if there is enough space to fit the popover in the desired position */\n const fits = (pos: PopoverPosition): boolean => {\n switch (pos) {\n case PopoverPosition.TOP:\n return (\n availableSpace.top >= hostHeight - this.spaceTolerance &&\n this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth)\n );\n case PopoverPosition.TOP_RIGHT:\n return (\n availableSpace.top >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.TOP_LEFT:\n return (\n availableSpace.top >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.RIGHT:\n return (\n availableSpace.right >= hostWidth &&\n this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight)\n );\n case PopoverPosition.RIGHT_BOTTOM:\n return (\n availableSpace.right >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.RIGHT_TOP:\n return (\n availableSpace.right >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.BOTTOM:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasCenteredHorizontalSpace(availableSpace.left, availableSpace.right, hostWidth, boundElementWidth)\n );\n case PopoverPosition.BOTTOM_LEFT:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.left, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.BOTTOM_RIGHT:\n return (\n availableSpace.bottom >= hostHeight &&\n this.hasEnoughSideSpace(availableSpace.right, hostWidth, boundElementWidth, offsetModifier)\n );\n case PopoverPosition.LEFT:\n return (\n availableSpace.left >= hostWidth &&\n this.hasCenteredVerticalSpace(availableSpace.top, availableSpace.bottom, hostHeight, boundElementHeight)\n );\n case PopoverPosition.LEFT_TOP:\n return (\n availableSpace.left >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.top, hostHeight, boundElementHeight, offsetModifier)\n );\n case PopoverPosition.LEFT_BOTTOM:\n return (\n availableSpace.left >= hostWidth &&\n this.hasEnoughSideSpace(availableSpace.bottom, hostHeight, boundElementHeight, offsetModifier)\n );\n\n default:\n return false;\n }\n };\n\n // Check desired position first\n if (fits(desiredPosition)) {\n return desiredPosition;\n }\n\n // Find position index and create rotation starting from next position\n const positions = ZPopover.positionOrder;\n const startIndex = positions.indexOf(desiredPosition);\n\n if (startIndex === -1) {\n return desiredPosition; // fallback if position not found\n }\n\n // Try all other positions starting from the next one\n for (let i = 1; i < positions.length; i++) {\n const posIndex = (startIndex + i) % positions.length;\n const pos = positions[posIndex];\n if (fits(pos)) {\n return pos;\n }\n }\n\n return this.findBestFallbackPosition(availableSpace);\n }\n\n /** Find the best fallback position based on available space when no position fits perfectly. */\n private findBestFallbackPosition(availableSpace: Offsets): PopoverPosition {\n // Determine which horizontal and vertical direction has the most available space\n const bestHorizontalDirection =\n availableSpace.right >= availableSpace.left ? PopoverPosition.RIGHT : PopoverPosition.LEFT;\n\n const bestVerticalDirection =\n availableSpace.bottom >= availableSpace.top ? PopoverPosition.BOTTOM : PopoverPosition.TOP;\n\n // Choose the main direction based on which axis has more space overall\n const maxHorizontalSpace = Math.max(availableSpace.right, availableSpace.left);\n const maxVerticalSpace = Math.max(availableSpace.bottom, availableSpace.top);\n\n const mainDirection = maxVerticalSpace >= maxHorizontalSpace ? bestVerticalDirection : bestHorizontalDirection;\n\n // Decide if a secondary direction is needed\n // Only add a secondary direction if the difference between min and max in that axis is at least double\n let needsSecondaryDirection = false;\n\n if (mainDirection === bestVerticalDirection) {\n // If main direction is vertical, check horizontal space difference\n const minHorizontalSpace = Math.min(availableSpace.right, availableSpace.left);\n needsSecondaryDirection = maxHorizontalSpace >= minHorizontalSpace * 2;\n } else {\n // If main direction is horizontal, check vertical space difference\n const minVerticalSpace = Math.min(availableSpace.bottom, availableSpace.top);\n needsSecondaryDirection = maxVerticalSpace >= minVerticalSpace * 2;\n }\n\n if (!needsSecondaryDirection) {\n return mainDirection;\n }\n\n const secondaryDirection =\n mainDirection === bestVerticalDirection ? bestHorizontalDirection : bestVerticalDirection;\n\n // Return a combined position (e.g., \"bottom_right\")\n return `${mainDirection}_${secondaryDirection}` as PopoverPosition;\n }\n\n /**\n * Find the nearest scrollable ancestor of an element to take as a reference for positioning.\n * The ancestor is considered scrollable if it doesn't have `overflow` property set to `hidden` and its scroll size is bigger than its client size.\n */\n private findScrollableAncestor(element: HTMLElement): HTMLElement {\n let parent = getParentElement(element);\n\n while (parent) {\n if (parent === element.ownerDocument.documentElement) {\n return parent as HTMLElement;\n }\n\n const style = window.getComputedStyle(parent);\n const {overflow, overflowX, overflowY} = style;\n const hasHiddenOverflow = overflow === \"hidden\" || overflowY === \"hidden\" || overflowX === \"hidden\";\n const isScrollable =\n (parent.scrollHeight > parent.clientHeight && overflow !== \"visible\" && overflowY !== \"visible\") ||\n (parent.scrollWidth > parent.clientWidth && overflow !== \"visible\" && overflowX !== \"visible\");\n\n if (!hasHiddenOverflow && isScrollable) {\n return parent as HTMLElement;\n }\n\n parent = getParentElement(parent);\n }\n\n return element.ownerDocument.documentElement;\n }\n\n /**\n * Calculate available space around the element bound with the popover, based on its nearest scrollable ancestor.\n *\n * Calculations for `right` and `bottom` can be a little bit confusing because `boundingRect.right` and `bottom` may not be what you expect...\n * For more information see the explanation in the docs.\n * @link https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect#return_value\n */\n private calculateAvailableSpace(): Offsets {\n const boundElementRect = this.boundElement.getBoundingClientRect();\n\n if (\n this.lastBoundRect &&\n this.lastBoundRect.x === boundElementRect.x &&\n this.lastBoundRect.y === boundElementRect.y &&\n this.lastBoundRect.width === boundElementRect.width &&\n this.lastBoundRect.height === boundElementRect.height &&\n this.cachedAvailableSpace\n ) {\n // If the bound element's rect hasn't changed, return the cached rect\n return this.cachedAvailableSpace;\n }\n\n this.lastBoundRect = boundElementRect;\n const scrollableAncestor = this.findScrollableAncestor(this.boundElement);\n const scrollableAncestorRect = scrollableAncestor.getBoundingClientRect();\n const isScrollableAncestorNested = scrollableAncestor !== this.boundElement.ownerDocument.documentElement;\n const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;\n const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;\n const safeSpace = 8; // extra space to avoid popover being too close to the edges\n\n // These deltas represent the offset between the scrollable ancestor and the viewport.\n // They are used to adjust the available space calculations when the scrollable ancestor is not the document or body,\n // to try to fit the popover inside the scrollable ancestor.\n const deltaTop = isScrollableAncestorNested ? scrollableAncestorRect.top : 0;\n const deltaRight = isScrollableAncestorNested ? documentWidth - scrollableAncestorRect.right : 0;\n const deltaBottom = isScrollableAncestorNested ? documentHeight - scrollableAncestorRect.bottom : 0;\n const deltaLeft = isScrollableAncestorNested ? scrollableAncestorRect.left : 0;\n\n this.cachedAvailableSpace = {\n top: boundElementRect.top - deltaTop - safeSpace,\n right: documentWidth - boundElementRect.right - deltaRight - safeSpace,\n bottom: documentHeight - boundElementRect.bottom - deltaBottom - safeSpace,\n left: boundElementRect.left - deltaLeft - safeSpace,\n };\n\n return this.cachedAvailableSpace;\n }\n\n /** Calculate the space around the bound element relative to the viewport. */\n private getBoundElementOffsets(): Offsets {\n const elementRect = this.boundElement.getBoundingClientRect();\n const documentWidth = this.boundElement.ownerDocument.documentElement.clientWidth;\n const documentHeight = this.boundElement.ownerDocument.documentElement.clientHeight;\n\n return {\n top: elementRect.top,\n right: documentWidth - elementRect.right,\n bottom: documentHeight - elementRect.bottom,\n left: elementRect.left,\n };\n }\n\n /** Compute positioning offsets in the appropriate coordinate space, accounting for transformed containing blocks and scroll. */\n private computePositionOffsets(): Offsets {\n const boundElementOffsets = this.getBoundElementOffsets();\n const containingBlockAncestor = findContainingBlockAncestor(this.host);\n const isDocumentElement = containingBlockAncestor === this.host.ownerDocument.documentElement;\n\n if (isDocumentElement) {\n return boundElementOffsets;\n }\n\n const containingBlockRect = containingBlockAncestor.getBoundingClientRect();\n const containingBlockStyle = getComputedStyle(containingBlockAncestor);\n /** Padding box of the containing block, accounting for borders. */\n const paddingBox = {\n top: containingBlockRect.top + parseFloat(containingBlockStyle.borderTopWidth),\n right: containingBlockRect.right - parseFloat(containingBlockStyle.borderRightWidth),\n bottom: containingBlockRect.bottom - parseFloat(containingBlockStyle.borderBottomWidth),\n left: containingBlockRect.left + parseFloat(containingBlockStyle.borderLeftWidth),\n };\n\n const boundElementRect = this.boundElement.getBoundingClientRect();\n /** Bound element offsets relative to the containing block padding box. */\n const relativeOffsets = {\n top: boundElementRect.top - paddingBox.top,\n right: paddingBox.right - boundElementRect.right,\n bottom: paddingBox.bottom - boundElementRect.bottom,\n left: boundElementRect.left - paddingBox.left,\n };\n\n /** Account for scroll to keep the popover aligned while the containing block scrolls. */\n return {\n top: relativeOffsets.top + containingBlockAncestor.scrollTop,\n right: relativeOffsets.right - containingBlockAncestor.scrollLeft,\n bottom: relativeOffsets.bottom - containingBlockAncestor.scrollTop,\n left: relativeOffsets.left + containingBlockAncestor.scrollLeft,\n };\n }\n\n /** Apply positioning styles based on `position` parameter. */\n private applyPositionStyles(position: PopoverPosition, availableSpace: Offsets): void {\n const boundElementWidth = this.boundElement.offsetWidth;\n const boundElementHeight = this.boundElement.offsetHeight;\n const offsetModifier = this.offsetModifier;\n /** Distance between the arrow center and the popover edge. Needed to align the center of the arrow with the center of the bound element when `showArrow` and `center` are enabled. */\n const arrowModifier = this.showArrow && this.center ? 8 : 0;\n const hostStyle = this.host.style;\n /** Gap between the popover and the bound element. */\n const distanceFromBound = parseInt(hostStyle.getPropertyValue(\"--space-unit\")) || 8;\n const positionOffsets = this.computePositionOffsets();\n\n /**\n * Precomputed bases to reduce repeated arithmetic in the switch below.\n * They represent the bound element edges plus optional centering offsets.\n */\n const leftBase = positionOffsets.left + boundElementWidth * offsetModifier;\n const rightBase = positionOffsets.right + boundElementWidth * offsetModifier;\n const topBase = positionOffsets.top + boundElementHeight;\n const bottomBase = positionOffsets.bottom + boundElementHeight;\n const sideTopBase = positionOffsets.top + boundElementHeight * offsetModifier;\n const sideBottomBase = positionOffsets.bottom + boundElementHeight * offsetModifier;\n\n let maxWidth: number;\n let maxHeight: number;\n\n switch (position) {\n case PopoverPosition.TOP:\n case PopoverPosition.TOP_RIGHT:\n hostStyle.bottom = `${bottomBase + distanceFromBound}px`;\n hostStyle.left = `${leftBase - (position === PopoverPosition.TOP_RIGHT ? arrowModifier : 0)}px`;\n maxHeight = availableSpace.top - distanceFromBound;\n if (position === PopoverPosition.TOP_RIGHT) {\n maxWidth = availableSpace.right + boundElementWidth * offsetModifier;\n }\n break;\n\n case PopoverPosition.TOP_LEFT:\n hostStyle.right = `${rightBase - arrowModifier}px`;\n hostStyle.bottom = `${bottomBase + distanceFromBound}px`;\n maxWidth = availableSpace.left + boundElementWidth * offsetModifier;\n maxHeight = availableSpace.top - distanceFromBound;\n break;\n\n case PopoverPosition.BOTTOM:\n case PopoverPosition.BOTTOM_RIGHT:\n hostStyle.top = `${topBase + distanceFromBound}px`;\n hostStyle.left = `${leftBase - (position === PopoverPosition.BOTTOM_RIGHT ? arrowModifier : 0)}px`;\n maxHeight = availableSpace.bottom - distanceFromBound;\n if (position === PopoverPosition.BOTTOM_RIGHT) {\n maxWidth = availableSpace.right + boundElementWidth * offsetModifier;\n }\n break;\n\n case PopoverPosition.BOTTOM_LEFT:\n hostStyle.top = `${topBase + distanceFromBound}px`;\n hostStyle.right = `${rightBase - arrowModifier}px`;\n maxWidth = availableSpace.left + boundElementWidth * offsetModifier;\n maxHeight = availableSpace.bottom - distanceFromBound;\n break;\n\n case PopoverPosition.RIGHT:\n case PopoverPosition.RIGHT_BOTTOM:\n hostStyle.top = `${sideTopBase - (position === PopoverPosition.RIGHT_BOTTOM ? arrowModifier : 0)}px`;\n hostStyle.left = `${positionOffsets.left + boundElementWidth + distanceFromBound}px`;\n maxWidth = availableSpace.right - distanceFromBound;\n if (position === PopoverPosition.RIGHT) {\n maxHeight = availableSpace.top + availableSpace.bottom + boundElementHeight;\n } else {\n maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;\n }\n break;\n\n case PopoverPosition.RIGHT_TOP:\n hostStyle.bottom = `${sideBottomBase - arrowModifier}px`;\n hostStyle.left = `${positionOffsets.left + boundElementWidth + distanceFromBound}px`;\n maxWidth = availableSpace.right - distanceFromBound;\n maxHeight = availableSpace.top + boundElementHeight * offsetModifier;\n break;\n\n case PopoverPosition.LEFT:\n case PopoverPosition.LEFT_BOTTOM:\n hostStyle.top = `${sideTopBase - (position === PopoverPosition.LEFT_BOTTOM ? arrowModifier : 0)}px`;\n hostStyle.right = `${positionOffsets.right + boundElementWidth + distanceFromBound}px`;\n maxWidth = availableSpace.left - distanceFromBound;\n if (position === PopoverPosition.LEFT_BOTTOM) {\n maxHeight = availableSpace.bottom + boundElementHeight * offsetModifier;\n }\n break;\n\n case PopoverPosition.LEFT_TOP:\n hostStyle.right = `${positionOffsets.right + boundElementWidth + distanceFromBound}px`;\n hostStyle.bottom = `${sideBottomBase - arrowModifier}px`;\n maxWidth = availableSpace.left - distanceFromBound;\n maxHeight = availableSpace.top + boundElementHeight * offsetModifier;\n break;\n }\n\n if (getDevice() !== Device.MOBILE) {\n // Only force max sizes on non-mobile viewports\n Object.assign(hostStyle, {\n maxWidth: maxWidth ? `${maxWidth}px` : \"\",\n maxHeight: maxHeight ? `${maxHeight}px` : \"\",\n });\n }\n }\n\n /** Set the position of the popover. */\n private setPosition(): void {\n if (!this.boundElement) {\n return;\n }\n\n if (!isElementVisibleInContainer(this.boundElement, this.findScrollableAncestor(this.boundElement))) {\n // If the bound element is not visible, hide the popover too\n this.open = false;\n\n return;\n }\n\n Object.assign(this.host.style, {\n // Reset all positioning properties\n top: \"auto\",\n right: \"auto\",\n bottom: \"auto\",\n left: \"auto\",\n maxWidth: \"\",\n maxHeight: \"\",\n // Set initial visibility to hidden while calculating position...\n visibility: \"hidden\",\n });\n\n const availableSpace = this.calculateAvailableSpace();\n const position = this.getOptimalPopoverPosition(this.position, availableSpace);\n\n this.applyPositionStyles(position, availableSpace);\n this.currentPosition = position;\n this.positionChange.emit({position: this.currentPosition});\n\n // ...then restore the visibility\n this.host.style.visibility = \"visible\";\n }\n\n componentWillLoad(): void {\n this.validatePosition(this.position);\n }\n\n componentDidLoad(): void {\n this.findBoundElement();\n if (this.open) {\n this.onOpen();\n }\n }\n\n disconnectedCallback(): void {\n cancelAnimationFrame(this.animationFrameRequestId);\n }\n\n render(): HTMLZPopoverElement {\n return (\n <Host current-position={this.currentPosition}>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
@@ -5,6 +5,7 @@ import { getColorTokenArgConfig } from "../../utils/storybook-utils";
5
5
  import "../list/z-list-element/index";
6
6
  import "../list/z-list/index";
7
7
  import "../z-button/index";
8
+ import "../z-offcanvas/index";
8
9
  import "./index";
9
10
  import "./index.stories.css";
10
11
  const onTriggerClick = (event) => {
@@ -231,4 +232,52 @@ export const TooltipWithNestedContainer = {
231
232
  </div>
232
233
  </div>`,
233
234
  };
235
+ export const PopoverInsideTransformedElement = {
236
+ args: {
237
+ "position": PopoverPosition.TOP,
238
+ "--z-popover-padding": "var(--space-unit)",
239
+ },
240
+ render: (args, { parameters }) => html `<div class="popover-container">
241
+ <script>
242
+ document.addEventListener("DOMContentLoaded", () => {
243
+ const offcanvasTrigger = document.querySelector("#offcanvas-trigger");
244
+ if (offcanvasTrigger) {
245
+ offcanvasTrigger.addEventListener("click", () => {
246
+ const offcanvas = document.querySelector(".popover-container z-offcanvas");
247
+ if (offcanvas) {
248
+ offcanvas.open = true;
249
+ }
250
+ });
251
+ }
252
+ });
253
+ </script>
254
+ <z-button id="offcanvas-trigger">open offcanvas</z-button>
255
+ <z-offcanvas
256
+ transitiondirection="up"
257
+ show-backdrop
258
+ >
259
+ <div slot="canvasContent">
260
+ <z-popover
261
+ style=${styleMap({
262
+ "--z-popover-theme--surface": args["--z-popover-theme--surface"],
263
+ "--z-popover-theme--text": args["--z-popover-theme--text"],
264
+ "--z-popover-padding": args["--z-popover-padding"],
265
+ })}
266
+ .position=${args.position}
267
+ bind-to="#popover-trigger"
268
+ >
269
+ <div class="popover-content">
270
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et
271
+ dolore magna aliqua.
272
+ </div>
273
+ </z-popover>
274
+ <z-button
275
+ id="popover-trigger"
276
+ icon="plus-filled"
277
+ .onclick=${parameters.onTriggerClick}
278
+ ></z-button>
279
+ </div>
280
+ </z-offcanvas>
281
+ </div>`,
282
+ };
234
283
  //# sourceMappingURL=index.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../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Ae,CAAC,KAAK;QACjC,qBAAqB,EAAE,mBAAmB;KAC3C;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAC,UAAU,EAAC,EAAE,EAAE,CAC7B,IAAI,CAAA;;gBAEQ,QAAQ,CAAC;QACf,4BAA4B,EAAE,IAAI,CAAC,4BAA4B,CAAC;QAChE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC;QAC1D,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC;KACnD,CAAC;oBACU,IAAI,CAAC,QAAQ;;;;;;;;;;;;;mBAad,UAAU,CAAC,cAAc;;WAEjC;CACM,CAAC;AAElB,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE;QACJ,UAAU,EAAE,eAAe,CAAC,GAAG;QAC/B,qBAAqB,EAAE,mBAAmB;KAC3C;IACD,MAAM,EAAE,CAAC,IAAI,EAAE,EAAC,UAAU,EAAC,EAAE,EAAE,CAC7B,IAAI,CAAA;;;;oBAIY,QAAQ,CAAC;QACf,4BAA4B,EAAE,IAAI,CAAC,4BAA4B,CAAC;QAChE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC;QAC1D,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC;KACnD,CAAC;wBACU,IAAI,CAAC,QAAQ;;;;;;;;;;;;;uBAad,UAAU,CAAC,cAAc;;;;WAIrC;CACM,CAAC","sourcesContent":["import {Meta, StoryObj} from \"@storybook/web-components\";\nimport {html} from \"lit\";\nimport {styleMap} from \"lit/directives/style-map.js\";\nimport {ZPopover} from \".\";\nimport {PopoverPosition} from \"../../beans\";\nimport {CSSVarsArguments, getColorTokenArgConfig} from \"../../utils/storybook-utils\";\nimport \"../list/z-list-element/index\";\nimport \"../list/z-list/index\";\nimport \"../z-button/index\";\nimport \"./index\";\nimport \"./index.stories.css\";\n\ntype ZPopoverStoriesArgs = ZPopover &\n CSSVarsArguments<\n \"--z-popover-theme--surface\" | \"--z-popover-theme--text\" | \"--z-popover-padding\" | \"--z-popover-shadow-filter\"\n >;\n\nconst onTriggerClick = (event: MouseEvent): void => {\n const popover = (event.target as HTMLElement).closest(\".popover-container\")?.querySelector(\"z-popover\");\n if (!popover) {\n return;\n }\n\n if (popover?.open) {\n popover.open = false;\n } else {\n popover.open = true;\n }\n};\n\n/**\n * Simple drag and drop utility.\n * @param element The element to make draggable.\n */\nconst makeDraggable = (element: HTMLElement): void => {\n if (element.draggable) {\n return;\n }\n\n let offsetX = 0;\n let offsetY = 0;\n let dragging = false;\n let clickPosition = {x: 0, y: 0};\n\n element.style.position = \"absolute\";\n element.draggable = true;\n\n element.addEventListener(\"mousedown\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n dragging = true;\n offsetX = element.offsetLeft - event.clientX;\n offsetY = element.offsetTop - event.clientY;\n clickPosition = {x: event.clientX, y: event.clientY};\n });\n\n document.addEventListener(\"mouseup\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n dragging = false;\n\n if (clickPosition.x !== event.clientX || clickPosition.y !== event.clientY) {\n return;\n }\n\n setTimeout(() => {\n onTriggerClick({...event, target: element});\n }, 0);\n });\n\n document.addEventListener(\"mousemove\", (event) => {\n if (dragging) {\n const container = element.parentElement;\n const left = Math.max(Math.min(event.clientX + offsetX, container.clientWidth - element.offsetWidth), 0);\n const top = Math.max(Math.min(event.clientY + offsetY, container.clientHeight - element.offsetHeight), 0);\n element.style.left = `${left}px`;\n element.style.top = `${top}px`;\n }\n });\n};\n\nconst StoryMeta = {\n title: \"ZPopover\",\n component: \"z-popover\",\n argTypes: {\n \"position\": {\n options: [null, ...Object.values(PopoverPosition).filter((value) => value !== PopoverPosition.AUTO)],\n control: {\n type: \"select\",\n labels: {\n null: \"-\",\n },\n },\n },\n \"--z-popover-theme--surface\": getColorTokenArgConfig(),\n \"--z-popover-theme--text\": getColorTokenArgConfig(),\n },\n args: {\n \"position\": null,\n \"--z-popover-theme--surface\": \"var(--color-surface01)\",\n \"--z-popover-theme--text\": \"var(--color-default-text)\",\n \"--z-popover-padding\": \"0\",\n },\n parameters: {\n onTriggerClick,\n docs: {\n story: {\n inline: false,\n iframeHeight: 500,\n },\n },\n },\n} satisfies Meta<ZPopoverStoriesArgs>;\n\nexport default StoryMeta;\n\ntype Story = StoryObj<ZPopoverStoriesArgs>;\n\nexport const Demo = {\n args: {\n \"--z-popover-padding\": \"var(--space-unit)\",\n \"--z-popover-shadow-filter\": \"drop-shadow(0 1px 2px var(--shadow-color-base))\",\n \"center\": false,\n \"showArrow\": false,\n \"closable\": true,\n },\n render: (args) => {\n document.addEventListener(\"DOMContentLoaded\", () => {\n const trigger = document.querySelector(\"#demo-trigger\");\n if (trigger) {\n makeDraggable(trigger as HTMLElement);\n }\n });\n\n return html`\n <div class=\"popover-container\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n .center=${args.center}\n .showArrow=${args.showArrow}\n bind-to=\"#demo-trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et\n dolore magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"demo-trigger\"\n icon=\"plus-filled\"\n ></z-button>\n </div>\n <p class=\"heading-2\">You can move the button to see the positioning adaptation while the popover is open.</p>\n `;\n },\n} satisfies Story;\n\nexport const ContextualMenuLike = {\n args: {\n \"--z-popover-theme--surface\": \"var(--color-surface01)\",\n \"--z-popover-padding\": \"var(--space-unit)\",\n \"position\": PopoverPosition.RIGHT_BOTTOM,\n },\n render: (args, {parameters}) => html`\n <div class=\"popover-container\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n bind-to=\"#trigger\"\n >\n <z-list>\n <z-list-element divider-type=\"element\">Elemento 1</z-list-element>\n <z-list-element divider-type=\"element\">Elemento 2</z-list-element>\n <z-list-element>Elemento 3</z-list-element>\n </z-list>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>\n `,\n} satisfies Story;\n\nexport const Tooltip = {\n args: {\n \"position\": PopoverPosition.RIGHT,\n \"--z-popover-padding\": \"var(--space-unit)\",\n },\n render: (args, {parameters}) =>\n html` <div class=\"popover-container popover-container-tooltip\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n center=\"true\"\n show-arrow=\"true\"\n bind-to=\"#trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore\n magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>`,\n} satisfies Story;\n\nexport const TooltipWithNestedContainer = {\n args: {\n \"position\": PopoverPosition.TOP,\n \"--z-popover-padding\": \"var(--space-unit)\",\n },\n render: (args, {parameters}) =>\n html` <div class=\"popover-container popover-container-tooltip\">\n <div class=\"popover-internal-container\">\n <div class=\"popover-internal-container-2\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n center=\"true\"\n show-arrow=\"true\"\n bind-to=\"#trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et\n dolore magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>\n </div>\n </div>`,\n} satisfies Story;\n"]}
1
+ {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../../src/components/z-popover/index.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAmB,sBAAsB,EAAC,MAAM,6BAA6B,CAAC;AACrF,OAAO,8BAA8B,CAAC;AACtC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,SAAS,CAAC;AACjB,OAAO,qBAAqB,CAAC;AAO7B,MAAM,cAAc,GAAG,CAAC,KAAiB,EAAQ,EAAE;;IACjD,MAAM,OAAO,GAAG,MAAC,KAAK,CAAC,MAAsB,CAAC,OAAO,CAAC,oBAAoB,CAAC,0CAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACxG,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IAED,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,CAAC;QAClB,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,aAAa,GAAG,CAAC,OAAoB,EAAQ,EAAE;IACnD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC;IA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D,MAAM,EAAE,CAAC,IAAI,EAAE,EAAC,UAAU,EAAC,EAAE,EAAE,CAC7B,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;oBAqBY,QAAQ,CAAC;QACf,4BAA4B,EAAE,IAAI,CAAC,4BAA4B,CAAC;QAChE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC;QAC1D,qBAAqB,EAAE,IAAI,CAAC,qBAAqB,CAAC;KACnD,CAAC;wBACU,IAAI,CAAC,QAAQ;;;;;;;;;;;uBAWd,UAAU,CAAC,cAAc;;;;WAIrC;CACM,CAAC","sourcesContent":["import {Meta, StoryObj} from \"@storybook/web-components\";\nimport {html} from \"lit\";\nimport {styleMap} from \"lit/directives/style-map.js\";\nimport {ZPopover} from \".\";\nimport {PopoverPosition} from \"../../beans\";\nimport {CSSVarsArguments, getColorTokenArgConfig} from \"../../utils/storybook-utils\";\nimport \"../list/z-list-element/index\";\nimport \"../list/z-list/index\";\nimport \"../z-button/index\";\nimport \"../z-offcanvas/index\";\nimport \"./index\";\nimport \"./index.stories.css\";\n\ntype ZPopoverStoriesArgs = ZPopover &\n CSSVarsArguments<\n \"--z-popover-theme--surface\" | \"--z-popover-theme--text\" | \"--z-popover-padding\" | \"--z-popover-shadow-filter\"\n >;\n\nconst onTriggerClick = (event: MouseEvent): void => {\n const popover = (event.target as HTMLElement).closest(\".popover-container\")?.querySelector(\"z-popover\");\n if (!popover) {\n return;\n }\n\n if (popover?.open) {\n popover.open = false;\n } else {\n popover.open = true;\n }\n};\n\n/**\n * Simple drag and drop utility.\n * @param element The element to make draggable.\n */\nconst makeDraggable = (element: HTMLElement): void => {\n if (element.draggable) {\n return;\n }\n\n let offsetX = 0;\n let offsetY = 0;\n let dragging = false;\n let clickPosition = {x: 0, y: 0};\n\n element.style.position = \"absolute\";\n element.draggable = true;\n\n element.addEventListener(\"mousedown\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n dragging = true;\n offsetX = element.offsetLeft - event.clientX;\n offsetY = element.offsetTop - event.clientY;\n clickPosition = {x: event.clientX, y: event.clientY};\n });\n\n document.addEventListener(\"mouseup\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n dragging = false;\n\n if (clickPosition.x !== event.clientX || clickPosition.y !== event.clientY) {\n return;\n }\n\n setTimeout(() => {\n onTriggerClick({...event, target: element});\n }, 0);\n });\n\n document.addEventListener(\"mousemove\", (event) => {\n if (dragging) {\n const container = element.parentElement;\n const left = Math.max(Math.min(event.clientX + offsetX, container.clientWidth - element.offsetWidth), 0);\n const top = Math.max(Math.min(event.clientY + offsetY, container.clientHeight - element.offsetHeight), 0);\n element.style.left = `${left}px`;\n element.style.top = `${top}px`;\n }\n });\n};\n\nconst StoryMeta = {\n title: \"ZPopover\",\n component: \"z-popover\",\n argTypes: {\n \"position\": {\n options: [null, ...Object.values(PopoverPosition).filter((value) => value !== PopoverPosition.AUTO)],\n control: {\n type: \"select\",\n labels: {\n null: \"-\",\n },\n },\n },\n \"--z-popover-theme--surface\": getColorTokenArgConfig(),\n \"--z-popover-theme--text\": getColorTokenArgConfig(),\n },\n args: {\n \"position\": null,\n \"--z-popover-theme--surface\": \"var(--color-surface01)\",\n \"--z-popover-theme--text\": \"var(--color-default-text)\",\n \"--z-popover-padding\": \"0\",\n },\n parameters: {\n onTriggerClick,\n docs: {\n story: {\n inline: false,\n iframeHeight: 500,\n },\n },\n },\n} satisfies Meta<ZPopoverStoriesArgs>;\n\nexport default StoryMeta;\n\ntype Story = StoryObj<ZPopoverStoriesArgs>;\n\nexport const Demo = {\n args: {\n \"--z-popover-padding\": \"var(--space-unit)\",\n \"--z-popover-shadow-filter\": \"drop-shadow(0 1px 2px var(--shadow-color-base))\",\n \"center\": false,\n \"showArrow\": false,\n \"closable\": true,\n },\n render: (args) => {\n document.addEventListener(\"DOMContentLoaded\", () => {\n const trigger = document.querySelector(\"#demo-trigger\");\n if (trigger) {\n makeDraggable(trigger as HTMLElement);\n }\n });\n\n return html`\n <div class=\"popover-container\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n .center=${args.center}\n .showArrow=${args.showArrow}\n bind-to=\"#demo-trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et\n dolore magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"demo-trigger\"\n icon=\"plus-filled\"\n ></z-button>\n </div>\n <p class=\"heading-2\">You can move the button to see the positioning adaptation while the popover is open.</p>\n `;\n },\n} satisfies Story;\n\nexport const ContextualMenuLike = {\n args: {\n \"--z-popover-theme--surface\": \"var(--color-surface01)\",\n \"--z-popover-padding\": \"var(--space-unit)\",\n \"position\": PopoverPosition.RIGHT_BOTTOM,\n },\n render: (args, {parameters}) => html`\n <div class=\"popover-container\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n bind-to=\"#trigger\"\n >\n <z-list>\n <z-list-element divider-type=\"element\">Elemento 1</z-list-element>\n <z-list-element divider-type=\"element\">Elemento 2</z-list-element>\n <z-list-element>Elemento 3</z-list-element>\n </z-list>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>\n `,\n} satisfies Story;\n\nexport const Tooltip = {\n args: {\n \"position\": PopoverPosition.RIGHT,\n \"--z-popover-padding\": \"var(--space-unit)\",\n },\n render: (args, {parameters}) =>\n html` <div class=\"popover-container popover-container-tooltip\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n center=\"true\"\n show-arrow=\"true\"\n bind-to=\"#trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore\n magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>`,\n} satisfies Story;\n\nexport const TooltipWithNestedContainer = {\n args: {\n \"position\": PopoverPosition.TOP,\n \"--z-popover-padding\": \"var(--space-unit)\",\n },\n render: (args, {parameters}) =>\n html` <div class=\"popover-container popover-container-tooltip\">\n <div class=\"popover-internal-container\">\n <div class=\"popover-internal-container-2\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n center=\"true\"\n show-arrow=\"true\"\n bind-to=\"#trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et\n dolore magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>\n </div>\n </div>`,\n} satisfies Story;\n\nexport const PopoverInsideTransformedElement = {\n args: {\n \"position\": PopoverPosition.TOP,\n \"--z-popover-padding\": \"var(--space-unit)\",\n },\n render: (args, {parameters}) =>\n html`<div class=\"popover-container\">\n <script>\n document.addEventListener(\"DOMContentLoaded\", () => {\n const offcanvasTrigger = document.querySelector(\"#offcanvas-trigger\");\n if (offcanvasTrigger) {\n offcanvasTrigger.addEventListener(\"click\", () => {\n const offcanvas = document.querySelector(\".popover-container z-offcanvas\");\n if (offcanvas) {\n offcanvas.open = true;\n }\n });\n }\n });\n </script>\n <z-button id=\"offcanvas-trigger\">open offcanvas</z-button>\n <z-offcanvas\n transitiondirection=\"up\"\n show-backdrop\n >\n <div slot=\"canvasContent\">\n <z-popover\n style=${styleMap({\n \"--z-popover-theme--surface\": args[\"--z-popover-theme--surface\"],\n \"--z-popover-theme--text\": args[\"--z-popover-theme--text\"],\n \"--z-popover-padding\": args[\"--z-popover-padding\"],\n })}\n .position=${args.position}\n bind-to=\"#popover-trigger\"\n >\n <div class=\"popover-content\">\n Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et\n dolore magna aliqua.\n </div>\n </z-popover>\n <z-button\n id=\"popover-trigger\"\n icon=\"plus-filled\"\n .onclick=${parameters.onTriggerClick}\n ></z-button>\n </div>\n </z-offcanvas>\n </div>`,\n} satisfies Story;\n"]}