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,359 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { settingsChange } from "viewkitjs/fields/query";
|
|
4
|
+
import { useLayoutEffect } from "react";
|
|
5
|
+
import { barItemsOf } from "../filters/filter-tree.js";
|
|
6
|
+
import { useViews } from "../provider/context.js";
|
|
7
|
+
import { useDesktop } from "../provider/desktop.js";
|
|
8
|
+
import { getViewOptionAvailability } from "../panels/availability.js";
|
|
9
|
+
import { settingsPanels } from "../panels/settings/settings-panels.js";
|
|
10
|
+
import { settingsCleared } from "../panels/toolbar/clear.js";
|
|
11
|
+
import { countsToggle, groupShown, showCountsChange, showCountsOf } from "../panels/toolbar/counts.js";
|
|
12
|
+
import { withEditView, withViewMenu } from "../panels/toolbar/edit-view.js";
|
|
13
|
+
import { splitViewAxes } from "../panels/views-row/model.js";
|
|
14
|
+
import { heldStands } from "../panels/react/filter/editor-ctx.js";
|
|
15
|
+
import { Toolbar, ToolbarSeparator } from "../panels/react/toolbar/Toolbar.js";
|
|
16
|
+
import { ToolbarFilter } from "../panels/react/toolbar/ToolbarFilter.js";
|
|
17
|
+
import { ToolbarFilterAdd } from "../panels/react/toolbar/ToolbarFilterAdd.js";
|
|
18
|
+
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
19
|
+
import { ToolbarNew } from "../panels/react/toolbar/ToolbarNew.js";
|
|
20
|
+
import { ToolbarOptions } from "../panels/react/toolbar/ToolbarOptions.js";
|
|
21
|
+
import { ToolbarQuickFilters } from "../panels/react/toolbar/ToolbarQuickFilters.js";
|
|
22
|
+
import { ToolbarSave } from "../panels/react/toolbar/ToolbarSave.js";
|
|
23
|
+
import { ToolbarSearch } from "../panels/react/toolbar/ToolbarSearch.js";
|
|
24
|
+
import { ToolbarSort } from "../panels/react/toolbar/ToolbarSort.js";
|
|
25
|
+
import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
26
|
+
import { ToolbarAdvancedFilters } from "../panels/react/toolbar/ToolbarAdvancedFilters.js";
|
|
27
|
+
import { ToolbarViews } from "../panels/react/toolbar/ToolbarViews.js";
|
|
28
|
+
import { applyParts } from "./parts.js";
|
|
29
|
+
import { useList, useListPanel, useListStore } from "./root.js";
|
|
30
|
+
import { useListViewsAxis } from "./views-axis.js";
|
|
31
|
+
export function ListToolbar(props) {
|
|
32
|
+
const { views: viewsHanded, viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, } = props;
|
|
33
|
+
const storeViews = useListViewsAxis(props.layouts);
|
|
34
|
+
const views = viewsHanded ?? storeViews;
|
|
35
|
+
const store = useListStore();
|
|
36
|
+
const settings = useList((s) => s.view.settings);
|
|
37
|
+
const layer = useList((s) => s.view.layer);
|
|
38
|
+
const onChange = useList((s) => s.setSettings);
|
|
39
|
+
const onLayerChange = useList((s) => s.setLayer);
|
|
40
|
+
const view = useList((s) => s.view.shared) ?? undefined;
|
|
41
|
+
const sortFilter = useList((s) => s.panels.sortFilter);
|
|
42
|
+
const bar = useList((s) => s.panels.bar);
|
|
43
|
+
const customizeOwn = {
|
|
44
|
+
...(viewName !== undefined && { viewName }),
|
|
45
|
+
...(onRenameView && { onRenameView }),
|
|
46
|
+
...(onCopyLink && { onCopyLink }),
|
|
47
|
+
...(onExport && { onExport }),
|
|
48
|
+
...(exportCount !== undefined && { exportCount }),
|
|
49
|
+
};
|
|
50
|
+
const { icons, messages, conventions } = useViews();
|
|
51
|
+
const desktop = useDesktop();
|
|
52
|
+
const phone = props.phone ?? !desktop;
|
|
53
|
+
const options = useListPanel("options");
|
|
54
|
+
const sortState = useListPanel("sort");
|
|
55
|
+
const filterState = useListPanel("filter");
|
|
56
|
+
const sortAdd = useListPanel("sort-add");
|
|
57
|
+
const filterAdd = useListPanel("filter-add");
|
|
58
|
+
const quickOwn = useListPanel("quick");
|
|
59
|
+
const quickState = props.quickFiltersOpen !== undefined && props.onQuickFiltersOpenChange
|
|
60
|
+
? { open: props.quickFiltersOpen, onOpenChange: props.onQuickFiltersOpenChange }
|
|
61
|
+
: quickOwn;
|
|
62
|
+
const held = useList((s) => s.panels.held);
|
|
63
|
+
const setHeld = useList((s) => s.hold);
|
|
64
|
+
const show = showCountsOf(settings);
|
|
65
|
+
const setShow = (next) => {
|
|
66
|
+
const change = showCountsChange(settings, next);
|
|
67
|
+
if (Object.keys(change).length > 0)
|
|
68
|
+
onChange(change);
|
|
69
|
+
};
|
|
70
|
+
const several = props.severalSorts ?? true;
|
|
71
|
+
const { toolbarParts: _placed, ...settingsProps } = props;
|
|
72
|
+
const input = {
|
|
73
|
+
...settingsProps,
|
|
74
|
+
settings,
|
|
75
|
+
layer,
|
|
76
|
+
onChange,
|
|
77
|
+
onLayerChange,
|
|
78
|
+
severalSorts: several,
|
|
79
|
+
filterGroups: props.filterGroups ?? true,
|
|
80
|
+
resolve: props.resolve ?? messages,
|
|
81
|
+
conventions: props.conventions ?? conventions,
|
|
82
|
+
};
|
|
83
|
+
const panels = settingsPanels(input);
|
|
84
|
+
const counts = countsToggle(views, props.toggles, show, setShow, messages);
|
|
85
|
+
const toggles = counts ? [...(props.toggles ?? []), counts] : props.toggles;
|
|
86
|
+
const inputs = {
|
|
87
|
+
filters: panels.filters,
|
|
88
|
+
sort: panels.sort,
|
|
89
|
+
sorts: panels.sorts,
|
|
90
|
+
filterTree: panels.filterTree,
|
|
91
|
+
group: groupShown(panels.group, panels.layout, phone),
|
|
92
|
+
layout: panels.layout,
|
|
93
|
+
toggles,
|
|
94
|
+
};
|
|
95
|
+
const clear = (scope) => () => {
|
|
96
|
+
const change = settingsCleared(input, scope, { phone });
|
|
97
|
+
if (change)
|
|
98
|
+
onChange(change);
|
|
99
|
+
};
|
|
100
|
+
const Edit = icons.options;
|
|
101
|
+
const editable = getViewOptionAvailability(inputs).desktop
|
|
102
|
+
? withEditView(views, {
|
|
103
|
+
key: "edit-view",
|
|
104
|
+
label: messages({ key: "views.panels.edit-view" }),
|
|
105
|
+
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
106
|
+
onSelect: () => options.onOpenChange(true),
|
|
107
|
+
})
|
|
108
|
+
: views;
|
|
109
|
+
const shownViews = withViewMenu(editable, menus?.view);
|
|
110
|
+
const ownNew = !addItems && onAdd ? { key: "new", label: addLabel ?? messages({ key: "views.panels.toolbar-new" }), onSelect: onAdd } : null;
|
|
111
|
+
const shapedNew = menus?.add ? menus.add(addItems ?? (ownNew ? [ownNew] : [])) : addItems;
|
|
112
|
+
const newItems = ownNew && shapedNew?.length === 1 && shapedNew[0] === ownNew ? undefined : shapedNew;
|
|
113
|
+
const search = settings.search ?? "";
|
|
114
|
+
const searchNode = (_jsx(ToolbarSearch, { value: search, placeholder: searchPlaceholder, searching: searching, onChange: (next) => {
|
|
115
|
+
const change = settingsChange(settings, { ...settings, search: next === "" ? undefined : next });
|
|
116
|
+
if (Object.keys(change).length > 0)
|
|
117
|
+
onChange(change);
|
|
118
|
+
} }));
|
|
119
|
+
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
|
+
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 }));
|
|
121
|
+
const quick = props.quickFilters?.fields.length
|
|
122
|
+
? { ...props.quickFilters, showCounts: props.quickFilters.showCounts ?? show }
|
|
123
|
+
: null;
|
|
124
|
+
const quickNode = quick ? (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick })) : null;
|
|
125
|
+
const arrangement = props.arrangement ?? "kit";
|
|
126
|
+
const kit = arrangement === "kit";
|
|
127
|
+
const placed = (parts) => (toolbarParts ? applyParts(parts, toolbarParts, { arrangement, phone }) : parts);
|
|
128
|
+
const { viewAxes, stackedAxes } = splitViewAxes(shownViews, viewsLayout);
|
|
129
|
+
const tree = panels.filterTree;
|
|
130
|
+
const mihais = sortFilter === "right" && !phone;
|
|
131
|
+
const always = bar === "always";
|
|
132
|
+
const filtered = tree ? barItemsOf(tree.tree).length > 0 || !!heldStands(held, tree.tree) : false;
|
|
133
|
+
const barShown = always || !!stackedAxes || filtered;
|
|
134
|
+
const footHere = phone || (mihais && !barShown);
|
|
135
|
+
const barPublished = kit && !phone && (sortFilter === "bar" || barShown);
|
|
136
|
+
const footPublished = kit ? footHere : true;
|
|
137
|
+
useLayoutEffect(() => store.patch({ panels: { barShown: barPublished, footHere: footPublished } }), [store, barPublished, footPublished]);
|
|
138
|
+
if (kit) {
|
|
139
|
+
const clearable = !view && settingsCleared(input, "options", { phone }) !== null;
|
|
140
|
+
const tabs = !phone && viewAxes?.length === 1 ? Math.max(0, viewAxes[0].options.length - 1) : 0;
|
|
141
|
+
const Sort = icons.sort;
|
|
142
|
+
const Filter = icons.filter;
|
|
143
|
+
const QuickGlyph = icons.filterCategory;
|
|
144
|
+
const hasFilter = panels.filters.length > 0;
|
|
145
|
+
const filterMenu = {
|
|
146
|
+
label: messages({ key: "views.panels.filter" }),
|
|
147
|
+
icon: _jsx(Filter, { className: "h-4 w-4" }),
|
|
148
|
+
onSelect: () => filterState.onOpenChange(true),
|
|
149
|
+
};
|
|
150
|
+
const filterParts = tree && !phone
|
|
151
|
+
? [
|
|
152
|
+
{
|
|
153
|
+
key: "filters",
|
|
154
|
+
line: 2,
|
|
155
|
+
...(barItemsOf(tree.tree).length === 0 && !heldStands(held, tree.tree)
|
|
156
|
+
? { shed: true, fold: true, menu: filterMenu }
|
|
157
|
+
: { filters: foldableFilters(tree.tree, held) }),
|
|
158
|
+
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter })),
|
|
159
|
+
},
|
|
160
|
+
]
|
|
161
|
+
: [
|
|
162
|
+
{ key: "filter", line: 2, shed: true, fold: true, menu: filterMenu, node: filterNode },
|
|
163
|
+
...(tree
|
|
164
|
+
? [
|
|
165
|
+
{
|
|
166
|
+
key: "advanced-filters",
|
|
167
|
+
line: 2,
|
|
168
|
+
node: _jsx(ToolbarAdvancedFilters, { filterTree: tree, host: hosts?.filter }),
|
|
169
|
+
},
|
|
170
|
+
]
|
|
171
|
+
: []),
|
|
172
|
+
];
|
|
173
|
+
const kitParts = [
|
|
174
|
+
...(shownViews
|
|
175
|
+
? [{ key: "views", tabs, node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show }) }]
|
|
176
|
+
: []),
|
|
177
|
+
...(shownViews && stackedAxes && !phone
|
|
178
|
+
? [
|
|
179
|
+
{
|
|
180
|
+
key: "views-stacked",
|
|
181
|
+
line: 2,
|
|
182
|
+
node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show, stacked: true }),
|
|
183
|
+
},
|
|
184
|
+
]
|
|
185
|
+
: []),
|
|
186
|
+
{
|
|
187
|
+
key: "options",
|
|
188
|
+
shed: true,
|
|
189
|
+
fold: true,
|
|
190
|
+
menu: {
|
|
191
|
+
label: messages({ key: "views.panels.toolbar-options" }),
|
|
192
|
+
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
193
|
+
onSelect: () => options.onOpenChange(true),
|
|
194
|
+
},
|
|
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: hosts?.options, ...customizeOwn })),
|
|
196
|
+
},
|
|
197
|
+
...(quickNode
|
|
198
|
+
? [
|
|
199
|
+
{
|
|
200
|
+
key: "quick",
|
|
201
|
+
side: "end",
|
|
202
|
+
shed: true,
|
|
203
|
+
fold: true,
|
|
204
|
+
menu: {
|
|
205
|
+
label: quick?.label ?? messages({ key: "views.panels.quick-filters" }),
|
|
206
|
+
icon: _jsx(QuickGlyph, { className: "h-4 w-4" }),
|
|
207
|
+
onSelect: () => quickState.onOpenChange(true),
|
|
208
|
+
},
|
|
209
|
+
node: quickNode,
|
|
210
|
+
},
|
|
211
|
+
]
|
|
212
|
+
: []),
|
|
213
|
+
{ key: "search", side: "end", role: "search", words: "icon", node: searchNode },
|
|
214
|
+
{ key: "new", side: "end", shed: true, node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
215
|
+
{
|
|
216
|
+
key: "sort",
|
|
217
|
+
line: 2,
|
|
218
|
+
shed: true,
|
|
219
|
+
fold: true,
|
|
220
|
+
menu: {
|
|
221
|
+
label: messages({ key: "views.panels.sort" }),
|
|
222
|
+
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
223
|
+
onSelect: () => sortState.onOpenChange(true),
|
|
224
|
+
},
|
|
225
|
+
node: sortNode,
|
|
226
|
+
},
|
|
227
|
+
...(hasFilter ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
228
|
+
...filterParts,
|
|
229
|
+
...(!phone
|
|
230
|
+
? [
|
|
231
|
+
{
|
|
232
|
+
key: "save",
|
|
233
|
+
line: 2,
|
|
234
|
+
side: "end",
|
|
235
|
+
node: _jsx(ToolbarSave, { view: view, onClear: clearable ? clear("options") : undefined }),
|
|
236
|
+
},
|
|
237
|
+
]
|
|
238
|
+
: []),
|
|
239
|
+
];
|
|
240
|
+
if (phone) {
|
|
241
|
+
const quickHere = kitParts.find((part) => part.key === "quick");
|
|
242
|
+
const phoneParts = quickHere
|
|
243
|
+
? [...kitParts.filter((part) => part !== quickHere), { ...quickHere, line: 2, side: "start" }]
|
|
244
|
+
: kitParts;
|
|
245
|
+
return _jsx(Toolbar, { parts: placed(phoneParts), phone: true, fold: true, more: menus?.more, className: className });
|
|
246
|
+
}
|
|
247
|
+
if (sortFilter === "bar")
|
|
248
|
+
return _jsx(Toolbar, { parts: placed(kitParts), phone: phone, fold: true, more: menus?.more, className: className });
|
|
249
|
+
const rowSort = {
|
|
250
|
+
key: "sort",
|
|
251
|
+
side: "end",
|
|
252
|
+
shed: true,
|
|
253
|
+
fold: true,
|
|
254
|
+
menu: {
|
|
255
|
+
label: messages({ key: "views.panels.sort" }),
|
|
256
|
+
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
257
|
+
onSelect: () => sortAdd.onOpenChange(true),
|
|
258
|
+
},
|
|
259
|
+
node: panels.sorts ? (_jsx(ToolbarSortPill, { row: true, sorts: panels.sorts, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort })),
|
|
260
|
+
};
|
|
261
|
+
const rowFilter = tree
|
|
262
|
+
? {
|
|
263
|
+
key: "filter-add",
|
|
264
|
+
side: "end",
|
|
265
|
+
shed: true,
|
|
266
|
+
fold: true,
|
|
267
|
+
menu: { ...filterMenu, onSelect: () => filterAdd.onOpenChange(true) },
|
|
268
|
+
node: (_jsx(ToolbarFilterAdd, { filterTree: tree, onHeldChange: setHeld, open: filterAdd.open, onOpenChange: filterAdd.onOpenChange, host: hosts?.filter })),
|
|
269
|
+
}
|
|
270
|
+
: { key: "filter", side: "end", shed: true, fold: true, menu: filterMenu, node: filterNode };
|
|
271
|
+
const pill = always && panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: false })) : null;
|
|
272
|
+
const stackedPart = kitParts.find((part) => part.key === "views-stacked");
|
|
273
|
+
const barParts = barShown
|
|
274
|
+
? [
|
|
275
|
+
...(stackedPart ? [stackedPart] : []),
|
|
276
|
+
...(pill ? [{ key: "sort-pill", line: 2, node: pill }] : []),
|
|
277
|
+
...(pill && (filtered || always) ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
278
|
+
...(tree
|
|
279
|
+
? [
|
|
280
|
+
{
|
|
281
|
+
key: "filters",
|
|
282
|
+
line: 2,
|
|
283
|
+
filters: foldableFilters(tree.tree, held),
|
|
284
|
+
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter, emptyPlace: always })),
|
|
285
|
+
},
|
|
286
|
+
]
|
|
287
|
+
: []),
|
|
288
|
+
{
|
|
289
|
+
key: "save",
|
|
290
|
+
line: 2,
|
|
291
|
+
side: "end",
|
|
292
|
+
node: _jsx(ToolbarSave, { view: view, onClear: clearable ? clear("options") : undefined }),
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
: [];
|
|
296
|
+
const at = (key) => kitParts.find((part) => part.key === key);
|
|
297
|
+
const quickPart = at("quick");
|
|
298
|
+
const mihaisParts = [
|
|
299
|
+
...kitParts.filter((part) => (part.line ?? 1) === 1 && !["quick", "search", "new", "sort", "filter", "filters"].includes(part.key)),
|
|
300
|
+
rowSort,
|
|
301
|
+
rowFilter,
|
|
302
|
+
...(quickPart && quick
|
|
303
|
+
? [
|
|
304
|
+
{
|
|
305
|
+
...quickPart,
|
|
306
|
+
words: "icon",
|
|
307
|
+
node: (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick, word: null })),
|
|
308
|
+
},
|
|
309
|
+
]
|
|
310
|
+
: []),
|
|
311
|
+
at("search"),
|
|
312
|
+
at("new"),
|
|
313
|
+
...barParts,
|
|
314
|
+
];
|
|
315
|
+
return _jsx(Toolbar, { parts: placed(mihaisParts), phone: phone, fold: true, more: menus?.more, className: className });
|
|
316
|
+
}
|
|
317
|
+
const parts = [
|
|
318
|
+
...(shownViews
|
|
319
|
+
? [
|
|
320
|
+
{ key: "views", node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show }) },
|
|
321
|
+
{ key: "views-stacked", line: 2, node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show, stacked: true }) },
|
|
322
|
+
]
|
|
323
|
+
: []),
|
|
324
|
+
{
|
|
325
|
+
key: "search",
|
|
326
|
+
side: "end",
|
|
327
|
+
role: "search",
|
|
328
|
+
words: "icon",
|
|
329
|
+
node: searchNode,
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: "sort",
|
|
333
|
+
side: "end",
|
|
334
|
+
node: sortNode,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: "filter",
|
|
338
|
+
side: "end",
|
|
339
|
+
node: filterNode,
|
|
340
|
+
},
|
|
341
|
+
...(panels.filterTree
|
|
342
|
+
? [
|
|
343
|
+
{
|
|
344
|
+
key: "advanced-filters",
|
|
345
|
+
side: "end",
|
|
346
|
+
node: _jsx(ToolbarAdvancedFilters, { filterTree: panels.filterTree, host: hosts?.filter }),
|
|
347
|
+
},
|
|
348
|
+
]
|
|
349
|
+
: []),
|
|
350
|
+
...(quickNode ? [{ key: "quick", side: "end", node: quickNode }] : []),
|
|
351
|
+
{
|
|
352
|
+
key: "options",
|
|
353
|
+
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: hosts?.options, ...customizeOwn })),
|
|
355
|
+
},
|
|
356
|
+
{ key: "new", side: "end", node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
357
|
+
];
|
|
358
|
+
return _jsx(Toolbar, { parts: placed(parts), phone: phone, narrow: narrow, className: className });
|
|
359
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ListLayout } from "viewkitjs/fields/query";
|
|
2
|
+
import type { CollectionViewsConfig } from "../panels/views-row/model.js";
|
|
3
|
+
/** The toolbar's views axis from the root's store (not on the door): undefined in memory mode, and while the store
|
|
4
|
+
* hasn't answered. `layouts`: what a new view can take, the toolbar's own `layouts`; none handed, a table. */
|
|
5
|
+
export declare function useListViewsAxis(layouts?: readonly ListLayout[]): CollectionViewsConfig<string> | undefined;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { writeListLink } from "viewkitjs/fields/query";
|
|
4
|
+
import { useViews } from "../provider/context.js";
|
|
5
|
+
import { useList } from "./root.js";
|
|
6
|
+
const LAYOUT_NAMES = {
|
|
7
|
+
table: { key: "views.panels.layout-table" },
|
|
8
|
+
list: { key: "views.panels.layout-list" },
|
|
9
|
+
board: { key: "views.panels.layout-board" },
|
|
10
|
+
calendar: { key: "views.panels.layout-calendar" },
|
|
11
|
+
};
|
|
12
|
+
const isLayout = (id) => id in LAYOUT_NAMES;
|
|
13
|
+
export function useListViewsAxis(layouts) {
|
|
14
|
+
const views = useList((s) => s.views);
|
|
15
|
+
const changes = useList((s) => s.view.shared?.changes ?? 0);
|
|
16
|
+
const settings = useList((s) => s.view.settings);
|
|
17
|
+
const openPanel = useList((s) => s.openPanel);
|
|
18
|
+
const { messages, ports } = useViews();
|
|
19
|
+
return useMemo(() => {
|
|
20
|
+
if (!views || (!views.ready && views.list.length === 0))
|
|
21
|
+
return undefined;
|
|
22
|
+
const byId = (id) => views.list.find((v) => v.id === id);
|
|
23
|
+
const onChange = (change) => {
|
|
24
|
+
switch (change.kind) {
|
|
25
|
+
case "rename":
|
|
26
|
+
return views.rename(change.id, change.name);
|
|
27
|
+
case "create":
|
|
28
|
+
return views.saveAs(change.name, {
|
|
29
|
+
...(change.from !== undefined && { from: change.from }),
|
|
30
|
+
...(isLayout(change.layout) && { layout: change.layout }),
|
|
31
|
+
});
|
|
32
|
+
case "duplicate": {
|
|
33
|
+
const view = byId(change.id);
|
|
34
|
+
if (view)
|
|
35
|
+
views.duplicate(view.id, messages({ key: "views.panels.view-copy-name", values: { name: view.name } }));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
case "delete":
|
|
39
|
+
return views.remove(change.id);
|
|
40
|
+
case "restore":
|
|
41
|
+
return views.restore(change.view.id, change.open);
|
|
42
|
+
case "save":
|
|
43
|
+
return views.save();
|
|
44
|
+
case "reset":
|
|
45
|
+
return views.reset();
|
|
46
|
+
case "edit":
|
|
47
|
+
return openPanel("options");
|
|
48
|
+
case "link": {
|
|
49
|
+
const view = byId(change.id);
|
|
50
|
+
if (!view || typeof location === "undefined")
|
|
51
|
+
return;
|
|
52
|
+
const shown = view.id === views.open ? { ...view.settings, ...(settings.search && { search: settings.search }) } : view.settings;
|
|
53
|
+
const { params } = writeListLink(location.search, { view: view.id, base: view.settings, settings: shown });
|
|
54
|
+
const query = params.toString();
|
|
55
|
+
void ports.clipboard.writeText(`${location.origin}${location.pathname}${query ? `?${query}` : ""}`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
case "favorite":
|
|
59
|
+
case "private":
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
value: views.open ?? "",
|
|
65
|
+
options: views.list.map((v) => ({
|
|
66
|
+
value: v.id,
|
|
67
|
+
label: v.name,
|
|
68
|
+
private: v.scope === "personal",
|
|
69
|
+
layout: v.settings.layout,
|
|
70
|
+
...(!views.canSave(v) && { readOnly: true }),
|
|
71
|
+
...(v.id === views.open && changes > 0 && { changed: true }),
|
|
72
|
+
})),
|
|
73
|
+
onChange: views.openView,
|
|
74
|
+
onCreate: () => { },
|
|
75
|
+
onReorder: (ids) => {
|
|
76
|
+
const first = byId(ids[0] ?? "");
|
|
77
|
+
if (first)
|
|
78
|
+
views.reorder(first.scope, ids);
|
|
79
|
+
},
|
|
80
|
+
canDrag: (id) => {
|
|
81
|
+
const view = byId(id);
|
|
82
|
+
return !!view && views.canSave(view);
|
|
83
|
+
},
|
|
84
|
+
verbs: {
|
|
85
|
+
layouts: (layouts?.length ? layouts : ["table"]).map((id) => ({
|
|
86
|
+
id,
|
|
87
|
+
name: messages(LAYOUT_NAMES[id]),
|
|
88
|
+
icon: "layout",
|
|
89
|
+
line: "",
|
|
90
|
+
})),
|
|
91
|
+
records: views.records,
|
|
92
|
+
onChange,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
}, [views, changes, settings.search, openPanel, messages, ports, layouts]);
|
|
96
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ListPersonalLayer, ListSettingsChange, SavedListSettings, SavedView } from "viewkitjs/fields/query";
|
|
2
|
+
/** A person's unsaved change over one view, and the view's `updatedAt` when it started. */
|
|
3
|
+
export type ViewDraft = {
|
|
4
|
+
change: ListSettingsChange;
|
|
5
|
+
base: string;
|
|
6
|
+
};
|
|
7
|
+
/** A view the app declares in its code: listed first, shared with everyone, read-only. */
|
|
8
|
+
export type ViewSeed = {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
settings: SavedListSettings;
|
|
12
|
+
};
|
|
13
|
+
/** What `save` takes: a view without its `updatedAt` (the store stamps it) and without `readOnly`; no `id` saves a
|
|
14
|
+
* new view, and the store makes its id. With an `id` the store no longer holds, it saves that view again. */
|
|
15
|
+
export type SavedViewInput = Omit<SavedView, "id" | "updatedAt" | "readOnly"> & {
|
|
16
|
+
id?: string;
|
|
17
|
+
};
|
|
18
|
+
/** Where a list's saved views, a person's drafts and their layer are kept. */
|
|
19
|
+
export interface ViewsStore {
|
|
20
|
+
/** The list's views: the shared ones, then the person's own, each in its `position`'s order. */
|
|
21
|
+
list(listId: string): readonly SavedView[] | Promise<readonly SavedView[]>;
|
|
22
|
+
/** Saves a view (save, save as, rename, a scope moved) and hands back the view as kept. */
|
|
23
|
+
save(listId: string, view: SavedViewInput): SavedView | Promise<SavedView>;
|
|
24
|
+
remove(listId: string, id: string): void | Promise<void>;
|
|
25
|
+
/** The views of one scope in a new order: every view of that scope, once. */
|
|
26
|
+
reorder(listId: string, scope: SavedView["scope"], ids: readonly string[]): void | Promise<void>;
|
|
27
|
+
/** Tells when the list's views change from elsewhere (another tab, another person); the answer stops it. */
|
|
28
|
+
subscribe?(listId: string, onChange: () => void): () => void;
|
|
29
|
+
draft: {
|
|
30
|
+
get(listId: string, viewId: string): ViewDraft | null | Promise<ViewDraft | null>;
|
|
31
|
+
set(listId: string, viewId: string, draft: ViewDraft | null): void | Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
layer: {
|
|
34
|
+
get(listId: string): ListPersonalLayer | Promise<ListPersonalLayer>;
|
|
35
|
+
set(listId: string, layer: ListPersonalLayer): void | Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
/** What this person may do: `share`, write shared views. Absent, they may not. */
|
|
38
|
+
can?: {
|
|
39
|
+
share: boolean;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type ListLayout, type ListLinkReading, type ListSettings, type SavedView } from "viewkitjs/fields/query";
|
|
2
|
+
import type { ListSync } from "./store.js";
|
|
3
|
+
import type { ViewsStore } from "./views-store.js";
|
|
4
|
+
/** A list's saved views as the root holds them (`ListState.views`): null in memory mode. */
|
|
5
|
+
export type ListViewsState = {
|
|
6
|
+
/** The views the row shows: shared first, then the person's own, each by position; a view held for Undo left out. */
|
|
7
|
+
list: readonly SavedView[];
|
|
8
|
+
/** The open view's id; null while the list has none. */
|
|
9
|
+
open: string | null;
|
|
10
|
+
/** The store has answered. */
|
|
11
|
+
ready: boolean;
|
|
12
|
+
/** This person may write shared views (`store.can.share`). */
|
|
13
|
+
share: boolean;
|
|
14
|
+
/** A write is under way. */
|
|
15
|
+
pending: boolean;
|
|
16
|
+
/** What the list holds, in the delete question's line (`ListViewsOptions.records`, default "records"). */
|
|
17
|
+
records: string;
|
|
18
|
+
openView: (id: string) => void;
|
|
19
|
+
/** The open view's edits saved over it, where this person may (`canSave`). */
|
|
20
|
+
save: () => void;
|
|
21
|
+
/** A new view of the person's own, named `name`: the edited settings of `from` (its edits let go), or with no `from`
|
|
22
|
+
* the defaults in `layout`. Opens it. */
|
|
23
|
+
saveAs: (name: string, options?: {
|
|
24
|
+
from?: string;
|
|
25
|
+
layout?: ListLayout;
|
|
26
|
+
}) => void;
|
|
27
|
+
rename: (id: string, name: string) => void;
|
|
28
|
+
/** A copy of what `id` saved, named `name`, right after it in its scope's order; opens it. */
|
|
29
|
+
duplicate: (id: string, name: string) => void;
|
|
30
|
+
/** Held: out of the row at once, `remove` once the hold ends (`holdMs`) or the page closes. */
|
|
31
|
+
remove: (id: string) => void;
|
|
32
|
+
/** Undo of `remove`: back in its place, opened again where `open`. */
|
|
33
|
+
restore: (id: string, open: boolean) => void;
|
|
34
|
+
reorder: (scope: SavedView["scope"], ids: readonly string[]) => void;
|
|
35
|
+
/** The open view's draft let go. */
|
|
36
|
+
reset: () => void;
|
|
37
|
+
/** Whether this person may change `view` (rename, delete, save over): not read-only, and shared only with `share`. */
|
|
38
|
+
canSave: (view: SavedView) => boolean;
|
|
39
|
+
};
|
|
40
|
+
export type ListViewsController = {
|
|
41
|
+
/** The `ListSync` the list store takes: the edited settings, the layer, their handlers and the open view's state,
|
|
42
|
+
* with the app's `sortFilter` and `bar`. */
|
|
43
|
+
sync: (extra: Pick<ListSync, "sortFilter" | "bar">) => ListSync;
|
|
44
|
+
/** Reads the store and starts following it (subscribe, `pagehide`); the cleanup stops both, the held deletes' timers
|
|
45
|
+
* too, and flushes them. Called from the root's layout effect. */
|
|
46
|
+
start: () => () => void;
|
|
47
|
+
/** The slice as it stands. */
|
|
48
|
+
state: () => ListViewsState;
|
|
49
|
+
};
|
|
50
|
+
/** The Toast's own time where nothing declares it: `--vk-toast-duration` as it reaches the toast's viewport (which its
|
|
51
|
+
* stylesheet hands the Toast), else the page's root, else 4000 ms. Read here, not imported: nothing outside the controls
|
|
52
|
+
* part imports from it. */
|
|
53
|
+
export declare function toastTime(): number;
|
|
54
|
+
export declare function createListViews(o: {
|
|
55
|
+
id: string;
|
|
56
|
+
store: ViewsStore;
|
|
57
|
+
defaults: ListSettings;
|
|
58
|
+
link?: ListLinkReading;
|
|
59
|
+
/** The delete question's noun; default "records". */
|
|
60
|
+
records?: string;
|
|
61
|
+
/** Told whenever the settings, the layer or the slice change, after the controller has synced them into the list store. */
|
|
62
|
+
onChange: () => void;
|
|
63
|
+
/** Said when a store write fails (the root hands `ports.toast.error`). */
|
|
64
|
+
onError: (message: string) => void;
|
|
65
|
+
/** How long a deleted view is held; default the Toast's own time (`toastTime()`). */
|
|
66
|
+
holdMs?: number;
|
|
67
|
+
}): ListViewsController;
|