@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,280 @@
1
+ import { cellClearPrev, cellCopyText, cellEditBaseline, cellPrevPayload, coercePaste, gridPasteOverlay, pasteUnit, rowHoldsCurrency, } from "./clipboard-model.js";
2
+ import { gridBooleanMode, columnEffectiveWritable, columnLabel, columnWritable, gridColumnLocked, gridEditRefusal, } from "../../model/column-capabilities.js";
3
+ import { resolveViewsMessage } from "../../contract.js";
4
+ import { gridRectIsMulti, resolveCellRect, } from "./coordinates.js";
5
+ import { resolveActiveRangeRect } from "./range-model.js";
6
+ import { fieldTypeOf } from "../../model/field-type-of.js";
7
+ function addRefusal(refusals, reason) {
8
+ const known = refusals.find((refusal) => refusal.reason === reason);
9
+ if (known)
10
+ known.count++;
11
+ else
12
+ refusals.push({ reason, count: 1 });
13
+ }
14
+ function cellRefusal(model, col) {
15
+ const messages = model.messages ?? resolveViewsMessage;
16
+ return ((col && gridEditRefusal(col, model.listConfig, model.conventions, messages)) ||
17
+ messages({ key: "views.grid.cell-read-only" }));
18
+ }
19
+ export function buildGridCopyMatrix(model, rect) {
20
+ const matrix = [];
21
+ for (let r = rect.r1; r <= rect.r2; r++) {
22
+ const entry = model.rowByKey.get(model.visibleRowIds[r]);
23
+ if (entry == null)
24
+ continue;
25
+ const { row, rowId } = entry;
26
+ const cells = [];
27
+ for (let c = rect.c1; c <= rect.c2; c++) {
28
+ const col = model.visibleColumns[c];
29
+ if (!col)
30
+ continue;
31
+ const baseline = cellEditBaseline(col, row, model.pendingByRow.get(rowId));
32
+ cells.push({
33
+ text: cellCopyText(col, baseline),
34
+ value: baseline,
35
+ type: col.type,
36
+ unit: col.editUnit?.value(row),
37
+ });
38
+ }
39
+ matrix.push(cells);
40
+ }
41
+ return matrix;
42
+ }
43
+ export function gridRectHasClearable(columns, rect) {
44
+ for (let c = rect.c1; c <= rect.c2; c++) {
45
+ const col = columns[c];
46
+ if (col && columnWritable(col) && (col.clearable || gridBooleanMode(col)))
47
+ return true;
48
+ }
49
+ return false;
50
+ }
51
+ function holdsNothing(value) {
52
+ return value == null || value === "" || (Array.isArray(value) && value.length === 0);
53
+ }
54
+ export function planGridClear(model, rect) {
55
+ const edits = [];
56
+ const refusals = [];
57
+ const required = new Set();
58
+ for (let r = rect.r1; r <= rect.r2; r++) {
59
+ const entry = model.rowByKey.get(model.visibleRowIds[r]);
60
+ if (entry == null)
61
+ continue;
62
+ const { row, rowId } = entry;
63
+ for (let c = rect.c1; c <= rect.c2; c++) {
64
+ const col = model.visibleColumns[c];
65
+ if (!col || !columnWritable(col))
66
+ continue;
67
+ if (!col.clearable && !gridBooleanMode(col)) {
68
+ const held = cellEditBaseline(col, row, model.pendingByRow.get(rowId));
69
+ if (!gridColumnLocked(col, model.listConfig) && !holdsNothing(held))
70
+ required.add(c);
71
+ continue;
72
+ }
73
+ if (gridColumnLocked(col, model.listConfig)) {
74
+ addRefusal(refusals, cellRefusal(model, col));
75
+ continue;
76
+ }
77
+ edits.push({
78
+ row,
79
+ rowId,
80
+ columnId: col.id,
81
+ prev: cellClearPrev(col, row, model.pendingByRow.get(rowId)),
82
+ next: "",
83
+ overlay: true,
84
+ rowSnapshot: row,
85
+ });
86
+ }
87
+ }
88
+ return {
89
+ edits,
90
+ refusals,
91
+ required: [...required].sort((a, b) => a - b).map((c) => columnLabel(model.visibleColumns[c])),
92
+ };
93
+ }
94
+ export function planGridPaste(model, matrix, anchor, activeRect, selectValuesByColumn) {
95
+ const empty = {
96
+ edits: [],
97
+ skipped: 0,
98
+ refusals: [],
99
+ targetCount: 0,
100
+ selection: null,
101
+ };
102
+ if (matrix.length === 0 || matrix[0]?.length === 0)
103
+ return empty;
104
+ const single = matrix.length === 1 && matrix[0].length === 1;
105
+ const targets = [];
106
+ if (single && activeRect && gridRectIsMulti(activeRect)) {
107
+ for (let r = activeRect.r1; r <= activeRect.r2; r++) {
108
+ for (let c = activeRect.c1; c <= activeRect.c2; c++) {
109
+ targets.push({ r, c, source: matrix[0][0] });
110
+ }
111
+ }
112
+ }
113
+ else {
114
+ for (let i = 0; i < matrix.length; i++) {
115
+ for (let j = 0; j < matrix[i].length; j++) {
116
+ const r = anchor.rowIdx + i;
117
+ const c = anchor.colIdx + j;
118
+ if (r >= model.visibleRowIds.length || c >= model.visibleColumns.length)
119
+ continue;
120
+ targets.push({ r, c, source: matrix[i][j] });
121
+ }
122
+ }
123
+ }
124
+ const edits = [];
125
+ let skipped = 0;
126
+ const refusals = [];
127
+ let maxR = anchor.rowIdx;
128
+ let maxC = anchor.colIdx;
129
+ for (const { r, c, source } of targets) {
130
+ const entry = model.rowByKey.get(model.visibleRowIds[r]);
131
+ const row = entry?.row;
132
+ const rowId = entry?.rowId;
133
+ const col = model.visibleColumns[c];
134
+ if (row == null || !col || !columnEffectiveWritable(col, model.listConfig)) {
135
+ skipped++;
136
+ addRefusal(refusals, cellRefusal(model, col));
137
+ continue;
138
+ }
139
+ const coerced = coercePaste(col, source, {
140
+ conventions: model.conventions,
141
+ messages: model.messages,
142
+ currentUnit: col.editUnit?.value(row),
143
+ holdsCurrency: rowHoldsCurrency(col, row),
144
+ values: selectValuesByColumn[col.id],
145
+ region: col.region?.(row),
146
+ });
147
+ if (!coerced.ok) {
148
+ skipped++;
149
+ addRefusal(refusals, coerced.reason);
150
+ continue;
151
+ }
152
+ edits.push({
153
+ row,
154
+ rowId,
155
+ columnId: col.id,
156
+ prev: cellPrevPayload(col, cellEditBaseline(col, row, model.pendingByRow.get(rowId)), col.editUnit?.value(row)),
157
+ next: coerced.next,
158
+ overlay: coerced.overlay,
159
+ rowSnapshot: row,
160
+ });
161
+ maxR = Math.max(maxR, r);
162
+ maxC = Math.max(maxC, c);
163
+ }
164
+ const anchorRowId = model.visibleRowIds[anchor.rowIdx];
165
+ const anchorColumn = model.visibleColumns[anchor.colIdx];
166
+ const headRowId = model.visibleRowIds[maxR];
167
+ const headColumn = model.visibleColumns[maxC];
168
+ const selection = !single && edits.length > 0 && anchorRowId && anchorColumn && headRowId && headColumn
169
+ ? {
170
+ anchor: { rowId: anchorRowId, columnId: anchorColumn.id },
171
+ head: { rowId: headRowId, columnId: headColumn.id },
172
+ }
173
+ : null;
174
+ return { edits, skipped, refusals, targetCount: targets.length, selection };
175
+ }
176
+ export function extendGridFillPreview(ranges, targetRowId, visibleRowIds, visibleColIds) {
177
+ if (!targetRowId || ranges.length === 0)
178
+ return ranges;
179
+ const active = ranges[ranges.length - 1];
180
+ const rect = resolveCellRect(active.anchor, active.head, visibleRowIds, visibleColIds);
181
+ const target = visibleRowIds.indexOf(targetRowId);
182
+ if (!rect || target < 0 || (target >= rect.r1 && target <= rect.r2)) {
183
+ return ranges;
184
+ }
185
+ const down = target > rect.r2;
186
+ return [
187
+ ...ranges,
188
+ {
189
+ anchor: {
190
+ rowId: visibleRowIds[down ? rect.r2 + 1 : target],
191
+ columnId: visibleColIds[rect.c1],
192
+ },
193
+ head: {
194
+ rowId: visibleRowIds[down ? target : rect.r1 - 1],
195
+ columnId: visibleColIds[rect.c2],
196
+ },
197
+ },
198
+ ];
199
+ }
200
+ export function planGridFill(model, ranges, focused, targetRowId) {
201
+ const visibleColIds = model.visibleColumns.map((col) => col.id);
202
+ const rect = resolveActiveRangeRect(ranges, focused, model.visibleRowIds, visibleColIds);
203
+ const active = ranges[ranges.length - 1] ?? (focused ? { anchor: focused, head: focused } : null);
204
+ const target = model.visibleRowIds.indexOf(targetRowId);
205
+ if (!rect || !active || target < 0 || (target >= rect.r1 && target <= rect.r2)) {
206
+ return { edits: [], selectionHead: null, skipped: 0, refusals: [], targetCount: 0 };
207
+ }
208
+ const down = target > rect.r2;
209
+ const sourceHeight = rect.r2 - rect.r1 + 1;
210
+ const targetIndices = [];
211
+ if (down) {
212
+ for (let index = rect.r2 + 1; index <= target; index++)
213
+ targetIndices.push(index);
214
+ }
215
+ else {
216
+ for (let index = target; index < rect.r1; index++)
217
+ targetIndices.push(index);
218
+ }
219
+ const edits = [];
220
+ let skipped = 0;
221
+ const refusals = [];
222
+ for (const targetIndex of targetIndices) {
223
+ const sourceIndex = down
224
+ ? rect.r1 + ((targetIndex - rect.r2 - 1) % sourceHeight)
225
+ : rect.r2 - ((rect.r1 - targetIndex - 1) % sourceHeight);
226
+ const source = model.rowByKey.get(model.visibleRowIds[sourceIndex]);
227
+ const next_ = model.rowByKey.get(model.visibleRowIds[targetIndex]);
228
+ if (source == null || next_ == null)
229
+ continue;
230
+ const { row: sourceRow, rowId: sourceRowId } = source;
231
+ const { row: nextRow, rowId: nextRowId } = next_;
232
+ for (let c = rect.c1; c <= rect.c2; c++) {
233
+ const col = model.visibleColumns[c];
234
+ if (!col || !columnWritable(col))
235
+ continue;
236
+ if (gridColumnLocked(col, model.listConfig)) {
237
+ skipped++;
238
+ addRefusal(refusals, cellRefusal(model, col));
239
+ continue;
240
+ }
241
+ const sourceBaseline = cellEditBaseline(col, sourceRow, model.pendingByRow.get(sourceRowId));
242
+ const empty = sourceBaseline == null || sourceBaseline === "";
243
+ if (empty && !col.clearable && !gridBooleanMode(col))
244
+ continue;
245
+ let next = empty && col.clearable ? "" : cellPrevPayload(col, sourceBaseline, col.editUnit?.value(sourceRow));
246
+ if (next == null)
247
+ continue;
248
+ if (!empty && fieldTypeOf(col) === "currency" && typeof next === "object") {
249
+ const payload = next;
250
+ const unit = pasteUnit(payload.unit, col.editUnit?.value(nextRow), col.editUnit?.options, rowHoldsCurrency(col, nextRow));
251
+ if ("refuse" in unit) {
252
+ skipped++;
253
+ addRefusal(refusals, (model.messages ?? resolveViewsMessage)({
254
+ key: "views.grid.paste-other-currency",
255
+ values: { currency: unit.refuse },
256
+ }));
257
+ continue;
258
+ }
259
+ next = { ...payload, unit: unit.unit };
260
+ }
261
+ const overlay = gridPasteOverlay(col);
262
+ edits.push({
263
+ row: nextRow,
264
+ rowId: nextRowId,
265
+ columnId: col.id,
266
+ prev: cellClearPrev(col, nextRow, model.pendingByRow.get(nextRowId)),
267
+ next,
268
+ overlay,
269
+ rowSnapshot: nextRow,
270
+ });
271
+ }
272
+ }
273
+ return {
274
+ edits,
275
+ selectionHead: { rowId: targetRowId, columnId: active.head.columnId },
276
+ skipped,
277
+ refusals,
278
+ targetCount: targetIndices.length * (rect.c2 - rect.c1 + 1),
279
+ };
280
+ }
@@ -0,0 +1,46 @@
1
+ import type { GridCellCommitFn, GridCellsCommitFn } from "./commit-model.js";
2
+ import { type GridCellPos } from "./coordinates.js";
3
+ import { type GridEditCell, type GridSettlementByRow } from "./editing-model.js";
4
+ export type { GridEditCell } from "./editing-model.js";
5
+ type GridEditingApi<Row> = {
6
+ focused: GridCellPos | null;
7
+ editing: GridCellPos | null;
8
+ pendingByRow: ReadonlyMap<string, Record<string, unknown>>;
9
+ /** The subset of pending cells whose write is only `requested` of its
10
+ * provider — drawn as a visible pending state (spec §11.2). */
11
+ settlementByRow: GridSettlementByRow;
12
+ focusCell: (rowId: string, columnId: string) => void;
13
+ clearFocus: () => void;
14
+ startEdit: (rowId: string, columnId: string) => void;
15
+ cancelEdit: (rowId?: string, columnId?: string) => void;
16
+ /** Close the editor open on this cell, by its RECORD id as a commit carries it, and write nothing:
17
+ * the chrome refused the commit. An editor open on another cell stays open. */
18
+ closeEdit: (rowId: string, columnId: string) => void;
19
+ commitEdit: (row: Row, rowId: string, columnId: string, prev: unknown, next: unknown, opts?: {
20
+ overlay?: boolean;
21
+ }) => void;
22
+ /** Commit MANY cells as one user action (fill, range paste/delete, a batch
23
+ * bar verb over a row selection). One history entry — ⌘Z reverts the whole
24
+ * thing in a single step. Rows ride along per cell (`row`); prev/next in
25
+ * commit-payload shape.
26
+ *
27
+ * Resolves TRUE once every cell has landed on the server, false if any
28
+ * failed (those overlays are already rolled back by then). Callers that own
29
+ * user-facing confirmation await it; the editors ignore it, because an
30
+ * optimistic edit's feedback is the cell itself. */
31
+ commitBatch: (edits: (GridEditCell<Row> & {
32
+ row: Row;
33
+ })[]) => Promise<boolean>;
34
+ /** Undo the most recent action (⌘Z). `resolveRow` maps a rowId to the
35
+ * CURRENT row object (stored snapshot is the fallback). `onApply` fires when
36
+ * the application actually starts — the chrome scrolls the cell into view.
37
+ * Returns false when there is nothing to undo. */
38
+ undo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
39
+ redo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
40
+ reconcile: (matchedKeys: string[]) => void;
41
+ /** True while a write for this cell has not settled — see hasInflight. */
42
+ hasInflight: (rowId: string, columnId: string) => boolean;
43
+ /** What the cell held before its pending write — see GridPendingEntry.baseline. */
44
+ pendingBaseline: (rowId: string, columnId: string) => unknown;
45
+ };
46
+ export declare function useGridEditing<Row>(onCellCommit?: GridCellCommitFn<Row>, onCellsCommit?: GridCellsCommitFn<Row>): GridEditingApi<Row>;
@@ -0,0 +1,93 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ import { gridRowIdFromKey } from "./coordinates.js";
3
+ import { GridEditingController } from "./editing-controller.js";
4
+ import { sameListValue } from "@viewkitjs/fields";
5
+ import { prepareGridCommitCells, } from "./editing-model.js";
6
+ export function useGridEditing(onCellCommit, onCellsCommit) {
7
+ const [focused, setFocused] = useState(null);
8
+ const [editing, setEditing] = useState(null);
9
+ const [pendingByRow, setPendingByRow] = useState(() => new Map());
10
+ const [settlementByRow, setSettlementByRow] = useState(() => new Map());
11
+ const [controller] = useState(() => new GridEditingController({ onCellCommit, onCellsCommit }, (pending, settlement) => {
12
+ setPendingByRow(pending);
13
+ setSettlementByRow(settlement);
14
+ }));
15
+ useEffect(() => {
16
+ const callbacks = { onCellCommit, onCellsCommit };
17
+ controller.setCallbacks(callbacks);
18
+ }, [controller, onCellCommit, onCellsCommit]);
19
+ const focusCell = useCallback((rowId, columnId) => {
20
+ setFocused({ rowId, columnId });
21
+ setEditing(null);
22
+ }, []);
23
+ const clearFocus = useCallback(() => {
24
+ setFocused(null);
25
+ setEditing(null);
26
+ }, []);
27
+ const startEdit = useCallback((rowId, columnId) => {
28
+ setFocused({ rowId, columnId });
29
+ setEditing({ rowId, columnId });
30
+ }, []);
31
+ const cancelEdit = useCallback((rowId, columnId) => {
32
+ setEditing((current) => rowId != null && current != null && (current.rowId !== rowId || current.columnId !== columnId)
33
+ ? current
34
+ : null);
35
+ }, []);
36
+ const closeEdit = useCallback((rowId, columnId) => {
37
+ setEditing((current) => current != null &&
38
+ (gridRowIdFromKey(current.rowId) !== rowId || current.columnId !== columnId)
39
+ ? current
40
+ : null);
41
+ }, []);
42
+ const commitEdit = useCallback((row, rowId, columnId, prev, next, opts) => {
43
+ closeEdit(rowId, columnId);
44
+ if (sameListValue(next, prev) || !onCellCommit)
45
+ return;
46
+ controller.commit([
47
+ {
48
+ row,
49
+ cell: {
50
+ rowId,
51
+ columnId,
52
+ prev,
53
+ next,
54
+ overlay: opts?.overlay !== false,
55
+ rowSnapshot: row,
56
+ },
57
+ },
58
+ ]);
59
+ }, [controller, onCellCommit, closeEdit]);
60
+ const commitBatch = useCallback((edits) => controller.commit(prepareGridCommitCells(edits)), [controller]);
61
+ const applyHistory = useCallback((kind, resolveRow, onApply) => {
62
+ const reveal = (pos) => {
63
+ setEditing(null);
64
+ onApply?.(pos);
65
+ };
66
+ return kind === "undo"
67
+ ? controller.undo(resolveRow, reveal)
68
+ : controller.redo(resolveRow, reveal);
69
+ }, [controller]);
70
+ const undo = useCallback((resolveRow, onApply) => applyHistory("undo", resolveRow, onApply), [applyHistory]);
71
+ const redo = useCallback((resolveRow, onApply) => applyHistory("redo", resolveRow, onApply), [applyHistory]);
72
+ const reconcile = useCallback((matchedKeys) => controller.reconcile(matchedKeys), [controller]);
73
+ const hasInflight = useCallback((rowId, columnId) => controller.hasInflight(rowId, columnId), [controller]);
74
+ const pendingBaseline = useCallback((rowId, columnId) => controller.pendingBaseline(rowId, columnId), [controller]);
75
+ return {
76
+ focused,
77
+ editing,
78
+ pendingByRow,
79
+ settlementByRow,
80
+ focusCell,
81
+ clearFocus,
82
+ startEdit,
83
+ cancelEdit,
84
+ closeEdit,
85
+ commitEdit,
86
+ commitBatch,
87
+ undo,
88
+ redo,
89
+ reconcile,
90
+ hasInflight,
91
+ pendingBaseline,
92
+ };
93
+ }
@@ -0,0 +1,20 @@
1
+ import type { GridCellPos } from "./coordinates.js";
2
+ import { type GridCellRange } from "./range-model.js";
3
+ export { type GridCellRange, type GridRowRangeSpan } from "./range-model.js";
4
+ type GridRangeApi = {
5
+ ranges: GridCellRange[];
6
+ /** Replace everything with a 1-cell range (plain click / focus sync). */
7
+ setSingle: (pos: GridCellPos) => void;
8
+ /** Replace everything with one rectangle (e.g. select a pasted block). */
9
+ setRect: (anchor: GridCellPos, head: GridCellPos) => void;
10
+ /** Start a drag range at `pos` — replaces the selection, or appends when
11
+ * `additive` (⌘-drag). */
12
+ beginDrag: (pos: GridCellPos, additive: boolean) => void;
13
+ /** Update the active range's head (drag / shift-click). Seeds a new range
14
+ * from `fallbackAnchor` when the selection is empty. */
15
+ extendTo: (pos: GridCellPos, fallbackAnchor?: GridCellPos) => void;
16
+ /** Append a 1-cell range (⌘-click). */
17
+ addCell: (pos: GridCellPos) => void;
18
+ clear: () => void;
19
+ };
20
+ export declare function useGridRange(): GridRangeApi;
@@ -0,0 +1,24 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+ import { addCellRange, beginRangeDrag, extendActiveRange, setRectRange, setSingleRange, } from "./range-model.js";
3
+ export function useGridRange() {
4
+ const [ranges, setRanges] = useState([]);
5
+ const setSingle = useCallback((pos) => {
6
+ setRanges(setSingleRange(pos));
7
+ }, []);
8
+ const setRect = useCallback((anchor, head) => {
9
+ setRanges(setRectRange(anchor, head));
10
+ }, []);
11
+ const beginDrag = useCallback((pos, additive) => {
12
+ setRanges((ranges) => beginRangeDrag(ranges, pos, additive));
13
+ }, []);
14
+ const extendTo = useCallback((pos, fallbackAnchor) => {
15
+ setRanges((ranges) => extendActiveRange(ranges, pos, fallbackAnchor));
16
+ }, []);
17
+ const addCell = useCallback((pos) => {
18
+ setRanges((ranges) => addCellRange(ranges, pos));
19
+ }, []);
20
+ const clear = useCallback(() => {
21
+ setRanges((rs) => (rs.length === 0 ? rs : []));
22
+ }, []);
23
+ return useMemo(() => ({ ranges, setSingle, setRect, beginDrag, extendTo, addCell, clear }), [ranges, setSingle, setRect, beginDrag, extendTo, addCell, clear]);
24
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * HOW TWO CELL VALUES COMPARE — the one place a list of values is understood.
3
+ *
4
+ * Four questions in this subsystem are all "are these the same value", and each
5
+ * answered it with `===`: did our write land (`findGridPendingMatches`), was it
6
+ * taken from us (`findSupersededCells`), and the two no-op checks before a
7
+ * commit. Identity is the right answer for every scalar type and the wrong one
8
+ * for an array, which is never identical to the array a refetch brings back —
9
+ * so a multi-value write would hold its overlay for the life of the mount AND
10
+ * report itself as somebody else's edit at the same time.
11
+ *
12
+ * TWO functions rather than one, because the two jobs genuinely differ and
13
+ * merging them would make each worse:
14
+ *
15
+ * - `sameListValue` asks "is there anything to write". It is exact, so a
16
+ * reordering counts as a change. It lives in `@viewkitjs/fields` — the same
17
+ * question is an editing CORE's, and a core cannot reach into the grid.
18
+ * - `looselyEqualValue`, below, asks "is the difference merely a FORMAT". It
19
+ * is forgiving, so a server that stores a list in its own order has not
20
+ * overruled you and nobody is warned. That is a question about a reply, not
21
+ * about a field, so it stays here.
22
+ *
23
+ * A third, `sameKeptValue` at the end, reads only a value a save handed back as
24
+ * what it kept, by structure, so an answer that never says what it kept keeps
25
+ * the two rules above unchanged.
26
+ */
27
+ /**
28
+ * Nothing, however it is spelled: `null`, `undefined`, a blank text, an empty list. An emptied cell
29
+ * sends `""` and an app stores nothing as `null`, the rule `@viewkitjs/fields` reads a stored value
30
+ * by. A zero and a false are values.
31
+ */
32
+ export declare function isEmptyValue(value: unknown): boolean;
33
+ /**
34
+ * The RESHAPING CHECK: one empty value for every spelling of nothing, a
35
+ * multiset for two arrays, the scalar rule otherwise.
36
+ *
37
+ * Order-insensitive on purpose. What comes back is the server's own storage
38
+ * order, and treating that as a third party's edit would put a warning on the
39
+ * screen every time somebody tagged something — which is how a warning becomes
40
+ * noise nobody reads. Duplicates are counted rather than merely matched, so
41
+ * `["a","a"]` and `["a","b"]` stay different.
42
+ */
43
+ export declare function looselyEqualValue(a: unknown, b: unknown): boolean;
44
+ /** Note a value a save said it kept. A primitive needs no note: the rules above already read it. */
45
+ export declare function markGridKeptValue(value: unknown): void;
46
+ /** Is this overlay value one a save said it kept? */
47
+ export declare function isGridKeptValue(value: unknown): boolean;
48
+ /**
49
+ * WHAT A SAVE KEPT, AGAINST WHAT THE ROWS NOW READ. The kept value is the server's own, but a fresh
50
+ * read hands back a new object holding it, so two plain objects are one when their keys and values
51
+ * are, and two lists when their items are, in any order (the format rule's own tolerance). Everything
52
+ * else goes by `looselyEqualValue`.
53
+ */
54
+ export declare function sameKeptValue(a: unknown, b: unknown): boolean;
@@ -0,0 +1,80 @@
1
+ function looselyEqualScalar(a, b) {
2
+ if (Object.is(a, b))
3
+ return true;
4
+ if (a == null || b == null)
5
+ return false;
6
+ if (typeof a === "object" || typeof b === "object")
7
+ return false;
8
+ const left = String(a).trim();
9
+ const right = String(b).trim();
10
+ if (left === right)
11
+ return true;
12
+ if (left === "" || right === "")
13
+ return false;
14
+ const leftNumber = Number(left);
15
+ const rightNumber = Number(right);
16
+ return !Number.isNaN(leftNumber) && !Number.isNaN(rightNumber) && leftNumber === rightNumber;
17
+ }
18
+ export function isEmptyValue(value) {
19
+ if (value == null)
20
+ return true;
21
+ if (typeof value === "string")
22
+ return value.trim() === "";
23
+ return Array.isArray(value) && value.length === 0;
24
+ }
25
+ export function looselyEqualValue(a, b) {
26
+ const emptyA = isEmptyValue(a);
27
+ const emptyB = isEmptyValue(b);
28
+ if (emptyA || emptyB)
29
+ return emptyA && emptyB;
30
+ if (Array.isArray(a) || Array.isArray(b)) {
31
+ if (!Array.isArray(a) || !Array.isArray(b))
32
+ return false;
33
+ if (a.length !== b.length)
34
+ return false;
35
+ const unmatched = [...b];
36
+ for (const item of a) {
37
+ const index = unmatched.findIndex((candidate) => looselyEqualScalar(item, candidate));
38
+ if (index === -1)
39
+ return false;
40
+ unmatched.splice(index, 1);
41
+ }
42
+ return true;
43
+ }
44
+ return looselyEqualScalar(a, b);
45
+ }
46
+ const keptValues = new WeakSet();
47
+ export function markGridKeptValue(value) {
48
+ if (typeof value === "object" && value !== null)
49
+ keptValues.add(value);
50
+ }
51
+ export function isGridKeptValue(value) {
52
+ return typeof value === "object" && value !== null && keptValues.has(value);
53
+ }
54
+ const isPlainObject = (value) => typeof value === "object" &&
55
+ value !== null &&
56
+ !Array.isArray(value) &&
57
+ (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
58
+ export function sameKeptValue(a, b) {
59
+ if (looselyEqualValue(a, b))
60
+ return true;
61
+ if (Array.isArray(a) && Array.isArray(b)) {
62
+ if (a.length !== b.length)
63
+ return false;
64
+ const unmatched = [...b];
65
+ for (const item of a) {
66
+ const index = unmatched.findIndex((candidate) => sameKeptValue(item, candidate));
67
+ if (index === -1)
68
+ return false;
69
+ unmatched.splice(index, 1);
70
+ }
71
+ return true;
72
+ }
73
+ if (!isPlainObject(a) || !isPlainObject(b))
74
+ return false;
75
+ const keysOf = (value) => Object.keys(value).filter((key) => value[key] !== undefined);
76
+ const keys = keysOf(a);
77
+ if (keys.length !== keysOf(b).length)
78
+ return false;
79
+ return keys.every((key) => Object.hasOwn(b, key) && sameKeptValue(a[key], b[key]));
80
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * THE SPREADSHEET.
3
+ *
4
+ * What a grid alone owns: the renderer and its personal prefs. What a COLUMN is
5
+ * (schema, capabilities, visibility, filters, prefs) is the views package's
6
+ * model, which every view reads: import it from `@viewkitjs/views`. The binding's helpers ride
7
+ * the same door: the commit types, the column values a filter offers, a cell's copy text and
8
+ * baseline, the title link's class.
9
+ */
10
+ export { useGridTablePrefs } from "./useGridTablePrefs.js";
11
+ export { GridTable, type GridTableProps } from "./chrome/GridTable.js";
12
+ export type { GridGroupByState, GridSortState } from "./chrome/GridColumnMenu.js";
13
+ export type { GridGroupSortOption } from "./chrome/GridGroupMenu.js";
14
+ export type { GridGroupFigure, GroupCountNoun } from "./chrome/grid-table-props.js";
15
+ export type { GridCellCommitFn, GridCellsCommitFn, GridCommitContext, GridCommitOutcome, } from "./core/commit-model.js";
16
+ export { deriveGridRelationValues, deriveGridSelectValues } from "./core/column-values.js";
17
+ export { cellCopyText, cellEditBaseline } from "./core/clipboard-model.js";
18
+ export { GRID_TITLE_LINK_CLASS } from "./chrome/grid-cell-classes.js";
@@ -0,0 +1,5 @@
1
+ export { useGridTablePrefs } from "./useGridTablePrefs.js";
2
+ export { GridTable } from "./chrome/GridTable.js";
3
+ export { deriveGridRelationValues, deriveGridSelectValues } from "./core/column-values.js";
4
+ export { cellCopyText, cellEditBaseline } from "./core/clipboard-model.js";
5
+ export { GRID_TITLE_LINK_CLASS } from "./chrome/grid-cell-classes.js";
@@ -0,0 +1,49 @@
1
+ import type { ListAggregateKind, ListColumn, ListSelectColor } from "../model/column-schema.js";
2
+ import type { ListDateStyle, ListDurationStyle, ListNumberFormatOverrides } from "../model/column-format.js";
3
+ import type { ListColumnState } from "../model/column-state.js";
4
+ import { type ListGroupSummaryPart, type ListViewPrefs } from "../model/preferences.js";
5
+ import type { PercentDisplay } from "@viewkitjs/fields";
6
+ /**
7
+ * THE standard wiring between a list's view-prefs blob and the grid: hands back
8
+ * `gridProps` to spread onto `<GridTable>` (all the per-user knobs + handlers).
9
+ * A host's layout panel is its own, built from the same handlers. Active-view
10
+ * selection and list-level filters belong to the binding.
11
+ */
12
+ export declare function useGridTablePrefs<Row>({ prefs, setPrefs, columns, viewBacked, }: {
13
+ prefs: ListViewPrefs;
14
+ setPrefs: (patch: Partial<ListViewPrefs>) => void;
15
+ /** The list's declared grid columns: the number formats read each one's money. */
16
+ columns: ListColumn<Row>[];
17
+ /** Saved views persist only field-backed column presentation. */
18
+ viewBacked?: boolean;
19
+ }): {
20
+ gridProps: {
21
+ verticalBorders: boolean;
22
+ showRowIcon: boolean;
23
+ freezeIdentity: boolean;
24
+ alwaysCheckboxes: boolean;
25
+ scale: number;
26
+ optionColors: import("../model/column-schema.js").ListOptionColorOverrides;
27
+ onOptionColorChange: (key: string, value: string, color: ListSelectColor | null) => void;
28
+ dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
29
+ onDateStyleChange: (key: string, style: ListDateStyle) => void;
30
+ durationStyles: import("../model/column-format.js").ListDurationStyleOverrides;
31
+ onDurationStyleChange: (key: string, style: ListDurationStyle) => void;
32
+ showTimeOverrides: import("../model/column-format.js").ListShowTimeOverrides;
33
+ onShowTimeChange: (key: string, show: boolean) => void;
34
+ percentDisplays: import("../model/column-format.js").ListPercentDisplayOverrides;
35
+ onPercentDisplayChange: (key: string, display: PercentDisplay) => void;
36
+ columnState: ListColumnState;
37
+ onColumnStateChange: (next: ListColumnState) => void;
38
+ groupSummary: ListGroupSummaryPart[];
39
+ onGroupSummaryChange: (part: ListGroupSummaryPart, next: boolean) => void;
40
+ aggregates: Record<string, ListAggregateKind>;
41
+ onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
42
+ viewBacked: boolean;
43
+ numberFormats: ListNumberFormatOverrides;
44
+ onNumberFormatChange: (key: string, patch: {
45
+ decimals?: number | null;
46
+ currency?: string;
47
+ }) => void;
48
+ };
49
+ };