numori-ui 0.1.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/LICENSE +651 -0
- package/README.md +466 -0
- package/dist/components/Alert.js +137 -0
- package/dist/components/Alert.js.map +1 -0
- package/dist/components/Avatar.js +133 -0
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/Badge.js +93 -0
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/Button.js +428 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/ButtonsGroup.js +153 -0
- package/dist/components/ButtonsGroup.js.map +1 -0
- package/dist/components/Checkbox.js +93 -0
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/Divider.js +79 -0
- package/dist/components/Divider.js.map +1 -0
- package/dist/components/Dropdown.js +166 -0
- package/dist/components/Dropdown.js.map +1 -0
- package/dist/components/DropdownItem.js +106 -0
- package/dist/components/DropdownItem.js.map +1 -0
- package/dist/components/DropdownRow.js +41 -0
- package/dist/components/DropdownRow.js.map +1 -0
- package/dist/components/DropdownSubmenu.js +142 -0
- package/dist/components/DropdownSubmenu.js.map +1 -0
- package/dist/components/FileInput.js +122 -0
- package/dist/components/FileInput.js.map +1 -0
- package/dist/components/FormField.js +112 -0
- package/dist/components/FormField.js.map +1 -0
- package/dist/components/Input.js +603 -0
- package/dist/components/Input.js.map +1 -0
- package/dist/components/Kbd.js +35 -0
- package/dist/components/Kbd.js.map +1 -0
- package/dist/components/ListMenu.js +143 -0
- package/dist/components/ListMenu.js.map +1 -0
- package/dist/components/ListMenuItem.js +189 -0
- package/dist/components/ListMenuItem.js.map +1 -0
- package/dist/components/Modal.js +206 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/Numpad.js +123 -0
- package/dist/components/Numpad.js.map +1 -0
- package/dist/components/Popup.js +170 -0
- package/dist/components/Popup.js.map +1 -0
- package/dist/components/ProgressBar.js +118 -0
- package/dist/components/ProgressBar.js.map +1 -0
- package/dist/components/Prompt.js +201 -0
- package/dist/components/Prompt.js.map +1 -0
- package/dist/components/Radio.js +81 -0
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/Select.js +441 -0
- package/dist/components/Select.js.map +1 -0
- package/dist/components/Slider.js +116 -0
- package/dist/components/Slider.js.map +1 -0
- package/dist/components/Stepper.js +65 -0
- package/dist/components/Stepper.js.map +1 -0
- package/dist/components/Toggle.js +133 -0
- package/dist/components/Toggle.js.map +1 -0
- package/dist/components/Tooltip.js +120 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/index.js +81 -0
- package/dist/components/index.js.map +1 -0
- package/dist/composables/onClickOutside.js +51 -0
- package/dist/composables/onClickOutside.js.map +1 -0
- package/dist/composables/useBackButton.js +98 -0
- package/dist/composables/useBackButton.js.map +1 -0
- package/dist/composables/useEventListener.js +63 -0
- package/dist/composables/useEventListener.js.map +1 -0
- package/dist/icons/Icon.js +120 -0
- package/dist/icons/Icon.js.map +1 -0
- package/dist/icons/mdi.js +69 -0
- package/dist/icons/mdi.js.map +1 -0
- package/dist/icons/registry.js +63 -0
- package/dist/icons/registry.js.map +1 -0
- package/dist/icons/resolver.js +49 -0
- package/dist/icons/resolver.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.js +89 -0
- package/dist/manifest.js.map +1 -0
- package/dist/numori-ui.css +184 -0
- package/dist/nuxt.d.ts +35 -0
- package/dist/nuxt.mjs +243 -0
- package/dist/nuxt.mjs.map +1 -0
- package/dist/vite.d.ts +29 -0
- package/dist/vite.mjs +187 -0
- package/dist/vite.mjs.map +1 -0
- package/package.json +138 -0
- package/src/components/Alert.vue +127 -0
- package/src/components/Avatar.vue +100 -0
- package/src/components/Badge.vue +77 -0
- package/src/components/Button.vue +419 -0
- package/src/components/ButtonsGroup.vue +140 -0
- package/src/components/Checkbox.vue +81 -0
- package/src/components/Divider.vue +64 -0
- package/src/components/Dropdown.vue +150 -0
- package/src/components/DropdownItem.vue +78 -0
- package/src/components/DropdownRow.vue +37 -0
- package/src/components/DropdownSubmenu.vue +127 -0
- package/src/components/FileInput.vue +107 -0
- package/src/components/FormField.vue +86 -0
- package/src/components/Input.vue +619 -0
- package/src/components/Kbd.vue +30 -0
- package/src/components/ListMenu.vue +127 -0
- package/src/components/ListMenuItem.vue +171 -0
- package/src/components/Modal.vue +209 -0
- package/src/components/Numpad.vue +118 -0
- package/src/components/Popup.vue +156 -0
- package/src/components/ProgressBar.vue +107 -0
- package/src/components/Prompt.vue +161 -0
- package/src/components/Radio.vue +50 -0
- package/src/components/Select.vue +470 -0
- package/src/components/Slider.vue +93 -0
- package/src/components/Stepper.vue +53 -0
- package/src/components/Toggle.vue +125 -0
- package/src/components/Tooltip.vue +113 -0
- package/src/components/index.js +109 -0
- package/src/composables/onClickOutside.js +61 -0
- package/src/composables/useBackButton.js +98 -0
- package/src/composables/useEventListener.js +65 -0
- package/src/icons/Icon.vue +139 -0
- package/src/icons/mdi.js +67 -0
- package/src/icons/registry.js +64 -0
- package/src/icons/resolver.js +48 -0
- package/src/index.js +167 -0
- package/src/manifest.js +86 -0
- package/src/nuxt.js +315 -0
- package/src/style.css +20 -0
- package/src/tailwind.css +18 -0
- package/src/theme.css +172 -0
- package/src/vite.js +235 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","names":[],"sources":["../../src/components/Button.vue"],"sourcesContent":["<template>\n <!-- Dynamic root element — renders as button, anchor, or any tag via :is -->\n <component\n :is=\"tag\"\n :type=\"isButton ? nativeType : undefined\"\n :disabled=\"isButton ? disabled || loading : undefined\"\n :href=\"tag === 'a' ? href : undefined\"\n :class=\"mergedClasses\"\n :title=\"title\"\n :aria-label=\"ariaLabel\"\n :aria-checked=\"ariaChecked\"\n :role=\"role\"\n :tabindex=\"tabindex\"\n v-bind=\"restAttrs\"\n >\n <!-- Loading state: spinner replaces slot content (default) -->\n <template v-if=\"loading && loadingStyle === 'spinner'\">\n <UiIcon :name=\"spinnerIcon\" class=\"animate-spin\" :class=\"spinnerSizeClass\" />\n </template>\n <!-- Default slot: button label, icons, or any child content -->\n <slot v-else :spinning=\"loading && loadingStyle === 'icon'\" />\n </component>\n</template>\n\n<script setup>\n/**\n * UiButton — Versatile button component with multiple variants, colors, sizes, and shapes.\n *\n * Supports rendering as any HTML element (button, anchor, div), eight visual variants\n * (solid, outline, ghost, dashed, text, link, menu-item, list-item), six color themes,\n * five sizes, and five shape options. Includes loading state with a configurable spinner,\n * icon-only mode, block/full-width layout, and full accessibility attribute support.\n * External Tailwind classes are merged via `tailwind-merge` so they can override internals.\n *\n * @example Basic solid button\n * <UiButton @click=\"save\">Save</UiButton>\n *\n * @example Ghost icon button\n * <UiButton variant=\"ghost\" color=\"gray\" icon-only>\n * <UiIcon name=\"mdi:close\" class=\"w-5 h-5\" />\n * </UiButton>\n *\n * @example Outline danger button with loading\n * <UiButton variant=\"outline\" color=\"red\" :loading=\"isSaving\">Delete</UiButton>\n *\n * @example Menu item in a dropdown\n * <UiButton variant=\"menu-item\" color=\"red\">\n * <UiIcon name=\"mdi:trash-can-outline\" class=\"w-4 h-4\" /> Delete\n * </UiButton>\n *\n * @example Anchor link\n * <UiButton tag=\"a\" variant=\"link\" href=\"/docs\">Read docs</UiButton>\n *\n * @slot default — Button content (label text, icons, or any child elements)\n */\nimport { computed, useAttrs } from 'vue'\nimport UiIcon from '../icons/Icon.vue'\nimport { twMerge } from 'tailwind-merge'\nconst props = defineProps({\n /**\n * HTML element tag to render.\n * @type {string}\n * @default 'button'\n * @values 'button' | 'a' | 'div' | any valid HTML tag\n */\n tag: { type: String, default: 'button' },\n\n /**\n * Native button `type` attribute (only applied when tag is 'button').\n * @type {string}\n * @default 'button'\n * @values 'button' | 'submit' | 'reset'\n */\n nativeType: { type: String, default: 'button' },\n\n /**\n * Visual variant controlling background, border, and hover styles.\n * - 'solid' — filled background with shadow\n * - 'outline' — transparent with colored border\n * - 'ghost' — transparent, colored on hover\n * - 'dashed' — dashed border, transparent background\n * - 'text' — plain text, underline on hover\n * - 'link' — inline link style, no padding\n * - 'menu-item' — full-width row for dropdown menus\n * - 'list-item' — full-width row for settings lists\n * @type {string}\n * @default 'solid'\n */\n variant: { type: String, default: 'solid' },\n\n /**\n * Color theme key mapped to Tailwind color scales.\n * @type {string}\n * @default 'primary'\n * @values 'primary' | 'gray' | 'red' | 'green' | 'amber' | 'white'\n */\n color: { type: String, default: 'primary' },\n\n /**\n * Button size controlling padding, font size, and gap.\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Border-radius shape of the button.\n * @type {string}\n * @default 'round'\n * @values 'round' (rounded-lg) | 'pill' (rounded-full) | 'square' (rounded-none) | 'circle' (rounded-full) | 'none'\n */\n shape: { type: String, default: 'round' },\n\n /**\n * Disabled state — visually dims the button and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Loading state — replaces slot content with a spinner and disables the button.\n * @type {boolean}\n * @default false\n */\n loading: { type: Boolean, default: false },\n\n /**\n * Loading visual style.\n * - 'spinner': replaces slot content with a spinner icon (default)\n * - 'icon': keeps slot content visible, exposes `spinning` slot prop for the icon\n * @type {string}\n * @default 'spinner'\n */\n loadingStyle: { type: String, default: 'spinner' },\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 /**\n * Block mode — makes the button full-width (w-full).\n * @type {boolean}\n * @default false\n */\n block: { type: Boolean, default: false },\n\n /**\n * Icon-only mode — uses equal padding on all sides for a square/circle button.\n * @type {boolean}\n * @default false\n */\n iconOnly: { type: Boolean, default: false },\n\n /**\n * URL for anchor tags (only applied when tag is 'a').\n * @type {string}\n * @default undefined\n */\n href: { type: String, default: undefined },\n\n /**\n * Native `title` attribute for hover tooltip.\n * @type {string}\n * @default undefined\n */\n title: { type: String, default: undefined },\n\n /**\n * Accessible label for screen readers.\n * @type {string}\n * @default undefined\n */\n ariaLabel: { type: String, default: undefined },\n\n /**\n * ARIA checked state for toggle-style buttons.\n * @type {string | boolean}\n * @default undefined\n */\n ariaChecked: { type: [String, Boolean], default: undefined },\n\n /**\n * ARIA role override (e.g. 'switch', 'tab').\n * @type {string}\n * @default undefined\n */\n role: { type: String, default: undefined },\n\n /**\n * Tab index for keyboard navigation order.\n * @type {string | number}\n * @default undefined\n */\n tabindex: { type: [String, Number], default: undefined },\n})\n\ndefineOptions({ inheritAttrs: false })\n\n// Determine element type and variant category for conditional attribute binding\nconst isButton = computed(() => props.tag === 'button')\nconst isMenuItem = computed(() => props.variant === 'menu-item')\nconst isListItem = computed(() => props.variant === 'list-item')\n// Menu-item and list-item variants share full-width, left-aligned layout behavior\nconst isInlineVariant = computed(() => isMenuItem.value || isListItem.value)\n\nconst spinnerIcon = computed(() => props.spinner)\n\nconst spinnerSizeClass = computed(() => {\n const map = { xs: 'w-3 h-3', sm: 'w-3.5 h-3.5', md: 'w-4 h-4', lg: 'w-5 h-5', xl: 'w-6 h-6' }\n return map[props.size] || map.md\n})\n\n// ── Size classes ──────────────────────────────────────────\nconst sizeClasses = computed(() => {\n if (isMenuItem.value) return 'px-3 py-1.5 text-sm gap-2'\n if (isListItem.value) return 'px-3.5 py-2.5 text-sm gap-3'\n if (props.iconOnly) {\n const map = { xs: 'p-1', sm: 'p-1.5', md: 'p-2', lg: 'p-2.5', xl: 'p-3' }\n return map[props.size] || map.md\n }\n const map = {\n xs: 'px-2 py-1 text-xs gap-1',\n sm: 'px-2.5 py-1.5 text-xs gap-1.5',\n md: 'px-4 py-2 text-sm gap-2',\n lg: 'px-5 py-2.5 text-sm gap-2',\n xl: 'px-6 py-3 text-base gap-2.5',\n }\n return map[props.size] || map.md\n})\n\n// ── Shape classes ─────────────────────────────────────────\nconst shapeClasses = computed(() => {\n if (isInlineVariant.value) return ''\n const map = {\n round: 'rounded-lg',\n pill: 'rounded-full',\n square: 'rounded-none',\n circle: 'rounded-full',\n none: '',\n }\n return map[props.shape] || map.round\n})\n\n// ── Colour × Variant matrix ──────────────────────────────\n// Each variant defines its own color map. Menu-item and list-item default\n// to gray when color is 'primary' since they sit inside neutral containers.\nconst colorVariantClasses = computed(() => {\n const v = props.variant\n const c = props.color\n\n // Menu item — no bg, no rounding, consistent hover. Defaults to gray text.\n if (v === 'menu-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-100 dark:hover:bg-red-900/30',\n green: 'text-success-600 dark:text-success-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-100 dark:hover:bg-gray-700',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[effectiveColor] || map.gray\n }\n\n // List item — settings list rows. Defaults to gray text.\n if (v === 'list-item') {\n const effectiveColor = c === 'primary' ? 'gray' : c\n const map = {\n gray: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n red: 'text-red-600 dark:text-red-400 hover:bg-red-200/50 dark:hover:bg-red-800/30',\n green:\n 'text-success-600 dark:text-success-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n amber: 'text-amber-600 dark:text-amber-400 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n white: 'text-gray-700 dark:text-gray-300 hover:bg-gray-200/70 dark:hover:bg-gray-700/50',\n }\n return map[effectiveColor] || map.gray\n }\n\n // Solid\n if (v === 'solid') {\n const map = {\n primary: 'bg-primary-600 hover:bg-primary-700 text-white shadow-sm hover:shadow-md',\n gray: 'bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 text-gray-700 dark:text-gray-300',\n red: 'bg-red-600 hover:bg-red-700 text-white shadow-sm hover:shadow-md',\n green: 'bg-success-600 hover:bg-success-700 text-white shadow-sm hover:shadow-md',\n amber: 'bg-amber-600 hover:bg-amber-700 text-white shadow-sm hover:shadow-md',\n white:\n 'bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-900 dark:text-gray-200 shadow-sm',\n }\n return map[c] || map.primary\n }\n\n // Outline\n if (v === 'outline') {\n const map = {\n primary:\n 'border border-primary-500 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Dashed\n if (v === 'dashed') {\n const map = {\n primary:\n 'border border-dashed border-primary-400 dark:border-primary-600 text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'border border-dashed border-red-300 dark:border-red-700 text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'border border-dashed border-success-300 dark:border-success-700 text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'border border-dashed border-amber-300 dark:border-amber-700 text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'border border-dashed border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-50 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Ghost\n if (v === 'ghost') {\n const map = {\n primary:\n 'text-primary-600 dark:text-primary-400 bg-transparent hover:bg-primary-50 dark:hover:bg-primary-900/20',\n gray: 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-800',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:bg-red-50 dark:hover:bg-red-900/20',\n green:\n 'text-success-600 dark:text-success-400 bg-transparent hover:bg-success-50 dark:hover:bg-success-900/20',\n amber:\n 'text-amber-600 dark:text-amber-400 bg-transparent hover:bg-amber-50 dark:hover:bg-amber-900/20',\n white:\n 'text-gray-700 dark:text-gray-300 bg-transparent hover:bg-gray-100 dark:hover:bg-gray-700',\n }\n return map[c] || map.primary\n }\n\n // Text\n if (v === 'text') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 bg-transparent hover:underline',\n gray: 'text-gray-600 dark:text-gray-400 bg-transparent hover:underline',\n red: 'text-red-600 dark:text-red-400 bg-transparent hover:underline',\n green: 'text-success-600 dark:text-success-400 bg-transparent hover:underline',\n amber: 'text-amber-600 dark:text-amber-400 bg-transparent hover:underline',\n white: 'text-gray-700 dark:text-gray-300 bg-transparent hover:underline',\n }\n return map[c] || map.primary\n }\n\n // Link\n if (v === 'link') {\n const map = {\n primary: 'text-primary-600 dark:text-primary-400 hover:underline p-0',\n gray: 'text-gray-500 dark:text-gray-400 hover:underline p-0',\n red: 'text-red-600 dark:text-red-400 hover:underline p-0',\n green: 'text-success-600 dark:text-success-400 hover:underline p-0',\n amber: 'text-amber-600 dark:text-amber-400 hover:underline p-0',\n white: 'text-gray-700 dark:text-gray-300 hover:underline p-0',\n }\n return map[c] || map.primary\n }\n\n return ''\n})\n\n// ── Disabled / loading classes ────────────────────────────\nconst stateClasses = computed(() => {\n if (props.disabled || props.loading) {\n return 'opacity-50 cursor-not-allowed pointer-events-none'\n }\n return 'cursor-pointer'\n})\n\n// ── Merge with external classes (external wins via twMerge) ──\nconst attrs = useAttrs()\n\nconst restAttrs = computed(() => {\n const { class: _, ...rest } = attrs\n return rest\n})\n\nconst mergedClasses = computed(() => {\n const externalClass = attrs.class || ''\n return twMerge(internalClasses.value, externalClass)\n})\n\n// ── Assembled internal classes ────────────────────────────\nconst internalClasses = computed(() => {\n const base = 'inline-flex items-center transition-colors select-none'\n const justify = isInlineVariant.value ? '' : 'justify-center'\n const blockClass = props.block || isInlineVariant.value ? 'w-full' : ''\n const weight = ['ghost', 'text', 'link', 'menu-item', 'list-item'].includes(props.variant)\n ? ''\n : 'font-medium'\n return [\n base,\n justify,\n weight,\n sizeClasses.value,\n shapeClasses.value,\n colorVariantClasses.value,\n stateClasses.value,\n blockClass,\n ]\n .filter(Boolean)\n .join(' ')\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DA,MAAM,QAAQ;EAkJd,MAAM,WAAW,eAAe,MAAM,QAAQ,QAAQ;EACtD,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAC/D,MAAM,aAAa,eAAe,MAAM,YAAY,WAAW;EAE/D,MAAM,kBAAkB,eAAe,WAAW,SAAS,WAAW,KAAK;EAE3E,MAAM,cAAc,eAAe,MAAM,OAAO;EAEhD,MAAM,mBAAmB,eAAe;GACtC,MAAM,MAAM;IAAE,IAAI;IAAW,IAAI;IAAe,IAA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;IAAW,CAAC,CAAC,SAAS,MAAM,OAAO,IACrF,KACA;IAKF,YAAY;IACZ,aAAa;IACb,oBAAoB;IACpB,aAAa;IACb;GACF,CAAA,CACG,OAAO,OAAO,CAAA,CACd,KAAK,GAAG;EACb,CAAC;;GA/ZC,OAAA,UAAA,GAAA,YAmBY,wBAlBL,QAAA,GAAG,GADV,WAmBY;IAjBT,MAAM,SAAA,QAAW,QAAA,aAAa,KAAA;IAC9B,UAAU,SAAA,QAAW,QAAA,YAAY,QAAA,UAAU,KAAA;IAC3C,MAAM,QAAA,QAAG,MAAW,QAAA,OAAO,KAAA;IAC3B,OAAO,cAAA;IACP,OAAO,QAAA;IACP,cAAY,QAAA;IACZ,gBAAc,QAAA;IACd,MAAM,QAAA;IACN,UAAU,QAAA;GACH,GAAA,UAAA,KAAS,GAAA;IAGjB,SAAA,cAEW,CAFK,QAAA,WAAW,QAAA,iBAAY,aACrC,UAAA,GAAA,YAA6E,aAAA;;KAApE,MAAM,YAAA;KAAa,OAAK,eAAA,CAAC,gBAAuB,iBAAA,KAAgB,CAAA;IAG3E,GAAA,MAAA,GAAA,CAAA,QAAA,OAAA,CAAA,KAAA,WAA8D,KAAA,QAAA,WAAA,EAAhD,UAAU,QAAA,WAAW,QAAA,iBAAY,OAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _sfc_main$1 from "../icons/Icon.js";
|
|
2
|
+
import _sfc_main$2 from "./Button.js";
|
|
3
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, normalizeClass, openBlock, renderList, toDisplayString, withCtx } from "vue";
|
|
4
|
+
//#region src/components/ButtonsGroup.vue
|
|
5
|
+
var _hoisted_1 = { key: 1 };
|
|
6
|
+
var _sfc_main = {
|
|
7
|
+
__name: "ButtonsGroup",
|
|
8
|
+
props: {
|
|
9
|
+
/**
|
|
10
|
+
* Currently selected option value (v-model).
|
|
11
|
+
* @type {string | number | boolean}
|
|
12
|
+
* @default ''
|
|
13
|
+
*/
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: [
|
|
16
|
+
String,
|
|
17
|
+
Number,
|
|
18
|
+
Boolean
|
|
19
|
+
],
|
|
20
|
+
default: ""
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Array of option objects: `{ value, icon?, label?, title? }`.
|
|
24
|
+
* At least `value` is required. Provide `icon` for toolbar mode, `label` for tabs.
|
|
25
|
+
* @type {Array<{ value: string|number, icon?: string, label?: string, title?: string }>}
|
|
26
|
+
* @required
|
|
27
|
+
*/
|
|
28
|
+
options: {
|
|
29
|
+
type: Array,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Visual style of the group.
|
|
34
|
+
* - 'toolbar': compact icon toggles with gray background
|
|
35
|
+
* - 'tabs': text-based tabs with lighter background and smaller buttons
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @default 'toolbar'
|
|
38
|
+
* @values 'toolbar' | 'tabs'
|
|
39
|
+
*/
|
|
40
|
+
variant: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "toolbar"
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Icon size class applied to icons in toolbar mode.
|
|
46
|
+
* @type {string}
|
|
47
|
+
* @default 'w-5 h-5'
|
|
48
|
+
*/
|
|
49
|
+
iconClass: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: "w-5 h-5"
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Button size for toolbar variant (tabs always use 'xs').
|
|
55
|
+
* @type {string}
|
|
56
|
+
* @default 'md'
|
|
57
|
+
* @values 'xs' | 'sm' | 'md'
|
|
58
|
+
*/
|
|
59
|
+
size: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: "md"
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Full-width mode. Defaults to true for tabs, false for toolbar.
|
|
65
|
+
* @type {boolean}
|
|
66
|
+
* @default undefined (auto-detected from variant)
|
|
67
|
+
*/
|
|
68
|
+
block: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
default: void 0
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
emits: ["update:modelValue"],
|
|
74
|
+
setup(__props) {
|
|
75
|
+
/**
|
|
76
|
+
* UiButtonsGroup — Segmented toggle button group for single-select options.
|
|
77
|
+
*
|
|
78
|
+
* Renders a row of UiButton elements styled as a connected group (toolbar or tabs).
|
|
79
|
+
* Only one option can be active at a time (radio-like behavior via v-model).
|
|
80
|
+
* Supports icon-only toolbar mode and text-based tab mode with automatic sizing,
|
|
81
|
+
* rounding, and active/inactive styling.
|
|
82
|
+
*
|
|
83
|
+
* @example Toolbar with icons
|
|
84
|
+
* <UiButtonsGroup v-model="view" :options="[
|
|
85
|
+
* { value: 'grid', icon: 'mdi:view-grid' },
|
|
86
|
+
* { value: 'list', icon: 'mdi:view-list' },
|
|
87
|
+
* ]" />
|
|
88
|
+
*
|
|
89
|
+
* @example Tab-style text group
|
|
90
|
+
* <UiButtonsGroup v-model="tab" variant="tabs" :options="[
|
|
91
|
+
* { value: 'all', label: 'All' },
|
|
92
|
+
* { value: 'active', label: 'Active' },
|
|
93
|
+
* { value: 'archived', label: 'Archived' },
|
|
94
|
+
* ]" />
|
|
95
|
+
*
|
|
96
|
+
* @emits {string | number | boolean} update:modelValue — Emitted when an option is selected
|
|
97
|
+
*
|
|
98
|
+
* @see UiButton — Underlying button component used for each option
|
|
99
|
+
*/
|
|
100
|
+
const props = __props;
|
|
101
|
+
const isBlock = computed(() => props.block ?? props.variant === "tabs");
|
|
102
|
+
const wrapperClass = computed(() => isBlock.value ? "flex items-center rounded-lg" : "inline-flex items-center rounded-lg");
|
|
103
|
+
const containerClass = computed(() => props.variant === "tabs" ? "bg-gray-100 dark:bg-gray-800 p-0.5" : "bg-gray-200/50 dark:bg-gray-800");
|
|
104
|
+
const buttonSize = computed(() => props.variant === "tabs" ? "xs" : props.size);
|
|
105
|
+
const roundingClass = (idx) => {
|
|
106
|
+
const last = props.options.length - 1;
|
|
107
|
+
const radius = props.variant === "tabs" ? "md" : "lg";
|
|
108
|
+
if (props.options.length === 1) return `rounded-${radius}`;
|
|
109
|
+
if (idx === 0) return `rounded-l-${radius} rounded-r-none`;
|
|
110
|
+
if (idx === last) return `rounded-r-${radius} rounded-l-none`;
|
|
111
|
+
return "rounded-none";
|
|
112
|
+
};
|
|
113
|
+
const activeClass = computed(() => props.variant === "tabs" ? "bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-200 shadow-sm hover:bg-white dark:hover:bg-gray-700" : "bg-white dark:bg-gray-700 text-primary-600 dark:text-primary-400 shadow-sm hover:bg-white dark:hover:bg-gray-700");
|
|
114
|
+
const inactiveClass = computed(() => props.variant === "tabs" ? "text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200/50 dark:hover:bg-gray-700/50" : "text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-300/40 dark:hover:bg-gray-700/50");
|
|
115
|
+
return (_ctx, _cache) => {
|
|
116
|
+
return openBlock(), createElementBlock("div", {
|
|
117
|
+
class: normalizeClass([wrapperClass.value, containerClass.value]),
|
|
118
|
+
role: "group"
|
|
119
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.options, (opt, idx) => {
|
|
120
|
+
return openBlock(), createBlock(_sfc_main$2, {
|
|
121
|
+
key: opt.value,
|
|
122
|
+
variant: "ghost",
|
|
123
|
+
"icon-only": !opt.label,
|
|
124
|
+
size: buttonSize.value,
|
|
125
|
+
class: normalizeClass([
|
|
126
|
+
roundingClass(idx),
|
|
127
|
+
__props.modelValue === opt.value ? activeClass.value : inactiveClass.value,
|
|
128
|
+
opt.label ? "flex-1" : ""
|
|
129
|
+
]),
|
|
130
|
+
title: opt.title || opt.label || "",
|
|
131
|
+
onClick: ($event) => _ctx.$emit("update:modelValue", opt.value)
|
|
132
|
+
}, {
|
|
133
|
+
default: withCtx(() => [opt.icon ? (openBlock(), createBlock(_sfc_main$1, {
|
|
134
|
+
key: 0,
|
|
135
|
+
name: opt.icon,
|
|
136
|
+
class: normalizeClass([__props.iconClass, "block"])
|
|
137
|
+
}, null, 8, ["name", "class"])) : createCommentVNode("", true), opt.label ? (openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(opt.label), 1)) : createCommentVNode("", true)]),
|
|
138
|
+
_: 2
|
|
139
|
+
}, 1032, [
|
|
140
|
+
"icon-only",
|
|
141
|
+
"size",
|
|
142
|
+
"class",
|
|
143
|
+
"title",
|
|
144
|
+
"onClick"
|
|
145
|
+
]);
|
|
146
|
+
}), 128))], 2);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
151
|
+
export { _sfc_main as default };
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=ButtonsGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonsGroup.js","names":["$emit"],"sources":["../../src/components/ButtonsGroup.vue"],"sourcesContent":["<template>\n <!-- Segmented button group rendered as a flex row with role=\"group\" -->\n <div :class=\"[wrapperClass, containerClass]\" role=\"group\">\n <UiButton\n v-for=\"(opt, idx) in options\"\n :key=\"opt.value\"\n variant=\"ghost\"\n :icon-only=\"!opt.label\"\n :size=\"buttonSize\"\n :class=\"[\n roundingClass(idx),\n modelValue === opt.value ? activeClass : inactiveClass,\n opt.label ? 'flex-1' : '',\n ]\"\n :title=\"opt.title || opt.label || ''\"\n @click=\"$emit('update:modelValue', opt.value)\"\n >\n <UiIcon v-if=\"opt.icon\" :name=\"opt.icon\" :class=\"iconClass\" class=\"block\" />\n <span v-if=\"opt.label\">{{ opt.label }}</span>\n </UiButton>\n </div>\n</template>\n\n<script setup>\n/**\n * UiButtonsGroup — Segmented toggle button group for single-select options.\n *\n * Renders a row of UiButton elements styled as a connected group (toolbar or tabs).\n * Only one option can be active at a time (radio-like behavior via v-model).\n * Supports icon-only toolbar mode and text-based tab mode with automatic sizing,\n * rounding, and active/inactive styling.\n *\n * @example Toolbar with icons\n * <UiButtonsGroup v-model=\"view\" :options=\"[\n * { value: 'grid', icon: 'mdi:view-grid' },\n * { value: 'list', icon: 'mdi:view-list' },\n * ]\" />\n *\n * @example Tab-style text group\n * <UiButtonsGroup v-model=\"tab\" variant=\"tabs\" :options=\"[\n * { value: 'all', label: 'All' },\n * { value: 'active', label: 'Active' },\n * { value: 'archived', label: 'Archived' },\n * ]\" />\n *\n * @emits {string | number | boolean} update:modelValue — Emitted when an option is selected\n *\n * @see UiButton — Underlying button component used for each option\n */\nimport { computed } from 'vue'\nimport UiButton from './Button.vue'\nimport UiIcon from '../icons/Icon.vue'\nconst props = defineProps({\n /**\n * Currently selected option value (v-model).\n * @type {string | number | boolean}\n * @default ''\n */\n modelValue: { type: [String, Number, Boolean], default: '' },\n\n /**\n * Array of option objects: `{ value, icon?, label?, title? }`.\n * At least `value` is required. Provide `icon` for toolbar mode, `label` for tabs.\n * @type {Array<{ value: string|number, icon?: string, label?: string, title?: string }>}\n * @required\n */\n options: { type: Array, required: true },\n\n /**\n * Visual style of the group.\n * - 'toolbar': compact icon toggles with gray background\n * - 'tabs': text-based tabs with lighter background and smaller buttons\n * @type {string}\n * @default 'toolbar'\n * @values 'toolbar' | 'tabs'\n */\n variant: { type: String, default: 'toolbar' },\n\n /**\n * Icon size class applied to icons in toolbar mode.\n * @type {string}\n * @default 'w-5 h-5'\n */\n iconClass: { type: String, default: 'w-5 h-5' },\n\n /**\n * Button size for toolbar variant (tabs always use 'xs').\n * @type {string}\n * @default 'md'\n * @values 'xs' | 'sm' | 'md'\n */\n size: { type: String, default: 'md' },\n\n /**\n * Full-width mode. Defaults to true for tabs, false for toolbar.\n * @type {boolean}\n * @default undefined (auto-detected from variant)\n */\n block: { type: Boolean, default: undefined },\n})\n\ndefineEmits(['update:modelValue'])\n\n// Block defaults to true for tabs (full-width) and false for toolbar (inline)\nconst isBlock = computed(() => props.block ?? props.variant === 'tabs')\n\nconst wrapperClass = computed(() =>\n isBlock.value ? 'flex items-center rounded-lg' : 'inline-flex items-center rounded-lg',\n)\n\nconst containerClass = computed(() =>\n props.variant === 'tabs'\n ? 'bg-gray-100 dark:bg-gray-800 p-0.5'\n : 'bg-gray-200/50 dark:bg-gray-800',\n)\n\nconst buttonSize = computed(() => (props.variant === 'tabs' ? 'xs' : props.size))\n\n// Apply rounding only to first/last buttons; middle buttons get rounded-none\nconst roundingClass = (idx) => {\n const last = props.options.length - 1\n const radius = props.variant === 'tabs' ? 'md' : 'lg'\n if (props.options.length === 1) return `rounded-${radius}`\n if (idx === 0) return `rounded-l-${radius} rounded-r-none`\n if (idx === last) return `rounded-r-${radius} rounded-l-none`\n return 'rounded-none'\n}\n\nconst activeClass = computed(() =>\n props.variant === 'tabs'\n ? 'bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-200 shadow-sm hover:bg-white dark:hover:bg-gray-700'\n : 'bg-white dark:bg-gray-700 text-primary-600 dark:text-primary-400 shadow-sm hover:bg-white dark:hover:bg-gray-700',\n)\n\nconst inactiveClass = computed(() =>\n props.variant === 'tabs'\n ? 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 hover:bg-gray-200/50 dark:hover:bg-gray-700/50'\n : 'text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-300/40 dark:hover:bg-gray-700/50',\n)\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDA,MAAM,QAAQ;EAoDd,MAAM,UAAU,eAAe,MAAM,SAAS,MAAM,YAAY,MAAM;EAEtE,MAAM,eAAe,eACnB,QAAQ,QAAQ,iCAAiC,qCACnD;EAEA,MAAM,iBAAiB,eACrB,MAAM,YAAY,S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,KAAK,GAAA,CAAA,KAAA,mBAAA,IAAA,IAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { computed, createElementBlock, normalizeClass, openBlock } from "vue";
|
|
2
|
+
//#region src/components/Checkbox.vue
|
|
3
|
+
var _hoisted_1 = ["checked", "disabled"];
|
|
4
|
+
var _sfc_main = {
|
|
5
|
+
__name: "Checkbox",
|
|
6
|
+
props: {
|
|
7
|
+
/**
|
|
8
|
+
* Controlled checked state (v-model). Takes priority over `checked` when defined.
|
|
9
|
+
* @type {boolean}
|
|
10
|
+
* @default undefined
|
|
11
|
+
*/
|
|
12
|
+
modelValue: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: void 0
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* Uncontrolled initial checked state (used when modelValue is undefined).
|
|
18
|
+
* @type {boolean}
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
checked: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Disabled state — dims the checkbox and prevents interaction.
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
disabled: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
/**
|
|
35
|
+
* Checkbox size controlling width and height.
|
|
36
|
+
* @type {string}
|
|
37
|
+
* @default 'md'
|
|
38
|
+
* @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)
|
|
39
|
+
*/
|
|
40
|
+
size: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "md"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
emits: ["update:modelValue", "change"],
|
|
46
|
+
setup(__props, { emit: __emit }) {
|
|
47
|
+
/**
|
|
48
|
+
* UiCheckbox — Simple styled checkbox input with configurable size.
|
|
49
|
+
*
|
|
50
|
+
* Wraps a native `<input type="checkbox">` with consistent Tailwind styling,
|
|
51
|
+
* primary color accent, and focus ring. Supports both v-model (`modelValue`)
|
|
52
|
+
* and uncontrolled (`checked`) usage patterns.
|
|
53
|
+
*
|
|
54
|
+
* @example Basic v-model checkbox
|
|
55
|
+
* <UiCheckbox v-model="agreed" />
|
|
56
|
+
*
|
|
57
|
+
* @example Small disabled checkbox
|
|
58
|
+
* <UiCheckbox v-model="locked" size="sm" disabled />
|
|
59
|
+
*
|
|
60
|
+
* @example Uncontrolled with checked prop
|
|
61
|
+
* <UiCheckbox :checked="true" @change="handleChange" />
|
|
62
|
+
*
|
|
63
|
+
* @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)
|
|
64
|
+
* @emits {Event} change — Emitted with the native change event
|
|
65
|
+
*/
|
|
66
|
+
const props = __props;
|
|
67
|
+
const emit = __emit;
|
|
68
|
+
const sizeClass = computed(() => {
|
|
69
|
+
switch (props.size) {
|
|
70
|
+
case "sm": return "w-3.5 h-3.5";
|
|
71
|
+
case "lg": return "w-5 h-5";
|
|
72
|
+
default: return "w-4 h-4";
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
function onChange(e) {
|
|
76
|
+
emit("update:modelValue", e.target.checked);
|
|
77
|
+
emit("change", e);
|
|
78
|
+
}
|
|
79
|
+
return (_ctx, _cache) => {
|
|
80
|
+
return openBlock(), createElementBlock("input", {
|
|
81
|
+
type: "checkbox",
|
|
82
|
+
checked: __props.modelValue ?? __props.checked,
|
|
83
|
+
disabled: __props.disabled,
|
|
84
|
+
class: normalizeClass(["rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500", sizeClass.value]),
|
|
85
|
+
onChange
|
|
86
|
+
}, null, 42, _hoisted_1);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { _sfc_main as default };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.vue"],"sourcesContent":["<template>\n <input\n type=\"checkbox\"\n :checked=\"modelValue ?? checked\"\n :disabled=\"disabled\"\n class=\"rounded border-gray-300 dark:border-gray-600 text-primary-600 focus:ring-primary-500\"\n :class=\"sizeClass\"\n @change=\"onChange\"\n />\n</template>\n\n<script setup>\n/**\n * UiCheckbox — Simple styled checkbox input with configurable size.\n *\n * Wraps a native `<input type=\"checkbox\">` with consistent Tailwind styling,\n * primary color accent, and focus ring. Supports both v-model (`modelValue`)\n * and uncontrolled (`checked`) usage patterns.\n *\n * @example Basic v-model checkbox\n * <UiCheckbox v-model=\"agreed\" />\n *\n * @example Small disabled checkbox\n * <UiCheckbox v-model=\"locked\" size=\"sm\" disabled />\n *\n * @example Uncontrolled with checked prop\n * <UiCheckbox :checked=\"true\" @change=\"handleChange\" />\n *\n * @emits {boolean} update:modelValue — Emitted when the checked state changes (v-model)\n * @emits {Event} change — Emitted with the native change event\n */\nimport { computed } from 'vue'\nconst props = defineProps({\n /**\n * Controlled checked state (v-model). Takes priority over `checked` when defined.\n * @type {boolean}\n * @default undefined\n */\n modelValue: { type: Boolean, default: undefined },\n\n /**\n * Uncontrolled initial checked state (used when modelValue is undefined).\n * @type {boolean}\n * @default false\n */\n checked: { type: Boolean, default: false },\n\n /**\n * Disabled state — dims the checkbox and prevents interaction.\n * @type {boolean}\n * @default false\n */\n disabled: { type: Boolean, default: false },\n\n /**\n * Checkbox size controlling width and height.\n * @type {string}\n * @default 'md'\n * @values 'sm' (3.5×3.5) | 'md' (4×4) | 'lg' (5×5)\n */\n size: { type: String, default: 'md' },\n})\n\nconst emit = defineEmits(['update:modelValue', 'change'])\n\nconst sizeClass = computed(() => {\n switch (props.size) {\n case 'sm':\n return 'w-3.5 h-3.5'\n case 'lg':\n return 'w-5 h-5'\n default:\n return 'w-4 h-4'\n }\n})\n\nfunction onChange(e) {\n emit('update:modelValue', e.target.checked)\n emit('change', e)\n}\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCA,MAAM,QAAQ;EA+Bd,MAAM,OAAO;EAEb,MAAM,YAAY,eAAe;GAC/B,QAAQ,MAAM,MAAd;IACE,KAAK,MACH,OAAO;IACT,KAAK,MACH,OAAO;IACT,SACE,OAAO;GACX;EACF,CAAC;EAED,SAAS,SAAS,GAAG;GACnB,KAAK,qBAAqB,EAAE,OAAO,OAAO;GAC1C,KAAK,UAAU,CAAC;EAClB;;GA9EE,OAAA,UAAA,GAAA,mBAOE,SAAA;IANA,MAAK;IACJ,SAAS,QAAA,cAAc,QAAA;IACvB,UAAU,QAAA;IACX,OAAK,eAAA,CAAC,wFACE,UAAA,KAAS,CAAA;IACR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { computed, createElementBlock, normalizeClass, openBlock } from "vue";
|
|
2
|
+
//#region src/components/Divider.vue
|
|
3
|
+
var horizontalClasses = "border-t my-1";
|
|
4
|
+
var verticalClasses = "w-px h-5 mx-1";
|
|
5
|
+
var _sfc_main = {
|
|
6
|
+
__name: "Divider",
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* Divider orientation.
|
|
10
|
+
* @type {string}
|
|
11
|
+
* @default 'horizontal'
|
|
12
|
+
* @values 'horizontal' | 'vertical'
|
|
13
|
+
*/
|
|
14
|
+
direction: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "horizontal"
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Color intensity preset.
|
|
20
|
+
* - 'light': subtle (gray-100/gray-700) — dropdown menus
|
|
21
|
+
* - 'medium': standard (gray-200/gray-700) — context menus, content sections
|
|
22
|
+
* - 'dark': stronger (gray-300/gray-600) — account menus, prominent separators
|
|
23
|
+
* @type {string}
|
|
24
|
+
* @default 'light'
|
|
25
|
+
* @values 'light' | 'medium' | 'dark'
|
|
26
|
+
*/
|
|
27
|
+
color: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "light"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
setup(__props) {
|
|
33
|
+
/**
|
|
34
|
+
* UiDivider — Visual separator line for menus, toolbars, and content sections.
|
|
35
|
+
*
|
|
36
|
+
* Renders a thin line either horizontally (full-width border-top) or vertically
|
|
37
|
+
* (1px-wide column). Supports three color presets matching common usage contexts.
|
|
38
|
+
*
|
|
39
|
+
* @example Horizontal menu divider
|
|
40
|
+
* <UiDivider />
|
|
41
|
+
*
|
|
42
|
+
* @example Vertical toolbar separator
|
|
43
|
+
* <UiDivider direction="vertical" />
|
|
44
|
+
*
|
|
45
|
+
* @example Darker divider
|
|
46
|
+
* <UiDivider color="medium" />
|
|
47
|
+
*/
|
|
48
|
+
const props = __props;
|
|
49
|
+
const colorClass = computed(() => {
|
|
50
|
+
if (props.direction === "vertical") {
|
|
51
|
+
const map = {
|
|
52
|
+
light: "bg-gray-300/60 dark:bg-gray-700",
|
|
53
|
+
medium: "bg-gray-300/60 dark:bg-gray-700",
|
|
54
|
+
dark: "bg-gray-300 dark:bg-gray-600"
|
|
55
|
+
};
|
|
56
|
+
return map[props.color] || map.light;
|
|
57
|
+
}
|
|
58
|
+
const map = {
|
|
59
|
+
light: "border-gray-100 dark:border-gray-700",
|
|
60
|
+
medium: "border-gray-200 dark:border-gray-700",
|
|
61
|
+
dark: "border-gray-300 dark:border-gray-600"
|
|
62
|
+
};
|
|
63
|
+
return map[props.color] || map.light;
|
|
64
|
+
});
|
|
65
|
+
return (_ctx, _cache) => {
|
|
66
|
+
return __props.direction === "vertical" ? (openBlock(), createElementBlock("div", {
|
|
67
|
+
key: 0,
|
|
68
|
+
class: normalizeClass(["shrink-0", [verticalClasses, colorClass.value]])
|
|
69
|
+
}, null, 2)) : (openBlock(), createElementBlock("div", {
|
|
70
|
+
key: 1,
|
|
71
|
+
class: normalizeClass([horizontalClasses, colorClass.value])
|
|
72
|
+
}, null, 2));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
//#endregion
|
|
77
|
+
export { _sfc_main as default };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=Divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.js","names":[],"sources":["../../src/components/Divider.vue"],"sourcesContent":["<template>\n <div v-if=\"direction === 'vertical'\" class=\"shrink-0\" :class=\"[verticalClasses, colorClass]\" />\n <div v-else :class=\"[horizontalClasses, colorClass]\" />\n</template>\n\n<script setup>\n/**\n * UiDivider — Visual separator line for menus, toolbars, and content sections.\n *\n * Renders a thin line either horizontally (full-width border-top) or vertically\n * (1px-wide column). Supports three color presets matching common usage contexts.\n *\n * @example Horizontal menu divider\n * <UiDivider />\n *\n * @example Vertical toolbar separator\n * <UiDivider direction=\"vertical\" />\n *\n * @example Darker divider\n * <UiDivider color=\"medium\" />\n */\nimport { computed } from 'vue'\nconst props = defineProps({\n /**\n * Divider orientation.\n * @type {string}\n * @default 'horizontal'\n * @values 'horizontal' | 'vertical'\n */\n direction: { type: String, default: 'horizontal' },\n\n /**\n * Color intensity preset.\n * - 'light': subtle (gray-100/gray-700) — dropdown menus\n * - 'medium': standard (gray-200/gray-700) — context menus, content sections\n * - 'dark': stronger (gray-300/gray-600) — account menus, prominent separators\n * @type {string}\n * @default 'light'\n * @values 'light' | 'medium' | 'dark'\n */\n color: { type: String, default: 'light' },\n})\n\nconst horizontalClasses = 'border-t my-1'\n\nconst verticalClasses = 'w-px h-5 mx-1'\n\nconst colorClass = computed(() => {\n if (props.direction === 'vertical') {\n const map = {\n light: 'bg-gray-300/60 dark:bg-gray-700',\n medium: 'bg-gray-300/60 dark:bg-gray-700',\n dark: 'bg-gray-300 dark:bg-gray-600',\n }\n return map[props.color] || map.light\n }\n const map = {\n light: 'border-gray-100 dark:border-gray-700',\n medium: 'border-gray-200 dark:border-gray-700',\n dark: 'border-gray-300 dark:border-gray-600',\n }\n return map[props.color] || map.light\n})\n</script>\n"],"mappings":";;AA2CA,IAAM,oBAAoB;AAE1B,IAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAvBxB,MAAM,QAAQ;EAyBd,MAAM,aAAa,eAAe;GAChC,IAAI,MAAM,cAAc,YAAY;IAClC,MAAM,MAAM;KACV,OAAO;KACP,QAAQ;KACR,MAAM;IACR;IACA,OAAO,IAAI,MAAM,UAAU,IAAI;GACjC;GACA,MAAM,MAAM;IACV,OAAO;IACP,QAAQ;IACR,MAAM;GACR;GACA,OAAO,IAAI,MAAM,UAAU,IAAI;EACjC,CAAC;;GA7DY,OAAA,QAAA,cAAS,cAApB,UAAA,GAAA,mBAA+F,OAAA;;IAA1D,OAAK,eAAA,CAAC,YAAU,CAAU,iBAAiB,WAAA,KAAU,CAAA,CAAA;GAC1F,GAAA,MAAA,CAAA,MAAA,UAAA,GAAA,mBAAuD,OAAA;;IAA1C,OAAK,eAAA,CAAG,mBAAmB,WAAA,KAAU,CAAA"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { useEventListener } from "../composables/useEventListener.js";
|
|
2
|
+
import { onClickOutside } from "../composables/onClickOutside.js";
|
|
3
|
+
import { Transition, computed, createElementBlock, createElementVNode, createVNode, normalizeClass, openBlock, ref, renderSlot, vShow, withCtx, withDirectives } from "vue";
|
|
4
|
+
//#region src/components/Dropdown.vue
|
|
5
|
+
var _sfc_main = {
|
|
6
|
+
__name: "Dropdown",
|
|
7
|
+
props: {
|
|
8
|
+
/**
|
|
9
|
+
* Width class applied to the dropdown panel.
|
|
10
|
+
* @type {string}
|
|
11
|
+
* @default 'w-56'
|
|
12
|
+
* @example 'w-48', 'w-64', 'w-72'
|
|
13
|
+
*/
|
|
14
|
+
width: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: "w-56"
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* Horizontal alignment of the panel relative to the trigger.
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @default 'left'
|
|
22
|
+
* @values 'left' | 'right'
|
|
23
|
+
*/
|
|
24
|
+
align: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: "left"
|
|
27
|
+
},
|
|
28
|
+
/**
|
|
29
|
+
* Drop direction — 'down' opens below the trigger, 'up' opens above.
|
|
30
|
+
* @type {string}
|
|
31
|
+
* @default 'down'
|
|
32
|
+
* @values 'down' | 'up'
|
|
33
|
+
*/
|
|
34
|
+
drop: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: "down"
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Override all default panel classes (bg, border, rounded, shadow).
|
|
40
|
+
* When set, the built-in panel styling is completely replaced.
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @default ''
|
|
43
|
+
*/
|
|
44
|
+
panelClass: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: ""
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
emits: ["open", "close"],
|
|
50
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
51
|
+
/**
|
|
52
|
+
* UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.
|
|
53
|
+
*
|
|
54
|
+
* Uses a trigger slot that receives `open` state and `toggle` function, and a default
|
|
55
|
+
* slot for menu content that receives a `close` function. Closes on outside click and
|
|
56
|
+
* Escape key. Supports both downward and upward drop directions with matching transitions.
|
|
57
|
+
* Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.
|
|
58
|
+
*
|
|
59
|
+
* @example Basic dropdown with button trigger
|
|
60
|
+
* <UiDropdown>
|
|
61
|
+
* <template #trigger="{ toggle }">
|
|
62
|
+
* <UiButton @click="toggle">Menu</UiButton>
|
|
63
|
+
* </template>
|
|
64
|
+
* <UiDropdownItem icon="mdi:pencil" label="Edit" @click="edit" />
|
|
65
|
+
* <UiDropdownItem icon="mdi:trash-can" label="Delete" color="red" @click="del" />
|
|
66
|
+
* </UiDropdown>
|
|
67
|
+
*
|
|
68
|
+
* @example Right-aligned, drop-up
|
|
69
|
+
* <UiDropdown align="right" drop="up" width="w-48">
|
|
70
|
+
* <template #trigger="{ toggle }">
|
|
71
|
+
* <UiButton variant="ghost" icon-only @click="toggle">
|
|
72
|
+
* <UiIcon name="mdi:dots-vertical" class="w-5 h-5" />
|
|
73
|
+
* </UiButton>
|
|
74
|
+
* </template>
|
|
75
|
+
* <slot />
|
|
76
|
+
* </UiDropdown>
|
|
77
|
+
*
|
|
78
|
+
* @emits {void} open — Emitted when the dropdown opens
|
|
79
|
+
* @emits {void} close — Emitted when the dropdown closes
|
|
80
|
+
*
|
|
81
|
+
* @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }
|
|
82
|
+
* @slot default — Dropdown menu content. Receives { close: Function }
|
|
83
|
+
*
|
|
84
|
+
* @see UiDropdownItem — Standard menu item for use inside this dropdown
|
|
85
|
+
* @see UiDropdownSubmenu — Nested submenu for this dropdown
|
|
86
|
+
*/
|
|
87
|
+
const props = __props;
|
|
88
|
+
const emit = __emit;
|
|
89
|
+
const isOpen = ref(false);
|
|
90
|
+
const containerRef = ref(null);
|
|
91
|
+
const panelClasses = computed(() => {
|
|
92
|
+
if (props.panelClass) return props.panelClass;
|
|
93
|
+
const align = props.align === "right" ? "right-0" : "left-0";
|
|
94
|
+
const dropDir = props.drop === "up" ? "bottom-full mb-1" : "mt-1";
|
|
95
|
+
return `absolute z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 ${props.width} ${align} ${dropDir}`;
|
|
96
|
+
});
|
|
97
|
+
const transitionClasses = computed(() => {
|
|
98
|
+
if (props.drop === "up") return {
|
|
99
|
+
enterActive: "transition ease-out duration-150",
|
|
100
|
+
enterFrom: "opacity-0 translate-y-1",
|
|
101
|
+
enterTo: "opacity-100 translate-y-0",
|
|
102
|
+
leaveActive: "transition ease-in duration-100",
|
|
103
|
+
leaveFrom: "opacity-100 translate-y-0",
|
|
104
|
+
leaveTo: "opacity-0 translate-y-1"
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
enterActive: "transition duration-100 ease-out",
|
|
108
|
+
enterFrom: "opacity-0 scale-95",
|
|
109
|
+
enterTo: "opacity-100 scale-100",
|
|
110
|
+
leaveActive: "transition duration-75 ease-in",
|
|
111
|
+
leaveFrom: "opacity-100 scale-100",
|
|
112
|
+
leaveTo: "opacity-0 scale-95"
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
const toggle = () => {
|
|
116
|
+
isOpen.value = !isOpen.value;
|
|
117
|
+
emit(isOpen.value ? "open" : "close");
|
|
118
|
+
};
|
|
119
|
+
const close = () => {
|
|
120
|
+
if (isOpen.value) {
|
|
121
|
+
isOpen.value = false;
|
|
122
|
+
emit("close");
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
onClickOutside(containerRef, close);
|
|
126
|
+
useEventListener(globalThis.document, "keydown", (e) => {
|
|
127
|
+
if (e.key === "Escape") close();
|
|
128
|
+
});
|
|
129
|
+
__expose({
|
|
130
|
+
isOpen,
|
|
131
|
+
toggle,
|
|
132
|
+
close
|
|
133
|
+
});
|
|
134
|
+
return (_ctx, _cache) => {
|
|
135
|
+
return openBlock(), createElementBlock("div", {
|
|
136
|
+
ref_key: "containerRef",
|
|
137
|
+
ref: containerRef,
|
|
138
|
+
class: "relative"
|
|
139
|
+
}, [renderSlot(_ctx.$slots, "trigger", {
|
|
140
|
+
open: isOpen.value,
|
|
141
|
+
toggle
|
|
142
|
+
}), createVNode(Transition, {
|
|
143
|
+
"enter-active-class": transitionClasses.value.enterActive,
|
|
144
|
+
"enter-from-class": transitionClasses.value.enterFrom,
|
|
145
|
+
"enter-to-class": transitionClasses.value.enterTo,
|
|
146
|
+
"leave-active-class": transitionClasses.value.leaveActive,
|
|
147
|
+
"leave-from-class": transitionClasses.value.leaveFrom,
|
|
148
|
+
"leave-to-class": transitionClasses.value.leaveTo
|
|
149
|
+
}, {
|
|
150
|
+
default: withCtx(() => [withDirectives(createElementVNode("div", { class: normalizeClass(panelClasses.value) }, [renderSlot(_ctx.$slots, "default", { close })], 2), [[vShow, isOpen.value]])]),
|
|
151
|
+
_: 3
|
|
152
|
+
}, 8, [
|
|
153
|
+
"enter-active-class",
|
|
154
|
+
"enter-from-class",
|
|
155
|
+
"enter-to-class",
|
|
156
|
+
"leave-active-class",
|
|
157
|
+
"leave-from-class",
|
|
158
|
+
"leave-to-class"
|
|
159
|
+
])], 512);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
export { _sfc_main as default };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropdown.js","names":[],"sources":["../../src/components/Dropdown.vue"],"sourcesContent":["<template>\n <div ref=\"containerRef\" class=\"relative\">\n <!-- Trigger slot: receives { open, toggle } for controlling the dropdown -->\n <slot name=\"trigger\" :open=\"isOpen\" :toggle=\"toggle\" />\n\n <!-- Dropdown panel with animated enter/leave transitions -->\n <Transition\n :enter-active-class=\"transitionClasses.enterActive\"\n :enter-from-class=\"transitionClasses.enterFrom\"\n :enter-to-class=\"transitionClasses.enterTo\"\n :leave-active-class=\"transitionClasses.leaveActive\"\n :leave-from-class=\"transitionClasses.leaveFrom\"\n :leave-to-class=\"transitionClasses.leaveTo\"\n >\n <div v-show=\"isOpen\" :class=\"panelClasses\">\n <slot :close=\"close\" />\n </div>\n </Transition>\n </div>\n</template>\n\n<script setup>\n/**\n * UiDropdown — Headless dropdown menu with configurable alignment, direction, and transitions.\n *\n * Uses a trigger slot that receives `open` state and `toggle` function, and a default\n * slot for menu content that receives a `close` function. Closes on outside click and\n * Escape key. Supports both downward and upward drop directions with matching transitions.\n * Exposes `isOpen`, `toggle()`, and `close()` for programmatic control.\n *\n * @example Basic dropdown with button trigger\n * <UiDropdown>\n * <template #trigger=\"{ toggle }\">\n * <UiButton @click=\"toggle\">Menu</UiButton>\n * </template>\n * <UiDropdownItem icon=\"mdi:pencil\" label=\"Edit\" @click=\"edit\" />\n * <UiDropdownItem icon=\"mdi:trash-can\" label=\"Delete\" color=\"red\" @click=\"del\" />\n * </UiDropdown>\n *\n * @example Right-aligned, drop-up\n * <UiDropdown align=\"right\" drop=\"up\" width=\"w-48\">\n * <template #trigger=\"{ toggle }\">\n * <UiButton variant=\"ghost\" icon-only @click=\"toggle\">\n * <UiIcon name=\"mdi:dots-vertical\" class=\"w-5 h-5\" />\n * </UiButton>\n * </template>\n * <slot />\n * </UiDropdown>\n *\n * @emits {void} open — Emitted when the dropdown opens\n * @emits {void} close — Emitted when the dropdown closes\n *\n * @slot trigger — Trigger element that opens the dropdown. Receives { open: boolean, toggle: Function }\n * @slot default — Dropdown menu content. Receives { close: Function }\n *\n * @see UiDropdownItem — Standard menu item for use inside this dropdown\n * @see UiDropdownSubmenu — Nested submenu for this dropdown\n */\nimport { ref, computed } from 'vue'\nimport { onClickOutside } from '../composables/onClickOutside.js'\nimport { useEventListener } from '../composables/useEventListener.js'\nconst props = defineProps({\n /**\n * Width class applied to the dropdown panel.\n * @type {string}\n * @default 'w-56'\n * @example 'w-48', 'w-64', 'w-72'\n */\n width: { type: String, default: 'w-56' },\n\n /**\n * Horizontal alignment of the panel relative to the trigger.\n * @type {string}\n * @default 'left'\n * @values 'left' | 'right'\n */\n align: { type: String, default: 'left' },\n\n /**\n * Drop direction — 'down' opens below the trigger, 'up' opens above.\n * @type {string}\n * @default 'down'\n * @values 'down' | 'up'\n */\n drop: { type: String, default: 'down' },\n\n /**\n * Override all default panel classes (bg, border, rounded, shadow).\n * When set, the built-in panel styling is completely replaced.\n * @type {string}\n * @default ''\n */\n panelClass: { type: String, default: '' },\n})\n\nconst emit = defineEmits(['open', 'close'])\n\nconst isOpen = ref(false)\nconst containerRef = ref(null)\n\n// Build panel positioning/styling classes, or use custom override\nconst panelClasses = computed(() => {\n if (props.panelClass) return props.panelClass\n const align = props.align === 'right' ? 'right-0' : 'left-0'\n const dropDir = props.drop === 'up' ? 'bottom-full mb-1' : 'mt-1'\n return `absolute z-50 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg py-1 ${props.width} ${align} ${dropDir}`\n})\n\n// Use slide-up transition for drop=\"up\", scale transition for drop=\"down\"\nconst transitionClasses = computed(() => {\n if (props.drop === 'up') {\n return {\n enterActive: 'transition ease-out duration-150',\n enterFrom: 'opacity-0 translate-y-1',\n enterTo: 'opacity-100 translate-y-0',\n leaveActive: 'transition ease-in duration-100',\n leaveFrom: 'opacity-100 translate-y-0',\n leaveTo: 'opacity-0 translate-y-1',\n }\n }\n return {\n enterActive: 'transition duration-100 ease-out',\n enterFrom: 'opacity-0 scale-95',\n enterTo: 'opacity-100 scale-100',\n leaveActive: 'transition duration-75 ease-in',\n leaveFrom: 'opacity-100 scale-100',\n leaveTo: 'opacity-0 scale-95',\n }\n})\n\nconst toggle = () => {\n isOpen.value = !isOpen.value\n emit(isOpen.value ? 'open' : 'close')\n}\n\nconst close = () => {\n if (isOpen.value) {\n isOpen.value = false\n emit('close')\n }\n}\n\nonClickOutside(containerRef, close)\n\nuseEventListener(globalThis.document, 'keydown', (e) => {\n if (e.key === 'Escape') close()\n})\n\ndefineExpose({ isOpen, toggle, close })\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6DA,MAAM,QAAQ;EAkCd,MAAM,OAAO;EAEb,MAAM,SAAS,IAAI,KAAK;EACxB,MAAM,eAAe,IAAI,IAAI;EAG7B,MAAM,eAAe,eAAe;GAClC,IAAI,MAAM,YAAY,OAAO,MAAM;GACnC,MAAM,QAAQ,MAAM,UAAU,UAAU,YAAY;GACpD,MAAM,UAAU,MAAM,SAAS,OAAO,qBAAqB;GAC3D,OAAO,iHA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