@umriss-ui/core 0.41.1 → 0.42.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 CHANGED
@@ -4,11 +4,12 @@ This document describes what changes for **callers** of the package: exports,
4
4
  props, behaviour.
5
5
 
6
6
  **The numbers.** The middle digit rises when something is added; the last one
7
- when something is repaired. As long as the first digit is `0`, no number
8
- promises compatibility — which is why a rule stronger than the figure applies as
9
- well: **whatever changes existing behaviour stands under a heading "Changed" of
10
- its own**, no matter which digit rose. Whoever reads only one section before an
11
- upgrade reads that one.
7
+ when something is repaired. The six packages are released in step, and a rename
8
+ keeps its old name for one further minor, with a warning, before the minor after
9
+ it removes the name ([the upgrade promise, ADR-0066](../../docs/adr/0066-one-number-peers-over-the-minor-a-rename-lives-one-minor.md)).
10
+ **Whatever changes existing behaviour stands under a heading "Changed" of its
11
+ own**, no matter which digit rose, with a `Migration:` line. Whoever reads only
12
+ one section before an upgrade reads that one.
12
13
 
13
14
  From 0.34.0 the packages share one number - five, and six from 0.40.0, when the dashboard joined: they are released together, and a package without a change of its own still gets a heading for it.
14
15
 
@@ -26,12 +27,30 @@ package stood at `0.1.0` the whole time, because it had exactly one caller and t
26
27
  caller lay in the same repository — and are grouped by unit of delivery, not by
27
28
  commit.
28
29
 
30
+ ## 0.42.0 – Tested in Vitest and Jest, themed from one file (Oct. 2026)
31
+
32
+ ### Added
33
+
34
+ - **Core loads in Vitest and Jest with the lines its README gives.** The new "Testing" section holds `vitest.config.ts`, `jest.config.cjs` with its CSS stub and Babel config, and `umriss.setup.js` with the five polyfills jsdom lacks; `.` and `./wording/de` carry a `default` condition for Jest's resolver. The release check installs the packed package into a scratch project and runs a test from those very blocks under both runners.
35
+ - **Six tokens where a value was written into a component:** `--u-modal-width-sm`, `--u-modal-width-md` and `--u-modal-width-lg` (400, 520 and 720 px), `--u-transform-caps` (`uppercase`, read by every text in spaced capitals - Card's eyebrow, Divider's label, the caps style, the DatePicker's weekdays, the CommandPalette, the table's head and the dashboard's mode label), `--u-button-press-scale` (0.98) and `--u-label-size` (a FormField label's size, `--u-text-sm`). Each defaults to the value it replaces.
36
+ - **A brand file to copy** in the README's Styles section: the font, the six accent tokens and the charts' palette, each light and dark; a unit test holds it to the stylesheets and the contrast pairs. Type on the accent surface joins the contrast pairs at 4.5:1.
37
+ - **The layer order for Tailwind v4 and for a wrapper library** stands in the Styles section, with the one declaration each needs; it holds in either load order.
38
+ - **A "Server Components" section** says what a Server Component may do with core: render its components with props React can serialise (ADR-0067).
39
+ - **TypeScript 5.4 or newer**, stated in the Install section (the declarations use `NoInfer`); the release check compiles a strict consumer under 5.4 as well as the current TypeScript.
40
+
41
+ ### Changed
42
+
43
+ - **`useFormats()` writes no date or time until the page has hydrated.** On a server and in the hydration render its instant formats (`date`, `dateShort`, `month`, `dateLong`, `time`, `dateTime`, `offset`) return an empty text; a client-only render never sees them empty. A server in another zone than the reader's no longer raises React's hydration error #418 (ADR-0060, amended). The pickers measure their field with the real formats, so their width does not jump.
44
+ - Migration: nothing to change in an application that renders in the browser; a test that renders to a string and expects a date finds an empty text - render it in the DOM instead.
45
+
29
46
  ## 0.41.1 – The documentation runs where the code is (Oct. 2026)
30
47
 
31
48
  ### Changed
32
49
 
33
50
  - **The documentation is no longer hosted.** The site on GitHub Pages is gone, and the package's `homepage` now names its README on GitHub. The running documentation of this version opens from a checkout of the tag `core-v0.41.1` with `pnpm install` and `pnpm start`, at `http://localhost:4170/umriss-ui/` - the repository README says how, under "See it running".
51
+ - Migration: nothing to change; a bookmark or link to the old hosted site no longer resolves - open the documentation from a checkout of the tag, as described above.
34
52
  - **`docs/llms-full.md` in the package stands on its own:** a link to another page points at that page's heading in the same file, a link to a place on the site that the file does not hold keeps only its text, and ADR-0032 is linked at this version's tag.
53
+ - Migration: nothing to change; look at any tool that read `docs/llms-full.md` and followed its links to the site, which now find the heading in the same file.
35
54
 
36
55
  ## 0.41.0 – Colours survive a modern build (Oct. 2026)
37
56
 
package/README.md CHANGED
@@ -28,15 +28,58 @@ In an application:
28
28
  import { Button, Card } from "@umriss-ui/core";
29
29
  ```
30
30
 
31
- Nothing else is required. React 19 or newer as a peer.
31
+ Nothing else is required. React 19 or newer as a peer. TypeScript 5.4 or newer (the declarations use `NoInfer`).
32
32
 
33
33
  The package ships ES2022 syntax; an application that serves older browsers
34
34
  transpiles it itself.
35
35
 
36
36
  Every entry, `./wording/de` included, begins with `"use client"`, the directive a framework
37
- with Server Components reads to treat a module as client code. No test runs
38
- inside such a framework: the package is rendered to a string in a test,
39
- and the fields' widths a server writes into the markup are checked there.
37
+ with Server Components reads to treat a module as client code. Core's components render from a
38
+ Server Component with props React can serialise; a function prop (a handler, a render prop) is
39
+ callable only in a client file. No test runs inside such a framework: the package is rendered to a
40
+ string in a test, and the fields' widths a server writes into the markup are checked there.
41
+
42
+ ### Server Components
43
+
44
+ A Server Component fetches the data and hands it to a Client Component. The views - table, chart,
45
+ schedule, dashboard - are declared by their hook, so the declaration stays in a client file next to
46
+ them, with its `rowKey`, columns and formatters. Only the rows cross the boundary:
47
+
48
+ ```tsx
49
+ // app/orders/page.tsx - a Server Component
50
+ import { OrdersTable } from "./orders-table";
51
+ import { loadOrders } from "@/lib/orders";
52
+
53
+ export default async function Page() {
54
+ return <OrdersTable rows={await loadOrders()} />;
55
+ }
56
+ ```
57
+
58
+ ```tsx
59
+ // app/orders/orders-table.tsx
60
+ "use client";
61
+ import { useTable } from "@umriss-ui/table";
62
+ import type { Order } from "@/lib/orders";
63
+
64
+ export function OrdersTable({ rows }: { rows: Order[] }) {
65
+ const { Table, Column } = useTable(rows, { rowKey: (o) => o.number });
66
+
67
+ return (
68
+ <Table ariaLabel="Orders">
69
+ <Column value="number" label="Order" rowHeader />
70
+ <Column value="customer" label="Customer" />
71
+ <Column value="quantity" label="Quantity" />
72
+ </Table>
73
+ );
74
+ }
75
+ ```
76
+
77
+ On a server, and until the page has hydrated, a date or time is empty, because only the browser
78
+ knows the reader's zone.
79
+
80
+ The calculation is the one view a Server Component writes itself: its tree is read where it is
81
+ written (see `@umriss-ui/calculation`). The reasons are in
82
+ [ADR-0067](../../docs/adr/0067-a-server-component-hands-umriss-its-data-and-writes-only-a-calculation.md).
40
83
 
41
84
  ### What an import costs
42
85
 
@@ -65,13 +108,60 @@ elements, a focus ring on what it makes focusable. A caller's content inside
65
108
  layers, `umriss.tokens`, `umriss.base` and `umriss.components`, and CSS written
66
109
  outside a layer wins over all of them, whatever the order of loading:
67
110
 
68
- ```css
111
+ A brand is one file to copy and edit. It sets the font, the whole accent and
112
+ the charts' palette, each colour with a light and a dark value, so that no part
113
+ of the interface stays petrol; the values are an example (indigo), not the
114
+ defaults:
115
+
116
+ ```css brand.css
69
117
  :root {
70
118
  --u-font-sans: "Inter", system-ui, sans-serif;
71
- --u-color-accent: #0f766e;
119
+
120
+ --u-color-accent: light-dark(#4338ca, #818cf8);
121
+ --u-color-accent-hover: light-dark(#3730a3, #a5b4fc);
122
+ --u-color-accent-subtle: light-dark(#eef0fb, #1e1f3d);
123
+ --u-color-accent-subtle-pressed: light-dark(#dfe2f7, #282a52);
124
+ --u-color-accent-text: light-dark(#4338ca, #a5b4fc);
125
+ --u-color-on-accent: light-dark(#ffffff, #1e1b4b);
126
+
127
+ --u-chart-1: light-dark(#4338ca, #818cf8);
128
+ --u-chart-2: light-dark(#db2777, #f472b6);
129
+ --u-chart-3: light-dark(#059669, #34d399);
130
+ --u-chart-4: light-dark(#d97706, #fbbf24);
131
+ --u-chart-5: light-dark(#0891b2, #22d3ee);
132
+ --u-chart-6: light-dark(#7c3aed, #a78bfa);
72
133
  }
73
134
  ```
74
135
 
136
+ A brand may also change the neutrals, the radius, `--u-transform-caps` with
137
+ `--u-tracking-caps`, `--u-button-press-scale`, `--u-label-size` and the modal
138
+ widths; the Theming page's table lists every token.
139
+
140
+ **Denser or roomier.** An application sets the type steps, the spaces and the
141
+ small control heights. A table and a calculation follow them, and the
142
+ provider's `density` chooses regular or compact on top.
143
+
144
+ **Layered CSS of your own.** The order of the layers decides who wins, so
145
+ declare it before anything else is read.
146
+
147
+ - Tailwind v4: this line as the first CSS the page reads, before
148
+ `@import "tailwindcss"`. Utilities then win over umriss, and Tailwind's
149
+ preflight stays below it.
150
+
151
+ ```css
152
+ @layer theme, base, umriss.tokens, umriss.base, umriss.components, components, utilities;
153
+ ```
154
+
155
+ - A wrapper library: this line as the first statement of its stylesheet,
156
+ with its own layer in place of `acme`. It holds in either load order.
157
+
158
+ ```css
159
+ @layer umriss.tokens, umriss.base, umriss.components, acme;
160
+ ```
161
+
162
+ Unlayered CSS always wins. A classic unlayered reset (Bootstrap and the like) is
163
+ not fixed by layer order.
164
+
75
165
  **Light and dark follow the application's `color-scheme`.** Every token with
76
166
  two values is written `light-dark(<light>, <dark>)`. An application that
77
167
  switches its mode with a theme library usually sets `color-scheme` already;
@@ -104,6 +194,108 @@ token away.
104
194
  older nowhere; an older browser discards the tokens and shows the interface
105
195
  unstyled.
106
196
 
197
+ ## Testing
198
+
199
+ Tested: Vitest 5 and Jest 30 (with babel-jest), both on jsdom. happy-dom and Jest 29 may work and are
200
+ not promised. `check:dist` runs a test of the installed package in a Vitest project and a Jest project
201
+ that hold exactly the files below.
202
+
203
+ **Vitest** needs one line, `server.deps.inline`: Vitest hands a dependency to Node, and Node cannot
204
+ import the stylesheet that the package's JavaScript imports (`Unknown file extension ".css"`). Inlined,
205
+ Vitest's own pipeline handles it.
206
+
207
+ ```ts vitest.config.ts
208
+ import { defineConfig } from "vitest/config";
209
+
210
+ export default defineConfig({
211
+ test: {
212
+ environment: "jsdom",
213
+ globals: true,
214
+ setupFiles: ["./umriss.setup.js"],
215
+ server: { deps: { inline: [/@umriss-ui/] } },
216
+ },
217
+ });
218
+ ```
219
+
220
+ **Jest** needs two settings: `moduleNameMapper` maps every stylesheet to an empty module, and
221
+ `transformIgnorePatterns` lets babel-jest compile the package, which ships ES modules. Babel's config
222
+ must apply to `node_modules`, so it is a root `babel.config.*`, not a `.babelrc`.
223
+
224
+ ```js jest.config.cjs
225
+ module.exports = {
226
+ testEnvironment: "jsdom",
227
+ setupFilesAfterEnv: ["<rootDir>/umriss.setup.js"],
228
+ moduleNameMapper: { "\\.css$": "<rootDir>/css-stub.cjs" },
229
+ transformIgnorePatterns: ["/node_modules/(?!(@umriss-ui)/)"],
230
+ };
231
+ ```
232
+
233
+ ```js css-stub.cjs
234
+ module.exports = {};
235
+ ```
236
+
237
+ ```js babel.config.cjs
238
+ module.exports = {
239
+ presets: [
240
+ ["@babel/preset-env", { targets: { node: "current" } }],
241
+ ["@babel/preset-react", { runtime: "automatic" }],
242
+ ],
243
+ };
244
+ ```
245
+
246
+ **Next.js** with `next/jest`: put the umriss packages in `transpilePackages`; the preset stubs the
247
+ stylesheets and compiles the packages itself.
248
+
249
+ **The setup file** gives jsdom the five browser APIs that core's components use. It is the same file
250
+ for both runners:
251
+
252
+ ```js umriss.setup.js
253
+ globalThis.ResizeObserver ??= class {
254
+ observe() {}
255
+ unobserve() {}
256
+ disconnect() {}
257
+ };
258
+
259
+ globalThis.IntersectionObserver ??= class {
260
+ observe() {}
261
+ unobserve() {}
262
+ disconnect() {}
263
+ takeRecords() {
264
+ return [];
265
+ }
266
+ };
267
+
268
+ window.matchMedia ??= (query) => ({
269
+ matches: false,
270
+ media: query,
271
+ onchange: null,
272
+ addEventListener() {},
273
+ removeEventListener() {},
274
+ addListener() {},
275
+ removeListener() {},
276
+ dispatchEvent: () => false,
277
+ });
278
+
279
+ Element.prototype.scrollIntoView ??= function () {};
280
+
281
+ /* jsdom knows <dialog> but not showModal() and close(). */
282
+ HTMLDialogElement.prototype.showModal ??= function () {
283
+ this.setAttribute("open", "");
284
+ };
285
+ HTMLDialogElement.prototype.close ??= function (value) {
286
+ if (!this.hasAttribute("open")) return;
287
+ this.removeAttribute("open");
288
+ if (value !== undefined) this.returnValue = value;
289
+ this.dispatchEvent(new Event("close"));
290
+ };
291
+ ```
292
+
293
+ **End-to-end suites.** The motion follows `prefers-reduced-motion`, so a Playwright suite turns it off
294
+ with `reducedMotion: 'reduce'` in `use`. A tool without that switch sets, on `:root`, the tokens the
295
+ reduced-motion block sets to `0ms`: `--u-transition`, `--u-duration-press`, `--u-duration-fast`,
296
+ `--u-duration-medium`, `--u-duration-draw`, `--u-delay-draw`, `--u-duration-exit-fast`,
297
+ `--u-duration-exit` and `--u-duration-exit-collapse`.
298
+
107
299
  ## Wording
108
300
 
109
301
  English is the default wording. German ships as well, as the subpath export