@1771technologies/lytenyte-pro 1.0.0-beta.11 → 1.0.0-beta.12

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 (381) hide show
  1. package/dist/+types.d.ts +4155 -3957
  2. package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +38 -38
  3. package/dist/cell-selection/are-rects-equal.js +6 -4
  4. package/dist/cell-selection/bound-selection-rect.js +14 -14
  5. package/dist/cell-selection/cell-selection-containers.js +108 -78
  6. package/dist/cell-selection/cell-selection-driver.js +250 -262
  7. package/dist/cell-selection/cell-style-row.d.ts +12 -6
  8. package/dist/cell-selection/cell-style-row.js +82 -79
  9. package/dist/cell-selection/deselect-rect-range.js +41 -40
  10. package/dist/cell-selection/expand-cell-selection-down.d.ts +5 -2
  11. package/dist/cell-selection/expand-cell-selection-down.js +29 -33
  12. package/dist/cell-selection/expand-cell-selection-end.d.ts +5 -2
  13. package/dist/cell-selection/expand-cell-selection-end.js +30 -34
  14. package/dist/cell-selection/expand-cell-selection-start.d.ts +5 -2
  15. package/dist/cell-selection/expand-cell-selection-start.js +29 -33
  16. package/dist/cell-selection/expand-cell-selection-up.d.ts +5 -2
  17. package/dist/cell-selection/expand-cell-selection-up.js +29 -33
  18. package/dist/cell-selection/full-width-start-end-index.js +3 -3
  19. package/dist/cell-selection/get-root-cell.d.ts +5 -1
  20. package/dist/cell-selection/get-root-cell.js +77 -79
  21. package/dist/cell-selection/is-bottom-rect.js +5 -5
  22. package/dist/cell-selection/is-center-col-rect.d.ts +5 -2
  23. package/dist/cell-selection/is-center-col-rect.js +5 -3
  24. package/dist/cell-selection/is-center-rect.js +3 -3
  25. package/dist/cell-selection/is-end-rect.d.ts +5 -2
  26. package/dist/cell-selection/is-end-rect.js +2 -2
  27. package/dist/cell-selection/is-overlapping-rect.js +6 -4
  28. package/dist/cell-selection/is-start-rect.d.ts +5 -2
  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 +12 -6
  33. package/dist/cell-selection/split-cell-selection-rect.js +53 -47
  34. package/dist/cell-selection/update-additive-cell-selection.d.ts +5 -2
  35. package/dist/cell-selection/update-additive-cell-selection.js +18 -19
  36. package/dist/cell-selection/use-edge-scroll.d.ts +8 -6
  37. package/dist/cell-selection/use-edge-scroll.js +65 -63
  38. package/dist/cells/cell-default.d.ts +5 -1
  39. package/dist/cells/cell-default.js +5 -5
  40. package/dist/cells/cell-editor.d.ts +4 -2
  41. package/dist/cells/cell-editor.js +121 -86
  42. package/dist/cells/cell.d.ts +16 -3
  43. package/dist/cells/cell.js +56 -27
  44. package/dist/column-manager/branch-lookup-context.d.ts +3 -1
  45. package/dist/column-manager/branch.d.ts +12 -4
  46. package/dist/column-manager/branch.js +39 -29
  47. package/dist/column-manager/column-manager.d.ts +58 -9
  48. package/dist/column-manager/column-manager.js +9 -9
  49. package/dist/column-manager/context.d.ts +1 -1
  50. package/dist/column-manager/label.d.ts +10 -2
  51. package/dist/column-manager/label.js +11 -12
  52. package/dist/column-manager/leaf.d.ts +10 -2
  53. package/dist/column-manager/leaf.js +42 -32
  54. package/dist/column-manager/move-handle.d.ts +14 -6
  55. package/dist/column-manager/move-handle.js +54 -50
  56. package/dist/column-manager/root.d.ts +9 -3
  57. package/dist/column-manager/root.js +26 -13
  58. package/dist/column-manager/use-column-manager.d.ts +12 -12
  59. package/dist/column-manager/use-column-manager.js +20 -20
  60. package/dist/column-manager/use-columns-from-context.js +18 -18
  61. package/dist/column-manager/visibility-checkbox.d.ts +14 -6
  62. package/dist/column-manager/visibility-checkbox.js +36 -23
  63. package/dist/context.d.ts +4 -4
  64. package/dist/filter-tree/branch.d.ts +13 -5
  65. package/dist/filter-tree/branch.js +23 -13
  66. package/dist/filter-tree/context.d.ts +16 -16
  67. package/dist/filter-tree/filter-tree.d.ts +49 -8
  68. package/dist/filter-tree/filter-tree.js +8 -8
  69. package/dist/filter-tree/hooks/use-filter-tree.d.ts +35 -29
  70. package/dist/filter-tree/hooks/use-filter-tree.js +94 -92
  71. package/dist/filter-tree/hooks/use-tree-item.d.ts +4 -4
  72. package/dist/filter-tree/hooks/use-tree-item.js +99 -106
  73. package/dist/filter-tree/inclusion-checkbox.d.ts +14 -6
  74. package/dist/filter-tree/inclusion-checkbox.js +19 -9
  75. package/dist/filter-tree/label.d.ts +10 -2
  76. package/dist/filter-tree/label.js +11 -12
  77. package/dist/filter-tree/leaf.d.ts +10 -2
  78. package/dist/filter-tree/leaf.js +15 -5
  79. package/dist/filter-tree/root.d.ts +23 -7
  80. package/dist/filter-tree/root.js +51 -23
  81. package/dist/grid-box/+types.d.ts +9 -9
  82. package/dist/grid-box/context.d.ts +3 -3
  83. package/dist/grid-box/grid-box.d.ts +26 -6
  84. package/dist/grid-box/grid-box.js +6 -6
  85. package/dist/grid-box/item.d.ts +11 -3
  86. package/dist/grid-box/item.js +29 -26
  87. package/dist/grid-box/panel.d.ts +13 -1
  88. package/dist/grid-box/panel.js +9 -2
  89. package/dist/grid-box/root.d.ts +11 -5
  90. package/dist/grid-box/root.js +11 -2
  91. package/dist/grid-box/use-aggregation-box-items.d.ts +16 -13
  92. package/dist/grid-box/use-aggregation-box-items.js +54 -55
  93. package/dist/grid-box/use-column-box-items.d.ts +31 -21
  94. package/dist/grid-box/use-column-box-items.js +90 -78
  95. package/dist/grid-box/use-row-group-box-items.d.ts +17 -12
  96. package/dist/grid-box/use-row-group-box-items.js +116 -124
  97. package/dist/grid-provider/context.d.ts +4 -2
  98. package/dist/grid-provider/provider.d.ts +4 -2
  99. package/dist/grid-provider/use-grid.d.ts +1 -1
  100. package/dist/grid.d.ts +150 -26
  101. package/dist/grid.js +38 -26
  102. package/dist/header/header-cell.d.ts +13 -5
  103. package/dist/header/header-cell.js +41 -15
  104. package/dist/header/header-group-cell.d.ts +10 -2
  105. package/dist/header/header-group-cell.js +21 -6
  106. package/dist/header/header-row.d.ts +10 -2
  107. package/dist/header/header-row.js +2 -2
  108. package/dist/header/header.d.ts +10 -1
  109. package/dist/header/header.js +11 -2
  110. package/dist/header/resize-handler.d.ts +15 -6
  111. package/dist/header/resize-handler.js +128 -118
  112. package/dist/header/use-drag-move.d.ts +22 -11
  113. package/dist/header/use-drag-move.js +83 -87
  114. package/dist/header/use-header-cell-renderer.d.ts +9 -2
  115. package/dist/header/use-header-cell-renderer.js +24 -29
  116. package/dist/icons/index.d.ts +92 -1
  117. package/dist/icons/index.js +92 -1
  118. package/dist/license.js +174 -174
  119. package/dist/listbox/context.d.ts +2 -2
  120. package/dist/listbox/item.d.ts +10 -1
  121. package/dist/listbox/item.js +23 -19
  122. package/dist/listbox/panel.d.ts +10 -1
  123. package/dist/listbox/panel.js +69 -43
  124. package/dist/listbox/root.d.ts +5 -3
  125. package/dist/listbox/root.js +7 -7
  126. package/dist/root/dialog-driver.js +22 -16
  127. package/dist/root/popover-driver.js +27 -16
  128. package/dist/root/root.d.ts +7 -3
  129. package/dist/root/root.js +111 -107
  130. package/dist/row-data-source-client/+types.d.ts +17 -17
  131. package/dist/row-data-source-client/built-ins/avg.js +3 -4
  132. package/dist/row-data-source-client/built-ins/built-ins.d.ts +16 -16
  133. package/dist/row-data-source-client/built-ins/built-ins.js +16 -16
  134. package/dist/row-data-source-client/built-ins/count.js +3 -5
  135. package/dist/row-data-source-client/built-ins/first.js +1 -1
  136. package/dist/row-data-source-client/built-ins/group.js +1 -1
  137. package/dist/row-data-source-client/built-ins/last.js +1 -1
  138. package/dist/row-data-source-client/built-ins/max.js +9 -13
  139. package/dist/row-data-source-client/built-ins/min.js +9 -13
  140. package/dist/row-data-source-client/built-ins/sum.js +8 -10
  141. package/dist/row-data-source-client/filter/+types.d.ts +35 -13
  142. package/dist/row-data-source-client/filter/compute-filtered-rows.d.ts +16 -2
  143. package/dist/row-data-source-client/filter/compute-filtered-rows.js +102 -102
  144. package/dist/row-data-source-client/pivots/create-agg-model.d.ts +8 -4
  145. package/dist/row-data-source-client/pivots/create-agg-model.js +8 -9
  146. package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.d.ts +6 -1
  147. package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +42 -46
  148. package/dist/row-data-source-client/pivots/create-pivot-columns.d.ts +6 -1
  149. package/dist/row-data-source-client/pivots/create-pivot-columns.js +16 -17
  150. package/dist/row-data-source-client/pivots/create-pivot-tree.d.ts +7 -1
  151. package/dist/row-data-source-client/pivots/create-pivot-tree.js +19 -19
  152. package/dist/row-data-source-client/tree/client-tree.d.ts +19 -13
  153. package/dist/row-data-source-client/tree/client-tree.js +64 -67
  154. package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +4 -1
  155. package/dist/row-data-source-client/tree/evaluator-aggregation.js +6 -6
  156. package/dist/row-data-source-client/tree/evaluator-group.d.ts +4 -1
  157. package/dist/row-data-source-client/tree/evaluator-group.js +6 -7
  158. package/dist/row-data-source-client/tree/traverse.d.ts +5 -1
  159. package/dist/row-data-source-client/tree/traverse.js +15 -18
  160. package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +9 -5
  161. package/dist/row-data-source-client/use-client-data-source-paginated.js +539 -522
  162. package/dist/row-data-source-client/use-client-data-source.d.ts +9 -5
  163. package/dist/row-data-source-client/use-client-data-source.js +682 -647
  164. package/dist/row-data-source-client/use-client-tree-data-source.d.ts +9 -5
  165. package/dist/row-data-source-client/use-client-tree-data-source.js +510 -499
  166. package/dist/row-data-source-server/async-tree/+types.async-tree.d.ts +36 -33
  167. package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.d.ts +4 -1
  168. package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +18 -22
  169. package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.d.ts +4 -1
  170. package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.js +17 -25
  171. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-unique.js +18 -18
  172. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-valid.js +9 -10
  173. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.d.ts +4 -1
  174. package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.js +13 -14
  175. package/dist/row-data-source-server/async-tree/check-set-action-item-kinds.js +9 -10
  176. package/dist/row-data-source-server/async-tree/get-parent-node-by-path.d.ts +4 -1
  177. package/dist/row-data-source-server/async-tree/get-parent-node-by-path.js +13 -13
  178. package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.d.ts +4 -1
  179. package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.js +1 -1
  180. package/dist/row-data-source-server/async-tree/make-async-tree.js +14 -14
  181. package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.d.ts +3 -1
  182. package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.js +6 -6
  183. package/dist/row-data-source-server/async-tree/maybe-apply-resize.d.ts +5 -1
  184. package/dist/row-data-source-server/async-tree/maybe-apply-resize.js +11 -14
  185. package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.d.ts +4 -1
  186. package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.js +42 -46
  187. package/dist/row-data-source-server/range-tree/range-tree.d.ts +28 -28
  188. package/dist/row-data-source-server/range-tree/range-tree.js +49 -48
  189. package/dist/row-data-source-server/use-server-data-source.d.ts +11 -2
  190. package/dist/row-data-source-server/use-server-data-source.js +665 -652
  191. package/dist/row-data-source-server/utils/get-node-depth.js +7 -7
  192. package/dist/row-data-source-server/utils/get-node-path.js +7 -7
  193. package/dist/row-data-source-server/utils/get-request-id.js +3 -4
  194. package/dist/rows/row/context.d.ts +2 -2
  195. package/dist/rows/row/row.d.ts +16 -3
  196. package/dist/rows/row/row.js +19 -4
  197. package/dist/rows/row/use-row-context-value.d.ts +5 -2
  198. package/dist/rows/row/use-row-context-value.js +23 -26
  199. package/dist/rows/row-detail-row.d.ts +4 -2
  200. package/dist/rows/row-detail-row.js +147 -124
  201. package/dist/rows/row-full-width.d.ts +12 -4
  202. package/dist/rows/row-full-width.js +35 -7
  203. package/dist/rows/rows-container.d.ts +10 -1
  204. package/dist/rows/rows-container.js +12 -3
  205. package/dist/rows/rows-sections.d.ts +30 -3
  206. package/dist/rows/rows-sections.js +42 -10
  207. package/dist/rows/scrollers/native-scroller.d.ts +3 -1
  208. package/dist/rows/scrollers/native-scroller.js +17 -13
  209. package/dist/sort-manager/+types.d.ts +14 -7
  210. package/dist/sort-manager/context.d.ts +4 -4
  211. package/dist/sort-manager/hooks/use-sort-manager.d.ts +9 -9
  212. package/dist/sort-manager/hooks/use-sort-manager.js +45 -49
  213. package/dist/sort-manager/hooks/use-sort-row-item.d.ts +57 -46
  214. package/dist/sort-manager/hooks/use-sort-row-item.js +126 -131
  215. package/dist/sort-manager/hooks/use-sortable-column-items.d.ts +6 -3
  216. package/dist/sort-manager/hooks/use-sortable-column-items.js +10 -10
  217. package/dist/sort-manager/root.d.ts +7 -1
  218. package/dist/sort-manager/root.js +10 -10
  219. package/dist/sort-manager/sort-add.d.ts +13 -5
  220. package/dist/sort-manager/sort-add.js +8 -8
  221. package/dist/sort-manager/sort-apply.d.ts +12 -4
  222. package/dist/sort-manager/sort-apply.js +16 -16
  223. package/dist/sort-manager/sort-cancel.d.ts +12 -4
  224. package/dist/sort-manager/sort-cancel.js +19 -19
  225. package/dist/sort-manager/sort-clear.d.ts +12 -4
  226. package/dist/sort-manager/sort-clear.js +15 -16
  227. package/dist/sort-manager/sort-column-select.d.ts +14 -6
  228. package/dist/sort-manager/sort-column-select.js +26 -15
  229. package/dist/sort-manager/sort-direction-select.d.ts +14 -6
  230. package/dist/sort-manager/sort-direction-select.js +27 -19
  231. package/dist/sort-manager/sort-manager.d.ts +93 -12
  232. package/dist/sort-manager/sort-manager.js +12 -12
  233. package/dist/sort-manager/sort-remove.d.ts +12 -4
  234. package/dist/sort-manager/sort-remove.js +8 -8
  235. package/dist/sort-manager/sort-row.d.ts +10 -2
  236. package/dist/sort-manager/sort-row.js +4 -1
  237. package/dist/sort-manager/sort-rows.d.ts +10 -1
  238. package/dist/sort-manager/sort-rows.js +1 -1
  239. package/dist/sort-manager/sort-value-select.d.ts +15 -7
  240. package/dist/sort-manager/sort-value-select.js +28 -19
  241. package/dist/sort-manager/utils/sort-item-to-sort-model.d.ts +4 -1
  242. package/dist/sort-manager/utils/sort-item-to-sort-model.js +46 -49
  243. package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +4 -1
  244. package/dist/sort-manager/utils/sort-model-to-sort-items.js +36 -44
  245. package/dist/state/+types.d.ts +41 -28
  246. package/dist/state/api/column-autosize.d.ts +4 -2
  247. package/dist/state/api/column-autosize.js +62 -63
  248. package/dist/state/api/column-by-id.js +4 -4
  249. package/dist/state/api/column-field.js +17 -20
  250. package/dist/state/api/column-from-index.js +4 -4
  251. package/dist/state/api/column-group-toggle.js +8 -8
  252. package/dist/state/api/column-index.js +5 -5
  253. package/dist/state/api/column-move.js +48 -46
  254. package/dist/state/api/column-resize.js +9 -7
  255. package/dist/state/api/column-update.js +11 -11
  256. package/dist/state/api/dialog-frame.d.ts +8 -4
  257. package/dist/state/api/dialog-frame.js +11 -12
  258. package/dist/state/api/edit-begin.d.ts +4 -2
  259. package/dist/state/api/edit-begin.js +71 -84
  260. package/dist/state/api/edit-end.d.ts +4 -2
  261. package/dist/state/api/edit-end.js +38 -41
  262. package/dist/state/api/edit-is-cell-active.d.ts +4 -2
  263. package/dist/state/api/edit-is-cell-active.js +17 -24
  264. package/dist/state/api/edit-update.d.ts +4 -2
  265. package/dist/state/api/edit-update.js +74 -85
  266. package/dist/state/api/event-listeners.d.ts +12 -3
  267. package/dist/state/api/event-listeners.js +16 -17
  268. package/dist/state/api/export-csv.js +33 -35
  269. package/dist/state/api/export-data-rect.js +21 -21
  270. package/dist/state/api/focus-cell.d.ts +4 -2
  271. package/dist/state/api/focus-cell.js +110 -109
  272. package/dist/state/api/popover-frame.d.ts +8 -4
  273. package/dist/state/api/popover-frame.js +11 -12
  274. package/dist/state/api/position-from-element.js +5 -6
  275. package/dist/state/api/row-by-id.js +3 -3
  276. package/dist/state/api/row-by-index.js +11 -6
  277. package/dist/state/api/row-detail-is-expanded.d.ts +3 -1
  278. package/dist/state/api/row-detail-is-expanded.js +4 -4
  279. package/dist/state/api/row-detail-rendered-height.d.ts +4 -2
  280. package/dist/state/api/row-detail-rendered-height.js +10 -12
  281. package/dist/state/api/row-detail-toggle.js +26 -30
  282. package/dist/state/api/row-group-apply-expansions.d.ts +3 -1
  283. package/dist/state/api/row-group-apply-expansions.js +15 -17
  284. package/dist/state/api/row-group-column-index.d.ts +3 -1
  285. package/dist/state/api/row-group-column-index.js +14 -12
  286. package/dist/state/api/row-group-is-expanded.d.ts +3 -1
  287. package/dist/state/api/row-group-is-expanded.js +11 -13
  288. package/dist/state/api/row-group-toggle.js +5 -5
  289. package/dist/state/api/row-handle-select.d.ts +4 -2
  290. package/dist/state/api/row-handle-select.js +36 -40
  291. package/dist/state/api/row-select-all.js +14 -15
  292. package/dist/state/api/row-select.d.ts +4 -2
  293. package/dist/state/api/row-select.js +30 -33
  294. package/dist/state/api/row-selected.js +10 -11
  295. package/dist/state/api/scroll-into-view.d.ts +4 -2
  296. package/dist/state/api/scroll-into-view.js +47 -47
  297. package/dist/state/api/sort-for-column.js +6 -7
  298. package/dist/state/api/use-row-drag.js +22 -24
  299. package/dist/state/helpers/cell-row-group.d.ts +5 -1
  300. package/dist/state/helpers/cell-row-group.js +18 -16
  301. package/dist/state/helpers/column-add-row-group.d.ts +16 -6
  302. package/dist/state/helpers/column-add-row-group.js +63 -58
  303. package/dist/state/helpers/column-layout.d.ts +7 -1
  304. package/dist/state/helpers/column-layout.js +60 -60
  305. package/dist/state/helpers/column-marker.d.ts +8 -4
  306. package/dist/state/helpers/column-marker.js +38 -34
  307. package/dist/state/helpers/column-view.d.ts +21 -15
  308. package/dist/state/helpers/column-view.js +56 -32
  309. package/dist/state/helpers/edit-on-change.d.ts +18 -10
  310. package/dist/state/helpers/edit-on-change.js +24 -24
  311. package/dist/state/helpers/empty-row-data-source.js +16 -16
  312. package/dist/state/helpers/get-data-rect.d.ts +20 -10
  313. package/dist/state/helpers/get-data-rect.js +67 -62
  314. package/dist/state/helpers/get-full-width-callback.d.ts +5 -1
  315. package/dist/state/helpers/get-full-width-callback.js +5 -6
  316. package/dist/state/helpers/get-span-callback.d.ts +6 -1
  317. package/dist/state/helpers/get-span-callback.js +15 -18
  318. package/dist/state/helpers/resolve-column.d.ts +6 -2
  319. package/dist/state/helpers/resolve-column.js +18 -18
  320. package/dist/state/helpers/row-layout/get-focus-criteria.d.ts +15 -12
  321. package/dist/state/helpers/row-layout/get-focus-criteria.js +57 -56
  322. package/dist/state/helpers/row-layout/row-layout.d.ts +15 -9
  323. package/dist/state/helpers/row-layout/row-layout.js +387 -401
  324. package/dist/state/use-lytenyte.js +556 -516
  325. package/dist/tree-view/branch/branch.d.ts +16 -8
  326. package/dist/tree-view/branch/branch.js +104 -52
  327. package/dist/tree-view/branch/use-branch-keys.d.ts +5 -1
  328. package/dist/tree-view/branch/use-branch-keys.js +71 -74
  329. package/dist/tree-view/context.d.ts +21 -17
  330. package/dist/tree-view/hooks/use-tree-view-paths.d.ts +6 -1
  331. package/dist/tree-view/hooks/use-tree-view-paths.js +5 -5
  332. package/dist/tree-view/index.d.ts +35 -7
  333. package/dist/tree-view/index.js +7 -7
  334. package/dist/tree-view/leaf.d.ts +10 -2
  335. package/dist/tree-view/leaf.js +29 -20
  336. package/dist/tree-view/navigation/get-all-ids.js +3 -3
  337. package/dist/tree-view/navigation/get-first-node.js +3 -3
  338. package/dist/tree-view/navigation/get-last-node.js +3 -3
  339. package/dist/tree-view/navigation/get-next-node.js +6 -8
  340. package/dist/tree-view/navigation/get-prev-node.js +6 -8
  341. package/dist/tree-view/panel/make-handle-navigation.js +23 -31
  342. package/dist/tree-view/panel/make-handle-selection.js +68 -77
  343. package/dist/tree-view/panel/make-handle-typeahead.js +34 -40
  344. package/dist/tree-view/panel/panel.d.ts +10 -1
  345. package/dist/tree-view/panel/panel.js +40 -20
  346. package/dist/tree-view/panel/use-tree-navigation.js +64 -52
  347. package/dist/tree-view/root.d.ts +20 -14
  348. package/dist/tree-view/root.js +53 -55
  349. package/dist/tree-view/utils/get-focusable-nodes.js +4 -2
  350. package/dist/tree-view/utils/get-focused-node.js +11 -11
  351. package/dist/tree-view/utils/get-ids-between-nodes.d.ts +5 -1
  352. package/dist/tree-view/utils/get-ids-between-nodes.js +10 -11
  353. package/dist/tree-view/utils/get-panel.js +5 -5
  354. package/dist/tree-view/utils/get-parent-node.js +6 -7
  355. package/dist/tree-view/utils/get-sibling-branches.js +8 -10
  356. package/dist/tree-view/utils/get-tree-node-id.js +1 -1
  357. package/dist/tree-view/utils/is-branch-node.js +1 -1
  358. package/dist/tree-view/utils/is-leaf-node.js +1 -1
  359. package/dist/tree-view/utils/is-tree-node-disabled.js +1 -1
  360. package/dist/tree-view/utils/select-node.d.ts +5 -1
  361. package/dist/tree-view/utils/select-node.js +8 -11
  362. package/dist/tree-view/utils/toggle-all-selections.js +4 -6
  363. package/dist/tree-view/utils/toggle-selection.js +15 -18
  364. package/dist/tree-view/virtualized/force-sync-scrolling.d.ts +3 -1
  365. package/dist/tree-view/virtualized/force-sync-scrolling.js +24 -18
  366. package/dist/tree-view/virtualized/get-virtual-tree-paths.d.ts +3 -1
  367. package/dist/tree-view/virtualized/get-virtual-tree-paths.js +11 -12
  368. package/dist/tree-view/virtualized/make-virtual-tree.d.ts +26 -21
  369. package/dist/tree-view/virtualized/make-virtual-tree.js +79 -85
  370. package/dist/tree-view/virtualized/use-flattened-tree.d.ts +17 -8
  371. package/dist/tree-view/virtualized/use-flattened-tree.js +30 -31
  372. package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +6 -1
  373. package/dist/tree-view/virtualized/use-row-start-and-end.js +21 -23
  374. package/dist/tree-view/virtualized/use-virtualized-tree.d.ts +21 -15
  375. package/dist/tree-view/virtualized/use-virtualized-tree.js +103 -90
  376. package/dist/utils/cycle-sorts.js +12 -14
  377. package/dist/viewport/begin-editing.d.ts +6 -2
  378. package/dist/viewport/begin-editing.js +9 -13
  379. package/dist/viewport/viewport.d.ts +10 -1
  380. package/dist/viewport/viewport.js +93 -70
  381. package/package.json +7 -7
@@ -2,528 +2,539 @@ 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 { dateComparator, makeGridAtom, numberComparator, stringComparator, } from "@1771technologies/lytenyte-shared";
5
+ import {
6
+ dateComparator,
7
+ makeGridAtom,
8
+ numberComparator,
9
+ stringComparator,
10
+ } from "@1771technologies/lytenyte-shared";
6
11
  import { equal } from "@1771technologies/lytenyte-js-utils";
7
12
  import { makeClientTree } from "./tree/client-tree.js";
8
13
  import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
9
14
  import { builtIns } from "./built-ins/built-ins.js";
10
15
  export function makeClientTreeDataSource(p) {
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 };
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],
82
33
  });
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;
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
+ ),
133
91
  };
134
- return comparator;
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 };
135
101
  });
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;
102
+ return makeClientTree({
103
+ rowData: filtered,
104
+ rowAggModel: grid ? rowAggModel : [],
105
+ rowBranchModel: p.getPathFromData,
106
+ rowIdGroup: p.rowIdBranch,
107
+ rowIdLeaf: p.rowIdLeaf,
142
108
  });
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 };
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);
180
155
  });
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
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, () => {
189
210
  const centerCount = rdsStore.get(flatLength);
190
211
  store.rowCenterCount.set(centerCount);
191
- cleanup.push(rdsStore.sub(flatLength, () => {
192
- const centerCount = rdsStore.get(flatLength);
193
- store.rowCenterCount.set(centerCount);
194
- grid.state.rowDataStore.rowClearCache();
195
- }));
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, () => {
196
219
  const top = rdsStore.get(topData).length;
197
220
  store.rowTopCount.set(top);
198
- cleanup.push(rdsStore.sub(topData, () => {
199
- const top = rdsStore.get(topData).length;
200
- store.rowTopCount.set(top);
201
- grid.state.rowDataStore.rowClearCache();
202
- }));
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();
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(),
209
289
  }));
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,
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;
225
407
  });
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) => {
287
408
  const grid = rdsStore.get(grid$);
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;
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));
423
+ });
424
+ 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));
309
480
  }
481
+ if (row?.id) ids.add(row.id);
482
+ }
310
483
  }
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;
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
+ }
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;
331
500
  }
332
- return null;
333
- };
334
- const rowAllChildIds = (rowId) => {
335
501
  const t = rdsStore.get(tree);
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
- });
502
+ grid.state.rowSelectedIds.set(new Set(t.idsAll));
503
+ },
504
+ rowAreAllSelected: (rowId) => {
505
+ const g = rdsStore.get(grid$);
506
+ if (!g) return false;
507
+ const selected = g.state.rowSelectedIds.get();
508
+ if (rowId) {
509
+ const row = rowById(rowId);
510
+ if (!row) return false;
511
+ const childIds = new Set(rowAllChildIds(rowId));
512
+ return childIds.isSubsetOf(selected);
342
513
  }
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
- rowAreAllSelected: (rowId) => {
490
- const g = rdsStore.get(grid$);
491
- if (!g)
492
- return false;
493
- const selected = g.state.rowSelectedIds.get();
494
- if (rowId) {
495
- const row = rowById(rowId);
496
- if (!row)
497
- return false;
498
- const childIds = new Set(rowAllChildIds(rowId));
499
- return childIds.isSubsetOf(selected);
500
- }
501
- const f = rdsStore.get(tree);
502
- return f.idsAll.isSubsetOf(selected);
503
- },
504
- },
505
- {
506
- top: makeGridAtom(topData, rdsStore),
507
- center: makeGridAtom(data, rdsStore),
508
- bottom: makeGridAtom(bottomData, rdsStore),
509
- },
510
- ];
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
+ ];
511
524
  }
512
525
  export function useClientTreeDataSource(p) {
513
- const ds = useRef(null);
514
- const dataAtomRef = useRef(null);
515
- if (!ds.current)
516
- [ds.current, dataAtomRef.current] = makeClientTreeDataSource(p);
517
- const da = dataAtomRef.current;
518
- if (p.reflectData) {
519
- // Need to queue the microtask since it we cannot update state during render.
520
- if (p.data !== da.center.get())
521
- queueMicrotask(() => ds.current.rowSetCenterData(p.data));
522
- if (!equal(p.topData ?? [], da.top.get())) {
523
- queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
524
- }
525
- if (!equal(p.bottomData ?? [], da.bottom.get()))
526
- queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
526
+ const ds = useRef(null);
527
+ const dataAtomRef = useRef(null);
528
+ if (!ds.current) [ds.current, dataAtomRef.current] = makeClientTreeDataSource(p);
529
+ const da = dataAtomRef.current;
530
+ if (p.reflectData) {
531
+ // Need to queue the microtask since it we cannot update state during render.
532
+ if (p.data !== da.center.get()) queueMicrotask(() => ds.current.rowSetCenterData(p.data));
533
+ if (!equal(p.topData ?? [], da.top.get())) {
534
+ queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
527
535
  }
528
- return ds.current;
536
+ if (!equal(p.bottomData ?? [], da.bottom.get()))
537
+ queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
538
+ }
539
+ return ds.current;
529
540
  }