@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
@@ -4,13 +4,19 @@ import { useMemo } from "react";
4
4
  import { resolveViewsMessage } from "../contract.js";
5
5
  import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
6
6
  import { ViewsContext } from "./context.js";
7
+ import { PlainInput } from "./plain-input.js";
7
8
  import { withSettledGroups } from "./menu-groups.js";
9
+ import { DEFAULT_DESKTOP_QUERY } from "./desktop.js";
8
10
  import { browserConfirm } from "./ports.js";
9
11
  export { useViews } from "./context.js";
10
- export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, }) {
12
+ export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, }) {
11
13
  const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
12
- const settled = useMemo(() => ({ ...components, Menu: withSettledGroups(components.Menu) }), [components]);
14
+ const settled = useMemo(() => ({
15
+ ...components,
16
+ Menu: withSettledGroups(components.Menu),
17
+ Input: components.Input ?? PlainInput,
18
+ }), [components]);
13
19
  const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
14
- const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation }), [settled, merged, conventions, icons, resolved, messages, presentation]);
20
+ const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation, desktopQuery }), [settled, merged, conventions, icons, resolved, messages, presentation, desktopQuery]);
15
21
  return _jsx(ViewsContext.Provider, { value: value, children: children });
16
22
  }
@@ -1,4 +1,4 @@
1
- import type { ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
1
+ import type { ComponentPropsWithRef, ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
2
2
  /** Where a floating part attaches: an element, a ref to one, or a point (a context menu). */
3
3
  export type ViewsAnchor = HTMLElement | RefObject<HTMLElement | null> | {
4
4
  x: number;
@@ -127,6 +127,10 @@ export type ViewsCommandParts = {
127
127
  filter?: (value: string, search: string) => number;
128
128
  /** The arrows wrap from the last item to the first and back. Default false. */
129
129
  loop?: boolean;
130
+ /** The item highlighted as the list opens, by its value. Without it, the first item; while no item has it (a
131
+ * remote page that doesn't hold it), none, until a key or typed text moves the highlight: never the first, which
132
+ * in a relation picker is None. A list that ignores it opens on its first item. */
133
+ defaultValue?: string;
130
134
  }>;
131
135
  Input: ComponentType<{
132
136
  value: string;
@@ -202,6 +206,13 @@ export type ViewsSheetProps = {
202
206
  className?: string;
203
207
  children: ReactNode;
204
208
  };
209
+ /** A single-line text box. Forward every prop to the element, `ref` included: the editors focus the
210
+ * box, place its caret and read its value through it. */
211
+ export type ViewsInputProps = Omit<ComponentPropsWithRef<"input">, "children"> & {
212
+ /** `bare`: the box draws no frame of its own (a grid cell, a panel that frames it). `field`: it
213
+ * wears the app's field frame, as a form's input does. Default `bare`. */
214
+ chrome?: "bare" | "field";
215
+ };
205
216
  export type ViewsComponents = {
206
217
  Button: ComponentType<ViewsButtonProps>;
207
218
  Popover: ComponentType<ViewsPopoverProps>;
@@ -227,4 +238,11 @@ export type ViewsComponents = {
227
238
  source: string;
228
239
  className?: string;
229
240
  }>;
241
+ /** Optional: every editor's single-line box draws through it. Left out, the provider draws a
242
+ * plain `<input>`. */
243
+ Input?: ComponentType<ViewsInputProps>;
244
+ };
245
+ /** The map as the views read it: the optional slots filled, the app's or the package's default. */
246
+ export type ViewsResolvedComponents = ViewsComponents & {
247
+ Input: ComponentType<ViewsInputProps>;
230
248
  };
@@ -1,3 +1,5 @@
1
- const _mapMatchesContract = true;
2
- void _mapMatchesContract;
1
+ const _requiredMatchContract = true;
2
+ const _optionalMatchContract = true;
3
+ void _requiredMatchContract;
4
+ void _optionalMatchContract;
3
5
  export {};
@@ -2,11 +2,12 @@ import type { FieldConventions } from "@viewkitjs/fields";
2
2
  import type { ViewsMessageResolver } from "../contract.js";
3
3
  import type { ViewsAtoms } from "../atoms/types.js";
4
4
  import type { FieldPresentation } from "../display/options.js";
5
- import type { ViewsComponents } from "./components.js";
5
+ import type { ViewsResolvedComponents } from "./components.js";
6
6
  import type { ViewsIcons } from "./icons.js";
7
7
  import type { ViewsResolvedPorts } from "./ports.js";
8
8
  export type ViewsContextValue = {
9
- components: ViewsComponents;
9
+ /** The app's components, with the optional ones filled: the app's own, or the package's plain default. */
10
+ components: ViewsResolvedComponents;
10
11
  atoms: ViewsAtoms;
11
12
  icons: ViewsIcons;
12
13
  /** The app's ports, with `confirm` always a function (the browser's where the app handed none). */
@@ -15,6 +16,8 @@ export type ViewsContextValue = {
15
16
  conventions: FieldConventions;
16
17
  /** The app's formatting: given the package's defaults, return the app's. */
17
18
  presentation?: (defaults: FieldPresentation) => FieldPresentation;
19
+ /** The media query that means a desktop: the app's own, or `DEFAULT_DESKTOP_QUERY`. */
20
+ desktopQuery: string;
18
21
  };
19
22
  export declare const ViewsContext: import("react").Context<ViewsContextValue | null>;
20
23
  export declare function useViews(): ViewsContextValue;
@@ -0,0 +1,9 @@
1
+ /** The width a desktop starts at, unless the app hands in its own query. */
2
+ export declare const DEFAULT_DESKTOP_QUERY = "(min-width: 1024px)";
3
+ /** Whether the screen is a desktop by `query`, asked now: true where there is no `matchMedia`. For
4
+ * an answer at the moment of a gesture, where a subscription would redraw its reader on a change.
5
+ * The package's own: no entry point exports it. */
6
+ export declare function isDesktopNow(query: string): boolean;
7
+ /** Whether the screen is a desktop, by the provider's `desktopQuery`: true where there is no
8
+ * `matchMedia`. It follows the query's changes. The package's own: no entry point exports it. */
9
+ export declare function useDesktop(): boolean;
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useCallback, useSyncExternalStore } from "react";
3
+ import { useViews } from "./context.js";
4
+ export const DEFAULT_DESKTOP_QUERY = "(min-width: 1024px)";
5
+ function canAsk() {
6
+ return typeof window !== "undefined" && typeof window.matchMedia === "function";
7
+ }
8
+ export function isDesktopNow(query) {
9
+ return canAsk() ? window.matchMedia(query).matches : true;
10
+ }
11
+ export function useDesktop() {
12
+ const { desktopQuery } = useViews();
13
+ const subscribe = useCallback((onChange) => {
14
+ if (!canAsk())
15
+ return () => { };
16
+ const list = window.matchMedia(desktopQuery);
17
+ list.addEventListener("change", onChange);
18
+ return () => list.removeEventListener("change", onChange);
19
+ }, [desktopQuery]);
20
+ const read = () => isDesktopNow(desktopQuery);
21
+ return useSyncExternalStore(subscribe, read, () => true);
22
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from "react";
2
+ import type { ViewsInputProps } from "./components.js";
3
+ /**
4
+ * The package's own `Input`, for an app that hands none: a bare `<input>` carrying exactly what the
5
+ * editor hands it, `ref` included, and no look of its own. `chrome` is a hint for an app's frame, so
6
+ * it never reaches the element.
7
+ */
8
+ export declare function PlainInput({ chrome: _chrome, ...props }: ViewsInputProps): ReactNode;
@@ -0,0 +1,5 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export function PlainInput({ chrome: _chrome, ...props }) {
4
+ return _jsx("input", { ...props });
5
+ }
package/dist/react.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { ViewsProvider, useViews } from "./provider/ViewsProvider.js";
2
2
  export type { ViewsContextValue, ViewsProviderProps } from "./provider/ViewsProvider.js";
3
- export type { ViewsAlign, ViewsAnchor, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsMenuItem, ViewsMenuProps, ViewsOpenChange, ViewsPopoverProps, ViewsSheetProps, ViewsSide, ViewsTooltipProps, } from "./provider/components.js";
3
+ export { DEFAULT_DESKTOP_QUERY } from "./provider/desktop.js";
4
+ export type { ViewsAlign, ViewsAnchor, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsInputProps, ViewsMenuItem, ViewsMenuProps, ViewsOpenChange, ViewsPopoverProps, ViewsResolvedComponents, ViewsSheetProps, ViewsSide, ViewsTooltipProps, } from "./provider/components.js";
4
5
  export type { ViewsIconProps, ViewsIcons } from "./provider/icons.js";
5
6
  export { NOOP_PORTS } from "./provider/ports.js";
6
7
  export type { ViewsClipboardPort, ViewsConfirmPort, ViewsConfirmRequest, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsResolvedPorts, ViewsToastPort, } from "./provider/ports.js";
package/dist/react.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use client";
2
2
  export { ViewsProvider, useViews } from "./provider/ViewsProvider.js";
3
+ export { DEFAULT_DESKTOP_QUERY } from "./provider/desktop.js";
3
4
  export { NOOP_PORTS } from "./provider/ports.js";
4
5
  export { DEFAULT_VIEWS_ATOMS } from "./atoms/defaults.js";
@@ -6,6 +6,8 @@ type SelectCheckboxProps = {
6
6
  onChange: (next: boolean, shift: boolean) => void;
7
7
  "aria-label"?: string;
8
8
  className?: string;
9
+ /** -1 takes it out of the Tab order, where a surface reaches it by its own keys (the grid's ←). */
10
+ tabIndex?: number;
9
11
  };
10
12
  /**
11
13
  * Row selection checkbox: the app's checkbox (in the portal, its neutral selection skin).
@@ -13,5 +15,5 @@ type SelectCheckboxProps = {
13
15
  * holds it) is hovered — not the whole row — and reads the shift key off the press that changed
14
16
  * it, for range selection.
15
17
  */
16
- export declare function SelectCheckbox({ checked, revealed, onChange, className, "aria-label": ariaLabel, }: SelectCheckboxProps): import("react/jsx-runtime").JSX.Element;
18
+ export declare function SelectCheckbox({ checked, revealed, onChange, className, tabIndex, "aria-label": ariaLabel, }: SelectCheckboxProps): import("react/jsx-runtime").JSX.Element;
17
19
  export {};
@@ -2,9 +2,9 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { cx } from "../internal/cx.js";
4
4
  import { useViews } from "../provider/context.js";
5
- export function SelectCheckbox({ checked, revealed, onChange, className, "aria-label": ariaLabel, }) {
5
+ export function SelectCheckbox({ checked, revealed, onChange, className, tabIndex, "aria-label": ariaLabel, }) {
6
6
  const { Checkbox } = useViews().components;
7
- return (_jsx(Checkbox, { checked: checked, "aria-label": ariaLabel, onCheckedChange: (next, details) => onChange(next, pressedWithShift(details?.event)), className: cx("opacity-0 group-hover/selzone:opacity-100", revealed && "opacity-100", checked && "opacity-100", className) }));
7
+ return (_jsx(Checkbox, { checked: checked, tabIndex: tabIndex, "aria-label": ariaLabel, onCheckedChange: (next, details) => onChange(next, pressedWithShift(details?.event)), className: cx("opacity-0 group-hover/selzone:opacity-100", revealed && "opacity-100", checked && "opacity-100", className) }));
8
8
  }
9
9
  function pressedWithShift(event) {
10
10
  return event !== undefined && "shiftKey" in event && event.shiftKey === true;
@@ -3,8 +3,8 @@ import { useCallback, useEffect, useRef, } from "react";
3
3
  export const ROW_CHECK_ATTR = "data-row-check";
4
4
  const EDGE_PX = 40;
5
5
  const MAX_STEP_PX = 24;
6
- function verticalScrollerOf(root) {
7
- let node = root;
6
+ function verticalScrollerOf(from) {
7
+ let node = from;
8
8
  while (node && node !== document.body) {
9
9
  const oy = getComputedStyle(node).overflowY;
10
10
  if ((oy === "auto" || oy === "scroll") && node.scrollHeight > node.clientHeight)
@@ -92,8 +92,8 @@ export function useCheckDragSelect({ enabled, rootRef, rowIds, rowIdOf = (attr)
92
92
  raf = requestAnimationFrame(tick);
93
93
  };
94
94
  const maybeScroll = (d) => {
95
- if (!scroller && rootRef.current)
96
- scroller = verticalScrollerOf(rootRef.current);
95
+ if (!scroller)
96
+ scroller = verticalScrollerOf(d.rowEl);
97
97
  if (!scroller || raf != null)
98
98
  return;
99
99
  if (edgeStep(d.lastY, scroller) !== 0)
@@ -139,7 +139,7 @@ export function useCheckDragSelect({ enabled, rootRef, rowIds, rowIdOf = (attr)
139
139
  return false;
140
140
  const rowEl = target.closest("[data-row-id]");
141
141
  const attr = rowEl?.getAttribute("data-row-id");
142
- if (!attr)
142
+ if (!rowEl || !attr)
143
143
  return false;
144
144
  const rowId = rowIdOfRef.current(attr);
145
145
  draggedRef.current = false;
@@ -149,6 +149,7 @@ export function useCheckDragSelect({ enabled, rootRef, rowIds, rowIdOf = (attr)
149
149
  lastX: e.clientX,
150
150
  lastY: e.clientY,
151
151
  rowId,
152
+ rowEl,
152
153
  value: !isSelectedRef.current(rowId),
153
154
  active: false,
154
155
  original: new Map(),
package/docs/contract.md CHANGED
@@ -22,12 +22,17 @@ use; the prefix keeps that selector from reaching an element of the app's own.
22
22
 
23
23
  | slot | the element |
24
24
  | ------------------------------------ | --------------------------------------------------------- |
25
- | `data-slot="vk-grid"` | the grid's frame: the scroll container |
25
+ | `data-slot="vk-grid"` | the grid's frame: fills the box the app gives it |
26
+ | `data-slot="vk-grid-scroll"` | the grid's one scroll area, both ways |
27
+ | `data-slot="vk-grid-head"` | an ungrouped grid's pinned head: its header row |
26
28
  | `data-slot="vk-grid-header"` | the header row |
27
29
  | `data-slot="vk-grid-header-cell"` | one column's header |
28
30
  | `data-slot="vk-grid-row"` | one record's row |
31
+ | `data-slot="vk-grid-rows"` | a group's rows: only those on screen are drawn |
32
+ | `data-slot="vk-grid-gap"` | the rows not drawn, as tall as they are |
29
33
  | `data-slot="vk-grid-cell"` | one value |
30
34
  | `data-slot="vk-grid-group"` | one group's band and its rows |
35
+ | `data-slot="vk-grid-group-head"` | a group's pinned head: its name bar and its header row |
31
36
  | `data-slot="vk-grid-group-header"` | a group's name and figures |
32
37
  | `data-slot="vk-grid-footer"` | the footer row |
33
38
  | `data-slot="vk-grid-footer-cell"` | one column's figure |
@@ -96,10 +101,7 @@ frame from its scale and its state; a skin reads them and an app overrides them
96
101
  | `--vk-footer-h` | footer height |
97
102
  | `--vk-label-h` | group band height |
98
103
  | `--vk-line-h` | a cell's line height |
99
- | `--vk-chrome-h` | the chrome above the first row |
100
104
  | `--vk-px` | horizontal cell padding |
101
- | `--vk-cell-py` | vertical cell padding |
102
- | `--vk-tail-py` | the tail button's vertical padding |
103
105
  | `--vk-tail-pl` | the tail button's left padding |
104
106
  | `--vk-rail-w` | the left rail's width |
105
107
  | `--vk-rail-gap` | the gap between rail and first cell |
@@ -161,14 +163,23 @@ corners come from the app's Tailwind radius scale.
161
163
  **The page gutter is the app's, if it has one.** `--vk-gutter` is the side padding a page gives its
162
164
  content: the grid's rows run edge to edge and line their content up with it. An app that pads its
163
165
  pages declares it once, onto its own padding; undeclared, the grid reads `0px` and sits flush with its
164
- container. `--vk-pinned-top` is how far down the surface's own pinned chrome reaches: the grid's
165
- sticky header row and each group's header stop under it, not behind it. An app that pins something
166
- over a grid (a tab strip, a toolbar) declares it on the element that scrolls the grid, onto the
167
- height of what it pins there; undeclared, the grid reads `0px` and its header sticks at the top.
166
+ container. `--vk-scroll-inset-bottom` is how much of the grid's foot the app covers with something it
167
+ floats there (a phone's bottom bar): the grid's scroll area runs underneath it, its last row scrolls
168
+ clear of it and a revealed cell stops above it. An app declares it on the grid's box or an ancestor;
169
+ undeclared, the grid reads `0px`.
170
+
171
+ **The grid scrolls inside itself.** Its frame fills the box its app gives it: a definite height, or
172
+ a flex column (the frame is `height: 100%`, `flex: 1 1 0` and `min-height: 0`). Inside the frame one
173
+ scroll area holds the table both ways, and each group's name bar and header row pin at the area's
174
+ top, so nothing the app pins above the grid concerns it. A box with no height gets a grid that grows
175
+ to its rows: the page scrolls it, and its heads don't pin. The grid's rows and frozen columns sit
176
+ inside your `Collapse`'s clip, so the clip must crop without scrolling (`overflow: clip`, never
177
+ `hidden`): a clip that scrolls takes the frozen columns' sticky edge with it.
168
178
 
169
179
  **The grid's own variables are not public.** The grid sets `--vk-drag-shift` (a header cell's
170
- offset while its column is dragged to a new place) and `--vk-col-w-<id>` (one column's resolved
171
- width, one per column) for itself. They carry the prefix because they share the global namespace;
180
+ offset while its column is dragged to a new place), `--vk-col-w-<id>` (one column's resolved
181
+ width, one per column) and `--vk-cols` (the columns' template on its scroll area, which every row
182
+ reads) for itself. They carry the prefix because they share the global namespace;
172
183
  an app neither sets nor reads them, and they may change in any release.
173
184
 
174
185
  ## The components map
@@ -183,15 +194,18 @@ both fill every one.
183
194
 
184
195
  `Button` · `Popover` · `Tooltip` · `Checkbox` · `Menu` · `Command` · `Calendar` · `Collapse` · `Sheet` · `AppIcon` · `Markdown`
185
196
 
197
+ `Input`, optional: a single-line text box, `ViewsInputProps`. Every editor's text box draws through it; without it the editors draw a plain `<input>`. Forward every prop to your element, `ref` included. `chrome` is `bare` (the default: a grid cell, a panel that frames the box) or `field` (your field's frame). `OPTIONAL_COMPONENT_NAMES` lists it apart from `COMPONENT_NAMES`, which lists the slots you must fill.
198
+
186
199
  The popover takes `alignOffset`, `initialFocus` (false keeps focus where it was when the popup
187
- opens; the editor that then takes focus does so with `preventScroll`, so an adapter places its popup
188
- however it likes, with no `fixed` positioning to hide a jump), and two vetoes, `onOutsidePress`
200
+ opens; the editor that then takes focus does so with `preventScroll`, so the package's own focus
201
+ never moves the page while your popup is placed; what your `Command` does as it mounts is yours, in
202
+ "Writing an adapter"), and two vetoes, `onOutsidePress`
189
203
  and `onEscape`, each returning `false` to keep it open. `onOutsidePress` is handed the pointer press, its `target` where the press landed, also when the
190
204
  focus that press moves is what would close the popup: a vetoed press holds against its focus too,
191
205
  and focus leaving by keyboard (a Tab out) closes without asking. Its
192
206
  `chrome` is `panel` (the app's card popover) or `menu` (the app's menu panel, for a list); a panel
193
207
  click reaches `onPanelClick`, and `panelData` sets `data-*` attributes on the popup; its `style` carries what a class cannot say, a width that follows a cell. The command
194
- list's root takes `shouldFilter`, `filter` and `loop` (the arrows wrap); an item takes `chosen`: the app colours the item as
208
+ list's root takes `shouldFilter`, `filter`, `loop` (the arrows wrap) and `defaultValue` (the value of the item highlighted as the list opens, and none while no item has it; the relation editor opens on the linked record through it, and a list that ignores it opens on its first row); an item takes `chosen`: the app colours the item as
195
209
  its chosen row, and the package's row inside draws the check, so the item draws no tick of its own; its input takes a `ref` (the place editor focuses its search through it), `onKeyDown`, and `chrome`
196
210
  `search` or `bare` (the input without the search row); its empty state and groups take a class. The
197
211
  calendar takes a controlled `month` (`YYYY-MM`) with `onMonthChange`, a `dropdown` caption, and the
@@ -221,7 +235,8 @@ What a Base UI adapter over shadcn copies does where its copies stop short of a
221
235
 
222
236
  **The menu.** The map's `Menu` has an anchor and no trigger, and no flyouts. Build it from the menu
223
237
  library's root, positioner and popup, handing the anchor to the positioner, where your copy's content
224
- doesn't forward one; with no flyouts, a root needs no trigger of its own.
238
+ doesn't forward one; with no flyouts, a root needs no trigger of its own. Opened, it puts focus on its
239
+ first row, as your `Popover` does by default: a row's menu opened by a key starts there.
225
240
 
226
241
  **A disabled group.** Nothing to do: its rows reach you already `disabled`.
227
242
 
@@ -232,6 +247,15 @@ menu classes over it.
232
247
  **The command item's chosen mark.** Colour the item as your chosen row; the row inside draws the
233
248
  check. Where your copy's item draws a tick of its own, hide it.
234
249
 
250
+ **A command list that scrolls as it mounts.** The chips, select and relation editors, and the grid's
251
+ Add column and group menu, mount a `Command.Root` with its rows in the frame the popover opens, before
252
+ your popover has placed its popup. A command library that scrolls its selected item into view on mount
253
+ (cmdk does, with `scrollIntoView`) scrolls the page towards the popup's unplaced spot, which at a
254
+ library's default positioning can be the page's top, and `preventScroll` on the focus doesn't reach
255
+ that scroll. Keep such a popover `fixed`, where the unplaced popup already sits inside the viewport, or
256
+ stop your `Command` scrolling on mount. Your library's default positioning is safe only for a
257
+ `Command` that doesn't.
258
+
235
259
  **`chrome: "bare"`.** The input alone, without the search row's glyph and divider. Where your copy
236
260
  has only the search row, reach the command library's own input.
237
261
 
@@ -258,7 +282,7 @@ container: the inset a run of rows sits in, inside a panel or a command list's g
258
282
  a button or, with `interactive={false}`, a static line), `RowContent` (a row's inside, for inside a
259
283
  command list's item, which owns the element and the highlight), `TickBox` (a paint-only tick box),
260
284
  `StatusBadge` (a pill by status slot), `StatusMarker` (an attention badge that opens its reason) and
261
- `Tag` (a category chip, removable, with an optional leading glyph), `CommandMenu` (a `command` cell's verb menu, opened from the trigger the cell drew; the default is the components map's `Menu`), `RowMenu` (the row's right-click menu, around the row: Open page, the rows the rendering builds, Delete; the default is the components map's `Menu` at the pointer, opened by a right-click or the row's ⋯ (`data-slot="vk-grid-row-more"`), wrapped in `data-slot="vk-row-menu"`; its Delete asks the `confirm` port with `views.menus.row-delete-confirm` (the browser's own confirm when you hand none), and a delete that rejects says so through the toast port's `error` with `views.menus.row-delete-failed`; a long-press on a phone opens nothing) and `RelationLink` (where a relation chip goes, around the chip the display drew; the default goes nowhere), `Loading` (a wait: the list reloading, or more rows arriving; the default is a plain ring) `LoadMore` (how a list asks for its next page; the default watches a sentinel past the last row) and `PlatformMark` (a link's platform, drawn before it, read from its address with the conventions' platforms; the default draws nothing, so a link looks plain, and the package ships no brand art, so an app that wants marks draws its own by the platform's key into `data-slot="vk-platform"`). Each ships as a default, exported as `DEFAULT_VIEWS_ATOMS`, drawn
285
+ `Tag` (a category chip, removable, with an optional leading glyph), `CommandMenu` (a `command` cell's verb menu, opened from the trigger the cell drew; the default is the components map's `Menu`), `RowMenu` (the row's right-click menu, around the row: Open page, the rows the rendering builds, Delete; the default is the components map's `Menu` at the pointer, opened by a right-click or the row's ⋯ (`data-slot="vk-grid-row-more"`), wrapped in `data-slot="vk-row-menu"`; the grid's row-menu keys send a cell the same right-click, with no press before it, so a `RowMenu` of your own opens on any `contextmenu` and doesn't wait for a press; its Delete asks the `confirm` port with `views.menus.row-delete-confirm` (the browser's own confirm when you hand none), and a delete that rejects says so through the toast port's `error` with `views.menus.row-delete-failed`; a long-press on a phone opens nothing) and `RelationLink` (where a relation chip goes, around the chip the display drew; the default goes nowhere), `Loading` (a wait: the list reloading, or more rows arriving; the default is a plain ring) `LoadMore` (how a list asks for its next page; the default watches a sentinel past the last row) and `PlatformMark` (a link's platform, drawn before it, read from its address with the conventions' platforms; the default draws nothing, so a link looks plain, and the package ships no brand art, so an app that wants marks draws its own by the platform's key into `data-slot="vk-platform"`). Each ships as a default, exported as `DEFAULT_VIEWS_ATOMS`, drawn
262
286
  from the app's colours; an app swaps any of them through the provider's `atoms`, and the rest
263
287
  stay the defaults.
264
288
 
@@ -281,6 +305,18 @@ with the states `data-chosen`, `data-disabled`, `data-muted`, `data-checked`, `d
281
305
  Lists that scroll wear the class `scrollbar-overlay`, which an app may define (to show the OS
282
306
  overlay scrollbar, say); without it the class does nothing.
283
307
 
308
+ ## The editor panel
309
+
310
+ `EditorPanel` (`@viewkitjs/views/editors/panel`) opens an editor in the components map's `Popover` on
311
+ a desktop and its `Sheet` on a phone, and marks its parts with these slots:
312
+
313
+ | slot | the element |
314
+ | ---------------------------------- | ------------------------------------------------------------- |
315
+ | `data-slot="vk-editor-panel"` | the popover's panel, or the sheet's body, an editor sits in |
316
+ | `data-slot="vk-editor-bar"` | the sheet's bar: its ✕ and its ✓ |
317
+ | `data-slot="vk-editor-refusal"` | the reason a refused value gave, under the editor |
318
+ | `data-slot="vk-text-editor"` | the text editor's box (`@viewkitjs/views/editors/text`), unless its host names its own |
319
+
284
320
  ## Ports
285
321
 
286
322
  Runtime services the app hands in through the provider, typed in `src/provider/ports.ts`:
@@ -314,7 +350,7 @@ message, read from the conventions the provider carries. The package's are a clo
314
350
  `views.editors.*`, `views.menus.*` and `views.display.*`: `views.editors.tag-remove` (`{ label }`),
315
351
  `views.editors.marker-resolve`, `views.editors.marker-no-reason`, `views.editors.range-low` and
316
352
  `views.editors.range-high` (a range editor's two boxes, "From" and "To"), and `views.editors.name-given`,
317
- `views.editors.name-family` and `views.editors.name-full` (a name editor's three boxes); `views.editors.values-add` ("Add"), `views.editors.values-label` ("Label"), `views.editors.values-main` ("Main", the main value's mark), `views.editors.values-make-main` (`{ value }`, "Make {value} the main one") and `views.editors.values-remove` (`{ value }`, "Remove {value}") (a value list editor's rows); the place editor's: `views.editors.place-country` ("Country"), `views.editors.place-country-search` ("Search countries"), `views.editors.place-change-country` ("Change country"), `views.editors.place-region-search` ("Search"), `views.editors.place-line1` ("Address line 1"), `views.editors.place-line2` ("Address line 2"), `views.editors.place-required` (`{ label }`, "{label} *", a part its country asks for), the region's words `views.editors.place-region-area`, `views.editors.place-region-county`, `views.editors.place-region-department`, `views.editors.place-region-district`, `views.editors.place-region-do-si`, `views.editors.place-region-emirate`, `views.editors.place-region-island`, `views.editors.place-region-oblast`, `views.editors.place-region-parish`, `views.editors.place-region-prefecture`, `views.editors.place-region-province` and `views.editors.place-region-state`, the city's `views.editors.place-city-city`, `views.editors.place-city-district`, `views.editors.place-city-post-town` and `views.editors.place-city-suburb`, and the postal code's `views.editors.place-postal-eircode`, `views.editors.place-postal-pin`, `views.editors.place-postal-postal` and `views.editors.place-postal-zip` (each its word in English: "County", "Do/Si", "Post town", "PIN code", "ZIP code"); `placeWordKey(kind, word)` gives the key for a word `placeFormat` names; `views.editors.place-region` ("Region") beside the place editor's `views.editors.place-country`,
353
+ `views.editors.name-family` and `views.editors.name-full` (a name editor's three boxes); `views.editors.values-add` ("Add"), `views.editors.values-label` ("Label"), `views.editors.values-main` ("Main", the main value's mark), `views.editors.values-make-main` (`{ value }`, "Make {value} the main one") and `views.editors.values-remove` (`{ value }`, "Remove {value}") (a value list editor's rows); `views.editors.discard` ("Discard", the editor sheet's ✕) and `views.editors.save` ("Save", its ✓); `views.editors.open-email`, `views.editors.open-phone` and `views.editors.open-link` (`{ value }`, "Email {value}", "Call {value}", "Open {value}", the open action beside a stored value in a phone's sheet); the place editor's: `views.editors.place-country` ("Country"), `views.editors.place-country-search` ("Search countries"), `views.editors.place-change-country` ("Change country"), `views.editors.place-region-search` ("Search"), `views.editors.place-line1` ("Address line 1"), `views.editors.place-line2` ("Address line 2"), `views.editors.place-required` (`{ label }`, "{label} *", a part its country asks for), the region's words `views.editors.place-region-area`, `views.editors.place-region-county`, `views.editors.place-region-department`, `views.editors.place-region-district`, `views.editors.place-region-do-si`, `views.editors.place-region-emirate`, `views.editors.place-region-island`, `views.editors.place-region-oblast`, `views.editors.place-region-parish`, `views.editors.place-region-prefecture`, `views.editors.place-region-province` and `views.editors.place-region-state`, the city's `views.editors.place-city-city`, `views.editors.place-city-district`, `views.editors.place-city-post-town` and `views.editors.place-city-suburb`, and the postal code's `views.editors.place-postal-eircode`, `views.editors.place-postal-pin`, `views.editors.place-postal-postal` and `views.editors.place-postal-zip` (each its word in English: "County", "Do/Si", "Post town", "PIN code", "ZIP code"); `placeWordKey(kind, word)` gives the key for a word `placeFormat` names; `views.editors.place-region` ("Region") beside the place editor's `views.editors.place-country`,
318
354
  `views.editors.place-city-city` and `views.editors.place-postal-postal`, a place's parts in a panel;
319
355
  `views.menus.part-row` (`{ field, part }`, one part's row in a panel: "Location · Country");
320
356
  the grid's column menu: `views.menus.sort-asc` ("Sort ascending"), `views.menus.sort-desc`, `views.menus.sort-clear`
@@ -341,7 +377,8 @@ the grid's own: `views.grid.figure` (`{ kind }`, a footer figure's name, `"none"
341
377
  `views.grid.change-value`, `views.grid.value` and `views.grid.edit-value` (a long text's box, read-only or not),
342
378
  `views.grid.read-only` and `views.grid.read-only-why` (a locked list's badge and its title); its refusals
343
379
  `views.grid.locked` (`{ field }`), `views.grid.not-clearable`, `views.grid.computed` (`{ from }`),
344
- `views.grid.cell-read-only` and `views.grid.clear-none`; its write gate's `views.grid.write-not-list`,
380
+ `views.grid.cell-read-only`, `views.grid.clear-none` and `views.grid.clear-required` (`{ fields }`, the fields a clear
381
+ over several cells left because they can't be empty, already joined in the viewer's locale); its write gate's `views.grid.write-not-list`,
345
382
  `views.grid.write-not-boolean`, `views.grid.write-marker`, `views.grid.write-not-email`, `views.grid.write-not-url`, `views.grid.write-not-link` and
346
383
  `views.grid.write-not-linkable`; a paste's `views.grid.paste-refused`, `views.grid.paste-empty`,
347
384
  `views.grid.paste-not-number`, `views.grid.paste-not-duration`, `views.grid.paste-not-date`,
@@ -361,7 +398,9 @@ record in another currency) and `views.grid.paste-not-range`; a paste or a fill
361
398
  (`{ value }`, `"true"` or `"false"` as text so a catalog's `select` reads it: a text boolean with no words of its own), `views.display.show-all` (`{ count }`), and
362
399
  `views.display.show-more` and `views.display.show-less` (rich text folded in a drawer), and
363
400
  `views.display.phone-extension` (`{ extension }`, "ext. 12" after a phone) and `views.display.phone-as-typed`
364
- (the title on a phone stored as typed).
401
+ (the title on a phone stored as typed), and `views.display.converted-from` (`{ code }`, "Converted from USD", the
402
+ title on a money figure shown in another currency than its record's) and `views.display.as-shown` ("as shown",
403
+ after that figure under a money editor).
365
404
  A span behind now is fields' own `time.ago`. The provider's `messages` resolves them; it defaults to the
366
405
  package's English, `resolveViewsMessage`; an app's resolver that words only some keys calls
367
406
  `resolveViewsMessage` for the rest, since the provider does not fall back for it. A new key is a
@@ -374,8 +413,8 @@ A value takes up to four shapes on its way through a view: **stored** (what the
374
413
 
375
414
  | type | stored | draft | commit | display |
376
415
  | -------------------------------------------- | --------------------------------------------------------- | ---------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------- |
377
- | `text` | a string | the host's own input | a string | the text; a long text folds |
378
- | `url`, `domain`, `email`, `phone` | a string (a phone `{ number, extension }`) | the host's own input | the typed text, which fields' `acceptFieldCommit` reads | a link (`tel:` for a phone) |
416
+ | `text` | a string | the text editor's box | a string | the text; a long text folds |
417
+ | `url`, `domain`, `email`, `phone` | a string (a phone `{ number, extension }`) | the text editor's box | the typed text, which fields' `acceptFieldCommit` reads | a link (`tel:` for a phone) |
379
418
  | the same, `multiple` | `{ value, label, main }[]`, the main one first | a row each | the whole list (`editors/value-list`) | the main value, and the rest on demand |
380
419
  | `number`, `percent`, `currency` | a number (a currency's code fixed, or in a sibling field) | the typed text | `NumberCommit`: `{ value, unit? }` | the figure in the conventions' locale; a percent appended, never multiplied |
381
420
  | `date` | `"2026-09-15"` | the picked day | `"2026-09-15"` | the day in the column's style |
@@ -383,16 +422,16 @@ A value takes up to four shapes on its way through a view: **stored** (what the
383
422
  | `boolean` | a boolean | none | a boolean, from the display control itself | a checkbox, an icon, a marker or text |
384
423
  | `select`, `status` | the option's code | none: a pick commits | the option's code, or `""` for None on a field that may be emptied | a badge, a status by its semantic slot |
385
424
  | `multiselect` | the codes | the chosen codes | the whole set | badges |
386
- | `relation`, `user` | an id or null (ids for a many relation) | the picked id | an id, or `null` for unlinked | a chip `{ id, label, entity, avatarUrl }` the host resolves |
425
+ | `relation`, `user` | an id or null (ids for a many relation) | the picked id; a many relation's set | an id, a ref `{ kind, id }`, or `null` for unlinked; a many relation's whole set as stored | a chip `{ id, label, entity, avatarUrl }` the host resolves |
387
426
  | `range` | `{ low, high }` | two boxes | `{ low, high }`, an empty box an open end | "11–50" with its unit and period |
388
427
  | `name` | `{ full, given, family }` | three boxes | `{ full, given, family }`, or `null` | the full name, else the parts, else the host's fallback |
389
- | `location` | the place's parts in its country's order | the country, then its parts | the place, or `null` (the grid has no editor for it) | the place written whole |
428
+ | `location` | the place's parts in its country's order | the country, then its parts | the place, or `null` | the place written whole |
390
429
  | `rich_text` | a markdown string | the host's own input; in the grid, the long-text panel | the markdown string | folded text |
391
430
  | `actor`, `lookup`, `rollup`, `formula` | set by the system, or derived | none | none: no editor opens | a chip, the far field, the result |
392
431
 
393
432
  A clear is the one exception to the commit column. Delete, Cut, the grid row menu's Clear and a clear over a range commit `""` for every type above but three, on a field that may be emptied: a relation (and a member) commits `null` and a multiselect `[]`, and a boolean commits `false`, whether or not it may be emptied. So a cleared number, date, name, range, select or text reaches the binding's `write` as `""`, and the `write` maps it to what the row stores for nothing.
394
433
 
395
- A derived field (a lookup, a rollup, a formula) has no commit at all: no edit core, and fields' `zodFor` refuses it. `EDIT_CORES` (`@viewkitjs/views/editors`) answers which types open an edit core; `null` is the answer for a type with none, including the types edited in the host's own text box (`text`, `rich_text`, `url`, `domain`, `email`, `phone`) and `boolean`, which its display control flips.
434
+ A derived field (a lookup, a rollup, a formula) has no commit at all: no edit core, and fields' `zodFor` refuses it. `EDIT_CORES` (`@viewkitjs/views/editors`) answers which types open an edit core; `null` is the answer for a type with none, such as `boolean`, which its display control flips. The text-like types (`text`, `rich_text`, `url`, `domain`, `email`, `phone`) share one, `TextEditor`.
396
435
 
397
436
  ## What an edit core never does
398
437
 
@@ -408,14 +447,14 @@ A field whose changes are transitions with rules of their own (a lost deal needs
408
447
 
409
448
  ## The doors
410
449
 
411
- Eighteen doors, and nothing else is importable but `./package.json`. What each holds is summarised here; each door's reference page names every export, one line each, starting at [`reference/views.md`](reference/views.md).
450
+ Twenty-one doors, and nothing else is importable but `./package.json`. What each holds is summarised here; each door's reference page names every export, one line each, starting at [`reference/views.md`](reference/views.md).
412
451
 
413
452
  `@viewkitjs/views`, no React at runtime, holds two things. The rendering contract, every name listed:
414
453
  the constants `VK_PREFIX`, `GRID_SLOTS`, `GRID_STATES`, `VK_TOKENS`, `VK_COLOURS`,
415
- `VK_OPTIONAL_COLOURS`, `VK_OPTIONAL_LAYOUT`, `COMPONENT_NAMES`, `ATOM_NAMES`, `ATOM_SLOTS`, `ATOM_STATES`, `PORT_NAMES`,
454
+ `VK_OPTIONAL_COLOURS`, `VK_OPTIONAL_LAYOUT`, `COMPONENT_NAMES`, `OPTIONAL_COMPONENT_NAMES`, `ATOM_NAMES`, `ATOM_SLOTS`, `ATOM_STATES`, `EDITOR_SLOTS`, `PORT_NAMES`,
416
455
  `ICON_NAMES`, `MESSAGE_NAMESPACES` and `VIEWS_MESSAGE_KEYS`; the functions `resolveViewsMessage` and `placeWordKey`; and
417
- the types `GridSlot`, `GridState`, `VkToken`, `VkColour`, `VkOptionalColour`, `VkOptionalLayout`, `ComponentName`,
418
- `AtomName`, `AtomSlot`, `AtomState`, `PortName`, `ViewsIconName`, `ViewsMessageNamespace`,
456
+ the types `GridSlot`, `GridState`, `VkToken`, `VkColour`, `VkOptionalColour`, `VkOptionalLayout`, `ComponentName`, `OptionalComponentName`,
457
+ `AtomName`, `AtomSlot`, `AtomState`, `EditorSlot`, `PortName`, `ViewsIconName`, `ViewsMessageNamespace`,
419
458
  `ViewsMessageKey`, `ViewsMessage`, `ViewsMessageResolver` and `PlaceWordKey`.
420
459
 
421
460
  And the model, by module: every export of `model/index.ts` (the column vocabulary — what a column is,
@@ -425,16 +464,18 @@ of the five model modules that barrel does not carry (`card-density`, `card-layo
425
464
  money reading),
426
465
  `filters/` (the filter registry and its types, the text, number and date rules, the filter config
427
466
  types and their guards), `figures.ts`, `grouping/` (`ListGroup` and the group sort) and `fields/`
428
- (the binding, money and currency, denomination, the write preparation, the edit-core types, number
467
+ (the binding, money and currency, denomination, the write preparation, the write target (`EntityWriteTarget`,
468
+ `EntityWriteReceipt`, `FieldWriteAdmission`, `FieldWriteAdmissionGuard`, `LockedResolver`, `FieldNote`,
469
+ `FieldWriteReconciliationRequired`), the edit-core types, number
429
470
  edit, the format knobs and the relation source types, the host's verb-menu types (`FieldMenus`, `FieldRowMenuItem`)). A name exported by one of those modules is
430
471
  public; nothing else at the root door is.
431
472
 
432
473
  `@viewkitjs/views/react`, which opens with the client directive: `ViewsProvider`, `useViews()` and
433
474
  `NOOP_PORTS`; the provider's types `ViewsProviderProps` and `ViewsContextValue`; the adapter's types
434
- `ViewsComponents`, `ViewsPorts`, `ViewsIcons` and `ViewsIconProps`; the components' props
475
+ `ViewsComponents`, `ViewsResolvedComponents` (the map as `useViews()` hands it on, `Input` always there), `ViewsPorts`, `ViewsIcons` and `ViewsIconProps`; the components' props
435
476
  `ViewsButtonProps`, `ViewsPopoverProps`, `ViewsTooltipProps`, `ViewsCheckboxProps`, `ViewsMenuProps`,
436
- `ViewsMenuItem`, `ViewsCommandParts`, `ViewsCalendarProps`, `ViewsCollapseProps` and
437
- `ViewsSheetProps`, with their shared shapes `ViewsAnchor`, `ViewsSide`, `ViewsAlign`,
477
+ `ViewsMenuItem`, `ViewsCommandParts`, `ViewsCalendarProps`, `ViewsCollapseProps`,
478
+ `ViewsSheetProps` and `ViewsInputProps`, with their shared shapes `ViewsAnchor`, `ViewsSide`, `ViewsAlign`,
438
479
  `ViewsCloseReason` and `ViewsOpenChange`; the ports' types `ViewsToastPort`, `ViewsHapticsPort`,
439
480
  `ViewsClipboardPort`, `ViewsPrefsPort`, `ViewsConfirmPort`, `ViewsConfirmRequest` and `ViewsResolvedPorts` (the
440
481
  ports `useViews()` hands on, `confirm` always there); the atoms' `DEFAULT_VIEWS_ATOMS` and types `ViewsAtoms`,
@@ -455,9 +496,11 @@ formatters `formatDateValue`, `formatNumberValue` and `formatMoney`, `DEFAULT_FI
455
496
  formatter handed no viewer reads the neutral conventions, never the runtime's.
456
497
 
457
498
  `@viewkitjs/views/editors`, no client directive on the door: `EDIT_CORES` (one editor per storage
458
- type, `null` where a type has no panel) and `hasEditCore`. One door per editor, each opening with the
499
+ type, `null` where a type has none of its own) and `hasEditCore`. One door per editor, each opening with the
459
500
  client directive: `@viewkitjs/views/editors/select` (`SelectEditor`, `SelectEditorHandle`,
460
- `pickerOptionsFromField`, `PickerOption`), `@viewkitjs/views/editors/relation` (`RelationEditor`,
501
+ `pickerOptionsFromField`, `PickerOption`, `SELECT_SEARCH_PAST`), `@viewkitjs/views/editors/text` (`TextEditor`,
502
+ `TextEditorHandle`, `TextEditorProps`, `TextEditorType`, `TEXT_INPUT_TYPE`: one box for text, a link, an email,
503
+ a phone, a domain, long text and rich text), `@viewkitjs/views/editors/relation` (`RelationEditor`,
461
504
  `RelationEditorHandle`, `RelationCreate`, `RELATION_PAGE_SIZE`, `RELATION_SEARCH_DEBOUNCE_MS`, and
462
505
  the relation source types), `@viewkitjs/views/editors/number` (`NumberEditor`, `NumberEditorHandle`,
463
506
  `NumberEditValue`), `@viewkitjs/views/editors/range` (`RangeEditor`, `RangeEditorHandle`: two boxes,
@@ -473,16 +516,31 @@ messages, read from the provider's conventions unless the host hands `message`.
473
516
 
474
517
  `@viewkitjs/views/editors/session`, opening with the client directive: `useAnchoredEditSession` and
475
518
  `EDITOR_EXIT_MS` — the one-answer guard and the exit gap every host that opens an editor over a value
476
- shares. Its own door, so a host that needs the session does not load the six editors.
519
+ shares; Escape always discards through it, and a refused attempt's reason comes back as `refusal`
520
+ (`EditSession`, `EditSessionAttempt`). Its own door, so a host that needs the session does not load the six editors.
521
+
522
+ `@viewkitjs/views/editors/panel`, opening with the client directive: `EditorPanel`, `EditorPanelProps`
523
+ and `EditorSurface` — an editor opened as the components map's `Popover` on a desktop and its `Sheet`
524
+ on a phone, by the provider's `desktopQuery`, chosen once when the session opens.
477
525
 
478
526
  `@viewkitjs/views/editors/open-values`, opening with the client directive: `OpenValuesProvider`,
479
- `useOpenValues(field)` and `offeredValues(field, known, seen)`. An open field's values (what its records
527
+ `useOpenValues(field)`, `offeredValues(field, known, seen)` and `takesNewValues(field)`. An open field's values (what its records
480
528
  hold, which the app's list answers) reach every editor of it: the app provides them above a surface, and
481
529
  a host reads them, asking once for a field's values when its editor mounts. A closed field, or no
482
530
  provider, reads none and asks nothing. `offeredValues` is what a host offers: the declared options, then
483
531
  the known values, then those seen, each once. `useOpenValuesContext()` reads the nearest provider whole: what a host
484
532
  hands `buildRelationFilters` as `farValues`.
485
533
 
534
+ `@viewkitjs/views/field-row`, opening with the client directive: `FieldRow` (`FieldRowProps`), one field of a
535
+ record drawn as its label, its value and, on a click, its type's editor in place, with `RowEditor` and `ROW_HOSTS`
536
+ (`RowEditorProps`, `RowEditorAttempt`, `RowClosed`, `RowHostProps`), the host each type mounts; and
537
+ `useFieldWrite` (`FieldWriteOptions`, `EditTiming`), the write path that admits a commit at once, queues one
538
+ record's writes, settles each on the save's receipt and rolls a failure back, with `FieldWriteRefusal`,
539
+ and, re-exported from the root door that holds them as the model, `FieldWriteReconciliationRequired` and the shapes it
540
+ writes through (`EntityWriteTarget`, `EntityWriteReceipt`, `FieldWriteAdmission`, `FieldWriteAdmissionGuard`,
541
+ `LockedResolver`, `FieldNote`). The panel around the rows
542
+ (its sections, its related records) is the app's.
543
+
486
544
  A relation's Related records row (`buildRelationFilters`) offers a far relation, user or actor by name
487
545
  only when its target names it (`RelationFilterTarget.named`, from the host's builder) and the host hands
488
546
  `farValues`, the values its list answers keyed by path: `farPathOf(relationKey, farKey)`, the two joined by
@@ -150,7 +150,7 @@ Swap it for a menu of your own, or for a long-press that selects: `onToggleSelec
150
150
 
151
151
  ## Waits
152
152
 
153
- `Loading` takes a `placement` and a `label`: `body` while the whole list reloads, `footer` while more rows arrive. The default is a ring with one turning arc, larger in the body. `LoadMore` is how a list asks for its next page: it takes `onReveal`, and an optional `label` drawn in place of the wait. The default watches a sentinel past the last row and calls `onReveal` as it comes within 600px of the viewport, drawing your `Loading` meanwhile; with no `IntersectionObserver` (a server render) it asks for nothing. Swap `LoadMore` for a button, or a different distance. [The grid guide](the-grid.md) shows the grid's `loadMore` prop that drives it.
153
+ `Loading` takes a `placement` and a `label`: `body` while the whole list reloads, `footer` while more rows arrive. The default is a ring with one turning arc, larger in the body. `LoadMore` is how a list asks for its next page: it takes `onReveal`, and an optional `label` drawn in place of the wait. The default watches a sentinel past the last row and calls `onReveal` as it comes within 600px of the end of what it scrolls in (the grid's own scroll area, else the viewport), drawing your `Loading` meanwhile; with no `IntersectionObserver` (a server render) it asks for nothing. Swap `LoadMore` for a button, or a different distance. [The grid guide](the-grid.md) shows the grid's `loadMore` prop that drives it.
154
154
 
155
155
  ## Handing them in
156
156
 
@@ -75,7 +75,7 @@ What it does with a column depends on what the column is:
75
75
  - A `title` column draws the row's title cell, the hotspot that opens the row (`data-cell-open`), with the column's `indicator` beside the name. A title whose field is a number, a percent, a currency, a date, a datetime or a name draws through that field, so a dated identity reads as a date; any other title draws as its text.
76
76
  - A relation chip goes where your `RelationLink` atom says, the app-wide answer for each kind of record. `onOpenRelation` overrides it for one surface and is handed the chip that was pressed, which matters when a cell holds several.
77
77
  - A `command` column handed `commandItems` opens your `CommandMenu` atom: the verbs for this row in place of an editor. The trigger is the value itself, or a chevron beside it where the value is a control of its own (a relation, a user, a link, an email, a phone or a domain). Without `commandItems` the cell is a plain value. [A command field](../contract.md#a-command-field) in the contract says where the verbs come from.
78
- - Any other column draws its field's display, in the code `resolveRowCurrency` finds for a money value.
78
+ - Any other column draws its field's display, in the code `resolveRowCurrency` finds for a money value. A money figure the column reads converted from the row's own currency (`convertedFromOf`) comes back marked: ≈ before it and a title naming the currency it came from (`ConvertedFigure`).
79
79
 
80
80
  ```tsx
81
81
  import { renderIdentityValue, renderTypedCellValue } from "@viewkitjs/views/cells";
@@ -91,7 +91,7 @@ The options, `GridCellOptions`, are all optional, and the grid fills the same on
91
91
  - How it reads: `viewer` and `presentation` (both default to the provider's), `dateStyle`, `durationStyle`, `decimals`, `withTime`, `percentDisplay`, `optionColors`, and `wrap`, which lets text wrap instead of truncating.
92
92
  - The row's answers: `currency`, `valueOverride` and `markerReason`.
93
93
  - The verbs: `onToggle` (a two-way boolean is clickable only when it is given), `onResolve` (clears a marker), `commandItems` and `onOpenRelation`.
94
- - Your host's: `entityIcon`, your glyph for a kind of record, and `slotOwnsClick`, for a host whose own element is the button (a calendar's event card): every cell inside it draws bare content, with no link, button or popover trigger of its own.
94
+ - Your host's: `entityIcon`, your glyph for a kind of record, and `slotOwnsClick`, for a host whose own element is the button (a calendar's event card): every cell inside it draws bare content, with no link, button or popover trigger of its own. `hostOwnsPlainClick`, for a host whose plain click on a value is its own (the grid, where it selects the cell): an email, phone, url or domain stays a link, marked `data-cell-link`, and lets the click through for your host to decide.
95
95
 
96
96
  [The cells reference](../reference/cells.md) has each one.
97
97