numori-ui 0.3.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 +82 -0
- package/README.md +23 -20
- package/dist/components/Banner.js +29 -32
- package/dist/components/Banner.js.map +1 -1
- 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/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/Table.js +174 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/index.js +65 -67
- 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 +1 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +34 -35
- 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 +1 -2
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Banner.vue +20 -9
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +2 -10
- 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/Table.vue +193 -0
- package/src/components/index.js +3 -6
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +1 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +1 -2
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/dist/components/ComparisonTable.js +0 -152
- package/dist/components/ComparisonTable.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
- package/src/components/ComparisonTable.vue +0 -141
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,88 @@ 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
|
+
|
|
10
92
|
## [0.3.0] — 2026-08-31
|
|
11
93
|
|
|
12
94
|
Six new components, bringing the library to 39 components (40 registered tags,
|
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`,
|
|
@@ -312,7 +313,7 @@ built-in validation), `UiSelect` (searchable, groupable, teleported panel), `UiC
|
|
|
312
313
|
|
|
313
314
|
**Layout & display** — `UiCard` (the surface primitive, with interactive and highlighted states),
|
|
314
315
|
`UiSectionHeading` (eyebrow / heading / standfirst), `UiBreadcrumb`, `UiIconTile` (tinted icon tile),
|
|
315
|
-
`
|
|
316
|
+
`UiTable` (data table with a built-in comparison mode), `UiCodeBlock` (copyable snippet), `UiListMenu`,
|
|
316
317
|
`UiListMenuItem`, `UiDivider`, `UiAvatar`, `UiKbd`, `UiIcon`
|
|
317
318
|
|
|
318
319
|
External classes always win. `UiButton` merges them with
|
|
@@ -386,7 +387,7 @@ app.use(NumoriUI, {
|
|
|
386
387
|
})
|
|
387
388
|
```
|
|
388
389
|
|
|
389
|
-
Registers all
|
|
390
|
+
Registers all 39 components, and bundles all of them — reach for `createNumoriUI` when that matters:
|
|
390
391
|
|
|
391
392
|
```js
|
|
392
393
|
app.use(createNumoriUI({ UiButton, UiModal }, { icons: { component: MyIcon } }))
|
|
@@ -420,7 +421,7 @@ into the component on the source path but emit a _second_ CSS file on the bundle
|
|
|
420
421
|
with one CSS import in some setups and two in others.
|
|
421
422
|
|
|
422
423
|
**SSR-safe.** Numori Notes is a client-only SPA and never exercised server rendering, so the
|
|
423
|
-
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
|
|
424
425
|
under strict SSR with no DOM globals, verified on every build.
|
|
425
426
|
|
|
426
427
|
## Development
|
|
@@ -462,8 +463,10 @@ that outgrows the codemod fails loudly instead of shipping broken.
|
|
|
462
463
|
## Changelog
|
|
463
464
|
|
|
464
465
|
See [CHANGELOG.md](./CHANGELOG.md) for the release history. The current release is
|
|
465
|
-
**0.
|
|
466
|
-
`UiComparisonTable
|
|
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.
|
|
467
470
|
|
|
468
471
|
## Licence and attribution
|
|
469
472
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, normalizeClass, normalizeStyle, openBlock, renderSlot,
|
|
2
|
+
import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, normalizeClass, normalizeStyle, openBlock, renderSlot, toDisplayString, withCtx, withModifiers } from "vue";
|
|
3
3
|
//#region src/components/Banner.vue
|
|
4
|
-
var _hoisted_1 =
|
|
4
|
+
var _hoisted_1 = ["aria-label"];
|
|
5
5
|
var _hoisted_2 = ["aria-label"];
|
|
6
6
|
var _sfc_main = {
|
|
7
7
|
__name: "Banner",
|
|
@@ -136,38 +136,35 @@ var _sfc_main = {
|
|
|
136
136
|
"leave-from-class": "max-h-24 opacity-100",
|
|
137
137
|
"leave-to-class": "max-h-0 opacity-0"
|
|
138
138
|
}, {
|
|
139
|
-
default: withCtx(() => [__props.show ? (openBlock(),
|
|
139
|
+
default: withCtx(() => [__props.show ? (openBlock(), createElementBlock("div", {
|
|
140
140
|
key: 0,
|
|
141
|
-
class: normalizeClass(["w-full shrink-0 overflow-hidden text-xs font-medium",
|
|
141
|
+
class: normalizeClass(["relative w-full shrink-0 overflow-hidden text-xs font-medium", colorClass.value]),
|
|
142
142
|
style: normalizeStyle(__props.safeArea ? { paddingTop: "env(safe-area-inset-top, 0px)" } : void 0),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"style",
|
|
169
|
-
"type"
|
|
170
|
-
])) : createCommentVNode("", true)]),
|
|
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)]),
|
|
171
168
|
_: 3
|
|
172
169
|
});
|
|
173
170
|
};
|
|
@@ -1 +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 <
|
|
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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GAAA;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,CAA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AA,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"}
|
package/dist/components/Card.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
2
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, mergeProps, openBlock, renderSlot, resolveDynamicComponent, unref, withCtx } from "vue";
|
|
3
3
|
//#region src/components/Card.vue
|
|
4
4
|
var _hoisted_1 = {
|
|
5
5
|
key: 0,
|
|
@@ -133,11 +133,6 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
133
133
|
* @slot footer — Optional footer, drawn below the body with a divider.
|
|
134
134
|
*/
|
|
135
135
|
const props = __props;
|
|
136
|
-
const attrs = useAttrs();
|
|
137
|
-
const restAttrs = computed(() => {
|
|
138
|
-
const { class: _class, ...rest } = attrs;
|
|
139
|
-
return rest;
|
|
140
|
-
});
|
|
141
136
|
const paddingClass = computed(() => ({
|
|
142
137
|
none: "",
|
|
143
138
|
xs: "p-3",
|
|
@@ -155,9 +150,20 @@ var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
|
155
150
|
card: "shadow-card",
|
|
156
151
|
"card-hover": "shadow-card-hover"
|
|
157
152
|
})[props.shadow] ?? "shadow-card");
|
|
158
|
-
const
|
|
153
|
+
const internalClasses = computed(() => [
|
|
154
|
+
"bg-white dark:bg-gray-900",
|
|
155
|
+
props.focusRing ? "relative" : "",
|
|
156
|
+
radiusClass.value,
|
|
157
|
+
props.bordered ? "border border-gray-200 dark:border-gray-700" : "",
|
|
158
|
+
shadowClass.value,
|
|
159
|
+
props.interactive ? "transition-[transform,box-shadow,border-color] duration-300 ease-out hover:-translate-y-1 hover:shadow-card-hover motion-reduce:transition-none motion-reduce:hover:translate-y-0" : "",
|
|
160
|
+
props.highlighted ? "border-primary-400 shadow-card-hover ring-1 ring-primary-400/20 dark:border-primary-400/60 dark:ring-primary-400/25" : "",
|
|
161
|
+
props.focusRing ? "focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary-500 dark:focus-within:outline-primary-400" : "",
|
|
162
|
+
paddingClass.value
|
|
163
|
+
].filter(Boolean).join(" "));
|
|
164
|
+
const { mergedClasses, restAttrs } = useMergedClasses(internalClasses);
|
|
159
165
|
return (_ctx, _cache) => {
|
|
160
|
-
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), mergeProps({ class: mergedClasses
|
|
166
|
+
return openBlock(), createBlock(resolveDynamicComponent(__props.tag), mergeProps({ class: unref(mergedClasses) }, unref(restAttrs)), {
|
|
161
167
|
default: withCtx(() => [
|
|
162
168
|
_ctx.$slots.header ? (openBlock(), createElementBlock("div", _hoisted_1, [renderSlot(_ctx.$slots, "header")])) : createCommentVNode("", true),
|
|
163
169
|
renderSlot(_ctx.$slots, "default"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Card.js","names":["$slots"],"sources":["../../src/components/Card.vue"],"sourcesContent":["<template>\n <!-- Dynamic root element — renders as div, article, section, or a link via :is -->\n <component :is=\"tag\" :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <!-- Optional header region, separated from the body by a hairline rule -->\n <div v-if=\"$slots.header\" class=\"mb-4 border-b border-gray-100 pb-4 dark:border-gray-800\">\n <slot name=\"header\" />\n </div>\n\n <slot />\n\n <!-- Optional footer region, pushed to the bottom in a flex-column card -->\n <div v-if=\"$slots.footer\" class=\"mt-auto border-t border-gray-100 pt-4 dark:border-gray-800\">\n <slot name=\"footer\" />\n </div>\n </component>\n</template>\n\n<script setup>\n/**\n * UiCard — the surface primitive: a bordered, rounded container with the\n * design system's card elevation, dark-mode surface, and optional interactive\n * and highlighted states.\n *\n * It is the shell only. Card lays out header / default / footer slots but takes\n * no view over their contents, so product cards, blog cards, pricing tiers and\n * link tiles can all share one surface while keeping their own internals.\n *\n * Renders as any element via `tag`, so a whole card can be a single link\n * (`tag=\"a\"`) or an article. External Tailwind classes are merged with\n * `tailwind-merge`, so a caller's `hover:border-primary-300` wins over the\n * neutral hover border added by `interactive` rather than doubling up.\n *\n * @example Basic card\n * <UiCard>\n * <h3 class=\"font-semibold\">Title</h3>\n * <p class=\"text-sm text-gray-600 dark:text-gray-400\">Body copy.</p>\n * </UiCard>\n *\n * @example Interactive card that is one big link (stretched-link pattern)\n * <UiCard tag=\"article\" interactive focus-ring>\n * <h3><a href=\"/x\" class=\"after:absolute after:inset-0\">Title</a></h3>\n * </UiCard>\n *\n * @example Highlighted pricing tier with a footer action\n * <UiCard highlighted padding=\"lg\" class=\"flex h-full flex-col\">\n * …\n * <template #footer><UiButton block>Choose</UiButton></template>\n * </UiCard>\n *\n * @slot default — Card body.\n * @slot header — Optional header, drawn above the body with a divider.\n * @slot footer — Optional footer, drawn below the body with a divider.\n */\nimport { computed
|
|
1
|
+
{"version":3,"file":"Card.js","names":["$slots"],"sources":["../../src/components/Card.vue"],"sourcesContent":["<template>\n <!-- Dynamic root element — renders as div, article, section, or a link via :is -->\n <component :is=\"tag\" :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <!-- Optional header region, separated from the body by a hairline rule -->\n <div v-if=\"$slots.header\" class=\"mb-4 border-b border-gray-100 pb-4 dark:border-gray-800\">\n <slot name=\"header\" />\n </div>\n\n <slot />\n\n <!-- Optional footer region, pushed to the bottom in a flex-column card -->\n <div v-if=\"$slots.footer\" class=\"mt-auto border-t border-gray-100 pt-4 dark:border-gray-800\">\n <slot name=\"footer\" />\n </div>\n </component>\n</template>\n\n<script setup>\n/**\n * UiCard — the surface primitive: a bordered, rounded container with the\n * design system's card elevation, dark-mode surface, and optional interactive\n * and highlighted states.\n *\n * It is the shell only. Card lays out header / default / footer slots but takes\n * no view over their contents, so product cards, blog cards, pricing tiers and\n * link tiles can all share one surface while keeping their own internals.\n *\n * Renders as any element via `tag`, so a whole card can be a single link\n * (`tag=\"a\"`) or an article. External Tailwind classes are merged with\n * `tailwind-merge`, so a caller's `hover:border-primary-300` wins over the\n * neutral hover border added by `interactive` rather than doubling up.\n *\n * @example Basic card\n * <UiCard>\n * <h3 class=\"font-semibold\">Title</h3>\n * <p class=\"text-sm text-gray-600 dark:text-gray-400\">Body copy.</p>\n * </UiCard>\n *\n * @example Interactive card that is one big link (stretched-link pattern)\n * <UiCard tag=\"article\" interactive focus-ring>\n * <h3><a href=\"/x\" class=\"after:absolute after:inset-0\">Title</a></h3>\n * </UiCard>\n *\n * @example Highlighted pricing tier with a footer action\n * <UiCard highlighted padding=\"lg\" class=\"flex h-full flex-col\">\n * …\n * <template #footer><UiButton block>Choose</UiButton></template>\n * </UiCard>\n *\n * @slot default — Card body.\n * @slot header — Optional header, drawn above the body with a divider.\n * @slot footer — Optional footer, drawn below the body with a divider.\n */\nimport { computed } from 'vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\nconst props = defineProps({\n /**\n * HTML element (or globally registered component name) to render as.\n * @type {string}\n * @default 'div'\n * @values 'div' | 'article' | 'section' | 'a' | 'li' | any valid tag\n */\n tag: { type: String, default: 'div' },\n\n /**\n * Inner padding.\n * @type {string}\n * @default 'md'\n * @values 'none' | 'xs' | 'sm' | 'md' | 'lg'\n */\n padding: { type: String, default: 'md' },\n\n /**\n * Corner radius.\n * @type {string}\n * @default '2xl'\n * @values 'lg' | 'xl' | '2xl'\n */\n radius: { type: String, default: '2xl' },\n\n /**\n * Base drop shadow. `interactive` raises this to `card-hover` on hover.\n * @type {string}\n * @default 'card'\n * @values 'none' | 'card' | 'card-hover'\n */\n shadow: { type: String, default: 'card' },\n\n /**\n * Draw the surface border. On by default; turn off for cards that sit on a\n * tinted panel and provide their own separation.\n * @type {boolean}\n * @default true\n */\n bordered: { type: Boolean, default: true },\n\n /**\n * Hover affordance: a small lift and a stronger shadow, with the transition\n * disabled under `prefers-reduced-motion`. Border-color is included in the\n * transition but left untinted, so add a `hover:border-*` (or `group-hover:\n * border-*`) class to colour the border on hover.\n * @type {boolean}\n * @default false\n */\n interactive: { type: Boolean, default: false },\n\n /**\n * Recommended / featured state: accent border and a raised shadow, for the\n * one card in a group that should draw the eye.\n * @type {boolean}\n * @default false\n */\n highlighted: { type: Boolean, default: false },\n\n /**\n * Lift the focus ring to the card when a single descendant link is stretched\n * over the whole surface (the `after:absolute after:inset-0` pattern). The\n * card becomes the positioning context and shows the ring on focus-within.\n * @type {boolean}\n * @default false\n */\n focusRing: { type: Boolean, default: false },\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst paddingClass = computed(\n () => ({ none: '', xs: 'p-3', sm: 'p-4', md: 'p-5', lg: 'p-6' })[props.padding] ?? 'p-5',\n)\n\nconst radiusClass = computed(\n () =>\n ({ lg: 'rounded-lg', xl: 'rounded-xl', '2xl': 'rounded-2xl' })[props.radius] ?? 'rounded-2xl',\n)\n\nconst shadowClass = computed(\n () =>\n ({ none: '', card: 'shadow-card', 'card-hover': 'shadow-card-hover' })[props.shadow] ??\n 'shadow-card',\n)\n\n// External classes merge last so a caller's `hover:border-primary-300` wins\n// over the neutral hover border rather than doubling up.\nconst internalClasses = computed(() =>\n [\n 'bg-white dark:bg-gray-900',\n props.focusRing ? 'relative' : '',\n radiusClass.value,\n props.bordered ? 'border border-gray-200 dark:border-gray-700' : '',\n shadowClass.value,\n props.interactive\n ? 'transition-[transform,box-shadow,border-color] duration-300 ease-out hover:-translate-y-1 hover:shadow-card-hover motion-reduce:transition-none motion-reduce:hover:translate-y-0'\n : '',\n props.highlighted\n ? 'border-primary-400 shadow-card-hover ring-1 ring-primary-400/20 dark:border-primary-400/60 dark:ring-primary-400/25'\n : '',\n props.focusRing\n ? 'focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary-500 dark:focus-within:outline-prim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,UAAA,GAAA,mBAEM,OAFN,YAEM,CADJ,WAAsB,KAAA,QAAA,QAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { checkableSizeClass } from "../internal/controlSizes.js";
|
|
1
2
|
import { computed, createElementBlock, normalizeClass, openBlock } from "vue";
|
|
2
3
|
//#region src/components/Checkbox.vue
|
|
3
4
|
var _hoisted_1 = ["checked", "disabled"];
|
|
@@ -65,13 +66,7 @@ var _sfc_main = {
|
|
|
65
66
|
*/
|
|
66
67
|
const props = __props;
|
|
67
68
|
const emit = __emit;
|
|
68
|
-
const sizeClass = computed(() =>
|
|
69
|
-
switch (props.size) {
|
|
70
|
-
case "sm": return "w-3.5 h-3.5";
|
|
71
|
-
case "lg": return "w-5 h-5";
|
|
72
|
-
default: return "w-4 h-4";
|
|
73
|
-
}
|
|
74
|
-
});
|
|
69
|
+
const sizeClass = computed(() => checkableSizeClass(props.size));
|
|
75
70
|
function onChange(e) {
|
|
76
71
|
emit("update:modelValue", e.target.checked);
|
|
77
72
|
emit("change", e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n type=\"checkbox\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst sizeClass = computed(() =>
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n type=\"checkbox\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCA,MAAM,QAAQ;EA+Bd,MAAM,OAAO;EAEb,MAAM,YAAY,eAAe,mBAAmB,MAAM,IAAI,CAAC;EAE/D,SAAS,SAAS,GAAG;GACnB,KAAK,qBAAqB,EAAE,OAAO,OAAO;GAC1C,KAAK,UAAU,CAAC;EAClB;;GAtEE,OAAA,UAAA,GAAA,mBAOE,SAAA;IANA,MAAK;IACJ,SAAS,QAAA,cAAc,QAAA;IACvB,UAAU,QAAA;IACX,OAAK,eAAA,CAAC,wFACE,UAAA,KAAS,CAAA;IACR"}
|