@viewkitjs/views 0.1.0 → 0.2.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 (246) hide show
  1. package/CHANGELOG.md +196 -1
  2. package/README.md +90 -41
  3. package/dist/atoms/Row.js +1 -1
  4. package/dist/atoms/RowMenu.d.ts +1 -1
  5. package/dist/atoms/RowMenu.js +15 -4
  6. package/dist/atoms/types.d.ts +4 -4
  7. package/dist/contract.d.ts +37 -7
  8. package/dist/contract.js +24 -5
  9. package/dist/display/format.d.ts +16 -1
  10. package/dist/display/format.js +10 -1
  11. package/dist/display/index.d.ts +1 -1
  12. package/dist/display/index.js +1 -1
  13. package/dist/display/link.js +5 -3
  14. package/dist/display/location.d.ts +4 -3
  15. package/dist/display/location.js +12 -5
  16. package/dist/display/options.d.ts +1 -1
  17. package/dist/display/percent.js +10 -3
  18. package/dist/display/phone.d.ts +2 -1
  19. package/dist/display/phone.js +8 -1
  20. package/dist/display/relation.js +1 -1
  21. package/dist/editors/ChipsEditor.js +1 -1
  22. package/dist/editors/LocationEditor.js +16 -17
  23. package/dist/editors/NameEditor.js +5 -4
  24. package/dist/editors/NumberEditor.js +2 -2
  25. package/dist/editors/RangeEditor.js +2 -2
  26. package/dist/editors/ValueListEditor.d.ts +2 -2
  27. package/dist/editors/ValueListEditor.js +8 -8
  28. package/dist/editors/edit-cores.d.ts +1 -1
  29. package/dist/fields/binding.d.ts +1 -1
  30. package/dist/fields/currency.d.ts +0 -10
  31. package/dist/fields/currency.js +0 -14
  32. package/dist/fields/money.d.ts +1 -0
  33. package/dist/fields/money.js +1 -0
  34. package/dist/filters/filter-model.d.ts +0 -1
  35. package/dist/filters/registry.d.ts +3 -36
  36. package/dist/filters/registry.js +0 -38
  37. package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
  38. package/dist/grid/chrome/GridAddColumn.js +29 -0
  39. package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
  40. package/dist/grid/chrome/GridAggregateMenu.js +27 -0
  41. package/dist/grid/chrome/GridCellEditors.d.ts +64 -0
  42. package/dist/grid/chrome/GridCellEditors.js +55 -0
  43. package/dist/grid/chrome/GridCellOutline.d.ts +70 -0
  44. package/dist/grid/chrome/GridCellOutline.js +21 -0
  45. package/dist/grid/chrome/GridChipsEditor.d.ts +28 -0
  46. package/dist/grid/chrome/GridChipsEditor.js +40 -0
  47. package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
  48. package/dist/grid/chrome/GridColumnColorSection.js +40 -0
  49. package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
  50. package/dist/grid/chrome/GridColumnDateSection.js +23 -0
  51. package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
  52. package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
  53. package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
  54. package/dist/grid/chrome/GridColumnMenu.js +99 -0
  55. package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
  56. package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
  57. package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
  58. package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
  59. package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
  60. package/dist/grid/chrome/GridColumnSortSection.js +16 -0
  61. package/dist/grid/chrome/GridDateEditor.d.ts +22 -0
  62. package/dist/grid/chrome/GridDateEditor.js +31 -0
  63. package/dist/grid/chrome/GridFlyout.d.ts +44 -0
  64. package/dist/grid/chrome/GridFlyout.js +80 -0
  65. package/dist/grid/chrome/GridFooter.d.ts +23 -0
  66. package/dist/grid/chrome/GridFooter.js +81 -0
  67. package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
  68. package/dist/grid/chrome/GridGroupMenu.js +57 -0
  69. package/dist/grid/chrome/GridHeader.d.ts +61 -0
  70. package/dist/grid/chrome/GridHeader.js +37 -0
  71. package/dist/grid/chrome/GridLongTextEditor.d.ts +36 -0
  72. package/dist/grid/chrome/GridLongTextEditor.js +127 -0
  73. package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
  74. package/dist/grid/chrome/GridMenuRow.js +15 -0
  75. package/dist/grid/chrome/GridNameEditor.d.ts +19 -0
  76. package/dist/grid/chrome/GridNameEditor.js +36 -0
  77. package/dist/grid/chrome/GridNumberEditor.d.ts +35 -0
  78. package/dist/grid/chrome/GridNumberEditor.js +25 -0
  79. package/dist/grid/chrome/GridRangeEditor.d.ts +20 -0
  80. package/dist/grid/chrome/GridRangeEditor.js +25 -0
  81. package/dist/grid/chrome/GridRelationEditor.d.ts +21 -0
  82. package/dist/grid/chrome/GridRelationEditor.js +30 -0
  83. package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
  84. package/dist/grid/chrome/GridResizeHandle.js +19 -0
  85. package/dist/grid/chrome/GridRow.d.ts +25 -0
  86. package/dist/grid/chrome/GridRow.js +136 -0
  87. package/dist/grid/chrome/GridRowActions.d.ts +32 -0
  88. package/dist/grid/chrome/GridRowActions.js +25 -0
  89. package/dist/grid/chrome/GridRowCells.d.ts +4 -0
  90. package/dist/grid/chrome/GridRowCells.js +133 -0
  91. package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
  92. package/dist/grid/chrome/GridRowGlyph.js +13 -0
  93. package/dist/grid/chrome/GridSelectEditor.d.ts +18 -0
  94. package/dist/grid/chrome/GridSelectEditor.js +49 -0
  95. package/dist/grid/chrome/GridStructure.d.ts +48 -0
  96. package/dist/grid/chrome/GridStructure.js +45 -0
  97. package/dist/grid/chrome/GridTable.d.ts +4 -0
  98. package/dist/grid/chrome/GridTable.js +125 -0
  99. package/dist/grid/chrome/GridTableSurface.d.ts +15 -0
  100. package/dist/grid/chrome/GridTableSurface.js +6 -0
  101. package/dist/grid/chrome/GridTextEditor.d.ts +11 -0
  102. package/dist/grid/chrome/GridTextEditor.js +40 -0
  103. package/dist/grid/chrome/GridValueListEditor.d.ts +18 -0
  104. package/dist/grid/chrome/GridValueListEditor.js +36 -0
  105. package/dist/grid/chrome/StuckMarker.d.ts +16 -0
  106. package/dist/grid/chrome/StuckMarker.js +34 -0
  107. package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
  108. package/dist/grid/chrome/cell-clipboard.js +28 -0
  109. package/dist/grid/chrome/cells.d.ts +21 -0
  110. package/dist/grid/chrome/cells.js +20 -0
  111. package/dist/grid/chrome/checks.d.ts +35 -0
  112. package/dist/grid/chrome/checks.js +22 -0
  113. package/dist/grid/chrome/column-glyph.d.ts +14 -0
  114. package/dist/grid/chrome/column-glyph.js +44 -0
  115. package/dist/grid/chrome/editors.d.ts +9 -0
  116. package/dist/grid/chrome/editors.js +10 -0
  117. package/dist/grid/chrome/grid-cell-classes.d.ts +59 -0
  118. package/dist/grid/chrome/grid-cell-classes.js +30 -0
  119. package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
  120. package/dist/grid/chrome/grid-menu-search.js +7 -0
  121. package/dist/grid/chrome/grid-row-props.d.ts +131 -0
  122. package/dist/grid/chrome/grid-row-props.js +1 -0
  123. package/dist/grid/chrome/grid-styles.d.ts +37 -0
  124. package/dist/grid/chrome/grid-styles.js +8 -0
  125. package/dist/grid/chrome/grid-table-props.d.ts +173 -0
  126. package/dist/grid/chrome/grid-table-props.js +1 -0
  127. package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
  128. package/dist/grid/chrome/useGridBatchApi.js +35 -0
  129. package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
  130. package/dist/grid/chrome/useGridColumnLayout.js +206 -0
  131. package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
  132. package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
  133. package/dist/grid/chrome/useGridKeyboard.d.ts +47 -0
  134. package/dist/grid/chrome/useGridKeyboard.js +274 -0
  135. package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
  136. package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
  137. package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
  138. package/dist/grid/chrome/useGridRailReveal.js +67 -0
  139. package/dist/grid/chrome/useGridRangeActions.d.ts +49 -0
  140. package/dist/grid/chrome/useGridRangeActions.js +188 -0
  141. package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
  142. package/dist/grid/chrome/useGridRangeGestures.js +190 -0
  143. package/dist/grid/chrome/useGridRowContextMenu.d.ts +35 -0
  144. package/dist/grid/chrome/useGridRowContextMenu.js +127 -0
  145. package/dist/grid/chrome/useGridScaleStyles.d.ts +1 -0
  146. package/dist/grid/chrome/useGridScaleStyles.js +29 -0
  147. package/dist/grid/chrome/useGridScrollSync.d.ts +38 -0
  148. package/dist/grid/chrome/useGridScrollSync.js +176 -0
  149. package/dist/grid/chrome/useGridTableInteractionModel.d.ts +55 -0
  150. package/dist/grid/chrome/useGridTableInteractionModel.js +197 -0
  151. package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
  152. package/dist/grid/chrome/useGridTableSelection.js +55 -0
  153. package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
  154. package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
  155. package/dist/grid/core/clipboard-model.d.ts +81 -0
  156. package/dist/grid/core/clipboard-model.js +291 -0
  157. package/dist/grid/core/column-values.d.ts +27 -0
  158. package/dist/grid/core/column-values.js +76 -0
  159. package/dist/grid/core/commit-model.d.ts +34 -0
  160. package/dist/grid/core/commit-model.js +3 -0
  161. package/dist/grid/core/coordinates.d.ts +48 -0
  162. package/dist/grid/core/coordinates.js +27 -0
  163. package/dist/grid/core/edit-values.d.ts +9 -0
  164. package/dist/grid/core/edit-values.js +1 -0
  165. package/dist/grid/core/editing-controller.d.ts +59 -0
  166. package/dist/grid/core/editing-controller.js +240 -0
  167. package/dist/grid/core/editing-model.d.ts +78 -0
  168. package/dist/grid/core/editing-model.js +136 -0
  169. package/dist/grid/core/grid-scale.d.ts +14 -0
  170. package/dist/grid/core/grid-scale.js +8 -0
  171. package/dist/grid/core/nav.d.ts +94 -0
  172. package/dist/grid/core/nav.js +92 -0
  173. package/dist/grid/core/pending-reconciliation.d.ts +50 -0
  174. package/dist/grid/core/pending-reconciliation.js +49 -0
  175. package/dist/grid/core/range-model.d.ts +25 -0
  176. package/dist/grid/core/range-model.js +59 -0
  177. package/dist/grid/core/spreadsheet-operations.d.ts +85 -0
  178. package/dist/grid/core/spreadsheet-operations.js +253 -0
  179. package/dist/grid/core/useGridEditing.d.ts +43 -0
  180. package/dist/grid/core/useGridEditing.js +90 -0
  181. package/dist/grid/core/useGridRange.d.ts +20 -0
  182. package/dist/grid/core/useGridRange.js +24 -0
  183. package/dist/grid/core/value-equality.d.ts +32 -0
  184. package/dist/grid/core/value-equality.js +34 -0
  185. package/dist/grid/index.d.ts +18 -0
  186. package/dist/grid/index.js +5 -0
  187. package/dist/grid/useGridTablePrefs.d.ts +50 -0
  188. package/dist/grid/useGridTablePrefs.js +101 -0
  189. package/dist/index.d.ts +0 -1
  190. package/dist/index.js +0 -1
  191. package/dist/internal/viewport.d.ts +5 -0
  192. package/dist/internal/viewport.js +29 -0
  193. package/dist/model/column-capabilities.d.ts +2 -2
  194. package/dist/model/column-state.d.ts +1 -1
  195. package/dist/model/density.js +3 -3
  196. package/dist/model/filter-capabilities.d.ts +1 -1
  197. package/dist/model/filter-capabilities.js +1 -1
  198. package/dist/model/index.d.ts +4 -6
  199. package/dist/model/index.js +0 -1
  200. package/dist/model/preferences.d.ts +7 -3
  201. package/dist/provider/ViewsProvider.d.ts +1 -1
  202. package/dist/provider/ViewsProvider.js +5 -1
  203. package/dist/provider/components.d.ts +16 -8
  204. package/dist/provider/context.d.ts +3 -2
  205. package/dist/provider/menu-groups.d.ts +8 -0
  206. package/dist/provider/menu-groups.js +38 -0
  207. package/dist/provider/ports.d.ts +22 -0
  208. package/dist/provider/ports.js +1 -0
  209. package/dist/react.d.ts +1 -1
  210. package/docs/contract.md +128 -56
  211. package/docs/getting-started.md +250 -0
  212. package/docs/guides/atoms.md +245 -0
  213. package/docs/guides/cells.md +302 -0
  214. package/docs/guides/columns.md +412 -0
  215. package/docs/guides/display.md +203 -0
  216. package/docs/guides/editors.md +404 -0
  217. package/docs/guides/ports.md +246 -0
  218. package/docs/guides/selection.md +270 -0
  219. package/docs/guides/the-grid.md +677 -0
  220. package/docs/guides/the-provider.md +446 -0
  221. package/docs/index.md +50 -0
  222. package/docs/install.md +9 -47
  223. package/docs/reference/cells.md +28 -0
  224. package/docs/reference/display.md +42 -0
  225. package/docs/reference/editors-chips.md +6 -0
  226. package/docs/reference/editors-date.md +6 -0
  227. package/docs/reference/editors-location.md +10 -0
  228. package/docs/reference/editors-name.md +6 -0
  229. package/docs/reference/editors-number.md +11 -0
  230. package/docs/reference/editors-open-values.md +9 -0
  231. package/docs/reference/editors-range.md +6 -0
  232. package/docs/reference/editors-relation.md +9 -0
  233. package/docs/reference/editors-select.md +8 -0
  234. package/docs/reference/editors-session.md +9 -0
  235. package/docs/reference/editors-value-list.md +6 -0
  236. package/docs/reference/editors.md +5 -0
  237. package/docs/reference/grid.md +39 -0
  238. package/docs/reference/react.md +86 -0
  239. package/docs/reference/selection.md +33 -0
  240. package/docs/reference/views.md +601 -0
  241. package/package.json +7 -3
  242. package/skills/views/SKILL.md +20 -5
  243. package/dist/filters/types.d.ts +0 -27
  244. package/dist/filters/types.js +0 -1
  245. package/dist/model/filter-pushdown.d.ts +0 -106
  246. package/dist/model/filter-pushdown.js +0 -147
package/dist/contract.js CHANGED
@@ -45,6 +45,7 @@ export const VK_TOKENS = [
45
45
  "--vk-px",
46
46
  "--vk-cell-py",
47
47
  "--vk-tail-py",
48
+ "--vk-tail-pl",
48
49
  "--vk-rail-w",
49
50
  "--vk-rail-gap",
50
51
  "--vk-tail-w",
@@ -60,6 +61,9 @@ export const VK_TOKENS = [
60
61
  "--vk-scrolled",
61
62
  "--vk-parked",
62
63
  "--vk-frozen-on",
64
+ "--vk-row-py",
65
+ "--vk-head-mb",
66
+ "--vk-row-gap",
63
67
  ];
64
68
  export const VK_COLOURS = [
65
69
  "--vk-fg",
@@ -95,7 +99,9 @@ export const VK_OPTIONAL_COLOURS = [
95
99
  "--vk-label-pink",
96
100
  "--vk-label-teal",
97
101
  ];
98
- export const VK_OPTIONAL_LAYOUT = ["--vk-gutter"];
102
+ export const VK_OPTIONAL_LAYOUT = ["--vk-gutter", "--vk-pinned-top"];
103
+ export const VK_INTERNAL = ["--vk-drag-shift"];
104
+ export const VK_INTERNAL_FAMILIES = ["--vk-col-w-"];
99
105
  export const COMPONENT_NAMES = [
100
106
  "Button",
101
107
  "Popover",
@@ -126,7 +132,7 @@ export const ATOM_SLOTS = [
126
132
  "vk-row-menu",
127
133
  ];
128
134
  export const ATOM_STATES = ["chosen", "disabled", "muted", "checked", "open", "status", "platform"];
129
- export const PORT_NAMES = ["toast", "haptics", "clipboard", "viewPrefs"];
135
+ export const PORT_NAMES = ["toast", "haptics", "clipboard", "viewPrefs", "confirm"];
130
136
  export const ICON_NAMES = [
131
137
  "text",
132
138
  "longText",
@@ -279,6 +285,7 @@ export const VIEWS_MESSAGE_KEYS = [
279
285
  "views.menus.row-select",
280
286
  "views.menus.row-delete",
281
287
  "views.menus.row-delete-confirm",
288
+ "views.menus.row-delete-failed",
282
289
  "views.grid.figure",
283
290
  "views.grid.figure-pick",
284
291
  "views.grid.add-column",
@@ -312,10 +319,13 @@ export const VIEWS_MESSAGE_KEYS = [
312
319
  "views.grid.paste-not-duration",
313
320
  "views.grid.paste-not-date",
314
321
  "views.grid.paste-not-option",
322
+ "views.grid.paste-ambiguous-option",
323
+ "views.grid.paste-other-currency",
315
324
  "views.grid.paste-pick",
316
325
  "views.grid.paste-not-linkable",
317
326
  "views.grid.paste-not-range",
318
- "views.grid.paste-failed",
327
+ "views.grid.paste-skipped",
328
+ "views.grid.fill-skipped",
319
329
  "views.grid.changed-elsewhere",
320
330
  "views.grid.changed-elsewhere-cells",
321
331
  "views.grid.saved-value",
@@ -386,6 +396,7 @@ const DURATION_STYLE_WORDS = {
386
396
  units: "Units",
387
397
  };
388
398
  const PERCENT_DISPLAY_WORDS = { text: "Number", bar: "Bar", ring: "Ring" };
399
+ const cellsWerent = (count) => (count === 1 ? "1 cell wasn't" : `${count} cells weren't`);
389
400
  export function resolveViewsMessage(message) {
390
401
  switch (message.key) {
391
402
  case "views.editors.tag-remove":
@@ -546,6 +557,8 @@ export function resolveViewsMessage(message) {
546
557
  return "Delete";
547
558
  case "views.menus.row-delete-confirm":
548
559
  return "Delete this row?";
560
+ case "views.menus.row-delete-failed":
561
+ return "Failed to delete the row";
549
562
  case "views.grid.figure":
550
563
  return FIGURE_WORDS[message.values.kind];
551
564
  case "views.grid.figure-pick":
@@ -612,14 +625,20 @@ export function resolveViewsMessage(message) {
612
625
  return "Not a date";
613
626
  case "views.grid.paste-not-option":
614
627
  return `“${message.values.value}” is not an option here`;
628
+ case "views.grid.paste-ambiguous-option":
629
+ return `“${message.values.value}” names more than one option`;
630
+ case "views.grid.paste-other-currency":
631
+ return `This record is in ${message.values.currency}`;
615
632
  case "views.grid.paste-pick":
616
633
  return `“${message.values.value}” can't be pasted here — pick it from the list`;
617
634
  case "views.grid.paste-not-linkable":
618
635
  return `“${message.values.value}” is not linkable here`;
619
636
  case "views.grid.paste-not-range":
620
637
  return "Not a range — try 11–50, 200+ or up to 50";
621
- case "views.grid.paste-failed":
622
- return `Failed to paste ${message.values.count} cell${message.values.count === 1 ? "" : "s"}`;
638
+ case "views.grid.paste-skipped":
639
+ return `${cellsWerent(message.values.count)} pasted: ${message.values.reason}`;
640
+ case "views.grid.fill-skipped":
641
+ return `${cellsWerent(message.values.count)} filled: ${message.values.reason}`;
623
642
  case "views.grid.changed-elsewhere":
624
643
  return `${message.values.field} was changed elsewhere`;
625
644
  case "views.grid.changed-elsewhere-cells":
@@ -36,12 +36,27 @@ export declare function formatNumberValue(value: number, format: NumberLikeForma
36
36
  * both and the caller resolves which style won.
37
37
  */
38
38
  export declare function formatDateValue(value: unknown, dateStyle: DateStyle | undefined, withTime?: boolean, kind?: TemporalKind, opts?: Pick<DisplayOptions, "presentation" | "viewer">): string;
39
+ /**
40
+ * An amount rendered in its OWN currency, with the right symbol and placement.
41
+ *
42
+ * Replaces four hand-rolled copies of `currency === "EUR" ? "€" : "$"`, which
43
+ * printed every RON amount as dollars — so a €53 Vodafone bill charged as 280
44
+ * RON rendered "$280.00" in the drawer, the hero and the history tab.
45
+ *
46
+ * Written as a money cell writes it (`formatNumberValue`, through the
47
+ * presentation's `number` for the viewer): hand it the display options a cell
48
+ * gets, and the amount reads in the viewer's locale and the app's look. With
49
+ * none, the default presentation and the neutral conventions (`en-GB`). The
50
+ * catch covers a code `Intl` doesn't accept, so a row with junk in the column
51
+ * still renders its number instead of throwing.
52
+ */
53
+ export declare function formatMoney(amount: number | null | undefined, currency: string | null | undefined, decimals?: number, opts?: Pick<DisplayOptions, "presentation" | "viewer">): string;
39
54
  /**
40
55
  * THE unit-suffix look (a "/mo" after a price). Any renderer — a typed core, a
41
56
  * custom cell, a group aggregate — uses this, so suffixes never diverge in style.
42
57
  *
43
58
  * Built with `createElement` rather than JSX because this module is the FORMAT
44
- * module: its other two exports are pure string functions that a Node-side
59
+ * module: its other exports are pure string functions that a Node-side
45
60
  * consumer can import, and one 3-line node is not worth turning the file into a
46
61
  * component module to get angle brackets.
47
62
  */
@@ -174,8 +174,17 @@ export function formatDateValue(value, dateStyle, withTime, kind = "datetime", o
174
174
  }
175
175
  return out;
176
176
  }
177
+ export function formatMoney(amount, currency, decimals = 2, opts) {
178
+ const code = (currency || "EUR").toUpperCase();
179
+ try {
180
+ return formatNumberValue(amount ?? 0, { style: "currency", currency: code }, { presentation: opts?.presentation, viewer: opts?.viewer, currency: code, decimals });
181
+ }
182
+ catch {
183
+ return `${code} ${(amount ?? 0).toFixed(decimals)}`;
184
+ }
185
+ }
177
186
  export function CellSuffix({ children }) {
178
187
  return createElement("span", {
179
- className: "ml-1 text-(length:--grid-text-xs,0.75rem) font-normal text-(color:--vk-fg-subtlest)",
188
+ className: "ml-1 text-(length:--vk-text-xs,0.75rem) font-normal text-(color:--vk-fg-subtlest)",
180
189
  }, children);
181
190
  }
@@ -1,7 +1,7 @@
1
1
  export { DISPLAY_CORES, renderFieldValue, type DisplayCore } from "./display-cores.js";
2
2
  export { webHref } from "./web-href.js";
3
3
  export type { DisplayOptions, FieldPresentation, FieldViewerContext, NumberLikeFormat, RelationWrap, } from "./options.js";
4
- export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatNumberValue } from "./format.js";
4
+ export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatMoney, formatNumberValue, } from "./format.js";
5
5
  export { viewerFrom } from "./viewer.js";
6
6
  export { cellTextClass } from "./text-class.js";
7
7
  export { MultiValueCell } from "./multi-value.js";
@@ -1,6 +1,6 @@
1
1
  export { DISPLAY_CORES, renderFieldValue } from "./display-cores.js";
2
2
  export { webHref } from "./web-href.js";
3
- export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatNumberValue } from "./format.js";
3
+ export { CellSuffix, DEFAULT_FIELD_PRESENTATION, formatDateValue, formatMoney, formatNumberValue, } from "./format.js";
4
4
  export { viewerFrom } from "./viewer.js";
5
5
  export { cellTextClass } from "./text-class.js";
6
6
  export { MultiValueCell } from "./multi-value.js";
@@ -38,11 +38,13 @@ function domainLink(domain, opts) {
38
38
  }
39
39
  export function renderEmail(_field, value, opts) {
40
40
  if (Array.isArray(value))
41
- return renderValueList(value, (one) => renderEmailAddress(String(one)), opts);
41
+ return renderValueList(value, (one) => renderEmailAddress(String(one), opts), opts);
42
42
  if (value == null || value === "")
43
43
  return null;
44
- return renderValueList([value], (one) => renderEmailAddress(String(one)), opts);
44
+ return renderValueList([value], (one) => renderEmailAddress(String(one), opts), opts);
45
45
  }
46
- function renderEmailAddress(address) {
46
+ function renderEmailAddress(address, opts) {
47
+ if (opts?.slotOwnsClick)
48
+ return _jsx("span", { children: address });
47
49
  return (_jsx("a", { href: `mailto:${address}`, "data-no-nav": true, className: "text-(color:--vk-fg) underline decoration-dotted decoration-(color:--vk-fg-subtle)/40 decoration-1 underline-offset-[3px] transition-colors hover:decoration-(color:--vk-fg-subtle)/60", onClick: (event) => event.stopPropagation(), children: address }));
48
50
  }
@@ -2,6 +2,7 @@ import { type FieldDefOf } from "@viewkitjs/fields";
2
2
  import type { DisplayOptions } from "./options.js";
3
3
  /** A place remains structured until the display boundary, then reads as one line. A cell draws it short, its city
4
4
  * and its country (`locationShort`); a host with room for the whole value (`wrap: "full"`) draws the whole place
5
- * (`locationText`). The country is named in the viewer's language. A list of places (a lookup through a many
6
- * relation, VK-63) draws through the several-values layout, each place written so. */
7
- export declare function renderLocation(field: FieldDefOf<"location">, value: unknown, opts?: DisplayOptions): string | import("react/jsx-runtime").JSX.Element | null;
5
+ * (`locationText`). The country is named in the viewer's language: the host's viewer, else the provider's
6
+ * conventions, as the place editor names it (VK-120). A list of places (a lookup through a many relation, VK-63)
7
+ * draws through the several-values layout, each place written so. */
8
+ export declare function renderLocation(field: FieldDefOf<"location">, value: unknown, opts?: DisplayOptions): import("react/jsx-runtime").JSX.Element | null;
@@ -2,14 +2,21 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { locationShort, locationText } from "@viewkitjs/fields";
4
4
  import { MultiValueCell } from "./multi-value.js";
5
+ import { useDisplayOptions } from "./use-display-options.js";
5
6
  export function renderLocation(field, value, opts) {
6
7
  void field;
7
8
  const write = opts?.wrap === "full" ? locationText : locationShort;
9
+ if (Array.isArray(value) ? !value.some((place) => write(place)) : !write(value))
10
+ return null;
11
+ return _jsx(PlaceValue, { value: value, opts: opts });
12
+ }
13
+ function PlaceValue({ value, opts: given }) {
14
+ const opts = useDisplayOptions(given);
15
+ const write = opts.wrap === "full" ? locationText : locationShort;
16
+ const locale = opts.viewer?.locale;
8
17
  if (Array.isArray(value)) {
9
- const places = value.map((place) => write(place, opts?.viewer?.locale)).filter(Boolean);
10
- if (places.length === 0)
11
- return null;
12
- return (_jsx(MultiValueCell, { items: places, wrap: !!opts?.wrap, title: places.join(", "), slotOwnsClick: opts?.slotOwnsClick }));
18
+ const places = value.map((place) => write(place, locale)).filter(Boolean);
19
+ return (_jsx(MultiValueCell, { items: places, wrap: !!opts.wrap, title: places.join(", "), slotOwnsClick: opts.slotOwnsClick }));
13
20
  }
14
- return write(value, opts?.viewer?.locale) || null;
21
+ return write(value, locale);
15
22
  }
@@ -98,7 +98,7 @@ export type DisplayOptions = {
98
98
  optionColors?: Record<string, CategoryColor>;
99
99
  /**
100
100
  * select/multiselect: the LIST's pre-registry label rule for a value no option
101
- * names. Absent, a stray value renders as the muted "unknown" chip (spec §3.6)
101
+ * names. Absent, a stray value renders as the muted "unknown" chip (fields' docs/guides/options.md)
102
102
  * — a registry field never invents a label for a code its vocabulary refuses.
103
103
  */
104
104
  labelFallback?: (value: string) => string;
@@ -24,10 +24,17 @@ function PercentValue({ field, n, opts: given }) {
24
24
  return (_jsxs("span", { className: cx(cellTextClass(opts?.wrap), "tabular-nums", toneClass), children: [figure, _jsx(CellSuffix, { children: "%" })] }));
25
25
  }
26
26
  const clamped = Math.max(0, Math.min(100, n));
27
- const figureSlot = `${5 + (decimals > 0 ? decimals + 1 : 0)}ch`;
28
- return (_jsxs("span", { className: cx("flex min-w-0 items-center gap-2", display === "bar" && "w-full flex-1"), style: display === "bar" ? { maxWidth: `calc(6rem + 0.5rem + ${figureSlot})` } : undefined, children: [display === "bar" ? (_jsx("span", { className: "h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-(color:--vk-neutral)", "aria-hidden": true, children: _jsx("span", { className: "block h-full bg-(color:--vk-brand)", style: { width: `${clamped}%` } }) })) : (_jsx("span", { className: "h-4 w-4 shrink-0 rounded-full", style: {
27
+ const figureSlot = `calc(${3 + decimals + (decimals > 0 ? 0.5 : 0) + 1.25}ch + 0.25rem)`;
28
+ const figureRoom = "calc(100% + var(--vk-px, 0px))";
29
+ const figureNode = (bar) => (_jsxs("span", { className: cx("shrink-0 text-right tabular-nums", bar && "truncate", toneClass), style: bar
30
+ ? { width: "max-content", minWidth: `min(${figureSlot}, ${figureRoom})`, maxWidth: figureRoom }
31
+ : { width: figureSlot }, children: [figure, _jsx(CellSuffix, { children: "%" })] }));
32
+ if (display === "bar") {
33
+ return (_jsxs("span", { className: "flex h-lh w-full min-w-0 flex-1 flex-row-reverse flex-wrap content-start items-center gap-x-2 overflow-y-clip", style: { maxWidth: `calc(6rem + 0.5rem + ${figureSlot})` }, children: [figureNode(true), _jsx("span", { className: "h-1.5 min-w-6 flex-1 overflow-hidden rounded-full bg-(color:--vk-neutral)", "aria-hidden": true, children: _jsx("span", { className: "block h-full bg-(color:--vk-brand)", style: { width: `${clamped}%` } }) })] }));
34
+ }
35
+ return (_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [_jsx("span", { className: "h-4 w-4 shrink-0 rounded-full", style: {
29
36
  background: `conic-gradient(var(--vk-brand) ${clamped}%, var(--vk-neutral) 0)`,
30
37
  WebkitMaskImage: RING_MASK,
31
38
  maskImage: RING_MASK,
32
- }, "aria-hidden": true })), _jsxs("span", { className: cx("shrink-0 text-right tabular-nums", toneClass), style: { width: figureSlot }, children: [figure, _jsx(CellSuffix, { children: "%" })] })] }));
39
+ }, "aria-hidden": true }), figureNode(false)] }));
33
40
  }
@@ -5,6 +5,7 @@ import type { DisplayOptions } from "./options.js";
5
5
  * A phone in its international form, written the way its country writes it for a viewer at home (the viewer's
6
6
  * region, from the conventions) and internationally for anyone else, its extension in the package's words after
7
7
  * it, dialled by its RFC 3966 link. A phone stored as typed, before phones had one form, is drawn as before (its
8
- * text, a link of its digits and a leading `+`) and flagged as not yet in the international form.
8
+ * text, a link of its digits and a leading `+`) and flagged as not yet in the international form. The viewer is
9
+ * the host's, else the provider's conventions and words (VK-120).
9
10
  */
10
11
  export declare function renderPhone(_field: FieldDefOf<"phone">, value: unknown, opts?: DisplayOptions): ReactNode;
@@ -5,10 +5,17 @@ import { resolveViewsMessage } from "../contract.js";
5
5
  import { cx } from "../internal/cx.js";
6
6
  import { CHIP_INTERACTIVE } from "../internal/chip.js";
7
7
  import { cellTextClass } from "./text-class.js";
8
+ import { useDisplayOptions } from "./use-display-options.js";
8
9
  import { renderValueList } from "./value-list.js";
9
10
  export function renderPhone(_field, value, opts) {
11
+ if (!Array.isArray(value) && !readPhone(value))
12
+ return null;
13
+ return _jsx(PhoneValue, { value: value, opts: opts });
14
+ }
15
+ function PhoneValue({ value, opts: given }) {
16
+ const opts = useDisplayOptions(given);
10
17
  if (Array.isArray(value))
11
- return renderValueList(value, (one) => phoneNode(one, opts && { ...opts, wrap: false }), opts, (one) => phoneLine(one, opts) ?? String(one));
18
+ return renderValueList(value, (one) => phoneNode(one, { ...opts, wrap: false }), opts, (one) => phoneLine(one, opts) ?? String(one));
12
19
  return phoneNode(value, opts);
13
20
  }
14
21
  function phoneLine(value, opts) {
@@ -13,7 +13,7 @@ export function renderRelation(field, value, opts) {
13
13
  .filter((entry) => entry != null));
14
14
  if (chips.length === 0)
15
15
  return null;
16
- return (_jsx(MultiValueCell, { items: chips.map((chip) => _jsx(RelationChip, { relation: chip, opts: opts })), wrap: !!opts?.wrap, title: chips.map((chip) => chip.label).join(", "), slotOwnsClick: opts?.slotOwnsClick }));
16
+ return (_jsx(MultiValueCell, { items: chips.map((chip) => _jsx(RelationChip, { relation: chip, opts: opts }, `${chip.entity ?? ""}:${chip.id}`)), wrap: !!opts?.wrap, title: chips.map((chip) => chip.label).join(", "), slotOwnsClick: opts?.slotOwnsClick }));
17
17
  }
18
18
  const relation = resolveRelationValue(value, relationKinds(field)[0]);
19
19
  if (!relation)
@@ -27,7 +27,7 @@ export const ChipsEditor = forwardRef(function ChipsEditor({ values, suggestions
27
27
  setDraft(next);
28
28
  };
29
29
  useEffect(() => {
30
- inputRef.current?.focus();
30
+ inputRef.current?.focus({ preventScroll: true });
31
31
  }, []);
32
32
  const clean = (raw) => (normalize ? normalize(raw) : raw.trim());
33
33
  const rows = useMemo(() => suggestions.filter((value) => !draft.includes(value)), [suggestions, draft]);
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
3
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState, } from "react";
4
4
  import { COUNTRY_CODES, countryName, LOCATION_PARTS, placeFormat, sameStoredValue, } from "@viewkitjs/fields";
5
5
  import { loadRegions, regionLabel } from "@viewkitjs/fields/places";
6
6
  import { placeWordKey } from "../contract.js";
@@ -18,6 +18,10 @@ function draftOf(initial) {
18
18
  }
19
19
  return draft;
20
20
  }
21
+ function withFilled(kept, draft) {
22
+ const filled = GENERIC.filter((part) => !kept.has(part) && draft[part]?.trim());
23
+ return filled.length === 0 ? kept : new Set([...kept, ...filled]);
24
+ }
21
25
  export const LocationEditor = forwardRef(function LocationEditor({ field, initial, allowEmpty = false, conventions, onRequestClose }, ref) {
22
26
  const views = useViews();
23
27
  const locale = (conventions ?? views.conventions).locale;
@@ -29,9 +33,11 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
29
33
  const takesCountry = parts.includes("countryCode");
30
34
  const [draft, setDraftState] = useState(() => draftOf(initial));
31
35
  const draftRef = useRef(draft);
36
+ const [keptShown, setKeptShown] = useState(() => withFilled(new Set(), draft));
32
37
  const setDraft = (next) => {
33
38
  draftRef.current = next;
34
39
  setDraftState(next);
40
+ setKeptShown((kept) => withFilled(kept, next));
35
41
  };
36
42
  const country = draft.countryCode?.trim() || null;
37
43
  const [choosingCountry, setChoosingCountry] = useState(takesCountry && !country);
@@ -52,7 +58,6 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
52
58
  };
53
59
  }, [wantsRegions, country]);
54
60
  const regionList = regions && regions.country === country && regions.list.length > 0 ? regions.list : null;
55
- const keptShown = useRef(new Set());
56
61
  const lastFocused = useRef(null);
57
62
  const rows = useMemo(() => {
58
63
  const laidOut = new Set();
@@ -67,15 +72,13 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
67
72
  const shown = (part) => {
68
73
  if (field.parts)
69
74
  return parts.includes(part);
70
- if (draft[part]?.trim())
71
- keptShown.current.add(part);
72
- return keptShown.current.has(part);
75
+ return keptShown.has(part);
73
76
  };
74
77
  for (const part of GENERIC)
75
78
  if (!laidOut.has(part) && shown(part))
76
79
  lines.push([part]);
77
80
  return lines;
78
- }, [format, parts, field.parts, draft]);
81
+ }, [format, parts, field.parts, keptShown]);
79
82
  const countries = useMemo(() => COUNTRY_CODES.map((code) => ({ code, name: countryName(code, locale) })).sort((a, b) => a.name.localeCompare(b.name, locale)), [locale]);
80
83
  const resolveClose = (reason) => {
81
84
  if (reason === "escape")
@@ -102,8 +105,9 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
102
105
  const last = lastFocused.current
103
106
  ? box.querySelector(`[data-place-part="${lastFocused.current}"]`)
104
107
  : null;
105
- (last ?? box.querySelector("[data-place-focus]"))?.focus();
108
+ (last ?? box.querySelector("[data-place-focus]"))?.focus({ preventScroll: true });
106
109
  }, [choosingCountry, choosingRegion, regionList]);
110
+ const focusSearch = useCallback((el) => el?.focus({ preventScroll: true }), []);
107
111
  const pickCountry = (code) => {
108
112
  const current = draftRef.current;
109
113
  const next = { ...current, countryCode: code };
@@ -178,9 +182,9 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
178
182
  ? { "aria-required": true, "data-required": "" }
179
183
  : { "data-required": "" }
180
184
  : {};
181
- const input = "h-7 w-24 min-w-0 flex-1 select-text bg-transparent text-(length:--grid-text) text-(color:--vk-fg) outline-hidden";
185
+ const input = "h-7 w-24 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden";
182
186
  const button = `${input} cursor-pointer truncate text-left`;
183
- const search = (value, onChange, placeholder) => (_jsx(Command.Input, { value: value, onValueChange: onChange, placeholder: placeholder, autoFocus: true, className: "h-9 text-[13px]", onKeyDown: (e) => {
187
+ const search = (value, onChange, placeholder) => (_jsx(Command.Input, { ref: focusSearch, value: value, onValueChange: onChange, placeholder: placeholder, className: "h-9 text-[13px]", onKeyDown: (e) => {
184
188
  if (e.key === "Escape") {
185
189
  e.stopPropagation();
186
190
  if (choosingRegion)
@@ -213,14 +217,9 @@ export const LocationEditor = forwardRef(function LocationEditor({ field, initia
213
217
  body = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: wordOf("region"), children: [search(regionQuery, setRegionQuery, say({ key: "views.editors.place-region-search" })), list(shown.map(({ region, label }) => (_jsx(Command.Item, { value: region.code ?? region.name, onSelect: () => pickRegion(region), chosen: label === draft.region, children: _jsx(RowContent, { size: "compact", label: label, chosen: label === draft.region, chosenTint: false }) }, region.code ?? region.name))))] }));
214
218
  }
215
219
  else {
216
- let focusSet = false;
217
- const focus = () => {
218
- if (focusSet)
219
- return {};
220
- focusSet = true;
221
- return { "data-place-focus": "" };
222
- };
223
- body = (_jsxs(_Fragment, { children: [takesCountry && country && (_jsx("button", { type: "button", "data-place-control": "", "aria-label": `${say({ key: "views.editors.place-change-country" })}: ${countryName(country, locale)}`, onClick: () => setChoosingCountry(true), onKeyDown: keys, className: `${button} font-medium`, children: countryName(country, locale) })), rows.map((row) => (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: row.map((part) => part === "region" && regionList ? (_jsx("button", { type: "button", "data-place-control": "", ...focus(), ...required(part, "button"), "data-place-part": part, "aria-label": draft.region ? `${labelOf(part)}: ${draft.region}` : labelOf(part), onFocus: () => (lastFocused.current = part), onClick: () => setChoosingRegion(true), onKeyDown: keys, className: `${button} ${draft.region ? "" : "text-(color:--vk-fg-subtle)"}`, children: draft.region || labelOf(part) }, part)) : (_jsx("input", { "data-place-control": "", ...focus(), ...required(part, "input"), "data-place-part": part, onFocus: () => (lastFocused.current = part), value: draft[part] ?? "", "aria-label": labelOf(part), placeholder: labelOf(part), onChange: (e) => type(part, e.target.value), onKeyDown: keys, onClick: (e) => e.stopPropagation(), className: input }, part))) }, row.join(" "))))] }));
220
+ const focusPart = rows[0]?.[0];
221
+ const focus = (part) => (part === focusPart ? { "data-place-focus": "" } : {});
222
+ body = (_jsxs(_Fragment, { children: [takesCountry && country && (_jsx("button", { type: "button", "data-place-control": "", "aria-label": `${say({ key: "views.editors.place-change-country" })}: ${countryName(country, locale)}`, onClick: () => setChoosingCountry(true), onKeyDown: keys, className: `${button} font-medium`, children: countryName(country, locale) })), rows.map((row) => (_jsx("span", { className: "flex min-w-0 items-center gap-1.5", children: row.map((part) => part === "region" && regionList ? (_jsx("button", { type: "button", "data-place-control": "", ...focus(part), ...required(part, "button"), "data-place-part": part, "aria-label": draft.region ? `${labelOf(part)}: ${draft.region}` : labelOf(part), onFocus: () => (lastFocused.current = part), onClick: () => setChoosingRegion(true), onKeyDown: keys, className: `${button} ${draft.region ? "" : "text-(color:--vk-fg-subtle)"}`, children: draft.region || labelOf(part) }, part)) : (_jsx("input", { "data-place-control": "", ...focus(part), ...required(part, "input"), "data-place-part": part, onFocus: () => (lastFocused.current = part), value: draft[part] ?? "", "aria-label": labelOf(part), placeholder: labelOf(part), onChange: (e) => type(part, e.target.value), onKeyDown: keys, onClick: (e) => e.stopPropagation(), className: input }, part))) }, row.join(" "))))] }));
224
223
  }
225
224
  return (_jsx("div", { ref: boxRef, onBlur: blur, onMouseDown: (e) => {
226
225
  if (!(e.target instanceof HTMLInputElement))
@@ -15,8 +15,9 @@ function fromParts(given, family) {
15
15
  export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowEmpty = false, onRequestClose }, ref) {
16
16
  const views = useViews();
17
17
  const boxRef = useRef(null);
18
+ const givenRef = useRef(null);
18
19
  const refs = {
19
- given: useRef(null),
20
+ given: givenRef,
20
21
  family: useRef(null),
21
22
  full: useRef(null),
22
23
  };
@@ -30,10 +31,10 @@ export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowE
30
31
  const [partsEdited, setPartsEdited] = useState(seed !== undefined);
31
32
  const full = ownFull || !partsEdited ? typedFull : fromParts(given, family);
32
33
  useEffect(() => {
33
- const el = refs.given.current;
34
+ const el = givenRef.current;
34
35
  if (!el)
35
36
  return;
36
- el.focus();
37
+ el.focus({ preventScroll: true });
37
38
  el.setSelectionRange(el.value.length, el.value.length);
38
39
  }, []);
39
40
  const resolveClose = (reason) => {
@@ -70,7 +71,7 @@ export const NameEditor = forwardRef(function NameEditor({ initial, seed, allowE
70
71
  if (!boxRef.current?.contains(e.relatedTarget))
71
72
  onRequestClose("blur");
72
73
  };
73
- const input = "h-full w-28 min-w-0 flex-1 select-text bg-transparent text-(length:--grid-text) text-(color:--vk-fg) outline-hidden";
74
+ const input = "h-full w-28 min-w-0 flex-1 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden";
74
75
  const box = (which, value, onChange) => {
75
76
  const label = views.messages({ key: LABELS[which] });
76
77
  return (_jsx("input", { ref: refs[which], value: value, "aria-label": label, placeholder: label, onChange: (e) => onChange(e.target.value), onKeyDown: keys(which), onBlur: blur, onClick: (e) => e.stopPropagation(), className: input }));
@@ -18,7 +18,7 @@ export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, un
18
18
  const el = inputRef.current;
19
19
  if (!el)
20
20
  return;
21
- el.focus();
21
+ el.focus({ preventScroll: true });
22
22
  const len = el.value.length;
23
23
  el.setSelectionRange(len, len);
24
24
  }, []);
@@ -74,7 +74,7 @@ export const NumberEditor = forwardRef(function NumberEditor({ initial, seed, un
74
74
  }, onBlur: () => {
75
75
  if (!unitOpen)
76
76
  onRequestClose("blur");
77
- }, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--grid-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-none text-left" : "w-full flex-1 text-right") }), unit &&
77
+ }, onClick: (e) => e.stopPropagation(), className: cx("h-full min-w-0 select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "start" ? "w-40 flex-none text-left" : "w-full flex-1 text-right") }), unit &&
78
78
  (unitOptions && unitOptions.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("button", { ref: chipRef, type: "button", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: (e) => {
79
79
  e.stopPropagation();
80
80
  setUnitOpen((o) => !o);
@@ -14,7 +14,7 @@ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, deci
14
14
  const el = lowRef.current;
15
15
  if (!el)
16
16
  return;
17
- el.focus();
17
+ el.focus({ preventScroll: true });
18
18
  el.setSelectionRange(el.value.length, el.value.length);
19
19
  }, []);
20
20
  const parse = (raw) => {
@@ -62,7 +62,7 @@ export const RangeEditor = forwardRef(function RangeEditor({ initial, seed, deci
62
62
  if (!boxRef.current?.contains(e.relatedTarget))
63
63
  onRequestClose("blur");
64
64
  };
65
- const input = cx("h-full w-16 min-w-0 flex-none select-text bg-transparent tabular-nums text-(length:--grid-text) text-(color:--vk-fg) outline-hidden", align === "end" ? "text-right" : "text-left");
65
+ const input = cx("h-full w-16 min-w-0 flex-none select-text bg-transparent tabular-nums text-(length:--vk-text) text-(color:--vk-fg) outline-hidden", align === "end" ? "text-right" : "text-left");
66
66
  return (_jsxs("span", { ref: boxRef, onMouseDown: (e) => {
67
67
  if (!(e.target instanceof HTMLInputElement))
68
68
  e.preventDefault();
@@ -15,8 +15,8 @@ import { type CloseReason, type CloseResolution, type FieldDefOf, type MultipleT
15
15
  * It is a draft, like the chips editor: the whole list commits ONCE when the
16
16
  * host closes it, the main one first. Escape discards; any other close keeps
17
17
  * what was built; closed untouched it writes nothing. A row left untouched
18
- * keeps its stored value as stored, so a phone kept as typed is not rewritten
19
- * by opening the editor. A row typed in commits its text, which the field's
18
+ * keeps its stored value as stored, so a value fields keeps by `stored` (a
19
+ * phone, a url) is not rewritten by opening the editor. A row typed in commits its text, which the field's
20
20
  * commit reads; a row whose reason still shows is refused there.
21
21
  */
22
22
  export type ValueListEditorHandle = {
@@ -16,7 +16,6 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
16
16
  const Add = views.icons.add;
17
17
  const Remove = views.icons.close;
18
18
  const boxRef = useRef(null);
19
- const nextId = useRef(0);
20
19
  const [opened] = useState(() => {
21
20
  const items = valueItems(initial);
22
21
  const main = items.find((item) => item.main);
@@ -24,11 +23,12 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
24
23
  const first = one.find((item) => item.main);
25
24
  return first ? [first, ...one.filter((item) => item !== first)] : one;
26
25
  });
26
+ const nextId = useRef(Math.max(opened.length, 1));
27
27
  const [rows, setRows] = useState(() => opened.length === 0
28
- ? [{ id: nextId.current++, text: "", label: "", main: true }]
29
- : opened.map((item) => {
28
+ ? [{ id: 0, text: "", label: "", main: true }]
29
+ : opened.map((item, index) => {
30
30
  const text = textOf(item.value);
31
- return { id: nextId.current++, text, label: item.label ?? "", main: item.main, stored: { value: item.value, text } };
31
+ return { id: index, text, label: item.label ?? "", main: item.main, stored: { value: item.value, text } };
32
32
  }));
33
33
  const rowsRef = useRef(rows);
34
34
  const update = (next) => {
@@ -40,7 +40,7 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
40
40
  const addRef = useRef(null);
41
41
  useEffect(() => {
42
42
  const first = boxRef.current?.querySelector("input[data-value]");
43
- first?.focus();
43
+ first?.focus({ preventScroll: true });
44
44
  }, []);
45
45
  useEffect(() => {
46
46
  if (focusAdd.current)
@@ -194,7 +194,7 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
194
194
  if (!boxRef.current?.contains(to))
195
195
  onRequestClose("blur");
196
196
  };
197
- const input = "h-7 min-w-0 select-text rounded-md bg-transparent px-1.5 text-[length:var(--grid-text,0.8125rem)] text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtle) focus:bg-(color:--vk-hovered)";
197
+ const input = "h-7 min-w-0 select-text rounded-md bg-transparent px-1.5 text-[length:var(--vk-text,0.8125rem)] text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtle) focus:bg-(color:--vk-hovered)";
198
198
  const iconButton = "flex size-6 shrink-0 items-center justify-center rounded-md text-(color:--vk-fg-subtle) transition-colors hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)";
199
199
  return (_jsxs("div", { ref: boxRef, onMouseDown: (e) => {
200
200
  if (!(e.target instanceof HTMLInputElement))
@@ -206,10 +206,10 @@ export const ValueListEditor = forwardRef(function ValueListEditor({ field, init
206
206
  : words({ key: "views.editors.values-make-main", values: { value: shown } }), title: row.main ? words({ key: "views.editors.values-main" }) : undefined, onClick: (e) => {
207
207
  e.stopPropagation();
208
208
  makeMain(row.id);
209
- }, onKeyDown: buttonKeys(row.id, () => makeMain(row.id)), onKeyUp: noSpaceClick, onBlur: blur(row.id), className: iconButton, children: _jsx("span", { className: cx("size-2.5 rounded-full border border-(color:--vk-fg-subtle)", row.main && "border-(color:--vk-fg-brand) bg-(color:--vk-fg-brand)") }) }), _jsx("input", { "data-walk": true, "data-value": row.id, value: row.text, "aria-label": field.label, placeholder: field.label, "aria-invalid": row.error ? true : undefined, onChange: (e) => set(row.id, { text: e.target.value, error: undefined }), onKeyDown: keys(row.id), onBlur: blur(row.id), onClick: (e) => e.stopPropagation(), className: cx(input, "flex-1") }), labels && (_jsx("input", { "data-walk": true, value: row.label, "aria-label": words({ key: "views.editors.values-label" }), placeholder: words({ key: "views.editors.values-label" }), onChange: (e) => set(row.id, { label: e.target.value }), onKeyDown: keys(row.id), onBlur: blur(row.id), onClick: (e) => e.stopPropagation(), className: cx(input, "w-24") })), _jsx("button", { type: "button", "data-walk": true, "aria-label": words({ key: "views.editors.values-remove", values: { value: shown } }), onClick: (e) => {
209
+ }, onKeyDown: (e) => buttonKeys(row.id, () => makeMain(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: iconButton, children: _jsx("span", { className: cx("size-2.5 rounded-full border border-(color:--vk-fg-subtle)", row.main && "border-(color:--vk-fg-brand) bg-(color:--vk-fg-brand)") }) }), _jsx("input", { "data-walk": true, "data-value": row.id, value: row.text, "aria-label": field.label, placeholder: field.label, "aria-invalid": row.error ? true : undefined, onChange: (e) => set(row.id, { text: e.target.value, error: undefined }), onKeyDown: keys(row.id), onBlur: (e) => blur(row.id)(e), onClick: (e) => e.stopPropagation(), className: cx(input, "flex-1") }), labels && (_jsx("input", { "data-walk": true, value: row.label, "aria-label": words({ key: "views.editors.values-label" }), placeholder: words({ key: "views.editors.values-label" }), onChange: (e) => set(row.id, { label: e.target.value }), onKeyDown: keys(row.id), onBlur: (e) => blur(row.id)(e), onClick: (e) => e.stopPropagation(), className: cx(input, "w-24") })), _jsx("button", { type: "button", "data-walk": true, "aria-label": words({ key: "views.editors.values-remove", values: { value: shown } }), onClick: (e) => {
210
210
  e.stopPropagation();
211
211
  remove(row.id);
212
- }, onKeyDown: buttonKeys(row.id, () => remove(row.id)), onKeyUp: noSpaceClick, onBlur: blur(row.id), className: iconButton, children: _jsx(Remove, { className: "size-3.5" }) })] }), row.error && (_jsx("p", { role: "alert", className: "px-8 pb-1 text-xs text-(color:--vk-danger)", children: row.error }))] }, row.id));
212
+ }, onKeyDown: (e) => buttonKeys(row.id, () => remove(row.id))(e), onKeyUp: noSpaceClick, onBlur: (e) => blur(row.id)(e), className: iconButton, children: _jsx(Remove, { className: "size-3.5" }) })] }), row.error && (_jsx("p", { role: "alert", className: "px-8 pb-1 text-xs text-(color:--vk-danger)", children: row.error }))] }, row.id));
213
213
  }), _jsx("div", { ref: addRef, onKeyDown: addKeys, onBlur: (e) => {
214
214
  if (!boxRef.current?.contains(e.relatedTarget))
215
215
  onRequestClose("blur");
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ONE EDITOR PER STORAGE TYPE, and the table that picks between them — the EDIT
3
- * twin of `DISPLAY_CORES` (spec §3.4), the same idea for the other family.
3
+ * twin of `DISPLAY_CORES` (docs/guides/editors.md), the same idea for the other family.
4
4
  *
5
5
  * The dispatch is a mapped record over `FieldType` for one reason: a type added
6
6
  * to the union with no answer here fails to COMPILE. A host that imports the
@@ -1,7 +1,7 @@
1
1
  import { type FieldDef, type FieldPatch } from "@viewkitjs/fields";
2
2
  import type { RelationSource } from "./relation-source-types.js";
3
3
  /**
4
- * How a field reads and writes on ONE entity's row (spec §3.5) — the three
4
+ * How a field reads and writes on ONE entity's row (docs/guides/columns.md) — the three
5
5
  * identities kept apart: the field's `key` (semantic), the binding (this row),
6
6
  * the storage column (the PATCH body's business). Declared once per entity in
7
7
  * the module's `bindings.ts`; every surface — grid column, drawer row, board
@@ -80,13 +80,3 @@ export declare function isDisplayCurrency(value: unknown): value is DisplayCurre
80
80
  /** Narrows a stored `string` to the set — for a row read back through an
81
81
  * untyped schema client, where the column's domain is the guarantee. */
82
82
  export declare function isSupportedCurrency(code: string | null | undefined): code is SupportedCurrency;
83
- /**
84
- * An amount rendered in its OWN currency, with the right symbol and placement.
85
- *
86
- * Replaces four hand-rolled copies of `currency === "EUR" ? "€" : "$"`, which
87
- * printed every RON amount as dollars — so a €53 Vodafone bill charged as 280
88
- * RON rendered "$280.00" in the drawer, the hero and the history tab. Intl knows
89
- * both the symbol and where it goes; the catch covers a code it doesn't accept,
90
- * so a row with junk in the column still renders its number instead of throwing.
91
- */
92
- export declare function formatMoney(amount: number | null | undefined, currency: string | null | undefined, decimals?: number): string;
@@ -39,17 +39,3 @@ export function isDisplayCurrency(value) {
39
39
  export function isSupportedCurrency(code) {
40
40
  return code != null && SUPPORTED_CURRENCIES.includes(code);
41
41
  }
42
- export function formatMoney(amount, currency, decimals = 2) {
43
- const code = (currency || "EUR").toUpperCase();
44
- try {
45
- return new Intl.NumberFormat("en-US", {
46
- style: "currency",
47
- currency: code,
48
- minimumFractionDigits: decimals,
49
- maximumFractionDigits: decimals,
50
- }).format(amount ?? 0);
51
- }
52
- catch {
53
- return `${code} ${(amount ?? 0).toFixed(decimals)}`;
54
- }
55
- }
@@ -24,6 +24,7 @@ export type MoneyColumn<Row> = DenominatedColumn<Row> & {
24
24
  reading?: MoneyReading;
25
25
  accessor?: ((row: Row) => unknown) | null;
26
26
  aggAccessor?: (row: Row) => number | null;
27
+ editAccessor?: ((row: Row) => unknown) | null;
27
28
  };
28
29
  export declare function isMoneyOpensOn(value: unknown): value is MoneyOpensOn;
29
30
  /** The reading a declaration opens on, for this reader. */