@globalpayments/vega 2.29.0 → 2.31.0

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 (272) hide show
  1. package/dist/cjs/{app-globals-46ab4eb3.js → app-globals-391d9a14.js} +4 -3
  2. package/dist/cjs/{child-nodes-event-prevent-slimmer-0245d631.js → child-nodes-event-prevent-slimmer-bed95a1b.js} +2 -2
  3. package/dist/cjs/{element-appender-slimmer-2b251c0a.js → element-appender-slimmer-415d261a.js} +725 -536
  4. package/dist/cjs/{event-emit-slimmer-d409d0ac.js → event-emit-slimmer-b321e3f5.js} +1 -1
  5. package/dist/cjs/{feature-flag-controller-078da332.js → feature-flag-controller-f0619cc7.js} +5 -0
  6. package/dist/cjs/index-d6bf3435.js +15 -0
  7. package/dist/cjs/index.cjs.js +6 -5
  8. package/dist/cjs/{internal-vega-event-manager-4d9a8e67.js → internal-vega-event-manager-9ffb3ed1.js} +10 -3
  9. package/dist/cjs/loader.cjs.js +7 -6
  10. package/dist/cjs/vega-accordion.cjs.entry.js +3 -3
  11. package/dist/cjs/vega-app-header-button.cjs.entry.js +5 -5
  12. package/dist/cjs/vega-banner.cjs.entry.js +4 -4
  13. package/dist/cjs/vega-breadcrumb.cjs.entry.js +5 -5
  14. package/dist/cjs/vega-button-circle.cjs.entry.js +5 -5
  15. package/dist/cjs/vega-button-group_2.cjs.entry.js +5 -5
  16. package/dist/cjs/vega-button-link.cjs.entry.js +5 -5
  17. package/dist/cjs/vega-button.cjs.entry.js +5 -5
  18. package/dist/cjs/vega-calendar_3.cjs.entry.js +5 -5
  19. package/dist/cjs/vega-carousel.cjs.entry.js +3 -3
  20. package/dist/cjs/vega-checkbox_2.cjs.entry.js +5 -5
  21. package/dist/cjs/vega-chip.cjs.entry.js +5 -5
  22. package/dist/cjs/vega-color-picker.cjs.entry.js +11 -5
  23. package/dist/cjs/vega-combo-box.cjs.entry.js +488 -178
  24. package/dist/cjs/vega-date-picker_2.cjs.entry.js +12 -9
  25. package/dist/cjs/vega-dialog_2.cjs.entry.js +5 -5
  26. package/dist/cjs/vega-dropdown_5.cjs.entry.js +40 -24
  27. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  28. package/dist/cjs/{vega-event-id-e40ac8f0.js → vega-event-id-419d36a8.js} +2 -0
  29. package/dist/cjs/vega-field-label.cjs.entry.js +3 -3
  30. package/dist/cjs/vega-file-uploader.cjs.entry.js +3 -3
  31. package/dist/cjs/vega-flex.cjs.entry.js +1 -1
  32. package/dist/cjs/vega-form.cjs.entry.js +5 -5
  33. package/dist/cjs/vega-image-uploader.cjs.entry.js +5 -5
  34. package/dist/cjs/vega-input-credit-card.cjs.entry.js +5 -5
  35. package/dist/cjs/vega-input-numeric.cjs.entry.js +5 -5
  36. package/dist/cjs/vega-input-phone-number.cjs.entry.js +5 -5
  37. package/dist/cjs/vega-input-range.cjs.entry.js +5 -5
  38. package/dist/cjs/vega-input-select.cjs.entry.js +18 -6
  39. package/dist/cjs/vega-input.cjs.entry.js +3 -3
  40. package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
  41. package/dist/cjs/vega-left-nav_5.cjs.entry.js +4 -4
  42. package/dist/cjs/vega-page-notification_2.cjs.entry.js +1 -1
  43. package/dist/cjs/vega-pagination.cjs.entry.js +7 -7
  44. package/dist/cjs/vega-popover_2.cjs.entry.js +8 -8
  45. package/dist/cjs/vega-progress-tracker.cjs.entry.js +3 -3
  46. package/dist/cjs/vega-radio_2.cjs.entry.js +5 -5
  47. package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
  48. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +5 -5
  49. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +5 -5
  50. package/dist/cjs/vega-sidenav_3.cjs.entry.js +10 -10
  51. package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -3
  52. package/dist/cjs/{vega-skeleton-loader-controller-4bd8cc88.js → vega-skeleton-loader-controller-4a016b04.js} +2 -12
  53. package/dist/cjs/vega-stepper.cjs.entry.js +5 -5
  54. package/dist/cjs/vega-tab-group_2.cjs.entry.js +5 -5
  55. package/dist/cjs/vega-table_8.cjs.entry.js +5 -5
  56. package/dist/cjs/vega-textarea.cjs.entry.js +5 -5
  57. package/dist/cjs/vega-time-picker_2.cjs.entry.js +7 -7
  58. package/dist/cjs/vega-toggle-switch.cjs.entry.js +3 -3
  59. package/dist/cjs/vega-tooltip_2.cjs.entry.js +6 -6
  60. package/dist/cjs/vega.cjs.js +7 -6
  61. package/dist/collection/components/vega-color-picker/vega-color-picker.css +8 -8
  62. package/dist/collection/components/vega-color-picker/vega-color-picker.js +30 -3
  63. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-items-slot-controller.js +57 -0
  64. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-keyboard-controller.js +114 -0
  65. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-source-controller.js +23 -0
  66. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-value-controller.js +23 -0
  67. package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.js +188 -0
  68. package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-renderer.js +50 -0
  69. package/dist/collection/components/vega-combo-box/vega-combo-box.js +40 -177
  70. package/dist/collection/components/vega-date-picker/slimmers/controllers/vega-date-picker-element-appender-controller.js +2 -0
  71. package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-scrollable-controller.js +6 -4
  72. package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-search-renderer.js +19 -5
  73. package/dist/collection/components/vega-dropdown/vega-dropdown.js +55 -9
  74. package/dist/collection/components/vega-input-select/slimmers/controllers/vega-input-select-dropdown-controller.js +7 -1
  75. package/dist/collection/components/vega-input-select/vega-input-select.js +55 -2
  76. package/dist/collection/components/vega-sidenav/vega-sidenav-group/vega-sidenav-group.js +4 -4
  77. package/dist/collection/components/vega-sidenav/vega-sidenav-link/vega-sidenav-link.js +9 -9
  78. package/dist/collection/components/vega-sidenav/vega-sidenav.js +12 -12
  79. package/dist/collection/constants/ui.js +1 -0
  80. package/dist/collection/helpers/event-manager/event-id/component-event-id-map.js +10 -3
  81. package/dist/collection/helpers/event-manager/event-id/vega-event-id.js +1 -0
  82. package/dist/collection/helpers/event-manager/test/vega-event-manager.test.js +2 -1
  83. package/dist/collection/helpers/feature-control/feature-flags-map.js +5 -0
  84. package/dist/collection/helpers/slimmers/element-appender-container/body-positioned-wrapper/body-positioned-wrapper.abstract.js +13 -0
  85. package/dist/collection/helpers/slimmers/element-appender-container/{position-relative-to-wrapper.js → body-positioned-wrapper/position-relative-to-wrapper.js} +23 -21
  86. package/dist/collection/helpers/slimmers/element-appender-container/{vega-modal-wrapper.js → body-positioned-wrapper/vega-modal-wrapper.js} +18 -15
  87. package/dist/collection/helpers/slimmers/element-appender-container/{vega-popover-wrapper.js → body-positioned-wrapper/vega-popover-wrapper.js} +20 -19
  88. package/dist/collection/helpers/slimmers/element-appender-container/default-wrapper.js +19 -19
  89. package/dist/collection/helpers/slimmers/element-appender-container/element-appender-container-controller.js +3 -3
  90. package/dist/collection/helpers/slimmers/element-appender-slimmer.js +10 -0
  91. package/dist/collection/helpers/slimmers/position-calculation/base-position-calculation-strategy.js +345 -0
  92. package/dist/collection/helpers/slimmers/position-calculation/body-position-calculation-strategy.js +66 -0
  93. package/dist/collection/helpers/slimmers/position-calculation/position-calculation-controller.js +121 -0
  94. package/dist/collection/helpers/slimmers/position-calculation/screen-position-calculation-strategy.js +59 -0
  95. package/dist/collection/{utils/test/position.test.js → helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.js} +135 -45
  96. package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +113 -0
  97. package/dist/collection/helpers/ui/element-appender.js +21 -70
  98. package/dist/collection/helpers/ui/test/element-appender.test.js +53 -0
  99. package/dist/collection/utils/pagination.js +2 -2
  100. package/dist/esm/{app-globals-d90e7905.js → app-globals-00a57fbe.js} +3 -2
  101. package/dist/esm/{child-nodes-event-prevent-slimmer-4ecbc8aa.js → child-nodes-event-prevent-slimmer-db288af1.js} +2 -2
  102. package/dist/esm/{element-appender-slimmer-6cf76806.js → element-appender-slimmer-48d826b2.js} +719 -530
  103. package/dist/esm/{event-emit-slimmer-cb9d6f6c.js → event-emit-slimmer-44cb4573.js} +1 -1
  104. package/dist/esm/{feature-flag-controller-10780eeb.js → feature-flag-controller-297c4b9b.js} +5 -0
  105. package/dist/esm/index-fda6b5ee.js +13 -0
  106. package/dist/esm/index.js +5 -4
  107. package/dist/esm/{internal-vega-event-manager-1ebfd1eb.js → internal-vega-event-manager-8154661e.js} +10 -3
  108. package/dist/esm/loader.js +7 -6
  109. package/dist/esm/vega-accordion.entry.js +3 -3
  110. package/dist/esm/vega-app-header-button.entry.js +5 -5
  111. package/dist/esm/vega-banner.entry.js +4 -4
  112. package/dist/esm/vega-breadcrumb.entry.js +5 -5
  113. package/dist/esm/vega-button-circle.entry.js +5 -5
  114. package/dist/esm/vega-button-group_2.entry.js +5 -5
  115. package/dist/esm/vega-button-link.entry.js +5 -5
  116. package/dist/esm/vega-button.entry.js +5 -5
  117. package/dist/esm/vega-calendar_3.entry.js +5 -5
  118. package/dist/esm/vega-carousel.entry.js +3 -3
  119. package/dist/esm/vega-checkbox_2.entry.js +5 -5
  120. package/dist/esm/vega-chip.entry.js +5 -5
  121. package/dist/esm/vega-color-picker.entry.js +12 -6
  122. package/dist/esm/vega-combo-box.entry.js +491 -181
  123. package/dist/esm/vega-date-picker_2.entry.js +12 -9
  124. package/dist/esm/vega-dialog_2.entry.js +5 -5
  125. package/dist/esm/vega-dropdown_5.entry.js +40 -24
  126. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  127. package/dist/esm/{vega-event-id-7465a011.js → vega-event-id-b1655cbc.js} +2 -1
  128. package/dist/esm/vega-field-label.entry.js +3 -3
  129. package/dist/esm/vega-file-uploader.entry.js +3 -3
  130. package/dist/esm/vega-flex.entry.js +1 -1
  131. package/dist/esm/vega-form.entry.js +5 -5
  132. package/dist/esm/vega-image-uploader.entry.js +5 -5
  133. package/dist/esm/vega-input-credit-card.entry.js +5 -5
  134. package/dist/esm/vega-input-numeric.entry.js +5 -5
  135. package/dist/esm/vega-input-phone-number.entry.js +5 -5
  136. package/dist/esm/vega-input-range.entry.js +5 -5
  137. package/dist/esm/vega-input-select.entry.js +18 -6
  138. package/dist/esm/vega-input.entry.js +3 -3
  139. package/dist/esm/vega-item-toggle.entry.js +3 -3
  140. package/dist/esm/vega-left-nav_5.entry.js +4 -4
  141. package/dist/esm/vega-page-notification_2.entry.js +1 -1
  142. package/dist/esm/vega-pagination.entry.js +7 -7
  143. package/dist/esm/vega-popover_2.entry.js +8 -8
  144. package/dist/esm/vega-progress-tracker.entry.js +3 -3
  145. package/dist/esm/vega-radio_2.entry.js +5 -5
  146. package/dist/esm/vega-segment-control.entry.js +3 -3
  147. package/dist/esm/vega-selection-chip_2.entry.js +5 -5
  148. package/dist/esm/vega-selection-tile_2.entry.js +5 -5
  149. package/dist/esm/vega-sidenav_3.entry.js +10 -10
  150. package/dist/esm/vega-signature-capture.entry.js +3 -3
  151. package/dist/esm/{vega-skeleton-loader-controller-def7bf3f.js → vega-skeleton-loader-controller-cec6753f.js} +2 -12
  152. package/dist/esm/vega-stepper.entry.js +5 -5
  153. package/dist/esm/vega-tab-group_2.entry.js +5 -5
  154. package/dist/esm/vega-table_8.entry.js +5 -5
  155. package/dist/esm/vega-textarea.entry.js +5 -5
  156. package/dist/esm/vega-time-picker_2.entry.js +7 -7
  157. package/dist/esm/vega-toggle-switch.entry.js +3 -3
  158. package/dist/esm/vega-tooltip_2.entry.js +6 -6
  159. package/dist/esm/vega.js +7 -6
  160. package/dist/types/components/vega-color-picker/vega-color-picker.d.ts +6 -0
  161. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-items-slot-controller.d.ts +19 -0
  162. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-keyboard-controller.d.ts +29 -0
  163. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-source-controller.d.ts +14 -0
  164. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-value-controller.d.ts +14 -0
  165. package/dist/types/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.d.ts +48 -0
  166. package/dist/types/components/vega-combo-box/slimmers/renderers/vega-combo-box-renderer.d.ts +17 -0
  167. package/dist/types/components/vega-combo-box/vega-combo-box.d.ts +12 -48
  168. package/dist/types/components/vega-dropdown/slimmers/renderers/vega-dropdown-search-renderer.d.ts +1 -0
  169. package/dist/types/components/vega-dropdown/types.d.ts +5 -0
  170. package/dist/types/components/vega-dropdown/vega-dropdown.d.ts +21 -1
  171. package/dist/types/components/vega-input-select/slimmers/controllers/vega-input-select-dropdown-controller.d.ts +1 -0
  172. package/dist/types/components/vega-input-select/vega-input-select.d.ts +20 -0
  173. package/dist/types/components/vega-sidenav/vega-sidenav-group/vega-sidenav-group.d.ts +3 -3
  174. package/dist/types/components/vega-sidenav/vega-sidenav-link/vega-sidenav-link.d.ts +7 -7
  175. package/dist/types/components/vega-sidenav/vega-sidenav.d.ts +8 -8
  176. package/dist/types/components.d.ts +58 -26
  177. package/dist/types/constants/ui.d.ts +1 -1
  178. package/dist/types/helpers/event-manager/event-id/vega-event-id.d.ts +1 -0
  179. package/dist/types/helpers/feature-control/feature-flag.d.ts +2 -1
  180. package/dist/types/helpers/slimmers/element-appender-container/body-positioned-wrapper/body-positioned-wrapper.abstract.d.ts +15 -0
  181. package/dist/types/helpers/slimmers/element-appender-container/{position-relative-to-wrapper.d.ts → body-positioned-wrapper/position-relative-to-wrapper.d.ts} +5 -5
  182. package/dist/types/helpers/slimmers/element-appender-container/{vega-modal-wrapper.d.ts → body-positioned-wrapper/vega-modal-wrapper.d.ts} +5 -5
  183. package/dist/types/helpers/slimmers/element-appender-container/{vega-popover-wrapper.d.ts → body-positioned-wrapper/vega-popover-wrapper.d.ts} +5 -5
  184. package/dist/types/helpers/slimmers/element-appender-container/default-wrapper.d.ts +2 -2
  185. package/dist/types/helpers/slimmers/element-appender-container/element-appender-container-controller.d.ts +3 -3
  186. package/dist/types/helpers/slimmers/element-appender-slimmer.d.ts +1 -0
  187. package/dist/types/helpers/slimmers/position-calculation/base-position-calculation-strategy.d.ts +138 -0
  188. package/dist/types/helpers/slimmers/position-calculation/body-position-calculation-strategy.d.ts +34 -0
  189. package/dist/types/helpers/slimmers/position-calculation/position-calculation-controller.d.ts +54 -0
  190. package/dist/types/helpers/slimmers/position-calculation/screen-position-calculation-strategy.d.ts +34 -0
  191. package/dist/types/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.d.ts +15 -0
  192. package/dist/types/helpers/ui/element-appender.d.ts +9 -24
  193. package/dist/types/types/components.type.d.ts +1 -0
  194. package/dist/vega/index.esm.js +1 -1
  195. package/dist/vega/{p-cf998fc5.entry.js → p-00c5aee5.entry.js} +1 -1
  196. package/dist/vega/{p-f6d4c1ff.entry.js → p-042b4b3f.entry.js} +1 -1
  197. package/dist/vega/{p-817a83c6.entry.js → p-07a8cf89.entry.js} +1 -1
  198. package/dist/vega/p-0abe1ade.entry.js +1 -0
  199. package/dist/vega/{p-74fcdbc6.entry.js → p-0f0e4198.entry.js} +1 -1
  200. package/dist/vega/{p-d7800ca2.entry.js → p-14f5a9ad.entry.js} +1 -1
  201. package/dist/vega/p-15023bad.entry.js +1 -0
  202. package/dist/vega/{p-38f26c82.entry.js → p-1be2fd46.entry.js} +1 -1
  203. package/dist/vega/p-1bfcb6b7.entry.js +1 -0
  204. package/dist/vega/p-1e6c23e0.entry.js +1 -0
  205. package/dist/vega/{p-b0a6421a.entry.js → p-20d9c07c.entry.js} +1 -1
  206. package/dist/vega/p-2306c736.js +1 -0
  207. package/dist/vega/{p-8ef03eed.js → p-302e7589.js} +1 -1
  208. package/dist/vega/p-34710a3c.entry.js +1 -0
  209. package/dist/vega/{p-0bbcc81a.entry.js → p-438caeb3.entry.js} +1 -1
  210. package/dist/vega/{p-319efe6c.js → p-4ffd7493.js} +1 -1
  211. package/dist/vega/{p-ed4a26e7.entry.js → p-57d9bde6.entry.js} +1 -1
  212. package/dist/vega/p-5f377954.js +1 -1
  213. package/dist/vega/{p-ff7bd85f.entry.js → p-623fe226.entry.js} +1 -1
  214. package/dist/vega/{p-1d94428c.entry.js → p-63bee4f1.entry.js} +1 -1
  215. package/dist/vega/{p-6ac3ba21.entry.js → p-64ff6318.entry.js} +1 -1
  216. package/dist/vega/p-6e6ec77d.entry.js +1 -0
  217. package/dist/vega/{p-86eda597.entry.js → p-72ecc510.entry.js} +1 -1
  218. package/dist/vega/p-79019d08.js +1 -0
  219. package/dist/vega/p-7941701a.entry.js +1 -0
  220. package/dist/vega/{p-689ee038.entry.js → p-799cb0a4.entry.js} +1 -1
  221. package/dist/vega/{p-1678b69f.entry.js → p-7a6a0740.entry.js} +1 -1
  222. package/dist/vega/p-80785fcf.entry.js +1 -0
  223. package/dist/vega/{p-0ae9b900.entry.js → p-83ef4c13.entry.js} +1 -1
  224. package/dist/vega/{p-ad31be2c.entry.js → p-87cd0d6a.entry.js} +1 -1
  225. package/dist/vega/{p-b771268b.entry.js → p-8cfe4027.entry.js} +1 -1
  226. package/dist/vega/{p-5dbcab1b.entry.js → p-9281cdb2.entry.js} +1 -1
  227. package/dist/vega/p-95b25b97.entry.js +1 -0
  228. package/dist/vega/p-9b45e5dc.entry.js +1 -0
  229. package/dist/vega/{p-0a91f217.entry.js → p-9b9c0afb.entry.js} +1 -1
  230. package/dist/vega/{p-92aaed64.entry.js → p-9ba68531.entry.js} +2 -2
  231. package/dist/vega/{p-dacf5572.entry.js → p-a66ea015.entry.js} +1 -1
  232. package/dist/vega/{p-d0756d70.entry.js → p-a67748c6.entry.js} +1 -1
  233. package/dist/vega/{p-53bb8cde.entry.js → p-a6e1d9bc.entry.js} +1 -1
  234. package/dist/vega/{p-8b0533c4.entry.js → p-b1a249ef.entry.js} +1 -1
  235. package/dist/vega/{p-cf4fea44.entry.js → p-b6e49ee9.entry.js} +1 -1
  236. package/dist/vega/{p-d045099d.entry.js → p-be6041fc.entry.js} +1 -1
  237. package/dist/vega/{p-2ae04da9.entry.js → p-bf38199b.entry.js} +1 -1
  238. package/dist/vega/p-bf3fbb9b.js +1 -0
  239. package/dist/vega/p-c06e7880.js +1 -0
  240. package/dist/vega/{p-e42a2a12.entry.js → p-c3c2890e.entry.js} +1 -1
  241. package/dist/vega/{p-b3417358.entry.js → p-c6ed1982.entry.js} +1 -1
  242. package/dist/vega/p-cdebfee7.entry.js +1 -0
  243. package/dist/vega/{p-e4d6e2c8.entry.js → p-d3c07efa.entry.js} +1 -1
  244. package/dist/vega/p-d71f968e.entry.js +1 -0
  245. package/dist/vega/{p-30693931.entry.js → p-e165c9f1.entry.js} +1 -1
  246. package/dist/vega/{p-19769aba.js → p-e5d7b4b8.js} +1 -1
  247. package/dist/vega/{p-ebb93b96.entry.js → p-e6f91767.entry.js} +1 -1
  248. package/dist/vega/p-ed237efc.js +1 -0
  249. package/dist/vega/{p-a105e4de.js → p-f2851f16.js} +1 -1
  250. package/dist/vega/{p-975c5a3a.entry.js → p-fb3233db.entry.js} +1 -1
  251. package/dist/vega/{p-a0f5d2cc.entry.js → p-ff22a95f.entry.js} +1 -1
  252. package/dist/vega/vega.esm.js +1 -1
  253. package/package.json +4 -2
  254. package/dist/collection/utils/position.js +0 -373
  255. package/dist/types/utils/position.d.ts +0 -17
  256. package/dist/vega/p-001c0b51.entry.js +0 -1
  257. package/dist/vega/p-0064f5b1.entry.js +0 -1
  258. package/dist/vega/p-19ef612a.js +0 -1
  259. package/dist/vega/p-1f03b576.entry.js +0 -1
  260. package/dist/vega/p-270b0d1a.entry.js +0 -1
  261. package/dist/vega/p-28c78b79.entry.js +0 -1
  262. package/dist/vega/p-31d530d2.entry.js +0 -1
  263. package/dist/vega/p-3f5e44c1.js +0 -1
  264. package/dist/vega/p-651e5c7d.entry.js +0 -1
  265. package/dist/vega/p-68823025.js +0 -1
  266. package/dist/vega/p-6b8277eb.js +0 -1
  267. package/dist/vega/p-7d02f723.entry.js +0 -1
  268. package/dist/vega/p-8bd09712.entry.js +0 -1
  269. package/dist/vega/p-a14be625.entry.js +0 -1
  270. package/dist/vega/p-cc272fbc.entry.js +0 -1
  271. package/dist/vega/p-e2c25432.entry.js +0 -1
  272. /package/dist/types/{utils/test/position.test.d.ts → helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.d.ts} +0 -0
@@ -1,384 +1,13 @@
1
- import { L as LogUtility, c as MapToComponentField, I as InjectVegaSlimmer, V as VegaSlimmer, M as MapToComponentMethod } from './global-slimmer-registry-17c4efd4.js';
2
- import { P as Placements, A as Alignments } from './ui-8424715a.js';
3
- import { z as isTranslocationType } from './type-guard-63caf78b.js';
4
- import { R as ResponsiveFormatFacade } from './responsive-format-facade-3dc84e41.js';
1
+ import { c as MapToComponentField, I as InjectVegaSlimmer, V as VegaSlimmer, L as LogUtility, M as MapToComponentMethod } from './global-slimmer-registry-17c4efd4.js';
5
2
  import { f as findParent, c as isElementVisible, i as isParent } from './ui-0132dbb5.js';
6
3
  import { I as InternalVegaZIndexManager } from './internal-vega-z-index-manager-7d2b54c3.js';
7
4
  import { c as createDynamicSlimmer } from './dynamic-slimmer-90b8af32.js';
8
5
  import { P as PageResizeObserverSlimmer } from './page-resize-observer-slimmer-994c1e1b.js';
6
+ import { P as Placements, A as Alignments } from './ui-8424715a.js';
7
+ import { z as isTranslocationType } from './type-guard-63caf78b.js';
8
+ import { R as ResponsiveFormatFacade } from './responsive-format-facade-3dc84e41.js';
9
9
 
10
- /**
11
- * Get the position of the element in the container according to the target element and the placement
12
- * If give a translocation, it will apply the translocation to the result.
13
- * Note: If you use this method to calculate the position, you should make container as relative position at first.
14
- *
15
- * @param {HTMLElement} container - The container element of the element to be positioned.
16
- * @param {HTMLElement} element - The element to be positioned.
17
- * @param {HTMLElement} target - The element to be positioned.
18
- * @param {PlacementType | PlacementType[]} [placement] - The placement of the element, which can be a
19
- * single placement or an array of placements.
20
- * @param {PositionAlignmentType | PositionAlignmentType[]} alignment - The alignment of the element
21
- * @param {TranslocationType} [translocation] - The offset of the element relative to the target.
22
- * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
23
- * returns an ElementPositionBox.
24
- */
25
- const getPositionBox = (container, element, target, placement, alignment, translocation = { X: 0, Y: 0 }) => {
26
- const containerStyle = window.getComputedStyle(container);
27
- if (containerStyle.position !== 'relative') {
28
- LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
29
- }
30
- const placements = getPlacements(placement);
31
- const alignments = getAlignments(alignment);
32
- const targetBox = getTargetBoundBox(target, container);
33
- const elementBox = getElementBoundBox(element);
34
- const containerBox = getElementScrollDimension(container);
35
- const suitablePlacement = getSuitablePlacement(containerBox, elementBox, targetBox, placements);
36
- const suitableAlignment = getSuitableAlignment(containerBox, elementBox, targetBox, suitablePlacement, alignments);
37
- const positionBox = calculatePosition(elementBox, targetBox, suitablePlacement, suitableAlignment);
38
- const translocationBox = getTranslocationBox(Array.isArray(placement) ? placement[0] : placement, suitablePlacement, translocation);
39
- positionBox.placement = suitablePlacement;
40
- positionBox.alignment = suitableAlignment;
41
- positionBox.left += translocationBox.X;
42
- positionBox.top += translocationBox.Y;
43
- return positionBox;
44
- };
45
- /**
46
- * It returns the translocation of the element relative to the target element
47
- *
48
- * @param {Nullable<PlacementType>} originPlacement - The origin placement of the element.
49
- * @param {PlacementType} placement - The suitable placement of the element.
50
- * @param {TranslocationType} translocation - TranslocationType
51
- * @returns {TranslocationType} A translocation object with X and Y properties.
52
- */
53
- function getTranslocationBox(originPlacement, placement, translocation) {
54
- const result = { X: 0, Y: 0 };
55
- if (isTranslocationType(translocation)) {
56
- let xValue = translocation.X;
57
- let yValue = translocation.Y;
58
- // If originPlacement and placement is not in same axis, it should reverse axis.
59
- if ((originPlacement &&
60
- ['left', 'right'].includes(originPlacement) &&
61
- ['top', 'bottom'].includes(placement)) ||
62
- (originPlacement &&
63
- ['top', 'bottom'].includes(originPlacement) &&
64
- ['left', 'right'].includes(placement))) {
65
- xValue = translocation.Y;
66
- yValue = translocation.X;
67
- }
68
- if (['bottom', 'top'].includes(placement)) {
69
- result.Y = placement === 'top' ? -yValue : yValue;
70
- result.X = xValue;
71
- }
72
- if (['left', 'right'].includes(placement)) {
73
- result.X = placement === 'left' ? -xValue : xValue;
74
- result.Y = yValue;
75
- }
76
- }
77
- return result;
78
- }
79
- /**
80
- * It takes a placement string or array of placements and returns an array of placements
81
- * if given placement is single, we should completion the placements with the default {@link Placements}
82
- * and make given placement as default.
83
- * if given placement is array, we should use it directly, even it partial of {@link Placements}.
84
- * if not placement give. we should use {@link Placements}.
85
- *
86
- * @param {PlacementType | PlacementType[]} [placement] - The placement of the tooltip.
87
- * @returns {PlacementType[]} ordered placements.
88
- */
89
- function getPlacements(placement) {
90
- if (typeof placement === 'string') {
91
- const partial = Placements.filter((direction) => direction !== placement);
92
- return [placement, ...partial];
93
- }
94
- else if (Array.isArray(placement)) {
95
- return placement;
96
- }
97
- else {
98
- return [...Placements];
99
- }
100
- }
101
- /**
102
- * It returns acceptable alignments.
103
- *
104
- * @param {PositionAlignmentType | PositionAlignmentType[]} [alignment] - The alignment of the popup.
105
- * @returns {PositionAlignmentType[]} acceptable alignments
106
- */
107
- function getAlignments(alignment) {
108
- if (typeof alignment === 'string') {
109
- const partial = Alignments.filter((item) => item !== alignment);
110
- return [alignment, ...partial];
111
- }
112
- else if (Array.isArray(alignment)) {
113
- return alignment;
114
- }
115
- else {
116
- return [...Alignments];
117
- }
118
- }
119
- /**
120
- * It takes a placement, a target box, and a element box, and returns an element box
121
- *
122
- * @param {ElementBoundBox} elementBox - The position of the element element.
123
- * @param {ElementBoundBox} targetBox - The position of the target element.
124
- * @param {PlacementType} placement - The placement of the element.
125
- * @param {PositionAlignmentType} alignment - The alignment of the element
126
- * @returns {ElementPositionBox} An object with top and left properties.
127
- */
128
- function calculatePosition(elementBox, targetBox, placement, alignment) {
129
- return {
130
- top: calculateTop(elementBox, targetBox, placement, alignment),
131
- left: calculateLeft(elementBox, targetBox, placement, alignment),
132
- };
133
- }
134
- /**
135
- * Calculate the left position of the element
136
- *
137
- * @param {ElementBoundBox} elementBox - The position box of the element.
138
- * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
139
- * @param {PlacementType} placement - The placement of the element.
140
- * @param {PositionAlignmentType} alignment - The alignment of the element
141
- * @returns {number} The left position of the element.
142
- */
143
- function calculateLeft(elementBox, targetBox, placement, alignment) {
144
- switch (placement) {
145
- case 'top':
146
- case 'bottom': {
147
- if (alignment === 'end') {
148
- return targetBox.left + targetBox.width - elementBox.width;
149
- }
150
- else if (alignment === 'center') {
151
- return targetBox.left - (elementBox.width - targetBox.width) / 2;
152
- }
153
- else {
154
- return targetBox.left;
155
- }
156
- }
157
- case 'left': {
158
- return targetBox.left - elementBox.width;
159
- }
160
- case 'right': {
161
- return targetBox.left + targetBox.width;
162
- }
163
- /* istanbul ignore next */
164
- default:
165
- throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
166
- }
167
- }
168
- /**
169
- * Calculate the top position of the element
170
- *
171
- * @param {ElementBoundBox} elementBox - The position box of the element.
172
- * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
173
- * @param {PlacementType} placement - The placement of the element.
174
- * @param {PositionAlignmentType} alignment - The alignment of the element
175
- * @returns {number} the top position of the element.
176
- */
177
- function calculateTop(elementBox, targetBox, placement, alignment) {
178
- switch (placement) {
179
- case 'left':
180
- case 'right': {
181
- if (alignment === 'end') {
182
- return targetBox.top + targetBox.height - elementBox.height;
183
- }
184
- else if (alignment === 'center') {
185
- return targetBox.top - (elementBox.height - targetBox.height) / 2;
186
- }
187
- else {
188
- return targetBox.top;
189
- }
190
- }
191
- case 'top': {
192
- return targetBox.top - elementBox.height;
193
- }
194
- case 'bottom': {
195
- return targetBox.top + targetBox.height;
196
- }
197
- /* istanbul ignore next */
198
- default:
199
- throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
200
- }
201
- }
202
- /**
203
- * It takes a list of placements and returns the first placement that has enough space to place the
204
- * element
205
- *
206
- * @param {ElementScrollDimension} containerBox - The box of the container element.
207
- * @param {ElementBoundBox} elementBox - The box of the element to be placed.
208
- * @param {ElementBoundBox} targetBox - The box of the target element.
209
- * @param {PlacementType[]} placements - The placements that we want to try.
210
- * @returns {PlacementType} A function that takes in a containerBox, elementBox, targetBox, placements, and element.
211
- */
212
- function getSuitablePlacement(containerBox, elementBox, targetBox, placements) {
213
- const defaultPlacement = placements[0];
214
- const suitablePlacement = placements.find((placement) => hasEnoughSpace(containerBox, placement, targetBox, elementBox));
215
- if (suitablePlacement) {
216
- return suitablePlacement;
217
- }
218
- else {
219
- LogUtility.warn(`
220
- No enough space found for placing element and we will keep using the defined placement:
221
- ${defaultPlacement}
222
- `);
223
- return defaultPlacement;
224
- }
225
- }
226
- /**
227
- * It takes a list of alignments and returns the suitable one that has enough space to fit the element
228
- *
229
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
230
- * @param {ElementBoundBox} elementBox - The box of the element that we want to position.
231
- * @param {ElementBoundBox} targetBox - The box of the element that the element to be positioned is aligned to.
232
- * @param {PlacementType} placement - The placement of the element relative to the target.
233
- * @param {PositionAlignmentType[]} alignments - An array of alignments to try.
234
- * @returns {PositionAlignmentType} the alignment that is suitable for the element.
235
- */
236
- const getSuitableAlignment = (containerBox, elementBox, targetBox, placement, alignments) => {
237
- const defaultAlignment = alignments[0];
238
- const suitableAlignment = alignments.find((alignment) => hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment));
239
- if (suitableAlignment) {
240
- return suitableAlignment;
241
- }
242
- else {
243
- LogUtility.warn(`
244
- No enough space found for placing element and we will keep using the defined alignment:
245
- ${defaultAlignment}
246
- `);
247
- return defaultAlignment;
248
- }
249
- };
250
- /**
251
- * Whether the alignment space is enough
252
- *
253
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
254
- * @param {ElementBoundBox} targetBox - The position of the target element.
255
- * @param {ElementBoundBox} elementBox - The box of the element that we're trying to position.
256
- * @param {PlacementType} placement - The placement of the element relative to the target.
257
- * @param {PlacementType} alignment - The alignment of the element relative to the target.
258
- * @returns {boolean} return true if it has enough space, otherwise false
259
- */
260
- function hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment) {
261
- if (['top', 'bottom'].includes(placement)) {
262
- switch (alignment) {
263
- case 'start': {
264
- return targetBox.left + elementBox.width <= containerBox.width;
265
- }
266
- case 'center': {
267
- return (targetBox.left >= elementBox.width - targetBox.width &&
268
- targetBox.left + targetBox.width / 2 + elementBox.width / 2 <= containerBox.width);
269
- }
270
- case 'end': {
271
- return targetBox.left + targetBox.width >= elementBox.width;
272
- }
273
- }
274
- }
275
- if (['right', 'left'].includes(placement)) {
276
- switch (alignment) {
277
- case 'start': {
278
- return targetBox.top + elementBox.height <= containerBox.height;
279
- }
280
- case 'center': {
281
- return (targetBox.top >= elementBox.height - targetBox.height &&
282
- targetBox.top + targetBox.height / 2 + elementBox.height / 2 <= containerBox.height);
283
- }
284
- case 'end': {
285
- return targetBox.top + targetBox.height >= elementBox.height;
286
- }
287
- }
288
- }
289
- /* istanbul ignore next */
290
- return false;
291
- }
292
- /**
293
- * If the placement is top or left, then the target's top or left position must be greater than or
294
- * equal to the element's height or width. If the placement is bottom or right, then the container's
295
- * height or width minus the target's top or left position minus the target's height or width must be
296
- * greater than or equal to the element's height or width.
297
- *
298
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
299
- * @param {PlacementType} placement - The placement of the element.
300
- * @param {ElementBoundBox} targetBox - The position of the target element.
301
- * @param {ElementBoundBox} elementBox - The dimensions of the element to be positioned.
302
- * @returns {boolean} A boolean value.
303
- */
304
- function hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
305
- switch (placement) {
306
- case 'top':
307
- return targetBox.top >= elementBox.height;
308
- case 'bottom':
309
- return containerBox.height - targetBox.top - targetBox.height >= elementBox.height;
310
- case 'left':
311
- return targetBox.left >= elementBox.width;
312
- case 'right':
313
- return containerBox.width - targetBox.left - targetBox.width >= elementBox.width;
314
- /* istanbul ignore next */
315
- default:
316
- return false;
317
- }
318
- }
319
- /**
320
- * It returns the position of an element relative to its container and also includes the scroll height of container.
321
- *
322
- * @param {HTMLElement} target - The element that you want to position.
323
- * @param {HTMLElement} container - The container element that the target element is inside of.
324
- * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
325
- */
326
- function getTargetBoundBox(target, container) {
327
- const containerRect = container.getBoundingClientRect();
328
- const targetRect = target.getBoundingClientRect();
329
- const targetTop = targetRect.top - containerRect.top + container.scrollTop;
330
- const targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
331
- return {
332
- width: targetRect.width,
333
- height: targetRect.height,
334
- top: targetTop,
335
- left: targetLeft,
336
- };
337
- }
338
- /**
339
- * "Get the width, height, and top position of an element."
340
- *
341
- * The function takes an element as an argument and returns an object with three properties: width,
342
- * height, and top.
343
- *
344
- * Note: If element is hide, we should temporary change it to `block` to get the bounding client rect of element,
345
- * After do that, this element will change to origin `hide`, if not, it will be contained in the calculate of `document.documentElement.scrollHeight`
346
- *
347
- * @param {HTMLElement} element - HTMLElement - The element to get the position box for.
348
- * @returns {ElementBoundBox} An object with the width, height, and top properties of the element.
349
- */
350
- function getElementBoundBox(element) {
351
- const isElementHide = element.classList.contains('vega-force-hidden');
352
- if (isElementHide)
353
- element.classList.remove('vega-force-hidden');
354
- const elementRect = element.getBoundingClientRect();
355
- if (isElementHide)
356
- element.classList.add('vega-force-hidden');
357
- return {
358
- width: elementRect.width,
359
- height: elementRect.height,
360
- left: elementRect.left,
361
- top: elementRect.top,
362
- };
363
- }
364
- /**
365
- * "Get the width and height of an element."
366
- *
367
- * The function takes a single parameter, a container element, and returns an object with two
368
- * properties: width and height
369
- *
370
- * @param {HTMLElement} container - The container element that the tooltip will be positioned relative
371
- * to.
372
- * @returns {ElementScrollDimension} An object with two properties: width and height.
373
- */
374
- function getElementScrollDimension(container) {
375
- return {
376
- width: container.scrollWidth,
377
- height: container.scrollHeight,
378
- };
379
- }
380
-
381
- var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
10
+ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
382
11
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
383
12
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
384
13
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -388,32 +17,46 @@ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators,
388
17
  * This class is is used to retrieve the body element of document.
389
18
  */
390
19
  class DefaultWrapper {
391
- constructor() {
392
- /**
393
- * The canRetrieve function return is always true.
394
- *
395
- * @returns {boolean} the boolean type.
396
- */
397
- this.canRetrieve = () => true;
398
- /**
399
- * The retrieve function get the body element of document.
400
- *
401
- * @returns {HTMLElement} the element.
402
- */
403
- this.retrieve = () => {
404
- const container = document.body;
405
- if (this.showConfig.appendableElement.parentElement !== container) {
406
- container.append(this.showConfig.appendableElement);
407
- }
408
- return container;
409
- };
20
+ /**
21
+ * The canRetrieve function return is always true.
22
+ *
23
+ * @returns {boolean} the boolean type.
24
+ */
25
+ canRetrieve() {
26
+ return true;
27
+ }
28
+ /**
29
+ * The retrieve function get the body element of document.
30
+ *
31
+ * @returns {HTMLElement} the element.
32
+ */
33
+ retrieve() {
34
+ const container = document.body;
35
+ if (this.showConfig.appendableElement.parentElement !== container) {
36
+ container.append(this.showConfig.appendableElement);
37
+ }
38
+ return container;
410
39
  }
411
40
  }
412
- __decorate$6([
41
+ __decorate$9([
413
42
  MapToComponentField()
414
43
  ], DefaultWrapper.prototype, "showConfig", void 0);
415
44
 
416
- var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
45
+ /**
46
+ * Body positioned wrapper.
47
+ */
48
+ class BodyPositionedWrapper {
49
+ /**
50
+ * Valid is a body position used wrapper.
51
+ *
52
+ * @returns {boolean} can retrieve or not.
53
+ */
54
+ canRetrieve() {
55
+ return !this.showConfig.isScreenPosition;
56
+ }
57
+ }
58
+
59
+ var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
417
60
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
418
61
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
419
62
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -424,34 +67,35 @@ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators,
424
67
  *
425
68
  * @property {HTMLElement} showConfig the show config
426
69
  */
427
- class PositionRelativeToWrapper {
428
- constructor() {
429
- /**
430
- * The canRetrieve function just determines whether the showConfig contains the positionRelativeTo object.
431
- *
432
- * @returns {boolean} the boolean type.
433
- */
434
- this.canRetrieve = () => !!this.showConfig.positionRelativeTo &&
435
- !!document.querySelector(this.showConfig.positionRelativeTo);
436
- /**
437
- * The retrieve function query the element of positionRelativeTo in showConfig.
438
- *
439
- * @returns {HTMLElement} the element.
440
- */
441
- this.retrieve = () => {
442
- const container = document.querySelector(this.showConfig.positionRelativeTo);
443
- if (this.showConfig.appendableElement.parentElement !== container) {
444
- container.append(this.showConfig.appendableElement);
445
- }
446
- return container;
447
- };
70
+ class PositionRelativeToWrapper extends BodyPositionedWrapper {
71
+ /**
72
+ * The canRetrieve function just determines whether the showConfig contains the positionRelativeTo object.
73
+ *
74
+ * @returns {boolean} the boolean type.
75
+ */
76
+ canRetrieve() {
77
+ return (super.canRetrieve() &&
78
+ !!this.showConfig.positionRelativeTo &&
79
+ !!document.querySelector(this.showConfig.positionRelativeTo));
80
+ }
81
+ /**
82
+ * The retrieve function query the element of positionRelativeTo in showConfig.
83
+ *
84
+ * @returns {HTMLElement} the element.
85
+ */
86
+ retrieve() {
87
+ const container = document.querySelector(this.showConfig.positionRelativeTo);
88
+ if (this.showConfig.appendableElement.parentElement !== container) {
89
+ container.append(this.showConfig.appendableElement);
90
+ }
91
+ return container;
448
92
  }
449
93
  }
450
- __decorate$5([
94
+ __decorate$8([
451
95
  MapToComponentField()
452
96
  ], PositionRelativeToWrapper.prototype, "showConfig", void 0);
453
97
 
454
- var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
98
+ var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
455
99
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
456
100
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
457
101
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -462,20 +106,22 @@ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators,
462
106
  *
463
107
  * @property {HTMLElement} showConfig the show config
464
108
  */
465
- class VegaModalWrapper {
466
- constructor() {
467
- /**
468
- * The canRetrieve function just determines whether the target of showConfig has the `vega-modal` element. If not, search upwards layer by layer.
469
- *
470
- * @returns {boolean} the boolean type.
471
- */
472
- this.canRetrieve = () => !!findParent(this.showConfig.target, 'vega-modal');
473
- /**
474
- * The retrieve function get the slot position of vega-modal element.
475
- *
476
- * @returns {HTMLElement} the element.
477
- */
478
- this.retrieve = () => this.getVegaModalShowConfigContainer();
109
+ class VegaModalWrapper extends BodyPositionedWrapper {
110
+ /**
111
+ * The canRetrieve function just determines whether the target of showConfig has the `vega-modal` element. If not, search upwards layer by layer.
112
+ *
113
+ * @returns {boolean} the boolean type.
114
+ */
115
+ canRetrieve() {
116
+ return super.canRetrieve() && !!findParent(this.showConfig.target, 'vega-modal');
117
+ }
118
+ /**
119
+ * The retrieve function get the slot position of vega-modal element.
120
+ *
121
+ * @returns {HTMLElement} the element.
122
+ */
123
+ retrieve() {
124
+ return this.getVegaModalShowConfigContainer();
479
125
  }
480
126
  /**
481
127
  * This function `getVegaModalContentWithoutScroll` determines whether vega-modal has a slot whose name is `content` or `modal-content`. If there is a component rendered in the modal, the elementAppender added to the corresponding slot attribute is added. If not, the elementAppender is not directly appended to the root directory of vega-modal.
@@ -508,11 +154,11 @@ class VegaModalWrapper {
508
154
  return modalContentScrollable ? modalContentScrollable : modalDialog;
509
155
  }
510
156
  }
511
- __decorate$4([
157
+ __decorate$7([
512
158
  MapToComponentField({ writable: true })
513
159
  ], VegaModalWrapper.prototype, "showConfig", void 0);
514
160
 
515
- var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
161
+ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
516
162
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
517
163
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
518
164
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -523,31 +169,31 @@ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators,
523
169
  *
524
170
  * @property {HTMLElement} showConfig the show config
525
171
  */
526
- class VegaPopoverWrapper {
527
- constructor() {
528
- /**
529
- * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
530
- *
531
- * @returns {boolean} the boolean type.
532
- */
533
- this.canRetrieve = () => !!findParent(this.showConfig.target, '.vega-popover');
534
- /**
535
- * The retrieve function get the element that if the target of showConfig does not have the class vega-popover, search upwards layer by layer until this element is found.
536
- *
537
- * @returns {HTMLElement} the element.
538
- */
539
- this.retrieve = () => {
540
- const container = findParent(this.showConfig.target, '.vega-popover');
541
- container.append(this.showConfig.appendableElement);
542
- return container;
543
- };
172
+ class VegaPopoverWrapper extends BodyPositionedWrapper {
173
+ /**
174
+ * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
175
+ *
176
+ * @returns {boolean} the boolean type.
177
+ */
178
+ canRetrieve() {
179
+ return super.canRetrieve() && !!findParent(this.showConfig.target, '.vega-popover');
180
+ }
181
+ /**
182
+ * The retrieve function get the element that if the target of showConfig does not have the class vega-popover, search upwards layer by layer until this element is found.
183
+ *
184
+ * @returns {HTMLElement} the element.
185
+ */
186
+ retrieve() {
187
+ const container = findParent(this.showConfig.target, '.vega-popover');
188
+ container.append(this.showConfig.appendableElement);
189
+ return container;
544
190
  }
545
191
  }
546
- __decorate$3([
192
+ __decorate$6([
547
193
  MapToComponentField()
548
194
  ], VegaPopoverWrapper.prototype, "showConfig", void 0);
549
195
 
550
- var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
196
+ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
551
197
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
552
198
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
553
199
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -591,25 +237,606 @@ class ElementAppenderContainerController extends VegaSlimmer {
591
237
  ];
592
238
  }
593
239
  }
594
- __decorate$2([
240
+ __decorate$5([
595
241
  MapToComponentField({ writable: true })
596
242
  ], ElementAppenderContainerController.prototype, "container", void 0);
597
- __decorate$2([
243
+ __decorate$5([
598
244
  MapToComponentField({ writable: true })
599
245
  ], ElementAppenderContainerController.prototype, "showConfig", void 0);
600
- __decorate$2([
246
+ __decorate$5([
601
247
  InjectVegaSlimmer()
602
248
  ], ElementAppenderContainerController.prototype, "positionRelativeToWrapper", void 0);
603
- __decorate$2([
249
+ __decorate$5([
604
250
  InjectVegaSlimmer()
605
251
  ], ElementAppenderContainerController.prototype, "vegaPopoverWrapper", void 0);
606
- __decorate$2([
252
+ __decorate$5([
607
253
  InjectVegaSlimmer()
608
254
  ], ElementAppenderContainerController.prototype, "vegaModalWrapper", void 0);
609
- __decorate$2([
255
+ __decorate$5([
610
256
  InjectVegaSlimmer()
611
257
  ], ElementAppenderContainerController.prototype, "defaultWrapper", void 0);
612
258
 
259
+ /**
260
+ * calculate position
261
+ */
262
+ class BasePositionCalculationStrategy extends VegaSlimmer {
263
+ /**
264
+ * Get the position box.
265
+ *
266
+ * @param {PlacementType[]} placement - previous placement.
267
+ * @param {PositionAlignmentType[]} alignment - previous placement.
268
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
269
+ * returns an ElementPositionBox.
270
+ */
271
+ getPositionBox(placement, alignment) {
272
+ const placements = placement || this.getPlacements();
273
+ const alignments = alignment || this.getAlignments();
274
+ const targetBox = this.getTargetBoundBox();
275
+ const elementBox = this.getElementBoundBox();
276
+ const containerBox = this.getElementScrollDimension();
277
+ const suitablePlacement = this.getSuitablePlacement(containerBox, elementBox, targetBox, placements);
278
+ const suitableAlignment = this.getSuitableAlignment(containerBox, elementBox, targetBox, suitablePlacement, alignments);
279
+ const positionBox = this.calculatePosition(elementBox, targetBox, suitablePlacement, suitableAlignment);
280
+ const translocationBox = this.getTranslocationBox(suitablePlacement);
281
+ positionBox.placement = suitablePlacement;
282
+ positionBox.alignment = suitableAlignment;
283
+ positionBox.left += translocationBox.X;
284
+ positionBox.top += translocationBox.Y;
285
+ return positionBox;
286
+ }
287
+ /**
288
+ * "Get the width, height, and top position of an element."
289
+ *
290
+ * The function takes an element as an argument and returns an object with three properties: width,
291
+ * height, and top.
292
+ *
293
+ * Note: If element is hide, we should temporary change it to `block` to get the bounding client rect of element,
294
+ * After do that, this element will change to origin `hide`, if not, it will be contained in the calculate of `document.documentElement.scrollHeight`
295
+ *
296
+ * @returns {ElementBoundBox} An object with the width, height, and top properties of the element.
297
+ */
298
+ getElementBoundBox() {
299
+ const element = this.showConfig.appendableElement;
300
+ const isElementHide = element.classList.contains('vega-force-hidden');
301
+ if (isElementHide)
302
+ element.classList.remove('vega-force-hidden');
303
+ const elementRect = element.getBoundingClientRect();
304
+ if (isElementHide)
305
+ element.classList.add('vega-force-hidden');
306
+ return {
307
+ width: elementRect.width,
308
+ height: elementRect.height,
309
+ left: elementRect.left,
310
+ top: elementRect.top,
311
+ };
312
+ }
313
+ /**
314
+ * It takes a placement string or array of placements and returns an array of placements
315
+ * if given placement is single, we should completion the placements with the default {@link Placements}
316
+ * and make given placement as default.
317
+ * if given placement is array, we should use it directly, even it partial of {@link Placements}.
318
+ * if not placement give. we should use {@link Placements}.
319
+ *
320
+ * @returns {PlacementType[]} ordered placements.
321
+ */
322
+ getPlacements() {
323
+ const placement = this.showConfig.placement;
324
+ if (typeof placement === 'string') {
325
+ const partial = Placements.filter((direction) => direction !== placement);
326
+ return [placement, ...partial];
327
+ }
328
+ else if (Array.isArray(placement)) {
329
+ return placement;
330
+ }
331
+ else {
332
+ return [...Placements];
333
+ }
334
+ }
335
+ /**
336
+ * It returns acceptable alignments.
337
+ *
338
+ * @returns {PositionAlignmentType[]} acceptable alignments
339
+ */
340
+ getAlignments() {
341
+ const alignment = this.showConfig.alignment;
342
+ if (typeof alignment === 'string') {
343
+ const partial = Alignments.filter((item) => item !== alignment);
344
+ return [alignment, ...partial];
345
+ }
346
+ else if (Array.isArray(alignment)) {
347
+ return alignment;
348
+ }
349
+ else {
350
+ return [...Alignments];
351
+ }
352
+ }
353
+ /**
354
+ * It takes a placement, a target box, and a element box, and returns an element box
355
+ *
356
+ * @param {ElementBoundBox} elementBox - The position of the element element.
357
+ * @param {ElementBoundBox} targetBox - The position of the target element.
358
+ * @param {PlacementType} placement - The placement of the element.
359
+ * @param {PositionAlignmentType} alignment - The alignment of the element
360
+ * @returns {ElementPositionBox} An object with top and left properties.
361
+ */
362
+ calculatePosition(elementBox, targetBox, placement, alignment) {
363
+ return {
364
+ top: this.calculateTop(elementBox, targetBox, placement, alignment),
365
+ left: this.calculateLeft(elementBox, targetBox, placement, alignment),
366
+ };
367
+ }
368
+ /**
369
+ * It returns the translocation of the element relative to the target element
370
+ *
371
+ * @param {PlacementType} placement - The suitable placement of the element.
372
+ * @returns {TranslocationType} A translocation object with X and Y properties.
373
+ */
374
+ getTranslocationBox(placement) {
375
+ const originPlacement = Array.isArray(this.showConfig.placement)
376
+ ? this.showConfig.placement[0]
377
+ : this.showConfig.placement;
378
+ const translocation = this.getTranslocation();
379
+ const result = { X: 0, Y: 0 };
380
+ if (isTranslocationType(translocation)) {
381
+ let xValue = translocation.X;
382
+ let yValue = translocation.Y;
383
+ // If originPlacement and placement is not in same axis, it should reverse axis.
384
+ if ((originPlacement &&
385
+ ['left', 'right'].includes(originPlacement) &&
386
+ ['top', 'bottom'].includes(placement)) ||
387
+ (originPlacement &&
388
+ ['top', 'bottom'].includes(originPlacement) &&
389
+ ['left', 'right'].includes(placement))) {
390
+ xValue = translocation.Y;
391
+ yValue = translocation.X;
392
+ }
393
+ if (['bottom', 'top'].includes(placement)) {
394
+ result.Y = placement === 'top' ? -yValue : yValue;
395
+ result.X = xValue;
396
+ }
397
+ if (['left', 'right'].includes(placement)) {
398
+ result.X = placement === 'left' ? -xValue : xValue;
399
+ result.Y = yValue;
400
+ }
401
+ }
402
+ return result;
403
+ }
404
+ /**
405
+ * Calculate the left position of the element
406
+ *
407
+ * @param {ElementBoundBox} elementBox - The position box of the element.
408
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
409
+ * @param {PlacementType} placement - The placement of the element.
410
+ * @param {PositionAlignmentType} alignment - The alignment of the element
411
+ * @returns {number} The left position of the element.
412
+ */
413
+ calculateLeft(elementBox, targetBox, placement, alignment) {
414
+ switch (placement) {
415
+ case 'top':
416
+ case 'bottom': {
417
+ if (alignment === 'end') {
418
+ return targetBox.left + targetBox.width - elementBox.width;
419
+ }
420
+ else if (alignment === 'center') {
421
+ return targetBox.left - (elementBox.width - targetBox.width) / 2;
422
+ }
423
+ else {
424
+ return targetBox.left;
425
+ }
426
+ }
427
+ case 'left': {
428
+ return targetBox.left - elementBox.width;
429
+ }
430
+ case 'right': {
431
+ return targetBox.left + targetBox.width;
432
+ }
433
+ /* istanbul ignore next */
434
+ default:
435
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
436
+ }
437
+ }
438
+ /**
439
+ * Calculate the top position of the element
440
+ *
441
+ * @param {ElementBoundBox} elementBox - The position box of the element.
442
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
443
+ * @param {PlacementType} placement - The placement of the element.
444
+ * @param {PositionAlignmentType} alignment - The alignment of the element
445
+ * @returns {number} the top position of the element.
446
+ */
447
+ calculateTop(elementBox, targetBox, placement, alignment) {
448
+ switch (placement) {
449
+ case 'left':
450
+ case 'right': {
451
+ if (alignment === 'end') {
452
+ return targetBox.top + targetBox.height - elementBox.height;
453
+ }
454
+ else if (alignment === 'center') {
455
+ return targetBox.top - (elementBox.height - targetBox.height) / 2;
456
+ }
457
+ else {
458
+ return targetBox.top;
459
+ }
460
+ }
461
+ case 'top': {
462
+ return targetBox.top - elementBox.height;
463
+ }
464
+ case 'bottom': {
465
+ return targetBox.top + targetBox.height;
466
+ }
467
+ /* istanbul ignore next */
468
+ default:
469
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
470
+ }
471
+ }
472
+ /**
473
+ * It takes a list of placements and returns the first placement that has enough space to place the
474
+ * element
475
+ *
476
+ * @param {ElementScrollDimension} containerBox - The box of the container element.
477
+ * @param {ElementBoundBox} elementBox - The box of the element to be placed.
478
+ * @param {ElementBoundBox} targetBox - The box of the target element.
479
+ * @param {PlacementType[]} placements - The placements that we want to try.
480
+ * @returns {PlacementType} A function that takes in a containerBox, elementBox, targetBox, placements, and element.
481
+ */
482
+ getSuitablePlacement(containerBox, elementBox, targetBox, placements) {
483
+ const defaultPlacement = placements[0];
484
+ const suitablePlacement = placements.find((placement) => this.hasEnoughSpace(containerBox, placement, targetBox, elementBox));
485
+ if (suitablePlacement) {
486
+ return suitablePlacement;
487
+ }
488
+ else {
489
+ LogUtility.warn(`
490
+ No enough space found for placing element and we will keep using the defined placement:
491
+ ${defaultPlacement}
492
+ `);
493
+ return defaultPlacement;
494
+ }
495
+ }
496
+ /**
497
+ * It takes a list of alignments and returns the suitable one that has enough space to fit the element
498
+ *
499
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
500
+ * @param {ElementBoundBox} elementBox - The box of the element that we want to position.
501
+ * @param {ElementBoundBox} targetBox - The box of the element that the element to be positioned is aligned to.
502
+ * @param {PlacementType} placement - The placement of the element relative to the target.
503
+ * @param {PositionAlignmentType[]} alignments - An array of alignments to try.
504
+ * @returns {PositionAlignmentType} the alignment that is suitable for the element.
505
+ */
506
+ getSuitableAlignment(containerBox, elementBox, targetBox, placement, alignments) {
507
+ const defaultAlignment = alignments[0];
508
+ const suitableAlignment = alignments.find((alignment) => this.hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment));
509
+ if (suitableAlignment) {
510
+ return suitableAlignment;
511
+ }
512
+ else {
513
+ LogUtility.warn(`
514
+ No enough space found for placing element and we will keep using the defined alignment:
515
+ ${defaultAlignment}
516
+ `);
517
+ return defaultAlignment;
518
+ }
519
+ }
520
+ /**
521
+ * Whether the alignment space is enough
522
+ *
523
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
524
+ * @param {ElementBoundBox} targetBox - The position of the target element.
525
+ * @param {ElementBoundBox} elementBox - The box of the element that we're trying to position.
526
+ * @param {PlacementType} placement - The placement of the element relative to the target.
527
+ * @param {PlacementType} alignment - The alignment of the element relative to the target.
528
+ * @returns {boolean} return true if it has enough space, otherwise false
529
+ */
530
+ hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment) {
531
+ if (['top', 'bottom'].includes(placement)) {
532
+ switch (alignment) {
533
+ case 'start': {
534
+ return targetBox.left + elementBox.width <= containerBox.width;
535
+ }
536
+ case 'center': {
537
+ return (targetBox.left >= (elementBox.width - targetBox.width) / 2 &&
538
+ targetBox.left + targetBox.width / 2 + elementBox.width / 2 <= containerBox.width);
539
+ }
540
+ case 'end': {
541
+ return targetBox.left + targetBox.width >= elementBox.width;
542
+ }
543
+ }
544
+ }
545
+ if (['right', 'left'].includes(placement)) {
546
+ switch (alignment) {
547
+ case 'start': {
548
+ return targetBox.top + elementBox.height <= containerBox.height;
549
+ }
550
+ case 'center': {
551
+ return (targetBox.top >= (elementBox.height - targetBox.height) / 2 &&
552
+ targetBox.top + targetBox.height / 2 + elementBox.height / 2 <= containerBox.height);
553
+ }
554
+ case 'end': {
555
+ return targetBox.top + targetBox.height >= elementBox.height;
556
+ }
557
+ }
558
+ }
559
+ /* istanbul ignore next */
560
+ return false;
561
+ }
562
+ /**
563
+ * If the placement is top or left, then the target's top or left position must be greater than or
564
+ * equal to the element's height or width. If the placement is bottom or right, then the container's
565
+ * height or width minus the target's top or left position minus the target's height or width must be
566
+ * greater than or equal to the element's height or width.
567
+ *
568
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
569
+ * @param {PlacementType} placement - The placement of the element.
570
+ * @param {ElementBoundBox} targetBox - The position of the target element.
571
+ * @param {ElementBoundBox} elementBox - The dimensions of the element to be positioned.
572
+ * @returns {boolean} A boolean value.
573
+ */
574
+ hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
575
+ switch (placement) {
576
+ case 'top':
577
+ return targetBox.top >= elementBox.height;
578
+ case 'bottom':
579
+ return containerBox.height - targetBox.top - targetBox.height >= elementBox.height;
580
+ case 'left':
581
+ return targetBox.left >= elementBox.width;
582
+ case 'right':
583
+ return containerBox.width - targetBox.left - targetBox.width >= elementBox.width;
584
+ /* istanbul ignore next */
585
+ default:
586
+ return false;
587
+ }
588
+ }
589
+ /**
590
+ * Retrieves and formats the translocation.
591
+ *
592
+ * @returns {TranslocationType} current translocation.
593
+ */
594
+ getTranslocation() {
595
+ const translocation = this.showConfig.translocation;
596
+ return translocation && ResponsiveFormatFacade.format(translocation, 'translocation');
597
+ }
598
+ }
599
+
600
+ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
601
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
602
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
603
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
604
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
605
+ };
606
+ /**
607
+ * calculate position by body container
608
+ */
609
+ class BodyPositionCalculationStrategy extends BasePositionCalculationStrategy {
610
+ /**
611
+ * Get the position of the element in the container according to the target element and the placement
612
+ * If give a translocation, it will apply the translocation to the result.
613
+ * Note: If you use this method to calculate the position, you should make container as relative position at first.
614
+ *
615
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
616
+ * returns an ElementPositionBox.
617
+ */
618
+ getPosition() {
619
+ const containerStyle = window.getComputedStyle(this.container);
620
+ if (containerStyle.position !== 'relative') {
621
+ LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
622
+ }
623
+ return this.getPositionBox();
624
+ }
625
+ /**
626
+ * It returns the position of an element relative to its container and also includes the scroll height of container.
627
+ *
628
+ * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
629
+ */
630
+ getTargetBoundBox() {
631
+ const containerRect = this.container.getBoundingClientRect();
632
+ const targetRect = this.showConfig.target.getBoundingClientRect();
633
+ const targetTop = targetRect.top - containerRect.top + this.container.scrollTop;
634
+ const targetLeft = targetRect.left - containerRect.left + this.container.scrollLeft;
635
+ return {
636
+ width: targetRect.width,
637
+ height: targetRect.height,
638
+ top: targetTop,
639
+ left: targetLeft,
640
+ };
641
+ }
642
+ /**
643
+ * "Get the width and height of an element."
644
+ *
645
+ * The function takes a single parameter, a container element, and returns an object with two
646
+ * properties: width and height
647
+ *
648
+ * @returns {ElementScrollDimension} An object with two properties: width and height.
649
+ */
650
+ getElementScrollDimension() {
651
+ return {
652
+ width: this.container.scrollWidth,
653
+ height: this.container.scrollHeight,
654
+ };
655
+ }
656
+ }
657
+ __decorate$4([
658
+ MapToComponentField()
659
+ ], BodyPositionCalculationStrategy.prototype, "container", void 0);
660
+ __decorate$4([
661
+ MapToComponentField()
662
+ ], BodyPositionCalculationStrategy.prototype, "showConfig", void 0);
663
+
664
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
665
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
666
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
667
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
668
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
669
+ };
670
+ /**
671
+ * calculate position by screen container
672
+ */
673
+ class ScreenPositionCalculationStrategy extends BasePositionCalculationStrategy {
674
+ /**
675
+ * Get the position of the element in the container according to the target element and the placement
676
+ * If give a translocation, it will apply the translocation to the result.
677
+ *
678
+ * @param {boolean} usePreviousPlacement - Should keep use previous placement and alignment.
679
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
680
+ * returns an ElementPositionBox.
681
+ */
682
+ getPosition(usePreviousPlacement) {
683
+ const positionBox = usePreviousPlacement
684
+ ? this.getPositionBox([this.previousPositionBox.placement], [this.previousPositionBox.alignment])
685
+ : this.getPositionBox();
686
+ this.previousPositionBox = positionBox;
687
+ return positionBox;
688
+ }
689
+ /**
690
+ * It returns the position of an element relative to its container and also includes the scroll height of container.
691
+ *
692
+ * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
693
+ */
694
+ getTargetBoundBox() {
695
+ const targetRect = this.showConfig.target.getBoundingClientRect();
696
+ return {
697
+ width: targetRect.width,
698
+ height: targetRect.height,
699
+ top: targetRect.top,
700
+ left: targetRect.left,
701
+ };
702
+ }
703
+ /**
704
+ * "Get the width and height of an element."
705
+ *
706
+ * The function takes a single parameter, a container element, and returns an object with two
707
+ * properties: width and height
708
+ *
709
+ * @returns {ElementScrollDimension} An object with two properties: width and height.
710
+ */
711
+ getElementScrollDimension() {
712
+ return {
713
+ width: window.innerWidth,
714
+ height: window.innerHeight,
715
+ };
716
+ }
717
+ }
718
+ __decorate$3([
719
+ MapToComponentField()
720
+ ], ScreenPositionCalculationStrategy.prototype, "showConfig", void 0);
721
+
722
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
723
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
724
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
725
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
726
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
727
+ };
728
+ /**
729
+ * Calculation and adjustment of positions for appendable elements based on target element positions.
730
+ */
731
+ class PositionCalculationController extends VegaSlimmer {
732
+ constructor() {
733
+ super(...arguments);
734
+ this.bodyPositionStrategy = new BodyPositionCalculationStrategy();
735
+ this.screenPositionStrategy = new ScreenPositionCalculationStrategy();
736
+ }
737
+ /**
738
+ * Sets the calculate postion strategy.
739
+ */
740
+ setCalculationStrategy() {
741
+ this.positionStrategy = this.showConfig.isScreenPosition
742
+ ? this.screenPositionStrategy
743
+ : this.bodyPositionStrategy;
744
+ }
745
+ /**
746
+ * Calculates the position and applies it to the appendable element.
747
+ *
748
+ * @param {boolean} [usePreviousPlacement] - Should keep use previous placement and alignment.
749
+ */
750
+ adjustPosition(usePreviousPlacement) {
751
+ this.adjustWidth();
752
+ this.adjustHeight();
753
+ this.applyPosition(this.positionStrategy.getPosition(usePreviousPlacement));
754
+ }
755
+ /**
756
+ * Apply the position to the appendable element.
757
+ *
758
+ * @param {ElementPositionBox} positionBox - position box
759
+ */
760
+ applyPosition(positionBox) {
761
+ const appendableElement = this.showConfig.appendableElement;
762
+ if (this.showConfig.isScreenPosition) {
763
+ appendableElement.style.position = 'fixed';
764
+ }
765
+ appendableElement.style.left = `${positionBox.left}px`;
766
+ appendableElement.style.top = `${positionBox.top}px`;
767
+ appendableElement.classList.remove('vega-placement-left', 'vega-placement-right', 'vega-placement-top', 'vega-placement-bottom');
768
+ appendableElement.classList.remove('vega-alignment-start', 'vega-alignment-center', 'vega-alignment-end');
769
+ appendableElement.classList.add(`vega-placement-${positionBox.placement}`);
770
+ appendableElement.classList.add(`vega-alignment-${positionBox.alignment}`);
771
+ }
772
+ /**
773
+ * It sets the width of the appendable element to the width of the target element if the
774
+ * matchTargetWidth property is true, otherwise it sets the width of the appendable element to the
775
+ * size property
776
+ *
777
+ * @returns {void}
778
+ */
779
+ adjustWidth() {
780
+ if (this.showConfig.matchTargetWidth) {
781
+ const { width: hostWidth } = this.showConfig.target.getBoundingClientRect();
782
+ this.setRelatedWidth('width', hostWidth);
783
+ }
784
+ else {
785
+ this.setRelatedWidth('width', this.showConfig.size);
786
+ this.setRelatedWidth('minWidth', this.showConfig.minWidth);
787
+ this.setRelatedWidth('maxWidth', this.showConfig.maxWidth);
788
+ }
789
+ }
790
+ /**
791
+ * It takes a name and a value, formats the value, and then sets the style of the element
792
+ *
793
+ * @param {'width' | 'maxWidth' | 'minWidth'} name - 'width' | 'maxWidth' | 'minWidth'
794
+ * @param {ResponsiveType<SizeType>} value - ResponsiveType<SizeType>
795
+ * @returns {void}
796
+ */
797
+ setRelatedWidth(name, value) {
798
+ if (!value)
799
+ return;
800
+ const formattedValue = ResponsiveFormatFacade.format(value, 'size');
801
+ if (formattedValue) {
802
+ this.showConfig.appendableElement.style[name] =
803
+ typeof formattedValue === 'number' ? `${formattedValue}px` : formattedValue;
804
+ }
805
+ }
806
+ /**
807
+ * > If the `matchContainerHeight` property is set to `true`, then the maximum height of the dropdown
808
+ * is set to the height of the container minus the height of the target minus the top offset of the
809
+ * target
810
+ *
811
+ * @returns {void}
812
+ */
813
+ adjustHeight() {
814
+ if (this.showConfig.matchContainerHeight) {
815
+ const { height: targetHeight } = this.showConfig.target.getBoundingClientRect();
816
+ let maxHeight = this.container.scrollHeight - this.showConfig.target.offsetTop - targetHeight;
817
+ if (this.showConfig.maxHeight) {
818
+ maxHeight = Math.min(maxHeight, this.showConfig.maxHeight);
819
+ }
820
+ this.showConfig.appendableElement.style.maxHeight = `${maxHeight}px`;
821
+ }
822
+ else if (this.showConfig.maxHeight) {
823
+ this.showConfig.appendableElement.style.maxHeight = `${this.showConfig.maxHeight}px`;
824
+ }
825
+ }
826
+ }
827
+ __decorate$2([
828
+ MapToComponentField()
829
+ ], PositionCalculationController.prototype, "container", void 0);
830
+ __decorate$2([
831
+ MapToComponentField()
832
+ ], PositionCalculationController.prototype, "showConfig", void 0);
833
+ __decorate$2([
834
+ InjectVegaSlimmer()
835
+ ], PositionCalculationController.prototype, "bodyPositionStrategy", void 0);
836
+ __decorate$2([
837
+ InjectVegaSlimmer()
838
+ ], PositionCalculationController.prototype, "screenPositionStrategy", void 0);
839
+
613
840
  var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
614
841
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
615
842
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -654,8 +881,6 @@ class ElementAppender {
654
881
  // https://gethired.atlassian.net/browse/VD-1087
655
882
  if (isElementVisible(this.showConfig.target) &&
656
883
  isElementVisible(this.showConfig.appendableElement)) {
657
- this.adjustWidth();
658
- this.adjustHeight();
659
884
  this.adjustPosition();
660
885
  }
661
886
  },
@@ -664,6 +889,7 @@ class ElementAppender {
664
889
  },
665
890
  ]);
666
891
  this.elementAppenderContainerController = new ElementAppenderContainerController();
892
+ this.positionCalculationController = new PositionCalculationController();
667
893
  this.showConfigCallback = showConfigCallback;
668
894
  this.showConfigCallbackTarget = showConfigCallbackTarget;
669
895
  const config = this.getShowConfig();
@@ -688,8 +914,6 @@ class ElementAppender {
688
914
  /* A function that takes no parameters and returns nothing. It sets the position of the appendable
689
915
  element. */
690
916
  this.prepareShow();
691
- this.adjustWidth();
692
- this.adjustHeight();
693
917
  this.adjustPosition();
694
918
  this.setZIndex();
695
919
  this.toggleShow(true);
@@ -705,6 +929,18 @@ class ElementAppender {
705
929
  this.resetContainerPosition();
706
930
  InternalVegaZIndexManager.removeZIndex(this.showConfig.appendableElement, 'base');
707
931
  }
932
+ /**
933
+ * Update position while window scroll.
934
+ */
935
+ onScroll() {
936
+ var _a;
937
+ const currentTargetRect = this.showConfig.target.getBoundingClientRect();
938
+ if (this.showConfig.isScreenPosition &&
939
+ (currentTargetRect.left !== ((_a = this.previousTargetRect) === null || _a === void 0 ? void 0 : _a.left) ||
940
+ currentTargetRect.top !== this.previousTargetRect.top)) {
941
+ this.adjustPosition(true);
942
+ }
943
+ }
708
944
  /* istanbul ignore next */
709
945
  /**
710
946
  * It removes the z-index from the appendable element, removes the appendable element from the DOM, and
@@ -814,76 +1050,16 @@ class ElementAppender {
814
1050
  this.container.style.position = 'relative';
815
1051
  }
816
1052
  this.showConfig.appendableElement.style.boxSizing = 'border-box';
817
- }
818
- /**
819
- * It sets the width of the appendable element to the width of the target element if the
820
- * matchTargetWidth property is true, otherwise it sets the width of the appendable element to the
821
- * size property
822
- *
823
- * @returns {void}
824
- */
825
- adjustWidth() {
826
- if (this.showConfig.matchTargetWidth) {
827
- const { width: hostWidth } = this.showConfig.target.getBoundingClientRect();
828
- this.setRelatedWidth('width', hostWidth);
829
- }
830
- else {
831
- this.setRelatedWidth('width', this.showConfig.size);
832
- this.setRelatedWidth('minWidth', this.showConfig.minWidth);
833
- this.setRelatedWidth('maxWidth', this.showConfig.maxWidth);
834
- }
835
- }
836
- /**
837
- * It takes a name and a value, formats the value, and then sets the style of the element
838
- *
839
- * @param {'width' | 'maxWidth' | 'minWidth'} name - 'width' | 'maxWidth' | 'minWidth'
840
- * @param {ResponsiveType<SizeType>} value - ResponsiveType<SizeType>
841
- * @returns {void}
842
- */
843
- setRelatedWidth(name, value) {
844
- if (!value)
845
- return;
846
- const formattedValue = ResponsiveFormatFacade.format(value, 'size');
847
- if (formattedValue) {
848
- this.showConfig.appendableElement.style[name] =
849
- typeof formattedValue === 'number' ? `${formattedValue}px` : formattedValue;
850
- }
851
- }
852
- /**
853
- * > If the `matchContainerHeight` property is set to `true`, then the maximum height of the dropdown
854
- * is set to the height of the container minus the height of the target minus the top offset of the
855
- * target
856
- *
857
- * @returns {void}
858
- */
859
- adjustHeight() {
860
- if (this.showConfig.matchContainerHeight) {
861
- const { height: targetHeight } = this.showConfig.target.getBoundingClientRect();
862
- let maxHeight = this.container.scrollHeight - this.showConfig.target.offsetTop - targetHeight;
863
- if (this.showConfig.maxHeight) {
864
- maxHeight = Math.min(maxHeight, this.showConfig.maxHeight);
865
- }
866
- this.showConfig.appendableElement.style.maxHeight = `${maxHeight}px`;
867
- }
868
- else if (this.showConfig.maxHeight) {
869
- this.showConfig.appendableElement.style.maxHeight = `${this.showConfig.maxHeight}px`;
870
- }
1053
+ this.positionCalculationController.setCalculationStrategy();
871
1054
  }
872
1055
  /**
873
1056
  * A function that takes no parameters and returns nothing. It sets the position of the appendable element.
874
1057
  *
1058
+ * @param {boolean} usePreviousPlacement - Should keep use previous placement and alignment.
875
1059
  * @returns {void}
876
1060
  */
877
- adjustPosition() {
878
- const translocation = this.showConfig.translocation &&
879
- ResponsiveFormatFacade.format(this.showConfig.translocation, 'translocation');
880
- const positionBox = getPositionBox(this.container, this.showConfig.appendableElement, this.showConfig.target, this.showConfig.placement, this.showConfig.alignment, translocation);
881
- this.showConfig.appendableElement.style.left = `${positionBox.left}px`;
882
- this.showConfig.appendableElement.style.top = `${positionBox.top}px`;
883
- this.showConfig.appendableElement.classList.remove('vega-placement-left', 'vega-placement-right', 'vega-placement-top', 'vega-placement-bottom');
884
- this.showConfig.appendableElement.classList.remove('vega-alignment-start', 'vega-alignment-center', 'vega-alignment-end');
885
- this.showConfig.appendableElement.classList.add(`vega-placement-${positionBox.placement}`);
886
- this.showConfig.appendableElement.classList.add(`vega-alignment-${positionBox.alignment}`);
1061
+ adjustPosition(usePreviousPlacement) {
1062
+ this.positionCalculationController.adjustPosition(usePreviousPlacement);
887
1063
  }
888
1064
  /**
889
1065
  * Sets the z-index of the appendable element to 11000.
@@ -919,6 +1095,9 @@ __decorate$1([
919
1095
  __decorate$1([
920
1096
  InjectVegaSlimmer()
921
1097
  ], ElementAppender.prototype, "elementAppenderContainerController", void 0);
1098
+ __decorate$1([
1099
+ InjectVegaSlimmer()
1100
+ ], ElementAppender.prototype, "positionCalculationController", void 0);
922
1101
 
923
1102
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
924
1103
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -944,6 +1123,7 @@ class ElementAppenderSlimmer extends VegaSlimmer {
944
1123
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseleave', this.elementMouseLeaveHandler);
945
1124
  }
946
1125
  window.addEventListener('mousedown', this.globalMouseDownHandler);
1126
+ document.addEventListener('scroll', this.globalScrollHandler, { capture: true });
947
1127
  };
948
1128
  /* It's a function that listens to the click event on the dropdown. It checks if the trigger
949
1129
  property is equal to 'click'. If it is, then it toggles the dropdown. */
@@ -1005,6 +1185,14 @@ class ElementAppenderSlimmer extends VegaSlimmer {
1005
1185
  this.hide();
1006
1186
  }
1007
1187
  };
1188
+ /* istanbul ignore next */
1189
+ /* Listen global scroll event */
1190
+ this.globalScrollHandler = () => {
1191
+ var _a;
1192
+ if (this.showConfig && this.showConfig.isScreenPosition && this.isShowing()) {
1193
+ (_a = this.elementAppender) === null || _a === void 0 ? void 0 : _a.onScroll();
1194
+ }
1195
+ };
1008
1196
  /* A timer that will hide the dropdown after a certain amount of time. */
1009
1197
  this.createDelayHideTimer = () => {
1010
1198
  this.delayHideTimer = setTimeout(() => {
@@ -1091,6 +1279,7 @@ class ElementAppenderSlimmer extends VegaSlimmer {
1091
1279
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('mouseleave', this.elementMouseLeaveHandler);
1092
1280
  }
1093
1281
  window.removeEventListener('mousedown', this.globalMouseDownHandler);
1282
+ document.removeEventListener('scroll', this.globalScrollHandler);
1094
1283
  }
1095
1284
  }
1096
1285
  ElementAppenderSlimmer.DELAY_HIDE_TIME = 100;