@silver-formily/vue 2.3.1 → 2.3.3
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.en.md +6 -6
- package/README.md +6 -6
- package/esm/components/ArrayField.d.ts +2 -0
- package/esm/components/Field.d.ts +2 -0
- package/esm/components/ObjectField.d.ts +2 -0
- package/esm/components/ReactiveField.mjs +48 -40
- package/esm/components/ReactiveField.mjs.map +1 -1
- package/esm/components/RecursionField.d.ts +127 -15
- package/esm/components/RecursionField.mjs +51 -53
- package/esm/components/RecursionField.mjs.map +1 -1
- package/esm/components/SchemaField.d.ts +142 -31
- package/esm/components/SchemaField.mjs +53 -51
- package/esm/components/SchemaField.mjs.map +1 -1
- package/esm/types/index.d.ts +2 -0
- package/esm/utils/fieldProps.d.ts +1 -0
- package/esm/utils/fieldProps.mjs +1 -0
- package/esm/utils/fieldProps.mjs.map +1 -1
- package/esm/utils/reactiveFieldHelpers.d.ts +2 -1
- package/esm/utils/reactiveFieldHelpers.mjs.map +1 -1
- package/esm/utils/slotMap.d.ts +1 -0
- package/esm/utils/slotMap.mjs +2 -0
- package/esm/utils/slotMap.mjs.map +1 -0
- package/package.json +6 -6
|
@@ -1,100 +1,100 @@
|
|
|
1
1
|
import { Schema as S } from "@formily/json-schema";
|
|
2
|
-
import { lazyMerge as
|
|
3
|
-
import { defineComponent as
|
|
4
|
-
import { useField as
|
|
5
|
-
import { SchemaOptionsSymbol as
|
|
2
|
+
import { lazyMerge as k, isValid as x, isFn as w } from "@formily/shared";
|
|
3
|
+
import { defineComponent as E, inject as j, computed as A, shallowRef as B, watch as C, provide as M, markRaw as V, h as u, Fragment as $ } from "vue";
|
|
4
|
+
import { useField as z } from "../hooks/useField.mjs";
|
|
5
|
+
import { SchemaOptionsSymbol as I, SchemaExpressionScopeSymbol as K, SchemaSymbol as q } from "../shared/context.mjs";
|
|
6
6
|
import "@formily/core";
|
|
7
7
|
import "@silver-formily/reactive-vue";
|
|
8
|
-
import { recursionFieldProps as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
8
|
+
import { recursionFieldProps as D } from "../utils/recursionFieldProps.mjs";
|
|
9
|
+
import G from "./ArrayField.mjs";
|
|
10
|
+
import H from "./Field.mjs";
|
|
11
|
+
import J from "./ObjectField.mjs";
|
|
12
|
+
import L from "./VoidField.mjs";
|
|
13
13
|
function F(e) {
|
|
14
14
|
const c = Object.keys(e);
|
|
15
15
|
if (!c.length)
|
|
16
|
-
return;
|
|
17
|
-
const
|
|
18
|
-
const t = e[
|
|
16
|
+
return null;
|
|
17
|
+
const s = c.reduce((i, v) => {
|
|
18
|
+
const t = e[v];
|
|
19
19
|
if (!t)
|
|
20
|
-
return
|
|
20
|
+
return i;
|
|
21
21
|
const f = t();
|
|
22
22
|
if (!f?.length)
|
|
23
|
-
return
|
|
23
|
+
return i;
|
|
24
24
|
const p = f.filter((P) => x(P));
|
|
25
|
-
return
|
|
25
|
+
return i.push(...p), i;
|
|
26
26
|
}, []);
|
|
27
|
-
|
|
28
|
-
return u(z, null, i);
|
|
27
|
+
return s.length ? u($, null, s) : null;
|
|
29
28
|
}
|
|
30
|
-
const
|
|
29
|
+
const N = E({
|
|
31
30
|
name: "RecursionField",
|
|
32
31
|
inheritAttrs: !1,
|
|
33
|
-
props:
|
|
32
|
+
props: D,
|
|
34
33
|
setup(e) {
|
|
35
|
-
const c =
|
|
36
|
-
if (!
|
|
34
|
+
const c = z(), s = j(I), i = j(K);
|
|
35
|
+
if (!s || !i)
|
|
37
36
|
throw new Error("RecursionField must be used under SchemaField.");
|
|
38
|
-
const
|
|
39
|
-
...
|
|
37
|
+
const v = (r) => V(S.isSchemaInstance(r) ? r : new S(r)), t = A(() => v(e.schema ?? {})), f = (r) => r?.toFieldProps?.({
|
|
38
|
+
...s.value,
|
|
40
39
|
get scope() {
|
|
41
|
-
return
|
|
40
|
+
return k(
|
|
42
41
|
{},
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
s.value.scope ?? {},
|
|
43
|
+
i.value
|
|
45
44
|
);
|
|
46
45
|
}
|
|
47
|
-
}), p =
|
|
48
|
-
|
|
46
|
+
}), p = B(f(t.value));
|
|
47
|
+
C([t, s], () => {
|
|
49
48
|
p.value = f(t.value);
|
|
50
49
|
});
|
|
51
50
|
const P = () => e.onlyRenderProperties ? e.basePath ?? c?.value?.address.concat(e.name) : e.basePath ?? c?.value?.address;
|
|
52
|
-
return
|
|
53
|
-
const r = P(),
|
|
51
|
+
return M(q, t), () => {
|
|
52
|
+
const r = P(), y = p.value, d = (R = !1) => {
|
|
54
53
|
if (e.onlyRenderSelf)
|
|
55
54
|
return {};
|
|
56
55
|
const b = S.getOrderProperties(t.value);
|
|
57
56
|
if (!b.length)
|
|
58
57
|
return {};
|
|
59
|
-
const h = {},
|
|
60
|
-
h[o] || (h[o] = []), h[o].push(
|
|
58
|
+
const h = {}, O = (o, l) => {
|
|
59
|
+
h[o] || (h[o] = []), h[o].push(l);
|
|
61
60
|
};
|
|
62
|
-
for (const [o, { schema:
|
|
63
|
-
let n =
|
|
61
|
+
for (const [o, { schema: l, key: a }] of b.entries()) {
|
|
62
|
+
let n = l;
|
|
64
63
|
if (w(e.mapProperties)) {
|
|
65
|
-
const m = e.mapProperties(
|
|
64
|
+
const m = e.mapProperties(l, a);
|
|
66
65
|
m && (n = m);
|
|
67
66
|
}
|
|
68
|
-
w(e.filterProperties) && e.filterProperties(n,
|
|
69
|
-
key: `${o}-${
|
|
67
|
+
w(e.filterProperties) && e.filterProperties(n, a) === !1 || O(n["x-slot"] ?? "default", (m) => u(N, {
|
|
68
|
+
key: `${o}-${a}`,
|
|
70
69
|
schema: n,
|
|
71
|
-
name:
|
|
70
|
+
name: a,
|
|
72
71
|
basePath: m?.address ?? r,
|
|
73
72
|
slot: n["x-slot"]
|
|
74
73
|
}));
|
|
75
74
|
}
|
|
76
75
|
const g = {};
|
|
77
76
|
for (const o of Object.keys(h)) {
|
|
78
|
-
const
|
|
79
|
-
g[o] =
|
|
77
|
+
const l = h[o], a = R ? (n) => l.map((m) => m(n?.field)) : () => l.map((n) => n());
|
|
78
|
+
g[o] = a;
|
|
80
79
|
}
|
|
81
80
|
return g;
|
|
82
|
-
}
|
|
81
|
+
};
|
|
82
|
+
return (() => {
|
|
83
83
|
if (!x(e.name))
|
|
84
84
|
return F(d());
|
|
85
85
|
if (t.value.type === "object")
|
|
86
86
|
return e.onlyRenderProperties ? F(d()) : u(
|
|
87
|
-
|
|
87
|
+
J,
|
|
88
88
|
{
|
|
89
|
-
...
|
|
89
|
+
...y,
|
|
90
90
|
name: e.name,
|
|
91
91
|
basePath: r
|
|
92
92
|
},
|
|
93
93
|
d(!0)
|
|
94
94
|
);
|
|
95
95
|
if (t.value.type === "array")
|
|
96
|
-
return u(
|
|
97
|
-
...
|
|
96
|
+
return u(G, {
|
|
97
|
+
...y,
|
|
98
98
|
name: e.name,
|
|
99
99
|
basePath: r
|
|
100
100
|
});
|
|
@@ -103,27 +103,25 @@ const Q = A({
|
|
|
103
103
|
return F(d());
|
|
104
104
|
const R = d(!0);
|
|
105
105
|
return u(
|
|
106
|
-
|
|
106
|
+
L,
|
|
107
107
|
{
|
|
108
|
-
...
|
|
108
|
+
...y,
|
|
109
109
|
name: e.name,
|
|
110
110
|
basePath: r
|
|
111
111
|
},
|
|
112
112
|
R
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
|
-
return u(
|
|
116
|
-
...
|
|
115
|
+
return u(H, {
|
|
116
|
+
...y,
|
|
117
117
|
name: e.name,
|
|
118
118
|
basePath: r
|
|
119
119
|
});
|
|
120
|
-
};
|
|
121
|
-
if (t.value)
|
|
122
|
-
return O();
|
|
120
|
+
})();
|
|
123
121
|
};
|
|
124
122
|
}
|
|
125
123
|
});
|
|
126
124
|
export {
|
|
127
|
-
|
|
125
|
+
N as default
|
|
128
126
|
};
|
|
129
127
|
//# sourceMappingURL=RecursionField.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecursionField.mjs","sources":["../../src/components/RecursionField.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Slots, VNode } from 'vue'\nimport type { IRecursionFieldProps, SchemaExpressionScope } from '../types'\nimport { Schema } from '@formily/json-schema'\nimport { isFn, isValid, lazyMerge } from '@formily/shared'\nimport { computed, defineComponent, Fragment, h, inject, markRaw, provide, shallowRef, watch } from 'vue'\nimport { useField } from '../hooks'\nimport { SchemaExpressionScopeSymbol, SchemaOptionsSymbol, SchemaSymbol } from '../shared'\nimport { recursionFieldProps } from '../utils/recursionFieldProps'\nimport ArrayField from './ArrayField'\nimport Field from './Field'\n\nimport ObjectField from './ObjectField'\nimport VoidField from './VoidField'\n\ntype PropertyRenderFn = (field?: GeneralField) => VNode\ninterface ScopedSlotPayload { field?: GeneralField }\ntype SlotRender = (payload?: ScopedSlotPayload) => VNode[] | undefined\ntype SlotMap = Record<string, SlotRender>\n\nfunction resolveEmptySlot(slots: SlotMap) {\n const slotKeys = Object.keys(slots)\n if (!slotKeys.length)\n return undefined\n const children = slotKeys.reduce<VNode[]>((acc, key) => {\n const slot = slots[key]\n if (!slot)\n return acc\n const result = slot()\n if (!result?.length)\n return acc\n const validChildren = result.filter(child => isValid(child))\n acc.push(...validChildren)\n return acc\n }, [])\n if (!children.length)\n return undefined\n return h(Fragment, null, children)\n}\n\nconst RecursionField = defineComponent({\n name: 'RecursionField',\n inheritAttrs: false,\n props: recursionFieldProps,\n setup(props: IRecursionFieldProps) {\n const parentRef = useField()\n const optionsRef = inject(SchemaOptionsSymbol)\n const scopeRef = inject(SchemaExpressionScopeSymbol)\n\n if (!optionsRef || !scopeRef) {\n throw new Error('RecursionField must be used under SchemaField.')\n }\n const createSchema = (schemaProp: IRecursionFieldProps['schema']) =>\n markRaw(Schema.isSchemaInstance(schemaProp) ? schemaProp : new Schema(schemaProp))\n const fieldSchemaRef = computed(() => createSchema(props.schema))\n\n const getPropsFromSchema = (schema: Schema) =>\n schema?.toFieldProps?.({\n ...optionsRef.value,\n get scope() {\n return lazyMerge(\n {} as SchemaExpressionScope,\n optionsRef.value.scope ?? {},\n scopeRef.value,\n )\n },\n })\n const fieldPropsRef = shallowRef(getPropsFromSchema(fieldSchemaRef.value))\n\n watch([fieldSchemaRef, optionsRef], () => {\n fieldPropsRef.value = getPropsFromSchema(fieldSchemaRef.value)\n })\n\n const getBasePath = () => {\n if (props.onlyRenderProperties) {\n return props.basePath ?? parentRef?.value?.address.concat(props.name!)\n }\n return props.basePath ?? parentRef?.value?.address\n }\n\n provide(SchemaSymbol, fieldSchemaRef)\n\n return () => {\n const basePath = getBasePath()\n const fieldProps = fieldPropsRef.value\n\n const generateSlotsByProperties = (scoped = false): SlotMap => {\n if (props.onlyRenderSelf)\n return {}\n const properties = Schema.getOrderProperties(fieldSchemaRef.value)\n if (!properties.length)\n return {}\n const renderMap: Record<string, PropertyRenderFn[]> = {}\n const setRender = (key: string, value: PropertyRenderFn) => {\n if (!renderMap[key]) {\n renderMap[key] = []\n }\n renderMap[key].push(value)\n }\n for (const [index, { schema: item, key: name }] of properties.entries()) {\n let schema: Schema = item\n if (isFn(props.mapProperties)) {\n const mapped = props.mapProperties(item, name)\n if (mapped) {\n schema = mapped\n }\n }\n if (isFn(props.filterProperties) && props.filterProperties(schema, name) === false) {\n continue\n }\n setRender(schema['x-slot'] ?? 'default', (field?: GeneralField) =>\n h(RecursionField, {\n key: `${index}-${name}`,\n schema,\n name,\n basePath: field?.address ?? basePath,\n slot: schema['x-slot'],\n }))\n }\n const slots: SlotMap = {}\n for (const key of Object.keys(renderMap)) {\n const renderFns = renderMap[key]\n const slotRender: SlotRender = scoped\n ? payload => renderFns!.map(fn => fn(payload?.field))\n : () => renderFns!.map(fn => fn())\n slots[key] = slotRender\n }\n return slots\n }\n\n const render = () => {\n if (!isValid(props.name))\n return resolveEmptySlot(generateSlotsByProperties())\n if (fieldSchemaRef.value.type === 'object') {\n if (props.onlyRenderProperties)\n return resolveEmptySlot(generateSlotsByProperties())\n return h(\n ObjectField,\n {\n ...fieldProps,\n name: props.name!,\n basePath,\n },\n generateSlotsByProperties(true) as Slots,\n )\n }\n else if (fieldSchemaRef.value.type === 'array') {\n return h(ArrayField, {\n ...fieldProps,\n name: props.name!,\n basePath,\n })\n }\n else if (fieldSchemaRef.value.type === 'void') {\n if (props.onlyRenderProperties)\n return resolveEmptySlot(generateSlotsByProperties())\n const slots = generateSlotsByProperties(true)\n return h(\n VoidField,\n {\n ...fieldProps,\n name: props.name!,\n basePath,\n },\n slots as Slots,\n )\n }\n\n return h(Field, {\n ...fieldProps,\n name: props.name!,\n basePath,\n })\n }\n\n if (!fieldSchemaRef.value)\n return\n\n return render()\n }\n },\n})\n\nexport default RecursionField\n"],"names":["resolveEmptySlot","slots","slotKeys","children","acc","key","slot","result","validChildren","child","isValid","h","Fragment","RecursionField","defineComponent","recursionFieldProps","props","parentRef","useField","optionsRef","inject","SchemaOptionsSymbol","scopeRef","SchemaExpressionScopeSymbol","createSchema","schemaProp","markRaw","Schema","fieldSchemaRef","computed","getPropsFromSchema","schema","lazyMerge","fieldPropsRef","shallowRef","watch","getBasePath","provide","SchemaSymbol","basePath","fieldProps","generateSlotsByProperties","scoped","properties","renderMap","setRender","value","index","item","name","isFn","mapped","field","renderFns","slotRender","payload","fn","render","ObjectField","ArrayField","VoidField","Field"],"mappings":";;;;;;;;;;;;AAoBA,SAASA,EAAiBC,GAAgB;AACxC,QAAMC,IAAW,OAAO,KAAKD,CAAK;AAClC,MAAI,CAACC,EAAS;AACZ;AACF,QAAMC,IAAWD,EAAS,OAAgB,CAACE,GAAKC,MAAQ;AACtD,UAAMC,IAAOL,EAAMI,CAAG;AACtB,QAAI,CAACC;AACH,aAAOF;AACT,UAAMG,IAASD,EAAA;AACf,QAAI,CAACC,GAAQ;AACX,aAAOH;AACT,UAAMI,IAAgBD,EAAO,OAAO,CAAAE,MAASC,EAAQD,CAAK,CAAC;AAC3D,WAAAL,EAAI,KAAK,GAAGI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MAAM,SAAS;AAChC,iBAAIZ,EAAM,uBACDhB,EAAiByC,GAA2B,IAC9C9B;AAAA,YACL+C;AAAA,YACA;AAAA,cACE,GAAGlB;AAAA,cACH,MAAMxB,EAAM;AAAA,cACZ,UAAAuB;AAAA,YAAA;AAAA,YAEFE,EAA0B,EAAI;AAAA,UAAA;AAElC,YACSb,EAAe,MAAM,SAAS;AACrC,iBAAOjB,EAAEgD,GAAY;AAAA,YACnB,GAAGnB;AAAA,YACH,MAAMxB,EAAM;AAAA,YACZ,UAAAuB;AAAA,UAAA,CACD;AACH,YACSX,EAAe,MAAM,SAAS,QAAQ;AAC7C,cAAIZ,EAAM;AACR,mBAAOhB,EAAiByC,GAA2B;AACrD,gBAAMxC,IAAQwC,EAA0B,EAAI;AAC5C,iBAAO9B;AAAA,YACLiD;AAAA,YACA;AAAA,cACE,GAAGpB;AAAA,cACH,MAAMxB,EAAM;AAAA,cACZ,UAAAuB;AAAA,YAAA;AAAA,YAEFtC;AAAA,UAAA;AAAA,QAEJ;AAEA,eAAOU,EAAEkD,GAAO;AAAA,UACd,GAAGrB;AAAA,UACH,MAAMxB,EAAM;AAAA,UACZ,UAAAuB;AAAA,QAAA,CACD;AAAA,MACH;AAEA,UAAKX,EAAe;AAGpB,eAAO6B,EAAA;AAAA,IACT;AAAA,EACF;AACF,CAAC;"}
|
|
1
|
+
{"version":3,"file":"RecursionField.mjs","sources":["../../src/components/RecursionField.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Slots, VNode } from 'vue'\nimport type { IRecursionFieldProps, SchemaExpressionScope } from '../types'\nimport type { RecursionFieldProps } from '../utils/recursionFieldProps'\nimport type { NamedSlotMap } from '../utils/slotMap'\nimport { Schema } from '@formily/json-schema'\nimport { isFn, isValid, lazyMerge } from '@formily/shared'\nimport { computed, defineComponent, Fragment, h, inject, markRaw, provide, shallowRef, watch } from 'vue'\nimport { useField } from '../hooks'\nimport { SchemaExpressionScopeSymbol, SchemaOptionsSymbol, SchemaSymbol } from '../shared'\nimport { recursionFieldProps } from '../utils/recursionFieldProps'\nimport ArrayField from './ArrayField'\nimport Field from './Field'\n\nimport ObjectField from './ObjectField'\nimport VoidField from './VoidField'\n\ntype PropertyRenderFn = (field?: GeneralField) => VNode\ninterface ScopedSlotPayload { field?: GeneralField }\ntype SlotRender = (payload?: ScopedSlotPayload) => VNode[]\ntype SlotMap = NamedSlotMap<SlotRender>\n\nfunction resolveEmptySlot(slots: SlotMap) {\n const slotKeys = Object.keys(slots)\n if (!slotKeys.length)\n return null\n const children = slotKeys.reduce<VNode[]>((acc, key) => {\n const slot = slots[key]\n if (!slot)\n return acc\n const result = slot()\n if (!result?.length)\n return acc\n const validChildren = result.filter(child => isValid(child))\n acc.push(...validChildren)\n return acc\n }, [])\n if (!children.length)\n return null\n return h(Fragment, null, children)\n}\n\nconst RecursionField = defineComponent({\n name: 'RecursionField',\n inheritAttrs: false,\n props: recursionFieldProps,\n setup(props: RecursionFieldProps) {\n const parentRef = useField()\n const optionsRef = inject(SchemaOptionsSymbol)\n const scopeRef = inject(SchemaExpressionScopeSymbol)\n\n if (!optionsRef || !scopeRef) {\n throw new Error('RecursionField must be used under SchemaField.')\n }\n const createSchema = (schemaProp: IRecursionFieldProps['schema']) =>\n markRaw(Schema.isSchemaInstance(schemaProp) ? schemaProp : new Schema(schemaProp))\n const fieldSchemaRef = computed<Schema>(() => createSchema(props.schema ?? {}))\n\n const getPropsFromSchema = (schema: Schema) =>\n schema?.toFieldProps?.({\n ...optionsRef.value,\n get scope() {\n return lazyMerge(\n {} as SchemaExpressionScope,\n optionsRef.value.scope ?? {},\n scopeRef.value,\n )\n },\n })\n const fieldPropsRef = shallowRef(getPropsFromSchema(fieldSchemaRef.value))\n\n watch([fieldSchemaRef, optionsRef], () => {\n fieldPropsRef.value = getPropsFromSchema(fieldSchemaRef.value)\n })\n\n const getBasePath = () => {\n if (props.onlyRenderProperties) {\n return props.basePath ?? parentRef?.value?.address.concat(props.name!)\n }\n return props.basePath ?? parentRef?.value?.address\n }\n\n provide(SchemaSymbol, fieldSchemaRef)\n\n return () => {\n const basePath = getBasePath()\n const fieldProps = fieldPropsRef.value\n\n const generateSlotsByProperties = (scoped = false): SlotMap => {\n if (props.onlyRenderSelf)\n return {}\n const properties = Schema.getOrderProperties(fieldSchemaRef.value)\n if (!properties.length)\n return {}\n const renderMap: Record<string, PropertyRenderFn[]> = {}\n const setRender = (key: string, value: PropertyRenderFn) => {\n if (!renderMap[key]) {\n renderMap[key] = []\n }\n renderMap[key].push(value)\n }\n for (const [index, { schema: item, key: name }] of properties.entries()) {\n let schema: Schema = item\n if (isFn(props.mapProperties)) {\n const mapped = props.mapProperties(item, name)\n if (mapped) {\n schema = mapped\n }\n }\n if (isFn(props.filterProperties) && props.filterProperties(schema, name) === false) {\n continue\n }\n setRender(schema['x-slot'] ?? 'default', (field?: GeneralField) =>\n h(RecursionField, {\n key: `${index}-${name}`,\n schema,\n name,\n basePath: field?.address ?? basePath,\n slot: schema['x-slot'],\n }))\n }\n const slots: SlotMap = {}\n for (const key of Object.keys(renderMap)) {\n const renderFns = renderMap[key]\n const slotRender: SlotRender = scoped\n ? payload => renderFns!.map(fn => fn(payload?.field))\n : () => renderFns!.map(fn => fn())\n slots[key] = slotRender\n }\n return slots\n }\n\n const render = () => {\n if (!isValid(props.name))\n return resolveEmptySlot(generateSlotsByProperties())\n if (fieldSchemaRef.value.type === 'object') {\n if (props.onlyRenderProperties)\n return resolveEmptySlot(generateSlotsByProperties())\n return h(\n ObjectField,\n {\n ...fieldProps,\n name: props.name!,\n basePath,\n },\n generateSlotsByProperties(true) as Slots,\n )\n }\n else if (fieldSchemaRef.value.type === 'array') {\n return h(ArrayField, {\n ...fieldProps,\n name: props.name!,\n basePath,\n })\n }\n else if (fieldSchemaRef.value.type === 'void') {\n if (props.onlyRenderProperties)\n return resolveEmptySlot(generateSlotsByProperties())\n const slots = generateSlotsByProperties(true)\n return h(\n VoidField,\n {\n ...fieldProps,\n name: props.name!,\n basePath,\n },\n slots as Slots,\n )\n }\n\n return h(Field, {\n ...fieldProps,\n name: props.name!,\n basePath,\n })\n }\n\n return render()\n }\n },\n})\n\nexport default RecursionField\n"],"names":["resolveEmptySlot","slots","slotKeys","children","acc","key","slot","result","validChildren","child","isValid","h","Fragment","RecursionField","defineComponent","recursionFieldProps","props","parentRef","useField","optionsRef","inject","SchemaOptionsSymbol","scopeRef","SchemaExpressionScopeSymbol","createSchema","schemaProp","markRaw","Schema","fieldSchemaRef","computed","getPropsFromSchema","schema","lazyMerge","fieldPropsRef","shallowRef","watch","getBasePath","provide","SchemaSymbol","basePath","fieldProps","generateSlotsByProperties","scoped","properties","renderMap","setRender","value","index","item","name","isFn","mapped","field","renderFns","slotRender","payload","fn","ObjectField","ArrayField","VoidField","Field"],"mappings":";;;;;;;;;;;;AAsBA,SAASA,EAAiBC,GAAgB;AACxC,QAAMC,IAAW,OAAO,KAAKD,CAAK;AAClC,MAAI,CAACC,EAAS;AACZ,WAAO;AACT,QAAMC,IAAWD,EAAS,OAAgB,CAACE,GAAKC,MAAQ;AACtD,UAAMC,IAAOL,EAAMI,CAAG;AACtB,QAAI,CAACC;AACH,aAAOF;AACT,UAAMG,IAASD,EAAA;AACf,QAAI,CAACC,GAAQ;AACX,aAAOH;AACT,UAAMI,IAAgBD,EAAO,OAAO,CAAAE,MAASC,EAAQD,CAAK,CAAC;AAC3D,WAAAL,EAAI,KAAK,GAAGI,CAAa,GAClBJ;AAAA,EACT,GAAG,CAAA,CAAE;AACL,SAAKD,EAAS,SAEPQ,EAAEC,GAAU,MAAMT,CAAQ,IADxB;AAEX;AAEA,MAAMU,IAAiBC,EAAgB;AAAA,EACrC,MAAM;AAAA,EACN,cAAc;AAAA,EACd,OAAOC;AAAA,EACP,MAAMC,GAA4B;AAChC,UAAMC,IAAYC,EAAA,GACZC,IAAaC,EAAOC,CAAmB,GACvCC,IAAWF,EAAOG,CAA2B;AAEnD,QAAI,CAACJ,KAAc,CAACG;AAClB,YAAM,I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A,UAAA,CACD;AACH,YACSX,EAAe,MAAM,SAAS,QAAQ;AAC7C,cAAIZ,EAAM;AACR,mBAAOhB,EAAiByC,GAA2B;AACrD,gBAAMxC,IAAQwC,EAA0B,EAAI;AAC5C,iBAAO9B;AAAA,YACLgD;AAAA,YACA;AAAA,cACE,GAAGnB;AAAA,cACH,MAAMxB,EAAM;AAAA,cACZ,UAAAuB;AAAA,YAAA;AAAA,YAEFtC;AAAA,UAAA;AAAA,QAEJ;AAEA,eAAOU,EAAEiD,GAAO;AAAA,UACd,GAAGpB;AAAA,UACH,MAAMxB,EAAM;AAAA,UACZ,UAAAuB;AAAA,QAAA,CACD;AAAA,MACH,GAEO;AAAA,IACT;AAAA,EACF;AACF,CAAC;"}
|
|
@@ -1,32 +1,145 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SchemaTypes } from '@formily/json-schema';
|
|
2
|
+
import { VNode } from 'vue';
|
|
2
3
|
import { ISchemaFieldVueFactoryOptions, SchemaExpressionScope, SchemaVueComponents } from '../types';
|
|
3
4
|
export declare function createSchemaField<Components extends SchemaVueComponents = SchemaVueComponents>(options?: ISchemaFieldVueFactoryOptions<Components>): {
|
|
4
5
|
SchemaField: import('vue').DefineComponent<{
|
|
5
|
-
|
|
6
|
-
components?: {
|
|
6
|
+
readonly name?: import('@formily/json-schema').SchemaKey | undefined;
|
|
7
|
+
readonly components?: {
|
|
7
8
|
[key: string]: import('vue').Component;
|
|
8
9
|
} | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
readonly basePath?: import('@formily/shared').FormPathPattern | undefined;
|
|
11
|
+
readonly schema?: import('@formily/json-schema').Stringify<{
|
|
12
|
+
[key: symbol]: any;
|
|
13
|
+
[key: `x-${string}`]: any;
|
|
14
|
+
[key: `x-${number}`]: any;
|
|
15
|
+
version?: string;
|
|
16
|
+
name?: import('@formily/json-schema').SchemaKey;
|
|
17
|
+
title?: any;
|
|
18
|
+
description?: any;
|
|
19
|
+
default?: any;
|
|
20
|
+
readOnly?: boolean;
|
|
21
|
+
writeOnly?: boolean;
|
|
22
|
+
type?: SchemaTypes;
|
|
23
|
+
enum?: import('@formily/json-schema').SchemaEnum<any> | undefined;
|
|
24
|
+
const?: any;
|
|
25
|
+
multipleOf?: number;
|
|
26
|
+
maximum?: number;
|
|
27
|
+
exclusiveMaximum?: number;
|
|
28
|
+
minimum?: number;
|
|
29
|
+
exclusiveMinimum?: number;
|
|
30
|
+
maxLength?: number;
|
|
31
|
+
minLength?: number;
|
|
32
|
+
pattern?: string | RegExp;
|
|
33
|
+
maxItems?: number;
|
|
34
|
+
minItems?: number;
|
|
35
|
+
uniqueItems?: boolean;
|
|
36
|
+
maxProperties?: number;
|
|
37
|
+
minProperties?: number;
|
|
38
|
+
required?: string[] | boolean | string;
|
|
39
|
+
format?: string;
|
|
40
|
+
$ref?: string;
|
|
41
|
+
$namespace?: string;
|
|
42
|
+
definitions?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
43
|
+
properties?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
44
|
+
items?: import('@formily/json-schema').SchemaItems<any, any, any, any, any, any, any, any> | undefined;
|
|
45
|
+
additionalItems?: import('@formily/json-schema').Stringify</*elided*/ any> | undefined;
|
|
46
|
+
patternProperties?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
47
|
+
additionalProperties?: import('@formily/json-schema').Stringify</*elided*/ any> | undefined;
|
|
48
|
+
"x-value"?: any;
|
|
49
|
+
"x-index"?: number;
|
|
50
|
+
"x-pattern"?: any;
|
|
51
|
+
"x-display"?: any;
|
|
52
|
+
"x-validator"?: any;
|
|
53
|
+
"x-decorator"?: any;
|
|
54
|
+
"x-decorator-props"?: any;
|
|
55
|
+
"x-component"?: any;
|
|
56
|
+
"x-component-props"?: any;
|
|
57
|
+
"x-reactions"?: import('@formily/json-schema').SchemaReactions<any> | undefined;
|
|
58
|
+
"x-content"?: any;
|
|
59
|
+
"x-data"?: any;
|
|
60
|
+
"x-visible"?: boolean;
|
|
61
|
+
"x-hidden"?: boolean;
|
|
62
|
+
"x-disabled"?: boolean;
|
|
63
|
+
"x-editable"?: boolean;
|
|
64
|
+
"x-read-only"?: boolean;
|
|
65
|
+
"x-read-pretty"?: boolean;
|
|
66
|
+
"x-compile-omitted"?: string[];
|
|
67
|
+
}> | undefined;
|
|
68
|
+
readonly onlyRenderProperties?: boolean | undefined;
|
|
69
|
+
readonly onlyRenderSelf?: boolean | undefined;
|
|
70
|
+
readonly mapProperties?: import('..').ISchemaMapper | undefined;
|
|
71
|
+
readonly filterProperties?: import('..').ISchemaFilter | undefined;
|
|
72
|
+
readonly scope?: SchemaExpressionScope | undefined;
|
|
73
|
+
}, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
17
74
|
[key: string]: any;
|
|
18
75
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
19
|
-
|
|
20
|
-
components?: {
|
|
76
|
+
readonly name?: import('@formily/json-schema').SchemaKey | undefined;
|
|
77
|
+
readonly components?: {
|
|
21
78
|
[key: string]: import('vue').Component;
|
|
22
79
|
} | undefined;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
80
|
+
readonly basePath?: import('@formily/shared').FormPathPattern | undefined;
|
|
81
|
+
readonly schema?: import('@formily/json-schema').Stringify<{
|
|
82
|
+
[key: symbol]: any;
|
|
83
|
+
[key: `x-${string}`]: any;
|
|
84
|
+
[key: `x-${number}`]: any;
|
|
85
|
+
version?: string;
|
|
86
|
+
name?: import('@formily/json-schema').SchemaKey;
|
|
87
|
+
title?: any;
|
|
88
|
+
description?: any;
|
|
89
|
+
default?: any;
|
|
90
|
+
readOnly?: boolean;
|
|
91
|
+
writeOnly?: boolean;
|
|
92
|
+
type?: SchemaTypes;
|
|
93
|
+
enum?: import('@formily/json-schema').SchemaEnum<any> | undefined;
|
|
94
|
+
const?: any;
|
|
95
|
+
multipleOf?: number;
|
|
96
|
+
maximum?: number;
|
|
97
|
+
exclusiveMaximum?: number;
|
|
98
|
+
minimum?: number;
|
|
99
|
+
exclusiveMinimum?: number;
|
|
100
|
+
maxLength?: number;
|
|
101
|
+
minLength?: number;
|
|
102
|
+
pattern?: string | RegExp;
|
|
103
|
+
maxItems?: number;
|
|
104
|
+
minItems?: number;
|
|
105
|
+
uniqueItems?: boolean;
|
|
106
|
+
maxProperties?: number;
|
|
107
|
+
minProperties?: number;
|
|
108
|
+
required?: string[] | boolean | string;
|
|
109
|
+
format?: string;
|
|
110
|
+
$ref?: string;
|
|
111
|
+
$namespace?: string;
|
|
112
|
+
definitions?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
113
|
+
properties?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
114
|
+
items?: import('@formily/json-schema').SchemaItems<any, any, any, any, any, any, any, any> | undefined;
|
|
115
|
+
additionalItems?: import('@formily/json-schema').Stringify</*elided*/ any> | undefined;
|
|
116
|
+
patternProperties?: import('@formily/json-schema').SchemaProperties<any, any, any, any, any, any, any, any> | undefined;
|
|
117
|
+
additionalProperties?: import('@formily/json-schema').Stringify</*elided*/ any> | undefined;
|
|
118
|
+
"x-value"?: any;
|
|
119
|
+
"x-index"?: number;
|
|
120
|
+
"x-pattern"?: any;
|
|
121
|
+
"x-display"?: any;
|
|
122
|
+
"x-validator"?: any;
|
|
123
|
+
"x-decorator"?: any;
|
|
124
|
+
"x-decorator-props"?: any;
|
|
125
|
+
"x-component"?: any;
|
|
126
|
+
"x-component-props"?: any;
|
|
127
|
+
"x-reactions"?: import('@formily/json-schema').SchemaReactions<any> | undefined;
|
|
128
|
+
"x-content"?: any;
|
|
129
|
+
"x-data"?: any;
|
|
130
|
+
"x-visible"?: boolean;
|
|
131
|
+
"x-hidden"?: boolean;
|
|
132
|
+
"x-disabled"?: boolean;
|
|
133
|
+
"x-editable"?: boolean;
|
|
134
|
+
"x-read-only"?: boolean;
|
|
135
|
+
"x-read-pretty"?: boolean;
|
|
136
|
+
"x-compile-omitted"?: string[];
|
|
137
|
+
}> | undefined;
|
|
138
|
+
readonly onlyRenderProperties?: boolean | undefined;
|
|
139
|
+
readonly onlyRenderSelf?: boolean | undefined;
|
|
140
|
+
readonly mapProperties?: import('..').ISchemaMapper | undefined;
|
|
141
|
+
readonly filterProperties?: import('..').ISchemaFilter | undefined;
|
|
142
|
+
readonly scope?: SchemaExpressionScope | undefined;
|
|
30
143
|
}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
31
144
|
SchemaMarkupField: import('vue').DefineComponent<{
|
|
32
145
|
readonly format?: string | undefined;
|
|
@@ -187,9 +300,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
187
300
|
readonly 'x-read-only'?: boolean | undefined;
|
|
188
301
|
readonly 'x-read-pretty'?: boolean | undefined;
|
|
189
302
|
readonly 'x-decorator-content'?: any;
|
|
190
|
-
}, (
|
|
191
|
-
[key: string]: any;
|
|
192
|
-
}>), {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
303
|
+
}, () => VNode | null, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
|
|
193
304
|
readonly format?: string | undefined;
|
|
194
305
|
readonly required?: string | boolean | string[] | undefined;
|
|
195
306
|
readonly pattern?: string | RegExp | undefined;
|
|
@@ -508,7 +619,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
508
619
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
509
620
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
510
621
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
511
|
-
}>, () =>
|
|
622
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
512
623
|
[key: string]: any;
|
|
513
624
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
514
625
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -829,7 +940,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
829
940
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
830
941
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
831
942
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
832
|
-
}>, () =>
|
|
943
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
833
944
|
[key: string]: any;
|
|
834
945
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
835
946
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -1150,7 +1261,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
1150
1261
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1151
1262
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1152
1263
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1153
|
-
}>, () =>
|
|
1264
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
1154
1265
|
[key: string]: any;
|
|
1155
1266
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
1156
1267
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -1471,7 +1582,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
1471
1582
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1472
1583
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1473
1584
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1474
|
-
}>, () =>
|
|
1585
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
1475
1586
|
[key: string]: any;
|
|
1476
1587
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
1477
1588
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -1792,7 +1903,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
1792
1903
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1793
1904
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1794
1905
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
1795
|
-
}>, () =>
|
|
1906
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
1796
1907
|
[key: string]: any;
|
|
1797
1908
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
1798
1909
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -2113,7 +2224,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
2113
2224
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2114
2225
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2115
2226
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2116
|
-
}>, () =>
|
|
2227
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
2117
2228
|
[key: string]: any;
|
|
2118
2229
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
2119
2230
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -2434,7 +2545,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
2434
2545
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2435
2546
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2436
2547
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2437
|
-
}>, () =>
|
|
2548
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
2438
2549
|
[key: string]: any;
|
|
2439
2550
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
2440
2551
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -2755,7 +2866,7 @@ export declare function createSchemaField<Components extends SchemaVueComponents
|
|
|
2755
2866
|
'x-editable': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2756
2867
|
'x-read-only': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2757
2868
|
'x-read-pretty': import('../utils/runtimeProps').RuntimeProp<boolean>;
|
|
2758
|
-
}>, () =>
|
|
2869
|
+
}>, () => VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
2759
2870
|
[key: string]: any;
|
|
2760
2871
|
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
2761
2872
|
version: import('../utils/runtimeProps').RuntimeProp<string | (string & {}) | undefined>;
|
|
@@ -1,88 +1,90 @@
|
|
|
1
|
-
import { Schema as
|
|
2
|
-
import { lazyMerge as
|
|
3
|
-
import { defineComponent as
|
|
1
|
+
import { Schema as f } from "@formily/json-schema";
|
|
2
|
+
import { lazyMerge as g } from "@formily/shared";
|
|
3
|
+
import { defineComponent as u, computed as h, provide as i, h as l, Fragment as y, inject as A, shallowRef as j, watch as I } from "vue";
|
|
4
4
|
import "@formily/core";
|
|
5
5
|
import "@silver-formily/reactive-vue";
|
|
6
|
-
import { SchemaMarkupSymbol as
|
|
7
|
-
import { resolveSchemaProps as
|
|
8
|
-
import { schemaFieldProps as k, markupSchemaProps as
|
|
6
|
+
import { SchemaMarkupSymbol as S, SchemaOptionsSymbol as M, SchemaExpressionScopeSymbol as N } from "../shared/context.mjs";
|
|
7
|
+
import { resolveSchemaProps as p } from "../utils/resolveSchemaProps.mjs";
|
|
8
|
+
import { schemaFieldProps as k, markupSchemaProps as v } from "../utils/schemaFieldProps.mjs";
|
|
9
9
|
import D from "./RecursionField.mjs";
|
|
10
|
-
const
|
|
10
|
+
const b = {
|
|
11
11
|
nonameId: 0
|
|
12
12
|
};
|
|
13
13
|
function P() {
|
|
14
|
-
return `NO_NAME_FIELD_$${
|
|
14
|
+
return `NO_NAME_FIELD_$${b.nonameId++}`;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
16
|
+
function C(d = {}) {
|
|
17
|
+
const R = u({
|
|
18
18
|
name: "SchemaField",
|
|
19
19
|
inheritAttrs: !1,
|
|
20
20
|
props: k,
|
|
21
|
-
setup(a, { slots:
|
|
22
|
-
const e =
|
|
23
|
-
() =>
|
|
21
|
+
setup(a, { slots: r }) {
|
|
22
|
+
const e = h(
|
|
23
|
+
() => f.isSchemaInstance(a.schema) ? a.schema : new f({
|
|
24
24
|
type: "object",
|
|
25
25
|
...a.schema
|
|
26
26
|
})
|
|
27
|
-
),
|
|
28
|
-
() =>
|
|
29
|
-
),
|
|
30
|
-
...
|
|
27
|
+
), m = h(
|
|
28
|
+
() => g({}, d.scope ?? {}, a.scope ?? {})
|
|
29
|
+
), n = h(() => ({
|
|
30
|
+
...d,
|
|
31
31
|
components: {
|
|
32
|
-
...
|
|
32
|
+
...d.components,
|
|
33
33
|
...a.components
|
|
34
34
|
}
|
|
35
35
|
}));
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
const
|
|
36
|
+
return i(S, e), i(M, n), i(N, m), () => {
|
|
37
|
+
b.nonameId = 0;
|
|
38
|
+
const s = r.default?.() ?? [], o = l(D, {
|
|
39
39
|
...a,
|
|
40
40
|
schema: e.value
|
|
41
41
|
});
|
|
42
|
-
return
|
|
42
|
+
return l(y, null, [...s, o]);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
}),
|
|
45
|
+
}), F = u({
|
|
46
46
|
name: "MarkupField",
|
|
47
47
|
props: {
|
|
48
48
|
type: String,
|
|
49
|
-
...
|
|
49
|
+
...v
|
|
50
50
|
},
|
|
51
|
-
setup(a, { slots:
|
|
52
|
-
const e =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
setup(a, { slots: r }) {
|
|
52
|
+
const e = A(S, null);
|
|
53
|
+
let m = () => null;
|
|
54
|
+
if (e?.value) {
|
|
55
|
+
const n = a.name || P(), s = (c) => e.value.items ? e.value.addProperty(n, c) : e.value.setItems(p(a)), o = j(e.value);
|
|
56
|
+
I(
|
|
57
|
+
e,
|
|
58
|
+
() => {
|
|
59
|
+
if (e.value.type === "object" || e.value.type === "void")
|
|
60
|
+
o.value = e.value.addProperty(n, p(a));
|
|
61
|
+
else if (e.value.type === "array") {
|
|
62
|
+
const c = s(p(a));
|
|
63
|
+
o.value = Array.isArray(c) ? c[0] : c;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{ immediate: !0, flush: "sync" }
|
|
67
|
+
), i(S, o), m = () => l(y, null, r.default?.() ?? []);
|
|
68
|
+
}
|
|
69
|
+
return m;
|
|
68
70
|
}
|
|
69
|
-
}), t = (a,
|
|
70
|
-
name:
|
|
71
|
-
props: { ...
|
|
72
|
-
setup(e, { slots:
|
|
73
|
-
return () =>
|
|
74
|
-
|
|
71
|
+
}), t = (a, r) => u({
|
|
72
|
+
name: r,
|
|
73
|
+
props: { ...v },
|
|
74
|
+
setup(e, { slots: m }) {
|
|
75
|
+
return () => l(
|
|
76
|
+
F,
|
|
75
77
|
{
|
|
76
78
|
...e,
|
|
77
79
|
type: a
|
|
78
80
|
},
|
|
79
|
-
|
|
81
|
+
m
|
|
80
82
|
);
|
|
81
83
|
}
|
|
82
84
|
});
|
|
83
85
|
return {
|
|
84
|
-
SchemaField:
|
|
85
|
-
SchemaMarkupField:
|
|
86
|
+
SchemaField: R,
|
|
87
|
+
SchemaMarkupField: F,
|
|
86
88
|
SchemaStringField: t("string", "SchemaStringField"),
|
|
87
89
|
SchemaObjectField: t("object", "SchemaObjectField"),
|
|
88
90
|
SchemaArrayField: t("array", "SchemaArrayField"),
|
|
@@ -94,6 +96,6 @@ function $(l = {}) {
|
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
98
|
export {
|
|
97
|
-
|
|
99
|
+
C as createSchemaField
|
|
98
100
|
};
|
|
99
101
|
//# sourceMappingURL=SchemaField.mjs.map
|