numori-ui 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +122 -0
- package/README.md +26 -21
- package/dist/components/Banner.js +176 -0
- package/dist/components/Banner.js.map +1 -0
- package/dist/components/Button.js +10 -19
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +15 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.js +2 -7
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CodeBlock.js +101 -0
- package/dist/components/CodeBlock.js.map +1 -0
- package/dist/components/Dropdown.js +10 -3
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/DropdownSubmenu.js +5 -3
- package/dist/components/DropdownSubmenu.js.map +1 -1
- package/dist/components/FileInput.js +12 -4
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/IconTile.js +5 -9
- package/dist/components/IconTile.js.map +1 -1
- package/dist/components/Input.js +6 -6
- package/dist/components/Input.js.map +1 -1
- package/dist/components/ListMenuItem.js +38 -31
- package/dist/components/ListMenuItem.js.map +1 -1
- package/dist/components/Numpad.js +4 -4
- package/dist/components/Numpad.js.map +1 -1
- package/dist/components/Popup.js +9 -3
- package/dist/components/Popup.js.map +1 -1
- package/dist/components/Radio.js +2 -7
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Segmented.js +100 -26
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +6 -4
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Spinner.js +87 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Table.js +174 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/ThemeToggle.js +85 -0
- package/dist/components/ThemeToggle.js.map +1 -0
- package/dist/components/Toast.js +107 -0
- package/dist/components/Toast.js.map +1 -0
- package/dist/components/index.js +67 -57
- package/dist/components/index.js.map +1 -1
- package/dist/composables/useMergedClasses.js +52 -0
- package/dist/composables/useMergedClasses.js.map +1 -0
- package/dist/icons/mdi.js +10 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +35 -30
- package/dist/index.js.map +1 -1
- package/dist/internal/controlSizes.js +21 -0
- package/dist/internal/controlSizes.js.map +1 -0
- package/dist/internal/menu.js +20 -0
- package/dist/internal/menu.js.map +1 -0
- package/dist/manifest.js +6 -1
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/Banner.vue +160 -0
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +2 -10
- package/src/components/CodeBlock.vue +99 -0
- package/src/components/Dropdown.vue +14 -2
- package/src/components/DropdownSubmenu.vue +4 -2
- package/src/components/FileInput.vue +19 -4
- package/src/components/IconTile.vue +4 -9
- package/src/components/Input.vue +6 -6
- package/src/components/ListMenuItem.vue +21 -5
- package/src/components/Numpad.vue +7 -4
- package/src/components/Popup.vue +6 -2
- package/src/components/Radio.vue +2 -10
- package/src/components/Segmented.vue +108 -38
- package/src/components/Select.vue +11 -2
- package/src/components/Spinner.vue +70 -0
- package/src/components/Table.vue +193 -0
- package/src/components/ThemeToggle.vue +81 -0
- package/src/components/Toast.vue +106 -0
- package/src/components/index.js +18 -3
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +10 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +6 -1
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode,
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, openBlock, renderList, toDisplayString } from "vue";
|
|
3
3
|
//#region src/components/Segmented.vue
|
|
4
4
|
var _hoisted_1 = ["aria-label"];
|
|
5
5
|
var _hoisted_2 = [
|
|
6
6
|
"aria-pressed",
|
|
7
7
|
"disabled",
|
|
8
|
+
"title",
|
|
8
9
|
"onClick"
|
|
9
10
|
];
|
|
10
|
-
var
|
|
11
|
+
var _hoisted_3 = { key: 1 };
|
|
11
12
|
var idleTextClass = "text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100";
|
|
12
13
|
var _sfc_main = {
|
|
13
14
|
__name: "Segmented",
|
|
@@ -22,14 +23,30 @@ var _sfc_main = {
|
|
|
22
23
|
default: void 0
|
|
23
24
|
},
|
|
24
25
|
/**
|
|
25
|
-
* The options. Each is `{ value, label
|
|
26
|
-
*
|
|
26
|
+
* The options. Each is `{ value, label?, icon?, disabled?, title? }`. Provide
|
|
27
|
+
* `label` for text segments, `icon` for icon-only segments, or both. `title`
|
|
28
|
+
* sets the native tooltip (useful for icon-only segments).
|
|
29
|
+
* @type {Array<{ value: string|number, label?: string, icon?: string, disabled?: boolean, title?: string }>}
|
|
27
30
|
*/
|
|
28
31
|
options: {
|
|
29
32
|
type: Array,
|
|
30
33
|
required: true
|
|
31
34
|
},
|
|
32
35
|
/**
|
|
36
|
+
* Active-segment appearance, mirroring the equivalent `UiButton` variants so
|
|
37
|
+
* the two feel like one family. The sliding indicator animates in every case.
|
|
38
|
+
* - 'solid' — a filled accent indicator; the active label goes white (default).
|
|
39
|
+
* - 'outline' — a bordered accent indicator; the active label takes the accent.
|
|
40
|
+
* - 'ghost' — a soft tinted indicator; the active label takes the accent.
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @default 'solid'
|
|
43
|
+
* @values 'solid' | 'outline' | 'ghost'
|
|
44
|
+
*/
|
|
45
|
+
variant: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: "solid"
|
|
48
|
+
},
|
|
49
|
+
/**
|
|
33
50
|
* Size preset controlling padding and font size.
|
|
34
51
|
* @type {string}
|
|
35
52
|
* @default 'md'
|
|
@@ -40,16 +57,27 @@ var _sfc_main = {
|
|
|
40
57
|
default: "md"
|
|
41
58
|
},
|
|
42
59
|
/**
|
|
43
|
-
* Corner shape of the track and
|
|
60
|
+
* Corner shape of the track, indicator, and segments. Matches `UiButton`'s
|
|
61
|
+
* `shape` naming.
|
|
44
62
|
* @type {string}
|
|
45
63
|
* @default 'pill'
|
|
46
|
-
* @values 'pill' | '
|
|
64
|
+
* @values 'pill' | 'round' | 'square'
|
|
47
65
|
*/
|
|
48
66
|
shape: {
|
|
49
67
|
type: String,
|
|
50
68
|
default: "pill"
|
|
51
69
|
},
|
|
52
70
|
/**
|
|
71
|
+
* Full-width mode — the control fills its container and segments share the
|
|
72
|
+
* width equally.
|
|
73
|
+
* @type {boolean}
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
block: {
|
|
77
|
+
type: Boolean,
|
|
78
|
+
default: false
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
53
81
|
* Accessible name for the group. Omit if you label it with an external
|
|
54
82
|
* heading via `aria-labelledby` (which falls through to the root).
|
|
55
83
|
* @type {string}
|
|
@@ -64,17 +92,32 @@ var _sfc_main = {
|
|
|
64
92
|
setup(__props, { emit: __emit }) {
|
|
65
93
|
/**
|
|
66
94
|
* UiSegmented — a segmented control: pick one of a few named options from a row
|
|
67
|
-
* of
|
|
95
|
+
* of segments, with an indicator that slides to the active choice.
|
|
68
96
|
*
|
|
69
97
|
* This is a set of toggle buttons (`role="group"` + `aria-pressed`), not a
|
|
70
98
|
* switch, because the choice is between named options rather than on/off — "the
|
|
71
99
|
* second option is off" is not something a screen reader should say. Segments
|
|
72
|
-
* are equal width so the
|
|
100
|
+
* are equal width so the indicator can slide by whole columns, and the slide
|
|
101
|
+
* animates in both variants.
|
|
102
|
+
*
|
|
103
|
+
* The `variant` values match `UiButton`'s — `solid`, `outline`, `ghost` — so a
|
|
104
|
+
* segmented control sits alongside buttons as part of one visual family. The
|
|
105
|
+
* indicator slides (and animates) to the active choice in every variant.
|
|
106
|
+
*
|
|
107
|
+
* - `variant="solid"` (default) — a filled accent indicator; the active label
|
|
108
|
+
* goes white. Like a solid button.
|
|
109
|
+
* - `variant="outline"` — a bordered accent indicator; the active label takes
|
|
110
|
+
* the accent colour. Like an outline button.
|
|
111
|
+
* - `variant="ghost"` — a soft tinted indicator; the active label takes the
|
|
112
|
+
* accent colour. Like a ghost button.
|
|
113
|
+
*
|
|
114
|
+
* `shape` controls the corners — `pill`, `round`, or `square` (matching
|
|
115
|
+
* `UiButton`) — and the indicator matches the track's radius.
|
|
73
116
|
*
|
|
74
117
|
* For an on/off control use `UiToggle`; for many options or a searchable list
|
|
75
118
|
* use `UiSelect`.
|
|
76
119
|
*
|
|
77
|
-
* @example Billing period
|
|
120
|
+
* @example Billing period (solid, the default)
|
|
78
121
|
* <UiSegmented
|
|
79
122
|
* v-model="billing"
|
|
80
123
|
* :options="[
|
|
@@ -84,9 +127,20 @@ var _sfc_main = {
|
|
|
84
127
|
* aria-label="Billing period"
|
|
85
128
|
* />
|
|
86
129
|
*
|
|
87
|
-
* @example
|
|
88
|
-
* <
|
|
89
|
-
*
|
|
130
|
+
* @example Icon toolbar (outline, square corners)
|
|
131
|
+
* <UiSegmented
|
|
132
|
+
* v-model="view"
|
|
133
|
+
* variant="outline"
|
|
134
|
+
* shape="square"
|
|
135
|
+
* :options="[
|
|
136
|
+
* { value: 'grid', icon: 'mdi:view-grid', title: 'Grid' },
|
|
137
|
+
* { value: 'list', icon: 'mdi:view-list', title: 'List' },
|
|
138
|
+
* ]"
|
|
139
|
+
* aria-label="View"
|
|
140
|
+
* />
|
|
141
|
+
*
|
|
142
|
+
* @example Full-width ghost tabs
|
|
143
|
+
* <UiSegmented v-model="tab" variant="ghost" block :options="tabs" />
|
|
90
144
|
*
|
|
91
145
|
* @emits {string|number} update:modelValue — the chosen option's `value`
|
|
92
146
|
*/
|
|
@@ -98,16 +152,31 @@ var _sfc_main = {
|
|
|
98
152
|
const i = (props.options ?? []).findIndex((o) => o.value === props.modelValue);
|
|
99
153
|
return i === -1 ? 0 : i;
|
|
100
154
|
});
|
|
101
|
-
function select(option
|
|
155
|
+
function select(option) {
|
|
102
156
|
if (option.disabled) return;
|
|
103
157
|
emit("update:modelValue", option.value);
|
|
104
158
|
}
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
159
|
+
const gridStyle = computed(() => ({ gridTemplateColumns: `repeat(${count.value}, minmax(0, 1fr))` }));
|
|
160
|
+
const radiusClass = computed(() => {
|
|
161
|
+
const map = {
|
|
162
|
+
pill: "rounded-full",
|
|
163
|
+
round: "rounded-lg",
|
|
164
|
+
square: "rounded-none"
|
|
165
|
+
};
|
|
166
|
+
return map[props.shape] ?? map.pill;
|
|
167
|
+
});
|
|
108
168
|
const buttonSizeClass = computed(() => props.size === "sm" ? "px-3 py-1 text-xs" : "px-4 py-1.5 text-sm");
|
|
109
169
|
const iconSizeClass = computed(() => props.size === "sm" ? "size-3.5" : "size-4");
|
|
110
|
-
const
|
|
170
|
+
const indicatorClass = computed(() => {
|
|
171
|
+
const map = {
|
|
172
|
+
solid: "bg-primary-600 shadow-sm",
|
|
173
|
+
outline: "border border-primary-500",
|
|
174
|
+
ghost: "bg-primary-50 dark:bg-primary-900/20"
|
|
175
|
+
};
|
|
176
|
+
return map[props.variant] ?? map.solid;
|
|
177
|
+
});
|
|
178
|
+
const activeTextClass = computed(() => props.variant === "solid" ? "text-white" : "text-primary-600 dark:text-primary-400");
|
|
179
|
+
const indicatorStyle = computed(() => ({
|
|
111
180
|
width: `calc((100% - 0.5rem) / ${count.value})`,
|
|
112
181
|
transform: `translateX(calc(${activeIndex.value} * 100%))`
|
|
113
182
|
}));
|
|
@@ -115,29 +184,34 @@ var _sfc_main = {
|
|
|
115
184
|
return openBlock(), createElementBlock("div", {
|
|
116
185
|
role: "group",
|
|
117
186
|
"aria-label": __props.ariaLabel,
|
|
118
|
-
class: normalizeClass(["relative
|
|
119
|
-
|
|
187
|
+
class: normalizeClass(["relative p-1", [
|
|
188
|
+
__props.block ? "grid w-full" : "inline-grid",
|
|
189
|
+
radiusClass.value,
|
|
190
|
+
"border border-gray-200 bg-gray-50 dark:border-gray-700 dark:bg-gray-900"
|
|
191
|
+
]]),
|
|
192
|
+
style: normalizeStyle(gridStyle.value)
|
|
120
193
|
}, [createElementVNode("span", {
|
|
121
194
|
"aria-hidden": "true",
|
|
122
|
-
class: normalizeClass(["pointer-events-none absolute bottom-1 left-1 top-1
|
|
123
|
-
style: normalizeStyle(
|
|
124
|
-
}, null, 6), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option
|
|
195
|
+
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]]),
|
|
196
|
+
style: normalizeStyle(indicatorStyle.value)
|
|
197
|
+
}, null, 6), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (option) => {
|
|
125
198
|
return openBlock(), createElementBlock("button", {
|
|
126
199
|
key: option.value,
|
|
127
200
|
type: "button",
|
|
128
201
|
"aria-pressed": isActive(option) ? "true" : "false",
|
|
129
202
|
disabled: option.disabled,
|
|
203
|
+
title: option.title || void 0,
|
|
130
204
|
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
205
|
buttonSizeClass.value,
|
|
132
|
-
|
|
133
|
-
isActive(option) ? activeTextClass : idleTextClass
|
|
206
|
+
radiusClass.value,
|
|
207
|
+
isActive(option) ? activeTextClass.value : idleTextClass
|
|
134
208
|
]]),
|
|
135
|
-
onClick: ($event) => select(option
|
|
209
|
+
onClick: ($event) => select(option)
|
|
136
210
|
}, [option.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
137
211
|
key: 0,
|
|
138
212
|
name: option.icon,
|
|
139
213
|
class: normalizeClass(iconSizeClass.value)
|
|
140
|
-
}, null, 8, ["name", "class"])) : createCommentVNode("", true),
|
|
214
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), option.label ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(option.label), 1)) : createCommentVNode("", true)], 10, _hoisted_2);
|
|
141
215
|
}), 128))], 14, _hoisted_1);
|
|
142
216
|
};
|
|
143
217
|
}
|
|
@@ -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,mB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AA,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 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,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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E,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,5 +1,6 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MENU_PANEL_CLASS } from "../internal/menu.js";
|
|
3
|
+
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";
|
|
3
4
|
//#region src/components/Select.vue
|
|
4
5
|
var _hoisted_1 = { class: "inline-flex items-center gap-2" };
|
|
5
6
|
var _hoisted_2 = {
|
|
@@ -194,7 +195,8 @@ var _sfc_main = {
|
|
|
194
195
|
const openUp = spaceBelow < 260 && rect.top > spaceBelow;
|
|
195
196
|
const style = {
|
|
196
197
|
left: `${rect.left}px`,
|
|
197
|
-
minWidth: `${rect.width}px
|
|
198
|
+
minWidth: `${rect.width}px`,
|
|
199
|
+
transformOrigin: openUp ? "bottom center" : "top center"
|
|
198
200
|
};
|
|
199
201
|
if (props.block) style.width = `${rect.width}px`;
|
|
200
202
|
if (openUp) style.bottom = `${window.innerHeight - rect.top + 4}px`;
|
|
@@ -396,7 +398,7 @@ var _sfc_main = {
|
|
|
396
398
|
default: withCtx(() => [withDirectives(createElementVNode("div", {
|
|
397
399
|
ref_key: "panelRef",
|
|
398
400
|
ref: panelRef,
|
|
399
|
-
class: "fixed z-[60]
|
|
401
|
+
class: normalizeClass(["fixed z-[60] overflow-hidden", unref(MENU_PANEL_CLASS)]),
|
|
400
402
|
style: normalizeStyle(panelStyle.value)
|
|
401
403
|
}, [__props.searchable ? (openBlock(), createElementBlock("div", _hoisted_5, [withDirectives(createElementVNode("input", {
|
|
402
404
|
ref_key: "searchRef",
|
|
@@ -428,7 +430,7 @@ var _sfc_main = {
|
|
|
428
430
|
class: "w-4 h-4 shrink-0"
|
|
429
431
|
}, null, 8, ["name"])) : createCommentVNode("", true), createElementVNode("div", _hoisted_15, [createElementVNode("span", _hoisted_16, toDisplayString(opt.label), 1), opt.subtitle ? (openBlock(), createElementBlock("span", _hoisted_17, toDisplayString(opt.subtitle), 1)) : createCommentVNode("", true)])], 10, _hoisted_14);
|
|
430
432
|
}), 128))], 64);
|
|
431
|
-
}), 128))])],
|
|
433
|
+
}), 128))])], 6), [[vShow, isOpen.value]])]),
|
|
432
434
|
_: 1
|
|
433
435
|
})]))
|
|
434
436
|
], 2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Select.js","names":[],"sources":["../../src/components/Select.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\" :class=\"!block ? 'inline-block' : ''\">\n <!-- Hidden sizer: measures the widest option label so the trigger never shrinks below it -->\n <div\n ref=\"sizerRef\"\n aria-hidden=\"true\"\n class=\"invisible absolute h-0 overflow-hidden pointer-events-none whitespace-nowrap\"\n :class=\"sizerTextClass\"\n >\n <span v-for=\"opt in normalizedOptions\" :key=\"opt.value\" class=\"block\">\n <span class=\"inline-flex items-center gap-2\">\n <span v-if=\"opt.icon\" class=\"w-4\" />\n {{ opt.label }}\n <!-- account for chevron + padding -->\n <span class=\"w-4\" />\n </span>\n </span>\n </div>\n\n <!-- Trigger button: shows selected value, placeholder, or loading spinner -->\n <button\n ref=\"triggerRef\"\n type=\"button\"\n :disabled=\"disabled || loading\"\n :aria-label=\"ariaLabel\"\n :class=\"[triggerClasses, disabled || loading ? 'opacity-50 cursor-not-allowed' : '']\"\n :style=\"autoMinWidth\"\n @click=\"toggleOpen\"\n >\n <span\n v-if=\"loading\"\n class=\"flex items-center gap-2 truncate text-gray-400 dark:text-gray-500\"\n >\n <UiIcon :name=\"spinner\" class=\"w-4 h-4 animate-spin shrink-0\" />\n <span>{{ loadingText }}</span>\n </span>\n <template v-else>\n <span\n class=\"flex items-center gap-2 truncate\"\n :class=\"selectedLabel ? '' : 'text-gray-400 dark:text-gray-500'\"\n >\n <UiIcon v-if=\"selectedIcon\" :name=\"selectedIcon\" class=\"w-4 h-4 shrink-0\" />\n {{ selectedLabel || placeholder || 'Select...' }}\n </span>\n </template>\n <UiIcon\n name=\"mdi:chevron-down\"\n class=\"w-4 h-4 shrink-0 text-gray-400 transition-transform\"\n :class=\"{ 'rotate-180': isOpen }\"\n />\n </button>\n\n <!-- Dropdown panel: teleported to <body> and fixed-positioned so it is never\n clipped by an ancestor with overflow (e.g. a scrollable modal body). -->\n <Teleport to=\"body\">\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-show=\"isOpen\"\n ref=\"panelRef\"\n class=\"fixed z-[60] bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden\"\n :style=\"panelStyle\"\n >\n <!-- Search input for filtering options -->\n <div v-if=\"searchable\" class=\"p-1.5\">\n <input\n ref=\"searchRef\"\n v-model=\"searchQuery\"\n type=\"text\"\n placeholder=\"Search...\"\n 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\"\n @keydown.escape=\"close\"\n @keydown.enter.prevent=\"selectFirst\"\n />\n </div>\n <!-- Options list: ungrouped flat list or grouped sections -->\n <ul class=\"max-h-64 overflow-y-auto py-1\">\n <li\n v-if=\"filteredOptions.length === 0 && filteredGroups.length === 0\"\n class=\"px-3 py-2 text-sm text-gray-400 dark:text-gray-500\"\n >\n No results\n </li>\n\n <!-- Ungrouped options -->\n <template v-if=\"filteredGroups.length === 0\">\n <li\n v-for=\"opt in filteredOptions\"\n :key=\"opt.value\"\n class=\"flex items-center gap-2 px-3 cursor-pointer transition-colors\"\n :class=\"[optionClass(opt.value), opt.subtitle ? 'py-1.5' : 'py-1.5']\"\n @click=\"select(opt.value)\"\n >\n <UiIcon v-if=\"opt.icon\" :name=\"opt.icon\" class=\"w-4 h-4 shrink-0\" />\n <div class=\"min-w-0\">\n <span class=\"block truncate text-sm\">{{ opt.label }}</span>\n <span\n v-if=\"opt.subtitle\"\n class=\"block truncate text-[11px] text-gray-400 dark:text-gray-500 leading-tight\"\n >{{ opt.subtitle }}</span\n >\n </div>\n </li>\n </template>\n\n <!-- Grouped options -->\n <template v-else>\n <template v-for=\"group in filteredGroups\" :key=\"group.label\">\n <li\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 select-none\"\n >\n {{ group.label }}\n </li>\n <li\n v-for=\"opt in group.options\"\n :key=\"opt.value\"\n class=\"flex items-center gap-2 px-3 cursor-pointer transition-colors\"\n :class=\"[optionClass(opt.value), opt.subtitle ? 'py-1.5' : 'py-1.5']\"\n @click=\"select(opt.value)\"\n >\n <UiIcon v-if=\"opt.icon\" :name=\"opt.icon\" class=\"w-4 h-4 shrink-0\" />\n <div class=\"min-w-0\">\n <span class=\"block truncate text-sm\">{{ opt.label }}</span>\n <span\n v-if=\"opt.subtitle\"\n class=\"block truncate text-[11px] text-gray-400 dark:text-gray-500 leading-tight\"\n >{{ opt.subtitle }}</span\n >\n </div>\n </li>\n </template>\n </template>\n </ul>\n </div>\n </Transition>\n </Teleport>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSelect — Custom dropdown select component with search, grouping, icons, and loading state.\n *\n * Renders a styled trigger button that opens a dropdown panel with filterable options.\n * Supports flat option lists and grouped options (via `group` key on option objects).\n * Includes keyboard navigation (Escape to close, Enter to select first match),\n * automatic drop-up when near the bottom of the viewport, and a loading spinner state.\n *\n * @example Basic select\n * <UiSelect v-model=\"color\" :options=\"['Red', 'Green', 'Blue']\" placeholder=\"Pick a color\" />\n *\n * @example Searchable select with object options\n * <UiSelect v-model=\"lang\" :options=\"[{ value: 'en', label: 'English' }, { value: 'es', label: 'Spanish' }]\" searchable />\n *\n * @example Grouped options with icons\n * <UiSelect v-model=\"tool\" :options=\"[\n * { value: 'pen', label: 'Pen', icon: 'mdi:pen', group: 'Drawing' },\n * { value: 'eraser', label: 'Eraser', icon: 'mdi:eraser', group: 'Drawing' },\n * { value: 'text', label: 'Text', icon: 'mdi:format-text', group: 'Insert' },\n * ]\" searchable />\n *\n * @example Loading state\n * <UiSelect v-model=\"val\" :options=\"[]\" :loading=\"true\" loading-text=\"Fetching...\" />\n *\n * @emits {string | number | boolean} update:modelValue — Emitted when an option is selected\n */\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /**\n * Currently selected value (v-model).\n * @type {string | number | boolean | null}\n * @default ''\n */\n modelValue: { type: [String, Number, Boolean, null], default: '' },\n\n /**\n * Array of selectable options. Each item can be:\n * - A primitive (string/number) used as both value and label\n * - An object: `{ value, label, icon?, group? }`\n * @type {Array}\n * @default []\n */\n options: { type: Array, default: () => [] },\n\n /**\n * Placeholder text shown when no option is selected.\n * @type {string}\n * @default ''\n */\n placeholder: { type: String, default: '' },\n\n /**\n * Enable a search input inside the dropdown for filtering options.\n * @type {boolean}\n * @default false\n */\n searchable: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the trigger and prevents opening.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Trigger button size controlling padding and font.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Full-width mode — trigger stretches to fill its container.\n * @type {boolean}\n * @default true\n */\n block: { type: Boolean, default: true },\n\n /**\n * Accessible label for the trigger button.\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * Loading state — shows a spinner and disables interaction.\n * @type {boolean}\n * @default false\n */\n loading: { type: Boolean, default: false },\n\n /**\n * Text displayed next to the spinner during loading.\n * @type {string}\n * @default 'Loading...'\n */\n loadingText: { type: String, default: 'Loading...' },\n\n /**\n * MDI icon name for the loading spinner.\n * @type {string}\n * @default 'mdi:loading'\n */\n spinner: { type: String, default: 'mdi:loading' },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst containerRef = ref(null)\nconst triggerRef = ref(null)\nconst searchRef = ref(null)\nconst sizerRef = ref(null)\nconst panelRef = ref(null)\nconst isOpen = ref(false)\nconst searchQuery = ref('')\nconst measuredWidth = ref(0)\nconst panelStyle = ref({})\n\n// Position the teleported panel under (or above) the trigger using fixed\n// coordinates so it overlays everything and is never clipped by a scrollable\n// ancestor. Re-run on scroll/resize while open so it stays anchored.\nconst reposition = () => {\n const el = triggerRef.value\n if (!el) return\n const rect = el.getBoundingClientRect()\n const spaceBelow = window.innerHeight - rect.bottom\n const openUp = spaceBelow < 260 && rect.top > spaceBelow\n const style = { left: `${rect.left}px`, minWidth: `${rect.width}px` }\n if (props.block) style.width = `${rect.width}px`\n if (openUp) style.bottom = `${window.innerHeight - rect.top + 4}px`\n else style.top = `${rect.bottom + 4}px`\n panelStyle.value = style\n}\n\nconst startTracking = () => {\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n}\nconst stopTracking = () => {\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n}\n\n// Text class for the hidden sizer — must match the trigger's font size\nconst sizerTextClass = computed(() => {\n const map = { xs: 'text-xs', sm: 'text-sm', md: 'text-sm' }\n return map[props.size] || 'text-sm'\n})\n\n// Measure the widest option on mount and when options change\nconst measureSizer = () => {\n if (!sizerRef.value) {\n measuredWidth.value = 0\n return\n }\n measuredWidth.value = sizerRef.value.scrollWidth\n}\n\nonMounted(measureSizer)\nwatch(\n () => props.options,\n () => nextTick(measureSizer),\n { deep: true },\n)\n\n// Auto min-width style: ensures trigger never shrinks below the widest option\nconst autoMinWidth = computed(() => {\n if (!measuredWidth.value) return undefined\n // Add padding for the trigger's horizontal padding + border\n const padMap = { xs: 28, sm: 24, md: 30 }\n const pad = padMap[props.size] || 30\n return { minWidth: `${measuredWidth.value + pad}px` }\n})\n\n// ── Normalize options ────────────────────────────────────\n// Convert primitive options (string/number) into { value, label, subtitle, icon, group } objects\nconst normalizedOptions = computed(() =>\n props.options.map((opt) =>\n typeof opt === 'object' && opt !== null\n ? {\n value: opt.value,\n label: opt.label ?? String(opt.value),\n subtitle: opt.subtitle || '',\n icon: opt.icon || '',\n group: opt.group || '',\n }\n : { value: opt, label: String(opt), subtitle: '', icon: '', group: '' },\n ),\n)\n\n// ── Filtering ────────────────────────────────────────────\n// Apply search query filter against option labels (case-insensitive)\nconst filteredNormalized = computed(() => {\n if (!searchQuery.value) return normalizedOptions.value\n const q = searchQuery.value.toLowerCase()\n return normalizedOptions.value.filter(\n (opt) => opt.label.toLowerCase().includes(q) || opt.subtitle.toLowerCase().includes(q),\n )\n})\n\n// ── Grouping ─────────────────────────────────────────────\n// Detect if any option has a group key to enable grouped rendering\nconst hasGroups = computed(() => normalizedOptions.value.some((o) => o.group))\n\n// Build grouped structure: Map<groupLabel, { label, options[] }>\nconst filteredGroups = computed(() => {\n if (!hasGroups.value) return []\n const map = new Map()\n for (const opt of filteredNormalized.value) {\n const key = opt.group || ''\n if (!map.has(key)) map.set(key, { label: key, options: [] })\n map.get(key).options.push(opt)\n }\n return [...map.values()].filter((g) => g.options.length > 0)\n})\n\nconst filteredOptions = computed(() => {\n if (hasGroups.value) return []\n return filteredNormalized.value\n})\n\n// ── Selected display ─────────────────────────────────────\nconst selectedOpt = computed(() =>\n normalizedOptions.value.find((o) => o.value === props.modelValue),\n)\nconst selectedLabel = computed(() => selectedOpt.value?.label || '')\nconst selectedIcon = computed(() => selectedOpt.value?.icon || '')\n\n// ── Styling ──────────────────────────────────────────────\nconst triggerClasses = computed(() => {\n const base =\n 'flex items-center justify-between gap-2 text-left border bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-400 outline-none transition-colors focus:ring-2 focus:ring-primary-500 focus:border-primary-500'\n const width = props.block ? 'w-full' : ''\n const sizeMap = {\n xs: 'px-2.5 py-1.5 text-xs rounded-md border-gray-200 dark:border-gray-700',\n sm: 'px-2 py-1 text-sm rounded-lg border-gray-300 dark:border-gray-600',\n md: 'px-3 py-2 text-sm rounded-lg border-gray-300 dark:border-gray-700',\n }\n return `${base} ${width} ${sizeMap[props.size] || sizeMap.md}`\n})\n\nconst optionClass = (value) =>\n props.modelValue === value\n ? 'bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300'\n : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'\n\n// ── Interactions ─────────────────────────────────────────\n// Toggle dropdown open/close, auto-detect drop direction, and focus search input\nconst toggleOpen = () => {\n if (props.disabled || props.loading) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n searchQuery.value = ''\n reposition()\n startTracking()\n nextTick(() => {\n reposition()\n if (props.searchable) searchRef.value?.focus()\n })\n } else {\n stopTracking()\n }\n}\n\nconst select = (value) => {\n emit('update:modelValue', value)\n close()\n}\n\nconst selectFirst = () => {\n const pool = hasGroups.value\n ? filteredGroups.value.flatMap((g) => g.options)\n : filteredOptions.value\n if (pool.length) select(pool[0].value)\n}\n\nconst close = () => {\n isOpen.value = false\n searchQuery.value = ''\n stopTracking()\n}\n\n// Programmatic toggle for parent row clicks.\n// Uses a skip flag to prevent the race with the document click handler:\n// when the row is clicked, the capture-phase listener fires first (closing the dropdown),\n// then the row handler calls toggle(). The flag lets us detect this and skip the re-open.\nlet skipNextOpen = false\nconst toggle = () => {\n if (props.disabled || props.loading) return\n if (skipNextOpen) {\n skipNextOpen = false\n return\n }\n toggleOpen()\n}\n\nconst closeFromOutside = () => {\n if (isOpen.value) skipNextOpen = true\n close()\n setTimeout(() => {\n skipNextOpen = false\n }, 0)\n}\n\nconst onDocumentClick = (e) => {\n // The panel is teleported to <body>, so clicks inside it are NOT inside the\n // container — check both before treating a click as \"outside\".\n if (containerRef.value?.contains(e.target)) return\n if (panelRef.value?.contains(e.target)) return\n closeFromOutside()\n}\n\nonMounted(() => document.addEventListener('click', onDocumentClick, true))\nonBeforeUnmount(() => {\n document.removeEventListener('click', onDocumentClick, true)\n stopTracking()\n})\n\ndefineExpose({ toggle, close, isOpen })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8KA,MAAM,QAAQ;EAkFd,MAAM,OAAO;EAEb,MAAM,eAAe,IAAI,IAAI;EAC7B,MAAM,aAAa,IAAI,IAAI;EAC3B,MAAM,YAAY,IAAI,IAAI;EAC1B,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,cAAc,IAAI,EAAE;EAC1B,MAAM,gBAAgB,IAAI,CAAC;EAC3B,MAAM,aAAa,IAAI,CAAC,CAAC;EAKzB,MAAM,mBAAmB;GACvB,MAAM,KAAK,WAAW;GACtB,IAAI,CAAC,IAAI;GACT,MAAM,OAAO,GAAG,sBAAsB;GACtC,MAAM,aAAa,OAAO,cAAc,KAAK;GAC7C,MAAM,SAAS,aAAa,OAAO,KAAK,MAAM;GAC9C,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3C,MAAM,IAAI;QAAM,OAAM;OAC/C,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,mBAOM,OAPN,aAOM,CANJ,mBAA2D,QAA3D,aAA2D,gBAAnB,IAAI,KAAK,GAAA,CAAA,GAEzC,IAAI,YADZ,UAAA,GAAA,mBAIC,QAJD,aAIC,gBADK,IAAI,QAAQ,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,CAAA,GAAA,IAAA,WAAA;;KApEpB,CAAA,GAAA,GAAA,EAAA,CAAA,CAAA,GAAA,CAAA,GAAA,CAAA,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"Select.js","names":[],"sources":["../../src/components/Select.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\" :class=\"!block ? 'inline-block' : ''\">\n <!-- Hidden sizer: measures the widest option label so the trigger never shrinks below it -->\n <div\n ref=\"sizerRef\"\n aria-hidden=\"true\"\n class=\"invisible absolute h-0 overflow-hidden pointer-events-none whitespace-nowrap\"\n :class=\"sizerTextClass\"\n >\n <span v-for=\"opt in normalizedOptions\" :key=\"opt.value\" class=\"block\">\n <span class=\"inline-flex items-center gap-2\">\n <span v-if=\"opt.icon\" class=\"w-4\" />\n {{ opt.label }}\n <!-- account for chevron + padding -->\n <span class=\"w-4\" />\n </span>\n </span>\n </div>\n\n <!-- Trigger button: shows selected value, placeholder, or loading spinner -->\n <button\n ref=\"triggerRef\"\n type=\"button\"\n :disabled=\"disabled || loading\"\n :aria-label=\"ariaLabel\"\n :class=\"[triggerClasses, disabled || loading ? 'opacity-50 cursor-not-allowed' : '']\"\n :style=\"autoMinWidth\"\n @click=\"toggleOpen\"\n >\n <span\n v-if=\"loading\"\n class=\"flex items-center gap-2 truncate text-gray-400 dark:text-gray-500\"\n >\n <UiIcon :name=\"spinner\" class=\"w-4 h-4 animate-spin shrink-0\" />\n <span>{{ loadingText }}</span>\n </span>\n <template v-else>\n <span\n class=\"flex items-center gap-2 truncate\"\n :class=\"selectedLabel ? '' : 'text-gray-400 dark:text-gray-500'\"\n >\n <UiIcon v-if=\"selectedIcon\" :name=\"selectedIcon\" class=\"w-4 h-4 shrink-0\" />\n {{ selectedLabel || placeholder || 'Select...' }}\n </span>\n </template>\n <UiIcon\n name=\"mdi:chevron-down\"\n class=\"w-4 h-4 shrink-0 text-gray-400 transition-transform\"\n :class=\"{ 'rotate-180': isOpen }\"\n />\n </button>\n\n <!-- Dropdown panel: teleported to <body> and fixed-positioned so it is never\n clipped by an ancestor with overflow (e.g. a scrollable modal body). -->\n <Teleport to=\"body\">\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-show=\"isOpen\"\n ref=\"panelRef\"\n class=\"fixed z-[60] overflow-hidden\"\n :class=\"MENU_PANEL_CLASS\"\n :style=\"panelStyle\"\n >\n <!-- Search input for filtering options -->\n <div v-if=\"searchable\" class=\"p-1.5\">\n <input\n ref=\"searchRef\"\n v-model=\"searchQuery\"\n type=\"text\"\n placeholder=\"Search...\"\n 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\"\n @keydown.escape=\"close\"\n @keydown.enter.prevent=\"selectFirst\"\n />\n </div>\n <!-- Options list: ungrouped flat list or grouped sections -->\n <ul class=\"max-h-64 overflow-y-auto py-1\">\n <li\n v-if=\"filteredOptions.length === 0 && filteredGroups.length === 0\"\n class=\"px-3 py-2 text-sm text-gray-400 dark:text-gray-500\"\n >\n No results\n </li>\n\n <!-- Ungrouped options -->\n <template v-if=\"filteredGroups.length === 0\">\n <li\n v-for=\"opt in filteredOptions\"\n :key=\"opt.value\"\n class=\"flex items-center gap-2 px-3 cursor-pointer transition-colors\"\n :class=\"[optionClass(opt.value), opt.subtitle ? 'py-1.5' : 'py-1.5']\"\n @click=\"select(opt.value)\"\n >\n <UiIcon v-if=\"opt.icon\" :name=\"opt.icon\" class=\"w-4 h-4 shrink-0\" />\n <div class=\"min-w-0\">\n <span class=\"block truncate text-sm\">{{ opt.label }}</span>\n <span\n v-if=\"opt.subtitle\"\n class=\"block truncate text-[11px] text-gray-400 dark:text-gray-500 leading-tight\"\n >{{ opt.subtitle }}</span\n >\n </div>\n </li>\n </template>\n\n <!-- Grouped options -->\n <template v-else>\n <template v-for=\"group in filteredGroups\" :key=\"group.label\">\n <li\n class=\"px-3 pt-2 pb-1 text-[11px] font-semibold uppercase tracking-wider text-gray-400 dark:text-gray-500 select-none\"\n >\n {{ group.label }}\n </li>\n <li\n v-for=\"opt in group.options\"\n :key=\"opt.value\"\n class=\"flex items-center gap-2 px-3 cursor-pointer transition-colors\"\n :class=\"[optionClass(opt.value), opt.subtitle ? 'py-1.5' : 'py-1.5']\"\n @click=\"select(opt.value)\"\n >\n <UiIcon v-if=\"opt.icon\" :name=\"opt.icon\" class=\"w-4 h-4 shrink-0\" />\n <div class=\"min-w-0\">\n <span class=\"block truncate text-sm\">{{ opt.label }}</span>\n <span\n v-if=\"opt.subtitle\"\n class=\"block truncate text-[11px] text-gray-400 dark:text-gray-500 leading-tight\"\n >{{ opt.subtitle }}</span\n >\n </div>\n </li>\n </template>\n </template>\n </ul>\n </div>\n </Transition>\n </Teleport>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSelect — Custom dropdown select component with search, grouping, icons, and loading state.\n *\n * Renders a styled trigger button that opens a dropdown panel with filterable options.\n * Supports flat option lists and grouped options (via `group` key on option objects).\n * Includes keyboard navigation (Escape to close, Enter to select first match),\n * automatic drop-up when near the bottom of the viewport, and a loading spinner state.\n *\n * @example Basic select\n * <UiSelect v-model=\"color\" :options=\"['Red', 'Green', 'Blue']\" placeholder=\"Pick a color\" />\n *\n * @example Searchable select with object options\n * <UiSelect v-model=\"lang\" :options=\"[{ value: 'en', label: 'English' }, { value: 'es', label: 'Spanish' }]\" searchable />\n *\n * @example Grouped options with icons\n * <UiSelect v-model=\"tool\" :options=\"[\n * { value: 'pen', label: 'Pen', icon: 'mdi:pen', group: 'Drawing' },\n * { value: 'eraser', label: 'Eraser', icon: 'mdi:eraser', group: 'Drawing' },\n * { value: 'text', label: 'Text', icon: 'mdi:format-text', group: 'Insert' },\n * ]\" searchable />\n *\n * @example Loading state\n * <UiSelect v-model=\"val\" :options=\"[]\" :loading=\"true\" loading-text=\"Fetching...\" />\n *\n * @emits {string | number | boolean} update:modelValue — Emitted when an option is selected\n */\nimport { ref, computed, watch, nextTick, onMounted, onBeforeUnmount } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { MENU_PANEL_CLASS } from '../internal/menu.js'\nconst props = defineProps({\n /**\n * Currently selected value (v-model).\n * @type {string | number | boolean | null}\n * @default ''\n */\n modelValue: { type: [String, Number, Boolean, null], default: '' },\n\n /**\n * Array of selectable options. Each item can be:\n * - A primitive (string/number) used as both value and label\n * - An object: `{ value, label, icon?, group? }`\n * @type {Array}\n * @default []\n */\n options: { type: Array, default: () => [] },\n\n /**\n * Placeholder text shown when no option is selected.\n * @type {string}\n * @default ''\n */\n placeholder: { type: String, default: '' },\n\n /**\n * Enable a search input inside the dropdown for filtering options.\n * @type {boolean}\n * @default false\n */\n searchable: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the trigger and prevents opening.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Trigger button size controlling padding and font.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Full-width mode — trigger stretches to fill its container.\n * @type {boolean}\n * @default true\n */\n block: { type: Boolean, default: true },\n\n /**\n * Accessible label for the trigger button.\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * Loading state — shows a spinner and disables interaction.\n * @type {boolean}\n * @default false\n */\n loading: { type: Boolean, default: false },\n\n /**\n * Text displayed next to the spinner during loading.\n * @type {string}\n * @default 'Loading...'\n */\n loadingText: { type: String, default: 'Loading...' },\n\n /**\n * MDI icon name for the loading spinner.\n * @type {string}\n * @default 'mdi:loading'\n */\n spinner: { type: String, default: 'mdi:loading' },\n})\n\nconst emit = defineEmits(['update:modelValue'])\n\nconst containerRef = ref(null)\nconst triggerRef = ref(null)\nconst searchRef = ref(null)\nconst sizerRef = ref(null)\nconst panelRef = ref(null)\nconst isOpen = ref(false)\nconst searchQuery = ref('')\nconst measuredWidth = ref(0)\nconst panelStyle = ref({})\n\n// Position the teleported panel under (or above) the trigger using fixed\n// coordinates so it overlays everything and is never clipped by a scrollable\n// ancestor. Re-run on scroll/resize while open so it stays anchored.\nconst reposition = () => {\n const el = triggerRef.value\n if (!el) return\n const rect = el.getBoundingClientRect()\n const spaceBelow = window.innerHeight - rect.bottom\n const openUp = spaceBelow < 260 && rect.top > spaceBelow\n // Inline transform-origin (not a Tailwind class) so the panel reliably scales\n // in from the edge nearest the trigger — top when dropping down, bottom when\n // dropping up — instead of drifting in from its centre.\n const style = {\n left: `${rect.left}px`,\n minWidth: `${rect.width}px`,\n transformOrigin: openUp ? 'bottom center' : 'top center',\n }\n if (props.block) style.width = `${rect.width}px`\n if (openUp) style.bottom = `${window.innerHeight - rect.top + 4}px`\n else style.top = `${rect.bottom + 4}px`\n panelStyle.value = style\n}\n\nconst startTracking = () => {\n window.addEventListener('scroll', reposition, true)\n window.addEventListener('resize', reposition)\n}\nconst stopTracking = () => {\n window.removeEventListener('scroll', reposition, true)\n window.removeEventListener('resize', reposition)\n}\n\n// Text class for the hidden sizer — must match the trigger's font size\nconst sizerTextClass = computed(() => {\n const map = { xs: 'text-xs', sm: 'text-sm', md: 'text-sm' }\n return map[props.size] || 'text-sm'\n})\n\n// Measure the widest option on mount and when options change\nconst measureSizer = () => {\n if (!sizerRef.value) {\n measuredWidth.value = 0\n return\n }\n measuredWidth.value = sizerRef.value.scrollWidth\n}\n\nonMounted(measureSizer)\nwatch(\n () => props.options,\n () => nextTick(measureSizer),\n { deep: true },\n)\n\n// Auto min-width style: ensures trigger never shrinks below the widest option\nconst autoMinWidth = computed(() => {\n if (!measuredWidth.value) return undefined\n // Add padding for the trigger's horizontal padding + border\n const padMap = { xs: 28, sm: 24, md: 30 }\n const pad = padMap[props.size] || 30\n return { minWidth: `${measuredWidth.value + pad}px` }\n})\n\n// ── Normalize options ────────────────────────────────────\n// Convert primitive options (string/number) into { value, label, subtitle, icon, group } objects\nconst normalizedOptions = computed(() =>\n props.options.map((opt) =>\n typeof opt === 'object' && opt !== null\n ? {\n value: opt.value,\n label: opt.label ?? String(opt.value),\n subtitle: opt.subtitle || '',\n icon: opt.icon || '',\n group: opt.group || '',\n }\n : { value: opt, label: String(opt), subtitle: '', icon: '', group: '' },\n ),\n)\n\n// ── Filtering ────────────────────────────────────────────\n// Apply search query filter against option labels (case-insensitive)\nconst filteredNormalized = computed(() => {\n if (!searchQuery.value) return normalizedOptions.value\n const q = searchQuery.value.toLowerCase()\n return normalizedOptions.value.filter(\n (opt) => opt.label.toLowerCase().includes(q) || opt.subtitle.toLowerCase().includes(q),\n )\n})\n\n// ── Grouping ─────────────────────────────────────────────\n// Detect if any option has a group key to enable grouped rendering\nconst hasGroups = computed(() => normalizedOptions.value.some((o) => o.group))\n\n// Build grouped structure: Map<groupLabel, { label, options[] }>\nconst filteredGroups = computed(() => {\n if (!hasGroups.value) return []\n const map = new Map()\n for (const opt of filteredNormalized.value) {\n const key = opt.group || ''\n if (!map.has(key)) map.set(key, { label: key, options: [] })\n map.get(key).options.push(opt)\n }\n return [...map.values()].filter((g) => g.options.length > 0)\n})\n\nconst filteredOptions = computed(() => {\n if (hasGroups.value) return []\n return filteredNormalized.value\n})\n\n// ── Selected display ─────────────────────────────────────\nconst selectedOpt = computed(() =>\n normalizedOptions.value.find((o) => o.value === props.modelValue),\n)\nconst selectedLabel = computed(() => selectedOpt.value?.label || '')\nconst selectedIcon = computed(() => selectedOpt.value?.icon || '')\n\n// ── Styling ──────────────────────────────────────────────\nconst triggerClasses = computed(() => {\n const base =\n 'flex items-center justify-between gap-2 text-left border bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-400 outline-none transition-colors focus:ring-2 focus:ring-primary-500 focus:border-primary-500'\n const width = props.block ? 'w-full' : ''\n const sizeMap = {\n xs: 'px-2.5 py-1.5 text-xs rounded-md border-gray-200 dark:border-gray-700',\n sm: 'px-2 py-1 text-sm rounded-lg border-gray-300 dark:border-gray-600',\n md: 'px-3 py-2 text-sm rounded-lg border-gray-300 dark:border-gray-700',\n }\n return `${base} ${width} ${sizeMap[props.size] || sizeMap.md}`\n})\n\nconst optionClass = (value) =>\n props.modelValue === value\n ? 'bg-primary-50 dark:bg-primary-900/20 text-primary-700 dark:text-primary-300'\n : 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700'\n\n// ── Interactions ─────────────────────────────────────────\n// Toggle dropdown open/close, auto-detect drop direction, and focus search input\nconst toggleOpen = () => {\n if (props.disabled || props.loading) return\n isOpen.value = !isOpen.value\n if (isOpen.value) {\n searchQuery.value = ''\n reposition()\n startTracking()\n nextTick(() => {\n reposition()\n if (props.searchable) searchRef.value?.focus()\n })\n } else {\n stopTracking()\n }\n}\n\nconst select = (value) => {\n emit('update:modelValue', value)\n close()\n}\n\nconst selectFirst = () => {\n const pool = hasGroups.value\n ? filteredGroups.value.flatMap((g) => g.options)\n : filteredOptions.value\n if (pool.length) select(pool[0].value)\n}\n\nconst close = () => {\n isOpen.value = false\n searchQuery.value = ''\n stopTracking()\n}\n\n// Programmatic toggle for parent row clicks.\n// Uses a skip flag to prevent the race with the document click handler:\n// when the row is clicked, the capture-phase listener fires first (closing the dropdown),\n// then the row handler calls toggle(). The flag lets us detect this and skip the re-open.\nlet skipNextOpen = false\nconst toggle = () => {\n if (props.disabled || props.loading) return\n if (skipNextOpen) {\n skipNextOpen = false\n return\n }\n toggleOpen()\n}\n\nconst closeFromOutside = () => {\n if (isOpen.value) skipNextOpen = true\n close()\n setTimeout(() => {\n skipNextOpen = false\n }, 0)\n}\n\nconst onDocumentClick = (e) => {\n // The panel is teleported to <body>, so clicks inside it are NOT inside the\n // container — check both before treating a click as \"outside\".\n if (containerRef.value?.contains(e.target)) return\n if (panelRef.value?.contains(e.target)) return\n closeFromOutside()\n}\n\nonMounted(() => document.addEventListener('click', onDocumentClick, true))\nonBeforeUnmount(() => {\n document.removeEventListener('click', onDocumentClick, true)\n stopTracking()\n})\n\ndefineExpose({ toggle, close, isOpen })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgLA,MAAM,QAAQ;EAkFd,MAAM,OAAO;EAEb,MAAM,eAAe,IAAI,IAAI;EAC7B,MAAM,aAAa,IAAI,IAAI;EAC3B,MAAM,YAAY,IAAI,IAAI;EAC1B,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,WAAW,IAAI,IAAI;EACzB,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,cAAc,IAAI,EAAE;EAC1B,MAAM,gBAAgB,IAAI,CAAC;EAC3B,MAAM,aAAa,IAAI,CAAC,CAAC;EAKzB,MAAM,mBAAmB;GACvB,MAAM,KAAK,WAAW;GACtB,IAAI,CAAC,IAAI;GACT,MAAM,OAAO,GAAG,sBAAsB;GACtC,MAAM,aAAa,OAAO,cAAc,KAAK;GAC7C,MAAM,SAAS,aAAa,OAAO,KAAK,MAAM;GAI9C,MAAM,QA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KAAK;OAEV,GAAA,CAAA,IAAI,QAAlB,UAAA,GAAA,YAAoE,aAAA;;QAA3C,MAAM,IAAI;QAAM,OAAM;OAC/C,GAAA,MAAA,GAAA,CAAA,MAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,GAAA,mBAOM,OAPN,aAOM,CANJ,mBAA2D,QAA3D,aAA2D,gBAAnB,IAAI,KAAK,GAAA,CAAA,GAEzC,IAAI,YADZ,UAAA,GAAA,mBAIC,QAJD,aAIC,gBADK,IAAI,QAAQ,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA,CAAA,GAAA,IAAA,WAAA;;KArEpB,CAAA,GAAA,GAAA,EAAA,CAAA,CAAA,GAAA,CAAA,GAAA,CAAA,CAAA,OAAA,OAAA,KAAM,CAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { computed, createBlock, normalizeClass, openBlock } from "vue";
|
|
3
|
+
//#region src/components/Spinner.vue
|
|
4
|
+
var _sfc_main = {
|
|
5
|
+
__name: "Spinner",
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Diameter of the spinner.
|
|
9
|
+
* @type {string}
|
|
10
|
+
* @default 'md'
|
|
11
|
+
* @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
12
|
+
*/
|
|
13
|
+
size: {
|
|
14
|
+
type: String,
|
|
15
|
+
default: "md"
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Accessible label. When set, the spinner is announced as a live status
|
|
19
|
+
* region; when omitted, it is hidden from assistive technology as decorative.
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @default ''
|
|
22
|
+
*/
|
|
23
|
+
label: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: ""
|
|
26
|
+
},
|
|
27
|
+
/**
|
|
28
|
+
* MDI icon to spin. The default is the same one `UiButton` uses; pass another
|
|
29
|
+
* (e.g. `'mdi:sync'`) for a different look.
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @default 'mdi:loading'
|
|
32
|
+
*/
|
|
33
|
+
icon: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "mdi:loading"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
setup(__props) {
|
|
39
|
+
/**
|
|
40
|
+
* UiSpinner — a spinning icon for loading and in-progress states.
|
|
41
|
+
*
|
|
42
|
+
* The same glyph `UiButton` shows while loading, pulled out as a standalone
|
|
43
|
+
* primitive so anything can signal work in progress without reaching for a
|
|
44
|
+
* button or hand-rolling `animate-spin`. Colour is inherited (`text-*`), exactly
|
|
45
|
+
* like `UiIcon`, so a spinner tints to match whatever surrounds it.
|
|
46
|
+
*
|
|
47
|
+
* By default it is decorative and hidden from assistive technology, which is
|
|
48
|
+
* right when a nearby label already says what is happening ("Saving…" next to
|
|
49
|
+
* it). Give it a `label` and it becomes a live `role="status"` region that
|
|
50
|
+
* announces on its own — use that when the spinner is the only thing on screen.
|
|
51
|
+
*
|
|
52
|
+
* @example Inline, decorative
|
|
53
|
+
* <UiSpinner />
|
|
54
|
+
*
|
|
55
|
+
* @example Larger, tinted, and self-announcing
|
|
56
|
+
* <UiSpinner size="lg" label="Syncing" class="text-primary-600 dark:text-primary-400" />
|
|
57
|
+
*/
|
|
58
|
+
const props = __props;
|
|
59
|
+
const SIZES = {
|
|
60
|
+
xs: "w-3 h-3",
|
|
61
|
+
sm: "w-3.5 h-3.5",
|
|
62
|
+
md: "w-5 h-5",
|
|
63
|
+
lg: "w-6 h-6",
|
|
64
|
+
xl: "w-8 h-8"
|
|
65
|
+
};
|
|
66
|
+
const sizeClass = computed(() => SIZES[props.size] || SIZES.md);
|
|
67
|
+
return (_ctx, _cache) => {
|
|
68
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
69
|
+
name: __props.icon,
|
|
70
|
+
class: normalizeClass(["animate-spin", sizeClass.value]),
|
|
71
|
+
"aria-hidden": __props.label ? void 0 : "true",
|
|
72
|
+
"aria-label": __props.label || void 0,
|
|
73
|
+
role: __props.label ? "status" : void 0
|
|
74
|
+
}, null, 8, [
|
|
75
|
+
"name",
|
|
76
|
+
"class",
|
|
77
|
+
"aria-hidden",
|
|
78
|
+
"aria-label",
|
|
79
|
+
"role"
|
|
80
|
+
]);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
//#endregion
|
|
85
|
+
export { _sfc_main as default };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=Spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Spinner.js","names":[],"sources":["../../src/components/Spinner.vue"],"sourcesContent":["<template>\n <UiIcon\n :name=\"icon\"\n class=\"animate-spin\"\n :class=\"sizeClass\"\n :aria-hidden=\"label ? undefined : 'true'\"\n :aria-label=\"label || undefined\"\n :role=\"label ? 'status' : undefined\"\n />\n</template>\n\n<script setup>\n/**\n * UiSpinner — a spinning icon for loading and in-progress states.\n *\n * The same glyph `UiButton` shows while loading, pulled out as a standalone\n * primitive so anything can signal work in progress without reaching for a\n * button or hand-rolling `animate-spin`. Colour is inherited (`text-*`), exactly\n * like `UiIcon`, so a spinner tints to match whatever surrounds it.\n *\n * By default it is decorative and hidden from assistive technology, which is\n * right when a nearby label already says what is happening (\"Saving…\" next to\n * it). Give it a `label` and it becomes a live `role=\"status\"` region that\n * announces on its own — use that when the spinner is the only thing on screen.\n *\n * @example Inline, decorative\n * <UiSpinner />\n *\n * @example Larger, tinted, and self-announcing\n * <UiSpinner size=\"lg\" label=\"Syncing\" class=\"text-primary-600 dark:text-primary-400\" />\n */\nimport { computed } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\n\nconst props = defineProps({\n /**\n * Diameter of the spinner.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Accessible label. When set, the spinner is announced as a live status\n * region; when omitted, it is hidden from assistive technology as decorative.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n\n /**\n * MDI icon to spin. The default is the same one `UiButton` uses; pass another\n * (e.g. `'mdi:sync'`) for a different look.\n * @type {string}\n * @default 'mdi:loading'\n */\n icon: { type: String, default: 'mdi:loading' },\n})\n\nconst SIZES = {\n xs: 'w-3 h-3',\n sm: 'w-3.5 h-3.5',\n md: 'w-5 h-5',\n lg: 'w-6 h-6',\n xl: 'w-8 h-8',\n}\n\nconst sizeClass = computed(() => SIZES[props.size] || SIZES.md)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCA,MAAM,QAAQ;EA0Bd,MAAM,QAAQ;GACZ,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EAEA,MAAM,YAAY,eAAe,MAAM,MAAM,SAAS,MAAM,EAAE;;GAnE5D,OAAA,UAAA,GAAA,YAOE,aAAA;IANC,MAAM,QAAA;IACP,OAAK,eAAA,CAAC,gBACE,UAAA,KAAS,CAAA;IAChB,eAAa,QAAA,QAAQ,KAAA,IAAS;IAC9B,cAAY,QAAA,SAAS,KAAA;IACrB,MAAM,QAAA,QAAK,WAAc,KAAA"}
|