viewkitjs 0.37.0 → 0.39.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 (220) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/MIGRATION.md +7 -0
  3. package/fields/dist/query/figure-kinds.d.ts +2 -2
  4. package/fields/dist/query/figure-kinds.js +3 -0
  5. package/fields/dist/query/figures.d.ts +5 -3
  6. package/fields/dist/query/figures.js +13 -0
  7. package/fields/docs/reference/query.md +3 -3
  8. package/package.json +1 -1
  9. package/postgres/docs/guides/field-map.md +1 -1
  10. package/views/dist/atoms/HeaderChrome.d.ts +7 -0
  11. package/views/dist/atoms/HeaderChrome.js +15 -0
  12. package/views/dist/atoms/ToolbarButton.d.ts +1 -1
  13. package/views/dist/atoms/ToolbarButton.js +2 -2
  14. package/views/dist/atoms/defaults.js +4 -0
  15. package/views/dist/atoms/types.d.ts +39 -2
  16. package/views/dist/contract.d.ts +25 -11
  17. package/views/dist/contract.js +41 -6
  18. package/views/dist/controls/field/looks.d.ts +1 -1
  19. package/views/dist/controls/field/looks.js +9 -3
  20. package/views/dist/controls/field/tokens.d.ts +4 -0
  21. package/views/dist/controls/field/tokens.js +1 -0
  22. package/views/dist/controls/field.css +93 -1
  23. package/views/dist/controls/filter-editor/block.d.ts +3 -1
  24. package/views/dist/controls/filter-editor/block.js +4 -3
  25. package/views/dist/controls/filter-editor/filter-editor.d.ts +13 -2
  26. package/views/dist/controls/filter-editor/filter-editor.js +45 -15
  27. package/views/dist/controls/filter-editor/how.d.ts +3 -1
  28. package/views/dist/controls/filter-editor/map-filter-body.js +5 -4
  29. package/views/dist/controls/filter-editor/map-rules.d.ts +2 -1
  30. package/views/dist/controls/filter-editor/map-rules.js +3 -3
  31. package/views/dist/controls/glyphs/glyphs.js +2 -0
  32. package/views/dist/controls/inline-input.css +3 -2
  33. package/views/dist/controls/internal/menu-items.d.ts +2 -0
  34. package/views/dist/controls/internal/menu-items.js +1 -1
  35. package/views/dist/controls/internal/part-slot.d.ts +1 -1
  36. package/views/dist/controls/internal/part-slot.js +1 -1
  37. package/views/dist/controls/internal/read-token.d.ts +2 -1
  38. package/views/dist/controls/internal/read-token.js +2 -1
  39. package/views/dist/controls/internal/row-actions.d.ts +33 -0
  40. package/views/dist/controls/internal/row-actions.js +28 -0
  41. package/views/dist/controls/menu/map-menu.js +1 -1
  42. package/views/dist/controls/number-editor/tokens.d.ts +8 -0
  43. package/views/dist/controls/number-editor/tokens.js +2 -0
  44. package/views/dist/controls/number-editor.css +20 -0
  45. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  46. package/views/dist/controls/popover/map-popover.js +2 -2
  47. package/views/dist/controls/sheet/map-sheet.js +9 -6
  48. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  49. package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
  50. package/views/dist/controls/sort-editor/sort-editor.js +41 -13
  51. package/views/dist/controls/text-editor/tokens.d.ts +8 -0
  52. package/views/dist/controls/text-editor/tokens.js +2 -0
  53. package/views/dist/controls/text-editor.css +44 -2
  54. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
  55. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
  56. package/views/dist/controls/tooltip/tooltip.js +2 -1
  57. package/views/dist/editors/EditorPanel.js +1 -1
  58. package/views/dist/field-row/FieldRow.js +46 -15
  59. package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
  60. package/views/dist/field-row/editors/RowDateEditor.js +3 -1
  61. package/views/dist/field-row/editors/RowNameEditor.js +3 -1
  62. package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
  63. package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
  64. package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
  65. package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
  66. package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
  67. package/views/dist/field-row/editors/RowTextEditor.js +25 -4
  68. package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
  69. package/views/dist/field-row/editors/row-place.d.ts +33 -0
  70. package/views/dist/field-row/editors/row-place.js +141 -0
  71. package/views/dist/field-row/field-row-button.d.ts +21 -6
  72. package/views/dist/field-row/field-row-button.js +8 -3
  73. package/views/dist/field-row/row-target.d.ts +4 -1
  74. package/views/dist/field-row/row-target.js +1 -1
  75. package/views/dist/fields/binding.d.ts +4 -0
  76. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
  77. package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
  78. package/views/dist/grid/chrome/GridCellEditors.d.ts +1 -1
  79. package/views/dist/grid/chrome/GridCellOutline.d.ts +13 -1
  80. package/views/dist/grid/chrome/GridCellOutline.js +17 -0
  81. package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
  82. package/views/dist/grid/chrome/GridFooter.js +11 -9
  83. package/views/dist/grid/chrome/GridHeader.js +4 -3
  84. package/views/dist/grid/chrome/GridNumberEditor.js +2 -1
  85. package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
  86. package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
  87. package/views/dist/grid/chrome/GridRowCells.js +1 -1
  88. package/views/dist/grid/chrome/GridStructure.js +3 -3
  89. package/views/dist/grid/chrome/GridTable.js +1 -1
  90. package/views/dist/grid/chrome/GridTableSurface.js +1 -1
  91. package/views/dist/grid/chrome/GridTextEditor.js +3 -1
  92. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
  93. package/views/dist/grid/chrome/grid-body-place.js +4 -4
  94. package/views/dist/grid/chrome/grid-edit-session.d.ts +7 -3
  95. package/views/dist/grid/chrome/grid-edit-session.js +12 -3
  96. package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -4
  97. package/views/dist/grid/chrome/grid-figure-value.js +10 -4
  98. package/views/dist/grid/chrome/grid-row-props.d.ts +1 -1
  99. package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
  100. package/views/dist/grid/chrome/useGridKeyboard.d.ts +5 -1
  101. package/views/dist/grid/chrome/useGridKeyboard.js +9 -5
  102. package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
  103. package/views/dist/grid/chrome/useGridTableInteractionModel.js +8 -3
  104. package/views/dist/grid/grid.css +7 -3
  105. package/views/dist/internal/length.d.ts +2 -0
  106. package/views/dist/internal/length.js +16 -0
  107. package/views/dist/internal/over-cell.d.ts +8 -0
  108. package/views/dist/internal/over-cell.js +5 -0
  109. package/views/dist/list/bar-keys.d.ts +5 -0
  110. package/views/dist/list/bar-keys.js +2 -0
  111. package/views/dist/list/bar-parts.d.ts +27 -0
  112. package/views/dist/list/bar-parts.js +38 -0
  113. package/views/dist/list/buttons/clear-save.d.ts +7 -0
  114. package/views/dist/list/buttons/clear-save.js +15 -0
  115. package/views/dist/list/buttons/customize.d.ts +28 -0
  116. package/views/dist/list/buttons/customize.js +31 -0
  117. package/views/dist/list/buttons/filter.d.ts +32 -0
  118. package/views/dist/list/buttons/filter.js +60 -0
  119. package/views/dist/list/buttons/new.d.ts +18 -0
  120. package/views/dist/list/buttons/new.js +9 -0
  121. package/views/dist/list/buttons/quick.d.ts +15 -0
  122. package/views/dist/list/buttons/quick.js +24 -0
  123. package/views/dist/list/buttons/search.d.ts +18 -0
  124. package/views/dist/list/buttons/search.js +17 -0
  125. package/views/dist/list/buttons/shared.d.ts +91 -0
  126. package/views/dist/list/buttons/shared.js +131 -0
  127. package/views/dist/list/buttons/sort-filter.d.ts +6 -0
  128. package/views/dist/list/buttons/sort-filter.js +16 -0
  129. package/views/dist/list/buttons/sort.d.ts +17 -0
  130. package/views/dist/list/buttons/sort.js +34 -0
  131. package/views/dist/list/buttons/views.d.ts +21 -0
  132. package/views/dist/list/buttons/views.js +36 -0
  133. package/views/dist/list/editor-menus.d.ts +13 -0
  134. package/views/dist/list/editor-menus.js +13 -0
  135. package/views/dist/list/index.d.ts +41 -0
  136. package/views/dist/list/index.js +19 -0
  137. package/views/dist/list/line.d.ts +55 -0
  138. package/views/dist/list/line.js +221 -0
  139. package/views/dist/list/pane-box.d.ts +6 -0
  140. package/views/dist/list/pane-box.js +15 -0
  141. package/views/dist/list/panels/customize.d.ts +8 -0
  142. package/views/dist/list/panels/customize.js +23 -0
  143. package/views/dist/list/panels/filter-bar.d.ts +12 -0
  144. package/views/dist/list/panels/filter-bar.js +67 -0
  145. package/views/dist/list/panels/filter.d.ts +8 -0
  146. package/views/dist/list/panels/filter.js +23 -0
  147. package/views/dist/list/panels/quick.d.ts +7 -0
  148. package/views/dist/list/panels/quick.js +16 -0
  149. package/views/dist/list/panels/shared.d.ts +25 -0
  150. package/views/dist/list/panels/shared.js +33 -0
  151. package/views/dist/list/panels/sort.d.ts +8 -0
  152. package/views/dist/list/panels/sort.js +19 -0
  153. package/views/dist/list/panels/views.d.ts +13 -0
  154. package/views/dist/list/panels/views.js +27 -0
  155. package/views/dist/list/ready.d.ts +35 -0
  156. package/views/dist/list/ready.js +7 -0
  157. package/views/dist/list/root-base.d.ts +17 -0
  158. package/views/dist/list/root-base.js +9 -1
  159. package/views/dist/list/root.js +2 -2
  160. package/views/dist/list/store.d.ts +19 -0
  161. package/views/dist/list/store.js +40 -1
  162. package/views/dist/list/toolbar-model.d.ts +95 -0
  163. package/views/dist/list/toolbar-model.js +177 -0
  164. package/views/dist/list/toolbar.js +140 -328
  165. package/views/dist/list/views-axis.js +15 -4
  166. package/views/dist/model/aggregates.d.ts +18 -8
  167. package/views/dist/model/aggregates.js +16 -22
  168. package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
  169. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  170. package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
  171. package/views/dist/panels/react/filter/filter-body.js +2 -2
  172. package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
  173. package/views/dist/panels/react/sort/SortEditor.js +4 -4
  174. package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
  175. package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
  176. package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
  177. package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +57 -0
  178. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
  179. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
  180. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
  181. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
  182. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  183. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
  184. package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
  185. package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
  186. package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
  187. package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
  188. package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
  189. package/views/dist/panels/react/toolbar/use-give-way.js +8 -1
  190. package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
  191. package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
  192. package/views/dist/panels/settings/filter-groups.js +7 -0
  193. package/views/dist/provider/components.d.ts +38 -3
  194. package/views/dist/react.d.ts +1 -1
  195. package/views/dist/selection/bar-overflow.d.ts +2 -0
  196. package/views/dist/selection/bar-overflow.js +2 -1
  197. package/views/dist/selection/bar-props.d.ts +1 -1
  198. package/views/dist/selection/verbs.d.ts +2 -2
  199. package/views/dist/styles.css +268 -5
  200. package/views/dist/styles.unlayered.css +268 -5
  201. package/views/docs/contract.md +29 -15
  202. package/views/docs/controls/field.md +1 -0
  203. package/views/docs/controls/filter-editor.md +1 -1
  204. package/views/docs/controls/menu.md +1 -1
  205. package/views/docs/controls/number-editor.md +2 -0
  206. package/views/docs/controls/sort-editor.md +1 -1
  207. package/views/docs/controls/text-editor.md +2 -0
  208. package/views/docs/guides/atoms.md +1 -0
  209. package/views/docs/guides/selection.md +1 -1
  210. package/views/docs/guides/the-grid.md +3 -3
  211. package/views/docs/reference/controls.md +3 -3
  212. package/views/docs/reference/field-row.md +1 -1
  213. package/views/docs/reference/grid.md +4 -4
  214. package/views/docs/reference/list.md +168 -6
  215. package/views/docs/reference/looks.md +1 -1
  216. package/views/docs/reference/panels-react.md +7 -7
  217. package/views/docs/reference/react.md +13 -10
  218. package/views/docs/reference/selection.md +1 -1
  219. package/views/docs/reference/views.md +9 -7
  220. package/views/skills/views/SKILL.md +2 -1
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { cx } from "../../internal/cx.js";
4
4
  import { CellSuffix } from "../../display/format.js";
5
- import { aggregateLabel, aggregateOptions, resolveAggregateKind } from "../../model/aggregates.js";
5
+ import { aggregateOptions, aggregateWord, resolveAggregateKind } from "../../model/aggregates.js";
6
6
  import { DEFAULT_DISPLAY_CURRENCY } from "../../fields/currency.js";
7
7
  import { useUndatedCellFormat } from "../../cells/use-cell-format.js";
8
8
  import { gridFigureValue } from "./grid-figure-value.js";
@@ -16,7 +16,7 @@ import { gridFocusOnPress } from "./useGridFocus.js";
16
16
  export function gridFooterShown({ interactive, hostCells, }) {
17
17
  return interactive || hostCells.some((cell) => cell != null);
18
18
  }
19
- export function GridFooter({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked = false, frozenCount = 0, frozenLeft, continuation, defaultCurrency = DEFAULT_DISPLAY_CURRENCY, pageOnly = false, pin, verticalBorders = false, ariaRowIndex, ariaLevel, ariaColOffset = 0, }) {
19
+ export function GridFooter({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked = false, frozenCount = 0, frozenLeft, continuation, defaultCurrency = DEFAULT_DISPLAY_CURRENCY, pageOnly = false, pin, verticalBorders = false, desktop = true, menus, ariaRowIndex, ariaLevel, ariaColOffset = 0, }) {
20
20
  const interactive = !!onAggregateChange;
21
21
  const cellFormat = useUndatedCellFormat();
22
22
  const { messages } = useViews();
@@ -30,26 +30,28 @@ export function GridFooter({ group, columns, selecting, aggregates, numberFormat
30
30
  : undefined;
31
31
  if (!gridFooterShown({ interactive, hostCells }))
32
32
  return continuation;
33
- const footer = (_jsxs("div", { "data-slot": "vk-grid-footer", "data-group-key": group.key, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, className: cx("grid grid-cols-(--vk-cols)", GRID_ONE_LINE, GRID_CONTENT_PAD, pin && "sticky bottom-(--vk-foot-at) z-20 data-[stuck=true]:bg-(color:--vk-ground)", pin === "foot" && "mt-auto"), children: [_jsx(GridRailSpacer, { selecting: selecting, bordered: verticalBorders }), columns.map((column, index) => {
33
+ const footer = (_jsxs("div", { "data-slot": "vk-grid-footer", "data-group-key": group.key, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, className: cx("grid grid-cols-(--vk-cols)", GRID_ONE_LINE, GRID_CONTENT_PAD, pin && "sticky bottom-(--vk-foot-at) z-20 border-t border-transparent data-[stuck=true]:bg-(color:--vk-ground) data-[stuck=true]:border-(color:--vk-border-subtle)", pin === "foot" && !desktop && "mt-auto"), children: [_jsx(GridRailSpacer, { selecting: selecting, bordered: true }), columns.map((column, index) => {
34
34
  const pageOwn = pageOnly && !sourced;
35
- const kind = pageOwn ? "none" : resolveAggregateKind(column, aggregates, sourced);
36
- const columnInteractive = !pageOwn && interactive && (!viewBacked || column.field != null);
35
+ const place = { first: index === 0 };
36
+ const kind = pageOwn ? "none" : resolveAggregateKind(column, aggregates, sourced, place);
37
+ const options = aggregateOptions(column, sourced, place);
38
+ const columnInteractive = !pageOwn && interactive && (!viewBacked || column.field != null) && options.some((option) => option !== "none");
37
39
  const host = hostCells[index];
38
40
  const figure = host == null
39
41
  ? gridFigureValue({ column, group, kind, numberFormats, defaultCurrency, cellFormat })
40
42
  : null;
41
43
  const value = host != null ? host : (figure?.text ?? null);
42
- const label = host == null && kind !== "none" ? aggregateLabel(kind, messages) : null;
44
+ const label = host == null && kind !== "none" ? aggregateWord(kind, messages) : null;
43
45
  const suffix = figure?.suffix ?? null;
44
46
  const frozen = index < frozenCount && !!frozenLeft;
45
47
  const offers = value == null && columnInteractive;
46
48
  const cell = (_jsx("div", { "data-slot": "vk-grid-footer-cell", "data-footcell": column.id, "data-empty": offers ? "" : undefined, "data-frozen": frozen ? "" : undefined, "data-frozen-edge": frozen && index === frozenCount - 1 ? "" : undefined, role: "gridcell", "aria-colindex": ariaColOffset + index + 1, tabIndex: -1, onPointerDown: (event) => gridFocusOnPress(event, "[data-footcell]"), style: {
47
49
  ...gridCellPlace(index),
48
50
  ...(frozen ? { left: `calc(var(--vk-stick,1) * ${frozenLeft(index)} + var(--vk-hold-x,0px))` } : null),
49
- }, className: cx("group/gridagg flex h-(--vk-footer-h) min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap px-(--vk-px)", GRID_CHROME_FOCUS, verticalBorders && "border-r border-b border-(color:--vk-border-subtle)", column.align === "right" && "justify-end", column.align === "center" && "justify-center", columnInteractive && "cursor-pointer select-none hover:bg-(color:--vk-hovered)", frozen ? cx("[position:var(--vk-pin,sticky)] z-7", GRID_GROUND_WHILE_SCROLLED) : "relative"), children: value != null ? (_jsxs(_Fragment, { children: [label && (_jsx("span", { "data-slot": "vk-grid-figure-label", className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest)", children: label })), _jsxs("span", { "data-slot": "vk-grid-figure-value", className: "text-(length:--vk-text) font-medium tabular-nums", children: [value, suffix && _jsx(CellSuffix, { children: suffix })] })] })) : offers ? (_jsx("span", { "data-slot": "vk-grid-figure-pick", className: "text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest) opacity-0 group-hover/gridagg:opacity-100", children: messages({ key: "views.grid.figure-pick" }) })) : null }, column.id));
51
+ }, className: cx("group/gridagg flex h-(--vk-footer-h) min-w-0 items-center gap-1.5 overflow-hidden whitespace-nowrap px-(--vk-px)", GRID_CHROME_FOCUS, "border-b border-(color:--vk-border-subtle)", verticalBorders && "border-r", "justify-end", columnInteractive && "cursor-pointer select-none hover:bg-(color:--vk-hovered)", frozen ? cx("[position:var(--vk-pin,sticky)] z-7", GRID_GROUND_WHILE_SCROLLED) : "relative"), children: value != null ? (_jsxs(_Fragment, { children: [label && (_jsx("span", { "data-slot": "vk-grid-figure-label", className: "min-w-0 overflow-hidden text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest)", children: label })), _jsxs("span", { "data-slot": "vk-grid-figure-value", className: "text-(length:--vk-text) font-medium tabular-nums", children: [value, suffix && _jsx(CellSuffix, { children: suffix })] })] })) : offers ? (_jsx("span", { "data-slot": "vk-grid-figure-pick", className: "min-w-0 overflow-hidden text-(length:--vk-text-10) uppercase tracking-wide text-(color:--vk-fg-subtlest) opacity-0 group-hover/gridagg:opacity-100 group-data-[open]/gridagg:opacity-100", children: messages({ key: "views.grid.figure-pick" }) })) : null }, column.id));
50
52
  if (!columnInteractive)
51
53
  return cell;
52
- return (_jsx(GridAggregateMenu, { column: column, options: aggregateOptions(column, sourced), current: kind, onChange: (next) => onAggregateChange(column.id, next), align: column.align === "right" ? "end" : column.align === "center" ? "center" : "start", children: cell }, column.id));
53
- }), _jsx("div", { "data-slot": "vk-grid-tail", "aria-hidden": true, style: GRID_TAIL_PLACE, className: cx("h-(--vk-footer-h)", verticalBorders && "border-b border-(color:--vk-border-subtle)") })] }));
54
+ return (_jsx(GridAggregateMenu, { column: column, options: options, current: kind, onChange: (next) => onAggregateChange(column.id, next), reshape: menus?.figure && ((items) => menus.figure(items, { column, group, current: kind })), children: cell }, column.id));
55
+ }), _jsx("div", { "data-slot": "vk-grid-tail", "aria-hidden": true, style: GRID_TAIL_PLACE, className: "h-(--vk-footer-h) border-b border-(color:--vk-border-subtle)" })] }));
54
56
  return (_jsxs(_Fragment, { children: [pin && _jsx(StuckMarker, { edge: "bottom" }), footer, continuation] }));
55
57
  }
@@ -16,8 +16,10 @@ import { gridFocusOnPress } from "./useGridFocus.js";
16
16
  import { columnSortParts, effectiveSortKey, sortPartOf } from "../../model/column-sort.js";
17
17
  import { columnPlacedByView } from "../../model/column-capabilities.js";
18
18
  import { timeShown } from "../../display/format.js";
19
+ const HEAD_GLYPH_CLASS = "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0 text-(color:--vk-head-glyph-fg,currentColor) opacity-70";
19
20
  export function GridHeader({ showAddColumn = false, addColumnAt = "end", checkbox, checkColumnId, groupKey, ariaRowIndex, ariaLevel, ariaColOffset = 0, ariaTailIndex, columns, columnManager, minWidth, sort, sortMark = false, selectValues, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnStateEnabled, listConfig, groupBy, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, headerDrag, frozenCount = 0, frozenLeft, verticalBorders = true, headerVerticalBorders = false, viewBacked = false, formatsWritable, renderAddColumn, columnMenuItems, menus, openColumnMenu, onOpenColumnMenuChange, }) {
20
- const { icons, components, messages } = useViews();
21
+ const { icons, components, messages, atoms } = useViews();
22
+ const { HeaderGlyph, HeaderSortMark, HeaderResizeHandle } = atoms;
21
23
  const headId = useId();
22
24
  const addColumnNode = columnManager && showAddColumn
23
25
  ? gridAddColumnNode(renderAddColumn, columnManager, addColumnAt, menus?.addColumn && ((items) => menus.addColumn(items, { columns: columnManager.items })))
@@ -39,7 +41,6 @@ export function GridHeader({ showAddColumn = false, addColumnAt = "end", checkbo
39
41
  sortPartOf(sort.value, column.field.key, columnSortParts(column, viewBacked)) !== undefined))
40
42
  ? sort.dir
41
43
  : null;
42
- const Mark = sortedAs === "asc" ? icons.sortAsc : icons.sortDesc;
43
44
  const cell = (_jsxs("div", { "data-slot": "vk-grid-header-cell", "data-headcell": column.id, "data-frozen": frozen ? "" : undefined, "data-frozen-edge": frozen && index === frozenCount - 1 ? "" : undefined, tabIndex: -1, role: "columnheader", "aria-colindex": ariaColOffset + index + 1, "aria-sort": sortedAs ? (sortedAs === "asc" ? "ascending" : "descending") : undefined, "aria-label": column.header ? undefined : (column.field?.label ?? column.id), "aria-labelledby": nameId, style: {
44
45
  ...headerDrag.cellStyle(column.id, index),
45
46
  ...gridCellPlace(index),
@@ -51,7 +52,7 @@ export function GridHeader({ showAddColumn = false, addColumnAt = "end", checkbo
51
52
  headerDrag.onCellPointerDown(column.id, index)(event);
52
53
  }, onPointerMove: headerDrag.onCellPointerMove, onPointerUp: headerDrag.onCellPointerUp, onPointerCancel: headerDrag.onCellPointerCancel, onClickCapture: headerDrag.onCellClickCapture, className: cx("flex h-(--vk-head-h) min-w-0 select-none items-center gap-1.5 overflow-hidden whitespace-nowrap border-b border-(color:--vk-border-subtle) px-(--vk-px) text-(length:--vk-head-text) text-(color:--vk-fg-subtle)", GRID_CHROME_FOCUS, !frozen && "hover:bg-(color:--vk-hovered)", headerVerticalBorders && cx("border-r", !verticalBorders && "border-r-transparent"), column.align === "center" && "justify-center", menuEnabled ? "cursor-pointer" : "cursor-default", "translate-x-(--vk-drag-shift,0px)", frozen
53
54
  ? cx("[position:var(--vk-pin,sticky)] z-7", GRID_HEADER_BG_FROZEN, GRID_HEADER_BG_FROZEN_HOVER)
54
- : "relative"), children: [withCheck && checkbox, gridColumnGlyph({ icons, AppIcon: components.AppIcon }, column, "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0 text-(color:--vk-head-glyph-fg,currentColor) opacity-70"), column.header ? (_jsx("span", { id: nameId, className: "truncate", children: column.header })) : null, sortMark && sortedAs && (_jsx("span", { "aria-hidden": true, className: "inline-flex shrink-0", children: _jsx(Mark, { className: "h-(--vk-head-glyph) w-(--vk-head-glyph)" }) })), withAddColumn && titleAddColumn, columnStateEnabled && (_jsx(GridResizeHandle, { active: resizingId === column.id, onResizeStart: (event) => startResize(column, event), onResizeMove: moveResize, onResizeEnd: endResize, onReset: () => resetColumnWidth(column) }))] }, column.id));
55
+ : "relative"), children: [withCheck && checkbox, _jsx(HeaderGlyph, { columnId: column.id, type: column.type, fieldKey: column.field?.key, fallback: gridColumnGlyph({ icons, AppIcon: components.AppIcon }, column, HEAD_GLYPH_CLASS), className: HEAD_GLYPH_CLASS }), column.header ? (_jsx("span", { id: nameId, className: "truncate", children: column.header })) : null, sortMark && sortedAs && (_jsx("span", { "aria-hidden": true, className: "inline-flex shrink-0", children: _jsx(HeaderSortMark, { columnId: column.id, dir: sortedAs, className: "h-(--vk-head-glyph) w-(--vk-head-glyph)" }) })), withAddColumn && titleAddColumn, columnStateEnabled && (_jsx(GridResizeHandle, { onResizeStart: (event) => startResize(column, event), onResizeMove: moveResize, onResizeEnd: endResize, onReset: () => resetColumnWidth(column), children: _jsx(HeaderResizeHandle, { columnId: column.id, active: resizingId === column.id }) }))] }, column.id));
55
56
  if (!menuEnabled)
56
57
  return cell;
57
58
  return (_jsx(GridColumnMenu, { column: column, values: selectValues[column.id] ?? [], viewBacked: viewBacked, sort: sort, groupBy: groupBy, optionColors: optionColors?.[fieldKeyOf(column)], onOptionColorChange: onOptionColorChange, dateStyle: dateStyles?.[fieldKeyOf(column)], onDateStyleChange: onDateStyleChange, durationStyle: durationStyles?.[fieldKeyOf(column)], onDurationStyleChange: onDurationStyleChange, numberFormat: numberFormats?.[fieldKeyOf(column)], onNumberFormatChange: onNumberFormatChange, showTime: timeShown(column.format?.withTime, showTimeOverrides?.[fieldKeyOf(column)]), onShowTimeChange: column.type === "datetime" ? onShowTimeChange : undefined, percentDisplay: percentDisplays?.[fieldKeyOf(column)], onPercentDisplayChange: onPercentDisplayChange, onMoveLeft: canMove && index > 0 ? () => moveColumn(column, -1) : undefined, onMoveRight: canMove && index < columns.length - 1 ? () => moveColumn(column, 1) : undefined, onHide: canHide ? () => hideColumn(column) : undefined, formatsWritable: formatsWritable, columnMenuItems: column.partOf ? undefined : columnMenuItems, reshape: menus?.column && ((items) => menus.column(items, { field: column.field, column })), open: openColumnMenu === undefined ? undefined : openColumnMenu === column.id, onOpenChange: onOpenColumnMenuChange ? (next) => onOpenColumnMenuChange(next ? column.id : null) : undefined, children: cell }, column.id));
@@ -8,6 +8,7 @@ import { useKeepInside } from "../../editors/keep-inside.js";
8
8
  import { cx } from "../../internal/cx.js";
9
9
  import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER, GRID_TYPE_IN } from "./grid-editor-layer.js";
10
10
  import { GridFittedBox } from "./grid-fitted-box.js";
11
+ import { GRID_TYPED_RING } from "./GridCellOutline.js";
11
12
  import { GridRefusal, UNDER_CELL_CLASS, useGridEditSession } from "./grid-edit-session.js";
12
13
  export function GridNumberEditor({ title, initial, seed, unit, unitOptions, code, decimals = 2, durationUnit, allowEmpty = false, unitLeft = false, conversion, onCommit, onCancel, onTab, onEnter, refuse, type, bounds, }) {
13
14
  const editorRef = useRef(null);
@@ -32,7 +33,7 @@ export function GridNumberEditor({ title, initial, seed, unit, unitOptions, code
32
33
  form: surface === "sheet" ? "phone" : "computer",
33
34
  }
34
35
  : {}), onRequestClose: close }));
35
- return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", ...GRID_TYPE_IN, className: cx(GRID_EDITOR_LAYER, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
36
+ return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", ...GRID_TYPE_IN, className: cx(GRID_EDITOR_LAYER, GRID_TYPED_RING.number, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
36
37
  }
37
38
  function UnderCellConversion({ figure }) {
38
39
  const ref = useRef(null);
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  /**
2
3
  * The column-resize grab zone on a header cell's right edge. The header cell is
3
4
  * (usually) a Radix PopoverTrigger — every pointer/click event here stops
@@ -8,12 +9,15 @@
8
9
  * move/up here, so the passed handlers see the whole gesture without any
9
10
  * document listeners). Double-click clears the column's width override — but
10
11
  * only for true double-clicks; GridTable ignores it after a real drag.
12
+ *
13
+ * What it shows is `children`, the `HeaderResizeHandle` atom: ViewKit's hairline, or the app's own, which
14
+ * resizes from a press anywhere on it because its events reach this zone.
11
15
  */
12
- export declare function GridResizeHandle({ active, onResizeStart, onResizeMove, onResizeEnd, onReset, }: {
13
- /** True while THIS column is being dragged — pins the hairline visible. */
14
- active: boolean;
16
+ export declare function GridResizeHandle({ onResizeStart, onResizeMove, onResizeEnd, onReset, children, }: {
15
17
  onResizeStart: (e: React.PointerEvent<HTMLElement>) => void;
16
18
  onResizeMove: (e: React.PointerEvent<HTMLElement>) => void;
17
19
  onResizeEnd: (e: React.PointerEvent<HTMLElement>) => void;
18
20
  onReset: () => void;
21
+ /** What the zone shows: the `HeaderResizeHandle` atom. */
22
+ children: ReactNode;
19
23
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { cx } from "../../internal/cx.js";
4
- export function GridResizeHandle({ active, onResizeStart, onResizeMove, onResizeEnd, onReset, }) {
3
+ export function GridResizeHandle({ onResizeStart, onResizeMove, onResizeEnd, onReset, children, }) {
5
4
  return (_jsx("div", { "data-slot": "vk-grid-resize-handle", "data-no-nav": true, className: "group/gridresize absolute inset-y-0 right-0 z-10 w-[7px] cursor-col-resize touch-none", onPointerDown: (e) => {
6
5
  if (e.button !== 0)
7
6
  return;
@@ -15,5 +14,5 @@ export function GridResizeHandle({ active, onResizeStart, onResizeMove, onResize
15
14
  }, onPointerCancel: onResizeEnd, onClick: (e) => e.stopPropagation(), onDoubleClick: (e) => {
16
15
  e.stopPropagation();
17
16
  onReset();
18
- }, children: _jsx("div", { className: cx("absolute inset-y-0 right-0 w-[3px] rounded-full bg-(color:--vk-brand)", active ? "opacity-100" : "opacity-0 group-hover/gridresize:opacity-100") }) }));
17
+ }, children: children }));
19
18
  }
@@ -113,7 +113,7 @@ export function GridRowCells({ props }) {
113
113
  listConfig,
114
114
  onCommitCell,
115
115
  onCancel: () => onCancelEdit(rowKey, col.id),
116
- onClosing: (reason) => onEditorClosing?.(rowKey, col.id, reason),
116
+ onClosing: (reason, popover) => onEditorClosing?.(rowKey, col.id, reason, popover),
117
117
  onTab: tabTo,
118
118
  onEnter: () => onFocusCell(rowKey, col.id),
119
119
  };
@@ -20,9 +20,9 @@ function GridRowsSlot({ children }) {
20
20
  const { RowsWait, pending } = slot;
21
21
  return _jsx(RowsWait, { pending: pending, children: children });
22
22
  }
23
- function GridCollapseRegion({ collapsed, children, }) {
23
+ function GridCollapseRegion({ collapsed, rows = false, children, }) {
24
24
  const { Collapse } = useViews().components;
25
- return (_jsx(Collapse, { open: !collapsed, clipClassName: "pt-[2px] mt-[-2px] pb-2 -mb-2", children: children }));
25
+ return (_jsx(Collapse, { open: !collapsed, clipClassName: rows ? "pt-[2px] mt-[-2px] pb-2 -mb-2" : undefined, children: children }));
26
26
  }
27
27
  function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks = false, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, groupMenu, menus, figures, countNoun, renderHeader, renderGroupCheckbox, selectGroup, renderRow, wrapRows, renderFooter, keptFor, barIndex, ariaColCount, oneHead, first, }) {
28
28
  const views = useViews();
@@ -68,7 +68,7 @@ function GridGroupSection({ group, collapsed, count, selectable, foldOverChecks
68
68
  canToggleFigures: !!onGroupSummaryChange,
69
69
  canHide: !!onHideGroup,
70
70
  canSelect: !!select,
71
- }).open && (_jsx(GridGroupMenu, { groupMenu: groupMenu, reshape: menus?.group && ((items) => menus.group(items, { group })), sort: sort, sortOptions: sortOptions ?? [], summary: summaryParts, onSummaryChange: onGroupSummaryChange, figures: figures, onHide: onHideGroup ? () => onHideGroup(group.key) : undefined, select: select }))] }) }), !oneHead && (_jsx(GridCollapseRegion, { collapsed: collapsed, children: renderHeader(selectable ? renderGroupCheckbox(group.items) : undefined, group.key) }))] }), _jsxs(GridCollapseRegion, { collapsed: collapsed, children: [wrapRows(_jsx(GridWindowRows, { groupKey: group.key, items: group.items, collapsed: collapsed, kept: keptFor(group.key), renderRow: renderRow })), renderFooter(group)] })] }));
71
+ }).open && (_jsx(GridGroupMenu, { groupMenu: groupMenu, reshape: menus?.group && ((items) => menus.group(items, { group })), sort: sort, sortOptions: sortOptions ?? [], summary: summaryParts, onSummaryChange: onGroupSummaryChange, figures: figures, onHide: onHideGroup ? () => onHideGroup(group.key) : undefined, select: select }))] }) }), !oneHead && (_jsx(GridCollapseRegion, { collapsed: collapsed, children: renderHeader(selectable ? renderGroupCheckbox(group.items) : undefined, group.key) }))] }), _jsxs(GridCollapseRegion, { collapsed: collapsed, rows: true, children: [wrapRows(_jsx(GridWindowRows, { groupKey: group.key, items: group.items, collapsed: collapsed, kept: keptFor(group.key), renderRow: renderRow })), renderFooter(group)] })] }));
72
72
  }
73
73
  export function GridBody({ empty, emptyState, grouped, oneHead, groups, rows, selectable, selecting, phoneChecks = false, foldOverChecks = false, allSelected, someSelected, selectAll, clearSelection, isCollapsed, countOf, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, groupMenu, menus, figures, countNoun, renderHeader, renderGroupCheckbox, selectGroup, renderRow, wrapRows, renderFooter, keptFor, barIndexOf, ariaColCount, }) {
74
74
  const { messages } = useViews();
@@ -396,7 +396,7 @@ function GridTableContent(given) {
396
396
  const pinFooter = props.pinFooter && footerKey.includes("1")
397
397
  ? { pin: grouped ? "group" : "foot", flush: footerKey.endsWith("1") }
398
398
  : undefined;
399
- const footer = (group) => (_jsx(GridFooter, { group: group, ariaRowIndex: aria.footIndex(grouped ? group.key : (flat.sections[0]?.groupKey ?? group.key)), ariaLevel: grouped ? 2 : undefined, ariaColOffset: ariaColOffset, columns: visibleColumns, selecting: selecting, aggregates: aggregates, numberFormats: numberFormats, renderAggregate: renderAggregate, onAggregateChange: onAggregateChange, viewBacked: props.viewBacked, frozenCount: frozenCount, frozenLeft: frozenLeft, continuation: props.renderGroupFooter?.(group), defaultCurrency: props.defaultCurrency, pageOnly: paged, pin: pinFooter?.pin, verticalBorders: verticalBorders }));
399
+ const footer = (group) => (_jsx(GridFooter, { group: group, ariaRowIndex: aria.footIndex(grouped ? group.key : (flat.sections[0]?.groupKey ?? group.key)), ariaLevel: grouped ? 2 : undefined, ariaColOffset: ariaColOffset, columns: visibleColumns, selecting: selecting, aggregates: aggregates, numberFormats: numberFormats, renderAggregate: renderAggregate, onAggregateChange: onAggregateChange, viewBacked: props.viewBacked, frozenCount: frozenCount, frozenLeft: frozenLeft, continuation: props.renderGroupFooter?.(group), defaultCurrency: props.defaultCurrency, pageOnly: paged, pin: pinFooter?.pin, verticalBorders: verticalBorders, desktop: !phone, menus: props.menus }));
400
400
  const groupCheckbox = (items) => pickOnPhone ? (_jsx(GridHeadCheckBox, { ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) })) : (_jsx(GridHeadCheck, { selecting: selecting, ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) }));
401
401
  return (_jsx(EditLeaveContext.Provider, { value: leaveScope, children: _jsx(GridFitContext.Provider, { value: fit, children: _jsx(GridHoverContext.Provider, { value: hoverStore, children: _jsx(GridRowHighlightContext.Provider, { value: highlight, children: _jsx(GridRowWindowContext.Provider, { value: rowWindow.store, children: _jsx(GridTableSurface, { rootRef: rootRef, empty: empty, desktop: !phone, areaRef: areaRef, panRef: panRef, boxes: boxes, minWidth: minWidth, columnsTemplate: gridTemplate, gridAria: empty
402
402
  ? { role: "grid", rowCount: 2, colCount: ariaTailIndex }
@@ -15,7 +15,7 @@ export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selec
15
15
  const scrollPaddingBottom = pinFooter
16
16
  ? "calc(var(--vk-scroll-inset-bottom,0px) + var(--vk-footer-h))"
17
17
  : "var(--vk-scroll-inset-bottom,0px)";
18
- const content = (_jsxs("div", { className: cx("relative", pinFooter?.pin === "foot" && "flex min-h-full flex-col"), role: gridAria?.role, "aria-rowcount": gridAria?.rowCount, "aria-colcount": gridAria?.colCount, "aria-multiselectable": gridAria ? true : undefined, style: {
18
+ const content = (_jsxs("div", { className: cx("relative", pinFooter?.pin === "foot" && !desktop && "flex min-h-full flex-col"), role: gridAria?.role, "aria-rowcount": gridAria?.rowCount, "aria-colcount": gridAria?.colCount, "aria-multiselectable": gridAria ? true : undefined, style: {
19
19
  minWidth,
20
20
  paddingBottom: footAt && pinFooter?.flush ? footAt : `calc(${foot} + 0.5rem)`,
21
21
  ...(footAt ? { "--vk-foot-at": footAt } : {}),
@@ -7,6 +7,8 @@ import { TextEditorHost, } from "../../editors/TextEditor.js";
7
7
  import { GridRefusal, useGridEditSession } from "./grid-edit-session.js";
8
8
  import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER, GRID_TYPE_IN } from "./grid-editor-layer.js";
9
9
  import { GridFittedBox } from "./grid-fitted-box.js";
10
+ import { GRID_TYPED_RING } from "./GridCellOutline.js";
11
+ import { cx } from "../../internal/cx.js";
10
12
  const TEXT_TYPES = new Set([
11
13
  "text",
12
14
  "url",
@@ -33,6 +35,6 @@ export function GridTextEditor({ initial, seed, type = "text", paragraph = false
33
35
  const [stored, setStored] = useState(seed === undefined);
34
36
  return (_jsx(EditorPanel, { session: session, title: title ?? "", anchor: null, inPlace: true, sheetOnPhone: true, children: (surface) => {
35
37
  const editor = (_jsx(TextEditorHost, { ref: editorRef, type: type, initial: initial, seed: seed, closeOnBlur: surface === "in-place", ...(paragraph ? { multiline: true } : {}), label: typeof title === "string" ? title : undefined, check: refuse, region: region, escapeKeeps: session.keeps ?? false, form: surface === "sheet" ? "phone" : "computer", place: "cell", onRequestClose: close }));
36
- return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { "data-grown": "", ...GRID_TYPE_IN, className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
38
+ return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { "data-grown": "", ...GRID_TYPE_IN, className: cx(GRID_EDITOR_LAYER, GRID_TYPED_RING.text), children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
37
39
  } }));
38
40
  }
@@ -1,8 +1,6 @@
1
1
  import { type RefObject } from "react";
2
+ import { type OverOffsets } from "../../internal/over-cell.js";
2
3
  /** The offsets a grid editor hands the popover around the app's body. */
3
- export type GridBodyPlace = {
4
- sideOffset: number;
5
- alignOffset: number;
6
- };
4
+ export type GridBodyPlace = OverOffsets;
7
5
  /** The offsets a grid editor hands its panel around the app's body: over the cell, a step up and a step left of it. */
8
6
  export declare function useGridBodyPlace(anchor: RefObject<HTMLElement | null>): GridBodyPlace;
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  import { useLayoutEffect, useState } from "react";
3
+ import { overCellOffsets } from "../../internal/over-cell.js";
3
4
  const UNDER = 4;
4
- const stepOf = (el) => parseFloat(getComputedStyle(el).getPropertyValue("--vk-spacing")) || 0;
5
5
  export function useGridBodyPlace(anchor) {
6
6
  const [at, setAt] = useState(null);
7
7
  useLayoutEffect(() => {
8
8
  const el = anchor.current;
9
9
  if (!el)
10
10
  return;
11
- const height = el.getBoundingClientRect().height, step = stepOf(el);
12
- setAt((now) => (now && now.height === height && now.step === step ? now : { height, step }));
11
+ const next = overCellOffsets(el);
12
+ setAt((now) => (now && now.sideOffset === next.sideOffset && now.alignOffset === next.alignOffset ? now : next));
13
13
  }, [anchor]);
14
- return at ? { sideOffset: -(at.height + at.step), alignOffset: -at.step } : { sideOffset: UNDER, alignOffset: 0 };
14
+ return at ?? { sideOffset: UNDER, alignOffset: 0 };
15
15
  }
@@ -8,9 +8,13 @@ type Handle<P> = {
8
8
  resolveClose: (reason: CloseReason) => CloseResolution<P>;
9
9
  };
10
10
  /** The cell around a grid editor, told the moment the editor starts to close: its session accepted an answer, and the
11
- * popover or the sheet begins its exit. With the reason the session closed by (null where it names none). The cell
12
- * stops wearing the editing state then, not once the exit is over, and a press away lets its pick go. */
13
- export declare const GridEditClosingContext: import("react").Context<((reason: CloseReason | null) => void) | null>;
11
+ * popover or the sheet begins its exit. With the reason the session closed by (null where it names none), and whether
12
+ * the editor stood in a computer's popover, which holds the focus until its exit ends. The cell stops wearing the
13
+ * editing state then, not once the exit is over; a press away lets its pick go, and a close that keeps the cell takes
14
+ * the focus back from the popover at once. */
15
+ export declare const GridEditClosingContext: import("react").Context<((reason: CloseReason | null, popover: boolean) => void) | null>;
16
+ /** Writes every kept answer still waiting out its popover's exit, so an undo heard now takes back the answer just given. */
17
+ export declare function flushGridKeptAnswers(): void;
14
18
  export type GridEditSessionArgs<P> = {
15
19
  editorRef: RefObject<Handle<P> | null>;
16
20
  /** Reshapes a commit before it is judged and written (a day field's timestamp trimmed to its day). */
@@ -9,6 +9,12 @@ import { useViews } from "../../provider/context.js";
9
9
  import { useDesktop } from "../../provider/desktop.js";
10
10
  export const GRID_SHEET_EXIT_MS = 500;
11
11
  export const GridEditClosingContext = createContext(null);
12
+ const keptFlushes = new Set();
13
+ export function flushGridKeptAnswers() {
14
+ for (const flush of [...keptFlushes])
15
+ flush();
16
+ }
17
+ const KEY_CLOSES = new Set(["enter", "tab", "shift-tab", "escape", "pick"]);
12
18
  export function useGridEditSession(args) {
13
19
  const { editorRef, mapPayload, inPlace = false } = args;
14
20
  const desktop = useDesktop();
@@ -30,8 +36,10 @@ export function useGridEditSession(args) {
30
36
  const flushRef = useRef(null);
31
37
  const leavingRef = useRef(false);
32
38
  const stopFlush = () => {
33
- if (flushRef.current)
39
+ if (flushRef.current) {
34
40
  document.removeEventListener("keydown", flushRef.current, true);
41
+ keptFlushes.delete(flushRef.current);
42
+ }
35
43
  flushRef.current = null;
36
44
  };
37
45
  const move = () => {
@@ -58,7 +66,7 @@ export function useGridEditSession(args) {
58
66
  keptRef.current = answer;
59
67
  if (leavingRef.current)
60
68
  return;
61
- if (sheet || (viaRef.current !== "enter" && viaRef.current !== "tab" && viaRef.current !== "shift-tab"))
69
+ if (sheet || !KEY_CLOSES.has(reasonRef.current))
62
70
  return;
63
71
  movedRef.current = true;
64
72
  move();
@@ -69,6 +77,7 @@ export function useGridEditSession(args) {
69
77
  stopFlush();
70
78
  };
71
79
  flushRef.current = flush;
80
+ keptFlushes.add(flush);
72
81
  document.addEventListener("keydown", flush, true);
73
82
  };
74
83
  const session = useAnchoredEditSession({
@@ -87,7 +96,7 @@ export function useGridEditSession(args) {
87
96
  if (reason !== null)
88
97
  return { accepted: false, reason };
89
98
  if (!leavingRef.current)
90
- closingRef.current?.(reasonRef.current);
99
+ closingRef.current?.(reasonRef.current, !sheet && !inPlace);
91
100
  if (inPlace && !sheet)
92
101
  write(answer, true);
93
102
  else
@@ -7,10 +7,11 @@
7
7
  */
8
8
  export declare const GRID_EDITOR_LAYER = "absolute -inset-px z-2 flex min-w-0";
9
9
  /**
10
- * What a cell typed in shows: only the caret. The layer tells ViewKit's Inline input it stands in a cell
11
- * (`data-inline-input-place`, inline-input.css): no edge, no ring and no ground of its own, so the cell shows as it was;
12
- * grown past its cell, the plain ground, never lifted. A text grows from the cell as the "In the cell" look grows it, whatever
13
- * the page's text look (`data-text-editor-box`). An app's own body draws its own look.
10
+ * What a cell typed in shows: the selected cell's ring round the caret and what is typed. The layer tells ViewKit's Inline
11
+ * input it stands in a cell (`data-inline-input-place`, inline-input.css): no edge, ring or ground of its own, so the cell
12
+ * shows as it was; grown past its cell, the plain ground, never lifted. The layer's `GRID_TYPED_RING` puts the grid's own
13
+ * selected ring on the box, so it goes round the box as it grows. A text grows from the cell as the "In the cell" look grows
14
+ * it, whatever the page's text look (`data-text-editor-box`). An app's own body draws its own look.
14
15
  */
15
16
  export declare const GRID_TYPE_IN: {
16
17
  readonly "data-inline-input-place": "cell";
@@ -3,9 +3,12 @@ import { computeAggregate, figureKeyOf, moneyFigureCode, moneyTotal } from "../.
3
3
  import { fieldTypeOf } from "../../model/field-type-of.js";
4
4
  import { fieldKeyOf } from "../../model/view-rules.js";
5
5
  import { formatNumber } from "./cells.js";
6
+ const COUNTS_NUMBERS = new Set(["number", "percent", "currency"]);
6
7
  function countsRows(kind) {
7
- return kind === "count" || kind === "filled" || kind === "unique";
8
+ return kind === "count" || kind === "filled" || kind === "empty" || kind === "unique" || isPercentOfRows(kind);
8
9
  }
10
+ const isPercentOfRows = (kind) => kind === "percentEmpty" || kind === "percentFilled";
11
+ const countText = (kind, n) => (isPercentOfRows(kind) ? `${n}%` : String(n));
9
12
  export function gridFigureValue({ column, group, kind, numberFormats, defaultCurrency, cellFormat, }) {
10
13
  if (kind === "none")
11
14
  return null;
@@ -15,16 +18,19 @@ export function gridFigureValue({ column, group, kind, numberFormats, defaultCur
15
18
  const written = (text) => (text == null ? null : { text, suffix });
16
19
  if (group.figures) {
17
20
  const ratioParts = column.field?.type === "formula" ? column.field.ratio : undefined;
21
+ const key = figureKeyOf(column, defaultCurrency);
22
+ if (kind === "filled" && !COUNTS_NUMBERS.has(fieldTypeOf(column)) && !column.aggAccessor && group.figures.fields[key]?.filled === undefined)
23
+ return null;
18
24
  const fromSource = kind === "ratio" && ratioParts
19
25
  ? ratioFigure(group.figures, ratioParts.numerator, ratioParts.denominator)
20
- : figureFor(kind, group.figures, figureKeyOf(column, defaultCurrency));
26
+ : figureFor(kind, group.figures, key);
21
27
  const sourceCode = fromSource != null && !countLike && fieldTypeOf(column) === "currency"
22
28
  ? moneyFigureCode(column, defaultCurrency)
23
29
  : undefined;
24
30
  if (fromSource == null || sourceCode === null)
25
31
  return null;
26
32
  return written(countLike
27
- ? String(fromSource)
33
+ ? countText(kind, fromSource)
28
34
  : formatNumber(fromSource, column, { ...cellFormat, decimals, currency: sourceCode }));
29
35
  }
30
36
  const money = moneyTotal(kind, column, group.items, defaultCurrency);
@@ -36,5 +42,5 @@ export function gridFigureValue({ column, group, kind, numberFormats, defaultCur
36
42
  const computed = computeAggregate(kind, column, group.items);
37
43
  if (computed == null)
38
44
  return null;
39
- return written(countLike ? String(computed) : formatNumber(computed, column, { ...cellFormat, decimals }));
45
+ return written(countLike ? countText(kind, computed) : formatNumber(computed, column, { ...cellFormat, decimals }));
40
46
  }
@@ -76,7 +76,7 @@ export type GridRowProps<Row> = {
76
76
  * picked again, no longer `data-editing`. False on every row but the editing one. */
77
77
  editClosing?: boolean;
78
78
  /** Told when THIS row's open editor starts to close, with the reason it closed by (null where its panel names none). */
79
- onEditorClosing?: (rowId: string, columnId: string, reason: CloseReason | null) => void;
79
+ onEditorClosing?: (rowId: string, columnId: string, reason: CloseReason | null, popover: boolean) => void;
80
80
  /** columnId → optimistic pending value (undefined when this row has none). */
81
81
  pendingByCol?: Record<string, unknown>;
82
82
  /** columnId → `requested` for a pending value saved here but not yet accepted
@@ -21,7 +21,9 @@ import type { GridGroupMenuPart } from "./grid-group-menu-parts.js";
21
21
  /** Each of the grid's menus as a function from its default items to the items it shows (`menu.drop`, `menu.rename`,
22
22
  * `menu.add` and `menu.move` on `viewkitjs/views/list` do the usual changes). `column` gets the column and its field,
23
23
  * `row` the row, `group` the group its band names, `addColumn` every column of the list, shown or hidden (+ Add column's
24
- * rows: each hidden column `add:<id>`, a field with parts `field:<id>`, or `all-shown`). Each reshapes a menu the grid opens: a column or band whose menu holds
24
+ * rows: each hidden column `add:<id>`, a field with parts `field:<id>`, or `all-shown`), `figure` a footer cell's calculation picker
25
+ * (its column, the group whose footer it is and the pick it shows; its rows keyed by their figure: `none`, `count`, `empty`,
26
+ * `filled`, `percentEmpty`, `percentFilled`, `sum`, `avg`, `min`, `max`, `ratio`). Each reshapes a menu the grid opens: a column or band whose menu holds
25
27
  * none of the grid's rows stays without one. Called while a menu draws: keep them pure and cheap.
26
28
  *
27
29
  * `row` is asked as a row's menu opens (a right-click, the row's ⋯, the menu key), never for a row drawn or pressed, and
@@ -43,6 +45,11 @@ export type GridMenus<Row> = {
43
45
  addColumn?: (items: ViewsMenuItem[], ctx: {
44
46
  columns: readonly ListColumnItem[];
45
47
  }) => ViewsMenuItem[];
48
+ figure?: (items: ViewsMenuItem[], ctx: {
49
+ column: ListColumn<Row>;
50
+ group: ListGroup<Row>;
51
+ current: ListAggregateKind;
52
+ }) => ViewsMenuItem[];
46
53
  };
47
54
  /** A group count's noun, singular and plural ("company", "companies"): "2 companies". None: a bare
48
55
  * count. */
@@ -284,8 +291,9 @@ export type GridTableProps<Row> = {
284
291
  oneHeader?: boolean;
285
292
  /** The footer pins at the foot of the grid's scroll area, `--vk-scroll-inset-bottom` above its edge (and, while rows are
286
293
  * selected, a step above the bar `renderBar` draws, measured where it stands; on the foot when it draws none), painted
287
- * the ground, and the rows pass under it. An ungrouped grid's footer
288
- * stands at the foot even when its rows don't fill the area (in pages too, just above the pager); a grouped grid's
294
+ * the ground under a line along its top, and the rows pass under it. On a computer it is never pushed below its last
295
+ * row: under a table shorter than the area it stands right after the last row. On a phone an ungrouped grid's footer
296
+ * stands at the foot even when its rows don't fill the area (in pages too, just above the pager). A grouped grid's
289
297
  * footers each pin while their group's rows run past the foot and close their group otherwise. Off by default: the
290
298
  * footer stands after the last row and scrolls with the rows. */
291
299
  pinFooter?: boolean;
@@ -6,7 +6,7 @@ import type { ListColumn } from "../../model/column-schema.js";
6
6
  import { type GridEditsState } from "../core/edits-sink.js";
7
7
  import type { GridRangeVerbs } from "./useGridRangeActions.js";
8
8
  import { type GridChromeTarget, type GridFocusShape } from "../core/grid-focus.js";
9
- export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
9
+ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editClosing, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
10
10
  rootRef: RefObject<HTMLDivElement | null>;
11
11
  /** A column name, a footer cell, a bar or a checkbox holding the focus (`useGridFocus`); null: a data cell, or
12
12
  * nothing. */
@@ -26,6 +26,10 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
26
26
  revealCell: (pos: GridCellPos, behavior: ScrollBehavior) => void;
27
27
  focusedCell: GridCellPos | null;
28
28
  editingCell: GridCellPos | null;
29
+ /** The open editor has started to close and plays its exit (`useGridTableInteractionModel`): the cell stands as
30
+ * picked, and the keys that move or let go of the pick are its own again. A key that opens or writes still waits for
31
+ * the exit, so a cell can't reopen under its closing editor. */
32
+ editClosing?: boolean;
29
33
  editingEnabled: boolean;
30
34
  /** Workspace-settings capability config — the keyboard routes ask the same effective
31
35
  * write gate the cells do, so a lock holds here too. */
@@ -14,6 +14,7 @@ import { GridEditsSinkContext } from "../core/edits-sink.js";
14
14
  import { GRID_KEY_OWNING_SURFACES, gridFocusElement } from "./useGridFocus.js";
15
15
  import { isGridRowMenuKey, openGridRowMenu } from "./grid-row-menu-key.js";
16
16
  import { openGridEditEscape } from "./grid-edit-escape.js";
17
+ import { flushGridKeptAnswers } from "./grid-edit-session.js";
17
18
  import { bodyInnerStepFrame } from "../../editors/inner-escape.js";
18
19
  import { gridBarArrow, gridFocusStep, gridFocusTab, } from "../core/grid-focus.js";
19
20
  const NAV_KEYS = {
@@ -33,7 +34,7 @@ function eventBelongsElsewhere(target, root) {
33
34
  return true;
34
35
  return !!target.closest(INTERACTIVE) && !root?.contains(target);
35
36
  }
36
- export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited = () => true, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
37
+ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editClosing = false, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited = () => true, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
37
38
  const { ports, messages, conventions } = useViews();
38
39
  const navFromEditorRef = useRef({ tab: () => { } });
39
40
  const onEditorTab = useCallback((rowId, columnId, backwards) => navFromEditorRef.current.tab(rowId, columnId, backwards), []);
@@ -93,6 +94,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
93
94
  const holder = event.target?.closest?.('[data-slot="vk-grid"]') ?? null;
94
95
  if (holder ? holder !== rootRef.current : !isLastEdited())
95
96
  return;
97
+ flushGridKeptAnswers();
96
98
  const handled = event.shiftKey
97
99
  ? redo(resolveRow, scrollToCell)
98
100
  : undo(resolveRow, scrollToCell);
@@ -270,6 +272,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
270
272
  const bare = !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
271
273
  const navDirection = NAV_KEYS[event.key];
272
274
  const navIntent = gridNavIntent(event);
275
+ const editorHolds = editingCell != null && !editClosing;
273
276
  rowMenuWatchRef.current?.();
274
277
  rowMenuWatchRef.current = null;
275
278
  if (isGridRowMenuKey(event) && !editingCell) {
@@ -281,14 +284,14 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
281
284
  }
282
285
  if (event.key === "Escape") {
283
286
  event.stopPropagation();
284
- if (editingCell)
287
+ if (editorHolds)
285
288
  (openGridEditEscape() ?? cancelEdit)();
286
289
  else {
287
290
  clearFocus();
288
291
  releaseToFrame();
289
292
  }
290
293
  }
291
- else if (navDirection && bare && !editingCell) {
294
+ else if (navDirection && bare && !editorHolds) {
292
295
  event.preventDefault();
293
296
  if (shape && navDirection !== "right") {
294
297
  const step = gridFocusStep({ kind: "cell", pos: focusedCell }, navDirection, shape);
@@ -302,7 +305,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
302
305
  focusCell(next.rowId, next.columnId);
303
306
  revealCell(next, "auto");
304
307
  }
305
- else if (navIntent && !editingCell) {
308
+ else if (navIntent && !editorHolds) {
306
309
  event.preventDefault();
307
310
  if (navIntent.kind === "selectAll") {
308
311
  const rect = wholeTableRect(visibleRowIds, visibleColIds);
@@ -328,7 +331,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
328
331
  revealCell(next, "auto");
329
332
  }
330
333
  else if (event.key === "Tab" && !event.metaKey && !event.ctrlKey && !event.altKey) {
331
- if (editingCell) {
334
+ if (editorHolds) {
332
335
  event.preventDefault();
333
336
  return;
334
337
  }
@@ -456,6 +459,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
456
459
  chrome,
457
460
  clearFocus,
458
461
  commitEdit,
462
+ editClosing,
459
463
  editingCell,
460
464
  editingEnabled,
461
465
  entryCell,
@@ -64,7 +64,7 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
64
64
  editWhole: boolean;
65
65
  editByKey: boolean;
66
66
  editClosing: boolean;
67
- onEditorClosing: (rowId: string, columnId: string, reason: CloseReason | null) => void;
67
+ onEditorClosing: (rowId: string, columnId: string, reason: CloseReason | null, popover: boolean) => void;
68
68
  focusCellSync: (rowId: string, columnId: string) => void;
69
69
  startEditSync: (rowId: string, columnId: string, seed?: string | null, whole?: boolean, byKey?: boolean) => void;
70
70
  cancelEdit: (rowId?: string, columnId?: string) => void;
@@ -12,7 +12,7 @@ import { gridFigureOf } from "../core/clipboard-model.js";
12
12
  import { sameStoredValue } from "viewkitjs/fields";
13
13
  import { gridRowIdFromKey } from "../core/coordinates.js";
14
14
  import { revealGridCell } from "./grid-scroll-owner.js";
15
- import { useGridFocus } from "./useGridFocus.js";
15
+ import { gridFocusElement, useGridFocus } from "./useGridFocus.js";
16
16
  import { gridBarOf } from "../core/grid-focus.js";
17
17
  import { useGridKeyboard } from "./useGridKeyboard.js";
18
18
  import { useGridPendingReconciliation } from "./useGridPendingReconciliation.js";
@@ -235,7 +235,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
235
235
  useEffect(() => {
236
236
  closingRef.current = { editingCell, held: cellPick.held, dropFocus, rangeClear };
237
237
  });
238
- const onEditorClosing = useCallback((rowId, columnId, reason) => {
238
+ const onEditorClosing = useCallback((rowId, columnId, reason, popover) => {
239
239
  const { editingCell: open, held, dropFocus: drop, rangeClear: clear } = closingRef.current;
240
240
  if (!open || open.rowId !== rowId || open.columnId !== columnId)
241
241
  return;
@@ -245,7 +245,11 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
245
245
  drop();
246
246
  clear();
247
247
  }
248
- }, []);
248
+ const keeps = reason === "escape" || reason === "pick" || reason === "enter";
249
+ const root = rootRef.current;
250
+ if (keeps && popover && root)
251
+ gridFocusElement(root, { kind: "cell", pos: open })?.focus({ preventScroll: true });
252
+ }, [rootRef]);
249
253
  const spreadsheetModel = useMemo(() => ({
250
254
  rows,
251
255
  rowByKey: rowIndex,
@@ -305,6 +309,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
305
309
  rootRef,
306
310
  focusedCell,
307
311
  editingCell,
312
+ editClosing,
308
313
  editingEnabled,
309
314
  listConfig,
310
315
  rowWritable,