react-stately 3.46.0 → 3.47.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 (496) hide show
  1. package/dist/exports/Color.cjs.map +1 -1
  2. package/dist/exports/Color.js.map +1 -1
  3. package/dist/exports/Color.mjs.map +1 -1
  4. package/dist/exports/index.cjs.map +1 -1
  5. package/dist/exports/index.js.map +1 -1
  6. package/dist/exports/index.mjs.map +1 -1
  7. package/dist/exports/private/autocomplete/useAutocompleteState.cjs.map +1 -1
  8. package/dist/exports/private/autocomplete/useAutocompleteState.js.map +1 -1
  9. package/dist/exports/private/autocomplete/useAutocompleteState.mjs.map +1 -1
  10. package/dist/exports/private/collections/getChildNodes.cjs.map +1 -1
  11. package/dist/exports/private/collections/getChildNodes.js.map +1 -1
  12. package/dist/exports/private/collections/getChildNodes.mjs.map +1 -1
  13. package/dist/exports/private/flags/flags.cjs.map +1 -1
  14. package/dist/exports/private/flags/flags.js.map +1 -1
  15. package/dist/exports/private/flags/flags.mjs.map +1 -1
  16. package/dist/exports/private/form/useFormValidationState.cjs.map +1 -1
  17. package/dist/exports/private/form/useFormValidationState.js.map +1 -1
  18. package/dist/exports/private/form/useFormValidationState.mjs.map +1 -1
  19. package/dist/exports/private/grid/GridCollection.cjs.map +1 -1
  20. package/dist/exports/private/grid/GridCollection.js.map +1 -1
  21. package/dist/exports/private/grid/GridCollection.mjs.map +1 -1
  22. package/dist/exports/private/steplist/useStepListState.cjs.map +1 -1
  23. package/dist/exports/private/steplist/useStepListState.js.map +1 -1
  24. package/dist/exports/private/steplist/useStepListState.mjs.map +1 -1
  25. package/dist/exports/private/table/TableCollection.cjs.map +1 -1
  26. package/dist/exports/private/table/TableCollection.js.map +1 -1
  27. package/dist/exports/private/table/TableCollection.mjs.map +1 -1
  28. package/dist/exports/private/table/useTreeGridState.cjs.map +1 -1
  29. package/dist/exports/private/table/useTreeGridState.js.map +1 -1
  30. package/dist/exports/private/table/useTreeGridState.mjs.map +1 -1
  31. package/dist/exports/useAsyncList.cjs.map +1 -1
  32. package/dist/exports/useAsyncList.js.map +1 -1
  33. package/dist/exports/useAsyncList.mjs.map +1 -1
  34. package/dist/exports/useCalendarState.cjs.map +1 -1
  35. package/dist/exports/useCalendarState.js.map +1 -1
  36. package/dist/exports/useCalendarState.mjs.map +1 -1
  37. package/dist/exports/useColorAreaState.cjs.map +1 -1
  38. package/dist/exports/useColorAreaState.js.map +1 -1
  39. package/dist/exports/useColorAreaState.mjs.map +1 -1
  40. package/dist/exports/useColorFieldState.cjs.map +1 -1
  41. package/dist/exports/useColorFieldState.js.map +1 -1
  42. package/dist/exports/useColorFieldState.mjs.map +1 -1
  43. package/dist/exports/useColorPickerState.cjs.map +1 -1
  44. package/dist/exports/useColorPickerState.js.map +1 -1
  45. package/dist/exports/useColorPickerState.mjs.map +1 -1
  46. package/dist/exports/useColorSliderState.cjs.map +1 -1
  47. package/dist/exports/useColorSliderState.js.map +1 -1
  48. package/dist/exports/useColorSliderState.mjs.map +1 -1
  49. package/dist/exports/useColorWheelState.cjs.map +1 -1
  50. package/dist/exports/useColorWheelState.js.map +1 -1
  51. package/dist/exports/useColorWheelState.mjs.map +1 -1
  52. package/dist/exports/useComboBoxState.cjs +1 -1
  53. package/dist/exports/useComboBoxState.cjs.map +1 -1
  54. package/dist/exports/useComboBoxState.js +1 -1
  55. package/dist/exports/useComboBoxState.js.map +1 -1
  56. package/dist/exports/useComboBoxState.mjs +1 -1
  57. package/dist/exports/useComboBoxState.mjs.map +1 -1
  58. package/dist/exports/useDateFieldState.cjs.map +1 -1
  59. package/dist/exports/useDateFieldState.js.map +1 -1
  60. package/dist/exports/useDateFieldState.mjs.map +1 -1
  61. package/dist/exports/useDatePickerState.cjs.map +1 -1
  62. package/dist/exports/useDatePickerState.js.map +1 -1
  63. package/dist/exports/useDatePickerState.mjs.map +1 -1
  64. package/dist/exports/useDateRangePickerState.cjs.map +1 -1
  65. package/dist/exports/useDateRangePickerState.js.map +1 -1
  66. package/dist/exports/useDateRangePickerState.mjs.map +1 -1
  67. package/dist/exports/useDisclosureGroupState.cjs.map +1 -1
  68. package/dist/exports/useDisclosureGroupState.js.map +1 -1
  69. package/dist/exports/useDisclosureGroupState.mjs.map +1 -1
  70. package/dist/exports/useDraggableCollectionState.cjs.map +1 -1
  71. package/dist/exports/useDraggableCollectionState.js.map +1 -1
  72. package/dist/exports/useDraggableCollectionState.mjs.map +1 -1
  73. package/dist/exports/useDroppableCollectionState.cjs.map +1 -1
  74. package/dist/exports/useDroppableCollectionState.js.map +1 -1
  75. package/dist/exports/useDroppableCollectionState.mjs.map +1 -1
  76. package/dist/exports/useMenuTriggerState.cjs.map +1 -1
  77. package/dist/exports/useMenuTriggerState.js.map +1 -1
  78. package/dist/exports/useMenuTriggerState.mjs.map +1 -1
  79. package/dist/exports/useMultipleSelectionState.cjs.map +1 -1
  80. package/dist/exports/useMultipleSelectionState.js.map +1 -1
  81. package/dist/exports/useMultipleSelectionState.mjs.map +1 -1
  82. package/dist/exports/useOverlayTriggerState.cjs.map +1 -1
  83. package/dist/exports/useOverlayTriggerState.js.map +1 -1
  84. package/dist/exports/useOverlayTriggerState.mjs.map +1 -1
  85. package/dist/exports/useRangeCalendarState.cjs.map +1 -1
  86. package/dist/exports/useRangeCalendarState.js.map +1 -1
  87. package/dist/exports/useRangeCalendarState.mjs.map +1 -1
  88. package/dist/exports/useSelectState.cjs.map +1 -1
  89. package/dist/exports/useSelectState.js.map +1 -1
  90. package/dist/exports/useSelectState.mjs.map +1 -1
  91. package/dist/exports/useSingleSelectListState.cjs.map +1 -1
  92. package/dist/exports/useSingleSelectListState.js.map +1 -1
  93. package/dist/exports/useSingleSelectListState.mjs.map +1 -1
  94. package/dist/exports/useTableState.cjs.map +1 -1
  95. package/dist/exports/useTableState.js.map +1 -1
  96. package/dist/exports/useTableState.mjs.map +1 -1
  97. package/dist/exports/useTimeFieldState.cjs.map +1 -1
  98. package/dist/exports/useTimeFieldState.js.map +1 -1
  99. package/dist/exports/useTimeFieldState.mjs.map +1 -1
  100. package/dist/exports/useToastState.cjs.map +1 -1
  101. package/dist/exports/useToastState.js.map +1 -1
  102. package/dist/exports/useToastState.mjs.map +1 -1
  103. package/dist/private/autocomplete/useAutocompleteState.cjs.map +1 -1
  104. package/dist/private/autocomplete/useAutocompleteState.js.map +1 -1
  105. package/dist/private/autocomplete/useAutocompleteState.mjs.map +1 -1
  106. package/dist/private/calendar/useCalendarState.cjs +82 -30
  107. package/dist/private/calendar/useCalendarState.cjs.map +1 -1
  108. package/dist/private/calendar/useCalendarState.js +85 -32
  109. package/dist/private/calendar/useCalendarState.js.map +1 -1
  110. package/dist/private/calendar/useCalendarState.mjs +84 -32
  111. package/dist/private/calendar/useCalendarState.mjs.map +1 -1
  112. package/dist/private/calendar/useRangeCalendarState.cjs +53 -40
  113. package/dist/private/calendar/useRangeCalendarState.cjs.map +1 -1
  114. package/dist/private/calendar/useRangeCalendarState.js +55 -43
  115. package/dist/private/calendar/useRangeCalendarState.js.map +1 -1
  116. package/dist/private/calendar/useRangeCalendarState.mjs +55 -42
  117. package/dist/private/calendar/useRangeCalendarState.mjs.map +1 -1
  118. package/dist/private/calendar/utils.cjs +6 -1
  119. package/dist/private/calendar/utils.cjs.map +1 -1
  120. package/dist/private/calendar/utils.js +6 -2
  121. package/dist/private/calendar/utils.js.map +1 -1
  122. package/dist/private/calendar/utils.mjs +6 -2
  123. package/dist/private/calendar/utils.mjs.map +1 -1
  124. package/dist/private/checkbox/useCheckboxGroupState.cjs.map +1 -1
  125. package/dist/private/checkbox/useCheckboxGroupState.js.map +1 -1
  126. package/dist/private/checkbox/useCheckboxGroupState.mjs.map +1 -1
  127. package/dist/private/collections/CollectionBuilder.cjs.map +1 -1
  128. package/dist/private/collections/CollectionBuilder.js.map +1 -1
  129. package/dist/private/collections/CollectionBuilder.mjs.map +1 -1
  130. package/dist/private/collections/Item.cjs +1 -0
  131. package/dist/private/collections/Item.cjs.map +1 -1
  132. package/dist/private/collections/Item.js +1 -0
  133. package/dist/private/collections/Item.js.map +1 -1
  134. package/dist/private/collections/Item.mjs +1 -0
  135. package/dist/private/collections/Item.mjs.map +1 -1
  136. package/dist/private/collections/Section.cjs +1 -0
  137. package/dist/private/collections/Section.cjs.map +1 -1
  138. package/dist/private/collections/Section.js +1 -0
  139. package/dist/private/collections/Section.js.map +1 -1
  140. package/dist/private/collections/Section.mjs +1 -0
  141. package/dist/private/collections/Section.mjs.map +1 -1
  142. package/dist/private/collections/getChildNodes.cjs.map +1 -1
  143. package/dist/private/collections/getChildNodes.js.map +1 -1
  144. package/dist/private/collections/getChildNodes.mjs.map +1 -1
  145. package/dist/private/collections/useCollection.cjs.map +1 -1
  146. package/dist/private/collections/useCollection.js.map +1 -1
  147. package/dist/private/collections/useCollection.mjs.map +1 -1
  148. package/dist/private/color/Color.cjs +15 -9
  149. package/dist/private/color/Color.cjs.map +1 -1
  150. package/dist/private/color/Color.js +15 -9
  151. package/dist/private/color/Color.js.map +1 -1
  152. package/dist/private/color/Color.mjs +15 -9
  153. package/dist/private/color/Color.mjs.map +1 -1
  154. package/dist/private/color/useColorAreaState.cjs.map +1 -1
  155. package/dist/private/color/useColorAreaState.js.map +1 -1
  156. package/dist/private/color/useColorAreaState.mjs.map +1 -1
  157. package/dist/private/color/useColorChannelFieldState.cjs.map +1 -1
  158. package/dist/private/color/useColorChannelFieldState.js.map +1 -1
  159. package/dist/private/color/useColorChannelFieldState.mjs.map +1 -1
  160. package/dist/private/color/useColorFieldState.cjs.map +1 -1
  161. package/dist/private/color/useColorFieldState.js.map +1 -1
  162. package/dist/private/color/useColorFieldState.mjs.map +1 -1
  163. package/dist/private/color/useColorPickerState.cjs.map +1 -1
  164. package/dist/private/color/useColorPickerState.js.map +1 -1
  165. package/dist/private/color/useColorPickerState.mjs.map +1 -1
  166. package/dist/private/color/useColorSliderState.cjs +5 -3
  167. package/dist/private/color/useColorSliderState.cjs.map +1 -1
  168. package/dist/private/color/useColorSliderState.js +5 -3
  169. package/dist/private/color/useColorSliderState.js.map +1 -1
  170. package/dist/private/color/useColorSliderState.mjs +5 -3
  171. package/dist/private/color/useColorSliderState.mjs.map +1 -1
  172. package/dist/private/color/useColorWheelState.cjs.map +1 -1
  173. package/dist/private/color/useColorWheelState.js.map +1 -1
  174. package/dist/private/color/useColorWheelState.mjs.map +1 -1
  175. package/dist/private/combobox/useComboBoxState.cjs +8 -2
  176. package/dist/private/combobox/useComboBoxState.cjs.map +1 -1
  177. package/dist/private/combobox/useComboBoxState.js +8 -2
  178. package/dist/private/combobox/useComboBoxState.js.map +1 -1
  179. package/dist/private/combobox/useComboBoxState.mjs +8 -2
  180. package/dist/private/combobox/useComboBoxState.mjs.map +1 -1
  181. package/dist/private/data/useAsyncList.cjs.map +1 -1
  182. package/dist/private/data/useAsyncList.js.map +1 -1
  183. package/dist/private/data/useAsyncList.mjs.map +1 -1
  184. package/dist/private/data/useListData.cjs.map +1 -1
  185. package/dist/private/data/useListData.js.map +1 -1
  186. package/dist/private/data/useListData.mjs.map +1 -1
  187. package/dist/private/data/useTreeData.cjs.map +1 -1
  188. package/dist/private/data/useTreeData.js.map +1 -1
  189. package/dist/private/data/useTreeData.mjs.map +1 -1
  190. package/dist/private/datepicker/IncompleteDate.cjs +8 -2
  191. package/dist/private/datepicker/IncompleteDate.cjs.map +1 -1
  192. package/dist/private/datepicker/IncompleteDate.js +8 -2
  193. package/dist/private/datepicker/IncompleteDate.js.map +1 -1
  194. package/dist/private/datepicker/IncompleteDate.mjs +8 -2
  195. package/dist/private/datepicker/IncompleteDate.mjs.map +1 -1
  196. package/dist/private/datepicker/placeholders.cjs +5 -0
  197. package/dist/private/datepicker/placeholders.cjs.map +1 -1
  198. package/dist/private/datepicker/placeholders.js +5 -0
  199. package/dist/private/datepicker/placeholders.js.map +1 -1
  200. package/dist/private/datepicker/placeholders.mjs +5 -0
  201. package/dist/private/datepicker/placeholders.mjs.map +1 -1
  202. package/dist/private/datepicker/useDateFieldState.cjs.map +1 -1
  203. package/dist/private/datepicker/useDateFieldState.js.map +1 -1
  204. package/dist/private/datepicker/useDateFieldState.mjs.map +1 -1
  205. package/dist/private/datepicker/useDatePickerState.cjs.map +1 -1
  206. package/dist/private/datepicker/useDatePickerState.js.map +1 -1
  207. package/dist/private/datepicker/useDatePickerState.mjs.map +1 -1
  208. package/dist/private/datepicker/useDateRangePickerState.cjs +1 -1
  209. package/dist/private/datepicker/useDateRangePickerState.cjs.map +1 -1
  210. package/dist/private/datepicker/useDateRangePickerState.js +1 -1
  211. package/dist/private/datepicker/useDateRangePickerState.js.map +1 -1
  212. package/dist/private/datepicker/useDateRangePickerState.mjs +1 -1
  213. package/dist/private/datepicker/useDateRangePickerState.mjs.map +1 -1
  214. package/dist/private/datepicker/useTimeFieldState.cjs.map +1 -1
  215. package/dist/private/datepicker/useTimeFieldState.js.map +1 -1
  216. package/dist/private/datepicker/useTimeFieldState.mjs.map +1 -1
  217. package/dist/private/datepicker/utils.cjs +2 -2
  218. package/dist/private/datepicker/utils.cjs.map +1 -1
  219. package/dist/private/datepicker/utils.js +2 -2
  220. package/dist/private/datepicker/utils.js.map +1 -1
  221. package/dist/private/datepicker/utils.mjs +2 -2
  222. package/dist/private/datepicker/utils.mjs.map +1 -1
  223. package/dist/private/disclosure/useDisclosureGroupState.cjs.map +1 -1
  224. package/dist/private/disclosure/useDisclosureGroupState.js.map +1 -1
  225. package/dist/private/disclosure/useDisclosureGroupState.mjs.map +1 -1
  226. package/dist/private/disclosure/useDisclosureState.cjs.map +1 -1
  227. package/dist/private/disclosure/useDisclosureState.js.map +1 -1
  228. package/dist/private/disclosure/useDisclosureState.mjs.map +1 -1
  229. package/dist/private/dnd/useDraggableCollectionState.cjs.map +1 -1
  230. package/dist/private/dnd/useDraggableCollectionState.js.map +1 -1
  231. package/dist/private/dnd/useDraggableCollectionState.mjs.map +1 -1
  232. package/dist/private/dnd/useDroppableCollectionState.cjs.map +1 -1
  233. package/dist/private/dnd/useDroppableCollectionState.js.map +1 -1
  234. package/dist/private/dnd/useDroppableCollectionState.mjs.map +1 -1
  235. package/dist/private/form/useFormValidationState.cjs.map +1 -1
  236. package/dist/private/form/useFormValidationState.js.map +1 -1
  237. package/dist/private/form/useFormValidationState.mjs.map +1 -1
  238. package/dist/private/grid/GridCollection.cjs.map +1 -1
  239. package/dist/private/grid/GridCollection.js.map +1 -1
  240. package/dist/private/grid/GridCollection.mjs.map +1 -1
  241. package/dist/private/grid/useGridState.cjs.map +1 -1
  242. package/dist/private/grid/useGridState.js.map +1 -1
  243. package/dist/private/grid/useGridState.mjs.map +1 -1
  244. package/dist/private/layout/GridLayout.cjs +8 -3
  245. package/dist/private/layout/GridLayout.cjs.map +1 -1
  246. package/dist/private/layout/GridLayout.js +8 -3
  247. package/dist/private/layout/GridLayout.js.map +1 -1
  248. package/dist/private/layout/GridLayout.mjs +8 -3
  249. package/dist/private/layout/GridLayout.mjs.map +1 -1
  250. package/dist/private/layout/ListLayout.cjs +1 -1
  251. package/dist/private/layout/ListLayout.cjs.map +1 -1
  252. package/dist/private/layout/ListLayout.js +2 -1
  253. package/dist/private/layout/ListLayout.js.map +1 -1
  254. package/dist/private/layout/ListLayout.mjs +1 -1
  255. package/dist/private/layout/ListLayout.mjs.map +1 -1
  256. package/dist/private/layout/TableLayout.cjs +60 -35
  257. package/dist/private/layout/TableLayout.cjs.map +1 -1
  258. package/dist/private/layout/TableLayout.js +65 -38
  259. package/dist/private/layout/TableLayout.js.map +1 -1
  260. package/dist/private/layout/TableLayout.mjs +61 -36
  261. package/dist/private/layout/TableLayout.mjs.map +1 -1
  262. package/dist/private/layout/WaterfallLayout.cjs.map +1 -1
  263. package/dist/private/layout/WaterfallLayout.js.map +1 -1
  264. package/dist/private/layout/WaterfallLayout.mjs.map +1 -1
  265. package/dist/private/list/ListCollection.cjs.map +1 -1
  266. package/dist/private/list/ListCollection.js.map +1 -1
  267. package/dist/private/list/ListCollection.mjs.map +1 -1
  268. package/dist/private/list/useListState.cjs.map +1 -1
  269. package/dist/private/list/useListState.js.map +1 -1
  270. package/dist/private/list/useListState.mjs.map +1 -1
  271. package/dist/private/list/useSingleSelectListState.cjs.map +1 -1
  272. package/dist/private/list/useSingleSelectListState.js.map +1 -1
  273. package/dist/private/list/useSingleSelectListState.mjs.map +1 -1
  274. package/dist/private/menu/useMenuTriggerState.cjs.map +1 -1
  275. package/dist/private/menu/useMenuTriggerState.js.map +1 -1
  276. package/dist/private/menu/useMenuTriggerState.mjs.map +1 -1
  277. package/dist/private/menu/useSubmenuTriggerState.cjs.map +1 -1
  278. package/dist/private/menu/useSubmenuTriggerState.js.map +1 -1
  279. package/dist/private/menu/useSubmenuTriggerState.mjs.map +1 -1
  280. package/dist/private/numberfield/useNumberFieldState.cjs +13 -1
  281. package/dist/private/numberfield/useNumberFieldState.cjs.map +1 -1
  282. package/dist/private/numberfield/useNumberFieldState.js +13 -1
  283. package/dist/private/numberfield/useNumberFieldState.js.map +1 -1
  284. package/dist/private/numberfield/useNumberFieldState.mjs +13 -1
  285. package/dist/private/numberfield/useNumberFieldState.mjs.map +1 -1
  286. package/dist/private/overlays/useOverlayTriggerState.cjs.map +1 -1
  287. package/dist/private/overlays/useOverlayTriggerState.js.map +1 -1
  288. package/dist/private/overlays/useOverlayTriggerState.mjs.map +1 -1
  289. package/dist/private/radio/useRadioGroupState.cjs.map +1 -1
  290. package/dist/private/radio/useRadioGroupState.js.map +1 -1
  291. package/dist/private/radio/useRadioGroupState.mjs.map +1 -1
  292. package/dist/private/searchfield/useSearchFieldState.cjs.map +1 -1
  293. package/dist/private/searchfield/useSearchFieldState.js.map +1 -1
  294. package/dist/private/searchfield/useSearchFieldState.mjs.map +1 -1
  295. package/dist/private/select/useSelectState.cjs.map +1 -1
  296. package/dist/private/select/useSelectState.js.map +1 -1
  297. package/dist/private/select/useSelectState.mjs.map +1 -1
  298. package/dist/private/selection/SelectionManager.cjs +2 -1
  299. package/dist/private/selection/SelectionManager.cjs.map +1 -1
  300. package/dist/private/selection/SelectionManager.js +3 -2
  301. package/dist/private/selection/SelectionManager.js.map +1 -1
  302. package/dist/private/selection/SelectionManager.mjs +2 -1
  303. package/dist/private/selection/SelectionManager.mjs.map +1 -1
  304. package/dist/private/selection/useMultipleSelectionState.cjs.map +1 -1
  305. package/dist/private/selection/useMultipleSelectionState.js.map +1 -1
  306. package/dist/private/selection/useMultipleSelectionState.mjs.map +1 -1
  307. package/dist/private/slider/useSliderState.cjs +22 -2
  308. package/dist/private/slider/useSliderState.cjs.map +1 -1
  309. package/dist/private/slider/useSliderState.js +22 -2
  310. package/dist/private/slider/useSliderState.js.map +1 -1
  311. package/dist/private/slider/useSliderState.mjs +22 -2
  312. package/dist/private/slider/useSliderState.mjs.map +1 -1
  313. package/dist/private/steplist/useStepListState.cjs.map +1 -1
  314. package/dist/private/steplist/useStepListState.js.map +1 -1
  315. package/dist/private/steplist/useStepListState.mjs.map +1 -1
  316. package/dist/private/table/Cell.cjs +2 -1
  317. package/dist/private/table/Cell.cjs.map +1 -1
  318. package/dist/private/table/Cell.js +2 -1
  319. package/dist/private/table/Cell.js.map +1 -1
  320. package/dist/private/table/Cell.mjs +2 -1
  321. package/dist/private/table/Cell.mjs.map +1 -1
  322. package/dist/private/table/Column.cjs +1 -0
  323. package/dist/private/table/Column.cjs.map +1 -1
  324. package/dist/private/table/Column.js +1 -0
  325. package/dist/private/table/Column.js.map +1 -1
  326. package/dist/private/table/Column.mjs +1 -0
  327. package/dist/private/table/Column.mjs.map +1 -1
  328. package/dist/private/table/Row.cjs +2 -1
  329. package/dist/private/table/Row.cjs.map +1 -1
  330. package/dist/private/table/Row.js +2 -1
  331. package/dist/private/table/Row.js.map +1 -1
  332. package/dist/private/table/Row.mjs +2 -1
  333. package/dist/private/table/Row.mjs.map +1 -1
  334. package/dist/private/table/TableBody.cjs +4 -2
  335. package/dist/private/table/TableBody.cjs.map +1 -1
  336. package/dist/private/table/TableBody.js +4 -2
  337. package/dist/private/table/TableBody.js.map +1 -1
  338. package/dist/private/table/TableBody.mjs +4 -2
  339. package/dist/private/table/TableBody.mjs.map +1 -1
  340. package/dist/private/table/TableCollection.cjs +1 -1
  341. package/dist/private/table/TableCollection.cjs.map +1 -1
  342. package/dist/private/table/TableCollection.js +1 -1
  343. package/dist/private/table/TableCollection.js.map +1 -1
  344. package/dist/private/table/TableCollection.mjs +1 -1
  345. package/dist/private/table/TableCollection.mjs.map +1 -1
  346. package/dist/private/table/TableColumnLayout.cjs +4 -1
  347. package/dist/private/table/TableColumnLayout.cjs.map +1 -1
  348. package/dist/private/table/TableColumnLayout.js +4 -1
  349. package/dist/private/table/TableColumnLayout.js.map +1 -1
  350. package/dist/private/table/TableColumnLayout.mjs +4 -1
  351. package/dist/private/table/TableColumnLayout.mjs.map +1 -1
  352. package/dist/private/table/TableHeader.cjs +4 -2
  353. package/dist/private/table/TableHeader.cjs.map +1 -1
  354. package/dist/private/table/TableHeader.js +4 -2
  355. package/dist/private/table/TableHeader.js.map +1 -1
  356. package/dist/private/table/TableHeader.mjs +4 -2
  357. package/dist/private/table/TableHeader.mjs.map +1 -1
  358. package/dist/private/table/TableUtils.cjs +1 -1
  359. package/dist/private/table/TableUtils.cjs.map +1 -1
  360. package/dist/private/table/TableUtils.js +1 -1
  361. package/dist/private/table/TableUtils.js.map +1 -1
  362. package/dist/private/table/TableUtils.mjs +1 -1
  363. package/dist/private/table/TableUtils.mjs.map +1 -1
  364. package/dist/private/table/useTableColumnResizeState.cjs.map +1 -1
  365. package/dist/private/table/useTableColumnResizeState.js.map +1 -1
  366. package/dist/private/table/useTableColumnResizeState.mjs.map +1 -1
  367. package/dist/private/table/useTableState.cjs +2 -1
  368. package/dist/private/table/useTableState.cjs.map +1 -1
  369. package/dist/private/table/useTableState.js +2 -1
  370. package/dist/private/table/useTableState.js.map +1 -1
  371. package/dist/private/table/useTableState.mjs +2 -1
  372. package/dist/private/table/useTableState.mjs.map +1 -1
  373. package/dist/private/table/useTreeGridState.cjs +2 -1
  374. package/dist/private/table/useTreeGridState.cjs.map +1 -1
  375. package/dist/private/table/useTreeGridState.js +2 -1
  376. package/dist/private/table/useTreeGridState.js.map +1 -1
  377. package/dist/private/table/useTreeGridState.mjs +2 -1
  378. package/dist/private/table/useTreeGridState.mjs.map +1 -1
  379. package/dist/private/tabs/useTabListState.cjs.map +1 -1
  380. package/dist/private/tabs/useTabListState.js.map +1 -1
  381. package/dist/private/tabs/useTabListState.mjs.map +1 -1
  382. package/dist/private/toast/useToastState.cjs.map +1 -1
  383. package/dist/private/toast/useToastState.js.map +1 -1
  384. package/dist/private/toast/useToastState.mjs.map +1 -1
  385. package/dist/private/toggle/useToggleGroupState.cjs.map +1 -1
  386. package/dist/private/toggle/useToggleGroupState.js.map +1 -1
  387. package/dist/private/toggle/useToggleGroupState.mjs.map +1 -1
  388. package/dist/private/toggle/useToggleState.cjs.map +1 -1
  389. package/dist/private/toggle/useToggleState.js.map +1 -1
  390. package/dist/private/toggle/useToggleState.mjs.map +1 -1
  391. package/dist/private/tooltip/useTooltipTriggerState.cjs.map +1 -1
  392. package/dist/private/tooltip/useTooltipTriggerState.js.map +1 -1
  393. package/dist/private/tooltip/useTooltipTriggerState.mjs.map +1 -1
  394. package/dist/private/tree/TreeCollection.cjs.map +1 -1
  395. package/dist/private/tree/TreeCollection.js.map +1 -1
  396. package/dist/private/tree/TreeCollection.mjs.map +1 -1
  397. package/dist/private/tree/useTreeState.cjs.map +1 -1
  398. package/dist/private/tree/useTreeState.js.map +1 -1
  399. package/dist/private/tree/useTreeState.mjs.map +1 -1
  400. package/dist/private/utils/number.cjs +2 -1
  401. package/dist/private/utils/number.cjs.map +1 -1
  402. package/dist/private/utils/number.js +2 -1
  403. package/dist/private/utils/number.js.map +1 -1
  404. package/dist/private/utils/number.mjs +2 -1
  405. package/dist/private/utils/number.mjs.map +1 -1
  406. package/dist/private/utils/useControlledState.cjs.map +1 -1
  407. package/dist/private/utils/useControlledState.js.map +1 -1
  408. package/dist/private/utils/useControlledState.mjs.map +1 -1
  409. package/dist/private/virtualizer/Layout.cjs.map +1 -1
  410. package/dist/private/virtualizer/Layout.js.map +1 -1
  411. package/dist/private/virtualizer/Layout.mjs.map +1 -1
  412. package/dist/private/virtualizer/LayoutInfo.cjs +4 -2
  413. package/dist/private/virtualizer/LayoutInfo.cjs.map +1 -1
  414. package/dist/private/virtualizer/LayoutInfo.js +4 -2
  415. package/dist/private/virtualizer/LayoutInfo.js.map +1 -1
  416. package/dist/private/virtualizer/LayoutInfo.mjs +4 -2
  417. package/dist/private/virtualizer/LayoutInfo.mjs.map +1 -1
  418. package/dist/private/virtualizer/Rect.cjs +4 -0
  419. package/dist/private/virtualizer/Rect.cjs.map +1 -1
  420. package/dist/private/virtualizer/Rect.js +4 -0
  421. package/dist/private/virtualizer/Rect.js.map +1 -1
  422. package/dist/private/virtualizer/Rect.mjs +4 -0
  423. package/dist/private/virtualizer/Rect.mjs.map +1 -1
  424. package/dist/private/virtualizer/ReusableView.cjs.map +1 -1
  425. package/dist/private/virtualizer/ReusableView.js.map +1 -1
  426. package/dist/private/virtualizer/ReusableView.mjs.map +1 -1
  427. package/dist/private/virtualizer/Size.cjs.map +1 -1
  428. package/dist/private/virtualizer/Size.js.map +1 -1
  429. package/dist/private/virtualizer/Size.mjs.map +1 -1
  430. package/dist/private/virtualizer/Virtualizer.cjs +4 -4
  431. package/dist/private/virtualizer/Virtualizer.cjs.map +1 -1
  432. package/dist/private/virtualizer/Virtualizer.js +4 -4
  433. package/dist/private/virtualizer/Virtualizer.js.map +1 -1
  434. package/dist/private/virtualizer/Virtualizer.mjs +4 -4
  435. package/dist/private/virtualizer/Virtualizer.mjs.map +1 -1
  436. package/dist/private/virtualizer/useVirtualizerState.cjs.map +1 -1
  437. package/dist/private/virtualizer/useVirtualizerState.js.map +1 -1
  438. package/dist/private/virtualizer/useVirtualizerState.mjs.map +1 -1
  439. package/dist/types/exports/useCalendarState.d.ts +1 -1
  440. package/dist/types/src/autocomplete/useAutocompleteState.d.ts +4 -1
  441. package/dist/types/src/calendar/types.d.ts +50 -14
  442. package/dist/types/src/calendar/useCalendarState.d.ts +20 -6
  443. package/dist/types/src/calendar/useRangeCalendarState.d.ts +14 -5
  444. package/dist/types/src/calendar/utils.d.ts +1 -0
  445. package/dist/types/src/checkbox/useCheckboxGroupState.d.ts +1 -0
  446. package/dist/types/src/collections/useCollection.d.ts +1 -1
  447. package/dist/types/src/color/useColorAreaState.d.ts +21 -8
  448. package/dist/types/src/color/useColorFieldState.d.ts +2 -3
  449. package/dist/types/src/color/useColorSliderState.d.ts +4 -1
  450. package/dist/types/src/color/useColorWheelState.d.ts +5 -1
  451. package/dist/types/src/combobox/useComboBoxState.d.ts +19 -6
  452. package/dist/types/src/data/useAsyncList.d.ts +2 -2
  453. package/dist/types/src/data/useListData.d.ts +13 -1
  454. package/dist/types/src/data/useTreeData.d.ts +11 -0
  455. package/dist/types/src/datepicker/IncompleteDate.d.ts +11 -5
  456. package/dist/types/src/datepicker/types.d.ts +37 -11
  457. package/dist/types/src/datepicker/useDateFieldState.d.ts +13 -4
  458. package/dist/types/src/datepicker/useDatePickerState.d.ts +10 -4
  459. package/dist/types/src/datepicker/useDateRangePickerState.d.ts +12 -3
  460. package/dist/types/src/dnd/useDraggableCollectionState.d.ts +4 -1
  461. package/dist/types/src/form/useFormValidationState.d.ts +4 -1
  462. package/dist/types/src/grid/GridCollection.d.ts +2 -1
  463. package/dist/types/src/grid/useGridState.d.ts +7 -3
  464. package/dist/types/src/layout/GridLayout.d.ts +18 -2
  465. package/dist/types/src/layout/ListLayout.d.ts +34 -12
  466. package/dist/types/src/layout/TableLayout.d.ts +11 -4
  467. package/dist/types/src/layout/WaterfallLayout.d.ts +9 -2
  468. package/dist/types/src/list/useListState.d.ts +2 -2
  469. package/dist/types/src/menu/useMenuTriggerState.d.ts +3 -1
  470. package/dist/types/src/menu/useSubmenuTriggerState.d.ts +2 -2
  471. package/dist/types/src/numberfield/useNumberFieldState.d.ts +15 -11
  472. package/dist/types/src/radio/useRadioGroupState.d.ts +4 -1
  473. package/dist/types/src/select/useSelectState.d.ts +13 -2
  474. package/dist/types/src/selection/types.d.ts +4 -1
  475. package/dist/types/src/selection/useMultipleSelectionState.d.ts +2 -0
  476. package/dist/types/src/slider/useSliderState.d.ts +22 -2
  477. package/dist/types/src/table/Column.d.ts +4 -1
  478. package/dist/types/src/table/Row.d.ts +5 -3
  479. package/dist/types/src/table/TableBody.d.ts +3 -2
  480. package/dist/types/src/table/TableCollection.d.ts +4 -1
  481. package/dist/types/src/table/TableColumnLayout.d.ts +4 -1
  482. package/dist/types/src/table/TableHeader.d.ts +7 -3
  483. package/dist/types/src/table/TableUtils.d.ts +19 -16
  484. package/dist/types/src/table/useTableColumnResizeState.d.ts +5 -3
  485. package/dist/types/src/table/useTableState.d.ts +15 -6
  486. package/dist/types/src/table/useTreeGridState.d.ts +3 -2
  487. package/dist/types/src/toggle/useToggleGroupState.d.ts +1 -0
  488. package/dist/types/src/toggle/useToggleState.d.ts +2 -1
  489. package/dist/types/src/tooltip/useTooltipTriggerState.d.ts +8 -2
  490. package/dist/types/src/tree/useTreeState.d.ts +1 -1
  491. package/dist/types/src/utils/number.d.ts +2 -1
  492. package/dist/types/src/virtualizer/Layout.d.ts +5 -2
  493. package/dist/types/src/virtualizer/LayoutInfo.d.ts +10 -3
  494. package/dist/types/src/virtualizer/Rect.d.ts +4 -0
  495. package/dist/types/src/virtualizer/Virtualizer.d.ts +5 -4
  496. package/package.json +8 -7
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAuDD,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,8BAAG,EAAE,KAAK;IAC3B,aAAa,IAAI,CAAA,GAAA,8BAAG,EAAE,UAAU;IAChC,qBAAqB;IACrB,UAAU,IAAI,CAAA,GAAA,8BAAG,EAAE,IAAI;IACvB,UAAU;IACV,YAAY;IACZ,wBAAwB;IACxB,cAAc;AAChB;AAQO,MAAM,kDAAuE,CAAA,GAAA,gCAAK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AsB;aAG7B,OAAO,IAAI,CAAA,GAAA,8BAAG,EACZ,OAAO,YAAY,KAAK,WACpB,WAAW,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACvE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC9E,WAAW,IAAI,CAAC,CAAC,EACjB,IAAI,CAAC,sBAAsB,EAC3B,WAAW,IAAI,CAAC,MAAM;QAI1B,OAAO,IAAI,CAAA,GAAA,oCAAS,EAAE,iBAAiB,OAAO,GAAG,GAAG,MAAM,OAAO,YAAY,EAAE;IACjF;;QA7SK,qBACK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACvB,cAAoB,IAAI,CAAA,GAAA,8BAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAwS3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n * @default false\n */\n preserveAspectRatio?: boolean,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum allowed horizontal space between items.\n * @default Infinity\n */\n maxHorizontalSpace?: number,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The fixed height of a loader element in px. This loader is specifically for\n * \"load more\" elements rendered when loading more rows at the root level or inside nested row/sections.\n * @default 48\n */\n loaderHeight?: number\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.maxColumns !== oldOptions.maxColumns\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio\n || (!(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize))\n || (!(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize))\n || (!(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || DEFAULT_OPTIONS.minSpace))\n || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace\n || newOptions.loaderHeight !== oldOptions.loaderHeight;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - (minSpace.width * Math.max(0, numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width));\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(Math.max(maxHorizontalSpace, minSpace.width), Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1)));\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor((virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2);\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content = oldLayoutInfo && oldLayoutInfo.content.key === key ? oldLayoutInfo.content : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.layoutOptionsChanged || invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize || (oldLayoutInfo.content !== content);\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (layoutInfo.rect.intersects(rect) || this.virtualizer!.isPersistedKey(layoutInfo.key) || layoutInfo.type === 'loader') {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(x, Math.max(0, y - this.gap.height), 1, Math.max(1, this.gap.height * 2));\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.cjs.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAsED,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,8BAAG,EAAE,KAA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AAC,aAAa,CAAC,OAAO,GAAG;QAC9C,IAAI;QACJ,IAAI,IAAI,CAAC,UAAU,KAAK,GACtB,kEAAkE;QAClE,OAAO,IAAI,CAAA,GAAA,8BAAG,EACZ,WAAW,IAAI,CAAC,CAAC,EACjB,OAAO,YAAY,KAAK,WACpB,WAAW,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACxE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC/E,WAAW,IAAI,CAAC,KAAK,EACrB,IAAI,CAAC,sBAAsB;aAG7B,OAAO,IAAI,CAAA,GAAA,8BAAG,EACZ,OAAO,YAAY,KAAK,WACpB,WAAW,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACvE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC9E,WAAW,IAAI,CAAC,CAAC,EACjB,IAAI,CAAC,sBAAsB,EAC3B,WAAW,IAAI,CAAC,MAAM;QAI1B,OAAO,IAAI,CAAA,GAAA,oCAAS,EAAE,iBAAiB,OAAO,GAAG,GAAG,MAAM,OAAO,YAAY,EAAE;IACjF;;QA5VK,qBAIK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACrB,YAA2B,YAC7B,cAAoB,IAAI,CAAA,GAAA,8BAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAmV3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n *\n * @default 200 x 200\n */\n minItemSize?: Size;\n /**\n * The maximum item size.\n *\n * @default Infinity\n */\n maxItemSize?: Size;\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n *\n * @default false\n */\n preserveAspectRatio?: boolean;\n /**\n * The minimum space required between items.\n *\n * @default 18 x 18\n */\n minSpace?: Size;\n /**\n * The maximum allowed horizontal space between items.\n *\n * @default Infinity\n */\n maxHorizontalSpace?: number;\n /**\n * The maximum number of columns.\n *\n * @default Infinity\n */\n maxColumns?: number;\n /**\n * The thickness of the drop indicator.\n *\n * @default 2\n */\n dropIndicatorThickness?: number;\n /**\n * The fixed height of a loader element in px. This loader is specifically for \"load more\"\n * elements rendered when loading more rows at the root level or inside nested row/sections.\n *\n * @default 48\n */\n loaderHeight?: number;\n /**\n * The layout direction. When `'rtl'`, drop target positions (`'before'`/`'after'`)\n * are computed correctly for right-to-left locales in multi-column grids.\n *\n * @default 'ltr'\n */\n direction?: 'ltr' | 'rtl';\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions>\n extends Layout<Node<T>, O>\n implements DropTargetDelegate\n{\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n protected direction: 'ltr' | 'rtl' = 'ltr';\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return (\n newOptions.maxColumns !== oldOptions.maxColumns ||\n newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness ||\n newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio ||\n !(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(\n oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize\n ) ||\n !(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(\n oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize\n ) ||\n !(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(\n oldOptions.minSpace || DEFAULT_OPTIONS.minSpace\n ) ||\n newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace ||\n newOptions.loaderHeight !== oldOptions.loaderHeight ||\n newOptions.direction !== oldOptions.direction\n );\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight,\n direction = 'ltr' as const\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n this.direction = direction;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - minSpace.width * Math.max(0, numColumns);\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = (itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width);\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(\n Math.max(maxHorizontalSpace, minSpace.width),\n Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1))\n );\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor(\n (virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2\n );\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content =\n oldLayoutInfo && oldLayoutInfo.content.key === key\n ? oldLayoutInfo.content\n : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize =\n invalidationContext.layoutOptionsChanged ||\n invalidationContext.sizeChanged ||\n oldLayoutInfo.estimatedSize ||\n oldLayoutInfo.content !== content;\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (\n layoutInfo.rect.intersects(rect) ||\n this.virtualizer!.isPersistedKey(layoutInfo.key) ||\n layoutInfo.type === 'loader'\n ) {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(\n x: number,\n y: number,\n isValidDropTarget: (target: DropTarget) => boolean\n ): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // In RTL mode the virtualizer positions items using CSS `right` with the\n // layout rect's x value as the right-offset, but pointer coordinates are\n // in visual (left-origin) space. Flip x so it matches the layout coords.\n if (this.direction === 'rtl' && this.numColumns > 1) {\n x = this.contentSize.width - x;\n }\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(\n x,\n Math.max(0, y - this.gap.height),\n 1,\n Math.max(1, this.gap.height * 2)\n );\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.cjs.map"}
@@ -29,11 +29,12 @@ const $5600a6980c0f940d$var$DEFAULT_OPTIONS = {
29
29
  };
30
30
  class $5600a6980c0f940d$export$7d2b12578154a735 extends (0, $bcf18cb0a16f75f6$export$c84671f46d6a1ca) {
31
31
  shouldInvalidateLayoutOptions(newOptions, oldOptions) {
32
- return newOptions.maxColumns !== oldOptions.maxColumns || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio || !(newOptions.minItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize) || !(newOptions.maxItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize) || !(newOptions.minSpace || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace) || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace || newOptions.loaderHeight !== oldOptions.loaderHeight;
32
+ return newOptions.maxColumns !== oldOptions.maxColumns || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio || !(newOptions.minItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize) || !(newOptions.maxItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize) || !(newOptions.minSpace || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace) || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace || newOptions.loaderHeight !== oldOptions.loaderHeight || newOptions.direction !== oldOptions.direction;
33
33
  }
34
34
  update(invalidationContext) {
35
- let { minItemSize: minItemSize = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize, maxItemSize: maxItemSize = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize, preserveAspectRatio: preserveAspectRatio = $5600a6980c0f940d$var$DEFAULT_OPTIONS.preserveAspectRatio, minSpace: minSpace = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace, maxHorizontalSpace: maxHorizontalSpace = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxSpace, maxColumns: maxColumns = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxColumns, dropIndicatorThickness: dropIndicatorThickness = $5600a6980c0f940d$var$DEFAULT_OPTIONS.dropIndicatorThickness, loaderHeight: loaderHeight = $5600a6980c0f940d$var$DEFAULT_OPTIONS.loaderHeight } = invalidationContext.layoutOptions || {};
35
+ let { minItemSize: minItemSize = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minItemSize, maxItemSize: maxItemSize = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxItemSize, preserveAspectRatio: preserveAspectRatio = $5600a6980c0f940d$var$DEFAULT_OPTIONS.preserveAspectRatio, minSpace: minSpace = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace, maxHorizontalSpace: maxHorizontalSpace = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxSpace, maxColumns: maxColumns = $5600a6980c0f940d$var$DEFAULT_OPTIONS.maxColumns, dropIndicatorThickness: dropIndicatorThickness = $5600a6980c0f940d$var$DEFAULT_OPTIONS.dropIndicatorThickness, loaderHeight: loaderHeight = $5600a6980c0f940d$var$DEFAULT_OPTIONS.loaderHeight, direction: direction = 'ltr' } = invalidationContext.layoutOptions || {};
36
36
  this.dropIndicatorThickness = dropIndicatorThickness;
37
+ this.direction = direction;
37
38
  let virtualizerWidth = this.virtualizer.size.width;
38
39
  // The max item width is always the entire viewport.
39
40
  // If the max item height is infinity, scale in proportion to the max width.
@@ -157,6 +158,10 @@ class $5600a6980c0f940d$export$7d2b12578154a735 extends (0, $bcf18cb0a16f75f6$ex
157
158
  };
158
159
  x += this.virtualizer.visibleRect.x;
159
160
  y += this.virtualizer.visibleRect.y;
161
+ // In RTL mode the virtualizer positions items using CSS `right` with the
162
+ // layout rect's x value as the right-offset, but pointer coordinates are
163
+ // in visual (left-origin) space. Flip x so it matches the layout coords.
164
+ if (this.direction === 'rtl' && this.numColumns > 1) x = this.contentSize.width - x;
160
165
  // Find the closest item within on either side of the point using the gap width.
161
166
  let key = null;
162
167
  if (this.numColumns === 1) {
@@ -230,7 +235,7 @@ class $5600a6980c0f940d$export$7d2b12578154a735 extends (0, $bcf18cb0a16f75f6$ex
230
235
  return new (0, $dcdbc700dd92e06f$export$7e0eeb9da702a085)('dropIndicator', target.key + ':' + target.dropPosition, rect);
231
236
  }
232
237
  constructor(...args){
233
- super(...args), this.gap = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace, this.dropIndicatorThickness = 2, this.numColumns = 0, this.contentSize = new (0, $266cbd2785be3a2c$export$cb6da89c6af1a8ec)(), this.layoutInfos = new Map(), this.margin = 0;
238
+ super(...args), this.gap = $5600a6980c0f940d$var$DEFAULT_OPTIONS.minSpace, this.dropIndicatorThickness = 2, this.numColumns = 0, this.direction = 'ltr', this.contentSize = new (0, $266cbd2785be3a2c$export$cb6da89c6af1a8ec)(), this.layoutInfos = new Map(), this.margin = 0;
234
239
  }
235
240
  }
236
241
 
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAuDD,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,KAAK;IAC3B,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,UAAU;IAChC,qBAAqB;IACrB,UAAU,IAAI,CAAA,GAAA,yCAAG,EAAE,IAAI;IACvB,UAAU;IACV,YAAY;IACZ,wBAAwB;IACxB,cAAc;AAChB;AAQO,MAAM,kDAAuE,CAAA,GAAA,wCAAK;IAQvF,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,WAAW,UAAU,KAAK,WAAW,UAAU,IACjD,WAAW,sBAAsB,KAAK,WAAW,sBAAsB,IACvE,WAAW,mBAAmB,KAAK,WAAW,mBAAmB,IAChE,CAAC,AAAC,CAAA,WAAW,WAAW,IAAI,sCAAgB,WAAW,AAAD,EAAG,MAAM,CAAC,WAAW,WAAW,IAAI,sCAAgB,WAAW,KACrH,CAAC,AAAC,CAAA,WAAW,WAAW,IAAI,sCAAgB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G,GAC9E,WAAW,IAAI,CAAC,CAAC,EACjB,IAAI,CAAC,sBAAsB,EAC3B,WAAW,IAAI,CAAC,MAAM;QAI1B,OAAO,IAAI,CAAA,GAAA,yCAAS,EAAE,iBAAiB,OAAO,GAAG,GAAG,MAAM,OAAO,YAAY,EAAE;IACjF;;QA7SK,qBACK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACvB,cAAoB,IAAI,CAAA,GAAA,yCAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAwS3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n * @default false\n */\n preserveAspectRatio?: boolean,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum allowed horizontal space between items.\n * @default Infinity\n */\n maxHorizontalSpace?: number,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The fixed height of a loader element in px. This loader is specifically for\n * \"load more\" elements rendered when loading more rows at the root level or inside nested row/sections.\n * @default 48\n */\n loaderHeight?: number\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.maxColumns !== oldOptions.maxColumns\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio\n || (!(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize))\n || (!(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize))\n || (!(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || DEFAULT_OPTIONS.minSpace))\n || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace\n || newOptions.loaderHeight !== oldOptions.loaderHeight;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - (minSpace.width * Math.max(0, numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width));\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(Math.max(maxHorizontalSpace, minSpace.width), Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1)));\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor((virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2);\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content = oldLayoutInfo && oldLayoutInfo.content.key === key ? oldLayoutInfo.content : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.layoutOptionsChanged || invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize || (oldLayoutInfo.content !== content);\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (layoutInfo.rect.intersects(rect) || this.virtualizer!.isPersistedKey(layoutInfo.key) || layoutInfo.type === 'loader') {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(x, Math.max(0, y - this.gap.height), 1, Math.max(1, this.gap.height * 2));\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.js.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAsED,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,KAAK;IAC3B,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,UAAU;IAChC,qBAAqB;IACrB,UAAU,IAAI,CAAA,GAAA,yCAAG,EAAE,IAAI;IACvB,UAAU;IACV,YAAY;IACZ,wBAAwB;IACxB,cAAc;AAChB;AAQO,MAAM,kDACH,CAAA,GAAA,wCAAK;IAWb,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OACE,WAAW,UAAU,KAAK,WAAW,U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,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACxE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC/E,WAAW,IAAI,CAAC,KAAK,EACrB,IAAI,CAAC,sBAAsB;aAG7B,OAAO,IAAI,CAAA,GAAA,yCAAG,EACZ,OAAO,YAAY,KAAK,WACpB,WAAW,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACvE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC9E,WAAW,IAAI,CAAC,CAAC,EACjB,IAAI,CAAC,sBAAsB,EAC3B,WAAW,IAAI,CAAC,MAAM;QAI1B,OAAO,IAAI,CAAA,GAAA,yCAAS,EAAE,iBAAiB,OAAO,GAAG,GAAG,MAAM,OAAO,YAAY,EAAE;IACjF;;QA5VK,qBAIK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACrB,YAA2B,YAC7B,cAAoB,IAAI,CAAA,GAAA,yCAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAmV3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n *\n * @default 200 x 200\n */\n minItemSize?: Size;\n /**\n * The maximum item size.\n *\n * @default Infinity\n */\n maxItemSize?: Size;\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n *\n * @default false\n */\n preserveAspectRatio?: boolean;\n /**\n * The minimum space required between items.\n *\n * @default 18 x 18\n */\n minSpace?: Size;\n /**\n * The maximum allowed horizontal space between items.\n *\n * @default Infinity\n */\n maxHorizontalSpace?: number;\n /**\n * The maximum number of columns.\n *\n * @default Infinity\n */\n maxColumns?: number;\n /**\n * The thickness of the drop indicator.\n *\n * @default 2\n */\n dropIndicatorThickness?: number;\n /**\n * The fixed height of a loader element in px. This loader is specifically for \"load more\"\n * elements rendered when loading more rows at the root level or inside nested row/sections.\n *\n * @default 48\n */\n loaderHeight?: number;\n /**\n * The layout direction. When `'rtl'`, drop target positions (`'before'`/`'after'`)\n * are computed correctly for right-to-left locales in multi-column grids.\n *\n * @default 'ltr'\n */\n direction?: 'ltr' | 'rtl';\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions>\n extends Layout<Node<T>, O>\n implements DropTargetDelegate\n{\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n protected direction: 'ltr' | 'rtl' = 'ltr';\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return (\n newOptions.maxColumns !== oldOptions.maxColumns ||\n newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness ||\n newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio ||\n !(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(\n oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize\n ) ||\n !(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(\n oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize\n ) ||\n !(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(\n oldOptions.minSpace || DEFAULT_OPTIONS.minSpace\n ) ||\n newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace ||\n newOptions.loaderHeight !== oldOptions.loaderHeight ||\n newOptions.direction !== oldOptions.direction\n );\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight,\n direction = 'ltr' as const\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n this.direction = direction;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - minSpace.width * Math.max(0, numColumns);\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = (itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width);\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(\n Math.max(maxHorizontalSpace, minSpace.width),\n Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1))\n );\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor(\n (virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2\n );\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content =\n oldLayoutInfo && oldLayoutInfo.content.key === key\n ? oldLayoutInfo.content\n : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize =\n invalidationContext.layoutOptionsChanged ||\n invalidationContext.sizeChanged ||\n oldLayoutInfo.estimatedSize ||\n oldLayoutInfo.content !== content;\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (\n layoutInfo.rect.intersects(rect) ||\n this.virtualizer!.isPersistedKey(layoutInfo.key) ||\n layoutInfo.type === 'loader'\n ) {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(\n x: number,\n y: number,\n isValidDropTarget: (target: DropTarget) => boolean\n ): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // In RTL mode the virtualizer positions items using CSS `right` with the\n // layout rect's x value as the right-offset, but pointer coordinates are\n // in visual (left-origin) space. Flip x so it matches the layout coords.\n if (this.direction === 'rtl' && this.numColumns > 1) {\n x = this.contentSize.width - x;\n }\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(\n x,\n Math.max(0, y - this.gap.height),\n 1,\n Math.max(1, this.gap.height * 2)\n );\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.js.map"}
@@ -29,11 +29,12 @@ const $fc34f5dff94ff74a$var$DEFAULT_OPTIONS = {
29
29
  };
30
30
  class $fc34f5dff94ff74a$export$7d2b12578154a735 extends (0, $85410e0c3cc54f1d$export$c84671f46d6a1ca) {
31
31
  shouldInvalidateLayoutOptions(newOptions, oldOptions) {
32
- return newOptions.maxColumns !== oldOptions.maxColumns || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio || !(newOptions.minItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize) || !(newOptions.maxItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize) || !(newOptions.minSpace || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace) || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace || newOptions.loaderHeight !== oldOptions.loaderHeight;
32
+ return newOptions.maxColumns !== oldOptions.maxColumns || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio || !(newOptions.minItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize) || !(newOptions.maxItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize) || !(newOptions.minSpace || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace) || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace || newOptions.loaderHeight !== oldOptions.loaderHeight || newOptions.direction !== oldOptions.direction;
33
33
  }
34
34
  update(invalidationContext) {
35
- let { minItemSize: minItemSize = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize, maxItemSize: maxItemSize = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize, preserveAspectRatio: preserveAspectRatio = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.preserveAspectRatio, minSpace: minSpace = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace, maxHorizontalSpace: maxHorizontalSpace = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxSpace, maxColumns: maxColumns = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxColumns, dropIndicatorThickness: dropIndicatorThickness = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.dropIndicatorThickness, loaderHeight: loaderHeight = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.loaderHeight } = invalidationContext.layoutOptions || {};
35
+ let { minItemSize: minItemSize = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minItemSize, maxItemSize: maxItemSize = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxItemSize, preserveAspectRatio: preserveAspectRatio = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.preserveAspectRatio, minSpace: minSpace = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace, maxHorizontalSpace: maxHorizontalSpace = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxSpace, maxColumns: maxColumns = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.maxColumns, dropIndicatorThickness: dropIndicatorThickness = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.dropIndicatorThickness, loaderHeight: loaderHeight = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.loaderHeight, direction: direction = 'ltr' } = invalidationContext.layoutOptions || {};
36
36
  this.dropIndicatorThickness = dropIndicatorThickness;
37
+ this.direction = direction;
37
38
  let virtualizerWidth = this.virtualizer.size.width;
38
39
  // The max item width is always the entire viewport.
39
40
  // If the max item height is infinity, scale in proportion to the max width.
@@ -157,6 +158,10 @@ class $fc34f5dff94ff74a$export$7d2b12578154a735 extends (0, $85410e0c3cc54f1d$ex
157
158
  };
158
159
  x += this.virtualizer.visibleRect.x;
159
160
  y += this.virtualizer.visibleRect.y;
161
+ // In RTL mode the virtualizer positions items using CSS `right` with the
162
+ // layout rect's x value as the right-offset, but pointer coordinates are
163
+ // in visual (left-origin) space. Flip x so it matches the layout coords.
164
+ if (this.direction === 'rtl' && this.numColumns > 1) x = this.contentSize.width - x;
160
165
  // Find the closest item within on either side of the point using the gap width.
161
166
  let key = null;
162
167
  if (this.numColumns === 1) {
@@ -230,7 +235,7 @@ class $fc34f5dff94ff74a$export$7d2b12578154a735 extends (0, $85410e0c3cc54f1d$ex
230
235
  return new (0, $eb6255cbf080eb7d$export$7e0eeb9da702a085)('dropIndicator', target.key + ':' + target.dropPosition, rect);
231
236
  }
232
237
  constructor(...args){
233
- super(...args), this.gap = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace, this.dropIndicatorThickness = 2, this.numColumns = 0, this.contentSize = new (0, $cc8e610d5d6e3fe4$export$cb6da89c6af1a8ec)(), this.layoutInfos = new Map(), this.margin = 0;
238
+ super(...args), this.gap = $fc34f5dff94ff74a$var$DEFAULT_OPTIONS.minSpace, this.dropIndicatorThickness = 2, this.numColumns = 0, this.direction = 'ltr', this.contentSize = new (0, $cc8e610d5d6e3fe4$export$cb6da89c6af1a8ec)(), this.layoutInfos = new Map(), this.margin = 0;
234
239
  }
235
240
  }
236
241
 
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAuDD,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,KAAK;IAC3B,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,UAAU;IAChC,qBAAqB;IACrB,UAAU,IAAI,CAAA,GAAA,yCAAG,EAAE,IAAI;IACvB,UAAU;IACV,YAAY;IACZ,wBAAwB;IACxB,cAAc;AAChB;AAQO,MAAM,kDAAuE,CAAA,GAAA,wCAAK;IAQvF,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OAAO,WAAW,UAAU,KAAK,WAAW,UAAU,IACjD,WAAW,sBAAsB,KAAK,WAAW,sBAAsB,IACvE,WAAW,mBAAmB,KAAK,WAAW,mBAAmB,IAChE,CAAC,AAAC,CAAA,WAAW,WAAW,IAAI,sCAAgB,WAAW,AAAD,EAAG,MAAM,CAAC,WAAW,WAAW,IAAI,sCAAgB,WAAW,KACrH,CAAC,AAAC,CAAA,WAAW,WAAW,IAAI,sCAAgB,WAAW,AAAD,EAAG,MAAM,CAAC,WAAW,WAAW,IAAI,sCAAgB,WAAW,KACrH,CAAC,AAAC,CAAA,WAAW,QAAQ,IAAI,sCAAgB,QAAQ,AAAD,EAAG,MAAM,CAAC,W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qBACK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACvB,cAAoB,IAAI,CAAA,GAAA,yCAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAwS3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n * @default false\n */\n preserveAspectRatio?: boolean,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum allowed horizontal space between items.\n * @default Infinity\n */\n maxHorizontalSpace?: number,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The fixed height of a loader element in px. This loader is specifically for\n * \"load more\" elements rendered when loading more rows at the root level or inside nested row/sections.\n * @default 48\n */\n loaderHeight?: number\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.maxColumns !== oldOptions.maxColumns\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio\n || (!(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize))\n || (!(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize))\n || (!(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(oldOptions.minSpace || DEFAULT_OPTIONS.minSpace))\n || newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace\n || newOptions.loaderHeight !== oldOptions.loaderHeight;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - (minSpace.width * Math.max(0, numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width));\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(Math.max(maxHorizontalSpace, minSpace.width), Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1)));\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor((virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2);\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content = oldLayoutInfo && oldLayoutInfo.content.key === key ? oldLayoutInfo.content : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.layoutOptionsChanged || invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize || (oldLayoutInfo.content !== content);\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (layoutInfo.rect.intersects(rect) || this.virtualizer!.isPersistedKey(layoutInfo.key) || layoutInfo.type === 'loader') {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(x, Math.max(0, y - this.gap.height), 1, Math.max(1, this.gap.height * 2));\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.mjs.map"}
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAsED,MAAM,wCAAkB;IACtB,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,KAAK;IAC3B,aAAa,IAAI,CAAA,GAAA,yCAAG,EAAE,UAAU;IAChC,qBAAqB;IACrB,UAAU,IAAI,CAAA,GAAA,yCAAG,EAAE,IAAI;IACvB,UAAU;IACV,YAAY;IACZ,wBAAwB;IACxB,cAAc;AAChB;AAQO,MAAM,kDACH,CAAA,GAAA,wCAAK;IAWb,8BAA8B,UAAa,EAAE,UAAa,EAAW;QACnE,OACE,WAAW,UAAU,KAAK,WAAW,UAAU,IAC/C,WAAW,sBAAsB,KAAK,WAAW,sBAAsB,IACvE,WAAW,mBAAmB,KAAK,WAAW,mBAAmB,IACjE,CAAC,AAAC,CAAA,WAAW,WAAW,IAAI,sCAAgB,WAAW,AAAD,EAAG,MAAM,CAC7D,WAAW,WAAW,IAAI,sCAAgB,WA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yCAAG,EACZ,OAAO,YAAY,KAAK,WACpB,WAAW,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,IACvE,WAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,IAAI,CAAC,sBAAsB,GAAG,GAC9E,WAAW,IAAI,CAAC,CAAC,EACjB,IAAI,CAAC,sBAAsB,EAC3B,WAAW,IAAI,CAAC,MAAM;QAI1B,OAAO,IAAI,CAAA,GAAA,yCAAS,EAAE,iBAAiB,OAAO,GAAG,GAAG,MAAM,OAAO,YAAY,EAAE;IACjF;;QA5VK,qBAIK,MAAY,sCAAgB,QAAQ,OACpC,yBAAyB,QACzB,aAAqB,QACrB,YAA2B,YAC7B,cAAoB,IAAI,CAAA,GAAA,yCAAG,UAC3B,cAAoC,IAAI,YACxC,SAAiB;;AAmV3B","sources":["packages/react-stately/src/layout/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {InvalidationContext} from '../virtualizer/types';\nimport {Layout} from '../virtualizer/Layout';\nimport {LayoutInfo} from '../virtualizer/LayoutInfo';\nimport {Rect} from '../virtualizer/Rect';\nimport {Size} from '../virtualizer/Size';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n *\n * @default 200 x 200\n */\n minItemSize?: Size;\n /**\n * The maximum item size.\n *\n * @default Infinity\n */\n maxItemSize?: Size;\n /**\n * Whether to preserve the aspect ratio of the `minItemSize`.\n * By default, grid rows may have variable heights. When `preserveAspectRatio`\n * is true, all rows will have equal heights.\n *\n * @default false\n */\n preserveAspectRatio?: boolean;\n /**\n * The minimum space required between items.\n *\n * @default 18 x 18\n */\n minSpace?: Size;\n /**\n * The maximum allowed horizontal space between items.\n *\n * @default Infinity\n */\n maxHorizontalSpace?: number;\n /**\n * The maximum number of columns.\n *\n * @default Infinity\n */\n maxColumns?: number;\n /**\n * The thickness of the drop indicator.\n *\n * @default 2\n */\n dropIndicatorThickness?: number;\n /**\n * The fixed height of a loader element in px. This loader is specifically for \"load more\"\n * elements rendered when loading more rows at the root level or inside nested row/sections.\n *\n * @default 48\n */\n loaderHeight?: number;\n /**\n * The layout direction. When `'rtl'`, drop target positions (`'before'`/`'after'`)\n * are computed correctly for right-to-left locales in multi-column grids.\n *\n * @default 'ltr'\n */\n direction?: 'ltr' | 'rtl';\n}\n\nconst DEFAULT_OPTIONS = {\n minItemSize: new Size(200, 200),\n maxItemSize: new Size(Infinity, Infinity),\n preserveAspectRatio: false,\n minSpace: new Size(18, 18),\n maxSpace: Infinity,\n maxColumns: Infinity,\n dropIndicatorThickness: 2,\n loaderHeight: 48\n};\n\n/**\n * GridLayout is a virtualizer Layout implementation\n * that arranges its items in a grid.\n * The items are sized between a minimum and maximum size\n * depending on the width of the container.\n */\nexport class GridLayout<T, O extends GridLayoutOptions = GridLayoutOptions>\n extends Layout<Node<T>, O>\n implements DropTargetDelegate\n{\n protected gap: Size = DEFAULT_OPTIONS.minSpace;\n protected dropIndicatorThickness = 2;\n protected numColumns: number = 0;\n protected direction: 'ltr' | 'rtl' = 'ltr';\n private contentSize: Size = new Size();\n private layoutInfos: Map<Key, LayoutInfo> = new Map();\n private margin: number = 0;\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return (\n newOptions.maxColumns !== oldOptions.maxColumns ||\n newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness ||\n newOptions.preserveAspectRatio !== oldOptions.preserveAspectRatio ||\n !(newOptions.minItemSize || DEFAULT_OPTIONS.minItemSize).equals(\n oldOptions.minItemSize || DEFAULT_OPTIONS.minItemSize\n ) ||\n !(newOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize).equals(\n oldOptions.maxItemSize || DEFAULT_OPTIONS.maxItemSize\n ) ||\n !(newOptions.minSpace || DEFAULT_OPTIONS.minSpace).equals(\n oldOptions.minSpace || DEFAULT_OPTIONS.minSpace\n ) ||\n newOptions.maxHorizontalSpace !== oldOptions.maxHorizontalSpace ||\n newOptions.loaderHeight !== oldOptions.loaderHeight ||\n newOptions.direction !== oldOptions.direction\n );\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let {\n minItemSize = DEFAULT_OPTIONS.minItemSize,\n maxItemSize = DEFAULT_OPTIONS.maxItemSize,\n preserveAspectRatio = DEFAULT_OPTIONS.preserveAspectRatio,\n minSpace = DEFAULT_OPTIONS.minSpace,\n maxHorizontalSpace = DEFAULT_OPTIONS.maxSpace,\n maxColumns = DEFAULT_OPTIONS.maxColumns,\n dropIndicatorThickness = DEFAULT_OPTIONS.dropIndicatorThickness,\n loaderHeight = DEFAULT_OPTIONS.loaderHeight,\n direction = 'ltr' as const\n } = invalidationContext.layoutOptions || {};\n this.dropIndicatorThickness = dropIndicatorThickness;\n this.direction = direction;\n\n let virtualizerWidth = this.virtualizer!.size.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(maxItemSize.width, virtualizerWidth);\n let maxItemHeight = Number.isFinite(maxItemSize.height)\n ? maxItemSize.height\n : Math.floor((minItemSize.height / minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(virtualizerWidth / (minItemSize.width + minSpace.width));\n let numColumns = Math.max(1, Math.min(maxColumns, columns));\n this.numColumns = numColumns;\n\n // Compute the available width (minus the space between items)\n let width = virtualizerWidth - minSpace.width * Math.max(0, numColumns);\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / numColumns);\n itemWidth = Math.max(minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = (itemWidth - minItemSize.width) / Math.max(1, maxItemWidth - minItemSize.width);\n let itemHeight = minItemSize.height + Math.floor((maxItemHeight - minItemSize.height) * t);\n itemHeight = Math.max(minItemSize.height, Math.min(maxItemHeight, itemHeight));\n\n // Compute the horizontal spacing, content height and horizontal margin\n let horizontalSpacing = Math.min(\n Math.max(maxHorizontalSpace, minSpace.width),\n Math.floor((virtualizerWidth - numColumns * itemWidth) / (numColumns + 1))\n );\n this.gap = new Size(horizontalSpacing, minSpace.height);\n this.margin = Math.floor(\n (virtualizerWidth - numColumns * itemWidth - horizontalSpacing * (numColumns + 1)) / 2\n );\n\n // If there is a skeleton loader within the last 2 items in the collection, increment the collection size\n // so that an additional row is added for the skeletons.\n let collection = this.virtualizer!.collection;\n let collectionSize = collection.size;\n let lastKey = collection.getLastKey();\n for (let i = 0; i < 2 && lastKey != null; i++) {\n let item = collection.getItem(lastKey);\n if (item?.type === 'skeleton') {\n collectionSize++;\n break;\n }\n lastKey = collection.getKeyBefore(lastKey);\n }\n\n let rows = Math.ceil(collectionSize / numColumns);\n let iterator = collection[Symbol.iterator]();\n let y = rows > 0 ? minSpace.height : 0;\n let newLayoutInfos = new Map();\n let skeleton: Node<T> | null = null;\n let skeletonCount = 0;\n for (let row = 0; row < rows; row++) {\n let maxHeight = 0;\n let rowLayoutInfos: LayoutInfo[] = [];\n for (let col = 0; col < numColumns; col++) {\n // Repeat skeleton until the end of the current row.\n let node = skeleton || iterator.next().value;\n if (!node) {\n break;\n }\n\n // We will add the loader after the skeletons so skip here\n if (node.type === 'loader') {\n continue;\n }\n\n if (node.type === 'skeleton') {\n skeleton = node;\n }\n\n let key = skeleton ? `${skeleton.key}-${skeletonCount++}` : node.key;\n let oldLayoutInfo = this.layoutInfos.get(key);\n let content = node;\n if (skeleton) {\n content =\n oldLayoutInfo && oldLayoutInfo.content.key === key\n ? oldLayoutInfo.content\n : {...skeleton, key};\n }\n let x = horizontalSpacing + col * (itemWidth + horizontalSpacing) + this.margin;\n let height = itemHeight;\n let estimatedSize = !preserveAspectRatio;\n if (oldLayoutInfo && estimatedSize) {\n height = oldLayoutInfo.rect.height;\n estimatedSize =\n invalidationContext.layoutOptionsChanged ||\n invalidationContext.sizeChanged ||\n oldLayoutInfo.estimatedSize ||\n oldLayoutInfo.content !== content;\n }\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n layoutInfo.content = content;\n newLayoutInfos.set(key, layoutInfo);\n rowLayoutInfos.push(layoutInfo);\n\n maxHeight = Math.max(maxHeight, layoutInfo.rect.height);\n }\n\n for (let layoutInfo of rowLayoutInfos) {\n layoutInfo.rect.height = maxHeight;\n }\n\n y += maxHeight + minSpace.height;\n\n // Keep adding skeleton rows until we fill the viewport\n if (skeleton && row === rows - 1 && y < this.virtualizer!.size.height) {\n rows++;\n }\n }\n\n // Always add the loader sentinel if present in the collection so we can make sure it is never virtualized out.\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n if (skeletonCount > 0 || !lastNode.props.isLoading) {\n loaderHeight = 0;\n }\n const loaderWidth = virtualizerWidth - horizontalSpacing * 2;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n let rect = new Rect(horizontalSpacing, y, loaderWidth, loaderHeight);\n let layoutInfo = new LayoutInfo('loader', lastNode.key, rect);\n newLayoutInfos.set(lastNode.key, layoutInfo);\n y = layoutInfo.rect.maxY;\n }\n\n this.layoutInfos = newLayoutInfos;\n this.contentSize = new Size(this.virtualizer!.size.width, y);\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n return this.layoutInfos.get(key) || null;\n }\n\n getContentSize(): Size {\n return this.contentSize;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let layoutInfos: LayoutInfo[] = [];\n for (let layoutInfo of this.layoutInfos.values()) {\n if (\n layoutInfo.rect.intersects(rect) ||\n this.virtualizer!.isPersistedKey(layoutInfo.key) ||\n layoutInfo.type === 'loader'\n ) {\n layoutInfos.push(layoutInfo);\n }\n }\n return layoutInfos;\n }\n\n updateItemSize(key: Key, size: Size): boolean {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getDropTargetFromPoint(\n x: number,\n y: number,\n isValidDropTarget: (target: DropTarget) => boolean\n ): DropTarget {\n if (this.layoutInfos.size === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // In RTL mode the virtualizer positions items using CSS `right` with the\n // layout rect's x value as the right-offset, but pointer coordinates are\n // in visual (left-origin) space. Flip x so it matches the layout coords.\n if (this.direction === 'rtl' && this.numColumns > 1) {\n x = this.contentSize.width - x;\n }\n\n // Find the closest item within on either side of the point using the gap width.\n let key: Key | null = null;\n if (this.numColumns === 1) {\n let searchRect = new Rect(\n x,\n Math.max(0, y - this.gap.height),\n 1,\n Math.max(1, this.gap.height * 2)\n );\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n } else {\n let searchRect = new Rect(Math.max(0, x - this.gap.width), y, this.gap.width * 2, 1);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let xDist = Math.abs(candidate.rect.x - x);\n let maxXDist = Math.abs(candidate.rect.maxX - x);\n let dist = Math.min(xDist, maxXDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.key;\n }\n }\n }\n\n let layoutInfo = key != null ? this.getLayoutInfo(key) : null;\n if (!layoutInfo) {\n return {type: 'root'};\n }\n\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key)!;\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before'\n ? layoutInfo.rect.y - this.gap.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.gap.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before'\n ? layoutInfo.rect.x - this.gap.width / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxX + this.gap.width / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.mjs.map"}
@@ -386,7 +386,7 @@ class $d474db7fa4a60716$export$cacbb3924155d68e extends (0, $4b8e6a761bc1571f$ex
386
386
  // Adjust the validRect so that only items above remain valid.
387
387
  this.validRect[heightProperty] = Math.min(this.validRect[heightProperty], layoutInfo.rect[offsetProperty] - this.validRect[offsetProperty]);
388
388
  // The requestedRect also needs to be adjusted to account for the height difference.
389
- this.requestedRect[heightProperty] += newLayoutInfo.rect[heightProperty] - layoutInfo.rect[heightProperty];
389
+ if (layoutNode.node?.type === 'item') this.requestedRect[heightProperty] += newLayoutInfo.rect[heightProperty] - layoutInfo.rect[heightProperty];
390
390
  // Invalidate layout for this layout node and all parents
391
391
  this.updateLayoutNode(key, layoutInfo, newLayoutInfo);
392
392
  let node = layoutInfo.parentKey != null ? collection.getItem(layoutInfo.parentKey) : null;