@silver-formily/vue 2.3.3 → 2.3.4
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/esm/components/ArrayField.d.ts +67 -60
- package/esm/components/ArrayField.mjs +23 -23
- package/esm/components/ArrayField.mjs.map +1 -1
- package/esm/components/ExpressionScope.d.ts +21 -16
- package/esm/components/ExpressionScope.mjs +22 -24
- package/esm/components/ExpressionScope.mjs.map +1 -1
- package/esm/components/Field.d.ts +67 -60
- package/esm/components/Field.mjs +23 -23
- package/esm/components/Field.mjs.map +1 -1
- package/esm/components/FormConsumer.d.ts +9 -4
- package/esm/components/FormConsumer.mjs +17 -18
- package/esm/components/FormConsumer.mjs.map +1 -1
- package/esm/components/FormProvider.d.ts +21 -16
- package/esm/components/FormProvider.mjs +26 -26
- package/esm/components/FormProvider.mjs.map +1 -1
- package/esm/components/ObjectField.d.ts +68 -60
- package/esm/components/ObjectField.mjs +23 -23
- package/esm/components/ObjectField.mjs.map +1 -1
- package/esm/components/ReactiveField.mjs +103 -83
- package/esm/components/ReactiveField.mjs.map +1 -1
- package/esm/components/RecursionField.d.ts +142 -134
- package/esm/components/RecursionField.mjs +123 -125
- package/esm/components/RecursionField.mjs.map +1 -1
- package/esm/components/SchemaField.d.ts +3041 -3030
- package/esm/components/SchemaField.mjs +104 -99
- package/esm/components/SchemaField.mjs.map +1 -1
- package/esm/components/VoidField.d.ts +48 -42
- package/esm/components/VoidField.mjs +23 -23
- package/esm/components/VoidField.mjs.map +1 -1
- package/esm/components/index.d.ts +9 -9
- package/esm/components/index.mjs +10 -21
- package/esm/hooks/index.d.ts +5 -5
- package/esm/hooks/index.mjs +6 -13
- package/esm/hooks/useAttach.mjs +21 -13
- package/esm/hooks/useAttach.mjs.map +1 -1
- package/esm/hooks/useField.d.ts +8 -3
- package/esm/hooks/useField.mjs +9 -8
- package/esm/hooks/useField.mjs.map +1 -1
- package/esm/hooks/useFieldSchema.d.ts +8 -1
- package/esm/hooks/useFieldSchema.mjs +9 -8
- package/esm/hooks/useFieldSchema.mjs.map +1 -1
- package/esm/hooks/useForm.d.ts +8 -3
- package/esm/hooks/useForm.mjs +9 -8
- package/esm/hooks/useForm.mjs.map +1 -1
- package/esm/hooks/useFormEffects.d.ts +7 -2
- package/esm/hooks/useFormEffects.mjs +18 -15
- package/esm/hooks/useFormEffects.mjs.map +1 -1
- package/esm/hooks/useInjectionCleaner.mjs +8 -7
- package/esm/hooks/useInjectionCleaner.mjs.map +1 -1
- package/esm/hooks/useParentForm.d.ts +8 -3
- package/esm/hooks/useParentForm.mjs +18 -11
- package/esm/hooks/useParentForm.mjs.map +1 -1
- package/esm/index.d.ts +19 -4
- package/esm/index.mjs +20 -42
- package/esm/shared/connect.d.ts +10 -5
- package/esm/shared/connect.mjs +69 -63
- package/esm/shared/connect.mjs.map +1 -1
- package/esm/shared/context.d.ts +15 -10
- package/esm/shared/context.mjs +11 -10
- package/esm/shared/context.mjs.map +1 -1
- package/esm/shared/index.d.ts +2 -2
- package/esm/shared/index.mjs +3 -14
- package/esm/types/index.d.ts +72 -70
- package/esm/types/validator.d.ts +39 -35
- package/esm/utils/fieldProps.mjs +53 -52
- package/esm/utils/fieldProps.mjs.map +1 -1
- package/esm/utils/getRawComponent.mjs +16 -12
- package/esm/utils/getRawComponent.mjs.map +1 -1
- package/esm/utils/reactiveFieldHelpers.mjs +116 -94
- package/esm/utils/reactiveFieldHelpers.mjs.map +1 -1
- package/esm/utils/recursionFieldProps.mjs +14 -13
- package/esm/utils/recursionFieldProps.mjs.map +1 -1
- package/esm/utils/resolveSchemaProps.mjs +13 -10
- package/esm/utils/resolveSchemaProps.mjs.map +1 -1
- package/esm/utils/runtimeProps.d.ts +10 -7
- package/esm/utils/runtimeProps.mjs +15 -15
- package/esm/utils/runtimeProps.mjs.map +1 -1
- package/esm/utils/schemaFieldProps.mjs +63 -62
- package/esm/utils/schemaFieldProps.mjs.map +1 -1
- package/package.json +13 -10
- package/esm/components/ReactiveField.d.ts +0 -16
- package/esm/components/index.mjs.map +0 -1
- package/esm/global.d.d.ts +0 -1
- package/esm/global.d.mjs +0 -2
- package/esm/global.d.mjs.map +0 -1
- package/esm/hooks/index.mjs.map +0 -1
- package/esm/hooks/useAttach.d.ts +0 -7
- package/esm/hooks/useInjectionCleaner.d.ts +0 -2
- package/esm/index.mjs.map +0 -1
- package/esm/shared/index.mjs.map +0 -1
- package/esm/types/index.mjs +0 -2
- package/esm/types/index.mjs.map +0 -1
- package/esm/types/validator.mjs +0 -2
- package/esm/types/validator.mjs.map +0 -1
- package/esm/utils/fieldProps.d.ts +0 -52
- package/esm/utils/getRawComponent.d.ts +0 -8
- package/esm/utils/reactiveFieldHelpers.d.ts +0 -17
- package/esm/utils/recursionFieldProps.d.ts +0 -67
- package/esm/utils/resolveSchemaProps.d.ts +0 -1
- package/esm/utils/schemaFieldProps.d.ts +0 -232
- package/esm/utils/slotMap.d.ts +0 -1
- package/esm/utils/slotMap.mjs +0 -2
- package/esm/utils/slotMap.mjs.map +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAttach
|
|
3
|
-
import { useInjectionCleaner
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { FieldSymbol, FormSymbol, SchemaExpressionScopeSymbol, SchemaMarkupSymbol, SchemaOptionsSymbol, SchemaSymbol } from "../shared/context.mjs";
|
|
2
|
+
import { useAttach } from "../hooks/useAttach.mjs";
|
|
3
|
+
import { useInjectionCleaner } from "../hooks/useInjectionCleaner.mjs";
|
|
4
|
+
import { defineComponent, provide, toRef } from "vue";
|
|
5
|
+
//#region src/components/FormProvider.ts
|
|
6
|
+
var FormProvider_default = defineComponent({
|
|
7
|
+
name: "FormProvider",
|
|
8
|
+
props: { form: {
|
|
9
|
+
type: Object,
|
|
10
|
+
required: true
|
|
11
|
+
} },
|
|
12
|
+
setup(props, { slots }) {
|
|
13
|
+
provide(FormSymbol, useAttach(toRef(props, "form")));
|
|
14
|
+
useInjectionCleaner([
|
|
15
|
+
FieldSymbol,
|
|
16
|
+
SchemaMarkupSymbol,
|
|
17
|
+
SchemaSymbol,
|
|
18
|
+
SchemaExpressionScopeSymbol,
|
|
19
|
+
SchemaOptionsSymbol
|
|
20
|
+
]);
|
|
21
|
+
return () => slots.default?.();
|
|
22
|
+
}
|
|
23
23
|
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=FormProvider.mjs.map
|
|
24
|
+
//#endregion
|
|
25
|
+
export { FormProvider_default as default };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=FormProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormProvider.mjs","sources":["../../src/components/FormProvider.ts"],"sourcesContent":["import type { PropType } from 'vue'\nimport type { IProviderProps } from '../types'\nimport { defineComponent, provide, toRef } from 'vue'\nimport { useAttach } from '../hooks/useAttach'\nimport { useInjectionCleaner } from '../hooks/useInjectionCleaner'\nimport {\n FieldSymbol,\n FormSymbol,\n SchemaExpressionScopeSymbol,\n SchemaMarkupSymbol,\n SchemaOptionsSymbol,\n SchemaSymbol,\n} from '../shared/context'\n\nexport default defineComponent({\n name: 'FormProvider',\n props: {\n form: {\n type: Object as PropType<IProviderProps['form']>,\n required: true,\n },\n },\n setup(props, { slots }) {\n const formRef = useAttach(toRef(props, 'form'))\n provide(FormSymbol, formRef)\n useInjectionCleaner([\n FieldSymbol,\n SchemaMarkupSymbol,\n SchemaSymbol,\n SchemaExpressionScopeSymbol,\n SchemaOptionsSymbol,\n ])\n\n return () => slots.default?.()\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"FormProvider.mjs","names":[],"sources":["../../src/components/FormProvider.ts"],"sourcesContent":["import type { PropType } from 'vue'\nimport type { IProviderProps } from '../types'\nimport { defineComponent, provide, toRef } from 'vue'\nimport { useAttach } from '../hooks/useAttach'\nimport { useInjectionCleaner } from '../hooks/useInjectionCleaner'\nimport {\n FieldSymbol,\n FormSymbol,\n SchemaExpressionScopeSymbol,\n SchemaMarkupSymbol,\n SchemaOptionsSymbol,\n SchemaSymbol,\n} from '../shared/context'\n\nexport default defineComponent({\n name: 'FormProvider',\n props: {\n form: {\n type: Object as PropType<IProviderProps['form']>,\n required: true,\n },\n },\n setup(props, { slots }) {\n const formRef = useAttach(toRef(props, 'form'))\n provide(FormSymbol, formRef)\n useInjectionCleaner([\n FieldSymbol,\n SchemaMarkupSymbol,\n SchemaSymbol,\n SchemaExpressionScopeSymbol,\n SchemaOptionsSymbol,\n ])\n\n return () => slots.default?.()\n },\n})\n"],"mappings":";;;;;AAcA,IAAA,uBAAe,gBAAgB;CAC7B,MAAM;CACN,OAAO,EACL,MAAM;EACJ,MAAM;EACN,UAAU;EACX,EACF;CACD,MAAM,OAAO,EAAE,SAAS;AAEtB,UAAQ,YADQ,UAAU,MAAM,OAAO,OAAO,CAAC,CACnB;AAC5B,sBAAoB;GAClB;GACA;GACA;GACA;GACA;GACD,CAAC;AAEF,eAAa,MAAM,WAAW;;CAEjC,CAAC"}
|
|
@@ -1,60 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
import { SchemaFieldValidator } from "../types/index.js";
|
|
2
|
+
import { RuntimeProp } from "../utils/runtimeProps.js";
|
|
3
|
+
import * as _$vue from "vue";
|
|
4
|
+
import * as _$_formily_core0 from "@formily/core";
|
|
5
|
+
|
|
6
|
+
//#region src/components/ObjectField.d.ts
|
|
7
|
+
declare const _default: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
|
|
8
|
+
readonly name: RuntimeProp<_$_formily_core0.FormPathPattern>;
|
|
9
|
+
readonly title: RuntimeProp<any>;
|
|
10
|
+
readonly description: RuntimeProp<any>;
|
|
11
|
+
readonly value: RuntimeProp<any>;
|
|
12
|
+
readonly initialValue: RuntimeProp<any>;
|
|
13
|
+
readonly basePath: RuntimeProp<_$_formily_core0.FormPathPattern | undefined>;
|
|
14
|
+
readonly decorator: RuntimeProp<_$_formily_core0.FieldDecorator<_$vue.Component, any> | undefined>;
|
|
15
|
+
readonly decoratorContent: RuntimeProp<any>;
|
|
16
|
+
readonly component: RuntimeProp<_$_formily_core0.FieldComponent<_$vue.Component, any> | undefined>;
|
|
17
|
+
readonly display: RuntimeProp<_$_formily_core0.FieldDisplayTypes | undefined>;
|
|
18
|
+
readonly pattern: RuntimeProp<_$_formily_core0.FieldPatternTypes | undefined>;
|
|
19
|
+
readonly required: RuntimeProp<boolean>;
|
|
20
|
+
readonly validateFirst: RuntimeProp<boolean>;
|
|
21
|
+
readonly hidden: RuntimeProp<boolean>;
|
|
22
|
+
readonly visible: RuntimeProp<boolean>;
|
|
23
|
+
readonly editable: RuntimeProp<boolean>;
|
|
24
|
+
readonly disabled: RuntimeProp<boolean>;
|
|
25
|
+
readonly readOnly: RuntimeProp<boolean>;
|
|
26
|
+
readonly readPretty: RuntimeProp<boolean>;
|
|
27
|
+
readonly loading: RuntimeProp<boolean>;
|
|
28
|
+
readonly dataSource: RuntimeProp<_$_formily_core0.FieldDataSource | undefined>;
|
|
29
|
+
readonly validatePattern: RuntimeProp<_$_formily_core0.FieldPatternTypes[] | undefined>;
|
|
30
|
+
readonly validateDisplay: RuntimeProp<_$_formily_core0.FieldDisplayTypes[] | undefined>;
|
|
31
|
+
readonly validator: RuntimeProp<SchemaFieldValidator | undefined>;
|
|
32
|
+
readonly reactions: RuntimeProp<_$_formily_core0.FieldReaction | _$_formily_core0.FieldReaction[] | undefined>;
|
|
33
|
+
readonly content: RuntimeProp<any>;
|
|
34
|
+
readonly data: RuntimeProp<any>;
|
|
35
|
+
}>, () => _$vue.VNode<_$vue.RendererNode, _$vue.RendererElement, {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
}>, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
|
|
38
|
+
readonly name: RuntimeProp<_$_formily_core0.FormPathPattern>;
|
|
39
|
+
readonly title: RuntimeProp<any>;
|
|
40
|
+
readonly description: RuntimeProp<any>;
|
|
41
|
+
readonly value: RuntimeProp<any>;
|
|
42
|
+
readonly initialValue: RuntimeProp<any>;
|
|
43
|
+
readonly basePath: RuntimeProp<_$_formily_core0.FormPathPattern | undefined>;
|
|
44
|
+
readonly decorator: RuntimeProp<_$_formily_core0.FieldDecorator<_$vue.Component, any> | undefined>;
|
|
45
|
+
readonly decoratorContent: RuntimeProp<any>;
|
|
46
|
+
readonly component: RuntimeProp<_$_formily_core0.FieldComponent<_$vue.Component, any> | undefined>;
|
|
47
|
+
readonly display: RuntimeProp<_$_formily_core0.FieldDisplayTypes | undefined>;
|
|
48
|
+
readonly pattern: RuntimeProp<_$_formily_core0.FieldPatternTypes | undefined>;
|
|
49
|
+
readonly required: RuntimeProp<boolean>;
|
|
50
|
+
readonly validateFirst: RuntimeProp<boolean>;
|
|
51
|
+
readonly hidden: RuntimeProp<boolean>;
|
|
52
|
+
readonly visible: RuntimeProp<boolean>;
|
|
53
|
+
readonly editable: RuntimeProp<boolean>;
|
|
54
|
+
readonly disabled: RuntimeProp<boolean>;
|
|
55
|
+
readonly readOnly: RuntimeProp<boolean>;
|
|
56
|
+
readonly readPretty: RuntimeProp<boolean>;
|
|
57
|
+
readonly loading: RuntimeProp<boolean>;
|
|
58
|
+
readonly dataSource: RuntimeProp<_$_formily_core0.FieldDataSource | undefined>;
|
|
59
|
+
readonly validatePattern: RuntimeProp<_$_formily_core0.FieldPatternTypes[] | undefined>;
|
|
60
|
+
readonly validateDisplay: RuntimeProp<_$_formily_core0.FieldDisplayTypes[] | undefined>;
|
|
61
|
+
readonly validator: RuntimeProp<SchemaFieldValidator | undefined>;
|
|
62
|
+
readonly reactions: RuntimeProp<_$_formily_core0.FieldReaction | _$_formily_core0.FieldReaction[] | undefined>;
|
|
63
|
+
readonly content: RuntimeProp<any>;
|
|
64
|
+
readonly data: RuntimeProp<any>;
|
|
65
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { _default };
|
|
68
|
+
//# sourceMappingURL=ObjectField.d.ts.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { fieldProps } from "../utils/fieldProps.mjs";
|
|
2
|
+
import { getRawComponent } from "../utils/getRawComponent.mjs";
|
|
3
|
+
import ReactiveField_default from "./ReactiveField.mjs";
|
|
4
|
+
import { defineComponent, h } from "vue";
|
|
5
|
+
//#region src/components/ObjectField.ts
|
|
6
|
+
var ObjectField_default = defineComponent({
|
|
7
|
+
name: "ObjectField",
|
|
8
|
+
props: fieldProps,
|
|
9
|
+
setup(props, { slots }) {
|
|
10
|
+
return () => {
|
|
11
|
+
return h(ReactiveField_default, {
|
|
12
|
+
fieldType: "ObjectField",
|
|
13
|
+
fieldProps: {
|
|
14
|
+
...props,
|
|
15
|
+
...getRawComponent(props)
|
|
16
|
+
}
|
|
17
|
+
}, slots);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
20
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=ObjectField.mjs.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ObjectField_default as default };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=ObjectField.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectField.mjs","sources":["../../src/components/ObjectField.ts"],"sourcesContent":["import { defineComponent, h } from 'vue'\nimport { fieldProps } from '../utils/fieldProps'\nimport { getRawComponent } from '../utils/getRawComponent'\nimport ReactiveField from './ReactiveField'\n\nexport default defineComponent({\n name: 'ObjectField',\n props: fieldProps,\n setup(props, { slots }) {\n return () => {\n const componentData = {\n fieldType: 'ObjectField',\n fieldProps: {\n ...props,\n ...getRawComponent(props),\n },\n }\n return h(ReactiveField, componentData, slots)\n }\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"ObjectField.mjs","names":["ReactiveField"],"sources":["../../src/components/ObjectField.ts"],"sourcesContent":["import { defineComponent, h } from 'vue'\nimport { fieldProps } from '../utils/fieldProps'\nimport { getRawComponent } from '../utils/getRawComponent'\nimport ReactiveField from './ReactiveField'\n\nexport default defineComponent({\n name: 'ObjectField',\n props: fieldProps,\n setup(props, { slots }) {\n return () => {\n const componentData = {\n fieldType: 'ObjectField',\n fieldProps: {\n ...props,\n ...getRawComponent(props),\n },\n }\n return h(ReactiveField, componentData, slots)\n }\n },\n})\n"],"mappings":";;;;;AAKA,IAAA,sBAAe,gBAAgB;CAC7B,MAAM;CACN,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;AACtB,eAAa;AAQX,UAAO,EAAEA,uBAPa;IACpB,WAAW;IACX,YAAY;KACV,GAAG;KACH,GAAG,gBAAgB,MAAM;KAC1B;IACF,EACsC,MAAM;;;CAGlD,CAAC"}
|
|
@@ -1,84 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1
|
+
import { FieldSymbol, SchemaOptionsSymbol, SchemaSymbol } from "../shared/context.mjs";
|
|
2
|
+
import { useField } from "../hooks/useField.mjs";
|
|
3
|
+
import { useForm } from "../hooks/useForm.mjs";
|
|
4
|
+
import "../hooks/index.mjs";
|
|
5
|
+
import { useAttach } from "../hooks/useAttach.mjs";
|
|
6
|
+
import { createVNodeProps, extractAttrsAndEvents, mergeSlots, wrapFragment } from "../utils/reactiveFieldHelpers.mjs";
|
|
7
|
+
import "../shared/index.mjs";
|
|
8
|
+
import { defineComponent, h, inject, provide, ref, shallowRef, watch } from "vue";
|
|
9
|
+
import { isVoidField } from "@formily/core";
|
|
10
|
+
import { toJS } from "@formily/reactive";
|
|
11
|
+
import { FormPath } from "@formily/shared";
|
|
12
|
+
import { useObserver } from "@silver-formily/reactive-vue";
|
|
13
|
+
//#region src/components/ReactiveField.ts
|
|
14
|
+
var ReactiveField_default = defineComponent({
|
|
15
|
+
name: "ReactiveField",
|
|
16
|
+
props: {
|
|
17
|
+
fieldType: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "Field"
|
|
20
|
+
},
|
|
21
|
+
fieldProps: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: () => ({})
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
setup(props, { slots }) {
|
|
27
|
+
const formRef = useForm();
|
|
28
|
+
const parentRef = useField();
|
|
29
|
+
const optionsRef = inject(SchemaOptionsSymbol, ref());
|
|
30
|
+
const schemaRef = inject(SchemaSymbol, ref());
|
|
31
|
+
useObserver();
|
|
32
|
+
const syncFieldRuntimeState = (field) => {
|
|
33
|
+
if (!field || isVoidField(field)) return field;
|
|
34
|
+
const loading = "loading" in props.fieldProps ? props.fieldProps.loading : void 0;
|
|
35
|
+
if (loading !== void 0 && field.loading !== loading) field.setLoading?.(loading);
|
|
36
|
+
return field;
|
|
37
|
+
};
|
|
38
|
+
const createField = () => syncFieldRuntimeState(formRef?.value?.[`create${props.fieldType}`]?.({
|
|
39
|
+
...props.fieldProps,
|
|
40
|
+
basePath: props.fieldProps?.basePath ?? parentRef.value?.address
|
|
41
|
+
}));
|
|
42
|
+
const fieldRef = shallowRef(createField());
|
|
43
|
+
watch(() => props.fieldProps, () => {
|
|
44
|
+
const nextField = createField();
|
|
45
|
+
if (nextField) fieldRef.value = nextField;
|
|
46
|
+
});
|
|
47
|
+
useAttach(fieldRef);
|
|
48
|
+
provide(FieldSymbol, fieldRef);
|
|
49
|
+
return () => {
|
|
50
|
+
const field = fieldRef.value;
|
|
51
|
+
const options = optionsRef.value;
|
|
52
|
+
if (!field) return slots.default?.();
|
|
53
|
+
if (field.display !== "visible") return null;
|
|
54
|
+
const mergedSlots = mergeSlots(field, slots, field.content);
|
|
55
|
+
const decoratorSlots = mergeSlots(field, slots, schemaRef.value?.["x-decorator-content"] ?? props.fieldProps?.decoratorContent);
|
|
56
|
+
const renderDecorator = (childNodes) => {
|
|
57
|
+
const normalizedChildren = childNodes.filter((child) => child != null);
|
|
58
|
+
if (!field.decoratorType) return wrapFragment(normalizedChildren);
|
|
59
|
+
const finalComponent = FormPath.getIn(options?.components, field.decoratorType) ?? field.decoratorType;
|
|
60
|
+
const { attrs, events } = extractAttrsAndEvents(toJS(Array.isArray(field.decorator) ? field.decorator[1] : void 0) || {});
|
|
61
|
+
return h(finalComponent, createVNodeProps(attrs, events), {
|
|
62
|
+
...decoratorSlots,
|
|
63
|
+
default: () => normalizedChildren
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const renderComponent = () => {
|
|
67
|
+
if (!field.componentType) return wrapFragment(mergedSlots?.default?.());
|
|
68
|
+
const component = FormPath.getIn(options?.components, field.componentType) ?? field.componentType;
|
|
69
|
+
const originData = toJS(Array.isArray(field.component) ? field.component[1] : void 0) || {};
|
|
70
|
+
const fieldValue = !isVoidField(field) ? field.value : void 0;
|
|
71
|
+
const { attrs, events } = extractAttrsAndEvents({
|
|
72
|
+
disabled: !isVoidField(field) ? field.pattern === "disabled" || field.pattern === "readPretty" : void 0,
|
|
73
|
+
readOnly: !isVoidField(field) ? field.pattern === "readOnly" : void 0,
|
|
74
|
+
...originData,
|
|
75
|
+
modelValue: fieldValue
|
|
76
|
+
});
|
|
77
|
+
const modelUpdateHandler = events["update:modelValue"];
|
|
78
|
+
const focusHandler = events.focus;
|
|
79
|
+
const blurHandler = events.blur;
|
|
80
|
+
const emitInput = (...args) => {
|
|
81
|
+
if (!isVoidField(field)) field.onInput(...args);
|
|
82
|
+
};
|
|
83
|
+
events["update:modelValue"] = (...args) => {
|
|
84
|
+
emitInput(...args);
|
|
85
|
+
modelUpdateHandler?.(...args);
|
|
86
|
+
};
|
|
87
|
+
events.focus = (...args) => {
|
|
88
|
+
if (!isVoidField(field)) field.onFocus(...args);
|
|
89
|
+
focusHandler?.(...args);
|
|
90
|
+
};
|
|
91
|
+
events.blur = (...args) => {
|
|
92
|
+
if (!isVoidField(field)) field.onBlur(...args);
|
|
93
|
+
blurHandler?.(...args);
|
|
94
|
+
};
|
|
95
|
+
return h(component, createVNodeProps(attrs, events), mergedSlots);
|
|
96
|
+
};
|
|
97
|
+
return renderDecorator([renderComponent()]);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
80
100
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//# sourceMappingURL=ReactiveField.mjs.map
|
|
101
|
+
//#endregion
|
|
102
|
+
export { ReactiveField_default as default };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=ReactiveField.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactiveField.mjs","sources":["../../src/components/ReactiveField.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Ref, VNode } from 'vue'\nimport type { IReactiveFieldProps } from '../types'\nimport { isVoidField } from '@formily/core'\nimport { toJS } from '@formily/reactive'\nimport { FormPath } from '@formily/shared'\nimport { useObserver } from '@silver-formily/reactive-vue'\nimport { defineComponent, h, inject, provide, ref, shallowRef, watch } from 'vue'\nimport { useField, useForm } from '../hooks'\nimport { useAttach } from '../hooks/useAttach'\n\nimport { FieldSymbol, SchemaOptionsSymbol, SchemaSymbol } from '../shared'\nimport { createVNodeProps, extractAttrsAndEvents, mergeSlots, wrapFragment } from '../utils/reactiveFieldHelpers'\n\ntype ComponentEventArgs = unknown[]\ntype ComponentEventHandler = (...args: ComponentEventArgs) => unknown\n\nexport default defineComponent({\n name: 'ReactiveField',\n props: {\n fieldType: {\n type: String,\n default: 'Field',\n },\n fieldProps: {\n type: Object,\n default: () => ({}),\n },\n },\n setup(props: IReactiveFieldProps, { slots }) {\n const formRef = useForm()\n const parentRef = useField()\n const optionsRef = inject(SchemaOptionsSymbol, ref())\n const schemaRef = inject(SchemaSymbol, ref())\n\n useObserver()\n\n // HACK: 修复运行时状态:https://github.com/alibaba/formily/issues/4357\n const syncFieldRuntimeState = (field?: GeneralField) => {\n if (!field || isVoidField(field)) {\n return field\n }\n\n const loading = 'loading' in props.fieldProps\n ? props.fieldProps.loading\n : undefined\n if (loading !== undefined && field.loading !== loading) {\n field.setLoading?.(loading)\n }\n\n return field\n }\n\n const createField = () =>\n syncFieldRuntimeState(formRef?.value?.[`create${props.fieldType}`]?.({\n ...props.fieldProps,\n basePath: props.fieldProps?.basePath ?? parentRef.value?.address,\n }))\n\n const fieldRef = shallowRef(createField()) as Ref<GeneralField>\n\n watch(\n () => props.fieldProps,\n () => {\n const nextField = createField()\n if (nextField) {\n fieldRef.value = nextField\n }\n },\n )\n\n useAttach(fieldRef)\n provide(FieldSymbol, fieldRef)\n\n return () => {\n const field = fieldRef.value\n const options = optionsRef.value\n\n if (!field) {\n return slots.default?.()\n }\n\n if (field.display !== 'visible') {\n return null\n }\n\n const mergedSlots = mergeSlots(field, slots, field.content)\n const decoratorContent = schemaRef.value?.['x-decorator-content']\n ?? props.fieldProps?.decoratorContent\n const decoratorSlots = mergeSlots(field, slots, decoratorContent)\n\n const renderDecorator = (childNodes: Array<VNode | null | undefined>) => {\n const normalizedChildren = childNodes.filter(child => child != null) as VNode[]\n if (!field.decoratorType) {\n return wrapFragment(normalizedChildren)\n }\n\n const finalComponent\n = FormPath.getIn(options?.components, field.decoratorType as string) ?? field.decoratorType\n const decoratorEntry = Array.isArray(field.decorator) ? field.decorator[1] : undefined\n const decoratorAttrs = toJS(decoratorEntry) || {}\n const { attrs, events } = extractAttrsAndEvents(decoratorAttrs)\n const decoratorProps = createVNodeProps(attrs, events)\n\n return h(finalComponent, decoratorProps, {\n ...decoratorSlots,\n default: () => normalizedChildren,\n })\n }\n\n const renderComponent = (): VNode | null => {\n if (!field.componentType) {\n return wrapFragment(mergedSlots?.default?.())\n }\n\n const component\n = FormPath.getIn(options?.components, field.componentType as string) ?? field.componentType\n\n const componentEntry = Array.isArray(field.component) ? field.component[1] : undefined\n const originData = toJS(componentEntry) || {}\n const fieldValue = !isVoidField(field) ? field.value : undefined\n const composedAttrs = {\n disabled: !isVoidField(field)\n ? field.pattern === 'disabled' || field.pattern === 'readPretty'\n : undefined,\n readOnly: !isVoidField(field) ? field.pattern === 'readOnly' : undefined,\n ...originData,\n modelValue: fieldValue,\n }\n const { attrs, events } = extractAttrsAndEvents(composedAttrs)\n const modelUpdateHandler: ComponentEventHandler | undefined = events['update:modelValue']\n const focusHandler: ComponentEventHandler | undefined = events.focus\n const blurHandler: ComponentEventHandler | undefined = events.blur\n\n const emitInput = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onInput(...(args as Parameters<typeof field.onInput>))\n }\n }\n\n events['update:modelValue'] = (...args: ComponentEventArgs) => {\n emitInput(...args)\n modelUpdateHandler?.(...args)\n }\n events.focus = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onFocus(...(args as Parameters<typeof field.onFocus>))\n }\n focusHandler?.(...args)\n }\n events.blur = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onBlur(...(args as Parameters<typeof field.onBlur>))\n }\n blurHandler?.(...args)\n }\n\n const componentProps = createVNodeProps(attrs, events)\n return h(component, componentProps, mergedSlots)\n }\n\n return renderDecorator([renderComponent()])\n }\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"ReactiveField.mjs","names":[],"sources":["../../src/components/ReactiveField.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Ref, VNode } from 'vue'\nimport type { IReactiveFieldProps } from '../types'\nimport { isVoidField } from '@formily/core'\nimport { toJS } from '@formily/reactive'\nimport { FormPath } from '@formily/shared'\nimport { useObserver } from '@silver-formily/reactive-vue'\nimport { defineComponent, h, inject, provide, ref, shallowRef, watch } from 'vue'\nimport { useField, useForm } from '../hooks'\nimport { useAttach } from '../hooks/useAttach'\n\nimport { FieldSymbol, SchemaOptionsSymbol, SchemaSymbol } from '../shared'\nimport { createVNodeProps, extractAttrsAndEvents, mergeSlots, wrapFragment } from '../utils/reactiveFieldHelpers'\n\ntype ComponentEventArgs = unknown[]\ntype ComponentEventHandler = (...args: ComponentEventArgs) => unknown\n\nexport default defineComponent({\n name: 'ReactiveField',\n props: {\n fieldType: {\n type: String,\n default: 'Field',\n },\n fieldProps: {\n type: Object,\n default: () => ({}),\n },\n },\n setup(props: IReactiveFieldProps, { slots }) {\n const formRef = useForm()\n const parentRef = useField()\n const optionsRef = inject(SchemaOptionsSymbol, ref())\n const schemaRef = inject(SchemaSymbol, ref())\n\n useObserver()\n\n // HACK: 修复运行时状态:https://github.com/alibaba/formily/issues/4357\n const syncFieldRuntimeState = (field?: GeneralField) => {\n if (!field || isVoidField(field)) {\n return field\n }\n\n const loading = 'loading' in props.fieldProps\n ? props.fieldProps.loading\n : undefined\n if (loading !== undefined && field.loading !== loading) {\n field.setLoading?.(loading)\n }\n\n return field\n }\n\n const createField = () =>\n syncFieldRuntimeState(formRef?.value?.[`create${props.fieldType}`]?.({\n ...props.fieldProps,\n basePath: props.fieldProps?.basePath ?? parentRef.value?.address,\n }))\n\n const fieldRef = shallowRef(createField()) as Ref<GeneralField>\n\n watch(\n () => props.fieldProps,\n () => {\n const nextField = createField()\n if (nextField) {\n fieldRef.value = nextField\n }\n },\n )\n\n useAttach(fieldRef)\n provide(FieldSymbol, fieldRef)\n\n return () => {\n const field = fieldRef.value\n const options = optionsRef.value\n\n if (!field) {\n return slots.default?.()\n }\n\n if (field.display !== 'visible') {\n return null\n }\n\n const mergedSlots = mergeSlots(field, slots, field.content)\n const decoratorContent = schemaRef.value?.['x-decorator-content']\n ?? props.fieldProps?.decoratorContent\n const decoratorSlots = mergeSlots(field, slots, decoratorContent)\n\n const renderDecorator = (childNodes: Array<VNode | null | undefined>) => {\n const normalizedChildren = childNodes.filter(child => child != null) as VNode[]\n if (!field.decoratorType) {\n return wrapFragment(normalizedChildren)\n }\n\n const finalComponent\n = FormPath.getIn(options?.components, field.decoratorType as string) ?? field.decoratorType\n const decoratorEntry = Array.isArray(field.decorator) ? field.decorator[1] : undefined\n const decoratorAttrs = toJS(decoratorEntry) || {}\n const { attrs, events } = extractAttrsAndEvents(decoratorAttrs)\n const decoratorProps = createVNodeProps(attrs, events)\n\n return h(finalComponent, decoratorProps, {\n ...decoratorSlots,\n default: () => normalizedChildren,\n })\n }\n\n const renderComponent = (): VNode | null => {\n if (!field.componentType) {\n return wrapFragment(mergedSlots?.default?.())\n }\n\n const component\n = FormPath.getIn(options?.components, field.componentType as string) ?? field.componentType\n\n const componentEntry = Array.isArray(field.component) ? field.component[1] : undefined\n const originData = toJS(componentEntry) || {}\n const fieldValue = !isVoidField(field) ? field.value : undefined\n const composedAttrs = {\n disabled: !isVoidField(field)\n ? field.pattern === 'disabled' || field.pattern === 'readPretty'\n : undefined,\n readOnly: !isVoidField(field) ? field.pattern === 'readOnly' : undefined,\n ...originData,\n modelValue: fieldValue,\n }\n const { attrs, events } = extractAttrsAndEvents(composedAttrs)\n const modelUpdateHandler: ComponentEventHandler | undefined = events['update:modelValue']\n const focusHandler: ComponentEventHandler | undefined = events.focus\n const blurHandler: ComponentEventHandler | undefined = events.blur\n\n const emitInput = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onInput(...(args as Parameters<typeof field.onInput>))\n }\n }\n\n events['update:modelValue'] = (...args: ComponentEventArgs) => {\n emitInput(...args)\n modelUpdateHandler?.(...args)\n }\n events.focus = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onFocus(...(args as Parameters<typeof field.onFocus>))\n }\n focusHandler?.(...args)\n }\n events.blur = (...args: ComponentEventArgs) => {\n if (!isVoidField(field)) {\n field.onBlur(...(args as Parameters<typeof field.onBlur>))\n }\n blurHandler?.(...args)\n }\n\n const componentProps = createVNodeProps(attrs, events)\n return h(component, componentProps, mergedSlots)\n }\n\n return renderDecorator([renderComponent()])\n }\n },\n})\n"],"mappings":"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"}
|