@1771technologies/lytenyte-pro 1.0.0-beta.36 → 1.0.0-beta.37

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 (386) hide show
  1. package/dist/+types.d.ts +4469 -4219
  2. package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +38 -38
  3. package/dist/cell-selection/are-rects-equal.js +4 -6
  4. package/dist/cell-selection/bound-selection-rect.js +14 -14
  5. package/dist/cell-selection/cell-selection-containers.js +78 -108
  6. package/dist/cell-selection/cell-selection-driver.js +262 -250
  7. package/dist/cell-selection/cell-style-row.d.ts +6 -12
  8. package/dist/cell-selection/cell-style-row.js +79 -82
  9. package/dist/cell-selection/deselect-rect-range.js +40 -41
  10. package/dist/cell-selection/expand-cell-selection-down.d.ts +2 -5
  11. package/dist/cell-selection/expand-cell-selection-down.js +33 -29
  12. package/dist/cell-selection/expand-cell-selection-end.d.ts +2 -5
  13. package/dist/cell-selection/expand-cell-selection-end.js +34 -30
  14. package/dist/cell-selection/expand-cell-selection-start.d.ts +2 -5
  15. package/dist/cell-selection/expand-cell-selection-start.js +33 -29
  16. package/dist/cell-selection/expand-cell-selection-up.d.ts +2 -5
  17. package/dist/cell-selection/expand-cell-selection-up.js +33 -29
  18. package/dist/cell-selection/full-width-start-end-index.js +3 -3
  19. package/dist/cell-selection/get-root-cell.d.ts +1 -5
  20. package/dist/cell-selection/get-root-cell.js +79 -77
  21. package/dist/cell-selection/is-bottom-rect.js +5 -5
  22. package/dist/cell-selection/is-center-col-rect.d.ts +2 -5
  23. package/dist/cell-selection/is-center-col-rect.js +3 -5
  24. package/dist/cell-selection/is-center-rect.js +3 -3
  25. package/dist/cell-selection/is-end-rect.d.ts +2 -5
  26. package/dist/cell-selection/is-end-rect.js +2 -2
  27. package/dist/cell-selection/is-overlapping-rect.js +4 -6
  28. package/dist/cell-selection/is-start-rect.d.ts +2 -5
  29. package/dist/cell-selection/is-start-rect.js +2 -2
  30. package/dist/cell-selection/is-top-rect.js +2 -2
  31. package/dist/cell-selection/is-within-selection-rect.js +1 -1
  32. package/dist/cell-selection/split-cell-selection-rect.d.ts +6 -12
  33. package/dist/cell-selection/split-cell-selection-rect.js +47 -53
  34. package/dist/cell-selection/update-additive-cell-selection.d.ts +2 -5
  35. package/dist/cell-selection/update-additive-cell-selection.js +17 -16
  36. package/dist/cell-selection/use-edge-scroll.d.ts +6 -8
  37. package/dist/cell-selection/use-edge-scroll.js +63 -65
  38. package/dist/cells/cell-default.d.ts +1 -5
  39. package/dist/cells/cell-default.js +5 -5
  40. package/dist/cells/cell-editor.d.ts +2 -4
  41. package/dist/cells/cell-editor.js +92 -129
  42. package/dist/cells/cell.d.ts +3 -16
  43. package/dist/cells/cell.js +27 -56
  44. package/dist/column-manager/branch-lookup-context.d.ts +1 -3
  45. package/dist/column-manager/branch.d.ts +9 -17
  46. package/dist/column-manager/branch.js +46 -64
  47. package/dist/column-manager/column-manager.d.ts +8 -57
  48. package/dist/column-manager/column-manager.js +8 -8
  49. package/dist/column-manager/context.d.ts +1 -1
  50. package/dist/column-manager/label.d.ts +2 -10
  51. package/dist/column-manager/label.js +12 -11
  52. package/dist/column-manager/leaf.d.ts +2 -10
  53. package/dist/column-manager/leaf.js +49 -61
  54. package/dist/column-manager/move-handle.d.ts +6 -14
  55. package/dist/column-manager/move-handle.js +48 -52
  56. package/dist/column-manager/panel.d.ts +1 -10
  57. package/dist/column-manager/root.d.ts +3 -7
  58. package/dist/column-manager/root.js +1 -4
  59. package/dist/column-manager/use-column-manager.d.ts +5 -7
  60. package/dist/column-manager/use-column-manager.js +21 -15
  61. package/dist/column-manager/use-columns-from-context.d.ts +1 -3
  62. package/dist/column-manager/use-columns-from-context.js +18 -18
  63. package/dist/column-manager/visibility-checkbox.d.ts +6 -14
  64. package/dist/column-manager/visibility-checkbox.js +23 -36
  65. package/dist/context.d.ts +4 -4
  66. package/dist/filter-tree/branch.d.ts +8 -16
  67. package/dist/filter-tree/branch.js +13 -23
  68. package/dist/filter-tree/context.d.ts +16 -16
  69. package/dist/filter-tree/filter-tree.d.ts +8 -49
  70. package/dist/filter-tree/filter-tree.js +8 -8
  71. package/dist/filter-tree/hooks/use-filter-tree.d.ts +29 -35
  72. package/dist/filter-tree/hooks/use-filter-tree.js +92 -94
  73. package/dist/filter-tree/hooks/use-tree-item.d.ts +4 -4
  74. package/dist/filter-tree/hooks/use-tree-item.js +106 -99
  75. package/dist/filter-tree/inclusion-checkbox.d.ts +6 -14
  76. package/dist/filter-tree/inclusion-checkbox.js +9 -19
  77. package/dist/filter-tree/label.d.ts +2 -10
  78. package/dist/filter-tree/label.js +12 -11
  79. package/dist/filter-tree/leaf.d.ts +2 -10
  80. package/dist/filter-tree/leaf.js +5 -15
  81. package/dist/filter-tree/root.d.ts +7 -23
  82. package/dist/filter-tree/root.js +23 -51
  83. package/dist/grid-box/+types.d.ts +11 -11
  84. package/dist/grid-box/context.d.ts +3 -3
  85. package/dist/grid-box/grid-box.d.ts +6 -26
  86. package/dist/grid-box/grid-box.js +6 -6
  87. package/dist/grid-box/item.d.ts +5 -13
  88. package/dist/grid-box/item.js +56 -73
  89. package/dist/grid-box/panel.d.ts +1 -13
  90. package/dist/grid-box/panel.js +2 -9
  91. package/dist/grid-box/root.d.ts +5 -11
  92. package/dist/grid-box/root.js +2 -11
  93. package/dist/grid-box/use-aggregation-box-items.d.ts +13 -16
  94. package/dist/grid-box/use-aggregation-box-items.js +57 -56
  95. package/dist/grid-box/use-column-box-items.d.ts +23 -33
  96. package/dist/grid-box/use-column-box-items.js +75 -87
  97. package/dist/grid-box/use-row-group-box-items.d.ts +12 -17
  98. package/dist/grid-box/use-row-group-box-items.js +123 -120
  99. package/dist/grid-provider/context.d.ts +2 -4
  100. package/dist/grid-provider/provider.d.ts +2 -4
  101. package/dist/grid-provider/use-grid.d.ts +1 -1
  102. package/dist/grid.d.ts +14 -126
  103. package/dist/grid.js +14 -14
  104. package/dist/header/header-cell.d.ts +5 -13
  105. package/dist/header/header-cell.js +15 -41
  106. package/dist/header/header-group-cell.d.ts +2 -10
  107. package/dist/header/header-group-cell.js +8 -26
  108. package/dist/header/header-row.d.ts +2 -10
  109. package/dist/header/header-row.js +2 -2
  110. package/dist/header/header.d.ts +1 -10
  111. package/dist/header/header.js +2 -11
  112. package/dist/header/resize-handler.d.ts +6 -15
  113. package/dist/header/resize-handler.js +122 -131
  114. package/dist/header/use-drag-move.d.ts +11 -22
  115. package/dist/header/use-drag-move.js +94 -95
  116. package/dist/header/use-header-cell-renderer.d.ts +2 -9
  117. package/dist/header/use-header-cell-renderer.js +29 -25
  118. package/dist/icons/index.d.ts +1 -92
  119. package/dist/icons/index.js +1 -92
  120. package/dist/index.d.ts +5 -22
  121. package/dist/index.js +5 -22
  122. package/dist/license.js +174 -174
  123. package/dist/listbox/context.d.ts +2 -2
  124. package/dist/listbox/item.d.ts +1 -10
  125. package/dist/listbox/item.js +19 -23
  126. package/dist/listbox/panel.d.ts +1 -10
  127. package/dist/listbox/panel.js +43 -69
  128. package/dist/listbox/root.d.ts +3 -5
  129. package/dist/listbox/root.js +7 -7
  130. package/dist/root/dialog-driver.js +16 -22
  131. package/dist/root/popover-driver.js +16 -27
  132. package/dist/root/root.d.ts +3 -7
  133. package/dist/root/root.js +107 -111
  134. package/dist/row-data-source-client/+types.d.ts +17 -17
  135. package/dist/row-data-source-client/built-ins/avg.js +4 -3
  136. package/dist/row-data-source-client/built-ins/built-ins.d.ts +16 -16
  137. package/dist/row-data-source-client/built-ins/built-ins.js +16 -16
  138. package/dist/row-data-source-client/built-ins/count.js +5 -3
  139. package/dist/row-data-source-client/built-ins/first.js +1 -1
  140. package/dist/row-data-source-client/built-ins/group.js +1 -1
  141. package/dist/row-data-source-client/built-ins/last.js +1 -1
  142. package/dist/row-data-source-client/built-ins/max.js +13 -9
  143. package/dist/row-data-source-client/built-ins/min.js +13 -9
  144. package/dist/row-data-source-client/built-ins/sum.js +10 -8
  145. package/dist/row-data-source-client/filter/+types.d.ts +13 -35
  146. package/dist/row-data-source-client/filter/compute-filtered-rows.d.ts +2 -16
  147. package/dist/row-data-source-client/filter/compute-filtered-rows.js +102 -102
  148. package/dist/row-data-source-client/pivots/create-agg-model.d.ts +4 -8
  149. package/dist/row-data-source-client/pivots/create-agg-model.js +9 -8
  150. package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.d.ts +1 -6
  151. package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +46 -42
  152. package/dist/row-data-source-client/pivots/create-pivot-columns.d.ts +1 -6
  153. package/dist/row-data-source-client/pivots/create-pivot-columns.js +17 -16
  154. package/dist/row-data-source-client/pivots/create-pivot-tree.d.ts +1 -7
  155. package/dist/row-data-source-client/pivots/create-pivot-tree.js +19 -19
  156. package/dist/row-data-source-client/tree/client-tree.d.ts +13 -19
  157. package/dist/row-data-source-client/tree/client-tree.js +67 -64
  158. package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +1 -4
  159. package/dist/row-data-source-client/tree/evaluator-aggregation.js +6 -6
  160. package/dist/row-data-source-client/tree/evaluator-group.d.ts +1 -4
  161. package/dist/row-data-source-client/tree/evaluator-group.js +7 -6
  162. package/dist/row-data-source-client/tree/traverse.d.ts +1 -5
  163. package/dist/row-data-source-client/tree/traverse.js +18 -15
  164. package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +5 -9
  165. package/dist/row-data-source-client/use-client-data-source-paginated.js +551 -566
  166. package/dist/row-data-source-client/use-client-data-source.d.ts +5 -9
  167. package/dist/row-data-source-client/use-client-data-source.js +661 -696
  168. package/dist/row-data-source-client/use-client-tree-data-source.d.ts +5 -9
  169. package/dist/row-data-source-client/use-client-tree-data-source.js +512 -523
  170. package/dist/row-data-source-server/async-tree/+types.async-tree.d.ts +33 -36
  171. package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.d.ts +1 -4
  172. package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +22 -18
  173. package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.d.ts +1 -4
  174. package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.js +25 -17
  175. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-unique.js +18 -18
  176. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-valid.js +10 -9
  177. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.d.ts +1 -4
  178. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.js +14 -13
  179. package/dist/row-data-source-server/async-tree/check-set-action-item-kinds.js +10 -9
  180. package/dist/row-data-source-server/async-tree/get-parent-node-by-path.d.ts +1 -4
  181. package/dist/row-data-source-server/async-tree/get-parent-node-by-path.js +13 -13
  182. package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.d.ts +1 -4
  183. package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.js +1 -1
  184. package/dist/row-data-source-server/async-tree/make-async-tree.js +14 -14
  185. package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.d.ts +1 -3
  186. package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.js +6 -6
  187. package/dist/row-data-source-server/async-tree/maybe-apply-resize.d.ts +1 -5
  188. package/dist/row-data-source-server/async-tree/maybe-apply-resize.js +14 -11
  189. package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.d.ts +1 -4
  190. package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.js +46 -42
  191. package/dist/row-data-source-server/range-tree/range-tree.d.ts +28 -28
  192. package/dist/row-data-source-server/range-tree/range-tree.js +48 -49
  193. package/dist/row-data-source-server/use-server-data-source.d.ts +2 -11
  194. package/dist/row-data-source-server/use-server-data-source.js +675 -688
  195. package/dist/row-data-source-server/utils/get-node-depth.js +7 -7
  196. package/dist/row-data-source-server/utils/get-node-path.js +7 -7
  197. package/dist/row-data-source-server/utils/get-request-id.js +4 -3
  198. package/dist/rows/row/context.d.ts +2 -2
  199. package/dist/rows/row/row.d.ts +3 -16
  200. package/dist/rows/row/row.js +4 -19
  201. package/dist/rows/row/use-row-context-value.d.ts +2 -5
  202. package/dist/rows/row/use-row-context-value.js +26 -23
  203. package/dist/rows/row-detail-row.d.ts +2 -4
  204. package/dist/rows/row-detail-row.js +124 -147
  205. package/dist/rows/row-full-width.d.ts +4 -12
  206. package/dist/rows/row-full-width.js +7 -35
  207. package/dist/rows/rows-container.d.ts +1 -10
  208. package/dist/rows/rows-container.js +3 -12
  209. package/dist/rows/rows-sections.d.ts +3 -30
  210. package/dist/rows/rows-sections.js +10 -42
  211. package/dist/rows/scrollers/native-scroller.d.ts +1 -3
  212. package/dist/rows/scrollers/native-scroller.js +13 -17
  213. package/dist/sort-manager/+types.d.ts +7 -14
  214. package/dist/sort-manager/context.d.ts +4 -4
  215. package/dist/sort-manager/hooks/use-sort-manager.d.ts +9 -9
  216. package/dist/sort-manager/hooks/use-sort-manager.js +49 -45
  217. package/dist/sort-manager/hooks/use-sort-row-item.d.ts +46 -57
  218. package/dist/sort-manager/hooks/use-sort-row-item.js +131 -126
  219. package/dist/sort-manager/hooks/use-sortable-column-items.d.ts +3 -6
  220. package/dist/sort-manager/hooks/use-sortable-column-items.js +10 -10
  221. package/dist/sort-manager/root.d.ts +1 -7
  222. package/dist/sort-manager/root.js +10 -10
  223. package/dist/sort-manager/sort-add.d.ts +5 -13
  224. package/dist/sort-manager/sort-add.js +8 -8
  225. package/dist/sort-manager/sort-apply.d.ts +4 -12
  226. package/dist/sort-manager/sort-apply.js +16 -16
  227. package/dist/sort-manager/sort-cancel.d.ts +4 -12
  228. package/dist/sort-manager/sort-cancel.js +19 -19
  229. package/dist/sort-manager/sort-clear.d.ts +4 -12
  230. package/dist/sort-manager/sort-clear.js +16 -15
  231. package/dist/sort-manager/sort-column-select.d.ts +6 -14
  232. package/dist/sort-manager/sort-column-select.js +14 -22
  233. package/dist/sort-manager/sort-direction-select.d.ts +6 -14
  234. package/dist/sort-manager/sort-direction-select.js +19 -27
  235. package/dist/sort-manager/sort-manager.d.ts +12 -93
  236. package/dist/sort-manager/sort-manager.js +12 -12
  237. package/dist/sort-manager/sort-remove.d.ts +4 -12
  238. package/dist/sort-manager/sort-remove.js +8 -8
  239. package/dist/sort-manager/sort-row.d.ts +2 -10
  240. package/dist/sort-manager/sort-row.js +1 -4
  241. package/dist/sort-manager/sort-rows.d.ts +1 -10
  242. package/dist/sort-manager/sort-rows.js +1 -1
  243. package/dist/sort-manager/sort-value-select.d.ts +7 -15
  244. package/dist/sort-manager/sort-value-select.js +19 -28
  245. package/dist/sort-manager/utils/sort-item-to-sort-model.d.ts +1 -4
  246. package/dist/sort-manager/utils/sort-item-to-sort-model.js +49 -46
  247. package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +1 -4
  248. package/dist/sort-manager/utils/sort-model-to-sort-items.js +44 -36
  249. package/dist/state/+types.d.ts +29 -43
  250. package/dist/state/api/column-autosize.d.ts +2 -4
  251. package/dist/state/api/column-autosize.js +63 -62
  252. package/dist/state/api/column-by-id.js +4 -4
  253. package/dist/state/api/column-field.js +20 -17
  254. package/dist/state/api/column-from-index.js +4 -4
  255. package/dist/state/api/column-group-toggle.js +8 -8
  256. package/dist/state/api/column-index.js +5 -5
  257. package/dist/state/api/column-move.js +46 -48
  258. package/dist/state/api/column-resize.js +7 -9
  259. package/dist/state/api/column-update.d.ts +2 -4
  260. package/dist/state/api/column-update.js +23 -23
  261. package/dist/state/api/dialog-frame.d.ts +4 -8
  262. package/dist/state/api/dialog-frame.js +12 -11
  263. package/dist/state/api/edit-begin.d.ts +2 -4
  264. package/dist/state/api/edit-begin.js +84 -71
  265. package/dist/state/api/edit-end.d.ts +2 -4
  266. package/dist/state/api/edit-end.js +41 -38
  267. package/dist/state/api/edit-is-cell-active.d.ts +2 -4
  268. package/dist/state/api/edit-is-cell-active.js +24 -17
  269. package/dist/state/api/edit-update.d.ts +2 -4
  270. package/dist/state/api/edit-update.js +85 -74
  271. package/dist/state/api/event-listeners.d.ts +3 -12
  272. package/dist/state/api/event-listeners.js +17 -16
  273. package/dist/state/api/export-csv.js +35 -33
  274. package/dist/state/api/export-data-rect.js +21 -21
  275. package/dist/state/api/focus-cell.d.ts +2 -4
  276. package/dist/state/api/focus-cell.js +109 -110
  277. package/dist/state/api/popover-frame.d.ts +4 -8
  278. package/dist/state/api/popover-frame.js +12 -11
  279. package/dist/state/api/position-from-element.js +6 -5
  280. package/dist/state/api/row-by-id.js +3 -3
  281. package/dist/state/api/row-by-index.js +6 -11
  282. package/dist/state/api/row-detail-is-expanded.d.ts +1 -3
  283. package/dist/state/api/row-detail-is-expanded.js +4 -4
  284. package/dist/state/api/row-detail-rendered-height.d.ts +2 -4
  285. package/dist/state/api/row-detail-rendered-height.js +12 -10
  286. package/dist/state/api/row-detail-toggle.js +30 -26
  287. package/dist/state/api/row-group-apply-expansions.d.ts +1 -3
  288. package/dist/state/api/row-group-apply-expansions.js +17 -15
  289. package/dist/state/api/row-group-column-index.d.ts +1 -3
  290. package/dist/state/api/row-group-column-index.js +12 -14
  291. package/dist/state/api/row-group-is-expanded.d.ts +1 -3
  292. package/dist/state/api/row-group-is-expanded.js +13 -11
  293. package/dist/state/api/row-group-toggle.js +5 -5
  294. package/dist/state/api/row-handle-select.d.ts +2 -4
  295. package/dist/state/api/row-handle-select.js +40 -36
  296. package/dist/state/api/row-select-all.js +15 -14
  297. package/dist/state/api/row-select.d.ts +2 -4
  298. package/dist/state/api/row-select.js +33 -30
  299. package/dist/state/api/row-selected.js +11 -10
  300. package/dist/state/api/scroll-into-view.d.ts +2 -4
  301. package/dist/state/api/scroll-into-view.js +47 -47
  302. package/dist/state/api/sort-for-column.js +7 -6
  303. package/dist/state/api/use-row-drag.js +24 -22
  304. package/dist/state/helpers/cell-row-group.d.ts +1 -5
  305. package/dist/state/helpers/cell-row-group.js +16 -18
  306. package/dist/state/helpers/column-add-row-group.d.ts +7 -18
  307. package/dist/state/helpers/column-add-row-group.js +66 -71
  308. package/dist/state/helpers/column-layout.d.ts +1 -7
  309. package/dist/state/helpers/column-layout.js +60 -60
  310. package/dist/state/helpers/column-marker.d.ts +4 -8
  311. package/dist/state/helpers/column-marker.js +34 -38
  312. package/dist/state/helpers/column-view.d.ts +15 -21
  313. package/dist/state/helpers/column-view.js +32 -56
  314. package/dist/state/helpers/edit-on-change.d.ts +10 -18
  315. package/dist/state/helpers/edit-on-change.js +25 -25
  316. package/dist/state/helpers/empty-row-data-source.js +16 -16
  317. package/dist/state/helpers/get-data-rect.d.ts +10 -20
  318. package/dist/state/helpers/get-data-rect.js +62 -67
  319. package/dist/state/helpers/get-full-width-callback.d.ts +1 -5
  320. package/dist/state/helpers/get-full-width-callback.js +6 -5
  321. package/dist/state/helpers/get-span-callback.d.ts +1 -6
  322. package/dist/state/helpers/get-span-callback.js +18 -15
  323. package/dist/state/helpers/resolve-column.d.ts +2 -6
  324. package/dist/state/helpers/resolve-column.js +23 -23
  325. package/dist/state/helpers/row-layout/get-focus-criteria.d.ts +12 -15
  326. package/dist/state/helpers/row-layout/get-focus-criteria.js +56 -57
  327. package/dist/state/helpers/row-layout/row-layout.d.ts +9 -15
  328. package/dist/state/helpers/row-layout/row-layout.js +401 -387
  329. package/dist/state/use-lytenyte.js +528 -567
  330. package/dist/tree-view/branch/branch.d.ts +11 -19
  331. package/dist/tree-view/branch/branch.js +54 -106
  332. package/dist/tree-view/branch/use-branch-keys.d.ts +1 -5
  333. package/dist/tree-view/branch/use-branch-keys.js +74 -71
  334. package/dist/tree-view/context.d.ts +17 -21
  335. package/dist/tree-view/hooks/use-tree-view-paths.d.ts +1 -7
  336. package/dist/tree-view/hooks/use-tree-view-paths.js +5 -5
  337. package/dist/tree-view/index.d.ts +7 -35
  338. package/dist/tree-view/index.js +7 -7
  339. package/dist/tree-view/leaf.d.ts +2 -10
  340. package/dist/tree-view/leaf.js +21 -30
  341. package/dist/tree-view/navigation/get-all-ids.js +3 -3
  342. package/dist/tree-view/navigation/get-first-node.js +3 -3
  343. package/dist/tree-view/navigation/get-last-node.js +3 -3
  344. package/dist/tree-view/navigation/get-next-node.js +8 -6
  345. package/dist/tree-view/navigation/get-prev-node.js +8 -6
  346. package/dist/tree-view/panel/make-handle-navigation.js +31 -23
  347. package/dist/tree-view/panel/make-handle-selection.js +77 -68
  348. package/dist/tree-view/panel/make-handle-typeahead.js +40 -34
  349. package/dist/tree-view/panel/panel.d.ts +1 -10
  350. package/dist/tree-view/panel/panel.js +20 -40
  351. package/dist/tree-view/panel/use-tree-navigation.js +52 -64
  352. package/dist/tree-view/root.d.ts +14 -20
  353. package/dist/tree-view/root.js +55 -53
  354. package/dist/tree-view/utils/get-focusable-nodes.js +2 -4
  355. package/dist/tree-view/utils/get-focused-node.js +11 -11
  356. package/dist/tree-view/utils/get-ids-between-nodes.d.ts +1 -5
  357. package/dist/tree-view/utils/get-ids-between-nodes.js +11 -10
  358. package/dist/tree-view/utils/get-panel.js +5 -5
  359. package/dist/tree-view/utils/get-parent-node.js +7 -6
  360. package/dist/tree-view/utils/get-sibling-branches.js +10 -8
  361. package/dist/tree-view/utils/get-tree-node-id.js +1 -1
  362. package/dist/tree-view/utils/is-branch-node.js +1 -1
  363. package/dist/tree-view/utils/is-leaf-node.js +1 -1
  364. package/dist/tree-view/utils/is-tree-node-disabled.js +1 -1
  365. package/dist/tree-view/utils/select-node.d.ts +1 -5
  366. package/dist/tree-view/utils/select-node.js +11 -8
  367. package/dist/tree-view/utils/toggle-all-selections.js +6 -4
  368. package/dist/tree-view/utils/toggle-selection.js +18 -15
  369. package/dist/tree-view/virtualized/force-sync-scrolling.d.ts +1 -3
  370. package/dist/tree-view/virtualized/force-sync-scrolling.js +18 -24
  371. package/dist/tree-view/virtualized/get-virtual-tree-paths.d.ts +1 -3
  372. package/dist/tree-view/virtualized/get-virtual-tree-paths.js +12 -11
  373. package/dist/tree-view/virtualized/make-virtual-tree.d.ts +21 -26
  374. package/dist/tree-view/virtualized/make-virtual-tree.js +85 -79
  375. package/dist/tree-view/virtualized/use-flattened-tree.d.ts +8 -17
  376. package/dist/tree-view/virtualized/use-flattened-tree.js +31 -30
  377. package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +1 -6
  378. package/dist/tree-view/virtualized/use-row-start-and-end.js +23 -21
  379. package/dist/tree-view/virtualized/use-virtualized-tree.d.ts +15 -21
  380. package/dist/tree-view/virtualized/use-virtualized-tree.js +90 -103
  381. package/dist/utils/cycle-sorts.js +14 -12
  382. package/dist/viewport/begin-editing.d.ts +2 -6
  383. package/dist/viewport/begin-editing.js +13 -9
  384. package/dist/viewport/viewport.d.ts +1 -10
  385. package/dist/viewport/viewport.js +70 -93
  386. package/package.json +7 -7
@@ -2,552 +2,541 @@ import {} from "../+types.js";
2
2
  import { useRef } from "react";
3
3
  import { atom, createStore } from "@1771technologies/atom";
4
4
  import { traverse } from "./tree/traverse.js";
5
- import {
6
- dateComparator,
7
- makeGridAtom,
8
- numberComparator,
9
- stringComparator,
10
- } from "@1771technologies/lytenyte-shared";
5
+ import { dateComparator, makeGridAtom, numberComparator, stringComparator, } from "@1771technologies/lytenyte-shared";
11
6
  import { equal } from "@1771technologies/lytenyte-js-utils";
12
7
  import { makeClientTree } from "./tree/client-tree.js";
13
8
  import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
14
9
  import { builtIns } from "./built-ins/built-ins.js";
15
10
  export function makeClientTreeDataSource(p) {
16
- const rdsStore = createStore();
17
- const data = atom(p.data);
18
- const topData = atom(p.topData ?? []);
19
- const bottomData = atom(p.bottomData ?? []);
20
- const dataToSrc$ = atom((g) => {
21
- return new Map(g(data).map((c, i) => [c, i]));
22
- });
23
- const cache = new Map();
24
- const centerNodes = atom((g) => {
25
- const nodes = [];
26
- const d = g(data);
27
- for (let i = 0; i < d.length; i++) {
28
- if (!cache.has(i)) {
29
- cache.set(i, {
30
- id: "",
31
- kind: "leaf",
32
- data: d[i],
11
+ const rdsStore = createStore();
12
+ const data = atom(p.data);
13
+ const topData = atom(p.topData ?? []);
14
+ const bottomData = atom(p.bottomData ?? []);
15
+ const dataToSrc$ = atom((g) => {
16
+ return new Map(g(data).map((c, i) => [c, i]));
17
+ });
18
+ const cache = new Map();
19
+ const centerNodes = atom((g) => {
20
+ const nodes = [];
21
+ const d = g(data);
22
+ for (let i = 0; i < d.length; i++) {
23
+ if (!cache.has(i)) {
24
+ cache.set(i, {
25
+ id: "",
26
+ kind: "leaf",
27
+ data: d[i],
28
+ });
29
+ }
30
+ const node = cache.get(i);
31
+ node.data = d[i];
32
+ nodes.push(node);
33
+ }
34
+ return nodes;
35
+ });
36
+ const topNodes = atom((g) => {
37
+ return g(topData).map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
38
+ });
39
+ const botNodes = atom((g) => {
40
+ return g(bottomData).map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
41
+ });
42
+ const pinnedIdMap = atom((g) => {
43
+ const combined = new Map([...g(topNodes), ...g(botNodes)].map((c) => [c.id, c]));
44
+ return combined;
45
+ });
46
+ const models = atom({
47
+ sort: [],
48
+ filter: {},
49
+ filterIn: {},
50
+ quickSearch: null,
51
+ agg: {},
52
+ groupExpansions: {},
53
+ columnPivotGroupExpansions: {},
54
+ });
55
+ const sortModel = atom((g) => g(models).sort);
56
+ const filterModel = atom((g) => g(models).filter);
57
+ const filterInModel = atom((g) => g(models).filterIn);
58
+ const groupExpansions = atom((g) => g(models).groupExpansions);
59
+ const aggModel = atom((g) => g(models).agg);
60
+ const quickSearch = atom((g) => g(models).quickSearch);
61
+ const grid$ = atom(null);
62
+ const snapshot = atom(0);
63
+ const tree = atom((g) => {
64
+ g(snapshot);
65
+ const grid = g(grid$);
66
+ const rows = g(centerNodes);
67
+ const filtered = computeFilteredRows(rows, grid, g(filterModel), g(filterInModel), g(quickSearch), grid?.state.quickSearchSensitivity.get() ?? "case-sensitive", false);
68
+ const rowAggModel = Object.entries(g(aggModel)).map(([name, agg]) => {
69
+ if (typeof agg.fn === "function") {
70
+ const fn = agg.fn;
71
+ return {
72
+ name,
73
+ fn: (rows) => fn(rows.map((c) => c.data), grid),
74
+ };
75
+ }
76
+ const key = agg.fn;
77
+ const fn = (data) => {
78
+ const fieldData = data.map((r) => grid?.api.columnField(name, { kind: "leaf", data: r.data }));
79
+ return builtIns[key](fieldData);
80
+ };
81
+ return { name, fn };
33
82
  });
34
- }
35
- const node = cache.get(i);
36
- node.data = d[i];
37
- nodes.push(node);
38
- }
39
- return nodes;
40
- });
41
- const topNodes = atom((g) => {
42
- return g(topData).map((c, i) => ({ data: c, id: `top-${i}`, kind: "leaf" }));
43
- });
44
- const botNodes = atom((g) => {
45
- return g(bottomData).map((c, i) => ({ data: c, id: `bottom-${i}`, kind: "leaf" }));
46
- });
47
- const pinnedIdMap = atom((g) => {
48
- const combined = new Map([...g(topNodes), ...g(botNodes)].map((c) => [c.id, c]));
49
- return combined;
50
- });
51
- const models = atom({
52
- sort: [],
53
- filter: {},
54
- filterIn: {},
55
- quickSearch: null,
56
- agg: {},
57
- groupExpansions: {},
58
- columnPivotGroupExpansions: {},
59
- });
60
- const sortModel = atom((g) => g(models).sort);
61
- const filterModel = atom((g) => g(models).filter);
62
- const filterInModel = atom((g) => g(models).filterIn);
63
- const groupExpansions = atom((g) => g(models).groupExpansions);
64
- const aggModel = atom((g) => g(models).agg);
65
- const quickSearch = atom((g) => g(models).quickSearch);
66
- const grid$ = atom(null);
67
- const snapshot = atom(0);
68
- const tree = atom((g) => {
69
- g(snapshot);
70
- const grid = g(grid$);
71
- const rows = g(centerNodes);
72
- const filtered = computeFilteredRows(
73
- rows,
74
- grid,
75
- g(filterModel),
76
- g(filterInModel),
77
- g(quickSearch),
78
- grid?.state.quickSearchSensitivity.get() ?? "case-sensitive",
79
- false,
80
- );
81
- const rowAggModel = Object.entries(g(aggModel)).map(([name, agg]) => {
82
- if (typeof agg.fn === "function") {
83
- const fn = agg.fn;
84
- return {
85
- name,
86
- fn: (rows) =>
87
- fn(
88
- rows.map((c) => c.data),
89
- grid,
90
- ),
83
+ return makeClientTree({
84
+ rowData: filtered,
85
+ rowAggModel: grid ? rowAggModel : [],
86
+ rowBranchModel: p.getPathFromData,
87
+ rowIdGroup: p.rowIdBranch,
88
+ rowIdLeaf: p.rowIdLeaf,
89
+ });
90
+ });
91
+ const sortComparator = atom((g) => {
92
+ const model = g(sortModel);
93
+ const grid = g(grid$);
94
+ if (!model.length || !grid)
95
+ return () => 0;
96
+ const comparator = (l, r) => {
97
+ let res = 0;
98
+ for (const sortSpec of model) {
99
+ const sort = sortSpec.sort;
100
+ const columnId = sortSpec.columnId;
101
+ const ld = l.kind === 2
102
+ ? { kind: "branch", data: l.data, key: l.key }
103
+ : { kind: "leaf", data: l.data.data };
104
+ const rd = r.kind === 2
105
+ ? { kind: "branch", data: r.data, key: r.key }
106
+ : { kind: "leaf", data: r.data.data };
107
+ if (sort.kind === "custom") {
108
+ res = sort.comparator(ld, rd, sort.options ?? {});
109
+ }
110
+ else if (sort.kind === "number") {
111
+ const left = grid.api.columnField(columnId, ld);
112
+ const right = grid.api.columnField(columnId, rd);
113
+ res = numberComparator(left, right, sort.options ?? {});
114
+ }
115
+ else if (sort.kind === "date") {
116
+ const left = grid.api.columnField(columnId, ld);
117
+ const right = grid.api.columnField(columnId, rd);
118
+ res = dateComparator(left, right, sort.options ?? {});
119
+ }
120
+ else if (sort.kind === "string") {
121
+ const left = grid.api.columnField(columnId, ld);
122
+ const right = grid.api.columnField(columnId, rd);
123
+ res = stringComparator(left, right, sort.options ?? {});
124
+ }
125
+ else {
126
+ res = 0;
127
+ }
128
+ res = sortSpec.isDescending ? -res : res;
129
+ if (res !== 0)
130
+ break;
131
+ }
132
+ return res;
91
133
  };
92
- }
93
- const key = agg.fn;
94
- const fn = (data) => {
95
- const fieldData = data.map((r) =>
96
- grid?.api.columnField(name, { kind: "leaf", data: r.data }),
97
- );
98
- return builtIns[key](fieldData);
99
- };
100
- return { name, fn };
134
+ return comparator;
101
135
  });
102
- return makeClientTree({
103
- rowData: filtered,
104
- rowAggModel: grid ? rowAggModel : [],
105
- rowBranchModel: p.getPathFromData,
106
- rowIdGroup: p.rowIdBranch,
107
- rowIdLeaf: p.rowIdLeaf,
136
+ const idToNode = atom((g) => {
137
+ const map = new Map();
138
+ traverse(g(tree).root, (node) => {
139
+ map.set(node.id, node);
140
+ });
141
+ return map;
108
142
  });
109
- });
110
- const sortComparator = atom((g) => {
111
- const model = g(sortModel);
112
- const grid = g(grid$);
113
- if (!model.length || !grid) return () => 0;
114
- const comparator = (l, r) => {
115
- let res = 0;
116
- for (const sortSpec of model) {
117
- const sort = sortSpec.sort;
118
- const columnId = sortSpec.columnId;
119
- const ld =
120
- l.kind === 2
121
- ? { kind: "branch", data: l.data, key: l.key }
122
- : { kind: "leaf", data: l.data.data };
123
- const rd =
124
- r.kind === 2
125
- ? { kind: "branch", data: r.data, key: r.key }
126
- : { kind: "leaf", data: r.data.data };
127
- if (sort.kind === "custom") {
128
- res = sort.comparator(ld, rd, sort.options ?? {});
129
- } else if (sort.kind === "number") {
130
- const left = grid.api.columnField(columnId, ld);
131
- const right = grid.api.columnField(columnId, rd);
132
- res = numberComparator(left, right, sort.options ?? {});
133
- } else if (sort.kind === "date") {
134
- const left = grid.api.columnField(columnId, ld);
135
- const right = grid.api.columnField(columnId, rd);
136
- res = dateComparator(left, right, sort.options ?? {});
137
- } else if (sort.kind === "string") {
138
- const left = grid.api.columnField(columnId, ld);
139
- const right = grid.api.columnField(columnId, rd);
140
- res = stringComparator(left, right, sort.options ?? {});
141
- } else {
142
- res = 0;
143
- }
144
- res = sortSpec.isDescending ? -res : res;
145
- if (res !== 0) break;
146
- }
147
- return res;
148
- };
149
- return comparator;
150
- });
151
- const idToNode = atom((g) => {
152
- const map = new Map();
153
- traverse(g(tree).root, (node) => {
154
- map.set(node.id, node);
143
+ const initialized = atom(false);
144
+ const flat = atom((g) => {
145
+ if (!g(initialized))
146
+ return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
147
+ const idMap = new Map();
148
+ const idToIndexMap = new Map();
149
+ const flattened = [];
150
+ const comparator = g(sortComparator);
151
+ const expansions = g(groupExpansions);
152
+ const defaultExpansion = g(grid$)?.state.rowGroupDefaultExpansion.get() ?? false;
153
+ let index = g(topNodes).length;
154
+ traverse(g(tree).root, (node) => {
155
+ if (node.kind === 1) {
156
+ node.data.id = node.id;
157
+ flattened.push(node.data);
158
+ }
159
+ else {
160
+ flattened.push({
161
+ kind: "branch",
162
+ data: node.data,
163
+ id: node.id,
164
+ key: node.key,
165
+ depth: node.depth,
166
+ });
167
+ }
168
+ idMap.set(node.id, flattened.at(-1));
169
+ idToIndexMap.set(node.id, index);
170
+ index++;
171
+ if (node.kind === 2) {
172
+ const expanded = expansions[node.id] ??
173
+ (typeof defaultExpansion === "number"
174
+ ? node.depth <= defaultExpansion
175
+ : defaultExpansion);
176
+ return expanded;
177
+ }
178
+ }, comparator);
179
+ return { flat: flattened, idMap, idToIndexMap };
155
180
  });
156
- return map;
157
- });
158
- const initialized = atom(false);
159
- const flat = atom((g) => {
160
- if (!g(initialized)) return { flat: [], idMap: new Map(), idToIndexMap: new Map() };
161
- const idMap = new Map();
162
- const idToIndexMap = new Map();
163
- const flattened = [];
164
- const comparator = g(sortComparator);
165
- const expansions = g(groupExpansions);
166
- const defaultExpansion = g(grid$)?.state.rowGroupDefaultExpansion.get() ?? false;
167
- let index = g(topNodes).length;
168
- traverse(
169
- g(tree).root,
170
- (node) => {
171
- if (node.kind === 1) {
172
- node.data.id = node.id;
173
- flattened.push(node.data);
174
- } else {
175
- flattened.push({
176
- kind: "branch",
177
- data: node.data,
178
- id: node.id,
179
- key: node.key,
180
- depth: node.depth,
181
- });
182
- }
183
- idMap.set(node.id, flattened.at(-1));
184
- idToIndexMap.set(node.id, index);
185
- index++;
186
- if (node.kind === 2) {
187
- const expanded =
188
- expansions[node.id] ??
189
- (typeof defaultExpansion === "number"
190
- ? node.depth <= defaultExpansion
191
- : defaultExpansion);
192
- return expanded;
193
- }
194
- },
195
- comparator,
196
- );
197
- return { flat: flattened, idMap, idToIndexMap };
198
- });
199
- const flatLength = atom((g) => g(flat).flat.length);
200
- const cleanup = [];
201
- const init = (grid) => {
202
- while (cleanup.length) cleanup.pop()?.();
203
- rdsStore.set(grid$, grid);
204
- const store = grid.state.rowDataStore;
205
- // Monitor row count changes
206
- const centerCount = rdsStore.get(flatLength);
207
- store.rowCenterCount.set(centerCount);
208
- cleanup.push(
209
- rdsStore.sub(flatLength, () => {
181
+ const flatLength = atom((g) => g(flat).flat.length);
182
+ const cleanup = [];
183
+ const init = (grid) => {
184
+ while (cleanup.length)
185
+ cleanup.pop()?.();
186
+ rdsStore.set(grid$, grid);
187
+ const store = grid.state.rowDataStore;
188
+ // Monitor row count changes
210
189
  const centerCount = rdsStore.get(flatLength);
211
190
  store.rowCenterCount.set(centerCount);
212
- grid.state.rowDataStore.rowClearCache();
213
- }),
214
- );
215
- const top = rdsStore.get(topData).length;
216
- store.rowTopCount.set(top);
217
- cleanup.push(
218
- rdsStore.sub(topData, () => {
191
+ cleanup.push(rdsStore.sub(flatLength, () => {
192
+ const centerCount = rdsStore.get(flatLength);
193
+ store.rowCenterCount.set(centerCount);
194
+ grid.state.rowDataStore.rowClearCache();
195
+ }));
219
196
  const top = rdsStore.get(topData).length;
220
197
  store.rowTopCount.set(top);
221
- grid.state.rowDataStore.rowClearCache();
222
- }),
223
- );
224
- const bottom = rdsStore.get(bottomData).length;
225
- store.rowBottomCount.set(bottom);
226
- cleanup.push(
227
- rdsStore.sub(bottomData, () => {
228
- const bot = rdsStore.get(bottomData).length;
229
- store.rowBottomCount.set(bot);
230
- grid.state.rowDataStore.rowClearCache();
231
- }),
232
- );
233
- const sort = grid.state.sortModel.get();
234
- const filter = grid.state.filterModel.get();
235
- const filterIn = grid.state.filterInModel.get();
236
- const groupExpansions = grid.state.rowGroupExpansions.get();
237
- const agg = grid.state.aggModel.get();
238
- const quickSearch = grid.state.quickSearch.get();
239
- const columnPivotGroupExpansions = grid.state.columnPivotRowGroupExpansions.get();
240
- rdsStore.set(models, {
241
- agg,
242
- filter,
243
- filterIn,
244
- quickSearch,
245
- groupExpansions,
246
- sort,
247
- columnPivotGroupExpansions,
248
- });
249
- rdsStore.set(initialized, true);
250
- // Sort model monitoring
251
- cleanup.push(
252
- grid.state.sortModel.watch(() => {
253
- rdsStore.set(models, (prev) => ({ ...prev, sort: grid.state.sortModel.get() }));
254
- grid.state.rowDataStore.rowClearCache();
255
- }),
256
- );
257
- // Filter model monitoring
258
- cleanup.push(
259
- grid.state.filterModel.watch(() => {
260
- rdsStore.set(models, (prev) => ({ ...prev, filter: grid.state.filterModel.get() }));
261
- grid.state.rowDataStore.rowClearCache();
262
- }),
263
- );
264
- cleanup.push(
265
- grid.state.quickSearch.watch(() => {
266
- rdsStore.set(models, (prev) => ({ ...prev, quickSearch: grid.state.quickSearch.get() }));
267
- grid.state.rowDataStore.rowClearCache();
268
- }),
269
- );
270
- cleanup.push(
271
- grid.state.filterInModel.watch(() => {
272
- rdsStore.set(models, (prev) => ({ ...prev, filterIn: grid.state.filterInModel.get() }));
273
- grid.state.rowDataStore.rowClearCache();
274
- }),
275
- );
276
- // Row group model monitoring
277
- cleanup.push(
278
- grid.state.rowGroupModel.watch(() => {
279
- rdsStore.set(models, (prev) => ({ ...prev, group: grid.state.rowGroupModel.get() }));
280
- grid.state.rowDataStore.rowClearCache();
281
- }),
282
- );
283
- // Row group expansions monitoring
284
- cleanup.push(
285
- grid.state.rowGroupExpansions.watch(() => {
286
- rdsStore.set(models, (prev) => ({
287
- ...prev,
288
- groupExpansions: grid.state.rowGroupExpansions.get(),
198
+ cleanup.push(rdsStore.sub(topData, () => {
199
+ const top = rdsStore.get(topData).length;
200
+ store.rowTopCount.set(top);
201
+ grid.state.rowDataStore.rowClearCache();
289
202
  }));
290
- grid.state.rowDataStore.rowClearCache();
291
- }),
292
- );
293
- // Agg model monitoring
294
- cleanup.push(
295
- grid.state.aggModel.watch(() => {
296
- rdsStore.set(models, (prev) => ({ ...prev, agg: grid.state.aggModel.get() }));
297
- grid.state.rowDataStore.rowClearCache();
298
- }),
299
- );
300
- };
301
- const rowById = (id) => {
302
- const pinned = rdsStore.get(pinnedIdMap);
303
- if (pinned.has(id)) return pinned.get(id);
304
- const t = rdsStore.get(flat);
305
- return t.idMap.get(id) ?? null;
306
- };
307
- const rowByIndex = (index) => {
308
- const top = rdsStore.get(topNodes);
309
- const bot = rdsStore.get(botNodes);
310
- const center = rdsStore.get(flat).flat;
311
- const topOffset = top.length;
312
- const centerOffset = topOffset + center.length;
313
- const botOffset = centerOffset + bot.length;
314
- if (index < topOffset) return top[index];
315
- if (index < centerOffset) return center[index - topOffset];
316
- if (index < botOffset) return bot[index - centerOffset];
317
- return null;
318
- };
319
- const rowUpdate = (updates) => {
320
- const grid = rdsStore.get(grid$);
321
- const d = rdsStore.get(data);
322
- const idMap = rdsStore.get(idToNode);
323
- const dataToSrc = rdsStore.get(dataToSrc$);
324
- for (const [key, next] of updates.entries()) {
325
- const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
326
- const treeNode = typeof key === "string" ? idMap.get(key) : null;
327
- if ((!row && !treeNode) || !grid) {
328
- console.error(`Failed to find the row with identifier ${key} which is being updated.`);
329
- continue;
330
- }
331
- if (row?.kind === "branch") {
332
- row.data = next;
333
- } else {
334
- const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
335
- const source = dataToSrc.get(data);
336
- if (source == null) {
337
- console.error(`Failed to find the row with identifier ${key} which is being updated.`);
338
- continue;
339
- }
340
- d[source] = next;
341
- }
342
- }
343
- rdsStore.set(data, [...d]);
344
- rdsStore.set(snapshot, (prev) => prev + 1);
345
- grid.state.rowDataStore.rowClearCache();
346
- };
347
- const rowToIndex = (rowId) => {
348
- const f = rdsStore.get(flat);
349
- const top = rdsStore.get(topNodes);
350
- const bot = rdsStore.get(botNodes);
351
- const topCount = top.length;
352
- const center = f.flat.length;
353
- const rowIndex = f.idToIndexMap.get(rowId);
354
- if (rowIndex != null) return rowIndex;
355
- if (rowIndex == null) {
356
- const foundTop = top.findIndex((row) => row.id === rowId);
357
- if (foundTop !== -1) return foundTop;
358
- const foundBot = bot.findIndex((row) => row.id === rowId);
359
- if (foundBot !== -1) return foundBot + topCount + center;
360
- }
361
- return null;
362
- };
363
- const rowAllChildIds = (rowId) => {
364
- const t = rdsStore.get(tree);
365
- const ids = [];
366
- const node = t.idToNode.get(rowId);
367
- if (node?.kind === 2) {
368
- traverse(node, (n) => {
369
- ids.push(n.id);
370
- });
371
- }
372
- return ids;
373
- };
374
- return [
375
- {
376
- init,
377
- rowById,
378
- rowByIndex,
379
- rowAllChildIds,
380
- rowUpdate,
381
- inFilterItems: (c) => {
382
- const grid = rdsStore.get(grid$);
383
- if (!grid) return [];
384
- const data = rdsStore.get(centerNodes);
385
- const values = new Set(
386
- data.map((row) => {
387
- const field = grid.api.columnField(c, row);
388
- return field;
389
- }),
390
- );
391
- if (p.transformInFilterItem) {
392
- return p.transformInFilterItem({ column: c, values: [...values] });
393
- }
394
- return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
395
- },
396
- rowAdd: (newRows, place = "end") => {
397
- rdsStore.set(data, (prev) => {
398
- if (!newRows.length) return prev;
399
- let next;
400
- if (place === "beginning") next = [...newRows, ...prev];
401
- else if (place === "end") next = [...prev, ...newRows];
402
- else {
403
- next = [...prev];
404
- next.splice(place, 0, ...newRows);
405
- }
406
- return next;
407
- });
408
- const grid = rdsStore.get(grid$);
409
- grid?.state.rowDataStore.rowClearCache();
410
- },
411
- rowDelete: (rows) => {
412
- const rowData = new Set(
413
- rows
414
- .map((c) => {
415
- if (typeof c === "number") return rowByIndex(c)?.data;
416
- else return rowById(c)?.data;
417
- })
418
- .filter((c) => !!c),
419
- );
420
- rdsStore.set(data, (prev) => {
421
- if (!rowData.size) return prev;
422
- return prev.filter((d) => !rowData.has(d));
203
+ const bottom = rdsStore.get(bottomData).length;
204
+ store.rowBottomCount.set(bottom);
205
+ cleanup.push(rdsStore.sub(bottomData, () => {
206
+ const bot = rdsStore.get(bottomData).length;
207
+ store.rowBottomCount.set(bot);
208
+ grid.state.rowDataStore.rowClearCache();
209
+ }));
210
+ const sort = grid.state.sortModel.get();
211
+ const filter = grid.state.filterModel.get();
212
+ const filterIn = grid.state.filterInModel.get();
213
+ const groupExpansions = grid.state.rowGroupExpansions.get();
214
+ const agg = grid.state.aggModel.get();
215
+ const quickSearch = grid.state.quickSearch.get();
216
+ const columnPivotGroupExpansions = grid.state.columnPivotRowGroupExpansions.get();
217
+ rdsStore.set(models, {
218
+ agg,
219
+ filter,
220
+ filterIn,
221
+ quickSearch,
222
+ groupExpansions,
223
+ sort,
224
+ columnPivotGroupExpansions,
423
225
  });
226
+ rdsStore.set(initialized, true);
227
+ // Sort model monitoring
228
+ cleanup.push(grid.state.sortModel.watch(() => {
229
+ rdsStore.set(models, (prev) => ({ ...prev, sort: grid.state.sortModel.get() }));
230
+ grid.state.rowDataStore.rowClearCache();
231
+ }));
232
+ // Filter model monitoring
233
+ cleanup.push(grid.state.filterModel.watch(() => {
234
+ rdsStore.set(models, (prev) => ({ ...prev, filter: grid.state.filterModel.get() }));
235
+ grid.state.rowDataStore.rowClearCache();
236
+ }));
237
+ cleanup.push(grid.state.quickSearch.watch(() => {
238
+ rdsStore.set(models, (prev) => ({ ...prev, quickSearch: grid.state.quickSearch.get() }));
239
+ grid.state.rowDataStore.rowClearCache();
240
+ }));
241
+ cleanup.push(grid.state.filterInModel.watch(() => {
242
+ rdsStore.set(models, (prev) => ({ ...prev, filterIn: grid.state.filterInModel.get() }));
243
+ grid.state.rowDataStore.rowClearCache();
244
+ }));
245
+ // Row group model monitoring
246
+ cleanup.push(grid.state.rowGroupModel.watch(() => {
247
+ rdsStore.set(models, (prev) => ({ ...prev, group: grid.state.rowGroupModel.get() }));
248
+ grid.state.rowDataStore.rowClearCache();
249
+ }));
250
+ // Row group expansions monitoring
251
+ cleanup.push(grid.state.rowGroupExpansions.watch(() => {
252
+ rdsStore.set(models, (prev) => ({
253
+ ...prev,
254
+ groupExpansions: grid.state.rowGroupExpansions.get(),
255
+ }));
256
+ grid.state.rowDataStore.rowClearCache();
257
+ }));
258
+ // Agg model monitoring
259
+ cleanup.push(grid.state.aggModel.watch(() => {
260
+ rdsStore.set(models, (prev) => ({ ...prev, agg: grid.state.aggModel.get() }));
261
+ grid.state.rowDataStore.rowClearCache();
262
+ }));
263
+ };
264
+ const rowById = (id) => {
265
+ const pinned = rdsStore.get(pinnedIdMap);
266
+ if (pinned.has(id))
267
+ return pinned.get(id);
268
+ const t = rdsStore.get(flat);
269
+ return t.idMap.get(id) ?? null;
270
+ };
271
+ const rowByIndex = (index) => {
272
+ const top = rdsStore.get(topNodes);
273
+ const bot = rdsStore.get(botNodes);
274
+ const center = rdsStore.get(flat).flat;
275
+ const topOffset = top.length;
276
+ const centerOffset = topOffset + center.length;
277
+ const botOffset = centerOffset + bot.length;
278
+ if (index < topOffset)
279
+ return top[index];
280
+ if (index < centerOffset)
281
+ return center[index - topOffset];
282
+ if (index < botOffset)
283
+ return bot[index - centerOffset];
284
+ return null;
285
+ };
286
+ const rowUpdate = (updates) => {
424
287
  const grid = rdsStore.get(grid$);
425
- grid?.state.rowDataStore.rowClearCache();
426
- },
427
- rowSetBotData: (data) => {
428
- rdsStore.set(bottomData, data);
429
- const grid = rdsStore.get(grid$);
430
- grid?.state.rowDataStore.rowClearCache();
431
- },
432
- rowSetCenterData: (d) => {
433
- rdsStore.set(data, d);
434
- const grid = rdsStore.get(grid$);
435
- grid?.state.rowDataStore.rowClearCache();
436
- },
437
- rowSetTopData: (data) => {
438
- rdsStore.set(topData, data);
439
- const grid = rdsStore.get(grid$);
440
- grid?.state.rowDataStore.rowClearCache();
441
- },
442
- rowExpand: (expansions) => {
443
- const grid = rdsStore.get(grid$);
444
- if (!grid) return;
445
- const mode = grid.state.columnPivotMode.get();
446
- if (mode)
447
- grid.state.columnPivotRowGroupExpansions.set((prev) => ({ ...prev, ...expansions }));
448
- else grid.state.rowGroupExpansions.set((prev) => ({ ...prev, ...expansions }));
449
- },
450
- rowToIndex,
451
- rowSelect: (params) => {
452
- const grid = rdsStore.get(grid$);
453
- if (!grid) return;
454
- if (params.mode === "none") return;
455
- if (params.mode === "single") {
456
- if (params.deselect) {
457
- grid.state.rowSelectedIds.set(new Set());
458
- } else {
459
- grid.state.rowSelectedIds.set(new Set([params.startId]));
460
- }
461
- return;
462
- }
463
- const ids = new Set();
464
- if (params.startId === params.endId) {
465
- ids.add(params.startId);
466
- if (params.selectChildren) {
467
- rowAllChildIds(params.startId).forEach((c) => ids.add(c));
468
- }
469
- } else {
470
- const first = rowToIndex(params.startId);
471
- const last = rowToIndex(params.endId);
472
- if (first == null || last == null) return;
473
- const start = Math.min(first, last);
474
- const end = Math.max(first, last);
475
- for (let i = start; i <= end; i++) {
476
- const row = rowByIndex(i);
477
- if (!row) continue;
478
- if (params.selectChildren) {
479
- rowAllChildIds(row.id).forEach((c) => ids.add(c));
288
+ const d = rdsStore.get(data);
289
+ const idMap = rdsStore.get(idToNode);
290
+ const dataToSrc = rdsStore.get(dataToSrc$);
291
+ for (const [key, next] of updates.entries()) {
292
+ const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
293
+ const treeNode = typeof key === "string" ? idMap.get(key) : null;
294
+ if ((!row && !treeNode) || !grid) {
295
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
296
+ continue;
297
+ }
298
+ if (row?.kind === "branch") {
299
+ row.data = next;
300
+ }
301
+ else {
302
+ const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
303
+ const source = dataToSrc.get(data);
304
+ if (source == null) {
305
+ console.error(`Failed to find the row with identifier ${key} which is being updated.`);
306
+ continue;
307
+ }
308
+ d[source] = next;
480
309
  }
481
- if (row?.id) ids.add(row.id);
482
- }
483
- }
484
- if (params.deselect) {
485
- const current = grid.state.rowSelectedIds.get();
486
- const next = current.difference(ids);
487
- grid.state.rowSelectedIds.set(next);
488
- } else {
489
- const current = grid.state.rowSelectedIds.get();
490
- const next = current.union(ids);
491
- grid.state.rowSelectedIds.set(next);
492
310
  }
493
- },
494
- rowSelectAll: (params) => {
495
- const grid = rdsStore.get(grid$);
496
- if (!grid) return;
497
- if (params.deselect) {
498
- grid.state.rowSelectedIds.set(new Set());
499
- return;
311
+ rdsStore.set(data, [...d]);
312
+ rdsStore.set(snapshot, (prev) => prev + 1);
313
+ grid.state.rowDataStore.rowClearCache();
314
+ };
315
+ const rowToIndex = (rowId) => {
316
+ const f = rdsStore.get(flat);
317
+ const top = rdsStore.get(topNodes);
318
+ const bot = rdsStore.get(botNodes);
319
+ const topCount = top.length;
320
+ const center = f.flat.length;
321
+ const rowIndex = f.idToIndexMap.get(rowId);
322
+ if (rowIndex != null)
323
+ return rowIndex;
324
+ if (rowIndex == null) {
325
+ const foundTop = top.findIndex((row) => row.id === rowId);
326
+ if (foundTop !== -1)
327
+ return foundTop;
328
+ const foundBot = bot.findIndex((row) => row.id === rowId);
329
+ if (foundBot !== -1)
330
+ return foundBot + topCount + center;
500
331
  }
332
+ return null;
333
+ };
334
+ const rowAllChildIds = (rowId) => {
501
335
  const t = rdsStore.get(tree);
502
- grid.state.rowSelectedIds.set(new Set(t.idsAll));
503
- },
504
- rowData: (section) => {
505
- const d = [];
506
- if (section === "top" || section === "flat") {
507
- d.push(...rdsStore.get(topData));
508
- }
509
- if (section === "center" || section === "flat") {
510
- d.push(...rdsStore.get(data));
336
+ const ids = [];
337
+ const node = t.idToNode.get(rowId);
338
+ if (node?.kind === 2) {
339
+ traverse(node, (n) => {
340
+ ids.push(n.id);
341
+ });
511
342
  }
512
- if (section === "bottom" || section === "flat") {
513
- d.push(...rdsStore.get(bottomData));
514
- }
515
- return d;
516
- },
517
- rowAreAllSelected: (rowId) => {
518
- const g = rdsStore.get(grid$);
519
- if (!g) return false;
520
- const selected = g.state.rowSelectedIds.get();
521
- if (rowId) {
522
- const row = rowById(rowId);
523
- if (!row) return false;
524
- const childIds = new Set(rowAllChildIds(rowId));
525
- return childIds.isSubsetOf(selected);
526
- }
527
- const f = rdsStore.get(tree);
528
- return f.idsAll.isSubsetOf(selected);
529
- },
530
- },
531
- {
532
- top: makeGridAtom(topData, rdsStore),
533
- center: makeGridAtom(data, rdsStore),
534
- bottom: makeGridAtom(bottomData, rdsStore),
535
- },
536
- ];
343
+ return ids;
344
+ };
345
+ return [
346
+ {
347
+ init,
348
+ rowById,
349
+ rowByIndex,
350
+ rowAllChildIds,
351
+ rowUpdate,
352
+ inFilterItems: (c) => {
353
+ const grid = rdsStore.get(grid$);
354
+ if (!grid)
355
+ return [];
356
+ const data = rdsStore.get(centerNodes);
357
+ const values = new Set(data.map((row) => {
358
+ const field = grid.api.columnField(c, row);
359
+ return field;
360
+ }));
361
+ if (p.transformInFilterItem) {
362
+ return p.transformInFilterItem({ column: c, values: [...values] });
363
+ }
364
+ return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
365
+ },
366
+ rowAdd: (newRows, place = "end") => {
367
+ rdsStore.set(data, (prev) => {
368
+ if (!newRows.length)
369
+ return prev;
370
+ let next;
371
+ if (place === "beginning")
372
+ next = [...newRows, ...prev];
373
+ else if (place === "end")
374
+ next = [...prev, ...newRows];
375
+ else {
376
+ next = [...prev];
377
+ next.splice(place, 0, ...newRows);
378
+ }
379
+ return next;
380
+ });
381
+ const grid = rdsStore.get(grid$);
382
+ grid?.state.rowDataStore.rowClearCache();
383
+ },
384
+ rowDelete: (rows) => {
385
+ const rowData = new Set(rows
386
+ .map((c) => {
387
+ if (typeof c === "number")
388
+ return rowByIndex(c)?.data;
389
+ else
390
+ return rowById(c)?.data;
391
+ })
392
+ .filter((c) => !!c));
393
+ rdsStore.set(data, (prev) => {
394
+ if (!rowData.size)
395
+ return prev;
396
+ return prev.filter((d) => !rowData.has(d));
397
+ });
398
+ const grid = rdsStore.get(grid$);
399
+ grid?.state.rowDataStore.rowClearCache();
400
+ },
401
+ rowSetBotData: (data) => {
402
+ rdsStore.set(bottomData, data);
403
+ const grid = rdsStore.get(grid$);
404
+ grid?.state.rowDataStore.rowClearCache();
405
+ },
406
+ rowSetCenterData: (d) => {
407
+ rdsStore.set(data, d);
408
+ const grid = rdsStore.get(grid$);
409
+ grid?.state.rowDataStore.rowClearCache();
410
+ },
411
+ rowSetTopData: (data) => {
412
+ rdsStore.set(topData, data);
413
+ const grid = rdsStore.get(grid$);
414
+ grid?.state.rowDataStore.rowClearCache();
415
+ },
416
+ rowExpand: (expansions) => {
417
+ const grid = rdsStore.get(grid$);
418
+ if (!grid)
419
+ return;
420
+ const mode = grid.state.columnPivotMode.get();
421
+ if (mode)
422
+ grid.state.columnPivotRowGroupExpansions.set((prev) => ({ ...prev, ...expansions }));
423
+ else
424
+ grid.state.rowGroupExpansions.set((prev) => ({ ...prev, ...expansions }));
425
+ },
426
+ rowToIndex,
427
+ rowSelect: (params) => {
428
+ const grid = rdsStore.get(grid$);
429
+ if (!grid)
430
+ return;
431
+ if (params.mode === "none")
432
+ return;
433
+ if (params.mode === "single") {
434
+ if (params.deselect) {
435
+ grid.state.rowSelectedIds.set(new Set());
436
+ }
437
+ else {
438
+ grid.state.rowSelectedIds.set(new Set([params.startId]));
439
+ }
440
+ return;
441
+ }
442
+ const ids = new Set();
443
+ if (params.startId === params.endId) {
444
+ ids.add(params.startId);
445
+ if (params.selectChildren) {
446
+ rowAllChildIds(params.startId).forEach((c) => ids.add(c));
447
+ }
448
+ }
449
+ else {
450
+ const first = rowToIndex(params.startId);
451
+ const last = rowToIndex(params.endId);
452
+ if (first == null || last == null)
453
+ return;
454
+ const start = Math.min(first, last);
455
+ const end = Math.max(first, last);
456
+ for (let i = start; i <= end; i++) {
457
+ const row = rowByIndex(i);
458
+ if (!row)
459
+ continue;
460
+ if (params.selectChildren) {
461
+ rowAllChildIds(row.id).forEach((c) => ids.add(c));
462
+ }
463
+ if (row?.id)
464
+ ids.add(row.id);
465
+ }
466
+ }
467
+ if (params.deselect) {
468
+ const current = grid.state.rowSelectedIds.get();
469
+ const next = current.difference(ids);
470
+ grid.state.rowSelectedIds.set(next);
471
+ }
472
+ else {
473
+ const current = grid.state.rowSelectedIds.get();
474
+ const next = current.union(ids);
475
+ grid.state.rowSelectedIds.set(next);
476
+ }
477
+ },
478
+ rowSelectAll: (params) => {
479
+ const grid = rdsStore.get(grid$);
480
+ if (!grid)
481
+ return;
482
+ if (params.deselect) {
483
+ grid.state.rowSelectedIds.set(new Set());
484
+ return;
485
+ }
486
+ const t = rdsStore.get(tree);
487
+ grid.state.rowSelectedIds.set(new Set(t.idsAll));
488
+ },
489
+ rowData: (section) => {
490
+ const d = [];
491
+ if (section === "top" || section === "flat") {
492
+ d.push(...rdsStore.get(topData));
493
+ }
494
+ if (section === "center" || section === "flat") {
495
+ d.push(...rdsStore.get(data));
496
+ }
497
+ if (section === "bottom" || section === "flat") {
498
+ d.push(...rdsStore.get(bottomData));
499
+ }
500
+ return d;
501
+ },
502
+ rowAreAllSelected: (rowId) => {
503
+ const g = rdsStore.get(grid$);
504
+ if (!g)
505
+ return false;
506
+ const selected = g.state.rowSelectedIds.get();
507
+ if (rowId) {
508
+ const row = rowById(rowId);
509
+ if (!row)
510
+ return false;
511
+ const childIds = new Set(rowAllChildIds(rowId));
512
+ return childIds.isSubsetOf(selected);
513
+ }
514
+ const f = rdsStore.get(tree);
515
+ return f.idsAll.isSubsetOf(selected);
516
+ },
517
+ },
518
+ {
519
+ top: makeGridAtom(topData, rdsStore),
520
+ center: makeGridAtom(data, rdsStore),
521
+ bottom: makeGridAtom(bottomData, rdsStore),
522
+ },
523
+ ];
537
524
  }
538
525
  export function useClientTreeDataSource(p) {
539
- const ds = useRef(null);
540
- const dataAtomRef = useRef(null);
541
- if (!ds.current) [ds.current, dataAtomRef.current] = makeClientTreeDataSource(p);
542
- const da = dataAtomRef.current;
543
- if (p.reflectData) {
544
- // Need to queue the microtask since it we cannot update state during render.
545
- if (p.data !== da.center.get()) queueMicrotask(() => ds.current.rowSetCenterData(p.data));
546
- if (!equal(p.topData ?? [], da.top.get())) {
547
- queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
526
+ const ds = useRef(null);
527
+ const dataAtomRef = useRef(null);
528
+ if (!ds.current)
529
+ [ds.current, dataAtomRef.current] = makeClientTreeDataSource(p);
530
+ const da = dataAtomRef.current;
531
+ if (p.reflectData) {
532
+ // Need to queue the microtask since it we cannot update state during render.
533
+ if (p.data !== da.center.get())
534
+ queueMicrotask(() => ds.current.rowSetCenterData(p.data));
535
+ if (!equal(p.topData ?? [], da.top.get())) {
536
+ queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
537
+ }
538
+ if (!equal(p.bottomData ?? [], da.bottom.get()))
539
+ queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
548
540
  }
549
- if (!equal(p.bottomData ?? [], da.bottom.get()))
550
- queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
551
- }
552
- return ds.current;
541
+ return ds.current;
553
542
  }