viewkitjs 0.35.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 (134) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/MIGRATION.md +7 -0
  3. package/package.json +1 -1
  4. package/views/dist/contract.d.ts +18 -1
  5. package/views/dist/contract.js +21 -0
  6. package/views/dist/controls/avatar/avatar.d.ts +3 -1
  7. package/views/dist/controls/avatar/avatar.js +2 -2
  8. package/views/dist/controls/compound-editor/map-parts-body.js +2 -0
  9. package/views/dist/controls/compound-editor/name-parts.js +1 -1
  10. package/views/dist/controls/compound-editor/place-parts.js +1 -1
  11. package/views/dist/controls/compound-editor/range-parts.js +1 -1
  12. package/views/dist/controls/compound-editor/words.d.ts +3 -0
  13. package/views/dist/controls/compound-editor/words.js +2 -0
  14. package/views/dist/controls/customize/customize.d.ts +10 -3
  15. package/views/dist/controls/customize/customize.js +147 -63
  16. package/views/dist/controls/customize/items.d.ts +49 -0
  17. package/views/dist/controls/customize/items.js +104 -0
  18. package/views/dist/controls/customize/map-customize-body.js +7 -4
  19. package/views/dist/controls/customize/words.d.ts +2 -0
  20. package/views/dist/controls/customize/words.js +1 -0
  21. package/views/dist/controls/filter-editor/block.js +5 -2
  22. package/views/dist/controls/filter-editor/filter-editor.d.ts +14 -1
  23. package/views/dist/controls/filter-editor/filter-editor.js +19 -11
  24. package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
  25. package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
  26. package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
  27. package/views/dist/controls/filter-editor/map-rules.js +18 -13
  28. package/views/dist/controls/filter-editor/parts.js +12 -11
  29. package/views/dist/controls/filter-editor/rules.d.ts +4 -4
  30. package/views/dist/controls/filter-editor/rules.js +6 -3
  31. package/views/dist/controls/filter-editor/words.d.ts +2 -0
  32. package/views/dist/controls/filter-editor/words.js +1 -0
  33. package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
  34. package/views/dist/controls/group-editor/group-editor.js +21 -15
  35. package/views/dist/controls/group-editor/map-group-body.js +1 -0
  36. package/views/dist/controls/index.d.ts +1 -1
  37. package/views/dist/controls/internal/kit-words.d.ts +11 -0
  38. package/views/dist/controls/internal/kit-words.js +7 -0
  39. package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
  40. package/views/dist/controls/internal/map-panel-controls.js +14 -1
  41. package/views/dist/controls/internal/menu-items.d.ts +9 -0
  42. package/views/dist/controls/internal/menu-items.js +97 -0
  43. package/views/dist/controls/internal/panel-controls.js +1 -1
  44. package/views/dist/controls/menu/menu.d.ts +1 -1
  45. package/views/dist/controls/menu/menu.js +1 -1
  46. package/views/dist/controls/number-editor/map-number-body.js +2 -0
  47. package/views/dist/controls/number-editor/number-editor.js +1 -1
  48. package/views/dist/controls/number-editor/words.d.ts +3 -0
  49. package/views/dist/controls/number-editor/words.js +2 -0
  50. package/views/dist/controls/picker/fields-frame.d.ts +5 -0
  51. package/views/dist/controls/picker/fields-frame.js +30 -0
  52. package/views/dist/controls/picker/map-fields-body.js +3 -26
  53. package/views/dist/controls/picker/map-picker.d.ts +2 -1
  54. package/views/dist/controls/picker/map-picker.js +4 -2
  55. package/views/dist/controls/picker/picker.js +9 -2
  56. package/views/dist/controls/picker/rows.d.ts +3 -1
  57. package/views/dist/controls/picker.css +2 -0
  58. package/views/dist/controls/select/map-select.d.ts +1 -1
  59. package/views/dist/controls/select/map-select.js +4 -1
  60. package/views/dist/controls/select/select.d.ts +2 -0
  61. package/views/dist/controls/select/select.js +3 -1
  62. package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
  63. package/views/dist/controls/sheet/bottom-sheet.js +3 -3
  64. package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
  65. package/views/dist/controls/sort-editor/sort-editor.d.ts +3 -1
  66. package/views/dist/controls/sort-editor/sort-editor.js +6 -4
  67. package/views/dist/controls/tag/tag.js +4 -2
  68. package/views/dist/controls/text-editor/map-text-body.js +4 -1
  69. package/views/dist/controls/text-editor/text-editor.js +2 -2
  70. package/views/dist/controls/text-editor/words.d.ts +3 -0
  71. package/views/dist/controls/text-editor/words.js +1 -1
  72. package/views/dist/controls/toolbar/toolbar.d.ts +8 -2
  73. package/views/dist/controls/views-list/map-views-list-body.js +9 -1
  74. package/views/dist/controls/views-list/rules.d.ts +1 -0
  75. package/views/dist/controls/views-list/rules.js +2 -2
  76. package/views/dist/controls/views-list/view-menu.js +2 -2
  77. package/views/dist/controls/views-list/words.d.ts +4 -0
  78. package/views/dist/controls/views-list/words.js +2 -1
  79. package/views/dist/display/option-badges.d.ts +3 -2
  80. package/views/dist/display/option-badges.js +2 -2
  81. package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
  82. package/views/dist/grid/chrome/GridAddColumn.js +5 -4
  83. package/views/dist/grid/chrome/GridHeader.js +3 -1
  84. package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
  85. package/views/dist/grid/chrome/GridRow.js +7 -1
  86. package/views/dist/grid/chrome/GridTableSurface.js +2 -1
  87. package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
  88. package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
  89. package/views/dist/grid/chrome/grid-table-props.d.ts +6 -2
  90. package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
  91. package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
  92. package/views/dist/grid/grid-format-props.d.ts +1 -1
  93. package/views/dist/grid/grid-format-props.js +18 -5
  94. package/views/dist/grid/grid.css +5 -1
  95. package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
  96. package/views/dist/grid/useGridTableSettings.d.ts +1 -1
  97. package/views/dist/list/list.js +2 -2
  98. package/views/dist/list/menu.d.ts +5 -4
  99. package/views/dist/list/toolbar.js +5 -3
  100. package/views/dist/panels/customize-body.d.ts +1 -1
  101. package/views/dist/panels/customize-body.js +8 -1
  102. package/views/dist/panels/model.d.ts +5 -0
  103. package/views/dist/panels/react/customize-body.js +11 -2
  104. package/views/dist/panels/react/customize.d.ts +3 -0
  105. package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
  106. package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
  107. package/views/dist/panels/react/filter/filter-body.js +3 -1
  108. package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
  109. package/views/dist/panels/react/filter/filter-part-body.js +2 -2
  110. package/views/dist/panels/react/sort/SortEditor.js +3 -1
  111. package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +9 -1
  112. package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
  113. package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +4 -1
  114. package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
  115. package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
  116. package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
  117. package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
  118. package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
  119. package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
  120. package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
  121. package/views/dist/panels/react/views-row/ViewPicker.js +6 -9
  122. package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
  123. package/views/dist/panels/react/views-row/new-view.js +21 -0
  124. package/views/dist/provider/components.d.ts +82 -2
  125. package/views/dist/react.d.ts +1 -1
  126. package/views/dist/styles.css +18 -5
  127. package/views/dist/styles.unlayered.css +18 -5
  128. package/views/docs/contract.md +19 -12
  129. package/views/docs/reference/controls.md +13 -12
  130. package/views/docs/reference/grid.md +4 -4
  131. package/views/docs/reference/list.md +25 -5
  132. package/views/docs/reference/panels-react.md +3 -3
  133. package/views/docs/reference/panels.md +1 -1
  134. package/views/docs/reference/react.md +16 -4
@@ -240,8 +240,8 @@ export function useTextEditor(props) {
240
240
  if (shell)
241
241
  return { body, head: {} };
242
242
  const head = {
243
- left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": "Close", icon: glyph(X), onClick: leave }),
244
- right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": "Save", icon: glyph(TICK), onClick: keep }),
243
+ left: _jsx(SheetButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: leave }),
244
+ right: _jsx(SheetButton, { "data-slot": "vk-editor-save", kind: "primary", "aria-label": w.save, icon: glyph(TICK), onClick: keep }),
245
245
  };
246
246
  return { body, head };
247
247
  }
@@ -4,6 +4,9 @@ export interface TextEditorWords {
4
4
  country: string;
5
5
  /** The countries' search. */
6
6
  searchCountry: string;
7
+ /** A phone's head where no holder keeps the draft: its ✕ and ✓ (VK-997). */
8
+ close: string;
9
+ save: string;
7
10
  /** The words of the countries' list. */
8
11
  picker?: Partial<PickerWords>;
9
12
  }
@@ -1,2 +1,2 @@
1
- export const TEXT_EDITOR_WORDS = { country: "Country", searchCountry: "Search for a country" };
1
+ export const TEXT_EDITOR_WORDS = { country: "Country", searchCountry: "Search for a country", close: "Close", save: "Save" };
2
2
  export const textWords = (given) => (given ? { ...TEXT_EDITOR_WORDS, ...given } : TEXT_EDITOR_WORDS);
@@ -80,16 +80,22 @@ export interface ToolbarProps extends Omit<BaseToolbar.Root.Props, "className" |
80
80
  className?: string;
81
81
  style?: React.CSSProperties;
82
82
  }
83
+ /** What the Toolbar hands an app's own button (⋯, "+N", "+N filters"): a Toolbar button's props, its `style` a plain one, never
84
+ * Base UI's state function, so the app spreads them onto a plain `<button>` with no cast (VK-1060). A button typed with
85
+ * `ToolbarButtonProps` is still taken. */
86
+ export type ToolbarOwnButtonProps = Omit<ToolbarButtonProps, "style"> & {
87
+ style?: React.CSSProperties;
88
+ };
83
89
  /** ⋯ as the app draws it: its glyph, its class, or its whole button, handed a Toolbar button's props. */
84
90
  export type ToolbarOverflowControl = {
85
91
  icon?: React.ReactNode;
86
92
  className?: string;
87
- button?: React.ComponentType<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
93
+ button?: React.ComponentType<ToolbarOwnButtonProps & React.RefAttributes<HTMLButtonElement>>;
88
94
  };
89
95
  /** "+N" or "+N filters" as the app draws it: its class, or its whole button, handed a Toolbar button's props (VK-1037). */
90
96
  export type ToolbarMoreControl = {
91
97
  className?: string;
92
- button?: React.ComponentType<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
98
+ button?: React.ComponentType<ToolbarOwnButtonProps & React.RefAttributes<HTMLButtonElement>>;
93
99
  };
94
100
  type Step = {
95
101
  i: number;
@@ -15,6 +15,7 @@ import { PanelHeadButton } from "../internal/head-button.js";
15
15
  import { PanelControlsFromViews } from "../internal/map-panel-controls.js";
16
16
  import { SheetPartsFrom } from "../sheet/sheet-parts.js";
17
17
  import { Icon } from "../internal/icons.js";
18
+ import { glyph, X } from "../internal/editor-parts.js";
18
19
  export function viewsListWordsOf(say, createLabel) {
19
20
  return {
20
21
  label: say({ key: "views.panels.views-list" }),
@@ -102,6 +103,8 @@ export function viewMenuWordsOf(say) {
102
103
  copyOf: (name) => say({ key: "views.panels.view-copy-name", values: { name } }),
103
104
  stay: (records) => say({ key: "views.panels.view-delete-stays", values: { records } }),
104
105
  goes: say({ key: "views.panels.view-delete-goes" }),
106
+ goesOwn: say({ key: "views.panels.view-delete-goes-own" }),
107
+ notNow: say({ key: "views.menus.not-now" }),
105
108
  columns: (layout) => say({ key: "views.panels.view-columns", values: { layout } }),
106
109
  };
107
110
  }
@@ -117,7 +120,12 @@ function useStepHead(step, props) {
117
120
  const setParts = React.useContext(SheetPartsFrom);
118
121
  React.useLayoutEffect(() => { setParts?.(step ? { title: step.title, head: { onBack: step.onBack } } : null); });
119
122
  React.useLayoutEffect(() => () => setParts?.(null), [setParts]);
120
- return step && props.actions?.back && !setParts ? (_jsx("div", { className: "o-sheet-head", "data-slot": "vk-views-list-head", children: _jsx(HeaderBar, { className: "o-sheet-row", "data-sides": "", title: _jsx("h2", { className: "o-sheet-title", children: step.title }), right: _jsx("span", {}), left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": props.actions.back.label, className: "o-sheet-back", icon: _jsx(Icon, { name: "left" }), onClick: props.actions.back.onPress }) }) })) : null;
123
+ const actions = props.actions;
124
+ if (!actions || setParts)
125
+ return null;
126
+ if (step)
127
+ return actions.back ? (_jsx("div", { className: "o-sheet-head", "data-slot": "vk-views-list-head", children: _jsx(HeaderBar, { className: "o-sheet-row", "data-sides": "", title: _jsx("h2", { className: "o-sheet-title", children: step.title }), right: _jsx("span", {}), left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": actions.back.label, className: "o-sheet-back", icon: _jsx(Icon, { name: "left" }), onClick: actions.back.onPress }) }) })) : null;
128
+ return (_jsx("div", { className: "o-sheet-head", "data-slot": "vk-views-list-head", children: _jsx(HeaderBar, { className: "o-sheet-row", "data-sides": "", title: _jsx("h2", { className: "o-sheet-title", children: props.label }), right: _jsx("span", {}), left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }) }) }));
121
129
  }
122
130
  function Plain(props) {
123
131
  const context = React.useContext(ViewsContext);
@@ -85,6 +85,7 @@ export declare const canDelete: (views: ListView[]) => boolean;
85
85
  export type DeleteLineWords = {
86
86
  stay: (records: string) => string;
87
87
  goes: string;
88
+ goesOwn: string;
88
89
  };
89
90
  /** The delete question's line: the view goes for everyone who uses it (a private view only for its maker), and the records stay. */
90
91
  export declare function deleteLine(view: ListView, records: string, words?: DeleteLineWords): string;
@@ -12,10 +12,10 @@ export function copyName(name, names, copyOf = (n) => `Copy of ${n}`) {
12
12
  return `${base} ${n}`;
13
13
  }
14
14
  export const canDelete = (views) => views.length > 1;
15
- const DELETE_LINE = { stay: (records) => `The ${records} in it stay as they are.`, goes: "The view goes for everyone who uses it." };
15
+ const DELETE_LINE = { stay: (records) => `The ${records} in it stay as they are.`, goes: "The view goes for everyone who uses it.", goesOwn: "The view goes only for you." };
16
16
  export function deleteLine(view, records, words = DELETE_LINE) {
17
17
  const stay = words.stay(records);
18
- return view.private ? stay : `${words.goes} ${stay}`;
18
+ return `${view.private ? words.goesOwn : words.goes} ${stay}`;
19
19
  }
20
20
  export const columnsLabel = (layoutName, words = (l) => `${l} columns`) => words(layoutName);
21
21
  const set = (views, id, change) => views.map((v) => (v.id === id ? { ...v, ...change } : v));
@@ -107,7 +107,7 @@ export function useViewMenu(props) {
107
107
  onDone?.();
108
108
  say(w.deleted(view.name), () => onChange({ kind: "restore", view, at, open: wasOpen }));
109
109
  };
110
- const lineOf = (v) => deleteLine(worn.privateViews ? v : { ...v, private: false }, records, { stay: w.stay, goes: w.goes });
110
+ const lineOf = (v) => deleteLine(v, records, { stay: w.stay, goes: w.goes, goesOwn: w.goesOwn });
111
111
  const askDelete = (id) => {
112
112
  const v = viewOf(id);
113
113
  if (!stepping && askPort && v) {
@@ -150,7 +150,7 @@ export function useViewMenu(props) {
150
150
  ];
151
151
  return props.reshape ? props.reshape(all, id) : all;
152
152
  };
153
- const entries = (id) => menuEntries(items(id), undefined, "vk-view-menu-row");
153
+ const entries = (id) => menuEntries(items(id), w.notNow, "vk-view-menu-row");
154
154
  const where = props.container ?? undefined, standing = props.standing;
155
155
  const target = asked && (asked.what === "rename" || asked.what === "delete" || asked.what === "menu") ? viewOf(asked.id) : undefined;
156
156
  const asking = shown;
@@ -72,6 +72,10 @@ export interface ViewMenuWords {
72
72
  copyOf: (name: string) => string;
73
73
  stay: (records: string) => string;
74
74
  goes: string;
75
+ /** The delete question's line on a person's own view (VK-959). */
76
+ goesOwn: string;
77
+ /** Why a row that can't be used, and gives no reason of its own, can't be (VK-997). */
78
+ notNow: string;
75
79
  columns: (layout: string) => string;
76
80
  }
77
81
  /** A view's menu's words in English. */
@@ -8,5 +8,6 @@ export const VIEW_MENU_WORDS = {
8
8
  thisView: "This view", renameTitle: "Rename view", save: "Save", newView: "New view", createView: "Create view", layout: "Layout", name: "Name",
9
9
  cancel: "Cancel", close: "Close", failed: "That didn't go through. Nothing changed.", tryAgain: "Try again",
10
10
  deleteTitle: (name) => `Delete ${name}?`, deleted: (name) => `${name} was deleted`, copyOf: (name) => `Copy of ${name}`,
11
- stay: (records) => `The ${records} in it stay as they are.`, goes: "The view goes for everyone who uses it.", columns: (layout) => `${layout} columns`,
11
+ stay: (records) => `The ${records} in it stay as they are.`, goes: "The view goes for everyone who uses it.", goesOwn: "The view goes only for you.", notNow: "Not now",
12
+ columns: (layout) => `${layout} columns`,
12
13
  };
@@ -8,9 +8,10 @@ export declare function OptionStatus({ slot, label, icon, place, }: {
8
8
  icon?: string;
9
9
  place?: ViewsStatusPlace;
10
10
  }): import("react/jsx-runtime").JSX.Element;
11
- /** A category option as its cell draws it. */
12
- export declare function OptionCategory({ label, color, icon }: {
11
+ /** A category option as its cell draws it; handed a remove, as an editor draws it held, with its ×. */
12
+ export declare function OptionCategory({ label, color, icon, onRemove }: {
13
13
  label: string;
14
14
  color: CategoryColor;
15
15
  icon?: string;
16
+ onRemove?: () => void;
16
17
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ export function OptionStatus({ slot, label, icon, place, }) {
5
5
  const { atoms: { StatusBadge }, components: { AppIcon }, } = useViews();
6
6
  return (_jsx(StatusBadge, { slot: slot, label: label, place: place, size: "row", className: "border-0", leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
7
7
  }
8
- export function OptionCategory({ label, color, icon }) {
8
+ export function OptionCategory({ label, color, icon, onRemove }) {
9
9
  const { atoms: { Tag }, components: { AppIcon }, } = useViews();
10
- return (_jsx(Tag, { label: label, color: color, leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined }));
10
+ return (_jsx(Tag, { label: label, color: color, leading: icon ? _jsx(AppIcon, { name: icon, className: "size-3 shrink-0" }) : undefined, ...(onRemove ? { onRemove } : {}) }));
11
11
  }
@@ -1,12 +1,15 @@
1
1
  import { type ReactNode } from "react";
2
+ import type { ViewsMenuItem } from "../../provider/components.js";
2
3
  import type { ListColumnsConfig } from "../../model/column-state.js";
3
4
  /** An app's own "+ Add column": a node, `null` for none, anything else falsy for the grid's own. */
4
5
  type RenderAddColumn = ((columns: ListColumnsConfig) => ReactNode) | undefined;
6
+ /** The app's function from + Add column's rows to the rows it shows (`menus.addColumn`, its columns already handed). */
7
+ type Reshape = (items: ViewsMenuItem[]) => ViewsMenuItem[];
5
8
  /** Whether the header row ends in an Add column: not where the app's own answers `null`. */
6
9
  export declare function gridAddColumnDrawn(render: RenderAddColumn, columns: ListColumnsConfig): boolean;
7
10
  /** The header's Add column: the app's own, none where it answers `null`, else the grid's own, drawn for where it
8
11
  * stands (`at`: the row's last cell, or a lone + in the title column's header). */
9
- export declare function gridAddColumnNode(render: RenderAddColumn, columns: ListColumnsConfig, at?: "end" | "title"): ReactNode | null;
12
+ export declare function gridAddColumnNode(render: RenderAddColumn, columns: ListColumnsConfig, at?: "end" | "title", reshape?: Reshape): ReactNode | null;
10
13
  /**
11
14
  * "+ ADD COLUMN" ON EVERY GRID: the header row's last cell, for anyone who reads the list. It lists the columns
12
15
  * this view hides and can show, and shows the one picked: a choice about the reader's own view, never a change
@@ -15,8 +18,10 @@ export declare function gridAddColumnNode(render: RenderAddColumn, columns: List
15
18
  * the host's instead (a relation's ›, Create new field), in the same look. Hiding is a column's own menu, the
16
19
  * order is dragging the header, and the whole list is the host's column list.
17
20
  */
18
- export declare function GridAddColumn({ columns, at, }: {
21
+ export declare function GridAddColumn({ columns, at, reshape, }: {
19
22
  columns: ListColumnsConfig;
23
+ /** The app's function from its rows to the rows it shows (`menus.addColumn`). */
24
+ reshape?: Reshape;
20
25
  /** Where it stands: the header row's last cell, its words beside the +, or the title column's header, a lone
21
26
  * round + at its right edge (`addColumnAt`). */
22
27
  at?: "end" | "title";
@@ -8,13 +8,13 @@ import { returnGridFocus, useGridMenuPress } from "./grid-menu-focus.js";
8
8
  export function gridAddColumnDrawn(render, columns) {
9
9
  return render?.(columns) !== null;
10
10
  }
11
- export function gridAddColumnNode(render, columns, at = "end") {
11
+ export function gridAddColumnNode(render, columns, at = "end", reshape) {
12
12
  const own = render?.(columns);
13
13
  if (own === null)
14
14
  return null;
15
- return own || _jsx(GridAddColumn, { columns: columns, at: at });
15
+ return own || _jsx(GridAddColumn, { columns: columns, at: at, ...(reshape && { reshape }) });
16
16
  }
17
- export function GridAddColumn({ columns, at = "end", }) {
17
+ export function GridAddColumn({ columns, at = "end", reshape, }) {
18
18
  const inTitle = at === "title";
19
19
  const [open, setOpen] = useState(false);
20
20
  const [anchor, setAnchor] = useState(null);
@@ -31,7 +31,8 @@ export function GridAddColumn({ columns, at = "end", }) {
31
31
  if (anchor && reason !== "outside-press" && reason !== "focus-out")
32
32
  returnGridFocus(anchor);
33
33
  }
34
- const items = open ? gridAddColumnItems(columns, { messages, close: () => close("item-press") }) : leaving;
34
+ const built = open ? gridAddColumnItems(columns, { messages, close: () => close("item-press") }) : null;
35
+ const items = built ? (reshape ? reshape(built) : built) : leaving;
35
36
  return (_jsxs(_Fragment, { children: [drawGridButton(views, {
36
37
  ref: setAnchor,
37
38
  tabIndex: -1,
@@ -19,7 +19,9 @@ import { timeShown } from "../../display/format.js";
19
19
  export function GridHeader({ showAddColumn = false, addColumnAt = "end", checkbox, checkColumnId, groupKey, ariaRowIndex, ariaLevel, ariaColOffset = 0, ariaTailIndex, columns, columnManager, minWidth, sort, sortMark = false, selectValues, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnStateEnabled, listConfig, groupBy, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, headerDrag, frozenCount = 0, frozenLeft, verticalBorders = true, headerVerticalBorders = false, viewBacked = false, formatsWritable, renderAddColumn, columnMenuItems, menus, openColumnMenu, onOpenColumnMenuChange, }) {
20
20
  const { icons, components, messages } = useViews();
21
21
  const headId = useId();
22
- const addColumnNode = columnManager && showAddColumn ? gridAddColumnNode(renderAddColumn, columnManager, addColumnAt) : null;
22
+ const addColumnNode = columnManager && showAddColumn
23
+ ? gridAddColumnNode(renderAddColumn, columnManager, addColumnAt, menus?.addColumn && ((items) => menus.addColumn(items, { columns: columnManager.items })))
24
+ : null;
23
25
  const addColumn = addColumnAt === "end" ? addColumnNode : null;
24
26
  const titleId = addColumnAt === "title" ? columns.find((column) => column.type === "title")?.id : undefined;
25
27
  const titleAddColumn = titleId != null && addColumnNode ? (_jsx("span", { "data-add-column": "", className: "ml-auto flex shrink-0 items-center", onClick: (event) => event.stopPropagation(), children: addColumnNode })) : null;
@@ -32,7 +32,7 @@ export function GridNumberEditor({ title, initial, seed, unit, unitOptions, code
32
32
  form: surface === "sheet" ? "phone" : "computer",
33
33
  }
34
34
  : {}), onRequestClose: close }));
35
- return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", className: cx(GRID_EDITOR_LAYER, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
35
+ return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", className: cx(GRID_EDITOR_LAYER, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
36
36
  }
37
37
  function UnderCellConversion({ figure }) {
38
38
  const ref = useRef(null);
@@ -31,6 +31,12 @@ function GridRowInner(props) {
31
31
  const More = icons.more;
32
32
  const { row, id, columns, selectable, selected, selectedAbove, selecting, toggle, toggleRange, rowClassName, rowHref, onOpenRow, onPrefetchRow, editingEnabled, focusedColId, editingColId, onFocusCell, rowKey, onStartEdit, onRefuseEdit, rowWritable = true, onExtendCell, onAddCell, ariaRowIndex, ariaLevel, ariaPosInSet, ariaSetSize, ariaTailIndex, } = props;
33
33
  const href = rowHref?.(row);
34
+ const offersMenu = selectable ||
35
+ !!props.contextMenu ||
36
+ !!props.rowMenuReshape ||
37
+ !!rowHref ||
38
+ !!props.onRowDelete ||
39
+ !!props.rowActions?.some((action) => !!action.onClick);
34
40
  const canEdit = (col) => editingEnabled && rowWritable && gridColumnHasEditor(col) && columnEffectiveWritable(col, props.listConfig);
35
41
  const refuse = (columnId) => (rowWritable ? onRefuseEdit?.(columnId) : onRefuseEdit?.(columnId, false));
36
42
  const whole = (col, cell) => isWholeTextColumn(col) && gridCellCutOff(cell);
@@ -147,7 +153,7 @@ function GridRowInner(props) {
147
153
  }, onPointerLeave: (e) => {
148
154
  rest.onPointerLeave();
149
155
  hover.onPointerLeave(e);
150
- }, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row), highlight }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: drawGridButton(views, {
156
+ }, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row), highlight }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: offersMenu && drawGridButton(views, {
151
157
  tabIndex: -1,
152
158
  "data-slot": "vk-grid-row-more",
153
159
  "aria-label": messages({ key: "views.grid.row-menu" }),
@@ -5,6 +5,7 @@ import { cx } from "../../internal/cx.js";
5
5
  import { BarRoomContext } from "../../selection/bar-room.js";
6
6
  import { GRID_BLEED } from "./grid-styles.js";
7
7
  import { useBarRoom } from "./useBarRoom.js";
8
+ import { GRID_HEIGHTS } from "./useGridScaleStyles.js";
8
9
  export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, pager, selectionBar, onGuardFocus, gridAria, empty, pinFooter, desktop = true, }) {
9
10
  const endGuardRef = useRef(null);
10
11
  const { room, ownBarRef } = useBarRoom(selecting, rootRef, endGuardRef);
@@ -19,7 +20,7 @@ export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selec
19
20
  paddingBottom: footAt && pinFooter?.flush ? footAt : `calc(${foot} + 0.5rem)`,
20
21
  ...(footAt ? { "--vk-foot-at": footAt } : {}),
21
22
  }, children: [body, loadMore ? (_jsx("div", { role: "row", children: _jsx("div", { role: "gridcell", "aria-colspan": gridAria?.colCount, children: loadMore }) })) : null] }));
22
- const frame = (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: "group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", "data-slot": "vk-grid", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [_jsx("span", { "data-grid-guard": "start", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("start", event.relatedTarget) }), boxes === 2 ? (_jsx("div", { ref: panRef, "data-slot": "vk-grid-pan", className: cx("@container flex min-h-0 flex-1 flex-col", GRID_BLEED), style: { overflowX: "auto", overflowY: "hidden", overscrollBehaviorX: "contain" }, children: _jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: "min-h-0 flex-1", style: {
23
+ const frame = (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: cx("group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", GRID_HEIGHTS), "data-slot": "vk-grid", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [_jsx("span", { "data-grid-guard": "start", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("start", event.relatedTarget) }), boxes === 2 ? (_jsx("div", { ref: panRef, "data-slot": "vk-grid-pan", className: cx("@container flex min-h-0 flex-1 flex-col", GRID_BLEED), style: { overflowX: "auto", overflowY: "hidden", overscrollBehaviorX: "contain" }, children: _jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: "min-h-0 flex-1", style: {
23
24
  overflowX: "hidden",
24
25
  overflowY: "auto",
25
26
  minWidth,
@@ -3,7 +3,8 @@ import { type ReactNode, type RefObject } from "react";
3
3
  * THE IN-PLACE EDITOR'S BOX, AS WIDE AS WHAT IS TYPED IN IT — an amount and its unit, or a line of
4
4
  * text (a link, an email, a phone, a domain, plain text). It is the cell's width until the value doesn't
5
5
  * fit; then it grows past the cell, away from the side the column aligns to (a right-aligned column's
6
- * box grows left, its amount still flush with the column's edge; a text's grows right), up to a cap.
6
+ * box grows left, its amount still flush with the column's edge; a text's grows right), as far as the room beside the
7
+ * cell: the grid's visible edge on that side. Past it, the value scrolls in its box.
7
8
  * Measured as it opens, before the panel brings it into view (a child's layout effect runs first), and
8
9
  * again at every keystroke: the input says by how much its text overflows it, and the box takes that
9
10
  * much more. Grown, it draws the editing cell's frame around itself, over the cell's own, so the editor
@@ -11,11 +12,13 @@ import { type ReactNode, type RefObject } from "react";
11
12
  * An app's body (`edge={false}`) draws its own edge, which grows with the box, so the box draws none; its value shares the
12
13
  * box with a unit or a country, so it keeps `room` to type in even when empty.
13
14
  */
14
- export declare function GridFittedBox({ boxRef, edge, room, children, }: {
15
+ export declare function GridFittedBox({ boxRef, edge, room, grows, children, }: {
15
16
  boxRef: RefObject<HTMLSpanElement | null>;
16
17
  /** The editing cell's frame round the grown box: false where what it holds draws its own edge. */
17
18
  edge?: boolean;
18
19
  /** The pixels the input keeps at least, its value or not: a box that shares the cell with a unit's button. */
19
20
  room?: number;
21
+ /** The side it grows to: right for a text, left for an amount in a right-aligned column (its box at the cell's end). */
22
+ grows?: "left" | "right";
20
23
  children: ReactNode;
21
24
  }): import("react/jsx-runtime").JSX.Element;
@@ -3,8 +3,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useCallback, useLayoutEffect } from "react";
4
4
  import { cx } from "../../internal/cx.js";
5
5
  import { GRID_EDITING_SHADOW, GRID_GROUND } from "./grid-styles.js";
6
- const FITTED_MAX_PX = 320;
7
- export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
6
+ function roomBeside(box, grows) {
7
+ const at = box.getBoundingClientRect();
8
+ if (at.width === 0 && at.height === 0)
9
+ return Infinity;
10
+ const page = { left: 0, right: document.documentElement.clientWidth || window.innerWidth };
11
+ const area = box.closest('[data-slot="vk-grid-scroll"]');
12
+ const seen = area?.getBoundingClientRect();
13
+ const left = seen ? Math.max(page.left, seen.left + area.clientLeft) : page.left;
14
+ const right = seen ? Math.min(page.right, seen.left + area.clientLeft + area.clientWidth) : page.right;
15
+ return Math.floor(grows === "left" ? at.right - left : right - at.left);
16
+ }
17
+ export function GridFittedBox({ boxRef, edge = true, room = 0, grows = "right", children, }) {
8
18
  const fit = useCallback(() => {
9
19
  const box = boxRef.current;
10
20
  const input = box?.querySelector("input");
@@ -12,7 +22,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
12
22
  return;
13
23
  box.style.minWidth = "";
14
24
  const over = Math.max(input.scrollWidth, room) - input.clientWidth;
15
- const width = over > 0 ? Math.min(box.offsetWidth + over + 1, FITTED_MAX_PX) : 0;
25
+ const width = over > 0 ? Math.min(box.offsetWidth + over + 1, roomBeside(box, grows)) : 0;
16
26
  if (width > box.offsetWidth) {
17
27
  box.style.minWidth = `${width}px`;
18
28
  box.dataset.grown = "";
@@ -20,7 +30,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
20
30
  else {
21
31
  delete box.dataset.grown;
22
32
  }
23
- }, [boxRef, room]);
33
+ }, [boxRef, room, grows]);
24
34
  useLayoutEffect(fit, [fit]);
25
35
  return (_jsxs("span", { ref: boxRef, onInput: fit, className: "group/fitted relative flex h-full w-full min-w-0 shrink-0 data-grown:z-2", children: [edge && (_jsx("span", { "aria-hidden": true, className: cx("pointer-events-none absolute inset-y-0 -inset-x-(--vk-px) -z-1 hidden rounded-sm border border-(color:--vk-border-brand) group-data-grown/fitted:block", GRID_EDITING_SHADOW, GRID_GROUND) })), children] }));
26
36
  }
@@ -9,7 +9,7 @@ import type { ListSelectionConfig } from "../../selection/types.js";
9
9
  import type { ListSettingsConfig } from "../../model/column-capabilities.js";
10
10
  import type { ListAggregateKind, ListCellAction, ListColumn, ListOptionColorOverrides, ListRelationValue, ListSelectColor } from "../../model/column-schema.js";
11
11
  import type { ListDateStyle, ListDateStyleOverrides, ListDurationStyle, ListDurationStyleOverrides, ListNumberFormatOverrides, ListPercentDisplayOverrides, ListShowTimeOverrides } from "../../model/column-format.js";
12
- import type { ListColumnState, ListColumnsConfig } from "../../model/column-state.js";
12
+ import type { ListColumnItem, ListColumnState, ListColumnsConfig } from "../../model/column-state.js";
13
13
  import type { PercentDisplay } from "viewkitjs/fields";
14
14
  import type { ListGroupSummaryPart } from "../../model/preferences.js";
15
15
  import type { ListRowIconAccessor } from "../../model/row-icon.js";
@@ -20,7 +20,8 @@ import type { GridGroupSortOption } from "./GridGroupMenu.js";
20
20
  import type { GridGroupMenuPart } from "./grid-group-menu-parts.js";
21
21
  /** Each of the grid's menus as a function from its default items to the items it shows (`menu.drop`, `menu.rename`,
22
22
  * `menu.add` and `menu.move` on `viewkitjs/views/list` do the usual changes). `column` gets the column and its field,
23
- * `row` the row, `group` the group its band names. Each reshapes a menu the grid opens: a column or band whose menu holds
23
+ * `row` the row, `group` the group its band names, `addColumn` every column of the list, shown or hidden (+ Add column's
24
+ * rows: each hidden column `add:<id>`, a field with parts `field:<id>`, or `all-shown`). Each reshapes a menu the grid opens: a column or band whose menu holds
24
25
  * none of the grid's rows stays without one. Called while a menu draws: keep them pure and cheap.
25
26
  *
26
27
  * `row` is asked as a row's menu opens (a right-click, the row's ⋯, the menu key), never for a row drawn or pressed, and
@@ -39,6 +40,9 @@ export type GridMenus<Row> = {
39
40
  group?: (items: ViewsMenuItem[], ctx: {
40
41
  group: ListGroup<Row>;
41
42
  }) => ViewsMenuItem[];
43
+ addColumn?: (items: ViewsMenuItem[], ctx: {
44
+ columns: readonly ListColumnItem[];
45
+ }) => ViewsMenuItem[];
42
46
  };
43
47
  /** A group count's noun, singular and plural ("company", "companies"): "2 companies". None: a bare
44
48
  * count. */
@@ -1,3 +1,11 @@
1
- /** One row's height at scale 1, in px: `--vk-row-h` is built from it, and the row window counts rows by it. */
1
+ /** One row's height at scale 1, in px: `--vk-row-h`'s default (`GRID_HEIGHTS`), and the row window's count until it has
2
+ * measured a drawn row. */
2
3
  export declare const GRID_ROW_PX = 37;
4
+ /**
5
+ * The four heights an app sets on the frame (`--vk-row-h`, `--vk-head-h`, `--vk-label-h`, `--vk-footer-h`), at the
6
+ * scale: classes on the frame, never an inline declaration, which would beat the app's own rule there. Each weighs
7
+ * nothing (`:where`), so any rule on the frame wins over it: an app's, and the grid look's (its Words header's height).
8
+ * Written whole, as the stylesheet's scan reads them; the row's is `GRID_ROW_PX`.
9
+ */
10
+ export declare const GRID_HEIGHTS = "[:where(&)]:[--vk-row-h:calc(37px*var(--vk-scale))] [:where(&)]:[--vk-head-h:calc(32px*var(--vk-scale))] [:where(&)]:[--vk-label-h:calc(36px*var(--vk-scale))] [:where(&)]:[--vk-footer-h:calc(36px*var(--vk-scale))]";
3
11
  export declare function useGridScaleStyles(scale: number, grouped: boolean, phone: boolean, addColumn?: boolean): import("react").CSSProperties;
@@ -1,17 +1,14 @@
1
1
  "use client";
2
2
  import { useMemo } from "react";
3
3
  export const GRID_ROW_PX = 37;
4
+ export const GRID_HEIGHTS = "[:where(&)]:[--vk-row-h:calc(37px*var(--vk-scale))] [:where(&)]:[--vk-head-h:calc(32px*var(--vk-scale))] [:where(&)]:[--vk-label-h:calc(36px*var(--vk-scale))] [:where(&)]:[--vk-footer-h:calc(36px*var(--vk-scale))]";
4
5
  export function useGridScaleStyles(scale, grouped, phone, addColumn = false) {
5
6
  return useMemo(() => ({
6
7
  "--vk-scale": String(scale),
7
8
  "--vk-indent": phone ? "0px" : "24px",
8
- "--vk-row-h": `calc(${GRID_ROW_PX}px * var(--vk-scale))`,
9
9
  "--vk-line-h": "calc(22px * var(--vk-scale))",
10
- "--vk-head-h": "calc(32px * var(--vk-scale))",
11
10
  "--vk-head-text": "calc(12px * var(--vk-scale))",
12
11
  "--vk-head-glyph": "calc(12px * var(--vk-scale))",
13
- "--vk-footer-h": "calc(36px * var(--vk-scale))",
14
- "--vk-label-h": "calc(36px * var(--vk-scale))",
15
12
  "--vk-text": "calc(14px * var(--vk-scale))",
16
13
  "--vk-text-xs": "calc(12px * var(--vk-scale))",
17
14
  "--vk-text-10": "calc(10px * var(--vk-scale))",
@@ -8,7 +8,7 @@ export type GridFormatPrefs = Pick<ListViewPrefs, "gridOptionColors" | "gridDate
8
8
  /** The grid's format props and the handlers that write them back through `setFormats`. Every format is keyed by the
9
9
  * FIELD key (`fieldKeyOf(column)`), the name every surface shares. */
10
10
  export declare function useGridFormatProps<Row>(formats: GridFormatPrefs, setFormats: (patch: Partial<GridFormatPrefs>) => void, columns: ListColumn<Row>[]): {
11
- optionColors: import("../model/column-schema.js").ListOptionColorOverrides;
11
+ optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
12
12
  onOptionColorChange: (key: string, value: string, color: ListSelectColor | null) => void;
13
13
  dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
14
14
  onDateStyleChange: (key: string, style: ListDateStyle) => void;
@@ -1,14 +1,27 @@
1
1
  "use client";
2
- import { useCallback, useMemo } from "react";
2
+ import { useCallback, useEffect, useMemo, useRef } from "react";
3
3
  import { fieldKeyOf } from "../model/view-rules.js";
4
4
  import { setCurrency, setDateStyle, setDecimals, setDurationStyle, setOptionColor, setPercentDisplay, setShowTime, } from "../model/preferences.js";
5
5
  import { moneyReadingOf } from "../fields/money.js";
6
6
  import { isMoneyReading, MONEY_READING_OPTIONS } from "../fields/currency.js";
7
+ function settled(map) {
8
+ if (!Object.values(map).includes(null))
9
+ return map;
10
+ return Object.fromEntries(Object.entries(map).filter(([, held]) => held !== null));
11
+ }
7
12
  export function useGridFormatProps(formats, setFormats, columns) {
8
- const { gridOptionColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals, gridCurrencies, } = formats;
13
+ const { gridOptionColors: storedColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals: storedDecimals, gridCurrencies, } = formats;
14
+ const gridOptionColors = useMemo(() => settled(storedColors), [storedColors]);
15
+ const gridDecimals = useMemo(() => settled(storedDecimals), [storedDecimals]);
16
+ const colours = useRef(gridOptionColors);
17
+ useEffect(() => {
18
+ colours.current = gridOptionColors;
19
+ }, [gridOptionColors]);
9
20
  const onOptionColorChange = useCallback((key, value, color) => {
10
- setFormats({ gridOptionColors: setOptionColor(gridOptionColors, key, value, color) });
11
- }, [gridOptionColors, setFormats]);
21
+ const next = setOptionColor(colours.current, key, value, color);
22
+ colours.current = next;
23
+ setFormats({ gridOptionColors: { ...next, [key]: next[key] ?? null } });
24
+ }, [setFormats]);
12
25
  const onDateStyleChange = useCallback((key, style) => setFormats({ gridDateStyles: setDateStyle(gridDateStyles, key, style) }), [gridDateStyles, setFormats]);
13
26
  const onDurationStyleChange = useCallback((key, style) => setFormats({ gridDurationStyles: setDurationStyle(gridDurationStyles, key, style) }), [gridDurationStyles, setFormats]);
14
27
  const onShowTimeChange = useCallback((key, show) => setFormats({ gridShowTime: setShowTime(gridShowTime, key, show) }), [gridShowTime, setFormats]);
@@ -31,7 +44,7 @@ export function useGridFormatProps(formats, setFormats, columns) {
31
44
  if (patch.currency != null && isMoneyReading(patch.currency))
32
45
  setFormats({ gridCurrencies: setCurrency(gridCurrencies, key, patch.currency) });
33
46
  if (patch.decimals === null)
34
- setFormats({ gridDecimals: { [key]: null } });
47
+ setFormats({ gridDecimals: { ...gridDecimals, [key]: null } });
35
48
  else if (patch.decimals !== undefined)
36
49
  setFormats({ gridDecimals: setDecimals(gridDecimals, key, patch.decimals) });
37
50
  }, [gridCurrencies, gridDecimals, setFormats]);
@@ -28,11 +28,15 @@
28
28
  one; the grid draws them at 70% of it. */
29
29
  [data-grid-header="words"] [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header"],
30
30
  [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header"]:not([data-grid-header] *) {
31
- --vk-head-h: calc(var(--vk-spacing) * 9 * var(--vk-scale));
32
31
  --vk-head-text: calc(var(--vk-font-size-sm) * var(--vk-scale));
33
32
  --vk-head-glyph: calc(var(--vk-spacing) * 3.5 * var(--vk-scale));
34
33
  --vk-head-glyph-fg: var(--vk-fg-subtle);
35
34
  }
35
+ /* Its height is the frame's, where an app sets the header's own (`--vk-head-h`): weighing nothing (`:where`), so
36
+ any rule of the app's on the frame wins over the look's. */
37
+ :where([data-grid-header="words"] [data-slot="vk-grid"][data-desktop], [data-slot="vk-grid"][data-desktop]:not([data-grid-header] *)) {
38
+ --vk-head-h: calc(var(--vk-spacing) * 9 * var(--vk-scale));
39
+ }
36
40
  [data-grid-header="words"] [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header-cell"],
37
41
  [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header-cell"]:not([data-grid-header] *) {
38
42
  --vk-fg-subtle: var(--vk-fg);
@@ -24,7 +24,7 @@ export declare function useGridTablePrefs<Row>({ prefs, setPrefs, columns, viewB
24
24
  aggregates: Record<string, import("viewkitjs/fields/query").FigureKind>;
25
25
  onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
26
26
  viewBacked: boolean;
27
- optionColors: import("../model/column-schema.js").ListOptionColorOverrides;
27
+ optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
28
28
  onOptionColorChange: (key: string, value: string, color: import("../model/column-schema.js").ListSelectColor | null) => void;
29
29
  dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
30
30
  onDateStyleChange: (key: string, style: import("../model/column-format.js").ListDateStyle) => void;
@@ -36,7 +36,7 @@ export declare function useGridTableSettings<Row>({ settings, layer, columns, pa
36
36
  aggregates: Record<string, import("viewkitjs/fields/query").FigureKind>;
37
37
  onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
38
38
  viewBacked: true;
39
- optionColors: import("../model/column-schema.js").ListOptionColorOverrides;
39
+ optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
40
40
  onOptionColorChange: (key: string, value: string, color: import("../model/column-schema.js").ListSelectColor | null) => void;
41
41
  dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
42
42
  onDateStyleChange: (key: string, style: import("../model/column-format.js").ListDateStyle) => void;
@@ -9,8 +9,8 @@ function handed(from) {
9
9
  return Object.fromEntries(Object.entries(from).filter(([, value]) => value !== undefined));
10
10
  }
11
11
  export function List({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, customizeIn, link = true, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }) {
12
- const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more }) };
13
- const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group }) };
12
+ const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more, customize: menus?.customize, sortEditor: menus?.sortEditor, filterEditor: menus?.filterEditor, groupEditor: menus?.groupEditor }) };
13
+ const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group, addColumn: menus?.addColumn }) };
14
14
  const [box, setBox] = useState(null);
15
15
  const inPane = (customizeIn ?? toolbar?.customizeIn) === "pane";
16
16
  const gridOf = (_jsx(ListGrid, { ...grid, ...handed({ onOpenRow, rowHref, rowWritable }), menus: gridMenus, children: grid?.children ?? _jsx(ListBulkBar, { ...bulk }) }));
@@ -1,8 +1,7 @@
1
1
  import type { GridMenus } from "../grid/chrome/grid-table-props.js";
2
2
  import type { ToolbarMenus } from "../panels/react/toolbar/ReadyToolbar.js";
3
- import type { ViewsMenuItem } from "../provider/components.js";
4
- /** Every menu of a list as data: the grid's (`column`, `row`, `group`, which `GridTable` takes as `menus`) and the toolbar's
5
- * (`view`, `add`, `more`, which `ReadyToolbar` and `ListToolbar` take as `menus`). Each is handed its default items and hands
3
+ /** Every menu of a list as data: the grid's (`column`, `row`, `group`, `addColumn`, which `GridTable` takes as `menus`) and the toolbar's
4
+ * (`view`, `add`, `more`, `customize`, which `ReadyToolbar` and `ListToolbar` take as `menus`). Each is handed its default items and hands
6
5
  * back the items it shows; a menu with no function is as ViewKit draws it. */
7
6
  export type ListMenus<Row> = GridMenus<Row> & ToolbarMenus;
8
7
  /** Where a row goes: right after the row of that key, or right before it. */
@@ -18,7 +17,9 @@ type Keyed<T> = {
18
17
  children?: T[];
19
18
  };
20
19
  declare function drop<T extends Keyed<T>>(items: T[], ...keys: string[]): T[];
21
- declare function rename(items: ViewsMenuItem[], key: string, label: string): ViewsMenuItem[];
20
+ declare function rename<T extends Keyed<T> & {
21
+ label: string;
22
+ }>(items: T[], key: string, label: string): T[];
22
23
  declare function add<T extends Keyed<T>>(items: T[], item: T, place?: MenuPlace): T[];
23
24
  declare function move<T extends Keyed<T>>(items: T[], key: string, place: MenuPlace): T[];
24
25
  /** The four changes an app's menu function makes to the items it is handed. */