@zooui/nuxt 0.1.0 → 0.1.1
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/README.md +50 -439
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,473 +4,84 @@ Zoo UI's theme-free Nuxt layer: **Nuxt UI exactly as it ships**, Zoo UI's `Z*` c
|
|
|
4
4
|
equivalent of, colored-edge surfaces, and the mechanisms every product needs. It has no look of its own: everything
|
|
5
5
|
is written on Nuxt UI's semantic tokens, so it takes the product's colors, typefaces and color-mode key.
|
|
6
6
|
|
|
7
|
-
For a ready-made look, extend a theme layer instead
|
|
8
|
-
extends this layer with its colors, ground, typefaces and schemes.
|
|
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
|
-
```
|
|
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.
|
|
17
9
|
|
|
18
10
|
## Using it
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
```bash
|
|
13
|
+
pnpm add @zooui/nuxt
|
|
14
|
+
```
|
|
22
15
|
|
|
23
16
|
```ts
|
|
24
|
-
// nuxt.config.ts
|
|
17
|
+
// nuxt.config.ts
|
|
25
18
|
export default defineNuxtConfig({
|
|
26
19
|
extends: ['@zooui/nuxt'],
|
|
27
20
|
css: ['~/assets/css/main.css'],
|
|
28
21
|
colorMode: { preference: 'light', fallback: 'light', storageKey: 'product-color-mode' },
|
|
29
|
-
icon: { mode: 'svg', clientBundle: { scan: true, icons: [/* the app's own */] } },
|
|
30
22
|
})
|
|
31
23
|
```
|
|
32
24
|
|
|
33
25
|
```css
|
|
34
26
|
/* app/assets/css/main.css — the app's one Tailwind entry */
|
|
35
27
|
@import "@zooui/nuxt/assets/css/base.css";
|
|
36
|
-
@theme
|
|
37
|
-
@utility section-label { /* … */ }
|
|
38
|
-
@layer base { [data-accent='teal'] { --a-600: var(--color-teal-600); /* … */ } }
|
|
28
|
+
/* the product's own @theme tokens, @utility and @layer base rules go after it */
|
|
39
29
|
```
|
|
40
30
|
|
|
41
31
|
The palette goes in the product's `app.config.ts` (`ui.colors: { primary: 'sky', neutral: 'slate', … }`), as with
|
|
42
|
-
plain Nuxt UI.
|
|
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.
|
|
32
|
+
plain Nuxt UI. Three rules:
|
|
123
33
|
|
|
124
|
-
**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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.
|
|
34
|
+
- **One Tailwind entry.** The layer registers Nuxt UI but not the stylesheet, so the app owns its single entry and
|
|
35
|
+
can add `@source` for components outside its root.
|
|
36
|
+
- **No `@nuxt/ui`, `tailwindcss` or `@tailwindcss/vite` in the product.** The layer owns them, and a second
|
|
37
|
+
Tailwind registration fails the build.
|
|
38
|
+
- **Wrap the app in `<UApp>`.** Nuxt UI mounts toasts, tooltips and overlays through it.
|
|
146
39
|
|
|
147
40
|
## Versions
|
|
148
41
|
|
|
149
|
-
| | Minimum |
|
|
42
|
+
| | Minimum | |
|
|
150
43
|
| --- | --- | --- |
|
|
151
|
-
| Nuxt | 4.1 |
|
|
152
|
-
| Nuxt UI | 4.11 (`~4.11.1`) | The layer's dependency
|
|
153
|
-
| Tailwind CSS | 4.3.3 |
|
|
154
|
-
| Node | 22 |
|
|
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).
|
|
44
|
+
| Nuxt | 4.1 | The layer's peer range (`^4.1.0`); tested on 4.5 |
|
|
45
|
+
| Nuxt UI | 4.11 (`~4.11.1`) | The layer's dependency; products don't add their own |
|
|
46
|
+
| Tailwind CSS | 4.3.3 | Comes with Nuxt UI |
|
|
47
|
+
| Node | 22 | Nuxt UI 4.11 needs ≥ 22.12 on the 22 line |
|
|
179
48
|
|
|
180
49
|
## Components
|
|
181
50
|
|
|
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
51
|
| Component | What it is |
|
|
187
52
|
| --- | --- |
|
|
188
|
-
|
|
|
189
|
-
|
|
|
190
|
-
|
|
|
191
|
-
|
|
|
192
|
-
|
|
|
193
|
-
|
|
|
194
|
-
|
|
|
195
|
-
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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`.
|
|
53
|
+
| `ZCard`, `ZModal`, `ZSlideover`, `ZDrawer` | Nuxt UI's surfaces with a `color` that draws a 3px colored edge |
|
|
54
|
+
| `ZKicker` | The mono label over a section: `[ DEPLOYMENTS ]` |
|
|
55
|
+
| `ZIdentifier` | A package, version or hash in the mono face |
|
|
56
|
+
| `ZStatus` | Status by shape, so it survives grayscale |
|
|
57
|
+
| `ZSlots` | One named chip per slot of capacity |
|
|
58
|
+
| `ZQuotaMeter` | Usage against a limit |
|
|
59
|
+
| `ZCodeBlock` | The near-black code surface, with copy |
|
|
60
|
+
| `ZTokenReveal` | A shown-once secret, with a warning and an optional acknowledgement |
|
|
61
|
+
| `ZEcosystemMark` | A package manager as a two-letter tile |
|
|
62
|
+
| `ZThemeToggle` | Light / dark / system |
|
|
63
|
+
| `ZRepeatingList` | A generic list editor |
|
|
64
|
+
| `ZNumberInput` | One number input for money, percent, count and hours, with a calc mode |
|
|
65
|
+
| `ZDateField` | A calendar-day field on `Temporal.PlainDate` |
|
|
66
|
+
|
|
67
|
+
## Docs
|
|
68
|
+
|
|
69
|
+
- [Components](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/components.md): every prop, the select-none helpers and the nav marker
|
|
70
|
+
- [ZRepeatingList](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/repeating-list.md),
|
|
71
|
+
[ZNumberInput](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/number-input.md),
|
|
72
|
+
[ZDateField](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/date-field.md)
|
|
73
|
+
- [The base and a theme](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/base-and-theme.md): what each layer carries, and why they're two layers
|
|
74
|
+
- [Accents and colored edges](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/accents-and-edges.md): `data-accent` sections and the `color` edge
|
|
75
|
+
- [Mechanisms](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/mechanisms.md): `light-dark()`, the hydration label fix, icon bundling, shipping as source
|
|
76
|
+
- [Guards and tests](https://github.com/zooui-dev/zooui/blob/main/packages/nuxt/docs/testing.md)
|
|
77
|
+
- [Releasing](https://github.com/zooui-dev/zooui/blob/main/docs/releasing.md) and [upgrading Nuxt UI](https://github.com/zooui-dev/zooui/blob/main/docs/upgrading-nuxt-ui.md)
|
|
78
|
+
|
|
79
|
+
## Developing
|
|
281
80
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
|
81
|
+
```bash
|
|
82
|
+
pnpm base:dev # → http://localhost:3004 — this layer alone, in a product's own look
|
|
83
|
+
pnpm base:build && pnpm base:test
|
|
84
|
+
pnpm ks:dev # → http://localhost:3003 — the baseline: Nuxt UI as it ships
|
|
390
85
|
```
|
|
391
86
|
|
|
392
|
-
|
|
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.
|
|
87
|
+
`apps/base` is this layer in a product with its own look; `apps/starter` is the smallest product on Forest.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zooui/nuxt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Zoo UI for Nuxt: a theme-free Nuxt layer with Nuxt UI as it ships, Zoo UI's Z* components and colored-edge surfaces, and the mechanisms every product needs, all on Nuxt UI's tokens so they take the product's own colors. Add a theme layer such as @zooui/theme-forest for a ready-made look.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|