@schemx/vue 0.1.22 → 0.2.1
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.
- package/README.md +37 -16
- package/dist/analyze.html +4949 -0
- package/dist/components/FormGroup/index.d.ts +1 -1
- package/dist/components/FormItem/index.d.ts +13 -6
- package/dist/components/FormItem/index.d.ts.map +1 -1
- package/dist/hocs/withRemoteOptions.d.ts +2 -2
- package/dist/hooks/index.d.ts +8 -4
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/provideFieldContext.d.ts +41 -0
- package/dist/hooks/provideFieldContext.d.ts.map +1 -0
- package/dist/hooks/provideFormConfigContext.d.ts +59 -0
- package/dist/hooks/provideFormConfigContext.d.ts.map +1 -0
- package/dist/hooks/provideFormContext.d.ts +57 -0
- package/dist/hooks/provideFormContext.d.ts.map +1 -0
- package/dist/hooks/useDictionary.d.ts +1 -1
- package/dist/hooks/useDictionary.d.ts.map +1 -1
- package/dist/hooks/useEffect.d.ts +1 -1
- package/dist/hooks/useField.d.ts +1 -32
- package/dist/hooks/useField.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +30 -32
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useViewSchemas.d.ts +1 -1
- package/dist/hooks/useWatch.d.ts +1 -1
- package/dist/index.cjs +1 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +208 -6311
- package/dist/index.mjs.map +1 -1
- package/dist/types/dictionary.d.ts +1 -1
- package/dist/types/field.d.ts +1 -1
- package/dist/types/form.d.ts +1 -1
- package/dist/utils/dynamic.d.ts +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/rendererProvider.d.ts +1 -1
- package/dist/utils/rulesProvider.d.ts +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/package.json +12 -8
- package/dist/hooks/useContext.d.ts +0 -52
- package/dist/hooks/useContext.d.ts.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropType, VNodeChild } from 'vue';
|
|
2
|
+
import { SchemxViewSchema, Values } from '@schemx/core';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* FormItem 属性。
|
|
@@ -8,10 +9,16 @@ import { SchemxViewSchema, Values } from '../../../../core/src/index.ts';
|
|
|
8
9
|
export interface SchemxItemProps<T extends Values = Values> {
|
|
9
10
|
schema: SchemxViewSchema<T>;
|
|
10
11
|
}
|
|
11
|
-
declare const FormItem: import('vue').
|
|
12
|
-
schema:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
12
|
+
declare const FormItem: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
13
|
+
schema: {
|
|
14
|
+
type: PropType<SchemxViewSchema>;
|
|
15
|
+
required: true;
|
|
16
|
+
};
|
|
17
|
+
}>, () => VNodeChild, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
18
|
+
schema: {
|
|
19
|
+
type: PropType<SchemxViewSchema>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
16
23
|
export default FormItem;
|
|
17
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/FormItem/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAgC,QAAQ,EAAS,MAAM,KAAK,CAAA;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAqBrC,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;;cAKQ,QAAQ,CAAC,gBAAgB,CAAC;;;UAMjC,UAAU;;cANH,QAAQ,CAAC,gBAAgB,CAAC;;;iGAgB9C,CAAA;AAoOF,eAAe,QAAQ,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Component, PropType } from 'vue';
|
|
2
2
|
import { SchemxDictionary } from '../types/dictionary';
|
|
3
|
-
import { NamePath } from '
|
|
3
|
+
import { NamePath } from '@schemx/core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* WithRemoteOptions 注入给被包装组件的额外 Props
|
|
@@ -67,7 +67,7 @@ export declare function WithRemoteOptions(WrappedComponent: Component): import('
|
|
|
67
67
|
default: undefined;
|
|
68
68
|
};
|
|
69
69
|
}>> & Readonly<{}>, {
|
|
70
|
-
dict: SchemxDictionary<import('
|
|
70
|
+
dict: SchemxDictionary<import('@schemx/core').Values, any>;
|
|
71
71
|
fieldName: string;
|
|
72
72
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
73
73
|
export default WithRemoteOptions;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -4,17 +4,21 @@
|
|
|
4
4
|
* @module hooks
|
|
5
5
|
*/
|
|
6
6
|
/** useForm - 表单状态管理 */
|
|
7
|
-
export { useForm
|
|
7
|
+
export { useForm } from './useForm';
|
|
8
|
+
/** createFormContext - 表单上下文注入与消费 */
|
|
9
|
+
export { createFormContext, useFormContext } from './provideFormContext';
|
|
8
10
|
/** useField - 单字段控制 */
|
|
9
|
-
export { useField
|
|
11
|
+
export { useField } from './useField';
|
|
12
|
+
/** createFieldContext - 表单上下文注入与消费 */
|
|
13
|
+
export { createFieldContext, useFieldContext } from './provideFieldContext';
|
|
10
14
|
/** useWatch - 字段变化监听 */
|
|
11
15
|
export { useWatch, useWatchField, useWatchFields, useWatchAll } from './useWatch';
|
|
12
16
|
/** useEffect - 通用 Signal effect */
|
|
13
17
|
export { useEffect } from './useEffect';
|
|
14
18
|
/** useDictionary - 字典选项加载 */
|
|
15
19
|
export { useDictionary, type SchemxDictionary, type SchemxWithDictionary, type UseDictionaryReturn, } from './useDictionary';
|
|
16
|
-
/**
|
|
17
|
-
export {
|
|
20
|
+
/** useFormConfigContext - 表单上下文注入与消费 */
|
|
21
|
+
export { createFormConfigContext, useFormConfigContext, type FormContextProps, } from './provideFormConfigContext';
|
|
18
22
|
/** useStableRef - 引用稳定化的 shallowRef */
|
|
19
23
|
export { useStableRef } from './useStableRef';
|
|
20
24
|
/** useViewSchemas - ViewSchemas Vue 桥接 */
|
|
@@ -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,cAAc,EAAE,MAAM,
|
|
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,qCAAqC;AACrC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAExE,uBAAuB;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE3E,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,wCAAwC;AACxC,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,gBAAgB,GACtB,MAAM,4BAA4B,CAAA;AAEnC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,0CAA0C;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FieldInstance } from '../types/field';
|
|
2
|
+
import { Values } from '@schemx/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 向后代组件提供当前字段实例。
|
|
6
|
+
*
|
|
7
|
+
* 应在创建字段实例的组件 setup() 同步阶段调用,通常由 FormItem
|
|
8
|
+
* 在调用 useField() 后使用,使字段插槽或自定义子组件能够读取同一实例。
|
|
9
|
+
*
|
|
10
|
+
* @param field - useField() 返回的字段实例
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* 该函数只注册字段上下文,不创建字段实例,也不负责字段实例的生命周期。
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // FormItem 中
|
|
18
|
+
* const field = useField('date')
|
|
19
|
+
* createFieldContext(field)
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function createFieldContext<TValues extends Values = Values>(field: FieldInstance<TValues>): void;
|
|
24
|
+
/**
|
|
25
|
+
* 获取最近祖先组件提供的当前字段实例。
|
|
26
|
+
*
|
|
27
|
+
* 必须在已调用 createFieldContext() 的组件子树内调用,否则抛出错误。
|
|
28
|
+
*
|
|
29
|
+
* @returns useField() 返回的字段实例
|
|
30
|
+
*
|
|
31
|
+
* @throws Error 当前组件不在字段上下文的后代组件树中时抛出
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* const field = useFieldContext()
|
|
36
|
+
* field.error.value // string[] | undefined
|
|
37
|
+
* field.getValue() // 当前字段值
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useFieldContext(): FieldInstance<Values>;
|
|
41
|
+
//# sourceMappingURL=provideFieldContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFieldContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFieldContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAO1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAChE,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,GAC5B,IAAI,CAEN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,IAAI,aAAa,CAAC,MAAM,CAAC,CAWvD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { SchemxFormProps } from '../types';
|
|
3
|
+
import { Values } from '@schemx/core';
|
|
4
|
+
|
|
5
|
+
/** 表单级展示配置在 Vue provide/inject 中使用的注入 key。 */
|
|
6
|
+
export declare const SCHEMX_FORM_CONFIG_KEY: InjectionKey<FormContextProps<Values>>;
|
|
7
|
+
/**
|
|
8
|
+
* 表单级默认配置。
|
|
9
|
+
*
|
|
10
|
+
* 该类型描述由 SchemxForm 提供给字段组件的配置上下文,排除表单实例、
|
|
11
|
+
* 表单数据和回调等运行时处理属性,供字段组件读取默认展示行为。
|
|
12
|
+
*
|
|
13
|
+
* @typeParam TValues - 表单值类型
|
|
14
|
+
*/
|
|
15
|
+
export interface FormContextProps<TValues extends Values = Values> extends Omit<SchemxFormProps<TValues>, "form" | "modelValue" | "rendererRegistry" | "defaultRendererTValuesype" | "rulesRegistery" | "onFinish" | "onFinishFailed" | "onValuesChange" | "onFieldsChange"> {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 创建并注入表单级配置上下文。
|
|
19
|
+
*
|
|
20
|
+
* 应在 `SchemxForm` 或自定义 Provider 的 setup() 同步阶段调用,
|
|
21
|
+
* 使后代字段组件能够读取 readonly、disabled、labelAlign 等默认配置。
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TValues - 表单值类型
|
|
24
|
+
* @param props - 要提供给后代组件的表单级默认配置
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* 该函数只注册上下文,不创建或销毁表单实例,也不改变传入配置的所有权。
|
|
28
|
+
*/
|
|
29
|
+
export declare const createFormConfigContext: <TValues extends Values = Values>(props: FormContextProps<TValues>) => void;
|
|
30
|
+
/**
|
|
31
|
+
* `createFormConfigContext` 的兼容别名。
|
|
32
|
+
*
|
|
33
|
+
* @deprecated 请使用 createFormConfigContext。
|
|
34
|
+
*/
|
|
35
|
+
export declare const createContext: <TValues extends Values = Values>(props: FormContextProps<TValues>) => void;
|
|
36
|
+
/**
|
|
37
|
+
* 获取最近祖先组件提供的表单级配置。
|
|
38
|
+
*
|
|
39
|
+
* 只能读取祖先组件通过 createFormConfigContext() 注册的配置,
|
|
40
|
+
* 不能读取当前组件或后代组件提供的值。
|
|
41
|
+
*
|
|
42
|
+
* @returns 当前表单树中的表单级默认配置
|
|
43
|
+
*
|
|
44
|
+
* @throws Error 当前组件不在已注册表单配置上下文的后代组件树中时抛出
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const context = useFormConfigContext()
|
|
49
|
+
* console.log(context.readonly, context.disabled)
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function useFormConfigContext(): FormContextProps;
|
|
53
|
+
/**
|
|
54
|
+
* `useFormConfigContext` 的兼容别名。
|
|
55
|
+
*
|
|
56
|
+
* @deprecated 请使用 useFormConfigContext。
|
|
57
|
+
*/
|
|
58
|
+
export declare const useContext: typeof useFormConfigContext;
|
|
59
|
+
//# sourceMappingURL=provideFormConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFormConfigContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFormConfigContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAU,KAAK,YAAY,EAAW,MAAM,KAAK,CAAA;AAExD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,8CAA8C;AAC9C,eAAO,MAAM,sBAAsB,EAAmC,YAAY,CAChF,gBAAgB,CAAC,MAAM,CAAC,CACzB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,IAAI,CAC7E,eAAe,CAAC,OAAO,CAAC,EACtB,MAAM,GACN,YAAY,GACZ,kBAAkB,GAClB,2BAA2B,GAC3B,gBAAgB,GAChB,UAAU,GACV,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,CACnB;CAAG;AAEJ;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uBAAuB,GAAI,OAAO,SAAS,MAAM,GAAG,MAAM,EACrE,OAAO,gBAAgB,CAAC,OAAO,CAAC,KAC/B,IAEF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAXc,OAAO,SAAS,MAAM,kBACrD,gBAAgB,CAAC,OAAO,CAAC,KAC/B,IASiD,CAAA;AAEpD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,IAAI,gBAAgB,CAWvD;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,6BAAuB,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { InjectionKey } from 'vue';
|
|
2
|
+
import { SchemxInstance, Values } from '@schemx/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* SchemxInstance 在 Vue provide/inject 中使用的注入 key。
|
|
6
|
+
*
|
|
7
|
+
* 该 key 只应与同一份包代码导出的 createFormContext() 和 useFormContext()
|
|
8
|
+
* 配套使用;重复安装不兼容版本的包不会共享此上下文。
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCHEMX_FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
|
|
11
|
+
/**
|
|
12
|
+
* 旧版表单实例注入 key。
|
|
13
|
+
*
|
|
14
|
+
* @deprecated 请使用 SCHEMX_FORM_INSTANCE_KEY。该别名仅用于兼容旧测试和旧适配代码。
|
|
15
|
+
*/
|
|
16
|
+
export declare const FORM_INSTANCE_KEY: InjectionKey<SchemxInstance<Values>>;
|
|
17
|
+
/**
|
|
18
|
+
* 向当前组件的后代组件提供表单实例。
|
|
19
|
+
*
|
|
20
|
+
* 必须在组件 setup() 的同步执行阶段调用;不要放入 onMounted、nextTick、
|
|
21
|
+
* Promise 或其他异步回调中,否则 Vue 无法把上下文关联到当前组件实例。
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TValues - 表单值类型
|
|
24
|
+
* @param instance - 要提供给后代组件的表单实例
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* 该函数不接管实例所有权,也不会在组件卸载时销毁实例。
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const form = props.form ?? useForm(options)
|
|
32
|
+
*
|
|
33
|
+
* // 无论 form 来自外部还是内部,都统一注册上下文。
|
|
34
|
+
* createFormContext(form)
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare function createFormContext<TValues extends Values = Values>(instance: SchemxInstance<TValues>): void;
|
|
38
|
+
/**
|
|
39
|
+
* 获取最近祖先组件提供的表单实例。
|
|
40
|
+
*
|
|
41
|
+
* 该函数只能读取祖先组件注册的上下文,不能读取当前组件自身或后代组件
|
|
42
|
+
* 调用 createFormContext() 提供的值。通常由 useField()、useWatch() 等其他
|
|
43
|
+
* 表单 hook 间接调用。
|
|
44
|
+
*
|
|
45
|
+
* @typeParam TValues - 表单值类型
|
|
46
|
+
* @returns 当前组件所属表单树中的 SchemxInstance
|
|
47
|
+
*
|
|
48
|
+
* @throws Error 当前组件不在已注册表单实例上下文的后代组件树中时抛出
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* const form = useFormContext<FormValues>()
|
|
53
|
+
* form.setFieldValue("name", "Schemx")
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function useFormContext<TValues extends Values = Values>(): SchemxInstance<TValues>;
|
|
57
|
+
//# sourceMappingURL=provideFormContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provideFormContext.d.ts","sourceRoot":"","sources":["../../src/hooks/provideFormContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAU,KAAK,YAAY,EAAW,MAAM,KAAK,CAAA;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAgC,YAAY,CAC/E,cAAc,CAAC,MAAM,CAAC,CACvB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,sCAA2B,CAAA;AAEzD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EAC/D,QAAQ,EAAE,cAAc,CAAC,OAAO,CAAC,GAChC,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,OAAO,SAAS,MAAM,GAAG,MAAM,KAC5B,cAAc,CAAC,OAAO,CAAC,CAW3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { SchemxDictionary } from '../types/dictionary';
|
|
3
|
-
import { NamePath, Values } from '
|
|
3
|
+
import { NamePath, Values } from '@schemx/core';
|
|
4
4
|
|
|
5
5
|
export type { SchemxDictionary, SchemxWithDictionary } from '../types/dictionary';
|
|
6
6
|
/**
|
|
@@ -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;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
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;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK1D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEpD,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAEhF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,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,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,8BAA8B;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"}
|
package/dist/hooks/useField.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldInstance } from '../types/field';
|
|
2
|
-
import { NamePath, Values } from '
|
|
2
|
+
import { NamePath, Values } from '@schemx/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* 获取单个字段的控制能力
|
|
@@ -34,36 +34,5 @@ import { NamePath, Values } from '../../../core/src/index.ts';
|
|
|
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>;
|
|
68
37
|
export default useField;
|
|
69
38
|
//# 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;
|
|
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"}
|
package/dist/hooks/useForm.d.ts
CHANGED
|
@@ -1,59 +1,57 @@
|
|
|
1
|
-
import { CreateFormOptions, NamePath, SchemxInstance, Values } from '
|
|
1
|
+
import { CreateFormOptions, NamePath, SchemxInstance, Values } from '@schemx/core';
|
|
2
2
|
|
|
3
|
-
/** SchemxInstance 在 Vue provide/inject 中的注入 key */
|
|
4
|
-
export declare const SCHEMX_INSTANCE_KEY: unique symbol;
|
|
5
|
-
/** @deprecated 请使用 SCHEMX_INSTANCE_KEY。保留给旧测试和旧适配代码兼容。 */
|
|
6
|
-
export declare const FORM_INSTANCE_KEY: symbol;
|
|
7
3
|
/**
|
|
8
|
-
* useForm
|
|
4
|
+
* useForm 配置选项。
|
|
9
5
|
*
|
|
10
|
-
*
|
|
6
|
+
* 当前与 core 层 CreateFormOptions 保持一致,并在 Vue 层自动补充默认的
|
|
7
|
+
* rendererRegistry 和 validatorRegistry。保留独立类型用于后续扩展
|
|
8
|
+
* Vue 专属配置,而不污染 core 层接口。
|
|
11
9
|
*
|
|
12
10
|
* @typeParam TValues - 表单值类型
|
|
13
11
|
*/
|
|
14
12
|
export interface UseFormOptions<TValues extends Values> extends CreateFormOptions<TValues, NamePath<TValues>> {
|
|
15
13
|
}
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* 创建由当前 Vue effect scope 持有的表单实例。
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* useForm 只负责以下职责:
|
|
18
|
+
* 1. 合并 Vue 层默认注册表;
|
|
19
|
+
* 2. 同步创建 SchemxInstance;
|
|
20
|
+
* 3. 在当前 effect scope 销毁时调用 instance.destroy()。
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* useForm 不再自动调用 provide()。需要向后代组件暴露实例时,应由
|
|
23
|
+
* <SchemxForm> 或其他 Provider 组件显式调用 createFormContext(form)。
|
|
24
|
+
* 这样无论实例是内部创建还是通过 props.form 外部传入,都能走同一条
|
|
25
|
+
* 上下文注册路径,并保持清晰的实例所有权:谁创建,谁销毁。
|
|
26
|
+
*
|
|
27
|
+
* 该函数应在组件 setup() 或其他有效的 Vue effect scope 中同步调用。
|
|
28
|
+
* 非 Vue 生命周期场景请直接使用 @schemx/core 的 createForm(),并自行销毁实例。
|
|
23
29
|
*
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
30
|
+
* @typeParam TValues - 表单值类型
|
|
31
|
+
* @param options - 表单创建配置
|
|
32
|
+
* @returns 当前 scope 持有的 SchemxInstance
|
|
26
33
|
*
|
|
27
34
|
* @example
|
|
28
|
-
* ```
|
|
29
|
-
* // 在 setup 中使用
|
|
35
|
+
* ```ts
|
|
30
36
|
* const form = useForm({
|
|
31
|
-
* initialValues: {
|
|
37
|
+
* initialValues: {
|
|
38
|
+
* name: "",
|
|
39
|
+
* email: "",
|
|
40
|
+
* },
|
|
32
41
|
* onFinish: async (values) => {
|
|
33
42
|
* await api.submit(values)
|
|
34
43
|
* },
|
|
35
44
|
* })
|
|
36
45
|
*
|
|
37
|
-
* form.setFieldValue(
|
|
46
|
+
* form.setFieldValue("name", "Schemx")
|
|
38
47
|
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
|
|
41
|
-
/**
|
|
42
|
-
* 获取表单实例
|
|
43
|
-
*
|
|
44
|
-
* 在子组件中获取 useForm 创建的 SchemxInstance,
|
|
45
|
-
* 可用于读写字段值、校验、订阅等操作。
|
|
46
|
-
*
|
|
47
|
-
* @typeParam TValues - 表单值类型
|
|
48
|
-
* @returns 表单实例
|
|
49
|
-
*
|
|
50
|
-
* @throws Error 如果不在 schemx 提供的上下文中调用
|
|
51
48
|
*
|
|
52
49
|
* @example
|
|
53
50
|
* ```ts
|
|
54
|
-
*
|
|
55
|
-
* form.
|
|
51
|
+
* // Provider 组件中统一注册上下文。
|
|
52
|
+
* const form = props.form ?? useForm(options)
|
|
53
|
+
* createFormContext(form)
|
|
56
54
|
* ```
|
|
57
55
|
*/
|
|
58
|
-
export declare function
|
|
56
|
+
export declare function useForm<TValues extends Values = Values>(options?: UseFormOptions<TValues>): SchemxInstance<TValues>;
|
|
59
57
|
//# sourceMappingURL=useForm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAEvF;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO,SAAS,MAAM,CAAE,SAAQ,iBAAiB,CAC/E,OAAO,EACP,QAAQ,CAAC,OAAO,CAAC,CAClB;CAAG;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM,EACrD,OAAO,GAAE,cAAc,CAAC,OAAO,CAAM,GACpC,cAAc,CAAC,OAAO,CAAC,CAgBzB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ShallowRef } from 'vue';
|
|
2
|
-
import { SchemxInstance, SchemxViewSchema, Values } from '
|
|
2
|
+
import { SchemxInstance, SchemxViewSchema, Values } from '@schemx/core';
|
|
3
3
|
|
|
4
4
|
export declare function useViewSchemas<T extends Values = Values>(form: SchemxInstance<T>): ShallowRef<readonly SchemxViewSchema<T>[]>;
|
|
5
5
|
export default useViewSchemas;
|
package/dist/hooks/useWatch.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '
|
|
1
|
+
import { NamePath, Values, CreateWatchOptions, WatchAllCallback, WatchFieldCallback, WatchFieldsCallback } from '@schemx/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 监听所有字段变化
|