viewkitjs 0.38.0 → 0.40.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 +134 -0
- package/MIGRATION.md +32 -0
- package/fields/dist/derived.d.ts +7 -0
- package/fields/dist/derived.js +4 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +5 -1
- package/fields/dist/messages.js +3 -0
- package/fields/dist/query/evaluate.d.ts +7 -1
- package/fields/dist/query/evaluate.js +8 -5
- 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/dist/query/filter.d.ts +7 -0
- package/fields/dist/query/filter.js +7 -1
- package/fields/dist/query/kit.d.ts +3 -2
- package/fields/dist/query/kit.js +1 -1
- package/fields/dist/query/layer.d.ts +6 -0
- package/fields/dist/query/layer.js +3 -0
- package/fields/dist/query/number.d.ts +3 -2
- package/fields/dist/query/number.js +5 -3
- package/fields/dist/query/read-rule.d.ts +1 -1
- package/fields/dist/query/read-rule.js +3 -0
- package/fields/docs/guides/queries.md +28 -24
- package/fields/docs/reference/fields.md +1 -0
- package/fields/docs/reference/query.md +9 -7
- package/package.json +2 -4
- package/postgres/dist/check.js +3 -1
- package/postgres/dist/definitions/storage.d.ts +3 -1
- package/postgres/dist/definitions/storage.js +3 -1
- package/postgres/dist/definitions/stored.js +13 -2
- package/postgres/dist/map.d.ts +5 -1
- package/postgres/dist/map.js +4 -0
- package/postgres/dist/records.js +6 -1
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +3 -3
- package/postgres/docs/reference/postgres.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 +38 -9
- package/views/dist/contract.js +64 -6
- package/views/dist/controls/avatar.css +1 -1
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +2 -14
- package/views/dist/controls/field/field.js +4 -9
- 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 +15 -2
- package/views/dist/controls/filter-editor/filter-editor.js +49 -16
- package/views/dist/controls/filter-editor/how.d.ts +11 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +21 -11
- package/views/dist/controls/filter-editor/map-rules.d.ts +6 -4
- package/views/dist/controls/filter-editor/map-rules.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +14 -1
- package/views/dist/controls/filter-editor/parts.js +14 -0
- package/views/dist/controls/filter-editor.css +4 -1
- package/views/dist/controls/index.d.ts +0 -3
- package/views/dist/controls/index.js +0 -3
- package/views/dist/controls/input.css +1 -1
- 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/menu-list.css +1 -1
- package/views/dist/controls/picker/looks.d.ts +1 -1
- package/views/dist/controls/picker.css +2 -2
- 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/press.css +0 -1
- package/views/dist/controls/radio/radio.d.ts +1 -1
- package/views/dist/controls/radio/radio.js +1 -16
- package/views/dist/controls/sheet/bottom-sheet.d.ts +2 -2
- package/views/dist/controls/sheet/bottom-sheet.js +31 -24
- 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 +22 -0
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- 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 +28 -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/filters/duration-bound.d.ts +7 -0
- package/views/dist/filters/duration-bound.js +9 -0
- package/views/dist/filters/filter-model.d.ts +4 -0
- package/views/dist/filters/number-refused.d.ts +8 -0
- package/views/dist/filters/number-refused.js +4 -0
- 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 +15 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +12 -2
- package/views/dist/grid/core/clipboard-model.js +42 -8
- package/views/dist/grid/core/commit-model.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.d.ts +29 -1
- package/views/dist/grid/core/editing-controller.js +142 -12
- package/views/dist/grid/core/pending-reconciliation.d.ts +14 -0
- package/views/dist/grid/core/pending-reconciliation.js +20 -8
- package/views/dist/grid/core/save-path.d.ts +4 -2
- package/views/dist/grid/core/save-path.js +1 -1
- package/views/dist/grid/core/spreadsheet-operations.js +43 -5
- package/views/dist/grid/core/useGridEditing.d.ts +5 -1
- package/views/dist/grid/core/useGridEditing.js +4 -4
- package/views/dist/grid/core/written-alongside.d.ts +16 -0
- package/views/dist/grid/core/written-alongside.js +30 -0
- package/views/dist/grid/grid.css +8 -4
- package/views/dist/grid/index.d.ts +1 -1
- package/views/dist/grid/looks.d.ts +2 -2
- package/views/dist/internal/before-paint.d.ts +5 -0
- package/views/dist/internal/before-paint.js +17 -0
- package/views/dist/internal/field-rows.d.ts +0 -8
- package/views/dist/internal/field-rows.js +1 -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 +8 -0
- package/views/dist/list/bar-keys.js +3 -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 +19 -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 +21 -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 +97 -0
- package/views/dist/list/buttons/shared.js +137 -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 +38 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +58 -0
- package/views/dist/list/line.js +229 -0
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- 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 +73 -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 +26 -0
- package/views/dist/list/panels/shared.js +36 -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 +19 -1
- package/views/dist/list/root-base.js +13 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +29 -0
- package/views/dist/list/store.js +48 -2
- package/views/dist/list/toolbar-model.d.ts +99 -0
- package/views/dist/list/toolbar-model.js +195 -0
- package/views/dist/list/toolbar.js +142 -329
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/list/views.d.ts +1 -1
- package/views/dist/list/views.js +4 -1
- package/views/dist/looks/index.d.ts +0 -1
- package/views/dist/looks/index.js +0 -1
- package/views/dist/looks/looks.d.ts +1 -1
- package/views/dist/looks/pieces.js +0 -2
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/model/column-filters.js +10 -3
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/filter/NumberFilterBody.js +6 -8
- package/views/dist/panels/labels.js +7 -2
- package/views/dist/panels/model.d.ts +3 -0
- 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 +7 -3
- 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 +84 -0
- package/views/dist/panels/react/toolbar/ToolbarButton.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +5 -3
- 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/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- 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 +10 -3
- 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 +12 -0
- package/views/dist/panels/settings/input.d.ts +11 -0
- package/views/dist/panels/settings/layout.js +26 -0
- package/views/dist/panels/settings/person.d.ts +15 -0
- package/views/dist/panels/settings/person.js +6 -0
- package/views/dist/panels/toolbar/page-resets.js +14 -3
- package/views/dist/provider/components.d.ts +47 -4
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +116 -257
- package/views/dist/styles.unlayered.css +116 -257
- package/views/docs/contract.md +28 -18
- package/views/docs/controls/field.md +2 -1
- 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/looks.md +1 -1
- package/views/docs/guides/the-grid.md +6 -4
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +6 -44
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +8 -7
- package/views/docs/reference/list.md +184 -11
- package/views/docs/reference/looks.md +13 -16
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +14 -11
- package/views/docs/reference/views.md +9 -7
- package/views/skills/views/SKILL.md +2 -1
- package/views/dist/controls/setting-row/looks.d.ts +0 -10
- package/views/dist/controls/setting-row/looks.js +0 -22
- package/views/dist/controls/setting-row/setting-row.d.ts +0 -102
- package/views/dist/controls/setting-row/setting-row.js +0 -135
- package/views/dist/controls/setting-row/tokens.d.ts +0 -156
- package/views/dist/controls/setting-row/tokens.js +0 -41
- package/views/dist/controls/setting-row.css +0 -216
- package/views/dist/controls/switch-row/switch-row.d.ts +0 -1
- package/views/dist/controls/switch-row/switch-row.js +0 -1
- package/views/dist/controls/switch-row/tokens.d.ts +0 -39
- package/views/dist/controls/switch-row/tokens.js +0 -12
- package/views/dist/controls/switch-row.css +0 -35
- package/views/dist/controls/tag-field/tag-field.d.ts +0 -24
- package/views/dist/controls/tag-field/tag-field.js +0 -25
- package/views/dist/controls/tag-field/tokens.d.ts +0 -23
- package/views/dist/controls/tag-field/tokens.js +0 -8
- package/views/dist/controls/tag-field.css +0 -32
- package/views/docs/controls/setting-row.md +0 -44
- package/views/docs/controls/switch-row.md +0 -15
- package/views/docs/controls/tag-field.md +0 -11
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { settingsChange } from "viewkitjs/fields/query";
|
|
2
|
+
import { useContext, useState } from "react";
|
|
3
|
+
import { settingsPanels } from "../panels/settings/settings-panels.js";
|
|
4
|
+
import { settingsCleared } from "../panels/toolbar/clear.js";
|
|
5
|
+
import { countsToggle, groupShown, showCountsChange, showCountsOf } from "../panels/toolbar/counts.js";
|
|
6
|
+
import { pageResets } from "../panels/toolbar/page-resets.js";
|
|
7
|
+
import { useViews } from "../provider/context.js";
|
|
8
|
+
import { FILTER_BAR_ALWAYS_KEY, FILTER_BAR_BUTTON_KEY, FILTER_BAR_KEY } from "./bar-keys.js";
|
|
9
|
+
import { EMPTY_LAYER, layerHolds } from "./layer.js";
|
|
10
|
+
import { ToolbarModelProvided, useList, useListStore, useRootQuickFilters } from "./root-base.js";
|
|
11
|
+
import { useListViewsAxis } from "./views-axis.js";
|
|
12
|
+
const ROOT_CELLS = new WeakMap();
|
|
13
|
+
const OWN_CELLS = new WeakMap();
|
|
14
|
+
const cellOf = (cells, by) => {
|
|
15
|
+
const held = cells.get(by);
|
|
16
|
+
if (held)
|
|
17
|
+
return held;
|
|
18
|
+
const cell = { reads: null, props: null, model: null };
|
|
19
|
+
cells.set(by, cell);
|
|
20
|
+
return cell;
|
|
21
|
+
};
|
|
22
|
+
const sameKeys = (a, b) => {
|
|
23
|
+
if (!a)
|
|
24
|
+
return false;
|
|
25
|
+
const x = a;
|
|
26
|
+
const y = b;
|
|
27
|
+
const keys = Object.keys(x);
|
|
28
|
+
return keys.length === Object.keys(y).length && keys.every((key) => Object.is(x[key], y[key]));
|
|
29
|
+
};
|
|
30
|
+
export function useToolbarModel(props) {
|
|
31
|
+
const reads = useModelReads(props);
|
|
32
|
+
const provided = useContext(ToolbarModelProvided);
|
|
33
|
+
const store = useListStore();
|
|
34
|
+
const [own] = useState(() => ({}));
|
|
35
|
+
if (props.fromRoot) {
|
|
36
|
+
if (provided)
|
|
37
|
+
return provided.model;
|
|
38
|
+
return modelIn(cellOf(ROOT_CELLS, store), reads, props);
|
|
39
|
+
}
|
|
40
|
+
return modelIn(cellOf(OWN_CELLS, own), reads, props);
|
|
41
|
+
}
|
|
42
|
+
export function useOwnToolbarModel(props) {
|
|
43
|
+
const reads = useModelReads(props);
|
|
44
|
+
const [own] = useState(() => ({}));
|
|
45
|
+
return modelIn(cellOf(OWN_CELLS, own), reads, props);
|
|
46
|
+
}
|
|
47
|
+
function modelIn(cell, reads, handed) {
|
|
48
|
+
const { toolbarParts: _places, ...props } = handed;
|
|
49
|
+
if (cell.model && sameKeys(cell.reads, reads) && sameKeys(cell.props, props))
|
|
50
|
+
return cell.model;
|
|
51
|
+
const model = modelOf(reads, props);
|
|
52
|
+
cell.reads = reads;
|
|
53
|
+
cell.props = props;
|
|
54
|
+
cell.model = model;
|
|
55
|
+
return model;
|
|
56
|
+
}
|
|
57
|
+
function useModelReads(props) {
|
|
58
|
+
const { messages, conventions } = useViews();
|
|
59
|
+
return {
|
|
60
|
+
storeViews: useListViewsAxis(props.layouts),
|
|
61
|
+
rootColumns: useList((s) => s.columns),
|
|
62
|
+
answer: useList((s) => s.answer),
|
|
63
|
+
settings: useList((s) => s.view.settings),
|
|
64
|
+
layer: useList((s) => s.view.layer),
|
|
65
|
+
onChange: useList((s) => s.setSettings),
|
|
66
|
+
onLayerChange: useList((s) => s.setLayer),
|
|
67
|
+
shared: useList((s) => s.view.shared) ?? undefined,
|
|
68
|
+
held: useList((s) => s.panels.held),
|
|
69
|
+
setHeld: useList((s) => s.hold),
|
|
70
|
+
rootQuick: useRootQuickFilters(),
|
|
71
|
+
personBar: useList((s) => s.panels.personBar),
|
|
72
|
+
personWords: useList((s) => s.panels.personWords),
|
|
73
|
+
barDefault: useList(barDefaultOf),
|
|
74
|
+
messages,
|
|
75
|
+
conventions,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function barDefaultOf(s) {
|
|
79
|
+
const placed = s.panels.placed;
|
|
80
|
+
if ((placed[FILTER_BAR_BUTTON_KEY] ?? 0) > 0)
|
|
81
|
+
return "button";
|
|
82
|
+
if ((placed[FILTER_BAR_ALWAYS_KEY] ?? 0) > 0)
|
|
83
|
+
return "always";
|
|
84
|
+
if ((placed[FILTER_BAR_KEY] ?? 0) > 0)
|
|
85
|
+
return "added";
|
|
86
|
+
return s.panels.bar;
|
|
87
|
+
}
|
|
88
|
+
const NO_COLUMNS = [];
|
|
89
|
+
function modelOf(reads, props) {
|
|
90
|
+
const { phone } = props;
|
|
91
|
+
const { storeViews, rootColumns, answer, settings, layer, onChange, onLayerChange, shared, held, setHeld, rootQuick, messages, conventions } = reads;
|
|
92
|
+
const person = { bar: reads.personBar, words: reads.personWords };
|
|
93
|
+
const views = props.views ?? storeViews;
|
|
94
|
+
const show = showCountsOf(settings);
|
|
95
|
+
const setShow = (next) => {
|
|
96
|
+
const change = showCountsChange(settings, next);
|
|
97
|
+
if (Object.keys(change).length > 0)
|
|
98
|
+
onChange(change);
|
|
99
|
+
};
|
|
100
|
+
const { toolbarParts: _placed, phone: _phone, fromRoot: _fromRoot, ...settingsProps } = props;
|
|
101
|
+
const input = {
|
|
102
|
+
...settingsProps,
|
|
103
|
+
columns: props.columns ?? rootColumns ?? NO_COLUMNS,
|
|
104
|
+
groupHeads: props.groupHeads ?? answer?.groupHeads,
|
|
105
|
+
filterData: props.filterData ?? answer?.filterValues,
|
|
106
|
+
settings,
|
|
107
|
+
layer,
|
|
108
|
+
onChange,
|
|
109
|
+
onLayerChange,
|
|
110
|
+
severalSorts: props.severalSorts ?? true,
|
|
111
|
+
filterGroups: props.filterGroups ?? true,
|
|
112
|
+
resolve: props.resolve ?? messages,
|
|
113
|
+
conventions: props.conventions ?? conventions,
|
|
114
|
+
person,
|
|
115
|
+
phone: !!phone,
|
|
116
|
+
barDefault: reads.barDefault,
|
|
117
|
+
};
|
|
118
|
+
const panels = settingsPanels(input);
|
|
119
|
+
const counts = countsToggle(views, props.toggles, show, setShow, messages);
|
|
120
|
+
const toggles = counts ? [...(props.toggles ?? []), counts] : props.toggles;
|
|
121
|
+
const inputs = {
|
|
122
|
+
filters: panels.filters,
|
|
123
|
+
sort: panels.sort,
|
|
124
|
+
sorts: panels.sorts,
|
|
125
|
+
filterTree: panels.filterTree,
|
|
126
|
+
group: groupShown(panels.group, panels.layout, phone),
|
|
127
|
+
layout: panels.layout,
|
|
128
|
+
toggles,
|
|
129
|
+
};
|
|
130
|
+
const clear = (scope) => () => {
|
|
131
|
+
const change = settingsCleared(input, scope, { phone });
|
|
132
|
+
if (change)
|
|
133
|
+
onChange(change);
|
|
134
|
+
};
|
|
135
|
+
const layered = layerHolds(layer, { phone, person });
|
|
136
|
+
const resetAll = () => {
|
|
137
|
+
if (shared) {
|
|
138
|
+
if (shared.changes > 0)
|
|
139
|
+
shared.onReset();
|
|
140
|
+
}
|
|
141
|
+
else
|
|
142
|
+
clear("options")();
|
|
143
|
+
if (layered)
|
|
144
|
+
onLayerChange(EMPTY_LAYER);
|
|
145
|
+
};
|
|
146
|
+
const view = shared && { ...shared, onReset: resetAll };
|
|
147
|
+
const resets = shared && !shared.saved ? undefined : Object.fromEntries(Object.entries(pageResets(input, shared ? shared.saved ?? null : null, { cleared: !shared, phone })).map(([page, back]) => [
|
|
148
|
+
page,
|
|
149
|
+
() => {
|
|
150
|
+
if (back.change)
|
|
151
|
+
onChange(back.change);
|
|
152
|
+
if (back.layer)
|
|
153
|
+
onLayerChange(back.layer);
|
|
154
|
+
},
|
|
155
|
+
]));
|
|
156
|
+
const differs = resets && { sort: !!resets.sort, filter: !!resets.filter };
|
|
157
|
+
const savedFilter = shared?.saved?.filter;
|
|
158
|
+
const clearable = !view && (layered || settingsCleared(input, "options", { phone }) !== null);
|
|
159
|
+
const holdCounts = answer?.holdCounts;
|
|
160
|
+
const own = props.quickFilters ?? (props.fromRoot ? rootQuick ?? undefined : undefined);
|
|
161
|
+
const quick = own?.fields.length
|
|
162
|
+
? {
|
|
163
|
+
...own,
|
|
164
|
+
showCounts: own.showCounts ?? show,
|
|
165
|
+
...(holdCounts && {
|
|
166
|
+
fields: own.fields.map((field) => field.counts === undefined && holdCounts[field.key] ? { ...field, counts: holdCounts[field.key] } : field),
|
|
167
|
+
}),
|
|
168
|
+
}
|
|
169
|
+
: null;
|
|
170
|
+
return {
|
|
171
|
+
settings,
|
|
172
|
+
layer,
|
|
173
|
+
onChange,
|
|
174
|
+
onLayerChange,
|
|
175
|
+
views,
|
|
176
|
+
input,
|
|
177
|
+
panels,
|
|
178
|
+
inputs,
|
|
179
|
+
view,
|
|
180
|
+
resets,
|
|
181
|
+
differs,
|
|
182
|
+
layered,
|
|
183
|
+
clearable,
|
|
184
|
+
resetAll,
|
|
185
|
+
clear,
|
|
186
|
+
show,
|
|
187
|
+
held,
|
|
188
|
+
setHeld,
|
|
189
|
+
savedFilter,
|
|
190
|
+
quick,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export function searchChange(settings, next) {
|
|
194
|
+
return settingsChange(settings, { ...settings, search: next === "" ? undefined : next });
|
|
195
|
+
}
|