viewkitjs 0.39.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 +65 -0
- package/MIGRATION.md +25 -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/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 +6 -4
- 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 +2 -2
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/contract.d.ts +20 -2
- package/views/dist/contract.js +27 -0
- 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/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +5 -2
- package/views/dist/controls/filter-editor/how.d.ts +8 -0
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +17 -8
- package/views/dist/controls/filter-editor/map-rules.d.ts +4 -3
- package/views/dist/controls/filter-editor/map-rules.js +5 -2
- 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/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/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/text-editor.css +5 -3
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.js +4 -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/grid-table-props.d.ts +4 -1
- 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 +1 -1
- 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/list/bar-keys.d.ts +3 -0
- package/views/dist/list/bar-keys.js +1 -0
- package/views/dist/list/buttons/clear-save.js +6 -2
- package/views/dist/list/buttons/new.d.ts +1 -1
- package/views/dist/list/buttons/new.js +14 -2
- package/views/dist/list/buttons/shared.d.ts +7 -1
- package/views/dist/list/buttons/shared.js +8 -2
- package/views/dist/list/buttons/views.js +6 -4
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +5 -2
- package/views/dist/list/line.js +11 -3
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/panels/filter-bar.d.ts +1 -1
- package/views/dist/list/panels/filter-bar.js +9 -3
- package/views/dist/list/panels/shared.d.ts +3 -2
- package/views/dist/list/panels/shared.js +5 -2
- package/views/dist/list/root-base.d.ts +2 -1
- package/views/dist/list/root-base.js +5 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/store.d.ts +10 -0
- package/views/dist/list/store.js +8 -1
- package/views/dist/list/toolbar-model.d.ts +4 -0
- package/views/dist/list/toolbar-model.js +19 -1
- package/views/dist/list/toolbar.js +2 -1
- 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/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/filter-body.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +28 -1
- 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/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +2 -2
- package/views/dist/panels/settings/filter-groups.js +5 -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 +12 -3
- package/views/dist/styles.css +16 -260
- package/views/dist/styles.unlayered.css +16 -260
- package/views/docs/contract.md +9 -7
- package/views/docs/controls/field.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +3 -41
- package/views/docs/reference/grid.md +4 -3
- package/views/docs/reference/list.md +24 -13
- package/views/docs/reference/looks.md +12 -15
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +3 -3
- package/views/docs/reference/views.md +1 -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
|
@@ -5,15 +5,19 @@ import { cx } from "../../internal/cx.js";
|
|
|
5
5
|
import { ToolbarBarSorts } from "../../panels/react/toolbar/ToolbarBarSorts.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { FILTER_BAR_BUTTON_KEY, FILTER_BAR_KEY, filterBarParts } from "../bar-parts.js";
|
|
8
|
+
import { FILTER_BAR_ALWAYS_KEY } from "../bar-keys.js";
|
|
9
|
+
import { personBar } from "../layer.js";
|
|
8
10
|
import { LineItem, useInLine } from "../line.js";
|
|
9
11
|
import { ReadyPiece, useReadyParts } from "../ready.js";
|
|
10
12
|
import { useList, useListPanel, useListStore } from "../root-base.js";
|
|
11
13
|
import { useToolbarModel } from "../toolbar-model.js";
|
|
12
14
|
import { usePartKey, usePartPhone } from "../buttons/shared.js";
|
|
13
|
-
export function ListFilterBar({ shows = "filled", sorts = "no", className }) {
|
|
15
|
+
export function ListFilterBar({ shows: own = "filled", sorts = "no", className }) {
|
|
14
16
|
const { messages } = useViews();
|
|
15
17
|
const phone = usePartPhone();
|
|
16
18
|
const store = useListStore();
|
|
19
|
+
const person = useList((s) => personBar(s, phone));
|
|
20
|
+
const shows = own !== "button" && person ? (person === "always" ? "always" : "filled") : own;
|
|
17
21
|
const ready = useReadyParts();
|
|
18
22
|
const piece = useContext(ReadyPiece);
|
|
19
23
|
const rooted = useList((s) => s.columns !== null);
|
|
@@ -29,13 +33,15 @@ export function ListFilterBar({ shows = "filled", sorts = "no", className }) {
|
|
|
29
33
|
return;
|
|
30
34
|
const unbar = store.get().place("bar");
|
|
31
35
|
const unplace = store.get().place(FILTER_BAR_KEY);
|
|
32
|
-
const unbutton =
|
|
36
|
+
const unbutton = own === "button" ? store.get().place(FILTER_BAR_BUTTON_KEY) : undefined;
|
|
37
|
+
const unalways = own === "always" ? store.get().place(FILTER_BAR_ALWAYS_KEY) : undefined;
|
|
33
38
|
return () => {
|
|
34
39
|
unbar();
|
|
35
40
|
unplace();
|
|
36
41
|
unbutton?.();
|
|
42
|
+
unalways?.();
|
|
37
43
|
};
|
|
38
|
-
}, [store, drawn,
|
|
44
|
+
}, [store, drawn, own, ready]);
|
|
39
45
|
if (!drawn)
|
|
40
46
|
return null;
|
|
41
47
|
const always = ready ? ready.barAlways : shows !== "filled";
|
|
@@ -10,8 +10,9 @@ export type PanelPlace = {
|
|
|
10
10
|
stands: "alone" | "shown" | null;
|
|
11
11
|
hide: () => void;
|
|
12
12
|
};
|
|
13
|
-
/** A placed panel's place (VK-1092): placed under its key while
|
|
14
|
-
|
|
13
|
+
/** A placed panel's place (VK-1092): placed under its key while it can draw (`can`; on a phone, not behind a button of the
|
|
14
|
+
* same), standing as `shows` and `holds` say, published. */
|
|
15
|
+
export declare function usePanelPlace(name: PartKeyName, shows: ListPanelShows, holds: boolean, can: boolean): PanelPlace;
|
|
15
16
|
/** The region a standing panel draws in: named, focusable so its button can point to it, and, where its body draws no head
|
|
16
17
|
* of its own, the panels' header (its name, ✕ while it stands only by its button). Nothing while it doesn't stand. */
|
|
17
18
|
export declare function PanelFrame({ place, label, head, panel, className, children, }: {
|
|
@@ -4,9 +4,12 @@ import { useLayoutEffect } from "react";
|
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { PanelHeader } from "../../panels/react/panel-header.js";
|
|
6
6
|
import { useList, useListStore } from "../root-base.js";
|
|
7
|
-
import { panelId, usePartKey } from "../buttons/shared.js";
|
|
8
|
-
export function usePanelPlace(name, shows, holds,
|
|
7
|
+
import { panelId, partButtonKey, usePartKey, usePartPhone } from "../buttons/shared.js";
|
|
8
|
+
export function usePanelPlace(name, shows, holds, can) {
|
|
9
9
|
const key = usePartKey(name);
|
|
10
|
+
const phone = usePartPhone();
|
|
11
|
+
const fronted = useList((s) => (s.panels.placed[partButtonKey(name)] ?? 0) > 0);
|
|
12
|
+
const drawn = can && !(phone && fronted);
|
|
10
13
|
const store = useListStore();
|
|
11
14
|
const listId = useList((s) => s.id);
|
|
12
15
|
const shown = useList((s) => !!s.panels.shown[key]);
|
|
@@ -14,7 +14,7 @@ export type ListViewsOptions = {
|
|
|
14
14
|
};
|
|
15
15
|
/** The list root's props: its id, and either its settings and layer as the app holds them (memory mode: what
|
|
16
16
|
* `useListSettingsState` returns, with the shared view), or no settings, and the root keeps them through a store. A
|
|
17
|
-
* root keeps the mode it mounted in. Either way, the toolbar's `sortFilter` and `bar
|
|
17
|
+
* root keeps the mode it mounted in. Either way, the toolbar's `sortFilter` and `bar`, and what the person may set (`personSettings`). */
|
|
18
18
|
export type ListRootModes = ListSync | {
|
|
19
19
|
settings?: undefined;
|
|
20
20
|
/** Where the list's saved views are kept: a store, or options; default `browserViewsStore()`. */
|
|
@@ -28,6 +28,7 @@ export type ListRootModes = ListSync | {
|
|
|
28
28
|
link?: boolean | ListLinkReading;
|
|
29
29
|
sortFilter?: ListSync["sortFilter"];
|
|
30
30
|
bar?: ListSync["bar"];
|
|
31
|
+
personSettings?: ListSync["personSettings"];
|
|
31
32
|
};
|
|
32
33
|
/** The base root's props: its id, its mode, and `share: false` (no "Save for everyone", store mode). Not on the door. */
|
|
33
34
|
export type ListRootBaseProps = {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, createElement, useCallback, useContext, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
|
|
3
3
|
import { LIST_SETTINGS_DEFAULTS, readListLink } from "viewkitjs/fields/query";
|
|
4
|
-
import { ListRadioContext, ToolbarRadioContext, useToolbarRadioState } from "../panels/react/toolbar/context.js";
|
|
4
|
+
import { ListRadioContext, PersonWordsContext, ToolbarRadioContext, useToolbarRadioState } from "../panels/react/toolbar/context.js";
|
|
5
|
+
import { personWords } from "./layer.js";
|
|
5
6
|
import { ListRegistryContext } from "./registry.js";
|
|
6
7
|
import { ViewsContext } from "../provider/context.js";
|
|
7
8
|
import { browserViewsStore } from "./browser-views-store.js";
|
|
@@ -12,7 +13,7 @@ const ListStoreContext = createContext(null);
|
|
|
12
13
|
export const ToolbarModelProvided = createContext(null);
|
|
13
14
|
export function ListRootBase({ id, children, share, ...props }) {
|
|
14
15
|
const mode = useStoreMode(id, props, share);
|
|
15
|
-
const extra = { sortFilter: props.sortFilter, bar: props.bar };
|
|
16
|
+
const extra = { sortFilter: props.sortFilter, bar: props.bar, personSettings: props.personSettings };
|
|
16
17
|
const sync = mode ? mode.views.sync(extra) : props;
|
|
17
18
|
const [store] = useState(() => createListStore(id, sync));
|
|
18
19
|
useListLink(store, !!mode && props.link === true, mode?.defaults ?? LIST_SETTINGS_DEFAULTS);
|
|
@@ -23,9 +24,10 @@ export function ListRootBase({ id, children, share, ...props }) {
|
|
|
23
24
|
const registry = useContext(ListRegistryContext);
|
|
24
25
|
useLayoutEffect(() => registry?.addStore(store.get().id, store), [registry, store]);
|
|
25
26
|
const radio = useToolbarRadioState();
|
|
27
|
+
const words = useSyncExternalStore(store.subscribe, () => personWords(store.get()), () => personWords(store.get()));
|
|
26
28
|
const [box, setBox] = useState(null);
|
|
27
29
|
const paneBox = useMemo(() => ({ box, setBox }), [box]);
|
|
28
|
-
return createElement(ListStoreContext.Provider, { value: store }, createElement(ListRadioContext.Provider, { value: radio }, createElement(ToolbarRadioContext.Provider, { value: radio }, createElement(ListPaneBoxContext.Provider, { value: paneBox }, createElement(ToolbarModelProvided.Provider, { value: null }, children)))));
|
|
30
|
+
return createElement(ListStoreContext.Provider, { value: store }, createElement(ListRadioContext.Provider, { value: radio }, createElement(ToolbarRadioContext.Provider, { value: radio }, createElement(ListPaneBoxContext.Provider, { value: paneBox }, createElement(ToolbarModelProvided.Provider, { value: null }, createElement(PersonWordsContext.Provider, { value: words }, children))))));
|
|
29
31
|
}
|
|
30
32
|
export const RootQuickFilters = createContext(null);
|
|
31
33
|
export function useRootQuickFilters() {
|
|
@@ -33,7 +33,7 @@ export type ListData<Row extends ListRow = ListRow> = {
|
|
|
33
33
|
};
|
|
34
34
|
/** The list root's props: its id, and either its settings and layer as the app holds them (memory mode: what
|
|
35
35
|
* `useListSettingsState` returns, with the shared view), or no settings, and the root keeps them through a store. A
|
|
36
|
-
* root keeps the mode it mounted in. Either way, the toolbar's `sortFilter` and `bar`, and the list's data. */
|
|
36
|
+
* root keeps the mode it mounted in. Either way, the toolbar's `sortFilter` and `bar`, what the person may set (`personSettings`), and the list's data. */
|
|
37
37
|
export type ListRootProps<Row extends ListRow = ListRow> = {
|
|
38
38
|
id: string;
|
|
39
39
|
children?: ReactNode;
|
|
@@ -30,6 +30,10 @@ export type ListState = {
|
|
|
30
30
|
footHere: boolean;
|
|
31
31
|
sortFilter: "right" | "bar";
|
|
32
32
|
bar: "added" | "always";
|
|
33
|
+
/** What the app lets the person set in their own Customize (`personSettings`): when the filter bar stands, the
|
|
34
|
+
* buttons' words. Two flags, so an app's inline object changes nothing while they hold. */
|
|
35
|
+
personBar: boolean;
|
|
36
|
+
personWords: boolean;
|
|
33
37
|
/** What stands under this root, by key, counted (VK-1091): `ListToolbar` places `bar` while it draws a filter bar, so a
|
|
34
38
|
* placed button's `opens="bar"` knows one is there. */
|
|
35
39
|
placed: Readonly<Record<string, number>>;
|
|
@@ -100,6 +104,12 @@ export type ListSync = {
|
|
|
100
104
|
view?: CollectionViewState;
|
|
101
105
|
sortFilter?: "right" | "bar";
|
|
102
106
|
bar?: "added" | "always";
|
|
107
|
+
/** What the person may set in their own Customize, each kept in their layer: `bar`, when the filter bar stands
|
|
108
|
+
* (once added or always); `words`, the toolbar buttons' words (icon and word, icon or word). Off by default. */
|
|
109
|
+
personSettings?: {
|
|
110
|
+
bar?: boolean;
|
|
111
|
+
words?: boolean;
|
|
112
|
+
};
|
|
103
113
|
};
|
|
104
114
|
export type ListStore = {
|
|
105
115
|
get: () => ListState;
|
package/views/dist/list/store.js
CHANGED
|
@@ -103,6 +103,8 @@ export function createListStore(id, props) {
|
|
|
103
103
|
footHere: false,
|
|
104
104
|
sortFilter: props.sortFilter ?? "right",
|
|
105
105
|
bar: props.bar ?? "added",
|
|
106
|
+
personBar: !!props.personSettings?.bar,
|
|
107
|
+
personWords: !!props.personSettings?.words,
|
|
106
108
|
placed: {},
|
|
107
109
|
barOpen: false,
|
|
108
110
|
shown: {},
|
|
@@ -135,7 +137,12 @@ export function createListStore(id, props) {
|
|
|
135
137
|
const view = viewOf(next);
|
|
136
138
|
if (!sameKeys(state.view, view))
|
|
137
139
|
changed.view = view;
|
|
138
|
-
const panels = {
|
|
140
|
+
const panels = {
|
|
141
|
+
sortFilter: next.sortFilter ?? "right",
|
|
142
|
+
bar: next.bar ?? "added",
|
|
143
|
+
personBar: !!next.personSettings?.bar,
|
|
144
|
+
personWords: !!next.personSettings?.words,
|
|
145
|
+
};
|
|
139
146
|
if (!sameKeys(state.panels, panels))
|
|
140
147
|
changed.panels = { ...state.panels, ...panels };
|
|
141
148
|
if (Object.keys(changed).length === 0)
|
|
@@ -75,6 +75,10 @@ type ModelReads = {
|
|
|
75
75
|
answer: ListState["answer"];
|
|
76
76
|
storeViews: CollectionViewsInput<string> | undefined;
|
|
77
77
|
rootQuick: QuickFiltersConfig | null;
|
|
78
|
+
/** What the app lets the person set, and when the bar stands while they picked none. */
|
|
79
|
+
personBar: boolean;
|
|
80
|
+
personWords: boolean;
|
|
81
|
+
barDefault: "added" | "always" | "button";
|
|
78
82
|
messages: ReturnType<typeof useViews>["messages"];
|
|
79
83
|
conventions: ReturnType<typeof useViews>["conventions"];
|
|
80
84
|
};
|
|
@@ -5,6 +5,7 @@ import { settingsCleared } from "../panels/toolbar/clear.js";
|
|
|
5
5
|
import { countsToggle, groupShown, showCountsChange, showCountsOf } from "../panels/toolbar/counts.js";
|
|
6
6
|
import { pageResets } from "../panels/toolbar/page-resets.js";
|
|
7
7
|
import { useViews } from "../provider/context.js";
|
|
8
|
+
import { FILTER_BAR_ALWAYS_KEY, FILTER_BAR_BUTTON_KEY, FILTER_BAR_KEY } from "./bar-keys.js";
|
|
8
9
|
import { EMPTY_LAYER, layerHolds } from "./layer.js";
|
|
9
10
|
import { ToolbarModelProvided, useList, useListStore, useRootQuickFilters } from "./root-base.js";
|
|
10
11
|
import { useListViewsAxis } from "./views-axis.js";
|
|
@@ -67,14 +68,28 @@ function useModelReads(props) {
|
|
|
67
68
|
held: useList((s) => s.panels.held),
|
|
68
69
|
setHeld: useList((s) => s.hold),
|
|
69
70
|
rootQuick: useRootQuickFilters(),
|
|
71
|
+
personBar: useList((s) => s.panels.personBar),
|
|
72
|
+
personWords: useList((s) => s.panels.personWords),
|
|
73
|
+
barDefault: useList(barDefaultOf),
|
|
70
74
|
messages,
|
|
71
75
|
conventions,
|
|
72
76
|
};
|
|
73
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
|
+
}
|
|
74
88
|
const NO_COLUMNS = [];
|
|
75
89
|
function modelOf(reads, props) {
|
|
76
90
|
const { phone } = props;
|
|
77
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 };
|
|
78
93
|
const views = props.views ?? storeViews;
|
|
79
94
|
const show = showCountsOf(settings);
|
|
80
95
|
const setShow = (next) => {
|
|
@@ -96,6 +111,9 @@ function modelOf(reads, props) {
|
|
|
96
111
|
filterGroups: props.filterGroups ?? true,
|
|
97
112
|
resolve: props.resolve ?? messages,
|
|
98
113
|
conventions: props.conventions ?? conventions,
|
|
114
|
+
person,
|
|
115
|
+
phone: !!phone,
|
|
116
|
+
barDefault: reads.barDefault,
|
|
99
117
|
};
|
|
100
118
|
const panels = settingsPanels(input);
|
|
101
119
|
const counts = countsToggle(views, props.toggles, show, setShow, messages);
|
|
@@ -114,7 +132,7 @@ function modelOf(reads, props) {
|
|
|
114
132
|
if (change)
|
|
115
133
|
onChange(change);
|
|
116
134
|
};
|
|
117
|
-
const layered = layerHolds(layer, { phone });
|
|
135
|
+
const layered = layerHolds(layer, { phone, person });
|
|
118
136
|
const resetAll = () => {
|
|
119
137
|
if (shared) {
|
|
120
138
|
if (shared.changes > 0)
|
|
@@ -14,6 +14,7 @@ import { PaneBox, PaneHost } from "../panels/react/toolbar/pane-host.js";
|
|
|
14
14
|
import { MoreViews } from "../panels/react/views-row/more-views.js";
|
|
15
15
|
import { ScreenForms } from "../internal/screen-forms.js";
|
|
16
16
|
import { FILTER_BAR_KEY, filterBarParts } from "./bar-parts.js";
|
|
17
|
+
import { personBar } from "./layer.js";
|
|
17
18
|
import { ListClearSave, SAVE_ITEM } from "./buttons/clear-save.js";
|
|
18
19
|
import { CUSTOMIZE_ITEM, ListCustomize } from "./buttons/customize.js";
|
|
19
20
|
import { FILTER_ITEM, ListAdvancedFilters, ListFilter, barFiltersItem, filterItemKey } from "./buttons/filter.js";
|
|
@@ -45,7 +46,7 @@ function ToolbarDrawn(props) {
|
|
|
45
46
|
const { viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, overflow, moreViews, } = props;
|
|
46
47
|
const store = useListStore();
|
|
47
48
|
const sortFilter = useList((s) => s.panels.sortFilter);
|
|
48
|
-
const bar = useList((s) => s.panels.bar);
|
|
49
|
+
const bar = useList((s) => personBar(s, props.phone) ?? s.panels.bar);
|
|
49
50
|
const barPlaced = useList((s) => (s.panels.placed[FILTER_BAR_KEY] ?? 0) > 0);
|
|
50
51
|
const customizeOwn = {
|
|
51
52
|
...(viewName !== undefined && { viewName }),
|
|
@@ -41,7 +41,7 @@ export type ListViewsState = {
|
|
|
41
41
|
export type ListViewsController = {
|
|
42
42
|
/** The `ListSync` the list store takes: the edited settings, the layer, their handlers and the open view's state,
|
|
43
43
|
* with the app's `sortFilter` and `bar`. */
|
|
44
|
-
sync: (extra: Pick<ListSync, "sortFilter" | "bar">) => ListSync;
|
|
44
|
+
sync: (extra: Pick<ListSync, "sortFilter" | "bar" | "personSettings">) => ListSync;
|
|
45
45
|
/** Reads the store and starts following it (subscribe, `pagehide`); the cleanup stops both, the held deletes' timers
|
|
46
46
|
* too, and flushes them. Called from the root's layout effect. */
|
|
47
47
|
start: () => () => void;
|
package/views/dist/list/views.js
CHANGED
|
@@ -388,7 +388,9 @@ export function createListViews(o) {
|
|
|
388
388
|
synced.layer === layer &&
|
|
389
389
|
synced.view === view &&
|
|
390
390
|
synced.sortFilter === extra.sortFilter &&
|
|
391
|
-
synced.bar === extra.bar
|
|
391
|
+
synced.bar === extra.bar &&
|
|
392
|
+
synced.personSettings?.bar === extra.personSettings?.bar &&
|
|
393
|
+
synced.personSettings?.words === extra.personSettings?.words)
|
|
392
394
|
return synced;
|
|
393
395
|
return (synced = {
|
|
394
396
|
settings: edited,
|
|
@@ -398,6 +400,7 @@ export function createListViews(o) {
|
|
|
398
400
|
...(view && { view }),
|
|
399
401
|
...(extra.sortFilter !== undefined && { sortFilter: extra.sortFilter }),
|
|
400
402
|
...(extra.bar !== undefined && { bar: extra.bar }),
|
|
403
|
+
...(extra.personSettings !== undefined && { personSettings: extra.personSettings }),
|
|
401
404
|
});
|
|
402
405
|
},
|
|
403
406
|
start,
|
|
@@ -22,7 +22,6 @@ export { TOGGLE_LOOKS, type ToggleLookOptionId } from "../controls/toggle/looks.
|
|
|
22
22
|
export { OPTION_LOOKS, optionColours, type OptionColour, type OptionLookOptionId } from "../controls/option/looks.js";
|
|
23
23
|
export { STATUS_LOOKS, type StatusLookOptionId } from "../controls/status/looks.js";
|
|
24
24
|
export { SWITCH_LOOKS, type SwitchLookOptionId } from "../controls/switch/looks.js";
|
|
25
|
-
export { SETTING_ROW_LOOKS, type SettingRowOptionId, type SettingRowPicks } from "../controls/setting-row/looks.js";
|
|
26
25
|
export { TAG_LOOKS, type TagLookOptionId } from "../controls/tag/looks.js";
|
|
27
26
|
export { MENU_LIST_LOOKS, type MenuListLookOptionId } from "../controls/menu-list/looks.js";
|
|
28
27
|
export { LIST_LOOKS, type ListOptionId } from "../controls/list/looks.js";
|
|
@@ -18,7 +18,6 @@ export { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
|
18
18
|
export { OPTION_LOOKS, optionColours } from "../controls/option/looks.js";
|
|
19
19
|
export { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
20
20
|
export { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
21
|
-
export { SETTING_ROW_LOOKS } from "../controls/setting-row/looks.js";
|
|
22
21
|
export { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
23
22
|
export { MENU_LIST_LOOKS } from "../controls/menu-list/looks.js";
|
|
24
23
|
export { LIST_LOOKS } from "../controls/list/looks.js";
|
|
@@ -28,7 +28,7 @@ export type Look<Id extends string = string, Picked extends Id = Id> = {
|
|
|
28
28
|
readonly device?: LookDevice;
|
|
29
29
|
readonly picks: Readonly<Record<Picked, string>>;
|
|
30
30
|
};
|
|
31
|
-
/** A piece's options and looks. Nothing picked wears each option's default (`def`),
|
|
31
|
+
/** A piece's options and looks. Nothing picked wears each option's default (`def`), ViewKit's own, which no look need
|
|
32
32
|
* match whole. */
|
|
33
33
|
export type PieceLooks<Id extends string = string, Picked extends Id = Id> = {
|
|
34
34
|
readonly id: string;
|
|
@@ -15,7 +15,6 @@ import { TOGGLE_LOOKS } from "../controls/toggle/looks.js";
|
|
|
15
15
|
import { OPTION_LOOKS } from "../controls/option/looks.js";
|
|
16
16
|
import { STATUS_LOOKS } from "../controls/status/looks.js";
|
|
17
17
|
import { SWITCH_LOOKS } from "../controls/switch/looks.js";
|
|
18
|
-
import { SETTING_ROW_LOOKS } from "../controls/setting-row/looks.js";
|
|
19
18
|
import { TAG_LOOKS } from "../controls/tag/looks.js";
|
|
20
19
|
import { MENU_LIST_LOOKS } from "../controls/menu-list/looks.js";
|
|
21
20
|
import { AVATAR_LOOKS } from "../controls/avatar/looks.js";
|
|
@@ -56,7 +55,6 @@ export const LOOKS = [
|
|
|
56
55
|
TAG_LOOKS,
|
|
57
56
|
STATUS_LOOKS,
|
|
58
57
|
SWITCH_LOOKS,
|
|
59
|
-
SETTING_ROW_LOOKS,
|
|
60
58
|
MENU_LIST_LOOKS,
|
|
61
59
|
LIST_LOOKS,
|
|
62
60
|
PICKER_LOOKS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { actorKey, COUNTRY_CODES, countryName, isIntegerField, isMultipleType, isOpenVocabulary, presentedDef, relationKey, scalarOf, storesDecimalText, valueItems, valueTypeOf, } from "viewkitjs/fields";
|
|
2
|
-
import { matchesRule, operatorsFor, ruleDecimalsOf } from "viewkitjs/fields/query";
|
|
1
|
+
import { actorKey, COUNTRY_CODES, countryName, DEFAULT_CONVENTIONS, isIntegerField, isMultipleType, isOpenVocabulary, presentedDef, relationKey, scalarOf, storesDecimalText, valueItems, valueTypeOf, } from "viewkitjs/fields";
|
|
2
|
+
import { matchesRule, operatorsFor, refusesNumberRule, ruleDecimalsOf } from "viewkitjs/fields/query";
|
|
3
3
|
import { resolveViewsMessage } from "../contract.js";
|
|
4
4
|
import { rangeUnit } from "../fields/range-unit.js";
|
|
5
5
|
import { FILTER_PART_ROWS, parsePartKey, partKey, partLabel } from "./part-rows.js";
|
|
@@ -124,6 +124,9 @@ export function buildColumnFilters({ columns, order, declared = [], icon, rules
|
|
|
124
124
|
...(col.format?.style === "duration"
|
|
125
125
|
? { numberStyle: "duration", durationUnit: col.format.unit ?? "ms" }
|
|
126
126
|
: {}),
|
|
127
|
+
...(refusesMixedNumbers(col)
|
|
128
|
+
? { refused: (conventions ?? DEFAULT_CONVENTIONS).messages({ key: "filter.mixed-currency" }) }
|
|
129
|
+
: {}),
|
|
127
130
|
onChange: (next) => onRuleChange?.(col.id, next ? { editor: "number", ...next } : null),
|
|
128
131
|
};
|
|
129
132
|
}
|
|
@@ -300,6 +303,9 @@ function partRuleMatches(row, key, rule, columns, decimals, conventions) {
|
|
|
300
303
|
const shown = type === "range" ? { decimals: rangeEndDecimals(col.field, key, decimals) } : {};
|
|
301
304
|
return !filterRule || matchesRule(type, col.accessor(row), filterRule, { ...shown, conventions });
|
|
302
305
|
}
|
|
306
|
+
function refusesMixedNumbers(col) {
|
|
307
|
+
return !!col.field && refusesNumberRule(col.field, "gt", !!col.surfaceOwnsCurrency);
|
|
308
|
+
}
|
|
303
309
|
export function rowMatchesRules(row, rules, columns, decimals, conventions) {
|
|
304
310
|
const ids = Object.keys(rules);
|
|
305
311
|
if (ids.length === 0)
|
|
@@ -325,7 +331,8 @@ export function rowMatchesRules(row, rules, columns, decimals, conventions) {
|
|
|
325
331
|
if (rule.editor === "options" && !matchesOptionsRule(value, rule.values))
|
|
326
332
|
return false;
|
|
327
333
|
const exact = !!col.field && storesDecimalText(col.field);
|
|
328
|
-
|
|
334
|
+
const refused = rule.editor === "number" && !!col.field && refusesNumberRule(col.field, rule.operator, !!col.surfaceOwnsCurrency);
|
|
335
|
+
if (rule.editor === "number" && !refused && !matchesNumberRule(value, rule, numberDecimals(col, decimals), exact))
|
|
329
336
|
return false;
|
|
330
337
|
if (rule.editor === "range" && !matchesRangeRule(value, rule))
|
|
331
338
|
return false;
|
|
@@ -297,5 +297,6 @@ export function viewReaderFrom(columns, decimals = {}) {
|
|
|
297
297
|
},
|
|
298
298
|
codeOf: (row, key) => denominationOf(byKey.get(key), row),
|
|
299
299
|
sortAmountOf: (row, key) => byKey.get(key)?.sortAccessor?.(row),
|
|
300
|
+
oneCurrency: (key) => !!byKey.get(key)?.surfaceOwnsCurrency,
|
|
300
301
|
};
|
|
301
302
|
}
|
|
@@ -5,13 +5,14 @@ import { cx } from "../../internal/cx.js";
|
|
|
5
5
|
import { useIdleWrite } from "../../internal/use-idle-write.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { FIELD_PADDING } from "./TextFilterBody.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { DEFAULT_NUMBER_FILTER_RULE, NUMBER_FILTER_OPERATORS, numberFilterOperatorLabel, numberFilterInputs, parseNumber, } from "viewkitjs/fields/query";
|
|
9
|
+
import { numberRuleRefused } from "../../filters/number-refused.js";
|
|
10
|
+
import { durationBound, durationDraft } from "../../filters/duration-bound.js";
|
|
10
11
|
const asDraft = (value, style, unit, cv) => {
|
|
11
12
|
if (value == null)
|
|
12
13
|
return "";
|
|
13
14
|
if (style === "duration")
|
|
14
|
-
return
|
|
15
|
+
return durationDraft(value, unit);
|
|
15
16
|
return cv.decimal === "," ? String(value).replace(".", ",") : String(value);
|
|
16
17
|
};
|
|
17
18
|
export function NumberFilterBody({ filter, rowClassName, rowBorderClassName, labelClassName, checkClassName, fieldClassName, wrapRows, autoFocus = false, }) {
|
|
@@ -20,10 +21,7 @@ export function NumberFilterBody({ filter, rowClassName, rowBorderClassName, lab
|
|
|
20
21
|
const rule = filter.value ?? DEFAULT_NUMBER_FILTER_RULE;
|
|
21
22
|
const inputs = numberFilterInputs(rule.operator);
|
|
22
23
|
const parse = (raw) => {
|
|
23
|
-
|
|
24
|
-
return parseNumber(raw, conventions);
|
|
25
|
-
const ms = parseDurationInput(raw, conventions);
|
|
26
|
-
return ms == null ? null : msToDurationUnit(ms, filter.durationUnit);
|
|
24
|
+
return filter.numberStyle === "duration" ? durationBound(raw, filter.durationUnit, conventions) : parseNumber(raw, conventions);
|
|
27
25
|
};
|
|
28
26
|
const draftOf = (value) => asDraft(value, filter.numberStyle, filter.durationUnit, conventions);
|
|
29
27
|
const [draft, setDraft] = useState(draftOf(rule.value));
|
|
@@ -71,5 +69,5 @@ export function NumberFilterBody({ filter, rowClassName, rowBorderClassName, lab
|
|
|
71
69
|
setDraft2(b);
|
|
72
70
|
commit(a, b, op.value);
|
|
73
71
|
}, className: cx(rowClassName, index > 0 && rowBorderClassName), labelClassName: labelClassName, checkClassName: checkClassName }, op.value)));
|
|
74
|
-
return (_jsxs(_Fragment, { children: [inputs > 0 && (_jsxs("div", { "data-vs-inset": true, className: cx("flex items-center gap-2", fieldClassName ?? FIELD_PADDING), children: [_jsx("div", { className: "min-w-0 flex-1", children: box(draft, setDraft, messages({ key: inputs === 2 ? "views.panels.bound-from" : "views.panels.bound-value" }), autoFocus) }), inputs === 2 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx("div", { className: "min-w-0 flex-1", children: box(draft2, setDraft2, messages({ key: "views.panels.bound-to" }), false) })] }))] })), wrapRows ? wrapRows(rows) : rows] }));
|
|
72
|
+
return (_jsxs(_Fragment, { children: [inputs > 0 && (_jsxs("div", { "data-vs-inset": true, className: cx("flex items-center gap-2", fieldClassName ?? FIELD_PADDING), children: [_jsx("div", { className: "min-w-0 flex-1", children: box(draft, setDraft, messages({ key: inputs === 2 ? "views.panels.bound-from" : "views.panels.bound-value" }), autoFocus) }), inputs === 2 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: "\u2013" }), _jsx("div", { className: "min-w-0 flex-1", children: box(draft2, setDraft2, messages({ key: "views.panels.bound-to" }), false) })] }))] })), numberRuleRefused({ refused: filter.refused, value: rule }) && (_jsx("p", { role: "note", "data-slot": "vk-filter-refused", className: cx("text-xs text-(color:--vk-fg-subtle)", fieldClassName ?? FIELD_PADDING), children: filter.refused })), wrapRows ? wrapRows(rows) : rows] }));
|
|
75
73
|
}
|
|
@@ -2,6 +2,7 @@ import { groupOrderFor, } from "./model.js";
|
|
|
2
2
|
import { isDateFilter, isNumberFilter, isRangeFilter, isRelationFilter, isTextFilter, isUnavailableFilter, isFilterActive, } from "../filters/filter-model.js";
|
|
3
3
|
import { dateRuleLabel, numberRuleLabel, rangeRuleLabel, textRuleLabel } from "viewkitjs/fields/query";
|
|
4
4
|
import { groupSortChoices, groupSortValue } from "./group-sort.js";
|
|
5
|
+
import { numberRuleRefused } from "../filters/number-refused.js";
|
|
5
6
|
import { DEFAULT_CONVENTIONS } from "viewkitjs/fields";
|
|
6
7
|
import { resolveViewsMessage } from "../contract.js";
|
|
7
8
|
function heldWhere(filter) {
|
|
@@ -62,8 +63,12 @@ export function filterValueLabel(filter, cv, messages = resolveViewsMessage) {
|
|
|
62
63
|
}
|
|
63
64
|
if (isTextFilter(filter))
|
|
64
65
|
return textRuleLabel(filter.value, cv);
|
|
65
|
-
if (isNumberFilter(filter))
|
|
66
|
-
|
|
66
|
+
if (isNumberFilter(filter)) {
|
|
67
|
+
if (numberRuleRefused(filter))
|
|
68
|
+
return filter.refused;
|
|
69
|
+
const duration = filter.numberStyle === "duration" ? (filter.durationUnit ?? "ms") : undefined;
|
|
70
|
+
return numberRuleLabel(filter.value, filter.decimals, filter.unit, cv, duration);
|
|
71
|
+
}
|
|
67
72
|
if (isRangeFilter(filter))
|
|
68
73
|
return rangeRuleLabel(filter.value, cv);
|
|
69
74
|
if (isDateFilter(filter))
|
|
@@ -81,6 +81,9 @@ export type FilterEditorField = {
|
|
|
81
81
|
mark?: FieldMark;
|
|
82
82
|
/** A number field that holds whole numbers only (`isIntegerField`): its box takes whole numbers. */
|
|
83
83
|
integer?: true;
|
|
84
|
+
/** A number kept as a duration, in this unit (its column's `format.unit`, `ms` unless it says `s`): its box reads and writes
|
|
85
|
+
* a duration (`1m 30s`, a bare number in seconds), VK-1121. */
|
|
86
|
+
duration?: "ms" | "s";
|
|
84
87
|
/** Why no rule can be made on it, in the app's words (an unavailable capability's reason, else
|
|
85
88
|
* `views.panels.filter-not-offered`); absent, it can. Only in `FilterTreeConfig.listed`: a field list draws it greyed. */
|
|
86
89
|
disabled?: string;
|
|
@@ -7,6 +7,8 @@ import { useViews } from "../../../provider/context.js";
|
|
|
7
7
|
import { useEditorMenus } from "../toolbar/editor-menus.js";
|
|
8
8
|
import { filterBodyChangeFits, listedFieldsOf, takesValue } from "../../settings/filter-groups.js";
|
|
9
9
|
import { asideFilterWords, barFilterWords } from "../../toolbar/filter-words.js";
|
|
10
|
+
import { isNumberFilter } from "../../../filters/filter-model.js";
|
|
11
|
+
import { numberRuleRefused } from "../../../filters/number-refused.js";
|
|
10
12
|
import { relationOf } from "./editor-ctx.js";
|
|
11
13
|
import { FilterValueBody } from "./FilterValueBody.js";
|
|
12
14
|
const QUANTIFIERS = ["any", "none", "every"];
|
|
@@ -73,7 +75,9 @@ export function AppFilterBody({ ctx, level, relation, excludable, label, onDone,
|
|
|
73
75
|
const ruleWords = (rule, at) => {
|
|
74
76
|
const node = at !== undefined ? { fieldKey: at, quantifier: "any", where: { op: "and", items: [rule] } } : rule;
|
|
75
77
|
const words = rule.setAside ? asideFilterWords(rule, ctx.filterTree, conventions, messages, at) : barFilterWords({ kind: "held", node }, ctx.filterTree, conventions, messages);
|
|
76
|
-
|
|
78
|
+
const config = rule.setAside ? null : ctx.filterTree.valueOf(rule, () => { }, at);
|
|
79
|
+
const refused = config && isNumberFilter(config) && numberRuleRefused(config) ? config.refused : undefined;
|
|
80
|
+
return { field: words.field, way: words.way, value: words.value, ...(refused !== undefined && { refused }) };
|
|
77
81
|
};
|
|
78
82
|
return (_jsx(FilterBody, { label: label, fields: fields, filter: level, levels: levels, excludable: excludable, relation: relation
|
|
79
83
|
? {
|
|
@@ -5,10 +5,12 @@ import { useViews } from "../../../provider/context.js";
|
|
|
5
5
|
import { addSortRule, canAddSortRule, openSortPlaces } from "../../settings/sorts.js";
|
|
6
6
|
import { SortFieldList } from "../sort/SortFieldList.js";
|
|
7
7
|
import { useToolbarPanel } from "./context.js";
|
|
8
|
+
import { useEditorMenus } from "./editor-menus.js";
|
|
8
9
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
9
10
|
export function ToolbarBarSorts({ sorts, open: openIn, onOpenChange: onOpenChangeIn, }) {
|
|
10
11
|
const { components, icons, messages } = useViews();
|
|
11
12
|
const { Popover } = components;
|
|
13
|
+
const shape = useEditorMenus().sort;
|
|
12
14
|
const panel = useToolbarPanel("bar-sorts", { open: openIn, onOpenChange: onOpenChangeIn });
|
|
13
15
|
const [held, setHeld] = useState(null);
|
|
14
16
|
const at = held?.at ?? null;
|
|
@@ -43,10 +45,35 @@ export function ToolbarBarSorts({ sorts, open: openIn, onOpenChange: onOpenChang
|
|
|
43
45
|
}
|
|
44
46
|
close();
|
|
45
47
|
};
|
|
48
|
+
const endOf = (rule, i, label) => {
|
|
49
|
+
const remove = { key: "delete", label: messages({ key: "views.panels.sort-remove", values: { label } }), icon: _jsx(Close, { className: "h-3.5 w-3.5 shrink-0" }) };
|
|
50
|
+
if (!shape)
|
|
51
|
+
return [remove];
|
|
52
|
+
const handed = shape([remove], { menu: "row", field: rule.value, index: i, form: "computer", place: "bar" });
|
|
53
|
+
const keys = new Set();
|
|
54
|
+
return handed.filter((item) => {
|
|
55
|
+
if (item.children !== undefined || item.checked !== undefined || item.key === "more" || keys.has(item.key))
|
|
56
|
+
return false;
|
|
57
|
+
keys.add(item.key);
|
|
58
|
+
return true;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
46
61
|
return (_jsxs(_Fragment, { children: [sorts.rules.map((rule, i) => {
|
|
47
62
|
const label = labelOf(rule.value);
|
|
48
63
|
const direction = messages({ key: rule.dir === "asc" ? "views.panels.sort-ascending" : "views.panels.sort-descending" });
|
|
49
|
-
|
|
64
|
+
const ends = endOf(rule, i, label);
|
|
65
|
+
return (_jsxs("span", { "data-slot": "vk-bar-sort", "data-rule": i, role: "group", "aria-label": label, className: "relative inline-flex min-w-0 shrink-0 items-center", children: [_jsx(ToolbarButton, { part: "sort-pill", icon: null, label: messages({ key: "views.panels.sort-field-named", values: { label } }), joined: "start", popup: "dialog", open: shown === i, onClick: (event) => openAt(i, event.currentTarget), children: label }), _jsx(ToolbarButton, { part: "sort-pill", icon: null, label: messages({ key: "views.panels.sort-direction-named", values: { label: direction } }), joined: ends.length > 0 ? "middle" : "end", onClick: () => write(sorts.rules.map((held, k) => (k === i ? { ...held, dir: held.dir === "asc" ? "desc" : "asc" } : held))), children: direction }), ends.map((item, k) => {
|
|
66
|
+
const own = item.key === "delete";
|
|
67
|
+
const icon = item.icon !== undefined ? item.icon : null;
|
|
68
|
+
return (_jsx(ToolbarButton, { part: "sort-pill", icon: icon, label: item.label, joined: k === ends.length - 1 ? "end" : "middle", ...(icon !== null && { iconAlone: true }), ...(item.disabled && { disabled: true, disabledReason: item.disabledReason || item.label }), onClick: () => {
|
|
69
|
+
if (item.disabled)
|
|
70
|
+
return;
|
|
71
|
+
if (own)
|
|
72
|
+
write(sorts.rules.filter((_, k) => k !== i));
|
|
73
|
+
else
|
|
74
|
+
item.onSelect?.();
|
|
75
|
+
}, children: icon === null ? item.label : undefined }, item.key));
|
|
76
|
+
})] }, `${rule.value}-${i}`));
|
|
50
77
|
}), _jsx("span", { "data-slot": "vk-bar-sort-add", className: "inline-flex", children: _jsx(ToolbarButton, { part: "sort-add", icon: _jsx(Plus, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.sort-add" }), ...(sorts.rules.length > 0 && { word: null }), popup: "dialog", open: shown === "add", disabled: !can, onClick: (event) => {
|
|
51
78
|
if (can)
|
|
52
79
|
openAt("add", event.currentTarget);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
3
|
export declare function ToolbarButton({ size, ...props }: Omit<ViewsToolbarButtonProps, "size"> & {
|
|
4
4
|
size?: "md" | "sm";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import { cx } from "../../../internal/cx.js";
|
|
4
5
|
import { useViews } from "../../../provider/context.js";
|
|
5
|
-
import { useToolbarSlot } from "./context.js";
|
|
6
|
+
import { PersonWordsContext, useToolbarSlot } from "./context.js";
|
|
6
7
|
export function ToolbarButton({ size, ...props }) {
|
|
7
8
|
const { atoms } = useViews();
|
|
8
9
|
const slot = useToolbarSlot();
|
|
9
|
-
const
|
|
10
|
+
const words = useContext(PersonWordsContext) ?? slot.words;
|
|
11
|
+
const iconOnly = words === "icon" && props.icon != null;
|
|
10
12
|
const hasWords = props.word !== null || props.children != null;
|
|
11
|
-
const wordOnly =
|
|
13
|
+
const wordOnly = words === "word" && hasWords && !props.foot;
|
|
12
14
|
const alone = !wordOnly && (slot.iconAlone || (iconOnly && hasWords));
|
|
13
15
|
const Button = slot.button ?? atoms.ToolbarButton;
|
|
14
16
|
const className = cx(slot.className, props.className) || undefined;
|
|
@@ -2,6 +2,10 @@ import { type ReactNode, type RefObject, type ComponentType } from "react";
|
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
3
|
import type { ViewsAlign, ViewsSide } from "../../../provider/components.js";
|
|
4
4
|
import type { ToolbarForm, ToolbarLine } from "../../toolbar/model.js";
|
|
5
|
+
/** The toolbar buttons' words a person picked in their own Customize, where the app lets them: over each button's
|
|
6
|
+
* own placement (`ToolbarSlotState.words`), `both` its icon and word, `icon` its icon alone, `word` its word alone. Undefined,
|
|
7
|
+
* each button as placed. A list root provides it (not on the door). */
|
|
8
|
+
export declare const PersonWordsContext: import("react").Context<"icon" | "word" | "both" | undefined>;
|
|
5
9
|
/** Where a part stands: the toolbar's form, whether it fills its line, its buttons' size, and its line's kind.
|
|
6
10
|
* In the fold arrangement (`fold`), also how far its line gave way: whether its words turned to its icon
|
|
7
11
|
* (`iconAlone`), how many of its view tabs folded into "+N" (`tabsFolded`), how many of its filters folded into
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, createElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
4
|
+
export const PersonWordsContext = createContext(undefined);
|
|
4
5
|
export function usePanelPlace(own) {
|
|
5
6
|
const { side, panel } = useToolbarSlot();
|
|
6
7
|
return { ...(panel?.side && { side: panel.side }), align: panel?.align ?? side ?? own, sideOffset: panel?.offset ?? 8 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { beforePaint } from "../../../internal/before-paint.js";
|
|
4
4
|
const HOLDING = [
|
|
5
5
|
'[data-slot="vk-toolbar-overflow"] [aria-expanded="true"]',
|
|
6
6
|
'[data-slot="vk-views-more"][aria-expanded="true"]',
|
|
@@ -60,7 +60,7 @@ export function useGiveWayLook(line, max, on) {
|
|
|
60
60
|
useEffect(() => {
|
|
61
61
|
if (!line || !on)
|
|
62
62
|
return;
|
|
63
|
-
const again = () =>
|
|
63
|
+
const again = () => beforePaint(() => look(latest.current.stage, latest.current.max));
|
|
64
64
|
let width = -1;
|
|
65
65
|
const sized = new ResizeObserver((entries) => {
|
|
66
66
|
const w = entries?.[0]?.contentRect.width;
|