@viewkitjs/views 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +571 -0
  2. package/README.md +5 -3
  3. package/dist/atoms/LoadMore.js +11 -1
  4. package/dist/atoms/RowMenu.js +5 -2
  5. package/dist/cells/cell-format.d.ts +3 -3
  6. package/dist/cells/cell-title.d.ts +1 -2
  7. package/dist/cells/cell-title.js +2 -2
  8. package/dist/cells/cell-values.js +6 -3
  9. package/dist/contract.d.ts +50 -9
  10. package/dist/contract.js +33 -5
  11. package/dist/display/converted.d.ts +19 -0
  12. package/dist/display/converted.js +12 -0
  13. package/dist/display/index.d.ts +1 -0
  14. package/dist/display/index.js +1 -0
  15. package/dist/display/link-click.d.ts +11 -0
  16. package/dist/display/link-click.js +3 -0
  17. package/dist/display/link.js +7 -3
  18. package/dist/display/multi-value.d.ts +1 -1
  19. package/dist/display/multi-value.js +1 -1
  20. package/dist/display/options.d.ts +7 -1
  21. package/dist/display/phone.js +3 -1
  22. package/dist/editors/ChipsEditor.d.ts +9 -4
  23. package/dist/editors/ChipsEditor.js +6 -2
  24. package/dist/editors/DateEditor.d.ts +21 -6
  25. package/dist/editors/DateEditor.js +118 -30
  26. package/dist/editors/EditorPanel.d.ts +61 -0
  27. package/dist/editors/EditorPanel.js +54 -0
  28. package/dist/editors/LocationEditor.d.ts +3 -0
  29. package/dist/editors/LocationEditor.js +14 -6
  30. package/dist/editors/NameEditor.d.ts +3 -0
  31. package/dist/editors/NameEditor.js +11 -7
  32. package/dist/editors/NumberEditor.d.ts +3 -0
  33. package/dist/editors/NumberEditor.js +6 -6
  34. package/dist/editors/RangeEditor.d.ts +16 -1
  35. package/dist/editors/RangeEditor.js +21 -5
  36. package/dist/editors/RelationEditor.d.ts +13 -28
  37. package/dist/editors/RelationEditor.js +17 -40
  38. package/dist/editors/RelationSetEditor.d.ts +53 -0
  39. package/dist/editors/RelationSetEditor.js +112 -0
  40. package/dist/editors/SelectEditor.d.ts +21 -3
  41. package/dist/editors/SelectEditor.js +55 -9
  42. package/dist/editors/TextEditor.d.ts +51 -0
  43. package/dist/editors/TextEditor.js +81 -0
  44. package/dist/editors/ValueListEditor.d.ts +3 -0
  45. package/dist/editors/ValueListEditor.js +4 -2
  46. package/dist/editors/edit-cores.d.ts +12 -9
  47. package/dist/editors/edit-cores.js +7 -6
  48. package/dist/editors/edit-session.d.ts +21 -11
  49. package/dist/editors/edit-session.js +19 -5
  50. package/dist/editors/keep-inside.d.ts +12 -0
  51. package/dist/editors/keep-inside.js +20 -0
  52. package/dist/editors/open-value.d.ts +21 -0
  53. package/dist/editors/open-value.js +36 -0
  54. package/dist/editors/open-values.d.ts +4 -0
  55. package/dist/editors/open-values.js +7 -0
  56. package/dist/editors/relation-kinds.d.ts +7 -0
  57. package/dist/editors/relation-kinds.js +21 -0
  58. package/dist/editors/relation-panel.d.ts +69 -0
  59. package/dist/editors/relation-panel.js +40 -0
  60. package/dist/field-row/FieldNoteLine.d.ts +14 -0
  61. package/dist/field-row/FieldNoteLine.js +14 -0
  62. package/dist/field-row/FieldRow.d.ts +73 -0
  63. package/dist/field-row/FieldRow.js +157 -0
  64. package/dist/field-row/FieldRowLane.d.ts +19 -0
  65. package/dist/field-row/FieldRowLane.js +11 -0
  66. package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
  67. package/dist/field-row/editors/RowChipsEditor.js +25 -0
  68. package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
  69. package/dist/field-row/editors/RowDateEditor.js +18 -0
  70. package/dist/field-row/editors/RowEditor.d.ts +39 -0
  71. package/dist/field-row/editors/RowEditor.js +64 -0
  72. package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
  73. package/dist/field-row/editors/RowNameEditor.js +15 -0
  74. package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
  75. package/dist/field-row/editors/RowNumberEditor.js +18 -0
  76. package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
  77. package/dist/field-row/editors/RowPlaceEditor.js +18 -0
  78. package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
  79. package/dist/field-row/editors/RowRangeEditor.js +15 -0
  80. package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
  81. package/dist/field-row/editors/RowRelationEditor.js +77 -0
  82. package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
  83. package/dist/field-row/editors/RowSelectEditor.js +23 -0
  84. package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
  85. package/dist/field-row/editors/RowTextEditor.js +16 -0
  86. package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
  87. package/dist/field-row/editors/RowValueListEditor.js +21 -0
  88. package/dist/field-row/editors/host.d.ts +59 -0
  89. package/dist/field-row/editors/host.js +1 -0
  90. package/dist/field-row/editors/row-session.d.ts +49 -0
  91. package/dist/field-row/editors/row-session.js +49 -0
  92. package/dist/field-row/index.d.ts +5 -0
  93. package/dist/field-row/index.js +5 -0
  94. package/dist/field-row/row-target.d.ts +20 -0
  95. package/dist/field-row/row-target.js +3 -0
  96. package/dist/field-row/useFieldWrite.d.ts +45 -0
  97. package/dist/field-row/useFieldWrite.js +190 -0
  98. package/dist/field-row/useRowSettlement.d.ts +33 -0
  99. package/dist/field-row/useRowSettlement.js +23 -0
  100. package/dist/fields/binding.d.ts +6 -1
  101. package/dist/fields/binding.js +13 -6
  102. package/dist/fields/edit-core-types.d.ts +9 -9
  103. package/dist/fields/edit-core-types.js +6 -6
  104. package/dist/fields/money.d.ts +5 -0
  105. package/dist/fields/money.js +10 -0
  106. package/dist/fields/number-edit.d.ts +6 -0
  107. package/dist/fields/number-edit.js +4 -0
  108. package/dist/fields/prepare-write.js +6 -1
  109. package/dist/fields/relation-source-types.d.ts +12 -0
  110. package/dist/fields/write-target.d.ts +50 -0
  111. package/dist/fields/write-target.js +10 -0
  112. package/dist/grid/chrome/GridAddColumn.js +1 -1
  113. package/dist/grid/chrome/GridAggregateMenu.d.ts +1 -1
  114. package/dist/grid/chrome/GridAggregateMenu.js +8 -6
  115. package/dist/grid/chrome/GridCellEditors.d.ts +7 -0
  116. package/dist/grid/chrome/GridCellEditors.js +87 -16
  117. package/dist/grid/chrome/GridCellOutline.d.ts +22 -43
  118. package/dist/grid/chrome/GridCellOutline.js +2 -7
  119. package/dist/grid/chrome/GridChipsEditor.d.ts +16 -6
  120. package/dist/grid/chrome/GridChipsEditor.js +21 -26
  121. package/dist/grid/chrome/GridColumnMenu.d.ts +1 -1
  122. package/dist/grid/chrome/GridColumnMenu.js +7 -3
  123. package/dist/grid/chrome/GridDateEditor.d.ts +23 -11
  124. package/dist/grid/chrome/GridDateEditor.js +13 -25
  125. package/dist/grid/chrome/GridFooter.d.ts +12 -2
  126. package/dist/grid/chrome/GridFooter.js +10 -6
  127. package/dist/grid/chrome/GridGroupMenu.js +20 -13
  128. package/dist/grid/chrome/GridHeader.d.ts +9 -4
  129. package/dist/grid/chrome/GridHeader.js +15 -10
  130. package/dist/grid/chrome/GridLongTextEditor.d.ts +28 -9
  131. package/dist/grid/chrome/GridLongTextEditor.js +16 -74
  132. package/dist/grid/chrome/GridNameEditor.d.ts +11 -6
  133. package/dist/grid/chrome/GridNameEditor.js +12 -27
  134. package/dist/grid/chrome/GridNumberEditor.d.ts +20 -6
  135. package/dist/grid/chrome/GridNumberEditor.js +46 -20
  136. package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
  137. package/dist/grid/chrome/GridPlaceEditor.js +22 -0
  138. package/dist/grid/chrome/GridRangeEditor.d.ts +15 -5
  139. package/dist/grid/chrome/GridRangeEditor.js +16 -20
  140. package/dist/grid/chrome/GridRelationEditor.d.ts +38 -14
  141. package/dist/grid/chrome/GridRelationEditor.js +86 -24
  142. package/dist/grid/chrome/GridRow.d.ts +7 -1
  143. package/dist/grid/chrome/GridRow.js +57 -14
  144. package/dist/grid/chrome/GridRowActions.js +1 -1
  145. package/dist/grid/chrome/GridRowCells.js +18 -23
  146. package/dist/grid/chrome/GridSelectEditor.d.ts +19 -4
  147. package/dist/grid/chrome/GridSelectEditor.js +21 -27
  148. package/dist/grid/chrome/GridStructure.d.ts +9 -10
  149. package/dist/grid/chrome/GridStructure.js +10 -14
  150. package/dist/grid/chrome/GridTable.js +97 -30
  151. package/dist/grid/chrome/GridTableSurface.d.ts +39 -2
  152. package/dist/grid/chrome/GridTableSurface.js +12 -3
  153. package/dist/grid/chrome/GridTextEditor.d.ts +35 -1
  154. package/dist/grid/chrome/GridTextEditor.js +35 -37
  155. package/dist/grid/chrome/GridValueListEditor.d.ts +15 -3
  156. package/dist/grid/chrome/GridValueListEditor.js +10 -27
  157. package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
  158. package/dist/grid/chrome/cell-cut-off.js +20 -0
  159. package/dist/grid/chrome/cells.js +1 -2
  160. package/dist/grid/chrome/checks.d.ts +2 -5
  161. package/dist/grid/chrome/checks.js +15 -5
  162. package/dist/grid/chrome/editors.d.ts +1 -1
  163. package/dist/grid/chrome/editors.js +1 -1
  164. package/dist/grid/chrome/grid-cell-classes.d.ts +2 -8
  165. package/dist/grid/chrome/grid-cell-classes.js +10 -8
  166. package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
  167. package/dist/grid/chrome/grid-cell-link.js +9 -0
  168. package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
  169. package/dist/grid/chrome/grid-edit-session.js +118 -0
  170. package/dist/grid/chrome/grid-hover.d.ts +60 -0
  171. package/dist/grid/chrome/grid-hover.js +81 -0
  172. package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
  173. package/dist/grid/chrome/grid-menu-focus.js +93 -0
  174. package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
  175. package/dist/grid/chrome/grid-row-menu-key.js +36 -0
  176. package/dist/grid/chrome/grid-row-props.d.ts +16 -4
  177. package/dist/grid/chrome/grid-row-window.d.ts +61 -0
  178. package/dist/grid/chrome/grid-row-window.js +212 -0
  179. package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
  180. package/dist/grid/chrome/grid-scroll-owner.js +75 -0
  181. package/dist/grid/chrome/grid-styles.d.ts +4 -1
  182. package/dist/grid/chrome/grid-styles.js +1 -0
  183. package/dist/grid/chrome/grid-table-props.d.ts +2 -3
  184. package/dist/grid/chrome/useGridFocus.d.ts +45 -0
  185. package/dist/grid/chrome/useGridFocus.js +122 -0
  186. package/dist/grid/chrome/useGridKeyboard.d.ts +21 -4
  187. package/dist/grid/chrome/useGridKeyboard.js +214 -38
  188. package/dist/grid/chrome/useGridRangeActions.d.ts +3 -1
  189. package/dist/grid/chrome/useGridRangeActions.js +17 -10
  190. package/dist/grid/chrome/useGridRangeGestures.js +68 -21
  191. package/dist/grid/chrome/useGridRowContextMenu.d.ts +4 -2
  192. package/dist/grid/chrome/useGridRowContextMenu.js +28 -2
  193. package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -1
  194. package/dist/grid/chrome/useGridScaleStyles.js +6 -7
  195. package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
  196. package/dist/grid/chrome/useGridScrollArea.js +65 -0
  197. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +28 -5
  198. package/dist/grid/chrome/useGridTableInteractionModel.js +66 -14
  199. package/dist/grid/chrome/useHeaderDragReorder.d.ts +2 -2
  200. package/dist/grid/core/clipboard-model.d.ts +2 -0
  201. package/dist/grid/core/clipboard-model.js +1 -1
  202. package/dist/grid/core/commit-model.d.ts +7 -0
  203. package/dist/grid/core/edge-scroll.d.ts +21 -0
  204. package/dist/grid/core/edge-scroll.js +23 -0
  205. package/dist/grid/core/editing-controller.d.ts +2 -1
  206. package/dist/grid/core/editing-controller.js +35 -9
  207. package/dist/grid/core/editing-model.d.ts +9 -0
  208. package/dist/grid/core/editing-model.js +12 -0
  209. package/dist/grid/core/flat-rows.d.ts +35 -0
  210. package/dist/grid/core/flat-rows.js +20 -0
  211. package/dist/grid/core/grid-aria.d.ts +27 -0
  212. package/dist/grid/core/grid-aria.js +39 -0
  213. package/dist/grid/core/grid-focus.d.ts +54 -0
  214. package/dist/grid/core/grid-focus.js +148 -0
  215. package/dist/grid/core/nav.d.ts +2 -2
  216. package/dist/grid/core/pending-reconciliation.d.ts +3 -0
  217. package/dist/grid/core/pending-reconciliation.js +5 -3
  218. package/dist/grid/core/row-window.d.ts +40 -0
  219. package/dist/grid/core/row-window.js +43 -0
  220. package/dist/grid/core/spreadsheet-operations.d.ts +17 -1
  221. package/dist/grid/core/spreadsheet-operations.js +33 -6
  222. package/dist/grid/core/useGridEditing.d.ts +3 -0
  223. package/dist/grid/core/useGridEditing.js +6 -3
  224. package/dist/grid/core/value-equality.d.ts +23 -1
  225. package/dist/grid/core/value-equality.js +46 -0
  226. package/dist/grid/useGridTablePrefs.d.ts +0 -1
  227. package/dist/grid/useGridTablePrefs.js +1 -3
  228. package/dist/index.d.ts +1 -0
  229. package/dist/index.js +1 -0
  230. package/dist/internal/viewport.d.ts +0 -2
  231. package/dist/internal/viewport.js +0 -14
  232. package/dist/model/column-capabilities.d.ts +2 -1
  233. package/dist/model/column-capabilities.js +28 -8
  234. package/dist/model/column-from.js +3 -0
  235. package/dist/model/column-inspect.d.ts +10 -2
  236. package/dist/model/column-inspect.js +9 -0
  237. package/dist/model/column-schema.d.ts +6 -1
  238. package/dist/model/column-types.d.ts +3 -1
  239. package/dist/model/column-types.js +1 -1
  240. package/dist/model/preferences.d.ts +0 -4
  241. package/dist/model/preferences.js +0 -1
  242. package/dist/model/prefs-buckets.d.ts +0 -1
  243. package/dist/model/prefs-buckets.js +0 -3
  244. package/dist/model/render-count.d.ts +6 -0
  245. package/dist/model/render-count.js +11 -0
  246. package/dist/provider/ViewsProvider.d.ts +5 -1
  247. package/dist/provider/ViewsProvider.js +9 -3
  248. package/dist/provider/components.d.ts +19 -1
  249. package/dist/provider/components.js +4 -2
  250. package/dist/provider/context.d.ts +5 -2
  251. package/dist/provider/desktop.d.ts +9 -0
  252. package/dist/provider/desktop.js +22 -0
  253. package/dist/provider/plain-input.d.ts +8 -0
  254. package/dist/provider/plain-input.js +5 -0
  255. package/dist/react.d.ts +2 -1
  256. package/dist/react.js +1 -0
  257. package/dist/selection/SelectCheckbox.d.ts +3 -1
  258. package/dist/selection/SelectCheckbox.js +2 -2
  259. package/dist/selection/useCheckDragSelect.js +6 -5
  260. package/docs/contract.md +93 -35
  261. package/docs/guides/atoms.md +1 -1
  262. package/docs/guides/cells.md +2 -2
  263. package/docs/guides/columns.md +3 -2
  264. package/docs/guides/display.md +1 -0
  265. package/docs/guides/editors.md +71 -13
  266. package/docs/guides/the-grid.md +32 -13
  267. package/docs/guides/the-provider.md +3 -1
  268. package/docs/index.md +3 -1
  269. package/docs/install.md +1 -1
  270. package/docs/reference/cells.md +1 -1
  271. package/docs/reference/display.md +3 -1
  272. package/docs/reference/editors-chips.md +2 -2
  273. package/docs/reference/editors-date.md +3 -3
  274. package/docs/reference/editors-location.md +1 -1
  275. package/docs/reference/editors-number.md +1 -1
  276. package/docs/reference/editors-open-values.md +1 -0
  277. package/docs/reference/editors-panel.md +12 -0
  278. package/docs/reference/editors-range.md +1 -1
  279. package/docs/reference/editors-relation.md +6 -3
  280. package/docs/reference/editors-select.md +3 -2
  281. package/docs/reference/editors-session.md +4 -2
  282. package/docs/reference/editors-text.md +9 -0
  283. package/docs/reference/editors-value-list.md +1 -1
  284. package/docs/reference/editors.md +2 -2
  285. package/docs/reference/field-row.md +16 -0
  286. package/docs/reference/grid.md +3 -3
  287. package/docs/reference/react.md +8 -5
  288. package/docs/reference/views.md +36 -15
  289. package/package.json +23 -4
  290. package/skills/views/SKILL.md +4 -4
  291. package/dist/grid/chrome/useGridScrollSync.d.ts +0 -38
  292. package/dist/grid/chrome/useGridScrollSync.js +0 -176
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
- import { ROW_INTERACTIVE_SELECTOR } from "../../selection/row-click.js";
3
+ import { gridControlAt } from "./grid-cell-link.js";
4
+ import { findGridScrollOwner, gridDragScrollStep, gridHitAtPoint, gridVisibleBox } from "./grid-scroll-owner.js";
4
5
  const MOUSE_DRAG_SELECT = false;
5
6
  function setBodySelectionDisabled(disabled) {
6
7
  document.body.style.userSelect = disabled ? "none" : "";
@@ -33,6 +34,9 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
33
34
  const fillDragRef = useRef(false);
34
35
  const [fillTargetRow, setFillTargetRow] = useState(null);
35
36
  const fillTargetRef = useRef(null);
37
+ const pointerRef = useRef(null);
38
+ const ownerRef = useRef(null);
39
+ const frameRef = useRef(null);
36
40
  const handleRootPointerDown = (event) => {
37
41
  if (event.button !== 0 || event.pointerType !== "mouse")
38
42
  return;
@@ -42,12 +46,14 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
42
46
  if (editingEnabled && target.closest("[data-fill-dot]")) {
43
47
  event.preventDefault();
44
48
  fillDragRef.current = true;
49
+ pointerRef.current = { x: event.clientX, y: event.clientY };
50
+ ownerRef.current = findGridScrollOwner(target);
45
51
  setBodySelectionDisabled(true);
46
52
  return;
47
53
  }
48
54
  if (!MOUSE_DRAG_SELECT)
49
55
  return;
50
- if (target.closest(ROW_INTERACTIVE_SELECTOR) || target.closest("[data-action-menu]"))
56
+ if (gridControlAt(target) || target.closest("[data-action-menu]"))
51
57
  return;
52
58
  const cell = target.closest("[data-col-id]");
53
59
  const row = target.closest("[data-row-id]");
@@ -62,6 +68,8 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
62
68
  extend: event.shiftKey,
63
69
  active: false,
64
70
  };
71
+ pointerRef.current = { x: event.clientX, y: event.clientY };
72
+ ownerRef.current = findGridScrollOwner(target);
65
73
  };
66
74
  const handleRootClickCapture = (event) => {
67
75
  if (!didCellDragRef.current)
@@ -71,17 +79,56 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
71
79
  event.stopPropagation();
72
80
  };
73
81
  useEffect(() => {
74
- const onMove = (event) => {
82
+ const dragging = () => fillDragRef.current || !!cellDragRef.current?.active;
83
+ const retarget = () => {
84
+ const root = rootRef.current;
85
+ const owner = ownerRef.current;
86
+ const point = pointerRef.current;
87
+ if (!root || !owner || !point)
88
+ return;
89
+ const hit = gridHitAtPoint(root, point.x, point.y, gridVisibleBox(root, owner));
90
+ if (!hit)
91
+ return;
75
92
  if (fillDragRef.current) {
76
- const element = document.elementFromPoint(event.clientX, event.clientY);
77
- const row = element?.closest?.("[data-row-id]");
78
- if (row && rootRef.current?.contains(row)) {
79
- const rowId = row.getAttribute("data-row-id");
80
- if (rowId !== fillTargetRef.current) {
81
- fillTargetRef.current = rowId;
82
- setFillTargetRow(rowId);
83
- }
93
+ if (hit.rowId !== fillTargetRef.current) {
94
+ fillTargetRef.current = hit.rowId;
95
+ setFillTargetRow(hit.rowId);
84
96
  }
97
+ }
98
+ else if (cellDragRef.current?.active && hit.columnId) {
99
+ rangeExtendTo({ rowId: hit.rowId, columnId: hit.columnId });
100
+ }
101
+ };
102
+ const tick = () => {
103
+ frameRef.current = null;
104
+ const root = rootRef.current;
105
+ const owner = ownerRef.current;
106
+ const point = pointerRef.current;
107
+ if (!root || !owner || !point || !dragging())
108
+ return;
109
+ const step = gridDragScrollStep(root, owner, point.y);
110
+ if (step !== 0) {
111
+ owner.scrollTop += step;
112
+ retarget();
113
+ }
114
+ frameRef.current = requestAnimationFrame(tick);
115
+ };
116
+ const follow = (event) => {
117
+ pointerRef.current = { x: event.clientX, y: event.clientY };
118
+ retarget();
119
+ if (frameRef.current == null)
120
+ frameRef.current = requestAnimationFrame(tick);
121
+ };
122
+ const stopEdgeScroll = () => {
123
+ if (frameRef.current != null)
124
+ cancelAnimationFrame(frameRef.current);
125
+ frameRef.current = null;
126
+ pointerRef.current = null;
127
+ ownerRef.current = null;
128
+ };
129
+ const onMove = (event) => {
130
+ if (fillDragRef.current) {
131
+ follow(event);
85
132
  return;
86
133
  }
87
134
  const drag = cellDragRef.current;
@@ -105,17 +152,10 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
105
152
  focusCell(start.rowId, start.columnId);
106
153
  }
107
154
  }
108
- const element = document.elementFromPoint(event.clientX, event.clientY);
109
- const cell = element?.closest?.("[data-col-id]");
110
- const row = element?.closest?.("[data-row-id]");
111
- if (cell && row && rootRef.current?.contains(row)) {
112
- rangeExtendTo({
113
- rowId: row.getAttribute("data-row-id"),
114
- columnId: cell.getAttribute("data-col-id"),
115
- });
116
- }
155
+ follow(event);
117
156
  };
118
157
  const onUp = () => {
158
+ stopEdgeScroll();
119
159
  if (fillDragRef.current) {
120
160
  fillDragRef.current = false;
121
161
  setBodySelectionDisabled(false);
@@ -137,9 +177,15 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
137
177
  };
138
178
  window.addEventListener("pointermove", onMove);
139
179
  window.addEventListener("pointerup", onUp);
180
+ if (dragging() && pointerRef.current && frameRef.current == null) {
181
+ frameRef.current = requestAnimationFrame(tick);
182
+ }
140
183
  return () => {
141
184
  window.removeEventListener("pointermove", onMove);
142
185
  window.removeEventListener("pointerup", onUp);
186
+ if (frameRef.current != null)
187
+ cancelAnimationFrame(frameRef.current);
188
+ frameRef.current = null;
143
189
  };
144
190
  }, [finishFillRef, focusCell, rangeBeginDrag, rangeExtendTo, rootRef]);
145
191
  const editingRef = useRef(editingCell);
@@ -149,6 +195,7 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
149
195
  const treePressRef = useRef(null);
150
196
  const handleRootPointerDownCapture = (event) => {
151
197
  treePressRef.current = event.nativeEvent;
198
+ didCellDragRef.current = false;
152
199
  };
153
200
  useEffect(() => {
154
201
  if (!focusedCell)
@@ -164,7 +211,7 @@ export function useGridRangeGestures({ rootRef, focusedCell, editingCell, editin
164
211
  if (rootRef.current?.contains(target)) {
165
212
  if (target.closest?.("[data-col-id]"))
166
213
  return;
167
- if (target.dataset?.gridScroller != null && onScrollbar(target, event))
214
+ if (target.dataset?.slot === "vk-grid-scroll" && onScrollbar(target, event))
168
215
  return;
169
216
  }
170
217
  if (editingRef.current) {
@@ -1,7 +1,7 @@
1
1
  import type { ViewsRowMenuItem } from "../../atoms/types.js";
2
- import type { ListColumn } from "../../model/column-schema.js";
2
+ import type { ListCellAction, ListColumn } from "../../model/column-schema.js";
3
3
  import type { GridRowRangeSpan } from "../core/useGridRange.js";
4
- export declare function useGridRowContextMenu<Row>({ row, id, rowKey, columns, selecting, selectable, selected, toggle, editingEnabled, pendingByCol, selectValues, rowRange, contextMenu, inActiveRange, rangeCanClear, onRangeCopy, onRangeCut, onRangePaste, onRangeClear, onPasteAtCell, onCommitCell, onFocusCell, }: {
4
+ export declare function useGridRowContextMenu<Row>({ row, id, rowKey, columns, rowActions, selecting, selectable, selected, toggle, editingEnabled, pendingByCol, selectValues, rowRange, contextMenu, inActiveRange, rangeCanClear, onRangeCopy, onRangeCut, onRangePaste, onRangeClear, onPasteAtCell, onCommitCell, onFocusCell, }: {
5
5
  row: Row;
6
6
  /** The DATA id — what a commit and the selection toggle address. */
7
7
  id: string;
@@ -9,6 +9,8 @@ export declare function useGridRowContextMenu<Row>({ row, id, rowKey, columns, s
9
9
  * target) is in terms of. See `GridCellPos`. */
10
10
  rowKey: string;
11
11
  columns: ListColumn<Row>[];
12
+ /** The name's actions, the title's lane: each that applies to the row is a row of its menu. */
13
+ rowActions?: ListCellAction<Row>[];
12
14
  selecting: boolean;
13
15
  selectable: boolean;
14
16
  selected: boolean;
@@ -4,7 +4,26 @@ import { useState } from "react";
4
4
  import { useViews } from "../../provider/context.js";
5
5
  import { gridColumnHasEditor } from "../../model/column-capabilities.js";
6
6
  import { cellClearPrev, cellEditBaseline, cellPrevPayload, coercePaste, copyCell, getGridClipboard, rowHoldsCurrency, } from "./cell-clipboard.js";
7
- export function useGridRowContextMenu({ row, id, rowKey, columns, selecting, selectable, selected, toggle, editingEnabled, pendingByCol, selectValues, rowRange, contextMenu, inActiveRange, rangeCanClear, onRangeCopy, onRangeCut, onRangePaste, onRangeClear, onPasteAtCell, onCommitCell, onFocusCell, }) {
7
+ function nameActionItems(row, actions, hostItems) {
8
+ if (!actions?.length)
9
+ return [];
10
+ const listed = new Set(hostItems.flatMap((item) => (item.separator ? [] : [item.label])));
11
+ const items = [];
12
+ for (const action of actions) {
13
+ if (!action.onClick)
14
+ continue;
15
+ const label = action.label?.(row);
16
+ if (!label || listed.has(label))
17
+ continue;
18
+ const icon = action.icon(row);
19
+ if (!icon)
20
+ continue;
21
+ const run = action.onClick;
22
+ items.push({ label, icon, onClick: () => run(row) });
23
+ }
24
+ return items.length > 0 ? [...items, { separator: true }] : [];
25
+ }
26
+ export function useGridRowContextMenu({ row, id, rowKey, columns, rowActions, selecting, selectable, selected, toggle, editingEnabled, pendingByCol, selectValues, rowRange, contextMenu, inActiveRange, rangeCanClear, onRangeCopy, onRangeCut, onRangePaste, onRangeClear, onPasteAtCell, onCommitCell, onFocusCell, }) {
8
27
  const { conventions, ports, messages, icons } = useViews();
9
28
  const copyLabel = messages({ key: "views.menus.copy" });
10
29
  const cutLabel = messages({ key: "views.menus.cut" });
@@ -60,6 +79,7 @@ export function useGridRowContextMenu({ row, id, rowKey, columns, selecting, sel
60
79
  currentUnit: unit,
61
80
  holdsCurrency: rowHoldsCurrency(menuColumn, row),
62
81
  values: selectValues?.[menuColumn.id],
82
+ region: menuColumn.region?.(row),
63
83
  })
64
84
  : null;
65
85
  cellItems.push({
@@ -110,7 +130,13 @@ export function useGridRowContextMenu({ row, id, rowKey, columns, selecting, sel
110
130
  { separator: true },
111
131
  ]
112
132
  : [];
113
- const contextItems = [...cellItems, ...selectItems, ...(contextMenu?.(row) ?? [])];
133
+ const hostItems = contextMenu?.(row) ?? [];
134
+ const contextItems = [
135
+ ...cellItems,
136
+ ...selectItems,
137
+ ...nameActionItems(row, rowActions, hostItems),
138
+ ...hostItems,
139
+ ];
114
140
  const handleContextMenu = (event) => {
115
141
  const target = event.target;
116
142
  const columnId = target.closest("[data-col-id]")?.getAttribute("data-col-id");
@@ -1 +1,3 @@
1
- export declare function useGridScaleStyles(scale: number, grouped: boolean, isMobile: boolean, addColumn?: boolean): import("react").CSSProperties;
1
+ /** One row's height at scale 1, in px: `--vk-row-h` is built from it, and the row window counts rows by it. */
2
+ export declare const GRID_ROW_PX = 37;
3
+ export declare function useGridScaleStyles(scale: number, grouped: boolean, phone: boolean, addColumn?: boolean): import("react").CSSProperties;
@@ -1,13 +1,12 @@
1
1
  "use client";
2
2
  import { useMemo } from "react";
3
- export function useGridScaleStyles(scale, grouped, isMobile, addColumn = false) {
3
+ export const GRID_ROW_PX = 37;
4
+ export function useGridScaleStyles(scale, grouped, phone, addColumn = false) {
4
5
  return useMemo(() => ({
5
6
  "--vk-scale": String(scale),
6
- "--vk-indent": isMobile ? "0px" : "24px",
7
- "--vk-row-h": "calc(37px * var(--vk-scale))",
7
+ "--vk-indent": phone ? "0px" : "24px",
8
+ "--vk-row-h": `calc(${GRID_ROW_PX}px * var(--vk-scale))`,
8
9
  "--vk-line-h": "calc(22px * var(--vk-scale))",
9
- "--vk-cell-py": "calc((var(--vk-row-h) - var(--vk-line-h) - 1px) / 2)",
10
- "--vk-tail-py": "max(0px, calc((var(--vk-row-h) - 2rem - 1px) / 2))",
11
10
  "--vk-head-h": "calc(32px * var(--vk-scale))",
12
11
  "--vk-head-text": "calc(12px * var(--vk-scale))",
13
12
  "--vk-head-glyph": "calc(12px * var(--vk-scale))",
@@ -24,6 +23,6 @@ export function useGridScaleStyles(scale, grouped, isMobile, addColumn = false)
24
23
  ? "max(0px, calc(var(--vk-px) + var(--vk-head-glyph) / 2 - 18px))"
25
24
  : "var(--vk-px)",
26
25
  "--vk-glyph": "calc(14px * var(--vk-scale))",
27
- "--vk-scroll-mt": `calc(${grouped ? "var(--vk-label-h) + 6px" : "0px"} + ${isMobile ? "0px" : "var(--vk-head-h)"} + 4px)`,
28
- }), [addColumn, grouped, isMobile, scale]);
26
+ "--vk-scroll-mt": `calc(${grouped ? "var(--vk-label-h) + 6px" : "0px"} + var(--vk-head-h) + 4px)`,
27
+ }), [addColumn, grouped, phone, scale]);
29
28
  }
@@ -0,0 +1,21 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * The grid's one scroll area, and what the rest of the grid reads off it.
4
+ *
5
+ * The whole table, headers and rows of every group, scrolls in ONE native element, both ways. Every
6
+ * browser engine scrolls off the main thread, so a position script copies from one scroller to
7
+ * another lands at least a frame late; here nothing is copied. The headers pin and the frozen
8
+ * columns stick because they sit in the same scrollport as the rows, and the browser moves them all
9
+ * at once.
10
+ *
11
+ * What script still does is paint bookkeeping, never position: one passive listener writes two 0/1
12
+ * flags on the frame, and only when one flips. `--vk-scrolled` is "has the table moved sideways at
13
+ * all"; `--vk-parked` is "has the leading chrome (the checkbox rail, the frozen block) reached its
14
+ * stop", which happens `parkAt` px later (measured below). It also keeps `scrollXRef` at the area's
15
+ * x, which the header's column drag folds into its shift.
16
+ */
17
+ export declare function useGridScrollArea(rootRef: RefObject<HTMLDivElement | null>): {
18
+ areaRef: (element: HTMLDivElement | null) => (() => void) | undefined;
19
+ scrollXRef: RefObject<number>;
20
+ getScroller: () => HTMLElement | undefined;
21
+ };
@@ -0,0 +1,65 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef } from "react";
3
+ export function useGridScrollArea(rootRef) {
4
+ const areaElRef = useRef(null);
5
+ const scrollXRef = useRef(0);
6
+ const parkAtRef = useRef(0);
7
+ const flagsRef = useRef({ scrolled: "", parked: "" });
8
+ const writeFlags = useCallback((x) => {
9
+ const root = rootRef.current;
10
+ if (!root)
11
+ return;
12
+ const scrolled = x > 0 ? "1" : "0";
13
+ const parked = x > 0 && x >= parkAtRef.current ? "1" : "0";
14
+ if (flagsRef.current.scrolled !== scrolled) {
15
+ flagsRef.current.scrolled = scrolled;
16
+ root.style.setProperty("--vk-scrolled", scrolled);
17
+ }
18
+ if (flagsRef.current.parked !== parked) {
19
+ flagsRef.current.parked = parked;
20
+ root.style.setProperty("--vk-parked", parked);
21
+ }
22
+ }, [rootRef]);
23
+ useEffect(() => {
24
+ const root = rootRef.current;
25
+ if (!root)
26
+ return;
27
+ const probe = document.createElement("div");
28
+ probe.setAttribute("aria-hidden", "true");
29
+ probe.style.cssText =
30
+ "position:absolute;top:0;left:0;height:0;visibility:hidden;pointer-events:none;" +
31
+ "width:calc(var(--vk-gutter,0px) + var(--vk-indent,0px) - var(--vk-rail-w))";
32
+ root.appendChild(probe);
33
+ const read = () => {
34
+ parkAtRef.current = probe.offsetWidth;
35
+ writeFlags(scrollXRef.current);
36
+ };
37
+ read();
38
+ if (typeof ResizeObserver === "undefined")
39
+ return () => probe.remove();
40
+ const observer = new ResizeObserver(read);
41
+ observer.observe(probe);
42
+ return () => {
43
+ observer.disconnect();
44
+ probe.remove();
45
+ };
46
+ }, [rootRef, writeFlags]);
47
+ const areaRef = useCallback((element) => {
48
+ areaElRef.current = element;
49
+ if (!element)
50
+ return;
51
+ const onScroll = () => {
52
+ const x = element.scrollLeft;
53
+ scrollXRef.current = x;
54
+ writeFlags(x);
55
+ };
56
+ element.addEventListener("scroll", onScroll, { passive: true });
57
+ return () => {
58
+ element.removeEventListener("scroll", onScroll);
59
+ if (areaElRef.current === element)
60
+ areaElRef.current = null;
61
+ };
62
+ }, [writeFlags]);
63
+ const getScroller = useCallback(() => areaElRef.current ?? undefined, []);
64
+ return { areaRef, scrollXRef, getScroller };
65
+ }
@@ -1,13 +1,24 @@
1
1
  import { type RefObject } from "react";
2
2
  import { type GridEditCell } from "../core/useGridEditing.js";
3
3
  import type { ListColumn } from "../../model/column-schema.js";
4
+ import { type GridCellPos } from "../core/coordinates.js";
4
5
  import type { GridTableProps } from "./grid-table-props.js";
5
- export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows, visibleRows, rowIndex, visibleColumns, selecting, }: {
6
+ import { type GridFocusShape } from "../core/grid-focus.js";
7
+ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }: {
8
+ /** What the keyboard walks beyond the data cells (`core/grid-focus.ts`): the sections, their footers and menus,
9
+ * the checkbox lane. None: the keys stay on the data cells. */
10
+ focusShape?: GridFocusShape;
11
+ /** The section a row KEY is drawn in, a shut one's included: a collapse sends that row's focus to its bar. */
12
+ groupOfRow?: (rowKey: string) => string | undefined;
6
13
  rootRef: RefObject<HTMLDivElement | null>;
7
14
  props: GridTableProps<Row>;
8
15
  rows: Row[];
9
- /** Row KEYS in render order — positions, not records. See `GridCellPos`. */
16
+ /** Row KEYS of the open groups in render order — positions, not records (see `GridCellPos`): the keyboard's, the
17
+ * range's, the spreadsheet's and the fill's order, so each skips a shut group's rows. */
10
18
  visibleRows: string[];
19
+ /** Row KEYS the page holds, a shut group's included: what an open edit is checked against, so collapsing a group
20
+ * never cancels an edit in it. Default: `visibleRows`, a list with no shut group. */
21
+ heldRows?: string[];
11
22
  /** Row key → the rendered row and its DATA id. */
12
23
  rowIndex: ReadonlyMap<string, {
13
24
  key: string;
@@ -16,9 +27,20 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
16
27
  }>;
17
28
  visibleColumns: ListColumn<Row>[];
18
29
  selecting: boolean;
30
+ /** Bring a row the page doesn't hold into view, by its row KEY and the column to show: the table's row window,
31
+ * since only the rows on screen are drawn. The one reveal (`revealGridCell`) calls it for a row it can't find in the page. */
32
+ revealRow?: (rowKey: string, columnId?: string) => void;
19
33
  }): {
34
+ focus: {
35
+ chrome: import("../core/grid-focus.js").GridChromeTarget | null;
36
+ setChrome: (target: import("../core/grid-focus.js").GridChromeTarget | null) => void;
37
+ target: import("../core/grid-focus.js").GridFocusTarget | null;
38
+ releaseToFrame: () => void;
39
+ lastCellRef: RefObject<GridCellPos | null>;
40
+ };
20
41
  onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
21
42
  onEditorEnter: (rowId: string, columnId: string) => void;
43
+ enterGrid: (_which: "start" | "end", from: Element | null) => void;
22
44
  visibleColIds: string[];
23
45
  rowSpansMap: Map<string, import("../core/range-model.js").GridRowRangeSpan[]>;
24
46
  selectValuesByColumn: Record<string, string[]>;
@@ -32,13 +54,14 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
32
54
  rangeCanClear: () => boolean;
33
55
  rangeVerbsRef: RefObject<import("./useGridRangeActions.js").GridRangeVerbs | null>;
34
56
  editingEnabled: boolean;
35
- focusedCell: import("../core/coordinates.js").GridCellPos | null;
36
- editingCell: import("../core/coordinates.js").GridCellPos | null;
57
+ focusedCell: GridCellPos | null;
58
+ editingCell: GridCellPos | null;
37
59
  pendingByRow: ReadonlyMap<string, Record<string, unknown>>;
38
60
  settlementByRow: import("../core/editing-model.js").GridSettlementByRow;
39
61
  editSeed: string | null;
62
+ editWhole: boolean;
40
63
  focusCellSync: (rowId: string, columnId: string) => void;
41
- startEditSync: (rowId: string, columnId: string, seed?: string) => void;
64
+ startEditSync: (rowId: string, columnId: string, seed?: string | null, whole?: boolean) => void;
42
65
  cancelEdit: (rowId?: string, columnId?: string) => void;
43
66
  commitEdit: (row: Row, rowId: string, columnId: string, prev: unknown, next: unknown, opts?: {
44
67
  overlay?: boolean;
@@ -3,30 +3,41 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { useViews } from "../../provider/context.js";
4
4
  import { useGridEditing } from "../core/useGridEditing.js";
5
5
  import { useGridRange } from "../core/useGridRange.js";
6
- import { columnEffectiveWritable, gridEditRefusal, gridNormalizeWrite, } from "../../model/column-capabilities.js";
6
+ import { columnEffectiveWritable, gridColumnLocked, gridEditRefusal, gridNormalizeWrite, } from "../../model/column-capabilities.js";
7
7
  import { gridRowIdFromKey } from "../core/coordinates.js";
8
+ import { revealGridCell } from "./grid-scroll-owner.js";
9
+ import { useGridFocus } from "./useGridFocus.js";
10
+ import { gridBarOf } from "../core/grid-focus.js";
8
11
  import { useGridKeyboard } from "./useGridKeyboard.js";
9
12
  import { useGridPendingReconciliation } from "./useGridPendingReconciliation.js";
10
13
  import { useGridRangeActions } from "./useGridRangeActions.js";
11
14
  import { useGridRangeGestures } from "./useGridRangeGestures.js";
12
15
  const REFUSAL_REPEAT_MS = 600;
13
- export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows, rowIndex, visibleColumns, selecting, }) {
16
+ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }) {
14
17
  const { columns, getRowId, listConfig } = props;
15
18
  const { conventions, ports, messages } = useViews();
16
19
  const editingEnabled = !!props.onCellCommit;
17
- const { focused: focusedCell, editing: editingCell, pendingByRow, settlementByRow, focusCell, clearFocus, startEdit, cancelEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, } = useGridEditing(props.onCellCommit, props.onCellsCommit);
20
+ const { focused: focusedCell, editing: editingCell, pendingByRow, settlementByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, } = useGridEditing(props.onCellCommit, props.onCellsCommit);
21
+ const lockedRefusal = useCallback((col) => gridColumnLocked(col, listConfig) ? gridEditRefusal(col, listConfig, conventions, messages) : undefined, [listConfig, conventions, messages]);
18
22
  const commitEdit = useCallback((row, rowId, columnId, prev, next, opts) => {
19
23
  const col = visibleColumns.find((c) => c.id === columnId);
20
24
  if (col) {
21
- const res = gridNormalizeWrite(col, next, conventions, { messages, stored: prev });
25
+ const locked = lockedRefusal(col);
26
+ if (locked) {
27
+ ports.toast.error(locked);
28
+ closeEdit(rowId, columnId);
29
+ return;
30
+ }
31
+ const res = gridNormalizeWrite(col, next, conventions, { messages, stored: prev, region: col.region?.(row) });
22
32
  if (!res.ok) {
23
33
  ports.toast.error(res.reason);
34
+ closeEdit(rowId, columnId);
24
35
  return;
25
36
  }
26
37
  next = res.value;
27
38
  }
28
39
  commitEditRaw(row, rowId, columnId, prev, next, opts);
29
- }, [visibleColumns, commitEditRaw, conventions, messages, ports]);
40
+ }, [visibleColumns, commitEditRaw, closeEdit, conventions, messages, ports, lockedRefusal]);
30
41
  const commitBatch = useCallback((edits) => {
31
42
  const colById = new Map(visibleColumns.map((c) => [c.id, c]));
32
43
  const kept = [];
@@ -37,7 +48,16 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
37
48
  kept.push(edit);
38
49
  continue;
39
50
  }
40
- const res = gridNormalizeWrite(col, edit.next, conventions, { messages, stored: edit.prev });
51
+ const locked = lockedRefusal(col);
52
+ if (locked) {
53
+ firstRefusal ??= locked;
54
+ continue;
55
+ }
56
+ const res = gridNormalizeWrite(col, edit.next, conventions, {
57
+ messages,
58
+ stored: edit.prev,
59
+ region: col.region?.(edit.row),
60
+ });
41
61
  if (!res.ok) {
42
62
  firstRefusal ??= res.reason;
43
63
  continue;
@@ -50,7 +70,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
50
70
  return Promise.resolve(true);
51
71
  }
52
72
  return commitBatchRaw(kept);
53
- }, [visibleColumns, commitBatchRaw, conventions, messages, ports]);
73
+ }, [visibleColumns, commitBatchRaw, conventions, messages, ports, lockedRefusal]);
54
74
  const lastRefusalRef = useRef(null);
55
75
  const refuseEdit = useCallback((columnId) => {
56
76
  if (!editingEnabled)
@@ -71,12 +91,14 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
71
91
  }, [editingEnabled, visibleColumns, listConfig, conventions, messages, ports]);
72
92
  const { ranges, setSingle: rangeSetSingle, setRect: rangeSetRect, beginDrag: rangeBeginDrag, extendTo: rangeExtendTo, addCell: rangeAddCell, clear: rangeClear, } = useGridRange();
73
93
  const [editSeed, setEditSeed] = useState(null);
94
+ const [editWhole, setEditWhole] = useState(false);
74
95
  const focusCellSync = useCallback((rowId, columnId) => {
75
96
  focusCell(rowId, columnId);
76
97
  rangeSetSingle({ rowId, columnId });
77
98
  }, [focusCell, rangeSetSingle]);
78
- const startEditSync = useCallback((rowId, columnId, seed) => {
99
+ const startEditSync = useCallback((rowId, columnId, seed, whole) => {
79
100
  setEditSeed(seed ?? null);
101
+ setEditWhole(!!whole);
80
102
  startEdit(rowId, columnId);
81
103
  rangeSetSingle({ rowId, columnId });
82
104
  }, [startEdit, rangeSetSingle]);
@@ -84,12 +106,16 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
84
106
  clearFocus();
85
107
  rangeClear();
86
108
  }, [clearFocus, rangeClear]);
109
+ const focus = useGridFocus({ rootRef, focusedCell, editingCell });
110
+ const setChrome = focus.setChrome;
87
111
  useEffect(() => {
88
112
  if (!focusedCell && !editingCell)
89
113
  return;
90
114
  const visible = new Set(visibleRows);
91
- const staleEdit = editingCell != null && !visible.has(editingCell.rowId);
92
- const staleFocus = focusedCell != null && !visible.has(focusedCell.rowId);
115
+ const held = heldRows ? new Set(heldRows) : visible;
116
+ const staleEdit = editingCell != null && !held.has(editingCell.rowId);
117
+ const focusKeptByEdit = focusedCell != null && editingCell?.rowId === focusedCell.rowId;
118
+ const staleFocus = focusedCell != null && !(focusKeptByEdit ? held : visible).has(focusedCell.rowId);
93
119
  if (!staleEdit && !staleFocus)
94
120
  return;
95
121
  const editedRowId = editingCell != null
@@ -98,14 +124,31 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
98
124
  const editedRowGone = editingCell != null && !rows.some((row) => getRowId(row) === editedRowId);
99
125
  if (staleEdit)
100
126
  cancelEdit();
101
- if (staleFocus)
127
+ if (staleFocus) {
102
128
  clearFocusSync();
129
+ const shutGroup = focusedCell && held.has(focusedCell.rowId) ? groupOfRow?.(focusedCell.rowId) : undefined;
130
+ const root = rootRef.current;
131
+ const active = document.activeElement;
132
+ const inGrid = active == null || active === document.body || (root?.contains(active) ?? false);
133
+ if (shutGroup != null && inGrid)
134
+ setChrome(gridBarOf(shutGroup));
135
+ }
103
136
  if (staleEdit && editedRowGone) {
104
137
  ports.toast.error(messages({ key: "views.grid.row-left" }));
105
138
  }
106
- }, [cancelEdit, clearFocusSync, editingCell, focusedCell, getRowId, messages, ports, rowIndex, rows, visibleRows]);
139
+ }, [cancelEdit, clearFocusSync, editingCell, focusedCell, getRowId, groupOfRow, heldRows, messages, ports, rootRef, rowIndex, rows, setChrome, visibleRows]);
107
140
  const visibleColumnIds = useMemo(() => visibleColumns.map((column) => column.id), [visibleColumns]);
108
- const spreadsheetModel = useMemo(() => ({ rows, rowByKey: rowIndex, visibleRowIds: visibleRows, visibleColumns, pendingByRow, conventions, messages }), [rows, rowIndex, visibleRows, visibleColumns, pendingByRow, conventions, messages]);
141
+ const spreadsheetModel = useMemo(() => ({
142
+ rows,
143
+ rowByKey: rowIndex,
144
+ visibleRowIds: visibleRows,
145
+ visibleColumns,
146
+ pendingByRow,
147
+ conventions,
148
+ messages,
149
+ listConfig,
150
+ }), [rows, rowIndex, visibleRows, visibleColumns, pendingByRow, conventions, messages, listConfig]);
151
+ const revealCell = useCallback((pos, behavior) => revealGridCell(rootRef.current, pos, behavior, revealRow), [revealRow, rootRef]);
109
152
  const finishFillRef = useRef(() => { });
110
153
  const { fillTargetRow, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, } = useGridRangeGestures({
111
154
  rootRef,
@@ -133,11 +176,18 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
133
176
  focusCell,
134
177
  rangeSetRect,
135
178
  rangeExtendTo,
179
+ revealCell,
136
180
  });
137
181
  useEffect(() => {
138
182
  finishFillRef.current = rangeActions.finishFill;
139
183
  }, [rangeActions.finishFill]);
140
184
  const keyboard = useGridKeyboard({
185
+ releaseToFrame: focus.releaseToFrame,
186
+ lastCellRef: focus.lastCellRef,
187
+ chrome: focus.chrome,
188
+ setChrome: focus.setChrome,
189
+ shape: focusShape,
190
+ toggleGroup: props.onToggleGroup,
141
191
  rootRef,
142
192
  focusedCell,
143
193
  editingCell,
@@ -159,10 +209,10 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
159
209
  refuseEdit,
160
210
  undo,
161
211
  redo,
162
- rangeSetSingle,
163
212
  rangeSetRect,
164
213
  rangeExtendTo,
165
214
  ranges,
215
+ revealCell,
166
216
  });
167
217
  useGridPendingReconciliation({
168
218
  rows,
@@ -180,6 +230,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
180
230
  pendingByRow,
181
231
  settlementByRow,
182
232
  editSeed,
233
+ editWhole,
183
234
  focusCellSync,
184
235
  startEditSync,
185
236
  cancelEdit,
@@ -193,5 +244,6 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
193
244
  handleRootClickCapture,
194
245
  ...rangeActions,
195
246
  ...keyboard,
247
+ focus,
196
248
  };
197
249
  }
@@ -3,9 +3,9 @@ export declare function useHeaderDragReorder({ enabled, ids, scrollXRef, getScro
3
3
  enabled: boolean;
4
4
  /** Visible column ids, in current order. */
5
5
  ids: string[];
6
- /** The scroll sync's current scrollLeft (GridTable's scrollXRef). */
6
+ /** The grid's scroll area's current scrollLeft (GridTable's scrollXRef). */
7
7
  scrollXRef: React.MutableRefObject<number>;
8
- /** Any one synced scroller — autoscroll target (the sync fans it out). */
8
+ /** The grid's scroll area: the edge autoscroll moves it. */
9
9
  getScroller: () => HTMLElement | undefined;
10
10
  /** Optional ownership gate for columns that remain fixed in declaration order. */
11
11
  canDrag?: (id: string) => boolean;
@@ -75,6 +75,8 @@ export declare function coercePaste<Row>(col: ListColumn<Row>, source: GridPaste
75
75
  /** Whether the target row holds a currency of its own (`rowHoldsCurrency`). Absent: it does. */
76
76
  holdsCurrency?: boolean;
77
77
  values?: readonly string[];
78
+ /** The target row's country, where a phone pasted without its country code is read (`ListColumn.region`). */
79
+ region?: string | null;
78
80
  }): GridPasteResult;
79
81
  /** Plain TSV form used for the system clipboard. */
80
82
  export declare function serializeClipboardMatrix(matrix: readonly (readonly GridClipboardCell[])[]): string;
@@ -130,7 +130,7 @@ export function gridPasteOverlay(col) {
130
130
  }
131
131
  export function coercePaste(col, source, opts) {
132
132
  const messages = opts.messages ?? resolveViewsMessage;
133
- const write = { messages };
133
+ const write = { messages, region: opts.region };
134
134
  const empty = { ok: false, reason: messages({ key: "views.grid.paste-empty" }) };
135
135
  const refused = { ok: false, reason: messages({ key: "views.grid.paste-refused" }) };
136
136
  const overlay = gridPasteOverlay(col);