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
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, normalizeClass, openBlock, renderList, renderSlot, toDisplayString } from "vue";
|
|
3
|
+
//#region src/components/Table.vue
|
|
4
|
+
var _hoisted_1 = { class: "overflow-x-auto rounded-2xl border border-gray-200 dark:border-gray-700" };
|
|
5
|
+
var _hoisted_2 = { class: "w-full border-collapse text-sm" };
|
|
6
|
+
var _hoisted_3 = { class: "border-b border-gray-200 dark:border-gray-700" };
|
|
7
|
+
var _sfc_main = {
|
|
8
|
+
__name: "Table",
|
|
9
|
+
props: {
|
|
10
|
+
/**
|
|
11
|
+
* Column definitions, left to right. Each is
|
|
12
|
+
* `{ key, label?, align?, header?, highlight?, icon?, width? }`:
|
|
13
|
+
* - `key` — the row field this column reads.
|
|
14
|
+
* - `label` — the column heading.
|
|
15
|
+
* - `align` — `'left'` (default) | `'center'` | `'right'`.
|
|
16
|
+
* - `header` — render this column's cells as row headers (`<th scope="row">`).
|
|
17
|
+
* - `highlight` — accent-tint the column (the featured column in a comparison).
|
|
18
|
+
* - `icon` — MDI icon shown before each value in the column.
|
|
19
|
+
* - `width` — optional width utility class, e.g. `'w-2/5'`.
|
|
20
|
+
* @type {Array<{ key: string, label?: string, align?: string, header?: boolean, highlight?: boolean, icon?: string, width?: string }>}
|
|
21
|
+
*/
|
|
22
|
+
columns: {
|
|
23
|
+
type: Array,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* Row objects, each keyed by the column `key`s.
|
|
28
|
+
* @type {Array<Record<string, unknown>>}
|
|
29
|
+
*/
|
|
30
|
+
rows: {
|
|
31
|
+
type: Array,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Table caption. Rendered as a real `<caption>` for accessibility; visible by
|
|
36
|
+
* default, or visually hidden with `hideCaption`.
|
|
37
|
+
* @type {string}
|
|
38
|
+
* @default ''
|
|
39
|
+
*/
|
|
40
|
+
caption: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: ""
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Keep the caption for assistive technology but hide it visually.
|
|
46
|
+
* @type {boolean}
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
hideCaption: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Row field used as the `v-for` key; falls back to the row index.
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @default 'key'
|
|
57
|
+
*/
|
|
58
|
+
rowKey: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: "key"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
setup(__props) {
|
|
64
|
+
/**
|
|
65
|
+
* UiTable — a data table with sensible defaults, and a built-in comparison mode.
|
|
66
|
+
*
|
|
67
|
+
* Drive it with `columns` and `rows`: each column names a `key`, and each row
|
|
68
|
+
* is an object keyed by those column keys. It renders a real, accessible
|
|
69
|
+
* `<table>` (`<caption>`, `scope="col"` headers) that scrolls horizontally on
|
|
70
|
+
* narrow screens rather than crushing its columns.
|
|
71
|
+
*
|
|
72
|
+
* **Comparison** is just a configuration, not a separate component: mark the
|
|
73
|
+
* label column `header: true` (so it renders as a `<th scope="row">`), give the
|
|
74
|
+
* column you want to feature `highlight: true` (accent tint), and hand each
|
|
75
|
+
* value column an `icon` (e.g. a tick for the highlighted column, a dash for
|
|
76
|
+
* the others). That reproduces the "us vs. the usual" table without a bespoke
|
|
77
|
+
* component. For full control of a cell, use the `#cell` scoped slot.
|
|
78
|
+
*
|
|
79
|
+
* @example A plain data table
|
|
80
|
+
* <UiTable
|
|
81
|
+
* caption="Team"
|
|
82
|
+
* :columns="[
|
|
83
|
+
* { key: 'name', label: 'Name' },
|
|
84
|
+
* { key: 'role', label: 'Role' },
|
|
85
|
+
* { key: 'commits', label: 'Commits', align: 'right' },
|
|
86
|
+
* ]"
|
|
87
|
+
* :rows="[
|
|
88
|
+
* { name: 'Ada Lovelace', role: 'Engineer', commits: 128 },
|
|
89
|
+
* { name: 'Grace Hopper', role: 'Lead', commits: 342 },
|
|
90
|
+
* ]"
|
|
91
|
+
* />
|
|
92
|
+
*
|
|
93
|
+
* @example A comparison table (the old UiComparisonTable, now a configuration)
|
|
94
|
+
* <UiTable
|
|
95
|
+
* caption="How Numori compares"
|
|
96
|
+
* :columns="[
|
|
97
|
+
* { key: 'feature', label: 'Feature', header: true },
|
|
98
|
+
* { key: 'numori', label: 'Numori', highlight: true, icon: 'mdi:check-circle' },
|
|
99
|
+
* { key: 'usual', label: 'The usual', icon: 'mdi:minus-circle-outline' },
|
|
100
|
+
* ]"
|
|
101
|
+
* :rows="[
|
|
102
|
+
* { feature: 'Open source', numori: 'Entire ecosystem', usual: 'The client, sometimes' },
|
|
103
|
+
* ]"
|
|
104
|
+
* />
|
|
105
|
+
*
|
|
106
|
+
* @example Custom cell rendering
|
|
107
|
+
* <UiTable :columns="cols" :rows="rows">
|
|
108
|
+
* <template #cell="{ column, value }">
|
|
109
|
+
* <UiBadge v-if="column.key === 'status'" :color="value === 'active' ? 'green' : 'gray'">
|
|
110
|
+
* {{ value }}
|
|
111
|
+
* </UiBadge>
|
|
112
|
+
* <template v-else>{{ value }}</template>
|
|
113
|
+
* </template>
|
|
114
|
+
* </UiTable>
|
|
115
|
+
*
|
|
116
|
+
* @slot caption — Rich caption content (overrides the `caption` prop).
|
|
117
|
+
* @slot cell — Custom cell content. Scope: `{ row, column, value }`.
|
|
118
|
+
*/
|
|
119
|
+
const alignClass = (align) => align === "right" ? "text-right" : align === "center" ? "text-center" : "text-left";
|
|
120
|
+
return (_ctx, _cache) => {
|
|
121
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [createElementVNode("table", _hoisted_2, [
|
|
122
|
+
__props.caption || _ctx.$slots.caption ? (openBlock(), createElementBlock("caption", {
|
|
123
|
+
key: 0,
|
|
124
|
+
class: normalizeClass(__props.hideCaption ? "sr-only" : "caption-top px-5 py-4 text-left text-sm font-semibold text-gray-900 dark:text-gray-100")
|
|
125
|
+
}, [renderSlot(_ctx.$slots, "caption", {}, () => [createTextVNode(toDisplayString(__props.caption), 1)])], 2)) : createCommentVNode("", true),
|
|
126
|
+
createElementVNode("thead", null, [createElementVNode("tr", _hoisted_3, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (col) => {
|
|
127
|
+
return openBlock(), createElementBlock("th", {
|
|
128
|
+
key: col.key,
|
|
129
|
+
scope: "col",
|
|
130
|
+
class: normalizeClass(["px-5 py-4 font-semibold", [
|
|
131
|
+
alignClass(col.align),
|
|
132
|
+
col.highlight ? "bg-primary-50 text-primary-800 dark:bg-primary-400/10 dark:text-primary-200" : "text-gray-600 dark:text-gray-300",
|
|
133
|
+
col.width
|
|
134
|
+
]])
|
|
135
|
+
}, [col.label ? (openBlock(), createElementBlock("span", {
|
|
136
|
+
key: 0,
|
|
137
|
+
class: normalizeClass(col.header && !col.label ? "sr-only" : "")
|
|
138
|
+
}, toDisplayString(col.label), 3)) : createCommentVNode("", true)], 2);
|
|
139
|
+
}), 128))])]),
|
|
140
|
+
createElementVNode("tbody", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.rows, (row, index) => {
|
|
141
|
+
return openBlock(), createElementBlock("tr", {
|
|
142
|
+
key: row[__props.rowKey] ?? index,
|
|
143
|
+
class: "border-b border-gray-100 transition-colors duration-200 last:border-0 hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-900/60"
|
|
144
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.columns, (col) => {
|
|
145
|
+
return openBlock(), createElementBlock(Fragment, { key: col.key }, [col.header ? (openBlock(), createElementBlock("th", {
|
|
146
|
+
key: 0,
|
|
147
|
+
scope: "row",
|
|
148
|
+
class: normalizeClass(["px-5 py-4 font-medium text-gray-900 dark:text-gray-100", alignClass(col.align)])
|
|
149
|
+
}, [renderSlot(_ctx.$slots, "cell", {
|
|
150
|
+
row,
|
|
151
|
+
column: col,
|
|
152
|
+
value: row[col.key]
|
|
153
|
+
}, () => [createTextVNode(toDisplayString(row[col.key]), 1)])], 2)) : (openBlock(), createElementBlock("td", {
|
|
154
|
+
key: 1,
|
|
155
|
+
class: normalizeClass(["px-5 py-4", [alignClass(col.align), col.highlight ? "bg-primary-50/50 text-gray-700 dark:bg-primary-400/5 dark:text-gray-200" : "text-gray-600 dark:text-gray-400"]])
|
|
156
|
+
}, [renderSlot(_ctx.$slots, "cell", {
|
|
157
|
+
row,
|
|
158
|
+
column: col,
|
|
159
|
+
value: row[col.key]
|
|
160
|
+
}, () => [createElementVNode("span", { class: normalizeClass(col.icon ? "flex items-start gap-2" : "") }, [col.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
161
|
+
key: 0,
|
|
162
|
+
name: col.icon,
|
|
163
|
+
class: normalizeClass(["mt-0.5 size-4 shrink-0", col.highlight ? "text-success-600 dark:text-success-400" : "text-gray-400 dark:text-gray-500"])
|
|
164
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createTextVNode(" " + toDisplayString(row[col.key]), 1)], 2)])], 2))], 64);
|
|
165
|
+
}), 128))]);
|
|
166
|
+
}), 128))])
|
|
167
|
+
])]);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
//#endregion
|
|
172
|
+
export { _sfc_main as default };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=Table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.js","names":["$slots"],"sources":["../../src/components/Table.vue"],"sourcesContent":["<template>\n <div class=\"overflow-x-auto rounded-2xl border border-gray-200 dark:border-gray-700\">\n <table class=\"w-full border-collapse text-sm\">\n <caption\n v-if=\"caption || $slots.caption\"\n :class=\"\n hideCaption\n ? 'sr-only'\n : 'caption-top px-5 py-4 text-left text-sm font-semibold text-gray-900 dark:text-gray-100'\n \"\n >\n <slot name=\"caption\">{{ caption }}</slot>\n </caption>\n\n <thead>\n <tr class=\"border-b border-gray-200 dark:border-gray-700\">\n <th\n v-for=\"col in columns\"\n :key=\"col.key\"\n scope=\"col\"\n class=\"px-5 py-4 font-semibold\"\n :class=\"[\n alignClass(col.align),\n col.highlight\n ? 'bg-primary-50 text-primary-800 dark:bg-primary-400/10 dark:text-primary-200'\n : 'text-gray-600 dark:text-gray-300',\n col.width,\n ]\"\n >\n <span v-if=\"col.label\" :class=\"col.header && !col.label ? 'sr-only' : ''\">{{\n col.label\n }}</span>\n </th>\n </tr>\n </thead>\n\n <tbody>\n <tr\n v-for=\"(row, index) in rows\"\n :key=\"row[rowKey] ?? index\"\n class=\"border-b border-gray-100 transition-colors duration-200 last:border-0 hover:bg-gray-50 dark:border-gray-800 dark:hover:bg-gray-900/60\"\n >\n <template v-for=\"col in columns\" :key=\"col.key\">\n <!-- Header columns render as row headers (<th scope=\"row\">), e.g. the\n feature column of a comparison table. -->\n <th\n v-if=\"col.header\"\n scope=\"row\"\n class=\"px-5 py-4 font-medium text-gray-900 dark:text-gray-100\"\n :class=\"alignClass(col.align)\"\n >\n <slot name=\"cell\" :row=\"row\" :column=\"col\" :value=\"row[col.key]\">\n {{ row[col.key] }}\n </slot>\n </th>\n <td\n v-else\n class=\"px-5 py-4\"\n :class=\"[\n alignClass(col.align),\n col.highlight\n ? 'bg-primary-50/50 text-gray-700 dark:bg-primary-400/5 dark:text-gray-200'\n : 'text-gray-600 dark:text-gray-400',\n ]\"\n >\n <slot name=\"cell\" :row=\"row\" :column=\"col\" :value=\"row[col.key]\">\n <span :class=\"col.icon ? 'flex items-start gap-2' : ''\">\n <UiIcon\n v-if=\"col.icon\"\n :name=\"col.icon\"\n class=\"mt-0.5 size-4 shrink-0\"\n :class=\"\n col.highlight\n ? 'text-success-600 dark:text-success-400'\n : 'text-gray-400 dark:text-gray-500'\n \"\n />\n {{ row[col.key] }}\n </span>\n </slot>\n </td>\n </template>\n </tr>\n </tbody>\n </table>\n </div>\n</template>\n\n<script setup>\n/**\n * UiTable — a data table with sensible defaults, and a built-in comparison mode.\n *\n * Drive it with `columns` and `rows`: each column names a `key`, and each row\n * is an object keyed by those column keys. It renders a real, accessible\n * `<table>` (`<caption>`, `scope=\"col\"` headers) that scrolls horizontally on\n * narrow screens rather than crushing its columns.\n *\n * **Comparison** is just a configuration, not a separate component: mark the\n * label column `header: true` (so it renders as a `<th scope=\"row\">`), give the\n * column you want to feature `highlight: true` (accent tint), and hand each\n * value column an `icon` (e.g. a tick for the highlighted column, a dash for\n * the others). That reproduces the \"us vs. the usual\" table without a bespoke\n * component. For full control of a cell, use the `#cell` scoped slot.\n *\n * @example A plain data table\n * <UiTable\n * caption=\"Team\"\n * :columns=\"[\n * { key: 'name', label: 'Name' },\n * { key: 'role', label: 'Role' },\n * { key: 'commits', label: 'Commits', align: 'right' },\n * ]\"\n * :rows=\"[\n * { name: 'Ada Lovelace', role: 'Engineer', commits: 128 },\n * { name: 'Grace Hopper', role: 'Lead', commits: 342 },\n * ]\"\n * />\n *\n * @example A comparison table (the old UiComparisonTable, now a configuration)\n * <UiTable\n * caption=\"How Numori compares\"\n * :columns=\"[\n * { key: 'feature', label: 'Feature', header: true },\n * { key: 'numori', label: 'Numori', highlight: true, icon: 'mdi:check-circle' },\n * { key: 'usual', label: 'The usual', icon: 'mdi:minus-circle-outline' },\n * ]\"\n * :rows=\"[\n * { feature: 'Open source', numori: 'Entire ecosystem', usual: 'The client, sometimes' },\n * ]\"\n * />\n *\n * @example Custom cell rendering\n * <UiTable :columns=\"cols\" :rows=\"rows\">\n * <template #cell=\"{ column, value }\">\n * <UiBadge v-if=\"column.key === 'status'\" :color=\"value === 'active' ? 'green' : 'gray'\">\n * {{ value }}\n * </UiBadge>\n * <template v-else>{{ value }}</template>\n * </template>\n * </UiTable>\n *\n * @slot caption — Rich caption content (overrides the `caption` prop).\n * @slot cell — Custom cell content. Scope: `{ row, column, value }`.\n */\nimport UiIcon from '../icons/Icon.vue'\n\ndefineProps({\n /**\n * Column definitions, left to right. Each is\n * `{ key, label?, align?, header?, highlight?, icon?, width? }`:\n * - `key` — the row field this column reads.\n * - `label` — the column heading.\n * - `align` — `'left'` (default) | `'center'` | `'right'`.\n * - `header` — render this column's cells as row headers (`<th scope=\"row\">`).\n * - `highlight` — accent-tint the column (the featured column in a comparison).\n * - `icon` — MDI icon shown before each value in the column.\n * - `width` — optional width utility class, e.g. `'w-2/5'`.\n * @type {Array<{ key: string, label?: string, align?: string, header?: boolean, highlight?: boolean, icon?: string, width?: string }>}\n */\n columns: { type: Array, required: true },\n\n /**\n * Row objects, each keyed by the column `key`s.\n * @type {Array<Record<string, unknown>>}\n */\n rows: { type: Array, required: true },\n\n /**\n * Table caption. Rendered as a real `<caption>` for accessibility; visible by\n * default, or visually hidden with `hideCaption`.\n * @type {string}\n * @default ''\n */\n caption: { type: String, default: '' },\n\n /**\n * Keep the caption for assistive technology but hide it visually.\n * @type {boolean}\n * @default false\n */\n hideCaption: { type: Boolean, default: false },\n\n /**\n * Row field used as the `v-for` key; falls back to the row index.\n * @type {string}\n * @default 'key'\n */\n rowKey: { type: String, default: 'key' },\n})\n\nconst alignClass = (align) =>\n align === 'right' ? 'text-right' : align === 'center' ? 'text-center' : 'text-left'\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8LA,MAAM,cAAc,UAClB,UAAU,UAAU,eAAe,UAAU,WAAW,gBAAgB;;GA9LxE,OAAA,UAAA,GAAA,mBAoFM,OApFN,YAoFM,CAnFJ,mBAkFQ,SAlFR,YAkFQ;IAhFE,QAAA,WAAWA,KAAAA,OAAO,WAD1B,UAAA,GAAA,mBASU,WAAA;;KAPP,OAAK,eAAa,QAAA,cAAA,YAAA,wFAAA;IAMnB,GAAA,CAAA,WAAyC,KAAA,QAAA,WAAA,CAAA,SAAA,CAAjB,gBAAA,gBAAA,QAAA,OAAO,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;IAGjC,mBAoBQ,SAAA,MAAA,CAnBN,mBAkBK,MAlBL,YAkBK,EAjBH,UAAA,IAAA,GAAA,mBAgBK,UAAA,MAAA,WAfW,QAAA,UAAP,QAAG;KADZ,OAAA,UAAA,GAAA,mBAgBK,MAAA;MAdF,KAAK,IAAI;MACV,OAAM;MACN,OAAK,eAAA,CAAC,2BAAyB;OACP,WAAW,IAAI,KAAK;OAAiB,IAAI,YAAA,gFAAA;OAA8K,IAAI;;KAQvO,GAAA,CAAA,IAAI,SAAhB,UAAA,GAAA,mBAES,QAAA;;MAFe,OAAK,eAAE,IAAI,UAAM,CAAK,IAAI,QAAK,YAAA,EAAA;KACrD,GAAA,gBAAA,IAAI,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,GAAA,CAAA;;IAMjB,mBA+CQ,SAAA,MAAA,EA9CN,UAAA,IAAA,GAAA,mBA6CK,UAAA,MAAA,WA5CoB,QAAA,OAAf,KAAK,UAAK;KADpB,OAAA,UAAA,GAAA,mBA6CK,MAAA;MA3CF,KAAK,IAAI,QAAA,WAAW;MACrB,OAAM;KAEN,GAAA,EAAA,UAAA,IAAA,GAAA,mBAuCW,UAAA,MAAA,WAvCa,QAAA,UAAP,QAAG;MAAmB,OAAA,UAAA,GAAA,mBAAA,UAAA,EAAA,KAAA,IAAI,IAAA,GAAA,CAIjC,IAAI,UADZ,UAAA,GAAA,mBASK,MAAA;;OAPH,OAAM;OACN,OAAK,eAAA,CAAC,0DACE,WAAW,IAAI,KAAK,CAAA,CAAA;MAE5B,GAAA,CAAA,WAEO,KAAA,QAAA,QAAA;OAFiB;OAAM,QAAQ;OAAM,OAAO,IAAI,IAAI;MAA3D,SAEO,CADF,gBAAA,gBAAA,IAAI,IAAI,IAAG,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,MAGlB,UAAA,GAAA,mBAyBK,MAAA;;OAvBH,OAAK,eAAA,CAAC,aAAW,CACS,WAAW,IAAI,KAAK,GAAmB,IAAI,YAAA,4EAAA,kCAAA,CAAA,CAAA;MAOrE,GAAA,CAAA,WAcO,KAAA,QAAA,QAAA;OAdiB;OAAM,QAAQ;OAAM,OAAO,IAAI,IAAI;MAA3D,SAcO,CAbL,mBAYO,QAAA,EAZA,OAAK,eAAE,IAAI,OAAI,2BAAA,EAAA,EAAA,GAAA,CAEZ,IAAI,QADZ,UAAA,GAAA,YASE,aAAA;;OAPC,MAAM,IAAI;OACX,OAAK,eAAA,CAAC,0BACyB,IAAI,YAAA,2CAAA,kCAAA,CAAA;MAKnC,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,gBAAA,MACF,gBAAG,IAAI,IAAI,IAAG,GAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,EAAA,GAAA,EAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import _sfc_main$2 from "./Button.js";
|
|
3
|
+
import { createBlock, createElementVNode, createVNode, normalizeClass, openBlock, withCtx } from "vue";
|
|
4
|
+
//#region src/components/ThemeToggle.vue
|
|
5
|
+
var _hoisted_1 = { class: "grid size-5 place-items-center" };
|
|
6
|
+
var _sfc_main = {
|
|
7
|
+
__name: "ThemeToggle",
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the dark theme is currently active. Drives which glyph is shown.
|
|
11
|
+
* @type {boolean}
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
isDark: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Accessible name and hover tooltip. Should describe the action the control
|
|
20
|
+
* performs, e.g. "Switch to dark mode".
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @default 'Toggle theme'
|
|
23
|
+
*/
|
|
24
|
+
label: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "Toggle theme"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
emits: ["toggle"],
|
|
30
|
+
setup(__props, { emit: __emit }) {
|
|
31
|
+
/**
|
|
32
|
+
* UiThemeToggle — an icon button that flips between light and dark.
|
|
33
|
+
*
|
|
34
|
+
* Deliberately presentational and stateless. Numori UI's dark mode is a `.dark`
|
|
35
|
+
* class on `<html>`, but *how* that class gets toggled and persisted is the
|
|
36
|
+
* host's decision — `@nuxtjs/color-mode`, VueUse's `useDark`, or two hand-written
|
|
37
|
+
* lines. So this component owns none of that: it takes the current state as
|
|
38
|
+
* `isDark` and emits `toggle`, and the parent does the flip.
|
|
39
|
+
*
|
|
40
|
+
* Because it is icon-only it carries both `title` (for pointer users) and
|
|
41
|
+
* `aria-label` (an icon has no accessible name otherwise), both from `label`.
|
|
42
|
+
* The sun and moon share one grid cell and cross-fade with a rotation.
|
|
43
|
+
*
|
|
44
|
+
* Under SSR the rendered theme is not known until the client reads the stored
|
|
45
|
+
* preference, so wrap it in whatever your framework uses to defer to the client
|
|
46
|
+
* (Nuxt's `<ClientOnly>`, for instance) if you render on the server, to avoid a
|
|
47
|
+
* hydration mismatch on the icon.
|
|
48
|
+
*
|
|
49
|
+
* @example With @nuxtjs/color-mode
|
|
50
|
+
* <script setup>
|
|
51
|
+
* const colorMode = useColorMode()
|
|
52
|
+
* const isDark = computed(() => colorMode.value === 'dark')
|
|
53
|
+
* const toggle = () => { colorMode.preference = isDark.value ? 'light' : 'dark' }
|
|
54
|
+
* <\/script>
|
|
55
|
+
*
|
|
56
|
+
* <UiThemeToggle :is-dark="isDark" :label="isDark ? 'Switch to light' : 'Switch to dark'"
|
|
57
|
+
* @toggle="toggle" />
|
|
58
|
+
*/
|
|
59
|
+
const emit = __emit;
|
|
60
|
+
return (_ctx, _cache) => {
|
|
61
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
62
|
+
variant: "ghost",
|
|
63
|
+
color: "gray",
|
|
64
|
+
"icon-only": "",
|
|
65
|
+
title: __props.label,
|
|
66
|
+
"aria-label": __props.label,
|
|
67
|
+
class: "group",
|
|
68
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("toggle"))
|
|
69
|
+
}, {
|
|
70
|
+
default: withCtx(() => [createElementVNode("span", _hoisted_1, [createVNode(_sfc_main$1, {
|
|
71
|
+
name: "mdi:weather-sunny",
|
|
72
|
+
class: normalizeClass(["col-start-1 row-start-1 size-5 transition-all duration-300", __props.isDark ? "rotate-0 scale-100 opacity-100" : "-rotate-90 scale-50 opacity-0"])
|
|
73
|
+
}, null, 8, ["class"]), createVNode(_sfc_main$1, {
|
|
74
|
+
name: "mdi:weather-night",
|
|
75
|
+
class: normalizeClass(["col-start-1 row-start-1 size-5 transition-all duration-300", __props.isDark ? "rotate-90 scale-50 opacity-0" : "rotate-0 scale-100 opacity-100"])
|
|
76
|
+
}, null, 8, ["class"])])]),
|
|
77
|
+
_: 1
|
|
78
|
+
}, 8, ["title", "aria-label"]);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
export { _sfc_main as default };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=ThemeToggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeToggle.js","names":[],"sources":["../../src/components/ThemeToggle.vue"],"sourcesContent":["<template>\n <UiButton\n variant=\"ghost\"\n color=\"gray\"\n icon-only\n :title=\"label\"\n :aria-label=\"label\"\n class=\"group\"\n @click=\"emit('toggle')\"\n >\n <!--\n The two glyphs occupy the same grid cell and cross-fade with a quarter\n turn, so flipping the theme reads as one control turning over rather than\n an icon being swapped out.\n -->\n <span class=\"grid size-5 place-items-center\">\n <UiIcon\n name=\"mdi:weather-sunny\"\n class=\"col-start-1 row-start-1 size-5 transition-all duration-300\"\n :class=\"isDark ? 'rotate-0 scale-100 opacity-100' : '-rotate-90 scale-50 opacity-0'\"\n />\n <UiIcon\n name=\"mdi:weather-night\"\n class=\"col-start-1 row-start-1 size-5 transition-all duration-300\"\n :class=\"isDark ? 'rotate-90 scale-50 opacity-0' : 'rotate-0 scale-100 opacity-100'\"\n />\n </span>\n </UiButton>\n</template>\n\n<script setup>\n/**\n * UiThemeToggle — an icon button that flips between light and dark.\n *\n * Deliberately presentational and stateless. Numori UI's dark mode is a `.dark`\n * class on `<html>`, but *how* that class gets toggled and persisted is the\n * host's decision — `@nuxtjs/color-mode`, VueUse's `useDark`, or two hand-written\n * lines. So this component owns none of that: it takes the current state as\n * `isDark` and emits `toggle`, and the parent does the flip.\n *\n * Because it is icon-only it carries both `title` (for pointer users) and\n * `aria-label` (an icon has no accessible name otherwise), both from `label`.\n * The sun and moon share one grid cell and cross-fade with a rotation.\n *\n * Under SSR the rendered theme is not known until the client reads the stored\n * preference, so wrap it in whatever your framework uses to defer to the client\n * (Nuxt's `<ClientOnly>`, for instance) if you render on the server, to avoid a\n * hydration mismatch on the icon.\n *\n * @example With @nuxtjs/color-mode\n * <script setup>\n * const colorMode = useColorMode()\n * const isDark = computed(() => colorMode.value === 'dark')\n * const toggle = () => { colorMode.preference = isDark.value ? 'light' : 'dark' }\n * <\\/script>\n *\n * <UiThemeToggle :is-dark=\"isDark\" :label=\"isDark ? 'Switch to light' : 'Switch to dark'\"\n * @toggle=\"toggle\" />\n */\nimport UiButton from './Button.vue'\nimport UiIcon from '../icons/Icon.vue'\n\ndefineProps({\n /**\n * Whether the dark theme is currently active. Drives which glyph is shown.\n * @type {boolean}\n * @default false\n */\n isDark: { type: Boolean, default: false },\n\n /**\n * Accessible name and hover tooltip. Should describe the action the control\n * performs, e.g. \"Switch to dark mode\".\n * @type {string}\n * @default 'Toggle theme'\n */\n label: { type: String, default: 'Toggle theme' },\n})\n\nconst emit = defineEmits(['toggle'])\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+EA,MAAM,OAAO;;GA9EX,OAAA,UAAA,GAAA,YA0BW,aAAA;IAzBT,SAAQ;IACR,OAAM;IACN,aAAA;IACC,OAAO,QAAA;IACP,cAAY,QAAA;IACb,OAAM;IACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,QAAA;;IAOZ,SAAA,cAWO,CAXP,mBAWO,QAXP,YAWO,CAVL,YAIE,aAAA;KAHA,MAAK;KACL,OAAK,eAAA,CAAC,8DACE,QAAA,SAAM,mCAAA,+BAAA,CAAA;IAEhB,GAAA,MAAA,GAAA,CAAA,OAAA,CAAA,GAAA,YAIE,aAAA;KAHA,MAAK;KACL,OAAK,eAAA,CAAC,8DACE,QAAA,SAAM,iCAAA,gCAAA,CAAA"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { Fragment, Teleport, TransitionGroup, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, normalizeClass, openBlock, renderList, toDisplayString, withCtx } from "vue";
|
|
3
|
+
//#region src/components/Toast.vue
|
|
4
|
+
var _sfc_main = {
|
|
5
|
+
__name: "Toast",
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* The messages to show. Each is `{ id, message, type?, icon? }`, where `id`
|
|
9
|
+
* is stable and unique, `type` is one of the values below (default neutral),
|
|
10
|
+
* and `icon` is an optional MDI name.
|
|
11
|
+
* @type {Array<{ id: string|number, message: string, type?: string, icon?: string }>}
|
|
12
|
+
* @default []
|
|
13
|
+
*/
|
|
14
|
+
toasts: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Where the stack anchors on screen.
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @default 'top'
|
|
22
|
+
* @values 'top' | 'bottom'
|
|
23
|
+
*/
|
|
24
|
+
position: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "top"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
setup(__props) {
|
|
30
|
+
/**
|
|
31
|
+
* UiToast — a stack of transient, self-dismissing messages.
|
|
32
|
+
*
|
|
33
|
+
* The presentational half of a toast system: it renders and animates a list of
|
|
34
|
+
* messages, teleported to `<body>` so it floats above everything and clear of
|
|
35
|
+
* any parent's `overflow` or stacking context. Owning the list — adding a toast,
|
|
36
|
+
* timing it out, removing it — is the app's job, because *when* something is
|
|
37
|
+
* worth announcing is application logic, not layout. Hand it a reactive array
|
|
38
|
+
* and mutate that array; the enter/leave transitions handle the rest.
|
|
39
|
+
*
|
|
40
|
+
* Each entry is `{ id, message, type?, icon? }`. `id` must be stable and unique
|
|
41
|
+
* (it keys the transition); `type` picks the colour and defaults to a neutral
|
|
42
|
+
* dark pill; `icon` is optional and drawn through `UiIcon`.
|
|
43
|
+
*
|
|
44
|
+
* The container does not capture pointer events, so it never blocks the UI
|
|
45
|
+
* underneath; only the pills themselves do. Each pill is a `role="status"`, so a
|
|
46
|
+
* screen reader announces it politely without stealing focus.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* <script setup>
|
|
50
|
+
* import { ref } from 'vue'
|
|
51
|
+
* const toasts = ref([])
|
|
52
|
+
* let seq = 0
|
|
53
|
+
* function notify(message, type = 'info') {
|
|
54
|
+
* const id = ++seq
|
|
55
|
+
* toasts.value.push({ id, message, type })
|
|
56
|
+
* setTimeout(() => { toasts.value = toasts.value.filter((t) => t.id !== id) }, 3000)
|
|
57
|
+
* }
|
|
58
|
+
* <\/script>
|
|
59
|
+
*
|
|
60
|
+
* <UiToast :toasts="toasts" />
|
|
61
|
+
* <UiButton @click="notify('Saved', 'success')">Save</UiButton>
|
|
62
|
+
*/
|
|
63
|
+
const props = __props;
|
|
64
|
+
const positionClass = computed(() => props.position === "bottom" ? "bottom-6" : "top-6");
|
|
65
|
+
/**
|
|
66
|
+
* Toast colours are drawn from the design tokens (`success`/`warning`/`error`)
|
|
67
|
+
* rather than literal Tailwind palette names, so a rebrand of those ramps
|
|
68
|
+
* carries through here too. Anything unrecognised falls back to a neutral pill.
|
|
69
|
+
* @param {string} type
|
|
70
|
+
*/
|
|
71
|
+
const toastClass = (type) => {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case "success": return "bg-success-600/90 text-white dark:bg-success-500/90";
|
|
74
|
+
case "warning": return "bg-warning-500/90 text-white dark:bg-warning-500/90";
|
|
75
|
+
case "error": return "bg-error-600/90 text-white dark:bg-error-500/90";
|
|
76
|
+
default: return "bg-gray-800/90 text-white dark:bg-gray-200/90 dark:text-gray-900";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return (_ctx, _cache) => {
|
|
80
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [createElementVNode("div", { class: normalizeClass(["fixed left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 pointer-events-none", positionClass.value]) }, [createVNode(TransitionGroup, {
|
|
81
|
+
"enter-active-class": "transition-all duration-250 ease-out",
|
|
82
|
+
"enter-from-class": "opacity-0 -translate-y-3 scale-95",
|
|
83
|
+
"enter-to-class": "opacity-100 translate-y-0 scale-100",
|
|
84
|
+
"leave-active-class": "transition-all duration-200 ease-in",
|
|
85
|
+
"leave-from-class": "opacity-100 translate-y-0 scale-100",
|
|
86
|
+
"leave-to-class": "opacity-0 -translate-y-1 scale-95"
|
|
87
|
+
}, {
|
|
88
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.toasts, (toast) => {
|
|
89
|
+
return openBlock(), createElementBlock("div", {
|
|
90
|
+
key: toast.id,
|
|
91
|
+
class: normalizeClass(["pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-xl shadow-lg text-sm font-medium backdrop-blur-xs", toastClass(toast.type)]),
|
|
92
|
+
role: "status"
|
|
93
|
+
}, [toast.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
94
|
+
key: 0,
|
|
95
|
+
name: toast.icon,
|
|
96
|
+
class: "w-4 h-4 shrink-0"
|
|
97
|
+
}, null, 8, ["name"])) : createCommentVNode("", true), createElementVNode("span", null, toDisplayString(toast.message), 1)], 2);
|
|
98
|
+
}), 128))]),
|
|
99
|
+
_: 1
|
|
100
|
+
})], 2)]);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
//#endregion
|
|
105
|
+
export { _sfc_main as default };
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=Toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast.js","names":[],"sources":["../../src/components/Toast.vue"],"sourcesContent":["<template>\n <Teleport to=\"body\">\n <div\n class=\"fixed left-1/2 -translate-x-1/2 z-[100] flex flex-col items-center gap-2 pointer-events-none\"\n :class=\"positionClass\"\n >\n <TransitionGroup\n enter-active-class=\"transition-all duration-250 ease-out\"\n enter-from-class=\"opacity-0 -translate-y-3 scale-95\"\n enter-to-class=\"opacity-100 translate-y-0 scale-100\"\n leave-active-class=\"transition-all duration-200 ease-in\"\n leave-from-class=\"opacity-100 translate-y-0 scale-100\"\n leave-to-class=\"opacity-0 -translate-y-1 scale-95\"\n >\n <div\n v-for=\"toast in toasts\"\n :key=\"toast.id\"\n class=\"pointer-events-auto flex items-center gap-2 px-4 py-2.5 rounded-xl shadow-lg text-sm font-medium backdrop-blur-xs\"\n :class=\"toastClass(toast.type)\"\n role=\"status\"\n >\n <UiIcon v-if=\"toast.icon\" :name=\"toast.icon\" class=\"w-4 h-4 shrink-0\" />\n <span>{{ toast.message }}</span>\n </div>\n </TransitionGroup>\n </div>\n </Teleport>\n</template>\n\n<script setup>\n/**\n * UiToast — a stack of transient, self-dismissing messages.\n *\n * The presentational half of a toast system: it renders and animates a list of\n * messages, teleported to `<body>` so it floats above everything and clear of\n * any parent's `overflow` or stacking context. Owning the list — adding a toast,\n * timing it out, removing it — is the app's job, because *when* something is\n * worth announcing is application logic, not layout. Hand it a reactive array\n * and mutate that array; the enter/leave transitions handle the rest.\n *\n * Each entry is `{ id, message, type?, icon? }`. `id` must be stable and unique\n * (it keys the transition); `type` picks the colour and defaults to a neutral\n * dark pill; `icon` is optional and drawn through `UiIcon`.\n *\n * The container does not capture pointer events, so it never blocks the UI\n * underneath; only the pills themselves do. Each pill is a `role=\"status\"`, so a\n * screen reader announces it politely without stealing focus.\n *\n * @example\n * <script setup>\n * import { ref } from 'vue'\n * const toasts = ref([])\n * let seq = 0\n * function notify(message, type = 'info') {\n * const id = ++seq\n * toasts.value.push({ id, message, type })\n * setTimeout(() => { toasts.value = toasts.value.filter((t) => t.id !== id) }, 3000)\n * }\n * <\\/script>\n *\n * <UiToast :toasts=\"toasts\" />\n * <UiButton @click=\"notify('Saved', 'success')\">Save</UiButton>\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * The messages to show. Each is `{ id, message, type?, icon? }`, where `id`\n * is stable and unique, `type` is one of the values below (default neutral),\n * and `icon` is an optional MDI name.\n * @type {Array<{ id: string|number, message: string, type?: string, icon?: string }>}\n * @default []\n */\n toasts: { type: Array, default: () => [] },\n\n /**\n * Where the stack anchors on screen.\n * @type {string}\n * @default 'top'\n * @values 'top' | 'bottom'\n */\n position: { type: String, default: 'top' },\n})\n\nconst positionClass = computed(() => (props.position === 'bottom' ? 'bottom-6' : 'top-6'))\n\n/**\n * Toast colours are drawn from the design tokens (`success`/`warning`/`error`)\n * rather than literal Tailwind palette names, so a rebrand of those ramps\n * carries through here too. Anything unrecognised falls back to a neutral pill.\n * @param {string} type\n */\nconst toastClass = (type) => {\n switch (type) {\n case 'success':\n return 'bg-success-600/90 text-white dark:bg-success-500/90'\n case 'warning':\n return 'bg-warning-500/90 text-white dark:bg-warning-500/90'\n case 'error':\n return 'bg-error-600/90 text-white dark:bg-error-500/90'\n default:\n return 'bg-gray-800/90 text-white dark:bg-gray-200/90 dark:text-gray-900'\n }\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEA,MAAM,QAAQ;EAmBd,MAAM,gBAAgB,eAAgB,MAAM,aAAa,WAAW,aAAa,OAAQ;;;;;;;EAQzF,MAAM,cAAc,SAAS;GAC3B,QAAQ,MAAR;IACE,KAAK,WACH,OAAO;IACT,KAAK,WACH,OAAO;IACT,KAAK,SACH,OAAO;IACT,SACE,OAAO;GACX;EACF;;GAvGE,OAAA,UAAA,GAAA,YAyBW,UAAA,EAzBD,IAAG,OAAM,GAAA,CACjB,mBAuBM,OAAA,EAtBJ,OAAK,eAAA,CAAC,gGACE,cAAA,KAAa,CAAA,EAAA,GAAA,CAErB,YAkBkB,iBAAA;IAjBhB,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAGb,SAAA,cAAuB,EADzB,UAAA,IAAA,GAAA,mBASM,UAAA,MAAA,WARY,QAAA,SAAT,UAAK;KADd,OAAA,UAAA,GAAA,mBASM,OAAA;MAPH,KAAK,MAAM;MACZ,OAAK,eAAA,CAAC,qHACE,WAAW,MAAM,IAAI,CAAA,CAAA;MAC7B,MAAK;KAES,GAAA,CAAA,MAAM,QAApB,UAAA,GAAA,YAAwE,aAAA;;MAA7C,MAAM,MAAM;MAAM,OAAM;KACnD,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,mBAAgC,QAAA,MAAA,gBAAvB,MAAM,OAAO,GAAA,CAAA,CAAA,GAAA,CAAA"}
|
package/dist/components/index.js
CHANGED
|
@@ -2,36 +2,41 @@ import _sfc_main from "../icons/Icon.js";
|
|
|
2
2
|
import _sfc_main$1 from "./Alert.js";
|
|
3
3
|
import _sfc_main$2 from "./Avatar.js";
|
|
4
4
|
import _sfc_main$3 from "./Badge.js";
|
|
5
|
-
import _sfc_main$4 from "./
|
|
6
|
-
import _sfc_main$5 from "./
|
|
7
|
-
import _sfc_main$6 from "./
|
|
5
|
+
import _sfc_main$4 from "./Banner.js";
|
|
6
|
+
import _sfc_main$5 from "./Breadcrumb.js";
|
|
7
|
+
import _sfc_main$6 from "./Button.js";
|
|
8
8
|
import _sfc_main$7 from "./Card.js";
|
|
9
9
|
import _sfc_main$8 from "./Checkbox.js";
|
|
10
|
-
import _sfc_main$9 from "./
|
|
11
|
-
import _sfc_main$10 from "./
|
|
12
|
-
import _sfc_main$11 from "./
|
|
13
|
-
import _sfc_main$12 from "./
|
|
14
|
-
import _sfc_main$13 from "./
|
|
15
|
-
import _sfc_main$14 from "./
|
|
16
|
-
import _sfc_main$15 from "./
|
|
17
|
-
import _sfc_main$16 from "./
|
|
18
|
-
import _sfc_main$17 from "./
|
|
19
|
-
import _sfc_main$18 from "./
|
|
20
|
-
import _sfc_main$19 from "./
|
|
21
|
-
import _sfc_main$20 from "./
|
|
22
|
-
import _sfc_main$21 from "./
|
|
23
|
-
import _sfc_main$22 from "./
|
|
24
|
-
import _sfc_main$23 from "./
|
|
25
|
-
import _sfc_main$24 from "./
|
|
26
|
-
import _sfc_main$25 from "./
|
|
27
|
-
import _sfc_main$26 from "./
|
|
28
|
-
import _sfc_main$27 from "./
|
|
29
|
-
import _sfc_main$28 from "./
|
|
30
|
-
import _sfc_main$29 from "./
|
|
31
|
-
import _sfc_main$30 from "./
|
|
32
|
-
import _sfc_main$31 from "./
|
|
33
|
-
import _sfc_main$32 from "./
|
|
34
|
-
import _sfc_main$33 from "./
|
|
10
|
+
import _sfc_main$9 from "./CodeBlock.js";
|
|
11
|
+
import _sfc_main$10 from "./Divider.js";
|
|
12
|
+
import _sfc_main$11 from "./Dropdown.js";
|
|
13
|
+
import _sfc_main$12 from "./DropdownItem.js";
|
|
14
|
+
import _sfc_main$13 from "./DropdownRow.js";
|
|
15
|
+
import _sfc_main$14 from "./DropdownSubmenu.js";
|
|
16
|
+
import _sfc_main$15 from "./FileInput.js";
|
|
17
|
+
import _sfc_main$16 from "./FormField.js";
|
|
18
|
+
import _sfc_main$17 from "./IconTile.js";
|
|
19
|
+
import _sfc_main$18 from "./Input.js";
|
|
20
|
+
import _sfc_main$19 from "./Kbd.js";
|
|
21
|
+
import _sfc_main$20 from "./ListMenu.js";
|
|
22
|
+
import _sfc_main$21 from "./ListMenuItem.js";
|
|
23
|
+
import _sfc_main$22 from "./Modal.js";
|
|
24
|
+
import _sfc_main$23 from "./Numpad.js";
|
|
25
|
+
import _sfc_main$24 from "./Popup.js";
|
|
26
|
+
import _sfc_main$25 from "./ProgressBar.js";
|
|
27
|
+
import _sfc_main$26 from "./Prompt.js";
|
|
28
|
+
import _sfc_main$27 from "./Radio.js";
|
|
29
|
+
import _sfc_main$28 from "./SectionHeading.js";
|
|
30
|
+
import _sfc_main$29 from "./Segmented.js";
|
|
31
|
+
import _sfc_main$30 from "./Select.js";
|
|
32
|
+
import _sfc_main$31 from "./Slider.js";
|
|
33
|
+
import _sfc_main$32 from "./Spinner.js";
|
|
34
|
+
import _sfc_main$33 from "./Stepper.js";
|
|
35
|
+
import _sfc_main$34 from "./Table.js";
|
|
36
|
+
import _sfc_main$35 from "./ThemeToggle.js";
|
|
37
|
+
import _sfc_main$36 from "./Toast.js";
|
|
38
|
+
import _sfc_main$37 from "./Toggle.js";
|
|
39
|
+
import _sfc_main$38 from "./Tooltip.js";
|
|
35
40
|
//#region src/components/index.js
|
|
36
41
|
/**
|
|
37
42
|
* Real component imports, re-exported under the default `Ui` prefix.
|
|
@@ -53,39 +58,44 @@ var components = {
|
|
|
53
58
|
Alert: _sfc_main$1,
|
|
54
59
|
Avatar: _sfc_main$2,
|
|
55
60
|
Badge: _sfc_main$3,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
Banner: _sfc_main$4,
|
|
62
|
+
Breadcrumb: _sfc_main$5,
|
|
63
|
+
Button: _sfc_main$6,
|
|
59
64
|
Card: _sfc_main$7,
|
|
60
65
|
Checkbox: _sfc_main$8,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
CodeBlock: _sfc_main$9,
|
|
67
|
+
Divider: _sfc_main$10,
|
|
68
|
+
Dropdown: _sfc_main$11,
|
|
69
|
+
DropdownItem: _sfc_main$12,
|
|
70
|
+
DropdownRow: _sfc_main$13,
|
|
71
|
+
DropdownSubmenu: _sfc_main$14,
|
|
72
|
+
FileInput: _sfc_main$15,
|
|
73
|
+
FormField: _sfc_main$16,
|
|
74
|
+
IconTile: _sfc_main$17,
|
|
75
|
+
Input: _sfc_main$18,
|
|
76
|
+
Kbd: _sfc_main$19,
|
|
77
|
+
ListMenu: _sfc_main$20,
|
|
78
|
+
ListMenuItem: _sfc_main$21,
|
|
79
|
+
Modal: _sfc_main$22,
|
|
80
|
+
Numpad: _sfc_main$23,
|
|
81
|
+
Popup: _sfc_main$24,
|
|
82
|
+
ProgressBar: _sfc_main$25,
|
|
83
|
+
Prompt: _sfc_main$26,
|
|
84
|
+
Radio: _sfc_main$27,
|
|
85
|
+
SectionHeading: _sfc_main$28,
|
|
86
|
+
Segmented: _sfc_main$29,
|
|
87
|
+
Select: _sfc_main$30,
|
|
88
|
+
Slider: _sfc_main$31,
|
|
89
|
+
Spinner: _sfc_main$32,
|
|
90
|
+
Stepper: _sfc_main$33,
|
|
91
|
+
Table: _sfc_main$34,
|
|
92
|
+
ThemeToggle: _sfc_main$35,
|
|
93
|
+
Toast: _sfc_main$36,
|
|
94
|
+
Toggle: _sfc_main$37,
|
|
95
|
+
Tooltip: _sfc_main$38,
|
|
86
96
|
Icon: _sfc_main
|
|
87
97
|
};
|
|
88
98
|
//#endregion
|
|
89
|
-
export { _sfc_main$1 as UiAlert, _sfc_main$2 as UiAvatar, _sfc_main$3 as UiBadge, _sfc_main$4 as
|
|
99
|
+
export { _sfc_main$1 as UiAlert, _sfc_main$2 as UiAvatar, _sfc_main$3 as UiBadge, _sfc_main$4 as UiBanner, _sfc_main$5 as UiBreadcrumb, _sfc_main$6 as UiButton, _sfc_main$7 as UiCard, _sfc_main$8 as UiCheckbox, _sfc_main$9 as UiCodeBlock, _sfc_main$10 as UiDivider, _sfc_main$11 as UiDropdown, _sfc_main$12 as UiDropdownItem, _sfc_main$13 as UiDropdownRow, _sfc_main$14 as UiDropdownSubmenu, _sfc_main$15 as UiFileInput, _sfc_main$16 as UiFormField, _sfc_main as UiIcon, _sfc_main$17 as UiIconTile, _sfc_main$18 as UiInput, _sfc_main$19 as UiKbd, _sfc_main$20 as UiListMenu, _sfc_main$21 as UiListMenuItem, _sfc_main$22 as UiModal, _sfc_main$23 as UiNumpad, _sfc_main$24 as UiPopup, _sfc_main$25 as UiProgressBar, _sfc_main$26 as UiPrompt, _sfc_main$27 as UiRadio, _sfc_main$28 as UiSectionHeading, _sfc_main$29 as UiSegmented, _sfc_main$30 as UiSelect, _sfc_main$31 as UiSlider, _sfc_main$32 as UiSpinner, _sfc_main$33 as UiStepper, _sfc_main$34 as UiTable, _sfc_main$35 as UiThemeToggle, _sfc_main$36 as UiToast, _sfc_main$37 as UiToggle, _sfc_main$38 as UiTooltip, components };
|
|
90
100
|
|
|
91
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/components/index.js"],"sourcesContent":["/**\n * Real component imports, re-exported under the default `Ui` prefix.\n *\n * The prefix is baked into the export names so that `import { UiButton }`\n * reads the same as `<UiButton>` in a template. Consumers who register the\n * library with a different prefix still import these names — only the\n * globally registered tag changes.\n *\n * `../manifest.js` carries the same list as plain data for build-time\n * consumers; `scripts/verify.mjs` keeps the two in sync.\n */\nimport Alert from './Alert.vue'\nimport Avatar from './Avatar.vue'\nimport Badge from './Badge.vue'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/components/index.js"],"sourcesContent":["/**\n * Real component imports, re-exported under the default `Ui` prefix.\n *\n * The prefix is baked into the export names so that `import { UiButton }`\n * reads the same as `<UiButton>` in a template. Consumers who register the\n * library with a different prefix still import these names — only the\n * globally registered tag changes.\n *\n * `../manifest.js` carries the same list as plain data for build-time\n * consumers; `scripts/verify.mjs` keeps the two in sync.\n */\nimport Alert from './Alert.vue'\nimport Avatar from './Avatar.vue'\nimport Badge from './Badge.vue'\nimport Banner from './Banner.vue'\nimport Breadcrumb from './Breadcrumb.vue'\nimport Button from './Button.vue'\nimport Card from './Card.vue'\nimport Checkbox from './Checkbox.vue'\nimport CodeBlock from './CodeBlock.vue'\nimport Divider from './Divider.vue'\nimport Dropdown from './Dropdown.vue'\nimport DropdownItem from './DropdownItem.vue'\nimport DropdownRow from './DropdownRow.vue'\nimport DropdownSubmenu from './DropdownSubmenu.vue'\nimport FileInput from './FileInput.vue'\nimport FormField from './FormField.vue'\nimport IconTile from './IconTile.vue'\nimport Input from './Input.vue'\nimport Kbd from './Kbd.vue'\nimport ListMenu from './ListMenu.vue'\nimport ListMenuItem from './ListMenuItem.vue'\nimport Modal from './Modal.vue'\nimport Numpad from './Numpad.vue'\nimport Popup from './Popup.vue'\nimport ProgressBar from './ProgressBar.vue'\nimport Prompt from './Prompt.vue'\nimport Radio from './Radio.vue'\nimport SectionHeading from './SectionHeading.vue'\nimport Segmented from './Segmented.vue'\nimport Select from './Select.vue'\nimport Slider from './Slider.vue'\nimport Spinner from './Spinner.vue'\nimport Stepper from './Stepper.vue'\nimport Table from './Table.vue'\nimport ThemeToggle from './ThemeToggle.vue'\nimport Toast from './Toast.vue'\nimport Toggle from './Toggle.vue'\nimport Tooltip from './Tooltip.vue'\nimport Icon from '../icons/Icon.vue'\n\nexport {\n Alert as UiAlert,\n Avatar as UiAvatar,\n Badge as UiBadge,\n Banner as UiBanner,\n Breadcrumb as UiBreadcrumb,\n Button as UiButton,\n Card as UiCard,\n Checkbox as UiCheckbox,\n CodeBlock as UiCodeBlock,\n Divider as UiDivider,\n Dropdown as UiDropdown,\n DropdownItem as UiDropdownItem,\n DropdownRow as UiDropdownRow,\n DropdownSubmenu as UiDropdownSubmenu,\n FileInput as UiFileInput,\n FormField as UiFormField,\n IconTile as UiIconTile,\n Input as UiInput,\n Kbd as UiKbd,\n ListMenu as UiListMenu,\n ListMenuItem as UiListMenuItem,\n Modal as UiModal,\n Numpad as UiNumpad,\n Popup as UiPopup,\n ProgressBar as UiProgressBar,\n Prompt as UiPrompt,\n Radio as UiRadio,\n SectionHeading as UiSectionHeading,\n Segmented as UiSegmented,\n Select as UiSelect,\n Slider as UiSlider,\n Spinner as UiSpinner,\n Stepper as UiStepper,\n Table as UiTable,\n ThemeToggle as UiThemeToggle,\n Toast as UiToast,\n Toggle as UiToggle,\n Tooltip as UiTooltip,\n Icon as UiIcon,\n}\n\n/**\n * Base-name -> component map, used by the Vue plugin to register everything\n * under whatever prefix the host chose.\n * @type {Record<string, import('vue').Component>}\n */\nexport const components = {\n Alert,\n Avatar,\n Badge,\n Banner,\n Breadcrumb,\n Button,\n Card,\n Checkbox,\n CodeBlock,\n Divider,\n Dropdown,\n DropdownItem,\n DropdownRow,\n DropdownSubmenu,\n FileInput,\n FormField,\n IconTile,\n Input,\n Kbd,\n ListMenu,\n ListMenuItem,\n Modal,\n Numpad,\n Popup,\n ProgressBar,\n Prompt,\n Radio,\n SectionHeading,\n Segmented,\n Select,\n Slider,\n Spinner,\n Stepper,\n Table,\n ThemeToggle,\n Toast,\n Toggle,\n Tooltip,\n Icon,\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA,IAAa,aAAa;CACxB,OAAA;CACA,QAAA;CACA,OAAA;CACA,QAAA;CACA,YAAA;CACA,QAAA;CACA,MAAA;CACA,UAAA;CACA,WAAA;CACA,SAAA;CACA,UAAA;CACA,cAAA;CACA,aAAA;CACA,iBAAA;CACA,WAAA;CACA,WAAA;CACA,UAAA;CACA,OAAA;CACA,KAAA;CACA,UAAA;CACA,cAAA;CACA,OAAA;CACA,QAAA;CACA,OAAA;CACA,aAAA;CACA,QAAA;CACA,OAAA;CACA,gBAAA;CACA,WAAA;CACA,QAAA;CACA,QAAA;CACA,SAAA;CACA,SAAA;CACA,OAAA;CACA,aAAA;CACA,OAAA;CACA,QAAA;CACA,SAAA;CACA,MAAA;AACF"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { computed, toValue, useAttrs } from "vue";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
//#region src/composables/useMergedClasses.js
|
|
4
|
+
/**
|
|
5
|
+
* useMergedClasses — merge a component's internal Tailwind classes with the
|
|
6
|
+
* caller's `class`, letting the caller win, and split the remaining attributes
|
|
7
|
+
* off for forwarding.
|
|
8
|
+
*
|
|
9
|
+
* This is the shared half of the "external classes override internals" pattern
|
|
10
|
+
* that UiButton, UiCard and UiIconTile all implement identically: bind
|
|
11
|
+
* `mergedClasses` to the root element's `:class`, spread `restAttrs` onto it
|
|
12
|
+
* with `v-bind`, and declare `defineOptions({ inheritAttrs: false })` in the
|
|
13
|
+
* component so Vue does not also apply `class` a second time.
|
|
14
|
+
*
|
|
15
|
+
* `tailwind-merge` resolves conflicts by keeping the last occurrence, and the
|
|
16
|
+
* caller's `class` is always passed last — so `bg-gray-100` from the outside
|
|
17
|
+
* beats a built-in `bg-primary-600` rather than both landing on the element.
|
|
18
|
+
* Passing the internal classes as one space-joined string is equivalent to
|
|
19
|
+
* passing them as separate arguments; twMerge tokenises either the same way.
|
|
20
|
+
*
|
|
21
|
+
* `defineOptions` is a compiler macro and cannot live in a composable, so each
|
|
22
|
+
* consuming SFC still declares `inheritAttrs: false` itself. Everything else —
|
|
23
|
+
* `useAttrs`, the class/rest split, and the merge — lives here.
|
|
24
|
+
*
|
|
25
|
+
* @param {import('vue').MaybeRefOrGetter<string>} internal
|
|
26
|
+
* The component's own classes, as a ref, getter, or plain string. A getter is
|
|
27
|
+
* the safest form when the internal classes are a `computed` declared later
|
|
28
|
+
* in setup, since it defers evaluation past that declaration.
|
|
29
|
+
* @returns {{ mergedClasses: import('vue').ComputedRef<string>, restAttrs: import('vue').ComputedRef<Record<string, unknown>> }}
|
|
30
|
+
* `mergedClasses` for the root `:class`; `restAttrs` (everything except
|
|
31
|
+
* `class`) for `v-bind`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* defineOptions({ inheritAttrs: false })
|
|
35
|
+
* const internal = computed(() => `inline-flex ${sizeClass.value} ${colorClass.value}`)
|
|
36
|
+
* const { mergedClasses, restAttrs } = useMergedClasses(internal)
|
|
37
|
+
*/
|
|
38
|
+
function useMergedClasses(internal) {
|
|
39
|
+
const attrs = useAttrs();
|
|
40
|
+
const restAttrs = computed(() => {
|
|
41
|
+
const { class: _class, ...rest } = attrs;
|
|
42
|
+
return rest;
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
mergedClasses: computed(() => twMerge(toValue(internal), attrs.class)),
|
|
46
|
+
restAttrs
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { useMergedClasses };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=useMergedClasses.js.map
|