numori-ui 0.3.0 → 0.5.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/README.md +36 -34
  3. package/dist/components/AppShell.js +234 -0
  4. package/dist/components/AppShell.js.map +1 -0
  5. package/dist/components/Banner.js +29 -32
  6. package/dist/components/Banner.js.map +1 -1
  7. package/dist/components/Button.js +10 -19
  8. package/dist/components/Button.js.map +1 -1
  9. package/dist/components/Card.js +15 -9
  10. package/dist/components/Card.js.map +1 -1
  11. package/dist/components/Checkbox.js +13 -9
  12. package/dist/components/Checkbox.js.map +1 -1
  13. package/dist/components/CopyField.js +195 -0
  14. package/dist/components/CopyField.js.map +1 -0
  15. package/dist/components/DescriptionList.js +116 -0
  16. package/dist/components/DescriptionList.js.map +1 -0
  17. package/dist/components/Dropdown.js +10 -3
  18. package/dist/components/Dropdown.js.map +1 -1
  19. package/dist/components/DropdownSubmenu.js +5 -3
  20. package/dist/components/DropdownSubmenu.js.map +1 -1
  21. package/dist/components/EmptyState.js +123 -0
  22. package/dist/components/EmptyState.js.map +1 -0
  23. package/dist/components/FileInput.js +12 -4
  24. package/dist/components/FileInput.js.map +1 -1
  25. package/dist/components/FormField.js +43 -13
  26. package/dist/components/FormField.js.map +1 -1
  27. package/dist/components/IconTile.js +5 -9
  28. package/dist/components/IconTile.js.map +1 -1
  29. package/dist/components/Input.js +21 -7
  30. package/dist/components/Input.js.map +1 -1
  31. package/dist/components/ListMenuItem.js +38 -31
  32. package/dist/components/ListMenuItem.js.map +1 -1
  33. package/dist/components/Numpad.js +4 -4
  34. package/dist/components/Numpad.js.map +1 -1
  35. package/dist/components/PageHeader.js +106 -0
  36. package/dist/components/PageHeader.js.map +1 -0
  37. package/dist/components/Pagination.js +236 -0
  38. package/dist/components/Pagination.js.map +1 -0
  39. package/dist/components/Popup.js +9 -3
  40. package/dist/components/Popup.js.map +1 -1
  41. package/dist/components/Radio.js +2 -7
  42. package/dist/components/Radio.js.map +1 -1
  43. package/dist/components/Segmented.js +109 -27
  44. package/dist/components/Segmented.js.map +1 -1
  45. package/dist/components/Select.js +16 -5
  46. package/dist/components/Select.js.map +1 -1
  47. package/dist/components/Sidebar.js +69 -0
  48. package/dist/components/Sidebar.js.map +1 -0
  49. package/dist/components/SidebarGroup.js +50 -0
  50. package/dist/components/SidebarGroup.js.map +1 -0
  51. package/dist/components/SidebarItem.js +167 -0
  52. package/dist/components/SidebarItem.js.map +1 -0
  53. package/dist/components/StatCard.js +185 -0
  54. package/dist/components/StatCard.js.map +1 -0
  55. package/dist/components/Table.js +306 -0
  56. package/dist/components/Table.js.map +1 -0
  57. package/dist/components/Tabs.js +216 -0
  58. package/dist/components/Tabs.js.map +1 -0
  59. package/dist/components/Toggle.js +11 -2
  60. package/dist/components/Toggle.js.map +1 -1
  61. package/dist/components/index.js +91 -76
  62. package/dist/components/index.js.map +1 -1
  63. package/dist/composables/useMergedClasses.js +52 -0
  64. package/dist/composables/useMergedClasses.js.map +1 -0
  65. package/dist/icons/mdi.js +11 -0
  66. package/dist/icons/mdi.js.map +1 -1
  67. package/dist/index.d.ts +13 -3
  68. package/dist/index.js +47 -37
  69. package/dist/index.js.map +1 -1
  70. package/dist/internal/controlSizes.js +21 -0
  71. package/dist/internal/controlSizes.js.map +1 -0
  72. package/dist/internal/formField.js +26 -0
  73. package/dist/internal/formField.js.map +1 -0
  74. package/dist/internal/menu.js +20 -0
  75. package/dist/internal/menu.js.map +1 -0
  76. package/dist/manifest.js +12 -2
  77. package/dist/manifest.js.map +1 -1
  78. package/package.json +2 -1
  79. package/src/components/AppShell.vue +231 -0
  80. package/src/components/Banner.vue +20 -9
  81. package/src/components/Button.vue +12 -19
  82. package/src/components/Card.vue +11 -12
  83. package/src/components/Checkbox.vue +7 -10
  84. package/src/components/CopyField.vue +178 -0
  85. package/src/components/DescriptionList.vue +114 -0
  86. package/src/components/Dropdown.vue +14 -2
  87. package/src/components/DropdownSubmenu.vue +4 -2
  88. package/src/components/EmptyState.vue +107 -0
  89. package/src/components/FileInput.vue +19 -4
  90. package/src/components/FormField.vue +37 -4
  91. package/src/components/IconTile.vue +4 -9
  92. package/src/components/Input.vue +15 -6
  93. package/src/components/ListMenuItem.vue +21 -5
  94. package/src/components/Numpad.vue +7 -4
  95. package/src/components/PageHeader.vue +102 -0
  96. package/src/components/Pagination.vue +199 -0
  97. package/src/components/Popup.vue +6 -2
  98. package/src/components/Radio.vue +2 -10
  99. package/src/components/Segmented.vue +113 -38
  100. package/src/components/Select.vue +16 -2
  101. package/src/components/Sidebar.vue +61 -0
  102. package/src/components/SidebarGroup.vue +43 -0
  103. package/src/components/SidebarItem.vue +159 -0
  104. package/src/components/StatCard.vue +165 -0
  105. package/src/components/Table.vue +323 -0
  106. package/src/components/Tabs.vue +217 -0
  107. package/src/components/Toggle.vue +5 -0
  108. package/src/components/index.js +36 -11
  109. package/src/composables/useMergedClasses.js +49 -0
  110. package/src/icons/mdi.js +11 -0
  111. package/src/internal/controlSizes.js +17 -0
  112. package/src/internal/formField.js +23 -0
  113. package/src/internal/menu.js +16 -0
  114. package/src/manifest.js +12 -2
  115. package/dist/components/ButtonsGroup.js +0 -153
  116. package/dist/components/ButtonsGroup.js.map +0 -1
  117. package/dist/components/ComparisonTable.js +0 -152
  118. package/dist/components/ComparisonTable.js.map +0 -1
  119. package/src/components/ButtonsGroup.vue +0 -140
  120. package/src/components/ComparisonTable.vue +0 -141
@@ -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:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800`\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6LA,IAAM,aACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAzGF,MAAM,QAAQ;EAwEd,MAAM,OAAO;EAEb,MAAM,YAAY,eAChB,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,IAAI,GAAG,MAAM,KAAK,IAAI,KAAK,IAAI,GAAG,MAAM,QAAQ,CAAC,CAAC,CAC/E;EACA,MAAM,UAAU,eAAe,KAAK,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,GAAG,UAAU,KAAK,CAAC;EAEjF,MAAM,cAAc,eAAe;GACjC,MAAM,QAAQ,KAAK,IAAI,GAAG,MAAM,KAAK;GACrC,MAAM,OAAO,UAAU,IAAI,KAAK,QAAQ,QAAQ,KAAK,MAAM,WAAW;GACtE,MAAM,KAAK,KAAK,IAAI,OAAO,QAAQ,QAAQ,MAAM,QAAQ;GACzD,OAAO,MAAM,cAAc,MAAM,IAAI,KAAK;EAC5C,CAAC;;EAGD,MAAM,QAAQ,eAAe;GAC3B,MAAM,OAAO,UAAU;GACvB,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,QAAQ,MAAM,QAAQ;GACxD,MAAM,MAAM,KAAK,IAAI,OAAO,GAAG,QAAQ,QAAQ,MAAM,QAAQ;GAC7D,MAAM,MAAM,CAAC;IAAE,MAAM;IAAQ,MAAM;IAAG,KAAK;GAAK,CAAC;GACjD,IAAI,QAAQ,GAAG,IAAI,KAAK;IAAE,MAAM;IAAO,KAAK;GAAY,CAAC;GACzD,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,KAAK,IAAI,KAAK;IAAE,MAAM;IAAQ,MAAM;IAAG,KAAK,IAAI;GAAI,CAAC;GACnF,IAAI,MAAM,OAAO,GAAG,IAAI,KAAK;IAAE,MAAM;IAAO,KAAK;GAAU,CAAC;GAC5D,IAAI,OAAO,GAAG,IAAI,KAAK;IAAE,MAAM;IAAQ,MAAM;IAAM,KAAK,IAAI;GAAO,CAAC;GACpE,OAAO;EACT,CAAC;EAED,SAAS,GAAG,MAAM;GAChB,MAAM,OAAO,KAAK,IAAI,KAAK,IAAI,GAAG,IAAI,GAAG,UAAU,KAAK;GACxD,IAAI,SAAS,QAAQ,OAAO,KAAK,eAAe,IAAI;EACtD;EAKA,MAAM,WAAW,GAAG,WAAW;EAE/B,MAAM,aAAa,SACjB,SAAS,QAAQ,QACb,GAAG,WAAW,qEACd,GAAG,WAAW;;GApMlB,OAAA,UAAA,GAAA,mBAoDM,OAAA;IApDA,cAAY,QAAA;IAAW,OAAM;GACxB,GAAA,CAAA,QAAA,eAAT,UAAA,GAAA,mBAEI,KAFJ,YAEI,gBADC,YAAA,KAAW,GAAA,CAAA,MAEhB,UAAA,GAAA,mBAAe,QAAA,UAAA,IAEL,UAAA,QAAS,KAAnB,UAAA,GAAA,mBA6CK,MA7CL,YA6CK;IA5CH,mBAUK,MAAA,MAAA,CATH,mBAQS,UAAA;KAPP,MAAK;KACJ,OAAK,eAAE,QAAQ;KACf,UAAU,QAAA,SAAO;KACjB,cAAY,QAAA;KACZ,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,GAAG,QAAA,QAAO,CAAA;IAElB,GAAA,CAAA,YAAiD,aAAA;KAAzC,MAAK;KAAmB,OAAM;;KAG1C,UAAA,IAAA,GAAA,mBAqBK,UAAA,MAAA,WApBY,MAAA,QAAR,SAAI;KADb,OAAA,UAAA,GAAA,mBAqBK,MAAA;MAnBF,KAAK,KAAK;MACV,OAAK,eAAE,KAAK,SAAS,QAAA,QAAO,KAAA,iBAAA;KAGrB,GAAA,CAAA,KAAK,SAAI,SADjB,UAAA,GAAA,mBAKC,QALD,YAIG,GAAC,MAEJ,UAAA,GAAA,mBASS,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,4 +1,5 @@
1
- import { Transition, computed, createCommentVNode, createElementBlock, createVNode, nextTick, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, watch, withCtx } from "vue";
1
+ import { MENU_PANEL_CLASS } from "../internal/menu.js";
2
+ import { Transition, computed, createCommentVNode, createElementBlock, createVNode, nextTick, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, unref, watch, withCtx } from "vue";
2
3
  //#region src/components/Popup.vue
3
4
  var _sfc_main = {
4
5
  __name: "Popup",
@@ -99,7 +100,8 @@ var _sfc_main = {
99
100
  });
100
101
  const positionStyle = computed(() => ({
101
102
  left: clampedPos.value.left + "px",
102
- top: clampedPos.value.top + "px"
103
+ top: clampedPos.value.top + "px",
104
+ transformOrigin: "top left"
103
105
  }));
104
106
  const updatePosition = () => {
105
107
  const left = props.x;
@@ -156,7 +158,11 @@ var _sfc_main = {
156
158
  key: 0,
157
159
  ref_key: "panelRef",
158
160
  ref: panelRef,
159
- class: normalizeClass(["absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1", [__props.width, __props.panelZ]]),
161
+ class: normalizeClass(["absolute py-1", [
162
+ unref(MENU_PANEL_CLASS),
163
+ __props.width,
164
+ __props.panelZ
165
+ ]]),
160
166
  style: normalizeStyle(positionStyle.value)
161
167
  }, [renderSlot(_ctx.$slots, "default")], 6)) : createCommentVNode("", true)]),
162
168
  _: 3
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["$emit"],"sources":["../../src/components/Popup.vue"],"sourcesContent":["<template>\n <div>\n <!-- Invisible full-screen backdrop to capture outside clicks -->\n <div v-if=\"show\" class=\"fixed inset-0\" :class=\"backdropZ\" @click=\"$emit('close')\" />\n <!-- Animated popup panel positioned at (x, y + offsetY) -->\n <Transition\n enter-active-class=\"transition duration-100 ease-out\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-75 ease-in\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n class=\"absolute bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1\"\n :class=\"[width, panelZ]\"\n :style=\"positionStyle\"\n >\n <slot />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiPopup — Absolutely positioned popup panel with viewport-aware clamping.\n *\n * Renders a floating panel at the given (x, y) coordinates relative to its offset parent.\n * Automatically clamps position to keep the panel within the visible viewport with an 8px margin.\n * Includes an invisible full-screen backdrop that emits 'close' on click.\n *\n * @example Context menu popup\n * <UiPopup :show=\"showMenu\" :x=\"menuX\" :y=\"menuY\" @close=\"showMenu = false\">\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiPopup>\n *\n * @example Popup with offset and custom width\n * <UiPopup :show=\"open\" :x=\"posX\" :y=\"posY\" :offset-y=\"8\" width=\"w-64\" @close=\"open = false\">\n * <div class=\"p-3\">Custom content</div>\n * </UiPopup>\n *\n * @emits {void} close — Emitted when the backdrop is clicked to dismiss the popup\n *\n * @slot default — Popup content\n */\nimport { ref, computed, watch, nextTick } from 'vue'\nconst props = defineProps({\n /**\n * Controls popup visibility.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Horizontal position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n x: { type: Number, default: 0 },\n\n /**\n * Vertical position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n y: { type: Number, default: 0 },\n\n /**\n * Additional vertical offset added to the y position (e.g. to clear a trigger element).\n * @type {number}\n * @default 0\n */\n offsetY: { type: Number, default: 0 },\n\n /**\n * Width class for the popup panel.\n * @type {string}\n * @default 'w-56'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Z-index class for the popup panel.\n * @type {string}\n * @default 'z-50'\n */\n panelZ: { type: String, default: 'z-50' },\n\n /**\n * Z-index class for the invisible backdrop behind the panel.\n * @type {string}\n * @default 'z-40'\n */\n backdropZ: { type: String, default: 'z-40' },\n})\n\ndefineEmits(['close'])\n\nconst panelRef = ref(null)\nconst clampedPos = ref({ left: 0, top: 0 })\n\nconst positionStyle = computed(() => ({\n left: clampedPos.value.left + 'px',\n top: clampedPos.value.top + 'px',\n}))\n\n// Clamp the panel position so it stays within the viewport (8px margin)\nconst updatePosition = () => {\n const left = props.x\n const top = props.y + props.offsetY\n\n nextTick(() => {\n const el = panelRef.value\n if (!el) return\n\n const parent = el.offsetParent || document.body\n const parentRect = parent.getBoundingClientRect()\n const panelW = el.offsetWidth\n const panelH = el.offsetHeight\n const viewW = window.innerWidth\n const viewH = window.innerHeight\n\n // Convert to viewport coords, clamp, convert back\n let absLeft = parentRect.left + left\n let absTop = parentRect.top + top\n\n const margin = 8\n if (absLeft + panelW > viewW - margin) absLeft = viewW - panelW - margin\n if (absLeft < margin) absLeft = margin\n if (absTop + panelH > viewH - margin) absTop = viewH - panelH - margin\n if (absTop < margin) absTop = margin\n\n clampedPos.value = {\n left: absLeft - parentRect.left,\n top: absTop - parentRect.top,\n }\n })\n}\n\nwatch(\n () => [props.show, props.x, props.y, props.offsetY],\n () => {\n if (props.show) {\n // Set initial position immediately so the panel renders near the right spot\n clampedPos.value = { left: props.x, top: props.y + props.offsetY }\n updatePosition()\n }\n },\n { immediate: true },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkDA,MAAM,QAAQ;EAqDd,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,aAAa,IAAI;GAAE,MAAM;GAAG,KAAK;EAAE,CAAC;EAE1C,MAAM,gBAAgB,gBAAgB;GACpC,MAAM,WAAW,MAAM,OAAO;GAC9B,KAAK,WAAW,MAAM,MAAM;EAC9B,EAAE;EAGF,MAAM,uBAAuB;GAC3B,MAAM,OAAO,MAAM;GACnB,MAAM,MAAM,MAAM,IAAI,MAAM;GAE5B,eAAe;IACb,MAAM,KAAK,SAAS;IACpB,IAAI,CAAC,IAAI;IAGT,MAAM,cADS,GAAG,gBAAgB,SAAS,KAAA,CACjB,sBAAsB;IAChD,MAAM,SAAS,GAAG;IAClB,MAAM,SAAS,GAAG;IAClB,MAAM,QAAQ,OAAO;IACrB,MAAM,QAAQ,OAAO;IAGrB,IAAI,UAAU,WAAW,OAAO;IAChC,IAAI,SAAS,WAAW,MAAM;IAE9B,MAAM,SAAS;IACf,IAAI,UAAU,SAAS,QAAQ,QAAQ,UAAU,QAAQ,SAAS;IAClE,IAAI,UAAU,QAAQ,UAAU;IAChC,IAAI,SAAS,SAAS,QAAQ,QAAQ,SAAS,QAAQ,SAAS;IAChE,IAAI,SAAS,QAAQ,SAAS;IAE9B,WAAW,QAAQ;KACjB,MAAM,UAAU,WAAW;KAC3B,KAAK,SAAS,WAAW;IAC3B;GACF,CAAC;EACH;EAEA,YACQ;GAAC,MAAM;GAAM,MAAM;GAAG,MAAM;GAAG,MAAM;EAAO,SAC5C;GACJ,IAAI,MAAM,MAAM;IAEd,WAAW,QAAQ;KAAE,MAAM,MAAM;KAAG,KAAK,MAAM,IAAI,MAAM;IAAQ;IACjE,eAAe;GACjB;EACF,GACA,EAAE,WAAW,KAAK,CACpB;;GAzJE,OAAA,UAAA,GAAA,mBAsBM,OAAA,MAAA,CApBO,QAAA,QAAX,UAAA,GAAA,mBAAoF,OAAA;;IAAnE,OAAK,eAAA,CAAC,iBAAwB,QAAA,SAAS,CAAA;IAAG,SAAK,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,OAAA;GAEvE,GAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,YAiBa,YAAA;IAhBX,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAEf,SAAA,cAQM,CAPE,QAAA,QADR,UAAA,GAAA,mBAQM,OAAA;;KANA,SAAA;KAAJ,KAAI;KACJ,OAAK,eAAA,CAAC,4GAA0G,CACvG,QAAA,OAAO,QAAA,MAAM,CAAA,CAAA;KACrB,OAAK,eAAE,cAAA,KAAa;IAErB,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"Popup.js","names":["$emit"],"sources":["../../src/components/Popup.vue"],"sourcesContent":["<template>\n <div>\n <!-- Invisible full-screen backdrop to capture outside clicks -->\n <div v-if=\"show\" class=\"fixed inset-0\" :class=\"backdropZ\" @click=\"$emit('close')\" />\n <!-- Animated popup panel positioned at (x, y + offsetY) -->\n <Transition\n enter-active-class=\"transition duration-100 ease-out\"\n enter-from-class=\"opacity-0 scale-95\"\n enter-to-class=\"opacity-100 scale-100\"\n leave-active-class=\"transition duration-75 ease-in\"\n leave-from-class=\"opacity-100 scale-100\"\n leave-to-class=\"opacity-0 scale-95\"\n >\n <div\n v-if=\"show\"\n ref=\"panelRef\"\n class=\"absolute py-1\"\n :class=\"[MENU_PANEL_CLASS, width, panelZ]\"\n :style=\"positionStyle\"\n >\n <slot />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiPopup — Absolutely positioned popup panel with viewport-aware clamping.\n *\n * Renders a floating panel at the given (x, y) coordinates relative to its offset parent.\n * Automatically clamps position to keep the panel within the visible viewport with an 8px margin.\n * Includes an invisible full-screen backdrop that emits 'close' on click.\n *\n * @example Context menu popup\n * <UiPopup :show=\"showMenu\" :x=\"menuX\" :y=\"menuY\" @close=\"showMenu = false\">\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiPopup>\n *\n * @example Popup with offset and custom width\n * <UiPopup :show=\"open\" :x=\"posX\" :y=\"posY\" :offset-y=\"8\" width=\"w-64\" @close=\"open = false\">\n * <div class=\"p-3\">Custom content</div>\n * </UiPopup>\n *\n * @emits {void} close — Emitted when the backdrop is clicked to dismiss the popup\n *\n * @slot default — Popup content\n */\nimport { ref, computed, watch, nextTick } from 'vue'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Controls popup visibility.\n * @type {boolean}\n * @default false\n */\n show: { type: Boolean, default: false },\n\n /**\n * Horizontal position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n x: { type: Number, default: 0 },\n\n /**\n * Vertical position in pixels relative to the offset parent.\n * @type {number}\n * @default 0\n */\n y: { type: Number, default: 0 },\n\n /**\n * Additional vertical offset added to the y position (e.g. to clear a trigger element).\n * @type {number}\n * @default 0\n */\n offsetY: { type: Number, default: 0 },\n\n /**\n * Width class for the popup panel.\n * @type {string}\n * @default 'w-56'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Z-index class for the popup panel.\n * @type {string}\n * @default 'z-50'\n */\n panelZ: { type: String, default: 'z-50' },\n\n /**\n * Z-index class for the invisible backdrop behind the panel.\n * @type {string}\n * @default 'z-40'\n */\n backdropZ: { type: String, default: 'z-40' },\n})\n\ndefineEmits(['close'])\n\nconst panelRef = ref(null)\nconst clampedPos = ref({ left: 0, top: 0 })\n\nconst positionStyle = computed(() => ({\n left: clampedPos.value.left + 'px',\n top: clampedPos.value.top + 'px',\n // Inline (not a Tailwind class) so the popup reliably scales in from its\n // top-left corner rather than drifting in from its centre.\n transformOrigin: 'top left',\n}))\n\n// Clamp the panel position so it stays within the viewport (8px margin)\nconst updatePosition = () => {\n const left = props.x\n const top = props.y + props.offsetY\n\n nextTick(() => {\n const el = panelRef.value\n if (!el) return\n\n const parent = el.offsetParent || document.body\n const parentRect = parent.getBoundingClientRect()\n const panelW = el.offsetWidth\n const panelH = el.offsetHeight\n const viewW = window.innerWidth\n const viewH = window.innerHeight\n\n // Convert to viewport coords, clamp, convert back\n let absLeft = parentRect.left + left\n let absTop = parentRect.top + top\n\n const margin = 8\n if (absLeft + panelW > viewW - margin) absLeft = viewW - panelW - margin\n if (absLeft < margin) absLeft = margin\n if (absTop + panelH > viewH - margin) absTop = viewH - panelH - margin\n if (absTop < margin) absTop = margin\n\n clampedPos.value = {\n left: absLeft - parentRect.left,\n top: absTop - parentRect.top,\n }\n })\n}\n\nwatch(\n () => [props.show, props.x, props.y, props.offsetY],\n () => {\n if (props.show) {\n // Set initial position immediately so the panel renders near the right spot\n clampedPos.value = { left: props.x, top: props.y + props.offsetY }\n updatePosition()\n }\n },\n { immediate: true },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,QAAQ;EAqDd,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,aAAa,IAAI;GAAE,MAAM;GAAG,KAAK;EAAE,CAAC;EAE1C,MAAM,gBAAgB,gBAAgB;GACpC,MAAM,WAAW,MAAM,OAAO;GAC9B,KAAK,WAAW,MAAM,MAAM;GAG5B,iBAAiB;EACnB,EAAE;EAGF,MAAM,uBAAuB;GAC3B,MAAM,OAAO,MAAM;GACnB,MAAM,MAAM,MAAM,IAAI,MAAM;GAE5B,eAAe;IACb,MAAM,KAAK,SAAS;IACpB,IAAI,CAAC,IAAI;IAGT,MAAM,cADS,GAAG,gBAAgB,SAAS,KAAA,CACjB,sBAAsB;IAChD,MAAM,SAAS,GAAG;IAClB,MAAM,SAAS,GAAG;IAClB,MAAM,QAAQ,OAAO;IACrB,MAAM,QAAQ,OAAO;IAGrB,IAAI,UAAU,WAAW,OAAO;IAChC,IAAI,SAAS,WAAW,MAAM;IAE9B,MAAM,SAAS;IACf,IAAI,UAAU,SAAS,QAAQ,QAAQ,UAAU,QAAQ,SAAS;IAClE,IAAI,UAAU,QAAQ,UAAU;IAChC,IAAI,SAAS,SAAS,QAAQ,QAAQ,SAAS,QAAQ,SAAS;IAChE,IAAI,SAAS,QAAQ,SAAS;IAE9B,WAAW,QAAQ;KACjB,MAAM,UAAU,WAAW;KAC3B,KAAK,SAAS,WAAW;IAC3B;GACF,CAAC;EACH;EAEA,YACQ;GAAC,MAAM;GAAM,MAAM;GAAG,MAAM;GAAG,MAAM;EAAO,SAC5C;GACJ,IAAI,MAAM,MAAM;IAEd,WAAW,QAAQ;KAAE,MAAM,MAAM;KAAG,KAAK,MAAM,IAAI,MAAM;IAAQ;IACjE,eAAe;GACjB;EACF,GACA,EAAE,WAAW,KAAK,CACpB;;GA7JE,OAAA,UAAA,GAAA,mBAsBM,OAAA,MAAA,CApBO,QAAA,QAAX,UAAA,GAAA,mBAAoF,OAAA;;IAAnE,OAAK,eAAA,CAAC,iBAAwB,QAAA,SAAS,CAAA;IAAG,SAAK,OAAA,OAAA,OAAA,MAAA,WAAEA,KAAAA,MAAK,OAAA;GAEvE,GAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,YAiBa,YAAA;IAhBX,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;IACf,sBAAmB;IACnB,oBAAiB;IACjB,kBAAe;;IAEf,SAAA,cAQM,CAPE,QAAA,QADR,UAAA,GAAA,mBAQM,OAAA;;KANA,SAAA;KAAJ,KAAI;KACJ,OAAK,eAAA,CAAC,iBAAe;MACZ,MAAA,gBAAA;MAAkB,QAAA;MAAO,QAAA;KAAM,CAAA,CAAA;KACvC,OAAK,eAAE,cAAA,KAAa;IAErB,GAAA,CAAA,WAAQ,KAAA,QAAA,SAAA,CAAA,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { checkableSizeClass } from "../internal/controlSizes.js";
1
2
  import { computed, createElementBlock, normalizeClass, openBlock } from "vue";
2
3
  //#region src/components/Radio.vue
3
4
  var _hoisted_1 = [
@@ -52,13 +53,7 @@ var _sfc_main = {
52
53
  */
53
54
  const props = __props;
54
55
  const emit = __emit;
55
- const sizeClass = computed(() => {
56
- switch (props.size) {
57
- case "sm": return "w-3.5 h-3.5";
58
- case "lg": return "w-5 h-5";
59
- default: return "w-4 h-4";
60
- }
61
- });
56
+ const sizeClass = computed(() => checkableSizeClass(props.size));
62
57
  function onChange() {
63
58
  emit("update:modelValue", props.value);
64
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Radio.js","names":[],"sources":["../../src/components/Radio.vue"],"sourcesContent":["<template>\n <input\n type=\"radio\"\n :checked=\"modelValue === value\"\n :disabled=\"disabled\"\n :name=\"name\"\n :value=\"value\"\n class=\"rounded-full border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiRadio — Simple styled radio input with configurable size.\n *\n * Wraps a native `<input type=\"radio\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Use with v-model for group selection.\n *\n * @example Radio group\n * <UiRadio v-model=\"selected\" value=\"a\" name=\"choice\" />\n * <UiRadio v-model=\"selected\" value=\"b\" name=\"choice\" />\n */\nimport { computed } from 'vue'\nconst props = defineProps({\n modelValue: { type: [String, Number, Boolean], default: null },\n value: { type: [String, Number, Boolean], required: true },\n name: { type: String, default: undefined },\n disabled: { type: Boolean, default: false },\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst sizeClass = computed(() => {\n switch (props.size) {\n case 'sm':\n return 'w-3.5 h-3.5'\n case 'lg':\n return 'w-5 h-5'\n default:\n return 'w-4 h-4'\n }\n})\n\nfunction onChange() {\n emit('update:modelValue', props.value)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBA,MAAM,QAAQ;EAQd,MAAM,OAAO;EAEb,MAAM,YAAY,eAAe;GAC/B,QAAQ,MAAM,MAAd;IACE,KAAK,MACH,OAAO;IACT,KAAK,MACH,OAAO;IACT,SACE,OAAO;GACX;EACF,CAAC;EAED,SAAS,WAAW;GAClB,KAAK,qBAAqB,MAAM,KAAK;EACvC;;GA/CE,OAAA,UAAA,GAAA,mBASE,SAAA;IARA,MAAK;IACJ,SAAS,QAAA,eAAe,QAAA;IACxB,UAAU,QAAA;IACV,MAAM,QAAA;IACN,OAAO,QAAA;IACR,OAAK,eAAA,CAAC,6FACE,UAAA,KAAS,CAAA;IACR"}
1
+ {"version":3,"file":"Radio.js","names":[],"sources":["../../src/components/Radio.vue"],"sourcesContent":["<template>\n <input\n type=\"radio\"\n :checked=\"modelValue === value\"\n :disabled=\"disabled\"\n :name=\"name\"\n :value=\"value\"\n class=\"rounded-full border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiRadio — Simple styled radio input with configurable size.\n *\n * Wraps a native `<input type=\"radio\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Use with v-model for group selection.\n *\n * @example Radio group\n * <UiRadio v-model=\"selected\" value=\"a\" name=\"choice\" />\n * <UiRadio v-model=\"selected\" value=\"b\" name=\"choice\" />\n */\nimport { computed } from 'vue'\nimport { checkableSizeClass } from '../internal/controlSizes.js'\nconst props = defineProps({\n modelValue: { type: [String, Number, Boolean], default: null },\n value: { type: [String, Number, Boolean], required: true },\n name: { type: String, default: undefined },\n disabled: { type: Boolean, default: false },\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst sizeClass = computed(() => checkableSizeClass(props.size))\n\nfunction onChange() {\n emit('update:modelValue', props.value)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BA,MAAM,QAAQ;EAQd,MAAM,OAAO;EAEb,MAAM,YAAY,eAAe,mBAAmB,MAAM,IAAI,CAAC;EAE/D,SAAS,WAAW;GAClB,KAAK,qBAAqB,MAAM,KAAK;EACvC;;GAvCE,OAAA,UAAA,GAAA,mBASE,SAAA;IARA,MAAK;IACJ,SAAS,QAAA,eAAe,QAAA;IACxB,UAAU,QAAA;IACV,MAAM,QAAA;IACN,OAAO,QAAA;IACR,OAAK,eAAA,CAAC,6FACE,UAAA,KAAS,CAAA;IACR"}
@@ -1,13 +1,19 @@
1
1
  import _sfc_main$1 from "../icons/Icon.js";
2
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, normalizeClass, normalizeStyle, openBlock, renderList, toDisplayString } from "vue";
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 = ["aria-label"];
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",
13
+ "title",
8
14
  "onClick"
9
15
  ];
10
- var activeTextClass = "text-white";
16
+ var _hoisted_3 = { key: 1 };
11
17
  var idleTextClass = "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100";
12
18
  var _sfc_main = {
13
19
  __name: "Segmented",
@@ -22,14 +28,30 @@ var _sfc_main = {
22
28
  default: void 0
23
29
  },
24
30
  /**
25
- * The options. Each is `{ value, label, icon?, disabled? }`.
26
- * @type {Array<{ value: string|number, label: string, icon?: string, disabled?: boolean }>}
31
+ * The options. Each is `{ value, label?, icon?, disabled?, title? }`. Provide
32
+ * `label` for text segments, `icon` for icon-only segments, or both. `title`
33
+ * sets the native tooltip (useful for icon-only segments).
34
+ * @type {Array<{ value: string|number, label?: string, icon?: string, disabled?: boolean, title?: string }>}
27
35
  */
28
36
  options: {
29
37
  type: Array,
30
38
  required: true
31
39
  },
32
40
  /**
41
+ * Active-segment appearance, mirroring the equivalent `UiButton` variants so
42
+ * the two feel like one family. The sliding indicator animates in every case.
43
+ * - 'solid' — a filled accent indicator; the active label goes white (default).
44
+ * - 'outline' — a bordered accent indicator; the active label takes the accent.
45
+ * - 'ghost' — a soft tinted indicator; the active label takes the accent.
46
+ * @type {string}
47
+ * @default 'solid'
48
+ * @values 'solid' | 'outline' | 'ghost'
49
+ */
50
+ variant: {
51
+ type: String,
52
+ default: "solid"
53
+ },
54
+ /**
33
55
  * Size preset controlling padding and font size.
34
56
  * @type {string}
35
57
  * @default 'md'
@@ -40,16 +62,27 @@ var _sfc_main = {
40
62
  default: "md"
41
63
  },
42
64
  /**
43
- * Corner shape of the track and pill.
65
+ * Corner shape of the track, indicator, and segments. Matches `UiButton`'s
66
+ * `shape` naming.
44
67
  * @type {string}
45
68
  * @default 'pill'
46
- * @values 'pill' | 'rounded'
69
+ * @values 'pill' | 'round' | 'square'
47
70
  */
48
71
  shape: {
49
72
  type: String,
50
73
  default: "pill"
51
74
  },
52
75
  /**
76
+ * Full-width mode — the control fills its container and segments share the
77
+ * width equally.
78
+ * @type {boolean}
79
+ * @default false
80
+ */
81
+ block: {
82
+ type: Boolean,
83
+ default: false
84
+ },
85
+ /**
53
86
  * Accessible name for the group. Omit if you label it with an external
54
87
  * heading via `aria-labelledby` (which falls through to the root).
55
88
  * @type {string}
@@ -64,17 +97,32 @@ var _sfc_main = {
64
97
  setup(__props, { emit: __emit }) {
65
98
  /**
66
99
  * UiSegmented — a segmented control: pick one of a few named options from a row
67
- * of buttons, with a pill that slides to the active choice.
100
+ * of segments, with an indicator that slides to the active choice.
68
101
  *
69
102
  * This is a set of toggle buttons (`role="group"` + `aria-pressed`), not a
70
103
  * switch, because the choice is between named options rather than on/off — "the
71
104
  * second option is off" is not something a screen reader should say. Segments
72
- * are equal width so the pill can slide by whole columns.
105
+ * are equal width so the indicator can slide by whole columns, and the slide
106
+ * animates in both variants.
107
+ *
108
+ * The `variant` values match `UiButton`'s — `solid`, `outline`, `ghost` — so a
109
+ * segmented control sits alongside buttons as part of one visual family. The
110
+ * indicator slides (and animates) to the active choice in every variant.
111
+ *
112
+ * - `variant="solid"` (default) — a filled accent indicator; the active label
113
+ * goes white. Like a solid button.
114
+ * - `variant="outline"` — a bordered accent indicator; the active label takes
115
+ * the accent colour. Like an outline button.
116
+ * - `variant="ghost"` — a soft tinted indicator; the active label takes the
117
+ * accent colour. Like a ghost button.
118
+ *
119
+ * `shape` controls the corners — `pill`, `round`, or `square` (matching
120
+ * `UiButton`) — and the indicator matches the track's radius.
73
121
  *
74
122
  * For an on/off control use `UiToggle`; for many options or a searchable list
75
123
  * use `UiSelect`.
76
124
  *
77
- * @example Billing period
125
+ * @example Billing period (solid, the default)
78
126
  * <UiSegmented
79
127
  * v-model="billing"
80
128
  * :options="[
@@ -84,30 +132,57 @@ var _sfc_main = {
84
132
  * aria-label="Billing period"
85
133
  * />
86
134
  *
87
- * @example With icons and a labelled-by heading
88
- * <h2 id="view-h" class="sr-only">View</h2>
89
- * <UiSegmented v-model="view" :options="views" aria-labelledby="view-h" />
135
+ * @example Icon toolbar (outline, square corners)
136
+ * <UiSegmented
137
+ * v-model="view"
138
+ * variant="outline"
139
+ * shape="square"
140
+ * :options="[
141
+ * { value: 'grid', icon: 'mdi:view-grid', title: 'Grid' },
142
+ * { value: 'list', icon: 'mdi:view-list', title: 'List' },
143
+ * ]"
144
+ * aria-label="View"
145
+ * />
146
+ *
147
+ * @example Full-width ghost tabs
148
+ * <UiSegmented v-model="tab" variant="ghost" block :options="tabs" />
90
149
  *
91
150
  * @emits {string|number} update:modelValue — the chosen option's `value`
92
151
  */
93
152
  const props = __props;
94
153
  const emit = __emit;
154
+ const field = useFormField();
95
155
  const count = computed(() => props.options?.length || 1);
96
156
  const isActive = (option) => option.value === props.modelValue;
97
157
  const activeIndex = computed(() => {
98
158
  const i = (props.options ?? []).findIndex((o) => o.value === props.modelValue);
99
159
  return i === -1 ? 0 : i;
100
160
  });
101
- function select(option, index) {
161
+ function select(option) {
102
162
  if (option.disabled) return;
103
163
  emit("update:modelValue", option.value);
104
164
  }
105
- const trackClass = computed(() => props.shape === "rounded" ? "rounded-xl" : "rounded-full");
106
- const buttonShapeClass = computed(() => props.shape === "rounded" ? "rounded-lg" : "rounded-full");
107
- const pillClass = computed(() => props.shape === "rounded" ? "rounded-lg" : "rounded-full");
165
+ const gridStyle = computed(() => ({ gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))` }));
166
+ const radiusClass = computed(() => {
167
+ const map = {
168
+ pill: "rounded-full",
169
+ round: "rounded-lg",
170
+ square: "rounded-none"
171
+ };
172
+ return map[props.shape] ?? map.pill;
173
+ });
108
174
  const buttonSizeClass = computed(() => props.size === "sm" ? "px-3 py-1 text-xs" : "px-4 py-1.5 text-sm");
109
175
  const iconSizeClass = computed(() => props.size === "sm" ? "size-3.5" : "size-4");
110
- const pillStyle = computed(() => ({
176
+ const indicatorClass = computed(() => {
177
+ const map = {
178
+ solid: "bg-primary-600 shadow-sm",
179
+ outline: "border border-primary-500",
180
+ ghost: "bg-primary-50 dark:bg-primary-900/20"
181
+ };
182
+ return map[props.variant] ?? map.solid;
183
+ });
184
+ const activeTextClass = computed(() => props.variant === "solid" ? "text-white" : "text-primary-600 dark:text-primary-400");
185
+ const indicatorStyle = computed(() => ({
111
186
  width: `calc((100% - 0.5rem) / ${count.value})`,
112
187
  transform: `translateX(calc(${activeIndex.value} * 100%))`
113
188
  }));
@@ -115,29 +190,36 @@ var _sfc_main = {
115
190
  return openBlock(), createElementBlock("div", {
116
191
  role: "group",
117
192
  "aria-label": __props.ariaLabel,
118
- class: normalizeClass(["relative inline-grid p-1", [trackClass.value, "border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900"]]),
119
- style: normalizeStyle({ gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))` })
193
+ "aria-labelledby": __props.ariaLabel ? void 0 : unref(field)?.labelId,
194
+ "aria-describedby": unref(field)?.describedBy.value,
195
+ class: normalizeClass(["relative p-1", [
196
+ __props.block ? "grid w-full" : "inline-grid",
197
+ radiusClass.value,
198
+ "border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900"
199
+ ]]),
200
+ style: normalizeStyle(gridStyle.value)
120
201
  }, [createElementVNode("span", {
121
202
  "aria-hidden": "true",
122
- class: normalizeClass(["pointer-events-none absolute bottom-1 left-1 top-1 bg-primary-500 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none", pillClass.value]),
123
- style: normalizeStyle(pillStyle.value)
124
- }, null, 6), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option, index) => {
203
+ class: normalizeClass(["pointer-events-none absolute bottom-1 left-1 top-1 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none", [radiusClass.value, indicatorClass.value]]),
204
+ style: normalizeStyle(indicatorStyle.value)
205
+ }, null, 6), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option) => {
125
206
  return openBlock(), createElementBlock("button", {
126
207
  key: option.value,
127
208
  type: "button",
128
209
  "aria-pressed": isActive(option) ? "true" : "false",
129
210
  disabled: option.disabled,
211
+ title: option.title || void 0,
130
212
  class: normalizeClass(["relative z-10 inline-flex items-center justify-center gap-1.5 font-semibold transition-colors disabled:cursor-not-allowed disabled:opacity-50", [
131
213
  buttonSizeClass.value,
132
- buttonShapeClass.value,
133
- isActive(option) ? activeTextClass : idleTextClass
214
+ radiusClass.value,
215
+ isActive(option) ? activeTextClass.value : idleTextClass
134
216
  ]]),
135
- onClick: ($event) => select(option, index)
217
+ onClick: ($event) => select(option)
136
218
  }, [option.icon ? (openBlock(), createBlock(_sfc_main$1, {
137
219
  key: 0,
138
220
  name: option.icon,
139
221
  class: normalizeClass(iconSizeClass.value)
140
- }, null, 8, ["name", "class"])) : createCommentVNode("", true), createTextVNode(" " + toDisplayString(option.label), 1)], 10, _hoisted_2);
222
+ }, null, 8, ["name", "class"])) : createCommentVNode("", true), option.label ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(option.label), 1)) : createCommentVNode("", true)], 10, _hoisted_2);
141
223
  }), 128))], 14, _hoisted_1);
142
224
  };
143
225
  }
@@ -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 inline-grid p-1\"\n :class=\"[trackClass, 'border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900']\"\n :style=\"{ gridTemplateColumns: `repeat(${count}, minmax(0, 1fr))` }\"\n >\n <!--\n A single pill slides between segments rather than each segment owning its\n own background, so the movement animates. Segments are equal-width, so the\n pill's width is one column and it translates by whole columns. `top/bottom/\n left` inset it inside the track's padding; `%` in translateX resolves\n against the pill's own (one-column) width.\n -->\n <span\n aria-hidden=\"true\"\n class=\"pointer-events-none absolute bottom-1 left-1 top-1 bg-primary-500 shadow-sm transition-transform duration-300 ease-out motion-reduce:transition-none\"\n :class=\"pillClass\"\n :style=\"pillStyle\"\n />\n\n <button\n v-for=\"(option, index) in options\"\n :key=\"option.value\"\n type=\"button\"\n :aria-pressed=\"isActive(option) ? 'true' : 'false'\"\n :disabled=\"option.disabled\"\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=\"[\n buttonSizeClass,\n buttonShapeClass,\n isActive(option) ? activeTextClass : idleTextClass,\n ]\"\n @click=\"select(option, index)\"\n >\n <UiIcon v-if=\"option.icon\" :name=\"option.icon\" :class=\"iconSizeClass\" />\n {{ option.label }}\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 buttons, with a pill 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 pill can slide by whole columns.\n *\n * For an on/off control use `UiToggle`; for many options or a searchable list\n * use `UiSelect`.\n *\n * @example Billing period\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 With icons and a labelled-by heading\n * <h2 id=\"view-h\" class=\"sr-only\">View</h2>\n * <UiSegmented v-model=\"view\" :options=\"views\" aria-labelledby=\"view-h\" />\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? }`.\n * @type {Array<{ value: string|number, label: string, icon?: string, disabled?: boolean }>}\n */\n options: { type: Array, required: true },\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 and pill.\n * @type {string}\n * @default 'pill'\n * @values 'pill' | 'rounded'\n */\n shape: { type: String, default: 'pill' },\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, index) {\n if (option.disabled) return\n emit('update:modelValue', option.value)\n // index is accepted for symmetry with the template call site; the value is\n // what identifies the option.\n void index\n}\n\nconst trackClass = computed(() => (props.shape === 'rounded' ? 'rounded-xl' : 'rounded-full'))\nconst buttonShapeClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))\nconst pillClass = computed(() => (props.shape === 'rounded' ? 'rounded-lg' : 'rounded-full'))\n\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\nconst activeTextClass = 'text-white'\nconst idleTextClass =\n 'text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100'\n\nconst pillStyle = 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":";;;;;;;;;AA6IA,IAAM,kBAAkB;AACxB,IAAM,gBACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EArEF,MAAM,QAAQ;EAuCd,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,OAAO;GAC7B,IAAI,OAAO,UAAU;GACrB,KAAK,qBAAqB,OAAO,KAAK;EAIxC;EAEA,MAAM,aAAa,eAAgB,MAAM,UAAU,YAAY,eAAe,cAAe;EAC7F,MAAM,mBAAmB,eAAgB,MAAM,UAAU,YAAY,eAAe,cAAe;EACnG,MAAM,YAAY,eAAgB,MAAM,UAAU,YAAY,eAAe,cAAe;EAE5F,MAAM,kBAAkB,eACtB,MAAM,SAAS,OAAO,sBAAsB,qBAC9C;EACA,MAAM,gBAAgB,eAAgB,MAAM,SAAS,OAAO,aAAa,QAAS;EAMlF,MAAM,YAAY,gBAAgB;GAGhC,OAAO,0BAA0B,MAAM,MAAM;GAC7C,WAAW,mBAAmB,YAAY,MAAM;EAClD,EAAE;;GArJA,OAAA,UAAA,GAAA,mBAsCM,OAAA;IArCJ,MAAK;IACJ,cAAY,QAAA;IACb,OAAK,eAAA,CAAC,4BAA0B,CACvB,WAAA,OAAU,yEAAA,CAAA,CAAA;IAClB,OAAK,eAAA,EAAA,qBAAA,UAAmC,MAAA,MAAK,mBAAA,CAAA;GAS9C,GAAA,CAAA,mBAKE,QAAA;IAJA,eAAY;IACZ,OAAK,eAAA,CAAC,wJACE,UAAA,KAAS,CAAA;IAChB,OAAK,eAAE,UAAA,KAAS;GAGnB,GAAA,MAAA,CAAA,IAAA,UAAA,IAAA,GAAA,mBAgBS,UAAA,MAAA,WAfmB,QAAA,UAAlB,QAAQ,UAAK;IADvB,OAAA,UAAA,GAAA,mBAgBS,UAAA;KAdN,KAAK,OAAO;KACb,MAAK;KACJ,gBAAc,SAAS,MAAM,IAAA,SAAA;KAC7B,UAAU,OAAO;KAClB,OAAK,eAAA,CAAC,iJAA+I;MACnI,gBAAA;MAAyB,iBAAA;MAA0B,SAAS,MAAM,IAAI,kBAAkB;;KAKzG,UAAK,WAAE,OAAO,QAAQ,KAAK;IAEd,GAAA,CAAA,OAAO,QAArB,UAAA,GAAA,YAAwE,aAAA;;KAA5C,MAAM,OAAO;KAAO,OAAK,eAAE,cAAA,KAAa;IAAI,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,gBAAA,MACxE,gBAAG,OAAO,KAAK,GAAA,CAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAlHF,MAAM,QAAQ;EA8Dd,MAAM,OAAO;EAEb,MAAM,QAAQ,aAAa;EAE3B,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,UAAU;GACrB,KAAK,qBAAqB,OAAO,KAAK;EACxC;EAEA,MAAM,YAAY,gBAAgB,EAChC,qBAAqB,UAAU,MAAM,MAAM,mBAC7C,EAAE;EAMF,MAAM,cAAc,eAAe;GACjC,MAAM,MAAM;IAAE,MAAM;IAAgB,OAAO;IAAc,QAAQ;GAAe;GAChF,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;EAGD,MAAM,kBAAkB,eACtB,MAAM,SAAS,OAAO,sBAAsB,qBAC9C;EACA,MAAM,gBAAgB,eAAgB,MAAM,SAAS,OAAO,aAAa,QAAS;EAKlF,MAAM,iBAAiB,eAAe;GACpC,MAAM,MAAM;IACV,OAAO;IACP,SAAS;IACT,OAAO;GACT;GACA,OAAO,IAAI,MAAM,YAAY,IAAI;EACnC,CAAC;EACD,MAAM,kBAAkB,eACtB,MAAM,YAAY,UAAU,eAAe,wCAC7C;EAIA,MAAM,iBAAiB,gBAAgB;GAGrC,OAAO,0BAA0B,MAAM,MAAM;GAC7C,WAAW,mBAAmB,YAAY,MAAM;EAClD,EAAE;;GAhOA,OAAA,UAAA,GAAA,mBAyCM,OAAA;IAxCJ,MAAK;IACJ,cAAY,QAAA;IACZ,mBAAiB,QAAA,YAAY,KAAA,IAAY,MAAA,KAAA,CAAK,EAAE;IAChD,oBAAkB,MAAA,KAAA,CAAK,EAAE,YAAY;IACtC,OAAK,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"}