@dazhicheng/ui 1.5.159 → 1.5.161

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';
@@ -2,7 +2,7 @@ import { PropType } from 'vue';
2
2
  import { Recordable } from '../../../../../../utils/src';
3
3
  import { FieldEntry } from '../types/forms';
4
4
  import { ArraySchemaContext, FormSchema } from '../types';
5
- type ArraySchemaProp = FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx?: ArraySchemaContext) => FormSchema[]);
5
+ type ArraySchemaProp = FormSchema[] | ((entry: FieldEntry<Recordable>, currentIndex: number, ctx: ArraySchemaContext) => FormSchema[]);
6
6
  declare const FormArrayRegister: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
7
7
  fieldName: {
8
8
  type: PropType<string>;
@@ -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/dist/index.js CHANGED
@@ -49326,7 +49326,7 @@ const tx = /* @__PURE__ */ be({
49326
49326
  }), f = k(() => {
49327
49327
  var p;
49328
49328
  return (p = h.value) == null ? void 0 : p.arrayAction;
49329
- }), A = An(new Proxy({}, {
49329
+ }), A = An(new Proxy(u.value, {
49330
49330
  /**
49331
49331
  * @param _target 代理目标(空对象,不实际存储)
49332
49332
  * @param key 属性名
@@ -49342,7 +49342,13 @@ const tx = /* @__PURE__ */ be({
49342
49342
  * @returns 是否设置成功
49343
49343
  */
49344
49344
  set(p, m, v) {
49345
- return rt(u.value, m, v), c == null || c.validateField(m), !0;
49345
+ return rt(u.value, m, v), c == null || c.validateField(String(m)), !0;
49346
+ },
49347
+ ownKeys() {
49348
+ return Reflect.ownKeys(u.value);
49349
+ },
49350
+ getOwnPropertyDescriptor(p, m) {
49351
+ return Object.getOwnPropertyDescriptor(u.value, m);
49346
49352
  }
49347
49353
  }));
49348
49354
  return a(o), Zi(l), () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.5.159",
3
+ "version": "1.5.161",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",