@tu-design/vue 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +625 -273
- package/dist/index.mjs +766 -235
- package/dist/registry/vue/alert-dialog.json +22 -0
- package/dist/registry/vue/context-menu.json +22 -0
- package/dist/registry/vue/drawer.json +22 -0
- package/dist/registry/vue/popconfirm.json +22 -0
- package/dist/registry/vue/registry.json +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "alert-dialog",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "确认弹窗单组件:v-model:open 控制显隐,title/description 传文案,@confirm/@cancel 处理确认与取消;确认处理器返回 Promise 时按钮进入 loading 并锁定 ESC/遮罩关闭,resolve 自动关闭、reject 保持打开;内容节点为 role=alertdialog。",
|
|
6
|
+
"registryDependencies": ["button", "utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "alert-dialog/AlertDialog.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/alert-dialog/AlertDialog.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, ref } from \"vue\";\nimport { Dialog as ArkDialog } from \"@ark-ui/vue/dialog\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/button\";\n\n// 用运行时 props 显式 default: undefined:Boolean prop 缺省时 Vue 会 cast 成 false,\n// 导致无法区分「未传(非受控)」与「传了 false(受控关闭)」。与 Dialog.vue 同款约定。\nconst props = defineProps({\n /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n /** 标题文案(#title 插槽优先) */\n title: { type: String, required: true },\n /** 描述文案(#description 插槽优先,可不传) */\n description: { type: String, default: undefined },\n /** 确认按钮文案 */\n confirmText: { type: String, default: \"确定\" },\n /** 取消按钮文案 */\n cancelText: { type: String, default: \"取消\" },\n /** 确认按钮使用 destructive 语义色(危险操作场景) */\n destructive: { type: Boolean, default: false },\n});\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n confirm: [];\n cancel: [];\n}>();\n\n// 对 Root 恒走受控模式(open 恒为布尔):非受控语义由内部 ref 实现,与 Dialog.vue 一致。\n// setup 期间捕获实例:getCurrentInstance 仅在 setup/生命周期内有效,事件回调里返回 null。\nconst instance = getCurrentInstance();\nconst internalOpen = ref(false);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\n\nfunction handleUpdate(open: boolean) {\n // pending 期间忽略一切关闭请求(走受控桥拒绝同步,弹窗保持打开)——\n // 与 Popconfirm 同款锁定方案;Root 仍保留 :close-on-escape/:close-on-interact-outside 双保险\n if (!open && loading.value) return;\n internalOpen.value = open;\n emit(\"update:open\", open);\n}\n\n/** 关闭弹窗:走受控桥把 open 置 false,退出动画/焦点还原由 zag 处理 */\nfunction close() {\n handleUpdate(false);\n}\n\n// 确认 Promise pending 时锁定关闭通道(ESC/遮罩/取消按钮全部锁死),只能等 Promise 落定\nconst loading = ref(false);\nconst locked = computed(() => loading.value);\n\n/**\n * 确认:emit 不会回传处理器返回值,因此从 vnode 上直接取原始 onConfirm 处理器调用——\n * 返回 Promise 时进入 loading 并锁定关闭,resolve 后自动关闭,reject 保持打开且退出 loading;\n * 同步处理器(或无处理器)直接关闭。\n */\nfunction handleConfirm() {\n if (loading.value) return;\n const handler = instance?.vnode.props?.onConfirm as ((...args: unknown[]) => unknown) | undefined;\n const result = handler?.();\n if (!handler) emit(\"confirm\");\n if (result instanceof Promise) {\n loading.value = true;\n result\n .then(() => {\n loading.value = false;\n close();\n })\n .catch(() => {\n loading.value = false;\n });\n } else {\n close();\n }\n}\n\n/** 取消:pending 时同样锁定;确认关闭并派发 cancel */\nfunction handleCancel() {\n if (loading.value) return;\n emit(\"cancel\");\n close();\n}\n\n// 面板样式:复用 Dialog 的内容面板类,宽度收窄为 sm:max-w-md 的确认弹窗尺度\nconst contentClass = computed(() =>\n cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed left-1/2 top-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-lg border p-6 shadow-lg duration-200 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:max-w-md\",\n ),\n);\n</script>\n\n<template>\n <ArkDialog.Root\n :open=\"isOpen\"\n :close-on-escape=\"!locked\"\n :close-on-interact-outside=\"!locked\"\n @update:open=\"handleUpdate\"\n >\n <ArkDialog.Backdrop\n class=\"fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\"\n />\n <ArkDialog.Positioner class=\"fixed inset-0 z-50 flex items-center justify-center p-4\">\n <!-- role=\"alertdialog\":覆盖 Ark Content 默认 role=\"dialog\",补偿无上游 AlertDialog 原语的角色语义 -->\n <ArkDialog.Content :class=\"contentClass\" role=\"alertdialog\" aria-modal=\"true\">\n <div class=\"flex flex-col gap-2 text-center sm:text-left\">\n <ArkDialog.Title class=\"text-lg font-semibold leading-none tracking-tight\">\n <slot name=\"title\">{{ props.title }}</slot>\n </ArkDialog.Title>\n <ArkDialog.Description\n v-if=\"$slots.description || props.description\"\n class=\"text-sm text-muted-foreground\"\n >\n <slot name=\"description\">{{ props.description }}</slot>\n </ArkDialog.Description>\n </div>\n\n <!-- 默认插槽:补充正文(可选) -->\n <slot />\n\n <!-- 底部操作区:取消 outline,确认按 destructive 切换语义色;pending 时确认钮转 loading -->\n <div class=\"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end\">\n <Button variant=\"outline\" :disabled=\"loading\" @click=\"handleCancel\">\n {{ props.cancelText }}\n </Button>\n <Button\n :variant=\"props.destructive ? 'destructive' : 'default'\"\n :disabled=\"loading\"\n @click=\"handleConfirm\"\n >\n <svg\n v-if=\"loading\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n class=\"size-4 animate-spin\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />\n </svg>\n {{ props.confirmText }}\n </Button>\n </div>\n </ArkDialog.Content>\n </ArkDialog.Positioner>\n </ArkDialog.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "alert-dialog/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/alert-dialog/index.ts",
|
|
19
|
+
"content": "export { default as AlertDialog } from \"./AlertDialog.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "context-menu",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "右键菜单:单组件模式,items 描述菜单项(与 dropdown-menu 同构,含分组/标题/分隔线,支持嵌套),默认插槽为触发元素(ContextTrigger as-child,右键唤出并定位到指针处),内置键盘导航与选中回调。",
|
|
6
|
+
"registryDependencies": ["utils", "dropdown-menu"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "context-menu/ContextMenu.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/context-menu/ContextMenu.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { useAttrs } from \"vue\";\nimport { Menu as ArkMenu } from \"@ark-ui/vue/menu\";\nimport { cn } from \"@/lib/utils\";\n// 与 dropdown-menu 同构:items 类型与渲染逻辑直接复用其实现(单一事实来源)\nimport MenuItems from \"../dropdown-menu/MenuItems.vue\";\nimport type { MenuItemOption } from \"../dropdown-menu/types\";\n\ndefineOptions({ name: \"ContextMenu\", inheritAttrs: false });\n\nconst props = defineProps({\n /** 菜单项描述列表,与 DropdownMenu 的 items 完全同构(item/label/separator/group 四种形态,group 可嵌套) */\n items: { type: Array as PropType<MenuItemOption[]>, required: true },\n});\n\n// 仅暴露选中事件;开合由触发元素上的右键(contextmenu)事件驱动,ark 内部管理状态\nconst emit = defineEmits<{\n /** 选中某个 item 时触发(对齐 DropdownMenu 的事件语义) */\n select: [details: { value: string }];\n}>();\n\n// attrs 转发到面板元素(Root 不渲染 DOM,避免 fallthrough 警告)\nconst attrs = useAttrs();\n\nfunction handleSelect(details: { value: string }) {\n emit(\"select\", details);\n}\n\n// 面板样式对齐 DropdownMenu 面板(token 化,暗色随主题变量自动切换)\nconst contentCls =\n \"bg-popover text-popover-foreground z-50 min-w-[8rem] overflow-hidden rounded-md border p-1 shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95\";\n</script>\n\n<template>\n <ArkMenu.Root @select=\"handleSelect\">\n <!-- 默认插槽 = 触发元素本身(ContextTrigger as-child 透传,右键唤出并定位到指针处) -->\n <ArkMenu.ContextTrigger as-child>\n <slot />\n </ArkMenu.ContextTrigger>\n\n <ArkMenu.Positioner class=\"z-50\">\n <ArkMenu.Content v-bind=\"attrs\" :class=\"cn(contentCls)\">\n <MenuItems :items=\"props.items\" />\n </ArkMenu.Content>\n </ArkMenu.Positioner>\n </ArkMenu.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "context-menu/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/context-menu/index.ts",
|
|
19
|
+
"content": "export { default as ContextMenu } from \"./ContextMenu.vue\";\n// items 类型与 dropdown-menu 同构:直接 re-export 其 MenuItemOption,保持单一事实来源\nexport type { MenuItemOption } from \"../dropdown-menu\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "drawer",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "抽屉单组件:从四方向滑出的侧边/顶底面板,#trigger 放触发元素,title/description 传文案,#footer 注入 close 关闭;基于 Ark UI Drawer 原语,进出场动画随 placement 方向自适应,含焦点圈定、Escape/遮罩关闭,支持 v-model:open。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "drawer/Drawer.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/drawer/Drawer.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { Drawer as ArkDrawer } from \"@ark-ui/vue/drawer\";\nimport { cn } from \"@/lib/utils\";\n\ntype Placement = \"top\" | \"right\" | \"bottom\" | \"left\";\ntype Size = \"sm\" | \"default\" | \"lg\";\n\n// 用运行时 props 显式 default: undefined:Boolean prop 缺省时 Vue 会 cast 成 false,\n// 导致无法区分「未传(非受控)」与「传了 false(受控关闭)」。\nconst props = defineProps({\n /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n /** 非受控时的初始开关 */\n defaultOpen: { type: Boolean, default: false },\n /** 首次打开前不挂载内容 */\n lazyMount: { type: Boolean, default: false },\n /** 关闭后卸载内容(关闭动画结束后) */\n unmountOnExit: { type: Boolean, default: false },\n /** 抽屉弹出方向 */\n placement: { type: String as PropType<Placement>, default: \"right\" },\n /** 尺寸档位:侧向(left/right)为宽度,顶/底向(top/bottom)为高度 */\n size: { type: String as PropType<Size>, default: \"default\" },\n /** 标题文案(#title 插槽优先,两者皆无则不渲染标题) */\n title: { type: String, default: undefined },\n /** 描述文案(#description 插槽优先,两者皆无则不渲染描述) */\n description: { type: String, default: undefined },\n /** 是否渲染右上角内置关闭按钮(aria-label=\"关闭\") */\n showCloseButton: { type: Boolean, default: true },\n});\n\nconst emit = defineEmits<{ \"update:open\": [open: boolean] }>();\n\n// 对 Root 恒走受控模式(open 恒为布尔):非受控语义由内部 ref 实现,\n// 与 Dialog 同款桥接,两种模式行为一致。\nconst internalOpen = ref(props.defaultOpen);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\n\nfunction handleUpdate(open: boolean) {\n internalOpen.value = open;\n emit(\"update:open\", open);\n}\n\n/** 关闭抽屉(#footer 作用域插槽注入) */\nfunction close() {\n handleUpdate(false);\n}\n\n// 标题/描述有任一来源(props 或插槽)时才渲染头部区块\nconst hasHeader = computed(() => Boolean(props.title || props.description));\n\n// 定位与尺寸:侧向=宽度档位,顶/底向=高度档位;边框贴合抽屉边缘\nconst placementConfig: Record<\n Placement,\n { positioner: string; content: string; sizes: Record<Size, string> }\n> = {\n right: {\n positioner: \"justify-end\",\n content: \"inset-y-0 right-0 h-full border-l\",\n // 档位类带 sm: 前缀 + 基础类用无前缀全宽:tw-merge 对不同断点前缀不互相覆盖,\n // 语义确定为「移动端全宽、sm 起按档位」(写成 \"w-full sm:w-96\" 而非让 tw-merge 去重)\n sizes: { sm: \"sm:w-80\", default: \"sm:w-96\", lg: \"sm:w-[40rem]\" },\n },\n left: {\n positioner: \"justify-start\",\n content: \"inset-y-0 left-0 h-full border-r\",\n sizes: { sm: \"sm:w-80\", default: \"sm:w-96\", lg: \"sm:w-[40rem]\" },\n },\n top: {\n positioner: \"items-start\",\n content: \"inset-x-0 top-0 w-full border-b\",\n sizes: { sm: \"sm:h-64\", default: \"sm:h-80\", lg: \"sm:h-[28rem]\" },\n },\n bottom: {\n positioner: \"items-end\",\n content: \"inset-x-0 bottom-0 w-full border-t\",\n sizes: { sm: \"sm:h-64\", default: \"sm:h-80\", lg: \"sm:h-[28rem]\" },\n },\n};\n\n// 进出场动画随 placement 方向自适应:从哪侧弹出就从哪侧滑入,退场对称滑出\nconst placementAnimations: Record<Placement, string> = {\n right: \"data-[state=open]:slide-in-from-right data-[state=closed]:slide-out-to-right\",\n left: \"data-[state=open]:slide-in-from-left data-[state=closed]:slide-out-to-left\",\n top: \"data-[state=open]:slide-in-from-top data-[state=closed]:slide-out-to-top\",\n bottom: \"data-[state=open]:slide-in-from-bottom data-[state=closed]:slide-out-to-bottom\",\n};\n\nconst config = computed(() => placementConfig[props.placement]);\n\nconst isLateral = computed(() => props.placement === \"left\" || props.placement === \"right\");\n\n// 面板样式:定位 + 档位尺寸 + 方向动画\n// 侧向:基础 w-full(移动端全宽)+ sm: 断点档位宽度;顶/底向:基础 h-full + sm: 档位高度\nconst contentClass = computed(() =>\n cn(\n \"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 overflow-y-auto p-6 shadow-lg duration-200\",\n config.value.content,\n isLateral.value\n ? cn(\"w-full\", config.value.sizes[props.size])\n : cn(\"h-full\", config.value.sizes[props.size]),\n placementAnimations[props.placement],\n ),\n);\n</script>\n\n<template>\n <ArkDrawer.Root\n :open=\"isOpen\"\n :lazy-mount=\"props.lazyMount\"\n :unmount-on-exit=\"props.unmountOnExit\"\n @update:open=\"handleUpdate\"\n >\n <ArkDrawer.Trigger v-if=\"$slots.trigger\" as-child>\n <slot name=\"trigger\" />\n </ArkDrawer.Trigger>\n\n <ArkDrawer.Backdrop\n class=\"fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\"\n />\n <ArkDrawer.Positioner :class=\"cn('fixed inset-0 z-50 flex', config.positioner)\">\n <ArkDrawer.Content :class=\"contentClass\">\n <div v-if=\"hasHeader || $slots.title || $slots.description\" class=\"flex flex-col gap-1.5\">\n <ArkDrawer.Title\n v-if=\"$slots.title || props.title\"\n class=\"text-lg font-semibold leading-none tracking-tight\"\n >\n <slot name=\"title\">{{ props.title }}</slot>\n </ArkDrawer.Title>\n <ArkDrawer.Description\n v-if=\"$slots.description || props.description\"\n class=\"text-sm text-muted-foreground\"\n >\n <slot name=\"description\">{{ props.description }}</slot>\n </ArkDrawer.Description>\n </div>\n\n <slot />\n\n <div\n v-if=\"$slots.footer\"\n class=\"mt-auto flex flex-col-reverse gap-2 pt-2 sm:flex-row sm:justify-end\"\n >\n <slot name=\"footer\" :close=\"close\" />\n </div>\n\n <ArkDrawer.CloseTrigger\n v-if=\"props.showCloseButton\"\n aria-label=\"关闭\"\n class=\"absolute right-4 top-4 cursor-pointer rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none\"\n >\n <svg\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"size-4\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n <span class=\"sr-only\">关闭</span>\n </ArkDrawer.CloseTrigger>\n </ArkDrawer.Content>\n </ArkDrawer.Positioner>\n </ArkDrawer.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "drawer/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/drawer/index.ts",
|
|
19
|
+
"content": "export { default as Drawer } from \"./Drawer.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "popconfirm",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "气泡确认:Popover 薄壳变体单组件,默认插槽为触发元素本体(asChild),title/description 传文案,@confirm/@cancel 处理确认与取消;确认处理器返回 Promise 时确认钮 loading 并锁定关闭通道,resolve 自动关闭、reject 保持打开。",
|
|
6
|
+
"registryDependencies": ["utils", "popover", "button"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "popconfirm/Popconfirm.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/popconfirm/Popconfirm.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, getCurrentInstance, ref, useAttrs } from \"vue\";\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\nimport { Popover } from \"@/components/popover\";\nimport { Button } from \"@/components/button\";\n\n/**\n * 气泡确认:Popover 的一体式薄壳变体,面板内容内置 title/description + 确认/取消按钮。\n * 行为与 M2 AlertDialog 对齐:@confirm 处理器返回 Promise 时确认钮进入 loading 并锁定全部\n * 关闭通道(ESC/点外部/触发器/取消钮),resolve 后自动关闭、reject 保持打开;\n * 同步处理器点击确认/取消后自动关闭并派发对应事件。\n */\n\nconst props = defineProps({\n /** 气泡标题(渲染为 Ark Popover.Title,content 自动接线 aria-labelledby) */\n title: { type: String, required: true },\n /** 气泡描述(可选,渲染为 Ark Popover.Description,content 自动接线 aria-describedby) */\n description: { type: String, default: undefined },\n /** 确认按钮文案 */\n confirmText: { type: String, default: \"确定\" },\n /** 取消按钮文案 */\n cancelText: { type: String, default: \"取消\" },\n /** 确认按钮风格:default 主色 / destructive 危险色 */\n variant: {\n type: String as PropType<\"default\" | \"destructive\">,\n default: \"default\",\n },\n /** 受控开关(配合 v-model:open);不传时为非受控,由内部状态管理 */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:open\": [open: boolean];\n confirm: [];\n cancel: [];\n}>();\n\ndefineOptions({ inheritAttrs: false });\n\n// attrs(positioning/modal 等 Ark Root 属性)原样透传给 Popover,由其合并到 Ark Root\nconst attrs = useAttrs();\n\n// setup 期间捕获实例:getCurrentInstance 仅在 setup/生命周期内有效,事件回调里返回 null\nconst instance = getCurrentInstance();\n\n// 确认 Promise pending 标记:锁定关闭通道与操作按钮\nconst loading = ref(false);\n\n// —— 受控桥接(Popover/Dialog 同款):Root 恒走受控,非受控语义由内部 ref 实现 ——\nconst internalOpen = ref(false);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\n\nfunction handleUpdate(open: boolean) {\n // pending 期间忽略一切关闭请求(走受控桥拒绝同步,气泡保持展开)\n if (!open && loading.value) return;\n internalOpen.value = open;\n emit(\"update:open\", open);\n}\n\n/** 关闭气泡:走受控桥把 open 置 false,定位回退/动画由 zag 处理 */\nfunction close() {\n handleUpdate(false);\n}\n\n/**\n * 确认:emit 不回传监听器返回值,因此从 vnode 取原始 onConfirm 处理器直接调用\n * (该调用本身就是父级监听器,不会重复派发)。返回 Promise 时进入 loading 并锁定关闭,\n * resolve 后自动关闭,reject 保持打开并退出 loading;同步处理器直接关闭。\n */\nfunction handleConfirm() {\n if (loading.value) return;\n const handler = instance?.vnode.props?.onConfirm as ((...args: unknown[]) => unknown) | undefined;\n const result = handler?.();\n if (!handler) emit(\"confirm\");\n if (result instanceof Promise) {\n loading.value = true;\n result\n .then(() => {\n loading.value = false;\n close();\n })\n .catch(() => {\n loading.value = false;\n });\n } else {\n close();\n }\n}\n\n/** 取消:pending 期间锁定;派发 cancel 并关闭 */\nfunction handleCancel() {\n if (loading.value) return;\n emit(\"cancel\");\n close();\n}\n</script>\n\n<template>\n <!-- 薄壳复用 Popover:触发器 asChild、受控桥、定位与进出场动画均由 Popover 提供 -->\n <Popover v-bind=\"attrs\" :open=\"isOpen\" content-class=\"w-64 p-3\" @update:open=\"handleUpdate\">\n <!-- 默认插槽即触发元素本体(asChild 语义合并到子元素) -->\n <slot />\n <template #content>\n <ArkPopover.Title class=\"text-sm font-medium\">{{ props.title }}</ArkPopover.Title>\n <ArkPopover.Description v-if=\"props.description\" class=\"mt-1 text-xs text-muted-foreground\">\n {{ props.description }}\n </ArkPopover.Description>\n <!-- 操作区:取消 outline,确认按 variant 切换语义色;pending 时双钮禁用 + 确认钮转 loading -->\n <div class=\"mt-3 flex items-center justify-end gap-2\">\n <Button variant=\"outline\" size=\"sm\" :disabled=\"loading\" @click=\"handleCancel\">\n {{ props.cancelText }}\n </Button>\n <Button\n :variant=\"props.variant === 'destructive' ? 'destructive' : 'default'\"\n size=\"sm\"\n :disabled=\"loading\"\n @click=\"handleConfirm\"\n >\n <svg\n v-if=\"loading\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n class=\"size-4 animate-spin\"\n aria-hidden=\"true\"\n >\n <path d=\"M21 12a9 9 0 1 1-6.219-8.56\" />\n </svg>\n {{ props.confirmText }}\n </Button>\n </div>\n </template>\n </Popover>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "popconfirm/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/popconfirm/index.ts",
|
|
19
|
+
"content": "export { default as Popconfirm } from \"./Popconfirm.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"type": "registry:ui",
|
|
9
9
|
"description": "语义化警示条,支持五种变体、内置图标与可关闭交互。"
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
"name": "alert-dialog",
|
|
13
|
+
"title": "AlertDialog",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"description": "确认弹窗单组件:v-model:open 控制显隐,title/description 传文案,@confirm/@cancel 处理确认与取消;确认处理器返回 Promise 时按钮进入 loading 并锁定 ESC/遮罩关闭,resolve 自动关闭、reject 保持打开;内容节点为 role=alertdialog。"
|
|
16
|
+
},
|
|
11
17
|
{
|
|
12
18
|
"name": "avatar",
|
|
13
19
|
"title": "Avatar",
|
|
@@ -56,6 +62,12 @@
|
|
|
56
62
|
"type": "registry:ui",
|
|
57
63
|
"description": "复选框:基于 Ark UI Checkbox 原语,支持标签插槽、受控/非受控与禁用。"
|
|
58
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"name": "context-menu",
|
|
67
|
+
"title": "ContextMenu",
|
|
68
|
+
"type": "registry:ui",
|
|
69
|
+
"description": "右键菜单:单组件模式,items 描述菜单项(与 dropdown-menu 同构,含分组/标题/分隔线,支持嵌套),默认插槽为触发元素(ContextTrigger as-child,右键唤出并定位到指针处),内置键盘导航与选中回调。"
|
|
70
|
+
},
|
|
59
71
|
{
|
|
60
72
|
"name": "currency-input",
|
|
61
73
|
"title": "CurrencyInput",
|
|
@@ -86,6 +98,12 @@
|
|
|
86
98
|
"type": "registry:ui",
|
|
87
99
|
"description": "模态对话框单组件:#trigger 放触发元素,title/description 传文案,#footer 注入 close 关闭;基于 Ark UI Dialog 原语,含焦点圈定、Escape/遮罩关闭与进出场动画,支持 v-model:open。"
|
|
88
100
|
},
|
|
101
|
+
{
|
|
102
|
+
"name": "drawer",
|
|
103
|
+
"title": "Drawer",
|
|
104
|
+
"type": "registry:ui",
|
|
105
|
+
"description": "抽屉单组件:从四方向滑出的侧边/顶底面板,#trigger 放触发元素,title/description 传文案,#footer 注入 close 关闭;基于 Ark UI Drawer 原语,进出场动画随 placement 方向自适应,含焦点圈定、Escape/遮罩关闭,支持 v-model:open。"
|
|
106
|
+
},
|
|
89
107
|
{
|
|
90
108
|
"name": "dropdown-menu",
|
|
91
109
|
"title": "DropdownMenu",
|
|
@@ -146,6 +164,12 @@
|
|
|
146
164
|
"type": "registry:ui",
|
|
147
165
|
"description": "多格验证码输入:length 指定格数,支持 otp/mask/字符类型、焦点自动跳格与填满回调,可选分隔符插槽。"
|
|
148
166
|
},
|
|
167
|
+
{
|
|
168
|
+
"name": "popconfirm",
|
|
169
|
+
"title": "Popconfirm",
|
|
170
|
+
"type": "registry:ui",
|
|
171
|
+
"description": "气泡确认:Popover 薄壳变体单组件,默认插槽为触发元素本体(asChild),title/description 传文案,@confirm/@cancel 处理确认与取消;确认处理器返回 Promise 时确认钮 loading 并锁定关闭通道,resolve 自动关闭、reject 保持打开。"
|
|
172
|
+
},
|
|
149
173
|
{
|
|
150
174
|
"name": "popover",
|
|
151
175
|
"title": "Popover",
|