viewkitjs 0.20.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/MIGRATION.md +2 -1
  3. package/fields/docs/reference/design-category-colors.md +1 -1
  4. package/fields/docs/reference/design-status-slots.md +1 -1
  5. package/package.json +5 -1
  6. package/views/README.md +2 -1
  7. package/views/dist/atoms/StatusBadge.js +1 -1
  8. package/views/dist/atoms/tones.js +7 -7
  9. package/views/dist/atoms/types.d.ts +3 -2
  10. package/views/dist/contract.d.ts +7 -2
  11. package/views/dist/contract.js +33 -0
  12. package/views/dist/display/fit-values.d.ts +3 -2
  13. package/views/dist/display/link.d.ts +1 -1
  14. package/views/dist/display/location.js +2 -1
  15. package/views/dist/display/multi-value.js +1 -1
  16. package/views/dist/display/name.js +3 -1
  17. package/views/dist/display/select.js +1 -1
  18. package/views/dist/display/value-list.d.ts +1 -1
  19. package/views/dist/grid/chrome/GridStructure.js +2 -1
  20. package/views/dist/grid/looks.d.ts +45 -0
  21. package/views/dist/grid/looks.js +74 -0
  22. package/views/dist/looks/index.d.ts +7 -0
  23. package/views/dist/looks/index.js +3 -0
  24. package/views/dist/looks/looks.d.ts +46 -0
  25. package/views/dist/looks/looks.js +25 -0
  26. package/views/dist/looks/pieces.d.ts +3 -0
  27. package/views/dist/looks/pieces.js +2 -0
  28. package/views/dist/provider/ViewsProvider.d.ts +3 -3
  29. package/views/dist/provider/ViewsProvider.js +1 -1
  30. package/views/dist/provider/context.d.ts +1 -1
  31. package/views/dist/styles.css +192 -80
  32. package/views/dist/styles.unlayered.css +192 -80
  33. package/views/docs/contract.md +49 -7
  34. package/views/docs/guides/display.md +11 -7
  35. package/views/docs/guides/looks.md +29 -0
  36. package/views/docs/guides/the-provider.md +1 -1
  37. package/views/docs/index.md +2 -0
  38. package/views/docs/install.md +5 -5
  39. package/views/docs/reference/display.md +2 -2
  40. package/views/docs/reference/looks.md +31 -0
  41. package/views/docs/reference/react.md +2 -2
  42. package/views/docs/reference/views.md +1 -1
  43. package/views/skills/views/SKILL.md +2 -2
@@ -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. `first`, the default, draws its first value and a "+N" count at any width, as on 0.5.0. `fit` 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. 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.
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
 
@@ -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
@@ -49,10 +49,7 @@
49
49
  already declares every one with the Outright look's value, light, and dark under `.dark` or `[data-theme="dark"]`;
50
50
  declare them yourself to wear your own theme. A declaration in no layer, or in any layer above
51
51
  `components`, wins over the stylesheet's. With `@source` instead of the stylesheet, nothing declares
52
- them for you, and this block is required. Under the stylesheet, three fills keep the Outright look for
53
- now, with no name of their own yet: a status's soft fill (success, warning, information), the text on a
54
- filled status, and a category chip's fill (the chip's text follows `--vk-label-<hue>`). On stock shadcn
55
- tokens:
52
+ them for you, and this block is required. On stock shadcn tokens:
56
53
 
57
54
  ```css
58
55
  :root {
@@ -81,7 +78,10 @@
81
78
 
82
79
  `.dark` needs nothing more: each line reads your own token, which your dark theme already sets.
83
80
  If your grounds each tune their hover, declare `--vk-hovered` and `--vk-pressed` beside each
84
- 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).
85
85
 
86
86
  If your pages pad their content at the sides, tell the grid how far, so its rows line up with the
87
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`. It shows one value, 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
- With the provider's `severalValues: "fit"`, on one line it shows as many whole values as fit its width instead (at most 20 are measured), then the count, following its width; the first shows cut when even it doesn't fit. The count is drawn by the `CellMore` atom inside `data-slot="vk-cell-more"`, with `data-open` while the list is open.
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. `first` (the default) 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 the count, following a column resize.
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, as a status value is drawn in a cell; or `regular`) 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.
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-three declared doors only, never a deep path: `viewkitjs/views` (the
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.