@altafusion/fugue-ui 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +46 -2
- package/components/AccentSectionCard.vue +243 -0
- package/components/CopyToClipboard.vue +105 -0
- package/components/FileDropzone.vue +223 -0
- package/components/FugueAppHeader.vue +66 -0
- package/components/FugueAppHeaderDefault.vue +74 -0
- package/components/FugueAppHeaderLanding.vue +85 -0
- package/components/PresenceOrb.vue +55 -0
- package/components/TileGroupSection.vue +65 -0
- package/components/TileHintTooltip.vue +37 -0
- package/components/TileSelector.vue +174 -0
- package/components/TileSelectorLabel.vue +110 -0
- package/components/TileSelectorMultiple.vue +114 -0
- package/components/accentSectionCard.shared.ts +293 -0
- package/components/fileDropzone.shared.ts +140 -0
- package/components/fugue-app-header-types.ts +6 -0
- package/components/tileGroupSection.shared.ts +60 -0
- package/components/tileSelector.shared.ts +491 -0
- package/composables/useFugueAppHeaderChrome.ts +33 -0
- package/eslint.config.mjs +4 -0
- package/lib/fugue-header-visual-style.ts +8 -0
- package/nuxt.config.ts +17 -0
- package/package.json +46 -3
- package/utils/brandTheme.ts +42 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CheckboxGroupItem,
|
|
3
|
+
CheckboxGroupProps,
|
|
4
|
+
GetItemKeys,
|
|
5
|
+
GetModelValue,
|
|
6
|
+
RadioGroupItem,
|
|
7
|
+
RadioGroupProps,
|
|
8
|
+
} from '@nuxt/ui'
|
|
9
|
+
import type { HTMLAttributes } from 'vue'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Tile selector shared types, variant presets, and item normalizers.
|
|
13
|
+
*
|
|
14
|
+
* **Item copy (Nuxt UI aligned)**
|
|
15
|
+
*
|
|
16
|
+
* | Field | Role |
|
|
17
|
+
* | --- | --- |
|
|
18
|
+
* | `label` | Primary title (`URadioGroup` `#label` / `labelKey`) |
|
|
19
|
+
* | `description` | Body helper (item field / `descriptionKey` → {@link TileSelectorLabel}) |
|
|
20
|
+
* | `hint` | Inline caption on row/feature (`{ text, color? }` from workflow manifest) |
|
|
21
|
+
* | `tooltip` | Optional lightbulb on the title |
|
|
22
|
+
*
|
|
23
|
+
* **Workflow manifest → tile item** (`mapTileOption`):
|
|
24
|
+
* - `variant: pill` + string `hint` → item `tooltip` (title + lightbulb)
|
|
25
|
+
* - other variants: string `hint` → `description`; `hint: { text, color? }` → item `hint`
|
|
26
|
+
* - `description` → body (card / row / feature)
|
|
27
|
+
*
|
|
28
|
+
* **Styling:** {@link TILE_VARIANT_UI} presets + optional `:ui` merge;
|
|
29
|
+
* row/feature label chrome uses `itemLabel`, `itemHint`, `itemDescription` slots
|
|
30
|
+
* (split from group ui via {@link splitTileUi}).
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** Visual layout for {@link TileSelector} / {@link TileSelectorMultiple}. */
|
|
34
|
+
export type TileSelectorVariant = 'card' | 'square' | 'pill' | 'row' | 'feature'
|
|
35
|
+
|
|
36
|
+
/** Row/feature variants render label + hint + description inside the custom `#label` slot. */
|
|
37
|
+
export function usesInlineTileLabel(variant: TileSelectorVariant | undefined): boolean {
|
|
38
|
+
return variant === 'row' || variant === 'feature'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Nuxt still sizes the indicator `container` by `size` (`md` → `h-5`) when
|
|
43
|
+
* `indicator="hidden"`. `size-0` does **not** beat `h-5` (different tw-merge
|
|
44
|
+
* groups), so the empty box kept stretching every tile. Mark the whole
|
|
45
|
+
* container `sr-only` — control stays in the a11y tree, zero layout impact.
|
|
46
|
+
* Also reset `<p>` label margins (card variant uses `<p>` for the label slot).
|
|
47
|
+
*/
|
|
48
|
+
export const HIDDEN_INDICATOR_GROUP_UI = {
|
|
49
|
+
container: 'sr-only',
|
|
50
|
+
// Zero margins — card still wraps labels in `<p>`; list uses `<label>` (preferred).
|
|
51
|
+
label: 'm-0! p-0! leading-none',
|
|
52
|
+
} as const
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Map our tile `variant` → Nuxt RadioGroup/CheckboxGroup `variant`.
|
|
56
|
+
*
|
|
57
|
+
* Pill / row / feature use Nuxt `list` so the label slot is a real `<label>`,
|
|
58
|
+
* not a `<p>`. App chrome sets `p { margin-bottom: var(--space-4) }` outside
|
|
59
|
+
* `@layer utilities`, which beats Tailwind `m-0` and left a 16px gap under
|
|
60
|
+
* every card-variant tile. `list` also skips card's `md` compound `p-3.5`.
|
|
61
|
+
*/
|
|
62
|
+
export function resolveNuxtTileVariant(
|
|
63
|
+
variant: TileSelectorVariant | undefined,
|
|
64
|
+
): NonNullable<RadioGroupProps['variant']> {
|
|
65
|
+
return variant === 'pill' || variant === 'row' || variant === 'feature'
|
|
66
|
+
? 'list'
|
|
67
|
+
: 'card'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export type TileGroupUi = NonNullable<RadioGroupProps['ui']>
|
|
71
|
+
|
|
72
|
+
/** Extra slots for inline label chrome (row/feature). Not passed to URadioGroup. */
|
|
73
|
+
export const TILE_LABEL_UI_KEYS = [
|
|
74
|
+
'itemRoot',
|
|
75
|
+
'itemLeading',
|
|
76
|
+
'itemLabel',
|
|
77
|
+
/** Inline caption under the title (row/feature) — workflow manifest `hint: { text, color? }`. */
|
|
78
|
+
'itemHint',
|
|
79
|
+
/** Body copy — Nuxt UI `description` (workflow manifest `description`). */
|
|
80
|
+
'itemDescription',
|
|
81
|
+
] as const
|
|
82
|
+
export type TileLabelUiKey = (typeof TILE_LABEL_UI_KEYS)[number]
|
|
83
|
+
|
|
84
|
+
export type TileUiClass = string | string[] | undefined | null | false
|
|
85
|
+
|
|
86
|
+
export type TileLabelUi = Partial<Record<TileLabelUiKey, TileUiClass>>
|
|
87
|
+
|
|
88
|
+
/** RadioGroup `ui` slots + tile label slots. */
|
|
89
|
+
export type TileSelectorUi = TileGroupUi & TileLabelUi
|
|
90
|
+
|
|
91
|
+
/** A single Nuxt UI `ui` slot value (string / class array / falsy), as typed by the group's `ui` prop. */
|
|
92
|
+
type TileSlotClass = TileGroupUi[keyof TileGroupUi] | TileUiClass
|
|
93
|
+
|
|
94
|
+
/** Nuxt UI semantic colors (`primary`, `success`, `info`, …). */
|
|
95
|
+
export const TILE_SEMANTIC_COLORS = [
|
|
96
|
+
'primary',
|
|
97
|
+
'secondary',
|
|
98
|
+
'success',
|
|
99
|
+
'info',
|
|
100
|
+
'warning',
|
|
101
|
+
'error',
|
|
102
|
+
'neutral',
|
|
103
|
+
] as const
|
|
104
|
+
|
|
105
|
+
export type TileSemanticColor = (typeof TILE_SEMANTIC_COLORS)[number]
|
|
106
|
+
|
|
107
|
+
/** Inline caption on row/feature tiles — workflow manifest `hint: { text, color? }`. */
|
|
108
|
+
export interface TileInlineHint {
|
|
109
|
+
text: string
|
|
110
|
+
color?: TileSemanticColor
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Map a Nuxt UI semantic color to a text utility class (static strings for Tailwind). */
|
|
114
|
+
const TILE_SEMANTIC_TEXT_CLASS: Record<TileSemanticColor, string> = {
|
|
115
|
+
primary: 'text-primary',
|
|
116
|
+
secondary: 'text-secondary',
|
|
117
|
+
success: 'text-success',
|
|
118
|
+
info: 'text-info',
|
|
119
|
+
warning: 'text-warning',
|
|
120
|
+
error: 'text-error',
|
|
121
|
+
neutral: 'text-neutral',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function tileSemanticTextClass(color?: TileSemanticColor): string | undefined {
|
|
125
|
+
return color ? TILE_SEMANTIC_TEXT_CLASS[color] : undefined
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Optional tile chrome on object items (ignored by Nuxt UI, used by {@link TileSelectorLabel}). */
|
|
129
|
+
export interface TileItemExtras {
|
|
130
|
+
icon?: string
|
|
131
|
+
iconClass?: string
|
|
132
|
+
imageSrc?: string
|
|
133
|
+
/** Lightbulb tooltip on the title. */
|
|
134
|
+
tooltip?: string
|
|
135
|
+
/** Inline caption (row/feature) — workflow manifest `hint: { text, color? }`. */
|
|
136
|
+
hint?: TileInlineHint
|
|
137
|
+
hidden?: boolean
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type TileLabelItem = TileItemExtras & {
|
|
141
|
+
id?: string
|
|
142
|
+
label?: string
|
|
143
|
+
description?: string
|
|
144
|
+
value?: unknown
|
|
145
|
+
[key: string]: unknown
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface TileSelectorProps<
|
|
149
|
+
T extends RadioGroupItem[] = RadioGroupItem[],
|
|
150
|
+
VK extends GetItemKeys<T> = 'value',
|
|
151
|
+
> extends Pick<
|
|
152
|
+
RadioGroupProps<T, VK>,
|
|
153
|
+
| 'items'
|
|
154
|
+
| 'legend'
|
|
155
|
+
| 'name'
|
|
156
|
+
| 'required'
|
|
157
|
+
| 'disabled'
|
|
158
|
+
| 'color'
|
|
159
|
+
| 'size'
|
|
160
|
+
| 'orientation'
|
|
161
|
+
| 'valueKey'
|
|
162
|
+
| 'labelKey'
|
|
163
|
+
| 'descriptionKey'
|
|
164
|
+
| 'indicator'
|
|
165
|
+
| 'loop'
|
|
166
|
+
| 'defaultValue'
|
|
167
|
+
| 'highlight'
|
|
168
|
+
> {
|
|
169
|
+
ui?: TileSelectorUi
|
|
170
|
+
error?: string
|
|
171
|
+
variant?: TileSelectorVariant
|
|
172
|
+
/** Skip the outer {@link UFormField} when a parent already owns label/error chrome. */
|
|
173
|
+
bare?: boolean
|
|
174
|
+
/** Extra classes for the outermost element. Accepts any Vue class binding. */
|
|
175
|
+
class?: HTMLAttributes['class']
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface TileSelectorMultipleProps<
|
|
179
|
+
T extends CheckboxGroupItem[] = CheckboxGroupItem[],
|
|
180
|
+
VK extends GetItemKeys<T> = 'value',
|
|
181
|
+
> extends Pick<
|
|
182
|
+
CheckboxGroupProps<T, VK>,
|
|
183
|
+
| 'items'
|
|
184
|
+
| 'legend'
|
|
185
|
+
| 'name'
|
|
186
|
+
| 'required'
|
|
187
|
+
| 'disabled'
|
|
188
|
+
| 'color'
|
|
189
|
+
| 'size'
|
|
190
|
+
| 'orientation'
|
|
191
|
+
| 'valueKey'
|
|
192
|
+
| 'labelKey'
|
|
193
|
+
| 'descriptionKey'
|
|
194
|
+
| 'indicator'
|
|
195
|
+
| 'loop'
|
|
196
|
+
| 'defaultValue'
|
|
197
|
+
| 'highlight'
|
|
198
|
+
| 'icon'
|
|
199
|
+
> {
|
|
200
|
+
ui?: TileSelectorUi
|
|
201
|
+
error?: string
|
|
202
|
+
variant?: TileSelectorVariant
|
|
203
|
+
/** Extra classes for the outermost element. Accepts any Vue class binding. */
|
|
204
|
+
class?: HTMLAttributes['class']
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export type TileSelectorModelValue<
|
|
208
|
+
T extends RadioGroupItem[] = RadioGroupItem[],
|
|
209
|
+
VK extends GetItemKeys<T> = 'value',
|
|
210
|
+
> = GetModelValue<T, VK, false>
|
|
211
|
+
|
|
212
|
+
export type TileSelectorMultipleModelValue<
|
|
213
|
+
T extends CheckboxGroupItem[] = CheckboxGroupItem[],
|
|
214
|
+
VK extends GetItemKeys<T> = 'value',
|
|
215
|
+
> = GetModelValue<T, VK, true>
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Nuxt `card` compounds `border-muted` (too faint inactive). Override to
|
|
219
|
+
* `border-default` for all variants; checked state uses primary.
|
|
220
|
+
*/
|
|
221
|
+
const checkedItemSurface: string[] = [
|
|
222
|
+
'border-default',
|
|
223
|
+
'has-data-[state=checked]:bg-primary/10',
|
|
224
|
+
'has-data-[state=checked]:border-primary',
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
const tileGridFieldset: string[] = [
|
|
228
|
+
'grid w-full grid-cols-1 gap-4',
|
|
229
|
+
'md:grid-cols-[repeat(auto-fill,minmax(195px,1fr))]',
|
|
230
|
+
]
|
|
231
|
+
|
|
232
|
+
/** Wider columns so title + body copy fit without stacking awkwardly. */
|
|
233
|
+
const featureGridFieldset: string[] = [
|
|
234
|
+
'grid w-full grid-cols-1 gap-4',
|
|
235
|
+
'md:grid-cols-[repeat(auto-fill,minmax(280px,1fr))]',
|
|
236
|
+
]
|
|
237
|
+
|
|
238
|
+
export const TILE_VARIANT_UI: Record<TileSelectorVariant, TileSelectorUi> = {
|
|
239
|
+
card: {
|
|
240
|
+
fieldset: tileGridFieldset,
|
|
241
|
+
item: [
|
|
242
|
+
'rounded-xl shadow-sm',
|
|
243
|
+
...checkedItemSurface,
|
|
244
|
+
],
|
|
245
|
+
wrapper: 'w-full text-center',
|
|
246
|
+
// Body copy lives in {@link TileSelectorLabel}; hide Nuxt's duplicate `<p>`.
|
|
247
|
+
description: 'hidden',
|
|
248
|
+
},
|
|
249
|
+
square: {
|
|
250
|
+
fieldset: tileGridFieldset,
|
|
251
|
+
item: [
|
|
252
|
+
'rounded-none',
|
|
253
|
+
...checkedItemSurface,
|
|
254
|
+
],
|
|
255
|
+
wrapper: 'w-full text-center',
|
|
256
|
+
description: 'hidden',
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* Compact chips — flex-wrap + fixed basis like `row`.
|
|
260
|
+
* Hidden-indicator container collapse is applied in {@link TileSelector}
|
|
261
|
+
* via {@link HIDDEN_INDICATOR_GROUP_UI} (all variants).
|
|
262
|
+
*/
|
|
263
|
+
pill: {
|
|
264
|
+
fieldset: 'flex flex-row flex-wrap gap-2',
|
|
265
|
+
item: [
|
|
266
|
+
// Nuxt list has no card padding; keep explicit chip padding only.
|
|
267
|
+
'rounded-full border px-3 py-1.5',
|
|
268
|
+
'shrink grow-0 basis-[11rem] max-w-[11rem]',
|
|
269
|
+
'flex items-center justify-center gap-0',
|
|
270
|
+
...checkedItemSurface,
|
|
271
|
+
'has-data-[state=checked]:text-primary',
|
|
272
|
+
],
|
|
273
|
+
wrapper: 'm-0 flex w-full items-center justify-center p-0 leading-none',
|
|
274
|
+
label: 'm-0 flex items-center justify-center p-0 leading-none',
|
|
275
|
+
},
|
|
276
|
+
/** Flex-wrap row tiles — fixed width so they don't stretch full-bleed. */
|
|
277
|
+
row: {
|
|
278
|
+
fieldset: 'flex flex-row flex-wrap gap-4',
|
|
279
|
+
item: [
|
|
280
|
+
// `border` required — Nuxt `list` (unlike `card`) does not add it.
|
|
281
|
+
'flex-row items-center gap-4 rounded-xl border px-4 py-3 shadow-sm',
|
|
282
|
+
'shrink grow-0 basis-[19.5rem] max-w-[19.5rem]',
|
|
283
|
+
...checkedItemSurface,
|
|
284
|
+
],
|
|
285
|
+
wrapper: 'min-w-0 flex-1 text-left',
|
|
286
|
+
label: 'block w-full',
|
|
287
|
+
description: 'hidden',
|
|
288
|
+
itemRoot: 'flex w-full items-center gap-4 text-left',
|
|
289
|
+
itemLeading: 'flex shrink-0 items-center justify-center',
|
|
290
|
+
itemLabel: 'text-base font-medium leading-tight text-default',
|
|
291
|
+
itemHint: 'block text-sm font-medium text-muted',
|
|
292
|
+
itemDescription: 'block text-sm text-muted',
|
|
293
|
+
},
|
|
294
|
+
/**
|
|
295
|
+
* Card grid + left icon/title/description — AIS-style layout without per-tile accent colors.
|
|
296
|
+
* Width: `featureGridFieldset` → `minmax(280px, 1fr)`.
|
|
297
|
+
*/
|
|
298
|
+
feature: {
|
|
299
|
+
fieldset: featureGridFieldset,
|
|
300
|
+
item: [
|
|
301
|
+
'flex-row items-start gap-3 rounded-xl border px-4 py-3 shadow-sm',
|
|
302
|
+
...checkedItemSurface,
|
|
303
|
+
],
|
|
304
|
+
wrapper: 'min-w-0 flex-1 text-left',
|
|
305
|
+
label: 'block w-full',
|
|
306
|
+
description: 'hidden',
|
|
307
|
+
itemRoot: 'flex w-full items-start gap-3 text-left',
|
|
308
|
+
itemLeading: 'flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-full bg-muted',
|
|
309
|
+
itemLabel: 'text-sm font-semibold leading-tight text-default',
|
|
310
|
+
itemHint: 'block text-xs mb-1',
|
|
311
|
+
itemDescription: 'block text-xs leading-relaxed text-muted',
|
|
312
|
+
},
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Default Lucide stroke for tile icons (Lucide bakes `2` into SVG presentation attrs). */
|
|
316
|
+
export const TILE_ICON_STROKE_WIDTH = '.85'
|
|
317
|
+
|
|
318
|
+
/** Overrides baked-in Lucide stroke on inline SVG (`mode="svg"`) via CSS variable. */
|
|
319
|
+
export const TILE_ICON_STROKE_CLASS = '[&_*]:![stroke-width:var(--tile-icon-stroke-width)]'
|
|
320
|
+
|
|
321
|
+
export const TILE_ICON_ROW_CLASS = `size-10 text-primary ${TILE_ICON_STROKE_CLASS}`
|
|
322
|
+
|
|
323
|
+
export const TILE_ICON_STACKED_CLASS = `size-5 text-primary ${TILE_ICON_STROKE_CLASS}`
|
|
324
|
+
|
|
325
|
+
export function tileIconStyle(strokeWidth: string = TILE_ICON_STROKE_WIDTH) {
|
|
326
|
+
return { '--tile-icon-stroke-width': strokeWidth } as const
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Merge caller `iconClass` with tile stroke override (stories often pass size/color only). */
|
|
330
|
+
export function resolveTileIconClass(
|
|
331
|
+
layout: 'row' | 'stacked',
|
|
332
|
+
iconClass?: string,
|
|
333
|
+
): string {
|
|
334
|
+
if (!iconClass) {
|
|
335
|
+
return layout === 'row'
|
|
336
|
+
? TILE_ICON_ROW_CLASS
|
|
337
|
+
: TILE_ICON_STACKED_CLASS
|
|
338
|
+
}
|
|
339
|
+
return `${iconClass} ${TILE_ICON_STROKE_CLASS}`
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// A `SlotClassReplacer` (function, or a plain object like `{ base, ... }`) can't be
|
|
343
|
+
// array-combined for class binding — it would stringify to "[object …]" and break styles.
|
|
344
|
+
// Only strings, arrays, and falsy values are safe tailwind-merge input.
|
|
345
|
+
function isSlotClassReplacer(value: TileSlotClass): boolean {
|
|
346
|
+
if (typeof value === 'function')
|
|
347
|
+
return true
|
|
348
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function mergeUiSlot(
|
|
352
|
+
base: TileSlotClass,
|
|
353
|
+
extra: TileSlotClass,
|
|
354
|
+
): TileSlotClass {
|
|
355
|
+
if (base === undefined)
|
|
356
|
+
return extra
|
|
357
|
+
if (extra === undefined)
|
|
358
|
+
return base
|
|
359
|
+
// If either side is a replacer, it can't be safely concatenated; the caller's override wins.
|
|
360
|
+
if (isSlotClassReplacer(base) || isSlotClassReplacer(extra))
|
|
361
|
+
return extra
|
|
362
|
+
// Combine as a class array (nested arrays are valid tailwind-merge input); the cast is
|
|
363
|
+
// needed only because the slot type also permits a non-array `SlotClassReplacer`.
|
|
364
|
+
return [base, extra] as TileSlotClass
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/** Merge {@link HIDDEN_INDICATOR_GROUP_UI} under variant/`ui` so callers can still override. */
|
|
368
|
+
export function applyHiddenIndicatorUi(groupUi: TileGroupUi): TileGroupUi {
|
|
369
|
+
return {
|
|
370
|
+
...groupUi,
|
|
371
|
+
container: mergeUiSlot(HIDDEN_INDICATOR_GROUP_UI.container, groupUi.container),
|
|
372
|
+
label: mergeUiSlot(HIDDEN_INDICATOR_GROUP_UI.label, groupUi.label),
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Deep-merge Nuxt UI `ui` slot classes with tile variant presets (arrays, not string concat). */
|
|
377
|
+
export function mergeTileUi(
|
|
378
|
+
variant: TileSelectorVariant,
|
|
379
|
+
ui?: TileSelectorUi,
|
|
380
|
+
): TileSelectorUi {
|
|
381
|
+
const preset = TILE_VARIANT_UI[variant] ?? TILE_VARIANT_UI.card
|
|
382
|
+
if (!ui)
|
|
383
|
+
return preset
|
|
384
|
+
|
|
385
|
+
const keys = new Set([
|
|
386
|
+
...Object.keys(preset),
|
|
387
|
+
...Object.keys(ui),
|
|
388
|
+
])
|
|
389
|
+
|
|
390
|
+
const merged: Record<string, TileSlotClass> = {}
|
|
391
|
+
for (const key of keys)
|
|
392
|
+
merged[key] = mergeUiSlot(preset[key as keyof TileSelectorUi], ui[key as keyof TileSelectorUi])
|
|
393
|
+
return merged as TileSelectorUi
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** Pick label-only ui slots out of a merged {@link TileSelectorUi}. */
|
|
397
|
+
function pickLabelUi(ui: TileSelectorUi): TileLabelUi {
|
|
398
|
+
const labelUi: TileLabelUi = {}
|
|
399
|
+
for (const key of TILE_LABEL_UI_KEYS) {
|
|
400
|
+
const value = ui[key]
|
|
401
|
+
if (value !== undefined)
|
|
402
|
+
labelUi[key] = value
|
|
403
|
+
}
|
|
404
|
+
return labelUi
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/** RadioGroup/CheckboxGroup slots only — strips {@link TILE_LABEL_UI_KEYS}. */
|
|
408
|
+
function pickGroupUi(ui: TileSelectorUi): TileGroupUi {
|
|
409
|
+
const groupUi: Record<string, TileSlotClass> = { ...ui }
|
|
410
|
+
for (const key of TILE_LABEL_UI_KEYS)
|
|
411
|
+
delete groupUi[key]
|
|
412
|
+
return groupUi as TileGroupUi
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Split merged `ui` into RadioGroup/CheckboxGroup slots vs inline label chrome. */
|
|
416
|
+
export function splitTileUi(ui: TileSelectorUi): {
|
|
417
|
+
groupUi: TileGroupUi
|
|
418
|
+
labelUi: TileLabelUi
|
|
419
|
+
} {
|
|
420
|
+
return {
|
|
421
|
+
groupUi: pickGroupUi(ui),
|
|
422
|
+
labelUi: pickLabelUi(ui),
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function isObjectItem(item: RadioGroupItem | CheckboxGroupItem): item is Record<string, unknown> {
|
|
427
|
+
return typeof item === 'object' && item !== null
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export function hasTileExtras(item: unknown): item is TileLabelItem {
|
|
431
|
+
if (!isObjectItem(item as RadioGroupItem))
|
|
432
|
+
return false
|
|
433
|
+
const tile = item as TileItemExtras
|
|
434
|
+
return Boolean(tile.icon || tile.imageSrc || tile.tooltip || tile.hint)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** Resolve an item's display label, honoring a custom `labelKey` and primitive items. */
|
|
438
|
+
export function resolveTileLabel(
|
|
439
|
+
item: RadioGroupItem | CheckboxGroupItem,
|
|
440
|
+
labelKey?: string,
|
|
441
|
+
): string {
|
|
442
|
+
if (!isObjectItem(item)) {
|
|
443
|
+
return item == null
|
|
444
|
+
? ''
|
|
445
|
+
: String(item)
|
|
446
|
+
}
|
|
447
|
+
const value = (item as Record<string, unknown>)[labelKey ?? 'label']
|
|
448
|
+
return value == null
|
|
449
|
+
? ''
|
|
450
|
+
: String(value)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Object shape for {@link TileSelectorLabel}, including primitive items. */
|
|
454
|
+
export function resolveTileLabelItem(
|
|
455
|
+
item: RadioGroupItem | CheckboxGroupItem,
|
|
456
|
+
labelKey?: string,
|
|
457
|
+
): TileLabelItem {
|
|
458
|
+
if (!isObjectItem(item)) {
|
|
459
|
+
return {
|
|
460
|
+
label: resolveTileLabel(item, labelKey),
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
...item,
|
|
465
|
+
label: resolveTileLabel(item, labelKey),
|
|
466
|
+
} as TileLabelItem
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/** Resolve an item's description, honoring a custom `descriptionKey` and primitive items. */
|
|
470
|
+
export function resolveTileDescription(
|
|
471
|
+
item: RadioGroupItem | CheckboxGroupItem,
|
|
472
|
+
descriptionKey?: string,
|
|
473
|
+
): string | undefined {
|
|
474
|
+
if (!isObjectItem(item))
|
|
475
|
+
return undefined
|
|
476
|
+
const value = (item as Record<string, unknown>)[descriptionKey ?? 'description']
|
|
477
|
+
return value == null
|
|
478
|
+
? undefined
|
|
479
|
+
: String(value)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/** Drop `hidden` object items; pass string/number items through. */
|
|
483
|
+
export function normalizeTileItems<I extends readonly (RadioGroupItem | CheckboxGroupItem)[]>(
|
|
484
|
+
items: I,
|
|
485
|
+
): I {
|
|
486
|
+
return items.filter((item) => {
|
|
487
|
+
if (!isObjectItem(item))
|
|
488
|
+
return true
|
|
489
|
+
return !item.hidden
|
|
490
|
+
}) as unknown as I
|
|
491
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Shared scroll + mobile drawer state for landing header visual styles. */
|
|
2
|
+
export function useFugueAppHeaderChrome() {
|
|
3
|
+
const navOpen = ref(false)
|
|
4
|
+
const scrolled = ref(false)
|
|
5
|
+
|
|
6
|
+
function onScroll() {
|
|
7
|
+
scrolled.value = window.scrollY >= 50
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
onMounted(() => {
|
|
11
|
+
onScroll()
|
|
12
|
+
window.addEventListener('scroll', onScroll, { passive: true })
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
onUnmounted(() => {
|
|
16
|
+
window.removeEventListener('scroll', onScroll)
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function closeNav() {
|
|
20
|
+
navOpen.value = false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function toggleNav() {
|
|
24
|
+
navOpen.value = !navOpen.value
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
navOpen,
|
|
29
|
+
scrolled,
|
|
30
|
+
closeNav,
|
|
31
|
+
toggleNav,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Structural chrome presets for {@link FugueAppHeader}. Colors stay in site palette / tokens. */
|
|
2
|
+
export type FugueHeaderVisualStyle = 'default' | 'landing-fixed' | 'landing-static'
|
|
3
|
+
|
|
4
|
+
export const FUGUE_HEADER_VISUAL_STYLE_DEFAULT: FugueHeaderVisualStyle = 'default'
|
|
5
|
+
|
|
6
|
+
export function isLandingHeaderStyle(style: FugueHeaderVisualStyle): boolean {
|
|
7
|
+
return style === 'landing-fixed' || style === 'landing-static'
|
|
8
|
+
}
|
package/nuxt.config.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @altafusion/fugue-ui — Nuxt layer
|
|
3
|
+
*
|
|
4
|
+
* Generic Vue UI primitives on Nuxt UI. Altafusion FugueAppHeader* variants stay in `./components`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export default defineNuxtConfig({
|
|
8
|
+
extends: ['@altafusion/fugue-nuxt-ui'],
|
|
9
|
+
|
|
10
|
+
components: [
|
|
11
|
+
{
|
|
12
|
+
path: './components',
|
|
13
|
+
pathPrefix: false,
|
|
14
|
+
ignore: ['FugueAppHeaderDefault.vue', 'FugueAppHeaderLanding.vue', 'fugue-app-header-types.ts'],
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altafusion/fugue-ui",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"description": "Generic Vue UI primitives on Nuxt UI — reusable across Altafusion apps",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./nuxt.config.ts",
|
|
12
|
+
"./components/*": "./components/*.ts",
|
|
13
|
+
"./utils/brandTheme": "./utils/brandTheme.ts"
|
|
14
|
+
},
|
|
15
|
+
"main": "./nuxt.config.ts",
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"nuxt": ">=4.0.0",
|
|
18
|
+
"vue": "^3.5.0"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@altafusion/fugue-nuxt-ui": "0.2.0",
|
|
22
|
+
"@vueuse/core": "^14.4.0",
|
|
23
|
+
"tailwind-merge": "^3.7.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@altafusion/eslint-config": "0.2.0",
|
|
27
|
+
"@altafusion/nuxt-base": "0.2.0",
|
|
28
|
+
"@nuxt/ui": "^4.13.0",
|
|
29
|
+
"@types/node": "^26.6.6",
|
|
30
|
+
"eslint": "^10.15.0",
|
|
31
|
+
"nuxt": "^4.6.4",
|
|
32
|
+
"typescript": "^6.0.3",
|
|
33
|
+
"vue": "^3.5.46"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"**",
|
|
37
|
+
"!**/*.test.ts",
|
|
38
|
+
"!**/.nuxt",
|
|
39
|
+
"!**/.output",
|
|
40
|
+
"!**/.data",
|
|
41
|
+
"!**/coverage",
|
|
42
|
+
"!**/node_modules"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"clean": "rm -rf .output .nuxt node_modules/.cache dist",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"lint:fix": "eslint . --fix"
|
|
48
|
+
}
|
|
6
49
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable kit — mirror in @altafusion/fugue-ui (`utils/brandTheme.ts`) or a neighbor `@altafusion/fugue-ui`.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export interface BrandDefinition {
|
|
6
|
+
id: string
|
|
7
|
+
label: string
|
|
8
|
+
/** Nuxt UI `ui.colors.primary` scale name (e.g. violet, blue, green) */
|
|
9
|
+
primary: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** At least one brand — brands[0] always defined. */
|
|
13
|
+
export type NonEmptyBrands = readonly [BrandDefinition, ...BrandDefinition[]]
|
|
14
|
+
|
|
15
|
+
export interface BrandThemeConfig<T extends NonEmptyBrands = NonEmptyBrands> {
|
|
16
|
+
brands: T
|
|
17
|
+
cookieKey: string
|
|
18
|
+
defaultBrandId?: T[number]['id']
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function resolveBrandMeta<T extends NonEmptyBrands>(
|
|
22
|
+
config: Pick<BrandThemeConfig<T>, 'brands' | 'defaultBrandId'>,
|
|
23
|
+
id: string | null | undefined,
|
|
24
|
+
): T[number] {
|
|
25
|
+
const { brands, defaultBrandId } = config
|
|
26
|
+
const match = brands.find(b => b.id === id)
|
|
27
|
+
if (match)
|
|
28
|
+
return match
|
|
29
|
+
if (defaultBrandId != null) {
|
|
30
|
+
const fallback = brands.find(b => b.id === defaultBrandId)
|
|
31
|
+
if (fallback)
|
|
32
|
+
return fallback
|
|
33
|
+
}
|
|
34
|
+
return brands[0]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function isKnownBrandId<T extends readonly BrandDefinition[]>(
|
|
38
|
+
brands: T,
|
|
39
|
+
id: string | null | undefined,
|
|
40
|
+
): id is T[number]['id'] {
|
|
41
|
+
return id != null && brands.some(b => b.id === id)
|
|
42
|
+
}
|