@mcistudio/unoui-vue 1.2.5 → 1.2.7
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/dist/chunks/{Table-M8DquYXh.js → Table-DFBQntI1.js} +3 -2
- package/dist/chunks/Table-DFBQntI1.js.map +1 -0
- package/dist/chunks/{colorpicker-B-kSQ2Gh.js → colorpicker-CyhB3GJP.js} +227 -204
- package/dist/chunks/colorpicker-CyhB3GJP.js.map +1 -0
- package/dist/chunks/drawer-BgGY0UFF.js +197 -0
- package/dist/chunks/drawer-BgGY0UFF.js.map +1 -0
- package/dist/chunks/{input-FN9FbBR8.js → input-CiYVpf72.js} +5 -5
- package/dist/chunks/input-CiYVpf72.js.map +1 -0
- package/dist/chunks/internal-drag-B2-9vftX.js +29 -0
- package/dist/chunks/internal-drag-B2-9vftX.js.map +1 -0
- package/dist/chunks/modal-BqB5SsLw.js +82 -0
- package/dist/chunks/modal-BqB5SsLw.js.map +1 -0
- package/dist/chunks/{pagination-DCJuheFj.js → pagination-zi5YKmBI.js} +2 -2
- package/dist/chunks/{pagination-DCJuheFj.js.map → pagination-zi5YKmBI.js.map} +1 -1
- package/dist/chunks/{slider-Z03Wx_8m.js → slider-DoS0hURd.js} +3 -3
- package/dist/chunks/slider-DoS0hURd.js.map +1 -0
- package/dist/colorpicker/index.js +1 -1
- package/dist/drawer/index.js +1 -1
- package/dist/index.js +7 -7
- package/dist/input/index.js +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/pagination/index.js +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/table/index.js +1 -1
- package/dist/utils/internal-drag.d.ts +7 -0
- package/package.json +1 -1
- package/dist/chunks/Table-M8DquYXh.js.map +0 -1
- package/dist/chunks/colorpicker-B-kSQ2Gh.js.map +0 -1
- package/dist/chunks/drawer-C3JZ28Xo.js +0 -193
- package/dist/chunks/drawer-C3JZ28Xo.js.map +0 -1
- package/dist/chunks/input-FN9FbBR8.js.map +0 -1
- package/dist/chunks/modal-D6l1iIvE.js +0 -81
- package/dist/chunks/modal-D6l1iIvE.js.map +0 -1
- package/dist/chunks/slider-Z03Wx_8m.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Table-M8DquYXh.js","names":[],"sources":["../../src/table/Table.vue","../../src/table/Table.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T extends TableRow = TableRow\">\nimport { clsx } from 'clsx'\nimport SimpleBar from 'simplebar-vue'\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { Button } from '../button'\nimport { Dropdown } from '../dropdown'\n\nimport '../assets/simplebar.css'\nimport 'simplebar-vue/dist/simplebar.min.css'\n\nimport type { TableColumn, TableFiltersState, TableRadius, TableRow, TableSize, TableSortState } from './types'\n\ninterface ColumnState {\n column: TableColumn<T>\n index: number\n fixed?: 'left' | 'right'\n left?: number\n right?: number\n isLeftEdge: boolean\n isRightEdge: boolean\n}\n\ntype SimpleBarComponent = InstanceType<typeof SimpleBar> & {\n recalculate?: () => void\n getScrollElement?: () => HTMLElement\n $el?: HTMLElement\n}\n\nconst props = withDefaults(\n defineProps<{\n /** rows 是表格原始数据源。 */\n rows: T[]\n /** columns 是列配置,控制渲染、排序、筛选和固定列。 */\n columns: TableColumn<T>[]\n /** rowKey 是行唯一键字段或取值函数。 */\n rowKey: keyof T | string | ((row: T, index: number) => string | number)\n /** sort 传入后表格排序变为受控状态。 */\n sort?: TableSortState | null\n /** defaultSort 是非受控排序初始值。 */\n defaultSort?: TableSortState | null\n /** filters 传入后表格筛选变为受控状态。 */\n filters?: TableFiltersState\n /** defaultFilters 是非受控筛选初始值。 */\n defaultFilters?: TableFiltersState\n /** maxHeight 是 SimpleBar 滚动区域最大高度。 */\n maxHeight?: string\n /** minWidth 是表格整体最小宽度。 */\n minWidth?: string\n /** stickyHeader 控制是否固定表头。 */\n stickyHeader?: boolean\n /** allowClearSort 控制排序是否允许从降序再次点击后清空。 */\n allowClearSort?: boolean\n /** stripe 控制是否展示斑马纹行背景。 */\n stripe?: boolean\n /** radius 控制表格外框圆角。 */\n radius?: TableRadius\n /** size 控制表格字号和行高。 */\n size?: TableSize\n /** showHorizontalLines 控制是否展示横向表格线。 */\n showHorizontalLines?: boolean\n /** showVerticalLines 控制是否展示纵向表格线。 */\n showVerticalLines?: boolean\n /** bordered 控制是否展示外边框。 */\n bordered?: boolean\n /** autoHideScrollbar 控制 SimpleBar 滚动条是否自动隐藏。 */\n autoHideScrollbar?: boolean\n /** emptyText 是空数据文案。 */\n emptyText?: string\n /** filterResetText 是筛选菜单清空按钮文案。 */\n filterResetText?: string\n /** filterEmptyText 是筛选菜单无选项文案。 */\n filterEmptyText?: string\n }>(),\n {\n defaultSort: null,\n defaultFilters: () => ({}),\n stickyHeader: true,\n allowClearSort: true,\n stripe: false,\n radius: 'md',\n size: 'md',\n showHorizontalLines: true,\n showVerticalLines: false,\n bordered: true,\n autoHideScrollbar: false,\n emptyText: '暂无数据',\n filterResetText: '清空',\n filterEmptyText: '暂无选项'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:sort', value: TableSortState | null): void\n (e: 'sort-change', value: TableSortState | null): void\n (e: 'update:filters', value: TableFiltersState): void\n (e: 'filter-change', value: TableFiltersState): void\n (e: 'row-click', row: T, index: number): void\n}>()\n\nconst simplebarRef = ref<SimpleBarComponent | null>(null)\nconst tableRootRef = useTemplateRef<HTMLElement>('tableRoot')\nconst tableElementRef = useTemplateRef<HTMLTableElement>('tableElement')\nconst internalSort = ref<TableSortState | null>(props.defaultSort)\nconst internalFilters = ref<TableFiltersState>({ ...props.defaultFilters })\nconst hasScrollLeft = ref(false)\nconst hasScrollRight = ref(false)\nconst hasScrollY = ref(false)\nlet resizeObserver: ResizeObserver | null = null\nlet resizeFrame = 0\nlet scrollStateFrame = 0\n\nconst radiusClass = computed(() => {\n const map: Record<TableRadius, string> = {\n none: 'rounded-none',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg'\n }\n return map[props.radius]\n})\n\nconst sizeClasses = computed(() => {\n const map: Record<TableSize, { table: string; header: string; cell: string; empty: string }> = {\n md: {\n table: 'text-sm leading-5',\n header: 'px-3 py-2 text-xs',\n cell: 'px-3 py-2 text-secondary',\n empty: 'px-3 py-10 text-sm'\n },\n lg: {\n table: 'text-base leading-6',\n header: 'px-4 py-3 text-sm',\n cell: 'px-4 py-3 text-secondary',\n empty: 'px-4 py-12 text-base'\n }\n }\n return map[props.size]\n})\n\nconst activeSort = computed(() => (props.sort === undefined ? internalSort.value : props.sort))\nconst activeFilters = computed(() => (props.filters === undefined ? internalFilters.value : props.filters))\n\nconst toCssLength = (value?: number | string) => {\n if (typeof value === 'number') return `${value}px`\n return value\n}\n\nconst toPixelWidth = (value?: number | string) => {\n if (typeof value === 'number') return value\n const match = value?.match(/^(\\d+(?:\\.\\d+)?)px$/)\n return match ? Number(match[1]) : 0\n}\n\nconst columnWidth = (column: TableColumn<T>) => toPixelWidth(column.width ?? column.minWidth)\n\nconst columnStates = computed<ColumnState[]>(() => {\n const states: ColumnState[] = props.columns.map((column, index) => ({\n column,\n index,\n fixed: column.fixed,\n isLeftEdge: false,\n isRightEdge: false\n }))\n\n let left = 0\n states.forEach((state) => {\n if (state.fixed !== 'left') return\n state.left = left\n left += columnWidth(state.column)\n })\n\n let right = 0\n ;[...states].reverse().forEach((state) => {\n if (state.fixed !== 'right') return\n state.right = right\n right += columnWidth(state.column)\n })\n\n const leftFixed = states.filter((state) => state.fixed === 'left')\n const rightFixed = states.filter((state) => state.fixed === 'right')\n const leftEdge = leftFixed.at(-1)\n const rightEdge = rightFixed[0]\n if (leftEdge) leftEdge.isLeftEdge = true\n if (rightEdge) rightEdge.isRightEdge = true\n\n return states\n})\n\nconst tableStyle = computed(() => ({\n minWidth: props.minWidth || undefined\n}))\n\nconst scrollStyle = computed(() => ({\n maxHeight: props.maxHeight,\n overflowY: props.maxHeight ? undefined : 'hidden'\n}))\n\nconst tableLayoutSignature = computed(() => props.columns.map((column) => [column.key, column.width ?? '', column.minWidth ?? '', column.maxWidth ?? '', column.fixed ?? ''].join(':')).join('|'))\n\nconst getScrollElement = () => {\n const current = simplebarRef.value\n if (!current) return null\n if (typeof current.getScrollElement === 'function') return current.getScrollElement()\n return current.$el?.querySelector('.simplebar-content-wrapper') as HTMLElement | null\n}\n\nconst isHorizontalThumbAtStart = () => {\n const simplebarElement = simplebarRef.value?.$el\n const track = simplebarElement?.querySelector('.simplebar-track.simplebar-horizontal')\n const thumb = track?.querySelector('.simplebar-scrollbar')\n const trackRect = track?.getBoundingClientRect()\n const thumbRect = thumb?.getBoundingClientRect()\n if (!trackRect || !thumbRect || thumbRect.width <= 0) return false\n return thumbRect.left - trackRect.left <= 2\n}\n\n// 同步水平滚动状态,用于固定列边缘阴影。\nconst updateScrollState = () => {\n const el = getScrollElement()\n if (!el) return\n hasScrollLeft.value = el.scrollLeft > 2 && !isHorizontalThumbAtStart()\n hasScrollRight.value = el.scrollLeft + el.clientWidth < el.scrollWidth - 1\n hasScrollY.value = el.scrollHeight - el.clientHeight > 2\n}\n\nconst handleScroll = () => updateScrollState()\n\nconst stopScrollStateLoop = () => {\n if (!scrollStateFrame) return\n cancelAnimationFrame(scrollStateFrame)\n scrollStateFrame = 0\n}\n\nconst runScrollStateLoop = () => {\n updateScrollState()\n\n const simplebarElement = simplebarRef.value?.$el\n if (simplebarElement?.classList.contains('simplebar-dragging')) {\n scrollStateFrame = requestAnimationFrame(runScrollStateLoop)\n return\n }\n\n scrollStateFrame = 0\n}\n\nconst startScrollStateLoop = () => {\n if (scrollStateFrame) return\n scrollStateFrame = requestAnimationFrame(runScrollStateLoop)\n}\n\nconst finishScrollStateLoop = () => {\n stopScrollStateLoop()\n updateScrollState()\n}\n\nconst handleScrollbarDragStart = (event: MouseEvent | TouchEvent) => {\n const target = event.target\n if (!(target instanceof Element) || !target.closest('.simplebar-track.simplebar-horizontal')) return\n\n startScrollStateLoop()\n window.addEventListener('mouseup', finishScrollStateLoop, { once: true })\n window.addEventListener('touchend', finishScrollStateLoop, { once: true })\n window.addEventListener('touchcancel', finishScrollStateLoop, { once: true })\n}\n\n// 表格所在容器或内容尺寸变化后,主动刷新 SimpleBar 的滚动尺寸与固定列阴影状态。\nconst scheduleTableResize = () => {\n if (resizeFrame) cancelAnimationFrame(resizeFrame)\n resizeFrame = requestAnimationFrame(() => {\n resizeFrame = 0\n nextTick(() => {\n simplebarRef.value?.recalculate?.()\n updateScrollState()\n })\n })\n}\n\nwatch(\n () => [props.rows.length, tableLayoutSignature.value, props.minWidth, props.maxHeight],\n () => scheduleTableResize()\n)\n\nonMounted(() => {\n resizeObserver = new ResizeObserver(() => scheduleTableResize())\n if (tableRootRef.value) resizeObserver.observe(tableRootRef.value)\n if (tableElementRef.value) resizeObserver.observe(tableElementRef.value)\n window.addEventListener('resize', scheduleTableResize)\n scheduleTableResize()\n})\n\nonBeforeUnmount(() => {\n window.removeEventListener('resize', scheduleTableResize)\n resizeObserver?.disconnect()\n resizeObserver = null\n if (resizeFrame) {\n cancelAnimationFrame(resizeFrame)\n resizeFrame = 0\n }\n stopScrollStateLoop()\n window.removeEventListener('mouseup', finishScrollStateLoop)\n window.removeEventListener('touchend', finishScrollStateLoop)\n window.removeEventListener('touchcancel', finishScrollStateLoop)\n})\n\nconst getValueByPath = (row: T, path?: keyof T | string) => {\n if (!path) return undefined\n const key = String(path)\n if (!key.includes('.')) return row[key as keyof T]\n return key.split('.').reduce<unknown>((value, part) => {\n if (value === null || typeof value !== 'object') return undefined\n return (value as Record<string, unknown>)[part]\n }, row)\n}\n\nconst getColumnValue = (row: T, column: TableColumn<T>) => getValueByPath(row, column.dataIndex ?? column.key)\n\nconst getFilterLabel = (item: unknown) => {\n if (typeof item === 'object' && item !== null && 'label' in item) return String((item as { label?: unknown }).label ?? '')\n return ''\n}\n\nconst comparePrimitive = (a: unknown, b: unknown) => {\n if (a === b) return 0\n if (a === undefined || a === null) return 1\n if (b === undefined || b === null) return -1\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime()\n return String(a).localeCompare(String(b), 'zh-Hans-CN', { numeric: true, sensitivity: 'base' })\n}\n\nconst filteredRows = computed(() => {\n const filters = activeFilters.value\n return props.rows.filter((row) =>\n props.columns.every((column) => {\n const selected = filters[column.key] || []\n if (!selected.length) return true\n if (column.filterFn) return column.filterFn(row, selected)\n return selected.includes(getColumnValue(row, column))\n })\n )\n})\n\nconst displayedRows = computed(() => {\n const sort = activeSort.value\n if (!sort) return filteredRows.value\n\n const column = props.columns.find((item) => item.key === sort.key)\n if (!column) return filteredRows.value\n\n return filteredRows.value\n .map((row, index) => ({ row, index }))\n .sort((a, b) => {\n const result = typeof column.sortable === 'function' ? column.sortable(a.row, b.row) : comparePrimitive(getColumnValue(a.row, column), getColumnValue(b.row, column))\n const sorted = sort.direction === 'asc' ? result : -result\n return sorted || a.index - b.index\n })\n .map((item) => item.row)\n})\n\nconst getRowKey = (row: T, index: number) => {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index)\n const value = getValueByPath(row, props.rowKey)\n return typeof value === 'string' || typeof value === 'number' ? value : index\n}\n\nconst setSort = (value: TableSortState | null) => {\n if (props.sort === undefined) internalSort.value = value\n emit('update:sort', value)\n emit('sort-change', value)\n}\n\nconst toggleSort = (column: TableColumn<T>) => {\n if (!column.sortable) return\n\n const current = activeSort.value\n if (current?.key !== column.key) {\n setSort({ key: column.key, direction: column.defaultSortDirection || 'asc' })\n return\n }\n\n if (current.direction === 'asc') {\n setSort({ key: column.key, direction: 'desc' })\n return\n }\n\n setSort(props.allowClearSort ? null : { key: column.key, direction: 'asc' })\n}\n\nconst setFilters = (value: TableFiltersState) => {\n if (props.filters === undefined) internalFilters.value = value\n emit('update:filters', value)\n emit('filter-change', value)\n nextTick(updateScrollState)\n}\n\nconst handleFilterValueChange = (column: TableColumn<T>, value: unknown) => {\n const selected = Array.isArray(value) ? value : value === undefined || value === null ? [] : [value]\n const nextSelected = column.filterMultiple === false && selected.length > 1 ? selected.slice(-1) : selected\n setFilters({\n ...activeFilters.value,\n [column.key]: nextSelected\n })\n}\n\nconst clearColumnFilter = (column: TableColumn<T>) => {\n const next = { ...activeFilters.value }\n delete next[column.key]\n setFilters(next)\n}\n\nconst isFilterActive = (column: TableColumn<T>) => (activeFilters.value[column.key] || []).length > 0\n\nconst formatCellValue = (row: T, column: TableColumn<T>, index: number) => {\n const value = getColumnValue(row, column)\n if (column.formatter) return column.formatter(value, row, index)\n if (value === undefined || value === null || value === '') return '-'\n return String(value)\n}\n\nconst getAlignClass = (align?: TableColumn<T>['align']) => {\n if (align === 'center') return 'text-center'\n if (align === 'right') return 'text-right'\n return 'text-left'\n}\n\nconst getHeaderJustifyClass = (align?: TableColumn<T>['align']) => {\n if (align === 'center') return 'justify-center'\n if (align === 'right') return 'justify-end'\n return 'justify-start'\n}\n\nconst getColumnStyle = (state: ColumnState) => {\n const column = state.column\n return {\n width: toCssLength(column.width),\n minWidth: toCssLength(column.minWidth ?? column.width),\n maxWidth: toCssLength(column.maxWidth ?? column.width),\n left: state.fixed === 'left' ? `${state.left || 0}px` : undefined,\n right: state.fixed === 'right' ? `${state.right || 0}px` : undefined\n }\n}\n\nconst getHeaderClass = (state: ColumnState) => {\n const column = state.column\n return clsx(\n 'relative bg-secondary font-bold uppercase text-tertiary whitespace-nowrap',\n sizeClasses.value.header,\n getAlignClass(column.align),\n props.stickyHeader && 'sticky top-0 z-20',\n state.fixed && 'sticky z-30',\n state.fixed === 'left' && 'ui-table__cell--fixed-left',\n state.fixed === 'right' && 'ui-table__cell--fixed-right',\n state.isLeftEdge && 'ui-table__cell--fixed-left-edge',\n state.isRightEdge && 'ui-table__cell--fixed-right-edge',\n props.showVerticalLines && state.index < props.columns.length - 1 && 'border-r border-medium/60',\n props.showHorizontalLines && 'border-b border-medium/70',\n column.headerClass\n )\n}\n\nconst getCellClass = (state: ColumnState, row: T, index: number) => {\n const column = state.column\n const rowBackground = props.stripe && index % 2 === 1 ? 'bg-secondary' : 'bg-primary'\n const customClass = typeof column.class === 'function' ? column.class(row, index) : column.class\n return clsx(\n 'relative align-middle transition-colors group-hover:bg-tertiary',\n sizeClasses.value.cell,\n rowBackground,\n column.wrap ? 'whitespace-normal' : 'whitespace-nowrap',\n getAlignClass(column.align),\n state.fixed && 'sticky z-10',\n state.fixed === 'left' && 'ui-table__cell--fixed-left',\n state.fixed === 'right' && 'ui-table__cell--fixed-right',\n state.isLeftEdge && 'ui-table__cell--fixed-left-edge',\n state.isRightEdge && 'ui-table__cell--fixed-right-edge',\n props.showVerticalLines && state.index < props.columns.length - 1 && 'border-r border-medium/60',\n props.showHorizontalLines && index > 0 && 'border-t border-medium/60',\n customClass\n )\n}\n\nconst getRowClass = (_index: number) => 'group'\n\nconst getSortIcon = (column: TableColumn<T>) => {\n const sort = activeSort.value\n if (sort?.key !== column.key) return 'i-lucide:chevrons-up-down'\n return sort.direction === 'asc' ? 'i-lucide:arrow-up-narrow-wide' : 'i-lucide:arrow-down-wide-narrow'\n}\n</script>\n\n<template>\n <div\n ref=\"tableRoot\"\n :class=\"\n clsx(\n 'ui-table overflow-hidden bg-primary',\n radiusClass,\n bordered && 'border border-medium',\n hasScrollLeft && 'ui-table--scrolled-left',\n hasScrollRight && 'ui-table--scrolled-right',\n hasScrollY && 'ui-table--scroll-y',\n showHorizontalLines && 'ui-table--horizontal-lines',\n showVerticalLines && 'ui-table--vertical-lines'\n )\n \"\n >\n <SimpleBar ref=\"simplebarRef\" class=\"ui-table__scroll w-full\" :auto-hide=\"autoHideScrollbar\" :style=\"scrollStyle\" @mousedown.capture=\"handleScrollbarDragStart\" @scroll=\"handleScroll\" @touchstart.capture=\"handleScrollbarDragStart\">\n <table ref=\"tableElement\" class=\"w-full border-separate border-spacing-0\" :class=\"sizeClasses.table\" :style=\"tableStyle\">\n <thead>\n <tr>\n <th v-for=\"state in columnStates\" :key=\"state.column.key\" :class=\"getHeaderClass(state)\" :style=\"getColumnStyle(state)\">\n <div class=\"flex min-w-0 items-center gap-1.5\" :class=\"getHeaderJustifyClass(state.column.align)\">\n <slot :name=\"`header-${state.column.key}`\" :column=\"state.column\">\n <div\n v-if=\"state.column.sortable\"\n class=\"flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-xs font-bold transition-colors hover:bg-primary/70\"\n :class=\"[getHeaderJustifyClass(state.column.align), activeSort?.key === state.column.key ? 'text-brand' : 'text-tertiary']\"\n @click=\"toggleSort(state.column)\"\n >\n <span class=\"truncate\">{{ state.column.title }}</span>\n <span :class=\"`${getSortIcon(state.column)} size-3.5 flex-shrink-0`\"></span>\n </div>\n <span v-else class=\"truncate\">{{ state.column.title }}</span>\n </slot>\n\n <Dropdown v-if=\"state.column.filters\" :value=\"activeFilters[state.column.key] || []\" :items=\"state.column.filters\" value-key=\"value\" align=\"left\" @update:value=\"handleFilterValueChange(state.column, $event)\">\n <template #trigger=\"{ open }\">\n <div class=\"flex size-6 flex-shrink-0 items-center justify-center rounded transition-colors hover:bg-primary/70\" :class=\"open || isFilterActive(state.column) ? 'text-brand' : 'text-tertiary'\" title=\"筛选\">\n <span class=\"i-lucide:funnel size-3.5\"></span>\n </div>\n </template>\n <template #item=\"{ item, selected }\">\n <div class=\"flex min-h-9 cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-secondary\" :class=\"selected ? 'bg-brand/10 text-brand' : 'text-primary'\">\n <span class=\"flex size-4 items-center justify-center rounded border border-medium bg-primary\">\n <span v-if=\"selected\" class=\"i-lucide:check size-3 text-brand\"></span>\n </span>\n <span class=\"min-w-0 truncate\">{{ getFilterLabel(item) }}</span>\n </div>\n </template>\n <template v-if=\"state.column.filters.length === 0\" #header>\n <div class=\"px-3 py-6 text-center text-sm text-tertiary\">{{ filterEmptyText }}</div>\n </template>\n <template #footer>\n <div class=\"border-t border-medium bg-primary px-2 py-2 flex justify-center\">\n <Button variant=\"outline\" size=\"sm\" class=\"px-5.5!\" @click.stop=\"clearColumnFilter(state.column)\">\n {{ filterResetText }}\n </Button>\n </div>\n </template>\n </Dropdown>\n </div>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(row, rowIndex) in displayedRows\" :key=\"getRowKey(row, rowIndex)\" :class=\"getRowClass(rowIndex)\" @click=\"emit('row-click', row, rowIndex)\">\n <td v-for=\"state in columnStates\" :key=\"state.column.key\" :class=\"getCellClass(state, row, rowIndex)\" :style=\"getColumnStyle(state)\">\n <slot :name=\"`cell-${state.column.key}`\" :row=\"row\" :column=\"state.column\" :value=\"getColumnValue(row, state.column)\" :index=\"rowIndex\">\n <slot name=\"cell\" :row=\"row\" :column=\"state.column\" :value=\"getColumnValue(row, state.column)\" :index=\"rowIndex\">\n {{ formatCellValue(row, state.column, rowIndex) }}\n </slot>\n </slot>\n </td>\n </tr>\n <tr v-if=\"displayedRows.length === 0\">\n <td :colspan=\"columns.length\" class=\"text-center text-tertiary\" :class=\"sizeClasses.empty\">\n <slot name=\"empty\">{{ emptyText }}</slot>\n </td>\n </tr>\n </tbody>\n </table>\n </SimpleBar>\n </div>\n</template>\n\n<style scoped>\n.ui-table :deep(.simplebar-scrollbar::before) {\n opacity: 0 !important;\n}\n\n.ui-table {\n --ui-table-fixed-shadow-color: rgba(15, 23, 42, 0.11);\n}\n\n[data-theme='dark'] .ui-table {\n --ui-table-fixed-shadow-color: rgba(135, 140, 145, 0.22);\n}\n\n.ui-table:not(.ui-table--scroll-y) :deep(.simplebar-track.simplebar-vertical) {\n visibility: hidden !important;\n}\n\n.ui-table:hover :deep(.simplebar-scrollbar::before),\n.ui-table :deep(.ui-table__scroll.simplebar-scrolling .simplebar-scrollbar::before),\n.ui-table :deep(.ui-table__scroll.simplebar-dragging .simplebar-scrollbar::before) {\n opacity: 1 !important;\n}\n\n.ui-table__cell--fixed-left {\n z-index: 12;\n}\n\n.ui-table__cell--fixed-right {\n z-index: 11;\n}\n\nthead .ui-table__cell--fixed-left {\n z-index: 32;\n}\n\nthead .ui-table__cell--fixed-right {\n z-index: 31;\n}\n\n.ui-table__cell--fixed-left-edge::after,\n.ui-table__cell--fixed-right-edge::before {\n position: absolute;\n top: 0;\n bottom: -1px;\n width: 30px;\n z-index: 1;\n pointer-events: none;\n content: '';\n transition: box-shadow 0.3s ease;\n}\n\n.ui-table__cell--fixed-left-edge::after {\n left: 100%;\n}\n\n.ui-table__cell--fixed-right-edge::before {\n right: 100%;\n}\n\n.ui-table--scrolled-left .ui-table__cell--fixed-left-edge::after {\n box-shadow: inset 10px 0 8px -8px var(--ui-table-fixed-shadow-color);\n}\n\n.ui-table--scrolled-right .ui-table__cell--fixed-right-edge::before {\n box-shadow: inset -10px 0 8px -8px var(--ui-table-fixed-shadow-color);\n}\n</style>\n","<script setup lang=\"ts\" generic=\"T extends TableRow = TableRow\">\nimport { clsx } from 'clsx'\nimport SimpleBar from 'simplebar-vue'\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from 'vue'\n\nimport { Button } from '../button'\nimport { Dropdown } from '../dropdown'\n\nimport '../assets/simplebar.css'\nimport 'simplebar-vue/dist/simplebar.min.css'\n\nimport type { TableColumn, TableFiltersState, TableRadius, TableRow, TableSize, TableSortState } from './types'\n\ninterface ColumnState {\n column: TableColumn<T>\n index: number\n fixed?: 'left' | 'right'\n left?: number\n right?: number\n isLeftEdge: boolean\n isRightEdge: boolean\n}\n\ntype SimpleBarComponent = InstanceType<typeof SimpleBar> & {\n recalculate?: () => void\n getScrollElement?: () => HTMLElement\n $el?: HTMLElement\n}\n\nconst props = withDefaults(\n defineProps<{\n /** rows 是表格原始数据源。 */\n rows: T[]\n /** columns 是列配置,控制渲染、排序、筛选和固定列。 */\n columns: TableColumn<T>[]\n /** rowKey 是行唯一键字段或取值函数。 */\n rowKey: keyof T | string | ((row: T, index: number) => string | number)\n /** sort 传入后表格排序变为受控状态。 */\n sort?: TableSortState | null\n /** defaultSort 是非受控排序初始值。 */\n defaultSort?: TableSortState | null\n /** filters 传入后表格筛选变为受控状态。 */\n filters?: TableFiltersState\n /** defaultFilters 是非受控筛选初始值。 */\n defaultFilters?: TableFiltersState\n /** maxHeight 是 SimpleBar 滚动区域最大高度。 */\n maxHeight?: string\n /** minWidth 是表格整体最小宽度。 */\n minWidth?: string\n /** stickyHeader 控制是否固定表头。 */\n stickyHeader?: boolean\n /** allowClearSort 控制排序是否允许从降序再次点击后清空。 */\n allowClearSort?: boolean\n /** stripe 控制是否展示斑马纹行背景。 */\n stripe?: boolean\n /** radius 控制表格外框圆角。 */\n radius?: TableRadius\n /** size 控制表格字号和行高。 */\n size?: TableSize\n /** showHorizontalLines 控制是否展示横向表格线。 */\n showHorizontalLines?: boolean\n /** showVerticalLines 控制是否展示纵向表格线。 */\n showVerticalLines?: boolean\n /** bordered 控制是否展示外边框。 */\n bordered?: boolean\n /** autoHideScrollbar 控制 SimpleBar 滚动条是否自动隐藏。 */\n autoHideScrollbar?: boolean\n /** emptyText 是空数据文案。 */\n emptyText?: string\n /** filterResetText 是筛选菜单清空按钮文案。 */\n filterResetText?: string\n /** filterEmptyText 是筛选菜单无选项文案。 */\n filterEmptyText?: string\n }>(),\n {\n defaultSort: null,\n defaultFilters: () => ({}),\n stickyHeader: true,\n allowClearSort: true,\n stripe: false,\n radius: 'md',\n size: 'md',\n showHorizontalLines: true,\n showVerticalLines: false,\n bordered: true,\n autoHideScrollbar: false,\n emptyText: '暂无数据',\n filterResetText: '清空',\n filterEmptyText: '暂无选项'\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:sort', value: TableSortState | null): void\n (e: 'sort-change', value: TableSortState | null): void\n (e: 'update:filters', value: TableFiltersState): void\n (e: 'filter-change', value: TableFiltersState): void\n (e: 'row-click', row: T, index: number): void\n}>()\n\nconst simplebarRef = ref<SimpleBarComponent | null>(null)\nconst tableRootRef = useTemplateRef<HTMLElement>('tableRoot')\nconst tableElementRef = useTemplateRef<HTMLTableElement>('tableElement')\nconst internalSort = ref<TableSortState | null>(props.defaultSort)\nconst internalFilters = ref<TableFiltersState>({ ...props.defaultFilters })\nconst hasScrollLeft = ref(false)\nconst hasScrollRight = ref(false)\nconst hasScrollY = ref(false)\nlet resizeObserver: ResizeObserver | null = null\nlet resizeFrame = 0\nlet scrollStateFrame = 0\n\nconst radiusClass = computed(() => {\n const map: Record<TableRadius, string> = {\n none: 'rounded-none',\n sm: 'rounded-sm',\n md: 'rounded-md',\n lg: 'rounded-lg'\n }\n return map[props.radius]\n})\n\nconst sizeClasses = computed(() => {\n const map: Record<TableSize, { table: string; header: string; cell: string; empty: string }> = {\n md: {\n table: 'text-sm leading-5',\n header: 'px-3 py-2 text-xs',\n cell: 'px-3 py-2 text-secondary',\n empty: 'px-3 py-10 text-sm'\n },\n lg: {\n table: 'text-base leading-6',\n header: 'px-4 py-3 text-sm',\n cell: 'px-4 py-3 text-secondary',\n empty: 'px-4 py-12 text-base'\n }\n }\n return map[props.size]\n})\n\nconst activeSort = computed(() => (props.sort === undefined ? internalSort.value : props.sort))\nconst activeFilters = computed(() => (props.filters === undefined ? internalFilters.value : props.filters))\n\nconst toCssLength = (value?: number | string) => {\n if (typeof value === 'number') return `${value}px`\n return value\n}\n\nconst toPixelWidth = (value?: number | string) => {\n if (typeof value === 'number') return value\n const match = value?.match(/^(\\d+(?:\\.\\d+)?)px$/)\n return match ? Number(match[1]) : 0\n}\n\nconst columnWidth = (column: TableColumn<T>) => toPixelWidth(column.width ?? column.minWidth)\n\nconst columnStates = computed<ColumnState[]>(() => {\n const states: ColumnState[] = props.columns.map((column, index) => ({\n column,\n index,\n fixed: column.fixed,\n isLeftEdge: false,\n isRightEdge: false\n }))\n\n let left = 0\n states.forEach((state) => {\n if (state.fixed !== 'left') return\n state.left = left\n left += columnWidth(state.column)\n })\n\n let right = 0\n ;[...states].reverse().forEach((state) => {\n if (state.fixed !== 'right') return\n state.right = right\n right += columnWidth(state.column)\n })\n\n const leftFixed = states.filter((state) => state.fixed === 'left')\n const rightFixed = states.filter((state) => state.fixed === 'right')\n const leftEdge = leftFixed.at(-1)\n const rightEdge = rightFixed[0]\n if (leftEdge) leftEdge.isLeftEdge = true\n if (rightEdge) rightEdge.isRightEdge = true\n\n return states\n})\n\nconst tableStyle = computed(() => ({\n minWidth: props.minWidth || undefined\n}))\n\nconst scrollStyle = computed(() => ({\n maxHeight: props.maxHeight,\n overflowY: props.maxHeight ? undefined : 'hidden'\n}))\n\nconst tableLayoutSignature = computed(() => props.columns.map((column) => [column.key, column.width ?? '', column.minWidth ?? '', column.maxWidth ?? '', column.fixed ?? ''].join(':')).join('|'))\n\nconst getScrollElement = () => {\n const current = simplebarRef.value\n if (!current) return null\n if (typeof current.getScrollElement === 'function') return current.getScrollElement()\n return current.$el?.querySelector('.simplebar-content-wrapper') as HTMLElement | null\n}\n\nconst isHorizontalThumbAtStart = () => {\n const simplebarElement = simplebarRef.value?.$el\n const track = simplebarElement?.querySelector('.simplebar-track.simplebar-horizontal')\n const thumb = track?.querySelector('.simplebar-scrollbar')\n const trackRect = track?.getBoundingClientRect()\n const thumbRect = thumb?.getBoundingClientRect()\n if (!trackRect || !thumbRect || thumbRect.width <= 0) return false\n return thumbRect.left - trackRect.left <= 2\n}\n\n// 同步水平滚动状态,用于固定列边缘阴影。\nconst updateScrollState = () => {\n const el = getScrollElement()\n if (!el) return\n hasScrollLeft.value = el.scrollLeft > 2 && !isHorizontalThumbAtStart()\n hasScrollRight.value = el.scrollLeft + el.clientWidth < el.scrollWidth - 1\n hasScrollY.value = el.scrollHeight - el.clientHeight > 2\n}\n\nconst handleScroll = () => updateScrollState()\n\nconst stopScrollStateLoop = () => {\n if (!scrollStateFrame) return\n cancelAnimationFrame(scrollStateFrame)\n scrollStateFrame = 0\n}\n\nconst runScrollStateLoop = () => {\n updateScrollState()\n\n const simplebarElement = simplebarRef.value?.$el\n if (simplebarElement?.classList.contains('simplebar-dragging')) {\n scrollStateFrame = requestAnimationFrame(runScrollStateLoop)\n return\n }\n\n scrollStateFrame = 0\n}\n\nconst startScrollStateLoop = () => {\n if (scrollStateFrame) return\n scrollStateFrame = requestAnimationFrame(runScrollStateLoop)\n}\n\nconst finishScrollStateLoop = () => {\n stopScrollStateLoop()\n updateScrollState()\n}\n\nconst handleScrollbarDragStart = (event: MouseEvent | TouchEvent) => {\n const target = event.target\n if (!(target instanceof Element) || !target.closest('.simplebar-track.simplebar-horizontal')) return\n\n startScrollStateLoop()\n window.addEventListener('mouseup', finishScrollStateLoop, { once: true })\n window.addEventListener('touchend', finishScrollStateLoop, { once: true })\n window.addEventListener('touchcancel', finishScrollStateLoop, { once: true })\n}\n\n// 表格所在容器或内容尺寸变化后,主动刷新 SimpleBar 的滚动尺寸与固定列阴影状态。\nconst scheduleTableResize = () => {\n if (resizeFrame) cancelAnimationFrame(resizeFrame)\n resizeFrame = requestAnimationFrame(() => {\n resizeFrame = 0\n nextTick(() => {\n simplebarRef.value?.recalculate?.()\n updateScrollState()\n })\n })\n}\n\nwatch(\n () => [props.rows.length, tableLayoutSignature.value, props.minWidth, props.maxHeight],\n () => scheduleTableResize()\n)\n\nonMounted(() => {\n resizeObserver = new ResizeObserver(() => scheduleTableResize())\n if (tableRootRef.value) resizeObserver.observe(tableRootRef.value)\n if (tableElementRef.value) resizeObserver.observe(tableElementRef.value)\n window.addEventListener('resize', scheduleTableResize)\n scheduleTableResize()\n})\n\nonBeforeUnmount(() => {\n window.removeEventListener('resize', scheduleTableResize)\n resizeObserver?.disconnect()\n resizeObserver = null\n if (resizeFrame) {\n cancelAnimationFrame(resizeFrame)\n resizeFrame = 0\n }\n stopScrollStateLoop()\n window.removeEventListener('mouseup', finishScrollStateLoop)\n window.removeEventListener('touchend', finishScrollStateLoop)\n window.removeEventListener('touchcancel', finishScrollStateLoop)\n})\n\nconst getValueByPath = (row: T, path?: keyof T | string) => {\n if (!path) return undefined\n const key = String(path)\n if (!key.includes('.')) return row[key as keyof T]\n return key.split('.').reduce<unknown>((value, part) => {\n if (value === null || typeof value !== 'object') return undefined\n return (value as Record<string, unknown>)[part]\n }, row)\n}\n\nconst getColumnValue = (row: T, column: TableColumn<T>) => getValueByPath(row, column.dataIndex ?? column.key)\n\nconst getFilterLabel = (item: unknown) => {\n if (typeof item === 'object' && item !== null && 'label' in item) return String((item as { label?: unknown }).label ?? '')\n return ''\n}\n\nconst comparePrimitive = (a: unknown, b: unknown) => {\n if (a === b) return 0\n if (a === undefined || a === null) return 1\n if (b === undefined || b === null) return -1\n if (typeof a === 'number' && typeof b === 'number') return a - b\n if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime()\n return String(a).localeCompare(String(b), 'zh-Hans-CN', { numeric: true, sensitivity: 'base' })\n}\n\nconst filteredRows = computed(() => {\n const filters = activeFilters.value\n return props.rows.filter((row) =>\n props.columns.every((column) => {\n const selected = filters[column.key] || []\n if (!selected.length) return true\n if (column.filterFn) return column.filterFn(row, selected)\n return selected.includes(getColumnValue(row, column))\n })\n )\n})\n\nconst displayedRows = computed(() => {\n const sort = activeSort.value\n if (!sort) return filteredRows.value\n\n const column = props.columns.find((item) => item.key === sort.key)\n if (!column) return filteredRows.value\n\n return filteredRows.value\n .map((row, index) => ({ row, index }))\n .sort((a, b) => {\n const result = typeof column.sortable === 'function' ? column.sortable(a.row, b.row) : comparePrimitive(getColumnValue(a.row, column), getColumnValue(b.row, column))\n const sorted = sort.direction === 'asc' ? result : -result\n return sorted || a.index - b.index\n })\n .map((item) => item.row)\n})\n\nconst getRowKey = (row: T, index: number) => {\n if (typeof props.rowKey === 'function') return props.rowKey(row, index)\n const value = getValueByPath(row, props.rowKey)\n return typeof value === 'string' || typeof value === 'number' ? value : index\n}\n\nconst setSort = (value: TableSortState | null) => {\n if (props.sort === undefined) internalSort.value = value\n emit('update:sort', value)\n emit('sort-change', value)\n}\n\nconst toggleSort = (column: TableColumn<T>) => {\n if (!column.sortable) return\n\n const current = activeSort.value\n if (current?.key !== column.key) {\n setSort({ key: column.key, direction: column.defaultSortDirection || 'asc' })\n return\n }\n\n if (current.direction === 'asc') {\n setSort({ key: column.key, direction: 'desc' })\n return\n }\n\n setSort(props.allowClearSort ? null : { key: column.key, direction: 'asc' })\n}\n\nconst setFilters = (value: TableFiltersState) => {\n if (props.filters === undefined) internalFilters.value = value\n emit('update:filters', value)\n emit('filter-change', value)\n nextTick(updateScrollState)\n}\n\nconst handleFilterValueChange = (column: TableColumn<T>, value: unknown) => {\n const selected = Array.isArray(value) ? value : value === undefined || value === null ? [] : [value]\n const nextSelected = column.filterMultiple === false && selected.length > 1 ? selected.slice(-1) : selected\n setFilters({\n ...activeFilters.value,\n [column.key]: nextSelected\n })\n}\n\nconst clearColumnFilter = (column: TableColumn<T>) => {\n const next = { ...activeFilters.value }\n delete next[column.key]\n setFilters(next)\n}\n\nconst isFilterActive = (column: TableColumn<T>) => (activeFilters.value[column.key] || []).length > 0\n\nconst formatCellValue = (row: T, column: TableColumn<T>, index: number) => {\n const value = getColumnValue(row, column)\n if (column.formatter) return column.formatter(value, row, index)\n if (value === undefined || value === null || value === '') return '-'\n return String(value)\n}\n\nconst getAlignClass = (align?: TableColumn<T>['align']) => {\n if (align === 'center') return 'text-center'\n if (align === 'right') return 'text-right'\n return 'text-left'\n}\n\nconst getHeaderJustifyClass = (align?: TableColumn<T>['align']) => {\n if (align === 'center') return 'justify-center'\n if (align === 'right') return 'justify-end'\n return 'justify-start'\n}\n\nconst getColumnStyle = (state: ColumnState) => {\n const column = state.column\n return {\n width: toCssLength(column.width),\n minWidth: toCssLength(column.minWidth ?? column.width),\n maxWidth: toCssLength(column.maxWidth ?? column.width),\n left: state.fixed === 'left' ? `${state.left || 0}px` : undefined,\n right: state.fixed === 'right' ? `${state.right || 0}px` : undefined\n }\n}\n\nconst getHeaderClass = (state: ColumnState) => {\n const column = state.column\n return clsx(\n 'relative bg-secondary font-bold uppercase text-tertiary whitespace-nowrap',\n sizeClasses.value.header,\n getAlignClass(column.align),\n props.stickyHeader && 'sticky top-0 z-20',\n state.fixed && 'sticky z-30',\n state.fixed === 'left' && 'ui-table__cell--fixed-left',\n state.fixed === 'right' && 'ui-table__cell--fixed-right',\n state.isLeftEdge && 'ui-table__cell--fixed-left-edge',\n state.isRightEdge && 'ui-table__cell--fixed-right-edge',\n props.showVerticalLines && state.index < props.columns.length - 1 && 'border-r border-medium/60',\n props.showHorizontalLines && 'border-b border-medium/70',\n column.headerClass\n )\n}\n\nconst getCellClass = (state: ColumnState, row: T, index: number) => {\n const column = state.column\n const rowBackground = props.stripe && index % 2 === 1 ? 'bg-secondary' : 'bg-primary'\n const customClass = typeof column.class === 'function' ? column.class(row, index) : column.class\n return clsx(\n 'relative align-middle transition-colors group-hover:bg-tertiary',\n sizeClasses.value.cell,\n rowBackground,\n column.wrap ? 'whitespace-normal' : 'whitespace-nowrap',\n getAlignClass(column.align),\n state.fixed && 'sticky z-10',\n state.fixed === 'left' && 'ui-table__cell--fixed-left',\n state.fixed === 'right' && 'ui-table__cell--fixed-right',\n state.isLeftEdge && 'ui-table__cell--fixed-left-edge',\n state.isRightEdge && 'ui-table__cell--fixed-right-edge',\n props.showVerticalLines && state.index < props.columns.length - 1 && 'border-r border-medium/60',\n props.showHorizontalLines && index > 0 && 'border-t border-medium/60',\n customClass\n )\n}\n\nconst getRowClass = (_index: number) => 'group'\n\nconst getSortIcon = (column: TableColumn<T>) => {\n const sort = activeSort.value\n if (sort?.key !== column.key) return 'i-lucide:chevrons-up-down'\n return sort.direction === 'asc' ? 'i-lucide:arrow-up-narrow-wide' : 'i-lucide:arrow-down-wide-narrow'\n}\n</script>\n\n<template>\n <div\n ref=\"tableRoot\"\n :class=\"\n clsx(\n 'ui-table overflow-hidden bg-primary',\n radiusClass,\n bordered && 'border border-medium',\n hasScrollLeft && 'ui-table--scrolled-left',\n hasScrollRight && 'ui-table--scrolled-right',\n hasScrollY && 'ui-table--scroll-y',\n showHorizontalLines && 'ui-table--horizontal-lines',\n showVerticalLines && 'ui-table--vertical-lines'\n )\n \"\n >\n <SimpleBar ref=\"simplebarRef\" class=\"ui-table__scroll w-full\" :auto-hide=\"autoHideScrollbar\" :style=\"scrollStyle\" @mousedown.capture=\"handleScrollbarDragStart\" @scroll=\"handleScroll\" @touchstart.capture=\"handleScrollbarDragStart\">\n <table ref=\"tableElement\" class=\"w-full border-separate border-spacing-0\" :class=\"sizeClasses.table\" :style=\"tableStyle\">\n <thead>\n <tr>\n <th v-for=\"state in columnStates\" :key=\"state.column.key\" :class=\"getHeaderClass(state)\" :style=\"getColumnStyle(state)\">\n <div class=\"flex min-w-0 items-center gap-1.5\" :class=\"getHeaderJustifyClass(state.column.align)\">\n <slot :name=\"`header-${state.column.key}`\" :column=\"state.column\">\n <div\n v-if=\"state.column.sortable\"\n class=\"flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-xs font-bold transition-colors hover:bg-primary/70\"\n :class=\"[getHeaderJustifyClass(state.column.align), activeSort?.key === state.column.key ? 'text-brand' : 'text-tertiary']\"\n @click=\"toggleSort(state.column)\"\n >\n <span class=\"truncate\">{{ state.column.title }}</span>\n <span :class=\"`${getSortIcon(state.column)} size-3.5 flex-shrink-0`\"></span>\n </div>\n <span v-else class=\"truncate\">{{ state.column.title }}</span>\n </slot>\n\n <Dropdown v-if=\"state.column.filters\" :value=\"activeFilters[state.column.key] || []\" :items=\"state.column.filters\" value-key=\"value\" align=\"left\" @update:value=\"handleFilterValueChange(state.column, $event)\">\n <template #trigger=\"{ open }\">\n <div class=\"flex size-6 flex-shrink-0 items-center justify-center rounded transition-colors hover:bg-primary/70\" :class=\"open || isFilterActive(state.column) ? 'text-brand' : 'text-tertiary'\" title=\"筛选\">\n <span class=\"i-lucide:funnel size-3.5\"></span>\n </div>\n </template>\n <template #item=\"{ item, selected }\">\n <div class=\"flex min-h-9 cursor-pointer items-center gap-2 px-3 py-2 text-sm transition-colors hover:bg-secondary\" :class=\"selected ? 'bg-brand/10 text-brand' : 'text-primary'\">\n <span class=\"flex size-4 items-center justify-center rounded border border-medium bg-primary\">\n <span v-if=\"selected\" class=\"i-lucide:check size-3 text-brand\"></span>\n </span>\n <span class=\"min-w-0 truncate\">{{ getFilterLabel(item) }}</span>\n </div>\n </template>\n <template v-if=\"state.column.filters.length === 0\" #header>\n <div class=\"px-3 py-6 text-center text-sm text-tertiary\">{{ filterEmptyText }}</div>\n </template>\n <template #footer>\n <div class=\"border-t border-medium bg-primary px-2 py-2 flex justify-center\">\n <Button variant=\"outline\" size=\"sm\" class=\"px-5.5!\" @click.stop=\"clearColumnFilter(state.column)\">\n {{ filterResetText }}\n </Button>\n </div>\n </template>\n </Dropdown>\n </div>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr v-for=\"(row, rowIndex) in displayedRows\" :key=\"getRowKey(row, rowIndex)\" :class=\"getRowClass(rowIndex)\" @click=\"emit('row-click', row, rowIndex)\">\n <td v-for=\"state in columnStates\" :key=\"state.column.key\" :class=\"getCellClass(state, row, rowIndex)\" :style=\"getColumnStyle(state)\">\n <slot :name=\"`cell-${state.column.key}`\" :row=\"row\" :column=\"state.column\" :value=\"getColumnValue(row, state.column)\" :index=\"rowIndex\">\n <slot name=\"cell\" :row=\"row\" :column=\"state.column\" :value=\"getColumnValue(row, state.column)\" :index=\"rowIndex\">\n {{ formatCellValue(row, state.column, rowIndex) }}\n </slot>\n </slot>\n </td>\n </tr>\n <tr v-if=\"displayedRows.length === 0\">\n <td :colspan=\"columns.length\" class=\"text-center text-tertiary\" :class=\"sizeClasses.empty\">\n <slot name=\"empty\">{{ emptyText }}</slot>\n </td>\n </tr>\n </tbody>\n </table>\n </SimpleBar>\n </div>\n</template>\n\n<style scoped>\n.ui-table :deep(.simplebar-scrollbar::before) {\n opacity: 0 !important;\n}\n\n.ui-table {\n --ui-table-fixed-shadow-color: rgba(15, 23, 42, 0.11);\n}\n\n[data-theme='dark'] .ui-table {\n --ui-table-fixed-shadow-color: rgba(135, 140, 145, 0.22);\n}\n\n.ui-table:not(.ui-table--scroll-y) :deep(.simplebar-track.simplebar-vertical) {\n visibility: hidden !important;\n}\n\n.ui-table:hover :deep(.simplebar-scrollbar::before),\n.ui-table :deep(.ui-table__scroll.simplebar-scrolling .simplebar-scrollbar::before),\n.ui-table :deep(.ui-table__scroll.simplebar-dragging .simplebar-scrollbar::before) {\n opacity: 1 !important;\n}\n\n.ui-table__cell--fixed-left {\n z-index: 12;\n}\n\n.ui-table__cell--fixed-right {\n z-index: 11;\n}\n\nthead .ui-table__cell--fixed-left {\n z-index: 32;\n}\n\nthead .ui-table__cell--fixed-right {\n z-index: 31;\n}\n\n.ui-table__cell--fixed-left-edge::after,\n.ui-table__cell--fixed-right-edge::before {\n position: absolute;\n top: 0;\n bottom: -1px;\n width: 30px;\n z-index: 1;\n pointer-events: none;\n content: '';\n transition: box-shadow 0.3s ease;\n}\n\n.ui-table__cell--fixed-left-edge::after {\n left: 100%;\n}\n\n.ui-table__cell--fixed-right-edge::before {\n right: 100%;\n}\n\n.ui-table--scrolled-left .ui-table__cell--fixed-left-edge::after {\n box-shadow: inset 10px 0 8px -8px var(--ui-table-fixed-shadow-color);\n}\n\n.ui-table--scrolled-right .ui-table__cell--fixed-right-edge::before {\n box-shadow: inset -10px 0 8px -8px var(--ui-table-fixed-shadow-color);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BA,IAAM,IAAQ,GA+DR,IAAO,GAQP,IAAe,EAA+B,IAAI,GAClD,IAAe,EAA4B,WAAW,GACtD,IAAkB,EAAiC,cAAc,GACjE,IAAe,EAA2B,EAAM,WAAW,GAC3D,IAAkB,EAAuB,EAAE,GAAG,EAAM,eAAe,CAAC,GACpE,IAAgB,EAAI,EAAK,GACzB,IAAiB,EAAI,EAAK,GAC1B,IAAa,EAAI,EAAK,GACxB,IAAwC,MACxC,IAAc,GACd,IAAmB,GAEjB,KAAc,SAOX;GALL,MAAM;GACN,IAAI;GACJ,IAAI;GACJ,IAAI;EAEC,EAAA,CAAI,EAAM,OAClB,GAEK,IAAc,SAeX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AAM,QAAQ,EAAM;IAAS,OAAO,EAAe,GAAK,EAAM,MAAM;IAAI,OAAO;YAEhG,CAAA,EAAA,EADF,GAAgB,GAAK,EAAM,QAAQ,CAAQ,CAAA,GAAA,CAAA,CAAA,GAAA,EAAA,CAAA,GAAA,EAAA,CAAA,GAAA,CAAA,+BAK5C,EAAA,MAAc,WAAM,KAAA,EAAA,GAA9B,EAIK,MAAA,IAAA,CAHH,EAEK,MAAA;IAFA,SAAS,EAAA,QAAQ;IAAQ,OAAK,EAAA,CAAC,6BAAoC,EAAA,MAAY,KAAK,CAAA;OACvF,EAAyC,EAAA,QAAA,SAAA,CAAA,SAAA,CAAA,EAAA,EAAnB,EAAA,SAAS,GAAA,CAAA,CAAA,GAAA,EAAA,CAAA,GAAA,IAAA,EAAA,CAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colorpicker-B-kSQ2Gh.js","names":[],"sources":["../../src/colorpicker/ColorPicker.vue","../../src/colorpicker/ColorPicker.vue","../../src/colorpicker/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, nextTick, onMounted, onUnmounted, reactive, ref, useAttrs, useTemplateRef, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { colorPickerSwatch, colorPickerTrigger, type ColorPickerSize } from '.'\nimport { clampAlpha, clampHue, clampPercent, cloneHsba, colorToHsba, hsbToRgb, hsbaToCss, normalizeDegree, normalizeRgba, parseCssColor, rgbaToCss, rgbaToHex, type ColorPickerHsbaColor, type ColorPickerMode, type ColorPickerValue, type InternalGradientStop } from './color'\n\ndefineOptions({\n inheritAttrs: false\n})\n\ntype EyeDropperConstructor = new () => {\n open: () => Promise<{ sRGBHex: string }>\n}\ntype Booleanish = boolean | 'true' | 'false' | ''\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是对象式颜色值,兼容 giacomohuang/colorpicker 的 solid/linear/radial 结构。 */\n modelValue?: ColorPickerValue\n /** size 是触发器尺寸,可选。 */\n size?: ColorPickerSize\n /** allowGradient 表示是否允许选择 linear/radial 渐变模式。 */\n allowGradient?: Booleanish\n /** allowAlpha 表示是否允许选择透明度;关闭后输出 alpha 固定为 1。 */\n allowAlpha?: Booleanish\n /** disabled 表示是否禁用颜色选择交互。 */\n disabled?: boolean\n }>(),\n {\n modelValue: undefined,\n size: 'md',\n allowGradient: true,\n allowAlpha: true,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: ColorPickerValue): void\n (e: 'changed', value: ColorPickerValue): void\n}>()\n\nconst attrs = useAttrs()\nconst rootRef = useTemplateRef<HTMLElement>('rootRef')\nconst panelRef = useTemplateRef<HTMLElement>('panelRef')\nconst paletteRef = useTemplateRef<HTMLElement>('paletteRef')\nconst hueBarRef = useTemplateRef<HTMLElement>('hueBarRef')\nconst opacityBarRef = useTemplateRef<HTMLElement>('opacityBarRef')\nconst gradientBarRef = useTemplateRef<HTMLElement>('gradientBarRef')\nconst degreeRef = useTemplateRef<HTMLElement>('degreeRef')\n\nconst open = ref(false)\nconst activeMode = ref<ColorPickerMode>('solid')\nconst degree = ref(90)\nconst activeGradientStopId = ref<number | null>(null)\nconst draggingGradientStopId = ref<number | null>(null)\nconst pendingRemoveGradientStopId = ref<number | null>(null)\nconst isDraggingHue = ref(false)\nconst isDraggingOpacity = ref(false)\nconst isDraggingDegree = ref(false)\nconst colorInputValue = ref('')\nconst colorInputInvalid = ref(false)\nconst isColorInputFocused = ref(false)\nconst gradientStops = ref<InternalGradientStop[]>([])\nconst paletteColor = reactive<ColorPickerHsbaColor>({ h: 0, s: 0, b: 0, a: 1 })\nconst panelPosition = reactive({ top: 0, left: 0 })\nconst eyeDropperSupported = ref(false)\nlet gradientStopSeed = 0\nlet dragCleanup: (() => void) | null = null\nlet syncingFromModel = false\nlet lastEmittedValue: ColorPickerValue | null = null\nlet lastEmittedSignature = ''\nlet colorInputCommitTimer: number | null = null\n\nconst modeOptions: { mode: ColorPickerMode; label: string }[] = [\n { mode: 'solid', label: '纯色' },\n { mode: 'linear', label: '线性渐变' },\n { mode: 'radial', label: '径向渐变' }\n]\nconst panelWidth = 260\nconst panelGap = 4\nconst viewportPadding = 8\nconst maxGradientStops = 10\nconst colorInputDebounceMs = 200\n// 控制点拖出渐变条一段距离后松手,按设计语义移除该控制点。\nconst gradientStopRemoveDistance = 24\n\nconst normalizeBooleanProp = (value: Booleanish | undefined, fallback: boolean) => {\n if (value === undefined) return fallback\n if (value === 'false') return false\n if (value === 'true' || value === '') return true\n return value\n}\nconst currentRgba = computed(() => hsbToRgb(paletteColor))\nconst activeDisplayRgba = computed(() => {\n if (activeMode.value === 'solid') return currentRgba.value\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n return activeStop ? hsbToRgb(activeStop.color) : currentRgba.value\n})\nconst activeColorText = computed(() => rgbaToHex(normalizeOutputRgba(activeDisplayRgba.value)))\nconst isGradientAllowed = computed(() => normalizeBooleanProp(props.allowGradient, true))\nconst isAlphaAllowed = computed(() => normalizeBooleanProp(props.allowAlpha, true))\nconst hueBackground = computed(() => rgbaToCss(hsbToRgb({ h: paletteColor.h, s: 100, b: 100, a: 1 })))\nconst gradientPreviewStops = computed(() =>\n getSortedGradientStops()\n .map((stop) => `${hsbaToCss(stop.color)} ${stop.percent}%`)\n .join(',')\n)\nconst gradientPreview = computed(() => {\n if (activeMode.value === 'linear') return `linear-gradient(${degree.value}deg,${gradientPreviewStops.value})`\n if (activeMode.value === 'radial') return `radial-gradient(circle,${gradientPreviewStops.value})`\n return rgbaToCss(currentRgba.value)\n})\nconst gradientBarBackground = computed(() => `linear-gradient(to right,${gradientPreviewStops.value || `${rgbaToCss(currentRgba.value)} 0%,${rgbaToCss(currentRgba.value)} 100%`})`)\nconst opacityBarBackground = computed(() => {\n const color = normalizeRgba({ ...currentRgba.value, a: 1 })\n return `linear-gradient(to right, rgba(${color.r},${color.g},${color.b},0), rgba(${color.r},${color.g},${color.b},1))`\n})\nconst previewBackground = computed(() => (activeMode.value === 'solid' ? rgbaToCss(currentRgba.value) : gradientPreview.value))\nconst triggerClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n colorPickerTrigger({\n size: props.size,\n focused: open.value,\n disabled: props.disabled\n })\n )\n)\nconst swatchClass = computed(() => colorPickerSwatch({ size: props.size }))\nconst eyeDropperButtonDisabled = computed(() => props.disabled || !eyeDropperSupported.value)\nconst panelStyle = computed<CSSProperties>(() => ({\n position: 'fixed',\n top: `${panelPosition.top}px`,\n left: `${panelPosition.left}px`,\n width: `${panelWidth}px`,\n maxHeight: `calc(100vh - ${viewportPadding * 2}px)`,\n overflowY: 'auto',\n zIndex: 2000\n}))\nconst paletteStyle = computed<CSSProperties>(() => ({\n background: hueBackground.value,\n height: '9rem'\n}))\nconst colorInputRowStyle = computed<CSSProperties>(() => ({\n gridTemplateColumns: 'minmax(0, 1fr) 56px'\n}))\nconst palettePickerStyle = computed<CSSProperties>(() => ({\n left: `${paletteColor.s}%`,\n top: `${100 - paletteColor.b}%`,\n backgroundColor: rgbaToCss(currentRgba.value)\n}))\nconst huePickerStyle = computed<CSSProperties>(() => ({\n left: `${(paletteColor.h / 360) * 100}%`\n}))\nconst opacityPickerStyle = computed<CSSProperties>(() => ({\n left: `${paletteColor.a * 100}%`\n}))\nconst degreePointerStyle = computed<CSSProperties>(() => ({\n transform: `translateY(-50%) rotate(${degree.value - 90}deg)`\n}))\n\nwatch(\n () => props.modelValue,\n (value) => {\n if (value && (value === lastEmittedValue || getModelSignature(value) === lastEmittedSignature)) {\n lastEmittedValue = null\n lastEmittedSignature = ''\n return\n }\n syncFromModelValue(value)\n },\n { deep: true, immediate: true }\n)\n\nwatch(open, (value) => {\n if (value) void updatePanelPosition()\n})\n\nwatch(\n activeColorText,\n (value) => {\n if (isColorInputFocused.value) return\n colorInputValue.value = value\n colorInputInvalid.value = false\n },\n { immediate: true }\n)\n\nwatch(isGradientAllowed, (value) => {\n if (!value && activeMode.value !== 'solid') {\n activeMode.value = 'solid'\n commitValue()\n }\n})\n\nwatch(isAlphaAllowed, (value) => {\n if (value) return\n let changed = false\n if (paletteColor.a !== 1) {\n paletteColor.a = 1\n changed = true\n }\n gradientStops.value.forEach((stop) => {\n if (stop.color.a !== 1) {\n stop.color.a = 1\n changed = true\n }\n })\n if (changed) commitValue()\n})\n\nfunction isValidMode(mode: unknown): mode is ColorPickerMode {\n return mode === 'solid' || mode === 'linear' || mode === 'radial'\n}\n\nfunction getSortedGradientStops() {\n return [...gradientStops.value].sort((a, b) => a.percent - b.percent)\n}\n\nfunction syncPaletteColor(color: ColorPickerHsbaColor) {\n const normalizedColor = normalizeHsbaForProps(color)\n paletteColor.h = normalizedColor.h\n paletteColor.s = normalizedColor.s\n paletteColor.b = normalizedColor.b\n paletteColor.a = normalizedColor.a\n}\n\nfunction createGradientStop(percent: number, color: ColorPickerHsbaColor): InternalGradientStop {\n return {\n id: gradientStopSeed++,\n percent: clampPercent(percent),\n color: normalizeHsbaForProps(color)\n }\n}\n\nfunction createDefaultGradientStops(color = paletteColor) {\n return [createGradientStop(0, color), createGradientStop(100, color)]\n}\n\nfunction normalizeGradientStops(value?: ColorPickerValue) {\n if (!value?.gradients?.length) return createDefaultGradientStops()\n const stops = value.gradients\n .filter((stop) => stop && typeof stop === 'object')\n .slice(0, maxGradientStops)\n .map((stop) => createGradientStop(stop.percent, colorToHsba(stop.color)))\n\n if (stops.length >= 2) return stops\n if (stops.length === 1) return [stops[0], createGradientStop(100, stops[0].color)]\n return createDefaultGradientStops()\n}\n\nfunction ensureGradientStops() {\n if (gradientStops.value.length >= 2) return\n gradientStops.value = createDefaultGradientStops()\n activeGradientStopId.value = gradientStops.value[0]?.id ?? null\n}\n\nfunction syncPaletteFromActiveGradientStop() {\n if (activeMode.value === 'solid') return\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n if (!activeStop) return\n activeGradientStopId.value = activeStop.id\n syncPaletteColor(activeStop.color)\n}\n\nfunction syncActiveGradientStopColor() {\n if (activeMode.value === 'solid') return\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value)\n if (activeStop) activeStop.color = normalizeHsbaForProps(paletteColor)\n}\n\nfunction syncFromModelValue(value?: ColorPickerValue) {\n syncingFromModel = true\n const nextMode = isGradientAllowed.value && isValidMode(value?.mode) ? value.mode : 'solid'\n const paletteSource = value?.color ?? value?.gradients?.[0]?.color\n activeMode.value = nextMode\n degree.value = normalizeDegree(value?.degree)\n syncPaletteColor(colorToHsba(paletteSource))\n gradientStops.value = normalizeGradientStops(value)\n activeGradientStopId.value = gradientStops.value[0]?.id ?? null\n if (nextMode !== 'solid') syncPaletteFromActiveGradientStop()\n syncingFromModel = false\n}\n\nfunction buildModelValue(): ColorPickerValue {\n if (activeMode.value === 'solid') {\n const color = normalizeOutputRgba(currentRgba.value)\n return {\n mode: 'solid',\n color,\n hex: rgbaToHex(color),\n css: `background-color:${rgbaToCss(color)}`\n }\n }\n\n const gradients = getSortedGradientStops().map((stop) => ({\n percent: stop.percent,\n color: normalizeOutputRgba(hsbToRgb(stop.color))\n }))\n const gradientBody = gradients.map((stop) => `${rgbaToCss(stop.color)} ${stop.percent}%`).join(',')\n\n if (activeMode.value === 'linear') {\n return {\n mode: 'linear',\n degree: degree.value,\n gradients,\n css: `background-image:linear-gradient(${degree.value}deg,${gradientBody})`\n }\n }\n\n return {\n mode: 'radial',\n gradients,\n css: `background-image:radial-gradient(${gradientBody})`\n }\n}\n\nfunction commitValue() {\n if (syncingFromModel) return\n const value = buildModelValue()\n lastEmittedValue = value\n lastEmittedSignature = getModelSignature(value)\n emit('update:modelValue', value)\n emit('changed', value)\n}\n\nfunction getModelSignature(value: ColorPickerValue) {\n return JSON.stringify(value)\n}\n\nfunction normalizeHsbaForProps(color: ColorPickerHsbaColor): ColorPickerHsbaColor {\n const normalizedColor = cloneHsba(color)\n if (!isAlphaAllowed.value) normalizedColor.a = 1\n return normalizedColor\n}\n\nfunction normalizeOutputRgba(color: ReturnType<typeof hsbToRgb>) {\n const normalizedColor = normalizeRgba(color)\n if (!isAlphaAllowed.value) normalizedColor.a = 1\n return normalizedColor\n}\n\nfunction clearColorInputCommitTimer() {\n if (colorInputCommitTimer === null) return\n window.clearTimeout(colorInputCommitTimer)\n colorInputCommitTimer = null\n}\n\nfunction applyColorInputValue(options: { formatInput?: boolean } = {}) {\n const color = parseCssColor(colorInputValue.value)\n if (!color) {\n colorInputInvalid.value = true\n return null\n }\n\n const outputColor = normalizeOutputRgba(color)\n const formattedValue = rgbaToHex(outputColor)\n const nextColor = normalizeHsbaForProps(colorToHsba(outputColor))\n colorInputInvalid.value = false\n if (options.formatInput) colorInputValue.value = formattedValue\n syncPaletteColor(nextColor)\n\n if (activeMode.value !== 'solid') {\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n if (activeStop) {\n activeGradientStopId.value = activeStop.id\n activeStop.color = nextColor\n }\n }\n\n commitValue()\n return formattedValue\n}\n\nfunction resetColorInputValue() {\n clearColorInputCommitTimer()\n colorInputValue.value = activeColorText.value\n colorInputInvalid.value = false\n}\n\nfunction scheduleColorInputCommit() {\n clearColorInputCommitTimer()\n colorInputCommitTimer = window.setTimeout(() => {\n colorInputCommitTimer = null\n applyColorInputValue()\n }, colorInputDebounceMs)\n}\n\nfunction handleColorInput(event: Event) {\n const value = (event.target as HTMLInputElement).value\n colorInputValue.value = value\n const parsedColor = parseCssColor(value)\n colorInputInvalid.value = value.trim() !== '' && !parsedColor\n if (parsedColor) {\n scheduleColorInputCommit()\n } else {\n clearColorInputCommitTimer()\n }\n}\n\nfunction handleColorInputKeydown(event: KeyboardEvent) {\n if (event.key === 'Enter') {\n event.preventDefault()\n clearColorInputCommitTimer()\n const formattedValue = applyColorInputValue({ formatInput: true })\n if (formattedValue && event.target instanceof HTMLInputElement) event.target.value = formattedValue\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n resetColorInputValue()\n }\n}\n\nfunction handleColorInputFocus() {\n isColorInputFocused.value = true\n}\n\nfunction handleColorInputBlur(event: FocusEvent) {\n isColorInputFocused.value = false\n clearColorInputCommitTimer()\n const formattedValue = applyColorInputValue({ formatInput: true })\n if (formattedValue && event.target instanceof HTMLInputElement) event.target.value = formattedValue\n}\n\nfunction updatePanelPosition() {\n return nextTick(() => {\n const triggerEl = rootRef.value\n if (!triggerEl) return\n const triggerRect = triggerEl.getBoundingClientRect()\n const panelHeight = panelRef.value?.offsetHeight || 360\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n const maxLeft = viewportWidth - panelWidth - viewportPadding\n const belowTop = triggerRect.bottom + panelGap\n const aboveTop = triggerRect.top - panelHeight - panelGap\n\n panelPosition.left = Math.max(viewportPadding, Math.min(triggerRect.left, maxLeft))\n panelPosition.top = belowTop + panelHeight <= viewportHeight - viewportPadding ? belowTop : Math.max(viewportPadding, aboveTop)\n })\n}\n\nfunction setOpen(value: boolean) {\n if (props.disabled) return\n open.value = value\n}\n\nfunction toggleOpen() {\n setOpen(!open.value)\n}\n\nfunction changeMode(mode: ColorPickerMode) {\n if (props.disabled) return\n if (mode !== 'solid' && !isGradientAllowed.value) return\n activeMode.value = mode\n if (activeMode.value !== 'solid') syncPaletteFromActiveGradientStop()\n commitValue()\n}\n\nfunction updatePaletteFromPointer(event: PointerEvent) {\n const rect = paletteRef.value?.getBoundingClientRect()\n if (!rect) return\n paletteColor.s = clampPercent(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100)\n paletteColor.b = clampPercent((1 - getBoundedPointerRatio(event.clientY, rect.top, rect.height)) * 100)\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateHueFromPointer(event: PointerEvent) {\n const rect = hueBarRef.value?.getBoundingClientRect()\n if (!rect) return\n // 色谱条是线性滑块,拖出边界时要停在端点,不能像角度盘一样循环。\n paletteColor.h = Math.round(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 360)\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateOpacityFromPointer(event: PointerEvent) {\n if (!isAlphaAllowed.value) return\n const rect = opacityBarRef.value?.getBoundingClientRect()\n if (!rect) return\n paletteColor.a = clampAlpha(getBoundedPointerRatio(event.clientX, rect.left, rect.width))\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateDegreeFromPointer(event: PointerEvent) {\n const rect = degreeRef.value?.getBoundingClientRect()\n if (!rect) return\n const centerX = rect.left + rect.width / 2\n const centerY = rect.top + rect.height / 2\n const rad = Math.atan2(centerY - event.clientY, event.clientX - centerX)\n const nextDegree = 90 - Math.floor((rad * 180) / Math.PI)\n degree.value = clampHue(nextDegree)\n commitValue()\n}\n\nfunction canRemoveGradientStop(stopId: number) {\n return gradientStops.value.length > 2 && gradientStops.value.some((stop) => stop.id === stopId)\n}\n\n// 只按垂直方向判断移除,横向拖动仍然用于调整百分比并夹在条内。\nfunction isPointerOutsideGradientBar(event: PointerEvent, rect: DOMRect) {\n return event.clientY < rect.top - gradientStopRemoveDistance || event.clientY > rect.bottom + gradientStopRemoveDistance\n}\n\nfunction updateGradientStopFromPointer(event: PointerEvent, stopId: number) {\n const rect = gradientBarRef.value?.getBoundingClientRect()\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!rect || !stop) return\n stop.percent = clampPercent(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100)\n pendingRemoveGradientStopId.value = canRemoveGradientStop(stopId) && isPointerOutsideGradientBar(event, rect) ? stopId : null\n commitValue()\n}\n\nfunction getBoundedPointerRatio(clientPosition: number, start: number, size: number) {\n if (!Number.isFinite(size) || size <= 0) return 0\n return Math.min(1, Math.max(0, (clientPosition - start) / size))\n}\n\nfunction startDrag(event: PointerEvent, update: (event: PointerEvent) => void, onEnd?: (event: PointerEvent) => void, onCancel?: () => void) {\n if (props.disabled) return\n event.preventDefault()\n dragCleanup?.()\n update(event)\n\n const handleMove = (moveEvent: PointerEvent) => {\n moveEvent.preventDefault()\n update(moveEvent)\n }\n const removeListeners = () => {\n document.removeEventListener('pointermove', handleMove)\n document.removeEventListener('pointerup', handleUp)\n document.removeEventListener('pointercancel', handleCancel)\n }\n const handleUp = (upEvent: PointerEvent) => {\n removeListeners()\n dragCleanup = null\n onEnd?.(upEvent)\n }\n const handleCancel = () => {\n removeListeners()\n dragCleanup = null\n onCancel?.()\n }\n\n document.addEventListener('pointermove', handleMove)\n document.addEventListener('pointerup', handleUp)\n document.addEventListener('pointercancel', handleCancel)\n dragCleanup = handleCancel\n}\n\nfunction handlePalettePointerDown(event: PointerEvent) {\n startDrag(event, updatePaletteFromPointer)\n}\n\nfunction handleHuePointerDown(event: PointerEvent) {\n isDraggingHue.value = true\n startDrag(\n event,\n updateHueFromPointer,\n () => {\n isDraggingHue.value = false\n },\n () => {\n isDraggingHue.value = false\n }\n )\n}\n\nfunction handleOpacityPointerDown(event: PointerEvent) {\n isDraggingOpacity.value = true\n startDrag(\n event,\n updateOpacityFromPointer,\n () => {\n isDraggingOpacity.value = false\n },\n () => {\n isDraggingOpacity.value = false\n }\n )\n}\n\nfunction handleDegreePointerDown(event: PointerEvent) {\n isDraggingDegree.value = true\n startDrag(\n event,\n updateDegreeFromPointer,\n () => {\n isDraggingDegree.value = false\n },\n () => {\n isDraggingDegree.value = false\n }\n )\n}\n\nfunction addGradientStop(event: PointerEvent) {\n if (!isGradientAllowed.value || activeMode.value === 'solid' || gradientStops.value.length >= maxGradientStops) return\n const rect = gradientBarRef.value?.getBoundingClientRect()\n if (!rect) return\n const stop = createGradientStop(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100, paletteColor)\n gradientStops.value.push(stop)\n activeGradientStopId.value = stop.id\n commitValue()\n}\n\nfunction handleGradientBarPointerDown(event: PointerEvent) {\n if (props.disabled) return\n addGradientStop(event)\n}\n\nfunction handleGradientStopPointerDown(event: PointerEvent, stopId: number) {\n if (props.disabled) return\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!stop) return\n activeGradientStopId.value = stop.id\n draggingGradientStopId.value = stop.id\n syncPaletteColor(stop.color)\n startDrag(\n event,\n (moveEvent) => updateGradientStopFromPointer(moveEvent, stopId),\n () => {\n if (pendingRemoveGradientStopId.value === stopId) removeGradientStop(stopId)\n draggingGradientStopId.value = null\n pendingRemoveGradientStopId.value = null\n },\n () => {\n draggingGradientStopId.value = null\n pendingRemoveGradientStopId.value = null\n }\n )\n}\n\nfunction handleGradientStopKeydown(event: KeyboardEvent, stopId: number) {\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!stop || props.disabled) return\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault()\n activeGradientStopId.value = stop.id\n stop.percent = clampPercent(stop.percent + (event.key === 'ArrowLeft' ? -1 : 1))\n commitValue()\n }\n}\n\nfunction removeGradientStop(stopId = activeGradientStopId.value) {\n if (stopId === null || gradientStops.value.length <= 2) return\n if (pendingRemoveGradientStopId.value === stopId) pendingRemoveGradientStopId.value = null\n const index = gradientStops.value.findIndex((stop) => stop.id === stopId)\n if (index === -1) return\n gradientStops.value.splice(index, 1)\n const nextStop = gradientStops.value[Math.min(index, gradientStops.value.length - 1)]\n activeGradientStopId.value = nextStop?.id ?? null\n if (nextStop) syncPaletteColor(nextStop.color)\n commitValue()\n}\n\nasync function pickScreenColor() {\n if (props.disabled || typeof window === 'undefined') return\n const EyeDropper = (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper\n if (!EyeDropper) return\n\n try {\n const result = await new EyeDropper().open()\n syncPaletteColor(colorToHsba(result.sRGBHex))\n syncActiveGradientStopColor()\n commitValue()\n } catch {\n // 用户取消系统取色时浏览器会 reject,保持当前颜色即可。\n }\n}\n\nfunction handleTriggerKeydown(event: KeyboardEvent) {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n toggleOpen()\n } else if (event.key === 'Escape') {\n open.value = false\n }\n}\n\nfunction handleDocumentPointerDown(event: PointerEvent) {\n if (!open.value) return\n const target = event.target as Node\n const isOutsideTrigger = rootRef.value && !rootRef.value.contains(target)\n const isOutsidePanel = panelRef.value && !panelRef.value.contains(target)\n if (isOutsideTrigger && isOutsidePanel) open.value = false\n}\n\nfunction handleDocumentKeydown(event: KeyboardEvent) {\n if (!open.value) return\n if (event.key === 'Escape') {\n open.value = false\n }\n}\n\nfunction schedulePanelPositionUpdate() {\n if (open.value) void updatePanelPosition()\n}\n\nonMounted(() => {\n eyeDropperSupported.value = typeof window !== 'undefined' && 'EyeDropper' in window\n document.addEventListener('pointerdown', handleDocumentPointerDown, true)\n document.addEventListener('keydown', handleDocumentKeydown)\n document.addEventListener('scroll', schedulePanelPositionUpdate, true)\n window.addEventListener('resize', schedulePanelPositionUpdate)\n})\n\nonUnmounted(() => {\n dragCleanup?.()\n clearColorInputCommitTimer()\n document.removeEventListener('pointerdown', handleDocumentPointerDown, true)\n document.removeEventListener('keydown', handleDocumentKeydown)\n document.removeEventListener('scroll', schedulePanelPositionUpdate, true)\n window.removeEventListener('resize', schedulePanelPositionUpdate)\n})\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"relative inline-flex align-middle\" :style=\"getUiAttrStyle(attrs)\">\n <button v-bind=\"getUiExposeAttrs(attrs)\" data-ui-colorpicker=\"true\" type=\"button\" :class=\"triggerClass\" :disabled=\"disabled\" :aria-expanded=\"open\" aria-haspopup=\"dialog\" aria-label=\"选择颜色\" @click=\"toggleOpen\" @keydown=\"handleTriggerKeydown\">\n <span :class=\"swatchClass\">\n <span class=\"block h-full w-full rounded-[inherit]\" :style=\"{ background: previewBackground }\"></span>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div v-if=\"open\" ref=\"panelRef\" role=\"dialog\" aria-label=\"颜色选择器\" :style=\"panelStyle\" class=\"ui-colorpicker-panel rounded-lg border border-medium bg-primary text-primary shadow-xl outline-none\" @contextmenu.prevent @pointerdown.stop @selectstart.prevent>\n <div v-if=\"isGradientAllowed\" class=\"flex h-10 items-center gap-1 border-b border-medium px-3\">\n <button v-for=\"item in modeOptions\" :key=\"item.mode\" type=\"button\" :title=\"item.label\" :aria-label=\"item.label\" class=\"flex size-6 items-center justify-center rounded bg-transparent\" @click=\"changeMode(item.mode)\">\n <span\n class=\"size-3.5 rounded-full border transition-[border-color,background,filter]\"\n :class=\"[\n item.mode === activeMode ? 'border-[#ff7d3a]' : 'border-[#7d7d7d] grayscale',\n item.mode === 'solid' ? (item.mode === activeMode ? 'bg-[#ffc9b6]' : 'bg-[#e2e2e2]') : '',\n item.mode === 'linear' ? (item.mode === activeMode ? 'bg-[linear-gradient(180deg,#ffc9b6,#ff5011)]' : 'bg-[linear-gradient(180deg,#ffffff,#999999)]') : '',\n item.mode === 'radial' ? (item.mode === activeMode ? 'bg-[radial-gradient(circle,#ffc9b6,#ff5011)]' : 'bg-[radial-gradient(circle,#ffffff,#999999)]') : ''\n ]\"\n ></span>\n </button>\n </div>\n\n <div v-if=\"isGradientAllowed && activeMode !== 'solid'\" class=\"border-b border-medium py-2\">\n <div data-ui-colorpicker-gradient-row=\"true\" class=\"flex items-center mx-3\">\n <div class=\"relative h-4 min-w-0 flex-1 rounded-full border border-medium ui-colorpicker-checker\" @pointerdown=\"handleGradientBarPointerDown\" ref=\"gradientBarRef\">\n <div class=\"absolute inset-0 rounded-full\" :style=\"{ background: gradientBarBackground }\"></div>\n <button\n v-for=\"stop in gradientStops\"\n :key=\"stop.id\"\n type=\"button\"\n class=\"ui-colorpicker-stop absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(100,116,139,0.75)] outline-none transition-[box-shadow,opacity,transform] hover:scale-125 focus-visible:ring-2 focus-visible:ring-brand/30\"\n :class=\"[stop.id === activeGradientStopId ? 'z-10 ring-2 ring-brand-500' : '', stop.id === draggingGradientStopId ? 'scale-125' : '', stop.id === pendingRemoveGradientStopId ? 'opacity-50' : '']\"\n :style=\"{ left: `${stop.percent}%`, background: hsbaToCss(stop.color) }\"\n :aria-label=\"`渐变节点 ${stop.percent}%`\"\n @pointerdown.stop=\"handleGradientStopPointerDown($event, stop.id)\"\n @keydown=\"handleGradientStopKeydown($event, stop.id)\"\n ></button>\n </div>\n\n <div v-if=\"activeMode === 'linear'\" data-ui-colorpicker-degree-group=\"true\" class=\"flex shrink-0 items-center\">\n <span class=\"min-w-9 text-right font-mono text-xs text-tertiary\">{{ degree }}°</span>\n <div ref=\"degreeRef\" data-ui-colorpicker-degree=\"true\" class=\"relative size-6 overflow-visible rounded-full border border-strong bg-secondary\" @pointerdown=\"handleDegreePointerDown\">\n <span data-ui-colorpicker-degree-pointer=\"true\" class=\"pointer-events-none absolute left-1/2 top-1/2 size-0 origin-left\" :style=\"degreePointerStyle\">\n <span data-ui-colorpicker-degree-line=\"true\" class=\"absolute left-0 top-0 h-0.5 w-2.5 -translate-y-1/2 rounded-full bg-[var(--color-border-strong)]\"></span>\n <span\n data-ui-colorpicker-degree-handle=\"true\"\n class=\"pointer-events-auto absolute left-2.5 top-0 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-strong bg-primary transition-[background-color,border-color,box-shadow,transform] hover:scale-125 hover:border-brand hover:bg-brand-50 hover:shadow-[0_0_0_2px_rgba(59,130,246,0.18)]\"\n :class=\"isDraggingDegree ? 'scale-125 border-brand bg-brand-50 shadow-[0_0_0_2px_rgba(59,130,246,0.18)]' : ''\"\n ></span>\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"grid gap-3 p-3\">\n <div ref=\"paletteRef\" data-ui-colorpicker-palette=\"true\" class=\"ui-colorpicker-palette relative overflow-hidden rounded-md border border-medium\" :style=\"paletteStyle\" @pointerdown=\"handlePalettePointerDown\">\n <div class=\"ui-colorpicker-palette-layer ui-colorpicker-palette-light\"></div>\n <div class=\"ui-colorpicker-palette-layer ui-colorpicker-palette-dark\"></div>\n <span class=\"ui-colorpicker-picker absolute size-3 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)]\" :style=\"palettePickerStyle\"></span>\n </div>\n\n <div class=\"flex items-center gap-3\">\n <button\n type=\"button\"\n class=\"flex size-8 shrink-0 items-center justify-center rounded-md border border-medium bg-secondary text-tertiary transition-colors hover:border-brand/40 hover:text-brand disabled:cursor-not-allowed disabled:opacity-50\"\n :disabled=\"eyeDropperButtonDisabled\"\n aria-label=\"屏幕取色\"\n title=\"屏幕取色\"\n @click=\"pickScreenColor\"\n >\n <span class=\"i-lucide:pipette size-4\"></span>\n </button>\n\n <div class=\"grid min-w-0 flex-1 gap-2\">\n <div ref=\"hueBarRef\" class=\"ui-colorpicker-huebar relative h-3 rounded-full border border-medium\" @pointerdown=\"handleHuePointerDown\">\n <span\n data-ui-colorpicker-hue-handle=\"true\"\n class=\"ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125\"\n :class=\"isDraggingHue ? 'scale-125' : ''\"\n :style=\"huePickerStyle\"\n ></span>\n </div>\n <div v-if=\"isAlphaAllowed\" ref=\"opacityBarRef\" data-ui-colorpicker-opacity=\"true\" class=\"ui-colorpicker-checker relative h-3 rounded-full border border-medium\" @pointerdown=\"handleOpacityPointerDown\">\n <div class=\"absolute inset-0 rounded-full\" :style=\"{ background: opacityBarBackground }\"></div>\n <span\n data-ui-colorpicker-opacity-handle=\"true\"\n class=\"ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125\"\n :class=\"isDraggingOpacity ? 'scale-125' : ''\"\n :style=\"opacityPickerStyle\"\n ></span>\n </div>\n </div>\n\n <span class=\"ui-colorpicker-checker size-8 shrink-0 overflow-hidden rounded-full border border-medium\">\n <span class=\"block h-full w-full rounded-full\" :style=\"{ background: previewBackground }\"></span>\n </span>\n </div>\n\n <div data-ui-colorpicker-input-row=\"true\" class=\"ui-colorpicker-input-row grid items-center gap-2 text-xs\" :style=\"colorInputRowStyle\">\n <input\n data-ui-colorpicker-color-input=\"true\"\n class=\"min-w-0 rounded border bg-secondary px-2 py-1 font-mono text-secondary outline-none transition-colors focus:border-brand\"\n :class=\"colorInputInvalid ? 'border-[#ff4d4f]' : 'border-medium'\"\n :value=\"colorInputValue\"\n :aria-invalid=\"colorInputInvalid\"\n spellcheck=\"false\"\n @focus=\"handleColorInputFocus\"\n @input=\"handleColorInput\"\n @keydown.stop=\"handleColorInputKeydown\"\n @blur=\"handleColorInputBlur\"\n />\n <span class=\"rounded border border-medium bg-secondary px-2 py-1 text-right font-mono text-tertiary\">{{ isAlphaAllowed ? Math.round(paletteColor.a * 100) : 100 }}%</span>\n </div>\n </div>\n </div>\n </Teleport>\n </div>\n</template>\n\n<style scoped>\n.ui-colorpicker-checker {\n background-color: #fff;\n background-image:\n linear-gradient(45deg, rgba(148, 163, 184, 0.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(148, 163, 184, 0.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.35) 75%);\n background-position:\n 0 0,\n 0 6px,\n 6px -6px,\n -6px 0;\n background-size: 12px 12px;\n}\n\n.ui-colorpicker-panel {\n box-sizing: border-box;\n}\n\n.ui-colorpicker-palette {\n height: 9rem;\n}\n\n.ui-colorpicker-palette-layer {\n position: absolute;\n inset: 0;\n}\n\n.ui-colorpicker-palette-light {\n background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\n}\n\n.ui-colorpicker-palette-dark {\n background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));\n}\n\n.ui-colorpicker-input-row {\n grid-template-columns: minmax(0, 1fr) 56px;\n}\n\n.ui-colorpicker-input-row input {\n min-width: 0;\n}\n\n.ui-colorpicker-picker {\n transform: translate(-50%, -50%);\n}\n\n.ui-colorpicker-huebar {\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n}\n</style>\n","<script setup lang=\"ts\">\nimport { clsx } from 'clsx'\nimport { computed, nextTick, onMounted, onUnmounted, reactive, ref, useAttrs, useTemplateRef, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiAttrStyle, getUiExposeAttrs } from '../attrs'\nimport { colorPickerSwatch, colorPickerTrigger, type ColorPickerSize } from '.'\nimport { clampAlpha, clampHue, clampPercent, cloneHsba, colorToHsba, hsbToRgb, hsbaToCss, normalizeDegree, normalizeRgba, parseCssColor, rgbaToCss, rgbaToHex, type ColorPickerHsbaColor, type ColorPickerMode, type ColorPickerValue, type InternalGradientStop } from './color'\n\ndefineOptions({\n inheritAttrs: false\n})\n\ntype EyeDropperConstructor = new () => {\n open: () => Promise<{ sRGBHex: string }>\n}\ntype Booleanish = boolean | 'true' | 'false' | ''\n\nconst props = withDefaults(\n defineProps<{\n /** modelValue 是对象式颜色值,兼容 giacomohuang/colorpicker 的 solid/linear/radial 结构。 */\n modelValue?: ColorPickerValue\n /** size 是触发器尺寸,可选。 */\n size?: ColorPickerSize\n /** allowGradient 表示是否允许选择 linear/radial 渐变模式。 */\n allowGradient?: Booleanish\n /** allowAlpha 表示是否允许选择透明度;关闭后输出 alpha 固定为 1。 */\n allowAlpha?: Booleanish\n /** disabled 表示是否禁用颜色选择交互。 */\n disabled?: boolean\n }>(),\n {\n modelValue: undefined,\n size: 'md',\n allowGradient: true,\n allowAlpha: true,\n disabled: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'update:modelValue', value: ColorPickerValue): void\n (e: 'changed', value: ColorPickerValue): void\n}>()\n\nconst attrs = useAttrs()\nconst rootRef = useTemplateRef<HTMLElement>('rootRef')\nconst panelRef = useTemplateRef<HTMLElement>('panelRef')\nconst paletteRef = useTemplateRef<HTMLElement>('paletteRef')\nconst hueBarRef = useTemplateRef<HTMLElement>('hueBarRef')\nconst opacityBarRef = useTemplateRef<HTMLElement>('opacityBarRef')\nconst gradientBarRef = useTemplateRef<HTMLElement>('gradientBarRef')\nconst degreeRef = useTemplateRef<HTMLElement>('degreeRef')\n\nconst open = ref(false)\nconst activeMode = ref<ColorPickerMode>('solid')\nconst degree = ref(90)\nconst activeGradientStopId = ref<number | null>(null)\nconst draggingGradientStopId = ref<number | null>(null)\nconst pendingRemoveGradientStopId = ref<number | null>(null)\nconst isDraggingHue = ref(false)\nconst isDraggingOpacity = ref(false)\nconst isDraggingDegree = ref(false)\nconst colorInputValue = ref('')\nconst colorInputInvalid = ref(false)\nconst isColorInputFocused = ref(false)\nconst gradientStops = ref<InternalGradientStop[]>([])\nconst paletteColor = reactive<ColorPickerHsbaColor>({ h: 0, s: 0, b: 0, a: 1 })\nconst panelPosition = reactive({ top: 0, left: 0 })\nconst eyeDropperSupported = ref(false)\nlet gradientStopSeed = 0\nlet dragCleanup: (() => void) | null = null\nlet syncingFromModel = false\nlet lastEmittedValue: ColorPickerValue | null = null\nlet lastEmittedSignature = ''\nlet colorInputCommitTimer: number | null = null\n\nconst modeOptions: { mode: ColorPickerMode; label: string }[] = [\n { mode: 'solid', label: '纯色' },\n { mode: 'linear', label: '线性渐变' },\n { mode: 'radial', label: '径向渐变' }\n]\nconst panelWidth = 260\nconst panelGap = 4\nconst viewportPadding = 8\nconst maxGradientStops = 10\nconst colorInputDebounceMs = 200\n// 控制点拖出渐变条一段距离后松手,按设计语义移除该控制点。\nconst gradientStopRemoveDistance = 24\n\nconst normalizeBooleanProp = (value: Booleanish | undefined, fallback: boolean) => {\n if (value === undefined) return fallback\n if (value === 'false') return false\n if (value === 'true' || value === '') return true\n return value\n}\nconst currentRgba = computed(() => hsbToRgb(paletteColor))\nconst activeDisplayRgba = computed(() => {\n if (activeMode.value === 'solid') return currentRgba.value\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n return activeStop ? hsbToRgb(activeStop.color) : currentRgba.value\n})\nconst activeColorText = computed(() => rgbaToHex(normalizeOutputRgba(activeDisplayRgba.value)))\nconst isGradientAllowed = computed(() => normalizeBooleanProp(props.allowGradient, true))\nconst isAlphaAllowed = computed(() => normalizeBooleanProp(props.allowAlpha, true))\nconst hueBackground = computed(() => rgbaToCss(hsbToRgb({ h: paletteColor.h, s: 100, b: 100, a: 1 })))\nconst gradientPreviewStops = computed(() =>\n getSortedGradientStops()\n .map((stop) => `${hsbaToCss(stop.color)} ${stop.percent}%`)\n .join(',')\n)\nconst gradientPreview = computed(() => {\n if (activeMode.value === 'linear') return `linear-gradient(${degree.value}deg,${gradientPreviewStops.value})`\n if (activeMode.value === 'radial') return `radial-gradient(circle,${gradientPreviewStops.value})`\n return rgbaToCss(currentRgba.value)\n})\nconst gradientBarBackground = computed(() => `linear-gradient(to right,${gradientPreviewStops.value || `${rgbaToCss(currentRgba.value)} 0%,${rgbaToCss(currentRgba.value)} 100%`})`)\nconst opacityBarBackground = computed(() => {\n const color = normalizeRgba({ ...currentRgba.value, a: 1 })\n return `linear-gradient(to right, rgba(${color.r},${color.g},${color.b},0), rgba(${color.r},${color.g},${color.b},1))`\n})\nconst previewBackground = computed(() => (activeMode.value === 'solid' ? rgbaToCss(currentRgba.value) : gradientPreview.value))\nconst triggerClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n colorPickerTrigger({\n size: props.size,\n focused: open.value,\n disabled: props.disabled\n })\n )\n)\nconst swatchClass = computed(() => colorPickerSwatch({ size: props.size }))\nconst eyeDropperButtonDisabled = computed(() => props.disabled || !eyeDropperSupported.value)\nconst panelStyle = computed<CSSProperties>(() => ({\n position: 'fixed',\n top: `${panelPosition.top}px`,\n left: `${panelPosition.left}px`,\n width: `${panelWidth}px`,\n maxHeight: `calc(100vh - ${viewportPadding * 2}px)`,\n overflowY: 'auto',\n zIndex: 2000\n}))\nconst paletteStyle = computed<CSSProperties>(() => ({\n background: hueBackground.value,\n height: '9rem'\n}))\nconst colorInputRowStyle = computed<CSSProperties>(() => ({\n gridTemplateColumns: 'minmax(0, 1fr) 56px'\n}))\nconst palettePickerStyle = computed<CSSProperties>(() => ({\n left: `${paletteColor.s}%`,\n top: `${100 - paletteColor.b}%`,\n backgroundColor: rgbaToCss(currentRgba.value)\n}))\nconst huePickerStyle = computed<CSSProperties>(() => ({\n left: `${(paletteColor.h / 360) * 100}%`\n}))\nconst opacityPickerStyle = computed<CSSProperties>(() => ({\n left: `${paletteColor.a * 100}%`\n}))\nconst degreePointerStyle = computed<CSSProperties>(() => ({\n transform: `translateY(-50%) rotate(${degree.value - 90}deg)`\n}))\n\nwatch(\n () => props.modelValue,\n (value) => {\n if (value && (value === lastEmittedValue || getModelSignature(value) === lastEmittedSignature)) {\n lastEmittedValue = null\n lastEmittedSignature = ''\n return\n }\n syncFromModelValue(value)\n },\n { deep: true, immediate: true }\n)\n\nwatch(open, (value) => {\n if (value) void updatePanelPosition()\n})\n\nwatch(\n activeColorText,\n (value) => {\n if (isColorInputFocused.value) return\n colorInputValue.value = value\n colorInputInvalid.value = false\n },\n { immediate: true }\n)\n\nwatch(isGradientAllowed, (value) => {\n if (!value && activeMode.value !== 'solid') {\n activeMode.value = 'solid'\n commitValue()\n }\n})\n\nwatch(isAlphaAllowed, (value) => {\n if (value) return\n let changed = false\n if (paletteColor.a !== 1) {\n paletteColor.a = 1\n changed = true\n }\n gradientStops.value.forEach((stop) => {\n if (stop.color.a !== 1) {\n stop.color.a = 1\n changed = true\n }\n })\n if (changed) commitValue()\n})\n\nfunction isValidMode(mode: unknown): mode is ColorPickerMode {\n return mode === 'solid' || mode === 'linear' || mode === 'radial'\n}\n\nfunction getSortedGradientStops() {\n return [...gradientStops.value].sort((a, b) => a.percent - b.percent)\n}\n\nfunction syncPaletteColor(color: ColorPickerHsbaColor) {\n const normalizedColor = normalizeHsbaForProps(color)\n paletteColor.h = normalizedColor.h\n paletteColor.s = normalizedColor.s\n paletteColor.b = normalizedColor.b\n paletteColor.a = normalizedColor.a\n}\n\nfunction createGradientStop(percent: number, color: ColorPickerHsbaColor): InternalGradientStop {\n return {\n id: gradientStopSeed++,\n percent: clampPercent(percent),\n color: normalizeHsbaForProps(color)\n }\n}\n\nfunction createDefaultGradientStops(color = paletteColor) {\n return [createGradientStop(0, color), createGradientStop(100, color)]\n}\n\nfunction normalizeGradientStops(value?: ColorPickerValue) {\n if (!value?.gradients?.length) return createDefaultGradientStops()\n const stops = value.gradients\n .filter((stop) => stop && typeof stop === 'object')\n .slice(0, maxGradientStops)\n .map((stop) => createGradientStop(stop.percent, colorToHsba(stop.color)))\n\n if (stops.length >= 2) return stops\n if (stops.length === 1) return [stops[0], createGradientStop(100, stops[0].color)]\n return createDefaultGradientStops()\n}\n\nfunction ensureGradientStops() {\n if (gradientStops.value.length >= 2) return\n gradientStops.value = createDefaultGradientStops()\n activeGradientStopId.value = gradientStops.value[0]?.id ?? null\n}\n\nfunction syncPaletteFromActiveGradientStop() {\n if (activeMode.value === 'solid') return\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n if (!activeStop) return\n activeGradientStopId.value = activeStop.id\n syncPaletteColor(activeStop.color)\n}\n\nfunction syncActiveGradientStopColor() {\n if (activeMode.value === 'solid') return\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value)\n if (activeStop) activeStop.color = normalizeHsbaForProps(paletteColor)\n}\n\nfunction syncFromModelValue(value?: ColorPickerValue) {\n syncingFromModel = true\n const nextMode = isGradientAllowed.value && isValidMode(value?.mode) ? value.mode : 'solid'\n const paletteSource = value?.color ?? value?.gradients?.[0]?.color\n activeMode.value = nextMode\n degree.value = normalizeDegree(value?.degree)\n syncPaletteColor(colorToHsba(paletteSource))\n gradientStops.value = normalizeGradientStops(value)\n activeGradientStopId.value = gradientStops.value[0]?.id ?? null\n if (nextMode !== 'solid') syncPaletteFromActiveGradientStop()\n syncingFromModel = false\n}\n\nfunction buildModelValue(): ColorPickerValue {\n if (activeMode.value === 'solid') {\n const color = normalizeOutputRgba(currentRgba.value)\n return {\n mode: 'solid',\n color,\n hex: rgbaToHex(color),\n css: `background-color:${rgbaToCss(color)}`\n }\n }\n\n const gradients = getSortedGradientStops().map((stop) => ({\n percent: stop.percent,\n color: normalizeOutputRgba(hsbToRgb(stop.color))\n }))\n const gradientBody = gradients.map((stop) => `${rgbaToCss(stop.color)} ${stop.percent}%`).join(',')\n\n if (activeMode.value === 'linear') {\n return {\n mode: 'linear',\n degree: degree.value,\n gradients,\n css: `background-image:linear-gradient(${degree.value}deg,${gradientBody})`\n }\n }\n\n return {\n mode: 'radial',\n gradients,\n css: `background-image:radial-gradient(${gradientBody})`\n }\n}\n\nfunction commitValue() {\n if (syncingFromModel) return\n const value = buildModelValue()\n lastEmittedValue = value\n lastEmittedSignature = getModelSignature(value)\n emit('update:modelValue', value)\n emit('changed', value)\n}\n\nfunction getModelSignature(value: ColorPickerValue) {\n return JSON.stringify(value)\n}\n\nfunction normalizeHsbaForProps(color: ColorPickerHsbaColor): ColorPickerHsbaColor {\n const normalizedColor = cloneHsba(color)\n if (!isAlphaAllowed.value) normalizedColor.a = 1\n return normalizedColor\n}\n\nfunction normalizeOutputRgba(color: ReturnType<typeof hsbToRgb>) {\n const normalizedColor = normalizeRgba(color)\n if (!isAlphaAllowed.value) normalizedColor.a = 1\n return normalizedColor\n}\n\nfunction clearColorInputCommitTimer() {\n if (colorInputCommitTimer === null) return\n window.clearTimeout(colorInputCommitTimer)\n colorInputCommitTimer = null\n}\n\nfunction applyColorInputValue(options: { formatInput?: boolean } = {}) {\n const color = parseCssColor(colorInputValue.value)\n if (!color) {\n colorInputInvalid.value = true\n return null\n }\n\n const outputColor = normalizeOutputRgba(color)\n const formattedValue = rgbaToHex(outputColor)\n const nextColor = normalizeHsbaForProps(colorToHsba(outputColor))\n colorInputInvalid.value = false\n if (options.formatInput) colorInputValue.value = formattedValue\n syncPaletteColor(nextColor)\n\n if (activeMode.value !== 'solid') {\n ensureGradientStops()\n const activeStop = gradientStops.value.find((stop) => stop.id === activeGradientStopId.value) ?? gradientStops.value[0]\n if (activeStop) {\n activeGradientStopId.value = activeStop.id\n activeStop.color = nextColor\n }\n }\n\n commitValue()\n return formattedValue\n}\n\nfunction resetColorInputValue() {\n clearColorInputCommitTimer()\n colorInputValue.value = activeColorText.value\n colorInputInvalid.value = false\n}\n\nfunction scheduleColorInputCommit() {\n clearColorInputCommitTimer()\n colorInputCommitTimer = window.setTimeout(() => {\n colorInputCommitTimer = null\n applyColorInputValue()\n }, colorInputDebounceMs)\n}\n\nfunction handleColorInput(event: Event) {\n const value = (event.target as HTMLInputElement).value\n colorInputValue.value = value\n const parsedColor = parseCssColor(value)\n colorInputInvalid.value = value.trim() !== '' && !parsedColor\n if (parsedColor) {\n scheduleColorInputCommit()\n } else {\n clearColorInputCommitTimer()\n }\n}\n\nfunction handleColorInputKeydown(event: KeyboardEvent) {\n if (event.key === 'Enter') {\n event.preventDefault()\n clearColorInputCommitTimer()\n const formattedValue = applyColorInputValue({ formatInput: true })\n if (formattedValue && event.target instanceof HTMLInputElement) event.target.value = formattedValue\n return\n }\n if (event.key === 'Escape') {\n event.preventDefault()\n resetColorInputValue()\n }\n}\n\nfunction handleColorInputFocus() {\n isColorInputFocused.value = true\n}\n\nfunction handleColorInputBlur(event: FocusEvent) {\n isColorInputFocused.value = false\n clearColorInputCommitTimer()\n const formattedValue = applyColorInputValue({ formatInput: true })\n if (formattedValue && event.target instanceof HTMLInputElement) event.target.value = formattedValue\n}\n\nfunction updatePanelPosition() {\n return nextTick(() => {\n const triggerEl = rootRef.value\n if (!triggerEl) return\n const triggerRect = triggerEl.getBoundingClientRect()\n const panelHeight = panelRef.value?.offsetHeight || 360\n const viewportWidth = window.innerWidth\n const viewportHeight = window.innerHeight\n const maxLeft = viewportWidth - panelWidth - viewportPadding\n const belowTop = triggerRect.bottom + panelGap\n const aboveTop = triggerRect.top - panelHeight - panelGap\n\n panelPosition.left = Math.max(viewportPadding, Math.min(triggerRect.left, maxLeft))\n panelPosition.top = belowTop + panelHeight <= viewportHeight - viewportPadding ? belowTop : Math.max(viewportPadding, aboveTop)\n })\n}\n\nfunction setOpen(value: boolean) {\n if (props.disabled) return\n open.value = value\n}\n\nfunction toggleOpen() {\n setOpen(!open.value)\n}\n\nfunction changeMode(mode: ColorPickerMode) {\n if (props.disabled) return\n if (mode !== 'solid' && !isGradientAllowed.value) return\n activeMode.value = mode\n if (activeMode.value !== 'solid') syncPaletteFromActiveGradientStop()\n commitValue()\n}\n\nfunction updatePaletteFromPointer(event: PointerEvent) {\n const rect = paletteRef.value?.getBoundingClientRect()\n if (!rect) return\n paletteColor.s = clampPercent(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100)\n paletteColor.b = clampPercent((1 - getBoundedPointerRatio(event.clientY, rect.top, rect.height)) * 100)\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateHueFromPointer(event: PointerEvent) {\n const rect = hueBarRef.value?.getBoundingClientRect()\n if (!rect) return\n // 色谱条是线性滑块,拖出边界时要停在端点,不能像角度盘一样循环。\n paletteColor.h = Math.round(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 360)\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateOpacityFromPointer(event: PointerEvent) {\n if (!isAlphaAllowed.value) return\n const rect = opacityBarRef.value?.getBoundingClientRect()\n if (!rect) return\n paletteColor.a = clampAlpha(getBoundedPointerRatio(event.clientX, rect.left, rect.width))\n syncActiveGradientStopColor()\n commitValue()\n}\n\nfunction updateDegreeFromPointer(event: PointerEvent) {\n const rect = degreeRef.value?.getBoundingClientRect()\n if (!rect) return\n const centerX = rect.left + rect.width / 2\n const centerY = rect.top + rect.height / 2\n const rad = Math.atan2(centerY - event.clientY, event.clientX - centerX)\n const nextDegree = 90 - Math.floor((rad * 180) / Math.PI)\n degree.value = clampHue(nextDegree)\n commitValue()\n}\n\nfunction canRemoveGradientStop(stopId: number) {\n return gradientStops.value.length > 2 && gradientStops.value.some((stop) => stop.id === stopId)\n}\n\n// 只按垂直方向判断移除,横向拖动仍然用于调整百分比并夹在条内。\nfunction isPointerOutsideGradientBar(event: PointerEvent, rect: DOMRect) {\n return event.clientY < rect.top - gradientStopRemoveDistance || event.clientY > rect.bottom + gradientStopRemoveDistance\n}\n\nfunction updateGradientStopFromPointer(event: PointerEvent, stopId: number) {\n const rect = gradientBarRef.value?.getBoundingClientRect()\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!rect || !stop) return\n stop.percent = clampPercent(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100)\n pendingRemoveGradientStopId.value = canRemoveGradientStop(stopId) && isPointerOutsideGradientBar(event, rect) ? stopId : null\n commitValue()\n}\n\nfunction getBoundedPointerRatio(clientPosition: number, start: number, size: number) {\n if (!Number.isFinite(size) || size <= 0) return 0\n return Math.min(1, Math.max(0, (clientPosition - start) / size))\n}\n\nfunction startDrag(event: PointerEvent, update: (event: PointerEvent) => void, onEnd?: (event: PointerEvent) => void, onCancel?: () => void) {\n if (props.disabled) return\n event.preventDefault()\n dragCleanup?.()\n update(event)\n\n const handleMove = (moveEvent: PointerEvent) => {\n moveEvent.preventDefault()\n update(moveEvent)\n }\n const removeListeners = () => {\n document.removeEventListener('pointermove', handleMove)\n document.removeEventListener('pointerup', handleUp)\n document.removeEventListener('pointercancel', handleCancel)\n }\n const handleUp = (upEvent: PointerEvent) => {\n removeListeners()\n dragCleanup = null\n onEnd?.(upEvent)\n }\n const handleCancel = () => {\n removeListeners()\n dragCleanup = null\n onCancel?.()\n }\n\n document.addEventListener('pointermove', handleMove)\n document.addEventListener('pointerup', handleUp)\n document.addEventListener('pointercancel', handleCancel)\n dragCleanup = handleCancel\n}\n\nfunction handlePalettePointerDown(event: PointerEvent) {\n startDrag(event, updatePaletteFromPointer)\n}\n\nfunction handleHuePointerDown(event: PointerEvent) {\n isDraggingHue.value = true\n startDrag(\n event,\n updateHueFromPointer,\n () => {\n isDraggingHue.value = false\n },\n () => {\n isDraggingHue.value = false\n }\n )\n}\n\nfunction handleOpacityPointerDown(event: PointerEvent) {\n isDraggingOpacity.value = true\n startDrag(\n event,\n updateOpacityFromPointer,\n () => {\n isDraggingOpacity.value = false\n },\n () => {\n isDraggingOpacity.value = false\n }\n )\n}\n\nfunction handleDegreePointerDown(event: PointerEvent) {\n isDraggingDegree.value = true\n startDrag(\n event,\n updateDegreeFromPointer,\n () => {\n isDraggingDegree.value = false\n },\n () => {\n isDraggingDegree.value = false\n }\n )\n}\n\nfunction addGradientStop(event: PointerEvent) {\n if (!isGradientAllowed.value || activeMode.value === 'solid' || gradientStops.value.length >= maxGradientStops) return\n const rect = gradientBarRef.value?.getBoundingClientRect()\n if (!rect) return\n const stop = createGradientStop(getBoundedPointerRatio(event.clientX, rect.left, rect.width) * 100, paletteColor)\n gradientStops.value.push(stop)\n activeGradientStopId.value = stop.id\n commitValue()\n}\n\nfunction handleGradientBarPointerDown(event: PointerEvent) {\n if (props.disabled) return\n addGradientStop(event)\n}\n\nfunction handleGradientStopPointerDown(event: PointerEvent, stopId: number) {\n if (props.disabled) return\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!stop) return\n activeGradientStopId.value = stop.id\n draggingGradientStopId.value = stop.id\n syncPaletteColor(stop.color)\n startDrag(\n event,\n (moveEvent) => updateGradientStopFromPointer(moveEvent, stopId),\n () => {\n if (pendingRemoveGradientStopId.value === stopId) removeGradientStop(stopId)\n draggingGradientStopId.value = null\n pendingRemoveGradientStopId.value = null\n },\n () => {\n draggingGradientStopId.value = null\n pendingRemoveGradientStopId.value = null\n }\n )\n}\n\nfunction handleGradientStopKeydown(event: KeyboardEvent, stopId: number) {\n const stop = gradientStops.value.find((item) => item.id === stopId)\n if (!stop || props.disabled) return\n if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {\n event.preventDefault()\n activeGradientStopId.value = stop.id\n stop.percent = clampPercent(stop.percent + (event.key === 'ArrowLeft' ? -1 : 1))\n commitValue()\n }\n}\n\nfunction removeGradientStop(stopId = activeGradientStopId.value) {\n if (stopId === null || gradientStops.value.length <= 2) return\n if (pendingRemoveGradientStopId.value === stopId) pendingRemoveGradientStopId.value = null\n const index = gradientStops.value.findIndex((stop) => stop.id === stopId)\n if (index === -1) return\n gradientStops.value.splice(index, 1)\n const nextStop = gradientStops.value[Math.min(index, gradientStops.value.length - 1)]\n activeGradientStopId.value = nextStop?.id ?? null\n if (nextStop) syncPaletteColor(nextStop.color)\n commitValue()\n}\n\nasync function pickScreenColor() {\n if (props.disabled || typeof window === 'undefined') return\n const EyeDropper = (window as Window & { EyeDropper?: EyeDropperConstructor }).EyeDropper\n if (!EyeDropper) return\n\n try {\n const result = await new EyeDropper().open()\n syncPaletteColor(colorToHsba(result.sRGBHex))\n syncActiveGradientStopColor()\n commitValue()\n } catch {\n // 用户取消系统取色时浏览器会 reject,保持当前颜色即可。\n }\n}\n\nfunction handleTriggerKeydown(event: KeyboardEvent) {\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault()\n toggleOpen()\n } else if (event.key === 'Escape') {\n open.value = false\n }\n}\n\nfunction handleDocumentPointerDown(event: PointerEvent) {\n if (!open.value) return\n const target = event.target as Node\n const isOutsideTrigger = rootRef.value && !rootRef.value.contains(target)\n const isOutsidePanel = panelRef.value && !panelRef.value.contains(target)\n if (isOutsideTrigger && isOutsidePanel) open.value = false\n}\n\nfunction handleDocumentKeydown(event: KeyboardEvent) {\n if (!open.value) return\n if (event.key === 'Escape') {\n open.value = false\n }\n}\n\nfunction schedulePanelPositionUpdate() {\n if (open.value) void updatePanelPosition()\n}\n\nonMounted(() => {\n eyeDropperSupported.value = typeof window !== 'undefined' && 'EyeDropper' in window\n document.addEventListener('pointerdown', handleDocumentPointerDown, true)\n document.addEventListener('keydown', handleDocumentKeydown)\n document.addEventListener('scroll', schedulePanelPositionUpdate, true)\n window.addEventListener('resize', schedulePanelPositionUpdate)\n})\n\nonUnmounted(() => {\n dragCleanup?.()\n clearColorInputCommitTimer()\n document.removeEventListener('pointerdown', handleDocumentPointerDown, true)\n document.removeEventListener('keydown', handleDocumentKeydown)\n document.removeEventListener('scroll', schedulePanelPositionUpdate, true)\n window.removeEventListener('resize', schedulePanelPositionUpdate)\n})\n</script>\n\n<template>\n <div ref=\"rootRef\" class=\"relative inline-flex align-middle\" :style=\"getUiAttrStyle(attrs)\">\n <button v-bind=\"getUiExposeAttrs(attrs)\" data-ui-colorpicker=\"true\" type=\"button\" :class=\"triggerClass\" :disabled=\"disabled\" :aria-expanded=\"open\" aria-haspopup=\"dialog\" aria-label=\"选择颜色\" @click=\"toggleOpen\" @keydown=\"handleTriggerKeydown\">\n <span :class=\"swatchClass\">\n <span class=\"block h-full w-full rounded-[inherit]\" :style=\"{ background: previewBackground }\"></span>\n </span>\n </button>\n\n <Teleport to=\"body\">\n <div v-if=\"open\" ref=\"panelRef\" role=\"dialog\" aria-label=\"颜色选择器\" :style=\"panelStyle\" class=\"ui-colorpicker-panel rounded-lg border border-medium bg-primary text-primary shadow-xl outline-none\" @contextmenu.prevent @pointerdown.stop @selectstart.prevent>\n <div v-if=\"isGradientAllowed\" class=\"flex h-10 items-center gap-1 border-b border-medium px-3\">\n <button v-for=\"item in modeOptions\" :key=\"item.mode\" type=\"button\" :title=\"item.label\" :aria-label=\"item.label\" class=\"flex size-6 items-center justify-center rounded bg-transparent\" @click=\"changeMode(item.mode)\">\n <span\n class=\"size-3.5 rounded-full border transition-[border-color,background,filter]\"\n :class=\"[\n item.mode === activeMode ? 'border-[#ff7d3a]' : 'border-[#7d7d7d] grayscale',\n item.mode === 'solid' ? (item.mode === activeMode ? 'bg-[#ffc9b6]' : 'bg-[#e2e2e2]') : '',\n item.mode === 'linear' ? (item.mode === activeMode ? 'bg-[linear-gradient(180deg,#ffc9b6,#ff5011)]' : 'bg-[linear-gradient(180deg,#ffffff,#999999)]') : '',\n item.mode === 'radial' ? (item.mode === activeMode ? 'bg-[radial-gradient(circle,#ffc9b6,#ff5011)]' : 'bg-[radial-gradient(circle,#ffffff,#999999)]') : ''\n ]\"\n ></span>\n </button>\n </div>\n\n <div v-if=\"isGradientAllowed && activeMode !== 'solid'\" class=\"border-b border-medium py-2\">\n <div data-ui-colorpicker-gradient-row=\"true\" class=\"flex items-center mx-3\">\n <div class=\"relative h-4 min-w-0 flex-1 rounded-full border border-medium ui-colorpicker-checker\" @pointerdown=\"handleGradientBarPointerDown\" ref=\"gradientBarRef\">\n <div class=\"absolute inset-0 rounded-full\" :style=\"{ background: gradientBarBackground }\"></div>\n <button\n v-for=\"stop in gradientStops\"\n :key=\"stop.id\"\n type=\"button\"\n class=\"ui-colorpicker-stop absolute top-1/2 size-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(100,116,139,0.75)] outline-none transition-[box-shadow,opacity,transform] hover:scale-125 focus-visible:ring-2 focus-visible:ring-brand/30\"\n :class=\"[stop.id === activeGradientStopId ? 'z-10 ring-2 ring-brand-500' : '', stop.id === draggingGradientStopId ? 'scale-125' : '', stop.id === pendingRemoveGradientStopId ? 'opacity-50' : '']\"\n :style=\"{ left: `${stop.percent}%`, background: hsbaToCss(stop.color) }\"\n :aria-label=\"`渐变节点 ${stop.percent}%`\"\n @pointerdown.stop=\"handleGradientStopPointerDown($event, stop.id)\"\n @keydown=\"handleGradientStopKeydown($event, stop.id)\"\n ></button>\n </div>\n\n <div v-if=\"activeMode === 'linear'\" data-ui-colorpicker-degree-group=\"true\" class=\"flex shrink-0 items-center\">\n <span class=\"min-w-9 text-right font-mono text-xs text-tertiary\">{{ degree }}°</span>\n <div ref=\"degreeRef\" data-ui-colorpicker-degree=\"true\" class=\"relative size-6 overflow-visible rounded-full border border-strong bg-secondary\" @pointerdown=\"handleDegreePointerDown\">\n <span data-ui-colorpicker-degree-pointer=\"true\" class=\"pointer-events-none absolute left-1/2 top-1/2 size-0 origin-left\" :style=\"degreePointerStyle\">\n <span data-ui-colorpicker-degree-line=\"true\" class=\"absolute left-0 top-0 h-0.5 w-2.5 -translate-y-1/2 rounded-full bg-[var(--color-border-strong)]\"></span>\n <span\n data-ui-colorpicker-degree-handle=\"true\"\n class=\"pointer-events-auto absolute left-2.5 top-0 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-strong bg-primary transition-[background-color,border-color,box-shadow,transform] hover:scale-125 hover:border-brand hover:bg-brand-50 hover:shadow-[0_0_0_2px_rgba(59,130,246,0.18)]\"\n :class=\"isDraggingDegree ? 'scale-125 border-brand bg-brand-50 shadow-[0_0_0_2px_rgba(59,130,246,0.18)]' : ''\"\n ></span>\n </span>\n </div>\n </div>\n </div>\n </div>\n\n <div class=\"grid gap-3 p-3\">\n <div ref=\"paletteRef\" data-ui-colorpicker-palette=\"true\" class=\"ui-colorpicker-palette relative overflow-hidden rounded-md border border-medium\" :style=\"paletteStyle\" @pointerdown=\"handlePalettePointerDown\">\n <div class=\"ui-colorpicker-palette-layer ui-colorpicker-palette-light\"></div>\n <div class=\"ui-colorpicker-palette-layer ui-colorpicker-palette-dark\"></div>\n <span class=\"ui-colorpicker-picker absolute size-3 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)]\" :style=\"palettePickerStyle\"></span>\n </div>\n\n <div class=\"flex items-center gap-3\">\n <button\n type=\"button\"\n class=\"flex size-8 shrink-0 items-center justify-center rounded-md border border-medium bg-secondary text-tertiary transition-colors hover:border-brand/40 hover:text-brand disabled:cursor-not-allowed disabled:opacity-50\"\n :disabled=\"eyeDropperButtonDisabled\"\n aria-label=\"屏幕取色\"\n title=\"屏幕取色\"\n @click=\"pickScreenColor\"\n >\n <span class=\"i-lucide:pipette size-4\"></span>\n </button>\n\n <div class=\"grid min-w-0 flex-1 gap-2\">\n <div ref=\"hueBarRef\" class=\"ui-colorpicker-huebar relative h-3 rounded-full border border-medium\" @pointerdown=\"handleHuePointerDown\">\n <span\n data-ui-colorpicker-hue-handle=\"true\"\n class=\"ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125\"\n :class=\"isDraggingHue ? 'scale-125' : ''\"\n :style=\"huePickerStyle\"\n ></span>\n </div>\n <div v-if=\"isAlphaAllowed\" ref=\"opacityBarRef\" data-ui-colorpicker-opacity=\"true\" class=\"ui-colorpicker-checker relative h-3 rounded-full border border-medium\" @pointerdown=\"handleOpacityPointerDown\">\n <div class=\"absolute inset-0 rounded-full\" :style=\"{ background: opacityBarBackground }\"></div>\n <span\n data-ui-colorpicker-opacity-handle=\"true\"\n class=\"ui-colorpicker-bar-picker absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(15,23,42,0.55)] transition-transform hover:scale-125\"\n :class=\"isDraggingOpacity ? 'scale-125' : ''\"\n :style=\"opacityPickerStyle\"\n ></span>\n </div>\n </div>\n\n <span class=\"ui-colorpicker-checker size-8 shrink-0 overflow-hidden rounded-full border border-medium\">\n <span class=\"block h-full w-full rounded-full\" :style=\"{ background: previewBackground }\"></span>\n </span>\n </div>\n\n <div data-ui-colorpicker-input-row=\"true\" class=\"ui-colorpicker-input-row grid items-center gap-2 text-xs\" :style=\"colorInputRowStyle\">\n <input\n data-ui-colorpicker-color-input=\"true\"\n class=\"min-w-0 rounded border bg-secondary px-2 py-1 font-mono text-secondary outline-none transition-colors focus:border-brand\"\n :class=\"colorInputInvalid ? 'border-[#ff4d4f]' : 'border-medium'\"\n :value=\"colorInputValue\"\n :aria-invalid=\"colorInputInvalid\"\n spellcheck=\"false\"\n @focus=\"handleColorInputFocus\"\n @input=\"handleColorInput\"\n @keydown.stop=\"handleColorInputKeydown\"\n @blur=\"handleColorInputBlur\"\n />\n <span class=\"rounded border border-medium bg-secondary px-2 py-1 text-right font-mono text-tertiary\">{{ isAlphaAllowed ? Math.round(paletteColor.a * 100) : 100 }}%</span>\n </div>\n </div>\n </div>\n </Teleport>\n </div>\n</template>\n\n<style scoped>\n.ui-colorpicker-checker {\n background-color: #fff;\n background-image:\n linear-gradient(45deg, rgba(148, 163, 184, 0.35) 25%, transparent 25%), linear-gradient(-45deg, rgba(148, 163, 184, 0.35) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgba(148, 163, 184, 0.35) 75%), linear-gradient(-45deg, transparent 75%, rgba(148, 163, 184, 0.35) 75%);\n background-position:\n 0 0,\n 0 6px,\n 6px -6px,\n -6px 0;\n background-size: 12px 12px;\n}\n\n.ui-colorpicker-panel {\n box-sizing: border-box;\n}\n\n.ui-colorpicker-palette {\n height: 9rem;\n}\n\n.ui-colorpicker-palette-layer {\n position: absolute;\n inset: 0;\n}\n\n.ui-colorpicker-palette-light {\n background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\n}\n\n.ui-colorpicker-palette-dark {\n background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));\n}\n\n.ui-colorpicker-input-row {\n grid-template-columns: minmax(0, 1fr) 56px;\n}\n\n.ui-colorpicker-input-row input {\n min-width: 0;\n}\n\n.ui-colorpicker-picker {\n transform: translate(-50%, -50%);\n}\n\n.ui-colorpicker-huebar {\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n}\n</style>\n","import { cva } from 'class-variance-authority'\nimport type { VariantProps } from 'class-variance-authority'\n\nexport { default as ColorPicker } from './ColorPicker.vue'\nexport type { ColorPickerGradientStop, ColorPickerMode, ColorPickerRgbaColor, ColorPickerValue } from './color'\n\n/** colorPickerTrigger 定义管理端 ColorPicker 触发按钮样式。 */\nexport const colorPickerTrigger = cva('group/ui-colorpicker inline-flex shrink-0 items-center justify-center overflow-hidden border bg-primary align-middle transition-colors duration-150', {\n variants: {\n size: {\n sm: 'rounded-md p-1',\n md: 'rounded-md p-1',\n lg: 'rounded-md p-1.5'\n },\n focused: {\n true: 'border-brand ring-2 ring-brand/15',\n false: 'border-control hover:border-brand/40'\n },\n disabled: {\n true: 'cursor-not-allowed bg-primary hover:border-control',\n false: 'cursor-pointer'\n }\n },\n defaultVariants: {\n size: 'md',\n focused: false,\n disabled: false\n }\n})\n\n/** colorPickerSwatch 通过内容尺寸和 trigger padding 自然形成标准控件高度。 */\nexport const colorPickerSwatch = cva('ui-colorpicker-checker block shrink-0 overflow-hidden rounded-[inherit]', {\n variants: {\n size: {\n sm: 'size-5',\n md: 'size-6',\n lg: 'size-6'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\n/** ColorPickerProps 是 colorPickerTrigger 变体推导出的组件属性类型。 */\nexport type ColorPickerProps = VariantProps<typeof colorPickerTrigger>\nexport type ColorPickerSize = NonNullable<ColorPickerProps['size']>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;4cAkFM,KAAa,KACb,KAAW,GACX,IAAkB,GAClB,KAAmB,IACnB,KAAuB,KAEvB,KAA6B;;;;;;;;;;;;;;;;;;;;;EAtEnC,IAAM,IAAQ,GAsBR,KAAO,IAKP,KAAQ,GAAS,GACjB,IAAU,EAA4B,SAAS,GAC/C,IAAW,EAA4B,UAAU,GACjD,KAAa,EAA4B,YAAY,GACrD,KAAY,EAA4B,WAAW,GACnD,KAAgB,EAA4B,eAAe,GAC3D,KAAiB,EAA4B,gBAAgB,GAC7D,KAAY,EAA4B,WAAW,GAEnD,IAAO,EAAI,EAAK,GAChB,IAAa,EAAqB,OAAO,GACzC,IAAS,EAAI,EAAE,GACf,IAAuB,EAAmB,IAAI,GAC9C,IAAyB,EAAmB,IAAI,GAChD,IAA8B,EAAmB,IAAI,GACrD,IAAgB,EAAI,EAAK,GACzB,IAAoB,EAAI,EAAK,GAC7B,IAAmB,EAAI,EAAK,GAC5B,IAAkB,EAAI,EAAE,GACxB,IAAoB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I;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CAAC"}
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
|
|
2
|
-
import { cva as t } from "class-variance-authority";
|
|
3
|
-
import { Teleport as n, Transition as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as ee, createVNode as l, defineComponent as u, inject as d, nextTick as te, normalizeClass as f, normalizeStyle as p, onBeforeUnmount as m, openBlock as h, provide as ne, ref as g, renderSlot as _, toDisplayString as re, unref as v, vShow as y, watch as b, withCtx as x, withDirectives as S, withModifiers as C } from "vue";
|
|
4
|
-
//#region src/drawer/Drawer.vue?vue&type=script&setup=true&lang.ts
|
|
5
|
-
var w = {
|
|
6
|
-
key: 0,
|
|
7
|
-
class: "flex min-h-12 items-center justify-between gap-3 border-b border-zinc-100/50 px-4 py-3 dark:border-zinc-800/50"
|
|
8
|
-
}, T = { class: "min-w-0 truncate text-xs font-bold uppercase tracking-widest text-zinc-500" }, E = {
|
|
9
|
-
key: 1,
|
|
10
|
-
class: "flex justify-end gap-2 border-t border-zinc-100/50 bg-zinc-50/30 px-3 py-2.5 dark:border-zinc-800/50 dark:bg-zinc-800/30"
|
|
11
|
-
}, D = 180, O = /*#__PURE__*/ e(/* @__PURE__ */ u({
|
|
12
|
-
__name: "Drawer",
|
|
13
|
-
props: {
|
|
14
|
-
modelValue: {
|
|
15
|
-
type: Boolean,
|
|
16
|
-
default: void 0
|
|
17
|
-
},
|
|
18
|
-
visible: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
default: void 0
|
|
21
|
-
},
|
|
22
|
-
title: { default: "" },
|
|
23
|
-
direction: { default: "rtl" },
|
|
24
|
-
size: { default: "30%" },
|
|
25
|
-
withHeader: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
default: !0
|
|
28
|
-
},
|
|
29
|
-
showClose: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: !0
|
|
32
|
-
},
|
|
33
|
-
closeOnClickModal: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: !0
|
|
36
|
-
},
|
|
37
|
-
closeOnPressEscape: {
|
|
38
|
-
type: Boolean,
|
|
39
|
-
default: !0
|
|
40
|
-
},
|
|
41
|
-
beforeClose: {
|
|
42
|
-
type: Function,
|
|
43
|
-
default: void 0
|
|
44
|
-
},
|
|
45
|
-
destroyOnClose: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
default: !1
|
|
48
|
-
},
|
|
49
|
-
modal: {
|
|
50
|
-
type: Boolean,
|
|
51
|
-
default: !0
|
|
52
|
-
},
|
|
53
|
-
lockScroll: {
|
|
54
|
-
type: Boolean,
|
|
55
|
-
default: !0
|
|
56
|
-
},
|
|
57
|
-
zIndex: { default: 2e3 },
|
|
58
|
-
bodyClass: { default: "" },
|
|
59
|
-
push: {
|
|
60
|
-
type: [Boolean, Object],
|
|
61
|
-
default: !0
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
emits: [
|
|
65
|
-
"update:modelValue",
|
|
66
|
-
"update:visible",
|
|
67
|
-
"open",
|
|
68
|
-
"opened",
|
|
69
|
-
"close",
|
|
70
|
-
"closed"
|
|
71
|
-
],
|
|
72
|
-
setup(e, { emit: t }) {
|
|
73
|
-
let u = e, O = t, j = i(() => u.modelValue ?? u.visible ?? !1), M = g(j.value), N = Symbol("ui-drawer"), P = d(k, null), F = g([]), I = i(() => u.direction === "rtl" || u.direction === "ltr"), L = i(() => typeof u.size == "number" ? `${u.size}px` : u.size), R = i(() => u.push === !1 ? 0 : typeof u.push == "object" && u.push.distance !== void 0 ? u.push.distance : P ? P.pushDistance.value : D), z = i(() => K(R.value)), B = i(() => {
|
|
74
|
-
if (!F.value.length) return;
|
|
75
|
-
let e = z.value;
|
|
76
|
-
if (e !== "0px") switch (u.direction) {
|
|
77
|
-
case "rtl": return `translateX(-${e})`;
|
|
78
|
-
case "ltr": return `translateX(${e})`;
|
|
79
|
-
case "ttb": return `translateY(${e})`;
|
|
80
|
-
case "btt": return `translateY(-${e})`;
|
|
81
|
-
default: return;
|
|
82
|
-
}
|
|
83
|
-
}), V = i(() => ({
|
|
84
|
-
width: I.value ? L.value : void 0,
|
|
85
|
-
height: I.value ? void 0 : L.value,
|
|
86
|
-
transform: B.value
|
|
87
|
-
})), H = i(() => `ui-drawer-${u.direction}`), U = "", W = !1, G = !1;
|
|
88
|
-
function K(e) {
|
|
89
|
-
return typeof e == "number" ? `${e}px` : e;
|
|
90
|
-
}
|
|
91
|
-
function q(e) {
|
|
92
|
-
O("update:modelValue", e), O("update:visible", e);
|
|
93
|
-
}
|
|
94
|
-
function J() {
|
|
95
|
-
q(!1), O("close");
|
|
96
|
-
}
|
|
97
|
-
async function Y() {
|
|
98
|
-
if (!u.beforeClose) {
|
|
99
|
-
J();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
let e = !1, t = await u.beforeClose(() => {
|
|
103
|
-
e = !0, J();
|
|
104
|
-
});
|
|
105
|
-
t === !1 || e || (u.beforeClose.length === 0 || t !== void 0) && J();
|
|
106
|
-
}
|
|
107
|
-
function X(e) {
|
|
108
|
-
!j.value || !u.closeOnPressEscape || e.key !== "Escape" || (e.preventDefault(), e.stopPropagation(), Y());
|
|
109
|
-
}
|
|
110
|
-
function Z() {
|
|
111
|
-
!u.lockScroll || typeof document > "u" || (U = document.body.style.overflow, document.body.style.overflow = "hidden");
|
|
112
|
-
}
|
|
113
|
-
function Q() {
|
|
114
|
-
!u.lockScroll || typeof document > "u" || (document.body.style.overflow = U);
|
|
115
|
-
}
|
|
116
|
-
function ie(e) {
|
|
117
|
-
u.push === !1 || F.value.includes(e) || (F.value = [...F.value, e]);
|
|
118
|
-
}
|
|
119
|
-
function ae(e) {
|
|
120
|
-
F.value.includes(e) && (F.value = F.value.filter((t) => t !== e));
|
|
121
|
-
}
|
|
122
|
-
function oe() {
|
|
123
|
-
!P || G || (P.push(N), G = !0);
|
|
124
|
-
}
|
|
125
|
-
function $() {
|
|
126
|
-
!P || !G || (P.pull(N), G = !1);
|
|
127
|
-
}
|
|
128
|
-
return ne(k, {
|
|
129
|
-
pushDistance: R,
|
|
130
|
-
push: ie,
|
|
131
|
-
pull: ae
|
|
132
|
-
}), b(j, (e) => {
|
|
133
|
-
e ? (M.value = !0, W = !0, oe(), Z(), O("open"), window.addEventListener("keydown", X, { capture: !0 }), te(() => O("opened"))) : ($(), F.value = [], Q(), window.removeEventListener("keydown", X, { capture: !0 }), W && O("closed"), u.destroyOnClose && window.setTimeout(() => {
|
|
134
|
-
j.value || (M.value = !1);
|
|
135
|
-
}, 180));
|
|
136
|
-
}, { immediate: !0 }), m(() => {
|
|
137
|
-
$(), Q(), window.removeEventListener("keydown", X, { capture: !0 });
|
|
138
|
-
}), (t, i) => (h(), a(n, { to: "body" }, [l(r, { name: "ui-drawer-fade" }, {
|
|
139
|
-
default: x(() => [M.value ? S((h(), s("div", {
|
|
140
|
-
key: 0,
|
|
141
|
-
class: "fixed inset-0 pointer-events-auto",
|
|
142
|
-
style: p({ zIndex: e.zIndex }),
|
|
143
|
-
onMousemove: i[1] ||= C(() => {}, ["stop"]),
|
|
144
|
-
onMousedown: i[2] ||= C(() => {}, ["stop"]),
|
|
145
|
-
onMouseup: i[3] ||= C(() => {}, ["stop"]),
|
|
146
|
-
onPointermove: i[4] ||= C(() => {}, ["stop"]),
|
|
147
|
-
onPointerdown: i[5] ||= C(() => {}, ["stop"]),
|
|
148
|
-
onPointerup: i[6] ||= C(() => {}, ["stop"]),
|
|
149
|
-
onWheel: i[7] ||= C(() => {}, ["stop"]),
|
|
150
|
-
onClick: i[8] ||= C(() => {}, ["stop"]),
|
|
151
|
-
onDblclick: i[9] ||= C(() => {}, ["stop"]),
|
|
152
|
-
onContextmenu: i[10] ||= C(() => {}, ["stop"])
|
|
153
|
-
}, [e.modal ? (h(), s("div", {
|
|
154
|
-
key: 0,
|
|
155
|
-
class: "absolute inset-0 bg-zinc-900/10 backdrop-blur-sm",
|
|
156
|
-
onClick: i[0] ||= (t) => e.closeOnClickModal && Y()
|
|
157
|
-
})) : o("", !0), l(r, {
|
|
158
|
-
name: H.value,
|
|
159
|
-
appear: ""
|
|
160
|
-
}, {
|
|
161
|
-
default: x(() => [S(c("aside", {
|
|
162
|
-
class: f(["ui-drawer-panel", v(A)({ direction: e.direction })]),
|
|
163
|
-
style: p(V.value),
|
|
164
|
-
"data-ui-drawer": "true"
|
|
165
|
-
}, [
|
|
166
|
-
e.withHeader ? (h(), s("header", w, [_(t.$slots, "header", {}, () => [c("h3", T, [_(t.$slots, "icon", {}, void 0, !0), ee(" " + re(e.title), 1)])], !0), e.showClose ? (h(), s("button", {
|
|
167
|
-
key: 0,
|
|
168
|
-
type: "button",
|
|
169
|
-
"aria-label": "关闭",
|
|
170
|
-
class: "group flex size-7 shrink-0 items-center justify-center rounded-full transition-colors hover:bg-brand-200 dark:hover:bg-brand-500",
|
|
171
|
-
onClick: Y
|
|
172
|
-
}, [...i[11] ||= [c("span", { class: "i-lucide:x size-4 text-zinc-400 group-hover:text-brand-600 dark:group-hover:text-brand-200" }, null, -1)]])) : o("", !0)])) : o("", !0),
|
|
173
|
-
c("div", { class: f(["min-h-0 flex-1 overflow-auto", e.bodyClass]) }, [!e.destroyOnClose || j.value ? _(t.$slots, "default", { key: 0 }, void 0, !0) : o("", !0)], 2),
|
|
174
|
-
t.$slots.footer ? (h(), s("footer", E, [_(t.$slots, "footer", {}, void 0, !0)])) : o("", !0)
|
|
175
|
-
], 6), [[y, j.value]])]),
|
|
176
|
-
_: 3
|
|
177
|
-
}, 8, ["name"])], 36)), [[y, j.value]]) : o("", !0)]),
|
|
178
|
-
_: 3
|
|
179
|
-
})]));
|
|
180
|
-
}
|
|
181
|
-
}), [["__scopeId", "data-v-f21b8c82"]]), k = Symbol("ui-drawer-context"), A = t("fixed z-10 flex bg-white/95 shadow-2xl backdrop-blur-md dark:bg-zinc-900/95", {
|
|
182
|
-
variants: { direction: {
|
|
183
|
-
rtl: "inset-y-0 right-0 flex-col border-l border-white/20 dark:border-zinc-800/50",
|
|
184
|
-
ltr: "inset-y-0 left-0 flex-col border-r border-white/20 dark:border-zinc-800/50",
|
|
185
|
-
ttb: "inset-x-0 top-0 flex-col border-b border-white/20 dark:border-zinc-800/50",
|
|
186
|
-
btt: "inset-x-0 bottom-0 flex-col border-t border-white/20 dark:border-zinc-800/50"
|
|
187
|
-
} },
|
|
188
|
-
defaultVariants: { direction: "rtl" }
|
|
189
|
-
});
|
|
190
|
-
//#endregion
|
|
191
|
-
export { A as n, O as r, k as t };
|
|
192
|
-
|
|
193
|
-
//# sourceMappingURL=drawer-C3JZ28Xo.js.map
|