@viewkitjs/views 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/CHANGELOG.md +767 -1
  2. package/README.md +92 -41
  3. package/dist/atoms/LoadMore.js +11 -1
  4. package/dist/atoms/Row.js +1 -1
  5. package/dist/atoms/RowMenu.d.ts +1 -1
  6. package/dist/atoms/RowMenu.js +20 -6
  7. package/dist/atoms/types.d.ts +4 -4
  8. package/dist/cells/cell-format.d.ts +3 -3
  9. package/dist/cells/cell-title.d.ts +1 -2
  10. package/dist/cells/cell-title.js +2 -2
  11. package/dist/cells/cell-values.js +6 -3
  12. package/dist/contract.d.ts +79 -8
  13. package/dist/contract.js +55 -8
  14. package/dist/display/converted.d.ts +19 -0
  15. package/dist/display/converted.js +12 -0
  16. package/dist/display/format.d.ts +16 -1
  17. package/dist/display/format.js +10 -1
  18. package/dist/display/index.d.ts +2 -1
  19. package/dist/display/index.js +2 -1
  20. package/dist/display/link-click.d.ts +11 -0
  21. package/dist/display/link-click.js +3 -0
  22. package/dist/display/link.js +12 -6
  23. package/dist/display/location.d.ts +4 -3
  24. package/dist/display/location.js +12 -5
  25. package/dist/display/multi-value.d.ts +1 -1
  26. package/dist/display/multi-value.js +1 -1
  27. package/dist/display/options.d.ts +8 -2
  28. package/dist/display/percent.js +10 -3
  29. package/dist/display/phone.d.ts +2 -1
  30. package/dist/display/phone.js +11 -2
  31. package/dist/display/relation.js +1 -1
  32. package/dist/editors/ChipsEditor.d.ts +9 -4
  33. package/dist/editors/ChipsEditor.js +7 -3
  34. package/dist/editors/DateEditor.d.ts +21 -6
  35. package/dist/editors/DateEditor.js +118 -30
  36. package/dist/editors/EditorPanel.d.ts +61 -0
  37. package/dist/editors/EditorPanel.js +54 -0
  38. package/dist/editors/LocationEditor.d.ts +3 -0
  39. package/dist/editors/LocationEditor.js +28 -21
  40. package/dist/editors/NameEditor.d.ts +3 -0
  41. package/dist/editors/NameEditor.js +15 -10
  42. package/dist/editors/NumberEditor.d.ts +3 -0
  43. package/dist/editors/NumberEditor.js +7 -7
  44. package/dist/editors/RangeEditor.d.ts +16 -1
  45. package/dist/editors/RangeEditor.js +22 -6
  46. package/dist/editors/RelationEditor.d.ts +13 -28
  47. package/dist/editors/RelationEditor.js +17 -40
  48. package/dist/editors/RelationSetEditor.d.ts +53 -0
  49. package/dist/editors/RelationSetEditor.js +112 -0
  50. package/dist/editors/SelectEditor.d.ts +21 -3
  51. package/dist/editors/SelectEditor.js +55 -9
  52. package/dist/editors/TextEditor.d.ts +51 -0
  53. package/dist/editors/TextEditor.js +81 -0
  54. package/dist/editors/ValueListEditor.d.ts +5 -2
  55. package/dist/editors/ValueListEditor.js +11 -9
  56. package/dist/editors/edit-cores.d.ts +13 -10
  57. package/dist/editors/edit-cores.js +7 -6
  58. package/dist/editors/edit-session.d.ts +21 -11
  59. package/dist/editors/edit-session.js +19 -5
  60. package/dist/editors/keep-inside.d.ts +12 -0
  61. package/dist/editors/keep-inside.js +20 -0
  62. package/dist/editors/open-value.d.ts +21 -0
  63. package/dist/editors/open-value.js +36 -0
  64. package/dist/editors/open-values.d.ts +4 -0
  65. package/dist/editors/open-values.js +7 -0
  66. package/dist/editors/relation-kinds.d.ts +7 -0
  67. package/dist/editors/relation-kinds.js +21 -0
  68. package/dist/editors/relation-panel.d.ts +69 -0
  69. package/dist/editors/relation-panel.js +40 -0
  70. package/dist/field-row/FieldNoteLine.d.ts +14 -0
  71. package/dist/field-row/FieldNoteLine.js +14 -0
  72. package/dist/field-row/FieldRow.d.ts +73 -0
  73. package/dist/field-row/FieldRow.js +157 -0
  74. package/dist/field-row/FieldRowLane.d.ts +19 -0
  75. package/dist/field-row/FieldRowLane.js +11 -0
  76. package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
  77. package/dist/field-row/editors/RowChipsEditor.js +25 -0
  78. package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
  79. package/dist/field-row/editors/RowDateEditor.js +18 -0
  80. package/dist/field-row/editors/RowEditor.d.ts +39 -0
  81. package/dist/field-row/editors/RowEditor.js +64 -0
  82. package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
  83. package/dist/field-row/editors/RowNameEditor.js +15 -0
  84. package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
  85. package/dist/field-row/editors/RowNumberEditor.js +18 -0
  86. package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
  87. package/dist/field-row/editors/RowPlaceEditor.js +18 -0
  88. package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
  89. package/dist/field-row/editors/RowRangeEditor.js +15 -0
  90. package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
  91. package/dist/field-row/editors/RowRelationEditor.js +77 -0
  92. package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
  93. package/dist/field-row/editors/RowSelectEditor.js +23 -0
  94. package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
  95. package/dist/field-row/editors/RowTextEditor.js +16 -0
  96. package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
  97. package/dist/field-row/editors/RowValueListEditor.js +21 -0
  98. package/dist/field-row/editors/host.d.ts +59 -0
  99. package/dist/field-row/editors/host.js +1 -0
  100. package/dist/field-row/editors/row-session.d.ts +49 -0
  101. package/dist/field-row/editors/row-session.js +49 -0
  102. package/dist/field-row/index.d.ts +5 -0
  103. package/dist/field-row/index.js +5 -0
  104. package/dist/field-row/row-target.d.ts +20 -0
  105. package/dist/field-row/row-target.js +3 -0
  106. package/dist/field-row/useFieldWrite.d.ts +45 -0
  107. package/dist/field-row/useFieldWrite.js +190 -0
  108. package/dist/field-row/useRowSettlement.d.ts +33 -0
  109. package/dist/field-row/useRowSettlement.js +23 -0
  110. package/dist/fields/binding.d.ts +7 -2
  111. package/dist/fields/binding.js +13 -6
  112. package/dist/fields/currency.d.ts +0 -10
  113. package/dist/fields/currency.js +0 -14
  114. package/dist/fields/edit-core-types.d.ts +9 -9
  115. package/dist/fields/edit-core-types.js +6 -6
  116. package/dist/fields/money.d.ts +6 -0
  117. package/dist/fields/money.js +11 -0
  118. package/dist/fields/number-edit.d.ts +6 -0
  119. package/dist/fields/number-edit.js +4 -0
  120. package/dist/fields/prepare-write.js +6 -1
  121. package/dist/fields/relation-source-types.d.ts +12 -0
  122. package/dist/fields/write-target.d.ts +50 -0
  123. package/dist/fields/write-target.js +10 -0
  124. package/dist/filters/filter-model.d.ts +0 -1
  125. package/dist/filters/registry.d.ts +3 -36
  126. package/dist/filters/registry.js +0 -38
  127. package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
  128. package/dist/grid/chrome/GridAddColumn.js +29 -0
  129. package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
  130. package/dist/grid/chrome/GridAggregateMenu.js +29 -0
  131. package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
  132. package/dist/grid/chrome/GridCellEditors.js +126 -0
  133. package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
  134. package/dist/grid/chrome/GridCellOutline.js +16 -0
  135. package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
  136. package/dist/grid/chrome/GridChipsEditor.js +35 -0
  137. package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
  138. package/dist/grid/chrome/GridColumnColorSection.js +40 -0
  139. package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
  140. package/dist/grid/chrome/GridColumnDateSection.js +23 -0
  141. package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
  142. package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
  143. package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
  144. package/dist/grid/chrome/GridColumnMenu.js +103 -0
  145. package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
  146. package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
  147. package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
  148. package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
  149. package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
  150. package/dist/grid/chrome/GridColumnSortSection.js +16 -0
  151. package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
  152. package/dist/grid/chrome/GridDateEditor.js +19 -0
  153. package/dist/grid/chrome/GridFlyout.d.ts +44 -0
  154. package/dist/grid/chrome/GridFlyout.js +80 -0
  155. package/dist/grid/chrome/GridFooter.d.ts +33 -0
  156. package/dist/grid/chrome/GridFooter.js +85 -0
  157. package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
  158. package/dist/grid/chrome/GridGroupMenu.js +64 -0
  159. package/dist/grid/chrome/GridHeader.d.ts +66 -0
  160. package/dist/grid/chrome/GridHeader.js +42 -0
  161. package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
  162. package/dist/grid/chrome/GridLongTextEditor.js +69 -0
  163. package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
  164. package/dist/grid/chrome/GridMenuRow.js +15 -0
  165. package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
  166. package/dist/grid/chrome/GridNameEditor.js +21 -0
  167. package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
  168. package/dist/grid/chrome/GridNumberEditor.js +51 -0
  169. package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
  170. package/dist/grid/chrome/GridPlaceEditor.js +22 -0
  171. package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
  172. package/dist/grid/chrome/GridRangeEditor.js +21 -0
  173. package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
  174. package/dist/grid/chrome/GridRelationEditor.js +92 -0
  175. package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
  176. package/dist/grid/chrome/GridResizeHandle.js +19 -0
  177. package/dist/grid/chrome/GridRow.d.ts +31 -0
  178. package/dist/grid/chrome/GridRow.js +179 -0
  179. package/dist/grid/chrome/GridRowActions.d.ts +32 -0
  180. package/dist/grid/chrome/GridRowActions.js +25 -0
  181. package/dist/grid/chrome/GridRowCells.d.ts +4 -0
  182. package/dist/grid/chrome/GridRowCells.js +128 -0
  183. package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
  184. package/dist/grid/chrome/GridRowGlyph.js +13 -0
  185. package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
  186. package/dist/grid/chrome/GridSelectEditor.js +43 -0
  187. package/dist/grid/chrome/GridStructure.d.ts +47 -0
  188. package/dist/grid/chrome/GridStructure.js +41 -0
  189. package/dist/grid/chrome/GridTable.d.ts +4 -0
  190. package/dist/grid/chrome/GridTable.js +192 -0
  191. package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
  192. package/dist/grid/chrome/GridTableSurface.js +15 -0
  193. package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
  194. package/dist/grid/chrome/GridTextEditor.js +38 -0
  195. package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
  196. package/dist/grid/chrome/GridValueListEditor.js +19 -0
  197. package/dist/grid/chrome/StuckMarker.d.ts +16 -0
  198. package/dist/grid/chrome/StuckMarker.js +34 -0
  199. package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
  200. package/dist/grid/chrome/cell-clipboard.js +28 -0
  201. package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
  202. package/dist/grid/chrome/cell-cut-off.js +20 -0
  203. package/dist/grid/chrome/cells.d.ts +21 -0
  204. package/dist/grid/chrome/cells.js +19 -0
  205. package/dist/grid/chrome/checks.d.ts +32 -0
  206. package/dist/grid/chrome/checks.js +32 -0
  207. package/dist/grid/chrome/column-glyph.d.ts +14 -0
  208. package/dist/grid/chrome/column-glyph.js +44 -0
  209. package/dist/grid/chrome/editors.d.ts +9 -0
  210. package/dist/grid/chrome/editors.js +10 -0
  211. package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
  212. package/dist/grid/chrome/grid-cell-classes.js +32 -0
  213. package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
  214. package/dist/grid/chrome/grid-cell-link.js +9 -0
  215. package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
  216. package/dist/grid/chrome/grid-edit-session.js +118 -0
  217. package/dist/grid/chrome/grid-hover.d.ts +60 -0
  218. package/dist/grid/chrome/grid-hover.js +81 -0
  219. package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
  220. package/dist/grid/chrome/grid-menu-focus.js +93 -0
  221. package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
  222. package/dist/grid/chrome/grid-menu-search.js +7 -0
  223. package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
  224. package/dist/grid/chrome/grid-row-menu-key.js +36 -0
  225. package/dist/grid/chrome/grid-row-props.d.ts +143 -0
  226. package/dist/grid/chrome/grid-row-props.js +1 -0
  227. package/dist/grid/chrome/grid-row-window.d.ts +61 -0
  228. package/dist/grid/chrome/grid-row-window.js +212 -0
  229. package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
  230. package/dist/grid/chrome/grid-scroll-owner.js +75 -0
  231. package/dist/grid/chrome/grid-styles.d.ts +40 -0
  232. package/dist/grid/chrome/grid-styles.js +9 -0
  233. package/dist/grid/chrome/grid-table-props.d.ts +172 -0
  234. package/dist/grid/chrome/grid-table-props.js +1 -0
  235. package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
  236. package/dist/grid/chrome/useGridBatchApi.js +35 -0
  237. package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
  238. package/dist/grid/chrome/useGridColumnLayout.js +206 -0
  239. package/dist/grid/chrome/useGridFocus.d.ts +45 -0
  240. package/dist/grid/chrome/useGridFocus.js +122 -0
  241. package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
  242. package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
  243. package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
  244. package/dist/grid/chrome/useGridKeyboard.js +450 -0
  245. package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
  246. package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
  247. package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
  248. package/dist/grid/chrome/useGridRailReveal.js +67 -0
  249. package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
  250. package/dist/grid/chrome/useGridRangeActions.js +195 -0
  251. package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
  252. package/dist/grid/chrome/useGridRangeGestures.js +237 -0
  253. package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
  254. package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
  255. package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
  256. package/dist/grid/chrome/useGridScaleStyles.js +28 -0
  257. package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
  258. package/dist/grid/chrome/useGridScrollArea.js +65 -0
  259. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
  260. package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
  261. package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
  262. package/dist/grid/chrome/useGridTableSelection.js +55 -0
  263. package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
  264. package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
  265. package/dist/grid/core/clipboard-model.d.ts +83 -0
  266. package/dist/grid/core/clipboard-model.js +291 -0
  267. package/dist/grid/core/column-values.d.ts +27 -0
  268. package/dist/grid/core/column-values.js +76 -0
  269. package/dist/grid/core/commit-model.d.ts +41 -0
  270. package/dist/grid/core/commit-model.js +3 -0
  271. package/dist/grid/core/coordinates.d.ts +48 -0
  272. package/dist/grid/core/coordinates.js +27 -0
  273. package/dist/grid/core/edge-scroll.d.ts +21 -0
  274. package/dist/grid/core/edge-scroll.js +23 -0
  275. package/dist/grid/core/edit-values.d.ts +9 -0
  276. package/dist/grid/core/edit-values.js +1 -0
  277. package/dist/grid/core/editing-controller.d.ts +60 -0
  278. package/dist/grid/core/editing-controller.js +266 -0
  279. package/dist/grid/core/editing-model.d.ts +87 -0
  280. package/dist/grid/core/editing-model.js +148 -0
  281. package/dist/grid/core/flat-rows.d.ts +35 -0
  282. package/dist/grid/core/flat-rows.js +20 -0
  283. package/dist/grid/core/grid-aria.d.ts +27 -0
  284. package/dist/grid/core/grid-aria.js +39 -0
  285. package/dist/grid/core/grid-focus.d.ts +54 -0
  286. package/dist/grid/core/grid-focus.js +148 -0
  287. package/dist/grid/core/grid-scale.d.ts +14 -0
  288. package/dist/grid/core/grid-scale.js +8 -0
  289. package/dist/grid/core/nav.d.ts +94 -0
  290. package/dist/grid/core/nav.js +92 -0
  291. package/dist/grid/core/pending-reconciliation.d.ts +53 -0
  292. package/dist/grid/core/pending-reconciliation.js +51 -0
  293. package/dist/grid/core/range-model.d.ts +25 -0
  294. package/dist/grid/core/range-model.js +59 -0
  295. package/dist/grid/core/row-window.d.ts +40 -0
  296. package/dist/grid/core/row-window.js +43 -0
  297. package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
  298. package/dist/grid/core/spreadsheet-operations.js +280 -0
  299. package/dist/grid/core/useGridEditing.d.ts +46 -0
  300. package/dist/grid/core/useGridEditing.js +93 -0
  301. package/dist/grid/core/useGridRange.d.ts +20 -0
  302. package/dist/grid/core/useGridRange.js +24 -0
  303. package/dist/grid/core/value-equality.d.ts +54 -0
  304. package/dist/grid/core/value-equality.js +80 -0
  305. package/dist/grid/index.d.ts +18 -0
  306. package/dist/grid/index.js +5 -0
  307. package/dist/grid/useGridTablePrefs.d.ts +49 -0
  308. package/dist/grid/useGridTablePrefs.js +99 -0
  309. package/dist/index.d.ts +1 -1
  310. package/dist/index.js +1 -1
  311. package/dist/internal/viewport.d.ts +3 -0
  312. package/dist/internal/viewport.js +15 -0
  313. package/dist/model/column-capabilities.d.ts +3 -2
  314. package/dist/model/column-capabilities.js +28 -8
  315. package/dist/model/column-from.js +3 -0
  316. package/dist/model/column-inspect.d.ts +10 -2
  317. package/dist/model/column-inspect.js +9 -0
  318. package/dist/model/column-schema.d.ts +6 -1
  319. package/dist/model/column-state.d.ts +1 -1
  320. package/dist/model/column-types.d.ts +3 -1
  321. package/dist/model/column-types.js +1 -1
  322. package/dist/model/density.js +3 -3
  323. package/dist/model/filter-capabilities.d.ts +1 -1
  324. package/dist/model/filter-capabilities.js +1 -1
  325. package/dist/model/index.d.ts +4 -6
  326. package/dist/model/index.js +0 -1
  327. package/dist/model/preferences.d.ts +7 -7
  328. package/dist/model/preferences.js +0 -1
  329. package/dist/model/prefs-buckets.d.ts +0 -1
  330. package/dist/model/prefs-buckets.js +0 -3
  331. package/dist/model/render-count.d.ts +6 -0
  332. package/dist/model/render-count.js +11 -0
  333. package/dist/provider/ViewsProvider.d.ts +6 -2
  334. package/dist/provider/ViewsProvider.js +12 -2
  335. package/dist/provider/components.d.ts +35 -9
  336. package/dist/provider/components.js +4 -2
  337. package/dist/provider/context.d.ts +8 -4
  338. package/dist/provider/desktop.d.ts +9 -0
  339. package/dist/provider/desktop.js +22 -0
  340. package/dist/provider/menu-groups.d.ts +8 -0
  341. package/dist/provider/menu-groups.js +38 -0
  342. package/dist/provider/plain-input.d.ts +8 -0
  343. package/dist/provider/plain-input.js +5 -0
  344. package/dist/provider/ports.d.ts +22 -0
  345. package/dist/provider/ports.js +1 -0
  346. package/dist/react.d.ts +3 -2
  347. package/dist/react.js +1 -0
  348. package/dist/selection/SelectCheckbox.d.ts +3 -1
  349. package/dist/selection/SelectCheckbox.js +2 -2
  350. package/dist/selection/useCheckDragSelect.js +6 -5
  351. package/docs/contract.md +202 -72
  352. package/docs/getting-started.md +250 -0
  353. package/docs/guides/atoms.md +245 -0
  354. package/docs/guides/cells.md +302 -0
  355. package/docs/guides/columns.md +413 -0
  356. package/docs/guides/display.md +204 -0
  357. package/docs/guides/editors.md +462 -0
  358. package/docs/guides/ports.md +246 -0
  359. package/docs/guides/selection.md +270 -0
  360. package/docs/guides/the-grid.md +696 -0
  361. package/docs/guides/the-provider.md +448 -0
  362. package/docs/index.md +52 -0
  363. package/docs/install.md +9 -47
  364. package/docs/reference/cells.md +28 -0
  365. package/docs/reference/display.md +44 -0
  366. package/docs/reference/editors-chips.md +6 -0
  367. package/docs/reference/editors-date.md +6 -0
  368. package/docs/reference/editors-location.md +10 -0
  369. package/docs/reference/editors-name.md +6 -0
  370. package/docs/reference/editors-number.md +11 -0
  371. package/docs/reference/editors-open-values.md +10 -0
  372. package/docs/reference/editors-panel.md +12 -0
  373. package/docs/reference/editors-range.md +6 -0
  374. package/docs/reference/editors-relation.md +12 -0
  375. package/docs/reference/editors-select.md +9 -0
  376. package/docs/reference/editors-session.md +11 -0
  377. package/docs/reference/editors-text.md +9 -0
  378. package/docs/reference/editors-value-list.md +6 -0
  379. package/docs/reference/editors.md +5 -0
  380. package/docs/reference/field-row.md +16 -0
  381. package/docs/reference/grid.md +39 -0
  382. package/docs/reference/react.md +89 -0
  383. package/docs/reference/selection.md +33 -0
  384. package/docs/reference/views.md +622 -0
  385. package/package.json +27 -4
  386. package/skills/views/SKILL.md +20 -5
  387. package/dist/filters/types.d.ts +0 -27
  388. package/dist/filters/types.js +0 -1
  389. package/dist/model/filter-pushdown.d.ts +0 -106
  390. package/dist/model/filter-pushdown.js +0 -147
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { useMemo } from "react";
3
+ export const GRID_ROW_PX = 37;
4
+ export function useGridScaleStyles(scale, grouped, phone, addColumn = false) {
5
+ return useMemo(() => ({
6
+ "--vk-scale": String(scale),
7
+ "--vk-indent": phone ? "0px" : "24px",
8
+ "--vk-row-h": `calc(${GRID_ROW_PX}px * var(--vk-scale))`,
9
+ "--vk-line-h": "calc(22px * var(--vk-scale))",
10
+ "--vk-head-h": "calc(32px * var(--vk-scale))",
11
+ "--vk-head-text": "calc(12px * var(--vk-scale))",
12
+ "--vk-head-glyph": "calc(12px * var(--vk-scale))",
13
+ "--vk-footer-h": "calc(36px * var(--vk-scale))",
14
+ "--vk-label-h": "calc(36px * var(--vk-scale))",
15
+ "--vk-text": "calc(14px * var(--vk-scale))",
16
+ "--vk-text-xs": "calc(12px * var(--vk-scale))",
17
+ "--vk-text-10": "calc(10px * var(--vk-scale))",
18
+ "--vk-px": "calc(12px * var(--vk-scale))",
19
+ "--vk-rail-gap": "3px",
20
+ "--vk-rail-w": "min(32px, calc(var(--vk-gutter,0px) + var(--vk-indent,0px)))",
21
+ "--vk-tail-w": addColumn ? "calc(140px + var(--vk-px))" : "calc(36px + var(--vk-px))",
22
+ "--vk-tail-pl": addColumn
23
+ ? "max(0px, calc(var(--vk-px) + var(--vk-head-glyph) / 2 - 18px))"
24
+ : "var(--vk-px)",
25
+ "--vk-glyph": "calc(14px * var(--vk-scale))",
26
+ "--vk-scroll-mt": `calc(${grouped ? "var(--vk-label-h) + 6px" : "0px"} + var(--vk-head-h) + 4px)`,
27
+ }), [addColumn, grouped, phone, scale]);
28
+ }
@@ -0,0 +1,21 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * The grid's one scroll area, and what the rest of the grid reads off it.
4
+ *
5
+ * The whole table, headers and rows of every group, scrolls in ONE native element, both ways. Every
6
+ * browser engine scrolls off the main thread, so a position script copies from one scroller to
7
+ * another lands at least a frame late; here nothing is copied. The headers pin and the frozen
8
+ * columns stick because they sit in the same scrollport as the rows, and the browser moves them all
9
+ * at once.
10
+ *
11
+ * What script still does is paint bookkeeping, never position: one passive listener writes two 0/1
12
+ * flags on the frame, and only when one flips. `--vk-scrolled` is "has the table moved sideways at
13
+ * all"; `--vk-parked` is "has the leading chrome (the checkbox rail, the frozen block) reached its
14
+ * stop", which happens `parkAt` px later (measured below). It also keeps `scrollXRef` at the area's
15
+ * x, which the header's column drag folds into its shift.
16
+ */
17
+ export declare function useGridScrollArea(rootRef: RefObject<HTMLDivElement | null>): {
18
+ areaRef: (element: HTMLDivElement | null) => (() => void) | undefined;
19
+ scrollXRef: RefObject<number>;
20
+ getScroller: () => HTMLElement | undefined;
21
+ };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef } from "react";
3
+ export function useGridScrollArea(rootRef) {
4
+ const areaElRef = useRef(null);
5
+ const scrollXRef = useRef(0);
6
+ const parkAtRef = useRef(0);
7
+ const flagsRef = useRef({ scrolled: "", parked: "" });
8
+ const writeFlags = useCallback((x) => {
9
+ const root = rootRef.current;
10
+ if (!root)
11
+ return;
12
+ const scrolled = x > 0 ? "1" : "0";
13
+ const parked = x > 0 && x >= parkAtRef.current ? "1" : "0";
14
+ if (flagsRef.current.scrolled !== scrolled) {
15
+ flagsRef.current.scrolled = scrolled;
16
+ root.style.setProperty("--vk-scrolled", scrolled);
17
+ }
18
+ if (flagsRef.current.parked !== parked) {
19
+ flagsRef.current.parked = parked;
20
+ root.style.setProperty("--vk-parked", parked);
21
+ }
22
+ }, [rootRef]);
23
+ useEffect(() => {
24
+ const root = rootRef.current;
25
+ if (!root)
26
+ return;
27
+ const probe = document.createElement("div");
28
+ probe.setAttribute("aria-hidden", "true");
29
+ probe.style.cssText =
30
+ "position:absolute;top:0;left:0;height:0;visibility:hidden;pointer-events:none;" +
31
+ "width:calc(var(--vk-gutter,0px) + var(--vk-indent,0px) - var(--vk-rail-w))";
32
+ root.appendChild(probe);
33
+ const read = () => {
34
+ parkAtRef.current = probe.offsetWidth;
35
+ writeFlags(scrollXRef.current);
36
+ };
37
+ read();
38
+ if (typeof ResizeObserver === "undefined")
39
+ return () => probe.remove();
40
+ const observer = new ResizeObserver(read);
41
+ observer.observe(probe);
42
+ return () => {
43
+ observer.disconnect();
44
+ probe.remove();
45
+ };
46
+ }, [rootRef, writeFlags]);
47
+ const areaRef = useCallback((element) => {
48
+ areaElRef.current = element;
49
+ if (!element)
50
+ return;
51
+ const onScroll = () => {
52
+ const x = element.scrollLeft;
53
+ scrollXRef.current = x;
54
+ writeFlags(x);
55
+ };
56
+ element.addEventListener("scroll", onScroll, { passive: true });
57
+ return () => {
58
+ element.removeEventListener("scroll", onScroll);
59
+ if (areaElRef.current === element)
60
+ areaElRef.current = null;
61
+ };
62
+ }, [writeFlags]);
63
+ const getScroller = useCallback(() => areaElRef.current ?? undefined, []);
64
+ return { areaRef, scrollXRef, getScroller };
65
+ }
@@ -0,0 +1,78 @@
1
+ import { type RefObject } from "react";
2
+ import { type GridEditCell } from "../core/useGridEditing.js";
3
+ import type { ListColumn } from "../../model/column-schema.js";
4
+ import { type GridCellPos } from "../core/coordinates.js";
5
+ import type { GridTableProps } from "./grid-table-props.js";
6
+ import { type GridFocusShape } from "../core/grid-focus.js";
7
+ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }: {
8
+ /** What the keyboard walks beyond the data cells (`core/grid-focus.ts`): the sections, their footers and menus,
9
+ * the checkbox lane. None: the keys stay on the data cells. */
10
+ focusShape?: GridFocusShape;
11
+ /** The section a row KEY is drawn in, a shut one's included: a collapse sends that row's focus to its bar. */
12
+ groupOfRow?: (rowKey: string) => string | undefined;
13
+ rootRef: RefObject<HTMLDivElement | null>;
14
+ props: GridTableProps<Row>;
15
+ rows: Row[];
16
+ /** Row KEYS of the open groups in render order — positions, not records (see `GridCellPos`): the keyboard's, the
17
+ * range's, the spreadsheet's and the fill's order, so each skips a shut group's rows. */
18
+ visibleRows: string[];
19
+ /** Row KEYS the page holds, a shut group's included: what an open edit is checked against, so collapsing a group
20
+ * never cancels an edit in it. Default: `visibleRows`, a list with no shut group. */
21
+ heldRows?: string[];
22
+ /** Row key → the rendered row and its DATA id. */
23
+ rowIndex: ReadonlyMap<string, {
24
+ key: string;
25
+ rowId: string;
26
+ row: Row;
27
+ }>;
28
+ visibleColumns: ListColumn<Row>[];
29
+ selecting: boolean;
30
+ /** Bring a row the page doesn't hold into view, by its row KEY and the column to show: the table's row window,
31
+ * since only the rows on screen are drawn. The one reveal (`revealGridCell`) calls it for a row it can't find in the page. */
32
+ revealRow?: (rowKey: string, columnId?: string) => void;
33
+ }): {
34
+ focus: {
35
+ chrome: import("../core/grid-focus.js").GridChromeTarget | null;
36
+ setChrome: (target: import("../core/grid-focus.js").GridChromeTarget | null) => void;
37
+ target: import("../core/grid-focus.js").GridFocusTarget | null;
38
+ releaseToFrame: () => void;
39
+ lastCellRef: RefObject<GridCellPos | null>;
40
+ };
41
+ onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
42
+ onEditorEnter: (rowId: string, columnId: string) => void;
43
+ enterGrid: (_which: "start" | "end", from: Element | null) => void;
44
+ visibleColIds: string[];
45
+ rowSpansMap: Map<string, import("../core/range-model.js").GridRowRangeSpan[]>;
46
+ selectValuesByColumn: Record<string, string[]>;
47
+ finishFill: (targetRowId: string) => void;
48
+ onRangeCopy: () => void | undefined;
49
+ onRangeCut: () => void | undefined;
50
+ onRangeClear: () => void | undefined;
51
+ onRangePaste: () => void | undefined;
52
+ onPasteAtCell: (rowId: string, columnId: string) => void | undefined;
53
+ inActiveRange: (rowId: string, columnId: string) => boolean;
54
+ rangeCanClear: () => boolean;
55
+ rangeVerbsRef: RefObject<import("./useGridRangeActions.js").GridRangeVerbs | null>;
56
+ editingEnabled: boolean;
57
+ focusedCell: GridCellPos | null;
58
+ editingCell: GridCellPos | null;
59
+ pendingByRow: ReadonlyMap<string, Record<string, unknown>>;
60
+ settlementByRow: import("../core/editing-model.js").GridSettlementByRow;
61
+ editSeed: string | null;
62
+ editWhole: boolean;
63
+ focusCellSync: (rowId: string, columnId: string) => void;
64
+ startEditSync: (rowId: string, columnId: string, seed?: string | null, whole?: boolean) => void;
65
+ cancelEdit: (rowId?: string, columnId?: string) => void;
66
+ commitEdit: (row: Row, rowId: string, columnId: string, prev: unknown, next: unknown, opts?: {
67
+ overlay?: boolean;
68
+ }) => void;
69
+ commitBatch: (edits: (GridEditCell<Row> & {
70
+ row: Row;
71
+ })[]) => Promise<boolean>;
72
+ refuseEdit: (columnId: string) => boolean;
73
+ onExtendCell: (rowId: string, columnId: string) => void;
74
+ onAddCell: (rowId: string, columnId: string) => void;
75
+ handleRootPointerDown: (event: React.PointerEvent) => void;
76
+ handleRootPointerDownCapture: (event: React.PointerEvent) => void;
77
+ handleRootClickCapture: (event: React.MouseEvent) => void;
78
+ };
@@ -0,0 +1,249 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
+ import { useViews } from "../../provider/context.js";
4
+ import { useGridEditing } from "../core/useGridEditing.js";
5
+ import { useGridRange } from "../core/useGridRange.js";
6
+ import { columnEffectiveWritable, gridColumnLocked, gridEditRefusal, gridNormalizeWrite, } from "../../model/column-capabilities.js";
7
+ import { gridRowIdFromKey } from "../core/coordinates.js";
8
+ import { revealGridCell } from "./grid-scroll-owner.js";
9
+ import { useGridFocus } from "./useGridFocus.js";
10
+ import { gridBarOf } from "../core/grid-focus.js";
11
+ import { useGridKeyboard } from "./useGridKeyboard.js";
12
+ import { useGridPendingReconciliation } from "./useGridPendingReconciliation.js";
13
+ import { useGridRangeActions } from "./useGridRangeActions.js";
14
+ import { useGridRangeGestures } from "./useGridRangeGestures.js";
15
+ const REFUSAL_REPEAT_MS = 600;
16
+ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }) {
17
+ const { columns, getRowId, listConfig } = props;
18
+ const { conventions, ports, messages } = useViews();
19
+ const editingEnabled = !!props.onCellCommit;
20
+ const { focused: focusedCell, editing: editingCell, pendingByRow, settlementByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, } = useGridEditing(props.onCellCommit, props.onCellsCommit);
21
+ const lockedRefusal = useCallback((col) => gridColumnLocked(col, listConfig) ? gridEditRefusal(col, listConfig, conventions, messages) : undefined, [listConfig, conventions, messages]);
22
+ const commitEdit = useCallback((row, rowId, columnId, prev, next, opts) => {
23
+ const col = visibleColumns.find((c) => c.id === columnId);
24
+ if (col) {
25
+ const locked = lockedRefusal(col);
26
+ if (locked) {
27
+ ports.toast.error(locked);
28
+ closeEdit(rowId, columnId);
29
+ return;
30
+ }
31
+ const res = gridNormalizeWrite(col, next, conventions, { messages, stored: prev, region: col.region?.(row) });
32
+ if (!res.ok) {
33
+ ports.toast.error(res.reason);
34
+ closeEdit(rowId, columnId);
35
+ return;
36
+ }
37
+ next = res.value;
38
+ }
39
+ commitEditRaw(row, rowId, columnId, prev, next, opts);
40
+ }, [visibleColumns, commitEditRaw, closeEdit, conventions, messages, ports, lockedRefusal]);
41
+ const commitBatch = useCallback((edits) => {
42
+ const colById = new Map(visibleColumns.map((c) => [c.id, c]));
43
+ const kept = [];
44
+ let firstRefusal;
45
+ for (const edit of edits) {
46
+ const col = colById.get(edit.columnId);
47
+ if (!col) {
48
+ kept.push(edit);
49
+ continue;
50
+ }
51
+ const locked = lockedRefusal(col);
52
+ if (locked) {
53
+ firstRefusal ??= locked;
54
+ continue;
55
+ }
56
+ const res = gridNormalizeWrite(col, edit.next, conventions, {
57
+ messages,
58
+ stored: edit.prev,
59
+ region: col.region?.(edit.row),
60
+ });
61
+ if (!res.ok) {
62
+ firstRefusal ??= res.reason;
63
+ continue;
64
+ }
65
+ kept.push(res.value === edit.next ? edit : { ...edit, next: res.value });
66
+ }
67
+ if (kept.length === 0) {
68
+ if (firstRefusal)
69
+ ports.toast.error(firstRefusal);
70
+ return Promise.resolve(true);
71
+ }
72
+ return commitBatchRaw(kept);
73
+ }, [visibleColumns, commitBatchRaw, conventions, messages, ports, lockedRefusal]);
74
+ const lastRefusalRef = useRef(null);
75
+ const refuseEdit = useCallback((columnId) => {
76
+ if (!editingEnabled)
77
+ return false;
78
+ const col = visibleColumns.find((c) => c.id === columnId);
79
+ if (!col || columnEffectiveWritable(col, listConfig))
80
+ return false;
81
+ const reason = gridEditRefusal(col, listConfig, conventions, messages);
82
+ if (!reason)
83
+ return false;
84
+ const now = Date.now();
85
+ const last = lastRefusalRef.current;
86
+ lastRefusalRef.current = { columnId, at: now };
87
+ if (last?.columnId === columnId && now - last.at < REFUSAL_REPEAT_MS)
88
+ return true;
89
+ ports.toast.error(reason);
90
+ return true;
91
+ }, [editingEnabled, visibleColumns, listConfig, conventions, messages, ports]);
92
+ const { ranges, setSingle: rangeSetSingle, setRect: rangeSetRect, beginDrag: rangeBeginDrag, extendTo: rangeExtendTo, addCell: rangeAddCell, clear: rangeClear, } = useGridRange();
93
+ const [editSeed, setEditSeed] = useState(null);
94
+ const [editWhole, setEditWhole] = useState(false);
95
+ const focusCellSync = useCallback((rowId, columnId) => {
96
+ focusCell(rowId, columnId);
97
+ rangeSetSingle({ rowId, columnId });
98
+ }, [focusCell, rangeSetSingle]);
99
+ const startEditSync = useCallback((rowId, columnId, seed, whole) => {
100
+ setEditSeed(seed ?? null);
101
+ setEditWhole(!!whole);
102
+ startEdit(rowId, columnId);
103
+ rangeSetSingle({ rowId, columnId });
104
+ }, [startEdit, rangeSetSingle]);
105
+ const clearFocusSync = useCallback(() => {
106
+ clearFocus();
107
+ rangeClear();
108
+ }, [clearFocus, rangeClear]);
109
+ const focus = useGridFocus({ rootRef, focusedCell, editingCell });
110
+ const setChrome = focus.setChrome;
111
+ useEffect(() => {
112
+ if (!focusedCell && !editingCell)
113
+ return;
114
+ const visible = new Set(visibleRows);
115
+ const held = heldRows ? new Set(heldRows) : visible;
116
+ const staleEdit = editingCell != null && !held.has(editingCell.rowId);
117
+ const focusKeptByEdit = focusedCell != null && editingCell?.rowId === focusedCell.rowId;
118
+ const staleFocus = focusedCell != null && !(focusKeptByEdit ? held : visible).has(focusedCell.rowId);
119
+ if (!staleEdit && !staleFocus)
120
+ return;
121
+ const editedRowId = editingCell != null
122
+ ? (rowIndex.get(editingCell.rowId)?.rowId ?? gridRowIdFromKey(editingCell.rowId))
123
+ : undefined;
124
+ const editedRowGone = editingCell != null && !rows.some((row) => getRowId(row) === editedRowId);
125
+ if (staleEdit)
126
+ cancelEdit();
127
+ if (staleFocus) {
128
+ clearFocusSync();
129
+ const shutGroup = focusedCell && held.has(focusedCell.rowId) ? groupOfRow?.(focusedCell.rowId) : undefined;
130
+ const root = rootRef.current;
131
+ const active = document.activeElement;
132
+ const inGrid = active == null || active === document.body || (root?.contains(active) ?? false);
133
+ if (shutGroup != null && inGrid)
134
+ setChrome(gridBarOf(shutGroup));
135
+ }
136
+ if (staleEdit && editedRowGone) {
137
+ ports.toast.error(messages({ key: "views.grid.row-left" }));
138
+ }
139
+ }, [cancelEdit, clearFocusSync, editingCell, focusedCell, getRowId, groupOfRow, heldRows, messages, ports, rootRef, rowIndex, rows, setChrome, visibleRows]);
140
+ const visibleColumnIds = useMemo(() => visibleColumns.map((column) => column.id), [visibleColumns]);
141
+ const spreadsheetModel = useMemo(() => ({
142
+ rows,
143
+ rowByKey: rowIndex,
144
+ visibleRowIds: visibleRows,
145
+ visibleColumns,
146
+ pendingByRow,
147
+ conventions,
148
+ messages,
149
+ listConfig,
150
+ }), [rows, rowIndex, visibleRows, visibleColumns, pendingByRow, conventions, messages, listConfig]);
151
+ const revealCell = useCallback((pos, behavior) => revealGridCell(rootRef.current, pos, behavior, revealRow), [revealRow, rootRef]);
152
+ const finishFillRef = useRef(() => { });
153
+ const { fillTargetRow, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, } = useGridRangeGestures({
154
+ rootRef,
155
+ focusedCell,
156
+ editingCell,
157
+ editingEnabled,
158
+ selecting,
159
+ focusCell,
160
+ clearFocus: clearFocusSync,
161
+ rangeBeginDrag,
162
+ rangeExtendTo,
163
+ rangeAddCell,
164
+ finishFillRef,
165
+ });
166
+ const rangeActions = useGridRangeActions({
167
+ ranges,
168
+ focusedCell,
169
+ editingCell,
170
+ editingEnabled,
171
+ fillTargetRow,
172
+ visibleRowIds: visibleRows,
173
+ visibleColumns,
174
+ spreadsheetModel,
175
+ commitBatch,
176
+ focusCell,
177
+ rangeSetRect,
178
+ rangeExtendTo,
179
+ revealCell,
180
+ });
181
+ useEffect(() => {
182
+ finishFillRef.current = rangeActions.finishFill;
183
+ }, [rangeActions.finishFill]);
184
+ const keyboard = useGridKeyboard({
185
+ releaseToFrame: focus.releaseToFrame,
186
+ lastCellRef: focus.lastCellRef,
187
+ chrome: focus.chrome,
188
+ setChrome: focus.setChrome,
189
+ shape: focusShape,
190
+ toggleGroup: props.onToggleGroup,
191
+ rootRef,
192
+ focusedCell,
193
+ editingCell,
194
+ editingEnabled,
195
+ listConfig,
196
+ visibleRowIds: visibleRows,
197
+ visibleColIds: visibleColumnIds,
198
+ visibleColumns,
199
+ rows,
200
+ getRowId,
201
+ rowByKey: rowIndex,
202
+ pendingByRow,
203
+ rangeVerbsRef: rangeActions.rangeVerbsRef,
204
+ focusCell: focusCellSync,
205
+ clearFocus: clearFocusSync,
206
+ startEdit: startEditSync,
207
+ cancelEdit,
208
+ commitEdit,
209
+ refuseEdit,
210
+ undo,
211
+ redo,
212
+ rangeSetRect,
213
+ rangeExtendTo,
214
+ ranges,
215
+ revealCell,
216
+ });
217
+ useGridPendingReconciliation({
218
+ rows,
219
+ columns,
220
+ getRowId,
221
+ pendingByRow,
222
+ reconcile,
223
+ hasInflight,
224
+ pendingBaseline,
225
+ });
226
+ return {
227
+ editingEnabled,
228
+ focusedCell,
229
+ editingCell,
230
+ pendingByRow,
231
+ settlementByRow,
232
+ editSeed,
233
+ editWhole,
234
+ focusCellSync,
235
+ startEditSync,
236
+ cancelEdit,
237
+ commitEdit,
238
+ commitBatch,
239
+ refuseEdit,
240
+ onExtendCell,
241
+ onAddCell,
242
+ handleRootPointerDown,
243
+ handleRootPointerDownCapture,
244
+ handleRootClickCapture,
245
+ ...rangeActions,
246
+ ...keyboard,
247
+ focus,
248
+ };
249
+ }
@@ -0,0 +1,29 @@
1
+ import { type RefObject } from "react";
2
+ import type { GridTableProps } from "./grid-table-props.js";
3
+ export declare function getVisibleGridRowIds<Row>({ groups, grouped, isCollapsed, getRowId, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId">): string[];
4
+ /**
5
+ * The Grid renderer's list-selection binding.
6
+ *
7
+ * Selection order includes every rendered row, while checkbox-lane drag order
8
+ * deliberately excludes rows hidden inside collapsed groups. Keeping both
9
+ * orders here prevents the renderer from accidentally feeding one contract to
10
+ * the other when its group chrome changes.
11
+ */
12
+ export declare function useGridTableSelection<Row>({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId" | "selection"> & {
13
+ rootRef: RefObject<HTMLDivElement | null>;
14
+ }): {
15
+ selectable: boolean;
16
+ selecting: boolean;
17
+ selectionState: import("../../selection/useListSelection.js").UseListSelectionResult;
18
+ derivedOrderedIds: string[];
19
+ visibleRowIds: string[];
20
+ checkDrag: {
21
+ tryArm: (e: import("react").PointerEvent) => boolean;
22
+ consumeDrag: () => boolean;
23
+ };
24
+ groupSelection: (items: Row[]) => {
25
+ allSelected: boolean;
26
+ someSelected: boolean;
27
+ onToggle: () => void;
28
+ };
29
+ };
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import { useMemo } from "react";
3
+ import { useCheckDragSelect } from "../../selection/useCheckDragSelect.js";
4
+ import { useEscapeToClear } from "../../selection/useListSelectionShortcuts.js";
5
+ import { useListSelection } from "../../selection/useListSelection.js";
6
+ import { gridRowIdFromKey } from "../core/coordinates.js";
7
+ export function getVisibleGridRowIds({ groups, grouped, isCollapsed, getRowId, }) {
8
+ const ids = [];
9
+ for (const group of groups) {
10
+ if (grouped && (isCollapsed?.(group.key) ?? false))
11
+ continue;
12
+ for (const row of group.items)
13
+ ids.push(getRowId(row));
14
+ }
15
+ return ids;
16
+ }
17
+ export function useGridTableSelection({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }) {
18
+ const selectable = !!selection;
19
+ const derivedOrderedIds = useMemo(() => groups.flatMap((group) => group.items).map(getRowId), [groups, getRowId]);
20
+ const orderedIds = selection?.orderedIds ?? derivedOrderedIds;
21
+ const selectionState = useListSelection({
22
+ orderedIds,
23
+ retention: selection?.retention,
24
+ resetKey: selection?.resetKey,
25
+ });
26
+ useEscapeToClear(selectionState.count > 0, selectionState.clear);
27
+ const selecting = selectable && selectionState.count > 0;
28
+ const visibleRowIds = useMemo(() => getVisibleGridRowIds({ groups, grouped, isCollapsed, getRowId }), [groups, grouped, isCollapsed, getRowId]);
29
+ const checkDrag = useCheckDragSelect({
30
+ enabled: selectable,
31
+ rootRef,
32
+ rowIds: visibleRowIds,
33
+ rowIdOf: gridRowIdFromKey,
34
+ isSelected: selectionState.isSelected,
35
+ setRowSelected: selectionState.toggle,
36
+ });
37
+ const groupSelection = (items) => {
38
+ const ids = items.map(getRowId);
39
+ const selectedCount = ids.filter((id) => selectionState.isSelected(id)).length;
40
+ return {
41
+ allSelected: selectedCount > 0 && selectedCount === ids.length,
42
+ someSelected: selectedCount > 0 && selectedCount < ids.length,
43
+ onToggle: () => selectionState.toggleMany(ids),
44
+ };
45
+ };
46
+ return {
47
+ selectable,
48
+ selecting,
49
+ selectionState,
50
+ derivedOrderedIds,
51
+ visibleRowIds,
52
+ checkDrag,
53
+ groupSelection,
54
+ };
55
+ }
@@ -0,0 +1,21 @@
1
+ import type React from "react";
2
+ export declare function useHeaderDragReorder({ enabled, ids, scrollXRef, getScroller, canDrag, onReorder, }: {
3
+ enabled: boolean;
4
+ /** Visible column ids, in current order. */
5
+ ids: string[];
6
+ /** The grid's scroll area's current scrollLeft (GridTable's scrollXRef). */
7
+ scrollXRef: React.MutableRefObject<number>;
8
+ /** The grid's scroll area: the edge autoscroll moves it. */
9
+ getScroller: () => HTMLElement | undefined;
10
+ /** Optional ownership gate for columns that remain fixed in declaration order. */
11
+ canDrag?: (id: string) => boolean;
12
+ /** Commit: the moved id + the full visible order after the move. */
13
+ onReorder: (movedId: string, nextVisibleIds: string[]) => void;
14
+ }): {
15
+ cellStyle: (id: string, index: number) => React.CSSProperties | undefined;
16
+ onCellPointerDown: (id: string, index: number) => (e: React.PointerEvent<HTMLElement>) => void;
17
+ onCellPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
18
+ onCellPointerUp: (e: React.PointerEvent<HTMLElement>) => void;
19
+ onCellPointerCancel: () => void;
20
+ onCellClickCapture: (e: React.MouseEvent<HTMLElement>) => void;
21
+ };