@viewkitjs/views 0.5.0 → 0.6.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 (413) hide show
  1. package/CHANGELOG.md +620 -0
  2. package/README.md +4 -2
  3. package/dist/atoms/Avatar.d.ts +2 -0
  4. package/dist/atoms/Avatar.js +13 -0
  5. package/dist/atoms/CellMore.d.ts +2 -0
  6. package/dist/atoms/CellMore.js +4 -0
  7. package/dist/atoms/DisabledReason.d.ts +11 -0
  8. package/dist/atoms/DisabledReason.js +10 -0
  9. package/dist/atoms/DrillRows.d.ts +2 -2
  10. package/dist/atoms/DrillRows.js +7 -5
  11. package/dist/atoms/Loading.d.ts +6 -0
  12. package/dist/atoms/Loading.js +4 -1
  13. package/dist/atoms/PanelRows.js +3 -5
  14. package/dist/atoms/Pill.d.ts +2 -0
  15. package/dist/atoms/Pill.js +25 -0
  16. package/dist/atoms/RangeCalendar.d.ts +8 -0
  17. package/dist/atoms/RangeCalendar.js +30 -0
  18. package/dist/atoms/RelationRoles.js +2 -2
  19. package/dist/atoms/SelectionSheet.js +5 -4
  20. package/dist/atoms/ToolbarButton.d.ts +2 -0
  21. package/dist/atoms/ToolbarButton.js +18 -0
  22. package/dist/atoms/defaults.js +10 -0
  23. package/dist/atoms/types.d.ts +141 -1
  24. package/dist/cells/cell-format.d.ts +10 -1
  25. package/dist/cells/cell-title.d.ts +5 -1
  26. package/dist/cells/cell-title.js +2 -2
  27. package/dist/cells/cell-values.js +22 -7
  28. package/dist/cells/relation-wrap.js +1 -1
  29. package/dist/contract.d.ts +351 -15
  30. package/dist/contract.js +482 -4
  31. package/dist/display/actor.js +1 -1
  32. package/dist/display/boolean.js +5 -0
  33. package/dist/display/entity-chip.d.ts +12 -9
  34. package/dist/display/entity-chip.js +4 -5
  35. package/dist/display/fit-values.d.ts +34 -0
  36. package/dist/display/fit-values.js +45 -0
  37. package/dist/display/location.js +1 -1
  38. package/dist/display/multi-value.js +72 -8
  39. package/dist/display/options.d.ts +9 -1
  40. package/dist/display/relation.js +1 -1
  41. package/dist/display/rich-text.js +17 -6
  42. package/dist/display/select.js +6 -4
  43. package/dist/display/status-steps.d.ts +8 -0
  44. package/dist/display/status-steps.js +18 -0
  45. package/dist/display/viewer.js +1 -0
  46. package/dist/editors/BodyFrame.d.ts +29 -0
  47. package/dist/editors/BodyFrame.js +80 -0
  48. package/dist/editors/DateEditor.js +13 -17
  49. package/dist/editors/LocationEditor.d.ts +2 -0
  50. package/dist/editors/LocationEditor.js +29 -5
  51. package/dist/editors/NameEditor.d.ts +2 -0
  52. package/dist/editors/NameEditor.js +27 -7
  53. package/dist/editors/NumberEditor.d.ts +18 -0
  54. package/dist/editors/NumberEditor.js +29 -2
  55. package/dist/editors/RangeEditor.d.ts +2 -0
  56. package/dist/editors/RangeEditor.js +29 -4
  57. package/dist/editors/SelectEditor.d.ts +5 -0
  58. package/dist/editors/SelectEditor.js +3 -2
  59. package/dist/editors/TextEditor.d.ts +11 -1
  60. package/dist/editors/TextEditor.js +25 -8
  61. package/dist/editors/ValueListEditor.d.ts +7 -0
  62. package/dist/editors/ValueListEditor.js +60 -48
  63. package/dist/editors/body-panel.d.ts +7 -0
  64. package/dist/editors/body-panel.js +8 -0
  65. package/dist/editors/edit-session.d.ts +20 -3
  66. package/dist/editors/edit-session.js +43 -3
  67. package/dist/editors/leave-scope.d.ts +23 -0
  68. package/dist/editors/leave-scope.js +28 -0
  69. package/dist/editors/number-body.d.ts +29 -0
  70. package/dist/editors/number-body.js +37 -0
  71. package/dist/editors/parts-body.d.ts +66 -0
  72. package/dist/editors/parts-body.js +114 -0
  73. package/dist/editors/tab-ends.d.ts +5 -0
  74. package/dist/editors/tab-ends.js +7 -0
  75. package/dist/editors/text-body.d.ts +16 -0
  76. package/dist/editors/text-body.js +30 -0
  77. package/dist/editors/values-body.d.ts +47 -0
  78. package/dist/editors/values-body.js +140 -0
  79. package/dist/field-row/FieldRow.d.ts +7 -0
  80. package/dist/field-row/FieldRow.js +44 -24
  81. package/dist/field-row/FieldRowLane.js +12 -4
  82. package/dist/field-row/editors/RowChipsEditor.js +3 -1
  83. package/dist/field-row/editors/RowEditor.js +2 -1
  84. package/dist/field-row/editors/RowNameEditor.d.ts +5 -2
  85. package/dist/field-row/editors/RowNameEditor.js +12 -5
  86. package/dist/field-row/editors/RowNumberEditor.js +18 -2
  87. package/dist/field-row/editors/RowPlaceEditor.js +4 -2
  88. package/dist/field-row/editors/RowRangeEditor.d.ts +5 -2
  89. package/dist/field-row/editors/RowRangeEditor.js +13 -6
  90. package/dist/field-row/editors/RowRelationEditor.js +5 -2
  91. package/dist/field-row/editors/RowSelectEditor.js +4 -1
  92. package/dist/field-row/editors/RowTextEditor.d.ts +1 -1
  93. package/dist/field-row/editors/RowTextEditor.js +12 -3
  94. package/dist/field-row/editors/RowValueListEditor.d.ts +2 -1
  95. package/dist/field-row/editors/RowValueListEditor.js +17 -4
  96. package/dist/field-row/editors/host.d.ts +3 -0
  97. package/dist/field-row/editors/row-session.d.ts +12 -1
  98. package/dist/field-row/editors/row-session.js +52 -2
  99. package/dist/field-row/field-row-button.d.ts +40 -0
  100. package/dist/field-row/field-row-button.js +18 -0
  101. package/dist/field-row/field-row-checkbox.d.ts +9 -0
  102. package/dist/field-row/field-row-checkbox.js +7 -0
  103. package/dist/filters/filter-model.d.ts +2 -0
  104. package/dist/grid/chrome/GridAddColumn.js +17 -3
  105. package/dist/grid/chrome/GridAggregateMenu.d.ts +2 -0
  106. package/dist/grid/chrome/GridAggregateMenu.js +2 -0
  107. package/dist/grid/chrome/GridCellEditors.js +16 -6
  108. package/dist/grid/chrome/GridCellOutline.d.ts +7 -4
  109. package/dist/grid/chrome/GridCellOutline.js +4 -2
  110. package/dist/grid/chrome/GridChipsEditor.js +3 -1
  111. package/dist/grid/chrome/GridColumnMenu.d.ts +4 -1
  112. package/dist/grid/chrome/GridColumnMenu.js +5 -3
  113. package/dist/grid/chrome/GridColumnSortSection.d.ts +20 -0
  114. package/dist/grid/chrome/GridColumnSortSection.js +18 -1
  115. package/dist/grid/chrome/GridFooter.d.ts +4 -1
  116. package/dist/grid/chrome/GridFooter.js +6 -4
  117. package/dist/grid/chrome/GridGroupMenu.d.ts +5 -1
  118. package/dist/grid/chrome/GridGroupMenu.js +30 -8
  119. package/dist/grid/chrome/GridHeader.d.ts +5 -1
  120. package/dist/grid/chrome/GridHeader.js +9 -5
  121. package/dist/grid/chrome/GridLongTextEditor.js +15 -11
  122. package/dist/grid/chrome/GridNameEditor.js +4 -2
  123. package/dist/grid/chrome/GridNumberEditor.d.ts +8 -1
  124. package/dist/grid/chrome/GridNumberEditor.js +15 -3
  125. package/dist/grid/chrome/GridPager.d.ts +7 -0
  126. package/dist/grid/chrome/GridPager.js +34 -0
  127. package/dist/grid/chrome/GridPlaceEditor.js +4 -2
  128. package/dist/grid/chrome/GridRangeEditor.js +12 -4
  129. package/dist/grid/chrome/GridRelationEditor.js +5 -2
  130. package/dist/grid/chrome/GridRow.js +18 -6
  131. package/dist/grid/chrome/GridRowActions.d.ts +8 -3
  132. package/dist/grid/chrome/GridRowActions.js +16 -6
  133. package/dist/grid/chrome/GridRowCells.js +23 -7
  134. package/dist/grid/chrome/GridRowGlyph.d.ts +3 -1
  135. package/dist/grid/chrome/GridRowGlyph.js +7 -2
  136. package/dist/grid/chrome/GridSelectEditor.js +6 -3
  137. package/dist/grid/chrome/GridStructure.d.ts +6 -1
  138. package/dist/grid/chrome/GridStructure.js +32 -8
  139. package/dist/grid/chrome/GridTable.js +36 -24
  140. package/dist/grid/chrome/GridTableSurface.d.ts +5 -1
  141. package/dist/grid/chrome/GridTableSurface.js +5 -2
  142. package/dist/grid/chrome/GridTextEditor.d.ts +5 -1
  143. package/dist/grid/chrome/GridTextEditor.js +13 -3
  144. package/dist/grid/chrome/GridValueListEditor.d.ts +12 -4
  145. package/dist/grid/chrome/GridValueListEditor.js +11 -3
  146. package/dist/grid/chrome/StuckMarker.d.ts +3 -1
  147. package/dist/grid/chrome/StuckMarker.js +6 -2
  148. package/dist/grid/chrome/cells.d.ts +4 -2
  149. package/dist/grid/chrome/cells.js +2 -2
  150. package/dist/grid/chrome/grid-add-column-items.d.ts +1 -1
  151. package/dist/grid/chrome/grid-add-column-items.js +8 -1
  152. package/dist/grid/chrome/grid-button.d.ts +32 -0
  153. package/dist/grid/chrome/grid-button.js +12 -0
  154. package/dist/grid/chrome/grid-cell-classes.d.ts +38 -0
  155. package/dist/grid/chrome/grid-cell-classes.js +30 -0
  156. package/dist/grid/chrome/grid-column-menu-items.d.ts +3 -0
  157. package/dist/grid/chrome/grid-column-menu-items.js +32 -3
  158. package/dist/grid/chrome/grid-columns-template.d.ts +27 -0
  159. package/dist/grid/chrome/grid-columns-template.js +13 -0
  160. package/dist/grid/chrome/grid-edit-session.d.ts +4 -1
  161. package/dist/grid/chrome/grid-edit-session.js +11 -1
  162. package/dist/grid/chrome/grid-group-menu-items.d.ts +8 -1
  163. package/dist/grid/chrome/grid-group-menu-items.js +17 -0
  164. package/dist/grid/chrome/grid-group-menu-parts.d.ts +10 -6
  165. package/dist/grid/chrome/grid-group-menu-parts.js +4 -2
  166. package/dist/grid/chrome/grid-hover.d.ts +4 -1
  167. package/dist/grid/chrome/grid-hover.js +16 -6
  168. package/dist/grid/chrome/grid-pages.d.ts +15 -0
  169. package/dist/grid/chrome/grid-pages.js +9 -0
  170. package/dist/grid/chrome/grid-row-menu-items.js +18 -10
  171. package/dist/grid/chrome/grid-row-props.d.ts +6 -2
  172. package/dist/grid/chrome/grid-row-window.d.ts +7 -0
  173. package/dist/grid/chrome/grid-row-window.js +35 -1
  174. package/dist/grid/chrome/grid-table-props.d.ts +38 -4
  175. package/dist/grid/chrome/useGridColumnLayout.d.ts +3 -1
  176. package/dist/grid/chrome/useGridColumnLayout.js +29 -9
  177. package/dist/grid/chrome/useGridPartColumns.js +1 -1
  178. package/dist/grid/chrome/useGridScrollArea.js +2 -0
  179. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
  180. package/dist/grid/chrome/useGridTableInteractionModel.js +5 -3
  181. package/dist/grid/chrome/useGridTableSelection.d.ts +3 -1
  182. package/dist/grid/chrome/useGridTableSelection.js +2 -2
  183. package/dist/grid/chrome/useHeaderDragReorder.js +2 -0
  184. package/dist/grid/core/editing-controller.d.ts +36 -11
  185. package/dist/grid/core/editing-controller.js +92 -25
  186. package/dist/grid/core/grid-aria.d.ts +4 -0
  187. package/dist/grid/core/grid-aria.js +6 -4
  188. package/dist/grid/core/grid-focus.d.ts +6 -0
  189. package/dist/grid/core/grid-focus.js +28 -5
  190. package/dist/grid/core/useGridEditing.d.ts +11 -2
  191. package/dist/grid/core/useGridEditing.js +9 -5
  192. package/dist/grid/core/write-states.d.ts +20 -0
  193. package/dist/grid/core/write-states.js +21 -0
  194. package/dist/grid/grid-format-props.d.ts +26 -0
  195. package/dist/grid/grid-format-props.js +65 -0
  196. package/dist/grid/index.d.ts +3 -1
  197. package/dist/grid/index.js +1 -0
  198. package/dist/grid/useGridTablePrefs.d.ts +19 -20
  199. package/dist/grid/useGridTablePrefs.js +6 -58
  200. package/dist/grid/useGridTableSettings.d.ts +60 -0
  201. package/dist/grid/useGridTableSettings.js +61 -0
  202. package/dist/internal/count.d.ts +3 -0
  203. package/dist/internal/count.js +3 -0
  204. package/dist/model/body-frame.d.ts +16 -0
  205. package/dist/model/body-frame.js +5 -0
  206. package/dist/model/column-capabilities.d.ts +4 -1
  207. package/dist/model/column-capabilities.js +4 -1
  208. package/dist/model/column-filters.d.ts +7 -4
  209. package/dist/model/column-filters.js +26 -18
  210. package/dist/model/column-inspect.d.ts +3 -2
  211. package/dist/model/column-inspect.js +3 -1
  212. package/dist/model/column-sort.d.ts +11 -0
  213. package/dist/model/column-sort.js +14 -0
  214. package/dist/model/one-value.d.ts +6 -0
  215. package/dist/model/one-value.js +5 -0
  216. package/dist/model/part-write.js +1 -1
  217. package/dist/model/place-parts.d.ts +6 -0
  218. package/dist/model/place-parts.js +14 -0
  219. package/dist/model/relation-filters.d.ts +13 -2
  220. package/dist/model/relation-filters.js +9 -4
  221. package/dist/model/row-icon.d.ts +16 -6
  222. package/dist/model/settings-columns.d.ts +34 -0
  223. package/dist/model/settings-columns.js +146 -0
  224. package/dist/model/settings-look.d.ts +17 -0
  225. package/dist/model/settings-look.js +23 -0
  226. package/dist/model/view-rules.js +6 -2
  227. package/dist/panels/availability.d.ts +26 -0
  228. package/dist/panels/availability.js +28 -0
  229. package/dist/panels/filter/DateFilterBody.d.ts +42 -0
  230. package/dist/panels/filter/DateFilterBody.js +64 -0
  231. package/dist/panels/filter/DateFilterCalendar.d.ts +19 -0
  232. package/dist/panels/filter/DateFilterCalendar.js +37 -0
  233. package/dist/panels/filter/DateFilterInput.d.ts +16 -0
  234. package/dist/panels/filter/DateFilterInput.js +37 -0
  235. package/dist/panels/filter/FilterIcon.d.ts +7 -0
  236. package/dist/panels/filter/FilterIcon.js +15 -0
  237. package/dist/panels/filter/MenuSelect.d.ts +12 -0
  238. package/dist/panels/filter/MenuSelect.js +34 -0
  239. package/dist/panels/filter/NumberFilterBody.d.ts +21 -0
  240. package/dist/panels/filter/NumberFilterBody.js +76 -0
  241. package/dist/panels/filter/RangeFilterBody.d.ts +19 -0
  242. package/dist/panels/filter/RangeFilterBody.js +71 -0
  243. package/dist/panels/filter/RelationFilterBody.d.ts +17 -0
  244. package/dist/panels/filter/RelationFilterBody.js +20 -0
  245. package/dist/panels/filter/TextFilterBody.d.ts +31 -0
  246. package/dist/panels/filter/TextFilterBody.js +44 -0
  247. package/dist/panels/filter/TimeScopeDetail.d.ts +6 -0
  248. package/dist/panels/filter/TimeScopeDetail.js +47 -0
  249. package/dist/panels/filter/details.d.ts +17 -0
  250. package/dist/panels/filter/details.js +73 -0
  251. package/dist/panels/filter/filter-list.d.ts +23 -0
  252. package/dist/panels/filter/filter-list.js +38 -0
  253. package/dist/panels/group-sort.d.ts +24 -0
  254. package/dist/panels/group-sort.js +58 -0
  255. package/dist/panels/index.d.ts +24 -0
  256. package/dist/panels/index.js +17 -0
  257. package/dist/panels/labels.d.ts +37 -0
  258. package/dist/panels/labels.js +166 -0
  259. package/dist/panels/model.d.ts +343 -0
  260. package/dist/panels/model.js +77 -0
  261. package/dist/panels/react/GroupBucketsList.d.ts +16 -0
  262. package/dist/panels/react/GroupBucketsList.js +38 -0
  263. package/dist/panels/react/LayoutColumnsList.d.ts +24 -0
  264. package/dist/panels/react/LayoutColumnsList.js +71 -0
  265. package/dist/panels/react/PopoverColumnDetail.d.ts +11 -0
  266. package/dist/panels/react/PopoverColumnDetail.js +24 -0
  267. package/dist/panels/react/chrome.d.ts +17 -0
  268. package/dist/panels/react/chrome.js +8 -0
  269. package/dist/panels/react/column-refusals.d.ts +7 -0
  270. package/dist/panels/react/column-refusals.js +14 -0
  271. package/dist/panels/react/customize.d.ts +26 -0
  272. package/dist/panels/react/customize.js +98 -0
  273. package/dist/panels/react/drag.d.ts +2 -0
  274. package/dist/panels/react/drag.js +6 -0
  275. package/dist/panels/react/field-editor.d.ts +10 -0
  276. package/dist/panels/react/field-editor.js +1 -0
  277. package/dist/panels/react/filter-panel.d.ts +15 -0
  278. package/dist/panels/react/filter-panel.js +48 -0
  279. package/dist/panels/react/layout-detail.d.ts +4 -0
  280. package/dist/panels/react/layout-detail.js +21 -0
  281. package/dist/panels/react/order-details.d.ts +32 -0
  282. package/dist/panels/react/order-details.js +81 -0
  283. package/dist/panels/react/panel-header.d.ts +10 -0
  284. package/dist/panels/react/panel-header.js +12 -0
  285. package/dist/panels/react/panel-sheet.d.ts +19 -0
  286. package/dist/panels/react/panel-sheet.js +22 -0
  287. package/dist/panels/react/popover.d.ts +71 -0
  288. package/dist/panels/react/popover.js +47 -0
  289. package/dist/panels/react/root-list.d.ts +6 -0
  290. package/dist/panels/react/root-list.js +31 -0
  291. package/dist/panels/react/toolbar/ReadyToolbar.d.ts +42 -0
  292. package/dist/panels/react/toolbar/ReadyToolbar.js +92 -0
  293. package/dist/panels/react/toolbar/Toolbar.d.ts +16 -0
  294. package/dist/panels/react/toolbar/Toolbar.js +34 -0
  295. package/dist/panels/react/toolbar/ToolbarButton.d.ts +5 -0
  296. package/dist/panels/react/toolbar/ToolbarButton.js +9 -0
  297. package/dist/panels/react/toolbar/ToolbarFilter.d.ts +19 -0
  298. package/dist/panels/react/toolbar/ToolbarFilter.js +32 -0
  299. package/dist/panels/react/toolbar/ToolbarNew.d.ts +12 -0
  300. package/dist/panels/react/toolbar/ToolbarNew.js +21 -0
  301. package/dist/panels/react/toolbar/ToolbarOptions.d.ts +25 -0
  302. package/dist/panels/react/toolbar/ToolbarOptions.js +33 -0
  303. package/dist/panels/react/toolbar/ToolbarSearch.d.ts +9 -0
  304. package/dist/panels/react/toolbar/ToolbarSearch.js +41 -0
  305. package/dist/panels/react/toolbar/ToolbarSort.d.ts +12 -0
  306. package/dist/panels/react/toolbar/ToolbarSort.js +16 -0
  307. package/dist/panels/react/toolbar/ToolbarViews.d.ts +13 -0
  308. package/dist/panels/react/toolbar/ToolbarViews.js +24 -0
  309. package/dist/panels/react/toolbar/context.d.ts +29 -0
  310. package/dist/panels/react/toolbar/context.js +49 -0
  311. package/dist/panels/react/toolbar/panel-part.d.ts +37 -0
  312. package/dist/panels/react/toolbar/panel-part.js +37 -0
  313. package/dist/panels/react/toolbar/panel-state.d.ts +9 -0
  314. package/dist/panels/react/toolbar/panel-state.js +12 -0
  315. package/dist/panels/react/toolbar/use-box-narrow.d.ts +2 -0
  316. package/dist/panels/react/toolbar/use-box-narrow.js +18 -0
  317. package/dist/panels/react/toolbar/use-list-settings-state.d.ts +10 -0
  318. package/dist/panels/react/toolbar/use-list-settings-state.js +10 -0
  319. package/dist/panels/react/view-actions.d.ts +4 -0
  320. package/dist/panels/react/view-actions.js +37 -0
  321. package/dist/panels/react/view-footer.d.ts +16 -0
  322. package/dist/panels/react/view-footer.js +11 -0
  323. package/dist/panels/react/views-row/FoldingViewRow.d.ts +4 -0
  324. package/dist/panels/react/views-row/FoldingViewRow.js +105 -0
  325. package/dist/panels/react/views-row/HScrollRow.d.ts +7 -0
  326. package/dist/panels/react/views-row/HScrollRow.js +42 -0
  327. package/dist/panels/react/views-row/PillGroup.d.ts +30 -0
  328. package/dist/panels/react/views-row/PillGroup.js +86 -0
  329. package/dist/panels/react/views-row/ViewAxes.d.ts +6 -0
  330. package/dist/panels/react/views-row/ViewAxes.js +16 -0
  331. package/dist/panels/react/views-row/ViewCreatePill.d.ts +7 -0
  332. package/dist/panels/react/views-row/ViewCreatePill.js +11 -0
  333. package/dist/panels/react/views-row/ViewPicker.d.ts +5 -0
  334. package/dist/panels/react/views-row/ViewPicker.js +65 -0
  335. package/dist/panels/react/views-row/ViewPickerRow.d.ts +7 -0
  336. package/dist/panels/react/views-row/ViewPickerRow.js +18 -0
  337. package/dist/panels/react/views-row/ViewTabs.d.ts +31 -0
  338. package/dist/panels/react/views-row/ViewTabs.js +29 -0
  339. package/dist/panels/react/views-row/menu-classes.d.ts +6 -0
  340. package/dist/panels/react/views-row/menu-classes.js +3 -0
  341. package/dist/panels/react/views-row/use-anchored-toggle.d.ts +19 -0
  342. package/dist/panels/react/views-row/use-anchored-toggle.js +31 -0
  343. package/dist/panels/react.d.ts +51 -0
  344. package/dist/panels/react.js +43 -0
  345. package/dist/panels/settings/axes.d.ts +28 -0
  346. package/dist/panels/settings/axes.js +71 -0
  347. package/dist/panels/settings/filters.d.ts +5 -0
  348. package/dist/panels/settings/filters.js +62 -0
  349. package/dist/panels/settings/group-buckets.d.ts +23 -0
  350. package/dist/panels/settings/group-buckets.js +73 -0
  351. package/dist/panels/settings/input.d.ts +69 -0
  352. package/dist/panels/settings/input.js +1 -0
  353. package/dist/panels/settings/layout.d.ts +5 -0
  354. package/dist/panels/settings/layout.js +244 -0
  355. package/dist/panels/settings/order.d.ts +19 -0
  356. package/dist/panels/settings/order.js +271 -0
  357. package/dist/panels/settings/settings-panels.d.ts +17 -0
  358. package/dist/panels/settings/settings-panels.js +28 -0
  359. package/dist/panels/toolbar/clear.d.ts +9 -0
  360. package/dist/panels/toolbar/clear.js +26 -0
  361. package/dist/panels/toolbar/counts.d.ts +15 -0
  362. package/dist/panels/toolbar/counts.js +21 -0
  363. package/dist/panels/toolbar/edit-view.d.ts +5 -0
  364. package/dist/panels/toolbar/edit-view.js +18 -0
  365. package/dist/panels/toolbar/model.d.ts +34 -0
  366. package/dist/panels/toolbar/model.js +52 -0
  367. package/dist/panels/use-filter-opened.d.ts +8 -0
  368. package/dist/panels/use-filter-opened.js +11 -0
  369. package/dist/panels/view-state.d.ts +38 -0
  370. package/dist/panels/view-state.js +1 -0
  371. package/dist/panels/views-row/model.d.ts +131 -0
  372. package/dist/panels/views-row/model.js +14 -0
  373. package/dist/provider/ViewsProvider.d.ts +46 -6
  374. package/dist/provider/ViewsProvider.js +32 -2
  375. package/dist/provider/components.d.ts +258 -11
  376. package/dist/provider/context.d.ts +21 -2
  377. package/dist/react.d.ts +5 -2
  378. package/dist/selection/SelectionBar.js +13 -7
  379. package/dist/selection/bar-overflow.js +14 -1
  380. package/dist/selection/bar-parts.d.ts +4 -2
  381. package/dist/selection/bar-parts.js +5 -3
  382. package/dist/selection/useListSelectionShortcuts.d.ts +3 -2
  383. package/dist/selection/useListSelectionShortcuts.js +1 -1
  384. package/dist/selection/verbs.d.ts +7 -0
  385. package/docs/contract.md +307 -41
  386. package/docs/getting-started.md +1 -1
  387. package/docs/guides/atoms.md +37 -5
  388. package/docs/guides/columns.md +1 -1
  389. package/docs/guides/display.md +3 -2
  390. package/docs/guides/editors.md +4 -3
  391. package/docs/guides/selection.md +4 -2
  392. package/docs/guides/the-grid.md +21 -11
  393. package/docs/guides/the-provider.md +22 -6
  394. package/docs/index.md +2 -2
  395. package/docs/install.md +2 -3
  396. package/docs/reference/cells.md +1 -1
  397. package/docs/reference/display.md +5 -4
  398. package/docs/reference/editors-location.md +3 -1
  399. package/docs/reference/editors-name.md +3 -1
  400. package/docs/reference/editors-number.md +1 -0
  401. package/docs/reference/editors-range.md +3 -1
  402. package/docs/reference/editors-session.md +1 -0
  403. package/docs/reference/editors-text.md +2 -2
  404. package/docs/reference/editors-value-list.md +1 -1
  405. package/docs/reference/field-row.md +2 -2
  406. package/docs/reference/grid.md +8 -5
  407. package/docs/reference/panels-react.md +101 -0
  408. package/docs/reference/panels.md +123 -0
  409. package/docs/reference/react.md +39 -16
  410. package/docs/reference/selection.md +5 -5
  411. package/docs/reference/views.md +17 -12
  412. package/package.json +16 -6
  413. package/skills/views/SKILL.md +4 -3
@@ -47,6 +47,21 @@ export type GridGroupFigure<Row> = GridDeclaredFigure | GridDrawnFigure<Row>;
47
47
  /** A view's identity: when it changes, the whole body is replaced, and the grid shows its wait for
48
48
  * one commit first. */
49
49
  type GridTransitionKey = string | number | boolean | null | undefined;
50
+ /** A grid in pages: the page on screen, its size, the view's count, and what moving does. */
51
+ export type GridPages = {
52
+ /** The page on screen, from 1. */
53
+ page: number;
54
+ /** How many rows a page holds. */
55
+ size: number;
56
+ /** How many rows the view keeps (the translator's `totalQuery`). */
57
+ total: number;
58
+ /** False when `total` is a capped count: the pager reads "of 1,000+". Default true. */
59
+ exact?: boolean;
60
+ /** The page-size pick's choices. Default 25, 50 and 100. */
61
+ sizes?: readonly number[];
62
+ onPage: (page: number) => void;
63
+ onSize: (size: number) => void;
64
+ };
50
65
  export type GridTableProps<Row> = {
51
66
  /** View/filter identity that replaces the whole collection body. */
52
67
  transitionKey?: GridTransitionKey;
@@ -62,9 +77,10 @@ export type GridTableProps<Row> = {
62
77
  /** Hide a group in the view, from its band's menu. Absent where a
63
78
  * list cannot hide one. */
64
79
  onHideGroup?: (key: string) => void;
65
- /** Which parts a group band's ⋯ menu holds: `"sort"`, `"figures"` (the count and each figure, turned on and
66
- * off) and `"hide"`. Each shows only when you also pass what it needs: `sort` with `sortOptions`;
67
- * `groupFigures` with `onGroupSummaryChange`; `onHideGroup`. On the `popover` route the sort list then always
80
+ /** Which parts a group band's ⋯ menu holds: `"select"` (Select all in group, leading the menu), `"sort"`,
81
+ * `"figures"` (the count and each figure, turned on and off) and `"hide"`. Each shows only when you also pass
82
+ * what it needs: `selection` for Select; `sort` with `sortOptions`; `groupFigures` with `onGroupSummaryChange`;
83
+ * `onHideGroup`. Select is never in the menu unless you name it here. On the `popover` route the sort list then always
68
84
  * searches through your `Command`, at any count. Left out, the ⋯ opens for sort or Hide, carries the figure toggles
69
85
  * with them, and searches past eight sort choices. On the `menu` route (the provider's `menus`) the sort choices
70
86
  * open beside the menu with no search, either way. */
@@ -123,7 +139,7 @@ export type GridTableProps<Row> = {
123
139
  * Select) for those that apply to it, so a key reaches them. */
124
140
  rowActions?: ListCellAction<Row>[];
125
141
  /** The leading glyph in the title cell, as a DESCRIPTOR — the grid decides
126
- * size and color from it. See `ListRowIconAccessor`. */
142
+ * size and color from it; one carrying an `avatar` draws the app's Avatar atom. See `ListRowIconAccessor`. */
127
143
  rowIcon?: ListRowIconAccessor<Row>;
128
144
  showRowIcon?: boolean;
129
145
  selection?: ListSelectionConfig;
@@ -132,11 +148,24 @@ export type GridTableProps<Row> = {
132
148
  onReveal: () => void;
133
149
  label?: string;
134
150
  };
151
+ /** Rows in pages: you hand one page's rows, and a pager under the grid shows where you are and moves between pages.
152
+ * `loadMore` is then not drawn, picks clear when the page or its size changes, and the footer shows only the figures
153
+ * you hand in a group's `figures` (a page's own sum is not the view's). A grouped grid draws no pager and keeps each
154
+ * group's own `loadMore` and `renderGroupFooter`. Absent (the default): rows arrive as you scroll. */
155
+ pages?: GridPages;
135
156
  emptyState?: ReactNode;
136
157
  /** The reader's default currency: a money column read in Original totals in it. The host's
137
158
  * answer (the portal: the reader's preference); default `DEFAULT_DISPLAY_CURRENCY`. */
138
159
  defaultCurrency?: DisplayCurrency;
160
+ /** Rules between the columns: the rows' always, the header's too with `headerVerticalBorders`. Default true. */
139
161
  verticalBorders?: boolean;
162
+ /** The header's columns follow `verticalBorders` as the rows' do, the last bare. Default false: the header draws no
163
+ * line between its columns unless the app asks. */
164
+ headerVerticalBorders?: boolean;
165
+ /** The columns share the grid's whole width, each growing in proportion to its own width and never below it; a
166
+ * column the person resized keeps its width, and one that declares `grid.maxWidth` too. A table already wider than
167
+ * the grid is unchanged and scrolls sideways. Default false: every column stands at its own width. */
168
+ fillWidth?: boolean;
140
169
  sort?: GridSortState;
141
170
  /** The view's group, for the header menu's Group by / Ungroup — present on
142
171
  * view-backed lists only, the way `sort` is. */
@@ -208,6 +237,11 @@ export type GridTableProps<Row> = {
208
237
  /** Per-user "Show checkboxes always" toggle: holds the checkbox rail open
209
238
  * instead of revealing it on hover. Same state a live selection forces. */
210
239
  alwaysCheckboxes?: boolean;
240
+ /** A grouped grid draws one row of column names, pinned at the top of its scroll area over every group, in place
241
+ * of each group's own; each group's bar pins under it, and the row's checkbox picks every row. Off by default:
242
+ * each group draws its own column names, with the box that picks its rows. An ungrouped grid draws one row
243
+ * either way. */
244
+ oneHeader?: boolean;
211
245
  /** Workspace-settings capability config for THIS list (table read-only / per-column
212
246
  * locks), inherited by every user. The CONFIG layer of
213
247
  * `declaration → config → prefs` — it may only SUBTRACT from what the
@@ -2,7 +2,7 @@ import { type PointerEvent as ReactPointerEvent, type RefObject } from "react";
2
2
  import type { ListColumnsConfig } from "../../model/column-state.js";
3
3
  import type { ListColumn } from "../../model/column-schema.js";
4
4
  import { type ListColumnState } from "../../model/column-state.js";
5
- export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity, viewBacked, }: {
5
+ export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity, viewBacked, fillWidth, }: {
6
6
  rootRef: RefObject<HTMLDivElement | null>;
7
7
  columns: ListColumn<Row>[];
8
8
  columnState?: ListColumnState;
@@ -12,6 +12,8 @@ export declare function useGridColumnLayout<Row>({ rootRef, columns, columnState
12
12
  freezeIdentity?: boolean;
13
13
  /** Saved views persist layout only for field-backed columns. */
14
14
  viewBacked?: boolean;
15
+ /** The columns share the grid's width (`GridTableProps.fillWidth`). */
16
+ fillWidth?: boolean;
15
17
  }): {
16
18
  visibleColumns: ListColumn<Row>[];
17
19
  widthVarsStyle: import("react").CSSProperties;
@@ -5,12 +5,13 @@ import { gridWidthVar } from "../core/grid-scale.js";
5
5
  import { clampColumnWidth, columnHideable, isColumnHidden, prettifyOptionValue, resolveColumnOrder, resolveColumnWidths, resolveVisibleColumns, toggleColumnHidden, } from "../../model/column-state.js";
6
6
  import { useViews } from "../../provider/context.js";
7
7
  import { gridColumnGlyph } from "./column-glyph.js";
8
+ import { gridColumnsTemplate } from "./grid-columns-template.js";
8
9
  import { partWord } from "../../model/part-rows.js";
9
10
  function setBodyResizeState(active) {
10
11
  document.body.style.cursor = active ? "col-resize" : "";
11
12
  document.body.style.userSelect = active ? "none" : "";
12
13
  }
13
- export function useGridColumnLayout({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity = true, viewBacked = false, }) {
14
+ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnStateChange, scale, freezeIdentity = true, viewBacked = false, fillWidth = false, }) {
14
15
  const { icons, components, messages } = useViews();
15
16
  const orderKey = columnState?.order;
16
17
  const hiddenKey = columnState?.hidden;
@@ -111,26 +112,41 @@ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnSta
111
112
  dirty: Object.keys(columnState ?? {}).length > 0,
112
113
  };
113
114
  }, [columnState, columns, components.AppIcon, icons, messages, onColumnStateChange, viewBacked]);
114
- const gridTemplate = useMemo(() => [
115
- "0px",
116
- ...visibleColumns.map((col) => `calc(var(${gridWidthVar(col.id)}) * var(--vk-scale))`),
117
- "minmax(var(--vk-tail-w),1fr)",
118
- ].join(" "), [visibleColumns]);
115
+ const [resizingId, setResizingId] = useState(null);
116
+ const storedWidths = columnState?.widths;
117
+ const gridTemplate = useMemo(() => {
118
+ if (!fillWidth)
119
+ return gridColumnsTemplate(visibleColumns, effectiveWidths);
120
+ const fixed = new Set(Object.entries(storedWidths ?? {})
121
+ .filter(([, width]) => width != null)
122
+ .map(([id]) => id));
123
+ if (resizingId)
124
+ fixed.add(resizingId);
125
+ return gridColumnsTemplate(visibleColumns, effectiveWidths, { fillWidth, fixed });
126
+ }, [visibleColumns, effectiveWidths, fillWidth, storedWidths, resizingId]);
119
127
  const minWidth = useMemo(() => `calc((${visibleColumns
120
128
  .map((col) => `var(${gridWidthVar(col.id)})`)
121
129
  .join(" + ")}) * var(--vk-scale) + 2*var(--vk-gutter,0px) + var(--vk-indent,0px) + var(--vk-tail-w))`, [visibleColumns]);
122
- const [resizingId, setResizingId] = useState(null);
123
130
  const dragRef = useRef(null);
124
131
  const rafRef = useRef(null);
125
132
  const pendingXRef = useRef(0);
126
133
  const lastGestureMovedRef = useRef(false);
127
134
  const startResize = (col, event) => {
135
+ const grows = fillWidth && storedWidths?.[col.id] == null && col.grid?.maxWidth == null;
136
+ const drawn = grows
137
+ ? (event.currentTarget.closest("[data-headcell]")?.getBoundingClientRect().width ?? 0) / scale
138
+ : 0;
139
+ const measured = drawn > 0;
140
+ const startW = measured ? clampColumnWidth(col, drawn) : effectiveWidths[col.id];
141
+ if (measured)
142
+ rootRef.current?.style.setProperty(gridWidthVar(col.id), `${startW}px`);
128
143
  dragRef.current = {
129
144
  col,
130
145
  startX: event.clientX,
131
- startW: effectiveWidths[col.id],
146
+ startW,
132
147
  lastW: null,
133
148
  moved: false,
149
+ measured,
134
150
  };
135
151
  lastGestureMovedRef.current = false;
136
152
  setResizingId(col.id);
@@ -167,8 +183,12 @@ export function useGridColumnLayout({ rootRef, columns, columnState, onColumnSta
167
183
  if (!drag)
168
184
  return;
169
185
  lastGestureMovedRef.current = drag.moved;
170
- if (!drag.moved || drag.lastW == null || drag.lastW === effectiveWidths[drag.col.id])
186
+ const unchanged = !drag.measured && drag.lastW === effectiveWidths[drag.col.id];
187
+ if (!drag.moved || drag.lastW == null || unchanged) {
188
+ if (drag.measured)
189
+ rootRef.current?.style.setProperty(gridWidthVar(drag.col.id), `${effectiveWidths[drag.col.id]}px`);
171
190
  return;
191
+ }
172
192
  onColumnStateChange?.({
173
193
  ...columnState,
174
194
  widths: { ...(columnState?.widths ?? {}), [drag.col.id]: drag.lastW },
@@ -4,6 +4,6 @@ import { withPartColumns } from "../../model/part-columns.js";
4
4
  import { useViews } from "../../provider/context.js";
5
5
  export function useGridPartColumns(columns, parts) {
6
6
  const { messages, conventions } = useViews();
7
- const locale = conventions.locale;
7
+ const locale = conventions.language;
8
8
  return useMemo(() => (parts ? withPartColumns(columns, { messages, locale }) : columns), [columns, parts, messages, locale]);
9
9
  }
@@ -22,6 +22,7 @@ export function useGridScrollArea(rootRef, boxes, recorderRef) {
22
22
  if (flags.scrolled !== scrolled) {
23
23
  flags.scrolled = scrolled;
24
24
  root.style.setProperty("--vk-scrolled", scrolled);
25
+ root.toggleAttribute("data-scrolled", scrolled === "1");
25
26
  }
26
27
  if (flags.pin !== pin) {
27
28
  flags.pin = pin;
@@ -31,6 +32,7 @@ export function useGridScrollArea(rootRef, boxes, recorderRef) {
31
32
  if (flags.parked !== parked) {
32
33
  flags.parked = parked;
33
34
  root.style.setProperty("--vk-parked", parked);
35
+ root.toggleAttribute("data-parked", parked === "1");
34
36
  }
35
37
  if (flags.hold !== hold) {
36
38
  flags.hold = hold;
@@ -59,6 +59,7 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
59
59
  editingCell: GridCellPos | null;
60
60
  pendingByRow: ReadonlyMap<string, Record<string, unknown>>;
61
61
  settlementByRow: import("../core/editing-model.js").GridSettlementByRow;
62
+ writeStateByRow: import("../core/write-states.js").GridWriteStateByRow;
62
63
  editSeed: string | null;
63
64
  editWhole: boolean;
64
65
  focusCellSync: (rowId: string, columnId: string) => void;
@@ -30,12 +30,13 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
30
30
  };
31
31
  ports.toast.error(gridRefusalSentence(refusal, nameOf, messages));
32
32
  }, [sayRefusals, columns, ports, messages]);
33
- const { focused: focusedCell, editing: editingCell, pendingByRow, settlementByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, sent, sentCells, forgetSent, } = useGridEditing(props.onCellCommit, props.onCellsCommit, sayRefusal);
34
33
  const columnById = useMemo(() => new Map([...columns, ...visibleColumns].map((column) => [column.id, column])), [columns, visibleColumns]);
35
34
  const partOfWhole = useCallback((wholeId) => [...columnById.values()].find((column) => column.partOf?.column === wholeId)?.partOf, [columnById]);
35
+ const keepsSent = useCallback((columnId) => partOfWhole(columnId) != null, [partOfWhole]);
36
+ const { focused: focusedCell, editing: editingCell, pendingByRow, pendingOf, settlementByRow, writeStateByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, sent, sentCells, forgetSent, } = useGridEditing(props.onCellCommit, props.onCellsCommit, sayRefusal, keepsSent);
36
37
  const wholeStored = useCallback((rowId, wholeId, row) => {
37
38
  const part = partOfWhole(wholeId);
38
- const overlay = pendingByRow.get(rowId);
39
+ const overlay = pendingOf(rowId);
39
40
  const last = sent(rowId, wholeId);
40
41
  const inChain = (value) => !!part && !!last && last.chain.some((each) => sameStoredValue(part.field, value, each));
41
42
  if (overlay && wholeId in overlay)
@@ -44,7 +45,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
44
45
  return undefined;
45
46
  const stored = part.read(row);
46
47
  return inChain(stored) ? last.value : stored;
47
- }, [partOfWhole, pendingByRow, sent]);
48
+ }, [partOfWhole, pendingOf, sent]);
48
49
  useEffect(() => {
49
50
  for (const { rowId, columnId } of sentCells()) {
50
51
  const part = partOfWhole(columnId);
@@ -286,6 +287,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
286
287
  editingCell,
287
288
  pendingByRow,
288
289
  settlementByRow,
290
+ writeStateByRow,
289
291
  editSeed,
290
292
  editWhole,
291
293
  focusCellSync,
@@ -9,8 +9,10 @@ export declare function getVisibleGridRowIds<Row>({ groups, grouped, isCollapsed
9
9
  * orders here prevents the renderer from accidentally feeding one contract to
10
10
  * the other when its group chrome changes.
11
11
  */
12
- export declare function useGridTableSelection<Row>({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId" | "selection"> & {
12
+ export declare function useGridTableSelection<Row>({ rootRef, groups, grouped, isCollapsed, getRowId, selection, pageKey, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId" | "selection"> & {
13
13
  rootRef: RefObject<HTMLDivElement | null>;
14
+ /** The page on screen, for a grid in pages: picks cover the page, so a new one clears them. */
15
+ pageKey?: string;
14
16
  }): {
15
17
  selectable: boolean;
16
18
  selecting: boolean;
@@ -14,14 +14,14 @@ export function getVisibleGridRowIds({ groups, grouped, isCollapsed, getRowId, }
14
14
  }
15
15
  return ids;
16
16
  }
17
- export function useGridTableSelection({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }) {
17
+ export function useGridTableSelection({ rootRef, groups, grouped, isCollapsed, getRowId, selection, pageKey, }) {
18
18
  const selectable = !!selection;
19
19
  const derivedOrderedIds = useMemo(() => groups.flatMap((group) => group.items).map(getRowId), [groups, getRowId]);
20
20
  const orderedIds = selection?.orderedIds ?? derivedOrderedIds;
21
21
  const selectionState = useListSelection({
22
22
  orderedIds,
23
23
  retention: selection?.retention,
24
- resetKey: selection?.resetKey,
24
+ resetKey: pageKey === undefined ? selection?.resetKey : `${selection?.resetKey ?? ""}\u0000${pageKey}`,
25
25
  });
26
26
  useEscapeToClear(selectionState.count > 0, selectionState.clear);
27
27
  const selecting = selectable && selectionState.count > 0;
@@ -44,6 +44,7 @@ export function useHeaderDragReorder({ enabled, ids, scrollXRef, getScroller, ca
44
44
  d.el.style.removeProperty("--vk-drag-shift");
45
45
  d.el.style.willChange = "";
46
46
  d.el.classList.remove("z-20", GRID_GROUND, "shadow-md");
47
+ d.el.removeAttribute("data-dragging");
47
48
  document.body.style.cursor = "";
48
49
  document.body.style.userSelect = "";
49
50
  dragRef.current = null;
@@ -145,6 +146,7 @@ export function useHeaderDragReorder({ enabled, ids, scrollXRef, getScroller, ca
145
146
  el.setPointerCapture(e.pointerId);
146
147
  el.style.willChange = "transform";
147
148
  el.classList.add("z-20", GRID_GROUND, "shadow-md");
149
+ el.setAttribute("data-dragging", "");
148
150
  document.body.style.cursor = "grabbing";
149
151
  document.body.style.userSelect = "none";
150
152
  dragRef.current = {
@@ -1,12 +1,16 @@
1
1
  import { type GridCellCommitFn, type GridCellsCommitFn, type GridCommitRefusal } from "./commit-model.js";
2
2
  import type { GridCellPos } from "./coordinates.js";
3
3
  import { type GridCommitCell, type GridSettlementByRow } from "./editing-model.js";
4
+ import { type GridWriteStateByRow } from "./write-states.js";
4
5
  export type GridEditingCallbacks<Row> = {
5
6
  onCellCommit?: GridCellCommitFn<Row>;
6
7
  onCellsCommit?: GridCellsCommitFn<Row>;
7
8
  /** Told once per write the app refused (a commit, a batch, an undo or a redo), after its cells rolled back. The
8
9
  * core says nothing itself: the chrome decides whether and how a refusal is said. */
9
10
  onRefused?: (refusal: GridCommitRefusal) => void;
11
+ /** Whether what a commit sends for a column's cells is kept for a part edit to build on (`sent`): the grid keeps
12
+ * it only for a whole a part column builds on. Absent: every column. */
13
+ keepsSent?: (columnId: string) => boolean;
10
14
  };
11
15
  type ResolveRow<Row> = (rowId: string) => Row | undefined;
12
16
  /**
@@ -18,19 +22,30 @@ export declare class GridEditingController<Row> {
18
22
  /** Fired with every overlay change: the values by row, and beside them the
19
23
  * cells whose write is only `requested` of its provider (spec §11.2). */
20
24
  private readonly onPendingChange;
25
+ /** Fired when a cell's write state changes (`write-states.ts`): pending while a write to it is in flight,
26
+ * invalid from the latest write's refusal until the cell's next write is sent. */
27
+ private readonly onWriteStateChange?;
21
28
  private history;
22
29
  private pending;
23
30
  private readonly inflight;
24
- /** The last value this grid sent for each cell and the value that write was built on, each entry its write's own
25
- * (`token`), so an older write's end never drops a newer one's (`sent`). */
31
+ /** What this grid sent for each cell: the cell's writes still standing, oldest first, never empty. Each is its own
32
+ * (`token`), so a write's end removes only that write, and the newest still standing is what a part edit builds
33
+ * on (`sent`). */
26
34
  private readonly lastSent;
35
+ /** Each cell's writes, for its `data-pending` and `data-invalid`: how many are out, the latest one's token, and
36
+ * whether that latest one was refused. An entry goes once nothing is out and it isn't refused. */
37
+ private readonly writes;
38
+ private writeStates;
27
39
  private applyChain;
28
40
  private nextHistoryId;
29
41
  private nextPendingRevision;
30
42
  constructor(callbacks: GridEditingCallbacks<Row>,
31
43
  /** Fired with every overlay change: the values by row, and beside them the
32
44
  * cells whose write is only `requested` of its provider (spec §11.2). */
33
- onPendingChange: (pendingByRow: ReadonlyMap<string, Record<string, unknown>>, settlementByRow: GridSettlementByRow) => void);
45
+ onPendingChange: (pendingByRow: ReadonlyMap<string, Record<string, unknown>>, settlementByRow: GridSettlementByRow) => void,
46
+ /** Fired when a cell's write state changes (`write-states.ts`): pending while a write to it is in flight,
47
+ * invalid from the latest write's refusal until the cell's next write is sent. */
48
+ onWriteStateChange?: ((byRow: GridWriteStateByRow) => void) | undefined);
34
49
  setCallbacks(callbacks: GridEditingCallbacks<Row>): void;
35
50
  canUndo(): boolean;
36
51
  canRedo(): boolean;
@@ -56,10 +71,11 @@ export declare class GridEditingController<Row> {
56
71
  /** Is a write for this cell still in flight? Reconciliation asks, so it can
57
72
  * tell "the refetch hasn't caught up yet" apart from "the server disagrees". */
58
73
  hasInflight(rowId: string, columnId: string): boolean;
59
- /** The last value this grid sent for a cell, the value that write was built on, and the chain of values the writes
60
- * built one on another led through (`builtOn` of the first, then each value sent). Kept until that write ends in
61
- * anything but confirmed, an undo or a redo restores the cell, or the row is seen holding the value sent with
62
- * nothing in flight (`forgetSent`). A part column's edit builds on it while the row holds a value of the chain. */
74
+ /** The newest write this grid sent for a cell that still stands: its value, the value it was built on, and the chain
75
+ * of values the writes built one on another led through to it. A write leaves when it ends in anything but
76
+ * confirmed, when a newer write of the cell is confirmed, or when an undo or a redo reaches it; the whole cell's
77
+ * memory goes once the row is seen holding the newest value sent (`forgetSent`). A part column's edit builds on it
78
+ * while the row holds a value of the chain. */
63
79
  sent(rowId: string, columnId: string): {
64
80
  value: unknown;
65
81
  builtOn: unknown;
@@ -70,17 +86,26 @@ export declare class GridEditingController<Row> {
70
86
  rowId: string;
71
87
  columnId: string;
72
88
  }[];
73
- /** Retires a cell's entry: its row holds what was sent and nothing is in flight. */
89
+ /** Retires a cell's entry: its row holds the newest value sent, in flight or not. */
74
90
  forgetSent(rowId: string, columnId: string): void;
75
- /** Records what a commit sends for a cell; the token is that write's own. */
91
+ /** Records what a commit sends for a cell, as the newest of its writes; the token is that write's own, and
92
+ * `entryId` the history entry the commit recorded. A column the grid keeps nothing for (`keepsSent`) isn't noted. */
76
93
  private noteSent;
77
- /** Drops a cell's entry: any entry, or, with a token, only while it is still that write's own. */
94
+ /** Removes one write from its cell's memory; the cell's entry goes with its last write. A write never noted (a null
95
+ * token) has nothing to remove. */
78
96
  private dropSent;
79
- /** A write's end: its entry goes on a failure, and takes the value the app stored where it says. */
97
+ /** A write's end: a failure removes it, so the newest write still standing is the base again. A confirmed write
98
+ * takes the value the app stored where it says, and the writes before it go: nothing older is newer than it. */
80
99
  private settleSent;
81
100
  /** What this cell held before the pending write. Reconciliation asks, so it
82
101
  * can tell a value the SERVER normalised apart from one somebody else set. */
83
102
  pendingBaseline(rowId: string, columnId: string): unknown;
103
+ /**
104
+ * A write sent for these cells: each is pending until the app answers, and its refusal leaves the cell invalid
105
+ * while it is still the latest write sent for it. A newer write's send clears a refusal ("the last commit").
106
+ */
107
+ private trackWrite;
108
+ private publishWriteStates;
84
109
  private registerInflight;
85
110
  private perform;
86
111
  private performBatch;
@@ -1,19 +1,24 @@
1
1
  import { gridCellKey, } from "./commit-model.js";
2
2
  import { applyGridPending, beginGridHistoryApply, createGridHistory, gridEditValue, gridHistoryValue, groupGridPendingByRow, groupGridPendingSettlement, keepGridPending, markGridPendingSettlement, planGridPendingAssignments, pruneGridHistoryEntry, reconcileGridPending, recordGridHistory, rollbackGridPending, settleGridHistoryApply, } from "./editing-model.js";
3
+ import { setGridWriteStates } from "./write-states.js";
3
4
  const confirmed = (outcome) => outcome ?? { status: "confirmed" };
4
5
  export class GridEditingController {
5
6
  callbacks;
6
7
  onPendingChange;
8
+ onWriteStateChange;
7
9
  history = createGridHistory();
8
10
  pending = new Map();
9
11
  inflight = new Map();
10
12
  lastSent = new Map();
13
+ writes = new Map();
14
+ writeStates = new Map();
11
15
  applyChain = Promise.resolve();
12
16
  nextHistoryId = 1;
13
17
  nextPendingRevision = 1;
14
- constructor(callbacks, onPendingChange) {
18
+ constructor(callbacks, onPendingChange, onWriteStateChange) {
15
19
  this.callbacks = callbacks;
16
20
  this.onPendingChange = onPendingChange;
21
+ this.onWriteStateChange = onWriteStateChange;
17
22
  }
18
23
  setCallbacks(callbacks) {
19
24
  this.callbacks = callbacks;
@@ -35,7 +40,7 @@ export class GridEditingController {
35
40
  edits: cells.map(({ cell }) => cell),
36
41
  };
37
42
  this.history = recordGridHistory(this.history, entry);
38
- return this.performBatch(cells, "next", "commit").then((results) => {
43
+ return this.performBatch(cells, "next", "commit", entry.id).then((results) => {
39
44
  this.reportRefusals(cells, results);
40
45
  const successes = results.map((result) => result.status === "confirmed");
41
46
  entry.edits = entry.edits.map((cell, index) => {
@@ -120,8 +125,8 @@ export class GridEditingController {
120
125
  return (this.inflight.get(gridCellKey(rowId, columnId))?.size ?? 0) > 0;
121
126
  }
122
127
  sent(rowId, columnId) {
123
- const entry = this.lastSent.get(gridCellKey(rowId, columnId));
124
- return entry ? { value: entry.value, builtOn: entry.builtOn, chain: entry.chain } : undefined;
128
+ const newest = this.lastSent.get(gridCellKey(rowId, columnId))?.writes.at(-1);
129
+ return newest ? { value: newest.value, builtOn: newest.builtOn, chain: newest.chain } : undefined;
125
130
  }
126
131
  sentCells() {
127
132
  return [...this.lastSent.values()].map(({ rowId, columnId }) => ({ rowId, columnId }));
@@ -129,31 +134,81 @@ export class GridEditingController {
129
134
  forgetSent(rowId, columnId) {
130
135
  this.lastSent.delete(gridCellKey(rowId, columnId));
131
136
  }
132
- noteSent(key, value, builtOn) {
137
+ noteSent({ rowId, columnId }, value, builtOn, entryId) {
138
+ if (this.callbacks.keepsSent && !this.callbacks.keepsSent(columnId))
139
+ return null;
140
+ const key = gridCellKey(rowId, columnId);
133
141
  const token = {};
134
- const last = this.lastSent.get(key);
135
- const chain = last && last.value === builtOn ? [...last.chain, value] : [builtOn, value];
136
- const at = key.lastIndexOf(":");
137
- this.lastSent.set(key, { rowId: key.slice(0, at), columnId: key.slice(at + 1), value, builtOn, chain, token });
142
+ const entry = this.lastSent.get(key);
143
+ const newest = entry?.writes.at(-1);
144
+ const chain = newest && newest.value === builtOn ? [...newest.chain, value] : [builtOn, value];
145
+ const write = { token, entryId, value, builtOn, chain };
146
+ if (entry)
147
+ entry.writes.push(write);
148
+ else {
149
+ this.lastSent.set(key, { rowId, columnId, writes: [write] });
150
+ }
138
151
  return token;
139
152
  }
140
153
  dropSent(key, token) {
141
154
  const entry = this.lastSent.get(key);
142
- if (entry && (!token || entry.token === token))
155
+ if (!entry || !token)
156
+ return;
157
+ entry.writes = entry.writes.filter((write) => write.token !== token);
158
+ if (entry.writes.length === 0)
143
159
  this.lastSent.delete(key);
144
160
  }
145
161
  settleSent(key, token, result) {
162
+ if (!token)
163
+ return;
146
164
  const entry = this.lastSent.get(key);
147
- if (!entry || entry.token !== token)
165
+ const at = entry?.writes.findIndex((write) => write.token === token) ?? -1;
166
+ if (!entry || at < 0)
148
167
  return;
149
- if (!result || result.status !== "confirmed")
150
- this.lastSent.delete(key);
151
- else if ("stored" in result)
152
- entry.value = result.stored;
168
+ if (!result || result.status !== "confirmed") {
169
+ this.dropSent(key, token);
170
+ return;
171
+ }
172
+ if ("stored" in result)
173
+ entry.writes[at].value = result.stored;
174
+ entry.writes = entry.writes.slice(at);
153
175
  }
154
176
  pendingBaseline(rowId, columnId) {
155
177
  return this.pending.get(gridCellKey(rowId, columnId))?.baseline;
156
178
  }
179
+ trackWrite(cells, promise) {
180
+ const token = {};
181
+ for (const { rowId, columnId } of cells) {
182
+ const key = gridCellKey(rowId, columnId);
183
+ const entry = this.writes.get(key);
184
+ this.writes.set(key, { rowId, columnId, out: (entry?.out ?? 0) + 1, latest: token, invalid: false });
185
+ }
186
+ this.publishWriteStates(cells);
187
+ void promise.then((results) => {
188
+ cells.forEach(({ rowId, columnId }, index) => {
189
+ const key = gridCellKey(rowId, columnId);
190
+ const entry = this.writes.get(key);
191
+ if (!entry)
192
+ return;
193
+ entry.out -= 1;
194
+ if (entry.latest === token && results[index]?.status === "failed")
195
+ entry.invalid = true;
196
+ if (entry.out <= 0 && !entry.invalid)
197
+ this.writes.delete(key);
198
+ });
199
+ this.publishWriteStates(cells);
200
+ });
201
+ }
202
+ publishWriteStates(cells) {
203
+ const next = setGridWriteStates(this.writeStates, cells.map(({ rowId, columnId }) => {
204
+ const entry = this.writes.get(gridCellKey(rowId, columnId));
205
+ return { rowId, columnId, state: entry ? { pending: entry.out > 0, invalid: entry.invalid } : null };
206
+ }));
207
+ if (next === this.writeStates)
208
+ return;
209
+ this.writeStates = next;
210
+ this.onWriteStateChange?.(next);
211
+ }
157
212
  registerInflight(keys, promise) {
158
213
  for (const key of keys) {
159
214
  const promises = this.inflight.get(key) ?? new Set();
@@ -169,12 +224,12 @@ export class GridEditingController {
169
224
  }
170
225
  });
171
226
  }
172
- perform(row, rowId, columnId, value, overlay, baseline, context = "commit") {
227
+ perform(row, rowId, columnId, value, overlay, baseline, context = "commit", entryId) {
173
228
  const { onCellCommit } = this.callbacks;
174
229
  if (!onCellCommit)
175
230
  return Promise.resolve({ status: "failed" });
176
231
  const key = gridCellKey(rowId, columnId);
177
- const sentToken = context === "commit" ? this.noteSent(key, value, baseline) : null;
232
+ const sentToken = context === "commit" && entryId !== undefined ? this.noteSent({ rowId, columnId }, value, baseline, entryId) : null;
178
233
  const assignments = overlay
179
234
  ? [{ key, value, baseline, revision: this.nextPendingRevision++ }]
180
235
  : [];
@@ -205,23 +260,24 @@ export class GridEditingController {
205
260
  return { status: "failed", error };
206
261
  });
207
262
  this.registerInflight([key], promise);
263
+ this.trackWrite([{ rowId, columnId }], promise.then((result) => [result]));
208
264
  return promise;
209
265
  }
210
- performBatch(cells, side, context) {
266
+ performBatch(cells, side, context, entryId) {
211
267
  if (cells.length === 0)
212
268
  return Promise.resolve([]);
213
269
  const { onCellsCommit } = this.callbacks;
214
270
  if (cells.length === 1 || !onCellsCommit) {
215
271
  return Promise.all(cells.map(({ row, cell }) => this.perform(row, cell.rowId, cell.columnId, context === "restore" ? gridHistoryValue(cell, side) : gridEditValue(cell, side), context === "restore" ? false : cell.overlay, context === "restore"
216
272
  ? gridHistoryValue(cell, side === "next" ? "prev" : "next")
217
- : gridEditValue(cell, side === "next" ? "prev" : "next"), context)));
273
+ : gridEditValue(cell, side === "next" ? "prev" : "next"), context, entryId)));
218
274
  }
219
275
  const assignments = context === "restore"
220
276
  ? []
221
277
  : planGridPendingAssignments(cells, side, this.nextPendingRevision++);
222
278
  const keys = cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId));
223
- const sentTokens = context === "commit"
224
- ? cells.map(({ cell }, index) => this.noteSent(keys[index], gridEditValue(cell, side), gridEditValue(cell, side === "next" ? "prev" : "next")))
279
+ const sentTokens = context === "commit" && entryId !== undefined
280
+ ? cells.map(({ cell }) => this.noteSent(cell, gridEditValue(cell, side), gridEditValue(cell, side === "next" ? "prev" : "next"), entryId))
225
281
  : null;
226
282
  if (assignments.length > 0) {
227
283
  this.publishPending(applyGridPending(this.pending, assignments));
@@ -256,7 +312,7 @@ export class GridEditingController {
256
312
  }
257
313
  const settled = cells.map((_, index) => results[index] ?? { status: "failed" });
258
314
  if (sentTokens)
259
- keys.forEach((key, index) => this.settleSent(key, sentTokens[index], settled[index]));
315
+ keys.forEach((key, index) => this.settleSent(key, sentTokens[index] ?? null, settled[index]));
260
316
  this.settle(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), settled, assignments);
261
317
  return settled;
262
318
  }, (error) => {
@@ -265,7 +321,7 @@ export class GridEditingController {
265
321
  : null;
266
322
  if (carried?.length === cells.length) {
267
323
  if (sentTokens)
268
- keys.forEach((key, index) => this.settleSent(key, sentTokens[index], carried[index]));
324
+ keys.forEach((key, index) => this.settleSent(key, sentTokens[index] ?? null, carried[index]));
269
325
  const failedKeys = new Set(cells
270
326
  .filter((_, index) => carried[index]?.status === "failed")
271
327
  .map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
@@ -275,13 +331,14 @@ export class GridEditingController {
275
331
  return carried;
276
332
  }
277
333
  if (sentTokens)
278
- keys.forEach((key, index) => this.dropSent(key, sentTokens[index]));
334
+ keys.forEach((key, index) => this.dropSent(key, sentTokens[index] ?? null));
279
335
  if (assignments.length > 0) {
280
336
  this.publishPending(rollbackGridPending(this.pending, assignments));
281
337
  }
282
338
  return cells.map(() => ({ status: "failed", error }));
283
339
  });
284
340
  this.registerInflight(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), promise);
341
+ this.trackWrite(cells.map(({ cell }) => ({ rowId: cell.rowId, columnId: cell.columnId })), promise);
285
342
  return promise;
286
343
  }
287
344
  inflightFor(entry) {
@@ -294,6 +351,16 @@ export class GridEditingController {
294
351
  return [...promises];
295
352
  }
296
353
  enqueueApply(kind, resolveRow, onApply) {
354
+ const top = (kind === "undo" ? this.history.undo : this.history.redo).at(-1);
355
+ for (const cell of top?.edits ?? []) {
356
+ const key = gridCellKey(cell.rowId, cell.columnId);
357
+ const entry = this.lastSent.get(key);
358
+ if (!entry)
359
+ continue;
360
+ entry.writes = entry.writes.filter((write) => write.entryId !== top.id);
361
+ if (entry.writes.length === 0)
362
+ this.lastSent.delete(key);
363
+ }
297
364
  this.applyChain = this.applyChain.then(async () => {
298
365
  const source = kind === "undo" ? this.history.undo : this.history.redo;
299
366
  const candidate = source[source.length - 1];
@@ -308,7 +375,7 @@ export class GridEditingController {
308
375
  if (!entry || entry.edits.length === 0)
309
376
  return;
310
377
  for (const cell of entry.edits)
311
- this.dropSent(gridCellKey(cell.rowId, cell.columnId));
378
+ this.lastSent.delete(gridCellKey(cell.rowId, cell.columnId));
312
379
  const first = entry.edits[0];
313
380
  onApply?.({ rowId: first.rowId, columnId: first.columnId });
314
381
  const cells = entry.edits.map((cell) => ({