@zooui/nuxt 0.0.0-stage → 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/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,87 @@
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.
9
+
10
+ ## Using it
11
+
12
+ ```bash
13
+ pnpm add @zooui/nuxt
14
+ ```
15
+
16
+ ```ts
17
+ // nuxt.config.ts
18
+ export default defineNuxtConfig({
19
+ extends: ['@zooui/nuxt'],
20
+ css: ['~/assets/css/main.css'],
21
+ colorMode: { preference: 'light', fallback: 'light', storageKey: 'product-color-mode' },
22
+ })
23
+ ```
24
+
25
+ ```css
26
+ /* app/assets/css/main.css — the app's one Tailwind entry */
27
+ @import "@zooui/nuxt/assets/css/base.css";
28
+ /* the product's own @theme tokens, @utility and @layer base rules go after it */
29
+ ```
30
+
31
+ The palette goes in the product's `app.config.ts` (`ui.colors: { primary: 'sky', neutral: 'slate', … }`), as with
32
+ plain Nuxt UI. Three rules:
33
+
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.
39
+
40
+ ## Versions
41
+
42
+ | | Minimum | |
43
+ | --- | --- | --- |
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 |
48
+
49
+ ## Components
50
+
51
+ | Component | What it is |
52
+ | --- | --- |
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
80
+
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
85
+ ```
86
+
87
+ `apps/base` is this layer in a product with its own look; `apps/starter` is the smallest product on Forest.
@@ -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>
@@ -0,0 +1,63 @@
1
+ <script setup lang="ts">
2
+ // `code` is imported as `codeCls`: the component has a `code` PROP, and in a
3
+ // <script setup> template the prop shadows the import — the wrapper div would
4
+ // have rendered the user's code string as its class list.
5
+ import { code as codeCls, ident, cx } from "./recipes";
6
+
7
+ const props = withDefaults(defineProps<{
8
+ /** inline = a chip; line = one command with a $ prompt; block = multi-line config */
9
+ variant?: "inline" | "line" | "block";
10
+ code: string;
11
+ /** substring highlighted as the secret */
12
+ token?: string;
13
+ lang?: string;
14
+ /** the block queries its OWN width: under 360px it stops wrapping and scrolls,
15
+ * because a command shredded into 3-character stacks is unreadable at any
16
+ * viewport size */
17
+ wrap?: boolean;
18
+ prompt?: string;
19
+ }>(), { variant: "line", wrap: true, prompt: "$" });
20
+
21
+ /** Only on success: a failed copy must never read as a saved secret. */
22
+ const emit = defineEmits<{ copy: [code: string] }>();
23
+
24
+ const result = ref<"copied" | "failed" | null>(null);
25
+
26
+ /** Split on the token so it can be marked up without injecting HTML — a token
27
+ * containing `<` must not be able to break the page. */
28
+ const parts = computed(() => {
29
+ if (!props.token || !props.code.includes(props.token)) return [{ text: props.code, tok: false }];
30
+ return props.code.split(props.token).flatMap((chunk: string, i: number, all: string[]) =>
31
+ i < all.length - 1
32
+ ? [{ text: chunk, tok: false }, { text: props.token!, tok: true }]
33
+ : [{ text: chunk, tok: false }]);
34
+ });
35
+
36
+ let reset: ReturnType<typeof setTimeout> | undefined;
37
+ async function copy() {
38
+ try {
39
+ await navigator.clipboard.writeText(props.code);
40
+ result.value = "copied";
41
+ emit("copy", props.code);
42
+ } catch {
43
+ // clipboard unavailable or refused: say so, and the token span's select-all leaves a one-click fallback
44
+ result.value = "failed";
45
+ }
46
+ clearTimeout(reset);
47
+ reset = setTimeout(() => (result.value = null), 1600);
48
+ }
49
+ onBeforeUnmount(() => clearTimeout(reset));
50
+ </script>
51
+
52
+ <template>
53
+ <code v-if="variant === 'inline'" :class="cx(ident.base, ident.kind.package)">{{ code }}</code>
54
+
55
+ <div v-else :class="codeCls.wrap">
56
+ <span v-if="variant === 'line' && prompt" :class="codeCls.prompt">{{ prompt }}</span>
57
+ <pre :class="cx(codeCls.pre, wrap ? 'whitespace-pre-wrap break-all @max-[359px]:whitespace-pre @max-[359px]:break-normal' : 'whitespace-pre')"><template v-for="(p, i) in parts" :key="i"><span v-if="p.tok" :class="codeCls.tok">{{ p.text }}</span><template v-else>{{ p.text }}</template></template></pre>
58
+ <span v-if="lang" :class="codeCls.lang">{{ lang }}</span>
59
+ <button type="button" :class="codeCls.copy" :data-done="result === 'copied'" @click="copy">{{ result === "copied" ? "copied" : result === "failed" ? "copy failed" : "copy" }}</button>
60
+ <!-- a changed button label is not announced; this is -->
61
+ <span class="sr-only" role="status">{{ result === "copied" ? "Copied to clipboard" : result === "failed" ? "Couldn't copy — select the text and copy it" : "" }}</span>
62
+ </div>
63
+ </template>
@@ -0,0 +1,312 @@
1
+ <script setup lang="ts">
2
+ // A calendar-day field: type a date, press a shortcut key, or pick from a calendar. The model is a Temporal.PlainDate (or null), the same type a `date`
3
+ // column comes back as, so a form round-trips the server's value without ever touching a string or a time zone.
4
+ //
5
+ // WHY NO `Date`. A JavaScript Date is an instant, not a day. Every conversion between the two goes through a
6
+ // time zone, and every one of those is a chance for the 12th to become the 11th. So nothing here constructs one:
7
+ // the typed text is parsed by parseDateEntry (utils/date-entry.ts, pure Temporal), and the calendar's
8
+ // CalendarDate is converted by its fields alone (year, month, day), never via toDate()/getLocalTimeZone().
9
+ // "Today" comes from useToday().
10
+ //
11
+ // <ZDateField v-model="form.endDate" clearable class="w-full" />
12
+ // <ZDateField v-model="due" format="DD.MM.YYYY" locale="de" />
13
+ //
14
+ // FORMAT AND LOCALE. `locale` names the calendar's language and week (Nuxt UI's locale when unset, `en` unless the
15
+ // app's <UApp :locale> says otherwise). `format` is how the box writes and reads a day — a pattern such as
16
+ // "MM/DD/YYYY", "DD/MM/YYYY", "DD.MM.YYYY" or "YYYY-MM-DD" — and when unset it is the locale's own numeric order
17
+ // (dateEntryFormatFor), so `en` gives MM/DD/YYYY. The placeholder is the pattern.
18
+ //
19
+ // Typing (in MM/DD/YYYY): "5" or "12" is that day this month, "0512" is May 12, "051226" and "5/12/26" and
20
+ // "5/12/2026" carry the year; other formats read the same shapes in their own order. Enter, Tab or leaving the
21
+ // field commits; text that isn't a date clears the field. Shortcut keys (see applyDateShortcut): t today, m/h
22
+ // start/end of month, y/r start/end of year, + and - a day either way (_ too, so a format whose separator is "-"
23
+ // keeps a key for the day before).
24
+ //
25
+ // `dateUpdate` fires when a date is settled — picked, cleared, set by a shortcut, committed with Enter, or when
26
+ // focus leaves the field for somewhere other than its own calendar (Tab included, once) — which is the moment
27
+ // an inline editor (a table cell) should save and close. It always carries the date just settled, even when
28
+ // the parent's v-model hasn't caught up yet, and fires once per settle: leaving right after Enter, a pick, a
29
+ // shortcut or a clear doesn't announce the same date again. Plain forms can ignore it and read v-model.
30
+ //
31
+ // Also: a leading `icon` whose click emits `iconClick`, a `calendarIcon` in place of the calendar,
32
+ // and one-letter weekday headers (the locale's narrow weekday).
33
+ import type { CalendarDate as CalendarDay } from '@internationalized/date'
34
+ import { CalendarDate } from '@internationalized/date'
35
+ import { useLocale } from '@nuxt/ui/composables'
36
+ import { Temporal } from 'temporal-polyfill/implementation'
37
+ import { useToday } from '../composables/useToday'
38
+ import { applyDateShortcut, commitDateEntry, dateEntryFormat, dateEntryFormatFor, formatDateEntry, parseDateEntry } from '../utils/date-entry'
39
+
40
+ defineOptions({ inheritAttrs: false })
41
+
42
+ const props = withDefaults(
43
+ defineProps<{
44
+ clearable?: boolean
45
+ disabled?: boolean
46
+ /** The pattern the box writes and reads: "MM/DD/YYYY", "DD.MM.YYYY", "YYYY-MM-DD" … Unset: the locale's own. */
47
+ format?: string
48
+ /** The calendar's locale (BCP 47), and the format's when `format` is unset. Unset: Nuxt UI's locale. */
49
+ locale?: string
50
+ /** Unset: the format's pattern, "MM/DD/YYYY". */
51
+ placeholder?: string
52
+ size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'
53
+ /** A leading icon; a click on it emits `iconClick`. */
54
+ icon?: string
55
+ /** The calendar button's icon. A product's own icon is the product's to bundle. */
56
+ calendarIcon?: string
57
+ highlight?: boolean
58
+ ui?: { root?: string, base?: string, trailing?: string, leading?: string, leadingIcon?: string }
59
+ // Where the calendar is teleported; the popover's default (body) escapes table cells and modals.
60
+ portal?: boolean | string
61
+ /** The two buttons' accessible names, for a product in another language. */
62
+ clearLabel?: string
63
+ chooseLabel?: string
64
+ }>(),
65
+ { portal: true, calendarIcon: 'i-lucide-calendar', clearLabel: 'Clear date', chooseLabel: 'Choose a date' },
66
+ )
67
+ const emit = defineEmits<{
68
+ dateUpdate: [value: Temporal.PlainDate | null]
69
+ clear: []
70
+ // A click on the leading `icon` (`iconClick`).
71
+ iconClick: [event: MouseEvent]
72
+ }>()
73
+ const model = defineModel<Temporal.PlainDate | null>({ default: null })
74
+
75
+ const { locale: uiLocale } = useLocale()
76
+ const localeCode = computed(() => props.locale ?? uiLocale.value.code)
77
+ const entryFormat = computed(() => (props.format ? dateEntryFormat(props.format) : dateEntryFormatFor(localeCode.value)))
78
+ const show = (d: Temporal.PlainDate | null) => formatDateEntry(d, entryFormat.value)
79
+
80
+ const open = ref(false)
81
+ const text = ref(show(model.value))
82
+
83
+ const sameDay = (a: Temporal.PlainDate | null, b: Temporal.PlainDate | null) => a === b || (!!a && !!b && a.equals(b))
84
+
85
+ // The date this field last settled on, which is what `dateUpdate` reports. NEVER re-read `model.value` for
86
+ // that: when the parent owns the v-model, writing it only emits `update:modelValue`, and the prop comes back
87
+ // on the parent's next render — so in the same tick `model.value` is still the OLD date, and a blur that just
88
+ // committed "5/12" would announce null.
89
+ let settled = model.value
90
+ // The date `dateUpdate` last carried, boxed so an announced null is told apart from nothing announced yet.
91
+ let announced: { date: Temporal.PlainDate | null } | undefined
92
+ watch(model, (d) => {
93
+ // The parent set a different date, so whatever we announced before is no longer what's in the field.
94
+ if (!sameDay(d, settled)) announced = undefined
95
+ settled = d
96
+ text.value = show(d)
97
+ })
98
+ // A new format redraws the date it holds.
99
+ watch(entryFormat, () => { text.value = show(settled) })
100
+
101
+ const inputCmp = useTemplateRef<{ inputRef: HTMLInputElement | null, $el: HTMLElement }>('inputCmp')
102
+ const panelId = useId()
103
+
104
+ function set(d: Temporal.PlainDate | null) {
105
+ if (!sameDay(d, settled)) model.value = d
106
+ settled = d
107
+ text.value = show(d)
108
+ return d
109
+ }
110
+
111
+ // What's typed becomes the value — or nothing, when it isn't a date. Leaving "5/32" in the box would show one
112
+ // thing while the form saved another. Untouched text keeps the date as it is, so passing through the field
113
+ // can't blank a stored date it wouldn't read back (a year before 1000).
114
+ function commitText() {
115
+ return set(commitDateEntry(text.value, settled, useToday(), entryFormat.value))
116
+ }
117
+
118
+ function focusInput() {
119
+ nextTick(() => {
120
+ const el = inputCmp.value?.inputRef
121
+ if (!el) return
122
+ el.focus()
123
+ el.setSelectionRange(el.value.length, el.value.length)
124
+ })
125
+ }
126
+
127
+ // Focus is "still ours" on the input and anywhere in the calendar popover (which is teleported, so it isn't
128
+ // inside the input's element).
129
+ function isOurs(target: EventTarget | null) {
130
+ if (!(target instanceof Element)) return false
131
+ return !!inputCmp.value?.$el?.contains(target) || !!target.closest(`[data-date-field-panel="${panelId}"]`)
132
+ }
133
+
134
+ function announce(d: Temporal.PlainDate | null) {
135
+ announced = { date: d }
136
+ emit('dateUpdate', d)
137
+ }
138
+
139
+ // Leaving settles the field, but a date already announced (by Enter, say) isn't announced again: an inline
140
+ // editor saving on dateUpdate would save it twice.
141
+ function leave(e: FocusEvent) {
142
+ if (isOurs(e.relatedTarget)) return
143
+ if (announced && sameDay(announced.date, settled)) return
144
+ announce(settled)
145
+ }
146
+
147
+ function onBlur(e: FocusEvent) {
148
+ commitText()
149
+ leave(e)
150
+ }
151
+
152
+ function onKeydown(e: KeyboardEvent) {
153
+ if (e.isComposing || e.ctrlKey || e.metaKey) return
154
+ if (e.altKey) {
155
+ if (e.key === 'ArrowDown') {
156
+ e.preventDefault()
157
+ open.value = true
158
+ }
159
+ return
160
+ }
161
+ if (e.key === 'Enter') {
162
+ open.value = false
163
+ announce(commitText())
164
+ return
165
+ }
166
+ // Tab commits here, so the text is settled before focus moves; the blur that follows announces it, once.
167
+ if (e.key === 'Tab') {
168
+ commitText()
169
+ open.value = false
170
+ return
171
+ }
172
+ if (e.key.length !== 1) return
173
+ const today = useToday()
174
+ // Shortcuts step from what's on screen, even if it hasn't been committed yet.
175
+ const next = applyDateShortcut(e.key, parseDateEntry(text.value, today, entryFormat.value) ?? settled, today, entryFormat.value)
176
+ if (!next) return
177
+ e.preventDefault()
178
+ announce(set(next))
179
+ // Selected, so typing a date replaces the shortcut's rather than appending to it.
180
+ nextTick(() => inputCmp.value?.inputRef?.select())
181
+ }
182
+
183
+ function clear() {
184
+ const d = set(null)
185
+ emit('clear')
186
+ announce(d)
187
+ focusInput()
188
+ }
189
+
190
+ // ── Calendar ──────────────────────────────────────────────────────────────────────────────────────────────
191
+ // CalendarDate is a bare year/month/day, so the conversion is by fields both ways.
192
+ const toCalendar = (d: Temporal.PlainDate) => new CalendarDate(d.year, d.month, d.day)
193
+
194
+ // The selection follows text typed but not yet committed, as the month and the shortcuts do, so the picker and the
195
+ // input never disagree; untouched or unreadable text falls back to the model.
196
+ const calendarValue = computed(() => {
197
+ const day = parseDateEntry(text.value, useToday(), entryFormat.value) ?? model.value
198
+ return day ? toCalendar(day) : undefined
199
+ })
200
+ // The month the calendar shows: the date in the box (typed or committed), else this month. Only read while
201
+ // the popover is open, which is only ever in the browser.
202
+ const calendarMonth = computed(() =>
203
+ toCalendar(parseDateEntry(text.value, useToday(), entryFormat.value) ?? model.value ?? useToday()),
204
+ )
205
+
206
+ function onPick(v: unknown) {
207
+ if (!v || typeof v !== 'object' || !('day' in v)) return
208
+ const { year, month, day } = v as CalendarDay
209
+ open.value = false
210
+ announce(set(Temporal.PlainDate.from({ year, month, day })))
211
+ focusInput()
212
+ }
213
+
214
+ // The month heading is the one thing in the calendar whose width depends on what it says, and the popover
215
+ // sizes to its content — so paging from May to September widened it and shoved the grid and the arrows
216
+ // sideways. A fixed width that fits the longest English heading ("September 2026" is about 7.9em) keeps every
217
+ // month the same. In em, so it follows the button's own font at every `size`; plus room for its padding, which is rem.
218
+ const headingButton = { class: 'w-[calc(8.5em+1.5rem)] flex-none' }
219
+
220
+ const popoverContent = computed(() => ({
221
+ side: 'bottom' as const,
222
+ align: 'start' as const,
223
+ 'data-date-field-panel': panelId,
224
+ // The input keeps focus while the calendar is open, so typing and shortcuts still work.
225
+ onOpenAutoFocus: (e: Event) => e.preventDefault(),
226
+ onCloseAutoFocus: (e: Event) => e.preventDefault(),
227
+ // A click on our own input or icon isn't "outside"; the icon toggles the calendar itself.
228
+ onInteractOutside: (e: CustomEvent<{ originalEvent?: Event }>) => {
229
+ if (isOurs(e.detail?.originalEvent?.target ?? e.target)) e.preventDefault()
230
+ },
231
+ onFocusout: leave,
232
+ }))
233
+
234
+ function toggle() {
235
+ if (props.disabled) return
236
+ open.value = !open.value
237
+ focusInput()
238
+ }
239
+
240
+ defineExpose({ focus: focusInput })
241
+ </script>
242
+
243
+ <template>
244
+ <UPopover v-model:open="open" :content="popoverContent" :portal="portal">
245
+ <template #anchor>
246
+ <!-- The placeholder keeps the input's own ink, the product's: a product may darken it (a date's shape must not read as
247
+ a date someone typed), through `ui.base` or its app.config's input. While the calendar is open the field
248
+ takes Nuxt UI's highlight ring, so it reads as the one being edited. -->
249
+ <UInput
250
+ ref="inputCmp"
251
+ v-model="text"
252
+ type="text"
253
+ autocomplete="off"
254
+ v-bind="$attrs"
255
+ :size="size"
256
+ :icon="icon"
257
+ :disabled="disabled"
258
+ :placeholder="placeholder ?? entryFormat.pattern"
259
+ :highlight="highlight || open"
260
+ :ui="{ ...ui, root: `group ${ui?.root ?? ''}` }"
261
+ @keydown="onKeydown"
262
+ @blur="onBlur"
263
+ >
264
+ <template v-if="icon" #leading="{ ui: inputUi }">
265
+ <UIcon :name="icon" data-slot="leadingIcon" :class="inputUi.leadingIcon({ class: ui?.leadingIcon })" @click="emit('iconClick', $event)" />
266
+ </template>
267
+ <template #trailing="{ ui: inputUi }">
268
+ <!-- Neither button takes focus (mousedown is prevented), so the input never blurs to them. Each icon is
269
+ `text-current`, over Nuxt UI's dimmed trailing icon, so the button's own color reaches it. -->
270
+ <button
271
+ v-if="clearable && model && !disabled"
272
+ type="button"
273
+ tabindex="-1"
274
+ :aria-label="clearLabel"
275
+ class="cursor-pointer items-center text-dimmed hover:text-primary"
276
+ :class="open ? 'flex' : 'hidden group-focus-within:flex'"
277
+ @mousedown.prevent
278
+ @click="clear"
279
+ >
280
+ <UIcon name="i-lucide-x" :class="inputUi.trailingIcon({ class: 'text-current' })" />
281
+ </button>
282
+ <button
283
+ type="button"
284
+ tabindex="-1"
285
+ :aria-label="chooseLabel"
286
+ :disabled="disabled"
287
+ class="flex cursor-pointer items-center hover:text-primary disabled:cursor-not-allowed"
288
+ :class="open ? 'text-primary' : 'text-dimmed group-focus-within:text-primary'"
289
+ @mousedown.prevent
290
+ @click="toggle"
291
+ >
292
+ <UIcon :name="calendarIcon" :class="inputUi.trailingIcon({ class: 'text-current' })" />
293
+ </button>
294
+ </template>
295
+ </UInput>
296
+ </template>
297
+
298
+ <template #content>
299
+ <UCalendar
300
+ :model-value="calendarValue"
301
+ :placeholder="calendarMonth"
302
+ :locale="localeCode"
303
+ :size="size"
304
+ :view-control="headingButton"
305
+ weekday-format="narrow"
306
+ prevent-deselect
307
+ class="p-2"
308
+ @update:model-value="onPick"
309
+ />
310
+ </template>
311
+ </UPopover>
312
+ </template>
@@ -0,0 +1,22 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * UDrawer with Zoo UI's colored edge: bottom drawer — a top edge, as for every overlay. Only `color` is added —
4
+ * every other prop, `v-model`, event and slot passes straight through to Nuxt UI's UDrawer, so its behavior
5
+ * and polish are untouched. No `color`, no edge: a plain UDrawer.
6
+ */
7
+ import { edge, useSectionAccent, withEdge, withSectionAccent, 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, 'content', edge('top', props.color)))
12
+ // `accent`: the overlay portals to <body>, so it takes the name of the section it was opened from
13
+ const section = useSectionAccent()
14
+ </script>
15
+
16
+ <template>
17
+ <UDrawer v-bind="$attrs" :ui="ui" :content="withSectionAccent($attrs.content, color, section)">
18
+ <template v-for="(_, name) in $slots" #[name]="scope">
19
+ <slot :name="name" v-bind="scope ?? {}" />
20
+ </template>
21
+ </UDrawer>
22
+ </template>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * An ecosystem (a package manager) as a two-letter monogram tile, told apart by its corner shape rather than brand
4
+ * color, so it reads at 20px and in grayscale. Known ecosystems are in ./ecosystems.ts; any other is drawn from
5
+ * `label` / `monogram` / `shape`. The tile is an image named by its label — or decorative, when `with-label` shows
6
+ * the name beside it. `disabled` dashes it: not available yet.
7
+ */
8
+ import { eco, cx } from "./recipes";
9
+ import { ecosystem as resolve, type EcosystemShape, type KnownEcosystem } from "./ecosystems";
10
+
11
+ const props = withDefaults(defineProps<{
12
+ ecosystem: KnownEcosystem | (string & {});
13
+ size?: keyof typeof eco.size;
14
+ withLabel?: boolean;
15
+ disabled?: boolean;
16
+ /** said after the label when disabled: "npm · soon" */
17
+ disabledNote?: string;
18
+ /** override, or define an ecosystem the layer does not know */
19
+ label?: string;
20
+ monogram?: string;
21
+ shape?: EcosystemShape;
22
+ }>(), { size: "sm", withLabel: false, disabled: false, disabledNote: "soon" });
23
+
24
+ const e = computed(() => resolve(props.ecosystem, { label: props.label, monogram: props.monogram, shape: props.shape }));
25
+ const state = computed(() => (props.disabled ? "disabled" : "enabled"));
26
+ const name = computed(() => (props.disabled ? `${e.value.label} (${props.disabledNote})` : e.value.label));
27
+ </script>
28
+
29
+ <template>
30
+ <span v-if="withLabel" :class="eco.wrap">
31
+ <span :class="cx(eco.base, eco.size[size], eco.state[state], eco.shape[e.shape])" :data-eco="ecosystem" aria-hidden="true">{{ e.monogram }}</span>
32
+ <span :class="eco.label[state]">{{ e.label }}<template v-if="disabled"> · {{ disabledNote }}</template></span>
33
+ </span>
34
+ <span
35
+ v-else
36
+ :class="cx(eco.base, eco.size[size], eco.state[state], eco.shape[e.shape])" :data-eco="ecosystem"
37
+ role="img" :aria-label="name" :title="name"
38
+ ><span aria-hidden="true">{{ e.monogram }}</span></span>
39
+ </template>
@@ -0,0 +1,8 @@
1
+ <script setup lang="ts">
2
+ import { ident, cx } from "./recipes";
3
+ withDefaults(defineProps<{ kind?: keyof typeof ident.kind }>(), { kind: "package" });
4
+ </script>
5
+
6
+ <template>
7
+ <span :class="cx(ident.base, ident.kind[kind])"><slot /></span>
8
+ </template>
@@ -0,0 +1,8 @@
1
+ <script setup lang="ts">
2
+ import { kicker, cx } from "./recipes";
3
+ withDefaults(defineProps<{ variant?: keyof typeof kicker.variant }>(), { variant: "bracket" });
4
+ </script>
5
+
6
+ <template>
7
+ <div :class="cx(kicker.base, kicker.variant[variant])"><slot /></div>
8
+ </template>