numori-ui 0.2.0 → 0.4.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 +122 -0
- package/README.md +26 -21
- package/dist/components/Banner.js +176 -0
- package/dist/components/Banner.js.map +1 -0
- package/dist/components/Button.js +10 -19
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +15 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.js +2 -7
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CodeBlock.js +101 -0
- package/dist/components/CodeBlock.js.map +1 -0
- package/dist/components/Dropdown.js +10 -3
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/DropdownSubmenu.js +5 -3
- package/dist/components/DropdownSubmenu.js.map +1 -1
- package/dist/components/FileInput.js +12 -4
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/IconTile.js +5 -9
- package/dist/components/IconTile.js.map +1 -1
- package/dist/components/Input.js +6 -6
- package/dist/components/Input.js.map +1 -1
- package/dist/components/ListMenuItem.js +38 -31
- package/dist/components/ListMenuItem.js.map +1 -1
- package/dist/components/Numpad.js +4 -4
- package/dist/components/Numpad.js.map +1 -1
- package/dist/components/Popup.js +9 -3
- package/dist/components/Popup.js.map +1 -1
- package/dist/components/Radio.js +2 -7
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Segmented.js +100 -26
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +6 -4
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Spinner.js +87 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Table.js +174 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/ThemeToggle.js +85 -0
- package/dist/components/ThemeToggle.js.map +1 -0
- package/dist/components/Toast.js +107 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/index.js +67 -57
- package/dist/components/index.js.map +1 -1
- package/dist/composables/useMergedClasses.js +52 -0
- package/dist/composables/useMergedClasses.js.map +1 -0
- package/dist/icons/mdi.js +10 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +35 -30
- package/dist/index.js.map +1 -1
- package/dist/internal/controlSizes.js +21 -0
- package/dist/internal/controlSizes.js.map +1 -0
- package/dist/internal/menu.js +20 -0
- package/dist/internal/menu.js.map +1 -0
- package/dist/manifest.js +6 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Banner.vue +160 -0
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +2 -10
- package/src/components/CodeBlock.vue +99 -0
- package/src/components/Dropdown.vue +14 -2
- package/src/components/DropdownSubmenu.vue +4 -2
- package/src/components/FileInput.vue +19 -4
- package/src/components/IconTile.vue +4 -9
- package/src/components/Input.vue +6 -6
- package/src/components/ListMenuItem.vue +21 -5
- package/src/components/Numpad.vue +7 -4
- package/src/components/Popup.vue +6 -2
- package/src/components/Radio.vue +2 -10
- package/src/components/Segmented.vue +108 -38
- package/src/components/Select.vue +11 -2
- package/src/components/Spinner.vue +70 -0
- package/src/components/Table.vue +193 -0
- package/src/components/ThemeToggle.vue +81 -0
- package/src/components/Toast.vue +106 -0
- package/src/components/index.js +18 -3
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +10 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +6 -1
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,127 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
While the library is pre-1.0, minor versions may add components and options; patch
|
|
8
8
|
versions are fixes.
|
|
9
9
|
|
|
10
|
+
## [0.4.0] — 2026-08-31
|
|
11
|
+
|
|
12
|
+
A consolidation-and-polish release. Two components fold into more capable,
|
|
13
|
+
cohesive ones, related controls gain matching APIs, and a class of SSR
|
|
14
|
+
hydration bugs is fixed. The library is now 38 components (39 registered tags,
|
|
15
|
+
including `UiIcon`).
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **`UiTable`** — a general, accessible data table: `columns` / `rows`,
|
|
20
|
+
per-column alignment, row-header columns, an optional per-column leading
|
|
21
|
+
`icon`, a highlightable column, and a `#cell` scoped slot for custom cells.
|
|
22
|
+
Configuring `header` + `highlight` + `icon` columns reproduces the old
|
|
23
|
+
comparison table, so comparison is now a feature rather than a component.
|
|
24
|
+
- **`UiSegmented`** gains a `variant` prop matching `UiButton` — `solid`
|
|
25
|
+
(default), `outline`, `ghost` — a `square` shape, a `block` full-width mode,
|
|
26
|
+
and per-option `title` and `disabled`. The sliding indicator now animates in
|
|
27
|
+
every variant. (Its previous `rounded` shape is now `round`, matching
|
|
28
|
+
`UiButton`.)
|
|
29
|
+
- `mdi:chevron-left` added to the bundled icon set, completing the nav-chevron
|
|
30
|
+
family (`up` / `down` / `left` / `right`).
|
|
31
|
+
|
|
32
|
+
### Changed (breaking)
|
|
33
|
+
|
|
34
|
+
- **`UiComparisonTable` removed, replaced by the new `UiTable`** (see Added).
|
|
35
|
+
Comparison is now a configuration of a general data table. Migrate by moving
|
|
36
|
+
rows/labels into `UiTable`'s `columns` + `rows`: mark the label column
|
|
37
|
+
`header: true`, the featured column `highlight: true`, and give value columns
|
|
38
|
+
an `icon`.
|
|
39
|
+
- **`UiButton` shapes trimmed to `round` / `pill` / `square`.** The old `circle`
|
|
40
|
+
and `none` were redundant — `circle` was identical to `pill` (`rounded-full`)
|
|
41
|
+
and `none` collapsed to `round`. The set now matches `UiSegmented`'s `shape`.
|
|
42
|
+
For a circular icon button, use `shape="pill"` with `icon-only`.
|
|
43
|
+
- **`UiButtonsGroup` removed; its role is now covered by `UiSegmented`.** The two
|
|
44
|
+
were the same control — single-select from a small row of segments — with
|
|
45
|
+
different looks. `UiSegmented`'s `variant` prop mirrors `UiButton` — `solid`
|
|
46
|
+
(default), `outline`, and `ghost` — so the two read as one family, and the
|
|
47
|
+
sliding indicator animates as the selection changes in every variant. `shape`
|
|
48
|
+
is `pill` (default), `round`, or `square`, and the indicator matches the
|
|
49
|
+
track's radius. Plus a `block` full-width mode and per-option `title`. Migrate
|
|
50
|
+
a toolbar/tabs `UiButtonsGroup` by switching the tag to `UiSegmented`;
|
|
51
|
+
icon-only toolbars use options that carry an `icon` and no `label`.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- **SSR hydration mismatches from invalid nested `<button>`s.** `UiBanner` (when
|
|
56
|
+
`clickable` + `dismissible`) and `UiListMenuItem` (an interactive row with an
|
|
57
|
+
interactive suffix such as `UiToggle` or `UiSelect`) nested a `<button>` inside
|
|
58
|
+
a `<button>`, which browsers restructure — so the hydrated DOM no longer
|
|
59
|
+
matched the server markup and the tree re-patched on load (a visible "settling"
|
|
60
|
+
wobble). `UiBanner` now uses a full-cover click target that is a sibling of the
|
|
61
|
+
dismiss control, and `UiListMenuItem`'s interactive root is a keyboard-operable
|
|
62
|
+
`<div role="button">`. No nested interactive elements, no mismatch.
|
|
63
|
+
- **`UiFileInput` did not open the picker when its trigger was a button.** A
|
|
64
|
+
`<label>` skips forwarding a click to its control when the click lands on an
|
|
65
|
+
interactive descendant; the wrapper now handles the click itself, so any
|
|
66
|
+
trigger content works.
|
|
67
|
+
- **Floating panels drifted while opening.** `UiSelect`, `UiDropdown`, `UiPopup`
|
|
68
|
+
and `UiDropdownSubmenu` now scale in from the edge nearest their trigger
|
|
69
|
+
(transform-origin) instead of expanding from their centre.
|
|
70
|
+
- **`UiNumpad` key contrast.** Hover used a non-existent token in dark mode and
|
|
71
|
+
the page-background colour in light mode; keys now use a proper hover/active
|
|
72
|
+
progression in both themes.
|
|
73
|
+
- **`UiInput` number steppers.** The stacked-chevron columns were too narrow and
|
|
74
|
+
their buttons did not fill the column; both are corrected.
|
|
75
|
+
- **Menu-row hover highlight.** `UiButton`'s `menu-item` and `list-item`
|
|
76
|
+
variants — and the `UiDropdownItem` / `UiDropdown` / `UiListMenu` rows built on
|
|
77
|
+
them — now round their hover/active highlight instead of drawing a square that
|
|
78
|
+
poked past the rounded menu panel. `UiDropdown` also insets its rows so the
|
|
79
|
+
highlight reads as a chip.
|
|
80
|
+
- **`UiNumpad` keys keep their size** via a minimum width, rather than shrinking
|
|
81
|
+
in narrow or flex containers.
|
|
82
|
+
|
|
83
|
+
### Internal
|
|
84
|
+
|
|
85
|
+
- Extracted the shared `tailwind-merge` + attribute-forwarding pattern
|
|
86
|
+
(external classes override internal ones) into a `useMergedClasses` composable,
|
|
87
|
+
used by `UiButton`, `UiCard` and `UiIconTile`.
|
|
88
|
+
- Extracted the shared floating-menu panel chrome into a single constant reused
|
|
89
|
+
by `UiDropdown`, `UiSelect`, `UiPopup` and `UiDropdownSubmenu`.
|
|
90
|
+
- De-duplicated the identical size scale shared by `UiCheckbox` and `UiRadio`.
|
|
91
|
+
|
|
92
|
+
## [0.3.0] — 2026-08-31
|
|
93
|
+
|
|
94
|
+
Six new components, bringing the library to 39 components (40 registered tags,
|
|
95
|
+
including `UiIcon`). All additions are backward compatible. These were extracted
|
|
96
|
+
from the wider Numori ecosystem — the notes app and the marketing site — where
|
|
97
|
+
the same patterns had been rebuilt more than once.
|
|
98
|
+
|
|
99
|
+
### Added
|
|
100
|
+
|
|
101
|
+
- **`UiToast`** — a teleported stack of transient, self-dismissing messages with
|
|
102
|
+
enter/leave transitions. Presentational only: the host owns the list and its
|
|
103
|
+
timing and mutates a reactive array. Entries are `{ id, message, type?, icon? }`;
|
|
104
|
+
`type` maps to the `success` / `warning` / `error` tokens with a neutral
|
|
105
|
+
default. The container ignores pointer events so it never blocks the UI, and
|
|
106
|
+
each pill is a polite `role="status"`.
|
|
107
|
+
- **`UiBanner`** — a full-width status strip that slides in above the content
|
|
108
|
+
(offline notices, verification prompts, update prompts). Driven by `show`, with
|
|
109
|
+
a semantic `color`, optional `icon` and message slot, top safe-area padding by
|
|
110
|
+
default, and optional `clickable` / `dismissible` affordances that emit `click`
|
|
111
|
+
and `dismiss`.
|
|
112
|
+
- **`UiSpinner`** — the loading glyph `UiButton` uses, as a standalone primitive.
|
|
113
|
+
Five `size`s, colour inherited via `text-*`. Decorative by default; pass a
|
|
114
|
+
`label` and it becomes a live `role="status"` region.
|
|
115
|
+
- **`UiThemeToggle`** — a stateless light/dark icon button. Takes `isDark` and
|
|
116
|
+
emits `toggle`, leaving persistence to the host (`@nuxtjs/color-mode`, VueUse,
|
|
117
|
+
or hand-written); the sun and moon share a cell and cross-fade with a rotation.
|
|
118
|
+
- **`UiCodeBlock`** — a static, copyable snippet with an optional filename
|
|
119
|
+
caption and a copy button that fades in on hover or focus. Uses the async
|
|
120
|
+
Clipboard API and fails silently where it is unavailable; button labels are
|
|
121
|
+
props, so no language is baked in.
|
|
122
|
+
- **`UiComparisonTable`** — a data-driven, accessible two-way comparison built on
|
|
123
|
+
a real `<table>` (`<caption>`, `scope` headers) with one column accented.
|
|
124
|
+
Decorative leading icons; the cell text carries the meaning.
|
|
125
|
+
|
|
126
|
+
### Changed
|
|
127
|
+
|
|
128
|
+
- README component list, groupings and counts updated for the six additions.
|
|
129
|
+
- Type declarations (`dist/index.d.ts`) now export the six new components.
|
|
130
|
+
|
|
10
131
|
## [0.2.0] — 2026-08-31
|
|
11
132
|
|
|
12
133
|
Five new components, bringing the library to 33 components (34 registered tags,
|
|
@@ -46,5 +167,6 @@ including `UiIcon`). All additions are backward compatible.
|
|
|
46
167
|
- First published release: 28 components (29 registered tags), consumable as a
|
|
47
168
|
Nuxt module, a Vite plugin or a framework-agnostic Vue plugin.
|
|
48
169
|
|
|
170
|
+
[0.3.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.3.0
|
|
49
171
|
[0.2.0]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.2.0
|
|
50
172
|
[0.1.1]: https://github.com/Numori-Ecosystem/Numori-UI/releases/tag/v0.1.1
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Numori UI
|
|
2
2
|
|
|
3
|
-
The Numori design system as a standalone Vue 3 component library.
|
|
3
|
+
The Numori design system as a standalone Vue 3 component library. 38 components, Tailwind CSS v4, no
|
|
4
4
|
TypeScript, consumable as a **Nuxt module** or a **Vite plugin**.
|
|
5
5
|
|
|
6
6
|
Extracted from [Numori Notes](https://github.com/Numori-Ecosystem/Numori-Notes), where these
|
|
@@ -133,7 +133,7 @@ import './style.css'
|
|
|
133
133
|
createApp(App).use(createNumoriUI({ UiButton, UiModal })).mount('#app')
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
There is also `app.use(NumoriUI)`, which registers all
|
|
136
|
+
There is also `app.use(NumoriUI)`, which registers all 39 components in one line — convenient for
|
|
137
137
|
prototyping, but it bundles all of them. See [Tree-shaking](#tree-shaking).
|
|
138
138
|
|
|
139
139
|
## Styling
|
|
@@ -222,21 +222,21 @@ at. Referencing three components ships three.
|
|
|
222
222
|
Measured with `npm run treeshake`, bundling each case for real with `vue` and `tailwind-merge`
|
|
223
223
|
external, so the numbers are Numori UI's own code:
|
|
224
224
|
|
|
225
|
-
| How you consume it | Bundled
|
|
226
|
-
| ----------------------------------------- |
|
|
227
|
-
| `import { UiKbd }` | 0.4 kB
|
|
228
|
-
| `import UiKbd from 'numori-ui/…/Kbd.vue'` | 0.4 kB
|
|
229
|
-
| `import { UiButton }` |
|
|
230
|
-
| `import { UiButton, UiModal, UiInput }` |
|
|
231
|
-
| `createNumoriUI({ UiButton, UiModal })` |
|
|
232
|
-
| `app.use(NumoriUI)` |
|
|
225
|
+
| How you consume it | Bundled |
|
|
226
|
+
| ----------------------------------------- | -------- |
|
|
227
|
+
| `import { UiKbd }` | 0.4 kB |
|
|
228
|
+
| `import UiKbd from 'numori-ui/…/Kbd.vue'` | 0.4 kB |
|
|
229
|
+
| `import { UiButton }` | 18.9 kB |
|
|
230
|
+
| `import { UiButton, UiModal, UiInput }` | 34.5 kB |
|
|
231
|
+
| `createNumoriUI({ UiButton, UiModal })` | 23.2 kB |
|
|
232
|
+
| `app.use(NumoriUI)` | 101.9 kB |
|
|
233
233
|
|
|
234
234
|
**The Nuxt module and Vite plugin are already optimal.** Both point at the raw `.vue` sources and
|
|
235
235
|
only import what a template references, so nothing further is needed — verified by checking that
|
|
236
236
|
`Numpad`, `Popup` and `Prompt` are absent from the Nuxt playground's client bundle.
|
|
237
237
|
|
|
238
|
-
**`app.use(NumoriUI)` is the one path that is not tree-shakeable.** To register all
|
|
239
|
-
has to reference all
|
|
238
|
+
**`app.use(NumoriUI)` is the one path that is not tree-shakeable.** To register all 39 components it
|
|
239
|
+
has to reference all 39, so they all end up in your bundle. The `include` option does not change
|
|
240
240
|
this — it controls registration, not bundling. Use `createNumoriUI` instead when size matters:
|
|
241
241
|
|
|
242
242
|
```js
|
|
@@ -244,7 +244,7 @@ this — it controls registration, not bundling. Use `createNumoriUI` instead wh
|
|
|
244
244
|
app.use(createNumoriUI({ UiButton, UiModal }))
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
-
**Two costs worth knowing about.** `UiButton` is
|
|
247
|
+
**Two costs worth knowing about.** `UiButton` is 19 kB because roughly 9 kB of that is the bundled
|
|
248
248
|
icon set — its loading spinner renders through `UiIcon`, and icons are resolved dynamically by name,
|
|
249
249
|
so the lookup needs the whole table. Any component drawing an icon carries it. If that matters,
|
|
250
250
|
supply your own icon component (see [Icons](#icons)) and the bundled set drops out entirely.
|
|
@@ -297,8 +297,9 @@ export default defineNuxtConfig({
|
|
|
297
297
|
Every component is documented with JSDoc at the top of its source file, including props, events,
|
|
298
298
|
slots and worked examples. Prefixes below assume the default `Ui`.
|
|
299
299
|
|
|
300
|
-
**Actions** — `UiButton` (8 variants × 6 colours × 5 sizes ×
|
|
301
|
-
`UiSegmented` (single-select with
|
|
300
|
+
**Actions** — `UiButton` (8 variants × 6 colours × 5 sizes × 3 shapes),
|
|
301
|
+
`UiSegmented` (single-select segmented control with an animated sliding indicator; `solid`/`outline`/`ghost`
|
|
302
|
+
variants matching `UiButton`; `pill`/`round`/`square` shapes), `UiThemeToggle` (stateless light/dark button)
|
|
302
303
|
|
|
303
304
|
**Forms** — `UiInput` (text, number with steppers, password with toggle, email, phone, textarea,
|
|
304
305
|
built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiCheckbox`, `UiRadio`,
|
|
@@ -307,11 +308,13 @@ built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiC
|
|
|
307
308
|
**Overlays** — `UiModal` (teleported, fullscreen-on-mobile, safe-area aware), `UiPrompt`,
|
|
308
309
|
`UiDropdown`, `UiDropdownItem`, `UiDropdownRow`, `UiDropdownSubmenu`, `UiPopup`, `UiTooltip`
|
|
309
310
|
|
|
310
|
-
**Feedback** — `UiAlert`, `UiBadge`, `UiProgressBar`
|
|
311
|
+
**Feedback** — `UiAlert`, `UiBadge`, `UiProgressBar`, `UiSpinner` (loading glyph),
|
|
312
|
+
`UiToast` (transient message stack), `UiBanner` (full-width status strip)
|
|
311
313
|
|
|
312
314
|
**Layout & display** — `UiCard` (the surface primitive, with interactive and highlighted states),
|
|
313
315
|
`UiSectionHeading` (eyebrow / heading / standfirst), `UiBreadcrumb`, `UiIconTile` (tinted icon tile),
|
|
314
|
-
`
|
|
316
|
+
`UiTable` (data table with a built-in comparison mode), `UiCodeBlock` (copyable snippet), `UiListMenu`,
|
|
317
|
+
`UiListMenuItem`, `UiDivider`, `UiAvatar`, `UiKbd`, `UiIcon`
|
|
315
318
|
|
|
316
319
|
External classes always win. `UiButton` merges them with
|
|
317
320
|
[tailwind-merge](https://github.com/dcastil/tailwind-merge), so `class="bg-gray-100"` genuinely
|
|
@@ -384,7 +387,7 @@ app.use(NumoriUI, {
|
|
|
384
387
|
})
|
|
385
388
|
```
|
|
386
389
|
|
|
387
|
-
Registers all
|
|
390
|
+
Registers all 39 components, and bundles all of them — reach for `createNumoriUI` when that matters:
|
|
388
391
|
|
|
389
392
|
```js
|
|
390
393
|
app.use(createNumoriUI({ UiButton, UiModal }, { icons: { component: MyIcon } }))
|
|
@@ -418,7 +421,7 @@ into the component on the source path but emit a _second_ CSS file on the bundle
|
|
|
418
421
|
with one CSS import in some setups and two in others.
|
|
419
422
|
|
|
420
423
|
**SSR-safe.** Numori Notes is a client-only SPA and never exercised server rendering, so the
|
|
421
|
-
extraction fixed several components that touched `document` or `window` during setup. All
|
|
424
|
+
extraction fixed several components that touched `document` or `window` during setup. All 38 render
|
|
422
425
|
under strict SSR with no DOM globals, verified on every build.
|
|
423
426
|
|
|
424
427
|
## Development
|
|
@@ -460,8 +463,10 @@ that outgrows the codemod fails loudly instead of shipping broken.
|
|
|
460
463
|
## Changelog
|
|
461
464
|
|
|
462
465
|
See [CHANGELOG.md](./CHANGELOG.md) for the release history. The current release is
|
|
463
|
-
**0.
|
|
464
|
-
`
|
|
466
|
+
**0.4.0**, a consolidation-and-polish release: `UiButtonsGroup` folds into `UiSegmented` and
|
|
467
|
+
`UiComparisonTable` into a general `UiTable`, `UiButton` shapes are trimmed to `round` / `pill` /
|
|
468
|
+
`square`, and a class of SSR hydration bugs is fixed. It is a breaking release — see the changelog
|
|
469
|
+
for migration notes.
|
|
465
470
|
|
|
466
471
|
## Licence and attribution
|
|
467
472
|
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, withCtx, withModifiers } from "vue";
|
|
3
|
+
//#region src/components/Banner.vue
|
|
4
|
+
var _hoisted_1 = ["aria-label"];
|
|
5
|
+
var _hoisted_2 = ["aria-label"];
|
|
6
|
+
var _sfc_main = {
|
|
7
|
+
__name: "Banner",
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the banner is shown. Drive this from the condition it reports;
|
|
11
|
+
* toggling it runs the slide-in / collapse-out transition.
|
|
12
|
+
* @type {boolean}
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
show: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: false
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Colour of the bar.
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @default 'info'
|
|
23
|
+
* @values 'info' | 'success' | 'warning' | 'error' | 'neutral'
|
|
24
|
+
*/
|
|
25
|
+
color: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: "info"
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Optional MDI icon shown before the message.
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @default ''
|
|
33
|
+
*/
|
|
34
|
+
icon: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: ""
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Message text. Ignored when the default slot is used.
|
|
40
|
+
* @type {string}
|
|
41
|
+
* @default ''
|
|
42
|
+
*/
|
|
43
|
+
message: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: ""
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* Makes the whole bar a button that emits `click`.
|
|
49
|
+
* @type {boolean}
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
clickable: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Adds a close control that emits `dismiss`.
|
|
58
|
+
* @type {boolean}
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
dismissible: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Accessible label for the dismiss control.
|
|
67
|
+
* @type {string}
|
|
68
|
+
* @default 'Dismiss'
|
|
69
|
+
*/
|
|
70
|
+
dismissLabel: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: "Dismiss"
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Pads for the top safe-area inset, for a banner pinned to the top of the
|
|
76
|
+
* screen. Turn off when the banner sits lower in the layout.
|
|
77
|
+
* @type {boolean}
|
|
78
|
+
* @default true
|
|
79
|
+
*/
|
|
80
|
+
safeArea: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
default: true
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
emits: ["click", "dismiss"],
|
|
86
|
+
setup(__props, { emit: __emit }) {
|
|
87
|
+
/**
|
|
88
|
+
* UiBanner — a full-width status strip that slides in above the content.
|
|
89
|
+
*
|
|
90
|
+
* The shape shared by "you're offline", "your email isn't verified" and "a new
|
|
91
|
+
* version is available": a thin, edge-to-edge bar that expands into view, states
|
|
92
|
+
* one thing with an optional icon, and collapses away when the condition clears.
|
|
93
|
+
* Mount it permanently and drive `show` from the condition; the height/opacity
|
|
94
|
+
* transition does the appearing and disappearing.
|
|
95
|
+
*
|
|
96
|
+
* It sits at the top of the layout, so it honours the top safe-area inset by
|
|
97
|
+
* default — on a notched phone the padding keeps the text out from under the
|
|
98
|
+
* status bar. Turn `safeArea` off for a banner that is not at the very top.
|
|
99
|
+
*
|
|
100
|
+
* Two optional affordances: `clickable` turns the whole bar into a button (for
|
|
101
|
+
* "tap here to verify"), and `dismissible` adds a close control. They emit
|
|
102
|
+
* `click` and `dismiss` respectively — the parent decides what those mean.
|
|
103
|
+
*
|
|
104
|
+
* Colour is a small semantic set rather than free-form, so banners stay
|
|
105
|
+
* consistent across apps; pass `bg-*`/`text-*` classes to step outside it.
|
|
106
|
+
*
|
|
107
|
+
* @example Offline notice
|
|
108
|
+
* <UiBanner :show="offline" color="warning" icon="mdi:wifi-off"
|
|
109
|
+
* message="You're offline — changes will sync when you reconnect" />
|
|
110
|
+
*
|
|
111
|
+
* @example Tappable call to action
|
|
112
|
+
* <UiBanner :show="!verified" color="info" icon="mdi:email-alert-outline"
|
|
113
|
+
* clickable message="Your email is not verified — tap here to verify"
|
|
114
|
+
* @click="openVerify" />
|
|
115
|
+
*/
|
|
116
|
+
const props = __props;
|
|
117
|
+
const emit = __emit;
|
|
118
|
+
/**
|
|
119
|
+
* Banner colours come from the design tokens so a rebrand carries through.
|
|
120
|
+
* `info` uses the primary ramp; `neutral` is the surface grey.
|
|
121
|
+
*/
|
|
122
|
+
const COLORS = {
|
|
123
|
+
info: "bg-primary-600 dark:bg-primary-700 text-white",
|
|
124
|
+
success: "bg-success-600 dark:bg-success-700 text-white",
|
|
125
|
+
warning: "bg-warning-500 dark:bg-warning-600 text-white",
|
|
126
|
+
error: "bg-error-600 dark:bg-error-700 text-white",
|
|
127
|
+
neutral: "bg-gray-800 dark:bg-gray-700 text-white"
|
|
128
|
+
};
|
|
129
|
+
const colorClass = computed(() => COLORS[props.color] || COLORS.info);
|
|
130
|
+
return (_ctx, _cache) => {
|
|
131
|
+
return openBlock(), createBlock(Transition, {
|
|
132
|
+
"enter-active-class": "transition-all duration-300 ease-out",
|
|
133
|
+
"enter-from-class": "max-h-0 opacity-0",
|
|
134
|
+
"enter-to-class": "max-h-24 opacity-100",
|
|
135
|
+
"leave-active-class": "transition-all duration-200 ease-in",
|
|
136
|
+
"leave-from-class": "max-h-24 opacity-100",
|
|
137
|
+
"leave-to-class": "max-h-0 opacity-0"
|
|
138
|
+
}, {
|
|
139
|
+
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
140
|
+
key: 0,
|
|
141
|
+
class: normalizeClass(["relative w-full shrink-0 overflow-hidden text-xs font-medium", colorClass.value]),
|
|
142
|
+
style: normalizeStyle(__props.safeArea ? { paddingTop: "env(safe-area-inset-top, 0px)" } : void 0),
|
|
143
|
+
role: "status"
|
|
144
|
+
}, [__props.clickable ? (openBlock(), createElementBlock("button", {
|
|
145
|
+
key: 0,
|
|
146
|
+
type: "button",
|
|
147
|
+
class: "absolute inset-0 z-0 cursor-pointer",
|
|
148
|
+
"aria-label": __props.message || void 0,
|
|
149
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("click"))
|
|
150
|
+
}, null, 8, _hoisted_1)) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass(["relative z-10 flex items-center justify-center gap-2 px-4 py-1.5", __props.clickable ? "pointer-events-none" : ""]) }, [
|
|
151
|
+
__props.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
152
|
+
key: 0,
|
|
153
|
+
name: __props.icon,
|
|
154
|
+
class: "w-3.5 h-3.5 shrink-0"
|
|
155
|
+
}, null, 8, ["name"])) : createCommentVNode("", true),
|
|
156
|
+
createElementVNode("span", null, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.message), 1)])]),
|
|
157
|
+
__props.dismissible ? (openBlock(), createElementBlock("button", {
|
|
158
|
+
key: 1,
|
|
159
|
+
type: "button",
|
|
160
|
+
class: "pointer-events-auto absolute right-3 inline-flex items-center opacity-80 hover:opacity-100",
|
|
161
|
+
"aria-label": __props.dismissLabel,
|
|
162
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(($event) => emit("dismiss"), ["stop"]))
|
|
163
|
+
}, [createVNode(_sfc_main$1, {
|
|
164
|
+
name: "mdi:close",
|
|
165
|
+
class: "w-3.5 h-3.5"
|
|
166
|
+
})], 8, _hoisted_2)) : createCommentVNode("", true)
|
|
167
|
+
], 2)], 6)) : createCommentVNode("", true)]),
|
|
168
|
+
_: 3
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
//#endregion
|
|
174
|
+
export { _sfc_main as default };
|
|
175
|
+
|
|
176
|
+
//# sourceMappingURL=Banner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Banner.js","names":[],"sources":["../../src/components/Banner.vue"],"sourcesContent":["<template>\n <Transition\n enter-active-class=\"transition-all duration-300 ease-out\"\n enter-from-class=\"max-h-0 opacity-0\"\n enter-to-class=\"max-h-24 opacity-100\"\n leave-active-class=\"transition-all duration-200 ease-in\"\n leave-from-class=\"max-h-24 opacity-100\"\n leave-to-class=\"max-h-0 opacity-0\"\n >\n <div\n v-if=\"show\"\n class=\"relative w-full shrink-0 overflow-hidden text-xs font-medium\"\n :class=\"colorClass\"\n :style=\"safeArea ? { paddingTop: 'env(safe-area-inset-top, 0px)' } : undefined\"\n role=\"status\"\n >\n <!-- Whole-banner click target as a full-cover button that is a *sibling*\n of the dismiss button, never its ancestor. Nesting a <button> inside\n a <button> is invalid HTML: the browser restructures it, so the\n hydrated DOM would no longer match the server markup. -->\n <button\n v-if=\"clickable\"\n type=\"button\"\n class=\"absolute inset-0 z-0 cursor-pointer\"\n :aria-label=\"message || undefined\"\n @click=\"emit('click')\"\n />\n <div\n class=\"relative z-10 flex items-center justify-center gap-2 px-4 py-1.5\"\n :class=\"clickable ? 'pointer-events-none' : ''\"\n >\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-3.5 h-3.5 shrink-0\" />\n <span\n ><slot>{{ message }}</slot></span\n >\n\n <button\n v-if=\"dismissible\"\n type=\"button\"\n class=\"pointer-events-auto absolute right-3 inline-flex items-center opacity-80 hover:opacity-100\"\n :aria-label=\"dismissLabel\"\n @click.stop=\"emit('dismiss')\"\n >\n <UiIcon name=\"mdi:close\" class=\"w-3.5 h-3.5\" />\n </button>\n </div>\n </div>\n </Transition>\n</template>\n\n<script setup>\n/**\n * UiBanner — a full-width status strip that slides in above the content.\n *\n * The shape shared by \"you're offline\", \"your email isn't verified\" and \"a new\n * version is available\": a thin, edge-to-edge bar that expands into view, states\n * one thing with an optional icon, and collapses away when the condition clears.\n * Mount it permanently and drive `show` from the condition; the height/opacity\n * transition does the appearing and disappearing.\n *\n * It sits at the top of the layout, so it honours the top safe-area inset by\n * default — on a notched phone the padding keeps the text out from under the\n * status bar. Turn `safeArea` off for a banner that is not at the very top.\n *\n * Two optional affordances: `clickable` turns the whole bar into a button (for\n * \"tap here to verify\"), and `dismissible` adds a close control. They emit\n * `click` and `dismiss` respectively — the parent decides what those mean.\n *\n * Colour is a small semantic set rather than free-form, so banners stay\n * consistent across apps; pass `bg-*`/`text-*` classes to step outside it.\n *\n * @example Offline notice\n * <UiBanner :show=\"offline\" color=\"warning\" icon=\"mdi:wifi-off\"\n * message=\"You're offline — changes will sync when you reconnect\" />\n *\n * @example Tappable call to action\n * <UiBanner :show=\"!verified\" color=\"info\" icon=\"mdi:email-alert-outline\"\n * clickable message=\"Your email is not verified — tap here to verify\"\n * @click=\"openVerify\" />\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Whether the banner is shown. Drive this from the condition it reports;\n * toggling it runs the slide-in / collapse-out transition.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Colour of the bar.\n * @type {string}\n * @default 'info'\n * @values 'info' | 'success' | 'warning' | 'error' | 'neutral'\n */\n color: { type: String, default: 'info' },\n\n /**\n * Optional MDI icon shown before the message.\n * @type {string}\n * @default ''\n */\n icon: { type: String, default: '' },\n\n /**\n * Message text. Ignored when the default slot is used.\n * @type {string}\n * @default ''\n */\n message: { type: String, default: '' },\n\n /**\n * Makes the whole bar a button that emits `click`.\n * @type {boolean}\n * @default false\n */\n clickable: { type: Boolean, default: false },\n\n /**\n * Adds a close control that emits `dismiss`.\n * @type {boolean}\n * @default false\n */\n dismissible: { type: Boolean, default: false },\n\n /**\n * Accessible label for the dismiss control.\n * @type {string}\n * @default 'Dismiss'\n */\n dismissLabel: { type: String, default: 'Dismiss' },\n\n /**\n * Pads for the top safe-area inset, for a banner pinned to the top of the\n * screen. Turn off when the banner sits lower in the layout.\n * @type {boolean}\n * @default true\n */\n safeArea: { type: Boolean, default: true },\n})\n\nconst emit = defineEmits(['click', 'dismiss'])\n\n/**\n * Banner colours come from the design tokens so a rebrand carries through.\n * `info` uses the primary ramp; `neutral` is the surface grey.\n */\nconst COLORS = {\n info: 'bg-primary-600 dark:bg-primary-700 text-white',\n success: 'bg-success-600 dark:bg-success-700 text-white',\n warning: 'bg-warning-500 dark:bg-warning-600 text-white',\n error: 'bg-error-600 dark:bg-error-700 text-white',\n neutral: 'bg-gray-800 dark:bg-gray-700 text-white',\n}\n\nconst colorClass = computed(() => COLORS[props.color] || COLORS.info)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmFA,MAAM,QAAQ;EA6Dd,MAAM,OAAO;;;;;EAMb,MAAM,SAAS;GACb,MAAM;GACN,SAAS;GACT,SAAS;GACT,OAAO;GACP,SAAS;EACX;EAEA,MAAM,aAAa,eAAe,OAAO,MAAM,UAAU,OAAO,IAAI;;GA7JlE,OAAA,UAAA,GAAA,YA8Ca,YAAA;IA7CX,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAEf,SAAA,cAqCM,CApCE,QAAA,QADR,UAAA,GAAA,mBAqCM,OAAA;;KAnCJ,OAAK,eAAA,CAAC,gEACE,WAAA,KAAU,CAAA;KACjB,OAAK,eAAE,QAAA,WAAQ,EAAA,YAAA,gCAAA,IAAqD,KAAA,CAAS;KAC9E,MAAK;IAOG,GAAA,CAAA,QAAA,aADR,UAAA,GAAA,mBAME,UAAA;;KAJA,MAAK;KACL,OAAM;KACL,cAAY,QAAA,WAAW,KAAA;KACvB,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,OAAA;IAEd,GAAA,MAAA,GAAA,UAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,mBAkBM,OAAA,EAjBJ,OAAK,eAAA,CAAC,oEACE,QAAA,YAAS,wBAAA,EAAA,CAAA,EAAA,GAAA;KAEH,QAAA,QAAd,UAAA,GAAA,YAAgE,aAAA;;MAA3C,MAAM,QAAA;MAAM,OAAM;;KACvC,mBAEC,QAAA,MAAA,CADE,WAA0B,KAAA,QAAA,WAAA,CAAA,SAAA,CAAjB,gBAAA,gBAAA,QAAA,OAAO,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;KAIX,QAAA,eADR,UAAA,GAAA,mBAQS,UAAA;;MANP,MAAK;MACL,OAAM;MACL,cAAY,QAAA;MACZ,SAAK,OAAA,OAAA,OAAA,KAAA,eAAA,WAAO,KAAI,SAAA,GAAA,CAAA,MAAA,CAAA;KAEjB,GAAA,CAAA,YAA+C,aAAA;MAAvC,MAAK;MAAY,OAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
3
|
+
import { computed, createBlock, mergeProps, normalizeClass, openBlock, renderSlot, resolveDynamicComponent, unref, withCtx } from "vue";
|
|
4
4
|
//#region src/components/Button.vue
|
|
5
5
|
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
6
6
|
__name: "Button",
|
|
@@ -63,10 +63,11 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
63
63
|
default: "md"
|
|
64
64
|
},
|
|
65
65
|
/**
|
|
66
|
-
* Border-radius shape of the button
|
|
66
|
+
* Border-radius shape of the button, matching `UiSegmented`'s `shape`.
|
|
67
|
+
* For a circular icon button, combine `shape="pill"` with `icon-only`.
|
|
67
68
|
* @type {string}
|
|
68
69
|
* @default 'round'
|
|
69
|
-
* @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none)
|
|
70
|
+
* @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none)
|
|
70
71
|
*/
|
|
71
72
|
shape: {
|
|
72
73
|
type: String,
|
|
@@ -253,13 +254,11 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
253
254
|
return map[props.size] || map.md;
|
|
254
255
|
});
|
|
255
256
|
const shapeClasses = computed(() => {
|
|
256
|
-
if (isInlineVariant.value) return "";
|
|
257
|
+
if (isInlineVariant.value) return "rounded-lg";
|
|
257
258
|
const map = {
|
|
258
259
|
round: "rounded-lg",
|
|
259
260
|
pill: "rounded-full",
|
|
260
|
-
square: "rounded-none"
|
|
261
|
-
circle: "rounded-full",
|
|
262
|
-
none: ""
|
|
261
|
+
square: "rounded-none"
|
|
263
262
|
};
|
|
264
263
|
return map[props.shape] || map.round;
|
|
265
264
|
});
|
|
@@ -360,15 +359,7 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
360
359
|
if (props.disabled || props.loading) return "opacity-50 cursor-not-allowed pointer-events-none";
|
|
361
360
|
return "cursor-pointer";
|
|
362
361
|
});
|
|
363
|
-
const
|
|
364
|
-
const restAttrs = computed(() => {
|
|
365
|
-
const { class: _, ...rest } = attrs;
|
|
366
|
-
return rest;
|
|
367
|
-
});
|
|
368
|
-
const mergedClasses = computed(() => {
|
|
369
|
-
const externalClass = attrs.class || "";
|
|
370
|
-
return twMerge(internalClasses.value, externalClass);
|
|
371
|
-
});
|
|
362
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value);
|
|
372
363
|
const internalClasses = computed(() => {
|
|
373
364
|
const base = "inline-flex items-center transition-colors select-none";
|
|
374
365
|
const justify = isInlineVariant.value ? "" : "justify-center";
|
|
@@ -395,13 +386,13 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
395
386
|
type: isButton.value ? __props.nativeType : void 0,
|
|
396
387
|
disabled: isButton.value ? __props.disabled || __props.loading : void 0,
|
|
397
388
|
href: __props.tag === "a" ? __props.href : void 0,
|
|
398
|
-
class: mergedClasses
|
|
389
|
+
class: unref(mergedClasses),
|
|
399
390
|
title: __props.title,
|
|
400
391
|
"aria-label": __props.ariaLabel,
|
|
401
392
|
"aria-checked": __props.ariaChecked,
|
|
402
393
|
role: __props.role,
|
|
403
394
|
tabindex: __props.tabindex
|
|
404
|
-
}, restAttrs
|
|
395
|
+
}, unref(restAttrs)), {
|
|
405
396
|
default: withCtx(() => [__props.loading && __props.loadingStyle === "spinner" ? (openBlock(), createBlock(_sfc_main$1, {
|
|
406
397
|
key: 0,
|
|
407
398
|
name: spinnerIcon.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":[],"sources":["../../src/components/Button.vue"],"sourcesContent":["<template>\n <!-- Dynamic root element — renders as button, anchor, or any tag via :is -->\n <component\n :is=\"tag\"\n :type=\"isButton ? nativeType : undefined\"\n :disabled=\"isButton ? disabled || loading : undefined\"\n :href=\"tag === 'a' ? href : undefined\"\n :class=\"mergedClasses\"\n :title=\"title\"\n :aria-label=\"ariaLabel\"\n :aria-checked=\"ariaChecked\"\n :role=\"role\"\n :tabindex=\"tabindex\"\n v-bind=\"restAttrs\"\n >\n <!-- Loading state: spinner replaces slot content (default) -->\n <template v-if=\"loading && loadingStyle === 'spinner'\">\n <UiIcon :name=\"spinnerIcon\" class=\"animate-spin\" :class=\"spinnerSizeClass\" />\n </template>\n <!-- Default slot: button label, icons, or any child content -->\n <slot v-else :spinning=\"loading && loadingStyle === 'icon'\" />\n </component>\n</template>\n\n<script setup>\n/**\n * UiButton — Versatile button component with multiple variants, colors, sizes, and shapes.\n *\n * Supports rendering as any HTML element (button, anchor, div), eight visual variants\n * (solid, outline, ghost, dashed, text, link, menu-item, list-item), six color themes,\n * five sizes, and five shape options. Includes loading state with a configurable spinner,\n * icon-only mode, block/full-width layout, and full accessibility attribute support.\n * External Tailwind classes are merged via `tailwind-merge` so they can override internals.\n *\n * @example Basic solid button\n * <UiButton @click=\"save\">Save</UiButton>\n *\n * @example Ghost icon button\n * <UiButton variant=\"ghost\" color=\"gray\" icon-only>\n * <UiIcon name=\"mdi:close\" class=\"w-5 h-5\" />\n * </UiButton>\n *\n * @example Outline danger button with loading\n * <UiButton variant=\"outline\" color=\"red\" :loading=\"isSaving\">Delete</UiButton>\n *\n * @example Menu item in a dropdown\n * <UiButton variant=\"menu-item\" color=\"red\">\n * <UiIcon name=\"mdi:trash-can-outline\" class=\"w-4 h-4\" /> Delete\n * </UiButton>\n *\n * @example Anchor link\n * <UiButton tag=\"a\" variant=\"link\" href=\"/docs\">Read docs</UiButton>\n *\n * @slot default — Button content (label text, icons, or any child elements)\n */\nimport { computed, useAttrs } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { twMerge } from 'tailwind-merge'\nconst props = defineProps({\n /**\n * HTML element tag to render.\n * @type {string}\n * @default 'button'\n * @values 'button' | 'a' | 'div' | any valid HTML tag\n */\n tag: { type: String, default: 'button' },\n\n /**\n * Native button `type` attribute (only applied when tag is 'button').\n * @type {string}\n * @default 'button'\n * @values 'button' | 'submit' | 'reset'\n */\n nativeType: { type: String, default: 'button' },\n\n /**\n * Visual variant controlling background, border, and hover styles.\n * - 'solid' — filled background with shadow\n * - 'outline' — transparent with colored border\n * - 'ghost' — transparent, colored on hover\n * - 'dashed' — dashed border, transparent background\n * - 'text' — plain text, underline on hover\n * - 'link' — inline link style, no padding\n * - 'menu-item' — full-width row for dropdown menus\n * - 'list-item' — full-width row for settings lists\n * @type {string}\n * @default 'solid'\n */\n variant: { type: String, default: 'solid' },\n\n /**\n * Color theme key mapped to Tailwind color scales.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray' | 'red' | 'green' | 'amber' | 'white'\n */\n color: { type: String, default: 'primary' },\n\n /**\n * Button size controlling padding, font size, and gap.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Border-radius shape of the button.\n * @type {string}\n * @default 'round'\n * @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none) | 'circle' (rounded-full) | 'none'\n */\n shape: { type: String, default: 'round' },\n\n /**\n * Disabled state — visually dims the button and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Loading state — replaces slot content with a spinner and disables the button.\n * @type {boolean}\n * @default false\n */\n loading: { type: Boolean, default: false },\n\n /**\n * Loading visual style.\n * - 'spinner': replaces slot content with a spinner icon (default)\n * - 'icon': keeps slot content visible, exposes `spinning` slot prop for the icon\n * @type {string}\n * @default 'spinner'\n */\n loadingStyle: { type: String, default: 'spinner' },\n\n /**\n * MDI icon name for the loading spinner.\n * @type {string}\n * @default 'mdi:loading'\n */\n spinner: { type: String, default: 'mdi:loading' },\n\n /**\n * Block mode — makes the button full-width (w-full).\n * @type {boolean}\n * @default false\n */\n block: { type: Boolean, default: false },\n\n /**\n * Icon-only mode — uses equal padding on all sides for a square/circle button.\n * @type {boolean}\n * @default false\n */\n iconOnly: { type: Boolean, default: false },\n\n /**\n * URL for anchor tags (only applied when tag is 'a').\n * @type {string}\n * @default undefined\n */\n href: { type: String, default: undefined },\n\n /**\n * Native `title` attribute for hover tooltip.\n * @type {string}\n * @default undefined\n */\n title: { type: String, default: undefined },\n\n /**\n * Accessible label for screen readers.\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * ARIA checked state for toggle-style buttons.\n * @type {string | boolean}\n * @default undefined\n */\n ariaChecked: { type: [String, Boolean], default: undefined },\n\n /**\n * ARIA role override (e.g. 'switch', 'tab').\n * @type {string}\n * @default undefined\n */\n role: { type: String, default: undefined },\n\n /**\n * Tab index for keyboard navigation order.\n * @type {string | number}\n * @default undefined\n */\n tabindex: { type: [String, Number], default: undefined },\n})\n\ndefineOptions({ inheritAttrs: false })\n\n// Determine element type and variant category for conditional attribute binding\nconst isButton = computed(() => props.tag === 'button')\nconst isMenuItem = computed(() => props.variant === 'menu-item')\nconst isListItem = computed(() => props.variant === 'list-item')\n// Menu-item and list-item variants share full-width, left-aligned layout behavior\nconst isInlineVariant = computed(() => isMenuItem.value || isListItem.value)\n\nconst spinnerIcon = computed(() => props.spinner)\n\nconst spinnerSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-3.5 h-3.5', md: 'w-4 h-4', lg: 'w-5 h-5', xl: 'w-6 h-6' }\n return map[props.size] || map.md\n})\n\n// ── Size classes ──────────────────────────────────────────\nconst sizeClasses = computed(() => {\n if (isMenuItem.value) return 'px-3 py-1.5 text-sm gap-2'\n if (isListItem.value) return 'px-3.5 py-2.5 text-sm gap-3'\n if (props.iconOnly) {\n const map = { xs: 'p-1', sm: 'p-1.5', md: 'p-2', lg: 'p-2.5', xl: 'p-3' }\n return map[props.size] || map.md\n }\n const map = {\n xs: 'px-2 py-1 text-xs gap-1',\n sm: 'px-2.5 py-1.5 text-xs gap-1.5',\n md: 'px-4 py-2 text-sm gap-2',\n lg: 'px-5 py-2.5 text-sm gap-2',\n xl: 'px-6 py-3 text-base gap-2.5',\n }\n return map[props.size] || map.md\n})\n\n// ── Shape classes ─────────────────────────────────────────\nconst shapeClasses = computed(() => {\n if (isInlineVariant.value) return ''\n const map = {\n round: 'rounded-lg',\n pill: 'rounded-full',\n square: 'rounded-none',\n circle: 'rounded-full',\n none: '',\n }\n return map[props.shape] || map.round\n})\n\n// ── Colour × Variant matrix ──────────────────────────────\n// Each variant defines its own color map. Menu-item and list-item default\n// to gray when color is 'primary' since they sit inside neutral containers.\nconst colorVariantClasses = computed(() => {\n const v = props.variant\n const c = props.color\n\n // Menu item — no bg, no rounding, consistent hover. Defaults to gray text.\n if (v === 'menu-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/30',\n green: 'text-success-600 dark:text-success-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[effectiveColor] || map.gray\n }\n\n // List item — settings list rows. Defaults to gray text.\n if (v === 'list-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-200/50 dark:hover:bg-red-800/30',\n green:\n 'text-success-600 dark:text-success-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n }\n return map[effectiveColor] || map.gray\n }\n\n // Solid\n if (v === 'solid') {\n const map = {\n primary: 'bg-primary-600 hover:bg-primary-700 text-white shadow-sm hover:shadow-md',\n gray: 'bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300',\n red: 'bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-md',\n green: 'bg-success-600 hover:bg-success-700 text-white shadow-sm hover:shadow-md',\n amber: 'bg-amber-600 hover:bg-amber-700 text-white shadow-sm hover:shadow-md',\n white:\n 'bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-900 dark:text-gray-200 shadow-sm',\n }\n return map[c] || map.primary\n }\n\n // Outline\n if (v === 'outline') {\n const map = {\n primary:\n 'border border-primary-500 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Dashed\n if (v === 'dashed') {\n const map = {\n primary:\n 'border border-dashed border-primary-400 dark:border-primary-600 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-dashed border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-dashed border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-dashed border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Ghost\n if (v === 'ghost') {\n const map = {\n primary:\n 'text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Text\n if (v === 'text') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 bg-transparent hover:underline',\n gray: 'text-gray-600 dark:text-gray-400 bg-transparent hover:underline',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:underline',\n green: 'text-success-600 dark:text-success-400 bg-transparent hover:underline',\n amber: 'text-amber-600 dark:text-amber-400 bg-transparent hover:underline',\n white: 'text-gray-700 dark:text-gray-300 bg-transparent hover:underline',\n }\n return map[c] || map.primary\n }\n\n // Link\n if (v === 'link') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 hover:underline p-0',\n gray: 'text-gray-500 dark:text-gray-400 hover:underline p-0',\n red: 'text-red-600 dark:text-red-400 hover:underline p-0',\n green: 'text-success-600 dark:text-success-400 hover:underline p-0',\n amber: 'text-amber-600 dark:text-amber-400 hover:underline p-0',\n white: 'text-gray-700 dark:text-gray-300 hover:underline p-0',\n }\n return map[c] || map.primary\n }\n\n return ''\n})\n\n// ── Disabled / loading classes ────────────────────────────\nconst stateClasses = computed(() => {\n if (props.disabled || props.loading) {\n return 'opacity-50 cursor-not-allowed pointer-events-none'\n }\n return 'cursor-pointer'\n})\n\n// ── Merge with external classes (external wins via twMerge) ──\nconst attrs = useAttrs()\n\nconst restAttrs = computed(() => {\n const { class: _, ...rest } = attrs\n return rest\n})\n\nconst mergedClasses = computed(() => {\n const externalClass = attrs.class || ''\n return twMerge(internalClasses.value, externalClass)\n})\n\n// ── Assembled internal classes ────────────────────────────\nconst internalClasses = computed(() => {\n const base = 'inline-flex items-center transition-colors select-none'\n const justify = isInlineVariant.value ? '' : 'justify-center'\n const blockClass = props.block || isInlineVariant.value ? 'w-full' : ''\n const weight = ['ghost', 'text', 'link', 'menu-item', 'list-item'].includes(props.variant)\n ? ''\n : 'font-medium'\n return [\n base,\n justify,\n weight,\n sizeClasses.value,\n shapeClasses.value,\n colorVariantClasses.value,\n stateClasses.value,\n blockClass,\n ]\n .filter(Boolean)\n .join(' ')\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DA,MAAM,QAAQ;EAkJd,MAAM,WAAW,eAAe,MAAM,QAAQ,QAAQ;EACtD,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAC/D,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAE/D,MAAM,kBAAkB,eAAe,WAAW,SAAS,WAAW,KAAK;EAE3E,MAAM,cAAc,eAAe,MAAM,OAAO;EAEhD,MAAM,mBAAmB,eAAe;GACtC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAe,IAAI;IAAW,IAAI;IAAW,IAAI;GAAU;GAC5F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,cAAc,eAAe;GACjC,IAAI,WAAW,OAAO,OAAO;GAC7B,IAAI,WAAW,OAAO,OAAO;GAC7B,IAAI,MAAM,UAAU;IAClB,MAAM,MAAM;KAAE,IAAI;KAAO,IAAI;KAAS,IAAI;KAAO,IAAI;KAAS,IAAI;IAAM;IACxE,OAAO,IAAI,MAAM,SAAS,IAAI;GAChC;GACA,MAAM,MAAM;IACV,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;GACN;GACA,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,eAAe,eAAe;GAClC,IAAI,gBAAgB,OAAO,OAAO;GAClC,MAA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;IAGjB,SAAA,cAEW,CAFK,QAAA,WAAW,QAAA,iBAAY,aACrC,UAAA,GAAA,YAA6E,aAAA;;KAApE,MAAM,YAAA;KAAa,OAAK,eAAA,CAAC,gBAAuB,iBAAA,KAAgB,CAAA;IAG3E,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,WAA8D,KAAA,QAAA,WAAA,EAAhD,UAAU,QAAA,WAAW,QAAA,iBAAY,OAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../src/components/Button.vue"],"sourcesContent":["<template>\n <!-- Dynamic root element — renders as button, anchor, or any tag via :is -->\n <component\n :is=\"tag\"\n :type=\"isButton ? nativeType : undefined\"\n :disabled=\"isButton ? disabled || loading : undefined\"\n :href=\"tag === 'a' ? href : undefined\"\n :class=\"mergedClasses\"\n :title=\"title\"\n :aria-label=\"ariaLabel\"\n :aria-checked=\"ariaChecked\"\n :role=\"role\"\n :tabindex=\"tabindex\"\n v-bind=\"restAttrs\"\n >\n <!-- Loading state: spinner replaces slot content (default) -->\n <template v-if=\"loading && loadingStyle === 'spinner'\">\n <UiIcon :name=\"spinnerIcon\" class=\"animate-spin\" :class=\"spinnerSizeClass\" />\n </template>\n <!-- Default slot: button label, icons, or any child content -->\n <slot v-else :spinning=\"loading && loadingStyle === 'icon'\" />\n </component>\n</template>\n\n<script setup>\n/**\n * UiButton — Versatile button component with multiple variants, colors, sizes, and shapes.\n *\n * Supports rendering as any HTML element (button, anchor, div), eight visual variants\n * (solid, outline, ghost, dashed, text, link, menu-item, list-item), six color themes,\n * five sizes, and five shape options. Includes loading state with a configurable spinner,\n * icon-only mode, block/full-width layout, and full accessibility attribute support.\n * External Tailwind classes are merged via `tailwind-merge` so they can override internals.\n *\n * @example Basic solid button\n * <UiButton @click=\"save\">Save</UiButton>\n *\n * @example Ghost icon button\n * <UiButton variant=\"ghost\" color=\"gray\" icon-only>\n * <UiIcon name=\"mdi:close\" class=\"w-5 h-5\" />\n * </UiButton>\n *\n * @example Outline danger button with loading\n * <UiButton variant=\"outline\" color=\"red\" :loading=\"isSaving\">Delete</UiButton>\n *\n * @example Menu item in a dropdown\n * <UiButton variant=\"menu-item\" color=\"red\">\n * <UiIcon name=\"mdi:trash-can-outline\" class=\"w-4 h-4\" /> Delete\n * </UiButton>\n *\n * @example Anchor link\n * <UiButton tag=\"a\" variant=\"link\" href=\"/docs\">Read docs</UiButton>\n *\n * @slot default — Button content (label text, icons, or any child elements)\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\nconst props = defineProps({\n /**\n * HTML element tag to render.\n * @type {string}\n * @default 'button'\n * @values 'button' | 'a' | 'div' | any valid HTML tag\n */\n tag: { type: String, default: 'button' },\n\n /**\n * Native button `type` attribute (only applied when tag is 'button').\n * @type {string}\n * @default 'button'\n * @values 'button' | 'submit' | 'reset'\n */\n nativeType: { type: String, default: 'button' },\n\n /**\n * Visual variant controlling background, border, and hover styles.\n * - 'solid' — filled background with shadow\n * - 'outline' — transparent with colored border\n * - 'ghost' — transparent, colored on hover\n * - 'dashed' — dashed border, transparent background\n * - 'text' — plain text, underline on hover\n * - 'link' — inline link style, no padding\n * - 'menu-item' — full-width row for dropdown menus\n * - 'list-item' — full-width row for settings lists\n * @type {string}\n * @default 'solid'\n */\n variant: { type: String, default: 'solid' },\n\n /**\n * Color theme key mapped to Tailwind color scales.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray' | 'red' | 'green' | 'amber' | 'white'\n */\n color: { type: String, default: 'primary' },\n\n /**\n * Button size controlling padding, font size, and gap.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Border-radius shape of the button, matching `UiSegmented`'s `shape`.\n * For a circular icon button, combine `shape=\"pill\"` with `icon-only`.\n * @type {string}\n * @default 'round'\n * @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none)\n */\n shape: { type: String, default: 'round' },\n\n /**\n * Disabled state — visually dims the button and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Loading state — replaces slot content with a spinner and disables the button.\n * @type {boolean}\n * @default false\n */\n loading: { type: Boolean, default: false },\n\n /**\n * Loading visual style.\n * - 'spinner': replaces slot content with a spinner icon (default)\n * - 'icon': keeps slot content visible, exposes `spinning` slot prop for the icon\n * @type {string}\n * @default 'spinner'\n */\n loadingStyle: { type: String, default: 'spinner' },\n\n /**\n * MDI icon name for the loading spinner.\n * @type {string}\n * @default 'mdi:loading'\n */\n spinner: { type: String, default: 'mdi:loading' },\n\n /**\n * Block mode — makes the button full-width (w-full).\n * @type {boolean}\n * @default false\n */\n block: { type: Boolean, default: false },\n\n /**\n * Icon-only mode — uses equal padding on all sides for a square/circle button.\n * @type {boolean}\n * @default false\n */\n iconOnly: { type: Boolean, default: false },\n\n /**\n * URL for anchor tags (only applied when tag is 'a').\n * @type {string}\n * @default undefined\n */\n href: { type: String, default: undefined },\n\n /**\n * Native `title` attribute for hover tooltip.\n * @type {string}\n * @default undefined\n */\n title: { type: String, default: undefined },\n\n /**\n * Accessible label for screen readers.\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * ARIA checked state for toggle-style buttons.\n * @type {string | boolean}\n * @default undefined\n */\n ariaChecked: { type: [String, Boolean], default: undefined },\n\n /**\n * ARIA role override (e.g. 'switch', 'tab').\n * @type {string}\n * @default undefined\n */\n role: { type: String, default: undefined },\n\n /**\n * Tab index for keyboard navigation order.\n * @type {string | number}\n * @default undefined\n */\n tabindex: { type: [String, Number], default: undefined },\n})\n\ndefineOptions({ inheritAttrs: false })\n\n// Determine element type and variant category for conditional attribute binding\nconst isButton = computed(() => props.tag === 'button')\nconst isMenuItem = computed(() => props.variant === 'menu-item')\nconst isListItem = computed(() => props.variant === 'list-item')\n// Menu-item and list-item variants share full-width, left-aligned layout behavior\nconst isInlineVariant = computed(() => isMenuItem.value || isListItem.value)\n\nconst spinnerIcon = computed(() => props.spinner)\n\nconst spinnerSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-3.5 h-3.5', md: 'w-4 h-4', lg: 'w-5 h-5', xl: 'w-6 h-6' }\n return map[props.size] || map.md\n})\n\n// ── Size classes ──────────────────────────────────────────\nconst sizeClasses = computed(() => {\n if (isMenuItem.value) return 'px-3 py-1.5 text-sm gap-2'\n if (isListItem.value) return 'px-3.5 py-2.5 text-sm gap-3'\n if (props.iconOnly) {\n const map = { xs: 'p-1', sm: 'p-1.5', md: 'p-2', lg: 'p-2.5', xl: 'p-3' }\n return map[props.size] || map.md\n }\n const map = {\n xs: 'px-2 py-1 text-xs gap-1',\n sm: 'px-2.5 py-1.5 text-xs gap-1.5',\n md: 'px-4 py-2 text-sm gap-2',\n lg: 'px-5 py-2.5 text-sm gap-2',\n xl: 'px-6 py-3 text-base gap-2.5',\n }\n return map[props.size] || map.md\n})\n\n// ── Shape classes ─────────────────────────────────────────\nconst shapeClasses = computed(() => {\n // Menu/list rows are full-width, but still round their corners so the hover\n // highlight is a rounded chip rather than a square that pokes past the\n // rounded menu panel around them.\n if (isInlineVariant.value) return 'rounded-lg'\n const map = {\n round: 'rounded-lg',\n pill: 'rounded-full',\n square: 'rounded-none',\n }\n return map[props.shape] || map.round\n})\n\n// ── Colour × Variant matrix ──────────────────────────────\n// Each variant defines its own color map. Menu-item and list-item default\n// to gray when color is 'primary' since they sit inside neutral containers.\nconst colorVariantClasses = computed(() => {\n const v = props.variant\n const c = props.color\n\n // Menu item — no bg, no rounding, consistent hover. Defaults to gray text.\n if (v === 'menu-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/30',\n green: 'text-success-600 dark:text-success-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[effectiveColor] || map.gray\n }\n\n // List item — settings list rows. Defaults to gray text.\n if (v === 'list-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-200/50 dark:hover:bg-red-800/30',\n green:\n 'text-success-600 dark:text-success-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n }\n return map[effectiveColor] || map.gray\n }\n\n // Solid\n if (v === 'solid') {\n const map = {\n primary: 'bg-primary-600 hover:bg-primary-700 text-white shadow-sm hover:shadow-md',\n gray: 'bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300',\n red: 'bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-md',\n green: 'bg-success-600 hover:bg-success-700 text-white shadow-sm hover:shadow-md',\n amber: 'bg-amber-600 hover:bg-amber-700 text-white shadow-sm hover:shadow-md',\n white:\n 'bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-900 dark:text-gray-200 shadow-sm',\n }\n return map[c] || map.primary\n }\n\n // Outline\n if (v === 'outline') {\n const map = {\n primary:\n 'border border-primary-500 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Dashed\n if (v === 'dashed') {\n const map = {\n primary:\n 'border border-dashed border-primary-400 dark:border-primary-600 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-dashed border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-dashed border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-dashed border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Ghost\n if (v === 'ghost') {\n const map = {\n primary:\n 'text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Text\n if (v === 'text') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 bg-transparent hover:underline',\n gray: 'text-gray-600 dark:text-gray-400 bg-transparent hover:underline',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:underline',\n green: 'text-success-600 dark:text-success-400 bg-transparent hover:underline',\n amber: 'text-amber-600 dark:text-amber-400 bg-transparent hover:underline',\n white: 'text-gray-700 dark:text-gray-300 bg-transparent hover:underline',\n }\n return map[c] || map.primary\n }\n\n // Link\n if (v === 'link') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 hover:underline p-0',\n gray: 'text-gray-500 dark:text-gray-400 hover:underline p-0',\n red: 'text-red-600 dark:text-red-400 hover:underline p-0',\n green: 'text-success-600 dark:text-success-400 hover:underline p-0',\n amber: 'text-amber-600 dark:text-amber-400 hover:underline p-0',\n white: 'text-gray-700 dark:text-gray-300 hover:underline p-0',\n }\n return map[c] || map.primary\n }\n\n return ''\n})\n\n// ── Disabled / loading classes ────────────────────────────\nconst stateClasses = computed(() => {\n if (props.disabled || props.loading) {\n return 'opacity-50 cursor-not-allowed pointer-events-none'\n }\n return 'cursor-pointer'\n})\n\n// ── Merge external classes over internals (external wins via twMerge) ──\n// A getter defers reading `internalClasses` until after its declaration below.\nconst { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)\n\n// ── Assembled internal classes ────────────────────────────\nconst internalClasses = computed(() => {\n const base = 'inline-flex items-center transition-colors select-none'\n const justify = isInlineVariant.value ? '' : 'justify-center'\n const blockClass = props.block || isInlineVariant.value ? 'w-full' : ''\n const weight = ['ghost', 'text', 'link', 'menu-item', 'list-item'].includes(props.variant)\n ? ''\n : 'font-medium'\n return [\n base,\n justify,\n weight,\n sizeClasses.value,\n shapeClasses.value,\n colorVariantClasses.value,\n stateClasses.value,\n blockClass,\n ]\n .filter(Boolean)\n .join(' ')\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DA,MAAM,QAAQ;EAmJd,MAAM,WAAW,eAAe,MAAM,QAAQ,QAAQ;EACtD,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAC/D,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAE/D,MAAM,kBAAkB,eAAe,WAAW,SAAS,WAAW,KAAK;EAE3E,MAAM,cAAc,eAAe,MAAM,OAAO;EAEhD,MAAM,mBAAmB,eAAe;GACtC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAe,IAAI;IAAW,IAAI;IAAW,IAAI;GAAU;GAC5F,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EAGD,MAAM,cAAc,eAAe;GACjC,IAAI,WAAW,OAAO,OAAO;GAC7B,IAAI,WAAW,OAAO,OAAO;GAC7B,IAAI,MAAM,UAAU;IAClB,MAAM,MAAM;KAAE,IAAI;KAAO,IAAI;KAAS,IAAI;KAAO,IAAI;KAAS,IAAI;IAAM;IACxE,OAAO,IAAI,MAAM,SAAS,IAAI;GAChC;GACA,MAAM,MAAM;IACV,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;GACN;GACA,OAAO,IAAI,MAAM,SAAS,IAAI;EAChC,CAAC;EA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