viewkitjs 0.21.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/MIGRATION.md +1 -1
  3. package/README.md +1 -1
  4. package/fields/dist/conventions.d.ts +15 -3
  5. package/fields/dist/conventions.js +25 -0
  6. package/fields/dist/design/category-colors.d.ts +12 -5
  7. package/fields/dist/design/category-colors.js +7 -7
  8. package/fields/dist/query/buckets.js +42 -35
  9. package/fields/dist/query/date.js +2 -13
  10. package/fields/docs/guides/conventions.md +1 -1
  11. package/fields/docs/guides/options.md +2 -1
  12. package/fields/docs/reference/design-category-colors.md +2 -2
  13. package/fields/docs/reference/fields.md +1 -1
  14. package/package.json +15 -1
  15. package/views/dist/atoms/tones.js +7 -7
  16. package/views/dist/contract.d.ts +288 -0
  17. package/views/dist/contract.js +96 -0
  18. package/views/dist/controls/button/button.d.ts +40 -0
  19. package/views/dist/controls/button/button.js +40 -0
  20. package/views/dist/controls/button/looks.d.ts +4 -0
  21. package/views/dist/controls/button/looks.js +20 -0
  22. package/views/dist/controls/button/map-button.d.ts +11 -0
  23. package/views/dist/controls/button/map-button.js +20 -0
  24. package/views/dist/controls/button/own-look.d.ts +59 -0
  25. package/views/dist/controls/button/own-look.js +33 -0
  26. package/views/dist/controls/button.css +530 -0
  27. package/views/dist/controls/controls.d.ts +5 -0
  28. package/views/dist/controls/controls.js +2 -0
  29. package/views/dist/controls/index.d.ts +11 -0
  30. package/views/dist/controls/index.js +6 -0
  31. package/views/dist/controls/smooth.css +101 -0
  32. package/views/dist/controls/spinner/looks.d.ts +4 -0
  33. package/views/dist/controls/spinner/looks.js +32 -0
  34. package/views/dist/controls/spinner/spinner.d.ts +23 -0
  35. package/views/dist/controls/spinner/spinner.js +16 -0
  36. package/views/dist/controls/spinner.css +147 -0
  37. package/views/dist/display/date.js +15 -2
  38. package/views/dist/looks/index.d.ts +2 -0
  39. package/views/dist/looks/index.js +2 -0
  40. package/views/dist/looks/looks.d.ts +2 -1
  41. package/views/dist/looks/pieces.js +3 -1
  42. package/views/dist/panels/react/views-row/FoldingViewRow.js +8 -8
  43. package/views/dist/styles.css +825 -56
  44. package/views/dist/styles.unlayered.css +842 -56
  45. package/views/docs/contract.md +131 -8
  46. package/views/docs/guides/the-provider.md +1 -1
  47. package/views/docs/index.md +1 -0
  48. package/views/docs/install.md +2 -0
  49. package/views/docs/reference/controls.md +36 -0
  50. package/views/docs/reference/looks.md +12 -2
  51. package/views/docs/reference/views.md +4 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ 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
+
8
30
  ## [0.21.0] — 2026-11-25
9
31
 
10
32
  ### Added
package/MIGRATION.md CHANGED
@@ -68,7 +68,7 @@ installs none of them.
68
68
  | `@viewkitjs/postgres/definitions` | `viewkitjs/postgres/definitions` |
69
69
 
70
70
  There is no `viewkitjs` entry on its own: every path names its part. A door added since, such as
71
- `viewkitjs/views/looks`, has no old path: an app starts on it under `viewkitjs`. The three `package.json` entries move the
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
72
72
  same way (`@viewkitjs/fields/package.json` is `viewkitjs/package.json`, one manifest for all three parts).
73
73
 
74
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 five are optional peers: an app that uses only fields or postgres installs none of them. ESM only, Node 20 or later.
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) are in
9
- * it, while dates, numbers and text order keep `locale`. Default: `locale`. */
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 are written in it. `locale` when none was stated. */
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 label palette's `-soft` rung as the chip fill, the
4
- * colour itself as text. The palette is the host stylesheet's `--label-*`: eight fixed
5
- * hues, the same in every theme (a label's colour is the user's choice, not
6
- * the theme's), with the soft rung derived into the live background so the
7
- * chip reads on a dark theme too. No `dark:` variants for that reason.
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-soft text-label-blue",
4
- green: "bg-label-green-soft text-label-green",
5
- amber: "bg-label-amber-soft text-label-amber",
6
- red: "bg-label-red-soft text-label-red",
7
- purple: "bg-label-purple-soft text-label-purple",
8
- pink: "bg-label-pink-soft text-label-pink",
9
- teal: "bg-label-teal-soft text-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", "rel:today": "today", "rel:yesterday": "yesterday",
44
- "rel:last_7_days": "last_7_days", "rel:last_30_days": "last_30_days",
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", "due:today": "today", "due:tomorrow": "tomorrow",
48
- "due:next_7_days": "next_7_days", "due:next_30_days": "next_30_days",
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": return { from: shiftDay(today, 1), to: LAST_DAY };
102
- case "rel:today": return { from: today, to: shiftDay(today, 1) };
103
- case "rel:yesterday": return { from: shiftDay(today, -1), to: today };
104
- case "rel:last_7_days": return { from: shiftDay(today, -7), to: shiftDay(today, -1) };
105
- case "rel:last_30_days": return { from: windowsFrom, to: shiftDay(today, -7) };
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": return { from: FIRST_DAY, to: today };
122
- case "due:today": return { from: today, to: shiftDay(today, 1) };
123
- case "due:tomorrow": return { from: shiftDay(today, 1), to: shiftDay(today, 2) };
124
- case "due:next_7_days": return { from: shiftDay(today, 2), to: shiftDay(today, 8) };
125
- case "due:next_30_days": return { from: shiftDay(today, 8), to: monthsFrom };
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 labelFormat(cv, "month").format(utcDay(Number(month[1]), Number(month[2]), 1));
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 labelFormat(cv, "month").format(at);
186
+ return writeDay(at, "month", cv);
185
187
  case "week":
186
188
  return cv.messages({
187
189
  key: "group.week-of",
188
- values: { day: labelFormat(cv, "day").format(at) },
190
+ values: { day: writeDay(at, "day", cv) },
189
191
  });
190
192
  case "day":
191
- return labelFormat(cv, "day").format(at);
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: { ...byOption, allKeys: (field) => (isOpenVocabulary(field) ? [] : optionValues(asOptionField(field))) },
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) ? `${v.low ?? ""}–${v.high ?? ""}` : UNCATEGORIZED_KEY;
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
- let format = SHORT_DAY.get(cv.locale);
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
- assert.equal(CATEGORY_COLOR_CLASSES.purple, "bg-label-purple-soft text-label-purple");
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. The class names read your stylesheet's `--label-*` tokens, eight hues that stay the same in every theme. Under `viewkitjs/views/styles.css` instead of your own Tailwind, a chip's text reads `--vk-label-<hue>` and its fill `--vk-label-<hue>-soft`, both names you can declare. The [options guide](../guides/options.md) shows an option with its colour.
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 colour's soft rung as the fill and the colour as text.
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`.
@@ -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.21.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": {
@@ -172,6 +172,10 @@
172
172
  "types": "./views/dist/looks/index.d.ts",
173
173
  "default": "./views/dist/looks/index.js"
174
174
  },
175
+ "./views/controls": {
176
+ "types": "./views/dist/controls/index.d.ts",
177
+ "default": "./views/dist/controls/index.js"
178
+ },
175
179
  "./views/panels": {
176
180
  "types": "./views/dist/panels/index.d.ts",
177
181
  "default": "./views/dist/panels/index.js"
@@ -182,6 +186,9 @@
182
186
  },
183
187
  "./views/styles.css": "./views/dist/styles.css",
184
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",
185
192
  "./postgres": {
186
193
  "types": "./postgres/dist/index.d.ts",
187
194
  "default": "./postgres/dist/index.js"
@@ -201,6 +208,7 @@
201
208
  "tldts": "7.5.5"
202
209
  },
203
210
  "peerDependencies": {
211
+ "@base-ui/react": "^1.6.0",
204
212
  "@dnd-kit/core": "^6.3.1",
205
213
  "@dnd-kit/sortable": "^10.0.0",
206
214
  "@dnd-kit/utilities": "^3.2.2",
@@ -209,6 +217,9 @@
209
217
  "zod": "^4.1.12"
210
218
  },
211
219
  "peerDependenciesMeta": {
220
+ "@base-ui/react": {
221
+ "optional": true
222
+ },
212
223
  "@dnd-kit/core": {
213
224
  "optional": true
214
225
  },
@@ -226,6 +237,7 @@
226
237
  }
227
238
  },
228
239
  "devDependencies": {
240
+ "@base-ui/react": "1.6.0",
229
241
  "@dnd-kit/core": "^6.3.1",
230
242
  "@dnd-kit/sortable": "^10.0.0",
231
243
  "@dnd-kit/utilities": "^3.2.2",
@@ -268,7 +280,9 @@
268
280
  "bench:picking": "node views/bench/picking-check.ts",
269
281
  "bench:footer": "node views/bench/footer-check.ts",
270
282
  "bench:chip": "node views/bench/chip-check.ts",
283
+ "bench:views-row": "node views/bench/views-row-check.ts",
271
284
  "bench:shift": "node views/bench/shift-check.ts",
285
+ "bench:title-click": "node views/bench/title-click-check.ts",
272
286
  "styles:defaults": "node views/styles/defaults.ts",
273
287
  "bench:stylesheet": "node views/bench/stylesheet-check.ts"
274
288
  }
@@ -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-[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-[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-[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-[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-[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-[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-[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-[var(--vk-label-teal-strong,color-mix(in_oklab,var(--vk-label-teal,hsl(173_80%_40%))_60%,var(--vk-fg)))]",
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
  };