@viewkitjs/views 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/CHANGELOG.md +571 -0
  2. package/README.md +5 -3
  3. package/dist/atoms/LoadMore.js +11 -1
  4. package/dist/atoms/RowMenu.js +5 -2
  5. package/dist/cells/cell-format.d.ts +3 -3
  6. package/dist/cells/cell-title.d.ts +1 -2
  7. package/dist/cells/cell-title.js +2 -2
  8. package/dist/cells/cell-values.js +6 -3
  9. package/dist/contract.d.ts +50 -9
  10. package/dist/contract.js +33 -5
  11. package/dist/display/converted.d.ts +19 -0
  12. package/dist/display/converted.js +12 -0
  13. package/dist/display/index.d.ts +1 -0
  14. package/dist/display/index.js +1 -0
  15. package/dist/display/link-click.d.ts +11 -0
  16. package/dist/display/link-click.js +3 -0
  17. package/dist/display/link.js +7 -3
  18. package/dist/display/multi-value.d.ts +1 -1
  19. package/dist/display/multi-value.js +1 -1
  20. package/dist/display/options.d.ts +7 -1
  21. package/dist/display/phone.js +3 -1
  22. package/dist/editors/ChipsEditor.d.ts +9 -4
  23. package/dist/editors/ChipsEditor.js +6 -2
  24. package/dist/editors/DateEditor.d.ts +21 -6
  25. package/dist/editors/DateEditor.js +118 -30
  26. package/dist/editors/EditorPanel.d.ts +61 -0
  27. package/dist/editors/EditorPanel.js +54 -0
  28. package/dist/editors/LocationEditor.d.ts +3 -0
  29. package/dist/editors/LocationEditor.js +14 -6
  30. package/dist/editors/NameEditor.d.ts +3 -0
  31. package/dist/editors/NameEditor.js +11 -7
  32. package/dist/editors/NumberEditor.d.ts +3 -0
  33. package/dist/editors/NumberEditor.js +6 -6
  34. package/dist/editors/RangeEditor.d.ts +16 -1
  35. package/dist/editors/RangeEditor.js +21 -5
  36. package/dist/editors/RelationEditor.d.ts +13 -28
  37. package/dist/editors/RelationEditor.js +17 -40
  38. package/dist/editors/RelationSetEditor.d.ts +53 -0
  39. package/dist/editors/RelationSetEditor.js +112 -0
  40. package/dist/editors/SelectEditor.d.ts +21 -3
  41. package/dist/editors/SelectEditor.js +55 -9
  42. package/dist/editors/TextEditor.d.ts +51 -0
  43. package/dist/editors/TextEditor.js +81 -0
  44. package/dist/editors/ValueListEditor.d.ts +3 -0
  45. package/dist/editors/ValueListEditor.js +4 -2
  46. package/dist/editors/edit-cores.d.ts +12 -9
  47. package/dist/editors/edit-cores.js +7 -6
  48. package/dist/editors/edit-session.d.ts +21 -11
  49. package/dist/editors/edit-session.js +19 -5
  50. package/dist/editors/keep-inside.d.ts +12 -0
  51. package/dist/editors/keep-inside.js +20 -0
  52. package/dist/editors/open-value.d.ts +21 -0
  53. package/dist/editors/open-value.js +36 -0
  54. package/dist/editors/open-values.d.ts +4 -0
  55. package/dist/editors/open-values.js +7 -0
  56. package/dist/editors/relation-kinds.d.ts +7 -0
  57. package/dist/editors/relation-kinds.js +21 -0
  58. package/dist/editors/relation-panel.d.ts +69 -0
  59. package/dist/editors/relation-panel.js +40 -0
  60. package/dist/field-row/FieldNoteLine.d.ts +14 -0
  61. package/dist/field-row/FieldNoteLine.js +14 -0
  62. package/dist/field-row/FieldRow.d.ts +73 -0
  63. package/dist/field-row/FieldRow.js +157 -0
  64. package/dist/field-row/FieldRowLane.d.ts +19 -0
  65. package/dist/field-row/FieldRowLane.js +11 -0
  66. package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
  67. package/dist/field-row/editors/RowChipsEditor.js +25 -0
  68. package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
  69. package/dist/field-row/editors/RowDateEditor.js +18 -0
  70. package/dist/field-row/editors/RowEditor.d.ts +39 -0
  71. package/dist/field-row/editors/RowEditor.js +64 -0
  72. package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
  73. package/dist/field-row/editors/RowNameEditor.js +15 -0
  74. package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
  75. package/dist/field-row/editors/RowNumberEditor.js +18 -0
  76. package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
  77. package/dist/field-row/editors/RowPlaceEditor.js +18 -0
  78. package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
  79. package/dist/field-row/editors/RowRangeEditor.js +15 -0
  80. package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
  81. package/dist/field-row/editors/RowRelationEditor.js +77 -0
  82. package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
  83. package/dist/field-row/editors/RowSelectEditor.js +23 -0
  84. package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
  85. package/dist/field-row/editors/RowTextEditor.js +16 -0
  86. package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
  87. package/dist/field-row/editors/RowValueListEditor.js +21 -0
  88. package/dist/field-row/editors/host.d.ts +59 -0
  89. package/dist/field-row/editors/host.js +1 -0
  90. package/dist/field-row/editors/row-session.d.ts +49 -0
  91. package/dist/field-row/editors/row-session.js +49 -0
  92. package/dist/field-row/index.d.ts +5 -0
  93. package/dist/field-row/index.js +5 -0
  94. package/dist/field-row/row-target.d.ts +20 -0
  95. package/dist/field-row/row-target.js +3 -0
  96. package/dist/field-row/useFieldWrite.d.ts +45 -0
  97. package/dist/field-row/useFieldWrite.js +190 -0
  98. package/dist/field-row/useRowSettlement.d.ts +33 -0
  99. package/dist/field-row/useRowSettlement.js +23 -0
  100. package/dist/fields/binding.d.ts +6 -1
  101. package/dist/fields/binding.js +13 -6
  102. package/dist/fields/edit-core-types.d.ts +9 -9
  103. package/dist/fields/edit-core-types.js +6 -6
  104. package/dist/fields/money.d.ts +5 -0
  105. package/dist/fields/money.js +10 -0
  106. package/dist/fields/number-edit.d.ts +6 -0
  107. package/dist/fields/number-edit.js +4 -0
  108. package/dist/fields/prepare-write.js +6 -1
  109. package/dist/fields/relation-source-types.d.ts +12 -0
  110. package/dist/fields/write-target.d.ts +50 -0
  111. package/dist/fields/write-target.js +10 -0
  112. package/dist/grid/chrome/GridAddColumn.js +1 -1
  113. package/dist/grid/chrome/GridAggregateMenu.d.ts +1 -1
  114. package/dist/grid/chrome/GridAggregateMenu.js +8 -6
  115. package/dist/grid/chrome/GridCellEditors.d.ts +7 -0
  116. package/dist/grid/chrome/GridCellEditors.js +87 -16
  117. package/dist/grid/chrome/GridCellOutline.d.ts +22 -43
  118. package/dist/grid/chrome/GridCellOutline.js +2 -7
  119. package/dist/grid/chrome/GridChipsEditor.d.ts +16 -6
  120. package/dist/grid/chrome/GridChipsEditor.js +21 -26
  121. package/dist/grid/chrome/GridColumnMenu.d.ts +1 -1
  122. package/dist/grid/chrome/GridColumnMenu.js +7 -3
  123. package/dist/grid/chrome/GridDateEditor.d.ts +23 -11
  124. package/dist/grid/chrome/GridDateEditor.js +13 -25
  125. package/dist/grid/chrome/GridFooter.d.ts +12 -2
  126. package/dist/grid/chrome/GridFooter.js +10 -6
  127. package/dist/grid/chrome/GridGroupMenu.js +20 -13
  128. package/dist/grid/chrome/GridHeader.d.ts +9 -4
  129. package/dist/grid/chrome/GridHeader.js +15 -10
  130. package/dist/grid/chrome/GridLongTextEditor.d.ts +28 -9
  131. package/dist/grid/chrome/GridLongTextEditor.js +16 -74
  132. package/dist/grid/chrome/GridNameEditor.d.ts +11 -6
  133. package/dist/grid/chrome/GridNameEditor.js +12 -27
  134. package/dist/grid/chrome/GridNumberEditor.d.ts +20 -6
  135. package/dist/grid/chrome/GridNumberEditor.js +46 -20
  136. package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
  137. package/dist/grid/chrome/GridPlaceEditor.js +22 -0
  138. package/dist/grid/chrome/GridRangeEditor.d.ts +15 -5
  139. package/dist/grid/chrome/GridRangeEditor.js +16 -20
  140. package/dist/grid/chrome/GridRelationEditor.d.ts +38 -14
  141. package/dist/grid/chrome/GridRelationEditor.js +86 -24
  142. package/dist/grid/chrome/GridRow.d.ts +7 -1
  143. package/dist/grid/chrome/GridRow.js +57 -14
  144. package/dist/grid/chrome/GridRowActions.js +1 -1
  145. package/dist/grid/chrome/GridRowCells.js +18 -23
  146. package/dist/grid/chrome/GridSelectEditor.d.ts +19 -4
  147. package/dist/grid/chrome/GridSelectEditor.js +21 -27
  148. package/dist/grid/chrome/GridStructure.d.ts +9 -10
  149. package/dist/grid/chrome/GridStructure.js +10 -14
  150. package/dist/grid/chrome/GridTable.js +97 -30
  151. package/dist/grid/chrome/GridTableSurface.d.ts +39 -2
  152. package/dist/grid/chrome/GridTableSurface.js +12 -3
  153. package/dist/grid/chrome/GridTextEditor.d.ts +35 -1
  154. package/dist/grid/chrome/GridTextEditor.js +35 -37
  155. package/dist/grid/chrome/GridValueListEditor.d.ts +15 -3
  156. package/dist/grid/chrome/GridValueListEditor.js +10 -27
  157. package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
  158. package/dist/grid/chrome/cell-cut-off.js +20 -0
  159. package/dist/grid/chrome/cells.js +1 -2
  160. package/dist/grid/chrome/checks.d.ts +2 -5
  161. package/dist/grid/chrome/checks.js +15 -5
  162. package/dist/grid/chrome/editors.d.ts +1 -1
  163. package/dist/grid/chrome/editors.js +1 -1
  164. package/dist/grid/chrome/grid-cell-classes.d.ts +2 -8
  165. package/dist/grid/chrome/grid-cell-classes.js +10 -8
  166. package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
  167. package/dist/grid/chrome/grid-cell-link.js +9 -0
  168. package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
  169. package/dist/grid/chrome/grid-edit-session.js +118 -0
  170. package/dist/grid/chrome/grid-hover.d.ts +60 -0
  171. package/dist/grid/chrome/grid-hover.js +81 -0
  172. package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
  173. package/dist/grid/chrome/grid-menu-focus.js +93 -0
  174. package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
  175. package/dist/grid/chrome/grid-row-menu-key.js +36 -0
  176. package/dist/grid/chrome/grid-row-props.d.ts +16 -4
  177. package/dist/grid/chrome/grid-row-window.d.ts +61 -0
  178. package/dist/grid/chrome/grid-row-window.js +212 -0
  179. package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
  180. package/dist/grid/chrome/grid-scroll-owner.js +75 -0
  181. package/dist/grid/chrome/grid-styles.d.ts +4 -1
  182. package/dist/grid/chrome/grid-styles.js +1 -0
  183. package/dist/grid/chrome/grid-table-props.d.ts +2 -3
  184. package/dist/grid/chrome/useGridFocus.d.ts +45 -0
  185. package/dist/grid/chrome/useGridFocus.js +122 -0
  186. package/dist/grid/chrome/useGridKeyboard.d.ts +21 -4
  187. package/dist/grid/chrome/useGridKeyboard.js +214 -38
  188. package/dist/grid/chrome/useGridRangeActions.d.ts +3 -1
  189. package/dist/grid/chrome/useGridRangeActions.js +17 -10
  190. package/dist/grid/chrome/useGridRangeGestures.js +68 -21
  191. package/dist/grid/chrome/useGridRowContextMenu.d.ts +4 -2
  192. package/dist/grid/chrome/useGridRowContextMenu.js +28 -2
  193. package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -1
  194. package/dist/grid/chrome/useGridScaleStyles.js +6 -7
  195. package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
  196. package/dist/grid/chrome/useGridScrollArea.js +65 -0
  197. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +28 -5
  198. package/dist/grid/chrome/useGridTableInteractionModel.js +66 -14
  199. package/dist/grid/chrome/useHeaderDragReorder.d.ts +2 -2
  200. package/dist/grid/core/clipboard-model.d.ts +2 -0
  201. package/dist/grid/core/clipboard-model.js +1 -1
  202. package/dist/grid/core/commit-model.d.ts +7 -0
  203. package/dist/grid/core/edge-scroll.d.ts +21 -0
  204. package/dist/grid/core/edge-scroll.js +23 -0
  205. package/dist/grid/core/editing-controller.d.ts +2 -1
  206. package/dist/grid/core/editing-controller.js +35 -9
  207. package/dist/grid/core/editing-model.d.ts +9 -0
  208. package/dist/grid/core/editing-model.js +12 -0
  209. package/dist/grid/core/flat-rows.d.ts +35 -0
  210. package/dist/grid/core/flat-rows.js +20 -0
  211. package/dist/grid/core/grid-aria.d.ts +27 -0
  212. package/dist/grid/core/grid-aria.js +39 -0
  213. package/dist/grid/core/grid-focus.d.ts +54 -0
  214. package/dist/grid/core/grid-focus.js +148 -0
  215. package/dist/grid/core/nav.d.ts +2 -2
  216. package/dist/grid/core/pending-reconciliation.d.ts +3 -0
  217. package/dist/grid/core/pending-reconciliation.js +5 -3
  218. package/dist/grid/core/row-window.d.ts +40 -0
  219. package/dist/grid/core/row-window.js +43 -0
  220. package/dist/grid/core/spreadsheet-operations.d.ts +17 -1
  221. package/dist/grid/core/spreadsheet-operations.js +33 -6
  222. package/dist/grid/core/useGridEditing.d.ts +3 -0
  223. package/dist/grid/core/useGridEditing.js +6 -3
  224. package/dist/grid/core/value-equality.d.ts +23 -1
  225. package/dist/grid/core/value-equality.js +46 -0
  226. package/dist/grid/useGridTablePrefs.d.ts +0 -1
  227. package/dist/grid/useGridTablePrefs.js +1 -3
  228. package/dist/index.d.ts +1 -0
  229. package/dist/index.js +1 -0
  230. package/dist/internal/viewport.d.ts +0 -2
  231. package/dist/internal/viewport.js +0 -14
  232. package/dist/model/column-capabilities.d.ts +2 -1
  233. package/dist/model/column-capabilities.js +28 -8
  234. package/dist/model/column-from.js +3 -0
  235. package/dist/model/column-inspect.d.ts +10 -2
  236. package/dist/model/column-inspect.js +9 -0
  237. package/dist/model/column-schema.d.ts +6 -1
  238. package/dist/model/column-types.d.ts +3 -1
  239. package/dist/model/column-types.js +1 -1
  240. package/dist/model/preferences.d.ts +0 -4
  241. package/dist/model/preferences.js +0 -1
  242. package/dist/model/prefs-buckets.d.ts +0 -1
  243. package/dist/model/prefs-buckets.js +0 -3
  244. package/dist/model/render-count.d.ts +6 -0
  245. package/dist/model/render-count.js +11 -0
  246. package/dist/provider/ViewsProvider.d.ts +5 -1
  247. package/dist/provider/ViewsProvider.js +9 -3
  248. package/dist/provider/components.d.ts +19 -1
  249. package/dist/provider/components.js +4 -2
  250. package/dist/provider/context.d.ts +5 -2
  251. package/dist/provider/desktop.d.ts +9 -0
  252. package/dist/provider/desktop.js +22 -0
  253. package/dist/provider/plain-input.d.ts +8 -0
  254. package/dist/provider/plain-input.js +5 -0
  255. package/dist/react.d.ts +2 -1
  256. package/dist/react.js +1 -0
  257. package/dist/selection/SelectCheckbox.d.ts +3 -1
  258. package/dist/selection/SelectCheckbox.js +2 -2
  259. package/dist/selection/useCheckDragSelect.js +6 -5
  260. package/docs/contract.md +93 -35
  261. package/docs/guides/atoms.md +1 -1
  262. package/docs/guides/cells.md +2 -2
  263. package/docs/guides/columns.md +3 -2
  264. package/docs/guides/display.md +1 -0
  265. package/docs/guides/editors.md +71 -13
  266. package/docs/guides/the-grid.md +32 -13
  267. package/docs/guides/the-provider.md +3 -1
  268. package/docs/index.md +3 -1
  269. package/docs/install.md +1 -1
  270. package/docs/reference/cells.md +1 -1
  271. package/docs/reference/display.md +3 -1
  272. package/docs/reference/editors-chips.md +2 -2
  273. package/docs/reference/editors-date.md +3 -3
  274. package/docs/reference/editors-location.md +1 -1
  275. package/docs/reference/editors-number.md +1 -1
  276. package/docs/reference/editors-open-values.md +1 -0
  277. package/docs/reference/editors-panel.md +12 -0
  278. package/docs/reference/editors-range.md +1 -1
  279. package/docs/reference/editors-relation.md +6 -3
  280. package/docs/reference/editors-select.md +3 -2
  281. package/docs/reference/editors-session.md +4 -2
  282. package/docs/reference/editors-text.md +9 -0
  283. package/docs/reference/editors-value-list.md +1 -1
  284. package/docs/reference/editors.md +2 -2
  285. package/docs/reference/field-row.md +16 -0
  286. package/docs/reference/grid.md +3 -3
  287. package/docs/reference/react.md +8 -5
  288. package/docs/reference/views.md +36 -15
  289. package/package.json +23 -4
  290. package/skills/views/SKILL.md +4 -4
  291. package/dist/grid/chrome/useGridScrollSync.d.ts +0 -38
  292. package/dist/grid/chrome/useGridScrollSync.js +0 -176
@@ -0,0 +1,73 @@
1
+ import { type ReactNode } from "react";
2
+ import type { DisplayOptions } from "../display/options.js";
3
+ import type { FieldBinding } from "../fields/binding.js";
4
+ import type { FieldRowMenuItem } from "../fields/menus.js";
5
+ import { type FieldNote, type FieldWriteAdmission } from "../fields/write-target.js";
6
+ export type FieldRowProps<Row> = {
7
+ binding: FieldBinding<Row>;
8
+ row: Row;
9
+ /** The DISPLAY value — `binding.read(row)`, or the panel's own override. */
10
+ value: unknown;
11
+ /** The STORED value the editor opens on — `binding.editRead?.(row) ?? value`. */
12
+ editValue: unknown;
13
+ writable: boolean;
14
+ /** Disables mutation gestures without drawing a temporary permission lock. */
15
+ ready?: boolean;
16
+ /** The row this value comes from does not hold it yet: a record painted from a list's row whose own read is
17
+ * on its way. Drawn blank, never as empty; the row keeps its label, lock and disabled target. */
18
+ unread?: boolean;
19
+ /** Why this row is read-only HERE, when it is — drawn as a lock. */
20
+ refusal?: string;
21
+ /** Synchronously admits/refuses the draft, then settles an accepted write. */
22
+ onCommit: (commit: unknown) => FieldWriteAdmission<Row>;
23
+ opts?: DisplayOptions;
24
+ /** The verbs this row offers INSTEAD of an editor (see `FieldMenus`). Present,
25
+ * the row is a menu trigger whatever `writable` says — a verb is not a write,
26
+ * and the lock that would otherwise sit here is what the menu answers. */
27
+ menu?: readonly FieldRowMenuItem[];
28
+ /** A trailing note in the value's own line — the stage a won deal froze at. */
29
+ meta?: ReactNode;
30
+ /** A sentence that explains the value — drawn under it, wrapping. */
31
+ note?: string | FieldNote | null;
32
+ /** The app's own icon name for a record kind (`AppIcon`'s name), or undefined: the glyph a
33
+ * relation's candidates wear in its editor. Unanswered, they wear the field type's glyph. */
34
+ kindIcon?: (kind: string) => string | undefined;
35
+ };
36
+ /**
37
+ * THE FIELD ROW — the third host of the shared field cores (docs/guides/editors.md), after
38
+ * the grid cell and the form field: one field of a record, in its panel or page.
39
+ *
40
+ * It draws a label and the field's DISPLAY core, and on click swaps the value
41
+ * for that type's editor in place. It never moves focus in the page behind it,
42
+ * never fetches, and never knows which entity it is drawing: everything it can
43
+ * do arrives as a binding, a value and one `onCommit`.
44
+ *
45
+ * Every editor opens through `EditorPanel` and one row session: a picker as a
46
+ * popover under the value on a desktop and in the sheet on a phone, a typed
47
+ * value in its own box on every width.
48
+ *
49
+ * The frame is glyph · `w-32` label · value, so the rows of a section, and any
50
+ * hand-written row an app draws on the same frame, line up down one column.
51
+ * Under the value it may draw a NOTE — the sentence that explains it — outside
52
+ * the click target, so the value stays the thing a click edits.
53
+ */
54
+ declare function FieldRowImpl<Row>({ binding, row, value, editValue, writable, ready, unread, refusal, onCommit, opts, menu, meta, note, kindIcon, }: FieldRowProps<Row>): import("react/jsx-runtime").JSX.Element;
55
+ /**
56
+ * Memoized — with an honest account of what that buys, which is less than it
57
+ * looks. `editing` and `pending` are the row's OWN state, so one row writing
58
+ * never re-renders its twenty siblings; the memo can only pay when the HOST
59
+ * re-renders, and then only for rows whose every prop compares equal.
60
+ *
61
+ * From a panel that builds `onCommit` as an inline closure
62
+ * per render, none do, and a list-valued `read` hands over a fresh array besides — so
63
+ * the comparison never succeeds from such a host, and this is one shallow compare
64
+ * that always falls through. It is kept because it costs that and nothing more,
65
+ * and because a host that does hold its callbacks stable gets the win without
66
+ * the row changing — not because any host provides that stability. Making the
67
+ * panel provide it means per-key memoised callbacks, i.e. a change to the row's
68
+ * contract for a residual too narrow to be worth it.
69
+ *
70
+ * The cast restores the generic that `memo` erases.
71
+ */
72
+ export declare const FieldRow: typeof FieldRowImpl;
73
+ export {};
@@ -0,0 +1,157 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { memo, useEffect, useRef, useState } from "react";
4
+ import { optimisticDisplay, phoneText, presentedDef, resolveFieldMessage, } from "@viewkitjs/fields";
5
+ import { ConvertedFigure } from "../display/converted.js";
6
+ import { renderFieldValue } from "../display/display-cores.js";
7
+ import { cx } from "../internal/cx.js";
8
+ import { useViews } from "../provider/context.js";
9
+ import { RowEditor } from "./editors/RowEditor.js";
10
+ import { FieldNoteLine } from "./FieldNoteLine.js";
11
+ import { FieldRowLane } from "./FieldRowLane.js";
12
+ import { FieldWriteReconciliationRequired, } from "../fields/write-target.js";
13
+ import { OpenValueAction, isOpenableType } from "../editors/open-value.js";
14
+ import { FIELD_ROW_TARGET as TARGET, FIELD_ROW_TARGET_BESIDE as TARGET_BESIDE, FIELD_ROW_TARGET_UNDER as TARGET_UNDER, } from "./row-target.js";
15
+ import { settlementAttributes, useRowSettlement } from "./useRowSettlement.js";
16
+ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true, unread = false, refusal, onCommit, opts, menu, meta, note, kindIcon, }) {
17
+ const { field } = binding;
18
+ const { atoms, components, conventions, icons } = useViews();
19
+ const { CommandMenu } = atoms;
20
+ const { AppIcon } = components;
21
+ const [editing, setEditing] = useState(false);
22
+ const [pending, setPending] = useState(null);
23
+ const [error, setError] = useState(null);
24
+ const [retryDraft, setRetryDraft] = useState(null);
25
+ const settlement = useRowSettlement(row);
26
+ const message = opts?.presentation?.message ?? resolveFieldMessage;
27
+ const buttonRef = useRef(null);
28
+ const focusBack = useRef(null);
29
+ const closed = (after) => {
30
+ focusBack.current = after.focusBack ? {} : null;
31
+ setEditing(false);
32
+ };
33
+ useEffect(() => {
34
+ const armed = focusBack.current;
35
+ if (!armed || editing)
36
+ return;
37
+ const button = buttonRef.current;
38
+ if (!button) {
39
+ focusBack.current = null;
40
+ return;
41
+ }
42
+ if (button.disabled) {
43
+ if (!("left" in armed))
44
+ armed.left = document.activeElement;
45
+ return;
46
+ }
47
+ focusBack.current = null;
48
+ const active = document.activeElement;
49
+ const moved = "left" in armed && active !== armed.left && active !== null && active !== document.body;
50
+ if (!moved)
51
+ button.focus({ preventScroll: true });
52
+ }, [editing, pending, ready]);
53
+ const shown = pending && "optimistic" in pending ? pending.optimistic : value;
54
+ const isEmpty = shown == null || shown === "" || (Array.isArray(shown) && shown.length === 0);
55
+ const attempt = (resolution) => {
56
+ if (resolution.kind !== "commit")
57
+ return { accepted: true };
58
+ if (!ready)
59
+ return { accepted: false, reason: "Wait for current data before editing" };
60
+ if (pending)
61
+ return { accepted: false, reason: message({ key: "field.already-saving" }) };
62
+ const admission = onCommit(resolution.payload);
63
+ if (!admission.accepted)
64
+ return admission;
65
+ const optimistic = optimisticDisplay(field, resolution.payload);
66
+ setError(null);
67
+ setRetryDraft(null);
68
+ setPending(optimistic === undefined ? {} : { optimistic });
69
+ void admission.completion.then((receipt) => {
70
+ setPending(null);
71
+ setRetryDraft(null);
72
+ setError(null);
73
+ settlement.settle(receipt);
74
+ }, (failure) => {
75
+ setPending(null);
76
+ setRetryDraft({ commit: resolution.payload });
77
+ setError(failure instanceof FieldWriteReconciliationRequired
78
+ ? failure.warning
79
+ : failure instanceof Error && failure.name === "FieldWriteRefusal"
80
+ ? failure.message
81
+ : message({ key: "field.retry-save" }));
82
+ });
83
+ return { accepted: true };
84
+ };
85
+ const shownDef = presentedDef(field);
86
+ const fieldOwnsCurrency = shownDef.type === "currency" && "fixed" in shownDef.code;
87
+ const hasMenu = !!menu && menu.length > 0 && field.edit?.mutability === "command";
88
+ const verbsInLane = hasMenu && (field.type === "url" || field.type === "relation");
89
+ const valueInButton = !unread && ((writable && shownDef.type !== "boolean" && !hasMenu) || (hasMenu && !verbsInLane));
90
+ const singleLink = !(Array.isArray(shown) && shown.length > 1) &&
91
+ (shownDef.type === "url" ||
92
+ shownDef.type === "email" ||
93
+ shownDef.type === "phone" ||
94
+ shownDef.type === "domain");
95
+ const base = {
96
+ wrap: (shownDef.type === "text" && shownDef.format?.long) ||
97
+ shownDef.type === "rich_text" ||
98
+ shownDef.type === "location"
99
+ ? "full"
100
+ : true,
101
+ ...opts,
102
+ currency: opts?.currency ?? (fieldOwnsCurrency || unread ? undefined : binding.unit?.read(row)),
103
+ ...(valueInButton ? { slotOwnsClick: true } : {}),
104
+ };
105
+ const editsInPlace = writable && shownDef.type !== "boolean" && !hasMenu && !unread && !isEmpty;
106
+ const openType = editsInPlace && singleLink && isOpenableType(shownDef.type) ? shownDef.type : null;
107
+ const openOne = Array.isArray(shown) ? shown[0] : shown;
108
+ const openValue = openOne && typeof openOne === "object" && "value" in openOne ? openOne.value : openOne;
109
+ const openLabel = shownDef.type === "phone" ? phoneText(openValue, binding.region?.(row) ?? null) : String(openValue ?? "");
110
+ const valueOverButton = editsInPlace && shownDef.type === "rich_text" && base.wrap === "full";
111
+ const displayOpts = shownDef.type === "boolean" && writable
112
+ ? {
113
+ ...base,
114
+ onToggle: (next) => attempt({ kind: "commit", payload: next }),
115
+ booleanDisabled: !ready || !!pending,
116
+ onResolve: !ready || pending ? undefined : () => attempt({ kind: "commit", payload: false }),
117
+ }
118
+ :
119
+ valueOverButton
120
+ ? { ...base, slotOwnsClick: false }
121
+ : base;
122
+ const rowCurrency = unread || fieldOwnsCurrency ? undefined : binding.unit?.read(row);
123
+ const convertedFrom = shownDef.type === "currency" &&
124
+ typeof shown === "number" &&
125
+ !!opts?.currency &&
126
+ !!rowCurrency &&
127
+ opts.currency !== rowCurrency
128
+ ? rowCurrency
129
+ : null;
130
+ const drawn = () => {
131
+ const value = renderFieldValue(field, shown, displayOpts);
132
+ return convertedFrom ? _jsx(ConvertedFigure, { from: convertedFrom, children: value }) : value;
133
+ };
134
+ const body = unread ? null : isEmpty ? (shownDef.type === "boolean" ? (renderFieldValue(field, shown, displayOpts)) : writable ? null : (_jsx("span", { className: "text-(color:--vk-fg-subtle)", children: "\u2014" }))) : (drawn());
135
+ const TypeGlyph = icons[field.type];
136
+ const glyph = binding.icon ? (_jsx(AppIcon, { name: binding.icon, className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" })) : (_jsx(TypeGlyph, { className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" }));
137
+ const menuItems = (menu ?? []).map((item) => ({
138
+ ...item,
139
+ disabled: !ready || item.disabled,
140
+ onClick: () => {
141
+ if (ready)
142
+ item.onClick();
143
+ },
144
+ }));
145
+ const valueNode = (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: "min-w-0 wrap-break-word", children: body }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
146
+ const editButton = (className, children) => (_jsx("button", { ref: buttonRef, type: "button", "aria-label": field.label, disabled: !ready || !!pending, onClick: () => {
147
+ setError(null);
148
+ setEditing(true);
149
+ }, className: className, children: children }));
150
+ return (_jsxs("div", { className: "flex items-start gap-3 border-b border-(color:--vk-border) py-2.5 last:border-0", "aria-busy": pending ? "true" : undefined, children: [_jsx("span", { className: "flex h-5 w-3.5 shrink-0 items-center justify-center", children: glyph }), _jsx("span", { className: "w-32 shrink-0 text-sm leading-5 text-(color:--vk-fg-subtle)", children: field.label }), _jsxs("div", { className: cx("min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, shown: shown, conversion: convertedFrom ? body : undefined, anchor: _jsx("span", { className: cx(TARGET, "bg-(color:--vk-neutral)"), children: valueNode }), onAttempt: attempt, onClose: closed, message: message, kindIcon: kindIcon }) })) : hasMenu && !verbsInLane ? (_jsx(CommandMenu, { trigger: _jsx("button", { type: "button", "aria-label": field.label, className: TARGET, disabled: !ready, children: valueNode }), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton ? (_jsxs("div", { className: "relative min-w-0", children: [editButton(cx(TARGET_UNDER, "disabled:pointer-events-none")), _jsx("span", { "data-slot": "vk-row-value-layer", className: cx("pointer-events-none relative block min-w-0 [&_a]:pointer-events-auto [&_button]:pointer-events-auto", pending && "opacity-70"), children: valueNode })] })) : openType ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [editButton(cx(TARGET_BESIDE, "disabled:pointer-events-none", pending && "opacity-70"), valueNode), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton(cx(TARGET, "disabled:pointer-events-none", pending && "opacity-70"), valueNode))) : (_jsx("span", { className: "block min-w-0", children: valueNode })), !editing && note ? (_jsx(FieldNoteLine, { note: typeof note === "string" ? { text: note } : note })) : null, !editing && error && retryDraft ? (_jsx("div", { role: "alert", className: "mt-1 text-xs text-(color:--vk-danger)", children: _jsx("button", { type: "button", onClick: () => {
151
+ setError(null);
152
+ const retried = attempt({ kind: "commit", payload: retryDraft.commit });
153
+ if (!retried.accepted)
154
+ setError(retried.reason);
155
+ }, className: "hover:underline", children: error }) })) : null] }), _jsx(FieldRowLane, { label: field.label, verbsInLane: verbsInLane, hasMenu: hasMenu, items: menuItems, ready: ready, writable: writable, refusal: refusal })] }));
156
+ }
157
+ export const FieldRow = memo(FieldRowImpl);
@@ -0,0 +1,19 @@
1
+ import type { FieldRowMenuItem } from "../fields/menus.js";
2
+ /**
3
+ * A FIELD ROW'S TRAILING LANE — the mark at the row's right edge that says how
4
+ * its value changes: the verb menu, when the value is itself a control (a URL,
5
+ * a relation) and so cannot be the menu's trigger; the ellipsis, when the value
6
+ * IS the trigger; or the lock with its reason, when the row is read-only. It is
7
+ * always drawn, at one width, so every value in the section ends on the same
8
+ * edge whether or not its row has a mark.
9
+ */
10
+ export declare function FieldRowLane({ label, verbsInLane, hasMenu, items, ready, writable, refusal, }: {
11
+ /** The FIELD's label — what the verb trigger announces. */
12
+ label: string;
13
+ verbsInLane: boolean;
14
+ hasMenu: boolean;
15
+ items: FieldRowMenuItem[];
16
+ ready: boolean;
17
+ writable: boolean;
18
+ refusal?: string;
19
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useViews } from "../provider/context.js";
4
+ export function FieldRowLane({ label, verbsInLane, hasMenu, items, ready, writable, refusal, }) {
5
+ const { atoms, icons } = useViews();
6
+ const { CommandMenu } = atoms;
7
+ const Chevron = icons.chevronDown;
8
+ const More = icons.more;
9
+ const Lock = icons.lock;
10
+ return (_jsx("span", { className: "flex h-5 w-3 shrink-0 items-center justify-center", children: verbsInLane ? (_jsx(CommandMenu, { trigger: _jsx("button", { type: "button", "aria-label": label, className: "group -m-1 p-1", disabled: !ready, children: _jsx(Chevron, { className: "h-3 w-3 text-(color:--vk-fg-subtlest) transition-colors group-hover:text-(color:--vk-fg-subtle)" }) }), items: items, align: "end" })) : hasMenu ? (_jsx(More, { className: "h-3 w-3 text-(color:--vk-fg-subtlest)" })) : !writable && refusal ? (_jsx("span", { title: refusal, className: "leading-none", children: _jsx(Lock, { className: "h-3 w-3 text-(color:--vk-fg-subtlest)" }) })) : null }));
11
+ }
@@ -0,0 +1,11 @@
1
+ import { type RowHostProps } from "./host.js";
2
+ /**
3
+ * The FIELD ROW's host around the shared `ChipsEditor` — the set is edited as
4
+ * a draft in the panel and commits ONCE, as one array: a popover on a desktop,
5
+ * the sheet on a phone (`EditorPanel`).
6
+ *
7
+ * For a set an outside click and Escape mean OPPOSITE things: an outside click
8
+ * keeps what you built, Escape discards the session. That rule is the core's
9
+ * and the panel's; this host only hands the reasons through.
10
+ */
11
+ export declare function RowChipsEditor<Row>({ field, initial, anchor, onAttempt, onClose, message, }: RowHostProps<Row, "multiselect">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { normalizerFor, optionFor } from "@viewkitjs/fields";
5
+ import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
6
+ import { ChipsEditor } from "../../editors/ChipsEditor.js";
7
+ import { EditorPanel } from "../../editors/EditorPanel.js";
8
+ import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
9
+ import { OPTION_ROW_INSET } from "./host.js";
10
+ import { useRowEditSession } from "./row-session.js";
11
+ export function RowChipsEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
12
+ const editorRef = useRef(null);
13
+ const anchorRef = useRef(null);
14
+ const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
15
+ const known = useOpenValues(field);
16
+ const values = Array.isArray(initial)
17
+ ? initial.filter((v) => typeof v === "string")
18
+ : [];
19
+ const resolve = (value) => ({
20
+ value,
21
+ label: optionFor(field, value)?.label ?? value,
22
+ color: resolveCategoryColor(value, field.options, undefined),
23
+ });
24
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offeredValues(field, known), resolve: resolve, normalize: normalizerFor(field), creatable: takesNewValues(field), onRequestClose: close, message: message }) })] }));
25
+ }
@@ -0,0 +1,16 @@
1
+ import type { RowHostProps } from "./host.js";
2
+ /**
3
+ * The FIELD ROW's host around the shared `DateEditor` — the same calendar the
4
+ * grid cell and the form field open: a popover on a desktop, the sheet on a
5
+ * phone (`EditorPanel`).
6
+ *
7
+ * TWO field types, one panel. They differ in what the row HOLDS, so they differ
8
+ * only in what this host does with the answer: a `date` is a calendar day, so
9
+ * the time the panel may have collected is trimmed off the payload and the chip
10
+ * starts empty (`timeOptional`); a `datetime` is an instant, so the commit
11
+ * always carries one — the grid's mode, preserved.
12
+ *
13
+ * A date's close rule is the core's: Escape discards; every other close commits
14
+ * the draft when it is dirty, and is nothing otherwise.
15
+ */
16
+ export declare function RowDateEditor<Row>({ field, initial, anchor, onAttempt, onClose, message, }: RowHostProps<Row, "date" | "datetime">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { DateEditor } from "../../editors/DateEditor.js";
5
+ import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { useRowEditSession } from "./row-session.js";
7
+ export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
8
+ const editorRef = useRef(null);
9
+ const anchorRef = useRef(null);
10
+ const dayOnly = field.type === "date";
11
+ const { session, close } = useRowEditSession({
12
+ editorRef,
13
+ onAttempt,
14
+ onClose,
15
+ mapPayload: (payload) => (payload === "" ? null : dayOnly ? payload.slice(0, 10) : payload),
16
+ });
17
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, chrome: "menu", className: "z-90 w-auto", children: (surface) => (_jsx(DateEditor, { ref: editorRef, initial: typeof initial === "string" && initial !== "" ? initial : undefined, timeOptional: dayOnly, dayOnly: dayOnly, clearable: !!field.nullable, fill: surface === "sheet", onRequestClose: close, message: message })) })] }));
18
+ }
@@ -0,0 +1,39 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RowEditorProps } from "./host.js";
3
+ import { RowChipsEditor } from "./RowChipsEditor.js";
4
+ import { RowDateEditor } from "./RowDateEditor.js";
5
+ import { RowNameEditor } from "./RowNameEditor.js";
6
+ import { RowNumberEditor } from "./RowNumberEditor.js";
7
+ import { RowPlaceEditor } from "./RowPlaceEditor.js";
8
+ import { RowRangeEditor } from "./RowRangeEditor.js";
9
+ import { RowRelationEditor } from "./RowRelationEditor.js";
10
+ import { RowSelectEditor } from "./RowSelectEditor.js";
11
+ import { RowTextEditor } from "./RowTextEditor.js";
12
+ import { RowListOrText } from "./RowValueListEditor.js";
13
+ export declare const ROW_HOSTS: {
14
+ select: typeof RowSelectEditor;
15
+ status: typeof RowSelectEditor;
16
+ relation: typeof RowRelationEditor;
17
+ user: typeof RowRelationEditor;
18
+ date: typeof RowDateEditor;
19
+ datetime: typeof RowDateEditor;
20
+ multiselect: typeof RowChipsEditor;
21
+ number: typeof RowNumberEditor;
22
+ percent: typeof RowNumberEditor;
23
+ currency: typeof RowNumberEditor;
24
+ range: typeof RowRangeEditor;
25
+ name: typeof RowNameEditor;
26
+ text: typeof RowTextEditor;
27
+ url: typeof RowListOrText;
28
+ domain: typeof RowListOrText;
29
+ phone: typeof RowListOrText;
30
+ rich_text: typeof RowTextEditor;
31
+ email: typeof RowListOrText;
32
+ boolean: null;
33
+ location: typeof RowPlaceEditor;
34
+ actor: null;
35
+ lookup: null;
36
+ rollup: null;
37
+ formula: null;
38
+ };
39
+ export declare function RowEditor<Row>(props: RowEditorProps<Row>): ReactNode;
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { RowChipsEditor } from "./RowChipsEditor.js";
4
+ import { RowDateEditor } from "./RowDateEditor.js";
5
+ import { RowNameEditor } from "./RowNameEditor.js";
6
+ import { RowNumberEditor } from "./RowNumberEditor.js";
7
+ import { RowPlaceEditor } from "./RowPlaceEditor.js";
8
+ import { RowRangeEditor } from "./RowRangeEditor.js";
9
+ import { RowRelationEditor } from "./RowRelationEditor.js";
10
+ import { RowSelectEditor } from "./RowSelectEditor.js";
11
+ import { RowTextEditor } from "./RowTextEditor.js";
12
+ import { RowListOrText } from "./RowValueListEditor.js";
13
+ export const ROW_HOSTS = {
14
+ select: RowSelectEditor,
15
+ status: RowSelectEditor,
16
+ relation: RowRelationEditor,
17
+ user: RowRelationEditor,
18
+ date: RowDateEditor,
19
+ datetime: RowDateEditor,
20
+ multiselect: RowChipsEditor,
21
+ number: RowNumberEditor,
22
+ percent: RowNumberEditor,
23
+ currency: RowNumberEditor,
24
+ range: RowRangeEditor,
25
+ name: RowNameEditor,
26
+ text: RowTextEditor,
27
+ url: RowListOrText,
28
+ domain: RowListOrText,
29
+ phone: RowListOrText,
30
+ rich_text: RowTextEditor,
31
+ email: RowListOrText,
32
+ boolean: null,
33
+ location: RowPlaceEditor,
34
+ actor: null,
35
+ lookup: null,
36
+ rollup: null,
37
+ formula: null,
38
+ };
39
+ function mountsHost(field) {
40
+ return ROW_HOSTS[field.type] != null;
41
+ }
42
+ function hostless(field) {
43
+ switch (field.type) {
44
+ case "boolean":
45
+ return null;
46
+ case "actor":
47
+ return null;
48
+ case "lookup":
49
+ case "rollup":
50
+ case "formula":
51
+ return null;
52
+ default: {
53
+ const unhandled = field;
54
+ throw new Error(`RowEditor: field type "${String(unhandled)}" reached the drawer with no editor`);
55
+ }
56
+ }
57
+ }
58
+ export function RowEditor(props) {
59
+ const { field } = props.binding;
60
+ if (!mountsHost(field))
61
+ return hostless(field);
62
+ const Host = ROW_HOSTS[field.type];
63
+ return _jsx(Host, { ...props, field: field });
64
+ }
@@ -0,0 +1,4 @@
1
+ import type { RowHostProps } from "./host.js";
2
+ /** The FIELD ROW's host around the shared `NameEditor` — in place, like the
3
+ * range host: three boxes replace the value where it sits, on every width. */
4
+ export declare function RowNameEditor<Row>({ field, initial, onAttempt, onClose, }: RowHostProps<Row, "name">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { isNameValue } from "@viewkitjs/fields";
5
+ import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { NameEditor } from "../../editors/NameEditor.js";
7
+ import { useViews } from "../../provider/context.js";
8
+ import { RowRefusal, useRowEditSession } from "./row-session.js";
9
+ export function RowNameEditor({ field, initial, onAttempt, onClose, }) {
10
+ const { conventions } = useViews();
11
+ const editorRef = useRef(null);
12
+ const anchorRef = useRef(null);
13
+ const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
14
+ return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(NameEditor, { ref: editorRef, initial: isNameValue(initial) ? initial : null, allowEmpty: !!field.nullable, conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal })] }));
15
+ }
@@ -0,0 +1,12 @@
1
+ import type { RowHostProps } from "./host.js";
2
+ /**
3
+ * The FIELD ROW's host around the shared `NumberEditor` — in place, on every
4
+ * width: the core replaces the row's value rather than opening a panel over it.
5
+ * Its close reasons are the keyboard's and the blur's, which the core names
6
+ * itself, and the row's session takes only the first.
7
+ *
8
+ * The commit is the core's `{ value, unit }` composite: the binding's `write`
9
+ * is what maps it onto the row's amount column and its currency column, which
10
+ * is why this host never splits it.
11
+ */
12
+ export declare function RowNumberEditor<Row>({ binding, row, field, initial, conversion, onAttempt, onClose, }: RowHostProps<Row, "number" | "percent" | "currency">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { ConversionLine } from "../../display/converted.js";
5
+ import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { NumberEditor } from "../../editors/NumberEditor.js";
7
+ import { durationUnitOf, numberEditCode, numberEditDecimals } from "../../fields/number-edit.js";
8
+ import { useViews } from "../../provider/context.js";
9
+ import { RowRefusal, useRowEditSession } from "./row-session.js";
10
+ export function RowNumberEditor({ binding, row, field, initial, conversion, onAttempt, onClose, }) {
11
+ const { conventions } = useViews();
12
+ const editorRef = useRef(null);
13
+ const anchorRef = useRef(null);
14
+ const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
15
+ const decimals = numberEditDecimals(field);
16
+ const durationUnit = durationUnitOf(field);
17
+ return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(NumberEditor, { ref: editorRef, initial: typeof initial === "number" ? initial : Number.NaN, unit: binding.unit?.read(row), unitOptions: binding.unit ? [...binding.unit.options] : undefined, code: binding.unit ? undefined : numberEditCode(field), decimals: decimals, durationUnit: durationUnit, allowEmpty: !!field.nullable, align: "start", conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1" }) : null] }));
18
+ }
@@ -0,0 +1,8 @@
1
+ import type { RowHostProps } from "./host.js";
2
+ /**
3
+ * The FIELD ROW's host around the shared `LocationEditor`. Anchored, as the grid's is: a country and its parts do
4
+ * not fit the row's line, so they open under the value, which stays on screen — a popover on a desktop, the sheet on
5
+ * a phone (`EditorPanel`). An emptied place always reaches the row, whose admission says so where the field can't be
6
+ * emptied, and the editor stays open with that sentence.
7
+ */
8
+ export declare function RowPlaceEditor<Row>({ field, initial, anchor, onAttempt, onClose, }: RowHostProps<Row, "location">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { EditorPanel } from "../../editors/EditorPanel.js";
5
+ import { LocationEditor } from "../../editors/LocationEditor.js";
6
+ import { useViews } from "../../provider/context.js";
7
+ import { useRowEditSession } from "./row-session.js";
8
+ export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, }) {
9
+ const { conventions } = useViews();
10
+ const editorRef = useRef(null);
11
+ const anchorRef = useRef(null);
12
+ const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
13
+ const place = initial && typeof initial === "object" && !Array.isArray(initial) ? initial : null;
14
+ return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, chrome: "menu", className: "z-90 w-96 max-w-[calc(100vw-2rem)] p-2", children: (surface) => {
15
+ const editor = (_jsx(LocationEditor, { ref: editorRef, field: field, initial: place, allowEmpty: true, conventions: conventions, chrome: surface === "sheet" ? "field" : "bare", onRequestClose: close }));
16
+ return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
17
+ } })] }));
18
+ }
@@ -0,0 +1,4 @@
1
+ import type { RowHostProps } from "./host.js";
2
+ /** The FIELD ROW's host around the shared `RangeEditor` — in place, like the
3
+ * number host: two boxes replace the value where it sits, on every width. */
4
+ export declare function RowRangeEditor<Row>({ field, initial, onAttempt, onClose, }: RowHostProps<Row, "range">): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { isRangeValue, rangeDecimals } from "@viewkitjs/fields";
5
+ import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { RangeEditor } from "../../editors/RangeEditor.js";
7
+ import { useViews } from "../../provider/context.js";
8
+ import { RowRefusal, useRowEditSession } from "./row-session.js";
9
+ export function RowRangeEditor({ field, initial, onAttempt, onClose, }) {
10
+ const { conventions } = useViews();
11
+ const editorRef = useRef(null);
12
+ const anchorRef = useRef(null);
13
+ const { session, close } = useRowEditSession({ editorRef, inPlace: true, onAttempt, onClose });
14
+ return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(RangeEditor, { ref: editorRef, initial: isRangeValue(initial) ? initial : null, decimals: rangeDecimals(field), allowEmpty: !!field.nullable, suffix: field.of === "percent" ? "%" : field.of === "currency" ? field.code?.fixed : undefined, align: "start", bands: field.presets, conventions: conventions, onRequestClose: close }), _jsx(RowRefusal, { text: session.refusal })] }));
15
+ }
@@ -0,0 +1,20 @@
1
+ import { type RowHostProps } from "./host.js";
2
+ /**
3
+ * The FIELD ROW's hosts around the shared relation cores — search the candidates the binding carries and pick: a
4
+ * popover on a desktop with the caret in its search, the sheet on a phone, which opens on the list with the keyboard
5
+ * down until the search is tapped (`EditorPanel`). A relation holding several records edits its set and its lead with
6
+ * the list open, and leaves as one change; one that holds one link replaces it.
7
+ *
8
+ * ## What a pick saves
9
+ *
10
+ * What the row STORES, worked out by the field (`relationStoredOf`): a bare id, a ref with the picked record's kind
11
+ * where the field stores refs, or the whole set with its lead. A member field saves the id alone.
12
+ *
13
+ * ## Why this host derives the stored link itself
14
+ *
15
+ * A relation binding's `editRead` is usually ABSENT, and that is the grid's answer rather than an oversight: the grid
16
+ * opens its editor on the DISPLAY value, the resolved `{ id, label }` object. So the row accepts ANY shape — a bare id,
17
+ * a stored ref `{ kind, id }`, a resolved value, or a list of them — and reads the links off it, rather than the
18
+ * bindings being changed for the row's convenience.
19
+ */
20
+ export declare function RowRelationEditor<Row>(props: RowHostProps<Row, "relation" | "user">): import("react/jsx-runtime").JSX.Element;