@tu-design/vue 0.2.2 → 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 +3717 -1104
- package/dist/index.mjs +7593 -1249
- package/dist/registry/vue/alert-dialog.json +22 -0
- package/dist/registry/vue/alert.json +22 -0
- package/dist/registry/vue/avatar-group.json +21 -0
- package/dist/registry/vue/avatar.json +3 -3
- package/dist/registry/vue/calendar.json +34 -0
- package/dist/registry/vue/card.json +3 -33
- package/dist/registry/vue/cascader.json +34 -0
- package/dist/registry/vue/checkbox.json +1 -1
- package/dist/registry/vue/context-menu.json +22 -0
- package/dist/registry/vue/currency-input.json +1 -1
- package/dist/registry/vue/date-picker.json +22 -0
- package/dist/registry/vue/date-range-picker.json +22 -0
- package/dist/registry/vue/date-shared.json +26 -0
- package/dist/registry/vue/dialog.json +3 -45
- package/dist/registry/vue/drawer.json +22 -0
- package/dist/registry/vue/dropdown-menu.json +11 -35
- package/dist/registry/vue/empty.json +21 -0
- package/dist/registry/vue/form-render.json +115 -0
- package/dist/registry/vue/form.json +2 -2
- package/dist/registry/vue/month-picker.json +22 -0
- package/dist/registry/vue/number-input.json +1 -1
- package/dist/registry/vue/popconfirm.json +22 -0
- package/dist/registry/vue/popover.json +3 -15
- package/dist/registry/vue/progress.json +22 -0
- package/dist/registry/vue/radio-group.json +2 -8
- package/dist/registry/vue/registry.json +138 -6
- package/dist/registry/vue/select.json +3 -27
- package/dist/registry/vue/slider.json +1 -1
- package/dist/registry/vue/spin.json +22 -0
- package/dist/registry/vue/table-render.json +62 -0
- package/dist/registry/vue/tabs.json +2 -20
- package/dist/registry/vue/toast.json +28 -0
- package/dist/registry/vue/tokens.json +1 -1
- package/dist/registry/vue/tooltip.json +2 -14
- package/dist/registry/vue/tree-select.json +34 -0
- package/dist/registry/vue/tree-shared.json +92 -0
- package/dist/registry/vue/week-picker.json +22 -0
- package/dist/registry/vue/year-picker.json +22 -0
- package/package.json +3 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "popover",
|
|
4
4
|
"type": "registry:ui",
|
|
5
|
-
"description": "气泡弹层:基于 Ark UI Popover
|
|
5
|
+
"description": "气泡弹层:基于 Ark UI Popover 原语的单组件,默认插槽为触发元素本体(asChild 语义),面板内容放 #content 插槽,受控/非受控开关。",
|
|
6
6
|
"registryDependencies": ["utils"],
|
|
7
7
|
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
8
|
"files": [
|
|
@@ -10,25 +10,13 @@
|
|
|
10
10
|
"path": "popover/Popover.vue",
|
|
11
11
|
"type": "registry:component",
|
|
12
12
|
"target": "components/ui/popover/Popover.vue",
|
|
13
|
-
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "popover/PopoverContent.vue",
|
|
17
|
-
"type": "registry:component",
|
|
18
|
-
"target": "components/ui/popover/PopoverContent.vue",
|
|
19
|
-
"content": "<script setup lang=\"ts\">\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n class?: string;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<template>\n <ArkPopover.Positioner class=\"z-50\">\n <ArkPopover.Content\n :class=\"\n cn(\n 'bg-popover text-popover-foreground z-50 w-72 rounded-md border p-4 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',\n props.class,\n )\n \"\n >\n <slot />\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n</template>\n"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "popover/PopoverTrigger.vue",
|
|
23
|
-
"type": "registry:component",
|
|
24
|
-
"target": "components/ui/popover/PopoverTrigger.vue",
|
|
25
|
-
"content": "<script setup lang=\"ts\">\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\n\ninterface Props {\n /** 以默认插槽子元素为渲染目标,行为合并其上 */\n asChild?: boolean;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<template>\n <ArkPopover.Trigger :as-child=\"props.asChild\">\n <slot />\n </ArkPopover.Trigger>\n</template>\n"
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { ClassValue } from \"clsx\";\nimport type { PropType } from \"vue\";\nimport { computed, ref, useAttrs } from \"vue\";\nimport type { PopoverRootProps } from \"@ark-ui/vue/popover\";\nimport { Popover as ArkPopover } from \"@ark-ui/vue/popover\";\nimport { cn } from \"@/lib/utils\";\n\n/** 面板相对触发器的对齐方向 */\ntype Align = \"start\" | \"center\" | \"end\";\n\n/** Ark Popover Root 的 positioning 配置(placement 含四方向 × 对齐组合) */\ntype ArkPositioning = NonNullable<PopoverRootProps[\"positioning\"]>;\ntype ArkPlacement = NonNullable<ArkPositioning[\"placement\"]>;\n\ndefineOptions({ inheritAttrs: false });\n\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 /** 面板相对触发器的对齐方向(默认居中);attrs.positioning.placement 显式给出时以其为准 */\n align: { type: String as PropType<Align>, default: \"center\" },\n /** 追加/覆盖面板样式类(默认 w-72 可由此覆盖,如 \"w-56 p-0\") */\n contentClass: { type: String, default: undefined },\n /** 透传到面板根元素上的属性(id/style/data-* 等,class 请用 contentClass) */\n contentProps: { type: Object as PropType<Record<string, unknown>>, default: undefined },\n});\n\nconst emit = defineEmits<{ \"update:open\": [open: boolean] }>();\n\n// attrs(positioning/modal 等 Ark Root 属性)手动转发,便于与 align 合并出 positioning\nconst attrs = useAttrs();\n\n// —— 受控桥接(Dialog 同款):Root 恒走受控,非受控语义由内部 ref 实现 ——\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// align → Ark positioning.placement(横轴对齐,主轴默认 bottom 与 Ark 原语一致);\n// 外部经 attrs 传入的 positioning 已显式指定 placement 时以其为准,其余字段原样合并\nconst rootPositioning = computed<ArkPositioning>(() => {\n const user = (attrs.positioning ?? {}) as ArkPositioning;\n if (user.placement) return user;\n const placement = (props.align === \"center\" ? \"bottom\" : `bottom-${props.align}`) as ArkPlacement;\n return { ...user, placement };\n});\n\n// 面板样式:内置类 + contentClass + contentProps.class 三方合并(twMerge 自动去冲突,后者优先)\nconst contentClass = computed(() =>\n cn(\n \"bg-popover text-popover-foreground z-50 w-72 rounded-md border p-4 shadow-md outline-none data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95\",\n props.contentClass,\n props.contentProps?.[\"class\"] as ClassValue,\n ),\n);\n</script>\n\n<template>\n <ArkPopover.Root\n v-bind=\"attrs\"\n :open=\"isOpen\"\n :positioning=\"rootPositioning\"\n :lazy-mount=\"props.lazyMount\"\n :unmount-on-exit=\"props.unmountOnExit\"\n @update:open=\"handleUpdate\"\n >\n <!-- 默认插槽即触发元素本体(asChild 语义合并到子元素,不额外包裹,原 PopoverTrigger 同款实现) -->\n <ArkPopover.Trigger as-child>\n <slot />\n </ArkPopover.Trigger>\n <ArkPopover.Positioner class=\"z-50\">\n <ArkPopover.Content v-bind=\"props.contentProps\" :class=\"contentClass\">\n <slot name=\"content\" />\n </ArkPopover.Content>\n </ArkPopover.Positioner>\n </ArkPopover.Root>\n</template>\n"
|
|
26
14
|
},
|
|
27
15
|
{
|
|
28
16
|
"path": "popover/index.ts",
|
|
29
17
|
"type": "registry:component",
|
|
30
18
|
"target": "components/ui/popover/index.ts",
|
|
31
|
-
"content": "export { default as Popover } from \"./Popover.vue\";\
|
|
19
|
+
"content": "export { default as Popover } from \"./Popover.vue\";\n"
|
|
32
20
|
}
|
|
33
21
|
]
|
|
34
22
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "progress",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "进度条:基于 Ark UI Progress 原语,支持语义色、标签与百分比显示、不确定态。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "progress/Progress.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/progress/Progress.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport { Progress as ArkProgress } from \"@ark-ui/vue/progress\";\nimport { cn } from \"@/lib/utils\";\n\n/** 语义变体 */\ntype ProgressVariant = \"default\" | \"info\" | \"success\" | \"warning\" | \"error\";\n\nconst props = withDefaults(\n defineProps<{\n /** 当前值(配合 v-model:value,0 ~ max);显式传 null 为不确定态 */\n value?: number | null;\n /** 最大值 @default 100 */\n max?: number;\n /** 进度标签文本 */\n label?: string;\n /** 是否显示百分比文本 @default false */\n showValue?: boolean;\n /** 语义变体:default 用 primary,error 映射 destructive @default \"default\" */\n variant?: ProgressVariant;\n /** 不确定态(忽略 value,恒以 null 传给 Ark) */\n indeterminate?: boolean;\n /** 追加/覆盖根元素样式类 */\n class?: string;\n }>(),\n { max: 100, showValue: false, variant: \"default\", indeterminate: false },\n);\n\nconst emit = defineEmits<{ \"update:value\": [value: number | null] }>();\n\n// —— 受控桥接(Popover 同款):Root 恒走受控,非受控语义由内部 ref 实现 ——\nconst internalValue = ref<number | null>(0);\nconst modelValue = computed<number | null>(() => {\n if (props.indeterminate) return null;\n // 显式传 value(含 null)即受控;未传走内部状态\n return props.value !== undefined ? props.value : internalValue.value;\n});\n\nfunction handleUpdate(value: number | null) {\n internalValue.value = value;\n emit(\"update:value\", value);\n}\n\n// variant → 语义 token 着色(default 用 primary)\nconst rangeClass = computed(\n () =>\n ({\n default: \"bg-primary\",\n info: \"bg-info\",\n success: \"bg-success\",\n warning: \"bg-warning\",\n error: \"bg-destructive\",\n })[props.variant],\n);\n</script>\n\n<template>\n <ArkProgress.Root\n :model-value=\"modelValue\"\n :max=\"props.max\"\n :class=\"cn('relative flex w-full items-center gap-3', props.class)\"\n @update:model-value=\"handleUpdate\"\n >\n <ArkProgress.Label\n v-if=\"props.label\"\n class=\"text-foreground text-sm font-medium whitespace-nowrap\"\n >\n {{ props.label }}\n </ArkProgress.Label>\n <ArkProgress.Track class=\"bg-muted relative h-2 w-full grow overflow-hidden rounded-full\">\n <ArkProgress.Range\n :class=\"\n cn(\n 'h-full rounded-full transition-all duration-300',\n 'data-[state=indeterminate]:w-1/2 data-[state=indeterminate]:animate-pulse',\n rangeClass,\n )\n \"\n />\n </ArkProgress.Track>\n <ArkProgress.ValueText\n v-if=\"props.showValue\"\n class=\"text-muted-foreground text-sm leading-none tabular-nums whitespace-nowrap\"\n />\n </ArkProgress.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "progress/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/progress/index.ts",
|
|
19
|
+
"content": "export { default as Progress } from \"./Progress.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -10,19 +10,13 @@
|
|
|
10
10
|
"path": "radio-group/RadioGroup.vue",
|
|
11
11
|
"type": "registry:component",
|
|
12
12
|
"target": "components/ui/radio-group/RadioGroup.vue",
|
|
13
|
-
"content": "<script setup lang=\"ts\">\nimport { RadioGroup as ArkRadioGroup } from \"@ark-ui/vue/radio-group\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n /** 当前值(配合 v-model:value
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "radio-group/RadioGroupItem.vue",
|
|
17
|
-
"type": "registry:component",
|
|
18
|
-
"target": "components/ui/radio-group/RadioGroupItem.vue",
|
|
19
|
-
"content": "<script setup lang=\"ts\">\nimport { RadioGroup as ArkRadioGroup } from \"@ark-ui/vue/radio-group\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n value: string;\n disabled?: boolean;\n class?: string;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<template>\n <ArkRadioGroup.Item\n :value=\"props.value\"\n :disabled=\"props.disabled\"\n :class=\"cn('flex items-center gap-2', props.class)\"\n >\n <ArkRadioGroup.ItemHiddenInput />\n <ArkRadioGroup.ItemControl\n class=\"border-input text-primary shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 group aspect-square size-4 shrink-0 rounded-full border outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50\"\n >\n <div\n class=\"bg-primary size-2 rounded-full opacity-0 transition-opacity group-data-[state=checked]:opacity-100\"\n />\n </ArkRadioGroup.ItemControl>\n <ArkRadioGroup.ItemText v-if=\"$slots.default\" class=\"text-sm\">\n <slot />\n </ArkRadioGroup.ItemText>\n </ArkRadioGroup.Item>\n</template>\n"
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport { computed, ref } from \"vue\";\nimport { RadioGroup as ArkRadioGroup } from \"@ark-ui/vue/radio-group\";\nimport { cn } from \"@/lib/utils\";\n\n/** 单个选项配置项 */\ninterface RadioGroupOption {\n /** 选中后写入组值的唯一标识 */\n value: string;\n /** 选项文案 */\n label: string;\n /** 是否禁用该项(禁用项不响应点击且不参与键盘导航) */\n disabled?: boolean;\n /** 追加到选项根元素的样式类 */\n class?: string;\n}\n\ninterface Props {\n /** 选项列表(必填) */\n items: RadioGroupOption[];\n /** 当前值(配合 v-model:value);不传时为非受控(内部 ref 维护) */\n value?: string;\n defaultValue?: string;\n disabled?: boolean;\n /** 原生表单提交字段名 */\n name?: string;\n /** 关联的 form id */\n form?: string;\n required?: boolean;\n readOnly?: boolean;\n /** 校验无效态;zag 会级联 data-invalid 到 root/item/item-control */\n invalid?: boolean;\n orientation?: \"horizontal\" | \"vertical\";\n class?: string;\n}\n\nconst props = defineProps<Props>();\n\nconst emit = defineEmits<{ \"update:value\": [value: string] }>();\n\n// 对 Root 恒走受控模式,非受控语义由内部 ref 实现(Tabs/Checkbox 同款约定)\nconst internalValue = ref<string | null>(props.defaultValue ?? null);\nconst currentValue = computed(() => props.value ?? internalValue.value);\n\n// Ark 的 update:modelValue 实际类型为 string | null(单选交互不会产生 null,仅作守卫)\nfunction handleUpdate(value: string | null) {\n if (value === null) return;\n internalValue.value = value;\n emit(\"update:value\", value);\n}\n</script>\n\n<template>\n <ArkRadioGroup.Root\n :model-value=\"currentValue\"\n :disabled=\"props.disabled\"\n :name=\"props.name\"\n :form=\"props.form\"\n :required=\"props.required\"\n :read-only=\"props.readOnly\"\n :invalid=\"props.invalid\"\n :orientation=\"props.orientation\"\n :class=\"\n cn(\n 'grid gap-2',\n props.orientation === 'horizontal' && 'grid-flow-col auto-cols-max gap-4',\n props.class,\n )\n \"\n @update:model-value=\"handleUpdate\"\n >\n <ArkRadioGroup.Item\n v-for=\"item in props.items\"\n :key=\"item.value\"\n :value=\"item.value\"\n :disabled=\"item.disabled\"\n :class=\"cn('flex items-center gap-2', item.class)\"\n >\n <!-- 隐藏原生 input 始终渲染:name/required 等表单语义不因自定义渲染丢失 -->\n <ArkRadioGroup.ItemHiddenInput />\n <!-- #item 逃生口:接管圆点控件与文本的渲染;未提供时使用内置渲染 -->\n <slot name=\"item\" :item=\"item\" :checked=\"item.value === currentValue\">\n <ArkRadioGroup.ItemControl\n class=\"border-input text-primary shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 group flex aspect-square size-4 shrink-0 items-center justify-center rounded-full border outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-invalid:border-destructive data-invalid:ring-destructive/20 data-invalid:ring-[3px]\"\n >\n <div\n class=\"bg-primary group-data-[invalid]:bg-destructive size-2 rounded-full opacity-0 transition-opacity group-data-[state=checked]:opacity-100\"\n />\n </ArkRadioGroup.ItemControl>\n <ArkRadioGroup.ItemText class=\"text-sm\">{{ item.label }}</ArkRadioGroup.ItemText>\n </slot>\n </ArkRadioGroup.Item>\n </ArkRadioGroup.Root>\n</template>\n"
|
|
20
14
|
},
|
|
21
15
|
{
|
|
22
16
|
"path": "radio-group/index.ts",
|
|
23
17
|
"type": "registry:component",
|
|
24
18
|
"target": "components/ui/radio-group/index.ts",
|
|
25
|
-
"content": "export { default as RadioGroup } from \"./RadioGroup.vue\";\
|
|
19
|
+
"content": "export { default as RadioGroup } from \"./RadioGroup.vue\";\n"
|
|
26
20
|
}
|
|
27
21
|
]
|
|
28
22
|
}
|
|
@@ -2,11 +2,29 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
3
3
|
"name": "tu-design",
|
|
4
4
|
"items": [
|
|
5
|
+
{
|
|
6
|
+
"name": "alert",
|
|
7
|
+
"title": "Alert",
|
|
8
|
+
"type": "registry:ui",
|
|
9
|
+
"description": "语义化警示条,支持五种变体、内置图标与可关闭交互。"
|
|
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
|
+
},
|
|
5
17
|
{
|
|
6
18
|
"name": "avatar",
|
|
7
19
|
"title": "Avatar",
|
|
8
20
|
"type": "registry:ui",
|
|
9
|
-
"description": "
|
|
21
|
+
"description": "头像,支持尺寸/形状、加载占位与失败回退(Ark UI)。"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "avatar-group",
|
|
25
|
+
"title": "AvatarGroup",
|
|
26
|
+
"type": "registry:ui",
|
|
27
|
+
"description": "头像组,数量折叠、悬停展开与垂直排列。"
|
|
10
28
|
},
|
|
11
29
|
{
|
|
12
30
|
"name": "badge",
|
|
@@ -20,11 +38,23 @@
|
|
|
20
38
|
"type": "registry:ui",
|
|
21
39
|
"description": "带变体与尺寸的按钮,支持 as 标签切换与 asChild 组合。"
|
|
22
40
|
},
|
|
41
|
+
{
|
|
42
|
+
"name": "calendar",
|
|
43
|
+
"title": "Calendar",
|
|
44
|
+
"type": "registry:ui",
|
|
45
|
+
"description": "日历(TCalendar):紧凑日历卡。Picker 弹层内为 embedded 内嵌形态(TDatePicker/TDateRangePicker 自动挂靠,纯卡片内核);独立使用即 standalone 独立形态(自带日历状态与 v-model,恒开展示)。"
|
|
46
|
+
},
|
|
23
47
|
{
|
|
24
48
|
"name": "card",
|
|
25
49
|
"title": "Card",
|
|
26
50
|
"type": "registry:ui",
|
|
27
|
-
"description": "
|
|
51
|
+
"description": "卡片容器:单组件 API,title/description 头部 + 命名插槽(cover/action/footer/header),支持尺寸、视觉变体、分段分隔与可关闭。"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "cascader",
|
|
55
|
+
"title": "Cascader",
|
|
56
|
+
"type": "registry:ui",
|
|
57
|
+
"description": "级联选择:一站式 props 驱动,多列联动、勾选级联、路径回显与多标签。"
|
|
28
58
|
},
|
|
29
59
|
{
|
|
30
60
|
"name": "checkbox",
|
|
@@ -32,23 +62,59 @@
|
|
|
32
62
|
"type": "registry:ui",
|
|
33
63
|
"description": "复选框:基于 Ark UI Checkbox 原语,支持标签插槽、受控/非受控与禁用。"
|
|
34
64
|
},
|
|
65
|
+
{
|
|
66
|
+
"name": "context-menu",
|
|
67
|
+
"title": "ContextMenu",
|
|
68
|
+
"type": "registry:ui",
|
|
69
|
+
"description": "右键菜单:单组件模式,items 描述菜单项(与 dropdown-menu 同构,含分组/标题/分隔线,支持嵌套),默认插槽为触发元素(ContextTrigger as-child,右键唤出并定位到指针处),内置键盘导航与选中回调。"
|
|
70
|
+
},
|
|
35
71
|
{
|
|
36
72
|
"name": "currency-input",
|
|
37
73
|
"title": "CurrencyInput",
|
|
38
74
|
"type": "registry:ui",
|
|
39
75
|
"description": "金额输入框:内置万/元/角/分单位后缀,labelUnit 输入单位与 valueUnit 存储单位自动换算(整数分最小精度),值以 number|null 受控。"
|
|
40
76
|
},
|
|
77
|
+
{
|
|
78
|
+
"name": "date-picker",
|
|
79
|
+
"title": "DatePicker",
|
|
80
|
+
"type": "registry:ui",
|
|
81
|
+
"description": "日期选择器:输入框 + 日历弹层(月/年视图切换),支持手动键入/清空/min-max 边界/不可选谓词,值以 \"yyyy-MM-dd\" 字符串受控。"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "date-range-picker",
|
|
85
|
+
"title": "DateRangePicker",
|
|
86
|
+
"type": "registry:ui",
|
|
87
|
+
"description": "日期范围选择器:双月日历弹层(月/年视图切换),点选起点与终点,值以 [\"yyyy-MM-dd\", \"yyyy-MM-dd\"] 有序元组受控,空值归一 null。"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "date-shared",
|
|
91
|
+
"title": "DateShared",
|
|
92
|
+
"type": "registry:ui",
|
|
93
|
+
"description": "日期家族共享模块:ISO 值域解析(日期/月/年/区间)与日历样式常量。"
|
|
94
|
+
},
|
|
41
95
|
{
|
|
42
96
|
"name": "dialog",
|
|
43
97
|
"title": "Dialog",
|
|
44
98
|
"type": "registry:ui",
|
|
45
|
-
"description": "
|
|
99
|
+
"description": "模态对话框单组件:#trigger 放触发元素,title/description 传文案,#footer 注入 close 关闭;基于 Ark UI Dialog 原语,含焦点圈定、Escape/遮罩关闭与进出场动画,支持 v-model:open。"
|
|
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。"
|
|
46
106
|
},
|
|
47
107
|
{
|
|
48
108
|
"name": "dropdown-menu",
|
|
49
109
|
"title": "DropdownMenu",
|
|
50
110
|
"type": "registry:ui",
|
|
51
|
-
"description": "
|
|
111
|
+
"description": "下拉菜单:单组件模式,items 描述菜单项(含分组/标题/分隔线,支持嵌套),内置键盘导航与选中回调,默认插槽为触发元素(asChild 透传)。"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "empty",
|
|
115
|
+
"title": "Empty",
|
|
116
|
+
"type": "registry:ui",
|
|
117
|
+
"description": "空状态占位,含默认插画与描述文案。"
|
|
52
118
|
},
|
|
53
119
|
{
|
|
54
120
|
"name": "form",
|
|
@@ -56,6 +122,12 @@
|
|
|
56
122
|
"type": "registry:ui",
|
|
57
123
|
"description": "表单状态与校验:基于 TanStack Form,配合 Valibot(Standard Schema)声明式校验,aria 自动接线。"
|
|
58
124
|
},
|
|
125
|
+
{
|
|
126
|
+
"name": "form-render",
|
|
127
|
+
"title": "FormRender",
|
|
128
|
+
"type": "registry:ui",
|
|
129
|
+
"description": "配置驱动表单渲染器:defineForm 聚合 TanStack Form 实例与字段配置,柯里化 widget DSL 声明控件,Tailwind 栅格自适应布局,复用 Form 家族 aria 接线。"
|
|
130
|
+
},
|
|
59
131
|
{
|
|
60
132
|
"name": "input",
|
|
61
133
|
"title": "Input",
|
|
@@ -68,6 +140,12 @@
|
|
|
68
140
|
"type": "registry:ui",
|
|
69
141
|
"description": "表单标签。"
|
|
70
142
|
},
|
|
143
|
+
{
|
|
144
|
+
"name": "month-picker",
|
|
145
|
+
"title": "MonthPicker",
|
|
146
|
+
"type": "registry:ui",
|
|
147
|
+
"description": "月份选择器:输入框 + 锁定月视图的日历弹层,值以 \"yyyy-MM\" 字符串受控,min/max 为月粒度闭区间(内部换算到当月末日)。"
|
|
148
|
+
},
|
|
71
149
|
{
|
|
72
150
|
"name": "number-input",
|
|
73
151
|
"title": "NumberInput",
|
|
@@ -86,11 +164,23 @@
|
|
|
86
164
|
"type": "registry:ui",
|
|
87
165
|
"description": "多格验证码输入:length 指定格数,支持 otp/mask/字符类型、焦点自动跳格与填满回调,可选分隔符插槽。"
|
|
88
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
|
+
},
|
|
89
173
|
{
|
|
90
174
|
"name": "popover",
|
|
91
175
|
"title": "Popover",
|
|
92
176
|
"type": "registry:ui",
|
|
93
|
-
"description": "气泡弹层:基于 Ark UI Popover
|
|
177
|
+
"description": "气泡弹层:基于 Ark UI Popover 原语的单组件,默认插槽为触发元素本体(asChild 语义),面板内容放 #content 插槽,受控/非受控开关。"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "progress",
|
|
181
|
+
"title": "Progress",
|
|
182
|
+
"type": "registry:ui",
|
|
183
|
+
"description": "进度条:基于 Ark UI Progress 原语,支持语义色、标签与百分比显示、不确定态。"
|
|
94
184
|
},
|
|
95
185
|
{
|
|
96
186
|
"name": "radio-group",
|
|
@@ -102,7 +192,7 @@
|
|
|
102
192
|
"name": "select",
|
|
103
193
|
"title": "Select",
|
|
104
194
|
"type": "registry:ui",
|
|
105
|
-
"description": "
|
|
195
|
+
"description": "下拉选择框:单组件 API,传入 items 数据驱动渲染,内置触发器回显、键盘导航与勾选指示,支持 #item 插槽自定义选项。"
|
|
106
196
|
},
|
|
107
197
|
{
|
|
108
198
|
"name": "separator",
|
|
@@ -128,12 +218,24 @@
|
|
|
128
218
|
"type": "registry:ui",
|
|
129
219
|
"description": "asChild 组合原语:将组件的 class 与 attrs 合并到子元素上,而不渲染额外 DOM。"
|
|
130
220
|
},
|
|
221
|
+
{
|
|
222
|
+
"name": "spin",
|
|
223
|
+
"title": "Spin",
|
|
224
|
+
"type": "registry:ui",
|
|
225
|
+
"description": "加载中旋转指示器,支持独立 spinner 与包裹内容(半透明遮罩)两种形态。"
|
|
226
|
+
},
|
|
131
227
|
{
|
|
132
228
|
"name": "switch",
|
|
133
229
|
"title": "Switch",
|
|
134
230
|
"type": "registry:ui",
|
|
135
231
|
"description": "开关:基于 Ark UI Switch 原语,支持标签插槽、受控/非受控与禁用。"
|
|
136
232
|
},
|
|
233
|
+
{
|
|
234
|
+
"name": "table-render",
|
|
235
|
+
"title": "TableRender",
|
|
236
|
+
"type": "registry:ui",
|
|
237
|
+
"description": "配置驱动表格渲染器:defineTable 聚合 TanStack Table 实例与列配置,静态/服务端双模式(onLoad 回写分页排序),搜索表单联动(search 接 FormRender),左右固定列 sticky 横向滚动,表体虚拟滚动(virtual + height,TanStack Virtual 动态测量行高),树形数据(tree:子行展开/收起、depth 缩进、caret 位于首列),列显隐(columnSettings 面板 + visibleKeys 受控),错误态占位与重试(#error 插槽 + load-error),ellipsis 支持 tooltip 形态,v-model 受控(pageIndex/pageSize/sort/selectedKeys),Ark Pagination 分页条 + 原生 select 每页条数,排序表头 aria-sort、加载骨架与空态插槽,语义化 table + Tailwind tokens。"
|
|
238
|
+
},
|
|
137
239
|
{
|
|
138
240
|
"name": "tabs",
|
|
139
241
|
"title": "Tabs",
|
|
@@ -146,6 +248,12 @@
|
|
|
146
248
|
"type": "registry:ui",
|
|
147
249
|
"description": "多行文本输入:纯样式封装,支持 invalid 校验态。"
|
|
148
250
|
},
|
|
251
|
+
{
|
|
252
|
+
"name": "toast",
|
|
253
|
+
"title": "Toast",
|
|
254
|
+
"type": "registry:ui",
|
|
255
|
+
"description": "全局轻提示:ToastProvider 在应用根部挂载一次,useToast() 提供命令式 API(success/error/info/warning/loading/promise/dismiss);基于 Ark UI Toast 原语,语义 type 映射主题 token 配色。"
|
|
256
|
+
},
|
|
149
257
|
{
|
|
150
258
|
"name": "tokens",
|
|
151
259
|
"title": "Tokens",
|
|
@@ -158,11 +266,35 @@
|
|
|
158
266
|
"type": "registry:ui",
|
|
159
267
|
"description": "文字提示气泡:悬停触发,基于 Ark UI Tooltip 原语,支持 asChild 与延迟配置。"
|
|
160
268
|
},
|
|
269
|
+
{
|
|
270
|
+
"name": "tree-select",
|
|
271
|
+
"title": "TreeSelect",
|
|
272
|
+
"type": "registry:ui",
|
|
273
|
+
"description": "树形下拉选择:一站式 props 驱动,支持单/多选、勾选级联、过滤与多标签折叠。"
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
"name": "tree-shared",
|
|
277
|
+
"title": "TreeShared",
|
|
278
|
+
"type": "registry:ui",
|
|
279
|
+
"description": "树形数据层与共享类型(移植自 treemate v0.3.11,MIT)。"
|
|
280
|
+
},
|
|
161
281
|
{
|
|
162
282
|
"name": "utils",
|
|
163
283
|
"title": "Utils",
|
|
164
284
|
"type": "registry:lib",
|
|
165
285
|
"description": "cn 类名合并工具(clsx + tailwind-merge)。"
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
"name": "week-picker",
|
|
289
|
+
"title": "WeekPicker",
|
|
290
|
+
"type": "registry:ui",
|
|
291
|
+
"description": "周选择器:输入框 + 日历弹层,点任意可选日归一到所在周并整周高亮,值以 \"yyyy-MM-dd\"(所在周起始日)字符串受控;周起点跟随 locale(zh-CN 周一起始),输入框回显 \"start ~ end\"。"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"name": "year-picker",
|
|
295
|
+
"title": "YearPicker",
|
|
296
|
+
"type": "registry:ui",
|
|
297
|
+
"description": "年份选择器:输入框 + 锁定年视图的日历弹层(decade 网格),值以 \"yyyy\" 字符串受控,min/max 为年粒度闭区间。"
|
|
166
298
|
}
|
|
167
299
|
]
|
|
168
300
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "select",
|
|
4
4
|
"type": "registry:ui",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "下拉选择框:单组件 API,传入 items 数据驱动渲染,内置触发器回显、键盘导航与勾选指示,支持 #item 插槽自定义选项。",
|
|
6
6
|
"registryDependencies": ["utils"],
|
|
7
7
|
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
8
|
"files": [
|
|
@@ -10,37 +10,13 @@
|
|
|
10
10
|
"path": "select/Select.vue",
|
|
11
11
|
"type": "registry:component",
|
|
12
12
|
"target": "components/ui/select/Select.vue",
|
|
13
|
-
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { createListCollection } from \"@ark-ui/vue/collection\";\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\nimport
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"path": "select/SelectContent.vue",
|
|
17
|
-
"type": "registry:component",
|
|
18
|
-
"target": "components/ui/select/SelectContent.vue",
|
|
19
|
-
"content": "<script setup lang=\"ts\">\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n class?: string;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<template>\n <ArkSelect.Positioner class=\"z-50\">\n <ArkSelect.Content\n :class=\"\n cn(\n 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md',\n props.class,\n )\n \"\n >\n <slot />\n </ArkSelect.Content>\n </ArkSelect.Positioner>\n</template>\n"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"path": "select/SelectItem.vue",
|
|
23
|
-
"type": "registry:component",
|
|
24
|
-
"target": "components/ui/select/SelectItem.vue",
|
|
25
|
-
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed } from \"vue\";\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\nimport { cn } from \"@/lib/utils\";\nimport { normalizeSelectItem, type SelectItemOption } from \"./types\";\n\ninterface Props {\n /** 选项(与 TSelect 的 items 中对应项一致,或直接传字符串) */\n item: string | SelectItemOption;\n class?: string;\n}\n\nconst props = defineProps({\n item: {\n type: [String, Object] as PropType<string | SelectItemOption>,\n required: true,\n },\n class: { type: String, default: undefined },\n});\n\nconst normalized = computed(() => normalizeSelectItem(props.item));\n</script>\n\n<template>\n <ArkSelect.Item\n :item=\"normalized\"\n :class=\"\n cn(\n 'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n props.class,\n )\n \"\n >\n <ArkSelect.ItemText>{{ normalized.label }}</ArkSelect.ItemText>\n <ArkSelect.ItemIndicator class=\"absolute right-2\">\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=\"M20 6 9 17l-5-5\" />\n </svg>\n </ArkSelect.ItemIndicator>\n </ArkSelect.Item>\n</template>\n"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"path": "select/SelectTrigger.vue",
|
|
29
|
-
"type": "registry:component",
|
|
30
|
-
"target": "components/ui/select/SelectTrigger.vue",
|
|
31
|
-
"content": "<script setup lang=\"ts\">\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n /** 以默认插槽子元素为渲染目标(chevron 需自行放置) */\n asChild?: boolean;\n class?: string;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<template>\n <ArkSelect.Control class=\"w-fit\">\n <ArkSelect.Trigger\n :as-child=\"props.asChild\"\n :class=\"\n cn(\n 'border-input data-[placeholder]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4',\n props.class,\n )\n \"\n >\n <slot />\n <svg\n v-if=\"!props.asChild\"\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 opacity-50\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </ArkSelect.Trigger>\n </ArkSelect.Control>\n</template>\n"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"path": "select/SelectValueText.vue",
|
|
35
|
-
"type": "registry:component",
|
|
36
|
-
"target": "components/ui/select/SelectValueText.vue",
|
|
37
|
-
"content": "<script setup lang=\"ts\">\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\n\ninterface Props {\n placeholder?: string;\n}\n\nconst props = defineProps<Props>();\n</script>\n\n<!-- 注意:不能向 ValueText 传插槽内容,其内部会对默认插槽做字符串化渲染 -->\n<template>\n <ArkSelect.ValueText :placeholder=\"props.placeholder\" />\n</template>\n"
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { createListCollection } from \"@ark-ui/vue/collection\";\nimport { Select as ArkSelect } from \"@ark-ui/vue/select\";\nimport { cn } from \"@/lib/utils\";\nimport { normalizeSelectItem, type SelectItemOption } from \"./types\";\n\n// modelValue 为 String 类型无 Boolean casting 问题;「未传」经 default: undefined 保持 undefined\nconst props = defineProps({\n /** 选项列表:字符串(label = value)或 { label, value, disabled? } */\n items: { type: Array as PropType<(string | SelectItemOption)[]>, required: true },\n /** 当前值(配合 v-model);不传时为非受控 */\n modelValue: { type: String as PropType<string | undefined>, default: undefined },\n defaultValue: { type: String, default: undefined },\n /** 弹层开合受控;undefined 走内部非受控(default: undefined 禁用 Boolean casting) */\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n defaultOpen: { type: Boolean, default: false },\n /** 未选中时触发器显示的占位文案 */\n placeholder: { type: String, default: \"请选择\" },\n /** 透传合并到触发器(Trigger)的 class */\n triggerClass: { type: String, default: undefined },\n /** 透传合并到弹层(Content)的 class */\n contentClass: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n \"update:open\": [open: boolean];\n}>();\n\n// zag select 的 value 内部统一为数组,这里保持单选 string 的公开语义\nconst toArray = (v: string | undefined) => (v === undefined ? undefined : [v]);\n\n// 对 Root 恒走受控模式(DatePicker 同款):非受控语义由内部 ref 实现\nconst internalValue = ref<string | undefined>(props.defaultValue);\nconst modelValue = computed(() => props.modelValue ?? internalValue.value);\n\n// 一次归一化(string → { label, value }),v-for 与 #item 插槽作用域共用\nconst normalizedItems = computed(() =>\n props.items.map((raw) => ({ raw, item: normalizeSelectItem(raw) })),\n);\n\nconst collection = computed(() =>\n createListCollection({\n items: normalizedItems.value.map((entry) => entry.item),\n isItemDisabled: (item) => item.disabled === true,\n }),\n);\n\nfunction handleModelUpdate(next: string | string[]) {\n const value = Array.isArray(next) ? next[0]! : next;\n internalValue.value = value;\n emit(\"update:modelValue\", value);\n}\n\nconst internalOpen = ref(props.defaultOpen);\nconst isOpen = computed(() => props.open ?? internalOpen.value);\n\nfunction handleOpenUpdate(open: boolean) {\n internalOpen.value = open;\n emit(\"update:open\", open);\n}\n</script>\n\n<template>\n <ArkSelect.Root\n :collection=\"collection\"\n :model-value=\"toArray(modelValue)\"\n :open=\"isOpen\"\n @update:model-value=\"handleModelUpdate\"\n @update:open=\"handleOpenUpdate\"\n >\n <!-- 触发器(收编自 SelectTrigger:内置选中回显与 chevron) -->\n <ArkSelect.Control class=\"w-fit\">\n <ArkSelect.Trigger\n :class=\"\n cn(\n 'border-input data-[placeholder]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:shrink-0 [&_svg:not([class*=size-])]:size-4',\n props.triggerClass,\n )\n \"\n >\n <!-- 注意:不能向 ValueText 传插槽内容,其内部会对默认插槽做字符串化渲染 -->\n <ArkSelect.ValueText :placeholder=\"props.placeholder\" />\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 opacity-50\"\n >\n <path d=\"m6 9 6 6 6-6\" />\n </svg>\n </ArkSelect.Trigger>\n </ArkSelect.Control>\n\n <ArkSelect.Positioner class=\"z-50\">\n <ArkSelect.Content\n :class=\"\n cn(\n 'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md',\n props.contentClass,\n )\n \"\n >\n <ArkSelect.Item\n v-for=\"entry in normalizedItems\"\n :key=\"entry.item.value\"\n :item=\"entry.item\"\n class=\"data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50\"\n >\n <slot\n name=\"item\"\n :item=\"entry.raw\"\n :label=\"entry.item.label\"\n :selected=\"entry.item.value === modelValue\"\n >\n <ArkSelect.ItemText>{{ entry.item.label }}</ArkSelect.ItemText>\n <ArkSelect.ItemIndicator class=\"absolute right-2\">\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=\"M20 6 9 17l-5-5\" />\n </svg>\n </ArkSelect.ItemIndicator>\n </slot>\n </ArkSelect.Item>\n </ArkSelect.Content>\n </ArkSelect.Positioner>\n </ArkSelect.Root>\n</template>\n"
|
|
38
14
|
},
|
|
39
15
|
{
|
|
40
16
|
"path": "select/index.ts",
|
|
41
17
|
"type": "registry:component",
|
|
42
18
|
"target": "components/ui/select/index.ts",
|
|
43
|
-
"content": "export { default as Select } from \"./Select.vue\";\nexport
|
|
19
|
+
"content": "export { default as Select } from \"./Select.vue\";\nexport type { SelectItemOption } from \"./types\";\n"
|
|
44
20
|
},
|
|
45
21
|
{
|
|
46
22
|
"path": "select/types.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"path": "slider/Slider.vue",
|
|
11
11
|
"type": "registry:component",
|
|
12
12
|
"target": "components/ui/slider/Slider.vue",
|
|
13
|
-
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed } from \"vue\";\nimport { Slider as ArkSlider } from \"@ark-ui/vue/slider\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed } from \"vue\";\nimport { Slider as ArkSlider } from \"@ark-ui/vue/slider\";\nimport { cn } from \"@/lib/utils\";\n\ninterface Props {\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n class?: string;\n}\n\nconst props = withDefaults(\n defineProps<{\n /** 当前值(配合 v-model);单值或区间数组,不传时为非受控。出参恒为 number[] */\n modelValue?: number | number[];\n /** 同 modelValue(兼容别名,v-model 场景请直接用 modelValue) */\n value?: number | number[];\n defaultValue?: number | number[];\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n class?: string;\n }>(),\n { min: 0, max: 100, step: 1 },\n);\n\nconst emit = defineEmits<{ \"update:modelValue\": [value: number[]] }>();\n\nconst toArray = (v: number | number[] | undefined) =>\n v === undefined ? undefined : Array.isArray(v) ? v : [v];\n\n// modelValue 未传时回落 value(兼容别名);都未传走非受控(defaultValue/内部状态)\nconst thumbs = computed(\n () =>\n toArray(props.modelValue) ?? toArray(props.value) ?? toArray(props.defaultValue) ?? [props.min],\n);\n</script>\n\n<template>\n <ArkSlider.Root\n :model-value=\"toArray(props.modelValue) ?? toArray(props.value)\"\n :default-value=\"toArray(props.defaultValue)\"\n :min=\"props.min\"\n :max=\"props.max\"\n :step=\"props.step\"\n :disabled=\"props.disabled\"\n :class=\"\n cn(\n 'relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50',\n props.class,\n )\n \"\n @update:model-value=\"(value: number[]) => emit('update:modelValue', value)\"\n >\n <ArkSlider.Control class=\"relative flex h-5 w-full items-center\">\n <ArkSlider.Track class=\"bg-muted relative h-1 w-full grow overflow-hidden rounded-full\">\n <ArkSlider.Range class=\"bg-primary absolute h-full\" />\n </ArkSlider.Track>\n <ArkSlider.Thumb\n v-for=\"(_, index) in thumbs\"\n :key=\"index\"\n :index=\"index\"\n class=\"border-primary bg-background ring-ring/50 block size-4 shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50\"\n >\n <ArkSlider.HiddenInput />\n </ArkSlider.Thumb>\n </ArkSlider.Control>\n </ArkSlider.Root>\n</template>\n"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "slider/index.ts",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "spin",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "加载中旋转指示器,支持独立 spinner 与包裹内容(半透明遮罩)两种形态。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["class-variance-authority@^0.7.1"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "spin/Spin.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/spin/Spin.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport { cva } from \"class-variance-authority\";\nimport { computed, useSlots } from \"vue\";\nimport { cn } from \"@/lib/utils\";\n\nconst props = withDefaults(\n defineProps<{\n /** spinner 尺寸 */\n size?: \"sm\" | \"default\" | \"lg\";\n /** 是否处于加载中 */\n spinning?: boolean;\n /** 无障碍标签(role=\"status\" 的 aria-label) */\n label?: string;\n class?: string;\n }>(),\n {\n size: \"default\",\n spinning: true,\n label: \"加载中\",\n },\n);\n\nconst spinVariants = cva(\"text-primary\", {\n variants: {\n size: {\n sm: \"size-4\",\n default: \"size-6\",\n lg: \"size-8\",\n },\n },\n defaultVariants: {\n size: \"default\",\n },\n});\n\n// aria-busy + aria-label 只挂在 role=\"status\" 状态元素上(避免根/状态元素双重播报);\n// 包裹态(默认插槽有内容)渲染内容 + 半透明遮罩,独立态仅渲染 spinner;\n// 包裹态 spinning 时根元素置 inert,阻止被遮罩内容聚焦/交互\nconst slots = useSlots();\nconst hasContent = computed(() => !!slots.default);\n</script>\n\n<template>\n <div\n v-if=\"hasContent || spinning\"\n :class=\"cn(hasContent ? 'relative' : 'inline-flex', props.class)\"\n :inert=\"hasContent && spinning\"\n >\n <slot v-if=\"hasContent\" />\n\n <div\n v-if=\"spinning\"\n role=\"status\"\n :aria-busy=\"spinning\"\n :aria-label=\"label\"\n :class=\"\n hasContent\n ? 'absolute inset-0 z-10 flex items-center justify-center rounded-[inherit] bg-background/60'\n : 'flex'\n \"\n >\n <svg\n :class=\"cn('animate-spin', spinVariants({ size }))\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"3\" class=\"opacity-25\" />\n <path\n d=\"M22 12a10 10 0 0 0-10-10\"\n stroke=\"currentColor\"\n stroke-width=\"3\"\n stroke-linecap=\"round\"\n />\n </svg>\n </div>\n </div>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "spin/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/spin/index.ts",
|
|
19
|
+
"content": "export { default as Spin } from \"./Spin.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|