@dazhicheng/ui 1.5.149 → 1.5.151

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.
@@ -1,9 +1,11 @@
1
1
  import { FormState, GenericObject, ResetFormOpts, ValidationOptions } from 'vee-validate';
2
2
  import { ComponentPublicInstance } from 'vue';
3
3
  import { Recordable, StateHandler } from '../../../../../utils/src';
4
- import { FormActions, FormSchema, TtFormProps } from './types';
4
+ import { FormActions, FormArrayActions, FormSchema, NestedArrayHandle, TtFormProps } from './types';
5
5
  import { FieldArrayContext } from './types/forms';
6
6
  import { Store } from './shared/store';
7
+ export type { ArrayPathSegment } from './utils/array-path';
8
+ export { buildArrayFieldPath } from './utils/array-path';
7
9
  export declare class FormApi {
8
10
  form: FormActions;
9
11
  isMounted: boolean;
@@ -208,22 +210,19 @@ export declare class FormApi {
208
210
  swap: (name: string, indexA: number, indexB: number) => void | undefined;
209
211
  /**
210
212
  * @description 获取嵌套数组路径下的操作器
211
- * @param parentPath 父数组路径(如 actions.data)
213
+ * @param parentPath 父数组路径(如 actions.data),或完整路径(仅传 path
212
214
  * @param index 父数组索引
213
215
  * @param childField 子数组字段名(如 skills)
214
216
  */
215
- at: <TValue = unknown>(parentPath: string, index: number, childField: string) => {
216
- path: string;
217
- get: () => Readonly<FieldArrayContext<TValue>> | undefined;
218
- push: (value: TValue) => void | undefined;
219
- remove: (idx: number) => void | undefined;
220
- replace: (values: TValue[]) => void | undefined;
221
- update: (idx: number, value: TValue) => void | undefined;
222
- insert: (idx: number, value: TValue) => void | undefined;
223
- prepend: (value: TValue) => void | undefined;
224
- move: (oldIdx: number, newIdx: number) => void | undefined;
225
- swap: (indexA: number, indexB: number) => void | undefined;
226
- };
217
+ at: FormArrayActions["at"];
227
218
  };
228
219
  private _getArrayFieldActions;
220
+ /**
221
+ * @description 创建嵌套数组操作器(在原 inline 实现基础上支持链式 `.at`)
222
+ */
223
+ private _createNestedArrayHandle;
224
+ /**
225
+ * @description 包装嵌套操作器,变更后执行回调(供 GroupFormApi 同步导航错误)
226
+ */
227
+ protected _wrapNestedArrayHandle<TValue = unknown>(nested: NestedArrayHandle<TValue>, afterMutate: () => void): NestedArrayHandle<TValue>;
229
228
  }
@@ -282,22 +282,13 @@ export declare class GroupFormApi extends FormApi {
282
282
  swap: (name: string, indexA: number, indexB: number) => void;
283
283
  /**
284
284
  * @description 获取嵌套数组路径下的操作器
285
- * @param parentPath 父数组路径
285
+ * @param parentPath 父数组路径,或完整路径(仅传 path)
286
286
  * @param index 父数组索引
287
287
  * @param childField 子数组字段名
288
- * @returns 嵌套数组操作器
289
288
  */
290
- at: <TValue = unknown>(parentPath: string, index: number, childField: string) => {
291
- path: string;
292
- get: () => Readonly<import('../types').FieldArrayContext<TValue>> | undefined;
293
- push: (value: TValue) => void;
294
- remove: (idx: number) => void;
295
- replace: (values: TValue[]) => void;
296
- update: (idx: number, value: TValue) => void;
297
- insert: (idx: number, value: TValue) => void;
298
- prepend: (value: TValue) => void;
299
- move: (oldIdx: number, newIdx: number) => void;
300
- swap: (indexA: number, indexB: number) => void;
289
+ at: {
290
+ <TValue = unknown>(fullPath: string): import('../types').NestedArrayHandle<TValue>;
291
+ <TValue = unknown>(parentPath: string, index: number, childField: string): import('../types').NestedArrayHandle<TValue>;
301
292
  };
302
293
  };
303
294
  unmount(): void;
@@ -52,11 +52,16 @@ type NavAnchorPropsBase = Omit<Partial<TtNavAnchorProps>, "items" | "modelValue"
52
52
  /**
53
53
  * useGroupForm 调用方传入的导航配置;`badgeCounts` 由 formApi 内部注入,调用方无需传入。
54
54
  */
55
- export type UseGroupFormNavAnchorProps = Omit<NavAnchorPropsBase, "badgeCounts">;
55
+ export type UseGroupFormNavAnchorProps = Omit<NavAnchorPropsBase, "badgeCounts"> & {
56
+ /**
57
+ * 额外错误徽标数(如自定义插槽内的校验错误),按分组 key 与 {@link GroupFormApi.navErrorCounts} 累加后展示在导航栏
58
+ */
59
+ extraBadgeCounts?: Record<string, number>;
60
+ };
56
61
  /**
57
- * VirtualGroupForm 组件接收的导航配置;`badgeCounts` useGroupForm 绑定 `api.navErrorCounts` 注入。
62
+ * VirtualGroupForm 组件接收的导航配置;`badgeCounts` 由组件内合并 `navErrorCounts` `extraBadgeCounts` 注入。
58
63
  */
59
- export type GroupFormNavAnchorProps = NavAnchorPropsBase;
64
+ export type GroupFormNavAnchorProps = UseGroupFormNavAnchorProps;
60
65
  /** 分组表单组件选项 */
61
66
  export interface UseGroupFormOptions extends Omit<TtFormProps, "schema" | "showDefaultActions"> {
62
67
  schema: GroupFormSchema[];
@@ -70,7 +75,7 @@ export interface UseGroupFormOptions extends Omit<TtFormProps, "schema" | "showD
70
75
  estimateFieldHeight?: number;
71
76
  /**
72
77
  * 悬浮导航锚点:是否显示、标题、定位等;默认 `{ show: true, title: '导航' }`。
73
- * `badgeCounts` 由 formApi 维护,无需在此传入。
78
+ * `badgeCounts` 由 formApi 维护;自定义插槽等额外错误可通过 `extraBadgeCounts` 按分组 key 传入。
74
79
  */
75
80
  navAnchorProps?: UseGroupFormNavAnchorProps;
76
81
  /** 滚动到分组时的顶部偏移量(px),用于补偿页面顶部固定元素(如 header)的遮挡,默认 0 */
@@ -72,7 +72,34 @@ export interface FormArrayActions {
72
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
+ /**
76
+ * 嵌套数组操作器
77
+ * - 三参数:与原先一致 `at(parentPath, index, childField)`
78
+ * - 单参数:完整路径 `at('actions.data[0].skills')`
79
+ * - 返回值可链式 `.at(index, field)` 进入更深层
80
+ */
81
+ at: {
82
+ <TValue = unknown>(fullPath: string): NestedArrayHandle<TValue>;
83
+ <TValue = unknown>(parentPath: string, index: number, childField: string): NestedArrayHandle<TValue>;
84
+ };
75
85
  }
86
+ /** `arrayAction.at` 返回值,多层嵌套可链式 `.at(index, field)` */
87
+ export type NestedArrayHandle<TValue = unknown> = {
88
+ path: string;
89
+ get: () => Readonly<FieldArrayContext<TValue>> | undefined;
90
+ push: (value: TValue) => void;
91
+ remove: (idx: number) => void;
92
+ replace: (values: TValue[]) => void;
93
+ update: (idx: number, value: TValue) => void;
94
+ insert: (idx: number, value: TValue) => void;
95
+ prepend: (value: TValue) => void;
96
+ move: (oldIdx: number, newIdx: number) => void;
97
+ swap: (indexA: number, indexB: number) => void;
98
+ /** 进入下一层嵌套数组,如 `.at(0, 'skills').at(1, 'items')` */
99
+ at: (index: number, childField: string) => NestedArrayHandle<TValue>;
100
+ };
101
+ export type { ArrayPathSegment } from './utils/array-path';
102
+ export { buildArrayFieldPath } from './utils/array-path';
76
103
  export type FormActions = FormContext<GenericObject> & {
77
104
  arrayAction?: FormArrayActions;
78
105
  };
@@ -495,4 +522,3 @@ export interface TtFormAdapterOptions<T extends BaseFormComponentType = BaseForm
495
522
  * @template P - 自定义组件的 Props 类型(可选,用于自定义组件类型推断)
496
523
  */
497
524
  export type InferredComponentPropsType<T extends BaseFormComponentType | Component, P = never> = T extends BaseFormComponentType ? Partial<BaseFormComponentMap[T]> & MaybeComponentProps : [P] extends [never] ? MaybeComponentProps : Partial<P> & MaybeComponentProps;
498
- export {};
@@ -1,8 +1,16 @@
1
+ /** 一层嵌套:父路径 + 行索引 + 子字段名 */
2
+ export type ArrayPathSegment = readonly [index: number, field: string];
1
3
  /**
2
- * 拼接数组子路径
3
- * @param parentPath 父数组路径
4
- * @param index 父数组索引
5
- * @param childField 子数组字段名
6
- * @returns 嵌套数组完整路径
4
+ * 拼接数组子路径;仅传 parentPath 时原样返回(完整路径)
5
+ * @returns `actions.data[0].skills`
7
6
  */
8
- export declare function childArrayPath(parentPath: string, index: number, childField: string): string;
7
+ export declare function childArrayPath(parentPath: string, index?: number, childField?: string): string;
8
+ /**
9
+ * 从根数组路径连续拼接多层嵌套路径
10
+ * @param rootPath 根数组 fieldName,如 `actions.data`
11
+ * @param segments 每层 `[行索引, 子数组字段名]`
12
+ * @example
13
+ * buildArrayFieldPath('actions.data', [0, 'skills'], [1, 'items'])
14
+ * // => 'actions.data[0].skills[1].items'
15
+ */
16
+ export declare function buildArrayFieldPath(rootPath: string, ...segments: ArrayPathSegment[]): string;
@@ -0,0 +1,37 @@
1
+ import { Component, VNode, MaybeRefOrGetter } from 'vue';
2
+ import { ComponentCaptureOptions, ElementScreenshotOptions, ScreenshotTarget } from '../../../hooks/src';
3
+ import { OssSignatureResult } from '../components/tt-upload/src/typing';
4
+ export interface ScreenshotOssOptions extends ElementScreenshotOptions {
5
+ /** OSS 目录前缀,不传则使用签名接口返回的 dir 或 notice */
6
+ ossDir?: string;
7
+ /** 上传文件名,默认 screenshot-{timestamp}.png / .jpg */
8
+ fileName?: string;
9
+ /** 获取 OSS 签名,不传则使用全局 setup 的 uploadOssApi */
10
+ uploadOssApi?: (file: File) => Promise<OssSignatureResult>;
11
+ }
12
+ export interface ScreenshotOssResult {
13
+ blob: Blob;
14
+ file: File;
15
+ ossKey: string;
16
+ }
17
+ export interface ScreenshotOssDataUrlResult extends ScreenshotOssResult {
18
+ dataUrl: string;
19
+ }
20
+ /** 离屏组件截图 + OSS 上传配置 */
21
+ export type ScreenshotOssComponentOptions = ScreenshotOssOptions & ComponentCaptureOptions;
22
+ /**
23
+ * @description 元素截图并上传 OSS,依赖全局 setup 的 uploadOssApi
24
+ */
25
+ export declare function useScreenshotOss(): {
26
+ captureToBlob: (target: MaybeRefOrGetter<ScreenshotTarget>, options?: ScreenshotOssOptions) => Promise<ScreenshotOssResult>;
27
+ captureToDataUrl: (target: MaybeRefOrGetter<ScreenshotTarget>, options?: ScreenshotOssOptions) => Promise<ScreenshotOssDataUrlResult>;
28
+ captureComponent: {
29
+ (component: Component | VNode, options: ScreenshotOssComponentOptions & {
30
+ output?: "dataUrl";
31
+ }): Promise<ScreenshotOssDataUrlResult>;
32
+ (component: Component | VNode, options: ScreenshotOssComponentOptions & {
33
+ output: "blob";
34
+ }): Promise<ScreenshotOssResult>;
35
+ };
36
+ isCapturing: import('vue').Ref<boolean, boolean>;
37
+ };
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ export { useFormSchemasLink } from './hooks/useFormSchemasLink';
26
26
  export { useDataPermissionOptions } from './hooks/useDataPermissionOptions';
27
27
  export { useFormat } from './hooks/useFormat';
28
28
  export { useLoading } from './hooks/useLoading';
29
+ export { useScreenshotOss, type ScreenshotOssComponentOptions, type ScreenshotOssDataUrlResult, type ScreenshotOssOptions, type ScreenshotOssResult, } from './hooks/useScreenshotOss';
29
30
  export { setXHR };
30
31
  /**
31
32
  * 表单组件适配器