viewkitjs 0.34.0 → 0.36.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 (272) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/MIGRATION.md +7 -0
  3. package/package.json +1 -1
  4. package/views/README.md +1 -1
  5. package/views/dist/atoms/Avatar.js +2 -1
  6. package/views/dist/atoms/RelationChip.d.ts +2 -0
  7. package/views/dist/atoms/RelationChip.js +5 -0
  8. package/views/dist/atoms/RowMenu.d.ts +1 -1
  9. package/views/dist/atoms/RowMenu.js +15 -3
  10. package/views/dist/atoms/defaults.js +2 -0
  11. package/views/dist/atoms/types.d.ts +40 -4
  12. package/views/dist/cells/relation-wrap.js +9 -2
  13. package/views/dist/contract.d.ts +27 -7
  14. package/views/dist/contract.js +25 -2
  15. package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
  16. package/views/dist/controls/avatar/avatar-mark.js +5 -0
  17. package/views/dist/controls/avatar/avatar.d.ts +10 -5
  18. package/views/dist/controls/avatar/avatar.js +12 -6
  19. package/views/dist/controls/avatar/looks.d.ts +1 -1
  20. package/views/dist/controls/avatar/looks.js +3 -0
  21. package/views/dist/controls/avatar/record-mark.d.ts +16 -0
  22. package/views/dist/controls/avatar/record-mark.js +13 -0
  23. package/views/dist/controls/avatar/tokens.d.ts +12 -0
  24. package/views/dist/controls/avatar/tokens.js +3 -0
  25. package/views/dist/controls/avatar.css +54 -17
  26. package/views/dist/controls/bulk-bar/bulk-bar.js +4 -5
  27. package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
  28. package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
  29. package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
  30. package/views/dist/controls/compound-editor/map-parts-body.js +8 -1
  31. package/views/dist/controls/compound-editor/name-parts.js +3 -2
  32. package/views/dist/controls/compound-editor/place-parts.js +3 -3
  33. package/views/dist/controls/compound-editor/range-parts.js +11 -10
  34. package/views/dist/controls/compound-editor/words.d.ts +3 -0
  35. package/views/dist/controls/compound-editor/words.js +2 -0
  36. package/views/dist/controls/customize/customize.d.ts +22 -6
  37. package/views/dist/controls/customize/customize.js +154 -73
  38. package/views/dist/controls/customize/items.d.ts +49 -0
  39. package/views/dist/controls/customize/items.js +104 -0
  40. package/views/dist/controls/customize/map-customize-body.js +19 -15
  41. package/views/dist/controls/customize/words.d.ts +5 -3
  42. package/views/dist/controls/customize/words.js +1 -0
  43. package/views/dist/controls/filter-editor/block.js +5 -2
  44. package/views/dist/controls/filter-editor/filter-editor.d.ts +16 -1
  45. package/views/dist/controls/filter-editor/filter-editor.js +22 -16
  46. package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
  47. package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
  48. package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
  49. package/views/dist/controls/filter-editor/map-rules.js +18 -13
  50. package/views/dist/controls/filter-editor/parts.d.ts +1 -1
  51. package/views/dist/controls/filter-editor/parts.js +16 -15
  52. package/views/dist/controls/filter-editor/rules.d.ts +4 -4
  53. package/views/dist/controls/filter-editor/rules.js +6 -3
  54. package/views/dist/controls/filter-editor/words.d.ts +2 -0
  55. package/views/dist/controls/filter-editor/words.js +1 -0
  56. package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
  57. package/views/dist/controls/group-editor/group-editor.js +21 -15
  58. package/views/dist/controls/group-editor/map-group-body.js +1 -0
  59. package/views/dist/controls/index.d.ts +1 -1
  60. package/views/dist/controls/internal/kit-words.d.ts +11 -0
  61. package/views/dist/controls/internal/kit-words.js +7 -0
  62. package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
  63. package/views/dist/controls/internal/map-panel-controls.js +23 -6
  64. package/views/dist/controls/internal/menu-items.d.ts +9 -0
  65. package/views/dist/controls/internal/menu-items.js +97 -0
  66. package/views/dist/controls/internal/panel-controls.d.ts +27 -3
  67. package/views/dist/controls/internal/panel-controls.js +142 -13
  68. package/views/dist/controls/links-editor/links-editor.js +5 -7
  69. package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
  70. package/views/dist/controls/links-editor/map-links-body.js +5 -1
  71. package/views/dist/controls/menu/menu.d.ts +4 -1
  72. package/views/dist/controls/menu/menu.js +3 -2
  73. package/views/dist/controls/number-editor/map-number-body.js +2 -0
  74. package/views/dist/controls/number-editor/number-editor.js +1 -1
  75. package/views/dist/controls/number-editor/words.d.ts +3 -0
  76. package/views/dist/controls/number-editor/words.js +2 -0
  77. package/views/dist/controls/picker/fields-frame.d.ts +5 -0
  78. package/views/dist/controls/picker/fields-frame.js +30 -0
  79. package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
  80. package/views/dist/controls/picker/map-fields-body.js +7 -26
  81. package/views/dist/controls/picker/map-picker.d.ts +9 -3
  82. package/views/dist/controls/picker/map-picker.js +16 -3
  83. package/views/dist/controls/picker/picker.js +20 -10
  84. package/views/dist/controls/picker/rows.d.ts +9 -2
  85. package/views/dist/controls/picker.css +2 -0
  86. package/views/dist/controls/quick-filters/map-quick-filters-body.js +2 -1
  87. package/views/dist/controls/quick-filters/quick-filters.js +4 -4
  88. package/views/dist/controls/quick-filters/reminder.js +2 -2
  89. package/views/dist/controls/quick-filters/rules.d.ts +4 -1
  90. package/views/dist/controls/quick-filters/words.d.ts +2 -0
  91. package/views/dist/controls/quick-filters/words.js +1 -0
  92. package/views/dist/controls/select/map-select.d.ts +1 -1
  93. package/views/dist/controls/select/map-select.js +4 -1
  94. package/views/dist/controls/select/select.d.ts +5 -0
  95. package/views/dist/controls/select/select.js +11 -3
  96. package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
  97. package/views/dist/controls/sheet/bottom-sheet.js +3 -3
  98. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  99. package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
  100. package/views/dist/controls/sort-editor/sort-editor.js +9 -8
  101. package/views/dist/controls/tag/tag.js +4 -2
  102. package/views/dist/controls/text-editor/map-text-body.js +4 -1
  103. package/views/dist/controls/text-editor/text-editor.js +2 -2
  104. package/views/dist/controls/text-editor/words.d.ts +3 -0
  105. package/views/dist/controls/text-editor/words.js +1 -1
  106. package/views/dist/controls/toolbar/toolbar.d.ts +31 -12
  107. package/views/dist/controls/toolbar/toolbar.js +15 -20
  108. package/views/dist/controls/toolbar.css +0 -5
  109. package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
  110. package/views/dist/controls/tooltip/map-tooltip.js +4 -2
  111. package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
  112. package/views/dist/controls/values-editor/map-values-body.js +5 -1
  113. package/views/dist/controls/values-editor/values-editor.js +8 -7
  114. package/views/dist/controls/views-list/map-views-list-body.js +9 -1
  115. package/views/dist/controls/views-list/rules.d.ts +1 -0
  116. package/views/dist/controls/views-list/rules.js +2 -2
  117. package/views/dist/controls/views-list/view-menu.js +2 -2
  118. package/views/dist/controls/views-list/words.d.ts +4 -0
  119. package/views/dist/controls/views-list/words.js +2 -1
  120. package/views/dist/display/option-badges.d.ts +17 -0
  121. package/views/dist/display/option-badges.js +11 -0
  122. package/views/dist/display/relation-link.d.ts +12 -0
  123. package/views/dist/display/relation-link.js +17 -0
  124. package/views/dist/display/relation.d.ts +1 -1
  125. package/views/dist/display/relation.js +10 -3
  126. package/views/dist/display/select.js +1 -8
  127. package/views/dist/editors/EditorPanel.js +1 -1
  128. package/views/dist/editors/RangeEditor.d.ts +3 -0
  129. package/views/dist/editors/RangeEditor.js +2 -2
  130. package/views/dist/editors/SelectEditor.d.ts +2 -2
  131. package/views/dist/editors/SelectEditor.js +1 -1
  132. package/views/dist/editors/TextEditor.js +4 -2
  133. package/views/dist/editors/ValueListEditor.js +2 -1
  134. package/views/dist/field-row/FieldRow.js +32 -5
  135. package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
  136. package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
  137. package/views/dist/grid/chrome/GridAddColumn.js +13 -9
  138. package/views/dist/grid/chrome/GridCellEditors.js +1 -1
  139. package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
  140. package/views/dist/grid/chrome/GridCellOutline.js +16 -6
  141. package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
  142. package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
  143. package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
  144. package/views/dist/grid/chrome/GridFooter.js +4 -4
  145. package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
  146. package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
  147. package/views/dist/grid/chrome/GridHeader.js +4 -3
  148. package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
  149. package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
  150. package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
  151. package/views/dist/grid/chrome/GridRow.js +11 -3
  152. package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
  153. package/views/dist/grid/chrome/GridRowActions.js +2 -2
  154. package/views/dist/grid/chrome/GridRowCells.js +3 -2
  155. package/views/dist/grid/chrome/GridStructure.js +1 -1
  156. package/views/dist/grid/chrome/GridTable.js +32 -20
  157. package/views/dist/grid/chrome/GridTableSurface.js +2 -1
  158. package/views/dist/grid/chrome/checks.d.ts +1 -1
  159. package/views/dist/grid/chrome/checks.js +4 -1
  160. package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
  161. package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
  162. package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
  163. package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
  164. package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
  165. package/views/dist/grid/chrome/grid-hover.js +14 -4
  166. package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
  167. package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
  168. package/views/dist/grid/chrome/grid-table-props.d.ts +16 -4
  169. package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
  170. package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
  171. package/views/dist/grid/grid-format-props.d.ts +1 -1
  172. package/views/dist/grid/grid-format-props.js +18 -5
  173. package/views/dist/grid/grid.css +11 -1
  174. package/views/dist/grid/looks.d.ts +3 -1
  175. package/views/dist/grid/looks.js +10 -4
  176. package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
  177. package/views/dist/grid/useGridTableSettings.d.ts +1 -1
  178. package/views/dist/list/layer.d.ts +8 -0
  179. package/views/dist/list/layer.js +7 -0
  180. package/views/dist/list/list.js +2 -2
  181. package/views/dist/list/menu.d.ts +5 -4
  182. package/views/dist/list/store.d.ts +1 -1
  183. package/views/dist/list/toolbar.js +47 -20
  184. package/views/dist/list/views.js +1 -0
  185. package/views/dist/panels/availability.d.ts +5 -0
  186. package/views/dist/panels/availability.js +4 -5
  187. package/views/dist/panels/customize-body.d.ts +5 -1
  188. package/views/dist/panels/customize-body.js +21 -12
  189. package/views/dist/panels/model.d.ts +14 -4
  190. package/views/dist/panels/react/customize-body.js +15 -3
  191. package/views/dist/panels/react/customize.d.ts +8 -0
  192. package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
  193. package/views/dist/panels/react/filter/FilterEditor.js +7 -0
  194. package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
  195. package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
  196. package/views/dist/panels/react/filter/filter-body.js +3 -1
  197. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
  198. package/views/dist/panels/react/filter/filter-part-body.js +2 -2
  199. package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
  200. package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
  201. package/views/dist/panels/react/sort/SortEditor.js +3 -1
  202. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -2
  203. package/views/dist/panels/react/toolbar/Toolbar.d.ts +11 -1
  204. package/views/dist/panels/react/toolbar/Toolbar.js +16 -6
  205. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
  206. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
  207. package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +12 -5
  208. package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
  209. package/views/dist/panels/react/toolbar/ToolbarFilters.js +18 -8
  210. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +9 -1
  211. package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
  212. package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
  213. package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
  214. package/views/dist/panels/react/toolbar/ToolbarSave.js +5 -4
  215. package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
  216. package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
  217. package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
  218. package/views/dist/panels/react/toolbar/ToolbarSortPill.js +4 -4
  219. package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
  220. package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
  221. package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
  222. package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
  223. package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
  224. package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
  225. package/views/dist/panels/react/views-row/ViewPicker.js +8 -3
  226. package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
  227. package/views/dist/panels/react/views-row/new-view.js +21 -0
  228. package/views/dist/panels/react.d.ts +1 -1
  229. package/views/dist/panels/settings/layout.js +6 -38
  230. package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
  231. package/views/dist/panels/toolbar/page-resets.js +62 -0
  232. package/views/dist/panels/toolbar/same-item.d.ts +7 -0
  233. package/views/dist/panels/toolbar/same-item.js +9 -0
  234. package/views/dist/panels/view-state.d.ts +4 -0
  235. package/views/dist/provider/ViewsProvider.d.ts +9 -4
  236. package/views/dist/provider/ViewsProvider.js +13 -2
  237. package/views/dist/provider/components.d.ts +109 -7
  238. package/views/dist/provider/components.js +1 -1
  239. package/views/dist/react.d.ts +2 -2
  240. package/views/dist/styles.css +115 -27
  241. package/views/dist/styles.unlayered.css +115 -27
  242. package/views/docs/contract.md +55 -35
  243. package/views/docs/controls/avatar.md +3 -0
  244. package/views/docs/controls/bulk-bar.md +3 -1
  245. package/views/docs/controls/compound-editor.md +2 -0
  246. package/views/docs/controls/customize.md +1 -1
  247. package/views/docs/controls/filter-editor.md +1 -1
  248. package/views/docs/controls/links-editor.md +2 -0
  249. package/views/docs/controls/pane.md +1 -1
  250. package/views/docs/controls/picker.md +2 -0
  251. package/views/docs/controls/quick-filters.md +1 -1
  252. package/views/docs/controls/text-editor.md +1 -1
  253. package/views/docs/controls/values-editor.md +2 -0
  254. package/views/docs/guides/atoms.md +54 -3
  255. package/views/docs/guides/display.md +1 -1
  256. package/views/docs/guides/looks.md +1 -1
  257. package/views/docs/guides/the-grid.md +4 -2
  258. package/views/docs/guides/the-provider.md +2 -2
  259. package/views/docs/index.md +2 -2
  260. package/views/docs/install.md +198 -104
  261. package/views/docs/reference/controls.md +27 -24
  262. package/views/docs/reference/editors-range.md +1 -1
  263. package/views/docs/reference/field-row.md +1 -1
  264. package/views/docs/reference/grid.md +6 -5
  265. package/views/docs/reference/list.md +27 -7
  266. package/views/docs/reference/looks.md +5 -5
  267. package/views/docs/reference/panels-react.md +15 -14
  268. package/views/docs/reference/panels.md +5 -5
  269. package/views/docs/reference/react.md +25 -11
  270. package/views/docs/reference/views.md +2 -2
  271. package/views/docs/reshaping.md +22 -6
  272. package/views/skills/views/SKILL.md +2 -2
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { glyph } from "../internal/editor-parts.js";
5
+ import { openerAt, useStepReturn } from "../internal/step-return.js";
5
6
  import { Icon } from "../internal/icons.js";
6
7
  import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
7
8
  import { InputGroup, InputGroupAddon } from "../input/input.js";
@@ -16,6 +17,8 @@ import { reduced, slideTime, useGlide } from "./glide.js";
16
17
  import { CUSTOMIZE_ATTRS, customizeWornOf } from "./looks.js";
17
18
  import { columnOpens, columnOpensBySettings, columnsSay, findColumns, moveColumn, setShown } from "./rules.js";
18
19
  import { customizeWords } from "./words.js";
20
+ import { entriesOf, keyOf, layoutItemsOf, listItemsOf, shapeItems } from "./items.js";
21
+ const ownPage = (s) => s !== "list" && !s.startsWith("page:");
19
22
  export function useCustomizeWorn() {
20
23
  const [el, setEl] = React.useState(null), [worn, setWorn] = React.useState(() => customizeWornOf(null));
21
24
  React.useLayoutEffect(() => {
@@ -40,7 +43,7 @@ const LAYOUT_MARKS = {
40
43
  };
41
44
  export const layoutMark = (id) => (LAYOUT_MARKS[id] ? glyph([LAYOUT_MARKS[id]]) : undefined);
42
45
  export function useCustomize(props) {
43
- const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
46
+ const { view, onViewChange, layouts, filter, sort, group, changed = false, onReset, onSave, pending = false, stale = false, exportCount, onCopyLink, onExport, toggles, layoutSettings, columnsReset, resets, differs, items, onLineChange, columnsFoot, fields = [], foldFields = false, onClose, onScreenChange } = props;
44
47
  const w = customizeWords(props.words);
45
48
  const { Button, Input } = usePanelControls();
46
49
  const host = React.useContext(PhoneHost), small = usePhone(), phone = (props.form ?? (host || small ? "phone" : "computer")) === "phone";
@@ -51,11 +54,34 @@ export function useCustomize(props) {
51
54
  const latest = React.useMemo(() => ({ get view() { return now.current; } }), []);
52
55
  const change = (next) => { now.current = next; onViewChange(next); };
53
56
  const NAMES = { layout: w.layout, columns: w.columns, filter: w.filter, sort: w.sort, group: w.group };
54
- const SCREEN_OF = { [w.layout]: "layout", [w.columns]: "columns", [w.filter]: "filter", [w.sort]: "sort", [w.group]: "group" };
55
57
  const handed = { filter, sort, group };
56
58
  const hasLayout = layouts.length > 0 || !!layoutSettings, hasColumns = view.columns.length > 0;
57
59
  const folded = foldFields && !filter && fields.length > 0;
58
- const opens = (to) => to === "list" || (to === "layout" ? hasLayout : to === "columns" ? hasColumns : to === "filter" && folded ? true : handed[to]?.opens != null);
60
+ const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
61
+ const filterFields = fields.filter((f) => f.place === "filters"), afterFields = fields.filter((f) => f.place === "after");
62
+ const inForceFields = filterFields.filter((f) => f.inForce).length;
63
+ const foldedFilter = folded ? { says: inForceFields ? String(inForceFields) : w.none, inForce: inForceFields > 0 } : undefined;
64
+ const form = phone ? "phone" : "computer";
65
+ const ctxOf = (page) => ({ page, form, ...(view.layout && { layout: view.layout }) });
66
+ const sectionItems = [
67
+ ...(hasLayout ? [{ key: "layout", label: w.layout, icon: layout?.mark, ...(layout && { detail: layout.name }), inForce: !!differs?.layout }] : []),
68
+ ...(hasColumns ? [{ key: "columns", label: w.columns, icon: COLUMNS, detail: columnsSay(view.columns, w), inForce: !!differs?.columns }] : []),
69
+ ...[["filter", _jsx(Icon, { name: "filter" }, "f"), filter ?? foldedFilter], ["sort", _jsx(Icon, { name: "sort" }, "s"), sort], ["group", GROUP, group]]
70
+ .flatMap(([key, icon, s]) => (s ? [{ key, label: NAMES[key], icon, detail: s.says, ...(s.inForce !== undefined && { inForce: s.inForce }) }] : [])),
71
+ ];
72
+ const listDefaults = listItemsOf(sectionItems, { filters: filterFields, after: afterFields, folded }, toggles ?? null, w, view.counts);
73
+ const listItems = shapeItems(listDefaults, items, ctxOf("list"));
74
+ const keysIn = (is, into = new Map()) => { for (const i of is) {
75
+ into.set(i.key, i);
76
+ if (i.children)
77
+ keysIn(i.children, into);
78
+ } return into; };
79
+ const listed = keysIn(listItems), ownKeys = new Set(keysIn(listDefaults).keys());
80
+ const onList = (key) => { const i = listed.get(key); return !!i && !i.disabled && i.children === undefined; };
81
+ const appPage = (key) => (onList(key) && !ownKeys.has(key) && listed.get(key).page !== undefined ? listed.get(key) : undefined);
82
+ const opens = (to) => to === "list" || (to.startsWith("page:") ? !!appPage(to.slice("page:".length))
83
+ : onList(to) && (to === "layout" ? hasLayout : to === "columns" ? hasColumns : to === "filter" && folded ? true : handed[to]?.opens != null));
84
+ const labelOf = (key) => listed.get(key)?.label;
59
85
  const [screen, setScreen] = React.useState(() => (props.screen && opens(props.screen) ? props.screen : "list")), [back, setBack] = React.useState(false);
60
86
  const [choosing, setChoosing] = React.useState(null), [column, setColumn] = React.useState(null);
61
87
  const [fieldKey, setFieldKey] = React.useState(null);
@@ -73,7 +99,7 @@ export function useCustomize(props) {
73
99
  setFind("");
74
100
  onScreenChange?.(to);
75
101
  };
76
- const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setColumn(null); setFieldKey(null); setFocusTo(from === "list" ? null : NAMES[from]); setFind(""); onScreenChange?.("list"); };
102
+ const goBack = () => { const from = screen; setBack(true); setScreen("list"); setChoosing(null); setColumn(null); setFieldKey(null); setFocusTo(from === "list" ? null : from.startsWith("page:") ? { slot: "vk-customize-page", key: from.slice("page:".length) } : { slot: "vk-customize-section", key: from }); setFind(""); onScreenChange?.("list"); };
77
103
  React.useLayoutEffect(() => {
78
104
  if (!focusTo || phone)
79
105
  return;
@@ -82,14 +108,37 @@ export function useCustomize(props) {
82
108
  backButton.current?.focus({ preventScroll: true });
83
109
  return;
84
110
  }
85
- const row = [...(root.current?.querySelectorAll("[data-item]") ?? [])].find((r) => r.querySelector(".o-menu-name")?.textContent === focusTo);
86
- row?.focus({ preventScroll: true });
111
+ root.current?.querySelector(`[data-slot=${focusTo.slot}][data-key="${CSS.escape(focusTo.key)}"]`)?.focus({ preventScroll: true });
87
112
  }, [focusTo, phone]);
113
+ const gone = screen !== "list" && (fieldKey && !folded ? !onList(keyOf.field(fieldKey)) : !opens(screen));
114
+ React.useLayoutEffect(() => {
115
+ if (!gone)
116
+ return;
117
+ setScreen("list");
118
+ setChoosing(null);
119
+ setColumn(null);
120
+ setFieldKey(null);
121
+ setBack(true);
122
+ onScreenChange?.("list");
123
+ }, [gone, onScreenChange]);
88
124
  const placeRoot = React.useCallback((el) => { root.current = el; place(el); }, [place]);
89
125
  const glide = useGlide(root);
90
126
  const [held, setHeld] = React.useState({});
91
127
  const holds = React.useRef([]);
128
+ const follow = React.useRef(null);
129
+ const columnRow = (id) => root.current?.querySelector(`[data-slot=vk-customize-column][data-key="${CSS.escape(id)}"]`) ?? null;
130
+ React.useLayoutEffect(() => {
131
+ const f = follow.current;
132
+ if (!f || view.columns.find((c) => c.id === f.id)?.shown !== f.on)
133
+ return;
134
+ follow.current = null;
135
+ const row = columnRow(f.id);
136
+ if (row && document.activeElement !== row)
137
+ row.focus({ preventScroll: true });
138
+ });
92
139
  const press = (ids, on) => {
140
+ const one = ids.length === 1 ? columnRow(ids[0]) : null;
141
+ follow.current = one?.contains(document.activeElement) ? { id: ids[0], on } : null;
93
142
  const land = (these) => change({ ...latest.view, columns: these.reduce((cols, id) => setShown(cols, id, on), latest.view.columns) });
94
143
  if (!ids.length)
95
144
  return;
@@ -117,25 +166,13 @@ export function useCustomize(props) {
117
166
  if (h.ids.length)
118
167
  h.land();
119
168
  } holds.current = []; }, []);
120
- const layout = layouts.find((l) => l.id === view.layout) ?? layouts[0];
121
169
  const part = (slot, key) => ({ slot: { slot, ...(key !== undefined ? { key } : {}) } });
122
- const section = (label, icon, s, key) => s ? [{ kind: "actions", icon, label, detail: s.says, inForce: s.inForce, entries: [], ...part("vk-customize-section", key) }] : [];
123
- const toggleRows = (ts) => ts.flatMap((t) => [
124
- { kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }), ...part("vk-customize-toggle", t.key) },
125
- ...(t.reset ? [{ icon: null, label: w.toggleReset(t.label), onSelect: t.reset, ...part("vk-customize-toggle-reset", t.key) }] : []),
126
- ]);
170
+ const toggleRows = (ts) => ts.map((t) => ({ kind: "check", label: t.label, checked: t.value, onCheckedChange: (on) => t.onChange(on), ...(t.icon != null && { icon: t.icon }), ...part("vk-customize-toggle", t.key) }));
127
171
  const sectionsOfToggles = (ts) => [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
128
- const checks = toggles
129
- ? [...toggleRows(toggles.filter((t) => !t.section)),
130
- ...sectionsOfToggles(toggles).map((s) => ({ kind: "group", heading: s, entries: toggleRows(toggles.filter((t) => t.section === s)) }))]
131
- : [{ kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }), ...part("vk-customize-toggle", "counts") }];
132
- const fieldRows = new Map();
133
172
  const fieldRow = (f) => {
134
173
  const entry = f.disabled != null
135
174
  ? { icon: f.icon ?? null, label: f.label, disabled: f.disabled, ...part("vk-customize-field", f.key) }
136
175
  : { kind: "actions", icon: f.icon ?? null, label: f.label, detail: f.says, inForce: f.inForce, entries: [], ...part("vk-customize-field", f.key) };
137
- if (f.disabled == null)
138
- fieldRows.set(entry, f.key);
139
176
  return entry;
140
177
  };
141
178
  const fieldEntries = (fs, line = false) => {
@@ -144,17 +181,19 @@ export function useCustomize(props) {
144
181
  ...heads.map((s) => ({ kind: "group", heading: s, entries: fs.filter((f) => f.section === s).map(fieldRow) })),
145
182
  ...(line && heads.length ? [{ kind: "separator" }] : [])];
146
183
  };
147
- const filterFields = fields.filter((f) => f.place === "filters"), afterFields = fields.filter((f) => f.place === "after");
148
- const inForceFields = filterFields.filter((f) => f.inForce).length;
149
- const foldedFilter = folded ? { says: inForceFields ? String(inForceFields) : w.none, inForce: inForceFields > 0 } : undefined;
150
- const sections = [
151
- ...(hasLayout ? [{ kind: "actions", icon: layout?.mark, label: w.layout, detail: layout?.name, entries: [], ...part("vk-customize-section", "layout") }] : []),
152
- ...(hasColumns ? [{ kind: "actions", icon: COLUMNS, label: w.columns, detail: columnsSay(view.columns, w), entries: [], ...part("vk-customize-section", "columns") }] : []),
153
- ...(folded ? [] : fieldEntries(filterFields, true)),
154
- ...section(w.filter, _jsx(Icon, { name: "filter" }), filter ?? foldedFilter, "filter"), ...section(w.sort, _jsx(Icon, { name: "sort" }), sort, "sort"), ...section(w.group, GROUP, group, "group"),
155
- ...(folded ? [] : fieldEntries(afterFields)),
156
- ...(checks.length ? [{ kind: "separator" }, ...checks] : []),
157
- ];
184
+ const ownList = new Map();
185
+ for (const it of sectionItems) {
186
+ ownList.set(it.key, { kind: "actions", icon: it.icon ?? null, label: it.label, ...(it.detail !== undefined && { detail: it.detail }), ...(it.inForce !== undefined && { inForce: it.inForce }),
187
+ entries: [], ...part("vk-customize-section", it.key) });
188
+ }
189
+ for (const f of fields)
190
+ ownList.set(keyOf.field(f.key), fieldRow(f));
191
+ if (toggles)
192
+ for (const t of toggles)
193
+ ownList.set(keyOf.toggle(t.key), toggleRows([t])[0]);
194
+ else
195
+ ownList.set(keyOf.toggle("counts"), { kind: "check", label: w.showCounts, checked: view.counts, onCheckedChange: (c) => change({ ...latest.view, counts: c }), ...part("vk-customize-toggle", "counts") });
196
+ const sections = entriesOf(listItems, ownList, { onList: true, unavailable: w.unavailable });
158
197
  const field = screen === "filter" && fieldKey ? fields.find((f) => f.key === fieldKey && f.disabled == null) : undefined;
159
198
  React.useLayoutEffect(() => {
160
199
  if (!fieldKey || field)
@@ -182,20 +221,31 @@ export function useCustomize(props) {
182
221
  f.onOpen?.();
183
222
  };
184
223
  const backFromField = () => {
185
- const label = field?.label ?? null;
186
224
  setBack(true);
187
225
  setFieldKey(null);
188
- setFocusTo(label);
226
+ setFocusTo(field ? { slot: "vk-customize-field", key: field.key } : null);
189
227
  if (!folded) {
190
228
  setScreen("list");
191
229
  onScreenChange?.("list");
192
230
  }
193
231
  };
194
- const opened = (e) => { const key = fieldRows.get(e); if (key) {
195
- openField(key);
196
- return;
197
- } if ("label" in e && SCREEN_OF[e.label])
198
- go(SCREEN_OF[e.label]); };
232
+ const opened = (e) => {
233
+ const at = "slot" in e ? e.slot : undefined, key = at?.key;
234
+ if (!at || key === undefined)
235
+ return;
236
+ if (at.slot === "vk-customize-section")
237
+ go(key);
238
+ else if (at.slot === "vk-customize-field")
239
+ openField(key);
240
+ else if (at.slot === "vk-customize-page")
241
+ go(`page:${key}`);
242
+ else if (at.slot === "vk-customize-choice") {
243
+ setBack(false);
244
+ setChoosing(key);
245
+ }
246
+ else if (at.slot === "vk-customize-column")
247
+ openColumn(key);
248
+ };
199
249
  const footer = [
200
250
  ...(onCopyLink ? [{ icon: _jsx(Icon, { name: "link" }), label: w.copyLink, onSelect: onCopyLink, ...part("vk-customize-action", "copy-link") }] : []),
201
251
  ...(onExport ? [{ icon: _jsx(Icon, { name: "export" }), label: w.export, ...(exportCount != null ? { count: exportCount } : {}), onSelect: onExport, ...part("vk-customize-action", "export") }] : []),
@@ -207,23 +257,40 @@ export function useCustomize(props) {
207
257
  setChoosing(null);
208
258
  setBack(true);
209
259
  } }, [column, col]);
210
- const allChoices = screen === "layout" ? (layoutSettings ? [...layoutSettings.choices, ...(layoutSettings.personal?.choices ?? [])] : []) : col?.settings?.choices ?? [];
211
- const choiceRows = new Map();
212
- const choiceOpened = (e) => { const c = choiceRows.get(e); if (c) {
213
- setBack(false);
214
- setChoosing(c.key);
215
- } };
260
+ const byKey = (slot, key) => openerAt(() => `[data-slot=${slot}][data-key="${CSS.escape(key)}"]`);
261
+ const openers = !phone || screen === "list" ? [] : [
262
+ ...(fieldKey && !folded ? [] : [screen.startsWith("page:") ? byKey("vk-customize-page", screen.slice("page:".length)) : byKey("vk-customize-section", screen)]),
263
+ ...(fieldKey ? [byKey("vk-customize-field", fieldKey)] : []),
264
+ ...(col ? [byKey("vk-customize-column", col.id)] : []),
265
+ ...(choosing ? [byKey("vk-customize-choice", choosing)] : []),
266
+ ];
267
+ useStepReturn(root, openers);
268
+ const allChoices = screen === "layout" ? layoutSettings?.choices ?? [] : col?.settings?.choices ?? [];
216
269
  const rowsList = (label, rows) => (phone
217
- ? _jsx(MenuList, { label: label, entries: rows, onOpen: choiceOpened, words: w.rows })
218
- : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen: choiceOpened, words: w.rows }));
270
+ ? _jsx(MenuList, { label: label, entries: rows, onOpen: opened, words: w.rows })
271
+ : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "switch", onOpen: opened, words: w.rows }));
219
272
  const choiceRow = (c) => {
220
273
  const entry = { kind: "choices", icon: null, label: c.label, value: c.value, choices: c.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
221
274
  detail: c.options.find((o) => o.value === c.value)?.label, ...part("vk-customize-choice", c.key) };
222
- choiceRows.set(entry, c);
223
275
  return entry;
224
276
  };
225
- const choice = allChoices.find((c) => c.key === choosing);
226
- const backFromChoice = () => { setBack(true); setFocusTo(choice?.label ?? null); setChoosing(null); };
277
+ const tableRows = !layoutSettings && layout?.id === "table";
278
+ const ownLayout = new Map();
279
+ if (layoutSettings) {
280
+ for (const c of layoutSettings.choices)
281
+ ownLayout.set(keyOf.choice(c.key), choiceRow(c));
282
+ for (const t of layoutSettings.toggles)
283
+ ownLayout.set(keyOf.toggle(t.key), toggleRows([t])[0]);
284
+ }
285
+ else if (tableRows) {
286
+ ownLayout.set(keyOf.toggle("freeze"), { kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }), ...part("vk-customize-toggle", "freeze") });
287
+ ownLayout.set(keyOf.toggle("wrap"), { kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }), ...part("vk-customize-toggle", "wrap") });
288
+ }
289
+ const layoutItems = screen === "layout"
290
+ ? shapeItems(layoutItemsOf(layoutSettings, tableRows ? { freeze: view.freeze, wrap: view.wrap, words: { freeze: w.freeze, wrap: w.wrap } } : null), items, ctxOf("layout")) : [];
291
+ const layoutKeys = keysIn(layoutItems);
292
+ const choice = allChoices.find((c) => c.key === choosing && (screen !== "layout" || layoutKeys.has(keyOf.choice(c.key))));
293
+ const backFromChoice = () => { setBack(true); setFocusTo(choice ? { slot: "vk-customize-choice", key: choice.key } : null); setChoosing(null); };
227
294
  const choiceLevel = choice && (() => {
228
295
  const rows = [{ kind: "pick", value: choice.value, choices: choice.options.map((o) => ({ value: o.value, label: o.label, ...part("vk-customize-option", o.value) })),
229
296
  onChoose: (v) => { if (v !== choice.value)
@@ -235,21 +302,33 @@ export function useCustomize(props) {
235
302
  const ownSettings = (settings, name, lead = [], own) => {
236
303
  const bare = settings.toggles.filter((t) => !t.section), sectioned = sectionsOfToggles(settings.toggles);
237
304
  const first = [...lead, ...settings.choices.map(choiceRow), ...toggleRows(bare)];
238
- const you = settings.personal, yours = you ? [...you.choices.map(choiceRow), ...toggleRows(you.toggles), ...(you.onReset ? [{ icon: null, label: w.personalReset, onSelect: you.onReset, ...part("vk-customize-toggle-reset", "personal") }] : [])] : [];
239
- return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own && headingWords(name, own === undefined ? layout?.id ?? name : name), rowsList(own?.list ?? w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [headingWords(s, s), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s)), you && yours.length > 0 && _jsxs(_Fragment, { children: [headingWords(you.label, "you"), rowsList(you.label, yours)] })] });
305
+ return _jsxs(_Fragment, { children: [first.length > 0 && _jsxs(_Fragment, { children: [!own && headingWords(name, own === undefined ? layout?.id ?? name : name), rowsList(own?.list ?? w.layoutSettings(name), first)] }), sectioned.map((s) => _jsxs(React.Fragment, { children: [headingWords(s, s), rowsList(s, toggleRows(settings.toggles.filter((t) => t.section === s)))] }, s))] });
240
306
  };
241
- const layoutScreen = (_jsxs(_Fragment, { children: [_jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
242
- change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later, "data-slot": "vk-customize-layout", "data-key": l.id }, l.id)) }), layoutSettings ? ownSettings(layoutSettings, layout?.name ?? w.layout) : layout?.id === "table" && _jsxs(_Fragment, { children: [headingWords(layout.name, layout.id), rowsList(w.layoutSettings(layout.name), [
243
- { kind: "check", label: w.freeze, checked: view.freeze, onCheckedChange: (c) => change({ ...latest.view, freeze: c }), ...part("vk-customize-toggle", "freeze") },
244
- { kind: "check", label: w.wrap, checked: view.wrap, onCheckedChange: (c) => change({ ...latest.view, wrap: c }), ...part("vk-customize-toggle", "wrap") },
245
- ])] })] }));
307
+ const layoutBlocks = (() => {
308
+ const name = layout?.name ?? w.layout, opts = { onList: false, unavailable: w.unavailable };
309
+ const blocks = [{ rows: [] }];
310
+ for (const i of layoutItems) {
311
+ if (i.children !== undefined && !i.disabled) {
312
+ if (entriesOf(i.children, ownLayout, opts).length)
313
+ blocks.push({ head: i, rows: [] });
314
+ }
315
+ else
316
+ blocks[blocks.length - 1].rows.push(i);
317
+ }
318
+ return blocks.map((b) => {
319
+ const entries = [...(b.head ? entriesOf(b.head.children, ownLayout, opts) : []), ...entriesOf(b.rows, ownLayout, opts)];
320
+ if (!entries.length)
321
+ return null;
322
+ const head = b.head && (b.head.key.startsWith("toggles:") ? b.head.key.slice("toggles:".length) : b.head.key);
323
+ return _jsxs(React.Fragment, { children: [b.head ? headingWords(b.head.label, head) : headingWords(name, layout?.id ?? name), rowsList(b.head ? b.head.label : w.layoutSettings(name), entries)] }, b.head?.key ?? "");
324
+ });
325
+ })();
326
+ const layoutScreen = (_jsxs(_Fragment, { children: [(!phone || layouts.length > 1) && _jsx(RadioGroup, { tiles: true, "aria-label": w.layout, value: view.layout, onValueChange: (v) => { if (typeof v === "string")
327
+ change({ ...latest.view, layout: v }); }, children: layouts.map((l) => _jsx(Radio, { value: l.id, mark: l.mark, label: l.name, disabled: l.later, "data-slot": "vk-customize-layout", "data-key": l.id }, l.id)) }), layoutBlocks] }));
246
328
  const searching = find.trim() !== "", eyes = worn.columns === "eye";
247
329
  const found = findColumns(view.columns, find);
248
330
  const gripped = (columns, shown) => (searching || (!shown && !eyes) ? [] : columns.filter((c) => c.shown === shown && !c.locked));
249
- const columnRows = new Map();
250
331
  const openColumn = (id) => { setBack(false); setColumn(id); setChoosing(null); setFocusTo("back"); setFind(""); };
251
- const columnOpened = (e) => { const id = columnRows.get(e); if (id)
252
- openColumn(id); };
253
332
  const lineMark = glyph(["M9 10l-5 5l5 5", "M20 4v7a4 4 0 0 1 -4 4h-12"]);
254
333
  const block = (shown) => {
255
334
  const grips = new Set(gripped(found, shown).map((c) => c.id));
@@ -259,8 +338,6 @@ export function useCustomize(props) {
259
338
  ...(columnOpens(c) && { opens: w.columnSettings(c.label) }),
260
339
  ...(c.line && { toggle: { icon: lineMark, label: c.line.on ? w.newLineOn(c.label) : w.newLineStart(c.label), on: c.line.on, onPress: () => onLineChange?.(c.id),
261
340
  ...(c.line.refused && { disabled: c.line.refused }) } }) };
262
- if (columnOpens(c))
263
- columnRows.set(entry, c.id);
264
341
  return entry;
265
342
  });
266
343
  };
@@ -271,8 +348,8 @@ export function useCustomize(props) {
271
348
  };
272
349
  const ticks = eyes ? "eye" : "switch";
273
350
  const rowsOf = (label, shown) => phone
274
- ? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: columnOpened, words: w.rows })
275
- : _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: columnOpened, words: w.rows });
351
+ ? _jsx(MenuList, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: opened, words: w.rows })
352
+ : _jsx(MenuListPanelRows, { label: label, entries: block(shown), ticks: ticks, onMove: moveIn(shown), onOpen: opened, words: w.rows });
276
353
  const canHide = view.columns.some((c) => c.shown && !c.locked), canShow = view.columns.some((c) => !c.shown);
277
354
  const shownHere = found.some((c) => c.shown), hiddenHere = found.some((c) => !c.shown);
278
355
  const typed = (e) => setFind(e.target.value);
@@ -280,10 +357,10 @@ export function useCustomize(props) {
280
357
  const columnsSearch = phone ? columnsBox : _jsx("div", { className: "o-customize-search", children: columnsBox });
281
358
  const shownActs = [
282
359
  ...(!searching && canHide ? [{ key: "hide-all", label: w.hideAll, onPress: () => press(latest.view.columns.filter((c) => c.shown && !c.locked).map((c) => c.id), false) }] : []),
283
- ...(!searching && columnsReset ? [{ key: "reset", label: w.columnsReset, onPress: columnsReset }] : []),
284
360
  ];
285
- const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, "shown", shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, "hidden", !searching && canShow ? [{ key: "show-all", label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "columns", children: w.noColumn(find.trim()) }), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", "data-slot": "vk-customize-columns-foot", children: columnsFoot })] }));
286
- const backFromColumn = () => { setBack(true); setFocusTo(col?.label ?? null); setColumn(null); setChoosing(null); };
361
+ const columnsExtra = screen === "columns" ? entriesOf(shapeItems([], items, ctxOf("columns")), new Map(), { onList: false, unavailable: w.unavailable }) : [];
362
+ const columnsScreen = (_jsxs(_Fragment, { children: [phone && columnsSearch, shownHere && _jsxs(_Fragment, { children: [heading(w.shownHeading, "shown", shownActs), rowsOf(w.shownHeading, true)] }), hiddenHere && _jsxs(_Fragment, { children: [heading(w.hiddenHeading, "hidden", !searching && canShow ? [{ key: "show-all", label: w.showAll, onPress: () => press(latest.view.columns.filter((c) => !c.shown).map((c) => c.id), true) }] : undefined), rowsOf(w.hiddenHeading, false)] }), !found.length && _jsx("p", { className: "o-customize-none", "data-slot": "vk-customize-none", "data-key": "columns", children: w.noColumn(find.trim()) }), columnsExtra.length > 0 && rowsList(w.columns, columnsExtra), columnsFoot != null && _jsx("div", { className: "o-customize-foot-rows", "data-slot": "vk-customize-columns-foot", children: columnsFoot })] }));
363
+ const backFromColumn = () => { setBack(true); setFocusTo(col ? { slot: "vk-customize-column", key: col.id } : null); setColumn(null); setChoosing(null); };
287
364
  const columnLevel = col && (_jsxs(_Fragment, { children: [ownSettings(col.settings ?? { choices: [], toggles: [] }, col.label, col.locked ? [] : [{ kind: "check", label: w.columnShown, checked: held[col.id] ?? col.shown, onCheckedChange: (on) => press([col.id], on), ...part("vk-customize-toggle", "shown") }], { list: w.columnSettings(col.label) }), col.rows != null && _jsxs("div", { className: "o-customize-rows", "data-slot": "vk-customize-rows", "data-key": col.id, children: [(!col.locked || columnOpensBySettings(col)) && _jsx("div", { role: "separator", className: "o-list-sep" }), col.rows] })] }));
288
365
  const rowsOfField = (label, rows) => (phone
289
366
  ? _jsx(MenuList, { label: label, entries: rows, words: w.rows }) : _jsx(MenuListPanelRows, { label: label, entries: rows, ticks: "box", words: w.rows }));
@@ -302,28 +379,32 @@ export function useCustomize(props) {
302
379
  const foldedScreen = folded && _jsx(_Fragment, { children: phone
303
380
  ? _jsx(MenuList, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows })
304
381
  : _jsx(MenuListPanelRows, { label: w.filter, entries: [...fieldEntries(filterFields), ...fieldEntries(afterFields)], onOpen: opened, words: w.rows }) });
382
+ const pageBody = (key) => { const p = appPage(key)?.page; return typeof p === "function" ? p(goBack) : p; };
305
383
  const content = screen === "list"
306
384
  ? phone ? _jsx(MenuList, { label: w.list, entries: sections, onOpen: opened, words: w.rows }) : _jsx(MenuListPanelRows, { label: w.list, entries: sections, ticks: "switch", onOpen: opened, words: w.rows })
307
385
  : screen === "layout" ? choiceLevel ?? layoutScreen : screen === "columns" ? choiceLevel ?? columnLevel ?? columnsScreen
308
- : screen === "filter" && (field || folded) ? fieldScreen ?? foldedScreen : handed[screen]?.opens;
309
- const form = phone ? "phone" : "computer";
386
+ : screen === "filter" && (field || folded) ? fieldScreen ?? foldedScreen
387
+ : screen.startsWith("page:") ? pageBody(screen.slice("page:".length)) : handed[screen]?.opens;
310
388
  const fieldLevel = field && "body" in field.opens ? field.opens.level ?? null : null;
311
- const level = choice ? { name: choice.label, back: backFromChoice } : col ? { name: col.label, back: backFromColumn }
312
- : field ? fieldLevel ?? { name: field.label, back: backFromField } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
389
+ const choiceName = choice && (screen === "layout" ? keysIn(layoutItems).get(keyOf.choice(choice.key))?.label : undefined);
390
+ const level = choice ? { name: choiceName ?? choice.label, back: backFromChoice } : col ? { name: col.label, back: backFromColumn }
391
+ : field ? fieldLevel ?? { name: labelOf(keyOf.field(field.key)) ?? field.label, back: backFromField } : screen !== "list" ? handed[screen]?.level ?? null : null, backTo = level?.back ?? goBack;
313
392
  const named = worn.head === "name" && view.name !== "";
314
- const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? NAMES[screen];
393
+ const name = screen === "list" ? (named ? view.name : w.title) : level?.name ?? (ownPage(screen) ? labelOf(screen) ?? NAMES[screen] : labelOf(screen.slice("page:".length)) ?? "");
315
394
  const titled = !named;
395
+ const pageReset = ownPage(screen) && !level ? (resets ? resets[screen] : screen === "columns" ? columnsReset : undefined) : undefined;
396
+ const pageWords = (size) => pageReset && (_jsx("div", { className: "o-customize-words", "data-slot": "vk-customize-changes", children: _jsx(Button, { kind: "link", size: size, "data-slot": "vk-customize-action", "data-key": "page-reset", onClick: pageReset, disabled: pending, children: w.reset }) }));
316
397
  const step = choice ? (col ? `columns:${col.id}:${choice.key}` : `layout:${choice.key}`) : col ? `columns:${col.id}` : field ? `field:${field.key}` : screen;
317
398
  if (phone) {
318
399
  const body = (_jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(SheetStep, { step: step, back: back, children: _jsx("div", { className: "o-customize-step", children: content }) }) }));
319
- const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", "data-slot": "vk-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : undefined;
400
+ const foot = screen === "list" && (changed || footer.length) ? (_jsxs("div", { className: "o-customize-foot", "data-slot": "vk-customize-foot", ...MENU_LIST_CARD_FRAME, children: [changed && words("44"), footer.length > 0 && _jsx(MenuList, { label: w.share, entries: footer, words: w.rows })] })) : pageReset ? _jsx("div", { className: "o-customize-foot", "data-slot": "vk-customize-foot", ...MENU_LIST_CARD_FRAME, children: pageWords("44") }) : undefined;
320
401
  return { body, title: name, head: screen === "list" ? { close: true } : { onBack: backTo, close: titled }, foot, level };
321
402
  }
322
403
  const title = (words) => (inPane ? _jsx(PaneTitle, { children: words }) : _jsx("h2", { className: "o-pane-title", children: words }));
323
404
  const xButton = (extra) => _jsx(Button, { kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-close", "aria-label": w.close, icon: _jsx(Icon, { name: "x" }), ...extra });
324
405
  const close = inPane ? _jsx(PaneClose, { render: xButton() }) : onClose ? xButton({ onClick: onClose }) : null;
325
- const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", "data-slot": "vk-customize-head", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-back", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", "data-slot": "vk-customize-head", children: [_jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", "data-slot": "vk-customize-head", children: [hasLayout && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "data-slot": "vk-customize-layout-button", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
326
- const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), footer.length > 0 && _jsx(PaneFoot, { "data-slot": "vk-customize-foot", children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
406
+ const head = screen !== "list" ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-screen", "data-slot": "vk-customize-head", children: [_jsx(Button, { ref: backButton, kind: "quiet", shape: "icon", size: "sm", "data-slot": "vk-customize-back", "aria-label": w.back, icon: _jsx(Icon, { name: "left" }), onClick: backTo }), _jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(name) }), titled && close] })) : titled ? (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-title", "data-slot": "vk-customize-head", children: [_jsx("span", { className: "o-customize-title", "data-slot": "vk-customize-title", children: title(w.title) }), close] })) : (_jsxs(PaneHead, { className: "o-customize-head o-customize-head-name", "data-slot": "vk-customize-head", children: [hasLayout && onList("layout") && _jsx(Button, { kind: "outline", shape: "icon", size: "sm", "data-slot": "vk-customize-layout-button", "aria-label": w.layoutButton(layout?.name ?? ""), icon: layout?.mark, onClick: () => go("layout") }), _jsx(ViewName, { name: view.name, label: w.viewName, onRename: (n) => change({ ...latest.view, name: n }) })] }));
407
+ const parts = (_jsxs(_Fragment, { children: [head, screen === "columns" && !col && columnsSearch, _jsx(PaneBody, { children: _jsx("div", { ref: placeRoot, className: "o-customize", "data-slot": "vk-customize", "data-kit": "customize", "data-customize-form": form, "data-customize-screen": screen, ...phoneMark(!!host || small), ...MENU_LIST_CARD_FRAME, children: _jsx(React.Fragment, { children: content }, step) }) }), screen === "list" && changed && words("xs"), pageWords("xs"), footer.length > 0 && _jsx(PaneFoot, { "data-slot": "vk-customize-foot", children: _jsx(MenuListPanelRows, { label: w.share, entries: footer, words: w.rows }) })] }));
327
408
  return { body: inPane ? parts : _jsx("div", { className: "o-customize-frame", children: parts }), title: name, head: {}, level };
328
409
  }
329
410
  function ViewName({ name, label, onRename }) {
@@ -0,0 +1,49 @@
1
+ import type * as React from "react";
2
+ import type { ViewsCustomizeItem, ViewsCustomizeItems, ViewsCustomizeItemsContext } from "../../provider/components.js";
3
+ import type { MenuListEntry } from "../menu-list/menu-list.js";
4
+ import type { CustomizeField, CustomizeLayoutSettings, CustomizeToggle } from "./customize.js";
5
+ /** ViewKit's own entry for each default key, built by the kit with its whole behaviour. */
6
+ export type OwnRows = Map<string, MenuListEntry>;
7
+ /** The one place the prefixed keys are made. */
8
+ export declare const keyOf: {
9
+ field: (k: string) => string;
10
+ fields: (s: string) => string;
11
+ toggle: (k: string) => string;
12
+ toggles: (s: string) => string;
13
+ choice: (k: string) => string;
14
+ };
15
+ /** A section of Customize's list, as its row says it. */
16
+ export type CustomizeSectionItem = {
17
+ key: "layout" | "columns" | "filter" | "sort" | "group";
18
+ label: string;
19
+ icon?: React.ReactNode;
20
+ detail?: string;
21
+ inForce?: boolean;
22
+ };
23
+ /** The list's rows in today's order: Layout, Columns, the filter fields (unless folded behind Filter), Filter, Sort, Group, the
24
+ * fields after them, then the toggles under a divider (Show counts from the view where no toggles are handed). A line follows
25
+ * the filter fields' sections, as the list draws them. */
26
+ export declare function listItemsOf(sections: CustomizeSectionItem[], fields: {
27
+ filters: CustomizeField[];
28
+ after: CustomizeField[];
29
+ folded: boolean;
30
+ }, toggles: CustomizeToggle[] | null, w: {
31
+ showCounts: string;
32
+ }, counts: boolean): ViewsCustomizeItem[];
33
+ /** Layout's rows: its pick-one settings, its toggles, each section of toggles as a group; with none handed, a table's Freeze
34
+ * and Wrap. */
35
+ export declare function layoutItemsOf(settings: CustomizeLayoutSettings | undefined, table: {
36
+ freeze: boolean;
37
+ wrap: boolean;
38
+ words: {
39
+ freeze: string;
40
+ wrap: string;
41
+ };
42
+ } | null): ViewsCustomizeItem[];
43
+ /** The app's function over a page's defaults, a key handed twice kept once (the first, at any depth). */
44
+ export declare function shapeItems(defaults: ViewsCustomizeItem[], fn: ViewsCustomizeItems | undefined, ctx: ViewsCustomizeItemsContext): ViewsCustomizeItem[];
45
+ /** The entries the items draw (Decision 4 of the plan): disabled first, then a section, then a default key, then the app's. */
46
+ export declare function entriesOf(items: ViewsCustomizeItem[], own: OwnRows, opts: {
47
+ onList: boolean;
48
+ unavailable: string;
49
+ }): MenuListEntry[];
@@ -0,0 +1,104 @@
1
+ export const keyOf = {
2
+ field: (k) => `field:${k}`,
3
+ fields: (s) => `fields:${s}`,
4
+ toggle: (k) => `toggle:${k}`,
5
+ toggles: (s) => `toggles:${s}`,
6
+ choice: (k) => `choice:${k}`,
7
+ };
8
+ const fieldItem = (f) => ({
9
+ key: keyOf.field(f.key), label: f.label, ...(f.icon != null && { icon: f.icon }), detail: f.says, ...(f.inForce !== undefined && { inForce: f.inForce }),
10
+ ...(f.disabled != null && { disabled: true, disabledReason: f.disabled }),
11
+ });
12
+ const fieldItems = (fs) => {
13
+ const heads = [...new Set(fs.flatMap((f) => (f.section ? [f.section] : [])))];
14
+ return [...fs.filter((f) => !f.section).map(fieldItem),
15
+ ...heads.map((s) => ({ key: keyOf.fields(s), label: s, children: fs.filter((f) => f.section === s).map(fieldItem) }))];
16
+ };
17
+ const toggleItem = (t) => ({ key: keyOf.toggle(t.key), label: t.label, checked: t.value, ...(t.icon != null && { icon: t.icon }) });
18
+ const toggleItems = (ts) => {
19
+ const heads = [...new Set(ts.flatMap((t) => (t.section ? [t.section] : [])))];
20
+ return [...ts.filter((t) => !t.section).map(toggleItem),
21
+ ...heads.map((s) => ({ key: keyOf.toggles(s), label: s, children: ts.filter((t) => t.section === s).map(toggleItem) }))];
22
+ };
23
+ const opening = (items) => (items.length ? [{ ...items[0], separatorBefore: true }, ...items.slice(1)] : items);
24
+ export function listItemsOf(sections, fields, toggles, w, counts) {
25
+ const section = (s) => ({ key: s.key, label: s.label, ...(s.icon != null && { icon: s.icon }), ...(s.detail !== undefined && { detail: s.detail }), ...(s.inForce !== undefined && { inForce: s.inForce }) });
26
+ const head = sections.filter((s) => s.key === "layout" || s.key === "columns").map(section);
27
+ const mid = sections.filter((s) => s.key !== "layout" && s.key !== "columns").map(section);
28
+ const filters = fields.folded ? [] : fieldItems(fields.filters);
29
+ const lined = fields.filters.some((f) => f.section) && !fields.folded;
30
+ const after = fields.folded ? [] : fieldItems(fields.after);
31
+ const checks = toggles ? toggleItems(toggles) : [{ key: keyOf.toggle("counts"), label: w.showCounts, checked: counts }];
32
+ const rest = [...mid, ...after];
33
+ return [...head, ...filters, ...(lined ? opening(rest) : rest), ...opening(checks)];
34
+ }
35
+ export function layoutItemsOf(settings, table) {
36
+ if (settings) {
37
+ const choice = (c) => {
38
+ const now = c.options.find((o) => o.value === c.value);
39
+ return { key: keyOf.choice(c.key), label: c.label, ...(now && { detail: now.label }) };
40
+ };
41
+ return [...settings.choices.map(choice),
42
+ ...toggleItems(settings.toggles)];
43
+ }
44
+ return table ? [{ key: keyOf.toggle("freeze"), label: table.words.freeze, checked: table.freeze }, { key: keyOf.toggle("wrap"), label: table.words.wrap, checked: table.wrap }] : [];
45
+ }
46
+ export function shapeItems(defaults, fn, ctx) {
47
+ if (!fn)
48
+ return defaults;
49
+ const seen = new Set();
50
+ const once = (items) => items.flatMap((i) => {
51
+ if (seen.has(i.key))
52
+ return [];
53
+ seen.add(i.key);
54
+ return [i.children ? { ...i, children: once(i.children) } : i];
55
+ });
56
+ return once(fn(defaults, ctx));
57
+ }
58
+ function laid(entry, item) {
59
+ if ("kind" in entry && entry.kind === "separator")
60
+ return entry;
61
+ const kind = "kind" in entry ? entry.kind : "action";
62
+ const next = { ...entry, label: item.label };
63
+ if (item.icon !== undefined)
64
+ next.icon = item.icon;
65
+ if (item.detail !== undefined && (kind === "actions" || kind === "choices"))
66
+ next.detail = item.detail;
67
+ if (item.inForce !== undefined && kind === "actions")
68
+ next.inForce = item.inForce;
69
+ return next;
70
+ }
71
+ export function entriesOf(items, own, opts) {
72
+ const out = [];
73
+ for (const item of items) {
74
+ const at = out.length;
75
+ const mine = own.get(item.key);
76
+ const ownSlot = mine && "slot" in mine ? mine.slot : undefined;
77
+ const slot = ownSlot ?? { slot: "vk-customize-row", key: item.key };
78
+ if (item.disabled) {
79
+ out.push({ icon: item.icon ?? null, label: item.label, disabled: item.disabledReason || opts.unavailable, slot });
80
+ }
81
+ else if (item.children !== undefined || item.key.startsWith("toggles:") || item.key.startsWith("fields:")) {
82
+ const entries = entriesOf(item.children ?? [], own, opts);
83
+ if (entries.length)
84
+ out.push({ kind: "group", heading: item.label, entries });
85
+ }
86
+ else if (mine) {
87
+ out.push(laid(mine, item));
88
+ }
89
+ else if (item.page !== undefined && opts.onList) {
90
+ out.push({ kind: "actions", icon: item.icon ?? null, label: item.label, entries: [], ...(item.detail !== undefined && { detail: item.detail }),
91
+ ...(item.inForce !== undefined && { inForce: item.inForce }), slot: { slot: "vk-customize-page", key: item.key } });
92
+ }
93
+ else if (item.checked !== undefined) {
94
+ const onSelect = item.onSelect;
95
+ out.push({ kind: "check", label: item.label, ...(item.icon != null && { icon: item.icon }), checked: item.checked, onCheckedChange: () => onSelect?.(), slot });
96
+ }
97
+ else {
98
+ out.push({ icon: item.icon ?? null, label: item.label, ...(item.onSelect && { onSelect: item.onSelect }), ...(item.destructive && { danger: true }), slot });
99
+ }
100
+ if (item.separatorBefore && at > 0 && out.length > at)
101
+ out.splice(at, 0, { kind: "separator" });
102
+ }
103
+ return out;
104
+ }