viewkitjs 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +8 -2
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -4
- package/views/dist/controls/avatar/avatar.js +5 -3
- package/views/dist/controls/avatar/tokens.d.ts +104 -0
- package/views/dist/controls/avatar/tokens.js +26 -0
- package/views/dist/controls/avatar.css +46 -15
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/input/input.d.ts +12 -1
- package/views/dist/controls/input/input.js +10 -6
- package/views/dist/controls/input/save-mark.d.ts +8 -0
- package/views/dist/controls/input/save-mark.js +26 -0
- package/views/dist/controls/input/tokens.d.ts +20 -0
- package/views/dist/controls/input/tokens.js +5 -0
- package/views/dist/controls/input.css +49 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +12 -3
- package/views/dist/controls/radio/radio.js +25 -5
- package/views/dist/controls/radio/tokens.d.ts +84 -0
- package/views/dist/controls/radio/tokens.js +21 -0
- package/views/dist/controls/radio.css +130 -3
- package/views/dist/controls/select/select.d.ts +12 -2
- package/views/dist/controls/select/select.js +15 -7
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +10 -0
- package/views/dist/controls/setting-row/looks.js +22 -0
- package/views/dist/controls/setting-row/setting-row.d.ts +100 -0
- package/views/dist/controls/setting-row/setting-row.js +133 -0
- package/views/dist/controls/setting-row/tokens.d.ts +156 -0
- package/views/dist/controls/setting-row/tokens.js +41 -0
- package/views/dist/controls/setting-row.css +215 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/switch-row.d.ts +1 -15
- package/views/dist/controls/switch-row/switch-row.js +1 -9
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/tokens.js +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +583 -61
- package/views/dist/styles.unlayered.css +583 -61
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +26 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +9 -0
- package/views/docs/controls/radio.md +33 -0
- package/views/docs/controls/select.md +6 -0
- package/views/docs/controls/setting-row.md +44 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +54 -27
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +3 -0
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { applySettingsChange, settingsChange, settingsForSaving, } from "viewkitjs/fields/query";
|
|
2
|
+
export function toastTime() {
|
|
3
|
+
if (typeof document === "undefined")
|
|
4
|
+
return 4000;
|
|
5
|
+
const msOf = (el) => {
|
|
6
|
+
if (!el)
|
|
7
|
+
return 0;
|
|
8
|
+
const value = getComputedStyle(el).getPropertyValue("--vk-toast-duration").trim();
|
|
9
|
+
const n = parseFloat(value);
|
|
10
|
+
if (Number.isNaN(n))
|
|
11
|
+
return 0;
|
|
12
|
+
return /\dms$/.test(value) ? n : /\ds$/.test(value) ? n * 1000 : n;
|
|
13
|
+
};
|
|
14
|
+
return msOf(document.querySelector(".o-toast-viewport")) || msOf(document.documentElement) || 4000;
|
|
15
|
+
}
|
|
16
|
+
const isThenable = (value) => typeof value?.then === "function";
|
|
17
|
+
const messageOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
18
|
+
const withSearch = (settings, search) => search === undefined ? settingsForSaving(settings) : { ...settings, search };
|
|
19
|
+
export function createListViews(o) {
|
|
20
|
+
const { id: listId, store } = o;
|
|
21
|
+
const link = o.link && (o.link.view !== undefined || Object.keys(o.link.change).some((k) => k !== "search")) ? o.link : null;
|
|
22
|
+
const linkSearch = o.link?.change.search;
|
|
23
|
+
const share = !!store.can?.share;
|
|
24
|
+
const records = o.records ?? "records";
|
|
25
|
+
let generation = 0;
|
|
26
|
+
let ready = false;
|
|
27
|
+
let list = [];
|
|
28
|
+
let open = null;
|
|
29
|
+
let edited = o.defaults;
|
|
30
|
+
let base = null;
|
|
31
|
+
let layer = {};
|
|
32
|
+
let writes = 0;
|
|
33
|
+
let waitingChanges = [];
|
|
34
|
+
let waitingLayer = null;
|
|
35
|
+
const held = new Map();
|
|
36
|
+
const gone = new Map();
|
|
37
|
+
const openOf = () => (open === null ? undefined : list.find((v) => v.id === open));
|
|
38
|
+
const savedOf = () => openOf()?.settings ?? settingsForSaving(o.defaults);
|
|
39
|
+
const draftKey = () => open ?? "";
|
|
40
|
+
const changeOf = () => settingsChange(savedOf(), settingsForSaving(edited));
|
|
41
|
+
const canSave = (view) => !view.readOnly && (view.scope === "personal" || share);
|
|
42
|
+
const tell = () => o.onChange();
|
|
43
|
+
const run = (call, done, failed, gated = true) => {
|
|
44
|
+
const at = generation;
|
|
45
|
+
let value;
|
|
46
|
+
try {
|
|
47
|
+
value = call();
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
failed(error);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!isThenable(value))
|
|
54
|
+
return done(value);
|
|
55
|
+
value.then((answer) => (!gated || at === generation) && done(answer), (error) => (!gated || at === generation) && failed(error));
|
|
56
|
+
};
|
|
57
|
+
const readFailed = (error) => o.onError(messageOf(error));
|
|
58
|
+
const write = (call, done = () => { }) => {
|
|
59
|
+
const at = generation;
|
|
60
|
+
writes += 1;
|
|
61
|
+
tell();
|
|
62
|
+
run(call, (value) => {
|
|
63
|
+
writes -= 1;
|
|
64
|
+
if (at === generation)
|
|
65
|
+
done(value);
|
|
66
|
+
tell();
|
|
67
|
+
}, (error) => {
|
|
68
|
+
writes -= 1;
|
|
69
|
+
o.onError(messageOf(error));
|
|
70
|
+
if (at === generation)
|
|
71
|
+
refresh();
|
|
72
|
+
tell();
|
|
73
|
+
}, false);
|
|
74
|
+
};
|
|
75
|
+
const writeDraft = () => {
|
|
76
|
+
const change = changeOf();
|
|
77
|
+
const { search: _search, ...kept } = change;
|
|
78
|
+
if (Object.keys(kept).length === 0) {
|
|
79
|
+
base = null;
|
|
80
|
+
write(() => store.draft.set(listId, draftKey(), null));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (base === null)
|
|
84
|
+
base = openOf()?.updatedAt ?? "";
|
|
85
|
+
const draft = { change: kept, base };
|
|
86
|
+
write(() => store.draft.set(listId, draftKey(), draft));
|
|
87
|
+
};
|
|
88
|
+
const opening = (view, then) => {
|
|
89
|
+
const search = edited.search;
|
|
90
|
+
open = view?.id ?? null;
|
|
91
|
+
base = null;
|
|
92
|
+
edited = withSearch(view?.settings ?? o.defaults, search);
|
|
93
|
+
const key = draftKey();
|
|
94
|
+
run(() => store.draft.get(listId, key), (draft) => {
|
|
95
|
+
if (draftKey() !== key)
|
|
96
|
+
return;
|
|
97
|
+
if (draft) {
|
|
98
|
+
edited = withSearch(applySettingsChange(view?.settings ?? settingsForSaving(o.defaults), draft.change), search);
|
|
99
|
+
base = draft.base;
|
|
100
|
+
}
|
|
101
|
+
then?.();
|
|
102
|
+
tell();
|
|
103
|
+
}, readFailed);
|
|
104
|
+
};
|
|
105
|
+
const same = (a, b) => a.id === b.id && a.updatedAt === b.updatedAt && a.position === b.position && a.name === b.name && a.scope === b.scope && !!a.readOnly === !!b.readOnly;
|
|
106
|
+
const listing = (views) => {
|
|
107
|
+
const next = views.filter((v) => !held.has(v.id));
|
|
108
|
+
return next.length === list.length && next.every((v, i) => same(v, list[i])) ? list : next;
|
|
109
|
+
};
|
|
110
|
+
const edits = () => Object.keys(changeOf()).some((key) => key !== "search");
|
|
111
|
+
const refresh = () => {
|
|
112
|
+
run(() => store.list(listId), (views) => {
|
|
113
|
+
const was = openOf();
|
|
114
|
+
const editing = edits();
|
|
115
|
+
const before = list;
|
|
116
|
+
list = listing(views);
|
|
117
|
+
if (list === before)
|
|
118
|
+
return;
|
|
119
|
+
const now = openOf();
|
|
120
|
+
if (open !== null && !now)
|
|
121
|
+
opening(list[0]);
|
|
122
|
+
else if (now && was && now.updatedAt !== was.updatedAt && !editing)
|
|
123
|
+
edited = withSearch(now.settings, edited.search);
|
|
124
|
+
tell();
|
|
125
|
+
}, readFailed);
|
|
126
|
+
};
|
|
127
|
+
const layered = (under, over) => {
|
|
128
|
+
const merged = { ...under };
|
|
129
|
+
for (const [key, value] of Object.entries(over)) {
|
|
130
|
+
const was = merged[key];
|
|
131
|
+
const record = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
132
|
+
merged[key] = record(was) && record(value) ? { ...was, ...value } : value;
|
|
133
|
+
}
|
|
134
|
+
return merged;
|
|
135
|
+
};
|
|
136
|
+
const load = () => {
|
|
137
|
+
run(() => store.list(listId), (views) => {
|
|
138
|
+
list = listing(views);
|
|
139
|
+
const linked = link?.view !== undefined ? list.find((v) => v.id === link.view) : undefined;
|
|
140
|
+
const view = linked ?? list[0];
|
|
141
|
+
const land = (draft) => {
|
|
142
|
+
open = view?.id ?? null;
|
|
143
|
+
const saved = view?.settings ?? settingsForSaving(o.defaults);
|
|
144
|
+
const change = link ? link.change : { ...draft?.change, ...(linkSearch !== undefined && { search: linkSearch }) };
|
|
145
|
+
let next = applySettingsChange(view ? saved : o.defaults, change);
|
|
146
|
+
for (const waiting of waitingChanges)
|
|
147
|
+
next = applySettingsChange(next, waiting);
|
|
148
|
+
edited = next;
|
|
149
|
+
base = link ? null : draft?.base ?? null;
|
|
150
|
+
run(() => store.layer.get(listId), (stored) => {
|
|
151
|
+
layer = waitingLayer ? layered(stored, waitingLayer) : stored;
|
|
152
|
+
ready = true;
|
|
153
|
+
if (waitingChanges.length > 0)
|
|
154
|
+
writeDraft();
|
|
155
|
+
if (waitingLayer)
|
|
156
|
+
write(() => store.layer.set(listId, layer));
|
|
157
|
+
waitingChanges = [];
|
|
158
|
+
waitingLayer = null;
|
|
159
|
+
tell();
|
|
160
|
+
}, readFailed);
|
|
161
|
+
};
|
|
162
|
+
if (link)
|
|
163
|
+
land(null);
|
|
164
|
+
else
|
|
165
|
+
run(() => store.draft.get(listId, view?.id ?? ""), land, readFailed);
|
|
166
|
+
}, readFailed);
|
|
167
|
+
};
|
|
168
|
+
const start = () => {
|
|
169
|
+
generation += 1;
|
|
170
|
+
const at = generation;
|
|
171
|
+
load();
|
|
172
|
+
const stopFollowing = store.subscribe?.(listId, () => (ready ? refresh() : load()));
|
|
173
|
+
const leaving = () => flushHolds();
|
|
174
|
+
if (typeof window !== "undefined")
|
|
175
|
+
window.addEventListener("pagehide", leaving);
|
|
176
|
+
return () => {
|
|
177
|
+
if (generation === at)
|
|
178
|
+
generation += 1;
|
|
179
|
+
stopFollowing?.();
|
|
180
|
+
if (typeof window !== "undefined")
|
|
181
|
+
window.removeEventListener("pagehide", leaving);
|
|
182
|
+
flushHolds();
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
const letGo = (id) => {
|
|
186
|
+
const hold = held.get(id);
|
|
187
|
+
if (!hold)
|
|
188
|
+
return;
|
|
189
|
+
clearTimeout(hold.timer);
|
|
190
|
+
held.delete(id);
|
|
191
|
+
gone.set(id, hold.view);
|
|
192
|
+
write(() => store.remove(listId, id));
|
|
193
|
+
};
|
|
194
|
+
const flushHolds = () => {
|
|
195
|
+
for (const id of [...held.keys()])
|
|
196
|
+
letGo(id);
|
|
197
|
+
};
|
|
198
|
+
const scopeOrder = (views) => [
|
|
199
|
+
...views.filter((v) => v.scope === "shared"),
|
|
200
|
+
...views.filter((v) => v.scope === "personal"),
|
|
201
|
+
];
|
|
202
|
+
const inputOf = (view, patch = {}) => ({
|
|
203
|
+
id: view.id,
|
|
204
|
+
name: view.name,
|
|
205
|
+
scope: view.scope,
|
|
206
|
+
position: view.position,
|
|
207
|
+
settings: view.settings,
|
|
208
|
+
...patch,
|
|
209
|
+
});
|
|
210
|
+
const replace = (saved) => {
|
|
211
|
+
list = list.some((v) => v.id === saved.id) ? list.map((v) => (v.id === saved.id ? saved : v)) : scopeOrder([...list, saved]);
|
|
212
|
+
};
|
|
213
|
+
const endOf = (scope) => list.reduce((most, v) => (v.scope === scope ? Math.max(most, v.position) : most), -1) + 1;
|
|
214
|
+
const reorder = (scope, ids) => {
|
|
215
|
+
if (!ready || (scope === "shared" && !share))
|
|
216
|
+
return;
|
|
217
|
+
const block = ids.map((id) => list.find((v) => v.id === id && v.scope === scope)).filter((v) => !!v);
|
|
218
|
+
const moved = block.map((v, position) => ({ ...v, position }));
|
|
219
|
+
list = scope === "shared" ? [...moved, ...list.filter((v) => v.scope !== "shared")] : [...list.filter((v) => v.scope !== "personal"), ...moved];
|
|
220
|
+
tell();
|
|
221
|
+
write(() => store.reorder(listId, scope, ids));
|
|
222
|
+
};
|
|
223
|
+
const actions = {
|
|
224
|
+
openView: (id) => {
|
|
225
|
+
if (!ready || id === open)
|
|
226
|
+
return;
|
|
227
|
+
const view = list.find((v) => v.id === id);
|
|
228
|
+
if (!view)
|
|
229
|
+
return;
|
|
230
|
+
opening(view);
|
|
231
|
+
tell();
|
|
232
|
+
},
|
|
233
|
+
save: () => {
|
|
234
|
+
const view = openOf();
|
|
235
|
+
if (!ready || !view || !canSave(view))
|
|
236
|
+
return;
|
|
237
|
+
write(() => store.save(listId, inputOf(view, { settings: settingsForSaving(edited) })), (saved) => {
|
|
238
|
+
replace(saved);
|
|
239
|
+
base = null;
|
|
240
|
+
write(() => store.draft.set(listId, saved.id, null));
|
|
241
|
+
refresh();
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
saveAs: (name, options = {}) => {
|
|
245
|
+
if (!ready)
|
|
246
|
+
return;
|
|
247
|
+
const from = options.from === undefined ? undefined : list.find((v) => v.id === options.from);
|
|
248
|
+
const settings = from
|
|
249
|
+
? from.id === open
|
|
250
|
+
? settingsForSaving(edited)
|
|
251
|
+
: from.settings
|
|
252
|
+
: settingsForSaving({ ...o.defaults, layout: options.layout ?? o.defaults.layout });
|
|
253
|
+
write(() => store.save(listId, { name, scope: "personal", position: endOf("personal"), settings: settings }), (saved) => {
|
|
254
|
+
if (from)
|
|
255
|
+
write(() => store.draft.set(listId, from.id, null));
|
|
256
|
+
replace(saved);
|
|
257
|
+
const search = edited.search;
|
|
258
|
+
open = saved.id;
|
|
259
|
+
base = null;
|
|
260
|
+
edited = withSearch(saved.settings, search);
|
|
261
|
+
refresh();
|
|
262
|
+
});
|
|
263
|
+
},
|
|
264
|
+
rename: (id, name) => {
|
|
265
|
+
const view = list.find((v) => v.id === id);
|
|
266
|
+
if (!ready || !view || !canSave(view) || !name.trim())
|
|
267
|
+
return;
|
|
268
|
+
write(() => store.save(listId, inputOf(view, { name: name.trim() })), (saved) => {
|
|
269
|
+
replace(saved);
|
|
270
|
+
if (saved.id === open && base === view.updatedAt) {
|
|
271
|
+
base = saved.updatedAt;
|
|
272
|
+
writeDraft();
|
|
273
|
+
}
|
|
274
|
+
refresh();
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
duplicate: (id, name) => {
|
|
278
|
+
const view = list.find((v) => v.id === id);
|
|
279
|
+
if (!ready || !view)
|
|
280
|
+
return;
|
|
281
|
+
const scope = view.scope === "shared" && share ? "shared" : "personal";
|
|
282
|
+
write(() => store.save(listId, { name, scope, position: endOf(scope), settings: view.settings }), (saved) => {
|
|
283
|
+
replace(saved);
|
|
284
|
+
const block = list.filter((v) => v.scope === scope && v.id !== saved.id).map((v) => v.id);
|
|
285
|
+
const after = block.indexOf(view.id);
|
|
286
|
+
if (after >= 0 && after < block.length - 1)
|
|
287
|
+
reorder(scope, [...block.slice(0, after + 1), saved.id, ...block.slice(after + 1)]);
|
|
288
|
+
opening(saved);
|
|
289
|
+
refresh();
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
remove: (id) => {
|
|
293
|
+
const index = list.findIndex((v) => v.id === id);
|
|
294
|
+
const view = list[index];
|
|
295
|
+
if (!ready || !view || !canSave(view))
|
|
296
|
+
return;
|
|
297
|
+
held.set(id, { view, index, timer: setTimeout(() => letGo(id), o.holdMs ?? toastTime()) });
|
|
298
|
+
list = list.filter((v) => v.id !== id);
|
|
299
|
+
if (open === id)
|
|
300
|
+
opening(list[0]);
|
|
301
|
+
tell();
|
|
302
|
+
},
|
|
303
|
+
restore: (id, reopen) => {
|
|
304
|
+
const hold = held.get(id);
|
|
305
|
+
if (hold) {
|
|
306
|
+
clearTimeout(hold.timer);
|
|
307
|
+
held.delete(id);
|
|
308
|
+
list = [...list.slice(0, hold.index), hold.view, ...list.slice(hold.index)];
|
|
309
|
+
if (reopen)
|
|
310
|
+
opening(hold.view);
|
|
311
|
+
tell();
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const was = gone.get(id);
|
|
315
|
+
if (!was)
|
|
316
|
+
return;
|
|
317
|
+
write(() => store.save(listId, inputOf(was)), (saved) => {
|
|
318
|
+
gone.delete(id);
|
|
319
|
+
replace(saved);
|
|
320
|
+
if (reopen)
|
|
321
|
+
opening(saved);
|
|
322
|
+
refresh();
|
|
323
|
+
});
|
|
324
|
+
},
|
|
325
|
+
reorder,
|
|
326
|
+
reset: () => {
|
|
327
|
+
if (!ready)
|
|
328
|
+
return;
|
|
329
|
+
edited = withSearch(savedOf(), edited.search);
|
|
330
|
+
writeDraft();
|
|
331
|
+
tell();
|
|
332
|
+
},
|
|
333
|
+
canSave,
|
|
334
|
+
};
|
|
335
|
+
const setSettings = (change) => {
|
|
336
|
+
edited = applySettingsChange(edited, change);
|
|
337
|
+
if (ready)
|
|
338
|
+
writeDraft();
|
|
339
|
+
else
|
|
340
|
+
waitingChanges = [...waitingChanges, change];
|
|
341
|
+
tell();
|
|
342
|
+
};
|
|
343
|
+
const setLayer = (given) => {
|
|
344
|
+
const patch = given.widths ? { ...given, widths: fitWidths(given.widths) } : given;
|
|
345
|
+
layer = { ...layer, ...patch };
|
|
346
|
+
if (ready)
|
|
347
|
+
write(() => store.layer.set(listId, layer));
|
|
348
|
+
else
|
|
349
|
+
waitingLayer = { ...waitingLayer, ...patch };
|
|
350
|
+
tell();
|
|
351
|
+
};
|
|
352
|
+
let shown;
|
|
353
|
+
const viewState = () => {
|
|
354
|
+
const view = openOf();
|
|
355
|
+
if (!view)
|
|
356
|
+
return (shown = undefined);
|
|
357
|
+
const { search: _search, ...change } = changeOf();
|
|
358
|
+
const next = {
|
|
359
|
+
changes: Object.keys(change).length,
|
|
360
|
+
stale: base !== null && base !== "" && Date.parse(base) < Date.parse(view.updatedAt),
|
|
361
|
+
canPublish: canSave(view),
|
|
362
|
+
own: view.scope === "personal",
|
|
363
|
+
pending: writes > 0,
|
|
364
|
+
};
|
|
365
|
+
if (shown && Object.keys(next).every((key) => shown[key] === next[key]))
|
|
366
|
+
return shown;
|
|
367
|
+
return (shown = { ...next, onReset: actions.reset, onPublish: actions.save });
|
|
368
|
+
};
|
|
369
|
+
let synced;
|
|
370
|
+
let slice;
|
|
371
|
+
return {
|
|
372
|
+
sync: (extra) => {
|
|
373
|
+
const view = viewState();
|
|
374
|
+
if (synced &&
|
|
375
|
+
synced.settings === edited &&
|
|
376
|
+
synced.layer === layer &&
|
|
377
|
+
synced.view === view &&
|
|
378
|
+
synced.sortFilter === extra.sortFilter &&
|
|
379
|
+
synced.bar === extra.bar)
|
|
380
|
+
return synced;
|
|
381
|
+
return (synced = {
|
|
382
|
+
settings: edited,
|
|
383
|
+
layer,
|
|
384
|
+
onChange: setSettings,
|
|
385
|
+
onLayerChange: setLayer,
|
|
386
|
+
...(view && { view }),
|
|
387
|
+
...(extra.sortFilter !== undefined && { sortFilter: extra.sortFilter }),
|
|
388
|
+
...(extra.bar !== undefined && { bar: extra.bar }),
|
|
389
|
+
});
|
|
390
|
+
},
|
|
391
|
+
start,
|
|
392
|
+
state: () => {
|
|
393
|
+
const pending = writes > 0;
|
|
394
|
+
if (slice && slice.list === list && slice.open === open && slice.ready === ready && slice.pending === pending)
|
|
395
|
+
return slice;
|
|
396
|
+
return (slice = { ...actions, list, open, ready, share, pending, records });
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const fitWidths = (widths) => Object.fromEntries(Object.entries(widths).map(([key, width]) => [key, Math.round(Math.min(2000, Math.max(24, width)))]));
|
|
@@ -21,6 +21,7 @@ export { TOGGLE_LOOKS, type ToggleLookOptionId } from "../controls/toggle/looks.
|
|
|
21
21
|
export { OPTION_LOOKS, optionColours, type OptionColour, type OptionLookOptionId } from "../controls/option/looks.js";
|
|
22
22
|
export { STATUS_LOOKS, type StatusLookOptionId } from "../controls/status/looks.js";
|
|
23
23
|
export { SWITCH_LOOKS, type SwitchLookOptionId } from "../controls/switch/looks.js";
|
|
24
|
+
export { SETTING_ROW_LOOKS, type SettingRowOptionId, type SettingRowPicks } from "../controls/setting-row/looks.js";
|
|
24
25
|
export { TAG_LOOKS, type TagLookOptionId } from "../controls/tag/looks.js";
|
|
25
26
|
export { MENU_LIST_LOOKS, type MenuListLookOptionId } from "../controls/menu-list/looks.js";
|
|
26
27
|
export { LIST_LOOKS, type ListOptionId } from "../controls/list/looks.js";
|
|
@@ -17,6 +17,7 @@ export { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
|
17
17
|
export { OPTION_LOOKS, optionColours } from "../controls/option/looks.js";
|
|
18
18
|
export { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
19
19
|
export { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
20
|
+
export { SETTING_ROW_LOOKS } from "../controls/setting-row/looks.js";
|
|
20
21
|
export { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
21
22
|
export { MENU_LIST_LOOKS } from "../controls/menu-list/looks.js";
|
|
22
23
|
export { LIST_LOOKS } from "../controls/list/looks.js";
|
|
@@ -15,6 +15,7 @@ import { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
|
15
15
|
import { OPTION_LOOKS } from "../controls/option/looks.js";
|
|
16
16
|
import { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
17
17
|
import { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
18
|
+
import { SETTING_ROW_LOOKS } from "../controls/setting-row/looks.js";
|
|
18
19
|
import { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
19
20
|
import { MENU_LIST_LOOKS } from "../controls/menu-list/looks.js";
|
|
20
21
|
import { AVATAR_LOOKS } from "../controls/avatar/looks.js";
|
|
@@ -55,6 +56,7 @@ export const LOOKS = [
|
|
|
55
56
|
TAG_LOOKS,
|
|
56
57
|
STATUS_LOOKS,
|
|
57
58
|
SWITCH_LOOKS,
|
|
59
|
+
SETTING_ROW_LOOKS,
|
|
58
60
|
MENU_LIST_LOOKS,
|
|
59
61
|
LIST_LOOKS,
|
|
60
62
|
PICKER_LOOKS,
|
|
@@ -5,7 +5,7 @@ export { getViewOptionAvailability, resolvePersonalSection } from "./availabilit
|
|
|
5
5
|
export { groupSortChoices, groupSortValue, offersManualOrder } from "./group-sort.js";
|
|
6
6
|
export { useFilterOpened } from "./use-filter-opened.js";
|
|
7
7
|
export { GROUP_BY_SEARCH_AFTER, activeGroupDimension, dateRangeValueLabel, drawsUnnamedValue, filterRowValueLabel, filterValueLabel, groupDateByLabel, groupSortLabel, groupValueLabel, layoutValueLabel, matchGroupDimensions, matchSortOptions, relationSentence, sortValueLabel, timeScopeRowValueLabel, } from "./labels.js";
|
|
8
|
-
export type { CollectionChildAxis, CollectionViewsConfig, CollectionViewsInput, PillOption, ViewTabOption, ViewsLayout, } from "./views-row/model.js";
|
|
8
|
+
export type { CollectionChildAxis, CollectionViewsConfig, CollectionViewsInput, PillOption, PillViewMenu, ViewTabOption, ViewsLayout, } from "./views-row/model.js";
|
|
9
9
|
export { splitViewAxes, toViewAxes } from "./views-row/model.js";
|
|
10
10
|
export { settingsPanels } from "./settings/settings-panels.js";
|
|
11
11
|
export type { SettingsPanels } from "./settings/settings-panels.js";
|
|
@@ -24,6 +24,8 @@ export { TOOLBAR_NARROW_BELOW, arrangeToolbar, foldState, foldSteps, toolbarForm
|
|
|
24
24
|
export type { FoldStep, ToolbarForm, ToolbarLine, ToolbarPlacement, ToolbarSlot } from "./toolbar/model.js";
|
|
25
25
|
export { SHOW_COUNTS_KEY, countsToggle, groupShown, showCountsChange, showCountsOf, withCounts, } from "./toolbar/counts.js";
|
|
26
26
|
export { withEditView } from "./toolbar/edit-view.js";
|
|
27
|
+
export { withViewMenu } from "./toolbar/edit-view.js";
|
|
28
|
+
export type { ViewMenuFn } from "./toolbar/edit-view.js";
|
|
27
29
|
export { settingsCleared } from "./toolbar/clear.js";
|
|
28
30
|
export { asideFilterWords, barFilterWords } from "./toolbar/filter-words.js";
|
|
29
31
|
export type { BarFilterWords } from "./toolbar/filter-words.js";
|
|
@@ -17,6 +17,7 @@ export { boardFieldOf, calendarFieldOf } from "./settings/axes.js";
|
|
|
17
17
|
export { TOOLBAR_NARROW_BELOW, arrangeToolbar, foldState, foldSteps, toolbarForm } from "./toolbar/model.js";
|
|
18
18
|
export { SHOW_COUNTS_KEY, countsToggle, groupShown, showCountsChange, showCountsOf, withCounts, } from "./toolbar/counts.js";
|
|
19
19
|
export { withEditView } from "./toolbar/edit-view.js";
|
|
20
|
+
export { withViewMenu } from "./toolbar/edit-view.js";
|
|
20
21
|
export { settingsCleared } from "./toolbar/clear.js";
|
|
21
22
|
export { asideFilterWords, barFilterWords } from "./toolbar/filter-words.js";
|
|
22
23
|
export { QUICK_SEARCH_AFTER, holdAfterPress, holdStands, quickFieldsShown, quickFirstOpen, quickHeldNames, quickHoldFits, quickPressCloses, quickReminderWords, quickValuesFound, quickValuesShown, } from "./quick/model.js";
|
|
@@ -112,6 +112,7 @@ export function customizeBodyPropsOf(props, { components, icons, messages, conve
|
|
|
112
112
|
pending: view.pending,
|
|
113
113
|
onReset: view.onReset,
|
|
114
114
|
onPublish: view.onPublish,
|
|
115
|
+
...(view.own && { own: true }),
|
|
115
116
|
},
|
|
116
117
|
}),
|
|
117
118
|
...(viewFoot && { foot: viewFoot }),
|
|
@@ -1,12 +1,42 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type { ViewsMenuItem } from "../../../provider/components.js";
|
|
2
|
+
import type { ViewsMenuItem, ViewsViewVerbs } from "../../../provider/components.js";
|
|
3
3
|
import type { ToggleConfig } from "../../model.js";
|
|
4
|
-
import type { SettingsPanelsInput } from "../../settings/input.js";
|
|
5
4
|
import type { QuickFiltersConfig } from "../../quick/model.js";
|
|
5
|
+
import type { SettingsPanelsInput } from "../../settings/input.js";
|
|
6
6
|
import type { CollectionViewState } from "../../view-state.js";
|
|
7
|
-
import {
|
|
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 { ToolbarMore } from "./Toolbar.js";
|
|
11
|
+
/** The toolbar's menus as data (VK-741): each handed its default items, each item keyed, and handing back the items it shows.
|
|
12
|
+
* `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
|
+
* list draws from an axis's verbs. `add`, New's items: `addItems`, or, with `onAdd` alone, one row keyed `new` that runs it;
|
|
14
|
+
* what it hands back New opens as a menu. `more`, the folded parts' ⋯, each row keyed by its part, handed which line's ⋯ it is (`row` or `bar`). */
|
|
15
|
+
export type ToolbarMenus = {
|
|
16
|
+
view?: ViewsViewVerbs["menu"];
|
|
17
|
+
add?: (items: ViewsMenuItem[]) => ViewsMenuItem[];
|
|
18
|
+
more?: ToolbarMore;
|
|
19
|
+
};
|
|
20
|
+
/** A part of the ready toolbar as the app places it (VK-967): its key (list.md, Default keys); the line it stands on: `row`,
|
|
21
|
+
* `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
|
+
* 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
|
+
* 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
|
+
export type ToolbarPartPlace = {
|
|
26
|
+
key: string;
|
|
27
|
+
line: "row" | "bar" | "foot";
|
|
28
|
+
side: "start" | "end";
|
|
29
|
+
words: "both" | "icon";
|
|
30
|
+
node?: ReactNode;
|
|
31
|
+
};
|
|
32
|
+
/** Which form's parts these are. */
|
|
33
|
+
export type ToolbarPartsContext = {
|
|
34
|
+
arrangement: "kit" | "row";
|
|
35
|
+
phone: boolean;
|
|
36
|
+
};
|
|
37
|
+
/** Handed the form's parts in their drawn order, it hands back the parts drawn, in their order, each on its line and side with
|
|
38
|
+
* its words. A part left out isn't drawn; a key the form doesn't hold is skipped, unless it brings its own `node`. */
|
|
39
|
+
export type ToolbarParts = (parts: ToolbarPartPlace[], ctx: ToolbarPartsContext) => ToolbarPartPlace[];
|
|
10
40
|
export type ReadyToolbarProps<Row> = SettingsPanelsInput<Row> & {
|
|
11
41
|
/** The list's views; absent, no views row (the phone's search then fills its row). */
|
|
12
42
|
views?: CollectionViewsInput<string>;
|
|
@@ -75,6 +105,13 @@ export type ReadyToolbarProps<Row> = SettingsPanelsInput<Row> & {
|
|
|
75
105
|
/** Export CSV, in Customize's foot, where handed, with what it takes in words (`exportCount`, "12 deals"). */
|
|
76
106
|
onExport?: () => void;
|
|
77
107
|
exportCount?: string;
|
|
108
|
+
/** The toolbar's menus as data (VK-741): a view's, New's and the folded ⋯. */
|
|
109
|
+
menus?: ToolbarMenus;
|
|
110
|
+
/** Where each part stands (VK-967): handed every form's parts as data, as `menus` hands a menu's items, it hands back the
|
|
111
|
+
* parts drawn, each on its line and side, in its order, with its words; absent, the arrangement's own. `menu.move`,
|
|
112
|
+
* `menu.drop` and `menu.add` (`viewkitjs/views/list`) take them too. Not `parts`, which lists a field's part columns in
|
|
113
|
+
* Customize. */
|
|
114
|
+
toolbarParts?: ToolbarParts;
|
|
78
115
|
className?: string;
|
|
79
116
|
};
|
|
80
|
-
export declare function ReadyToolbar<Row>(
|
|
117
|
+
export declare function ReadyToolbar<Row>({ settings, layer, onChange, onLayerChange, view, sortFilter, bar, ...rest }: ReadyToolbarProps<Row>): ReactNode;
|