@dazhicheng/ui 1.5.188 → 1.5.193

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.
@@ -26,7 +26,9 @@ export declare const FormArrayRegister: import('vue').DefineComponent<{
26
26
  }> & Readonly<{}>, {
27
27
  readonly disabled: boolean | undefined;
28
28
  readonly hide: boolean | undefined;
29
+ readonly defaultValue: any;
29
30
  readonly wrapperClass: string;
31
+ readonly useArraySchema: boolean | undefined;
30
32
  readonly arraySchema: import('./props').ArraySchemaProp;
31
33
  readonly dependencies: import('./types').ArrayRegisterDependencies | undefined;
32
34
  readonly rules: import('../../types').FormSchemaRuleType | undefined;
@@ -24,6 +24,14 @@ export declare const formArrayRegisterProps: {
24
24
  readonly type: PropType<ArraySchemaProp>;
25
25
  readonly default: () => FormSchema[];
26
26
  };
27
+ readonly useArraySchema: {
28
+ readonly type: PropType<boolean | undefined>;
29
+ readonly default: undefined;
30
+ };
31
+ readonly defaultValue: {
32
+ readonly type: PropType<FormSchema["defaultValue"]>;
33
+ readonly default: undefined;
34
+ };
27
35
  readonly formItemClass: {
28
36
  readonly type: PropType<NonNullable<FormSchema["formItemClass"]>>;
29
37
  readonly default: undefined;
@@ -147,7 +147,7 @@ export declare class FormApi {
147
147
  * @param name 需要注册的数组字段
148
148
  * @param actions 操作方法
149
149
  */
150
- registerArrayField(name: string, actions: ResolvedFieldArrayContext): void;
150
+ registerArrayField(name: string, actions: ResolvedFieldArrayContext, schema?: FormSchema): void;
151
151
  unregisterArrayField(name: string, actions?: ResolvedFieldArrayContext): void;
152
152
  /** @description 数组字段操作集合 */
153
153
  get arrayAction(): {
@@ -162,7 +162,7 @@ export declare class FormApi {
162
162
  * @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
163
163
  * @param value 要追加的数组项值
164
164
  */
165
- push: <TValue = unknown>(name: string, value: TValue) => void;
165
+ push: <TValue = unknown>(name: string, value?: TValue) => void;
166
166
  /**
167
167
  * @description 删除指定索引的项
168
168
  * @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
@@ -190,14 +190,14 @@ export declare class FormApi {
190
190
  * @param idx 插入位置索引
191
191
  * @param value 要插入的数组项值
192
192
  */
193
- insert: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
193
+ insert: <TValue = unknown>(name: string, idx: number, value?: TValue) => void;
194
194
  /**
195
195
  * @description 在数组头部新增一项
196
196
  * @template TValue 数组项类型
197
197
  * @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
198
198
  * @param value 要插入到头部的数组项值
199
199
  */
200
- prepend: <TValue = unknown>(name: string, value: TValue) => void;
200
+ prepend: <TValue = unknown>(name: string, value?: TValue) => void;
201
201
  /**
202
202
  * @description 将项从旧索引移动到新索引
203
203
  * @param name 数组字段名(例如 `fieldName的值 数组下才生效`)
@@ -224,8 +224,31 @@ export declare class FormApi {
224
224
  * @description 将业务传入路径规范化为数组注册表键
225
225
  */
226
226
  protected _resolveArrayFieldPath(name: string): string;
227
+ private _getRegisteredArrayFieldItem;
227
228
  private _getRegisteredArrayField;
228
229
  private _getArrayFieldActions;
230
+ /**
231
+ * @description 获取数组字段 schema
232
+ */
233
+ protected _getArrayFieldSchema(name: string): FormSchema | undefined;
234
+ /**
235
+ * @description 解析数组新增项默认值
236
+ */
237
+ protected _resolveArrayDefaultItemValue(name: string): unknown;
238
+ /**
239
+ * @description 按新增操作场景解析数组新增项默认值
240
+ */
241
+ protected _resolveArrayDefaultItemValueByMutation(name: string, value?: unknown, options?: {
242
+ index?: number;
243
+ arrayLength?: number;
244
+ }): unknown;
245
+ /**
246
+ * @description 合并数组新增项值,优先使用 schema 默认值补齐
247
+ */
248
+ protected _resolveArrayItemValue<TValue = unknown>(name: string, value?: TValue, options?: {
249
+ index?: number;
250
+ arrayLength?: number;
251
+ }): TValue;
229
252
  /**
230
253
  * @description 开发环境:数组字段未注册时输出告警与相近路径提示
231
254
  */
@@ -339,12 +339,12 @@ export declare class GroupFormApi extends FormApi {
339
339
  */
340
340
  get arrayAction(): {
341
341
  get: <TValue = unknown>(name: string) => Readonly<import('../..').FieldArrayContext<TValue>> | undefined;
342
- push: <TValue = unknown>(name: string, value: TValue) => void;
342
+ push: <TValue = unknown>(name: string, value?: TValue) => void;
343
343
  remove: (name: string, idx: number) => void;
344
344
  replace: <TValue = unknown>(name: string, values: TValue[]) => void;
345
345
  update: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
346
- insert: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
347
- prepend: <TValue = unknown>(name: string, value: TValue) => void;
346
+ insert: <TValue = unknown>(name: string, idx: number, value?: TValue) => void;
347
+ prepend: <TValue = unknown>(name: string, value?: TValue) => void;
348
348
  move: (name: string, oldIdx: number, newIdx: number) => void;
349
349
  swap: (name: string, indexA: number, indexB: number) => void;
350
350
  /**
@@ -1,2 +1,3 @@
1
+ import { FormSchema } from '../types';
1
2
  import { ResolvedFieldArrayContext } from '../types/forms';
2
- export declare function useArrayRegistry(name: string): readonly [(actions?: ResolvedFieldArrayContext) => void, () => void];
3
+ export declare function useArrayRegistry(name: string, schema?: FormSchema): readonly [(actions?: ResolvedFieldArrayContext) => void, () => void];
@@ -64,12 +64,12 @@ export type MaybeComponentProps = {
64
64
  /** 数组操作方法 */
65
65
  export interface FormArrayActions {
66
66
  get: <TValue = unknown>(name: string) => Readonly<FieldArrayContext<TValue>> | undefined;
67
- push: <TValue = unknown>(name: string, value: TValue) => void;
67
+ push: <TValue = unknown>(name: string, value?: TValue) => void;
68
68
  remove: (name: string, idx: number) => void;
69
69
  replace: <TValue = unknown>(name: string, values: TValue[]) => void;
70
70
  update: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
71
- insert: <TValue = unknown>(name: string, idx: number, value: TValue) => void;
72
- prepend: <TValue = unknown>(name: string, value: TValue) => void;
71
+ insert: <TValue = unknown>(name: string, idx: number, value?: TValue) => void;
72
+ prepend: <TValue = unknown>(name: string, value?: TValue) => void;
73
73
  move: (name: string, oldIdx: number, newIdx: number) => void;
74
74
  swap: (name: string, indexA: number, indexB: number) => void;
75
75
  /**
@@ -87,12 +87,12 @@ export interface FormArrayActions {
87
87
  export type NestedArrayHandle<TValue = unknown> = {
88
88
  path: string;
89
89
  get: () => Readonly<FieldArrayContext<TValue>> | undefined;
90
- push: (value: TValue) => void;
90
+ push: (value?: TValue) => void;
91
91
  remove: (idx: number) => void;
92
92
  replace: (values: TValue[]) => void;
93
93
  update: (idx: number, value: TValue) => void;
94
- insert: (idx: number, value: TValue) => void;
95
- prepend: (value: TValue) => void;
94
+ insert: (idx: number, value?: TValue) => void;
95
+ prepend: (value?: TValue) => void;
96
96
  move: (oldIdx: number, newIdx: number) => void;
97
97
  swap: (indexA: number, indexB: number) => void;
98
98
  /** 进入下一层嵌套数组,如 `.at(0, 'skills').at(1, 'items')` */
@@ -1,5 +1,5 @@
1
1
  import { ComputedRef } from 'vue';
2
- import { FormSchema, ExtendedFormApi, FormActions, TtFormProps } from './types';
2
+ import { ArraySchemaContext, FormArrayActions, FormSchema, NestedArrayHandle, ExtendedFormApi, FormActions, TtFormProps } from './types';
3
3
  type ExtendFormProps = TtFormProps & {
4
4
  formApi?: ExtendedFormApi;
5
5
  };
@@ -8,6 +8,65 @@ export declare const injectFormProps: <T extends [ExtendFormProps | ComputedRef<
8
8
  export declare const injectComponentRefMap: <T extends Map<string, unknown> | null | undefined = Map<string, unknown>>(fallback?: T | undefined) => T extends null ? Map<string, unknown> | null : Map<string, unknown>, provideComponentRefMap: (contextValue: Map<string, unknown>) => Map<string, unknown>;
9
9
  /** 提取单个字段默认值:defaultValue 优先,其次 Zod rules */
10
10
  export declare function resolveSchemaItemDefaultValue(item: FormSchema): unknown | undefined;
11
+ /** 数组 schema 运行时上下文参数 */
12
+ type ArraySchemaRuntimeOptions = {
13
+ /**
14
+ * 当前数组字段 schema
15
+ */
16
+ item: FormSchema;
17
+ /**
18
+ * 当前数组完整路径
19
+ */
20
+ arrayPath: string;
21
+ /**
22
+ * 当前行完整路径
23
+ */
24
+ itemPath: string;
25
+ /**
26
+ * 当前行值
27
+ */
28
+ row: Record<string, unknown>;
29
+ /**
30
+ * 当前行索引
31
+ */
32
+ index: number;
33
+ /**
34
+ * 当前数组长度
35
+ */
36
+ arrayLength: number;
37
+ /**
38
+ * 父行路径
39
+ */
40
+ parentItemPath?: string;
41
+ /**
42
+ * 表单值代理
43
+ */
44
+ form?: Record<string, unknown>;
45
+ /**
46
+ * 表单数组操作器
47
+ */
48
+ arrayAction?: FormArrayActions;
49
+ /**
50
+ * 当前数组句柄
51
+ */
52
+ arrayHandle?: NestedArrayHandle;
53
+ /**
54
+ * 是否禁用运行时变更
55
+ */
56
+ safeMutations?: boolean;
57
+ };
58
+ type PublicArraySchemaRuntimeOptions = Omit<ArraySchemaRuntimeOptions, "safeMutations">;
59
+ /** 从数组路径提取父行路径 */
60
+ export declare function resolveParentItemPathFromArrayPath(arrayPath: string): string | undefined;
61
+ /** 创建数组 schema 运行时上下文 */
62
+ export declare function createArraySchemaContext(options: PublicArraySchemaRuntimeOptions): ArraySchemaContext;
63
+ /** 统一解析数组字段的 schema(支持静态数组和函数) */
64
+ export declare function resolveArraySchemasForRuntime(options: PublicArraySchemaRuntimeOptions): FormSchema[];
65
+ export declare function resolveArrayFieldInitialValueWithRuntime(item: FormSchema, options: Omit<PublicArraySchemaRuntimeOptions, "item" | "row" | "index" | "arrayLength" | "itemPath"> & {
66
+ row?: Record<string, unknown>;
67
+ index?: number;
68
+ arrayLength?: number;
69
+ }): unknown;
11
70
  /**
12
71
  * 解析 useArraySchema 字段的 initialValues
13
72
  * - 有 defaultValue 数组:沿用并在每行合并静态 arraySchema 嵌套默认值
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 弹窗 ESC 栈管理器
3
+ *
4
+ * 解决 element-plus ElDialog 两个问题:
5
+ * 1. 多个弹窗同时打开时,按 ESC 会一次性关闭所有弹窗。
6
+ * 期望:按一次 ESC 只关闭最顶层(最后打开)的弹窗,逐个关闭。
7
+ * 2. 弹窗内表单元素(input / select 等)聚焦时按 ESC 也会关闭弹窗。
8
+ * vue2 的 element-ui 不存在该问题。
9
+ * 期望:焦点位于表单交互元素上时,ESC 交给该元素处理(如关闭下拉),不关闭弹窗。
10
+ *
11
+ * 实现方式:在 ElDialog 上禁用原生 close-on-press-escape,由本管理器统一处理。
12
+ */
13
+ export interface ModalStackItem {
14
+ /** 弹窗实例 uid */
15
+ uid: number;
16
+ /** 关闭弹窗的回调 */
17
+ close: () => void;
18
+ }
19
+ /**
20
+ * 弹窗打开时入栈,并确保全局监听已绑定。
21
+ */
22
+ export declare function pushModal(item: ModalStackItem): void;
23
+ /**
24
+ * 弹窗关闭时出栈,栈为空时解绑全局监听。
25
+ */
26
+ export declare function removeModal(uid: number): void;
@@ -14,7 +14,9 @@ export declare const TtNavAnchor: import('../../../../utils/src').SFCWithInstall
14
14
  modelValue: string;
15
15
  position: "fixed" | "static" | "sticky";
16
16
  badgeCounts: Record<string, number>;
17
+ teleportTo: string | HTMLElement;
17
18
  }, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
19
+ sourceRef: HTMLSpanElement;
18
20
  navRef: HTMLDivElement;
19
21
  headerRef: HTMLDivElement;
20
22
  }, any, import('vue').ComponentProvideOptions, {
@@ -36,6 +38,7 @@ export declare const TtNavAnchor: import('../../../../utils/src').SFCWithInstall
36
38
  modelValue: string;
37
39
  position: "fixed" | "static" | "sticky";
38
40
  badgeCounts: Record<string, number>;
41
+ teleportTo: string | HTMLElement;
39
42
  }>;
40
43
  __isFragment?: never;
41
44
  __isTeleport?: never;
@@ -55,6 +58,7 @@ export declare const TtNavAnchor: import('../../../../utils/src').SFCWithInstall
55
58
  modelValue: string;
56
59
  position: "fixed" | "static" | "sticky";
57
60
  badgeCounts: Record<string, number>;
61
+ teleportTo: string | HTMLElement;
58
62
  }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
59
63
  $slots: Readonly<{
60
64
  description?: (scope: import('.').NavAnchorItemScope) => import('vue').VNodeChild;
@@ -10,6 +10,7 @@ declare function __VLS_template(): {
10
10
  description?: (scope: NavAnchorItemScope) => VNodeChild;
11
11
  };
12
12
  refs: {
13
+ sourceRef: HTMLSpanElement;
13
14
  navRef: HTMLDivElement;
14
15
  headerRef: HTMLDivElement;
15
16
  };
@@ -31,7 +32,9 @@ declare const __VLS_component: import('vue').DefineComponent<TtNavAnchorProps, {
31
32
  modelValue: string;
32
33
  position: "fixed" | "static" | "sticky";
33
34
  badgeCounts: Record<string, number>;
35
+ teleportTo: string | HTMLElement;
34
36
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
37
+ sourceRef: HTMLSpanElement;
35
38
  navRef: HTMLDivElement;
36
39
  headerRef: HTMLDivElement;
37
40
  }, any>;
@@ -37,4 +37,6 @@ export interface TtNavAnchorProps {
37
37
  left?: number | string;
38
38
  /** fixed/sticky 时距底部的距离 */
39
39
  bottom?: number | string;
40
+ /** Teleport 挂载目标,未传时默认使用组件内置策略 */
41
+ teleportTo?: string | HTMLElement;
40
42
  }