viewkitjs 0.30.1 → 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 (298) hide show
  1. package/CHANGELOG.md +143 -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 +8 -2
  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 +10 -4
  45. package/views/dist/controls/avatar/avatar.js +5 -3
  46. package/views/dist/controls/avatar/tokens.d.ts +104 -0
  47. package/views/dist/controls/avatar/tokens.js +26 -0
  48. package/views/dist/controls/avatar.css +46 -15
  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 +4 -2
  63. package/views/dist/controls/index.js +3 -1
  64. package/views/dist/controls/input/input.d.ts +12 -1
  65. package/views/dist/controls/input/input.js +10 -6
  66. package/views/dist/controls/input/save-mark.d.ts +8 -0
  67. package/views/dist/controls/input/save-mark.js +26 -0
  68. package/views/dist/controls/input/tokens.d.ts +20 -0
  69. package/views/dist/controls/input/tokens.js +5 -0
  70. package/views/dist/controls/input.css +49 -3
  71. package/views/dist/controls/internal/icons.js +10 -0
  72. package/views/dist/controls/internal/keep-focus.d.ts +2 -0
  73. package/views/dist/controls/internal/keep-focus.js +17 -0
  74. package/views/dist/controls/internal/watch-frame.d.ts +2 -0
  75. package/views/dist/controls/internal/watch-frame.js +33 -0
  76. package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
  77. package/views/dist/controls/markdown/map-markdown.js +5 -0
  78. package/views/dist/controls/menu/map-menu.js +2 -2
  79. package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
  80. package/views/dist/controls/menu-list/menu-list.js +5 -4
  81. package/views/dist/controls/modal/modal.js +5 -1
  82. package/views/dist/controls/pane/pane.js +2 -1
  83. package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
  84. package/views/dist/controls/phone-header/header-bar.js +2 -2
  85. package/views/dist/controls/phone-header.css +11 -1
  86. package/views/dist/controls/picker/map-picker.js +3 -0
  87. package/views/dist/controls/picker/picker.d.ts +14 -0
  88. package/views/dist/controls/picker/picker.js +30 -10
  89. package/views/dist/controls/picker.css +2 -0
  90. package/views/dist/controls/popover/popover.js +2 -1
  91. package/views/dist/controls/radio/radio.d.ts +12 -3
  92. package/views/dist/controls/radio/radio.js +25 -5
  93. package/views/dist/controls/radio/tokens.d.ts +84 -0
  94. package/views/dist/controls/radio/tokens.js +21 -0
  95. package/views/dist/controls/radio.css +130 -3
  96. package/views/dist/controls/select/select.d.ts +12 -2
  97. package/views/dist/controls/select/select.js +15 -7
  98. package/views/dist/controls/select/tokens.d.ts +8 -0
  99. package/views/dist/controls/select/tokens.js +2 -0
  100. package/views/dist/controls/select.css +17 -0
  101. package/views/dist/controls/setting-row/looks.d.ts +10 -0
  102. package/views/dist/controls/setting-row/looks.js +22 -0
  103. package/views/dist/controls/setting-row/setting-row.d.ts +100 -0
  104. package/views/dist/controls/setting-row/setting-row.js +133 -0
  105. package/views/dist/controls/setting-row/tokens.d.ts +156 -0
  106. package/views/dist/controls/setting-row/tokens.js +41 -0
  107. package/views/dist/controls/setting-row.css +215 -0
  108. package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
  109. package/views/dist/controls/sheet/bottom-sheet.js +6 -3
  110. package/views/dist/controls/sheet.css +4 -1
  111. package/views/dist/controls/sort-editor/sort-editor.js +3 -2
  112. package/views/dist/controls/sort-editor.css +8 -2
  113. package/views/dist/controls/switch-row/switch-row.d.ts +1 -15
  114. package/views/dist/controls/switch-row/switch-row.js +1 -9
  115. package/views/dist/controls/switch-row/tokens.d.ts +0 -12
  116. package/views/dist/controls/switch-row/tokens.js +0 -3
  117. package/views/dist/controls/switch-row.css +3 -7
  118. package/views/dist/controls/switch.css +17 -7
  119. package/views/dist/controls/tag/tag.d.ts +3 -1
  120. package/views/dist/controls/tag/tag.js +2 -2
  121. package/views/dist/controls/tag/tokens.d.ts +4 -0
  122. package/views/dist/controls/tag/tokens.js +1 -0
  123. package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
  124. package/views/dist/controls/tag-field/tag-field.js +11 -5
  125. package/views/dist/controls/tag-field/tokens.d.ts +16 -0
  126. package/views/dist/controls/tag-field/tokens.js +4 -0
  127. package/views/dist/controls/tag-field.css +19 -0
  128. package/views/dist/controls/tag.css +2 -0
  129. package/views/dist/controls/tokens.js +2 -0
  130. package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
  131. package/views/dist/controls/toolbar/toolbar.js +22 -15
  132. package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
  133. package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
  134. package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
  135. package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
  136. package/views/dist/controls/toolbar-button.css +4 -0
  137. package/views/dist/controls/toolbar.css +5 -0
  138. package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
  139. package/views/dist/controls/views-list/map-view-menu.js +25 -0
  140. package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
  141. package/views/dist/controls/views-list/map-views-list-body.js +39 -21
  142. package/views/dist/controls/views-list/rules.d.ts +2 -0
  143. package/views/dist/controls/views-list/view-menu.d.ts +7 -0
  144. package/views/dist/controls/views-list/view-menu.js +28 -24
  145. package/views/dist/controls/views-list/words.d.ts +2 -0
  146. package/views/dist/controls/views-list/words.js +1 -1
  147. package/views/dist/editors/EditorPanel.js +2 -1
  148. package/views/dist/editors/edit-session.js +2 -5
  149. package/views/dist/field-row/FieldRow.d.ts +4 -2
  150. package/views/dist/field-row/FieldRow.js +67 -20
  151. package/views/dist/field-row/FieldRowLane.d.ts +7 -2
  152. package/views/dist/field-row/FieldRowLane.js +4 -3
  153. package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
  154. package/views/dist/field-row/editors/RowEditor.js +31 -1
  155. package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
  156. package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
  157. package/views/dist/field-row/field-row-button.d.ts +5 -0
  158. package/views/dist/field-row/field-row-button.js +2 -0
  159. package/views/dist/fields/binding.d.ts +3 -2
  160. package/views/dist/fields/binding.js +38 -5
  161. package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
  162. package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
  163. package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
  164. package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
  165. package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
  166. package/views/dist/grid/chrome/GridHeader.js +2 -2
  167. package/views/dist/grid/chrome/GridRow.js +6 -5
  168. package/views/dist/grid/chrome/GridRowCells.js +6 -9
  169. package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
  170. package/views/dist/grid/chrome/GridStructure.js +4 -4
  171. package/views/dist/grid/chrome/GridTable.js +5 -2
  172. package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
  173. package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
  174. package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
  175. package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
  176. package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
  177. package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
  178. package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
  179. package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
  180. package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
  181. package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
  182. package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
  183. package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
  184. package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
  185. package/views/dist/grid/core/commit-model.d.ts +20 -2
  186. package/views/dist/grid/core/editing-controller.d.ts +18 -0
  187. package/views/dist/grid/core/editing-controller.js +188 -42
  188. package/views/dist/grid/core/editing-model.d.ts +3 -0
  189. package/views/dist/grid/core/editing-model.js +3 -0
  190. package/views/dist/grid/core/save-path.d.ts +24 -0
  191. package/views/dist/grid/core/save-path.js +122 -0
  192. package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
  193. package/views/dist/grid/core/spreadsheet-operations.js +23 -0
  194. package/views/dist/grid/index.d.ts +3 -2
  195. package/views/dist/grid/index.js +1 -0
  196. package/views/dist/internal/field-rows.d.ts +26 -0
  197. package/views/dist/internal/field-rows.js +8 -0
  198. package/views/dist/internal/page-close.d.ts +7 -0
  199. package/views/dist/internal/page-close.js +43 -0
  200. package/views/dist/list/browser-views-store.d.ts +10 -0
  201. package/views/dist/list/browser-views-store.js +182 -0
  202. package/views/dist/list/index.d.ts +23 -0
  203. package/views/dist/list/index.js +8 -0
  204. package/views/dist/list/menu.d.ts +31 -0
  205. package/views/dist/list/menu.js +76 -0
  206. package/views/dist/list/parts.d.ts +6 -0
  207. package/views/dist/list/parts.js +59 -0
  208. package/views/dist/list/registry.d.ts +11 -0
  209. package/views/dist/list/registry.js +31 -0
  210. package/views/dist/list/root.d.ts +40 -0
  211. package/views/dist/list/root.js +128 -0
  212. package/views/dist/list/slot.d.ts +14 -0
  213. package/views/dist/list/slot.js +22 -0
  214. package/views/dist/list/source.d.ts +11 -0
  215. package/views/dist/list/source.js +31 -0
  216. package/views/dist/list/store.d.ts +87 -0
  217. package/views/dist/list/store.js +115 -0
  218. package/views/dist/list/toolbar.d.ts +6 -0
  219. package/views/dist/list/toolbar.js +359 -0
  220. package/views/dist/list/views-axis.d.ts +5 -0
  221. package/views/dist/list/views-axis.js +96 -0
  222. package/views/dist/list/views-store.d.ts +41 -0
  223. package/views/dist/list/views-store.js +1 -0
  224. package/views/dist/list/views.d.ts +67 -0
  225. package/views/dist/list/views.js +400 -0
  226. package/views/dist/looks/index.d.ts +1 -0
  227. package/views/dist/looks/index.js +1 -0
  228. package/views/dist/looks/pieces.js +2 -0
  229. package/views/dist/model/preferences.js +1 -1
  230. package/views/dist/model/prefs-buckets.js +1 -1
  231. package/views/dist/panels/index.d.ts +3 -1
  232. package/views/dist/panels/index.js +1 -0
  233. package/views/dist/panels/react/customize-body.js +1 -0
  234. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
  235. package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
  236. package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
  237. package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
  238. package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
  239. package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
  240. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
  241. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
  242. package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
  243. package/views/dist/panels/react/toolbar/context.d.ts +10 -2
  244. package/views/dist/panels/react/toolbar/context.js +3 -1
  245. package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
  246. package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
  247. package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
  248. package/views/dist/panels/react/views-row/PillGroup.js +16 -7
  249. package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
  250. package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
  251. package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
  252. package/views/dist/panels/react.d.ts +2 -2
  253. package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
  254. package/views/dist/panels/toolbar/edit-view.js +14 -0
  255. package/views/dist/panels/toolbar/model.d.ts +5 -0
  256. package/views/dist/panels/toolbar/model.js +7 -3
  257. package/views/dist/panels/view-state.d.ts +5 -3
  258. package/views/dist/panels/views-row/model.d.ts +19 -2
  259. package/views/dist/panels/views-row/model.js +14 -0
  260. package/views/dist/provider/ViewsProvider.d.ts +16 -7
  261. package/views/dist/provider/ViewsProvider.js +23 -5
  262. package/views/dist/provider/components.d.ts +43 -2
  263. package/views/dist/provider/context.d.ts +2 -1
  264. package/views/dist/provider/context.js +1 -1
  265. package/views/dist/provider/ports.d.ts +19 -12
  266. package/views/dist/provider/ports.js +69 -1
  267. package/views/dist/react.d.ts +1 -1
  268. package/views/dist/styles.css +583 -61
  269. package/views/dist/styles.unlayered.css +583 -61
  270. package/views/docs/contract.md +42 -31
  271. package/views/docs/controls/avatar.md +26 -0
  272. package/views/docs/controls/choice.md +0 -1
  273. package/views/docs/controls/field.md +3 -0
  274. package/views/docs/controls/input.md +9 -0
  275. package/views/docs/controls/radio.md +33 -0
  276. package/views/docs/controls/select.md +6 -0
  277. package/views/docs/controls/setting-row.md +44 -0
  278. package/views/docs/controls/switch-row.md +0 -3
  279. package/views/docs/controls/tag-field.md +4 -0
  280. package/views/docs/controls/tag.md +1 -0
  281. package/views/docs/getting-started.md +2 -2
  282. package/views/docs/guides/atoms.md +2 -2
  283. package/views/docs/guides/columns.md +1 -1
  284. package/views/docs/guides/ports.md +1 -1
  285. package/views/docs/guides/the-grid.md +34 -7
  286. package/views/docs/guides/the-provider.md +4 -2
  287. package/views/docs/index.md +1 -0
  288. package/views/docs/reference/controls.md +54 -27
  289. package/views/docs/reference/editors-session.md +1 -1
  290. package/views/docs/reference/field-row.md +9 -1
  291. package/views/docs/reference/grid.md +14 -8
  292. package/views/docs/reference/list.md +227 -0
  293. package/views/docs/reference/looks.md +3 -0
  294. package/views/docs/reference/panels-react.md +17 -12
  295. package/views/docs/reference/panels.md +8 -5
  296. package/views/docs/reference/react.md +11 -9
  297. package/views/docs/reference/views.md +2 -2
  298. package/views/skills/views/SKILL.md +9 -6
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
4
4
  import { useViews } from "../../../provider/context.js";
5
5
  import { formatCount } from "../../../internal/count.js";
6
6
  import { drawPanelButton, PanelButton } from "../../panel-button.js";
7
7
  import { VIEWS_LIST_CLASS } from "./menu-classes.js";
8
+ import { viewsListItemsOf } from "../../views-row/model.js";
8
9
  import { PillGroup } from "./PillGroup.js";
9
10
  import { useAnchoredToggle } from "./use-anchored-toggle.js";
10
11
  import { ToolbarButton } from "../toolbar/ToolbarButton.js";
@@ -20,6 +21,10 @@ export function FoldingViewRow({ axis, folded: told }) {
20
21
  const words = usePillWords(axis.hideCounts);
21
22
  const inFrame = useViewsRowInFrame();
22
23
  const pills = useMemo(() => toPillOptions(axis.options, words), [axis.options, words]);
24
+ const viewMenu = useMemo(() => (axis.verbs && views.components.ViewMenu ? { views: viewsListItemsOf(axis), value: axis.value, verbs: axis.verbs } : undefined), [axis, views.components.ViewMenu]);
25
+ const [creating, setCreating] = useState(0);
26
+ const ViewMenu = views.components.ViewMenu;
27
+ const newView = viewMenu && ViewMenu ? { ViewMenu, menu: viewMenu } : undefined;
23
28
  const isTold = told !== undefined;
24
29
  useLayoutEffect(() => {
25
30
  const host = hostRef.current;
@@ -89,7 +94,7 @@ export function FoldingViewRow({ axis, folded: told }) {
89
94
  const ordered = pills.filter(inBlock).map((pill) => (visibleValues.has(pill.value) ? dealt.shift() : pill.value));
90
95
  axis.onReorder(ordered);
91
96
  };
92
- return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: axis.onCreate }), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
97
+ return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }), axis.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView ? () => setCreating((n) => n + 1) : axis.onCreate }), newView && creating > 0 && (_jsx(newView.ViewMenu, { open: true, onOpenChange: keepOpen, anchor: hostRef, views: newView.menu.views, value: newView.menu.value, verbs: newView.menu.verbs }, creating)), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
93
98
  frame: MORE_CHIP_FRAME,
94
99
  variant: "ghost",
95
100
  size: "sm",
@@ -97,6 +102,7 @@ export function FoldingViewRow({ axis, folded: told }) {
97
102
  children: moreChipInner(views, 99),
98
103
  }) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
99
104
  }
105
+ const keepOpen = () => { };
100
106
  const MORE_CHIP_FRAME = "h-8 shrink-0 gap-0.5 whitespace-nowrap px-2.5";
101
107
  function moreChipInner({ conventions, icons }, count) {
102
108
  const Chevron = icons.chevronDown;
@@ -106,13 +112,18 @@ function MoreButton({ count, ref, open, onPointerDown, onClick, }) {
106
112
  const { conventions, messages } = useViews();
107
113
  return (_jsxs(ToolbarButton, { ref: ref, icon: null, label: messages({ key: "views.panels.views-more", values: { count } }), part: "views-more", popup: "dialog", open: Boolean(open), onPointerDown: onPointerDown, onClick: onClick, children: ["+", formatCount(count, conventions)] }));
108
114
  }
109
- function FoldedViews({ axis, options, }) {
115
+ function FoldedViews({ axis, options, viewMenu, }) {
110
116
  const views = useViews();
111
117
  const { components, messages } = views;
112
118
  const { Popover } = components;
113
119
  const anchor = useRef(null);
114
120
  const toggle = useAnchoredToggle(anchor);
115
121
  const inFrame = useViewsRowInFrame();
122
+ const holding = useRef(false);
123
+ const onHold = useCallback((on) => {
124
+ holding.current = on;
125
+ }, []);
126
+ const rowMenu = viewMenu && { ...viewMenu, onDone: toggle.close, onHold };
116
127
  return (_jsxs(_Fragment, { children: [inFrame ? (_jsx(MoreButton, { count: options.length, ref: anchor, open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick })) : (_jsx(PanelButton, { views: views, draw: {
117
128
  frame: MORE_CHIP_FRAME,
118
129
  variant: "ghost",
@@ -126,7 +137,7 @@ function FoldedViews({ axis, options, }) {
126
137
  onPointerDown: toggle.triggerProps.onPointerDown,
127
138
  onClick: toggle.triggerProps.onClick,
128
139
  children: moreChipInner(views, options.length),
129
- } })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-64", children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, onSelect: () => {
140
+ } })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-64", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, viewMenu: rowMenu, onSelect: () => {
130
141
  axis.onChange(option.value);
131
142
  toggle.close();
132
143
  } }, option.value))) }) })] }));
@@ -1,4 +1,4 @@
1
- import type { PillOption } from "../../views-row/model.js";
1
+ import type { PillOption, PillViewMenu } from "../../views-row/model.js";
2
2
  /** Which look a pill row wears. See the `variant` prop below. */
3
3
  type PillVariant = "solid" | "plain";
4
4
  type PillGroupProps<T extends string = string> = {
@@ -25,6 +25,9 @@ type PillGroupProps<T extends string = string> = {
25
25
  onReorder?: (orderedValues: T[]) => void;
26
26
  /** Which pills may be picked up. Default: all of them, once `onReorder` is set. */
27
27
  canDrag?: (value: T) => boolean;
28
+ /** A view's whole menu (VK-947): where your map draws `ViewMenu`, every pill opens it for its view, as its `menu` rows open,
29
+ * in their place. Left out, or with no `ViewMenu`, a pill's menu is its `menu` rows. */
30
+ viewMenu?: PillViewMenu;
28
31
  };
29
- export declare function PillGroup<T extends string = string>({ value, options, onChange, className, size, variant, onReorder, canDrag, }: PillGroupProps<T>): import("react/jsx-runtime").JSX.Element;
32
+ export declare function PillGroup<T extends string = string>({ value, options, onChange, className, size, variant, onReorder, canDrag, viewMenu: handedMenu, }: PillGroupProps<T>): import("react/jsx-runtime").JSX.Element;
30
33
  export {};
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
- import { useRef } from "react";
3
+ import { useRef, useState } from "react";
4
4
  import { cx } from "../../../internal/cx.js";
5
5
  import { useViews } from "../../../provider/context.js";
6
6
  import { useDesktop } from "../../../provider/desktop.js";
@@ -8,8 +8,9 @@ import { moveItem, SortableFrame, useDragKit, useDragSensors, useSortableItem }
8
8
  import { ToolbarButton } from "../toolbar/ToolbarButton.js";
9
9
  import { useViewsRowInFrame } from "./in-frame.js";
10
10
  import { useAnchoredToggle } from "./use-anchored-toggle.js";
11
- export function PillGroup({ value, options, onChange, className, size = "default", variant = "solid", onReorder, canDrag, }) {
12
- const { icons, messages } = useViews();
11
+ export function PillGroup({ value, options, onChange, className, size = "default", variant = "solid", onReorder, canDrag, viewMenu: handedMenu, }) {
12
+ const { icons, messages, components } = useViews();
13
+ const viewMenu = components.ViewMenu ? handedMenu : undefined;
13
14
  const Lock = icons.lock;
14
15
  const plain = variant === "plain";
15
16
  const dressed = plain && size !== "sm";
@@ -37,6 +38,8 @@ export function PillGroup({ value, options, onChange, className, size = "default
37
38
  const shared = {
38
39
  active,
39
40
  menu,
41
+ viewMenu,
42
+ view: option.value,
40
43
  label: option.label,
41
44
  onSelect: () => onChange(option.value),
42
45
  variant,
@@ -50,12 +53,16 @@ export function PillGroup({ value, options, onChange, className, size = "default
50
53
  return row;
51
54
  return (_jsx(SortableFrame, { kit: kit, sensors: sensors, items: options.map((option) => option.value), axis: "x", onDragEnd: handleDragEnd, nameOf: (value) => options.find((option) => option.value === value)?.label ?? value, children: row }));
52
55
  }
53
- function Pill({ menu, label, onSelect, children, ...pill }) {
56
+ function Pill({ menu: rows, viewMenu, view, label, onSelect, children, ...pill }) {
54
57
  const { atoms, components } = useViews();
55
- const { Menu } = components;
58
+ const { Menu, ViewMenu } = components;
56
59
  const anchor = useRef(null);
57
60
  const toggle = useAnchoredToggle(anchor);
58
61
  const inFrame = useViewsRowInFrame();
62
+ const menu = Boolean(rows || viewMenu);
63
+ const [kept, setKept] = useState(false);
64
+ if (toggle.open && !kept)
65
+ setKept(true);
59
66
  const trigger = menu && pill.active;
60
67
  const onContextMenu = menu
61
68
  ? (event) => {
@@ -64,9 +71,11 @@ function Pill({ menu, label, onSelect, children, ...pill }) {
64
71
  }
65
72
  : undefined;
66
73
  const button = inFrame ? (_jsx(ToolbarButton, { ref: anchor, icon: pill.leading ?? null, label: label, current: pill.active, part: "views-tab", size: pill.size === "sm" ? "sm" : undefined, popup: trigger ? "menu" : undefined, open: trigger ? toggle.open : undefined, onPointerDown: trigger ? toggle.triggerProps.onPointerDown : undefined, onClick: trigger ? toggle.triggerProps.onClick : onSelect, onContextMenu: onContextMenu, children: children })) : (_jsx(atoms.Pill, { ...pill, ref: anchor, menuOpen: trigger ? toggle.open : undefined, onPointerDown: trigger ? toggle.triggerProps.onPointerDown : undefined, onClick: trigger ? toggle.triggerProps.onClick : onSelect, onContextMenu: onContextMenu, children: children }));
67
- if (!menu)
74
+ if (viewMenu && ViewMenu)
75
+ return (_jsxs(_Fragment, { children: [button, (toggle.open || kept) && (_jsx(ViewMenu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", view: view, views: viewMenu.views, value: viewMenu.value, verbs: viewMenu.verbs, ...(viewMenu.onDone && { onDone: viewMenu.onDone }), ...(viewMenu.onHold && { onHold: viewMenu.onHold }) }))] }));
76
+ if (!rows)
68
77
  return button;
69
- return (_jsxs(_Fragment, { children: [button, _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", label: label, items: menu })] }));
78
+ return (_jsxs(_Fragment, { children: [button, _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", label: label, items: rows })] }));
70
79
  }
71
80
  function SortablePill({ id, draggable, leading, children, ...pill }) {
72
81
  const { icons, messages } = useViews();
@@ -4,7 +4,7 @@ import { useCallback, useRef } from "react";
4
4
  import { cx } from "../../../internal/cx.js";
5
5
  import { useViews } from "../../../provider/context.js";
6
6
  import { formatCount } from "../../../internal/count.js";
7
- import { viewsListOrderFits, viewsListPickFits, } from "../../views-row/model.js";
7
+ import { viewsListItemsOf, viewsListOrderFits, viewsListPickFits, } from "../../views-row/model.js";
8
8
  import { PanelButton } from "../../panel-button.js";
9
9
  import { PanelSheet, useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
10
10
  import { usePanelStep } from "../panel-step.js";
@@ -36,17 +36,7 @@ export function ViewPicker({ axis, className }) {
36
36
  const { onCreate, onReorder } = axis;
37
37
  const listLabel = messages({ key: "views.panels.views-list" });
38
38
  const createLabel = axis.createLabel ?? messages({ key: "views.panels.view-create" });
39
- const list = (_jsx(ViewsListBody, { label: listLabel, views: axis.options.map((option) => ({
40
- value: option.value,
41
- label: option.label,
42
- ...(option.icon !== undefined && { icon: option.icon }),
43
- ...(!axis.hideCounts && typeof option.count === "number" && { count: option.count }),
44
- ...(option.private !== undefined && { private: option.private }),
45
- ...(option.menu !== undefined && { menu: option.menu }),
46
- ...(option.layout !== undefined && { layout: option.layout }),
47
- ...(option.changed !== undefined && { changed: option.changed }),
48
- ...(option.favorite !== undefined && { favorite: option.favorite }),
49
- })), ...(axis.verbs && { verbs: axis.verbs }), ...(sheet ? { onStepChange: step.onStepChange } : { onHold }), value: axis.value, form: sheet ? "phone" : "computer", onViewChange: (value) => {
39
+ const list = (_jsx(ViewsListBody, { label: listLabel, views: viewsListItemsOf(axis), ...(axis.verbs && { verbs: axis.verbs }), ...(sheet ? { onStepChange: step.onStepChange } : { onHold }), value: axis.value, form: sheet ? "phone" : "computer", onViewChange: (value) => {
50
40
  if (viewsListPickFits(axis.options, value))
51
41
  axis.onChange(value);
52
42
  }, ...(onCreate && {
@@ -1,7 +1,9 @@
1
- import type { ViewTabOption } from "../../views-row/model.js";
2
- export declare function ViewPickerRow({ option, active, onSelect, hideCounts, }: {
1
+ import type { PillViewMenu, ViewTabOption } from "../../views-row/model.js";
2
+ export declare function ViewPickerRow({ option, active, onSelect, hideCounts, viewMenu: handedMenu, }: {
3
3
  option: ViewTabOption<string>;
4
4
  active: boolean;
5
5
  onSelect: () => void;
6
6
  hideCounts?: boolean;
7
+ /** The view's whole menu (VK-947), through your `ViewMenu` where your map draws one, in place of `option.menu`. */
8
+ viewMenu?: PillViewMenu;
7
9
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,21 +1,25 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { useRef } from "react";
3
+ import { useRef, useState } from "react";
4
4
  import { cx } from "../../../internal/cx.js";
5
5
  import { useViews } from "../../../provider/context.js";
6
6
  import { useDesktop } from "../../../provider/desktop.js";
7
7
  import { formatCount } from "../../../internal/count.js";
8
8
  import { drawPanelButton } from "../../panel-button.js";
9
9
  import { useAnchoredToggle } from "./use-anchored-toggle.js";
10
- export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
10
+ export function ViewPickerRow({ option, active, onSelect, hideCounts, viewMenu: handedMenu, }) {
11
11
  const views = useViews();
12
12
  const { components, conventions, icons, messages } = views;
13
13
  const desktop = useDesktop();
14
- const { AppIcon, Menu } = components;
14
+ const { AppIcon, Menu, ViewMenu } = components;
15
+ const viewMenu = ViewMenu ? handedMenu : undefined;
15
16
  const Lock = icons.lock;
16
17
  const More = icons.moreVertical;
17
18
  const anchor = useRef(null);
18
19
  const toggle = useAnchoredToggle(anchor);
20
+ const [kept, setKept] = useState(false);
21
+ if (toggle.open && !kept)
22
+ setKept(true);
19
23
  const count = !hideCounts && typeof option.count === "number" ? option.count : null;
20
24
  return (_jsxs("div", { className: cx("group flex items-center rounded-lg transition-colors", active ? "bg-(color:--vk-neutral)" : "hover:bg-(color:--vk-hovered)"), children: [drawPanelButton(views, {
21
25
  frame: "h-8 min-w-0 flex-1 justify-start gap-2.5 px-2 text-left text-sm font-normal",
@@ -25,7 +29,7 @@ export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
25
29
  "aria-selected": active,
26
30
  onClick: onSelect,
27
31
  children: (_jsxs(_Fragment, { children: [option.icon && (_jsx(AppIcon, { name: option.icon, className: cx("h-4 w-4 shrink-0", active ? "text-(color:--vk-fg)" : "text-(color:--vk-fg-subtle)") })), _jsx("span", { className: cx("min-w-0 flex-1 truncate", active && "[-webkit-text-stroke:var(--vk-selected-stroke,0.4px)_currentColor]"), children: option.label }), option.private && _jsx(Lock, { className: "h-3 w-3 shrink-0 text-(color:--vk-fg-subtle) opacity-70" }), count !== null && _jsx("span", { className: "shrink-0 text-xs tabular-nums text-(color:--vk-fg-subtle)", children: formatCount(count, conventions) })] })),
28
- }), option.menu?.length ? (_jsxs(_Fragment, { children: [drawPanelButton(views, {
32
+ }), viewMenu || option.menu?.length ? (_jsxs(_Fragment, { children: [drawPanelButton(views, {
29
33
  frame: "h-6 w-6",
30
34
  variant: "ghost",
31
35
  size: "icon",
@@ -41,5 +45,5 @@ export function ViewPickerRow({ option, active, onSelect, hideCounts, }) {
41
45
  classes: "mr-1 inline-flex shrink-0 transition-opacity data-desktop:opacity-0 data-desktop:group-hover:opacity-100 data-desktop:group-focus-within:opacity-100 data-desktop:data-[state=open]:opacity-100",
42
46
  },
43
47
  children: _jsx(More, { className: "h-3.5 w-3.5" }),
44
- }), _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", label: option.label, items: option.menu })] })) : null] }));
48
+ }), viewMenu && ViewMenu ? ((toggle.open || kept) && (_jsx(ViewMenu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", view: option.value, views: viewMenu.views, value: viewMenu.value, verbs: viewMenu.verbs, ...(viewMenu.onDone && { onDone: viewMenu.onDone }), ...(viewMenu.onHold && { onHold: viewMenu.onHold }) }))) : (_jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "end", label: option.label, items: option.menu ?? [] }))] })) : null] }));
45
49
  }
@@ -27,7 +27,7 @@ export { ViewOptionsActions } from "./react/view-actions.js";
27
27
  export { ViewOptionsPopoverPanel, keepPanelOpenForPortals, useViewActivePanel, useViewOptionsPopover, viewOptionsPopoverClassName, } from "./react/popover.js";
28
28
  export type { ViewOptionsPopoverState } from "./react/popover.js";
29
29
  export { Toolbar, ToolbarSeparator } from "./react/toolbar/Toolbar.js";
30
- export type { ToolbarPart } from "./react/toolbar/Toolbar.js";
30
+ export type { ToolbarMore, ToolbarPart } from "./react/toolbar/Toolbar.js";
31
31
  export { ToolbarButton } from "./react/toolbar/ToolbarButton.js";
32
32
  export { useToolbarPanel, useToolbarSlot } from "./react/toolbar/context.js";
33
33
  export { ToolbarRadioProvider, ToolbarSlotProvider } from "./react/toolbar/context.js";
@@ -57,5 +57,5 @@ export type { ToolbarPanelState } from "./react/toolbar/panel-state.js";
57
57
  export { FilterPanelContent } from "./react/filter-panel.js";
58
58
  export { ToolbarSave } from "./react/toolbar/ToolbarSave.js";
59
59
  export { ReadyToolbar } from "./react/toolbar/ReadyToolbar.js";
60
- export type { ReadyToolbarProps } from "./react/toolbar/ReadyToolbar.js";
60
+ export type { ReadyToolbarProps, ToolbarMenus, ToolbarPartPlace, ToolbarParts, ToolbarPartsContext } from "./react/toolbar/ReadyToolbar.js";
61
61
  export { useListSettingsState } from "./react/toolbar/use-list-settings-state.js";
@@ -1,5 +1,11 @@
1
- import type { ViewsMenuItem } from "../../provider/components.js";
1
+ import type { ViewsMenuItem, ViewsViewVerbs } from "../../provider/components.js";
2
2
  import type { CollectionViewsInput } from "../views-row/model.js";
3
3
  /** `item` at the head of the active option's menu on every axis whose active option has one; an axis whose active
4
4
  * view has no verbs gains none. One config in, one config out; an array, an array. */
5
5
  export declare function withEditView<V extends string>(views: CollectionViewsInput<V> | undefined, item: ViewsMenuItem): CollectionViewsInput<V> | undefined;
6
+ /** A view's menu as data (VK-741): handed its items and the view, it hands back the items drawn. */
7
+ export type ViewMenuFn = NonNullable<ViewsViewVerbs["menu"]>;
8
+ /** `fn` over every view's menu on every axis: each option's own rows (Edit view… among them, once `withEditView` added it),
9
+ * handed the option as the view, and the menu a views list draws from an axis's verbs (`verbs.menu`). One config in, one
10
+ * config out; without `fn`, what it was handed. */
11
+ export declare function withViewMenu<V extends string>(views: CollectionViewsInput<V> | undefined, fn: ViewMenuFn | undefined): CollectionViewsInput<V> | undefined;
@@ -16,3 +16,17 @@ export function withEditView(views, item) {
16
16
  return views.map((axis) => onAxis(axis, item));
17
17
  return onAxis(views, item);
18
18
  }
19
+ function menuOnAxis(axis, fn) {
20
+ return {
21
+ ...axis,
22
+ options: axis.options.map((option) => (option.menu ? { ...option, menu: fn(option.menu, { view: option }) } : option)),
23
+ ...(axis.verbs ? { verbs: { ...axis.verbs, menu: fn } } : {}),
24
+ };
25
+ }
26
+ export function withViewMenu(views, fn) {
27
+ if (!views || !fn)
28
+ return views;
29
+ if (Array.isArray(views))
30
+ return views.map((axis) => menuOnAxis(axis, fn));
31
+ return menuOnAxis(views, fn);
32
+ }
@@ -16,6 +16,11 @@ export type ToolbarPlacement = {
16
16
  filters?: number;
17
17
  /** In the fold arrangement, it may fold into ⋯ when its line still has no room. */
18
18
  fold?: boolean;
19
+ /** Its words, for a part whose button has a word (VK-967): `both`, as the look's words say (icon and word where they show);
20
+ * `icon`, its icon alone whatever the look. Absent, the part's own. */
21
+ words?: "both" | "icon";
22
+ /** On a phone's folding line New stands at the list's foot, unless `false` keeps it on the line (VK-967). */
23
+ foot?: boolean;
19
24
  };
20
25
  /** One part in a line. `fill` is a part that takes the line's room (the search, as a field). The fold
21
26
  * arrangement alone sets the rest, each only where it holds: `shed`, `tabs`, `filters` and `fold` as placed, and
@@ -27,10 +27,14 @@ function arrangeFolding(parts, form) {
27
27
  const on = (line, side) => parts.filter((part) => onLine(part) === line && sideOf(part) === side).map(foldSlot);
28
28
  if (form === "phone") {
29
29
  const rowStart = on(1, "start");
30
- const viewsSlot = rowStart.filter((slot) => slot.key === "views");
31
- const rest = rowStart.filter((slot) => slot.key !== "views");
30
+ const after = rowStart.findIndex((slot) => slot.key === "views") + 1;
32
31
  return kept([
33
- { kind: "main", start: [...viewsSlot, ...on(2, "start"), ...rest], end: [...on(1, "end"), ...on(2, "end")], size: "md" },
32
+ {
33
+ kind: "main",
34
+ start: [...rowStart.slice(0, after), ...on(2, "start"), ...rowStart.slice(after)],
35
+ end: [...on(1, "end"), ...on(2, "end")],
36
+ size: "md",
37
+ },
34
38
  ]);
35
39
  }
36
40
  return kept([
@@ -2,12 +2,12 @@
2
2
  * THE VIEW AS A THING SHARED WITH OTHERS — how far what this person sees has
3
3
  * drifted from it, and the two verbs that settle the drift.
4
4
  *
5
- * Present only on a list showing a SHARED saved view. When it is, the
5
+ * Present on a list showing a saved view: everyone's (shared) or, with `own`, the reader's own. When it is, the
6
6
  * Customize trigger's badge counts `changes` (dimensions that differ from
7
7
  * everyone's view — Linear's dot, with a number) instead of "active filters",
8
8
  * its ✕ is `onReset`, and the panel's footer carries Reset · Set default for
9
- * everyone. A personal view or a list with no saved view passes nothing and
10
- * keeps the active-options count: there is no "everyone's" to differ from.
9
+ * everyone (Save, on the reader's own view). A list with no saved view passes
10
+ * nothing and keeps the active-options count: there is nothing to differ from.
11
11
  *
12
12
  * Its own module rather than a block in `model.ts`: the model is the toolbar's
13
13
  * dimension vocabulary (filters, sort, group…) and is at its size ceiling;
@@ -16,6 +16,8 @@
16
16
  export type CollectionViewState = {
17
17
  /** Dimensions in which what you see differs from the shared view. */
18
18
  changes: number;
19
+ /** The view is this reader's own: its Save says `views.panels.view-save-own` ("Save"), not Save for everyone. */
20
+ own?: boolean;
19
21
  /** Everyone's view moved after this person's edits were seeded from it. */
20
22
  stale: boolean;
21
23
  /** Owner or admin — may set what they see as everyone's. */
@@ -1,6 +1,6 @@
1
1
  import type { StatusSlot } from "viewkitjs/fields/design/status-slots";
2
2
  import type { ReactNode } from "react";
3
- import type { ViewsMenuItem, ViewsViewVerbs } from "../../provider/components.js";
3
+ import type { ViewsMenuItem, ViewsViewsListItem, ViewsViewVerbs } from "../../provider/components.js";
4
4
  export type ViewTabOption<V extends string> = {
5
5
  value: V;
6
6
  label: string;
@@ -26,10 +26,12 @@ export type ViewTabOption<V extends string> = {
26
26
  menu?: ViewsMenuItem[];
27
27
  /** Its layout, by the axis's `verbs.layouts`' id: what Save as new view and New view start from. */
28
28
  layout?: string;
29
- /** It holds changes not saved: its menu offers Save for everyone, Reset and Save as new view. */
29
+ /** It holds changes not saved: its menu offers Save for everyone (Save on a private view), Reset and Save as new view. */
30
30
  changed?: boolean;
31
31
  /** One of the reader's favorites. */
32
32
  favorite?: boolean;
33
+ /** 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. */
34
+ readOnly?: boolean;
33
35
  };
34
36
  /** One option of a `PillGroup`: any row of pills, a views row's or a tab row's. */
35
37
  export type PillOption<T extends string = string> = {
@@ -87,6 +89,21 @@ export type CollectionViewsConfig<V extends string = string> = {
87
89
  * and Undo from them; left out, a view's menu is its `menu` rows. */
88
90
  verbs?: ViewsViewVerbs;
89
91
  };
92
+ /** The axis's views as the views list (`ViewsListBody`) and a view's menu (`ViewMenu`) are handed them: each its value, words,
93
+ * glyph, count (absent while the axis hides counts), and what its menu reads. */
94
+ export declare function viewsListItemsOf(axis: CollectionViewsConfig<string>): ViewsViewsListItem[];
95
+ /** A view's whole menu, ViewKit's (VK-947), as a views row hands it to its pills and its "+N" rows: the axis's views as the views
96
+ * list is handed them, the view in use and the axis's `verbs`. Where the app's map draws `ViewMenu`, a pill opens it in place of
97
+ * its `menu` rows. */
98
+ export type PillViewMenu = {
99
+ views: readonly ViewsViewsListItem[];
100
+ value: string;
101
+ verbs: ViewsViewVerbs;
102
+ /** What holds the pill closes: a change opened a view, ended in the Toast, or asked for Customize. */
103
+ onDone?: () => void;
104
+ /** What holds the pill holds itself open while the menu asks outside it (the `confirm` port). */
105
+ onHold?: (holding: boolean) => void;
106
+ };
90
107
  /** Whether a view an app's views list hands back (`ViewsListBody`, VK-554) is one of the axis's views. One that isn't
91
108
  * is never picked. */
92
109
  export declare function viewsListPickFits(views: readonly Pick<ViewTabOption<string>, "value">[], value: string): boolean;
@@ -1,3 +1,17 @@
1
+ export function viewsListItemsOf(axis) {
2
+ return axis.options.map((option) => ({
3
+ value: option.value,
4
+ label: option.label,
5
+ ...(option.icon !== undefined && { icon: option.icon }),
6
+ ...(!axis.hideCounts && typeof option.count === "number" && { count: option.count }),
7
+ ...(option.private !== undefined && { private: option.private }),
8
+ ...(option.menu !== undefined && { menu: option.menu }),
9
+ ...(option.layout !== undefined && { layout: option.layout }),
10
+ ...(option.changed !== undefined && { changed: option.changed }),
11
+ ...(option.favorite !== undefined && { favorite: option.favorite }),
12
+ ...(option.readOnly !== undefined && { readOnly: option.readOnly }),
13
+ }));
14
+ }
1
15
  export function viewsListPickFits(views, value) {
2
16
  return views.some((view) => view.value === value);
3
17
  }
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
- import type { FieldConventions } from "viewkitjs/fields";
2
+ import { type FieldConventions } from "viewkitjs/fields";
3
3
  import { type ViewsMessageResolver } from "../contract.js";
4
4
  import type { ViewsAtoms } from "../atoms/types.js";
5
5
  import type { FieldPresentation } from "../display/options.js";
@@ -11,12 +11,21 @@ import type { ViewsSeveralValues } from "../display/fit-values.js";
11
11
  import { type ViewsPorts } from "./ports.js";
12
12
  export { useViews, type ViewsContextValue } from "./context.js";
13
13
  export type ViewsProviderProps = {
14
+ /** The controls ViewKit draws with: `CONTROLS` (`viewkitjs/views/controls`), or it with your own spread after it, or
15
+ * every one of your own. */
14
16
  components: ViewsComponents;
15
- icons: ViewsIcons;
16
- ports: ViewsPorts;
17
- conventions: FieldConventions;
18
- /** The app's own atoms, each over the default of its name. Pass a module-level
19
- * object: a new one each render re-renders every view. */
17
+ /** The glyphs by meaning. Absent: each meaning drawn through your `AppIcon` by its name, which `CONTROLS.AppIcon`
18
+ * draws with ViewKit's own glyphs. */
19
+ icons?: ViewsIcons;
20
+ /** The runtime services. Each one left out has its default: haptics that do nothing, the browser's clipboard, a store on
21
+ * `localStorage`, and the toast and confirm `PortsHost` draws (`CONTROLS` hands it). */
22
+ ports?: ViewsPorts;
23
+ /** How values read and are typed: the locale, the time zone and the rest. Absent: `en-US` in `UTC`, the same on the
24
+ * server and in the browser. */
25
+ conventions?: FieldConventions;
26
+ /** The app's own atoms, each over the default of its name. `CONTROLS` brings `CONTROL_ATOMS`, so handed it as it
27
+ * stands, yours lie over those; a map spread from it brings none. Pass a module-level object: a new one each render
28
+ * re-renders every view. */
20
29
  atoms?: Partial<ViewsAtoms>;
21
30
  /** The app's wording for the package's own messages. Default: the package's English. */
22
31
  messages?: ViewsMessageResolver;
@@ -62,4 +71,4 @@ export type ViewsProviderProps = {
62
71
  now?: Date;
63
72
  children: ReactNode;
64
73
  };
65
- export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, severalValues, selectionBar, datePicks, now, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
74
+ export declare function ViewsProvider({ children, components, conventions, icons: ownIcons, ports, atoms, messages, presentation, desktopQuery, sheetActions, escape, oneValue, severalValues, selectionBar, datePicks, now, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
4
- import { resolveViewsMessage } from "../contract.js";
4
+ import { defineConventions } from "viewkitjs/fields";
5
+ import { ICON_NAMES, resolveViewsMessage } from "../contract.js";
6
+ import { carriedAtoms } from "../atoms/carried.js";
5
7
  import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
6
8
  import { ViewsContext } from "./context.js";
7
9
  import { HasMomentContext, MomentContext } from "./moment.js";
@@ -9,14 +11,24 @@ import { PlainInput } from "./plain-input.js";
9
11
  import { missingComponent } from "./missing-slot.js";
10
12
  import { withSettledGroups } from "./menu-groups.js";
11
13
  import { DEFAULT_DESKTOP_QUERY, PhoneLine } from "../internal/phone-line.js";
12
- import { browserConfirm, NOOP_TOAST } from "./ports.js";
14
+ import { createListRegistry, ListRegistryContext } from "../list/registry.js";
15
+ import { browserClipboard, browserConfirm, localPrefs, NO_HAPTICS, NOOP_TOAST, } from "./ports.js";
13
16
  export { useViews } from "./context.js";
17
+ const DEFAULT_CONVENTIONS = defineConventions({ locale: "en-US", timeZone: "UTC" });
18
+ const NO_PORTS = {};
19
+ function iconsThrough(AppIcon) {
20
+ const through = (name) => function ViewsGlyph({ className }) {
21
+ return _jsx(AppIcon, { name: name, className: className });
22
+ };
23
+ return Object.fromEntries(ICON_NAMES.map((name) => [name, through(name)]));
24
+ }
14
25
  const MISSING_CALENDAR_COMPONENT = missingComponent("Calendar");
15
26
  const NO_SUBSCRIBE = () => () => { };
16
27
  const IN_BROWSER = () => true;
17
28
  const ON_SERVER = () => false;
18
- export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, severalValues = "fit", selectionBar, datePicks, now, }) {
29
+ export function ViewsProvider({ children, components, conventions = DEFAULT_CONVENTIONS, icons: ownIcons, ports = NO_PORTS, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, sheetActions = "bar", escape, oneValue, severalValues = "fit", selectionBar, datePicks, now, }) {
19
30
  const [readNow, setReadNow] = useState(null);
31
+ const [lists] = useState(createListRegistry);
20
32
  useEffect(() => {
21
33
  if (now)
22
34
  return;
@@ -35,7 +47,10 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
35
47
  }, [now]);
36
48
  const nowTime = now?.getTime();
37
49
  const moment = useMemo(() => (nowTime != null ? new Date(nowTime) : readNow), [nowTime, readNow]);
38
- const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
50
+ const carried = carriedAtoms(components);
51
+ const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...carried, ...atoms }), [carried, atoms]);
52
+ const AppIcon = components.AppIcon;
53
+ const icons = useMemo(() => ownIcons ?? iconsThrough(AppIcon), [ownIcons, AppIcon]);
39
54
  const settled = useMemo(() => ({
40
55
  ...components,
41
56
  Menu: withSettledGroups(components.Menu),
@@ -49,6 +64,9 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
49
64
  }, []);
50
65
  const resolved = useMemo(() => ({
51
66
  ...ports,
67
+ haptics: ports.haptics ?? NO_HAPTICS,
68
+ clipboard: ports.clipboard ?? browserClipboard,
69
+ viewPrefs: ports.viewPrefs ?? localPrefs,
52
70
  toast: ports.toast ?? {
53
71
  success: (message, options) => (hosted.current.toast ?? NOOP_TOAST).success(message, options),
54
72
  error: (message) => (hosted.current.toast ?? NOOP_TOAST).error(message),
@@ -95,5 +113,5 @@ export function ViewsProvider({ children, components, conventions, icons, ports,
95
113
  selectionBar,
96
114
  datePicks,
97
115
  ]);
98
- return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(MomentContext.Provider, { value: moment, children: _jsx(HasMomentContext.Provider, { value: moment != null, children: _jsxs(PhoneLine.Provider, { value: desktopQuery, children: [children, host] }) }) }) }));
116
+ return (_jsx(ViewsContext.Provider, { value: value, children: _jsx(MomentContext.Provider, { value: moment, children: _jsx(HasMomentContext.Provider, { value: moment != null, children: _jsx(PhoneLine.Provider, { value: desktopQuery, children: _jsxs(ListRegistryContext.Provider, { value: lists, children: [children, host] }) }) }) }) }));
99
117
  }
@@ -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>;