viewkitjs 0.38.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 (184) hide show
  1. package/CHANGELOG.md +69 -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 +19 -8
  17. package/views/dist/contract.js +37 -6
  18. package/views/dist/controls/field/looks.d.ts +1 -1
  19. package/views/dist/controls/field/looks.js +7 -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 +33 -0
  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/internal/menu-items.d.ts +2 -0
  32. package/views/dist/controls/internal/menu-items.js +1 -1
  33. package/views/dist/controls/internal/part-slot.d.ts +1 -1
  34. package/views/dist/controls/internal/part-slot.js +1 -1
  35. package/views/dist/controls/internal/row-actions.d.ts +33 -0
  36. package/views/dist/controls/internal/row-actions.js +28 -0
  37. package/views/dist/controls/menu/map-menu.js +1 -1
  38. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  39. package/views/dist/controls/popover/map-popover.js +2 -2
  40. package/views/dist/controls/sheet/map-sheet.js +9 -6
  41. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  42. package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
  43. package/views/dist/controls/sort-editor/sort-editor.js +41 -13
  44. package/views/dist/controls/text-editor.css +20 -0
  45. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
  46. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
  47. package/views/dist/editors/EditorPanel.js +1 -1
  48. package/views/dist/field-row/FieldRow.js +38 -16
  49. package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
  50. package/views/dist/field-row/editors/RowDateEditor.js +3 -1
  51. package/views/dist/field-row/editors/RowNameEditor.js +3 -1
  52. package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
  53. package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
  54. package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
  55. package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
  56. package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
  57. package/views/dist/field-row/editors/RowTextEditor.js +25 -4
  58. package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
  59. package/views/dist/field-row/editors/row-place.d.ts +33 -0
  60. package/views/dist/field-row/editors/row-place.js +141 -0
  61. package/views/dist/field-row/field-row-button.d.ts +9 -6
  62. package/views/dist/field-row/field-row-button.js +3 -3
  63. package/views/dist/field-row/row-target.d.ts +4 -1
  64. package/views/dist/field-row/row-target.js +1 -1
  65. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
  66. package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
  67. package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
  68. package/views/dist/grid/chrome/GridFooter.js +11 -9
  69. package/views/dist/grid/chrome/GridHeader.js +4 -3
  70. package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
  71. package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
  72. package/views/dist/grid/chrome/GridTable.js +1 -1
  73. package/views/dist/grid/chrome/GridTableSurface.js +1 -1
  74. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
  75. package/views/dist/grid/chrome/grid-body-place.js +4 -5
  76. package/views/dist/grid/chrome/grid-figure-value.js +10 -4
  77. package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
  78. package/views/dist/grid/grid.css +7 -3
  79. package/views/dist/internal/over-cell.d.ts +8 -0
  80. package/views/dist/internal/over-cell.js +5 -0
  81. package/views/dist/list/bar-keys.d.ts +5 -0
  82. package/views/dist/list/bar-keys.js +2 -0
  83. package/views/dist/list/bar-parts.d.ts +27 -0
  84. package/views/dist/list/bar-parts.js +38 -0
  85. package/views/dist/list/buttons/clear-save.d.ts +7 -0
  86. package/views/dist/list/buttons/clear-save.js +15 -0
  87. package/views/dist/list/buttons/customize.d.ts +28 -0
  88. package/views/dist/list/buttons/customize.js +31 -0
  89. package/views/dist/list/buttons/filter.d.ts +32 -0
  90. package/views/dist/list/buttons/filter.js +60 -0
  91. package/views/dist/list/buttons/new.d.ts +18 -0
  92. package/views/dist/list/buttons/new.js +9 -0
  93. package/views/dist/list/buttons/quick.d.ts +15 -0
  94. package/views/dist/list/buttons/quick.js +24 -0
  95. package/views/dist/list/buttons/search.d.ts +18 -0
  96. package/views/dist/list/buttons/search.js +17 -0
  97. package/views/dist/list/buttons/shared.d.ts +91 -0
  98. package/views/dist/list/buttons/shared.js +131 -0
  99. package/views/dist/list/buttons/sort-filter.d.ts +6 -0
  100. package/views/dist/list/buttons/sort-filter.js +16 -0
  101. package/views/dist/list/buttons/sort.d.ts +17 -0
  102. package/views/dist/list/buttons/sort.js +34 -0
  103. package/views/dist/list/buttons/views.d.ts +21 -0
  104. package/views/dist/list/buttons/views.js +36 -0
  105. package/views/dist/list/editor-menus.d.ts +13 -0
  106. package/views/dist/list/editor-menus.js +13 -0
  107. package/views/dist/list/index.d.ts +41 -0
  108. package/views/dist/list/index.js +19 -0
  109. package/views/dist/list/line.d.ts +55 -0
  110. package/views/dist/list/line.js +221 -0
  111. package/views/dist/list/pane-box.d.ts +6 -0
  112. package/views/dist/list/pane-box.js +15 -0
  113. package/views/dist/list/panels/customize.d.ts +8 -0
  114. package/views/dist/list/panels/customize.js +23 -0
  115. package/views/dist/list/panels/filter-bar.d.ts +12 -0
  116. package/views/dist/list/panels/filter-bar.js +67 -0
  117. package/views/dist/list/panels/filter.d.ts +8 -0
  118. package/views/dist/list/panels/filter.js +23 -0
  119. package/views/dist/list/panels/quick.d.ts +7 -0
  120. package/views/dist/list/panels/quick.js +16 -0
  121. package/views/dist/list/panels/shared.d.ts +25 -0
  122. package/views/dist/list/panels/shared.js +33 -0
  123. package/views/dist/list/panels/sort.d.ts +8 -0
  124. package/views/dist/list/panels/sort.js +19 -0
  125. package/views/dist/list/panels/views.d.ts +13 -0
  126. package/views/dist/list/panels/views.js +27 -0
  127. package/views/dist/list/ready.d.ts +35 -0
  128. package/views/dist/list/ready.js +7 -0
  129. package/views/dist/list/root-base.d.ts +17 -0
  130. package/views/dist/list/root-base.js +9 -1
  131. package/views/dist/list/root.js +2 -2
  132. package/views/dist/list/store.d.ts +19 -0
  133. package/views/dist/list/store.js +40 -1
  134. package/views/dist/list/toolbar-model.d.ts +95 -0
  135. package/views/dist/list/toolbar-model.js +177 -0
  136. package/views/dist/list/toolbar.js +140 -328
  137. package/views/dist/list/views-axis.js +15 -4
  138. package/views/dist/model/aggregates.d.ts +18 -8
  139. package/views/dist/model/aggregates.js +16 -22
  140. package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
  141. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  142. package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
  143. package/views/dist/panels/react/filter/filter-body.js +2 -2
  144. package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
  145. package/views/dist/panels/react/sort/SortEditor.js +4 -4
  146. package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
  147. package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
  148. package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
  149. package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +57 -0
  150. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
  151. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
  152. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
  153. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
  154. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  155. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
  156. package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
  157. package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
  158. package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
  159. package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
  160. package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
  161. package/views/dist/panels/react/toolbar/use-give-way.js +8 -1
  162. package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
  163. package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
  164. package/views/dist/panels/settings/filter-groups.js +7 -0
  165. package/views/dist/provider/components.d.ts +36 -2
  166. package/views/dist/react.d.ts +1 -1
  167. package/views/dist/styles.css +104 -1
  168. package/views/dist/styles.unlayered.css +104 -1
  169. package/views/docs/contract.md +20 -12
  170. package/views/docs/controls/field.md +1 -0
  171. package/views/docs/controls/filter-editor.md +1 -1
  172. package/views/docs/controls/menu.md +1 -1
  173. package/views/docs/controls/sort-editor.md +1 -1
  174. package/views/docs/guides/atoms.md +1 -0
  175. package/views/docs/guides/the-grid.md +2 -2
  176. package/views/docs/reference/controls.md +3 -3
  177. package/views/docs/reference/field-row.md +1 -1
  178. package/views/docs/reference/grid.md +4 -4
  179. package/views/docs/reference/list.md +168 -6
  180. package/views/docs/reference/looks.md +1 -1
  181. package/views/docs/reference/panels-react.md +7 -7
  182. package/views/docs/reference/react.md +13 -10
  183. package/views/docs/reference/views.md +8 -6
  184. package/views/skills/views/SKILL.md +2 -1
@@ -0,0 +1,141 @@
1
+ "use client";
2
+ import { createContext, useCallback, useLayoutEffect, useState } from "react";
3
+ import { overCellOffsets } from "../../internal/over-cell.js";
4
+ import { useDesktop } from "../../provider/desktop.js";
5
+ export const RowLongContext = createContext(false);
6
+ const BOX = "[data-field-row-anchor]";
7
+ const FIRST_LINE = "[data-vk-first-line]";
8
+ const TYPED = new Set(["", "text", "search", "tel", "email", "url", "number", "password"]);
9
+ const px = (value) => parseFloat(value) || 0;
10
+ function typedWords(el) {
11
+ const r = el.getBoundingClientRect();
12
+ if (r.width <= 1 || r.height <= 1)
13
+ return null;
14
+ const s = getComputedStyle(el);
15
+ const x = r.left + px(s.borderLeftWidth) + px(s.paddingLeft);
16
+ if (el instanceof HTMLInputElement)
17
+ return { x, y: r.top + r.height / 2 };
18
+ return { x, y: r.top + px(s.borderTopWidth) + px(s.paddingTop) + px(s.lineHeight) / 2 };
19
+ }
20
+ function textWords(node) {
21
+ let holder = node.parentElement;
22
+ while (holder && getComputedStyle(holder).display === "contents")
23
+ holder = holder.parentElement;
24
+ const own = holder?.getBoundingClientRect();
25
+ if (own && (own.width <= 1 || own.height <= 1))
26
+ return null;
27
+ const range = document.createRange();
28
+ range.selectNodeContents(node);
29
+ const r = range.getClientRects()[0];
30
+ return r && r.width > 1 && r.height > 1 ? { x: r.left, y: r.top + r.height / 2 } : null;
31
+ }
32
+ export function firstWords(root) {
33
+ const marked = root.querySelector(FIRST_LINE);
34
+ const from = marked ?? root;
35
+ const walk = document.createTreeWalker(from, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, {
36
+ acceptNode: (n) => n instanceof Element && n.getAttribute("aria-hidden") === "true" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT,
37
+ });
38
+ for (let n = from; n; n = walk.nextNode()) {
39
+ if (n instanceof HTMLTextAreaElement || (n instanceof HTMLInputElement && TYPED.has(n.type))) {
40
+ const at = typedWords(n);
41
+ if (at)
42
+ return at;
43
+ }
44
+ else if (n instanceof Text && n.textContent?.trim()) {
45
+ const at = textWords(n);
46
+ if (at)
47
+ return at;
48
+ }
49
+ }
50
+ return null;
51
+ }
52
+ function positionerOf(body) {
53
+ for (let el = body.parentElement; el; el = el.parentElement) {
54
+ const position = getComputedStyle(el).position;
55
+ if (position === "fixed" || position === "absolute")
56
+ return el;
57
+ }
58
+ return null;
59
+ }
60
+ function popupOf(body, positioner) {
61
+ let el = body;
62
+ while (el.parentElement && el.parentElement !== positioner)
63
+ el = el.parentElement;
64
+ return el;
65
+ }
66
+ const busy = (body) => body.querySelector('[aria-busy="true"]') !== null;
67
+ function minWidthOf(anchor, box, alignOffset) {
68
+ const left = anchor.left + alignOffset;
69
+ return box.right - left + Math.max(0, box.left - left);
70
+ }
71
+ function overBox(anchor) {
72
+ const boxEl = anchor.querySelector(BOX) ?? anchor;
73
+ const a = anchor.getBoundingClientRect(), b = boxEl.getBoundingClientRect();
74
+ const o = overCellOffsets(boxEl);
75
+ const alignOffset = b.left + o.alignOffset - a.left;
76
+ return { sideOffset: b.bottom + o.sideOffset - a.bottom, alignOffset, minWidth: minWidthOf(a, b, alignOffset) };
77
+ }
78
+ function overWords(anchor, body) {
79
+ if (busy(body))
80
+ return null;
81
+ const positioner = positionerOf(body);
82
+ if (!positioner)
83
+ return null;
84
+ const popup = popupOf(body, positioner);
85
+ const first = firstWords(body), value = firstWords(anchor);
86
+ if (!first || !value)
87
+ return null;
88
+ const drawn = popup.getBoundingClientRect();
89
+ const sx = popup.offsetWidth ? drawn.width / popup.offsetWidth : 1, sy = popup.offsetHeight ? drawn.height / popup.offsetHeight : 1;
90
+ const inset = { x: popup.offsetLeft + (first.x - drawn.left) / (sx || 1), y: popup.offsetTop + (first.y - drawn.top) / (sy || 1) };
91
+ const boxEl = anchor.querySelector(BOX) ?? anchor;
92
+ const a = anchor.getBoundingClientRect(), b = boxEl.getBoundingClientRect();
93
+ const alignOffset = value.x - inset.x - a.left;
94
+ return { sideOffset: value.y - inset.y - a.bottom, alignOffset, minWidth: minWidthOf(a, b, alignOffset) };
95
+ }
96
+ const same = (a, b) => !!a && Math.abs(a.sideOffset - b.sideOffset) < 0.01 && Math.abs(a.alignOffset - b.alignOffset) < 0.01 && Math.abs(a.minWidth - b.minWidth) < 0.01;
97
+ export function useRowBodyPlace(anchor, below, opts) {
98
+ const desktop = useDesktop();
99
+ const force = opts?.over === "force";
100
+ const [body, setBody] = useState(null);
101
+ const onBody = useCallback((el) => setBody(el), []);
102
+ const [place, setPlace] = useState(null);
103
+ const keep = useCallback((next) => setPlace((now) => (same(now, next) ? now : next)), []);
104
+ const [over, setOver] = useState(false);
105
+ useLayoutEffect(() => {
106
+ const el = anchor.current;
107
+ if (!el || !desktop)
108
+ return;
109
+ if (!force && el.closest("[data-field-row-open]")?.getAttribute("data-field-row-open") !== "over")
110
+ return;
111
+ setOver(true);
112
+ keep(overBox(el));
113
+ }, []);
114
+ useLayoutEffect(() => {
115
+ const el = anchor.current;
116
+ if (!over || !el || !body)
117
+ return;
118
+ const measure = () => {
119
+ const next = overWords(el, body);
120
+ if (next)
121
+ keep(next);
122
+ };
123
+ measure();
124
+ const positioner = positionerOf(body);
125
+ const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
126
+ if (positioner)
127
+ observer?.observe(popupOf(body, positioner));
128
+ const hold = () => stop();
129
+ const stop = () => {
130
+ observer?.disconnect();
131
+ body.removeEventListener("input", hold, true);
132
+ body.removeEventListener("keydown", hold, true);
133
+ };
134
+ body.addEventListener("input", hold, true);
135
+ body.addEventListener("keydown", hold, true);
136
+ return stop;
137
+ }, [anchor, body, over, keep]);
138
+ if (!over || !place)
139
+ return { sideOffset: below.sideOffset, alignOffset: below.alignOffset, style: undefined, onBody };
140
+ return { sideOffset: place.sideOffset, alignOffset: place.alignOffset, style: { minWidth: place.minWidth }, onBody };
141
+ }
@@ -31,15 +31,18 @@ export type FieldRowButtonDraw = {
31
31
  children?: ReactNode;
32
32
  };
33
33
  /** The row's edit target on the app's `Button`: the target's own box (padded out and pulled back by the same amount),
34
- * a height that grows with a wrapped value, and the row's own type, so the value reads as it does unpressed. */
35
- export declare const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
36
- /** The same, sharing its line with a link's open action beside it. */
37
- export declare const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
34
+ * a height that grows with a wrapped value, and the row's own type, so the value reads as it does unpressed. What the app's
35
+ * Button wraps its words in shrinks with it, so a value asked for one line ends in its "…" at the box's end. */
36
+ export declare const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
37
+ /** The same, sharing its line with a link's open action beside it. What the app's Button wraps its words in shrinks with it, so a
38
+ * long link wraps, or ends in its "…" on one line, before the action. */
39
+ export declare const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
38
40
  /** The empty target laid under a rich text, filling the value's footprint. */
39
41
  export declare const FIELD_ROW_FRAME_UNDER = "absolute -inset-x-2 -inset-y-1 h-auto w-auto p-0";
40
42
  /** In a Field rows card the target is the row's value, with no pill of its own: the card's row is what is pressed. It keeps
41
- * its own box: its cut and its phone pressing area are absolute, and would otherwise lie over the rows round it. */
42
- export declare const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
43
+ * its own box: its cut and its phone pressing area are absolute, and would otherwise lie over the rows round it. What the app's
44
+ * Button wraps its words in shrinks with it, so a value on one line is cut short of the row's ›. */
45
+ export declare const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 *:min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
43
46
  /** The same in a card, laid under a rich text: the value's whole box, no ground of its own. */
44
47
  export declare const FIELD_ROW_FRAME_ROWS_UNDER = "absolute inset-0 h-auto w-auto p-0 bg-transparent hover:bg-transparent";
45
48
  /** The same drawing as an element, for a button that carries a ref: the ref passes as a prop, never read while the
@@ -5,10 +5,10 @@ export const TARGET_KEY = {
5
5
  beside: "vk-field-row-beside",
6
6
  under: "vk-field-row-under",
7
7
  };
8
- export const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
9
- export const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
8
+ export const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
9
+ export const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
10
10
  export const FIELD_ROW_FRAME_UNDER = "absolute -inset-x-2 -inset-y-1 h-auto w-auto p-0";
11
- export const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
11
+ export const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 *:min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
12
12
  export const FIELD_ROW_FRAME_ROWS_UNDER = "absolute inset-0 h-auto w-auto p-0 bg-transparent hover:bg-transparent";
13
13
  export function FieldRowButton({ views, ...draw }) {
14
14
  return drawFieldRowButton(views, draw);
@@ -9,5 +9,8 @@
9
9
  * `py-1` top and bottom (8px) is 28px — `h-7`. `min-h-5` looks like "one line"
10
10
  * and is 12px of content once the padding is taken out, which is why an empty
11
11
  * row's hover came up visibly short of its neighbours'.
12
+ *
13
+ * It says `box-border` itself: the row wears it on the value an open picker keeps in the button's place, a span, which isn't
14
+ * border-box of its own. That span takes the button's edge too (FieldRow's `edge`), so it stands in the button's box.
12
15
  */
13
- export declare const FIELD_ROW_TARGET = "-mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
16
+ export declare const FIELD_ROW_TARGET = "box-border -mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
@@ -1 +1 @@
1
- export const FIELD_ROW_TARGET = "-mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
1
+ export const FIELD_ROW_TARGET = "box-border -mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
@@ -1,5 +1,6 @@
1
1
  import { type MouseEvent as ReactMouseEvent, type ReactElement, type Ref } from "react";
2
2
  import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
3
+ import type { ViewsMenuItem } from "../../provider/components.js";
3
4
  /** What the menu sets on the footer cell it opens from. */
4
5
  type TriggerProps = {
5
6
  ref?: Ref<HTMLElement>;
@@ -12,22 +13,22 @@ type TriggerProps = {
12
13
  "data-open"?: "";
13
14
  };
14
15
  /**
15
- * The footer cell's Calculate menu — pick the aggregate function for one
16
- * column (numeric columns get sum/avg/min/max/count; everything else
17
- * count/filled/unique; a source list's footer offers what the database answers,
18
- * handed in as `options`). The trigger is the WHOLE footer cell, passed as the
19
- * child: the map's `Menu` anchors on it, one ticked row per figure; selection
20
- * commits through the host's persisted `gridAggregates` pref.
16
+ * The footer cell's calculation picker — pick the figure for one column, from what it offers (`aggregateOptions`:
17
+ * Count on the first column, the empty and filled counts and percents elsewhere, Sum, Average, Min and Max on a
18
+ * number and money), handed in as `options`. The trigger is the WHOLE footer cell, passed as the child: the map's
19
+ * `Menu` anchors on it, above it with its right edge on the cell's on every column (Attio's), one ticked row per
20
+ * figure keyed by its kind, its rows reshaped by the app's `menus.figure` (`reshape`); selection commits through the
21
+ * host's persisted `gridAggregates` pref.
21
22
  */
22
- export declare function GridAggregateMenu<Row>({ column, options, current, onChange, align, children, }: {
23
+ export declare function GridAggregateMenu<Row>({ column, options, current, onChange, reshape, children, }: {
23
24
  column: ListColumn<Row>;
24
- /** The picks to offer — a source list's footer offers what the database
25
- * answers (`aggregateOptions(column, sourced)`). Default: the column's own. */
25
+ /** The picks to offer, as the footer works them out for the column's place (`aggregateOptions(column, sourced,
26
+ * place)`). Default: the column's own off the first column. */
26
27
  options?: ListAggregateKind[];
27
28
  current: ListAggregateKind;
28
29
  onChange: (kind: ListAggregateKind) => void;
29
- /** Match the column's alignment so the menu hugs the value. */
30
- align: "start" | "center" | "end";
30
+ /** The app's function from the picker's rows to the rows it shows (`menus.figure`, its context already handed). */
31
+ reshape?: (items: ViewsMenuItem[]) => ViewsMenuItem[];
31
32
  /** The footer cell. The menu sets its `ref`, so it must carry none of its own. */
32
33
  children: ReactElement<TriggerProps>;
33
34
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import { aggregateLabel, aggregateOptions } from "../../model/aggregates.js";
5
5
  import { columnLabel } from "../../model/column-capabilities.js";
6
6
  import { useViews } from "../../provider/context.js";
7
7
  import { useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
8
- export function GridAggregateMenu({ column, options, current, onChange, align, children, }) {
8
+ export function GridAggregateMenu({ column, options, current, onChange, reshape, children, }) {
9
9
  const [open, setOpen] = useState(false);
10
10
  const [anchor, setAnchor] = useState(null);
11
11
  useGridMenuFocus(open, anchor);
@@ -13,6 +13,7 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
13
13
  const { components, messages } = useViews();
14
14
  const { Menu } = components;
15
15
  const figures = options ?? aggregateOptions(column);
16
+ const reshaped = (items) => (reshape ? reshape(items) : items);
16
17
  const menuTrigger = cloneElement(children, {
17
18
  ref: setAnchor,
18
19
  onPointerDownCapture: press.notePress,
@@ -28,7 +29,7 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
28
29
  "aria-expanded": open,
29
30
  "data-open": open ? "" : undefined,
30
31
  });
31
- return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "bottom", align: align, label: messages({ key: "views.menus.figure-menu", values: { field: columnLabel(column) } }), items: figures.map((kind) => ({
32
+ return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "top", align: "end", "data-slot": "vk-grid-figure-menu", label: messages({ key: "views.menus.figure-menu", values: { field: columnLabel(column) } }), items: reshaped(figures.map((kind) => ({
32
33
  key: kind,
33
34
  label: aggregateLabel(kind, messages),
34
35
  checked: kind === current,
@@ -37,5 +38,5 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
37
38
  if (kind !== current)
38
39
  onChange(kind);
39
40
  },
40
- })) })] }));
41
+ }))) })] }));
41
42
  }
@@ -3,13 +3,14 @@ import type { ListGroup } from "../../grouping/types.js";
3
3
  import { type DisplayCurrency } from "../../fields/currency.js";
4
4
  import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
5
5
  import type { ListNumberFormatOverrides } from "../../model/column-format.js";
6
+ import type { GridMenus } from "./grid-table-props.js";
6
7
  /** Whether a group's footer row is drawn: when its figures can be picked, or the host hands in one of its own. The
7
8
  * keyboard and the screen reader's row numbers ask the same question the footer does. */
8
9
  export declare function gridFooterShown({ interactive, hostCells, }: {
9
10
  interactive: boolean;
10
11
  hostCells: readonly ReactNode[];
11
12
  }): boolean;
12
- export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, pageOnly, pin, verticalBorders, ariaRowIndex, ariaLevel, ariaColOffset, }: {
13
+ export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, pageOnly, pin, verticalBorders, desktop, menus, ariaRowIndex, ariaLevel, ariaColOffset, }: {
13
14
  /** What a screen reader reads (`core/grid-aria.ts`): the row's number, its level in a tree grid, and the columns
14
15
  * before the first data column (the checkbox lane). */
15
16
  ariaRowIndex?: number;
@@ -34,10 +35,17 @@ export declare function GridFooter<Row>({ group, columns, selecting, aggregates,
34
35
  * own sum is not the view's), and no column offers one. The row is still drawn, as without it. */
35
36
  pageOnly?: boolean;
36
37
  /** The grid's `pinFooter`: the row pins at the rows' box's foot (`--vk-foot-at` above its edge, set on the content
37
- * box), over the rows. `foot`, the one footer of an ungrouped grid, which also takes the space its rows leave above
38
- * it, so it stands at the foot when they don't fill the area; `group`, a group's, which closes its group. */
38
+ * box), over the rows, and is never pushed below its last row. `foot`, the one footer of an ungrouped grid,
39
+ * which on a phone also takes the space its rows leave above it, so it stands at the foot when they don't fill the
40
+ * area; `group`, a group's, which closes its group. */
39
41
  pin?: "foot" | "group";
40
42
  /** The grid's column lines (`verticalBorders`): each cell ruled on its right as the rows' cells are, the last
41
- * included, and a line under the row (its cells, its rail and its tail), pinned or not. Off: no line at all. */
43
+ * included. The line under the row (its cells, its rail and its tail) stands in every look, as does the one over it
44
+ * while rows pass under a pinned footer. */
42
45
  verticalBorders?: boolean;
46
+ /** The grid's computer form (`data-desktop`): a pinned footer follows its last row there, never pushed below it; a
47
+ * phone's one footer stands at the foot. */
48
+ desktop?: boolean;
49
+ /** The app's menus (`GridMenus`): `figure` reshapes each cell's calculation picker. */
50
+ menus?: GridMenus<Row>;
43
51
  }): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
@@ -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));
@@ -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
  }
@@ -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 } : {}),
@@ -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,16 +1,15 @@
1
1
  "use client";
2
2
  import { useLayoutEffect, useState } from "react";
3
- import { lengthPx } from "../../internal/length.js";
3
+ import { overCellOffsets } from "../../internal/over-cell.js";
4
4
  const UNDER = 4;
5
- const stepOf = (el) => lengthPx(el, "--vk-spacing");
6
5
  export function useGridBodyPlace(anchor) {
7
6
  const [at, setAt] = useState(null);
8
7
  useLayoutEffect(() => {
9
8
  const el = anchor.current;
10
9
  if (!el)
11
10
  return;
12
- const height = el.getBoundingClientRect().height, step = stepOf(el);
13
- 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));
14
13
  }, [anchor]);
15
- return at ? { sideOffset: -(at.height + at.step), alignOffset: -at.step } : { sideOffset: UNDER, alignOffset: 0 };
14
+ return at ?? { sideOffset: UNDER, alignOffset: 0 };
16
15
  }
@@ -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
  }
@@ -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;