viewkitjs 0.30.1 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +8 -2
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -4
- package/views/dist/controls/avatar/avatar.js +5 -3
- package/views/dist/controls/avatar/tokens.d.ts +104 -0
- package/views/dist/controls/avatar/tokens.js +26 -0
- package/views/dist/controls/avatar.css +46 -15
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/input/input.d.ts +12 -1
- package/views/dist/controls/input/input.js +10 -6
- package/views/dist/controls/input/save-mark.d.ts +8 -0
- package/views/dist/controls/input/save-mark.js +26 -0
- package/views/dist/controls/input/tokens.d.ts +20 -0
- package/views/dist/controls/input/tokens.js +5 -0
- package/views/dist/controls/input.css +49 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +12 -3
- package/views/dist/controls/radio/radio.js +25 -5
- package/views/dist/controls/radio/tokens.d.ts +84 -0
- package/views/dist/controls/radio/tokens.js +21 -0
- package/views/dist/controls/radio.css +130 -3
- package/views/dist/controls/select/select.d.ts +12 -2
- package/views/dist/controls/select/select.js +15 -7
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +10 -0
- package/views/dist/controls/setting-row/looks.js +22 -0
- package/views/dist/controls/setting-row/setting-row.d.ts +100 -0
- package/views/dist/controls/setting-row/setting-row.js +133 -0
- package/views/dist/controls/setting-row/tokens.d.ts +156 -0
- package/views/dist/controls/setting-row/tokens.js +41 -0
- package/views/dist/controls/setting-row.css +215 -0
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/switch-row.d.ts +1 -15
- package/views/dist/controls/switch-row/switch-row.js +1 -9
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/tokens.js +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +583 -61
- package/views/dist/styles.unlayered.css +583 -61
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +26 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +9 -0
- package/views/docs/controls/radio.md +33 -0
- package/views/docs/controls/select.md +6 -0
- package/views/docs/controls/setting-row.md +44 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +54 -27
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +3 -0
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# `viewkitjs/views/list`
|
|
2
|
+
|
|
3
|
+
Import from `viewkitjs/views/list` to give a list its rows from your server, and to hold a list's state for every part that draws it. A source takes one list request and returns its answer. The request, the answer and their schemas are `viewkitjs/fields/query`'s (`listRequestSchema`, `listAnswerSchema`), so your browser and your server check them the same way. A source carries no React; the root and its toolbar are client components. The toolbar draws the panels' parts that drag, so an app that renders it installs the dnd-kit peers, as for `viewkitjs/views/panels/react`; the door itself loads without them.
|
|
4
|
+
|
|
5
|
+
## A list's source
|
|
6
|
+
|
|
7
|
+
- `ListSource` — where a list's rows come from: `(request: ListRequest) => Promise<ListAnswer<Row>>`.
|
|
8
|
+
- It takes one argument, so a server action that takes a `ListRequest` and returns a `ListAnswer` is a source as it stands.
|
|
9
|
+
- A refusal is an answer (`{ refused: { code, message } }`, read with `isRefused`), never a throw: in production, Next hides a thrown server-action error's message.
|
|
10
|
+
- A throw is a failure the list can only report.
|
|
11
|
+
- Pass every answer through `answerFor(request, answer)`, which throws on an answer to another part.
|
|
12
|
+
- `fetchSource` — `fetchSource(url, init?)` makes a source that POSTs each request as JSON to `url`.
|
|
13
|
+
- `init` is handed to `fetch`, minus `method` and `body`. The headers you hand in are kept, and `content-type` is set to JSON.
|
|
14
|
+
- A 2xx answer, or a 400 holding a refusal, is checked with `listAnswerSchema` and `answerFor` and handed back.
|
|
15
|
+
- It throws, naming `url`, on any other status, on an answer that is no list answer, and on an answer to another part.
|
|
16
|
+
|
|
17
|
+
## What a source answers
|
|
18
|
+
|
|
19
|
+
- **A row** is your own flat row, `{ id, ...values }`, the same shape as rows a list holds in memory. `id` is the record's key as text: a numeric key is sent as its digits. `id` is never a field's key, and a request refuses a field named `id`.
|
|
20
|
+
- **A row's values** are as JSON carries them: a date is its ISO text.
|
|
21
|
+
- **`total`** is counted on a first page (no `after`), and is `null` on the pages after.
|
|
22
|
+
- **A grouped `rows` answer** holds its rows in its groups:
|
|
23
|
+
- its own `rows` is `[]`, its `next` is `null`, and its `total` is the whole list's;
|
|
24
|
+
- a group that carries `rows` is loaded, and carries its own `next`;
|
|
25
|
+
- a group without rows is loaded by a `group` request for its key (`""` for the rows with no value).
|
|
26
|
+
- **A page that shows part of a list** (one company's deals) narrows it in its source, on the server: `source={(request) => loadDeals(companyId, request)}`. Your server adds that narrowing beside its access rules and never takes one from the request.
|
|
27
|
+
- **Request members are strict**, so when a request gains a key, update your servers before your clients.
|
|
28
|
+
|
|
29
|
+
## A list's root
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import type { ReactNode } from "react";
|
|
33
|
+
import { LIST_SETTINGS_DEFAULTS } from "viewkitjs/fields/query";
|
|
34
|
+
import { ListRoot } from "viewkitjs/views/list";
|
|
35
|
+
import { useListSettingsState } from "viewkitjs/views/panels/react";
|
|
36
|
+
|
|
37
|
+
// A list kept in memory; any arrangement goes inside: ViewKit's parts, your own, anywhere.
|
|
38
|
+
export function DealsList({ children }: { children: ReactNode }) {
|
|
39
|
+
const memory = useListSettingsState({ settings: LIST_SETTINGS_DEFAULTS });
|
|
40
|
+
return (
|
|
41
|
+
<ListRoot id="deals" {...memory}>
|
|
42
|
+
{children}
|
|
43
|
+
</ListRoot>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- `ListRoot` — holds one list's state in a store outside React, for every part inside it, wherever it stands. It has two modes, fixed by its first render:
|
|
49
|
+
- **Yours (memory mode):** it takes `id`, and the list's settings and layer as you hold them: `settings`, `layer`, `onChange` and `onLayerChange`, exactly as `useListSettingsState` returns them, or your own saved view's. Optionally `view` (the shared view this list shows, a `CollectionViewState`), `sortFilter` and `bar` (as `ReadyToolbar` takes them).
|
|
50
|
+
- **Kept by ViewKit:** handed no `settings`, it keeps the list's saved views, the person's draft and their layer itself, through a `ViewsStore`: below, "A list's saved views". It takes `id`, and optionally `views`, `defaults`, `link`, `sortFilter` and `bar`.
|
|
51
|
+
- A change a part makes goes to your `onChange` or `onLayerChange`; your next `settings` and `layer` are what every part reads. A change you refuse never shows.
|
|
52
|
+
- One panel is open per root, whichever frame opened it: every `Toolbar` inside it, every frame of your own under a `ToolbarRadioProvider` and every part standing in no frame share the root's radio. Outside a root, each frame keeps its own. Two roots never close each other's panels.
|
|
53
|
+
- It draws no element of its own.
|
|
54
|
+
- `ListRootProps` — what `ListRoot` takes.
|
|
55
|
+
- `ListSlot` — a place for a list's parts outside its tree, where you put it (your page header): `<ListSlot name="header" />` draws a `div` (`data-slot="vk-list-slot"`, `data-name`), optionally with your `className`. One slot per name under a `ViewsProvider`: a later one takes the fills from an earlier.
|
|
56
|
+
- `ListSlotProps` — what `ListSlot` takes: `name`, and optionally `className`.
|
|
57
|
+
- `ListFill` — what goes into the slot of its `name`, from inside a `ListRoot`: `<ListFill name="header"><ListToolbar … /></ListFill>`. It draws through a portal, so what it holds keeps the root around the fill: a toolbar drawn in your header reads and changes the list, and its panels are the root's, open across a change of form. While no slot of its name stands, it draws nothing.
|
|
58
|
+
- `ListFillProps` — what `ListFill` takes: `name` and `children`.
|
|
59
|
+
- `useList` — `useList(select, equal?)`: what this part selects of its list's state (`ListState`), from the `ListRoot` around it.
|
|
60
|
+
- It re-renders only when what it selected changes: `useList((s) => s.selection.count)` doesn't redraw when the search changes. `equal` says when two selections are the same (`Object.is` by default); hand one when your selector builds a fresh object.
|
|
61
|
+
- Select an action as it stands (`useList((s) => s.openPanel)`): actions never change, so selecting one never re-renders.
|
|
62
|
+
- Outside a `ListRoot`, it throws.
|
|
63
|
+
- `useList(id, select, equal?)` reads the root of that `id` from anywhere under the `ViewsProvider`, inside or outside its tree: a count in your page header, a drawer reading the list. It reads `undefined` while no root of that id stands, and follows a root that comes later. A root keeps the `id` it was first given; with two roots of one id under one provider, the later is read. Outside a `ViewsProvider`, it throws.
|
|
64
|
+
- `ListState` — one list's state, as a part selects it:
|
|
65
|
+
- `id`: the root's.
|
|
66
|
+
- `view`: `settings` (the view as the person edits it), `layer` (their own layer over it) and `shared` (the shared view, or `null`; kept by ViewKit, the open view, the person's own included).
|
|
67
|
+
- `panels`: `open` (the one open panel's key, or `null`), `pages` (each panel's page by its key), `held` (the filter rule held until whole), `barShown` (the filter bar shows), `footHere` (Clear and Save stand in Customize's foot, not at the bar's end), `sortFilter` and `bar`. `ListToolbar` says `barShown` and `footHere` as it draws.
|
|
68
|
+
- `views`: the list's saved views where the root keeps them (a `ListViewsState`); `null` in memory mode.
|
|
69
|
+
- `selection`: `ids` (the picked rows), `all` (every matching row is picked) and `count` (how many; `null` while every matching row is picked and the list doesn't know its total).
|
|
70
|
+
- `setSettings(change)` and `setLayer(patch)`: hand a change to the root's `onChange` and `onLayerChange`.
|
|
71
|
+
- `openPanel(key, page?)`: opens a panel and closes any other, on `page` where handed, else on the page it holds. `closePanel(key)`: closes it if it is the one open, forgetting its page. `setPage(key, page)`: a panel's page; set on a panel that isn't open, it waits for it, until another opens.
|
|
72
|
+
- `hold(rule)`: holds a filter rule until whole, or `null`.
|
|
73
|
+
- `select(ids)`: picks these rows; `select("all")` picks every matching row; `select([])` picks none.
|
|
74
|
+
- `saveView()` and `resetView()`: the shared view's Save for everyone and Reset (kept by ViewKit, the open view's Save and Reset); nothing without one.
|
|
75
|
+
- `undo()`: takes back the list's last edit; it does nothing until the list holds edits.
|
|
76
|
+
- `ListToolbar` — the ready toolbar's parts in their arrangements, reading the root around it: every `ReadyToolbar` prop but those the root holds. `ReadyToolbar` is a `ListRoot` around it. Place one per root: two would draw the same panels. Handed no `views` in a root that keeps its views, it draws the views row from them, its menu included; a new view takes one of its `layouts` (a table where none are handed).
|
|
77
|
+
- `ListToolbarProps` — what `ListToolbar` takes: `ReadyToolbarProps` without `settings`, `layer`, `onChange`, `onLayerChange`, `view`, `sortFilter` and `bar`; `toolbarParts` among them ([Parts as data](#parts-as-data)).
|
|
78
|
+
|
|
79
|
+
## A list's saved views
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
// With the imports above.
|
|
83
|
+
import type { ListSettings } from "viewkitjs/fields/query";
|
|
84
|
+
import { ListToolbar, type ListToolbarProps, type ViewSeed } from "viewkitjs/views/list";
|
|
85
|
+
|
|
86
|
+
type SavedDeal = { id: string; name: string };
|
|
87
|
+
declare const DEAL_COLUMNS: ListToolbarProps<SavedDeal>["columns"]; // your list's columns
|
|
88
|
+
|
|
89
|
+
const ALL: ListSettings = { ...LIST_SETTINGS_DEFAULTS, sorts: [{ fieldKey: "name", direction: "asc" }] };
|
|
90
|
+
// Your own views, in your code: listed first, shared with everyone, read-only.
|
|
91
|
+
const DEAL_VIEWS: ViewSeed[] = [{ id: "all", name: "All deals", settings: ALL }];
|
|
92
|
+
|
|
93
|
+
export function Deals() {
|
|
94
|
+
return (
|
|
95
|
+
<ListRoot id="deals" views={{ seed: DEAL_VIEWS, records: "deals" }} defaults={ALL}>
|
|
96
|
+
<ListToolbar columns={DEAL_COLUMNS} layouts={["table"]} />
|
|
97
|
+
{/* your grid, reading useList((s) => s.view.settings) */}
|
|
98
|
+
</ListRoot>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
A `ListRoot` handed no `settings` keeps the list's saved views, a person's draft over each and their own layer, behind a store: the browser's `localStorage` by default, or your app's own.
|
|
104
|
+
|
|
105
|
+
- In this mode, `ListRoot` takes:
|
|
106
|
+
- `views`: where the views are kept: a `ViewsStore`, or options (`ListViewsOptions`); left out, `browserViewsStore()`.
|
|
107
|
+
- `defaults`: what a list with no saved view shows, and a new view's start; default `LIST_SETTINGS_DEFAULTS`.
|
|
108
|
+
- `link`: the address's reading as the list opened (`readListLink(location.search)` from `viewkitjs/fields/query`): its view opens, and its change (the search with it) shows over that view, in place of the person's draft. A link that names no view and no change beyond a search is no link: the draft shows, the search over it.
|
|
109
|
+
- `ListViewsOptions` — `views` as options: `store` (your own `ViewsStore`), or `seed` (your own views for this list, on the browser store: listed first, shared, read-only), and `records` (what the list holds, in the delete question's line: "deals"; default "records").
|
|
110
|
+
- `ListViewsState` — `ListState.views`: `list` (the views the row shows: shared first, then the person's own, each by position), `open` (the open view's id, or `null`), `ready` (the store has answered), `share` (this person may write shared views), `pending` (a write is under way) and `records`; and the verbs `openView(id)`, `save()`, `saveAs(name, { from?, layout? })`, `rename(id, name)`, `duplicate(id, name)`, `remove(id)`, `restore(id, open)`, `reorder(scope, ids)`, `reset()` and `canSave(view)`. The views row calls them; a part of your own can too.
|
|
111
|
+
- `browserViewsStore(options?)` — the default store: one `localStorage` entry per list, `vk:views:<list id>`, holding the person's own views, their drafts and their layer. An entry that doesn't read (a hand edit, an older one) reads as empty, and the next write replaces it. Where storage refuses a write, the change lasts as long as the page.
|
|
112
|
+
- `BrowserViewsStoreOptions` — what `browserViewsStore` takes: `key` (the entries' prefix, default `"vk:views"`), `seed` (your own views, by list id) and `storage` (default `window.localStorage`; `null` keeps them for the page's life).
|
|
113
|
+
- `ViewsStore` — the one interface a root keeps its views through, the browser store's and your app's own: `list`, `save` (hands back the view as kept), `remove`, `reorder`, optionally `subscribe`, `draft.get`/`draft.set`, `layer.get`/`layer.set`, and optionally `can.share`. Every call names its list, so one store serves an app. Each answers at once or with a promise.
|
|
114
|
+
- `SavedViewInput` — what `save` takes: a `SavedView` without `updatedAt` and `readOnly`; with no `id`, a new view, whose id the store makes.
|
|
115
|
+
- `ViewDraft` — a person's unsaved change over one view (`change`, never the search), and the view's `updatedAt` when it began (`base`).
|
|
116
|
+
- `ViewSeed` — one of your own views: `id`, `name` and `settings`.
|
|
117
|
+
|
|
118
|
+
How the views behave:
|
|
119
|
+
|
|
120
|
+
- **Your own views come first**, shared and read-only: their menu offers Reset, Save as new view, Duplicate and Copy link, never Rename, Delete or Save.
|
|
121
|
+
- **With the browser store, everything a person saves is their own**, so "Save for everyone" never shows: their own view's Save says "Save" (`views.panels.view-save-own`), in its menu and Customize's foot. A store whose `can.share` is true lets that person save over shared views too.
|
|
122
|
+
- **A draft per view.** Each change a person makes is kept as their draft over the open view, never the search, and shows again when they come back. Undoing every change lets the draft go. A draft begun before its view was saved again (another tab, another person) is marked: Customize says "Everyone's view changed since you started." The draft is kept.
|
|
123
|
+
- **A link wins** over the draft: the view it names opens with its change; a view the store doesn't have opens the first listed, with the link's change.
|
|
124
|
+
- **Delete with Undo.** A deleted view leaves the row at once and ViewKit's toast offers Undo. It is removed from the store once the toast's time ends (`--vk-toast-duration`), or at once when the page closes (`pagehide`). An Undo after that saves it back under its own id.
|
|
125
|
+
- **Other tabs follow** through the `storage` event: a view saved, renamed, reordered or deleted shows in each tab; the open view gone, the first listed opens.
|
|
126
|
+
- **Copy link** copies the address with the view in it, and the search where it is the open view; never the person's draft.
|
|
127
|
+
- **A view's scope isn't changed from its menu yet**: a person's own view stays theirs, and Favorite isn't offered.
|
|
128
|
+
|
|
129
|
+
Your app's own store implements `ViewsStore` over its API, a server checking each view with `savedViewSchema` (`viewkitjs/fields/query`):
|
|
130
|
+
|
|
131
|
+
- A write it refuses throws, or rejects, with an `Error` whose message a person reads: the root says it through your `toast` port's `error`, reads `list` again, and keeps the person's edits.
|
|
132
|
+
- Drafts and the layer are written on every edit (`draft.set`, `layer.set`): debounce them, and flush what you hold on `pagehide`.
|
|
133
|
+
- Writes made as the page closes (that, and a held delete's `remove`) must reach your server: send them with `fetch(…, { keepalive: true })` or `navigator.sendBeacon`, since a plain request leaving as the page closes may never arrive.
|
|
134
|
+
- Whether this person may write shared views is `can.share`; left out, no one may.
|
|
135
|
+
- A store with `subscribe(listId, onChange)` tells the root when the list changes from elsewhere; left out, a person sees others' changes on their next visit.
|
|
136
|
+
|
|
137
|
+
## Menus as data
|
|
138
|
+
|
|
139
|
+
Each of a list's menus below hands you its default items as data, and draws the items your function hands back: drop a row, rename it, move it, add your own, or draw a row's inside yourself. The grid's "+ Add column" menu takes no function yet.
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { GridTable, type GridTableProps } from "viewkitjs/views/grid";
|
|
143
|
+
import { menu, type ListMenus } from "viewkitjs/views/list";
|
|
144
|
+
|
|
145
|
+
type Deal = { id: string; name: string };
|
|
146
|
+
|
|
147
|
+
const menus: ListMenus<Deal> = {
|
|
148
|
+
// A column's menu: Move left gone, Hide renamed, your own row after it.
|
|
149
|
+
column: (items, { field }) =>
|
|
150
|
+
menu.add(
|
|
151
|
+
menu.rename(menu.drop(items, "move-left"), "hide-column", "Hide from view"),
|
|
152
|
+
{ key: "copy-key", label: "Copy field key", onSelect: () => void navigator.clipboard.writeText(field?.key ?? "") },
|
|
153
|
+
{ after: "hide-column" }
|
|
154
|
+
),
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export function DealsGrid(grid: GridTableProps<Deal>) {
|
|
158
|
+
return <GridTable {...grid} menus={menus} />;
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- `ListMenus` — every menu of a list as data: `ListMenus<Row>`, six functions, each optional. Each takes the menu's default items (`ViewsMenuItem[]`, every row keyed) and returns the items it shows. A menu with no function is as ViewKit draws it.
|
|
163
|
+
- `column(items, { field, column })`: a column's header menu, handed the column (`ListColumn`) and its field (`undefined` for a column with none).
|
|
164
|
+
- `row(items, { row })`: a row's menu, on a right-click and in its ⋯ tail, handed the row. Its items hold Open page (`row-open`, from `rowHref`) and Delete (`row-delete`, from `onRowDelete`, still asking your `confirm` port): drop `row-delete` for a row that can't be deleted, and your `RowMenu` draws neither of its own. It is asked as the menu opens (a right-click, the ⋯, the menu key), never for a row drawn or pressed, and may answer later: hand back a promise (`async (items, { row }) => …`, one request to your server) and it is asked once per opening, the menu holding one greyed row with your `loading` glyph, "Loading…" (`row-waiting`), and nothing the answer may take away, until it answers. An answer that a later opening has outrun is dropped; one that fails draws the grid's own rows. A host whose delete can be undone leaves out `onRowDelete` and adds its own destructive row, which asks nothing.
|
|
165
|
+
- `group(items, { group })`: a group band's ⋯, handed the group (`ListGroup`).
|
|
166
|
+
- `view(items, { view })`: a view's menu, handed the view (`ViewsViewsListItem`): the rows a view's option hands (`menu`, Edit view… among them) and the menu a views list draws from the axis's `verbs` (`ViewsViewVerbs.menu`).
|
|
167
|
+
- `add(items)`: New's items: your `addItems`, or with `onAdd` alone one row keyed `new` that runs it. New opens what it returns as a menu.
|
|
168
|
+
- `more(items, { line })`: ⋯, the folded parts' rows, each keyed by its part. Each line folds into its own ⋯, so it is handed which: `"row"` or `"bar"` (the filter bar). A press on any row closes ⋯ first.
|
|
169
|
+
- Until `<List>` takes it whole, `GridTable` takes `column`, `row` and `group` as `menus` ([`/grid`](./grid.md)), and `ReadyToolbar` and `ListToolbar` take `view`, `add` and `more` as `menus` ([`/panels/react`](./panels-react.md)).
|
|
170
|
+
- A menu ViewKit doesn't open stays closed: ⋯ stands only while a part has folded, whatever `more` adds, and New stays a button while `add` hands back its one `new` row. A menu ViewKit opens stays openable: a function that returns `[]` opens an empty menu, so drop what you don't want rather than everything.
|
|
171
|
+
- Each function is called as ViewKit draws (`view` on every toolbar render, the rest as their menus draw): keep it pure and cheap, and call no hooks in it. `row` alone may answer later, with a promise, asked once per opening.
|
|
172
|
+
- `menu` — the four changes a menu function makes, each pure: it returns a new list and never changes the one it is handed. A key is found at any depth, a group's rows too. `drop`, `add` and `move` take any list of keyed rows, so they reshape the toolbar's parts too ([Parts as data](#parts-as-data)).
|
|
173
|
+
- `menu.drop(items, ...keys)`: removes those rows. A dropped row that opened a block hands its divider to the row that takes its place; a group whose every row is dropped goes too.
|
|
174
|
+
- `menu.rename(items, key, label)`: that row's words.
|
|
175
|
+
- `menu.add(items, item, place?)`: your row, at `place` (a `MenuPlace`), else at the end. Added before a row, it takes over that row's divider, or has none, and joins its block (its own `separatorBefore` set aside); added after one, it keeps its own `separatorBefore`. A place by a key the menu doesn't hold adds it at the end.
|
|
176
|
+
- `menu.move(items, key, place)`: that row, to `place`. A key the menu doesn't hold, a place by itself or by one of its own rows changes nothing.
|
|
177
|
+
- No list they return starts with a divider.
|
|
178
|
+
- `MenuPlace` — where a row goes: `{ after: key }` or `{ before: key }`.
|
|
179
|
+
- A row may draw its own inside: `render` on a `ViewsMenuItem` ([`/react`](./react.md)) draws in place of its icon, words, keys and count, its `label` still its name. It is honoured on a plain row.
|
|
180
|
+
- The old route stays, and adds rows only: `columnMenuItems` on `GridTable` (your rows above Hide), `groupMenu` (which parts a band's ⋯ holds), `rowMenu` and `contextMenu` (a row's items), and `addItems` (New's).
|
|
181
|
+
|
|
182
|
+
### Default keys
|
|
183
|
+
|
|
184
|
+
Every default row's key is a public name: your function finds rows by it. A key that ends in a value is written here with that value as `<…>`.
|
|
185
|
+
|
|
186
|
+
- A column's menu: `sort-asc`, `sort-desc`, and on a place column `sort-asc:<part>` and `sort-desc:<part>` under them; `sort-clear`; `group-by`, `ungroup`; `percent-display` and `percent-display:<display>`; `date-format` and `date-format:<style>`; `show-time`; `duration-format` and `duration-format:<style>`; `decimals` and `decimals:<decimals>` (`decimals:auto` the field's own); `currency` and `currency:<code>`; `colour:<value>`, under it `colour:<value>:auto` and `colour:<value>:<colour>`, and `colours-reset`; `move-left`, `move-right`; `hide-column`. Your `columnMenuItems` rows keep their keys.
|
|
187
|
+
- A group band's ⋯: `group-select`; `group-sort` and `group-sort:<value>`; `group-show` and `group-show:<part>`; `group-hide`.
|
|
188
|
+
- A row's menu: `copy`, `cut`, `paste`, `clear`; `row-select`; `action:<id>` for each of a name column's actions. Your `contextMenu` rows keep their keys, or are keyed by their words. With `row`, also `row-open` (first) and `row-delete` (last), and `row-waiting`, the greyed row drawn while a promise from `row` waits (never handed to `row`).
|
|
189
|
+
- A view's menu, from the axis's verbs: `rename`, `edit`, `private`, `save`, `reset`, `save-new`, `copy-link`, `favorite`, `duplicate`, `delete`; on a phone `save`, `reset` and `save-new` are under `unsaved`, and `private` and `edit` under `this-view`. A view's own rows keep their keys, `edit-view` (Edit view…) at the head of the open view's.
|
|
190
|
+
- New: your `addItems`' keys, or `new`.
|
|
191
|
+
- ⋯: the folded parts' keys: `options`, `sort`, `filter`, `filters`, `filter-add`, `quick`.
|
|
192
|
+
|
|
193
|
+
## Parts as data
|
|
194
|
+
|
|
195
|
+
The ready toolbar (`ReadyToolbar`, `ListToolbar`) hands you each form's parts as data, as its menus hand their items, and draws the parts your `toolbarParts` function hands back: each on its line and side, in your order, with its words. Hand nothing and each arrangement stands its parts as it always has. Atlas's layout, the views alone on the left and Search (with its word), Sort, Filter, Customize and New on the right:
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
// With `menu` and `Deal` above.
|
|
199
|
+
import { ReadyToolbar, type ReadyToolbarProps, type ToolbarParts } from "viewkitjs/views/panels/react";
|
|
200
|
+
|
|
201
|
+
const toolbarParts: ToolbarParts = (parts) =>
|
|
202
|
+
menu.move(
|
|
203
|
+
menu.move(
|
|
204
|
+
parts.map((p) => (p.key === "options" ? { ...p, side: "end" as const } : p.key === "search" ? { ...p, words: "both" as const } : p)),
|
|
205
|
+
"search",
|
|
206
|
+
{ before: "sort" }
|
|
207
|
+
),
|
|
208
|
+
"options",
|
|
209
|
+
{ before: "new" }
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
export function DealsToolbar(props: ReadyToolbarProps<Deal>) {
|
|
213
|
+
return <ReadyToolbar {...props} toolbarParts={toolbarParts} />;
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
- The function, `(parts, ctx) => parts` ([`ToolbarParts`, `ToolbarPartPlace` and `ToolbarPartsContext`, in `/panels/react`](./panels-react.md#the-toolbar)): handed the form's parts in the order they are placed (the row's start, its end, then the bar's start and end, as they draw on a computer; a kit phone's one line as it reads; in the `row` arrangement's narrow and phone forms the search still moves where the form puts it), it hands back the parts drawn, in their order. A part left out isn't drawn; a key the form doesn't hold is skipped, unless it brings its own `node`; a key handed twice counts once. Handed back as it came, the toolbar is exactly as with nothing handed. It is called as the toolbar draws: keep it pure and cheap, and call no hooks in it. Not `parts`, which is the builder's own (a field's part columns in Customize).
|
|
218
|
+
- A part's place: `{ key, line, side, words, node? }`.
|
|
219
|
+
- `key`: the part's public name: `views` (and `views-stacked`, a second axis of views on the bar), `options` (Customize), `search`, `sort` (on the row, or the bar's sort in the old form), `sort-pill` (the bar's sort in Mihai's look with `bar: "always"`), `filter` and `filter-add` (Filter), `filters` (the filters on the bar), `advanced-filters`, `sep` (the bar's separator), `quick`, `new`, `save` (Clear and Save).
|
|
220
|
+
- `line`: `"row"`, `"bar"` (the filter bar; in the `row` arrangement, the line below the row) or `"foot"` (a kit phone list's foot, New's place; anywhere else it means the row). On a kit phone the row and the bar are one line, so `"bar"` stands a part on it too, and New stands on the line once you place it anywhere but `"foot"`.
|
|
221
|
+
- `side`: `"start"` or `"end"`.
|
|
222
|
+
- `words`: `"both"`, as the look's words say (icon and word where the buttons on the right show theirs), or `"icon"`, its icon alone whatever the look. It means something for a part whose button has an icon and a word: `search`, `quick`, `sort`, `filter`, `filter-add`, `options`, `new`. The search and, in Mihai's look, the quick filters' button are handed `"icon"`, as they always stood; placed `"both"`, they read their word and give it up first as the line narrows, as Sort and Filter do. A button with no icon (Clear, Save) keeps its words.
|
|
223
|
+
- `node`: a part of your own, under a key of your own, drawn where you place it (it doesn't fold into ⋯). `menu.add` places it. The keys above are the toolbar's, even while a part of theirs isn't handed: don't name your own part by one.
|
|
224
|
+
- Which form: `ctx` is `{ arrangement, phone }` (`"kit"` or `"row"`, and whether it is a phone's), so one function can place each form its own way.
|
|
225
|
+
- A part that comes and goes stays the toolbar's: the bar's `filters`, `save`, `sort-pill` and `sep` are handed only while the bar stands, so find them by key (a move by a key the list doesn't hold changes nothing). A part you place on the bar in Mihai's look at rest brings the bar with it; Clear and Save then still wait in Customize's foot.
|
|
226
|
+
- What stays fixed: Clear and Save move as one part (`save`); a part's words are `both` or `icon`, never its word alone; the kit's own `Toolbar` control ([`/controls`](./controls.md)) still places its parts from its look options, `settings: "right"` included, while the ready toolbar never reads `settings`: Customize's side comes through `toolbarParts`.
|
|
227
|
+
|
|
@@ -88,6 +88,9 @@ on a frame round the controls as `data-<piece>-*`, which each control's styleshe
|
|
|
88
88
|
- `StatusLookOptionId` — the Status's option ids.
|
|
89
89
|
- `SWITCH_LOOKS` — the Switch's: 4 options (`shape` a computer's, `phone` a phone's, `mark`, `motion`) and five looks, `slim`, `capsule`, `thin`, `hairline` and `classic`.
|
|
90
90
|
- `SwitchLookOptionId` — the Switch's option ids.
|
|
91
|
+
- `SETTING_ROW_LOOKS` — the setting row's: 3 options, two a computer's (`card`, `outlined` (the default) or `raised`; `rows`, `snug` (the default) or `roomy`, 64 tall) and one a phone's (`icon`, `line` (the default), the glyph alone, or `tile`, a white glyph on a tile of the row's `colour`), and two looks, `outright` (every option's default, the SwitchRows as they were) and `attio` (`raised`, `roomy`, `line`).
|
|
92
|
+
- `SettingRowOptionId` — its option ids.
|
|
93
|
+
- `SettingRowPicks` — one value for each.
|
|
91
94
|
- `MENU_LIST_LOOKS` — the menu list's, each a phone's: 6 options (`rows`, what its rows stand on; `lines`; `height`, a scale from `48` to `56`; `corners`, a scale from `lg` to `2xl`; `close`, a Close row; `tiles`) and five looks, `stack`, `card`, `plain`, `joined` and `words`, which pick the first four and leave the Close row and the tiles to the app.
|
|
92
95
|
- `MenuListLookOptionId` — the menu list's option ids.
|
|
93
96
|
|
|
@@ -27,13 +27,13 @@ Import from `viewkitjs/views/panels/react` for the panels as they draw: each is
|
|
|
27
27
|
The row of views over a list, and any row of pills: each pill is your `Pill` atom, a pill's verbs open through your `Menu`, the folded views and the picker's list through your `Popover`, a view's glyph through your `AppIcon`. The pills drag with dnd-kit, by the mouse and the keyboard (Space on a pill's grip, the arrows, Space), within their block: a private view moves among the private ones, a shared view among the shared. A pill's verbs open on a right-click, the active pill's on a click on it too, another pill's click still picking it. Each pill handed verbs has its `Menu` drawn beside it in the row, so a closed `Menu` must render nothing in place (a portaled popup does): the fold measures the row's children. Install `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` to use it: the pills, the sort's rules, the Columns list and the group order the door loads with `import()` as it loads (in a bundler, a chunk of its own); they draw still (no grip lifts) on the server, while hydrating and until they have arrived; the first time they arrive on a page, the rows already drawn mount again, so a pill that had focus loses it and an open pill's menu closes. The axes it draws are `/panels`' (`ViewTabOption`, `CollectionViewsConfig` and the rest).
|
|
28
28
|
|
|
29
29
|
- `loadPanelsDrag` — loads the drag library the parts that drag use, once: resolves `true` once it has loaded, `false` when it isn't installed (or didn't arrive; a later call tries again). The door starts it as it loads; a test that drags awaits it first (`beforeAll(() => loadPanelsDrag())`), so a list drags on its first render.
|
|
30
|
-
- `PillGroup` — a single-select drawn as pills, `solid` or `plain`, `default` or `sm`, reordering by drag when handed `onReorder`. Its options are `PillOption`s.
|
|
30
|
+
- `PillGroup` — a single-select drawn as pills, `solid` or `plain`, `default` or `sm`, reordering by drag when handed `onReorder`. Its options are `PillOption`s. Handed `viewMenu` (the axis's views and `verbs`) where your map draws `ViewMenu`, each pill opens that view's whole menu (your `ViewMenu`, `CONTROLS.ViewMenu` ViewKit's own) in place of its `menu` rows: the open one on a click on it again or a right-click, another on a right-click (VK-947).
|
|
31
31
|
- `HScrollRow` — a scroll rail that keeps the active pill in view, its width and end room from `--vk-scroll-row-inset` and `--vk-scroll-row-end`.
|
|
32
32
|
- `ViewTabs` — one axis as plain pills on a scroll rail.
|
|
33
33
|
- `toPillOptions` — views turned into pill options: the label and count joined by `views.panels.view-count`, a slot's colours, the glyph by your `AppIcon`.
|
|
34
|
-
- `FoldingViewRow` — the saved-views row that folds what doesn't fit into a "+N" chip, never folding the active view, and closes with the + when the axis grows. Handed `folded`, as a folding toolbar line hands it, it folds that many tabs and measures nothing of its own.
|
|
34
|
+
- `FoldingViewRow` — the saved-views row that folds what doesn't fit into a "+N" chip, never folding the active view, and closes with the + when the axis grows. Handed `folded`, as a folding toolbar line hands it, it folds that many tabs and measures nothing of its own. Where the axis hands `verbs` and your map draws `ViewMenu`, its pills and each folded view's `⋮` in the "+N" list open the view's whole menu through it (VK-947), and its + opens New view's Modal through it, in place of the axis's `onCreate` (VK-971).
|
|
35
35
|
- `ViewPicker` — the same axis as one chip naming the active view, opening your `ViewsListBody` (`CONTROLS.ViewsListBody` is ViewKit's own) in your `Popover` at the chip; on a phone (in a `Toolbar`, its phone form; elsewhere your provider's `desktopQuery`) in your `Sheet` (`snap: "auto"`, titled `views.panels.views-list`). The body is handed the views as data, a pick or an order is written once it fits the axis, its `onDone` closes the list, and on a phone it gets the ✕ (and Back on a step) as its `actions` only where your sheet's head doesn't draw it, and `onStepChange`, whose step's title and Back the sheet shows; the axis's `verbs`, where it hands them, reach it as they are ([the components map](../contract.md#the-components-map)).
|
|
36
|
-
- `ViewPickerRow` — one view as a row of a list, with the active view's
|
|
36
|
+
- `ViewPickerRow` — one view as a row of a list, with the active view's `⋮`; handed `viewMenu`, every row's `⋮` opens the view's whole menu through your `ViewMenu`.
|
|
37
37
|
- `ViewCreatePill` — the + that creates a view.
|
|
38
38
|
- `ViewAxes` — an axis or several on one row: one axis at the row's size folds, peer axes share one rail, each in its own track. `folded` is handed on to the one axis's `FoldingViewRow`.
|
|
39
39
|
|
|
@@ -64,18 +64,18 @@ The panel a list's Options button opens: your components map's `CustomizeBody` (
|
|
|
64
64
|
|
|
65
65
|
The frame that holds a list's controls, and the parts that need no list settings. `Toolbar` takes the parts your app hands it, each placed at the start or the end, on the first line or the second, and draws them in one of three forms (`/panels`' [arrangement](panels.md#the-toolbars-arrangement)): `row`, `narrow` (its own box under 700px) or `phone` (your provider's `desktopQuery` says it is not a desktop). Pass `phone` or `narrow` to decide either yourself. A part is any node: the frame tells it where it stands through `useToolbarSlot`, and its buttons draw through the `ToolbarButton` atom at their line's size. A part that opens something (a menu, a panel, a pane your app holds) registers it with `useToolbarPanel`, and opening one closes every other, however it opened. A change of form draws the parts afresh, so keep what must last across it (a search's text, a panel's open state) in your app: a panel part left to hold its own state closes when the box crosses 700px, and one handed its state from `useToolbarPanelState`, held above the `Toolbar`, stays open on its page. The row's end controls float over the views on a fade of `--vk-ground` (`data-toolbar-cluster`), which the folding views row measures. Its look is plain; its pieces carry the `data-slot`s the [contract](../contract.md) lists.
|
|
66
66
|
|
|
67
|
-
- `Toolbar` — the frame. Takes `parts` (`ToolbarPart[]`), and optionally `phone`, `narrow`, `narrowBelow` (700 by default), `fold` and `className`. With `fold` it draws the kit's arrangement (`/panels`' fold arrangement): the row and the filter bar under it, each a band with a line across under it, or a phone's one line, with no narrow form; each line measures itself and gives way as it narrows (it contains its own inline size, so its width comes from where it stands and never from what its lines hold: in a holder sized from its content, a main beside a sidebar, it still gives way, with no wrapper of yours), a part's words turning to its icon (the `ToolbarButton` atom's `iconAlone`), the views folding tabs into "+N", a part's filters folding into "+N filters", then what may fold going behind ⋯ (`data-slot="vk-toolbar-overflow"`, your `Menu`, each row the folded part's `menu`). A folded part keeps its state, and what it opens hangs under ⋯; while ⋯'s menu, a folded part's panel, the views' "+N" list, a filter with a part open (`data-slot="vk-toolbar-filter-rule"` marked `data-open`), an open advanced filter (`data-slot="vk-toolbar-advanced-filter"` marked `data-open`) or "+N filters"' menu (the button in `data-slot="vk-toolbar-more-filters"`, `aria-expanded`) is open, the line holds still. The frame holds the search's open state: open, the line gives way around it, and on a phone the search takes the line beside the views.
|
|
68
|
-
- `ToolbarPart` — a part as your app hands it: a `ToolbarPlacement` (its `key`, `side`, `line`, `role`,
|
|
67
|
+
- `Toolbar` — the frame (one radio for its parts, or, inside a `ListRoot`, the root's). Takes `parts` (`ToolbarPart[]`), and optionally `phone`, `narrow`, `narrowBelow` (700 by default), `fold`, `more` (`ToolbarMore`, ⋯ as data: handed the folded parts' rows, each keyed by its part, and `{ line }`, `"row"` or `"bar"`, since each line folds into its own ⋯, it returns the rows ⋯ shows; a press on any of them closes ⋯ first) and `className`. Each of its lines is a toolbar of its own (`role="toolbar"`): the filter bar (and the three forms' second line) named `views.panels.toolbar-bar` ("Sort and filters"), every other line `views.panels.toolbar-row` ("List tools"). With `fold` it draws the kit's arrangement (`/panels`' fold arrangement): the row and the filter bar under it, each a band with a line across under it, or a phone's one line, with no narrow form; each line measures itself and gives way as it narrows (it contains its own inline size, so its width comes from where it stands and never from what its lines hold: in a holder sized from its content, a main beside a sidebar, it still gives way, with no wrapper of yours), a part's words turning to its icon (the `ToolbarButton` atom's `iconAlone`), the views folding tabs into "+N", a part's filters folding into "+N filters", then what may fold going behind ⋯ (`data-slot="vk-toolbar-overflow"`, your `Menu`, each row the folded part's `menu`). A folded part keeps its state, and what it opens hangs under ⋯; while ⋯'s menu, a folded part's panel, the views' "+N" list, a filter with a part open (`data-slot="vk-toolbar-filter-rule"` marked `data-open`), an open advanced filter (`data-slot="vk-toolbar-advanced-filter"` marked `data-open`) or "+N filters"' menu (the button in `data-slot="vk-toolbar-more-filters"`, `aria-expanded`) is open, the line holds still. The frame holds the search's open state: open, the line gives way around it, and on a phone the search takes the line beside the views.
|
|
68
|
+
- `ToolbarPart` — a part as your app hands it: a `ToolbarPlacement` (its `key`, `side`, `line`, `role`, in the fold arrangement `shed`, `tabs`, `filters` and `fold`, and `words` and `foot`), its `node`, and for a part that may fold its `menu`: `{ label, icon?, onSelect }`, its row in ⋯. `words`: `"icon"` stands a `ToolbarButton` drawn in it as its icon alone, its words given up (a button with no icon keeps them); `"both"` gives the search's button, and the quick filters' button handed `word={null}`, their word, as the look's words say; absent, each its own. `foot: false` keeps New on a phone's folding line instead of at the list's foot.
|
|
69
69
|
- `ToolbarSeparator` — the line between the sort and the filters on a filter bar (or Filter while there is none), placed with `role: "separator"`: drawn only while a part stands drawn on each side of it, and never on a phone's line.
|
|
70
70
|
- `ToolbarViews` — the views row: `views` (`CollectionViewsInput`) and `viewsLayout`. On the row and in the narrow panel it draws `ViewAxes`, or with `as="picker"` and one axis alone its `ViewPicker`; placed again with `stacked` on the second line, it draws the axes a stacked layout pushes beneath, small. On the phone it draws a `ViewPicker` per axis, every axis, and nothing for `stacked`. With `showCounts` the toolbar owns Show counts (`withCounts`). Place it only when the list has views: the phone's search fills the row when nothing is placed at the start.
|
|
71
|
-
- `ToolbarSearch` — the search, placed with `role: "search"`: `value`, `onChange`, `placeholder` (`views.panels.search` by default) and `searching` (while true, a spinner, worded `views.panels.searching`, stands where its glass is, on the button and in the field, and the field, marked `aria-busy`, keeps its value and its typing; your app decides when it is true). On the row, and beside the phone's views, a button that opens an inline field; in the narrow panel, and on a phone with no views, a field that fills its line. A field that holds a value shows from the start. Escape and its ✕ clear it and close a field the button opened; a blur with nothing typed closes it. The field is your `Input`, or, handed `SearchField` in your components map, your whole search box: it stands in place of the glass, the field and the ✕, handed the value, the clear and its form, while the button, the open state, the caret on a press, Escape and a blur stay ViewKit's ([the components map](../contract.md#the-components-map)).
|
|
71
|
+
- `ToolbarSearch` — the search, placed with `role: "search"`: `value`, `onChange`, `placeholder` (`views.panels.search` by default) and `searching` (while true, a spinner, worded `views.panels.searching`, stands where its glass is, on the button and in the field, and the field, marked `aria-busy`, keeps its value and its typing; your app decides when it is true). On the row, and beside the phone's views, a button that opens an inline field; in the narrow panel, and on a phone with no views, a field that fills its line. A field that holds a value shows from the start. Escape and its ✕ clear it and close a field the button opened; a blur with nothing typed closes it. The field is your `Input`, or, handed `SearchField` in your components map, your whole search box: it stands in place of the glass, the field and the ✕, handed the value, the clear and its form, while the button, the open state, the caret on a press, Escape and a blur stay ViewKit's ([the components map](../contract.md#the-components-map)). Shut, its button is its glass alone, reading "Search" beside it only where its part is placed `words: "both"`, as the look's words say.
|
|
72
72
|
- `ToolbarNew` — the +: `onAdd` (one way to add, the button fires it) or `items` (several, opened through your `Menu`, one of the toolbar's panels), `label` (`views.panels.toolbar-new` by default) and `icon` (your `add` glyph by default); its word for a dress is its label. With neither, the row draws it disabled, so its place never moves; the narrow panel and the phone draw nothing. In a folding `Toolbar` on a phone it stands at the list's foot instead (`data-at="foot"`): a round + (the atom's `foot`) fixed at the screen's bottom-end corner, over the list, lifted by `--vk-toolbar-foot`, and drawn into the document's body so a page that scrolls inside a transformed box can't carry it away; with no verb, nothing there.
|
|
73
73
|
- `ToolbarButton` — the `ToolbarButton` atom at the size of the line it stands in, for a custom part's buttons.
|
|
74
|
-
- `useToolbarSlot` — where this part stands (`ToolbarSlotState`): `form`, `fill`, `size` and its line's kind; in the fold arrangement also `fold`, `iconAlone`, `tabsFolded`, `filtersFolded` (how many of its filters folded into "+N filters"), `folded`, `more` (⋯'s button) and, for the search, `search` (its open state, held by the frame); and `appFrame`, true inside your own frame (`ToolbarSlotProvider`); outside a `Toolbar`, the row's main line at `md`, folding nothing.
|
|
74
|
+
- `useToolbarSlot` — where this part stands (`ToolbarSlotState`): `form`, `fill`, `size` and its line's kind; in the fold arrangement also `fold`, `iconAlone`, `tabsFolded`, `filtersFolded` (how many of its filters folded into "+N filters"), `folded`, `more` (⋯'s button) and, for the search, `search` (its open state, held by the frame); `words` and `foot`, as the part was placed (`ToolbarPlacement`, [`/panels`](./panels.md)), which your own frame may set too; and `appFrame`, true inside your own frame (`ToolbarSlotProvider`); outside a `Toolbar`, the row's main line at `md`, folding nothing.
|
|
75
75
|
- `ToolbarSlotState` — what `useToolbarSlot` returns.
|
|
76
|
-
- `useToolbarPanel` — a part's open state as one of the toolbar's panels, named by a key: `{ open, onOpenChange }`. Each call is its own panel, so two parts that name the same key still close each other. Hand it `{ open, onOpenChange }` for a panel your app holds; without, it holds its own.
|
|
76
|
+
- `useToolbarPanel` — a part's open state as one of the toolbar's panels, named by a key: `{ open, onOpenChange }`. Each call is its own panel, so two parts that name the same key still close each other. Hand it `{ open, onOpenChange }` for a panel your app holds; without, it holds its own. Inside a `ListRoot`, one of the root's panels; outside a `Toolbar` and a root, plain open state.
|
|
77
77
|
- `ToolbarSlotProvider` — for your own toolbar frame: tells the part inside it where it stands, as `Toolbar` tells each of its parts. Takes `slot`, a partial `ToolbarSlotState` laid over the outside default (the row's main line at `md`, folding nothing); its `form` defaults to your provider's `desktopQuery` (`"phone"` off a desktop). It sets `appFrame: true` (`slot.appFrame: false` opts out): inside it the Views part (`ToolbarViews`) draws its chip, its view tabs, its "+N" and its "+" through your `ToolbarButton`, and `ToolbarSave` its Clear and Save, each told what it is (`current`, `part`, `onContextMenu`); a tab's status colours (`activeClassName`, `hoverClassName`) stay with ViewKit's own pills and don't reach it, and a `PillGroup`, `ViewTabs`, `ViewPicker` or `ViewCreatePill` you place yourself stays as it is. It replaces any slot above it.
|
|
78
|
-
- `ToolbarRadioProvider` — for your own toolbar frame: the radio, held for its life, as `Toolbar` holds one. Placed around your frame, the parts inside it that open something close each other, and a part's panel opens in your `Sheet` when its slot's `form` is `"phone"`.
|
|
78
|
+
- `ToolbarRadioProvider` — for your own toolbar frame: the radio, held for its life, as `Toolbar` holds one. Placed around your frame, the parts inside it that open something close each other, and a part's panel opens in your `Sheet` when its slot's `form` is `"phone"`. Inside a `ListRoot` ([`/list`](./list.md)) it is the root's radio, so your frame's panels and every other frame's in that list close each other.
|
|
79
79
|
|
|
80
80
|
#### In your own frame
|
|
81
81
|
|
|
@@ -136,7 +136,7 @@ Options, Sort and Filter each open their panel from their own button, and each t
|
|
|
136
136
|
- `SortEditorHost` — the host of your sort body alone, for a holder of your own (a popover; ViewKit's own body is `SortEditor`, on `viewkitjs/views/controls`): `sorts`, `form` (`"computer"` or `"phone"`), and optionally `open`, `onDone` and `addSort` (Add sort at a computer's body's foot, for a holder with no + of its own). It opens your `SortBody` (`CONTROLS.SortBody` is ViewKit's own), handed the rules as data, its whole list written once it fits the rules; every change goes out through `sorts.onChange` as it is made.
|
|
137
137
|
- `useSortEditorHost` — the sort editor's state for a sheet's holder (`SortEditorOptions`: `sorts`, `form`, `open`, `onDone`, `addSort`): `{ body, head, title, escapeBack }`. `body(closeButton)` draws your `SortBody`, on a phone handed `head` as its `actions` when `closeButton` is true (no head of your sheet draws them: your provider's `sheetActions` is `bar`, or a host of yours holds it); `head` is the ✕ (named `views.panels.close`) and ✓ (`views.panels.sort-done`) for your sheet's head, as its `actions`. ✕ takes the rules back, in one change, to what they were when `open` last turned true; the body's `onDone` calls the `onDone` you hand ([the components map](../contract.md#the-components-map)). On a phone the body is also handed `onStepChange`: while it stands on a step of its own, `title` is the step's (your sheet's title in place of the sort's), `head` gains `back` (Back, for `close`'s place), and `escapeBack()` goes back a step and says it did, so your sheet's Escape calls it first and closes only when it returns false.
|
|
138
138
|
- `SortEditorOptions` — what `useSortEditorHost` takes.
|
|
139
|
-
- `ToolbarQuickFilters` — the quick filters' button (`data-slot="vk-toolbar-quick"`), named `views.panels.quick-filters` (or the config's `label`), lit (`changed`) while a value is held: takes `quickFilters` (a `QuickFiltersConfig`, [`/panels`](./panels.md#quick-filters)), and optionally `open` and `onOpenChange` (to hold its state yourself), `host`, `icon` (its glyph; the `filterCategory` icon when absent) and `word` (`null`: its icon alone, its name its label to a screen reader, as `ReadyToolbar`'s default draws it on a computer). It opens your `QuickFiltersBody` (through `QuickFiltersPanel`) in your `Popover` (`data-slot="vk-toolbar-quick-panel"`), in `host`, or on a phone in your `Sheet`, and is one of the toolbar's panels. With no field to offer it draws nothing.
|
|
139
|
+
- `ToolbarQuickFilters` — the quick filters' button (`data-slot="vk-toolbar-quick"`), named `views.panels.quick-filters` (or the config's `label`), lit (`changed`) while a value is held: takes `quickFilters` (a `QuickFiltersConfig`, [`/panels`](./panels.md#quick-filters)), and optionally `open` and `onOpenChange` (to hold its state yourself), `host`, `icon` (its glyph; the `filterCategory` icon when absent) and `word` (`null`: its icon alone, its name its label to a screen reader, as `ReadyToolbar`'s default draws it on a computer, unless its part is placed `words: "both"`). It opens your `QuickFiltersBody` (through `QuickFiltersPanel`) in your `Popover` (`data-slot="vk-toolbar-quick-panel"`), in `host`, or on a phone in your `Sheet`, and is one of the toolbar's panels. With no field to offer it draws nothing.
|
|
140
140
|
- `QuickFiltersPanel` — the quick filters' panel alone, for a holder of your own: `quickFilters`, `form` (`"computer"` or `"phone"`), and optionally `onDone` and `closeButton` (false where your sheet's head draws the ✕). It opens your `QuickFiltersBody` (`CONTROLS.QuickFiltersBody` is ViewKit's own), handed the fields as the strip shows them (`quickFieldsShown`) with their values as they show (`quickValuesShown`, worded by the config's `heldLabels`), and writes its hold once `quickHoldFits` takes it; on a phone the body gets the ✕ as its `actions` when `closeButton` is true ([the components map](../contract.md#the-components-map)).
|
|
141
141
|
- `QuickFiltersReminder` — on a phone, the reminder that a hold stands while the quick filters are closed: takes `quickFilters` (the same `QuickFiltersConfig`), `onOpen` (a press on its names: open the quick filters, whose open state you hold through `ToolbarQuickFilters`' `open`, or `ReadyToolbar`'s `quickFiltersOpen`) and optionally `hidden` (it steps aside: hand whether rows are selected or the quick filters are open, so it never stands with your selection bar or over the open quick filters), and `holder` (a ref to your list's box: leaving with the focus in it, by its ✕ or by stepping aside as the quick filters open, it hands the focus there, giving a box that takes no focus `tabindex="-1"`, so the focus never falls to the page and a sheet opened from its names hands it back into the box; with none, the focus goes where the browser drops it; it never searches the page for one). Place it once at your list's foot. It is portalled to the body where the selection bar's phone pill stands (the provider's `selectionBar.phone`: its `bottom`, `zIndex` and `className`), a pill (`data-slot="vk-quick-filters-reminder"`) holding the held values' names, each by its words and never its key (`quickHeldNames`), the first two and "+N" for the rest (`quickReminderWords`, `views.panels.quick-more`), a press on them (`data-slot="vk-quick-filters-reminder-open"`, named `views.panels.quick-reminder` with every name once) calling `onOpen`; then ✕ (`data-slot="vk-quick-filters-reminder-clear"`, `views.panels.quick-clear`), letting every hold go. It draws nothing on a computer, while nothing is held, or while `hidden`. An app that wears its own reminder places that one instead, fed by `quickHeldNames`.
|
|
142
142
|
- `SortFieldList` — the fields a rule is picked from: `sorts`, `onPick`, and optionally `own` (a rule whose field it changes), `onDone` (done with no pick) and `form`. It opens your `FieldsBody` (`CONTROLS.FieldsBody` is ViewKit's own), in every holder, handed the options as data, each marked as the grid's header marks its column, a field already sorted, but `own`, `disabled` with why ("Sorted"); a pick of a key it didn't offer, or offered disabled, writes nothing ([the components map](../contract.md#the-components-map)).
|
|
@@ -154,6 +154,11 @@ Options, Sort and Filter each open their panel from their own button, and each t
|
|
|
154
154
|
- `ToolbarPanelState` — what `useToolbarPanelState` returns.
|
|
155
155
|
- `FilterPanelContent` — the Filter panel standing alone, for a host of your own: the filter list at its root (titled `views.panels.filter`, no back arrow) and the pages it opens, with `filters`, `timeScopeConfig`, `dateRangeConfigs`, `page`, `onPageChange`, `onClose` and `fill`.
|
|
156
156
|
- `ToolbarSave` — Clear and Save, at the end of a filter bar while the list differs (`data-slot="vk-toolbar-save"`): takes `view` (a `CollectionViewState`: Clear is its `onReset`, Save its `onPublish`, shown only where `canPublish`, both waiting while `pending`, nothing while `changes` is 0), or with no shared view `onClear`, Clear alone taking the list back to its default; nothing when neither has anything to do. Clear has no ground and Save wears the field's look, each your `Button`.
|
|
157
|
-
- `ReadyToolbar` — the toolbar for an app that doesn't arrange its own (`ReadyToolbarProps`): the builder's input (`settings`, `layer`, `columns`, `onChange`, `onLayerChange` and the rest of `SettingsPanelsInput`), and optionally `views`, `viewsLayout`, `onAdd` or `addItems` and `addLabel`, `view`, `toggles`, `fieldEditor`, `searchPlaceholder`, `searching` (handed to its search), `hosts` (`{ options, sort, filter, quick }`), `quickFilters` (a `QuickFiltersConfig`: handed, the quick filters' button stands on the row's end before the search, in the row arrangement before Options, folding into ⋯ as the row narrows; its counts follow the toolbar's Show counts unless the config carries its own `showCounts`), `quickFiltersOpen` with `onQuickFiltersOpenChange` (the quick filters' panel open, held by you, so a `QuickFiltersReminder` at your list's foot can open it; absent, the toolbar holds it), `phone`, `narrow`, `severalSorts` (true by default: the sort holds up to 3 rules, the row's Sort opening the sort editor on them, or in the old form the sort pill on the bar; `false` keeps Sort's one rule, which opens its own list whether or not a sort stands), `addAfter` (true by default: the + after the sort pill; `false` draws none, and the pill's editor, or your `SortBody`, has Add sort at its foot, as `ToolbarSortPill`'s), `filterGroups` (true by default: and/or groups, each filter on the filter bar on a computer, in the row arrangement each advanced filter's pill after Filter and Convert to advanced filter on a filter's page, and on a phone Filter opening the filter editor on every rule; `false` keeps Filter, counting what is applied, in either arrangement), `arrangement` (`"kit"` by default, or `"row"`), `sortFilter` (`"right"` by default, or `"bar"`), `bar` (`"added"` by default, or `"always"`: with Sort and Filter on the row's right, the bar then always shows, its empty Sort and Filter included), `viewName`, `onRenameView`, `onCopyLink`, `onExport` and `exportCount` (handed on to Customize, as `ToolbarOptions` takes them) and `className`. It calls the builder and draws its parts in the kit's arrangement (`Toolbar`'s `fold`). By default, on a computer, one row at rest: the views with Customize beside them, then on its right Sort and Filter with their words, the quick filters' button and the search, each its icon alone, and New. Sort holds the sort (`ToolbarSortPill`'s `row`): lit while one stands (a view's saved sort included), counted from two, it opens the sort editor to change or remove the rules, Add sort at its foot; with none, the fields. Filter (`ToolbarFilterAdd`) adds a filter to the bar. Under the row the filter bar, a step smaller, is the filters' line: it comes only while a filter stands or is held (or one of its parts is open, or a second axis of views stands there), holding the filters (each as below, + after the last, no empty Filter) and Clear and Save at its end. While it doesn't stand, an unsaved change (a sort, a removed last filter) waits in Customize's foot, Clear and Save (on a shared view Customize also carries its dot), as on a phone. Each of the row's Sort and Filter is a panel of its own, apart from the bar's, so a press opens one list. `sortFilter: "bar"` with `bar: "always"` draws the kit arrangement's old form: the row, the views with Customize beside them and the search and New at its end, and under it the filter bar, always shown, a step smaller: the sort pill first, a separator, the filters (`ToolbarFilters`: each filter as its four joined parts, each advanced filter's pill, + after the last; while there is none, Filter, an empty place; the rule held until whole is held by the toolbar, so the bar counts it as it folds; with `filterGroups` false, Filter as before, with what is applied counted), and at its end Clear and Save (`ToolbarSave`) while the list differs: on a shared view (`view`) Clear takes it back and Save, where `canPublish`, keeps it for everyone; with no shared view, Clear alone takes the list back to its default (nothing filtered, the default sort, no group: so a list that starts grouped or filtered shows Clear at once); Customize's foot then draws neither. A row with no room folds as the kit's does (words to icons, the view tabs into "+N", the bar's last filters into "+N filters", then into ⋯: by default Customize and the row's Sort and Filter, whatever is set; in the old form Customize, and the sort and Filter while no filter stands), with no narrow form. On a phone one line in either form (the views, the sort, Filter, the quick filters' button when handed, Customize, then the search, which opens across the line), Clear and Save in Customize's foot (`views.panels.view-clear`, `views.panels.view-save`; with no shared view, Clear alone), and New a round + at the list's foot, lifted by `--vk-toolbar-foot`. `arrangement: "row"` draws the order of 12 Nov instead: the views on the left; search, sort, filter, options and new on the right, the narrow form under 700px, and Reset and Save for everyone in Customize's foot. Every change comes back as a `ListSettingsChange` or a layer patch: its search writes the settings' search, its ✕s clear in one change (`settingsCleared`), and the active view's menu gains "Edit view…" (`withEditView`), which opens Customize. It
|
|
157
|
+
- `ReadyToolbar` — the toolbar for an app that doesn't arrange its own (`ReadyToolbarProps`): the builder's input (`settings`, `layer`, `columns`, `onChange`, `onLayerChange` and the rest of `SettingsPanelsInput`), and optionally `views`, `viewsLayout`, `onAdd` or `addItems` and `addLabel`, `view`, `toggles`, `fieldEditor`, `searchPlaceholder`, `searching` (handed to its search), `hosts` (`{ options, sort, filter, quick }`), `quickFilters` (a `QuickFiltersConfig`: handed, the quick filters' button stands on the row's end before the search, in the row arrangement before Options, folding into ⋯ as the row narrows; its counts follow the toolbar's Show counts unless the config carries its own `showCounts`), `quickFiltersOpen` with `onQuickFiltersOpenChange` (the quick filters' panel open, held by you, so a `QuickFiltersReminder` at your list's foot can open it; absent, the toolbar holds it), `phone`, `narrow`, `severalSorts` (true by default: the sort holds up to 3 rules, the row's Sort opening the sort editor on them, or in the old form the sort pill on the bar; `false` keeps Sort's one rule, which opens its own list whether or not a sort stands), `addAfter` (true by default: the + after the sort pill; `false` draws none, and the pill's editor, or your `SortBody`, has Add sort at its foot, as `ToolbarSortPill`'s), `filterGroups` (true by default: and/or groups, each filter on the filter bar on a computer, in the row arrangement each advanced filter's pill after Filter and Convert to advanced filter on a filter's page, and on a phone Filter opening the filter editor on every rule; `false` keeps Filter, counting what is applied, in either arrangement), `arrangement` (`"kit"` by default, or `"row"`), `sortFilter` (`"right"` by default, or `"bar"`), `bar` (`"added"` by default, or `"always"`: with Sort and Filter on the row's right, the bar then always shows, its empty Sort and Filter included), `viewName`, `onRenameView`, `onCopyLink`, `onExport` and `exportCount` (handed on to Customize, as `ToolbarOptions` takes them), `menus` (`ToolbarMenus`: a view's menu, New's and ⋯ as data), `toolbarParts` (`ToolbarParts`: where each part stands, every form's parts handed as data and drawn as you hand them back, [`/list`'s Parts as data](./list.md#parts-as-data)) and `className`. It calls the builder and draws its parts in the kit's arrangement (`Toolbar`'s `fold`). By default, on a computer, one row at rest: the views with Customize beside them, then on its right Sort and Filter with their words, the quick filters' button and the search, each its icon alone, and New. Sort holds the sort (`ToolbarSortPill`'s `row`): lit while one stands (a view's saved sort included), counted from two, it opens the sort editor to change or remove the rules, Add sort at its foot; with none, the fields. Filter (`ToolbarFilterAdd`) adds a filter to the bar. Under the row the filter bar, a step smaller, is the filters' line: it comes only while a filter stands or is held (or one of its parts is open, or a second axis of views stands there), holding the filters (each as below, + after the last, no empty Filter) and Clear and Save at its end. While it doesn't stand, an unsaved change (a sort, a removed last filter) waits in Customize's foot, Clear and Save (on a shared view Customize also carries its dot), as on a phone. Each of the row's Sort and Filter is a panel of its own, apart from the bar's, so a press opens one list. `sortFilter: "bar"` with `bar: "always"` draws the kit arrangement's old form: the row, the views with Customize beside them and the search and New at its end, and under it the filter bar, always shown, a step smaller: the sort pill first, a separator, the filters (`ToolbarFilters`: each filter as its four joined parts, each advanced filter's pill, + after the last; while there is none, Filter, an empty place; the rule held until whole is held by the toolbar, so the bar counts it as it folds; with `filterGroups` false, Filter as before, with what is applied counted), and at its end Clear and Save (`ToolbarSave`) while the list differs: on a shared view (`view`) Clear takes it back and Save, where `canPublish`, keeps it for everyone; with no shared view, Clear alone takes the list back to its default (nothing filtered, the default sort, no group: so a list that starts grouped or filtered shows Clear at once); Customize's foot then draws neither. A row with no room folds as the kit's does (words to icons, the view tabs into "+N", the bar's last filters into "+N filters", then into ⋯: by default Customize and the row's Sort and Filter, whatever is set; in the old form Customize, and the sort and Filter while no filter stands), with no narrow form. On a phone one line in either form (the views, the sort, Filter, the quick filters' button when handed, Customize, then the search, which opens across the line), Clear and Save in Customize's foot (`views.panels.view-clear`, `views.panels.view-save`; with no shared view, Clear alone), and New a round + at the list's foot, lifted by `--vk-toolbar-foot`. `arrangement: "row"` draws the order of 12 Nov instead: the views on the left; search, sort, filter, options and new on the right, the narrow form under 700px, and Reset and Save for everyone in Customize's foot. Every change comes back as a `ListSettingsChange` or a layer patch: its search writes the settings' search, its ✕s clear in one change (`settingsCleared`), and the active view's menu gains "Edit view…" (`withEditView`), which opens Customize. It is a `ListRoot` around `ListToolbar` ([`/list`](./list.md)): its panels' state is held in that root, above its frame, so a change of form keeps a panel open on its page, in a sheet once the form is the phone's. Show counts is the view's: read from `settings.showCounts` for the views row and the quick filters, absent meaning on, it joins Customize's toggles where the views carry counts and is written back through `onChange`. Group steps aside on a board (`groupShown`).
|
|
158
158
|
- `ReadyToolbarProps` — what `ReadyToolbar` takes.
|
|
159
|
-
- `
|
|
159
|
+
- `ToolbarParts` — `ReadyToolbar`'s and `ListToolbar`'s `toolbarParts`: `(parts: ToolbarPartPlace[], ctx: ToolbarPartsContext) => ToolbarPartPlace[]`, handed the form's parts in the order they are placed and handing back the parts drawn, in their order. The rules and an example are [`/list`'s Parts as data](./list.md#parts-as-data).
|
|
160
|
+
- `ToolbarPartPlace` — a part's place: `{ key, line, side, words, node? }`: its public key, its line (`"row"`, `"bar"`, or `"foot"`, New's place at a kit phone list's foot), its side (`"start"` or `"end"`), its words (`"both"` or `"icon"`), and `node` for a part of your own under a key of your own.
|
|
161
|
+
- `ToolbarPartsContext` — which form the parts are for: `{ arrangement, phone }` (`"kit"` or `"row"`, and whether it is a phone's).
|
|
162
|
+
- `ToolbarMore` — ⋯ as data, `Toolbar`'s `more` and `ToolbarMenus`' `more`: `(items, { line }) => items`.
|
|
163
|
+
- `ToolbarMenus` — the toolbar's menus as data, `ReadyToolbar`'s and `ListToolbar`'s `menus`: `view(items, { view })` (a view's menu: an option's own rows, Edit view… among them, and the menu a views list draws from the axis's verbs), `add(items)` (New's items: `addItems`, or with `onAdd` alone one row keyed `new`; New opens what it returns as a menu) and `more(items, { line })` (⋯'s rows, each keyed by its part, on the row's line or the filter bar's). The helpers, the keys and the rules are [`/list`'s Menus as data](./list.md#menus-as-data).
|
|
164
|
+
- `useListSettingsState` — a list's settings and layer held in memory, for an app that keeps none yet (a proof page, a test): `{ settings, layer? }` in, `{ settings, layer, onChange, onLayerChange }` out, ready to spread into `ReadyToolbar` beside its `columns`, or into a `ListRoot` ([`/list`](./list.md)): it is the root's memory mode. Each change is applied to the latest settings (`applySettingsChange`), each patch merged into the latest layer.
|
|
@@ -24,7 +24,7 @@ Import from `viewkitjs/views/panels` for what a list's panels read and say: the
|
|
|
24
24
|
- `DateRangeValue` — a range's two ends, each a `Date` or `null`.
|
|
25
25
|
- `ActivePanel` — which drill-in is open: a filter (and a Where field inside a relation's), group, sort, time scope, a date range, a toggle, layout, the Filter list, Columns, one column, or Group's by, sort and date-by pages.
|
|
26
26
|
- `ViewOptionInputs` — everything a Customize panel is handed: filters, sort, group, time scope, date ranges, toggles and layout; with and/or groups, the builder's `filterTree` too.
|
|
27
|
-
- `CollectionViewState` — the
|
|
27
|
+
- `CollectionViewState` — the view on screen, shared or the person's own (`own`): how far what this person sees drifted from it (`changes`, `stale`), whether they may publish, a write in flight, and the two verbs that settle the drift.
|
|
28
28
|
- `CollectionExportCsv` — a list's export, when it offers one: `count`, the rows it would take, which the Export CSV row shows, and `run`, which builds and downloads the file and says how it went.
|
|
29
29
|
- `isSortActive` — whether a sort differs from its default.
|
|
30
30
|
- `isGroupActive` — whether a list is grouped.
|
|
@@ -67,23 +67,24 @@ Import from `viewkitjs/views/panels` for what a list's panels read and say: the
|
|
|
67
67
|
|
|
68
68
|
What a list hands the views row ([`viewkitjs/views/panels/react`](panels-react.md) draws it).
|
|
69
69
|
|
|
70
|
-
- `ViewTabOption` — one view: its `value`, `label`, `count`, a status `slot` or your own `activeClassName`, its `icon` by your own glyph's name, whether it is `private`, and its verbs as `menu` (the package's menu rows, reached from the active view only); and, for a view's whole menu, its `layout` (by the axis's `verbs.layouts`), `changed` (it holds unsaved changes) and `
|
|
71
|
-
- `CollectionViewsConfig` — one axis of views: its `value`, `options`, `onChange`, `hideCounts`, `onCreate` and its `createLabel`, `onReorder` (one block in its new order, folded views included) and `canDrag`; and `verbs` (`ViewsViewVerbs`: `layouts`, `records`, a board's `columns` and one `onChange` taking every `ViewsViewChange` a view's menu makes), handed where your app lets a views list that can draw a view's whole menu (`CONTROLS.ViewsListBody`) draw it.
|
|
70
|
+
- `ViewTabOption` — one view: its `value`, `label`, `count`, a status `slot` or your own `activeClassName`, its `icon` by your own glyph's name, whether it is `private`, and its verbs as `menu` (the package's menu rows, reached from the active view only); and, for a view's whole menu, its `layout` (by the axis's `verbs.layouts`), `changed` (it holds unsaved changes), `favorite` and `readOnly` (nothing that changes it).
|
|
71
|
+
- `CollectionViewsConfig` — one axis of views: its `value`, `options`, `onChange`, `hideCounts`, `onCreate` and its `createLabel`, `onReorder` (one block in its new order, folded views included) and `canDrag`; and `verbs` (`ViewsViewVerbs`: `layouts`, `records`, a board's `columns` and one `onChange` taking every `ViewsViewChange` a view's menu makes), handed where your app lets a views list that can draw a view's whole menu (`CONTROLS.ViewsListBody`) draw it, and a views row's pill on a computer open it (`CONTROLS.ViewMenu`, VK-947).
|
|
72
72
|
- `CollectionViewsInput` — one axis, or an array of peer axes.
|
|
73
73
|
- `ViewsLayout` — how peer axes lay out: `stacked` (each after the first on a row of its own) or `inline`.
|
|
74
74
|
- `CollectionChildAxis` — a child axis whose options depend on the primary selection, as data, for a phone's sheet.
|
|
75
75
|
- `toViewAxes` — the array form of either arity.
|
|
76
76
|
- `splitViewAxes` — the axes split into the primary row and the row a stacked layout pushes beneath.
|
|
77
77
|
- `PillOption` — one of a `PillGroup`'s options: its `value`, `label`, `badge`, a leading glyph, your own active and hover classes, whether it is `private`, and its `menu`.
|
|
78
|
+
- `PillViewMenu` — a view's whole menu as a views row hands it to its pills and its "+N" rows (`PillGroup`'s and `ViewPickerRow`'s `viewMenu`): the axis's views as `ViewsListBody` is handed them, the view in use (`value`), its `verbs`, and `onDone` and `onHold` for what holds the pill.
|
|
78
79
|
|
|
79
80
|
## The toolbar's arrangement
|
|
80
81
|
|
|
81
82
|
Which form a toolbar draws and where each part stands in it; [`viewkitjs/views/panels/react`](panels-react.md)'s `Toolbar` draws it. Three forms: `row`, one line with the start and the end cluster and a second line beneath; `narrow`, for a box under 700px on a big screen, the search filling its own line with the end controls beside it and the views flowing on the line under it; and `phone`, one row with the views at the start, or the search filling the row when nothing stands at the start. A part marked as the search is the one the forms move; every other part stands where it asks.
|
|
82
83
|
|
|
83
|
-
The fold arrangement (`arrangeToolbar`'s `{ fold: true }`) is the kit's: on a computer the row (line 1) and, under it, the filter bar (line 2), a step smaller; on a phone one line holding the
|
|
84
|
+
The fold arrangement (`arrangeToolbar`'s `{ fold: true }`) is the kit's: on a computer the row (line 1) and, under it, the filter bar (line 2), a step smaller; on a phone one line holding the row's start in the order handed, the bar's start going in right after the views (first where there are none), then the row's and the bar's ends. It has no narrow form: a line with no room folds instead, in steps from its end: the words of every part that may `shed` them turn to its icon, then the view tabs fold into "+N" one at a time, then each part's filters fold into "+N filters" one at a time, then every part that may `fold` goes into ⋯.
|
|
84
85
|
|
|
85
86
|
- `ToolbarForm` — `"row"`, `"narrow"` or `"phone"`.
|
|
86
|
-
- `ToolbarPlacement` — where a part stands: its `key`, its `side` (`start`, the default, or `end`), its `line` (`1`, the default, or `2`) and `role: "search"` for the search (a second part marked as the search stands as a plain part) or `role: "separator"` for a line between the parts either side of it. In the fold arrangement, `shed` (its words may turn to its icon), `tabs` (how many of its view tabs may fold into "+N"), `filters` (how many of its filters may fold into "+N filters") and `fold` (it may fold into ⋯).
|
|
87
|
+
- `ToolbarPlacement` — where a part stands: its `key`, its `side` (`start`, the default, or `end`), its `line` (`1`, the default, or `2`) and `role: "search"` for the search (a second part marked as the search stands as a plain part) or `role: "separator"` for a line between the parts either side of it. In the fold arrangement, `shed` (its words may turn to its icon), `tabs` (how many of its view tabs may fold into "+N"), `filters` (how many of its filters may fold into "+N filters") and `fold` (it may fold into ⋯). And `words` (`"icon"`: its buttons stand as their icon alone; `"both"`: the search's, and a quick filters' button handed no word, read theirs; absent, each its own) and `foot` (`false` keeps New on a phone's folding line instead of at the list's foot), both reaching the part through its slot.
|
|
87
88
|
- `ToolbarSlot` — one part in a line: its `key`, and `fill` when it takes the line's room (the search as a field); in the fold arrangement also `shed`, `tabs`, `filters`, `fold`, `separator` and `search`, each only where it holds.
|
|
88
89
|
- `ToolbarLine` — one line: its `kind` (`main`, `search`, `views`, `below`, or the fold arrangement's `bar`), its `start` and `end` slots, and the `size` its buttons take (`md` or `sm`).
|
|
89
90
|
- `TOOLBAR_NARROW_BELOW` — the box width under which a toolbar is narrow (700).
|
|
@@ -102,6 +103,8 @@ What the toolbar owns over a list's settings:
|
|
|
102
103
|
- `countsToggle` — the toolbar's own Show counts as a `ToggleConfig` for the Options panel, worded `views.panels.show-counts`: absent when no option carries a number, or when the list's toggles already hold one keyed `show_counts`.
|
|
103
104
|
- `groupShown` — the list's `GroupConfig`, or nothing on a board: when the active layout (the phone's own on a phone) is one the layout's `hidesGroupFor` names.
|
|
104
105
|
- `withEditView` — the views with a row of yours (`ViewsMenuItem`, "Edit view…" in the ready toolbar, worded `views.panels.edit-view`) at the head of the active option's menu on every axis whose active option has a menu, the row after it carrying `separatorBefore`. One config in, one config out; an array, an array. Apply it once to the views your app hands in: applied twice, it adds the row twice.
|
|
106
|
+
- `withViewMenu` — the views with your function (`ViewMenuFn`) over every view's menu on every axis: each option's own rows (`menu`, Edit view… among them once `withEditView` has added it), handed the option as the view, and the axis's `verbs.menu`, for the menu a views list draws from them. One config in, one config out; without a function, what it was handed. The ready toolbar applies it for `menus.view`.
|
|
107
|
+
- `ViewMenuFn` — a view's menu as data: `(items, { view }) => items`, `ViewsViewVerbs.menu`'s type.
|
|
105
108
|
- `settingsCleared` — what a toolbar ✕ clears over a list's settings, as one `ListSettingsChange`, or `null` when nothing would change: `"filters"` the Filter panel's rows (with `{ phone: true }` and `filterGroups`, every rule and group too, since a phone's Filter opens the filter editor on all of them), `"options"` those, the sort (back to its default) and the group (to none) where Options shows it, and with `filterGroups` every rule and group of the filter but the top's set-aside rules (And/or groups, below): on a board the group is the table's and stays untouched, as `groupShown` says (pass `{ phone: true }` to read the phone's own layout). It takes the builder's input without its callbacks. Clearing the builder's rows through their own `onChange` hands several changes, the last of which clears them all (the rows of one build add up); this folds the clear through the builder and hands back one change.
|
|
106
109
|
|
|
107
110
|
## Quick filters
|
|
@@ -6,17 +6,18 @@ Import from `viewkitjs/views/react` in a client component: the door opens with t
|
|
|
6
6
|
|
|
7
7
|
Guide: [the provider](../guides/the-provider.md).
|
|
8
8
|
|
|
9
|
-
- `ViewsProvider` — the provider every view reads: mount it once at your app's client root, above every view,
|
|
9
|
+
- `ViewsProvider` — the provider every view reads: mount it once at your app's client root, above every view: `<ViewsProvider components={CONTROLS}>` at the least, and whatever of its icons, ports and conventions your app draws its own. It lays your atoms over the defaults (handed `CONTROLS` as it stands, over `CONTROL_ATOMS`, which it carries), hands your `Menu` its items with every row under a disabled group already disabled, and fills in the browser's own confirm where your ports carry no `confirm`. It hands its views one context value per distinct set of inputs, so pass module-level objects: a new one on each render re-renders every view.
|
|
10
10
|
- `ViewsProviderProps` — what the provider takes. Its optional `desktopQuery` is the media query that means a desktop, so an editor opens as a popover there and as a sheet elsewhere, the default controls take their phone form below it (`PhoneLine`), as do the toolbar's panels and the views picker outside a `Toolbar`, and the grid's own chrome takes its desktop form there (the grid's frame carries `data-desktop`); hand in the one your own shell switches on. Default `DEFAULT_DESKTOP_QUERY`. Its optional `sheetActions` (`ViewsSheetActionsPlace`, default `bar`) says where an editor's ✕ and ✓, and a toolbar panel's ✕, stand in that sheet. Its optional `escape` (`ViewsEscapeRules`) says what Escape does in an editor of each field type on a desktop, `"keep"` or `"cancel"`, a type left out cancelling. Its optional `selectionBar` (`ViewsSelectionBarSettings`) says where the selection bar sits. Its optional `oneValue` (`ViewsOneValueEditors`) says whether a single email or domain opens the text box in its cell (the default) or the value list holding one value, in the grid and a field row alike. Its optional `datePicks` (`ViewsDatePicks`) names the quick days the date editors offer, in order; absent, today, tomorrow and next Monday. Its optional `now` (a `Date`) is the moment every date counts from; absent, the provider reads the clock after mount, then once a minute and when the tab comes back into view, never while rendering, and a date that needs it draws its full form until the first read.
|
|
11
11
|
- `EditEscape` — `"cancel" | "keep"`: what Escape does in an edit session (`viewkitjs/views/editors/session` hands it on too).
|
|
12
12
|
- `ViewsEscapeRules` — the provider's `escape`: an `EditEscape` per field type, and for `email`, `phone`, `url` and `domain` either one `EditEscape`, which covers both of their editors, or an `EditEscapeByEditor`.
|
|
13
13
|
- `EditEscapeByEditor` — `{ box?: EditEscape; list?: EditEscape }`: what Escape does in an email, phone, link or domain field by the editor it opens, `box` its text box (a single value) and `list` the value list (several values, or a single one `oneValue` opens as a list of one). One left out throws the edit away.
|
|
14
14
|
- `ViewsOneValueEditors` — `Partial<Record<"email" | "domain", "text" | "list">>`, the provider's `oneValue`.
|
|
15
15
|
- `DEFAULT_DESKTOP_QUERY` — `(min-width: 1024px)`: the width a desktop starts at when the provider is handed no `desktopQuery`, the default controls' phone line too (`PhoneLine`, in controls.md). Where the screen can't be asked (a server render, a browser with no `matchMedia`), it is a desktop.
|
|
16
|
-
- Required: `components` (your primitives, `ViewsComponents
|
|
17
|
-
-
|
|
16
|
+
- Required: `components` (your primitives, `ViewsComponents`: `CONTROLS`, or it with your own spread after it, or every one of your own) and `children`.
|
|
17
|
+
- Defaulted (VK-198): `icons` (your glyphs by meaning, `ViewsIcons`; absent, each meaning drawn through your `AppIcon` by its name, which `CONTROLS.AppIcon` draws with ViewKit's own glyphs); `ports` (your runtime services, `ViewsPorts`, each optional: absent, haptics that do nothing, the browser's clipboard, a store on `localStorage` at the package's `vk:` keys, and the toast and confirm `PortsHost` draws); `conventions` (the `FieldConventions` of `viewkitjs/fields` every value is read with; absent, `en-US` in `UTC`, the same on the server and in the browser). What you hand wins.
|
|
18
|
+
- Optional: `atoms`, any of your own atoms, each laid over the default of its name, or over `CONTROL_ATOMS`' where `components` is `CONTROLS` as it stands (a map spread from it carries none); `messages`, your wording for the package's own messages, defaulting to `resolveViewsMessage` (the package's English); `presentation`, `(defaults: FieldPresentation) => FieldPresentation`, how your numbers, dates and durations read: given the package's defaults in the conventions' locale, return yours. It is called where a value is drawn, so your provider imports none of the display.
|
|
18
19
|
- `useViews` — reads the nearest provider's value inside a view or an atom of your own. It throws an error that says where to mount one when no `ViewsProvider` is above it.
|
|
19
|
-
- `ViewsContextValue` — what `useViews` returns: the `components` (your `Menu` wrapped to settle disabled groups), the merged `atoms`, the `icons`, the `ports` as `ViewsResolvedPorts` (
|
|
20
|
+
- `ViewsContextValue` — what `useViews` returns: the `components` (your `Menu` wrapped to settle disabled groups), the merged `atoms`, the `icons`, the `ports` as `ViewsResolvedPorts` (every port there, yours or its default), the `messages` resolver, the `conventions`, your `presentation` when you handed one, and the `desktopQuery` in force (yours or `DEFAULT_DESKTOP_QUERY`); `escape` and `oneValue` when you handed them; `selectionBar` and `datePicks` when you handed them. The provider's moment (`now`) isn't in it: what draws a date reads it, so a new moment redraws only those.
|
|
20
21
|
- `NOOP_PORTS` — ports that do nothing, for a server render, a test or an app without a device: the toasts and haptics are empty, the clipboard writes nothing (resolving `false`) and reads `null`, and the prefs store keeps nothing. It carries no `confirm`, so the provider falls back to `PortsHost`'s or the browser's.
|
|
21
22
|
- `NOOP_TOAST` — the toast that draws nothing, `NOOP_PORTS`' own: what `useViews().ports.toast` is where an app hands no toast and no `PortsHost` stands.
|
|
22
23
|
|
|
@@ -36,7 +37,7 @@ The primitives your app hands in, modelled on Base UI's shapes: a controlled `op
|
|
|
36
37
|
- `ViewsTooltipProps` — a tooltip around the element it wraps (`children`), showing `content`, with `side`, `align`, `delayMs` and a class. Your app mounts one tooltip provider above the views; a tooltip never mounts its own.
|
|
37
38
|
- `ViewsCheckboxProps` — a checkbox: `checked`, and `indeterminate` for a box ticked partly, whose press hands `true` while `checked` is false. `onCheckedChange` hands the new value and, where your library reports it, `{ event }`, the press that changed it (a list reads its shift key for a range). `partialTone` colours the partial mark, `muted` by default or `brand` for a select-all with a live selection; with `disabled`, `readOnly` (shown as it is and not pressable: a yes/no the grid or a field row can't write), a class, `tabIndex` and `aria-label`.
|
|
38
39
|
- `ViewsMenuProps` — a menu opened at an `anchor`, with no trigger child (a group opens beside it only where it asks to and your menu can), controlled by `open` and `onOpenChange`, drawing its `items`, placed by `side` and `align`, and named by `label`, its accessible name, which every menu the package opens hands. On Base UI it is the menu's root, positioner and popup, the anchor handed to the positioner.
|
|
39
|
-
- `ViewsMenuItem` — one row of a menu, as data your `Menu` draws: its `key`, `label` (always words), `icon`, `onSelect`, `disabled` with an optional `disabledReason` (why, for you to show), and `destructive`, a `separatorBefore`, a `shortcut` hint drawn at its end and never bound, and an `href` that makes it a link (with `onSelect` still firing). A `checked` row is checkable and closes the menu like any row, unless it carries `keepOpen`. A row with `children` is a group: its rows drawn in place under its label, unless it carries `beside` (open them one level in), its own `onSelect`, `href` and `checked` ignored; a disabled group's rows reach your `Menu` already `disabled`, with the group's reason where they give none. Any row may carry `detail`, its current value in words, for its end. All three are hints: a menu that draws none of them keeps every group in place and every row closing.
|
|
40
|
+
- `ViewsMenuItem` — one row of a menu, as data your `Menu` draws: its `key`, `label` (always words), `icon`, `onSelect`, `disabled` with an optional `disabledReason` (why, for you to show), and `destructive`, a `separatorBefore`, a `shortcut` hint drawn at its end and never bound, and an `href` that makes it a link (with `onSelect` still firing). A `checked` row is checkable and closes the menu like any row, unless it carries `keepOpen`. A row with `children` is a group: its rows drawn in place under its label, unless it carries `beside` (open them one level in), its own `onSelect`, `href` and `checked` ignored; a disabled group's rows reach your `Menu` already `disabled`, with the group's reason where they give none. Any row may carry `detail`, its current value in words, for its end. A plain row may carry `render`, which draws its inside in place of its icon, words, keys and count (`label` still its name; called while the menu draws, so it may call no hooks). All three are hints: a menu that draws none of them keeps every group in place and every row closing.
|
|
40
41
|
- `ViewsCommandParts` — the command list's parts, the shape cmdk-based copies already have: `Root` (taking `label`, `shouldFilter` false to hand filtering to the host, a scoring `filter`, `loop` to wrap the arrows, and `defaultValue`, the value of the item highlighted as the list opens, none while no item has it), `Input` (a controlled `value` with `onValueChange`, a `placeholder`, `autoFocus`, a `ref`, `onKeyDown`, and `chrome` `search` for your search row or `bare` for the input alone), `List`, `Empty`, `Group` (with a `heading`) and `Item` (a `value`, `onSelect`, `disabled`, and `chosen`, which you colour as your chosen row while the package's row inside draws the check).
|
|
41
42
|
- `ViewsPickerProps` — a whole pick list your app draws, its search, rows, empty row and create row: its `label` (the field's name), `items`, `multiple`, `value` (one value or `null`; several, a list), `onValueChange` (the pick, `null` for the empty row, or the whole new list on every change; nothing is saved until the editor closes), `onDone` (a pick of one is made), `empty` (the empty row's words; absent, a value of one can't be emptied), `search` (its words before anything is typed), `onCreate` (handed what was typed, returns the value it makes, which you then pick or add), `typed` (what was typed on what opened it: on a computer, light its first match, so Enter picks it), `autoFocus`, `keyed` (opened by a key: on a computer, light the held row as it opens and let ↓ go on from it to the next), `fromHeld` (opened by a press, before a row is lit: ↓ and ↑ go on from the held row, to the next or the one before, nothing drawn lit until then), `form`, `computer` or `phone` (on a phone, draw no ✕, ✓ or Cancel of your own and hand every change as it is made), and for a relation `onSearch` (the editor filters or fetches: hand it every typed query and draw `items` as handed), `doing` (`searching` or `failed`; `searching` from the keystroke until the typed query answers, its `items` meanwhile the held records that match it alone), `onRetry`, `onMore`, `actions` (`ViewsPickerAction` rows after the rows) and `lead` (which held value leads, `onLead`, `label` and `makeLabel`); and, where your app adds options to a select's or multiselect's list, `onAdd` (draw an add row after the matches and call it with the typed text; handed instead of `onCreate`), `adding` (the text being added: draw its row as waiting, not pressable) and `addRefused` (your app's refusal, or the failure's words, to show where the add row was). A body that draws none of them offers no add. A status field's `steps`: its active steps by value, in order, so a held archived option is placed nowhere, as its cell places it.
|
|
42
43
|
- `ViewsPickerItem` — one row of a picker body, as data: its `value` and `label`, a status `slot` (draw your status badge) or a category `color` (draw your option chip), an `icon` (your glyph's name, as `AppIcon` draws it), a quieter `line`, the `group` it stands under, `disabled`, and for a relation's record a `badge` (a word telling kinds apart), a `glyph` (the record's own, unsized), an `avatarUrl` and its `kind`.
|
|
@@ -63,8 +64,9 @@ The primitives your app hands in, modelled on Base UI's shapes: a controlled `op
|
|
|
63
64
|
- `ViewsFilterPartBodyProps` — a filter rule's way or value your app draws: `part` (`way` or `value`), `label`, `rule` (the rule as data), `field` (the field it names, a `ViewsFilterBodyField` with no `far`), `ways` (each its operator and its words), `own` (ViewKit's own value body; null at `way`), `form`, `onRuleChange` (the rule with its new way, written as ViewKit's own writes one, or its new value; another field or part, a way its field doesn't offer or a value its way can't hold writes nothing) and `onDone` (what holds it closes).
|
|
64
65
|
- `ViewsSearchFieldProps` — the toolbar's search box your app draws: `value`, `onChange` (every keystroke), `placeholder`, `label` (its name to a screen reader), `searching` and `searchingLabel` (draw a spinner where your glass is, the box still usable), `onClear` (empties the search, and closes it where `closes`), `clearLabel` (your clear's name: "Close search" where it closes, "Clear" where it only clears), `closes` (opened from its button: your clear stands while it is open, empty or not; filling its line: show it only with a value), `form` (`computer` or `phone`) and `fill` (it fills its line).
|
|
65
66
|
- `ViewsViewsListBodyProps` — the views list's whole body your app draws: `label`, `views` (each a `ViewsViewsListItem`), `value` (the view in use), `form`, `onViewChange` (a view picked; written when it is one of `views`; it closes nothing), `onCreate` and `createLabel` where the axis grows (what holds it closes first), `onReorder` and `canDrag` where the axis reorders (one whole block, shared or the reader's own, each once; any other order writes nothing), `onDone` (what holds it closes), on a phone where the sheet's head doesn't draw it `actions` (the ✕, and Back while the body stands on a step), on a computer `onHold` (while true, a press outside and Escape close nothing: the body asks outside the list), on a phone `onStepChange` (the body stands on a step of its own: the sheet shows its title and Back), and, where the axis hands them, `verbs` (a view's whole menu's data, `ViewsViewVerbs`).
|
|
66
|
-
- `ViewsViewsListItem` — one view as the views list's body is handed it: `value`, `label`, `icon`, `count` (absent while counts are hidden), `private`, `menu` (the view's own verbs), and for a view's whole menu `layout`, `changed` and `
|
|
67
|
-
- `
|
|
67
|
+
- `ViewsViewsListItem` — one view as the views list's body is handed it: `value`, `label`, `icon`, `count` (absent while counts are hidden), `private`, `menu` (the view's own verbs), and for a view's whole menu `layout`, `changed`, `favorite` and `readOnly` (nothing that changes it).
|
|
68
|
+
- `ViewsViewMenuProps` — one view's whole menu your app may draw (`ViewMenu`, optional; `CONTROLS.ViewMenu` is ViewKit's own), opened on a computer by a views row's pill and a folded view's `⋮` where the axis hands `verbs`: `open`, `onOpenChange`, `anchor` and `align`, as `Menu` is; `view` (whose menu it is; left out, New view's Modal stands in place of a menu, as the row's + opens it, and `onOpenChange(false)` is told once it has closed), `views` (every view of the axis, each a `ViewsViewsListItem`), `value` (the view in use), `verbs`, `onDone` (what holds it closes) and `onHold` (while true, a press outside and Escape close nothing: the menu asks outside what holds it).
|
|
69
|
+
- `ViewsViewVerbs` — a view's verbs, handed on the axis where your app lets ViewKit draw a view's whole menu: `layouts`, `records` (the noun in the delete question's line), a board's `columns`, and `onChange`, which takes each `ViewsViewChange` and opens the right view itself (ViewKit moves none: `viewsAfter` does it); optionally `menu`, the view's menu as data, handed its default items and the view and returning the items drawn ([`/list`'s Menus as data](./list.md#menus-as-data)).
|
|
68
70
|
- `ViewsViewChange` — a change a view's menu makes: rename, create (with its layout, name, a board's columns and the view it was made from), duplicate, delete, restore (Undo: the view, its place, whether it was open), save, reset, edit, link, favorite, private.
|
|
69
71
|
- `ViewsViewLayout` — a layout a new view can take: `id`, `name`, `icon` (your `AppIcon`'s name), `line`, and `columns` where it asks which field makes its columns.
|
|
70
72
|
- `ViewsViewRecord` — a view as a restore hands it back: `id`, `name`, `layout`, and `private`, `favorite`, `changed`, `count` where it has them.
|
|
@@ -72,7 +74,7 @@ The primitives your app hands in, modelled on Base UI's shapes: a controlled `op
|
|
|
72
74
|
- `ViewsGroupDimension` — a field a list can be grouped by: `value`, `label`, `orderOptions` (each its mode, words and `defaultDir`), `defaultOrder`, and a date's `granularities` with `defaultGranularity`.
|
|
73
75
|
- `ViewsGroupValue` — a list's group as one value: `value` (the field grouped by, or `none`), `order` (the active field's `mode` and `dir`), `granularity`, `hideEmpty` and `groups` (each a `ViewsGroupEntry`, in the order the list shows them).
|
|
74
76
|
- `ViewsGroupEntry` — one group: `key`, `label`, `empty`, `hidden`, and its `count` where the list counts it.
|
|
75
|
-
- `ViewsCustomizeBodyProps` — Customize's whole body your app draws: `label`, `page` and `onPageChange` (a `ViewsCustomizePage`), `layout` (a `ViewsCustomizeLayout`), `columns` (`ViewsCustomizeColumns`), `filter` (`FilterBody`'s props on the whole filter, without `form`, `onDone` and `actions`), `sort` (`SortBody`'s, likewise), `group` (`GroupBody`'s, likewise), `toggles` (each a `ViewsCustomizeToggle`, Show counts among them), `view` (on a shared view
|
|
77
|
+
- `ViewsCustomizeBodyProps` — Customize's whole body your app draws: `label`, `page` and `onPageChange` (a `ViewsCustomizePage`), `layout` (a `ViewsCustomizeLayout`), `columns` (`ViewsCustomizeColumns`), `filter` (`FilterBody`'s props on the whole filter, without `form`, `onDone` and `actions`), `sort` (`SortBody`'s, likewise), `group` (`GroupBody`'s, likewise), `toggles` (each a `ViewsCustomizeToggle`, Show counts among them), `view` (on a shared view, or the person's own with `own`: `changes`, `stale`, `canPublish`, `pending`, `onReset`, `onPublish`), `foot`, `onClear`, `clearAll`, `form`, `onDone` and, on a phone where the sheet's head doesn't draw it, `actions` (the ✕). `fields` (`ViewsCustomizeFields`): a list's per-field filters, its time range and its date ranges.
|
|
76
78
|
- `ViewsCustomizePage` — where a Customize body stands: `list`, `layout`, `columns`, `filter`, `sort` or `group`.
|
|
77
79
|
- `ViewsCustomizeLayout` — the layouts (`options`, `refused` with reasons, `value`, `onLayoutChange`) and the layout in use's `toggles`, `choices`, `density` and the reader's own `personal` settings.
|
|
78
80
|
- `ViewsCustomizeFields` — a list's per-field filters, its time range and its date ranges: `folded` (behind one Filter row, or each its own row) and `items`, each a `ViewsCustomizeField`.
|
|
@@ -155,7 +157,7 @@ The pieces the rendering is built from, and your app's own pieces it cannot draw
|
|
|
155
157
|
- `ViewsRangeCalendarProps` — the filter panel's month, in ISO days: `mode` (`single` or `range`), `from`, `to`, `onSelect` (the selection a press makes, and the day pressed), `armed` (the end the next press sets), `limit`, a painted `window`, `minNights`, a `footer`, `cellSize`, `locale` and `className`. The default is the map's one-day `Calendar` on the end being picked; hand your own to paint a range.
|
|
156
158
|
- `ViewsSelectionSheetProps` — the phone's sheet of a selection's verbs, opened by the selection bar's Actions: `open`, `onOpenChange`, `title` ("3 selected"), the `verbs`, `onDelete` and `deleteLabel` for the bar's own delete, drawn last, and `busy`. The default draws a disabled verb's `disabledReason` as its row's second line, none while `busy`. Picking a row closes the sheet, then runs it.
|
|
157
159
|
- `ViewsRowMenuProps` — the row's right-click menu, around the row it opens on (`children`): opened by a right-click on the row or by its ⋯, it lists an Open page row for `openHref` (a new tab), the `items` the rendering built, and a Delete row when `onDelete` is given, called with `rowId` once the confirm port says yes, with `deleteLabel` as its `subject`. A delete that rejects says so through the toast port's `error`. `onToggleSelect` flips the row's selection, for an app whose long-press selects; with `GridTable`'s `phonePicking` on, a call that answers a long press still held ticks the pressed row once with the grid's own, never flipping it back, and with no press held it flips the row last pressed. The default doesn't use it, and without `phonePicking` a long-press on a phone opens nothing.
|
|
158
|
-
- `ViewsRowMenuItem` — one row of the row's menu, the shape a host's own row-menu items already have: a rule (`{ separator: true }`), or a row with its `label`, `icon`, `onClick`, `destructive`, `disabled
|
|
160
|
+
- `ViewsRowMenuItem` — one row of the row's menu, the shape a host's own row-menu items already have: a rule (`{ separator: true }`), or a row with its `label`, `icon`, `onClick`, `destructive`, `disabled`, a `shortcut` hint drawn at its end and never bound, and an optional `key`, by which `menus.row` finds it (its words, without one).
|
|
159
161
|
- `ViewsRelationLinkProps` — where a relation chip goes: the `relation` value and the chip the display drew as `children`, for your app's own link around it. The default goes nowhere, since a relation is a fact as often as a destination.
|
|
160
162
|
- `ViewsRelationRolesProps` — a link's roles, drawn inside its chip after the record's name, on a `many` relation that declares `links`: the `relation` value and its `roles` in order, each its stored `value` and its `label` (the field's, else the value). Handed only when the link holds one or more. The default draws the labels in the subtle colour after a middle dot, cut before the name in a narrow cell, and names the record and every role on hover.
|
|
161
163
|
- `ViewsCellMoreProps` — the count after a cell's shown values: `count`, how many are not shown, and `inert`, true where the host owns the click (the count is plain text, and nothing opens). Drawn inside `data-slot="vk-cell-more"`, a button that opens the whole list. The default, `DefaultCellMore`, draws "+" and the number, and ViewKit keeps its own frame on that element only for it; yours draws inside a bare button (or span), so a count tag of yours stands there alone.
|