@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
@@ -4,31 +4,32 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  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;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { findParent } from '../../../utils/ui';
7
+ import { findParent } from '../../../../utils/ui';
8
+ import { BodyPositionedWrapper } from './body-positioned-wrapper.abstract';
8
9
  import { MapToComponentField as MapToSlimmerField } from 'vega-slimmer/core';
9
10
  /**
10
11
  * This class is used to get the class `vega-popover` as a container and store the element appender element.
11
12
  *
12
13
  * @property {HTMLElement} showConfig the show config
13
14
  */
14
- export class VegaPopoverWrapper {
15
- constructor() {
16
- /**
17
- * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
18
- *
19
- * @returns {boolean} the boolean type.
20
- */
21
- this.canRetrieve = () => !!findParent(this.showConfig.target, '.vega-popover');
22
- /**
23
- * 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.
24
- *
25
- * @returns {HTMLElement} the element.
26
- */
27
- this.retrieve = () => {
28
- const container = findParent(this.showConfig.target, '.vega-popover');
29
- container.append(this.showConfig.appendableElement);
30
- return container;
31
- };
15
+ export class VegaPopoverWrapper extends BodyPositionedWrapper {
16
+ /**
17
+ * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
18
+ *
19
+ * @returns {boolean} the boolean type.
20
+ */
21
+ canRetrieve() {
22
+ return super.canRetrieve() && !!findParent(this.showConfig.target, '.vega-popover');
23
+ }
24
+ /**
25
+ * 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.
26
+ *
27
+ * @returns {HTMLElement} the element.
28
+ */
29
+ retrieve() {
30
+ const container = findParent(this.showConfig.target, '.vega-popover');
31
+ container.append(this.showConfig.appendableElement);
32
+ return container;
32
33
  }
33
34
  }
34
35
  __decorate([
@@ -9,25 +9,25 @@ import { MapToComponentField as MapToSlimmerField } from 'vega-slimmer/core';
9
9
  * This class is is used to retrieve the body element of document.
10
10
  */
11
11
  export class DefaultWrapper {
12
- constructor() {
13
- /**
14
- * The canRetrieve function return is always true.
15
- *
16
- * @returns {boolean} the boolean type.
17
- */
18
- this.canRetrieve = () => true;
19
- /**
20
- * The retrieve function get the body element of document.
21
- *
22
- * @returns {HTMLElement} the element.
23
- */
24
- this.retrieve = () => {
25
- const container = document.body;
26
- if (this.showConfig.appendableElement.parentElement !== container) {
27
- container.append(this.showConfig.appendableElement);
28
- }
29
- return container;
30
- };
12
+ /**
13
+ * The canRetrieve function return is always true.
14
+ *
15
+ * @returns {boolean} the boolean type.
16
+ */
17
+ canRetrieve() {
18
+ return true;
19
+ }
20
+ /**
21
+ * The retrieve function get the body element of document.
22
+ *
23
+ * @returns {HTMLElement} the element.
24
+ */
25
+ retrieve() {
26
+ const container = document.body;
27
+ if (this.showConfig.appendableElement.parentElement !== container) {
28
+ container.append(this.showConfig.appendableElement);
29
+ }
30
+ return container;
31
31
  }
32
32
  }
33
33
  __decorate([
@@ -6,9 +6,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { InjectVegaSlimmer, MapToComponentField as MapToSlimmerField, VegaSlimmer } from 'vega-slimmer/core';
8
8
  import { DefaultWrapper } from './default-wrapper';
9
- import { PositionRelativeToWrapper } from './position-relative-to-wrapper';
10
- import { VegaModalWrapper } from './vega-modal-wrapper';
11
- import { VegaPopoverWrapper } from './vega-popover-wrapper';
9
+ import { PositionRelativeToWrapper } from './body-positioned-wrapper/position-relative-to-wrapper';
10
+ import { VegaModalWrapper } from './body-positioned-wrapper/vega-modal-wrapper';
11
+ import { VegaPopoverWrapper } from './body-positioned-wrapper/vega-popover-wrapper';
12
12
  /**
13
13
  * This class is responsible for setting the container element for appending an element based on certain conditions.
14
14
  *
@@ -25,6 +25,7 @@ export class ElementAppenderSlimmer extends VegaSlimmer {
25
25
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseleave', this.elementMouseLeaveHandler);
26
26
  }
27
27
  window.addEventListener('mousedown', this.globalMouseDownHandler);
28
+ document.addEventListener('scroll', this.globalScrollHandler, { capture: true });
28
29
  };
29
30
  /* It's a function that listens to the click event on the dropdown. It checks if the trigger
30
31
  property is equal to 'click'. If it is, then it toggles the dropdown. */
@@ -86,6 +87,14 @@ export class ElementAppenderSlimmer extends VegaSlimmer {
86
87
  this.hide();
87
88
  }
88
89
  };
90
+ /* istanbul ignore next */
91
+ /* Listen global scroll event */
92
+ this.globalScrollHandler = () => {
93
+ var _a;
94
+ if (this.showConfig && this.showConfig.isScreenPosition && this.isShowing()) {
95
+ (_a = this.elementAppender) === null || _a === void 0 ? void 0 : _a.onScroll();
96
+ }
97
+ };
89
98
  /* A timer that will hide the dropdown after a certain amount of time. */
90
99
  this.createDelayHideTimer = () => {
91
100
  this.delayHideTimer = setTimeout(() => {
@@ -172,6 +181,7 @@ export class ElementAppenderSlimmer extends VegaSlimmer {
172
181
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('mouseleave', this.elementMouseLeaveHandler);
173
182
  }
174
183
  window.removeEventListener('mousedown', this.globalMouseDownHandler);
184
+ document.removeEventListener('scroll', this.globalScrollHandler);
175
185
  }
176
186
  }
177
187
  ElementAppenderSlimmer.DELAY_HIDE_TIME = 100;
@@ -0,0 +1,345 @@
1
+ import { VegaSlimmer } from 'vega-slimmer/core';
2
+ import { Alignments, Placements } from '../../../constants/ui';
3
+ import { isTranslocationType } from '../../../types/type-guard';
4
+ import { LogUtility } from '../../../utils/log';
5
+ import ResponsiveFormatFacade from '../../formatter/responsive-map-formatter/responsive-format-facade';
6
+ /**
7
+ * calculate position
8
+ */
9
+ export class BasePositionCalculationStrategy extends VegaSlimmer {
10
+ /**
11
+ * Get the position box.
12
+ *
13
+ * @param {PlacementType[]} placement - previous placement.
14
+ * @param {PositionAlignmentType[]} alignment - previous placement.
15
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
16
+ * returns an ElementPositionBox.
17
+ */
18
+ getPositionBox(placement, alignment) {
19
+ const placements = placement || this.getPlacements();
20
+ const alignments = alignment || this.getAlignments();
21
+ const targetBox = this.getTargetBoundBox();
22
+ const elementBox = this.getElementBoundBox();
23
+ const containerBox = this.getElementScrollDimension();
24
+ const suitablePlacement = this.getSuitablePlacement(containerBox, elementBox, targetBox, placements);
25
+ const suitableAlignment = this.getSuitableAlignment(containerBox, elementBox, targetBox, suitablePlacement, alignments);
26
+ const positionBox = this.calculatePosition(elementBox, targetBox, suitablePlacement, suitableAlignment);
27
+ const translocationBox = this.getTranslocationBox(suitablePlacement);
28
+ positionBox.placement = suitablePlacement;
29
+ positionBox.alignment = suitableAlignment;
30
+ positionBox.left += translocationBox.X;
31
+ positionBox.top += translocationBox.Y;
32
+ return positionBox;
33
+ }
34
+ /**
35
+ * "Get the width, height, and top position of an element."
36
+ *
37
+ * The function takes an element as an argument and returns an object with three properties: width,
38
+ * height, and top.
39
+ *
40
+ * Note: If element is hide, we should temporary change it to `block` to get the bounding client rect of element,
41
+ * After do that, this element will change to origin `hide`, if not, it will be contained in the calculate of `document.documentElement.scrollHeight`
42
+ *
43
+ * @returns {ElementBoundBox} An object with the width, height, and top properties of the element.
44
+ */
45
+ getElementBoundBox() {
46
+ const element = this.showConfig.appendableElement;
47
+ const isElementHide = element.classList.contains('vega-force-hidden');
48
+ if (isElementHide)
49
+ element.classList.remove('vega-force-hidden');
50
+ const elementRect = element.getBoundingClientRect();
51
+ if (isElementHide)
52
+ element.classList.add('vega-force-hidden');
53
+ return {
54
+ width: elementRect.width,
55
+ height: elementRect.height,
56
+ left: elementRect.left,
57
+ top: elementRect.top,
58
+ };
59
+ }
60
+ /**
61
+ * It takes a placement string or array of placements and returns an array of placements
62
+ * if given placement is single, we should completion the placements with the default {@link Placements}
63
+ * and make given placement as default.
64
+ * if given placement is array, we should use it directly, even it partial of {@link Placements}.
65
+ * if not placement give. we should use {@link Placements}.
66
+ *
67
+ * @returns {PlacementType[]} ordered placements.
68
+ */
69
+ getPlacements() {
70
+ const placement = this.showConfig.placement;
71
+ if (typeof placement === 'string') {
72
+ const partial = Placements.filter((direction) => direction !== placement);
73
+ return [placement, ...partial];
74
+ }
75
+ else if (Array.isArray(placement)) {
76
+ return placement;
77
+ }
78
+ else {
79
+ return [...Placements];
80
+ }
81
+ }
82
+ /**
83
+ * It returns acceptable alignments.
84
+ *
85
+ * @returns {PositionAlignmentType[]} acceptable alignments
86
+ */
87
+ getAlignments() {
88
+ const alignment = this.showConfig.alignment;
89
+ if (typeof alignment === 'string') {
90
+ const partial = Alignments.filter((item) => item !== alignment);
91
+ return [alignment, ...partial];
92
+ }
93
+ else if (Array.isArray(alignment)) {
94
+ return alignment;
95
+ }
96
+ else {
97
+ return [...Alignments];
98
+ }
99
+ }
100
+ /**
101
+ * It takes a placement, a target box, and a element box, and returns an element box
102
+ *
103
+ * @param {ElementBoundBox} elementBox - The position of the element element.
104
+ * @param {ElementBoundBox} targetBox - The position of the target element.
105
+ * @param {PlacementType} placement - The placement of the element.
106
+ * @param {PositionAlignmentType} alignment - The alignment of the element
107
+ * @returns {ElementPositionBox} An object with top and left properties.
108
+ */
109
+ calculatePosition(elementBox, targetBox, placement, alignment) {
110
+ return {
111
+ top: this.calculateTop(elementBox, targetBox, placement, alignment),
112
+ left: this.calculateLeft(elementBox, targetBox, placement, alignment),
113
+ };
114
+ }
115
+ /**
116
+ * It returns the translocation of the element relative to the target element
117
+ *
118
+ * @param {PlacementType} placement - The suitable placement of the element.
119
+ * @returns {TranslocationType} A translocation object with X and Y properties.
120
+ */
121
+ getTranslocationBox(placement) {
122
+ const originPlacement = Array.isArray(this.showConfig.placement)
123
+ ? this.showConfig.placement[0]
124
+ : this.showConfig.placement;
125
+ const translocation = this.getTranslocation();
126
+ const result = { X: 0, Y: 0 };
127
+ if (isTranslocationType(translocation)) {
128
+ let xValue = translocation.X;
129
+ let yValue = translocation.Y;
130
+ // If originPlacement and placement is not in same axis, it should reverse axis.
131
+ if ((originPlacement &&
132
+ ['left', 'right'].includes(originPlacement) &&
133
+ ['top', 'bottom'].includes(placement)) ||
134
+ (originPlacement &&
135
+ ['top', 'bottom'].includes(originPlacement) &&
136
+ ['left', 'right'].includes(placement))) {
137
+ xValue = translocation.Y;
138
+ yValue = translocation.X;
139
+ }
140
+ if (['bottom', 'top'].includes(placement)) {
141
+ result.Y = placement === 'top' ? -yValue : yValue;
142
+ result.X = xValue;
143
+ }
144
+ if (['left', 'right'].includes(placement)) {
145
+ result.X = placement === 'left' ? -xValue : xValue;
146
+ result.Y = yValue;
147
+ }
148
+ }
149
+ return result;
150
+ }
151
+ /**
152
+ * Calculate the left position of the element
153
+ *
154
+ * @param {ElementBoundBox} elementBox - The position box of the element.
155
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
156
+ * @param {PlacementType} placement - The placement of the element.
157
+ * @param {PositionAlignmentType} alignment - The alignment of the element
158
+ * @returns {number} The left position of the element.
159
+ */
160
+ calculateLeft(elementBox, targetBox, placement, alignment) {
161
+ switch (placement) {
162
+ case 'top':
163
+ case 'bottom': {
164
+ if (alignment === 'end') {
165
+ return targetBox.left + targetBox.width - elementBox.width;
166
+ }
167
+ else if (alignment === 'center') {
168
+ return targetBox.left - (elementBox.width - targetBox.width) / 2;
169
+ }
170
+ else {
171
+ return targetBox.left;
172
+ }
173
+ }
174
+ case 'left': {
175
+ return targetBox.left - elementBox.width;
176
+ }
177
+ case 'right': {
178
+ return targetBox.left + targetBox.width;
179
+ }
180
+ /* istanbul ignore next */
181
+ default:
182
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
183
+ }
184
+ }
185
+ /**
186
+ * Calculate the top position of the element
187
+ *
188
+ * @param {ElementBoundBox} elementBox - The position box of the element.
189
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
190
+ * @param {PlacementType} placement - The placement of the element.
191
+ * @param {PositionAlignmentType} alignment - The alignment of the element
192
+ * @returns {number} the top position of the element.
193
+ */
194
+ calculateTop(elementBox, targetBox, placement, alignment) {
195
+ switch (placement) {
196
+ case 'left':
197
+ case 'right': {
198
+ if (alignment === 'end') {
199
+ return targetBox.top + targetBox.height - elementBox.height;
200
+ }
201
+ else if (alignment === 'center') {
202
+ return targetBox.top - (elementBox.height - targetBox.height) / 2;
203
+ }
204
+ else {
205
+ return targetBox.top;
206
+ }
207
+ }
208
+ case 'top': {
209
+ return targetBox.top - elementBox.height;
210
+ }
211
+ case 'bottom': {
212
+ return targetBox.top + targetBox.height;
213
+ }
214
+ /* istanbul ignore next */
215
+ default:
216
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
217
+ }
218
+ }
219
+ /**
220
+ * It takes a list of placements and returns the first placement that has enough space to place the
221
+ * element
222
+ *
223
+ * @param {ElementScrollDimension} containerBox - The box of the container element.
224
+ * @param {ElementBoundBox} elementBox - The box of the element to be placed.
225
+ * @param {ElementBoundBox} targetBox - The box of the target element.
226
+ * @param {PlacementType[]} placements - The placements that we want to try.
227
+ * @returns {PlacementType} A function that takes in a containerBox, elementBox, targetBox, placements, and element.
228
+ */
229
+ getSuitablePlacement(containerBox, elementBox, targetBox, placements) {
230
+ const defaultPlacement = placements[0];
231
+ const suitablePlacement = placements.find((placement) => this.hasEnoughSpace(containerBox, placement, targetBox, elementBox));
232
+ if (suitablePlacement) {
233
+ return suitablePlacement;
234
+ }
235
+ else {
236
+ LogUtility.warn(`
237
+ No enough space found for placing element and we will keep using the defined placement:
238
+ ${defaultPlacement}
239
+ `);
240
+ return defaultPlacement;
241
+ }
242
+ }
243
+ /**
244
+ * It takes a list of alignments and returns the suitable one that has enough space to fit the element
245
+ *
246
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
247
+ * @param {ElementBoundBox} elementBox - The box of the element that we want to position.
248
+ * @param {ElementBoundBox} targetBox - The box of the element that the element to be positioned is aligned to.
249
+ * @param {PlacementType} placement - The placement of the element relative to the target.
250
+ * @param {PositionAlignmentType[]} alignments - An array of alignments to try.
251
+ * @returns {PositionAlignmentType} the alignment that is suitable for the element.
252
+ */
253
+ getSuitableAlignment(containerBox, elementBox, targetBox, placement, alignments) {
254
+ const defaultAlignment = alignments[0];
255
+ const suitableAlignment = alignments.find((alignment) => this.hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment));
256
+ if (suitableAlignment) {
257
+ return suitableAlignment;
258
+ }
259
+ else {
260
+ LogUtility.warn(`
261
+ No enough space found for placing element and we will keep using the defined alignment:
262
+ ${defaultAlignment}
263
+ `);
264
+ return defaultAlignment;
265
+ }
266
+ }
267
+ /**
268
+ * Whether the alignment space is enough
269
+ *
270
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
271
+ * @param {ElementBoundBox} targetBox - The position of the target element.
272
+ * @param {ElementBoundBox} elementBox - The box of the element that we're trying to position.
273
+ * @param {PlacementType} placement - The placement of the element relative to the target.
274
+ * @param {PlacementType} alignment - The alignment of the element relative to the target.
275
+ * @returns {boolean} return true if it has enough space, otherwise false
276
+ */
277
+ hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment) {
278
+ if (['top', 'bottom'].includes(placement)) {
279
+ switch (alignment) {
280
+ case 'start': {
281
+ return targetBox.left + elementBox.width <= containerBox.width;
282
+ }
283
+ case 'center': {
284
+ return (targetBox.left >= (elementBox.width - targetBox.width) / 2 &&
285
+ targetBox.left + targetBox.width / 2 + elementBox.width / 2 <= containerBox.width);
286
+ }
287
+ case 'end': {
288
+ return targetBox.left + targetBox.width >= elementBox.width;
289
+ }
290
+ }
291
+ }
292
+ if (['right', 'left'].includes(placement)) {
293
+ switch (alignment) {
294
+ case 'start': {
295
+ return targetBox.top + elementBox.height <= containerBox.height;
296
+ }
297
+ case 'center': {
298
+ return (targetBox.top >= (elementBox.height - targetBox.height) / 2 &&
299
+ targetBox.top + targetBox.height / 2 + elementBox.height / 2 <= containerBox.height);
300
+ }
301
+ case 'end': {
302
+ return targetBox.top + targetBox.height >= elementBox.height;
303
+ }
304
+ }
305
+ }
306
+ /* istanbul ignore next */
307
+ return false;
308
+ }
309
+ /**
310
+ * If the placement is top or left, then the target's top or left position must be greater than or
311
+ * equal to the element's height or width. If the placement is bottom or right, then the container's
312
+ * height or width minus the target's top or left position minus the target's height or width must be
313
+ * greater than or equal to the element's height or width.
314
+ *
315
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
316
+ * @param {PlacementType} placement - The placement of the element.
317
+ * @param {ElementBoundBox} targetBox - The position of the target element.
318
+ * @param {ElementBoundBox} elementBox - The dimensions of the element to be positioned.
319
+ * @returns {boolean} A boolean value.
320
+ */
321
+ hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
322
+ switch (placement) {
323
+ case 'top':
324
+ return targetBox.top >= elementBox.height;
325
+ case 'bottom':
326
+ return containerBox.height - targetBox.top - targetBox.height >= elementBox.height;
327
+ case 'left':
328
+ return targetBox.left >= elementBox.width;
329
+ case 'right':
330
+ return containerBox.width - targetBox.left - targetBox.width >= elementBox.width;
331
+ /* istanbul ignore next */
332
+ default:
333
+ return false;
334
+ }
335
+ }
336
+ /**
337
+ * Retrieves and formats the translocation.
338
+ *
339
+ * @returns {TranslocationType} current translocation.
340
+ */
341
+ getTranslocation() {
342
+ const translocation = this.showConfig.translocation;
343
+ return translocation && ResponsiveFormatFacade.format(translocation, 'translocation');
344
+ }
345
+ }
@@ -0,0 +1,66 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LogUtility } from '../../../utils/log';
8
+ import { BasePositionCalculationStrategy } from './base-position-calculation-strategy';
9
+ import { MapToComponentField } from 'vega-slimmer/core';
10
+ /**
11
+ * calculate position by body container
12
+ */
13
+ export class BodyPositionCalculationStrategy extends BasePositionCalculationStrategy {
14
+ /**
15
+ * Get the position of the element in the container according to the target element and the placement
16
+ * If give a translocation, it will apply the translocation to the result.
17
+ * Note: If you use this method to calculate the position, you should make container as relative position at first.
18
+ *
19
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
20
+ * returns an ElementPositionBox.
21
+ */
22
+ getPosition() {
23
+ const containerStyle = window.getComputedStyle(this.container);
24
+ if (containerStyle.position !== 'relative') {
25
+ LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
26
+ }
27
+ return this.getPositionBox();
28
+ }
29
+ /**
30
+ * It returns the position of an element relative to its container and also includes the scroll height of container.
31
+ *
32
+ * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
33
+ */
34
+ getTargetBoundBox() {
35
+ const containerRect = this.container.getBoundingClientRect();
36
+ const targetRect = this.showConfig.target.getBoundingClientRect();
37
+ const targetTop = targetRect.top - containerRect.top + this.container.scrollTop;
38
+ const targetLeft = targetRect.left - containerRect.left + this.container.scrollLeft;
39
+ return {
40
+ width: targetRect.width,
41
+ height: targetRect.height,
42
+ top: targetTop,
43
+ left: targetLeft,
44
+ };
45
+ }
46
+ /**
47
+ * "Get the width and height of an element."
48
+ *
49
+ * The function takes a single parameter, a container element, and returns an object with two
50
+ * properties: width and height
51
+ *
52
+ * @returns {ElementScrollDimension} An object with two properties: width and height.
53
+ */
54
+ getElementScrollDimension() {
55
+ return {
56
+ width: this.container.scrollWidth,
57
+ height: this.container.scrollHeight,
58
+ };
59
+ }
60
+ }
61
+ __decorate([
62
+ MapToComponentField()
63
+ ], BodyPositionCalculationStrategy.prototype, "container", void 0);
64
+ __decorate([
65
+ MapToComponentField()
66
+ ], BodyPositionCalculationStrategy.prototype, "showConfig", void 0);
@@ -0,0 +1,121 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ 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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { InjectVegaSlimmer, MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
8
+ import { BodyPositionCalculationStrategy } from './body-position-calculation-strategy';
9
+ import { ScreenPositionCalculationStrategy } from './screen-position-calculation-strategy';
10
+ import ResponsiveFormatFacade from '../../formatter/responsive-map-formatter/responsive-format-facade';
11
+ /**
12
+ * Calculation and adjustment of positions for appendable elements based on target element positions.
13
+ */
14
+ export class PositionCalculationController extends VegaSlimmer {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.bodyPositionStrategy = new BodyPositionCalculationStrategy();
18
+ this.screenPositionStrategy = new ScreenPositionCalculationStrategy();
19
+ }
20
+ /**
21
+ * Sets the calculate postion strategy.
22
+ */
23
+ setCalculationStrategy() {
24
+ this.positionStrategy = this.showConfig.isScreenPosition
25
+ ? this.screenPositionStrategy
26
+ : this.bodyPositionStrategy;
27
+ }
28
+ /**
29
+ * Calculates the position and applies it to the appendable element.
30
+ *
31
+ * @param {boolean} [usePreviousPlacement] - Should keep use previous placement and alignment.
32
+ */
33
+ adjustPosition(usePreviousPlacement) {
34
+ this.adjustWidth();
35
+ this.adjustHeight();
36
+ this.applyPosition(this.positionStrategy.getPosition(usePreviousPlacement));
37
+ }
38
+ /**
39
+ * Apply the position to the appendable element.
40
+ *
41
+ * @param {ElementPositionBox} positionBox - position box
42
+ */
43
+ applyPosition(positionBox) {
44
+ const appendableElement = this.showConfig.appendableElement;
45
+ if (this.showConfig.isScreenPosition) {
46
+ appendableElement.style.position = 'fixed';
47
+ }
48
+ appendableElement.style.left = `${positionBox.left}px`;
49
+ appendableElement.style.top = `${positionBox.top}px`;
50
+ appendableElement.classList.remove('vega-placement-left', 'vega-placement-right', 'vega-placement-top', 'vega-placement-bottom');
51
+ appendableElement.classList.remove('vega-alignment-start', 'vega-alignment-center', 'vega-alignment-end');
52
+ appendableElement.classList.add(`vega-placement-${positionBox.placement}`);
53
+ appendableElement.classList.add(`vega-alignment-${positionBox.alignment}`);
54
+ }
55
+ /**
56
+ * It sets the width of the appendable element to the width of the target element if the
57
+ * matchTargetWidth property is true, otherwise it sets the width of the appendable element to the
58
+ * size property
59
+ *
60
+ * @returns {void}
61
+ */
62
+ adjustWidth() {
63
+ if (this.showConfig.matchTargetWidth) {
64
+ const { width: hostWidth } = this.showConfig.target.getBoundingClientRect();
65
+ this.setRelatedWidth('width', hostWidth);
66
+ }
67
+ else {
68
+ this.setRelatedWidth('width', this.showConfig.size);
69
+ this.setRelatedWidth('minWidth', this.showConfig.minWidth);
70
+ this.setRelatedWidth('maxWidth', this.showConfig.maxWidth);
71
+ }
72
+ }
73
+ /**
74
+ * It takes a name and a value, formats the value, and then sets the style of the element
75
+ *
76
+ * @param {'width' | 'maxWidth' | 'minWidth'} name - 'width' | 'maxWidth' | 'minWidth'
77
+ * @param {ResponsiveType<SizeType>} value - ResponsiveType<SizeType>
78
+ * @returns {void}
79
+ */
80
+ setRelatedWidth(name, value) {
81
+ if (!value)
82
+ return;
83
+ const formattedValue = ResponsiveFormatFacade.format(value, 'size');
84
+ if (formattedValue) {
85
+ this.showConfig.appendableElement.style[name] =
86
+ typeof formattedValue === 'number' ? `${formattedValue}px` : formattedValue;
87
+ }
88
+ }
89
+ /**
90
+ * > If the `matchContainerHeight` property is set to `true`, then the maximum height of the dropdown
91
+ * is set to the height of the container minus the height of the target minus the top offset of the
92
+ * target
93
+ *
94
+ * @returns {void}
95
+ */
96
+ adjustHeight() {
97
+ if (this.showConfig.matchContainerHeight) {
98
+ const { height: targetHeight } = this.showConfig.target.getBoundingClientRect();
99
+ let maxHeight = this.container.scrollHeight - this.showConfig.target.offsetTop - targetHeight;
100
+ if (this.showConfig.maxHeight) {
101
+ maxHeight = Math.min(maxHeight, this.showConfig.maxHeight);
102
+ }
103
+ this.showConfig.appendableElement.style.maxHeight = `${maxHeight}px`;
104
+ }
105
+ else if (this.showConfig.maxHeight) {
106
+ this.showConfig.appendableElement.style.maxHeight = `${this.showConfig.maxHeight}px`;
107
+ }
108
+ }
109
+ }
110
+ __decorate([
111
+ MapToComponentField()
112
+ ], PositionCalculationController.prototype, "container", void 0);
113
+ __decorate([
114
+ MapToComponentField()
115
+ ], PositionCalculationController.prototype, "showConfig", void 0);
116
+ __decorate([
117
+ InjectVegaSlimmer()
118
+ ], PositionCalculationController.prototype, "bodyPositionStrategy", void 0);
119
+ __decorate([
120
+ InjectVegaSlimmer()
121
+ ], PositionCalculationController.prototype, "screenPositionStrategy", void 0);