viewkitjs 0.19.0 → 0.21.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 +66 -0
- package/MIGRATION.md +117 -0
- package/README.md +7 -3
- package/fields/README.md +3 -3
- package/fields/dist/derived.d.ts +4 -0
- package/fields/dist/derived.js +39 -0
- package/fields/dist/entities.js +30 -30
- package/fields/dist/formula.js +2 -2
- package/fields/dist/query/evaluate.js +5 -5
- package/fields/dist/query/figures.js +5 -5
- package/fields/dist/query/filter.d.ts +15 -0
- package/fields/dist/query/filter.js +85 -0
- package/fields/dist/query/hold.js +2 -2
- package/fields/dist/query/option-counts.js +2 -2
- package/fields/dist/query/read-rule.js +2 -2
- package/fields/dist/query/search.js +2 -2
- package/fields/dist/query/set-aside.js +4 -4
- package/fields/dist/query/settings.d.ts +2 -15
- package/fields/dist/query/settings.js +3 -81
- package/fields/dist/query/sort.js +4 -4
- package/fields/dist/registry.d.ts +19 -5
- package/fields/dist/registry.js +371 -50
- package/fields/dist/types.d.ts +1 -1
- package/fields/docs/getting-started.md +2 -2
- package/fields/docs/guides/checking-definitions.md +17 -4
- package/fields/docs/guides/derived-fields.md +5 -5
- package/fields/docs/guides/queries.md +1 -1
- package/fields/docs/reference/design-category-colors.md +1 -1
- package/fields/docs/reference/design-status-slots.md +1 -1
- package/fields/docs/reference/fields.md +3 -3
- package/fields/docs/reference/query.md +1 -0
- package/fields/skills/viewkit/SKILL.md +2 -2
- package/package.json +17 -6
- package/postgres/README.md +2 -2
- package/postgres/dist/access.d.ts +12 -4
- package/postgres/dist/access.js +3 -0
- package/postgres/dist/calendar.js +3 -2
- package/postgres/dist/check.d.ts +6 -4
- package/postgres/dist/check.js +27 -16
- package/postgres/dist/counts.js +3 -2
- package/postgres/dist/definitions/build.js +7 -0
- package/postgres/dist/definitions/formula.d.ts +1 -1
- package/postgres/dist/definitions/formula.js +5 -3
- package/postgres/dist/definitions/lookup.js +5 -1
- package/postgres/dist/definitions/money.js +6 -1
- package/postgres/dist/definitions/place.d.ts +7 -0
- package/postgres/dist/definitions/place.js +8 -0
- package/postgres/dist/definitions/relations.js +36 -3
- package/postgres/dist/definitions/rollup.d.ts +1 -1
- package/postgres/dist/definitions/rollup.js +11 -6
- package/postgres/dist/field-values.js +11 -8
- package/postgres/dist/figures.js +4 -2
- package/postgres/dist/filled.js +2 -2
- package/postgres/dist/groups.d.ts +2 -1
- package/postgres/dist/groups.js +5 -3
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/kept.js +8 -4
- package/postgres/dist/lanes.js +5 -3
- package/postgres/dist/phone.js +2 -2
- package/postgres/dist/predicates.js +2 -2
- package/postgres/dist/readable.d.ts +40 -0
- package/postgres/dist/readable.js +84 -0
- package/postgres/dist/records.js +7 -4
- package/postgres/dist/refusals.d.ts +8 -1
- package/postgres/dist/refusals.js +7 -0
- package/postgres/dist/relations.js +5 -4
- package/postgres/dist/search-indexes.js +2 -1
- package/postgres/dist/search.js +6 -4
- package/postgres/dist/several.js +8 -8
- package/postgres/dist/sort.d.ts +5 -3
- package/postgres/dist/sort.js +13 -8
- package/postgres/dist/value-rows.js +2 -2
- package/postgres/dist/values.js +4 -2
- package/postgres/docs/guides/definitions.md +2 -2
- package/postgres/docs/guides/field-map.md +43 -18
- package/postgres/docs/guides/test-kit.md +2 -0
- package/postgres/docs/reference/postgres.md +10 -4
- package/views/README.md +4 -2
- package/views/dist/atoms/StatusBadge.js +1 -1
- package/views/dist/atoms/tones.js +7 -7
- package/views/dist/atoms/types.d.ts +3 -2
- package/views/dist/contract.d.ts +7 -2
- package/views/dist/contract.js +33 -0
- package/views/dist/display/fit-values.d.ts +3 -2
- package/views/dist/display/link.d.ts +1 -1
- package/views/dist/display/location.js +2 -1
- package/views/dist/display/multi-value.js +1 -1
- package/views/dist/display/name.js +3 -1
- package/views/dist/display/select.js +1 -1
- package/views/dist/display/value-list.d.ts +1 -1
- package/views/dist/grid/chrome/GridStructure.js +2 -1
- package/views/dist/grid/looks.d.ts +45 -0
- package/views/dist/grid/looks.js +74 -0
- package/views/dist/looks/index.d.ts +7 -0
- package/views/dist/looks/index.js +3 -0
- package/views/dist/looks/looks.d.ts +46 -0
- package/views/dist/looks/looks.js +25 -0
- package/views/dist/looks/pieces.d.ts +3 -0
- package/views/dist/looks/pieces.js +2 -0
- package/views/dist/provider/ViewsProvider.d.ts +3 -3
- package/views/dist/provider/ViewsProvider.js +1 -1
- package/views/dist/provider/context.d.ts +1 -1
- package/views/dist/styles.css +3277 -0
- package/views/dist/styles.unlayered.css +3276 -0
- package/views/docs/contract.md +61 -13
- package/views/docs/getting-started.md +1 -1
- package/views/docs/guides/display.md +11 -7
- package/views/docs/guides/looks.md +29 -0
- package/views/docs/guides/the-grid.md +1 -1
- package/views/docs/guides/the-provider.md +1 -1
- package/views/docs/index.md +2 -0
- package/views/docs/install.md +36 -9
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/looks.md +31 -0
- package/views/docs/reference/react.md +2 -2
- package/views/docs/reference/views.md +1 -1
- package/views/skills/views/SKILL.md +2 -2
package/views/docs/contract.md
CHANGED
|
@@ -23,7 +23,8 @@ layout that can't break. Everything a person sees is the app's to dress, through
|
|
|
23
23
|
own only where an app hands nothing, and each such place names the option, component, atom or body that replaces
|
|
24
24
|
it;
|
|
25
25
|
- **a colour, size, gap, line, radius, shadow or timing** through a `--vk-*` variable with a default (Tokens), or
|
|
26
|
-
through the
|
|
26
|
+
through the scale ViewKit's class reads (`text-sm`, `rounded-md`): the Outright look's with the stylesheet, the
|
|
27
|
+
app's own Tailwind scale with `@source`;
|
|
27
28
|
- **a part** through its `data-slot` (Slots), and **a state** through its data attribute (States);
|
|
28
29
|
- **a choice a list makes** through an option with a default, today's look being the default.
|
|
29
30
|
|
|
@@ -65,7 +66,7 @@ use; the prefix keeps that selector from reaching an element of the app's own.
|
|
|
65
66
|
| `data-slot="vk-grid-group-header"` | a group's name and figures |
|
|
66
67
|
| `data-slot="vk-grid-group-count"` | a group's count, in its head |
|
|
67
68
|
| `data-slot="vk-grid-group-figure"` | one of a group's figures, in its head |
|
|
68
|
-
| `data-slot="vk-grid-group-dot"` | the · before a group's
|
|
69
|
+
| `data-slot="vk-grid-group-dot"` | the · before a group's figure |
|
|
69
70
|
| `data-slot="vk-grid-footer"` | the footer row |
|
|
70
71
|
| `data-slot="vk-grid-footer-cell"` | one column's figure |
|
|
71
72
|
| `data-slot="vk-grid-figure-label"` | a footer figure's kind ("Sum"), drawn before its value; none on a figure the app draws |
|
|
@@ -96,8 +97,8 @@ colours the name at rest also writes its own `:hover` rule, or the name keeps th
|
|
|
96
97
|
Only the grid's titles carry the part; a title drawn on another surface names none.
|
|
97
98
|
|
|
98
99
|
Each of a group head's three parts carries `data-part="<part>"`, an identifier like `data-group-key="<key>"` rather than a state: the summary part it shows or stands before (`count`,
|
|
99
|
-
`total`, `total:<columnId>`), so an app hides one dot by it
|
|
100
|
-
|
|
100
|
+
`total`, `total:<columnId>`), so an app hides one dot by it. The count is a chip ViewKit draws itself, at the
|
|
101
|
+
row's text size, with no dot before it; each figure follows its dot.
|
|
101
102
|
|
|
102
103
|
Board's slots (`vk-board`, `vk-board-lane`, `vk-board-lane-header`, `vk-board-card`,
|
|
103
104
|
`vk-board-add-card`) join this table when the board arrives.
|
|
@@ -215,7 +216,11 @@ rows read them.
|
|
|
215
216
|
**Colour is the app's, by the package's names.** The rendering paints every colour through a CSS
|
|
216
217
|
variable the app declares, spelled in a class as `text-(color:--vk-fg)` and in a value as
|
|
217
218
|
`var(--vk-ground)`, and names no variable of the app's own. An app maps each name onto its tokens
|
|
218
|
-
once; `docs/install.md` holds the block for stock shadcn.
|
|
219
|
+
once; `docs/install.md` holds the block for stock shadcn. The stylesheet (`viewkitjs/views/styles.css`)
|
|
220
|
+
declares each with the Outright look's value, light, and dark under `.dark` or `[data-theme="dark"]`, under the app's
|
|
221
|
+
own. It also draws the shadcn colour names `viewkitjs/fields/design/status-slots` and
|
|
222
|
+
`viewkitjs/fields/design/category-colors` write (`bg-muted`, `text-primary`,
|
|
223
|
+
`bg-success-soft`, …) on the kit tokens they stand for, through these names where one stands for it.
|
|
219
224
|
|
|
220
225
|
| colour | what it paints |
|
|
221
226
|
| ---------------------- | ----------------------------------------------------- |
|
|
@@ -245,7 +250,27 @@ declares both wherever a ground declares its own, so a part takes the states of
|
|
|
245
250
|
The default atoms and the display also read `--vk-success`, `--vk-warning`, `--vk-info`,
|
|
246
251
|
`--vk-label-blue`, `--vk-label-green`, `--vk-label-amber`, `--vk-label-red`, `--vk-label-purple`,
|
|
247
252
|
`--vk-label-pink` and `--vk-label-teal` when the app declares them, each with a built-in fallback. The
|
|
248
|
-
|
|
253
|
+
default Tag draws each hue as a pill, and the stylesheet draws fields' soft fills and the words on a filled
|
|
254
|
+
status, through the optional colours below (`<hue>` is each of the seven: blue, green, amber, red, purple,
|
|
255
|
+
pink, teal). Each is optional: the stylesheet declares the Outright look's, and with `@source` the Tag's
|
|
256
|
+
rungs fall back to the hue itself, so an app that declares only `--vk-label-<hue>` keeps its hue, and
|
|
257
|
+
fields' names draw on the app's own theme.
|
|
258
|
+
|
|
259
|
+
| optional colour | what it paints |
|
|
260
|
+
| -------------------------- | ------------------------------------------------------------------------------ |
|
|
261
|
+
| `--vk-success-subtlest` | a success wash: a status's soft fill (`bg-success-soft`) |
|
|
262
|
+
| `--vk-warning-subtlest` | a warning wash (`bg-warning-soft`) |
|
|
263
|
+
| `--vk-info-subtlest` | an information wash (`bg-info-soft`) |
|
|
264
|
+
| `--vk-fg-inverse` | words on a filled success, information or error |
|
|
265
|
+
| `--vk-fg-warning-inverse` | words on a filled warning |
|
|
266
|
+
| `--vk-label-<hue>-soft` | the hue's pale ground: a category chip's fill (`bg-label-<hue>-soft`) |
|
|
267
|
+
| `--vk-label-<hue>-fill` | the Tag's fill; undeclared, the hue 15% into `--vk-ground` |
|
|
268
|
+
| `--vk-label-<hue>-edge` | the Tag's edge, drawn inside; undeclared, the hue 40% into `--vk-ground` |
|
|
269
|
+
| `--vk-label-<hue>-strong` | the Tag's words; undeclared, the hue 60% into `--vk-fg` |
|
|
270
|
+
|
|
271
|
+
By name: `--vk-label-blue-soft`, `--vk-label-green-soft`, `--vk-label-amber-soft`, `--vk-label-red-soft`, `--vk-label-purple-soft`, `--vk-label-pink-soft`, `--vk-label-teal-soft`; `--vk-label-blue-fill`, `--vk-label-green-fill`, `--vk-label-amber-fill`, `--vk-label-red-fill`, `--vk-label-purple-fill`, `--vk-label-pink-fill`, `--vk-label-teal-fill`; `--vk-label-blue-edge`, `--vk-label-green-edge`, `--vk-label-amber-edge`, `--vk-label-red-edge`, `--vk-label-purple-edge`, `--vk-label-pink-edge`, `--vk-label-teal-edge`; `--vk-label-blue-strong`, `--vk-label-green-strong`, `--vk-label-amber-strong`, `--vk-label-red-strong`, `--vk-label-purple-strong`, `--vk-label-pink-strong`, `--vk-label-teal-strong`.
|
|
272
|
+
|
|
273
|
+
The selection bar reads `--vk-float-shadow`, a whole `box-shadow` value for what floats over a list, with a
|
|
249
274
|
built-in fallback. The grid's chrome (its header and footer cells, a group's name and its own buttons) draws keyboard focus as
|
|
250
275
|
`--vk-focus-ring`, a whole `box-shadow` value;
|
|
251
276
|
undeclared, `inset 0 0 0 2px var(--vk-brand)`. The views row (`/panels/react`) reads `--vk-selected`, the ground's selected state (the
|
|
@@ -253,12 +278,12 @@ active view's pill and the picker's chip), falling back to `--vk-neutral`; an ap
|
|
|
253
278
|
their states declares it beside `--vk-hovered` and `--vk-pressed`. The header's column glyphs ViewKit
|
|
254
279
|
draws (a field's or a type's, a binding's `AppIcon`) read `--vk-head-glyph-fg`, falling back to the
|
|
255
280
|
header's words' colour; they are drawn at 70% opacity either way, so a set colour shows at 70% of itself,
|
|
256
|
-
and an app that wants an exact colour sets it stronger. A column's own `icon` node is drawn as given. The corners come from the
|
|
257
|
-
Tailwind radius scale
|
|
281
|
+
and an app that wants an exact colour sets it stronger. A column's own `icon` node is drawn as given. The corners come from the
|
|
282
|
+
Outright look's radius scale with the stylesheet, or from the app's Tailwind radius scale with `@source`.
|
|
258
283
|
|
|
259
284
|
**The cell outlines are the app's to dress by five variables.** The line of the cell under the pointer and the
|
|
260
|
-
picked cell's ring share one geometry: `--vk-outline-radius` is the corners of both (undeclared, the
|
|
261
|
-
|
|
285
|
+
picked cell's ring share one geometry: `--vk-outline-radius` is the corners of both (undeclared, the small
|
|
286
|
+
radius, exactly what `rounded-sm` drew: the Outright look's with the stylesheet, the app's Tailwind one with `@source`), so an app that draws a picked cell straight declares `0` and the
|
|
262
287
|
hovered cell follows. Each line takes its own colour: `--vk-outline-hover` the hovered cell's (undeclared,
|
|
263
288
|
`--vk-border-bold`), `--vk-outline` the picked ring at rest (undeclared, `--vk-fg-subtle`) and
|
|
264
289
|
`--vk-outline-active` the picked ring under the pointer or while editing (undeclared, `--vk-border-brand`).
|
|
@@ -334,9 +359,25 @@ reads, and through which `GridTable`'s `fillWidth` has the columns share the gri
|
|
|
334
359
|
`--vk-foot-at` (how far above the rows' box's edge the footer pins: the app's inset, and the selection bar
|
|
335
360
|
while rows are selected), and
|
|
336
361
|
while the lab's lock is on `--vk-hold-x` and `--vk-sx` (the offsets that hold the frozen columns, the rail, a group's name and the empty message at the left while the table is scrolled
|
|
337
|
-
sideways) for itself.
|
|
362
|
+
sideways) for itself. The stylesheet declares `--vk-t-<name>`, its own theme values that differ in the
|
|
363
|
+
dark (a shadow). They carry the prefix because they share the global namespace;
|
|
338
364
|
an app neither sets nor reads them, and they may change in any release.
|
|
339
365
|
|
|
366
|
+
## Looks
|
|
367
|
+
|
|
368
|
+
A piece's looks are declared beside the piece and listed in `LOOKS` (`viewkitjs/views/looks`). An option is a closed set
|
|
369
|
+
of values with a default; a look is a named set of picks, one value for every option, its first the piece's own. An app
|
|
370
|
+
wears a set of picks as data attributes on a frame round the piece, `data-<piece>-<option>="<value>"` (`lookAttrs`), which
|
|
371
|
+
the piece's look stylesheet reads, and the piece's code reads the same picks back (`lookWorn`, `lookWornOf`); a pick its
|
|
372
|
+
option doesn't have wears the default. **Public:** a piece's id, its options' ids, their values' ids and its looks' ids,
|
|
373
|
+
renamed only with a codemod, since apps save picks by them. Not public: the words (`name`), which a later version may
|
|
374
|
+
reword. Only options live in the shape: what a piece takes from an app's own design beyond its options stays outside it.
|
|
375
|
+
|
|
376
|
+
Today one piece declares looks, the grid (`GRID_LOOKS`): 25 options and two looks, `attio` and `portal`. Fourteen of its
|
|
377
|
+
options are read by the grid's code (`GRID_LOOK_READ`): eleven become the props it is handed (`gridLookProps`), and three
|
|
378
|
+
the app wires itself, `more` (pages under `GridTable`'s `pages`), `figures` (the footer's words, through the provider's
|
|
379
|
+
messages) and `wait` (`RowsWait` in the components map). The other eleven are its look stylesheet's, which ships later.
|
|
380
|
+
|
|
340
381
|
## The components map
|
|
341
382
|
|
|
342
383
|
The primitives an app hands in through `ViewsProvider`, typed in `src/provider/components.ts`.
|
|
@@ -935,7 +976,7 @@ A field whose changes are transitions with rules of their own (a lost deal needs
|
|
|
935
976
|
|
|
936
977
|
## The doors
|
|
937
978
|
|
|
938
|
-
Twenty-
|
|
979
|
+
Twenty-four doors in this version, and nothing else is importable but `./package.json`; the panels' two (`/panels` and `/panels/react`) are described last. What each holds is summarised here; each door's reference page names every export, one line each, starting at [`reference/views.md`](reference/views.md).
|
|
939
980
|
|
|
940
981
|
`viewkitjs/views`, no React at runtime, holds two things. The rendering contract, every name listed:
|
|
941
982
|
the constants `VK_PREFIX`, `GRID_SLOTS`, `GRID_STATES`, `VK_TOKENS`, `VK_COLOURS`,
|
|
@@ -1008,7 +1049,7 @@ And `selectionBar`'s `chip` (`ViewsSelectionChip`, default `own`): who draws the
|
|
|
1008
1049
|
on the desktop. `own` draws ViewKit's own, as on 0.5.0; `button` draws your `Button`, `variant` `outline`, `size` `sm`,
|
|
1009
1050
|
its box in `className`, `data-slot="vk-selection-chip"`, `aria-label`, and `disabled` while a batch runs, inside the
|
|
1010
1051
|
same `Tooltip`.
|
|
1011
|
-
And an optional `severalValues` (`ViewsSeveralValues`, from `./react`, default `
|
|
1052
|
+
And an optional `severalValues` (`ViewsSeveralValues`, from `./react`, default `fit`): how a cell of several values
|
|
1012
1053
|
draws on one line, wherever it draws (a grid cell, a board or calendar card, a field row that doesn't wrap). `first`
|
|
1013
1054
|
draws its first value and a count at any width, as on 0.5.0. `fit` draws as many whole values as fit its width, then
|
|
1014
1055
|
the count, and follows a column resize; the first shows cut when even it doesn't fit, and a wrapped row shows three
|
|
@@ -1123,6 +1164,13 @@ host's binding shares with the grid: `GridCommitContext` and `GridCommitOutcome`
|
|
|
1123
1164
|
CSV export reuses), and `GRID_TITLE_LINK_CLASS`. The house menu rows, the group collapse and the type
|
|
1124
1165
|
icons are the app's; the selection bar is `SelectionBar`, on the selection door, drawn with the app's verbs.
|
|
1125
1166
|
|
|
1167
|
+
`viewkitjs/views/looks`, no React at runtime: a piece's options and looks (see Looks above). The shape,
|
|
1168
|
+
`PieceLooks` with its `LookOption`s, `LookValue`s and `Look`s, `LookPicks` and `LookDevice`; its helpers, `lookAttrs` (the
|
|
1169
|
+
frame's `data-<piece>-<option>` attributes for a set of picks), `lookPicks` (a look's picks by its id), `lookWorn` and
|
|
1170
|
+
`lookWornOf` (the picks read back, from picks or from the closest frame); `LOOKS`, every piece that declares looks; and the
|
|
1171
|
+
grid's, `GRID_LOOKS` with `GridLookOptionId`, `GRID_LOOK_READ`, `GridLookWorn`, `gridLookWorn`, `gridLookWornOf`, and
|
|
1172
|
+
`gridLookProps` with `GridLookProps` (the `GridTable` props a look sets).
|
|
1173
|
+
|
|
1126
1174
|
`viewkitjs/views/panels`, no client
|
|
1127
1175
|
directive on the door, the one hook behind it (`useFilterOpened`) carrying
|
|
1128
1176
|
its own: what a list's panels read and say. The settings they edit (`SortConfig`, `GroupConfig`, `ToggleConfig`,
|
|
@@ -10,7 +10,7 @@ pnpm add viewkitjs zod
|
|
|
10
10
|
|
|
11
11
|
`react` and `react-dom` 19 are optional peers that the views part needs and you already have, and `zod` `^4.1.12` is a peer of the package. The dnd-kit packages are optional peers too, for the panels' parts that drag (the views row's pills, the sort's rules, the Columns list, the group order), which the door loads with `import()` as it loads: install them if your app renders one. The drawn panels' door (`viewkitjs/views/panels/react`) itself loads without them. The package is ESM only and runs on Node 20 or later.
|
|
12
12
|
|
|
13
|
-
The rendering
|
|
13
|
+
The rendering's look is one stylesheet: `@import "viewkitjs/views/styles.css";` draws it with no Tailwind, the Outright look by default, and one block mapping the `--vk-*` colours onto your theme makes it your app's. [Install](install.md) has both, and the `@source` line that lets your own Tailwind compile it instead.
|
|
14
14
|
|
|
15
15
|
The blocks below check their own results with `node:assert`. To run this page as a script, save the blocks in order as one `.tsx` file in an ES module project and run it with `tsx` (`pnpm add -D tsx @types/node`); in your app the asserts are only there to show you what each call returns.
|
|
16
16
|
|
|
@@ -30,10 +30,7 @@ assert.equal(renderFieldValue(DEAL_FIELDS.tags, []), null);
|
|
|
30
30
|
// An unset boolean still draws: its empty box is the control.
|
|
31
31
|
assert.notEqual(renderFieldValue(DEAL_FIELDS.archived, null), null);
|
|
32
32
|
|
|
33
|
-
//
|
|
34
|
-
assert.equal(renderFieldValue(DEAL_FIELDS.contact, { full: null, given: "Ada", family: "Lovelace" }), "Ada Lovelace");
|
|
35
|
-
// An empty name draws the words you hand it, or nothing.
|
|
36
|
-
assert.equal(renderFieldValue(DEAL_FIELDS.contact, null, { nameFallback: "ada@example.com" }), "ada@example.com");
|
|
33
|
+
// An empty name draws nothing, unless you hand it words to draw (below).
|
|
37
34
|
assert.equal(renderFieldValue(DEAL_FIELDS.contact, { full: null, given: null, family: null }), null);
|
|
38
35
|
```
|
|
39
36
|
|
|
@@ -49,6 +46,13 @@ assert.ok(titleHtml.includes('title="Acme renewal"')); // a clipped value keeps
|
|
|
49
46
|
const websiteHtml = renderToStaticMarkup(<>{renderFieldValue(DEAL_FIELDS.website, "https://acme.example")}</>);
|
|
50
47
|
assert.ok(websiteHtml.includes('href="https://acme.example"'));
|
|
51
48
|
assert.ok(websiteHtml.includes(">acme.example</a>"));
|
|
49
|
+
|
|
50
|
+
// A name reads as written: the full name, else the given and family names, in a box that ends in "…" when it
|
|
51
|
+
// doesn't fit. An empty name draws the words you hand it.
|
|
52
|
+
const nameHtml = renderToStaticMarkup(<>{renderFieldValue(DEAL_FIELDS.contact, { full: null, given: "Ada", family: "Lovelace" })}</>);
|
|
53
|
+
assert.ok(nameHtml.includes(">Ada Lovelace</span>"));
|
|
54
|
+
const fallbackHtml = renderToStaticMarkup(<>{renderFieldValue(DEAL_FIELDS.contact, null, { nameFallback: "ada@example.com" })}</>);
|
|
55
|
+
assert.ok(fallbackHtml.includes(">ada@example.com</span>"));
|
|
52
56
|
```
|
|
53
57
|
|
|
54
58
|
## One renderer per storage type
|
|
@@ -73,7 +77,7 @@ assert.equal(DISPLAY_CORES.date, DISPLAY_CORES.datetime);
|
|
|
73
77
|
- **boolean**: four looks, the field's `format.style`. `checkbox` (the default) draws the `TickBox` atom, and `icon` your `booleanIcon(on)`; either becomes a real switch only when you hand `onToggle`, and is a plain glyph otherwise. `text` draws the option's label for the value, or the package's words. `marker` draws only when true, as the `StatusMarker` atom with your `marker` words, `markerReason` and `onResolve`.
|
|
74
78
|
- **select**, **status** and **multiselect**: a select is a category and draws the `Tag` atom in its colour (a reader's `optionColors` first, then the option's declared colour, then one derived from the value). A status is a state and draws the `StatusBadge` atom in its option's slot. A multiselect draws a tag per value, through the several-values layout. A value no option names draws as the raw value, muted, with a hover saying it is not an option, unless you hand a `labelFallback`; an open (`custom-values`) vocabulary's values are their own labels. An option's `icon` is drawn through your `AppIcon`.
|
|
75
79
|
- **relation** and **user**: a chip, the record's avatar when it has one, else your `entityIcon(kind)`, else the relation glyph, then its label, then, on a `many` relation that declares `links`, the link's roles, drawn by the `RelationRoles` atom ([atoms](atoms.md)). Where it goes is yours (`relationWrap`); without one the chip is inert. Several draw through the several-values layout, the lead link first. A user is drawn as a relation to a member, so the two never differ.
|
|
76
|
-
- **url**, **domain**, **email** and **phone**: a url is a link with its scheme off the label, its platform's mark before it (the [`PlatformMark` atom](atoms.md)); a value that is no safe web address draws as text. A domain links to its site and reads no platform from it. An email is a `mailto:` link to the address alone: text stored after it (`?cc=…`, a second address) is never part of the link, and a value that holds no address draws as text. A phone is written in its international form, as its country writes it for a viewer in that country (the conventions' `region`) and internationally for anyone else, its extension after it, and dialled through a `tel:` link; a phone stored as typed draws as its text and is marked `data-as-typed`, still a link to its digits, and as text alone when it holds no digit to dial. Every phone's value is the part `data-slot="vk-phone"`, its link or its text. Several values of one of these draw
|
|
80
|
+
- **url**, **domain**, **email** and **phone**: a url is a link with its scheme off the label, its platform's mark before it (the [`PlatformMark` atom](atoms.md)); a value that is no safe web address draws as text. A domain links to its site and reads no platform from it. An email is a `mailto:` link to the address alone: text stored after it (`?cc=…`, a second address) is never part of the link, and a value that holds no address draws as text. A phone is written in its international form, as its country writes it for a viewer in that country (the conventions' `region`) and internationally for anyone else, its extension after it, and dialled through a `tel:` link; a phone stored as typed draws as its text and is marked `data-as-typed`, still a link to its digits, and as text alone when it holds no digit to dial. Every phone's value is the part `data-slot="vk-phone"`, its link or its text. Several values of one of these draw the main one first, as many as fit, then a count.
|
|
77
81
|
- **location**: in a cell, its city and its country; with `wrap: "full"`, the whole place. The country is named in the viewer's language.
|
|
78
82
|
- **name**: the full name as written, else the given and family names, else `nameFallback`, else nothing.
|
|
79
83
|
- **actor**: a chip like a relation's that opens nothing, since an actor records who did something rather than pointing at a record: a member's avatar when your value carries an `avatarUrl` beside it, and your glyph for an automation, an API key or the system.
|
|
@@ -81,8 +85,8 @@ assert.equal(DISPLAY_CORES.date, DISPLAY_CORES.datetime);
|
|
|
81
85
|
- **range**: its two ends as text ("11–50", "10,001+", "up to 50"), then its unit (`%`, its currency code or its suffix) and its period ("/mo").
|
|
82
86
|
- **lookup** and **formula**: as the field their result is. A **rollup** grouped by an option draws a segmented bar beside its headline, and one grouped by time a sparkline, the current bucket faded.
|
|
83
87
|
|
|
84
|
-
A value that holds several, of any of these types, uses `MultiValueCell`: one
|
|
85
|
-
With the provider's `severalValues: "
|
|
88
|
+
A value that holds several, of any of these types, uses `MultiValueCell`: as many as fit on one line, or three when wrapped, then a `+N` count that opens all of them in a list. It is exported for your own cells; [the display reference](../reference/display.md) has its props.
|
|
89
|
+
With the provider's `severalValues: "first"`, a value on one line shows its first value and the count at any width instead ([the provider](the-provider.md)). The count is the `CellMore` atom ([atoms](atoms.md)).
|
|
86
90
|
|
|
87
91
|
## What the field can't know
|
|
88
92
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Looks
|
|
2
|
+
|
|
3
|
+
A piece's look is what an app sets once for every copy of the piece it draws: the grid's column lines, its density, how a grouped grid draws its titles. ViewKit declares each piece's options and looks beside the piece, in `viewkitjs/views/looks`, and an app picks one by its name, or picks option by option, and saves the picks it made. Reference: [`viewkitjs/views/looks`](../reference/looks.md).
|
|
4
|
+
|
|
5
|
+
## Options and looks
|
|
6
|
+
|
|
7
|
+
An option is a closed set of values with a default: the grid's `columns` is `all`, `none` or `pinned`. A look is a named set of picks, one value for every option: the grid's `attio` look, its first, is every option's default; its `portal` look is ViewKit's own grid as the portal draws it. The ids are public and stay as they are, since an app saves picks by them; the words beside them (`name`) may change.
|
|
8
|
+
|
|
9
|
+
## Picking the grid's look
|
|
10
|
+
|
|
11
|
+
The picks go on the element round the grid as data attributes, which the grid's look stylesheet reads, and the options the grid's code reads go to `GridTable` as props:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { GRID_LOOKS, gridLookProps, gridLookWorn, lookAttrs, lookPicks } from "viewkitjs/views/looks";
|
|
15
|
+
|
|
16
|
+
// The portal's look, with the columns sharing the grid's whole width.
|
|
17
|
+
const picks = { ...lookPicks(GRID_LOOKS, "portal"), width: "fill" };
|
|
18
|
+
const frame = lookAttrs(GRID_LOOKS, picks); // spread on the element round the grid
|
|
19
|
+
const props = gridLookProps(gridLookWorn(picks), false); // spread on GridTable, false on a computer
|
|
20
|
+
console.log(frame["data-grid-columns"], props.verticalBorders, props.fillWidth); // all true true
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A pick its option doesn't have (one saved by an older version, say) wears the option's default, so saved picks never break a grid. Where the picks live on the page rather than in your state, `gridLookWornOf(element)` reads them back from the closest frame.
|
|
24
|
+
|
|
25
|
+
Fourteen of the grid's options are read by its code. Eleven become its props through `gridLookProps`; three you wire yourself, as the Showcase does: `more` (`"pages"`: hand `GridTable` its `pages`), `figures` (`"value"`: the footer's figure words through your provider's messages) and `wait` (`"kept"`: hand the components map a `RowsWait`). The other eleven (the header's words, the rows' lines, the pinned edge, picked rows and cells, the cells' frames, names and phones) are its look stylesheet's alone, and draw nothing until that stylesheet ships.
|
|
26
|
+
|
|
27
|
+
## A piece of your own
|
|
28
|
+
|
|
29
|
+
A piece that comes into ViewKit declares its options and looks in its own folder, in the same shape (`PieceLooks`), and adds itself to `LOOKS`. Only options live in the shape: what a piece takes from an app's own design beyond its options (its own colours, its own sizes) stays outside it.
|
|
@@ -119,7 +119,7 @@ const DEAL_FIELD_MAP: Readonly<Record<string, FieldDef>> = DEAL_FIELDS;
|
|
|
119
119
|
|
|
120
120
|
/** How the evaluator reads a deal: the field from the registry, the value from the row's own key. */
|
|
121
121
|
const dealReader: ViewFieldReader<Deal> = {
|
|
122
|
-
fieldOf: (key) => DEAL_FIELD_MAP[key],
|
|
122
|
+
fieldOf: (key) => (Object.hasOwn(DEAL_FIELD_MAP, key) ? DEAL_FIELD_MAP[key] : undefined),
|
|
123
123
|
read: (deal, key) => (deal as Record<string, unknown>)[key],
|
|
124
124
|
};
|
|
125
125
|
|
|
@@ -26,7 +26,7 @@ Every view reads what it takes from its app, other than its own props, from one
|
|
|
26
26
|
|
|
27
27
|
`gridButtons` says who draws the buttons the grid draws itself: a group's fold and ⋯, "+ Add column", a row's ⋯, the name's actions (the pencil and your `rowActions`), an action column's buttons, a pick-list cell's ▾, and a command cell's ▾ and its trigger. `own`, the default, draws ViewKit's own, as on 0.5.0. `button` draws your `Button`, so they take your pointer, hover, press and focus ring: the grid hands its box (size, place, the reveal on hover) in `className`, `variant` `ghost` or `outline`, `size` `icon` or `sm`. Before you set it, make your `Button` forward `ref`, `tabIndex`, `aria-haspopup`, `aria-expanded`, `data-slot` and `data-open` to its element and let the `className` it is handed win over its own size: a `Button` that drops the ref leaves the ⋯'s and "+ Add column"'s menus with nothing to anchor on, and one that drops `tabIndex` makes every grid button a Tab stop. The example adapters on this page forward none of them; they suit the default.
|
|
28
28
|
|
|
29
|
-
`severalValues` says how a cell of several values (a multiselect's options, several emails or records, a lookup's names) draws on one line. `
|
|
29
|
+
`severalValues` says how a cell of several values (a multiselect's options, several emails or records, a lookup's names) draws on one line. `fit`, the default, draws as many whole values as fit the cell's width, then the count, and follows a column resize; when even the first doesn't fit whole, it shows cut. `first` draws its first value and a "+N" count at any width, as on 0.5.0. A wrapped row shows three either way. Each cell measures its values once when it mounts or they change, and a resize is arithmetic over what it kept, so fitting costs no row a redraw.
|
|
30
30
|
|
|
31
31
|
`gridCheckboxes` says who draws a yes/no cell's box in the grid. `own`, the default, draws ViewKit's tick box in its own switch button, as on 0.5.0. `checkbox` draws your `Checkbox`, the box your rail draws, so a row's two boxes are one: it is handed `checked`, the column's name, `tabIndex` -1 and `onCheckedChange`, and a press writes the value once. A cell the grid can't write is handed `readOnly` and a press that writes nothing. Before you set it, make your `Checkbox` forward `readOnly`: one that drops it shows a read-only cell that looks pressable and does nothing when pressed.
|
|
32
32
|
|
package/views/docs/index.md
CHANGED
|
@@ -28,6 +28,7 @@ Drawing and editing values:
|
|
|
28
28
|
The grid:
|
|
29
29
|
|
|
30
30
|
- [The grid](guides/the-grid.md): grouping, sorting, writes, preferences, figures and the editing rules
|
|
31
|
+
- [Looks](guides/looks.md): a piece's options and looks, and picking the grid's by name
|
|
31
32
|
|
|
32
33
|
Reference material:
|
|
33
34
|
|
|
@@ -50,5 +51,6 @@ One page per door. Each lists every name the door exports.
|
|
|
50
51
|
- [`viewkitjs/views/cells`](reference/cells.md): a column's typed cell
|
|
51
52
|
- [`viewkitjs/views/selection`](reference/selection.md): a list's selection
|
|
52
53
|
- [`viewkitjs/views/grid`](reference/grid.md): the grid, its props and the helpers a host shares with it
|
|
54
|
+
- [`viewkitjs/views/looks`](reference/looks.md): a piece's options and looks, and the helpers that wear one ([guide](guides/looks.md))
|
|
53
55
|
- [`viewkitjs/views/panels`](reference/panels.md): what a list's panels read and say, built from its settings, and the toolbar's arrangement, with no React
|
|
54
56
|
- [`viewkitjs/views/panels/react`](reference/panels-react.md): the panels as they draw, the toolbar's frame, its parts and the ready toolbar
|
package/views/docs/install.md
CHANGED
|
@@ -11,21 +11,45 @@
|
|
|
11
11
|
Columns list, the group order), which the door loads with `import()` as it loads: install them if your app renders one. The drawn
|
|
12
12
|
panels' door (`viewkitjs/views/panels/react`) itself loads without them. ESM only, Node 20 or later.
|
|
13
13
|
|
|
14
|
-
2. **
|
|
15
|
-
|
|
14
|
+
2. **Import the stylesheet.** One line gives the rendering its whole look, with no Tailwind needed:
|
|
15
|
+
|
|
16
|
+
```css
|
|
17
|
+
@import "viewkitjs/views/styles.css";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
It goes anywhere among your imports. Its rules sit in `components › viewkit`, a layer inside
|
|
21
|
+
`components`, and the file opens by declaring Tailwind's order (`theme, base, components, utilities`), so
|
|
22
|
+
your own components rules and your utilities win over ViewKit's whatever the order you import things in.
|
|
23
|
+
Its defaults are the Outright look (the look Outright's own apps wear), light, and dark under `.dark` or
|
|
24
|
+
`[data-theme="dark"]`. The reset it carries (Tailwind's preflight) touches only ViewKit's elements and what
|
|
25
|
+
your components draw inside them, and sits in `base › viewkit`, under your own base styles: a rule of yours
|
|
26
|
+
in `base` (shadcn's border colour) still wins there.
|
|
27
|
+
|
|
28
|
+
An app whose reset or styles sit in no layer (Tailwind 3, or a plain CSS reset, whose unlayered preflight
|
|
29
|
+
beats any layer) imports `viewkitjs/views/styles.unlayered.css` instead: ViewKit's classes outside any
|
|
30
|
+
layer, its reset and defaults still in `base › viewkit` and `components › viewkit`, and Tailwind's
|
|
31
|
+
fallbacks for browsers without `@property` in a `properties` layer. It declares no layer order, so it is
|
|
32
|
+
for an app with no layers of its own: a Tailwind 4 app takes `styles.css`.
|
|
33
|
+
|
|
34
|
+
Until each piece moves to CSS of its own, the stylesheet carries ViewKit's classes under Tailwind's names (`h-8`, `rounded-md`). Where your own Tailwind writes a class of the same name, your rule wins on ViewKit's element too: a stock Tailwind app that uses `rounded-md` itself draws ViewKit's corners at 6px, not the Outright look's 7.5px. The pieces move to their own `vk-*` classes one by one, and the overlap goes with them.
|
|
35
|
+
|
|
36
|
+
**Or let your Tailwind compile it.** An app on Tailwind 4 can still draw ViewKit on its own scale: leave
|
|
37
|
+
the import out and add one line to the stylesheet that imports Tailwind instead:
|
|
16
38
|
|
|
17
39
|
```css
|
|
18
40
|
@source "../../node_modules/viewkitjs/views";
|
|
19
41
|
```
|
|
20
42
|
|
|
21
43
|
(Adjust the relative path to where your stylesheet sits.) A missing line shows unstyled values and editors.
|
|
44
|
+
This way the rendering needs no base reset (Tailwind's preflight or any other): every button, input,
|
|
45
|
+
textarea and link it draws itself resets itself, at zero specificity, so it looks the same with or without
|
|
46
|
+
one, and your own classes and base styles elsewhere are untouched.
|
|
22
47
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
once. On stock shadcn tokens:
|
|
48
|
+
3. **Make the colours yours (optional).** The rendering paints through its own names. The stylesheet
|
|
49
|
+
already declares every one with the Outright look's value, light, and dark under `.dark` or `[data-theme="dark"]`;
|
|
50
|
+
declare them yourself to wear your own theme. A declaration in no layer, or in any layer above
|
|
51
|
+
`components`, wins over the stylesheet's. With `@source` instead of the stylesheet, nothing declares
|
|
52
|
+
them for you, and this block is required. On stock shadcn tokens:
|
|
29
53
|
|
|
30
54
|
```css
|
|
31
55
|
:root {
|
|
@@ -54,7 +78,10 @@
|
|
|
54
78
|
|
|
55
79
|
`.dark` needs nothing more: each line reads your own token, which your dark theme already sets.
|
|
56
80
|
If your grounds each tune their hover, declare `--vk-hovered` and `--vk-pressed` beside each
|
|
57
|
-
ground's own. The status and category hues (`--vk-success`, `--vk-label-blue`, …) are optional
|
|
81
|
+
ground's own. The status and category hues (`--vk-success`, `--vk-label-blue`, …) are optional, and so
|
|
82
|
+
are the status washes, the words on a filled status and each hue's soft fill and pill rungs
|
|
83
|
+
(`--vk-success-subtlest`, `--vk-fg-inverse`, `--vk-label-blue-soft`, `--vk-label-blue-strong`, …; the list
|
|
84
|
+
is in `docs/contract.md`, Tokens).
|
|
58
85
|
|
|
59
86
|
If your pages pad their content at the sides, tell the grid how far, so its rows line up with the
|
|
60
87
|
rest of the page: declare `--vk-gutter` beside the colours, onto your own padding. Without it the
|
|
@@ -17,8 +17,8 @@ Guide: [display](../guides/display.md).
|
|
|
17
17
|
- A relation's: `entityIcon` (your glyph for an entity kind) and `relationWrap` (where a chip goes; absent, the chip is inert).
|
|
18
18
|
- The host's slot: `slotOwnsClick`, set by a host whose own element is the button, such as a calendar card. Every core then draws bare content: an overflow count as plain text, a boolean with no toggle. `hostOwnsPlainClick`, set by a host whose plain click on a value is its own, such as the grid: an email, phone, url or domain stays a link, marked `data-cell-link`, not draggable, and lets its click through for the host to decide.
|
|
19
19
|
- `RelationWrap` — the type of `relationWrap`: `(relation, chip) => ReactNode`. The core draws the chip (its picture or glyph, through your `Avatar` atom, and its label); your function wraps it in your own link or button, since where a record opens is your app's.
|
|
20
|
-
- `MultiValueCell` — the layout for a value that holds several: several emails, phones, links or domains, a multiselect, the far side of a relation. It takes `items` (one drawn node per value), and optionally `details` (a word beside each value in the list, never in the cell), `wrap`, `title` (the native hover text) and `slotOwnsClick`.
|
|
21
|
-
With the provider's `severalValues: "
|
|
20
|
+
- `MultiValueCell` — the layout for a value that holds several: several emails, phones, links or domains, a multiselect, the far side of a relation. It takes `items` (one drawn node per value), and optionally `details` (a word beside each value in the list, never in the cell), `wrap`, `title` (the native hover text) and `slotOwnsClick`. On one line it shows as many whole values as fit its width (at most 20 are measured), or three when wrapped, then a `+N` count that opens every value in a read-only list in the components map's `Popover`, drawn with the `List` and `Row` atoms. With `slotOwnsClick` the count is plain text and nothing opens. No items draws nothing.
|
|
21
|
+
It follows its width, and the first shows cut when even it doesn't fit. With the provider's `severalValues: "first"`, on one line it shows its first value and the count instead, at any width. The count is drawn by the `CellMore` atom inside `data-slot="vk-cell-more"`, with `data-open` while the list is open.
|
|
22
22
|
- `ConvertedFigure` — a money figure shown in another currency than its record's own, marked: ≈ before its `children`, and a title naming the currency it came `from` ("Converted from USD", the `views.display.converted-from` message). `renderTypedCellValue` draws it around a converted cell, and a field row around a figure its host reads in another currency; an app draws it on a surface of its own.
|
|
23
23
|
- `ConversionLine` — the line under a money editor opened from a converted figure: the marked `figure`, then "as shown" (`views.display.as-shown`), so the record's own amount being edited and the figure the person clicked read as one value. An optional `className` spaces it.
|
|
24
24
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# `viewkitjs/views/looks`
|
|
2
|
+
|
|
3
|
+
Import from `viewkitjs/views/looks` to pick a piece's look by name: each piece's options and looks, declared beside the piece, and the helpers that wear a set of picks on a frame and read it back. No React at runtime, so a server or a script reads it too. A piece's id, its options' ids, their values' ids and its looks' ids are public ([the contract](../contract.md#looks)); the words are not. Guide: [looks](../guides/looks.md).
|
|
4
|
+
|
|
5
|
+
## The shape
|
|
6
|
+
|
|
7
|
+
- `PieceLooks` — a piece's options and looks: `id` (the piece's, the middle of its attributes' names), `name`, `options` (`LookOption`s, in the order a picker shows them) and `looks` (`Look`s, the first the one worn when nothing is picked).
|
|
8
|
+
- `LookOption` — one option: `id`, `name`, `def` (the value worn when nothing is picked, or when the pick is a value it doesn't have), `values` (`LookValue`s), and optionally `device` (a `LookDevice`), `kind` (`"steps"` for an ordered scale, `"list"` for a long list), `unless` (an option and a value, or several, under which this one means nothing) and `demo: false` (it changes nothing a whole list draws, so a list-wide picker may leave it out).
|
|
9
|
+
- `LookValue` — one value an option can hold: `id` and `name`.
|
|
10
|
+
- `Look` — a named set of picks: `id`, `name`, `picks` (one value for every option) and optionally `device`.
|
|
11
|
+
- `LookPicks` — some options' picks, by option id; what an app saves.
|
|
12
|
+
- `LookDevice` — `"phone"` or `"desktop"`: the device an option or a look is for, when it is for one.
|
|
13
|
+
|
|
14
|
+
## Wearing a look
|
|
15
|
+
|
|
16
|
+
- `lookAttrs` — `lookAttrs(piece, picks?)`: the `data-<piece>-<option>` attribute for every option, the pick where the option has it and the default otherwise, to spread on the element round the piece.
|
|
17
|
+
- `lookPicks` — `lookPicks(piece, id)`: a look's picks by its id, or `undefined` for an id the piece has no look by.
|
|
18
|
+
- `lookWorn` — `lookWorn(piece, picks, ids)`: the named options' values from a set of picks, each its default when missing or unknown.
|
|
19
|
+
- `lookWornOf` — `lookWornOf(piece, element, ids)`: the same, read from the closest frame round `element` carrying each option's attribute; with `null`, or outside any frame, the defaults.
|
|
20
|
+
- `LOOKS` — every piece that declares looks, in a list, each found by its `id`. Today, the grid.
|
|
21
|
+
|
|
22
|
+
## The grid's
|
|
23
|
+
|
|
24
|
+
- `GRID_LOOKS` — the grid's options and looks: 25 options (`header`, `lines`, `columns`, `density`, `phone`, `name`, `edge`, `boxes`, `icon`, `picked`, `cell`, `corners`, `hover`, `frame`, `groups`, `names`, `phones`, `typed`, `figures`, `width`, `more`, `wait`, `foot`, `add`, `picking`) and two looks, `attio` (every option's default) and `portal` (ViewKit's own grid, as the portal draws it).
|
|
25
|
+
- `GridLookOptionId` — the grid's option ids.
|
|
26
|
+
- `GridLookWorn` — what the grid's code reads of its options: `columns`, `density`, `phone`, `name`, `boxes`, `icon`, `groups`, `figures`, `width`, `more`, `wait`, `foot`, `add` and `picking`. The others are its look stylesheet's alone, which ships later.
|
|
27
|
+
- `GRID_LOOK_READ` — those fourteen option ids, in that order. Eleven reach `GridTable` through `gridLookProps`; `more`, `figures` and `wait` the app wires itself (the [guide](../guides/looks.md)).
|
|
28
|
+
- `gridLookWorn` — `gridLookWorn(picks?)`: a `GridLookWorn` from a set of picks.
|
|
29
|
+
- `gridLookWornOf` — `gridLookWornOf(element)`: a `GridLookWorn` read from the frame round `element`.
|
|
30
|
+
- `gridLookProps` — `gridLookProps(worn, phone)`: the `GridTable` props a look sets, on a phone or a computer, as a `GridLookProps`.
|
|
31
|
+
- `GridLookProps` — `verticalBorders`, `headerVerticalBorders`, `scale` (the density's, times 1.25 on a phone under `phone: "attio"`), `freezeIdentity`, `alwaysCheckboxes`, `showRowIcon`, `oneHeader`, `groupMenu`, `fillWidth`, and the phone's three, `pinFooter`, `addColumnAt` and `phonePicking`, which on a computer are always ViewKit's own.
|
|
@@ -82,7 +82,7 @@ The primitives your app hands in, modelled on Base UI's shapes: a controlled `op
|
|
|
82
82
|
- `ViewsSheetAction` — one of them: its `label` (the accessible name) and `onPress`. The glyph is yours.
|
|
83
83
|
- `ViewsBodyStep` — `{ title, onBack }`: a step of an editor body's own on a phone (a list of countries, a label's list), which a `TextBody`, `PartsBody`, `ValuesBody` or `LinksBody` hands the sheet through its `onStepChange`. The sheet's head shows `title` in place of the field's name, and Back and the sheet's Escape call `onBack`; the body hands `null` once it is back.
|
|
84
84
|
- `ViewsMenuRoute` — `"popover" | "menu"`, the provider's `menus`: how the grid opens its own menus (a column's, a footer's figure picker, a group's ⋯, Add column). `popover` (the default) draws ViewKit's rows in your `Popover`; `menu` hands your `Menu` its rows as data. The row menu and a command cell's menu always go through your `Menu`.
|
|
85
|
-
- `ViewsSeveralValues` — `"first" | "fit"`, the provider's `severalValues`: how a cell of several values draws on one line. `
|
|
85
|
+
- `ViewsSeveralValues` — `"first" | "fit"`, the provider's `severalValues`: how a cell of several values draws on one line. `fit` (the default) draws as many whole values as fit its width, then the count, following a column resize; `first` draws its first value and a count at any width, as on 0.5.0.
|
|
86
86
|
- `ViewsGridButtons` — `"own" | "button"`, the provider's `gridButtons`: who draws the buttons the grid draws itself (a group's fold and ⋯, "+ Add column", a row's ⋯, the name's actions, an action column's buttons, a pick-list cell's ▾, a command cell's ▾ and trigger). `own` (the default) draws ViewKit's own, as on 0.5.0; `button` draws your `Button`, handed the grid's box in `className`.
|
|
87
87
|
- `ViewsGridCheckboxes` — `"own" | "checkbox"`, the provider's `gridCheckboxes`: who draws a yes/no cell's box in the grid (the checkbox style). `own` (the default) draws ViewKit's tick box in its own switch button, as on 0.5.0; `checkbox` draws your `Checkbox`, handed `checked`, the column's name, `tabIndex` -1 and `onCheckedChange`, or `readOnly` where the grid can't write.
|
|
88
88
|
- `ViewsFieldRowButtons` — `"own" | "button"`, the provider's `fieldRowButtons`: who draws a field row's own buttons (its edit target, the verb trigger around a value, the lane's ▾, rich text's Show more). `own` (the default) draws ViewKit's, as on 0.5.0; `button` draws your `Button`.
|
|
@@ -146,7 +146,7 @@ The pieces the rendering is built from, and your app's own pieces it cannot draw
|
|
|
146
146
|
- `ViewsRowProps` — a whole row: everything `ViewsRowContentProps` takes, as a button, or with `interactive` false a static line. It adds `onClick`, `onMouseDown` (for a row inside an editor that keeps its input focused), `disabled`, `title`, a `role` with `aria-selected`, and `opens` and `open` for a row that opens a flyout beside its menu.
|
|
147
147
|
- `ViewsTickBoxProps` — a paint-only tick box: `checked` and a class. The control around it is the caller's.
|
|
148
148
|
- `ViewsAvatarProps` — a person's or a record's picture, drawn in a user's, a relation's and an actor's chip (`size: "chip"`) and before the name when the list's `rowIcon` hands the row's `avatar` (`size: "glyph"`, sized by `--vk-glyph`): `label` (whose picture it is, for initials), `avatarUrl` (the picture, when there is one), `kind` (the record's kind as your app names it: a relation's `entity`, `user` for a member, an actor's type) and `fallback` (the glyph the chip or the name draws without a picture). The default draws the picture while it loads and the fallback otherwise; yours may hand back the fallback for a kind it doesn't dress. It only paints: what wraps the chip owns the click.
|
|
149
|
-
- `ViewsStatusBadgeProps` — a pill coloured by a status slot of `viewkitjs/fields`: its `slot` and `label`, a `leading` mark that replaces the slot's own, a `title`, a `size` (`compact`, 11px, the default
|
|
149
|
+
- `ViewsStatusBadgeProps` — a pill coloured by a status slot of `viewkitjs/fields`: its `slot` and `label`, a `leading` mark that replaces the slot's own, a `title`, a `size` (`compact`, 11px, the default; `regular`; or `row`, the text size of the row it sits in, which a cell's status value hands) and a class. It is handed `place` wherever a field's option is drawn (a cell, the select editor, the selection bar): where the status stands among the field's steps.
|
|
150
150
|
- `ViewsStatusPlace` — a status's `place`: `options`, the field's active options in their order (the same array for every cell of a field), and `index`, this one's place in them. A stray or archived value, and a badge that is no option, are handed none.
|
|
151
151
|
- `ViewsStatusOption` — one of those options as a badge is handed it: `value`, `label` and its `slot`.
|
|
152
152
|
- `ViewsStatusMarkerProps` — an attention badge that opens its reason in a popover: its `label`, its `title` (the panel's heading and the marker's accessible name), a `slot` (`warning` by default), the `reason`, the `emptyReason` shown when there is none (the package's wording by default), and `onResolve` with its `resolveLabel`; without `onResolve` the marker is read-only.
|
|
@@ -17,7 +17,7 @@ Guide: [the provider](../guides/the-provider.md).
|
|
|
17
17
|
- `VkToken` — one member of `VK_TOKENS`.
|
|
18
18
|
- `VK_COLOURS` — the colours the rendering paints, each a CSS variable your app declares (`--vk-fg`, `--vk-ground`, `--vk-brand`, `--vk-border` and the rest). The package sets none of them and names no variable of your own; you map each onto your tokens once ([Tokens](../contract.md#tokens)).
|
|
19
19
|
- `VkColour` — one member of `VK_COLOURS`.
|
|
20
|
-
- `VK_OPTIONAL_COLOURS` — the status hues (`--vk-success`, `--vk-warning`, `--vk-info`) and the category hues (`--vk-label-blue` to `--vk-label-teal`) the default atoms and the display read when your app declares them, each with a built-in fallback, beside the shadows, the selected ground and the cell outlines' colours listed under [Tokens](../contract.md#tokens).
|
|
20
|
+
- `VK_OPTIONAL_COLOURS` — the status hues (`--vk-success`, `--vk-warning`, `--vk-info`) and the category hues (`--vk-label-blue` to `--vk-label-teal`) the default atoms and the display read when your app declares them, each with a built-in fallback; the status washes (`--vk-success-subtlest`, `--vk-warning-subtlest`, `--vk-info-subtlest`), the words on a filled status (`--vk-fg-inverse`, `--vk-fg-warning-inverse`), and each hue's soft fill and the default Tag's pill rungs (`--vk-label-blue-soft`, `--vk-label-blue-fill`, `--vk-label-blue-edge`, `--vk-label-blue-strong` and the same for each hue); beside the shadows, the selected ground and the cell outlines' colours listed under [Tokens](../contract.md#tokens).
|
|
21
21
|
- `VkOptionalColour` — one member of `VK_OPTIONAL_COLOURS`.
|
|
22
22
|
- `VK_OPTIONAL_LAYOUT` — the layout your app may declare, each read with a fallback: `--vk-gutter` (`0px`), the side padding your page gives its content, which the grid's rows line their content up with; `--vk-scroll-inset-bottom` (`0px`), how much of the grid's foot your app covers with something it floats there (a phone's bottom bar), so the grid's scroll area runs underneath it and its last row scrolls clear of it; and `--vk-panel-padding` (`0.375rem`), the inset a panel's list keeps from the panel's edge; and the rail, outline, gap, type, line and timing variables listed under [Tokens](../contract.md#tokens).
|
|
23
23
|
- `VkOptionalLayout` — one member of `VK_OPTIONAL_LAYOUT`.
|
|
@@ -5,11 +5,11 @@ description: Mount and adapt viewkitjs/views — the provider, the components ma
|
|
|
5
5
|
|
|
6
6
|
# ViewKit views
|
|
7
7
|
|
|
8
|
-
Use the package through its twenty-
|
|
8
|
+
Use the package through its twenty-four declared doors only, never a deep path: `viewkitjs/views` (the
|
|
9
9
|
contract and the model), `viewkitjs/views/react` (the provider, the atoms, the adapter's types),
|
|
10
10
|
`/display`, `/editors`, `/editors/select`, `/editors/text`, `/editors/relation`, `/editors/number`, `/editors/range`,
|
|
11
11
|
`/editors/name`, `/editors/location`, `/editors/value-list`, `/editors/date`, `/editors/chips`,
|
|
12
|
-
`/editors/session`, `/editors/panel`, `/editors/open-values`, `/field-row`, `/cells`, `/selection`, `/grid`,
|
|
12
|
+
`/editors/session`, `/editors/panel`, `/editors/open-values`, `/field-row`, `/cells`, `/selection`, `/grid`, `/looks`,
|
|
13
13
|
`/panels` (what a list's panels read and say, no React) and `/panels/react` (the panels and the toolbar as they draw). The package's docs
|
|
14
14
|
start at `views/docs/index.md`: `views/docs/getting-started.md` goes from install to a grid on screen, a guide per
|
|
15
15
|
concept sits in `views/docs/guides/`, and `views/docs/reference/` names every export of each door.
|