viewkitjs 0.31.0 → 0.32.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 (289) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/MIGRATION.md +40 -6
  3. package/README.md +1 -1
  4. package/fields/dist/query/index.d.ts +2 -0
  5. package/fields/dist/query/index.js +2 -0
  6. package/fields/dist/query/list-request.d.ts +148 -0
  7. package/fields/dist/query/list-request.js +125 -0
  8. package/fields/dist/query/saved-view.d.ts +15 -0
  9. package/fields/dist/query/saved-view.js +11 -0
  10. package/fields/dist/query/settings.d.ts +9 -0
  11. package/fields/dist/query/settings.js +9 -0
  12. package/fields/docs/reference/query.md +66 -0
  13. package/package.json +5 -1
  14. package/postgres/README.md +1 -0
  15. package/postgres/dist/handler.d.ts +53 -0
  16. package/postgres/dist/handler.js +211 -0
  17. package/postgres/dist/ids.d.ts +1 -1
  18. package/postgres/dist/ids.js +19 -1
  19. package/postgres/dist/index.d.ts +1 -0
  20. package/postgres/dist/index.js +1 -0
  21. package/postgres/dist/limits.d.ts +3 -1
  22. package/postgres/dist/limits.js +1 -1
  23. package/postgres/dist/list-fields.d.ts +10 -0
  24. package/postgres/dist/list-fields.js +36 -0
  25. package/postgres/dist/readable.d.ts +4 -0
  26. package/postgres/dist/readable.js +4 -0
  27. package/postgres/dist/refusals.d.ts +9 -2
  28. package/postgres/dist/refusals.js +6 -0
  29. package/postgres/docs/guides/field-map.md +2 -2
  30. package/postgres/docs/guides/list-handler.md +99 -0
  31. package/postgres/docs/index.md +1 -0
  32. package/postgres/docs/reference/postgres.md +11 -3
  33. package/views/README.md +2 -2
  34. package/views/dist/atoms/RowMenu.d.ts +7 -0
  35. package/views/dist/atoms/RowMenu.js +18 -16
  36. package/views/dist/atoms/carried.d.ts +5 -0
  37. package/views/dist/atoms/carried.js +7 -0
  38. package/views/dist/atoms/types.d.ts +3 -0
  39. package/views/dist/contract.d.ts +26 -6
  40. package/views/dist/contract.js +25 -0
  41. package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
  42. package/views/dist/controls/atoms.d.ts +2 -0
  43. package/views/dist/controls/atoms.js +2 -0
  44. package/views/dist/controls/avatar/avatar.d.ts +3 -3
  45. package/views/dist/controls/avatar/avatar.js +1 -1
  46. package/views/dist/controls/avatar/tokens.d.ts +44 -0
  47. package/views/dist/controls/avatar/tokens.js +11 -0
  48. package/views/dist/controls/avatar.css +22 -5
  49. package/views/dist/controls/choice/tokens.d.ts +0 -4
  50. package/views/dist/controls/choice/tokens.js +0 -1
  51. package/views/dist/controls/choice.css +3 -3
  52. package/views/dist/controls/controls.d.ts +6 -0
  53. package/views/dist/controls/controls.js +10 -2
  54. package/views/dist/controls/customize/map-customize-body.js +1 -1
  55. package/views/dist/controls/field/field.d.ts +19 -4
  56. package/views/dist/controls/field/field.js +63 -5
  57. package/views/dist/controls/field/tokens.d.ts +4 -0
  58. package/views/dist/controls/field/tokens.js +1 -0
  59. package/views/dist/controls/field.css +41 -16
  60. package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
  61. package/views/dist/controls/glyphs/glyphs.js +173 -0
  62. package/views/dist/controls/index.d.ts +2 -1
  63. package/views/dist/controls/index.js +2 -1
  64. package/views/dist/controls/input/input.js +5 -2
  65. package/views/dist/controls/input/tokens.d.ts +4 -0
  66. package/views/dist/controls/input/tokens.js +1 -0
  67. package/views/dist/controls/input.css +31 -3
  68. package/views/dist/controls/internal/icons.js +10 -0
  69. package/views/dist/controls/internal/keep-focus.d.ts +2 -0
  70. package/views/dist/controls/internal/keep-focus.js +17 -0
  71. package/views/dist/controls/internal/watch-frame.d.ts +2 -0
  72. package/views/dist/controls/internal/watch-frame.js +33 -0
  73. package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
  74. package/views/dist/controls/markdown/map-markdown.js +5 -0
  75. package/views/dist/controls/menu/map-menu.js +2 -2
  76. package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
  77. package/views/dist/controls/menu-list/menu-list.js +5 -4
  78. package/views/dist/controls/modal/modal.js +5 -1
  79. package/views/dist/controls/pane/pane.js +2 -1
  80. package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
  81. package/views/dist/controls/phone-header/header-bar.js +2 -2
  82. package/views/dist/controls/phone-header.css +11 -1
  83. package/views/dist/controls/picker/map-picker.js +3 -0
  84. package/views/dist/controls/picker/picker.d.ts +14 -0
  85. package/views/dist/controls/picker/picker.js +30 -10
  86. package/views/dist/controls/picker.css +2 -0
  87. package/views/dist/controls/popover/popover.js +2 -1
  88. package/views/dist/controls/radio/radio.d.ts +5 -3
  89. package/views/dist/controls/radio/radio.js +18 -2
  90. package/views/dist/controls/radio/tokens.d.ts +44 -0
  91. package/views/dist/controls/radio/tokens.js +11 -0
  92. package/views/dist/controls/radio.css +79 -1
  93. package/views/dist/controls/select/select.d.ts +4 -0
  94. package/views/dist/controls/select/select.js +11 -5
  95. package/views/dist/controls/select/tokens.d.ts +8 -0
  96. package/views/dist/controls/select/tokens.js +2 -0
  97. package/views/dist/controls/select.css +17 -0
  98. package/views/dist/controls/setting-row/looks.d.ts +1 -1
  99. package/views/dist/controls/setting-row/looks.js +9 -4
  100. package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
  101. package/views/dist/controls/setting-row/setting-row.js +82 -15
  102. package/views/dist/controls/setting-row/tokens.d.ts +74 -2
  103. package/views/dist/controls/setting-row/tokens.js +19 -1
  104. package/views/dist/controls/setting-row.css +135 -14
  105. package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
  106. package/views/dist/controls/sheet/bottom-sheet.js +6 -3
  107. package/views/dist/controls/sheet.css +4 -1
  108. package/views/dist/controls/sort-editor/sort-editor.js +3 -2
  109. package/views/dist/controls/sort-editor.css +8 -2
  110. package/views/dist/controls/switch-row/tokens.d.ts +0 -12
  111. package/views/dist/controls/switch-row/tokens.js +0 -3
  112. package/views/dist/controls/switch-row.css +3 -7
  113. package/views/dist/controls/switch.css +17 -7
  114. package/views/dist/controls/tag/tag.d.ts +3 -1
  115. package/views/dist/controls/tag/tag.js +2 -2
  116. package/views/dist/controls/tag/tokens.d.ts +4 -0
  117. package/views/dist/controls/tag/tokens.js +1 -0
  118. package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
  119. package/views/dist/controls/tag-field/tag-field.js +11 -5
  120. package/views/dist/controls/tag-field/tokens.d.ts +16 -0
  121. package/views/dist/controls/tag-field/tokens.js +4 -0
  122. package/views/dist/controls/tag-field.css +19 -0
  123. package/views/dist/controls/tag.css +2 -0
  124. package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
  125. package/views/dist/controls/toolbar/toolbar.js +22 -15
  126. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
  127. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
  128. package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
  129. package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
  130. package/views/dist/controls/toolbar-button.css +4 -0
  131. package/views/dist/controls/toolbar.css +5 -0
  132. package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
  133. package/views/dist/controls/views-list/map-view-menu.js +25 -0
  134. package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
  135. package/views/dist/controls/views-list/map-views-list-body.js +39 -21
  136. package/views/dist/controls/views-list/rules.d.ts +2 -0
  137. package/views/dist/controls/views-list/view-menu.d.ts +7 -0
  138. package/views/dist/controls/views-list/view-menu.js +28 -24
  139. package/views/dist/controls/views-list/words.d.ts +2 -0
  140. package/views/dist/controls/views-list/words.js +1 -1
  141. package/views/dist/editors/EditorPanel.js +2 -1
  142. package/views/dist/editors/edit-session.js +2 -5
  143. package/views/dist/field-row/FieldRow.d.ts +4 -2
  144. package/views/dist/field-row/FieldRow.js +67 -20
  145. package/views/dist/field-row/FieldRowLane.d.ts +7 -2
  146. package/views/dist/field-row/FieldRowLane.js +4 -3
  147. package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
  148. package/views/dist/field-row/editors/RowEditor.js +31 -1
  149. package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
  150. package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
  151. package/views/dist/field-row/field-row-button.d.ts +5 -0
  152. package/views/dist/field-row/field-row-button.js +2 -0
  153. package/views/dist/fields/binding.d.ts +3 -2
  154. package/views/dist/fields/binding.js +38 -5
  155. package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
  156. package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
  157. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
  158. package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
  159. package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
  160. package/views/dist/grid/chrome/GridHeader.js +2 -2
  161. package/views/dist/grid/chrome/GridRow.js +6 -5
  162. package/views/dist/grid/chrome/GridRowCells.js +6 -9
  163. package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
  164. package/views/dist/grid/chrome/GridStructure.js +4 -4
  165. package/views/dist/grid/chrome/GridTable.js +5 -2
  166. package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
  167. package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
  168. package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
  169. package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
  170. package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
  171. package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
  172. package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
  173. package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
  174. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
  175. package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
  176. package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
  177. package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
  178. package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
  179. package/views/dist/grid/core/commit-model.d.ts +20 -2
  180. package/views/dist/grid/core/editing-controller.d.ts +18 -0
  181. package/views/dist/grid/core/editing-controller.js +188 -42
  182. package/views/dist/grid/core/editing-model.d.ts +3 -0
  183. package/views/dist/grid/core/editing-model.js +3 -0
  184. package/views/dist/grid/core/save-path.d.ts +24 -0
  185. package/views/dist/grid/core/save-path.js +122 -0
  186. package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
  187. package/views/dist/grid/core/spreadsheet-operations.js +23 -0
  188. package/views/dist/grid/index.d.ts +3 -2
  189. package/views/dist/grid/index.js +1 -0
  190. package/views/dist/internal/field-rows.d.ts +26 -0
  191. package/views/dist/internal/field-rows.js +8 -0
  192. package/views/dist/internal/page-close.d.ts +7 -0
  193. package/views/dist/internal/page-close.js +43 -0
  194. package/views/dist/list/browser-views-store.d.ts +10 -0
  195. package/views/dist/list/browser-views-store.js +182 -0
  196. package/views/dist/list/index.d.ts +23 -0
  197. package/views/dist/list/index.js +8 -0
  198. package/views/dist/list/menu.d.ts +31 -0
  199. package/views/dist/list/menu.js +76 -0
  200. package/views/dist/list/parts.d.ts +6 -0
  201. package/views/dist/list/parts.js +59 -0
  202. package/views/dist/list/registry.d.ts +11 -0
  203. package/views/dist/list/registry.js +31 -0
  204. package/views/dist/list/root.d.ts +40 -0
  205. package/views/dist/list/root.js +128 -0
  206. package/views/dist/list/slot.d.ts +14 -0
  207. package/views/dist/list/slot.js +22 -0
  208. package/views/dist/list/source.d.ts +11 -0
  209. package/views/dist/list/source.js +31 -0
  210. package/views/dist/list/store.d.ts +87 -0
  211. package/views/dist/list/store.js +115 -0
  212. package/views/dist/list/toolbar.d.ts +6 -0
  213. package/views/dist/list/toolbar.js +359 -0
  214. package/views/dist/list/views-axis.d.ts +5 -0
  215. package/views/dist/list/views-axis.js +96 -0
  216. package/views/dist/list/views-store.d.ts +41 -0
  217. package/views/dist/list/views-store.js +1 -0
  218. package/views/dist/list/views.d.ts +67 -0
  219. package/views/dist/list/views.js +400 -0
  220. package/views/dist/model/preferences.js +1 -1
  221. package/views/dist/model/prefs-buckets.js +1 -1
  222. package/views/dist/panels/index.d.ts +3 -1
  223. package/views/dist/panels/index.js +1 -0
  224. package/views/dist/panels/react/customize-body.js +1 -0
  225. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
  226. package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
  227. package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
  228. package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
  229. package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
  230. package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
  231. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
  232. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
  233. package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
  234. package/views/dist/panels/react/toolbar/context.d.ts +10 -2
  235. package/views/dist/panels/react/toolbar/context.js +3 -1
  236. package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
  237. package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
  238. package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
  239. package/views/dist/panels/react/views-row/PillGroup.js +16 -7
  240. package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
  241. package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
  242. package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
  243. package/views/dist/panels/react.d.ts +2 -2
  244. package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
  245. package/views/dist/panels/toolbar/edit-view.js +14 -0
  246. package/views/dist/panels/toolbar/model.d.ts +5 -0
  247. package/views/dist/panels/toolbar/model.js +7 -3
  248. package/views/dist/panels/view-state.d.ts +5 -3
  249. package/views/dist/panels/views-row/model.d.ts +19 -2
  250. package/views/dist/panels/views-row/model.js +14 -0
  251. package/views/dist/provider/ViewsProvider.d.ts +16 -7
  252. package/views/dist/provider/ViewsProvider.js +23 -5
  253. package/views/dist/provider/components.d.ts +43 -2
  254. package/views/dist/provider/context.d.ts +2 -1
  255. package/views/dist/provider/context.js +1 -1
  256. package/views/dist/provider/ports.d.ts +19 -12
  257. package/views/dist/provider/ports.js +69 -1
  258. package/views/dist/react.d.ts +1 -1
  259. package/views/dist/styles.css +418 -59
  260. package/views/dist/styles.unlayered.css +418 -59
  261. package/views/docs/contract.md +42 -31
  262. package/views/docs/controls/avatar.md +11 -0
  263. package/views/docs/controls/choice.md +0 -1
  264. package/views/docs/controls/field.md +3 -0
  265. package/views/docs/controls/input.md +1 -0
  266. package/views/docs/controls/radio.md +16 -1
  267. package/views/docs/controls/select.md +2 -0
  268. package/views/docs/controls/setting-row.md +18 -0
  269. package/views/docs/controls/switch-row.md +0 -3
  270. package/views/docs/controls/tag-field.md +4 -0
  271. package/views/docs/controls/tag.md +1 -0
  272. package/views/docs/getting-started.md +2 -2
  273. package/views/docs/guides/atoms.md +2 -2
  274. package/views/docs/guides/columns.md +1 -1
  275. package/views/docs/guides/ports.md +1 -1
  276. package/views/docs/guides/the-grid.md +34 -7
  277. package/views/docs/guides/the-provider.md +4 -2
  278. package/views/docs/index.md +1 -0
  279. package/views/docs/reference/controls.md +35 -25
  280. package/views/docs/reference/editors-session.md +1 -1
  281. package/views/docs/reference/field-row.md +9 -1
  282. package/views/docs/reference/grid.md +14 -8
  283. package/views/docs/reference/list.md +227 -0
  284. package/views/docs/reference/looks.md +1 -1
  285. package/views/docs/reference/panels-react.md +17 -12
  286. package/views/docs/reference/panels.md +8 -5
  287. package/views/docs/reference/react.md +11 -9
  288. package/views/docs/reference/views.md +2 -2
  289. package/views/skills/views/SKILL.md +9 -6
@@ -157,6 +157,10 @@ export type ViewsMenuItem = {
157
157
  shortcut?: string;
158
158
  /** A link item: the row is an anchor and `onSelect` still fires. */
159
159
  href?: string;
160
+ /** Draws the row's inside, in place of its icon, words, keys and count; `label` stays its words (a screen reader, typing
161
+ * to find it). Called while the menu draws: return elements, call no hooks in it. Honoured on a plain row: a group, a
162
+ * tick and a link draw as they are. A hint: an adapter that ignores it draws the label. */
163
+ render?: () => ReactNode;
160
164
  };
161
165
  /** Opens at `anchor`, with no trigger child; a group opens beside it only where it asks to and the
162
166
  * adapter can. On Base UI, the menu's root, positioner and popup, the anchor handed to the positioner. */
@@ -993,6 +997,8 @@ export type ViewsViewsListItem = {
993
997
  changed?: boolean;
994
998
  /** One of the reader's favorites. */
995
999
  favorite?: boolean;
1000
+ /** A view this reader can't change: no Rename, Delete, Private view or Save in its menu; Reset, Save as new view, Copy link and Duplicate stay. */
1001
+ readOnly?: boolean;
996
1002
  };
997
1003
  /** A view as a restore hands it back. */
998
1004
  export type ViewsViewRecord = {
@@ -1074,6 +1080,12 @@ export type ViewsViewVerbs = {
1074
1080
  * is deleted, the view again on a restore with `open`, the new one on a create or a duplicate, whose ids your app makes).
1075
1081
  * `viewsAfter` (viewkitjs/views/controls) does all of it over your views. */
1076
1082
  onChange: (change: ViewsViewChange) => void;
1083
+ /** The view's menu as data (VK-741): handed its default items, keyed (`rename`, `edit`, `private`, `save`, `reset`,
1084
+ * `save-new`, `copy-link`, `favorite`, `duplicate`, `delete`; on a phone the groups `unsaved` and `this-view`), and the view,
1085
+ * it hands back the items drawn. `menu` (viewkitjs/views/list) drops, renames, adds and moves them. */
1086
+ menu?: (items: ViewsMenuItem[], ctx: {
1087
+ view: ViewsViewsListItem;
1088
+ }) => ViewsMenuItem[];
1077
1089
  };
1078
1090
  /** The views list's body, which your app draws (`ViewsListBody`): what the view picker's chip opens on a computer and in
1079
1091
  * the phone's Sheet, in place of ViewKit's own list. A panel's body, as every panel's: handed the axis's views as data,
@@ -1113,6 +1125,29 @@ export type ViewsViewsListBodyProps = {
1113
1125
  * dialog, which stands outside the list's popover), and the list stays when it is answered. On a computer. */
1114
1126
  onHold?: (holding: boolean) => void;
1115
1127
  };
1128
+ /** One view's whole menu at an anchor, which your app may draw (`ViewMenu`; `CONTROLS.ViewMenu` is ViewKit's own): what a views
1129
+ * row's pill and a folded view's ⋮ open on a computer where the axis hands `verbs` (VK-947), in place of the view's `menu`
1130
+ * rows. Its items are the views list's view menu's (Rename, Edit view, Save, Reset, Save as new view, Copy link, Duplicate,
1131
+ * Delete), as data `verbs.menu` reshapes; Rename and New view ask in their Modal, Delete asks first and says so with Undo. */
1132
+ export type ViewsViewMenuProps = {
1133
+ open: boolean;
1134
+ onOpenChange: ViewsOpenChange;
1135
+ anchor: ViewsAnchor;
1136
+ align?: ViewsAlign;
1137
+ /** The view whose menu it is, by its value. Left out, it stands on New view's Modal (the layouts, the name) in place of a
1138
+ * menu, as the views row's + opens it (VK-971): drawn with `open`, it tells `onOpenChange(false)` once the Modal has closed. */
1139
+ view?: string;
1140
+ /** Every view of the axis, in its order, as the views list is handed them: Delete keeps one, Undo puts it back in its place. */
1141
+ views: readonly ViewsViewsListItem[];
1142
+ /** The view in use. */
1143
+ value: string;
1144
+ verbs: ViewsViewVerbs;
1145
+ /** A change opened a view, ended in the Toast, or asked for Customize: what holds the menu closes. */
1146
+ onDone?: () => void;
1147
+ /** While true, the menu asks outside what holds it (your `confirm` port's dialog): a press outside and Escape close nothing
1148
+ * there, and it stays when it is answered. */
1149
+ onHold?: (holding: boolean) => void;
1150
+ };
1116
1151
  /** A field a list can be grouped by, as the group body is handed it (`ViewsGroupBodyProps.dimensions`): the panels'
1117
1152
  * `GroupDimension` (`viewkitjs/views/panels`), written out here, since the provider reaches nothing inside the panels. */
1118
1153
  export type ViewsGroupDimension = {
@@ -1395,9 +1430,11 @@ export type ViewsCustomizeBodyProps = {
1395
1430
  group?: Omit<ViewsGroupBodyProps, "form" | "onDone" | "actions" | "onStepChange">;
1396
1431
  /** The list's own toggles, Show counts among them (read from the view). */
1397
1432
  toggles: readonly ViewsCustomizeToggle[];
1398
- /** On a shared view: how far the reader has drifted from it, and Reset and Save for everyone. */
1433
+ /** On a saved view: how far the reader has drifted from it, and Reset and Save for everyone (Save on the reader's own). */
1399
1434
  view?: {
1400
1435
  changes: number;
1436
+ /** The view is this reader's own: its Save says `views.panels.view-save-own`. */
1437
+ own?: boolean;
1401
1438
  /** Everyone's view moved after the reader's changes began. */
1402
1439
  stale: boolean;
1403
1440
  /** The reader may set what they see as everyone's. */
@@ -1574,6 +1611,10 @@ export type ViewsComponents = {
1574
1611
  /** Required: the views list's whole body, which your app draws (`CONTROLS.ViewsListBody` is ViewKit's own). The view
1575
1612
  * picker's chip opens it on a computer and in the phone's Sheet, handed the views as data. */
1576
1613
  ViewsListBody: ComponentType<ViewsViewsListBodyProps>;
1614
+ /** Optional: one view's whole menu, which your app draws (`CONTROLS.ViewMenu` is ViewKit's own). A views row's pill and a
1615
+ * folded view's ⋮ open it where the axis hands `verbs`, and the row's + opens it with no `view`, on New view; left out, they
1616
+ * open the view's `menu` rows through `Menu`, and the + calls the axis's `onCreate`. */
1617
+ ViewMenu?: ComponentType<ViewsViewMenuProps>;
1577
1618
  /** @deprecated Read by nothing: only ViewKit's own Customize opened it, and that Customize is gone. A `CustomizeBody`
1578
1619
  * holds its own group editor, handed the group as `GroupBody` was (`ViewsCustomizeBodyProps.group`). */
1579
1620
  GroupBody?: ComponentType<ViewsGroupBodyProps>;
@@ -1596,7 +1637,7 @@ export type ViewsComponents = {
1596
1637
  /** The selection bar's props, as your `SelectionBar` is handed them: ViewKit's `SelectionBar`'s own. */
1597
1638
  export type ViewsSelectionBarProps = SelectionBarProps;
1598
1639
  /** The map as the views read it: `Input` and `Calendar` always filled, the app's or the
1599
- * package's own; `RowsWait`, `GroupBody`, `SearchField`, `PortsHost` and `SelectionBar` as the app handed them. */
1640
+ * package's own; `RowsWait`, `GroupBody`, `SearchField`, `PortsHost`, `SelectionBar` and `ViewMenu` as the app handed them. */
1600
1641
  export type ViewsResolvedComponents = ViewsComponents & {
1601
1642
  Input: ComponentType<ViewsInputProps>;
1602
1643
  Calendar: ComponentType<ViewsCalendarProps>;
@@ -13,7 +13,8 @@ export type ViewsContextValue = {
13
13
  components: ViewsResolvedComponents;
14
14
  atoms: ViewsAtoms;
15
15
  icons: ViewsIcons;
16
- /** The app's ports, with `confirm` always a function (the browser's where the app handed none). */
16
+ /** The app's ports, each one it left out filled with its default: `confirm` always a function (the browser's where
17
+ * nothing draws ViewKit's). */
17
18
  ports: ViewsResolvedPorts;
18
19
  /** No `confirm` of the app's and no `PortsHost` to draw ViewKit's: `ports.confirm` is the browser's own. A control that can ask
19
20
  * in a dialog of its own (a view's menu, VK-823) asks there instead. */
@@ -4,7 +4,7 @@ export const ViewsContext = createContext(null);
4
4
  export function useViews() {
5
5
  const value = useContext(ViewsContext);
6
6
  if (!value) {
7
- throw new Error("useViews() needs a <ViewsProvider> above it: mount one at the app's client root with its components, icons, ports and conventions.");
7
+ throw new Error("useViews() needs a <ViewsProvider> above it: mount one at the app's client root, <ViewsProvider components={CONTROLS}> at the least.");
8
8
  }
9
9
  return value;
10
10
  }
@@ -46,24 +46,31 @@ export type ViewsConfirmPort = (request: ViewsConfirmRequest) => Promise<boolean
46
46
  export type ViewsPorts = {
47
47
  /** What ViewKit reports. Absent: ViewKit's Toast where the components map hands `PortsHost` (CONTROLS does), else nothing. */
48
48
  toast?: ViewsToastPort;
49
- haptics: ViewsHapticsPort;
50
- clipboard: ViewsClipboardPort;
51
- viewPrefs: ViewsPrefsPort;
49
+ /** Absent: haptics that do nothing (`NO_HAPTICS`). */
50
+ haptics?: ViewsHapticsPort;
51
+ /** Absent: the browser's own clipboard (`browserClipboard`). */
52
+ clipboard?: ViewsClipboardPort;
53
+ /** Absent: a store on the browser's `localStorage`, at the package's own `vk:` keys (`localPrefs`). */
54
+ viewPrefs?: ViewsPrefsPort;
52
55
  /** Asks before a destructive act (a row's Delete). Absent: ViewKit's alert dialog where the components map hands
53
56
  * `PortsHost` (CONTROLS does), else the browser's own confirm with `message`. */
54
57
  confirm?: ViewsConfirmPort;
55
58
  };
56
- /** The ports as the provider hands them on: `toast` and `confirm` always there, `PortsHost`'s where the app handed none,
57
- * else a toast that draws nothing and the browser's confirm. */
58
- export type ViewsResolvedPorts = ViewsPorts & {
59
- toast: ViewsToastPort;
60
- confirm: ViewsConfirmPort;
61
- };
59
+ /** The ports as the provider hands them on, every one there: the app's own, else the default. `toast` and `confirm` are
60
+ * `PortsHost`'s where the app handed none, else a toast that draws nothing and the browser's confirm. */
61
+ export type ViewsResolvedPorts = Required<ViewsPorts>;
62
62
  /** The browser's own dialog, read when it is asked, so a server render never reaches `window`. */
63
63
  export declare const browserConfirm: ViewsConfirmPort;
64
64
  /** A toast that draws nothing: where an app hands none and nothing draws ViewKit's. */
65
65
  export declare const NOOP_TOAST: ViewsToastPort;
66
+ /** Haptics that do nothing: the default where an app hands none. */
67
+ export declare const NO_HAPTICS: ViewsHapticsPort;
68
+ /** The browser's own clipboard, the default where an app hands none: read when it is called, so a server render never
69
+ * reaches it; where the browser refuses or has none, a write resolves to false and a read to null. */
70
+ export declare const browserClipboard: ViewsClipboardPort;
71
+ /** The per-device store on the browser's `localStorage`, the default where an app hands none: each value as JSON at the
72
+ * package's own key (its `vk:` names). Read when it is called, never while the server renders; where storage is refused
73
+ * or there is no window, nothing is kept and nothing throws. */
74
+ export declare const localPrefs: ViewsPrefsPort;
66
75
  /** Ports that do nothing: a server render, a test, an app without a device. */
67
- export declare const NOOP_PORTS: ViewsPorts & {
68
- toast: ViewsToastPort;
69
- };
76
+ export declare const NOOP_PORTS: ViewsPorts & Required<Omit<ViewsPorts, "confirm">>;
@@ -2,9 +2,77 @@ export const browserConfirm = async ({ message }) => window.confirm(message);
2
2
  const _portsMatchContract = true;
3
3
  void _portsMatchContract;
4
4
  export const NOOP_TOAST = { success() { }, error() { }, info() { }, warning() { } };
5
+ export const NO_HAPTICS = { selection() { }, impact() { }, notification() { } };
6
+ export const browserClipboard = {
7
+ writeText: async (text) => {
8
+ try {
9
+ if (typeof navigator === "undefined" || !navigator.clipboard)
10
+ return false;
11
+ await navigator.clipboard.writeText(text);
12
+ return true;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ },
18
+ readText: async () => {
19
+ try {
20
+ if (typeof navigator === "undefined" || !navigator.clipboard)
21
+ return null;
22
+ return await navigator.clipboard.readText();
23
+ }
24
+ catch {
25
+ return null;
26
+ }
27
+ },
28
+ };
29
+ const prefListeners = new Map();
30
+ export const localPrefs = {
31
+ get: (key) => {
32
+ try {
33
+ if (typeof window === "undefined")
34
+ return undefined;
35
+ const stored = localStorage.getItem(key);
36
+ return stored == null ? undefined : JSON.parse(stored);
37
+ }
38
+ catch {
39
+ return undefined;
40
+ }
41
+ },
42
+ set: (key, value) => {
43
+ try {
44
+ if (typeof window === "undefined")
45
+ return;
46
+ localStorage.setItem(key, JSON.stringify(value));
47
+ }
48
+ catch {
49
+ return;
50
+ }
51
+ for (const listener of [...(prefListeners.get(key) ?? [])])
52
+ listener();
53
+ },
54
+ subscribe: (key, listener) => {
55
+ if (typeof window === "undefined")
56
+ return () => { };
57
+ const onStorage = (event) => {
58
+ if (event.key === key)
59
+ listener();
60
+ };
61
+ const listeners = prefListeners.get(key) ?? new Set();
62
+ listeners.add(listener);
63
+ prefListeners.set(key, listeners);
64
+ window.addEventListener("storage", onStorage);
65
+ return () => {
66
+ listeners.delete(listener);
67
+ if (listeners.size === 0)
68
+ prefListeners.delete(key);
69
+ window.removeEventListener("storage", onStorage);
70
+ };
71
+ },
72
+ };
5
73
  export const NOOP_PORTS = {
6
74
  toast: NOOP_TOAST,
7
- haptics: { selection() { }, impact() { }, notification() { } },
75
+ haptics: NO_HAPTICS,
8
76
  clipboard: { writeText: async () => false, readText: async () => null },
9
77
  viewPrefs: { get: () => undefined, set() { }, subscribe: () => () => { } },
10
78
  };
@@ -4,7 +4,7 @@ export type { EditEscape, EditEscapeByEditor, ViewsEscapeRules } from "./editors
4
4
  export type { ViewsOneValueEditors } from "./model/one-value.js";
5
5
  export { DEFAULT_DESKTOP_QUERY } from "./provider/desktop.js";
6
6
  export type { ViewsSeveralValues } from "./display/fit-values.js";
7
- export type { ViewsAlign, ViewsAnchor, ViewsBarPlacement, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsCustomizeBodyProps, ViewsCustomizeChoice, ViewsCustomizeColumn, ViewsCustomizeColumns, ViewsCustomizeField, ViewsCustomizeFields, ViewsCustomizeLayout, ViewsCustomizePage, ViewsCustomizeToggle, ViewsDateBodyProps, ViewsDatePick, ViewsDatePicks, ViewsInputProps, ViewsFieldsBodyField, ViewsFieldsBodyProps, ViewsFilterBodyField, ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsGroupBodyProps, ViewsGroupDimension, ViewsGroupEntry, ViewsGroupValue, ViewsMenuItem, ViewsMenuProps, ViewsNumberBodyProps, ViewsOpenChange, ViewsPartsBodyProps, ViewsPickerAction, ViewsPickerItem, ViewsPickerProps, ViewsLink, ViewsLinkRole, ViewsLinksBodyProps, ViewsPlacePart, ViewsPlaceParts, ViewsPopoverProps, ViewsPortsHostProps, ViewsSelectionBarProps, ViewsQuickFiltersBodyProps, ViewsResolvedComponents, ViewsRowsWaitProps, ViewsSearchFieldProps, ViewsSelectionBarSettings, ViewsSheetAction, ViewsSheetActions, ViewsBodyStep, ViewsSheetActionsPlace, ViewsSheetProps, ViewsSide, ViewsSortBodyProps, ViewsTextBodyProps, ViewsTooltipProps, ViewsValueLine, ViewsValuesBodyProps, ViewsViewsListBodyProps, ViewsViewsListItem, ViewsViewChange, ViewsViewLayout, ViewsViewRecord, ViewsViewVerbs, } from "./provider/components.js";
7
+ export type { ViewsAlign, ViewsAnchor, ViewsBarPlacement, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsCustomizeBodyProps, ViewsCustomizeChoice, ViewsCustomizeColumn, ViewsCustomizeColumns, ViewsCustomizeField, ViewsCustomizeFields, ViewsCustomizeLayout, ViewsCustomizePage, ViewsCustomizeToggle, ViewsDateBodyProps, ViewsDatePick, ViewsDatePicks, ViewsInputProps, ViewsFieldsBodyField, ViewsFieldsBodyProps, ViewsFilterBodyField, ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsGroupBodyProps, ViewsGroupDimension, ViewsGroupEntry, ViewsGroupValue, ViewsMenuItem, ViewsMenuProps, ViewsNumberBodyProps, ViewsOpenChange, ViewsPartsBodyProps, ViewsPickerAction, ViewsPickerItem, ViewsPickerProps, ViewsLink, ViewsLinkRole, ViewsLinksBodyProps, ViewsPlacePart, ViewsPlaceParts, ViewsPopoverProps, ViewsPortsHostProps, ViewsSelectionBarProps, ViewsQuickFiltersBodyProps, ViewsResolvedComponents, ViewsRowsWaitProps, ViewsSearchFieldProps, ViewsSelectionBarSettings, ViewsSheetAction, ViewsSheetActions, ViewsBodyStep, ViewsSheetActionsPlace, ViewsSheetProps, ViewsSide, ViewsSortBodyProps, ViewsTextBodyProps, ViewsTooltipProps, ViewsValueLine, ViewsValuesBodyProps, ViewsViewsListBodyProps, ViewsViewsListItem, ViewsViewChange, ViewsViewLayout, ViewsViewMenuProps, ViewsViewRecord, ViewsViewVerbs, } from "./provider/components.js";
8
8
  export type { ViewsIconProps, ViewsIcons } from "./provider/icons.js";
9
9
  export { NOOP_PORTS, NOOP_TOAST } from "./provider/ports.js";
10
10
  export type { ViewsClipboardPort, ViewsConfirmPort, ViewsConfirmRequest, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsResolvedPorts, ViewsToastPort, } from "./provider/ports.js";