@viewkitjs/views 0.3.0 → 0.5.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 (288) hide show
  1. package/CHANGELOG.md +641 -0
  2. package/README.md +3 -3
  3. package/dist/atoms/CommandMenu.d.ts +1 -1
  4. package/dist/atoms/CommandMenu.js +7 -3
  5. package/dist/atoms/DrillRows.d.ts +3 -0
  6. package/dist/atoms/DrillRows.js +25 -0
  7. package/dist/atoms/PanelRows.d.ts +5 -0
  8. package/dist/atoms/PanelRows.js +40 -0
  9. package/dist/atoms/PanelSearch.d.ts +2 -0
  10. package/dist/atoms/PanelSearch.js +21 -0
  11. package/dist/atoms/RelationRoles.d.ts +2 -0
  12. package/dist/atoms/RelationRoles.js +6 -0
  13. package/dist/atoms/Row.js +2 -1
  14. package/dist/atoms/RowMenu.js +2 -1
  15. package/dist/atoms/SelectionSheet.d.ts +3 -0
  16. package/dist/atoms/SelectionSheet.js +30 -0
  17. package/dist/atoms/StatusMarker.js +3 -1
  18. package/dist/atoms/Tag.js +2 -1
  19. package/dist/atoms/defaults.js +14 -0
  20. package/dist/atoms/types.d.ts +146 -8
  21. package/dist/cells/cell-values.js +4 -2
  22. package/dist/cells/relation-wrap.js +3 -1
  23. package/dist/contract.d.ts +212 -17
  24. package/dist/contract.js +208 -6
  25. package/dist/display/boolean.js +3 -1
  26. package/dist/display/date.d.ts +1 -1
  27. package/dist/display/date.js +4 -2
  28. package/dist/display/format.js +20 -4
  29. package/dist/display/link.js +4 -3
  30. package/dist/display/multi-value.js +2 -1
  31. package/dist/display/percent.js +2 -1
  32. package/dist/display/phone.js +2 -1
  33. package/dist/display/range.js +3 -13
  34. package/dist/display/relation.js +23 -8
  35. package/dist/display/rich-text.js +2 -1
  36. package/dist/editors/ChipsEditor.d.ts +5 -1
  37. package/dist/editors/ChipsEditor.js +15 -2
  38. package/dist/editors/DateEditor.d.ts +2 -0
  39. package/dist/editors/DateEditor.js +76 -10
  40. package/dist/editors/EditorPanel.d.ts +14 -4
  41. package/dist/editors/EditorPanel.js +21 -4
  42. package/dist/editors/LocationEditor.js +35 -3
  43. package/dist/editors/NumberEditor.js +3 -2
  44. package/dist/editors/RangeEditor.d.ts +8 -0
  45. package/dist/editors/RangeEditor.js +3 -2
  46. package/dist/editors/RelationEditor.d.ts +2 -0
  47. package/dist/editors/RelationEditor.js +16 -2
  48. package/dist/editors/RelationSetEditor.d.ts +4 -2
  49. package/dist/editors/RelationSetEditor.js +36 -2
  50. package/dist/editors/SelectEditor.d.ts +5 -2
  51. package/dist/editors/SelectEditor.js +31 -4
  52. package/dist/editors/TextEditor.js +3 -1
  53. package/dist/editors/ValueListEditor.d.ts +3 -0
  54. package/dist/editors/ValueListEditor.js +10 -4
  55. package/dist/editors/edit-session.d.ts +14 -2
  56. package/dist/editors/edit-session.js +13 -5
  57. package/dist/editors/escape-rule.d.ts +12 -0
  58. package/dist/editors/escape-rule.js +8 -0
  59. package/dist/editors/open-value.js +2 -1
  60. package/dist/editors/picker-slot.d.ts +25 -0
  61. package/dist/editors/picker-slot.js +37 -0
  62. package/dist/editors/relation-picker.d.ts +44 -0
  63. package/dist/editors/relation-picker.js +49 -0
  64. package/dist/editors/relation-source.d.ts +1 -0
  65. package/dist/editors/relation-source.js +7 -1
  66. package/dist/field-row/FieldNoteLine.js +2 -1
  67. package/dist/field-row/FieldRow.js +41 -6
  68. package/dist/field-row/FieldRowLane.js +3 -1
  69. package/dist/field-row/editors/RowChipsEditor.js +1 -1
  70. package/dist/field-row/editors/RowDateEditor.js +1 -1
  71. package/dist/field-row/editors/RowEditor.js +2 -1
  72. package/dist/field-row/editors/RowRangeEditor.js +2 -1
  73. package/dist/field-row/editors/RowRelationEditor.js +2 -2
  74. package/dist/field-row/editors/RowSelectEditor.d.ts +1 -1
  75. package/dist/field-row/editors/RowSelectEditor.js +2 -2
  76. package/dist/field-row/editors/RowValueListEditor.js +1 -1
  77. package/dist/field-row/editors/host.d.ts +3 -0
  78. package/dist/field-row/editors/row-session.js +4 -1
  79. package/dist/fields/menus.d.ts +2 -0
  80. package/dist/fields/range-unit.d.ts +7 -0
  81. package/dist/fields/range-unit.js +13 -0
  82. package/dist/figures.d.ts +5 -48
  83. package/dist/figures.js +1 -63
  84. package/dist/grid/chrome/GridAddColumn.d.ts +8 -0
  85. package/dist/grid/chrome/GridAddColumn.js +66 -9
  86. package/dist/grid/chrome/GridAggregateMenu.d.ts +5 -2
  87. package/dist/grid/chrome/GridAggregateMenu.js +33 -4
  88. package/dist/grid/chrome/GridCellEditors.d.ts +9 -2
  89. package/dist/grid/chrome/GridCellEditors.js +24 -5
  90. package/dist/grid/chrome/GridCellOutline.d.ts +3 -2
  91. package/dist/grid/chrome/GridCellOutline.js +11 -1
  92. package/dist/grid/chrome/GridChipsEditor.js +1 -1
  93. package/dist/grid/chrome/GridColumnColorSection.d.ts +2 -0
  94. package/dist/grid/chrome/GridColumnColorSection.js +2 -2
  95. package/dist/grid/chrome/GridColumnDateSection.d.ts +4 -0
  96. package/dist/grid/chrome/GridColumnDateSection.js +2 -2
  97. package/dist/grid/chrome/GridColumnDurationSection.d.ts +4 -0
  98. package/dist/grid/chrome/GridColumnDurationSection.js +2 -2
  99. package/dist/grid/chrome/GridColumnMenu.d.ts +10 -6
  100. package/dist/grid/chrome/GridColumnMenu.js +62 -24
  101. package/dist/grid/chrome/GridColumnNumberSection.d.ts +4 -0
  102. package/dist/grid/chrome/GridColumnNumberSection.js +2 -2
  103. package/dist/grid/chrome/GridColumnPercentSection.d.ts +1 -0
  104. package/dist/grid/chrome/GridColumnPercentSection.js +1 -1
  105. package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
  106. package/dist/grid/chrome/GridDateEditor.js +1 -1
  107. package/dist/grid/chrome/GridFooter.js +7 -48
  108. package/dist/grid/chrome/GridGroupMenu.d.ts +11 -5
  109. package/dist/grid/chrome/GridGroupMenu.js +28 -13
  110. package/dist/grid/chrome/GridHeader.d.ts +3 -1
  111. package/dist/grid/chrome/GridHeader.js +8 -8
  112. package/dist/grid/chrome/GridNumberEditor.js +3 -24
  113. package/dist/grid/chrome/GridRangeEditor.js +3 -2
  114. package/dist/grid/chrome/GridRelationEditor.js +2 -2
  115. package/dist/grid/chrome/GridRow.d.ts +2 -1
  116. package/dist/grid/chrome/GridRow.js +13 -37
  117. package/dist/grid/chrome/GridRowActions.js +2 -1
  118. package/dist/grid/chrome/GridRowCells.js +9 -4
  119. package/dist/grid/chrome/GridSelectEditor.js +30 -20
  120. package/dist/grid/chrome/GridStructure.d.ts +11 -4
  121. package/dist/grid/chrome/GridStructure.js +19 -7
  122. package/dist/grid/chrome/GridTable.js +138 -16
  123. package/dist/grid/chrome/GridTableSurface.d.ts +25 -12
  124. package/dist/grid/chrome/GridTableSurface.js +13 -6
  125. package/dist/grid/chrome/GridTextEditor.js +3 -1
  126. package/dist/grid/chrome/GridValueListEditor.js +1 -1
  127. package/dist/grid/chrome/cell-clipboard.d.ts +1 -1
  128. package/dist/grid/chrome/cell-clipboard.js +1 -1
  129. package/dist/grid/chrome/checks.d.ts +10 -2
  130. package/dist/grid/chrome/checks.js +17 -11
  131. package/dist/grid/chrome/column-glyph.d.ts +2 -2
  132. package/dist/grid/chrome/column-glyph.js +4 -0
  133. package/dist/grid/chrome/grid-add-column-items.d.ts +13 -0
  134. package/dist/grid/chrome/grid-add-column-items.js +40 -0
  135. package/dist/grid/chrome/grid-cell-classes.d.ts +2 -0
  136. package/dist/grid/chrome/grid-cell-classes.js +10 -4
  137. package/dist/grid/chrome/grid-column-menu-items.d.ts +75 -0
  138. package/dist/grid/chrome/grid-column-menu-items.js +263 -0
  139. package/dist/grid/chrome/grid-edit-escape.d.ts +4 -0
  140. package/dist/grid/chrome/grid-edit-escape.js +12 -0
  141. package/dist/grid/chrome/grid-edit-session.d.ts +2 -1
  142. package/dist/grid/chrome/grid-edit-session.js +14 -1
  143. package/dist/grid/chrome/grid-figure-value.d.ts +25 -0
  144. package/dist/grid/chrome/grid-figure-value.js +40 -0
  145. package/dist/grid/chrome/grid-fitted-box.d.ts +15 -0
  146. package/dist/grid/chrome/grid-fitted-box.js +26 -0
  147. package/dist/grid/chrome/grid-group-menu-items.d.ts +31 -0
  148. package/dist/grid/chrome/grid-group-menu-items.js +75 -0
  149. package/dist/grid/chrome/grid-group-menu-parts.d.ts +27 -0
  150. package/dist/grid/chrome/grid-group-menu-parts.js +19 -0
  151. package/dist/grid/chrome/grid-hover.d.ts +1 -0
  152. package/dist/grid/chrome/grid-hover.js +13 -1
  153. package/dist/grid/chrome/grid-lab.d.ts +7 -0
  154. package/dist/grid/chrome/grid-lab.js +7 -0
  155. package/dist/grid/chrome/grid-menu-focus.d.ts +12 -0
  156. package/dist/grid/chrome/grid-menu-focus.js +13 -0
  157. package/dist/grid/chrome/{useGridRowContextMenu.d.ts → grid-row-menu-items.d.ts} +15 -4
  158. package/dist/grid/chrome/{useGridRowContextMenu.js → grid-row-menu-items.js} +15 -18
  159. package/dist/grid/chrome/grid-row-props.d.ts +3 -1
  160. package/dist/grid/chrome/grid-row-window.d.ts +15 -5
  161. package/dist/grid/chrome/grid-row-window.js +44 -10
  162. package/dist/grid/chrome/grid-rows-menu.d.ts +38 -0
  163. package/dist/grid/chrome/grid-rows-menu.js +83 -0
  164. package/dist/grid/chrome/grid-table-props.d.ts +53 -8
  165. package/dist/grid/chrome/useGridBandFigures.d.ts +26 -0
  166. package/dist/grid/chrome/useGridBandFigures.js +50 -0
  167. package/dist/grid/chrome/useGridBoxes.d.ts +22 -0
  168. package/dist/grid/chrome/useGridBoxes.js +22 -0
  169. package/dist/grid/chrome/useGridColumnLayout.js +29 -4
  170. package/dist/grid/chrome/useGridKeyboard.js +7 -2
  171. package/dist/grid/chrome/useGridPartColumns.d.ts +5 -0
  172. package/dist/grid/chrome/useGridPartColumns.js +9 -0
  173. package/dist/grid/chrome/useGridRangeGestures.js +2 -1
  174. package/dist/grid/chrome/useGridRecorder.d.ts +16 -0
  175. package/dist/grid/chrome/useGridRecorder.js +144 -0
  176. package/dist/grid/chrome/useGridRowOpener.d.ts +41 -0
  177. package/dist/grid/chrome/useGridRowOpener.js +83 -0
  178. package/dist/grid/chrome/useGridScrollArea.d.ts +38 -12
  179. package/dist/grid/chrome/useGridScrollArea.js +70 -17
  180. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
  181. package/dist/grid/chrome/useGridTableInteractionModel.js +67 -9
  182. package/dist/grid/core/clipboard-model.d.ts +11 -3
  183. package/dist/grid/core/clipboard-model.js +9 -4
  184. package/dist/grid/core/commit-model.d.ts +7 -0
  185. package/dist/grid/core/editing-controller.d.ts +31 -1
  186. package/dist/grid/core/editing-controller.js +65 -0
  187. package/dist/grid/core/grid-recorder.d.ts +111 -0
  188. package/dist/grid/core/grid-recorder.js +223 -0
  189. package/dist/grid/core/part-edits.d.ts +18 -0
  190. package/dist/grid/core/part-edits.js +48 -0
  191. package/dist/grid/core/pending-reconciliation.js +12 -3
  192. package/dist/grid/core/refusal-sentence.d.ts +3 -0
  193. package/dist/grid/core/refusal-sentence.js +15 -0
  194. package/dist/grid/core/row-opened-from.d.ts +21 -0
  195. package/dist/grid/core/row-opened-from.js +11 -0
  196. package/dist/grid/core/useGridEditing.d.ts +16 -2
  197. package/dist/grid/core/useGridEditing.js +10 -4
  198. package/dist/grid/core/value-equality.d.ts +19 -1
  199. package/dist/grid/core/value-equality.js +24 -0
  200. package/dist/grid/index.d.ts +4 -1
  201. package/dist/grid/index.js +1 -0
  202. package/dist/grid/useGridTablePrefs.d.ts +1 -1
  203. package/dist/grid-lab.d.ts +18 -0
  204. package/dist/grid-lab.js +16 -0
  205. package/dist/grouping/sort-groups.d.ts +6 -7
  206. package/dist/index.d.ts +1 -0
  207. package/dist/index.js +1 -0
  208. package/dist/internal/reset.d.ts +9 -0
  209. package/dist/internal/reset.js +1 -0
  210. package/dist/model/aggregates.d.ts +3 -3
  211. package/dist/model/aggregates.js +17 -71
  212. package/dist/model/column-capabilities.d.ts +29 -2
  213. package/dist/model/column-capabilities.js +27 -3
  214. package/dist/model/column-filters.js +24 -4
  215. package/dist/model/column-inspect.d.ts +2 -1
  216. package/dist/model/column-order.d.ts +2 -2
  217. package/dist/model/column-schema.d.ts +18 -7
  218. package/dist/model/column-state.d.ts +9 -20
  219. package/dist/model/column-state.js +1 -4
  220. package/dist/model/column-types.d.ts +1 -15
  221. package/dist/model/column-types.js +1 -1
  222. package/dist/model/part-columns.d.ts +17 -0
  223. package/dist/model/part-columns.js +67 -0
  224. package/dist/model/part-rows.d.ts +3 -10
  225. package/dist/model/part-rows.js +6 -11
  226. package/dist/model/part-write.d.ts +11 -0
  227. package/dist/model/part-write.js +52 -0
  228. package/dist/model/preferences.d.ts +3 -23
  229. package/dist/model/preferences.js +1 -17
  230. package/dist/model/prefs-buckets.d.ts +0 -27
  231. package/dist/model/prefs-buckets.js +1 -1
  232. package/dist/model/relation-filters.d.ts +0 -1
  233. package/dist/model/relation-filters.js +1 -1
  234. package/dist/model/row-icon.d.ts +5 -9
  235. package/dist/model/view-rules.d.ts +32 -6
  236. package/dist/model/view-rules.js +101 -21
  237. package/dist/provider/ViewsProvider.d.ts +22 -2
  238. package/dist/provider/ViewsProvider.js +21 -2
  239. package/dist/provider/components.d.ts +197 -9
  240. package/dist/provider/context.d.ts +12 -1
  241. package/dist/provider/desktop.d.ts +3 -0
  242. package/dist/provider/desktop.js +7 -4
  243. package/dist/provider/menu-groups.d.ts +3 -2
  244. package/dist/provider/menu-groups.js +13 -7
  245. package/dist/provider/missing-slot.d.ts +10 -0
  246. package/dist/provider/missing-slot.js +15 -0
  247. package/dist/provider/plain-input.d.ts +3 -2
  248. package/dist/provider/plain-input.js +3 -1
  249. package/dist/react.d.ts +3 -2
  250. package/dist/selection/SelectionBar.d.ts +18 -0
  251. package/dist/selection/SelectionBar.js +92 -0
  252. package/dist/selection/SelectionBarPhone.d.ts +3 -0
  253. package/dist/selection/SelectionBarPhone.js +14 -0
  254. package/dist/selection/bar-overflow.d.ts +12 -0
  255. package/dist/selection/bar-overflow.js +42 -0
  256. package/dist/selection/bar-parts.d.ts +15 -0
  257. package/dist/selection/bar-parts.js +17 -0
  258. package/dist/selection/index.d.ts +2 -0
  259. package/dist/selection/index.js +1 -0
  260. package/dist/selection/types.d.ts +3 -2
  261. package/dist/selection/verbs.d.ts +34 -0
  262. package/dist/selection/verbs.js +1 -0
  263. package/docs/contract.md +142 -39
  264. package/docs/getting-started.md +1 -1
  265. package/docs/guides/atoms.md +32 -4
  266. package/docs/guides/columns.md +1 -1
  267. package/docs/guides/display.md +1 -1
  268. package/docs/guides/editors.md +3 -3
  269. package/docs/guides/ports.md +1 -1
  270. package/docs/guides/selection.md +32 -20
  271. package/docs/guides/the-grid.md +43 -21
  272. package/docs/guides/the-provider.md +14 -4
  273. package/docs/index.md +2 -0
  274. package/docs/install.md +8 -1
  275. package/docs/reference/editors-date.md +2 -0
  276. package/docs/reference/editors-panel.md +4 -4
  277. package/docs/reference/editors-range.md +1 -1
  278. package/docs/reference/editors-relation.md +3 -3
  279. package/docs/reference/editors-select.md +1 -1
  280. package/docs/reference/editors-session.md +3 -2
  281. package/docs/reference/editors-value-list.md +1 -1
  282. package/docs/reference/field-row.md +2 -2
  283. package/docs/reference/grid.md +25 -6
  284. package/docs/reference/react.md +30 -8
  285. package/docs/reference/selection.md +10 -2
  286. package/docs/reference/views.md +42 -36
  287. package/package.json +22 -3
  288. package/skills/views/SKILL.md +3 -3
@@ -7,6 +7,7 @@ export class GridEditingController {
7
7
  history = createGridHistory();
8
8
  pending = new Map();
9
9
  inflight = new Map();
10
+ lastSent = new Map();
10
11
  applyChain = Promise.resolve();
11
12
  nextHistoryId = 1;
12
13
  nextPendingRevision = 1;
@@ -35,6 +36,7 @@ export class GridEditingController {
35
36
  };
36
37
  this.history = recordGridHistory(this.history, entry);
37
38
  return this.performBatch(cells, "next", "commit").then((results) => {
39
+ this.reportRefusals(cells, results);
38
40
  const successes = results.map((result) => result.status === "confirmed");
39
41
  entry.edits = entry.edits.map((cell, index) => {
40
42
  const result = results[index];
@@ -73,6 +75,19 @@ export class GridEditingController {
73
75
  this.enqueueApply("redo", resolveRow, onApply);
74
76
  return true;
75
77
  }
78
+ reportRefusals(cells, results) {
79
+ const failed = cells.flatMap(({ cell }, index) => {
80
+ const result = results[index];
81
+ return result?.status === "failed" ? [{ columnId: cell.columnId, error: result.error }] : [];
82
+ });
83
+ if (failed.length === 0)
84
+ return;
85
+ this.callbacks.onRefused?.({
86
+ columnIds: failed.map((each) => each.columnId),
87
+ count: failed.length,
88
+ error: failed[0].error,
89
+ });
90
+ }
76
91
  publishPending(next) {
77
92
  this.pending = next;
78
93
  this.onPendingChange(groupGridPendingByRow(next), groupGridPendingSettlement(next));
@@ -104,6 +119,38 @@ export class GridEditingController {
104
119
  hasInflight(rowId, columnId) {
105
120
  return (this.inflight.get(gridCellKey(rowId, columnId))?.size ?? 0) > 0;
106
121
  }
122
+ 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;
125
+ }
126
+ sentCells() {
127
+ return [...this.lastSent.values()].map(({ rowId, columnId }) => ({ rowId, columnId }));
128
+ }
129
+ forgetSent(rowId, columnId) {
130
+ this.lastSent.delete(gridCellKey(rowId, columnId));
131
+ }
132
+ noteSent(key, value, builtOn) {
133
+ 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 });
138
+ return token;
139
+ }
140
+ dropSent(key, token) {
141
+ const entry = this.lastSent.get(key);
142
+ if (entry && (!token || entry.token === token))
143
+ this.lastSent.delete(key);
144
+ }
145
+ settleSent(key, token, result) {
146
+ const entry = this.lastSent.get(key);
147
+ if (!entry || entry.token !== token)
148
+ return;
149
+ if (!result || result.status !== "confirmed")
150
+ this.lastSent.delete(key);
151
+ else if ("stored" in result)
152
+ entry.value = result.stored;
153
+ }
107
154
  pendingBaseline(rowId, columnId) {
108
155
  return this.pending.get(gridCellKey(rowId, columnId))?.baseline;
109
156
  }
@@ -127,6 +174,7 @@ export class GridEditingController {
127
174
  if (!onCellCommit)
128
175
  return Promise.resolve({ status: "failed" });
129
176
  const key = gridCellKey(rowId, columnId);
177
+ const sentToken = context === "commit" ? this.noteSent(key, value, baseline) : null;
130
178
  const assignments = overlay
131
179
  ? [{ key, value, baseline, revision: this.nextPendingRevision++ }]
132
180
  : [];
@@ -144,9 +192,13 @@ export class GridEditingController {
144
192
  }
145
193
  const promise = commit.then((outcome) => {
146
194
  const result = confirmed(outcome);
195
+ if (sentToken)
196
+ this.settleSent(key, sentToken, result);
147
197
  this.settle([key], [result], assignments);
148
198
  return result;
149
199
  }, (error) => {
200
+ if (sentToken)
201
+ this.dropSent(key, sentToken);
150
202
  if (assignments.length > 0) {
151
203
  this.publishPending(rollbackGridPending(this.pending, assignments));
152
204
  }
@@ -167,6 +219,10 @@ export class GridEditingController {
167
219
  const assignments = context === "restore"
168
220
  ? []
169
221
  : planGridPendingAssignments(cells, side, this.nextPendingRevision++);
222
+ 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")))
225
+ : null;
170
226
  if (assignments.length > 0) {
171
227
  this.publishPending(applyGridPending(this.pending, assignments));
172
228
  }
@@ -199,6 +255,8 @@ export class GridEditingController {
199
255
  this.publishPending(rollbackGridPending(this.pending, assignments.filter((assignment) => failedKeys.has(assignment.key))));
200
256
  }
201
257
  const settled = cells.map((_, index) => results[index] ?? { status: "failed" });
258
+ if (sentTokens)
259
+ keys.forEach((key, index) => this.settleSent(key, sentTokens[index], settled[index]));
202
260
  this.settle(cells.map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)), settled, assignments);
203
261
  return settled;
204
262
  }, (error) => {
@@ -206,6 +264,8 @@ export class GridEditingController {
206
264
  ? error.outcomes
207
265
  : null;
208
266
  if (carried?.length === cells.length) {
267
+ if (sentTokens)
268
+ keys.forEach((key, index) => this.settleSent(key, sentTokens[index], carried[index]));
209
269
  const failedKeys = new Set(cells
210
270
  .filter((_, index) => carried[index]?.status === "failed")
211
271
  .map(({ cell }) => gridCellKey(cell.rowId, cell.columnId)));
@@ -214,6 +274,8 @@ export class GridEditingController {
214
274
  }
215
275
  return carried;
216
276
  }
277
+ if (sentTokens)
278
+ keys.forEach((key, index) => this.dropSent(key, sentTokens[index]));
217
279
  if (assignments.length > 0) {
218
280
  this.publishPending(rollbackGridPending(this.pending, assignments));
219
281
  }
@@ -245,6 +307,8 @@ export class GridEditingController {
245
307
  const entry = begun.entry;
246
308
  if (!entry || entry.edits.length === 0)
247
309
  return;
310
+ for (const cell of entry.edits)
311
+ this.dropSent(gridCellKey(cell.rowId, cell.columnId));
248
312
  const first = entry.edits[0];
249
313
  onApply?.({ rowId: first.rowId, columnId: first.columnId });
250
314
  const cells = entry.edits.map((cell) => ({
@@ -257,6 +321,7 @@ export class GridEditingController {
257
321
  return held ? { key, value: held.value, revision: held.revision } : null;
258
322
  });
259
323
  const results = await this.performBatch(cells, kind === "undo" ? "prev" : "next", "restore");
324
+ this.reportRefusals(cells, results);
260
325
  const cleared = overwritten.filter((held, index) => held != null && results[index]?.status === "confirmed");
261
326
  if (cleared.length > 0)
262
327
  this.publishPending(rollbackGridPending(this.pending, cleared));
@@ -0,0 +1,111 @@
1
+ /**
2
+ * THE GRID'S RECORDER: what a scroll costs on a device, measured on the device.
3
+ *
4
+ * It samples three things while an app's lab asks it to (`setGridLab`): every scroll event of the
5
+ * grid's own area (where it was, how long the grid's handler took, whether rows were drawn, how
6
+ * many are drawn, whether the frozen cells were pinned, the content's height), every animation
7
+ * frame, and every touch (down, and up with the finger's speed). At a flush it turns them into one
8
+ * recording with a summary, and hands it to the app.
9
+ *
10
+ * WHAT IT CAN'T SEE: the screen. On iOS the screen scrolls on its own while the page draws, so the
11
+ * page never learns how much of the screen was blank. What it measures is how late the page is:
12
+ * the time between scroll events, how far each event jumps against the rows drawn ahead, the
13
+ * handler's time and the frame rate. A screen recording stays the ground truth for blank.
14
+ *
15
+ * ITS OWN COST is the measure's honesty, so nothing is allocated per sample: the samples go into
16
+ * typed arrays sized to the caps when the recorder is made, and the tuples and the summary are
17
+ * built only at the flush. At a cap it stops sampling that kind and counts what it dropped. It
18
+ * never sends by itself: the caller flushes once the list is still, or when the page is hidden.
19
+ */
20
+ /** [t ms since the recording began (1 decimal), scrollTop, scrollLeft, handler ms (1 decimal), rendered 0|1, rows drawn, pinned 0|1, scrollHeight] */
21
+ export type GridScrollSample = [number, number, number, number, 0 | 1, number, 0 | 1, number];
22
+ export type GridTouchKind = "start" | "end";
23
+ /** [t, kind, x, y] in client px; "end" carries the finger's release speed in px/s as x (horizontal) and y (vertical). */
24
+ export type GridTouchSample = [number, GridTouchKind, number, number];
25
+ export type GridSpread = {
26
+ p50: number;
27
+ p90: number;
28
+ max: number;
29
+ };
30
+ export type GridRecordingSummary = {
31
+ durationMs: number;
32
+ scrollEvents: number;
33
+ eventGapMs: GridSpread;
34
+ jumpPx: GridSpread;
35
+ aheadPx: number;
36
+ jumpsOverAhead: number;
37
+ handlerMs: GridSpread;
38
+ frameGapMs: GridSpread;
39
+ framesOver50ms: number;
40
+ maxLeftPx: number;
41
+ pinFlips: number;
42
+ scrollHeightChanges: number;
43
+ longestStillTouchMs: number;
44
+ };
45
+ export type GridRecordingContext = {
46
+ page: string;
47
+ /** The rows the window drew beyond each edge of the view while this was recorded. */
48
+ lab: {
49
+ overscan: number;
50
+ };
51
+ device: {
52
+ ua: string;
53
+ dpr: number;
54
+ screen: [number, number];
55
+ viewport: [number, number];
56
+ cores: number;
57
+ };
58
+ /** `boxes`: 1, one box scrolled both ways; 2, the rows up and down inside a box that scrolls sideways. */
59
+ grid: {
60
+ rows: number;
61
+ groups: number;
62
+ rowHeight: number;
63
+ boxes: 1 | 2;
64
+ };
65
+ };
66
+ export type GridRecording = GridRecordingContext & {
67
+ v: 1;
68
+ /** One per recording. */
69
+ id: string;
70
+ /** One per page life. */
71
+ session: string;
72
+ startedAt: string;
73
+ scrolls: GridScrollSample[];
74
+ /** The t of each animation frame. */
75
+ frames: number[];
76
+ touches: GridTouchSample[];
77
+ summary: GridRecordingSummary;
78
+ /** Samples left out once a cap was reached. */
79
+ dropped: {
80
+ scrolls: number;
81
+ frames: number;
82
+ touches: number;
83
+ };
84
+ };
85
+ export declare const GRID_RECORDER_CAPS: {
86
+ readonly scrolls: 4000;
87
+ readonly frames: 8000;
88
+ readonly touches: 2000;
89
+ };
90
+ export type GridRecorder = {
91
+ scroll(at: number, top: number, left: number, handlerMs: number, rendered: boolean, drawn: number, scrollHeight: number): void;
92
+ /** The scroll area's own listener, later in the same dispatch: this event's sideways offset and pin. */
93
+ amend(left: number, pinned: boolean): void;
94
+ frame(at: number): void;
95
+ touch(at: number, kind: GridTouchKind, x: number, y: number): void;
96
+ /** Sends what it holds as one recording (nothing when it holds no scroll and no touch) and starts afresh. */
97
+ flush(): void;
98
+ readonly empty: boolean;
99
+ /** The typed arrays the samples are written into, for the test that holds them allocated once. */
100
+ __buffers(): readonly ArrayBufferView[];
101
+ };
102
+ /** A v4 UUID: `crypto.randomUUID` where the page is a secure context, else built from `getRandomValues`. */
103
+ export declare function gridRecordingId(): string;
104
+ export declare function createGridRecorder(options: {
105
+ send: (recording: GridRecording) => void;
106
+ context: () => GridRecordingContext;
107
+ session: string;
108
+ newId?: () => string;
109
+ nowIso?: () => string;
110
+ }): GridRecorder;
111
+ export declare function summarizeGridRecording(r: Pick<GridRecording, "scrolls" | "frames" | "touches" | "lab" | "grid">): GridRecordingSummary;
@@ -0,0 +1,223 @@
1
+ export const GRID_RECORDER_CAPS = { scrolls: 4000, frames: 8000, touches: 2000 };
2
+ const TOUCH_KINDS = ["start", "end"];
3
+ const SCROLL_NUMBERS = 6;
4
+ const SCROLL_FLAGS = 2;
5
+ const PAUSE_MS = 1000;
6
+ const round1 = (value) => Math.round(value * 10) / 10;
7
+ export function gridRecordingId() {
8
+ if (typeof crypto.randomUUID === "function")
9
+ return crypto.randomUUID();
10
+ const bytes = crypto.getRandomValues(new Uint8Array(16));
11
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
12
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
13
+ const hex = [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("");
14
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
15
+ }
16
+ export function createGridRecorder(options) {
17
+ const newId = options.newId ?? gridRecordingId;
18
+ const nowIso = options.nowIso ?? (() => new Date().toISOString());
19
+ const scrollNumbers = new Float64Array(GRID_RECORDER_CAPS.scrolls * SCROLL_NUMBERS);
20
+ const scrollFlags = new Uint8Array(GRID_RECORDER_CAPS.scrolls * SCROLL_FLAGS);
21
+ const frameTimes = new Float64Array(GRID_RECORDER_CAPS.frames);
22
+ const touchNumbers = new Float64Array(GRID_RECORDER_CAPS.touches * 3);
23
+ const touchKinds = new Uint8Array(GRID_RECORDER_CAPS.touches);
24
+ let scrolls = 0;
25
+ let frames = 0;
26
+ let touches = 0;
27
+ let droppedScrolls = 0;
28
+ let droppedFrames = 0;
29
+ let droppedTouches = 0;
30
+ let amendable = false;
31
+ let origin = Number.NaN;
32
+ let startedAt = "";
33
+ const begin = (at) => {
34
+ if (Number.isNaN(origin)) {
35
+ origin = at;
36
+ startedAt = nowIso();
37
+ }
38
+ };
39
+ const reset = () => {
40
+ scrolls = frames = touches = 0;
41
+ droppedScrolls = droppedFrames = droppedTouches = 0;
42
+ amendable = false;
43
+ origin = Number.NaN;
44
+ startedAt = "";
45
+ };
46
+ return {
47
+ scroll(at, top, left, handlerMs, rendered, drawn, scrollHeight) {
48
+ if (scrolls >= GRID_RECORDER_CAPS.scrolls) {
49
+ droppedScrolls++;
50
+ amendable = false;
51
+ return;
52
+ }
53
+ begin(at);
54
+ const n = scrolls * SCROLL_NUMBERS;
55
+ scrollNumbers[n] = at;
56
+ scrollNumbers[n + 1] = top;
57
+ scrollNumbers[n + 2] = left;
58
+ scrollNumbers[n + 3] = handlerMs;
59
+ scrollNumbers[n + 4] = drawn;
60
+ scrollNumbers[n + 5] = scrollHeight;
61
+ scrollFlags[scrolls * SCROLL_FLAGS] = rendered ? 1 : 0;
62
+ scrollFlags[scrolls * SCROLL_FLAGS + 1] = 0;
63
+ scrolls++;
64
+ amendable = true;
65
+ },
66
+ amend(left, pinned) {
67
+ if (!amendable || scrolls === 0)
68
+ return;
69
+ scrollNumbers[(scrolls - 1) * SCROLL_NUMBERS + 2] = left;
70
+ scrollFlags[(scrolls - 1) * SCROLL_FLAGS + 1] = pinned ? 1 : 0;
71
+ amendable = false;
72
+ },
73
+ frame(at) {
74
+ if (frames >= GRID_RECORDER_CAPS.frames) {
75
+ droppedFrames++;
76
+ return;
77
+ }
78
+ begin(at);
79
+ frameTimes[frames++] = at;
80
+ },
81
+ touch(at, kind, x, y) {
82
+ if (touches >= GRID_RECORDER_CAPS.touches) {
83
+ droppedTouches++;
84
+ return;
85
+ }
86
+ begin(at);
87
+ const n = touches * 3;
88
+ touchNumbers[n] = at;
89
+ touchNumbers[n + 1] = x;
90
+ touchNumbers[n + 2] = y;
91
+ touchKinds[touches++] = TOUCH_KINDS.indexOf(kind);
92
+ },
93
+ flush() {
94
+ if (scrolls === 0 && touches === 0) {
95
+ reset();
96
+ return;
97
+ }
98
+ const start = frames > 0 ? Math.min(origin, frameTimes[0]) : origin;
99
+ const t = (at) => round1(at - start);
100
+ const scrollSamples = [];
101
+ for (let i = 0; i < scrolls; i++) {
102
+ const n = i * SCROLL_NUMBERS;
103
+ scrollSamples.push([
104
+ t(scrollNumbers[n]),
105
+ Math.round(scrollNumbers[n + 1]),
106
+ Math.round(scrollNumbers[n + 2]),
107
+ round1(scrollNumbers[n + 3]),
108
+ scrollFlags[i * SCROLL_FLAGS],
109
+ scrollNumbers[n + 4],
110
+ scrollFlags[i * SCROLL_FLAGS + 1],
111
+ Math.round(scrollNumbers[n + 5]),
112
+ ]);
113
+ }
114
+ const frameSamples = [];
115
+ for (let i = 0; i < frames; i++)
116
+ frameSamples.push(t(frameTimes[i]));
117
+ const touchSamples = [];
118
+ for (let i = 0; i < touches; i++) {
119
+ const n = i * 3;
120
+ touchSamples.push([
121
+ t(touchNumbers[n]),
122
+ TOUCH_KINDS[touchKinds[i]],
123
+ round1(touchNumbers[n + 1]),
124
+ round1(touchNumbers[n + 2]),
125
+ ]);
126
+ }
127
+ const context = options.context();
128
+ const recording = {
129
+ v: 1,
130
+ id: newId(),
131
+ session: options.session,
132
+ startedAt,
133
+ ...context,
134
+ scrolls: scrollSamples,
135
+ frames: frameSamples,
136
+ touches: touchSamples,
137
+ summary: summarizeGridRecording({
138
+ scrolls: scrollSamples,
139
+ frames: frameSamples,
140
+ touches: touchSamples,
141
+ lab: context.lab,
142
+ grid: context.grid,
143
+ }),
144
+ dropped: { scrolls: droppedScrolls, frames: droppedFrames, touches: droppedTouches },
145
+ };
146
+ reset();
147
+ options.send(recording);
148
+ },
149
+ get empty() {
150
+ return scrolls === 0 && touches === 0;
151
+ },
152
+ __buffers: () => [scrollNumbers, scrollFlags, frameTimes, touchNumbers, touchKinds],
153
+ };
154
+ }
155
+ function spread(values) {
156
+ if (values.length === 0)
157
+ return { p50: 0, p90: 0, max: 0 };
158
+ const sorted = [...values].sort((a, b) => a - b);
159
+ const rank = (p) => sorted[Math.max(0, Math.ceil(p * sorted.length) - 1)];
160
+ return { p50: round1(rank(0.5)), p90: round1(rank(0.9)), max: round1(sorted[sorted.length - 1]) };
161
+ }
162
+ export function summarizeGridRecording(r) {
163
+ const gaps = [];
164
+ const jumps = [];
165
+ let pinFlips = 0;
166
+ let scrollHeightChanges = 0;
167
+ let maxLeft = 0;
168
+ r.scrolls.forEach((sample, i) => {
169
+ maxLeft = Math.max(maxLeft, sample[2]);
170
+ if (i === 0)
171
+ return;
172
+ const before = r.scrolls[i - 1];
173
+ if (sample[6] !== before[6])
174
+ pinFlips++;
175
+ if (sample[7] !== before[7])
176
+ scrollHeightChanges++;
177
+ const gap = sample[0] - before[0];
178
+ if (gap > PAUSE_MS)
179
+ return;
180
+ gaps.push(gap);
181
+ jumps.push(Math.abs(sample[1] - before[1]));
182
+ });
183
+ const frameGaps = [];
184
+ for (let i = 1; i < r.frames.length; i++) {
185
+ const gap = r.frames[i] - r.frames[i - 1];
186
+ if (gap <= PAUSE_MS)
187
+ frameGaps.push(gap);
188
+ }
189
+ const aheadPx = round1(r.lab.overscan * r.grid.rowHeight);
190
+ let longestStill = 0;
191
+ let downAt = null;
192
+ for (const [at, kind] of r.touches) {
193
+ if (kind === "start")
194
+ downAt = at;
195
+ else if (kind === "end" && downAt !== null) {
196
+ let last = downAt;
197
+ for (const sample of r.scrolls) {
198
+ if (sample[0] < downAt || sample[0] > at)
199
+ continue;
200
+ longestStill = Math.max(longestStill, sample[0] - last);
201
+ last = sample[0];
202
+ }
203
+ longestStill = Math.max(longestStill, at - last);
204
+ downAt = null;
205
+ }
206
+ }
207
+ const times = [...r.scrolls.map((s) => s[0]), ...r.frames, ...r.touches.map((s) => s[0])];
208
+ return {
209
+ durationMs: times.length ? round1(Math.max(...times) - Math.min(...times)) : 0,
210
+ scrollEvents: r.scrolls.length,
211
+ eventGapMs: spread(gaps),
212
+ jumpPx: spread(jumps),
213
+ aheadPx,
214
+ jumpsOverAhead: jumps.filter((jump) => jump > aheadPx).length,
215
+ handlerMs: spread(r.scrolls.map((s) => s[3])),
216
+ frameGapMs: spread(frameGaps),
217
+ framesOver50ms: frameGaps.filter((gap) => gap > 50).length,
218
+ maxLeftPx: maxLeft,
219
+ pinFlips,
220
+ scrollHeightChanges,
221
+ longestStillTouchMs: round1(longestStill),
222
+ };
223
+ }
@@ -0,0 +1,18 @@
1
+ import type { FieldConventions } from "@viewkitjs/fields";
2
+ import type { ViewsMessageResolver } from "../../contract.js";
3
+ import type { ListColumn } from "../../model/column-schema.js";
4
+ import type { GridEditCell } from "./editing-model.js";
5
+ type RowEdit<Row> = GridEditCell<Row> & {
6
+ row: Row;
7
+ };
8
+ /** A batch's edits with every part edit written into its whole: the edits of one row's field, a part column's or the
9
+ * field's own, fold in the batch's order onto that field's stored value (`wholeStored`), the field's own edit cleaned
10
+ * by the write gate first, and become ONE edit of the whole column, without an overlay, where the first of them
11
+ * stood. Other edits pass as they are. A refused edit drops, its reason kept. */
12
+ export declare function foldPartEdits<Row>(edits: readonly RowEdit<Row>[], columnById: ReadonlyMap<string, ListColumn<Row>>, wholeStored: (rowId: string, wholeId: string, row: Row) => unknown, conventions: FieldConventions, options?: {
13
+ messages?: ViewsMessageResolver;
14
+ }): {
15
+ edits: RowEdit<Row>[];
16
+ refusals: string[];
17
+ };
18
+ export {};
@@ -0,0 +1,48 @@
1
+ import { gridNormalizeWrite } from "../../model/column-capabilities.js";
2
+ import { gridPartWrite } from "../../model/part-write.js";
3
+ export function foldPartEdits(edits, columnById, wholeStored, conventions, options = {}) {
4
+ const groupOf = (edit) => {
5
+ const wholeId = columnById.get(edit.columnId)?.partOf?.column;
6
+ return wholeId ? `${edit.rowId}␟${wholeId}` : null;
7
+ };
8
+ const folding = new Set(edits.map(groupOf).filter((group) => group !== null));
9
+ if (folding.size === 0)
10
+ return { edits: [...edits], refusals: [] };
11
+ const refusals = [];
12
+ const out = [];
13
+ const folded = new Map();
14
+ for (const edit of edits) {
15
+ const col = columnById.get(edit.columnId);
16
+ const wholeId = col?.partOf?.column ?? (folding.has(`${edit.rowId}␟${edit.columnId}`) ? edit.columnId : null);
17
+ if (!col || !wholeId) {
18
+ out.push(edit);
19
+ continue;
20
+ }
21
+ const group = `${edit.rowId}␟${wholeId}`;
22
+ let entry = folded.get(group);
23
+ if (!entry) {
24
+ const stored = wholeStored(edit.rowId, wholeId, edit.row);
25
+ entry = {
26
+ index: out.length,
27
+ edit: { ...edit, columnId: wholeId, prev: stored, overlay: false },
28
+ value: stored,
29
+ };
30
+ folded.set(group, entry);
31
+ out.push(null);
32
+ }
33
+ const result = col.partOf
34
+ ? gridPartWrite(col, entry.value, edit.next, conventions, options)
35
+ : gridNormalizeWrite(col, edit.next, conventions, { messages: options.messages, stored: entry.value });
36
+ if (!result.ok) {
37
+ refusals.push(result.reason);
38
+ continue;
39
+ }
40
+ entry.value = result.value;
41
+ entry.edit = { ...entry.edit, next: result.value };
42
+ }
43
+ for (const entry of folded.values()) {
44
+ if (entry.value !== entry.edit.prev)
45
+ out[entry.index] = entry.edit;
46
+ }
47
+ return { edits: out.filter((edit) => edit !== null), refusals };
48
+ }
@@ -1,6 +1,11 @@
1
1
  import { gridCellKey } from "./commit-model.js";
2
2
  import { sameListValue } from "@viewkitjs/fields";
3
- import { isEmptyValue, isGridKeptValue, looselyEqualValue, sameKeptValue } from "./value-equality.js";
3
+ import { isEmptyValue, isGridKeptValue, looselyEqualValue, sameCalendarDay, sameInstantMinute, sameKeptValue, } from "./value-equality.js";
4
+ import { fieldTypeOf } from "../../model/field-type-of.js";
5
+ const sameInstantIn = (col, a, b) => {
6
+ const type = col == null ? undefined : fieldTypeOf(col);
7
+ return type === "datetime" ? sameInstantMinute(a, b) : type === "date" && sameCalendarDay(a, b);
8
+ };
4
9
  export function findGridPendingMatches(rows, columns, getRowId, pendingByRow, hasInflight) {
5
10
  const byId = new Map(rows.map((row) => [getRowId(row), row]));
6
11
  const byColumn = new Map(columns.map((column) => [column.id, column]));
@@ -16,7 +21,8 @@ export function findGridPendingMatches(rows, columns, getRowId, pendingByRow, ha
16
21
  continue;
17
22
  const server = read(row);
18
23
  const landed = (isGridKeptValue(value) ? sameKeptValue(server, value) : sameListValue(server, value)) ||
19
- (isEmptyValue(value) && isEmptyValue(server));
24
+ (isEmptyValue(value) && isEmptyValue(server)) ||
25
+ sameInstantIn(col, server, value);
20
26
  const superseded = !landed && hasInflight != null && !hasInflight(rowId, columnId);
21
27
  if (landed || superseded)
22
28
  matched.push(gridCellKey(rowId, columnId));
@@ -42,7 +48,10 @@ export function findSupersededCells(rows, columns, getRowId, pendingByRow, hasIn
42
48
  const serverValue = read(row);
43
49
  if (isGridKeptValue(value) ? sameKeptValue(serverValue, value) : looselyEqualValue(serverValue, value))
44
50
  continue;
45
- if (looselyEqualValue(serverValue, baselineOf(rowId, columnId)))
51
+ if (sameInstantIn(col, serverValue, value))
52
+ continue;
53
+ const baseline = baselineOf(rowId, columnId);
54
+ if (looselyEqualValue(serverValue, baseline) || sameInstantIn(col, serverValue, baseline))
46
55
  continue;
47
56
  taken.push({ rowId, columnId, column: col, serverValue });
48
57
  }
@@ -0,0 +1,3 @@
1
+ import type { ViewsMessageResolver } from "../../contract.js";
2
+ import type { GridCommitRefusal } from "./commit-model.js";
3
+ export declare function gridRefusalSentence(refusal: GridCommitRefusal, fieldName: (columnId: string) => string, messages: ViewsMessageResolver): string;
@@ -0,0 +1,15 @@
1
+ function wordsOf(error) {
2
+ const text = error instanceof Error ? error.message : typeof error === "string" ? error : "";
3
+ const trimmed = text.trim();
4
+ return trimmed === "" ? null : trimmed;
5
+ }
6
+ export function gridRefusalSentence(refusal, fieldName, messages) {
7
+ const reason = wordsOf(refusal.error);
8
+ if (refusal.count === 1) {
9
+ return reason ?? messages({ key: "views.grid.commit-refused", values: { field: fieldName(refusal.columnIds[0]) } });
10
+ }
11
+ return messages({
12
+ key: "views.grid.commit-refused-many",
13
+ values: reason === null ? { count: refusal.count } : { count: refusal.count, reason },
14
+ });
15
+ }
@@ -0,0 +1,21 @@
1
+ import { type GridCellPos } from "./coordinates.js";
2
+ /**
3
+ * What `onOpenRow` hands with the row: the way back to the cell the row was opened from, for when what it opened (a
4
+ * drawer, a dialog) closes. The place is read again when it is called, so a refetch in between is no matter.
5
+ */
6
+ export type GridRowOpenedFrom = {
7
+ /** Puts the focus back on that cell (on a desktop the grid's focused cell too, so the keys carry on from it) and
8
+ * returns true; when its record is no longer shown, focuses the grid's frame and returns false. */
9
+ readonly focus: () => boolean;
10
+ /** The same place as an element, for a dialog's final-focus option: the cell, or the grid's frame when its record
11
+ * is no longer shown; null once the grid is gone. Asked as a dialog closes, the grid settles it once the close is
12
+ * done: the focus lands on the cell (selected on a desktop) unless it went elsewhere. */
13
+ readonly element: () => HTMLElement | null;
14
+ };
15
+ /**
16
+ * Where a row's `from` lands now. The key it was opened from while that copy is still drawn (one record can be drawn
17
+ * under two groups, and the one opened is the one meant); else the record's first copy in the visible order (a
18
+ * refetch moved it under another group); else null, its record no longer shown. The column it was opened from, else
19
+ * the row's first visible column (hidden meanwhile).
20
+ */
21
+ export declare function resolveOpenedFrom(at: GridCellPos, visibleRowKeys: readonly string[], visibleColIds: readonly string[]): GridCellPos | null;
@@ -0,0 +1,11 @@
1
+ import { gridRowIdFromKey } from "./coordinates.js";
2
+ export function resolveOpenedFrom(at, visibleRowKeys, visibleColIds) {
3
+ const columnId = visibleColIds.includes(at.columnId) ? at.columnId : visibleColIds[0];
4
+ if (columnId == null)
5
+ return null;
6
+ if (visibleRowKeys.includes(at.rowId))
7
+ return { rowId: at.rowId, columnId };
8
+ const record = gridRowIdFromKey(at.rowId);
9
+ const rowId = visibleRowKeys.find((key) => gridRowIdFromKey(key) === record);
10
+ return rowId == null ? null : { rowId, columnId };
11
+ }
@@ -1,4 +1,4 @@
1
- import type { GridCellCommitFn, GridCellsCommitFn } from "./commit-model.js";
1
+ import type { GridCellCommitFn, GridCellsCommitFn, GridCommitRefusal } from "./commit-model.js";
2
2
  import { type GridCellPos } from "./coordinates.js";
3
3
  import { type GridEditCell, type GridSettlementByRow } from "./editing-model.js";
4
4
  export type { GridEditCell } from "./editing-model.js";
@@ -42,5 +42,19 @@ type GridEditingApi<Row> = {
42
42
  hasInflight: (rowId: string, columnId: string) => boolean;
43
43
  /** What the cell held before its pending write — see GridPendingEntry.baseline. */
44
44
  pendingBaseline: (rowId: string, columnId: string) => unknown;
45
+ /** The last value this grid sent for a cell and what it was built on — see GridEditingController.sent. */
46
+ sent: (rowId: string, columnId: string) => {
47
+ value: unknown;
48
+ builtOn: unknown;
49
+ chain: readonly unknown[];
50
+ } | undefined;
51
+ /** The cells the controller holds a sent value for, and retiring one — see GridEditingController.forgetSent. */
52
+ sentCells: () => {
53
+ rowId: string;
54
+ columnId: string;
55
+ }[];
56
+ forgetSent: (rowId: string, columnId: string) => void;
45
57
  };
46
- export declare function useGridEditing<Row>(onCellCommit?: GridCellCommitFn<Row>, onCellsCommit?: GridCellsCommitFn<Row>): GridEditingApi<Row>;
58
+ export declare function useGridEditing<Row>(onCellCommit?: GridCellCommitFn<Row>, onCellsCommit?: GridCellsCommitFn<Row>,
59
+ /** Told once per write the app refused (`GridEditingCallbacks.onRefused`). */
60
+ onRefused?: (refusal: GridCommitRefusal) => void): GridEditingApi<Row>;