@mcistudio/unoui-vue 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/button/index.js +1 -1
  2. package/dist/checkbox/index.js +1 -1
  3. package/dist/chunks/{ImageEditor-CahA7Ut7.js → ImageEditor-DRoD50TJ.js} +2 -2
  4. package/dist/chunks/{ImageEditor-CahA7Ut7.js.map → ImageEditor-DRoD50TJ.js.map} +1 -1
  5. package/dist/chunks/{Table-DhXmuKQd.js → Table-QvmJFoxl.js} +3 -3
  6. package/dist/chunks/{Table-DhXmuKQd.js.map → Table-QvmJFoxl.js.map} +1 -1
  7. package/dist/chunks/{button-pDObrN_X.js → button-BBFPr3FH.js} +34 -33
  8. package/dist/chunks/{button-pDObrN_X.js.map → button-BBFPr3FH.js.map} +1 -1
  9. package/dist/chunks/{checkbox-9_0oR4kg.js → checkbox-wJpQHCeN.js} +2 -2
  10. package/dist/chunks/{checkbox-9_0oR4kg.js.map → checkbox-wJpQHCeN.js.map} +1 -1
  11. package/dist/chunks/{colorpicker-CcizUCQv.js → colorpicker-B-kSQ2Gh.js} +154 -158
  12. package/dist/chunks/colorpicker-B-kSQ2Gh.js.map +1 -0
  13. package/dist/chunks/control-BIl2ynWn.js +10 -0
  14. package/dist/chunks/control-BIl2ynWn.js.map +1 -0
  15. package/dist/chunks/datepicker-XNgIvgTe.js +1411 -0
  16. package/dist/chunks/datepicker-XNgIvgTe.js.map +1 -0
  17. package/dist/chunks/{dropdown-0l967g7D.js → dropdown-B4XuqfaI.js} +4 -4
  18. package/dist/chunks/dropdown-B4XuqfaI.js.map +1 -0
  19. package/dist/chunks/{form-Qeqkd-HH.js → form-CVJ4YMWA.js} +7 -7
  20. package/dist/chunks/{form-Qeqkd-HH.js.map → form-CVJ4YMWA.js.map} +1 -1
  21. package/dist/chunks/input-hIYHtcTj.js +1272 -0
  22. package/dist/chunks/input-hIYHtcTj.js.map +1 -0
  23. package/dist/chunks/{pagination-Bc583AQX.js → pagination-xntyuczw.js} +38 -56
  24. package/dist/chunks/pagination-xntyuczw.js.map +1 -0
  25. package/dist/chunks/{popconfirm-D6lUfSxG.js → popconfirm-DWmeebIf.js} +2 -2
  26. package/dist/chunks/{popconfirm-D6lUfSxG.js.map → popconfirm-DWmeebIf.js.map} +1 -1
  27. package/dist/chunks/{radio-DnYm59xH.js → radio-DGt8o-UL.js} +12 -12
  28. package/dist/chunks/{radio-DnYm59xH.js.map → radio-DGt8o-UL.js.map} +1 -1
  29. package/dist/chunks/select-eZ9h_f58.js +462 -0
  30. package/dist/chunks/select-eZ9h_f58.js.map +1 -0
  31. package/dist/chunks/{switch-BULGbODP.js → switch-C6a6ga2G.js} +2 -2
  32. package/dist/chunks/{switch-BULGbODP.js.map → switch-C6a6ga2G.js.map} +1 -1
  33. package/dist/chunks/{timepicker-DsGIdcf8.js → timepicker-BU9TRvFI.js} +326 -329
  34. package/dist/chunks/{timepicker-DsGIdcf8.js.map → timepicker-BU9TRvFI.js.map} +1 -1
  35. package/dist/colorpicker/index.d.ts +4 -0
  36. package/dist/colorpicker/index.js +2 -2
  37. package/dist/control.d.ts +6 -0
  38. package/dist/datepicker/index.js +1 -1
  39. package/dist/dropdown/index.js +1 -1
  40. package/dist/form/index.js +1 -1
  41. package/dist/imageeditor/index.js +1 -1
  42. package/dist/index.js +31 -31
  43. package/dist/input/index.d.ts +4 -0
  44. package/dist/input/index.js +2 -2
  45. package/dist/modal/Modal.vue.d.ts +1 -1
  46. package/dist/pagination/index.js +1 -1
  47. package/dist/popconfirm/index.js +1 -1
  48. package/dist/radio/index.js +1 -1
  49. package/dist/select/index.js +1 -1
  50. package/dist/style.css +1 -1
  51. package/dist/switch/index.js +1 -1
  52. package/dist/table/index.js +1 -1
  53. package/dist/timepicker/index.js +1 -1
  54. package/dist/uno.js +1 -0
  55. package/dist/uno.js.map +1 -1
  56. package/package.json +1 -1
  57. package/dist/chunks/colorpicker-CcizUCQv.js.map +0 -1
  58. package/dist/chunks/datepicker-Cy808x7X.js +0 -1414
  59. package/dist/chunks/datepicker-Cy808x7X.js.map +0 -1
  60. package/dist/chunks/dropdown-0l967g7D.js.map +0 -1
  61. package/dist/chunks/input-BDOXVCrK.js +0 -1281
  62. package/dist/chunks/input-BDOXVCrK.js.map +0 -1
  63. package/dist/chunks/pagination-Bc583AQX.js.map +0 -1
  64. package/dist/chunks/select-ChTfQM5u.js +0 -417
  65. package/dist/chunks/select-ChTfQM5u.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown-B4XuqfaI.js","names":["$slots"],"sources":["../../src/dropdown/Dropdown.vue","../../src/dropdown/Dropdown.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport SimpleBar from 'simplebar-vue'\n\nimport 'simplebar-vue/dist/simplebar.min.css'\nimport { computed, nextTick, onMounted, onUnmounted, ref, useSlots, useTemplateRef, watch } from 'vue'\n\ntype DropdownItem = object & { disabled?: boolean }\ntype DropdownValue = unknown | unknown[]\ntype DropdownTrigger = 'click' | 'hover' | 'contextMenu'\ntype DropdownPlacement = 'bottomLeft' | 'bottom' | 'bottomRight' | 'topLeft' | 'top' | 'topRight'\ntype OpenChangeSource = 'trigger' | 'menu'\ntype DropdownArrow = boolean | { pointAtCenter?: boolean }\ntype DropdownStyle = string | Record<string, string | number>\n\ninterface TriggerBounds {\n top: number\n bottom: number\n left: number\n right: number\n width: number\n height: number\n}\n\n/**\n * Dropdown 是支持 Teleport、键盘导航和多选值的轻量下拉容器。\n */\nconst props = withDefaults(\n defineProps<{\n /** items 是下拉项数据源,可选;每项可通过 disabled 禁用。 */\n items?: DropdownItem[]\n /** valueKey 是从 item 取值的字段名,可选;为空时使用 item 本身。 */\n valueKey?: string\n /** align 是下拉层水平对齐方式,可选,默认 left。 */\n align?: 'left' | 'right'\n /** placement 是下拉层弹出位置,支持六个常用方位。 */\n placement?: DropdownPlacement\n /** trigger 是触发方式,可组合 click、hover、contextMenu。 */\n trigger?: DropdownTrigger | DropdownTrigger[]\n /** arrow 控制是否显示箭头,可用 pointAtCenter 让箭头指向触发器中心。 */\n arrow?: DropdownArrow\n /** autoAdjustOverflow 控制空间不足时是否自动翻转并限制视口溢出。 */\n autoAdjustOverflow?: boolean\n /** disabled 表示禁用触发器打开行为。 */\n disabled?: boolean\n /** destroyOnHidden 控制关闭后是否销毁下拉层 DOM,默认保留本地旧行为。 */\n destroyOnHidden?: boolean\n /** closeOnSelect 控制选中后是否关闭;未设置时单选关闭、多选保持展开。 */\n closeOnSelect?: boolean\n /** minWidth 是下拉层最小宽度,可选,需为 CSS 长度。 */\n minWidth?: string\n /** width 是下拉层固定宽度,可选,需为 CSS 长度。 */\n width?: string\n /** maxHeight 是滚动区域最大高度,可选,默认 320px。 */\n maxHeight?: string\n /** contentClass 是下拉层额外类名,可选。 */\n contentClass?: string\n /** popupStyle 是浮层额外内联样式。 */\n popupStyle?: DropdownStyle\n /** focusOnOpen 控制打开后是否自动聚焦菜单容器,输入型触发器需要关闭。 */\n focusOnOpen?: boolean\n /** fullWidth 控制触发器容器是否撑满父级,表单控件型下拉可开启。 */\n fullWidth?: boolean\n }>(),\n {\n align: 'left',\n trigger: 'click',\n arrow: false,\n autoAdjustOverflow: true,\n disabled: false,\n destroyOnHidden: true,\n minWidth: '128px',\n maxHeight: '320px',\n focusOnOpen: true,\n fullWidth: false\n }\n)\n\nconst value = defineModel<DropdownValue>('value')\nconst isOpen = defineModel<boolean>('open', { default: false })\nconst slots = useSlots()\nconst dropdownRef = useTemplateRef('dropdownRef')\nconst menuContainerRef = useTemplateRef('menuContainerRef')\nconst menuRef = useTemplateRef('menuRef')\nconst activeIndex = ref(-1)\nconst keyboardNavigationActive = ref(false)\nconst menuTop = ref<number | null>(null)\nconst menuScrollMaxHeight = ref(props.maxHeight)\nconst menuMeasuredWidth = ref<number | null>(null)\nconst menuGap = 4\nconst viewportPadding = 8\nconst arrowSize = 8\nlet positionFrame = 0\nlet positionUpdateId = 0\nlet shouldRefreshTriggerBounds = false\nlet latestOpenChangeSource: OpenChangeSource = 'trigger'\nlet triggerResizeObserver: ResizeObserver | null = null\nlet hoverOpenTimer: number | undefined\n\nconst triggerBounds = ref<TriggerBounds>({\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n width: 0,\n height: 0\n})\nconst activePlacement = ref<DropdownPlacement>(props.placement ?? (props.align === 'right' ? 'bottomRight' : 'bottomLeft'))\nconst contextMenuPoint = ref<{ left: number; top: number } | null>(null)\n\nconst getTriggerBounds = (): TriggerBounds | null => {\n const triggerEl = dropdownRef.value\n if (!triggerEl) return null\n\n const rect = triggerEl.getBoundingClientRect()\n return {\n top: rect.top,\n bottom: rect.bottom,\n left: rect.left,\n right: rect.right,\n width: rect.width,\n height: rect.height\n }\n}\n\n// 触发器在普通文档流中,下拉层通过 Teleport 固定到 body,需要缓存触发器的视口坐标。\nconst updateTriggerBounds = () => {\n const bounds = getTriggerBounds()\n if (bounds) triggerBounds.value = bounds\n}\n\nconst parsePixelLength = (value?: string) => {\n const match = value?.match(/^(\\d+(?:\\.\\d+)?)px$/)\n return match ? Number(match[1]) : undefined\n}\n\nconst normalizePlacement = (): DropdownPlacement => props.placement ?? (props.align === 'right' ? 'bottomRight' : 'bottomLeft')\n\nconst normalizedTriggers = computed<DropdownTrigger[]>(() => (Array.isArray(props.trigger) ? props.trigger : [props.trigger]))\nconst shouldRenderMenu = computed(() => isOpen.value || !props.destroyOnHidden)\nconst hasArrow = computed(() => Boolean(props.arrow))\nconst arrowPointAtCenter = computed(() => typeof props.arrow === 'object' && Boolean(props.arrow.pointAtCenter))\n\nconst normalizeStyleValue = (style?: DropdownStyle) => {\n if (!style) return {}\n if (typeof style === 'string') return style\n return style\n}\n\nconst extraPopupStyle = computed(() => normalizeStyleValue(props.popupStyle))\n\nconst getAlignment = (placement: DropdownPlacement) => {\n if (placement.endsWith('Left')) return 'left'\n if (placement.endsWith('Right')) return 'right'\n return 'center'\n}\n\nconst getVerticalPlacement = (placement: DropdownPlacement) => (placement.startsWith('top') ? 'top' : 'bottom')\n\nconst getOppositePlacement = (placement: DropdownPlacement): DropdownPlacement => {\n const alignment = getAlignment(placement)\n const isTop = placement.startsWith('top')\n if (alignment === 'left') return isTop ? 'bottomLeft' : 'topLeft'\n if (alignment === 'right') return isTop ? 'bottomRight' : 'topRight'\n return isTop ? 'bottom' : 'top'\n}\n\nconst getHorizontalPosition = (placement: DropdownPlacement, anchorBounds: TriggerBounds, menuWidth: number) => {\n if (contextMenuPoint.value) return contextMenuPoint.value.left\n const alignment = getAlignment(placement)\n if (alignment === 'center') return anchorBounds.left + (anchorBounds.width - menuWidth) / 2\n if (alignment === 'right') return anchorBounds.right - menuWidth\n return anchorBounds.left\n}\n\nconst getAnchorBounds = (): TriggerBounds => {\n if (!contextMenuPoint.value) return triggerBounds.value\n const { left, top } = contextMenuPoint.value\n return {\n top,\n bottom: top,\n left,\n right: left,\n width: 0,\n height: 0\n }\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(value, max))\n\nconst getClampedLeft = (left: number, menuWidth: number, viewportWidth: number) => {\n if (!props.autoAdjustOverflow) return left\n const maxLeft = Math.max(viewportPadding, viewportWidth - menuWidth - viewportPadding)\n return clamp(left, viewportPadding, maxLeft)\n}\n\nconst getArrowLeft = (menuLeft: number, menuWidth: number) => {\n const anchorCenter = contextMenuPoint.value ? contextMenuPoint.value.left : triggerBounds.value.left + triggerBounds.value.width / 2\n if (arrowPointAtCenter.value) return clamp(anchorCenter - menuLeft - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n const alignment = getAlignment(activePlacement.value)\n if (alignment === 'center') return clamp(menuWidth / 2 - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n return clamp(anchorCenter - menuLeft - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n}\n\nconst menuStyle = computed(() => {\n const anchorBounds = getAnchorBounds()\n const expectedWidth = menuMeasuredWidth.value ?? parsePixelLength(props.width) ?? parsePixelLength(props.minWidth) ?? 0\n const viewportWidth = typeof window === 'undefined' ? 0 : window.innerWidth\n const menuWidth = expectedWidth || anchorBounds.width || parsePixelLength(props.minWidth) || 128\n const rawLeft = getHorizontalPosition(activePlacement.value, anchorBounds, menuWidth)\n const style: Record<string, string | number> = {\n position: 'fixed',\n top: `${menuTop.value ?? anchorBounds.bottom + menuGap}px`,\n left: `${getClampedLeft(rawLeft, menuWidth, viewportWidth)}px`,\n minWidth: props.minWidth,\n maxWidth: props.autoAdjustOverflow ? `calc(100vw - ${viewportPadding * 2}px)` : 'none',\n zIndex: 2000\n }\n\n if (props.width) {\n style.width = props.width\n }\n\n return style\n})\n\nconst arrowStyle = computed(() => {\n const menuWidth = menuMeasuredWidth.value ?? parsePixelLength(props.width) ?? parsePixelLength(props.minWidth) ?? triggerBounds.value.width ?? 128\n const menuLeft = parseFloat(String(menuStyle.value.left || '0'))\n return {\n left: `${getArrowLeft(menuLeft, menuWidth)}px`\n }\n})\n\nconst arrowClass = computed(() => (getVerticalPlacement(activePlacement.value) === 'top' ? 'bottom-[-4px] border-b border-r' : 'top-[-4px] border-l border-t'))\n\nconst transformOrigin = computed(() => {\n const vertical = getVerticalPlacement(activePlacement.value)\n const alignment = getAlignment(activePlacement.value)\n const x = alignment === 'left' ? 'left' : alignment === 'right' ? 'right' : 'center'\n return `${x} ${vertical === 'top' ? 'bottom' : 'top'}`\n})\n\nconst hasDefaultContent = computed(() => !!slots.default)\nconst menuContentStyle = computed(() => ({ maxHeight: menuScrollMaxHeight.value }))\n\nconst emit = defineEmits<{\n (e: 'select', item: DropdownItem): void\n (e: 'openChange', open: boolean, info: { source: OpenChangeSource }): void\n (e: 'visible-change', open: boolean): void\n (e: 'visibleChange', open: boolean): void\n}>()\n\nconst getMenuElement = () => {\n const current = menuRef.value\n if (!current) return null\n return current instanceof HTMLElement ? current : current.$el || null\n}\n\nconst setOpen = (open: boolean, source: OpenChangeSource = 'trigger') => {\n if (props.disabled && open) return\n latestOpenChangeSource = source\n isOpen.value = open\n}\n\nconst openByTrigger = () => {\n contextMenuPoint.value = null\n activePlacement.value = normalizePlacement()\n setOpen(true, 'trigger')\n}\n\nconst closeByTrigger = () => {\n setOpen(false, 'trigger')\n}\n\nconst toggleByTrigger = () => {\n contextMenuPoint.value = null\n activePlacement.value = normalizePlacement()\n setOpen(!isOpen.value, 'trigger')\n}\n\nconst clearHoverTimers = () => {\n if (hoverOpenTimer !== undefined) {\n window.clearTimeout(hoverOpenTimer)\n hoverOpenTimer = undefined\n }\n}\n\nconst updateMenuPosition = async (refreshTriggerBounds = false) => {\n const updateId = ++positionUpdateId\n if (!isOpen.value) return\n\n menuScrollMaxHeight.value = props.maxHeight\n await nextTick()\n\n const menuEl = menuContainerRef.value\n if (updateId !== positionUpdateId || !isOpen.value || !menuEl) return\n\n if (refreshTriggerBounds) {\n const nextTriggerBounds = getTriggerBounds()\n if (!nextTriggerBounds) return\n triggerBounds.value = nextTriggerBounds\n }\n\n const anchorBounds = getAnchorBounds()\n const placement = activePlacement.value\n const verticalPlacement = getVerticalPlacement(placement)\n const viewportTop = 0\n const viewportBottom = window.innerHeight\n const paddedTop = viewportTop + viewportPadding\n const paddedBottom = viewportBottom - viewportPadding\n const defaultTop = verticalPlacement === 'top' ? anchorBounds.top - menuEl.offsetHeight - menuGap : anchorBounds.bottom + menuGap\n const menuHeight = menuEl.offsetHeight\n menuMeasuredWidth.value = menuEl.offsetWidth\n\n if (!props.autoAdjustOverflow) {\n menuTop.value = defaultTop\n return\n }\n\n const canFitBelow = anchorBounds.bottom + menuGap + menuHeight <= paddedBottom\n const canFitAbove = anchorBounds.top - menuHeight - menuGap >= paddedTop\n\n if (verticalPlacement === 'bottom' && (canFitBelow || !canFitAbove)) {\n menuTop.value = anchorBounds.bottom + menuGap\n return\n }\n\n if (verticalPlacement === 'top' && (canFitAbove || !canFitBelow)) {\n menuTop.value = anchorBounds.top - menuHeight - menuGap\n return\n }\n\n activePlacement.value = getOppositePlacement(placement)\n const nextVerticalPlacement = getVerticalPlacement(activePlacement.value)\n const nextDefaultTop = nextVerticalPlacement === 'top' ? anchorBounds.top - menuHeight - menuGap : anchorBounds.bottom + menuGap\n\n if (nextDefaultTop >= paddedTop && nextDefaultTop + menuHeight <= paddedBottom) {\n menuTop.value = nextDefaultTop\n return\n }\n\n const scrollEl = getMenuElement()\n const nonScrollableHeight = hasDefaultContent.value ? 0 : Math.max(0, menuHeight - (scrollEl?.offsetHeight || 0))\n const availableBelow = Math.max(0, paddedBottom - (anchorBounds.bottom + menuGap))\n const availableAbove = Math.max(0, anchorBounds.top - menuGap - paddedTop)\n const shouldPlaceAbove = nextVerticalPlacement === 'top' ? availableAbove >= availableBelow : availableAbove > availableBelow\n activePlacement.value = shouldPlaceAbove ? (activePlacement.value.endsWith('Right') ? 'topRight' : activePlacement.value.endsWith('Left') ? 'topLeft' : 'top') : activePlacement.value.endsWith('Right') ? 'bottomRight' : activePlacement.value.endsWith('Left') ? 'bottomLeft' : 'bottom'\n const availableHeight = shouldPlaceAbove ? availableAbove : Math.max(availableBelow, paddedBottom - paddedTop)\n\n // 两侧都放不下完整菜单时,压缩滚动区域高度,保留 header/footer 的实际高度。\n menuScrollMaxHeight.value = `${Math.max(0, Math.floor(availableHeight - nonScrollableHeight))}px`\n await nextTick()\n\n if (updateId !== positionUpdateId || !isOpen.value) return\n const nextMenuHeight = menuEl.offsetHeight\n const nextBottomTop = anchorBounds.bottom + menuGap\n menuTop.value = shouldPlaceAbove ? Math.max(paddedTop, anchorBounds.top - nextMenuHeight - menuGap) : Math.min(nextBottomTop, paddedBottom - nextMenuHeight)\n}\n\nconst scheduleMenuPositionUpdate = (options: { refreshTriggerBounds?: boolean } = {}) => {\n if (!isOpen.value) return\n shouldRefreshTriggerBounds ||= Boolean(options.refreshTriggerBounds)\n if (positionFrame) cancelAnimationFrame(positionFrame)\n positionFrame = requestAnimationFrame(() => {\n positionFrame = 0\n const refreshTriggerBounds = shouldRefreshTriggerBounds\n shouldRefreshTriggerBounds = false\n void updateMenuPosition(refreshTriggerBounds)\n })\n}\n\nconst scheduleMenuPositionRefresh = () => scheduleMenuPositionUpdate({ refreshTriggerBounds: true })\n\nconst handleScroll = (event: Event) => {\n const target = event.target\n if (target instanceof Node && menuContainerRef.value?.contains(target)) return\n scheduleMenuPositionRefresh()\n}\n\nconst isTriggerEnabled = (trigger: DropdownTrigger) => !props.disabled && normalizedTriggers.value.includes(trigger)\n\nconst isInsideHoverArea = (target: EventTarget | null) => {\n if (!(target instanceof Node)) return false\n return Boolean(dropdownRef.value?.contains(target) || menuContainerRef.value?.contains(target))\n}\n\nconst handleTriggerClick = () => {\n if (!isTriggerEnabled('click')) return\n toggleByTrigger()\n}\n\nconst handleContextMenu = (event: MouseEvent) => {\n if (!isTriggerEnabled('contextMenu')) return\n event.preventDefault()\n contextMenuPoint.value = { left: event.clientX, top: event.clientY }\n activePlacement.value = normalizePlacement()\n setOpen(true, 'trigger')\n}\n\nconst handleMouseEnter = () => {\n if (!isTriggerEnabled('hover')) return\n clearHoverTimers()\n hoverOpenTimer = window.setTimeout(() => {\n hoverOpenTimer = undefined\n openByTrigger()\n }, 80)\n}\n\nconst handleMouseLeave = (event: MouseEvent) => {\n if (!isTriggerEnabled('hover')) return\n if (hoverOpenTimer !== undefined) {\n window.clearTimeout(hoverOpenTimer)\n hoverOpenTimer = undefined\n }\n if (isInsideHoverArea(event.relatedTarget)) return\n closeByTrigger()\n}\n\nconst getItemValue = (item: DropdownItem) => (props.valueKey ? (item as Record<string, unknown>)[props.valueKey] : item)\n\nconst getIndexByValue = (val: unknown) => {\n if (!props.items) return -1\n return props.items.findIndex((item) => {\n const itemValue = getItemValue(item)\n if (Array.isArray(val)) {\n return val.includes(itemValue)\n }\n return itemValue === val\n })\n}\n\nconst isItemSelected = (item: DropdownItem) => {\n const itemValue = getItemValue(item)\n if (Array.isArray(value.value)) {\n return value.value.includes(itemValue)\n }\n return value.value === itemValue\n}\n\nwatch(isOpen, (val) => {\n keyboardNavigationActive.value = false\n emit('openChange', val, { source: latestOpenChangeSource })\n emit('visible-change', val)\n emit('visibleChange', val)\n if (val) {\n activeIndex.value = getIndexByValue(value.value)\n if (!contextMenuPoint.value) activePlacement.value = normalizePlacement()\n menuTop.value = null\n menuMeasuredWidth.value = null\n if (!contextMenuPoint.value) updateTriggerBounds()\n nextTick(() => {\n scheduleMenuPositionUpdate()\n\n // SimpleBar component's root element or its wrapper\n const el = getMenuElement()\n if (props.focusOnOpen) el?.focus()\n\n // Scroll to active item if exists\n if (activeIndex.value >= 0) {\n const items = el?.querySelectorAll('.dropdown-item-wrapper')\n const activeItem = items?.[activeIndex.value]\n if (activeItem && 'scrollIntoView' in activeItem && typeof activeItem.scrollIntoView === 'function') {\n activeItem.scrollIntoView({ block: 'nearest' })\n }\n }\n })\n } else {\n clearHoverTimers()\n contextMenuPoint.value = null\n shouldRefreshTriggerBounds = false\n menuTop.value = null\n menuMeasuredWidth.value = null\n menuScrollMaxHeight.value = props.maxHeight\n }\n})\n\nwatch(\n () => props.items,\n () => {\n keyboardNavigationActive.value = false\n }\n)\n\nwatch(\n () => [props.items, props.width, props.minWidth, props.maxHeight, props.placement, props.align],\n () => {\n activeIndex.value = getIndexByValue(value.value)\n activePlacement.value = normalizePlacement()\n menuScrollMaxHeight.value = props.maxHeight\n scheduleMenuPositionUpdate()\n }\n)\n\nconst handleKeyDown = (e: KeyboardEvent) => {\n if (!isOpen.value || !props.items?.length) return false\n\n const items = props.items\n const itemCount = items.length\n e.preventDefault()\n e.stopPropagation()\n if (e.code === 'ArrowDown') {\n keyboardNavigationActive.value = true\n activeIndex.value = (activeIndex.value + 1) % itemCount\n } else if (e.code === 'ArrowUp') {\n keyboardNavigationActive.value = true\n activeIndex.value = (activeIndex.value - 1 + itemCount) % itemCount\n } else if (e.code === 'PageDown') {\n keyboardNavigationActive.value = true\n activeIndex.value = Math.min(activeIndex.value + 5, itemCount - 1)\n } else if (e.code === 'PageUp') {\n keyboardNavigationActive.value = true\n activeIndex.value = Math.max(activeIndex.value - 5, 0)\n } else if (e.code === 'Enter' || e.code === 'Space') {\n keyboardNavigationActive.value = true\n if (activeIndex.value >= 0) {\n handleItemClick(items[activeIndex.value])\n return true\n }\n return false\n } else if (e.code === 'Escape') {\n isOpen.value = false\n return true\n }\n\n // 键盘移动后保持当前激活项在 SimpleBar 可视区域内。\n if (activeIndex.value >= 0) {\n nextTick(() => {\n const menuEl = getMenuElement()\n const itemEl = menuEl?.querySelectorAll('.dropdown-item-wrapper')[activeIndex.value]\n if (itemEl && 'scrollIntoView' in itemEl && typeof itemEl.scrollIntoView === 'function') {\n itemEl.scrollIntoView({ block: 'nearest' })\n }\n })\n }\n\n return true\n}\n\nconst handleItemMouseEnter = (index: number) => {\n activeIndex.value = index\n keyboardNavigationActive.value = false\n}\n\nconst handleItemClick = (item: DropdownItem) => {\n if (item?.disabled) return\n\n const isMultiple = Array.isArray(value.value)\n const itemValue = getItemValue(item)\n if (isMultiple && Array.isArray(value.value)) {\n // 数组值表示多选模式,点击同一项时切换选中状态。\n const index = value.value.indexOf(itemValue)\n if (index === -1) {\n value.value = [...value.value, itemValue]\n } else {\n value.value = value.value.filter((v) => v !== itemValue)\n }\n } else {\n // 单选模式选择后立即关闭下拉层,符合菜单选择预期。\n value.value = itemValue\n if (props.closeOnSelect ?? true) setOpen(false, 'menu')\n }\n\n if (isMultiple && props.closeOnSelect) setOpen(false, 'menu')\n emit('select', item)\n}\n\nconst handleClickOutside = (event: PointerEvent) => {\n const target = event.target as Node\n const isOutsideTrigger = dropdownRef.value && !dropdownRef.value.contains(target)\n const isOutsideMenu = menuContainerRef.value && !menuContainerRef.value.contains(target)\n\n if (isOutsideTrigger && isOutsideMenu) {\n closeByTrigger()\n }\n}\n\nonMounted(() => {\n updateTriggerBounds()\n if (isOpen.value) {\n activeIndex.value = getIndexByValue(value.value)\n activePlacement.value = normalizePlacement()\n scheduleMenuPositionUpdate()\n }\n document.addEventListener('pointerdown', handleClickOutside, true)\n document.addEventListener('scroll', handleScroll, true)\n window.addEventListener('resize', scheduleMenuPositionRefresh)\n\n if (typeof ResizeObserver !== 'undefined' && dropdownRef.value) {\n triggerResizeObserver = new ResizeObserver(() => scheduleMenuPositionUpdate())\n triggerResizeObserver.observe(dropdownRef.value)\n }\n})\n\nonUnmounted(() => {\n clearHoverTimers()\n document.removeEventListener('pointerdown', handleClickOutside, true)\n document.removeEventListener('scroll', handleScroll, true)\n window.removeEventListener('resize', scheduleMenuPositionRefresh)\n triggerResizeObserver?.disconnect()\n if (positionFrame) cancelAnimationFrame(positionFrame)\n})\n\ndefineExpose({\n close: () => (isOpen.value = false),\n open: () => (isOpen.value = true),\n handleKeyDown\n})\n</script>\n\n<template>\n <div ref=\"dropdownRef\" :class=\"['relative inline-block', fullWidth ? 'w-full min-w-0' : '', { 'pointer-events-none opacity-50': disabled }]\" @mouseenter=\"handleMouseEnter\" @mouseleave=\"handleMouseLeave\" @contextmenu=\"handleContextMenu\">\n <div :class=\"['h-full flex items-center', fullWidth ? 'w-full min-w-0' : '']\" @click=\"handleTriggerClick\">\n <slot name=\"trigger\" :open=\"isOpen\" />\n </div>\n\n <Teleport to=\"body\">\n <Transition name=\"ui-dropdown-motion\">\n <div\n v-if=\"shouldRenderMenu\"\n v-show=\"isOpen\"\n ref=\"menuContainerRef\"\n :class=\"['fixed bg-primary border border-control shadow-xl rounded-lg outline-none overflow-hidden', contentClass]\"\n :style=\"[menuStyle, { transformOrigin }, extraPopupStyle]\"\n :data-placement=\"activePlacement\"\n @mouseenter=\"handleMouseEnter\"\n @mouseleave=\"handleMouseLeave\"\n >\n <span v-if=\"hasArrow\" :class=\"['absolute z-1 size-2 rotate-45 border-control bg-primary', arrowClass]\" :style=\"arrowStyle\"></span>\n <slot name=\"header\" />\n <slot v-if=\"$slots.default\" />\n <SimpleBar v-else ref=\"menuRef\" tabindex=\"-1\" role=\"menu\" @keydown=\"handleKeyDown\" class=\"outline-none\" :style=\"menuContentStyle\">\n <div\n v-for=\"(item, index) in items\"\n :key=\"index\"\n class=\"dropdown-item-wrapper\"\n :class=\"{ 'is-active': keyboardNavigationActive && index === activeIndex, 'is-selected': isItemSelected(item), 'pointer-events-none opacity-50': item.disabled }\"\n :data-selected=\"isItemSelected(item) ? 'true' : undefined\"\n @mouseenter=\"handleItemMouseEnter(index)\"\n @click=\"handleItemClick(item)\"\n >\n <slot name=\"item\" :item=\"item\" :index=\"index\" :active=\"keyboardNavigationActive && index === activeIndex\" :selected=\"isItemSelected(item)\" />\n </div>\n </SimpleBar>\n <slot name=\"footer\" />\n </div>\n </Transition>\n </Teleport>\n </div>\n</template>\n\n<style scoped>\n.ui-dropdown-motion-enter-active,\n.ui-dropdown-motion-leave-active {\n transition:\n opacity 120ms cubic-bezier(0.2, 0, 0.2, 1),\n transform 120ms cubic-bezier(0.2, 0, 0.2, 1);\n}\n\n.ui-dropdown-motion-enter-from,\n.ui-dropdown-motion-leave-to {\n opacity: 0;\n transform: scaleY(0.92);\n}\n\n.ui-dropdown-motion-enter-to,\n.ui-dropdown-motion-leave-from {\n opacity: 1;\n transform: scaleY(1);\n}\n\n:deep(.dropdown-item-wrapper),\n:deep(.dropdown-item-wrapper > *) {\n --at-apply: '!text-primary';\n transition-property: color, background-color;\n transition-duration: 150ms;\n}\n\n:deep(.dropdown-item-wrapper:not(.is-selected):hover),\n:deep(.dropdown-item-wrapper:not(.is-selected):hover > *) {\n --at-apply: '!bg-secondary/70';\n}\n\n:deep(.dropdown-item-wrapper.is-selected),\n:deep(.dropdown-item-wrapper.is-selected > *) {\n --at-apply: '!bg-brand/10 !text-brand';\n}\n\n:deep(.dropdown-item-wrapper.is-selected:hover),\n:deep(.dropdown-item-wrapper.is-selected:hover > *) {\n --at-apply: '!bg-brand/15';\n}\n\n:deep(.dropdown-item-wrapper.is-active:not(.is-selected)),\n:deep(.dropdown-item-wrapper.is-active:not(.is-selected) > *) {\n --at-apply: '!bg-brand/10';\n}\n\n:deep(.dropdown-item-wrapper.is-selected.is-active),\n:deep(.dropdown-item-wrapper.is-selected.is-active > *) {\n --at-apply: '!bg-brand/20';\n box-shadow: none !important;\n outline: none !important;\n}\n</style>\n","<script setup lang=\"ts\">\nimport SimpleBar from 'simplebar-vue'\n\nimport 'simplebar-vue/dist/simplebar.min.css'\nimport { computed, nextTick, onMounted, onUnmounted, ref, useSlots, useTemplateRef, watch } from 'vue'\n\ntype DropdownItem = object & { disabled?: boolean }\ntype DropdownValue = unknown | unknown[]\ntype DropdownTrigger = 'click' | 'hover' | 'contextMenu'\ntype DropdownPlacement = 'bottomLeft' | 'bottom' | 'bottomRight' | 'topLeft' | 'top' | 'topRight'\ntype OpenChangeSource = 'trigger' | 'menu'\ntype DropdownArrow = boolean | { pointAtCenter?: boolean }\ntype DropdownStyle = string | Record<string, string | number>\n\ninterface TriggerBounds {\n top: number\n bottom: number\n left: number\n right: number\n width: number\n height: number\n}\n\n/**\n * Dropdown 是支持 Teleport、键盘导航和多选值的轻量下拉容器。\n */\nconst props = withDefaults(\n defineProps<{\n /** items 是下拉项数据源,可选;每项可通过 disabled 禁用。 */\n items?: DropdownItem[]\n /** valueKey 是从 item 取值的字段名,可选;为空时使用 item 本身。 */\n valueKey?: string\n /** align 是下拉层水平对齐方式,可选,默认 left。 */\n align?: 'left' | 'right'\n /** placement 是下拉层弹出位置,支持六个常用方位。 */\n placement?: DropdownPlacement\n /** trigger 是触发方式,可组合 click、hover、contextMenu。 */\n trigger?: DropdownTrigger | DropdownTrigger[]\n /** arrow 控制是否显示箭头,可用 pointAtCenter 让箭头指向触发器中心。 */\n arrow?: DropdownArrow\n /** autoAdjustOverflow 控制空间不足时是否自动翻转并限制视口溢出。 */\n autoAdjustOverflow?: boolean\n /** disabled 表示禁用触发器打开行为。 */\n disabled?: boolean\n /** destroyOnHidden 控制关闭后是否销毁下拉层 DOM,默认保留本地旧行为。 */\n destroyOnHidden?: boolean\n /** closeOnSelect 控制选中后是否关闭;未设置时单选关闭、多选保持展开。 */\n closeOnSelect?: boolean\n /** minWidth 是下拉层最小宽度,可选,需为 CSS 长度。 */\n minWidth?: string\n /** width 是下拉层固定宽度,可选,需为 CSS 长度。 */\n width?: string\n /** maxHeight 是滚动区域最大高度,可选,默认 320px。 */\n maxHeight?: string\n /** contentClass 是下拉层额外类名,可选。 */\n contentClass?: string\n /** popupStyle 是浮层额外内联样式。 */\n popupStyle?: DropdownStyle\n /** focusOnOpen 控制打开后是否自动聚焦菜单容器,输入型触发器需要关闭。 */\n focusOnOpen?: boolean\n /** fullWidth 控制触发器容器是否撑满父级,表单控件型下拉可开启。 */\n fullWidth?: boolean\n }>(),\n {\n align: 'left',\n trigger: 'click',\n arrow: false,\n autoAdjustOverflow: true,\n disabled: false,\n destroyOnHidden: true,\n minWidth: '128px',\n maxHeight: '320px',\n focusOnOpen: true,\n fullWidth: false\n }\n)\n\nconst value = defineModel<DropdownValue>('value')\nconst isOpen = defineModel<boolean>('open', { default: false })\nconst slots = useSlots()\nconst dropdownRef = useTemplateRef('dropdownRef')\nconst menuContainerRef = useTemplateRef('menuContainerRef')\nconst menuRef = useTemplateRef('menuRef')\nconst activeIndex = ref(-1)\nconst keyboardNavigationActive = ref(false)\nconst menuTop = ref<number | null>(null)\nconst menuScrollMaxHeight = ref(props.maxHeight)\nconst menuMeasuredWidth = ref<number | null>(null)\nconst menuGap = 4\nconst viewportPadding = 8\nconst arrowSize = 8\nlet positionFrame = 0\nlet positionUpdateId = 0\nlet shouldRefreshTriggerBounds = false\nlet latestOpenChangeSource: OpenChangeSource = 'trigger'\nlet triggerResizeObserver: ResizeObserver | null = null\nlet hoverOpenTimer: number | undefined\n\nconst triggerBounds = ref<TriggerBounds>({\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n width: 0,\n height: 0\n})\nconst activePlacement = ref<DropdownPlacement>(props.placement ?? (props.align === 'right' ? 'bottomRight' : 'bottomLeft'))\nconst contextMenuPoint = ref<{ left: number; top: number } | null>(null)\n\nconst getTriggerBounds = (): TriggerBounds | null => {\n const triggerEl = dropdownRef.value\n if (!triggerEl) return null\n\n const rect = triggerEl.getBoundingClientRect()\n return {\n top: rect.top,\n bottom: rect.bottom,\n left: rect.left,\n right: rect.right,\n width: rect.width,\n height: rect.height\n }\n}\n\n// 触发器在普通文档流中,下拉层通过 Teleport 固定到 body,需要缓存触发器的视口坐标。\nconst updateTriggerBounds = () => {\n const bounds = getTriggerBounds()\n if (bounds) triggerBounds.value = bounds\n}\n\nconst parsePixelLength = (value?: string) => {\n const match = value?.match(/^(\\d+(?:\\.\\d+)?)px$/)\n return match ? Number(match[1]) : undefined\n}\n\nconst normalizePlacement = (): DropdownPlacement => props.placement ?? (props.align === 'right' ? 'bottomRight' : 'bottomLeft')\n\nconst normalizedTriggers = computed<DropdownTrigger[]>(() => (Array.isArray(props.trigger) ? props.trigger : [props.trigger]))\nconst shouldRenderMenu = computed(() => isOpen.value || !props.destroyOnHidden)\nconst hasArrow = computed(() => Boolean(props.arrow))\nconst arrowPointAtCenter = computed(() => typeof props.arrow === 'object' && Boolean(props.arrow.pointAtCenter))\n\nconst normalizeStyleValue = (style?: DropdownStyle) => {\n if (!style) return {}\n if (typeof style === 'string') return style\n return style\n}\n\nconst extraPopupStyle = computed(() => normalizeStyleValue(props.popupStyle))\n\nconst getAlignment = (placement: DropdownPlacement) => {\n if (placement.endsWith('Left')) return 'left'\n if (placement.endsWith('Right')) return 'right'\n return 'center'\n}\n\nconst getVerticalPlacement = (placement: DropdownPlacement) => (placement.startsWith('top') ? 'top' : 'bottom')\n\nconst getOppositePlacement = (placement: DropdownPlacement): DropdownPlacement => {\n const alignment = getAlignment(placement)\n const isTop = placement.startsWith('top')\n if (alignment === 'left') return isTop ? 'bottomLeft' : 'topLeft'\n if (alignment === 'right') return isTop ? 'bottomRight' : 'topRight'\n return isTop ? 'bottom' : 'top'\n}\n\nconst getHorizontalPosition = (placement: DropdownPlacement, anchorBounds: TriggerBounds, menuWidth: number) => {\n if (contextMenuPoint.value) return contextMenuPoint.value.left\n const alignment = getAlignment(placement)\n if (alignment === 'center') return anchorBounds.left + (anchorBounds.width - menuWidth) / 2\n if (alignment === 'right') return anchorBounds.right - menuWidth\n return anchorBounds.left\n}\n\nconst getAnchorBounds = (): TriggerBounds => {\n if (!contextMenuPoint.value) return triggerBounds.value\n const { left, top } = contextMenuPoint.value\n return {\n top,\n bottom: top,\n left,\n right: left,\n width: 0,\n height: 0\n }\n}\n\nconst clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(value, max))\n\nconst getClampedLeft = (left: number, menuWidth: number, viewportWidth: number) => {\n if (!props.autoAdjustOverflow) return left\n const maxLeft = Math.max(viewportPadding, viewportWidth - menuWidth - viewportPadding)\n return clamp(left, viewportPadding, maxLeft)\n}\n\nconst getArrowLeft = (menuLeft: number, menuWidth: number) => {\n const anchorCenter = contextMenuPoint.value ? contextMenuPoint.value.left : triggerBounds.value.left + triggerBounds.value.width / 2\n if (arrowPointAtCenter.value) return clamp(anchorCenter - menuLeft - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n const alignment = getAlignment(activePlacement.value)\n if (alignment === 'center') return clamp(menuWidth / 2 - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n return clamp(anchorCenter - menuLeft - arrowSize / 2, arrowSize, Math.max(arrowSize, menuWidth - arrowSize * 2))\n}\n\nconst menuStyle = computed(() => {\n const anchorBounds = getAnchorBounds()\n const expectedWidth = menuMeasuredWidth.value ?? parsePixelLength(props.width) ?? parsePixelLength(props.minWidth) ?? 0\n const viewportWidth = typeof window === 'undefined' ? 0 : window.innerWidth\n const menuWidth = expectedWidth || anchorBounds.width || parsePixelLength(props.minWidth) || 128\n const rawLeft = getHorizontalPosition(activePlacement.value, anchorBounds, menuWidth)\n const style: Record<string, string | number> = {\n position: 'fixed',\n top: `${menuTop.value ?? anchorBounds.bottom + menuGap}px`,\n left: `${getClampedLeft(rawLeft, menuWidth, viewportWidth)}px`,\n minWidth: props.minWidth,\n maxWidth: props.autoAdjustOverflow ? `calc(100vw - ${viewportPadding * 2}px)` : 'none',\n zIndex: 2000\n }\n\n if (props.width) {\n style.width = props.width\n }\n\n return style\n})\n\nconst arrowStyle = computed(() => {\n const menuWidth = menuMeasuredWidth.value ?? parsePixelLength(props.width) ?? parsePixelLength(props.minWidth) ?? triggerBounds.value.width ?? 128\n const menuLeft = parseFloat(String(menuStyle.value.left || '0'))\n return {\n left: `${getArrowLeft(menuLeft, menuWidth)}px`\n }\n})\n\nconst arrowClass = computed(() => (getVerticalPlacement(activePlacement.value) === 'top' ? 'bottom-[-4px] border-b border-r' : 'top-[-4px] border-l border-t'))\n\nconst transformOrigin = computed(() => {\n const vertical = getVerticalPlacement(activePlacement.value)\n const alignment = getAlignment(activePlacement.value)\n const x = alignment === 'left' ? 'left' : alignment === 'right' ? 'right' : 'center'\n return `${x} ${vertical === 'top' ? 'bottom' : 'top'}`\n})\n\nconst hasDefaultContent = computed(() => !!slots.default)\nconst menuContentStyle = computed(() => ({ maxHeight: menuScrollMaxHeight.value }))\n\nconst emit = defineEmits<{\n (e: 'select', item: DropdownItem): void\n (e: 'openChange', open: boolean, info: { source: OpenChangeSource }): void\n (e: 'visible-change', open: boolean): void\n (e: 'visibleChange', open: boolean): void\n}>()\n\nconst getMenuElement = () => {\n const current = menuRef.value\n if (!current) return null\n return current instanceof HTMLElement ? current : current.$el || null\n}\n\nconst setOpen = (open: boolean, source: OpenChangeSource = 'trigger') => {\n if (props.disabled && open) return\n latestOpenChangeSource = source\n isOpen.value = open\n}\n\nconst openByTrigger = () => {\n contextMenuPoint.value = null\n activePlacement.value = normalizePlacement()\n setOpen(true, 'trigger')\n}\n\nconst closeByTrigger = () => {\n setOpen(false, 'trigger')\n}\n\nconst toggleByTrigger = () => {\n contextMenuPoint.value = null\n activePlacement.value = normalizePlacement()\n setOpen(!isOpen.value, 'trigger')\n}\n\nconst clearHoverTimers = () => {\n if (hoverOpenTimer !== undefined) {\n window.clearTimeout(hoverOpenTimer)\n hoverOpenTimer = undefined\n }\n}\n\nconst updateMenuPosition = async (refreshTriggerBounds = false) => {\n const updateId = ++positionUpdateId\n if (!isOpen.value) return\n\n menuScrollMaxHeight.value = props.maxHeight\n await nextTick()\n\n const menuEl = menuContainerRef.value\n if (updateId !== positionUpdateId || !isOpen.value || !menuEl) return\n\n if (refreshTriggerBounds) {\n const nextTriggerBounds = getTriggerBounds()\n if (!nextTriggerBounds) return\n triggerBounds.value = nextTriggerBounds\n }\n\n const anchorBounds = getAnchorBounds()\n const placement = activePlacement.value\n const verticalPlacement = getVerticalPlacement(placement)\n const viewportTop = 0\n const viewportBottom = window.innerHeight\n const paddedTop = viewportTop + viewportPadding\n const paddedBottom = viewportBottom - viewportPadding\n const defaultTop = verticalPlacement === 'top' ? anchorBounds.top - menuEl.offsetHeight - menuGap : anchorBounds.bottom + menuGap\n const menuHeight = menuEl.offsetHeight\n menuMeasuredWidth.value = menuEl.offsetWidth\n\n if (!props.autoAdjustOverflow) {\n menuTop.value = defaultTop\n return\n }\n\n const canFitBelow = anchorBounds.bottom + menuGap + menuHeight <= paddedBottom\n const canFitAbove = anchorBounds.top - menuHeight - menuGap >= paddedTop\n\n if (verticalPlacement === 'bottom' && (canFitBelow || !canFitAbove)) {\n menuTop.value = anchorBounds.bottom + menuGap\n return\n }\n\n if (verticalPlacement === 'top' && (canFitAbove || !canFitBelow)) {\n menuTop.value = anchorBounds.top - menuHeight - menuGap\n return\n }\n\n activePlacement.value = getOppositePlacement(placement)\n const nextVerticalPlacement = getVerticalPlacement(activePlacement.value)\n const nextDefaultTop = nextVerticalPlacement === 'top' ? anchorBounds.top - menuHeight - menuGap : anchorBounds.bottom + menuGap\n\n if (nextDefaultTop >= paddedTop && nextDefaultTop + menuHeight <= paddedBottom) {\n menuTop.value = nextDefaultTop\n return\n }\n\n const scrollEl = getMenuElement()\n const nonScrollableHeight = hasDefaultContent.value ? 0 : Math.max(0, menuHeight - (scrollEl?.offsetHeight || 0))\n const availableBelow = Math.max(0, paddedBottom - (anchorBounds.bottom + menuGap))\n const availableAbove = Math.max(0, anchorBounds.top - menuGap - paddedTop)\n const shouldPlaceAbove = nextVerticalPlacement === 'top' ? availableAbove >= availableBelow : availableAbove > availableBelow\n activePlacement.value = shouldPlaceAbove ? (activePlacement.value.endsWith('Right') ? 'topRight' : activePlacement.value.endsWith('Left') ? 'topLeft' : 'top') : activePlacement.value.endsWith('Right') ? 'bottomRight' : activePlacement.value.endsWith('Left') ? 'bottomLeft' : 'bottom'\n const availableHeight = shouldPlaceAbove ? availableAbove : Math.max(availableBelow, paddedBottom - paddedTop)\n\n // 两侧都放不下完整菜单时,压缩滚动区域高度,保留 header/footer 的实际高度。\n menuScrollMaxHeight.value = `${Math.max(0, Math.floor(availableHeight - nonScrollableHeight))}px`\n await nextTick()\n\n if (updateId !== positionUpdateId || !isOpen.value) return\n const nextMenuHeight = menuEl.offsetHeight\n const nextBottomTop = anchorBounds.bottom + menuGap\n menuTop.value = shouldPlaceAbove ? Math.max(paddedTop, anchorBounds.top - nextMenuHeight - menuGap) : Math.min(nextBottomTop, paddedBottom - nextMenuHeight)\n}\n\nconst scheduleMenuPositionUpdate = (options: { refreshTriggerBounds?: boolean } = {}) => {\n if (!isOpen.value) return\n shouldRefreshTriggerBounds ||= Boolean(options.refreshTriggerBounds)\n if (positionFrame) cancelAnimationFrame(positionFrame)\n positionFrame = requestAnimationFrame(() => {\n positionFrame = 0\n const refreshTriggerBounds = shouldRefreshTriggerBounds\n shouldRefreshTriggerBounds = false\n void updateMenuPosition(refreshTriggerBounds)\n })\n}\n\nconst scheduleMenuPositionRefresh = () => scheduleMenuPositionUpdate({ refreshTriggerBounds: true })\n\nconst handleScroll = (event: Event) => {\n const target = event.target\n if (target instanceof Node && menuContainerRef.value?.contains(target)) return\n scheduleMenuPositionRefresh()\n}\n\nconst isTriggerEnabled = (trigger: DropdownTrigger) => !props.disabled && normalizedTriggers.value.includes(trigger)\n\nconst isInsideHoverArea = (target: EventTarget | null) => {\n if (!(target instanceof Node)) return false\n return Boolean(dropdownRef.value?.contains(target) || menuContainerRef.value?.contains(target))\n}\n\nconst handleTriggerClick = () => {\n if (!isTriggerEnabled('click')) return\n toggleByTrigger()\n}\n\nconst handleContextMenu = (event: MouseEvent) => {\n if (!isTriggerEnabled('contextMenu')) return\n event.preventDefault()\n contextMenuPoint.value = { left: event.clientX, top: event.clientY }\n activePlacement.value = normalizePlacement()\n setOpen(true, 'trigger')\n}\n\nconst handleMouseEnter = () => {\n if (!isTriggerEnabled('hover')) return\n clearHoverTimers()\n hoverOpenTimer = window.setTimeout(() => {\n hoverOpenTimer = undefined\n openByTrigger()\n }, 80)\n}\n\nconst handleMouseLeave = (event: MouseEvent) => {\n if (!isTriggerEnabled('hover')) return\n if (hoverOpenTimer !== undefined) {\n window.clearTimeout(hoverOpenTimer)\n hoverOpenTimer = undefined\n }\n if (isInsideHoverArea(event.relatedTarget)) return\n closeByTrigger()\n}\n\nconst getItemValue = (item: DropdownItem) => (props.valueKey ? (item as Record<string, unknown>)[props.valueKey] : item)\n\nconst getIndexByValue = (val: unknown) => {\n if (!props.items) return -1\n return props.items.findIndex((item) => {\n const itemValue = getItemValue(item)\n if (Array.isArray(val)) {\n return val.includes(itemValue)\n }\n return itemValue === val\n })\n}\n\nconst isItemSelected = (item: DropdownItem) => {\n const itemValue = getItemValue(item)\n if (Array.isArray(value.value)) {\n return value.value.includes(itemValue)\n }\n return value.value === itemValue\n}\n\nwatch(isOpen, (val) => {\n keyboardNavigationActive.value = false\n emit('openChange', val, { source: latestOpenChangeSource })\n emit('visible-change', val)\n emit('visibleChange', val)\n if (val) {\n activeIndex.value = getIndexByValue(value.value)\n if (!contextMenuPoint.value) activePlacement.value = normalizePlacement()\n menuTop.value = null\n menuMeasuredWidth.value = null\n if (!contextMenuPoint.value) updateTriggerBounds()\n nextTick(() => {\n scheduleMenuPositionUpdate()\n\n // SimpleBar component's root element or its wrapper\n const el = getMenuElement()\n if (props.focusOnOpen) el?.focus()\n\n // Scroll to active item if exists\n if (activeIndex.value >= 0) {\n const items = el?.querySelectorAll('.dropdown-item-wrapper')\n const activeItem = items?.[activeIndex.value]\n if (activeItem && 'scrollIntoView' in activeItem && typeof activeItem.scrollIntoView === 'function') {\n activeItem.scrollIntoView({ block: 'nearest' })\n }\n }\n })\n } else {\n clearHoverTimers()\n contextMenuPoint.value = null\n shouldRefreshTriggerBounds = false\n menuTop.value = null\n menuMeasuredWidth.value = null\n menuScrollMaxHeight.value = props.maxHeight\n }\n})\n\nwatch(\n () => props.items,\n () => {\n keyboardNavigationActive.value = false\n }\n)\n\nwatch(\n () => [props.items, props.width, props.minWidth, props.maxHeight, props.placement, props.align],\n () => {\n activeIndex.value = getIndexByValue(value.value)\n activePlacement.value = normalizePlacement()\n menuScrollMaxHeight.value = props.maxHeight\n scheduleMenuPositionUpdate()\n }\n)\n\nconst handleKeyDown = (e: KeyboardEvent) => {\n if (!isOpen.value || !props.items?.length) return false\n\n const items = props.items\n const itemCount = items.length\n e.preventDefault()\n e.stopPropagation()\n if (e.code === 'ArrowDown') {\n keyboardNavigationActive.value = true\n activeIndex.value = (activeIndex.value + 1) % itemCount\n } else if (e.code === 'ArrowUp') {\n keyboardNavigationActive.value = true\n activeIndex.value = (activeIndex.value - 1 + itemCount) % itemCount\n } else if (e.code === 'PageDown') {\n keyboardNavigationActive.value = true\n activeIndex.value = Math.min(activeIndex.value + 5, itemCount - 1)\n } else if (e.code === 'PageUp') {\n keyboardNavigationActive.value = true\n activeIndex.value = Math.max(activeIndex.value - 5, 0)\n } else if (e.code === 'Enter' || e.code === 'Space') {\n keyboardNavigationActive.value = true\n if (activeIndex.value >= 0) {\n handleItemClick(items[activeIndex.value])\n return true\n }\n return false\n } else if (e.code === 'Escape') {\n isOpen.value = false\n return true\n }\n\n // 键盘移动后保持当前激活项在 SimpleBar 可视区域内。\n if (activeIndex.value >= 0) {\n nextTick(() => {\n const menuEl = getMenuElement()\n const itemEl = menuEl?.querySelectorAll('.dropdown-item-wrapper')[activeIndex.value]\n if (itemEl && 'scrollIntoView' in itemEl && typeof itemEl.scrollIntoView === 'function') {\n itemEl.scrollIntoView({ block: 'nearest' })\n }\n })\n }\n\n return true\n}\n\nconst handleItemMouseEnter = (index: number) => {\n activeIndex.value = index\n keyboardNavigationActive.value = false\n}\n\nconst handleItemClick = (item: DropdownItem) => {\n if (item?.disabled) return\n\n const isMultiple = Array.isArray(value.value)\n const itemValue = getItemValue(item)\n if (isMultiple && Array.isArray(value.value)) {\n // 数组值表示多选模式,点击同一项时切换选中状态。\n const index = value.value.indexOf(itemValue)\n if (index === -1) {\n value.value = [...value.value, itemValue]\n } else {\n value.value = value.value.filter((v) => v !== itemValue)\n }\n } else {\n // 单选模式选择后立即关闭下拉层,符合菜单选择预期。\n value.value = itemValue\n if (props.closeOnSelect ?? true) setOpen(false, 'menu')\n }\n\n if (isMultiple && props.closeOnSelect) setOpen(false, 'menu')\n emit('select', item)\n}\n\nconst handleClickOutside = (event: PointerEvent) => {\n const target = event.target as Node\n const isOutsideTrigger = dropdownRef.value && !dropdownRef.value.contains(target)\n const isOutsideMenu = menuContainerRef.value && !menuContainerRef.value.contains(target)\n\n if (isOutsideTrigger && isOutsideMenu) {\n closeByTrigger()\n }\n}\n\nonMounted(() => {\n updateTriggerBounds()\n if (isOpen.value) {\n activeIndex.value = getIndexByValue(value.value)\n activePlacement.value = normalizePlacement()\n scheduleMenuPositionUpdate()\n }\n document.addEventListener('pointerdown', handleClickOutside, true)\n document.addEventListener('scroll', handleScroll, true)\n window.addEventListener('resize', scheduleMenuPositionRefresh)\n\n if (typeof ResizeObserver !== 'undefined' && dropdownRef.value) {\n triggerResizeObserver = new ResizeObserver(() => scheduleMenuPositionUpdate())\n triggerResizeObserver.observe(dropdownRef.value)\n }\n})\n\nonUnmounted(() => {\n clearHoverTimers()\n document.removeEventListener('pointerdown', handleClickOutside, true)\n document.removeEventListener('scroll', handleScroll, true)\n window.removeEventListener('resize', scheduleMenuPositionRefresh)\n triggerResizeObserver?.disconnect()\n if (positionFrame) cancelAnimationFrame(positionFrame)\n})\n\ndefineExpose({\n close: () => (isOpen.value = false),\n open: () => (isOpen.value = true),\n handleKeyDown\n})\n</script>\n\n<template>\n <div ref=\"dropdownRef\" :class=\"['relative inline-block', fullWidth ? 'w-full min-w-0' : '', { 'pointer-events-none opacity-50': disabled }]\" @mouseenter=\"handleMouseEnter\" @mouseleave=\"handleMouseLeave\" @contextmenu=\"handleContextMenu\">\n <div :class=\"['h-full flex items-center', fullWidth ? 'w-full min-w-0' : '']\" @click=\"handleTriggerClick\">\n <slot name=\"trigger\" :open=\"isOpen\" />\n </div>\n\n <Teleport to=\"body\">\n <Transition name=\"ui-dropdown-motion\">\n <div\n v-if=\"shouldRenderMenu\"\n v-show=\"isOpen\"\n ref=\"menuContainerRef\"\n :class=\"['fixed bg-primary border border-control shadow-xl rounded-lg outline-none overflow-hidden', contentClass]\"\n :style=\"[menuStyle, { transformOrigin }, extraPopupStyle]\"\n :data-placement=\"activePlacement\"\n @mouseenter=\"handleMouseEnter\"\n @mouseleave=\"handleMouseLeave\"\n >\n <span v-if=\"hasArrow\" :class=\"['absolute z-1 size-2 rotate-45 border-control bg-primary', arrowClass]\" :style=\"arrowStyle\"></span>\n <slot name=\"header\" />\n <slot v-if=\"$slots.default\" />\n <SimpleBar v-else ref=\"menuRef\" tabindex=\"-1\" role=\"menu\" @keydown=\"handleKeyDown\" class=\"outline-none\" :style=\"menuContentStyle\">\n <div\n v-for=\"(item, index) in items\"\n :key=\"index\"\n class=\"dropdown-item-wrapper\"\n :class=\"{ 'is-active': keyboardNavigationActive && index === activeIndex, 'is-selected': isItemSelected(item), 'pointer-events-none opacity-50': item.disabled }\"\n :data-selected=\"isItemSelected(item) ? 'true' : undefined\"\n @mouseenter=\"handleItemMouseEnter(index)\"\n @click=\"handleItemClick(item)\"\n >\n <slot name=\"item\" :item=\"item\" :index=\"index\" :active=\"keyboardNavigationActive && index === activeIndex\" :selected=\"isItemSelected(item)\" />\n </div>\n </SimpleBar>\n <slot name=\"footer\" />\n </div>\n </Transition>\n </Teleport>\n </div>\n</template>\n\n<style scoped>\n.ui-dropdown-motion-enter-active,\n.ui-dropdown-motion-leave-active {\n transition:\n opacity 120ms cubic-bezier(0.2, 0, 0.2, 1),\n transform 120ms cubic-bezier(0.2, 0, 0.2, 1);\n}\n\n.ui-dropdown-motion-enter-from,\n.ui-dropdown-motion-leave-to {\n opacity: 0;\n transform: scaleY(0.92);\n}\n\n.ui-dropdown-motion-enter-to,\n.ui-dropdown-motion-leave-from {\n opacity: 1;\n transform: scaleY(1);\n}\n\n:deep(.dropdown-item-wrapper),\n:deep(.dropdown-item-wrapper > *) {\n --at-apply: '!text-primary';\n transition-property: color, background-color;\n transition-duration: 150ms;\n}\n\n:deep(.dropdown-item-wrapper:not(.is-selected):hover),\n:deep(.dropdown-item-wrapper:not(.is-selected):hover > *) {\n --at-apply: '!bg-secondary/70';\n}\n\n:deep(.dropdown-item-wrapper.is-selected),\n:deep(.dropdown-item-wrapper.is-selected > *) {\n --at-apply: '!bg-brand/10 !text-brand';\n}\n\n:deep(.dropdown-item-wrapper.is-selected:hover),\n:deep(.dropdown-item-wrapper.is-selected:hover > *) {\n --at-apply: '!bg-brand/15';\n}\n\n:deep(.dropdown-item-wrapper.is-active:not(.is-selected)),\n:deep(.dropdown-item-wrapper.is-active:not(.is-selected) > *) {\n --at-apply: '!bg-brand/10';\n}\n\n:deep(.dropdown-item-wrapper.is-selected.is-active),\n:deep(.dropdown-item-wrapper.is-selected.is-active > *) {\n --at-apply: '!bg-brand/20';\n box-shadow: none !important;\n outline: none !important;\n}\n</style>\n"],"mappings":";;;;;;;;;GAwFM,IAAU,GACV,IAAkB,GAClB,IAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAhElB,IAAM,IAAQ,GAmDR,IAAQ,GAA0B,GAAC,OAAO,GAC1C,IAAS,GAAoB,GAAC,MAA0B,GACx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AA,SAA4B,MAAU,EAAA;OAAW,eAAiB,EAAe,CAAI;OAAA,kCAAqC,EAAK;MAAQ,CAAA,CAAA;MAC7J,iBAAe,EAAe,CAAI,IAAA,SAAa,KAAA;MAC/C,eAAU,MAAE,GAAqB,CAAK;MACtC,UAAK,MAAE,GAAgB,CAAI;SAE5B,EAA6I,EAAA,QAAA,QAAA;MAApH;MAAc;MAAQ,QAAQ,EAAA,SAA4B,MAAU,EAAA;MAAc,UAAU,EAAe,CAAI;;;;IAG5I,EAAsB,EAAA,QAAA,UAAA,CAAA,GAAA,KAAA,GAAA,EAAA;sBAxBd,EAAA,KAAM,CAAA,CAAA,IAAA,EAAA,IAAA,EAAA,CAAA,CAAA"}
@@ -562,17 +562,17 @@ var B = {
562
562
  {
563
563
  labelPosition: ["left", "right"],
564
564
  size: "sm",
565
- class: "min-h-[calc(1.75rem+7px)] items-center"
565
+ class: "items-center border-y border-transparent py-1"
566
566
  },
567
567
  {
568
568
  labelPosition: ["left", "right"],
569
569
  size: "md",
570
- class: "min-h-[calc(2rem+3px)] items-center"
570
+ class: "items-center border-y border-transparent py-1.5"
571
571
  },
572
572
  {
573
573
  labelPosition: ["left", "right"],
574
574
  size: "lg",
575
- class: "min-h-[calc(2.25rem)] items-center"
575
+ class: "items-center border-y border-transparent py-1.5"
576
576
  }
577
577
  ],
578
578
  defaultVariants: {
@@ -602,7 +602,7 @@ var B = {
602
602
  "top"
603
603
  ],
604
604
  size: "sm",
605
- class: "min-h-[calc(1.75rem+7px)]"
605
+ class: "min-h-7.5"
606
606
  },
607
607
  {
608
608
  labelPosition: [
@@ -611,7 +611,7 @@ var B = {
611
611
  "top"
612
612
  ],
613
613
  size: "md",
614
- class: "min-h-[calc(2rem+3px)]"
614
+ class: "min-h-8.5"
615
615
  },
616
616
  {
617
617
  labelPosition: [
@@ -620,7 +620,7 @@ var B = {
620
620
  "top"
621
621
  ],
622
622
  size: "lg",
623
- class: "min-h-[calc(2.25rem)]"
623
+ class: "min-h-9.5"
624
624
  }
625
625
  ],
626
626
  defaultVariants: {
@@ -639,4 +639,4 @@ var B = {
639
639
  //#endregion
640
640
  export { W as a, V as c, F as d, R as f, k as g, j as h, H as i, N as l, z as m, B as n, U as o, L as p, M as r, G as s, P as t, I as u };
641
641
 
642
- //# sourceMappingURL=form-Qeqkd-HH.js.map
642
+ //# sourceMappingURL=form-CVJ4YMWA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-Qeqkd-HH.js","names":["$slots"],"sources":["../../src/form/Form.vue","../../src/form/Form.vue","../../src/form/FormItem.vue","../../src/form/FormItem.vue","../../src/form/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ValidateFieldsError, Values } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { computed, nextTick, provide, ref, shallowRef, toRef, useAttrs, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiExposeAttrs } from '../attrs'\nimport { defaultFormValidateMessages, formContextKey, formRoot, getValueByPath, normalizeFormProp, normalizeRules, setValueByPath, type FormContext, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormRules, type FormSize, type FormValidateCallback, type FormValidateTrigger } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** model 是表单数据对象,字段校验会按 prop 从该对象取值。 */\n model?: Values\n /** rules 是表单级校验规则,语法兼容 async-validator,并扩展 preset/trigger。 */\n rules?: FormRules\n /** inline 表示行内表单布局。 */\n inline?: boolean\n /** labelPosition 是标签位置,支持 left/right/top。 */\n labelPosition?: FormLabelPosition\n /** labelWidth 是非 top 布局下的标签列宽。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 的 FormItem 是否保留标签列。 */\n reserveLabelSpace?: boolean\n /** itemGap 是字段之间的纵向间距,支持数字像素值或 CSS 长度。 */\n itemGap?: string | number\n /** size 统一控制 FormItem 标签尺寸,默认 md。 */\n size?: FormSize\n /** disabled 统一设置表单禁用语义,具体控件仍需绑定自身 disabled。 */\n disabled?: boolean\n /** showMessage 是否显示 FormItem 错误消息。 */\n showMessage?: boolean\n /** validateTrigger 设置字段默认自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** validateOnRuleChange 是否在 rules 变化时重新校验。 */\n validateOnRuleChange?: boolean\n /** requireAsteriskPosition 设置必填星号位置。 */\n requireAsteriskPosition?: 'left' | 'right'\n /** hideRequiredAsterisk 是否隐藏必填星号。 */\n hideRequiredAsterisk?: boolean\n }>(),\n {\n model: undefined,\n rules: undefined,\n inline: false,\n labelPosition: 'right',\n labelWidth: '96px',\n reserveLabelSpace: true,\n itemGap: '16px',\n size: 'md',\n disabled: false,\n showMessage: true,\n validateTrigger: () => ['change', 'blur'],\n validateOnRuleChange: true,\n requireAsteriskPosition: 'left',\n hideRequiredAsterisk: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'validate', prop: FormProp | undefined, valid: boolean, message: string): void\n (e: 'submit', event: SubmitEvent): void\n (e: 'reset', event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst fields = shallowRef<FormItemContext[]>([])\n\nconst rootClass = computed(() => clsx(attrs.class as string | undefined, formRoot({ inline: props.inline, size: props.size, disabled: props.disabled })))\nconst rootStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof props.itemGap === 'number' ? `${props.itemGap}px` : props.itemGap\n}))\n\nfunction getLabelWidthValue() {\n if (props.labelPosition === 'top') return 'auto'\n return typeof props.labelWidth === 'number' ? `${props.labelWidth}px` : props.labelWidth\n}\n\nfunction getFieldRules(prop?: FormProp, localRules?: FormItemRule) {\n const normalizedProp = normalizeFormProp(prop)\n return [...normalizeRules(normalizedProp ? props.rules?.[normalizedProp] : undefined), ...normalizeRules(localRules)]\n}\n\nfunction getFieldValue(prop?: FormProp) {\n return getValueByPath(props.model, prop)\n}\n\nfunction setFieldValue(prop: FormProp | undefined, value: unknown) {\n setValueByPath(props.model, prop, value)\n}\n\nfunction getTargetFields(propsValue?: FormProp | FormProp[]) {\n if (!propsValue) return [...fields.value]\n const propList = (Array.isArray(propsValue) && typeof propsValue[0] !== 'string' ? propsValue : [propsValue]) as FormProp[]\n const propSet = new Set(propList.map((prop) => normalizeFormProp(prop)))\n return fields.value.filter((field) => field.prop && propSet.has(normalizeFormProp(field.prop)))\n}\n\nasync function validateField(propsValue?: FormProp | FormProp[], callback?: FormValidateCallback) {\n const targetFields = getTargetFields(propsValue)\n const invalidFields: ValidateFieldsError = {}\n let valid = true\n\n for (const field of targetFields) {\n const result = await field.validate()\n const prop = normalizeFormProp(field.prop)\n if (!result.valid && prop) {\n valid = false\n invalidFields[prop] = result.errors ?? []\n }\n }\n\n await callback?.(valid, valid ? undefined : invalidFields)\n return valid\n}\n\nfunction clearValidate(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.clearValidate())\n}\n\nfunction resetFields(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.resetField())\n}\n\nfunction registerField(field: FormItemContext) {\n fields.value = [...fields.value, field]\n}\n\nfunction unregisterField(field: FormItemContext) {\n fields.value = fields.value.filter((item) => item !== field)\n}\n\nfunction emitValidate(prop: FormProp | undefined, valid: boolean, message: string) {\n emit('validate', prop, valid, message)\n}\n\nfunction handleSubmit(event: SubmitEvent) {\n emit('submit', event)\n}\n\nfunction handleReset(event: Event) {\n resetFields()\n emit('reset', event)\n}\n\nwatch(\n () => props.rules,\n () => {\n if (props.validateOnRuleChange) void nextTick(() => validateField())\n },\n { deep: true }\n)\n\nprovide<FormContext>(formContextKey, {\n get model() {\n return props.model\n },\n get rules() {\n return props.rules\n },\n size: toRef(props, 'size'),\n disabled: toRef(props, 'disabled'),\n inline: toRef(props, 'inline'),\n labelPosition: toRef(props, 'labelPosition'),\n labelWidth: computed(getLabelWidthValue),\n reserveLabelSpace: toRef(props, 'reserveLabelSpace'),\n itemGap: toRef(props, 'itemGap'),\n showMessage: toRef(props, 'showMessage'),\n validateTrigger: toRef(props, 'validateTrigger'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n validateOnRuleChange: toRef(props, 'validateOnRuleChange'),\n registerField,\n unregisterField,\n getFieldRules,\n getFieldValue,\n setFieldValue,\n validateField,\n clearValidate,\n resetFields,\n emitValidate\n})\n\ndefineExpose({\n validate: (callback?: FormValidateCallback) => validateField(undefined, callback),\n validateField,\n resetFields,\n clearValidate,\n fields,\n defaultValidateMessages: ref(defaultFormValidateMessages)\n})\n</script>\n\n<template>\n <form v-bind=\"getUiExposeAttrs(attrs)\" :class=\"rootClass\" :style=\"rootStyle\" :data-disabled=\"disabled || undefined\" @submit=\"handleSubmit\" @reset=\"handleReset\">\n <slot></slot>\n </form>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateFieldsError, Values } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { computed, nextTick, provide, ref, shallowRef, toRef, useAttrs, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiExposeAttrs } from '../attrs'\nimport { defaultFormValidateMessages, formContextKey, formRoot, getValueByPath, normalizeFormProp, normalizeRules, setValueByPath, type FormContext, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormRules, type FormSize, type FormValidateCallback, type FormValidateTrigger } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** model 是表单数据对象,字段校验会按 prop 从该对象取值。 */\n model?: Values\n /** rules 是表单级校验规则,语法兼容 async-validator,并扩展 preset/trigger。 */\n rules?: FormRules\n /** inline 表示行内表单布局。 */\n inline?: boolean\n /** labelPosition 是标签位置,支持 left/right/top。 */\n labelPosition?: FormLabelPosition\n /** labelWidth 是非 top 布局下的标签列宽。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 的 FormItem 是否保留标签列。 */\n reserveLabelSpace?: boolean\n /** itemGap 是字段之间的纵向间距,支持数字像素值或 CSS 长度。 */\n itemGap?: string | number\n /** size 统一控制 FormItem 标签尺寸,默认 md。 */\n size?: FormSize\n /** disabled 统一设置表单禁用语义,具体控件仍需绑定自身 disabled。 */\n disabled?: boolean\n /** showMessage 是否显示 FormItem 错误消息。 */\n showMessage?: boolean\n /** validateTrigger 设置字段默认自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** validateOnRuleChange 是否在 rules 变化时重新校验。 */\n validateOnRuleChange?: boolean\n /** requireAsteriskPosition 设置必填星号位置。 */\n requireAsteriskPosition?: 'left' | 'right'\n /** hideRequiredAsterisk 是否隐藏必填星号。 */\n hideRequiredAsterisk?: boolean\n }>(),\n {\n model: undefined,\n rules: undefined,\n inline: false,\n labelPosition: 'right',\n labelWidth: '96px',\n reserveLabelSpace: true,\n itemGap: '16px',\n size: 'md',\n disabled: false,\n showMessage: true,\n validateTrigger: () => ['change', 'blur'],\n validateOnRuleChange: true,\n requireAsteriskPosition: 'left',\n hideRequiredAsterisk: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'validate', prop: FormProp | undefined, valid: boolean, message: string): void\n (e: 'submit', event: SubmitEvent): void\n (e: 'reset', event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst fields = shallowRef<FormItemContext[]>([])\n\nconst rootClass = computed(() => clsx(attrs.class as string | undefined, formRoot({ inline: props.inline, size: props.size, disabled: props.disabled })))\nconst rootStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof props.itemGap === 'number' ? `${props.itemGap}px` : props.itemGap\n}))\n\nfunction getLabelWidthValue() {\n if (props.labelPosition === 'top') return 'auto'\n return typeof props.labelWidth === 'number' ? `${props.labelWidth}px` : props.labelWidth\n}\n\nfunction getFieldRules(prop?: FormProp, localRules?: FormItemRule) {\n const normalizedProp = normalizeFormProp(prop)\n return [...normalizeRules(normalizedProp ? props.rules?.[normalizedProp] : undefined), ...normalizeRules(localRules)]\n}\n\nfunction getFieldValue(prop?: FormProp) {\n return getValueByPath(props.model, prop)\n}\n\nfunction setFieldValue(prop: FormProp | undefined, value: unknown) {\n setValueByPath(props.model, prop, value)\n}\n\nfunction getTargetFields(propsValue?: FormProp | FormProp[]) {\n if (!propsValue) return [...fields.value]\n const propList = (Array.isArray(propsValue) && typeof propsValue[0] !== 'string' ? propsValue : [propsValue]) as FormProp[]\n const propSet = new Set(propList.map((prop) => normalizeFormProp(prop)))\n return fields.value.filter((field) => field.prop && propSet.has(normalizeFormProp(field.prop)))\n}\n\nasync function validateField(propsValue?: FormProp | FormProp[], callback?: FormValidateCallback) {\n const targetFields = getTargetFields(propsValue)\n const invalidFields: ValidateFieldsError = {}\n let valid = true\n\n for (const field of targetFields) {\n const result = await field.validate()\n const prop = normalizeFormProp(field.prop)\n if (!result.valid && prop) {\n valid = false\n invalidFields[prop] = result.errors ?? []\n }\n }\n\n await callback?.(valid, valid ? undefined : invalidFields)\n return valid\n}\n\nfunction clearValidate(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.clearValidate())\n}\n\nfunction resetFields(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.resetField())\n}\n\nfunction registerField(field: FormItemContext) {\n fields.value = [...fields.value, field]\n}\n\nfunction unregisterField(field: FormItemContext) {\n fields.value = fields.value.filter((item) => item !== field)\n}\n\nfunction emitValidate(prop: FormProp | undefined, valid: boolean, message: string) {\n emit('validate', prop, valid, message)\n}\n\nfunction handleSubmit(event: SubmitEvent) {\n emit('submit', event)\n}\n\nfunction handleReset(event: Event) {\n resetFields()\n emit('reset', event)\n}\n\nwatch(\n () => props.rules,\n () => {\n if (props.validateOnRuleChange) void nextTick(() => validateField())\n },\n { deep: true }\n)\n\nprovide<FormContext>(formContextKey, {\n get model() {\n return props.model\n },\n get rules() {\n return props.rules\n },\n size: toRef(props, 'size'),\n disabled: toRef(props, 'disabled'),\n inline: toRef(props, 'inline'),\n labelPosition: toRef(props, 'labelPosition'),\n labelWidth: computed(getLabelWidthValue),\n reserveLabelSpace: toRef(props, 'reserveLabelSpace'),\n itemGap: toRef(props, 'itemGap'),\n showMessage: toRef(props, 'showMessage'),\n validateTrigger: toRef(props, 'validateTrigger'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n validateOnRuleChange: toRef(props, 'validateOnRuleChange'),\n registerField,\n unregisterField,\n getFieldRules,\n getFieldValue,\n setFieldValue,\n validateField,\n clearValidate,\n resetFields,\n emitValidate\n})\n\ndefineExpose({\n validate: (callback?: FormValidateCallback) => validateField(undefined, callback),\n validateField,\n resetFields,\n clearValidate,\n fields,\n defaultValidateMessages: ref(defaultFormValidateMessages)\n})\n</script>\n\n<template>\n <form v-bind=\"getUiExposeAttrs(attrs)\" :class=\"rootClass\" :style=\"rootStyle\" :data-disabled=\"disabled || undefined\" @submit=\"handleSubmit\" @reset=\"handleReset\">\n <slot></slot>\n </form>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateOption } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { cloneVNode, computed, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, toRaw, useAttrs, useSlots, watch } from 'vue'\nimport type { CSSProperties, VNode } from 'vue'\n\nimport { formContextKey, formItem, formItemContent, formItemLabel, formItemMessage, normalizeFormProp, validateFormValue, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormSize, type FormValidateStatus, type FormValidateTrigger } from '.'\nimport { getUiExposeAttrs } from '../attrs'\nimport { Tooltip } from '../tooltip'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** prop 是 model 字段路径,支持 a.b 或路径数组。 */\n prop?: FormProp\n /** label 是字段标签文本,可选。 */\n label?: string\n /** info 是显示在 label 旁的信息提示内容。 */\n info?: string\n /** rules 是字段局部规则,会与 Form.rules[prop] 合并。 */\n rules?: FormItemRule\n /** required 可单独控制必填星号;未设置时从规则推导。 */\n required?: boolean\n /** error 是外部传入的错误消息,会覆盖内部校验结果。 */\n error?: string\n /** validateStatus 是外部传入的校验状态。 */\n validateStatus?: FormValidateStatus\n /** showMessage 是否显示本字段错误消息,默认继承 Form。 */\n showMessage?: boolean\n /** validateTrigger 覆盖 Form 的自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** labelWidth 覆盖 Form.labelWidth。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 时是否保留标签列,默认继承 Form。 */\n reserveLabelSpace?: boolean\n /** labelPosition 覆盖 Form.labelPosition。 */\n labelPosition?: FormLabelPosition\n /** size 覆盖 Form.size。 */\n size?: FormSize\n }>(),\n {\n prop: undefined,\n label: '',\n info: '',\n rules: undefined,\n required: undefined,\n error: '',\n validateStatus: '',\n showMessage: undefined,\n validateTrigger: undefined,\n labelWidth: undefined,\n reserveLabelSpace: undefined,\n labelPosition: undefined,\n size: undefined\n }\n)\n\nconst attrs = useAttrs()\nconst slots = useSlots()\nconst instance = getCurrentInstance()\nconst form = inject(formContextKey, undefined)\nconst validateState = ref<FormValidateStatus>('')\nconst validateMessage = ref('')\nconst localInitialValue = shallowRef<unknown>()\nconst localInitialValueReady = ref(false)\n\nconst currentSize = computed(() => props.size ?? form?.size.value ?? 'md')\nconst currentLabelPosition = computed(() => props.labelPosition ?? form?.labelPosition.value ?? 'right')\nconst currentLabelWidth = computed(() => {\n if (currentLabelPosition.value === 'top') return 'auto'\n const width = props.labelWidth ?? form?.labelWidth.value ?? '96px'\n return typeof width === 'number' ? `${width}px` : width\n})\nconst currentShowMessage = computed(() => props.showMessage ?? form?.showMessage.value ?? true)\nconst currentValidateTriggers = computed<FormValidateTrigger[]>(() => {\n const triggers = props.validateTrigger ?? form?.validateTrigger.value ?? ['change', 'blur']\n return Array.isArray(triggers) ? triggers : [triggers]\n})\nconst fieldRules = computed(() => form?.getFieldRules(props.prop, props.rules) ?? [])\nconst isRequired = computed(() => props.required ?? fieldRules.value.some((rule) => rule.required))\nconst showRequiredAsterisk = computed(() => isRequired.value && !(form?.hideRequiredAsterisk.value ?? false))\nconst hasOwnReserveLabelSpace = computed(() => {\n const vnodeProps = instance?.vnode.props\n return !!vnodeProps && ('reserveLabelSpace' in vnodeProps || 'reserve-label-space' in vnodeProps)\n})\nconst currentReserveLabelSpace = computed(() => (hasOwnReserveLabelSpace.value ? props.reserveLabelSpace : (form?.reserveLabelSpace.value ?? true)))\nconst shouldReserveLabelSpace = computed(() => !props.label && currentReserveLabelSpace.value && (currentLabelPosition.value !== 'top' || (form?.inline.value ?? false)))\nconst shownValidateState = computed(() => props.validateStatus || (props.error ? 'error' : validateState.value))\nconst shownValidateMessage = computed(() => props.error || validateMessage.value)\nconst labelId = computed(() => (props.label ? `ui-form-item-${normalizeFormProp(props.prop) ?? Math.random().toString(36).slice(2)}-label` : undefined))\nconst contentId = computed(() => (props.prop ? `ui-form-item-${normalizeFormProp(props.prop)}-content` : undefined))\nconst itemClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n formItem({\n inline: form?.inline.value ?? false,\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n error: shownValidateState.value === 'error'\n })\n )\n)\nconst itemStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof form?.itemGap.value === 'number' ? `${form.itemGap.value}px` : form?.itemGap.value,\n '--ui-form-label-width': currentLabelWidth.value\n}))\nconst labelClass = computed(() =>\n formItemLabel({\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n required: showRequiredAsterisk.value,\n requiredPosition: form?.requireAsteriskPosition.value ?? 'left'\n })\n)\nconst infoClass = computed(() => clsx('ml-1 inline-flex shrink-0 items-center', currentLabelPosition.value === 'top' && 'h-[1lh] self-start'))\nconst emptyLabelClass = computed(() => currentLabelPosition.value === 'top' && 'h-[1lh] shrink-0')\nconst contentClass = computed(() => clsx(formItemContent({ labelPosition: currentLabelPosition.value, size: currentSize.value }), !props.label && currentLabelPosition.value !== 'top' && (shouldReserveLabelSpace.value ? 'col-start-2' : 'col-span-full')))\nconst messageClass = computed(() => formItemMessage({ status: shownValidateState.value }))\n\nfunction isObjectValue(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\nfunction cloneInitialFieldValue(value: unknown): unknown {\n const rawValue = toRaw(value)\n if (Array.isArray(rawValue)) return rawValue.map((item) => cloneInitialFieldValue(item))\n if (!isObjectValue(rawValue)) return rawValue\n if (rawValue instanceof Date) return new Date(rawValue)\n if (rawValue instanceof RegExp) {\n const clonedValue = new RegExp(rawValue.source, rawValue.flags)\n clonedValue.lastIndex = rawValue.lastIndex\n return clonedValue\n }\n if (rawValue instanceof ArrayBuffer || ArrayBuffer.isView(rawValue)) return structuredClone(rawValue)\n if (rawValue instanceof Map) return new Map(Array.from(rawValue.entries(), ([key, item]) => [cloneInitialFieldValue(key), cloneInitialFieldValue(item)]))\n if (rawValue instanceof Set) return new Set(Array.from(rawValue.values(), (item) => cloneInitialFieldValue(item)))\n\n const prototype = Object.getPrototypeOf(rawValue)\n if (prototype !== Object.prototype && prototype !== null) {\n try {\n return structuredClone(rawValue)\n } catch {\n return rawValue\n }\n }\n\n const cloneableValue: Record<PropertyKey, unknown> = {}\n Reflect.ownKeys(rawValue).forEach((key) => {\n cloneableValue[key] = cloneInitialFieldValue((rawValue as Record<PropertyKey, unknown>)[key])\n })\n return cloneableValue\n}\n\nfunction shouldValidateByTrigger(ruleTrigger: FormValidateTrigger | FormValidateTrigger[] | undefined, trigger?: FormValidateTrigger) {\n if (!trigger) return true\n if (!ruleTrigger) return true\n return Array.isArray(ruleTrigger) ? ruleTrigger.includes(trigger) : ruleTrigger === trigger\n}\n\nasync function validate(trigger?: FormValidateTrigger, options: ValidateOption = {}) {\n const rules = fieldRules.value.filter((rule) => shouldValidateByTrigger(rule.trigger, trigger))\n if (!props.prop || fieldRules.value.length === 0) {\n validateState.value = ''\n validateMessage.value = ''\n return { valid: true }\n }\n if (rules.length === 0) return { valid: true }\n\n validateState.value = 'validating'\n const result = await validateFormValue(props.prop, form?.getFieldValue(props.prop), rules, options)\n validateState.value = result.valid ? 'success' : 'error'\n validateMessage.value = result.errors?.[0]?.message ?? ''\n form?.emitValidate(props.prop, result.valid, validateMessage.value)\n return result\n}\n\nconst scheduledValidateTriggers = new Set<FormValidateTrigger>()\n\nfunction scheduleValidate(trigger: FormValidateTrigger) {\n if (!currentValidateTriggers.value.includes(trigger) || scheduledValidateTriggers.has(trigger)) return\n scheduledValidateTriggers.add(trigger)\n void nextTick(() => {\n scheduledValidateTriggers.delete(trigger)\n void validate(trigger)\n })\n}\n\nfunction cloneControlVNode(vnode: VNode) {\n if (typeof vnode.type === 'symbol') return vnode\n const listeners =\n typeof vnode.type === 'string'\n ? {\n onInput: () => scheduleValidate('change'),\n onChange: () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n : {\n 'onUpdate:modelValue': () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n return cloneVNode(vnode, listeners, true)\n}\n\nconst FormItemControl = defineComponent({\n name: 'UnoUIFormItemControl',\n setup() {\n return () =>\n slots\n .default?.({\n validate,\n validateState: shownValidateState.value,\n validateMessage: shownValidateMessage.value\n })\n ?.map(cloneControlVNode)\n }\n})\n\nfunction resetField() {\n if (props.prop && form && localInitialValueReady.value) form.setFieldValue(props.prop, cloneInitialFieldValue(localInitialValue.value))\n clearValidate()\n}\n\nfunction clearValidate() {\n validateState.value = ''\n validateMessage.value = ''\n}\n\nconst fieldContext: FormItemContext = {\n prop: props.prop,\n validateState,\n validateMessage,\n validate,\n resetField,\n clearValidate,\n isRequired\n}\n\nwatch(\n () => props.error,\n (error) => {\n if (error) {\n validateState.value = 'error'\n validateMessage.value = error\n }\n },\n { immediate: true }\n)\n\nonMounted(() => {\n if (props.prop && form) {\n const value = form.getFieldValue(props.prop)\n localInitialValue.value = cloneInitialFieldValue(value)\n localInitialValueReady.value = true\n form.registerField(fieldContext)\n }\n})\n\nonBeforeUnmount(() => {\n form?.unregisterField(fieldContext)\n})\n\ndefineExpose({\n validate,\n resetField,\n clearValidate,\n validateState,\n validateMessage\n})\n</script>\n\n<template>\n <div v-bind=\"getUiExposeAttrs(attrs)\" :class=\"itemClass\" :style=\"itemStyle\" :data-status=\"shownValidateState || undefined\">\n <slot name=\"label\" :label=\"label\">\n <label v-if=\"label\" :id=\"labelId\" :for=\"contentId\" :class=\"labelClass\">\n <span class=\"min-w-0 whitespace-normal break-words text-inherit\">{{ label }}</span>\n <span v-if=\"info || $slots.info\" :class=\"infoClass\" data-ui-form-item-info-wrapper=\"true\">\n <Tooltip :title=\"info\" :trigger=\"['hover', 'focus']\" :mouse-enter-delay=\"0\">\n <span\n class=\"i-lucide:info size-3.5 cursor-help rounded-sm text-tertiary outline-none transition-colors hover:text-secondary focus-visible:text-secondary focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1\"\n data-ui-form-item-info=\"true\"\n role=\"img\"\n tabindex=\"0\"\n :aria-label=\"info || `${label}说明`\"\n ></span>\n <template #title>\n <slot name=\"info\">{{ info }}</slot>\n </template>\n </Tooltip>\n </span>\n </label>\n <div v-else-if=\"shouldReserveLabelSpace\" :class=\"emptyLabelClass\" aria-hidden=\"true\"></div>\n </slot>\n\n <div :id=\"contentId\" :class=\"contentClass\" :aria-labelledby=\"labelId\">\n <FormItemControl />\n <slot v-if=\"currentShowMessage && shownValidateMessage\" name=\"error\" :error=\"shownValidateMessage\" :validate-state=\"shownValidateState\">\n <div :class=\"messageClass\">{{ shownValidateMessage }}</div>\n </slot>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateOption } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { cloneVNode, computed, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, toRaw, useAttrs, useSlots, watch } from 'vue'\nimport type { CSSProperties, VNode } from 'vue'\n\nimport { formContextKey, formItem, formItemContent, formItemLabel, formItemMessage, normalizeFormProp, validateFormValue, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormSize, type FormValidateStatus, type FormValidateTrigger } from '.'\nimport { getUiExposeAttrs } from '../attrs'\nimport { Tooltip } from '../tooltip'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** prop 是 model 字段路径,支持 a.b 或路径数组。 */\n prop?: FormProp\n /** label 是字段标签文本,可选。 */\n label?: string\n /** info 是显示在 label 旁的信息提示内容。 */\n info?: string\n /** rules 是字段局部规则,会与 Form.rules[prop] 合并。 */\n rules?: FormItemRule\n /** required 可单独控制必填星号;未设置时从规则推导。 */\n required?: boolean\n /** error 是外部传入的错误消息,会覆盖内部校验结果。 */\n error?: string\n /** validateStatus 是外部传入的校验状态。 */\n validateStatus?: FormValidateStatus\n /** showMessage 是否显示本字段错误消息,默认继承 Form。 */\n showMessage?: boolean\n /** validateTrigger 覆盖 Form 的自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** labelWidth 覆盖 Form.labelWidth。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 时是否保留标签列,默认继承 Form。 */\n reserveLabelSpace?: boolean\n /** labelPosition 覆盖 Form.labelPosition。 */\n labelPosition?: FormLabelPosition\n /** size 覆盖 Form.size。 */\n size?: FormSize\n }>(),\n {\n prop: undefined,\n label: '',\n info: '',\n rules: undefined,\n required: undefined,\n error: '',\n validateStatus: '',\n showMessage: undefined,\n validateTrigger: undefined,\n labelWidth: undefined,\n reserveLabelSpace: undefined,\n labelPosition: undefined,\n size: undefined\n }\n)\n\nconst attrs = useAttrs()\nconst slots = useSlots()\nconst instance = getCurrentInstance()\nconst form = inject(formContextKey, undefined)\nconst validateState = ref<FormValidateStatus>('')\nconst validateMessage = ref('')\nconst localInitialValue = shallowRef<unknown>()\nconst localInitialValueReady = ref(false)\n\nconst currentSize = computed(() => props.size ?? form?.size.value ?? 'md')\nconst currentLabelPosition = computed(() => props.labelPosition ?? form?.labelPosition.value ?? 'right')\nconst currentLabelWidth = computed(() => {\n if (currentLabelPosition.value === 'top') return 'auto'\n const width = props.labelWidth ?? form?.labelWidth.value ?? '96px'\n return typeof width === 'number' ? `${width}px` : width\n})\nconst currentShowMessage = computed(() => props.showMessage ?? form?.showMessage.value ?? true)\nconst currentValidateTriggers = computed<FormValidateTrigger[]>(() => {\n const triggers = props.validateTrigger ?? form?.validateTrigger.value ?? ['change', 'blur']\n return Array.isArray(triggers) ? triggers : [triggers]\n})\nconst fieldRules = computed(() => form?.getFieldRules(props.prop, props.rules) ?? [])\nconst isRequired = computed(() => props.required ?? fieldRules.value.some((rule) => rule.required))\nconst showRequiredAsterisk = computed(() => isRequired.value && !(form?.hideRequiredAsterisk.value ?? false))\nconst hasOwnReserveLabelSpace = computed(() => {\n const vnodeProps = instance?.vnode.props\n return !!vnodeProps && ('reserveLabelSpace' in vnodeProps || 'reserve-label-space' in vnodeProps)\n})\nconst currentReserveLabelSpace = computed(() => (hasOwnReserveLabelSpace.value ? props.reserveLabelSpace : (form?.reserveLabelSpace.value ?? true)))\nconst shouldReserveLabelSpace = computed(() => !props.label && currentReserveLabelSpace.value && (currentLabelPosition.value !== 'top' || (form?.inline.value ?? false)))\nconst shownValidateState = computed(() => props.validateStatus || (props.error ? 'error' : validateState.value))\nconst shownValidateMessage = computed(() => props.error || validateMessage.value)\nconst labelId = computed(() => (props.label ? `ui-form-item-${normalizeFormProp(props.prop) ?? Math.random().toString(36).slice(2)}-label` : undefined))\nconst contentId = computed(() => (props.prop ? `ui-form-item-${normalizeFormProp(props.prop)}-content` : undefined))\nconst itemClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n formItem({\n inline: form?.inline.value ?? false,\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n error: shownValidateState.value === 'error'\n })\n )\n)\nconst itemStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof form?.itemGap.value === 'number' ? `${form.itemGap.value}px` : form?.itemGap.value,\n '--ui-form-label-width': currentLabelWidth.value\n}))\nconst labelClass = computed(() =>\n formItemLabel({\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n required: showRequiredAsterisk.value,\n requiredPosition: form?.requireAsteriskPosition.value ?? 'left'\n })\n)\nconst infoClass = computed(() => clsx('ml-1 inline-flex shrink-0 items-center', currentLabelPosition.value === 'top' && 'h-[1lh] self-start'))\nconst emptyLabelClass = computed(() => currentLabelPosition.value === 'top' && 'h-[1lh] shrink-0')\nconst contentClass = computed(() => clsx(formItemContent({ labelPosition: currentLabelPosition.value, size: currentSize.value }), !props.label && currentLabelPosition.value !== 'top' && (shouldReserveLabelSpace.value ? 'col-start-2' : 'col-span-full')))\nconst messageClass = computed(() => formItemMessage({ status: shownValidateState.value }))\n\nfunction isObjectValue(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\nfunction cloneInitialFieldValue(value: unknown): unknown {\n const rawValue = toRaw(value)\n if (Array.isArray(rawValue)) return rawValue.map((item) => cloneInitialFieldValue(item))\n if (!isObjectValue(rawValue)) return rawValue\n if (rawValue instanceof Date) return new Date(rawValue)\n if (rawValue instanceof RegExp) {\n const clonedValue = new RegExp(rawValue.source, rawValue.flags)\n clonedValue.lastIndex = rawValue.lastIndex\n return clonedValue\n }\n if (rawValue instanceof ArrayBuffer || ArrayBuffer.isView(rawValue)) return structuredClone(rawValue)\n if (rawValue instanceof Map) return new Map(Array.from(rawValue.entries(), ([key, item]) => [cloneInitialFieldValue(key), cloneInitialFieldValue(item)]))\n if (rawValue instanceof Set) return new Set(Array.from(rawValue.values(), (item) => cloneInitialFieldValue(item)))\n\n const prototype = Object.getPrototypeOf(rawValue)\n if (prototype !== Object.prototype && prototype !== null) {\n try {\n return structuredClone(rawValue)\n } catch {\n return rawValue\n }\n }\n\n const cloneableValue: Record<PropertyKey, unknown> = {}\n Reflect.ownKeys(rawValue).forEach((key) => {\n cloneableValue[key] = cloneInitialFieldValue((rawValue as Record<PropertyKey, unknown>)[key])\n })\n return cloneableValue\n}\n\nfunction shouldValidateByTrigger(ruleTrigger: FormValidateTrigger | FormValidateTrigger[] | undefined, trigger?: FormValidateTrigger) {\n if (!trigger) return true\n if (!ruleTrigger) return true\n return Array.isArray(ruleTrigger) ? ruleTrigger.includes(trigger) : ruleTrigger === trigger\n}\n\nasync function validate(trigger?: FormValidateTrigger, options: ValidateOption = {}) {\n const rules = fieldRules.value.filter((rule) => shouldValidateByTrigger(rule.trigger, trigger))\n if (!props.prop || fieldRules.value.length === 0) {\n validateState.value = ''\n validateMessage.value = ''\n return { valid: true }\n }\n if (rules.length === 0) return { valid: true }\n\n validateState.value = 'validating'\n const result = await validateFormValue(props.prop, form?.getFieldValue(props.prop), rules, options)\n validateState.value = result.valid ? 'success' : 'error'\n validateMessage.value = result.errors?.[0]?.message ?? ''\n form?.emitValidate(props.prop, result.valid, validateMessage.value)\n return result\n}\n\nconst scheduledValidateTriggers = new Set<FormValidateTrigger>()\n\nfunction scheduleValidate(trigger: FormValidateTrigger) {\n if (!currentValidateTriggers.value.includes(trigger) || scheduledValidateTriggers.has(trigger)) return\n scheduledValidateTriggers.add(trigger)\n void nextTick(() => {\n scheduledValidateTriggers.delete(trigger)\n void validate(trigger)\n })\n}\n\nfunction cloneControlVNode(vnode: VNode) {\n if (typeof vnode.type === 'symbol') return vnode\n const listeners =\n typeof vnode.type === 'string'\n ? {\n onInput: () => scheduleValidate('change'),\n onChange: () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n : {\n 'onUpdate:modelValue': () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n return cloneVNode(vnode, listeners, true)\n}\n\nconst FormItemControl = defineComponent({\n name: 'UnoUIFormItemControl',\n setup() {\n return () =>\n slots\n .default?.({\n validate,\n validateState: shownValidateState.value,\n validateMessage: shownValidateMessage.value\n })\n ?.map(cloneControlVNode)\n }\n})\n\nfunction resetField() {\n if (props.prop && form && localInitialValueReady.value) form.setFieldValue(props.prop, cloneInitialFieldValue(localInitialValue.value))\n clearValidate()\n}\n\nfunction clearValidate() {\n validateState.value = ''\n validateMessage.value = ''\n}\n\nconst fieldContext: FormItemContext = {\n prop: props.prop,\n validateState,\n validateMessage,\n validate,\n resetField,\n clearValidate,\n isRequired\n}\n\nwatch(\n () => props.error,\n (error) => {\n if (error) {\n validateState.value = 'error'\n validateMessage.value = error\n }\n },\n { immediate: true }\n)\n\nonMounted(() => {\n if (props.prop && form) {\n const value = form.getFieldValue(props.prop)\n localInitialValue.value = cloneInitialFieldValue(value)\n localInitialValueReady.value = true\n form.registerField(fieldContext)\n }\n})\n\nonBeforeUnmount(() => {\n form?.unregisterField(fieldContext)\n})\n\ndefineExpose({\n validate,\n resetField,\n clearValidate,\n validateState,\n validateMessage\n})\n</script>\n\n<template>\n <div v-bind=\"getUiExposeAttrs(attrs)\" :class=\"itemClass\" :style=\"itemStyle\" :data-status=\"shownValidateState || undefined\">\n <slot name=\"label\" :label=\"label\">\n <label v-if=\"label\" :id=\"labelId\" :for=\"contentId\" :class=\"labelClass\">\n <span class=\"min-w-0 whitespace-normal break-words text-inherit\">{{ label }}</span>\n <span v-if=\"info || $slots.info\" :class=\"infoClass\" data-ui-form-item-info-wrapper=\"true\">\n <Tooltip :title=\"info\" :trigger=\"['hover', 'focus']\" :mouse-enter-delay=\"0\">\n <span\n class=\"i-lucide:info size-3.5 cursor-help rounded-sm text-tertiary outline-none transition-colors hover:text-secondary focus-visible:text-secondary focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1\"\n data-ui-form-item-info=\"true\"\n role=\"img\"\n tabindex=\"0\"\n :aria-label=\"info || `${label}说明`\"\n ></span>\n <template #title>\n <slot name=\"info\">{{ info }}</slot>\n </template>\n </Tooltip>\n </span>\n </label>\n <div v-else-if=\"shouldReserveLabelSpace\" :class=\"emptyLabelClass\" aria-hidden=\"true\"></div>\n </slot>\n\n <div :id=\"contentId\" :class=\"contentClass\" :aria-labelledby=\"labelId\">\n <FormItemControl />\n <slot v-if=\"currentShowMessage && shownValidateMessage\" name=\"error\" :error=\"shownValidateMessage\" :validate-state=\"shownValidateState\">\n <div :class=\"messageClass\">{{ shownValidateMessage }}</div>\n </slot>\n </div>\n </div>\n</template>\n","import Schema from \"async-validator\";\nimport type { RuleItem, ValidateError, ValidateFieldsError, ValidateMessages, ValidateOption, Values } from \"async-validator\";\nimport { cva } from \"class-variance-authority\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport type { InjectionKey, Ref } from \"vue\";\n\nexport { default as Form } from \"./Form.vue\";\nexport { default as FormItem } from \"./FormItem.vue\";\n\nexport type FormLabelPosition = \"left\" | \"right\" | \"top\";\nexport type FormSize = \"sm\" | \"md\" | \"lg\";\nexport type FormValidateStatus = \"\" | \"validating\" | \"success\" | \"error\";\nexport type FormValidateTrigger = \"blur\" | \"change\" | (string & {});\nexport type FormProp = string | string[];\nexport type FormRulePreset = keyof typeof formValidatorPatterns;\n\nexport interface FormRule extends RuleItem {\n trigger?: FormValidateTrigger | FormValidateTrigger[];\n preset?: FormRulePreset;\n}\n\nexport type FormItemRule = FormRule | FormRule[];\nexport type FormRules<T extends Values = Values> = Partial<Record<keyof T | string, FormItemRule>>;\nexport type FormValidateCallback = (valid: boolean, invalidFields?: ValidateFieldsError) => void | Promise<void>;\n\nexport interface FormItemValidateResult {\n valid: boolean;\n errors?: ValidateError[];\n}\n\nexport interface FormItemContext {\n prop?: FormProp;\n validateState: Ref<FormValidateStatus>;\n validateMessage: Ref<string>;\n validate: (trigger?: FormValidateTrigger, options?: ValidateOption) => Promise<FormItemValidateResult>;\n resetField: () => void;\n clearValidate: () => void;\n isRequired: Ref<boolean>;\n}\n\nexport interface FormContext {\n model?: Values;\n rules?: FormRules;\n size: Ref<FormSize>;\n disabled: Ref<boolean>;\n inline: Ref<boolean>;\n labelPosition: Ref<FormLabelPosition>;\n labelWidth: Ref<string | number>;\n reserveLabelSpace: Ref<boolean>;\n itemGap: Ref<string | number>;\n showMessage: Ref<boolean>;\n validateTrigger: Ref<FormValidateTrigger | FormValidateTrigger[]>;\n requireAsteriskPosition: Ref<\"left\" | \"right\">;\n hideRequiredAsterisk: Ref<boolean>;\n validateOnRuleChange: Ref<boolean>;\n registerField: (field: FormItemContext) => void;\n unregisterField: (field: FormItemContext) => void;\n getFieldRules: (prop?: FormProp, localRules?: FormItemRule) => FormRule[];\n getFieldValue: (prop?: FormProp) => unknown;\n setFieldValue: (prop: FormProp | undefined, value: unknown) => void;\n validateField: (props?: FormProp | FormProp[], callback?: FormValidateCallback) => Promise<boolean>;\n clearValidate: (props?: FormProp | FormProp[]) => void;\n resetFields: (props?: FormProp | FormProp[]) => void;\n emitValidate: (prop: FormProp | undefined, valid: boolean, message: string) => void;\n}\n\nexport interface FormValidationPreset {\n pattern: RegExp;\n message: string;\n}\n\nexport const formContextKey: InjectionKey<FormContext> = Symbol(\"ui-form-context\");\n\n/** formValidatorPatterns 提供管理端表单常用正则,业务规则可通过 preset 直接复用。 */\nexport const formValidatorPatterns = {\n email: { pattern: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/, message: \"请输入正确的邮箱地址\" },\n phoneCN: { pattern: /^1[3-9]\\d{9}$/, message: \"请输入正确的手机号\" },\n url: { pattern: /^(https?:\\/\\/)?([\\w-]+\\.)+[\\w-]+(\\/[\\w./?%&=+#:-]*)?$/i, message: \"请输入正确的 URL\" },\n ipv4: { pattern: /^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$/, message: \"请输入正确的 IPv4 地址\" },\n idCardCN: { pattern: /(^\\d{15}$)|(^\\d{17}[\\dXx]$)/, message: \"请输入正确的身份证号码\" },\n postalCodeCN: { pattern: /^\\d{6}$/, message: \"请输入正确的邮政编码\" },\n integer: { pattern: /^-?\\d+$/, message: \"请输入整数\" },\n positiveInteger: { pattern: /^[1-9]\\d*$/, message: \"请输入正整数\" },\n number: { pattern: /^-?(\\d+|\\d+\\.\\d+|\\.\\d+)$/, message: \"请输入数字\" },\n decimal2: { pattern: /^-?\\d+(\\.\\d{1,2})?$/, message: \"最多保留两位小数\" },\n alpha: { pattern: /^[A-Za-z]+$/, message: \"只能输入英文字母\" },\n alphaNum: { pattern: /^[A-Za-z0-9]+$/, message: \"只能输入英文字母和数字\" },\n projectId: { pattern: /^[A-Za-z0-9_-]+$/, message: \"只能输入字母、数字、下划线和短横线\" },\n slug: { pattern: /^[a-z0-9]+(?:-[a-z0-9]+)*$/, message: \"请输入小写字母、数字和短横线组成的标识\" },\n hexColor: { pattern: /^#(?:[0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/, message: \"请输入正确的十六进制颜色\" },\n chinese: { pattern: /^[\\u4e00-\\u9fa5]+$/, message: \"只能输入中文\" },\n password: { pattern: /^(?=.*[A-Za-z])(?=.*\\d).{8,32}$/, message: \"密码需包含字母和数字,长度 8-32 位\" },\n} satisfies Record<string, FormValidationPreset>;\n\n/** createFormRule 让调用方用内置 preset 快速构造 async-validator 规则。 */\nexport function createFormRule(preset: FormRulePreset, rule: Omit<FormRule, \"preset\" | \"pattern\"> = {}): FormRule {\n const validator = formValidatorPatterns[preset];\n return {\n pattern: validator.pattern,\n message: validator.message,\n ...rule,\n };\n}\n\nexport function normalizeFormProp(prop?: FormProp) {\n if (Array.isArray(prop)) return prop.join(\".\");\n return prop;\n}\n\nexport function getValueByPath(source: Values | undefined, prop?: FormProp) {\n if (!source || !prop) return undefined;\n const paths = Array.isArray(prop) ? prop : String(prop).split(\".\");\n return paths.reduce<unknown>((value, path) => (value !== null && typeof value === \"object\" ? (value as Values)[path] : undefined), source);\n}\n\nexport function setValueByPath(source: Values | undefined, prop: FormProp | undefined, value: unknown) {\n if (!source || !prop) return;\n const paths = Array.isArray(prop) ? prop : String(prop).split(\".\");\n const lastPath = paths.at(-1);\n if (!lastPath) return;\n\n let target: Values = source;\n for (const path of paths.slice(0, -1)) {\n const nextValue = target[path];\n if (nextValue === null || typeof nextValue !== \"object\") target[path] = {};\n target = target[path] as Values;\n }\n target[lastPath] = value;\n}\n\nexport function normalizeRules(rules?: FormItemRule): FormRule[] {\n if (!rules) return [];\n return (Array.isArray(rules) ? rules : [rules]).map((rule) => {\n if (!rule.preset) return { ...rule };\n const preset = formValidatorPatterns[rule.preset];\n return {\n pattern: preset.pattern,\n message: preset.message,\n ...rule,\n preset: undefined,\n };\n });\n}\n\nexport async function validateFormValue(prop: FormProp | undefined, value: unknown, rules: FormRule[], options: ValidateOption = {}) {\n const field = normalizeFormProp(prop);\n if (!field || rules.length === 0) return { valid: true } satisfies FormItemValidateResult;\n\n const descriptor = { [field]: rules.map(({ trigger: _trigger, preset: _preset, ...rule }) => rule) };\n const validator = new Schema(descriptor);\n try {\n await validator.validate({ [field]: value }, options);\n return { valid: true } satisfies FormItemValidateResult;\n } catch (error) {\n const validationError = error as { errors?: ValidateError[]; fields?: ValidateFieldsError };\n const errors = validationError.errors ?? validationError.fields?.[field] ?? [];\n return { valid: false, errors } satisfies FormItemValidateResult;\n }\n}\n\nexport const defaultFormValidateMessages: ValidateMessages = {\n default: \"字段验证错误\",\n required: \"%s 为必填项\",\n types: {\n email: \"%s 不是有效的邮箱地址\",\n url: \"%s 不是有效的 URL\",\n number: \"%s 不是有效的数字\",\n },\n string: {\n min: \"%s 至少 %s 个字符\",\n max: \"%s 最多 %s 个字符\",\n range: \"%s 长度需在 %s 到 %s 个字符之间\",\n },\n number: {\n min: \"%s 不能小于 %s\",\n max: \"%s 不能大于 %s\",\n range: \"%s 需在 %s 到 %s 之间\",\n },\n};\n\n/** formRoot 定义 Form 根布局,支持标准、inline 两种模式。 */\nexport const formRoot = cva(\"ui-form text-primary\", {\n variants: {\n inline: {\n true: \"flex flex-wrap items-start gap-x-4\",\n false: \"\",\n },\n size: {\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-base\",\n },\n disabled: {\n true: \"opacity-70\",\n false: \"\",\n },\n },\n defaultVariants: {\n inline: false,\n size: \"md\",\n disabled: false,\n },\n});\n\n/** formItem 定义 FormItem 的整体排版和字段间距,确保嵌套网格内也有稳定行距。 */\nexport const formItem = cva(\"ui-form-item mb-[var(--ui-form-item-gap,16px)] min-w-0 self-start content-start last:mb-0\", {\n variants: {\n inline: {\n true: \"inline-flex w-auto items-start\",\n false: \"grid w-full\",\n },\n labelPosition: {\n left: \"grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3\",\n right: \"grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3\",\n top: \"gap-1\",\n },\n size: {\n sm: \"\",\n md: \"\",\n lg: \"\",\n },\n error: {\n true: \"\",\n false: \"\",\n },\n },\n compoundVariants: [\n { inline: true, labelPosition: \"top\", class: \"flex-col\" },\n ],\n defaultVariants: {\n inline: false,\n labelPosition: \"right\",\n size: \"md\",\n error: false,\n },\n});\n\n/** formItemLabel 定义 FormItem 标签对齐、尺寸和必填标识样式。 */\nexport const formItemLabel = cva(\"flex min-w-0 whitespace-normal break-words text-primary\", {\n variants: {\n labelPosition: {\n left: \"justify-start\",\n right: \"justify-end\",\n top: \"justify-start\",\n },\n size: {\n sm: \"text-xs/5\",\n md: \"text-sm/5\",\n lg: \"text-base/6\",\n },\n required: {\n true: \"\",\n false: \"\",\n },\n requiredPosition: {\n left: \"\",\n right: \"\",\n },\n },\n compoundVariants: [\n { required: true, requiredPosition: \"left\", class: \"before:mr-1 before:text-red-500 before:content-['*']\" },\n { required: true, requiredPosition: \"right\", class: \"after:ml-1 after:text-red-500 after:content-['*']\" },\n { labelPosition: [\"left\", \"right\"], size: \"sm\", class: \"min-h-[calc(1.75rem+7px)] items-center\" },\n { labelPosition: [\"left\", \"right\"], size: \"md\", class: \"min-h-[calc(2rem+3px)] items-center\" },\n { labelPosition: [\"left\", \"right\"], size: \"lg\", class: \"min-h-[calc(2.25rem)] items-center\" },\n ],\n defaultVariants: {\n labelPosition: \"right\",\n size: \"md\",\n required: false,\n requiredPosition: \"right\",\n },\n});\n\n/** formItemContent 定义控件区与错误提示布局。 */\nexport const formItemContent = cva(\"flex min-w-0 flex-col justify-center\", {\n variants: {\n labelPosition: {\n left: \"\",\n right: \"\",\n top: \"\",\n },\n size: {\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-base\",\n },\n },\n compoundVariants: [\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"sm\", class: \"min-h-[calc(1.75rem+7px)]\" },\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"md\", class: \"min-h-[calc(2rem+3px)]\" },\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"lg\", class: \"min-h-[calc(2.25rem)]\" },\n ],\n defaultVariants: {\n labelPosition: \"right\",\n size: \"md\",\n },\n});\n\n/** formItemMessage 定义 FormItem 校验提示视觉。 */\nexport const formItemMessage = cva(\"mt-1.5 min-h-4 text-xs/4\", {\n variants: {\n status: {\n \"\": \"text-tertiary\",\n validating: \"text-brand-500\",\n success: \"text-green-600 dark:text-green-400\",\n error: \"text-red-600 dark:text-red-400\",\n },\n },\n defaultVariants: {\n status: \"\",\n },\n});\n\nexport type FormProps = VariantProps<typeof formRoot>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaA,IAAM,IAAQ,GAiDR,IAAO,GAMP,IAAQ,EAAS,GACjB,IAAS,EAA8B,CAAC,CAAC,GAEzC,IAAY,QAAe,EAAK,EAAM,OAA6B,EAAS;GAAE,QAAQ,EAAM;GAAQ,MAAM,EAAM;GAAM,UAAU,EAAM;EAAS,CAAC,CAAC,CAAC,GAClJ,IAAY,SAA+B;GAC/C,GAAI,EAAM;GACV,sBAAsB,OAAO,EAAM,WAAY,WAAW,GAAG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;CACF;CACA,kBAAkB;EAChB;GAAE,eAAe;IAAC;IAAQ;IAAS;GAAK;GAAG,MAAM;GAAM,OAAO;EAA4B;EAC1F;GAAE,eAAe;IAAC;IAAQ;IAAS;GAAK;GAAG,MAAM;GAAM,OAAO;EAAyB;EACvF;GAAE,eAAe;IAAC;IAAQ;IAAS;GAAK;GAAG,MAAM;GAAM,OAAO;EAAwB;CACxF;CACA,iBAAiB;EACf,eAAe;EACf,MAAM;CACR;AACF,CAAC,GAGY,IAAkB,EAAI,4BAA4B;CAC7D,UAAU,EACR,QAAQ;EACN,IAAI;EACJ,YAAY;EACZ,SAAS;EACT,OAAO;CACT,EACF;CACA,iBAAiB,EACf,QAAQ,GACV;AACF,CAAC"}
1
+ {"version":3,"file":"form-CVJ4YMWA.js","names":["$slots"],"sources":["../../src/form/Form.vue","../../src/form/Form.vue","../../src/form/FormItem.vue","../../src/form/FormItem.vue","../../src/form/index.ts"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { ValidateFieldsError, Values } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { computed, nextTick, provide, ref, shallowRef, toRef, useAttrs, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiExposeAttrs } from '../attrs'\nimport { defaultFormValidateMessages, formContextKey, formRoot, getValueByPath, normalizeFormProp, normalizeRules, setValueByPath, type FormContext, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormRules, type FormSize, type FormValidateCallback, type FormValidateTrigger } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** model 是表单数据对象,字段校验会按 prop 从该对象取值。 */\n model?: Values\n /** rules 是表单级校验规则,语法兼容 async-validator,并扩展 preset/trigger。 */\n rules?: FormRules\n /** inline 表示行内表单布局。 */\n inline?: boolean\n /** labelPosition 是标签位置,支持 left/right/top。 */\n labelPosition?: FormLabelPosition\n /** labelWidth 是非 top 布局下的标签列宽。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 的 FormItem 是否保留标签列。 */\n reserveLabelSpace?: boolean\n /** itemGap 是字段之间的纵向间距,支持数字像素值或 CSS 长度。 */\n itemGap?: string | number\n /** size 统一控制 FormItem 标签尺寸,默认 md。 */\n size?: FormSize\n /** disabled 统一设置表单禁用语义,具体控件仍需绑定自身 disabled。 */\n disabled?: boolean\n /** showMessage 是否显示 FormItem 错误消息。 */\n showMessage?: boolean\n /** validateTrigger 设置字段默认自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** validateOnRuleChange 是否在 rules 变化时重新校验。 */\n validateOnRuleChange?: boolean\n /** requireAsteriskPosition 设置必填星号位置。 */\n requireAsteriskPosition?: 'left' | 'right'\n /** hideRequiredAsterisk 是否隐藏必填星号。 */\n hideRequiredAsterisk?: boolean\n }>(),\n {\n model: undefined,\n rules: undefined,\n inline: false,\n labelPosition: 'right',\n labelWidth: '96px',\n reserveLabelSpace: true,\n itemGap: '16px',\n size: 'md',\n disabled: false,\n showMessage: true,\n validateTrigger: () => ['change', 'blur'],\n validateOnRuleChange: true,\n requireAsteriskPosition: 'left',\n hideRequiredAsterisk: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'validate', prop: FormProp | undefined, valid: boolean, message: string): void\n (e: 'submit', event: SubmitEvent): void\n (e: 'reset', event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst fields = shallowRef<FormItemContext[]>([])\n\nconst rootClass = computed(() => clsx(attrs.class as string | undefined, formRoot({ inline: props.inline, size: props.size, disabled: props.disabled })))\nconst rootStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof props.itemGap === 'number' ? `${props.itemGap}px` : props.itemGap\n}))\n\nfunction getLabelWidthValue() {\n if (props.labelPosition === 'top') return 'auto'\n return typeof props.labelWidth === 'number' ? `${props.labelWidth}px` : props.labelWidth\n}\n\nfunction getFieldRules(prop?: FormProp, localRules?: FormItemRule) {\n const normalizedProp = normalizeFormProp(prop)\n return [...normalizeRules(normalizedProp ? props.rules?.[normalizedProp] : undefined), ...normalizeRules(localRules)]\n}\n\nfunction getFieldValue(prop?: FormProp) {\n return getValueByPath(props.model, prop)\n}\n\nfunction setFieldValue(prop: FormProp | undefined, value: unknown) {\n setValueByPath(props.model, prop, value)\n}\n\nfunction getTargetFields(propsValue?: FormProp | FormProp[]) {\n if (!propsValue) return [...fields.value]\n const propList = (Array.isArray(propsValue) && typeof propsValue[0] !== 'string' ? propsValue : [propsValue]) as FormProp[]\n const propSet = new Set(propList.map((prop) => normalizeFormProp(prop)))\n return fields.value.filter((field) => field.prop && propSet.has(normalizeFormProp(field.prop)))\n}\n\nasync function validateField(propsValue?: FormProp | FormProp[], callback?: FormValidateCallback) {\n const targetFields = getTargetFields(propsValue)\n const invalidFields: ValidateFieldsError = {}\n let valid = true\n\n for (const field of targetFields) {\n const result = await field.validate()\n const prop = normalizeFormProp(field.prop)\n if (!result.valid && prop) {\n valid = false\n invalidFields[prop] = result.errors ?? []\n }\n }\n\n await callback?.(valid, valid ? undefined : invalidFields)\n return valid\n}\n\nfunction clearValidate(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.clearValidate())\n}\n\nfunction resetFields(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.resetField())\n}\n\nfunction registerField(field: FormItemContext) {\n fields.value = [...fields.value, field]\n}\n\nfunction unregisterField(field: FormItemContext) {\n fields.value = fields.value.filter((item) => item !== field)\n}\n\nfunction emitValidate(prop: FormProp | undefined, valid: boolean, message: string) {\n emit('validate', prop, valid, message)\n}\n\nfunction handleSubmit(event: SubmitEvent) {\n emit('submit', event)\n}\n\nfunction handleReset(event: Event) {\n resetFields()\n emit('reset', event)\n}\n\nwatch(\n () => props.rules,\n () => {\n if (props.validateOnRuleChange) void nextTick(() => validateField())\n },\n { deep: true }\n)\n\nprovide<FormContext>(formContextKey, {\n get model() {\n return props.model\n },\n get rules() {\n return props.rules\n },\n size: toRef(props, 'size'),\n disabled: toRef(props, 'disabled'),\n inline: toRef(props, 'inline'),\n labelPosition: toRef(props, 'labelPosition'),\n labelWidth: computed(getLabelWidthValue),\n reserveLabelSpace: toRef(props, 'reserveLabelSpace'),\n itemGap: toRef(props, 'itemGap'),\n showMessage: toRef(props, 'showMessage'),\n validateTrigger: toRef(props, 'validateTrigger'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n validateOnRuleChange: toRef(props, 'validateOnRuleChange'),\n registerField,\n unregisterField,\n getFieldRules,\n getFieldValue,\n setFieldValue,\n validateField,\n clearValidate,\n resetFields,\n emitValidate\n})\n\ndefineExpose({\n validate: (callback?: FormValidateCallback) => validateField(undefined, callback),\n validateField,\n resetFields,\n clearValidate,\n fields,\n defaultValidateMessages: ref(defaultFormValidateMessages)\n})\n</script>\n\n<template>\n <form v-bind=\"getUiExposeAttrs(attrs)\" :class=\"rootClass\" :style=\"rootStyle\" :data-disabled=\"disabled || undefined\" @submit=\"handleSubmit\" @reset=\"handleReset\">\n <slot></slot>\n </form>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateFieldsError, Values } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { computed, nextTick, provide, ref, shallowRef, toRef, useAttrs, watch } from 'vue'\nimport type { CSSProperties } from 'vue'\n\nimport { getUiExposeAttrs } from '../attrs'\nimport { defaultFormValidateMessages, formContextKey, formRoot, getValueByPath, normalizeFormProp, normalizeRules, setValueByPath, type FormContext, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormRules, type FormSize, type FormValidateCallback, type FormValidateTrigger } from '.'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** model 是表单数据对象,字段校验会按 prop 从该对象取值。 */\n model?: Values\n /** rules 是表单级校验规则,语法兼容 async-validator,并扩展 preset/trigger。 */\n rules?: FormRules\n /** inline 表示行内表单布局。 */\n inline?: boolean\n /** labelPosition 是标签位置,支持 left/right/top。 */\n labelPosition?: FormLabelPosition\n /** labelWidth 是非 top 布局下的标签列宽。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 的 FormItem 是否保留标签列。 */\n reserveLabelSpace?: boolean\n /** itemGap 是字段之间的纵向间距,支持数字像素值或 CSS 长度。 */\n itemGap?: string | number\n /** size 统一控制 FormItem 标签尺寸,默认 md。 */\n size?: FormSize\n /** disabled 统一设置表单禁用语义,具体控件仍需绑定自身 disabled。 */\n disabled?: boolean\n /** showMessage 是否显示 FormItem 错误消息。 */\n showMessage?: boolean\n /** validateTrigger 设置字段默认自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** validateOnRuleChange 是否在 rules 变化时重新校验。 */\n validateOnRuleChange?: boolean\n /** requireAsteriskPosition 设置必填星号位置。 */\n requireAsteriskPosition?: 'left' | 'right'\n /** hideRequiredAsterisk 是否隐藏必填星号。 */\n hideRequiredAsterisk?: boolean\n }>(),\n {\n model: undefined,\n rules: undefined,\n inline: false,\n labelPosition: 'right',\n labelWidth: '96px',\n reserveLabelSpace: true,\n itemGap: '16px',\n size: 'md',\n disabled: false,\n showMessage: true,\n validateTrigger: () => ['change', 'blur'],\n validateOnRuleChange: true,\n requireAsteriskPosition: 'left',\n hideRequiredAsterisk: false\n }\n)\n\nconst emit = defineEmits<{\n (e: 'validate', prop: FormProp | undefined, valid: boolean, message: string): void\n (e: 'submit', event: SubmitEvent): void\n (e: 'reset', event: Event): void\n}>()\n\nconst attrs = useAttrs()\nconst fields = shallowRef<FormItemContext[]>([])\n\nconst rootClass = computed(() => clsx(attrs.class as string | undefined, formRoot({ inline: props.inline, size: props.size, disabled: props.disabled })))\nconst rootStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof props.itemGap === 'number' ? `${props.itemGap}px` : props.itemGap\n}))\n\nfunction getLabelWidthValue() {\n if (props.labelPosition === 'top') return 'auto'\n return typeof props.labelWidth === 'number' ? `${props.labelWidth}px` : props.labelWidth\n}\n\nfunction getFieldRules(prop?: FormProp, localRules?: FormItemRule) {\n const normalizedProp = normalizeFormProp(prop)\n return [...normalizeRules(normalizedProp ? props.rules?.[normalizedProp] : undefined), ...normalizeRules(localRules)]\n}\n\nfunction getFieldValue(prop?: FormProp) {\n return getValueByPath(props.model, prop)\n}\n\nfunction setFieldValue(prop: FormProp | undefined, value: unknown) {\n setValueByPath(props.model, prop, value)\n}\n\nfunction getTargetFields(propsValue?: FormProp | FormProp[]) {\n if (!propsValue) return [...fields.value]\n const propList = (Array.isArray(propsValue) && typeof propsValue[0] !== 'string' ? propsValue : [propsValue]) as FormProp[]\n const propSet = new Set(propList.map((prop) => normalizeFormProp(prop)))\n return fields.value.filter((field) => field.prop && propSet.has(normalizeFormProp(field.prop)))\n}\n\nasync function validateField(propsValue?: FormProp | FormProp[], callback?: FormValidateCallback) {\n const targetFields = getTargetFields(propsValue)\n const invalidFields: ValidateFieldsError = {}\n let valid = true\n\n for (const field of targetFields) {\n const result = await field.validate()\n const prop = normalizeFormProp(field.prop)\n if (!result.valid && prop) {\n valid = false\n invalidFields[prop] = result.errors ?? []\n }\n }\n\n await callback?.(valid, valid ? undefined : invalidFields)\n return valid\n}\n\nfunction clearValidate(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.clearValidate())\n}\n\nfunction resetFields(propsValue?: FormProp | FormProp[]) {\n getTargetFields(propsValue).forEach((field) => field.resetField())\n}\n\nfunction registerField(field: FormItemContext) {\n fields.value = [...fields.value, field]\n}\n\nfunction unregisterField(field: FormItemContext) {\n fields.value = fields.value.filter((item) => item !== field)\n}\n\nfunction emitValidate(prop: FormProp | undefined, valid: boolean, message: string) {\n emit('validate', prop, valid, message)\n}\n\nfunction handleSubmit(event: SubmitEvent) {\n emit('submit', event)\n}\n\nfunction handleReset(event: Event) {\n resetFields()\n emit('reset', event)\n}\n\nwatch(\n () => props.rules,\n () => {\n if (props.validateOnRuleChange) void nextTick(() => validateField())\n },\n { deep: true }\n)\n\nprovide<FormContext>(formContextKey, {\n get model() {\n return props.model\n },\n get rules() {\n return props.rules\n },\n size: toRef(props, 'size'),\n disabled: toRef(props, 'disabled'),\n inline: toRef(props, 'inline'),\n labelPosition: toRef(props, 'labelPosition'),\n labelWidth: computed(getLabelWidthValue),\n reserveLabelSpace: toRef(props, 'reserveLabelSpace'),\n itemGap: toRef(props, 'itemGap'),\n showMessage: toRef(props, 'showMessage'),\n validateTrigger: toRef(props, 'validateTrigger'),\n requireAsteriskPosition: toRef(props, 'requireAsteriskPosition'),\n hideRequiredAsterisk: toRef(props, 'hideRequiredAsterisk'),\n validateOnRuleChange: toRef(props, 'validateOnRuleChange'),\n registerField,\n unregisterField,\n getFieldRules,\n getFieldValue,\n setFieldValue,\n validateField,\n clearValidate,\n resetFields,\n emitValidate\n})\n\ndefineExpose({\n validate: (callback?: FormValidateCallback) => validateField(undefined, callback),\n validateField,\n resetFields,\n clearValidate,\n fields,\n defaultValidateMessages: ref(defaultFormValidateMessages)\n})\n</script>\n\n<template>\n <form v-bind=\"getUiExposeAttrs(attrs)\" :class=\"rootClass\" :style=\"rootStyle\" :data-disabled=\"disabled || undefined\" @submit=\"handleSubmit\" @reset=\"handleReset\">\n <slot></slot>\n </form>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateOption } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { cloneVNode, computed, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, toRaw, useAttrs, useSlots, watch } from 'vue'\nimport type { CSSProperties, VNode } from 'vue'\n\nimport { formContextKey, formItem, formItemContent, formItemLabel, formItemMessage, normalizeFormProp, validateFormValue, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormSize, type FormValidateStatus, type FormValidateTrigger } from '.'\nimport { getUiExposeAttrs } from '../attrs'\nimport { Tooltip } from '../tooltip'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** prop 是 model 字段路径,支持 a.b 或路径数组。 */\n prop?: FormProp\n /** label 是字段标签文本,可选。 */\n label?: string\n /** info 是显示在 label 旁的信息提示内容。 */\n info?: string\n /** rules 是字段局部规则,会与 Form.rules[prop] 合并。 */\n rules?: FormItemRule\n /** required 可单独控制必填星号;未设置时从规则推导。 */\n required?: boolean\n /** error 是外部传入的错误消息,会覆盖内部校验结果。 */\n error?: string\n /** validateStatus 是外部传入的校验状态。 */\n validateStatus?: FormValidateStatus\n /** showMessage 是否显示本字段错误消息,默认继承 Form。 */\n showMessage?: boolean\n /** validateTrigger 覆盖 Form 的自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** labelWidth 覆盖 Form.labelWidth。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 时是否保留标签列,默认继承 Form。 */\n reserveLabelSpace?: boolean\n /** labelPosition 覆盖 Form.labelPosition。 */\n labelPosition?: FormLabelPosition\n /** size 覆盖 Form.size。 */\n size?: FormSize\n }>(),\n {\n prop: undefined,\n label: '',\n info: '',\n rules: undefined,\n required: undefined,\n error: '',\n validateStatus: '',\n showMessage: undefined,\n validateTrigger: undefined,\n labelWidth: undefined,\n reserveLabelSpace: undefined,\n labelPosition: undefined,\n size: undefined\n }\n)\n\nconst attrs = useAttrs()\nconst slots = useSlots()\nconst instance = getCurrentInstance()\nconst form = inject(formContextKey, undefined)\nconst validateState = ref<FormValidateStatus>('')\nconst validateMessage = ref('')\nconst localInitialValue = shallowRef<unknown>()\nconst localInitialValueReady = ref(false)\n\nconst currentSize = computed(() => props.size ?? form?.size.value ?? 'md')\nconst currentLabelPosition = computed(() => props.labelPosition ?? form?.labelPosition.value ?? 'right')\nconst currentLabelWidth = computed(() => {\n if (currentLabelPosition.value === 'top') return 'auto'\n const width = props.labelWidth ?? form?.labelWidth.value ?? '96px'\n return typeof width === 'number' ? `${width}px` : width\n})\nconst currentShowMessage = computed(() => props.showMessage ?? form?.showMessage.value ?? true)\nconst currentValidateTriggers = computed<FormValidateTrigger[]>(() => {\n const triggers = props.validateTrigger ?? form?.validateTrigger.value ?? ['change', 'blur']\n return Array.isArray(triggers) ? triggers : [triggers]\n})\nconst fieldRules = computed(() => form?.getFieldRules(props.prop, props.rules) ?? [])\nconst isRequired = computed(() => props.required ?? fieldRules.value.some((rule) => rule.required))\nconst showRequiredAsterisk = computed(() => isRequired.value && !(form?.hideRequiredAsterisk.value ?? false))\nconst hasOwnReserveLabelSpace = computed(() => {\n const vnodeProps = instance?.vnode.props\n return !!vnodeProps && ('reserveLabelSpace' in vnodeProps || 'reserve-label-space' in vnodeProps)\n})\nconst currentReserveLabelSpace = computed(() => (hasOwnReserveLabelSpace.value ? props.reserveLabelSpace : (form?.reserveLabelSpace.value ?? true)))\nconst shouldReserveLabelSpace = computed(() => !props.label && currentReserveLabelSpace.value && (currentLabelPosition.value !== 'top' || (form?.inline.value ?? false)))\nconst shownValidateState = computed(() => props.validateStatus || (props.error ? 'error' : validateState.value))\nconst shownValidateMessage = computed(() => props.error || validateMessage.value)\nconst labelId = computed(() => (props.label ? `ui-form-item-${normalizeFormProp(props.prop) ?? Math.random().toString(36).slice(2)}-label` : undefined))\nconst contentId = computed(() => (props.prop ? `ui-form-item-${normalizeFormProp(props.prop)}-content` : undefined))\nconst itemClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n formItem({\n inline: form?.inline.value ?? false,\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n error: shownValidateState.value === 'error'\n })\n )\n)\nconst itemStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof form?.itemGap.value === 'number' ? `${form.itemGap.value}px` : form?.itemGap.value,\n '--ui-form-label-width': currentLabelWidth.value\n}))\nconst labelClass = computed(() =>\n formItemLabel({\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n required: showRequiredAsterisk.value,\n requiredPosition: form?.requireAsteriskPosition.value ?? 'left'\n })\n)\nconst infoClass = computed(() => clsx('ml-1 inline-flex shrink-0 items-center', currentLabelPosition.value === 'top' && 'h-[1lh] self-start'))\nconst emptyLabelClass = computed(() => currentLabelPosition.value === 'top' && 'h-[1lh] shrink-0')\nconst contentClass = computed(() => clsx(formItemContent({ labelPosition: currentLabelPosition.value, size: currentSize.value }), !props.label && currentLabelPosition.value !== 'top' && (shouldReserveLabelSpace.value ? 'col-start-2' : 'col-span-full')))\nconst messageClass = computed(() => formItemMessage({ status: shownValidateState.value }))\n\nfunction isObjectValue(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\nfunction cloneInitialFieldValue(value: unknown): unknown {\n const rawValue = toRaw(value)\n if (Array.isArray(rawValue)) return rawValue.map((item) => cloneInitialFieldValue(item))\n if (!isObjectValue(rawValue)) return rawValue\n if (rawValue instanceof Date) return new Date(rawValue)\n if (rawValue instanceof RegExp) {\n const clonedValue = new RegExp(rawValue.source, rawValue.flags)\n clonedValue.lastIndex = rawValue.lastIndex\n return clonedValue\n }\n if (rawValue instanceof ArrayBuffer || ArrayBuffer.isView(rawValue)) return structuredClone(rawValue)\n if (rawValue instanceof Map) return new Map(Array.from(rawValue.entries(), ([key, item]) => [cloneInitialFieldValue(key), cloneInitialFieldValue(item)]))\n if (rawValue instanceof Set) return new Set(Array.from(rawValue.values(), (item) => cloneInitialFieldValue(item)))\n\n const prototype = Object.getPrototypeOf(rawValue)\n if (prototype !== Object.prototype && prototype !== null) {\n try {\n return structuredClone(rawValue)\n } catch {\n return rawValue\n }\n }\n\n const cloneableValue: Record<PropertyKey, unknown> = {}\n Reflect.ownKeys(rawValue).forEach((key) => {\n cloneableValue[key] = cloneInitialFieldValue((rawValue as Record<PropertyKey, unknown>)[key])\n })\n return cloneableValue\n}\n\nfunction shouldValidateByTrigger(ruleTrigger: FormValidateTrigger | FormValidateTrigger[] | undefined, trigger?: FormValidateTrigger) {\n if (!trigger) return true\n if (!ruleTrigger) return true\n return Array.isArray(ruleTrigger) ? ruleTrigger.includes(trigger) : ruleTrigger === trigger\n}\n\nasync function validate(trigger?: FormValidateTrigger, options: ValidateOption = {}) {\n const rules = fieldRules.value.filter((rule) => shouldValidateByTrigger(rule.trigger, trigger))\n if (!props.prop || fieldRules.value.length === 0) {\n validateState.value = ''\n validateMessage.value = ''\n return { valid: true }\n }\n if (rules.length === 0) return { valid: true }\n\n validateState.value = 'validating'\n const result = await validateFormValue(props.prop, form?.getFieldValue(props.prop), rules, options)\n validateState.value = result.valid ? 'success' : 'error'\n validateMessage.value = result.errors?.[0]?.message ?? ''\n form?.emitValidate(props.prop, result.valid, validateMessage.value)\n return result\n}\n\nconst scheduledValidateTriggers = new Set<FormValidateTrigger>()\n\nfunction scheduleValidate(trigger: FormValidateTrigger) {\n if (!currentValidateTriggers.value.includes(trigger) || scheduledValidateTriggers.has(trigger)) return\n scheduledValidateTriggers.add(trigger)\n void nextTick(() => {\n scheduledValidateTriggers.delete(trigger)\n void validate(trigger)\n })\n}\n\nfunction cloneControlVNode(vnode: VNode) {\n if (typeof vnode.type === 'symbol') return vnode\n const listeners =\n typeof vnode.type === 'string'\n ? {\n onInput: () => scheduleValidate('change'),\n onChange: () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n : {\n 'onUpdate:modelValue': () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n return cloneVNode(vnode, listeners, true)\n}\n\nconst FormItemControl = defineComponent({\n name: 'UnoUIFormItemControl',\n setup() {\n return () =>\n slots\n .default?.({\n validate,\n validateState: shownValidateState.value,\n validateMessage: shownValidateMessage.value\n })\n ?.map(cloneControlVNode)\n }\n})\n\nfunction resetField() {\n if (props.prop && form && localInitialValueReady.value) form.setFieldValue(props.prop, cloneInitialFieldValue(localInitialValue.value))\n clearValidate()\n}\n\nfunction clearValidate() {\n validateState.value = ''\n validateMessage.value = ''\n}\n\nconst fieldContext: FormItemContext = {\n prop: props.prop,\n validateState,\n validateMessage,\n validate,\n resetField,\n clearValidate,\n isRequired\n}\n\nwatch(\n () => props.error,\n (error) => {\n if (error) {\n validateState.value = 'error'\n validateMessage.value = error\n }\n },\n { immediate: true }\n)\n\nonMounted(() => {\n if (props.prop && form) {\n const value = form.getFieldValue(props.prop)\n localInitialValue.value = cloneInitialFieldValue(value)\n localInitialValueReady.value = true\n form.registerField(fieldContext)\n }\n})\n\nonBeforeUnmount(() => {\n form?.unregisterField(fieldContext)\n})\n\ndefineExpose({\n validate,\n resetField,\n clearValidate,\n validateState,\n validateMessage\n})\n</script>\n\n<template>\n <div v-bind=\"getUiExposeAttrs(attrs)\" :class=\"itemClass\" :style=\"itemStyle\" :data-status=\"shownValidateState || undefined\">\n <slot name=\"label\" :label=\"label\">\n <label v-if=\"label\" :id=\"labelId\" :for=\"contentId\" :class=\"labelClass\">\n <span class=\"min-w-0 whitespace-normal break-words text-inherit\">{{ label }}</span>\n <span v-if=\"info || $slots.info\" :class=\"infoClass\" data-ui-form-item-info-wrapper=\"true\">\n <Tooltip :title=\"info\" :trigger=\"['hover', 'focus']\" :mouse-enter-delay=\"0\">\n <span\n class=\"i-lucide:info size-3.5 cursor-help rounded-sm text-tertiary outline-none transition-colors hover:text-secondary focus-visible:text-secondary focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1\"\n data-ui-form-item-info=\"true\"\n role=\"img\"\n tabindex=\"0\"\n :aria-label=\"info || `${label}说明`\"\n ></span>\n <template #title>\n <slot name=\"info\">{{ info }}</slot>\n </template>\n </Tooltip>\n </span>\n </label>\n <div v-else-if=\"shouldReserveLabelSpace\" :class=\"emptyLabelClass\" aria-hidden=\"true\"></div>\n </slot>\n\n <div :id=\"contentId\" :class=\"contentClass\" :aria-labelledby=\"labelId\">\n <FormItemControl />\n <slot v-if=\"currentShowMessage && shownValidateMessage\" name=\"error\" :error=\"shownValidateMessage\" :validate-state=\"shownValidateState\">\n <div :class=\"messageClass\">{{ shownValidateMessage }}</div>\n </slot>\n </div>\n </div>\n</template>\n","<script setup lang=\"ts\">\nimport type { ValidateOption } from 'async-validator'\nimport { clsx } from 'clsx'\nimport { cloneVNode, computed, defineComponent, getCurrentInstance, inject, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, toRaw, useAttrs, useSlots, watch } from 'vue'\nimport type { CSSProperties, VNode } from 'vue'\n\nimport { formContextKey, formItem, formItemContent, formItemLabel, formItemMessage, normalizeFormProp, validateFormValue, type FormItemContext, type FormItemRule, type FormLabelPosition, type FormProp, type FormSize, type FormValidateStatus, type FormValidateTrigger } from '.'\nimport { getUiExposeAttrs } from '../attrs'\nimport { Tooltip } from '../tooltip'\n\ndefineOptions({\n inheritAttrs: false\n})\n\nconst props = withDefaults(\n defineProps<{\n /** prop 是 model 字段路径,支持 a.b 或路径数组。 */\n prop?: FormProp\n /** label 是字段标签文本,可选。 */\n label?: string\n /** info 是显示在 label 旁的信息提示内容。 */\n info?: string\n /** rules 是字段局部规则,会与 Form.rules[prop] 合并。 */\n rules?: FormItemRule\n /** required 可单独控制必填星号;未设置时从规则推导。 */\n required?: boolean\n /** error 是外部传入的错误消息,会覆盖内部校验结果。 */\n error?: string\n /** validateStatus 是外部传入的校验状态。 */\n validateStatus?: FormValidateStatus\n /** showMessage 是否显示本字段错误消息,默认继承 Form。 */\n showMessage?: boolean\n /** validateTrigger 覆盖 Form 的自动校验时机;空数组表示仅显式校验。 */\n validateTrigger?: FormValidateTrigger | FormValidateTrigger[]\n /** labelWidth 覆盖 Form.labelWidth。 */\n labelWidth?: string | number\n /** reserveLabelSpace 控制无 label 时是否保留标签列,默认继承 Form。 */\n reserveLabelSpace?: boolean\n /** labelPosition 覆盖 Form.labelPosition。 */\n labelPosition?: FormLabelPosition\n /** size 覆盖 Form.size。 */\n size?: FormSize\n }>(),\n {\n prop: undefined,\n label: '',\n info: '',\n rules: undefined,\n required: undefined,\n error: '',\n validateStatus: '',\n showMessage: undefined,\n validateTrigger: undefined,\n labelWidth: undefined,\n reserveLabelSpace: undefined,\n labelPosition: undefined,\n size: undefined\n }\n)\n\nconst attrs = useAttrs()\nconst slots = useSlots()\nconst instance = getCurrentInstance()\nconst form = inject(formContextKey, undefined)\nconst validateState = ref<FormValidateStatus>('')\nconst validateMessage = ref('')\nconst localInitialValue = shallowRef<unknown>()\nconst localInitialValueReady = ref(false)\n\nconst currentSize = computed(() => props.size ?? form?.size.value ?? 'md')\nconst currentLabelPosition = computed(() => props.labelPosition ?? form?.labelPosition.value ?? 'right')\nconst currentLabelWidth = computed(() => {\n if (currentLabelPosition.value === 'top') return 'auto'\n const width = props.labelWidth ?? form?.labelWidth.value ?? '96px'\n return typeof width === 'number' ? `${width}px` : width\n})\nconst currentShowMessage = computed(() => props.showMessage ?? form?.showMessage.value ?? true)\nconst currentValidateTriggers = computed<FormValidateTrigger[]>(() => {\n const triggers = props.validateTrigger ?? form?.validateTrigger.value ?? ['change', 'blur']\n return Array.isArray(triggers) ? triggers : [triggers]\n})\nconst fieldRules = computed(() => form?.getFieldRules(props.prop, props.rules) ?? [])\nconst isRequired = computed(() => props.required ?? fieldRules.value.some((rule) => rule.required))\nconst showRequiredAsterisk = computed(() => isRequired.value && !(form?.hideRequiredAsterisk.value ?? false))\nconst hasOwnReserveLabelSpace = computed(() => {\n const vnodeProps = instance?.vnode.props\n return !!vnodeProps && ('reserveLabelSpace' in vnodeProps || 'reserve-label-space' in vnodeProps)\n})\nconst currentReserveLabelSpace = computed(() => (hasOwnReserveLabelSpace.value ? props.reserveLabelSpace : (form?.reserveLabelSpace.value ?? true)))\nconst shouldReserveLabelSpace = computed(() => !props.label && currentReserveLabelSpace.value && (currentLabelPosition.value !== 'top' || (form?.inline.value ?? false)))\nconst shownValidateState = computed(() => props.validateStatus || (props.error ? 'error' : validateState.value))\nconst shownValidateMessage = computed(() => props.error || validateMessage.value)\nconst labelId = computed(() => (props.label ? `ui-form-item-${normalizeFormProp(props.prop) ?? Math.random().toString(36).slice(2)}-label` : undefined))\nconst contentId = computed(() => (props.prop ? `ui-form-item-${normalizeFormProp(props.prop)}-content` : undefined))\nconst itemClass = computed(() =>\n clsx(\n attrs.class as string | undefined,\n formItem({\n inline: form?.inline.value ?? false,\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n error: shownValidateState.value === 'error'\n })\n )\n)\nconst itemStyle = computed<CSSProperties>(() => ({\n ...(attrs.style as CSSProperties | undefined),\n '--ui-form-item-gap': typeof form?.itemGap.value === 'number' ? `${form.itemGap.value}px` : form?.itemGap.value,\n '--ui-form-label-width': currentLabelWidth.value\n}))\nconst labelClass = computed(() =>\n formItemLabel({\n labelPosition: currentLabelPosition.value,\n size: currentSize.value,\n required: showRequiredAsterisk.value,\n requiredPosition: form?.requireAsteriskPosition.value ?? 'left'\n })\n)\nconst infoClass = computed(() => clsx('ml-1 inline-flex shrink-0 items-center', currentLabelPosition.value === 'top' && 'h-[1lh] self-start'))\nconst emptyLabelClass = computed(() => currentLabelPosition.value === 'top' && 'h-[1lh] shrink-0')\nconst contentClass = computed(() => clsx(formItemContent({ labelPosition: currentLabelPosition.value, size: currentSize.value }), !props.label && currentLabelPosition.value !== 'top' && (shouldReserveLabelSpace.value ? 'col-start-2' : 'col-span-full')))\nconst messageClass = computed(() => formItemMessage({ status: shownValidateState.value }))\n\nfunction isObjectValue(value: unknown): value is object {\n return value !== null && typeof value === 'object'\n}\n\nfunction cloneInitialFieldValue(value: unknown): unknown {\n const rawValue = toRaw(value)\n if (Array.isArray(rawValue)) return rawValue.map((item) => cloneInitialFieldValue(item))\n if (!isObjectValue(rawValue)) return rawValue\n if (rawValue instanceof Date) return new Date(rawValue)\n if (rawValue instanceof RegExp) {\n const clonedValue = new RegExp(rawValue.source, rawValue.flags)\n clonedValue.lastIndex = rawValue.lastIndex\n return clonedValue\n }\n if (rawValue instanceof ArrayBuffer || ArrayBuffer.isView(rawValue)) return structuredClone(rawValue)\n if (rawValue instanceof Map) return new Map(Array.from(rawValue.entries(), ([key, item]) => [cloneInitialFieldValue(key), cloneInitialFieldValue(item)]))\n if (rawValue instanceof Set) return new Set(Array.from(rawValue.values(), (item) => cloneInitialFieldValue(item)))\n\n const prototype = Object.getPrototypeOf(rawValue)\n if (prototype !== Object.prototype && prototype !== null) {\n try {\n return structuredClone(rawValue)\n } catch {\n return rawValue\n }\n }\n\n const cloneableValue: Record<PropertyKey, unknown> = {}\n Reflect.ownKeys(rawValue).forEach((key) => {\n cloneableValue[key] = cloneInitialFieldValue((rawValue as Record<PropertyKey, unknown>)[key])\n })\n return cloneableValue\n}\n\nfunction shouldValidateByTrigger(ruleTrigger: FormValidateTrigger | FormValidateTrigger[] | undefined, trigger?: FormValidateTrigger) {\n if (!trigger) return true\n if (!ruleTrigger) return true\n return Array.isArray(ruleTrigger) ? ruleTrigger.includes(trigger) : ruleTrigger === trigger\n}\n\nasync function validate(trigger?: FormValidateTrigger, options: ValidateOption = {}) {\n const rules = fieldRules.value.filter((rule) => shouldValidateByTrigger(rule.trigger, trigger))\n if (!props.prop || fieldRules.value.length === 0) {\n validateState.value = ''\n validateMessage.value = ''\n return { valid: true }\n }\n if (rules.length === 0) return { valid: true }\n\n validateState.value = 'validating'\n const result = await validateFormValue(props.prop, form?.getFieldValue(props.prop), rules, options)\n validateState.value = result.valid ? 'success' : 'error'\n validateMessage.value = result.errors?.[0]?.message ?? ''\n form?.emitValidate(props.prop, result.valid, validateMessage.value)\n return result\n}\n\nconst scheduledValidateTriggers = new Set<FormValidateTrigger>()\n\nfunction scheduleValidate(trigger: FormValidateTrigger) {\n if (!currentValidateTriggers.value.includes(trigger) || scheduledValidateTriggers.has(trigger)) return\n scheduledValidateTriggers.add(trigger)\n void nextTick(() => {\n scheduledValidateTriggers.delete(trigger)\n void validate(trigger)\n })\n}\n\nfunction cloneControlVNode(vnode: VNode) {\n if (typeof vnode.type === 'symbol') return vnode\n const listeners =\n typeof vnode.type === 'string'\n ? {\n onInput: () => scheduleValidate('change'),\n onChange: () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n : {\n 'onUpdate:modelValue': () => scheduleValidate('change'),\n onBlur: () => scheduleValidate('blur')\n }\n return cloneVNode(vnode, listeners, true)\n}\n\nconst FormItemControl = defineComponent({\n name: 'UnoUIFormItemControl',\n setup() {\n return () =>\n slots\n .default?.({\n validate,\n validateState: shownValidateState.value,\n validateMessage: shownValidateMessage.value\n })\n ?.map(cloneControlVNode)\n }\n})\n\nfunction resetField() {\n if (props.prop && form && localInitialValueReady.value) form.setFieldValue(props.prop, cloneInitialFieldValue(localInitialValue.value))\n clearValidate()\n}\n\nfunction clearValidate() {\n validateState.value = ''\n validateMessage.value = ''\n}\n\nconst fieldContext: FormItemContext = {\n prop: props.prop,\n validateState,\n validateMessage,\n validate,\n resetField,\n clearValidate,\n isRequired\n}\n\nwatch(\n () => props.error,\n (error) => {\n if (error) {\n validateState.value = 'error'\n validateMessage.value = error\n }\n },\n { immediate: true }\n)\n\nonMounted(() => {\n if (props.prop && form) {\n const value = form.getFieldValue(props.prop)\n localInitialValue.value = cloneInitialFieldValue(value)\n localInitialValueReady.value = true\n form.registerField(fieldContext)\n }\n})\n\nonBeforeUnmount(() => {\n form?.unregisterField(fieldContext)\n})\n\ndefineExpose({\n validate,\n resetField,\n clearValidate,\n validateState,\n validateMessage\n})\n</script>\n\n<template>\n <div v-bind=\"getUiExposeAttrs(attrs)\" :class=\"itemClass\" :style=\"itemStyle\" :data-status=\"shownValidateState || undefined\">\n <slot name=\"label\" :label=\"label\">\n <label v-if=\"label\" :id=\"labelId\" :for=\"contentId\" :class=\"labelClass\">\n <span class=\"min-w-0 whitespace-normal break-words text-inherit\">{{ label }}</span>\n <span v-if=\"info || $slots.info\" :class=\"infoClass\" data-ui-form-item-info-wrapper=\"true\">\n <Tooltip :title=\"info\" :trigger=\"['hover', 'focus']\" :mouse-enter-delay=\"0\">\n <span\n class=\"i-lucide:info size-3.5 cursor-help rounded-sm text-tertiary outline-none transition-colors hover:text-secondary focus-visible:text-secondary focus-visible:ring-2 focus-visible:ring-brand-500 focus-visible:ring-offset-1\"\n data-ui-form-item-info=\"true\"\n role=\"img\"\n tabindex=\"0\"\n :aria-label=\"info || `${label}说明`\"\n ></span>\n <template #title>\n <slot name=\"info\">{{ info }}</slot>\n </template>\n </Tooltip>\n </span>\n </label>\n <div v-else-if=\"shouldReserveLabelSpace\" :class=\"emptyLabelClass\" aria-hidden=\"true\"></div>\n </slot>\n\n <div :id=\"contentId\" :class=\"contentClass\" :aria-labelledby=\"labelId\">\n <FormItemControl />\n <slot v-if=\"currentShowMessage && shownValidateMessage\" name=\"error\" :error=\"shownValidateMessage\" :validate-state=\"shownValidateState\">\n <div :class=\"messageClass\">{{ shownValidateMessage }}</div>\n </slot>\n </div>\n </div>\n</template>\n","import Schema from \"async-validator\";\nimport type { RuleItem, ValidateError, ValidateFieldsError, ValidateMessages, ValidateOption, Values } from \"async-validator\";\nimport { cva } from \"class-variance-authority\";\nimport type { VariantProps } from \"class-variance-authority\";\nimport type { InjectionKey, Ref } from \"vue\";\n\nexport { default as Form } from \"./Form.vue\";\nexport { default as FormItem } from \"./FormItem.vue\";\n\nexport type FormLabelPosition = \"left\" | \"right\" | \"top\";\nexport type FormSize = \"sm\" | \"md\" | \"lg\";\nexport type FormValidateStatus = \"\" | \"validating\" | \"success\" | \"error\";\nexport type FormValidateTrigger = \"blur\" | \"change\" | (string & {});\nexport type FormProp = string | string[];\nexport type FormRulePreset = keyof typeof formValidatorPatterns;\n\nexport interface FormRule extends RuleItem {\n trigger?: FormValidateTrigger | FormValidateTrigger[];\n preset?: FormRulePreset;\n}\n\nexport type FormItemRule = FormRule | FormRule[];\nexport type FormRules<T extends Values = Values> = Partial<Record<keyof T | string, FormItemRule>>;\nexport type FormValidateCallback = (valid: boolean, invalidFields?: ValidateFieldsError) => void | Promise<void>;\n\nexport interface FormItemValidateResult {\n valid: boolean;\n errors?: ValidateError[];\n}\n\nexport interface FormItemContext {\n prop?: FormProp;\n validateState: Ref<FormValidateStatus>;\n validateMessage: Ref<string>;\n validate: (trigger?: FormValidateTrigger, options?: ValidateOption) => Promise<FormItemValidateResult>;\n resetField: () => void;\n clearValidate: () => void;\n isRequired: Ref<boolean>;\n}\n\nexport interface FormContext {\n model?: Values;\n rules?: FormRules;\n size: Ref<FormSize>;\n disabled: Ref<boolean>;\n inline: Ref<boolean>;\n labelPosition: Ref<FormLabelPosition>;\n labelWidth: Ref<string | number>;\n reserveLabelSpace: Ref<boolean>;\n itemGap: Ref<string | number>;\n showMessage: Ref<boolean>;\n validateTrigger: Ref<FormValidateTrigger | FormValidateTrigger[]>;\n requireAsteriskPosition: Ref<\"left\" | \"right\">;\n hideRequiredAsterisk: Ref<boolean>;\n validateOnRuleChange: Ref<boolean>;\n registerField: (field: FormItemContext) => void;\n unregisterField: (field: FormItemContext) => void;\n getFieldRules: (prop?: FormProp, localRules?: FormItemRule) => FormRule[];\n getFieldValue: (prop?: FormProp) => unknown;\n setFieldValue: (prop: FormProp | undefined, value: unknown) => void;\n validateField: (props?: FormProp | FormProp[], callback?: FormValidateCallback) => Promise<boolean>;\n clearValidate: (props?: FormProp | FormProp[]) => void;\n resetFields: (props?: FormProp | FormProp[]) => void;\n emitValidate: (prop: FormProp | undefined, valid: boolean, message: string) => void;\n}\n\nexport interface FormValidationPreset {\n pattern: RegExp;\n message: string;\n}\n\nexport const formContextKey: InjectionKey<FormContext> = Symbol(\"ui-form-context\");\n\n/** formValidatorPatterns 提供管理端表单常用正则,业务规则可通过 preset 直接复用。 */\nexport const formValidatorPatterns = {\n email: { pattern: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/, message: \"请输入正确的邮箱地址\" },\n phoneCN: { pattern: /^1[3-9]\\d{9}$/, message: \"请输入正确的手机号\" },\n url: { pattern: /^(https?:\\/\\/)?([\\w-]+\\.)+[\\w-]+(\\/[\\w./?%&=+#:-]*)?$/i, message: \"请输入正确的 URL\" },\n ipv4: { pattern: /^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}$/, message: \"请输入正确的 IPv4 地址\" },\n idCardCN: { pattern: /(^\\d{15}$)|(^\\d{17}[\\dXx]$)/, message: \"请输入正确的身份证号码\" },\n postalCodeCN: { pattern: /^\\d{6}$/, message: \"请输入正确的邮政编码\" },\n integer: { pattern: /^-?\\d+$/, message: \"请输入整数\" },\n positiveInteger: { pattern: /^[1-9]\\d*$/, message: \"请输入正整数\" },\n number: { pattern: /^-?(\\d+|\\d+\\.\\d+|\\.\\d+)$/, message: \"请输入数字\" },\n decimal2: { pattern: /^-?\\d+(\\.\\d{1,2})?$/, message: \"最多保留两位小数\" },\n alpha: { pattern: /^[A-Za-z]+$/, message: \"只能输入英文字母\" },\n alphaNum: { pattern: /^[A-Za-z0-9]+$/, message: \"只能输入英文字母和数字\" },\n projectId: { pattern: /^[A-Za-z0-9_-]+$/, message: \"只能输入字母、数字、下划线和短横线\" },\n slug: { pattern: /^[a-z0-9]+(?:-[a-z0-9]+)*$/, message: \"请输入小写字母、数字和短横线组成的标识\" },\n hexColor: { pattern: /^#(?:[0-9A-Fa-f]{3}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/, message: \"请输入正确的十六进制颜色\" },\n chinese: { pattern: /^[\\u4e00-\\u9fa5]+$/, message: \"只能输入中文\" },\n password: { pattern: /^(?=.*[A-Za-z])(?=.*\\d).{8,32}$/, message: \"密码需包含字母和数字,长度 8-32 位\" },\n} satisfies Record<string, FormValidationPreset>;\n\n/** createFormRule 让调用方用内置 preset 快速构造 async-validator 规则。 */\nexport function createFormRule(preset: FormRulePreset, rule: Omit<FormRule, \"preset\" | \"pattern\"> = {}): FormRule {\n const validator = formValidatorPatterns[preset];\n return {\n pattern: validator.pattern,\n message: validator.message,\n ...rule,\n };\n}\n\nexport function normalizeFormProp(prop?: FormProp) {\n if (Array.isArray(prop)) return prop.join(\".\");\n return prop;\n}\n\nexport function getValueByPath(source: Values | undefined, prop?: FormProp) {\n if (!source || !prop) return undefined;\n const paths = Array.isArray(prop) ? prop : String(prop).split(\".\");\n return paths.reduce<unknown>((value, path) => (value !== null && typeof value === \"object\" ? (value as Values)[path] : undefined), source);\n}\n\nexport function setValueByPath(source: Values | undefined, prop: FormProp | undefined, value: unknown) {\n if (!source || !prop) return;\n const paths = Array.isArray(prop) ? prop : String(prop).split(\".\");\n const lastPath = paths.at(-1);\n if (!lastPath) return;\n\n let target: Values = source;\n for (const path of paths.slice(0, -1)) {\n const nextValue = target[path];\n if (nextValue === null || typeof nextValue !== \"object\") target[path] = {};\n target = target[path] as Values;\n }\n target[lastPath] = value;\n}\n\nexport function normalizeRules(rules?: FormItemRule): FormRule[] {\n if (!rules) return [];\n return (Array.isArray(rules) ? rules : [rules]).map((rule) => {\n if (!rule.preset) return { ...rule };\n const preset = formValidatorPatterns[rule.preset];\n return {\n pattern: preset.pattern,\n message: preset.message,\n ...rule,\n preset: undefined,\n };\n });\n}\n\nexport async function validateFormValue(prop: FormProp | undefined, value: unknown, rules: FormRule[], options: ValidateOption = {}) {\n const field = normalizeFormProp(prop);\n if (!field || rules.length === 0) return { valid: true } satisfies FormItemValidateResult;\n\n const descriptor = { [field]: rules.map(({ trigger: _trigger, preset: _preset, ...rule }) => rule) };\n const validator = new Schema(descriptor);\n try {\n await validator.validate({ [field]: value }, options);\n return { valid: true } satisfies FormItemValidateResult;\n } catch (error) {\n const validationError = error as { errors?: ValidateError[]; fields?: ValidateFieldsError };\n const errors = validationError.errors ?? validationError.fields?.[field] ?? [];\n return { valid: false, errors } satisfies FormItemValidateResult;\n }\n}\n\nexport const defaultFormValidateMessages: ValidateMessages = {\n default: \"字段验证错误\",\n required: \"%s 为必填项\",\n types: {\n email: \"%s 不是有效的邮箱地址\",\n url: \"%s 不是有效的 URL\",\n number: \"%s 不是有效的数字\",\n },\n string: {\n min: \"%s 至少 %s 个字符\",\n max: \"%s 最多 %s 个字符\",\n range: \"%s 长度需在 %s 到 %s 个字符之间\",\n },\n number: {\n min: \"%s 不能小于 %s\",\n max: \"%s 不能大于 %s\",\n range: \"%s 需在 %s 到 %s 之间\",\n },\n};\n\n/** formRoot 定义 Form 根布局,支持标准、inline 两种模式。 */\nexport const formRoot = cva(\"ui-form text-primary\", {\n variants: {\n inline: {\n true: \"flex flex-wrap items-start gap-x-4\",\n false: \"\",\n },\n size: {\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-base\",\n },\n disabled: {\n true: \"opacity-70\",\n false: \"\",\n },\n },\n defaultVariants: {\n inline: false,\n size: \"md\",\n disabled: false,\n },\n});\n\n/** formItem 定义 FormItem 的整体排版和字段间距,确保嵌套网格内也有稳定行距。 */\nexport const formItem = cva(\"ui-form-item mb-[var(--ui-form-item-gap,16px)] min-w-0 self-start content-start last:mb-0\", {\n variants: {\n inline: {\n true: \"inline-flex w-auto items-start\",\n false: \"grid w-full\",\n },\n labelPosition: {\n left: \"grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3\",\n right: \"grid-cols-[var(--ui-form-label-width)_minmax(0,1fr)] items-start gap-x-3\",\n top: \"gap-1\",\n },\n size: {\n sm: \"\",\n md: \"\",\n lg: \"\",\n },\n error: {\n true: \"\",\n false: \"\",\n },\n },\n compoundVariants: [\n { inline: true, labelPosition: \"top\", class: \"flex-col\" },\n ],\n defaultVariants: {\n inline: false,\n labelPosition: \"right\",\n size: \"md\",\n error: false,\n },\n});\n\n/** formItemLabel 定义 FormItem 标签对齐、尺寸和必填标识样式。 */\nexport const formItemLabel = cva(\"flex min-w-0 whitespace-normal break-words text-primary\", {\n variants: {\n labelPosition: {\n left: \"justify-start\",\n right: \"justify-end\",\n top: \"justify-start\",\n },\n size: {\n sm: \"text-xs/5\",\n md: \"text-sm/5\",\n lg: \"text-base/6\",\n },\n required: {\n true: \"\",\n false: \"\",\n },\n requiredPosition: {\n left: \"\",\n right: \"\",\n },\n },\n compoundVariants: [\n { required: true, requiredPosition: \"left\", class: \"before:mr-1 before:text-red-500 before:content-['*']\" },\n { required: true, requiredPosition: \"right\", class: \"after:ml-1 after:text-red-500 after:content-['*']\" },\n { labelPosition: [\"left\", \"right\"], size: \"sm\", class: \"items-center border-y border-transparent py-1\" },\n { labelPosition: [\"left\", \"right\"], size: \"md\", class: \"items-center border-y border-transparent py-1.5\" },\n { labelPosition: [\"left\", \"right\"], size: \"lg\", class: \"items-center border-y border-transparent py-1.5\" },\n ],\n defaultVariants: {\n labelPosition: \"right\",\n size: \"md\",\n required: false,\n requiredPosition: \"right\",\n },\n});\n\n/** formItemContent 定义控件区与错误提示布局。 */\nexport const formItemContent = cva(\"flex min-w-0 flex-col justify-center\", {\n variants: {\n labelPosition: {\n left: \"\",\n right: \"\",\n top: \"\",\n },\n size: {\n sm: \"text-sm\",\n md: \"text-sm\",\n lg: \"text-base\",\n },\n },\n compoundVariants: [\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"sm\", class: \"min-h-7.5\" },\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"md\", class: \"min-h-8.5\" },\n { labelPosition: [\"left\", \"right\", \"top\"], size: \"lg\", class: \"min-h-9.5\" },\n ],\n defaultVariants: {\n labelPosition: \"right\",\n size: \"md\",\n },\n});\n\n/** formItemMessage 定义 FormItem 校验提示视觉。 */\nexport const formItemMessage = cva(\"mt-1.5 min-h-4 text-xs/4\", {\n variants: {\n status: {\n \"\": \"text-tertiary\",\n validating: \"text-brand-500\",\n success: \"text-green-600 dark:text-green-400\",\n error: \"text-red-600 dark:text-red-400\",\n },\n },\n defaultVariants: {\n status: \"\",\n },\n});\n\nexport type FormProps = VariantProps<typeof formRoot>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAaA,IAAM,IAAQ,GAiDR,IAAO,GAMP,IAAQ,EAAS,GACjB,IAAS,EAA8B,CAAC,CAAC,GAEzC,IAAY,QAAe,EAAK,EAAM,OAA6B,EAAS;GAAE,QAAQ,E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