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

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