numori-ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +9 -1
  3. package/dist/components/Avatar.js +71 -19
  4. package/dist/components/Avatar.js.map +1 -1
  5. package/dist/components/Dropdown.js +3 -1
  6. package/dist/components/Dropdown.js.map +1 -1
  7. package/dist/components/Modal.js +61 -4
  8. package/dist/components/Modal.js.map +1 -1
  9. package/dist/components/Prompt.js +11 -6
  10. package/dist/components/Prompt.js.map +1 -1
  11. package/dist/components/Select.js +1 -1
  12. package/dist/components/Select.js.map +1 -1
  13. package/dist/components/Skeleton.js +122 -0
  14. package/dist/components/Skeleton.js.map +1 -0
  15. package/dist/components/SplitPane.js +264 -0
  16. package/dist/components/SplitPane.js.map +1 -0
  17. package/dist/components/Tree.js +417 -0
  18. package/dist/components/Tree.js.map +1 -0
  19. package/dist/components/VirtualList.js +292 -0
  20. package/dist/components/VirtualList.js.map +1 -0
  21. package/dist/components/index.js +29 -22
  22. package/dist/components/index.js.map +1 -1
  23. package/dist/icons/mdi.js +2 -0
  24. package/dist/icons/mdi.js.map +1 -1
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.js +15 -11
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal/focusTrap.js +163 -0
  29. package/dist/internal/focusTrap.js.map +1 -0
  30. package/dist/manifest.js +5 -1
  31. package/dist/manifest.js.map +1 -1
  32. package/package.json +1 -1
  33. package/src/components/Avatar.vue +69 -18
  34. package/src/components/Dropdown.vue +4 -1
  35. package/src/components/Modal.vue +51 -3
  36. package/src/components/Prompt.vue +14 -3
  37. package/src/components/Select.vue +1 -1
  38. package/src/components/Skeleton.vue +91 -0
  39. package/src/components/SplitPane.vue +264 -0
  40. package/src/components/Tree.vue +428 -0
  41. package/src/components/VirtualList.vue +250 -0
  42. package/src/components/index.js +12 -1
  43. package/src/icons/mdi.js +2 -0
  44. package/src/internal/focusTrap.js +185 -0
  45. package/src/manifest.js +4 -0
@@ -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 :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,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,QAAQ;IACZ,MAAM,GAAG,KAAK,KAAK;IACnB,UAAU,GAAG,KAAK,MAAM;IACxB,iBAAiB,SAAS,kBAAkB;GAC9C;GACA,IAAI,MAAM,OAAO,MAAM,QAAQ,GAAG,KAAK,MAAM;GAC7C,IAAI,QAAQ,MAAM,SAAS,GAAG,OAAO,cAAc,KAAK,MAAM,EAAE;QAC3D,MAAM,MAAM,GAAG,KAAK,SAA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OM,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"}
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.prevent=\"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,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;G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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,122 @@
1
+ import { Fragment, computed, createCommentVNode, createElementBlock, mergeProps, normalizeClass, openBlock, renderList, toDisplayString } from "vue";
2
+ //#region src/components/Skeleton.vue
3
+ var _hoisted_1 = {
4
+ key: 0,
5
+ class: "sr-only"
6
+ };
7
+ var _hoisted_2 = {
8
+ key: 0,
9
+ class: "sr-only"
10
+ };
11
+ var _sfc_main = {
12
+ __name: "Skeleton",
13
+ props: {
14
+ /**
15
+ * Shape of the placeholder.
16
+ * @type {string}
17
+ * @default 'text'
18
+ * @values 'text' | 'rect' | 'circle'
19
+ */
20
+ variant: {
21
+ type: String,
22
+ default: "text"
23
+ },
24
+ /**
25
+ * Number of lines for `variant="text"`.
26
+ * @type {number}
27
+ * @default 1
28
+ */
29
+ lines: {
30
+ type: Number,
31
+ default: 1
32
+ },
33
+ /**
34
+ * Spacing between text lines.
35
+ * @type {string}
36
+ * @default 'md'
37
+ * @values 'sm' | 'md' | 'lg'
38
+ */
39
+ gap: {
40
+ type: String,
41
+ default: "md"
42
+ },
43
+ /**
44
+ * Pulse while waiting. Always off under `prefers-reduced-motion`.
45
+ * @type {boolean}
46
+ * @default true
47
+ */
48
+ animated: {
49
+ type: Boolean,
50
+ default: true
51
+ },
52
+ /**
53
+ * Announce the placeholder as a loading status with this text. Empty keeps
54
+ * it hidden from assistive technology.
55
+ * @type {string}
56
+ * @default ''
57
+ */
58
+ label: {
59
+ type: String,
60
+ default: ""
61
+ }
62
+ },
63
+ setup(__props) {
64
+ /**
65
+ * UiSkeleton — a placeholder shaped like the content that is about to load.
66
+ *
67
+ * Three shapes: `text` (one or more lines, the last one shorter), `rect` and
68
+ * `circle`. Size the shape with ordinary classes — `class="h-24 w-full"`, or
69
+ * `class="size-9"` for an avatar-sized circle.
70
+ *
71
+ * The shimmer is a gentle pulse and stops for anyone who prefers reduced
72
+ * motion. Skeletons are decorative (`aria-hidden`) by default; give one a
73
+ * `label` and it becomes a polite status message instead, so a screen reader
74
+ * hears "Loading messages" once rather than nothing at all. Label one
75
+ * skeleton per region, not every line.
76
+ *
77
+ * @example A message row while it loads
78
+ * <div class="flex items-center gap-3">
79
+ * <UiSkeleton variant="circle" class="size-9" />
80
+ * <UiSkeleton :lines="2" class="flex-1" />
81
+ * </div>
82
+ *
83
+ * @example Announced to screen readers
84
+ * <UiSkeleton variant="rect" class="h-40" label="Loading message" />
85
+ */
86
+ const props = __props;
87
+ const baseClass = computed(() => ["block bg-gray-200 dark:bg-gray-800", props.animated ? "animate-pulse motion-reduce:animate-none" : ""].join(" "));
88
+ const shapeClass = computed(() => props.variant === "circle" ? "rounded-full" : "rounded-lg");
89
+ const gapClass = computed(() => ({
90
+ sm: "gap-1.5",
91
+ md: "gap-2",
92
+ lg: "gap-3"
93
+ })[props.gap] ?? "gap-2");
94
+ const a11yAttrs = computed(() => props.label ? {
95
+ role: "status",
96
+ "aria-live": "polite"
97
+ } : { "aria-hidden": "true" });
98
+ return (_ctx, _cache) => {
99
+ return __props.variant === "text" ? (openBlock(), createElementBlock("div", mergeProps({
100
+ key: 0,
101
+ class: ["flex flex-col", gapClass.value]
102
+ }, a11yAttrs.value), [__props.label ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(__props.label), 1)) : createCommentVNode("", true), (openBlock(true), createElementBlock(Fragment, null, renderList(__props.lines, (line) => {
103
+ return openBlock(), createElementBlock("div", {
104
+ key: line,
105
+ class: normalizeClass([
106
+ baseClass.value,
107
+ "h-3 rounded-md",
108
+ line === __props.lines && __props.lines > 1 ? "w-3/5" : "w-full"
109
+ ]),
110
+ "aria-hidden": "true"
111
+ }, null, 2);
112
+ }), 128))], 16)) : (openBlock(), createElementBlock("div", mergeProps({
113
+ key: 1,
114
+ class: [baseClass.value, shapeClass.value]
115
+ }, a11yAttrs.value), [__props.label ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(__props.label), 1)) : createCommentVNode("", true)], 16));
116
+ };
117
+ }
118
+ };
119
+ //#endregion
120
+ export { _sfc_main as default };
121
+
122
+ //# sourceMappingURL=Skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Skeleton.js","names":[],"sources":["../../src/components/Skeleton.vue"],"sourcesContent":["<template>\n <div v-if=\"variant === 'text'\" :class=\"['flex flex-col', gapClass]\" v-bind=\"a11yAttrs\">\n <span v-if=\"label\" class=\"sr-only\">{{ label }}</span>\n <div\n v-for=\"line in lines\"\n :key=\"line\"\n :class=\"[baseClass, 'h-3 rounded-md', line === lines && lines > 1 ? 'w-3/5' : 'w-full']\"\n aria-hidden=\"true\"\n />\n </div>\n <div v-else :class=\"[baseClass, shapeClass]\" v-bind=\"a11yAttrs\">\n <span v-if=\"label\" class=\"sr-only\">{{ label }}</span>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSkeleton — a placeholder shaped like the content that is about to load.\n *\n * Three shapes: `text` (one or more lines, the last one shorter), `rect` and\n * `circle`. Size the shape with ordinary classes — `class=\"h-24 w-full\"`, or\n * `class=\"size-9\"` for an avatar-sized circle.\n *\n * The shimmer is a gentle pulse and stops for anyone who prefers reduced\n * motion. Skeletons are decorative (`aria-hidden`) by default; give one a\n * `label` and it becomes a polite status message instead, so a screen reader\n * hears \"Loading messages\" once rather than nothing at all. Label one\n * skeleton per region, not every line.\n *\n * @example A message row while it loads\n * <div class=\"flex items-center gap-3\">\n * <UiSkeleton variant=\"circle\" class=\"size-9\" />\n * <UiSkeleton :lines=\"2\" class=\"flex-1\" />\n * </div>\n *\n * @example Announced to screen readers\n * <UiSkeleton variant=\"rect\" class=\"h-40\" label=\"Loading message\" />\n */\nimport { computed } from 'vue'\n\nconst props = defineProps({\n /**\n * Shape of the placeholder.\n * @type {string}\n * @default 'text'\n * @values 'text' | 'rect' | 'circle'\n */\n variant: { type: String, default: 'text' },\n /**\n * Number of lines for `variant=\"text\"`.\n * @type {number}\n * @default 1\n */\n lines: { type: Number, default: 1 },\n /**\n * Spacing between text lines.\n * @type {string}\n * @default 'md'\n * @values 'sm' | 'md' | 'lg'\n */\n gap: { type: String, default: 'md' },\n /**\n * Pulse while waiting. Always off under `prefers-reduced-motion`.\n * @type {boolean}\n * @default true\n */\n animated: { type: Boolean, default: true },\n /**\n * Announce the placeholder as a loading status with this text. Empty keeps\n * it hidden from assistive technology.\n * @type {string}\n * @default ''\n */\n label: { type: String, default: '' },\n})\n\nconst baseClass = computed(() =>\n [\n 'block bg-gray-200 dark:bg-gray-800',\n props.animated ? 'animate-pulse motion-reduce:animate-none' : '',\n ].join(' '),\n)\n\nconst shapeClass = computed(() => (props.variant === 'circle' ? 'rounded-full' : 'rounded-lg'))\n\nconst gapClass = computed(() => ({ sm: 'gap-1.5', md: 'gap-2', lg: 'gap-3' })[props.gap] ?? 'gap-2')\n\nconst a11yAttrs = computed(() =>\n props.label ? { role: 'status', 'aria-live': 'polite' } : { 'aria-hidden': 'true' },\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderSlot, useId } from "vue";
2
+ //#region src/components/SplitPane.vue
3
+ var _hoisted_1 = [
4
+ "aria-label",
5
+ "aria-orientation",
6
+ "aria-valuenow",
7
+ "aria-valuemin",
8
+ "aria-valuemax",
9
+ "data-dragging"
10
+ ];
11
+ var _hoisted_2 = { class: "relative min-h-0 min-w-0 flex-1 overflow-hidden" };
12
+ var _sfc_main = {
13
+ __name: "SplitPane",
14
+ props: {
15
+ /**
16
+ * Size of the start pane in pixels, for `v-model`. Leave unset to let the
17
+ * component manage it from `defaultSize`.
18
+ * @type {number}
19
+ * @default undefined
20
+ */
21
+ modelValue: {
22
+ type: Number,
23
+ default: void 0
24
+ },
25
+ /**
26
+ * Initial size in pixels when uncontrolled, and the size double-click resets to.
27
+ * @type {number}
28
+ * @default 320
29
+ */
30
+ defaultSize: {
31
+ type: Number,
32
+ default: 320
33
+ },
34
+ /**
35
+ * Smallest start pane size in pixels.
36
+ * @type {number}
37
+ * @default 160
38
+ */
39
+ min: {
40
+ type: Number,
41
+ default: 160
42
+ },
43
+ /**
44
+ * Largest start pane size in pixels. The pane is also never allowed to push
45
+ * the end pane below `endMin`.
46
+ * @type {number}
47
+ * @default 800
48
+ */
49
+ max: {
50
+ type: Number,
51
+ default: 800
52
+ },
53
+ /**
54
+ * Smallest size the end pane may be squeezed to, in pixels.
55
+ * @type {number}
56
+ * @default 240
57
+ */
58
+ endMin: {
59
+ type: Number,
60
+ default: 240
61
+ },
62
+ /**
63
+ * Layout direction. `horizontal` puts the panes side by side.
64
+ * @type {string}
65
+ * @default 'horizontal'
66
+ * @values 'horizontal' | 'vertical'
67
+ */
68
+ direction: {
69
+ type: String,
70
+ default: "horizontal"
71
+ },
72
+ /**
73
+ * Arrow-key step in pixels. Shift multiplies it by five.
74
+ * @type {number}
75
+ * @default 16
76
+ */
77
+ step: {
78
+ type: Number,
79
+ default: 16
80
+ },
81
+ /**
82
+ * Accessible name for the splitter.
83
+ * @type {string}
84
+ * @default 'Resize panes'
85
+ */
86
+ label: {
87
+ type: String,
88
+ default: "Resize panes"
89
+ }
90
+ },
91
+ emits: ["update:modelValue", "resize-end"],
92
+ setup(__props, { emit: __emit }) {
93
+ /**
94
+ * UiSplitPane — two panes divided by a draggable, keyboard-operable splitter.
95
+ *
96
+ * The `start` pane has an explicit size in pixels; the `end` pane takes the
97
+ * rest. Drag the splitter with a mouse, finger or pen, or focus it and use the
98
+ * arrow keys (Shift for bigger steps), Home and End for the limits, and Enter
99
+ * to toggle between the current size and `min`. Double-click resets to
100
+ * `defaultSize`.
101
+ *
102
+ * Follows the WAI-ARIA window splitter pattern: the splitter is a focusable
103
+ * `role="separator"` whose `aria-valuenow` is the start pane's size and whose
104
+ * `aria-controls` points at it, so assistive technology can report and change
105
+ * the split.
106
+ *
107
+ * Bind `v-model` to persist the size (for example to local storage); leave it
108
+ * unbound and the component keeps its own state. `update:modelValue` fires on
109
+ * every change while dragging, and `resize-end` once when a drag or key press
110
+ * finishes — persist on the latter to avoid a write per pixel.
111
+ *
112
+ * The component fills its parent (`h-full w-full`), so give the parent a
113
+ * size. Panes can nest: put a second `UiSplitPane` in `#end` for three columns.
114
+ *
115
+ * @example Message list beside a reader
116
+ * <UiSplitPane v-model="listWidth" :min="280" :max="640" label="Resize message list">
117
+ * <template #start><MessageList /></template>
118
+ * <template #end><MessageReader /></template>
119
+ * </UiSplitPane>
120
+ *
121
+ * @example Stacked
122
+ * <UiSplitPane direction="vertical" :default-size="240" label="Resize preview">
123
+ * <template #start>Top</template>
124
+ * <template #end>Bottom</template>
125
+ * </UiSplitPane>
126
+ *
127
+ * @emits {number} update:modelValue — The start pane's new size, in pixels.
128
+ * @emits {number} resize-end — A drag or keyboard adjustment finished, with the final size.
129
+ *
130
+ * @slot start — The sized pane. Scope: `{ size }`.
131
+ * @slot end — The flexible pane.
132
+ */
133
+ const props = __props;
134
+ const emit = __emit;
135
+ const startId = `${useId()}-start`;
136
+ const rootRef = ref(null);
137
+ const isHorizontal = computed(() => props.direction !== "vertical");
138
+ const internalSize = ref(props.defaultSize);
139
+ const currentSize = computed(() => props.modelValue ?? internalSize.value);
140
+ const extent = ref(0);
141
+ const effectiveMax = computed(() => {
142
+ if (!extent.value) return props.max;
143
+ return Math.max(props.min, Math.min(props.max, extent.value - props.endMin));
144
+ });
145
+ const clamp = (value) => Math.round(Math.min(effectiveMax.value, Math.max(props.min, value)));
146
+ const startStyle = computed(() => {
147
+ const size = `${clamp(currentSize.value)}px`;
148
+ return isHorizontal.value ? { width: size } : { height: size };
149
+ });
150
+ function setSize(value) {
151
+ const next = clamp(value);
152
+ if (next === currentSize.value) return;
153
+ internalSize.value = next;
154
+ emit("update:modelValue", next);
155
+ }
156
+ const finish = () => emit("resize-end", clamp(currentSize.value));
157
+ const dragging = ref(false);
158
+ let dragOrigin = 0;
159
+ let sizeOrigin = 0;
160
+ function onPointerDown(event) {
161
+ if (event.button !== 0) return;
162
+ event.preventDefault();
163
+ event.currentTarget.setPointerCapture?.(event.pointerId);
164
+ event.currentTarget.focus({ preventScroll: true });
165
+ dragging.value = true;
166
+ dragOrigin = isHorizontal.value ? event.clientX : event.clientY;
167
+ sizeOrigin = clamp(currentSize.value);
168
+ event.currentTarget.addEventListener("pointermove", onPointerMove);
169
+ event.currentTarget.addEventListener("pointerup", onPointerUp, { once: true });
170
+ event.currentTarget.addEventListener("pointercancel", onPointerUp, { once: true });
171
+ }
172
+ function onPointerMove(event) {
173
+ if (!dragging.value) return;
174
+ const position = isHorizontal.value ? event.clientX : event.clientY;
175
+ setSize(sizeOrigin + position - dragOrigin);
176
+ }
177
+ function onPointerUp(event) {
178
+ event.currentTarget.removeEventListener("pointermove", onPointerMove);
179
+ event.currentTarget.removeEventListener("pointerup", onPointerUp);
180
+ event.currentTarget.removeEventListener("pointercancel", onPointerUp);
181
+ if (!dragging.value) return;
182
+ dragging.value = false;
183
+ finish();
184
+ }
185
+ let sizeBeforeCollapse = null;
186
+ function onKeydown(event) {
187
+ const decrease = isHorizontal.value ? "ArrowLeft" : "ArrowUp";
188
+ const increase = isHorizontal.value ? "ArrowRight" : "ArrowDown";
189
+ const amount = event.shiftKey ? props.step * 5 : props.step;
190
+ const now = clamp(currentSize.value);
191
+ let next = null;
192
+ if (event.key === decrease) next = now - amount;
193
+ else if (event.key === increase) next = now + amount;
194
+ else if (event.key === "Home") next = props.min;
195
+ else if (event.key === "End") next = effectiveMax.value;
196
+ else if (event.key === "Enter") {
197
+ if (now > props.min) {
198
+ sizeBeforeCollapse = now;
199
+ next = props.min;
200
+ } else next = sizeBeforeCollapse ?? props.defaultSize;
201
+ }
202
+ if (next === null) return;
203
+ event.preventDefault();
204
+ setSize(next);
205
+ finish();
206
+ }
207
+ function reset() {
208
+ setSize(props.defaultSize);
209
+ finish();
210
+ }
211
+ let observer = null;
212
+ onMounted(() => {
213
+ const measure = () => {
214
+ const rect = rootRef.value?.getBoundingClientRect();
215
+ if (rect) extent.value = isHorizontal.value ? rect.width : rect.height;
216
+ };
217
+ measure();
218
+ if (typeof ResizeObserver !== "undefined" && rootRef.value) {
219
+ observer = new ResizeObserver(measure);
220
+ observer.observe(rootRef.value);
221
+ }
222
+ });
223
+ onBeforeUnmount(() => observer?.disconnect());
224
+ return (_ctx, _cache) => {
225
+ return openBlock(), createElementBlock("div", {
226
+ ref_key: "rootRef",
227
+ ref: rootRef,
228
+ class: normalizeClass(["flex h-full w-full min-h-0 min-w-0", [isHorizontal.value ? "flex-row" : "flex-col", dragging.value ? "select-none" : ""]])
229
+ }, [
230
+ createElementVNode("div", {
231
+ id: startId,
232
+ class: "relative min-h-0 min-w-0 shrink-0 overflow-hidden",
233
+ style: normalizeStyle(startStyle.value)
234
+ }, [renderSlot(_ctx.$slots, "start", { size: currentSize.value })], 4),
235
+ createElementVNode("div", {
236
+ role: "separator",
237
+ tabindex: "0",
238
+ "aria-label": __props.label,
239
+ "aria-controls": startId,
240
+ "aria-orientation": isHorizontal.value ? "vertical" : "horizontal",
241
+ "aria-valuenow": Math.round(currentSize.value),
242
+ "aria-valuemin": __props.min,
243
+ "aria-valuemax": effectiveMax.value,
244
+ "data-dragging": dragging.value ? "true" : void 0,
245
+ class: normalizeClass(["group relative z-10 shrink-0 touch-none focus-visible:outline-none", isHorizontal.value ? "w-px cursor-col-resize" : "h-px cursor-row-resize"]),
246
+ onPointerdown: onPointerDown,
247
+ onKeydown,
248
+ onDblclick: reset
249
+ }, [createElementVNode("span", {
250
+ "aria-hidden": "true",
251
+ class: normalizeClass(["absolute bg-gray-200 transition-colors group-hover:bg-primary-400 group-focus-visible:bg-primary-500 group-data-[dragging=true]:bg-primary-500 dark:bg-gray-800 dark:group-hover:bg-primary-500", isHorizontal.value ? "inset-y-0 left-0 w-px group-focus-visible:-left-px group-focus-visible:w-[3px]" : "inset-x-0 top-0 h-px group-focus-visible:-top-px group-focus-visible:h-[3px]"])
252
+ }, null, 2), createElementVNode("span", {
253
+ "aria-hidden": "true",
254
+ class: normalizeClass(["absolute", isHorizontal.value ? "inset-y-0 -left-1.5 w-3" : "inset-x-0 -top-1.5 h-3"])
255
+ }, null, 2)], 42, _hoisted_1),
256
+ createElementVNode("div", _hoisted_2, [renderSlot(_ctx.$slots, "end")])
257
+ ], 2);
258
+ };
259
+ }
260
+ };
261
+ //#endregion
262
+ export { _sfc_main as default };
263
+
264
+ //# sourceMappingURL=SplitPane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SplitPane.js","names":[],"sources":["../../src/components/SplitPane.vue"],"sourcesContent":["<template>\n <div\n ref=\"rootRef\"\n class=\"flex h-full w-full min-h-0 min-w-0\"\n :class=\"[isHorizontal ? 'flex-row' : 'flex-col', dragging ? 'select-none' : '']\"\n >\n <div\n :id=\"startId\"\n class=\"relative min-h-0 min-w-0 shrink-0 overflow-hidden\"\n :style=\"startStyle\"\n >\n <slot name=\"start\" :size=\"currentSize\" />\n </div>\n\n <!-- The splitter: the WAI-ARIA \"window splitter\" pattern. A 1px rule with\n a wider invisible hit area, focusable and operable from the keyboard. -->\n <div\n role=\"separator\"\n tabindex=\"0\"\n :aria-label=\"label\"\n :aria-controls=\"startId\"\n :aria-orientation=\"isHorizontal ? 'vertical' : 'horizontal'\"\n :aria-valuenow=\"Math.round(currentSize)\"\n :aria-valuemin=\"min\"\n :aria-valuemax=\"effectiveMax\"\n :data-dragging=\"dragging ? 'true' : undefined\"\n class=\"group relative z-10 shrink-0 touch-none focus-visible:outline-none\"\n :class=\"isHorizontal ? 'w-px cursor-col-resize' : 'h-px cursor-row-resize'\"\n @pointerdown=\"onPointerDown\"\n @keydown=\"onKeydown\"\n @dblclick=\"reset\"\n >\n <span\n aria-hidden=\"true\"\n class=\"absolute bg-gray-200 transition-colors group-hover:bg-primary-400 group-focus-visible:bg-primary-500 group-data-[dragging=true]:bg-primary-500 dark:bg-gray-800 dark:group-hover:bg-primary-500\"\n :class=\"\n isHorizontal\n ? 'inset-y-0 left-0 w-px group-focus-visible:-left-px group-focus-visible:w-[3px]'\n : 'inset-x-0 top-0 h-px group-focus-visible:-top-px group-focus-visible:h-[3px]'\n \"\n />\n <span\n aria-hidden=\"true\"\n class=\"absolute\"\n :class=\"isHorizontal ? 'inset-y-0 -left-1.5 w-3' : 'inset-x-0 -top-1.5 h-3'\"\n />\n </div>\n\n <div class=\"relative min-h-0 min-w-0 flex-1 overflow-hidden\">\n <slot name=\"end\" />\n </div>\n </div>\n</template>\n\n<script setup>\n/**\n * UiSplitPane — two panes divided by a draggable, keyboard-operable splitter.\n *\n * The `start` pane has an explicit size in pixels; the `end` pane takes the\n * rest. Drag the splitter with a mouse, finger or pen, or focus it and use the\n * arrow keys (Shift for bigger steps), Home and End for the limits, and Enter\n * to toggle between the current size and `min`. Double-click resets to\n * `defaultSize`.\n *\n * Follows the WAI-ARIA window splitter pattern: the splitter is a focusable\n * `role=\"separator\"` whose `aria-valuenow` is the start pane's size and whose\n * `aria-controls` points at it, so assistive technology can report and change\n * the split.\n *\n * Bind `v-model` to persist the size (for example to local storage); leave it\n * unbound and the component keeps its own state. `update:modelValue` fires on\n * every change while dragging, and `resize-end` once when a drag or key press\n * finishes — persist on the latter to avoid a write per pixel.\n *\n * The component fills its parent (`h-full w-full`), so give the parent a\n * size. Panes can nest: put a second `UiSplitPane` in `#end` for three columns.\n *\n * @example Message list beside a reader\n * <UiSplitPane v-model=\"listWidth\" :min=\"280\" :max=\"640\" label=\"Resize message list\">\n * <template #start><MessageList /></template>\n * <template #end><MessageReader /></template>\n * </UiSplitPane>\n *\n * @example Stacked\n * <UiSplitPane direction=\"vertical\" :default-size=\"240\" label=\"Resize preview\">\n * <template #start>Top</template>\n * <template #end>Bottom</template>\n * </UiSplitPane>\n *\n * @emits {number} update:modelValue — The start pane's new size, in pixels.\n * @emits {number} resize-end — A drag or keyboard adjustment finished, with the final size.\n *\n * @slot start — The sized pane. Scope: `{ size }`.\n * @slot end — The flexible pane.\n */\nimport { computed, onBeforeUnmount, onMounted, ref, useId } from 'vue'\n\nconst props = defineProps({\n /**\n * Size of the start pane in pixels, for `v-model`. Leave unset to let the\n * component manage it from `defaultSize`.\n * @type {number}\n * @default undefined\n */\n modelValue: { type: Number, default: undefined },\n /**\n * Initial size in pixels when uncontrolled, and the size double-click resets to.\n * @type {number}\n * @default 320\n */\n defaultSize: { type: Number, default: 320 },\n /**\n * Smallest start pane size in pixels.\n * @type {number}\n * @default 160\n */\n min: { type: Number, default: 160 },\n /**\n * Largest start pane size in pixels. The pane is also never allowed to push\n * the end pane below `endMin`.\n * @type {number}\n * @default 800\n */\n max: { type: Number, default: 800 },\n /**\n * Smallest size the end pane may be squeezed to, in pixels.\n * @type {number}\n * @default 240\n */\n endMin: { type: Number, default: 240 },\n /**\n * Layout direction. `horizontal` puts the panes side by side.\n * @type {string}\n * @default 'horizontal'\n * @values 'horizontal' | 'vertical'\n */\n direction: { type: String, default: 'horizontal' },\n /**\n * Arrow-key step in pixels. Shift multiplies it by five.\n * @type {number}\n * @default 16\n */\n step: { type: Number, default: 16 },\n /**\n * Accessible name for the splitter.\n * @type {string}\n * @default 'Resize panes'\n */\n label: { type: String, default: 'Resize panes' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'resize-end'])\n\nconst startId = `${useId()}-start`\nconst rootRef = ref(null)\nconst isHorizontal = computed(() => props.direction !== 'vertical')\n\n// ── Size state (controlled or uncontrolled) ──\nconst internalSize = ref(props.defaultSize)\nconst currentSize = computed(() => props.modelValue ?? internalSize.value)\n\n// The container's extent along the split axis, so `max` can respect `endMin`.\nconst extent = ref(0)\nconst effectiveMax = computed(() => {\n if (!extent.value) return props.max\n return Math.max(props.min, Math.min(props.max, extent.value - props.endMin))\n})\n\nconst clamp = (value) => Math.round(Math.min(effectiveMax.value, Math.max(props.min, value)))\n\nconst startStyle = computed(() => {\n const size = `${clamp(currentSize.value)}px`\n return isHorizontal.value ? { width: size } : { height: size }\n})\n\nfunction setSize(value) {\n const next = clamp(value)\n if (next === currentSize.value) return\n internalSize.value = next\n emit('update:modelValue', next)\n}\n\nconst finish = () => emit('resize-end', clamp(currentSize.value))\n\n// ── Pointer dragging ──\nconst dragging = ref(false)\nlet dragOrigin = 0\nlet sizeOrigin = 0\n\nfunction onPointerDown(event) {\n if (event.button !== 0) return\n event.preventDefault()\n event.currentTarget.setPointerCapture?.(event.pointerId)\n event.currentTarget.focus({ preventScroll: true })\n dragging.value = true\n dragOrigin = isHorizontal.value ? event.clientX : event.clientY\n sizeOrigin = clamp(currentSize.value)\n event.currentTarget.addEventListener('pointermove', onPointerMove)\n event.currentTarget.addEventListener('pointerup', onPointerUp, { once: true })\n event.currentTarget.addEventListener('pointercancel', onPointerUp, { once: true })\n}\n\nfunction onPointerMove(event) {\n if (!dragging.value) return\n const position = isHorizontal.value ? event.clientX : event.clientY\n setSize(sizeOrigin + position - dragOrigin)\n}\n\nfunction onPointerUp(event) {\n event.currentTarget.removeEventListener('pointermove', onPointerMove)\n event.currentTarget.removeEventListener('pointerup', onPointerUp)\n event.currentTarget.removeEventListener('pointercancel', onPointerUp)\n if (!dragging.value) return\n dragging.value = false\n finish()\n}\n\n// ── Keyboard ──\nlet sizeBeforeCollapse = null\n\nfunction onKeydown(event) {\n const decrease = isHorizontal.value ? 'ArrowLeft' : 'ArrowUp'\n const increase = isHorizontal.value ? 'ArrowRight' : 'ArrowDown'\n const amount = event.shiftKey ? props.step * 5 : props.step\n const now = clamp(currentSize.value)\n let next = null\n if (event.key === decrease) next = now - amount\n else if (event.key === increase) next = now + amount\n else if (event.key === 'Home') next = props.min\n else if (event.key === 'End') next = effectiveMax.value\n else if (event.key === 'Enter') {\n if (now > props.min) {\n sizeBeforeCollapse = now\n next = props.min\n } else {\n next = sizeBeforeCollapse ?? props.defaultSize\n }\n }\n if (next === null) return\n event.preventDefault()\n setSize(next)\n finish()\n}\n\nfunction reset() {\n setSize(props.defaultSize)\n finish()\n}\n\n// ── Track the container size ──\nlet observer = null\nonMounted(() => {\n const measure = () => {\n const rect = rootRef.value?.getBoundingClientRect()\n if (rect) extent.value = isHorizontal.value ? rect.width : rect.height\n }\n measure()\n if (typeof ResizeObserver !== 'undefined' && rootRef.value) {\n observer = new ResizeObserver(measure)\n observer.observe(rootRef.value)\n }\n})\nonBeforeUnmount(() => observer?.disconnect())\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiGA,MAAM,QAAQ;EAsDd,MAAM,OAAO;EAEb,MAAM,UAAU,GAAG,MAAM,EAAE;EAC3B,MAAM,UAAU,IAAI,IAAI;EACxB,MAAM,eAAe,eAAe,MAAM,cAAc,UAAU;EAGlE,MAAM,eAAe,IAAI,MAAM,WAAW;EAC1C,MAAM,cAAc,eAAe,MAAM,cAAc,aAAa,KAAK;EAGzE,MAAM,SAAS,IAAI,CAAC;EACpB,MAAM,eAAe,eAAe;GAClC,IAAI,CAAC,OAAO,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