viewkitjs 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/query/evaluate.d.ts +7 -0
- package/fields/dist/query/exact-number.d.ts +8 -2
- package/fields/dist/query/exact-number.js +14 -1
- package/fields/dist/query/sort.js +13 -10
- package/fields/dist/registry.js +5 -1
- package/fields/dist/types.d.ts +4 -1
- package/fields/dist/zod.d.ts +5 -0
- package/fields/dist/zod.js +10 -1
- package/fields/docs/guides/contact-values.md +12 -0
- package/fields/docs/guides/field-types.md +1 -1
- package/fields/docs/guides/queries.md +3 -1
- package/fields/docs/reference/fields.md +1 -0
- package/package.json +1 -1
- package/postgres/dist/check.js +4 -1
- package/postgres/dist/definitions/formula-forms.js +3 -1
- package/postgres/dist/definitions/money.js +2 -1
- package/postgres/dist/page.js +6 -3
- package/postgres/dist/rules.d.ts +15 -1
- package/postgres/dist/rules.js +16 -0
- package/postgres/dist/sort.js +7 -2
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +1 -1
- package/postgres/docs/reference/definitions.md +1 -1
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +4 -3
- package/views/dist/atoms/frame-parts.d.ts +6 -0
- package/views/dist/atoms/frame-parts.js +15 -0
- package/views/dist/atoms/types.d.ts +16 -7
- package/views/dist/cells/cell-title.d.ts +3 -1
- package/views/dist/cells/cell-title.js +2 -2
- package/views/dist/cells/cell-values.js +2 -2
- package/views/dist/contract.d.ts +31 -6
- package/views/dist/contract.js +123 -0
- package/views/dist/controls/button/map-button.js +2 -0
- package/views/dist/controls/checkbox/checkbox.d.ts +3 -2
- package/views/dist/controls/checkbox/checkbox.js +2 -2
- package/views/dist/controls/compound-editor/compound-editor.d.ts +1 -1
- package/views/dist/controls/compound-editor/name-parts.js +4 -4
- package/views/dist/controls/compound-editor/place-parts.js +19 -19
- package/views/dist/controls/compound-editor/range-parts.js +14 -14
- package/views/dist/controls/compound-editor/row.d.ts +3 -1
- package/views/dist/controls/compound-editor/row.js +2 -2
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/customize/customize.js +37 -35
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -0
- package/views/dist/controls/customize/map-customize-body.js +4 -0
- package/views/dist/controls/date-editor/date-days.js +2 -2
- package/views/dist/controls/date-editor/date-editor.js +18 -18
- package/views/dist/controls/date-editor/date-parts.js +6 -6
- package/views/dist/controls/date-editor/map-calendar.js +1 -1
- package/views/dist/controls/date-editor.css +2 -2
- package/views/dist/controls/field/field.d.ts +3 -0
- package/views/dist/controls/field/field.js +6 -6
- package/views/dist/controls/filter-editor/block.d.ts +2 -2
- package/views/dist/controls/filter-editor/block.js +5 -5
- package/views/dist/controls/filter-editor/filter-editor.js +31 -33
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +1 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -3
- package/views/dist/controls/filter-editor/map-rules.js +1 -1
- package/views/dist/controls/filter-editor/parts.js +2 -1
- package/views/dist/controls/group-editor/group-editor.js +15 -13
- package/views/dist/controls/index.d.ts +2 -0
- package/views/dist/controls/index.js +1 -0
- package/views/dist/controls/input/input.js +2 -2
- package/views/dist/controls/input/map-input.js +2 -0
- package/views/dist/controls/internal/editor-parts.js +1 -1
- package/views/dist/controls/internal/map-panel-controls.d.ts +8 -0
- package/views/dist/controls/internal/map-panel-controls.js +20 -0
- package/views/dist/controls/internal/panel-controls.d.ts +50 -0
- package/views/dist/controls/internal/panel-controls.js +197 -0
- package/views/dist/controls/internal/part-slot.d.ts +12 -0
- package/views/dist/controls/internal/part-slot.js +5 -0
- package/views/dist/controls/links-editor/links-editor.d.ts +1 -1
- package/views/dist/controls/links-editor/links-editor.js +27 -27
- package/views/dist/controls/menu/map-menu.d.ts +2 -2
- package/views/dist/controls/menu/map-menu.js +15 -12
- package/views/dist/controls/menu/menu.d.ts +2 -0
- package/views/dist/controls/menu/menu.js +3 -3
- package/views/dist/controls/menu-list/menu-list.d.ts +14 -4
- package/views/dist/controls/menu-list/menu-list.js +23 -22
- package/views/dist/controls/notice/notice.d.ts +3 -1
- package/views/dist/controls/notice/notice.js +2 -2
- package/views/dist/controls/number-editor/number-editor.d.ts +1 -1
- package/views/dist/controls/number-editor/number-editor.js +13 -13
- package/views/dist/controls/number-field/number-field.js +5 -3
- package/views/dist/controls/pane/pane.d.ts +4 -2
- package/views/dist/controls/pane/pane.js +4 -4
- package/views/dist/controls/picker/picker.d.ts +2 -0
- package/views/dist/controls/picker/picker.js +37 -36
- package/views/dist/controls/picker/rows.d.ts +4 -0
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +4 -2
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/radio/radio.d.ts +3 -0
- package/views/dist/controls/radio/radio.js +4 -3
- package/views/dist/controls/select/map-select.d.ts +3 -0
- package/views/dist/controls/select/map-select.js +8 -0
- package/views/dist/controls/select/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +3 -3
- package/views/dist/controls/sheet/bottom-sheet.d.ts +5 -1
- package/views/dist/controls/sheet/bottom-sheet.js +2 -2
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/sort-editor/map-sort-body.d.ts +1 -0
- package/views/dist/controls/sort-editor/map-sort-body.js +7 -3
- package/views/dist/controls/sort-editor/sort-editor.js +24 -26
- package/views/dist/controls/sort-editor.css +5 -0
- package/views/dist/controls/text-editor/text-editor.d.ts +1 -1
- package/views/dist/controls/text-editor/text-editor.js +8 -8
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +3 -3
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +7 -6
- package/views/dist/controls/values-editor/values-editor.d.ts +1 -1
- package/views/dist/controls/values-editor/values-editor.js +22 -22
- package/views/dist/controls/views-list/map-view-menu.js +1 -1
- package/views/dist/controls/views-list/view-menu.js +6 -6
- package/views/dist/controls/views-list/views-list.js +4 -4
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +13 -0
- package/views/dist/fields/money.d.ts +5 -2
- package/views/dist/fields/money.js +14 -2
- package/views/dist/grid/chrome/GridTable.js +4 -1
- package/views/dist/grid/chrome/cell-clipboard.d.ts +4 -2
- package/views/dist/grid/chrome/cell-clipboard.js +2 -2
- package/views/dist/grid/chrome/cells.js +3 -1
- package/views/dist/grid/chrome/grid-row-menu-items.js +1 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +29 -6
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +9 -2
- package/views/dist/grid/core/clipboard-model.d.ts +3 -1
- package/views/dist/grid/core/clipboard-model.js +9 -8
- package/views/dist/grid/core/editing-controller.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.js +6 -0
- package/views/dist/grid/core/edits-sink.d.ts +19 -0
- package/views/dist/grid/core/edits-sink.js +2 -0
- package/views/dist/grid/core/spreadsheet-operations.js +1 -1
- package/views/dist/grid/core/useGridEditing.d.ts +5 -0
- package/views/dist/grid/core/useGridEditing.js +6 -0
- package/views/dist/list/answer.d.ts +40 -0
- package/views/dist/list/answer.js +43 -0
- package/views/dist/list/bulk-bar.d.ts +7 -0
- package/views/dist/list/bulk-bar.js +10 -0
- package/views/dist/list/columns.d.ts +24 -0
- package/views/dist/list/columns.js +27 -0
- package/views/dist/list/edits.d.ts +19 -0
- package/views/dist/list/edits.js +56 -0
- package/views/dist/list/grid.d.ts +11 -0
- package/views/dist/list/grid.js +76 -0
- package/views/dist/list/index.d.ts +14 -1
- package/views/dist/list/index.js +4 -1
- package/views/dist/list/link.d.ts +8 -0
- package/views/dist/list/link.js +78 -0
- package/views/dist/list/list.d.ts +70 -0
- package/views/dist/list/list.js +14 -0
- package/views/dist/list/parts.js +10 -3
- package/views/dist/list/root-base.d.ts +46 -0
- package/views/dist/list/root-base.js +137 -0
- package/views/dist/list/root.d.ts +35 -34
- package/views/dist/list/root.js +153 -113
- package/views/dist/list/source-answers.d.ts +39 -0
- package/views/dist/list/source-answers.js +225 -0
- package/views/dist/list/store.d.ts +37 -5
- package/views/dist/list/store.js +31 -0
- package/views/dist/list/toolbar.d.ts +3 -2
- package/views/dist/list/toolbar.js +14 -2
- package/views/dist/list/views-axis.js +4 -2
- package/views/dist/list/views.d.ts +7 -2
- package/views/dist/list/views.js +16 -5
- package/views/dist/model/column-capabilities.d.ts +13 -0
- package/views/dist/model/column-capabilities.js +23 -2
- package/views/dist/model/column-schema.d.ts +11 -1
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/model.d.ts +2 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +8 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +2 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +8 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +12 -3
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarAsideFilter.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -4
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilter.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterSheet.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/context.d.ts +10 -1
- package/views/dist/panels/react/toolbar/panel-part.d.ts +4 -1
- package/views/dist/panels/react/toolbar/panel-part.js +5 -3
- package/views/dist/panels/settings/filter-groups.js +6 -1
- package/views/dist/provider/ViewsProvider.d.ts +6 -2
- package/views/dist/provider/ViewsProvider.js +18 -1
- package/views/dist/provider/components.d.ts +59 -0
- package/views/dist/provider/components.js +1 -1
- package/views/dist/provider/context.d.ts +4 -1
- package/views/dist/provider/own-control.d.ts +4 -0
- package/views/dist/provider/own-control.js +7 -0
- package/views/dist/provider/select-items.d.ts +3 -0
- package/views/dist/provider/select-items.js +6 -0
- package/views/dist/react.d.ts +4 -2
- package/views/dist/react.js +2 -0
- package/views/dist/styles.css +86 -78
- package/views/dist/styles.unlayered.css +86 -78
- package/views/docs/contract.md +252 -5
- package/views/docs/controls/compound-editor.md +4 -0
- package/views/docs/controls/customize.md +6 -0
- package/views/docs/controls/date-editor.md +4 -0
- package/views/docs/controls/field.md +4 -0
- package/views/docs/controls/filter-editor.md +8 -0
- package/views/docs/controls/group-editor.md +6 -0
- package/views/docs/controls/input.md +4 -0
- package/views/docs/controls/links-editor.md +4 -0
- package/views/docs/controls/menu-list.md +8 -0
- package/views/docs/controls/menu.md +4 -0
- package/views/docs/controls/notice.md +4 -0
- package/views/docs/controls/number-editor.md +4 -0
- package/views/docs/controls/pane.md +4 -0
- package/views/docs/controls/picker.md +8 -0
- package/views/docs/controls/quick-filters.md +6 -0
- package/views/docs/controls/radio.md +4 -0
- package/views/docs/controls/select.md +8 -0
- package/views/docs/controls/sheet.md +4 -0
- package/views/docs/controls/sort-editor.md +8 -0
- package/views/docs/controls/text-editor.md +4 -0
- package/views/docs/controls/values-editor.md +4 -0
- package/views/docs/controls/views-list.md +6 -0
- package/views/docs/guides/the-grid.md +2 -2
- package/views/docs/guides/the-provider.md +19 -2
- package/views/docs/reference/controls.md +7 -5
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +1 -1
- package/views/docs/reference/list.md +141 -11
- package/views/docs/reference/panels-react.md +2 -2
- package/views/docs/reference/react.md +15 -9
- package/views/docs/reference/views.md +8 -4
- package/views/docs/reshaping.md +6 -1
|
@@ -560,7 +560,7 @@ assert.equal(fieldKeyOf(valueColumn), "value");
|
|
|
560
560
|
|
|
561
561
|
## A list's locks
|
|
562
562
|
|
|
563
|
-
Three layers decide whether a cell may be written, and each only takes away from the one before: the column's declaration, your workspace's settings for the list, and a person's preferences. The settings are a `ListSettingsConfig` you store and hand the grid as `listConfig`: `readOnly` for the whole list, or a lock per field under `columns`. A locked column refuses every write, by every route, and still sorts, hides and resizes; a read-only list says so with a badge in its header. `toggleListColumnLock` and `toggleListReadOnly` build the config, sparse.
|
|
563
|
+
Three layers decide whether a cell may be written, and each only takes away from the one before: the column's declaration, your workspace's settings for the list, and a person's preferences. The settings are a `ListSettingsConfig` you store and hand the grid as `listConfig`: `readOnly` for the whole list, or a lock per field under `columns`. A locked column refuses every write, by every route, and still sorts, hides and resizes; a lock on a worked-out field edited through a stored one (`editThrough`), or on that stored field, locks both, since an edit of one writes the other (`withEditThroughLocks`); a read-only list says so with a badge in its header. `toggleListColumnLock` and `toggleListReadOnly` build the config, sparse.
|
|
564
564
|
|
|
565
565
|
A reader who may edit some records and not others is answered per row: hand the grid `rowWritable`, `(row) => boolean`. A row it refuses opens no editor and takes no typing, paste, fill, clear, cut or bulk-bar write, its cells marked `aria-readonly` and a person's try answered "Cell is read-only"; a range over it writes the other rows and says how many cells it refused. It only takes away, and your API still guards its own writes.
|
|
566
566
|
|
|
@@ -713,7 +713,7 @@ The grid styles through attributes, never class names: each part carries a `data
|
|
|
713
713
|
A surface of your own beside the grid reads values the way the grid does with these.
|
|
714
714
|
|
|
715
715
|
- `cellEditBaseline(column, row)` is a cell's value as an editor and a copy see it: the column's raw edit value where it declares one, else what it draws.
|
|
716
|
-
- `cellCopyText(column, value)` is that value as the clipboard writes it: a relation by its label, an option by its label, several values joined with commas, a name or a place as its cell writes it, a range as "11–50", or as its band's name when its ends are exactly a preset's. A CSV export reuses the two, so its cells read as a copy from the grid does.
|
|
716
|
+
- `cellCopyText(column, value)` is that value as the clipboard writes it: a relation by its label, an option by its label, several values joined with commas, a name or a place as its cell writes it (a place's country in the names language you pass as its third argument, `conventions.language`, English without one), a range as "11–50", or as its band's name when its ends are exactly a preset's. A CSV export reuses the two, so its cells read as a copy from the grid does.
|
|
717
717
|
- `deriveGridSelectValues(columns, rows)` is the values each option column offers, by column id: its active options in declared order, then any other value its rows hold. `{ includeArchived: true }` keeps archived options, for a filter that must still find a row holding one.
|
|
718
718
|
- `deriveGridRelationValues(columns, rows)` is the records each relation column's rows point at, by column id, as `{ id, label }` in alphabetical order: what a filter offers is what the list holds, never every record that could be linked.
|
|
719
719
|
- `GRID_TITLE_LINK_CLASS` is the class a title cell wears: the element marked `data-cell-open` inside it, the text that opens the row, takes the brand colour and an underline on its own hover. A title you draw beside the grid wears it to read the same. In the grid that element is also the part `vk-grid-title`, which your app styles at rest and under the pointer (the contract's Slots).
|
|
@@ -4,7 +4,7 @@ Every view reads what it takes from its app, other than its own props, from one
|
|
|
4
4
|
|
|
5
5
|
## Mount it once
|
|
6
6
|
|
|
7
|
-
`ViewsProvider` sits once at your app's client root, above every view. It needs one thing and the children: `components` (your primitives; `components={CONTROLS}` is ViewKit's own, every slot filled). Three more have defaults, so you hand them only to draw your own: `icons` (your glyphs by meaning; absent, each drawn through your `AppIcon` by its name, which `CONTROLS.AppIcon` draws with ViewKit's own glyphs), `ports` (your haptics, clipboard, per-device store, toast and confirm dialog, each optional; [ports](ports.md)) and `conventions` (absent, `en-US` in `UTC`).
|
|
7
|
+
`ViewsProvider` sits once at your app's client root, above every view. It needs one thing and the children: `components` (your primitives; `components={CONTROLS}` is ViewKit's own, every slot filled). Three more have defaults, so you hand them only to draw your own: `icons` (your glyphs by meaning; absent, each drawn through your `AppIcon` by its name, which `CONTROLS.AppIcon` draws with ViewKit's own glyphs), `ports` (your haptics, clipboard, per-device store, toast and confirm dialog, each optional; [ports](ports.md)) and `conventions` (absent, `en-US` in `UTC`). Eleven more are optional: `atoms`, `messages`, `presentation`, `desktopQuery`, `sheetActions`, `escape`, `oneValue`, `severalValues`, `selectionBar`, `datePicks` and `panelControls` (your own controls inside ViewKit's panels, below).
|
|
8
8
|
|
|
9
9
|
`desktopQuery` says which screens are desktops: there an editor opens as a popover, and elsewhere as a sheet; so do the toolbar's panels and the views picker outside a `Toolbar` (inside one, the toolbar's phone form decides), and the grid's own chrome: a row's and a group's ⋯ and the row actions show on hover on a desktop, and a row's and a group's ⋯ always elsewhere, where the row actions don't show. It defaults to `DEFAULT_DESKTOP_QUERY`, `(min-width: 1024px)`; hand in the query your own shell switches on, so the editors and your layout change at the same width. A server render counts as a desktop.
|
|
10
10
|
|
|
@@ -73,7 +73,7 @@ assert.equal(conventions.locale, "en-GB"); // the app's own, untouched
|
|
|
73
73
|
|
|
74
74
|
## The components map
|
|
75
75
|
|
|
76
|
-
The package draws nothing with a UI library of its own. `ViewsComponents`, from `viewkitjs/views/react`, is the map you hand it: `Button`, `Popover`, `Tooltip`, `Checkbox`, `Menu`, `Collapse`, `Sheet`, `AppIcon`, `Markdown`, `TextBody` (a whole body for a text typed as one string), `NumberBody` (a whole body for a number, money or a percent), `Picker` (a whole pick list), `LinksBody` (a whole links body: each link's roles and its lead), `DateBody` (a whole date body), `PartsBody` (a whole body for a name, a place or a range) and `ValuesBody` (a whole body for several emails, phones, links or domains), `SortBody` (the sort editor's whole body), `FilterBody` (the filter editor's whole body), `FilterPartBody` (a filter rule's way and value), `FieldsBody` (the field list's whole body), `QuickFiltersBody` (the quick filters' whole body), `ViewsListBody` (the views list's whole body) and `CustomizeBody` (Customize's whole body), and
|
|
76
|
+
The package draws nothing with a UI library of its own. `ViewsComponents`, from `viewkitjs/views/react`, is the map you hand it: `Button`, `Popover`, `Tooltip`, `Checkbox`, `Menu`, `Collapse`, `Sheet`, `AppIcon`, `Markdown`, `TextBody` (a whole body for a text typed as one string), `NumberBody` (a whole body for a number, money or a percent), `Picker` (a whole pick list), `LinksBody` (a whole links body: each link's roles and its lead), `DateBody` (a whole date body), `PartsBody` (a whole body for a name, a place or a range) and `ValuesBody` (a whole body for several emails, phones, links or domains), `SortBody` (the sort editor's whole body), `FilterBody` (the filter editor's whole body), `FilterPartBody` (a filter rule's way and value), `FieldsBody` (the field list's whole body), `QuickFiltersBody` (the quick filters' whole body), `ViewsListBody` (the views list's whole body) and `CustomizeBody` (Customize's whole body), and ten you may leave out: `Input`, `Select` (the panels' boxes that pick, drawn only under `panelControls`), `Command` (the command list's parts, for the grid's menus on the popover route), `Calendar` (the filter panel's month), `RowsWait` (what a grid's rows wait in while new ones load), `GroupBody` (deprecated: read by nothing), `SearchField` (the toolbar's search box), `PortsHost` (what draws the `toast` and `confirm` ports you leave out), `SelectionBar` (the selection bar) and `ViewMenu` (a view's whole menu). The [contract](../contract.md#the-components-map) says what each slot must accept; the [`viewkitjs/views/react` reference](../reference/react.md) lists every prop.
|
|
77
77
|
|
|
78
78
|
The shapes are Base UI's, and the types promise three things:
|
|
79
79
|
|
|
@@ -83,6 +83,23 @@ The shapes are Base UI's, and the types promise three things:
|
|
|
83
83
|
|
|
84
84
|
So an app on Base UI wraps its own copies thinly, and an app on Radix maps the difference in its adapter. The package's own defaults are `CONTROLS`, from `viewkitjs/views/controls`, on Base UI, an optional peer: spread it first and your own controls after. Every other door depends on neither library.
|
|
85
85
|
|
|
86
|
+
### Your own controls inside the panels
|
|
87
|
+
|
|
88
|
+
Your `Button`, `Popover` and `Menu` draw the grid's chrome and the toolbar's frame as soon as you hand them. Inside ViewKit's own panels they draw only where you say so, so an app that hands its own for the grid sees no panel change on upgrade:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
declare const CONTROLS: ViewsComponents; // from viewkitjs/views/controls
|
|
92
|
+
declare const yourControls: Pick<ViewsComponents, "Button" | "Select" | "Menu" | "Popover" | "Input">; // your own
|
|
93
|
+
|
|
94
|
+
export function ViewsWithYourControls({ children }: { children: ReactNode }) {
|
|
95
|
+
return <ViewsProvider components={{ ...CONTROLS, ...yourControls }} panelControls>{children}</ViewsProvider>;
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`panelControls` takes `true` (all five) or the names you want (`["Button", "Select"]`). The sort and filter panels then draw every button, box that picks, menu, popover and text box with yours (VK-1013; the group editor, Customize, the views list and the quick filters follow in VK-1014). Each is handed the map's props, never ViewKit's own look: your Button a `variant` from what it is (an outlined Add sort `outline`, a quiet × `ghost` at `size="icon"`), its icon and words as its children, `aria-disabled` where it can't be used but keeps its focus; your Select its rows, value and pick, `open` and `onOpenChange`, the search's words; your Menu its rows as data, opened at the button that opens it; your Popover its anchor, its close and its `label`; your Input its typing as `onChange`, in your field's frame (`chrome="field"`). Each part's name rides with it as `data-slot` and `data-key`, so your control and your stylesheet meet on one name. A control of `CONTROLS`' stays ViewKit's whatever `panelControls` says. A `Select` of your own that `panelControls` doesn't name is never drawn, and ViewKit says so once in development.
|
|
100
|
+
|
|
101
|
+
Still ViewKit's inside the panels: the Tooltip, the Picker (the field lists), the menu rows of ViewKit's own menus, the sort's grip, the filter's number and range boxes (ViewKit's Number field), and the filter bar's way-and-value box (`FilterPartBody`, VK-1014). A filter rule's value box is named by what holds it (`vk-filter-value`), not on the box your Select or Input draws.
|
|
102
|
+
|
|
86
103
|
### An adapter over Radix
|
|
87
104
|
|
|
88
105
|
Radix opens a popover from a trigger and reports no close reasons. The adapter answers both. It hands Radix's `Anchor` a virtual ref, an object whose `getBoundingClientRect` measures the package's anchor, whichever of the three it is. It records the reason in the handler Radix calls just before it closes. And it turns the package's two vetoes, `onOutsidePress` and `onEscape`, into `preventDefault` on the event Radix hands that handler.
|
|
@@ -4,7 +4,7 @@ Import from `viewkitjs/views/controls` to draw ViewKit's default controls: the O
|
|
|
4
4
|
|
|
5
5
|
## The defaults
|
|
6
6
|
|
|
7
|
-
- `CONTROLS` — the components map's defaults, for each control an app leaves out: each control below that fills a slot of the map. An app spreads it first and its own controls after, `components={{ ...CONTROLS, ...own }}`. Handed as it stands, `components={CONTROLS}`, it brings `CONTROL_ATOMS` too, under the provider's `atoms`; a map spread from it brings none. Its `Button` draws ViewKit's buttons (`variant`, `size`) as the kit's Button's kinds and sizes, stands a glyph handed before the words as the Button's icon, and one handed after them as its end icon. Its `AppIcon` draws ViewKit's own glyph of each name (`CONTROL_ICONS`), and nothing for a name it doesn't draw; a provider handed no `icons` draws every meaning through it. Its `Markdown` draws the stored text as it stands, its line breaks kept, with no renderer.
|
|
7
|
+
- `CONTROLS` — the components map's defaults, for each control an app leaves out: each control below that fills a slot of the map. An app spreads it first and its own controls after, `components={{ ...CONTROLS, ...own }}`. Handed as it stands, `components={CONTROLS}`, it brings `CONTROL_ATOMS` too, under the provider's `atoms`; a map spread from it brings none. Its `Button` draws ViewKit's buttons (`variant`, `size`) as the kit's Button's kinds and sizes, stands a glyph handed before the words as the Button's icon, and one handed after them as its end icon. Its `AppIcon` draws ViewKit's own glyph of each name (`CONTROL_ICONS`), and nothing for a name it doesn't draw; a provider handed no `icons` draws every meaning through it. Its `Markdown` draws the stored text as it stands, its line breaks kept, with no renderer. Its `Button`, `Select`, `Menu`, `Popover` and `Input` are ViewKit's own: named in the provider's `panelControls`, they still draw the panels exactly as without it.
|
|
8
8
|
- `CONTROL_ICONS` — ViewKit's default glyphs by meaning, a `ViewsIcons` over every `ICON_NAMES` meaning, each a Tabler icon as the Outright kit draws it (a line of 2 in the colour of its words; the carets filled; `loading` the Spinner): what `CONTROLS.AppIcon` draws, for an app with an `AppIcon` of its own that keeps ViewKit's glyphs, `icons={CONTROL_ICONS}`.
|
|
9
9
|
- `leadingGlyph` — `leadingGlyph(children, glyphs)`: a glyph before a button's words (an svg, or one of the app's icons or its `AppIcon` in `glyphs`) as `icon`, one after them as `iconEnd`, and the words as `label`; a glyph alone, or another component, stays `{ label }`.
|
|
10
10
|
|
|
@@ -210,7 +210,8 @@ Their stylesheets are `input.css`, `inline-input.css`, `field.css`, `toggle.css`
|
|
|
210
210
|
- `MenuListRow` — a name and its value as one row standing alone, at the list's own height and inset.
|
|
211
211
|
- `MenuScroll` — what scrolls in a menu's panel: its rows alone, the Scrollbar over them.
|
|
212
212
|
- `MenuEntry` — a row of a menu: an action, a link, a tick, a choice or actions one level in, a pick under a heading, a group, a separator.
|
|
213
|
-
- `MenuChoice` — a choice: its value, its name, its mark and its `
|
|
213
|
+
- `MenuChoice` — a choice: its value, its name, its mark, its `detail` and its public name (`slot`, a `PartSlot`).
|
|
214
|
+
- `PartSlot` — a part's public name (`slot`, its `data-slot`) and which one of its kind it is (`key`, its `data-key`; `index`, its `data-index`): what a `MenuEntry`, a `MenuChoice` and a `PickerItem` carry as `slot`, drawn on the row in every form (VK-988). A `pick` or a `group` names its rows through its choices or entries.
|
|
214
215
|
- `MenuListEntry` — a menu's entry with what a row adds: a `note` under its name, an `end` on its right, a `grip`.
|
|
215
216
|
- `MenuListTile` — one of the few done most, as a tile.
|
|
216
217
|
- `tilesOf` — `tilesOf(entries, allRows?)`: the first four plain actions as tiles when there are three or more, the rest as rows.
|
|
@@ -274,8 +275,9 @@ Their stylesheets are `input.css`, `inline-input.css`, `field.css`, `toggle.css`
|
|
|
274
275
|
- `ContextMenu` — the same menu at the pointer, from a right-click on what it wraps; on a phone a long press opens the Sheet.
|
|
275
276
|
- `MenuDots` — the ⋯ button: the Button's quiet icon form at 32px, the neutral fill under the pointer and while its menu is open.
|
|
276
277
|
- `useSheetMenus` — whether menus are the Sheet here: on a phone, or in a phone's screen standing on a page.
|
|
277
|
-
- `MapMenu` — the components map's default `Menu` (`CONTROLS.Menu`): ViewKit's menu rows drawn as the Menu at their anchor.
|
|
278
|
-
- `
|
|
278
|
+
- `MapMenu` — the components map's default `Menu` (`CONTROLS.Menu`): ViewKit's menu rows drawn as the Menu at their anchor; a row carrying its own `slot` drawn with it as its name.
|
|
279
|
+
- `MapSelect` — the components map's default `Select` (`CONTROLS.Select`): the map's `ViewsSelectProps` drawn as ViewKit's own Select, its list as wide as its rows need, its rows one level in opened in place. The panels draw ViewKit's Select itself unless your own is opted in; hand or wrap this to have ViewKit's back.
|
|
280
|
+
- `menuEntries` — `menuEntries(items, notNow?, rowSlot?)`: ViewKit's menu rows (`ViewsMenuItem`) as the Menu's own kinds: ticks that close side by side one pick, a group beside its row a level in, a disabled row saying why; handed `rowSlot` (VK-988), each row and choice named by it, `data-key` its item's key.
|
|
279
281
|
|
|
280
282
|
## The Avatar
|
|
281
283
|
|
|
@@ -304,7 +306,7 @@ Their stylesheets are `input.css`, `inline-input.css`, `field.css`, `toggle.css`
|
|
|
304
306
|
- `PickerDoing` — what its list is doing: `searching` or `failed`.
|
|
305
307
|
- `PickerLead` — the row that leads, where its field leads several.
|
|
306
308
|
- `PickerBoxSearch` — what a box that is its search is handed: its keys and what it holds.
|
|
307
|
-
- `PickerItem` — a row handed to it: its value, words, second line, group, level, menu, count,
|
|
309
|
+
- `PickerItem` — a row handed to it: its value, words, second line, group, level, menu, count, the words its search also finds (`also`), and its public name (`slot`, a `PartSlot`, VK-988).
|
|
308
310
|
- `PickerAs` — what a row is drawn as: an Option, a Status, an Avatar, a sign or a mark.
|
|
309
311
|
- `PickerRow` — a row its list shows.
|
|
310
312
|
- `RowsInput` — what its rows are worked out from.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Import from `viewkitjs/views/field-row` in a client component, under your `ViewsProvider`: the door opens with the client directive. It holds a record's field row: one field drawn as its label, its value and, on a click, its type's editor in place, and the write path that admits each edit at once, queues one record's writes, settles each on the save's receipt and rolls a failure back. The row knows no entity, only a binding, a value and a commit, so your app builds its record's panel (its sections, its related records) around the rows. It draws with your provider's `Popover`, `Sheet`, `Collapse`, `AppIcon`, icons, `CommandMenu` atom and toast port. The shapes its writes go through (the write target, the receipt, the admission, a value's note, the reconciliation error) are the root door's, described under [A write's target](views.md#a-writes-target), and this door re-exports them. Guide: [editors](../guides/editors.md).
|
|
4
4
|
|
|
5
|
-
- `FieldRow` — one field of a record: a glyph (the binding's `icon` through your `AppIcon`, else the type's icon), the label, and the value drawn by the display. Outside a Field rows card (below), below the provider's `desktopQuery` the label stands above the value, which then takes the row's width; at it and above, glyph, label and value share one line. A writable row holding nothing draws your `views.field-row.empty` word, muted; a read-only one draws "—". A writable row's edit button is named by the label, then the value as it is drawn ("Stage, Won"; "Terms, Empty" for a row holding nothing); a row still loading, and a rich text laid over its button, are named by the label alone. A writable row opens its type's editor on a click, through the editor panel and one edit session: a picker (a select, a date, several tags, a relation or a set of records, several values, a place) anchored under the value in your `Popover` on a desktop and in your `Sheet` on a phone, by the provider's `desktopQuery`; a typed value (text, a number, money) in its own box on every width; a name and a range open your `PartsBody` anchored under the value, as a place does; and a single email or domain opens the value list holding one value, anchored, where the provider's `oneValue` says `list` for its type. Escape throws the edit away, unless the provider's `escape` keeps the field's type, on a desktop, where it keeps what was typed and a refusal stays open until a second Escape throws the edit away; a sheet's swipe or ✕ changes nothing. On a desktop the date editor opens with the keyboard in your `DateBody`, as a place's or a long select's does; and with an editor open in its popover, an Escape heard from the page itself or from an element holding the row closes that editor and goes no further, so a drawer around the row hears only the next one. On a desktop, a select gives your Picker the keys however it opened, by Enter, Space or a pointer: the focus in its search, the arrows going on from the value it holds, and Enter picking the one lit (opened by a key, an Enter at once changes nothing). On a desktop, an editor closed by Tab, Shift-Tab, Escape, Enter or a pick puts the focus back on the row's own button, once its exit has played out and a write still saving has saved, so the next Tab moves on from that row; a press or a focus outside an editor's panel since the close lets that go, so a row opened meanwhile keeps its editor, and an outside press leaves the focus where it put it. A relation saves what its row stores (an id, a ref with the picked record's kind, or a set of records with its lead); a date field has no time and offers No date where it may be empty; several values read a phone typed without its code in the binding's `region`. A value of several parts inside a writable row draws its count as plain text: the row's press opens the editor, which lists them all. A single email, phone, link or domain in a writable row reads as plain text too, with an open action beside the row's button (a mail, a call, the site), and a writable rich text lies over its button, so its links and "Show more" keep their own press while a press on its text edits. A money figure its host reads in another currency than the record's own (it hands the converted figure as `value` and that currency as `opts.currency`) is marked ≈ with the currency it came from, and its editor names it under the record's own amount. A boolean commits from its own control, a `command` field opens its verbs, and a read-only row draws a lock with its reason. A refused commit keeps the editor open with the reason under it, a saved value shows at once and stays until the receipt settles it, and a failed save rolls back with a retry. A text, an email, a phone, a link, a domain, long or rich text edits in place in the row; handed the components map's `TextBody`, the row opens it there, at every width, with the field's own check and the record's country. A number, money or a percent edits in place too; handed `NumberBody`, the row opens it there, at every width, with the field's own check and its limits (a duration keeps the editor's own box).
|
|
5
|
+
- `FieldRow` — one field of a record: a glyph (the binding's `icon` through your `AppIcon`, else the type's icon), the label, and the value drawn by the display. Outside a Field rows card (below), below the provider's `desktopQuery` the label stands above the value, which then takes the row's width; at it and above, glyph, label and value share one line. A writable row holding nothing draws your `views.field-row.empty` word, muted; a read-only one draws "—". A writable row's edit button is named by the label, then the value as it is drawn ("Stage, Won"; "Terms, Empty" for a row holding nothing); a row still loading, and a rich text laid over its button, are named by the label alone. A writable row opens its type's editor on a click, through the editor panel and one edit session: a picker (a select, a date, several tags, a relation or a set of records, several values, a place) anchored under the value in your `Popover` on a desktop and in your `Sheet` on a phone, by the provider's `desktopQuery`; a typed value (text, a number, money) in its own box on every width; a name and a range open your `PartsBody` anchored under the value, as a place does; and a single email or domain opens the value list holding one value, anchored, where the provider's `oneValue` says `list` for its type. Escape throws the edit away, unless the provider's `escape` keeps the field's type, on a desktop, where it keeps what was typed and a refusal stays open until a second Escape throws the edit away; a sheet's swipe or ✕ changes nothing. On a desktop the date editor opens with the keyboard in your `DateBody`, as a place's or a long select's does; and with an editor open in its popover, an Escape heard from the page itself or from an element holding the row closes that editor and goes no further, so a drawer around the row hears only the next one. On a desktop, a select gives your Picker the keys however it opened, by Enter, Space or a pointer: the focus in its search, the arrows going on from the value it holds, and Enter picking the one lit (opened by a key, an Enter at once changes nothing). As the editor takes the place of the row's button, the row holds the focus the button held until the editor takes it, so the focus never falls to the page: a dialog around the row that takes such a focus back to itself (Base UI's) leaves a text's or a number's editor open. On a desktop, an editor closed by Tab, Shift-Tab, Escape, Enter or a pick puts the focus back on the row's own button, once its exit has played out and a write still saving has saved, so the next Tab moves on from that row; a press or a focus outside an editor's panel since the close lets that go, so a row opened meanwhile keeps its editor, and an outside press leaves the focus where it put it. A relation saves what its row stores (an id, a ref with the picked record's kind, or a set of records with its lead); a date field has no time and offers No date where it may be empty; several values read a phone typed without its code in the binding's `region`. A value of several parts inside a writable row draws its count as plain text: the row's press opens the editor, which lists them all. A single email, phone, link or domain in a writable row reads as plain text too, with an open action beside the row's button (a mail, a call, the site), and a writable rich text lies over its button, so its links and "Show more" keep their own press while a press on its text edits. A money figure its host reads in another currency than the record's own (it hands the converted figure as `value` and that currency as `opts.currency`) is marked ≈ with the currency it came from, and its editor names it under the record's own amount. A boolean commits from its own control, a `command` field opens its verbs, and a read-only row draws a lock with its reason. A refused commit keeps the editor open with the reason under it, a saved value shows at once and stays until the receipt settles it, and a failed save rolls back with a retry. A text, an email, a phone, a link, a domain, long or rich text edits in place in the row; handed the components map's `TextBody`, the row opens it there, at every width, with the field's own check and the record's country. A number, money or a percent edits in place too; handed `NumberBody`, the row opens it there, at every width, with the field's own check and its limits (a duration keeps the editor's own box).
|
|
6
6
|
- `FieldRowProps` — the row's props: `binding`, `row`, `value` (the display value), `editValue` (the stored value the editor opens on), `writable`, `ready` (false refuses gestures while the record loads), `unread` (the value isn't read yet, drawn blank), `refusal` (why it's read-only here), `onCommit` (admits or refuses a draft, then settles; an editor still open when the page or the row goes is asked as for a press outside, so it can be called inside `pagehide`), `opts` (display options), `menu` (a `command` field's verbs), `meta` (a few words in the value's line), `note` (a sentence under the value, with an optional quote a tap opens) and `kindIcon` (your icon name for a record kind, the glyph a relation's candidates wear; unanswered, they wear the type's glyph).
|
|
7
7
|
- `RowEditor` — the editor a row mounts for its field's type, picked from `ROW_HOSTS`.
|
|
8
8
|
- `ROW_HOSTS` — the host each field type mounts in a row, or `null` for a type the row never opens (a boolean, a derived or system field).
|
|
@@ -51,7 +51,7 @@ The spreadsheet. The door carries no client directive; every rendering file behi
|
|
|
51
51
|
- `deriveGridSelectValues` — the values each select, status and multiselect column offers, given the columns and the rows: column id to values. A status offers its options; a select or multiselect offers its options, then the values the rows hold, each once. Archived values are left out unless `includeArchived` is set, as a filter sets it so a row still holding a retired value can be found.
|
|
52
52
|
- `deriveGridRelationValues` — the relations present in the loaded rows, given the columns and the rows: column id to `ListRelationValue`s, each once, sorted by label, for every relation, user and actor column (an actor's id is its key). It reads the rows, never the candidates a column can link to, so a filter lists only what the table holds.
|
|
53
53
|
- `cellEditBaseline` — the value an edit of a cell starts from: the column's pending value when one is given, else the column's `editAccessor`, else its `accessor`.
|
|
54
|
-
- `cellCopyText` — a cell's value as copied text, given its column
|
|
54
|
+
- `cellCopyText` — a cell's value as copied text, given its column, its baseline (from `cellEditBaseline`) and, optionally, the names language (`conventions.language`) a place's country is named in (English without one), which a CSV export can reuse. Empty for no value; a relation or an actor copies as its name, not its id; a select, status or multiselect copies as its options' labels, not their keys; a place, a name and a range copy as their cells write them; a list copies its items joined by commas, several values of one kind their values, the main one first.
|
|
55
55
|
- `GRID_TITLE_LINK_CLASS` — the class that dresses the row-open text inside a title cell (the element carrying `data-cell-open`) as a link on its own hover: the brand colour and an underline.
|
|
56
56
|
|
|
57
57
|
## The lab
|
|
@@ -23,9 +23,86 @@ Import from `viewkitjs/views/list` to give a list its rows from your server, and
|
|
|
23
23
|
- its own `rows` is `[]`, its `next` is `null`, and its `total` is the whole list's;
|
|
24
24
|
- a group that carries `rows` is loaded, and carries its own `next`;
|
|
25
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.
|
|
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. Where the narrowing can change while the list stays mounted (another company, the same page), hand the list `key={companyId}` too, so it starts again rather than paging one company's rows from another's source.
|
|
27
27
|
- **Request members are strict**, so when a request gains a key, update your servers before your clients.
|
|
28
28
|
|
|
29
|
+
## The ready List
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
"use client";
|
|
33
|
+
import { defineFields } from "viewkitjs/fields";
|
|
34
|
+
import { List, type ListChange } from "viewkitjs/views/list";
|
|
35
|
+
|
|
36
|
+
const ORDER_FIELDS = defineFields({
|
|
37
|
+
entity: "order",
|
|
38
|
+
identity: "name",
|
|
39
|
+
fields: {
|
|
40
|
+
name: { type: "text", label: "Name", required: true },
|
|
41
|
+
owner: { type: "text", label: "Owner" },
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
type Order = { id: string; name: string; owner: string };
|
|
46
|
+
|
|
47
|
+
async function save({ id, values }: ListChange<Order>) {
|
|
48
|
+
const answer = await fetch(`/api/orders/${id}`, { method: "PATCH", body: JSON.stringify(values) });
|
|
49
|
+
if (!answer.ok) throw new Error("The order wasn't saved.");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// The whole list: the toolbar, the grid, saved views, edits and undo, on a computer and a phone.
|
|
53
|
+
export function Orders({ orders }: { orders: readonly Order[] }) {
|
|
54
|
+
return <List id="orders" fields={ORDER_FIELDS} rows={orders} save={save} />;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
From your server, a page at a time, the list hands each part's request to a `source` in place of `rows`:
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { fetchSource, type ListSource } from "viewkitjs/views/list";
|
|
62
|
+
|
|
63
|
+
// A route that answers list requests.
|
|
64
|
+
const ORDERS = fetchSource<Order>("/api/orders/list");
|
|
65
|
+
export function OrdersFromARoute() {
|
|
66
|
+
return <List id="orders" fields={ORDER_FIELDS} source={ORDERS} save={save} />;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Or your server action ("use server"), a source as it stands.
|
|
70
|
+
declare const loadOrders: ListSource<Order>;
|
|
71
|
+
export function OrdersFromAnAction() {
|
|
72
|
+
return <List id="orders" fields={ORDER_FIELDS} source={loadOrders} save={save} />;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
- `List` — a whole list in one component: a `ListRoot` that keeps its saved views (the browser's store by default) around `ListToolbar`, `ListGrid` and `ListBulkBar`, in the Outright look. Below the provider's desktop query it draws the phone's form (the toolbar's one line, its panels in sheets, the grid's taps), with nothing more passed. Its props, each optional but the first three:
|
|
77
|
+
- `id`: the list's name; its saved views, the person's draft and layer, and its open view are kept under it.
|
|
78
|
+
- `fields`: a `defineFields` registry. Every field is a column, in the registry's order, bound by its key.
|
|
79
|
+
- `rows`: your rows, each your own flat `{ id, ...values }`; the list filters, sorts and groups them as its settings ask.
|
|
80
|
+
- `source`, in place of `rows`: where the rows come from (a `ListSource`: `fetchSource("/api/deals/list")`, or your server action as it stands, `source={loadDeals}`). Whether there is one is read as the list mounts; each request goes to the one handed last. Hand one or the other, never both.
|
|
81
|
+
- The list asks one request per part it draws, each through `answerFor`: the first page of `rows` as the settings or the quick filters' hold change (a width or a hidden column asks nothing), the next page as the grid's end comes near, a group's next page as that group's end does; every matching row's `ids` as your app calls `select("all")`; each saved view's `view-counts` while Show counts is on (each view's own filter, beside the search and the hold, not the open view's filter); the quick filters' `counts` while their panel is open; and the `values` of each text field while Filter or Customize is open.
|
|
82
|
+
- An answer a newer request has outrun is dropped, and no page is ever asked with a cursor from older settings. A part is asked again only as what a request carries changes.
|
|
83
|
+
- While a first page is out with no rows shown, the grid shows its wait, not its empty state; rows shown stay until the new ones land. A group the source sends unnamed (postgres leaves an option's so) takes its field's name for its key.
|
|
84
|
+
- A refusal shows in the grid's empty state, in your server's words; a refusal of a later page keeps the rows shown. A throw is said through the toast, and the rows shown stay.
|
|
85
|
+
- Picks from a paged list stay across its pages, and clear as the search, filter, group or the quick filters' hold changes; the grid's header box picks the rows in hand. A refused or failed `ids` is said through the toast, and the picks go back to the grid's.
|
|
86
|
+
- `pageSize`: with a `source`, how many rows each page asks for. Default 50, held between 1 and 1000.
|
|
87
|
+
- `save`: one save per record (`ListSave`). An edit, a paste, a fill, an undo or a redo of one record's cells is one call; it throws to refuse, in words the toast says. With none, the list is read-only.
|
|
88
|
+
- `columns`: columns changed by their field's key (`ListColumnsOverride`). Keep it stable (a module constant, or `useMemo`): a new object binds the fields and works out the rows again.
|
|
89
|
+
- `views`: a `ViewsStore`, or `{ seed }` (your own views, read-only), `{ records }` (what the delete question calls the rows), `{ store }`.
|
|
90
|
+
- `defaults`: what a list with no saved view shows; by default the fields' columns over `LIST_SETTINGS_DEFAULTS`.
|
|
91
|
+
- `sortFilter` and `bar`: the toolbar's form on a computer, as `ListRoot` takes them.
|
|
92
|
+
- `menus`: every menu as data ([Menus as data](#menus-as-data)): `column`, `row` and `group` reach the grid, `view`, `add` and `more` the toolbar.
|
|
93
|
+
- `toolbarParts`: where each of the toolbar's parts stands ([Parts as data](#parts-as-data)).
|
|
94
|
+
- `link`: default `true`. The address carries the open view and what changed over it (`view`, `q`, `change`), written in place as it changes, your other parameters and history state kept; an opened link wins over the person's draft; back and forward open what the address says. A link it can't read is said through the toast. Two lists on one page share those parameters: hand the second `link={false}`.
|
|
95
|
+
- `can`: `{ edit: false }` leaves every cell read-only, as with no `save`; `{ share: false }` takes "Save for everyone" away even where the store lets the person share, read as the list mounts, as `defaults` is.
|
|
96
|
+
- `onOpenRow`, `rowHref` and `rowWritable` reach the grid, as `GridTable` takes them; `onAdd`, `addItems` and `quickFilters` the toolbar, as `ReadyToolbar` takes them; the quick filters' hold narrows the rows too.
|
|
97
|
+
- `toolbar`, `grid` and `bulk`: any other prop of `ListToolbar`, `ListGrid` and `ListBulkBar`. A prop handed at the top wins over the same one in these; one not handed leaves theirs. `menus` merges key by key. A `grid.children` of your own (your own bar) stands where `ListBulkBar` would, and wins.
|
|
98
|
+
- `className`: on the `div` around the parts (`data-slot="vk-list"`).
|
|
99
|
+
- A field its key can't bind (a writable `datetime`, whose editor needs your time zone) throws, naming the field: hand its binding in `columns` (`bind`).
|
|
100
|
+
- For another arrangement, write `ListRoot` with the same data props and place the parts yourself.
|
|
101
|
+
- `ListProps` — what `List` takes.
|
|
102
|
+
- `ListColumnOverride` — one column's change by its field's key: `width`, `header`, `hidden` (the column starts hidden in the defaults), `editable: false` (an edit only ever taken away), and `bind`, the field's binding where its key doesn't say (a `bindFields` spec: `read`, and `write` handing back `{ body }` or `{ skip, reason }`).
|
|
103
|
+
- `ListColumnsOverride` — the columns changed, by field key.
|
|
104
|
+
- `ListFieldsRegistry` — a list's fields: what `defineFields` returns.
|
|
105
|
+
|
|
29
106
|
## A list's root
|
|
30
107
|
|
|
31
108
|
```tsx
|
|
@@ -47,11 +124,18 @@ export function DealsList({ children }: { children: ReactNode }) {
|
|
|
47
124
|
|
|
48
125
|
- `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
126
|
- **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`.
|
|
127
|
+
- **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`. `link={true}` carries the open view in the address, as `List`'s `link` does; a `readListLink` reading is opened and never written. Either way the open view is kept on the device (`ports.viewPrefs`), opened again where no link names one.
|
|
128
|
+
- **A list's data, in either mode** (`ListData`): `fields` (its columns, and in store mode its defaults), `rows` (worked out as the settings ask, into `answer`) or `source` and `pageSize` (answered a page at a time), `quickFilters` (their hold narrows the rows, in memory and from a source), `columns`, `save` and `can`, as `List` takes them. A grid under the root (`ListGrid`) saves through `save`, and hands the root its undo, redo and edits.
|
|
51
129
|
- 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
130
|
- 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
131
|
- It draws no element of its own.
|
|
54
132
|
- `ListRootProps` — what `ListRoot` takes.
|
|
133
|
+
- `ListData` — what `ListRoot` holds of a list's data, in either mode: `fields`, `rows` or `source` and `pageSize`, `quickFilters`, `columns`, `save` and `can`.
|
|
134
|
+
- `ListAnswerState` — the rows a list shows: `groups` and `grouped` (as `GridTable` takes them), `groupHeads` (every group's head, hidden ones too, for the group panel), `ids` (the rows in hand, in the order drawn), `total` (`{ count, exact }`, or `null`), `filterValues` (what the filter offers), `loading` (a source's first page is out) and `refused` (a source's), `more` (`rows`: the next page; `groups`: each group's), `paged` (the rows come a page at a time), `viewCounts` and `holdCounts` (each saved view's count and each quick filter's values counted, where a source answered them; `null` otherwise).
|
|
135
|
+
- `ListGrid` — `GridTable` reading the root around it: its rows from `answer`, its columns from `fields`, the widths, order, look and figures from the person's settings and layer, the header's sort and Group by from the settings, a band folded into the layer, an edit through the root's `save`, and its picks published to `selection`. Every `GridTable` prop is yours to hand, and wins. Its children stand where the grid keeps room for its selection bar (`ListBulkBar`). A `selection` handed is your own: the root then doesn't follow the grid's picks, and the children aren't drawn.
|
|
136
|
+
- `ListGridProps` — what `ListGrid` takes: `GridTableProps`, each optional, and `children`.
|
|
137
|
+
- `ListBulkBar` — ViewKit's selection bar over the root's picks: their count, and its clear picking none. Place it inside `ListGrid`. Your `verbs` (none by default), `onDelete` and the rest of `SelectionBar`'s props.
|
|
138
|
+
- `ListBulkBarProps` — what `ListBulkBar` takes: `SelectionBarProps` without `count` and `onClear`, `verbs` optional.
|
|
55
139
|
- `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
140
|
- `ListSlotProps` — what `ListSlot` takes: `name`, and optionally `className`.
|
|
57
141
|
- `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.
|
|
@@ -66,15 +150,19 @@ export function DealsList({ children }: { children: ReactNode }) {
|
|
|
66
150
|
- `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
151
|
- `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
152
|
- `views`: the list's saved views where the root keeps them (a `ListViewsState`); `null` in memory mode.
|
|
69
|
-
- `
|
|
153
|
+
- `columns`: the list's columns from its `fields`; `null` with none.
|
|
154
|
+
- `answer`: the rows the list shows (a `ListAnswerState`); `null` with no `fields`, or with neither `rows` nor a `source`.
|
|
155
|
+
- `edits`: `saving` (a write is still out), `canUndo` and `canRedo`, from the grid under the root.
|
|
156
|
+
- `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). With a `ListGrid` under the root, the picks are the grid's: they clear as the view's search, filter or group (or the quick filters' hold) changes, and `select("all")` picks every row shown, or from a source every matching row, kept across its pages.
|
|
70
157
|
- `setSettings(change)` and `setLayer(patch)`: hand a change to the root's `onChange` and `onLayerChange`.
|
|
71
158
|
- `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
159
|
- `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.
|
|
160
|
+
- `select(ids)`: picks these rows; `select("all")` picks every matching row (from a source, it asks for their `ids` first, `all` and the total's `count` while they come); `select([])` picks none.
|
|
74
161
|
- `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()`:
|
|
76
|
-
- `
|
|
77
|
-
- `
|
|
162
|
+
- `undo()` and `redo()`: take back the list's last edit, and put back the last one taken back, as ⌘Z and ⌘⇧Z do; nothing until there is one.
|
|
163
|
+
- `loadMore()` and `loadGroup(key)`: from a source, the next page, and a group's; nothing in memory, or while a newer request is out.
|
|
164
|
+
- `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` holding no data 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).
|
|
165
|
+
- `ListToolbarProps` — what `ListToolbar` takes: `ReadyToolbarProps` without `settings`, `layer`, `onChange`, `onLayerChange`, `view`, `sortFilter` and `bar`; `toolbarParts` among them ([Parts as data](#parts-as-data)). In a root that holds a list's `fields` and its `rows` or `source`, `columns`, `groupHeads` and `filterData` default to the root's; handed, yours win.
|
|
78
166
|
|
|
79
167
|
## A list's saved views
|
|
80
168
|
|
|
@@ -107,7 +195,7 @@ A `ListRoot` handed no `settings` keeps the list's saved views, a person's draft
|
|
|
107
195
|
- `defaults`: what a list with no saved view shows, and a new view's start; default `LIST_SETTINGS_DEFAULTS`.
|
|
108
196
|
- `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
197
|
- `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.
|
|
198
|
+
- `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, change?)` (with `change`, laid over the view as the edited settings, its draft replaced: what an opened link does), `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
199
|
- `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
200
|
- `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
201
|
- `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.
|
|
@@ -166,7 +254,7 @@ export function DealsGrid(grid: GridTableProps<Deal>) {
|
|
|
166
254
|
- `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
255
|
- `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
256
|
- `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
|
-
-
|
|
257
|
+
- `List` takes `menus` whole and hands each part its own: `GridTable` (and `ListGrid`) 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
258
|
- 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
259
|
- 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
260
|
- `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)).
|
|
@@ -190,6 +278,18 @@ Every default row's key is a public name: your function finds rows by it. A key
|
|
|
190
278
|
- New: your `addItems`' keys, or `new`.
|
|
191
279
|
- ⋯: the folded parts' keys: `options`, `sort`, `filter`, `filters`, `filter-add`, `quick`.
|
|
192
280
|
|
|
281
|
+
Every toolbar button names itself to your `ToolbarButton` by the same keys (`part`, VK-984): a button is named after the
|
|
282
|
+
place it stands in, and a place's second kind of button by a name of its own. Each place's buttons:
|
|
283
|
+
|
|
284
|
+
| Place (`key`) | Its buttons' `part` |
|
|
285
|
+
|---|---|
|
|
286
|
+
| `options`, `search`, `quick`, `new`, `filter`, `filter-add`, `advanced-filters` | the key itself (an advanced filter's pill, one each) |
|
|
287
|
+
| `sort` | `sort` (Sort, or the sort's pill where it stands in this place); `sort-add`, the + after the pill |
|
|
288
|
+
| `sort-pill` | `sort-pill`; `sort-add`, the + after it |
|
|
289
|
+
| `filters` | `filters` (each rule's four joined buttons, told apart by `joined`); `filter` (the bar's Filter while it holds none) or `filter-add` (its + after them); `more-filters` ("+N filters") |
|
|
290
|
+
| `views`, `views-stacked`, `save` | none outside your own frame: ViewKit's own pills and your `Button`. In your own frame, `views-chip`, `views-tab`, `views-more`, `views-add`, `clear` and `save` (`ViewsFramePart`) |
|
|
291
|
+
| ⋯ (no place) | `more` |
|
|
292
|
+
|
|
193
293
|
## Parts as data
|
|
194
294
|
|
|
195
295
|
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:
|
|
@@ -215,13 +315,43 @@ export function DealsToolbar(props: ReadyToolbarProps<Deal>) {
|
|
|
215
315
|
```
|
|
216
316
|
|
|
217
317
|
- 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? }`.
|
|
318
|
+
- A part's place: `{ key, line, side, words, node?, className?, button? }`.
|
|
219
319
|
- `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
320
|
- `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
321
|
- `side`: `"start"` or `"end"`.
|
|
222
322
|
- `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
323
|
- `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.
|
|
324
|
+
- `className`: put on every toolbar button the part draws (each handed its `part`, [Default keys](#default-keys)'s table), on the button itself, through your `ToolbarButton` (ViewKit's own puts it on its `<button>`, `CONTROL_ATOMS`' on the toolbar button or New's `Button`).
|
|
325
|
+
- `button`: your own button for the part, a component taking `ViewsToolbarButtonProps` ([`/react`](./react.md)), drawn for each of its toolbar buttons in place of your `ToolbarButton` and handed the very props it would get: `part`, `open`, `count`, `onClick`, `ref` and the rest. What it opens stays ViewKit's and hangs at your button through `ref`: put `ref` on the element you draw.
|
|
224
326
|
- 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
327
|
- 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
|
-
-
|
|
328
|
+
- Dressing a place, New your own button, Sort a ghost and Customize outlined by your stylesheet:
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
import type { ViewsToolbarButtonProps } from "viewkitjs/views/react";
|
|
332
|
+
|
|
333
|
+
// Your own New: handed what ViewKit's button would be, `ref` on the element it draws.
|
|
334
|
+
function OutlinedNew({ icon, label, onClick, ref }: ViewsToolbarButtonProps) {
|
|
335
|
+
return (
|
|
336
|
+
<button ref={ref} type="button" className="deals-new" onClick={onClick}>
|
|
337
|
+
{icon}
|
|
338
|
+
{label}
|
|
339
|
+
</button>
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const dressedParts: ToolbarParts = (parts) =>
|
|
344
|
+
parts.map((p) =>
|
|
345
|
+
p.key === "new" ? { ...p, button: OutlinedNew }
|
|
346
|
+
: p.key === "sort" ? { ...p, className: "deals-sort" }
|
|
347
|
+
: p.key === "options" ? { ...p, className: "deals-options" }
|
|
348
|
+
: p);
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- What stays fixed:
|
|
352
|
+
- Clear and Save move as one part (`save`); a part's words are `both` or `icon`, never its word alone.
|
|
353
|
+
- The views row (its chip, tabs, "+N" and "+", and `views-stacked`) and Clear and Save draw ViewKit's own pills and your `Button` in the ready toolbar: they take no `part`, and their place's `className` and `button` don't reach them (in your own frame they draw through your `ToolbarButton`, [`/panels/react`](./panels-react.md#the-toolbar)).
|
|
354
|
+
- ⋯ is named (`more`) but has no place, so no class or button of yours: dress it in your `ToolbarButton` by its `part`.
|
|
355
|
+
- A place's second buttons (Sort's +, the bar's Filter and +, "+N filters", a rule's four) share their place's one `className` and one `button`; tell them apart by `part` and `joined`.
|
|
356
|
+
- 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
357
|
|
|
@@ -71,7 +71,7 @@ The frame that holds a list's controls, and the parts that need no list settings
|
|
|
71
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); `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.
|
|
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; `key`, `className` and `button`, its place's key and look (`ToolbarPartPlace`): a part names its buttons after `key`, and draws each with `button` in place of your `ToolbarButton` and with `className` on it, which your own frame may hand 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
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.
|
|
@@ -157,7 +157,7 @@ Options, Sort and Filter each open their panel from their own button, and each t
|
|
|
157
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"`),
|
|
160
|
+
- `ToolbarPartPlace` — a part's place: `{ key, line, side, words, node?, className?, button? }`: 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"`), `node` for a part of your own under a key of your own, and its look: `className`, put on every toolbar button the part draws, and `button`, your own button drawn for each of them in place of your `ToolbarButton`, handed the same props (`ref` included: put it on your button). [`/list`'s Parts as data](./list.md#parts-as-data) lists each place's buttons and what stays fixed.
|
|
161
161
|
- `ToolbarPartsContext` — which form the parts are for: `{ arrangement, phone }` (`"kit"` or `"row"`, and whether it is a phone's).
|
|
162
162
|
- `ToolbarMore` — ⋯ as data, `Toolbar`'s `more` and `ToolbarMenus`' `more`: `(items, { line }) => items`.
|
|
163
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).
|