@cloudscape-design/components 3.0.950 → 3.0.951

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 (540) hide show
  1. package/alert/actions-wrapper/styles.css.js +1 -1
  2. package/alert/actions-wrapper/styles.scoped.css +3 -3
  3. package/alert/actions-wrapper/styles.selectors.js +1 -1
  4. package/alert/styles.css.js +27 -27
  5. package/alert/styles.scoped.css +90 -90
  6. package/alert/styles.selectors.js +27 -27
  7. package/anchor-navigation/styles.css.js +8 -8
  8. package/anchor-navigation/styles.scoped.css +60 -60
  9. package/anchor-navigation/styles.selectors.js +8 -8
  10. package/annotation-context/annotation/styles.css.js +24 -24
  11. package/annotation-context/annotation/styles.scoped.css +52 -52
  12. package/annotation-context/annotation/styles.selectors.js +24 -24
  13. package/app-layout/content-wrapper/styles.css.js +3 -3
  14. package/app-layout/content-wrapper/styles.scoped.css +10 -10
  15. package/app-layout/content-wrapper/styles.selectors.js +3 -3
  16. package/app-layout/drawer/styles.css.js +14 -14
  17. package/app-layout/drawer/styles.scoped.css +34 -34
  18. package/app-layout/drawer/styles.selectors.js +14 -14
  19. package/app-layout/mobile-toolbar/styles.css.js +8 -8
  20. package/app-layout/mobile-toolbar/styles.scoped.css +18 -18
  21. package/app-layout/mobile-toolbar/styles.selectors.js +8 -8
  22. package/app-layout/notifications/styles.css.js +3 -3
  23. package/app-layout/notifications/styles.scoped.css +7 -7
  24. package/app-layout/notifications/styles.selectors.js +3 -3
  25. package/app-layout/resize/styles.css.js +5 -5
  26. package/app-layout/resize/styles.scoped.css +14 -14
  27. package/app-layout/resize/styles.selectors.js +5 -5
  28. package/app-layout/styles.css.js +12 -12
  29. package/app-layout/styles.scoped.css +21 -21
  30. package/app-layout/styles.selectors.js +12 -12
  31. package/app-layout/toggles/styles.css.js +2 -2
  32. package/app-layout/toggles/styles.scoped.css +20 -20
  33. package/app-layout/toggles/styles.selectors.js +2 -2
  34. package/app-layout/visual-refresh/styles.css.js +86 -86
  35. package/app-layout/visual-refresh/styles.scoped.css +263 -263
  36. package/app-layout/visual-refresh/styles.selectors.js +86 -86
  37. package/app-layout/visual-refresh-toolbar/drawer/styles.css.js +10 -10
  38. package/app-layout/visual-refresh-toolbar/drawer/styles.scoped.css +15 -15
  39. package/app-layout/visual-refresh-toolbar/drawer/styles.selectors.js +10 -10
  40. package/app-layout/visual-refresh-toolbar/navigation/styles.css.js +4 -4
  41. package/app-layout/visual-refresh-toolbar/navigation/styles.scoped.css +7 -7
  42. package/app-layout/visual-refresh-toolbar/navigation/styles.selectors.js +4 -4
  43. package/app-layout/visual-refresh-toolbar/notifications/styles.css.js +3 -3
  44. package/app-layout/visual-refresh-toolbar/notifications/styles.scoped.css +5 -5
  45. package/app-layout/visual-refresh-toolbar/notifications/styles.selectors.js +3 -3
  46. package/app-layout/visual-refresh-toolbar/skeleton/index.d.ts.map +1 -1
  47. package/app-layout/visual-refresh-toolbar/skeleton/index.js +23 -21
  48. package/app-layout/visual-refresh-toolbar/skeleton/index.js.map +1 -1
  49. package/app-layout/visual-refresh-toolbar/skeleton/styles.css.js +19 -19
  50. package/app-layout/visual-refresh-toolbar/skeleton/styles.scoped.css +52 -52
  51. package/app-layout/visual-refresh-toolbar/skeleton/styles.selectors.js +19 -19
  52. package/app-layout/visual-refresh-toolbar/toolbar/styles.css.js +13 -13
  53. package/app-layout/visual-refresh-toolbar/toolbar/styles.scoped.css +29 -29
  54. package/app-layout/visual-refresh-toolbar/toolbar/styles.selectors.js +13 -13
  55. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.css.js +7 -7
  56. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.scoped.css +38 -38
  57. package/app-layout/visual-refresh-toolbar/toolbar/trigger-button/styles.selectors.js +7 -7
  58. package/area-chart/elements/area-chart-filter.d.ts.map +1 -1
  59. package/area-chart/elements/area-chart-filter.js +6 -1
  60. package/area-chart/elements/area-chart-filter.js.map +1 -1
  61. package/area-chart/elements/area-chart-legend.d.ts.map +1 -1
  62. package/area-chart/elements/area-chart-legend.js +2 -1
  63. package/area-chart/elements/area-chart-legend.js.map +1 -1
  64. package/area-chart/elements/chart-popover.d.ts.map +1 -1
  65. package/area-chart/elements/chart-popover.js +2 -4
  66. package/area-chart/elements/chart-popover.js.map +1 -1
  67. package/area-chart/styles.css.js +6 -6
  68. package/area-chart/styles.scoped.css +16 -16
  69. package/area-chart/styles.selectors.js +6 -6
  70. package/attribute-editor/styles.css.js +15 -15
  71. package/attribute-editor/styles.scoped.css +44 -44
  72. package/attribute-editor/styles.selectors.js +15 -15
  73. package/badge/styles.css.js +10 -10
  74. package/badge/styles.scoped.css +38 -38
  75. package/badge/styles.selectors.js +10 -10
  76. package/box/styles.css.js +191 -191
  77. package/box/styles.scoped.css +445 -445
  78. package/box/styles.selectors.js +191 -191
  79. package/breadcrumb-group/item/styles.css.js +7 -7
  80. package/breadcrumb-group/item/styles.scoped.css +39 -39
  81. package/breadcrumb-group/item/styles.selectors.js +7 -7
  82. package/breadcrumb-group/styles.css.js +14 -14
  83. package/breadcrumb-group/styles.scoped.css +54 -54
  84. package/breadcrumb-group/styles.selectors.js +14 -14
  85. package/button/styles.css.js +22 -22
  86. package/button/styles.scoped.css +196 -196
  87. package/button/styles.selectors.js +22 -22
  88. package/button-dropdown/category-elements/expandable-category-element.d.ts.map +1 -1
  89. package/button-dropdown/category-elements/expandable-category-element.js +3 -0
  90. package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
  91. package/button-dropdown/category-elements/styles.css.js +15 -14
  92. package/button-dropdown/category-elements/styles.scoped.css +53 -51
  93. package/button-dropdown/category-elements/styles.selectors.js +15 -14
  94. package/button-dropdown/item-element/index.d.ts.map +1 -1
  95. package/button-dropdown/item-element/index.js +3 -0
  96. package/button-dropdown/item-element/index.js.map +1 -1
  97. package/button-dropdown/item-element/styles.css.js +16 -15
  98. package/button-dropdown/item-element/styles.scoped.css +60 -58
  99. package/button-dropdown/item-element/styles.selectors.js +16 -15
  100. package/button-dropdown/mobile-expandable-group/styles.css.js +5 -5
  101. package/button-dropdown/mobile-expandable-group/styles.scoped.css +10 -10
  102. package/button-dropdown/mobile-expandable-group/styles.selectors.js +5 -5
  103. package/button-dropdown/styles.css.js +21 -21
  104. package/button-dropdown/styles.scoped.css +43 -43
  105. package/button-dropdown/styles.selectors.js +21 -21
  106. package/button-group/styles.css.js +4 -4
  107. package/button-group/styles.scoped.css +12 -12
  108. package/button-group/styles.selectors.js +4 -4
  109. package/calendar/styles.css.js +21 -21
  110. package/calendar/styles.scoped.css +128 -128
  111. package/calendar/styles.selectors.js +21 -21
  112. package/cards/styles.css.js +39 -39
  113. package/cards/styles.scoped.css +112 -112
  114. package/cards/styles.selectors.js +39 -39
  115. package/checkbox/styles.css.js +3 -3
  116. package/checkbox/styles.scoped.css +19 -19
  117. package/checkbox/styles.selectors.js +3 -3
  118. package/code-editor/resizable-box/styles.css.js +4 -4
  119. package/code-editor/resizable-box/styles.scoped.css +9 -9
  120. package/code-editor/resizable-box/styles.selectors.js +4 -4
  121. package/code-editor/styles.css.js +33 -33
  122. package/code-editor/styles.scoped.css +256 -256
  123. package/code-editor/styles.selectors.js +33 -33
  124. package/collection-preferences/content-display/styles.css.js +11 -11
  125. package/collection-preferences/content-display/styles.scoped.css +34 -34
  126. package/collection-preferences/content-display/styles.selectors.js +11 -11
  127. package/collection-preferences/styles.css.js +38 -38
  128. package/collection-preferences/styles.scoped.css +75 -75
  129. package/collection-preferences/styles.selectors.js +38 -38
  130. package/column-layout/flexible-column-layout/styles.css.js +5 -5
  131. package/column-layout/flexible-column-layout/styles.scoped.css +13 -13
  132. package/column-layout/flexible-column-layout/styles.selectors.js +5 -5
  133. package/column-layout/styles.css.js +13 -13
  134. package/column-layout/styles.scoped.css +58 -58
  135. package/column-layout/styles.selectors.js +13 -13
  136. package/container/styles.css.js +33 -33
  137. package/container/styles.scoped.css +127 -127
  138. package/container/styles.selectors.js +33 -33
  139. package/content-layout/styles.css.js +14 -14
  140. package/content-layout/styles.scoped.css +27 -27
  141. package/content-layout/styles.selectors.js +14 -14
  142. package/copy-to-clipboard/styles.css.js +3 -3
  143. package/copy-to-clipboard/styles.scoped.css +4 -4
  144. package/copy-to-clipboard/styles.selectors.js +3 -3
  145. package/date-picker/styles.css.js +7 -7
  146. package/date-picker/styles.scoped.css +19 -19
  147. package/date-picker/styles.selectors.js +7 -7
  148. package/date-range-picker/calendar/grids/styles.css.js +30 -30
  149. package/date-range-picker/calendar/grids/styles.scoped.css +124 -124
  150. package/date-range-picker/calendar/grids/styles.selectors.js +30 -30
  151. package/date-range-picker/relative-range/styles.css.js +6 -6
  152. package/date-range-picker/relative-range/styles.scoped.css +13 -13
  153. package/date-range-picker/relative-range/styles.selectors.js +6 -6
  154. package/date-range-picker/styles.css.js +23 -23
  155. package/date-range-picker/styles.scoped.css +69 -69
  156. package/date-range-picker/styles.selectors.js +23 -23
  157. package/drawer/implementation.d.ts +1 -1
  158. package/drawer/implementation.d.ts.map +1 -1
  159. package/drawer/implementation.js +2 -2
  160. package/drawer/implementation.js.map +1 -1
  161. package/drawer/interfaces.d.ts +4 -0
  162. package/drawer/interfaces.d.ts.map +1 -1
  163. package/drawer/interfaces.js.map +1 -1
  164. package/drawer/styles.css.js +5 -5
  165. package/drawer/styles.scoped.css +32 -33
  166. package/drawer/styles.selectors.js +5 -5
  167. package/expandable-section/internal.d.ts +1 -2
  168. package/expandable-section/internal.d.ts.map +1 -1
  169. package/expandable-section/internal.js +2 -1
  170. package/expandable-section/internal.js.map +1 -1
  171. package/expandable-section/styles.css.js +34 -34
  172. package/expandable-section/styles.scoped.css +127 -127
  173. package/expandable-section/styles.selectors.js +34 -34
  174. package/file-dropzone/styles.css.js +3 -3
  175. package/file-dropzone/styles.scoped.css +19 -19
  176. package/file-dropzone/styles.selectors.js +3 -3
  177. package/file-input/styles.css.js +6 -6
  178. package/file-input/styles.scoped.css +29 -29
  179. package/file-input/styles.selectors.js +6 -6
  180. package/file-token-group/styles.css.js +22 -22
  181. package/file-token-group/styles.scoped.css +69 -69
  182. package/file-token-group/styles.selectors.js +22 -22
  183. package/file-upload/styles.css.js +2 -2
  184. package/file-upload/styles.scoped.css +4 -4
  185. package/file-upload/styles.selectors.js +2 -2
  186. package/flashbar/analytics-metadata/interfaces.d.ts +12 -1
  187. package/flashbar/analytics-metadata/interfaces.d.ts.map +1 -1
  188. package/flashbar/analytics-metadata/interfaces.js.map +1 -1
  189. package/flashbar/collapsible-flashbar.d.ts.map +1 -1
  190. package/flashbar/collapsible-flashbar.js +1 -2
  191. package/flashbar/collapsible-flashbar.js.map +1 -1
  192. package/flashbar/styles.css.js +50 -50
  193. package/flashbar/styles.scoped.css +253 -253
  194. package/flashbar/styles.selectors.js +50 -50
  195. package/form/styles.css.js +8 -8
  196. package/form/styles.scoped.css +20 -20
  197. package/form/styles.selectors.js +8 -8
  198. package/form-field/styles.css.js +24 -24
  199. package/form-field/styles.scoped.css +67 -67
  200. package/form-field/styles.selectors.js +24 -24
  201. package/grid/styles.css.js +53 -53
  202. package/grid/styles.scoped.css +62 -62
  203. package/grid/styles.selectors.js +53 -53
  204. package/header/styles.css.js +34 -34
  205. package/header/styles.scoped.css +126 -126
  206. package/header/styles.selectors.js +34 -34
  207. package/help-panel/styles.css.js +6 -6
  208. package/help-panel/styles.scoped.css +172 -172
  209. package/help-panel/styles.selectors.js +6 -6
  210. package/hotspot/styles.css.js +7 -7
  211. package/hotspot/styles.scoped.css +10 -10
  212. package/hotspot/styles.selectors.js +7 -7
  213. package/icon/styles.css.js +39 -39
  214. package/icon/styles.scoped.css +125 -125
  215. package/icon/styles.selectors.js +39 -39
  216. package/input/styles.css.js +13 -13
  217. package/input/styles.scoped.css +95 -95
  218. package/input/styles.selectors.js +13 -13
  219. package/internal/base-component/styles.scoped.css +1912 -1893
  220. package/internal/components/abstract-switch/styles.css.js +13 -13
  221. package/internal/components/abstract-switch/styles.scoped.css +28 -28
  222. package/internal/components/abstract-switch/styles.selectors.js +13 -13
  223. package/internal/components/button-trigger/styles.css.js +13 -13
  224. package/internal/components/button-trigger/styles.scoped.css +91 -89
  225. package/internal/components/button-trigger/styles.selectors.js +13 -13
  226. package/internal/components/cartesian-chart/styles.css.js +28 -28
  227. package/internal/components/cartesian-chart/styles.scoped.css +43 -43
  228. package/internal/components/cartesian-chart/styles.selectors.js +28 -28
  229. package/internal/components/chart-filter/index.d.ts +2 -4
  230. package/internal/components/chart-filter/index.d.ts.map +1 -1
  231. package/internal/components/chart-filter/index.js +1 -3
  232. package/internal/components/chart-filter/index.js.map +1 -1
  233. package/internal/components/chart-filter/styles.css.js +3 -3
  234. package/internal/components/chart-filter/styles.scoped.css +7 -7
  235. package/internal/components/chart-filter/styles.selectors.js +3 -3
  236. package/internal/components/chart-legend/index.d.ts +1 -3
  237. package/internal/components/chart-legend/index.d.ts.map +1 -1
  238. package/internal/components/chart-legend/index.js +1 -2
  239. package/internal/components/chart-legend/index.js.map +1 -1
  240. package/internal/components/chart-legend/styles.css.js +6 -6
  241. package/internal/components/chart-legend/styles.scoped.css +25 -25
  242. package/internal/components/chart-legend/styles.selectors.js +6 -6
  243. package/internal/components/chart-plot/styles.css.js +5 -5
  244. package/internal/components/chart-plot/styles.scoped.css +6 -6
  245. package/internal/components/chart-plot/styles.selectors.js +5 -5
  246. package/internal/components/chart-popover/index.d.ts +6 -2
  247. package/internal/components/chart-popover/index.d.ts.map +1 -1
  248. package/internal/components/chart-popover/index.js +7 -5
  249. package/internal/components/chart-popover/index.js.map +1 -1
  250. package/internal/components/chart-popover/styles.css.js +3 -3
  251. package/internal/components/chart-popover/styles.scoped.css +17 -13
  252. package/internal/components/chart-popover/styles.selectors.js +3 -3
  253. package/internal/components/chart-popover/test-classes/styles.css.js +8 -0
  254. package/internal/components/chart-popover/test-classes/styles.scoped.css +9 -0
  255. package/internal/components/{chart-popover-footer → chart-popover/test-classes}/styles.selectors.js +3 -1
  256. package/internal/components/chart-series-details/index.js +3 -3
  257. package/internal/components/chart-series-details/index.js.map +1 -1
  258. package/internal/components/chart-series-details/series-details-text.d.ts +1 -0
  259. package/internal/components/chart-series-details/series-details-text.d.ts.map +1 -1
  260. package/internal/components/chart-series-details/series-details-text.js +2 -3
  261. package/internal/components/chart-series-details/series-details-text.js.map +1 -1
  262. package/internal/components/chart-series-details/styles.css.js +19 -20
  263. package/internal/components/chart-series-details/styles.scoped.css +55 -59
  264. package/internal/components/chart-series-details/styles.selectors.js +19 -20
  265. package/internal/components/chart-series-marker/styles.css.js +5 -5
  266. package/internal/components/chart-series-marker/styles.scoped.css +14 -14
  267. package/internal/components/chart-series-marker/styles.selectors.js +5 -5
  268. package/internal/components/chart-status-container/styles.css.js +2 -2
  269. package/internal/components/chart-status-container/styles.scoped.css +3 -3
  270. package/internal/components/chart-status-container/styles.selectors.js +2 -2
  271. package/internal/components/chart-wrapper/styles.css.js +9 -9
  272. package/internal/components/chart-wrapper/styles.scoped.css +15 -15
  273. package/internal/components/chart-wrapper/styles.selectors.js +9 -9
  274. package/internal/components/checkbox-icon/index.js +3 -3
  275. package/internal/components/checkbox-icon/index.js.map +1 -1
  276. package/internal/components/checkbox-icon/styles.css.js +9 -9
  277. package/internal/components/checkbox-icon/styles.scoped.css +20 -20
  278. package/internal/components/checkbox-icon/styles.selectors.js +9 -9
  279. package/internal/components/drag-handle/styles.css.js +12 -12
  280. package/internal/components/drag-handle/styles.scoped.css +31 -31
  281. package/internal/components/drag-handle/styles.selectors.js +12 -12
  282. package/internal/components/drag-handle-wrapper/styles.css.js +27 -27
  283. package/internal/components/drag-handle-wrapper/styles.scoped.css +106 -106
  284. package/internal/components/drag-handle-wrapper/styles.selectors.js +27 -27
  285. package/internal/components/dropdown/styles.css.js +20 -20
  286. package/internal/components/dropdown/styles.scoped.css +60 -60
  287. package/internal/components/dropdown/styles.selectors.js +20 -20
  288. package/internal/components/dropdown-footer/styles.css.js +3 -3
  289. package/internal/components/dropdown-footer/styles.scoped.css +9 -9
  290. package/internal/components/dropdown-footer/styles.selectors.js +3 -3
  291. package/internal/components/dropdown-status/styles.css.js +2 -2
  292. package/internal/components/dropdown-status/styles.scoped.css +10 -10
  293. package/internal/components/dropdown-status/styles.selectors.js +2 -2
  294. package/internal/components/menu-dropdown/styles.css.js +7 -7
  295. package/internal/components/menu-dropdown/styles.scoped.css +34 -34
  296. package/internal/components/menu-dropdown/styles.selectors.js +7 -7
  297. package/internal/components/option/styles.css.js +17 -17
  298. package/internal/components/option/styles.scoped.css +47 -47
  299. package/internal/components/option/styles.selectors.js +17 -17
  300. package/internal/components/options-list/styles.css.js +3 -3
  301. package/internal/components/options-list/styles.scoped.css +11 -11
  302. package/internal/components/options-list/styles.selectors.js +3 -3
  303. package/internal/components/panel-resize-handle/styles.css.js +5 -5
  304. package/internal/components/panel-resize-handle/styles.scoped.css +17 -17
  305. package/internal/components/panel-resize-handle/styles.selectors.js +5 -5
  306. package/internal/components/selectable-item/index.d.ts.map +1 -1
  307. package/internal/components/selectable-item/index.js +3 -0
  308. package/internal/components/selectable-item/index.js.map +1 -1
  309. package/internal/components/selectable-item/styles.css.js +21 -20
  310. package/internal/components/selectable-item/styles.scoped.css +99 -97
  311. package/internal/components/selectable-item/styles.selectors.js +21 -20
  312. package/internal/components/sortable-area/styles.css.js +8 -8
  313. package/internal/components/sortable-area/styles.scoped.css +52 -52
  314. package/internal/components/sortable-area/styles.selectors.js +8 -8
  315. package/internal/components/token-list/styles.css.js +10 -10
  316. package/internal/components/token-list/styles.scoped.css +48 -48
  317. package/internal/components/token-list/styles.selectors.js +10 -10
  318. package/internal/do-not-use/chart-filter.d.ts +4 -0
  319. package/internal/do-not-use/chart-filter.d.ts.map +1 -0
  320. package/internal/do-not-use/chart-filter.js +5 -0
  321. package/internal/do-not-use/chart-filter.js.map +1 -0
  322. package/internal/do-not-use/chart-tooltip.d.ts +4 -0
  323. package/internal/do-not-use/chart-tooltip.d.ts.map +1 -0
  324. package/internal/do-not-use/chart-tooltip.js +5 -0
  325. package/internal/do-not-use/chart-tooltip.js.map +1 -0
  326. package/internal/do-not-use/expandable-section.d.ts +4 -0
  327. package/internal/do-not-use/expandable-section.d.ts.map +1 -0
  328. package/internal/do-not-use/expandable-section.js +5 -0
  329. package/internal/do-not-use/expandable-section.js.map +1 -0
  330. package/internal/do-not-use/i18n.d.ts +2 -0
  331. package/internal/do-not-use/i18n.d.ts.map +1 -0
  332. package/internal/do-not-use/i18n.js +4 -0
  333. package/internal/do-not-use/i18n.js.map +1 -0
  334. package/internal/do-not-use/tooltip.d.ts +4 -0
  335. package/internal/do-not-use/tooltip.d.ts.map +1 -0
  336. package/internal/do-not-use/tooltip.js +5 -0
  337. package/internal/do-not-use/tooltip.js.map +1 -0
  338. package/internal/environment.js +1 -1
  339. package/internal/environment.json +1 -1
  340. package/internal/generated/styles/tokens.d.ts +2 -0
  341. package/internal/generated/styles/tokens.js +755 -753
  342. package/internal/generated/theming/index.cjs +817 -773
  343. package/internal/generated/theming/index.cjs.d.ts +255 -0
  344. package/internal/generated/theming/index.d.ts +255 -0
  345. package/internal/generated/theming/index.js +817 -773
  346. package/internal/manifest.json +1 -1
  347. package/internal/tooltip-do-not-use/index.d.ts.map +1 -1
  348. package/internal/tooltip-do-not-use/index.js.map +1 -1
  349. package/key-value-pairs/styles.css.js +8 -8
  350. package/key-value-pairs/styles.scoped.css +27 -27
  351. package/key-value-pairs/styles.selectors.js +8 -8
  352. package/link/styles.css.js +20 -20
  353. package/link/styles.scoped.css +150 -150
  354. package/link/styles.selectors.js +20 -20
  355. package/mixed-line-bar-chart/chart-legend.d.ts.map +1 -1
  356. package/mixed-line-bar-chart/chart-legend.js +2 -2
  357. package/mixed-line-bar-chart/chart-legend.js.map +1 -1
  358. package/mixed-line-bar-chart/chart-popover.d.ts.map +1 -1
  359. package/mixed-line-bar-chart/chart-popover.js +2 -4
  360. package/mixed-line-bar-chart/chart-popover.js.map +1 -1
  361. package/mixed-line-bar-chart/internal.d.ts.map +1 -1
  362. package/mixed-line-bar-chart/internal.js +2 -2
  363. package/mixed-line-bar-chart/internal.js.map +1 -1
  364. package/mixed-line-bar-chart/styles.css.js +11 -11
  365. package/mixed-line-bar-chart/styles.scoped.css +22 -22
  366. package/mixed-line-bar-chart/styles.selectors.js +11 -11
  367. package/modal/styles.css.js +23 -23
  368. package/modal/styles.scoped.css +77 -77
  369. package/modal/styles.selectors.js +23 -23
  370. package/multiselect/styles.css.js +3 -3
  371. package/multiselect/styles.scoped.css +12 -12
  372. package/multiselect/styles.selectors.js +3 -3
  373. package/package.json +8 -1
  374. package/pagination/styles.css.js +9 -9
  375. package/pagination/styles.scoped.css +53 -53
  376. package/pagination/styles.selectors.js +9 -9
  377. package/pie-chart/index.d.ts.map +1 -1
  378. package/pie-chart/index.js +2 -2
  379. package/pie-chart/index.js.map +1 -1
  380. package/pie-chart/pie-chart.d.ts.map +1 -1
  381. package/pie-chart/pie-chart.js +1 -4
  382. package/pie-chart/pie-chart.js.map +1 -1
  383. package/pie-chart/styles.css.js +27 -27
  384. package/pie-chart/styles.scoped.css +72 -72
  385. package/pie-chart/styles.selectors.js +27 -27
  386. package/popover/body.d.ts +1 -1
  387. package/popover/body.d.ts.map +1 -1
  388. package/popover/body.js +1 -1
  389. package/popover/body.js.map +1 -1
  390. package/popover/container.d.ts +5 -2
  391. package/popover/container.d.ts.map +1 -1
  392. package/popover/container.js +15 -5
  393. package/popover/container.js.map +1 -1
  394. package/popover/styles.css.js +56 -54
  395. package/popover/styles.scoped.css +152 -140
  396. package/popover/styles.selectors.js +56 -54
  397. package/popover/use-popover-position.d.ts +3 -2
  398. package/popover/use-popover-position.d.ts.map +1 -1
  399. package/popover/use-popover-position.js +12 -6
  400. package/popover/use-popover-position.js.map +1 -1
  401. package/popover/utils/positions.d.ts +2 -1
  402. package/popover/utils/positions.d.ts.map +1 -1
  403. package/popover/utils/positions.js +10 -4
  404. package/popover/utils/positions.js.map +1 -1
  405. package/progress-bar/styles.css.js +19 -19
  406. package/progress-bar/styles.scoped.css +56 -56
  407. package/progress-bar/styles.selectors.js +19 -19
  408. package/prompt-input/styles.css.js +15 -15
  409. package/prompt-input/styles.scoped.css +149 -149
  410. package/prompt-input/styles.selectors.js +15 -15
  411. package/property-filter/filtering-token/styles.css.js +18 -18
  412. package/property-filter/filtering-token/styles.scoped.css +83 -83
  413. package/property-filter/filtering-token/styles.selectors.js +18 -18
  414. package/property-filter/styles.css.js +39 -39
  415. package/property-filter/styles.scoped.css +102 -102
  416. package/property-filter/styles.selectors.js +39 -39
  417. package/radio-group/radio-button.d.ts.map +1 -1
  418. package/radio-group/radio-button.js +1 -3
  419. package/radio-group/radio-button.js.map +1 -1
  420. package/radio-group/styles.css.js +10 -10
  421. package/radio-group/styles.scoped.css +43 -43
  422. package/radio-group/styles.selectors.js +10 -10
  423. package/s3-resource-selector/s3-in-context/styles.css.js +7 -7
  424. package/s3-resource-selector/s3-in-context/styles.scoped.css +14 -14
  425. package/s3-resource-selector/s3-in-context/styles.selectors.js +7 -7
  426. package/s3-resource-selector/s3-modal/styles.css.js +3 -3
  427. package/s3-resource-selector/s3-modal/styles.scoped.css +7 -7
  428. package/s3-resource-selector/s3-modal/styles.selectors.js +3 -3
  429. package/segmented-control/styles.css.js +16 -16
  430. package/segmented-control/styles.scoped.css +98 -96
  431. package/segmented-control/styles.selectors.js +16 -16
  432. package/select/parts/styles.css.js +20 -20
  433. package/select/parts/styles.scoped.css +57 -57
  434. package/select/parts/styles.selectors.js +20 -20
  435. package/select/styles.css.js +1 -1
  436. package/select/styles.scoped.css +5 -5
  437. package/select/styles.selectors.js +1 -1
  438. package/side-navigation/styles.css.js +30 -30
  439. package/side-navigation/styles.scoped.css +106 -106
  440. package/side-navigation/styles.selectors.js +30 -30
  441. package/slider/styles.css.js +26 -26
  442. package/slider/styles.scoped.css +198 -198
  443. package/slider/styles.selectors.js +26 -26
  444. package/space-between/styles.css.js +23 -23
  445. package/space-between/styles.scoped.css +40 -40
  446. package/space-between/styles.selectors.js +23 -23
  447. package/spinner/styles.css.js +13 -13
  448. package/spinner/styles.scoped.css +36 -36
  449. package/spinner/styles.selectors.js +13 -13
  450. package/split-panel/icons/styles.css.js +22 -22
  451. package/split-panel/icons/styles.scoped.css +47 -47
  452. package/split-panel/icons/styles.selectors.js +22 -22
  453. package/split-panel/styles.css.js +27 -27
  454. package/split-panel/styles.scoped.css +85 -85
  455. package/split-panel/styles.selectors.js +27 -27
  456. package/status-indicator/styles.css.js +23 -23
  457. package/status-indicator/styles.scoped.css +48 -48
  458. package/status-indicator/styles.selectors.js +23 -23
  459. package/steps/styles.css.js +6 -6
  460. package/steps/styles.scoped.css +18 -18
  461. package/steps/styles.selectors.js +6 -6
  462. package/table/body-cell/styles.css.js +46 -46
  463. package/table/body-cell/styles.scoped.css +881 -878
  464. package/table/body-cell/styles.selectors.js +46 -46
  465. package/table/expandable-rows/styles.css.js +3 -3
  466. package/table/expandable-rows/styles.scoped.css +33 -33
  467. package/table/expandable-rows/styles.selectors.js +3 -3
  468. package/table/header-cell/styles.css.js +28 -28
  469. package/table/header-cell/styles.scoped.css +198 -198
  470. package/table/header-cell/styles.selectors.js +28 -28
  471. package/table/resizer/styles.css.js +8 -8
  472. package/table/resizer/styles.scoped.css +39 -39
  473. package/table/resizer/styles.selectors.js +8 -8
  474. package/table/selection/styles.css.js +4 -4
  475. package/table/selection/styles.scoped.css +6 -6
  476. package/table/selection/styles.selectors.js +4 -4
  477. package/table/sticky-scrollbar/styles.css.js +6 -6
  478. package/table/sticky-scrollbar/styles.scoped.css +12 -12
  479. package/table/sticky-scrollbar/styles.selectors.js +6 -6
  480. package/table/styles.css.js +34 -34
  481. package/table/styles.scoped.css +88 -88
  482. package/table/styles.selectors.js +34 -34
  483. package/tabs/styles.css.js +30 -30
  484. package/tabs/styles.scoped.css +123 -123
  485. package/tabs/styles.selectors.js +30 -30
  486. package/tag-editor/styles.css.js +3 -3
  487. package/tag-editor/styles.scoped.css +27 -27
  488. package/tag-editor/styles.selectors.js +3 -3
  489. package/test-utils/dom/internal/chart-tooltip.d.ts +9 -0
  490. package/test-utils/dom/internal/chart-tooltip.js +26 -0
  491. package/test-utils/dom/internal/chart-tooltip.js.map +1 -0
  492. package/test-utils/selectors/internal/chart-tooltip.d.ts +9 -0
  493. package/test-utils/selectors/internal/chart-tooltip.js +26 -0
  494. package/test-utils/selectors/internal/chart-tooltip.js.map +1 -0
  495. package/test-utils/tsconfig.tsbuildinfo +1 -1
  496. package/text-content/styles.css.js +1 -1
  497. package/text-content/styles.scoped.css +123 -123
  498. package/text-content/styles.selectors.js +1 -1
  499. package/text-filter/styles.css.js +3 -3
  500. package/text-filter/styles.scoped.css +10 -10
  501. package/text-filter/styles.selectors.js +3 -3
  502. package/textarea/styles.css.js +5 -5
  503. package/textarea/styles.scoped.css +58 -58
  504. package/textarea/styles.selectors.js +5 -5
  505. package/tiles/styles.css.js +30 -30
  506. package/tiles/styles.scoped.css +152 -149
  507. package/tiles/styles.selectors.js +30 -30
  508. package/toggle/styles.css.js +10 -10
  509. package/toggle/styles.scoped.css +36 -36
  510. package/toggle/styles.selectors.js +10 -10
  511. package/toggle-button/styles.css.js +3 -3
  512. package/toggle-button/styles.scoped.css +6 -6
  513. package/toggle-button/styles.selectors.js +3 -3
  514. package/token-group/styles.css.js +8 -8
  515. package/token-group/styles.scoped.css +52 -52
  516. package/token-group/styles.selectors.js +8 -8
  517. package/top-navigation/1.0-beta/styles.css.js +23 -23
  518. package/top-navigation/1.0-beta/styles.scoped.css +78 -78
  519. package/top-navigation/1.0-beta/styles.selectors.js +23 -23
  520. package/top-navigation/styles.css.js +47 -47
  521. package/top-navigation/styles.scoped.css +158 -158
  522. package/top-navigation/styles.selectors.js +47 -47
  523. package/tutorial-panel/components/tutorial-detail-view/styles.css.js +20 -20
  524. package/tutorial-panel/components/tutorial-detail-view/styles.scoped.css +43 -43
  525. package/tutorial-panel/components/tutorial-detail-view/styles.selectors.js +20 -20
  526. package/tutorial-panel/components/tutorial-list/styles.css.js +18 -18
  527. package/tutorial-panel/components/tutorial-list/styles.scoped.css +59 -59
  528. package/tutorial-panel/components/tutorial-list/styles.selectors.js +18 -18
  529. package/tutorial-panel/styles.css.js +1 -1
  530. package/tutorial-panel/styles.scoped.css +7 -7
  531. package/tutorial-panel/styles.selectors.js +1 -1
  532. package/wizard/styles.css.js +30 -30
  533. package/wizard/styles.scoped.css +118 -118
  534. package/wizard/styles.selectors.js +30 -30
  535. package/internal/components/chart-popover-footer/index.d.ts +0 -5
  536. package/internal/components/chart-popover-footer/index.d.ts.map +0 -1
  537. package/internal/components/chart-popover-footer/index.js +0 -8
  538. package/internal/components/chart-popover-footer/index.js.map +0 -1
  539. package/internal/components/chart-popover-footer/styles.css.js +0 -6
  540. package/internal/components/chart-popover-footer/styles.scoped.css +0 -19
@@ -2,59 +2,61 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "arrow": "awsui_arrow_xjuzf_t5apl_289",
6
- "arrow-outer": "awsui_arrow-outer_xjuzf_t5apl_293",
7
- "arrow-inner": "awsui_arrow-inner_xjuzf_t5apl_293",
8
- "arrow-position-right-top": "awsui_arrow-position-right-top_xjuzf_t5apl_335",
9
- "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_xjuzf_t5apl_335",
10
- "arrow-position-left-top": "awsui_arrow-position-left-top_xjuzf_t5apl_338",
11
- "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_xjuzf_t5apl_338",
12
- "arrow-position-top-center": "awsui_arrow-position-top-center_xjuzf_t5apl_341",
13
- "arrow-position-top-right": "awsui_arrow-position-top-right_xjuzf_t5apl_341",
14
- "arrow-position-top-left": "awsui_arrow-position-top-left_xjuzf_t5apl_341",
15
- "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_xjuzf_t5apl_341",
16
- "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_xjuzf_t5apl_344",
17
- "arrow-position-bottom-right": "awsui_arrow-position-bottom-right_xjuzf_t5apl_344",
18
- "arrow-position-bottom-left": "awsui_arrow-position-bottom-left_xjuzf_t5apl_344",
19
- "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_xjuzf_t5apl_344",
20
- "body": "awsui_body_xjuzf_t5apl_492",
21
- "body-overflow-visible": "awsui_body-overflow-visible_xjuzf_t5apl_528",
22
- "has-dismiss": "awsui_has-dismiss_xjuzf_t5apl_532",
23
- "dismiss": "awsui_dismiss_xjuzf_t5apl_537",
24
- "dismiss-control": "awsui_dismiss-control_xjuzf_t5apl_545",
25
- "header-row": "awsui_header-row_xjuzf_t5apl_549",
26
- "header": "awsui_header_xjuzf_t5apl_549",
27
- "content": "awsui_content_xjuzf_t5apl_574",
28
- "content-overflow-visible": "awsui_content-overflow-visible_xjuzf_t5apl_582",
29
- "container": "awsui_container_xjuzf_t5apl_730",
30
- "container-arrow-position-bottom-left": "awsui_container-arrow-position-bottom-left_xjuzf_t5apl_741",
31
- "container-arrow-position-bottom-center": "awsui_container-arrow-position-bottom-center_xjuzf_t5apl_741",
32
- "container-arrow-position-bottom-right": "awsui_container-arrow-position-bottom-right_xjuzf_t5apl_741",
33
- "container-arrow-position-top-left": "awsui_container-arrow-position-top-left_xjuzf_t5apl_746",
34
- "container-arrow-position-top-center": "awsui_container-arrow-position-top-center_xjuzf_t5apl_746",
35
- "container-arrow-position-top-right": "awsui_container-arrow-position-top-right_xjuzf_t5apl_746",
36
- "container-arrow-position-right-top": "awsui_container-arrow-position-right-top_xjuzf_t5apl_751",
37
- "container-arrow-position-right-bottom": "awsui_container-arrow-position-right-bottom_xjuzf_t5apl_751",
38
- "container-arrow-position-left-top": "awsui_container-arrow-position-left-top_xjuzf_t5apl_756",
39
- "container-arrow-position-left-bottom": "awsui_container-arrow-position-left-bottom_xjuzf_t5apl_756",
40
- "container-body": "awsui_container-body_xjuzf_t5apl_762",
41
- "container-body-variant-annotation": "awsui_container-body-variant-annotation_xjuzf_t5apl_802",
42
- "container-body-size-small": "awsui_container-body-size-small_xjuzf_t5apl_807",
43
- "fixed-width": "awsui_fixed-width_xjuzf_t5apl_810",
44
- "container-body-size-medium": "awsui_container-body-size-medium_xjuzf_t5apl_814",
45
- "container-body-size-large": "awsui_container-body-size-large_xjuzf_t5apl_821",
46
- "container-arrow": "awsui_container-arrow_xjuzf_t5apl_741",
47
- "container-arrow-position-top-responsive": "awsui_container-arrow-position-top-responsive_xjuzf_t5apl_871",
48
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_xjuzf_t5apl_1",
49
- "refresh": "awsui_refresh_xjuzf_t5apl_1065",
50
- "root": "awsui_root_xjuzf_t5apl_1087",
51
- "no-wrap": "awsui_no-wrap_xjuzf_t5apl_1119",
52
- "root-filtering-token": "awsui_root-filtering-token_xjuzf_t5apl_1123",
53
- "trigger": "awsui_trigger_xjuzf_t5apl_1127",
54
- "overflow-ellipsis": "awsui_overflow-ellipsis_xjuzf_t5apl_1134",
55
- "trigger-type-text-inline": "awsui_trigger-type-text-inline_xjuzf_t5apl_1142",
56
- "trigger-type-text": "awsui_trigger-type-text_xjuzf_t5apl_1142",
57
- "trigger-type-filtering-token": "awsui_trigger-type-filtering-token_xjuzf_t5apl_1210",
58
- "popover-inline-content": "awsui_popover-inline-content_xjuzf_t5apl_1214"
5
+ "arrow": "awsui_arrow_xjuzf_bivkc_289",
6
+ "arrow-outer": "awsui_arrow-outer_xjuzf_bivkc_293",
7
+ "arrow-inner": "awsui_arrow-inner_xjuzf_bivkc_293",
8
+ "arrow-position-right-top": "awsui_arrow-position-right-top_xjuzf_bivkc_335",
9
+ "arrow-position-right-bottom": "awsui_arrow-position-right-bottom_xjuzf_bivkc_335",
10
+ "arrow-position-left-top": "awsui_arrow-position-left-top_xjuzf_bivkc_338",
11
+ "arrow-position-left-bottom": "awsui_arrow-position-left-bottom_xjuzf_bivkc_338",
12
+ "arrow-position-top-center": "awsui_arrow-position-top-center_xjuzf_bivkc_341",
13
+ "arrow-position-top-right": "awsui_arrow-position-top-right_xjuzf_bivkc_341",
14
+ "arrow-position-top-left": "awsui_arrow-position-top-left_xjuzf_bivkc_341",
15
+ "arrow-position-top-responsive": "awsui_arrow-position-top-responsive_xjuzf_bivkc_341",
16
+ "arrow-position-bottom-center": "awsui_arrow-position-bottom-center_xjuzf_bivkc_344",
17
+ "arrow-position-bottom-right": "awsui_arrow-position-bottom-right_xjuzf_bivkc_344",
18
+ "arrow-position-bottom-left": "awsui_arrow-position-bottom-left_xjuzf_bivkc_344",
19
+ "arrow-position-bottom-responsive": "awsui_arrow-position-bottom-responsive_xjuzf_bivkc_344",
20
+ "body": "awsui_body_xjuzf_bivkc_492",
21
+ "body-overflow-visible": "awsui_body-overflow-visible_xjuzf_bivkc_528",
22
+ "body-variant-chart": "awsui_body-variant-chart_xjuzf_bivkc_531",
23
+ "has-dismiss": "awsui_has-dismiss_xjuzf_bivkc_536",
24
+ "dismiss": "awsui_dismiss_xjuzf_bivkc_541",
25
+ "dismiss-control": "awsui_dismiss-control_xjuzf_bivkc_549",
26
+ "header-row": "awsui_header-row_xjuzf_bivkc_553",
27
+ "header": "awsui_header_xjuzf_bivkc_553",
28
+ "content": "awsui_content_xjuzf_bivkc_578",
29
+ "content-overflow-visible": "awsui_content-overflow-visible_xjuzf_bivkc_586",
30
+ "container": "awsui_container_xjuzf_bivkc_734",
31
+ "container-arrow-position-bottom-left": "awsui_container-arrow-position-bottom-left_xjuzf_bivkc_745",
32
+ "container-arrow-position-bottom-center": "awsui_container-arrow-position-bottom-center_xjuzf_bivkc_745",
33
+ "container-arrow-position-bottom-right": "awsui_container-arrow-position-bottom-right_xjuzf_bivkc_745",
34
+ "container-arrow-position-top-left": "awsui_container-arrow-position-top-left_xjuzf_bivkc_750",
35
+ "container-arrow-position-top-center": "awsui_container-arrow-position-top-center_xjuzf_bivkc_750",
36
+ "container-arrow-position-top-right": "awsui_container-arrow-position-top-right_xjuzf_bivkc_750",
37
+ "container-arrow-position-right-top": "awsui_container-arrow-position-right-top_xjuzf_bivkc_755",
38
+ "container-arrow-position-right-bottom": "awsui_container-arrow-position-right-bottom_xjuzf_bivkc_755",
39
+ "container-arrow-position-left-top": "awsui_container-arrow-position-left-top_xjuzf_bivkc_760",
40
+ "container-arrow-position-left-bottom": "awsui_container-arrow-position-left-bottom_xjuzf_bivkc_760",
41
+ "container-body": "awsui_container-body_xjuzf_bivkc_766",
42
+ "container-body-variant-annotation": "awsui_container-body-variant-annotation_xjuzf_bivkc_806",
43
+ "container-body-size-small": "awsui_container-body-size-small_xjuzf_bivkc_811",
44
+ "fixed-width": "awsui_fixed-width_xjuzf_bivkc_814",
45
+ "container-body-size-medium": "awsui_container-body-size-medium_xjuzf_bivkc_818",
46
+ "container-body-size-large": "awsui_container-body-size-large_xjuzf_bivkc_825",
47
+ "container-arrow": "awsui_container-arrow_xjuzf_bivkc_745",
48
+ "container-arrow-position-top-responsive": "awsui_container-arrow-position-top-responsive_xjuzf_bivkc_875",
49
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_xjuzf_bivkc_1",
50
+ "refresh": "awsui_refresh_xjuzf_bivkc_1069",
51
+ "root": "awsui_root_xjuzf_bivkc_1091",
52
+ "no-wrap": "awsui_no-wrap_xjuzf_bivkc_1123",
53
+ "root-filtering-token": "awsui_root-filtering-token_xjuzf_bivkc_1127",
54
+ "trigger": "awsui_trigger_xjuzf_bivkc_1131",
55
+ "overflow-ellipsis": "awsui_overflow-ellipsis_xjuzf_bivkc_1138",
56
+ "trigger-type-text-inline": "awsui_trigger-type-text-inline_xjuzf_bivkc_1146",
57
+ "trigger-type-text": "awsui_trigger-type-text_xjuzf_bivkc_1146",
58
+ "trigger-type-filtering-token": "awsui_trigger-type-filtering-token_xjuzf_bivkc_1214",
59
+ "popover-inline-content": "awsui_popover-inline-content_xjuzf_bivkc_1218",
60
+ "hover-area": "awsui_hover-area_xjuzf_bivkc_1222"
59
61
  };
60
62
 
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { InternalPosition, Offset, PopoverProps } from './interfaces';
3
- export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, }: {
3
+ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, getTrack, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, minVisibleBlockSize, }: {
4
4
  popoverRef: React.RefObject<HTMLDivElement | null>;
5
5
  bodyRef: React.RefObject<HTMLDivElement | null>;
6
6
  arrowRef: React.RefObject<HTMLDivElement | null>;
7
- trackRef: React.RefObject<HTMLElement | SVGElement | null>;
7
+ getTrack: () => null | HTMLElement | SVGElement;
8
8
  contentRef: React.RefObject<HTMLDivElement | null>;
9
9
  allowScrollToFit?: boolean;
10
10
  allowVerticalOverflow?: boolean;
@@ -12,6 +12,7 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
12
12
  renderWithPortal?: boolean;
13
13
  keepPosition?: boolean;
14
14
  hideOnOverscroll?: boolean;
15
+ minVisibleBlockSize?: number;
15
16
  }): {
16
17
  updatePositionHandler: (onContentResize?: any) => void;
17
18
  popoverStyle: Partial<Offset>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-popover-position.d.ts","sourceRoot":"","sources":["../../../src/popover/use-popover-position.ts"],"names":[],"mappings":"AAGA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAW7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAQ,MAAM,cAAc,CAAC;AAGzF,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,EAAE;IACD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC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,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACnD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,EAAE,YAAY,CAAC,QAAQ,CAAC;IACzC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;;;;qDAOyC,IAAI;;EA2K7C"}
@@ -6,7 +6,7 @@ import { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolk
6
6
  import { findUpUntilMultiple, isContainingBlock } from '../internal/utils/dom';
7
7
  import { calculateScroll, getFirstScrollableParent, scrollRectangleIntoView, } from '../internal/utils/scrollable-containers';
8
8
  import { calculatePosition, getDimensions, getOffsetDimensions, isCenterOutside } from './utils/positions';
9
- export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trackRef, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, }) {
9
+ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, getTrack, contentRef, allowScrollToFit, allowVerticalOverflow, preferredPosition, renderWithPortal, keepPosition, hideOnOverscroll, minVisibleBlockSize, }) {
10
10
  const previousInternalPositionRef = useRef(null);
11
11
  const [popoverStyle, setPopoverStyle] = useState({});
12
12
  const [internalPosition, setInternalPosition] = useState(null);
@@ -16,7 +16,8 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
16
16
  const scrollableContainerRectRef = useRef(null);
17
17
  const updatePositionHandler = useCallback((onContentResize = false) => {
18
18
  var _a;
19
- if (!trackRef.current || !popoverRef.current || !bodyRef.current || !contentRef.current || !arrowRef.current) {
19
+ const track = getTrack();
20
+ if (!track || !popoverRef.current || !bodyRef.current || !contentRef.current || !arrowRef.current) {
20
21
  return;
21
22
  }
22
23
  // Get important elements
@@ -24,7 +25,6 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
24
25
  const body = bodyRef.current;
25
26
  const arrow = arrowRef.current;
26
27
  const document = popover.ownerDocument;
27
- const track = trackRef.current;
28
28
  // If the popover body isn't being rendered for whatever reason (e.g. "display: none" or JSDOM),
29
29
  // or track does not belong to the document - bail on calculating dimensions.
30
30
  const { offsetWidth, offsetHeight } = getOffsetDimensions(popover);
@@ -80,6 +80,7 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
80
80
  viewport: viewportRect,
81
81
  renderWithPortal,
82
82
  allowVerticalOverflow,
83
+ minVisibleBlockSize,
83
84
  });
84
85
  // Get the position of the popover relative to the containing block.
85
86
  const popoverOffset = toRelativePosition(rect, containingBlockRect);
@@ -109,13 +110,17 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
109
110
  const scrollableParent = getFirstScrollableParent(popover);
110
111
  scrollRectangleIntoView(rect, scrollableParent);
111
112
  }
112
- if (hideOnOverscroll && trackRef.current instanceof HTMLElement) {
113
- const scrollableContainer = getFirstScrollableParent(trackRef.current);
113
+ if (hideOnOverscroll && track instanceof HTMLElement) {
114
+ const scrollableContainer = getFirstScrollableParent(track);
114
115
  if (scrollableContainer) {
115
116
  scrollableContainerRectRef.current = getLogicalBoundingClientRect(scrollableContainer);
116
117
  }
117
118
  }
118
119
  positionHandlerRef.current = () => {
120
+ const track = getTrack();
121
+ if (!track) {
122
+ return;
123
+ }
119
124
  const trackRect = getLogicalBoundingClientRect(track);
120
125
  const newTrackOffset = toRelativePosition(trackRect, containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect);
121
126
  setPopoverStyle({
@@ -130,7 +135,7 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
130
135
  }
131
136
  };
132
137
  }, [
133
- trackRef,
138
+ getTrack,
134
139
  popoverRef,
135
140
  bodyRef,
136
141
  contentRef,
@@ -141,6 +146,7 @@ export default function usePopoverPosition({ popoverRef, bodyRef, arrowRef, trac
141
146
  allowVerticalOverflow,
142
147
  allowScrollToFit,
143
148
  hideOnOverscroll,
149
+ minVisibleBlockSize,
144
150
  ]);
145
151
  return { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling };
146
152
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-popover-position.js","sourceRoot":"","sources":["../../../src/popover/use-popover-position.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3G,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GAajB;IACC,MAAM,2BAA2B,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAA0B,IAAI,CAAC,CAAC;IACxF,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CA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AAY;KACjD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,OAAoB;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,KAAK,MAAM,CAAC;AACvE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { findUpUntilMultiple, isContainingBlock } from '../internal/utils/dom';\nimport {\n calculateScroll,\n getFirstScrollableParent,\n scrollRectangleIntoView,\n} from '../internal/utils/scrollable-containers';\nimport { BoundingBox, InternalPosition, Offset, PopoverProps, Rect } from './interfaces';\nimport { calculatePosition, getDimensions, getOffsetDimensions, isCenterOutside } from './utils/positions';\n\nexport default function usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n trackRef,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n}: {\n popoverRef: React.RefObject<HTMLDivElement | null>;\n bodyRef: React.RefObject<HTMLDivElement | null>;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n trackRef: React.RefObject<HTMLElement | SVGElement | null>;\n contentRef: React.RefObject<HTMLDivElement | null>;\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n preferredPosition: PopoverProps.Position;\n renderWithPortal?: boolean;\n keepPosition?: boolean;\n hideOnOverscroll?: boolean;\n}) {\n const previousInternalPositionRef = useRef<InternalPosition | null>(null);\n const [popoverStyle, setPopoverStyle] = useState<Partial<Offset>>({});\n const [internalPosition, setInternalPosition] = useState<InternalPosition | null>(null);\n const [isOverscrolling, setIsOverscrolling] = useState(false);\n\n // Store the handler in a ref so that it can still be replaced from outside of the listener closure.\n const positionHandlerRef = useRef<() => void>(() => {});\n\n const scrollableContainerRectRef = useRef<Rect | null>(null);\n\n const updatePositionHandler = useCallback(\n (onContentResize = false) => {\n if (!trackRef.current || !popoverRef.current || !bodyRef.current || !contentRef.current || !arrowRef.current) {\n return;\n }\n\n // Get important elements\n const popover = popoverRef.current;\n const body = bodyRef.current;\n const arrow = arrowRef.current;\n const document = popover.ownerDocument;\n const track = trackRef.current;\n\n // If the popover body isn't being rendered for whatever reason (e.g. \"display: none\" or JSDOM),\n // or track does not belong to the document - bail on calculating dimensions.\n const { offsetWidth, offsetHeight } = getOffsetDimensions(popover);\n if (offsetWidth === 0 || offsetHeight === 0 || !nodeContains(document.body, track)) {\n return;\n }\n\n // Imperatively move body off-screen to give it room to expand.\n // Not doing this in React because this recalculation should happen\n // in the span of a single frame without rerendering anything.\n const prevInsetBlockStart = popover.style.insetBlockStart;\n const prevInsetInlineStart = popover.style.insetInlineStart;\n\n popover.style.insetBlockStart = '0';\n popover.style.insetInlineStart = '0';\n // Imperatively remove body styles that can remain from the previous computation.\n body.style.maxBlockSize = '';\n body.style.overflowX = '';\n body.style.overflowY = '';\n\n // Get rects representing key elements\n // Use getComputedStyle for arrowRect to avoid modifications made by transform\n const viewportRect = getViewportRect(document.defaultView!);\n const trackRect = getLogicalBoundingClientRect(track);\n const arrowRect = getDimensions(arrow);\n const { containingBlock, boundary } = findUpUntilMultiple({\n startElement: popover,\n tests: {\n containingBlock: isContainingBlock,\n boundary: (element: HTMLElement) => isContainingBlock(element) || isBoundary(element),\n },\n });\n\n // Rectangle for the containing block, which provides the reference frame for the popover coordinates.\n const containingBlockRect = containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect;\n\n // Rectangle outside of which the popover should not be positioned, because it would be clipped.\n const boundaryRect = boundary ? getLogicalBoundingClientRect(boundary) : getDocumentRect(document);\n\n const bodyBorderWidth = getBorderWidth(body);\n const contentRect = getLogicalBoundingClientRect(contentRef.current);\n const contentBoundingBox = {\n inlineSize: contentRect.inlineSize + 2 * bodyBorderWidth,\n blockSize: contentRect.blockSize + 2 * bodyBorderWidth,\n };\n\n // When keepPosition is true and the recalculation was triggered by a resize of the popover content,\n // we maintain the previously defined internal position,\n // but we still call calculatePosition to know if the popover should be scrollable.\n const shouldKeepPosition = keepPosition && onContentResize && !!previousInternalPositionRef.current;\n const fixedInternalPosition = (shouldKeepPosition && previousInternalPositionRef.current) ?? undefined;\n\n // Calculate the arrow direction and viewport-relative position of the popover.\n const {\n scrollable,\n internalPosition: newInternalPosition,\n rect,\n } = calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger: trackRect,\n arrow: arrowRect,\n body: contentBoundingBox,\n container: boundaryRect,\n viewport: viewportRect,\n renderWithPortal,\n allowVerticalOverflow,\n });\n\n // Get the position of the popover relative to the containing block.\n const popoverOffset = toRelativePosition(rect, containingBlockRect);\n\n // Cache the distance between the trigger and the popover (which stays the same as you scroll),\n // and use that to recalculate the new popover position.\n const trackRelativeOffset = toRelativePosition(popoverOffset, toRelativePosition(trackRect, containingBlockRect));\n\n // Bring back the container to its original position to prevent any flashing.\n popover.style.insetBlockStart = prevInsetBlockStart;\n popover.style.insetInlineStart = prevInsetInlineStart;\n\n // Allow popover body to scroll if can't fit the popover into the container/viewport otherwise.\n if (scrollable) {\n body.style.maxBlockSize = rect.blockSize + 'px';\n body.style.overflowX = 'hidden';\n body.style.overflowY = 'auto';\n }\n\n // Remember the internal position in case we want to keep it later.\n previousInternalPositionRef.current = newInternalPosition;\n setInternalPosition(newInternalPosition);\n\n const shouldScroll = allowScrollToFit && !shouldKeepPosition;\n\n // Position the popover\n const insetBlockStart = shouldScroll\n ? popoverOffset.insetBlockStart + calculateScroll(rect)\n : popoverOffset.insetBlockStart;\n setPopoverStyle({ insetBlockStart, insetInlineStart: popoverOffset.insetInlineStart });\n\n // Scroll if necessary\n if (shouldScroll) {\n const scrollableParent = getFirstScrollableParent(popover);\n scrollRectangleIntoView(rect, scrollableParent);\n }\n\n if (hideOnOverscroll && trackRef.current instanceof HTMLElement) {\n const scrollableContainer = getFirstScrollableParent(trackRef.current);\n if (scrollableContainer) {\n scrollableContainerRectRef.current = getLogicalBoundingClientRect(scrollableContainer);\n }\n }\n\n positionHandlerRef.current = () => {\n const trackRect = getLogicalBoundingClientRect(track);\n\n const newTrackOffset = toRelativePosition(\n trackRect,\n containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect\n );\n\n setPopoverStyle({\n insetBlockStart: newTrackOffset.insetBlockStart + trackRelativeOffset.insetBlockStart,\n insetInlineStart: newTrackOffset.insetInlineStart + trackRelativeOffset.insetInlineStart,\n });\n\n if (hideOnOverscroll && scrollableContainerRectRef.current) {\n // Assuming the arrow tip is at the vertical center of the popover trigger.\n // This is good enough for disabled reason tooltip in select and multiselect.\n // Can be further refined to take the exact arrow position into account if hideOnOverscroll is to be used in other cases.\n setIsOverscrolling(isCenterOutside(trackRect, scrollableContainerRectRef.current));\n }\n };\n },\n [\n trackRef,\n popoverRef,\n bodyRef,\n contentRef,\n arrowRef,\n keepPosition,\n preferredPosition,\n renderWithPortal,\n allowVerticalOverflow,\n allowScrollToFit,\n hideOnOverscroll,\n ]\n );\n return { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling };\n}\n\nfunction getBorderWidth(element: HTMLElement) {\n return parseInt(getComputedStyle(element).borderWidth) || 0;\n}\n\n/**\n * Convert a viewport-relative offset to an element-relative offset.\n */\nfunction toRelativePosition(element: Offset, parent: Offset): Offset {\n return {\n insetBlockStart: element.insetBlockStart - parent.insetBlockStart,\n insetInlineStart: element.insetInlineStart - parent.insetInlineStart,\n };\n}\n\n/**\n * Get a BoundingBox that represents the visible viewport.\n */\nfunction getViewportRect(window: Window): BoundingBox {\n return {\n insetBlockStart: 0,\n insetInlineStart: 0,\n inlineSize: window.visualViewport?.width ?? window.innerWidth,\n blockSize: window.visualViewport?.height ?? window.innerHeight,\n };\n}\n\nfunction getDocumentRect(document: Document): BoundingBox {\n const { insetBlockStart, insetInlineStart } = getLogicalBoundingClientRect(document.documentElement);\n\n return {\n insetBlockStart,\n insetInlineStart,\n inlineSize: document.documentElement.scrollWidth,\n blockSize: document.documentElement.scrollHeight,\n };\n}\n\nfunction isBoundary(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return !!computedStyle.clipPath && computedStyle.clipPath !== 'none';\n}\n"]}
1
+ {"version":3,"file":"use-popover-position.js","sourceRoot":"","sources":["../../../src/popover/use-popover-position.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3G,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,GAcpB;IACC,MAAM,2BAA2B,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAC1E,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAA0B,IAAI,CAAC,CAAC;IACxF,MAAM,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;QACL,eAAe;QACf,gBAAgB;QAChB,UAAU,EAAE,QAAQ,CAAC,eAAe,CAAC,WAAW;QAChD,SAAS,EAAE,QAAQ,CAAC,eAAe,CAAC,YAAY;KACjD,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,OAAoB;IACtC,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,KAAK,MAAM,CAAC;AACvE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useCallback, useRef, useState } from 'react';\n\nimport { nodeContains } from '@cloudscape-design/component-toolkit/dom';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { findUpUntilMultiple, isContainingBlock } from '../internal/utils/dom';\nimport {\n calculateScroll,\n getFirstScrollableParent,\n scrollRectangleIntoView,\n} from '../internal/utils/scrollable-containers';\nimport { BoundingBox, InternalPosition, Offset, PopoverProps, Rect } from './interfaces';\nimport { calculatePosition, getDimensions, getOffsetDimensions, isCenterOutside } from './utils/positions';\n\nexport default function usePopoverPosition({\n popoverRef,\n bodyRef,\n arrowRef,\n getTrack,\n contentRef,\n allowScrollToFit,\n allowVerticalOverflow,\n preferredPosition,\n renderWithPortal,\n keepPosition,\n hideOnOverscroll,\n minVisibleBlockSize,\n}: {\n popoverRef: React.RefObject<HTMLDivElement | null>;\n bodyRef: React.RefObject<HTMLDivElement | null>;\n arrowRef: React.RefObject<HTMLDivElement | null>;\n getTrack: () => null | HTMLElement | SVGElement;\n contentRef: React.RefObject<HTMLDivElement | null>;\n allowScrollToFit?: boolean;\n allowVerticalOverflow?: boolean;\n preferredPosition: PopoverProps.Position;\n renderWithPortal?: boolean;\n keepPosition?: boolean;\n hideOnOverscroll?: boolean;\n minVisibleBlockSize?: number;\n}) {\n const previousInternalPositionRef = useRef<InternalPosition | null>(null);\n const [popoverStyle, setPopoverStyle] = useState<Partial<Offset>>({});\n const [internalPosition, setInternalPosition] = useState<InternalPosition | null>(null);\n const [isOverscrolling, setIsOverscrolling] = useState(false);\n\n // Store the handler in a ref so that it can still be replaced from outside of the listener closure.\n const positionHandlerRef = useRef<() => void>(() => {});\n\n const scrollableContainerRectRef = useRef<Rect | null>(null);\n\n const updatePositionHandler = useCallback(\n (onContentResize = false) => {\n const track = getTrack();\n if (!track || !popoverRef.current || !bodyRef.current || !contentRef.current || !arrowRef.current) {\n return;\n }\n\n // Get important elements\n const popover = popoverRef.current;\n const body = bodyRef.current;\n const arrow = arrowRef.current;\n const document = popover.ownerDocument;\n\n // If the popover body isn't being rendered for whatever reason (e.g. \"display: none\" or JSDOM),\n // or track does not belong to the document - bail on calculating dimensions.\n const { offsetWidth, offsetHeight } = getOffsetDimensions(popover);\n if (offsetWidth === 0 || offsetHeight === 0 || !nodeContains(document.body, track)) {\n return;\n }\n\n // Imperatively move body off-screen to give it room to expand.\n // Not doing this in React because this recalculation should happen\n // in the span of a single frame without rerendering anything.\n const prevInsetBlockStart = popover.style.insetBlockStart;\n const prevInsetInlineStart = popover.style.insetInlineStart;\n\n popover.style.insetBlockStart = '0';\n popover.style.insetInlineStart = '0';\n // Imperatively remove body styles that can remain from the previous computation.\n body.style.maxBlockSize = '';\n body.style.overflowX = '';\n body.style.overflowY = '';\n\n // Get rects representing key elements\n // Use getComputedStyle for arrowRect to avoid modifications made by transform\n const viewportRect = getViewportRect(document.defaultView!);\n const trackRect = getLogicalBoundingClientRect(track);\n const arrowRect = getDimensions(arrow);\n const { containingBlock, boundary } = findUpUntilMultiple({\n startElement: popover,\n tests: {\n containingBlock: isContainingBlock,\n boundary: (element: HTMLElement) => isContainingBlock(element) || isBoundary(element),\n },\n });\n\n // Rectangle for the containing block, which provides the reference frame for the popover coordinates.\n const containingBlockRect = containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect;\n\n // Rectangle outside of which the popover should not be positioned, because it would be clipped.\n const boundaryRect = boundary ? getLogicalBoundingClientRect(boundary) : getDocumentRect(document);\n\n const bodyBorderWidth = getBorderWidth(body);\n const contentRect = getLogicalBoundingClientRect(contentRef.current);\n const contentBoundingBox = {\n inlineSize: contentRect.inlineSize + 2 * bodyBorderWidth,\n blockSize: contentRect.blockSize + 2 * bodyBorderWidth,\n };\n\n // When keepPosition is true and the recalculation was triggered by a resize of the popover content,\n // we maintain the previously defined internal position,\n // but we still call calculatePosition to know if the popover should be scrollable.\n const shouldKeepPosition = keepPosition && onContentResize && !!previousInternalPositionRef.current;\n const fixedInternalPosition = (shouldKeepPosition && previousInternalPositionRef.current) ?? undefined;\n\n // Calculate the arrow direction and viewport-relative position of the popover.\n const {\n scrollable,\n internalPosition: newInternalPosition,\n rect,\n } = calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger: trackRect,\n arrow: arrowRect,\n body: contentBoundingBox,\n container: boundaryRect,\n viewport: viewportRect,\n renderWithPortal,\n allowVerticalOverflow,\n minVisibleBlockSize,\n });\n\n // Get the position of the popover relative to the containing block.\n const popoverOffset = toRelativePosition(rect, containingBlockRect);\n\n // Cache the distance between the trigger and the popover (which stays the same as you scroll),\n // and use that to recalculate the new popover position.\n const trackRelativeOffset = toRelativePosition(popoverOffset, toRelativePosition(trackRect, containingBlockRect));\n\n // Bring back the container to its original position to prevent any flashing.\n popover.style.insetBlockStart = prevInsetBlockStart;\n popover.style.insetInlineStart = prevInsetInlineStart;\n\n // Allow popover body to scroll if can't fit the popover into the container/viewport otherwise.\n if (scrollable) {\n body.style.maxBlockSize = rect.blockSize + 'px';\n body.style.overflowX = 'hidden';\n body.style.overflowY = 'auto';\n }\n\n // Remember the internal position in case we want to keep it later.\n previousInternalPositionRef.current = newInternalPosition;\n setInternalPosition(newInternalPosition);\n\n const shouldScroll = allowScrollToFit && !shouldKeepPosition;\n\n // Position the popover\n const insetBlockStart = shouldScroll\n ? popoverOffset.insetBlockStart + calculateScroll(rect)\n : popoverOffset.insetBlockStart;\n setPopoverStyle({ insetBlockStart, insetInlineStart: popoverOffset.insetInlineStart });\n\n // Scroll if necessary\n if (shouldScroll) {\n const scrollableParent = getFirstScrollableParent(popover);\n scrollRectangleIntoView(rect, scrollableParent);\n }\n\n if (hideOnOverscroll && track instanceof HTMLElement) {\n const scrollableContainer = getFirstScrollableParent(track);\n if (scrollableContainer) {\n scrollableContainerRectRef.current = getLogicalBoundingClientRect(scrollableContainer);\n }\n }\n\n positionHandlerRef.current = () => {\n const track = getTrack();\n if (!track) {\n return;\n }\n const trackRect = getLogicalBoundingClientRect(track);\n\n const newTrackOffset = toRelativePosition(\n trackRect,\n containingBlock ? getLogicalBoundingClientRect(containingBlock) : viewportRect\n );\n\n setPopoverStyle({\n insetBlockStart: newTrackOffset.insetBlockStart + trackRelativeOffset.insetBlockStart,\n insetInlineStart: newTrackOffset.insetInlineStart + trackRelativeOffset.insetInlineStart,\n });\n\n if (hideOnOverscroll && scrollableContainerRectRef.current) {\n // Assuming the arrow tip is at the vertical center of the popover trigger.\n // This is good enough for disabled reason tooltip in select and multiselect.\n // Can be further refined to take the exact arrow position into account if hideOnOverscroll is to be used in other cases.\n setIsOverscrolling(isCenterOutside(trackRect, scrollableContainerRectRef.current));\n }\n };\n },\n [\n getTrack,\n popoverRef,\n bodyRef,\n contentRef,\n arrowRef,\n keepPosition,\n preferredPosition,\n renderWithPortal,\n allowVerticalOverflow,\n allowScrollToFit,\n hideOnOverscroll,\n minVisibleBlockSize,\n ]\n );\n return { updatePositionHandler, popoverStyle, internalPosition, positionHandlerRef, isOverscrolling };\n}\n\nfunction getBorderWidth(element: HTMLElement) {\n return parseInt(getComputedStyle(element).borderWidth) || 0;\n}\n\n/**\n * Convert a viewport-relative offset to an element-relative offset.\n */\nfunction toRelativePosition(element: Offset, parent: Offset): Offset {\n return {\n insetBlockStart: element.insetBlockStart - parent.insetBlockStart,\n insetInlineStart: element.insetInlineStart - parent.insetInlineStart,\n };\n}\n\n/**\n * Get a BoundingBox that represents the visible viewport.\n */\nfunction getViewportRect(window: Window): BoundingBox {\n return {\n insetBlockStart: 0,\n insetInlineStart: 0,\n inlineSize: window.visualViewport?.width ?? window.innerWidth,\n blockSize: window.visualViewport?.height ?? window.innerHeight,\n };\n}\n\nfunction getDocumentRect(document: Document): BoundingBox {\n const { insetBlockStart, insetInlineStart } = getLogicalBoundingClientRect(document.documentElement);\n\n return {\n insetBlockStart,\n insetInlineStart,\n inlineSize: document.documentElement.scrollWidth,\n blockSize: document.documentElement.scrollHeight,\n };\n}\n\nfunction isBoundary(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return !!computedStyle.clipPath && computedStyle.clipPath !== 'none';\n}\n"]}
@@ -12,7 +12,7 @@ export declare function intersectRectangles(rectangles: BoundingBox[]): number |
12
12
  /**
13
13
  * A functions that returns the correct popover position based on screen dimensions.
14
14
  */
15
- export declare function calculatePosition({ preferredPosition, fixedInternalPosition, trigger, arrow, body, container, viewport, renderWithPortal, allowVerticalOverflow, }: {
15
+ export declare function calculatePosition({ preferredPosition, fixedInternalPosition, trigger, arrow, body, container, viewport, renderWithPortal, allowVerticalOverflow, minVisibleBlockSize, }: {
16
16
  preferredPosition: PopoverProps.Position;
17
17
  fixedInternalPosition?: InternalPosition;
18
18
  trigger: BoundingBox;
@@ -22,6 +22,7 @@ export declare function calculatePosition({ preferredPosition, fixedInternalPosi
22
22
  viewport: BoundingBox;
23
23
  renderWithPortal?: boolean;
24
24
  allowVerticalOverflow?: boolean;
25
+ minVisibleBlockSize?: number;
25
26
  }): CalculatedPosition;
26
27
  export declare function getOffsetDimensions(element: HTMLElement): {
27
28
  offsetHeight: number;
@@ -1 +1 @@
1
- {"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../../../../src/popover/utils/positions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG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U,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,IAAI,EAAE,WAAW,CAAC;CACnB;AAUD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,CAiD9E,CAAC;AAqJF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CAG5E;AAID;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,IAAI,EACJ,SAAS,EACT,QAAQ,EAER,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,GACpB,EAAE;IACD,iBAAiB,EAAE,YAAY,CAAC,QAAQ,CAAC;IACzC,qBAAqB,CAAC,EAAE,gBAAgB,CAAC;IACzC,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,WAAW,CAAC;IACvB,QAAQ,EAAE,WAAW,CAAC;IAEtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,GAAG,kBAAkB,CA0DrB;AAmBD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW;;;EAEvD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW;;;EAMjD;AAMD,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,WAKxD"}
@@ -191,7 +191,7 @@ export function intersectRectangles(rectangles) {
191
191
  */
192
192
  export function calculatePosition({ preferredPosition, fixedInternalPosition, trigger, arrow, body, container, viewport,
193
193
  // the popover is only bound by the viewport if it is rendered in a portal
194
- renderWithPortal, allowVerticalOverflow, }) {
194
+ renderWithPortal, allowVerticalOverflow, minVisibleBlockSize, }) {
195
195
  let bestOption = null;
196
196
  // If a fixed internal position is passed, only consider this one.
197
197
  const preferredInternalPositions = fixedInternalPosition
@@ -203,9 +203,15 @@ renderWithPortal, allowVerticalOverflow, }) {
203
203
  const visibleArea = renderWithPortal
204
204
  ? getIntersection([rect, viewport])
205
205
  : getIntersection([rect, viewport, container]);
206
- const fitsWithoutOverflow = visibleArea && visibleArea.inlineSize === body.inlineSize && visibleArea.blockSize === body.blockSize;
207
- if (fitsWithoutOverflow) {
208
- return { internalPosition, rect };
206
+ // When min visible block size is set, the popover is considered fitting the container if the available space
207
+ // is the same or larger than min allowed, even if it means the scrollbar is needed.
208
+ const fitsBlockSize = minVisibleBlockSize === undefined
209
+ ? visibleArea && visibleArea.blockSize === body.blockSize
210
+ : visibleArea && visibleArea.blockSize >= Math.min(body.blockSize, minVisibleBlockSize);
211
+ const fitsInlineSize = visibleArea && visibleArea.inlineSize === body.inlineSize;
212
+ if (fitsBlockSize && fitsInlineSize) {
213
+ const scrollable = visibleArea && visibleArea.blockSize < body.blockSize;
214
+ return { internalPosition, rect: scrollable ? fitIntoContainer(rect, viewport) : rect, scrollable };
209
215
  }
210
216
  const newOption = { rect, internalPosition, visibleArea };
211
217
  bestOption = getBestOption(newOption, bestOption);
@@ -1 +1 @@
1
- {"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../../src/popover/utils/positions.ts"],"names":[],"mappings":"AAiBA,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAsD;IACjF,GAAG,EAAE;QACH,YAAY;QACZ,WAAW;QACX,UAAU;QACV,eAAe;QACf,cAAc;QACd,aAAa;QACb,WAAW;QACX,cAAc;QACd,UAAU;QACV,aAAa;KACd;IACD,MAAM,EAAE;QACN,eAAe;QACf,cAAc;QACd,aAAa;QACb,YAAY;QACZ,WAAW;QACX,UAAU;QACV,WAAW;QACX,cAAc;QACd,UAAU;QACV,aAAa;KACd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AC,eAAe,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC;IACjE,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC;IAC7D,OAAO,mBAAmB,IAAI,iBAAiB,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BoundingBox, Dimensions, InternalPosition, PopoverProps, Rect } from '../interfaces';\n\n// A structure describing how the popover should be positioned\ninterface CalculatedPosition {\n scrollable?: boolean;\n internalPosition: InternalPosition;\n rect: BoundingBox;\n}\n\ninterface ElementGroup {\n body: Dimensions;\n trigger: BoundingBox;\n arrow: Dimensions;\n}\n\nconst ARROW_OFFSET = 12;\n\nexport const PRIORITY_MAPPING: Record<PopoverProps.Position, InternalPosition[]> = {\n top: [\n 'top-center',\n 'top-right',\n 'top-left',\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n bottom: [\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'top-center',\n 'top-right',\n 'top-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n left: [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-left',\n 'top-left',\n 'bottom-right',\n 'top-right',\n ],\n right: [\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-right',\n 'top-right',\n 'bottom-left',\n 'top-left',\n ],\n};\n\nconst RECTANGLE_CALCULATIONS: Record<InternalPosition, (r: ElementGroup) => BoundingBox> = {\n 'top-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n};\n\nfunction fitIntoContainer(inner: BoundingBox, outer: BoundingBox): BoundingBox {\n let { insetInlineStart, inlineSize, insetBlockStart, blockSize } = inner;\n\n // Adjust left boundary.\n if (insetInlineStart < outer.insetInlineStart) {\n inlineSize = insetInlineStart + inlineSize - outer.insetInlineStart;\n insetInlineStart = outer.insetInlineStart;\n }\n // Adjust right boundary.\n else if (insetInlineStart + inlineSize > outer.insetInlineStart + outer.inlineSize) {\n inlineSize = outer.insetInlineStart + outer.inlineSize - insetInlineStart;\n }\n // Adjust top boundary.\n if (insetBlockStart < outer.insetBlockStart) {\n blockSize = insetBlockStart + blockSize - outer.insetBlockStart;\n insetBlockStart = outer.insetBlockStart;\n }\n // Adjust bottom boundary.\n else if (insetBlockStart + blockSize > outer.insetBlockStart + outer.blockSize) {\n blockSize = outer.insetBlockStart + outer.blockSize - insetBlockStart;\n }\n\n return { insetInlineStart, inlineSize, insetBlockStart, blockSize };\n}\n\nfunction getTallestRect(rect1: BoundingBox, rect2: BoundingBox): BoundingBox {\n return rect1.blockSize >= rect2.blockSize ? rect1 : rect2;\n}\n\nfunction getIntersection(rectangles: BoundingBox[]): BoundingBox | null {\n let boundingBox: BoundingBox | null = null;\n for (const currentRect of rectangles) {\n if (!boundingBox) {\n boundingBox = currentRect;\n continue;\n }\n const insetInlineStart = Math.max(boundingBox.insetInlineStart, currentRect.insetInlineStart);\n const insetBlockStart = Math.max(boundingBox.insetBlockStart, currentRect.insetBlockStart);\n const insetInlineEnd = Math.min(\n boundingBox.insetInlineStart + boundingBox.inlineSize,\n currentRect.insetInlineStart + currentRect.inlineSize\n );\n const insetBlockEnd = Math.min(\n boundingBox.insetBlockStart + boundingBox.blockSize,\n currentRect.insetBlockStart + currentRect.blockSize\n );\n\n if (insetInlineEnd < insetInlineStart || insetBlockEnd < insetBlockStart) {\n return null;\n }\n boundingBox = {\n insetInlineStart,\n insetBlockStart,\n inlineSize: insetInlineEnd - insetInlineStart,\n blockSize: insetBlockEnd - insetBlockStart,\n };\n }\n return boundingBox;\n}\n\n/**\n * Returns the area of the intersection of passed in rectangles or a null, if there is no intersection\n */\nexport function intersectRectangles(rectangles: BoundingBox[]): number | null {\n const boundingBox: BoundingBox | null = getIntersection(rectangles);\n return boundingBox && boundingBox.blockSize * boundingBox.inlineSize;\n}\n\ntype CandidatePosition = CalculatedPosition & { visibleArea: BoundingBox | null };\n\n/**\n * A functions that returns the correct popover position based on screen dimensions.\n */\nexport function calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger,\n arrow,\n body,\n container,\n viewport,\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal,\n allowVerticalOverflow,\n}: {\n preferredPosition: PopoverProps.Position;\n fixedInternalPosition?: InternalPosition;\n trigger: BoundingBox;\n arrow: Dimensions;\n body: Dimensions;\n container: BoundingBox;\n viewport: BoundingBox;\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal?: boolean;\n allowVerticalOverflow?: boolean;\n}): CalculatedPosition {\n let bestOption: CandidatePosition | null = null;\n\n // If a fixed internal position is passed, only consider this one.\n const preferredInternalPositions = fixedInternalPosition\n ? [fixedInternalPosition]\n : PRIORITY_MAPPING[preferredPosition];\n\n // Attempt to position the popover based on the priority list for this position.\n for (const internalPosition of preferredInternalPositions) {\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n const visibleArea = renderWithPortal\n ? getIntersection([rect, viewport])\n : getIntersection([rect, viewport, container]);\n\n const fitsWithoutOverflow =\n visibleArea && visibleArea.inlineSize === body.inlineSize && visibleArea.blockSize === body.blockSize;\n\n if (fitsWithoutOverflow) {\n return { internalPosition, rect };\n }\n\n const newOption = { rect, internalPosition, visibleArea };\n bestOption = getBestOption(newOption, bestOption);\n }\n\n // Use best possible placement.\n const internalPosition = bestOption?.internalPosition || 'right-top';\n // Get default rect for that placement.\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n\n // Get largest possible rect that fits into the viewport or container.\n\n // We allow the popover to overflow the viewport if allowVerticalOverflow is true _and_ the popover will be anchored to the top or the bottom.\n // If it is anchored to the right or left, we consider that it should have enough vertical space so that applying scroll to it is a better option.\n const tallestBoundingContainer = getTallestRect(viewport, container);\n const boundingContainer =\n allowVerticalOverflow && isTopOrBottom(internalPosition)\n ? {\n insetBlockStart: tallestBoundingContainer.insetBlockStart,\n blockSize: tallestBoundingContainer.blockSize,\n insetInlineStart: viewport.insetInlineStart,\n inlineSize: viewport.inlineSize,\n }\n : viewport;\n\n const optimizedRect = fitIntoContainer(rect, boundingContainer);\n\n // If largest possible rect is shorter than original - set body scroll.\n const scrollable = optimizedRect.blockSize < rect.blockSize;\n\n return { internalPosition, rect: optimizedRect, scrollable };\n}\n\nfunction getBestOption(option1: CandidatePosition, option2: CandidatePosition | null) {\n // Within calculatePosition, the only case where option2 will not be defined will be in the first call.\n // The only case where the visibleArea of an option will be null is when the popover is totally outside of the viewport.\n if (!option2?.visibleArea) {\n return option1;\n }\n if (!option1.visibleArea) {\n return option2;\n }\n // Only if none of the two options overflows horizontally, choose the best based on the visible height.\n if (option1.visibleArea.inlineSize === option2.visibleArea.inlineSize) {\n return option1.visibleArea.blockSize > option2.visibleArea.blockSize ? option1 : option2;\n }\n // Otherwise, choose the option that is less cut off horizontally.\n return option1.visibleArea.inlineSize > option2.visibleArea.inlineSize ? option1 : option2;\n}\n\nexport function getOffsetDimensions(element: HTMLElement) {\n return { offsetHeight: element.offsetHeight, offsetWidth: element.offsetWidth };\n}\n\nexport function getDimensions(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return {\n inlineSize: parseFloat(computedStyle.inlineSize),\n blockSize: parseFloat(computedStyle.blockSize),\n };\n}\n\nfunction isTopOrBottom(internalPosition: InternalPosition) {\n return ['top', 'bottom'].includes(internalPosition.split('-')[0]);\n}\n\nexport function isCenterOutside(child: Rect, parent: Rect) {\n const childCenter = child.insetBlockStart + child.blockSize / 2;\n const overflowsBlockStart = childCenter < parent.insetBlockStart;\n const overflowsBlockEnd = childCenter > parent.insetBlockEnd;\n return overflowsBlockStart || overflowsBlockEnd;\n}\n"]}
1
+ {"version":3,"file":"positions.js","sourceRoot":"","sources":["../../../../src/popover/utils/positions.ts"],"names":[],"mappings":"AAiBA,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,CAAC,MAAM,gBAAgB,GAAsD;IACjF,GAAG,EAAE;QACH,YAAY;QACZ,WAAW;QACX,UAAU;QACV,eAAe;QACf,cAAc;QACd,aAAa;QACb,WAAW;QACX,cAAc;QACd,UAAU;QACV,aAAa;KACd;IACD,MAAM,EAAE;QACN,eAAe;QACf,cAAc;QACd,aAAa;QACb,YAAY;QACZ,WAAW;QACX,UAAU;QACV,WAAW;QACX,cAAc;QACd,UAAU;QACV,aAAa;KACd;IACD,IAAI,EAAE;QACJ,UAAU;QACV,aAAa;QACb,WAAW;QACX,cAAc;QACd,eAAe;QACf,YAAY;QACZ,aAAa;QACb,UAAU;Q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SAAS,EAAE,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC;KAC/C,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,gBAAkC;IACvD,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAW,EAAE,MAAY;IACvD,MAAM,WAAW,GAAG,KAAK,CAAC,eAAe,GAAG,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,WAAW,GAAG,MAAM,CAAC,eAAe,CAAC;IACjE,MAAM,iBAAiB,GAAG,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC;IAC7D,OAAO,mBAAmB,IAAI,iBAAiB,CAAC;AAClD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { BoundingBox, Dimensions, InternalPosition, PopoverProps, Rect } from '../interfaces';\n\n// A structure describing how the popover should be positioned\ninterface CalculatedPosition {\n scrollable?: boolean;\n internalPosition: InternalPosition;\n rect: BoundingBox;\n}\n\ninterface ElementGroup {\n body: Dimensions;\n trigger: BoundingBox;\n arrow: Dimensions;\n}\n\nconst ARROW_OFFSET = 12;\n\nexport const PRIORITY_MAPPING: Record<PopoverProps.Position, InternalPosition[]> = {\n top: [\n 'top-center',\n 'top-right',\n 'top-left',\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n bottom: [\n 'bottom-center',\n 'bottom-right',\n 'bottom-left',\n 'top-center',\n 'top-right',\n 'top-left',\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n ],\n left: [\n 'left-top',\n 'left-bottom',\n 'right-top',\n 'right-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-left',\n 'top-left',\n 'bottom-right',\n 'top-right',\n ],\n right: [\n 'right-top',\n 'right-bottom',\n 'left-top',\n 'left-bottom',\n 'bottom-center',\n 'top-center',\n 'bottom-right',\n 'top-right',\n 'bottom-left',\n 'top-left',\n ],\n};\n\nconst RECTANGLE_CALCULATIONS: Record<InternalPosition, (r: ElementGroup) => BoundingBox> = {\n 'top-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'top-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart - body.blockSize - arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-center': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - body.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-right': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize / 2 - ARROW_OFFSET - arrow.inlineSize / 2,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'bottom-left': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize + arrow.blockSize,\n insetInlineStart:\n trigger.insetInlineStart + trigger.inlineSize / 2 + ARROW_OFFSET + arrow.inlineSize / 2 - body.inlineSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'right-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart + trigger.inlineSize + arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-top': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart: trigger.insetBlockStart + trigger.blockSize / 2 - ARROW_OFFSET - arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n 'left-bottom': ({ body, trigger, arrow }) => {\n return {\n insetBlockStart:\n trigger.insetBlockStart + trigger.blockSize / 2 - body.blockSize + ARROW_OFFSET + arrow.blockSize,\n insetInlineStart: trigger.insetInlineStart - body.inlineSize - arrow.blockSize,\n inlineSize: body.inlineSize,\n blockSize: body.blockSize,\n };\n },\n};\n\nfunction fitIntoContainer(inner: BoundingBox, outer: BoundingBox): BoundingBox {\n let { insetInlineStart, inlineSize, insetBlockStart, blockSize } = inner;\n\n // Adjust left boundary.\n if (insetInlineStart < outer.insetInlineStart) {\n inlineSize = insetInlineStart + inlineSize - outer.insetInlineStart;\n insetInlineStart = outer.insetInlineStart;\n }\n // Adjust right boundary.\n else if (insetInlineStart + inlineSize > outer.insetInlineStart + outer.inlineSize) {\n inlineSize = outer.insetInlineStart + outer.inlineSize - insetInlineStart;\n }\n // Adjust top boundary.\n if (insetBlockStart < outer.insetBlockStart) {\n blockSize = insetBlockStart + blockSize - outer.insetBlockStart;\n insetBlockStart = outer.insetBlockStart;\n }\n // Adjust bottom boundary.\n else if (insetBlockStart + blockSize > outer.insetBlockStart + outer.blockSize) {\n blockSize = outer.insetBlockStart + outer.blockSize - insetBlockStart;\n }\n\n return { insetInlineStart, inlineSize, insetBlockStart, blockSize };\n}\n\nfunction getTallestRect(rect1: BoundingBox, rect2: BoundingBox): BoundingBox {\n return rect1.blockSize >= rect2.blockSize ? rect1 : rect2;\n}\n\nfunction getIntersection(rectangles: BoundingBox[]): BoundingBox | null {\n let boundingBox: BoundingBox | null = null;\n for (const currentRect of rectangles) {\n if (!boundingBox) {\n boundingBox = currentRect;\n continue;\n }\n const insetInlineStart = Math.max(boundingBox.insetInlineStart, currentRect.insetInlineStart);\n const insetBlockStart = Math.max(boundingBox.insetBlockStart, currentRect.insetBlockStart);\n const insetInlineEnd = Math.min(\n boundingBox.insetInlineStart + boundingBox.inlineSize,\n currentRect.insetInlineStart + currentRect.inlineSize\n );\n const insetBlockEnd = Math.min(\n boundingBox.insetBlockStart + boundingBox.blockSize,\n currentRect.insetBlockStart + currentRect.blockSize\n );\n\n if (insetInlineEnd < insetInlineStart || insetBlockEnd < insetBlockStart) {\n return null;\n }\n boundingBox = {\n insetInlineStart,\n insetBlockStart,\n inlineSize: insetInlineEnd - insetInlineStart,\n blockSize: insetBlockEnd - insetBlockStart,\n };\n }\n return boundingBox;\n}\n\n/**\n * Returns the area of the intersection of passed in rectangles or a null, if there is no intersection\n */\nexport function intersectRectangles(rectangles: BoundingBox[]): number | null {\n const boundingBox: BoundingBox | null = getIntersection(rectangles);\n return boundingBox && boundingBox.blockSize * boundingBox.inlineSize;\n}\n\ntype CandidatePosition = CalculatedPosition & { visibleArea: BoundingBox | null };\n\n/**\n * A functions that returns the correct popover position based on screen dimensions.\n */\nexport function calculatePosition({\n preferredPosition,\n fixedInternalPosition,\n trigger,\n arrow,\n body,\n container,\n viewport,\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal,\n allowVerticalOverflow,\n minVisibleBlockSize,\n}: {\n preferredPosition: PopoverProps.Position;\n fixedInternalPosition?: InternalPosition;\n trigger: BoundingBox;\n arrow: Dimensions;\n body: Dimensions;\n container: BoundingBox;\n viewport: BoundingBox;\n // the popover is only bound by the viewport if it is rendered in a portal\n renderWithPortal?: boolean;\n allowVerticalOverflow?: boolean;\n minVisibleBlockSize?: number;\n}): CalculatedPosition {\n let bestOption: CandidatePosition | null = null;\n\n // If a fixed internal position is passed, only consider this one.\n const preferredInternalPositions = fixedInternalPosition\n ? [fixedInternalPosition]\n : PRIORITY_MAPPING[preferredPosition];\n\n // Attempt to position the popover based on the priority list for this position.\n for (const internalPosition of preferredInternalPositions) {\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n const visibleArea = renderWithPortal\n ? getIntersection([rect, viewport])\n : getIntersection([rect, viewport, container]);\n\n // When min visible block size is set, the popover is considered fitting the container if the available space\n // is the same or larger than min allowed, even if it means the scrollbar is needed.\n const fitsBlockSize =\n minVisibleBlockSize === undefined\n ? visibleArea && visibleArea.blockSize === body.blockSize\n : visibleArea && visibleArea.blockSize >= Math.min(body.blockSize, minVisibleBlockSize);\n const fitsInlineSize = visibleArea && visibleArea.inlineSize === body.inlineSize;\n\n if (fitsBlockSize && fitsInlineSize) {\n const scrollable = visibleArea && visibleArea.blockSize < body.blockSize;\n return { internalPosition, rect: scrollable ? fitIntoContainer(rect, viewport) : rect, scrollable };\n }\n\n const newOption = { rect, internalPosition, visibleArea };\n bestOption = getBestOption(newOption, bestOption);\n }\n\n // Use best possible placement.\n const internalPosition = bestOption?.internalPosition || 'right-top';\n // Get default rect for that placement.\n const rect = RECTANGLE_CALCULATIONS[internalPosition]({ body, trigger, arrow });\n\n // Get largest possible rect that fits into the viewport or container.\n\n // We allow the popover to overflow the viewport if allowVerticalOverflow is true _and_ the popover will be anchored to the top or the bottom.\n // If it is anchored to the right or left, we consider that it should have enough vertical space so that applying scroll to it is a better option.\n const tallestBoundingContainer = getTallestRect(viewport, container);\n const boundingContainer =\n allowVerticalOverflow && isTopOrBottom(internalPosition)\n ? {\n insetBlockStart: tallestBoundingContainer.insetBlockStart,\n blockSize: tallestBoundingContainer.blockSize,\n insetInlineStart: viewport.insetInlineStart,\n inlineSize: viewport.inlineSize,\n }\n : viewport;\n\n const optimizedRect = fitIntoContainer(rect, boundingContainer);\n\n // If largest possible rect is shorter than original - set body scroll.\n const scrollable = optimizedRect.blockSize < rect.blockSize;\n\n return { internalPosition, rect: optimizedRect, scrollable };\n}\n\nfunction getBestOption(option1: CandidatePosition, option2: CandidatePosition | null) {\n // Within calculatePosition, the only case where option2 will not be defined will be in the first call.\n // The only case where the visibleArea of an option will be null is when the popover is totally outside of the viewport.\n if (!option2?.visibleArea) {\n return option1;\n }\n if (!option1.visibleArea) {\n return option2;\n }\n // Only if none of the two options overflows horizontally, choose the best based on the visible height.\n if (option1.visibleArea.inlineSize === option2.visibleArea.inlineSize) {\n return option1.visibleArea.blockSize > option2.visibleArea.blockSize ? option1 : option2;\n }\n // Otherwise, choose the option that is less cut off horizontally.\n return option1.visibleArea.inlineSize > option2.visibleArea.inlineSize ? option1 : option2;\n}\n\nexport function getOffsetDimensions(element: HTMLElement) {\n return { offsetHeight: element.offsetHeight, offsetWidth: element.offsetWidth };\n}\n\nexport function getDimensions(element: HTMLElement) {\n const computedStyle = getComputedStyle(element);\n return {\n inlineSize: parseFloat(computedStyle.inlineSize),\n blockSize: parseFloat(computedStyle.blockSize),\n };\n}\n\nfunction isTopOrBottom(internalPosition: InternalPosition) {\n return ['top', 'bottom'].includes(internalPosition.split('-')[0]);\n}\n\nexport function isCenterOutside(child: Rect, parent: Rect) {\n const childCenter = child.insetBlockStart + child.blockSize / 2;\n const overflowsBlockStart = childCenter < parent.insetBlockStart;\n const overflowsBlockEnd = childCenter > parent.insetBlockEnd;\n return overflowsBlockStart || overflowsBlockEnd;\n}\n"]}
@@ -1,24 +1,24 @@
1
1
 
2
2
  import './styles.scoped.css';
3
3
  export default {
4
- "progress": "awsui_progress_11huc_1iefd_361",
5
- "result-state": "awsui_result-state_11huc_1iefd_375",
6
- "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_11huc_1iefd_1",
7
- "root": "awsui_root_11huc_1iefd_397",
8
- "with-result-button": "awsui_with-result-button_11huc_1iefd_429",
9
- "result-text": "awsui_result-text_11huc_1iefd_433",
10
- "result-container-error": "awsui_result-container-error_11huc_1iefd_437",
11
- "result-container-success": "awsui_result-container-success_11huc_1iefd_437",
12
- "result-button": "awsui_result-button_11huc_1iefd_441",
13
- "word-wrap": "awsui_word-wrap_11huc_1iefd_447",
14
- "label-flash": "awsui_label-flash_11huc_1iefd_452",
15
- "label-key-value": "awsui_label-key-value_11huc_1iefd_456",
16
- "flash": "awsui_flash_11huc_1iefd_464",
17
- "progress-container": "awsui_progress-container_11huc_1iefd_468",
18
- "percentage-container": "awsui_percentage-container_11huc_1iefd_475",
19
- "percentage": "awsui_percentage_11huc_1iefd_475",
20
- "complete": "awsui_complete_11huc_1iefd_521",
21
- "progress-in-flash": "awsui_progress-in-flash_11huc_1iefd_534",
22
- "additional-info": "awsui_additional-info_11huc_1iefd_547"
4
+ "progress": "awsui_progress_11huc_3hniz_361",
5
+ "result-state": "awsui_result-state_11huc_3hniz_375",
6
+ "awsui-motion-fade-in": "awsui_awsui-motion-fade-in_11huc_3hniz_1",
7
+ "root": "awsui_root_11huc_3hniz_397",
8
+ "with-result-button": "awsui_with-result-button_11huc_3hniz_429",
9
+ "result-text": "awsui_result-text_11huc_3hniz_433",
10
+ "result-container-error": "awsui_result-container-error_11huc_3hniz_437",
11
+ "result-container-success": "awsui_result-container-success_11huc_3hniz_437",
12
+ "result-button": "awsui_result-button_11huc_3hniz_441",
13
+ "word-wrap": "awsui_word-wrap_11huc_3hniz_447",
14
+ "label-flash": "awsui_label-flash_11huc_3hniz_452",
15
+ "label-key-value": "awsui_label-key-value_11huc_3hniz_456",
16
+ "flash": "awsui_flash_11huc_3hniz_464",
17
+ "progress-container": "awsui_progress-container_11huc_3hniz_468",
18
+ "percentage-container": "awsui_percentage-container_11huc_3hniz_475",
19
+ "percentage": "awsui_percentage_11huc_3hniz_475",
20
+ "complete": "awsui_complete_11huc_3hniz_521",
21
+ "progress-in-flash": "awsui_progress-in-flash_11huc_3hniz_534",
22
+ "additional-info": "awsui_additional-info_11huc_3hniz_547"
23
23
  };
24
24