viewkitjs 0.20.0 → 0.22.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 +39 -0
- package/MIGRATION.md +2 -1
- package/README.md +1 -1
- package/fields/dist/conventions.d.ts +15 -3
- package/fields/dist/conventions.js +25 -0
- package/fields/dist/design/category-colors.d.ts +12 -5
- package/fields/dist/design/category-colors.js +7 -7
- package/fields/dist/query/buckets.js +42 -35
- package/fields/dist/query/date.js +2 -13
- package/fields/docs/guides/conventions.md +1 -1
- package/fields/docs/guides/options.md +2 -1
- package/fields/docs/reference/design-category-colors.md +2 -2
- package/fields/docs/reference/design-status-slots.md +1 -1
- package/fields/docs/reference/fields.md +1 -1
- package/package.json +19 -1
- package/views/README.md +2 -1
- 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 +295 -2
- package/views/dist/contract.js +129 -0
- package/views/dist/controls/button/button.d.ts +40 -0
- package/views/dist/controls/button/button.js +40 -0
- package/views/dist/controls/button/looks.d.ts +4 -0
- package/views/dist/controls/button/looks.js +20 -0
- package/views/dist/controls/button/map-button.d.ts +11 -0
- package/views/dist/controls/button/map-button.js +20 -0
- package/views/dist/controls/button/own-look.d.ts +59 -0
- package/views/dist/controls/button/own-look.js +33 -0
- package/views/dist/controls/button.css +530 -0
- package/views/dist/controls/controls.d.ts +5 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/index.d.ts +11 -0
- package/views/dist/controls/index.js +6 -0
- package/views/dist/controls/smooth.css +101 -0
- package/views/dist/controls/spinner/looks.d.ts +4 -0
- package/views/dist/controls/spinner/looks.js +32 -0
- package/views/dist/controls/spinner/spinner.d.ts +23 -0
- package/views/dist/controls/spinner/spinner.js +16 -0
- package/views/dist/controls/spinner.css +147 -0
- package/views/dist/display/date.js +15 -2
- 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 +9 -0
- package/views/dist/looks/index.js +5 -0
- package/views/dist/looks/looks.d.ts +47 -0
- package/views/dist/looks/looks.js +25 -0
- package/views/dist/looks/pieces.d.ts +3 -0
- package/views/dist/looks/pieces.js +4 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
- 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 +1000 -119
- package/views/dist/styles.unlayered.css +1017 -119
- package/views/docs/contract.md +172 -7
- package/views/docs/guides/display.md +11 -7
- package/views/docs/guides/looks.md +29 -0
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +3 -0
- package/views/docs/install.md +7 -5
- package/views/docs/reference/controls.md +36 -0
- package/views/docs/reference/display.md +2 -2
- package/views/docs/reference/looks.md +41 -0
- package/views/docs/reference/react.md +2 -2
- package/views/docs/reference/views.md +5 -2
- package/views/skills/views/SKILL.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,45 @@ Until 0.19.0 ViewKit shipped as three packages; their changes are in [fields/CHA
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [0.22.0] — 2026-11-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `viewkitjs/views/controls`: ViewKit's default controls, on Base UI. `CONTROLS` holds the components map's defaults, today the `Button`: spread it first and your own controls after, `components={{ ...CONTROLS, ...own }}`, and whatever you hand wins. It is the one door that needs `@base-ui/react`, a new optional peer (`^1.6.0`): an app that hands every control never imports it and never installs Base UI. The door also exports the `Button` itself (its kinds, sizes and forms, `loading`, icons and its own look), `ButtonGroup`, `ButtonGroupText`, `ButtonGroupSeparator`, `buttonClass`, `Spinner` and `LoadingBar`.
|
|
13
|
+
- The ready stylesheet (`viewkitjs/views/styles.css`) carries the controls. Every token they read is a new optional `--vk-*` name declared at the Outright look's value, light and dark, which an app declares to change ([the contract's controls' tokens](views/docs/contract.md#the-controls-tokens)). An app on the Outright tokens can instead import `viewkitjs/views/controls/smooth.css`, `button.css` and `spinner.css`, in that order, and declare each of those names as its own Outright token on the controls.
|
|
14
|
+
- `viewkitjs/views/looks`: the Button's options and looks (`BUTTON_LOOKS`: `classic`, `keycap`, `pill`, `soft-lift`) and the Spinner's (`SPINNER_LOOKS`, thirteen looks), listed in `LOOKS`. With nothing picked the Spinner is the tail and the loading bar's ends are soft, the Outright look's picks.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- A piece's looks: nothing picked wears each option's default, the Outright look's pick, which no look need match whole (it was the first look).
|
|
19
|
+
- `CATEGORY_COLOR_CLASSES`, from `viewkitjs/fields/design/category-colors`, draws the default Tag's pill: each hue's fill, its edge drawn inside, and its words a strong step, which read at 4.5:1 or more on their fill in every hue, light and dark (before, the hue's own words on its `-soft` rung, as low as 3.75:1 for red). The classes now read `--vk-label-<hue>-fill`, `--vk-label-<hue>-edge` and `--vk-label-<hue>-strong` in place of your theme's `label-<hue>` and `label-<hue>-soft` colours; undeclared, each comes from your `--vk-label-<hue>` (else ViewKit's own hue), mixed into `--vk-ground` and `--vk-fg`. An app with its own Tailwind that drew these chips from its `--label-*` tokens declares the three rungs, or at least `--vk-label-<hue>`, `--vk-ground` and `--vk-fg`, to keep its hues. Gray is unchanged.
|
|
20
|
+
- Before: `CATEGORY_COLOR_CLASSES.red` was `bg-label-red-soft text-label-red`.
|
|
21
|
+
- Now: the default Tag's red, word for word: a fill that reads `--vk-label-red-fill`, an inset edge that reads `--vk-label-red-edge` and words, typed as a colour, that read `--vk-label-red-strong`, each with the fallback above.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- A views row whose tabs don't fit no longer makes its page scroll sideways. The hidden copy of the row it measures its tabs on, as wide as every tab together, now stands in a box that clips it; the row itself clips nothing, so a tab's focus ring and a tab being dragged are drawn whole. It folds the same tabs into "+N" as before.
|
|
26
|
+
- `viewkitjs/views`: a date or a moment mounts the app's `Tooltip` at the first mouse or pen move over it with no button down, where it mounted at the first pointerenter, and never inside a press. A press whose element was swapped for the tooltip's fired no click, so a list whose title is a date could miss its first click on a row: in Safari, every time the list was drawn under a resting pointer. The long form still shows on a resting pointer.
|
|
27
|
+
- A date filter's summary writes its month's word in the conventions' `language`, the language the interface reads in, while the day's order and digits keep `locale`: `{ locale: "ro", language: "en" }` reads "After 24 Nov 2026", where it read "After 24 nov. 2026". An app that states no `language` sees no change.
|
|
28
|
+
- A date group's heading, by day, week or month, and a relative or due grouping's month groups, write their month's word in the conventions' `language`, while the day's order and digits keep `locale`, as a date filter's summary does: `{ locale: "ro", language: "en" }` heads a month "November 2026" and a day "24 Nov 2026", where they read "noiembrie 2026" and "24 nov. 2026". An app that states no `language` sees no change.
|
|
29
|
+
|
|
30
|
+
## [0.21.0] — 2026-11-25
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- `viewkitjs/views/looks`: a piece's options and looks, declared beside it, and the helpers to wear one. `lookAttrs` gives the `data-<piece>-<option>` attributes for a set of picks, `lookPicks` a look's picks by its id, and `lookWorn` and `lookWornOf` read the picks back, from picks or from the frame round an element; a pick its option doesn't have wears the default. `LOOKS` lists every piece that declares looks; today, the grid. No React at runtime. A piece's, its options', their values' and its looks' ids are public ([the contract](views/docs/contract.md#looks)).
|
|
35
|
+
- The grid's options and its two looks, `attio` and `portal`, as `GRID_LOOKS`, with `gridLookWorn`, `gridLookWornOf` and `gridLookProps`: the `GridTable` props a look sets (its column lines, density and scale on a phone, pinned name, checkboxes, row icon, groups, width, and on a phone its footer, + Add column and picking). The options only the grid's look stylesheet reads (the header's words, the rows' lines, the pinned edge, picked rows and cells, the cells' frames, names and phones) draw nothing yet: that stylesheet ships later.
|
|
36
|
+
- Each hue's pill reads three optional colours, `--vk-label-<hue>-fill`, `--vk-label-<hue>-edge` and `--vk-label-<hue>-strong`. Undeclared, they come from your own `--vk-label-<hue>` (15% and 40% into `--vk-ground`, 60% into `--vk-fg`), so an app on `@source` that declares only its hues keeps them. The stylesheet declares the Outright look's, so under `styles.css` an app that sets its own `--vk-label-<hue>` sets the three rungs too, or the pill wears the Outright look's.
|
|
37
|
+
- Under `viewkitjs/views/styles.css`, the fills that kept the Outright look have names you can declare: `--vk-success-subtlest`, `--vk-warning-subtlest` and `--vk-info-subtlest` (a status's soft fill), `--vk-fg-inverse` and `--vk-fg-warning-inverse` (the words on a filled status), and `--vk-label-<hue>-soft` (a category chip's fill). `docs/contract.md`, Tokens, lists them all. With `@source`, an app's own theme draws these as before.
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Several values in one cell (several emails, phones, links or domains, a multiselect, a many relation, a lookup's names or places) now show as many whole values as fit the cell's width, then "+N", by default. `severalValues: "first"` on `ViewsProvider` keeps the old way: the first value and a count at any width.
|
|
42
|
+
- Every cell type's text that doesn't fit its column ends in "…". A place and a name used to be cut mid-letter.
|
|
43
|
+
- A status drawn as a field's value (a grid cell, a drawer's field row, a card) draws its text at the size of the text around it, its dot as before. `ViewsStatusBadgeProps["size"]` gains `"row"`, which a cell's status value hands; your own `StatusBadge` atom should take its text size from around it for `"row"`.
|
|
44
|
+
- A group's count is a chip ViewKit draws itself, on `--vk-neutral` at the row's text size, with no dot before it; each figure still follows its dot. A rule your app wrote to dress `vk-grid-group-count` as a chip, or to hide the dot before it, can go.
|
|
45
|
+
- The default Tag draws a pill, the Outright look's Option: each hue's fill, its edge drawn inside, and its words a strong step, which read at 4.5:1 or more on their fill in every hue, light and dark (before, the hue's own words on a 12% tint, as low as 1.97:1 for amber). An app that hands its own `Tag` atom sees no change.
|
|
46
|
+
|
|
8
47
|
## [0.20.0] — 2026-11-25
|
|
9
48
|
|
|
10
49
|
### Added
|
package/MIGRATION.md
CHANGED
|
@@ -67,7 +67,8 @@ installs none of them.
|
|
|
67
67
|
| `@viewkitjs/postgres` | `viewkitjs/postgres` |
|
|
68
68
|
| `@viewkitjs/postgres/definitions` | `viewkitjs/postgres/definitions` |
|
|
69
69
|
|
|
70
|
-
There is no `viewkitjs` entry on its own: every path names its part.
|
|
70
|
+
There is no `viewkitjs` entry on its own: every path names its part. A door added since, such as
|
|
71
|
+
`viewkitjs/views/looks` or `viewkitjs/views/controls`, has no old path: an app starts on it under `viewkitjs`. The three `package.json` entries move the
|
|
71
72
|
same way (`@viewkitjs/fields/package.json` is `viewkitjs/package.json`, one manifest for all three parts).
|
|
72
73
|
|
|
73
74
|
## The names your app narrows
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ ViewKit: typed fields, the grid and its editors, and a list's SQL, for record li
|
|
|
8
8
|
pnpm add viewkitjs zod
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
Add `react` and `react-dom` 19 for `viewkitjs/views/*`, and `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` for the panels' parts that drag in `viewkitjs/views/panels/react`. All
|
|
11
|
+
Add `react` and `react-dom` 19 for `viewkitjs/views/*`, and `@dnd-kit/core`, `@dnd-kit/sortable` and `@dnd-kit/utilities` for the panels' parts that drag in `viewkitjs/views/panels/react`, and `@base-ui/react` (1.6 or later) only to take ViewKit's default controls from `viewkitjs/views/controls`. All six are optional peers: an app that uses only fields or postgres installs none of them. ESM only, Node 20 or later.
|
|
12
12
|
|
|
13
13
|
## The parts
|
|
14
14
|
|
|
@@ -5,8 +5,9 @@ export type DecimalSeparator = "." | ",";
|
|
|
5
5
|
export type ConventionsInput = {
|
|
6
6
|
/** BCP 47. Drives text sort order and every date label. Default "en-GB". */
|
|
7
7
|
locale?: string;
|
|
8
|
-
/** BCP 47. The language the interface reads in: the names the library writes (a country's, a region's
|
|
9
|
-
* it, while dates
|
|
8
|
+
/** BCP 47. The language the interface reads in: the names the library writes (a country's, a region's, the month
|
|
9
|
+
* of a date filter's summary and of a date group's heading) are in it, while dates' order and digits, numbers and
|
|
10
|
+
* text order keep `locale`. Default: `locale`. */
|
|
10
11
|
language?: string;
|
|
11
12
|
/** IANA zone. Which calendar day an instant falls on. Default "UTC". */
|
|
12
13
|
timeZone?: string;
|
|
@@ -33,7 +34,8 @@ export type ConventionsOverrides = Omit<ConventionsInput, "decimal" | "region">
|
|
|
33
34
|
};
|
|
34
35
|
export type FieldConventions = {
|
|
35
36
|
readonly locale: string;
|
|
36
|
-
/** The names language: a country's and a region's names
|
|
37
|
+
/** The names language: a country's and a region's names, and the month of a date filter's summary and of a date
|
|
38
|
+
* group's heading, are written in it. `locale` when none was stated. */
|
|
37
39
|
readonly language: string;
|
|
38
40
|
readonly timeZone: string;
|
|
39
41
|
readonly decimal?: DecimalSeparator;
|
|
@@ -59,3 +61,13 @@ export declare const DEFAULT_CONVENTIONS: FieldConventions;
|
|
|
59
61
|
* is passed bare — `["contains"].map(textFilterOperatorLabel)` — and reads the
|
|
60
62
|
* defaults instead of throwing. Internal: not exported from the package. */
|
|
61
63
|
export declare function conventionsOr(cv: unknown): FieldConventions;
|
|
64
|
+
/** `day`: "24 Nov 2026"; `month`: "November 2026". */
|
|
65
|
+
export type DayStyle = "day" | "month";
|
|
66
|
+
/**
|
|
67
|
+
* A calendar day written for a person: its order and digits in `cv.locale`, its month's word in `cv.language`, the
|
|
68
|
+
* language the interface reads in. Romanian dates under an English interface read "24 Nov 2026" and "November 2026";
|
|
69
|
+
* with no language stated (it defaults to the locale), the locale writes it all. A date filter's summary and a date
|
|
70
|
+
* group's heading both write through here. A day is not an instant: it is formatted AS UTC so no zone can move it, and
|
|
71
|
+
* the caller hands it built as UTC midnight (`utcDay`). Not part of the package's surface.
|
|
72
|
+
*/
|
|
73
|
+
export declare function writeDay(at: Date, style: DayStyle, cv: FieldConventions): string;
|
|
@@ -95,3 +95,28 @@ export function conventionsOr(cv) {
|
|
|
95
95
|
? cv
|
|
96
96
|
: DEFAULT_CONVENTIONS;
|
|
97
97
|
}
|
|
98
|
+
const DAY_FORMATS = new Map();
|
|
99
|
+
function formatIn(locale, style) {
|
|
100
|
+
const id = `${locale}|${style}`;
|
|
101
|
+
let format = DAY_FORMATS.get(id);
|
|
102
|
+
if (!format) {
|
|
103
|
+
format = new Intl.DateTimeFormat(locale, {
|
|
104
|
+
...(style === "day" ? { day: "numeric", month: "short" } : { month: "long" }),
|
|
105
|
+
year: "numeric",
|
|
106
|
+
timeZone: "UTC",
|
|
107
|
+
});
|
|
108
|
+
DAY_FORMATS.set(id, format);
|
|
109
|
+
}
|
|
110
|
+
return format;
|
|
111
|
+
}
|
|
112
|
+
export function writeDay(at, style, cv) {
|
|
113
|
+
if (cv.language === cv.locale)
|
|
114
|
+
return formatIn(cv.locale, style).format(at);
|
|
115
|
+
const month = formatIn(cv.language, style)
|
|
116
|
+
.formatToParts(at)
|
|
117
|
+
.find((part) => part.type === "month")?.value;
|
|
118
|
+
return formatIn(cv.locale, style)
|
|
119
|
+
.formatToParts(at)
|
|
120
|
+
.map((part) => (part.type === "month" && month !== undefined ? month : part.value))
|
|
121
|
+
.join("");
|
|
122
|
+
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
export type CategoryColor = "gray" | "blue" | "green" | "amber" | "red" | "purple" | "pink" | "teal";
|
|
2
2
|
/**
|
|
3
|
-
* Classes per colour — the
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Classes per colour — the default Tag's pill: each hue's fill,
|
|
4
|
+
* its edge drawn inside and its words a strong step, 4.5:1 and more on the
|
|
5
|
+
* fill in every hue, light and dark. Each rung is a name an app may declare,
|
|
6
|
+
* `--vk-label-<hue>-fill`, `-edge` and `-strong`; undeclared, it is the app's
|
|
7
|
+
* own `--vk-label-<hue>` (else ViewKit's hue) mixed 15% and 40% into
|
|
8
|
+
* `--vk-ground` and 60% into `--vk-fg`, so an app that declares only its hues
|
|
9
|
+
* keeps them. The same strings as views' `TAG_TONE`, written out here because
|
|
10
|
+
* an app's Tailwind finds a class by its literal text in the files it scans;
|
|
11
|
+
* views' tag-contrast test holds the two equal and the ratios. The words carry
|
|
12
|
+
* the colour type hint, so an app's tailwind-merge doesn't read them as a font
|
|
13
|
+
* size and drop the chip's own size. Gray stays the
|
|
14
|
+
* muted ground with its muted words. No `dark:` variants: every name carries dark.
|
|
8
15
|
*/
|
|
9
16
|
export declare const CATEGORY_COLOR_CLASSES: Record<CategoryColor, string>;
|
|
10
17
|
/** Solid dot color per category color (for the reserved `dot` variant). */
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export const CATEGORY_COLOR_CLASSES = {
|
|
2
2
|
gray: "bg-muted text-muted-foreground",
|
|
3
|
-
blue: "bg-label-blue-
|
|
4
|
-
green: "bg-label-green-
|
|
5
|
-
amber: "bg-label-amber-
|
|
6
|
-
red: "bg-label-red-
|
|
7
|
-
purple: "bg-label-purple-
|
|
8
|
-
pink: "bg-label-pink-
|
|
9
|
-
teal: "bg-label-teal-
|
|
3
|
+
blue: "bg-[var(--vk-label-blue-fill,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-blue-edge,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-blue-strong,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_60%,var(--vk-fg)))]",
|
|
4
|
+
green: "bg-[var(--vk-label-green-fill,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-green-edge,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-green-strong,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_60%,var(--vk-fg)))]",
|
|
5
|
+
amber: "bg-[var(--vk-label-amber-fill,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-amber-edge,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-amber-strong,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_60%,var(--vk-fg)))]",
|
|
6
|
+
red: "bg-[var(--vk-label-red-fill,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-red-edge,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-red-strong,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_60%,var(--vk-fg)))]",
|
|
7
|
+
purple: "bg-[var(--vk-label-purple-fill,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-purple-edge,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-purple-strong,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_60%,var(--vk-fg)))]",
|
|
8
|
+
pink: "bg-[var(--vk-label-pink-fill,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-pink-edge,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-pink-strong,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_60%,var(--vk-fg)))]",
|
|
9
|
+
teal: "bg-[var(--vk-label-teal-fill,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-teal-edge,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-teal-strong,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_60%,var(--vk-fg)))]",
|
|
10
10
|
};
|
|
11
11
|
export const CATEGORY_DOT_CLASSES = {
|
|
12
12
|
gray: "bg-description-foreground",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localDay, utcDay } from "../codecs.js";
|
|
2
|
-
import { DEFAULT_CONVENTIONS } from "../conventions.js";
|
|
2
|
+
import { DEFAULT_CONVENTIONS, writeDay } from "../conventions.js";
|
|
3
3
|
import { isEmptyRange, isRangeValue, presetOf, rangeText } from "../range.js";
|
|
4
4
|
import { actorKey, actorTypeOfKey, isActorValue } from "../actor.js";
|
|
5
5
|
import { orderLinks, relationIdOf, relationKey } from "../relation.js";
|
|
@@ -25,27 +25,19 @@ function isLinkObject(v) {
|
|
|
25
25
|
}
|
|
26
26
|
export const UNCATEGORIZED_KEY = "";
|
|
27
27
|
export const UNGROUPED_KEY = "_all";
|
|
28
|
-
const LABELS = new Map();
|
|
29
|
-
function labelFormat(cv, kind) {
|
|
30
|
-
const id = `${cv.locale}|${kind}`;
|
|
31
|
-
let format = LABELS.get(id);
|
|
32
|
-
if (!format) {
|
|
33
|
-
format = new Intl.DateTimeFormat(cv.locale, {
|
|
34
|
-
...(kind === "day" ? { day: "numeric", month: "short" } : { month: "long" }),
|
|
35
|
-
year: "numeric",
|
|
36
|
-
timeZone: "UTC",
|
|
37
|
-
});
|
|
38
|
-
LABELS.set(id, format);
|
|
39
|
-
}
|
|
40
|
-
return format;
|
|
41
|
-
}
|
|
42
28
|
const RELATIVE_BUCKET = {
|
|
43
|
-
"rel:future": "future",
|
|
44
|
-
"rel:
|
|
29
|
+
"rel:future": "future",
|
|
30
|
+
"rel:today": "today",
|
|
31
|
+
"rel:yesterday": "yesterday",
|
|
32
|
+
"rel:last_7_days": "last_7_days",
|
|
33
|
+
"rel:last_30_days": "last_30_days",
|
|
45
34
|
};
|
|
46
35
|
const DUE_BUCKET = {
|
|
47
|
-
"due:overdue": "overdue",
|
|
48
|
-
"due:
|
|
36
|
+
"due:overdue": "overdue",
|
|
37
|
+
"due:today": "today",
|
|
38
|
+
"due:tomorrow": "tomorrow",
|
|
39
|
+
"due:next_7_days": "next_7_days",
|
|
40
|
+
"due:next_30_days": "next_30_days",
|
|
49
41
|
};
|
|
50
42
|
const FIRST_DAY = "0001-01-01";
|
|
51
43
|
const LAST_DAY = "9999-12-31";
|
|
@@ -98,11 +90,16 @@ function relativeRange(key, today) {
|
|
|
98
90
|
const monthsFrom = monthStart(today, -12);
|
|
99
91
|
const windowsFrom = shiftDay(today, -30);
|
|
100
92
|
switch (key) {
|
|
101
|
-
case "rel:future":
|
|
102
|
-
|
|
103
|
-
case "rel:
|
|
104
|
-
|
|
105
|
-
case "rel:
|
|
93
|
+
case "rel:future":
|
|
94
|
+
return { from: shiftDay(today, 1), to: LAST_DAY };
|
|
95
|
+
case "rel:today":
|
|
96
|
+
return { from: today, to: shiftDay(today, 1) };
|
|
97
|
+
case "rel:yesterday":
|
|
98
|
+
return { from: shiftDay(today, -1), to: today };
|
|
99
|
+
case "rel:last_7_days":
|
|
100
|
+
return { from: shiftDay(today, -7), to: shiftDay(today, -1) };
|
|
101
|
+
case "rel:last_30_days":
|
|
102
|
+
return { from: windowsFrom, to: shiftDay(today, -7) };
|
|
106
103
|
}
|
|
107
104
|
const month = /^rel:m:(\d{4}-\d{2})$/.exec(key)?.[1];
|
|
108
105
|
if (month && fromDayKey(`${month}-01`)) {
|
|
@@ -118,11 +115,16 @@ function dueRange(key, today) {
|
|
|
118
115
|
const monthsFrom = shiftDay(today, 31);
|
|
119
116
|
const yearsFrom = monthStart(today, 13);
|
|
120
117
|
switch (key) {
|
|
121
|
-
case "due:overdue":
|
|
122
|
-
|
|
123
|
-
case "due:
|
|
124
|
-
|
|
125
|
-
case "due:
|
|
118
|
+
case "due:overdue":
|
|
119
|
+
return { from: FIRST_DAY, to: today };
|
|
120
|
+
case "due:today":
|
|
121
|
+
return { from: today, to: shiftDay(today, 1) };
|
|
122
|
+
case "due:tomorrow":
|
|
123
|
+
return { from: shiftDay(today, 1), to: shiftDay(today, 2) };
|
|
124
|
+
case "due:next_7_days":
|
|
125
|
+
return { from: shiftDay(today, 2), to: shiftDay(today, 8) };
|
|
126
|
+
case "due:next_30_days":
|
|
127
|
+
return { from: shiftDay(today, 8), to: monthsFrom };
|
|
126
128
|
}
|
|
127
129
|
const month = /^due:m:(\d{4}-\d{2})$/.exec(key)?.[1];
|
|
128
130
|
if (month && fromDayKey(`${month}-01`)) {
|
|
@@ -163,7 +165,7 @@ function dateLabel(_field, key, granularity = "month", cv = DEFAULT_CONVENTIONS)
|
|
|
163
165
|
if (granularity === "relative" || granularity === "due") {
|
|
164
166
|
const month = /^(?:rel|due):m:(\d{4})-(\d{2})$/.exec(key);
|
|
165
167
|
if (month) {
|
|
166
|
-
return
|
|
168
|
+
return writeDay(utcDay(Number(month[1]), Number(month[2]), 1), "month", cv);
|
|
167
169
|
}
|
|
168
170
|
const year = /^(?:rel|due):y:(\d{4})$/.exec(key)?.[1];
|
|
169
171
|
if (year)
|
|
@@ -181,14 +183,14 @@ function dateLabel(_field, key, granularity = "month", cv = DEFAULT_CONVENTIONS)
|
|
|
181
183
|
case "year":
|
|
182
184
|
return String(y);
|
|
183
185
|
case "month":
|
|
184
|
-
return
|
|
186
|
+
return writeDay(at, "month", cv);
|
|
185
187
|
case "week":
|
|
186
188
|
return cv.messages({
|
|
187
189
|
key: "group.week-of",
|
|
188
|
-
values: { day:
|
|
190
|
+
values: { day: writeDay(at, "day", cv) },
|
|
189
191
|
});
|
|
190
192
|
case "day":
|
|
191
|
-
return
|
|
193
|
+
return writeDay(at, "day", cv);
|
|
192
194
|
}
|
|
193
195
|
}
|
|
194
196
|
export function dateBucketRange(key, granularity, now = new Date(), cv = DEFAULT_CONVENTIONS) {
|
|
@@ -223,7 +225,10 @@ const byOption = {
|
|
|
223
225
|
allKeys: (field) => optionValues(asOptionField(field)),
|
|
224
226
|
};
|
|
225
227
|
export const BUCKET_RULES = {
|
|
226
|
-
select: {
|
|
228
|
+
select: {
|
|
229
|
+
...byOption,
|
|
230
|
+
allKeys: (field) => (isOpenVocabulary(field) ? [] : optionValues(asOptionField(field))),
|
|
231
|
+
},
|
|
227
232
|
status: {
|
|
228
233
|
...byOption,
|
|
229
234
|
allKeys: (field) => statusOptionOrder(field),
|
|
@@ -295,7 +300,9 @@ export const BUCKET_RULES = {
|
|
|
295
300
|
const preset = presetOf(def, v);
|
|
296
301
|
if (preset)
|
|
297
302
|
return preset.key;
|
|
298
|
-
return isRangeValue(v) && !isEmptyRange(v)
|
|
303
|
+
return isRangeValue(v) && !isEmptyRange(v)
|
|
304
|
+
? `${v.low ?? ""}–${v.high ?? ""}`
|
|
305
|
+
: UNCATEGORIZED_KEY;
|
|
299
306
|
},
|
|
300
307
|
labelOf: (field, key, _g, cv = DEFAULT_CONVENTIONS) => {
|
|
301
308
|
if (key === UNCATEGORIZED_KEY)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { localDay, utcDay } from "../codecs.js";
|
|
2
|
-
import { DEFAULT_CONVENTIONS, conventionsOr } from "../conventions.js";
|
|
2
|
+
import { DEFAULT_CONVENTIONS, conventionsOr, writeDay, } from "../conventions.js";
|
|
3
3
|
export const DATE_FILTER_OPERATORS = [
|
|
4
4
|
{ value: "is", label: "Is", dates: 1 },
|
|
5
5
|
{ value: "is_not", label: "Is not", dates: 1 },
|
|
@@ -168,22 +168,11 @@ export function isDateRuleActive(rule) {
|
|
|
168
168
|
return false;
|
|
169
169
|
return dates === 1 || !!rule.to;
|
|
170
170
|
}
|
|
171
|
-
const SHORT_DAY = new Map();
|
|
172
171
|
function short(key, cv) {
|
|
173
172
|
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(key);
|
|
174
173
|
if (!match || !fromDayKey(key))
|
|
175
174
|
return key;
|
|
176
|
-
|
|
177
|
-
if (!format) {
|
|
178
|
-
format = new Intl.DateTimeFormat(cv.locale, {
|
|
179
|
-
day: "numeric",
|
|
180
|
-
month: "short",
|
|
181
|
-
year: "numeric",
|
|
182
|
-
timeZone: "UTC",
|
|
183
|
-
});
|
|
184
|
-
SHORT_DAY.set(cv.locale, format);
|
|
185
|
-
}
|
|
186
|
-
return format.format(utcDay(Number(match[1]), Number(match[2]), Number(match[3])));
|
|
175
|
+
return writeDay(utcDay(Number(match[1]), Number(match[2]), Number(match[3])), "day", cv);
|
|
187
176
|
}
|
|
188
177
|
export function dateRuleLabel(rule, cv = DEFAULT_CONVENTIONS) {
|
|
189
178
|
cv = conventionsOr(cv);
|
|
@@ -102,7 +102,7 @@ assert.equal(
|
|
|
102
102
|
|
|
103
103
|
## `language`
|
|
104
104
|
|
|
105
|
-
The language is a BCP 47 tag too: the language your interface reads in. The names the library writes from data are in it, a place's country and region, while dates, numbers and the order text sorts in keep `locale`. So an app that writes its dates the Romanian way in an English interface states both. Unstated, it is `locale`, and `.with({ locale })` moves it along until you state one.
|
|
105
|
+
The language is a BCP 47 tag too: the language your interface reads in. The names the library writes from data are in it, a place's country and region, and so is the month's word in a date filter's summary and in a date group's heading, while dates' order and digits, numbers and the order text sorts in keep `locale`. So an app that writes its dates the Romanian way in an English interface states both, and a date filter's summary reads "After 24 Nov 2026" where the locale alone writes "After 24 nov. 2026": the day's order and digits are the locale's, its month's word the language's. A group's heading by day, week or month reads the same way: "November 2026", "24 Nov 2026", "Week of 24 Nov 2026". Unstated, it is `locale`, and `.with({ locale })` moves it along until you state one.
|
|
106
106
|
|
|
107
107
|
```ts
|
|
108
108
|
import { countryName, locationShort } from "viewkitjs/fields";
|
|
@@ -314,7 +314,8 @@ assert.equal(resolveCategoryColor("Software", industryOptions, { Software: "teal
|
|
|
314
314
|
// A value no option colours takes its derived colour, the same every time.
|
|
315
315
|
assert.equal(resolveCategoryColor("Retail", industryOptions, undefined), deriveCategoryColor("Retail"));
|
|
316
316
|
assert.equal(deriveCategoryColor("Retail"), deriveCategoryColor("Retail"));
|
|
317
|
-
|
|
317
|
+
// A chip wears the default Tag's pill: its words read the hue's strong step.
|
|
318
|
+
assert.ok(CATEGORY_COLOR_CLASSES.purple.includes("var(--vk-label-purple-strong,"));
|
|
318
319
|
```
|
|
319
320
|
|
|
320
321
|
## A stage mark
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# `viewkitjs/fields/design/category-colors`
|
|
2
2
|
|
|
3
|
-
Import from `viewkitjs/fields/design/category-colors` where you draw a value of a `select` or a `multiselect`. These colours are decorative: they tell one category from another and say nothing about state, which is a status's slot.
|
|
3
|
+
Import from `viewkitjs/fields/design/category-colors` where you draw a value of a `select` or a `multiselect`. These colours are decorative: they tell one category from another and say nothing about state, which is a status's slot. A chip wears the default Tag's pill: each hue's fill, its edge drawn inside and its words a strong step, which read at 4.5:1 or more on their fill in every hue, light and dark. Each rung reads a name you can declare, `--vk-label-<hue>-fill`, `--vk-label-<hue>-edge` and `--vk-label-<hue>-strong`; undeclared, it comes from your `--vk-label-<hue>` (else ViewKit's own hue), 15% and 40% into `--vk-ground` and 60% into `--vk-fg`, so with your own Tailwind map `--vk-ground` and `--vk-fg` at least. Under `viewkitjs/views/styles.css` the rungs are the Outright look's. Gray is your theme's `muted` ground with its `muted-foreground` words. The [options guide](../guides/options.md) shows an option with its colour.
|
|
4
4
|
- `CategoryColor` — the eight colours: `gray`, `blue`, `green`, `amber`, `red`, `purple`, `pink` and `teal`.
|
|
5
|
-
- `CATEGORY_COLOR_CLASSES` — a chip's class names per colour: the
|
|
5
|
+
- `CATEGORY_COLOR_CLASSES` — a chip's class names per colour: the default Tag's pill, the same strings as the Tag's.
|
|
6
6
|
- `CATEGORY_DOT_CLASSES` — a solid dot's class name per colour.
|
|
7
7
|
- `deriveCategoryColor` — a colour worked out from a value's text, the same every time, for an option that declares none.
|
|
8
8
|
- `resolveCategoryColor` — the colour a value wears: a person's own override first, then the option's declared colour, then `deriveCategoryColor`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `viewkitjs/fields/design/status-slots`
|
|
2
2
|
|
|
3
|
-
Import from `viewkitjs/fields/design/status-slots` where you draw a status. Every option of a `status` field wears one semantic slot (`slot: "success"`), and this entry maps each slot to Tailwind class names. Each class names a theme token (`success`, `destructive`, `warning`, `info`, `primary` and the greys), never a palette colour, so your stylesheet defines the tokens once and every badge, dot and pill follows them in both themes. Under `viewkitjs/views/styles.css` instead of your own Tailwind, the classes draw the Outright look's colours,
|
|
3
|
+
Import from `viewkitjs/fields/design/status-slots` where you draw a status. Every option of a `status` field wears one semantic slot (`slot: "success"`), and this entry maps each slot to Tailwind class names. Each class names a theme token (`success`, `destructive`, `warning`, `info`, `primary` and the greys), never a palette colour, so your stylesheet defines the tokens once and every badge, dot and pill follows them in both themes. Under `viewkitjs/views/styles.css` instead of your own Tailwind, the classes draw the Outright look's colours, each through a `--vk-*` name you can declare (`--vk-success`, `--vk-brand`, `--vk-neutral`, the soft fills `--vk-success-subtlest`, `--vk-warning-subtlest` and `--vk-info-subtlest`, and the words on a filled pill `--vk-fg-inverse` and `--vk-fg-warning-inverse`). The [options guide](../guides/options.md) shows a status's options.
|
|
4
4
|
- `StatusSlot` — the seven slots: `success` (a good end), `error` (failed), `warning` (needs attention), `running` (happening now), `pending` (waiting), `primary` (active, mid-way) and `muted` (skipped, inactive).
|
|
5
5
|
- `StatusBadgeVariant` — a status pill's two looks, both borderless: `soft` (a tinted fill and the colour as text) and `solid` (the colour as fill).
|
|
6
6
|
- `STATUS_SLOT_CLASSES` — the class names per slot: a badge's pill for each variant, an avatar's corner dot, a bare glyph's colour, an active tab and a plain tab's hover.
|
|
@@ -49,7 +49,7 @@ Guide: [the index](../guides/the-index.md).
|
|
|
49
49
|
|
|
50
50
|
Guide: [conventions](../guides/conventions.md).
|
|
51
51
|
|
|
52
|
-
- `defineConventions` — builds a host's frozen conventions: its locale, its names language (`language`, the language a place's country and region are named in; default its locale), time zone, decimal separator, region, id formats, message resolver and link platforms. It throws `FieldConventionsError` on a locale, zone, region or platform it cannot use, and the result's `with` returns a new copy with some of them stated differently.
|
|
52
|
+
- `defineConventions` — builds a host's frozen conventions: its locale, its names language (`language`, the language a place's country and region are named in, and the month of a date filter's summary and of a date group's heading; default its locale), time zone, decimal separator, region, id formats, message resolver and link platforms. It throws `FieldConventionsError` on a locale, zone, region or platform it cannot use, and the result's `with` returns a new copy with some of them stated differently.
|
|
53
53
|
- `DEFAULT_CONVENTIONS` — the conventions a function uses when it is handed none: `en-GB`, UTC, both decimal styles read, no region and the neutral English messages. They never depend on the runtime, so a server and a browser that state nothing agree.
|
|
54
54
|
- `ConventionsInput` — what a host may state to `defineConventions`; every member is optional.
|
|
55
55
|
- `ConventionsOverrides` — what `with` takes: any member of `ConventionsInput`, and `null` for `decimal` or `region` to state none.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viewkitjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "ViewKit — typed fields, the grid and its editors, and a list's SQL for record lists, in one package: viewkitjs/fields, viewkitjs/views and viewkitjs/postgres. By Sheaf.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -168,6 +168,14 @@
|
|
|
168
168
|
"types": "./views/dist/grid/index.d.ts",
|
|
169
169
|
"default": "./views/dist/grid/index.js"
|
|
170
170
|
},
|
|
171
|
+
"./views/looks": {
|
|
172
|
+
"types": "./views/dist/looks/index.d.ts",
|
|
173
|
+
"default": "./views/dist/looks/index.js"
|
|
174
|
+
},
|
|
175
|
+
"./views/controls": {
|
|
176
|
+
"types": "./views/dist/controls/index.d.ts",
|
|
177
|
+
"default": "./views/dist/controls/index.js"
|
|
178
|
+
},
|
|
171
179
|
"./views/panels": {
|
|
172
180
|
"types": "./views/dist/panels/index.d.ts",
|
|
173
181
|
"default": "./views/dist/panels/index.js"
|
|
@@ -178,6 +186,9 @@
|
|
|
178
186
|
},
|
|
179
187
|
"./views/styles.css": "./views/dist/styles.css",
|
|
180
188
|
"./views/styles.unlayered.css": "./views/dist/styles.unlayered.css",
|
|
189
|
+
"./views/controls/smooth.css": "./views/dist/controls/smooth.css",
|
|
190
|
+
"./views/controls/button.css": "./views/dist/controls/button.css",
|
|
191
|
+
"./views/controls/spinner.css": "./views/dist/controls/spinner.css",
|
|
181
192
|
"./postgres": {
|
|
182
193
|
"types": "./postgres/dist/index.d.ts",
|
|
183
194
|
"default": "./postgres/dist/index.js"
|
|
@@ -197,6 +208,7 @@
|
|
|
197
208
|
"tldts": "7.5.5"
|
|
198
209
|
},
|
|
199
210
|
"peerDependencies": {
|
|
211
|
+
"@base-ui/react": "^1.6.0",
|
|
200
212
|
"@dnd-kit/core": "^6.3.1",
|
|
201
213
|
"@dnd-kit/sortable": "^10.0.0",
|
|
202
214
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -205,6 +217,9 @@
|
|
|
205
217
|
"zod": "^4.1.12"
|
|
206
218
|
},
|
|
207
219
|
"peerDependenciesMeta": {
|
|
220
|
+
"@base-ui/react": {
|
|
221
|
+
"optional": true
|
|
222
|
+
},
|
|
208
223
|
"@dnd-kit/core": {
|
|
209
224
|
"optional": true
|
|
210
225
|
},
|
|
@@ -222,6 +237,7 @@
|
|
|
222
237
|
}
|
|
223
238
|
},
|
|
224
239
|
"devDependencies": {
|
|
240
|
+
"@base-ui/react": "1.6.0",
|
|
225
241
|
"@dnd-kit/core": "^6.3.1",
|
|
226
242
|
"@dnd-kit/sortable": "^10.0.0",
|
|
227
243
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -264,7 +280,9 @@
|
|
|
264
280
|
"bench:picking": "node views/bench/picking-check.ts",
|
|
265
281
|
"bench:footer": "node views/bench/footer-check.ts",
|
|
266
282
|
"bench:chip": "node views/bench/chip-check.ts",
|
|
283
|
+
"bench:views-row": "node views/bench/views-row-check.ts",
|
|
267
284
|
"bench:shift": "node views/bench/shift-check.ts",
|
|
285
|
+
"bench:title-click": "node views/bench/title-click-check.ts",
|
|
268
286
|
"styles:defaults": "node views/styles/defaults.ts",
|
|
269
287
|
"bench:stylesheet": "node views/bench/stylesheet-check.ts"
|
|
270
288
|
}
|
package/views/README.md
CHANGED
|
@@ -86,11 +86,12 @@ References, one per door, each naming every export: [`viewkitjs/views`](./docs/r
|
|
|
86
86
|
| `viewkitjs/views/cells` | a column's typed cell, and its column-shaped string formatters |
|
|
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
|
+
| `viewkitjs/views/looks` | a piece's options and looks, declared beside it, and the helpers that wear one; the grid's first; no React |
|
|
89
90
|
| `viewkitjs/views/panels` | what a list's panels read and say, built from its settings, and the toolbar's arrangement; no React |
|
|
90
91
|
| `viewkitjs/views/panels/react` | the panels as they draw, the toolbar's frame, its parts and the ready toolbar |
|
|
91
92
|
| `viewkitjs/views/styles.css`, `/styles.unlayered.css` | the rendering's look as one stylesheet, the Outright look by default, with no Tailwind needed ([install](./docs/install.md)) |
|
|
92
93
|
|
|
93
|
-
Twenty-
|
|
94
|
+
Twenty-four doors and two stylesheets; there are no other subpaths.
|
|
94
95
|
|
|
95
96
|
## For coding agents
|
|
96
97
|
|
|
@@ -3,5 +3,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { cx } from "../internal/cx.js";
|
|
4
4
|
import { STATUS_DOT, STATUS_TEXT } from "./tones.js";
|
|
5
5
|
export function DefaultStatusBadge({ slot, label, leading, title, size = "compact", className }) {
|
|
6
|
-
return (_jsxs("span", { "data-slot": "vk-status", "data-status": slot, title: title, className: cx("inline-flex min-w-0 items-center gap-1.5 font-medium", size === "compact" ? "text-[11px]" : "text-xs", STATUS_TEXT[slot], className), children: [leading ?? _jsx("span", { "aria-hidden": "true", className: cx("size-1.5 shrink-0 rounded-full", STATUS_DOT[slot]) }), _jsx("span", { className: "truncate", children: label })] }));
|
|
6
|
+
return (_jsxs("span", { "data-slot": "vk-status", "data-status": slot, title: title, className: cx("inline-flex min-w-0 items-center gap-1.5 font-medium", size === "compact" ? "text-[11px]" : size === "regular" && "text-xs", STATUS_TEXT[slot], className), children: [leading ?? _jsx("span", { "aria-hidden": "true", className: cx("size-1.5 shrink-0 rounded-full", STATUS_DOT[slot]) }), _jsx("span", { className: "truncate", children: label })] }));
|
|
7
7
|
}
|
|
@@ -18,11 +18,11 @@ export const STATUS_DOT = {
|
|
|
18
18
|
};
|
|
19
19
|
export const TAG_TONE = {
|
|
20
20
|
gray: "bg-(color:--vk-neutral) text-(color:--vk-fg-subtle)",
|
|
21
|
-
blue: "bg-[color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))
|
|
22
|
-
green: "bg-[color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))
|
|
23
|
-
amber: "bg-[color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))
|
|
24
|
-
red: "bg-[color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))
|
|
25
|
-
purple: "bg-[color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))
|
|
26
|
-
pink: "bg-[color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))
|
|
27
|
-
teal: "bg-[color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))
|
|
21
|
+
blue: "bg-[var(--vk-label-blue-fill,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-blue-edge,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-blue-strong,color-mix(in_oklab,var(--vk-label-blue,hsl(199_89%_48%))_60%,var(--vk-fg)))]",
|
|
22
|
+
green: "bg-[var(--vk-label-green-fill,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-green-edge,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-green-strong,color-mix(in_oklab,var(--vk-label-green,hsl(160_84%_39%))_60%,var(--vk-fg)))]",
|
|
23
|
+
amber: "bg-[var(--vk-label-amber-fill,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-amber-edge,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-amber-strong,color-mix(in_oklab,var(--vk-label-amber,hsl(38_92%_50%))_60%,var(--vk-fg)))]",
|
|
24
|
+
red: "bg-[var(--vk-label-red-fill,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-red-edge,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-red-strong,color-mix(in_oklab,var(--vk-label-red,hsl(0_84%_60%))_60%,var(--vk-fg)))]",
|
|
25
|
+
purple: "bg-[var(--vk-label-purple-fill,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-purple-edge,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-purple-strong,color-mix(in_oklab,var(--vk-label-purple,hsl(258_90%_66%))_60%,var(--vk-fg)))]",
|
|
26
|
+
pink: "bg-[var(--vk-label-pink-fill,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-pink-edge,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-pink-strong,color-mix(in_oklab,var(--vk-label-pink,hsl(330_81%_60%))_60%,var(--vk-fg)))]",
|
|
27
|
+
teal: "bg-[var(--vk-label-teal-fill,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_15%,var(--vk-ground)))] shadow-[inset_0_0_0_1px_var(--vk-label-teal-edge,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_40%,var(--vk-ground)))] text-[color:var(--vk-label-teal-strong,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_60%,var(--vk-fg)))]",
|
|
28
28
|
};
|
|
@@ -98,8 +98,9 @@ export type ViewsStatusBadgeProps = {
|
|
|
98
98
|
/** Replaces the slot's own mark. */
|
|
99
99
|
leading?: ReactNode;
|
|
100
100
|
title?: string;
|
|
101
|
-
/** Default `compact` (11px)
|
|
102
|
-
|
|
101
|
+
/** Default `compact` (11px). `row`: the text size of the row it sits in, its dot as compact's: what a cell's
|
|
102
|
+
* status value hands, which an app's own badge should honour. */
|
|
103
|
+
size?: "compact" | "regular" | "row";
|
|
103
104
|
className?: string;
|
|
104
105
|
};
|
|
105
106
|
export type ViewsStatusMarkerProps = {
|