viewkitjs 0.38.0 → 0.40.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 (309) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/MIGRATION.md +32 -0
  3. package/fields/dist/derived.d.ts +7 -0
  4. package/fields/dist/derived.js +4 -0
  5. package/fields/dist/index.d.ts +1 -1
  6. package/fields/dist/index.js +1 -1
  7. package/fields/dist/messages.d.ts +5 -1
  8. package/fields/dist/messages.js +3 -0
  9. package/fields/dist/query/evaluate.d.ts +7 -1
  10. package/fields/dist/query/evaluate.js +8 -5
  11. package/fields/dist/query/figure-kinds.d.ts +2 -2
  12. package/fields/dist/query/figure-kinds.js +3 -0
  13. package/fields/dist/query/figures.d.ts +5 -3
  14. package/fields/dist/query/figures.js +13 -0
  15. package/fields/dist/query/filter.d.ts +7 -0
  16. package/fields/dist/query/filter.js +7 -1
  17. package/fields/dist/query/kit.d.ts +3 -2
  18. package/fields/dist/query/kit.js +1 -1
  19. package/fields/dist/query/layer.d.ts +6 -0
  20. package/fields/dist/query/layer.js +3 -0
  21. package/fields/dist/query/number.d.ts +3 -2
  22. package/fields/dist/query/number.js +5 -3
  23. package/fields/dist/query/read-rule.d.ts +1 -1
  24. package/fields/dist/query/read-rule.js +3 -0
  25. package/fields/docs/guides/queries.md +28 -24
  26. package/fields/docs/reference/fields.md +1 -0
  27. package/fields/docs/reference/query.md +9 -7
  28. package/package.json +2 -4
  29. package/postgres/dist/check.js +3 -1
  30. package/postgres/dist/definitions/storage.d.ts +3 -1
  31. package/postgres/dist/definitions/storage.js +3 -1
  32. package/postgres/dist/definitions/stored.js +13 -2
  33. package/postgres/dist/map.d.ts +5 -1
  34. package/postgres/dist/map.js +4 -0
  35. package/postgres/dist/records.js +6 -1
  36. package/postgres/docs/guides/definitions.md +1 -1
  37. package/postgres/docs/guides/field-map.md +3 -3
  38. package/postgres/docs/reference/postgres.md +1 -1
  39. package/views/dist/atoms/HeaderChrome.d.ts +7 -0
  40. package/views/dist/atoms/HeaderChrome.js +15 -0
  41. package/views/dist/atoms/ToolbarButton.d.ts +1 -1
  42. package/views/dist/atoms/ToolbarButton.js +2 -2
  43. package/views/dist/atoms/defaults.js +4 -0
  44. package/views/dist/atoms/types.d.ts +39 -2
  45. package/views/dist/contract.d.ts +38 -9
  46. package/views/dist/contract.js +64 -6
  47. package/views/dist/controls/avatar.css +1 -1
  48. package/views/dist/controls/customize/map-customize-body.js +1 -1
  49. package/views/dist/controls/field/field.d.ts +2 -14
  50. package/views/dist/controls/field/field.js +4 -9
  51. package/views/dist/controls/field/looks.d.ts +1 -1
  52. package/views/dist/controls/field/looks.js +7 -3
  53. package/views/dist/controls/field/tokens.d.ts +4 -0
  54. package/views/dist/controls/field/tokens.js +1 -0
  55. package/views/dist/controls/field.css +33 -0
  56. package/views/dist/controls/filter-editor/block.d.ts +3 -1
  57. package/views/dist/controls/filter-editor/block.js +4 -3
  58. package/views/dist/controls/filter-editor/filter-editor.d.ts +15 -2
  59. package/views/dist/controls/filter-editor/filter-editor.js +49 -16
  60. package/views/dist/controls/filter-editor/how.d.ts +11 -1
  61. package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
  62. package/views/dist/controls/filter-editor/map-filter-body.js +21 -11
  63. package/views/dist/controls/filter-editor/map-rules.d.ts +6 -4
  64. package/views/dist/controls/filter-editor/map-rules.js +7 -4
  65. package/views/dist/controls/filter-editor/parts.d.ts +14 -1
  66. package/views/dist/controls/filter-editor/parts.js +14 -0
  67. package/views/dist/controls/filter-editor.css +4 -1
  68. package/views/dist/controls/index.d.ts +0 -3
  69. package/views/dist/controls/index.js +0 -3
  70. package/views/dist/controls/input.css +1 -1
  71. package/views/dist/controls/internal/menu-items.d.ts +2 -0
  72. package/views/dist/controls/internal/menu-items.js +1 -1
  73. package/views/dist/controls/internal/part-slot.d.ts +1 -1
  74. package/views/dist/controls/internal/part-slot.js +1 -1
  75. package/views/dist/controls/internal/row-actions.d.ts +33 -0
  76. package/views/dist/controls/internal/row-actions.js +28 -0
  77. package/views/dist/controls/menu/map-menu.js +1 -1
  78. package/views/dist/controls/menu-list.css +1 -1
  79. package/views/dist/controls/picker/looks.d.ts +1 -1
  80. package/views/dist/controls/picker.css +2 -2
  81. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  82. package/views/dist/controls/popover/map-popover.js +2 -2
  83. package/views/dist/controls/press.css +0 -1
  84. package/views/dist/controls/radio/radio.d.ts +1 -1
  85. package/views/dist/controls/radio/radio.js +1 -16
  86. package/views/dist/controls/sheet/bottom-sheet.d.ts +2 -2
  87. package/views/dist/controls/sheet/bottom-sheet.js +31 -24
  88. package/views/dist/controls/sheet/map-sheet.js +9 -6
  89. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  90. package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
  91. package/views/dist/controls/sort-editor/sort-editor.js +41 -13
  92. package/views/dist/controls/text-editor.css +22 -0
  93. package/views/dist/controls/tokens.js +0 -6
  94. package/views/dist/controls/toolbar/toolbar.js +2 -2
  95. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
  96. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
  97. package/views/dist/editors/EditorPanel.js +1 -1
  98. package/views/dist/field-row/FieldRow.js +38 -16
  99. package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
  100. package/views/dist/field-row/editors/RowDateEditor.js +3 -1
  101. package/views/dist/field-row/editors/RowNameEditor.js +3 -1
  102. package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
  103. package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
  104. package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
  105. package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
  106. package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
  107. package/views/dist/field-row/editors/RowTextEditor.js +28 -4
  108. package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
  109. package/views/dist/field-row/editors/row-place.d.ts +33 -0
  110. package/views/dist/field-row/editors/row-place.js +141 -0
  111. package/views/dist/field-row/field-row-button.d.ts +9 -6
  112. package/views/dist/field-row/field-row-button.js +3 -3
  113. package/views/dist/field-row/row-target.d.ts +4 -1
  114. package/views/dist/field-row/row-target.js +1 -1
  115. package/views/dist/filters/duration-bound.d.ts +7 -0
  116. package/views/dist/filters/duration-bound.js +9 -0
  117. package/views/dist/filters/filter-model.d.ts +4 -0
  118. package/views/dist/filters/number-refused.d.ts +8 -0
  119. package/views/dist/filters/number-refused.js +4 -0
  120. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
  121. package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
  122. package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
  123. package/views/dist/grid/chrome/GridFooter.js +11 -9
  124. package/views/dist/grid/chrome/GridHeader.js +4 -3
  125. package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
  126. package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
  127. package/views/dist/grid/chrome/GridTable.js +1 -1
  128. package/views/dist/grid/chrome/GridTableSurface.js +1 -1
  129. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
  130. package/views/dist/grid/chrome/grid-body-place.js +4 -5
  131. package/views/dist/grid/chrome/grid-figure-value.js +10 -4
  132. package/views/dist/grid/chrome/grid-table-props.d.ts +15 -4
  133. package/views/dist/grid/chrome/useGridTableInteractionModel.js +12 -2
  134. package/views/dist/grid/core/clipboard-model.js +42 -8
  135. package/views/dist/grid/core/commit-model.d.ts +3 -0
  136. package/views/dist/grid/core/editing-controller.d.ts +29 -1
  137. package/views/dist/grid/core/editing-controller.js +142 -12
  138. package/views/dist/grid/core/pending-reconciliation.d.ts +14 -0
  139. package/views/dist/grid/core/pending-reconciliation.js +20 -8
  140. package/views/dist/grid/core/save-path.d.ts +4 -2
  141. package/views/dist/grid/core/save-path.js +1 -1
  142. package/views/dist/grid/core/spreadsheet-operations.js +43 -5
  143. package/views/dist/grid/core/useGridEditing.d.ts +5 -1
  144. package/views/dist/grid/core/useGridEditing.js +4 -4
  145. package/views/dist/grid/core/written-alongside.d.ts +16 -0
  146. package/views/dist/grid/core/written-alongside.js +30 -0
  147. package/views/dist/grid/grid.css +8 -4
  148. package/views/dist/grid/index.d.ts +1 -1
  149. package/views/dist/grid/looks.d.ts +2 -2
  150. package/views/dist/internal/before-paint.d.ts +5 -0
  151. package/views/dist/internal/before-paint.js +17 -0
  152. package/views/dist/internal/field-rows.d.ts +0 -8
  153. package/views/dist/internal/field-rows.js +1 -3
  154. package/views/dist/internal/over-cell.d.ts +8 -0
  155. package/views/dist/internal/over-cell.js +5 -0
  156. package/views/dist/list/bar-keys.d.ts +8 -0
  157. package/views/dist/list/bar-keys.js +3 -0
  158. package/views/dist/list/bar-parts.d.ts +27 -0
  159. package/views/dist/list/bar-parts.js +38 -0
  160. package/views/dist/list/buttons/clear-save.d.ts +7 -0
  161. package/views/dist/list/buttons/clear-save.js +19 -0
  162. package/views/dist/list/buttons/customize.d.ts +28 -0
  163. package/views/dist/list/buttons/customize.js +31 -0
  164. package/views/dist/list/buttons/filter.d.ts +32 -0
  165. package/views/dist/list/buttons/filter.js +60 -0
  166. package/views/dist/list/buttons/new.d.ts +18 -0
  167. package/views/dist/list/buttons/new.js +21 -0
  168. package/views/dist/list/buttons/quick.d.ts +15 -0
  169. package/views/dist/list/buttons/quick.js +24 -0
  170. package/views/dist/list/buttons/search.d.ts +18 -0
  171. package/views/dist/list/buttons/search.js +17 -0
  172. package/views/dist/list/buttons/shared.d.ts +97 -0
  173. package/views/dist/list/buttons/shared.js +137 -0
  174. package/views/dist/list/buttons/sort-filter.d.ts +6 -0
  175. package/views/dist/list/buttons/sort-filter.js +16 -0
  176. package/views/dist/list/buttons/sort.d.ts +17 -0
  177. package/views/dist/list/buttons/sort.js +34 -0
  178. package/views/dist/list/buttons/views.d.ts +21 -0
  179. package/views/dist/list/buttons/views.js +38 -0
  180. package/views/dist/list/editor-menus.d.ts +13 -0
  181. package/views/dist/list/editor-menus.js +13 -0
  182. package/views/dist/list/edits.d.ts +3 -1
  183. package/views/dist/list/index.d.ts +41 -0
  184. package/views/dist/list/index.js +19 -0
  185. package/views/dist/list/layer.d.ts +13 -3
  186. package/views/dist/list/layer.js +13 -3
  187. package/views/dist/list/line.d.ts +58 -0
  188. package/views/dist/list/line.js +229 -0
  189. package/views/dist/list/list.d.ts +7 -1
  190. package/views/dist/list/list.js +2 -2
  191. package/views/dist/list/pane-box.d.ts +6 -0
  192. package/views/dist/list/pane-box.js +15 -0
  193. package/views/dist/list/panels/customize.d.ts +8 -0
  194. package/views/dist/list/panels/customize.js +23 -0
  195. package/views/dist/list/panels/filter-bar.d.ts +12 -0
  196. package/views/dist/list/panels/filter-bar.js +73 -0
  197. package/views/dist/list/panels/filter.d.ts +8 -0
  198. package/views/dist/list/panels/filter.js +23 -0
  199. package/views/dist/list/panels/quick.d.ts +7 -0
  200. package/views/dist/list/panels/quick.js +16 -0
  201. package/views/dist/list/panels/shared.d.ts +26 -0
  202. package/views/dist/list/panels/shared.js +36 -0
  203. package/views/dist/list/panels/sort.d.ts +8 -0
  204. package/views/dist/list/panels/sort.js +19 -0
  205. package/views/dist/list/panels/views.d.ts +13 -0
  206. package/views/dist/list/panels/views.js +27 -0
  207. package/views/dist/list/ready.d.ts +35 -0
  208. package/views/dist/list/ready.js +7 -0
  209. package/views/dist/list/root-base.d.ts +19 -1
  210. package/views/dist/list/root-base.js +13 -3
  211. package/views/dist/list/root.d.ts +1 -1
  212. package/views/dist/list/root.js +2 -2
  213. package/views/dist/list/store.d.ts +29 -0
  214. package/views/dist/list/store.js +48 -2
  215. package/views/dist/list/toolbar-model.d.ts +99 -0
  216. package/views/dist/list/toolbar-model.js +195 -0
  217. package/views/dist/list/toolbar.js +142 -329
  218. package/views/dist/list/views-axis.js +15 -4
  219. package/views/dist/list/views.d.ts +1 -1
  220. package/views/dist/list/views.js +4 -1
  221. package/views/dist/looks/index.d.ts +0 -1
  222. package/views/dist/looks/index.js +0 -1
  223. package/views/dist/looks/looks.d.ts +1 -1
  224. package/views/dist/looks/pieces.js +0 -2
  225. package/views/dist/model/aggregates.d.ts +18 -8
  226. package/views/dist/model/aggregates.js +16 -22
  227. package/views/dist/model/column-filters.js +10 -3
  228. package/views/dist/model/view-rules.js +1 -0
  229. package/views/dist/panels/filter/NumberFilterBody.js +6 -8
  230. package/views/dist/panels/labels.js +7 -2
  231. package/views/dist/panels/model.d.ts +3 -0
  232. package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
  233. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  234. package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
  235. package/views/dist/panels/react/filter/filter-body.js +7 -3
  236. package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
  237. package/views/dist/panels/react/sort/SortEditor.js +4 -4
  238. package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
  239. package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
  240. package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
  241. package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +84 -0
  242. package/views/dist/panels/react/toolbar/ToolbarButton.d.ts +1 -1
  243. package/views/dist/panels/react/toolbar/ToolbarButton.js +5 -3
  244. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
  245. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
  246. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
  247. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
  248. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  249. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
  250. package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
  251. package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
  252. package/views/dist/panels/react/toolbar/context.d.ts +4 -0
  253. package/views/dist/panels/react/toolbar/context.js +1 -0
  254. package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
  255. package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
  256. package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
  257. package/views/dist/panels/react/toolbar/use-give-way.js +10 -3
  258. package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
  259. package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
  260. package/views/dist/panels/settings/filter-groups.js +12 -0
  261. package/views/dist/panels/settings/input.d.ts +11 -0
  262. package/views/dist/panels/settings/layout.js +26 -0
  263. package/views/dist/panels/settings/person.d.ts +15 -0
  264. package/views/dist/panels/settings/person.js +6 -0
  265. package/views/dist/panels/toolbar/page-resets.js +14 -3
  266. package/views/dist/provider/components.d.ts +47 -4
  267. package/views/dist/react.d.ts +1 -1
  268. package/views/dist/styles.css +116 -257
  269. package/views/dist/styles.unlayered.css +116 -257
  270. package/views/docs/contract.md +28 -18
  271. package/views/docs/controls/field.md +2 -1
  272. package/views/docs/controls/filter-editor.md +1 -1
  273. package/views/docs/controls/menu.md +1 -1
  274. package/views/docs/controls/sort-editor.md +1 -1
  275. package/views/docs/guides/atoms.md +1 -0
  276. package/views/docs/guides/looks.md +1 -1
  277. package/views/docs/guides/the-grid.md +6 -4
  278. package/views/docs/guides/toolbar-parts.md +337 -0
  279. package/views/docs/index.md +4 -0
  280. package/views/docs/reference/controls.md +6 -44
  281. package/views/docs/reference/field-row.md +1 -1
  282. package/views/docs/reference/grid.md +8 -7
  283. package/views/docs/reference/list.md +184 -11
  284. package/views/docs/reference/looks.md +13 -16
  285. package/views/docs/reference/panels-react.md +7 -7
  286. package/views/docs/reference/panels.md +1 -1
  287. package/views/docs/reference/react.md +14 -11
  288. package/views/docs/reference/views.md +9 -7
  289. package/views/skills/views/SKILL.md +2 -1
  290. package/views/dist/controls/setting-row/looks.d.ts +0 -10
  291. package/views/dist/controls/setting-row/looks.js +0 -22
  292. package/views/dist/controls/setting-row/setting-row.d.ts +0 -102
  293. package/views/dist/controls/setting-row/setting-row.js +0 -135
  294. package/views/dist/controls/setting-row/tokens.d.ts +0 -156
  295. package/views/dist/controls/setting-row/tokens.js +0 -41
  296. package/views/dist/controls/setting-row.css +0 -216
  297. package/views/dist/controls/switch-row/switch-row.d.ts +0 -1
  298. package/views/dist/controls/switch-row/switch-row.js +0 -1
  299. package/views/dist/controls/switch-row/tokens.d.ts +0 -39
  300. package/views/dist/controls/switch-row/tokens.js +0 -12
  301. package/views/dist/controls/switch-row.css +0 -35
  302. package/views/dist/controls/tag-field/tag-field.d.ts +0 -24
  303. package/views/dist/controls/tag-field/tag-field.js +0 -25
  304. package/views/dist/controls/tag-field/tokens.d.ts +0 -23
  305. package/views/dist/controls/tag-field/tokens.js +0 -8
  306. package/views/dist/controls/tag-field.css +0 -32
  307. package/views/docs/controls/setting-row.md +0 -44
  308. package/views/docs/controls/switch-row.md +0 -15
  309. package/views/docs/controls/tag-field.md +0 -11
@@ -11,5 +11,11 @@ import type { RowHostProps } from "./host.js";
11
11
  * throws the edit away. A `long` text is a paragraph, where Enter is a newline
12
12
  * and ⌘/Ctrl+Enter closes. The row's session asks whether the answer may
13
13
  * close: a refused one keeps the box open with its draft and its reason under it.
14
+ *
15
+ * UNDER THE FIELD'S LONG (`row-long: line`, read by the row as it opened, `RowLongContext`), on a computer, a long text opens on top
16
+ * of the row's box instead: the row keeps its value, one line, as the anchor, and the box stands in a popover over it, placed as the
17
+ * Field's Open places a body (`useRowBodyPlace`, over whatever that option says), the box's first line where the words were. It
18
+ * grows down over the rows below to the editor's most height (`--vk-editor-max-h`, text-editor.css), then scrolls; the row never
19
+ * moves. Its keys are the same; a press outside closes it as the popover's, a blur alone doesn't. A phone keeps its box in place.
14
20
  */
15
- export declare function RowTextEditor<Row>({ field, binding, row, initial, onAttempt, onClose, }: RowHostProps<Row, "text" | "url" | "domain" | "email" | "phone" | "rich_text">): import("react/jsx-runtime").JSX.Element;
21
+ export declare function RowTextEditor<Row>({ field, binding, row, initial, anchor, onAttempt, onClose, }: RowHostProps<Row, "text" | "url" | "domain" | "email" | "phone" | "rich_text">): import("react/jsx-runtime").JSX.Element;
@@ -1,17 +1,39 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef } from "react";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useContext, useRef, useState } from "react";
4
4
  import { acceptFieldCommit, phoneText } from "viewkitjs/fields";
5
5
  import { EditorPanel } from "../../editors/EditorPanel.js";
6
6
  import { TextEditorHost } from "../../editors/TextEditor.js";
7
7
  import { useViews } from "../../provider/context.js";
8
+ import { useDesktop } from "../../provider/desktop.js";
9
+ import { RowLongContext, useRowBodyPlace } from "./row-place.js";
8
10
  import { RowRefusal, useRowEditSession } from "./row-session.js";
9
- export function RowTextEditor({ field, binding, row, initial, onAttempt, onClose, }) {
11
+ export function RowTextEditor({ field, binding, row, initial, anchor, onAttempt, onClose, }) {
10
12
  const editorRef = useRef(null);
11
13
  const anchorRef = useRef(null);
12
14
  const baseline = field.type === "phone" ? phoneText(initial, null) : typeof initial === "string" ? initial : "";
13
15
  const long = (field.type === "text" && !!field.format?.long) || field.type === "rich_text";
14
- const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
16
+ const longLine = useContext(RowLongContext);
17
+ const desktop = useDesktop();
18
+ const [over] = useState(() => long && longLine && desktop);
19
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 }, { over: over ? "force" : "auto" });
20
+ const [edge, setEdge] = useState();
21
+ const [inBox, setInBox] = useState(false);
22
+ const onAnchor = useCallback((el) => {
23
+ anchorRef.current = el;
24
+ const box = el?.querySelector("[data-field-row-anchor]");
25
+ if (!box)
26
+ return;
27
+ if (box.closest('[data-field-row-box="box"]'))
28
+ setInBox(true);
29
+ const s = getComputedStyle(box);
30
+ const sides = [s.borderTopWidth, s.borderRightWidth, s.borderBottomWidth, s.borderLeftWidth];
31
+ if (!sides.some((w) => parseFloat(w) > 0))
32
+ return;
33
+ const most = s.getPropertyValue("--vk-editor-max-h").trim() || "calc(var(--vk-spacing) * 80)";
34
+ setEdge({ padding: sides.join(" "), "--vk-editor-max-h": `calc(${most} - ${sides[0]} - ${sides[2]})` });
35
+ }, []);
36
+ const { session, close } = useRowEditSession({ editorRef, inPlace: !over, onAttempt, onClose });
15
37
  const { conventions } = useViews();
16
38
  const region = binding.region?.(row) ?? undefined;
17
39
  const check = (text) => {
@@ -20,5 +42,7 @@ export function RowTextEditor({ field, binding, row, initial, onAttempt, onClose
20
42
  const read = acceptFieldCommit(field, text, { conventions, region, stored: initial });
21
43
  return read.ok ? null : read.reason;
22
44
  };
45
+ if (over)
46
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: onAnchor, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, panelData: { "data-field-row-long-editor": inBox ? "box" : "" }, className: "z-90 max-w-[calc(100vw-2rem)]", children: _jsx("span", { ref: onBody, style: edge ? { display: "flex", flexDirection: "column", flex: "1 1 auto", minHeight: 0, ...edge } : { display: "contents" }, children: _jsx(TextEditorHost, { ref: editorRef, type: field.type, multiline: true, initial: baseline, label: field.label, closeOnBlur: false, onRequestClose: close, check: check, region: region, escapeKeeps: session.keeps ?? false, place: "row" }) }) })] }));
23
47
  return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(TextEditorHost, { ref: editorRef, type: field.type, multiline: long, initial: baseline, label: field.label, onRequestClose: close, check: check, region: region, escapeKeeps: session.keeps ?? false, place: "row" }), _jsx(RowRefusal, { text: session.refusal })] }));
24
48
  }
@@ -7,6 +7,7 @@ import { opensAsList } from "../../model/one-value.js";
7
7
  import { ValueListEditor } from "../../editors/ValueListEditor.js";
8
8
  import { listOfOne, oneOfList } from "../../editors/values-body.js";
9
9
  import { useViews } from "../../provider/context.js";
10
+ import { useRowBodyPlace } from "./row-place.js";
10
11
  import { RowTextEditor } from "./RowTextEditor.js";
11
12
  import { useRowEditSession } from "./row-session.js";
12
13
  import { bodyPanel } from "../../editors/body-panel.js";
@@ -17,12 +18,11 @@ function RowValueListEditor({ field, binding, row, initial, anchor, onAttempt, o
17
18
  const oneRef = useRef({ resolveClose: (reason) => oneOfList(listRef.current.resolveClose(reason)) });
18
19
  const editorRef = one ? oneRef : listRef;
19
20
  const anchorRef = useRef(null);
21
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
20
22
  const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
21
- return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, chrome: "menu", className: panel.className, children: (surface) => {
23
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: (surface) => {
22
24
  const editor = (_jsx(ValueListEditor, { ref: listRef, field: field, label: field.label, initial: one ? listOfOne(initial) : initial, labels: binding.labels !== false && !one, holds: holds, allowEmpty: true, region: binding.region?.(row), escapeKeeps: session.keeps ?? false, onRequestClose: close }));
23
- if (surface !== "sheet")
24
- return editor;
25
- return _jsx("div", { className: "px-4 pb-4", children: editor });
25
+ return _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor });
26
26
  } })] }));
27
27
  }
28
28
  export function rowOpensList(field, oneValue) {
@@ -0,0 +1,33 @@
1
+ import { type CSSProperties, type RefObject } from "react";
2
+ /** The Field's Long reads `line` round the row (`data-field-row-long`, FIELD_LOOKS `row-long`), as the row read it when its editor
3
+ * opened: a long text's editor opens over the row's box, whatever the Field's Open says (RowTextEditor). */
4
+ export declare const RowLongContext: import("react").Context<boolean>;
5
+ /** Over whatever the frame says (`force`), or as the Field's Open on a frame round the rows says (`auto`). */
6
+ export type RowBodyOver = "auto" | "force";
7
+ /** What a row host hands its EditorPanel: the offsets and style it hands its popover, and the ref round its body. */
8
+ export type RowBodyPlace = {
9
+ sideOffset: number;
10
+ alignOffset: number | undefined;
11
+ /** Only over: `{ minWidth }` in px, wide enough to cover the row's box. Undefined below. */
12
+ style?: CSSProperties;
13
+ /** Set on a `display: contents` span wrapping the body inside the EditorPanel: the body the hook measures. */
14
+ onBody: (el: HTMLElement | null) => void;
15
+ };
16
+ /** A point: where a line's words start (x) and their line's middle (y). */
17
+ type Words = {
18
+ x: number;
19
+ y: number;
20
+ };
21
+ /** Where a line's words start, and their middle: the line a body marks `data-vk-first-line`; else the first, in the order drawn,
22
+ * of a typed input (its content box; a textarea's first line) and a visible, non-blank text (its line box), an aria-hidden part
23
+ * passed over. Null when nothing in it is laid out. */
24
+ export declare function firstWords(root: Element): Words | null;
25
+ /** Where a row's body opens: today's `below` offsets, or over the box (`data-field-row-open="over"` round the anchor, or
26
+ * `over: "force"`, a computer only), its first line's words on the value's. */
27
+ export declare function useRowBodyPlace(anchor: RefObject<HTMLElement | null>, below: {
28
+ sideOffset: number;
29
+ alignOffset?: number;
30
+ }, opts?: {
31
+ over?: RowBodyOver;
32
+ }): RowBodyPlace;
33
+ export {};
@@ -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)";
@@ -0,0 +1,7 @@
1
+ import type { FieldConventions } from "viewkitjs/fields";
2
+ import { type DurationUnit } from "viewkitjs/fields/query";
3
+ /** A stored bound as its box shows it: `2m 30s`, never 150000 (or 150, on a column kept in seconds); nothing for none. */
4
+ export declare function durationDraft(value: number | null | undefined, unit: DurationUnit | undefined): string;
5
+ /** What is typed in a duration's box as the bound the rule keeps, in the column's unit: `90` and `1m 30s` are 90000 ms (90 in
6
+ * seconds); null for nothing, or what reads as no duration. */
7
+ export declare function durationBound(typed: string, unit: DurationUnit | undefined, cv?: FieldConventions): number | null;
@@ -0,0 +1,9 @@
1
+ import { formatDurationMs } from "viewkitjs/fields/format/time";
2
+ import { durationUnitToMs, msToDurationUnit, parseDurationInput } from "viewkitjs/fields/query";
3
+ export function durationDraft(value, unit) {
4
+ return value == null ? "" : formatDurationMs(durationUnitToMs(value, unit));
5
+ }
6
+ export function durationBound(typed, unit, cv) {
7
+ const ms = parseDurationInput(typed, cv);
8
+ return ms == null ? null : msToDurationUnit(ms, unit);
9
+ }
@@ -116,6 +116,10 @@ export type FilterConfigNumber = FilterConfigBase & {
116
116
  * the cell holds.
117
117
  */
118
118
  durationUnit?: "ms" | "s";
119
+ /** Why a rule here that compares a number filters nothing, in words: the column's amounts are in several
120
+ * currencies. Its operators stay offered; a rule that compares one reads this as its summary and under its box,
121
+ * and Is empty / Is not empty filter as ever (`numberRuleRefused`). Absent: every rule filters. */
122
+ refused?: string;
119
123
  };
120
124
  /** A date dimension: absolute operators, a range, or a relative window. */
121
125
  export type FilterConfigDate = FilterConfigBase & {
@@ -0,0 +1,8 @@
1
+ import { type NumberFilterOperator } from "viewkitjs/fields/query";
2
+ /** Whether a number filter's rule is refused: its column says why (`refused`) and the rule compares a number. */
3
+ export declare function numberRuleRefused(filter: {
4
+ refused?: string;
5
+ value: {
6
+ operator: NumberFilterOperator;
7
+ } | null;
8
+ }): boolean;
@@ -0,0 +1,4 @@
1
+ import { comparesNumber } from "viewkitjs/fields/query";
2
+ export function numberRuleRefused(filter) {
3
+ return filter.refused !== undefined && !!filter.value && comparesNumber(filter.value.operator);
4
+ }
@@ -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));