viewkitjs 0.32.0 → 0.34.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 (285) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/fields/dist/index.d.ts +1 -1
  3. package/fields/dist/index.js +1 -1
  4. package/fields/dist/query/evaluate.d.ts +7 -0
  5. package/fields/dist/query/exact-number.d.ts +8 -2
  6. package/fields/dist/query/exact-number.js +14 -1
  7. package/fields/dist/query/sort.js +13 -10
  8. package/fields/dist/registry.js +5 -1
  9. package/fields/dist/types.d.ts +4 -1
  10. package/fields/dist/zod.d.ts +5 -0
  11. package/fields/dist/zod.js +10 -1
  12. package/fields/docs/guides/contact-values.md +12 -0
  13. package/fields/docs/guides/field-types.md +1 -1
  14. package/fields/docs/guides/queries.md +3 -1
  15. package/fields/docs/reference/fields.md +1 -0
  16. package/package.json +1 -1
  17. package/postgres/dist/check.js +4 -1
  18. package/postgres/dist/definitions/formula-forms.js +3 -1
  19. package/postgres/dist/definitions/money.js +2 -1
  20. package/postgres/dist/page.js +6 -3
  21. package/postgres/dist/rules.d.ts +15 -1
  22. package/postgres/dist/rules.js +16 -0
  23. package/postgres/dist/sort.js +7 -2
  24. package/postgres/docs/guides/definitions.md +1 -1
  25. package/postgres/docs/guides/field-map.md +1 -1
  26. package/postgres/docs/reference/definitions.md +1 -1
  27. package/postgres/docs/reference/postgres.md +1 -1
  28. package/views/dist/atoms/ToolbarButton.d.ts +1 -1
  29. package/views/dist/atoms/ToolbarButton.js +4 -3
  30. package/views/dist/atoms/frame-parts.d.ts +6 -0
  31. package/views/dist/atoms/frame-parts.js +15 -0
  32. package/views/dist/atoms/types.d.ts +16 -7
  33. package/views/dist/cells/cell-title.d.ts +3 -1
  34. package/views/dist/cells/cell-title.js +2 -2
  35. package/views/dist/cells/cell-values.js +2 -2
  36. package/views/dist/contract.d.ts +46 -11
  37. package/views/dist/contract.js +157 -0
  38. package/views/dist/controls/alert/alert.js +2 -1
  39. package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
  40. package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
  41. package/views/dist/controls/button/map-button.js +2 -0
  42. package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
  43. package/views/dist/controls/checkbox/checkbox.js +2 -2
  44. package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
  45. package/views/dist/controls/compound-editor/name-parts.js +4 -4
  46. package/views/dist/controls/compound-editor/place-parts.js +19 -19
  47. package/views/dist/controls/compound-editor/range-parts.js +14 -14
  48. package/views/dist/controls/compound-editor/row.d.ts +3 -1
  49. package/views/dist/controls/compound-editor/row.js +2 -2
  50. package/views/dist/controls/controls.d.ts +4 -0
  51. package/views/dist/controls/controls.js +4 -0
  52. package/views/dist/controls/customize/customize.js +43 -39
  53. package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
  54. package/views/dist/controls/customize/map-customize-body.js +7 -2
  55. package/views/dist/controls/date-editor/date-days.js +2 -2
  56. package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
  57. package/views/dist/controls/date-editor/date-editor.js +27 -21
  58. package/views/dist/controls/date-editor/date-parts.js +6 -6
  59. package/views/dist/controls/date-editor/map-calendar.js +3 -1
  60. package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
  61. package/views/dist/controls/date-editor/map-date-body.js +7 -3
  62. package/views/dist/controls/date-editor.css +2 -2
  63. package/views/dist/controls/field/field.d.ts +3 -0
  64. package/views/dist/controls/field/field.js +6 -6
  65. package/views/dist/controls/filter-editor/block.d.ts +2 -2
  66. package/views/dist/controls/filter-editor/block.js +5 -5
  67. package/views/dist/controls/filter-editor/filter-editor.js +31 -33
  68. package/views/dist/controls/filter-editor/how.d.ts +3 -1
  69. package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -0
  70. package/views/dist/controls/filter-editor/map-filter-body.js +11 -4
  71. package/views/dist/controls/filter-editor/map-rules.js +1 -1
  72. package/views/dist/controls/filter-editor/parts.d.ts +3 -1
  73. package/views/dist/controls/filter-editor/parts.js +8 -6
  74. package/views/dist/controls/group-editor/group-editor.js +17 -14
  75. package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
  76. package/views/dist/controls/group-editor/map-group-body.js +5 -1
  77. package/views/dist/controls/index.d.ts +2 -0
  78. package/views/dist/controls/index.js +1 -0
  79. package/views/dist/controls/input/input.js +4 -3
  80. package/views/dist/controls/input/map-input.js +2 -0
  81. package/views/dist/controls/internal/editor-parts.js +1 -1
  82. package/views/dist/controls/internal/head-button.d.ts +9 -0
  83. package/views/dist/controls/internal/head-button.js +13 -0
  84. package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
  85. package/views/dist/controls/internal/map-panel-controls.js +20 -0
  86. package/views/dist/controls/internal/panel-controls.d.ts +58 -0
  87. package/views/dist/controls/internal/panel-controls.js +240 -0
  88. package/views/dist/controls/internal/part-slot.d.ts +12 -0
  89. package/views/dist/controls/internal/part-slot.js +5 -0
  90. package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
  91. package/views/dist/controls/links-editor/links-editor.js +27 -27
  92. package/views/dist/controls/menu/map-menu.d.ts +2 -2
  93. package/views/dist/controls/menu/map-menu.js +15 -12
  94. package/views/dist/controls/menu/menu.d.ts +3 -0
  95. package/views/dist/controls/menu/menu.js +5 -5
  96. package/views/dist/controls/menu-list/menu-list.d.ts +14 -4
  97. package/views/dist/controls/menu-list/menu-list.js +23 -22
  98. package/views/dist/controls/modal/modal.js +5 -3
  99. package/views/dist/controls/notice/notice.d.ts +3 -1
  100. package/views/dist/controls/notice/notice.js +2 -2
  101. package/views/dist/controls/number-editor/map-number-body.js +5 -1
  102. package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
  103. package/views/dist/controls/number-editor/number-editor.js +16 -16
  104. package/views/dist/controls/number-field/number-field.js +5 -3
  105. package/views/dist/controls/pane/map-pane.d.ts +3 -0
  106. package/views/dist/controls/pane/map-pane.js +5 -0
  107. package/views/dist/controls/pane/pane.d.ts +4 -2
  108. package/views/dist/controls/pane/pane.js +4 -4
  109. package/views/dist/controls/picker/map-fields-body.js +25 -1
  110. package/views/dist/controls/picker/picker.d.ts +2 -0
  111. package/views/dist/controls/picker/picker.js +37 -36
  112. package/views/dist/controls/picker/rows.d.ts +4 -0
  113. package/views/dist/controls/picker.css +10 -1
  114. package/views/dist/controls/popover/map-popover.d.ts +1 -1
  115. package/views/dist/controls/popover/map-popover.js +4 -2
  116. package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
  117. package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
  118. package/views/dist/controls/quick-filters/quick-filters.js +8 -6
  119. package/views/dist/controls/radio/radio.d.ts +3 -0
  120. package/views/dist/controls/radio/radio.js +4 -3
  121. package/views/dist/controls/select/map-select.d.ts +3 -0
  122. package/views/dist/controls/select/map-select.js +8 -0
  123. package/views/dist/controls/select/select.d.ts +3 -0
  124. package/views/dist/controls/select/select.js +3 -3
  125. package/views/dist/controls/setting-row/looks.js +5 -5
  126. package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
  127. package/views/dist/controls/setting-row/setting-row.js +3 -1
  128. package/views/dist/controls/setting-row.css +3 -2
  129. package/views/dist/controls/sheet/bottom-sheet.d.ts +8 -2
  130. package/views/dist/controls/sheet/bottom-sheet.js +4 -4
  131. package/views/dist/controls/sheet/map-sheet.js +1 -1
  132. package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
  133. package/views/dist/controls/sort-editor/map-sort-body.js +8 -4
  134. package/views/dist/controls/sort-editor/sort-editor.js +24 -26
  135. package/views/dist/controls/sort-editor.css +5 -0
  136. package/views/dist/controls/text-editor/map-text-body.js +5 -1
  137. package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
  138. package/views/dist/controls/text-editor/text-editor.js +11 -10
  139. package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
  140. package/views/dist/controls/toolbar/toolbar.js +2 -2
  141. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +3 -3
  142. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +7 -6
  143. package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
  144. package/views/dist/controls/values-editor/values-editor.js +22 -22
  145. package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
  146. package/views/dist/controls/views-list/map-view-menu.js +7 -3
  147. package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
  148. package/views/dist/controls/views-list/map-views-list-body.js +6 -5
  149. package/views/dist/controls/views-list/view-menu.js +9 -10
  150. package/views/dist/controls/views-list/views-list.js +6 -6
  151. package/views/dist/editors/EditorPanel.js +4 -4
  152. package/views/dist/field-row/FieldRow.js +13 -0
  153. package/views/dist/fields/money.d.ts +5 -2
  154. package/views/dist/fields/money.js +14 -2
  155. package/views/dist/grid/chrome/GridTable.js +4 -1
  156. package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
  157. package/views/dist/grid/chrome/cell-clipboard.js +2 -2
  158. package/views/dist/grid/chrome/cells.js +3 -1
  159. package/views/dist/grid/chrome/grid-row-menu-items.js +1 -1
  160. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
  161. package/views/dist/grid/chrome/useGridKeyboard.js +29 -6
  162. package/views/dist/grid/chrome/useGridTableInteractionModel.js +9 -2
  163. package/views/dist/grid/core/clipboard-model.d.ts +3 -1
  164. package/views/dist/grid/core/clipboard-model.js +9 -8
  165. package/views/dist/grid/core/editing-controller.d.ts +3 -0
  166. package/views/dist/grid/core/editing-controller.js +6 -0
  167. package/views/dist/grid/core/edits-sink.d.ts +19 -0
  168. package/views/dist/grid/core/edits-sink.js +2 -0
  169. package/views/dist/grid/core/spreadsheet-operations.js +1 -1
  170. package/views/dist/grid/core/useGridEditing.d.ts +5 -0
  171. package/views/dist/grid/core/useGridEditing.js +6 -0
  172. package/views/dist/list/answer.d.ts +40 -0
  173. package/views/dist/list/answer.js +43 -0
  174. package/views/dist/list/bulk-bar.d.ts +7 -0
  175. package/views/dist/list/bulk-bar.js +10 -0
  176. package/views/dist/list/columns.d.ts +24 -0
  177. package/views/dist/list/columns.js +27 -0
  178. package/views/dist/list/edits.d.ts +19 -0
  179. package/views/dist/list/edits.js +56 -0
  180. package/views/dist/list/grid.d.ts +11 -0
  181. package/views/dist/list/grid.js +76 -0
  182. package/views/dist/list/index.d.ts +14 -1
  183. package/views/dist/list/index.js +4 -1
  184. package/views/dist/list/link.d.ts +8 -0
  185. package/views/dist/list/link.js +78 -0
  186. package/views/dist/list/list.d.ts +74 -0
  187. package/views/dist/list/list.js +18 -0
  188. package/views/dist/list/parts.js +11 -3
  189. package/views/dist/list/root-base.d.ts +46 -0
  190. package/views/dist/list/root-base.js +137 -0
  191. package/views/dist/list/root.d.ts +35 -34
  192. package/views/dist/list/root.js +153 -113
  193. package/views/dist/list/source-answers.d.ts +39 -0
  194. package/views/dist/list/source-answers.js +225 -0
  195. package/views/dist/list/store.d.ts +37 -5
  196. package/views/dist/list/store.js +31 -0
  197. package/views/dist/list/toolbar.d.ts +3 -2
  198. package/views/dist/list/toolbar.js +23 -5
  199. package/views/dist/list/views-axis.js +4 -2
  200. package/views/dist/list/views.d.ts +7 -2
  201. package/views/dist/list/views.js +16 -5
  202. package/views/dist/model/column-capabilities.d.ts +13 -0
  203. package/views/dist/model/column-capabilities.js +23 -2
  204. package/views/dist/model/column-schema.d.ts +11 -1
  205. package/views/dist/model/view-rules.js +1 -0
  206. package/views/dist/panels/model.d.ts +2 -0
  207. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +21 -2
  208. package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
  209. package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
  210. package/views/dist/panels/react/toolbar/Toolbar.js +20 -6
  211. package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +4 -3
  212. package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
  213. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
  214. package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
  215. package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
  216. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +4 -3
  217. package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
  218. package/views/dist/panels/react/toolbar/ToolbarFilters.js +5 -4
  219. package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
  220. package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
  221. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  222. package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
  223. package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
  224. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +8 -5
  225. package/views/dist/panels/react/toolbar/context.d.ts +31 -1
  226. package/views/dist/panels/react/toolbar/context.js +4 -0
  227. package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
  228. package/views/dist/panels/react/toolbar/pane-host.js +17 -0
  229. package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
  230. package/views/dist/panels/react/toolbar/panel-part.js +7 -4
  231. package/views/dist/panels/react.d.ts +1 -1
  232. package/views/dist/panels/settings/filter-groups.js +6 -1
  233. package/views/dist/provider/ViewsProvider.d.ts +7 -2
  234. package/views/dist/provider/ViewsProvider.js +18 -1
  235. package/views/dist/provider/components.d.ts +90 -2
  236. package/views/dist/provider/components.js +1 -1
  237. package/views/dist/provider/context.d.ts +4 -1
  238. package/views/dist/provider/own-control.d.ts +4 -0
  239. package/views/dist/provider/own-control.js +7 -0
  240. package/views/dist/provider/select-items.d.ts +3 -0
  241. package/views/dist/provider/select-items.js +6 -0
  242. package/views/dist/react.d.ts +4 -2
  243. package/views/dist/react.js +2 -0
  244. package/views/dist/styles.css +107 -80
  245. package/views/dist/styles.unlayered.css +107 -80
  246. package/views/docs/contract.md +310 -7
  247. package/views/docs/controls/alert-dialog.md +4 -0
  248. package/views/docs/controls/alert.md +4 -0
  249. package/views/docs/controls/bulk-bar.md +4 -0
  250. package/views/docs/controls/compound-editor.md +4 -0
  251. package/views/docs/controls/customize.md +8 -0
  252. package/views/docs/controls/date-editor.md +6 -0
  253. package/views/docs/controls/field.md +4 -0
  254. package/views/docs/controls/filter-editor.md +8 -0
  255. package/views/docs/controls/group-editor.md +8 -0
  256. package/views/docs/controls/input.md +4 -0
  257. package/views/docs/controls/links-editor.md +4 -0
  258. package/views/docs/controls/menu-list.md +8 -0
  259. package/views/docs/controls/menu.md +6 -0
  260. package/views/docs/controls/modal.md +4 -0
  261. package/views/docs/controls/notice.md +4 -0
  262. package/views/docs/controls/number-editor.md +6 -0
  263. package/views/docs/controls/pane.md +4 -0
  264. package/views/docs/controls/picker.md +8 -0
  265. package/views/docs/controls/quick-filters.md +8 -0
  266. package/views/docs/controls/radio.md +4 -0
  267. package/views/docs/controls/select.md +8 -0
  268. package/views/docs/controls/sheet.md +4 -0
  269. package/views/docs/controls/sort-editor.md +8 -0
  270. package/views/docs/controls/text-editor.md +6 -0
  271. package/views/docs/controls/toolbar.md +4 -0
  272. package/views/docs/controls/values-editor.md +4 -0
  273. package/views/docs/controls/views-list.md +8 -0
  274. package/views/docs/guides/the-grid.md +2 -2
  275. package/views/docs/guides/the-provider.md +19 -2
  276. package/views/docs/reference/controls.md +11 -7
  277. package/views/docs/reference/field-row.md +1 -1
  278. package/views/docs/reference/grid.md +1 -1
  279. package/views/docs/reference/list.md +143 -11
  280. package/views/docs/reference/looks.md +1 -1
  281. package/views/docs/reference/panels-react.md +6 -5
  282. package/views/docs/reference/react.md +19 -12
  283. package/views/docs/reference/views.md +11 -5
  284. package/views/docs/reshaping.md +17 -1
  285. package/views/skills/views/SKILL.md +1 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,104 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.34.0] — 2026-12-03
9
+
10
+ ### Added
11
+
12
+ - Under the provider's `panelControls`, your own `Button`, `Select` and `Input` now draw inside the group editor, Customize, the views list and view menu (with the Modal they open, and on a phone the Delete question; on a computer Delete still goes to your `confirm` port), the quick filters' search, the filter bar's typed value and date, and every head a panel draws itself on a phone (its ✕, ‹ and ✓, your Button alone in place of ViewKit's glass and plain pair). Each is handed the components map's props, and each panel part its `data-slot` and `data-key` (the Modal's and the alert's buttons carry no public name). Nothing changes without it. The head ViewKit's own `Sheet` draws stays ViewKit's: hand your own `Sheet` to change it.
13
+ - The last parts around the panels carry public names (VK-1003): `vk-filter-part-value` (the filter bar's typed value) and `vk-filter-part-pair` (a range's two numbers there), `vk-quick-strip` and `vk-quick-values` (the quick filters' fields and values, `data-key` the field), `vk-customize-none` (`data-key` `columns` or `choices`), `vk-customize-rows` (a column's own rows, `data-key` its id) and `vk-customize-columns-foot`. The quick filters', views list's and Customize's own phone heads name their ✕ and ‹ `vk-editor-close` and `vk-editor-back`, as the sort's and filter's do. A phone menu's sheet carries its menu's name, and so does the views list's phone step that holds a view's menu (`vk-view-menu`, its rows `vk-view-menu-row` with or without `verbs`).
14
+ - `viewkitjs/views/react`: the provider's `panelControls` now reaches the text, number and date editors too. Each button, popover and one-line box inside them is your own `Button`, `Popover` and `Input`, except what `docs/reshaping.md` names (a box that grows over lines, the Number field, the date's segments, its quarter list and its parts' boxes among them), handed the components map's props and the part's `data-slot` and `data-key`. Inside a box group of ViewKit's (a date's line, a phone number's digits) your Input is handed `chrome="bare"`, and ViewKit's autofill-off where the box holds a record's details. Nothing changes without it.
15
+ - `panelControls` takes a sixth name, `Calendar` (`true` now means all six): your `Calendar` draws the date editor's month in place of its own head and days, handed the conventions' locale and `data-slot="vk-calendar"` (`ViewsCalendarProps` takes `data-slot`). `CONTROLS.Calendar` stays ViewKit's whatever it says, and the filter's range calendar reads your `Calendar` as before.
16
+ - `ViewsSheetAction` takes `slot`: an editor panel hands your Sheet's head its ✕, ✓ and Back as `vk-editor-close`, `vk-editor-save` and `vk-editor-back`.
17
+ - `viewkitjs/views/controls`: every part of the bulk bar (`CONTROLS.SelectionBar`) and of what it opens has a public `data-slot`, in every form (a computer's bar, the phone's tray and pill): the bar, its count, the separator, each verb (`vk-bulk-verb`, `data-key` its place in the verbs), Delete, More, the pill's ✕ and Actions, More's and Actions' menu and its rows, a group's menu and rows, a field's values and empty row in a menu, a field's popover and sheet, and where its Toast rises (`vk-bulk-*`). Listed in `BULK_BAR_SLOTS` (and `SELECTION_SLOTS`) and `docs/contract.md`. An app dresses one part by its name; with nothing dressed, the bar draws as it did.
18
+ - `Sheet` and `ToolbarSeparatorControl` draw a handed `data-slot`; a named `Menu` draws its `data-slot` on its sheet on a phone too.
19
+ - `viewkitjs/views/list` and `viewkitjs/views/panels/react`: `customizeIn: "pane"` opens Customize on a computer in ViewKit's Pane, at the list's right edge under the toolbar and as tall as the list, over its edge, the list scrolling and taking presses beside it, with no host of the app's own (VK-1026). The ready `<List>` takes it and stands its grid in a box of its own (`data-slot="vk-list-box"`), the Pane's; `ReadyToolbar` and `ListToolbar` take it with `paneBox`, the app's own box round its grid. On a phone Customize keeps its Sheet. With nothing set, Customize opens in the toolbar's popover, as before; an app's own `hosts.options` still wins.
20
+ - The components map takes an optional `Pane` (`ViewsPaneProps`, `OPTIONAL_COMPONENT_NAMES`): `CONTROLS.Pane` is ViewKit's own. A map without one keeps the popover.
21
+ - `viewkitjs/views/panels/react`: a folding toolbar's line on a computer (the ready toolbar's, `ListToolbar`'s, `Toolbar`'s `fold`) reads three optional tokens: `--vk-toolbar-line-py`, its padding above and below (10px undeclared), `--vk-toolbar-line-gap`, the room between its tools (8px), and `--vk-toolbar-line-w`, the line under it (1px; `0px` draws none, so you can draw your own edge to edge without touching `--vk-border-subtle`). Undeclared, the line draws as before.
22
+ - `viewkitjs/views/panels/react`: a `toolbarParts` place takes `panel`, `{ side?, align?, offset? }` (`ToolbarPanelPlace`), where what the part opens hangs at its button: your `Popover`'s `side`, `align` and `sideOffset`. `ToolbarSlotState` carries the part's `side` of its line and its place's `panel`.
23
+ - `viewkitjs/views/controls`: `SettingRow` has a plain kind, for a row with no page to open: given no `switch`, `select`, `action` or `onOpen`, it draws its mark, name and line with nothing at its end and no press (`data-setting-row-kind="plain"`), on a computer and in a phone's card. A row given none of the four used to draw the open kind, a button with ›; give it `onOpen` to keep that.
24
+
25
+ ### Changed
26
+
27
+ - `pressGroup` puts the cursor in a box group's typed input where it holds no Input of ViewKit's (an app's own, bare inside it).
28
+ - The reset ViewKit's stylesheet holds to its own elements starts at no bulk bar part's name: More's menu, standing in the page, draws as before.
29
+ - `viewkitjs/views/panels/react`: inside a `Toolbar`, a panel opens toward its part's side of the line: a part on the end side (Sort and Filter on the row's right, the default) aligned to its button's end, a part on the start side (Customize beside the views, the default) to its start. Before, Customize, the row's Sort and the quick filters opened at their button's end and the row's Filter and the sort pill at its start, wherever they stood. A part outside a `Toolbar` opens as before. To keep a part's old alignment, hand its place `panel: { align }`.
30
+ - `viewkitjs/views`: the default field list (`CONTROLS.FieldsBody`, Sort's and Filter's) stands as wide as its widest row on a computer, or as its search's placeholder where that is wider, so the placeholder reads whole; never past the 288 it stood at before nor narrower than what opened it, and it holds that width while what is typed narrows its rows. Its search box fills that width and no longer sets it, and its rows keep room for the check only on the field already held. An app that boxed the list in to get this can drop its box.
31
+ - `viewkitjs/views/looks`: the setting row's defaults are now its `attio` look: `card` defaults to `raised` (was `outlined`) and `rows` to `roomy` (was `snug`); `end`, `fields` and `icon` are unchanged. With nothing picked, `lookAttrs(SETTING_ROW_LOOKS)` and `settingRowWornOf` give `raised` and `roomy`. To keep the old drawing, wear the `outright` look: `lookAttrs(SETTING_ROW_LOOKS, lookPicks(SETTING_ROW_LOOKS, "outright"))`. A frame with no `data-setting-row-*` attribute at all still draws outlined and snug.
32
+
33
+ ### Fixed
34
+
35
+ - `viewkitjs/views`: on a computer, a Picker's list stops at 8½ rows when the app sets no `--list-rows` (the Select's figure). It ran the window's full height: Sort's and Filter's field lists, and a phone value's country list. An app that sets `--list-rows` still gets its own figure.
36
+
37
+ ## [0.33.0] — 2026-12-03
38
+
39
+ ### Added
40
+
41
+ - `viewkitjs/views/react`: the provider's `panelControls` draws your own `Button`, `Select`, `Menu`, `Popover` and `Input` inside the sort and filter panels (`true`, or the names you want), each handed the components map's props and the part's `data-slot` and `data-key`. Nothing changes without it, and a control of `CONTROLS`' stays ViewKit's whatever it says. `PanelControlName`, `PANEL_CONTROL_NAMES` and `flatSelectItems` (a Select's rows one level in, flattened and named by their path) are exported.
42
+ - The components map takes an optional `Select` (`ViewsSelectProps`, `ViewsSelectItem`), drawn only inside the panels under `panelControls`; `CONTROLS.Select` (`MapSelect`, from `viewkitjs/views/controls`) is ViewKit's own. A `Select` of your own that `panelControls` doesn't name is never drawn, and the provider says so once in development.
43
+ - `ViewsButtonProps` takes `data-key`, `ViewsMenuItem` takes `slot` (a row's public name, which ViewKit's own Menu draws too), and `ViewsPopoverProps` takes `label` (its name to a screen reader).
44
+ - `viewkitjs/fields`: a url field can say `bareHost: "https"`. A host typed with no scheme (`acme.ro`, `acme.ro/work`) is then stored as `https://` and the host, where it was refused for naming no scheme. Every place a value is committed does it the same way: a grid cell, a paste, a field row, `acceptFieldCommit` and `zodFor` on your route. An address that names its scheme is kept as typed, text that is no host is still refused in the same words, the ceiling (`validation.maxLength`) counts what is stored, and a url kept as stored comes back as it was. Absent, nothing changes.
45
+ - `viewkitjs/fields`: `withUrlScheme(text)` is that rule: trimmed text naming no scheme, whose host holds a dot, with `https://` before it; anything else trimmed and unchanged.
46
+ - `viewkitjs/views`: `ViewsFilterBodyField.integer` is `true` on a number field that holds whole numbers only, so your own filter body's box can take whole numbers.
47
+ - `viewkitjs/views/model`: `withEditThroughLocks(config, fields)` gives a list's locks with each edit-through pair locked together: a lock stored under a worked-out field edited through a stored one (`editThrough`), or under that stored field, holds under both keys. The stored config is untouched, so each field keeps its own lock toggle. A surface that checks a lock by field key, such as a record's `LockedResolver`, passes its fields through it to agree with the grid.
48
+ - `viewkitjs/views/grid`: `cellCopyText(column, value, language?)` takes the names language a place's country is written in; without it, English, as before.
49
+ - `viewkitjs/postgres`: `FilterContext.sortCurrency`, the currency a money field that converts is sorted in when `currencies` names none for it, your app's own, say. The rows then order by each amount converted into it, so amounts in different currencies change places when the direction flips, while each row still reads in its own currency. A page's cursor is bound to it; one that is no currency is refused.
50
+ - `viewkitjs/fields/query`: `ViewFieldReader.sortAmountOf(row, key)`, the amount a money field sorts by when its cells show each row's own currency, converted into one currency for the whole list. `compareBy` orders by it, with no code clusters, where it answers both rows.
51
+ - `viewkitjs/views`: `ListColumn.sortAccessor`, set by `readMoneyColumns` on a convertible column read in Original: each row's figure in the reader's default currency. The grid's reader answers `sortAmountOf` from it, so an in-memory sort agrees with a server's sorted by `sortCurrency`. `readMoneyColumn` takes the currency as an optional third argument.
52
+ - `viewkitjs/views/list`: `List`, a whole list in one component. Hand it `id`, your fields (`defineFields`), your rows and one `save`, and it draws the toolbar, the grid, saved views, edits with undo and redo, and the bulk bar, in the Outright look, on a computer and a phone. Columns come from the fields, changed by key (`columns`, with `bind` for a field its key can't bind); the address carries the open view (`link`, on by default); `can` takes away editing or sharing; `menus`, `toolbarParts`, and `toolbar`, `grid` and `bulk` reach every part.
53
+ - `viewkitjs/views/list`: `ListGrid` (the grid reading its list root) and `ListBulkBar` (the selection bar over the root's picks), for an arrangement of your own inside `ListRoot`.
54
+ - `viewkitjs/views/list`: `ListRoot` takes a list's data in either mode: `fields`, `rows`, `columns`, `save` and `can`; in store mode `link={true}` carries the open view in the address, and the open view is kept on the device. `ListState` gains `columns`, `answer`, `edits` and `redo()`; `ListViewsState.openView` takes a change to lay over the view.
55
+ - `viewkitjs/views/list`: `ListToolbar` takes its `columns`, group heads and filter values from a root that holds a list's fields and rows.
56
+ - `viewkitjs/views/list`: the types `ListProps`, `ListGridProps`, `ListBulkBarProps`, `ListColumnOverride`, `ListColumnsOverride`, `ListFieldsRegistry`, `ListAnswerState` and `ListData`; `ListChange` and `ListSave` are named here too.
57
+ - `viewkitjs/views/list`: `List` and `ListRoot` take their rows from a `source` in place of `rows`: `fetchSource(url)`, or your server action as it stands. The list asks one list request per part it draws, each answer through `answerFor`. It asks for the first page as the settings or the quick filters' hold change, the next page and a group's next page as their ends come near, every matching row's ids as your app calls `select("all")`, each saved view's count while Show counts is on, the quick filters' counts while their panel is open, and each text field's values while a filter panel is open. An answer a newer request has outrun is dropped, and no page is asked with a cursor from older settings. While the first page is out the grid shows its wait; a group the source sends unnamed takes its field's name. A refusal shows in the grid's empty state in your server's words; a throw is said through the toast, and the rows shown stay. Picks clear as the quick filters' hold changes, as they do for the search, filter and group. `pageSize` sets a page, 50 by default, held between 1 and 1000.
58
+ - `viewkitjs/views/list`: `ListRoot` and `List` take `quickFilters`, whose hold narrows the rows, held in memory or from a source. `ListState` gains `loadMore()` and `loadGroup(key)`; `ListAnswerState` gains `more`, `paged`, `viewCounts` and `holdCounts`.
59
+ - `viewkitjs/views/react`: every button the toolbar draws now hands your `ToolbarButton` its `part`, named after the `toolbarParts` place it stands in: `options`, `search`, `quick`, `new`, `sort`, `filter`, `filter-add`, `filters` (each of a rule's four joined buttons), `advanced-filters` and `sort-pill`; a place's second kind of button by a name of its own, `sort-add` (the + after the sort) and `more-filters` ("+N filters"); and ⋯ `more`. Before, only the views row's parts, Clear and Save in an app's own frame were named. New type: `ViewsFramePart`, those six.
60
+ - `viewkitjs/views/react`: `ViewsToolbarButtonProps` takes `className`, the class its toolbar place hands: put it on the button. ViewKit's own button and `CONTROL_ATOMS`' put it there.
61
+ - `viewkitjs/views/panels/react`: a `toolbarParts` place (`ToolbarPartPlace`) takes `className`, put on every toolbar button the part draws, and `button`, your own button for the part, drawn in place of your `ToolbarButton` and handed the same props, `ref` included, so what it opens still hangs at it. Hand neither and every toolbar draws exactly as before.
62
+ - `viewkitjs/views`: every part inside the default panels has a public name. The sort, filter and group editors, Customize, the views list, a view's menu and the quick filters mark each part with a `data-slot` of its own (`vk-sort-rule`, `vk-sort-add`, `vk-filter-rule`, `vk-customize-section` …, listed in `PANEL_SLOTS` and the contract), and a part that repeats says which one it is (`data-key`; a rule its place, `data-index`), so an app's stylesheet dresses one sort rule, Add sort or one Customize section on its own. An app that styles nothing draws as before.
63
+ - `viewkitjs/views/controls`: a Menu list's entry and choice and a Picker's item take `slot` (`PartSlot`), drawn on the row in every form; the Select's box, the Radio's label, `PaneHead`, `PaneFoot`, `Notice` and a Menu's popup take a handed `data-slot`; the Picker's `menuSlot` names its rows' menus.
64
+ - `ViewsMenuProps` takes `data-slot`: ViewKit's own Menu draws it on its popup and names that menu's rows by their items' keys.
65
+ - `data-toolbar-item`, the folding toolbar's mark of each place (its key, an app's own included), is public.
66
+ - `viewkitjs/views/controls`: every part inside the default field editors has a public `data-slot`, the same in the grid, the field row and a phone's sheet, on the box a person sees: the date editor and its calendar (`vk-date-*`, `vk-calendar`: its quick picks, line, time, head, days, months, years, quarters, parts, wheels), the text and number editors (`vk-text-*`, `vk-number-*`), the name, place and range editor (`vk-parts-*`, each part by `data-key`), the values editor (`vk-values-*`, each row by `data-index`) and the links editor (`vk-links-*`, each link by its record, each field by its id); every editor's ✕, ✓ and a step's ‹ are `vk-editor-close`, `vk-editor-save` and `vk-editor-back`. Listed in `EDITOR_PART_SLOTS` and `docs/contract.md`. An app dresses one part by its name; with nothing dressed, every editor draws as it did.
67
+ - `Input` draws a handed `data-slot` and `data-key` on its box; `Field` on its root in every form; `SheetButton` and `SheetHead` (`backSlot`) on their buttons.
68
+
69
+ ### Changed
70
+
71
+ - The filter editor's field and how boxes carry `vk-filter-field` and `vk-filter-how` on the box itself (the Select's, `data-kit="select"`), as the sort's do, no longer on the box's wrapper. A stylesheet that dressed the wrapper by those names now dresses the box.
72
+ - `viewkitjs/views/react`'s size budget rises from 25 to 30 kB gzipped: the provider's `panelControls`, `PANEL_CONTROL_NAMES`, `flatSelectItems` and the own-control mark brought it to 25.0 kB.
73
+ - `viewkitjs/views`: a column's `indicator` is handed the value its cell shows beside the row, as `render` is: `indicator?: (row, cell?: { value })`. While a write saves (a paste, a fill, an edit), `cell.value` is the value being saved, which the cell already draws; otherwise it is what `accessor` reads. An indicator read from `cell.value` agrees with the value beside it from the moment it shows, and goes back with it if the save fails. An indicator that reads only the row works as before.
74
+ - A money column read in each row's own currency, sorted in memory after `readMoneyColumns`, now orders by its amount in the reader's default currency instead of clustering by code first. Hand `context.sortCurrency` to `viewkitjs/postgres` for the same order from the server.
75
+ - `viewkitjs/views/list`'s size budget rises to 360 kB gzipped: the door now carries the grid, the save path and the in-memory answers `List` draws with. `ReadyToolbar` and `ListToolbar` don't load them.
76
+ - The tarball's unpacked budget rises from 10500 kB to 11560 kB: with the ready List and this release's other additions the package unpacks to 10505 kB. The new budget is that measure plus 10%, rounded up to the next 5 kB, the rule a first budget takes.
77
+ - `viewkitjs/views/react`: `ViewsToolbarButtonPart` now names every toolbar button, so an atom that dressed any `part` as the views row's, Clear's or Save's dresses Sort, New and the rest that way too. Dress by the six alone, and key a record by `ViewsFramePart`:
78
+
79
+ ```tsx
80
+ // Before
81
+ const SLOT: Record<ViewsToolbarButtonPart, string> = { /* the six */ };
82
+ if (part) return <FrameButton data-slot={SLOT[part]} />;
83
+
84
+ // After
85
+ const SLOT: Record<ViewsFramePart, string> = { /* the six */ };
86
+ const FRAME = new Set<string>(Object.keys(SLOT));
87
+ if (part && FRAME.has(part)) return <FrameButton data-slot={SLOT[part as ViewsFramePart]} />;
88
+ ```
89
+
90
+ - `viewkitjs/views/react`: an atom that spreads its leftover props onto its element now spreads `part` too (`part="sort"` on the button): take `part` out of the props first, as you take `icon` and `label`.
91
+ - The reset ViewKit's stylesheet holds to its own elements starts at no part's name: an editor an app draws on its own, outside ViewKit's frames, draws as before.
92
+ - The date editor's roving day is marked `data-stop` (was an internal `data-key`), so a public `data-key` rule never catches it.
93
+
94
+ ### Fixed
95
+
96
+ - `viewkitjs/views/field-row`: one click on a text, email, phone, link or number row inside a dialog that takes back a focus fallen to the page (Base UI's Dialog, which returns it to its popup) opens the row's editor and keeps it open. The row now holds the focus while its editor takes the button's place, so the focus never falls to the page; a click away, Escape and Tab close the editor as before.
97
+ - `viewkitjs/views/grid`: a value whose field has commands (its ▾) no longer loses its last 8px to an ellipsis when its column has room; in a narrow column it still ends in "…", with the ▾ inside the cell.
98
+ - `viewkitjs/views/grid`: a fraction pasted into a whole-number column is rounded, as typing it is, instead of being refused when it is saved.
99
+ - `viewkitjs/views`: the filter editor's number box on a whole-number column rounds what is typed to a whole number.
100
+ - `viewkitjs/views/grid`: a lock on a stored field now locks the worked-out field edited through it, and a lock on the worked-out field locks the stored field it writes, through every write route (editor, Delete, fill, paste, the selection bar).
101
+ - `viewkitjs/views/grid`: copying a place cell names its country in the names language (`conventions.language`), as the cell shows it: "Budapest, Ungaria" under Romanian, where it always wrote English. A paste of that country into the place's Country part still reads it back.
102
+ - `viewkitjs/fields/query`: a number sort in memory places NaN and the infinities where Postgres orders a numeric or a float8: -Infinity below every number, then Infinity, then NaN, whether the value is a JavaScript number or decimal text ("NaN", "Infinity"). A list sorted in memory and the same list sorted by the database now agree. The number filter still reads them as empty.
103
+ - `viewkitjs/postgres`: a formula that concatenates text is written in functions an index can hold, with the same answers, so `searchIndexes` prints its trigram index (a first and last name joined with `concat`, say) instead of naming it unserved. A concat of a day, an instant or a number is still unserved.
104
+ - `viewkitjs/views/controls`: on a computer, ViewKit's own Popover holding the sort editor (the ready toolbar's Sort, with a rule) is as wide as its rows, so each rule's grip, field, direction and × stand inside it; it was 288 px and cut them off. It never goes under 288 px nor past the room on screen, and with no rule Add sort's fields open at 288 px as before. An app's own Popover, or its own width on this one, is unchanged.
105
+
8
106
  ## [0.32.0] — 2026-12-03
9
107
 
10
108
  ### Added
@@ -27,7 +27,7 @@ export { isOpenVocabulary, optionFor, optionValues, optionsOf, statusOptionOrder
27
27
  export { sameListValue, sameStoredValue } from "./equality.js";
28
28
  export { optimisticDisplay, sameFieldValue } from "./optimistic.js";
29
29
  export * from "./relation.js";
30
- export { zodFor } from "./zod.js";
30
+ export { withUrlScheme, zodFor } from "./zod.js";
31
31
  export { acceptFieldCommit, acceptStoredFieldValue, fieldClearRefusal, type FieldAcceptance, } from "./accept.js";
32
32
  export * from "./codecs.js";
33
33
  export { dateOfDay, dateOfInstant, dayOf, instantOf, type DateReading, } from "./date-codec.js";
@@ -24,7 +24,7 @@ export { isOpenVocabulary, optionFor, optionValues, optionsOf, statusOptionOrder
24
24
  export { sameListValue, sameStoredValue } from "./equality.js";
25
25
  export { optimisticDisplay, sameFieldValue } from "./optimistic.js";
26
26
  export * from "./relation.js";
27
- export { zodFor } from "./zod.js";
27
+ export { withUrlScheme, zodFor } from "./zod.js";
28
28
  export { acceptFieldCommit, acceptStoredFieldValue, fieldClearRefusal, } from "./accept.js";
29
29
  export * from "./codecs.js";
30
30
  export { dateOfDay, dateOfInstant, dayOf, instantOf, } from "./date-codec.js";
@@ -36,6 +36,13 @@ export type ViewFieldReader<Row> = {
36
36
  * blank in the sibling) is its own cluster and sorts after every known code.
37
37
  * The library converts nothing itself. */
38
38
  codeOf?: (row: Row, key: string) => string | null | undefined;
39
+ /** The number a money field SORTS by when its cells show each row's own
40
+ * currency: the row's amount converted into one currency for the whole list
41
+ * (`null` when it has none, or no rate: last both ways). A host that answers
42
+ * it for two rows has them ordered by these numbers, with no code clusters,
43
+ * so the order flips with the direction; `undefined` (or no hook) sorts by
44
+ * what `read` returns, clustered by code as `codeOf` says. */
45
+ sortAmountOf?: (row: Row, key: string) => number | null | undefined;
39
46
  /** The records a row's relation holds, each read as a record of its own (`recordReaderFor` over the far rows and
40
47
  * their reader), so a rule across the relation ("any / none / every of its records where …") is answered in
41
48
  * memory. Absent, or `undefined` for a row, the rule has no opinion and the row stays. */
@@ -1,5 +1,11 @@
1
1
  /** `value` as canonical decimal text, or null when it reads as no number: absent, blank, malformed or not finite. */
2
2
  export declare function exactNumberText(value: unknown): string | null;
3
- /** Whether `value` reads as no number, as `exactNumberText` reads it. A JS number always reads as one, an infinity
4
- * included, so it sorts as a value, as a database sorts it. */
3
+ /**
4
+ * Where a non-finite number sorts, as postgres orders a numeric or a float8: -1 for -Infinity, below every number; 1
5
+ * for Infinity, above them; 2 for NaN, above Infinity. 0 for anything else. A JS number or decimal text spelling one.
6
+ * Only the sort reads it: to a filter, `exactNumberText` still reads these as no number.
7
+ */
8
+ export declare function nonFiniteSide(value: unknown): -1 | 0 | 1 | 2;
9
+ /** Whether `value` reads as no number to the sort: a JS number never does, and a non-finite one in text sorts as a
10
+ * value too, as postgres sorts it (`nonFiniteSide`); anything else as `exactNumberText` reads it. */
5
11
  export declare function readsAsNoNumber(value: unknown): boolean;
@@ -13,6 +13,19 @@ export function exactNumberText(value) {
13
13
  const read = MACHINE_NUMBER.test(text) ? Number(text) : parseNumber(text);
14
14
  return read == null ? null : decimalTextOf(read);
15
15
  }
16
+ const INFINITY_TEXT = /^([+-]?)inf(inity)?$/i;
17
+ const NAN_TEXT = /^nan$/i;
18
+ export function nonFiniteSide(value) {
19
+ if (typeof value === "number")
20
+ return Number.isNaN(value) ? 2 : value === Infinity ? 1 : value === -Infinity ? -1 : 0;
21
+ if (typeof value !== "string")
22
+ return 0;
23
+ const text = value.trim();
24
+ if (NAN_TEXT.test(text))
25
+ return 2;
26
+ const infinity = INFINITY_TEXT.exec(text);
27
+ return infinity === null ? 0 : infinity[1] === "-" ? -1 : 1;
28
+ }
16
29
  export function readsAsNoNumber(value) {
17
- return typeof value === "number" ? false : exactNumberText(value) === null;
30
+ return typeof value === "number" || nonFiniteSide(value) !== 0 ? false : exactNumberText(value) === null;
18
31
  }
@@ -8,7 +8,7 @@ import { LOCATION_ORDERS, locationSortText } from "./location.js";
8
8
  import { isOpenVocabulary, statusOptionOrder } from "../options.js";
9
9
  import { phoneMatchText } from "../phone.js";
10
10
  import { compareDecimalText } from "../parse-number.js";
11
- import { exactNumberText, readsAsNoNumber } from "./exact-number.js";
11
+ import { exactNumberText, nonFiniteSide, readsAsNoNumber } from "./exact-number.js";
12
12
  import { textOrderOf } from "./collate.js";
13
13
  import { mainItem, valueItems } from "../value-list.js";
14
14
  const NUMBER_TYPES = new Set(["number", "percent", "currency"]);
@@ -37,16 +37,16 @@ function mainOf(v) {
37
37
  function firstOf(v) {
38
38
  return Array.isArray(v) ? v[0] : v;
39
39
  }
40
- const infinitySide = (v) => (typeof v === "number" && (v === Infinity || v === -Infinity) ? Math.sign(v) : 0);
41
40
  const number = (a, b) => {
42
- if (typeof a === "number" && typeof b === "number")
43
- return a === b ? 0 : a < b ? -1 : a > b ? 1 : 0;
44
- const ia = infinitySide(a), ib = infinitySide(b);
41
+ const ia = nonFiniteSide(a), ib = nonFiniteSide(b);
42
+ if (ia === 0 && ib === 0 && typeof a === "number" && typeof b === "number")
43
+ return a === b ? 0 : a < b ? -1 : 1;
44
+ const ta = ia === 0 ? exactNumberText(a) : null, tb = ib === 0 ? exactNumberText(b) : null;
45
+ const noneA = ia === 0 && ta === null, noneB = ib === 0 && tb === null;
46
+ if (noneA || noneB)
47
+ return noneA === noneB ? 0 : noneA ? 1 : -1;
45
48
  if (ia !== 0 || ib !== 0)
46
49
  return ia - ib;
47
- const ta = exactNumberText(a), tb = exactNumberText(b);
48
- if (ta === null || tb === null)
49
- return ta === tb ? 0 : ta === null ? 1 : -1;
50
50
  return compareDecimalText(ta, tb);
51
51
  };
52
52
  const instant = nullsLast((a, b) => new Date(String(a)).getTime() - new Date(String(b)).getTime());
@@ -250,17 +250,20 @@ export function compareBy(sorts, reader, cv = DEFAULT_CONVENTIONS) {
250
250
  emptyName: valueTypeOf(field) === "name",
251
251
  emptyRange: valueTypeOf(field) === "range",
252
252
  emptyNumber: NUMBER_TYPES.has(valueTypeOf(field)) && !isPerCodeCurrency(presented),
253
+ sortAmountOf: money && reader.sortAmountOf,
253
254
  denominationOf: money && denominationReader(reader, spec.fieldKey, money),
254
255
  codeOrder: money && codeOrderFor(reader, money, cv),
255
256
  };
256
257
  });
257
258
  return (a, b) => {
258
259
  for (const step of steps) {
259
- const va = scalarOf(step.field, reader.read(a, step.key)), vb = scalarOf(step.field, reader.read(b, step.key));
260
+ const sa = step.sortAmountOf?.(a, step.key), sb = step.sortAmountOf?.(b, step.key);
261
+ const converted = sa !== undefined && sb !== undefined;
262
+ const va = converted ? sa : scalarOf(step.field, reader.read(a, step.key)), vb = converted ? sb : scalarOf(step.field, reader.read(b, step.key));
260
263
  const ea = isEmpty(va) || (step.emptyName && isEmptyName(firstOf(va))) || (step.emptyRange && isEmptyRange(va)) || (step.emptyNumber && readsAsNoNumber(va)), eb = isEmpty(vb) || (step.emptyName && isEmptyName(firstOf(vb))) || (step.emptyRange && isEmptyRange(vb)) || (step.emptyNumber && readsAsNoNumber(vb));
261
264
  if (ea !== eb)
262
265
  return ea ? 1 : -1;
263
- if (!ea && step.denominationOf && step.codeOrder) {
266
+ if (!ea && !converted && step.denominationOf && step.codeOrder) {
264
267
  const ca = step.denominationOf(a), cb = step.denominationOf(b);
265
268
  if ((ca === undefined) !== (cb === undefined))
266
269
  return ca === undefined ? 1 : -1;
@@ -1047,7 +1047,11 @@ const STORED = [
1047
1047
  MULTISELECT,
1048
1048
  RELATION,
1049
1049
  { type: z.literal("user") },
1050
- { type: z.literal("url"), validation: z.strictObject({ maxLength: finite.optional(), maxItems: finite.optional() }).optional() },
1050
+ {
1051
+ type: z.literal("url"),
1052
+ bareHost: z.literal("https").optional(),
1053
+ validation: z.strictObject({ maxLength: finite.optional(), maxItems: finite.optional() }).optional(),
1054
+ },
1051
1055
  { type: z.literal("domain"), ...ruledValidation },
1052
1056
  { type: z.literal("email"), validation: listMax.optional() },
1053
1057
  { type: z.literal("phone"), ...ruledValidation },
@@ -444,9 +444,12 @@ export type FieldDef = (FieldBase & TextSpec & {
444
444
  | (FieldBase & {
445
445
  type: "user";
446
446
  })
447
- /** `multiple`: several links, each a `{ value, label, main }` (`ValueItem`), at most one main. */
447
+ /** `multiple`: several links, each a `{ value, label, main }` (`ValueItem`), at most one main. `bareHost: "https"`: a
448
+ * host typed with no scheme (`acme.ro`, `acme.ro/work`) is stored with `https://` before it, by every commit and by
449
+ * `zodFor` alike (`withUrlScheme`); absent, it is refused for naming no scheme. */
448
450
  | (FieldBase & UrlSpec & {
449
451
  multiple?: true;
452
+ bareHost?: "https";
450
453
  validation?: {
451
454
  maxItems?: number;
452
455
  };
@@ -22,6 +22,11 @@ type KeptKeys = {
22
22
  /** Internal: the key a relation link's stored role is kept under: the link it rides on and the role, so the role
23
23
  * passes on that link alone. */
24
24
  export declare function linkRoleKey(kind: string, id: string, role: string): string;
25
+ /** A url as a field with `bareHost: "https"` stores it: trimmed text that names no scheme, whose host (the text before
26
+ * its first `/`, `?` or `#`, after a leading `//`) holds a dot and no space, with `https://` before it. Anything else
27
+ * comes back trimmed and is judged as typed: an address with its scheme, `mailto:`, a host with a port (which reads
28
+ * as a scheme, as a cell's link reads it), or a word that is no host (`hello`). */
29
+ export declare function withUrlScheme(text: string): string;
25
30
  /** Internal: whether a stored url is one a url cell links — an absolute web address, or text naming no scheme that
26
31
  * is one once `https://` is put before it. What a kept url is held to (`accept.ts`). Text with a space or a control
27
32
  * character inside is none: a split `java\tscript:` would hide its scheme here and lose it in the address parser. */
@@ -22,6 +22,14 @@ export function linkRoleKey(kind, id, role) {
22
22
  }
23
23
  const NO_KEPT = { has: () => false };
24
24
  const WEB_ADDRESS = z.url().refine((u) => /^https?:\/\//i.test(u));
25
+ export function withUrlScheme(text) {
26
+ const trimmed = text.trim();
27
+ if (/^[a-z][a-z\d+.-]*:/i.test(trimmed))
28
+ return trimmed;
29
+ const rest = trimmed.startsWith("//") ? trimmed.slice(2) : trimmed;
30
+ const host = rest.split(/[/?#]/, 1)[0] ?? "";
31
+ return /^[^\s.]+(\.[^\s.]+)+$/.test(host) ? `https://${rest}` : trimmed;
32
+ }
25
33
  export function readsAsLink(value) {
26
34
  if (typeof value !== "string")
27
35
  return false;
@@ -347,13 +355,14 @@ function build(field, cv, say, kept = NO_KEPT) {
347
355
  error: () => say({ key: "validation.url" }),
348
356
  });
349
357
  const max = field.validation?.maxLength;
350
- const checked = max === undefined
358
+ const ruled = max === undefined
351
359
  ? address
352
360
  : z
353
361
  .string({ error: () => say({ key: "validation.url" }) })
354
362
  .trim()
355
363
  .max(max, { error: () => say({ key: "validation.max-length", values: { max } }) })
356
364
  .pipe(address);
365
+ const checked = field.bareHost === "https" ? z.preprocess((v) => (typeof v === "string" ? withUrlScheme(v) : v), ruled) : ruled;
357
366
  const one = kept === NO_KEPT
358
367
  ? checked
359
368
  : z.unknown().transform((v, ctx) => {
@@ -21,6 +21,7 @@ const PERSON = defineFields({
21
21
  phones: { type: "phone", label: "Phones", multiple: true },
22
22
  website: { type: "url", label: "Website", validation: { maxLength: 300 } },
23
23
  links: { type: "url", label: "Links", multiple: true, emptiable: true },
24
+ blog: { type: "url", label: "Blog", bareHost: "https" },
24
25
  },
25
26
  });
26
27
 
@@ -141,6 +142,17 @@ const long = acceptFieldCommit(PERSON.website, `https://ana.example/${"a".repeat
141
142
  assert.equal(long.ok ? "" : long.reason, "Too long — at most 300 characters");
142
143
  ```
143
144
 
145
+ A url field with `bareHost: "https"` takes a host typed with no scheme and stores it with `https://` before it: `ana.example` is stored as `https://ana.example`, its path kept. Every commit does it the same way: `acceptFieldCommit`, `zodFor` on your route, and the grid's own check. `withUrlScheme` is the rule they share. An address that names its scheme is kept as typed, and text that is no host (`hello`, a host with a port, `mailto:`) is still refused in the url's words. The ceiling counts what is stored, the scheme included. A url kept as stored (`stored`, below) comes back as it was. Without the key, a bare host is refused.
146
+
147
+ ```ts
148
+ import { withUrlScheme, zodFor } from "viewkitjs/fields";
149
+
150
+ assert.deepEqual(acceptFieldCommit(PERSON.blog, " ana.example/notes "), { ok: true, value: "https://ana.example/notes" });
151
+ assert.equal(zodFor(PERSON.blog).parse("ana.example"), "https://ana.example");
152
+ assert.equal(acceptFieldCommit(PERSON.blog, "hello").ok, false);
153
+ assert.equal(withUrlScheme("http://ana.example"), "http://ana.example");
154
+ ```
155
+
144
156
  A link's platform is read from its address whenever it is asked for, and never stored. A platform a host adds later reaches every link already stored. `linkPlatform` gives `{ key, name }`: the first platform that answers on the link's host, else a website (`WEBSITE`, the key `"website"`), or null for a value that is no web link. A platform's host matches itself and every subdomain of it, as whole labels. `LINK_PLATFORMS` lists the library's own.
145
157
 
146
158
  ```ts
@@ -516,7 +516,7 @@ assert.throws(
516
516
 
517
517
  Six types hold a value with a shape of its own. In brief:
518
518
 
519
- - `url`: a web address with its scheme, stored as text. Its platform (LinkedIn, GitHub, a website…) is read from the address when asked for, never stored.
519
+ - `url`: a web address with its scheme, stored as text; `bareHost: "https"` stores a host typed without one with `https://` before it. Its platform (LinkedIn, GitHub, a website…) is read from the address when asked for, never stored.
520
520
  - `email`: an address, stored as text.
521
521
  - `domain`: a company's domain, kept clean: no scheme, `www.`, path or port; lower case; subdomains kept. It takes no validation of its own.
522
522
  - `phone`: `{ number, extension }`, the number in its international form (`+40722123456`). The phone library is its whole check.
@@ -561,6 +561,8 @@ const inEuros: ViewFieldReader<Deal> = {
561
561
  assert.deepEqual(sortedBy(DEALS, [{ fieldKey: "value", direction: "asc" }], inEuros), ["d5", "d3", "d2", "d4", "d1", "d6"]);
562
562
  ```
563
563
 
564
+ A reader whose cells show each row's own currency can still sort them as one: `sortAmountOf(row, key)` answers the amount converted into one currency for the whole list (`null` for none). Where it answers both rows, they order by those numbers, with no code clusters, so the order flips with the direction; `undefined` leaves the rule above in charge.
565
+
564
566
  ## Groups and buckets
565
567
 
566
568
  A `GroupSpec` splits a list into sections by one field. `canGroupBy(type, by?)` says whether a type can: a select, a status, a relation, a user, an actor, a yes or no, a date and a range group as a whole, a multiselect under every value it holds, so a row tagged twice sits in both buckets, and a many relation by its first link; text, numbers and names do not. A place groups only by one part, named by `by`, which `groupOrdersFor(type)` lists. `bucketRows(rows, spec, field, read, options?)` makes the buckets, each with its key, its label, its rows and whether it is hidden.
@@ -746,7 +748,7 @@ assert.deepEqual(columns.map((c) => [c.key, c.items.length, c.hidden]), [
746
748
 
747
749
  `evaluateView(rows, query, reader, options?)` runs a whole `ViewQuery`: it filters, sorts, and then groups the sorted rows, so each bucket's rows keep the sort. It returns the rows and the buckets, `null` when the query has no group or groups by a field the reader does not know. Pass `now` and `conventions` so today and every day are the host's.
748
750
 
749
- The reader is the one `compareBy` takes. `fieldOf(key)` gives a field's definition and `read(row, key)` its value as drawn. `decimalsOf(key)` gives a number column's decimals for equality, and `codeOf(row, key)` the currency a converted amount is in. A rollup with a breakdown is filtered, sorted and grouped by its headline.
751
+ The reader is the one `compareBy` takes. `fieldOf(key)` gives a field's definition and `read(row, key)` its value as drawn. `decimalsOf(key)` gives a number column's decimals for equality, `codeOf(row, key)` the currency a converted amount is in, and `sortAmountOf(row, key)` the amount a money field sorts by when its cells show each row's own currency. A rollup with a breakdown is filtered, sorted and grouped by its headline.
750
752
 
751
753
  ```ts
752
754
  import type { ViewQuery } from "viewkitjs/fields/query";
@@ -63,6 +63,7 @@ Guide: [conventions](../guides/conventions.md).
63
63
 
64
64
  Guide: [validation and acceptance](../guides/validation-and-acceptance.md).
65
65
 
66
+ - `withUrlScheme` — a url as a field with `bareHost: "https"` stores it: trimmed text naming no scheme, whose host holds a dot, with `https://` before it (`acme.ro/work` → `https://acme.ro/work`, `//acme.ro` → `https://acme.ro`); anything else trimmed and unchanged, to be judged as typed. `acceptFieldCommit`, `zodFor` and the grid's check all read it.
66
67
  - `zodFor` — the Zod schema of a field's stored value, worded in the host's messages. Input and output keep the stored type and nothing is coerced between types, so a form resolver keeps the row's literal types. Its JSON Schema (`z.toJSONSchema`) names each type's stored shape; a phone's is an object of an E.164 `number` and an `extension` of digits or `null`, while the phone library judges the number itself.
67
68
  - `acceptFieldCommit` — judges the value a field's editor commits and returns the value to store or a refusal: an empty commit becomes null or the type's empty value, or is refused; typed text is trimmed, a domain cleaned, a phone read in the record's or the person's region. It judges the value only, never who may change the field (that is `lockReason` and the field's mutability): an actor and a non-empty commit to a derived field are refused, and an empty commit to a nullable derived field is accepted as null.
68
69
  - `acceptStoredFieldValue` — judges the value a binding says it will store, as the last gate before a write: null only for a nullable field, no blank for a required one, then the stored-value schema.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewkitjs",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "ViewKit — typed fields, the grid and its editors, and a list's SQL for record lists, in one package: viewkitjs/fields, viewkitjs/views and viewkitjs/postgres. By Sheaf.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
@@ -3,7 +3,7 @@ import { filterPartsFor, filterValueSchema, operatorsForField, ruleIsActive, whe
3
3
  import { fieldsOf, isOneRelation } from "./map.js";
4
4
  import { readableField } from "./readable.js";
5
5
  import { REFUSALS } from "./refusals.js";
6
- import { currenciesProblem } from "./rules.js";
6
+ import { currenciesProblem, sortCurrencyProblem } from "./rules.js";
7
7
  const TEXT_TYPES = new Set([
8
8
  "text",
9
9
  "url",
@@ -103,6 +103,9 @@ function contextProblem(context) {
103
103
  const currencies = currenciesProblem(context.currencies);
104
104
  if (currencies !== null)
105
105
  return currencies;
106
+ const sortCurrency = sortCurrencyProblem(context.sortCurrency);
107
+ if (sortCurrency !== null)
108
+ return sortCurrency;
106
109
  const since = context.since;
107
110
  return since === undefined || (since instanceof Date && Number.isFinite(since.getTime())) ? null : "since is no moment";
108
111
  }
@@ -163,7 +163,9 @@ export function formulaSql(rule, read, clock) {
163
163
  case "isEmpty":
164
164
  return boolean(a.type === "text" || a.spelled ? sql `(NULLIF(${a.sql}, '') IS NULL)` : sql `(${a.sql} IS NULL)`);
165
165
  case "concat":
166
- return text(sql `concat(${join(args.map(textOf), sql `, `)})`);
166
+ if (args.length === 0)
167
+ return text(sql `''::text`);
168
+ return text(sql `(${join(args.map((one) => sql `COALESCE(${textOf(one)}, '')`), sql ` || `)})`);
167
169
  case "join": {
168
170
  const [separator, ...parts] = args;
169
171
  if (parts.length === 0)
@@ -1,6 +1,6 @@
1
1
  import { conversionOf, presentedDef, valueTypeOf } from "viewkitjs/fields";
2
2
  import { openedOf } from "../access.js";
3
- import { currencyOf } from "../rules.js";
3
+ import { convertsWith, currencyOf } from "../rules.js";
4
4
  import { sql } from "../sql.js";
5
5
  import { StorageError } from "./storage.js";
6
6
  export const MONEY_REASONS = {
@@ -76,6 +76,7 @@ export function placeConverted(at, base) {
76
76
  return into === undefined ? kept(row) : convert(row, into);
77
77
  };
78
78
  KEPT.set(value, kept);
79
+ convertsWith(value, convert);
79
80
  const fields = [
80
81
  ...("fields" in base ? (base.fields ?? []) : []),
81
82
  { table, key: codeKey },
@@ -3,7 +3,7 @@ import { fingerprintOf, fitsKey, KEY_ARRAYS, readCursor, spelledAsKept, writeCur
3
3
  import { doubleText } from "./double.js";
4
4
  import { fieldsOf } from "./map.js";
5
5
  import { REFUSALS } from "./refusals.js";
6
- import { currencyOf } from "./rules.js";
6
+ import { currencyOf, sortCurrencyOf } from "./rules.js";
7
7
  import { checkSorts, keyPartsOf, orderItem } from "./sort.js";
8
8
  import { isDateType } from "./date-groups.js";
9
9
  import { groupSql } from "./groups.js";
@@ -131,7 +131,8 @@ function readsDay(node) {
131
131
  return node.items.some(readsDay);
132
132
  }
133
133
  function currenciesRead(map, checked, sorts, groupKey, context) {
134
- const keys = new Set([...sorts.map((sort) => sort.key), ...(groupKey === undefined ? [] : [groupKey])]);
134
+ const sorted = new Set(sorts.map((sort) => sort.key));
135
+ const keys = new Set([...sorted, ...(groupKey === undefined ? [] : [groupKey])]);
135
136
  const walk = (node) => {
136
137
  if (node === null || "quantifier" in node)
137
138
  return;
@@ -144,7 +145,9 @@ function currenciesRead(map, checked, sorts, groupKey, context) {
144
145
  const read = [];
145
146
  for (const key of [...keys].sort()) {
146
147
  const field = Object.hasOwn(map.fields, key) ? map.fields[key] : undefined;
147
- const currency = field === undefined ? undefined : currencyOf(context, key, field.def);
148
+ const currency = field === undefined
149
+ ? undefined
150
+ : (currencyOf(context, key, field.def) ?? (sorted.has(key) ? sortCurrencyOf(context, key, field.def) : undefined));
148
151
  if (currency !== undefined)
149
152
  read.push([key, currency]);
150
153
  }
@@ -1,6 +1,6 @@
1
1
  import { type FieldDef, type ValueType } from "viewkitjs/fields";
2
2
  import { type FilterRule } from "viewkitjs/fields/query";
3
- import type { Stored } from "./map.js";
3
+ import type { Row, Stored } from "./map.js";
4
4
  import { type Sql } from "./sql.js";
5
5
  /**
6
6
  * What a rule reads beside its row: the zone a day is read in, the moment relative days count from, and the reader's
@@ -15,9 +15,23 @@ export type FilterContext = {
15
15
  /** The currency a field whose definition converts is read in, by the list's own field key; a field not named reads
16
16
  * its amount as kept, beside its own code. */
17
17
  readonly currencies?: Readonly<Record<string, string>>;
18
+ /** The currency a field whose definition converts is SORTED in when `currencies` names none for it: its amount
19
+ * converted into it, so rows in different currencies order as one number that flips with the direction. The cells
20
+ * still read each amount as kept, beside its own code. Your app's own currency, say. Absent, such a sort clusters
21
+ * by code first. */
22
+ readonly sortCurrency?: string;
18
23
  };
19
24
  /** Why a context's `currencies` can't be read, or null: no record, or a currency that is no text. */
20
25
  export declare function currenciesProblem(currencies: unknown): string | null;
26
+ /** Why a context's `sortCurrency` can't be read, or null. */
27
+ export declare function sortCurrencyProblem(sortCurrency: unknown): string | null;
28
+ /** The currency field `key` is sorted in when the request reads it as kept: the context's `sortCurrency`, for a field
29
+ * whose definition converts and that `currencies` names no currency for; else undefined. */
30
+ export declare function sortCurrencyOf(context: FilterContext | undefined, key: string, def: FieldDef): string | undefined;
31
+ /** Records `convert` as the conversion behind the read `read`. */
32
+ export declare function convertsWith(read: (row: Row) => Sql, convert: (row: Row, into: string) => Sql): void;
33
+ /** The conversion behind a read that converts, else undefined: a column, or an app's own expression, has none. */
34
+ export declare function conversionBehind(read: unknown): ((row: Row, into: string) => Sql) | undefined;
21
35
  /**
22
36
  * The currency the request reads field `key` in: undefined for a lookup (its code is a far record's), a field whose
23
37
  * definition doesn't convert, or one the request names none for. The one place the translator reads `currencies`.
@@ -15,6 +15,22 @@ export function currenciesProblem(currencies) {
15
15
  }
16
16
  return null;
17
17
  }
18
+ export function sortCurrencyProblem(sortCurrency) {
19
+ return sortCurrency === undefined || (typeof sortCurrency === "string" && sortCurrency !== "") ? null : "sortCurrency is no currency";
20
+ }
21
+ export function sortCurrencyOf(context, key, def) {
22
+ if (def.type === "lookup" || conversionOf(def) === null || currencyOf(context, key, def) !== undefined)
23
+ return undefined;
24
+ const code = context?.sortCurrency;
25
+ return typeof code === "string" && code !== "" ? code : undefined;
26
+ }
27
+ const CONVERTS = new WeakMap();
28
+ export function convertsWith(read, convert) {
29
+ CONVERTS.set(read, convert);
30
+ }
31
+ export function conversionBehind(read) {
32
+ return typeof read === "function" ? CONVERTS.get(read) : undefined;
33
+ }
18
34
  export function currencyOf(context, key, def) {
19
35
  if (def.type === "lookup" || conversionOf(def) === null)
20
36
  return undefined;
@@ -6,7 +6,7 @@ import { fieldsOf, isOneRelation } from "./map.js";
6
6
  import { REFUSALS } from "./refusals.js";
7
7
  import { castTo, integerLiteral, isSql, join, render, sql } from "./sql.js";
8
8
  import { reachedFrom } from "./relations.js";
9
- import { currencyOf } from "./rules.js";
9
+ import { conversionBehind, currencyOf, sortCurrencyOf } from "./rules.js";
10
10
  import { joinedValueSql, mainValueSql } from "./several.js";
11
11
  import { joinedOf, labelOf, partNamesOf, partSql, rowJoinOf, valueSql } from "./values.js";
12
12
  import { rowFilledSql, rowProbeOn, rowProbeSql } from "./value-rows.js";
@@ -231,10 +231,15 @@ function partsOf(scope, main, sort, locale) {
231
231
  if (field.mapping.notNull === true)
232
232
  return [{ ...turning(value(), kindOf(stored)), notNull: true }];
233
233
  return walking([last(value(), kindOf(stored))], asKept);
234
- case "currency":
234
+ case "currency": {
235
235
  if (currencyOf(scope.context, key, field.def) !== undefined)
236
236
  return [last(value(), kindOf(stored))];
237
+ const into = sortCurrencyOf(scope.context, key, field.def);
238
+ const convert = into === undefined ? undefined : conversionBehind(field.mapping.value);
239
+ if (into !== undefined && convert !== undefined)
240
+ return [last(convert(main.row, into), "numeric")];
237
241
  return walking(currencyParts(scope, main, sort, def, value(), kindOf(stored), last, flag, (codes) => rowWalk(value(), rowFilledSql(stored, value()), (probe) => rowFilledSql(stored, probe.row.column(row.value)), { codes })), asKept);
242
+ }
238
243
  case "select":
239
244
  case "status": {
240
245
  const v = stored === "uuid" ? sql `(${value()})::text` : value();
@@ -186,7 +186,7 @@ Hand it in beside the rest: `buildFieldMap({ index, storage, kind: "deal", money
186
186
  - **`day`** is `{ ask }`, the request's moment, for a definition that converts at today's rate (read it as its UTC day), or `{ row, type }` for one that converts at a row's own date: `type: "date"` for a date, `"datetime"` for an instant, handed as a `timestamptz` (one kept without a zone is read as UTC), whose UTC day you read.
187
187
  - **`into`** is the currency the request names for the field, as text, or, for a rollup, the currency its result names: a fixed code, or its record's own as SQL.
188
188
 
189
- The request names a currency per field, in its context: `context: { timeZone, now, currencies: { value: "USD" } }`. A field it names reads, filters, sorts, adds up and pages in that currency, and a page's cursor is bound to it. A field it names none for reads its amount as kept, beside its own code, and sorts by its code first, as the translator sorts any amount whose code is a sibling.
189
+ The request names a currency per field, in its context: `context: { timeZone, now, currencies: { value: "USD" } }`. A field it names reads, filters, sorts, adds up and pages in that currency, and a page's cursor is bound to it. A field it names none for reads its amount as kept, beside its own code, and sorts by its code first, as the translator sorts any amount whose code is a sibling, unless the context names a `sortCurrency` (`context: { timeZone, now, sortCurrency: "EUR" }`, your app's own currency): then it sorts by its amount converted into that one, so €12,000 and $8,000 change places when the direction does, while each row still reads in its own currency.
190
190
 
191
191
  Only the list's own rows convert: a related record's amount reads as kept. A formula reads the amounts it uses as kept, and its own result converts when its definition says so, so nothing converts twice. A rollup's sum, average, smallest, largest or first of an amount that converts converts each far amount on its far row's own day into the currency its result names: a fixed code, or its record's own (`code: { field }`), so it converts even when the request names no currency; a result that converts in turn then converts into the one the request names. A definition that converts, with no `money` handed in, is refused when the map is built, as a `StorageError` at `money` naming the field. So is your own entry (`handWritten`) for one: an amount that converts is read through your money function, so the currency a request names always reaches it.
192
192
 
@@ -412,7 +412,7 @@ assert.deepEqual(unserved, []);
412
412
  - A word of one or two letters reads every row: a trigram index has nothing to look it up by.
413
413
  - The indexes serve a statement Postgres plans with its values, as it plans one sent unnamed (`pg`, Prisma's driver adapters, a transaction pooler). A prepared statement planned generically reads every row, with the same answers.
414
414
  - A relation's column, when it is your expression, now runs on every row a search reads, so it must never raise.
415
- - An index holds only immutable SQL. A `search` read, a label or a formula that calls a function Postgres won't index (`concat_ws`, `concat`, `to_char`, `unaccent`, `now()`) is named in `unserved` (`notImmutable`, or `farLabel` for a relation's far label) and never printed. A name kept in parts is labelled in immutable SQL, so its index builds. Write your own label the same way: `COALESCE(given || ' ' || family, given, family)`, not `concat_ws`. A stable cast (text to a date or a timestamp) is not recognised: an index on one is printed, and `CREATE INDEX` refuses it (`42P17`).
415
+ - An index holds only immutable SQL. A `search` read, a label or a formula that calls a function Postgres won't index (`concat_ws`, `concat`, `to_char`, `unaccent`, `now()`) is named in `unserved` (`notImmutable`, or `farLabel` for a relation's far label) and never printed. A name kept in parts is labelled in immutable SQL, so its index builds, and so is a formula's `join` and `concat` of text; a formula that reads a day, an instant or a number into text still reaches `to_char` and is named unserved. Write your own label the same way: `COALESCE(given || ' ' || family, given, family)`, not `concat_ws`. A stable cast (text to a date or a timestamp) is not recognised: an index on one is printed, and `CREATE INDEX` refuses it (`42P17`).
416
416
  - Each trigram index adds cost to every insert and update on its table, so index only the fields a list searches. Built without `CONCURRENTLY` inside a migration's transaction, an index blocks writes to its table until the migration commits.
417
417
 
418
418
  Measured on a list of about 26,000 records searched across five fields, one a formula and one a relation: with every word of three letters or more, each statement took under 50 ms through its indexes, where reading every row took 110–270 ms.