@dazhicheng/ui 1.5.159 → 1.5.160

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.
@@ -10,7 +10,7 @@ type TtFormSchema = FormSchema<BaseFormComponentType>;
10
10
  type TtFormRenderProps = FormRenderProps<BaseFormComponentType>;
11
11
  type TtExtendedFormApi = ExtendedFormApi;
12
12
  export type { ArraySchemaContext, BaseFormComponentMap, BaseFormComponentType, FormArrayActions, FormSlotSchema, InferredComponentPropsType, NestedArrayHandle, } from './src/types';
13
- export type { FieldArrayContext, FieldEntry, ResolvedFieldArrayContext } from './src/types/forms';
13
+ export type { FieldArrayContext, FieldEntry, ReadonlyFieldEntry, ResolvedFieldArrayContext } from './src/types/forms';
14
14
  export type { TtExtendedFormApi, TtFormProps, TtFormRenderProps, TtFormSchema };
15
15
  export * as z from 'zod';
16
16
  export { useGroupForm } from './src/group-form';
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { PartialDeep } from 'type-fest';
3
- import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, UnwrapRef } from 'vue';
3
+ import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
4
4
  import { FlattenAndSetPathsType, GenericObject, MapValuesPathsToRefs, MaybeArray, MaybePromise } from './common';
5
5
  import { Path, PathValue } from './paths';
6
6
  import { FieldValidationMetaInfo } from './shared';
@@ -88,14 +88,26 @@ export type PathState<TInput = unknown, TOutput = TInput> = {
88
88
  validate?: FieldValidator<TOutput>;
89
89
  };
90
90
  export type { FieldEntry };
91
+ /** 递归只读,用于 `arrayAction.get()` 返回的 `fields[].value` */
92
+ export type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
93
+ readonly [K in keyof T]: DeepReadonly<T[K]>;
94
+ } : T;
95
+ /** `arrayAction.get()` 返回的数组项(只读快照,不可改 `value` 及其嵌套字段) */
96
+ export type ReadonlyFieldEntry<TValue = unknown> = {
97
+ readonly value: DeepReadonly<TValue>;
98
+ readonly key: string | number;
99
+ readonly isFirst: boolean;
100
+ readonly isLast: boolean;
101
+ };
91
102
  /** vee-validate 原始数组上下文(`fields` 为 Ref,用于 `useFieldArray` / 注册表) */
92
103
  export type ResolvedFieldArrayContext<TValue = unknown> = VeeFieldArrayContext<TValue>;
93
104
  /**
94
105
  * 经 FormApi `reactive(Map)` 读取时的数组上下文。
95
106
  * `fields` 在运行时由 Vue reactive 自动解包,用法与 vee-validate `<FieldArray>` 插槽一致(`fields.length` / `v-for`)。
107
+ * `fields` 为只读快照:不可 `push/splice`,也不可改 `fields[i].value` 及其嵌套字段;增删改请用 `arrayAction` / `arrayHandle`。
96
108
  */
97
109
  export type FieldArrayContext<TValue = unknown> = Omit<ResolvedFieldArrayContext<TValue>, "fields"> & {
98
- fields: UnwrapRef<ResolvedFieldArrayContext<TValue>["fields"]>;
110
+ readonly fields: ReadonlyArray<ReadonlyFieldEntry<TValue>>;
99
111
  };
100
112
  /**
101
113
  * 将注册表中的 `ResolvedFieldArrayContext` 转为对外 `FieldArrayContext`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.5.159",
3
+ "version": "1.5.160",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -47,8 +47,8 @@
47
47
  "sortablejs": "^1.15.7",
48
48
  "vee-validate": "^4.15.1",
49
49
  "zod": "^4.3.6",
50
- "@dazhicheng/hooks": "1.4.39",
51
- "@dazhicheng/utils": "1.3.38"
50
+ "@dazhicheng/utils": "1.3.38",
51
+ "@dazhicheng/hooks": "1.4.39"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@element-plus/icons-vue": "^2.3.2",