@viewkitjs/views 0.4.0 → 0.5.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/README.md +3 -3
  3. package/dist/atoms/DrillRows.d.ts +3 -0
  4. package/dist/atoms/DrillRows.js +25 -0
  5. package/dist/atoms/PanelRows.d.ts +5 -0
  6. package/dist/atoms/PanelRows.js +40 -0
  7. package/dist/atoms/PanelSearch.d.ts +2 -0
  8. package/dist/atoms/PanelSearch.js +21 -0
  9. package/dist/atoms/SelectionSheet.d.ts +3 -0
  10. package/dist/atoms/SelectionSheet.js +30 -0
  11. package/dist/atoms/defaults.js +12 -0
  12. package/dist/atoms/types.d.ts +117 -1
  13. package/dist/contract.d.ts +170 -9
  14. package/dist/contract.js +179 -2
  15. package/dist/figures.d.ts +5 -48
  16. package/dist/figures.js +1 -63
  17. package/dist/grid/chrome/GridColumnMenu.d.ts +3 -3
  18. package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
  19. package/dist/grid/chrome/GridGroupMenu.d.ts +2 -2
  20. package/dist/grid/chrome/GridTable.js +1 -1
  21. package/dist/grid/useGridTablePrefs.d.ts +1 -1
  22. package/dist/grouping/sort-groups.d.ts +6 -7
  23. package/dist/model/aggregates.d.ts +3 -3
  24. package/dist/model/aggregates.js +17 -71
  25. package/dist/model/column-order.d.ts +2 -2
  26. package/dist/model/column-schema.d.ts +6 -7
  27. package/dist/model/column-state.d.ts +3 -20
  28. package/dist/model/column-state.js +1 -4
  29. package/dist/model/column-types.d.ts +1 -15
  30. package/dist/model/column-types.js +1 -1
  31. package/dist/model/part-columns.d.ts +1 -6
  32. package/dist/model/part-columns.js +1 -1
  33. package/dist/model/part-rows.d.ts +2 -9
  34. package/dist/model/part-rows.js +1 -10
  35. package/dist/model/preferences.d.ts +3 -23
  36. package/dist/model/preferences.js +1 -17
  37. package/dist/model/prefs-buckets.d.ts +0 -27
  38. package/dist/model/prefs-buckets.js +1 -1
  39. package/dist/model/relation-filters.d.ts +0 -1
  40. package/dist/model/relation-filters.js +1 -1
  41. package/dist/model/row-icon.d.ts +5 -9
  42. package/dist/model/view-rules.d.ts +32 -6
  43. package/dist/model/view-rules.js +94 -22
  44. package/dist/provider/ViewsProvider.d.ts +6 -2
  45. package/dist/provider/ViewsProvider.js +3 -2
  46. package/dist/provider/components.d.ts +16 -0
  47. package/dist/provider/context.d.ts +3 -1
  48. package/dist/provider/desktop.d.ts +3 -0
  49. package/dist/provider/desktop.js +7 -4
  50. package/dist/react.d.ts +2 -2
  51. package/dist/selection/SelectionBar.d.ts +18 -0
  52. package/dist/selection/SelectionBar.js +92 -0
  53. package/dist/selection/SelectionBarPhone.d.ts +3 -0
  54. package/dist/selection/SelectionBarPhone.js +14 -0
  55. package/dist/selection/bar-overflow.d.ts +12 -0
  56. package/dist/selection/bar-overflow.js +42 -0
  57. package/dist/selection/bar-parts.d.ts +15 -0
  58. package/dist/selection/bar-parts.js +17 -0
  59. package/dist/selection/index.d.ts +2 -0
  60. package/dist/selection/index.js +1 -0
  61. package/dist/selection/types.d.ts +3 -2
  62. package/dist/selection/verbs.d.ts +34 -0
  63. package/dist/selection/verbs.js +1 -0
  64. package/docs/contract.md +62 -8
  65. package/docs/getting-started.md +1 -1
  66. package/docs/guides/atoms.md +2 -1
  67. package/docs/guides/selection.md +32 -20
  68. package/docs/guides/the-grid.md +3 -2
  69. package/docs/guides/the-provider.md +4 -2
  70. package/docs/index.md +2 -0
  71. package/docs/install.md +4 -1
  72. package/docs/reference/grid.md +2 -2
  73. package/docs/reference/react.md +13 -3
  74. package/docs/reference/selection.md +10 -2
  75. package/docs/reference/views.md +25 -27
  76. package/package.json +22 -3
  77. package/skills/views/SKILL.md +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,154 @@ All notable changes to `@viewkitjs/views`. `0.x`: the API may change between min
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.5.0] — 2026-11-14
8
+
9
+ The selection bar, one conversion between a filter panel and a view's filter tree, figures worked out by
10
+ `@viewkitjs/fields`, and the rows, icons and words the list's panels will draw with. It needs `@viewkitjs/fields`
11
+ 0.12. The panels' own door, `@viewkitjs/views/panels`, is still being built and is not in this version: a later
12
+ release publishes it, with the controls.
13
+
14
+ What an app changes when it takes this version:
15
+
16
+ - **Install `@viewkitjs/fields` 0.12** beside it: the peer is `^0.12.0` (Changed).
17
+ - **Your icons map draws two more glyphs**, `search` and `reset`: an icons map typed `ViewsIcons` doesn't compile
18
+ until it does (For an adapter).
19
+ - **Forty-six new message keys**, ten `views.selection.*` and thirty-six `views.panels.*`. A resolver that falls back
20
+ to `resolveViewsMessage` reads them in English; one that words every message with a `switch` and no default must
21
+ word them, and a test that holds your catalogue to `VIEWS_MESSAGE_KEYS` fails until it does (For an adapter).
22
+ - **Fourteen names are removed**, each with what replaces it (Removed). None of them is needed by a grid, an editor
23
+ or a display that an app draws.
24
+
25
+ ### Added
26
+
27
+ - **The selection bar.** `SelectionBar` on `@viewkitjs/views/selection` draws the bar a selection opens: the count
28
+ that clears it, your verbs as data (`SelectionVerb`: an action, a group, or an options verb picked as badges), the
29
+ trash for `onDelete` and More. An island on a desktop, a pill on a phone whose Actions open the new
30
+ `SelectionSheet` atom, which an app swaps for its own action sheet. Its words are the new `views.selection.*`
31
+ messages, its slots `vk-selection-bar`, `vk-selection-pill` and `vk-selection-chip`, and it reads the new optional
32
+ `--vk-float-shadow`. The provider's new `selectionBar` (`ViewsSelectionBarSettings`) places it.
33
+ - One conversion between a filter panel and a view's filter tree, both ways: `filterPanelFromTree(tree, columns, { parts })`
34
+ reads a tree into `{ op, rules, rest }`, a rule per column (and per part row), and `treeFromFilterPanel(panel, columns,
35
+ { parts })` writes it back. Whatever no row can draw (and/or groups, relation rules, a second rule on one column, an
36
+ operator its editor doesn't write) is kept whole in `rest`, so a round trip loses no rule, and reading the tree it
37
+ writes gives the same state.
38
+ - Quick values convert through the same rules: `quickValuesFromTree(tree, fields)` reads an offered field's picks,
39
+ `withQuickValues(tree, fields, values)` writes them as ordinary root rules. Types: `FilterPanelState`, `QuickValues`,
40
+ `QuickValueField`.
41
+ - Seven atoms for a list's panels' rows, each with a plain default: `ChoiceRow`, `CheckRow`, `RadioRow`,
42
+ `DirectionButton`, `MenuRow`, `ToggleRow` and `PanelSearch`, marked `data-slot="vk-choice-row"` and so on. Your own
43
+ panels may draw with them today.
44
+ - Two icon names: `search` (a panel's text box) and `reset` (a setting's way back to the reader's default).
45
+ - The `views.panels.*` message keys, for the panels' words.
46
+ - `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` as optional peer dependencies, for the panels' door a
47
+ later release publishes. This version reaches none of them: don't install them for it.
48
+
49
+ ### Changed
50
+
51
+ - **The peer is `@viewkitjs/fields` `^0.12.0`.** `ListColumnState`, `ListDensity`, `FigureKind`, `partKey`,
52
+ `parsePartKey` and a group header's figures (`ListGroupSummaryPart`, `ListGroupFigurePart`, `isGroupSummaryPart`,
53
+ `normalizeGroupSummary`, `groupFigurePart`) are now `@viewkitjs/fields/query`'s, re-exported unchanged, so this
54
+ version needs fields 0.12.0, which carries them.
55
+ - A grid's figures (sum, average, smallest, largest, count, filled, unique and ratio) are now worked out by
56
+ `@viewkitjs/fields`, whose query entry answers the same figures in memory and in the shape a database answers.
57
+ Nothing changes in what a footer or a group band shows. `EMPTY_FIGURE`, `combineFigure`, `figureFor`,
58
+ `figureOf`, `isGroupFigures`, `ratioFigure`, `ColumnFigure`, `FigureKind` and `GroupFigures` are still exported
59
+ from `@viewkitjs/views`, now as `@viewkitjs/fields/query`'s own: import them from either.
60
+ - `ListAggregateKind` is now `@viewkitjs/fields/query`'s `FigureKind` under the grid's name: the same picks, written
61
+ once.
62
+ - **`ListSelectionConfig.renderBar` is optional.** A selection with none ticks rows and draws no bar; an app that
63
+ handed `() => null` can drop it.
64
+ - The filter panel's rows leave a set-aside rule unseen and untouched: `rootRulesByColumn` and `rootRelationRules`
65
+ never read one into a row, and `withRootRule` and `withRootRelationRules` keep it as it is when a row is written or
66
+ cleared. Until a list shows set-aside rules, such a rule stays kept and filters nothing.
67
+
68
+ ### Removed
69
+
70
+ - `OrderMode` and `OrderDir`. They restated `@viewkitjs/fields/query`'s `BucketOrderMode` and `SortDirection`, which
71
+ `OrderChoice`, `defaultDirFor` and `sortDirFor` now name:
72
+
73
+ ```ts
74
+ // before
75
+ import type { OrderDir, OrderMode } from "@viewkitjs/views";
76
+ // after
77
+ import type { BucketOrderMode, SortDirection } from "@viewkitjs/fields/query";
78
+ ```
79
+
80
+ - `ListStatusSlot` and `ListRowIconTone`, two more names for `StatusSlot`:
81
+
82
+ ```ts
83
+ // before
84
+ import type { ListStatusSlot } from "@viewkitjs/views";
85
+ // after
86
+ import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
87
+ ```
88
+
89
+ - `withRootRuleState`. Write a panel's rules back with `treeFromFilterPanel`:
90
+
91
+ ```ts
92
+ // before
93
+ withRootRuleState(tree, columns, rules, { parts: true });
94
+ // after
95
+ treeFromFilterPanel({ ...filterPanelFromTree(tree, columns, { parts: true }), rules }, columns, { parts: true });
96
+ ```
97
+
98
+ - `LIST_AGGREGATE_LABELS`. Word a figure with `aggregateLabel(kind, messages?)`, which gives the same English without
99
+ `messages`:
100
+
101
+ ```ts
102
+ // before
103
+ LIST_AGGREGATE_LABELS.sum;
104
+ // after
105
+ aggregateLabel("sum");
106
+ ```
107
+
108
+ - `PART_KEY_SEPARATOR`: `partKey` joins a key and its part, and `parsePartKey` splits one:
109
+
110
+ ```ts
111
+ // before
112
+ `${columnId}${PART_KEY_SEPARATOR}${part}`;
113
+ // after
114
+ partKey(columnId, part);
115
+ ```
116
+
117
+ - `computeMinWidth`: sum the columns' widths and your gutter yourself.
118
+ - `ListFieldFormatPrefs`, which nothing read.
119
+ - `RELATED_RECORDS_SECTION`, `LIST_DEFAULT_MIN_WIDTH`, `LIST_LAYOUT_DEFAULTS`, `gridColumnIsNumericAgg` and
120
+ `resolveGridRelation`, which only served the function beside them: `buildColumnFilters` places the relation rows,
121
+ `clampColumnWidth` holds a column to 60 pixels when it states no `grid.minWidth`, `readViewLayout` fills in the shipped
122
+ layout, `aggregateOptions` says which figures a column offers, and `@viewkitjs/fields`'
123
+ `resolveRelationValue(raw, col.relation?.entity)` reads a relation value.
124
+
125
+ ### Fixed
126
+
127
+ - A number between, or a range's end between, with one end still empty converts to `null` at that end, both ways, and
128
+ filters nothing until both ends are in. It had been written as `0`, narrowing the list to values from 0.
129
+ - A panel rule on "is empty" or "is not empty" converts to a rule whose value is `null`, which `filterValueSchema`
130
+ accepts. A text row's had carried its box's `""`.
131
+ - `filterPanelFromTree` and `quickValuesFromTree` no longer read a set-aside rule into a row, so writing the panel back
132
+ with `treeFromFilterPanel` or `withQuickValues` keeps it set aside, where before it lost its mark and filtered again.
133
+ - A footer or a group band totalling a column no longer reads a list, a yes/no or blank text as a number: a cell
134
+ holding `[]`, `true` or `" "` is no value, as an empty cell is, so it no longer adds 0 or 1 to a sum or an average.
135
+
136
+ ### For an adapter
137
+
138
+ - **Your icons map draws `search` and `reset`.** `ICON_NAMES` gains both, and `ViewsIcons` requires them:
139
+
140
+ ```tsx
141
+ // before
142
+ const icons: ViewsIcons = { ...glyphs };
143
+ // after
144
+ const icons: ViewsIcons = { ...glyphs, search: SearchIcon, reset: ResetIcon };
145
+ ```
146
+
147
+ - **Forty-six new message keys**: ten `views.selection.*` (the selection bar's words) and thirty-six `views.panels.*`
148
+ (the panels' words). A resolver that words every message with a `switch` and no default must word them too; one
149
+ that falls back to `resolveViewsMessage` reads them in English. The [contract](docs/contract.md#message-keys) lists
150
+ every key with its English.
151
+ - `ATOM_NAMES` gains the seven panel rows and `SelectionSheet`. An adapter typed as the whole `ViewsAtoms` won't
152
+ compile until it maps them or leaves them to the defaults (`Omit<ViewsAtoms, …>`); the provider's `atoms` takes any
153
+ part of it, as before.
154
+
7
155
  ## [0.4.0] — 2026-11-13
8
156
 
9
157
  Three bodies of work in one release: the field editors' last fixes, a grid that keeps up better on a phone, and
package/README.md CHANGED
@@ -10,7 +10,7 @@ The grid, its cells, the field display and the editors over typed fields: a head
10
10
  pnpm add @viewkitjs/views @viewkitjs/fields zod
11
11
  ```
12
12
 
13
- ESM only. Node 20 or later. `react` and `react-dom` 19 and `@viewkitjs/fields` are peer dependencies. Add one `@source` line so Tailwind sees the package, and map its colours onto your theme: [docs/install.md](./docs/install.md).
13
+ ESM only. Node 20 or later. `react` and `react-dom` 19 and `@viewkitjs/fields` are peer dependencies; `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` are optional ones, installed only to use `/panels`. Add one `@source` line so Tailwind sees the package, and map its colours onto your theme: [docs/install.md](./docs/install.md).
14
14
 
15
15
  ## Getting started
16
16
 
@@ -69,7 +69,7 @@ Guides:
69
69
  - [The grid](./docs/guides/the-grid.md): grouping, sorting, writes, preferences, figures and the editing rules.
70
70
  - [The rendering contract](./docs/contract.md): every public name and what each door holds; [reshaping a view](./docs/reshaping.md): the cheapest change first.
71
71
 
72
- References, one per door, each naming every export: [`@viewkitjs/views`](./docs/reference/views.md), [`/react`](./docs/reference/react.md), [`/display`](./docs/reference/display.md), [`/editors`](./docs/reference/editors.md), [`/editors/select`](./docs/reference/editors-select.md), [`/editors/text`](./docs/reference/editors-text.md), [`/editors/relation`](./docs/reference/editors-relation.md), [`/editors/number`](./docs/reference/editors-number.md), [`/editors/range`](./docs/reference/editors-range.md), [`/editors/name`](./docs/reference/editors-name.md), [`/editors/location`](./docs/reference/editors-location.md), [`/editors/value-list`](./docs/reference/editors-value-list.md), [`/editors/date`](./docs/reference/editors-date.md), [`/editors/chips`](./docs/reference/editors-chips.md), [`/editors/session`](./docs/reference/editors-session.md), [`/editors/panel`](./docs/reference/editors-panel.md), [`/editors/open-values`](./docs/reference/editors-open-values.md), [`/field-row`](./docs/reference/field-row.md), [`/cells`](./docs/reference/cells.md), [`/selection`](./docs/reference/selection.md), [`/grid`](./docs/reference/grid.md).
72
+ References, one per door, each naming every export: [`@viewkitjs/views`](./docs/reference/views.md), [`/react`](./docs/reference/react.md), [`/display`](./docs/reference/display.md), [`/editors`](./docs/reference/editors.md), [`/editors/select`](./docs/reference/editors-select.md), [`/editors/text`](./docs/reference/editors-text.md), [`/editors/relation`](./docs/reference/editors-relation.md), [`/editors/number`](./docs/reference/editors-number.md), [`/editors/range`](./docs/reference/editors-range.md), [`/editors/name`](./docs/reference/editors-name.md), [`/editors/location`](./docs/reference/editors-location.md), [`/editors/value-list`](./docs/reference/editors-value-list.md), [`/editors/date`](./docs/reference/editors-date.md), [`/editors/chips`](./docs/reference/editors-chips.md), [`/editors/session`](./docs/reference/editors-session.md), [`/editors/panel`](./docs/reference/editors-panel.md), [`/editors/open-values`](./docs/reference/editors-open-values.md), [`/field-row`](./docs/reference/field-row.md), [`/cells`](./docs/reference/cells.md), [`/selection`](./docs/reference/selection.md) and [`/grid`](./docs/reference/grid.md).
73
73
 
74
74
  ## Doors
75
75
 
@@ -87,7 +87,7 @@ References, one per door, each naming every export: [`@viewkitjs/views`](./docs/
87
87
  | `@viewkitjs/views/selection` | a list's selection: the model, the hook, the row checkbox, drag-select and the row-click rules |
88
88
  | `@viewkitjs/views/grid` | the grid: the table, its props, its preferences, and the helpers a host shares with it |
89
89
 
90
- Twenty-one doors; there are no other subpaths.
90
+ Twenty-one doors; there are no other subpaths. A twenty-second, `@viewkitjs/views/panels` (what a list's panels read and say), is still being built and comes in a later release, with the controls.
91
91
 
92
92
  ## For coding agents
93
93
 
@@ -0,0 +1,3 @@
1
+ import type { ViewsMenuRowProps, ViewsToggleRowProps } from "./types.js";
2
+ export declare function DefaultMenuRow({ icon, label, value, active, disabled, onClick }: ViewsMenuRowProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function DefaultToggleRow({ icon, label, active, disabled, onClick, reset }: ViewsToggleRowProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cx } from "../internal/cx.js";
4
+ import { ELEMENT_RESET } from "../internal/reset.js";
5
+ import { useViews } from "../provider/context.js";
6
+ const ROW = "flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-(color:--vk-hovered)";
7
+ function Glyph({ active, children }) {
8
+ return (_jsx("span", { className: cx("flex size-4 shrink-0 items-center justify-center", active ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg-subtle)"), children: children }));
9
+ }
10
+ export function DefaultMenuRow({ icon, label, value, active, disabled, onClick }) {
11
+ const Chevron = useViews().icons.chevronRight;
12
+ return (_jsxs("button", { type: "button", "data-slot": "vk-menu-row", "data-chosen": active || undefined, "data-disabled": disabled || undefined, onClick: onClick, disabled: disabled, className: cx(ELEMENT_RESET, ROW, disabled && "cursor-default opacity-50 hover:bg-transparent"), children: [_jsx(Glyph, { active: active, children: icon }), _jsx("span", { className: cx("flex-1 whitespace-nowrap text-sm font-medium", active ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg)"), children: label }), _jsx("span", { className: cx("max-w-[120px] shrink-0 truncate whitespace-nowrap text-xs", active ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg-subtle)"), children: value }), disabled ? null : _jsx(Chevron, { className: "size-3.5 shrink-0 text-(color:--vk-fg-subtlest)" })] }));
13
+ }
14
+ function SwitchMark({ on }) {
15
+ return (_jsx("span", { "aria-hidden": "true", className: cx("inline-flex h-4 w-7 shrink-0 items-center rounded-full border-2 transition-colors", on ? "border-transparent bg-(color:--vk-brand)" : "border-(color:--vk-border) bg-transparent"), children: _jsx("span", { className: cx("block size-3 rounded-full transition-transform", on ? "translate-x-3 bg-(color:--vk-fg-on-brand)" : "translate-x-0 bg-(color:--vk-border)") }) }));
16
+ }
17
+ export function DefaultToggleRow({ icon, label, active, disabled, onClick, reset }) {
18
+ const { icons, messages } = useViews();
19
+ const Reset = icons.reset;
20
+ const labelText = _jsx("span", { className: "flex-1 whitespace-nowrap text-sm font-medium text-(color:--vk-fg)", children: label });
21
+ if (reset) {
22
+ return (_jsxs("div", { "data-slot": "vk-toggle-row", "data-checked": active || undefined, className: ROW, children: [_jsxs("button", { type: "button", onClick: onClick, disabled: disabled, "aria-pressed": active, className: cx(ELEMENT_RESET, "flex min-w-0 flex-1 items-center gap-2.5 text-left"), children: [_jsx(Glyph, { active: active, children: icon }), labelText] }), _jsx("button", { type: "button", onClick: reset.onReset, "aria-label": messages({ key: "views.panels.toggle-reset", values: { label } }), title: messages({ key: "views.panels.toggle-reset-hint" }), className: cx(ELEMENT_RESET, "flex size-5 shrink-0 items-center justify-center rounded-full text-(color:--vk-fg-subtle) transition-colors hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)"), children: _jsx(Reset, { className: "size-3" }) }), _jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-pressed": active, className: cx(ELEMENT_RESET, "flex h-5 shrink-0 items-center"), children: _jsx(SwitchMark, { on: active }) })] }));
23
+ }
24
+ return (_jsxs("button", { type: "button", "data-slot": "vk-toggle-row", "data-checked": active || undefined, onClick: onClick, disabled: disabled, "aria-pressed": active, className: cx(ELEMENT_RESET, ROW, disabled && "cursor-default opacity-50 hover:bg-transparent"), children: [_jsx(Glyph, { active: active, children: icon }), labelText, _jsx(SwitchMark, { on: active })] }));
25
+ }
@@ -0,0 +1,5 @@
1
+ import type { ViewsCheckRowProps, ViewsChoiceRowProps, ViewsDirectionButtonProps, ViewsRadioRowProps } from "./types.js";
2
+ export declare function DefaultChoiceRow({ selected, label, description, meta, leading, trailing, onClick, onMouseDown, disabled, className, role, "aria-selected": ariaSelected, }: ViewsChoiceRowProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function DefaultCheckRow({ checked, onClick, children, leading, trailing, disabled, className }: ViewsCheckRowProps): import("react/jsx-runtime").JSX.Element;
4
+ export declare function DefaultRadioRow({ selected, label, onClick, leading, trailing, className, checkClassName, labelClassName, mark, disabled, disabledReason, }: ViewsRadioRowProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function DefaultDirectionButton({ dir, onClick, className, iconClassName }: ViewsDirectionButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cx } from "../internal/cx.js";
4
+ import { ELEMENT_RESET } from "../internal/reset.js";
5
+ import { useViews } from "../provider/context.js";
6
+ const ROW = "flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-sm transition-colors hover:bg-(color:--vk-hovered)";
7
+ const CHOSEN = "font-medium text-(color:--vk-fg-selected)";
8
+ const DISABLED = "pointer-events-none opacity-50";
9
+ const DISABLED_REASON_DELAY_MS = 1000;
10
+ function ChosenCheck({ className }) {
11
+ const Check = useViews().icons.check;
12
+ return (_jsx("span", { className: "ml-auto flex size-4 shrink-0 items-center justify-center text-(color:--vk-fg-selected)", children: _jsx(Check, { className: cx("size-3.5", className) }) }));
13
+ }
14
+ function Slot({ children }) {
15
+ return _jsx("span", { className: "flex shrink-0 items-center", children: children });
16
+ }
17
+ export function DefaultChoiceRow({ selected = false, label, description, meta, leading, trailing, onClick, onMouseDown, disabled, className, role, "aria-selected": ariaSelected, }) {
18
+ return (_jsxs("button", { type: "button", "data-slot": "vk-choice-row", "data-chosen": selected || undefined, onClick: onClick, onMouseDown: onMouseDown, disabled: disabled, role: role, "aria-selected": ariaSelected, className: cx(ELEMENT_RESET, ROW, selected ? CHOSEN : "text-(color:--vk-fg)", disabled && DISABLED, className), children: [leading ? _jsx(Slot, { children: leading }) : null, _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "truncate", children: label }), description ? (_jsx("span", { className: "mt-0.5 truncate text-[11px] font-normal leading-snug text-(color:--vk-fg-subtle)", children: description })) : null] }), meta ? (_jsx("span", { className: cx("ml-3.5 shrink-0 truncate text-xs font-normal", selected ? "text-(color:--vk-fg-brand)" : "text-(color:--vk-fg-subtle)"), children: meta })) : null, trailing ? _jsx(Slot, { children: trailing }) : null, selected && !meta ? _jsx(ChosenCheck, {}) : null] }));
19
+ }
20
+ export function DefaultCheckRow({ checked, onClick, children, leading, trailing, disabled, className }) {
21
+ const { TickBox } = useViews().atoms;
22
+ return (_jsxs("button", { type: "button", "data-slot": "vk-check-row", "data-checked": checked || undefined, "aria-pressed": checked, onClick: onClick, disabled: disabled, className: cx(ELEMENT_RESET, ROW, "text-(color:--vk-fg)", disabled && DISABLED, className), children: [_jsx(TickBox, { checked: checked }), leading ? _jsx(Slot, { children: leading }) : null, _jsx("span", { className: "inline-flex min-w-0 flex-1 items-center", children: children }), trailing ? _jsx(Slot, { children: trailing }) : null] }));
23
+ }
24
+ export function DefaultRadioRow({ selected, label, onClick, leading, trailing, className, checkClassName, labelClassName, mark = "check", disabled, disabledReason, }) {
25
+ const { atoms, components } = useViews();
26
+ const box = mark === "box";
27
+ const row = (_jsxs("div", { "data-slot": "vk-radio-row", "data-chosen": selected || undefined, "data-disabled": disabled || undefined, className: cx(ROW, disabled && DISABLED, className), children: [_jsxs("button", { type: "button", "aria-pressed": selected, disabled: disabled, "aria-disabled": disabled || undefined, onClick: disabled ? undefined : onClick, className: cx(ELEMENT_RESET, "flex min-w-0 flex-1 items-center gap-2.5 text-left", !box && selected ? CHOSEN : "text-(color:--vk-fg)"), children: [box ? _jsx(atoms.TickBox, { checked: selected }) : null, leading ? _jsx(Slot, { children: leading }) : null, _jsx("span", { className: cx("flex-1 truncate text-sm", labelClassName), children: label }), !box && selected ? _jsx(ChosenCheck, { className: checkClassName }) : null] }), trailing] }));
28
+ if (!disabled || !disabledReason)
29
+ return row;
30
+ return (_jsx(components.Tooltip, { content: disabledReason, side: "right", delayMs: DISABLED_REASON_DELAY_MS, children: _jsx("span", { className: "block", children: row }) }));
31
+ }
32
+ export function DefaultDirectionButton({ dir, onClick, className, iconClassName }) {
33
+ const { icons, messages } = useViews();
34
+ const Arrow = icons.sortAsc;
35
+ return (_jsx("button", { type: "button", "data-slot": "vk-direction", "data-dir": dir, "aria-label": messages({ key: "views.panels.direction", values: { dir } }), onPointerDown: (event) => event.stopPropagation(), onClick: (event) => {
36
+ event.preventDefault();
37
+ event.stopPropagation();
38
+ onClick();
39
+ }, className: cx(ELEMENT_RESET, "inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm text-(color:--vk-fg-brand) transition-colors hover:bg-(color:--vk-brand-subtlest)", className), children: _jsx(Arrow, { className: cx("size-3.5 transition-transform duration-200 ease-out", dir === "desc" && "rotate-180", iconClassName) }) }));
40
+ }
@@ -0,0 +1,2 @@
1
+ import type { ViewsPanelSearchProps } from "./types.js";
2
+ export declare function DefaultPanelSearch({ value, onChange, onClear, placeholder, autoFocus, onKeyDown, onFocus, inputRef, className, leading, suffix, inputMode, }: ViewsPanelSearchProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef } from "react";
4
+ import { cx } from "../internal/cx.js";
5
+ import { ELEMENT_RESET } from "../internal/reset.js";
6
+ import { useViews } from "../provider/context.js";
7
+ export function DefaultPanelSearch({ value, onChange, onClear, placeholder, autoFocus = false, onKeyDown, onFocus, inputRef, className, leading, suffix, inputMode, }) {
8
+ const { icons, messages } = useViews();
9
+ const ownRef = useRef(null);
10
+ const ref = inputRef ?? ownRef;
11
+ const Search = icons.search;
12
+ const Close = icons.close;
13
+ const lead = leading === undefined ? _jsx(Search, { className: "size-4 text-(color:--vk-fg-subtlest)" }) : leading;
14
+ return (_jsxs("div", { "data-slot": "vk-panel-search", className: cx("flex items-center gap-1.5 rounded-lg bg-(color:--vk-neutral) px-2.5 py-1.5 transition-colors focus-within:ring-1 focus-within:ring-(color:--vk-border-brand)", className), children: [lead ? _jsx("span", { className: "flex shrink-0 items-center", children: lead }) : null, _jsx("input", { ref: ref, type: "text", value: value, autoFocus: autoFocus, autoComplete: "off", onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, onFocus: onFocus, placeholder: placeholder, inputMode: inputMode, className: cx(ELEMENT_RESET, "min-w-0 flex-1 bg-transparent text-base text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest) md:text-sm") }), suffix != null ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtlest)", children: suffix }) : null, value.length > 0 ? (_jsx("button", { type: "button", "aria-label": messages({ key: "views.panels.search-clear" }), onClick: () => {
15
+ if (onClear)
16
+ onClear();
17
+ else
18
+ onChange("");
19
+ ref.current?.focus();
20
+ }, className: cx(ELEMENT_RESET, "-mr-1 inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-(color:--vk-fg-subtlest) transition-colors hover:text-(color:--vk-fg)"), children: _jsx(Close, { className: "size-3.5" }) })) : null] }));
21
+ }
@@ -0,0 +1,3 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ViewsSelectionSheetProps } from "./types.js";
3
+ export declare function DefaultSelectionSheet({ open, onOpenChange, title, verbs, onDelete, deleteLabel, busy }: ViewsSelectionSheetProps): ReactNode;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Fragment, useState } from "react";
4
+ import { cx } from "../internal/cx.js";
5
+ import { useViews } from "../provider/context.js";
6
+ import { OptionLabel } from "../selection/bar-parts.js";
7
+ const DANGER = "text-(color:--vk-danger)";
8
+ export function DefaultSelectionSheet({ open, onOpenChange, title, verbs, onDelete, deleteLabel, busy }) {
9
+ const { components, atoms, icons, messages } = useViews();
10
+ const { Sheet, Collapse } = components;
11
+ const { List, Row } = atoms;
12
+ const [expanded, setExpanded] = useState(null);
13
+ if (!open && expanded !== null)
14
+ setExpanded(null);
15
+ const run = (verb) => () => {
16
+ onOpenChange(false, { reason: "item-press" });
17
+ verb();
18
+ };
19
+ const Trash = icons.delete;
20
+ return (_jsx(Sheet, { open: open, onOpenChange: onOpenChange, title: title, label: messages({ key: "views.selection.sheet-label" }), snap: "auto", children: _jsx("div", { "data-slot": "vk-selection-sheet", children: _jsxs(List, { children: [verbs.map((verb, index) => {
21
+ if (verb.kind === "action") {
22
+ return (_jsx(Row, { label: verb.label, leading: verb.icon, className: cx(verb.destructive && DANGER), disabled: busy || verb.disabled, onClick: run(verb.onClick) }, index));
23
+ }
24
+ const isOpen = expanded === index;
25
+ const rows = verb.kind === "group"
26
+ ? verb.items.map((item, at) => (_jsx(Row, { label: item.label, leading: item.icon, className: cx(item.destructive && DANGER), disabled: busy || item.disabled, onClick: run(item.onClick) }, at)))
27
+ : verb.options.map((option) => (_jsx(Row, { size: "compact", label: _jsx(OptionLabel, { option: option }), disabled: busy, onClick: run(() => verb.onSelect(option.value)) }, option.value)));
28
+ return (_jsxs(Fragment, { children: [_jsx(Row, { label: verb.label, leading: verb.icon, disabled: busy || verb.disabled, open: isOpen, onClick: () => setExpanded(isOpen ? null : index) }), _jsx(Collapse, { open: isOpen, children: _jsx("div", { className: "pl-4", children: rows }) })] }, index));
29
+ }), onDelete ? (_jsx(Row, { label: deleteLabel, leading: _jsx(Trash, { className: "h-4 w-4" }), className: DANGER, disabled: busy, onClick: run(onDelete) })) : null] }) }) }));
30
+ }
@@ -1,4 +1,7 @@
1
1
  import { DefaultCommandMenu } from "./CommandMenu.js";
2
+ import { DefaultMenuRow, DefaultToggleRow } from "./DrillRows.js";
3
+ import { DefaultCheckRow, DefaultChoiceRow, DefaultDirectionButton, DefaultRadioRow } from "./PanelRows.js";
4
+ import { DefaultPanelSearch } from "./PanelSearch.js";
2
5
  import { DefaultList } from "./List.js";
3
6
  import { DefaultLoading } from "./Loading.js";
4
7
  import { DefaultLoadMore } from "./LoadMore.js";
@@ -7,6 +10,7 @@ import { DefaultRelationLink } from "./RelationLink.js";
7
10
  import { DefaultRelationRoles } from "./RelationRoles.js";
8
11
  import { DefaultRow, DefaultRowContent } from "./Row.js";
9
12
  import { DefaultRowMenu } from "./RowMenu.js";
13
+ import { DefaultSelectionSheet } from "./SelectionSheet.js";
10
14
  import { DefaultStatusBadge } from "./StatusBadge.js";
11
15
  import { DefaultStatusMarker } from "./StatusMarker.js";
12
16
  import { DefaultTag } from "./Tag.js";
@@ -26,4 +30,12 @@ export const DEFAULT_VIEWS_ATOMS = {
26
30
  LoadMore: DefaultLoadMore,
27
31
  PlatformMark: DefaultPlatformMark,
28
32
  RowMenu: DefaultRowMenu,
33
+ ChoiceRow: DefaultChoiceRow,
34
+ CheckRow: DefaultCheckRow,
35
+ RadioRow: DefaultRadioRow,
36
+ DirectionButton: DefaultDirectionButton,
37
+ MenuRow: DefaultMenuRow,
38
+ ToggleRow: DefaultToggleRow,
39
+ PanelSearch: DefaultPanelSearch,
40
+ SelectionSheet: DefaultSelectionSheet,
29
41
  };
@@ -1,8 +1,10 @@
1
- import type { ComponentType, MouseEventHandler, ReactElement, ReactNode } from "react";
1
+ import type { ComponentType, KeyboardEvent, MouseEventHandler, ReactElement, ReactNode, RefObject } from "react";
2
2
  import type { LinkPlatform, RelationValue } from "@viewkitjs/fields";
3
3
  import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
4
4
  import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
5
5
  import type { FieldRowMenuItem } from "../fields/menus.js";
6
+ import type { ViewsOpenChange } from "../provider/components.js";
7
+ import type { SelectionVerb } from "../selection/verbs.js";
6
8
  /** A row's inside. Inside a command list's item it is all the row is: the item owns
7
9
  * the element, the highlight and the keyboard. */
8
10
  export type ViewsRowContentProps = {
@@ -157,6 +159,22 @@ export type ViewsRowMenuItem = {
157
159
  /** A keyboard hint drawn at the row's end, never bound by the menu. */
158
160
  shortcut?: string;
159
161
  };
162
+ /** The phone's sheet of a selection's verbs, opened by the selection bar's Actions. The default is the
163
+ * components map's `Sheet` holding the atoms' rows: a group's or an options verb's rows open in place under
164
+ * it, and the delete comes last, in words. Picking a row closes the sheet, then runs it, since a verb usually
165
+ * ends by clearing the selection and taking the bar down with it. An app swaps in its own action sheet. */
166
+ export type ViewsSelectionSheetProps = {
167
+ open: boolean;
168
+ onOpenChange: ViewsOpenChange;
169
+ /** "3 selected". */
170
+ title: string;
171
+ verbs: readonly SelectionVerb[];
172
+ /** The bar's own delete, drawn last; absent when the list has no bulk delete. */
173
+ onDelete?: () => void;
174
+ deleteLabel: string;
175
+ /** A batch is running: every row is disabled. */
176
+ busy: boolean;
177
+ };
160
178
  /** The rows' right-click menu, around the rows it opens on. The grid mounts ONE for each section's rows'
161
179
  * container, never one per row, and AIMS it: its props are those of the row a press or a right-click came
162
180
  * from, set in the same event the menu opens on, so a person meets each row's own menu. The rendering
@@ -182,6 +200,96 @@ export type ViewsRowMenuProps = {
182
200
  * The default doesn't use it: on a phone the ⋯ is the way in. */
183
201
  onToggleSelect?: () => void;
184
202
  };
203
+ /** Picks one value: its label, a second line, a right-hand `meta` (a sample, a count), the check when chosen. */
204
+ export type ViewsChoiceRowProps = {
205
+ selected?: boolean;
206
+ label: ReactNode;
207
+ /** A second line under the label. */
208
+ description?: ReactNode;
209
+ /** Right-aligned secondary text; a row with one draws no check, its meta in the brand colour when chosen. */
210
+ meta?: ReactNode;
211
+ leading?: ReactNode;
212
+ trailing?: ReactNode;
213
+ onClick: () => void;
214
+ /** For a row inside an editor that must keep its input focused. */
215
+ onMouseDown?: MouseEventHandler<HTMLButtonElement>;
216
+ disabled?: boolean;
217
+ className?: string;
218
+ role?: string;
219
+ "aria-selected"?: boolean;
220
+ };
221
+ /** Toggles one of many: a tick box on the left shows both states. */
222
+ export type ViewsCheckRowProps = {
223
+ checked: boolean;
224
+ onClick: () => void;
225
+ children: ReactNode;
226
+ leading?: ReactNode;
227
+ trailing?: ReactNode;
228
+ /** Drawn but not togglable for now (a toggle still saving). */
229
+ disabled?: boolean;
230
+ className?: string;
231
+ };
232
+ /** Picks one of a set: `mark="check"` (default) marks the chosen row with a check, `mark="box"` draws a tick
233
+ * box with radio semantics. `trailing` sits outside the choosing button. A disabled row with a
234
+ * `disabledReason` shows it in the map's `Tooltip` once the pointer rests. */
235
+ export type ViewsRadioRowProps = {
236
+ selected: boolean;
237
+ label: string;
238
+ onClick: () => void;
239
+ leading?: ReactNode;
240
+ trailing?: ReactNode;
241
+ className?: string;
242
+ checkClassName?: string;
243
+ labelClassName?: string;
244
+ mark?: "check" | "box";
245
+ disabled?: boolean;
246
+ disabledReason?: string;
247
+ };
248
+ /** A sort's direction arrow, flipped by a press that never reaches the row around it. */
249
+ export type ViewsDirectionButtonProps = {
250
+ dir: "asc" | "desc";
251
+ onClick: () => void;
252
+ className?: string;
253
+ iconClassName?: string;
254
+ };
255
+ /** A drill-in row: a glyph, the section's name, where it stands, and a chevron unless disabled. */
256
+ export type ViewsMenuRowProps = {
257
+ icon: ReactNode;
258
+ label: string;
259
+ value: string;
260
+ active: boolean;
261
+ /** Listed but not openable. */
262
+ disabled?: boolean;
263
+ onClick: () => void;
264
+ };
265
+ /** A boolean that flips in place, a painted switch where the chevron would be; `reset` draws the way back to
266
+ * the reader's default on the row. */
267
+ export type ViewsToggleRowProps = {
268
+ icon?: ReactNode;
269
+ label: string;
270
+ active: boolean;
271
+ disabled?: boolean;
272
+ onClick: () => void;
273
+ reset?: {
274
+ onReset: () => void;
275
+ };
276
+ };
277
+ /** A panel's text box: a filled well with a magnifier. `leading` replaces it, `null` drops it. */
278
+ export type ViewsPanelSearchProps = {
279
+ value: string;
280
+ onChange: (value: string) => void;
281
+ /** Emptying, committed at once; falls back to `onChange("")`. */
282
+ onClear?: () => void;
283
+ placeholder?: string;
284
+ autoFocus?: boolean;
285
+ onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
286
+ onFocus?: () => void;
287
+ inputRef?: RefObject<HTMLInputElement | null>;
288
+ className?: string;
289
+ leading?: ReactNode | null;
290
+ suffix?: ReactNode;
291
+ inputMode?: "text" | "decimal" | "numeric";
292
+ };
185
293
  export type ViewsAtoms = {
186
294
  List: ComponentType<ViewsListProps>;
187
295
  Row: ComponentType<ViewsRowProps>;
@@ -197,4 +305,12 @@ export type ViewsAtoms = {
197
305
  LoadMore: ComponentType<ViewsLoadMoreProps>;
198
306
  PlatformMark: ComponentType<ViewsPlatformMarkProps>;
199
307
  RowMenu: ComponentType<ViewsRowMenuProps>;
308
+ ChoiceRow: ComponentType<ViewsChoiceRowProps>;
309
+ CheckRow: ComponentType<ViewsCheckRowProps>;
310
+ RadioRow: ComponentType<ViewsRadioRowProps>;
311
+ DirectionButton: ComponentType<ViewsDirectionButtonProps>;
312
+ MenuRow: ComponentType<ViewsMenuRowProps>;
313
+ ToggleRow: ComponentType<ViewsToggleRowProps>;
314
+ PanelSearch: ComponentType<ViewsPanelSearchProps>;
315
+ SelectionSheet: ComponentType<ViewsSelectionSheetProps>;
200
316
  };