@zooui/nuxt 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 John Campion
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ No font files are in this repository. The Forest theme's default typefaces,
24
+ Inter and JetBrains Mono, are installed as npm dependencies
25
+ (@fontsource-variable/inter, @fontsource-variable/jetbrains-mono) under the SIL
26
+ Open Font License 1.1.
package/README.md CHANGED
@@ -1,3 +1,476 @@
1
- # Temporary Holding Version
1
+ # `@zooui/nuxt`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Zoo UI's theme-free Nuxt layer: **Nuxt UI exactly as it ships**, Zoo UI's `Z*` components for what Nuxt UI has no
4
+ equivalent of, colored-edge surfaces, and the mechanisms every product needs. It has no look of its own: everything
5
+ is written on Nuxt UI's semantic tokens, so it takes the product's colors, typefaces and color-mode key.
6
+
7
+ For a ready-made look, extend a theme layer instead. Forest, [`@zooui/theme-forest`](https://github.com/zooui-dev/zooui/blob/main/packages/theme-forest/README.md),
8
+ extends this layer with its colors, ground, typefaces and schemes. Radius, spacing, shadows, motion, focus rings and
9
+ component geometry stay Nuxt UI's in both: anything beyond that is added one deliberate decision at a time, judged
10
+ against the untouched baseline in `../../apps/kitchen-sink`.
11
+
12
+ ```bash
13
+ pnpm base:dev # → http://localhost:3004 — this layer alone, in a product's own look
14
+ pnpm base:build && pnpm base:test
15
+ pnpm ks:dev # → http://localhost:3003 — the baseline: Nuxt UI as it ships
16
+ ```
17
+
18
+ ## Using it
19
+
20
+ A product with a look of its own (say sky and slate, Nuxt UI's sans stack, its own color-mode key) extends this
21
+ layer and imports `base.css`. Nuxt UI, the `Z*` components and the mechanisms below arrive; no look does.
22
+
23
+ ```ts
24
+ // nuxt.config.ts — a product with its own look: its own color mode and icons stay its own
25
+ export default defineNuxtConfig({
26
+ extends: ['@zooui/nuxt'],
27
+ css: ['~/assets/css/main.css'],
28
+ colorMode: { preference: 'light', fallback: 'light', storageKey: 'product-color-mode' },
29
+ icon: { mode: 'svg', clientBundle: { scan: true, icons: [/* the app's own */] } },
30
+ })
31
+ ```
32
+
33
+ ```css
34
+ /* app/assets/css/main.css — the app's one Tailwind entry */
35
+ @import "@zooui/nuxt/assets/css/base.css";
36
+ @theme { --text-sm: 0.9375rem; --color-val-input: light-dark(var(--color-sky-900), var(--color-sky-200)); }
37
+ @utility section-label { /* … */ }
38
+ @layer base { [data-accent='teal'] { --a-600: var(--color-teal-600); /* … */ } }
39
+ ```
40
+
41
+ The palette goes in the product's `app.config.ts` (`ui.colors: { primary: 'sky', neutral: 'slate', … }`), as with
42
+ plain Nuxt UI. Tokens, utilities and base rules go after the `base.css` import, in the same entry: one Tailwind
43
+ compile, and the product's `@theme` overrides Tailwind's own tokens there.
44
+
45
+ The layer registers Nuxt UI but **not** the stylesheet: the app owns its single Tailwind entry so it can add
46
+ `@source` for components outside its root (and, on a theme, pick a scheme). Two entries would mean two Tailwind
47
+ compiles. `apps/forest` shows why it matters: its specimens come from `../../apps/kitchen-sink`, and until it
48
+ declared `@source` for them the page had the right colors and no spacing at all.
49
+
50
+ Do **not** add `@nuxt/ui`, `tailwindcss` or `@tailwindcss/vite` to a product: the layer owns them, and a second
51
+ Tailwind registration fails the build. Wrap the app in `<UApp>`: Nuxt UI mounts toasts, tooltips and overlays
52
+ through it. `../../apps/base` is this layer in a product with its own look; `../../apps/starter` is the smallest product
53
+ on Forest.
54
+
55
+ ## The base and a theme
56
+
57
+ | | Base — `@zooui/nuxt`, `base.css` | Theme — `@zooui/theme-forest`, `theme.css` |
58
+ | --- | --- | --- |
59
+ | Nuxt UI | registered (the one Tailwind registration, and the guard against a second) | — |
60
+ | Components | every `Z*` component, on Nuxt UI's semantic tokens | — |
61
+ | Colors | none: Nuxt UI's defaults until the product's `ui.colors` | `ui.colors` → Forest's palettes; ramps, schemes, per-scheme success/info |
62
+ | Typefaces | none: `@nuxt/fonts` on, as Nuxt UI ships | `ui.fonts: false`; Inter and JetBrains Mono (fontsource), behind the six `--zoo-font-*` / `--zoo-features-*` hooks |
63
+ | Ground | Nuxt UI's (`--ui-bg`) | Forest's paper under light pages |
64
+ | Nuxt UI restyling | none | mono badges, kbd and table headers; striped alerts; toast edges, no progress bar; nu-grid |
65
+ | Color mode | untouched: the product's key and default | `storageKey: 'zooui-color-mode'` |
66
+ | Also | `color-scheme` on the root, `data-accent` roles, `hatch`, the SSR label fix, Z\* icons bundled, `testing/find-conflicts` | — |
67
+
68
+ **Why two layers, not an option.** Nuxt merges every layer's `app.config` into the product's, and a product's
69
+ app.config can override a key but never remove one: a base that carried Forest's `ui.colors` or its alert restyling
70
+ would carry them into every product, and a product could only paint over them one key at a time. A module option
71
+ could not help either — the theme is mostly app.config and CSS, which are merged, not executed. So the theme is a
72
+ layer of its own that extends the base, and adding it (or not) is the whole choice. The CSS splits the same way:
73
+ `forest.css` is `base.css` then `theme.css`.
74
+
75
+ **The layer and the stylesheet must agree**, and the base fails the build if they don't: an app whose CSS imports
76
+ `forest.css` but extends only the base
77
+ would get Forest's typefaces and ramps with Nuxt UI's default colors, and the theme layer over `base.css` is half a
78
+ theme too. The error names the fix. The guard follows each `css` entry's active `@import` rules (comments aside) to
79
+ the files they resolve to, package specifiers included, so it judges what the CSS reaches, not how it is spelled:
80
+ `base.css` then `theme.css` counts as `forest.css` (`stylesheet-guard.js`, tested by
81
+ `scripts/check-stylesheet-guard.test.mjs`).
82
+
83
+ **Z\* components in a product's colors.** They are written on Nuxt UI's semantic tokens and palettes (`text-muted`,
84
+ `bg-elevated`, `--ui-color-primary-700` …), never on a theme's ramps, so on the base they take the product's primary,
85
+ neutral and status colors, in both modes. Where they set a value in mono (`ZKicker`, `ZIdentifier`, `ZCodeBlock`,
86
+ `ZQuotaMeter`, `ZEcosystemMark`) they use `font-mono`, which on the base is Tailwind's system mono stack
87
+ (`ui-monospace, …`) — the product's, if it sets `--font-mono`. `ZTokenReveal`'s warning is Nuxt UI's outline alert,
88
+ unstriped. `../../apps/base` is the base in a product with its own look, and its tests hold all of this.
89
+
90
+ ## Per-section accent (`data-accent`)
91
+
92
+ A product can paint each section in its own hue: `data-accent="teal"` on a container, and everything inside reads
93
+ six **roles** instead of a fixed color. The base defines the roles; the **product supplies the hues**.
94
+
95
+ | Role | For | Light | Dark |
96
+ | --- | --- | --- | --- |
97
+ | `--accent` | the solid: an icon tile, a band's rule, a colored edge | `--a-600` | `--a-400` |
98
+ | `--accent-on` | text or an icon on the solid | white | `--a-950` |
99
+ | `--accent-strong` | titles and labels in the accent | `--a-800` | `--a-200` |
100
+ | `--accent-soft` | a band or panel tint | `--a-50` | `--a-500` at 12% |
101
+ | `--accent-muted` | chips | `--a-100` | `--a-500` at 24% |
102
+ | `--accent-line` | a rule or border | `--a-200` | `--a-500` at 40% |
103
+
104
+ A hue is eight stops, `--a-50 … --a-950`, set under `[data-accent='<name>']` in the product's CSS (in `@layer base`
105
+ or unlayered: either wins over the base's rule). They are inputs to the roles, not a palette, so a hue may point one
106
+ elsewhere or set a role outright — a cyan hue can use cyan-500 for its solid and set `--accent-on` to cyan-950.
107
+ Each role carries both modes in one `light-dark()` declaration, so the product writes no `.dark` rules. A name with no
108
+ hue map reads as the product's primary. Components read the roles with arbitrary values (`bg-(--accent)
109
+ text-(--accent-on)`, `border-(--accent-line)`), and the colored-edge wrappers take `color="accent"`: `<ZCard
110
+ color="accent">` inside a section gets that section's edge (the primary outside any section). Overlays portal to
111
+ `<body>`, out of the section, so `ZModal`, `ZSlideover` and `ZDrawer` read the section they are rendered in and put
112
+ its `data-accent` on the overlay's content: a dialog opened from a teal section has a teal edge.
113
+
114
+ ## Mechanisms the base carries
115
+
116
+ **`color-scheme` on the root, for `light-dark()`.** Tailwind 4's production build (Lightning CSS) compiles
117
+ `light-dark()` into variables it defines only where `color-scheme` is declared. color-mode only toggles the `dark`
118
+ class, and Nuxt UI declares `color-scheme` on `<body>` — but `@theme` tokens live on `:root`, so a token like
119
+ `--color-x: light-dark(#fff, #000)` came out empty in production while dev looked right. The base declares
120
+ `:root { color-scheme: light } .dark { color-scheme: dark }`. On a Forest product it changes nothing on the page (the
121
+ Forest app and the starter were compared pixel for pixel, light and dark, before and after); the browser's own page
122
+ scrollbar now follows dark mode.
123
+
124
+ **UFormField labels after hydration.** Nuxt strips `onServerPrefetch` from the client production bundle, but Vue
125
+ counts each component that registers one (every `UIcon` in svg mode) as an async boundary when it hands out
126
+ `useId()` ids. Stripped on the client only, the ids after an icon drift: hydration re-sets a `UInput`'s id while its
127
+ label keeps the server's `for`, and the field loses its name. The base removes `onServerPrefetch` from
128
+ `optimization.treeShake.composables.client.vue` — filtered out of Nuxt's list, so every other composable it
129
+ tree-shakes still is.
130
+
131
+ **Z\* icons in the client bundle.** The icons the `Z*` components render (`ZThemeToggle`'s, `ZTokenReveal`'s) are
132
+ added to the consumer's client icon bundle through `@nuxt/icon`'s `icon:clientBundleIcons` hook, as Nuxt UI adds its
133
+ own — whatever the product's `icon` options, and without touching its list. A product need not list them.
134
+ `scripts/check-icons.test.mjs` holds the layer's list to what `components/` uses. Most of them (sun, moon, monitor,
135
+ triangle-alert, check, circle-check, x, plus, chevron-up, chevron-down) are also Nuxt UI's own default icons,
136
+ which Nuxt UI bundles anyway; `ZRepeatingList`'s pencil and trash-2 and `ZDateField`'s calendar are not, so only the
137
+ layer's registration puts them in the bundle. The base app's tests hold the outcome
138
+ (Z\* icons render with no request for icon data), and a `ZDateField` that mounts in the browser on a page of its own
139
+ (`apps/base/app/pages/date-field-later.vue`) fails that test when `lucide:calendar` is taken out of the list.
140
+
141
+ **Shipping as source.** The package is TypeScript and `.vue`, not built output, and needs nothing from a product:
142
+ Nuxt adds every layer root under `node_modules` to `build.transpile` and transpiles component directories there
143
+ itself, and neither layer has a `server/` directory or module of its own for Nitro to parse, so no `nitro.esbuild`
144
+ setting is needed either. The workspace apps consume it as
145
+ `workspace:*`, which resolves outside `node_modules`; an npm install is the `node_modules` case above.
146
+
147
+ ## Versions
148
+
149
+ | | Minimum | Why |
150
+ | --- | --- | --- |
151
+ | Nuxt | 4.1 | Nuxt UI 4's own floor; the layer's peer range (`^4.1.0`). Tested on 4.5. |
152
+ | Nuxt UI | 4.11 (`~4.11.1`) | The layer's dependency — products do **not** add their own. |
153
+ | Tailwind CSS | 4.3.3 | What Nuxt UI 4.11 depends on; it comes with Nuxt UI, not from the product. |
154
+ | Node | 22 | `engines` (Nuxt UI 4.11 itself needs ≥ 22.12 on the 22 line). |
155
+
156
+ A product on an older Nuxt UI moves to the layer's when it adopts Zoo UI: it removes its own `@nuxt/ui` (and
157
+ `tailwindcss`) and gets 4.11 through the layer. A product on 4.10 moves to 4.11 that way. See [Upgrading Nuxt
158
+ UI](#upgrading-nuxt-ui).
159
+
160
+ ## Colored edges
161
+
162
+ A **3px edge in the surface's color**: on the **left** for inline surfaces (cards) and on the **top** for overlays
163
+ (dialogs, slideovers, drawers). Everything else about the surface — padding, radius, shadow, motion, focus — is
164
+ Nuxt UI's. No color, no edge.
165
+
166
+ | Surface | How | Edge |
167
+ | --- | --- | --- |
168
+ | Card | `<ZCard color="…">` | left |
169
+ | Dialog | `<ZModal color="…">` | top |
170
+ | Side drawer | `<ZSlideover color="…">` | top |
171
+ | Bottom drawer | `<ZDrawer color="…">` | top |
172
+
173
+ Only `UToast` has a `color` of its own, so these four get a thin `Z*` wrapper (`components/`) that adds
174
+ `color` and passes every other prop, `v-model`, event and slot straight through to the Nuxt UI component —
175
+ tests hold each overlay to its Nuxt UI behavior (focus, Escape, focus return). Colors are the semantic ones
176
+ (`primary` … `neutral`), so edges follow the product's palette and switch shade in dark mode on their own — plus
177
+ `accent`, the section's [`data-accent`](#per-section-accent-data-accent) color. Forest adds the same edge to toasts
178
+ and striped alert banners: [Forest's colored edges](https://github.com/zooui-dev/zooui/blob/main/packages/theme-forest/README.md#colored-edges).
179
+
180
+ ## Components
181
+
182
+ For what Nuxt UI has no equivalent of — built on Nuxt UI's tokens, so a product's palette, a theme's schemes and
183
+ dark mode carry through them as they do through Nuxt UI's own components. Inks that carry text use the 700 shade in
184
+ light mode and 300 in dark, so they clear 4.5:1 on every Forest scheme (Nuxt UI's 500 does not, on Teal or Slate · Cobalt).
185
+
186
+ | Component | What it is |
187
+ | --- | --- |
188
+ | `<ZKicker variant="bracket \| eyebrow">` | The mono label over a section: `[ DEPLOYMENTS ]`, brackets in the primary (default); `eyebrow` is the label itself in the accent ink, no brackets |
189
+ | `<ZIdentifier kind="package \| version \| hash \| plain">` | A value set in the mono face, on a chip except `plain`; `version` in the accent |
190
+ | `<ZStatus state="healthy \| warn \| suspended \| unreachable \| quiet" pill? glow?>` | Status by **shape** (circle, triangle, square, dashed ring, hollow ring), so it survives grayscale; color only reinforces it. `glow` lights the healthy dot with a soft 12px glow in its own color; the other states stay unlit |
191
+ | `<ZSlots :slots="[{ label, available, title? }]" label size?>` | One **named** chip per slot of capacity, as a labeled list: open slots a solid primary badge ("slot 1 · free"), held ones an outline neutral badge saying what holds them ("slot 2 · build 4812"). Nuxt UI's `UBadge` (in the mono face on the theme) |
192
+ | `<ZQuotaMeter :used :quota unit warn-at?>` | Usage against a limit: a `meter`, amber from the mark, red and hatched over |
193
+ | `<ZCodeBlock variant="inline \| line \| block" code token? lang?>` | The code surface — near-black in both themes — with a copy button; `token` marks the secret. The copy result is announced (`role="status"`), a refused copy says so, and `@copy` fires only on success |
194
+ | `<ZTokenReveal token name? require-ack? ack-label? title?>` | The shown-once secret: the token on the code surface (copy, one-click select) under a `[ token · name · shown once ]` kicker, with a warning banner (`UAlert` outline; the default slot is its text). `require-ack` adds a button that blurs the secret and makes it inert; `@copy`, `@ack`, `#actions` |
195
+ | `<ZEcosystemMark ecosystem size? with-label? disabled? label? monogram? shape?>` | A package manager as a two-letter mono tile, told apart by **corner shape**, not brand color (npm square, NuGet circle, winget one round corner …); dashed when `disabled`. Named for assistive tech by its label. Six known ecosystems (`components/ecosystems.ts`); any other is drawn from `label`/`monogram`/`shape` (`square`, `circle`, `leaf`, `arch`, `lens`, `drop`, `rounded`) |
196
+ | `<ZThemeToggle>` | Light / dark / system as Nuxt UI buttons; `useZooTheme()` is the same over color-mode |
197
+ | `<ZRepeatingList v-model item-label :new-row row-key? min? max? errors? compact?>` | A generic (`T`) list editor: rows of the caller's fields in `#row`, Add under them and Remove on each, an optional folded `#summary` that opens on an error, focus into a new row, and the count change announced — [below](#zrepeatinglist) |
198
+ | `<ZNumberInput v-model unit? step? min? max? spin? calc? prefix? suffix? min-fraction-digits? max-fraction-digits? freeform? currency? locale?>` | One number input for money, percent, count and hours, formatting as it is typed for the locale: unit marks in fixed slots so a column lines up, its own chevrons and arrow keys moving by `step` from the current value, clamped and rounded on commit, a `calc` mode for `+ - * /`, decimal arithmetic, the caller's string, number or `Decimal` handed back. [Below](#znumberinput) |
199
+ | `<ZDateField v-model format? locale? clearable? placeholder? size? icon? calendar-icon? highlight? portal? clear-label? choose-label?>` | A calendar-day field: a `Temporal.PlainDate` v-model, typed entry (`5`, `0512`, `5/12/26`), shortcut keys, a `UPopover` + `UCalendar` picker; `@date-update` when a date settles, `@clear`, `@icon-click`, exposed `focus()`. [Below](#zdatefield) |
200
+
201
+ The colored-edge wrappers (`ZCard`, `ZModal`, `ZSlideover`, `ZDrawer`) are above. Everything else is Nuxt UI's
202
+ own component: `UAlert variant="outline"` is the banner, `UTable` the table, `UTabs` the segmented control.
203
+
204
+ **Select "none" (`utils/select-none.ts`, auto-imported).** reka-ui, under `USelect` and `USelectMenu`, throws during render
205
+ on a `SelectItem` with `value=""`, so an explicit "None" option holds `SELECT_NONE` (`'__none__'`) and is translated back
206
+ at the edge: `selectNoneToUndefined(v)` (a create), `selectNoneToNull(v)` (an update that clears the field) and
207
+ `emptyToSelectNone(v)` (the value to show for one that may be absent). The names are safe as globals, unlike a bare
208
+ `NONE` or `orNull`. Tested by `scripts/select-none.test.mjs`.
209
+
210
+ **The current-page marker.** On the theme (`@zooui/theme-forest`'s `app.config.ts`; the base leaves `UNavigationMenu` as
211
+ Nuxt UI ships it), where a `UNavigationMenu` asks for Nuxt UI's `highlight`, the bar's thickness and the current
212
+ item's weight read `--nav-highlight-size` and `--nav-current-weight`. A product sets them in its own CSS (say `2px` and
213
+ `700`); unset, they fall back to exactly what Nuxt UI ships (1px, medium), so no menu changes until it does.
214
+ `variant="link" color="neutral" highlight highlight-color="primary"` gives no pill, the current page a neutral label
215
+ over a primary underline (`highlight-color` must be named: unset, Nuxt UI takes it from `color`, and the bar goes
216
+ neutral).
217
+
218
+ ### ZRepeatingList
219
+
220
+ ```vue
221
+ <ZRepeatingList v-model="sources" item-label="referral source" :new-row="() => ({ name: '' })" :row-key="(s) => s.id" :errors="errors">
222
+ <template #row="{ row, errorId }"><UFormField label="Name"><UInput v-model="row.name" :aria-describedby="errorId" /></UFormField></template>
223
+ <template #summary="{ row }">{{ row.name }}</template>
224
+ </ZRepeatingList>
225
+ ```
226
+
227
+ Generic over the row type (`T extends object`), so `row` in `#row` and `#summary` is the list's own type. Rows are
228
+ told apart by `rowKey`, or by object identity for rows without one. `min` rows are always on screen (Remove hides at
229
+ it); at `max` Add is disabled and `max-label` says so. `errors` is keyed by row key; a row's message is a
230
+ `role="alert"` under it, and its id reaches the slot as `errorId`. With `#summary`, rows present at mount fold to one
231
+ line with Edit; new rows and rows with an error are open. `compact` is one line per row with an icon-only Remove.
232
+ Focus goes to the first `focus-selector` match in an added or opened row, and to Add after a remove; a polite live
233
+ region announces each add and remove. The words are props: `add-label`, `remove-label`, `edit-label`, `max-label`,
234
+ `row-title`, `announce`. The list carries `data-testid="repeating-list"` and each row `data-row`, for e2e selectors.
235
+
236
+ ### ZDateField
237
+
238
+ The date field (`components/DateField.vue`), with its parser (`utils/date-entry.ts`) and `useToday()`. The model is
239
+ a `Temporal.PlainDate` or `null`, the same type a `date` column comes back as, and **no JavaScript `Date` is made
240
+ anywhere**: a `Date` is an instant, and every conversion to a day goes through a time zone. The calendar's `CalendarDate`
241
+ is converted by its fields alone.
242
+
243
+ ```vue
244
+ <UFormField label="Ends"><ZDateField v-model="form.endDate" clearable class="w-full" /></UFormField>
245
+ <ZDateField v-model="due" locale="de" /> <!-- DD.MM.YYYY, a German calendar -->
246
+ <ZDateField v-model="due" format="YYYY-MM-DD" />
247
+ ```
248
+
249
+ - **Typing**, in MM/DD/YYYY: `5` or `12` is that day this month, `0512` May 12, `051226`, `5/12/26` and `5/12/2026`
250
+ carry the year (a two-digit year lands within 20 years ahead and 79 behind; a four-digit one must be 1000 or later).
251
+ A year of all zeros is not a date: `5/12/0`, `5/12/00` and `051200` clear the field rather
252
+ than land on 2000. Other formats read the same shapes in their own order. Enter, Tab or leaving commits; text that
253
+ isn't a date clears the field; untouched text keeps its date, even one it couldn't read back (a stored year before
254
+ 1000).
255
+ - **Shortcut keys**: `t` today; `m`/`h` first and last of the month, `y`/`r` of the year (again to keep walking); `+`
256
+ or `=` the next day, `-` or `_` the day before. The format's separator is never a shortcut, so in `YYYY-MM-DD`, `-`
257
+ types a dash and `_` is the day before. Alt+↓ opens the calendar. Shortcuts stop at 1000-01-01 and 9999-12-31.
258
+ - **Format and locale.** `format` is a pattern of `MM`, `DD` and `YYYY` in month-day-year, day-month-year or
259
+ year-month-day order with one separator: `MM/DD/YYYY`, `DD/MM/YYYY`, `DD.MM.YYYY`, `YYYY-MM-DD` …
260
+ `locale` is the calendar's language. **By default** the locale is Nuxt UI's (`<UApp :locale>`,
261
+ `en` unless set) and the format is that locale's own numeric order (`dateEntryFormatFor`: `en` → `MM/DD/YYYY`,
262
+ `en-GB` → `DD/MM/YYYY`, `de` → `DD.MM.YYYY`, `sv` → `YYYY-MM-DD`), so a product on `en` gets `MM/DD/YYYY` with
263
+ no props. The placeholder is the pattern. The two buttons are named by `clear-label` and `choose-label` (English
264
+ by default) for a product in another language.
265
+ - **`@date-update`** fires once per settle (picked, cleared, a shortcut, Enter, or focus leaving for somewhere other
266
+ than its own calendar) and always carries the date just settled, even before a parent-owned v-model has caught up:
267
+ the moment an inline editor should save.
268
+ - **Icons.** `icon` puts a leading icon in the field, and a click on it emits
269
+ **`@icon-click`** with the `MouseEvent` (the field's own handling is untouched: the click still blurs the input, so
270
+ a typed date settles first). `calendar-icon` replaces the calendar button's icon (`i-lucide-calendar` by default).
271
+ The layer bundles only its default; an icon a product passes is the product's to bundle (its `icon.clientBundle`) or
272
+ to serve from its icon endpoint.
273
+ - **The calendar** heads its columns with the locale's narrow weekdays (`S M T W T F S` in `en`, `M D M D F S S` in
274
+ `de`).
275
+ - **Today** is `useToday()`: the browser's day, in the browser's time zone, client-only (it throws on the server,
276
+ where the zone is the server's). Server code that needs the business's today wants
277
+ `Temporal.Now.plainDateISO(companyZone)` instead.
278
+ - **Look.** Nuxt UI's `UInput` and `UCalendar` in the product's colors; while the calendar is open the field takes
279
+ Nuxt UI's `highlight` ring. The placeholder keeps the input's own ink: a product that wants it darker (its own
280
+ placeholder color token) passes `:ui="{ base: 'placeholder:…' }"` or sets it on `ui.input` in `app.config`.
281
+
282
+ **The parser** is framework-free TypeScript, auto-imported in a product and importable anywhere as
283
+ `@zooui/nuxt/date-entry` (a server route, a domain package): `parseDateEntry`, `formatDateEntry`, `commitDateEntry`,
284
+ `applyDateShortcut`, `dateEntryFormat`, `dateEntryFormatFor`, `entryDay`, `US_DATE_ENTRY`, `FIRST_ENTRY_DATE`,
285
+ `LAST_ENTRY_DATE`. Each takes "today" from its caller and the format last (default `MM/DD/YYYY`), so a call that
286
+ relies on the default reads the same. Its tests are `scripts/date-entry.test.mjs` (`node:test`, every format).
287
+
288
+ **Temporal** is `temporal-polyfill`'s `/implementation` entry (^1.0.5), never the bare entry, which becomes the
289
+ engine's own `Temporal` where one exists. A product builds its `PlainDate`s from the same subpath, so there is one
290
+ class; a product that already installs `temporal-polyfill` imports from that subpath too, and one that doesn't adds
291
+ it.
292
+
293
+ ### ZNumberInput
294
+
295
+ One number input, so every figure looks and moves the same, formatting as it is typed. It is Nuxt UI's `UInput` (`type="text"`, `inputmode="decimal"`): every other attribute, `size`,
296
+ `color`, `highlight`, `disabled`, `readonly`, `ui`, `aria-*`, falls through to it, the marks and chevrons sit in its
297
+ `leading` and `trailing` slots, and calc's preview in its default slot. It is on Nuxt UI's tokens: marks and chevrons
298
+ in `text-dimmed`, hover `text-default`, the preview `bg-inverted`/`text-inverted`.
299
+
300
+ | Prop | | |
301
+ | --- | --- | --- |
302
+ | `modelValue` | `string \| number \| Decimal \| null` | Every change hands back the caller's kind: a string stays a string (as typed: `"1.0"` on the way to `"1.05"`; written to the places on commit, `"1234.50"`), a number a number, a decimal.js `Decimal` a `Decimal` of the caller's own class. Cleared: `''` for a string, `null` otherwise. Strings and Decimals never pass through a float |
303
+ | `modelType` | `'string' \| 'number' \| 'decimal'` | The kind to hand back when the model starts empty (it has no value to take a kind from). A `Decimal` v-model that can start null needs `model-type="decimal"`; without it, empty starts as a string |
304
+ | `unit` | `money \| percent \| count \| hours` | `count` by default. Money puts the currency symbol on the left; percent `%` and hours `hrs` on the right, in a slot kept the same width when empty, so values end on one edge |
305
+ | `locale`, `currency` | BCP 47, ISO 4217 | The grouping and decimal marks typed and shown (`de`: `1.234,56`), the money symbol, and the chevrons' labels ("Add $5,000", "Subtract 0.5 hours") |
306
+ | `minFractionDigits`, `maxFractionDigits` | `number` | Decimal places: the minimum written on commit, the maximum rounded to on commit and the most that can be typed. Money is `2`/`2`; every other unit `0`/none (as typed). A minimum above an explicit maximum comes down to it |
307
+ | `min`, `max` | `number \| string` | Clamp a nudge and a commit. Out of range otherwise (between keystrokes, or a model that arrives so) the field is `:invalid` (`setCustomValidity`), following the model as a parent changes it; a minus can't be typed where `min` is 0 or more |
308
+ | `step` | `number` | What the chevrons and ArrowUp/ArrowDown add, from the current value, never snapped to a multiple |
309
+ | `spin` | `boolean` | `true` by default. `false`: no chevrons, ArrowUp/ArrowDown do nothing, and the field is a plain text box rather than a `spinbutton` |
310
+ | `prefix`, `suffix` | `string` | Free text beside the marks: `prefix="~"` shows `~$`, `suffix="/mo"` shows `/mo` after the value. Kept out of the text, in the mark slots, which grow to fit |
311
+ | `highlightOnFocus` | `boolean` | Select the whole value on focus, by click or key (on by default in `calc`) |
312
+ | `calc` | `boolean` | Take `+ - * /` expressions ([below](#calc)) |
313
+ | `commitOnBlur` | `boolean` | `true` by default. `false` for a grid editor that commits itself with `evaluate()` |
314
+ | `freeform` | `boolean` | A text box that takes "$125,000" or "24 %" as typed and hands the text back as it is, for a product that tidies it itself; the arrows read the figure out of it (in the field's locale) and leave anything else ("forty") untouched. No live formatting, clamping or rounding |
315
+
316
+ Emits `update:modelValue`; no slots. Exposes `evaluate()`, which commits what is typed and returns the model's value,
317
+ and `inputRef`. Keeps `data-number-input` on the `<input>` (and adds `data-unit`), `data-number-mark` on the
318
+ marks, and the chevrons' labels.
319
+
320
+ **Typing.** Each keystroke, paste and deletion is worked out before the browser applies it (`beforeinput`): the
321
+ locale's grouping comes and goes (`12,345`), the caret stays on its digit, one decimal mark, a minus only at the
322
+ front, no leading zeros. Backspace or Delete over a separator takes the digit beyond it; a fixed decimal mark is
323
+ stepped over rather than deleted; typed into a full fraction, a digit overwrites the next; typed before a minus, a
324
+ digit goes after it. A key that would add nothing (a letter, a second decimal mark, a minus where none may go) is
325
+ refused, and leaves a selection selected. A paste keeps the figure's digits (`$1,234.50` arrives as `1,234.50`).
326
+ Anything else (an IME, undo, autofill) is tidied after it lands, and keys an IME is composing with are left to it.
327
+ The model follows the typing; a **commit** (blur, Enter, Tab, or a nudge, by key or chevron alike: a chevron doesn't
328
+ take the focus) rounds to the places (half away from zero, in decimal.js), keeps the result within `min`/`max`, and
329
+ shows the value in full (`38,500.00`). A rounded value past a bound becomes the nearest value inside it that the
330
+ places can write (`max="1.235"` at two places commits `1.23`, never `1.24`); if the places can write none (`min` 0.004,
331
+ `max` 0.006, two places), the bound itself is kept.
332
+
333
+ **Marks.** The currency symbol and `prefix` stay to the left of the text and `%`, `hrs` and `suffix` to the right,
334
+ in the input's own padding, so a column of values still ends on one edge and typing only ever meets digits. A
335
+ locale that writes its symbol after the number (`de`: `1.234,56 €`) still shows `€` on the left, with the money.
336
+
337
+ **Accessibility.** While it spins the input is a `spinbutton` with `aria-valuemin`, `aria-valuemax`, `aria-valuenow`
338
+ and an `aria-valuetext` with its marks ("$38,500.00"); the chevrons are named buttons, out of the tab order (the
339
+ arrow keys do the same). With `:spin="false"` it is a plain text box.
340
+
341
+ #### Calc
342
+
343
+ `calc` makes the field a small calculator: `+ - * /` with the usual precedence, read by a small
344
+ recursive-descent parser (never `eval`) and worked in decimal.js, so `0.1+0.2` is `0.3`.
345
+ Each number is grouped as it is typed, for the locale, keeping the caret. While focused, the result shows under the
346
+ field (`= $1,250.00`, with the unit's marks), absolutely placed in `UInput`'s slot so nothing moves, and announced
347
+ politely. Enter, Tab or blur (unless `:commit-on-blur="false"`) puts it in, rounded and kept in range like any commit.
348
+ The result is rounded once, at the field's places (ten where the field has no maximum), so a sum is never
349
+ rounded twice: whole dollars only is `calc :max-fraction-digits="0"`. A line break in a paste is a space. Incomplete or invalid input (`678+`, `abc`) or a division
350
+ by zero gives no value. An operator typed over a selection is added at the end (the value is
351
+ selected on focus, so `+50` adds to it), except a minus over everything, which starts a negative number. A grid
352
+ cell editor:
353
+
354
+ ```vue
355
+ <ZNumberInput ref="cell" v-model="value" unit="money" calc :spin="false" :commit-on-blur="false" />
356
+ <!-- on Enter, Tab or an arrow: cell.value.evaluate(), then move -->
357
+ ```
358
+
359
+ **Defaults, and a product's own.** Without props: money moves by 1, percent and count by 1, hours by 0.5, in US
360
+ dollars, `en-US` (fixed, so the server and the browser render the same text), money to 2 places. A product sets its
361
+ own once in its `app.config.ts`; a prop still wins. A product's own $5,000 step:
362
+
363
+ ```ts
364
+ export default defineAppConfig({ zooui: { numberInput: { steps: { money: 5000 } } } })
365
+ // also: currency, locale, fractionDigits: { money: { min: 0, max: 0 } }
366
+ ```
367
+
368
+ **Decimal.** A database client may return Postgres `numeric` as decimal.js `Decimal`s, and a schema may check
369
+ `instanceof Decimal`. ZNumberInput recognizes a `Decimal` with `Decimal.isDecimal` (which knows another copy's
370
+ instances too), reads it from its string, and builds every value it hands back with the caller's own class, so
371
+ `instanceof` holds even with two copies installed. A `Decimal.clone()` comes back the clone, with its precision, and
372
+ a subclass (`class Money extends Decimal`) comes back a subclass: decimal.js writes the class it extends onto each
373
+ instance, so for a subclass the class is read from the instance's prototype instead. The layer depends on decimal.js
374
+ `^10.6.0`, so a product that also installs decimal.js itself gets one copy: keep the product's own range compatible
375
+ with it.
376
+
377
+ **Where it lives.** The component is thin; the rules are pure TypeScript beside it: `number-format.ts` (the locale's
378
+ marks, live formatting and the caret, commits, the caller's kind of value), `number-calc.ts` (the evaluator and
379
+ expression editing) and `number-input.ts` (config, labels, nudges, freeform reading). Their tests are
380
+ `scripts/number-input.test.mjs` and `scripts/number-calc.test.mjs`.
381
+
382
+ ## The guards every product runs
383
+
384
+ One check ships with the base layer, for any page's Playwright test (it runs inside the page):
385
+
386
+ ```ts
387
+ import { findConflicts } from '@zooui/nuxt/testing/find-conflicts'
388
+
389
+ expect(await page.evaluate(findConflicts)).toEqual([]) // no element with two same-property utilities
390
+ ```
391
+
392
+ ## The tests
393
+
394
+ `../../apps/base/tests/base.spec.ts` holds the base alone, in a product with its own look (its own palette, typefaces,
395
+ color-mode key, CSS and accent map), against its production build: none of Forest's colors, ramps, typefaces,
396
+ ground or restyling arrive; the color-mode key and default stay the product's and no `data-theme` is written;
397
+ every Z\* component paints in the product's colors in both modes, and `font-mono` falls back to the system mono
398
+ stack; the product's `@theme` tokens, `@utility` and `@layer base` rules work after `base.css`; `light-dark()`
399
+ tokens resolve in both modes in the compiled CSS; a `data-accent` hue map paints the roles and `ZCard
400
+ color="accent"` in both modes; `UFormField` labels still name their inputs after hydration; and Z\* icons render
401
+ with no request for icon data.
402
+
403
+ Forest's own tests, which also run every `Z*` component on every scheme, are in
404
+ [its README](https://github.com/zooui-dev/zooui/blob/main/packages/theme-forest/README.md#the-tests-prove-color-only).
405
+
406
+ ## Open — decide one at a time
407
+
408
+ **Corners.** Nuxt UI's `--ui-radius` (4px base) is close to the design source's `tight` corners; its
409
+ `soft`/`tight`/`flat` dial is not carried into Nuxt. A product that wants squarer corners sets `--ui-radius` itself.
410
+
411
+ ## Releasing
412
+
413
+ Both layers, `@zooui/nuxt` and `@zooui/theme-forest`, release to the public npm registry
414
+ (`publishConfig.access: public`) through **shiprig**. Neither has been published yet. The theme
415
+ ships no font files of its own.
416
+
417
+ 1. **In each PR with a user-facing change**, record it: `changerig add -t fix -p @zooui/nuxt -m "…"` (or `-p @zooui/theme-forest`)
418
+ (`feat` for features). The entry is written for the changelog's reader, and links its commit and PR.
419
+ 2. **To release: merge the release PR, approve the publish run, done.** shiprig's action
420
+ (`.github/workflows/release.yml`, `rigsmith/shiprig-action`, settings in `.github/shiprig-action.jsonc`) works the
421
+ way release-please does, on every push to `main` of zooui-dev/zooui (anywhere else it does nothing):
422
+ - With changesets pending, it keeps a standing **release PR** (`chore: release …`) up to date: `shiprig version`
423
+ bumps the versions and writes each package's `CHANGELOG.md`. This needs no approval and no secret.
424
+ - Merge that PR, and the run for the merge has something to publish: its **Publish** job waits for approval in
425
+ the protected `release` environment. Approve it (the run's page → Review deployments). It checks every package
426
+ it would publish has a `## <version>` entry in its `CHANGELOG.md` (the GitHub release is made from it) and stops
427
+ with nothing published if one doesn't, then `shiprig publish` packs each layer with pnpm (which rewrites the
428
+ theme's `workspace:*` dependency on the base to the exact version) and npm publishes it with provenance. It
429
+ pushes the tags and makes a GitHub release per package from its changelog entry.
430
+ - Any other push does nothing.
431
+ - **Rehearse** any time: Actions → **Release** → Run workflow, with `dry_run` ticked (the default). It shows the
432
+ release PR it would open or what it would publish, with no approval and no secret, and changes nothing. With
433
+ `dry_run` unticked, a manual run does what a push does: the way to retry a publish that failed or was rejected.
434
+ - **Locally**, `shiprig release --dry-run` previews the whole pipeline (`.changeset/release.jsonc`). A real local
435
+ publish is refused: `node.provenance` is `"always"` (`.changeset/config.json`), and npm provenance can only be
436
+ made in GitHub Actions.
437
+ 3. **Design source changes** (`packages/theme-forest/design/`) are `@zooui/theme-forest` changes: record them with
438
+ `changerig add -p @zooui/theme-forest`. Like any change to `@zooui/theme-forest`, it is recorded in the theme's changeset and appears in the theme's changelog.
439
+
440
+ Don't edit the version or changelog by hand, and don't `pnpm publish` directly: `changerig` owns both (0.1.0, below, was the one exception).
441
+
442
+ ### The first release, 0.1.0
443
+
444
+ Both layers are already at `0.1.0` and have never been published, and the public repository starts with no
445
+ changesets and empty changelogs. `releaseAs` in `.github/shiprig-action.jsonc` names each at `0.1.0`, which makes
446
+ every push open a `chore: release 0.1.0` PR anyway. npm trusted publishing can only be set up for a package that
447
+ already exists, and npm no longer issues tokens a CI publish can use, so 0.1.0 is published by hand and the workflow
448
+ takes over from there. Once, in zooui-dev/zooui:
449
+
450
+ 1. **The `release` environment.** Settings → Environments → New environment, named `release`, with **Required
451
+ reviewers** (John). Only the Publish job runs in it, so only a real release waits for that approval.
452
+ 2. **Let workflows open PRs.** Settings → Actions → General → Workflow permissions: tick **Allow GitHub Actions to
453
+ create and approve pull requests**, or the action can't open the release PR. (In an organization that forbids
454
+ it, allow it at the organization first.)
455
+ 3. **Push `main`.** The push opens `chore: release 0.1.0`, in which
456
+ `shiprig version --release-as @zooui/nuxt=0.1.0 --release-as @zooui/theme-forest=0.1.0` writes each package's
457
+ `## 0.1.0` changelog entry ("Initial release") and changes no version. Don't merge it yet.
458
+ 4. **Publish 0.1.0 by hand**, from a clean checkout of that `main`, logged in to npm as an owner of the `@zooui`
459
+ scope: `pnpm publish -r --access public`. pnpm publishes the base before the theme and rewrites the theme's
460
+ `workspace:*` dependency to `0.1.0`. This is the only publish that isn't the workflow's.
461
+ 5. **Trusted publishing.** On npmjs.com, each package → Settings → Trusted publishing → GitHub Actions: repository
462
+ `zooui-dev/zooui`, workflow `release.yml`, environment `release`. Do both packages.
463
+ 6. **Merge the release PR.** A PR the default token opens doesn't start its own checks: approve them on the PR
464
+ (**Approve workflows to run**) first. The merge's run waits for approval in `release`; approve it. It finds 0.1.0
465
+ already on npm and skips the publish, then pushes the `@zooui/nuxt@0.1.0` and `@zooui/theme-forest@0.1.0` tags
466
+ and makes their GitHub releases. Every later release publishes from the workflow with the run's OIDC token.
467
+
468
+ The `releaseAs` entries can stay: once a package has its `## 0.1.0` entry and tag, the action skips them.
469
+
470
+ ### Upgrading Nuxt UI
471
+
472
+ The layer depends on `@nuxt/ui` with a **tilde** range (`~4.11.1`): patches arrive by themselves, minors don't.
473
+ The `apps/forest` tests pin Nuxt UI's measured geometry, so a Nuxt UI minor can change what the layer delivers, and
474
+ a caret range would let products resolve a version the tests never saw. A minor is a deliberate upgrade of the
475
+ layer: bump `@nuxt/ui` here and in `apps/kitchen-sink/package.json` (the baseline, always the same range), run the
476
+ `apps/forest` suite against the kitchen sink, record it with `changerig add`, and release.
@@ -0,0 +1,57 @@
1
+ /* Zoo UI's BASE stylesheet: Tailwind, Nuxt UI, the Z* components' sources, and the few mechanisms every product needs
2
+ whatever it looks like. No colors, typefaces or ground — those are a theme's (Forest's theme.css, and forest.css for the two together).
3
+ A product with its own look imports this as the first line of its one Tailwind entry and adds its own @theme
4
+ tokens, @utility rules and @layer base rules after it. */
5
+ @import "tailwindcss";
6
+ @import "@nuxt/ui";
7
+
8
+ /* The layer's components live outside any app's root, so the layer declares their source — otherwise an app sees
9
+ the components but not their styles. */
10
+ @source "../../components";
11
+
12
+ /* Zoo UI's hatch: diagonal stripes in currentColor, so whatever sets the text color sets the stripe. ZQuotaMeter's
13
+ over-limit fill, and the theme's striped alert edge. Same pattern as core's --hatch. */
14
+ @utility hatch {
15
+ background-image: repeating-linear-gradient(135deg, transparent 0 3px, currentColor 3px 4px);
16
+ }
17
+
18
+ @layer base {
19
+ /* `color-scheme` on the root, for light-dark(). color-mode only toggles the `dark` class, and Nuxt UI declares
20
+ color-scheme on <body> — but tokens are declared on :root, and a production build (Lightning CSS) compiles
21
+ light-dark() into variables it defines only where color-scheme is declared. Without these two rules a token
22
+ like `--color-x: light-dark(#fff, #000)` resolves to nothing in production while dev looks right. On the page
23
+ itself they change nothing (body already carries the same scheme); the browser's page scrollbar follows dark
24
+ mode. */
25
+ :root { color-scheme: light; }
26
+ .dark { color-scheme: dark; }
27
+
28
+ /* Per-section accent, `data-accent`. A container names a hue (`<main data-accent="teal">`) and everything in it
29
+ paints with six ROLES instead of a hard-coded hue — the contract components read:
30
+ --accent solid: an icon tile, a band's rule, a colored edge
31
+ --accent-on text or icon on the solid
32
+ --accent-strong titles and labels in the accent
33
+ --accent-soft a band or panel tint
34
+ --accent-muted chips
35
+ --accent-line a rule or border in the accent
36
+ Each role carries its light and dark value in one declaration (light-dark(), hence color-scheme above).
37
+ The PRODUCT supplies the hues: for each name, eight stops `--a-50 … --a-950` (inputs to the roles below; a hue
38
+ may point a stop elsewhere, as a cyan hue might set --a-600 to cyan-500), or a role outright. Until it does, the
39
+ stops are Nuxt UI's primary, so an unmapped name still reads as the product's brand rather than as nothing.
40
+ Hue rules have this rule's specificity and come after it, so they win in @layer base or unlayered. */
41
+ [data-accent] {
42
+ --a-50: var(--ui-color-primary-50);
43
+ --a-100: var(--ui-color-primary-100);
44
+ --a-200: var(--ui-color-primary-200);
45
+ --a-400: var(--ui-color-primary-400);
46
+ --a-500: var(--ui-color-primary-500);
47
+ --a-600: var(--ui-color-primary-600);
48
+ --a-800: var(--ui-color-primary-800);
49
+ --a-950: var(--ui-color-primary-950);
50
+ --accent: light-dark(var(--a-600), var(--a-400));
51
+ --accent-on: light-dark(#fff, var(--a-950));
52
+ --accent-strong: light-dark(var(--a-800), var(--a-200));
53
+ --accent-soft: light-dark(var(--a-50), color-mix(in oklab, var(--a-500) 12%, transparent));
54
+ --accent-muted: light-dark(var(--a-100), color-mix(in oklab, var(--a-500) 24%, transparent));
55
+ --accent-line: light-dark(var(--a-200), color-mix(in oklab, var(--a-500) 40%, transparent));
56
+ }
57
+ }
@@ -0,0 +1,20 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * UCard with Zoo UI's colored edge: card — a left edge, like Zoo UI's callout. Only `color` is added — every
4
+ * other prop, `v-model`, event and slot passes straight through to Nuxt UI's UCard, so its behavior and
5
+ * polish are untouched. No `color`, no edge: a plain UCard.
6
+ */
7
+ import { edge, withEdge, type EdgeColor } from './edge'
8
+
9
+ defineOptions({ inheritAttrs: false })
10
+ const props = defineProps<{ color?: EdgeColor; ui?: Record<string, any> }>()
11
+ const ui = computed(() => withEdge(props.ui, 'root', edge('left', props.color)))
12
+ </script>
13
+
14
+ <template>
15
+ <UCard v-bind="$attrs" :ui="ui">
16
+ <template v-for="(_, name) in $slots" #[name]="scope">
17
+ <slot :name="name" v-bind="scope ?? {}" />
18
+ </template>
19
+ </UCard>
20
+ </template>