@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 +26 -0
- package/README.md +475 -2
- package/assets/css/base.css +57 -0
- package/components/Card.vue +20 -0
- package/components/CodeBlock.vue +63 -0
- package/components/DateField.vue +312 -0
- package/components/Drawer.vue +22 -0
- package/components/EcosystemMark.vue +39 -0
- package/components/Identifier.vue +8 -0
- package/components/Kicker.vue +8 -0
- package/components/Modal.vue +22 -0
- package/components/NumberInput.vue +370 -0
- package/components/QuotaMeter.vue +32 -0
- package/components/RepeatingList.vue +256 -0
- package/components/Slideover.vue +22 -0
- package/components/Slots.vue +27 -0
- package/components/Status.vue +24 -0
- package/components/ThemeToggle.vue +30 -0
- package/components/TokenReveal.vue +62 -0
- package/components/ecosystems.ts +38 -0
- package/components/edge.ts +63 -0
- package/components/number-calc.ts +118 -0
- package/components/number-format.ts +357 -0
- package/components/number-input.ts +110 -0
- package/components/recipes.ts +141 -0
- package/composables/useToday.ts +19 -0
- package/composables/useZooTheme.ts +25 -0
- package/nuxt.config.ts +93 -0
- package/package.json +57 -3
- package/stylesheet-guard.d.ts +12 -0
- package/stylesheet-guard.js +103 -0
- package/testing/find-conflicts.d.ts +2 -0
- package/testing/find-conflicts.js +103 -0
- package/utils/date-entry.ts +245 -0
- package/utils/select-none.ts +23 -0
|
@@ -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 { 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>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* UModal with Zoo UI's colored edge: dialog — a top edge, like Zoo UI's danger dialog. Only `color` is added —
|
|
4
|
+
* every other prop, `v-model`, event and slot passes straight through to Nuxt UI's UModal, so its behavior
|
|
5
|
+
* and polish are untouched. No `color`, no edge: a plain UModal.
|
|
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
|
+
<UModal 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
|
+
</UModal>
|
|
22
|
+
</template>
|