@movk/nuxt 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +5 -29
  2. package/dist/module.d.mts +3 -1
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +120 -34
  5. package/dist/runtime/auto-form/controls.d.ts +221 -0
  6. package/dist/runtime/auto-form/controls.js +70 -0
  7. package/dist/runtime/{utils → auto-form}/field-utils.d.ts +4 -20
  8. package/dist/runtime/{utils → auto-form}/field-utils.js +1 -2
  9. package/dist/runtime/auto-form/metadata.d.ts +22 -0
  10. package/dist/runtime/auto-form/metadata.js +53 -0
  11. package/dist/runtime/auto-form/provider.d.ts +27 -0
  12. package/dist/runtime/{internal/useAutoFormProvider.js → auto-form/provider.js} +1 -1
  13. package/dist/runtime/{utils → auto-form}/reactive-utils.d.ts +4 -22
  14. package/dist/runtime/{utils → auto-form}/schema-introspector.d.ts +3 -9
  15. package/dist/runtime/{utils → auto-form}/schema-introspector.js +11 -9
  16. package/dist/runtime/components/AutoForm.d.vue.ts +4 -5
  17. package/dist/runtime/components/AutoForm.vue +12 -35
  18. package/dist/runtime/components/AutoForm.vue.d.ts +4 -5
  19. package/dist/runtime/components/ColorChooser.d.vue.ts +10 -6
  20. package/dist/runtime/components/ColorChooser.vue +4 -7
  21. package/dist/runtime/components/ColorChooser.vue.d.ts +10 -6
  22. package/dist/runtime/components/DatePicker.d.vue.ts +16 -10
  23. package/dist/runtime/components/DatePicker.vue.d.ts +16 -10
  24. package/dist/runtime/components/SearchForm.d.vue.ts +171 -0
  25. package/dist/runtime/components/SearchForm.vue +216 -0
  26. package/dist/runtime/components/SearchForm.vue.d.ts +171 -0
  27. package/dist/runtime/components/SlideVerify.d.vue.ts +5 -32
  28. package/dist/runtime/components/SlideVerify.vue +4 -4
  29. package/dist/runtime/components/SlideVerify.vue.d.ts +5 -32
  30. package/dist/runtime/components/StarRating.d.vue.ts +8 -16
  31. package/dist/runtime/components/StarRating.vue +50 -65
  32. package/dist/runtime/components/StarRating.vue.d.ts +8 -16
  33. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.d.vue.ts +10 -2
  34. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue +16 -23
  35. package/dist/runtime/components/auto-form-renderer/AutoFormRendererArray.vue.d.ts +10 -2
  36. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.d.vue.ts +26 -0
  37. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue +50 -0
  38. package/dist/runtime/components/auto-form-renderer/AutoFormRendererChildren.vue.d.ts +26 -0
  39. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.d.vue.ts +8 -2
  40. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue +2 -2
  41. package/dist/runtime/components/auto-form-renderer/AutoFormRendererField.vue.d.ts +8 -2
  42. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.d.vue.ts +8 -2
  43. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue +29 -64
  44. package/dist/runtime/components/auto-form-renderer/AutoFormRendererLayout.vue.d.ts +8 -2
  45. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.d.vue.ts +8 -2
  46. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue +15 -69
  47. package/dist/runtime/components/auto-form-renderer/AutoFormRendererNested.vue.d.ts +8 -2
  48. package/dist/runtime/components/input/AsPhoneNumberInput.d.vue.ts +36 -0
  49. package/dist/runtime/components/input/AsPhoneNumberInput.vue +35 -0
  50. package/dist/runtime/components/input/AsPhoneNumberInput.vue.d.ts +36 -0
  51. package/dist/runtime/components/input/WithCharacterLimit.d.vue.ts +17 -9
  52. package/dist/runtime/components/input/WithCharacterLimit.vue +5 -5
  53. package/dist/runtime/components/input/WithCharacterLimit.vue.d.ts +17 -9
  54. package/dist/runtime/components/input/WithClear.d.vue.ts +13 -9
  55. package/dist/runtime/components/input/WithClear.vue +2 -2
  56. package/dist/runtime/components/input/WithClear.vue.d.ts +13 -9
  57. package/dist/runtime/components/input/WithCopy.d.vue.ts +16 -10
  58. package/dist/runtime/components/input/WithCopy.vue +3 -3
  59. package/dist/runtime/components/input/WithCopy.vue.d.ts +16 -10
  60. package/dist/runtime/components/input/WithFloatingLabel.d.vue.ts +36 -0
  61. package/dist/runtime/components/input/WithFloatingLabel.vue +67 -0
  62. package/dist/runtime/components/input/WithFloatingLabel.vue.d.ts +36 -0
  63. package/dist/runtime/components/input/WithPasswordToggle.d.vue.ts +11 -9
  64. package/dist/runtime/components/input/WithPasswordToggle.vue +3 -3
  65. package/dist/runtime/components/input/WithPasswordToggle.vue.d.ts +11 -9
  66. package/dist/runtime/components/theme-picker/ThemePicker.d.vue.ts +1 -1
  67. package/dist/runtime/components/theme-picker/ThemePicker.vue +19 -25
  68. package/dist/runtime/components/theme-picker/ThemePicker.vue.d.ts +1 -1
  69. package/dist/runtime/components/theme-picker/ThemePickerButton.d.vue.ts +1 -7
  70. package/dist/runtime/components/theme-picker/ThemePickerButton.vue.d.ts +1 -7
  71. package/dist/runtime/composables/index.d.ts +1 -1
  72. package/dist/runtime/composables/index.js +1 -1
  73. package/dist/runtime/composables/useApiFetch.d.ts +17 -14
  74. package/dist/runtime/composables/useApiFetch.js +3 -28
  75. package/dist/runtime/composables/useAutoForm.d.ts +14 -98
  76. package/dist/runtime/composables/useAutoForm.js +37 -157
  77. package/dist/runtime/composables/useClientApiFetch.d.ts +5 -6
  78. package/dist/runtime/composables/useDownloadWithProgress.js +5 -6
  79. package/dist/runtime/composables/useLazyApiFetch.d.ts +18 -0
  80. package/dist/runtime/composables/useLazyApiFetch.js +4 -0
  81. package/dist/runtime/composables/useTheme.d.ts +17 -14
  82. package/dist/runtime/composables/useTheme.js +68 -72
  83. package/dist/runtime/composables/useUploadWithProgress.d.ts +2 -2
  84. package/dist/runtime/composables/useUploadWithProgress.js +7 -7
  85. package/dist/runtime/constants/api-defaults.d.ts +9 -0
  86. package/dist/runtime/constants/api-defaults.js +32 -0
  87. package/dist/runtime/constants/auto-form.d.ts +0 -2
  88. package/dist/runtime/constants/auto-form.js +0 -25
  89. package/dist/runtime/constants/grid-cols.d.ts +7 -0
  90. package/dist/runtime/constants/grid-cols.js +44 -0
  91. package/dist/runtime/plugins/api.factory.js +78 -121
  92. package/dist/runtime/plugins/theme.js +44 -64
  93. package/dist/runtime/style.css +1 -1
  94. package/dist/runtime/types/api.d.ts +277 -146
  95. package/dist/runtime/types/auto-form.d.ts +122 -411
  96. package/dist/runtime/types/index.d.ts +2 -2
  97. package/dist/runtime/types/index.js +2 -2
  98. package/dist/runtime/types/module.d.ts +70 -13
  99. package/dist/runtime/types/theme.d.ts +2 -0
  100. package/dist/runtime/types/zod.d.ts +11 -10
  101. package/dist/runtime/utils/api-utils.d.ts +27 -48
  102. package/dist/runtime/utils/api-utils.js +18 -47
  103. package/dist/runtime/utils/meta.d.ts +7 -0
  104. package/dist/runtime/utils/meta.js +16 -0
  105. package/package.json +36 -35
  106. package/dist/runtime/composables/useApiAuth.d.ts +0 -47
  107. package/dist/runtime/composables/useApiAuth.js +0 -66
  108. package/dist/runtime/internal/useAutoFormProvider.d.ts +0 -50
  109. package/dist/runtime/schemas/api.d.ts +0 -590
  110. package/dist/runtime/schemas/api.js +0 -228
  111. package/dist/runtime/server/api/_movk/session.post.d.ts +0 -10
  112. package/dist/runtime/server/api/_movk/session.post.js +0 -18
  113. package/dist/runtime/types/auth.d.ts +0 -34
  114. package/dist/runtime/types/auto-form-renderer.d.ts +0 -22
  115. package/dist/runtime/types/components.d.ts +0 -43
  116. package/dist/runtime/types/components.js +0 -0
  117. package/dist/runtime/utils/auto-form.d.ts +0 -3
  118. package/dist/runtime/utils/auto-form.js +0 -18
  119. /package/dist/runtime/{utils → auto-form}/reactive-utils.js +0 -0
  120. /package/dist/runtime/types/{auto-form-renderer.js → theme.js} +0 -0
@@ -0,0 +1,22 @@
1
+ import type { z } from 'zod';
2
+ /**
3
+ * 应用元数据到 Zod schema
4
+ */
5
+ export declare function applyMeta<T extends z.ZodType>(schema: T, meta?: unknown): T;
6
+ /**
7
+ * 从 Zod schema 中提取 AutoForm 元数据
8
+ *
9
+ * 通过 BFS 遍历以下路径读取 meta:
10
+ * - schema.meta() — Zod v4 全局 registry
11
+ * - schema._zod.parent — .refine()/.check() 创建新实例时设置的父引用
12
+ * - schema.unwrap() — 可选/默认值等包装类型
13
+ * - schema.def.innerType / .in / .out / .schema — 结构性内层类型
14
+ *
15
+ * 收集所有层级的 meta 并合并,外层优先级更高。
16
+ */
17
+ export declare function getAutoFormMetadata(schema: z.ZodType): Record<string, any>;
18
+ /**
19
+ * 提取错误消息和元数据
20
+ * @returns [errorMessage, metadata]
21
+ */
22
+ export declare function extractErrorAndMeta(controlMeta?: any): [string | undefined, any];
@@ -0,0 +1,53 @@
1
+ import { isObject } from "@movk/core";
2
+ import { AUTOFORM_META } from "../constants/auto-form.js";
3
+ export function applyMeta(schema, meta) {
4
+ const normalizedMeta = isObject(meta) ? meta : {};
5
+ return schema.meta(normalizedMeta);
6
+ }
7
+ export function getAutoFormMetadata(schema) {
8
+ const queue = [schema];
9
+ const visited = /* @__PURE__ */ new Set();
10
+ const collectedMetas = [];
11
+ while (queue.length > 0) {
12
+ const current = queue.shift();
13
+ if (!current || visited.has(current))
14
+ continue;
15
+ visited.add(current);
16
+ const meta = typeof current.meta === "function" ? current.meta() : void 0;
17
+ if (meta && isObject(meta)) {
18
+ const typedMeta = meta;
19
+ const normalizedMeta = typedMeta?.[AUTOFORM_META.KEY] && isObject(typedMeta[AUTOFORM_META.KEY]) ? typedMeta[AUTOFORM_META.KEY] : typedMeta;
20
+ collectedMetas.push(normalizedMeta);
21
+ }
22
+ if (typeof current.unwrap === "function") {
23
+ try {
24
+ queue.push(current.unwrap());
25
+ } catch {
26
+ }
27
+ }
28
+ if (current?._zod?.parent)
29
+ queue.push(current._zod.parent);
30
+ const def = current?.def || current?._def;
31
+ if (def?.innerType)
32
+ queue.push(def.innerType);
33
+ if (def?.in)
34
+ queue.push(def.in);
35
+ if (def?.out)
36
+ queue.push(def.out);
37
+ if (def?.schema)
38
+ queue.push(def.schema);
39
+ }
40
+ if (collectedMetas.length === 0)
41
+ return {};
42
+ return Object.assign({}, ...collectedMetas.reverse());
43
+ }
44
+ export function extractErrorAndMeta(controlMeta) {
45
+ if (typeof controlMeta === "string") {
46
+ return [controlMeta, void 0];
47
+ }
48
+ if (controlMeta && isObject(controlMeta) && "error" in controlMeta) {
49
+ const { error, ...meta } = controlMeta;
50
+ return [error, meta];
51
+ }
52
+ return [void 0, controlMeta];
53
+ }
@@ -0,0 +1,27 @@
1
+ import type { Ref } from 'vue';
2
+ import type { AutoFormField, AutoFormFieldContext } from '../types/auto-form.js';
3
+ /** 初始化表单上下文工厂并通过 provide 注入给所有子渲染器 */
4
+ export declare function useAutoFormProvider<T extends Record<string, any>>(state: Ref<T>, slots: Record<string, any>): {
5
+ createFieldContext: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
6
+ createSlotProps: (field: AutoFormField, extraProps?: Record<string, any>) => AutoFormFieldContext;
7
+ resolveFieldProp: <T_1 = any>(field: AutoFormField, prop: string, defaultValue?: T_1, extraProps?: Record<string, any>) => T_1 | undefined;
8
+ renderFieldSlot: (fn?: (props?: any) => any, slotProps?: any) => any;
9
+ getResolvedFieldSlots: (field: AutoFormField, extraProps?: Record<string, any>) => undefined;
10
+ renderControl: (field: AutoFormField, extraProps?: Record<string, any>) => any;
11
+ createSlotResolver: (field: AutoFormField, extraProps?: Record<string, any>) => {
12
+ hasSlot(name: string): boolean;
13
+ renderSlot(name: string, slotProps: any): any;
14
+ };
15
+ createFormFieldSlots: (field: AutoFormField, slotResolver: ReturnType<(field: AutoFormField, extraProps?: Record<string, any>) => {
16
+ hasSlot(name: string): boolean;
17
+ renderSlot(name: string, slotProps: any): any;
18
+ }>, extraProps?: Record<string, any>) => Record<string, any>;
19
+ createCollapsibleEnhancer: (field: AutoFormField, extraProps?: Record<string, any>) => {
20
+ collapsibleConfig: any;
21
+ shouldShowCollapsible: any;
22
+ isHidden: any;
23
+ enhancedField: any;
24
+ };
25
+ };
26
+ /** 注入表单上下文,必须在 AutoForm 子渲染器中调用 */
27
+ export declare function useAutoFormInjector(): any;
@@ -2,7 +2,7 @@ import { UIcon } from "#components";
2
2
  import defu from "defu";
3
3
  import { computed, h, inject, isVNode, provide, resolveDynamicComponent, unref } from "vue";
4
4
  import { getPath, setPath } from "@movk/core";
5
- import { enhanceEventProps, resolveReactiveValue } from "../utils/auto-form.js";
5
+ import { enhanceEventProps, resolveReactiveValue } from "./reactive-utils.js";
6
6
  const AUTO_FORM_CONTEXT_KEY = Symbol("AUTO_FORM_CONTEXT_KEY");
7
7
  export function useAutoFormProvider(state, slots) {
8
8
  function createFieldContext(field, extraProps) {
@@ -1,30 +1,12 @@
1
1
  import type { ReactiveValue, AnyObject } from '@movk/core';
2
2
  import type { AutoFormFieldContext } from '../types/auto-form.js';
3
- /**
4
- * 响应式值解析
5
- * @param value - 响应式值
6
- * @param context - 表单字段上下文
7
- * @returns 解析后的值
8
- */
3
+ /** 解析单个响应式值:函数则以 context 调用,ref 则解包,否则原样返回 */
9
4
  export declare function resolveReactiveValue(value: ReactiveValue<any, any>, context: AutoFormFieldContext): any;
10
- /**
11
- * 响应式对象解析
12
- * @param obj - 要解析的对象
13
- * @param context - 表单字段上下文
14
- * @param depth - 当前递归深度(防止无限递归)
15
- * @returns 解析后的对象
16
- */
5
+ /** 递归解析对象/数组中所有响应式值,VNode 和 ref 不再展开以防止意外渲染 */
17
6
  export declare function resolveReactiveObject<T extends Record<string, any>>(obj: T, context: AutoFormFieldContext, depth?: number): T;
18
- /**
19
- * 增强的事件属性处理 - 提升性能和安全性
20
- * @param originalProps - 原始属性对象
21
- * @param ctx - 表单字段上下文
22
- * @returns 增强后的属性对象
23
- */
7
+ /** 为 onXxx 事件 prop 自动追加 context 作为最后一个参数,方便用户在事件回调中访问表单状态 */
24
8
  export declare function enhanceEventProps(originalProps: AnyObject, ctx: AutoFormFieldContext): Record<string, any>;
25
- /**
26
- * VNode 渲染组件 - 修复水合错误
27
- */
9
+ /** 渲染任意 VNode 内容(slot 函数返回值、h() 结果等),单子节点直接返回,多个节点包入 Fragment */
28
10
  export declare function VNodeRender(props: {
29
11
  node: unknown;
30
12
  }): any;
@@ -1,13 +1,7 @@
1
- import type { z } from 'zod/v4';
1
+ import type { z } from 'zod';
2
2
  import type { AutoFormControls, AutoFormField } from '../types/auto-form.js';
3
3
  import type { ZodAutoFormFieldMeta } from '../types/zod.js';
4
- /**
5
- * Schema 内省 - 递归解析 Zod Schema 为表单字段结构
6
- */
4
+ /** 将 Zod schema 递归解析为 AutoFormField 列表(schema 遍历的核心入口) */
7
5
  export declare function introspectSchema(schema: z.ZodType, mapping: AutoFormControls, path: string, globalMeta?: ZodAutoFormFieldMeta): AutoFormField[];
8
- /**
9
- * 提取纯净的数据 schema(去除所有布局标记)
10
- * @param schema - 包含布局标记的 ZodObject
11
- * @returns 纯净的 ZodObject,只包含数据字段
12
- */
6
+ /** 将含布局标记的 schema 还原为纯字段 schema,用于 Zod 表单校验 */
13
7
  export declare function extractPureSchema<T extends z.ZodObject<any, any>>(schema: T): z.ZodObject<any, any>;
@@ -1,14 +1,18 @@
1
1
  import { markRaw } from "vue";
2
- import { z as zod } from "zod/v4";
2
+ import { z as zod } from "zod";
3
3
  import { joinPath, startCase, toPath, isFunction, isObject } from "@movk/core";
4
- import { useAutoForm } from "../composables/useAutoForm.js";
4
+ import { getAutoFormMetadata } from "./metadata.js";
5
5
  import { AUTOFORM_LIMITS, AUTOFORM_META } from "../constants/auto-form.js";
6
+ function getUnwrappedSchema(schema) {
7
+ const def = schema?.def || schema?._def;
8
+ return def?.innerType || def?.in || def?.schema || void 0;
9
+ }
6
10
  function extractDecorators(schema) {
7
11
  const decorators = {};
8
12
  let cur = schema;
9
13
  let coreSchema = schema;
10
14
  while (cur) {
11
- const def = cur?.def;
15
+ const def = cur?.def || cur?._def;
12
16
  if (!def?.type)
13
17
  break;
14
18
  switch (def.type) {
@@ -22,9 +26,11 @@ function extractDecorators(schema) {
22
26
  decorators.defaultValue = isFunction(def.defaultValue) ? def.defaultValue() : def.defaultValue;
23
27
  break;
24
28
  }
25
- const next = def?.innerType;
29
+ const next = getUnwrappedSchema(cur);
26
30
  if (!next)
27
31
  break;
32
+ if (next === cur)
33
+ break;
28
34
  cur = next;
29
35
  coreSchema = next;
30
36
  }
@@ -34,7 +40,6 @@ function extractDecorators(schema) {
34
40
  return { decorators, coreSchema };
35
41
  }
36
42
  function extractSchemaInfo(schema, globalMeta, autoGeneratedLabel) {
37
- const { getAutoFormMetadata } = useAutoForm();
38
43
  const customMeta = getAutoFormMetadata(schema);
39
44
  const { decorators, coreSchema } = extractDecorators(schema);
40
45
  const computedType = customMeta?.component ? void 0 : customMeta?.type ?? coreSchema?.type;
@@ -47,7 +52,6 @@ function extractSchemaInfo(schema, globalMeta, autoGeneratedLabel) {
47
52
  ...globalMeta,
48
53
  ...customMeta,
49
54
  type: computedType,
50
- // 如果有 overwrite,则进行合并
51
55
  ...customMeta?.overwrite && isObject(customMeta.overwrite) ? customMeta.overwrite : {}
52
56
  };
53
57
  return { decorators, mergedMeta, coreSchema };
@@ -162,14 +166,13 @@ export function introspectSchema(schema, mapping, path, globalMeta = {}) {
162
166
  if (enumValues && enumValues.length > 0) {
163
167
  field.meta.controlProps = {
164
168
  items: enumValues,
165
- ...field.meta.controlProps || {}
169
+ ...field.meta.controlProps
166
170
  };
167
171
  }
168
172
  }
169
173
  return [field];
170
174
  }
171
175
  function isLayoutMarker(schema) {
172
- const { getAutoFormMetadata } = useAutoForm();
173
176
  const meta = getAutoFormMetadata(schema);
174
177
  return meta?.type === AUTOFORM_META.LAYOUT_KEY;
175
178
  }
@@ -177,7 +180,6 @@ function processLayoutShape(shape) {
177
180
  const resultShape = {};
178
181
  for (const [key, fieldSchema] of Object.entries(shape)) {
179
182
  if (isLayoutMarker(fieldSchema)) {
180
- const { getAutoFormMetadata } = useAutoForm();
181
183
  const meta = getAutoFormMetadata(fieldSchema);
182
184
  const layoutFields = meta?.layout?.fields;
183
185
  if (layoutFields && isObject(layoutFields)) {
@@ -1,5 +1,5 @@
1
1
  import type { ButtonProps, FormEmits, FormProps, InferInput } from '@nuxt/ui';
2
- import type { z } from 'zod/v4';
2
+ import type { z } from 'zod';
3
3
  import type { ZodAutoFormFieldMeta } from '../types/zod.js';
4
4
  import type { AutoFormControls, AutoFormSlotProps, DynamicFormSlots } from '../types/auto-form.js';
5
5
  export interface AutoFormProps<S extends z.ZodObject, T extends boolean = true, N extends boolean = false> extends FormProps<S, T, N> {
@@ -27,19 +27,18 @@ export type AutoFormSlots<T extends object> = {
27
27
  } & DynamicFormSlots<T>;
28
28
  declare const __VLS_export: <S extends z.ZodObject, T extends boolean = true, N extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
29
29
  props: import("vue").PublicProps & __VLS_PrettifyLocal<AutoFormProps<S, T, N> & {
30
- onError?: ((event: import("@nuxt/ui/.").FormErrorEvent) => any) | undefined;
31
- onSubmit?: ((event: import("@nuxt/ui/.").FormSubmitEvent<import("@nuxt/ui/.").FormData<S, T>>) => any) | undefined;
30
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
32
31
  }> & (typeof globalThis extends {
33
32
  __VLS_PROPS_FALLBACK: infer P;
34
33
  } ? P : {});
35
34
  expose: (exposed: import("vue").ShallowUnwrapRef<{
36
- formRef: Readonly<import("vue").ShallowRef<any, any>>;
35
+ formRef: any;
37
36
  reset: () => void;
38
37
  clear: () => void;
39
38
  }>) => void;
40
39
  attrs: any;
41
40
  slots: AutoFormSlots<N extends false ? Partial<InferInput<S>> : never>;
42
- emit: ((evt: "error", event: import("@nuxt/ui/.").FormErrorEvent) => void) & ((evt: "submit", event: import("@nuxt/ui/.").FormSubmitEvent<import("@nuxt/ui/.").FormData<S, T>>) => void);
41
+ emit: any;
43
42
  }>) => import("vue").VNode & {
44
43
  __ctx?: Awaited<typeof __VLS_setup>;
45
44
  };
@@ -1,14 +1,13 @@
1
1
  <script setup>
2
2
  import { UForm } from "#components";
3
3
  import { computed, onMounted, ref, useTemplateRef } from "vue";
4
- import { useAutoFormProvider } from "../internal/useAutoFormProvider";
4
+ import { useAutoFormProvider } from "../auto-form/provider";
5
5
  import { getPath, setPath } from "@movk/core";
6
- import { classifyFields, extractPureSchema, introspectSchema } from "../utils/auto-form";
7
- import AutoFormRendererArray from "./auto-form-renderer/AutoFormRendererArray.vue";
8
- import AutoFormRendererField from "./auto-form-renderer/AutoFormRendererField.vue";
9
- import AutoFormRendererLayout from "./auto-form-renderer/AutoFormRendererLayout.vue";
10
- import AutoFormRendererNested from "./auto-form-renderer/AutoFormRendererNested.vue";
6
+ import { classifyFields } from "../auto-form/field-utils";
7
+ import { extractPureSchema, introspectSchema } from "../auto-form/schema-introspector";
11
8
  import { useAutoForm } from "../composables/useAutoForm";
9
+ import AutoFormRendererChildren from "./auto-form-renderer/AutoFormRendererChildren.vue";
10
+ import AutoFormRendererField from "./auto-form-renderer/AutoFormRendererField.vue";
12
11
  const {
13
12
  schema,
14
13
  controls,
@@ -37,6 +36,7 @@ const {
37
36
  transform: { type: null, required: false },
38
37
  nested: { type: Boolean, required: false },
39
38
  class: { type: null, required: false },
39
+ ui: { type: Object, required: false },
40
40
  onSubmit: { type: Function, required: false }
41
41
  });
42
42
  defineEmits(["submit", "error"]);
@@ -54,8 +54,7 @@ const controlsMapping = computed(() => ({
54
54
  const fields = computed(() => {
55
55
  if (!schema)
56
56
  return [];
57
- const items = introspectSchema(schema, controlsMapping.value, "", globalMeta);
58
- return items;
57
+ return introspectSchema(schema, controlsMapping.value, "", globalMeta);
59
58
  });
60
59
  function resolveDefaultValue(fields2, stateValue) {
61
60
  if (!fields2.length)
@@ -134,33 +133,11 @@ defineExpose({
134
133
  <slot name="header" v-bind="{ errors, loading, fields: visibleFields, state }" />
135
134
 
136
135
  <template v-if="renderData.hasComplexFields">
137
- <template v-for="field in renderData.allFields" :key="field.path">
138
- <AutoFormRendererField
139
- v-if="renderData.leafFields.includes(field)"
140
- :field="field"
141
- :schema="schema"
142
- :extra-props="{ errors, loading }"
143
- />
144
- <AutoFormRendererArray
145
- v-else-if="renderData.arrayFields.includes(field)"
146
- :field="field"
147
- :schema="schema"
148
- :extra-props="{ errors, loading }"
149
- :add-button-props="addButtonProps"
150
- />
151
- <AutoFormRendererLayout
152
- v-else-if="renderData.layoutFields.includes(field)"
153
- :field="field"
154
- :schema="schema"
155
- :extra-props="{ errors, loading }"
156
- />
157
- <AutoFormRendererNested
158
- v-else
159
- :field="field"
160
- :schema="schema"
161
- :extra-props="{ errors, loading }"
162
- />
163
- </template>
136
+ <AutoFormRendererChildren
137
+ :fields="renderData.allFields"
138
+ :schema="schema"
139
+ :extra-props="{ errors, loading }"
140
+ />
164
141
  </template>
165
142
 
166
143
  <template v-else>
@@ -1,5 +1,5 @@
1
1
  import type { ButtonProps, FormEmits, FormProps, InferInput } from '@nuxt/ui';
2
- import type { z } from 'zod/v4';
2
+ import type { z } from 'zod';
3
3
  import type { ZodAutoFormFieldMeta } from '../types/zod.js';
4
4
  import type { AutoFormControls, AutoFormSlotProps, DynamicFormSlots } from '../types/auto-form.js';
5
5
  export interface AutoFormProps<S extends z.ZodObject, T extends boolean = true, N extends boolean = false> extends FormProps<S, T, N> {
@@ -27,19 +27,18 @@ export type AutoFormSlots<T extends object> = {
27
27
  } & DynamicFormSlots<T>;
28
28
  declare const __VLS_export: <S extends z.ZodObject, T extends boolean = true, N extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
29
29
  props: import("vue").PublicProps & __VLS_PrettifyLocal<AutoFormProps<S, T, N> & {
30
- onError?: ((event: import("@nuxt/ui/.").FormErrorEvent) => any) | undefined;
31
- onSubmit?: ((event: import("@nuxt/ui/.").FormSubmitEvent<import("@nuxt/ui/.").FormData<S, T>>) => any) | undefined;
30
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
32
31
  }> & (typeof globalThis extends {
33
32
  __VLS_PROPS_FALLBACK: infer P;
34
33
  } ? P : {});
35
34
  expose: (exposed: import("vue").ShallowUnwrapRef<{
36
- formRef: Readonly<import("vue").ShallowRef<any, any>>;
35
+ formRef: any;
37
36
  reset: () => void;
38
37
  clear: () => void;
39
38
  }>) => void;
40
39
  attrs: any;
41
40
  slots: AutoFormSlots<N extends false ? Partial<InferInput<S>> : never>;
42
- emit: ((evt: "error", event: import("@nuxt/ui/.").FormErrorEvent) => void) & ((evt: "submit", event: import("@nuxt/ui/.").FormSubmitEvent<import("@nuxt/ui/.").FormData<S, T>>) => void);
41
+ emit: any;
43
42
  }>) => import("vue").VNode & {
44
43
  __ctx?: Awaited<typeof __VLS_setup>;
45
44
  };
@@ -1,11 +1,15 @@
1
- import type { ColorChooserProps } from '../types/components.js';
1
+ import type { ButtonProps, ColorPickerProps, PopoverProps } from '@nuxt/ui';
2
+ export interface ColorChooserProps<P extends 'click' | 'hover' = 'click'> extends /** @vue-ignore */ ColorPickerProps {
3
+ /** 弹出层组件属性 */
4
+ popoverProps?: PopoverProps<P>;
5
+ /** 按钮组件属性 */
6
+ buttonProps?: ButtonProps;
7
+ }
2
8
  declare const __VLS_export: <P extends "click" | "hover" = "click">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: import("vue").PublicProps & __VLS_PrettifyLocal<(ColorChooserProps<"click"> & {
9
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(ColorChooserProps<P> & {
4
10
  modelValue?: string;
5
11
  }) & {
6
- "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
7
- "onClose:prevent"?: (() => any) | undefined;
8
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
12
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
9
13
  }> & (typeof globalThis extends {
10
14
  __VLS_PROPS_FALLBACK: infer P_1;
11
15
  } ? P_1 : {});
@@ -20,7 +24,7 @@ declare const __VLS_export: <P extends "click" | "hover" = "click">(__VLS_props:
20
24
  } & {
21
25
  anchor?: (props: any) => any;
22
26
  };
23
- emit: (((evt: "close:prevent") => void) & ((evt: "update:open", value: boolean) => void)) & ((evt: "update:modelValue", value: string | undefined) => void);
27
+ emit: any & ((event: "update:modelValue", value: string | undefined) => void);
24
28
  }>) => import("vue").VNode & {
25
29
  __ctx?: Awaited<typeof __VLS_setup>;
26
30
  };
@@ -1,10 +1,7 @@
1
1
  <script setup>
2
2
  import { UPopover, UButton, UColorPicker, UIcon } from "#components";
3
3
  import { computed } from "vue";
4
- const {
5
- buttonProps,
6
- popoverProps
7
- } = defineProps({
4
+ const props = defineProps({
8
5
  popoverProps: { type: Object, required: false },
9
6
  buttonProps: { type: Object, required: false }
10
7
  });
@@ -12,7 +9,7 @@ const emit = defineEmits(["close:prevent", "update:open"]);
12
9
  defineOptions({ inheritAttrs: false });
13
10
  const modelValue = defineModel({ type: String });
14
11
  const label = computed(() => {
15
- return modelValue.value || buttonProps?.label || "\u9009\u62E9\u989C\u8272";
12
+ return modelValue.value || props.buttonProps?.label || "\u9009\u62E9\u989C\u8272";
16
13
  });
17
14
  const chipStyle = computed(() => ({
18
15
  backgroundColor: modelValue.value || ""
@@ -20,14 +17,14 @@ const chipStyle = computed(() => ({
20
17
  </script>
21
18
 
22
19
  <template>
23
- <UPopover v-bind="popoverProps" @close:prevent="emit('close:prevent')" @update:open="emit('update:open', $event)">
20
+ <UPopover v-bind="props.popoverProps" @close:prevent="emit('close:prevent')" @update:open="emit('update:open', $event)">
24
21
  <template #default="defaultSlotProps">
25
22
  <slot v-bind="defaultSlotProps">
26
23
  <UButton
27
24
  color="neutral"
28
25
  variant="subtle"
29
26
  class="w-full"
30
- v-bind="buttonProps"
27
+ v-bind="props.buttonProps"
31
28
  :label="label"
32
29
  >
33
30
  <template #leading="leading">
@@ -1,11 +1,15 @@
1
- import type { ColorChooserProps } from '../types/components.js';
1
+ import type { ButtonProps, ColorPickerProps, PopoverProps } from '@nuxt/ui';
2
+ export interface ColorChooserProps<P extends 'click' | 'hover' = 'click'> extends /** @vue-ignore */ ColorPickerProps {
3
+ /** 弹出层组件属性 */
4
+ popoverProps?: PopoverProps<P>;
5
+ /** 按钮组件属性 */
6
+ buttonProps?: ButtonProps;
7
+ }
2
8
  declare const __VLS_export: <P extends "click" | "hover" = "click">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
- props: import("vue").PublicProps & __VLS_PrettifyLocal<(ColorChooserProps<"click"> & {
9
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(ColorChooserProps<P> & {
4
10
  modelValue?: string;
5
11
  }) & {
6
- "onUpdate:modelValue"?: ((value: string | undefined) => any) | undefined;
7
- "onClose:prevent"?: (() => any) | undefined;
8
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
12
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
9
13
  }> & (typeof globalThis extends {
10
14
  __VLS_PROPS_FALLBACK: infer P_1;
11
15
  } ? P_1 : {});
@@ -20,7 +24,7 @@ declare const __VLS_export: <P extends "click" | "hover" = "click">(__VLS_props:
20
24
  } & {
21
25
  anchor?: (props: any) => any;
22
26
  };
23
- emit: (((evt: "close:prevent") => void) & ((evt: "update:open", value: boolean) => void)) & ((evt: "update:modelValue", value: string | undefined) => void);
27
+ emit: any & ((event: "update:modelValue", value: string | undefined) => void);
24
28
  }>) => import("vue").VNode & {
25
29
  __ctx?: Awaited<typeof __VLS_setup>;
26
30
  };
@@ -1,15 +1,21 @@
1
- import type { DateValue } from '@internationalized/date';
2
- import type { DatePickerProps, ValueType } from '../types/components.js';
1
+ import type { DateFormatterOptions } from '../composables/useDateFormatter.js';
2
+ import type { ButtonProps, CalendarProps, PopoverProps } from '@nuxt/ui';
3
+ import type { OmitByKey } from '@movk/core';
4
+ import { useDateFormatter } from '../composables/useDateFormatter.js';
5
+ export type LabelFormat = 'iso' | 'formatted' | 'date' | 'timestamp' | 'unix';
6
+ export interface DatePickerProps<R extends boolean, M extends boolean, P extends 'click' | 'hover' = 'click'> extends /** @vue-ignore */ OmitByKey<CalendarProps<R, M>, 'modelValue'>, DateFormatterOptions {
7
+ /** 按钮组件属性 */
8
+ buttonProps?: ButtonProps;
9
+ /** 弹出层组件属性 */
10
+ popoverProps?: PopoverProps<P>;
11
+ /** 按钮上展示文本的格式 */
12
+ labelFormat?: LabelFormat | ((formatter: ReturnType<typeof useDateFormatter>, modelValue: CalendarProps<R, M>['modelValue']) => string);
13
+ }
3
14
  declare const __VLS_export: <R extends boolean, M extends boolean, P extends "click" | "hover" = "click">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
15
  props: import("vue").PublicProps & __VLS_PrettifyLocal<(DatePickerProps<R, M, P> & {
5
- modelValue?: ValueType<R, M>;
16
+ modelValue?: CalendarProps<R, M>["modelValue"];
6
17
  }) & {
7
- "onUpdate:modelValue"?: ((value: ValueType<R, M>) => any) | undefined;
8
- "onUpdate:placeholder"?: ((...args: DateValue[]) => any) | undefined;
9
- "onUpdate:validModelValue"?: ((date: import("reka-ui").DateRange) => any) | undefined;
10
- "onUpdate:startValue"?: ((date: DateValue | undefined) => any) | undefined;
11
- "onClose:prevent"?: (() => any) | undefined;
12
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
18
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
13
19
  }> & (typeof globalThis extends {
14
20
  __VLS_PROPS_FALLBACK: infer P_1;
15
21
  } ? P_1 : {});
@@ -30,7 +36,7 @@ declare const __VLS_export: <R extends boolean, M extends boolean, P extends "cl
30
36
  } & {
31
37
  'week-day'?: (props: any) => any;
32
38
  };
33
- emit: (((evt: "update:modelValue", date: R extends true ? import("reka-ui").DateRange | null : M extends true ? DateValue[] | undefined : DateValue | undefined) => void) & ((evt: "update:placeholder", ...args: [date: DateValue] & [date: DateValue]) => void) & ((evt: "update:validModelValue", date: import("reka-ui").DateRange) => void) & ((evt: "update:startValue", date: DateValue | undefined) => void) & ((evt: "close:prevent") => void) & ((evt: "update:open", value: boolean) => void)) & ((evt: "update:modelValue", value: ValueType<R, M>) => void);
39
+ emit: any;
34
40
  }>) => import("vue").VNode & {
35
41
  __ctx?: Awaited<typeof __VLS_setup>;
36
42
  };
@@ -1,15 +1,21 @@
1
- import type { DateValue } from '@internationalized/date';
2
- import type { DatePickerProps, ValueType } from '../types/components.js';
1
+ import type { DateFormatterOptions } from '../composables/useDateFormatter.js';
2
+ import type { ButtonProps, CalendarProps, PopoverProps } from '@nuxt/ui';
3
+ import type { OmitByKey } from '@movk/core';
4
+ import { useDateFormatter } from '../composables/useDateFormatter.js';
5
+ export type LabelFormat = 'iso' | 'formatted' | 'date' | 'timestamp' | 'unix';
6
+ export interface DatePickerProps<R extends boolean, M extends boolean, P extends 'click' | 'hover' = 'click'> extends /** @vue-ignore */ OmitByKey<CalendarProps<R, M>, 'modelValue'>, DateFormatterOptions {
7
+ /** 按钮组件属性 */
8
+ buttonProps?: ButtonProps;
9
+ /** 弹出层组件属性 */
10
+ popoverProps?: PopoverProps<P>;
11
+ /** 按钮上展示文本的格式 */
12
+ labelFormat?: LabelFormat | ((formatter: ReturnType<typeof useDateFormatter>, modelValue: CalendarProps<R, M>['modelValue']) => string);
13
+ }
3
14
  declare const __VLS_export: <R extends boolean, M extends boolean, P extends "click" | "hover" = "click">(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
15
  props: import("vue").PublicProps & __VLS_PrettifyLocal<(DatePickerProps<R, M, P> & {
5
- modelValue?: ValueType<R, M>;
16
+ modelValue?: CalendarProps<R, M>["modelValue"];
6
17
  }) & {
7
- "onUpdate:modelValue"?: ((value: ValueType<R, M>) => any) | undefined;
8
- "onUpdate:placeholder"?: ((...args: DateValue[]) => any) | undefined;
9
- "onUpdate:validModelValue"?: ((date: import("reka-ui").DateRange) => any) | undefined;
10
- "onUpdate:startValue"?: ((date: DateValue | undefined) => any) | undefined;
11
- "onClose:prevent"?: (() => any) | undefined;
12
- "onUpdate:open"?: ((value: boolean) => any) | undefined;
18
+ [x: `on${Capitalize<string>}`]: ((...args: any) => any) | undefined;
13
19
  }> & (typeof globalThis extends {
14
20
  __VLS_PROPS_FALLBACK: infer P_1;
15
21
  } ? P_1 : {});
@@ -30,7 +36,7 @@ declare const __VLS_export: <R extends boolean, M extends boolean, P extends "cl
30
36
  } & {
31
37
  'week-day'?: (props: any) => any;
32
38
  };
33
- emit: (((evt: "update:modelValue", date: R extends true ? import("reka-ui").DateRange | null : M extends true ? DateValue[] | undefined : DateValue | undefined) => void) & ((evt: "update:placeholder", ...args: [date: DateValue] & [date: DateValue]) => void) & ((evt: "update:validModelValue", date: import("reka-ui").DateRange) => void) & ((evt: "update:startValue", date: DateValue | undefined) => void) & ((evt: "close:prevent") => void) & ((evt: "update:open", value: boolean) => void)) & ((evt: "update:modelValue", value: ValueType<R, M>) => void);
39
+ emit: any;
34
40
  }>) => import("vue").VNode & {
35
41
  __ctx?: Awaited<typeof __VLS_setup>;
36
42
  };