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.
- package/CHANGELOG.md +148 -0
- package/README.md +36 -34
- package/dist/components/AppShell.js +234 -0
- package/dist/components/AppShell.js.map +1 -0
- package/dist/components/Banner.js +29 -32
- package/dist/components/Banner.js.map +1 -1
- package/dist/components/Button.js +10 -19
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Card.js +15 -9
- package/dist/components/Card.js.map +1 -1
- package/dist/components/Checkbox.js +13 -9
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/CopyField.js +195 -0
- package/dist/components/CopyField.js.map +1 -0
- package/dist/components/DescriptionList.js +116 -0
- package/dist/components/DescriptionList.js.map +1 -0
- package/dist/components/Dropdown.js +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/EmptyState.js +123 -0
- package/dist/components/EmptyState.js.map +1 -0
- package/dist/components/FileInput.js +12 -4
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/FormField.js +43 -13
- package/dist/components/FormField.js.map +1 -1
- package/dist/components/IconTile.js +5 -9
- package/dist/components/IconTile.js.map +1 -1
- package/dist/components/Input.js +21 -7
- 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/PageHeader.js +106 -0
- package/dist/components/PageHeader.js.map +1 -0
- package/dist/components/Pagination.js +236 -0
- package/dist/components/Pagination.js.map +1 -0
- package/dist/components/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 +109 -27
- package/dist/components/Segmented.js.map +1 -1
- package/dist/components/Select.js +16 -5
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Sidebar.js +69 -0
- package/dist/components/Sidebar.js.map +1 -0
- package/dist/components/SidebarGroup.js +50 -0
- package/dist/components/SidebarGroup.js.map +1 -0
- package/dist/components/SidebarItem.js +167 -0
- package/dist/components/SidebarItem.js.map +1 -0
- package/dist/components/StatCard.js +185 -0
- package/dist/components/StatCard.js.map +1 -0
- package/dist/components/Table.js +306 -0
- package/dist/components/Table.js.map +1 -0
- package/dist/components/Tabs.js +216 -0
- package/dist/components/Tabs.js.map +1 -0
- package/dist/components/Toggle.js +11 -2
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/index.js +91 -76
- 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 +11 -0
- package/dist/icons/mdi.js.map +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/index.js +47 -37
- 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/formField.js +26 -0
- package/dist/internal/formField.js.map +1 -0
- package/dist/internal/menu.js +20 -0
- package/dist/internal/menu.js.map +1 -0
- package/dist/manifest.js +12 -2
- package/dist/manifest.js.map +1 -1
- package/package.json +2 -1
- package/src/components/AppShell.vue +231 -0
- package/src/components/Banner.vue +20 -9
- package/src/components/Button.vue +12 -19
- package/src/components/Card.vue +11 -12
- package/src/components/Checkbox.vue +7 -10
- package/src/components/CopyField.vue +178 -0
- package/src/components/DescriptionList.vue +114 -0
- package/src/components/Dropdown.vue +14 -2
- package/src/components/DropdownSubmenu.vue +4 -2
- package/src/components/EmptyState.vue +107 -0
- package/src/components/FileInput.vue +19 -4
- package/src/components/FormField.vue +37 -4
- package/src/components/IconTile.vue +4 -9
- package/src/components/Input.vue +15 -6
- package/src/components/ListMenuItem.vue +21 -5
- package/src/components/Numpad.vue +7 -4
- package/src/components/PageHeader.vue +102 -0
- package/src/components/Pagination.vue +199 -0
- package/src/components/Popup.vue +6 -2
- package/src/components/Radio.vue +2 -10
- package/src/components/Segmented.vue +113 -38
- package/src/components/Select.vue +16 -2
- package/src/components/Sidebar.vue +61 -0
- package/src/components/SidebarGroup.vue +43 -0
- package/src/components/SidebarItem.vue +159 -0
- package/src/components/StatCard.vue +165 -0
- package/src/components/Table.vue +323 -0
- package/src/components/Tabs.vue +217 -0
- package/src/components/Toggle.vue +5 -0
- package/src/components/index.js +36 -11
- package/src/composables/useMergedClasses.js +49 -0
- package/src/icons/mdi.js +11 -0
- package/src/internal/controlSizes.js +17 -0
- package/src/internal/formField.js +23 -0
- package/src/internal/menu.js +16 -0
- package/src/manifest.js +12 -2
- package/dist/components/ButtonsGroup.js +0 -153
- package/dist/components/ButtonsGroup.js.map +0 -1
- package/dist/components/ComparisonTable.js +0 -152
- package/dist/components/ComparisonTable.js.map +0 -1
- package/src/components/ButtonsGroup.vue +0 -140
- package/src/components/ComparisonTable.vue +0 -141
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
-
import {
|
|
2
|
+
import { useFormField } from "../internal/formField.js";
|
|
3
|
+
import { MENU_PANEL_CLASS } from "../internal/menu.js";
|
|
4
|
+
import { Fragment, Teleport, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, toDisplayString, unref, vModelText, vShow, watch, withCtx, withDirectives, withKeys, withModifiers } from "vue";
|
|
3
5
|
//#region src/components/Select.vue
|
|
4
6
|
var _hoisted_1 = { class: "inline-flex items-center gap-2" };
|
|
5
7
|
var _hoisted_2 = {
|
|
6
8
|
key: 0,
|
|
7
9
|
class: "w-4"
|
|
8
10
|
};
|
|
9
|
-
var _hoisted_3 = [
|
|
11
|
+
var _hoisted_3 = [
|
|
12
|
+
"id",
|
|
13
|
+
"aria-describedby",
|
|
14
|
+
"disabled",
|
|
15
|
+
"aria-label"
|
|
16
|
+
];
|
|
10
17
|
var _hoisted_4 = {
|
|
11
18
|
key: 0,
|
|
12
19
|
class: "flex items-center gap-2 truncate text-gray-400 dark:text-gray-500"
|
|
@@ -177,6 +184,7 @@ var _sfc_main = {
|
|
|
177
184
|
*/
|
|
178
185
|
const props = __props;
|
|
179
186
|
const emit = __emit;
|
|
187
|
+
const field = useFormField();
|
|
180
188
|
const containerRef = ref(null);
|
|
181
189
|
const triggerRef = ref(null);
|
|
182
190
|
const searchRef = ref(null);
|
|
@@ -194,7 +202,8 @@ var _sfc_main = {
|
|
|
194
202
|
const openUp = spaceBelow < 260 && rect.top > spaceBelow;
|
|
195
203
|
const style = {
|
|
196
204
|
left: `${rect.left}px`,
|
|
197
|
-
minWidth: `${rect.width}px
|
|
205
|
+
minWidth: `${rect.width}px`,
|
|
206
|
+
transformOrigin: openUp ? "bottom center" : "top center"
|
|
198
207
|
};
|
|
199
208
|
if (props.block) style.width = `${rect.width}px`;
|
|
200
209
|
if (openUp) style.bottom = `${window.innerHeight - rect.top + 4}px`;
|
|
@@ -363,9 +372,11 @@ var _sfc_main = {
|
|
|
363
372
|
])]);
|
|
364
373
|
}), 128))], 2),
|
|
365
374
|
createElementVNode("button", {
|
|
375
|
+
id: unref(field)?.controlId.value,
|
|
366
376
|
ref_key: "triggerRef",
|
|
367
377
|
ref: triggerRef,
|
|
368
378
|
type: "button",
|
|
379
|
+
"aria-describedby": unref(field)?.describedBy.value,
|
|
369
380
|
disabled: __props.disabled || __props.loading,
|
|
370
381
|
"aria-label": __props.ariaLabel,
|
|
371
382
|
class: normalizeClass([triggerClasses.value, __props.disabled || __props.loading ? "opacity-50 cursor-not-allowed" : ""]),
|
|
@@ -396,7 +407,7 @@ var _sfc_main = {
|
|
|
396
407
|
default: withCtx(() => [withDirectives(createElementVNode("div", {
|
|
397
408
|
ref_key: "panelRef",
|
|
398
409
|
ref: panelRef,
|
|
399
|
-
class: "fixed z-[60]
|
|
410
|
+
class: normalizeClass(["fixed z-[60] overflow-hidden", unref(MENU_PANEL_CLASS)]),
|
|
400
411
|
style: normalizeStyle(panelStyle.value)
|
|
401
412
|
}, [__props.searchable ? (openBlock(), createElementBlock("div", _hoisted_5, [withDirectives(createElementVNode("input", {
|
|
402
413
|
ref_key: "searchRef",
|
|
@@ -428,7 +439,7 @@ var _sfc_main = {
|
|
|
428
439
|
class: "w-4 h-4 shrink-0"
|
|
429
440
|
}, 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
441
|
}), 128))], 64);
|
|
431
|
-
}), 128))])],
|
|
442
|
+
}), 128))])], 6), [[vShow, isOpen.value]])]),
|
|
432
443
|
_: 1
|
|
433
444
|
})]))
|
|
434
445
|
], 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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,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;;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 :id=\"field?.controlId.value\"\n ref=\"triggerRef\"\n type=\"button\"\n :aria-describedby=\"field?.describedBy.value\"\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'\nimport { useFormField } from '../internal/formField.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 field = useFormField()\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmLA,MAAM,QAAQ;EAkFd,MAAM,OAAO;EAEb,MAAM,QAAQ,aAAa;EAE3B,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,M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B,UAAA,IAAA,GAAA,mBAgBK,UAAA,MAAA,WAfW,MAAM,UAAb,QAAG;OADZ,OAAA,UAAA,GAAA,mBAgBK,MAAA;QAdF,KAAK,IAAI;QACV,OAAK,eAAA,CAAC,iEAA+D,CAC5D,YAAY,IAAI,KAAK,GAAG,IAAI,WAAQ,WAAA,QAAA,CAAA,CAAA;QAC5C,UAAK,WAAE,OAAO,IAAI,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,69 @@
|
|
|
1
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
2
|
+
import { createCommentVNode, createElementBlock, createElementVNode, mergeProps, openBlock, renderSlot, unref } from "vue";
|
|
3
|
+
//#region src/components/Sidebar.vue
|
|
4
|
+
var _hoisted_1 = ["aria-label"];
|
|
5
|
+
var _hoisted_2 = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "flex h-14 shrink-0 items-center gap-2 border-b border-gray-200 px-4 dark:border-gray-800"
|
|
8
|
+
};
|
|
9
|
+
var _hoisted_3 = { class: "min-h-0 flex-1 space-y-0.5 overflow-y-auto px-3 py-4" };
|
|
10
|
+
var _hoisted_4 = {
|
|
11
|
+
key: 1,
|
|
12
|
+
class: "shrink-0 border-t border-gray-200 p-3 dark:border-gray-800"
|
|
13
|
+
};
|
|
14
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
15
|
+
__name: "Sidebar",
|
|
16
|
+
props: {
|
|
17
|
+
/**
|
|
18
|
+
* Accessible name of the navigation landmark.
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @default 'Main'
|
|
21
|
+
*/
|
|
22
|
+
label: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: "Main"
|
|
25
|
+
} },
|
|
26
|
+
setup(__props) {
|
|
27
|
+
/**
|
|
28
|
+
* UiSidebar — vertical navigation for an application, with a brand header,
|
|
29
|
+
* a scrolling list of items and a pinned footer.
|
|
30
|
+
*
|
|
31
|
+
* Fills the height of its container, so it is usually placed in
|
|
32
|
+
* `UiAppShell`'s `#sidebar` slot, which handles the pinned / off-canvas
|
|
33
|
+
* behaviour. Fill it with `UiSidebarItem`s, grouped under headings with
|
|
34
|
+
* `UiSidebarGroup` when the list grows.
|
|
35
|
+
*
|
|
36
|
+
* Renders a `<nav>` landmark; give each one on a page a distinct `label`.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* <UiSidebar label="Main">
|
|
40
|
+
* <template #header><strong>Numori CRDT</strong></template>
|
|
41
|
+
* <UiSidebarItem icon="mdi:view-grid" href="/" active>Dashboard</UiSidebarItem>
|
|
42
|
+
* <UiSidebarGroup label="Manage">
|
|
43
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
44
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users">Users</UiSidebarItem>
|
|
45
|
+
* </UiSidebarGroup>
|
|
46
|
+
* <template #footer>Signed in as ada</template>
|
|
47
|
+
* </UiSidebar>
|
|
48
|
+
*
|
|
49
|
+
* @slot default — Navigation items and groups.
|
|
50
|
+
* @slot header — Brand area at the top, the same height as the shell's top bar.
|
|
51
|
+
* @slot footer — Pinned content at the bottom (account, version, etc.).
|
|
52
|
+
*/
|
|
53
|
+
const { mergedClasses, restAttrs } = useMergedClasses("flex h-full min-h-0 w-full flex-col");
|
|
54
|
+
return (_ctx, _cache) => {
|
|
55
|
+
return openBlock(), createElementBlock("nav", mergeProps({
|
|
56
|
+
"aria-label": __props.label,
|
|
57
|
+
class: unref(mergedClasses)
|
|
58
|
+
}, unref(restAttrs)), [
|
|
59
|
+
_ctx.$slots.header ? (openBlock(), createElementBlock("div", _hoisted_2, [renderSlot(_ctx.$slots, "header")])) : createCommentVNode("", true),
|
|
60
|
+
createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "default")]),
|
|
61
|
+
_ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_4, [renderSlot(_ctx.$slots, "footer")])) : createCommentVNode("", true)
|
|
62
|
+
], 16, _hoisted_1);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
//#endregion
|
|
67
|
+
export { _sfc_main as default };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=Sidebar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sidebar.js","names":["$slots"],"sources":["../../src/components/Sidebar.vue"],"sourcesContent":["<template>\n <nav :aria-label=\"label\" :class=\"mergedClasses\" v-bind=\"restAttrs\">\n <div\n v-if=\"$slots.header\"\n class=\"flex h-14 shrink-0 items-center gap-2 border-b border-gray-200 px-4 dark:border-gray-800\"\n >\n <slot name=\"header\" />\n </div>\n\n <div class=\"min-h-0 flex-1 space-y-0.5 overflow-y-auto px-3 py-4\">\n <slot />\n </div>\n\n <div v-if=\"$slots.footer\" class=\"shrink-0 border-t border-gray-200 p-3 dark:border-gray-800\">\n <slot name=\"footer\" />\n </div>\n </nav>\n</template>\n\n<script setup>\n/**\n * UiSidebar — vertical navigation for an application, with a brand header,\n * a scrolling list of items and a pinned footer.\n *\n * Fills the height of its container, so it is usually placed in\n * `UiAppShell`'s `#sidebar` slot, which handles the pinned / off-canvas\n * behaviour. Fill it with `UiSidebarItem`s, grouped under headings with\n * `UiSidebarGroup` when the list grows.\n *\n * Renders a `<nav>` landmark; give each one on a page a distinct `label`.\n *\n * @example\n * <UiSidebar label=\"Main\">\n * <template #header><strong>Numori CRDT</strong></template>\n * <UiSidebarItem icon=\"mdi:view-grid\" href=\"/\" active>Dashboard</UiSidebarItem>\n * <UiSidebarGroup label=\"Manage\">\n * <UiSidebarItem icon=\"mdi:sync\" href=\"/apps\">Apps</UiSidebarItem>\n * <UiSidebarItem icon=\"mdi:account-group\" href=\"/users\">Users</UiSidebarItem>\n * </UiSidebarGroup>\n * <template #footer>Signed in as ada</template>\n * </UiSidebar>\n *\n * @slot default — Navigation items and groups.\n * @slot header — Brand area at the top, the same height as the shell's top bar.\n * @slot footer — Pinned content at the bottom (account, version, etc.).\n */\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\ndefineProps({\n /**\n * Accessible name of the navigation landmark.\n * @type {string}\n * @default 'Main'\n */\n label: { type: String, default: 'Main' },\n})\n\ndefineOptions({ inheritAttrs: false })\n\nconst { mergedClasses, restAttrs } = useMergedClasses('flex h-full min-h-0 w-full flex-col')\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2DA,MAAM,EAAE,eAAe,cAAc,iBAAiB,qCAAqC;;GA1DzF,OAAA,UAAA,GAAA,mBAeM,OAfN,WAeM;IAfA,cAAY,QAAA;IAAQ,OAAO,MAAA,aAAA;GAAuB,GAAA,MAAA,SAAA,CAAS,GAAA;IAEvDA,KAAAA,OAAO,UADf,UAAA,GAAA,mBAKM,OALN,YAKM,CADJ,WAAsB,KAAA,QAAA,QAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA;IAGxB,mBAEM,OAFN,YAEM,CADJ,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA;IAGCA,KAAAA,OAAO,UAAlB,UAAA,GAAA,mBAEM,OAFN,YAEM,CADJ,WAAsB,KAAA,QAAA,QAAA,CAAA,CAAA,KAAA,mBAAA,IAAA,IAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createCommentVNode, createElementBlock, createElementVNode, openBlock, renderSlot, toDisplayString, unref, useId } from "vue";
|
|
2
|
+
//#region src/components/SidebarGroup.vue
|
|
3
|
+
var _hoisted_1 = ["aria-labelledby"];
|
|
4
|
+
var _hoisted_2 = ["id"];
|
|
5
|
+
var _hoisted_3 = { class: "space-y-0.5" };
|
|
6
|
+
var _sfc_main = {
|
|
7
|
+
__name: "SidebarGroup",
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Heading shown above the items.
|
|
11
|
+
* @type {string}
|
|
12
|
+
* @default ''
|
|
13
|
+
*/
|
|
14
|
+
label: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: ""
|
|
17
|
+
} },
|
|
18
|
+
setup(__props) {
|
|
19
|
+
/**
|
|
20
|
+
* UiSidebarGroup — a labelled section of a `UiSidebar`.
|
|
21
|
+
*
|
|
22
|
+
* Groups related `UiSidebarItem`s under a small uppercase heading, which is
|
|
23
|
+
* also the group's accessible name.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <UiSidebarGroup label="Manage">
|
|
27
|
+
* <UiSidebarItem icon="mdi:sync" href="/apps">Apps</UiSidebarItem>
|
|
28
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users">Users</UiSidebarItem>
|
|
29
|
+
* </UiSidebarGroup>
|
|
30
|
+
*
|
|
31
|
+
* @slot default — The group's items.
|
|
32
|
+
*/
|
|
33
|
+
const headingId = useId();
|
|
34
|
+
return (_ctx, _cache) => {
|
|
35
|
+
return openBlock(), createElementBlock("div", {
|
|
36
|
+
role: "group",
|
|
37
|
+
"aria-labelledby": __props.label ? unref(headingId) : void 0,
|
|
38
|
+
class: "pt-5 first:pt-0"
|
|
39
|
+
}, [__props.label ? (openBlock(), createElementBlock("p", {
|
|
40
|
+
key: 0,
|
|
41
|
+
id: unref(headingId),
|
|
42
|
+
class: "px-3 pb-1.5 text-xs font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500"
|
|
43
|
+
}, toDisplayString(__props.label), 9, _hoisted_2)) : createCommentVNode("", true), createElementVNode("div", _hoisted_3, [renderSlot(_ctx.$slots, "default")])], 8, _hoisted_1);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { _sfc_main as default };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=SidebarGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarGroup.js","names":[],"sources":["../../src/components/SidebarGroup.vue"],"sourcesContent":["<template>\n <div role=\"group\" :aria-labelledby=\"label ? headingId : undefined\" class=\"pt-5 first:pt-0\">\n <p\n v-if=\"label\"\n :id=\"headingId\"\n class=\"px-3 pb-1.5 text-xs font-semibold tracking-wide text-gray-400 uppercase dark:text-gray-500\"\n >\n {{ label }}\n </p>\n <div class=\"space-y-0.5\">\n <slot />\n </div>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSidebarGroup — a labelled section of a `UiSidebar`.\n *\n * Groups related `UiSidebarItem`s under a small uppercase heading, which is\n * also the group's accessible name.\n *\n * @example\n * <UiSidebarGroup label=\"Manage\">\n * <UiSidebarItem icon=\"mdi:sync\" href=\"/apps\">Apps</UiSidebarItem>\n * <UiSidebarItem icon=\"mdi:account-group\" href=\"/users\">Users</UiSidebarItem>\n * </UiSidebarGroup>\n *\n * @slot default — The group's items.\n */\nimport { useId } from 'vue'\n\ndefineProps({\n /**\n * Heading shown above the items.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n})\n\nconst headingId = useId()\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,YAAY,MAAM;;GAxCtB,OAAA,UAAA,GAAA,mBAWM,OAAA;IAXD,MAAK;IAAS,mBAAiB,QAAA,QAAQ,MAAA,SAAA,IAAY,KAAA;IAAW,OAAM;GAE/D,GAAA,CAAA,QAAA,SADR,UAAA,GAAA,mBAMI,KAAA;;IAJD,IAAI,MAAA,SAAA;IACL,OAAM;GAEH,GAAA,gBAAA,QAAA,KAAK,GAAA,GAAA,UAAA,KAAA,mBAAA,IAAA,IAAA,GAEV,mBAEM,OAFN,YAEM,CADJ,WAAQ,KAAA,QAAA,SAAA,CAAA,CAAA,CAAA,GAAA,GAAA,UAAA"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import { useMergedClasses } from "../composables/useMergedClasses.js";
|
|
3
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, inject, mergeProps, normalizeClass, openBlock, renderSlot, resolveDynamicComponent, toDisplayString, unref, withCtx } from "vue";
|
|
4
|
+
//#region src/components/SidebarItem.vue
|
|
5
|
+
var _hoisted_1 = { class: "min-w-0 flex-1 truncate" };
|
|
6
|
+
var _sfc_main = /*@__PURE__*/ Object.assign({ inheritAttrs: false }, {
|
|
7
|
+
__name: "SidebarItem",
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Element or component to render. Defaults to `RouterLink` when `to` is
|
|
11
|
+
* set, `a` when `href` is set, and `button` otherwise.
|
|
12
|
+
* @type {string}
|
|
13
|
+
* @default ''
|
|
14
|
+
*/
|
|
15
|
+
tag: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* Router location, passed to the link component.
|
|
21
|
+
* @type {string | object}
|
|
22
|
+
* @default undefined
|
|
23
|
+
*/
|
|
24
|
+
to: {
|
|
25
|
+
type: [String, Object],
|
|
26
|
+
default: void 0
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Plain link target.
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @default ''
|
|
32
|
+
*/
|
|
33
|
+
href: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: ""
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* MDI icon shown before the label.
|
|
39
|
+
* @type {string}
|
|
40
|
+
* @default ''
|
|
41
|
+
*/
|
|
42
|
+
icon: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ""
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Mark as the current page.
|
|
48
|
+
* @type {boolean}
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
active: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Count or short label shown at the end of the row. Empty hides it.
|
|
57
|
+
* @type {string | number}
|
|
58
|
+
* @default ''
|
|
59
|
+
*/
|
|
60
|
+
badge: {
|
|
61
|
+
type: [String, Number],
|
|
62
|
+
default: ""
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Dim the item and ignore clicks.
|
|
66
|
+
* @type {boolean}
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
69
|
+
disabled: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: false
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
emits: ["click"],
|
|
75
|
+
setup(__props, { emit: __emit }) {
|
|
76
|
+
/**
|
|
77
|
+
* UiSidebarItem — one navigation entry in a `UiSidebar`.
|
|
78
|
+
*
|
|
79
|
+
* Router-agnostic. Pass `to` to render through a globally registered
|
|
80
|
+
* `RouterLink` (or set `tag="NuxtLink"`), `href` for a plain anchor, or neither
|
|
81
|
+
* for a `<button>` that only emits `click`. The current page is marked with
|
|
82
|
+
* `active`, which also sets `aria-current="page"` — the item does not inspect
|
|
83
|
+
* the route itself, so any router (or none) works.
|
|
84
|
+
*
|
|
85
|
+
* Choosing an item inside a `UiAppShell` closes the shell's mobile drawer.
|
|
86
|
+
*
|
|
87
|
+
* @example With vue-router
|
|
88
|
+
* <UiSidebarItem icon="mdi:sync" to="/apps" :active="route.path.startsWith('/apps')">
|
|
89
|
+
* Apps
|
|
90
|
+
* </UiSidebarItem>
|
|
91
|
+
*
|
|
92
|
+
* @example With a count badge
|
|
93
|
+
* <UiSidebarItem icon="mdi:account-group" href="/users" :badge="3">Users</UiSidebarItem>
|
|
94
|
+
*
|
|
95
|
+
* @emits {MouseEvent} click — The item was chosen (not emitted while disabled).
|
|
96
|
+
*
|
|
97
|
+
* @slot default — Label.
|
|
98
|
+
* @slot suffix — Trailing content, replacing the badge.
|
|
99
|
+
*/
|
|
100
|
+
const props = __props;
|
|
101
|
+
const emit = __emit;
|
|
102
|
+
const shell = inject("numori-ui:app-shell", null);
|
|
103
|
+
const resolvedTag = computed(() => {
|
|
104
|
+
if (props.tag) return props.tag;
|
|
105
|
+
if (props.to !== void 0) return "RouterLink";
|
|
106
|
+
if (props.href) return "a";
|
|
107
|
+
return "button";
|
|
108
|
+
});
|
|
109
|
+
const linkAttrs = computed(() => {
|
|
110
|
+
if (resolvedTag.value === "button") return {
|
|
111
|
+
type: "button",
|
|
112
|
+
disabled: props.disabled
|
|
113
|
+
};
|
|
114
|
+
if (resolvedTag.value === "a") return { href: props.disabled ? void 0 : props.href };
|
|
115
|
+
return { to: props.to };
|
|
116
|
+
});
|
|
117
|
+
const hasBadge = computed(() => props.badge !== "" && props.badge !== null);
|
|
118
|
+
function onClick(event) {
|
|
119
|
+
if (props.disabled) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
emit("click", event);
|
|
124
|
+
shell?.close();
|
|
125
|
+
}
|
|
126
|
+
const internalClasses = computed(() => [
|
|
127
|
+
"group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors",
|
|
128
|
+
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:focus-visible:outline-primary-400",
|
|
129
|
+
props.active ? "bg-primary-50 text-primary-700 dark:bg-primary-400/10 dark:text-primary-200" : "text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100",
|
|
130
|
+
props.disabled ? "pointer-events-none opacity-40" : "cursor-pointer"
|
|
131
|
+
].join(" "));
|
|
132
|
+
const { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value);
|
|
133
|
+
return (_ctx, _cache) => {
|
|
134
|
+
return openBlock(), createBlock(resolveDynamicComponent(resolvedTag.value), mergeProps({
|
|
135
|
+
...linkAttrs.value,
|
|
136
|
+
...unref(restAttrs)
|
|
137
|
+
}, {
|
|
138
|
+
class: unref(mergedClasses),
|
|
139
|
+
"aria-current": __props.active ? "page" : void 0,
|
|
140
|
+
"aria-disabled": __props.disabled ? "true" : void 0,
|
|
141
|
+
onClick
|
|
142
|
+
}), {
|
|
143
|
+
default: withCtx(() => [
|
|
144
|
+
__props.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
145
|
+
key: 0,
|
|
146
|
+
name: __props.icon,
|
|
147
|
+
class: normalizeClass(["size-[18px] shrink-0", __props.active ? "text-primary-600 dark:text-primary-400" : "text-gray-400 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300"])
|
|
148
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true),
|
|
149
|
+
createElementVNode("span", _hoisted_1, [renderSlot(_ctx.$slots, "default")]),
|
|
150
|
+
renderSlot(_ctx.$slots, "suffix", {}, () => [hasBadge.value ? (openBlock(), createElementBlock("span", {
|
|
151
|
+
key: 0,
|
|
152
|
+
class: normalizeClass(["ml-auto inline-flex min-w-5 items-center justify-center rounded-full px-1.5 text-xs font-semibold tabular-nums", __props.active ? "bg-primary-100 text-primary-700 dark:bg-primary-400/20 dark:text-primary-200" : "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300"])
|
|
153
|
+
}, toDisplayString(__props.badge), 3)) : createCommentVNode("", true)])
|
|
154
|
+
]),
|
|
155
|
+
_: 3
|
|
156
|
+
}, 16, [
|
|
157
|
+
"class",
|
|
158
|
+
"aria-current",
|
|
159
|
+
"aria-disabled"
|
|
160
|
+
]);
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
//#endregion
|
|
165
|
+
export { _sfc_main as default };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=SidebarItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidebarItem.js","names":[],"sources":["../../src/components/SidebarItem.vue"],"sourcesContent":["<template>\n <component\n :is=\"resolvedTag\"\n v-bind=\"{ ...linkAttrs, ...restAttrs }\"\n :class=\"mergedClasses\"\n :aria-current=\"active ? 'page' : undefined\"\n :aria-disabled=\"disabled ? 'true' : undefined\"\n @click=\"onClick\"\n >\n <UiIcon\n v-if=\"icon\"\n :name=\"icon\"\n class=\"size-[18px] shrink-0\"\n :class=\"\n active\n ? 'text-primary-600 dark:text-primary-400'\n : 'text-gray-400 group-hover:text-gray-600 dark:text-gray-500 dark:group-hover:text-gray-300'\n \"\n />\n <span class=\"min-w-0 flex-1 truncate\"><slot /></span>\n <slot name=\"suffix\">\n <span\n v-if=\"hasBadge\"\n class=\"ml-auto inline-flex min-w-5 items-center justify-center rounded-full px-1.5 text-xs font-semibold tabular-nums\"\n :class=\"\n active\n ? 'bg-primary-100 text-primary-700 dark:bg-primary-400/20 dark:text-primary-200'\n : 'bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-300'\n \"\n >{{ badge }}</span\n >\n </slot>\n </component>\n</template>\n\n<script setup>\n/**\n * UiSidebarItem — one navigation entry in a `UiSidebar`.\n *\n * Router-agnostic. Pass `to` to render through a globally registered\n * `RouterLink` (or set `tag=\"NuxtLink\"`), `href` for a plain anchor, or neither\n * for a `<button>` that only emits `click`. The current page is marked with\n * `active`, which also sets `aria-current=\"page\"` — the item does not inspect\n * the route itself, so any router (or none) works.\n *\n * Choosing an item inside a `UiAppShell` closes the shell's mobile drawer.\n *\n * @example With vue-router\n * <UiSidebarItem icon=\"mdi:sync\" to=\"/apps\" :active=\"route.path.startsWith('/apps')\">\n * Apps\n * </UiSidebarItem>\n *\n * @example With a count badge\n * <UiSidebarItem icon=\"mdi:account-group\" href=\"/users\" :badge=\"3\">Users</UiSidebarItem>\n *\n * @emits {MouseEvent} click — The item was chosen (not emitted while disabled).\n *\n * @slot default — Label.\n * @slot suffix — Trailing content, replacing the badge.\n */\nimport { computed, inject } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { useMergedClasses } from '../composables/useMergedClasses.js'\n\nconst props = defineProps({\n /**\n * Element or component to render. Defaults to `RouterLink` when `to` is\n * set, `a` when `href` is set, and `button` otherwise.\n * @type {string}\n * @default ''\n */\n tag: { type: String, default: '' },\n\n /**\n * Router location, passed to the link component.\n * @type {string | object}\n * @default undefined\n */\n to: { type: [String, Object], default: undefined },\n\n /**\n * Plain link target.\n * @type {string}\n * @default ''\n */\n href: { type: String, default: '' },\n\n /**\n * MDI icon shown before the label.\n * @type {string}\n * @default ''\n */\n icon: { type: String, default: '' },\n\n /**\n * Mark as the current page.\n * @type {boolean}\n * @default false\n */\n active: { type: Boolean, default: false },\n\n /**\n * Count or short label shown at the end of the row. Empty hides it.\n * @type {string | number}\n * @default ''\n */\n badge: { type: [String, Number], default: '' },\n\n /**\n * Dim the item and ignore clicks.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n})\n\nconst emit = defineEmits(['click'])\n\ndefineOptions({ inheritAttrs: false })\n\nconst shell = inject('numori-ui:app-shell', null)\n\nconst resolvedTag = computed(() => {\n if (props.tag) return props.tag\n if (props.to !== undefined) return 'RouterLink'\n if (props.href) return 'a'\n return 'button'\n})\n\nconst linkAttrs = computed(() => {\n if (resolvedTag.value === 'button') return { type: 'button', disabled: props.disabled }\n if (resolvedTag.value === 'a') return { href: props.disabled ? undefined : props.href }\n return { to: props.to }\n})\n\nconst hasBadge = computed(() => props.badge !== '' && props.badge !== null)\n\nfunction onClick(event) {\n if (props.disabled) {\n event.preventDefault()\n return\n }\n emit('click', event)\n shell?.close()\n}\n\nconst internalClasses = computed(() =>\n [\n 'group flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm font-medium transition-colors',\n 'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary-500 dark:focus-visible:outline-primary-400',\n props.active\n ? 'bg-primary-50 text-primary-700 dark:bg-primary-400/10 dark:text-primary-200'\n : 'text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-100',\n props.disabled ? 'pointer-events-none opacity-40' : 'cursor-pointer',\n ].join(' '),\n)\n\nconst { mergedClasses, restAttrs } = useMergedClasses(() => internalClasses.value)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgEA,MAAM,QAAQ;EAoDd,MAAM,OAAO;EAIb,MAAM,QAAQ,OAAO,uBAAuB,IAAI;EAEhD,MAAM,cAAc,eAAe;GACjC,IAAI,MAAM,KAAK,OAAO,MAAM;GAC5B,IAAI,MAAM,OAAO,KAAA,GAAW,OAAO;GACnC,IAAI,MAAM,MAAM,OAAO;GACvB,OAAO;EACT,CAAC;EAED,MAAM,YAAY,eAAe;GAC/B,IAAI,YAAY,UAAU,UAAU,OAAO;IAAE,MAAM;IAAU,UAAU,MAAM;GAAS;GACtF,IAAI,YAAY,UAAU,KAAK,OAAO,EAAE,MAAM,MAAM,WAAW,KAAA,IAAY,MAAM,KAAK;GACtF,OAAO,EAAE,IAAI,MAAM,GAAG;EACxB,CAAC;EAED,MAAM,WAAW,eAAe,MAAM,UAAU,MAAM,MAAM,UAAU,IAAI;EAE1E,SAAS,QAAQ,OAAO;GACtB,IAAI,MAAM,UAAU;IAClB,MAAM,eAAe;IACrB;GACF;GACA,KAAK,SAAS,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