viewkitjs 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/MIGRATION.md +7 -0
  3. package/fields/dist/query/figure-kinds.d.ts +2 -2
  4. package/fields/dist/query/figure-kinds.js +3 -0
  5. package/fields/dist/query/figures.d.ts +5 -3
  6. package/fields/dist/query/figures.js +13 -0
  7. package/fields/docs/reference/query.md +3 -3
  8. package/package.json +1 -1
  9. package/postgres/docs/guides/field-map.md +1 -1
  10. package/views/dist/atoms/HeaderChrome.d.ts +7 -0
  11. package/views/dist/atoms/HeaderChrome.js +15 -0
  12. package/views/dist/atoms/ToolbarButton.d.ts +1 -1
  13. package/views/dist/atoms/ToolbarButton.js +2 -2
  14. package/views/dist/atoms/defaults.js +4 -0
  15. package/views/dist/atoms/types.d.ts +39 -2
  16. package/views/dist/contract.d.ts +19 -8
  17. package/views/dist/contract.js +37 -6
  18. package/views/dist/controls/field/looks.d.ts +1 -1
  19. package/views/dist/controls/field/looks.js +7 -3
  20. package/views/dist/controls/field/tokens.d.ts +4 -0
  21. package/views/dist/controls/field/tokens.js +1 -0
  22. package/views/dist/controls/field.css +33 -0
  23. package/views/dist/controls/filter-editor/block.d.ts +3 -1
  24. package/views/dist/controls/filter-editor/block.js +4 -3
  25. package/views/dist/controls/filter-editor/filter-editor.d.ts +13 -2
  26. package/views/dist/controls/filter-editor/filter-editor.js +45 -15
  27. package/views/dist/controls/filter-editor/how.d.ts +3 -1
  28. package/views/dist/controls/filter-editor/map-filter-body.js +5 -4
  29. package/views/dist/controls/filter-editor/map-rules.d.ts +2 -1
  30. package/views/dist/controls/filter-editor/map-rules.js +3 -3
  31. package/views/dist/controls/internal/menu-items.d.ts +2 -0
  32. package/views/dist/controls/internal/menu-items.js +1 -1
  33. package/views/dist/controls/internal/part-slot.d.ts +1 -1
  34. package/views/dist/controls/internal/part-slot.js +1 -1
  35. package/views/dist/controls/internal/row-actions.d.ts +33 -0
  36. package/views/dist/controls/internal/row-actions.js +28 -0
  37. package/views/dist/controls/menu/map-menu.js +1 -1
  38. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  39. package/views/dist/controls/popover/map-popover.js +2 -2
  40. package/views/dist/controls/sheet/map-sheet.js +9 -6
  41. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  42. package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
  43. package/views/dist/controls/sort-editor/sort-editor.js +41 -13
  44. package/views/dist/controls/text-editor.css +20 -0
  45. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
  46. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
  47. package/views/dist/editors/EditorPanel.js +1 -1
  48. package/views/dist/field-row/FieldRow.js +38 -16
  49. package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
  50. package/views/dist/field-row/editors/RowDateEditor.js +3 -1
  51. package/views/dist/field-row/editors/RowNameEditor.js +3 -1
  52. package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
  53. package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
  54. package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
  55. package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
  56. package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
  57. package/views/dist/field-row/editors/RowTextEditor.js +25 -4
  58. package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
  59. package/views/dist/field-row/editors/row-place.d.ts +33 -0
  60. package/views/dist/field-row/editors/row-place.js +141 -0
  61. package/views/dist/field-row/field-row-button.d.ts +9 -6
  62. package/views/dist/field-row/field-row-button.js +3 -3
  63. package/views/dist/field-row/row-target.d.ts +4 -1
  64. package/views/dist/field-row/row-target.js +1 -1
  65. package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
  66. package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
  67. package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
  68. package/views/dist/grid/chrome/GridFooter.js +11 -9
  69. package/views/dist/grid/chrome/GridHeader.js +4 -3
  70. package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
  71. package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
  72. package/views/dist/grid/chrome/GridTable.js +1 -1
  73. package/views/dist/grid/chrome/GridTableSurface.js +1 -1
  74. package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
  75. package/views/dist/grid/chrome/grid-body-place.js +4 -5
  76. package/views/dist/grid/chrome/grid-figure-value.js +10 -4
  77. package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
  78. package/views/dist/grid/grid.css +7 -3
  79. package/views/dist/internal/over-cell.d.ts +8 -0
  80. package/views/dist/internal/over-cell.js +5 -0
  81. package/views/dist/list/bar-keys.d.ts +5 -0
  82. package/views/dist/list/bar-keys.js +2 -0
  83. package/views/dist/list/bar-parts.d.ts +27 -0
  84. package/views/dist/list/bar-parts.js +38 -0
  85. package/views/dist/list/buttons/clear-save.d.ts +7 -0
  86. package/views/dist/list/buttons/clear-save.js +15 -0
  87. package/views/dist/list/buttons/customize.d.ts +28 -0
  88. package/views/dist/list/buttons/customize.js +31 -0
  89. package/views/dist/list/buttons/filter.d.ts +32 -0
  90. package/views/dist/list/buttons/filter.js +60 -0
  91. package/views/dist/list/buttons/new.d.ts +18 -0
  92. package/views/dist/list/buttons/new.js +9 -0
  93. package/views/dist/list/buttons/quick.d.ts +15 -0
  94. package/views/dist/list/buttons/quick.js +24 -0
  95. package/views/dist/list/buttons/search.d.ts +18 -0
  96. package/views/dist/list/buttons/search.js +17 -0
  97. package/views/dist/list/buttons/shared.d.ts +91 -0
  98. package/views/dist/list/buttons/shared.js +131 -0
  99. package/views/dist/list/buttons/sort-filter.d.ts +6 -0
  100. package/views/dist/list/buttons/sort-filter.js +16 -0
  101. package/views/dist/list/buttons/sort.d.ts +17 -0
  102. package/views/dist/list/buttons/sort.js +34 -0
  103. package/views/dist/list/buttons/views.d.ts +21 -0
  104. package/views/dist/list/buttons/views.js +36 -0
  105. package/views/dist/list/editor-menus.d.ts +13 -0
  106. package/views/dist/list/editor-menus.js +13 -0
  107. package/views/dist/list/index.d.ts +41 -0
  108. package/views/dist/list/index.js +19 -0
  109. package/views/dist/list/line.d.ts +55 -0
  110. package/views/dist/list/line.js +221 -0
  111. package/views/dist/list/pane-box.d.ts +6 -0
  112. package/views/dist/list/pane-box.js +15 -0
  113. package/views/dist/list/panels/customize.d.ts +8 -0
  114. package/views/dist/list/panels/customize.js +23 -0
  115. package/views/dist/list/panels/filter-bar.d.ts +12 -0
  116. package/views/dist/list/panels/filter-bar.js +67 -0
  117. package/views/dist/list/panels/filter.d.ts +8 -0
  118. package/views/dist/list/panels/filter.js +23 -0
  119. package/views/dist/list/panels/quick.d.ts +7 -0
  120. package/views/dist/list/panels/quick.js +16 -0
  121. package/views/dist/list/panels/shared.d.ts +25 -0
  122. package/views/dist/list/panels/shared.js +33 -0
  123. package/views/dist/list/panels/sort.d.ts +8 -0
  124. package/views/dist/list/panels/sort.js +19 -0
  125. package/views/dist/list/panels/views.d.ts +13 -0
  126. package/views/dist/list/panels/views.js +27 -0
  127. package/views/dist/list/ready.d.ts +35 -0
  128. package/views/dist/list/ready.js +7 -0
  129. package/views/dist/list/root-base.d.ts +17 -0
  130. package/views/dist/list/root-base.js +9 -1
  131. package/views/dist/list/root.js +2 -2
  132. package/views/dist/list/store.d.ts +19 -0
  133. package/views/dist/list/store.js +40 -1
  134. package/views/dist/list/toolbar-model.d.ts +95 -0
  135. package/views/dist/list/toolbar-model.js +177 -0
  136. package/views/dist/list/toolbar.js +140 -328
  137. package/views/dist/list/views-axis.js +15 -4
  138. package/views/dist/model/aggregates.d.ts +18 -8
  139. package/views/dist/model/aggregates.js +16 -22
  140. package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
  141. package/views/dist/panels/react/filter/FilterEditor.js +2 -2
  142. package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
  143. package/views/dist/panels/react/filter/filter-body.js +2 -2
  144. package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
  145. package/views/dist/panels/react/sort/SortEditor.js +4 -4
  146. package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
  147. package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
  148. package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
  149. package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +57 -0
  150. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
  151. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
  152. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
  153. package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
  154. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
  155. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
  156. package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
  157. package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
  158. package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
  159. package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
  160. package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
  161. package/views/dist/panels/react/toolbar/use-give-way.js +8 -1
  162. package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
  163. package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
  164. package/views/dist/panels/settings/filter-groups.js +7 -0
  165. package/views/dist/provider/components.d.ts +36 -2
  166. package/views/dist/react.d.ts +1 -1
  167. package/views/dist/styles.css +104 -1
  168. package/views/dist/styles.unlayered.css +104 -1
  169. package/views/docs/contract.md +20 -12
  170. package/views/docs/controls/field.md +1 -0
  171. package/views/docs/controls/filter-editor.md +1 -1
  172. package/views/docs/controls/menu.md +1 -1
  173. package/views/docs/controls/sort-editor.md +1 -1
  174. package/views/docs/guides/atoms.md +1 -0
  175. package/views/docs/guides/the-grid.md +2 -2
  176. package/views/docs/reference/controls.md +3 -3
  177. package/views/docs/reference/field-row.md +1 -1
  178. package/views/docs/reference/grid.md +4 -4
  179. package/views/docs/reference/list.md +168 -6
  180. package/views/docs/reference/looks.md +1 -1
  181. package/views/docs/reference/panels-react.md +7 -7
  182. package/views/docs/reference/react.md +13 -10
  183. package/views/docs/reference/views.md +8 -6
  184. package/views/skills/views/SKILL.md +2 -1
@@ -101,6 +101,26 @@
101
101
  white-space: pre; overflow: hidden;
102
102
  }
103
103
 
104
+ /* ── A record's long text under the Field's Long (row-long: line, field.css), on a computer: its box stands in a popover on top of the
105
+ row's box (the popover marked data-field-row-long-editor, field-row/editors/RowTextEditor.tsx), the popover its only frame. The
106
+ box is the popover's whole content: no edge, ring or ground of its own, its words as far from its edge as the row's box holds
107
+ them (--vk-field-row-box-h and -x, undeclared 32 and 8), so its first line stands where the row's words stood. It is as tall as its
108
+ text up to the editor's most height (--vk-editor-max-h, the popover's own cap; undeclared, 320), then it scrolls. (0,5,0): over the
109
+ row's place. ─────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
110
+ .o-popover[data-field-row-long-editor] { --popover-pad: 0px; }
111
+ [data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form="computer"] {
112
+ --inline-input-row: var(--vk-field-row-box-h, calc(var(--vk-spacing) * 8)); --inline-input-edge: 0px; --inline-input-ring: 0px;
113
+ }
114
+ [data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form] .o-text-editor-box {
115
+ --inline-input-words: var(--vk-field-row-box-x, calc(var(--vk-spacing) * 2));
116
+ max-height: var(--vk-editor-max-h, calc(var(--vk-spacing) * 80)); border-radius: 0; background-color: transparent; box-shadow: none;
117
+ }
118
+ /* In place, under the Field's Action (row-action: icon, field.css), a long text's box keeps the icon's room at its end, as its
119
+ target did at rest, so its lines break where they did. */
120
+ :where([data-field-row-action="icon"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"][data-text-kind="long"] .o-text-editor-box {
121
+ padding-right: calc(var(--vk-spacing) * 8 - var(--inline-input-e));
122
+ }
123
+
104
124
  /* ── On a phone: the Input at the phone's size; long text one tall box; a phone's country in the box's start side ──── */
105
125
  .o-text-editor[data-text-form="phone"] { display: grid; }
106
126
  .o-text-editor[data-text-form="phone"] .o-text-editor-country { gap: calc(var(--vk-spacing) * 0.75); }
@@ -11,4 +11,4 @@ export declare function toolbarPartDress(part: ViewsFramePart, { current, phone,
11
11
  ground: ToolbarButtonGround;
12
12
  }): Partial<ToolbarButtonProps>;
13
13
  /** The ToolbarButton atom as the toolbar button. ViewKit's own `size` is not read: in a Toolbar a button takes its line's. */
14
- export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, expanded, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -22,7 +22,7 @@ export function toolbarPartDress(part, { current, phone, tabs, ground }) {
22
22
  case "save": return { ground: "bordered", words: "word" };
23
23
  }
24
24
  }
25
- export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }) {
25
+ export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, expanded, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }) {
26
26
  const row = React.useContext(InToolbar);
27
27
  const [el, setEl] = React.useState(null);
28
28
  const picks = useToolbarWorn(el);
@@ -33,7 +33,7 @@ export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, c
33
33
  else if (ref)
34
34
  ref.current = node;
35
35
  }, [ref]);
36
- const opens = popup ? { "aria-haspopup": popup, "aria-expanded": !!open } : {};
36
+ const opens = popup ? { "aria-haspopup": popup, "aria-expanded": !!open } : expanded !== undefined ? { "aria-expanded": expanded } : {};
37
37
  const text = children ?? (typeof word === "string" ? word : undefined);
38
38
  const said = waits && text != null ? _jsx("span", { className: "o-toolbar-button-waits", children: text }) : text;
39
39
  if (foot)
@@ -108,7 +108,7 @@ export function EditorPanel({ session, title, anchor, inPlace = false, sheetOnPh
108
108
  return editor;
109
109
  const reason = refusal ? (_jsx("p", { role: "alert", "data-slot": "vk-editor-refusal", className: cx("px-2 pb-2 text-xs text-(color:--vk-danger)", surface === "popover" && "sticky bottom-0 bg-(color:--vk-overlay)"), children: refusal })) : null;
110
110
  if (surface === "popover") {
111
- return (_jsxs(Popover, { ...popover, open: open, onOpenChange: (next, details) => {
111
+ return (_jsxs(Popover, { ...popover, ...(around ? { finalFocus: false } : {}), open: open, onOpenChange: (next, details) => {
112
112
  if (next || details?.reason === "outside-press")
113
113
  return;
114
114
  if (details?.reason === "escape-key" && escapedRef.current) {
@@ -14,13 +14,14 @@ import { useViews } from "../provider/context.js";
14
14
  import { ScreenForms } from "../internal/screen-forms.js";
15
15
  import { useDesktop } from "../provider/desktop.js";
16
16
  import { RowEditor, rowOpensSheet } from "./editors/RowEditor.js";
17
+ import { RowLongContext } from "./editors/row-place.js";
17
18
  import { drawnText } from "./drawn-text.js";
18
19
  import { FieldNoteLine } from "./FieldNoteLine.js";
19
20
  import { FieldRowCheckbox } from "./field-row-checkbox.js";
20
21
  import { FIELD_ROW_FRAME, FIELD_ROW_FRAME_BESIDE, FIELD_ROW_FRAME_ROWS, FIELD_ROW_FRAME_ROWS_UNDER, FIELD_ROW_FRAME_UNDER, FieldRowButton, drawFieldRowButton, TARGET_KEY, } from "./field-row-button.js";
21
22
  import { FieldRowLane } from "./FieldRowLane.js";
22
23
  import { FieldWriteReconciliationRequired, } from "../fields/write-target.js";
23
- import { OpenValueAction, isOpenableType } from "../editors/open-value.js";
24
+ import { OpenValueAction, isOpenableType, openValueHref } from "../editors/open-value.js";
24
25
  import { FIELD_ROW_TARGET as TARGET } from "./row-target.js";
25
26
  import { settlementAttributes, useRowSettlement } from "./useRowSettlement.js";
26
27
  import { EditLeaveContext, useEditLeaveScope } from "../editors/leave-scope.js";
@@ -57,6 +58,9 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
57
58
  const { AppIcon } = components;
58
59
  const [editing, setEditing] = useState(false);
59
60
  const [byKey, setByKey] = useState(false);
61
+ const [longLine, setLongLine] = useState(false);
62
+ const [edge, setEdge] = useState();
63
+ const [linkWords, setLinkWords] = useState(false);
60
64
  const [pending, setPending] = useState(null);
61
65
  const [error, setError] = useState(null);
62
66
  const [retryDraft, setRetryDraft] = useState(null);
@@ -192,6 +196,13 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
192
196
  booleanCheckbox: FieldRowCheckbox,
193
197
  };
194
198
  const editsInPlace = writable && shownDef.type !== "boolean" && !hasMenu && !unread && !isEmpty;
199
+ const textMark = inRows || !editsInPlace
200
+ ? undefined
201
+ : (shownDef.type === "text" && shownDef.format?.long) || shownDef.type === "rich_text"
202
+ ? "long"
203
+ : shownDef.type === "text"
204
+ ? "line"
205
+ : undefined;
195
206
  const openType = editsInPlace && singleLink && isOpenableType(shownDef.type) ? shownDef.type : null;
196
207
  const openOne = Array.isArray(shown) ? shown[0] : shown;
197
208
  const openValue = openOne && typeof openOne === "object" && "value" in openOne
@@ -200,6 +211,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
200
211
  const openLabel = shownDef.type === "phone"
201
212
  ? phoneText(openValue, binding.region?.(row) ?? null)
202
213
  : String(openValue ?? "");
214
+ const wordsLink = linkWords && !inRows && openType !== null && openValueHref(openType, openValue) !== null;
203
215
  const valueOverButton = editsInPlace && shownDef.type === "rich_text" && base.wrap === "full";
204
216
  const displayOpts = shownDef.type === "boolean" && writable
205
217
  ? {
@@ -209,7 +221,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
209
221
  onResolve: !ready || pending ? undefined : () => attempt({ kind: "commit", payload: false }),
210
222
  }
211
223
  :
212
- valueOverButton
224
+ valueOverButton || wordsLink
213
225
  ? { ...base, slotOwnsClick: false }
214
226
  : base;
215
227
  const rowCurrency = unread || fieldOwnsCurrency ? undefined : binding.unit?.read(row);
@@ -230,7 +242,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
230
242
  const TypeGlyph = icons[field.type];
231
243
  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)" }));
232
244
  const menuItems = fieldRowMenuItems(menu, ready, messages);
233
- const valueNode = (_jsxs("span", { ref: valueRef, className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: "min-w-0 wrap-break-word", children: _jsx(RelationChipSize.Provider, { value: "row", children: body }) }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
245
+ const valueNode = (_jsxs("span", { ref: valueRef, className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: base.wrap === false ? (inRows ? "min-w-0 truncate *:max-w-full" : "min-w-0 truncate") : "min-w-0 wrap-break-word", "data-field-row-text": textMark, children: _jsx(RelationChipSize.Provider, { value: "row", children: body }) }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
234
246
  const handOver = () => {
235
247
  const row = rowRef.current;
236
248
  if (!row || !buttonRef.current || document.activeElement !== buttonRef.current)
@@ -249,14 +261,19 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
249
261
  handOver();
250
262
  setError(null);
251
263
  setByKey(byKey);
264
+ setLongLine(!inRows && rowRef.current?.closest("[data-field-row-long]")?.getAttribute("data-field-row-long") === "line");
265
+ const button = buttonRef.current && getComputedStyle(buttonRef.current);
266
+ setEdge(button ? [button.borderTopWidth, button.borderRightWidth, button.borderBottomWidth, button.borderLeftWidth].map((w) => w || "0px").join(" ") : undefined);
252
267
  setEditing(true);
253
268
  };
254
269
  const action = binding.action ??
255
- ((field.type === "text" && field.format?.long) || field.type === "rich_text"
256
- ? "expand"
257
- : rowOpensSheet(field, oneValue)
258
- ? "edit"
259
- : "none");
270
+ (wordsLink
271
+ ? "edit"
272
+ : (field.type === "text" && field.format?.long) || field.type === "rich_text"
273
+ ? "expand"
274
+ : rowOpensSheet(field, oneValue)
275
+ ? "edit"
276
+ : "none");
260
277
  const Act = inRows || action === "none" ? null : icons[action];
261
278
  const actIcon = Act ? (_jsx("span", { "data-field-row-act": action, "aria-hidden": "true", className: "hidden", children: _jsx(Act, { className: "size-3.75" }) })) : null;
262
279
  const frameOf = (shape) => inRows
@@ -272,6 +289,11 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
272
289
  : FIELD_ROW_FRAME;
273
290
  const editButton = (shape, children) => (_jsx(FieldRowButton, { views: views, frame: cx(frameOf(shape), "disabled:pointer-events-none aria-disabled:pointer-events-none", shape !== "under" && pending && "opacity-70"), variant: "ghost", size: "sm", ref: buttonRef, "data-key": inRows ? undefined : TARGET_KEY[shape], "aria-label": unread || shape === "under" || !shownText ? field.label : `${field.label}, ${shownText}`, disabled: !ready, "aria-disabled": pending ? true : undefined, onClick: (event) => open(event.detail === 0), children: children }));
274
291
  const rowRef = useRef(null);
292
+ useLayoutEffect(() => {
293
+ const words = rowRef.current?.closest("[data-field-row-link]")?.getAttribute("data-field-row-link") === "words";
294
+ if (words !== linkWords)
295
+ setLinkWords(words);
296
+ });
275
297
  const downWhileEditing = useRef(false);
276
298
  const pressOpens = inRows && writable && shownDef.type !== "boolean" && !hasMenu && !unread && !editing && !pending && ready;
277
299
  const onRowPress = (event) => {
@@ -303,13 +325,13 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
303
325
  ? "o-field-row-glyph"
304
326
  : "flex h-5 w-3.5 shrink-0 items-center justify-center group-data-[form=computer]/field-row:in-data-[field-row-icon=off]:hidden", children: glyph }), _jsx("span", { className: inRows
305
327
  ? "o-field-row-label"
306
- : "text-sm leading-5 text-(color:--vk-field-row-label-fg,var(--vk-fg-subtle))", children: field.label }), _jsxs("div", { className: cx(inRows ? "min-w-0 flex-1" : "min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", !inRows && "group-data-[form=phone]/field-row:col-span-2 group-data-[form=phone]/field-row:col-start-2 group-data-[form=phone]/field-row:row-start-2", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { "data-field-row-editor": inRows ? undefined : "", children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, refused: retryDraft?.reason, shown: shown, conversion: convertedFrom ? body : undefined, anchor: inRows ? (_jsx("span", { className: "flex min-w-0", children: valueNode })) : (_jsxs("span", { className: cx(TARGET, "bg-(color:--vk-neutral)"), "data-field-row-anchor": "", children: [valueNode, actIcon] })), onAttempt: (resolution) => {
307
- watchLeaving();
308
- const answer = attempt(resolution);
309
- if (answer.accepted && leaving.current)
310
- leaving.current.exiting = true;
311
- return answer;
312
- }, onClose: closed, message: message, kindIcon: kindIcon, openedByKey: byKey }) })) : hasMenu && !verbsInLane ? (_jsx(CommandMenu, { trigger: drawFieldRowButton(views, {
328
+ : "text-sm leading-5 text-(color:--vk-field-row-label-fg,var(--vk-fg-subtle))", children: field.label }), _jsxs("div", { className: cx(inRows ? "min-w-0 flex-1" : "min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", !inRows && "group-data-[form=phone]/field-row:col-span-2 group-data-[form=phone]/field-row:col-start-2 group-data-[form=phone]/field-row:row-start-2", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { "data-field-row-editor": inRows ? undefined : "", children: _jsx(RowLongContext.Provider, { value: longLine, children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, refused: retryDraft?.reason, shown: shown, conversion: convertedFrom ? body : undefined, anchor: inRows ? (_jsx("span", { className: "flex min-w-0", children: valueNode })) : (_jsxs("span", { className: cx(TARGET, "border-solid border-transparent bg-(color:--vk-neutral)"), style: { borderWidth: edge ?? 0 }, "data-field-row-anchor": "", children: [valueNode, actIcon] })), onAttempt: (resolution) => {
329
+ watchLeaving();
330
+ const answer = attempt(resolution);
331
+ if (answer.accepted && leaving.current)
332
+ leaving.current.exiting = true;
333
+ return answer;
334
+ }, onClose: closed, message: message, kindIcon: kindIcon, openedByKey: byKey }) }) })) : hasMenu && !verbsInLane ? (_jsx(CommandMenu, { trigger: drawFieldRowButton(views, {
313
335
  frame: inRows ? FIELD_ROW_FRAME_ROWS : FIELD_ROW_FRAME,
314
336
  ...(inRows ? {} : { "data-key": TARGET_KEY.target }),
315
337
  variant: "ghost",
@@ -317,7 +339,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
317
339
  "aria-label": field.label,
318
340
  disabled: !ready,
319
341
  children: valueNode,
320
- }), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton ? (_jsxs("div", { className: "relative min-w-0", children: [editButton("under", actIcon), _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("beside", _jsxs(_Fragment, { children: [valueNode, actIcon] })), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton("target", _jsxs(_Fragment, { children: [valueNode, actIcon] })))) : (_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", "data-slot": "vk-field-retry", onClick: () => {
342
+ }), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton || wordsLink ? (_jsxs("div", { className: "relative min-w-0", "data-field-row-words": wordsLink ? "" : undefined, children: [editButton("under", actIcon), _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("beside", _jsxs(_Fragment, { children: [valueNode, actIcon] })), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton("target", _jsxs(_Fragment, { children: [valueNode, actIcon] })))) : (_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", "data-slot": "vk-field-retry", onClick: () => {
321
343
  setError(null);
322
344
  const retried = attempt({ kind: "commit", payload: retryDraft.commit });
323
345
  if (!retried.accepted)
@@ -7,12 +7,14 @@ import { ChipsEditor } from "../../editors/ChipsEditor.js";
7
7
  import { EditorPanel } from "../../editors/EditorPanel.js";
8
8
  import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
9
9
  import { OPTION_ROW_INSET } from "./host.js";
10
+ import { useRowBodyPlace } from "./row-place.js";
10
11
  import { useRowEditSession } from "./row-session.js";
11
12
  import { bodyPanel } from "../../editors/body-panel.js";
12
13
  export function RowChipsEditor({ binding, field, initial, anchor, onAttempt, onClose, message, }) {
13
14
  const panel = bodyPanel("picker", "z-90");
14
15
  const editorRef = useRef(null);
15
16
  const anchorRef = useRef(null);
17
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
16
18
  const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
17
19
  const known = useOpenValues(field);
18
20
  const values = Array.isArray(initial)
@@ -23,5 +25,5 @@ export function RowChipsEditor({ binding, field, initial, anchor, onAttempt, onC
23
25
  label: optionFor(field, value)?.label ?? value,
24
26
  color: resolveCategoryColor(value, field.options, undefined),
25
27
  });
26
- 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", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offeredValues(field, known), resolve: resolve, normalize: normalizerFor(field), creatable: takesNewValues(field), onRequestClose: close, message: message, label: field.label, addOption: binding.addOption }) })] }));
28
+ 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", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offeredValues(field, known), resolve: resolve, normalize: normalizerFor(field), creatable: takesNewValues(field), onRequestClose: close, message: message, label: field.label, addOption: binding.addOption }) }) })] }));
27
29
  }
@@ -3,10 +3,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
3
3
  import { useRef } from "react";
4
4
  import { DateEditorHost } from "../../editors/DateEditor.js";
5
5
  import { EditorPanel } from "../../editors/EditorPanel.js";
6
+ import { useRowBodyPlace } from "./row-place.js";
6
7
  import { useRowEditSession } from "./row-session.js";
7
8
  export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
8
9
  const editorRef = useRef(null);
9
10
  const anchorRef = useRef(null);
11
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
10
12
  const dayOnly = field.type === "date";
11
13
  const { session, close, sheet } = useRowEditSession({
12
14
  editorRef,
@@ -14,5 +16,5 @@ export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, mess
14
16
  onClose,
15
17
  mapPayload: (payload) => (payload === "" ? null : dayOnly ? payload.slice(0, 10) : payload),
16
18
  });
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: () => (_jsx(DateEditorHost, { ref: editorRef, label: field.label, initial: typeof initial === "string" && initial !== "" ? initial : undefined, timeOptional: dayOnly, dayOnly: dayOnly, clearable: !!field.nullable, focusDate: !sheet, onRequestClose: close, message: message })) })] }));
19
+ 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: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: "z-90 w-auto", children: () => (_jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(DateEditorHost, { ref: editorRef, label: field.label, initial: typeof initial === "string" && initial !== "" ? initial : undefined, timeOptional: dayOnly, dayOnly: dayOnly, clearable: !!field.nullable, focusDate: !sheet, onRequestClose: close, message: message }) })) })] }));
18
20
  }
@@ -5,6 +5,7 @@ import { isNameValue } from "viewkitjs/fields";
5
5
  import { EditorPanel } from "../../editors/EditorPanel.js";
6
6
  import { NameEditor } from "../../editors/NameEditor.js";
7
7
  import { useViews } from "../../provider/context.js";
8
+ import { useRowBodyPlace } from "./row-place.js";
8
9
  import { useRowEditSession } from "./row-session.js";
9
10
  import { bodyPanel } from "../../editors/body-panel.js";
10
11
  export function RowNameEditor({ field, initial, anchor, onAttempt, onClose, }) {
@@ -12,7 +13,8 @@ export function RowNameEditor({ field, initial, anchor, onAttempt, onClose, }) {
12
13
  const { conventions } = useViews();
13
14
  const editorRef = useRef(null);
14
15
  const anchorRef = useRef(null);
16
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
15
17
  const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
16
18
  const editor = (_jsx(NameEditor, { ref: editorRef, initial: isNameValue(initial) ? initial : null, allowEmpty: !!field.nullable, conventions: conventions, label: field.label, onRequestClose: close }));
17
- 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) => (surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor) })] }));
19
+ 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) => _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor }) })] }));
18
20
  }
@@ -4,6 +4,7 @@ import { useRef } from "react";
4
4
  import { EditorPanel } from "../../editors/EditorPanel.js";
5
5
  import { LocationEditor } from "../../editors/LocationEditor.js";
6
6
  import { useViews } from "../../provider/context.js";
7
+ import { useRowBodyPlace } from "./row-place.js";
7
8
  import { useRowEditSession } from "./row-session.js";
8
9
  import { bodyPanel } from "../../editors/body-panel.js";
9
10
  export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, }) {
@@ -11,10 +12,11 @@ export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, })
11
12
  const { conventions } = useViews();
12
13
  const editorRef = useRef(null);
13
14
  const anchorRef = useRef(null);
15
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
14
16
  const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
15
17
  const place = initial && typeof initial === "object" && !Array.isArray(initial) ? initial : null;
16
- 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) => {
18
+ 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) => {
17
19
  const editor = (_jsx(LocationEditor, { ref: editorRef, field: field, initial: place, allowEmpty: true, conventions: conventions, label: field.label, onRequestClose: close }));
18
- return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
20
+ return _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor });
19
21
  } })] }));
20
22
  }
@@ -6,6 +6,7 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
6
6
  import { RangeEditor } from "../../editors/RangeEditor.js";
7
7
  import { numberBounds } from "../../editors/number-body.js";
8
8
  import { useViews } from "../../provider/context.js";
9
+ import { useRowBodyPlace } from "./row-place.js";
9
10
  import { useRowEditSession } from "./row-session.js";
10
11
  import { bodyPanel } from "../../editors/body-panel.js";
11
12
  export function RowRangeEditor({ field, initial, anchor, onAttempt, onClose, }) {
@@ -13,7 +14,8 @@ export function RowRangeEditor({ field, initial, anchor, onAttempt, onClose, })
13
14
  const { conventions } = useViews();
14
15
  const editorRef = useRef(null);
15
16
  const anchorRef = useRef(null);
17
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
16
18
  const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
17
19
  const editor = (_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, bands: field.presets, ...numberBounds(field), conventions: conventions, label: field.label, onRequestClose: close }));
18
- 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) => (surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor) })] }));
20
+ 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) => _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor }) })] }));
19
21
  }
@@ -7,6 +7,7 @@ import { RelationEditor, RelationSetEditor, } from "../../editors/RelationEditor
7
7
  import { useKnownKinds } from "../../editors/relation-kinds.js";
8
8
  import { useViews } from "../../provider/context.js";
9
9
  import { OPTION_ROW_INSET } from "./host.js";
10
+ import { useRowBodyPlace } from "./row-place.js";
10
11
  import { useRowEditSession } from "./row-session.js";
11
12
  import { bodyPanel, useSetBody } from "../../editors/body-panel.js";
12
13
  export function RowRelationEditor(props) {
@@ -25,6 +26,7 @@ function RowRelationOneEditor({ binding, field, initial, anchor, onAttempt, onCl
25
26
  const panel = bodyPanel("picker", "z-90");
26
27
  const editorRef = useRef(null);
27
28
  const anchorRef = useRef(null);
29
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
28
30
  const kindGlyph = useKindGlyph(field, kindIcon);
29
31
  const [candidates, kindOf] = useKnownKinds(binding.relation ?? { kind: "static", items: [] });
30
32
  const { session, close, sheet } = useRowEditSession({
@@ -40,12 +42,13 @@ function RowRelationOneEditor({ binding, field, initial, anchor, onAttempt, onCl
40
42
  });
41
43
  if (!binding.relation)
42
44
  return null;
43
- 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", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(RelationEditor, { ref: editorRef, candidates: candidates, initial: relationIdOf(initial), clearable: !!field.nullable, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) })] }));
45
+ 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", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(RelationEditor, { ref: editorRef, candidates: candidates, initial: relationIdOf(initial), clearable: !!field.nullable, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) }) })] }));
44
46
  }
45
47
  function RowRelationSetEditor({ binding, field, initial, shown, anchor, onAttempt, onClose, message, kindIcon, }) {
46
48
  const panel = bodyPanel(useSetBody(field.links), "z-90");
47
49
  const editorRef = useRef(null);
48
50
  const anchorRef = useRef(null);
51
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
49
52
  const kindGlyph = useKindGlyph(field, kindIcon);
50
53
  const { session, close, sheet } = useRowEditSession({
51
54
  editorRef,
@@ -56,7 +59,7 @@ function RowRelationSetEditor({ binding, field, initial, shown, anchor, onAttemp
56
59
  const candidates = binding.relation;
57
60
  if (!candidates)
58
61
  return null;
59
- 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", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: setItems(field, initial, shown, candidates), lead: field.links?.primary === "flag", links: field.links, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) })] }));
62
+ 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", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: setItems(field, initial, shown, candidates), lead: field.links?.primary === "flag", links: field.links, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) }) })] }));
60
63
  }
61
64
  function setItems(field, initial, shown, candidates) {
62
65
  const labels = new Map();
@@ -7,12 +7,14 @@ import { statusSteps } from "../../display/status-steps.js";
7
7
  import { useOpenValues } from "../../editors/open-values.js";
8
8
  import { SelectEditor, pickerOptionsFromField, } from "../../editors/SelectEditor.js";
9
9
  import { OPTION_ROW_INSET } from "./host.js";
10
+ import { useRowBodyPlace } from "./row-place.js";
10
11
  import { useRowEditSession } from "./row-session.js";
11
12
  import { bodyPanel } from "../../editors/body-panel.js";
12
13
  export function RowSelectEditor({ binding, field, initial, anchor, onAttempt, onClose, message, openedByKey = false, }) {
13
14
  const panel = bodyPanel("picker", "z-90");
14
15
  const editorRef = useRef(null);
15
16
  const anchorRef = useRef(null);
17
+ const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
16
18
  const known = useOpenValues(field);
17
19
  const current = typeof initial === "string" ? initial : null;
18
20
  const options = useMemo(() => pickerOptionsFromField(field, { extraValues: known, current }), [field, known, current]);
@@ -22,5 +24,5 @@ export function RowSelectEditor({ binding, field, initial, anchor, onAttempt, on
22
24
  onClose,
23
25
  mapPayload: (payload) => (payload === "" ? null : payload),
24
26
  });
25
- 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", alignOffset: -OPTION_ROW_INSET, sideOffset: 4, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(SelectEditor, { ref: editorRef, options: options, steps: statusSteps(field), initial: current, clearable: !!field.nullable, creatable: isOpenVocabulary(field), focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, message: message, label: field.label, addOption: field.type === "select" ? binding.addOption : undefined }) })] }));
27
+ 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", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(SelectEditor, { ref: editorRef, options: options, steps: statusSteps(field), initial: current, clearable: !!field.nullable, creatable: isOpenVocabulary(field), focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, message: message, label: field.label, addOption: field.type === "select" ? binding.addOption : undefined }) }) })] }));
26
28
  }
@@ -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,36 @@
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 onAnchor = useCallback((el) => {
22
+ anchorRef.current = el;
23
+ const box = el?.querySelector("[data-field-row-anchor]");
24
+ if (!box)
25
+ return;
26
+ const s = getComputedStyle(box);
27
+ const sides = [s.borderTopWidth, s.borderRightWidth, s.borderBottomWidth, s.borderLeftWidth];
28
+ if (!sides.some((w) => parseFloat(w) > 0))
29
+ return;
30
+ const most = s.getPropertyValue("--vk-editor-max-h").trim() || "calc(var(--vk-spacing) * 80)";
31
+ setEdge({ padding: sides.join(" "), "--vk-editor-max-h": `calc(${most} - ${sides[0]} - ${sides[2]})` });
32
+ }, []);
33
+ const { session, close } = useRowEditSession({ editorRef, inPlace: !over, onAttempt, onClose });
15
34
  const { conventions } = useViews();
16
35
  const region = binding.region?.(row) ?? undefined;
17
36
  const check = (text) => {
@@ -20,5 +39,7 @@ export function RowTextEditor({ field, binding, row, initial, onAttempt, onClose
20
39
  const read = acceptFieldCommit(field, text, { conventions, region, stored: initial });
21
40
  return read.ok ? null : read.reason;
22
41
  };
42
+ if (over)
43
+ 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": "" }, 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
44
  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
45
  }
@@ -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 {};