viewkitjs 0.38.0 → 0.39.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 +69 -0
- package/MIGRATION.md +7 -0
- package/fields/dist/query/figure-kinds.d.ts +2 -2
- package/fields/dist/query/figure-kinds.js +3 -0
- package/fields/dist/query/figures.d.ts +5 -3
- package/fields/dist/query/figures.js +13 -0
- package/fields/docs/reference/query.md +3 -3
- package/package.json +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/views/dist/atoms/HeaderChrome.d.ts +7 -0
- package/views/dist/atoms/HeaderChrome.js +15 -0
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +2 -2
- package/views/dist/atoms/defaults.js +4 -0
- package/views/dist/atoms/types.d.ts +39 -2
- package/views/dist/contract.d.ts +19 -8
- package/views/dist/contract.js +37 -6
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -3
- 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 +33 -0
- package/views/dist/controls/filter-editor/block.d.ts +3 -1
- package/views/dist/controls/filter-editor/block.js +4 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +13 -2
- package/views/dist/controls/filter-editor/filter-editor.js +45 -15
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +5 -4
- package/views/dist/controls/filter-editor/map-rules.d.ts +2 -1
- package/views/dist/controls/filter-editor/map-rules.js +3 -3
- package/views/dist/controls/internal/menu-items.d.ts +2 -0
- package/views/dist/controls/internal/menu-items.js +1 -1
- package/views/dist/controls/internal/part-slot.d.ts +1 -1
- package/views/dist/controls/internal/part-slot.js +1 -1
- package/views/dist/controls/internal/row-actions.d.ts +33 -0
- package/views/dist/controls/internal/row-actions.js +28 -0
- package/views/dist/controls/menu/map-menu.js +1 -1
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/sheet/map-sheet.js +9 -6
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +41 -13
- package/views/dist/controls/text-editor.css +20 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +38 -16
- package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/views/dist/field-row/editors/RowDateEditor.js +3 -1
- package/views/dist/field-row/editors/RowNameEditor.js +3 -1
- package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
- package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
- package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
- package/views/dist/field-row/editors/RowTextEditor.js +25 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
- package/views/dist/field-row/editors/row-place.d.ts +33 -0
- package/views/dist/field-row/editors/row-place.js +141 -0
- package/views/dist/field-row/field-row-button.d.ts +9 -6
- package/views/dist/field-row/field-row-button.js +3 -3
- package/views/dist/field-row/row-target.d.ts +4 -1
- package/views/dist/field-row/row-target.js +1 -1
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
- package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
- package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
- package/views/dist/grid/chrome/GridFooter.js +11 -9
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -5
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
- package/views/dist/grid/grid.css +7 -3
- package/views/dist/internal/over-cell.d.ts +8 -0
- package/views/dist/internal/over-cell.js +5 -0
- package/views/dist/list/bar-keys.d.ts +5 -0
- package/views/dist/list/bar-keys.js +2 -0
- package/views/dist/list/bar-parts.d.ts +27 -0
- package/views/dist/list/bar-parts.js +38 -0
- package/views/dist/list/buttons/clear-save.d.ts +7 -0
- package/views/dist/list/buttons/clear-save.js +15 -0
- package/views/dist/list/buttons/customize.d.ts +28 -0
- package/views/dist/list/buttons/customize.js +31 -0
- package/views/dist/list/buttons/filter.d.ts +32 -0
- package/views/dist/list/buttons/filter.js +60 -0
- package/views/dist/list/buttons/new.d.ts +18 -0
- package/views/dist/list/buttons/new.js +9 -0
- package/views/dist/list/buttons/quick.d.ts +15 -0
- package/views/dist/list/buttons/quick.js +24 -0
- package/views/dist/list/buttons/search.d.ts +18 -0
- package/views/dist/list/buttons/search.js +17 -0
- package/views/dist/list/buttons/shared.d.ts +91 -0
- package/views/dist/list/buttons/shared.js +131 -0
- package/views/dist/list/buttons/sort-filter.d.ts +6 -0
- package/views/dist/list/buttons/sort-filter.js +16 -0
- package/views/dist/list/buttons/sort.d.ts +17 -0
- package/views/dist/list/buttons/sort.js +34 -0
- package/views/dist/list/buttons/views.d.ts +21 -0
- package/views/dist/list/buttons/views.js +36 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/line.d.ts +55 -0
- package/views/dist/list/line.js +221 -0
- package/views/dist/list/pane-box.d.ts +6 -0
- package/views/dist/list/pane-box.js +15 -0
- package/views/dist/list/panels/customize.d.ts +8 -0
- package/views/dist/list/panels/customize.js +23 -0
- package/views/dist/list/panels/filter-bar.d.ts +12 -0
- package/views/dist/list/panels/filter-bar.js +67 -0
- package/views/dist/list/panels/filter.d.ts +8 -0
- package/views/dist/list/panels/filter.js +23 -0
- package/views/dist/list/panels/quick.d.ts +7 -0
- package/views/dist/list/panels/quick.js +16 -0
- package/views/dist/list/panels/shared.d.ts +25 -0
- package/views/dist/list/panels/shared.js +33 -0
- package/views/dist/list/panels/sort.d.ts +8 -0
- package/views/dist/list/panels/sort.js +19 -0
- package/views/dist/list/panels/views.d.ts +13 -0
- package/views/dist/list/panels/views.js +27 -0
- package/views/dist/list/ready.d.ts +35 -0
- package/views/dist/list/ready.js +7 -0
- package/views/dist/list/root-base.d.ts +17 -0
- package/views/dist/list/root-base.js +9 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +19 -0
- package/views/dist/list/store.js +40 -1
- package/views/dist/list/toolbar-model.d.ts +95 -0
- package/views/dist/list/toolbar-model.js +177 -0
- package/views/dist/list/toolbar.js +140 -328
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-body.js +2 -2
- package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
- package/views/dist/panels/react/sort/SortEditor.js +4 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +57 -0
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
- package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
- package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
- package/views/dist/panels/settings/filter-groups.js +7 -0
- package/views/dist/provider/components.d.ts +36 -2
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +104 -1
- package/views/dist/styles.unlayered.css +104 -1
- package/views/docs/contract.md +20 -12
- package/views/docs/controls/field.md +1 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/reference/controls.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +168 -6
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/react.md +13 -10
- package/views/docs/reference/views.md +8 -6
- package/views/skills/views/SKILL.md +2 -1
|
@@ -1,57 +1,52 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { useLayoutEffect } from "react";
|
|
5
|
-
import { barItemsOf } from "../filters/filter-tree.js";
|
|
3
|
+
import { useLayoutEffect, useMemo } from "react";
|
|
6
4
|
import { useViews } from "../provider/context.js";
|
|
7
5
|
import { useDesktop } from "../provider/desktop.js";
|
|
8
6
|
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 { pageResets } from "../panels/toolbar/page-resets.js";
|
|
12
|
-
import { countsToggle, groupShown, showCountsChange, showCountsOf } from "../panels/toolbar/counts.js";
|
|
13
7
|
import { withEditView, withViewMenu } from "../panels/toolbar/edit-view.js";
|
|
8
|
+
import { arrangeToolbar, toolbarForm } from "../panels/toolbar/model.js";
|
|
14
9
|
import { splitViewAxes } from "../panels/views-row/model.js";
|
|
15
10
|
import { heldStands } from "../panels/react/filter/editor-ctx.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { ToolbarFilterAdd } from "../panels/react/toolbar/ToolbarFilterAdd.js";
|
|
19
|
-
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
20
|
-
import { ToolbarNew } from "../panels/react/toolbar/ToolbarNew.js";
|
|
21
|
-
import { ToolbarOptions } from "../panels/react/toolbar/ToolbarOptions.js";
|
|
22
|
-
import { EditorMenus } from "../panels/react/toolbar/editor-menus.js";
|
|
11
|
+
import { FoldFrame, Toolbar } from "../panels/react/toolbar/Toolbar.js";
|
|
12
|
+
import { foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
23
13
|
import { PaneBox, PaneHost } from "../panels/react/toolbar/pane-host.js";
|
|
24
|
-
import { ToolbarQuickFilters } from "../panels/react/toolbar/ToolbarQuickFilters.js";
|
|
25
|
-
import { ToolbarSave } from "../panels/react/toolbar/ToolbarSave.js";
|
|
26
|
-
import { ToolbarSearch } from "../panels/react/toolbar/ToolbarSearch.js";
|
|
27
|
-
import { ToolbarSort } from "../panels/react/toolbar/ToolbarSort.js";
|
|
28
|
-
import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
29
|
-
import { ToolbarAdvancedFilters } from "../panels/react/toolbar/ToolbarAdvancedFilters.js";
|
|
30
|
-
import { ToolbarViews } from "../panels/react/toolbar/ToolbarViews.js";
|
|
31
14
|
import { MoreViews } from "../panels/react/views-row/more-views.js";
|
|
32
15
|
import { ScreenForms } from "../internal/screen-forms.js";
|
|
16
|
+
import { FILTER_BAR_KEY, filterBarParts } from "./bar-parts.js";
|
|
17
|
+
import { ListClearSave, SAVE_ITEM } from "./buttons/clear-save.js";
|
|
18
|
+
import { CUSTOMIZE_ITEM, ListCustomize } from "./buttons/customize.js";
|
|
19
|
+
import { FILTER_ITEM, ListAdvancedFilters, ListFilter, barFiltersItem, filterItemKey } from "./buttons/filter.js";
|
|
20
|
+
import { ListNew, NEW_ITEM } from "./buttons/new.js";
|
|
21
|
+
import { ListQuickFilters, QUICK_ITEM } from "./buttons/quick.js";
|
|
22
|
+
import { ListSearch, SEARCH_ITEM } from "./buttons/search.js";
|
|
23
|
+
import { PartKeys } from "./buttons/shared.js";
|
|
24
|
+
import { ListSort, SORT_ITEM } from "./buttons/sort.js";
|
|
25
|
+
import { ListViews, viewsTabs } from "./buttons/views.js";
|
|
26
|
+
import { ListEditorMenus } from "./editor-menus.js";
|
|
27
|
+
import { LineForm, LineItem, LinePlace, LineSeed, LineSep, ListGap, ListLine, SEED_GAP } from "./line.js";
|
|
28
|
+
import { ListFilterBar } from "./panels/filter-bar.js";
|
|
33
29
|
import { applyParts } from "./parts.js";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
30
|
+
import { ReadyPartsContext, ReadyPiece } from "./ready.js";
|
|
31
|
+
import { ToolbarModelProvided, useList, useListPanel, useListStore } from "./root-base.js";
|
|
32
|
+
import { useOwnToolbarModel } from "./toolbar-model.js";
|
|
37
33
|
export function ListToolbar(props) {
|
|
38
34
|
const { sortEditor: sort, filterEditor: filter, groupEditor: group } = props.menus ?? {};
|
|
39
|
-
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(
|
|
35
|
+
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(ListEditorMenus, { sortEditor: sort, filterEditor: filter, groupEditor: group, children: _jsx(MoreViews.Provider, { value: props.moreViews ?? null, children: _jsx(ScreenForms, { off: props.phone !== undefined, children: _jsx(ToolbarOfList, { ...props }) }) }) }) }));
|
|
40
36
|
}
|
|
41
37
|
function ToolbarOfList(props) {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
38
|
+
const desktop = useDesktop();
|
|
39
|
+
const phone = props.phone ?? !desktop;
|
|
40
|
+
const model = useOwnToolbarModel({ ...props, phone });
|
|
41
|
+
const provided = useMemo(() => ({ model }), [model]);
|
|
42
|
+
return (_jsx(ToolbarModelProvided.Provider, { value: provided, children: _jsx(ToolbarDrawn, { ...props, model: model, phone: phone }) }));
|
|
43
|
+
}
|
|
44
|
+
function ToolbarDrawn(props) {
|
|
45
|
+
const { viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, overflow, moreViews, } = props;
|
|
47
46
|
const store = useListStore();
|
|
48
|
-
const settings = useList((s) => s.view.settings);
|
|
49
|
-
const layer = useList((s) => s.view.layer);
|
|
50
|
-
const onChange = useList((s) => s.setSettings);
|
|
51
|
-
const onLayerChange = useList((s) => s.setLayer);
|
|
52
|
-
const shared = useList((s) => s.view.shared) ?? undefined;
|
|
53
47
|
const sortFilter = useList((s) => s.panels.sortFilter);
|
|
54
48
|
const bar = useList((s) => s.panels.bar);
|
|
49
|
+
const barPlaced = useList((s) => (s.panels.placed[FILTER_BAR_KEY] ?? 0) > 0);
|
|
55
50
|
const customizeOwn = {
|
|
56
51
|
...(viewName !== undefined && { viewName }),
|
|
57
52
|
...(onRenameView && { onRenameView }),
|
|
@@ -59,84 +54,15 @@ function ToolbarOfList(props) {
|
|
|
59
54
|
...(onExport && { onExport }),
|
|
60
55
|
...(exportCount !== undefined && { exportCount }),
|
|
61
56
|
};
|
|
62
|
-
const { icons, messages,
|
|
63
|
-
const
|
|
64
|
-
const
|
|
57
|
+
const { icons, messages, components } = useViews();
|
|
58
|
+
const { phone } = props;
|
|
59
|
+
const { views, panels, inputs, differs, held, setHeld, savedFilter, quick } = props.model;
|
|
65
60
|
const optionsHost = hosts?.options ??
|
|
66
61
|
(props.customizeIn === "pane" && props.paneBox !== undefined && !phone && components.Pane ? PaneHost : undefined);
|
|
67
62
|
const options = useListPanel("options");
|
|
68
|
-
const sortState = useListPanel("sort");
|
|
69
|
-
const filterState = useListPanel("filter");
|
|
70
|
-
const sortAdd = useListPanel("sort-add");
|
|
71
|
-
const filterAdd = useListPanel("filter-add");
|
|
72
|
-
const quickOwn = useListPanel("quick");
|
|
73
63
|
const quickState = props.quickFiltersOpen !== undefined && props.onQuickFiltersOpenChange
|
|
74
64
|
? { open: props.quickFiltersOpen, onOpenChange: props.onQuickFiltersOpenChange }
|
|
75
|
-
:
|
|
76
|
-
const held = useList((s) => s.panels.held);
|
|
77
|
-
const setHeld = useList((s) => s.hold);
|
|
78
|
-
const show = showCountsOf(settings);
|
|
79
|
-
const setShow = (next) => {
|
|
80
|
-
const change = showCountsChange(settings, next);
|
|
81
|
-
if (Object.keys(change).length > 0)
|
|
82
|
-
onChange(change);
|
|
83
|
-
};
|
|
84
|
-
const several = props.severalSorts ?? true;
|
|
85
|
-
const { toolbarParts: _placed, ...settingsProps } = props;
|
|
86
|
-
const input = {
|
|
87
|
-
...settingsProps,
|
|
88
|
-
columns: props.columns ?? rootColumns ?? [],
|
|
89
|
-
groupHeads: props.groupHeads ?? answer?.groupHeads,
|
|
90
|
-
filterData: props.filterData ?? answer?.filterValues,
|
|
91
|
-
settings,
|
|
92
|
-
layer,
|
|
93
|
-
onChange,
|
|
94
|
-
onLayerChange,
|
|
95
|
-
severalSorts: several,
|
|
96
|
-
filterGroups: props.filterGroups ?? true,
|
|
97
|
-
resolve: props.resolve ?? messages,
|
|
98
|
-
conventions: props.conventions ?? conventions,
|
|
99
|
-
};
|
|
100
|
-
const panels = settingsPanels(input);
|
|
101
|
-
const counts = countsToggle(views, props.toggles, show, setShow, messages);
|
|
102
|
-
const toggles = counts ? [...(props.toggles ?? []), counts] : props.toggles;
|
|
103
|
-
const inputs = {
|
|
104
|
-
filters: panels.filters,
|
|
105
|
-
sort: panels.sort,
|
|
106
|
-
sorts: panels.sorts,
|
|
107
|
-
filterTree: panels.filterTree,
|
|
108
|
-
group: groupShown(panels.group, panels.layout, phone),
|
|
109
|
-
layout: panels.layout,
|
|
110
|
-
toggles,
|
|
111
|
-
};
|
|
112
|
-
const clear = (scope) => () => {
|
|
113
|
-
const change = settingsCleared(input, scope, { phone });
|
|
114
|
-
if (change)
|
|
115
|
-
onChange(change);
|
|
116
|
-
};
|
|
117
|
-
const layered = layerHolds(layer, { phone });
|
|
118
|
-
const resetAll = () => {
|
|
119
|
-
if (shared) {
|
|
120
|
-
if (shared.changes > 0)
|
|
121
|
-
shared.onReset();
|
|
122
|
-
}
|
|
123
|
-
else
|
|
124
|
-
clear("options")();
|
|
125
|
-
if (layered)
|
|
126
|
-
onLayerChange(EMPTY_LAYER);
|
|
127
|
-
};
|
|
128
|
-
const view = shared && { ...shared, onReset: resetAll };
|
|
129
|
-
const resets = shared && !shared.saved ? undefined : Object.fromEntries(Object.entries(pageResets(input, shared ? shared.saved ?? null : null, { cleared: !shared, phone })).map(([page, back]) => [
|
|
130
|
-
page,
|
|
131
|
-
() => {
|
|
132
|
-
if (back.change)
|
|
133
|
-
onChange(back.change);
|
|
134
|
-
if (back.layer)
|
|
135
|
-
onLayerChange(back.layer);
|
|
136
|
-
},
|
|
137
|
-
]));
|
|
138
|
-
const differs = resets && { sort: !!resets.sort, filter: !!resets.filter };
|
|
139
|
-
const savedFilter = shared?.saved?.filter;
|
|
65
|
+
: undefined;
|
|
140
66
|
const Edit = icons.options;
|
|
141
67
|
const editable = getViewOptionAvailability(inputs).desktop
|
|
142
68
|
? withEditView(views, {
|
|
@@ -150,259 +76,145 @@ function ToolbarOfList(props) {
|
|
|
150
76
|
const ownNew = !addItems && onAdd ? { key: "new", label: addLabel ?? messages({ key: "views.panels.toolbar-new" }), onSelect: onAdd } : null;
|
|
151
77
|
const shapedNew = menus?.add ? menus.add(addItems ?? (ownNew ? [ownNew] : [])) : addItems;
|
|
152
78
|
const newItems = ownNew && shapedNew?.length === 1 && shapedNew[0] === ownNew ? undefined : shapedNew;
|
|
153
|
-
const search = settings.search ?? "";
|
|
154
|
-
const searchNode = (_jsx(ToolbarSearch, { value: search, placeholder: searchPlaceholder, searching: searching, onChange: (next) => {
|
|
155
|
-
const change = settingsChange(settings, { ...settings, search: next === "" ? undefined : next });
|
|
156
|
-
if (Object.keys(change).length > 0)
|
|
157
|
-
onChange(change);
|
|
158
|
-
} }));
|
|
159
|
-
const sortNode = several && panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: props.addAfter, ...(differs && { changed: differs.sort }) })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort }));
|
|
160
|
-
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 }));
|
|
161
|
-
const holdCounts = answer?.holdCounts;
|
|
162
|
-
const quick = props.quickFilters?.fields.length
|
|
163
|
-
? {
|
|
164
|
-
...props.quickFilters,
|
|
165
|
-
showCounts: props.quickFilters.showCounts ?? show,
|
|
166
|
-
...(holdCounts && {
|
|
167
|
-
fields: props.quickFilters.fields.map((field) => field.counts === undefined && holdCounts[field.key] ? { ...field, counts: holdCounts[field.key] } : field),
|
|
168
|
-
}),
|
|
169
|
-
}
|
|
170
|
-
: null;
|
|
171
|
-
const quickNode = quick ? (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick })) : null;
|
|
172
79
|
const arrangement = props.arrangement ?? "kit";
|
|
173
80
|
const kit = arrangement === "kit";
|
|
174
81
|
const placed = (parts) => (toolbarParts ? applyParts(parts, toolbarParts, { arrangement, phone }) : parts);
|
|
175
|
-
const {
|
|
82
|
+
const { stackedAxes } = splitViewAxes(shownViews, viewsLayout);
|
|
176
83
|
const tree = panels.filterTree;
|
|
177
84
|
const mihais = sortFilter === "right" && !phone;
|
|
178
85
|
const always = bar === "always";
|
|
179
86
|
const filtered = tree ? foldableFilters(tree.tree, null, savedFilter) > 0 || !!heldStands(held, tree.tree) : false;
|
|
180
|
-
const barShown =
|
|
87
|
+
const barShown = barPlaced
|
|
88
|
+
? !!stackedAxes || (!!differs && (differs.sort || differs.filter))
|
|
89
|
+
: always || !!stackedAxes || filtered || (!!differs && (differs.sort || differs.filter));
|
|
181
90
|
const footHere = phone || mihais;
|
|
182
91
|
const barPublished = kit && !phone && (sortFilter === "bar" || barShown);
|
|
183
92
|
const footPublished = kit ? footHere : true;
|
|
184
93
|
useLayoutEffect(() => store.patch({ panels: { barShown: barPublished, footHere: footPublished } }), [store, barPublished, footPublished]);
|
|
94
|
+
const barHere = kit && !phone;
|
|
95
|
+
useLayoutEffect(() => (barHere ? store.get().place("bar") : undefined), [store, barHere]);
|
|
96
|
+
const piece = (name, node) => _jsx(ReadyPiece.Provider, { value: name, children: node });
|
|
97
|
+
const viewsNode = _jsx(ListViews, { views: editable, menu: menus?.view, moreViews: moreViews });
|
|
98
|
+
const stackedNode = piece("stacked", viewsNode);
|
|
99
|
+
const customizeNode = _jsx(ListCustomize, { menu: menus?.customize, fieldEditor: fieldEditor, ...customizeOwn });
|
|
100
|
+
const searchNode = _jsx(ListSearch, { placeholder: searchPlaceholder, searching: searching });
|
|
101
|
+
const newNode = _jsx(ListNew, { onAdd: onAdd, items: newItems, label: addLabel });
|
|
102
|
+
const asked = (form) => ({
|
|
103
|
+
phone,
|
|
104
|
+
hosts: { options: optionsHost, sort: hosts?.sort, filter: hosts?.filter, quick: hosts?.quick },
|
|
105
|
+
addAfter: props.addAfter,
|
|
106
|
+
...(quickState && { quickState }),
|
|
107
|
+
viewsLayout,
|
|
108
|
+
barAlways: always,
|
|
109
|
+
...form,
|
|
110
|
+
});
|
|
111
|
+
const keys = (sortKey, filterKey) => ({
|
|
112
|
+
sort: sortKey,
|
|
113
|
+
filter: filterKey,
|
|
114
|
+
customize: "options",
|
|
115
|
+
quick: "quick",
|
|
116
|
+
barSort: "sort",
|
|
117
|
+
barFilters: "filter",
|
|
118
|
+
});
|
|
119
|
+
const asParts = (ready, partKeys, drawn) => (_jsx(PartKeys.Provider, { value: partKeys, children: _jsx(ReadyPartsContext.Provider, { value: ready, children: drawn }) }));
|
|
185
120
|
if (kit) {
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const saveParts = { node: saveOf(), apart: { clear: saveOf("clear"), save: saveOf("save") } };
|
|
189
|
-
const tabs = !phone && viewAxes?.length === 1 ? Math.max(0, viewAxes[0].options.length - 1) : 0;
|
|
190
|
-
const Sort = icons.sort;
|
|
191
|
-
const Filter = icons.filter;
|
|
192
|
-
const QuickGlyph = icons.filterCategory;
|
|
121
|
+
const saveParts = { node: _jsx(ListClearSave, {}), apart: { clear: piece("clear", _jsx(ListClearSave, {})), save: piece("save", _jsx(ListClearSave, {})) } };
|
|
122
|
+
const tabs = viewsTabs(shownViews ?? [], viewsLayout, phone);
|
|
193
123
|
const hasFilter = panels.filters.length > 0;
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
};
|
|
199
|
-
const filterParts = tree && !phone
|
|
200
|
-
? [
|
|
201
|
-
{
|
|
202
|
-
key: "filters",
|
|
203
|
-
line: 2,
|
|
204
|
-
...(barItemsOf(tree.tree).length === 0 && !heldStands(held, tree.tree)
|
|
205
|
-
? { shed: true, fold: true, menu: filterMenu }
|
|
206
|
-
: { filters: foldableFilters(tree.tree, held) }),
|
|
207
|
-
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter })),
|
|
208
|
-
},
|
|
209
|
-
]
|
|
124
|
+
const quickHere = !!quick;
|
|
125
|
+
const barFilters = !!tree && !phone && !barPlaced;
|
|
126
|
+
const filterParts = barFilters
|
|
127
|
+
? [{ key: "filters", line: 2, ...barFiltersItem(tree.tree, held), node: _jsx(ListFilter, {}) }]
|
|
210
128
|
: [
|
|
211
|
-
{ key: "filter", line: 2,
|
|
212
|
-
...(tree
|
|
213
|
-
? [
|
|
214
|
-
{
|
|
215
|
-
key: "advanced-filters",
|
|
216
|
-
line: 2,
|
|
217
|
-
node: _jsx(ToolbarAdvancedFilters, { filterTree: tree, host: hosts?.filter }),
|
|
218
|
-
},
|
|
219
|
-
]
|
|
220
|
-
: []),
|
|
129
|
+
{ key: "filter", line: 2, ...FILTER_ITEM, node: _jsx(ListFilter, {}) },
|
|
130
|
+
...(tree && !barPlaced ? [{ key: "advanced-filters", line: 2, node: _jsx(ListAdvancedFilters, {}) }] : []),
|
|
221
131
|
];
|
|
222
132
|
const kitParts = [
|
|
223
|
-
...(shownViews
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
...(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show, stacked: true }),
|
|
232
|
-
},
|
|
233
|
-
]
|
|
234
|
-
: []),
|
|
235
|
-
{
|
|
236
|
-
key: "options",
|
|
237
|
-
shed: true,
|
|
238
|
-
fold: true,
|
|
239
|
-
menu: {
|
|
240
|
-
label: messages({ key: "views.panels.toolbar-options" }),
|
|
241
|
-
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
242
|
-
onSelect: () => options.onOpenChange(true),
|
|
243
|
-
},
|
|
244
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, ...(layered && { layered }), viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? resetAll : undefined, resets: resets, customizeItems: menus?.customize, fieldEditor: fieldEditor, onClear: resetAll, open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
245
|
-
},
|
|
246
|
-
...(quickNode
|
|
247
|
-
? [
|
|
248
|
-
{
|
|
249
|
-
key: "quick",
|
|
250
|
-
side: "end",
|
|
251
|
-
shed: true,
|
|
252
|
-
fold: true,
|
|
253
|
-
menu: {
|
|
254
|
-
label: quick?.label ?? messages({ key: "views.panels.quick-filters" }),
|
|
255
|
-
icon: _jsx(QuickGlyph, { className: "h-4 w-4" }),
|
|
256
|
-
onSelect: () => quickState.onOpenChange(true),
|
|
257
|
-
},
|
|
258
|
-
node: quickNode,
|
|
259
|
-
},
|
|
260
|
-
]
|
|
261
|
-
: []),
|
|
262
|
-
{ key: "search", side: "end", role: "search", words: "icon", node: searchNode },
|
|
263
|
-
{ key: "new", side: "end", shed: true, node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
264
|
-
{
|
|
265
|
-
key: "sort",
|
|
266
|
-
line: 2,
|
|
267
|
-
shed: true,
|
|
268
|
-
fold: true,
|
|
269
|
-
menu: {
|
|
270
|
-
label: messages({ key: "views.panels.sort" }),
|
|
271
|
-
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
272
|
-
onSelect: () => sortState.onOpenChange(true),
|
|
273
|
-
},
|
|
274
|
-
node: sortNode,
|
|
275
|
-
},
|
|
276
|
-
...(hasFilter ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
133
|
+
...(shownViews ? [{ key: "views", tabs, node: viewsNode }] : []),
|
|
134
|
+
...(shownViews && stackedAxes && !phone ? [{ key: "views-stacked", line: 2, node: stackedNode }] : []),
|
|
135
|
+
{ ...CUSTOMIZE_ITEM, node: customizeNode },
|
|
136
|
+
...(quickHere ? [{ ...QUICK_ITEM, side: "end", node: _jsx(ListQuickFilters, {}) }] : []),
|
|
137
|
+
{ ...SEARCH_ITEM, side: "end", words: "icon", node: searchNode },
|
|
138
|
+
{ ...NEW_ITEM, side: "end", node: newNode },
|
|
139
|
+
{ ...SORT_ITEM, line: 2, node: _jsx(ListSort, {}) },
|
|
140
|
+
...(hasFilter ? [{ key: "sep", line: 2, role: "separator", node: _jsx(LineSep, {}) }] : []),
|
|
277
141
|
...filterParts,
|
|
278
|
-
...(!phone
|
|
279
|
-
? [
|
|
280
|
-
{
|
|
281
|
-
key: "save",
|
|
282
|
-
line: 2,
|
|
283
|
-
side: "end",
|
|
284
|
-
...saveParts,
|
|
285
|
-
},
|
|
286
|
-
]
|
|
287
|
-
: []),
|
|
142
|
+
...(!phone ? [{ ...SAVE_ITEM, line: 2, side: "end", ...saveParts }] : []),
|
|
288
143
|
];
|
|
144
|
+
const form = toolbarForm({ phone, narrow: false });
|
|
145
|
+
const lined = (parts, ready, partKeys) => asParts(ready, partKeys, _jsx(ReadyLines, { parts: parts, built: placed(parts), form: form, more: menus?.more, overflow: overflow, className: className }));
|
|
289
146
|
if (phone) {
|
|
290
|
-
const
|
|
291
|
-
const phoneParts =
|
|
292
|
-
? [...kitParts.filter((part) => part !==
|
|
147
|
+
const quickPart = kitParts.find((part) => part.key === "quick");
|
|
148
|
+
const phoneParts = quickPart
|
|
149
|
+
? [...kitParts.filter((part) => part !== quickPart), { ...quickPart, line: 2, side: "start" }]
|
|
293
150
|
: kitParts;
|
|
294
|
-
return
|
|
151
|
+
return lined(phoneParts, asked({ sort: "line", filter: "plain", customizeFoot: "parts", quickWord: "own" }), keys("sort", "filter"));
|
|
295
152
|
}
|
|
296
153
|
if (sortFilter === "bar")
|
|
297
|
-
return
|
|
298
|
-
const rowSort = {
|
|
299
|
-
key: "sort",
|
|
300
|
-
side: "end",
|
|
301
|
-
shed: true,
|
|
302
|
-
fold: true,
|
|
303
|
-
menu: {
|
|
304
|
-
label: messages({ key: "views.panels.sort" }),
|
|
305
|
-
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
306
|
-
onSelect: () => sortAdd.onOpenChange(true),
|
|
307
|
-
},
|
|
308
|
-
node: panels.sorts ? (_jsx(ToolbarSortPill, { row: true, sorts: panels.sorts, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort, ...(differs && { changed: differs.sort }) })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort, ...(differs && { changed: differs.sort }) })),
|
|
309
|
-
};
|
|
310
|
-
const rowFilter = tree
|
|
311
|
-
? {
|
|
312
|
-
key: "filter-add",
|
|
313
|
-
side: "end",
|
|
314
|
-
shed: true,
|
|
315
|
-
fold: true,
|
|
316
|
-
menu: { ...filterMenu, onSelect: () => filterAdd.onOpenChange(true) },
|
|
317
|
-
node: (_jsx(ToolbarFilterAdd, { filterTree: tree, onHeldChange: setHeld, open: filterAdd.open, onOpenChange: filterAdd.onOpenChange, host: hosts?.filter, changed: !!differs?.filter, opens: "filters" })),
|
|
318
|
-
}
|
|
319
|
-
: { key: "filter", side: "end", shed: true, fold: true, menu: filterMenu, node: filterNode };
|
|
320
|
-
const pill = (always || !!differs?.sort) && (panels.sorts ?? panels.sort).options.length > 0 ? (panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: false })) : (_jsx(ToolbarSort, { bar: true, sort: panels.sort, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort }))) : null;
|
|
154
|
+
return lined(kitParts, asked({ sort: "line", filter: barFilters ? "bar" : "plain", customizeFoot: "none", quickWord: "own" }), keys("sort", "filter"));
|
|
321
155
|
const stackedPart = kitParts.find((part) => part.key === "views-stacked");
|
|
156
|
+
const pieces = barPlaced
|
|
157
|
+
? []
|
|
158
|
+
: filterBarParts({ panels, differs, held, setHeld, savedFilter, always, sorts: "no", sortState: CLOSED, filterState: CLOSED }).parts.map((part) => ({ ...part, node: piece(part.key, _jsx(ListFilterBar, {})) }));
|
|
322
159
|
const barParts = barShown
|
|
323
|
-
? [
|
|
324
|
-
...(stackedPart ? [stackedPart] : []),
|
|
325
|
-
...(pill ? [{ key: "sort-pill", line: 2, node: pill }] : []),
|
|
326
|
-
...(pill && (filtered || always) ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
327
|
-
...(tree
|
|
328
|
-
? [
|
|
329
|
-
{
|
|
330
|
-
key: "filters",
|
|
331
|
-
line: 2,
|
|
332
|
-
filters: foldableFilters(tree.tree, held, always ? undefined : savedFilter),
|
|
333
|
-
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter, emptyPlace: always, ...(!always && savedFilter && { saved: savedFilter }) })),
|
|
334
|
-
},
|
|
335
|
-
]
|
|
336
|
-
: []),
|
|
337
|
-
{
|
|
338
|
-
key: "save",
|
|
339
|
-
line: 2,
|
|
340
|
-
side: "end",
|
|
341
|
-
...saveParts,
|
|
342
|
-
},
|
|
343
|
-
]
|
|
160
|
+
? [...(stackedPart ? [stackedPart] : []), ...pieces, { ...SAVE_ITEM, line: 2, side: "end", ...saveParts }]
|
|
344
161
|
: [];
|
|
345
162
|
const at = (key) => kitParts.find((part) => part.key === key);
|
|
346
163
|
const quickPart = at("quick");
|
|
347
164
|
const mihaisParts = [
|
|
348
|
-
...kitParts.filter((part) => (part.line ?? 1) === 1 && !["quick", "search", "new"
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
...(quickPart
|
|
352
|
-
? [
|
|
353
|
-
{
|
|
354
|
-
...quickPart,
|
|
355
|
-
words: "icon",
|
|
356
|
-
node: (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick, word: null })),
|
|
357
|
-
},
|
|
358
|
-
]
|
|
359
|
-
: []),
|
|
165
|
+
...kitParts.filter((part) => (part.line ?? 1) === 1 && !["quick", "search", "new"].includes(part.key)),
|
|
166
|
+
{ ...SORT_ITEM, side: "end", node: _jsx(ListSort, {}) },
|
|
167
|
+
{ key: filterItemKey("add", !!tree, phone), side: "end", ...FILTER_ITEM, node: _jsx(ListFilter, {}) },
|
|
168
|
+
...(quickPart ? [{ ...quickPart, words: "icon" }] : []),
|
|
360
169
|
at("search"),
|
|
361
170
|
at("new"),
|
|
362
171
|
...barParts,
|
|
363
172
|
];
|
|
364
|
-
return
|
|
173
|
+
return lined(mihaisParts, asked({ sort: "row", filter: "add", customizeFoot: "parts", quickWord: "icon" }), keys("sort-add", tree ? "filter-add" : "filter"));
|
|
365
174
|
}
|
|
366
175
|
const parts = [
|
|
367
|
-
...(shownViews
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
{
|
|
374
|
-
|
|
375
|
-
side: "end",
|
|
376
|
-
role: "search",
|
|
377
|
-
words: "icon",
|
|
378
|
-
node: searchNode,
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
key: "sort",
|
|
382
|
-
side: "end",
|
|
383
|
-
node: sortNode,
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
key: "filter",
|
|
387
|
-
side: "end",
|
|
388
|
-
node: filterNode,
|
|
389
|
-
},
|
|
390
|
-
...(panels.filterTree
|
|
391
|
-
? [
|
|
392
|
-
{
|
|
393
|
-
key: "advanced-filters",
|
|
394
|
-
side: "end",
|
|
395
|
-
node: _jsx(ToolbarAdvancedFilters, { filterTree: panels.filterTree, host: hosts?.filter }),
|
|
396
|
-
},
|
|
397
|
-
]
|
|
398
|
-
: []),
|
|
399
|
-
...(quickNode ? [{ key: "quick", side: "end", node: quickNode }] : []),
|
|
400
|
-
{
|
|
401
|
-
key: "options",
|
|
402
|
-
side: "end",
|
|
403
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, ...(layered && { layered }), resets: resets, customizeItems: menus?.customize, fieldEditor: fieldEditor, onClear: resetAll, open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
404
|
-
},
|
|
405
|
-
{ key: "new", side: "end", node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
176
|
+
...(shownViews ? [{ key: "views", node: viewsNode }, { key: "views-stacked", line: 2, node: stackedNode }] : []),
|
|
177
|
+
{ key: "search", side: "end", role: "search", words: "icon", node: searchNode },
|
|
178
|
+
{ key: "sort", side: "end", node: _jsx(ListSort, {}) },
|
|
179
|
+
{ key: "filter", side: "end", node: _jsx(ListFilter, {}) },
|
|
180
|
+
...(tree ? [{ key: "advanced-filters", side: "end", node: _jsx(ListAdvancedFilters, {}) }] : []),
|
|
181
|
+
...(quick ? [{ key: "quick", side: "end", node: _jsx(ListQuickFilters, {}) }] : []),
|
|
182
|
+
{ key: "options", side: "end", node: customizeNode },
|
|
183
|
+
{ key: "new", side: "end", node: newNode },
|
|
406
184
|
];
|
|
407
|
-
return _jsx(Toolbar, { parts: placed(parts), phone: phone, narrow: narrow, className: className });
|
|
185
|
+
return asParts(asked({ sort: "line", filter: "plain", customizeFoot: "own", quickWord: "own" }), keys("sort", "filter"), _jsx(Toolbar, { parts: ownApart(parts, placed(parts)), phone: phone, narrow: narrow, className: className }));
|
|
186
|
+
}
|
|
187
|
+
const asOwn = (node) => (_jsx(PartKeys.Provider, { value: NO_KEYS, children: _jsx(ReadyPartsContext.Provider, { value: null, children: _jsx(ReadyPiece.Provider, { value: null, children: node }) }) }));
|
|
188
|
+
const NO_KEYS = {};
|
|
189
|
+
function ownApart(built, placed) {
|
|
190
|
+
const ours = new Set(built.flatMap((part) => [part.key, ...Object.keys(part.apart ?? {})]));
|
|
191
|
+
return placed.map((part) => (ours.has(part.key) ? part : { ...part, node: asOwn(part.node) }));
|
|
192
|
+
}
|
|
193
|
+
const CLOSED = { open: false, onOpenChange: () => { }, page: null, onPageChange: () => { } };
|
|
194
|
+
function ReadyLines({ parts, built, form, more, overflow, className, }) {
|
|
195
|
+
const lines = arrangeToolbar(built, form, { fold: true });
|
|
196
|
+
const byKey = new Map(built.map((part) => [part.key, part]));
|
|
197
|
+
const own = new Map();
|
|
198
|
+
for (const part of parts)
|
|
199
|
+
for (const key of [part.key, ...Object.keys(part.apart ?? {})])
|
|
200
|
+
own.set(key, !!part.shed);
|
|
201
|
+
const item = (slot) => {
|
|
202
|
+
const part = byKey.get(slot.key);
|
|
203
|
+
const place = {
|
|
204
|
+
...(part.words && { words: part.words }),
|
|
205
|
+
...(part.foot !== undefined && { foot: part.foot }),
|
|
206
|
+
...(part.className && { className: part.className }),
|
|
207
|
+
...(part.button && { button: part.button }),
|
|
208
|
+
...(part.panel && { panel: part.panel }),
|
|
209
|
+
};
|
|
210
|
+
const turned = own.has(part.key) && own.get(part.key) !== !!part.shed;
|
|
211
|
+
const value = { id: part.key, place, ...(turned && { shed: !!part.shed }) };
|
|
212
|
+
return (_jsx(LinePlace.Provider, { value: value, children: own.has(part.key) ? part.node : _jsx(LineItem, { item: { key: part.key }, children: asOwn(part.node) }) }, part.key));
|
|
213
|
+
};
|
|
214
|
+
return (_jsx(FoldFrame, { form: form, className: className, children: _jsx(LineForm.Provider, { value: form, children: lines.map((line) => (_jsx(LineSeed.Provider, { value: line, children: _jsx(ListLine, { kind: line.kind === "bar" ? "bar" : "row", more: more, overflow: overflow, children: [
|
|
215
|
+
...line.start.map(item),
|
|
216
|
+
_jsx(LinePlace.Provider, { value: GAP_PLACE, children: _jsx(ListGap, {}) }, SEED_GAP),
|
|
217
|
+
...line.end.map(item),
|
|
218
|
+
] }) }, line.kind))) }) }));
|
|
408
219
|
}
|
|
220
|
+
const GAP_PLACE = { id: SEED_GAP };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
2
|
import { writeListLink } from "viewkitjs/fields/query";
|
|
4
3
|
import { useViews } from "../provider/context.js";
|
|
5
|
-
import { useList } from "./root-base.js";
|
|
4
|
+
import { useList, useListStore } from "./root-base.js";
|
|
6
5
|
const LAYOUT_NAMES = {
|
|
7
6
|
table: { key: "views.panels.layout-table" },
|
|
8
7
|
list: { key: "views.panels.layout-list" },
|
|
@@ -17,7 +16,18 @@ export function useListViewsAxis(layouts) {
|
|
|
17
16
|
const settings = useList((s) => s.view.settings);
|
|
18
17
|
const openPanel = useList((s) => s.openPanel);
|
|
19
18
|
const { messages, ports } = useViews();
|
|
20
|
-
|
|
19
|
+
const store = useListStore();
|
|
20
|
+
const at = layouts?.join("\u0000") ?? "";
|
|
21
|
+
const deps = [views, changes, counts, settings.search, openPanel, messages, ports, at];
|
|
22
|
+
const cells = AXES.get(store) ?? new Map();
|
|
23
|
+
AXES.set(store, cells);
|
|
24
|
+
const held = cells.get(at);
|
|
25
|
+
if (held && held.deps.length === deps.length && held.deps.every((dep, i) => Object.is(dep, deps[i])))
|
|
26
|
+
return held.value;
|
|
27
|
+
const value = axisOf();
|
|
28
|
+
cells.set(at, { deps, value });
|
|
29
|
+
return value;
|
|
30
|
+
function axisOf() {
|
|
21
31
|
if (!views || (!views.ready && views.list.length === 0))
|
|
22
32
|
return undefined;
|
|
23
33
|
const byId = (id) => views.list.find((v) => v.id === id);
|
|
@@ -94,5 +104,6 @@ export function useListViewsAxis(layouts) {
|
|
|
94
104
|
onChange,
|
|
95
105
|
},
|
|
96
106
|
};
|
|
97
|
-
}
|
|
107
|
+
}
|
|
98
108
|
}
|
|
109
|
+
const AXES = new WeakMap();
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type ViewsMessageResolver } from "../contract.js";
|
|
2
2
|
import { type DisplayCurrency } from "../fields/currency.js";
|
|
3
3
|
import type { ListAggregateKind, ListColumn } from "./column-schema.js";
|
|
4
|
-
/** A figure's name, as the app words it: `views.grid.figure
|
|
4
|
+
/** A figure's name, as the app words it: `views.grid.figure`, a row of the footer's picker ("Count empty"). */
|
|
5
5
|
export declare function aggregateLabel(kind: ListAggregateKind, messages?: ViewsMessageResolver): string;
|
|
6
|
+
/** A figure's word after its value in the footer ("20% empty", "13 count"), as the app words it: `views.grid.figure-word`. */
|
|
7
|
+
export declare function aggregateWord(kind: ListAggregateKind, messages?: ViewsMessageResolver): string;
|
|
8
|
+
/** Where a column stands in the footer: the first (visible) column offers Count alone, as Attio's name column does. */
|
|
9
|
+
export type AggregatePlace = {
|
|
10
|
+
first?: boolean;
|
|
11
|
+
};
|
|
6
12
|
/** A source list's footer (POR-470, POR-472): the keys whose figures the
|
|
7
13
|
* database answered, those of them whose figure carries `filled` (VK-632; none
|
|
8
14
|
* when absent), and the reader's default currency — the key a money column
|
|
@@ -18,14 +24,18 @@ export type SourcedAggregates = {
|
|
|
18
24
|
* server's `moneyFigureKey` writes the same key. */
|
|
19
25
|
export declare function figureKeyOf<Row>(col: ListColumn<Row>, defaultCurrency: DisplayCurrency): string;
|
|
20
26
|
/**
|
|
21
|
-
* The aggregates a column offers.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
27
|
+
* The aggregates a column offers, Attio's set, None first. The first column (`place.first`) offers Count alone: on any
|
|
28
|
+
* other it would repeat the row count. Every other column offers Count empty, Count filled, Percent empty and Percent
|
|
29
|
+
* filled; a number and money add Sum, Average, Min and Max. A PERCENT never offers `sum` — adding percents is
|
|
30
|
+
* meaningless — and offers `ratio` only when the column carries the two readers (a ratio formula): sum over sum is the
|
|
31
|
+
* honest total for a percent-of-something, where `avg` weights every row alike. The rule reads the column's value
|
|
32
|
+
* type — a bound column's field, a field-less column's own.
|
|
26
33
|
*/
|
|
27
|
-
export declare function aggregateOptions<Row>(col: ListColumn<Row>, sourced?: SourcedAggregates): ListAggregateKind[];
|
|
28
|
-
|
|
34
|
+
export declare function aggregateOptions<Row>(col: ListColumn<Row>, sourced?: SourcedAggregates, place?: AggregatePlace): ListAggregateKind[];
|
|
35
|
+
/** The pick a column's footer shows: the reader's, when the column offers it (a stored pick it no longer offers, a
|
|
36
|
+
* Count off the first column or a Unique, reads None and stays stored); else ratio for a ratio column; else the
|
|
37
|
+
* column's declared default, when offered. */
|
|
38
|
+
export declare function resolveAggregateKind<Row>(col: ListColumn<Row>, prefs?: Readonly<Record<string, ListAggregateKind>>, sourced?: SourcedAggregates, place?: AggregatePlace): ListAggregateKind;
|
|
29
39
|
/** A column's figure over some rows, worked out by `viewkitjs/fields` (`figureOfValues`, `ratioOf`) from what the
|
|
30
40
|
* column reads: its cells for a count, the filled and the different ones; the figure it says to total
|
|
31
41
|
* (`aggAccessor`, else the cell) for the numbers; its two readers for a ratio. */
|