viewkitjs 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +129 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +5 -1
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +3 -3
- package/views/dist/controls/avatar/avatar.js +1 -1
- package/views/dist/controls/avatar/tokens.d.ts +44 -0
- package/views/dist/controls/avatar/tokens.js +11 -0
- package/views/dist/controls/avatar.css +22 -5
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +2 -1
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.js +5 -2
- package/views/dist/controls/input/tokens.d.ts +4 -0
- package/views/dist/controls/input/tokens.js +1 -0
- package/views/dist/controls/input.css +31 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +5 -3
- package/views/dist/controls/radio/radio.js +18 -2
- package/views/dist/controls/radio/tokens.d.ts +44 -0
- package/views/dist/controls/radio/tokens.js +11 -0
- package/views/dist/controls/radio.css +79 -1
- package/views/dist/controls/select/select.d.ts +4 -0
- package/views/dist/controls/select/select.js +11 -5
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +1 -1
- package/views/dist/controls/setting-row/looks.js +9 -4
- package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
- package/views/dist/controls/setting-row/setting-row.js +82 -15
- package/views/dist/controls/setting-row/tokens.d.ts +74 -2
- package/views/dist/controls/setting-row/tokens.js +19 -1
- package/views/dist/controls/setting-row.css +135 -14
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +418 -59
- package/views/dist/styles.unlayered.css +418 -59
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +11 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +1 -0
- package/views/docs/controls/radio.md +16 -1
- package/views/docs/controls/select.md +2 -0
- package/views/docs/controls/setting-row.md +18 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +35 -25
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export type ListSlotProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
};
|
|
6
|
+
export type ListFillProps = {
|
|
7
|
+
name: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
/** Where the fills of this name draw: a `div` (`data-slot="vk-list-slot"`, `data-name`). One slot per name under a
|
|
11
|
+
* provider: a later one takes the fills from an earlier. */
|
|
12
|
+
export declare function ListSlot({ name, className }: ListSlotProps): ReactNode;
|
|
13
|
+
/** What it holds, drawn in the `ListSlot` of its name; nothing while none stands. */
|
|
14
|
+
export declare function ListFill({ name, children }: ListFillProps): ReactNode;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useContext, useSyncExternalStore } from "react";
|
|
4
|
+
import { createPortal } from "react-dom";
|
|
5
|
+
import { ListRegistryContext } from "./registry.js";
|
|
6
|
+
function useRegistry(part) {
|
|
7
|
+
const registry = useContext(ListRegistryContext);
|
|
8
|
+
if (!registry)
|
|
9
|
+
throw new Error(`${part} needs a ViewsProvider around it`);
|
|
10
|
+
return registry;
|
|
11
|
+
}
|
|
12
|
+
export function ListSlot({ name, className }) {
|
|
13
|
+
const registry = useRegistry("ListSlot");
|
|
14
|
+
const ref = useCallback((element) => (element ? registry.addSlot(name, element) : undefined), [registry, name]);
|
|
15
|
+
return _jsx("div", { ref: ref, "data-slot": "vk-list-slot", "data-name": name, className: className });
|
|
16
|
+
}
|
|
17
|
+
export function ListFill({ name, children }) {
|
|
18
|
+
const registry = useRegistry("ListFill");
|
|
19
|
+
const read = () => registry.slot(name) ?? null;
|
|
20
|
+
const element = useSyncExternalStore(registry.subscribe, read, () => null);
|
|
21
|
+
return element ? createPortal(children, element) : null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ListAnswer, type ListRequest, type ListRow } from "viewkitjs/fields/query";
|
|
2
|
+
/** Where a list's rows come from: one request in, its answer out. A refusal is an answer (`isRefused`), never a
|
|
3
|
+
* throw; a throw is a failure the list can only report. One argument, so a server action is a source as it stands. */
|
|
4
|
+
export type ListSource<Row extends ListRow = ListRow> = (request: ListRequest) => Promise<ListAnswer<Row>>;
|
|
5
|
+
/**
|
|
6
|
+
* A source that POSTs each request as JSON to `url` and reads the answer. `init` is handed to `fetch` (its headers
|
|
7
|
+
* kept, `content-type` set to JSON). A 2xx answer, or a 400 holding a refusal, is checked with `listAnswerSchema` and
|
|
8
|
+
* `answerFor` and handed back; any other status throws, naming it, as does an answer that is no list answer or an
|
|
9
|
+
* answer to another part.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fetchSource<Row extends ListRow = ListRow>(url: string | URL, init?: Omit<RequestInit, "method" | "body">): ListSource<Row>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { answerFor, listAnswerSchema } from "viewkitjs/fields/query";
|
|
2
|
+
export function fetchSource(url, init) {
|
|
3
|
+
const at = `the list source at ${String(url)}`;
|
|
4
|
+
return async (request) => {
|
|
5
|
+
const headers = new Headers(init?.headers);
|
|
6
|
+
headers.set("content-type", "application/json");
|
|
7
|
+
if (!headers.has("accept"))
|
|
8
|
+
headers.set("accept", "application/json");
|
|
9
|
+
const response = await fetch(url, { ...init, method: "POST", headers, body: JSON.stringify(request) });
|
|
10
|
+
if (!response.ok && response.status !== 400)
|
|
11
|
+
throw new Error(`${at} answered ${response.status}`);
|
|
12
|
+
let body;
|
|
13
|
+
try {
|
|
14
|
+
body = await response.json();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw new Error(`${at} answered ${response.status} with no JSON`);
|
|
18
|
+
}
|
|
19
|
+
const read = listAnswerSchema.safeParse(body);
|
|
20
|
+
if (!read.success)
|
|
21
|
+
throw new Error(`${at} answered no list answer: ${read.error.issues[0]?.message ?? "unreadable"}`);
|
|
22
|
+
if (!response.ok && !("refused" in read.data))
|
|
23
|
+
throw new Error(`${at} answered ${response.status}`);
|
|
24
|
+
try {
|
|
25
|
+
return answerFor(request, read.data);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new Error(`${at} ${error.message}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ListPersonalLayer, ListSettings, ListSettingsChange } from "viewkitjs/fields/query";
|
|
2
|
+
import type { ActivePanel } from "../panels/model.js";
|
|
3
|
+
import type { Pending } from "../panels/react/filter/editor-ctx.js";
|
|
4
|
+
import type { CollectionViewState } from "../panels/view-state.js";
|
|
5
|
+
import type { ListViewsState } from "./views.js";
|
|
6
|
+
/** One list's state, as a part selects it (`useList((s) => …)`). */
|
|
7
|
+
export type ListState = {
|
|
8
|
+
/** The list's id (`ListRoot`'s). */
|
|
9
|
+
id: string;
|
|
10
|
+
/** The settings as the person edits them, their own layer over them, and the shared view this list shows (null:
|
|
11
|
+
* none). */
|
|
12
|
+
view: {
|
|
13
|
+
settings: ListSettings;
|
|
14
|
+
layer: ListPersonalLayer;
|
|
15
|
+
shared: CollectionViewState | null;
|
|
16
|
+
};
|
|
17
|
+
panels: {
|
|
18
|
+
/** The one panel open in this list, by its key; null, none. */
|
|
19
|
+
open: string | null;
|
|
20
|
+
/** The page each panel stands on, by its key: the open one's, or one set for a panel about to open. */
|
|
21
|
+
pages: Readonly<Record<string, ActivePanel>>;
|
|
22
|
+
/** The filter rule held until whole, shared by Filter on the row and the filter bar. */
|
|
23
|
+
held: Pending | null;
|
|
24
|
+
/** The filter bar shows (the toolbar says, as it draws). */
|
|
25
|
+
barShown: boolean;
|
|
26
|
+
/** Clear and Save stand in Customize's foot, not at the bar's end (the toolbar says, as it draws). */
|
|
27
|
+
footHere: boolean;
|
|
28
|
+
sortFilter: "right" | "bar";
|
|
29
|
+
bar: "added" | "always";
|
|
30
|
+
};
|
|
31
|
+
/** The picked rows: their ids, or every matching row (`all`), and how many (null: every matching row, before the
|
|
32
|
+
* list knows its total). */
|
|
33
|
+
selection: {
|
|
34
|
+
ids: readonly string[];
|
|
35
|
+
all: boolean;
|
|
36
|
+
count: number | null;
|
|
37
|
+
};
|
|
38
|
+
/** The list's saved views where the root keeps them through a store (VK-196); null in memory mode. */
|
|
39
|
+
views: ListViewsState | null;
|
|
40
|
+
/** A change to the settings, handed to the app. */
|
|
41
|
+
setSettings: (change: ListSettingsChange) => void;
|
|
42
|
+
/** A patch to the person's layer, handed to the app. */
|
|
43
|
+
setLayer: (patch: ListPersonalLayer) => void;
|
|
44
|
+
/** Opens a panel and closes any other; on `page` where handed, else on the page it holds. */
|
|
45
|
+
openPanel: (key: string, page?: ActivePanel) => void;
|
|
46
|
+
/** Closes a panel, if it is the one open; its page, or a page waiting for it, is forgotten. */
|
|
47
|
+
closePanel: (key: string) => void;
|
|
48
|
+
/** A panel's page: the open one's, or kept for a panel until another opens. */
|
|
49
|
+
setPage: (key: string, page: ActivePanel) => void;
|
|
50
|
+
hold: (held: Pending | null) => void;
|
|
51
|
+
/** Picks these rows, or every matching row (`"all"`); `[]` picks none. */
|
|
52
|
+
select: (ids: readonly string[] | "all") => void;
|
|
53
|
+
/** The shared view's Save for everyone; nothing without a shared view. */
|
|
54
|
+
saveView: () => void;
|
|
55
|
+
/** The shared view's Reset; nothing without a shared view. */
|
|
56
|
+
resetView: () => void;
|
|
57
|
+
/** Takes back the list's last edit; nothing until the list holds edits. */
|
|
58
|
+
undo: () => void;
|
|
59
|
+
};
|
|
60
|
+
/** What the app hands the root: synced in on every render. */
|
|
61
|
+
export type ListSync = {
|
|
62
|
+
settings: ListSettings;
|
|
63
|
+
layer: ListPersonalLayer;
|
|
64
|
+
onChange: (change: ListSettingsChange) => void;
|
|
65
|
+
onLayerChange: (patch: ListPersonalLayer) => void;
|
|
66
|
+
view?: CollectionViewState;
|
|
67
|
+
sortFilter?: "right" | "bar";
|
|
68
|
+
bar?: "added" | "always";
|
|
69
|
+
};
|
|
70
|
+
export type ListStore = {
|
|
71
|
+
get: () => ListState;
|
|
72
|
+
subscribe: (listener: () => void) => () => void;
|
|
73
|
+
/** Takes the app's latest props without telling anyone; `flush` tells. */
|
|
74
|
+
sync: (props: ListSync) => void;
|
|
75
|
+
flush: () => void;
|
|
76
|
+
/** The toolbar's published bar (`barShown`, `footHere`), and the root's saved views. The ready List widens it with its
|
|
77
|
+
* answer and edits. */
|
|
78
|
+
patch: (patch: {
|
|
79
|
+
panels?: Partial<Pick<ListState["panels"], "barShown" | "footHere">>;
|
|
80
|
+
views?: ListViewsState | null;
|
|
81
|
+
}) => void;
|
|
82
|
+
/** The ready List wires its edits' undo here. */
|
|
83
|
+
wire: (handlers: {
|
|
84
|
+
undo?: () => void;
|
|
85
|
+
}) => void;
|
|
86
|
+
};
|
|
87
|
+
export declare function createListStore(id: string, props: ListSync): ListStore;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const sameKeys = (a, b) => Object.keys(b).every((key) => Object.is(a[key], b[key]));
|
|
2
|
+
const sameIds = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
|
|
3
|
+
export function createListStore(id, props) {
|
|
4
|
+
let latest = props;
|
|
5
|
+
let wired = {};
|
|
6
|
+
const listeners = new Set();
|
|
7
|
+
let dirty = false;
|
|
8
|
+
const viewOf = (from) => ({
|
|
9
|
+
settings: from.settings,
|
|
10
|
+
layer: from.layer,
|
|
11
|
+
shared: from.view ?? null,
|
|
12
|
+
});
|
|
13
|
+
const actions = {
|
|
14
|
+
setSettings: (change) => latest.onChange(change),
|
|
15
|
+
setLayer: (patch) => latest.onLayerChange(patch),
|
|
16
|
+
openPanel: (key, page) => {
|
|
17
|
+
const { panels } = state;
|
|
18
|
+
const kept = page ?? panels.pages[key];
|
|
19
|
+
if (panels.open === key && panels.pages[key] === kept)
|
|
20
|
+
return;
|
|
21
|
+
write({ panels: { ...panels, open: key, pages: kept ? { [key]: kept } : {} } });
|
|
22
|
+
},
|
|
23
|
+
closePanel: (key) => {
|
|
24
|
+
const { panels } = state;
|
|
25
|
+
if (panels.open !== key && !(key in panels.pages))
|
|
26
|
+
return;
|
|
27
|
+
const { [key]: _forgotten, ...waiting } = panels.pages;
|
|
28
|
+
write({ panels: { ...panels, open: panels.open === key ? null : panels.open, pages: waiting } });
|
|
29
|
+
},
|
|
30
|
+
setPage: (key, page) => {
|
|
31
|
+
const { panels } = state;
|
|
32
|
+
if (panels.pages[key] === page)
|
|
33
|
+
return;
|
|
34
|
+
write({ panels: { ...panels, pages: { ...panels.pages, [key]: page } } });
|
|
35
|
+
},
|
|
36
|
+
hold: (held) => {
|
|
37
|
+
if (state.panels.held === held)
|
|
38
|
+
return;
|
|
39
|
+
write({ panels: { ...state.panels, held } });
|
|
40
|
+
},
|
|
41
|
+
select: (ids) => {
|
|
42
|
+
const { selection } = state;
|
|
43
|
+
if (ids === "all" ? selection.all : !selection.all && sameIds(selection.ids, ids))
|
|
44
|
+
return;
|
|
45
|
+
write({ selection: ids === "all" ? { ids: [], all: true, count: null } : { ids, all: false, count: ids.length } });
|
|
46
|
+
},
|
|
47
|
+
saveView: () => latest.view?.onPublish(),
|
|
48
|
+
resetView: () => latest.view?.onReset(),
|
|
49
|
+
undo: () => wired.undo?.(),
|
|
50
|
+
};
|
|
51
|
+
const data = {
|
|
52
|
+
id,
|
|
53
|
+
view: viewOf(props),
|
|
54
|
+
panels: {
|
|
55
|
+
open: null,
|
|
56
|
+
pages: {},
|
|
57
|
+
held: null,
|
|
58
|
+
barShown: false,
|
|
59
|
+
footHere: false,
|
|
60
|
+
sortFilter: props.sortFilter ?? "right",
|
|
61
|
+
bar: props.bar ?? "added",
|
|
62
|
+
},
|
|
63
|
+
selection: { ids: [], all: false, count: 0 },
|
|
64
|
+
views: null,
|
|
65
|
+
};
|
|
66
|
+
let state = { ...data, ...actions };
|
|
67
|
+
function swap(next) {
|
|
68
|
+
state = { ...state, ...next };
|
|
69
|
+
}
|
|
70
|
+
function write(next) {
|
|
71
|
+
swap(next);
|
|
72
|
+
for (const listener of [...listeners])
|
|
73
|
+
listener();
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
get: () => state,
|
|
77
|
+
subscribe: (listener) => {
|
|
78
|
+
listeners.add(listener);
|
|
79
|
+
return () => listeners.delete(listener);
|
|
80
|
+
},
|
|
81
|
+
sync: (next) => {
|
|
82
|
+
latest = next;
|
|
83
|
+
const changed = {};
|
|
84
|
+
const view = viewOf(next);
|
|
85
|
+
if (!sameKeys(state.view, view))
|
|
86
|
+
changed.view = view;
|
|
87
|
+
const panels = { sortFilter: next.sortFilter ?? "right", bar: next.bar ?? "added" };
|
|
88
|
+
if (!sameKeys(state.panels, panels))
|
|
89
|
+
changed.panels = { ...state.panels, ...panels };
|
|
90
|
+
if (Object.keys(changed).length === 0)
|
|
91
|
+
return;
|
|
92
|
+
swap(changed);
|
|
93
|
+
dirty = true;
|
|
94
|
+
},
|
|
95
|
+
flush: () => {
|
|
96
|
+
if (!dirty)
|
|
97
|
+
return;
|
|
98
|
+
dirty = false;
|
|
99
|
+
for (const listener of [...listeners])
|
|
100
|
+
listener();
|
|
101
|
+
},
|
|
102
|
+
patch: (patch) => {
|
|
103
|
+
const next = {};
|
|
104
|
+
if (patch.panels && !sameKeys(state.panels, patch.panels))
|
|
105
|
+
next.panels = { ...state.panels, ...patch.panels };
|
|
106
|
+
if (patch.views !== undefined && !Object.is(state.views, patch.views))
|
|
107
|
+
next.views = patch.views;
|
|
108
|
+
if (Object.keys(next).length > 0)
|
|
109
|
+
write(next);
|
|
110
|
+
},
|
|
111
|
+
wire: (handlers) => {
|
|
112
|
+
wired = { ...wired, ...handlers };
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ReadyToolbarProps } from "../panels/react/toolbar/ReadyToolbar.js";
|
|
3
|
+
/** `ReadyToolbar`'s props but those the root holds: the settings and the layer with their callbacks, the shared view,
|
|
4
|
+
* `sortFilter` and `bar`. */
|
|
5
|
+
export type ListToolbarProps<Row> = Omit<ReadyToolbarProps<Row>, "settings" | "layer" | "onChange" | "onLayerChange" | "view" | "sortFilter" | "bar">;
|
|
6
|
+
export declare function ListToolbar<Row>(props: ListToolbarProps<Row>): ReactNode;
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { settingsChange } from "viewkitjs/fields/query";
|
|
4
|
+
import { useLayoutEffect } from "react";
|
|
5
|
+
import { barItemsOf } from "../filters/filter-tree.js";
|
|
6
|
+
import { useViews } from "../provider/context.js";
|
|
7
|
+
import { useDesktop } from "../provider/desktop.js";
|
|
8
|
+
import { getViewOptionAvailability } from "../panels/availability.js";
|
|
9
|
+
import { settingsPanels } from "../panels/settings/settings-panels.js";
|
|
10
|
+
import { settingsCleared } from "../panels/toolbar/clear.js";
|
|
11
|
+
import { countsToggle, groupShown, showCountsChange, showCountsOf } from "../panels/toolbar/counts.js";
|
|
12
|
+
import { withEditView, withViewMenu } from "../panels/toolbar/edit-view.js";
|
|
13
|
+
import { splitViewAxes } from "../panels/views-row/model.js";
|
|
14
|
+
import { heldStands } from "../panels/react/filter/editor-ctx.js";
|
|
15
|
+
import { Toolbar, ToolbarSeparator } from "../panels/react/toolbar/Toolbar.js";
|
|
16
|
+
import { ToolbarFilter } from "../panels/react/toolbar/ToolbarFilter.js";
|
|
17
|
+
import { ToolbarFilterAdd } from "../panels/react/toolbar/ToolbarFilterAdd.js";
|
|
18
|
+
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
19
|
+
import { ToolbarNew } from "../panels/react/toolbar/ToolbarNew.js";
|
|
20
|
+
import { ToolbarOptions } from "../panels/react/toolbar/ToolbarOptions.js";
|
|
21
|
+
import { ToolbarQuickFilters } from "../panels/react/toolbar/ToolbarQuickFilters.js";
|
|
22
|
+
import { ToolbarSave } from "../panels/react/toolbar/ToolbarSave.js";
|
|
23
|
+
import { ToolbarSearch } from "../panels/react/toolbar/ToolbarSearch.js";
|
|
24
|
+
import { ToolbarSort } from "../panels/react/toolbar/ToolbarSort.js";
|
|
25
|
+
import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
26
|
+
import { ToolbarAdvancedFilters } from "../panels/react/toolbar/ToolbarAdvancedFilters.js";
|
|
27
|
+
import { ToolbarViews } from "../panels/react/toolbar/ToolbarViews.js";
|
|
28
|
+
import { applyParts } from "./parts.js";
|
|
29
|
+
import { useList, useListPanel, useListStore } from "./root.js";
|
|
30
|
+
import { useListViewsAxis } from "./views-axis.js";
|
|
31
|
+
export function ListToolbar(props) {
|
|
32
|
+
const { views: viewsHanded, viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, } = props;
|
|
33
|
+
const storeViews = useListViewsAxis(props.layouts);
|
|
34
|
+
const views = viewsHanded ?? storeViews;
|
|
35
|
+
const store = useListStore();
|
|
36
|
+
const settings = useList((s) => s.view.settings);
|
|
37
|
+
const layer = useList((s) => s.view.layer);
|
|
38
|
+
const onChange = useList((s) => s.setSettings);
|
|
39
|
+
const onLayerChange = useList((s) => s.setLayer);
|
|
40
|
+
const view = useList((s) => s.view.shared) ?? undefined;
|
|
41
|
+
const sortFilter = useList((s) => s.panels.sortFilter);
|
|
42
|
+
const bar = useList((s) => s.panels.bar);
|
|
43
|
+
const customizeOwn = {
|
|
44
|
+
...(viewName !== undefined && { viewName }),
|
|
45
|
+
...(onRenameView && { onRenameView }),
|
|
46
|
+
...(onCopyLink && { onCopyLink }),
|
|
47
|
+
...(onExport && { onExport }),
|
|
48
|
+
...(exportCount !== undefined && { exportCount }),
|
|
49
|
+
};
|
|
50
|
+
const { icons, messages, conventions } = useViews();
|
|
51
|
+
const desktop = useDesktop();
|
|
52
|
+
const phone = props.phone ?? !desktop;
|
|
53
|
+
const options = useListPanel("options");
|
|
54
|
+
const sortState = useListPanel("sort");
|
|
55
|
+
const filterState = useListPanel("filter");
|
|
56
|
+
const sortAdd = useListPanel("sort-add");
|
|
57
|
+
const filterAdd = useListPanel("filter-add");
|
|
58
|
+
const quickOwn = useListPanel("quick");
|
|
59
|
+
const quickState = props.quickFiltersOpen !== undefined && props.onQuickFiltersOpenChange
|
|
60
|
+
? { open: props.quickFiltersOpen, onOpenChange: props.onQuickFiltersOpenChange }
|
|
61
|
+
: quickOwn;
|
|
62
|
+
const held = useList((s) => s.panels.held);
|
|
63
|
+
const setHeld = useList((s) => s.hold);
|
|
64
|
+
const show = showCountsOf(settings);
|
|
65
|
+
const setShow = (next) => {
|
|
66
|
+
const change = showCountsChange(settings, next);
|
|
67
|
+
if (Object.keys(change).length > 0)
|
|
68
|
+
onChange(change);
|
|
69
|
+
};
|
|
70
|
+
const several = props.severalSorts ?? true;
|
|
71
|
+
const { toolbarParts: _placed, ...settingsProps } = props;
|
|
72
|
+
const input = {
|
|
73
|
+
...settingsProps,
|
|
74
|
+
settings,
|
|
75
|
+
layer,
|
|
76
|
+
onChange,
|
|
77
|
+
onLayerChange,
|
|
78
|
+
severalSorts: several,
|
|
79
|
+
filterGroups: props.filterGroups ?? true,
|
|
80
|
+
resolve: props.resolve ?? messages,
|
|
81
|
+
conventions: props.conventions ?? conventions,
|
|
82
|
+
};
|
|
83
|
+
const panels = settingsPanels(input);
|
|
84
|
+
const counts = countsToggle(views, props.toggles, show, setShow, messages);
|
|
85
|
+
const toggles = counts ? [...(props.toggles ?? []), counts] : props.toggles;
|
|
86
|
+
const inputs = {
|
|
87
|
+
filters: panels.filters,
|
|
88
|
+
sort: panels.sort,
|
|
89
|
+
sorts: panels.sorts,
|
|
90
|
+
filterTree: panels.filterTree,
|
|
91
|
+
group: groupShown(panels.group, panels.layout, phone),
|
|
92
|
+
layout: panels.layout,
|
|
93
|
+
toggles,
|
|
94
|
+
};
|
|
95
|
+
const clear = (scope) => () => {
|
|
96
|
+
const change = settingsCleared(input, scope, { phone });
|
|
97
|
+
if (change)
|
|
98
|
+
onChange(change);
|
|
99
|
+
};
|
|
100
|
+
const Edit = icons.options;
|
|
101
|
+
const editable = getViewOptionAvailability(inputs).desktop
|
|
102
|
+
? withEditView(views, {
|
|
103
|
+
key: "edit-view",
|
|
104
|
+
label: messages({ key: "views.panels.edit-view" }),
|
|
105
|
+
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
106
|
+
onSelect: () => options.onOpenChange(true),
|
|
107
|
+
})
|
|
108
|
+
: views;
|
|
109
|
+
const shownViews = withViewMenu(editable, menus?.view);
|
|
110
|
+
const ownNew = !addItems && onAdd ? { key: "new", label: addLabel ?? messages({ key: "views.panels.toolbar-new" }), onSelect: onAdd } : null;
|
|
111
|
+
const shapedNew = menus?.add ? menus.add(addItems ?? (ownNew ? [ownNew] : [])) : addItems;
|
|
112
|
+
const newItems = ownNew && shapedNew?.length === 1 && shapedNew[0] === ownNew ? undefined : shapedNew;
|
|
113
|
+
const search = settings.search ?? "";
|
|
114
|
+
const searchNode = (_jsx(ToolbarSearch, { value: search, placeholder: searchPlaceholder, searching: searching, onChange: (next) => {
|
|
115
|
+
const change = settingsChange(settings, { ...settings, search: next === "" ? undefined : next });
|
|
116
|
+
if (Object.keys(change).length > 0)
|
|
117
|
+
onChange(change);
|
|
118
|
+
} }));
|
|
119
|
+
const sortNode = several && panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: props.addAfter })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort }));
|
|
120
|
+
const filterNode = (_jsx(ToolbarFilter, { filters: panels.filters, filterTree: panels.filterTree, onClear: clear("filters"), open: filterState.open, onOpenChange: filterState.onOpenChange, page: filterState.page, onPageChange: filterState.onPageChange, host: hosts?.filter }));
|
|
121
|
+
const quick = props.quickFilters?.fields.length
|
|
122
|
+
? { ...props.quickFilters, showCounts: props.quickFilters.showCounts ?? show }
|
|
123
|
+
: null;
|
|
124
|
+
const quickNode = quick ? (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick })) : null;
|
|
125
|
+
const arrangement = props.arrangement ?? "kit";
|
|
126
|
+
const kit = arrangement === "kit";
|
|
127
|
+
const placed = (parts) => (toolbarParts ? applyParts(parts, toolbarParts, { arrangement, phone }) : parts);
|
|
128
|
+
const { viewAxes, stackedAxes } = splitViewAxes(shownViews, viewsLayout);
|
|
129
|
+
const tree = panels.filterTree;
|
|
130
|
+
const mihais = sortFilter === "right" && !phone;
|
|
131
|
+
const always = bar === "always";
|
|
132
|
+
const filtered = tree ? barItemsOf(tree.tree).length > 0 || !!heldStands(held, tree.tree) : false;
|
|
133
|
+
const barShown = always || !!stackedAxes || filtered;
|
|
134
|
+
const footHere = phone || (mihais && !barShown);
|
|
135
|
+
const barPublished = kit && !phone && (sortFilter === "bar" || barShown);
|
|
136
|
+
const footPublished = kit ? footHere : true;
|
|
137
|
+
useLayoutEffect(() => store.patch({ panels: { barShown: barPublished, footHere: footPublished } }), [store, barPublished, footPublished]);
|
|
138
|
+
if (kit) {
|
|
139
|
+
const clearable = !view && settingsCleared(input, "options", { phone }) !== null;
|
|
140
|
+
const tabs = !phone && viewAxes?.length === 1 ? Math.max(0, viewAxes[0].options.length - 1) : 0;
|
|
141
|
+
const Sort = icons.sort;
|
|
142
|
+
const Filter = icons.filter;
|
|
143
|
+
const QuickGlyph = icons.filterCategory;
|
|
144
|
+
const hasFilter = panels.filters.length > 0;
|
|
145
|
+
const filterMenu = {
|
|
146
|
+
label: messages({ key: "views.panels.filter" }),
|
|
147
|
+
icon: _jsx(Filter, { className: "h-4 w-4" }),
|
|
148
|
+
onSelect: () => filterState.onOpenChange(true),
|
|
149
|
+
};
|
|
150
|
+
const filterParts = tree && !phone
|
|
151
|
+
? [
|
|
152
|
+
{
|
|
153
|
+
key: "filters",
|
|
154
|
+
line: 2,
|
|
155
|
+
...(barItemsOf(tree.tree).length === 0 && !heldStands(held, tree.tree)
|
|
156
|
+
? { shed: true, fold: true, menu: filterMenu }
|
|
157
|
+
: { filters: foldableFilters(tree.tree, held) }),
|
|
158
|
+
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter })),
|
|
159
|
+
},
|
|
160
|
+
]
|
|
161
|
+
: [
|
|
162
|
+
{ key: "filter", line: 2, shed: true, fold: true, menu: filterMenu, node: filterNode },
|
|
163
|
+
...(tree
|
|
164
|
+
? [
|
|
165
|
+
{
|
|
166
|
+
key: "advanced-filters",
|
|
167
|
+
line: 2,
|
|
168
|
+
node: _jsx(ToolbarAdvancedFilters, { filterTree: tree, host: hosts?.filter }),
|
|
169
|
+
},
|
|
170
|
+
]
|
|
171
|
+
: []),
|
|
172
|
+
];
|
|
173
|
+
const kitParts = [
|
|
174
|
+
...(shownViews
|
|
175
|
+
? [{ key: "views", tabs, node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show }) }]
|
|
176
|
+
: []),
|
|
177
|
+
...(shownViews && stackedAxes && !phone
|
|
178
|
+
? [
|
|
179
|
+
{
|
|
180
|
+
key: "views-stacked",
|
|
181
|
+
line: 2,
|
|
182
|
+
node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show, stacked: true }),
|
|
183
|
+
},
|
|
184
|
+
]
|
|
185
|
+
: []),
|
|
186
|
+
{
|
|
187
|
+
key: "options",
|
|
188
|
+
shed: true,
|
|
189
|
+
fold: true,
|
|
190
|
+
menu: {
|
|
191
|
+
label: messages({ key: "views.panels.toolbar-options" }),
|
|
192
|
+
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
193
|
+
onSelect: () => options.onOpenChange(true),
|
|
194
|
+
},
|
|
195
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? clear("options") : undefined, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: hosts?.options, ...customizeOwn })),
|
|
196
|
+
},
|
|
197
|
+
...(quickNode
|
|
198
|
+
? [
|
|
199
|
+
{
|
|
200
|
+
key: "quick",
|
|
201
|
+
side: "end",
|
|
202
|
+
shed: true,
|
|
203
|
+
fold: true,
|
|
204
|
+
menu: {
|
|
205
|
+
label: quick?.label ?? messages({ key: "views.panels.quick-filters" }),
|
|
206
|
+
icon: _jsx(QuickGlyph, { className: "h-4 w-4" }),
|
|
207
|
+
onSelect: () => quickState.onOpenChange(true),
|
|
208
|
+
},
|
|
209
|
+
node: quickNode,
|
|
210
|
+
},
|
|
211
|
+
]
|
|
212
|
+
: []),
|
|
213
|
+
{ key: "search", side: "end", role: "search", words: "icon", node: searchNode },
|
|
214
|
+
{ key: "new", side: "end", shed: true, node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
215
|
+
{
|
|
216
|
+
key: "sort",
|
|
217
|
+
line: 2,
|
|
218
|
+
shed: true,
|
|
219
|
+
fold: true,
|
|
220
|
+
menu: {
|
|
221
|
+
label: messages({ key: "views.panels.sort" }),
|
|
222
|
+
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
223
|
+
onSelect: () => sortState.onOpenChange(true),
|
|
224
|
+
},
|
|
225
|
+
node: sortNode,
|
|
226
|
+
},
|
|
227
|
+
...(hasFilter ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
228
|
+
...filterParts,
|
|
229
|
+
...(!phone
|
|
230
|
+
? [
|
|
231
|
+
{
|
|
232
|
+
key: "save",
|
|
233
|
+
line: 2,
|
|
234
|
+
side: "end",
|
|
235
|
+
node: _jsx(ToolbarSave, { view: view, onClear: clearable ? clear("options") : undefined }),
|
|
236
|
+
},
|
|
237
|
+
]
|
|
238
|
+
: []),
|
|
239
|
+
];
|
|
240
|
+
if (phone) {
|
|
241
|
+
const quickHere = kitParts.find((part) => part.key === "quick");
|
|
242
|
+
const phoneParts = quickHere
|
|
243
|
+
? [...kitParts.filter((part) => part !== quickHere), { ...quickHere, line: 2, side: "start" }]
|
|
244
|
+
: kitParts;
|
|
245
|
+
return _jsx(Toolbar, { parts: placed(phoneParts), phone: true, fold: true, more: menus?.more, className: className });
|
|
246
|
+
}
|
|
247
|
+
if (sortFilter === "bar")
|
|
248
|
+
return _jsx(Toolbar, { parts: placed(kitParts), phone: phone, fold: true, more: menus?.more, className: className });
|
|
249
|
+
const rowSort = {
|
|
250
|
+
key: "sort",
|
|
251
|
+
side: "end",
|
|
252
|
+
shed: true,
|
|
253
|
+
fold: true,
|
|
254
|
+
menu: {
|
|
255
|
+
label: messages({ key: "views.panels.sort" }),
|
|
256
|
+
icon: _jsx(Sort, { className: "h-4 w-4" }),
|
|
257
|
+
onSelect: () => sortAdd.onOpenChange(true),
|
|
258
|
+
},
|
|
259
|
+
node: panels.sorts ? (_jsx(ToolbarSortPill, { row: true, sorts: panels.sorts, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort })) : (_jsx(ToolbarSort, { sort: panels.sort, open: sortAdd.open, onOpenChange: sortAdd.onOpenChange, host: hosts?.sort })),
|
|
260
|
+
};
|
|
261
|
+
const rowFilter = tree
|
|
262
|
+
? {
|
|
263
|
+
key: "filter-add",
|
|
264
|
+
side: "end",
|
|
265
|
+
shed: true,
|
|
266
|
+
fold: true,
|
|
267
|
+
menu: { ...filterMenu, onSelect: () => filterAdd.onOpenChange(true) },
|
|
268
|
+
node: (_jsx(ToolbarFilterAdd, { filterTree: tree, onHeldChange: setHeld, open: filterAdd.open, onOpenChange: filterAdd.onOpenChange, host: hosts?.filter })),
|
|
269
|
+
}
|
|
270
|
+
: { key: "filter", side: "end", shed: true, fold: true, menu: filterMenu, node: filterNode };
|
|
271
|
+
const pill = always && panels.sorts ? (_jsx(ToolbarSortPill, { sorts: panels.sorts, open: sortState.open, onOpenChange: sortState.onOpenChange, host: hosts?.sort, addAfter: false })) : null;
|
|
272
|
+
const stackedPart = kitParts.find((part) => part.key === "views-stacked");
|
|
273
|
+
const barParts = barShown
|
|
274
|
+
? [
|
|
275
|
+
...(stackedPart ? [stackedPart] : []),
|
|
276
|
+
...(pill ? [{ key: "sort-pill", line: 2, node: pill }] : []),
|
|
277
|
+
...(pill && (filtered || always) ? [{ key: "sep", line: 2, role: "separator", node: _jsx(ToolbarSeparator, {}) }] : []),
|
|
278
|
+
...(tree
|
|
279
|
+
? [
|
|
280
|
+
{
|
|
281
|
+
key: "filters",
|
|
282
|
+
line: 2,
|
|
283
|
+
filters: foldableFilters(tree.tree, held),
|
|
284
|
+
node: (_jsx(ToolbarFilters, { filterTree: tree, open: filterState.open, onOpenChange: filterState.onOpenChange, held: held, onHeldChange: setHeld, host: hosts?.filter, emptyPlace: always })),
|
|
285
|
+
},
|
|
286
|
+
]
|
|
287
|
+
: []),
|
|
288
|
+
{
|
|
289
|
+
key: "save",
|
|
290
|
+
line: 2,
|
|
291
|
+
side: "end",
|
|
292
|
+
node: _jsx(ToolbarSave, { view: view, onClear: clearable ? clear("options") : undefined }),
|
|
293
|
+
},
|
|
294
|
+
]
|
|
295
|
+
: [];
|
|
296
|
+
const at = (key) => kitParts.find((part) => part.key === key);
|
|
297
|
+
const quickPart = at("quick");
|
|
298
|
+
const mihaisParts = [
|
|
299
|
+
...kitParts.filter((part) => (part.line ?? 1) === 1 && !["quick", "search", "new", "sort", "filter", "filters"].includes(part.key)),
|
|
300
|
+
rowSort,
|
|
301
|
+
rowFilter,
|
|
302
|
+
...(quickPart && quick
|
|
303
|
+
? [
|
|
304
|
+
{
|
|
305
|
+
...quickPart,
|
|
306
|
+
words: "icon",
|
|
307
|
+
node: (_jsx(ToolbarQuickFilters, { quickFilters: quick, open: quickState.open, onOpenChange: quickState.onOpenChange, host: hosts?.quick, word: null })),
|
|
308
|
+
},
|
|
309
|
+
]
|
|
310
|
+
: []),
|
|
311
|
+
at("search"),
|
|
312
|
+
at("new"),
|
|
313
|
+
...barParts,
|
|
314
|
+
];
|
|
315
|
+
return _jsx(Toolbar, { parts: placed(mihaisParts), phone: phone, fold: true, more: menus?.more, className: className });
|
|
316
|
+
}
|
|
317
|
+
const parts = [
|
|
318
|
+
...(shownViews
|
|
319
|
+
? [
|
|
320
|
+
{ key: "views", node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show }) },
|
|
321
|
+
{ key: "views-stacked", line: 2, node: _jsx(ToolbarViews, { views: shownViews, viewsLayout: viewsLayout, showCounts: show, stacked: true }) },
|
|
322
|
+
]
|
|
323
|
+
: []),
|
|
324
|
+
{
|
|
325
|
+
key: "search",
|
|
326
|
+
side: "end",
|
|
327
|
+
role: "search",
|
|
328
|
+
words: "icon",
|
|
329
|
+
node: searchNode,
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
key: "sort",
|
|
333
|
+
side: "end",
|
|
334
|
+
node: sortNode,
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
key: "filter",
|
|
338
|
+
side: "end",
|
|
339
|
+
node: filterNode,
|
|
340
|
+
},
|
|
341
|
+
...(panels.filterTree
|
|
342
|
+
? [
|
|
343
|
+
{
|
|
344
|
+
key: "advanced-filters",
|
|
345
|
+
side: "end",
|
|
346
|
+
node: _jsx(ToolbarAdvancedFilters, { filterTree: panels.filterTree, host: hosts?.filter }),
|
|
347
|
+
},
|
|
348
|
+
]
|
|
349
|
+
: []),
|
|
350
|
+
...(quickNode ? [{ key: "quick", side: "end", node: quickNode }] : []),
|
|
351
|
+
{
|
|
352
|
+
key: "options",
|
|
353
|
+
side: "end",
|
|
354
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: hosts?.options, ...customizeOwn })),
|
|
355
|
+
},
|
|
356
|
+
{ key: "new", side: "end", node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
357
|
+
];
|
|
358
|
+
return _jsx(Toolbar, { parts: placed(parts), phone: phone, narrow: narrow, className: className });
|
|
359
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ListLayout } from "viewkitjs/fields/query";
|
|
2
|
+
import type { CollectionViewsConfig } from "../panels/views-row/model.js";
|
|
3
|
+
/** The toolbar's views axis from the root's store (not on the door): undefined in memory mode, and while the store
|
|
4
|
+
* hasn't answered. `layouts`: what a new view can take, the toolbar's own `layouts`; none handed, a table. */
|
|
5
|
+
export declare function useListViewsAxis(layouts?: readonly ListLayout[]): CollectionViewsConfig<string> | undefined;
|