numori-ui 0.4.0 → 0.6.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 +120 -0
- package/README.md +27 -20
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Avatar.js +71 -19
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Checkbox.js +11 -2
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CopyField.js +195 -0
- package/dist/components/CopyField.js.map +1 -0
- package/dist/components/DescriptionList.js +116 -0
- package/dist/components/DescriptionList.js.map +1 -0
- package/dist/components/Dropdown.js +3 -1
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/Input.js +15 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Modal.js +61 -4
- package/dist/components/Modal.js.map +1 -1
- package/dist/components/PageHeader.js +106 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.js +236 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/Prompt.js +11 -6
- package/dist/components/Prompt.js.map +1 -1
- package/dist/components/Segmented.js +10 -2
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +11 -2
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.js +69 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SidebarGroup.js +50 -0
- package/dist/components/SidebarGroup.js.map +1 -0
- package/dist/components/SidebarItem.js +167 -0
- package/dist/components/SidebarItem.js.map +1 -0
- package/dist/components/Skeleton.js +122 -0
- package/dist/components/Skeleton.js.map +1 -0
- package/dist/components/SplitPane.js +264 -0
- package/dist/components/SplitPane.js.map +1 -0
- package/dist/components/StatCard.js +185 -0
- package/dist/components/StatCard.js.map +1 -0
- package/dist/components/Table.js +182 -50
- package/dist/components/Table.js.map +1 -1
- package/dist/components/Tabs.js +216 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Toggle.js +11 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tree.js +417 -0
- package/dist/components/Tree.js.map +1 -0
- package/dist/components/VirtualList.js +292 -0
- package/dist/components/VirtualList.js.map +1 -0
- package/dist/components/index.js +105 -81
- package/dist/components/index.js.map +1 -1
- package/dist/icons/mdi.js +12 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +54 -39
- package/dist/index.js.map +1 -1
- package/dist/internal/focusTrap.js +163 -0
- package/dist/internal/focusTrap.js.map +1 -0
- package/dist/internal/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/manifest.js +16 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Avatar.vue +69 -18
- package/src/components/Checkbox.vue +5 -0
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +4 -1
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FormField.vue +37 -4
- package/src/components/Input.vue +9 -0
- package/src/components/Modal.vue +51 -3
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Prompt.vue +14 -3
- package/src/components/Segmented.vue +5 -0
- package/src/components/Select.vue +6 -1
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/Skeleton.vue +91 -0
- package/src/components/SplitPane.vue +264 -0
- package/src/components/StatCard.vue +165 -0
- package/src/components/Table.vue +148 -18
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/Tree.vue +428 -0
- package/src/components/VirtualList.vue +250 -0
- package/src/components/index.js +45 -6
- package/src/icons/mdi.js +12 -0
- package/src/internal/focusTrap.js +185 -0
- package/src/internal/formField.js +23 -0
- package/src/manifest.js +15 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, normalizeClass, openBlock, renderList, toDisplayString } from "vue";
|
|
3
|
+
//#region src/components/Pagination.vue
|
|
4
|
+
var _hoisted_1 = ["aria-label"];
|
|
5
|
+
var _hoisted_2 = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "text-sm text-gray-500 tabular-nums dark:text-gray-400"
|
|
8
|
+
};
|
|
9
|
+
var _hoisted_3 = { key: 1 };
|
|
10
|
+
var _hoisted_4 = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "flex items-center gap-1"
|
|
13
|
+
};
|
|
14
|
+
var _hoisted_5 = ["disabled", "aria-label"];
|
|
15
|
+
var _hoisted_6 = {
|
|
16
|
+
key: 0,
|
|
17
|
+
class: "inline-flex size-9 items-center justify-center text-sm text-gray-400 dark:text-gray-500",
|
|
18
|
+
"aria-hidden": "true"
|
|
19
|
+
};
|
|
20
|
+
var _hoisted_7 = [
|
|
21
|
+
"aria-current",
|
|
22
|
+
"aria-label",
|
|
23
|
+
"onClick"
|
|
24
|
+
];
|
|
25
|
+
var _hoisted_8 = ["disabled", "aria-label"];
|
|
26
|
+
var buttonBase = "inline-flex size-9 items-center justify-center rounded-lg text-sm font-medium tabular-nums transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500";
|
|
27
|
+
var _sfc_main = {
|
|
28
|
+
__name: "Pagination",
|
|
29
|
+
props: {
|
|
30
|
+
/**
|
|
31
|
+
* Current page, 1-based.
|
|
32
|
+
* @type {number}
|
|
33
|
+
* @default 1
|
|
34
|
+
*/
|
|
35
|
+
page: {
|
|
36
|
+
type: Number,
|
|
37
|
+
default: 1
|
|
38
|
+
},
|
|
39
|
+
/**
|
|
40
|
+
* Items per page.
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @default 20
|
|
43
|
+
*/
|
|
44
|
+
pageSize: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 20
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Total number of items.
|
|
50
|
+
* @type {number}
|
|
51
|
+
*/
|
|
52
|
+
total: {
|
|
53
|
+
type: Number,
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Pages shown either side of the current one.
|
|
58
|
+
* @type {number}
|
|
59
|
+
* @default 1
|
|
60
|
+
*/
|
|
61
|
+
siblings: {
|
|
62
|
+
type: Number,
|
|
63
|
+
default: 1
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Show the "from–to of total" summary.
|
|
67
|
+
* @type {boolean}
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
showSummary: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: true
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Builds the summary text from the 1-based range shown and the total.
|
|
76
|
+
* @type {(from: number, to: number, total: number) => string}
|
|
77
|
+
*/
|
|
78
|
+
formatSummary: {
|
|
79
|
+
type: Function,
|
|
80
|
+
default: (from, to, total) => total === 0 ? "No items" : `${from}–${to} of ${total}`
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Builds each page button's accessible label.
|
|
84
|
+
* @type {(page: number) => string}
|
|
85
|
+
*/
|
|
86
|
+
formatPageLabel: {
|
|
87
|
+
type: Function,
|
|
88
|
+
default: (page) => `Page ${page}`
|
|
89
|
+
},
|
|
90
|
+
/**
|
|
91
|
+
* Accessible label of the previous button.
|
|
92
|
+
* @type {string}
|
|
93
|
+
* @default 'Previous page'
|
|
94
|
+
*/
|
|
95
|
+
previousLabel: {
|
|
96
|
+
type: String,
|
|
97
|
+
default: "Previous page"
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Accessible label of the next button.
|
|
101
|
+
* @type {string}
|
|
102
|
+
* @default 'Next page'
|
|
103
|
+
*/
|
|
104
|
+
nextLabel: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: "Next page"
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Accessible name of the navigation landmark.
|
|
110
|
+
* @type {string}
|
|
111
|
+
* @default 'Pagination'
|
|
112
|
+
*/
|
|
113
|
+
ariaLabel: {
|
|
114
|
+
type: String,
|
|
115
|
+
default: "Pagination"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
emits: ["update:page"],
|
|
119
|
+
setup(__props, { emit: __emit }) {
|
|
120
|
+
/**
|
|
121
|
+
* UiPagination — page controls for a long list, with a "21–40 of 134" summary.
|
|
122
|
+
*
|
|
123
|
+
* Shows the first and last page, the current page and `siblings` pages either
|
|
124
|
+
* side of it, collapsing the rest into gaps, so the control stays the same
|
|
125
|
+
* width however many pages there are. On narrow screens only the current page
|
|
126
|
+
* and the arrows remain.
|
|
127
|
+
*
|
|
128
|
+
* Bind `v-model:page`; the component never fetches anything. All visible text
|
|
129
|
+
* is configurable for localisation.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* <UiPagination v-model:page="page" :page-size="20" :total="134" />
|
|
133
|
+
*
|
|
134
|
+
* @example Localised
|
|
135
|
+
* <UiPagination
|
|
136
|
+
* v-model:page="page"
|
|
137
|
+
* :total="total"
|
|
138
|
+
* previous-label="Anterior"
|
|
139
|
+
* next-label="Siguiente"
|
|
140
|
+
* :format-summary="(from, to, total) => `${from}–${to} de ${total}`"
|
|
141
|
+
* />
|
|
142
|
+
*
|
|
143
|
+
* @emits {number} update:page — The requested page (1-based).
|
|
144
|
+
*/
|
|
145
|
+
const props = __props;
|
|
146
|
+
const emit = __emit;
|
|
147
|
+
const pageCount = computed(() => Math.max(1, Math.ceil(Math.max(0, props.total) / Math.max(1, props.pageSize))));
|
|
148
|
+
const current = computed(() => Math.min(Math.max(1, props.page), pageCount.value));
|
|
149
|
+
const summaryText = computed(() => {
|
|
150
|
+
const total = Math.max(0, props.total);
|
|
151
|
+
const from = total === 0 ? 0 : (current.value - 1) * props.pageSize + 1;
|
|
152
|
+
const to = Math.min(total, current.value * props.pageSize);
|
|
153
|
+
return props.formatSummary(from, to, total);
|
|
154
|
+
});
|
|
155
|
+
/** First, last, current ± siblings, with gaps where pages are skipped. */
|
|
156
|
+
const items = computed(() => {
|
|
157
|
+
const last = pageCount.value;
|
|
158
|
+
const start = Math.max(2, current.value - props.siblings);
|
|
159
|
+
const end = Math.min(last - 1, current.value + props.siblings);
|
|
160
|
+
const out = [{
|
|
161
|
+
type: "page",
|
|
162
|
+
page: 1,
|
|
163
|
+
key: "p1"
|
|
164
|
+
}];
|
|
165
|
+
if (start > 2) out.push({
|
|
166
|
+
type: "gap",
|
|
167
|
+
key: "gap-start"
|
|
168
|
+
});
|
|
169
|
+
for (let p = start; p <= end; p++) out.push({
|
|
170
|
+
type: "page",
|
|
171
|
+
page: p,
|
|
172
|
+
key: `p${p}`
|
|
173
|
+
});
|
|
174
|
+
if (end < last - 1) out.push({
|
|
175
|
+
type: "gap",
|
|
176
|
+
key: "gap-end"
|
|
177
|
+
});
|
|
178
|
+
if (last > 1) out.push({
|
|
179
|
+
type: "page",
|
|
180
|
+
page: last,
|
|
181
|
+
key: `p${last}`
|
|
182
|
+
});
|
|
183
|
+
return out;
|
|
184
|
+
});
|
|
185
|
+
function go(page) {
|
|
186
|
+
const next = Math.min(Math.max(1, page), pageCount.value);
|
|
187
|
+
if (next !== current.value) emit("update:page", next);
|
|
188
|
+
}
|
|
189
|
+
const navClass = `${buttonBase} text-gray-600 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100`;
|
|
190
|
+
const pageClass = (page) => page === current.value ? `${buttonBase} bg-primary-600 text-white dark:bg-primary-500 dark:text-gray-950` : `${buttonBase} text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800`;
|
|
191
|
+
return (_ctx, _cache) => {
|
|
192
|
+
return openBlock(), createElementBlock("nav", {
|
|
193
|
+
"aria-label": __props.ariaLabel,
|
|
194
|
+
class: "flex flex-col items-center justify-between gap-3 sm:flex-row"
|
|
195
|
+
}, [__props.showSummary ? (openBlock(), createElementBlock("p", _hoisted_2, toDisplayString(summaryText.value), 1)) : (openBlock(), createElementBlock("span", _hoisted_3)), pageCount.value > 1 ? (openBlock(), createElementBlock("ul", _hoisted_4, [
|
|
196
|
+
createElementVNode("li", null, [createElementVNode("button", {
|
|
197
|
+
type: "button",
|
|
198
|
+
class: normalizeClass(navClass),
|
|
199
|
+
disabled: current.value <= 1,
|
|
200
|
+
"aria-label": __props.previousLabel,
|
|
201
|
+
onClick: _cache[0] || (_cache[0] = ($event) => go(current.value - 1))
|
|
202
|
+
}, [createVNode(_sfc_main$1, {
|
|
203
|
+
name: "mdi:chevron-left",
|
|
204
|
+
class: "size-4"
|
|
205
|
+
})], 8, _hoisted_5)]),
|
|
206
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item) => {
|
|
207
|
+
return openBlock(), createElementBlock("li", {
|
|
208
|
+
key: item.key,
|
|
209
|
+
class: normalizeClass(item.page === current.value ? "" : "hidden sm:block")
|
|
210
|
+
}, [item.type === "gap" ? (openBlock(), createElementBlock("span", _hoisted_6, "…")) : (openBlock(), createElementBlock("button", {
|
|
211
|
+
key: 1,
|
|
212
|
+
type: "button",
|
|
213
|
+
class: normalizeClass(pageClass(item.page)),
|
|
214
|
+
"aria-current": item.page === current.value ? "page" : void 0,
|
|
215
|
+
"aria-label": __props.formatPageLabel(item.page),
|
|
216
|
+
onClick: ($event) => go(item.page)
|
|
217
|
+
}, toDisplayString(item.page), 11, _hoisted_7))], 2);
|
|
218
|
+
}), 128)),
|
|
219
|
+
createElementVNode("li", null, [createElementVNode("button", {
|
|
220
|
+
type: "button",
|
|
221
|
+
class: normalizeClass(navClass),
|
|
222
|
+
disabled: current.value >= pageCount.value,
|
|
223
|
+
"aria-label": __props.nextLabel,
|
|
224
|
+
onClick: _cache[1] || (_cache[1] = ($event) => go(current.value + 1))
|
|
225
|
+
}, [createVNode(_sfc_main$1, {
|
|
226
|
+
name: "mdi:chevron-right",
|
|
227
|
+
class: "size-4"
|
|
228
|
+
})], 8, _hoisted_8)])
|
|
229
|
+
])) : createCommentVNode("", true)], 8, _hoisted_1);
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
//#endregion
|
|
234
|
+
export { _sfc_main as default };
|
|
235
|
+
|
|
236
|
+
//# sourceMappingURL=Pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pagination.js","names":[],"sources":["../../src/components/Pagination.vue"],"sourcesContent":["<template>\n <nav :aria-label=\"ariaLabel\" class=\"flex flex-col items-center justify-between gap-3 sm:flex-row\">\n <p v-if=\"showSummary\" class=\"text-sm text-gray-500 tabular-nums dark:text-gray-400\">\n {{ summaryText }}\n </p>\n <span v-else />\n\n <ul v-if=\"pageCount > 1\" class=\"flex items-center gap-1\">\n <li>\n <button\n type=\"button\"\n :class=\"navClass\"\n :disabled=\"current <= 1\"\n :aria-label=\"previousLabel\"\n @click=\"go(current - 1)\"\n >\n <UiIcon name=\"mdi:chevron-left\" class=\"size-4\" />\n </button>\n </li>\n <li\n v-for=\"item in items\"\n :key=\"item.key\"\n :class=\"item.page === current ? '' : 'hidden sm:block'\"\n >\n <span\n v-if=\"item.type === 'gap'\"\n class=\"inline-flex size-9 items-center justify-center text-sm text-gray-400 dark:text-gray-500\"\n aria-hidden=\"true\"\n >…</span\n >\n <button\n v-else\n type=\"button\"\n :class=\"pageClass(item.page)\"\n :aria-current=\"item.page === current ? 'page' : undefined\"\n :aria-label=\"formatPageLabel(item.page)\"\n @click=\"go(item.page)\"\n >\n {{ item.page }}\n </button>\n </li>\n <li>\n <button\n type=\"button\"\n :class=\"navClass\"\n :disabled=\"current >= pageCount\"\n :aria-label=\"nextLabel\"\n @click=\"go(current + 1)\"\n >\n <UiIcon name=\"mdi:chevron-right\" class=\"size-4\" />\n </button>\n </li>\n </ul>\n </nav>\n</template>\n\n<script setup>\n/**\n * UiPagination — page controls for a long list, with a \"21–40 of 134\" summary.\n *\n * Shows the first and last page, the current page and `siblings` pages either\n * side of it, collapsing the rest into gaps, so the control stays the same\n * width however many pages there are. On narrow screens only the current page\n * and the arrows remain.\n *\n * Bind `v-model:page`; the component never fetches anything. All visible text\n * is configurable for localisation.\n *\n * @example\n * <UiPagination v-model:page=\"page\" :page-size=\"20\" :total=\"134\" />\n *\n * @example Localised\n * <UiPagination\n * v-model:page=\"page\"\n * :total=\"total\"\n * previous-label=\"Anterior\"\n * next-label=\"Siguiente\"\n * :format-summary=\"(from, to, total) => `${from}–${to} de ${total}`\"\n * />\n *\n * @emits {number} update:page — The requested page (1-based).\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Current page, 1-based.\n * @type {number}\n * @default 1\n */\n page: { type: Number, default: 1 },\n\n /**\n * Items per page.\n * @type {number}\n * @default 20\n */\n pageSize: { type: Number, default: 20 },\n\n /**\n * Total number of items.\n * @type {number}\n */\n total: { type: Number, required: true },\n\n /**\n * Pages shown either side of the current one.\n * @type {number}\n * @default 1\n */\n siblings: { type: Number, default: 1 },\n\n /**\n * Show the \"from–to of total\" summary.\n * @type {boolean}\n * @default true\n */\n showSummary: { type: Boolean, default: true },\n\n /**\n * Builds the summary text from the 1-based range shown and the total.\n * @type {(from: number, to: number, total: number) => string}\n */\n formatSummary: {\n type: Function,\n default: (from, to, total) => (total === 0 ? 'No items' : `${from}–${to} of ${total}`),\n },\n\n /**\n * Builds each page button's accessible label.\n * @type {(page: number) => string}\n */\n formatPageLabel: { type: Function, default: (page) => `Page ${page}` },\n\n /**\n * Accessible label of the previous button.\n * @type {string}\n * @default 'Previous page'\n */\n previousLabel: { type: String, default: 'Previous page' },\n\n /**\n * Accessible label of the next button.\n * @type {string}\n * @default 'Next page'\n */\n nextLabel: { type: String, default: 'Next page' },\n\n /**\n * Accessible name of the navigation landmark.\n * @type {string}\n * @default 'Pagination'\n */\n ariaLabel: { type: String, default: 'Pagination' },\n})\n\nconst emit = defineEmits(['update:page'])\n\nconst pageCount = computed(() =>\n Math.max(1, Math.ceil(Math.max(0, props.total) / Math.max(1, props.pageSize))),\n)\nconst current = computed(() => Math.min(Math.max(1, props.page), pageCount.value))\n\nconst summaryText = computed(() => {\n const total = Math.max(0, props.total)\n const from = total === 0 ? 0 : (current.value - 1) * props.pageSize + 1\n const to = Math.min(total, current.value * props.pageSize)\n return props.formatSummary(from, to, total)\n})\n\n/** First, last, current ± siblings, with gaps where pages are skipped. */\nconst items = computed(() => {\n const last = pageCount.value\n const start = Math.max(2, current.value - props.siblings)\n const end = Math.min(last - 1, current.value + props.siblings)\n const out = [{ type: 'page', page: 1, key: 'p1' }]\n if (start > 2) out.push({ type: 'gap', key: 'gap-start' })\n for (let p = start; p <= end; p++) out.push({ type: 'page', page: p, key: `p${p}` })\n if (end < last - 1) out.push({ type: 'gap', key: 'gap-end' })\n if (last > 1) out.push({ type: 'page', page: last, key: `p${last}` })\n return out\n})\n\nfunction go(page) {\n const next = Math.min(Math.max(1, page), pageCount.value)\n if (next !== current.value) emit('update:page', next)\n}\n\nconst buttonBase =\n 'inline-flex size-9 items-center justify-center rounded-lg text-sm font-medium tabular-nums transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500'\n\nconst navClass = `${buttonBase} text-gray-600 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100`\n\nconst pageClass = (page) =>\n page === current.value\n ? `${buttonBase} bg-primary-600 text-white dark:bg-primary-500 dark:text-gray-950`\n : `${buttonBase} text-gray-700 hover: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,UAAA;;MAPP,MAAK;MACJ,OAAK,eAAE,UAAU,KAAK,IAAI,CAAA;MAC1B,gBAAc,KAAK,SAAS,QAAA,QAAO,SAAY,KAAA;MAC/C,cAAY,QAAA,gBAAgB,KAAK,IAAI;MACrC,UAAK,WAAE,GAAG,KAAK,IAAI;KAEjB,GAAA,gBAAA,KAAK,IAAI,GAAA,IAAA,UAAA,EAAA,GAAA,CAAA;;IAGhB,mBAUK,MAAA,MAAA,CATH,mBAQS,UAAA;KAPP,MAAK;KACJ,OAAK,eAAE,QAAQ;KACf,UAAU,QAAA,SAAW,UAAA;KACrB,cAAY,QAAA;KACZ,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,GAAG,QAAA,QAAO,CAAA;IAElB,GAAA,CAAA,YAAkD,aAAA;KAA1C,MAAK;KAAoB,OAAM"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
2
|
import _sfc_main$2 from "./Button.js";
|
|
3
3
|
import _sfc_main$3 from "./Modal.js";
|
|
4
|
-
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useSlots, watch, withCtx } from "vue";
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, openBlock, ref, renderSlot, toDisplayString, useId, useSlots, watch, withCtx } from "vue";
|
|
5
5
|
//#region src/components/Prompt.vue
|
|
6
6
|
var _hoisted_1 = { class: "flex items-center justify-between p-4 pb-0 mb-3 shrink-0" };
|
|
7
7
|
var _hoisted_2 = { class: "flex items-center gap-2" };
|
|
8
|
-
var _hoisted_3 = { class: "
|
|
9
|
-
var _hoisted_4 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
|
|
8
|
+
var _hoisted_3 = { class: "flex justify-end gap-2 p-4 pt-0 shrink-0" };
|
|
10
9
|
var _sfc_main = {
|
|
11
10
|
__name: "Prompt",
|
|
12
11
|
props: {
|
|
@@ -105,6 +104,7 @@ var _sfc_main = {
|
|
|
105
104
|
const props = __props;
|
|
106
105
|
const emit = __emit;
|
|
107
106
|
const confirmRef = ref(null);
|
|
107
|
+
const titleId = `${useId()}-title`;
|
|
108
108
|
const hasCustomActions = computed(() => !!useSlots().actions);
|
|
109
109
|
const iconColorClass = computed(() => {
|
|
110
110
|
const map = {
|
|
@@ -139,6 +139,7 @@ var _sfc_main = {
|
|
|
139
139
|
"max-width": "sm",
|
|
140
140
|
"fullscreen-mobile": __props.fullscreenMobile,
|
|
141
141
|
"panel-class": __props.panelClass,
|
|
142
|
+
labelledby: titleId,
|
|
142
143
|
onClose: handleClose
|
|
143
144
|
}, {
|
|
144
145
|
default: withCtx(() => [createElementVNode("div", {
|
|
@@ -150,10 +151,14 @@ var _sfc_main = {
|
|
|
150
151
|
key: 0,
|
|
151
152
|
name: __props.icon,
|
|
152
153
|
class: normalizeClass(["w-5 h-5", iconColorClass.value])
|
|
153
|
-
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2",
|
|
154
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), createElementVNode("h2", {
|
|
155
|
+
id: titleId,
|
|
156
|
+
class: "text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none"
|
|
157
|
+
}, toDisplayString(__props.title), 1)]), createVNode(_sfc_main$2, {
|
|
154
158
|
variant: "ghost",
|
|
155
159
|
color: "gray",
|
|
156
160
|
"icon-only": "",
|
|
161
|
+
"aria-label": __props.cancelLabel,
|
|
157
162
|
onClick: handleClose
|
|
158
163
|
}, {
|
|
159
164
|
default: withCtx(() => [createVNode(_sfc_main$1, {
|
|
@@ -161,12 +166,12 @@ var _sfc_main = {
|
|
|
161
166
|
class: "block w-5 h-5"
|
|
162
167
|
})]),
|
|
163
168
|
_: 1
|
|
164
|
-
})]),
|
|
169
|
+
}, 8, ["aria-label"])]),
|
|
165
170
|
__props.body || _ctx.$slots.default ? (openBlock(), createElementBlock("div", {
|
|
166
171
|
key: 0,
|
|
167
172
|
class: normalizeClass(["text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0", __props.panelClass.includes("overflow-visible") ? "overflow-visible" : "overflow-y-auto"])
|
|
168
173
|
}, [renderSlot(_ctx.$slots, "default", {}, () => [createTextVNode(toDisplayString(__props.body), 1)])], 2)) : createCommentVNode("", true),
|
|
169
|
-
createElementVNode("div",
|
|
174
|
+
createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "actions", {}, () => [createVNode(_sfc_main$2, {
|
|
170
175
|
variant: "ghost",
|
|
171
176
|
color: "gray",
|
|
172
177
|
disabled: __props.loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2
|
|
1
|
+
{"version":3,"file":"Prompt.js","names":["$slots"],"sources":["../../src/components/Prompt.vue"],"sourcesContent":["<template>\n <UiModal\n :show=\"show\"\n max-width=\"sm\"\n :fullscreen-mobile=\"fullscreenMobile\"\n :panel-class=\"panelClass\"\n :labelledby=\"titleId\"\n @close=\"handleClose\"\n >\n <div\n ref=\"promptRef\"\n class=\"flex flex-col max-h-full\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-hidden'\"\n @keydown=\"onKeydown\"\n >\n <div class=\"flex items-center justify-between p-4 pb-0 mb-3 shrink-0\">\n <div class=\"flex items-center gap-2\">\n <UiIcon v-if=\"icon\" :name=\"icon\" class=\"w-5 h-5\" :class=\"iconColorClass\" />\n <h2\n :id=\"titleId\"\n class=\"text-sm font-semibold text-gray-900 dark:text-gray-200 leading-none\"\n >\n {{ title }}\n </h2>\n </div>\n <UiButton\n variant=\"ghost\"\n color=\"gray\"\n icon-only\n :aria-label=\"cancelLabel\"\n @click=\"handleClose\"\n >\n <UiIcon name=\"mdi:close\" class=\"block w-5 h-5\" />\n </UiButton>\n </div>\n\n <div\n v-if=\"body || $slots.default\"\n class=\"text-sm text-gray-600 dark:text-gray-400 mb-4 leading-relaxed px-4 min-h-0\"\n :class=\"panelClass.includes('overflow-visible') ? 'overflow-visible' : 'overflow-y-auto'\"\n >\n <slot>{{ body }}</slot>\n </div>\n\n <div class=\"flex justify-end gap-2 p-4 pt-0 shrink-0\">\n <slot name=\"actions\">\n <UiButton variant=\"ghost\" color=\"gray\" :disabled=\"loading\" @click=\"handleClose\">\n {{ cancelLabel }}\n </UiButton>\n <UiButton\n ref=\"confirmRef\"\n variant=\"solid\"\n :color=\"confirmColor\"\n :loading=\"loading\"\n @click=\"handleConfirm\"\n >\n {{ confirmLabel }}\n </UiButton>\n </slot>\n </div>\n </div>\n </UiModal>\n</template>\n\n<script setup>\n/**\n * UiPrompt — A modal prompt primitive for confirmations, choices, and user decisions.\n *\n * Wraps UiModal with a consistent header (icon + title + close), body content, and\n * action buttons. Handles keyboard (Escape to close, Enter to confirm), auto-focuses\n * the confirm button on open, and prevents double-submit while loading.\n *\n * For simple text prompts, use the `body` prop. For rich content, use the default slot.\n * Override the `#actions` slot for custom button layouts.\n *\n * @example Simple confirmation (props only, no slots needed)\n * <UiPrompt :show=\"confirming\" title=\"Delete item?\" body=\"This action cannot be undone.\"\n * icon=\"mdi:delete\" confirm-label=\"Delete\" confirm-color=\"red\"\n * @close=\"confirming = false\" @confirm=\"doDelete\" />\n *\n * @example Rich body content\n * <UiPrompt :show=\"open\" title=\"Warning\" @close=\"open = false\" @confirm=\"proceed\">\n * <p>This will affect <strong>{{ count }}</strong> items.</p>\n * </UiPrompt>\n *\n * @example Custom actions\n * <UiPrompt :show=\"choosing\" title=\"Export Options\" @close=\"choosing = false\">\n * Include results in the export?\n * <template #actions>\n * <UiButton variant=\"ghost\" color=\"gray\" @click=\"doExport(false)\">Without</UiButton>\n * <UiButton @click=\"doExport(true)\">With Results</UiButton>\n * </template>\n * </UiPrompt>\n *\n * @example Form prompt (disable Enter-to-confirm)\n * <UiPrompt :show=\"open\" title=\"New Group\" :confirm-on-enter=\"false\" @close=\"open = false\">\n * <UiInput v-model=\"name\" @keydown.enter=\"save\" />\n * </UiPrompt>\n */\nimport { ref, computed, watch, nextTick, useSlots, useId } from 'vue'\nimport UiButton from './Button.vue'\nimport UiModal from './Modal.vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /** Controls prompt visibility. */\n show: { type: Boolean, default: false },\n /** Prompt heading text. */\n title: { type: String, default: 'Confirm' },\n /** Optional icon name displayed before the title. */\n icon: { type: String, default: null },\n /** Plain text body content. Ignored when the default slot is used. */\n body: { type: String, default: null },\n /** Label for the confirm button (default actions only). */\n confirmLabel: { type: String, default: 'Confirm' },\n /** Label for the cancel button (default actions only). */\n cancelLabel: { type: String, default: 'Cancel' },\n /** Color of the confirm button and icon. */\n confirmColor: { type: String, default: 'primary' },\n /** Shows a loading spinner on the confirm button and prevents double-submit. */\n loading: { type: Boolean, default: false },\n /** Whether pressing Enter triggers confirm. Disable for form-based prompts. */\n confirmOnEnter: { type: Boolean, default: true },\n /** Whether the prompt goes fullscreen on mobile viewports. */\n fullscreenMobile: { type: Boolean, default: false },\n /** Additional CSS class(es) applied to the modal panel element. */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['close', 'confirm'])\n\nconst confirmRef = ref(null)\nconst titleId = `${useId()}-title`\nconst hasCustomActions = computed(() => !!useSlots().actions)\n\nconst iconColorClass = computed(() => {\n const map = {\n red: 'text-red-600 dark:text-red-400',\n amber: 'text-amber-600 dark:text-amber-400',\n primary: 'text-primary-600 dark:text-primary-400',\n gray: 'text-gray-500 dark:text-gray-400',\n }\n return map[props.confirmColor] || map.primary\n})\n\nconst handleClose = () => {\n if (!props.loading) emit('close')\n}\n\nconst handleConfirm = () => {\n if (!props.loading) emit('confirm')\n}\n\nconst onKeydown = (e) => {\n if (e.key === 'Enter' && props.confirmOnEnter && !hasCustomActions.value && !props.loading) {\n e.preventDefault()\n handleConfirm()\n }\n}\n\n// Auto-focus confirm button when prompt opens\nwatch(\n () => props.show,\n (open) => {\n if (open) {\n nextTick(() => {\n const el = confirmRef.value?.$el ?? confirmRef.value\n if (el instanceof HTMLElement) el.focus()\n })\n }\n },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuGA,MAAM,QAAQ;EAyBd,MAAM,OAAO;EAEb,MAAM,aAAa,IAAI,IAAI;EAC3B,MAAM,UAAU,GAAG,MAAM,EAAE;EAC3B,MAAM,mBAAmB,eAAe,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO;EAE5D,MAAM,iBAAiB,eAAe;GACpC,MAAM,MAAM;IACV,KAAK;IACL,OAAO;IACP,SAAS;IACT,MAAM;GACR;GACA,OAAO,IAAI,MAAM,iBAAiB,IAAI;EACxC,CAAC;EAED,MAAM,oBAAoB;GACxB,IAAI,CAAC,MAAM,SAAS,KAAK,OAAO;EAClC;EAEA,MAAM,sBAAsB;GAC1B,IAAI,CAAC,MAAM,SAAS,KAAK,SAAS;EACpC;EAEA,MAAM,aAAa,MAAM;GACvB,IAAI,EAAE,QAAQ,WAAW,MAAM,kBAAkB,CAAC,iBAAiB,SAAS,CAAC,MAAM,SAAS;IAC1F,EAAE,eAAe;IACj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,IAAA,IAAA;KAGf,mBAeM,OAfN,YAeM,CAdJ,WAaO,KAAA,QAAA,WAAA,CAAA,SAAA,CAZL,YAEW,aAAA;MAFD,SAAQ;MAAQ,OAAM;MAAQ,UAAU,QAAA;MAAU,SAAO;;MACjE,SAAA,cAAiB,CAAd,gBAAA,gBAAA,QAAA,WAAW,GAAA,CAAA,CAAA,CAAA;;KAEhB,GAAA,GAAA,CAAA,UAAA,CAAA,GAAA,YAQW,aAAA;MAPL,SAAA;MAAJ,KAAI;MACJ,SAAQ;MACP,OAAO,QAAA;MACP,SAAS,QAAA;MACT,SAAO;;MAER,SAAA,cAAkB,CAAf,gBAAA,gBAAA,QAAA,YAAY,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFormField } from "../internal/formField.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, openBlock, renderList, toDisplayString, unref } from "vue";
|
|
3
4
|
//#region src/components/Segmented.vue
|
|
4
|
-
var _hoisted_1 = [
|
|
5
|
+
var _hoisted_1 = [
|
|
6
|
+
"aria-label",
|
|
7
|
+
"aria-labelledby",
|
|
8
|
+
"aria-describedby"
|
|
9
|
+
];
|
|
5
10
|
var _hoisted_2 = [
|
|
6
11
|
"aria-pressed",
|
|
7
12
|
"disabled",
|
|
@@ -146,6 +151,7 @@ var _sfc_main = {
|
|
|
146
151
|
*/
|
|
147
152
|
const props = __props;
|
|
148
153
|
const emit = __emit;
|
|
154
|
+
const field = useFormField();
|
|
149
155
|
const count = computed(() => props.options?.length || 1);
|
|
150
156
|
const isActive = (option) => option.value === props.modelValue;
|
|
151
157
|
const activeIndex = computed(() => {
|
|
@@ -184,6 +190,8 @@ var _sfc_main = {
|
|
|
184
190
|
return openBlock(), createElementBlock("div", {
|
|
185
191
|
role: "group",
|
|
186
192
|
"aria-label": __props.ariaLabel,
|
|
193
|
+
"aria-labelledby": __props.ariaLabel ? void 0 : unref(field)?.labelId,
|
|
194
|
+
"aria-describedby": unref(field)?.describedBy.value,
|
|
187
195
|
class: normalizeClass(["relative p-1", [
|
|
188
196
|
__props.block ? "grid w-full" : "inline-grid",
|
|
189
197
|
radiusClass.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Segmented.js","names":[],"sources":["../../src/components/Segmented.vue"],"sourcesContent":["<template>\n <div\n role=\"group\"\n :aria-label=\"ariaLabel\"\n class=\"relative p-1\"\n :class=\"[\n block ? 'grid w-full' : 'inline-grid',\n radiusClass,\n 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900',\n ]\"\n :style=\"gridStyle\"\n >\n <!--\n A single indicator slides between segments, so changing the selection\n animates in every variant. Segments are equal-width grid columns, so the\n indicator is one column wide and translates by whole columns. The variant\n only changes how the indicator looks (accent fill vs raised surface); the\n sliding mechanism is shared.\n -->\n <span\n aria-hidden=\"true\"\n class=\"pointer-events-none absolute bottom-1 left-1 top-1 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none\"\n :class=\"[radiusClass, indicatorClass]\"\n :style=\"indicatorStyle\"\n />\n\n <button\n v-for=\"option in options\"\n :key=\"option.value\"\n type=\"button\"\n :aria-pressed=\"isActive(option) ? 'true' : 'false'\"\n :disabled=\"option.disabled\"\n :title=\"option.title || undefined\"\n class=\"relative z-10 inline-flex items-center justify-center gap-1.5 font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50\"\n :class=\"[buttonSizeClass, radiusClass, isActive(option) ? activeTextClass : idleTextClass]\"\n @click=\"select(option)\"\n >\n <UiIcon v-if=\"option.icon\" :name=\"option.icon\" :class=\"iconSizeClass\" />\n <span v-if=\"option.label\">{{ option.label }}</span>\n </button>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSegmented — a segmented control: pick one of a few named options from a row\n * of segments, with an indicator that slides to the active choice.\n *\n * This is a set of toggle buttons (`role=\"group\"` + `aria-pressed`), not a\n * switch, because the choice is between named options rather than on/off — \"the\n * second option is off\" is not something a screen reader should say. Segments\n * are equal width so the indicator can slide by whole columns, and the slide\n * animates in both variants.\n *\n * The `variant` values match `UiButton`'s — `solid`, `outline`, `ghost` — so a\n * segmented control sits alongside buttons as part of one visual family. The\n * indicator slides (and animates) to the active choice in every variant.\n *\n * - `variant=\"solid\"` (default) — a filled accent indicator; the active label\n * goes white. Like a solid button.\n * - `variant=\"outline\"` — a bordered accent indicator; the active label takes\n * the accent colour. Like an outline button.\n * - `variant=\"ghost\"` — a soft tinted indicator; the active label takes the\n * accent colour. Like a ghost button.\n *\n * `shape` controls the corners — `pill`, `round`, or `square` (matching\n * `UiButton`) — and the indicator matches the track's radius.\n *\n * For an on/off control use `UiToggle`; for many options or a searchable list\n * use `UiSelect`.\n *\n * @example Billing period (solid, the default)\n * <UiSegmented\n * v-model=\"billing\"\n * :options=\"[\n * { value: 'monthly', label: 'Monthly' },\n * { value: 'yearly', label: 'Yearly' },\n * ]\"\n * aria-label=\"Billing period\"\n * />\n *\n * @example Icon toolbar (outline, square corners)\n * <UiSegmented\n * v-model=\"view\"\n * variant=\"outline\"\n * shape=\"square\"\n * :options=\"[\n * { value: 'grid', icon: 'mdi:view-grid', title: 'Grid' },\n * { value: 'list', icon: 'mdi:view-list', title: 'List' },\n * ]\"\n * aria-label=\"View\"\n * />\n *\n * @example Full-width ghost tabs\n * <UiSegmented v-model=\"tab\" variant=\"ghost\" block :options=\"tabs\" />\n *\n * @emits {string|number} update:modelValue — the chosen option's `value`\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Selected value (v-model), matched against each option's `value`.\n * @type {string | number}\n * @default undefined\n */\n modelValue: { type: [String, Number], default: undefined },\n\n /**\n * The options. Each is `{ value, label?, icon?, disabled?, title? }`. Provide\n * `label` for text segments, `icon` for icon-only segments, or both. `title`\n * sets the native tooltip (useful for icon-only segments).\n * @type {Array<{ value: string|number, label?: string, icon?: string, disabled?: boolean, title?: string }>}\n */\n options: { type: Array, required: true },\n\n /**\n * Active-segment appearance, mirroring the equivalent `UiButton` variants so\n * the two feel like one family. The sliding indicator animates in every case.\n * - 'solid' — a filled accent indicator; the active label goes white (default).\n * - 'outline' — a bordered accent indicator; the active label takes the accent.\n * - 'ghost' — a soft tinted indicator; the active label takes the accent.\n * @type {string}\n * @default 'solid'\n * @values 'solid' | 'outline' | 'ghost'\n */\n variant: { type: String, default: 'solid' },\n\n /**\n * Size preset controlling padding and font size.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Corner shape of the track, indicator, and segments. Matches `UiButton`'s\n * `shape` naming.\n * @type {string}\n * @default 'pill'\n * @values 'pill' | 'round' | 'square'\n */\n shape: { type: String, default: 'pill' },\n\n /**\n * Full-width mode — the control fills its container and segments share the\n * width equally.\n * @type {boolean}\n * @default false\n */\n block: { type: Boolean, default: false },\n\n /**\n * Accessible name for the group. Omit if you label it with an external\n * heading via `aria-labelledby` (which falls through to the root).\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst count = computed(() => props.options?.length || 1)\n\nconst isActive = (option) => option.value === props.modelValue\n\nconst activeIndex = computed(() => {\n const i = (props.options ?? []).findIndex((o) => o.value === props.modelValue)\n return i === -1 ? 0 : i\n})\n\nfunction select(option) {\n if (option.disabled) return\n emit('update:modelValue', option.value)\n}\n\nconst gridStyle = computed(() => ({\n gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))`,\n}))\n\n// ── Shape ─────────────────────────────────────────────────\n// The track, the sliding indicator, and the segments all share one radius so\n// the indicator's corners match the holder's rather than reading as a tighter\n// (or looser) curve inside it.\nconst radiusClass = computed(() => {\n const map = { pill: 'rounded-full', round: 'rounded-lg', square: 'rounded-none' }\n return map[props.shape] ?? map.pill\n})\n\n// ── Size ──────────────────────────────────────────────────\nconst buttonSizeClass = computed(() =>\n props.size === 'sm' ? 'px-3 py-1 text-xs' : 'px-4 py-1.5 text-sm',\n)\nconst iconSizeClass = computed(() => (props.size === 'sm' ? 'size-3.5' : 'size-4'))\n\n// ── Variant: indicator look + active label colour ─────────\n// These mirror UiButton's solid / outline / ghost variants (primary colour) so\n// a segmented control reads as part of the same family as the buttons near it.\nconst indicatorClass = computed(() => {\n const map = {\n solid: 'bg-primary-600 shadow-sm',\n outline: 'border border-primary-500',\n ghost: 'bg-primary-50 dark:bg-primary-900/20',\n }\n return map[props.variant] ?? map.solid\n})\nconst activeTextClass = computed(() =>\n props.variant === 'solid' ? 'text-white' : 'text-primary-600 dark:text-primary-400',\n)\nconst idleTextClass =\n 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'\n\nconst indicatorStyle = computed(() => ({\n // Track padding is p-1 (0.25rem) each side, so the usable width is\n // `100% - 0.5rem`; one segment is that divided by the option count.\n width: `calc((100% - 0.5rem) / ${count.value})`,\n transform: `translateX(calc(${activeIndex.value} * 100%))`,\n}))\n</script>\n"],"mappings":";;;;;;;;;;;AAoNA,IAAM,gBACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAhHF,MAAM,QAAQ;EA8Dd,MAAM,OAAO;EAEb,MAAM,QAAQ,eAAe,MAAM,SAAS,UAAU,CAAC;EAEvD,MAAM,YAAY,WAAW,OAAO,UAAU,MAAM;EAEpD,MAAM,cAAc,eAAe;GACjC,MAAM,KAAK,MAAM,WAAW,CAAC,EAAA,CAAG,WAAW,MAAM,EAAE,UAAU,MAAM,UAAU;GAC7E,OAAO,MAAM,KAAK,IAAI;EACxB,CAAC;EAED,SAAS,OAAO,QAAQ;GACtB,IAAI,OAAO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AA;KACxB,OAAK,eAAA,CAAC,iJAA+I;MAC5I,gBAAA;MAAiB,YAAA;MAAa,SAAS,MAAM,IAAI,gBAAA,QAAkB;KAAa,CAAA,CAAA;KACxF,UAAK,WAAE,OAAO,MAAM;IAEP,GAAA,CAAA,OAAO,QAArB,UAAA,GAAA,YAAwE,aAAA;;KAA5C,MAAM,OAAO;KAAO,OAAK,eAAE,cAAA,KAAa;IACxD,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,OAAO,SAAnB,UAAA,GAAA,mBAAmD,QAAA,YAAA,gBAAtB,OAAO,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,GAAA,IAAA,UAAA"}
|
|
1
|
+
{"version":3,"file":"Segmented.js","names":[],"sources":["../../src/components/Segmented.vue"],"sourcesContent":["<template>\n <div\n role=\"group\"\n :aria-label=\"ariaLabel\"\n :aria-labelledby=\"ariaLabel ? undefined : field?.labelId\"\n :aria-describedby=\"field?.describedBy.value\"\n class=\"relative p-1\"\n :class=\"[\n block ? 'grid w-full' : 'inline-grid',\n radiusClass,\n 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900',\n ]\"\n :style=\"gridStyle\"\n >\n <!--\n A single indicator slides between segments, so changing the selection\n animates in every variant. Segments are equal-width grid columns, so the\n indicator is one column wide and translates by whole columns. The variant\n only changes how the indicator looks (accent fill vs raised surface); the\n sliding mechanism is shared.\n -->\n <span\n aria-hidden=\"true\"\n class=\"pointer-events-none absolute bottom-1 left-1 top-1 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none\"\n :class=\"[radiusClass, indicatorClass]\"\n :style=\"indicatorStyle\"\n />\n\n <button\n v-for=\"option in options\"\n :key=\"option.value\"\n type=\"button\"\n :aria-pressed=\"isActive(option) ? 'true' : 'false'\"\n :disabled=\"option.disabled\"\n :title=\"option.title || undefined\"\n class=\"relative z-10 inline-flex items-center justify-center gap-1.5 font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50\"\n :class=\"[buttonSizeClass, radiusClass, isActive(option) ? activeTextClass : idleTextClass]\"\n @click=\"select(option)\"\n >\n <UiIcon v-if=\"option.icon\" :name=\"option.icon\" :class=\"iconSizeClass\" />\n <span v-if=\"option.label\">{{ option.label }}</span>\n </button>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSegmented — a segmented control: pick one of a few named options from a row\n * of segments, with an indicator that slides to the active choice.\n *\n * This is a set of toggle buttons (`role=\"group\"` + `aria-pressed`), not a\n * switch, because the choice is between named options rather than on/off — \"the\n * second option is off\" is not something a screen reader should say. Segments\n * are equal width so the indicator can slide by whole columns, and the slide\n * animates in both variants.\n *\n * The `variant` values match `UiButton`'s — `solid`, `outline`, `ghost` — so a\n * segmented control sits alongside buttons as part of one visual family. The\n * indicator slides (and animates) to the active choice in every variant.\n *\n * - `variant=\"solid\"` (default) — a filled accent indicator; the active label\n * goes white. Like a solid button.\n * - `variant=\"outline\"` — a bordered accent indicator; the active label takes\n * the accent colour. Like an outline button.\n * - `variant=\"ghost\"` — a soft tinted indicator; the active label takes the\n * accent colour. Like a ghost button.\n *\n * `shape` controls the corners — `pill`, `round`, or `square` (matching\n * `UiButton`) — and the indicator matches the track's radius.\n *\n * For an on/off control use `UiToggle`; for many options or a searchable list\n * use `UiSelect`.\n *\n * @example Billing period (solid, the default)\n * <UiSegmented\n * v-model=\"billing\"\n * :options=\"[\n * { value: 'monthly', label: 'Monthly' },\n * { value: 'yearly', label: 'Yearly' },\n * ]\"\n * aria-label=\"Billing period\"\n * />\n *\n * @example Icon toolbar (outline, square corners)\n * <UiSegmented\n * v-model=\"view\"\n * variant=\"outline\"\n * shape=\"square\"\n * :options=\"[\n * { value: 'grid', icon: 'mdi:view-grid', title: 'Grid' },\n * { value: 'list', icon: 'mdi:view-list', title: 'List' },\n * ]\"\n * aria-label=\"View\"\n * />\n *\n * @example Full-width ghost tabs\n * <UiSegmented v-model=\"tab\" variant=\"ghost\" block :options=\"tabs\" />\n *\n * @emits {string|number} update:modelValue — the chosen option's `value`\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useFormField } from '../internal/formField.js'\n\nconst props = defineProps({\n /**\n * Selected value (v-model), matched against each option's `value`.\n * @type {string | number}\n * @default undefined\n */\n modelValue: { type: [String, Number], default: undefined },\n\n /**\n * The options. Each is `{ value, label?, icon?, disabled?, title? }`. Provide\n * `label` for text segments, `icon` for icon-only segments, or both. `title`\n * sets the native tooltip (useful for icon-only segments).\n * @type {Array<{ value: string|number, label?: string, icon?: string, disabled?: boolean, title?: string }>}\n */\n options: { type: Array, required: true },\n\n /**\n * Active-segment appearance, mirroring the equivalent `UiButton` variants so\n * the two feel like one family. The sliding indicator animates in every case.\n * - 'solid' — a filled accent indicator; the active label goes white (default).\n * - 'outline' — a bordered accent indicator; the active label takes the accent.\n * - 'ghost' — a soft tinted indicator; the active label takes the accent.\n * @type {string}\n * @default 'solid'\n * @values 'solid' | 'outline' | 'ghost'\n */\n variant: { type: String, default: 'solid' },\n\n /**\n * Size preset controlling padding and font size.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Corner shape of the track, indicator, and segments. Matches `UiButton`'s\n * `shape` naming.\n * @type {string}\n * @default 'pill'\n * @values 'pill' | 'round' | 'square'\n */\n shape: { type: String, default: 'pill' },\n\n /**\n * Full-width mode — the control fills its container and segments share the\n * width equally.\n * @type {boolean}\n * @default false\n */\n block: { type: Boolean, default: false },\n\n /**\n * Accessible name for the group. Omit if you label it with an external\n * heading via `aria-labelledby` (which falls through to the root).\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst field = useFormField()\n\nconst count = computed(() => props.options?.length || 1)\n\nconst isActive = (option) => option.value === props.modelValue\n\nconst activeIndex = computed(() => {\n const i = (props.options ?? []).findIndex((o) => o.value === props.modelValue)\n return i === -1 ? 0 : i\n})\n\nfunction select(option) {\n if (option.disabled) return\n emit('update:modelValue', option.value)\n}\n\nconst gridStyle = computed(() => ({\n gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))`,\n}))\n\n// ── Shape ─────────────────────────────────────────────────\n// The track, the sliding indicator, and the segments all share one radius so\n// the indicator's corners match the holder's rather than reading as a tighter\n// (or looser) curve inside it.\nconst radiusClass = computed(() => {\n const map = { pill: 'rounded-full', round: 'rounded-lg', square: 'rounded-none' }\n return map[props.shape] ?? map.pill\n})\n\n// ── Size ──────────────────────────────────────────────────\nconst buttonSizeClass = computed(() =>\n props.size === 'sm' ? 'px-3 py-1 text-xs' : 'px-4 py-1.5 text-sm',\n)\nconst iconSizeClass = computed(() => (props.size === 'sm' ? 'size-3.5' : 'size-4'))\n\n// ── Variant: indicator look + active label colour ─────────\n// These mirror UiButton's solid / outline / ghost variants (primary colour) so\n// a segmented control reads as part of the same family as the buttons near it.\nconst indicatorClass = computed(() => {\n const map = {\n solid: 'bg-primary-600 shadow-sm',\n outline: 'border border-primary-500',\n ghost: 'bg-primary-50 dark:bg-primary-900/20',\n }\n return map[props.variant] ?? map.solid\n})\nconst activeTextClass = computed(() =>\n props.variant === 'solid' ? 'text-white' : 'text-primary-600 dark:text-primary-400',\n)\nconst idleTextClass =\n 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'\n\nconst indicatorStyle = computed(() => ({\n // Track padding is p-1 (0.25rem) each side, so the usable width is\n // `100% - 0.5rem`; one segment is that divided by the option count.\n width: `calc((100% - 0.5rem) / ${count.value})`,\n transform: `translateX(calc(${activeIndex.value} * 100%))`,\n}))\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;AAyNA,IAAM,gBACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,eAAA,CAAC,gBAAc;KACJ,QAAA,QAAK,gBAAA;KAAwC,YAAA;;;IAK5D,OAAK,eAAE,UAAA,KAAS;GASjB,GAAA,CAAA,mBAKE,QAAA;IAJA,eAAY;IACZ,OAAK,eAAA,CAAC,yIAAuI,CACpI,YAAA,OAAa,eAAA,KAAc,CAAA,CAAA;IACnC,OAAK,eAAE,eAAA,KAAc;GAGxB,GAAA,MAAA,CAAA,IAAA,UAAA,IAAA,GAAA,mBAaS,UAAA,MAAA,WAZU,QAAA,UAAV,WAAM;IADf,OAAA,UAAA,GAAA,mBAaS,UAAA;KAXN,KAAK,OAAO;KACb,MAAK;KACJ,gBAAc,SAAS,MAAM,IAAA,SAAA;KAC7B,UAAU,OAAO;KACjB,OAAO,OAAO,SAAS,KAAA;KACxB,OAAK,eAAA,CAAC,iJAA+I;MAC5I,gBAAA;MAAiB,YAAA;MAAa,SAAS,MAAM,IAAI,gBAAA,QAAkB;KAAa,CAAA,CAAA;KACxF,UAAK,WAAE,OAAO,MAAM;IAEP,GAAA,CAAA,OAAO,QAArB,UAAA,GAAA,YAAwE,aAAA;;KAA5C,MAAM,OAAO;KAAO,OAAK,eAAE,cAAA,KAAa;IACxD,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,OAAO,SAAnB,UAAA,GAAA,mBAAmD,QAAA,YAAA,gBAAtB,OAAO,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,GAAA,IAAA,UAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useFormField } from "../internal/formField.js";
|
|
2
3
|
import { MENU_PANEL_CLASS } from "../internal/menu.js";
|
|
3
4
|
import { Fragment, Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, toDisplayString, unref, vModelText, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
4
5
|
//#region src/components/Select.vue
|
|
@@ -7,7 +8,12 @@ var _hoisted_2 = {
|
|
|
7
8
|
key: 0,
|
|
8
9
|
class: "w-4"
|
|
9
10
|
};
|
|
10
|
-
var _hoisted_3 = [
|
|
11
|
+
var _hoisted_3 = [
|
|
12
|
+
"id",
|
|
13
|
+
"aria-describedby",
|
|
14
|
+
"disabled",
|
|
15
|
+
"aria-label"
|
|
16
|
+
];
|
|
11
17
|
var _hoisted_4 = {
|
|
12
18
|
key: 0,
|
|
13
19
|
class: "flex items-center gap-2 truncate text-gray-400 dark:text-gray-500"
|
|
@@ -178,6 +184,7 @@ var _sfc_main = {
|
|
|
178
184
|
*/
|
|
179
185
|
const props = __props;
|
|
180
186
|
const emit = __emit;
|
|
187
|
+
const field = useFormField();
|
|
181
188
|
const containerRef = ref(null);
|
|
182
189
|
const triggerRef = ref(null);
|
|
183
190
|
const searchRef = ref(null);
|
|
@@ -365,9 +372,11 @@ var _sfc_main = {
|
|
|
365
372
|
])]);
|
|
366
373
|
}), 128))], 2),
|
|
367
374
|
createElementVNode("button", {
|
|
375
|
+
id: unref(field)?.controlId.value,
|
|
368
376
|
ref_key: "triggerRef",
|
|
369
377
|
ref: triggerRef,
|
|
370
378
|
type: "button",
|
|
379
|
+
"aria-describedby": unref(field)?.describedBy.value,
|
|
371
380
|
disabled: __props.disabled || __props.loading,
|
|
372
381
|
"aria-label": __props.ariaLabel,
|
|
373
382
|
class: normalizeClass([triggerClasses.value, __props.disabled || __props.loading ? "opacity-50 cursor-not-allowed" : ""]),
|
|
@@ -407,7 +416,7 @@ var _sfc_main = {
|
|
|
407
416
|
type: "text",
|
|
408
417
|
placeholder: "Search...",
|
|
409
418
|
class: "w-full px-2.5 py-1.5 text-sm border border-gray-200 dark:border-gray-700 rounded-md bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-gray-300 outline-none focus:ring-1 focus:ring-primary-500 placeholder-gray-400",
|
|
410
|
-
onKeydown: [withKeys(close, ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
|
|
419
|
+
onKeydown: [withKeys(withModifiers(close, ["prevent"]), ["escape"]), withKeys(withModifiers(selectFirst, ["prevent"]), ["enter"])]
|
|
411
420
|
}, null, 40, _hoisted_6), [[vModelText, searchQuery.value]])])) : createCommentVNode("", true), createElementVNode("ul", _hoisted_7, [filteredOptions.value.length === 0 && filteredGroups.value.length === 0 ? (openBlock(), createElementBlock("li", _hoisted_8, " No results ")) : createCommentVNode("", true), filteredGroups.value.length === 0 ? (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(filteredOptions.value, (opt) => {
|
|
412
421
|
return openBlock(), createElementBlock("li", {
|
|
413
422
|
key: opt.value,
|