@jimka/typescript-ui 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/dist/lib/{AbstractBooleanInput-C3rj7sje.js → AbstractBooleanInput-BGesvIZy.js} +2 -2
  2. package/dist/lib/{AbstractBooleanInput-C3rj7sje.js.map → AbstractBooleanInput-BGesvIZy.js.map} +1 -1
  3. package/dist/lib/{AbstractInput-CfjW_HM2.js → AbstractInput-BxOtFrER.js} +2 -2
  4. package/dist/lib/{AbstractInput-CfjW_HM2.js.map → AbstractInput-BxOtFrER.js.map} +1 -1
  5. package/dist/lib/AnimatedDropdown-CZQEqQi-.js +2 -0
  6. package/dist/lib/AnimatedDropdown-CZQEqQi-.js.map +1 -0
  7. package/dist/lib/Border-BgaZkc1R.js +2 -0
  8. package/dist/lib/Border-BgaZkc1R.js.map +1 -0
  9. package/dist/lib/{BoxLayout-8ryMD4j5.js → BoxLayout-DrKGfsup.js} +2 -2
  10. package/dist/lib/{BoxLayout-8ryMD4j5.js.map → BoxLayout-DrKGfsup.js.map} +1 -1
  11. package/dist/lib/Button-U1rsP4v8.js +2 -0
  12. package/dist/lib/Button-U1rsP4v8.js.map +1 -0
  13. package/dist/lib/{Card-AKIUAWYS.js → Card-BVwOS8AG.js} +2 -2
  14. package/dist/lib/{Card-AKIUAWYS.js.map → Card-BVwOS8AG.js.map} +1 -1
  15. package/dist/lib/ComboBox-B9EDPu6T.js +2 -0
  16. package/dist/lib/ComboBox-B9EDPu6T.js.map +1 -0
  17. package/dist/lib/Component-DXf5a3g0.js +2 -0
  18. package/dist/lib/Component-DXf5a3g0.js.map +1 -0
  19. package/dist/lib/Container-D5H8VxJK.js +2 -0
  20. package/dist/lib/{Container-3KsvsJ6S.js.map → Container-D5H8VxJK.js.map} +1 -1
  21. package/dist/lib/DOM-CGn7xyTw.js +2 -0
  22. package/dist/lib/DOM-CGn7xyTw.js.map +1 -0
  23. package/dist/lib/{DragManager-c6M_mE3e.js → DragManager-CI4mZQFy.js} +2 -2
  24. package/dist/lib/{DragManager-tPMnbjeO.js.map → DragManager-CI4mZQFy.js.map} +1 -1
  25. package/dist/lib/FieldDecorator-CJs9gwqH.js +2 -0
  26. package/dist/lib/{FieldDecorator-Bl0h9UEF.js.map → FieldDecorator-CJs9gwqH.js.map} +1 -1
  27. package/dist/lib/{Fit-CFIr4P9R.js → Fit-DjRsiwlg.js} +2 -2
  28. package/dist/lib/{Fit-CUS1JXy3.js.map → Fit-DjRsiwlg.js.map} +1 -1
  29. package/dist/lib/Glyph-KEf4nIv2.js +2 -0
  30. package/dist/lib/Glyph-KEf4nIv2.js.map +1 -0
  31. package/dist/lib/{Grid-Czux--Mr.js → Grid-DdL9TVeJ.js} +2 -2
  32. package/dist/lib/{Grid-D8luwRPI.js.map → Grid-DdL9TVeJ.js.map} +1 -1
  33. package/dist/lib/GridConstraints-DkLueyrf.js +2 -0
  34. package/dist/lib/GridConstraints-DkLueyrf.js.map +1 -0
  35. package/dist/lib/{HBox-BWMf9h6r.js → HBox-Ce0GTCJP.js} +2 -2
  36. package/dist/lib/{HBox-BWMf9h6r.js.map → HBox-Ce0GTCJP.js.map} +1 -1
  37. package/dist/lib/{Header-CQjomjo0.js → Header-BQIVpBte.js} +2 -2
  38. package/dist/lib/{Header-CQjomjo0.js.map → Header-BQIVpBte.js.map} +1 -1
  39. package/dist/lib/{IconText-BXJK0MOq.js → IconText-Bo4Qcnot.js} +2 -2
  40. package/dist/lib/{IconText-BXJK0MOq.js.map → IconText-Bo4Qcnot.js.map} +1 -1
  41. package/dist/lib/LayoutConstraints-DkctJZXB.js +2 -0
  42. package/dist/lib/LayoutConstraints-DkctJZXB.js.map +1 -0
  43. package/dist/lib/LayoutSerialization-BT66TY83.js +2 -0
  44. package/dist/lib/LayoutSerialization-BT66TY83.js.map +1 -0
  45. package/dist/lib/LayoutSizes-DU3qSq0w.js +2 -0
  46. package/dist/lib/LayoutSizes-DU3qSq0w.js.map +1 -0
  47. package/dist/lib/List-DtTVTyWW.js +2 -0
  48. package/dist/lib/List-DtTVTyWW.js.map +1 -0
  49. package/dist/lib/Menu-Dz4L7EKJ.js +2 -0
  50. package/dist/lib/Menu-Dz4L7EKJ.js.map +1 -0
  51. package/dist/lib/{MenuButton-D15cSbMf.js → MenuButton-VJ5uC3c1.js} +2 -2
  52. package/dist/lib/{MenuButton-D15cSbMf.js.map → MenuButton-VJ5uC3c1.js.map} +1 -1
  53. package/dist/lib/Panel-DzWdYwq1.js +2 -0
  54. package/dist/lib/Panel-DzWdYwq1.js.map +1 -0
  55. package/dist/lib/{Position-DJKB0N3l.js → Position-A39T7-_1.js} +2 -2
  56. package/dist/lib/{Position-DJKB0N3l.js.map → Position-A39T7-_1.js.map} +1 -1
  57. package/dist/lib/ProgressSpinner-zJKtGyNJ.js +2 -0
  58. package/dist/lib/ProgressSpinner-zJKtGyNJ.js.map +1 -0
  59. package/dist/lib/RadioButton-CYSSv4nV.js +2 -0
  60. package/dist/lib/RadioButton-CYSSv4nV.js.map +1 -0
  61. package/dist/lib/{RovingTabIndex-CFIzIjjU.js → RovingTabIndex-BSZ31Vp5.js} +2 -2
  62. package/dist/lib/{RovingTabIndex-D-zOuptw.js.map → RovingTabIndex-BSZ31Vp5.js.map} +1 -1
  63. package/dist/lib/Scrollbar-BhtOjqkG.js +2 -0
  64. package/dist/lib/Scrollbar-BhtOjqkG.js.map +1 -0
  65. package/dist/lib/Slider-CdXm7E64.js +2 -0
  66. package/dist/lib/Slider-CdXm7E64.js.map +1 -0
  67. package/dist/lib/{Spacer-BVQncB5B.js → Spacer-D9NGW4QG.js} +2 -2
  68. package/dist/lib/{Spacer-BVQncB5B.js.map → Spacer-D9NGW4QG.js.map} +1 -1
  69. package/dist/lib/{TabButton-DqYDfN7P.js → TabButton-CThevdY_.js} +2 -2
  70. package/dist/lib/{TabButton-DqYDfN7P.js.map → TabButton-CThevdY_.js.map} +1 -1
  71. package/dist/lib/Text-gz6qjFfP.js +2 -0
  72. package/dist/lib/Text-gz6qjFfP.js.map +1 -0
  73. package/dist/lib/Tooltip-tkXDk5Bo.js +3 -0
  74. package/dist/lib/Tooltip-tkXDk5Bo.js.map +1 -0
  75. package/dist/lib/{VBox-CdV9VGxR.js → VBox-EIqw85Rh.js} +2 -2
  76. package/dist/lib/{VBox-CdV9VGxR.js.map → VBox-EIqw85Rh.js.map} +1 -1
  77. package/dist/lib/{VirtualRowView-C18j90n5.js → VirtualRowView-BxpHQ_u8.js} +2 -2
  78. package/dist/lib/{VirtualRowView-C18j90n5.js.map → VirtualRowView-BxpHQ_u8.js.map} +1 -1
  79. package/dist/lib/{VirtualScroller-BKMvTisA.js → VirtualScroller-DwEEJE1_.js} +2 -2
  80. package/dist/lib/{VirtualScroller-BKMvTisA.js.map → VirtualScroller-DwEEJE1_.js.map} +1 -1
  81. package/dist/lib/component/button.es.js +1 -1
  82. package/dist/lib/component/button.es.js.map +1 -1
  83. package/dist/lib/component/chart.es.js +1 -1
  84. package/dist/lib/component/chart.es.js.map +1 -1
  85. package/dist/lib/component/container.es.js +1 -1
  86. package/dist/lib/component/container.es.js.map +1 -1
  87. package/dist/lib/component/diagram.es.js +1 -1
  88. package/dist/lib/component/diagram.es.js.map +1 -1
  89. package/dist/lib/component/display.es.js +1 -1
  90. package/dist/lib/component/display.es.js.map +1 -1
  91. package/dist/lib/component/editor.es.js +2 -2
  92. package/dist/lib/component/editor.es.js.map +1 -1
  93. package/dist/lib/component/input.es.js +1 -1
  94. package/dist/lib/component/input.es.js.map +1 -1
  95. package/dist/lib/component/list.es.js +1 -1
  96. package/dist/lib/component/menubar.es.js +1 -1
  97. package/dist/lib/component/menubar.es.js.map +1 -1
  98. package/dist/lib/component/table.es.js +2 -2
  99. package/dist/lib/component/table.es.js.map +1 -1
  100. package/dist/lib/component/tree.es.js +1 -1
  101. package/dist/lib/component/tree.es.js.map +1 -1
  102. package/dist/lib/core.es.js +1 -1
  103. package/dist/lib/core.es.js.map +1 -1
  104. package/dist/lib/layout.es.js +1 -1
  105. package/dist/lib/overlay.es.js +1 -1
  106. package/dist/lib/overlay.es.js.map +1 -1
  107. package/dist/lib/primitive.es.js +1 -1
  108. package/dist/lib/router.es.js +1 -1
  109. package/dist/lib/types/component/button/Button.d.ts +4 -3
  110. package/dist/lib/types/component/chart/AbstractChart.d.ts +1 -1
  111. package/dist/lib/types/component/chart/ChartLegend.d.ts +1 -1
  112. package/dist/lib/types/component/container/DialogBackdrop.d.ts +2 -1
  113. package/dist/lib/types/component/container/MenuItem.d.ts +1 -1
  114. package/dist/lib/types/component/container/ScrollStrip.d.ts +1 -0
  115. package/dist/lib/types/component/container/SplitGutter.d.ts +3 -2
  116. package/dist/lib/types/component/container/TabBar.d.ts +1 -2
  117. package/dist/lib/types/component/container/TabPanel.d.ts +6 -3
  118. package/dist/lib/types/component/container/WindowBorder.d.ts +2 -1
  119. package/dist/lib/types/component/container/WindowHeader.d.ts +2 -1
  120. package/dist/lib/types/component/display/Glyph.d.ts +2 -1
  121. package/dist/lib/types/component/display/Markdown.d.ts +1 -1
  122. package/dist/lib/types/component/display/PaginationBar.d.ts +1 -1
  123. package/dist/lib/types/component/display/SpinnerWrap.d.ts +2 -0
  124. package/dist/lib/types/component/display/Video.d.ts +1 -1
  125. package/dist/lib/types/component/display/VideoPlayer.d.ts +1 -1
  126. package/dist/lib/types/component/editor/CodeEditor.d.ts +2 -1
  127. package/dist/lib/types/component/editor/MarkdownEditor.d.ts +1 -1
  128. package/dist/lib/types/component/input/Checkbox.d.ts +2 -1
  129. package/dist/lib/types/component/input/Link.d.ts +1 -1
  130. package/dist/lib/types/component/input/RadioButton.d.ts +2 -1
  131. package/dist/lib/types/component/input/Slider.d.ts +2 -1
  132. package/dist/lib/types/component/input/Text.d.ts +1 -3
  133. package/dist/lib/types/component/input/TextInput.d.ts +3 -2
  134. package/dist/lib/types/component/list/AbstractSelectableList.d.ts +2 -1
  135. package/dist/lib/types/component/menubar/MenuBarButton.d.ts +1 -1
  136. package/dist/lib/types/core/AnimatedDropdown.d.ts +6 -2
  137. package/dist/lib/types/core/Animation.d.ts +9 -6
  138. package/dist/lib/types/core/Component.d.ts +16 -11
  139. package/dist/lib/types/core/DOM.d.ts +8 -0
  140. package/dist/lib/types/core/Event.d.ts +12 -6
  141. package/dist/lib/types/core/index.d.ts +2 -2
  142. package/dist/lib/types/layout/Accordion.d.ts +2 -0
  143. package/dist/lib/types/layout/Border.d.ts +1 -0
  144. package/dist/lib/types/layout/CollapseSupport.d.ts +5 -1
  145. package/dist/lib/types/layout/LayoutConstraints.d.ts +1 -0
  146. package/dist/lib/types/layout/LayoutManager.d.ts +2 -0
  147. package/dist/lib/types/layout/Split.d.ts +1 -0
  148. package/dist/lib/types/layout/Tab.d.ts +10 -3
  149. package/dist/lib/types/overlay/AbstractWindow.d.ts +9 -2
  150. package/dist/lib/types/overlay/Dialog.d.ts +6 -0
  151. package/dist/lib/types/overlay/Dock.d.ts +12 -2
  152. package/dist/lib/types/overlay/Drawer.d.ts +5 -0
  153. package/dist/lib/types/overlay/Menu.d.ts +3 -1
  154. package/dist/lib/types/overlay/Notification.d.ts +3 -0
  155. package/dist/lib/types/overlay/Popover.d.ts +3 -1
  156. package/dist/lib/types/overlay/Rail.d.ts +7 -0
  157. package/dist/lib/types/overlay/Tooltip.d.ts +3 -0
  158. package/dist/lib/types/overlay/index.d.ts +1 -1
  159. package/dist/lib/validation.es.js +1 -1
  160. package/llms.txt +1 -1
  161. package/package.json +1 -1
  162. package/dist/lib/AbstractBooleanInput-C6CidMMX.js +0 -2
  163. package/dist/lib/AbstractBooleanInput-C6CidMMX.js.map +0 -1
  164. package/dist/lib/AbstractInput-DD-NpicS.js +0 -2
  165. package/dist/lib/AbstractInput-DD-NpicS.js.map +0 -1
  166. package/dist/lib/AnimatedDropdown-BFz-DO7R.js +0 -2
  167. package/dist/lib/AnimatedDropdown-BFz-DO7R.js.map +0 -1
  168. package/dist/lib/AnimatedDropdown-BbGCs70E.js +0 -2
  169. package/dist/lib/AnimatedDropdown-BbGCs70E.js.map +0 -1
  170. package/dist/lib/Border-5Ki2DCWz.js +0 -2
  171. package/dist/lib/Border-5Ki2DCWz.js.map +0 -1
  172. package/dist/lib/Border-oZC_SDy8.js +0 -2
  173. package/dist/lib/Border-oZC_SDy8.js.map +0 -1
  174. package/dist/lib/BoxLayout-DgZukB5_.js +0 -2
  175. package/dist/lib/BoxLayout-DgZukB5_.js.map +0 -1
  176. package/dist/lib/Button-Cdq2ySPL.js +0 -2
  177. package/dist/lib/Button-Cdq2ySPL.js.map +0 -1
  178. package/dist/lib/Button-DEUtBqK4.js +0 -2
  179. package/dist/lib/Button-DEUtBqK4.js.map +0 -1
  180. package/dist/lib/Card-UF0fq8cQ.js +0 -2
  181. package/dist/lib/Card-UF0fq8cQ.js.map +0 -1
  182. package/dist/lib/ComboBox-GOBOAJ1N.js +0 -2
  183. package/dist/lib/ComboBox-GOBOAJ1N.js.map +0 -1
  184. package/dist/lib/ComboBox-e_YVsWBr.js +0 -2
  185. package/dist/lib/ComboBox-e_YVsWBr.js.map +0 -1
  186. package/dist/lib/Component-BR2f0Itb.js +0 -2
  187. package/dist/lib/Component-BR2f0Itb.js.map +0 -1
  188. package/dist/lib/Component-Bs6TvaGZ.js +0 -2
  189. package/dist/lib/Component-Bs6TvaGZ.js.map +0 -1
  190. package/dist/lib/Container-3KsvsJ6S.js +0 -2
  191. package/dist/lib/Container-CzyZeMyZ.js +0 -2
  192. package/dist/lib/Container-CzyZeMyZ.js.map +0 -1
  193. package/dist/lib/DOM-DeF_dWe2.js +0 -2
  194. package/dist/lib/DOM-DeF_dWe2.js.map +0 -1
  195. package/dist/lib/DragManager-c6M_mE3e.js.map +0 -1
  196. package/dist/lib/DragManager-tPMnbjeO.js +0 -2
  197. package/dist/lib/FieldDecorator-Bl0h9UEF.js +0 -2
  198. package/dist/lib/FieldDecorator-E7WzutjO.js +0 -2
  199. package/dist/lib/FieldDecorator-E7WzutjO.js.map +0 -1
  200. package/dist/lib/Fit-CFIr4P9R.js.map +0 -1
  201. package/dist/lib/Fit-CUS1JXy3.js +0 -2
  202. package/dist/lib/Glyph-6Ki3A1_a.js +0 -2
  203. package/dist/lib/Glyph-6Ki3A1_a.js.map +0 -1
  204. package/dist/lib/Glyph-WUqTF_Z9.js +0 -2
  205. package/dist/lib/Glyph-WUqTF_Z9.js.map +0 -1
  206. package/dist/lib/Grid-Czux--Mr.js.map +0 -1
  207. package/dist/lib/Grid-D8luwRPI.js +0 -2
  208. package/dist/lib/GridConstraints-CzC0w4i-.js +0 -2
  209. package/dist/lib/GridConstraints-CzC0w4i-.js.map +0 -1
  210. package/dist/lib/GridConstraints-Q3wvuovN.js +0 -2
  211. package/dist/lib/GridConstraints-Q3wvuovN.js.map +0 -1
  212. package/dist/lib/HBox-Q8y1PHlk.js +0 -2
  213. package/dist/lib/HBox-Q8y1PHlk.js.map +0 -1
  214. package/dist/lib/Header-zPdvC2AX.js +0 -2
  215. package/dist/lib/Header-zPdvC2AX.js.map +0 -1
  216. package/dist/lib/IconText-BvGfu7eq.js +0 -2
  217. package/dist/lib/IconText-BvGfu7eq.js.map +0 -1
  218. package/dist/lib/LayoutConstraints-CHI2lhPd.js +0 -2
  219. package/dist/lib/LayoutConstraints-CHI2lhPd.js.map +0 -1
  220. package/dist/lib/LayoutSerialization-CWU0iEuV.js +0 -2
  221. package/dist/lib/LayoutSerialization-CWU0iEuV.js.map +0 -1
  222. package/dist/lib/LayoutSerialization-C_zcwaN3.js +0 -2
  223. package/dist/lib/LayoutSerialization-C_zcwaN3.js.map +0 -1
  224. package/dist/lib/LayoutSizes-BW4wyGDI.js +0 -2
  225. package/dist/lib/LayoutSizes-BW4wyGDI.js.map +0 -1
  226. package/dist/lib/LayoutSizes-XdhpAOmc.js +0 -2
  227. package/dist/lib/LayoutSizes-XdhpAOmc.js.map +0 -1
  228. package/dist/lib/List-BgxnLWnl.js +0 -2
  229. package/dist/lib/List-BgxnLWnl.js.map +0 -1
  230. package/dist/lib/List-D-GhoVgB.js +0 -2
  231. package/dist/lib/List-D-GhoVgB.js.map +0 -1
  232. package/dist/lib/Menu-BdnwRY0M.js +0 -2
  233. package/dist/lib/Menu-BdnwRY0M.js.map +0 -1
  234. package/dist/lib/Menu-Wz4MK6sA.js +0 -2
  235. package/dist/lib/Menu-Wz4MK6sA.js.map +0 -1
  236. package/dist/lib/MenuButton-JQQaKThJ.js +0 -2
  237. package/dist/lib/MenuButton-JQQaKThJ.js.map +0 -1
  238. package/dist/lib/Panel-DApa7vA6.js +0 -2
  239. package/dist/lib/Panel-DApa7vA6.js.map +0 -1
  240. package/dist/lib/Panel-DIsdaqc2.js +0 -2
  241. package/dist/lib/Panel-DIsdaqc2.js.map +0 -1
  242. package/dist/lib/Position-B-WfZYAJ.js +0 -2
  243. package/dist/lib/Position-B-WfZYAJ.js.map +0 -1
  244. package/dist/lib/ProgressSpinner-CNYcsBhw.js +0 -2
  245. package/dist/lib/ProgressSpinner-CNYcsBhw.js.map +0 -1
  246. package/dist/lib/ProgressSpinner-Dzaka7_c.js +0 -2
  247. package/dist/lib/ProgressSpinner-Dzaka7_c.js.map +0 -1
  248. package/dist/lib/RadioButton-CepkneSA.js +0 -2
  249. package/dist/lib/RadioButton-CepkneSA.js.map +0 -1
  250. package/dist/lib/RadioButton-eI3-vXn3.js +0 -2
  251. package/dist/lib/RadioButton-eI3-vXn3.js.map +0 -1
  252. package/dist/lib/RovingTabIndex-CFIzIjjU.js.map +0 -1
  253. package/dist/lib/RovingTabIndex-D-zOuptw.js +0 -2
  254. package/dist/lib/Scrollbar-DQdCdj94.js +0 -2
  255. package/dist/lib/Scrollbar-DQdCdj94.js.map +0 -1
  256. package/dist/lib/Scrollbar-DchfiFKC.js +0 -2
  257. package/dist/lib/Scrollbar-DchfiFKC.js.map +0 -1
  258. package/dist/lib/Slider-DvDdVvRm.js +0 -2
  259. package/dist/lib/Slider-DvDdVvRm.js.map +0 -1
  260. package/dist/lib/Slider-xRxNSjFN.js +0 -2
  261. package/dist/lib/Slider-xRxNSjFN.js.map +0 -1
  262. package/dist/lib/Spacer-BqiPiCqz.js +0 -2
  263. package/dist/lib/Spacer-BqiPiCqz.js.map +0 -1
  264. package/dist/lib/TabButton-pZKFYg7b.js +0 -2
  265. package/dist/lib/TabButton-pZKFYg7b.js.map +0 -1
  266. package/dist/lib/Text-D1RrBY52.js +0 -2
  267. package/dist/lib/Text-D1RrBY52.js.map +0 -1
  268. package/dist/lib/Text-DJoUHukb.js +0 -2
  269. package/dist/lib/Text-DJoUHukb.js.map +0 -1
  270. package/dist/lib/Tooltip-4lU_tf6r.js +0 -3
  271. package/dist/lib/Tooltip-4lU_tf6r.js.map +0 -1
  272. package/dist/lib/Tooltip-5BR7yYEX.js +0 -3
  273. package/dist/lib/Tooltip-5BR7yYEX.js.map +0 -1
  274. package/dist/lib/VBox-D5B9ecw0.js +0 -2
  275. package/dist/lib/VBox-D5B9ecw0.js.map +0 -1
  276. package/dist/lib/VirtualRowView-Con9SWiU.js +0 -2
  277. package/dist/lib/VirtualRowView-Con9SWiU.js.map +0 -1
  278. package/dist/lib/VirtualScroller-BPDmO1ir.js +0 -2
  279. package/dist/lib/VirtualScroller-BPDmO1ir.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Fit-CUS1JXy3.js","names":[],"sources":["../../src/typescript/lib/layout/Fit.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutManager, LayoutManagerOptions } from \"~/layout/LayoutManager.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Fit}.\n *\n * @category Layouts\n */\nexport interface FitOptions extends LayoutManagerOptions {\n fill?: FillType;\n}\n\n/**\n * A layout manager that expects exactly one child component and positions it\n * inside the container's entire inner bounds. The default fill mode is\n * `FillType.BOTH` — the child stretches to fill the bounds. Pass\n * `fill: FillType.NONE` (or call {@link Fit.setFill}) to centre the child at\n * its preferred size instead; `HORIZONTAL` / `VERTICAL` stretch on one axis\n * and centre on the other. Throws if the container holds more than one\n * component.\n *\n * @category Layouts\n */\nclass Fit extends LayoutManager {\n\n private _fill: FillType = FillType.BOTH;\n\n constructor(options?: FitOptions) {\n // LayoutManager's constructor takes no options; applied via applyOptions below.\n // eslint-disable-next-line local/forward-super-options\n super();\n\n if (options) {\n this.applyOptions(options);\n }\n }\n\n /**\n * Applies a {@link FitOptions} bag, dispatching the fill mode after the\n * inherited LayoutManager defaults.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: FitOptions): void {\n super.applyOptions(options);\n\n if (options.fill !== undefined) {\n this.setFill(options.fill);\n }\n }\n\n /**\n * Returns the fill mode applied to the single child.\n *\n * @returns The current [`FillType`](/api/layout/enumerations/FillType).\n */\n getFill(): FillType {\n return this._fill;\n }\n\n /**\n * Sets the fill mode applied to the single child.\n *\n * @param fill - `BOTH` stretches the child to fill (default), `NONE`\n * centres it at its preferred size, `HORIZONTAL` / `VERTICAL` stretch on\n * one axis and centre on the other.\n *\n * @returns This layout manager, for method chaining.\n */\n setFill(fill: FillType): this {\n this._fill = fill;\n\n return this;\n }\n\n /**\n * Returns the preferred size of the single child component plus the container perimeter.\n *\n * @returns The preferred `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getPreferredSize(): Size | null {\n return this.computeSize(component => component.getPreferredSize());\n }\n\n /**\n * Returns the minimum size of the single child component plus the container perimeter.\n *\n * @returns The minimum `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getMinSize(): Size | null {\n return this.computeSize(component => component.getMinSize());\n }\n\n /**\n * Returns the maximum size of the single child component plus the container perimeter.\n *\n * @returns The maximum `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getMaxSize(): Size | null {\n return this.computeSize(component => component.getMaxSize());\n }\n\n /**\n * Shared core of {@link getPreferredSize} / {@link getMinSize} /\n * {@link getMaxSize}: adds the displayed child's size (selected by `sizeOf`)\n * to the container perimeter.\n *\n * @param sizeOf - Selects the child's preferred, minimum, or maximum size.\n * @returns The composed `{width, height}`, or `null` if there is no\n * container, no displayed child, or the child reports no size.\n */\n private computeSize(sizeOf: (component: Component) => Size | null): Size | null {\n const container = this.getContainer();\n if (!container) {\n return null;\n }\n\n const perimeterSize = container.getPerimeterSize();\n\n const outerWidth = perimeterSize.left + perimeterSize.right;\n const outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n // Size the displayed child only: a hidden sole child contributes no\n // size, so the Fit container reports none and its own parent reserves\n // nothing for it (honouring `displayed`, matching doLayout below).\n const component = container.getLaidOutComponents()[0] ?? null;\n if (!component) {\n return null;\n }\n\n const size = sizeOf(component);\n if (!size) {\n return null;\n }\n\n return {\n width: size.width + outerWidth,\n height: size.height + outerHeight\n };\n }\n\n /**\n * Returns the single child component of the container, or `undefined` if the container is empty.\n *\n * @returns The child component, or `undefined`.\n *\n * @remarks Throws if the container holds more than one component.\n */\n getComponent() {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let components = container.getComponents();\n\n if (components.length > 1) {\n throw new Error(\"Container contains more than one component.\");\n }\n\n let component;\n\n if (components.length == 1) {\n component = components[0];\n }\n\n return component;\n }\n\n /**\n * Computes the children's combined minSize along this manager's geometry:\n * the single child's minSize. Used by `doLayout` to inflate the working\n * size when the host has opted into `setOverflowing`.\n *\n * @returns The single child's min-size; `{ width: 0, height: 0 }` when\n * the container is absent or empty.\n */\n protected computeTotalMinSize(): Size {\n const container = this.getContainer();\n if (!container) {\n return { width: 0, height: 0 };\n }\n\n const component = container.getLaidOutComponents()[0];\n if (!component) {\n return { width: 0, height: 0 };\n }\n\n const min = component.getMinSize();\n\n return min ?? { width: 0, height: 0 };\n }\n\n /**\n * Places the single child component inside the container's inner bounds\n * using the configured fill mode.\n *\n * @remarks Throws if the container holds more than one component. With\n * the default `FillType.BOTH` the child is sized to the full bounds;\n * with `FillType.NONE` it is placed at its preferred size and centred\n * via the inherited anchor-displacement logic in `placeComponent`.\n */\n doLayout() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n // Honour `displayed`: a hidden sole child contributes nothing and a\n // hidden first-of-two is skipped, so the visible child still fits.\n let components = container.getLaidOutComponents();\n\n if (components.length > 1) {\n throw new Error(\"Container contains more than one component.\");\n }\n\n let component;\n\n if (components.length == 1) {\n component = components[0];\n }\n\n if (!component) {\n return;\n }\n\n let containerSize = container.getInnerSize();\n let containerInsets = container.getContentInsets();\n\n // Universal scroll: see HBox.doLayout for the rationale. When the\n // host has marked the corresponding axis as overflowing, grow the\n // working size past the host's inner rect to the child's minSize so\n // the host's CSS `overflow: auto` produces a scrollbar.\n if (containerSize) {\n containerSize = this.inflateForOverflow(containerSize);\n }\n\n this.placeComponent(\n component,\n containerInsets ? containerInsets.getLeft() : 0,\n containerInsets ? containerInsets.getTop() : 0,\n containerSize ? containerSize.width : 0,\n containerSize ? containerSize.height : 0,\n this._fill\n );\n }\n}\n\nconst FitCallable = callable(Fit);\ntype FitCallable = Fit;\nexport {\n Fit as _Fit,\n FitCallable as Fit\n};\n"],"mappings":"0DA4BA,IAAM,IAAN,cAAkB,CAAc,CAE5B,MAA0B,EAAS,KAEnC,YAAY,EAAsB,CAG9B,MAAM,EAEF,GACA,KAAK,aAAa,CAAO,CAEjC,CAQA,aAAuB,EAA2B,CAC9C,MAAM,aAAa,CAAO,EAEtB,EAAQ,OAAS,IAAA,IACjB,KAAK,QAAQ,EAAQ,IAAI,CAEjC,CAOA,SAAoB,CAChB,OAAO,KAAK,KAChB,CAWA,QAAQ,EAAsB,CAG1B,MAFA,MAAK,MAAQ,EAEN,IACX,CAOA,kBAAgC,CAC5B,OAAO,KAAK,YAAY,GAAa,EAAU,iBAAiB,CAAC,CACrE,CAOA,YAA0B,CACtB,OAAO,KAAK,YAAY,GAAa,EAAU,WAAW,CAAC,CAC/D,CAOA,YAA0B,CACtB,OAAO,KAAK,YAAY,GAAa,EAAU,WAA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EAAI,EAC9C,EAAkB,EAAgB,OAAO,EAAI,EAC7C,EAAgB,EAAc,MAAQ,EACtC,EAAgB,EAAc,OAAS,EACvC,KAAK,KACT,CACJ,CACJ,EAEM,EAAc,EAAS,GAAG"}
1
+ {"version":3,"file":"Fit-DjRsiwlg.js","names":[],"sources":["../../src/typescript/lib/layout/Fit.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutManager, LayoutManagerOptions } from \"~/layout/LayoutManager.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Fit}.\n *\n * @category Layouts\n */\nexport interface FitOptions extends LayoutManagerOptions {\n fill?: FillType;\n}\n\n/**\n * A layout manager that expects exactly one child component and positions it\n * inside the container's entire inner bounds. The default fill mode is\n * `FillType.BOTH` — the child stretches to fill the bounds. Pass\n * `fill: FillType.NONE` (or call {@link Fit.setFill}) to centre the child at\n * its preferred size instead; `HORIZONTAL` / `VERTICAL` stretch on one axis\n * and centre on the other. Throws if the container holds more than one\n * component.\n *\n * @category Layouts\n */\nclass Fit extends LayoutManager {\n\n private _fill: FillType = FillType.BOTH;\n\n constructor(options?: FitOptions) {\n // LayoutManager's constructor takes no options; applied via applyOptions below.\n // eslint-disable-next-line local/forward-super-options\n super();\n\n if (options) {\n this.applyOptions(options);\n }\n }\n\n /**\n * Applies a {@link FitOptions} bag, dispatching the fill mode after the\n * inherited LayoutManager defaults.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: FitOptions): void {\n super.applyOptions(options);\n\n if (options.fill !== undefined) {\n this.setFill(options.fill);\n }\n }\n\n /**\n * Returns the fill mode applied to the single child.\n *\n * @returns The current [`FillType`](/api/layout/enumerations/FillType).\n */\n getFill(): FillType {\n return this._fill;\n }\n\n /**\n * Sets the fill mode applied to the single child.\n *\n * @param fill - `BOTH` stretches the child to fill (default), `NONE`\n * centres it at its preferred size, `HORIZONTAL` / `VERTICAL` stretch on\n * one axis and centre on the other.\n *\n * @returns This layout manager, for method chaining.\n */\n setFill(fill: FillType): this {\n this._fill = fill;\n\n return this;\n }\n\n /**\n * Returns the preferred size of the single child component plus the container perimeter.\n *\n * @returns The preferred `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getPreferredSize(): Size | null {\n return this.computeSize(component => component.getPreferredSize());\n }\n\n /**\n * Returns the minimum size of the single child component plus the container perimeter.\n *\n * @returns The minimum `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getMinSize(): Size | null {\n return this.computeSize(component => component.getMinSize());\n }\n\n /**\n * Returns the maximum size of the single child component plus the container perimeter.\n *\n * @returns The maximum `{width, height}`, or `null` if there is no container or no displayed child.\n */\n getMaxSize(): Size | null {\n return this.computeSize(component => component.getMaxSize());\n }\n\n /**\n * Shared core of {@link getPreferredSize} / {@link getMinSize} /\n * {@link getMaxSize}: adds the displayed child's size (selected by `sizeOf`)\n * to the container perimeter.\n *\n * @param sizeOf - Selects the child's preferred, minimum, or maximum size.\n * @returns The composed `{width, height}`, or `null` if there is no\n * container, no displayed child, or the child reports no size.\n */\n private computeSize(sizeOf: (component: Component) => Size | null): Size | null {\n const container = this.getContainer();\n if (!container) {\n return null;\n }\n\n const perimeterSize = container.getPerimeterSize();\n\n const outerWidth = perimeterSize.left + perimeterSize.right;\n const outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n // Size the displayed child only: a hidden sole child contributes no\n // size, so the Fit container reports none and its own parent reserves\n // nothing for it (honouring `displayed`, matching doLayout below).\n const component = container.getLaidOutComponents()[0] ?? null;\n if (!component) {\n return null;\n }\n\n const size = sizeOf(component);\n if (!size) {\n return null;\n }\n\n return {\n width: size.width + outerWidth,\n height: size.height + outerHeight\n };\n }\n\n /**\n * Returns the single child component of the container, or `undefined` if the container is empty.\n *\n * @returns The child component, or `undefined`.\n *\n * @remarks Throws if the container holds more than one component.\n */\n getComponent() {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let components = container.getComponents();\n\n if (components.length > 1) {\n throw new Error(\"Container contains more than one component.\");\n }\n\n let component;\n\n if (components.length == 1) {\n component = components[0];\n }\n\n return component;\n }\n\n /**\n * Computes the children's combined minSize along this manager's geometry:\n * the single child's minSize. Used by `doLayout` to inflate the working\n * size when the host has opted into `setOverflowing`.\n *\n * @returns The single child's min-size; `{ width: 0, height: 0 }` when\n * the container is absent or empty.\n */\n protected computeTotalMinSize(): Size {\n const container = this.getContainer();\n if (!container) {\n return { width: 0, height: 0 };\n }\n\n const component = container.getLaidOutComponents()[0];\n if (!component) {\n return { width: 0, height: 0 };\n }\n\n const min = component.getMinSize();\n\n return min ?? { width: 0, height: 0 };\n }\n\n /**\n * Places the single child component inside the container's inner bounds\n * using the configured fill mode.\n *\n * @remarks Throws if the container holds more than one component. With\n * the default `FillType.BOTH` the child is sized to the full bounds;\n * with `FillType.NONE` it is placed at its preferred size and centred\n * via the inherited anchor-displacement logic in `placeComponent`.\n */\n doLayout() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n // Honour `displayed`: a hidden sole child contributes nothing and a\n // hidden first-of-two is skipped, so the visible child still fits.\n let components = container.getLaidOutComponents();\n\n if (components.length > 1) {\n throw new Error(\"Container contains more than one component.\");\n }\n\n let component;\n\n if (components.length == 1) {\n component = components[0];\n }\n\n if (!component) {\n return;\n }\n\n let containerSize = container.getInnerSize();\n let containerInsets = container.getContentInsets();\n\n // Universal scroll: see HBox.doLayout for the rationale. When the\n // host has marked the corresponding axis as overflowing, grow the\n // working size past the host's inner rect to the child's minSize so\n // the host's CSS `overflow: auto` produces a scrollbar.\n if (containerSize) {\n containerSize = this.inflateForOverflow(containerSize);\n }\n\n this.placeComponent(\n component,\n containerInsets ? containerInsets.getLeft() : 0,\n containerInsets ? containerInsets.getTop() : 0,\n containerSize ? containerSize.width : 0,\n containerSize ? containerSize.height : 0,\n this._fill\n );\n }\n}\n\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AAM,EAAY,KAAK,aAAa,EACpC,GAAI,CAAC,EACD,MAAO,CAAE,MAAO,EAAG,OAAQ,CAAE,EAGjC,IAAM,EAAY,EAAU,qBAAqB,CAAC,CAAC,GAOnD,OANK,EAIO,EAAU,WAEf,GAAO,CAAE,MAAO,EAAG,OAAQ,CAAE,EALzB,CAAE,MAAO,EAAG,OAAQ,CAAE,CAMrC,CAWA,UAAW,CACP,IAAI,EAAY,KAAK,aAAa,EAClC,GAAI,CAAC,EACD,OAKJ,IAAI,EAAa,EAAU,qBAAqB,EAEhD,GAAI,EAAW,OAAS,EACpB,MAAU,MAAM,6CAA6C,EAGjE,IAAI,EAMJ,GAJI,EAAW,QAAU,IACrB,EAAY,EAAW,IAGvB,CAAC,EACD,OAGJ,IAAI,EAAgB,EAAU,aAAa,EACvC,EAAkB,EAAU,iBAAiB,EAMjD,AACI,IAAgB,KAAK,mBAAmB,CAAa,EAGzD,KAAK,eACD,EACA,EAAkB,EAAgB,QAAQ,EAAI,EAC9C,EAAkB,EAAgB,OAAO,EAAI,EAC7C,EAAgB,EAAc,MAAQ,EACtC,EAAgB,EAAc,OAAS,EACvC,KAAK,KACT,CACJ,CACJ,EAEM,EAAc,EAAS,GAAG"}
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./DOM-CGn7xyTw.js";import{_ as t,f as n,h as r,t as i}from"./Component-DXf5a3g0.js";var a=new Map;a.set(`unicode-arrow-up`,{kind:`char`,char:`▲`}),a.set(`unicode-arrow-down`,{kind:`char`,char:`▼`}),a.set(`unicode-arrow-left`,{kind:`char`,char:`◀`}),a.set(`unicode-arrow-right`,{kind:`char`,char:`▶`});var o=`http://www.w3.org/2000/svg`,s=`ts-glyph-`,c=!1,l=null;function registerGlyph(e){a.set(e.name,e),e.kind===`svg`&&c&&_addSymbolToSprite(e.name,e)}function unregisterGlyph(e){let t=a.get(e);a.delete(e),t&&t.kind===`svg`&&c&&_removeSymbolFromSprite(e)}function lookupGlyph(e){return a.get(e)}function ensureGlyphSprite(){if(c)return;let t=e.sink.createElementNS(o,`svg`);e.sink.apply(t,{setAttr:{"aria-hidden":`true`,focusable:`false`},style:{position:`absolute`,width:`0`,height:`0`,overflow:`hidden`}}),e.sink.appendChild(e.source.getBody(),t),l=t,c=!0}function ensureGlyphSymbolMounted(e){if(!c)return;let t=a.get(e);t&&t.kind===`svg`&&_addSymbolToSprite(e,t)}function _addSymbolToSprite(t,n){if(!l||n.kind!==`svg`)return;let r=s+t;if(e.source.querySelector(l,`#${e.source.escapeSelector(r)}`))return;let i=e.sink.createElementNS(o,`symbol`);e.sink.apply(i,{setAttr:{id:r,viewBox:n.viewBox}});let a=e.sink.createElementNS(o,`path`);e.sink.apply(a,{setAttr:{d:n.path}}),e.sink.appendChild(i,a),e.sink.appendChild(l,i)}function _removeSymbolFromSprite(t){if(!l)return;let n=s+t,r=e.source.querySelector(l,`#${e.source.escapeSelector(n)}`);if(r){let t=e.source.querySelector(r,`path`);e.sink.removeChild(l,r),e.sink.release(r),t&&e.sink.release(t)}}var u=`ts-ui-glyph-`,d=new Set,f=!1;function ensureGlyphKeyframes(){f||(f=!0,t.ensureKeyframes(`ts-ui-glyph-spin`,`from { transform: rotate(0deg); } to { transform: rotate(360deg); }`),t.ensureKeyframes(`ts-ui-glyph-pulse`,`0%, 12.5% { transform: rotate(0deg); } 12.5%, 25% { transform: rotate(45deg); } 25%, 37.5% { transform: rotate(90deg); } 37.5%, 50% { transform: rotate(135deg); } 50%, 62.5% { transform: rotate(180deg); } 62.5%, 75% { transform: rotate(225deg); } 75%, 87.5% { transform: rotate(270deg); } 87.5%, 100% { transform: rotate(315deg); }`),t.ensureKeyframes(`ts-ui-glyph-beat`,`0%, 90% { transform: scale(1); } 45% { transform: scale(1.25); }`),new t({scope:`class`,name:`ts-ui-glyph-spin`,styles:{animation:`ts-ui-glyph-spin var(--ts-ui-glyph-spin-duration, 2000ms) linear infinite`}}),new t({scope:`class`,name:`ts-ui-glyph-pulse`,styles:{animation:`ts-ui-glyph-pulse var(--ts-ui-glyph-pulse-duration, 1000ms) steps(8) infinite`}}),new t({scope:`class`,name:`ts-ui-glyph-beat`,styles:{animation:`ts-ui-glyph-beat var(--ts-ui-glyph-beat-duration, 1000ms) ease-in-out infinite`}}))}function _onReducedMotionChange(){for(let e of Array.from(d)){let t=e.deref();if(!t){d.delete(e);continue}t._syncReducedMotion()}}e.source.matchMedia(`(prefers-reduced-motion: reduce)`).addChangeListener(_onReducedMotionChange);var p={preferredSize:{width:16,height:16}},Glyph=class extends i{_name;_def;static register(...e){for(let t of e)registerGlyph(t)}static unregister(e){unregisterGlyph(e)}constructor(e,t){let n=lookupGlyph(e);if(!n)throw Error(`Unknown glyph: `+e);super(t,{...p,tag:n.kind===`svg`?`svg`:`span`}),this._name=e,this._def=n,n.kind===`char`&&(this._options.lineHeight===void 0&&this.setLineHeight(`1`),this._options.textAlign===void 0&&this.setTextAlign(`center`))}setPreferredSize(e){return super.setPreferredSize(e),super.setMinSize(e),super.setMaxSize(e),this}getBaseline(){let e=this.getPreferredSize();return e?e.height-3:null}getGlyphName(){return this._name}getFontSize(){return this._options.fontSize??null}setFontSize(e){return this._options.fontSize=e,this.setElementCSSRule(`fontSize`,e+`px`),this}getLineHeight(){let e=this._options.lineHeight;return e===void 0?null:typeof e==`number`?e+`px`:e}setLineHeight(e){return this._options.lineHeight=e,this.setElementCSSRule(`lineHeight`,typeof e==`number`?e+`px`:e),this}getTextAlign(){return this._options.textAlign??null}setTextAlign(e){return this._options.textAlign=e,this.setElementCSSRule(`textAlign`,e),this}getAnimated(){return this._glyphAnimation}setAnimated(t){if(this._glyphAnimation===t)return this;let n=this._glyphAnimation;this._glyphAnimation=t;let i=this.getElement();return i&&n&&e.sink.apply(i,{removeClass:[u+n]}),t===null?(this.setElementStyle(`animationDuration`,null),this.setWillChange(null),this._animatedRef&&=(d.delete(this._animatedRef),null),this):(ensureGlyphKeyframes(),this._animatedRef||(this._animatedRef=new WeakRef(this),d.add(this._animatedRef)),r.isReducedMotion()||(i&&e.sink.apply(i,{addClass:[u+t]}),this.setWillChange(`transform`)),this._glyphAnimationDuration>0&&this.setElementStyle(`animationDuration`,this._glyphAnimationDuration+`ms`),this)}clearAnimated(){return this.setAnimated(null)}getAnimationDuration(){return this._glyphAnimationDuration}setAnimationDuration(e){return this._glyphAnimationDuration=e,this._glyphAnimation!==null&&!r.isReducedMotion()&&this.setElementStyle(`animationDuration`,e>0?e+`ms`:null),this}_syncReducedMotion(){let t=this._glyphAnimation;if(!t)return;let n=this.getElement(!0),i=u+t;r.isReducedMotion()?(e.sink.apply(n,{removeClass:[i]}),this.setWillChange(null),this.setElementStyle(`animationDuration`,null)):(e.sink.apply(n,{addClass:[i]}),this.setWillChange(`transform`),this._glyphAnimationDuration>0&&this.setElementStyle(`animationDuration`,this._glyphAnimationDuration+`ms`))}applyOptions(e){super.applyOptions(e),e.fontSize!==void 0&&this.setFontSize(e.fontSize),e.lineHeight!==void 0&&this.setLineHeight(e.lineHeight),e.textAlign!==void 0&&this.setTextAlign(e.textAlign),e.animationDuration!==void 0&&this.setAnimationDuration(e.animationDuration);let t=this.getPreferredSizeConstraint();return t&&(e.minSize===void 0&&this.setMinSize({width:t.width,height:t.height}),e.maxSize===void 0&&this.setMaxSize({width:t.width,height:t.height})),e.animation!==void 0&&this.setAnimated(e.animation),this}createRootElement(){if(this._def.kind===`svg`){ensureGlyphSprite(),ensureGlyphSymbolMounted(this._name);let t=`http://www.w3.org/2000/svg`,n=e.sink.createElementNS(t,`svg`);e.sink.apply(n,{setAttr:{fill:`currentColor`,"aria-hidden":`true`,focusable:`false`}});let r=e.sink.createElementNS(t,`use`);return e.sink.apply(r,{setAttr:{href:`#`+s+this._name}}),e.sink.appendChild(n,r),this.trackHandle(r),n}return super.createRootElement()}render(){let t=super.render();this._def.kind===`char`&&e.sink.apply(t,{text:this._def.char}),this._glyphAnimation&&!r.isReducedMotion()&&e.sink.apply(t,{addClass:[u+this._glyphAnimation]});let n=this._options.preferredSize;return n&&(this.setElementStyle(`width`,n.width+`px`),this.setElementStyle(`height`,n.height+`px`)),t}},m=n(Glyph);export{m as t};
2
+ //# sourceMappingURL=Glyph-KEf4nIv2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Glyph-KEf4nIv2.js","names":[],"sources":["../../src/typescript/lib/component/display/Glyphs.ts","../../src/typescript/lib/component/display/Glyph.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\n\n/**\n * Tagged union describing how a glyph is rendered.\n *\n * @remarks\n * - `kind: \"svg\"` entries supply a `viewBox` and an SVG `<path>` `d` attribute.\n * The path data is mounted once into a shared hidden `<svg>` sprite and each\n * Glyph instance references it via `<svg><use href=\"#...\"/></svg>` so the\n * path string is not duplicated in the DOM.\n * - `kind: \"char\"` entries carry a single Unicode character rendered inside a\n * `<span>`; the character follows the inherited text colour.\n */\nexport type GlyphDef =\n | { kind: \"svg\", viewBox: string; path: string }\n | { kind: \"char\", char: string };\n\n/**\n * A {@link GlyphDef} carrying its own registry name. Glyph modules generated\n * from third-party icon sets export values of this shape so they can be\n * registered in a single call to `Glyph.register(...)`.\n */\nexport type NamedGlyphDef = GlyphDef & { name: string };\n\n/**\n * Mutable registry of named glyphs, populated via `registerGlyph` /\n * `Glyph.register`. Starts empty — consumers register the glyphs they need.\n *\n * @internal\n */\nconst _glyphs: Map<string, GlyphDef> = new Map();\n\n// Built-in Unicode-triangle glyphs registered eagerly. Prefixed `unicode-` so\n// user code can register its own `arrow-up` / `arrow-down` SVG glyphs without\n// overwriting these — built-in chrome like Scrollbar's end-cap buttons\n// references the prefixed names directly and stays immune to user overrides.\n// Char-mode entries are tiny (no sprite, no path data) so the always-on cost\n// is negligible; the triangles inherit the surrounding text colour via\n// `currentColor`, so a single foreground-colour write themes them.\n_glyphs.set(\"unicode-arrow-up\", { kind: \"char\", char: \"▲\" });\n_glyphs.set(\"unicode-arrow-down\", { kind: \"char\", char: \"▼\" });\n_glyphs.set(\"unicode-arrow-left\", { kind: \"char\", char: \"◀\" });\n_glyphs.set(\"unicode-arrow-right\", { kind: \"char\", char: \"▶\" });\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n/**\n * Prefix applied to every `<symbol>` id inside the sprite. A consumer-supplied\n * registry name `\"xmark\"` becomes the id `\"ts-glyph-xmark\"`, which is what\n * `<use href=\"#ts-glyph-xmark\"/>` references.\n */\nexport const GLYPH_SYMBOL_ID_PREFIX = \"ts-glyph-\";\n\nlet _spriteMounted: boolean = false;\nlet _spriteElement: Handle | null = null;\n\n/**\n * Registers a glyph by name. If the glyph is SVG-mode and the sprite is\n * already mounted, the corresponding `<symbol>` is appended immediately so\n * Glyphs constructed after this call can reference it.\n *\n * @internal\n */\nexport function registerGlyph(def: NamedGlyphDef): void {\n _glyphs.set(def.name, def);\n\n if (def.kind === \"svg\" && _spriteMounted) {\n _addSymbolToSprite(def.name, def);\n }\n}\n\n/**\n * Removes a glyph from the registry by name. If the glyph was SVG-mode and\n * the sprite is mounted, its `<symbol>` is removed from the DOM as well.\n *\n * @internal\n */\nexport function unregisterGlyph(name: string): void {\n const def = _glyphs.get(name);\n _glyphs.delete(name);\n\n if (def && def.kind === \"svg\" && _spriteMounted) {\n _removeSymbolFromSprite(name);\n }\n}\n\n/**\n * Looks up a glyph definition by registry name.\n *\n * @returns The registered {@link GlyphDef}, or `undefined` if not registered.\n *\n * @internal\n */\nexport function lookupGlyph(name: string): GlyphDef | undefined {\n return _glyphs.get(name);\n}\n\n/**\n * Ensures the document carries a single hidden `<svg>` sprite that hosts the\n * `<symbol>` elements for every SVG-mode glyph. Idempotent — subsequent calls\n * are no-ops. The sprite starts empty; entries are appended incrementally\n * either by {@link registerGlyph} (after the sprite is mounted) or by\n * {@link ensureGlyphSymbolMounted} (when a Glyph instance is constructed).\n *\n * @internal\n */\nexport function ensureGlyphSprite(): void {\n if (_spriteMounted) {\n return;\n }\n\n const sprite = DOM.sink.createElementNS(SVG_NS, \"svg\");\n // `sprite` is a raw off-screen SVG element mounted directly on document.body,\n // not a Component, so the Component style setters don't apply here.\n DOM.sink.apply(sprite, {\n setAttr: { \"aria-hidden\": \"true\", focusable: \"false\" },\n style: { position: \"absolute\", width: \"0\", height: \"0\", overflow: \"hidden\" },\n });\n\n DOM.sink.appendChild(DOM.source.getBody(), sprite);\n\n _spriteElement = sprite;\n _spriteMounted = true;\n}\n\n/**\n * Ensures the sprite carries a `<symbol>` for the named SVG-mode glyph,\n * appending it on demand for glyphs registered before the sprite was mounted.\n * Idempotent.\n *\n * @internal\n */\nexport function ensureGlyphSymbolMounted(name: string): void {\n if (!_spriteMounted) {\n return;\n }\n\n const def = _glyphs.get(name);\n if (def && def.kind === \"svg\") {\n _addSymbolToSprite(name, def);\n }\n}\n\n/**\n * Appends a `<symbol>` for the given SVG-mode glyph to the sprite. Idempotent:\n * a no-op when a `<symbol>` with the same id already exists.\n *\n * @internal\n */\nfunction _addSymbolToSprite(name: string, def: GlyphDef): void {\n if (!_spriteElement || def.kind !== \"svg\") {\n return;\n }\n\n const id = GLYPH_SYMBOL_ID_PREFIX + name;\n if (DOM.source.querySelector(_spriteElement, `#${DOM.source.escapeSelector(id)}`)) {\n return;\n }\n\n const symbol = DOM.sink.createElementNS(SVG_NS, \"symbol\");\n DOM.sink.apply(symbol, { setAttr: { id: id, viewBox: def.viewBox } });\n\n const path = DOM.sink.createElementNS(SVG_NS, \"path\");\n DOM.sink.apply(path, { setAttr: { d: def.path } });\n DOM.sink.appendChild(symbol, path);\n\n DOM.sink.appendChild(_spriteElement, symbol);\n}\n\n/**\n * Removes the `<symbol>` for the given glyph name from the sprite, if present.\n *\n * @internal\n */\nfunction _removeSymbolFromSprite(name: string): void {\n if (!_spriteElement) {\n return;\n }\n\n const id = GLYPH_SYMBOL_ID_PREFIX + name;\n const symbol = DOM.source.querySelector(_spriteElement, `#${DOM.source.escapeSelector(id)}`);\n if (symbol) {\n // Release the symbol's retained `<path>` child too — releasing only the\n // symbol would pin the detached path handle in the registry. Queried\n // before removal so it resolves to its canonical retained handle.\n const path = DOM.source.querySelector(symbol, \"path\");\n\n DOM.sink.removeChild(_spriteElement, symbol);\n DOM.sink.release(symbol);\n\n if (path) {\n DOM.sink.release(path);\n }\n }\n}\n","// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { Animation } from \"~/core/Animation.js\";\nimport { Component, ComponentOptions } from \"~/core/Component.js\";\nimport { DOM } from \"~/core/DOM.js\";\nimport type { Handle } from \"~/core/DOM.js\";\nimport { StyleRule } from \"~/core/StyleTarget.js\";\nimport { callable } from \"~/core/Callable.js\";\nimport { Size } from \"~/primitive/Size.js\";\nimport {\n ensureGlyphSprite,\n ensureGlyphSymbolMounted,\n GLYPH_SYMBOL_ID_PREFIX,\n GlyphDef,\n lookupGlyph,\n NamedGlyphDef,\n registerGlyph,\n unregisterGlyph,\n} from \"~/component/display/Glyphs.js\";\n\n/**\n * Named animation kinds supported by {@link Glyph.setAnimated}.\n *\n * - `spin` — continuous 360 degree rotate. Loading and refresh affordances.\n * - `pulse` — 8-step rotate. Mechanical, faux-loading tick.\n * - `beat` — transform-scale pulse. Notification dots and attention nudges.\n *\n * Mirrors FontAwesome's `fa-spin` / `fa-pulse` / `fa-beat` vocabulary.\n *\n * @category Components\n */\nexport type GlyphAnimation = \"spin\" | \"pulse\" | \"beat\";\n\n/**\n * CSS class prefix shared by all three animation rules. The full class name\n * is `ts-ui-glyph-<kind>` (e.g. `ts-ui-glyph-spin`).\n */\nconst CLASS_PREFIX = \"ts-ui-glyph-\";\n\n/**\n * Registry of `WeakRef<Glyph>` for currently-animated instances. A single\n * module-level `matchMedia` listener walks this set on OS preference changes\n * and re-applies the class to match. `WeakRef` lets the GC collect unrooted\n * glyphs without an explicit deregister-on-disposal step.\n */\nconst _animatedRefs: Set<WeakRef<Glyph>> = new Set();\n\nlet _keyframesInjected = false;\n\n/**\n * Injects the three `@keyframes` blocks and matching class rules on first\n * use. Idempotent — guarded by the module-level `_keyframesInjected` flag.\n */\nfunction ensureGlyphKeyframes(): void {\n if (_keyframesInjected) {\n return;\n }\n\n _keyframesInjected = true;\n\n StyleRule.ensureKeyframes(\"ts-ui-glyph-spin\",\n \"from { transform: rotate(0deg); } to { transform: rotate(360deg); }\");\n\n StyleRule.ensureKeyframes(\"ts-ui-glyph-pulse\",\n \"0%, 12.5% { transform: rotate(0deg); } \" +\n \"12.5%, 25% { transform: rotate(45deg); } \" +\n \"25%, 37.5% { transform: rotate(90deg); } \" +\n \"37.5%, 50% { transform: rotate(135deg); } \" +\n \"50%, 62.5% { transform: rotate(180deg); } \" +\n \"62.5%, 75% { transform: rotate(225deg); } \" +\n \"75%, 87.5% { transform: rotate(270deg); } \" +\n \"87.5%, 100% { transform: rotate(315deg); }\");\n\n StyleRule.ensureKeyframes(\"ts-ui-glyph-beat\",\n \"0%, 90% { transform: scale(1); } 45% { transform: scale(1.25); }\");\n\n new StyleRule({\n scope: \"class\",\n name: CLASS_PREFIX + \"spin\",\n styles: {\n animation: \"ts-ui-glyph-spin var(--ts-ui-glyph-spin-duration, 2000ms) linear infinite\",\n },\n });\n\n new StyleRule({\n scope: \"class\",\n name: CLASS_PREFIX + \"pulse\",\n styles: {\n animation: \"ts-ui-glyph-pulse var(--ts-ui-glyph-pulse-duration, 1000ms) steps(8) infinite\",\n },\n });\n\n new StyleRule({\n scope: \"class\",\n name: CLASS_PREFIX + \"beat\",\n styles: {\n animation: \"ts-ui-glyph-beat var(--ts-ui-glyph-beat-duration, 1000ms) ease-in-out infinite\",\n },\n });\n}\n\n/**\n * Module-level listener that re-evaluates every animated glyph when the OS\n * `prefers-reduced-motion` preference flips. Dead `WeakRef`s are pruned.\n */\nfunction _onReducedMotionChange(): void {\n for (const ref of Array.from(_animatedRefs)) {\n const glyph = ref.deref();\n if (!glyph) {\n _animatedRefs.delete(ref);\n continue;\n }\n\n glyph._syncReducedMotion();\n }\n}\n\n// The seam's `matchMedia` degrades to an inert result off-browser, so this\n// module-level registration needs no environment guard of its own.\nDOM.source.matchMedia(\"(prefers-reduced-motion: reduce)\").addChangeListener(_onReducedMotionChange);\n\n/**\n * Construction-time options for {@link Glyph}.\n *\n * @category Components\n */\nexport interface GlyphOptions extends ComponentOptions {\n\n /**\n * CSS `font-size` override in pixels. Only meaningful for char-mode\n * glyphs (SVG glyphs paint via `<use>` and ignore font-size). Useful when\n * the inherited font-size produces a line-box taller than the glyph's\n * element box and the Unicode character overflows or gets clipped.\n */\n fontSize?: number;\n\n /**\n * CSS `line-height` override. A number is interpreted as pixels (e.g.\n * `24` → `\"24px\"`); a string is used verbatim (e.g. `\"1\"` for the\n * unitless font-size multiplier used by char-mode glyphs).\n */\n lineHeight?: number | string;\n\n /**\n * CSS `text-align` keyword (e.g. `\"left\"`, `\"center\"`, `\"right\"`).\n * Char-mode glyphs default to `\"center\"`; SVG-mode glyphs leave this\n * unset.\n */\n textAlign?: string;\n\n /**\n * Optional animation kind to play on this glyph from construction.\n */\n animation?: GlyphAnimation;\n\n /**\n * Optional override (ms) for the active animation's duration. Wins over\n * the theme-token default while non-zero. Ignored when `animation` is\n * unset.\n */\n animationDuration?: number;\n}\n\n/**\n * User-overridable defaults forwarded to `super` via the options bag. The\n * cascade dispatches each present setter once with the final value. Only\n * defaults that apply unconditionally for every Glyph kind live here — the\n * char-only `lineHeight`/`textAlign` defaults stay in the constructor body\n * because they depend on the per-instance `def.kind`.\n */\nconst _defaultGlyphOptions: Partial<GlyphOptions> = {\n preferredSize: { width: 16, height: 16 } as GlyphOptions[\"preferredSize\"],\n};\n\n/**\n * A small icon rendered from the internal `Glyphs` registry.\n *\n * @remarks\n * Each registry entry is either an SVG or a single Unicode character. SVG\n * entries are rendered as `<svg><use href=\"#…\"/></svg>` against a hidden\n * sprite mounted once into `document.body`, so the path data lives in the\n * DOM exactly once regardless of how many Glyph instances reference it.\n * Unicode entries render as `<span>`. Both forms render with `currentColor`,\n * so a `Glyph` inherits the surrounding text colour for free. The underlying\n * root tag is decided once at construction from the entry's `kind` and\n * cannot be changed afterwards — to swap glyph, discard the instance and\n * create a new one.\n *\n * Pass any registry name to the constructor; unknown names throw at\n * construction. The default preferred size is 16×16.\n *\n * @example\n * ```typescript\n * import { xmark } from \"~/glyphs/solid/xmark.js\";\n * import { arrow_right } from \"~/glyphs/solid/arrow_right.js\";\n *\n * Glyph.register(xmark, arrow_right);\n *\n * panel.addComponent(new Glyph(\"xmark\"));\n * panel.addComponent(new Glyph(\"arrow-right\"));\n * ```\n *\n * @category Components\n */\nclass Glyph extends Component<GlyphOptions> {\n\n private _name: string;\n private _def: GlyphDef;\n declare private _glyphAnimation: GlyphAnimation | null;\n declare private _glyphAnimationDuration: number;\n declare private _animatedRef: WeakRef<Glyph> | null;\n\n /**\n * Registers one or more glyph definitions so they can be instantiated by\n * name. Pass the named exports from `~/glyphs/<style>/<name>.js` modules.\n *\n * @param defs - One or more {@link NamedGlyphDef} values to register.\n */\n static register(...defs: NamedGlyphDef[]): void {\n for (const def of defs) {\n registerGlyph(def);\n }\n }\n\n /**\n * Removes a previously registered glyph by name.\n *\n * @param name - Registry key to unregister.\n */\n static unregister(name: string): void {\n unregisterGlyph(name);\n }\n\n /**\n * Constructs a Glyph for the registry entry with the given name.\n *\n * @param name - Registry key. Must have been registered via {@link Glyph.register}.\n * @param options - Optional component options bag.\n */\n constructor(name: string, options?: GlyphOptions) {\n const def = lookupGlyph(name);\n if (!def) {\n throw new Error(\"Unknown glyph: \" + name);\n }\n\n // Hand defaults plus the per-instance tag (chosen from the registry\n // entry's `kind`) to Component via the subclass-defaults arg so they\n // land in `_defaultOptions`. Component's super-time cascade applies\n // them; user `options` win because `applyOptions` merges\n // `{...defaults, ...options}` at dispatch time.\n super(options, {\n ..._defaultGlyphOptions,\n tag: def.kind === \"svg\" ? \"svg\" : \"span\",\n });\n\n this._name = name;\n this._def = def;\n\n // Char-mode glyphs need a line-height and text-align that SVG glyphs\n // should not get. Keep these guards in the constructor body since they\n // depend on per-instance `def.kind` rather than a static default.\n if (def.kind === \"char\") {\n if (this._options.lineHeight === undefined) {\n this.setLineHeight(\"1\");\n }\n\n if (this._options.textAlign === undefined) {\n this.setTextAlign(\"center\");\n }\n }\n }\n\n /**\n * Sets the preferred size and pins minSize/maxSize to the same value so\n * the glyph stays rigid in flexible layouts — HBox's shrink-on-overflow\n * logic and any grow path see equal min/pref/max and leave the glyph at\n * its configured size. Callers can still override the lock by calling\n * `setMinSize` / `setMaxSize` explicitly after this method.\n *\n * @param size - The preferred size in pixels.\n *\n * @returns This component, for method chaining.\n */\n setPreferredSize(size: Size): this {\n super.setPreferredSize(size);\n super.setMinSize(size);\n super.setMaxSize(size);\n\n return this;\n }\n\n /**\n * Returns a baseline near the bottom edge so the glyph participates in\n * baseline alignment — sitting with its ink roughly on the surrounding text\n * baseline when placed next to labels — instead of being vertically centred\n * in the row. The anchor is 4px above the bottom edge (vs 2px on the\n * bar-shaped controls), which drops a square icon slightly lower so its ink\n * lands on the text baseline rather than floating above it.\n *\n * @returns The preferred height minus 4, or `null` before a size is set.\n */\n getBaseline(): number | null {\n const size = this.getPreferredSize();\n\n return size ? size.height - 3 : null;\n }\n\n /**\n * Returns the registry name this Glyph was constructed with. Named\n * `getGlyphName` rather than `getName` so it does not shadow\n * [`Component.getName`](/api/core/classes/Component#getname), whose\n * intrinsic `name` is a display label with a different meaning.\n *\n * @returns The registry key supplied to the constructor.\n */\n getGlyphName(): string {\n return this._name;\n }\n\n /**\n * Returns the explicit CSS `font-size` override (in pixels) written by\n * this Glyph, or `null` when no override has been written (the element\n * inherits the parent's font-size).\n *\n * @returns The cached font-size in pixels, or null.\n */\n getFontSize(): number | null {\n return this._options.fontSize ?? null;\n }\n\n /**\n * Overrides the CSS `font-size` of this Glyph's root element. Useful when\n * the ambient inherited font-size produces a line-box taller than the\n * glyph's `preferredSize`, causing the Unicode character to overflow or\n * get clipped by the element's `overflow: hidden`. No-op visually for\n * SVG glyphs (which size via `viewBox`), but the rule is written regardless.\n *\n * @param value - The new font-size in pixels.\n * @returns This Glyph, for method chaining.\n */\n setFontSize(value: number): this {\n this._options.fontSize = value;\n this.setElementCSSRule(\"fontSize\", value + \"px\");\n\n return this;\n }\n\n /**\n * Returns the current CSS `line-height` value written by this Glyph, or\n * `null` if no rule has been written (the element inherits the parent's\n * line-height).\n *\n * @returns The cached line-height CSS value (e.g. `\"1\"`, `\"24px\"`), or null.\n *\n * @remarks\n * Char-mode glyphs construct with `\"1\"`; SVG-mode glyphs default to null.\n * Use this getter rather than reading `element.style.lineHeight` to avoid\n * a forced style read.\n */\n getLineHeight(): string | null {\n const value = this._options.lineHeight;\n if (value === undefined) {\n return null;\n }\n\n return typeof value === \"number\" ? value + \"px\" : value;\n }\n\n /**\n * Overrides the CSS `line-height` of this Glyph's root element.\n *\n * @param value - Pixel number (e.g. `24` → `\"24px\"`) or a raw CSS\n * line-height value (e.g. `\"1\"` for the unitless\n * font-size multiplier used by char-mode glyphs).\n * @returns This Glyph, for method chaining.\n *\n * @remarks\n * Char-mode glyphs construct with `line-height: 1`, which keeps Unicode\n * characters like `▲` / `▼` snug against the top of their box. When a\n * Glyph is sized larger than its natural char height and needs to\n * vertically centre within that box, callers can match the line-height to\n * the element height to push the line-box to the middle. No-op visually\n * for SVG glyphs (which size via `viewBox`), but the rule is written\n * regardless.\n */\n setLineHeight(value: number | string): this {\n this._options.lineHeight = value;\n this.setElementCSSRule(\"lineHeight\", typeof value === \"number\" ? value + \"px\" : value);\n\n return this;\n }\n\n /**\n * Returns the current CSS `text-align` value written by this Glyph, or\n * `null` if no rule has been written (the element inherits the parent's\n * text-align).\n *\n * @returns The cached text-align CSS value (e.g. `\"center\"`), or null.\n *\n * @remarks\n * Char-mode glyphs construct with `\"center\"` to keep the Unicode\n * character horizontally centred within its element box; SVG-mode glyphs\n * default to null. Use this getter rather than reading\n * `element.style.textAlign` to avoid a forced style read.\n */\n getTextAlign(): string | null {\n return this._options.textAlign ?? null;\n }\n\n /**\n * Overrides the CSS `text-align` of this Glyph's root element.\n *\n * @param value - A CSS `text-align` keyword such as `\"left\"`, `\"center\"`,\n * `\"right\"`, `\"start\"`, or `\"end\"`.\n * @returns This Glyph, for method chaining.\n */\n setTextAlign(value: string): this {\n this._options.textAlign = value;\n this.setElementCSSRule(\"textAlign\", value);\n\n return this;\n }\n\n /**\n * Returns the currently-playing animation kind, or `null` when none is\n * active.\n *\n * @returns The active {@link GlyphAnimation}, or `null`.\n */\n getAnimated(): GlyphAnimation | null {\n return this._glyphAnimation;\n }\n\n /**\n * Starts the named animation, or stops the current one when `kind` is\n * `null`. No-op when the requested kind already matches the current one.\n *\n * @param kind - A {@link GlyphAnimation} value or `null` to stop.\n * @returns This Glyph, for method chaining.\n *\n * @remarks\n * Adds the corresponding `ts-ui-glyph-<kind>` class to the root element.\n * Honours [`Animation.isReducedMotion`](/api/core/namespaces/Animation/functions/isReducedMotion):\n * when reduced-motion is on, the class is not mounted but the requested\n * kind is cached and a module-level listener re-applies it should the OS\n * preference flip back. While motion is active, `will-change: transform`\n * is set via [`Component.setWillChange`](/api/core/classes/Component#setwillchange);\n * cleared when motion stops.\n *\n * Differs from the inherited `Component.setAnimation(value: string)`:\n * this is a typed-enum surface that toggles a pre-registered class rule;\n * the inherited setter accepts a raw CSS shorthand and writes a\n * per-component `#id { animation: … }` rule.\n *\n * @example\n * ```typescript\n * const g = new Glyph(\"xmark\");\n * g.setAnimated(\"spin\");\n * g.setAnimated(null); // stop\n * ```\n */\n setAnimated(kind: GlyphAnimation | null): this {\n if (this._glyphAnimation === kind) {\n return this;\n }\n\n const prev = this._glyphAnimation;\n this._glyphAnimation = kind;\n\n const el = this.getElement();\n\n if (el && prev) {\n DOM.sink.apply(el, { removeClass: [CLASS_PREFIX + prev] });\n }\n\n if (kind === null) {\n this.setElementStyle(\"animationDuration\", null);\n this.setWillChange(null);\n\n if (this._animatedRef) {\n _animatedRefs.delete(this._animatedRef);\n this._animatedRef = null;\n }\n\n return this;\n }\n\n ensureGlyphKeyframes();\n\n if (!this._animatedRef) {\n this._animatedRef = new WeakRef(this);\n _animatedRefs.add(this._animatedRef);\n }\n\n if (!Animation.isReducedMotion()) {\n if (el) {\n DOM.sink.apply(el, { addClass: [CLASS_PREFIX + kind] });\n }\n\n this.setWillChange(\"transform\");\n }\n\n if (this._glyphAnimationDuration > 0) {\n this.setElementStyle(\"animationDuration\", this._glyphAnimationDuration + \"ms\");\n }\n\n return this;\n }\n\n /**\n * Stops the current animation. Equivalent to `setAnimated(null)`.\n *\n * @returns This Glyph, for method chaining.\n */\n clearAnimated(): this {\n return this.setAnimated(null);\n }\n\n /**\n * Returns the override duration (ms) set via {@link setAnimationDuration},\n * or `0` when no override is active. Read the active CSS custom property\n * (`--ts-ui-glyph-<kind>-duration`) for the live value when no override\n * is set.\n *\n * @returns The override duration in ms, or `0`.\n */\n getAnimationDuration(): number {\n return this._glyphAnimationDuration;\n }\n\n /**\n * Overrides the active animation's duration. Pass `0` to clear the\n * override and fall back to the theme-token default. No visible effect\n * when no animation is currently set, but the override is cached and\n * will apply on the next {@link setAnimated} call.\n *\n * @param ms - Duration in milliseconds, or `0` to clear.\n * @returns This Glyph, for method chaining.\n */\n setAnimationDuration(ms: number): this {\n this._glyphAnimationDuration = ms;\n\n if (this._glyphAnimation !== null && !Animation.isReducedMotion()) {\n this.setElementStyle(\"animationDuration\", ms > 0 ? ms + \"ms\" : null);\n }\n\n return this;\n }\n\n /**\n * Re-applies (or removes) the animation class to match the current\n * `prefers-reduced-motion` state. Called by the module-level listener\n * when the OS preference flips. Internal; not part of the public API.\n */\n _syncReducedMotion(): void {\n const kind = this._glyphAnimation;\n if (!kind) {\n return;\n }\n\n const element = this.getElement(true)!;\n const className = CLASS_PREFIX + kind;\n\n if (Animation.isReducedMotion()) {\n DOM.sink.apply(element, { removeClass: [className] });\n this.setWillChange(null);\n this.setElementStyle(\"animationDuration\", null);\n } else {\n DOM.sink.apply(element, { addClass: [className] });\n this.setWillChange(\"transform\");\n\n if (this._glyphAnimationDuration > 0) {\n this.setElementStyle(\"animationDuration\", this._glyphAnimationDuration + \"ms\");\n }\n }\n }\n\n /**\n * Applies a {@link GlyphOptions} bag by dispatching each present field to\n * its corresponding setter.\n *\n * @param options - The options bag carrying the values to apply.\n * @returns This Glyph, for method chaining.\n */\n protected applyOptions(options: GlyphOptions): this {\n super.applyOptions(options);\n\n if (options.fontSize !== undefined) {\n this.setFontSize(options.fontSize);\n }\n\n if (options.lineHeight !== undefined) {\n this.setLineHeight(options.lineHeight);\n }\n\n if (options.textAlign !== undefined) {\n this.setTextAlign(options.textAlign);\n }\n\n if (options.animationDuration !== undefined) {\n this.setAnimationDuration(options.animationDuration);\n }\n\n // Re-pin minSize / maxSize to the current preferred size so the glyph\n // stays rigid in flexible layouts. The inherited cascade has just\n // overwritten the pin from `setPreferredSize` with Component's `{0,0}`\n // minSize / `{MAX,MAX}` maxSize defaults; restore it here, but honour\n // an explicit `options.minSize` / `options.maxSize` from the caller.\n const pref = this.getPreferredSizeConstraint();\n if (pref) {\n if (options.minSize === undefined) {\n this.setMinSize({ width: pref.width, height: pref.height });\n }\n\n if (options.maxSize === undefined) {\n this.setMaxSize({ width: pref.width, height: pref.height });\n }\n }\n\n if (options.animation !== undefined) {\n this.setAnimated(options.animation);\n }\n\n return this;\n }\n\n /**\n * Creates the root element, using the SVG namespace when the registry\n * entry is an SVG definition. SVG instances reference a shared sprite\n * symbol rather than inlining the path data.\n *\n * @returns The root element for this Glyph (HTML `<span>` or SVG `<svg>`).\n */\n protected createRootElement(): Handle {\n if (this._def.kind === \"svg\") {\n ensureGlyphSprite();\n ensureGlyphSymbolMounted(this._name);\n\n const svgNs = \"http://www.w3.org/2000/svg\";\n const svg = DOM.sink.createElementNS(svgNs, \"svg\");\n DOM.sink.apply(svg, { setAttr: { fill: \"currentColor\", \"aria-hidden\": \"true\", focusable: \"false\" } });\n\n const use = DOM.sink.createElementNS(svgNs, \"use\");\n DOM.sink.apply(use, { setAttr: { href: \"#\" + GLYPH_SYMBOL_ID_PREFIX + this._name } });\n DOM.sink.appendChild(svg, use);\n\n // Track the `<use>` child so it is released with the glyph (the root\n // `svg` is tracked by Component.render). Released on destructor or GC.\n this.trackHandle(use);\n\n return svg;\n }\n\n return super.createRootElement();\n }\n\n /**\n * Populates the rendered element. For char-mode glyphs the character is\n * written into the span's text content; SVG-mode element children are\n * created by `createRootElement`.\n *\n * Applies `preferredSize` as inline width/height so SVG glyphs appended\n * raw via `glyph.getElement(true)` outside a framework layout don't fall\n * back to the user-agent's 300×150 default replaced-element size.\n *\n * @returns The rendered root element.\n */\n protected render(): Handle {\n const element = super.render();\n\n if (this._def.kind === \"char\") {\n DOM.sink.apply(element, { text: this._def.char });\n }\n\n if (this._glyphAnimation && !Animation.isReducedMotion()) {\n DOM.sink.apply(element, { addClass: [CLASS_PREFIX + this._glyphAnimation] });\n }\n\n const preferredSize = this._options.preferredSize;\n if (preferredSize) {\n this.setElementStyle(\"width\", preferredSize.width + \"px\");\n this.setElementStyle(\"height\", preferredSize.height + \"px\");\n }\n\n return element;\n }\n}\n\nconst GlyphCallable = callable(Glyph);\ntype GlyphCallable = Glyph;\nexport {\n Glyph as _Glyph,\n GlyphCallable as Glyph\n};\n"],"mappings":"uGAiCA,IAAM,EAAiC,IAAI,IAS3C,EAAQ,IAAI,mBAAuB,CAAE,KAAM,OAAQ,KAAM,GAAI,CAAC,EAC9D,EAAQ,IAAI,qBAAuB,CAAE,KAAM,OAAQ,KAAM,GAAI,CAAC,EAC9D,EAAQ,IAAI,qBAAuB,CAAE,KAAM,OAAQ,KAAM,GAAI,CAAC,EAC9D,EAAQ,IAAI,sBAAuB,CAAE,KAAM,OAAQ,KAAM,GAAI,CAAC,EAE9D,IAAM,EAAS,6BAOF,EAAyB,YAElC,EAAiC,GACjC,EAAgC,KASpC,SAAgB,cAAc,EAA0B,CACpD,EAAQ,IAAI,EAAI,KAAM,CAAG,EAErB,EAAI,OAAS,OAAS,GACtB,mBAAmB,EAAI,KAAM,CAAG,CAExC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AEA,OAAO,MAAM,kBAAkB,CACnC,CAaA,QAA2B,CACvB,IAAM,EAAU,MAAM,OAAO,EAEzB,KAAK,KAAK,OAAS,QACnB,EAAI,KAAK,MAAM,EAAS,CAAE,KAAM,KAAK,KAAK,IAAK,CAAC,EAGhD,KAAK,iBAAmB,CAAC,EAAU,gBAAgB,GACnD,EAAI,KAAK,MAAM,EAAS,CAAE,SAAU,CAAC,EAAe,KAAK,eAAe,CAAE,CAAC,EAG/E,IAAM,EAAgB,KAAK,SAAS,cAMpC,OALI,IACA,KAAK,gBAAgB,QAAU,EAAc,MAAS,IAAI,EAC1D,KAAK,gBAAgB,SAAU,EAAc,OAAS,IAAI,GAGvD,CACX,CACJ,EAEM,EAAgB,EAAS,KAAK"}
@@ -1,2 +1,2 @@
1
- import{a as e,l as t,o as n,s as r}from"./Position-B-WfZYAJ.js";import{d as i,f as a,l as o,u as s}from"./Component-BR2f0Itb.js";var Grid=class extends o{_rows=0;_columns=0;_spacing=5;_defaultFill=i.BOTH;_defaultAnchor=s.CENTER;_baselineAlign=!1;_columnTracks=[];_rowTracks=[];constructor(e){super(),e&&this.applyOptions(e)}applyOptions(e){super.applyOptions(e),e.rows!==void 0&&this.setRows(e.rows),e.columns!==void 0&&this.setColumns(e.columns),e.spacing!==void 0&&this.setComponentSpacing(e.spacing),e.defaultFill!==void 0&&this.setDefaultFill(e.defaultFill),e.defaultAnchor!==void 0&&this.setDefaultAnchor(e.defaultAnchor),e.baselineAlign!==void 0&&this.setBaselineAlign(e.baselineAlign),e.columnTracks!==void 0&&this.setColumnTracks(e.columnTracks),e.rowTracks!==void 0&&this.setRowTracks(e.rowTracks)}getDefaultFill(){return this._defaultFill}setDefaultFill(e){return this._defaultFill=e,this}getDefaultAnchor(){return this._defaultAnchor}setDefaultAnchor(e){return this._defaultAnchor=e,this}isBaselineAlign(){return this._baselineAlign}setBaselineAlign(e){return this._baselineAlign=e,this}getRows(){return this._rows}setRows(e){return this._rows=e,this}getComponentSpacing(){return this._spacing||0}setComponentSpacing(e){return this._spacing=e||0,this}getColumns(){return this._columns}setColumns(e){return this._columns=e,this}getColumnTracks(){return this._columnTracks}setColumnTracks(e){return this._columnTracks=e,this}getRowTracks(){return this._rowTracks}setRowTracks(e){return this._rowTracks=e,this}getColRowCount(){let e=this.getContainer();if(!e)return;let t=e.getLaidOutComponents().length,n=0,r=0;return!this._rows&&!this._columns?(r=Math.floor(Math.sqrt(t)),n=Math.ceil(t/r)):this._rows&&this._columns?(n=this._rows,r=this._columns):this._columns?(r=this._columns,n=Math.ceil(t/r)):(n=this._rows,r=Math.ceil(t/n)),{width:r,height:n}}getPreferredSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=e.getLaidOutComponents(),a=0,o=0;for(let e of i){let t=e.getPreferredSize();t&&(a=Math.max(a,t.width),o=Math.max(o,t.height))}let s=this.getColRowCount(),c=s?s.width:1,l=s?s.height:1,u=this.getComponentSpacing(),d=this.measureContent(i,c,l),f=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,c,d.columns,!0):a*c,p=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,l,d.rows,!0):o*l;return f+=Math.max(0,c-1)*u,p+=Math.max(0,l-1)*u,{width:f+n,height:p+r}}getMinSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=e.getLaidOutComponents(),a=0,o=0;for(let e of i){let t=e.getMinSize();t&&(a=Math.max(a,t.width),o=Math.max(o,t.height))}let s=this.getColRowCount(),c=s?s.width:1,l=s?s.height:1,u=this.getComponentSpacing(),d=this.measureContent(i,c,l),f=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,c,d.columns,!1):a*c,p=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,l,d.rows,!1):o*l;return f+=Math.max(0,c-1)*u,p+=Math.max(0,l-1)*u,{width:f+n,height:p+r}}getMaxSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,i=t.top+t.bottom,a=e.getLaidOutComponents(),o=this.getColRowCount(),s=o?o.width:1,c=o?o.height:1,l=this.getComponentSpacing(),u=this.measureContent(a,s,c),d=this._columnTracks.length>0?this.trackAxisMax(this._columnTracks,s,u.columns):s*this.maxChildExtent(a,!0),f=this._rowTracks.length>0?this.trackAxisMax(this._rowTracks,c,u.rows):c*this.maxChildExtent(a,!1);return{width:r(d+Math.max(0,s-1)*l+n),height:r(f+Math.max(0,c-1)*l+i)}}trackAxisMax(t,n,r){let i=0;for(let a=0;a<n;a+=1){let n=t[a]??{mode:`weight`,value:1};if(n.mode===`fixed`)i+=n.value??0;else if(n.mode===`content`)i+=r[a]??0;else return e}return i}maxChildExtent(t,r){let i=0;for(let a of t){let t=a.getMaxSize();if(!t)return e;let o=r?t.width:t.height;if(n(o))return e;i=Math.max(i,o)}return i}computeTotalMinSize(){let e=this.getContainer();if(!e)return{width:0,height:0};let t=e.getLaidOutComponents();if(t.length===0)return{width:0,height:0};let n=this.getColRowCount(),r=n?n.width:1,i=n?n.height:1,a=this.getComponentSpacing(),o=0,s=0;for(let e of t){let t=e.getMinSize();t&&(o=Math.max(o,t.width),s=Math.max(s,t.height))}let c=this.measureContent(t,r,i),l=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,r,c.columns,!1):r*o,u=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,i,c.rows,!1):i*s;return{width:l+Math.max(0,r-1)*a,height:u+Math.max(0,i-1)*a}}trackAxisExtent(e,t,n,r){let i=0;for(let a=0;a<t;a+=1){let t=e[a]??{mode:`weight`,value:1};t.mode===`fixed`?i+=t.value??0:(t.mode===`content`||r)&&(i+=n[a]??0)}return i}doLayout(){let e=this.getContainer();if(!e)return;let n=e.getLaidOutComponents(),r=e.getContentInsets(),i=e.getInnerSize();if(!i)return;let a=this.getColRowCount(),o=a?a.width:1,s=a?a.height:1,c=this.getComponentSpacing();if(i=this.inflateForOverflow(i),!this._baselineAlign){this.layoutOccupancy(n,o,s,i,r,c);return}let l=this.measureContent(n,o,s),u=this.resolveTracks(this._columnTracks,o,i.width,c,l.columns),d=this.resolveTracks(this._rowTracks,s,i.height,c,l.rows),f=Array.from({length:s},()=>[]),p=0,m=0;for(let e of n){if(m>=s)break;let n=this.getLayoutConstraints(e),r=t.clamp(n?.colSpan??1,1,o),i=e.getPreferredSize();f[m].push({component:e,col:p,colSpan:r,height:i?i.height:0,baseline:e.getBaseline()}),p+=r,p>=o&&(p=0,m+=1)}let h=r.getTop();for(let e=0;e<s;e+=1){let t=f[e],{rowAscent:n,rowDescent:i}=this.computeRowMetrics(t.map(e=>e.height),t.map(e=>e.baseline));for(let e of t){let t=r.getLeft();for(let n=0;n<e.col;n+=1)t+=(u[n]??0)+c;let a=(e.colSpan-1)*c;for(let t=e.col;t<e.col+e.colSpan;t+=1)a+=u[t]??0;let o;o=n===null?h:e.baseline===null?h+this.nullChildY(e.height,n,i):h+(n-e.baseline),this.placeComponent(e.component,t,o,a,e.height,this._defaultFill,this._defaultAnchor)}let a=n===null?0:n+i;h+=Math.max(d[e]??0,a)+c}}resolveTracks(e,t,n,r,i){let a=n-Math.max(0,t-1)*r,o=Array(t).fill(0),s=0,c=0,l=0;for(let n=0;n<t;n+=1){let t=e[n]??{mode:`weight`,value:1};t.mode===`fixed`?(o[n]=t.value??0,s+=o[n]):t.mode===`content`?(o[n]=i[n]??0,c+=o[n]):l+=Math.max(0,t.value??1)}let u=Math.max(0,a-s-c);if(l>0)for(let n=0;n<t;n+=1){let t=e[n]??{mode:`weight`,value:1};t.mode===`weight`&&(o[n]=u*(Math.max(0,t.value??1)/l))}return o}measureContent(e,n,r){let i=Array(n).fill(0),a=Array(r).fill(0),o=this._baselineAlign?Array.from({length:r},()=>[]):[],s=this._baselineAlign?Array.from({length:r},()=>[]):[],c=0,l=0;for(let u of e){let e=this.getLayoutConstraints(u),d=u.getPreferredSize(),f=u.getMinSize(),p=Math.max(d?d.width:0,f?f.width:0),m=Math.max(d?d.height:0,f?f.height:0),h=Math.max(1,e?.colSpan??1),g=Math.max(1,e?.rowSpan??1),_,v;e&&(e.col!=null||e.row!=null)?(_=t.clamp(e.col??0,0,Math.max(0,n-1)),v=t.clamp(e.row??0,0,Math.max(0,r-1))):(_=c,v=l,c+=h,c>=n&&(c=0,l+=g)),h===1&&_<n&&(i[_]=Math.max(i[_],p)),g===1&&v<r&&(a[v]=Math.max(a[v],m),this._baselineAlign&&(o[v].push(d?d.height:0),s[v].push(u.getBaseline())))}if(this._baselineAlign)for(let e=0;e<r;e+=1){let{rowAscent:t,rowDescent:n}=this.computeRowMetrics(o[e],s[e]);t!==null&&(a[e]=Math.max(a[e],t+n))}return{columns:i,rows:a}}layoutOccupancy(e,n,r,i,a,o){let s=this.measureContent(e,n,r),c=this.resolveTracks(this._columnTracks,n,i.width,o,s.columns),l=this.resolveTracks(this._rowTracks,r,i.height,o,s.rows),u=[];for(let e=0;e<r;e+=1)u.push(Array(n).fill(!1));let d=[];for(let e=0;e<r;e+=1)d.push(Array(n).fill(null));let placeAt=(e,t,n,r,i)=>{let s=a.getLeft();for(let e=0;e<n;e+=1)s+=c[e]+o;let u=a.getTop();for(let e=0;e<t;e+=1)u+=l[e]+o;let d=(i-1)*o;for(let e=n;e<n+i;e+=1)d+=c[e]??0;let f=(r-1)*o;for(let e=t;e<t+r;e+=1)f+=l[e]??0;let p=e.getMinSize();if(p&&(p.width>d||p.height>f)){let t=this.resolveBounds(e,s,u,d,f,this._defaultFill,this._defaultAnchor),n=e.getPreferredSize(),r=p.width>d?n?n.width:p.width:t.width,i=p.height>f?n?n.height:p.height:t.height;e.setClipFrame(s,u,d,f),this.commitBounds(e,t.x-s,t.y-u,r,i)}else{let t=this.resolveBounds(e,s,u,d,f,this._defaultFill,this._defaultAnchor);e.clearClipFrame(),this.commitBounds(e,t.x,t.y,t.width,t.height)}};for(let i of e){let e=this.getLayoutConstraints(i);if(!e||e.col==null&&e.row==null)continue;let a=t.clamp(e.col??0,0,Math.max(0,n-1)),o=t.clamp(e.row??0,0,Math.max(0,r-1)),s=t.clamp(e.colSpan??1,1,n-a),c=t.clamp(e.rowSpan??1,1,r-o);for(let e=o;e<o+c;e+=1)for(let t=a;t<a+s;t+=1)u[e][t]&&console.warn(`Grid: ${i.getId()} overlaps ${d[e][t]} at cell (${e},${t})`),u[e][t]=!0,d[e][t]=i.getId();placeAt(i,o,a,c,s)}for(let i of e){let e=this.getLayoutConstraints(i);if(e&&(e.col!=null||e.row!=null))continue;let a=t.clamp(e?.colSpan??1,1,n),o=t.clamp(e?.rowSpan??1,1,r),s=this.findFreeCell(u,r,n,o,a);if(s){for(let e=s.r;e<s.r+o;e+=1)for(let t=s.c;t<s.c+a;t+=1)u[e][t]=!0,d[e][t]=i.getId();placeAt(i,s.r,s.c,o,a)}}}findFreeCell(e,t,n,r,i){for(let a=0;a+r<=t;a+=1)for(let t=0;t+i<=n;t+=1){let n=!0;for(let o=a;o<a+r&&n;o+=1)for(let r=t;r<t+i;r+=1)if(e[o][r]){n=!1;break}if(n)return{r:a,c:t}}return null}},c=a(Grid);export{c as t};
2
- //# sourceMappingURL=Grid-Czux--Mr.js.map
1
+ import{a as e,l as t,o as n,s as r}from"./Position-A39T7-_1.js";import{d as i,f as a,l as o,u as s}from"./Component-DXf5a3g0.js";var Grid=class extends o{_rows=0;_columns=0;_spacing=5;_defaultFill=i.BOTH;_defaultAnchor=s.CENTER;_baselineAlign=!1;_columnTracks=[];_rowTracks=[];constructor(e){super(),e&&this.applyOptions(e)}applyOptions(e){super.applyOptions(e),e.rows!==void 0&&this.setRows(e.rows),e.columns!==void 0&&this.setColumns(e.columns),e.spacing!==void 0&&this.setComponentSpacing(e.spacing),e.defaultFill!==void 0&&this.setDefaultFill(e.defaultFill),e.defaultAnchor!==void 0&&this.setDefaultAnchor(e.defaultAnchor),e.baselineAlign!==void 0&&this.setBaselineAlign(e.baselineAlign),e.columnTracks!==void 0&&this.setColumnTracks(e.columnTracks),e.rowTracks!==void 0&&this.setRowTracks(e.rowTracks)}getDefaultFill(){return this._defaultFill}setDefaultFill(e){return this._defaultFill=e,this}getDefaultAnchor(){return this._defaultAnchor}setDefaultAnchor(e){return this._defaultAnchor=e,this}isBaselineAlign(){return this._baselineAlign}setBaselineAlign(e){return this._baselineAlign=e,this}getRows(){return this._rows}setRows(e){return this._rows=e,this}getComponentSpacing(){return this._spacing||0}setComponentSpacing(e){return this._spacing=e||0,this}getColumns(){return this._columns}setColumns(e){return this._columns=e,this}getColumnTracks(){return this._columnTracks}setColumnTracks(e){return this._columnTracks=e,this}getRowTracks(){return this._rowTracks}setRowTracks(e){return this._rowTracks=e,this}getColRowCount(){let e=this.getContainer();if(!e)return;let t=e.getLaidOutComponents().length,n=0,r=0;return!this._rows&&!this._columns?(r=Math.floor(Math.sqrt(t)),n=Math.ceil(t/r)):this._rows&&this._columns?(n=this._rows,r=this._columns):this._columns?(r=this._columns,n=Math.ceil(t/r)):(n=this._rows,r=Math.ceil(t/n)),{width:r,height:n}}getPreferredSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=e.getLaidOutComponents(),a=0,o=0;for(let e of i){let t=e.getPreferredSize();t&&(a=Math.max(a,t.width),o=Math.max(o,t.height))}let s=this.getColRowCount(),c=s?s.width:1,l=s?s.height:1,u=this.getComponentSpacing(),d=this.measureContent(i,c,l),f=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,c,d.columns,!0):a*c,p=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,l,d.rows,!0):o*l;return f+=Math.max(0,c-1)*u,p+=Math.max(0,l-1)*u,{width:f+n,height:p+r}}getMinSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,r=t.top+t.bottom,i=e.getLaidOutComponents(),a=0,o=0;for(let e of i){let t=e.getMinSize();t&&(a=Math.max(a,t.width),o=Math.max(o,t.height))}let s=this.getColRowCount(),c=s?s.width:1,l=s?s.height:1,u=this.getComponentSpacing(),d=this.measureContent(i,c,l),f=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,c,d.columns,!1):a*c,p=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,l,d.rows,!1):o*l;return f+=Math.max(0,c-1)*u,p+=Math.max(0,l-1)*u,{width:f+n,height:p+r}}getMaxSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=t.left+t.right,i=t.top+t.bottom,a=e.getLaidOutComponents(),o=this.getColRowCount(),s=o?o.width:1,c=o?o.height:1,l=this.getComponentSpacing(),u=this.measureContent(a,s,c),d=this._columnTracks.length>0?this.trackAxisMax(this._columnTracks,s,u.columns):s*this.maxChildExtent(a,!0),f=this._rowTracks.length>0?this.trackAxisMax(this._rowTracks,c,u.rows):c*this.maxChildExtent(a,!1);return{width:r(d+Math.max(0,s-1)*l+n),height:r(f+Math.max(0,c-1)*l+i)}}trackAxisMax(t,n,r){let i=0;for(let a=0;a<n;a+=1){let n=t[a]??{mode:`weight`,value:1};if(n.mode===`fixed`)i+=n.value??0;else if(n.mode===`content`)i+=r[a]??0;else return e}return i}maxChildExtent(t,r){let i=0;for(let a of t){let t=a.getMaxSize();if(!t)return e;let o=r?t.width:t.height;if(n(o))return e;i=Math.max(i,o)}return i}computeTotalMinSize(){let e=this.getContainer();if(!e)return{width:0,height:0};let t=e.getLaidOutComponents();if(t.length===0)return{width:0,height:0};let n=this.getColRowCount(),r=n?n.width:1,i=n?n.height:1,a=this.getComponentSpacing(),o=0,s=0;for(let e of t){let t=e.getMinSize();t&&(o=Math.max(o,t.width),s=Math.max(s,t.height))}let c=this.measureContent(t,r,i),l=this._columnTracks.length>0?this.trackAxisExtent(this._columnTracks,r,c.columns,!1):r*o,u=this._rowTracks.length>0?this.trackAxisExtent(this._rowTracks,i,c.rows,!1):i*s;return{width:l+Math.max(0,r-1)*a,height:u+Math.max(0,i-1)*a}}trackAxisExtent(e,t,n,r){let i=0;for(let a=0;a<t;a+=1){let t=e[a]??{mode:`weight`,value:1};t.mode===`fixed`?i+=t.value??0:(t.mode===`content`||r)&&(i+=n[a]??0)}return i}doLayout(){let e=this.getContainer();if(!e)return;let n=e.getLaidOutComponents(),r=e.getContentInsets(),i=e.getInnerSize();if(!i)return;let a=this.getColRowCount(),o=a?a.width:1,s=a?a.height:1,c=this.getComponentSpacing();if(i=this.inflateForOverflow(i),!this._baselineAlign){this.layoutOccupancy(n,o,s,i,r,c);return}let l=this.measureContent(n,o,s),u=this.resolveTracks(this._columnTracks,o,i.width,c,l.columns),d=this.resolveTracks(this._rowTracks,s,i.height,c,l.rows),f=Array.from({length:s},()=>[]),p=0,m=0;for(let e of n){if(m>=s)break;let n=this.getLayoutConstraints(e),r=t.clamp(n?.colSpan??1,1,o),i=e.getPreferredSize();f[m].push({component:e,col:p,colSpan:r,height:i?i.height:0,baseline:e.getBaseline()}),p+=r,p>=o&&(p=0,m+=1)}let h=r.getTop();for(let e=0;e<s;e+=1){let t=f[e],{rowAscent:n,rowDescent:i}=this.computeRowMetrics(t.map(e=>e.height),t.map(e=>e.baseline));for(let e of t){let t=r.getLeft();for(let n=0;n<e.col;n+=1)t+=(u[n]??0)+c;let a=(e.colSpan-1)*c;for(let t=e.col;t<e.col+e.colSpan;t+=1)a+=u[t]??0;let o;o=n===null?h:e.baseline===null?h+this.nullChildY(e.height,n,i):h+(n-e.baseline),this.placeComponent(e.component,t,o,a,e.height,this._defaultFill,this._defaultAnchor)}let a=n===null?0:n+i;h+=Math.max(d[e]??0,a)+c}}resolveTracks(e,t,n,r,i){let a=n-Math.max(0,t-1)*r,o=Array(t).fill(0),s=0,c=0,l=0;for(let n=0;n<t;n+=1){let t=e[n]??{mode:`weight`,value:1};t.mode===`fixed`?(o[n]=t.value??0,s+=o[n]):t.mode===`content`?(o[n]=i[n]??0,c+=o[n]):l+=Math.max(0,t.value??1)}let u=Math.max(0,a-s-c);if(l>0)for(let n=0;n<t;n+=1){let t=e[n]??{mode:`weight`,value:1};t.mode===`weight`&&(o[n]=u*(Math.max(0,t.value??1)/l))}return o}measureContent(e,n,r){let i=Array(n).fill(0),a=Array(r).fill(0),o=this._baselineAlign?Array.from({length:r},()=>[]):[],s=this._baselineAlign?Array.from({length:r},()=>[]):[],c=0,l=0;for(let u of e){let e=this.getLayoutConstraints(u),d=u.getPreferredSize(),f=u.getMinSize(),p=Math.max(d?d.width:0,f?f.width:0),m=Math.max(d?d.height:0,f?f.height:0),h=Math.max(1,e?.colSpan??1),g=Math.max(1,e?.rowSpan??1),_,v;e&&(e.col!=null||e.row!=null)?(_=t.clamp(e.col??0,0,Math.max(0,n-1)),v=t.clamp(e.row??0,0,Math.max(0,r-1))):(_=c,v=l,c+=h,c>=n&&(c=0,l+=g)),h===1&&_<n&&(i[_]=Math.max(i[_],p)),g===1&&v<r&&(a[v]=Math.max(a[v],m),this._baselineAlign&&(o[v].push(d?d.height:0),s[v].push(u.getBaseline())))}if(this._baselineAlign)for(let e=0;e<r;e+=1){let{rowAscent:t,rowDescent:n}=this.computeRowMetrics(o[e],s[e]);t!==null&&(a[e]=Math.max(a[e],t+n))}return{columns:i,rows:a}}layoutOccupancy(e,n,r,i,a,o){let s=this.measureContent(e,n,r),c=this.resolveTracks(this._columnTracks,n,i.width,o,s.columns),l=this.resolveTracks(this._rowTracks,r,i.height,o,s.rows),u=[];for(let e=0;e<r;e+=1)u.push(Array(n).fill(!1));let d=[];for(let e=0;e<r;e+=1)d.push(Array(n).fill(null));let placeAt=(e,t,n,r,i)=>{let s=a.getLeft();for(let e=0;e<n;e+=1)s+=c[e]+o;let u=a.getTop();for(let e=0;e<t;e+=1)u+=l[e]+o;let d=(i-1)*o;for(let e=n;e<n+i;e+=1)d+=c[e]??0;let f=(r-1)*o;for(let e=t;e<t+r;e+=1)f+=l[e]??0;let p=e.getMinSize();if(p&&(p.width>d||p.height>f)){let t=this.resolveBounds(e,s,u,d,f,this._defaultFill,this._defaultAnchor),n=e.getPreferredSize(),r=p.width>d?n?n.width:p.width:t.width,i=p.height>f?n?n.height:p.height:t.height;e.setClipFrame(s,u,d,f),this.commitBounds(e,t.x-s,t.y-u,r,i)}else{let t=this.resolveBounds(e,s,u,d,f,this._defaultFill,this._defaultAnchor);e.clearClipFrame(),this.commitBounds(e,t.x,t.y,t.width,t.height)}};for(let i of e){let e=this.getLayoutConstraints(i);if(!e||e.col==null&&e.row==null)continue;let a=t.clamp(e.col??0,0,Math.max(0,n-1)),o=t.clamp(e.row??0,0,Math.max(0,r-1)),s=t.clamp(e.colSpan??1,1,n-a),c=t.clamp(e.rowSpan??1,1,r-o);for(let e=o;e<o+c;e+=1)for(let t=a;t<a+s;t+=1)u[e][t]&&console.warn(`Grid: ${i.getId()} overlaps ${d[e][t]} at cell (${e},${t})`),u[e][t]=!0,d[e][t]=i.getId();placeAt(i,o,a,c,s)}for(let i of e){let e=this.getLayoutConstraints(i);if(e&&(e.col!=null||e.row!=null))continue;let a=t.clamp(e?.colSpan??1,1,n),o=t.clamp(e?.rowSpan??1,1,r),s=this.findFreeCell(u,r,n,o,a);if(s){for(let e=s.r;e<s.r+o;e+=1)for(let t=s.c;t<s.c+a;t+=1)u[e][t]=!0,d[e][t]=i.getId();placeAt(i,s.r,s.c,o,a)}}}findFreeCell(e,t,n,r,i){for(let a=0;a+r<=t;a+=1)for(let t=0;t+i<=n;t+=1){let n=!0;for(let o=a;o<a+r&&n;o+=1)for(let r=t;r<t+i;r+=1)if(e[o][r]){n=!1;break}if(n)return{r:a,c:t}}return null}},c=a(Grid);export{c as t};
2
+ //# sourceMappingURL=Grid-DdL9TVeJ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Grid-D8luwRPI.js","names":[],"sources":["../../src/typescript/lib/layout/Grid.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutManager, LayoutManagerOptions } from \"~/layout/LayoutManager.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { AnchorType } from \"~/layout/AnchorType.js\";\nimport { GridTrack } from \"~/layout/GridTrack.js\";\nimport { GridConstraints } from \"~/layout/GridConstraints.js\";\nimport { Size, UNBOUNDED, isUnbounded, saturate } from \"~/primitive/Size.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { Util } from \"~/core/Util.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Grid}.\n *\n * @category Layouts\n */\nexport interface GridOptions extends LayoutManagerOptions {\n rows?: number;\n columns?: number;\n spacing?: number;\n\n /** Grid-wide fill applied to children that don't set their own `fill`. Default {@link FillType.BOTH}. */\n defaultFill?: FillType;\n\n /** Grid-wide anchor applied to non-filling children that don't set their own `anchor`. Default {@link AnchorType.CENTER}. */\n defaultAnchor?: AnchorType;\n\n /** When `true`, children are baseline-aligned per row (column/row tracks still apply; children use preferred height). Default `false`. */\n baselineAlign?: boolean;\n\n /** Per-column sizing tracks; see {@link GridTrack}. */\n columnTracks?: GridTrack[];\n\n /** Per-row sizing tracks; see {@link GridTrack}. */\n rowTracks?: GridTrack[];\n}\n\n/**\n * A layout manager that tiles children in a uniform grid of equal-sized cells.\n * Row and column counts can be configured explicitly or left at `0` for auto-calculation.\n *\n * @category Layouts\n */\nclass Grid extends LayoutManager {\n\n private _rows: number = 0;\n private _columns: number = 0;\n private _spacing: number = 5;\n private _defaultFill: FillType = FillType.BOTH;\n private _defaultAnchor: AnchorType = AnchorType.CENTER;\n private _baselineAlign: boolean = false;\n private _columnTracks: GridTrack[] = [];\n private _rowTracks: GridTrack[] = [];\n\n constructor(options?: GridOptions) {\n // LayoutManager's constructor takes no options; applied via applyOptions below.\n // eslint-disable-next-line local/forward-super-options\n super();\n\n if (options) {\n this.applyOptions(options);\n }\n }\n\n /**\n * Applies a {@link GridOptions} bag, dispatching grid dimensions, spacing,\n * default fill/anchor, and baseline alignment after the inherited\n * LayoutManager defaults.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: GridOptions): void {\n super.applyOptions(options);\n\n if (options.rows !== undefined) {\n this.setRows(options.rows);\n }\n\n if (options.columns !== undefined) {\n this.setColumns(options.columns);\n }\n\n if (options.spacing !== undefined) {\n this.setComponentSpacing(options.spacing);\n }\n\n if (options.defaultFill !== undefined) {\n this.setDefaultFill(options.defaultFill);\n }\n\n if (options.defaultAnchor !== undefined) {\n this.setDefaultAnchor(options.defaultAnchor);\n }\n\n if (options.baselineAlign !== undefined) {\n this.setBaselineAlign(options.baselineAlign);\n }\n\n if (options.columnTracks !== undefined) {\n this.setColumnTracks(options.columnTracks);\n }\n\n if (options.rowTracks !== undefined) {\n this.setRowTracks(options.rowTracks);\n }\n }\n\n /**\n * Returns the grid-wide default fill applied to children that don't set\n * their own `fill` constraint.\n *\n * @returns The default {@link FillType} (initially {@link FillType.BOTH}).\n */\n getDefaultFill(): FillType {\n return this._defaultFill;\n }\n\n /**\n * Sets the grid-wide default fill. Each child overrides this with its own\n * {@link GridConstraints} `fill`; otherwise this value drives whether the\n * child fills its cell.\n *\n * @param fill - The default fill strategy for children without their own `fill`.\n */\n setDefaultFill(fill: FillType): this {\n this._defaultFill = fill;\n\n return this;\n }\n\n /**\n * Returns the grid-wide default anchor applied to non-filling children that\n * don't set their own `anchor` constraint.\n *\n * @returns The default {@link AnchorType} (initially {@link AnchorType.CENTER}).\n */\n getDefaultAnchor(): AnchorType {\n return this._defaultAnchor;\n }\n\n /**\n * Sets the grid-wide default anchor. Each child overrides this with its own\n * {@link GridConstraints} `anchor`; otherwise this value positions a\n * non-filling child within its cell.\n *\n * @param anchor - The default anchor for children without their own `anchor`.\n */\n setDefaultAnchor(anchor: AnchorType): this {\n this._defaultAnchor = anchor;\n\n return this;\n }\n\n /**\n * Returns whether children are baseline-aligned per row.\n *\n * @returns `true` if per-row baseline alignment is enabled.\n */\n isBaselineAlign(): boolean {\n return this._baselineAlign;\n }\n\n /**\n * Sets whether children are baseline-aligned per row. When `true`, the\n * column/row tracks still size each cell (so a `\"content\"` column hugs its\n * content), each row uses the natural heights of its children, and\n * components are baseline-aligned within the row, mirroring\n * [`HBox`](/api/layout/classes/HBox)'s baseline-aware placement. Orthogonal\n * to {@link Grid.setDefaultFill} — baseline alignment owns the vertical axis\n * while fill/anchor still drive the horizontal axis.\n *\n * @param baselineAlign - Pass `true` to enable per-row baseline alignment.\n */\n setBaselineAlign(baselineAlign: boolean): this {\n this._baselineAlign = baselineAlign;\n\n return this;\n }\n\n /**\n * Returns the configured number of rows, or `0` if the grid auto-calculates row count.\n *\n * @returns The row count.\n */\n getRows() {\n return this._rows;\n }\n\n /**\n * Sets the number of rows. Pass `0` to let the grid auto-calculate.\n *\n * @param rows - The desired row count, or `0` for automatic.\n */\n setRows(rows: number) : this {\n this._rows = rows;\n\n return this;\n }\n\n /**\n * Returns the gap, in pixels, between adjacent cells (horizontally and vertically).\n *\n * @returns The current spacing in pixels.\n */\n getComponentSpacing() {\n return this._spacing || 0;\n }\n\n /**\n * Sets the gap, in pixels, between adjacent cells. Applied both horizontally\n * (between columns) and vertically (between rows).\n *\n * @param spacing - Spacing in pixels. Falsy values are treated as `0`.\n */\n setComponentSpacing(spacing: number) : this {\n this._spacing = spacing || 0;\n\n return this;\n }\n\n /**\n * Returns the configured number of columns, or `0` if the grid auto-calculates column count.\n *\n * @returns The column count.\n */\n getColumns() {\n return this._columns;\n }\n\n /**\n * Sets the number of columns. Pass `0` to let the grid auto-calculate.\n *\n * @param columns - The desired column count, or `0` for automatic.\n */\n setColumns(columns: number) : this {\n this._columns = columns;\n\n return this;\n }\n\n /**\n * Returns the per-column sizing tracks.\n *\n * @returns The configured column tracks; empty when columns size uniformly.\n */\n getColumnTracks(): GridTrack[] {\n return this._columnTracks;\n }\n\n /**\n * Sets the per-column sizing tracks. When fewer tracks are supplied than the\n * grid has columns, the missing tracks default to `{ mode: \"weight\", value: 1 }`.\n *\n * @param tracks - The column tracks; see {@link GridTrack}.\n */\n setColumnTracks(tracks: GridTrack[]): this {\n this._columnTracks = tracks;\n\n return this;\n }\n\n /**\n * Returns the per-row sizing tracks.\n *\n * @returns The configured row tracks; empty when rows size uniformly.\n */\n getRowTracks(): GridTrack[] {\n return this._rowTracks;\n }\n\n /**\n * Sets the per-row sizing tracks. When fewer tracks are supplied than the\n * grid has rows, the missing tracks default to `{ mode: \"weight\", value: 1 }`.\n *\n * @param tracks - The row tracks; see {@link GridTrack}.\n */\n setRowTracks(tracks: GridTrack[]): this {\n this._rowTracks = tracks;\n\n return this;\n }\n\n /**\n * Returns the computed cell count for the current component list as `{width: rows, height: columns}`.\n *\n * @returns An object with `width` (row count) and `height` (column count), or `undefined` if no container is attached.\n *\n * @remarks The property names `width` and `height` are repurposed here to\n * carry column and row counts rather than pixel dimensions —\n * `result.width` is the column count, `result.height` is the row count.\n */\n getColRowCount() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n let components = container.getLaidOutComponents();\n let componentCount = components.length;\n\n let rows = 0;\n let columns = 0;\n\n if (!this._rows && !this._columns) {\n columns = Math.floor(Math.sqrt(componentCount));\n rows = Math.ceil(componentCount / columns);\n } else if (this._rows && this._columns) {\n rows = this._rows;\n columns = this._columns;\n } else if (this._columns) {\n columns = this._columns;\n rows = Math.ceil(componentCount / columns);\n } else {\n rows = this._rows;\n columns = Math.ceil(componentCount / rows);\n }\n\n return {\n width: columns,\n height: rows\n };\n }\n\n /**\n * Returns the preferred size. With tracks declared, this is the sum of the\n * per-track preferred extents (fixed tracks their value, content *and*\n * weight tracks their measured content — wide/tall enough to show every\n * cell at its natural size) plus spacing. Track-less grids keep the uniform\n * `maxChildPreferred * count` estimate.\n *\n * @returns The preferred `{width, height}`, or `null` if no container is attached.\n */\n getPreferredSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n let size = component.getPreferredSize();\n\n if (size) {\n maxCellWidth = Math.max(maxCellWidth, size.width);\n maxCellHeight = Math.max(maxCellHeight, size.height);\n }\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n let innerWidth = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, true)\n : maxCellWidth * cols;\n\n let innerHeight = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, true)\n : maxCellHeight * rows;\n\n innerWidth += Math.max(0, cols - 1) * spacing;\n innerHeight += Math.max(0, rows - 1) * spacing;\n\n return {\n width: innerWidth + outerWidth,\n height: innerHeight + outerHeight\n };\n }\n\n /**\n * Returns the minimum size. With tracks declared, this is the sum of the\n * per-track minima (fixed tracks their value, content tracks their measured\n * content, weight tracks `0`) plus spacing — matching what `doLayout`\n * actually lays out, so a host no longer over-reserves space the way the\n * uniform `maxChildMin * count` estimate did. Track-less grids keep that\n * uniform estimate.\n *\n * @returns The minimum `{width, height}`, or `null` if no container is attached.\n */\n getMinSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n let size = component.getMinSize();\n\n if (size) {\n maxCellWidth = Math.max(maxCellWidth, size.width);\n maxCellHeight = Math.max(maxCellHeight, size.height);\n }\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n let innerWidth = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, false)\n : maxCellWidth * cols;\n\n let innerHeight = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, false)\n : maxCellHeight * rows;\n\n innerWidth += Math.max(0, cols - 1) * spacing;\n innerHeight += Math.max(0, rows - 1) * spacing;\n\n return {\n width: innerWidth + outerWidth,\n height: innerHeight + outerHeight\n };\n }\n\n /**\n * Returns the maximum size the grid can usefully occupy: the sum of the\n * per-track maxima plus inter-cell spacing and the container perimeter. A\n * `fixed` track contributes its pixel value, a `content` track its measured\n * content, and a `weight` track is unbounded — so any weight track makes the\n * whole axis unbounded (the grid can absorb arbitrary slack there). With no\n * tracks on an axis the fallback is `cols * maxChildMax` (the uniform-cell\n * estimate), where a child's `null`/sentinel maximum counts as unbounded.\n *\n * @returns The maximum `{width, height}`, or `null` if no container is attached.\n */\n getMaxSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n const innerWidth = this._columnTracks.length > 0\n ? this.trackAxisMax(this._columnTracks, cols, content.columns)\n : cols * this.maxChildExtent(components, true);\n\n const innerHeight = this._rowTracks.length > 0\n ? this.trackAxisMax(this._rowTracks, rows, content.rows)\n : rows * this.maxChildExtent(components, false);\n\n return {\n width: saturate(innerWidth + Math.max(0, cols - 1) * spacing + outerWidth),\n height: saturate(innerHeight + Math.max(0, rows - 1) * spacing + outerHeight)\n };\n }\n\n /**\n * Sums the per-track maxima along one axis: a `fixed` track contributes its\n * pixel value, a `content` track its measured content size, and a `weight`\n * track is unbounded — the first weight track saturates the axis to the\n * unbounded sentinel, since a flex track can grow without limit. A\n * missing track defaults to `weight`, matching {@link trackAxisExtent}.\n *\n * @param tracks - The declared tracks for this axis.\n * @param count - The number of columns (or rows) to size.\n * @param contentSizes - Measured content maxima per track.\n * @returns The summed maximum extent for the axis, excluding spacing.\n */\n private trackAxisMax(tracks: GridTrack[], count: number, contentSizes: number[]): number {\n let total = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n total += track.value ?? 0;\n } else if (track.mode === \"content\") {\n total += contentSizes[i] ?? 0;\n } else {\n return UNBOUNDED;\n }\n }\n\n return total;\n }\n\n /**\n * Returns the largest per-child maximum extent across all children on one\n * axis, for the uniform-cell (no-track) fallback. A child whose maximum is\n * `null` or at the unbounded sentinel makes the whole axis unbounded, so the\n * result saturates to the unbounded sentinel.\n *\n * @param components - The grid's children.\n * @param horizontal - `true` to read each child's max width, `false` for height.\n * @returns The largest child maximum, or the unbounded sentinel when any\n * child is unbounded.\n */\n private maxChildExtent(components: Component[], horizontal: boolean): number {\n let largest = 0;\n\n for (const component of components) {\n const max = component.getMaxSize();\n\n if (!max) {\n return UNBOUNDED;\n }\n\n const extent = horizontal ? max.width : max.height;\n\n if (isUnbounded(extent)) {\n return UNBOUNDED;\n }\n\n largest = Math.max(largest, extent);\n }\n\n return largest;\n }\n\n /**\n * Computes the children's combined minSize along this manager's geometry:\n * width is `cols * maxChildMinWidth + (cols-1) * spacing`; height is\n * `rows * maxChildMinHeight + (rows-1) * spacing`. Used by `doLayout` to\n * inflate the working size when the host has opted into `setOverflowing`.\n *\n * @returns The total min-size; `{ width: 0, height: 0 }` when the\n * container is absent or has no children.\n */\n protected computeTotalMinSize(): Size {\n const container = this.getContainer();\n if (!container) {\n return { width: 0, height: 0 };\n }\n\n const components = container.getLaidOutComponents();\n if (components.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const colRowCount = this.getColRowCount();\n const cols = colRowCount ? colRowCount.width : 1;\n const rows = colRowCount ? colRowCount.height : 1;\n const spacing = this.getComponentSpacing();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n const min = component.getMinSize();\n if (min) {\n maxCellWidth = Math.max(maxCellWidth, min.width);\n maxCellHeight = Math.max(maxCellHeight, min.height);\n }\n }\n\n const content = this.measureContent(components, cols, rows);\n\n // When tracks are declared, the axis minimum is the sum of per-track\n // minima — a `fixed` track needs its fixed value, a `content` track its\n // measured content, and a `weight` track nothing (it flexes to fill\n // slack and clips oversized children, so it imposes no intrinsic floor).\n // This keeps a child that the grid is meant to *clip* (e.g. an oversized\n // child in a fixed column) from inflating the whole grid's min width.\n // With no tracks on an axis, fall back to the uniform `maxChild*count`\n // estimate so non-track grids still drive universal scroll unchanged.\n const widthMin = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, false)\n : cols * maxCellWidth;\n\n const heightMin = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, false)\n : rows * maxCellHeight;\n\n return {\n width: widthMin + Math.max(0, cols - 1) * spacing,\n height: heightMin + Math.max(0, rows - 1) * spacing,\n };\n }\n\n /**\n * Sums the per-track extents along one axis: a `fixed` track contributes its\n * pixel value and a `content` track its measured content size. A `weight`\n * track contributes its measured content when `includeWeightContent` is\n * `true` (the *preferred* extent — wide enough to show its content at\n * natural size) and `0` otherwise (the *minimum* extent — a flex track can\n * shrink to nothing). A missing track (when the list is shorter than\n * `count`) defaults to `weight`, matching `resolveTracks`' weight default.\n *\n * @param tracks - The declared tracks for this axis.\n * @param count - The number of columns (or rows) to size.\n * @param contentSizes - Measured content maxima per track.\n * @param includeWeightContent - Whether weight tracks contribute their\n * measured content (preferred extent) rather than `0` (minimum extent).\n * @returns The summed extent for the axis, excluding spacing.\n */\n private trackAxisExtent(tracks: GridTrack[], count: number, contentSizes: number[], includeWeightContent: boolean): number {\n let total = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n total += track.value ?? 0;\n } else if (track.mode === \"content\") {\n total += contentSizes[i] ?? 0;\n } else if (includeWeightContent) {\n total += contentSizes[i] ?? 0;\n }\n }\n\n return total;\n }\n\n /**\n * Tiles all children in a grid of equal-sized cells, left-to-right then top-to-bottom.\n *\n * @remarks Each cell is sized by the column/row tracks; how a child sits\n * inside its cell is driven by the child's own `fill`/`anchor`\n * ([`GridConstraints`](/api/layout/classes/GridConstraints)) falling back to\n * the grid's {@link Grid.setDefaultFill}/{@link Grid.setDefaultAnchor}\n * (default {@link FillType.BOTH}, so children fill their cells out of the\n * box). When {@link Grid.setBaselineAlign} is enabled, the column/row tracks\n * still size each cell (a `\"content\"` column hugs its content), each row\n * uses the natural heights of its children, and components are\n * baseline-aligned within their row, mirroring\n * [`HBox`](/api/layout/classes/HBox)'s baseline-aware placement. Baseline\n * mode auto-flows by `colSpan`; explicit `col`/`row` and `rowSpan > 1` are\n * not supported.\n */\n doLayout() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n let components = container.getLaidOutComponents();\n let containerInsets = container.getContentInsets();\n let containerSize = container.getInnerSize();\n if (!containerSize) {\n return;\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n // Universal scroll: see HBox.doLayout for the rationale. Inflates the\n // working size to the children's combined minSize on the axes the\n // host has marked as overflowing.\n containerSize = this.inflateForOverflow(containerSize);\n\n if (!this._baselineAlign) {\n this.layoutOccupancy(components, cols, rows, containerSize, containerInsets, spacing);\n\n return;\n }\n\n // Baseline mode honours the same per-track column/row sizing as the\n // occupancy path — so a \"content\" column hugs its titles instead of\n // taking a uniform 1/cols share — plus colSpan auto-flow, then\n // baseline-aligns each row's children within the row (mirroring HBox).\n // Explicit col/row placement and rowSpan > 1 are not supported here.\n const content = this.measureContent(components, cols, rows);\n const colExtents = this.resolveTracks(this._columnTracks, cols, containerSize.width, spacing, content.columns);\n const rowExtents = this.resolveTracks(this._rowTracks, rows, containerSize.height, spacing, content.rows);\n\n type BaselineCell = {\n component: Component;\n col: number;\n colSpan: number;\n height: number;\n baseline: number | null;\n };\n\n const perRow: BaselineCell[][] = Array.from({ length: rows }, () => []);\n\n let flowCol = 0;\n let flowRow = 0;\n\n for (const component of components) {\n if (flowRow >= rows) {\n break;\n }\n\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n const colSpan = Util.clamp(cons?.colSpan ?? 1, 1, cols);\n const size = component.getPreferredSize();\n\n perRow[flowRow].push({\n component,\n col: flowCol,\n colSpan,\n height: size ? size.height : 0,\n baseline: component.getBaseline(),\n });\n\n flowCol += colSpan;\n\n if (flowCol >= cols) {\n flowCol = 0;\n flowRow += 1;\n }\n }\n\n let y = containerInsets.getTop();\n\n for (let row = 0; row < rows; row += 1) {\n const rowCells = perRow[row];\n\n const { rowAscent, rowDescent } = this.computeRowMetrics(\n rowCells.map(cell => cell.height),\n rowCells.map(cell => cell.baseline),\n );\n\n for (const cell of rowCells) {\n let x = containerInsets.getLeft();\n for (let i = 0; i < cell.col; i += 1) {\n x += (colExtents[i] ?? 0) + spacing;\n }\n\n let width = (cell.colSpan - 1) * spacing;\n for (let i = cell.col; i < cell.col + cell.colSpan; i += 1) {\n width += colExtents[i] ?? 0;\n }\n\n let cellY: number;\n\n if (rowAscent !== null) {\n cellY = cell.baseline !== null\n ? y + (rowAscent - cell.baseline)\n : y + this.nullChildY(cell.height, rowAscent, rowDescent);\n } else {\n cellY = y;\n }\n\n this.placeComponent(\n cell.component,\n x,\n cellY,\n width,\n cell.height,\n this._defaultFill,\n this._defaultAnchor\n );\n }\n\n const baselineHeight = rowAscent !== null ? rowAscent + rowDescent : 0;\n\n y += Math.max(rowExtents[row] ?? 0, baselineHeight) + spacing;\n }\n }\n\n /**\n * Resolves a track list into per-track pixel extents along one axis.\n *\n * @param tracks - The declared tracks; missing tracks (when shorter than\n * `count`) default to `{ mode: \"weight\", value: 1 }`.\n * @param count - The number of columns (or rows) to size.\n * @param available - The inner extent of the container along this axis.\n * @param spacing - The inter-cell gap, in pixels.\n * @param contentSizes - Measured content maxima per track, used for `\"content\"` tracks.\n * @returns A `number[count]` of pixel extents.\n *\n * @remarks Fixed tracks keep their `value`; content tracks keep their measured\n * size; the remaining space is split among weight tracks in proportion to their\n * weights. When no weight track exists the remaining space is left unused.\n */\n private resolveTracks(tracks: GridTrack[], count: number, available: number, spacing: number, contentSizes: number[]): number[] {\n const inner = available - Math.max(0, count - 1) * spacing;\n\n const resolved: number[] = new Array(count).fill(0);\n\n let fixedSum = 0;\n let contentSum = 0;\n let weightSum = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n resolved[i] = track.value ?? 0;\n fixedSum += resolved[i];\n } else if (track.mode === \"content\") {\n resolved[i] = contentSizes[i] ?? 0;\n contentSum += resolved[i];\n } else {\n weightSum += Math.max(0, track.value ?? 1);\n }\n }\n\n const remaining = Math.max(0, inner - fixedSum - contentSum);\n\n if (weightSum > 0) {\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"weight\") {\n resolved[i] = remaining * (Math.max(0, track.value ?? 1) / weightSum);\n }\n }\n }\n\n return resolved;\n }\n\n /**\n * Measures the content maxima of single-track-spanning children, per column\n * and per row, for `\"content\"` track sizing.\n *\n * @param components - The container's children.\n * @param cols - The column count.\n * @param rows - The row count.\n * @returns `{ columns, rows }` arrays of per-track content maxima.\n *\n * @remarks Each child contributes `max(preferred, min)` so a child that only\n * set a min size still widens (or heightens) its track. A child contributes to\n * a column only when its `colSpan` is `1`, and to a row only when its `rowSpan`\n * is `1` — multi-track spanners are not distributed in v1. Because content\n * measurement is independent of cell placement, the maxima are folded by\n * explicit-or-flow position when known, else by document-order column/row.\n */\n private measureContent(components: Component[], cols: number, rows: number): { columns: number[]; rows: number[] } {\n const columns: number[] = new Array(cols).fill(0);\n const rowSizes: number[] = new Array(rows).fill(0);\n\n // Baseline mode only: per-row preferred heights + baselines, so the row\n // content size can fold in the baseline spread `doLayout` reserves (see\n // below). Left empty when `baselineAlign` is off.\n const rowHeights: number[][] = this._baselineAlign ? Array.from({ length: rows }, () => []) : [];\n const rowBaselines: Array<Array<number | null>> = this._baselineAlign ? Array.from({ length: rows }, () => []) : [];\n\n let flowCol = 0;\n let flowRow = 0;\n\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n const preferred = component.getPreferredSize();\n const min = component.getMinSize();\n\n const w = Math.max(preferred ? preferred.width : 0, min ? min.width : 0);\n const h = Math.max(preferred ? preferred.height : 0, min ? min.height : 0);\n\n const colSpan = Math.max(1, cons?.colSpan ?? 1);\n const rowSpan = Math.max(1, cons?.rowSpan ?? 1);\n\n let c: number;\n let r: number;\n\n if (cons && (cons.col != null || cons.row != null)) {\n c = Util.clamp(cons.col ?? 0, 0, Math.max(0, cols - 1));\n r = Util.clamp(cons.row ?? 0, 0, Math.max(0, rows - 1));\n } else {\n c = flowCol;\n r = flowRow;\n\n flowCol += colSpan;\n\n if (flowCol >= cols) {\n flowCol = 0;\n flowRow += rowSpan;\n }\n }\n\n if (colSpan === 1 && c < cols) {\n columns[c] = Math.max(columns[c], w);\n }\n\n if (rowSpan === 1 && r < rows) {\n rowSizes[r] = Math.max(rowSizes[r], h);\n\n if (this._baselineAlign) {\n // Pair the preferred height with the baseline, exactly as\n // `doLayout` does — the cell's placed height and baseline\n // together set the row's ascent/descent.\n rowHeights[r].push(preferred ? preferred.height : 0);\n rowBaselines[r].push(component.getBaseline());\n }\n }\n }\n\n // A baseline-aligned row is `max(tallestCell, rowAscent + rowDescent)`\n // (see `doLayout`): cells on mismatched baselines need the highest ascent\n // plus the deepest descent, which can exceed the tallest cell. Fold that\n // spread into the measured row size so `getPreferredSize` / `getMinSize`\n // reserve what `doLayout` actually lays out, rather than under-reporting\n // and letting the content overflow the box the parent sized from it.\n if (this._baselineAlign) {\n for (let r = 0; r < rows; r += 1) {\n const { rowAscent, rowDescent } = this.computeRowMetrics(rowHeights[r], rowBaselines[r]);\n\n if (rowAscent !== null) {\n rowSizes[r] = Math.max(rowSizes[r], rowAscent + rowDescent);\n }\n }\n }\n\n return { columns, rows: rowSizes };\n }\n\n /**\n * Tiles children using the occupancy-grid algorithm: explicitly-placed\n * children are reserved first, then the remaining children auto-flow into the\n * free cells, with per-track sizing and per-cell clip-vs-place.\n *\n * @param components - The container's children.\n * @param cols - The column count.\n * @param rows - The row count.\n * @param containerSize - The container's (possibly overflow-inflated) inner size.\n * @param insets - The container's insets, supplying the cell origin offset.\n * @param spacing - The inter-cell gap, in pixels.\n */\n private layoutOccupancy(components: Component[], cols: number, rows: number, containerSize: Size, insets: Insets, spacing: number): void {\n const content = this.measureContent(components, cols, rows);\n\n const colExtents = this.resolveTracks(this._columnTracks, cols, containerSize.width, spacing, content.columns);\n const rowExtents = this.resolveTracks(this._rowTracks, rows, containerSize.height, spacing, content.rows);\n\n const occupancy: boolean[][] = [];\n\n for (let r = 0; r < rows; r += 1) {\n occupancy.push(new Array(cols).fill(false));\n }\n\n const owners: Array<Array<string | null>> = [];\n\n for (let r = 0; r < rows; r += 1) {\n owners.push(new Array(cols).fill(null));\n }\n\n const placeAt = (component: Component, r: number, c: number, rowSpan: number, colSpan: number): void => {\n let x = insets.getLeft();\n\n for (let i = 0; i < c; i += 1) {\n x += colExtents[i] + spacing;\n }\n\n let y = insets.getTop();\n\n for (let i = 0; i < r; i += 1) {\n y += rowExtents[i] + spacing;\n }\n\n let w = (colSpan - 1) * spacing;\n\n for (let i = c; i < c + colSpan; i += 1) {\n w += colExtents[i] ?? 0;\n }\n\n let h = (rowSpan - 1) * spacing;\n\n for (let i = r; i < r + rowSpan; i += 1) {\n h += rowExtents[i] ?? 0;\n }\n\n const min = component.getMinSize();\n\n if (min && (min.width > w || min.height > h)) {\n // The child's own `min-width` / `min-height` keep its box from\n // shrinking to the cell on the overflowing axis, so clip it with\n // a cell-sized frame. Honour the grid's fill/anchor on whichever\n // axis the child *does* fit — `resolveBounds` yields the\n // fill/anchor-placed box — and override only the overflowing axis\n // to the child's natural extent (its preferred size, falling back\n // to min) so the content renders at full size up to the clip edge\n // rather than at a cramped preferred that drops fill. The frame is\n // anchored at the cell; the child commits at the resolved offset\n // within it (0 on an overflowing axis, since `resolveBounds`\n // applies no anchor displacement when the child exceeds the cell).\n const resolved = this.resolveBounds(component, x, y, w, h, this._defaultFill, this._defaultAnchor);\n const pref = component.getPreferredSize();\n\n const childWidth = min.width > w ? (pref ? pref.width : min.width) : resolved.width;\n const childHeight = min.height > h ? (pref ? pref.height : min.height) : resolved.height;\n\n component.setClipFrame(x, y, w, h);\n this.commitBounds(component, resolved.x - x, resolved.y - y, childWidth, childHeight);\n } else {\n // The child fits: resolve its bounds honouring its own\n // fill/anchor over the grid defaults, then commit the result so\n // a non-filling child shrinks and anchors within its cell.\n const resolved = this.resolveBounds(component, x, y, w, h, this._defaultFill, this._defaultAnchor);\n\n component.clearClipFrame();\n this.commitBounds(component, resolved.x, resolved.y, resolved.width, resolved.height);\n }\n };\n\n // Pass 1 — reserve explicitly-positioned children.\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n\n if (!cons || (cons.col == null && cons.row == null)) {\n continue;\n }\n\n const c = Util.clamp(cons.col ?? 0, 0, Math.max(0, cols - 1));\n const r = Util.clamp(cons.row ?? 0, 0, Math.max(0, rows - 1));\n const colSpan = Util.clamp(cons.colSpan ?? 1, 1, cols - c);\n const rowSpan = Util.clamp(cons.rowSpan ?? 1, 1, rows - r);\n\n for (let rr = r; rr < r + rowSpan; rr += 1) {\n for (let cc = c; cc < c + colSpan; cc += 1) {\n if (occupancy[rr][cc]) {\n console.warn(`Grid: ${component.getId()} overlaps ${owners[rr][cc]} at cell (${rr},${cc})`);\n }\n\n occupancy[rr][cc] = true;\n owners[rr][cc] = component.getId();\n }\n }\n\n placeAt(component, r, c, rowSpan, colSpan);\n }\n\n // Pass 2 — auto-flow the remaining children into free cells.\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n\n if (cons && (cons.col != null || cons.row != null)) {\n continue;\n }\n\n const colSpan = Util.clamp(cons?.colSpan ?? 1, 1, cols);\n const rowSpan = Util.clamp(cons?.rowSpan ?? 1, 1, rows);\n\n const slot = this.findFreeCell(occupancy, rows, cols, rowSpan, colSpan);\n\n if (!slot) {\n continue;\n }\n\n for (let rr = slot.r; rr < slot.r + rowSpan; rr += 1) {\n for (let cc = slot.c; cc < slot.c + colSpan; cc += 1) {\n occupancy[rr][cc] = true;\n owners[rr][cc] = component.getId();\n }\n }\n\n placeAt(component, slot.r, slot.c, rowSpan, colSpan);\n }\n }\n\n /**\n * Scans the occupancy grid in row-major order for the first top-left cell\n * whose `rowSpan`×`colSpan` block is entirely free.\n *\n * @param occupancy - The `boolean[rows][cols]` occupancy map.\n * @param rows - The row count.\n * @param cols - The column count.\n * @param rowSpan - The block height to fit.\n * @param colSpan - The block width to fit.\n * @returns The free block's top-left `{ r, c }`, or `null` if none fits.\n */\n private findFreeCell(occupancy: boolean[][], rows: number, cols: number, rowSpan: number, colSpan: number): { r: number; c: number } | null {\n for (let r = 0; r + rowSpan <= rows; r += 1) {\n for (let c = 0; c + colSpan <= cols; c += 1) {\n let free = true;\n\n for (let rr = r; rr < r + rowSpan && free; rr += 1) {\n for (let cc = c; cc < c + colSpan; cc += 1) {\n if (occupancy[rr][cc]) {\n free = false;\n\n break;\n }\n }\n }\n\n if (free) {\n return { r, c };\n }\n }\n }\n\n return null;\n }\n}\n\nconst GridCallable = callable(Grid);\ntype GridCallable = Grid;\nexport {\n Grid as _Grid,\n GridCallable as Grid\n};\n"],"mappings":"iIA6CA,IAAM,KAAN,cAAmB,CAAc,CAE7B,MAAwB,EACxB,SA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EAAK,EAAG,EAAS,CAAO,CAH/C,CAIR,CACJ,CAaA,aAAqB,EAAwB,EAAc,EAAc,EAAiB,EAAkD,CACxI,IAAK,IAAI,EAAI,EAAG,EAAI,GAAW,EAAM,GAAK,EACtC,IAAK,IAAI,EAAI,EAAG,EAAI,GAAW,EAAM,GAAK,EAAG,CACzC,IAAI,EAAO,GAEX,IAAK,IAAI,EAAK,EAAG,EAAK,EAAI,GAAW,EAAM,GAAM,EAC7C,IAAK,IAAI,EAAK,EAAG,EAAK,EAAI,EAAS,GAAM,EACrC,GAAI,EAAU,EAAG,CAAC,GAAK,CACnB,EAAO,GAEP,KACJ,CAIR,GAAI,EACA,MAAO,CAAE,IAAG,GAAE,CAEtB,CAGJ,OAAO,IACX,CACJ,EAEM,EAAe,EAAS,IAAI"}
1
+ {"version":3,"file":"Grid-DdL9TVeJ.js","names":[],"sources":["../../src/typescript/lib/layout/Grid.ts"],"sourcesContent":["// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0\n\nimport { LayoutManager, LayoutManagerOptions } from \"~/layout/LayoutManager.js\";\nimport { FillType } from \"~/layout/FillType.js\";\nimport { AnchorType } from \"~/layout/AnchorType.js\";\nimport { GridTrack } from \"~/layout/GridTrack.js\";\nimport { GridConstraints } from \"~/layout/GridConstraints.js\";\nimport { Size, UNBOUNDED, isUnbounded, saturate } from \"~/primitive/Size.js\";\nimport { Insets } from \"~/primitive/Insets.js\";\nimport { Component } from \"~/core/Component.js\";\nimport { Util } from \"~/core/Util.js\";\nimport { callable } from \"~/core/Callable.js\";\n\n/**\n * Construction-time options for {@link Grid}.\n *\n * @category Layouts\n */\nexport interface GridOptions extends LayoutManagerOptions {\n rows?: number;\n columns?: number;\n spacing?: number;\n\n /** Grid-wide fill applied to children that don't set their own `fill`. Default {@link FillType.BOTH}. */\n defaultFill?: FillType;\n\n /** Grid-wide anchor applied to non-filling children that don't set their own `anchor`. Default {@link AnchorType.CENTER}. */\n defaultAnchor?: AnchorType;\n\n /** When `true`, children are baseline-aligned per row (column/row tracks still apply; children use preferred height). Default `false`. */\n baselineAlign?: boolean;\n\n /** Per-column sizing tracks; see {@link GridTrack}. */\n columnTracks?: GridTrack[];\n\n /** Per-row sizing tracks; see {@link GridTrack}. */\n rowTracks?: GridTrack[];\n}\n\n/**\n * A layout manager that tiles children in a uniform grid of equal-sized cells.\n * Row and column counts can be configured explicitly or left at `0` for auto-calculation.\n *\n * @category Layouts\n */\nclass Grid extends LayoutManager {\n\n private _rows: number = 0;\n private _columns: number = 0;\n private _spacing: number = 5;\n private _defaultFill: FillType = FillType.BOTH;\n private _defaultAnchor: AnchorType = AnchorType.CENTER;\n private _baselineAlign: boolean = false;\n private _columnTracks: GridTrack[] = [];\n private _rowTracks: GridTrack[] = [];\n\n constructor(options?: GridOptions) {\n // LayoutManager's constructor takes no options; applied via applyOptions below.\n // eslint-disable-next-line local/forward-super-options\n super();\n\n if (options) {\n this.applyOptions(options);\n }\n }\n\n /**\n * Applies a {@link GridOptions} bag, dispatching grid dimensions, spacing,\n * default fill/anchor, and baseline alignment after the inherited\n * LayoutManager defaults.\n *\n * @param options - The options bag carrying the values to apply.\n */\n protected applyOptions(options: GridOptions): void {\n super.applyOptions(options);\n\n if (options.rows !== undefined) {\n this.setRows(options.rows);\n }\n\n if (options.columns !== undefined) {\n this.setColumns(options.columns);\n }\n\n if (options.spacing !== undefined) {\n this.setComponentSpacing(options.spacing);\n }\n\n if (options.defaultFill !== undefined) {\n this.setDefaultFill(options.defaultFill);\n }\n\n if (options.defaultAnchor !== undefined) {\n this.setDefaultAnchor(options.defaultAnchor);\n }\n\n if (options.baselineAlign !== undefined) {\n this.setBaselineAlign(options.baselineAlign);\n }\n\n if (options.columnTracks !== undefined) {\n this.setColumnTracks(options.columnTracks);\n }\n\n if (options.rowTracks !== undefined) {\n this.setRowTracks(options.rowTracks);\n }\n }\n\n /**\n * Returns the grid-wide default fill applied to children that don't set\n * their own `fill` constraint.\n *\n * @returns The default {@link FillType} (initially {@link FillType.BOTH}).\n */\n getDefaultFill(): FillType {\n return this._defaultFill;\n }\n\n /**\n * Sets the grid-wide default fill. Each child overrides this with its own\n * {@link GridConstraints} `fill`; otherwise this value drives whether the\n * child fills its cell.\n *\n * @param fill - The default fill strategy for children without their own `fill`.\n */\n setDefaultFill(fill: FillType): this {\n this._defaultFill = fill;\n\n return this;\n }\n\n /**\n * Returns the grid-wide default anchor applied to non-filling children that\n * don't set their own `anchor` constraint.\n *\n * @returns The default {@link AnchorType} (initially {@link AnchorType.CENTER}).\n */\n getDefaultAnchor(): AnchorType {\n return this._defaultAnchor;\n }\n\n /**\n * Sets the grid-wide default anchor. Each child overrides this with its own\n * {@link GridConstraints} `anchor`; otherwise this value positions a\n * non-filling child within its cell.\n *\n * @param anchor - The default anchor for children without their own `anchor`.\n */\n setDefaultAnchor(anchor: AnchorType): this {\n this._defaultAnchor = anchor;\n\n return this;\n }\n\n /**\n * Returns whether children are baseline-aligned per row.\n *\n * @returns `true` if per-row baseline alignment is enabled.\n */\n isBaselineAlign(): boolean {\n return this._baselineAlign;\n }\n\n /**\n * Sets whether children are baseline-aligned per row. When `true`, the\n * column/row tracks still size each cell (so a `\"content\"` column hugs its\n * content), each row uses the natural heights of its children, and\n * components are baseline-aligned within the row, mirroring\n * [`HBox`](/api/layout/classes/HBox)'s baseline-aware placement. Orthogonal\n * to {@link Grid.setDefaultFill} — baseline alignment owns the vertical axis\n * while fill/anchor still drive the horizontal axis.\n *\n * @param baselineAlign - Pass `true` to enable per-row baseline alignment.\n */\n setBaselineAlign(baselineAlign: boolean): this {\n this._baselineAlign = baselineAlign;\n\n return this;\n }\n\n /**\n * Returns the configured number of rows, or `0` if the grid auto-calculates row count.\n *\n * @returns The row count.\n */\n getRows() {\n return this._rows;\n }\n\n /**\n * Sets the number of rows. Pass `0` to let the grid auto-calculate.\n *\n * @param rows - The desired row count, or `0` for automatic.\n */\n setRows(rows: number) : this {\n this._rows = rows;\n\n return this;\n }\n\n /**\n * Returns the gap, in pixels, between adjacent cells (horizontally and vertically).\n *\n * @returns The current spacing in pixels.\n */\n getComponentSpacing() {\n return this._spacing || 0;\n }\n\n /**\n * Sets the gap, in pixels, between adjacent cells. Applied both horizontally\n * (between columns) and vertically (between rows).\n *\n * @param spacing - Spacing in pixels. Falsy values are treated as `0`.\n */\n setComponentSpacing(spacing: number) : this {\n this._spacing = spacing || 0;\n\n return this;\n }\n\n /**\n * Returns the configured number of columns, or `0` if the grid auto-calculates column count.\n *\n * @returns The column count.\n */\n getColumns() {\n return this._columns;\n }\n\n /**\n * Sets the number of columns. Pass `0` to let the grid auto-calculate.\n *\n * @param columns - The desired column count, or `0` for automatic.\n */\n setColumns(columns: number) : this {\n this._columns = columns;\n\n return this;\n }\n\n /**\n * Returns the per-column sizing tracks.\n *\n * @returns The configured column tracks; empty when columns size uniformly.\n */\n getColumnTracks(): GridTrack[] {\n return this._columnTracks;\n }\n\n /**\n * Sets the per-column sizing tracks. When fewer tracks are supplied than the\n * grid has columns, the missing tracks default to `{ mode: \"weight\", value: 1 }`.\n *\n * @param tracks - The column tracks; see {@link GridTrack}.\n */\n setColumnTracks(tracks: GridTrack[]): this {\n this._columnTracks = tracks;\n\n return this;\n }\n\n /**\n * Returns the per-row sizing tracks.\n *\n * @returns The configured row tracks; empty when rows size uniformly.\n */\n getRowTracks(): GridTrack[] {\n return this._rowTracks;\n }\n\n /**\n * Sets the per-row sizing tracks. When fewer tracks are supplied than the\n * grid has rows, the missing tracks default to `{ mode: \"weight\", value: 1 }`.\n *\n * @param tracks - The row tracks; see {@link GridTrack}.\n */\n setRowTracks(tracks: GridTrack[]): this {\n this._rowTracks = tracks;\n\n return this;\n }\n\n /**\n * Returns the computed cell count for the current component list as `{width: rows, height: columns}`.\n *\n * @returns An object with `width` (row count) and `height` (column count), or `undefined` if no container is attached.\n *\n * @remarks The property names `width` and `height` are repurposed here to\n * carry column and row counts rather than pixel dimensions —\n * `result.width` is the column count, `result.height` is the row count.\n */\n getColRowCount() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n let components = container.getLaidOutComponents();\n let componentCount = components.length;\n\n let rows = 0;\n let columns = 0;\n\n if (!this._rows && !this._columns) {\n columns = Math.floor(Math.sqrt(componentCount));\n rows = Math.ceil(componentCount / columns);\n } else if (this._rows && this._columns) {\n rows = this._rows;\n columns = this._columns;\n } else if (this._columns) {\n columns = this._columns;\n rows = Math.ceil(componentCount / columns);\n } else {\n rows = this._rows;\n columns = Math.ceil(componentCount / rows);\n }\n\n return {\n width: columns,\n height: rows\n };\n }\n\n /**\n * Returns the preferred size. With tracks declared, this is the sum of the\n * per-track preferred extents (fixed tracks their value, content *and*\n * weight tracks their measured content — wide/tall enough to show every\n * cell at its natural size) plus spacing. Track-less grids keep the uniform\n * `maxChildPreferred * count` estimate.\n *\n * @returns The preferred `{width, height}`, or `null` if no container is attached.\n */\n getPreferredSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n let size = component.getPreferredSize();\n\n if (size) {\n maxCellWidth = Math.max(maxCellWidth, size.width);\n maxCellHeight = Math.max(maxCellHeight, size.height);\n }\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n let innerWidth = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, true)\n : maxCellWidth * cols;\n\n let innerHeight = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, true)\n : maxCellHeight * rows;\n\n innerWidth += Math.max(0, cols - 1) * spacing;\n innerHeight += Math.max(0, rows - 1) * spacing;\n\n return {\n width: innerWidth + outerWidth,\n height: innerHeight + outerHeight\n };\n }\n\n /**\n * Returns the minimum size. With tracks declared, this is the sum of the\n * per-track minima (fixed tracks their value, content tracks their measured\n * content, weight tracks `0`) plus spacing — matching what `doLayout`\n * actually lays out, so a host no longer over-reserves space the way the\n * uniform `maxChildMin * count` estimate did. Track-less grids keep that\n * uniform estimate.\n *\n * @returns The minimum `{width, height}`, or `null` if no container is attached.\n */\n getMinSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n let size = component.getMinSize();\n\n if (size) {\n maxCellWidth = Math.max(maxCellWidth, size.width);\n maxCellHeight = Math.max(maxCellHeight, size.height);\n }\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n let innerWidth = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, false)\n : maxCellWidth * cols;\n\n let innerHeight = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, false)\n : maxCellHeight * rows;\n\n innerWidth += Math.max(0, cols - 1) * spacing;\n innerHeight += Math.max(0, rows - 1) * spacing;\n\n return {\n width: innerWidth + outerWidth,\n height: innerHeight + outerHeight\n };\n }\n\n /**\n * Returns the maximum size the grid can usefully occupy: the sum of the\n * per-track maxima plus inter-cell spacing and the container perimeter. A\n * `fixed` track contributes its pixel value, a `content` track its measured\n * content, and a `weight` track is unbounded — so any weight track makes the\n * whole axis unbounded (the grid can absorb arbitrary slack there). With no\n * tracks on an axis the fallback is `cols * maxChildMax` (the uniform-cell\n * estimate), where a child's `null`/sentinel maximum counts as unbounded.\n *\n * @returns The maximum `{width, height}`, or `null` if no container is attached.\n */\n getMaxSize(): Size | null {\n let container = this.getContainer();\n if (!container) {\n return null;\n }\n\n let perimeterSize = container.getPerimeterSize();\n\n let outerWidth = perimeterSize.left + perimeterSize.right;\n let outerHeight = perimeterSize.top + perimeterSize.bottom;\n\n let components = container.getLaidOutComponents();\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n const content = this.measureContent(components, cols, rows);\n\n const innerWidth = this._columnTracks.length > 0\n ? this.trackAxisMax(this._columnTracks, cols, content.columns)\n : cols * this.maxChildExtent(components, true);\n\n const innerHeight = this._rowTracks.length > 0\n ? this.trackAxisMax(this._rowTracks, rows, content.rows)\n : rows * this.maxChildExtent(components, false);\n\n return {\n width: saturate(innerWidth + Math.max(0, cols - 1) * spacing + outerWidth),\n height: saturate(innerHeight + Math.max(0, rows - 1) * spacing + outerHeight)\n };\n }\n\n /**\n * Sums the per-track maxima along one axis: a `fixed` track contributes its\n * pixel value, a `content` track its measured content size, and a `weight`\n * track is unbounded — the first weight track saturates the axis to the\n * unbounded sentinel, since a flex track can grow without limit. A\n * missing track defaults to `weight`, matching {@link trackAxisExtent}.\n *\n * @param tracks - The declared tracks for this axis.\n * @param count - The number of columns (or rows) to size.\n * @param contentSizes - Measured content maxima per track.\n * @returns The summed maximum extent for the axis, excluding spacing.\n */\n private trackAxisMax(tracks: GridTrack[], count: number, contentSizes: number[]): number {\n let total = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n total += track.value ?? 0;\n } else if (track.mode === \"content\") {\n total += contentSizes[i] ?? 0;\n } else {\n return UNBOUNDED;\n }\n }\n\n return total;\n }\n\n /**\n * Returns the largest per-child maximum extent across all children on one\n * axis, for the uniform-cell (no-track) fallback. A child whose maximum is\n * `null` or at the unbounded sentinel makes the whole axis unbounded, so the\n * result saturates to the unbounded sentinel.\n *\n * @param components - The grid's children.\n * @param horizontal - `true` to read each child's max width, `false` for height.\n * @returns The largest child maximum, or the unbounded sentinel when any\n * child is unbounded.\n */\n private maxChildExtent(components: Component[], horizontal: boolean): number {\n let largest = 0;\n\n for (const component of components) {\n const max = component.getMaxSize();\n\n if (!max) {\n return UNBOUNDED;\n }\n\n const extent = horizontal ? max.width : max.height;\n\n if (isUnbounded(extent)) {\n return UNBOUNDED;\n }\n\n largest = Math.max(largest, extent);\n }\n\n return largest;\n }\n\n /**\n * Computes the children's combined minSize along this manager's geometry:\n * width is `cols * maxChildMinWidth + (cols-1) * spacing`; height is\n * `rows * maxChildMinHeight + (rows-1) * spacing`. Used by `doLayout` to\n * inflate the working size when the host has opted into `setOverflowing`.\n *\n * @returns The total min-size; `{ width: 0, height: 0 }` when the\n * container is absent or has no children.\n */\n protected computeTotalMinSize(): Size {\n const container = this.getContainer();\n if (!container) {\n return { width: 0, height: 0 };\n }\n\n const components = container.getLaidOutComponents();\n if (components.length === 0) {\n return { width: 0, height: 0 };\n }\n\n const colRowCount = this.getColRowCount();\n const cols = colRowCount ? colRowCount.width : 1;\n const rows = colRowCount ? colRowCount.height : 1;\n const spacing = this.getComponentSpacing();\n\n let maxCellWidth = 0;\n let maxCellHeight = 0;\n\n for (const component of components) {\n const min = component.getMinSize();\n if (min) {\n maxCellWidth = Math.max(maxCellWidth, min.width);\n maxCellHeight = Math.max(maxCellHeight, min.height);\n }\n }\n\n const content = this.measureContent(components, cols, rows);\n\n // When tracks are declared, the axis minimum is the sum of per-track\n // minima — a `fixed` track needs its fixed value, a `content` track its\n // measured content, and a `weight` track nothing (it flexes to fill\n // slack and clips oversized children, so it imposes no intrinsic floor).\n // This keeps a child that the grid is meant to *clip* (e.g. an oversized\n // child in a fixed column) from inflating the whole grid's min width.\n // With no tracks on an axis, fall back to the uniform `maxChild*count`\n // estimate so non-track grids still drive universal scroll unchanged.\n const widthMin = this._columnTracks.length > 0\n ? this.trackAxisExtent(this._columnTracks, cols, content.columns, false)\n : cols * maxCellWidth;\n\n const heightMin = this._rowTracks.length > 0\n ? this.trackAxisExtent(this._rowTracks, rows, content.rows, false)\n : rows * maxCellHeight;\n\n return {\n width: widthMin + Math.max(0, cols - 1) * spacing,\n height: heightMin + Math.max(0, rows - 1) * spacing,\n };\n }\n\n /**\n * Sums the per-track extents along one axis: a `fixed` track contributes its\n * pixel value and a `content` track its measured content size. A `weight`\n * track contributes its measured content when `includeWeightContent` is\n * `true` (the *preferred* extent — wide enough to show its content at\n * natural size) and `0` otherwise (the *minimum* extent — a flex track can\n * shrink to nothing). A missing track (when the list is shorter than\n * `count`) defaults to `weight`, matching `resolveTracks`' weight default.\n *\n * @param tracks - The declared tracks for this axis.\n * @param count - The number of columns (or rows) to size.\n * @param contentSizes - Measured content maxima per track.\n * @param includeWeightContent - Whether weight tracks contribute their\n * measured content (preferred extent) rather than `0` (minimum extent).\n * @returns The summed extent for the axis, excluding spacing.\n */\n private trackAxisExtent(tracks: GridTrack[], count: number, contentSizes: number[], includeWeightContent: boolean): number {\n let total = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n total += track.value ?? 0;\n } else if (track.mode === \"content\") {\n total += contentSizes[i] ?? 0;\n } else if (includeWeightContent) {\n total += contentSizes[i] ?? 0;\n }\n }\n\n return total;\n }\n\n /**\n * Tiles all children in a grid of equal-sized cells, left-to-right then top-to-bottom.\n *\n * @remarks Each cell is sized by the column/row tracks; how a child sits\n * inside its cell is driven by the child's own `fill`/`anchor`\n * ([`GridConstraints`](/api/layout/classes/GridConstraints)) falling back to\n * the grid's {@link Grid.setDefaultFill}/{@link Grid.setDefaultAnchor}\n * (default {@link FillType.BOTH}, so children fill their cells out of the\n * box). When {@link Grid.setBaselineAlign} is enabled, the column/row tracks\n * still size each cell (a `\"content\"` column hugs its content), each row\n * uses the natural heights of its children, and components are\n * baseline-aligned within their row, mirroring\n * [`HBox`](/api/layout/classes/HBox)'s baseline-aware placement. Baseline\n * mode auto-flows by `colSpan`; explicit `col`/`row` and `rowSpan > 1` are\n * not supported.\n */\n doLayout() {\n let container = this.getContainer();\n if (!container) {\n return;\n }\n\n let components = container.getLaidOutComponents();\n let containerInsets = container.getContentInsets();\n let containerSize = container.getInnerSize();\n if (!containerSize) {\n return;\n }\n\n let colRowCount = this.getColRowCount();\n let cols = colRowCount ? colRowCount.width : 1;\n let rows = colRowCount ? colRowCount.height : 1;\n let spacing = this.getComponentSpacing();\n\n // Universal scroll: see HBox.doLayout for the rationale. Inflates the\n // working size to the children's combined minSize on the axes the\n // host has marked as overflowing.\n containerSize = this.inflateForOverflow(containerSize);\n\n if (!this._baselineAlign) {\n this.layoutOccupancy(components, cols, rows, containerSize, containerInsets, spacing);\n\n return;\n }\n\n // Baseline mode honours the same per-track column/row sizing as the\n // occupancy path — so a \"content\" column hugs its titles instead of\n // taking a uniform 1/cols share — plus colSpan auto-flow, then\n // baseline-aligns each row's children within the row (mirroring HBox).\n // Explicit col/row placement and rowSpan > 1 are not supported here.\n const content = this.measureContent(components, cols, rows);\n const colExtents = this.resolveTracks(this._columnTracks, cols, containerSize.width, spacing, content.columns);\n const rowExtents = this.resolveTracks(this._rowTracks, rows, containerSize.height, spacing, content.rows);\n\n type BaselineCell = {\n component: Component;\n col: number;\n colSpan: number;\n height: number;\n baseline: number | null;\n };\n\n const perRow: BaselineCell[][] = Array.from({ length: rows }, () => []);\n\n let flowCol = 0;\n let flowRow = 0;\n\n for (const component of components) {\n if (flowRow >= rows) {\n break;\n }\n\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n const colSpan = Util.clamp(cons?.colSpan ?? 1, 1, cols);\n const size = component.getPreferredSize();\n\n perRow[flowRow].push({\n component,\n col: flowCol,\n colSpan,\n height: size ? size.height : 0,\n baseline: component.getBaseline(),\n });\n\n flowCol += colSpan;\n\n if (flowCol >= cols) {\n flowCol = 0;\n flowRow += 1;\n }\n }\n\n let y = containerInsets.getTop();\n\n for (let row = 0; row < rows; row += 1) {\n const rowCells = perRow[row];\n\n const { rowAscent, rowDescent } = this.computeRowMetrics(\n rowCells.map(cell => cell.height),\n rowCells.map(cell => cell.baseline),\n );\n\n for (const cell of rowCells) {\n let x = containerInsets.getLeft();\n for (let i = 0; i < cell.col; i += 1) {\n x += (colExtents[i] ?? 0) + spacing;\n }\n\n let width = (cell.colSpan - 1) * spacing;\n for (let i = cell.col; i < cell.col + cell.colSpan; i += 1) {\n width += colExtents[i] ?? 0;\n }\n\n let cellY: number;\n\n if (rowAscent !== null) {\n cellY = cell.baseline !== null\n ? y + (rowAscent - cell.baseline)\n : y + this.nullChildY(cell.height, rowAscent, rowDescent);\n } else {\n cellY = y;\n }\n\n this.placeComponent(\n cell.component,\n x,\n cellY,\n width,\n cell.height,\n this._defaultFill,\n this._defaultAnchor\n );\n }\n\n const baselineHeight = rowAscent !== null ? rowAscent + rowDescent : 0;\n\n y += Math.max(rowExtents[row] ?? 0, baselineHeight) + spacing;\n }\n }\n\n /**\n * Resolves a track list into per-track pixel extents along one axis.\n *\n * @param tracks - The declared tracks; missing tracks (when shorter than\n * `count`) default to `{ mode: \"weight\", value: 1 }`.\n * @param count - The number of columns (or rows) to size.\n * @param available - The inner extent of the container along this axis.\n * @param spacing - The inter-cell gap, in pixels.\n * @param contentSizes - Measured content maxima per track, used for `\"content\"` tracks.\n * @returns A `number[count]` of pixel extents.\n *\n * @remarks Fixed tracks keep their `value`; content tracks keep their measured\n * size; the remaining space is split among weight tracks in proportion to their\n * weights. When no weight track exists the remaining space is left unused.\n */\n private resolveTracks(tracks: GridTrack[], count: number, available: number, spacing: number, contentSizes: number[]): number[] {\n const inner = available - Math.max(0, count - 1) * spacing;\n\n const resolved: number[] = new Array(count).fill(0);\n\n let fixedSum = 0;\n let contentSum = 0;\n let weightSum = 0;\n\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"fixed\") {\n resolved[i] = track.value ?? 0;\n fixedSum += resolved[i];\n } else if (track.mode === \"content\") {\n resolved[i] = contentSizes[i] ?? 0;\n contentSum += resolved[i];\n } else {\n weightSum += Math.max(0, track.value ?? 1);\n }\n }\n\n const remaining = Math.max(0, inner - fixedSum - contentSum);\n\n if (weightSum > 0) {\n for (let i = 0; i < count; i += 1) {\n const track = tracks[i] ?? { mode: \"weight\" as const, value: 1 };\n\n if (track.mode === \"weight\") {\n resolved[i] = remaining * (Math.max(0, track.value ?? 1) / weightSum);\n }\n }\n }\n\n return resolved;\n }\n\n /**\n * Measures the content maxima of single-track-spanning children, per column\n * and per row, for `\"content\"` track sizing.\n *\n * @param components - The container's children.\n * @param cols - The column count.\n * @param rows - The row count.\n * @returns `{ columns, rows }` arrays of per-track content maxima.\n *\n * @remarks Each child contributes `max(preferred, min)` so a child that only\n * set a min size still widens (or heightens) its track. A child contributes to\n * a column only when its `colSpan` is `1`, and to a row only when its `rowSpan`\n * is `1` — multi-track spanners are not distributed in v1. Because content\n * measurement is independent of cell placement, the maxima are folded by\n * explicit-or-flow position when known, else by document-order column/row.\n */\n private measureContent(components: Component[], cols: number, rows: number): { columns: number[]; rows: number[] } {\n const columns: number[] = new Array(cols).fill(0);\n const rowSizes: number[] = new Array(rows).fill(0);\n\n // Baseline mode only: per-row preferred heights + baselines, so the row\n // content size can fold in the baseline spread `doLayout` reserves (see\n // below). Left empty when `baselineAlign` is off.\n const rowHeights: number[][] = this._baselineAlign ? Array.from({ length: rows }, () => []) : [];\n const rowBaselines: Array<Array<number | null>> = this._baselineAlign ? Array.from({ length: rows }, () => []) : [];\n\n let flowCol = 0;\n let flowRow = 0;\n\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n const preferred = component.getPreferredSize();\n const min = component.getMinSize();\n\n const w = Math.max(preferred ? preferred.width : 0, min ? min.width : 0);\n const h = Math.max(preferred ? preferred.height : 0, min ? min.height : 0);\n\n const colSpan = Math.max(1, cons?.colSpan ?? 1);\n const rowSpan = Math.max(1, cons?.rowSpan ?? 1);\n\n let c: number;\n let r: number;\n\n if (cons && (cons.col != null || cons.row != null)) {\n c = Util.clamp(cons.col ?? 0, 0, Math.max(0, cols - 1));\n r = Util.clamp(cons.row ?? 0, 0, Math.max(0, rows - 1));\n } else {\n c = flowCol;\n r = flowRow;\n\n flowCol += colSpan;\n\n if (flowCol >= cols) {\n flowCol = 0;\n flowRow += rowSpan;\n }\n }\n\n if (colSpan === 1 && c < cols) {\n columns[c] = Math.max(columns[c], w);\n }\n\n if (rowSpan === 1 && r < rows) {\n rowSizes[r] = Math.max(rowSizes[r], h);\n\n if (this._baselineAlign) {\n // Pair the preferred height with the baseline, exactly as\n // `doLayout` does — the cell's placed height and baseline\n // together set the row's ascent/descent.\n rowHeights[r].push(preferred ? preferred.height : 0);\n rowBaselines[r].push(component.getBaseline());\n }\n }\n }\n\n // A baseline-aligned row is `max(tallestCell, rowAscent + rowDescent)`\n // (see `doLayout`): cells on mismatched baselines need the highest ascent\n // plus the deepest descent, which can exceed the tallest cell. Fold that\n // spread into the measured row size so `getPreferredSize` / `getMinSize`\n // reserve what `doLayout` actually lays out, rather than under-reporting\n // and letting the content overflow the box the parent sized from it.\n if (this._baselineAlign) {\n for (let r = 0; r < rows; r += 1) {\n const { rowAscent, rowDescent } = this.computeRowMetrics(rowHeights[r], rowBaselines[r]);\n\n if (rowAscent !== null) {\n rowSizes[r] = Math.max(rowSizes[r], rowAscent + rowDescent);\n }\n }\n }\n\n return { columns, rows: rowSizes };\n }\n\n /**\n * Tiles children using the occupancy-grid algorithm: explicitly-placed\n * children are reserved first, then the remaining children auto-flow into the\n * free cells, with per-track sizing and per-cell clip-vs-place.\n *\n * @param components - The container's children.\n * @param cols - The column count.\n * @param rows - The row count.\n * @param containerSize - The container's (possibly overflow-inflated) inner size.\n * @param insets - The container's insets, supplying the cell origin offset.\n * @param spacing - The inter-cell gap, in pixels.\n */\n private layoutOccupancy(components: Component[], cols: number, rows: number, containerSize: Size, insets: Insets, spacing: number): void {\n const content = this.measureContent(components, cols, rows);\n\n const colExtents = this.resolveTracks(this._columnTracks, cols, containerSize.width, spacing, content.columns);\n const rowExtents = this.resolveTracks(this._rowTracks, rows, containerSize.height, spacing, content.rows);\n\n const occupancy: boolean[][] = [];\n\n for (let r = 0; r < rows; r += 1) {\n occupancy.push(new Array(cols).fill(false));\n }\n\n const owners: Array<Array<string | null>> = [];\n\n for (let r = 0; r < rows; r += 1) {\n owners.push(new Array(cols).fill(null));\n }\n\n const placeAt = (component: Component, r: number, c: number, rowSpan: number, colSpan: number): void => {\n let x = insets.getLeft();\n\n for (let i = 0; i < c; i += 1) {\n x += colExtents[i] + spacing;\n }\n\n let y = insets.getTop();\n\n for (let i = 0; i < r; i += 1) {\n y += rowExtents[i] + spacing;\n }\n\n let w = (colSpan - 1) * spacing;\n\n for (let i = c; i < c + colSpan; i += 1) {\n w += colExtents[i] ?? 0;\n }\n\n let h = (rowSpan - 1) * spacing;\n\n for (let i = r; i < r + rowSpan; i += 1) {\n h += rowExtents[i] ?? 0;\n }\n\n const min = component.getMinSize();\n\n if (min && (min.width > w || min.height > h)) {\n // The child's own `min-width` / `min-height` keep its box from\n // shrinking to the cell on the overflowing axis, so clip it with\n // a cell-sized frame. Honour the grid's fill/anchor on whichever\n // axis the child *does* fit — `resolveBounds` yields the\n // fill/anchor-placed box — and override only the overflowing axis\n // to the child's natural extent (its preferred size, falling back\n // to min) so the content renders at full size up to the clip edge\n // rather than at a cramped preferred that drops fill. The frame is\n // anchored at the cell; the child commits at the resolved offset\n // within it (0 on an overflowing axis, since `resolveBounds`\n // applies no anchor displacement when the child exceeds the cell).\n const resolved = this.resolveBounds(component, x, y, w, h, this._defaultFill, this._defaultAnchor);\n const pref = component.getPreferredSize();\n\n const childWidth = min.width > w ? (pref ? pref.width : min.width) : resolved.width;\n const childHeight = min.height > h ? (pref ? pref.height : min.height) : resolved.height;\n\n component.setClipFrame(x, y, w, h);\n this.commitBounds(component, resolved.x - x, resolved.y - y, childWidth, childHeight);\n } else {\n // The child fits: resolve its bounds honouring its own\n // fill/anchor over the grid defaults, then commit the result so\n // a non-filling child shrinks and anchors within its cell.\n const resolved = this.resolveBounds(component, x, y, w, h, this._defaultFill, this._defaultAnchor);\n\n component.clearClipFrame();\n this.commitBounds(component, resolved.x, resolved.y, resolved.width, resolved.height);\n }\n };\n\n // Pass 1 — reserve explicitly-positioned children.\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n\n if (!cons || (cons.col == null && cons.row == null)) {\n continue;\n }\n\n const c = Util.clamp(cons.col ?? 0, 0, Math.max(0, cols - 1));\n const r = Util.clamp(cons.row ?? 0, 0, Math.max(0, rows - 1));\n const colSpan = Util.clamp(cons.colSpan ?? 1, 1, cols - c);\n const rowSpan = Util.clamp(cons.rowSpan ?? 1, 1, rows - r);\n\n for (let rr = r; rr < r + rowSpan; rr += 1) {\n for (let cc = c; cc < c + colSpan; cc += 1) {\n if (occupancy[rr][cc]) {\n console.warn(`Grid: ${component.getId()} overlaps ${owners[rr][cc]} at cell (${rr},${cc})`);\n }\n\n occupancy[rr][cc] = true;\n owners[rr][cc] = component.getId();\n }\n }\n\n placeAt(component, r, c, rowSpan, colSpan);\n }\n\n // Pass 2 — auto-flow the remaining children into free cells.\n for (const component of components) {\n const cons = this.getLayoutConstraints(component) as GridConstraints | undefined;\n\n if (cons && (cons.col != null || cons.row != null)) {\n continue;\n }\n\n const colSpan = Util.clamp(cons?.colSpan ?? 1, 1, cols);\n const rowSpan = Util.clamp(cons?.rowSpan ?? 1, 1, rows);\n\n const slot = this.findFreeCell(occupancy, rows, cols, rowSpan, colSpan);\n\n if (!slot) {\n continue;\n }\n\n for (let rr = slot.r; rr < slot.r + rowSpan; rr += 1) {\n for (let cc = slot.c; cc < slot.c + colSpan; cc += 1) {\n occupancy[rr][cc] = true;\n owners[rr][cc] = component.getId();\n }\n }\n\n placeAt(component, slot.r, slot.c, rowSpan, colSpan);\n }\n }\n\n /**\n * Scans the occupancy grid in row-major order for the first top-left cell\n * whose `rowSpan`×`colSpan` block is entirely free.\n *\n * @param occupancy - The `boolean[rows][cols]` occupancy map.\n * @param rows - The row count.\n * @param cols - The column count.\n * @param rowSpan - The block height to fit.\n * @param colSpan - The block width to fit.\n * @returns The free block's top-left `{ r, c }`, or `null` if none fits.\n */\n private findFreeCell(occupancy: boolean[][], rows: number, cols: number, rowSpan: number, colSpan: number): { r: number; c: number } | null {\n for (let r = 0; r + rowSpan <= rows; r += 1) {\n for (let c = 0; c + colSpan <= cols; c += 1) {\n let free = true;\n\n for (let rr = r; rr < r + rowSpan && free; rr += 1) {\n for (let cc = c; cc < c + colSpan; cc += 1) {\n if (occupancy[rr][cc]) {\n free = false;\n\n break;\n }\n }\n }\n\n if (free) {\n return { r, c };\n }\n }\n }\n\n return null;\n }\n}\n\nconst GridCallable = callable(Grid);\ntype GridCallable = Grid;\nexport {\n Grid as _Grid,\n GridCallable as Grid\n};\n"],"mappings":"iIA6CA,IAAM,KAAN,cAAmB,CAAc,CAE7B,MAAwB,EACxB,SAA2B,EAC3B,SAA2B,EAC3B,aAAiC,EAAS,KAC1C,eAAqC,EAAW,OAChD,eAAkC,GAClC,cAAqC,CAAC,EACtC,WAAkC,CAAC,EAEnC,YAAY,EAAuB,CAG/B,MAAM,EAEF,GACA,KAAK,aAAa,CAAO,CAEjC,CASA,aAAuB,EAA4B,CAC/C,MAAM,aAAa,CAAO,EAEtB,EAAQ,OAAS,IAAA,IACjB,KAAK,QAAQ,EAAQ,IAAI,EAGzB,EAAQ,UAAY,IAAA,IACpB,KAAK,WAAW,EAAQ,OAAO,EAG/B,EAAQ,UAAY,IAAA,IACpB,KAAK,oBAAoB,EAAQ,OAAO,EAGxC,EAAQ,cAAgB,IAAA,IACxB,KAAK,eAAe,EAAQ,WAAW,EAGvC,EAAQ,gBAAkB,IAAA,IAC1B,KAAK,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0 +1,2 @@
1
+ import{t as e}from"./DOM-CGn7xyTw.js";import{a as t,l as n,n as r}from"./Position-A39T7-_1.js";import{_ as i,f as a,h as o,l as s,t as c,u as l,y as u}from"./Component-DXf5a3g0.js";import{t as d}from"./ListenerBag-WPdKuuds.js";import{t as f}from"./HBox-Ce0GTCJP.js";import{i as p,n as m,t as h}from"./LayoutSizes-DU3qSq0w.js";import{n as g}from"./Border-BgaZkc1R.js";import{t as _}from"./LayoutConstraints-DkctJZXB.js";import{t as v}from"./Button-U1rsP4v8.js";var y=14,b=`▶`,x=null;function ensureAccordionIndicatorClassRule(){x||=new i({scope:`class`,name:`AccordionIndicator`,styles:{textAlign:`center`,pointerEvents:`none`,fontSize:`10px`,color:`var(--ts-ui-accordion-indicator-color, rgb(100,100,100))`,transition:`transform 200ms ease`}})}var AccordionIndicator=class extends c{_lineHeight=null;constructor(e){ensureAccordionIndicatorClassRule(),super({tag:`span`,preferredSize:{width:y,height:y},...e??{}}),this._expanded??=!1,this._character??=b,this.createStyleRule(`.expanded`).set(`transform`,`rotate(90deg)`)}setLineHeight(e){return this._lineHeight===e?this:(this._lineHeight=e,this.setElementCSSRule(`lineHeight`,e+`px`),this)}setHeight(e){return super.setHeight(e),this.setLineHeight(e),this}applyOptions(e){return super.applyOptions(e),e.expanded!==void 0&&this.setExpanded(e.expanded),e.character!==void 0&&this.setCharacter(e.character),this}getCharacter(){return this._character??b}setCharacter(t){this._character=t;let n=this.getElement();return n&&e.sink.apply(n,{text:t}),this}render(){let t=super.render();return e.sink.apply(t,{text:this._character??b}),this._expanded&&e.sink.apply(t,{addClass:[`expanded`]}),t}getExpanded(){return this._expanded}setExpanded(t){this._expanded=t;let n=this.getElement();return n&&e.sink.apply(n,{toggleClass:{expanded:t}}),this}clearExpanded(){return this.setExpanded(!1)}setAnimationTiming(e,t){return this.setTransition(`transform ${e}ms ${t}`),this}},S=a(AccordionIndicator),C=8,w=10,T=4,E=6,D=6,O=2,AccordionHeader=class extends c{_tools=[];_chevronSide=`end`;constructor(e,t){super({tag:`div`,...t}),this._indicator=new S({character:t?.chevronGlyph}),this._title=new v(e,{chromeless:!0,anchor:l.WEST,glyph:t?.glyph}),this._toolGroup=new c,this._toolGroup.setLayoutManager(new f({spacing:T,stretching:!0})),this._toolGroup.setBackgroundColor(`transparent`),this.setLayoutManager(new f({spacing:T,stretching:!0}));let n=new _;n.weight=1,this.addComponent(this._title,n),this.addComponent(this._toolGroup),this._chevronSide=t?.chevronSide??`end`,this.placeIndicator(),this.setExpanded(t?.expanded??!1),this.setCompact(t?.compact??!1)}setCompact(e){let t=e?E:C,n=e?D:w;return this.setInsets(new r(0,n,0,t)),this.getLayoutManager().setComponentSpacing(e?O:T),this._title?.setCompact(e),this.scheduleLayout(),this}placeIndicator(){this.getComponents().includes(this._indicator)&&this.removeComponent(this._indicator),this._chevronSide===`start`?this.insertComponent(this._indicator,0):this.addComponent(this._indicator)}getTitleButton(){return this._title}setExpanded(e){return this._indicator?.setExpanded(e),this._title?.getAria().setExpanded(e),this}isExpanded(){return this._indicator?.getExpanded()??!1}setChevronSide(e){return this._chevronSide===e?this:(this._chevronSide=e,this.placeIndicator(),this.scheduleLayout(),this)}getChevronSide(){return this._chevronSide}setChevronGlyph(e){return this._indicator?.setCharacter(e),this}addTool(e){return e instanceof v&&e.setFlat(!0),this._tools.includes(e)?this:(this._tools.push(e),this._toolGroup.addComponent(e),this.scheduleLayout(),this)}removeTool(e){let t=this._tools.indexOf(e);return t===-1?this:(this._tools.splice(t,1),this._toolGroup.removeComponent(e),this.scheduleLayout(),this)}setToolsRevealed(e){return this._toolGroup.setDisplayed(e),this}setAnimationTiming(e,t){return this._indicator?.setAnimationTiming(e,t),this}},k=a(AccordionHeader),A=`cubic-bezier(0.4, 0, 0.6, 1)`,j=22,M=6,N=1e-6,P=`var(--ts-ui-accordion-header-bg, rgb(243,244,246))`,F=`var(--ts-ui-accordion-header-border, 1px solid rgb(214,217,222))`,I=`var(--ts-ui-accordion-header-color, inherit)`,L=`var(--ts-ui-accordion-border, 1px solid rgb(214,217,222))`,Accordion=class extends s{_headers=[];_panelWrappers=[];_openState=[];_singleOpen=!1;_headerHeight=28;_headerHeightExplicit=!1;_compact=!1;_animationDuration=200;_chevronSide=`end`;_chevronGlyph=null;_spacing=0;_themed=!0;_fillHeight=!1;_tools=[];_toolsVisibility=`hover`;_hoveredHeader=-1;_listeners=new d;_resizable=!1;_resizeSizes=new Map;_pendingSectionSizes=null;_resizeFactor=1;_resizePinned=new Set;_resizeGutters=[];_gutterPairs=[];_dragUpper=null;_dragLower=null;_dragLastPointer=0;_dragOpenIndices=[];_dragGutterUpperPos=0;_toggleAnimations=0;_shrinkAnimations=new Map;_wrapperAnimations=new Map;_boundOnGutterDragEnd=()=>this.onGutterDragEnd();constructor(e){super(),e&&this.applyOptions(e)}applyOptions(e){if(super.applyOptions(e),e.headerHeight!==void 0&&this.setHeaderHeight(e.headerHeight),e.animationDuration!==void 0&&this.setAnimationDuration(e.animationDuration),e.chevronSide!==void 0&&this.setChevronSide(e.chevronSide),e.toolsVisibility!==void 0&&this.setToolsVisibility(e.toolsVisibility),e.compact!==void 0&&this.setCompact(e.compact),e.chevronGlyph!==void 0&&this.setChevronGlyph(e.chevronGlyph),e.spacing!==void 0&&this.setSpacing(e.spacing),e.themed!==void 0&&this.setThemed(e.themed),e.fillHeight!==void 0&&this.setFillHeight(e.fillHeight),e.resizable!==void 0&&this.setResizable(e.resizable),e.sectionSizes!==void 0&&(this._pendingSectionSizes=e.sectionSizes.map(e=>({...e}))),e.listeners!==void 0){let t=e.listeners;for(let e of Object.keys(t)){let n=t[e];n!==void 0&&this.on(e,n)}}e.singleOpen!==void 0&&this.setSingleOpen(e.singleOpen)}isSingleOpen(){return this._singleOpen}setSingleOpen(e){if(this._singleOpen=e,!e)return this;let t=!1;for(let e=0;e<this._openState.length;e++)this._openState[e]&&(t?(this.primeWrapper(e),this._openState[e]=!1,this._headers[e].setExpanded(!1),this.emit(`sectiontoggle`,e,!1)):t=!0);return this.relayoutHost(),this}getHeaderHeight(){return this._headerHeight}setHeaderHeight(e){return this._headerHeight=e,this._headerHeightExplicit=!0,this}effectiveHeaderHeight(){return this._compact&&!this._headerHeightExplicit?j:this._headerHeight}isCompact(){return this._compact}setCompact(e){this._compact=e;for(let t of this._headers)t.setCompact(e);return this.relayoutHost(),this}getAnimationDuration(){return this._animationDuration}setAnimationDuration(e){return this._animationDuration=e,this}getChevronSide(){return this._chevronSide}setChevronSide(e){this._chevronSide=e;for(let t of this._headers)t.setChevronSide(e);return this.getContainer()?.scheduleLayout(),this}getChevronGlyph(){return this._chevronGlyph}setChevronGlyph(e){this._chevronGlyph=e;for(let t of this._headers)t.setChevronGlyph(e);return this.getContainer()?.scheduleLayout(),this}getSpacing(){return this._spacing}setSpacing(e){return this._spacing=e,this.relayoutHost(),this}isFillHeight(){return this._fillHeight}setFillHeight(e){return this._fillHeight=e,this.getContainer()?.scheduleLayout(),this}isResizable(){return this._resizable}setResizable(e){return this._resizable=e,this.getContainer()?.scheduleLayout(),this}isThemed(){return this._themed}setThemed(e){this._themed=e,this.applyContainerTheming();for(let e=0;e<this._headers.length;e++)this.applySectionTheming(e);return this.getContainer()?.scheduleLayout(),this}applyContainerTheming(){let e=this.getContainer();e&&(this._themed?e.setBorder({border:L}):e.clearBorder())}applySectionTheming(e){let t=this._headers[e];if(t){if(!this._themed){t.clearBackground(),t.clearForegroundColor(),t.clearBorder();return}t.setBackground(P),t.setForegroundColor(I),t.setBorder({border:`none`,borderBottom:F})}}getToolsVisibility(){return this._toolsVisibility}setToolsVisibility(e){this._toolsVisibility=e;for(let t of this._headers)t.setToolsRevealed(e===`always`);return this}addTool(e){return this._tools.includes(e)?this:(this._tools.push(e),this._hoveredHeader!==-1&&this._headers[this._hoveredHeader]?.addTool(e),this.getContainer()?.scheduleLayout(),this)}removeTool(e){let t=this._tools.indexOf(e);return t===-1?this:(this._tools.splice(t,1),this._hoveredHeader!==-1&&this._headers[this._hoveredHeader]?.removeTool(e),this.getContainer()?.scheduleLayout(),this)}revealHeaderTools(e){let t=this._headers[e];if(t){for(let e of this._tools)t.addTool(e);this._toolsVisibility===`hover`&&t.setToolsRevealed(!0)}}hideHeaderTools(e){let t=this._headers[e];if(t){for(let e of this._tools)t.removeTool(e);this._toolsVisibility===`hover`&&t.setToolsRevealed(!1)}}onHeaderHoverEnter(t,n){let r=this._headers[t]?.getElement();r&&e.source.isNode(n.relatedTarget)&&e.source.contains(r,e.source.intern(n.relatedTarget))||this._hoveredHeader!==t&&(this._hoveredHeader!==-1&&this.hideHeaderTools(this._hoveredHeader),this._hoveredHeader=t,this.revealHeaderTools(t))}onHeaderHoverLeave(t,n){let r=this._headers[t]?.getElement();r&&e.source.isNode(n.relatedTarget)&&e.source.contains(r,e.source.intern(n.relatedTarget))||this._hoveredHeader===t&&(this.hideHeaderTools(t),this._hoveredHeader=-1)}relayoutHost(){let e=this.getContainer();e?.scheduleLayout(),e?.notifyIntrinsicSizeChanged()}openSection(e){if(e<0||e>=this._openState.length)return this;if(this._singleOpen)for(let t=0;t<this._openState.length;t++)t!==e&&this._openState[t]&&(this.primeWrapper(t),this._openState[t]=!1,this._headers[t].setExpanded(!1),this.emit(`sectiontoggle`,t,!1));return this.primeWrapper(e),this._openState[e]=!0,this._headers[e].setExpanded(!0),this.emit(`sectiontoggle`,e,!0),this.relayoutHost(),this}closeSection(e){return e<0||e>=this._openState.length?this:(this.primeWrapper(e),this._openState[e]=!1,this._headers[e].setExpanded(!1),this.emit(`sectiontoggle`,e,!1),this.relayoutHost(),this)}expandAll(){if(this._singleOpen)return this.openSection(0),this;for(let e=0;e<this._openState.length;e++)this.openSection(e);return this}collapseAll(){for(let e=0;e<this._openState.length;e++)this.closeSection(e);return this}isSectionOpen(e){return this._openState[e]??!1}sectionSizeUnits(e){return e.map(e=>this.effectiveWeight(e)===0?`px`:`ratio`)}getSectionSizes(){let e=this.getContainer();if(!e)return[];let t=e.getComponents();if(t.length===0)return[];let n=this.sectionSizeUnits(t);return this._pendingSectionSizes!==null&&m(this._pendingSectionSizes,n)?this._pendingSectionSizes.map(e=>({...e})):p(n,t.map(e=>this._resizeSizes.get(e)??0))}applySectionSizes(e){return this._pendingSectionSizes=e.map(e=>({...e})),this.getContainer()?.scheduleLayout(),this}on(e,t){return this._listeners.add(e,t),this}off(e,t){return this._listeners.remove(e,t),this}emit(e,...t){this._listeners.fire(e,...t)}attach(e){return super.attach(e),this}detach(){let t=this.getContainer();for(let e of this._shrinkAnimations.values())e.cancel();this._shrinkAnimations.clear();for(let e of this._wrapperAnimations.values())e.cancel();this._wrapperAnimations.clear(),this._toggleAnimations>0&&(this._toggleAnimations=0,this.setSectionTransitions(!1),t?.setTransition(null)),this._dragUpper&&this.onGutterDragEnd();for(let n=0;n<this._headers.length;n++){let r=(t?t.getComponents():[])[n];r&&t&&e.sink.appendChild(t.getElement(),r.getElement()),e.sink.removeElement(this._headers[n].getElement()),e.sink.removeElement(this._panelWrappers[n].getElement())}this._headers=[],this._panelWrappers=[],this._openState=[];for(let t of this._resizeGutters)e.sink.removeElement(t.getElement()),t.destroy();return this._resizeGutters=[],this._resizeSizes.clear(),this._gutterPairs=[],super.detach(),this}getPreferredSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=e.getComponents(),r=t.top+t.bottom,i=0,a=0;for(let e=0;e<n.length;e++)if(n[e].isDisplayed()&&(a>0&&(r+=this._spacing),a+=1,r+=this.effectiveHeaderHeight(),e<this._openState.length?this._openState[e]:this.getLayoutConstraints(n[e])?.initiallyOpen??!1)){let t=n[e].getPreferredSize();t&&(r+=t.height,t.width>i&&(i=t.width))}return{width:i+t.left+t.right,height:r}}getMinSize(){let e=this.getContainer();if(!e)return null;let t=e.getPerimeterSize(),n=e.getComponents(),r=t.top+t.bottom,i=0,a=0;for(let e=0;e<n.length;e++)if(n[e].isDisplayed()&&(a>0&&(r+=this._spacing),a+=1,r+=this.effectiveHeaderHeight(),e<this._openState.length?this._openState[e]:this.getLayoutConstraints(n[e])?.initiallyOpen??!1)){let t=n[e].getMinSize();t&&(r+=t.height,t.width>i&&(i=t.width))}return{width:i+t.left+t.right,height:r}}getMaxSize(){return{width:t,height:t}}createSection(t,n){let r=this.getContainer(),i=this.getLayoutConstraints(t),a=i?.label??t.getId(),o=i?.initiallyOpen??!1,s=new k(a,{chevronSide:this._chevronSide,glyph:i?.glyph??void 0,compact:this._compact,chevronGlyph:this._chevronGlyph??void 0});s.setAnimationTiming(this._animationDuration,A),s.setTransition(`none`);let l=s.getTitleButton();l.on(`action`,()=>this.onHeaderClicked(n)),u.addListener(s,`click`,()=>this.onHeaderClicked(n)),u.addListener(l,`keydown`,e=>this.onHeaderKeyDown(e,n)),u.addSubtreeListener(s,`mouseover`,e=>this.onHeaderHoverEnter(n,e)),u.addSubtreeListener(s,`mouseout`,e=>this.onHeaderHoverLeave(n,e));let d=new c;d.setOverflow(`hidden`),d.setContain(`layout paint`),d.setTransition(`none`),e.sink.appendChild(r.getElement(),s.getElement(!0)),e.sink.appendChild(r.getElement(),d.getElement(!0)),e.sink.appendChild(d.getElement(),t.getElement()),t.setTransition(`none`),this._openState.push(o),this._headers.push(s),this._panelWrappers.push(d),s.setExpanded(o),l.getAria().setControls(d.getId()),d.getAria().setRole(`region`),d.getAria().setLabelledBy(l.getId());for(let e of i?.tools??[])s.addTool(e);this._toolsVisibility===`hover`&&s.setToolsRevealed(!1),this.applySectionTheming(n)}computeTotalMinSize(){let e=this.getContainer();if(!e)return{width:0,height:0};let t=0;for(let n of e.getComponents()){if(!n.isDisplayed())continue;let e=n.getMinSize();e&&(t=Math.max(t,e.width))}return{width:t,height:0}}placeSection(e,t,n,r,i,a,o){let s=this._headers[e],c=this._panelWrappers[e],l=this.effectiveHeaderHeight();s.setX(o),s.setY(n),s.setWidth(a),s.setHeight(l),s.doLayout();let u=n+l;return c.setX(o),c.setY(u),c.setWidth(a),c.setHeight(r),t.setX(0),t.setY(0),t.setWidth(a),t.setHeight(i),u+r}doLayout(){let e=this.getContainer();if(!e)return;let t=e.getComponents();for(let e=this._headers.length;e<t.length;e++)this.createSection(t[e],e);this.applyContainerTheming();let n=e.getInnerSize(),r=e.getContentInsets(),i=n?n.width:0;if(this.isOverflowingX()){let e=this.computeTotalMinSize();i=Math.max(i,e.width)}let a=this.computeShrinkRatio(t,n),o=this.computeFill(t,n,a),s=this.computeResizableHeights(t,n,a,o);this.layoutSections(t,i,r.getLeft(),r.getTop(),s!==null,(e,n)=>{if(n)return s?.get(e)??this.openContentHeight(t[e],a)+(o.get(e)??0);let r=t[e].getPreferredSize();return r?r.height:100},!0,!0)}layoutSections(e,t,n,r,i,a,s,c){let l=r,u=0,d=null,f=0,p=0;for(let r=0;r<e.length;r++){let m=e[r],h=this._headers[r],g=this._panelWrappers[r],_=this._openState[r];if(!m.isDisplayed()){h.setDisplayed(!1),g.setDisplayed(!1);continue}h.setDisplayed(!0),g.setDisplayed(!0),u>0&&(l+=this._spacing),u+=1;let v=a(r,_),y=_?v:0;_&&i&&d!==null&&(this.placeGutter(p,f,t,n),this._gutterPairs[p]={upper:d,lower:m},p+=1);let b=m.getHeight(),x=_&&s&&!o.isReducedMotion()&&v<b,S=this.placeSection(r,m,l,y,v,t,n);(c||v!==b)&&(x?(this._shrinkAnimations.get(r)?.cancel(),this._shrinkAnimations.set(r,o.afterTransition({component:g,property:`height`,durationMs:this._animationDuration,fallbackBufferMs:40,onComplete:()=>{this._shrinkAnimations.delete(r),m.doLayout()}}))):m.doLayout()),_&&i&&(d=m,f=S),l=S}this._gutterPairs.length=p;for(let e=p;e<this._resizeGutters.length;e++)this._resizeGutters[e].setVisible(!1)}getOrCreateResizeGutter(t){let n=this._resizeGutters[t];if(n)return n;let r=this.getContainer(),i=new g(`vertical`,{collapsible:!1,expandedBackground:`transparent`});return i.setTransition(`none`),i.on(`dragstart`,e=>this.onGutterDragStart(t,e)),i.on(`drag`,e=>this.onGutterDrag(t,e)),e.sink.appendChild(r.getElement(),i.getElement(!0)),this._resizeGutters.push(i),i}placeGutter(e,t,n,r){let i=this.getOrCreateResizeGutter(e);i.setX(r),i.setY(t-M),i.setWidth(n),i.setHeight(M),i.setVisible(!0)}onGutterDragStart(e,t){let n=this._gutterPairs[e];if(!n)return;let r=this.getContainer()?.getComponents()??[];this._dragOpenIndices=[];for(let e=0;e<r.length;e++)r[e].isDisplayed()&&this._openState[e]&&this._dragOpenIndices.push(e);if(this._dragGutterUpperPos=this._dragOpenIndices.indexOf(r.indexOf(n.upper)),this._dragGutterUpperPos===-1)return;this._dragUpper=n.upper,this._dragLower=n.lower,this._dragLastPointer=t;let i=this.getContainer();i&&(u.addViewportListener(i,`mouseup`,this._boundOnGutterDragEnd),u.addViewportListener(i,`touchend`,this._boundOnGutterDragEnd),u.addViewportListener(i,`touchcancel`,this._boundOnGutterDragEnd))}onGutterDrag(e,t){let n=this._gutterPairs[e],r=this.getContainer();if(!n||n.upper!==this._dragUpper||n.lower!==this._dragLower||!r)return;let i=r.getComponents(),a=this._dragOpenIndices,o=this._dragGutterUpperPos,s=t-this._dragLastPointer,c=a.map(e=>i[e].getHeight()),l=a.map(e=>{let t=i[e].getMinSize();return t?t.height:0}),u=a.map(e=>{let t=i[e].getMaxSize();return t?t.height:1/0}),d=[],f=[];for(let e=o;e>=0;e--)d.push(e);for(let e=o+1;e<a.length;e++)f.push(e);let p=s>=0?d:f,m=s>=0?f:d,h=0,g=0;for(let e of p)h+=Math.max(0,u[e]-c[e]);for(let e of m)g+=Math.max(0,c[e]-l[e]);let _=Math.max(0,Math.min(Math.abs(s),h,g));this._dragLastPointer+=Math.sign(s)*_;let v=c.slice();this.distributeDragChain(p,c,_,1,l,u,v),this.distributeDragChain(m,c,_,-1,l,u,v);let y=new Map;for(let e=0;e<a.length;e++){let t=i[a[e]],n=this._resizePinned.has(t)?1:this._resizeFactor;y.set(a[e],v[e]),this._resizeSizes.set(t,v[e]/n)}let b=r.getContentInsets(),x=this._panelWrappers[a[0]].getWidth();this.layoutSections(i,x,b.getLeft(),b.getTop(),!0,(e,t)=>t?y.get(e)??i[e].getHeight():i[e].getHeight(),!1,!1)}distributeDragChain(e,t,n,r,i,a,o){let room=e=>r>0?Math.max(0,a[e]-t[e]):Math.max(0,t[e]-i[e]),s=n;for(let t of e){if(s<=N)return;let e=Math.min(s,room(t));o[t]+=r*e,s-=e}}onGutterDragEnd(){let e=this._dragUpper!==null,t=this.getContainer();return t&&(u.removeViewportListener(t,`mouseup`,this._boundOnGutterDragEnd),u.removeViewportListener(t,`touchend`,this._boundOnGutterDragEnd),u.removeViewportListener(t,`touchcancel`,this._boundOnGutterDragEnd)),this._dragUpper=null,this._dragLower=null,e&&this.emit(`sectionresize`,this.getSectionSizes()),!0}computeShrinkRatio(e,t){if(!t)return 0;let n=0,r=0,i=0,a=0;for(let t=0;t<e.length;t++){if(!e[t].isDisplayed()||(a>0&&(n+=this._spacing),a+=1,n+=this.effectiveHeaderHeight(),!this._openState[t]))continue;let o=e[t].getPreferredSize(),s=e[t].getMinSize();r+=o?o.height:100,i+=s?s.height:0}let o=n+r,s=n+i,c=t.height;if(o<=c||s>c)return 0;let l=o-s;return l>0?(o-c)/l:0}openContentHeight(e,t){let n=e.getPreferredSize(),r=n?n.height:100,i=e.getMinSize(),a=i?i.height:0,o=r-t*(r-a),s=e.getMaxSize(),c=s?Math.min(o,s.height):o;return Math.max(c,a)}computeFill(e,t,n){let r=new Map;if(!t)return r;let i=0,a=0,o=[],s=0;for(let t=0;t<e.length;t++)if(e[t].isDisplayed()&&(a>0&&(i+=this._spacing),a+=1,i+=this.effectiveHeaderHeight(),this._openState[t])){let r=this.openContentHeight(e[t],n);i+=r;let a=this.effectiveWeight(e[t]);a>0&&(o.push({index:t,weight:a,headroom:this.fillHeadroom(e[t],r)}),s+=a)}let c=t.height-i;return c<=0||s<=0?r:this.distributeFillWithinMax(o,c)}effectiveWeight(e){let t=this.getLayoutConstraints(e)?.weight??0;return t>0?t:+!!this._fillHeight}resizePinnedSections(e,t,n){let r=[],i=0,a=0;for(let n of t)this.effectiveWeight(e[n])>0?i+=1:(r.push(n),a+=this.clampSectionHeight(e[n],this._resizeSizes.get(e[n])??0));return i===0||a>n?[]:r}clampSectionHeight(e,t){let r=e.getMinSize(),i=e.getMaxSize();return n.clamp(t,r?r.height:0,i?i.height:1/0)}fillHeadroom(e,t){let n=e.getMaxSize();return n?Math.max(0,n.height-t):1/0}distributeFillWithinMax(e,t){let n=new Map,r=new Set(e),i=t;for(;;){let e=0;for(let t of r)e+=t.weight;if(e<=0)break;let t=i/e,a=!1;for(let e of r)if(e.weight*t>e.headroom){n.set(e.index,e.headroom),i-=e.headroom,r.delete(e),a=!0;break}if(!a){for(let e of r)n.set(e.index,e.weight*t);break}if(r.size===0)break}return n}computeResizableHeights(e,t,n,r){if(!this._resizable||!t)return null;for(let t of[...this._resizeSizes.keys()])e.includes(t)||this._resizeSizes.delete(t);let i=0,a=0,o=[];for(let t=0;t<e.length;t++)e[t].isDisplayed()&&(a>0&&(i+=this._spacing),a+=1,i+=this.effectiveHeaderHeight(),this._openState[t]&&o.push(t));if(o.length===0)return null;let s=t.height-i;this.applyPendingSectionSizes(e,s);for(let t of o){let i=e[t];this._resizeSizes.has(i)||this._resizeSizes.set(i,this.openContentHeight(i,n)+(r.get(t)??0))}return this.distributeWithinConstraints(e,o,s)}applyPendingSectionSizes(e,t){let n=this._pendingSectionSizes;if(n===null||(this._pendingSectionSizes=null,!m(n,this.sectionSizeUnits(e))))return;let r=h(n,t);for(let t=0;t<e.length;t+=1)r[t]>0?this._resizeSizes.set(e[t],r[t]):this._resizeSizes.delete(e[t])}distributeWithinConstraints(e,t,n){let r=new Map,i=new Set(t),a=n,o=1;this._resizePinned.clear();for(let o of this.resizePinnedSections(e,t,n)){let t=this.clampSectionHeight(e[o],this._resizeSizes.get(e[o])??0);r.set(o,t),a-=t,i.delete(o),this._resizePinned.add(e[o])}for(;;){let t=0;for(let n of i)t+=this._resizeSizes.get(e[n])??0;o=t>0?a/t:0;let n=!1;for(let t of i){let s=e[t],c=(this._resizeSizes.get(s)??0)*o,l=s.getMinSize(),u=s.getMaxSize(),d=l?l.height:0,f=u?u.height:1/0;if(c<d){r.set(t,d),a-=d,i.delete(t),n=!0;break}if(c>f){r.set(t,f),a-=f,i.delete(t),n=!0;break}}if(!n){for(let t of i)r.set(t,(this._resizeSizes.get(e[t])??0)*o);break}if(i.size===0)break}return this._resizeFactor=o>0?o:1,r}onHeaderKeyDown(e,t){let n=this._headers.length;if(n===0)return;let r;switch(e.key){case`ArrowDown`:r=(t+1)%n;break;case`ArrowUp`:r=(t-1+n)%n;break;case`Home`:r=0;break;case`End`:r=n-1;break;default:return}e.preventDefault(),this._headers[r].getTitleButton().focus()}onHeaderClicked(e){let t=this._openState[e];if(this._singleOpen&&!t)for(let t=0;t<this._openState.length;t++)t!==e&&this._openState[t]&&(this.primeWrapper(t),this._openState[t]=!1,this._headers[t].setExpanded(!1),this.emit(`sectiontoggle`,t,!1));let n=!t;this.primeWrapper(e),this._openState[e]=n,this._headers[e].setExpanded(n),this.emit(`sectiontoggle`,e,n),this.relayoutHost()}primeWrapper(t){if(o.isReducedMotion())return;let n=this._panelWrappers[t],r=this.getContainer();this.setSectionTransitions(!0),r?.setTransition(`height ${this._animationDuration}ms ${A}`),n.setWillChange(`height`);let i=r?.getElement();i&&e.source.getElementRect(i);let a=this._wrapperAnimations.get(t);a?(a.cancel(),this._wrapperAnimations.delete(t)):this._toggleAnimations+=1,this._wrapperAnimations.set(t,o.afterTransition({component:n,property:`height`,durationMs:this._animationDuration,fallbackBufferMs:40,onComplete:()=>{this._wrapperAnimations.delete(t),n.setWillChange(null),--this._toggleAnimations,this._toggleAnimations<=0&&(this._toggleAnimations=0,this.setSectionTransitions(!1),r?.setTransition(null),this.relayoutHost())}}))}setSectionTransitions(e){let t=this.getContainer()?.getComponents()??[];for(let n=0;n<this._headers.length;n++)this._headers[n].setTransition(e?this.buildHeaderTransition():`none`),this._panelWrappers[n].setTransition(e?this.buildWrapperTransition():`none`),t[n]?.setTransition(e?this.buildContentTransition():`none`);for(let t of this._resizeGutters)t.setTransition(e?this.buildHeaderTransition():`none`)}buildHeaderTransition(){return`top ${this._animationDuration}ms ${A}`}buildWrapperTransition(){return`height ${this._animationDuration}ms ${A}, top ${this._animationDuration}ms ${A}`}buildContentTransition(){return`height ${this._animationDuration}ms ${A}`}},R=a(Accordion),AccordionConstraints=class extends _{label;initiallyOpen;tools;constructor(e,t,n,r){super(),this.label=e,this.initiallyOpen=t,this.glyph=n??null,this.tools=r}},GridConstraints=class extends _{col;row;rowSpan;colSpan;constructor(){super()}};export{S as a,k as i,AccordionConstraints as n,R as r,GridConstraints as t};
2
+ //# sourceMappingURL=GridConstraints-DkLueyrf.js.map