viewkitjs 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/query/evaluate.d.ts +7 -0
- package/fields/dist/query/exact-number.d.ts +8 -2
- package/fields/dist/query/exact-number.js +14 -1
- package/fields/dist/query/sort.js +13 -10
- package/fields/dist/registry.js +5 -1
- package/fields/dist/types.d.ts +4 -1
- package/fields/dist/zod.d.ts +5 -0
- package/fields/dist/zod.js +10 -1
- package/fields/docs/guides/contact-values.md +12 -0
- package/fields/docs/guides/field-types.md +1 -1
- package/fields/docs/guides/queries.md +3 -1
- package/fields/docs/reference/fields.md +1 -0
- package/package.json +1 -1
- package/postgres/dist/check.js +4 -1
- package/postgres/dist/definitions/formula-forms.js +3 -1
- package/postgres/dist/definitions/money.js +2 -1
- package/postgres/dist/page.js +6 -3
- package/postgres/dist/rules.d.ts +15 -1
- package/postgres/dist/rules.js +16 -0
- package/postgres/dist/sort.js +7 -2
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/postgres/docs/reference/definitions.md +1 -1
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +4 -3
- package/views/dist/atoms/frame-parts.d.ts +6 -0
- package/views/dist/atoms/frame-parts.js +15 -0
- package/views/dist/atoms/types.d.ts +16 -7
- package/views/dist/cells/cell-title.d.ts +3 -1
- package/views/dist/cells/cell-title.js +2 -2
- package/views/dist/cells/cell-values.js +2 -2
- package/views/dist/contract.d.ts +46 -11
- package/views/dist/contract.js +157 -0
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
- package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
- package/views/dist/controls/button/map-button.js +2 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
- package/views/dist/controls/checkbox/checkbox.js +2 -2
- package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
- package/views/dist/controls/compound-editor/name-parts.js +4 -4
- package/views/dist/controls/compound-editor/place-parts.js +19 -19
- package/views/dist/controls/compound-editor/range-parts.js +14 -14
- package/views/dist/controls/compound-editor/row.d.ts +3 -1
- package/views/dist/controls/compound-editor/row.js +2 -2
- package/views/dist/controls/controls.d.ts +4 -0
- package/views/dist/controls/controls.js +4 -0
- package/views/dist/controls/customize/customize.js +43 -39
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -2
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +27 -21
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +3 -1
- package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
- package/views/dist/controls/date-editor/map-date-body.js +7 -3
- package/views/dist/controls/date-editor.css +2 -2
- package/views/dist/controls/field/field.d.ts +3 -0
- package/views/dist/controls/field/field.js +6 -6
- package/views/dist/controls/filter-editor/block.d.ts +2 -2
- package/views/dist/controls/filter-editor/block.js +5 -5
- package/views/dist/controls/filter-editor/filter-editor.js +31 -33
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +11 -4
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.d.ts +3 -1
- package/views/dist/controls/filter-editor/parts.js +8 -6
- package/views/dist/controls/group-editor/group-editor.js +17 -14
- package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
- package/views/dist/controls/group-editor/map-group-body.js +5 -1
- package/views/dist/controls/index.d.ts +2 -0
- package/views/dist/controls/index.js +1 -0
- package/views/dist/controls/input/input.js +4 -3
- package/views/dist/controls/input/map-input.js +2 -0
- package/views/dist/controls/internal/editor-parts.js +1 -1
- package/views/dist/controls/internal/head-button.d.ts +9 -0
- package/views/dist/controls/internal/head-button.js +13 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
- package/views/dist/controls/internal/map-panel-controls.js +20 -0
- package/views/dist/controls/internal/panel-controls.d.ts +58 -0
- package/views/dist/controls/internal/panel-controls.js +240 -0
- package/views/dist/controls/internal/part-slot.d.ts +12 -0
- package/views/dist/controls/internal/part-slot.js +5 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
- package/views/dist/controls/links-editor/links-editor.js +27 -27
- package/views/dist/controls/menu/map-menu.d.ts +2 -2
- package/views/dist/controls/menu/map-menu.js +15 -12
- package/views/dist/controls/menu/menu.d.ts +3 -0
- package/views/dist/controls/menu/menu.js +5 -5
- package/views/dist/controls/menu-list/menu-list.d.ts +14 -4
- package/views/dist/controls/menu-list/menu-list.js +23 -22
- package/views/dist/controls/modal/modal.js +5 -3
- package/views/dist/controls/notice/notice.d.ts +3 -1
- package/views/dist/controls/notice/notice.js +2 -2
- package/views/dist/controls/number-editor/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +16 -16
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/map-pane.d.ts +3 -0
- package/views/dist/controls/pane/map-pane.js +5 -0
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +4 -4
- package/views/dist/controls/picker/map-fields-body.js +25 -1
- package/views/dist/controls/picker/picker.d.ts +2 -0
- package/views/dist/controls/picker/picker.js +37 -36
- package/views/dist/controls/picker/rows.d.ts +4 -0
- package/views/dist/controls/picker.css +10 -1
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +4 -2
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
- package/views/dist/controls/quick-filters/quick-filters.js +8 -6
- package/views/dist/controls/radio/radio.d.ts +3 -0
- package/views/dist/controls/radio/radio.js +4 -3
- package/views/dist/controls/select/map-select.d.ts +3 -0
- package/views/dist/controls/select/map-select.js +8 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +3 -3
- package/views/dist/controls/setting-row/looks.js +5 -5
- package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
- package/views/dist/controls/setting-row/setting-row.js +3 -1
- package/views/dist/controls/setting-row.css +3 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +8 -2
- package/views/dist/controls/sheet/bottom-sheet.js +4 -4
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +8 -4
- package/views/dist/controls/sort-editor/sort-editor.js +24 -26
- package/views/dist/controls/sort-editor.css +5 -0
- package/views/dist/controls/text-editor/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +11 -10
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +3 -3
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +7 -6
- package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
- package/views/dist/controls/values-editor/values-editor.js +22 -22
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +7 -3
- package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
- package/views/dist/controls/views-list/map-views-list-body.js +6 -5
- package/views/dist/controls/views-list/view-menu.js +9 -10
- package/views/dist/controls/views-list/views-list.js +6 -6
- package/views/dist/editors/EditorPanel.js +4 -4
- package/views/dist/field-row/FieldRow.js +13 -0
- package/views/dist/fields/money.d.ts +5 -2
- package/views/dist/fields/money.js +14 -2
- package/views/dist/grid/chrome/GridTable.js +4 -1
- package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
- package/views/dist/grid/chrome/cell-clipboard.js +2 -2
- package/views/dist/grid/chrome/cells.js +3 -1
- package/views/dist/grid/chrome/grid-row-menu-items.js +1 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +29 -6
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +9 -2
- package/views/dist/grid/core/clipboard-model.d.ts +3 -1
- package/views/dist/grid/core/clipboard-model.js +9 -8
- package/views/dist/grid/core/editing-controller.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.js +6 -0
- package/views/dist/grid/core/edits-sink.d.ts +19 -0
- package/views/dist/grid/core/edits-sink.js +2 -0
- package/views/dist/grid/core/spreadsheet-operations.js +1 -1
- package/views/dist/grid/core/useGridEditing.d.ts +5 -0
- package/views/dist/grid/core/useGridEditing.js +6 -0
- package/views/dist/list/answer.d.ts +40 -0
- package/views/dist/list/answer.js +43 -0
- package/views/dist/list/bulk-bar.d.ts +7 -0
- package/views/dist/list/bulk-bar.js +10 -0
- package/views/dist/list/columns.d.ts +24 -0
- package/views/dist/list/columns.js +27 -0
- package/views/dist/list/edits.d.ts +19 -0
- package/views/dist/list/edits.js +56 -0
- package/views/dist/list/grid.d.ts +11 -0
- package/views/dist/list/grid.js +76 -0
- package/views/dist/list/index.d.ts +14 -1
- package/views/dist/list/index.js +4 -1
- package/views/dist/list/link.d.ts +8 -0
- package/views/dist/list/link.js +78 -0
- package/views/dist/list/list.d.ts +74 -0
- package/views/dist/list/list.js +18 -0
- package/views/dist/list/parts.js +11 -3
- package/views/dist/list/root-base.d.ts +46 -0
- package/views/dist/list/root-base.js +137 -0
- package/views/dist/list/root.d.ts +35 -34
- package/views/dist/list/root.js +153 -113
- package/views/dist/list/source-answers.d.ts +39 -0
- package/views/dist/list/source-answers.js +225 -0
- package/views/dist/list/store.d.ts +37 -5
- package/views/dist/list/store.js +31 -0
- package/views/dist/list/toolbar.d.ts +3 -2
- package/views/dist/list/toolbar.js +23 -5
- package/views/dist/list/views-axis.js +4 -2
- package/views/dist/list/views.d.ts +7 -2
- package/views/dist/list/views.js +16 -5
- package/views/dist/model/column-capabilities.d.ts +13 -0
- package/views/dist/model/column-capabilities.js +23 -2
- package/views/dist/model/column-schema.d.ts +11 -1
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/model.d.ts +2 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +21 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +20 -6
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +4 -3
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +4 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +8 -5
- package/views/dist/panels/react/toolbar/context.d.ts +31 -1
- package/views/dist/panels/react/toolbar/context.js +4 -0
- package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
- package/views/dist/panels/react/toolbar/pane-host.js +17 -0
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +7 -4
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/provider/ViewsProvider.d.ts +7 -2
- package/views/dist/provider/ViewsProvider.js +18 -1
- package/views/dist/provider/components.d.ts +90 -2
- package/views/dist/provider/components.js +1 -1
- package/views/dist/provider/context.d.ts +4 -1
- package/views/dist/provider/own-control.d.ts +4 -0
- package/views/dist/provider/own-control.js +7 -0
- package/views/dist/provider/select-items.d.ts +3 -0
- package/views/dist/provider/select-items.js +6 -0
- package/views/dist/react.d.ts +4 -2
- package/views/dist/react.js +2 -0
- package/views/dist/styles.css +107 -80
- package/views/dist/styles.unlayered.css +107 -80
- package/views/docs/contract.md +310 -7
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/bulk-bar.md +4 -0
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +8 -0
- package/views/docs/controls/date-editor.md +6 -0
- package/views/docs/controls/field.md +4 -0
- package/views/docs/controls/filter-editor.md +8 -0
- package/views/docs/controls/group-editor.md +8 -0
- package/views/docs/controls/input.md +4 -0
- package/views/docs/controls/links-editor.md +4 -0
- package/views/docs/controls/menu-list.md +8 -0
- package/views/docs/controls/menu.md +6 -0
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +6 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +8 -0
- package/views/docs/controls/radio.md +4 -0
- package/views/docs/controls/select.md +8 -0
- package/views/docs/controls/sheet.md +4 -0
- package/views/docs/controls/sort-editor.md +8 -0
- package/views/docs/controls/text-editor.md +6 -0
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +8 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/guides/the-provider.md +19 -2
- package/views/docs/reference/controls.md +11 -7
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +1 -1
- package/views/docs/reference/list.md +143 -11
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +6 -5
- package/views/docs/reference/react.md +19 -12
- package/views/docs/reference/views.md +11 -5
- package/views/docs/reshaping.md +17 -1
- package/views/skills/views/SKILL.md +1 -1
package/views/dist/list/store.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
const NO_EDITS = { saving: false, canUndo: false, canRedo: false };
|
|
1
2
|
const sameKeys = (a, b) => Object.keys(b).every((key) => Object.is(a[key], b[key]));
|
|
2
3
|
const sameIds = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
|
|
4
|
+
const sameSelection = (a, b) => a.all === b.all && a.count === b.count && sameIds(a.ids, b.ids);
|
|
3
5
|
export function createListStore(id, props) {
|
|
4
6
|
let latest = props;
|
|
5
7
|
let wired = {};
|
|
@@ -39,6 +41,10 @@ export function createListStore(id, props) {
|
|
|
39
41
|
write({ panels: { ...state.panels, held } });
|
|
40
42
|
},
|
|
41
43
|
select: (ids) => {
|
|
44
|
+
if (ids === "all" && wired.selectAll)
|
|
45
|
+
return wired.selectAll();
|
|
46
|
+
if (wired.select)
|
|
47
|
+
return wired.select(ids);
|
|
42
48
|
const { selection } = state;
|
|
43
49
|
if (ids === "all" ? selection.all : !selection.all && sameIds(selection.ids, ids))
|
|
44
50
|
return;
|
|
@@ -47,6 +53,9 @@ export function createListStore(id, props) {
|
|
|
47
53
|
saveView: () => latest.view?.onPublish(),
|
|
48
54
|
resetView: () => latest.view?.onReset(),
|
|
49
55
|
undo: () => wired.undo?.(),
|
|
56
|
+
redo: () => wired.redo?.(),
|
|
57
|
+
loadMore: () => wired.loadMore?.(),
|
|
58
|
+
loadGroup: (key) => wired.loadGroup?.(key),
|
|
50
59
|
};
|
|
51
60
|
const data = {
|
|
52
61
|
id,
|
|
@@ -62,6 +71,9 @@ export function createListStore(id, props) {
|
|
|
62
71
|
},
|
|
63
72
|
selection: { ids: [], all: false, count: 0 },
|
|
64
73
|
views: null,
|
|
74
|
+
columns: null,
|
|
75
|
+
answer: null,
|
|
76
|
+
edits: NO_EDITS,
|
|
65
77
|
};
|
|
66
78
|
let state = { ...data, ...actions };
|
|
67
79
|
function swap(next) {
|
|
@@ -92,6 +104,17 @@ export function createListStore(id, props) {
|
|
|
92
104
|
swap(changed);
|
|
93
105
|
dirty = true;
|
|
94
106
|
},
|
|
107
|
+
syncData: (data) => {
|
|
108
|
+
const changed = {};
|
|
109
|
+
if (!Object.is(state.columns, data.columns))
|
|
110
|
+
changed.columns = data.columns;
|
|
111
|
+
if (!Object.is(state.answer, data.answer))
|
|
112
|
+
changed.answer = data.answer;
|
|
113
|
+
if (Object.keys(changed).length === 0)
|
|
114
|
+
return;
|
|
115
|
+
swap(changed);
|
|
116
|
+
dirty = true;
|
|
117
|
+
},
|
|
95
118
|
flush: () => {
|
|
96
119
|
if (!dirty)
|
|
97
120
|
return;
|
|
@@ -105,6 +128,14 @@ export function createListStore(id, props) {
|
|
|
105
128
|
next.panels = { ...state.panels, ...patch.panels };
|
|
106
129
|
if (patch.views !== undefined && !Object.is(state.views, patch.views))
|
|
107
130
|
next.views = patch.views;
|
|
131
|
+
if (patch.columns !== undefined && !Object.is(state.columns, patch.columns))
|
|
132
|
+
next.columns = patch.columns;
|
|
133
|
+
if (patch.answer !== undefined && !Object.is(state.answer, patch.answer))
|
|
134
|
+
next.answer = patch.answer;
|
|
135
|
+
if (patch.edits && !sameKeys(state.edits, patch.edits))
|
|
136
|
+
next.edits = patch.edits;
|
|
137
|
+
if (patch.selection && !sameSelection(state.selection, patch.selection))
|
|
138
|
+
next.selection = patch.selection;
|
|
108
139
|
if (Object.keys(next).length > 0)
|
|
109
140
|
write(next);
|
|
110
141
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { ReadyToolbarProps } from "../panels/react/toolbar/ReadyToolbar.js";
|
|
3
3
|
/** `ReadyToolbar`'s props but those the root holds: the settings and the layer with their callbacks, the shared view,
|
|
4
|
-
* `sortFilter` and `bar`.
|
|
5
|
-
|
|
4
|
+
* `sortFilter` and `bar`. `columns`, `groupHeads` and `filterData` default to the root's, where it holds a list's
|
|
5
|
+
* fields and rows; handed, they win. */
|
|
6
|
+
export type ListToolbarProps<Row> = Omit<ReadyToolbarProps<Row>, "settings" | "layer" | "onChange" | "onLayerChange" | "view" | "sortFilter" | "bar" | "columns"> & Partial<Pick<ReadyToolbarProps<Row>, "columns">>;
|
|
6
7
|
export declare function ListToolbar<Row>(props: ListToolbarProps<Row>): ReactNode;
|
|
@@ -18,6 +18,7 @@ import { ToolbarFilterAdd } from "../panels/react/toolbar/ToolbarFilterAdd.js";
|
|
|
18
18
|
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
19
19
|
import { ToolbarNew } from "../panels/react/toolbar/ToolbarNew.js";
|
|
20
20
|
import { ToolbarOptions } from "../panels/react/toolbar/ToolbarOptions.js";
|
|
21
|
+
import { PaneBox, PaneHost } from "../panels/react/toolbar/pane-host.js";
|
|
21
22
|
import { ToolbarQuickFilters } from "../panels/react/toolbar/ToolbarQuickFilters.js";
|
|
22
23
|
import { ToolbarSave } from "../panels/react/toolbar/ToolbarSave.js";
|
|
23
24
|
import { ToolbarSearch } from "../panels/react/toolbar/ToolbarSearch.js";
|
|
@@ -26,11 +27,16 @@ import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
|
26
27
|
import { ToolbarAdvancedFilters } from "../panels/react/toolbar/ToolbarAdvancedFilters.js";
|
|
27
28
|
import { ToolbarViews } from "../panels/react/toolbar/ToolbarViews.js";
|
|
28
29
|
import { applyParts } from "./parts.js";
|
|
29
|
-
import { useList, useListPanel, useListStore } from "./root.js";
|
|
30
|
+
import { useList, useListPanel, useListStore } from "./root-base.js";
|
|
30
31
|
import { useListViewsAxis } from "./views-axis.js";
|
|
31
32
|
export function ListToolbar(props) {
|
|
33
|
+
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(ToolbarOfList, { ...props }) }));
|
|
34
|
+
}
|
|
35
|
+
function ToolbarOfList(props) {
|
|
32
36
|
const { views: viewsHanded, viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, } = props;
|
|
33
37
|
const storeViews = useListViewsAxis(props.layouts);
|
|
38
|
+
const rootColumns = useList((s) => s.columns);
|
|
39
|
+
const answer = useList((s) => s.answer);
|
|
34
40
|
const views = viewsHanded ?? storeViews;
|
|
35
41
|
const store = useListStore();
|
|
36
42
|
const settings = useList((s) => s.view.settings);
|
|
@@ -47,9 +53,11 @@ export function ListToolbar(props) {
|
|
|
47
53
|
...(onExport && { onExport }),
|
|
48
54
|
...(exportCount !== undefined && { exportCount }),
|
|
49
55
|
};
|
|
50
|
-
const { icons, messages, conventions } = useViews();
|
|
56
|
+
const { icons, messages, conventions, components } = useViews();
|
|
51
57
|
const desktop = useDesktop();
|
|
52
58
|
const phone = props.phone ?? !desktop;
|
|
59
|
+
const optionsHost = hosts?.options ??
|
|
60
|
+
(props.customizeIn === "pane" && props.paneBox !== undefined && !phone && components.Pane ? PaneHost : undefined);
|
|
53
61
|
const options = useListPanel("options");
|
|
54
62
|
const sortState = useListPanel("sort");
|
|
55
63
|
const filterState = useListPanel("filter");
|
|
@@ -71,6 +79,9 @@ export function ListToolbar(props) {
|
|
|
71
79
|
const { toolbarParts: _placed, ...settingsProps } = props;
|
|
72
80
|
const input = {
|
|
73
81
|
...settingsProps,
|
|
82
|
+
columns: props.columns ?? rootColumns ?? [],
|
|
83
|
+
groupHeads: props.groupHeads ?? answer?.groupHeads,
|
|
84
|
+
filterData: props.filterData ?? answer?.filterValues,
|
|
74
85
|
settings,
|
|
75
86
|
layer,
|
|
76
87
|
onChange,
|
|
@@ -118,8 +129,15 @@ export function ListToolbar(props) {
|
|
|
118
129
|
} }));
|
|
119
130
|
const sortNode = several && panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: props.addAfter })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort }));
|
|
120
131
|
const filterNode = (_jsx(ToolbarFilter, { filters: panels.filters, filterTree: panels.filterTree, onClear: clear("filters"), open: filterState.open, onOpenChange: filterState.onOpenChange, page: filterState.page, onPageChange: filterState.onPageChange, host: hosts?.filter }));
|
|
132
|
+
const holdCounts = answer?.holdCounts;
|
|
121
133
|
const quick = props.quickFilters?.fields.length
|
|
122
|
-
? {
|
|
134
|
+
? {
|
|
135
|
+
...props.quickFilters,
|
|
136
|
+
showCounts: props.quickFilters.showCounts ?? show,
|
|
137
|
+
...(holdCounts && {
|
|
138
|
+
fields: props.quickFilters.fields.map((field) => field.counts === undefined && holdCounts[field.key] ? { ...field, counts: holdCounts[field.key] } : field),
|
|
139
|
+
}),
|
|
140
|
+
}
|
|
123
141
|
: null;
|
|
124
142
|
const quickNode = quick ? (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick })) : null;
|
|
125
143
|
const arrangement = props.arrangement ?? "kit";
|
|
@@ -192,7 +210,7 @@ export function ListToolbar(props) {
|
|
|
192
210
|
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
193
211
|
onSelect: () => options.onOpenChange(true),
|
|
194
212
|
},
|
|
195
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? clear("options") : undefined, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host:
|
|
213
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? clear("options") : undefined, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
196
214
|
},
|
|
197
215
|
...(quickNode
|
|
198
216
|
? [
|
|
@@ -351,7 +369,7 @@ export function ListToolbar(props) {
|
|
|
351
369
|
{
|
|
352
370
|
key: "options",
|
|
353
371
|
side: "end",
|
|
354
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host:
|
|
372
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
355
373
|
},
|
|
356
374
|
{ key: "new", side: "end", node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
357
375
|
];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { writeListLink } from "viewkitjs/fields/query";
|
|
4
4
|
import { useViews } from "../provider/context.js";
|
|
5
|
-
import { useList } from "./root.js";
|
|
5
|
+
import { useList } from "./root-base.js";
|
|
6
6
|
const LAYOUT_NAMES = {
|
|
7
7
|
table: { key: "views.panels.layout-table" },
|
|
8
8
|
list: { key: "views.panels.layout-list" },
|
|
@@ -12,6 +12,7 @@ const LAYOUT_NAMES = {
|
|
|
12
12
|
const isLayout = (id) => id in LAYOUT_NAMES;
|
|
13
13
|
export function useListViewsAxis(layouts) {
|
|
14
14
|
const views = useList((s) => s.views);
|
|
15
|
+
const counts = useList((s) => s.answer?.viewCounts ?? null);
|
|
15
16
|
const changes = useList((s) => s.view.shared?.changes ?? 0);
|
|
16
17
|
const settings = useList((s) => s.view.settings);
|
|
17
18
|
const openPanel = useList((s) => s.openPanel);
|
|
@@ -69,6 +70,7 @@ export function useListViewsAxis(layouts) {
|
|
|
69
70
|
layout: v.settings.layout,
|
|
70
71
|
...(!views.canSave(v) && { readOnly: true }),
|
|
71
72
|
...(v.id === views.open && changes > 0 && { changed: true }),
|
|
73
|
+
...(counts?.[v.id] !== undefined && { count: counts[v.id] }),
|
|
72
74
|
})),
|
|
73
75
|
onChange: views.openView,
|
|
74
76
|
onCreate: () => { },
|
|
@@ -92,5 +94,5 @@ export function useListViewsAxis(layouts) {
|
|
|
92
94
|
onChange,
|
|
93
95
|
},
|
|
94
96
|
};
|
|
95
|
-
}, [views, changes, settings.search, openPanel, messages, ports, layouts]);
|
|
97
|
+
}, [views, changes, counts, settings.search, openPanel, messages, ports, layouts]);
|
|
96
98
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ListLayout, type ListLinkReading, type ListSettings, type SavedView } from "viewkitjs/fields/query";
|
|
1
|
+
import { type ListLayout, type ListLinkReading, type ListSettings, type ListSettingsChange, type SavedView } from "viewkitjs/fields/query";
|
|
2
2
|
import type { ListSync } from "./store.js";
|
|
3
3
|
import type { ViewsStore } from "./views-store.js";
|
|
4
4
|
/** A list's saved views as the root holds them (`ListState.views`): null in memory mode. */
|
|
@@ -15,7 +15,8 @@ export type ListViewsState = {
|
|
|
15
15
|
pending: boolean;
|
|
16
16
|
/** What the list holds, in the delete question's line (`ListViewsOptions.records`, default "records"). */
|
|
17
17
|
records: string;
|
|
18
|
-
|
|
18
|
+
/** Opens a view; with `change`, lays it over the view as the edited settings, its draft replaced (a link wins). */
|
|
19
|
+
openView: (id: string, change?: ListSettingsChange) => void;
|
|
19
20
|
/** The open view's edits saved over it, where this person may (`canSave`). */
|
|
20
21
|
save: () => void;
|
|
21
22
|
/** A new view of the person's own, named `name`: the edited settings of `from` (its edits let go), or with no `from`
|
|
@@ -58,6 +59,10 @@ export declare function createListViews(o: {
|
|
|
58
59
|
link?: ListLinkReading;
|
|
59
60
|
/** The delete question's noun; default "records". */
|
|
60
61
|
records?: string;
|
|
62
|
+
/** `false` takes "Save for everyone" away, even where the store lets this person share. */
|
|
63
|
+
share?: boolean;
|
|
64
|
+
/** The view this person had open last: opened where no link names one and the store still holds it. */
|
|
65
|
+
kept?: string;
|
|
61
66
|
/** Told whenever the settings, the layer or the slice change, after the controller has synced them into the list store. */
|
|
62
67
|
onChange: () => void;
|
|
63
68
|
/** Said when a store write fails (the root hands `ports.toast.error`). */
|
package/views/dist/list/views.js
CHANGED
|
@@ -20,7 +20,7 @@ export function createListViews(o) {
|
|
|
20
20
|
const { id: listId, store } = o;
|
|
21
21
|
const link = o.link && (o.link.view !== undefined || Object.keys(o.link.change).some((k) => k !== "search")) ? o.link : null;
|
|
22
22
|
const linkSearch = o.link?.change.search;
|
|
23
|
-
const share = !!store.can?.share;
|
|
23
|
+
const share = !!store.can?.share && o.share !== false;
|
|
24
24
|
const records = o.records ?? "records";
|
|
25
25
|
let generation = 0;
|
|
26
26
|
let ready = false;
|
|
@@ -137,7 +137,8 @@ export function createListViews(o) {
|
|
|
137
137
|
run(() => store.list(listId), (views) => {
|
|
138
138
|
list = listing(views);
|
|
139
139
|
const linked = link?.view !== undefined ? list.find((v) => v.id === link.view) : undefined;
|
|
140
|
-
const
|
|
140
|
+
const kept = !linked && o.kept !== undefined ? list.find((v) => v.id === o.kept) : undefined;
|
|
141
|
+
const view = linked ?? kept ?? list[0];
|
|
141
142
|
const land = (draft) => {
|
|
142
143
|
open = view?.id ?? null;
|
|
143
144
|
const saved = view?.settings ?? settingsForSaving(o.defaults);
|
|
@@ -221,13 +222,23 @@ export function createListViews(o) {
|
|
|
221
222
|
write(() => store.reorder(listId, scope, ids));
|
|
222
223
|
};
|
|
223
224
|
const actions = {
|
|
224
|
-
openView: (id) => {
|
|
225
|
-
if (!ready
|
|
225
|
+
openView: (id, change) => {
|
|
226
|
+
if (!ready)
|
|
226
227
|
return;
|
|
227
228
|
const view = list.find((v) => v.id === id);
|
|
228
229
|
if (!view)
|
|
229
230
|
return;
|
|
230
|
-
|
|
231
|
+
if (change === undefined) {
|
|
232
|
+
if (id === open)
|
|
233
|
+
return;
|
|
234
|
+
opening(view);
|
|
235
|
+
tell();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
open = view.id;
|
|
239
|
+
base = null;
|
|
240
|
+
edited = applySettingsChange(view.settings, change);
|
|
241
|
+
writeDraft();
|
|
231
242
|
tell();
|
|
232
243
|
},
|
|
233
244
|
save: () => {
|
|
@@ -115,6 +115,19 @@ export declare function baseColumnOrder<Row>(columns: ListColumn<Row>[], order:
|
|
|
115
115
|
* stays because a lock site reads better saying what it is looking up.
|
|
116
116
|
*/
|
|
117
117
|
export declare function lockKeyOf<Row>(col: ListColumn<Row>): string;
|
|
118
|
+
/**
|
|
119
|
+
* A list's locks with each edit-through pair locked together: a lock stored under either a worked-out field edited
|
|
120
|
+
* through a stored one (`editThrough`) or that stored field holds under both keys. A lock is a rule about what an edit
|
|
121
|
+
* writes, and an edit of the worked-out field writes the stored one, so a lock on Paid on locks the Date edited
|
|
122
|
+
* through it, and a lock on Date locks Paid on. The stored config is untouched: each key keeps its own toggle, and
|
|
123
|
+
* this is the config a lock is checked against. The grid widens its `listConfig` with its columns' fields; a surface
|
|
124
|
+
* that checks a lock by field key (a drawer's `LockedResolver`) passes its own fields. Gives back the same config when
|
|
125
|
+
* no pair widens it.
|
|
126
|
+
*/
|
|
127
|
+
export declare function withEditThroughLocks(config: ListSettingsConfig | undefined, fields: Iterable<{
|
|
128
|
+
key: string;
|
|
129
|
+
editThrough?: string;
|
|
130
|
+
} | null | undefined>): ListSettingsConfig | undefined;
|
|
118
131
|
/** Is this column locked by the workspace config (a column lock or the whole
|
|
119
132
|
* table's read-only)? Locks only ever SUBTRACT — they never grant. */
|
|
120
133
|
export declare function gridColumnLocked<Row>(col: ListColumn<Row>, config: ListSettingsConfig | undefined): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { acceptFieldCommit, isMultipleType, lockReason, relationIdOf, valueTypeOf, } from "viewkitjs/fields";
|
|
1
|
+
import { acceptFieldCommit, isMultipleType, lockReason, relationIdOf, valueTypeOf, withUrlScheme, } from "viewkitjs/fields";
|
|
2
2
|
import { resolveViewsMessage } from "../contract.js";
|
|
3
3
|
import { opensAsList } from "./one-value.js";
|
|
4
4
|
import { prettifyOptionValue, resolveColumnOrder } from "./column-state.js";
|
|
@@ -116,6 +116,27 @@ export function baseColumnOrder(columns, order, viewBacked) {
|
|
|
116
116
|
export function lockKeyOf(col) {
|
|
117
117
|
return col.partOf?.field.key ?? fieldKeyOf(col);
|
|
118
118
|
}
|
|
119
|
+
export function withEditThroughLocks(config, fields) {
|
|
120
|
+
const locked = config?.columns;
|
|
121
|
+
if (!locked)
|
|
122
|
+
return config;
|
|
123
|
+
let widened;
|
|
124
|
+
for (const field of fields) {
|
|
125
|
+
const through = field?.editThrough;
|
|
126
|
+
if (!field || !through)
|
|
127
|
+
continue;
|
|
128
|
+
const pairLocked = !!locked[field.key]?.locked || !!locked[through]?.locked;
|
|
129
|
+
if (!pairLocked)
|
|
130
|
+
continue;
|
|
131
|
+
for (const key of [field.key, through]) {
|
|
132
|
+
if (locked[key]?.locked || widened?.[key]?.locked)
|
|
133
|
+
continue;
|
|
134
|
+
widened ??= { ...locked };
|
|
135
|
+
widened[key] = { ...locked[key], locked: true };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return widened ? { ...config, columns: widened } : config;
|
|
139
|
+
}
|
|
119
140
|
export function gridColumnLocked(col, config) {
|
|
120
141
|
if (!config)
|
|
121
142
|
return false;
|
|
@@ -210,7 +231,7 @@ export function coerceWrite(col, next, messages) {
|
|
|
210
231
|
return { ok: true, value: next };
|
|
211
232
|
if (typeof next !== "string")
|
|
212
233
|
return { ok: true, value: next };
|
|
213
|
-
const trimmed = next.trim();
|
|
234
|
+
const trimmed = col.field?.type === "url" && col.field.bareHost === "https" ? withUrlScheme(next) : next.trim();
|
|
214
235
|
if (!URL_SHAPE.test(trimmed)) {
|
|
215
236
|
return { ok: false, reason: messages({ key: "views.grid.write-not-url" }) };
|
|
216
237
|
}
|
|
@@ -113,7 +113,10 @@ export type ListColumn<Row> = {
|
|
|
113
113
|
* custom money cell draws the chassis's reading and converts nothing. */
|
|
114
114
|
render?: (row: Row, cell?: RenderedValue) => ReactNode;
|
|
115
115
|
actions?: ListCellAction<Row>[];
|
|
116
|
-
|
|
116
|
+
/** An adornment beside the cell's value, drawn by the app. Handed the row and, beside it, the value the cell
|
|
117
|
+
* shows: a write still saving (a paste, a fill, an edit) while it saves, else what `accessor` reads, so a cue
|
|
118
|
+
* read from it agrees with the value beside it from the moment it shows, and goes back with it if the save fails. */
|
|
119
|
+
indicator?: (row: Row, cell?: RenderedValue) => ReactNode;
|
|
117
120
|
accessor?: (row: Row) => unknown;
|
|
118
121
|
/** Raw field used for editing when display accessor contains fallbacks. */
|
|
119
122
|
editAccessor?: (row: Row) => unknown;
|
|
@@ -153,6 +156,13 @@ export type ListColumn<Row> = {
|
|
|
153
156
|
money?: MoneyDeclaration<Row>;
|
|
154
157
|
/** The reading in force on a convertible column — set by `readMoneyColumn`. */
|
|
155
158
|
reading?: MoneyReading;
|
|
159
|
+
/** What a convertible money column SORTS by when it shows each row's own
|
|
160
|
+
* currency: the row's figure converted into the reader's default currency
|
|
161
|
+
* (`null`: no figure, or no rate), so rows in different currencies order as
|
|
162
|
+
* one number that flips with the direction. Set by `readMoneyColumns` under
|
|
163
|
+
* the Original reading; absent, the column sorts by `accessor`, clustered by
|
|
164
|
+
* code. */
|
|
165
|
+
sortAccessor?: (row: Row) => number | null;
|
|
156
166
|
defaultAggregate?: ListAggregateKind;
|
|
157
167
|
/** The field whose database figures this column's footer reads, when it is
|
|
158
168
|
* not the column's own (Transactions' Amount totals its paid figure). A
|
|
@@ -296,5 +296,6 @@ export function viewReaderFrom(columns, decimals = {}) {
|
|
|
296
296
|
return decimals[key] ?? col.format?.decimals ?? fallback;
|
|
297
297
|
},
|
|
298
298
|
codeOf: (row, key) => denominationOf(byKey.get(key), row),
|
|
299
|
+
sortAmountOf: (row, key) => byKey.get(key)?.sortAccessor?.(row),
|
|
299
300
|
};
|
|
300
301
|
}
|
|
@@ -79,6 +79,8 @@ export type FilterEditorField = {
|
|
|
79
79
|
far?: readonly FilterEditorField[];
|
|
80
80
|
/** How its field is marked, as the grid's header marks its column (`columnMark`); a relation has none. */
|
|
81
81
|
mark?: FieldMark;
|
|
82
|
+
/** A number field that holds whole numbers only (`isIntegerField`): its box takes whole numbers. */
|
|
83
|
+
integer?: true;
|
|
82
84
|
/** Why no rule can be made on it, in the app's words (an unavailable capability's reason, else
|
|
83
85
|
* `views.panels.filter-not-offered`); absent, it can. Only in `FilterTreeConfig.listed`: a field list draws it greyed. */
|
|
84
86
|
disabled?: string;
|
|
@@ -7,7 +7,8 @@ import type { CollectionViewState } from "../../view-state.js";
|
|
|
7
7
|
import type { CollectionViewsInput, ViewsLayout } from "../../views-row/model.js";
|
|
8
8
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
9
9
|
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
10
|
-
import type {
|
|
10
|
+
import type { ToolbarPanelPlace } from "./context.js";
|
|
11
|
+
import type { ToolbarMore, ToolbarPartButton } from "./Toolbar.js";
|
|
11
12
|
/** The toolbar's menus as data (VK-741): each handed its default items, each item keyed, and handing back the items it shows.
|
|
12
13
|
* `view`, a view's menu, handed the view too: the rows an option hands (`menu`, Edit view… among them) and the menu a views
|
|
13
14
|
* list draws from an axis's verbs. `add`, New's items: `addItems`, or, with `onAdd` alone, one row keyed `new` that runs it;
|
|
@@ -21,13 +22,22 @@ export type ToolbarMenus = {
|
|
|
21
22
|
* `bar` (the filter bar; in `row`, the line below the row) or `foot` (a kit phone list's foot, New's place: anywhere else, the
|
|
22
23
|
* row); on a kit phone the row and the bar are one line. Its side, and its words (`both`, as the look's words say; `icon`, its
|
|
23
24
|
* icon alone), meaningful for a part whose button has a word: `search`, `quick`, `sort`, `filter`, `filter-add`, `options`,
|
|
24
|
-
* `new`. `node`: a part of the app's own, under a key of its own (a key the form holds keeps its own node).
|
|
25
|
+
* `new`. `node`: a part of the app's own, under a key of its own (a key the form holds keeps its own node).
|
|
26
|
+
* Its look (VK-984): `className`, put on every toolbar button the part draws (each handed its `part`, list.md's table), and
|
|
27
|
+
* `button`, your own button drawn for each of them in place of your `ToolbarButton`, handed the very props it would get, `ref`
|
|
28
|
+
* included: put `ref` on your button, so what it opens hangs at it. A part that draws ViewKit's own pills (the views row, Clear
|
|
29
|
+
* and Save, outside your own frame) takes neither. */
|
|
25
30
|
export type ToolbarPartPlace = {
|
|
26
31
|
key: string;
|
|
27
32
|
line: "row" | "bar" | "foot";
|
|
28
33
|
side: "start" | "end";
|
|
29
34
|
words: "both" | "icon";
|
|
30
35
|
node?: ReactNode;
|
|
36
|
+
className?: string;
|
|
37
|
+
button?: ToolbarPartButton;
|
|
38
|
+
/** Where what it opens hangs at its button (VK-994): its popover's `side`, `align` and `offset`. Absent, toward its side
|
|
39
|
+
* of its line, 8 px below it. */
|
|
40
|
+
panel?: ToolbarPanelPlace;
|
|
31
41
|
};
|
|
32
42
|
/** Which form's parts these are. */
|
|
33
43
|
export type ToolbarPartsContext = {
|
|
@@ -63,6 +73,15 @@ export type ReadyToolbarProps<Row> = SettingsPanelsInput<Row> & {
|
|
|
63
73
|
filter?: ToolbarPanelHost;
|
|
64
74
|
quick?: ToolbarPanelHost;
|
|
65
75
|
};
|
|
76
|
+
/** Where Customize opens on a computer (VK-1026): `"popover"`, the default, at its button; `"pane"`, in the components map's
|
|
77
|
+
* `Pane` (`CONTROLS.Pane`), at the right edge of `paneBox` under the toolbar, as tall as the list (where the list has a
|
|
78
|
+
* height of its own: a page that scrolls whole makes it as tall as every row), the list in use beside it. On a phone Customize keeps its Sheet either way. A map with no `Pane`, or an app's own `hosts.options`, keeps
|
|
79
|
+
* theirs. */
|
|
80
|
+
customizeIn?: "popover" | "pane";
|
|
81
|
+
/** The list's box the Pane stands in, with `customizeIn: "pane"`: positioned, holding the grid (which scrolls inside it)
|
|
82
|
+
* under the toolbar, never scrolling itself. Null until it is on the page; not handed, Customize opens in the popover.
|
|
83
|
+
* The ready `<List>` hands its own. */
|
|
84
|
+
paneBox?: HTMLElement | null;
|
|
66
85
|
/** Quick filters (VK-563): the fields offered, the hold and its writes. Handed, their button stands on the row. */
|
|
67
86
|
quickFilters?: QuickFiltersConfig;
|
|
68
87
|
/** The quick filters' panel open, when the app holds it (VK-566), so the reminder at its list's foot
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useId } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { ListRootBase } from "../../../list/root-base.js";
|
|
5
5
|
import { ListToolbar } from "../../../list/toolbar.js";
|
|
6
6
|
export function ReadyToolbar({ settings, layer, onChange, onLayerChange, view, sortFilter, bar, ...rest }) {
|
|
7
7
|
const id = useId();
|
|
8
|
-
return (_jsx(
|
|
8
|
+
return (_jsx(ListRootBase, { id: id, settings: settings, layer: layer, onChange: onChange, onLayerChange: onLayerChange, view: view, sortFilter: sortFilter, bar: bar, children: _jsx(ListToolbar, { ...rest }) }));
|
|
9
9
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
2
|
+
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
2
3
|
import type { ViewsMenuItem } from "../../../provider/components.js";
|
|
3
4
|
import { type ToolbarPlacement } from "../../toolbar/model.js";
|
|
5
|
+
import { type ToolbarPanelPlace } from "./context.js";
|
|
4
6
|
/** ⋯ as data (VK-741): the folded parts' rows, each keyed by its part, and which line's ⋯ they are in. */
|
|
5
7
|
export type ToolbarMore = (items: ViewsMenuItem[], ctx: {
|
|
6
8
|
line: "row" | "bar";
|
|
@@ -14,7 +16,16 @@ export type ToolbarPart = ToolbarPlacement & {
|
|
|
14
16
|
icon?: ReactNode;
|
|
15
17
|
onSelect: () => void;
|
|
16
18
|
};
|
|
19
|
+
/** Handed to every toolbar button the part draws (VK-984): its place's class. */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Drawn for every toolbar button the part draws, in place of the app's `ToolbarButton`, handed the same props (VK-984). */
|
|
22
|
+
button?: ToolbarPartButton;
|
|
23
|
+
/** Where what it opens hangs at its button (VK-994): its popover's side, align and offset. Absent, toward the part's
|
|
24
|
+
* side of its line, 8 px below it. */
|
|
25
|
+
panel?: ToolbarPanelPlace;
|
|
17
26
|
};
|
|
27
|
+
/** A place's own button (VK-984): a `ToolbarButton` of the app's, for one place. */
|
|
28
|
+
export type ToolbarPartButton = ComponentType<ViewsToolbarButtonProps>;
|
|
18
29
|
export declare function Toolbar({ parts, phone, narrow, narrowBelow, fold, more, className, }: {
|
|
19
30
|
parts: readonly ToolbarPart[];
|
|
20
31
|
/** The phone's one row; absent, the provider's answer (`desktopQuery`). */
|
|
@@ -6,7 +6,7 @@ import { useViews } from "../../../provider/context.js";
|
|
|
6
6
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
7
7
|
import { TOOLBAR_NARROW_BELOW, arrangeToolbar, foldState, foldSteps, toolbarForm, } from "../../toolbar/model.js";
|
|
8
8
|
import { useAnchoredToggle } from "../views-row/use-anchored-toggle.js";
|
|
9
|
-
import { ListRadioContext, NOT_FOLDING, ToolbarRadioContext, ToolbarSlotContext, useToolbarPanel, useToolbarRadioState } from "./context.js";
|
|
9
|
+
import { ListRadioContext, NOT_FOLDING, ToolbarRadioContext, ToolbarSlotContext, useToolbarPanel, useToolbarRadioState, } from "./context.js";
|
|
10
10
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
11
11
|
import { useBoxNarrow } from "./use-box-narrow.js";
|
|
12
12
|
import { useGiveWay } from "./use-give-way.js";
|
|
@@ -21,20 +21,31 @@ export function Toolbar({ parts, phone, narrow, narrowBelow = TOOLBAR_NARROW_BEL
|
|
|
21
21
|
const form = toolbarForm({ phone: phone ?? !desktop, narrow: fold ? false : (narrow ?? measured) });
|
|
22
22
|
const lines = arrangeToolbar(parts, form, { fold });
|
|
23
23
|
const nodes = new Map(parts.map((part) => [part.key, part.node]));
|
|
24
|
-
const placed = new Map(parts.map((part) => [
|
|
24
|
+
const placed = new Map(parts.map((part) => [
|
|
25
|
+
part.key,
|
|
26
|
+
{
|
|
27
|
+
key: part.key,
|
|
28
|
+
...(part.words && { words: part.words }),
|
|
29
|
+
...(part.foot !== undefined && { foot: part.foot }),
|
|
30
|
+
...(part.className && { className: part.className }),
|
|
31
|
+
...(part.button && { button: part.button }),
|
|
32
|
+
...(part.panel && { panel: part.panel }),
|
|
33
|
+
},
|
|
34
|
+
]));
|
|
25
35
|
if (fold) {
|
|
26
36
|
const menus = new Map(parts.flatMap((part) => (part.menu ? [[part.key, part.menu]] : [])));
|
|
27
37
|
return (_jsx(ToolbarRadioContext.Provider, { value: radio, children: _jsx("div", { ref: box, "data-slot": "vk-toolbar", "data-form": form, "data-fold": "", className: cx("@container flex w-full flex-col", className), children: lines.map((line) => (_jsx(FoldLine, { line: line, form: form, nodes: nodes, placed: placed, menus: menus, more: more, search: { open: searchOpen, onOpenChange: setSearchOpen } }, line.kind))) }) }));
|
|
28
38
|
}
|
|
29
39
|
return (_jsx(ToolbarRadioContext.Provider, { value: radio, children: _jsx("div", { ref: box, "data-slot": "vk-toolbar", "data-form": form, className: cx("flex w-full flex-col", form === "row" ? "gap-1" : "gap-2", className), children: lines.map((line) => (_jsx(Line, { line: line, form: form, nodes: nodes, placed: placed }, line.kind))) }) }));
|
|
30
40
|
}
|
|
41
|
+
const sideOf = (line, key) => (line.end.some((slot) => slot.key === key) ? "end" : "start");
|
|
31
42
|
function useLineName(kind) {
|
|
32
43
|
const { messages } = useViews();
|
|
33
44
|
return messages({ key: kind === "bar" || kind === "below" ? "views.panels.toolbar-bar" : "views.panels.toolbar-row" });
|
|
34
45
|
}
|
|
35
46
|
function Line({ line, form, nodes, placed }) {
|
|
36
47
|
const name = useLineName(line.kind);
|
|
37
|
-
const draw = (slots) => slots.map((slot) => (_jsx(ToolbarSlotContext.Provider, { value: { form, fill: slot.fill, size: line.size, line: line.kind, ...NOT_FOLDING, appFrame: false, ...placed.get(slot.key) }, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }, slot.key)));
|
|
48
|
+
const draw = (slots) => slots.map((slot) => (_jsx(ToolbarSlotContext.Provider, { value: { form, fill: slot.fill, size: line.size, line: line.kind, ...NOT_FOLDING, appFrame: false, side: sideOf(line, slot.key), ...placed.get(slot.key) }, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }, slot.key)));
|
|
38
49
|
const mark = { "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name };
|
|
39
50
|
if (line.kind === "main" && form === "row") {
|
|
40
51
|
return (_jsxs("div", { ...mark, "data-toolbar-row": true, className: "relative flex min-h-9 items-center empty:hidden", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: draw(line.start) }), line.end.length > 0 && (_jsx("div", { "data-slot": "vk-toolbar-cluster", "data-toolbar-cluster": true, className: "absolute inset-y-0 right-0 flex items-center gap-1 pl-8", style: { background: CLUSTER_FADE }, children: draw(line.end) }))] }));
|
|
@@ -87,6 +98,7 @@ function FoldLine({ line, form, nodes, placed, menus, more: reshape, search, })
|
|
|
87
98
|
more,
|
|
88
99
|
search: slot.search ? search : null,
|
|
89
100
|
appFrame: false,
|
|
101
|
+
side: sideOf(line, folded && state.moreAfter ? state.moreAfter : slot.key),
|
|
90
102
|
...placed.get(slot.key),
|
|
91
103
|
}, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }) }, slot.key));
|
|
92
104
|
if (slot.key !== state.moreAfter)
|
|
@@ -95,11 +107,13 @@ function FoldLine({ line, form, nodes, placed, menus, more: reshape, search, })
|
|
|
95
107
|
const menu = state.folded.has(s.key) ? menus.get(s.key) : undefined;
|
|
96
108
|
return menu ? [{ key: s.key, ...menu }] : [];
|
|
97
109
|
});
|
|
98
|
-
const align = line
|
|
110
|
+
const align = sideOf(line, slot.key);
|
|
99
111
|
return [itemNode, _jsx(Overflow, { anchor: more, rows: rows, reshape: reshape && ((items) => reshape(items, { line: line.kind === "bar" || line.kind === "below" ? "bar" : "row" })), size: line.size, form: form, align: align }, "vk-overflow")];
|
|
100
112
|
});
|
|
101
113
|
};
|
|
102
|
-
return (_jsxs("div", { ref: setElement, "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name, ...(line.kind === "main" ? { "data-toolbar-row": "" } : {}), className: cx("flex min-w-0 items-center", phone
|
|
114
|
+
return (_jsxs("div", { ref: setElement, "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name, ...(line.kind === "main" ? { "data-toolbar-row": "" } : {}), className: cx("flex min-w-0 items-center", phone
|
|
115
|
+
? "gap-1.5"
|
|
116
|
+
: "gap-(--vk-toolbar-line-gap,calc(var(--spacing)*2)) border-b-(length:--vk-toolbar-line-w,1px) border-(color:--vk-border-subtle) py-(--vk-toolbar-line-py,calc(var(--spacing)*2.5))"), children: [draw(line.start), !searchTakesLine && _jsx("span", { "data-toolbar-spacer": true, "aria-hidden": true, className: "min-w-0 flex-1" }), draw(line.end)] }));
|
|
103
117
|
}
|
|
104
118
|
const closingFirst = (items, setOpen) => items.map((item) => ({
|
|
105
119
|
...item,
|
|
@@ -117,7 +131,7 @@ function Overflow({ anchor, rows, reshape, size, form, align, }) {
|
|
|
117
131
|
const items = list.map((row) => ({ key: row.key, label: row.label, icon: row.icon, onSelect: row.onSelect }));
|
|
118
132
|
return reshape ? reshape(items) : items;
|
|
119
133
|
};
|
|
120
|
-
return (_jsxs("span", { "data-slot": "vk-toolbar-overflow", className: "relative inline-flex shrink-0", children: [_jsx(ToolbarSlotContext.Provider, { value: { form, fill: false, size, line: "main", ...NOT_FOLDING, iconAlone: true, appFrame: false }, children: _jsx(ToolbarButton, { ref: anchor, icon: _jsx(More, { className: "h-4 w-4 shrink-0" }), label: name, word: null, popup: "menu", open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick }) }), _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: align, label: name, items: closingFirst(own(rows), toggle.setOpen) })] }));
|
|
134
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-overflow", className: "relative inline-flex shrink-0", children: [_jsx(ToolbarSlotContext.Provider, { value: { form, fill: false, size, line: "main", ...NOT_FOLDING, iconAlone: true, appFrame: false }, children: _jsx(ToolbarButton, { part: "more", ref: anchor, icon: _jsx(More, { className: "h-4 w-4 shrink-0" }), label: name, word: null, popup: "menu", open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick }) }), _jsx(Menu, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: align, label: name, items: closingFirst(own(rows), toggle.setOpen) })] }));
|
|
121
135
|
}
|
|
122
136
|
export function ToolbarSeparator() {
|
|
123
137
|
return _jsx("span", { role: "separator", "aria-orientation": "vertical", "data-slot": "vk-toolbar-separator", className: "h-4 w-px shrink-0 self-center bg-(color:--vk-border)" });
|
|
@@ -5,7 +5,7 @@ import { advancedFiltersOf, followAdvancedKeys, } from "../../../filters/filter-
|
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { FilterEditorHost } from "../filter/FilterEditor.js";
|
|
7
7
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
8
|
-
import { useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
8
|
+
import { usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
9
9
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
10
10
|
export function ToolbarAdvancedFilters({ filterTree, host, }) {
|
|
11
11
|
const phone = useSheetPanels();
|
|
@@ -65,12 +65,13 @@ export function AdvancedFilterPill({ filterTree, at, count, aside = false, host:
|
|
|
65
65
|
const name = messages({ key: "views.panels.advanced-filter" });
|
|
66
66
|
const openAtPress = useRef(false);
|
|
67
67
|
const anchor = foldedAt ?? pill;
|
|
68
|
+
const hangs = usePanelPlace("end");
|
|
68
69
|
const close = (focus = true) => {
|
|
69
70
|
panel.onOpenChange(false);
|
|
70
71
|
if (focus)
|
|
71
72
|
anchor.current?.focus({ preventScroll: true });
|
|
72
73
|
};
|
|
73
|
-
const button = (_jsx(ToolbarButton, { ref: pill, icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, changed: !aside, aside: aside, more: aside ? undefined : String(count), popup: "dialog", open: panel.open, onPointerDown: () => {
|
|
74
|
+
const button = (_jsx(ToolbarButton, { ref: pill, part: "advanced-filters", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, changed: !aside, aside: aside, more: aside ? undefined : String(count), popup: "dialog", open: panel.open, onPointerDown: () => {
|
|
74
75
|
openAtPress.current = panel.open;
|
|
75
76
|
}, onClick: (event) => {
|
|
76
77
|
const wasOpen = event.detail === 0 ? panel.open : openAtPress.current;
|
|
@@ -81,5 +82,5 @@ export function AdvancedFilterPill({ filterTree, at, count, aside = false, host:
|
|
|
81
82
|
return (_jsxs("span", { "data-slot": "vk-toolbar-advanced-filter", "data-open": (slot.fold || foldedAt) && panel.open ? "" : undefined, hidden: foldedAt ? true : undefined, className: "relative inline-flex shrink-0 items-center", children: [aside ? (_jsx(Tooltip, { content: messages({ key: "views.panels.advanced-filter-set-aside" }), side: "bottom", children: _jsx("span", { className: "inline-flex min-w-0", children: button }) })) : (button), Host ? (_jsx(Host, { open: panel.open, onOpenChange: panel.onOpenChange, title: name, children: content })) : (_jsx(Popover, { open: panel.open, onOpenChange: (next, details) => {
|
|
82
83
|
if (!next)
|
|
83
84
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
84
|
-
}, anchor: anchor,
|
|
85
|
+
}, anchor: anchor, ...hangs, chrome: "panel", className: "w-fit max-w-[calc(100vw-2rem)]", panelData: { "data-slot": "vk-toolbar-advanced-filter-panel" }, children: content }))] }));
|
|
85
86
|
}
|
|
@@ -45,12 +45,12 @@ export function ToolbarAsideFilter({ ctx, path, node, open, onOpenChange, folded
|
|
|
45
45
|
if (details?.reason !== "outside-press" && details?.reason !== "focus-out")
|
|
46
46
|
anchorOf(part).current?.focus({ preventScroll: true });
|
|
47
47
|
};
|
|
48
|
-
return (_jsxs("span", { ref: placeBox, "data-slot": "vk-toolbar-filter-aside", "data-aside": "", role: "group", "aria-label": words.sentence, "data-open": open ? "" : undefined, hidden: foldedAt ? true : undefined, className: "relative inline-flex min-w-0 shrink-0 items-center", children: [_jsx(Tooltip, { content: words.why, side: "bottom", children: _jsx("span", { className: "inline-flex min-w-0", children: _jsx(ToolbarButton, { ref: fieldBox, icon: null, label: messages({ key: "views.panels.filter-field" }), joined: "start", aside: true, popup: "dialog", open: open === "field", ...press("field"), children: words.field }) }) }), _jsx(Popover, { open: open === "field", onOpenChange: closed("field"), anchor: anchorOf("field"), align: "start", sideOffset: 8, chrome: "menu", children: _jsx(FilterFieldList, { fields: listedFieldsOf(ctx.filterTree), relations: true, onPick: (picked, far) => {
|
|
48
|
+
return (_jsxs("span", { ref: placeBox, "data-slot": "vk-toolbar-filter-aside", "data-aside": "", role: "group", "aria-label": words.sentence, "data-open": open ? "" : undefined, hidden: foldedAt ? true : undefined, className: "relative inline-flex min-w-0 shrink-0 items-center", children: [_jsx(Tooltip, { content: words.why, side: "bottom", children: _jsx("span", { className: "inline-flex min-w-0", children: _jsx(ToolbarButton, { part: "filters", ref: fieldBox, icon: null, label: messages({ key: "views.panels.filter-field" }), joined: "start", aside: true, popup: "dialog", open: open === "field", ...press("field"), children: words.field }) }) }), _jsx(Popover, { open: open === "field", onOpenChange: closed("field"), anchor: anchorOf("field"), align: "start", sideOffset: 8, chrome: "menu", children: _jsx(FilterFieldList, { fields: listedFieldsOf(ctx.filterTree), relations: true, onPick: (picked, far) => {
|
|
49
49
|
onOpenChange(null);
|
|
50
50
|
const result = repointBarFilter(ctx, path, node, picked, far);
|
|
51
51
|
if (result)
|
|
52
52
|
onRepointed?.(result);
|
|
53
|
-
}, onDone: () => onOpenChange(null) }) }), _jsx(ToolbarButton, { icon: null, label: messages({ key: "views.panels.filter-way" }), joined: "middle", disabled: true, disabledReason: words.why, children: words.way }), words.value !== null && (_jsx("span", { "data-part": "value", className: "inline-flex min-w-0 max-w-60", children: _jsx(ToolbarButton, { icon: null, label: messages({ key: "views.panels.filter-value" }), joined: "middle", disabled: true, disabledReason: words.why, children: words.value }) })), _jsx(ToolbarButton, { ref: menuBox, icon: _jsx(More, { className: "h-4 w-4 shrink-0" }), label: actions, joined: "end", iconAlone: true, popup: "menu", open: open === "menu", ...press("menu") }), _jsx(Menu, { open: open === "menu", onOpenChange: closed("menu"), anchor: anchorOf("menu"), align: "end", label: actions, items: [
|
|
53
|
+
}, onDone: () => onOpenChange(null) }) }), _jsx(ToolbarButton, { part: "filters", icon: null, label: messages({ key: "views.panels.filter-way" }), joined: "middle", disabled: true, disabledReason: words.why, children: words.way }), words.value !== null && (_jsx("span", { "data-part": "value", className: "inline-flex min-w-0 max-w-60", children: _jsx(ToolbarButton, { part: "filters", icon: null, label: messages({ key: "views.panels.filter-value" }), joined: "middle", disabled: true, disabledReason: words.why, children: words.value }) })), _jsx(ToolbarButton, { part: "filters", ref: menuBox, icon: _jsx(More, { className: "h-4 w-4 shrink-0" }), label: actions, joined: "end", iconAlone: true, popup: "menu", open: open === "menu", ...press("menu") }), _jsx(Menu, { open: open === "menu", onOpenChange: closed("menu"), anchor: anchorOf("menu"), align: "end", label: actions, items: [
|
|
54
54
|
{ key: "why", label: words.why, disabled: true },
|
|
55
55
|
...(fits
|
|
56
56
|
? [
|