@tu-design/vue 0.2.0 → 0.2.2
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 +1015 -330
- package/dist/index.mjs +874 -44
- package/dist/registry/vue/currency-input.json +27 -0
- package/dist/registry/vue/form.json +70 -0
- package/dist/registry/vue/input.json +2 -2
- package/dist/registry/vue/number-input.json +28 -0
- package/dist/registry/vue/password-input.json +21 -0
- package/dist/registry/vue/pin-input.json +22 -0
- package/dist/registry/vue/popover.json +34 -0
- package/dist/registry/vue/registry.json +43 -1
- package/dist/registry/vue/textarea.json +21 -0
- package/package.json +4 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "currency-input",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "金额输入框:内置万/元/角/分单位后缀,labelUnit 输入单位与 valueUnit 存储单位自动换算(整数分最小精度),值以 number|null 受控。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"path": "currency-input/CurrencyInput.vue",
|
|
10
|
+
"type": "registry:component",
|
|
11
|
+
"target": "components/ui/currency-input/CurrencyInput.vue",
|
|
12
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref, watch } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { formatCurrency, parseCurrency, type CurrencyUnit } from \"./utils\";\n\nconst props = defineProps({\n /** 受控值(valueUnit 单位);undefined 走内部非受控,null 表示空 */\n modelValue: { type: Number as PropType<number | null | undefined>, default: undefined },\n /** 界面输入单位 */\n labelUnit: { type: String as PropType<CurrencyUnit>, default: \"元\" },\n /** 存储单位(v-model 值的单位) */\n valueUnit: { type: String as PropType<CurrencyUnit>, default: \"元\" },\n placeholder: { type: String, default: undefined },\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n invalid: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: number | null];\n}>();\n\n// attrs(id/aria-*)转发给内部 input,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\n// 纯原生实现:金额换算为十进制字符串移位(整数分精度),无需 ark/zag 原语\nconst internalValue = ref<number | null>(null);\nconst isControlled = computed(() => props.modelValue !== undefined);\n\n// 输入框保留用户键入原文;仅外部 modelValue 变化(非本次 emit 回流)才反算回显\nconst display = ref(\n props.modelValue !== undefined && props.modelValue !== null\n ? formatCurrency(props.modelValue, props.valueUnit, props.labelUnit)\n : \"\",\n);\nlet lastEmitted: number | null | undefined;\n\nfunction onInput(event: Event) {\n const raw = (event.target as HTMLInputElement).value;\n display.value = raw;\n const next = parseCurrency(raw, props.labelUnit, props.valueUnit);\n lastEmitted = next;\n if (!isControlled.value) internalValue.value = next;\n emit(\"update:modelValue\", next);\n}\n\nwatch(\n () => props.modelValue,\n (value) => {\n if (!isControlled.value || value === lastEmitted) return;\n display.value = value === null ? \"\" : formatCurrency(value, props.valueUnit, props.labelUnit);\n },\n);\n</script>\n\n<template>\n <div\n :class=\"\n cn(\n 'border-input flex h-9 w-full items-center overflow-hidden rounded-md border shadow-sm transition-[color,box-shadow] outline-none focus-within:border-ring focus-within:ring-ring/20 focus-within:ring-[3px] data-invalid:border-destructive data-invalid:ring-destructive/20 data-invalid:ring-[3px]',\n props.class,\n )\n \"\n :data-invalid=\"props.invalid ? '' : undefined\"\n >\n <input\n v-bind=\"$attrs\"\n type=\"text\"\n inputmode=\"decimal\"\n :value=\"display\"\n :placeholder=\"props.placeholder\"\n :disabled=\"props.disabled\"\n :aria-invalid=\"props.invalid || undefined\"\n :class=\"'bg-transparent h-full w-full min-w-0 flex-1 px-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50'\"\n @input=\"onInput\"\n />\n <div\n aria-hidden=\"true\"\n :class=\"\n cn(\n 'border-input text-muted-foreground flex h-full shrink-0 items-center border-l bg-muted/40 px-3 text-sm',\n props.disabled && 'opacity-50',\n )\n \"\n >\n {{ props.labelUnit }}\n </div>\n </div>\n</template>\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "currency-input/index.ts",
|
|
16
|
+
"type": "registry:component",
|
|
17
|
+
"target": "components/ui/currency-input/index.ts",
|
|
18
|
+
"content": "export { default as CurrencyInput } from \"./CurrencyInput.vue\";\nexport { formatCurrency, parseCurrency, type CurrencyUnit } from \"./utils\";\n"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"path": "currency-input/utils.ts",
|
|
22
|
+
"type": "registry:component",
|
|
23
|
+
"target": "components/ui/currency-input/utils.ts",
|
|
24
|
+
"content": "/** 货币单位:万/元/角/分(组件枚举固定,换算基准为整数分) */\nexport type CurrencyUnit = \"万\" | \"元\" | \"角\" | \"分\";\n\n/** 各单位折合整数分:分=1、角=10、元=100、万=1000000 */\nconst UNIT_FEN_EXP: Record<CurrencyUnit, number> = { 万: 6, 元: 2, 角: 1, 分: 0 };\n\n/**\n * 解析输入文本为 valueUnit 单位的数值(number|null)。\n * 全程十进制字符串移位(BigInt),仅在超出整数分精度时一次四舍五入;\n * 白名单 ^\\d*(\\.\\d*)?$,负号/非法字符/无数字一律 null。\n */\nexport function parseCurrency(\n raw: string,\n labelUnit: CurrencyUnit,\n valueUnit: CurrencyUnit,\n): number | null {\n if (!/^\\d*(\\.\\d*)?$/.test(raw) || !/\\d/.test(raw)) return null;\n const [intPart, fracPart = \"\"] = raw.split(\".\");\n const digits = BigInt((intPart || \"0\") + fracPart);\n const shift = UNIT_FEN_EXP[labelUnit] - fracPart.length;\n let fen: bigint;\n if (shift >= 0) {\n fen = digits * 10n ** BigInt(shift);\n } else {\n const divisor = 10n ** BigInt(-shift);\n const q = digits / divisor;\n const r = digits % divisor;\n fen = r * 2n >= divisor ? q + 1n : q;\n }\n return Number(fen) / 10 ** UNIT_FEN_EXP[valueUnit];\n}\n\n/**\n * 受控值(valueUnit 单位)反算为 labelUnit 单位的回显文本。\n * 值先取整到整数分(吸收浮点噪声),再做十进制移位并去尾零。\n */\nexport function formatCurrency(\n value: number,\n valueUnit: CurrencyUnit,\n labelUnit: CurrencyUnit,\n): string {\n if (!Number.isFinite(value)) return \"\";\n const negative = value < 0;\n const fen = BigInt(Math.abs(Math.round(value * 10 ** UNIT_FEN_EXP[valueUnit])));\n const exp = UNIT_FEN_EXP[labelUnit];\n let text: string;\n if (exp === 0) {\n text = fen.toString();\n } else {\n const s = fen.toString().padStart(exp + 1, \"0\");\n const frac = s.slice(-exp).replace(/0+$/, \"\");\n text = frac ? `${s.slice(0, -exp)}.${frac}` : s.slice(0, -exp);\n }\n return negative ? `-${text}` : text;\n}\n"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "form",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "表单状态与校验:基于 TanStack Form,配合 Valibot(Standard Schema)声明式校验,aria 自动接线。",
|
|
6
|
+
"registryDependencies": ["utils", "input", "button", "label"],
|
|
7
|
+
"dependencies": ["@tanstack/vue-form@^1.33.5", "valibot@^1.5.0"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "form/Form.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/form/Form.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport { provide } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { FORM_KEY, type FormInstance } from \"./context\";\n\nconst props = defineProps<{\n /** useForm() 返回的实例 */\n form: FormInstance;\n class?: string;\n}>();\n\nprovide(FORM_KEY, props.form);\n</script>\n\n<template>\n <form\n novalidate\n :class=\"cn('flex flex-col gap-4', props.class)\"\n @submit.prevent=\"props.form.handleSubmit()\"\n >\n <slot />\n </form>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "form/FormControl.vue",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/form/FormControl.vue",
|
|
19
|
+
"content": "<script lang=\"ts\">\nimport { cloneVNode, computed, defineComponent, inject } from \"vue\";\nimport { FIELD_KEY, FORM_ITEM_KEY } from \"./context\";\n\n/**\n * 把 id / aria-invalid / aria-describedby 合并到唯一子元素(cloneVNode)。\n * aria 全同步计算:description/message 的 presence 由 FormItem 的 refs 提供。\n */\nexport default defineComponent({\n name: \"TuFormControl\",\n props: {\n class: { type: String, default: undefined },\n },\n setup(props, { slots }) {\n const fieldCtx = inject(FIELD_KEY, undefined);\n const itemCtx = inject(FORM_ITEM_KEY, undefined);\n\n if (import.meta.env.DEV && (!fieldCtx || !itemCtx)) {\n console.warn(\"[tu-design] <FormControl> 必须在 <FormField> + <FormItem> 内使用\");\n }\n\n const isInvalid = computed(() => (fieldCtx?.field.value?.state.meta.errors.length ?? 0) > 0);\n const describedBy = computed(() => {\n if (!itemCtx) return undefined;\n const ids = [\n itemCtx.hasDescription.value && itemCtx.descriptionId,\n itemCtx.hasMessage.value && itemCtx.isInvalid.value && itemCtx.messageId,\n ].filter(Boolean);\n return ids.length > 0 ? ids.join(\" \") : undefined;\n });\n\n return () => {\n const vnodes = slots.default?.() ?? [];\n if (import.meta.env.DEV && vnodes.length !== 1) {\n console.warn(\"[tu-design] <FormControl> 需要且仅需要一个子元素\");\n }\n const first = vnodes[0];\n if (!first) return null;\n return cloneVNode(first, {\n id: itemCtx?.controlId,\n \"aria-invalid\": isInvalid.value || undefined,\n \"aria-describedby\": describedBy.value,\n class: props.class,\n });\n };\n },\n});\n</script>\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "form/FormDescription.vue",
|
|
23
|
+
"type": "registry:component",
|
|
24
|
+
"target": "components/ui/form/FormDescription.vue",
|
|
25
|
+
"content": "<script setup lang=\"ts\">\nimport { inject, onMounted, onUnmounted } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { FORM_ITEM_KEY } from \"./context\";\n\nconst itemCtx = inject(FORM_ITEM_KEY, undefined);\nconst props = defineProps<{ class?: string }>();\n\nif (import.meta.env.DEV && !itemCtx) {\n console.warn(\"[tu-design] <FormDescription> 必须在 <FormField> + <FormItem> 内使用\");\n}\n\nonMounted(() => itemCtx && (itemCtx.hasDescription.value = true));\nonUnmounted(() => itemCtx && (itemCtx.hasDescription.value = false));\n</script>\n\n<template>\n <p :id=\"itemCtx?.descriptionId\" :class=\"cn('text-muted-foreground text-sm', props.class)\">\n <slot />\n </p>\n</template>\n"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "form/FormField.vue",
|
|
29
|
+
"type": "registry:component",
|
|
30
|
+
"target": "components/ui/form/FormField.vue",
|
|
31
|
+
"content": "<script lang=\"ts\">\nimport type { AnyFieldApi } from \"@tanstack/vue-form\";\nimport type { PropType } from \"vue\";\nimport { defineComponent, h, inject, provide, shallowRef } from \"vue\";\nimport { FIELD_KEY, FORM_KEY } from \"./context\";\n\n/**\n * 渲染 TanStack `form.Field` 并经 provide 下发 field 上下文。\n * field 实例只能在 form.Field 的插槽执行期取得(时序早于子组件 setup),\n * 故用 defineComponent + render function 在插槽回调中写入 ShallowRef。\n */\nexport default defineComponent({\n name: \"TuFormField\",\n props: {\n /** 字段名(TanStack 深层 key 的运行时形态) */\n name: { type: String, required: true },\n /** 校验器配置,原样透传(值可为函数或 Standard Schema,如 valibot) */\n validators: { type: Object as PropType<Record<string, unknown>>, default: undefined },\n },\n setup(props, { slots }) {\n const form = inject(FORM_KEY);\n if (!form && import.meta.env.DEV) {\n console.warn(\"[tu-design] <FormField> 必须在 <Form> 内使用\");\n }\n\n const fieldRef = shallowRef<AnyFieldApi>();\n provide(FIELD_KEY, { field: fieldRef, name: props.name });\n\n if (!form) {\n // 优雅降级:field 上下文缺席(FIELD_KEY.field 为 undefined),子组件需自行容忍\n return () => slots.default?.({ field: undefined as unknown as AnyFieldApi });\n }\n\n return () =>\n h(form.Field as never, { name: props.name, validators: props.validators } as never, {\n default: (slotProps: { field: AnyFieldApi }) => {\n fieldRef.value = slotProps.field;\n return slots.default?.(slotProps);\n },\n });\n },\n});\n</script>\n"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"path": "form/FormItem.vue",
|
|
35
|
+
"type": "registry:component",
|
|
36
|
+
"target": "components/ui/form/FormItem.vue",
|
|
37
|
+
"content": "<script setup lang=\"ts\">\nimport { computed, inject, provide, ref, useId } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { FIELD_KEY, FORM_ITEM_KEY, type FormItemContext } from \"./context\";\n\nconst fieldCtx = inject(FIELD_KEY)!;\n\nconst name = fieldCtx.name;\n// 实例级唯一 id 前缀:裸 name 会与同页其他表单的同名字段冲突(Vue 3.5 useId,SSR 稳定)\nconst controlId = `${useId()}-${name}`;\nconst descriptionId = `${controlId}-form-item-description`;\nconst messageId = `${controlId}-form-item-message`;\nconst hasDescription = ref(false);\nconst hasMessage = ref(false);\nconst isInvalid = computed(() => (fieldCtx.field.value?.state.meta.errors.length ?? 0) > 0);\n\nprovide(FORM_ITEM_KEY, {\n name,\n controlId,\n descriptionId,\n messageId,\n hasDescription,\n hasMessage,\n isInvalid,\n} satisfies FormItemContext);\n</script>\n\n<template>\n <div :class=\"cn('group flex flex-col gap-1.5')\" :data-invalid=\"isInvalid ? '' : undefined\">\n <slot />\n </div>\n</template>\n"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"path": "form/FormLabel.vue",
|
|
41
|
+
"type": "registry:component",
|
|
42
|
+
"target": "components/ui/form/FormLabel.vue",
|
|
43
|
+
"content": "<script setup lang=\"ts\">\nimport { computed, inject } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { FORM_ITEM_KEY } from \"./context\";\n\nconst itemCtx = inject(FORM_ITEM_KEY, undefined);\nconst props = defineProps<{ class?: string }>();\n\nif (import.meta.env.DEV && !itemCtx) {\n console.warn(\"[tu-design] <FormLabel> 必须在 <FormField> + <FormItem> 内使用\");\n}\n\nconst isInvalid = computed(() => itemCtx?.isInvalid.value ?? false);\n</script>\n\n<template>\n <label\n :for=\"itemCtx?.controlId\"\n :data-invalid=\"isInvalid ? '' : undefined\"\n :class=\"cn('text-sm font-medium leading-none data-invalid:text-destructive', props.class)\"\n >\n <slot />\n </label>\n</template>\n"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"path": "form/FormMessage.vue",
|
|
47
|
+
"type": "registry:component",
|
|
48
|
+
"target": "components/ui/form/FormMessage.vue",
|
|
49
|
+
"content": "<script setup lang=\"ts\">\nimport { computed, inject, onMounted, onUnmounted } from \"vue\";\nimport { cn } from \"@/lib/utils\";\nimport { FIELD_KEY, FORM_ITEM_KEY } from \"./context\";\n\nconst fieldCtx = inject(FIELD_KEY, undefined);\nconst itemCtx = inject(FORM_ITEM_KEY, undefined);\n\nconst props = defineProps<{\n /** 静态提示文案:传入后即使无校验错误也渲染(不走 aria-errormessage) */\n message?: string;\n class?: string;\n}>();\n\nif (import.meta.env.DEV && (!fieldCtx || !itemCtx)) {\n console.warn(\"[tu-design] <FormMessage> 必须在 <FormField> + <FormItem> 内使用\");\n}\n\nconst errorText = computed(() => {\n if (props.message) return props.message;\n const raw = fieldCtx?.field.value?.state.meta.errors[0];\n if (raw === undefined) return undefined;\n return typeof raw === \"string\" ? raw : raw?.message;\n});\n\nonMounted(() => itemCtx && (itemCtx.hasMessage.value = true));\nonUnmounted(() => itemCtx && (itemCtx.hasMessage.value = false));\n</script>\n\n<template>\n <p v-if=\"errorText\" :id=\"itemCtx?.messageId\" :class=\"cn('text-destructive text-sm', props.class)\">\n {{ errorText }}\n </p>\n</template>\n"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"path": "form/FormSubscribe.vue",
|
|
53
|
+
"type": "registry:component",
|
|
54
|
+
"target": "components/ui/form/FormSubscribe.vue",
|
|
55
|
+
"content": "<script setup lang=\"ts\">\nimport { inject } from \"vue\";\nimport { FORM_KEY } from \"./context\";\n\nconst form = inject(FORM_KEY, undefined);\n\nif (import.meta.env.DEV && !form) {\n console.warn(\"[tu-design] <FormSubscribe> 必须在 <Form> 内使用\");\n}\n</script>\n\n<template>\n <component v-if=\"form\" :is=\"form.Subscribe\">\n <template #default=\"state\">\n <slot :can-submit=\"state.canSubmit\" :is-submitting=\"state.isSubmitting\" />\n </template>\n </component>\n</template>\n"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"path": "form/context.ts",
|
|
59
|
+
"type": "registry:component",
|
|
60
|
+
"target": "components/ui/form/context.ts",
|
|
61
|
+
"content": "import type { AnyFieldApi, FormApi, VueFormApi } from \"@tanstack/vue-form\";\nimport type { ComputedRef, InjectionKey, Ref, ShallowRef } from \"vue\";\n\n/** useForm() 返回实例的宽松形态(provide/inject 边界会擦除泛型,any 化是契约) */\n/* prettier-ignore */\nexport type FormInstance =\n FormApi<any, any, any, any, any, any, any, any, any, any, any, any> &\n VueFormApi<any, any, any, any, any, any, any, any, any, any, any, any>;\n\n/** FormField 内部经 form.Field 插槽才能拿到 field 实例,用 ShallowRef 承载 provide 时序 */\nexport interface FieldContext {\n field: ShallowRef<AnyFieldApi | undefined>;\n name: string;\n}\n\n/** FormItem 提供给 FormLabel/FormControl/FormDescription/FormMessage 的静态 id 与 presence 上下文 */\nexport interface FormItemContext {\n name: string;\n /** 实例级唯一控件 id(useId 前缀 + 字段名),label/控件/aria 均由它派生 */\n controlId: string;\n descriptionId: string;\n messageId: string;\n hasDescription: Ref<boolean>;\n hasMessage: Ref<boolean>;\n isInvalid: ComputedRef<boolean>;\n}\n\nexport const FORM_KEY: InjectionKey<FormInstance> = Symbol(\"tu-form\");\nexport const FIELD_KEY: InjectionKey<FieldContext> = Symbol(\"tu-form-field\");\nexport const FORM_ITEM_KEY: InjectionKey<FormItemContext> = Symbol(\"tu-form-item\");\n"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"path": "form/index.ts",
|
|
65
|
+
"type": "registry:component",
|
|
66
|
+
"target": "components/ui/form/index.ts",
|
|
67
|
+
"content": "export { default as Form } from \"./Form.vue\";\nexport { default as FormControl } from \"./FormControl.vue\";\nexport { default as FormDescription } from \"./FormDescription.vue\";\nexport { default as FormField } from \"./FormField.vue\";\nexport { default as FormItem } from \"./FormItem.vue\";\nexport { default as FormLabel } from \"./FormLabel.vue\";\nexport { default as FormMessage } from \"./FormMessage.vue\";\nexport { default as FormSubscribe } from \"./FormSubscribe.vue\";\n"
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "input",
|
|
4
4
|
"type": "registry:ui",
|
|
5
|
-
"description": "文本输入框,支持 v-model
|
|
5
|
+
"description": "文本输入框,支持 v-model、attrs 透传与 invalid 校验态。",
|
|
6
6
|
"registryDependencies": ["utils"],
|
|
7
7
|
"files": [
|
|
8
8
|
{
|
|
9
9
|
"path": "input/Input.vue",
|
|
10
10
|
"type": "registry:component",
|
|
11
11
|
"target": "components/ui/input/Input.vue",
|
|
12
|
-
"content": "<script setup lang=\"ts\">\nimport { cn } from \"@/lib/utils\";\n\nconst modelValue = defineModel<string | number>();\nconst props = defineProps<{ class?: string }>();\n</script>\n\n<template>\n <input\n v-model=\"modelValue\"\n :class=\"\n cn(\n 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus-visible:
|
|
12
|
+
"content": "<script setup lang=\"ts\">\nimport { cn } from \"@/lib/utils\";\n\nconst modelValue = defineModel<string | number>();\nconst props = defineProps<{ class?: string; invalid?: boolean }>();\n</script>\n\n<template>\n <input\n v-model=\"modelValue\"\n :aria-invalid=\"props.invalid ? 'true' : undefined\"\n :class=\"\n cn(\n 'flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive',\n props.class,\n )\n \"\n />\n</template>\n"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"path": "input/index.ts",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "number-input",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "数字输入框:内置加减步进按钮与数值边界,值以 number|null 受控(空值归一 null),支持 Intl 数字格式化。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "number-input/NumberInput.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/number-input/NumberInput.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { NumberInput as ArkNumberInput } from \"@ark-ui/vue/number-input\";\nimport { cn } from \"@/lib/utils\";\nimport { numberOrNull } from \"./utils\";\n\nconst props = defineProps({\n /** 受控值:number 或 null(空);undefined 走内部非受控 */\n modelValue: { type: Number as PropType<number | null | undefined>, default: undefined },\n min: { type: Number, default: undefined },\n max: { type: Number, default: undefined },\n step: { type: Number, default: undefined },\n formatOptions: { type: Object as PropType<Intl.NumberFormatOptions>, default: undefined },\n // default: undefined 禁用 Boolean casting(Checkbox/Dialog 同款约定)\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n invalid: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{ \"update:modelValue\": [value: number | null] }>();\n\n// attrs(id/aria-*)转发给内部真实 input,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\n// 对 Ark Root 恒走受控模式,非受控语义由内部 ref 实现(Checkbox 同款)\nconst internalValue = ref<number | null>(null);\nconst current = computed(() =>\n props.modelValue === undefined ? internalValue.value : props.modelValue,\n);\n\n/** number → Ark 受控 string(null/NaN → 空串) */\nconst arkValue = computed(() =>\n current.value == null || Number.isNaN(current.value) ? \"\" : String(current.value),\n);\n\n/** Ark details(value: string / valueAsNumber: number)→ number|null(空串/NaN 归一 null) */\nfunction handleValueChange(details: { value: string; valueAsNumber: number }) {\n const next = numberOrNull(details);\n internalValue.value = next;\n emit(\"update:modelValue\", next);\n}\n</script>\n\n<template>\n <ArkNumberInput.Root\n :model-value=\"arkValue\"\n :min=\"props.min\"\n :max=\"props.max\"\n :step=\"props.step\"\n :format-options=\"props.formatOptions\"\n :disabled=\"props.disabled\"\n :invalid=\"props.invalid\"\n :class=\"\n cn(\n 'border-input flex h-9 items-stretch overflow-hidden rounded-md border shadow-sm transition-[color,box-shadow] outline-none data-invalid:border-destructive data-invalid:ring-destructive/20 data-invalid:ring-[3px]',\n props.class,\n )\n \"\n @value-change=\"handleValueChange\"\n >\n <ArkNumberInput.DecrementTrigger\n :class=\"'bg-muted/50 hover:bg-accent flex w-9 shrink-0 items-center justify-center border-r text-muted-foreground text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50'\"\n >\n <slot name=\"decrement\">\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 aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n </svg>\n </slot>\n </ArkNumberInput.DecrementTrigger>\n <ArkNumberInput.Input\n v-bind=\"$attrs\"\n :class=\"'bg-transparent flex-1 min-w-0 px-1 text-center text-sm outline-none disabled:cursor-not-allowed'\"\n />\n <ArkNumberInput.IncrementTrigger\n :class=\"'bg-muted/50 hover:bg-accent flex w-9 shrink-0 items-center justify-center border-l text-muted-foreground text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50'\"\n >\n <slot name=\"increment\">\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 aria-hidden=\"true\"\n >\n <path d=\"M5 12h14\" />\n <path d=\"M12 5v14\" />\n </svg>\n </slot>\n </ArkNumberInput.IncrementTrigger>\n </ArkNumberInput.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "number-input/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/number-input/index.ts",
|
|
19
|
+
"content": "export { default as NumberInput } from \"./NumberInput.vue\";\nexport { numberOrNull } from \"./utils\";\n"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "number-input/utils.ts",
|
|
23
|
+
"type": "registry:component",
|
|
24
|
+
"target": "components/ui/number-input/utils.ts",
|
|
25
|
+
"content": "/** Ark ValueChangeDetails → number|null(空串/NaN 归一 null,numberOrNull 为可单测的纯函数) */\nexport function numberOrNull(details: { value: string; valueAsNumber: number }): number | null {\n return details.value === \"\" || Number.isNaN(details.valueAsNumber) ? null : details.valueAsNumber;\n}\n"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "password-input",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "密码输入框:内置明文/掩码切换按钮(Eye/EyeOff,带 aria 语义),值与可见性均支持 v-model 受控。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"path": "password-input/PasswordInput.vue",
|
|
10
|
+
"type": "registry:component",
|
|
11
|
+
"target": "components/ui/password-input/PasswordInput.vue",
|
|
12
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { cn } from \"@/lib/utils\";\n\nconst props = defineProps({\n /** 受控值;undefined 走内部非受控 */\n modelValue: { type: String as PropType<string | undefined>, default: undefined },\n /** 明文显示;undefined 走内部非受控(默认隐藏) */\n // default: undefined 禁用 Boolean casting(Checkbox/Dialog 同款约定)\n visible: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n autoComplete: {\n type: String as PropType<\"current-password\" | \"new-password\">,\n default: \"current-password\",\n },\n placeholder: { type: String, default: undefined },\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n invalid: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string];\n \"update:visible\": [visible: boolean];\n}>();\n\n// attrs(id/aria-*)转发给内部 input,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\n// 纯原生实现:input type 切换即可,无需 zag/ark 原语\nconst internalValue = ref(\"\");\nconst current = computed(() => props.modelValue ?? internalValue.value);\n\nfunction onInput(event: Event) {\n const value = (event.target as HTMLInputElement).value;\n internalValue.value = value;\n emit(\"update:modelValue\", value);\n}\n\nconst internalVisible = ref(false);\nconst isVisible = computed(() => props.visible ?? internalVisible.value);\n\nfunction toggleVisible() {\n const next = !isVisible.value;\n internalVisible.value = next;\n emit(\"update:visible\", next);\n}\n</script>\n\n<template>\n <div\n :class=\"\n cn(\n 'border-input flex h-9 w-full items-center rounded-md border shadow-sm transition-[color,box-shadow] outline-none focus-within:border-ring focus-within:ring-ring/20 focus-within:ring-[3px] data-invalid:border-destructive data-invalid:ring-destructive/20 data-invalid:ring-[3px]',\n props.class,\n )\n \"\n :data-invalid=\"props.invalid ? '' : undefined\"\n >\n <input\n v-bind=\"$attrs\"\n :type=\"isVisible ? 'text' : 'password'\"\n :value=\"current\"\n :autocomplete=\"props.autoComplete\"\n :placeholder=\"props.placeholder\"\n :disabled=\"props.disabled\"\n :aria-invalid=\"props.invalid || undefined\"\n :class=\"'bg-transparent h-full w-full min-w-0 flex-1 rounded-md px-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50'\"\n @input=\"onInput\"\n />\n <button\n type=\"button\"\n :aria-label=\"isVisible ? '隐藏密码' : '显示密码'\"\n :aria-pressed=\"isVisible ? 'true' : 'false'\"\n :disabled=\"props.disabled\"\n :class=\"'hover:text-foreground mr-1 flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-sm text-muted-foreground outline-none disabled:cursor-not-allowed disabled:opacity-50'\"\n @click=\"toggleVisible\"\n >\n <!-- 可见时显示 EyeOff(点击隐藏),默认显示 Eye(点击查看) -->\n <slot name=\"visibility-icon\" :visible=\"isVisible\">\n <svg\n v-if=\"isVisible\"\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 aria-hidden=\"true\"\n >\n <path d=\"M9.88 9.88a3 3 0 1 0 4.24 4.24\" />\n <path d=\"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68\" />\n <path d=\"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61\" />\n <line x1=\"2\" x2=\"22\" y1=\"2\" y2=\"22\" />\n </svg>\n <svg\n v-else\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 aria-hidden=\"true\"\n >\n <path d=\"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z\" />\n <circle cx=\"12\" cy=\"12\" r=\"3\" />\n </svg>\n </slot>\n </button>\n </div>\n</template>\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "password-input/index.ts",
|
|
16
|
+
"type": "registry:component",
|
|
17
|
+
"target": "components/ui/password-input/index.ts",
|
|
18
|
+
"content": "export { default as PasswordInput } from \"./PasswordInput.vue\";\n"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "pin-input",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "多格验证码输入:length 指定格数,支持 otp/mask/字符类型、焦点自动跳格与填满回调,可选分隔符插槽。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "pin-input/PinInput.vue",
|
|
11
|
+
"type": "registry:component",
|
|
12
|
+
"target": "components/ui/pin-input/PinInput.vue",
|
|
13
|
+
"content": "<script setup lang=\"ts\">\nimport type { PropType } from \"vue\";\nimport { computed, ref } from \"vue\";\nimport { PinInput as ArkPinInput } from \"@ark-ui/vue/pin-input\";\nimport { cn } from \"@/lib/utils\";\n\nconst props = defineProps({\n /** 受控值:每格一个元素的数组;undefined 走内部非受控 */\n modelValue: {\n type: Array as PropType<string[] | undefined>,\n default: undefined,\n },\n /** 格数(默认 4) */\n length: { type: Number, default: 4 },\n /** 单格字符类型 */\n type: { type: String as PropType<\"numeric\" | \"alphanumeric\" | undefined>, default: undefined },\n // default: undefined 禁用 Boolean casting(Checkbox/Dialog 同款约定)\n otp: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n mask: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n autoSubmit: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n blurOnComplete: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n placeholder: { type: String, default: undefined },\n disabled: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n invalid: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n class: { type: String, default: undefined },\n});\n\nconst emit = defineEmits<{\n \"update:modelValue\": [value: string[]];\n complete: [value: string[]];\n}>();\n\n// attrs(id/aria-*)转发给首格 input,保证 TLabel/TFormControl 关联\ndefineOptions({ inheritAttrs: false });\n\n// 对 Ark Root 恒走受控模式,非受控语义由内部 ref 实现(Checkbox 同款)\nconst internalValue = ref<string[]>([]);\nconst current = computed(() =>\n props.modelValue === undefined ? internalValue.value : props.modelValue,\n);\n\nfunction handleValueChange(details: { value: string[] }) {\n internalValue.value = details.value;\n emit(\"update:modelValue\", details.value);\n}\n\nfunction handleValueComplete(details: { value: string[] }) {\n emit(\"complete\", details.value);\n}\n</script>\n\n<template>\n <ArkPinInput.Root\n :model-value=\"current\"\n :type=\"props.type\"\n :otp=\"props.otp\"\n :mask=\"props.mask\"\n :auto-submit=\"props.autoSubmit\"\n :blur-on-complete=\"props.blurOnComplete\"\n :placeholder=\"props.placeholder\"\n :disabled=\"props.disabled\"\n :invalid=\"props.invalid\"\n :class=\"cn('flex items-center gap-2', props.class)\"\n @value-change=\"handleValueChange\"\n @value-complete=\"handleValueComplete\"\n >\n <template v-for=\"i in props.length\" :key=\"i\">\n <ArkPinInput.Input\n v-bind=\"i === 1 ? $attrs : undefined\"\n :index=\"i - 1\"\n :class=\"'border-input bg-transparent h-9 w-9 rounded-md border text-center text-sm shadow-sm transition-[color,box-shadow] outline-none data-invalid:border-destructive data-invalid:ring-destructive/20 data-invalid:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50'\"\n />\n <slot v-if=\"i < props.length\" name=\"separator\" />\n </template>\n </ArkPinInput.Root>\n</template>\n"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"path": "pin-input/index.ts",
|
|
17
|
+
"type": "registry:component",
|
|
18
|
+
"target": "components/ui/pin-input/index.ts",
|
|
19
|
+
"content": "export { default as PinInput } from \"./PinInput.vue\";\n"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "popover",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "气泡弹层:基于 Ark UI Popover 原语,受控/非受控开关,Trigger 支持 asChild。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"dependencies": ["@ark-ui/vue@^5.39.2"],
|
|
8
|
+
"files": [
|
|
9
|
+
{
|
|
10
|
+
"path": "popover/Popover.vue",
|
|
11
|
+
"type": "registry:component",
|
|
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\";\n\ninterface Props {\n /** 受控开关(配合 v-model:open);不传时为非受控 */\n open?: boolean;\n defaultOpen?: boolean;\n lazyMount?: boolean;\n unmountOnExit?: boolean;\n}\n\n// open 用 default: undefined 禁用 Boolean casting,保证「未传」可辨(Dialog 同款约定)\nconst props = defineProps({\n open: { type: Boolean as PropType<boolean | undefined>, default: undefined },\n defaultOpen: { type: Boolean, default: false },\n lazyMount: { type: Boolean, default: false },\n unmountOnExit: { type: Boolean, default: false },\n});\n\nconst emit = defineEmits<{ \"update:open\": [open: boolean] }>();\n\n// 对 Root 恒走受控模式,非受控语义由内部 ref 实现(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</script>\n\n<template>\n <ArkPopover.Root\n :open=\"isOpen\"\n :lazy-mount=\"props.lazyMount\"\n :unmount-on-exit=\"props.unmountOnExit\"\n @update:open=\"handleUpdate\"\n >\n <slot />\n </ArkPopover.Root>\n</template>\n"
|
|
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"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"path": "popover/index.ts",
|
|
29
|
+
"type": "registry:component",
|
|
30
|
+
"target": "components/ui/popover/index.ts",
|
|
31
|
+
"content": "export { default as Popover } from \"./Popover.vue\";\nexport { default as PopoverContent } from \"./PopoverContent.vue\";\nexport { default as PopoverTrigger } from \"./PopoverTrigger.vue\";\n"
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
@@ -32,6 +32,12 @@
|
|
|
32
32
|
"type": "registry:ui",
|
|
33
33
|
"description": "复选框:基于 Ark UI Checkbox 原语,支持标签插槽、受控/非受控与禁用。"
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
"name": "currency-input",
|
|
37
|
+
"title": "CurrencyInput",
|
|
38
|
+
"type": "registry:ui",
|
|
39
|
+
"description": "金额输入框:内置万/元/角/分单位后缀,labelUnit 输入单位与 valueUnit 存储单位自动换算(整数分最小精度),值以 number|null 受控。"
|
|
40
|
+
},
|
|
35
41
|
{
|
|
36
42
|
"name": "dialog",
|
|
37
43
|
"title": "Dialog",
|
|
@@ -44,11 +50,17 @@
|
|
|
44
50
|
"type": "registry:ui",
|
|
45
51
|
"description": "下拉菜单:基于 Ark UI Menu 原语,含键盘导航、选中回调与分组/分隔线,Trigger 支持 asChild。"
|
|
46
52
|
},
|
|
53
|
+
{
|
|
54
|
+
"name": "form",
|
|
55
|
+
"title": "Form",
|
|
56
|
+
"type": "registry:ui",
|
|
57
|
+
"description": "表单状态与校验:基于 TanStack Form,配合 Valibot(Standard Schema)声明式校验,aria 自动接线。"
|
|
58
|
+
},
|
|
47
59
|
{
|
|
48
60
|
"name": "input",
|
|
49
61
|
"title": "Input",
|
|
50
62
|
"type": "registry:ui",
|
|
51
|
-
"description": "文本输入框,支持 v-model
|
|
63
|
+
"description": "文本输入框,支持 v-model、attrs 透传与 invalid 校验态。"
|
|
52
64
|
},
|
|
53
65
|
{
|
|
54
66
|
"name": "label",
|
|
@@ -56,6 +68,30 @@
|
|
|
56
68
|
"type": "registry:ui",
|
|
57
69
|
"description": "表单标签。"
|
|
58
70
|
},
|
|
71
|
+
{
|
|
72
|
+
"name": "number-input",
|
|
73
|
+
"title": "NumberInput",
|
|
74
|
+
"type": "registry:ui",
|
|
75
|
+
"description": "数字输入框:内置加减步进按钮与数值边界,值以 number|null 受控(空值归一 null),支持 Intl 数字格式化。"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "password-input",
|
|
79
|
+
"title": "PasswordInput",
|
|
80
|
+
"type": "registry:ui",
|
|
81
|
+
"description": "密码输入框:内置明文/掩码切换按钮(Eye/EyeOff,带 aria 语义),值与可见性均支持 v-model 受控。"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"name": "pin-input",
|
|
85
|
+
"title": "PinInput",
|
|
86
|
+
"type": "registry:ui",
|
|
87
|
+
"description": "多格验证码输入:length 指定格数,支持 otp/mask/字符类型、焦点自动跳格与填满回调,可选分隔符插槽。"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "popover",
|
|
91
|
+
"title": "Popover",
|
|
92
|
+
"type": "registry:ui",
|
|
93
|
+
"description": "气泡弹层:基于 Ark UI Popover 原语,受控/非受控开关,Trigger 支持 asChild。"
|
|
94
|
+
},
|
|
59
95
|
{
|
|
60
96
|
"name": "radio-group",
|
|
61
97
|
"title": "RadioGroup",
|
|
@@ -104,6 +140,12 @@
|
|
|
104
140
|
"type": "registry:ui",
|
|
105
141
|
"description": "选项卡:基于 Ark UI Tabs 原语,键盘导航与受控/非受控双模式。"
|
|
106
142
|
},
|
|
143
|
+
{
|
|
144
|
+
"name": "textarea",
|
|
145
|
+
"title": "Textarea",
|
|
146
|
+
"type": "registry:ui",
|
|
147
|
+
"description": "多行文本输入:纯样式封装,支持 invalid 校验态。"
|
|
148
|
+
},
|
|
107
149
|
{
|
|
108
150
|
"name": "tokens",
|
|
109
151
|
"title": "Tokens",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "textarea",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"description": "多行文本输入:纯样式封装,支持 invalid 校验态。",
|
|
6
|
+
"registryDependencies": ["utils"],
|
|
7
|
+
"files": [
|
|
8
|
+
{
|
|
9
|
+
"path": "textarea/Textarea.vue",
|
|
10
|
+
"type": "registry:component",
|
|
11
|
+
"target": "components/ui/textarea/Textarea.vue",
|
|
12
|
+
"content": "<script setup lang=\"ts\">\nimport { cn } from \"@/lib/utils\";\n\nconst modelValue = defineModel<string | number>();\nconst props = defineProps<{ class?: string; invalid?: boolean }>();\n</script>\n\n<template>\n <textarea\n v-model=\"modelValue\"\n :aria-invalid=\"props.invalid ? 'true' : undefined\"\n :class=\"\n cn(\n 'flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-destructive/20 aria-invalid:border-destructive md:text-sm',\n props.class,\n )\n \"\n />\n</template>\n"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"path": "textarea/index.ts",
|
|
16
|
+
"type": "registry:component",
|
|
17
|
+
"target": "components/ui/textarea/index.ts",
|
|
18
|
+
"content": "export { default as Textarea } from \"./Textarea.vue\";\n"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tu-design/vue",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "shadcn 风格的 Vue 3 组件库:Tailwind CSS v4 主题 + Ark UI 原语,CLI 分发组件源码。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ark-ui/vue": "^5.39.2",
|
|
36
|
+
"@tanstack/vue-form": "^1.33.5",
|
|
36
37
|
"class-variance-authority": "^0.7.1",
|
|
37
38
|
"clsx": "^2.1.1",
|
|
38
39
|
"tailwind-merge": "^3.7.0",
|
|
39
|
-
"tw-animate-css": "^1.4.0"
|
|
40
|
+
"tw-animate-css": "^1.4.0",
|
|
41
|
+
"valibot": "^1.5.0"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@vitejs/plugin-vue": "^6",
|