@globalpayments/vega 2.28.1 → 2.30.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 (431) hide show
  1. package/dist/cjs/{app-globals-512d84f4.js → app-globals-391d9a14.js} +9 -8
  2. package/dist/cjs/{array-6e559cde.js → array-5adef7b2.js} +13 -1
  3. package/dist/cjs/{child-nodes-event-prevent-slimmer-e383a914.js → child-nodes-event-prevent-slimmer-bed95a1b.js} +2 -2
  4. package/dist/cjs/{create-public-api-runtime-metrics-slimmer-7510221b.js → create-public-api-runtime-metrics-slimmer-5cc88124.js} +1 -0
  5. package/dist/cjs/{design-token-17b8e4d8.js → design-token-92906579.js} +1 -1
  6. package/dist/cjs/{element-appender-slimmer-bf5ecbd8.js → element-appender-slimmer-415d261a.js} +726 -537
  7. package/dist/cjs/{event-emit-slimmer-8f51adaa.js → event-emit-slimmer-b321e3f5.js} +1 -1
  8. package/dist/cjs/{feature-flag-controller-078da332.js → feature-flag-controller-f0619cc7.js} +5 -0
  9. package/dist/cjs/{form-field-controller-slimmer-223f8ee3.js → form-field-controller-slimmer-a4231b97.js} +6 -6
  10. package/dist/cjs/{icon-manager-5a2b67cf.js → icon-manager-3787af39.js} +1 -1
  11. package/dist/cjs/index-09acd3c9.js +8 -0
  12. package/dist/cjs/index-d6bf3435.js +15 -0
  13. package/dist/cjs/index.cjs.js +16 -15
  14. package/dist/cjs/{internal-icon-manager-858baff1.js → internal-icon-manager-2ff58050.js} +1 -1
  15. package/dist/cjs/{internal-vega-event-manager-627b1328.js → internal-vega-event-manager-9ffb3ed1.js} +13 -3
  16. package/dist/cjs/{internal-vega-z-index-manager-23051df4.js → internal-vega-z-index-manager-f03ddb37.js} +1 -1
  17. package/dist/cjs/{legend-input-processor-6ab8782a.js → legend-input-processor-d0b3f621.js} +1 -1
  18. package/dist/cjs/loader.cjs.js +15 -14
  19. package/dist/cjs/{min-number-rule-84f21ad9.js → min-number-rule-115c5a3b.js} +1 -1
  20. package/dist/cjs/{mutation-observer-filters-79b60f28.js → mutation-observer-filters-e5a7f85a.js} +1 -1
  21. package/dist/cjs/{number-459031f7.js → number-4816603d.js} +11 -0
  22. package/dist/cjs/{responsive-format-facade-7bc51a43.js → responsive-format-facade-ad2f67bf.js} +1 -1
  23. package/dist/cjs/{static-subject-title-3599787e.js → static-subject-title-471e1793.js} +2 -0
  24. package/dist/cjs/{style-formatter-a0829641.js → style-formatter-68f3a5f8.js} +1 -1
  25. package/dist/cjs/sub-state-notify-slimmer-c729699e.js +81 -0
  26. package/dist/cjs/{sub-state-observer-slimmer-36660092.js → sub-state-observer-slimmer-c1332b19.js} +3 -73
  27. package/dist/cjs/{translation-0dd74433.js → translation-42c1b2c8.js} +2 -2
  28. package/dist/cjs/{translation-slimmer-83577cfd.js → translation-slimmer-32aa13e7.js} +1 -1
  29. package/dist/cjs/{valid-credit-card-number-rule-8d8f04f1.js → valid-credit-card-number-rule-4a9ae5d9.js} +1 -1
  30. package/dist/cjs/vega-accordion.cjs.entry.js +10 -10
  31. package/dist/cjs/vega-app-header-button.cjs.entry.js +11 -11
  32. package/dist/cjs/vega-banner.cjs.entry.js +7 -7
  33. package/dist/cjs/vega-bar-chart.cjs.entry.js +4 -4
  34. package/dist/cjs/vega-box.cjs.entry.js +4 -4
  35. package/dist/cjs/vega-breadcrumb.cjs.entry.js +5 -5
  36. package/dist/cjs/vega-button-circle.cjs.entry.js +9 -9
  37. package/dist/cjs/vega-button-group_2.cjs.entry.js +11 -10
  38. package/dist/cjs/vega-button-link.cjs.entry.js +5 -5
  39. package/dist/cjs/vega-button.cjs.entry.js +8 -8
  40. package/dist/cjs/vega-calendar_3.cjs.entry.js +18 -17
  41. package/dist/cjs/vega-card.cjs.entry.js +3 -3
  42. package/dist/cjs/vega-carousel.cjs.entry.js +5 -5
  43. package/dist/cjs/vega-checkbox_2.cjs.entry.js +13 -13
  44. package/dist/cjs/vega-chip.cjs.entry.js +8 -8
  45. package/dist/cjs/vega-color-picker.cjs.entry.js +19 -13
  46. package/dist/cjs/vega-combo-box.cjs.entry.js +367 -183
  47. package/dist/cjs/vega-date-picker_2.cjs.entry.js +23 -20
  48. package/dist/cjs/{vega-dialog-controller-6a8525b3.js → vega-dialog-controller-dce8cdaf.js} +1 -1
  49. package/dist/cjs/vega-dialog_2.cjs.entry.js +9 -9
  50. package/dist/cjs/vega-divider.cjs.entry.js +3 -3
  51. package/dist/cjs/vega-dropdown_5.cjs.entry.js +47 -32
  52. package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
  53. package/dist/cjs/{vega-event-id-e40ac8f0.js → vega-event-id-419d36a8.js} +2 -0
  54. package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
  55. package/dist/cjs/vega-field-label.cjs.entry.js +3 -3
  56. package/dist/cjs/vega-file-uploader.cjs.entry.js +14 -14
  57. package/dist/cjs/vega-flex.cjs.entry.js +5 -5
  58. package/dist/cjs/vega-font.cjs.entry.js +3 -3
  59. package/dist/cjs/vega-form.cjs.entry.js +13 -13
  60. package/dist/cjs/vega-grid.cjs.entry.js +3 -3
  61. package/dist/cjs/vega-icon.cjs.entry.js +5 -5
  62. package/dist/cjs/vega-image-uploader.cjs.entry.js +16 -16
  63. package/dist/cjs/vega-input-credit-card.cjs.entry.js +16 -16
  64. package/dist/cjs/vega-input-numeric.cjs.entry.js +410 -0
  65. package/dist/cjs/vega-input-phone-number.cjs.entry.js +15 -15
  66. package/dist/cjs/vega-input-range.cjs.entry.js +14 -14
  67. package/dist/cjs/vega-input-select.cjs.entry.js +30 -18
  68. package/dist/cjs/vega-input.cjs.entry.js +218 -25
  69. package/dist/cjs/{vega-internal-event-id-c98e9a7d.js → vega-internal-event-id-99cc22e1.js} +2 -0
  70. package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
  71. package/dist/cjs/vega-left-nav_5.cjs.entry.js +13 -13
  72. package/dist/cjs/vega-line-chart.cjs.entry.js +4 -4
  73. package/dist/cjs/vega-loader-wrapper_2.cjs.entry.js +2 -2
  74. package/dist/cjs/vega-page-notification_2.cjs.entry.js +1 -1
  75. package/dist/cjs/vega-pagination.cjs.entry.js +12 -12
  76. package/dist/cjs/vega-pie-chart.cjs.entry.js +3 -3
  77. package/dist/cjs/vega-popover_2.cjs.entry.js +9 -9
  78. package/dist/cjs/vega-progress-tracker.cjs.entry.js +4 -4
  79. package/dist/cjs/vega-radio_2.cjs.entry.js +13 -13
  80. package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
  81. package/dist/cjs/vega-selection-chip_2.cjs.entry.js +19 -18
  82. package/dist/cjs/vega-selection-tile_2.cjs.entry.js +18 -17
  83. package/dist/cjs/vega-sidenav_3.cjs.entry.js +1006 -0
  84. package/dist/cjs/vega-signature-capture.cjs.entry.js +16 -16
  85. package/dist/cjs/{vega-skeleton-loader-controller-e886dc58.js → vega-skeleton-loader-controller-4a016b04.js} +4 -14
  86. package/dist/cjs/vega-stepper.cjs.entry.js +14 -14
  87. package/dist/cjs/vega-tab-group_2.cjs.entry.js +6 -6
  88. package/dist/cjs/vega-table_8.cjs.entry.js +29 -28
  89. package/dist/cjs/vega-textarea.cjs.entry.js +13 -13
  90. package/dist/cjs/vega-time-picker_2.cjs.entry.js +17 -17
  91. package/dist/cjs/vega-toggle-switch.cjs.entry.js +11 -11
  92. package/dist/cjs/vega-tooltip_2.cjs.entry.js +7 -7
  93. package/dist/cjs/vega.cjs.js +15 -14
  94. package/dist/cjs/{y-axis-input-processor-cc6e9196.js → y-axis-input-processor-a0df5e74.js} +2 -2
  95. package/dist/collection/collection-manifest.json +16 -0
  96. package/dist/collection/components/vega-color-picker/vega-color-picker.css +8 -8
  97. package/dist/collection/components/vega-color-picker/vega-color-picker.js +30 -3
  98. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-keyboard-controller.js +114 -0
  99. package/dist/collection/components/vega-combo-box/slimmers/controllers/vega-combo-box-value-controller.js +23 -0
  100. package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.js +147 -0
  101. package/dist/collection/components/vega-combo-box/slimmers/renderers/vega-combo-box-renderer.js +50 -0
  102. package/dist/collection/components/vega-combo-box/vega-combo-box.js +30 -177
  103. package/dist/collection/components/vega-date-picker/slimmers/controllers/vega-date-picker-element-appender-controller.js +2 -0
  104. package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-search-renderer.js +19 -5
  105. package/dist/collection/components/vega-dropdown/vega-dropdown.js +55 -9
  106. package/dist/collection/components/vega-input/slimmers/controllers/vega-input-compact-width-controller.js +118 -0
  107. package/dist/collection/components/vega-input/slimmers/controllers/vega-input-state-controller.js +46 -0
  108. package/dist/collection/components/vega-input/vega-input.css +104 -0
  109. package/dist/collection/components/vega-input/vega-input.js +44 -2
  110. package/dist/collection/components/vega-input-numeric/slimmers/controllers/vega-input-numeric-keyboard-controller.js +79 -0
  111. package/dist/collection/components/vega-input-numeric/slimmers/controllers/vega-input-numeric-value-controller.js +45 -0
  112. package/dist/collection/components/vega-input-numeric/slimmers/renderers/vega-input-numeric-renderer.js +72 -0
  113. package/dist/collection/components/vega-input-numeric/vega-input-numeric.css +9 -0
  114. package/dist/collection/components/vega-input-numeric/vega-input-numeric.js +606 -0
  115. package/dist/collection/components/vega-input-select/slimmers/controllers/vega-input-select-dropdown-controller.js +7 -1
  116. package/dist/collection/components/vega-input-select/vega-input-select.js +55 -2
  117. package/dist/collection/components/vega-sidenav/icons/chevron-right.js +4 -0
  118. package/dist/collection/components/vega-sidenav/icons/toggle-button-bg.js +3 -0
  119. package/dist/collection/components/vega-sidenav/slimmers/controllers/vega-sidenav-backdrop-controller.js +101 -0
  120. package/dist/collection/components/vega-sidenav/slimmers/controllers/vega-sidenav-open-status-controller.js +316 -0
  121. package/dist/collection/components/vega-sidenav/slimmers/renderers/vega-sidenav-collapse-button-renderer.js +79 -0
  122. package/dist/collection/components/vega-sidenav/test/test.helper.js +68 -0
  123. package/dist/collection/components/vega-sidenav/utils/index.js +9 -0
  124. package/dist/collection/components/vega-sidenav/vega-sidenav-group/slimmers/controllers/vega-sidenav-group-sub-state-controller.js +28 -0
  125. package/dist/collection/components/vega-sidenav/vega-sidenav-group/vega-sidenav-group.css +172 -0
  126. package/dist/collection/components/vega-sidenav/vega-sidenav-group/vega-sidenav-group.js +152 -0
  127. package/dist/collection/components/vega-sidenav/vega-sidenav-link/slimmers/controllers/vega-sidenav-link-sub-state.controller.js +28 -0
  128. package/dist/collection/components/vega-sidenav/vega-sidenav-link/vega-sidenav-link.css +136 -0
  129. package/dist/collection/components/vega-sidenav/vega-sidenav-link/vega-sidenav-link.js +264 -0
  130. package/dist/collection/components/vega-sidenav/vega-sidenav.css +300 -0
  131. package/dist/collection/components/vega-sidenav/vega-sidenav.js +422 -0
  132. package/dist/collection/constants/ui.js +1 -0
  133. package/dist/collection/helpers/event-manager/event-id/component-event-id-map.js +13 -3
  134. package/dist/collection/helpers/event-manager/event-id/vega-event-id.js +1 -0
  135. package/dist/collection/helpers/event-manager/event-id/vega-internal-event-id.js +1 -0
  136. package/dist/collection/helpers/event-manager/test/vega-event-manager.test.js +2 -1
  137. package/dist/collection/helpers/feature-control/feature-flags-map.js +5 -0
  138. package/dist/collection/helpers/slimmers/element-appender-container/body-positioned-wrapper/body-positioned-wrapper.abstract.js +13 -0
  139. package/dist/collection/helpers/slimmers/element-appender-container/{position-relative-to-wrapper.js → body-positioned-wrapper/position-relative-to-wrapper.js} +23 -21
  140. package/dist/collection/helpers/slimmers/element-appender-container/{vega-modal-wrapper.js → body-positioned-wrapper/vega-modal-wrapper.js} +18 -15
  141. package/dist/collection/helpers/slimmers/element-appender-container/{vega-popover-wrapper.js → body-positioned-wrapper/vega-popover-wrapper.js} +20 -19
  142. package/dist/collection/helpers/slimmers/element-appender-container/default-wrapper.js +19 -19
  143. package/dist/collection/helpers/slimmers/element-appender-container/element-appender-container-controller.js +3 -3
  144. package/dist/collection/helpers/slimmers/element-appender-slimmer.js +10 -0
  145. package/dist/collection/helpers/slimmers/position-calculation/base-position-calculation-strategy.js +345 -0
  146. package/dist/collection/helpers/slimmers/position-calculation/body-position-calculation-strategy.js +66 -0
  147. package/dist/collection/helpers/slimmers/position-calculation/position-calculation-controller.js +121 -0
  148. package/dist/collection/helpers/slimmers/position-calculation/screen-position-calculation-strategy.js +59 -0
  149. package/dist/collection/{utils/test/position.test.js → helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.js} +135 -45
  150. package/dist/collection/helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.js +113 -0
  151. package/dist/collection/helpers/slimmers/sub-state/sub-state-notify-slimmer.js +8 -5
  152. package/dist/collection/helpers/slimmers/sub-state/test/sub-state-observer-slimmer.test.js +24 -0
  153. package/dist/collection/helpers/ui/element-appender.js +21 -70
  154. package/dist/collection/helpers/ui/test/element-appender.test.js +53 -0
  155. package/dist/collection/utils/number.js +10 -0
  156. package/dist/collection/utils/pagination.js +2 -2
  157. package/dist/collection/utils/test/number.test.js +5 -1
  158. package/dist/collection/value-model-adapters/angular-ng-model-accessor-adapter.js +1 -0
  159. package/dist/collection/value-model-adapters/vue-component-v-model-adaptor.js +1 -0
  160. package/dist/esm/{app-globals-41797af8.js → app-globals-00a57fbe.js} +8 -7
  161. package/dist/esm/{array-506b88b9.js → array-b668466e.js} +13 -2
  162. package/dist/esm/{child-nodes-event-prevent-slimmer-345c46c5.js → child-nodes-event-prevent-slimmer-db288af1.js} +2 -2
  163. package/dist/esm/{create-public-api-runtime-metrics-slimmer-928ad7f0.js → create-public-api-runtime-metrics-slimmer-cc1164bb.js} +1 -1
  164. package/dist/esm/{design-token-3671ce60.js → design-token-2a527af3.js} +1 -1
  165. package/dist/esm/{element-appender-slimmer-1172e2ea.js → element-appender-slimmer-48d826b2.js} +720 -531
  166. package/dist/esm/{event-emit-slimmer-eee9fd41.js → event-emit-slimmer-44cb4573.js} +1 -1
  167. package/dist/esm/{feature-flag-controller-10780eeb.js → feature-flag-controller-297c4b9b.js} +5 -0
  168. package/dist/esm/{form-field-controller-slimmer-edbaaf7c.js → form-field-controller-slimmer-a64c679c.js} +6 -6
  169. package/dist/esm/{icon-manager-0f030f8a.js → icon-manager-1ee2c968.js} +1 -1
  170. package/dist/esm/index-187f71d1.js +8 -0
  171. package/dist/esm/index-fda6b5ee.js +13 -0
  172. package/dist/esm/index.js +15 -14
  173. package/dist/esm/{internal-icon-manager-9671142a.js → internal-icon-manager-7004584d.js} +1 -1
  174. package/dist/esm/{internal-vega-event-manager-722461c1.js → internal-vega-event-manager-8154661e.js} +13 -3
  175. package/dist/esm/{internal-vega-z-index-manager-0553458e.js → internal-vega-z-index-manager-7d2b54c3.js} +1 -1
  176. package/dist/esm/{legend-input-processor-abb0b4f4.js → legend-input-processor-0cef3ebe.js} +1 -1
  177. package/dist/esm/loader.js +15 -14
  178. package/dist/esm/{min-number-rule-8f643dbd.js → min-number-rule-31d48b22.js} +1 -1
  179. package/dist/esm/{mutation-observer-filters-9086b5cc.js → mutation-observer-filters-1035b064.js} +1 -1
  180. package/dist/esm/{number-e2519d1c.js → number-4398f2e1.js} +11 -1
  181. package/dist/esm/{responsive-format-facade-5a1329a7.js → responsive-format-facade-3dc84e41.js} +1 -1
  182. package/dist/esm/{static-subject-title-6987a80b.js → static-subject-title-500cf2a3.js} +2 -1
  183. package/dist/esm/{style-formatter-2fa5ce09.js → style-formatter-ccb2da0d.js} +1 -1
  184. package/dist/esm/sub-state-notify-slimmer-be5bcc4e.js +79 -0
  185. package/dist/esm/{sub-state-observer-slimmer-8eff5559.js → sub-state-observer-slimmer-cd7adab1.js} +5 -74
  186. package/dist/esm/{translation-0fa7cf77.js → translation-4eb3cf85.js} +2 -2
  187. package/dist/esm/{translation-slimmer-79f9a9c9.js → translation-slimmer-9d07a0ff.js} +1 -1
  188. package/dist/esm/{valid-credit-card-number-rule-232f2986.js → valid-credit-card-number-rule-2aef3ad5.js} +1 -1
  189. package/dist/esm/vega-accordion.entry.js +10 -10
  190. package/dist/esm/vega-app-header-button.entry.js +11 -11
  191. package/dist/esm/vega-banner.entry.js +7 -7
  192. package/dist/esm/vega-bar-chart.entry.js +4 -4
  193. package/dist/esm/vega-box.entry.js +4 -4
  194. package/dist/esm/vega-breadcrumb.entry.js +5 -5
  195. package/dist/esm/vega-button-circle.entry.js +9 -9
  196. package/dist/esm/vega-button-group_2.entry.js +8 -7
  197. package/dist/esm/vega-button-link.entry.js +5 -5
  198. package/dist/esm/vega-button.entry.js +8 -8
  199. package/dist/esm/vega-calendar_3.entry.js +16 -15
  200. package/dist/esm/vega-card.entry.js +3 -3
  201. package/dist/esm/vega-carousel.entry.js +5 -5
  202. package/dist/esm/vega-checkbox_2.entry.js +13 -13
  203. package/dist/esm/vega-chip.entry.js +8 -8
  204. package/dist/esm/vega-color-picker.entry.js +20 -14
  205. package/dist/esm/vega-combo-box.entry.js +370 -186
  206. package/dist/esm/vega-date-picker_2.entry.js +23 -20
  207. package/dist/esm/{vega-dialog-controller-3b905672.js → vega-dialog-controller-8b343a17.js} +1 -1
  208. package/dist/esm/vega-dialog_2.entry.js +9 -9
  209. package/dist/esm/vega-divider.entry.js +3 -3
  210. package/dist/esm/vega-dropdown_5.entry.js +43 -28
  211. package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
  212. package/dist/esm/{vega-event-id-7465a011.js → vega-event-id-b1655cbc.js} +2 -1
  213. package/dist/esm/vega-field-error.entry.js +1 -1
  214. package/dist/esm/vega-field-label.entry.js +3 -3
  215. package/dist/esm/vega-file-uploader.entry.js +14 -14
  216. package/dist/esm/vega-flex.entry.js +5 -5
  217. package/dist/esm/vega-font.entry.js +3 -3
  218. package/dist/esm/vega-form.entry.js +13 -13
  219. package/dist/esm/vega-grid.entry.js +3 -3
  220. package/dist/esm/vega-icon.entry.js +5 -5
  221. package/dist/esm/vega-image-uploader.entry.js +16 -16
  222. package/dist/esm/vega-input-credit-card.entry.js +16 -16
  223. package/dist/esm/vega-input-numeric.entry.js +406 -0
  224. package/dist/esm/vega-input-phone-number.entry.js +15 -15
  225. package/dist/esm/vega-input-range.entry.js +14 -14
  226. package/dist/esm/vega-input-select.entry.js +30 -18
  227. package/dist/esm/vega-input.entry.js +219 -26
  228. package/dist/esm/{vega-internal-event-id-7e05cf4a.js → vega-internal-event-id-c8507b85.js} +2 -1
  229. package/dist/esm/vega-item-toggle.entry.js +3 -3
  230. package/dist/esm/vega-left-nav_5.entry.js +13 -13
  231. package/dist/esm/vega-line-chart.entry.js +4 -4
  232. package/dist/esm/vega-loader-wrapper_2.entry.js +2 -2
  233. package/dist/esm/vega-page-notification_2.entry.js +1 -1
  234. package/dist/esm/vega-pagination.entry.js +12 -12
  235. package/dist/esm/vega-pie-chart.entry.js +3 -3
  236. package/dist/esm/vega-popover_2.entry.js +9 -9
  237. package/dist/esm/vega-progress-tracker.entry.js +4 -4
  238. package/dist/esm/vega-radio_2.entry.js +13 -13
  239. package/dist/esm/vega-segment-control.entry.js +3 -3
  240. package/dist/esm/vega-selection-chip_2.entry.js +16 -15
  241. package/dist/esm/vega-selection-tile_2.entry.js +15 -14
  242. package/dist/esm/vega-sidenav_3.entry.js +1000 -0
  243. package/dist/esm/vega-signature-capture.entry.js +16 -16
  244. package/dist/esm/{vega-skeleton-loader-controller-6fb25f3b.js → vega-skeleton-loader-controller-cec6753f.js} +4 -14
  245. package/dist/esm/vega-stepper.entry.js +14 -14
  246. package/dist/esm/vega-tab-group_2.entry.js +6 -6
  247. package/dist/esm/vega-table_8.entry.js +19 -18
  248. package/dist/esm/vega-textarea.entry.js +13 -13
  249. package/dist/esm/vega-time-picker_2.entry.js +17 -17
  250. package/dist/esm/vega-toggle-switch.entry.js +11 -11
  251. package/dist/esm/vega-tooltip_2.entry.js +7 -7
  252. package/dist/esm/vega.js +15 -14
  253. package/dist/esm/{y-axis-input-processor-08c89594.js → y-axis-input-processor-a4d6aa50.js} +2 -2
  254. package/dist/types/components/vega-color-picker/vega-color-picker.d.ts +6 -0
  255. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-keyboard-controller.d.ts +29 -0
  256. package/dist/types/components/vega-combo-box/slimmers/controllers/vega-combo-box-value-controller.d.ts +14 -0
  257. package/dist/types/components/vega-combo-box/slimmers/renderers/vega-combo-box-dropdown-renderer.d.ts +41 -0
  258. package/dist/types/components/vega-combo-box/slimmers/renderers/vega-combo-box-renderer.d.ts +17 -0
  259. package/dist/types/components/vega-combo-box/vega-combo-box.d.ts +8 -48
  260. package/dist/types/components/vega-dropdown/slimmers/renderers/vega-dropdown-search-renderer.d.ts +1 -0
  261. package/dist/types/components/vega-dropdown/types.d.ts +5 -0
  262. package/dist/types/components/vega-dropdown/vega-dropdown.d.ts +21 -1
  263. package/dist/types/components/vega-input/slimmers/controllers/vega-input-compact-width-controller.d.ts +47 -0
  264. package/dist/types/components/vega-input/slimmers/controllers/vega-input-state-controller.d.ts +13 -0
  265. package/dist/types/components/vega-input/vega-input.d.ts +18 -6
  266. package/dist/types/components/vega-input-numeric/slimmers/controllers/vega-input-numeric-keyboard-controller.d.ts +18 -0
  267. package/dist/types/components/vega-input-numeric/slimmers/controllers/vega-input-numeric-value-controller.d.ts +20 -0
  268. package/dist/types/components/vega-input-numeric/slimmers/renderers/vega-input-numeric-renderer.d.ts +19 -0
  269. package/dist/types/components/vega-input-numeric/vega-input-numeric.d.ts +169 -0
  270. package/dist/types/components/vega-input-select/slimmers/controllers/vega-input-select-dropdown-controller.d.ts +1 -0
  271. package/dist/types/components/vega-input-select/vega-input-select.d.ts +20 -0
  272. package/dist/types/components/vega-sidenav/icons/chevron-right.d.ts +3 -0
  273. package/dist/types/components/vega-sidenav/icons/toggle-button-bg.d.ts +3 -0
  274. package/dist/types/components/vega-sidenav/slimmers/controllers/vega-sidenav-backdrop-controller.d.ts +42 -0
  275. package/dist/types/components/vega-sidenav/slimmers/controllers/vega-sidenav-open-status-controller.d.ts +94 -0
  276. package/dist/types/components/vega-sidenav/slimmers/renderers/vega-sidenav-collapse-button-renderer.d.ts +31 -0
  277. package/dist/types/components/vega-sidenav/test/test.helper.d.ts +6 -0
  278. package/dist/types/components/vega-sidenav/types.d.ts +24 -0
  279. package/dist/types/components/vega-sidenav/utils/index.d.ts +7 -0
  280. package/dist/types/components/vega-sidenav/vega-sidenav-group/slimmers/controllers/vega-sidenav-group-sub-state-controller.d.ts +10 -0
  281. package/dist/types/components/vega-sidenav/vega-sidenav-group/vega-sidenav-group.d.ts +47 -0
  282. package/dist/types/components/vega-sidenav/vega-sidenav-link/slimmers/controllers/vega-sidenav-link-sub-state.controller.d.ts +10 -0
  283. package/dist/types/components/vega-sidenav/vega-sidenav-link/vega-sidenav-link.d.ts +80 -0
  284. package/dist/types/components/vega-sidenav/vega-sidenav.d.ts +137 -0
  285. package/dist/types/components.d.ts +407 -1
  286. package/dist/types/constants/ui.d.ts +1 -1
  287. package/dist/types/helpers/event-manager/event-id/vega-event-id.d.ts +1 -0
  288. package/dist/types/helpers/event-manager/event-id/vega-internal-event-id.d.ts +1 -0
  289. package/dist/types/helpers/feature-control/feature-flag.d.ts +2 -1
  290. package/dist/types/helpers/slimmers/element-appender-container/body-positioned-wrapper/body-positioned-wrapper.abstract.d.ts +15 -0
  291. 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
  292. package/dist/types/helpers/slimmers/element-appender-container/{vega-modal-wrapper.d.ts → body-positioned-wrapper/vega-modal-wrapper.d.ts} +5 -5
  293. package/dist/types/helpers/slimmers/element-appender-container/{vega-popover-wrapper.d.ts → body-positioned-wrapper/vega-popover-wrapper.d.ts} +5 -5
  294. package/dist/types/helpers/slimmers/element-appender-container/default-wrapper.d.ts +2 -2
  295. package/dist/types/helpers/slimmers/element-appender-container/element-appender-container-controller.d.ts +3 -3
  296. package/dist/types/helpers/slimmers/element-appender-slimmer.d.ts +1 -0
  297. package/dist/types/helpers/slimmers/position-calculation/base-position-calculation-strategy.d.ts +138 -0
  298. package/dist/types/helpers/slimmers/position-calculation/body-position-calculation-strategy.d.ts +34 -0
  299. package/dist/types/helpers/slimmers/position-calculation/position-calculation-controller.d.ts +54 -0
  300. package/dist/types/helpers/slimmers/position-calculation/screen-position-calculation-strategy.d.ts +34 -0
  301. package/dist/types/helpers/slimmers/position-calculation/test/body-position-calculation-strategy.test.d.ts +15 -0
  302. package/dist/types/helpers/slimmers/sub-state/sub-state-notify-slimmer.d.ts +1 -1
  303. package/dist/types/helpers/ui/element-appender.d.ts +9 -24
  304. package/dist/types/types/components.type.d.ts +7 -0
  305. package/dist/types/utils/number.d.ts +7 -0
  306. package/dist/vega/index.esm.js +1 -1
  307. package/dist/vega/{p-d4c85e4e.entry.js → p-00c5aee5.entry.js} +1 -1
  308. package/dist/vega/{p-573948c2.js → p-04215e74.js} +1 -1
  309. package/dist/vega/p-042b4b3f.entry.js +1 -0
  310. package/dist/vega/{p-fd929ab5.entry.js → p-07a8cf89.entry.js} +1 -1
  311. package/dist/vega/p-0abe1ade.entry.js +1 -0
  312. package/dist/vega/p-0f0e4198.entry.js +1 -0
  313. package/dist/vega/{p-b86e8c8b.entry.js → p-11786565.entry.js} +1 -1
  314. package/dist/vega/{p-063c3ba6.entry.js → p-14f5a9ad.entry.js} +1 -1
  315. package/dist/vega/p-15023bad.entry.js +1 -0
  316. package/dist/vega/p-1be2fd46.entry.js +1 -0
  317. package/dist/vega/p-1bfcb6b7.entry.js +1 -0
  318. package/dist/vega/p-20d9c07c.entry.js +1 -0
  319. package/dist/vega/p-2306c736.js +1 -0
  320. package/dist/vega/p-262ec334.js +1 -0
  321. package/dist/vega/{p-a5f80d35.js → p-2d5a9f66.js} +1 -1
  322. package/dist/vega/{p-83af8ed7.js → p-302e7589.js} +1 -1
  323. package/dist/vega/p-32f651f7.js +1 -0
  324. package/dist/vega/p-34710a3c.entry.js +1 -0
  325. package/dist/vega/p-3903ce7a.entry.js +1 -0
  326. package/dist/vega/{p-b2053fa8.entry.js → p-4022f395.entry.js} +1 -1
  327. package/dist/vega/{p-51cd2a39.entry.js → p-438caeb3.entry.js} +1 -1
  328. package/dist/vega/{p-1ea57951.js → p-4d25df7d.js} +1 -1
  329. package/dist/vega/{p-319efe6c.js → p-4ffd7493.js} +1 -1
  330. package/dist/vega/p-5440344e.js +1 -0
  331. package/dist/vega/{p-fc746bae.entry.js → p-57d9bde6.entry.js} +1 -1
  332. package/dist/vega/p-5f377954.js +1 -1
  333. package/dist/vega/p-5fbac513.js +1 -0
  334. package/dist/vega/{p-d686dd96.entry.js → p-623fe226.entry.js} +1 -1
  335. package/dist/vega/{p-be26b334.entry.js → p-63bee4f1.entry.js} +1 -1
  336. package/dist/vega/{p-40f6add9.entry.js → p-64ff6318.entry.js} +1 -1
  337. package/dist/vega/{p-9e6934fb.js → p-68ad953c.js} +1 -1
  338. package/dist/vega/{p-7a1df282.entry.js → p-69e63d21.entry.js} +1 -1
  339. package/dist/vega/{p-ac0ab38b.js → p-6a8f1251.js} +1 -1
  340. package/dist/vega/{p-9a4ffc2c.entry.js → p-72ecc510.entry.js} +1 -1
  341. package/dist/vega/{p-a2169994.entry.js → p-7372cd79.entry.js} +1 -1
  342. package/dist/vega/{p-7b40ac07.js → p-74958b1a.js} +1 -1
  343. package/dist/vega/{p-3fc59fd3.entry.js → p-760283d1.entry.js} +1 -1
  344. package/dist/vega/{p-152393dd.js → p-781fd6e0.js} +1 -1
  345. package/dist/vega/p-79019d08.js +1 -0
  346. package/dist/vega/p-7941701a.entry.js +1 -0
  347. package/dist/vega/{p-8fd6775a.entry.js → p-799cb0a4.entry.js} +1 -1
  348. package/dist/vega/{p-34545d2d.entry.js → p-7a6a0740.entry.js} +1 -1
  349. package/dist/vega/{p-a59c221b.entry.js → p-7df3aa44.entry.js} +1 -1
  350. package/dist/vega/p-80785fcf.entry.js +1 -0
  351. package/dist/vega/{p-8c72aa56.entry.js → p-83ef4c13.entry.js} +1 -1
  352. package/dist/vega/{p-1e33c6e3.entry.js → p-87640a4d.entry.js} +1 -1
  353. package/dist/vega/{p-1bbc62ef.entry.js → p-87cd0d6a.entry.js} +1 -1
  354. package/dist/vega/{p-22a85055.entry.js → p-8cfe4027.entry.js} +1 -1
  355. package/dist/vega/{p-056f448c.entry.js → p-9281cdb2.entry.js} +1 -1
  356. package/dist/vega/p-95b25b97.entry.js +1 -0
  357. package/dist/vega/p-9b45e5dc.entry.js +1 -0
  358. package/dist/vega/{p-4bc042ec.entry.js → p-9b9c0afb.entry.js} +1 -1
  359. package/dist/vega/{p-128fbe13.entry.js → p-9ba68531.entry.js} +2 -2
  360. package/dist/vega/{p-be784f53.js → p-9f3b1d77.js} +1 -1
  361. package/dist/vega/p-a66ea015.entry.js +1 -0
  362. package/dist/vega/p-a67748c6.entry.js +1 -0
  363. package/dist/vega/{p-33366630.entry.js → p-a6e1d9bc.entry.js} +1 -1
  364. package/dist/vega/{p-38d81bde.js → p-a9354a5c.js} +1 -1
  365. package/dist/vega/p-ab983e7d.js +1 -0
  366. package/dist/vega/p-ae3fd67e.js +1 -0
  367. package/dist/vega/p-b0502d01.js +1 -0
  368. package/dist/vega/{p-8b0533c4.entry.js → p-b1a249ef.entry.js} +1 -1
  369. package/dist/vega/{p-bccacf42.js → p-b347f967.js} +1 -1
  370. package/dist/vega/p-b3e754da.entry.js +1 -0
  371. package/dist/vega/{p-ddc70a7b.js → p-b62f0454.js} +1 -1
  372. package/dist/vega/{p-26d0d411.entry.js → p-b6e49ee9.entry.js} +1 -1
  373. package/dist/vega/{p-a901494d.entry.js → p-bb6f8b70.entry.js} +1 -1
  374. package/dist/vega/{p-456416ea.js → p-bdb94242.js} +1 -1
  375. package/dist/vega/{p-5d231a82.entry.js → p-be6041fc.entry.js} +1 -1
  376. package/dist/vega/{p-0dd750b0.entry.js → p-bf38199b.entry.js} +1 -1
  377. package/dist/vega/p-bf3fbb9b.js +1 -0
  378. package/dist/vega/p-c06e7880.js +1 -0
  379. package/dist/vega/{p-51622ace.entry.js → p-c3c2890e.entry.js} +1 -1
  380. package/dist/vega/{p-6874d6a1.entry.js → p-c6ed1982.entry.js} +1 -1
  381. package/dist/vega/{p-33596687.js → p-c7d70786.js} +1 -1
  382. package/dist/vega/p-cdebfee7.entry.js +1 -0
  383. package/dist/vega/p-cea70476.entry.js +1 -0
  384. package/dist/vega/{p-d550fc66.entry.js → p-d3c07efa.entry.js} +1 -1
  385. package/dist/vega/p-d71f968e.entry.js +1 -0
  386. package/dist/vega/{p-365c340d.entry.js → p-e165c9f1.entry.js} +1 -1
  387. package/dist/vega/{p-5dc98104.js → p-e5d7b4b8.js} +1 -1
  388. package/dist/vega/p-e6f91767.entry.js +1 -0
  389. package/dist/vega/p-e731976a.js +1 -0
  390. package/dist/vega/p-ed237efc.js +1 -0
  391. package/dist/vega/{p-cbeda6ca.entry.js → p-f2685ec5.entry.js} +1 -1
  392. package/dist/vega/{p-115e5967.js → p-f2851f16.js} +1 -1
  393. package/dist/vega/p-f5b0ce61.js +1 -0
  394. package/dist/vega/{p-a57eed48.entry.js → p-f64fb740.entry.js} +1 -1
  395. package/dist/vega/{p-80c0f98c.entry.js → p-fb3233db.entry.js} +1 -1
  396. package/dist/vega/{p-8f60c3ee.entry.js → p-ff22a95f.entry.js} +1 -1
  397. package/dist/vega/vega.esm.js +1 -1
  398. package/package.json +7 -3
  399. package/dist/collection/utils/position.js +0 -373
  400. package/dist/types/utils/position.d.ts +0 -17
  401. package/dist/vega/p-0120ce7a.js +0 -1
  402. package/dist/vega/p-0395e791.entry.js +0 -1
  403. package/dist/vega/p-048a97d1.entry.js +0 -1
  404. package/dist/vega/p-1f38eef6.entry.js +0 -1
  405. package/dist/vega/p-1fc5373a.entry.js +0 -1
  406. package/dist/vega/p-344ee7cb.js +0 -1
  407. package/dist/vega/p-3f5e44c1.js +0 -1
  408. package/dist/vega/p-41784db1.js +0 -1
  409. package/dist/vega/p-6168c1e7.js +0 -1
  410. package/dist/vega/p-64e8bb64.js +0 -1
  411. package/dist/vega/p-657df167.entry.js +0 -1
  412. package/dist/vega/p-68055c2d.entry.js +0 -1
  413. package/dist/vega/p-6d015656.entry.js +0 -1
  414. package/dist/vega/p-6e3cc7f0.entry.js +0 -1
  415. package/dist/vega/p-880f91fb.js +0 -1
  416. package/dist/vega/p-8843226a.entry.js +0 -1
  417. package/dist/vega/p-a10074a8.entry.js +0 -1
  418. package/dist/vega/p-a454acc4.entry.js +0 -1
  419. package/dist/vega/p-a8b1f19c.entry.js +0 -1
  420. package/dist/vega/p-acf8b473.js +0 -1
  421. package/dist/vega/p-d0a83562.entry.js +0 -1
  422. package/dist/vega/p-d4fb2264.entry.js +0 -1
  423. package/dist/vega/p-da86ba01.js +0 -1
  424. package/dist/vega/p-ead1a647.js +0 -1
  425. package/dist/vega/p-ead9a2b9.entry.js +0 -1
  426. package/dist/vega/p-ee68920f.js +0 -1
  427. package/dist/vega/p-f0ad06bd.entry.js +0 -1
  428. package/dist/vega/p-f2019f70.entry.js +0 -1
  429. package/dist/vega/p-f948debe.entry.js +0 -1
  430. package/dist/vega/p-fb6c90d6.js +0 -1
  431. /package/dist/types/{utils/test/position.test.d.ts → helpers/slimmers/position-calculation/test/screen-position-calculation-strategy.test.d.ts} +0 -0
@@ -1,386 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
4
- const ui = require('./ui-32e69595.js');
5
- const typeGuard = require('./type-guard-a07b353b.js');
6
- const responsiveFormatFacade = require('./responsive-format-facade-7bc51a43.js');
7
- const ui$1 = require('./ui-08f33116.js');
8
- const internalVegaZIndexManager = require('./internal-vega-z-index-manager-23051df4.js');
4
+ const ui = require('./ui-08f33116.js');
5
+ const internalVegaZIndexManager = require('./internal-vega-z-index-manager-f03ddb37.js');
9
6
  const dynamicSlimmer = require('./dynamic-slimmer-f31fdfd7.js');
10
7
  const pageResizeObserverSlimmer = require('./page-resize-observer-slimmer-a8cf1874.js');
8
+ const ui$1 = require('./ui-32e69595.js');
9
+ const typeGuard = require('./type-guard-a07b353b.js');
10
+ const responsiveFormatFacade = require('./responsive-format-facade-ad2f67bf.js');
11
11
 
12
- /**
13
- * Get the position of the element in the container according to the target element and the placement
14
- * If give a translocation, it will apply the translocation to the result.
15
- * Note: If you use this method to calculate the position, you should make container as relative position at first.
16
- *
17
- * @param {HTMLElement} container - The container element of the element to be positioned.
18
- * @param {HTMLElement} element - The element to be positioned.
19
- * @param {HTMLElement} target - The element to be positioned.
20
- * @param {PlacementType | PlacementType[]} [placement] - The placement of the element, which can be a
21
- * single placement or an array of placements.
22
- * @param {PositionAlignmentType | PositionAlignmentType[]} alignment - The alignment of the element
23
- * @param {TranslocationType} [translocation] - The offset of the element relative to the target.
24
- * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
25
- * returns an ElementPositionBox.
26
- */
27
- const getPositionBox = (container, element, target, placement, alignment, translocation = { X: 0, Y: 0 }) => {
28
- const containerStyle = window.getComputedStyle(container);
29
- if (containerStyle.position !== 'relative') {
30
- globalSlimmerRegistry.LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
31
- }
32
- const placements = getPlacements(placement);
33
- const alignments = getAlignments(alignment);
34
- const targetBox = getTargetBoundBox(target, container);
35
- const elementBox = getElementBoundBox(element);
36
- const containerBox = getElementScrollDimension(container);
37
- const suitablePlacement = getSuitablePlacement(containerBox, elementBox, targetBox, placements);
38
- const suitableAlignment = getSuitableAlignment(containerBox, elementBox, targetBox, suitablePlacement, alignments);
39
- const positionBox = calculatePosition(elementBox, targetBox, suitablePlacement, suitableAlignment);
40
- const translocationBox = getTranslocationBox(Array.isArray(placement) ? placement[0] : placement, suitablePlacement, translocation);
41
- positionBox.placement = suitablePlacement;
42
- positionBox.alignment = suitableAlignment;
43
- positionBox.left += translocationBox.X;
44
- positionBox.top += translocationBox.Y;
45
- return positionBox;
46
- };
47
- /**
48
- * It returns the translocation of the element relative to the target element
49
- *
50
- * @param {Nullable<PlacementType>} originPlacement - The origin placement of the element.
51
- * @param {PlacementType} placement - The suitable placement of the element.
52
- * @param {TranslocationType} translocation - TranslocationType
53
- * @returns {TranslocationType} A translocation object with X and Y properties.
54
- */
55
- function getTranslocationBox(originPlacement, placement, translocation) {
56
- const result = { X: 0, Y: 0 };
57
- if (typeGuard.isTranslocationType(translocation)) {
58
- let xValue = translocation.X;
59
- let yValue = translocation.Y;
60
- // If originPlacement and placement is not in same axis, it should reverse axis.
61
- if ((originPlacement &&
62
- ['left', 'right'].includes(originPlacement) &&
63
- ['top', 'bottom'].includes(placement)) ||
64
- (originPlacement &&
65
- ['top', 'bottom'].includes(originPlacement) &&
66
- ['left', 'right'].includes(placement))) {
67
- xValue = translocation.Y;
68
- yValue = translocation.X;
69
- }
70
- if (['bottom', 'top'].includes(placement)) {
71
- result.Y = placement === 'top' ? -yValue : yValue;
72
- result.X = xValue;
73
- }
74
- if (['left', 'right'].includes(placement)) {
75
- result.X = placement === 'left' ? -xValue : xValue;
76
- result.Y = yValue;
77
- }
78
- }
79
- return result;
80
- }
81
- /**
82
- * It takes a placement string or array of placements and returns an array of placements
83
- * if given placement is single, we should completion the placements with the default {@link Placements}
84
- * and make given placement as default.
85
- * if given placement is array, we should use it directly, even it partial of {@link Placements}.
86
- * if not placement give. we should use {@link Placements}.
87
- *
88
- * @param {PlacementType | PlacementType[]} [placement] - The placement of the tooltip.
89
- * @returns {PlacementType[]} ordered placements.
90
- */
91
- function getPlacements(placement) {
92
- if (typeof placement === 'string') {
93
- const partial = ui.Placements.filter((direction) => direction !== placement);
94
- return [placement, ...partial];
95
- }
96
- else if (Array.isArray(placement)) {
97
- return placement;
98
- }
99
- else {
100
- return [...ui.Placements];
101
- }
102
- }
103
- /**
104
- * It returns acceptable alignments.
105
- *
106
- * @param {PositionAlignmentType | PositionAlignmentType[]} [alignment] - The alignment of the popup.
107
- * @returns {PositionAlignmentType[]} acceptable alignments
108
- */
109
- function getAlignments(alignment) {
110
- if (typeof alignment === 'string') {
111
- const partial = ui.Alignments.filter((item) => item !== alignment);
112
- return [alignment, ...partial];
113
- }
114
- else if (Array.isArray(alignment)) {
115
- return alignment;
116
- }
117
- else {
118
- return [...ui.Alignments];
119
- }
120
- }
121
- /**
122
- * It takes a placement, a target box, and a element box, and returns an element box
123
- *
124
- * @param {ElementBoundBox} elementBox - The position of the element element.
125
- * @param {ElementBoundBox} targetBox - The position of the target element.
126
- * @param {PlacementType} placement - The placement of the element.
127
- * @param {PositionAlignmentType} alignment - The alignment of the element
128
- * @returns {ElementPositionBox} An object with top and left properties.
129
- */
130
- function calculatePosition(elementBox, targetBox, placement, alignment) {
131
- return {
132
- top: calculateTop(elementBox, targetBox, placement, alignment),
133
- left: calculateLeft(elementBox, targetBox, placement, alignment),
134
- };
135
- }
136
- /**
137
- * Calculate the left position of the element
138
- *
139
- * @param {ElementBoundBox} elementBox - The position box of the element.
140
- * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
141
- * @param {PlacementType} placement - The placement of the element.
142
- * @param {PositionAlignmentType} alignment - The alignment of the element
143
- * @returns {number} The left position of the element.
144
- */
145
- function calculateLeft(elementBox, targetBox, placement, alignment) {
146
- switch (placement) {
147
- case 'top':
148
- case 'bottom': {
149
- if (alignment === 'end') {
150
- return targetBox.left + targetBox.width - elementBox.width;
151
- }
152
- else if (alignment === 'center') {
153
- return targetBox.left - (elementBox.width - targetBox.width) / 2;
154
- }
155
- else {
156
- return targetBox.left;
157
- }
158
- }
159
- case 'left': {
160
- return targetBox.left - elementBox.width;
161
- }
162
- case 'right': {
163
- return targetBox.left + targetBox.width;
164
- }
165
- /* istanbul ignore next */
166
- default:
167
- throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
168
- }
169
- }
170
- /**
171
- * Calculate the top position of the element
172
- *
173
- * @param {ElementBoundBox} elementBox - The position box of the element.
174
- * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
175
- * @param {PlacementType} placement - The placement of the element.
176
- * @param {PositionAlignmentType} alignment - The alignment of the element
177
- * @returns {number} the top position of the element.
178
- */
179
- function calculateTop(elementBox, targetBox, placement, alignment) {
180
- switch (placement) {
181
- case 'left':
182
- case 'right': {
183
- if (alignment === 'end') {
184
- return targetBox.top + targetBox.height - elementBox.height;
185
- }
186
- else if (alignment === 'center') {
187
- return targetBox.top - (elementBox.height - targetBox.height) / 2;
188
- }
189
- else {
190
- return targetBox.top;
191
- }
192
- }
193
- case 'top': {
194
- return targetBox.top - elementBox.height;
195
- }
196
- case 'bottom': {
197
- return targetBox.top + targetBox.height;
198
- }
199
- /* istanbul ignore next */
200
- default:
201
- throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
202
- }
203
- }
204
- /**
205
- * It takes a list of placements and returns the first placement that has enough space to place the
206
- * element
207
- *
208
- * @param {ElementScrollDimension} containerBox - The box of the container element.
209
- * @param {ElementBoundBox} elementBox - The box of the element to be placed.
210
- * @param {ElementBoundBox} targetBox - The box of the target element.
211
- * @param {PlacementType[]} placements - The placements that we want to try.
212
- * @returns {PlacementType} A function that takes in a containerBox, elementBox, targetBox, placements, and element.
213
- */
214
- function getSuitablePlacement(containerBox, elementBox, targetBox, placements) {
215
- const defaultPlacement = placements[0];
216
- const suitablePlacement = placements.find((placement) => hasEnoughSpace(containerBox, placement, targetBox, elementBox));
217
- if (suitablePlacement) {
218
- return suitablePlacement;
219
- }
220
- else {
221
- globalSlimmerRegistry.LogUtility.warn(`
222
- No enough space found for placing element and we will keep using the defined placement:
223
- ${defaultPlacement}
224
- `);
225
- return defaultPlacement;
226
- }
227
- }
228
- /**
229
- * It takes a list of alignments and returns the suitable one that has enough space to fit the element
230
- *
231
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
232
- * @param {ElementBoundBox} elementBox - The box of the element that we want to position.
233
- * @param {ElementBoundBox} targetBox - The box of the element that the element to be positioned is aligned to.
234
- * @param {PlacementType} placement - The placement of the element relative to the target.
235
- * @param {PositionAlignmentType[]} alignments - An array of alignments to try.
236
- * @returns {PositionAlignmentType} the alignment that is suitable for the element.
237
- */
238
- const getSuitableAlignment = (containerBox, elementBox, targetBox, placement, alignments) => {
239
- const defaultAlignment = alignments[0];
240
- const suitableAlignment = alignments.find((alignment) => hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment));
241
- if (suitableAlignment) {
242
- return suitableAlignment;
243
- }
244
- else {
245
- globalSlimmerRegistry.LogUtility.warn(`
246
- No enough space found for placing element and we will keep using the defined alignment:
247
- ${defaultAlignment}
248
- `);
249
- return defaultAlignment;
250
- }
251
- };
252
- /**
253
- * Whether the alignment space is enough
254
- *
255
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
256
- * @param {ElementBoundBox} targetBox - The position of the target element.
257
- * @param {ElementBoundBox} elementBox - The box of the element that we're trying to position.
258
- * @param {PlacementType} placement - The placement of the element relative to the target.
259
- * @param {PlacementType} alignment - The alignment of the element relative to the target.
260
- * @returns {boolean} return true if it has enough space, otherwise false
261
- */
262
- function hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment) {
263
- if (['top', 'bottom'].includes(placement)) {
264
- switch (alignment) {
265
- case 'start': {
266
- return targetBox.left + elementBox.width <= containerBox.width;
267
- }
268
- case 'center': {
269
- return (targetBox.left >= elementBox.width - targetBox.width &&
270
- targetBox.left + targetBox.width / 2 + elementBox.width / 2 <= containerBox.width);
271
- }
272
- case 'end': {
273
- return targetBox.left + targetBox.width >= elementBox.width;
274
- }
275
- }
276
- }
277
- if (['right', 'left'].includes(placement)) {
278
- switch (alignment) {
279
- case 'start': {
280
- return targetBox.top + elementBox.height <= containerBox.height;
281
- }
282
- case 'center': {
283
- return (targetBox.top >= elementBox.height - targetBox.height &&
284
- targetBox.top + targetBox.height / 2 + elementBox.height / 2 <= containerBox.height);
285
- }
286
- case 'end': {
287
- return targetBox.top + targetBox.height >= elementBox.height;
288
- }
289
- }
290
- }
291
- /* istanbul ignore next */
292
- return false;
293
- }
294
- /**
295
- * If the placement is top or left, then the target's top or left position must be greater than or
296
- * equal to the element's height or width. If the placement is bottom or right, then the container's
297
- * height or width minus the target's top or left position minus the target's height or width must be
298
- * greater than or equal to the element's height or width.
299
- *
300
- * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
301
- * @param {PlacementType} placement - The placement of the element.
302
- * @param {ElementBoundBox} targetBox - The position of the target element.
303
- * @param {ElementBoundBox} elementBox - The dimensions of the element to be positioned.
304
- * @returns {boolean} A boolean value.
305
- */
306
- function hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
307
- switch (placement) {
308
- case 'top':
309
- return targetBox.top >= elementBox.height;
310
- case 'bottom':
311
- return containerBox.height - targetBox.top - targetBox.height >= elementBox.height;
312
- case 'left':
313
- return targetBox.left >= elementBox.width;
314
- case 'right':
315
- return containerBox.width - targetBox.left - targetBox.width >= elementBox.width;
316
- /* istanbul ignore next */
317
- default:
318
- return false;
319
- }
320
- }
321
- /**
322
- * It returns the position of an element relative to its container and also includes the scroll height of container.
323
- *
324
- * @param {HTMLElement} target - The element that you want to position.
325
- * @param {HTMLElement} container - The container element that the target element is inside of.
326
- * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
327
- */
328
- function getTargetBoundBox(target, container) {
329
- const containerRect = container.getBoundingClientRect();
330
- const targetRect = target.getBoundingClientRect();
331
- const targetTop = targetRect.top - containerRect.top + container.scrollTop;
332
- const targetLeft = targetRect.left - containerRect.left + container.scrollLeft;
333
- return {
334
- width: targetRect.width,
335
- height: targetRect.height,
336
- top: targetTop,
337
- left: targetLeft,
338
- };
339
- }
340
- /**
341
- * "Get the width, height, and top position of an element."
342
- *
343
- * The function takes an element as an argument and returns an object with three properties: width,
344
- * height, and top.
345
- *
346
- * Note: If element is hide, we should temporary change it to `block` to get the bounding client rect of element,
347
- * After do that, this element will change to origin `hide`, if not, it will be contained in the calculate of `document.documentElement.scrollHeight`
348
- *
349
- * @param {HTMLElement} element - HTMLElement - The element to get the position box for.
350
- * @returns {ElementBoundBox} An object with the width, height, and top properties of the element.
351
- */
352
- function getElementBoundBox(element) {
353
- const isElementHide = element.classList.contains('vega-force-hidden');
354
- if (isElementHide)
355
- element.classList.remove('vega-force-hidden');
356
- const elementRect = element.getBoundingClientRect();
357
- if (isElementHide)
358
- element.classList.add('vega-force-hidden');
359
- return {
360
- width: elementRect.width,
361
- height: elementRect.height,
362
- left: elementRect.left,
363
- top: elementRect.top,
364
- };
365
- }
366
- /**
367
- * "Get the width and height of an element."
368
- *
369
- * The function takes a single parameter, a container element, and returns an object with two
370
- * properties: width and height
371
- *
372
- * @param {HTMLElement} container - The container element that the tooltip will be positioned relative
373
- * to.
374
- * @returns {ElementScrollDimension} An object with two properties: width and height.
375
- */
376
- function getElementScrollDimension(container) {
377
- return {
378
- width: container.scrollWidth,
379
- height: container.scrollHeight,
380
- };
381
- }
382
-
383
- var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
12
+ var __decorate$9 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
384
13
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
385
14
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
386
15
  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;
@@ -390,32 +19,46 @@ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators,
390
19
  * This class is is used to retrieve the body element of document.
391
20
  */
392
21
  class DefaultWrapper {
393
- constructor() {
394
- /**
395
- * The canRetrieve function return is always true.
396
- *
397
- * @returns {boolean} the boolean type.
398
- */
399
- this.canRetrieve = () => true;
400
- /**
401
- * The retrieve function get the body element of document.
402
- *
403
- * @returns {HTMLElement} the element.
404
- */
405
- this.retrieve = () => {
406
- const container = document.body;
407
- if (this.showConfig.appendableElement.parentElement !== container) {
408
- container.append(this.showConfig.appendableElement);
409
- }
410
- return container;
411
- };
22
+ /**
23
+ * The canRetrieve function return is always true.
24
+ *
25
+ * @returns {boolean} the boolean type.
26
+ */
27
+ canRetrieve() {
28
+ return true;
29
+ }
30
+ /**
31
+ * The retrieve function get the body element of document.
32
+ *
33
+ * @returns {HTMLElement} the element.
34
+ */
35
+ retrieve() {
36
+ const container = document.body;
37
+ if (this.showConfig.appendableElement.parentElement !== container) {
38
+ container.append(this.showConfig.appendableElement);
39
+ }
40
+ return container;
412
41
  }
413
42
  }
414
- __decorate$6([
43
+ __decorate$9([
415
44
  globalSlimmerRegistry.MapToComponentField()
416
45
  ], DefaultWrapper.prototype, "showConfig", void 0);
417
46
 
418
- var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
47
+ /**
48
+ * Body positioned wrapper.
49
+ */
50
+ class BodyPositionedWrapper {
51
+ /**
52
+ * Valid is a body position used wrapper.
53
+ *
54
+ * @returns {boolean} can retrieve or not.
55
+ */
56
+ canRetrieve() {
57
+ return !this.showConfig.isScreenPosition;
58
+ }
59
+ }
60
+
61
+ var __decorate$8 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
419
62
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
420
63
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
421
64
  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;
@@ -426,34 +69,35 @@ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators,
426
69
  *
427
70
  * @property {HTMLElement} showConfig the show config
428
71
  */
429
- class PositionRelativeToWrapper {
430
- constructor() {
431
- /**
432
- * The canRetrieve function just determines whether the showConfig contains the positionRelativeTo object.
433
- *
434
- * @returns {boolean} the boolean type.
435
- */
436
- this.canRetrieve = () => !!this.showConfig.positionRelativeTo &&
437
- !!document.querySelector(this.showConfig.positionRelativeTo);
438
- /**
439
- * The retrieve function query the element of positionRelativeTo in showConfig.
440
- *
441
- * @returns {HTMLElement} the element.
442
- */
443
- this.retrieve = () => {
444
- const container = document.querySelector(this.showConfig.positionRelativeTo);
445
- if (this.showConfig.appendableElement.parentElement !== container) {
446
- container.append(this.showConfig.appendableElement);
447
- }
448
- return container;
449
- };
72
+ class PositionRelativeToWrapper extends BodyPositionedWrapper {
73
+ /**
74
+ * The canRetrieve function just determines whether the showConfig contains the positionRelativeTo object.
75
+ *
76
+ * @returns {boolean} the boolean type.
77
+ */
78
+ canRetrieve() {
79
+ return (super.canRetrieve() &&
80
+ !!this.showConfig.positionRelativeTo &&
81
+ !!document.querySelector(this.showConfig.positionRelativeTo));
82
+ }
83
+ /**
84
+ * The retrieve function query the element of positionRelativeTo in showConfig.
85
+ *
86
+ * @returns {HTMLElement} the element.
87
+ */
88
+ retrieve() {
89
+ const container = document.querySelector(this.showConfig.positionRelativeTo);
90
+ if (this.showConfig.appendableElement.parentElement !== container) {
91
+ container.append(this.showConfig.appendableElement);
92
+ }
93
+ return container;
450
94
  }
451
95
  }
452
- __decorate$5([
96
+ __decorate$8([
453
97
  globalSlimmerRegistry.MapToComponentField()
454
98
  ], PositionRelativeToWrapper.prototype, "showConfig", void 0);
455
99
 
456
- var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
100
+ var __decorate$7 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
457
101
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
458
102
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
459
103
  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;
@@ -464,20 +108,22 @@ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators,
464
108
  *
465
109
  * @property {HTMLElement} showConfig the show config
466
110
  */
467
- class VegaModalWrapper {
468
- constructor() {
469
- /**
470
- * The canRetrieve function just determines whether the target of showConfig has the `vega-modal` element. If not, search upwards layer by layer.
471
- *
472
- * @returns {boolean} the boolean type.
473
- */
474
- this.canRetrieve = () => !!ui$1.findParent(this.showConfig.target, 'vega-modal');
475
- /**
476
- * The retrieve function get the slot position of vega-modal element.
477
- *
478
- * @returns {HTMLElement} the element.
479
- */
480
- this.retrieve = () => this.getVegaModalShowConfigContainer();
111
+ class VegaModalWrapper extends BodyPositionedWrapper {
112
+ /**
113
+ * The canRetrieve function just determines whether the target of showConfig has the `vega-modal` element. If not, search upwards layer by layer.
114
+ *
115
+ * @returns {boolean} the boolean type.
116
+ */
117
+ canRetrieve() {
118
+ return super.canRetrieve() && !!ui.findParent(this.showConfig.target, 'vega-modal');
119
+ }
120
+ /**
121
+ * The retrieve function get the slot position of vega-modal element.
122
+ *
123
+ * @returns {HTMLElement} the element.
124
+ */
125
+ retrieve() {
126
+ return this.getVegaModalShowConfigContainer();
481
127
  }
482
128
  /**
483
129
  * 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.
@@ -502,7 +148,7 @@ class VegaModalWrapper {
502
148
  * @returns {HTMLElement} the `scrollContainer` element.
503
149
  */
504
150
  getVegaModalShowConfigContainer() {
505
- const parentModal = ui$1.findParent(this.showConfig.target, 'vega-modal');
151
+ const parentModal = ui.findParent(this.showConfig.target, 'vega-modal');
506
152
  const modalContentScrollable = parentModal.shadowRoot.querySelector('.vega-modal-content-with-scroll');
507
153
  const modalDialog = parentModal.shadowRoot.querySelector('.modal-dialog');
508
154
  this.setElementSlot(parentModal, this.showConfig.appendableElement);
@@ -510,11 +156,11 @@ class VegaModalWrapper {
510
156
  return modalContentScrollable ? modalContentScrollable : modalDialog;
511
157
  }
512
158
  }
513
- __decorate$4([
159
+ __decorate$7([
514
160
  globalSlimmerRegistry.MapToComponentField({ writable: true })
515
161
  ], VegaModalWrapper.prototype, "showConfig", void 0);
516
162
 
517
- var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
163
+ var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
518
164
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
519
165
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
520
166
  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;
@@ -525,31 +171,31 @@ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators,
525
171
  *
526
172
  * @property {HTMLElement} showConfig the show config
527
173
  */
528
- class VegaPopoverWrapper {
529
- constructor() {
530
- /**
531
- * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
532
- *
533
- * @returns {boolean} the boolean type.
534
- */
535
- this.canRetrieve = () => !!ui$1.findParent(this.showConfig.target, '.vega-popover');
536
- /**
537
- * 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.
538
- *
539
- * @returns {HTMLElement} the element.
540
- */
541
- this.retrieve = () => {
542
- const container = ui$1.findParent(this.showConfig.target, '.vega-popover');
543
- container.append(this.showConfig.appendableElement);
544
- return container;
545
- };
174
+ class VegaPopoverWrapper extends BodyPositionedWrapper {
175
+ /**
176
+ * The canRetrieve function just determine whether the target of showConfig has the class `vega-popover`. If not, search upwards layer by layer.
177
+ *
178
+ * @returns {boolean} the boolean type.
179
+ */
180
+ canRetrieve() {
181
+ return super.canRetrieve() && !!ui.findParent(this.showConfig.target, '.vega-popover');
182
+ }
183
+ /**
184
+ * 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.
185
+ *
186
+ * @returns {HTMLElement} the element.
187
+ */
188
+ retrieve() {
189
+ const container = ui.findParent(this.showConfig.target, '.vega-popover');
190
+ container.append(this.showConfig.appendableElement);
191
+ return container;
546
192
  }
547
193
  }
548
- __decorate$3([
194
+ __decorate$6([
549
195
  globalSlimmerRegistry.MapToComponentField()
550
196
  ], VegaPopoverWrapper.prototype, "showConfig", void 0);
551
197
 
552
- var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
198
+ var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
553
199
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
554
200
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
555
201
  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;
@@ -593,25 +239,606 @@ class ElementAppenderContainerController extends globalSlimmerRegistry.VegaSlimm
593
239
  ];
594
240
  }
595
241
  }
596
- __decorate$2([
242
+ __decorate$5([
597
243
  globalSlimmerRegistry.MapToComponentField({ writable: true })
598
244
  ], ElementAppenderContainerController.prototype, "container", void 0);
599
- __decorate$2([
245
+ __decorate$5([
600
246
  globalSlimmerRegistry.MapToComponentField({ writable: true })
601
247
  ], ElementAppenderContainerController.prototype, "showConfig", void 0);
602
- __decorate$2([
248
+ __decorate$5([
603
249
  globalSlimmerRegistry.InjectVegaSlimmer()
604
250
  ], ElementAppenderContainerController.prototype, "positionRelativeToWrapper", void 0);
605
- __decorate$2([
251
+ __decorate$5([
606
252
  globalSlimmerRegistry.InjectVegaSlimmer()
607
253
  ], ElementAppenderContainerController.prototype, "vegaPopoverWrapper", void 0);
608
- __decorate$2([
254
+ __decorate$5([
609
255
  globalSlimmerRegistry.InjectVegaSlimmer()
610
256
  ], ElementAppenderContainerController.prototype, "vegaModalWrapper", void 0);
611
- __decorate$2([
257
+ __decorate$5([
612
258
  globalSlimmerRegistry.InjectVegaSlimmer()
613
259
  ], ElementAppenderContainerController.prototype, "defaultWrapper", void 0);
614
260
 
261
+ /**
262
+ * calculate position
263
+ */
264
+ class BasePositionCalculationStrategy extends globalSlimmerRegistry.VegaSlimmer {
265
+ /**
266
+ * Get the position box.
267
+ *
268
+ * @param {PlacementType[]} placement - previous placement.
269
+ * @param {PositionAlignmentType[]} alignment - previous placement.
270
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
271
+ * returns an ElementPositionBox.
272
+ */
273
+ getPositionBox(placement, alignment) {
274
+ const placements = placement || this.getPlacements();
275
+ const alignments = alignment || this.getAlignments();
276
+ const targetBox = this.getTargetBoundBox();
277
+ const elementBox = this.getElementBoundBox();
278
+ const containerBox = this.getElementScrollDimension();
279
+ const suitablePlacement = this.getSuitablePlacement(containerBox, elementBox, targetBox, placements);
280
+ const suitableAlignment = this.getSuitableAlignment(containerBox, elementBox, targetBox, suitablePlacement, alignments);
281
+ const positionBox = this.calculatePosition(elementBox, targetBox, suitablePlacement, suitableAlignment);
282
+ const translocationBox = this.getTranslocationBox(suitablePlacement);
283
+ positionBox.placement = suitablePlacement;
284
+ positionBox.alignment = suitableAlignment;
285
+ positionBox.left += translocationBox.X;
286
+ positionBox.top += translocationBox.Y;
287
+ return positionBox;
288
+ }
289
+ /**
290
+ * "Get the width, height, and top position of an element."
291
+ *
292
+ * The function takes an element as an argument and returns an object with three properties: width,
293
+ * height, and top.
294
+ *
295
+ * Note: If element is hide, we should temporary change it to `block` to get the bounding client rect of element,
296
+ * After do that, this element will change to origin `hide`, if not, it will be contained in the calculate of `document.documentElement.scrollHeight`
297
+ *
298
+ * @returns {ElementBoundBox} An object with the width, height, and top properties of the element.
299
+ */
300
+ getElementBoundBox() {
301
+ const element = this.showConfig.appendableElement;
302
+ const isElementHide = element.classList.contains('vega-force-hidden');
303
+ if (isElementHide)
304
+ element.classList.remove('vega-force-hidden');
305
+ const elementRect = element.getBoundingClientRect();
306
+ if (isElementHide)
307
+ element.classList.add('vega-force-hidden');
308
+ return {
309
+ width: elementRect.width,
310
+ height: elementRect.height,
311
+ left: elementRect.left,
312
+ top: elementRect.top,
313
+ };
314
+ }
315
+ /**
316
+ * It takes a placement string or array of placements and returns an array of placements
317
+ * if given placement is single, we should completion the placements with the default {@link Placements}
318
+ * and make given placement as default.
319
+ * if given placement is array, we should use it directly, even it partial of {@link Placements}.
320
+ * if not placement give. we should use {@link Placements}.
321
+ *
322
+ * @returns {PlacementType[]} ordered placements.
323
+ */
324
+ getPlacements() {
325
+ const placement = this.showConfig.placement;
326
+ if (typeof placement === 'string') {
327
+ const partial = ui$1.Placements.filter((direction) => direction !== placement);
328
+ return [placement, ...partial];
329
+ }
330
+ else if (Array.isArray(placement)) {
331
+ return placement;
332
+ }
333
+ else {
334
+ return [...ui$1.Placements];
335
+ }
336
+ }
337
+ /**
338
+ * It returns acceptable alignments.
339
+ *
340
+ * @returns {PositionAlignmentType[]} acceptable alignments
341
+ */
342
+ getAlignments() {
343
+ const alignment = this.showConfig.alignment;
344
+ if (typeof alignment === 'string') {
345
+ const partial = ui$1.Alignments.filter((item) => item !== alignment);
346
+ return [alignment, ...partial];
347
+ }
348
+ else if (Array.isArray(alignment)) {
349
+ return alignment;
350
+ }
351
+ else {
352
+ return [...ui$1.Alignments];
353
+ }
354
+ }
355
+ /**
356
+ * It takes a placement, a target box, and a element box, and returns an element box
357
+ *
358
+ * @param {ElementBoundBox} elementBox - The position of the element element.
359
+ * @param {ElementBoundBox} targetBox - The position of the target element.
360
+ * @param {PlacementType} placement - The placement of the element.
361
+ * @param {PositionAlignmentType} alignment - The alignment of the element
362
+ * @returns {ElementPositionBox} An object with top and left properties.
363
+ */
364
+ calculatePosition(elementBox, targetBox, placement, alignment) {
365
+ return {
366
+ top: this.calculateTop(elementBox, targetBox, placement, alignment),
367
+ left: this.calculateLeft(elementBox, targetBox, placement, alignment),
368
+ };
369
+ }
370
+ /**
371
+ * It returns the translocation of the element relative to the target element
372
+ *
373
+ * @param {PlacementType} placement - The suitable placement of the element.
374
+ * @returns {TranslocationType} A translocation object with X and Y properties.
375
+ */
376
+ getTranslocationBox(placement) {
377
+ const originPlacement = Array.isArray(this.showConfig.placement)
378
+ ? this.showConfig.placement[0]
379
+ : this.showConfig.placement;
380
+ const translocation = this.getTranslocation();
381
+ const result = { X: 0, Y: 0 };
382
+ if (typeGuard.isTranslocationType(translocation)) {
383
+ let xValue = translocation.X;
384
+ let yValue = translocation.Y;
385
+ // If originPlacement and placement is not in same axis, it should reverse axis.
386
+ if ((originPlacement &&
387
+ ['left', 'right'].includes(originPlacement) &&
388
+ ['top', 'bottom'].includes(placement)) ||
389
+ (originPlacement &&
390
+ ['top', 'bottom'].includes(originPlacement) &&
391
+ ['left', 'right'].includes(placement))) {
392
+ xValue = translocation.Y;
393
+ yValue = translocation.X;
394
+ }
395
+ if (['bottom', 'top'].includes(placement)) {
396
+ result.Y = placement === 'top' ? -yValue : yValue;
397
+ result.X = xValue;
398
+ }
399
+ if (['left', 'right'].includes(placement)) {
400
+ result.X = placement === 'left' ? -xValue : xValue;
401
+ result.Y = yValue;
402
+ }
403
+ }
404
+ return result;
405
+ }
406
+ /**
407
+ * Calculate the left position of the element
408
+ *
409
+ * @param {ElementBoundBox} elementBox - The position box of the element.
410
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
411
+ * @param {PlacementType} placement - The placement of the element.
412
+ * @param {PositionAlignmentType} alignment - The alignment of the element
413
+ * @returns {number} The left position of the element.
414
+ */
415
+ calculateLeft(elementBox, targetBox, placement, alignment) {
416
+ switch (placement) {
417
+ case 'top':
418
+ case 'bottom': {
419
+ if (alignment === 'end') {
420
+ return targetBox.left + targetBox.width - elementBox.width;
421
+ }
422
+ else if (alignment === 'center') {
423
+ return targetBox.left - (elementBox.width - targetBox.width) / 2;
424
+ }
425
+ else {
426
+ return targetBox.left;
427
+ }
428
+ }
429
+ case 'left': {
430
+ return targetBox.left - elementBox.width;
431
+ }
432
+ case 'right': {
433
+ return targetBox.left + targetBox.width;
434
+ }
435
+ /* istanbul ignore next */
436
+ default:
437
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
438
+ }
439
+ }
440
+ /**
441
+ * Calculate the top position of the element
442
+ *
443
+ * @param {ElementBoundBox} elementBox - The position box of the element.
444
+ * @param {ElementBoundBox} targetBox - The position box of the target element that is attached to.
445
+ * @param {PlacementType} placement - The placement of the element.
446
+ * @param {PositionAlignmentType} alignment - The alignment of the element
447
+ * @returns {number} the top position of the element.
448
+ */
449
+ calculateTop(elementBox, targetBox, placement, alignment) {
450
+ switch (placement) {
451
+ case 'left':
452
+ case 'right': {
453
+ if (alignment === 'end') {
454
+ return targetBox.top + targetBox.height - elementBox.height;
455
+ }
456
+ else if (alignment === 'center') {
457
+ return targetBox.top - (elementBox.height - targetBox.height) / 2;
458
+ }
459
+ else {
460
+ return targetBox.top;
461
+ }
462
+ }
463
+ case 'top': {
464
+ return targetBox.top - elementBox.height;
465
+ }
466
+ case 'bottom': {
467
+ return targetBox.top + targetBox.height;
468
+ }
469
+ /* istanbul ignore next */
470
+ default:
471
+ throw new Error(`Unexpected placement: ${placement}. Expected values are top, bottom, left, or right.`);
472
+ }
473
+ }
474
+ /**
475
+ * It takes a list of placements and returns the first placement that has enough space to place the
476
+ * element
477
+ *
478
+ * @param {ElementScrollDimension} containerBox - The box of the container element.
479
+ * @param {ElementBoundBox} elementBox - The box of the element to be placed.
480
+ * @param {ElementBoundBox} targetBox - The box of the target element.
481
+ * @param {PlacementType[]} placements - The placements that we want to try.
482
+ * @returns {PlacementType} A function that takes in a containerBox, elementBox, targetBox, placements, and element.
483
+ */
484
+ getSuitablePlacement(containerBox, elementBox, targetBox, placements) {
485
+ const defaultPlacement = placements[0];
486
+ const suitablePlacement = placements.find((placement) => this.hasEnoughSpace(containerBox, placement, targetBox, elementBox));
487
+ if (suitablePlacement) {
488
+ return suitablePlacement;
489
+ }
490
+ else {
491
+ globalSlimmerRegistry.LogUtility.warn(`
492
+ No enough space found for placing element and we will keep using the defined placement:
493
+ ${defaultPlacement}
494
+ `);
495
+ return defaultPlacement;
496
+ }
497
+ }
498
+ /**
499
+ * It takes a list of alignments and returns the suitable one that has enough space to fit the element
500
+ *
501
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
502
+ * @param {ElementBoundBox} elementBox - The box of the element that we want to position.
503
+ * @param {ElementBoundBox} targetBox - The box of the element that the element to be positioned is aligned to.
504
+ * @param {PlacementType} placement - The placement of the element relative to the target.
505
+ * @param {PositionAlignmentType[]} alignments - An array of alignments to try.
506
+ * @returns {PositionAlignmentType} the alignment that is suitable for the element.
507
+ */
508
+ getSuitableAlignment(containerBox, elementBox, targetBox, placement, alignments) {
509
+ const defaultAlignment = alignments[0];
510
+ const suitableAlignment = alignments.find((alignment) => this.hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment));
511
+ if (suitableAlignment) {
512
+ return suitableAlignment;
513
+ }
514
+ else {
515
+ globalSlimmerRegistry.LogUtility.warn(`
516
+ No enough space found for placing element and we will keep using the defined alignment:
517
+ ${defaultAlignment}
518
+ `);
519
+ return defaultAlignment;
520
+ }
521
+ }
522
+ /**
523
+ * Whether the alignment space is enough
524
+ *
525
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
526
+ * @param {ElementBoundBox} targetBox - The position of the target element.
527
+ * @param {ElementBoundBox} elementBox - The box of the element that we're trying to position.
528
+ * @param {PlacementType} placement - The placement of the element relative to the target.
529
+ * @param {PlacementType} alignment - The alignment of the element relative to the target.
530
+ * @returns {boolean} return true if it has enough space, otherwise false
531
+ */
532
+ hasEnoughAlignmentSpace(containerBox, targetBox, elementBox, placement, alignment) {
533
+ if (['top', 'bottom'].includes(placement)) {
534
+ switch (alignment) {
535
+ case 'start': {
536
+ return targetBox.left + elementBox.width <= containerBox.width;
537
+ }
538
+ case 'center': {
539
+ return (targetBox.left >= (elementBox.width - targetBox.width) / 2 &&
540
+ targetBox.left + targetBox.width / 2 + elementBox.width / 2 <= containerBox.width);
541
+ }
542
+ case 'end': {
543
+ return targetBox.left + targetBox.width >= elementBox.width;
544
+ }
545
+ }
546
+ }
547
+ if (['right', 'left'].includes(placement)) {
548
+ switch (alignment) {
549
+ case 'start': {
550
+ return targetBox.top + elementBox.height <= containerBox.height;
551
+ }
552
+ case 'center': {
553
+ return (targetBox.top >= (elementBox.height - targetBox.height) / 2 &&
554
+ targetBox.top + targetBox.height / 2 + elementBox.height / 2 <= containerBox.height);
555
+ }
556
+ case 'end': {
557
+ return targetBox.top + targetBox.height >= elementBox.height;
558
+ }
559
+ }
560
+ }
561
+ /* istanbul ignore next */
562
+ return false;
563
+ }
564
+ /**
565
+ * If the placement is top or left, then the target's top or left position must be greater than or
566
+ * equal to the element's height or width. If the placement is bottom or right, then the container's
567
+ * height or width minus the target's top or left position minus the target's height or width must be
568
+ * greater than or equal to the element's height or width.
569
+ *
570
+ * @param {ElementScrollDimension} containerBox - The bounding box of the container element.
571
+ * @param {PlacementType} placement - The placement of the element.
572
+ * @param {ElementBoundBox} targetBox - The position of the target element.
573
+ * @param {ElementBoundBox} elementBox - The dimensions of the element to be positioned.
574
+ * @returns {boolean} A boolean value.
575
+ */
576
+ hasEnoughSpace(containerBox, placement, targetBox, elementBox) {
577
+ switch (placement) {
578
+ case 'top':
579
+ return targetBox.top >= elementBox.height;
580
+ case 'bottom':
581
+ return containerBox.height - targetBox.top - targetBox.height >= elementBox.height;
582
+ case 'left':
583
+ return targetBox.left >= elementBox.width;
584
+ case 'right':
585
+ return containerBox.width - targetBox.left - targetBox.width >= elementBox.width;
586
+ /* istanbul ignore next */
587
+ default:
588
+ return false;
589
+ }
590
+ }
591
+ /**
592
+ * Retrieves and formats the translocation.
593
+ *
594
+ * @returns {TranslocationType} current translocation.
595
+ */
596
+ getTranslocation() {
597
+ const translocation = this.showConfig.translocation;
598
+ return translocation && responsiveFormatFacade.ResponsiveFormatFacade.format(translocation, 'translocation');
599
+ }
600
+ }
601
+
602
+ var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
603
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
604
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
605
+ 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;
606
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
607
+ };
608
+ /**
609
+ * calculate position by body container
610
+ */
611
+ class BodyPositionCalculationStrategy extends BasePositionCalculationStrategy {
612
+ /**
613
+ * Get the position of the element in the container according to the target element and the placement
614
+ * If give a translocation, it will apply the translocation to the result.
615
+ * Note: If you use this method to calculate the position, you should make container as relative position at first.
616
+ *
617
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
618
+ * returns an ElementPositionBox.
619
+ */
620
+ getPosition() {
621
+ const containerStyle = window.getComputedStyle(this.container);
622
+ if (containerStyle.position !== 'relative') {
623
+ globalSlimmerRegistry.LogUtility.warn(`Calculate position should make container as 'position: relative', otherwise the result might not be accurate.`);
624
+ }
625
+ return this.getPositionBox();
626
+ }
627
+ /**
628
+ * It returns the position of an element relative to its container and also includes the scroll height of container.
629
+ *
630
+ * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
631
+ */
632
+ getTargetBoundBox() {
633
+ const containerRect = this.container.getBoundingClientRect();
634
+ const targetRect = this.showConfig.target.getBoundingClientRect();
635
+ const targetTop = targetRect.top - containerRect.top + this.container.scrollTop;
636
+ const targetLeft = targetRect.left - containerRect.left + this.container.scrollLeft;
637
+ return {
638
+ width: targetRect.width,
639
+ height: targetRect.height,
640
+ top: targetTop,
641
+ left: targetLeft,
642
+ };
643
+ }
644
+ /**
645
+ * "Get the width and height of an element."
646
+ *
647
+ * The function takes a single parameter, a container element, and returns an object with two
648
+ * properties: width and height
649
+ *
650
+ * @returns {ElementScrollDimension} An object with two properties: width and height.
651
+ */
652
+ getElementScrollDimension() {
653
+ return {
654
+ width: this.container.scrollWidth,
655
+ height: this.container.scrollHeight,
656
+ };
657
+ }
658
+ }
659
+ __decorate$4([
660
+ globalSlimmerRegistry.MapToComponentField()
661
+ ], BodyPositionCalculationStrategy.prototype, "container", void 0);
662
+ __decorate$4([
663
+ globalSlimmerRegistry.MapToComponentField()
664
+ ], BodyPositionCalculationStrategy.prototype, "showConfig", void 0);
665
+
666
+ var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
667
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
668
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
669
+ 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;
670
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
671
+ };
672
+ /**
673
+ * calculate position by screen container
674
+ */
675
+ class ScreenPositionCalculationStrategy extends BasePositionCalculationStrategy {
676
+ /**
677
+ * Get the position of the element in the container according to the target element and the placement
678
+ * If give a translocation, it will apply the translocation to the result.
679
+ *
680
+ * @param {boolean} usePreviousPlacement - Should keep use previous placement and alignment.
681
+ * @returns {ElementPositionBox} A function that takes in a container, element, target, placement, and translocation and
682
+ * returns an ElementPositionBox.
683
+ */
684
+ getPosition(usePreviousPlacement) {
685
+ const positionBox = usePreviousPlacement
686
+ ? this.getPositionBox([this.previousPositionBox.placement], [this.previousPositionBox.alignment])
687
+ : this.getPositionBox();
688
+ this.previousPositionBox = positionBox;
689
+ return positionBox;
690
+ }
691
+ /**
692
+ * It returns the position of an element relative to its container and also includes the scroll height of container.
693
+ *
694
+ * @returns {ElementBoundBox} An object with the properties width, height, top, and left.
695
+ */
696
+ getTargetBoundBox() {
697
+ const targetRect = this.showConfig.target.getBoundingClientRect();
698
+ return {
699
+ width: targetRect.width,
700
+ height: targetRect.height,
701
+ top: targetRect.top,
702
+ left: targetRect.left,
703
+ };
704
+ }
705
+ /**
706
+ * "Get the width and height of an element."
707
+ *
708
+ * The function takes a single parameter, a container element, and returns an object with two
709
+ * properties: width and height
710
+ *
711
+ * @returns {ElementScrollDimension} An object with two properties: width and height.
712
+ */
713
+ getElementScrollDimension() {
714
+ return {
715
+ width: window.innerWidth,
716
+ height: window.innerHeight,
717
+ };
718
+ }
719
+ }
720
+ __decorate$3([
721
+ globalSlimmerRegistry.MapToComponentField()
722
+ ], ScreenPositionCalculationStrategy.prototype, "showConfig", void 0);
723
+
724
+ var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
725
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
726
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
727
+ 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;
728
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
729
+ };
730
+ /**
731
+ * Calculation and adjustment of positions for appendable elements based on target element positions.
732
+ */
733
+ class PositionCalculationController extends globalSlimmerRegistry.VegaSlimmer {
734
+ constructor() {
735
+ super(...arguments);
736
+ this.bodyPositionStrategy = new BodyPositionCalculationStrategy();
737
+ this.screenPositionStrategy = new ScreenPositionCalculationStrategy();
738
+ }
739
+ /**
740
+ * Sets the calculate postion strategy.
741
+ */
742
+ setCalculationStrategy() {
743
+ this.positionStrategy = this.showConfig.isScreenPosition
744
+ ? this.screenPositionStrategy
745
+ : this.bodyPositionStrategy;
746
+ }
747
+ /**
748
+ * Calculates the position and applies it to the appendable element.
749
+ *
750
+ * @param {boolean} [usePreviousPlacement] - Should keep use previous placement and alignment.
751
+ */
752
+ adjustPosition(usePreviousPlacement) {
753
+ this.adjustWidth();
754
+ this.adjustHeight();
755
+ this.applyPosition(this.positionStrategy.getPosition(usePreviousPlacement));
756
+ }
757
+ /**
758
+ * Apply the position to the appendable element.
759
+ *
760
+ * @param {ElementPositionBox} positionBox - position box
761
+ */
762
+ applyPosition(positionBox) {
763
+ const appendableElement = this.showConfig.appendableElement;
764
+ if (this.showConfig.isScreenPosition) {
765
+ appendableElement.style.position = 'fixed';
766
+ }
767
+ appendableElement.style.left = `${positionBox.left}px`;
768
+ appendableElement.style.top = `${positionBox.top}px`;
769
+ appendableElement.classList.remove('vega-placement-left', 'vega-placement-right', 'vega-placement-top', 'vega-placement-bottom');
770
+ appendableElement.classList.remove('vega-alignment-start', 'vega-alignment-center', 'vega-alignment-end');
771
+ appendableElement.classList.add(`vega-placement-${positionBox.placement}`);
772
+ appendableElement.classList.add(`vega-alignment-${positionBox.alignment}`);
773
+ }
774
+ /**
775
+ * It sets the width of the appendable element to the width of the target element if the
776
+ * matchTargetWidth property is true, otherwise it sets the width of the appendable element to the
777
+ * size property
778
+ *
779
+ * @returns {void}
780
+ */
781
+ adjustWidth() {
782
+ if (this.showConfig.matchTargetWidth) {
783
+ const { width: hostWidth } = this.showConfig.target.getBoundingClientRect();
784
+ this.setRelatedWidth('width', hostWidth);
785
+ }
786
+ else {
787
+ this.setRelatedWidth('width', this.showConfig.size);
788
+ this.setRelatedWidth('minWidth', this.showConfig.minWidth);
789
+ this.setRelatedWidth('maxWidth', this.showConfig.maxWidth);
790
+ }
791
+ }
792
+ /**
793
+ * It takes a name and a value, formats the value, and then sets the style of the element
794
+ *
795
+ * @param {'width' | 'maxWidth' | 'minWidth'} name - 'width' | 'maxWidth' | 'minWidth'
796
+ * @param {ResponsiveType<SizeType>} value - ResponsiveType<SizeType>
797
+ * @returns {void}
798
+ */
799
+ setRelatedWidth(name, value) {
800
+ if (!value)
801
+ return;
802
+ const formattedValue = responsiveFormatFacade.ResponsiveFormatFacade.format(value, 'size');
803
+ if (formattedValue) {
804
+ this.showConfig.appendableElement.style[name] =
805
+ typeof formattedValue === 'number' ? `${formattedValue}px` : formattedValue;
806
+ }
807
+ }
808
+ /**
809
+ * > If the `matchContainerHeight` property is set to `true`, then the maximum height of the dropdown
810
+ * is set to the height of the container minus the height of the target minus the top offset of the
811
+ * target
812
+ *
813
+ * @returns {void}
814
+ */
815
+ adjustHeight() {
816
+ if (this.showConfig.matchContainerHeight) {
817
+ const { height: targetHeight } = this.showConfig.target.getBoundingClientRect();
818
+ let maxHeight = this.container.scrollHeight - this.showConfig.target.offsetTop - targetHeight;
819
+ if (this.showConfig.maxHeight) {
820
+ maxHeight = Math.min(maxHeight, this.showConfig.maxHeight);
821
+ }
822
+ this.showConfig.appendableElement.style.maxHeight = `${maxHeight}px`;
823
+ }
824
+ else if (this.showConfig.maxHeight) {
825
+ this.showConfig.appendableElement.style.maxHeight = `${this.showConfig.maxHeight}px`;
826
+ }
827
+ }
828
+ }
829
+ __decorate$2([
830
+ globalSlimmerRegistry.MapToComponentField()
831
+ ], PositionCalculationController.prototype, "container", void 0);
832
+ __decorate$2([
833
+ globalSlimmerRegistry.MapToComponentField()
834
+ ], PositionCalculationController.prototype, "showConfig", void 0);
835
+ __decorate$2([
836
+ globalSlimmerRegistry.InjectVegaSlimmer()
837
+ ], PositionCalculationController.prototype, "bodyPositionStrategy", void 0);
838
+ __decorate$2([
839
+ globalSlimmerRegistry.InjectVegaSlimmer()
840
+ ], PositionCalculationController.prototype, "screenPositionStrategy", void 0);
841
+
615
842
  var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
616
843
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
617
844
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -654,10 +881,8 @@ class ElementAppender {
654
881
  callback: /* istanbul ignore next */ () => {
655
882
  // while target and appendableElement are both visible, we can adjust position.
656
883
  // https://gethired.atlassian.net/browse/VD-1087
657
- if (ui$1.isElementVisible(this.showConfig.target) &&
658
- ui$1.isElementVisible(this.showConfig.appendableElement)) {
659
- this.adjustWidth();
660
- this.adjustHeight();
884
+ if (ui.isElementVisible(this.showConfig.target) &&
885
+ ui.isElementVisible(this.showConfig.appendableElement)) {
661
886
  this.adjustPosition();
662
887
  }
663
888
  },
@@ -666,6 +891,7 @@ class ElementAppender {
666
891
  },
667
892
  ]);
668
893
  this.elementAppenderContainerController = new ElementAppenderContainerController();
894
+ this.positionCalculationController = new PositionCalculationController();
669
895
  this.showConfigCallback = showConfigCallback;
670
896
  this.showConfigCallbackTarget = showConfigCallbackTarget;
671
897
  const config = this.getShowConfig();
@@ -690,8 +916,6 @@ class ElementAppender {
690
916
  /* A function that takes no parameters and returns nothing. It sets the position of the appendable
691
917
  element. */
692
918
  this.prepareShow();
693
- this.adjustWidth();
694
- this.adjustHeight();
695
919
  this.adjustPosition();
696
920
  this.setZIndex();
697
921
  this.toggleShow(true);
@@ -707,6 +931,18 @@ class ElementAppender {
707
931
  this.resetContainerPosition();
708
932
  internalVegaZIndexManager.InternalVegaZIndexManager.removeZIndex(this.showConfig.appendableElement, 'base');
709
933
  }
934
+ /**
935
+ * Update position while window scroll.
936
+ */
937
+ onScroll() {
938
+ var _a;
939
+ const currentTargetRect = this.showConfig.target.getBoundingClientRect();
940
+ if (this.showConfig.isScreenPosition &&
941
+ (currentTargetRect.left !== ((_a = this.previousTargetRect) === null || _a === void 0 ? void 0 : _a.left) ||
942
+ currentTargetRect.top !== this.previousTargetRect.top)) {
943
+ this.adjustPosition(true);
944
+ }
945
+ }
710
946
  /* istanbul ignore next */
711
947
  /**
712
948
  * It removes the z-index from the appendable element, removes the appendable element from the DOM, and
@@ -816,76 +1052,16 @@ class ElementAppender {
816
1052
  this.container.style.position = 'relative';
817
1053
  }
818
1054
  this.showConfig.appendableElement.style.boxSizing = 'border-box';
819
- }
820
- /**
821
- * It sets the width of the appendable element to the width of the target element if the
822
- * matchTargetWidth property is true, otherwise it sets the width of the appendable element to the
823
- * size property
824
- *
825
- * @returns {void}
826
- */
827
- adjustWidth() {
828
- if (this.showConfig.matchTargetWidth) {
829
- const { width: hostWidth } = this.showConfig.target.getBoundingClientRect();
830
- this.setRelatedWidth('width', hostWidth);
831
- }
832
- else {
833
- this.setRelatedWidth('width', this.showConfig.size);
834
- this.setRelatedWidth('minWidth', this.showConfig.minWidth);
835
- this.setRelatedWidth('maxWidth', this.showConfig.maxWidth);
836
- }
837
- }
838
- /**
839
- * It takes a name and a value, formats the value, and then sets the style of the element
840
- *
841
- * @param {'width' | 'maxWidth' | 'minWidth'} name - 'width' | 'maxWidth' | 'minWidth'
842
- * @param {ResponsiveType<SizeType>} value - ResponsiveType<SizeType>
843
- * @returns {void}
844
- */
845
- setRelatedWidth(name, value) {
846
- if (!value)
847
- return;
848
- const formattedValue = responsiveFormatFacade.ResponsiveFormatFacade.format(value, 'size');
849
- if (formattedValue) {
850
- this.showConfig.appendableElement.style[name] =
851
- typeof formattedValue === 'number' ? `${formattedValue}px` : formattedValue;
852
- }
853
- }
854
- /**
855
- * > If the `matchContainerHeight` property is set to `true`, then the maximum height of the dropdown
856
- * is set to the height of the container minus the height of the target minus the top offset of the
857
- * target
858
- *
859
- * @returns {void}
860
- */
861
- adjustHeight() {
862
- if (this.showConfig.matchContainerHeight) {
863
- const { height: targetHeight } = this.showConfig.target.getBoundingClientRect();
864
- let maxHeight = this.container.scrollHeight - this.showConfig.target.offsetTop - targetHeight;
865
- if (this.showConfig.maxHeight) {
866
- maxHeight = Math.min(maxHeight, this.showConfig.maxHeight);
867
- }
868
- this.showConfig.appendableElement.style.maxHeight = `${maxHeight}px`;
869
- }
870
- else if (this.showConfig.maxHeight) {
871
- this.showConfig.appendableElement.style.maxHeight = `${this.showConfig.maxHeight}px`;
872
- }
1055
+ this.positionCalculationController.setCalculationStrategy();
873
1056
  }
874
1057
  /**
875
1058
  * A function that takes no parameters and returns nothing. It sets the position of the appendable element.
876
1059
  *
1060
+ * @param {boolean} usePreviousPlacement - Should keep use previous placement and alignment.
877
1061
  * @returns {void}
878
1062
  */
879
- adjustPosition() {
880
- const translocation = this.showConfig.translocation &&
881
- responsiveFormatFacade.ResponsiveFormatFacade.format(this.showConfig.translocation, 'translocation');
882
- const positionBox = getPositionBox(this.container, this.showConfig.appendableElement, this.showConfig.target, this.showConfig.placement, this.showConfig.alignment, translocation);
883
- this.showConfig.appendableElement.style.left = `${positionBox.left}px`;
884
- this.showConfig.appendableElement.style.top = `${positionBox.top}px`;
885
- this.showConfig.appendableElement.classList.remove('vega-placement-left', 'vega-placement-right', 'vega-placement-top', 'vega-placement-bottom');
886
- this.showConfig.appendableElement.classList.remove('vega-alignment-start', 'vega-alignment-center', 'vega-alignment-end');
887
- this.showConfig.appendableElement.classList.add(`vega-placement-${positionBox.placement}`);
888
- this.showConfig.appendableElement.classList.add(`vega-alignment-${positionBox.alignment}`);
1063
+ adjustPosition(usePreviousPlacement) {
1064
+ this.positionCalculationController.adjustPosition(usePreviousPlacement);
889
1065
  }
890
1066
  /**
891
1067
  * Sets the z-index of the appendable element to 11000.
@@ -921,6 +1097,9 @@ __decorate$1([
921
1097
  __decorate$1([
922
1098
  globalSlimmerRegistry.InjectVegaSlimmer()
923
1099
  ], ElementAppender.prototype, "elementAppenderContainerController", void 0);
1100
+ __decorate$1([
1101
+ globalSlimmerRegistry.InjectVegaSlimmer()
1102
+ ], ElementAppender.prototype, "positionCalculationController", void 0);
924
1103
 
925
1104
  var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
926
1105
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -946,6 +1125,7 @@ class ElementAppenderSlimmer extends globalSlimmerRegistry.VegaSlimmer {
946
1125
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.addEventListener('mouseleave', this.elementMouseLeaveHandler);
947
1126
  }
948
1127
  window.addEventListener('mousedown', this.globalMouseDownHandler);
1128
+ document.addEventListener('scroll', this.globalScrollHandler, { capture: true });
949
1129
  };
950
1130
  /* It's a function that listens to the click event on the dropdown. It checks if the trigger
951
1131
  property is equal to 'click'. If it is, then it toggles the dropdown. */
@@ -1001,12 +1181,20 @@ class ElementAppenderSlimmer extends globalSlimmerRegistry.VegaSlimmer {
1001
1181
  if (this.shouldListenerWork('custom') &&
1002
1182
  this.isShowing() &&
1003
1183
  this.showConfig &&
1004
- !ui$1.isParent(currentTarget, this.showConfig.appendableElement) &&
1005
- !ui$1.isParent(currentTarget, this.showConfig.target) &&
1006
- ui$1.findParent(currentTarget, 'vega-modal') === ui$1.findParent(this.showConfig.target, 'vega-modal')) {
1184
+ !ui.isParent(currentTarget, this.showConfig.appendableElement) &&
1185
+ !ui.isParent(currentTarget, this.showConfig.target) &&
1186
+ ui.findParent(currentTarget, 'vega-modal') === ui.findParent(this.showConfig.target, 'vega-modal')) {
1007
1187
  this.hide();
1008
1188
  }
1009
1189
  };
1190
+ /* istanbul ignore next */
1191
+ /* Listen global scroll event */
1192
+ this.globalScrollHandler = () => {
1193
+ var _a;
1194
+ if (this.showConfig && this.showConfig.isScreenPosition && this.isShowing()) {
1195
+ (_a = this.elementAppender) === null || _a === void 0 ? void 0 : _a.onScroll();
1196
+ }
1197
+ };
1010
1198
  /* A timer that will hide the dropdown after a certain amount of time. */
1011
1199
  this.createDelayHideTimer = () => {
1012
1200
  this.delayHideTimer = setTimeout(() => {
@@ -1093,6 +1281,7 @@ class ElementAppenderSlimmer extends globalSlimmerRegistry.VegaSlimmer {
1093
1281
  (_f = this.showConfig.appendableElement) === null || _f === void 0 ? void 0 : _f.removeEventListener('mouseleave', this.elementMouseLeaveHandler);
1094
1282
  }
1095
1283
  window.removeEventListener('mousedown', this.globalMouseDownHandler);
1284
+ document.removeEventListener('scroll', this.globalScrollHandler);
1096
1285
  }
1097
1286
  }
1098
1287
  ElementAppenderSlimmer.DELAY_HIDE_TIME = 100;