@schemx/vue 0.1.21 → 0.1.22

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 (43) hide show
  1. package/README.md +12 -12
  2. package/dist/components/FormGroup/index.d.ts +1 -1
  3. package/dist/components/FormItem/index.d.ts +1 -1
  4. package/dist/components/FormItem/index.d.ts.map +1 -1
  5. package/dist/hocs/index.d.ts +0 -1
  6. package/dist/hocs/index.d.ts.map +1 -1
  7. package/dist/hocs/withRemoteOptions.d.ts +3 -3
  8. package/dist/hocs/withRemoteOptions.d.ts.map +1 -1
  9. package/dist/hooks/index.d.ts +5 -7
  10. package/dist/hooks/index.d.ts.map +1 -1
  11. package/dist/hooks/useContext.d.ts +15 -3
  12. package/dist/hooks/useContext.d.ts.map +1 -1
  13. package/dist/hooks/useDictionary.d.ts +11 -4
  14. package/dist/hooks/useDictionary.d.ts.map +1 -1
  15. package/dist/hooks/useEffect.d.ts +1 -1
  16. package/dist/hooks/useField.d.ts +32 -1
  17. package/dist/hooks/useField.d.ts.map +1 -1
  18. package/dist/hooks/useForm.d.ts +4 -4
  19. package/dist/hooks/useForm.d.ts.map +1 -1
  20. package/dist/hooks/useViewSchemas.d.ts +1 -1
  21. package/dist/hooks/useWatch.d.ts +1 -1
  22. package/dist/index.cjs +6 -1
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.ts +4 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.mjs +2591 -1081
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/types/dictionary.d.ts +150 -0
  29. package/dist/types/dictionary.d.ts.map +1 -0
  30. package/dist/types/field.d.ts +1 -1
  31. package/dist/types/form.d.ts +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/utils/dynamic.d.ts +1 -1
  35. package/dist/utils/helpers.d.ts +1 -1
  36. package/dist/utils/rendererProvider.d.ts +1 -1
  37. package/dist/utils/rulesProvider.d.ts +1 -1
  38. package/dist/utils/validation.d.ts +1 -1
  39. package/package.json +2 -2
  40. package/dist/hooks/useFieldContext.d.ts +0 -23
  41. package/dist/hooks/useFieldContext.d.ts.map +0 -1
  42. package/dist/index.umd.js +0 -2
  43. package/dist/index.umd.js.map +0 -1
package/README.md CHANGED
@@ -119,18 +119,18 @@ rendererRegistry.register("input", InputRenderer)
119
119
 
120
120
  ## Composition API
121
121
 
122
- | API | 说明 |
123
- | ------------------- | --------------------------------------------- |
124
- | `useForm()` | 创建表单实例,并通过 Vue context 提供给子组件 |
125
- | `useField()` | 获取字段级读写、校验和状态能力 |
126
- | `useWatch()` | 监听字段变化 |
127
- | `useWatchField()` | 监听单个字段 |
128
- | `useWatchFields()` | 监听多个字段 |
129
- | `useWatchAll()` | 监听整张表单 |
130
- | `useDictionary()` | 管理依赖字段的远程或本地选项 |
131
- | `useContext()` | 获取表单上下文 |
132
- | `useEffect()` | 创建字段依赖追踪 effect |
133
- | `useFieldContext()` | 获取当前字段上下文 |
122
+ | API | 说明 |
123
+ | -------------------- | --------------------------------------------- |
124
+ | `useForm()` | 创建表单实例,并通过 Vue context 提供给子组件 |
125
+ | `useField()` | 获取字段级读写、校验和状态能力 |
126
+ | `useWatch()` | 监听字段变化 |
127
+ | `useWatchField()` | 监听单个字段 |
128
+ | `useWatchFields()` | 监听多个字段 |
129
+ | `useWatchAll()` | 监听整张表单 |
130
+ | `useDictionary()` | 管理依赖字段的远程或本地选项 |
131
+ | `useConfigContext()` | 获取表单上下文 |
132
+ | `useEffect()` | 创建字段依赖追踪 effect |
133
+ | `useFieldContext()` | 获取当前字段上下文 |
134
134
 
135
135
  ## Adapter 边界
136
136
 
@@ -1,4 +1,4 @@
1
- import { SchemxViewGroupSchema, Values } from '@schemx/core';
1
+ import { SchemxViewGroupSchema, Values } from '../../../../core/src/index.ts';
2
2
 
3
3
  /**
4
4
  * FormGroup Props
@@ -1,4 +1,4 @@
1
- import { SchemxViewSchema, Values } from '@schemx/core';
1
+ import { SchemxViewSchema, Values } from '../../../../core/src/index.ts';
2
2
 
3
3
  /**
4
4
  * FormItem 属性。
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsBH,OAAO,KAAK,EAOV,gBAAgB,EAChB,MAAM,EACP,MAAM,cAAc,CAAA;AAErB;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAC5B;AAED,QAAA,MAAM,QAAQ;;;;kCAwPb,CAAA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,OAAO,KAAK,EAMV,gBAAgB,EAChB,MAAM,EACP,MAAM,cAAc,CAAA;AAErB;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAC5B;AAED,QAAA,MAAM,QAAQ;;;;kCAkOb,CAAA;AAED,eAAe,QAAQ,CAAA"}
@@ -6,5 +6,4 @@
6
6
  * @module hocs
7
7
  */
8
8
  export { WithRemoteOptions } from './withRemoteOptions';
9
- export type { SchemxDictionary, SchemxWithDictionary } from './withRemoteOptions';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hocs/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import { Component, PropType } from 'vue';
2
- import { NamePath, SchemxDictionary } from '@schemx/core';
2
+ import { SchemxDictionary } from '../types/dictionary';
3
+ import { NamePath } from '../../../core/src/index.ts';
3
4
 
4
- export type { SchemxDictionary, SchemxWithDictionary } from '@schemx/core';
5
5
  /**
6
6
  * WithRemoteOptions 注入给被包装组件的额外 Props
7
7
  */
@@ -67,7 +67,7 @@ export declare function WithRemoteOptions(WrappedComponent: Component): import('
67
67
  default: undefined;
68
68
  };
69
69
  }>> & Readonly<{}>, {
70
- dict: SchemxDictionary<import('@schemx/core').Values, any>;
70
+ dict: SchemxDictionary<import('../../../core/src/index.ts').Values, any>;
71
71
  fieldName: string;
72
72
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
73
73
  export default WithRemoteOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"withRemoteOptions.d.ts","sourceRoot":"","sources":["../../src/hocs/withRemoteOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAgC,QAAQ,EAAgB,MAAM,KAAK,CAAA;AAIrF,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE9D,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE1E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,cAAc;IACd,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,WAAW;IACX,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,SAAS;;cAMrC,QAAQ,CAAC,gBAAgB,CAAC;;;;cAIjB,QAAQ,CAAC,QAAQ,CAAC;;;;;;;cAJ3B,QAAQ,CAAC,gBAAgB,CAAC;;;;cAIjB,QAAQ,CAAC,QAAQ,CAAC;;;;;;6EAoBlD;AAED,eAAe,iBAAiB,CAAA"}
1
+ {"version":3,"file":"withRemoteOptions.d.ts","sourceRoot":"","sources":["../../src/hocs/withRemoteOptions.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAgC,QAAQ,EAAgB,MAAM,KAAK,CAAA;AAErF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAG5C;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,cAAc;IACd,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,WAAW;IACX,OAAO,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,SAAS;;cAMrC,QAAQ,CAAC,gBAAgB,CAAC;;;;cAIjB,QAAQ,CAAC,QAAQ,CAAC;;;;;;;cAJ3B,QAAQ,CAAC,gBAAgB,CAAC;;;;cAIjB,QAAQ,CAAC,QAAQ,CAAC;;;;;;6EAoBlD;AAED,eAAe,iBAAiB,CAAA"}
@@ -4,21 +4,19 @@
4
4
  * @module hooks
5
5
  */
6
6
  /** useForm - 表单状态管理 */
7
- export { useForm } from './useForm';
7
+ export { useForm, useFormContext } from './useForm';
8
8
  /** useField - 单字段控制 */
9
- export { useField } from './useField';
9
+ export { useField, createFieldContext, useFieldContext } from './useField';
10
10
  /** useWatch - 字段变化监听 */
11
11
  export { useWatch, useWatchField, useWatchFields, useWatchAll } from './useWatch';
12
12
  /** useEffect - 通用 Signal effect */
13
13
  export { useEffect } from './useEffect';
14
14
  /** useDictionary - 字典选项加载 */
15
- export { useDictionary, type SchemxDictionary, type SchemxWithDictionary, type UseDictOptionsReturn, } from './useDictionary';
16
- /** useContext - 表单上下文注入与消费 */
17
- export { type FormContextProps, useContext } from './useContext';
15
+ export { useDictionary, type SchemxDictionary, type SchemxWithDictionary, type UseDictionaryReturn, } from './useDictionary';
16
+ /** useConfigContext - 表单上下文注入与消费 */
17
+ export { createConfigContext, useConfigContext, type FormContextProps, } from './useContext';
18
18
  /** useStableRef - 引用稳定化的 shallowRef */
19
19
  export { useStableRef } from './useStableRef';
20
20
  /** useViewSchemas - ViewSchemas Vue 桥接 */
21
21
  export { useViewSchemas } from './useViewSchemas';
22
- /** useFieldContext - 字段上下文注入与消费 */
23
- export { useFieldContext } from './useFieldContext';
24
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uBAAuB;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,uBAAuB;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,wBAAwB;AACxB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEjF,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAA;AAExB,8BAA8B;AAC9B,OAAO,EAAE,KAAK,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEhE,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,0CAA0C;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,mCAAmC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,uBAAuB;AACvB,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAEnD,uBAAuB;AACvB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE1E,wBAAwB;AACxB,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEjF,mCAAmC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,iBAAiB,CAAA;AAExB,oCAAoC;AACpC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,gBAAgB,GACtB,MAAM,cAAc,CAAA;AAErB,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,0CAA0C;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { SchemxFormProps } from '../types';
2
- import { Values } from '@schemx/core';
2
+ import { Values } from '../../../core/src/index.ts';
3
3
 
4
4
  /** FormContext 注入 key */
5
5
  export declare const FORM_CONTEXT_KEY: unique symbol;
@@ -20,6 +20,12 @@ export interface FormContextProps<T extends Values = Values> extends Omit<Schemx
20
20
  * @typeParam T - 表单值类型
21
21
  * @param props - 表单上下文属性
22
22
  */
23
+ export declare const createConfigContext: <T extends Values = Values>(props: FormContextProps<T>) => void;
24
+ /**
25
+ * @deprecated
26
+ *
27
+ * 已弃用,请使用 **createConfigContext**
28
+ */
23
29
  export declare const createContext: <T extends Values = Values>(props: FormContextProps<T>) => void;
24
30
  /**
25
31
  * 获取表单上下文配置
@@ -32,9 +38,15 @@ export declare const createContext: <T extends Values = Values>(props: FormConte
32
38
  *
33
39
  * @example
34
40
  * ```ts
35
- * const context = useContext()
41
+ * const context = useConfigContext()
36
42
  * console.log(context.readonly, context.disabled)
37
43
  * ```
38
44
  */
39
- export declare function useContext(): FormContextProps;
45
+ export declare function useConfigContext(): FormContextProps;
46
+ /**
47
+ * @deprecated
48
+ *
49
+ * 已弃用,请使用 **useConfigContext**
50
+ */
51
+ export declare const useContext: typeof useConfigContext;
40
52
  //# sourceMappingURL=useContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,yBAAyB;AACzB,eAAO,MAAM,gBAAgB,eAAwB,CAAA;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CACvE,eAAe,CAAC,CAAC,CAAC,EAChB,MAAM,GACN,YAAY,GACZ,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,UAAU,GACV,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CACnB;CAAG;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,OAAO,gBAAgB,CAAC,CAAC,CAAC,SAElF,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CAQ7C"}
1
+ {"version":3,"file":"useContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,yBAAyB;AACzB,eAAO,MAAM,gBAAgB,eAAwB,CAAA;AAErD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CACvE,eAAe,CAAC,CAAC,CAAC,EAChB,MAAM,GACN,YAAY,GACZ,kBAAkB,GAClB,qBAAqB,GACrB,gBAAgB,GAChB,UAAU,GACV,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CACnB;CAAG;AAEJ;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,EAC3D,OAAO,gBAAgB,CAAC,CAAC,CAAC,SAG3B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAXU,CAAC,SAAS,MAAM,kBAC3C,gBAAgB,CAAC,CAAC,CAAC,SAUoB,CAAA;AAEhD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,IAAI,gBAAgB,CAQnD;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,yBAAmB,CAAA"}
@@ -1,11 +1,12 @@
1
1
  import { Ref } from 'vue';
2
- import { NamePath, SchemxDictionary, Values } from '@schemx/core';
2
+ import { SchemxDictionary } from '../types/dictionary';
3
+ import { NamePath, Values } from '../../../core/src/index.ts';
3
4
 
4
- export type { SchemxDictionary, SchemxWithDictionary } from '@schemx/core';
5
+ export type { SchemxDictionary, SchemxWithDictionary } from '../types/dictionary';
5
6
  /**
6
7
  * useDictionary 返回值
7
8
  */
8
- export interface UseDictOptionsReturn {
9
+ export interface UseDictionaryReturn {
9
10
  /** 远程加载的字典选项列表(响应式) */
10
11
  list: Ref<any[]>;
11
12
  /** 请求加载状态(响应式) */
@@ -19,6 +20,12 @@ export interface UseDictOptionsReturn {
19
20
  /** 直接修改 list 的值,不触发 api 调用 */
20
21
  mutate: (data: any[]) => void;
21
22
  }
23
+ /**
24
+ * @deprecated
25
+ *
26
+ * 已弃用,请使用 **UseDictionaryReturn**
27
+ */
28
+ export type UseDictOptionsReturn = UseDictionaryReturn;
22
29
  /**
23
30
  * 将未知抛出值规范化为 `Error` 实例
24
31
  *
@@ -58,6 +65,6 @@ export declare function normalizeError(err: unknown): Error;
58
65
  * }, 'city')
59
66
  * ```
60
67
  */
61
- export declare const useDictionary: <TValues extends Values = Values, TName extends NamePath<TValues> = NamePath<TValues>>(options: SchemxDictionary<TValues>, fieldName?: TName) => UseDictOptionsReturn;
68
+ export declare const useDictionary: <TValues extends Values = Values, TName extends NamePath<TValues> = NamePath<TValues>>(options: SchemxDictionary<TValues>, fieldName?: TName) => UseDictionaryReturn;
62
69
  export default useDictionary;
63
70
  //# sourceMappingURL=useDictionary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.d.ts","sourceRoot":"","sources":["../../src/hooks/useDictionary.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAa,GAAG,EAAO,MAAM,KAAK,CAAA;AAKzC,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEtE,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE1E;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC,CAAA;IAChB,kBAAkB;IAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,kBAAkB;IAClB,KAAK,EAAE,GAAG,CAAC,KAAK,GAAG,SAAS,CAAC,CAAA;IAC7B,eAAe;IACf,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,qBAAqB;IACrB,OAAO,EAAE,MA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;IAC9B,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,CAAA;AAEtD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAIlD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/B,KAAK,SAAS,QAAQ,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAEnD,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAClC,YAAY,KAAK,KAChB,mBAmIF,CAAA;AAED,eAAe,aAAa,CAAA"}
@@ -1,4 +1,4 @@
1
- import { CreateEffectReturn, EffectCallback } from '@schemx/core';
1
+ import { CreateEffectReturn, EffectCallback } from '../../../core/src/index.ts';
2
2
 
3
3
  /**
4
4
  * 创建 Signal effect 并在组件卸载时自动取消。
@@ -1,5 +1,5 @@
1
1
  import { FieldInstance } from '../types/field';
2
- import { NamePath, Values } from '@schemx/core';
2
+ import { NamePath, Values } from '../../../core/src/index.ts';
3
3
 
4
4
  /**
5
5
  * 获取单个字段的控制能力
@@ -34,5 +34,36 @@ import { NamePath, Values } from '@schemx/core';
34
34
  * ```
35
35
  */
36
36
  export declare const useField: <TValues extends Values = Values>(name: NamePath<TValues>) => FieldInstance<TValues>;
37
+ /**
38
+ * 向子组件树注入当前字段上下文。
39
+ *
40
+ * 应在 FormItem(或任何创建了 useField 的组件)的 setup 中调用。
41
+ *
42
+ * @param field - useField 返回的字段实例
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // FormItem 中
47
+ * const field = useField('date')
48
+ * createFieldContext(field)
49
+ *
50
+ * ```
51
+ */
52
+ export declare function createFieldContext<TValues extends Values = Values>(field: FieldInstance<TValues>): void;
53
+ /**
54
+ * 从最近的 FormItem 获取当前字段上下文。
55
+ *
56
+ * 必须在 FormItem 的组件子树内调用,否则抛出错误。
57
+ *
58
+ * @returns useField 返回的字段实例
59
+ *
60
+ * @throws 当不在 FormItem 子树内时抛出
61
+ *
62
+ * @example
63
+ * const field = useFieldContext()
64
+ * field.error.value // string[] | undefined
65
+ * field.getValue() // 当前字段值(Vue 响应式)
66
+ */
67
+ export declare function useFieldContext(): ReturnType<typeof useField>;
37
68
  export default useField;
38
69
  //# sourceMappingURL=useField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,EAAE,MAAM,cAAc,CAAA;AAoEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACtD,MAAM,QAAQ,CAAC,OAAO,CAAC,KACtB,aAAa,CAAC,OAAO,CAuCvB,CAAA;AAED,eAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"useField.d.ts","sourceRoot":"","sources":["../../src/hooks/useField.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,EAAE,MAAM,cAAc,CAAA;AAuEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACtD,MAAM,QAAQ,CAAC,OAAO,CAAC,KACtB,aAAa,CAAC,OAAO,CAuCvB,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAChE,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAC5B,IAAI,CAEN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAAC,OAAO,QAAQ,CAAC,CAQ7D;AAED,eAAe,QAAQ,CAAA"}
@@ -1,4 +1,4 @@
1
- import { CreateFormOptions, NamePath, SchemxInstance, Values } from '@schemx/core';
1
+ import { CreateFormOptions, NamePath, SchemxInstance, Values } from '../../../core/src/index.ts';
2
2
 
3
3
  /** SchemxInstance 在 Vue provide/inject 中的注入 key */
4
4
  export declare const SCHEMX_INSTANCE_KEY: unique symbol;
@@ -37,7 +37,7 @@ export interface UseFormOptions<TValues extends Values> extends CreateFormOption
37
37
  * form.setFieldValue('name', 'John')
38
38
  * ```
39
39
  */
40
- export declare function useForm<TValues extends Values = Values>(options: UseFormOptions<TValues>): SchemxInstance<TValues>;
40
+ export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
41
41
  /**
42
42
  * 获取表单实例
43
43
  *
@@ -51,9 +51,9 @@ export declare function useForm<TValues extends Values = Values>(options: UseFor
51
51
  *
52
52
  * @example
53
53
  * ```ts
54
- * const form = useFormInstance()
54
+ * const form = useFormContext()
55
55
  * form.setFieldValue('name', 'hello')
56
56
  * ```
57
57
  */
58
- export declare function useFormInstance<TValues extends Values = Values>(): SchemxInstance<TValues>;
58
+ export declare function useFormContext<TValues extends Values = Values>(): SchemxInstance<TValues>;
59
59
  //# sourceMappingURL=useForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEvF,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,eAA4B,CAAA;AAC5D,0DAA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,5 +1,5 @@
1
1
  import { ShallowRef } from 'vue';
2
- import { SchemxInstance, SchemxViewSchema, Values } from '@schemx/core';
2
+ import { SchemxInstance, SchemxViewSchema, Values } from '../../../core/src/index.ts';
3
3
 
4
4
  export declare function useViewSchemas<T extends Values = Values>(form: SchemxInstance<T>): ShallowRef<readonly SchemxViewSchema<T>[]>;
5
5
  export default useViewSchemas;
@@ -1,4 +1,4 @@
1
- import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '@schemx/core';
1
+ import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '../../../core/src/index.ts';
2
2
 
3
3
  /**
4
4
  * 监听所有字段变化