@silver-formily/vue 0.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/esm/components/ArrayField.d.ts +56 -0
  2. package/esm/components/ArrayField.mjs +24 -0
  3. package/esm/components/ArrayField.mjs.map +1 -0
  4. package/esm/components/ExpressionScope.d.ts +16 -0
  5. package/esm/components/ExpressionScope.mjs +25 -0
  6. package/esm/components/ExpressionScope.mjs.map +1 -0
  7. package/esm/components/Field.d.ts +56 -0
  8. package/esm/components/Field.mjs +24 -0
  9. package/esm/components/Field.mjs.map +1 -0
  10. package/esm/components/FormConsumer.d.ts +4 -0
  11. package/esm/components/FormConsumer.mjs +19 -0
  12. package/esm/components/FormConsumer.mjs.map +1 -0
  13. package/esm/components/FormProvider.d.ts +16 -0
  14. package/esm/components/FormProvider.mjs +27 -0
  15. package/esm/components/FormProvider.mjs.map +1 -0
  16. package/esm/components/ObjectField.d.ts +56 -0
  17. package/esm/components/ObjectField.mjs +24 -0
  18. package/esm/components/ObjectField.mjs.map +1 -0
  19. package/esm/components/ReactiveField.d.ts +16 -0
  20. package/esm/components/ReactiveField.mjs +75 -0
  21. package/esm/components/ReactiveField.mjs.map +1 -0
  22. package/esm/components/RecursionField.d.ts +22 -0
  23. package/esm/components/RecursionField.mjs +129 -0
  24. package/esm/components/RecursionField.mjs.map +1 -0
  25. package/esm/components/SchemaField.d.ts +2900 -0
  26. package/esm/components/SchemaField.mjs +106 -0
  27. package/esm/components/SchemaField.mjs.map +1 -0
  28. package/esm/components/VoidField.d.ts +40 -0
  29. package/esm/components/VoidField.mjs +24 -0
  30. package/esm/components/VoidField.mjs.map +1 -0
  31. package/esm/components/index.d.ts +9 -0
  32. package/esm/components/index.mjs +21 -0
  33. package/esm/components/index.mjs.map +1 -0
  34. package/esm/global.d.mjs +2 -0
  35. package/esm/global.d.mjs.map +1 -0
  36. package/esm/hooks/index.d.ts +5 -0
  37. package/esm/hooks/index.mjs +13 -0
  38. package/esm/hooks/index.mjs.map +1 -0
  39. package/esm/hooks/useAttach.d.ts +7 -0
  40. package/esm/hooks/useAttach.mjs +14 -0
  41. package/esm/hooks/useAttach.mjs.map +1 -0
  42. package/esm/hooks/useField.d.ts +3 -0
  43. package/esm/hooks/useField.mjs +9 -0
  44. package/esm/hooks/useField.mjs.map +1 -0
  45. package/esm/hooks/useFieldSchema.d.ts +1 -0
  46. package/esm/hooks/useFieldSchema.mjs +9 -0
  47. package/esm/hooks/useFieldSchema.mjs.map +1 -0
  48. package/esm/hooks/useForm.d.ts +3 -0
  49. package/esm/hooks/useForm.mjs +9 -0
  50. package/esm/hooks/useForm.mjs.map +1 -0
  51. package/esm/hooks/useFormEffects.d.ts +2 -0
  52. package/esm/hooks/useFormEffects.mjs +16 -0
  53. package/esm/hooks/useFormEffects.mjs.map +1 -0
  54. package/esm/hooks/useInjectionCleaner.d.ts +2 -0
  55. package/esm/hooks/useInjectionCleaner.mjs +8 -0
  56. package/esm/hooks/useInjectionCleaner.mjs.map +1 -0
  57. package/esm/hooks/useParentForm.d.ts +3 -0
  58. package/esm/hooks/useParentForm.mjs +12 -0
  59. package/esm/hooks/useParentForm.mjs.map +1 -0
  60. package/esm/index.d.ts +4 -0
  61. package/esm/index.mjs +42 -0
  62. package/esm/index.mjs.map +1 -0
  63. package/esm/shared/connect.d.ts +9 -0
  64. package/esm/shared/connect.mjs +66 -0
  65. package/esm/shared/connect.mjs.map +1 -0
  66. package/esm/shared/context.d.ts +10 -0
  67. package/esm/shared/context.mjs +10 -0
  68. package/esm/shared/context.mjs.map +1 -0
  69. package/esm/shared/index.d.ts +2 -0
  70. package/esm/shared/index.mjs +14 -0
  71. package/esm/shared/index.mjs.map +1 -0
  72. package/esm/types/index.d.ts +64 -0
  73. package/esm/types/index.mjs +2 -0
  74. package/esm/types/index.mjs.map +1 -0
  75. package/esm/utils/fieldProps.d.ts +49 -0
  76. package/esm/utils/fieldProps.mjs +51 -0
  77. package/esm/utils/fieldProps.mjs.map +1 -0
  78. package/esm/utils/getRawComponent.d.ts +8 -0
  79. package/esm/utils/getRawComponent.mjs +13 -0
  80. package/esm/utils/getRawComponent.mjs.map +1 -0
  81. package/esm/utils/reactiveFieldHelpers.d.ts +16 -0
  82. package/esm/utils/reactiveFieldHelpers.mjs +106 -0
  83. package/esm/utils/reactiveFieldHelpers.mjs.map +1 -0
  84. package/esm/utils/recursionFieldProps.d.ts +67 -0
  85. package/esm/utils/recursionFieldProps.mjs +14 -0
  86. package/esm/utils/recursionFieldProps.mjs.map +1 -0
  87. package/esm/utils/resolveSchemaProps.d.ts +1 -0
  88. package/esm/utils/resolveSchemaProps.mjs +11 -0
  89. package/esm/utils/resolveSchemaProps.mjs.map +1 -0
  90. package/esm/utils/runtimeProps.d.ts +8 -0
  91. package/esm/utils/runtimeProps.mjs +17 -0
  92. package/esm/utils/runtimeProps.mjs.map +1 -0
  93. package/esm/utils/schemaFieldProps.d.ts +231 -0
  94. package/esm/utils/schemaFieldProps.mjs +63 -0
  95. package/esm/utils/schemaFieldProps.mjs.map +1 -0
  96. package/package.json +69 -0
@@ -0,0 +1,106 @@
1
+ import { Schema as F } from "@formily/json-schema";
2
+ import { lazyMerge as R } from "@formily/shared";
3
+ import { defineComponent as d, computed as u, provide as c, h as i, Fragment as f, inject as g, shallowRef as j, watch as I } from "vue";
4
+ import "./ArrayField.mjs";
5
+ import "./ExpressionScope.mjs";
6
+ import "./Field.mjs";
7
+ import "./FormConsumer.mjs";
8
+ import "./FormProvider.mjs";
9
+ import "./ObjectField.mjs";
10
+ import M from "./RecursionField.mjs";
11
+ import "./VoidField.mjs";
12
+ import "@formily/core";
13
+ import "@formily/reactive-vue";
14
+ import { SchemaMarkupSymbol as h, SchemaOptionsSymbol as N, SchemaExpressionScopeSymbol as k } from "../shared/context.mjs";
15
+ import { resolveSchemaProps as p } from "../utils/resolveSchemaProps.mjs";
16
+ import { schemaFieldProps as D, markupSchemaProps as y } from "../utils/schemaFieldProps.mjs";
17
+ const v = {
18
+ nonameId: 0
19
+ };
20
+ function P() {
21
+ return `NO_NAME_FIELD_$${v.nonameId++}`;
22
+ }
23
+ function K(l = {}) {
24
+ const b = d({
25
+ name: "SchemaField",
26
+ inheritAttrs: !1,
27
+ props: D,
28
+ setup(a, { slots: n }) {
29
+ const e = u(
30
+ () => F.isSchemaInstance(a.schema) ? a.schema : new F({
31
+ type: "object",
32
+ ...a.schema
33
+ })
34
+ ), o = u(
35
+ () => R({}, l.scope ?? {}, a.scope ?? {})
36
+ ), s = u(() => ({
37
+ ...l,
38
+ components: {
39
+ ...l.components,
40
+ ...a.components
41
+ }
42
+ }));
43
+ return c(h, e), c(N, s), c(k, o), () => {
44
+ v.nonameId = 0;
45
+ const r = n.default?.(), m = Array.isArray(r) ? r : r ? [r] : [], A = i(M, {
46
+ ...a,
47
+ schema: e.value
48
+ });
49
+ return i(f, null, [...m, A]);
50
+ };
51
+ }
52
+ }), S = d({
53
+ name: "MarkupField",
54
+ props: {
55
+ type: String,
56
+ ...y
57
+ },
58
+ setup(a, { slots: n }) {
59
+ const e = g(h, null);
60
+ if (!e || !e.value)
61
+ return () => null;
62
+ const o = a.name || P(), s = (m) => e.value.items ? e.value.addProperty(o, m) : e.value.setItems(p(a)), r = j();
63
+ return I(
64
+ e,
65
+ () => {
66
+ if (e.value.type === "object" || e.value.type === "void")
67
+ r.value = e.value.addProperty(o, p(a));
68
+ else if (e.value.type === "array") {
69
+ const m = s(p(a));
70
+ r.value = Array.isArray(m) ? m[0] : m;
71
+ }
72
+ },
73
+ { immediate: !0 }
74
+ ), c(h, r), () => i(f, null, n.default?.());
75
+ }
76
+ }), t = (a, n) => d({
77
+ name: n,
78
+ props: { ...y },
79
+ setup(e, { slots: o }) {
80
+ return () => i(
81
+ S,
82
+ {
83
+ ...e,
84
+ type: a
85
+ },
86
+ o
87
+ );
88
+ }
89
+ });
90
+ return {
91
+ SchemaField: b,
92
+ SchemaMarkupField: S,
93
+ SchemaStringField: t("string", "SchemaStringField"),
94
+ SchemaObjectField: t("object", "SchemaObjectField"),
95
+ SchemaArrayField: t("array", "SchemaArrayField"),
96
+ SchemaBooleanField: t("boolean", "SchemaBooleanField"),
97
+ SchemaDateField: t("date", "SchemaDateField"),
98
+ SchemaDateTimeField: t("datetime", "SchemaDatetimeField"),
99
+ SchemaVoidField: t("void", "SchemaVoidField"),
100
+ SchemaNumberField: t("number", "SchemaNumberField")
101
+ };
102
+ }
103
+ export {
104
+ K as createSchemaField
105
+ };
106
+ //# sourceMappingURL=SchemaField.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaField.mjs","sources":["../../src/components/SchemaField.ts"],"sourcesContent":["import type { ISchema, SchemaTypes } from '@formily/json-schema'\nimport type {\n ISchemaFieldProps,\n ISchemaFieldVueFactoryOptions,\n SchemaExpressionScope,\n SchemaVueComponents,\n // ISchemaMarkupFieldProps,\n // ISchemaTypeFieldProps,\n} from '../types'\nimport type { MarkupSchemaProps } from '../utils/schemaFieldProps'\nimport { Schema } from '@formily/json-schema'\nimport { lazyMerge } from '@formily/shared'\nimport { computed, defineComponent, Fragment, h, inject, provide, shallowRef, watch } from 'vue'\nimport { RecursionField } from '../components'\nimport { SchemaExpressionScopeSymbol, SchemaMarkupSymbol, SchemaOptionsSymbol } from '../shared'\nimport { resolveSchemaProps } from '../utils/resolveSchemaProps'\nimport {\n markupSchemaProps,\n\n schemaFieldProps,\n} from '../utils/schemaFieldProps'\n\nconst env = {\n nonameId: 0,\n}\n\nfunction getRandomName() {\n return `NO_NAME_FIELD_$${env.nonameId++}`\n}\n\nexport function createSchemaField<Components extends SchemaVueComponents = SchemaVueComponents>(\n options: ISchemaFieldVueFactoryOptions<Components> = {},\n) {\n const SchemaField = defineComponent({\n name: 'SchemaField',\n inheritAttrs: false,\n props: schemaFieldProps,\n setup(props: ISchemaFieldProps, { slots }) {\n const schemaRef = computed(() =>\n Schema.isSchemaInstance(props.schema)\n ? props.schema\n : new Schema({\n type: 'object',\n ...props.schema,\n }),\n )\n\n const scopeRef = computed<SchemaExpressionScope>(() =>\n lazyMerge({} as SchemaExpressionScope, options.scope ?? {}, props.scope ?? {}),\n )\n\n const optionsRef = computed(() => ({\n ...options,\n components: {\n ...options.components,\n ...props.components,\n },\n }))\n\n provide(SchemaMarkupSymbol, schemaRef)\n provide(SchemaOptionsSymbol, optionsRef)\n provide(SchemaExpressionScopeSymbol, scopeRef)\n\n return () => {\n env.nonameId = 0\n\n const slotContent = slots.default?.()\n const normalizedSlots = Array.isArray(slotContent)\n ? slotContent\n : slotContent\n ? [slotContent]\n : []\n\n const recursionNode = h(RecursionField, {\n ...props,\n schema: schemaRef.value,\n })\n\n return h(Fragment, null, [...normalizedSlots, recursionNode])\n }\n },\n })\n\n const MarkupField = defineComponent({\n name: 'MarkupField',\n props: {\n type: String,\n ...markupSchemaProps,\n },\n setup(props: MarkupSchemaProps, { slots }) {\n const parentRef = inject(SchemaMarkupSymbol, null)\n if (!parentRef || !parentRef.value)\n return () => null\n\n const name = props.name || getRandomName()\n const appendArraySchema = (schema: ISchema) => {\n if (parentRef.value.items) {\n return parentRef.value.addProperty(name, schema)\n }\n else {\n return parentRef.value.setItems(resolveSchemaProps(props))\n }\n }\n\n const schemaRef = shallowRef()\n\n watch(\n parentRef,\n () => {\n if (parentRef.value.type === 'object' || parentRef.value.type === 'void') {\n schemaRef.value = parentRef.value.addProperty(name, resolveSchemaProps(props))\n }\n else if (parentRef.value.type === 'array') {\n const schema = appendArraySchema(resolveSchemaProps(props))\n schemaRef.value = Array.isArray(schema) ? schema[0] : schema\n }\n },\n { immediate: true },\n )\n provide(SchemaMarkupSymbol, schemaRef)\n\n return () => h(Fragment, null, slots.default?.())\n },\n })\n\n const SchemaFieldFactory = (type: SchemaTypes, name: string) => {\n return defineComponent({\n name,\n props: { ...markupSchemaProps },\n setup(props, { slots }) {\n return () =>\n h(\n MarkupField,\n {\n ...props,\n type,\n },\n slots,\n )\n },\n })\n }\n\n return {\n SchemaField,\n SchemaMarkupField: MarkupField,\n SchemaStringField: SchemaFieldFactory('string', 'SchemaStringField'),\n SchemaObjectField: SchemaFieldFactory('object', 'SchemaObjectField'),\n SchemaArrayField: SchemaFieldFactory('array', 'SchemaArrayField'),\n SchemaBooleanField: SchemaFieldFactory('boolean', 'SchemaBooleanField'),\n SchemaDateField: SchemaFieldFactory('date', 'SchemaDateField'),\n SchemaDateTimeField: SchemaFieldFactory('datetime', 'SchemaDatetimeField'),\n SchemaVoidField: SchemaFieldFactory('void', 'SchemaVoidField'),\n SchemaNumberField: SchemaFieldFactory('number', 'SchemaNumberField'),\n }\n}\n"],"names":["env","getRandomName","createSchemaField","options","SchemaField","defineComponent","schemaFieldProps","props","slots","schemaRef","computed","Schema","scopeRef","lazyMerge","optionsRef","provide","SchemaMarkupSymbol","SchemaOptionsSymbol","SchemaExpressionScopeSymbol","slotContent","normalizedSlots","recursionNode","h","RecursionField","Fragment","MarkupField","markupSchemaProps","parentRef","inject","name","appendArraySchema","schema","resolveSchemaProps","shallowRef","watch","SchemaFieldFactory","type"],"mappings":"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"}
@@ -0,0 +1,40 @@
1
+ declare const _default: import('vue').DefineComponent<{
2
+ name: import('@formily/core').FormPathPattern;
3
+ basePath?: import('@formily/core').FormPathPattern;
4
+ title?: any;
5
+ description?: any;
6
+ display?: string;
7
+ pattern?: string;
8
+ hidden?: boolean;
9
+ visible?: boolean;
10
+ editable?: boolean;
11
+ disabled?: boolean;
12
+ readOnly?: boolean;
13
+ readPretty?: boolean;
14
+ decorator?: import('@formily/core').FieldDecorator<import('vue').Component, any>;
15
+ component?: import('@formily/core').FieldComponent<import('vue').Component, any>;
16
+ reactions?: import('@formily/core').FieldReaction[] | import('@formily/core').FieldReaction;
17
+ content?: any;
18
+ data?: any;
19
+ }, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
20
+ [key: string]: any;
21
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
22
+ name: import('@formily/core').FormPathPattern;
23
+ basePath?: import('@formily/core').FormPathPattern;
24
+ title?: any;
25
+ description?: any;
26
+ display?: string;
27
+ pattern?: string;
28
+ hidden?: boolean;
29
+ visible?: boolean;
30
+ editable?: boolean;
31
+ disabled?: boolean;
32
+ readOnly?: boolean;
33
+ readPretty?: boolean;
34
+ decorator?: import('@formily/core').FieldDecorator<import('vue').Component, any>;
35
+ component?: import('@formily/core').FieldComponent<import('vue').Component, any>;
36
+ reactions?: import('@formily/core').FieldReaction[] | import('@formily/core').FieldReaction;
37
+ content?: any;
38
+ data?: any;
39
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
40
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { defineComponent as t, h as r } from "vue";
2
+ import { voidFieldProps as d } from "../utils/fieldProps.mjs";
3
+ import { getRawComponent as m } from "../utils/getRawComponent.mjs";
4
+ import n from "./ReactiveField.mjs";
5
+ const s = t({
6
+ name: "VoidField",
7
+ props: d,
8
+ setup(o, { slots: e }) {
9
+ return () => {
10
+ const i = {
11
+ fieldType: "VoidField",
12
+ fieldProps: {
13
+ ...o,
14
+ ...m(o)
15
+ }
16
+ };
17
+ return r(n, i, e);
18
+ };
19
+ }
20
+ });
21
+ export {
22
+ s as default
23
+ };
24
+ //# sourceMappingURL=VoidField.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoidField.mjs","sources":["../../src/components/VoidField.ts"],"sourcesContent":["import type { IReactiveFieldProps, IVoidFieldProps } from '../types'\nimport { defineComponent, h } from 'vue'\nimport { voidFieldProps } from '../utils/fieldProps'\nimport { getRawComponent } from '../utils/getRawComponent'\nimport ReactiveField from './ReactiveField'\n\nexport default defineComponent({\n name: 'VoidField',\n props: voidFieldProps,\n setup(props: IVoidFieldProps, { slots }) {\n return () => {\n const componentData: IReactiveFieldProps = {\n fieldType: 'VoidField',\n fieldProps: {\n ...props,\n ...getRawComponent(props),\n },\n }\n return h(ReactiveField, componentData, slots)\n }\n },\n})\n"],"names":["VoidField","defineComponent","voidFieldProps","props","slots","componentData","getRawComponent","h","ReactiveField"],"mappings":";;;;AAMA,MAAAA,IAAeC,EAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,OAAOC;AAAA,EACP,MAAMC,GAAwB,EAAE,OAAAC,KAAS;AACvC,WAAO,MAAM;AACX,YAAMC,IAAqC;AAAA,QACzC,WAAW;AAAA,QACX,YAAY;AAAA,UACV,GAAGF;AAAA,UACH,GAAGG,EAAgBH,CAAK;AAAA,QAAA;AAAA,MAC1B;AAEF,aAAOI,EAAEC,GAAeH,GAAeD,CAAK;AAAA,IAC9C;AAAA,EACF;AACF,CAAC;"}
@@ -0,0 +1,9 @@
1
+ export { default as ArrayField } from './ArrayField';
2
+ export { default as ExpressionScope } from './ExpressionScope';
3
+ export { default as Field } from './Field';
4
+ export { default as FormConsumer } from './FormConsumer';
5
+ export { default as FormProvider } from './FormProvider';
6
+ export { default as ObjectField } from './ObjectField';
7
+ export { default as RecursionField } from './RecursionField';
8
+ export { createSchemaField } from './SchemaField';
9
+ export { default as VoidField } from './VoidField';
@@ -0,0 +1,21 @@
1
+ import { default as o } from "./ArrayField.mjs";
2
+ import { default as t } from "./ExpressionScope.mjs";
3
+ import { default as d } from "./Field.mjs";
4
+ import { default as m } from "./FormConsumer.mjs";
5
+ import { default as p } from "./FormProvider.mjs";
6
+ import { default as u } from "./ObjectField.mjs";
7
+ import { default as F } from "./RecursionField.mjs";
8
+ import { createSchemaField as n } from "./SchemaField.mjs";
9
+ import { default as b } from "./VoidField.mjs";
10
+ export {
11
+ o as ArrayField,
12
+ t as ExpressionScope,
13
+ d as Field,
14
+ m as FormConsumer,
15
+ p as FormProvider,
16
+ u as ObjectField,
17
+ F as RecursionField,
18
+ b as VoidField,
19
+ n as createSchemaField
20
+ };
21
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=global.d.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global.d.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export * from './useField';
2
+ export * from './useFieldSchema';
3
+ export * from './useForm';
4
+ export * from './useFormEffects';
5
+ export * from './useParentForm';
@@ -0,0 +1,13 @@
1
+ import { useField as o } from "./useField.mjs";
2
+ import { useFieldSchema as f } from "./useFieldSchema.mjs";
3
+ import { useForm as s } from "./useForm.mjs";
4
+ import { useFormEffects as u } from "./useFormEffects.mjs";
5
+ import { useParentForm as F } from "./useParentForm.mjs";
6
+ export {
7
+ o as useField,
8
+ f as useFieldSchema,
9
+ s as useForm,
10
+ u as useFormEffects,
11
+ F as useParentForm
12
+ };
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -0,0 +1,7 @@
1
+ import { Ref } from 'vue';
2
+ interface IRecycleTarget {
3
+ onMount: () => void;
4
+ onUnmount: () => void;
5
+ }
6
+ export declare function useAttach<T extends IRecycleTarget>(target: Ref<T>): Ref<T>;
7
+ export {};
@@ -0,0 +1,14 @@
1
+ import { watch as m, nextTick as e, onMounted as c, onUnmounted as i } from "vue";
2
+ function f(n) {
3
+ return m(n, (o, u, t) => {
4
+ o && o !== u && (u?.onUnmount(), e(() => o.onMount()), t(() => o.onUnmount()));
5
+ }), c(() => {
6
+ n.value?.onMount();
7
+ }), i(() => {
8
+ n.value?.onUnmount();
9
+ }), n;
10
+ }
11
+ export {
12
+ f as useAttach
13
+ };
14
+ //# sourceMappingURL=useAttach.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAttach.mjs","sources":["../../src/hooks/useAttach.ts"],"sourcesContent":["import type { Ref } from 'vue'\nimport { nextTick, onMounted, onUnmounted, watch } from 'vue'\n\ninterface IRecycleTarget {\n onMount: () => void\n onUnmount: () => void\n}\n\nexport function useAttach<T extends IRecycleTarget>(target: Ref<T>): Ref<T> {\n watch(target, (v, old, onInvalidate) => {\n if (v && v !== old) {\n old?.onUnmount()\n nextTick(() => v.onMount())\n onInvalidate(() => v.onUnmount())\n }\n })\n onMounted(() => {\n target.value?.onMount()\n })\n onUnmounted(() => {\n target.value?.onUnmount()\n })\n return target\n}\n"],"names":["useAttach","target","watch","v","old","onInvalidate","nextTick","onMounted","onUnmounted"],"mappings":";AAQO,SAASA,EAAoCC,GAAwB;AAC1E,SAAAC,EAAMD,GAAQ,CAACE,GAAGC,GAAKC,MAAiB;AACtC,IAAIF,KAAKA,MAAMC,MACbA,GAAK,UAAA,GACLE,EAAS,MAAMH,EAAE,SAAS,GAC1BE,EAAa,MAAMF,EAAE,WAAW;AAAA,EAEpC,CAAC,GACDI,EAAU,MAAM;AACd,IAAAN,EAAO,OAAO,QAAA;AAAA,EAChB,CAAC,GACDO,EAAY,MAAM;AAChB,IAAAP,EAAO,OAAO,UAAA;AAAA,EAChB,CAAC,GACMA;AACT;"}
@@ -0,0 +1,3 @@
1
+ import { GeneralField } from '@formily/core';
2
+ import { Ref } from 'vue';
3
+ export declare function useField<T = GeneralField>(): Ref<T>;
@@ -0,0 +1,9 @@
1
+ import { inject as r, ref as e } from "vue";
2
+ import { FieldSymbol as o } from "../shared/context.mjs";
3
+ function m() {
4
+ return r(o, e());
5
+ }
6
+ export {
7
+ m as useField
8
+ };
9
+ //# sourceMappingURL=useField.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useField.mjs","sources":["../../src/hooks/useField.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Ref } from 'vue'\nimport { inject, ref } from 'vue'\nimport { FieldSymbol } from '../shared/context'\n\nexport function useField<T = GeneralField>() {\n return inject(FieldSymbol, ref()) as Ref<T>\n}\n"],"names":["useField","inject","FieldSymbol","ref"],"mappings":";;AAKO,SAASA,IAA6B;AAC3C,SAAOC,EAAOC,GAAaC,GAAK;AAClC;"}
@@ -0,0 +1 @@
1
+ export declare function useFieldSchema(): import('vue').Ref<import('@formily/json-schema').Schema<any, any, any, any, any, any, any, any, any>, import('@formily/json-schema').Schema<any, any, any, any, any, any, any, any, any>>;
@@ -0,0 +1,9 @@
1
+ import { inject as e, ref as r } from "vue";
2
+ import { SchemaSymbol as m } from "../shared/context.mjs";
3
+ function i() {
4
+ return e(m, r());
5
+ }
6
+ export {
7
+ i as useFieldSchema
8
+ };
9
+ //# sourceMappingURL=useFieldSchema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldSchema.mjs","sources":["../../src/hooks/useFieldSchema.ts"],"sourcesContent":["import { inject, ref } from 'vue'\nimport { SchemaSymbol } from '../shared/context'\n\nexport function useFieldSchema() {\n return inject(SchemaSymbol, ref())\n}\n"],"names":["useFieldSchema","inject","SchemaSymbol","ref"],"mappings":";;AAGO,SAASA,IAAiB;AAC/B,SAAOC,EAAOC,GAAcC,GAAK;AACnC;"}
@@ -0,0 +1,3 @@
1
+ import { Form } from '@formily/core';
2
+ import { Ref } from 'vue';
3
+ export declare function useForm(): Ref<Form>;
@@ -0,0 +1,9 @@
1
+ import { inject as o, ref as r } from "vue";
2
+ import { FormSymbol as m } from "../shared/context.mjs";
3
+ function n() {
4
+ return o(m, r());
5
+ }
6
+ export {
7
+ n as useForm
8
+ };
9
+ //# sourceMappingURL=useForm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useForm.mjs","sources":["../../src/hooks/useForm.ts"],"sourcesContent":["import type { Form } from '@formily/core'\nimport type { Ref } from 'vue'\nimport { inject, ref } from 'vue'\nimport { FormSymbol } from '../shared/context'\n\nexport function useForm() {\n const form = inject(FormSymbol, ref())\n return form as Ref<Form>\n}\n"],"names":["useForm","inject","FormSymbol","ref"],"mappings":";;AAKO,SAASA,IAAU;AAExB,SADaC,EAAOC,GAAYC,EAAA,CAAK;AAEvC;"}
@@ -0,0 +1,2 @@
1
+ import { Form } from '@formily/core';
2
+ export declare function useFormEffects(effects?: (form: Form) => void): void;
@@ -0,0 +1,16 @@
1
+ import { uid as m } from "@formily/shared";
2
+ import { watchEffect as c, onBeforeUnmount as s } from "vue";
3
+ import { useForm as n } from "./useForm.mjs";
4
+ function a(t) {
5
+ const o = n(), e = c((r) => {
6
+ const f = m();
7
+ o.value.addEffects(f, t), r(() => {
8
+ o.value.removeEffects(f);
9
+ });
10
+ });
11
+ s(() => e());
12
+ }
13
+ export {
14
+ a as useFormEffects
15
+ };
16
+ //# sourceMappingURL=useFormEffects.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFormEffects.mjs","sources":["../../src/hooks/useFormEffects.ts"],"sourcesContent":["import type { Form } from '@formily/core'\nimport { uid } from '@formily/shared'\nimport { onBeforeUnmount, watchEffect } from 'vue'\nimport { useForm } from './useForm'\n\nexport function useFormEffects(effects?: (form: Form) => void): void {\n const formRef = useForm()\n\n const stop = watchEffect((onCleanup) => {\n const id = uid()\n formRef.value.addEffects(id, effects)\n\n onCleanup(() => {\n formRef.value.removeEffects(id)\n })\n })\n\n onBeforeUnmount(() => stop())\n}\n"],"names":["useFormEffects","effects","formRef","useForm","stop","watchEffect","onCleanup","id","uid","onBeforeUnmount"],"mappings":";;;AAKO,SAASA,EAAeC,GAAsC;AACnE,QAAMC,IAAUC,EAAA,GAEVC,IAAOC,EAAY,CAACC,MAAc;AACtC,UAAMC,IAAKC,EAAA;AACX,IAAAN,EAAQ,MAAM,WAAWK,GAAIN,CAAO,GAEpCK,EAAU,MAAM;AACd,MAAAJ,EAAQ,MAAM,cAAcK,CAAE;AAAA,IAChC,CAAC;AAAA,EACH,CAAC;AAED,EAAAE,EAAgB,MAAML,GAAM;AAC9B;"}
@@ -0,0 +1,2 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ export declare function useInjectionCleaner(injectionKeys: InjectionKey<Ref<unknown>>[]): void;
@@ -0,0 +1,8 @@
1
+ import { provide as r, ref as n } from "vue";
2
+ function i(e) {
3
+ e.forEach((o) => r(o, n()));
4
+ }
5
+ export {
6
+ i as useInjectionCleaner
7
+ };
8
+ //# sourceMappingURL=useInjectionCleaner.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInjectionCleaner.mjs","sources":["../../src/hooks/useInjectionCleaner.ts"],"sourcesContent":["import type { InjectionKey, Ref } from 'vue'\nimport { provide, ref } from 'vue'\n\nexport function useInjectionCleaner(injectionKeys: InjectionKey<Ref<unknown>>[]) {\n injectionKeys.forEach(key => provide(key, ref()))\n}\n"],"names":["useInjectionCleaner","injectionKeys","key","provide","ref"],"mappings":";AAGO,SAASA,EAAoBC,GAA6C;AAC/E,EAAAA,EAAc,QAAQ,CAAAC,MAAOC,EAAQD,GAAKE,EAAA,CAAK,CAAC;AAClD;"}
@@ -0,0 +1,3 @@
1
+ import { Form, ObjectField } from '@formily/core';
2
+ import { Ref } from 'vue';
3
+ export declare function useParentForm(): Ref<Form | ObjectField>;
@@ -0,0 +1,12 @@
1
+ import { isObjectField as n } from "@formily/core";
2
+ import { computed as m } from "vue";
3
+ import { useField as u } from "./useField.mjs";
4
+ import { useForm as i } from "./useForm.mjs";
5
+ function a() {
6
+ const o = u(), e = i(), t = (r) => r ? n(r) ? r : t(r?.parent) : e.value;
7
+ return m(() => t(o.value));
8
+ }
9
+ export {
10
+ a as useParentForm
11
+ };
12
+ //# sourceMappingURL=useParentForm.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useParentForm.mjs","sources":["../../src/hooks/useParentForm.ts"],"sourcesContent":["import type { Form, GeneralField, ObjectField } from '@formily/core'\nimport type { Ref } from 'vue'\nimport { isObjectField } from '@formily/core'\nimport { computed } from 'vue'\nimport { useField } from './useField'\nimport { useForm } from './useForm'\n\nexport function useParentForm(): Ref<Form | ObjectField> {\n const field = useField()\n const form = useForm()\n const findObjectParent = (field: GeneralField) => {\n if (!field)\n return form.value\n if (isObjectField(field))\n return field\n return findObjectParent(field?.parent)\n }\n return computed(() => findObjectParent(field.value))\n}\n"],"names":["useParentForm","field","useField","form","useForm","findObjectParent","isObjectField","computed"],"mappings":";;;;AAOO,SAASA,IAAyC;AACvD,QAAMC,IAAQC,EAAA,GACRC,IAAOC,EAAA,GACPC,IAAmB,CAACJ,MACnBA,IAEDK,EAAcL,CAAK,IACdA,IACFI,EAAiBJ,GAAO,MAAM,IAH5BE,EAAK;AAKhB,SAAOI,EAAS,MAAMF,EAAiBJ,EAAM,KAAK,CAAC;AACrD;"}
package/esm/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export * from './components';
2
+ export * from './hooks';
3
+ export * from './shared';
4
+ export * from './types';
package/esm/index.mjs ADDED
@@ -0,0 +1,42 @@
1
+ import { default as r } from "./components/ArrayField.mjs";
2
+ import { default as t } from "./components/ExpressionScope.mjs";
3
+ import { default as f } from "./components/Field.mjs";
4
+ import { default as l } from "./components/FormConsumer.mjs";
5
+ import { default as d } from "./components/FormProvider.mjs";
6
+ import { default as u } from "./components/ObjectField.mjs";
7
+ import { default as F } from "./components/RecursionField.mjs";
8
+ import { createSchemaField as S } from "./components/SchemaField.mjs";
9
+ import { default as y } from "./components/VoidField.mjs";
10
+ import { useField as h } from "./hooks/useField.mjs";
11
+ import { useFieldSchema as E } from "./hooks/useFieldSchema.mjs";
12
+ import { useForm as R } from "./hooks/useForm.mjs";
13
+ import { useFormEffects as k } from "./hooks/useFormEffects.mjs";
14
+ import { useParentForm as A } from "./hooks/useParentForm.mjs";
15
+ import { connect as M, mapProps as V, mapReadPretty as g } from "./shared/connect.mjs";
16
+ import { FieldSymbol as w, FormSymbol as z, SchemaExpressionScopeSymbol as B, SchemaMarkupSymbol as D, SchemaOptionsSymbol as G, SchemaSymbol as H } from "./shared/context.mjs";
17
+ export {
18
+ r as ArrayField,
19
+ t as ExpressionScope,
20
+ f as Field,
21
+ w as FieldSymbol,
22
+ l as FormConsumer,
23
+ d as FormProvider,
24
+ z as FormSymbol,
25
+ u as ObjectField,
26
+ F as RecursionField,
27
+ B as SchemaExpressionScopeSymbol,
28
+ D as SchemaMarkupSymbol,
29
+ G as SchemaOptionsSymbol,
30
+ H as SchemaSymbol,
31
+ y as VoidField,
32
+ M as connect,
33
+ S as createSchemaField,
34
+ V as mapProps,
35
+ g as mapReadPretty,
36
+ h as useField,
37
+ E as useFieldSchema,
38
+ R as useForm,
39
+ k as useFormEffects,
40
+ A as useParentForm
41
+ };
42
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ import { Component } from 'vue';
2
+ import { IComponentMapper, IStateMapper, VueComponentProps } from '../types';
3
+ export declare function mapProps<T extends Component = Component>(...args: IStateMapper<VueComponentProps<T>>[]): (target: T) => import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
4
+ [key: string]: any;
5
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
6
+ export declare function mapReadPretty<T extends Component, C extends Component>(component: C, readPrettyProps?: Record<string, any>): (target: T) => import('vue').DefineComponent<{}, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
7
+ [key: string]: any;
8
+ }>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
9
+ export declare function connect<T extends Component>(target: T, ...args: IComponentMapper[]): T;
@@ -0,0 +1,66 @@
1
+ import { isVoidField as P } from "@formily/core";
2
+ import { observer as R } from "@formily/reactive-vue";
3
+ import { isFn as p, each as F, FormPath as d, isStr as b, isValid as C } from "@formily/shared";
4
+ import { defineComponent as f, h as l, markRaw as h } from "vue";
5
+ import { useField as V } from "../hooks/useField.mjs";
6
+ import { extractAttrsAndEvents as v, createVNodeProps as A } from "../utils/reactiveFieldHelpers.mjs";
7
+ function j(...u) {
8
+ const m = (t, i) => u.reduce((e, r) => (p(r) ? e = Object.assign(e, r(e, i)) : F(r, (o, n) => {
9
+ const s = d.getIn(i, n), a = b(o) ? o : n, c = d.getIn(e, a);
10
+ n === "value" && o !== n && delete e.value, !(C(c) && !C(s)) && d.setIn(e, a, s);
11
+ }), e), t);
12
+ return (t) => R(
13
+ f({
14
+ name: t.name ? `Connected${t.name}` : "ConnectedComponent",
15
+ setup(i, { attrs: e, slots: r }) {
16
+ const o = V();
17
+ return () => {
18
+ const { attrs: n, events: s } = v(e), a = { ...n }, c = o.value ? m(a, o.value) : a;
19
+ return l(t, A(c, s), r);
20
+ };
21
+ }
22
+ })
23
+ );
24
+ }
25
+ function k(u, m) {
26
+ return (t) => R(
27
+ f({
28
+ name: t.name ? `Read${t.name}` : "ReadComponent",
29
+ setup(i, { attrs: e, slots: r }) {
30
+ const o = V();
31
+ return () => {
32
+ const n = o.value, { attrs: s, events: a } = v(e);
33
+ return l(
34
+ n && !P(n) && n.pattern === "readPretty" ? u : t,
35
+ A(
36
+ {
37
+ ...m,
38
+ ...s
39
+ },
40
+ a
41
+ ),
42
+ r
43
+ );
44
+ };
45
+ }
46
+ })
47
+ );
48
+ }
49
+ function E(u, ...m) {
50
+ const t = m.reduce((e, r) => r(e), u), i = f({
51
+ name: u.name,
52
+ setup(e, { attrs: r, slots: o }) {
53
+ return () => {
54
+ const { attrs: n, events: s } = v(r);
55
+ return l(t, A(n, s), o);
56
+ };
57
+ }
58
+ });
59
+ return h(i);
60
+ }
61
+ export {
62
+ E as connect,
63
+ j as mapProps,
64
+ k as mapReadPretty
65
+ };
66
+ //# sourceMappingURL=connect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connect.mjs","sources":["../../src/shared/connect.ts"],"sourcesContent":["import type { GeneralField } from '@formily/core'\nimport type { Component } from 'vue'\nimport type { IComponentMapper, IStateMapper, VueComponentProps } from '../types'\nimport { isVoidField } from '@formily/core'\nimport { observer } from '@formily/reactive-vue'\nimport { each, FormPath, isFn, isStr, isValid } from '@formily/shared'\nimport { defineComponent, h, markRaw } from 'vue'\nimport { useField } from '../hooks/useField'\n\nimport { createVNodeProps, extractAttrsAndEvents } from '../utils/reactiveFieldHelpers'\n\nexport function mapProps<T extends Component = Component>(\n ...args: IStateMapper<VueComponentProps<T>>[]\n) {\n const transform = (input: VueComponentProps<T>, field: GeneralField) =>\n args.reduce((props, mapper) => {\n if (isFn(mapper)) {\n props = Object.assign(props, mapper(props, field))\n }\n else {\n each(mapper, (to, extract) => {\n const extractValue = FormPath.getIn(field, extract)\n const targetValue = isStr(to) ? to : extract\n const originalValue = FormPath.getIn(props, targetValue)\n if (extract === 'value') {\n if (to !== extract) {\n delete props.value\n }\n }\n if (isValid(originalValue) && !isValid(extractValue))\n return\n FormPath.setIn(props, targetValue, extractValue)\n })\n }\n return props\n }, input)\n\n return (target: T) => {\n return observer(\n defineComponent({\n name: target.name ? `Connected${target.name}` : `ConnectedComponent`,\n setup(_, { attrs, slots }) {\n const fieldRef = useField()\n return () => {\n const { attrs: normalizedAttrs, events } = extractAttrsAndEvents(attrs)\n const baseAttrs = { ...normalizedAttrs } as VueComponentProps<T>\n const newAttrs = fieldRef.value ? transform(baseAttrs, fieldRef.value) : baseAttrs\n return h(target, createVNodeProps(newAttrs, events), slots)\n }\n },\n }),\n )\n }\n}\n\nexport function mapReadPretty<T extends Component, C extends Component>(\n component: C,\n readPrettyProps?: Record<string, any>,\n) {\n return (target: T) => {\n return observer(\n defineComponent({\n name: target.name ? `Read${target.name}` : `ReadComponent`,\n setup(_, { attrs, slots }) {\n const fieldRef = useField()\n return () => {\n const field = fieldRef.value\n const { attrs: normalizedAttrs, events } = extractAttrsAndEvents(attrs)\n return h(\n field && !isVoidField(field) && field.pattern === 'readPretty' ? component : target,\n createVNodeProps(\n {\n ...readPrettyProps,\n ...normalizedAttrs,\n },\n events,\n ),\n slots,\n )\n }\n },\n }),\n )\n }\n}\n\nexport function connect<T extends Component>(target: T, ...args: IComponentMapper[]): T {\n const Component = args.reduce((target: Component, mapper) => {\n return mapper(target)\n }, target)\n\n const functionalComponent = defineComponent({\n name: target.name,\n setup(_, { attrs, slots }) {\n return () => {\n const { attrs: normalizedAttrs, events } = extractAttrsAndEvents(attrs)\n return h(Component, createVNodeProps(normalizedAttrs, events), slots)\n }\n },\n })\n\n return markRaw(functionalComponent) as unknown as T\n}\n"],"names":["mapProps","args","transform","input","field","props","mapper","isFn","each","to","extract","extractValue","FormPath","targetValue","isStr","originalValue","isValid","target","observer","defineComponent","_","attrs","slots","fieldRef","useField","normalizedAttrs","events","extractAttrsAndEvents","baseAttrs","newAttrs","h","createVNodeProps","mapReadPretty","component","readPrettyProps","isVoidField","connect","Component","functionalComponent","markRaw"],"mappings":";;;;;;AAWO,SAASA,KACXC,GACH;AACA,QAAMC,IAAY,CAACC,GAA6BC,MAC9CH,EAAK,OAAO,CAACI,GAAOC,OACdC,EAAKD,CAAM,IACbD,IAAQ,OAAO,OAAOA,GAAOC,EAAOD,GAAOD,CAAK,CAAC,IAGjDI,EAAKF,GAAQ,CAACG,GAAIC,MAAY;AAC5B,UAAMC,IAAeC,EAAS,MAAMR,GAAOM,CAAO,GAC5CG,IAAcC,EAAML,CAAE,IAAIA,IAAKC,GAC/BK,IAAgBH,EAAS,MAAMP,GAAOQ,CAAW;AAMvD,IALIH,MAAY,WACVD,MAAOC,KACT,OAAOL,EAAM,OAGb,EAAAW,EAAQD,CAAa,KAAK,CAACC,EAAQL,CAAY,MAEnDC,EAAS,MAAMP,GAAOQ,GAAaF,CAAY;AAAA,EACjD,CAAC,GAEIN,IACNF,CAAK;AAEV,SAAO,CAACc,MACCC;AAAA,IACLC,EAAgB;AAAA,MACd,MAAMF,EAAO,OAAO,YAAYA,EAAO,IAAI,KAAK;AAAA,MAChD,MAAMG,GAAG,EAAE,OAAAC,GAAO,OAAAC,KAAS;AACzB,cAAMC,IAAWC,EAAA;AACjB,eAAO,MAAM;AACX,gBAAM,EAAE,OAAOC,GAAiB,QAAAC,EAAA,IAAWC,EAAsBN,CAAK,GAChEO,IAAY,EAAE,GAAGH,EAAA,GACjBI,IAAWN,EAAS,QAAQrB,EAAU0B,GAAWL,EAAS,KAAK,IAAIK;AACzE,iBAAOE,EAAEb,GAAQc,EAAiBF,GAAUH,CAAM,GAAGJ,CAAK;AAAA,QAC5D;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAGP;AAEO,SAASU,EACdC,GACAC,GACA;AACA,SAAO,CAACjB,MACCC;AAAA,IACLC,EAAgB;AAAA,MACd,MAAMF,EAAO,OAAO,OAAOA,EAAO,IAAI,KAAK;AAAA,MAC3C,MAAMG,GAAG,EAAE,OAAAC,GAAO,OAAAC,KAAS;AACzB,cAAMC,IAAWC,EAAA;AACjB,eAAO,MAAM;AACX,gBAAMpB,IAAQmB,EAAS,OACjB,EAAE,OAAOE,GAAiB,QAAAC,EAAA,IAAWC,EAAsBN,CAAK;AACtE,iBAAOS;AAAA,YACL1B,KAAS,CAAC+B,EAAY/B,CAAK,KAAKA,EAAM,YAAY,eAAe6B,IAAYhB;AAAA,YAC7Ec;AAAA,cACE;AAAA,gBACE,GAAGG;AAAA,gBACH,GAAGT;AAAA,cAAA;AAAA,cAELC;AAAA,YAAA;AAAA,YAEFJ;AAAA,UAAA;AAAA,QAEJ;AAAA,MACF;AAAA,IAAA,CACD;AAAA,EAAA;AAGP;AAEO,SAASc,EAA6BnB,MAAchB,GAA6B;AACtF,QAAMoC,IAAYpC,EAAK,OAAO,CAACgB,GAAmBX,MACzCA,EAAOW,CAAM,GACnBA,CAAM,GAEHqB,IAAsBnB,EAAgB;AAAA,IAC1C,MAAMF,EAAO;AAAA,IACb,MAAMG,GAAG,EAAE,OAAAC,GAAO,OAAAC,KAAS;AACzB,aAAO,MAAM;AACX,cAAM,EAAE,OAAOG,GAAiB,QAAAC,EAAA,IAAWC,EAAsBN,CAAK;AACtE,eAAOS,EAAEO,GAAWN,EAAiBN,GAAiBC,CAAM,GAAGJ,CAAK;AAAA,MACtE;AAAA,IACF;AAAA,EAAA,CACD;AAED,SAAOiB,EAAQD,CAAmB;AACpC;"}
@@ -0,0 +1,10 @@
1
+ import { Form, GeneralField } from '@formily/core';
2
+ import { Schema } from '@formily/json-schema';
3
+ import { InjectionKey, Ref } from 'vue';
4
+ import { ISchemaFieldVueFactoryOptions, SchemaExpressionScope } from '../types';
5
+ export declare const FormSymbol: InjectionKey<Ref<Form>>;
6
+ export declare const FieldSymbol: InjectionKey<Ref<GeneralField>>;
7
+ export declare const SchemaMarkupSymbol: InjectionKey<Ref<Schema>>;
8
+ export declare const SchemaSymbol: InjectionKey<Ref<Schema>>;
9
+ export declare const SchemaExpressionScopeSymbol: InjectionKey<Ref<SchemaExpressionScope>>;
10
+ export declare const SchemaOptionsSymbol: InjectionKey<Ref<ISchemaFieldVueFactoryOptions>>;
@@ -0,0 +1,10 @@
1
+ const o = /* @__PURE__ */ Symbol("form"), m = /* @__PURE__ */ Symbol("field"), S = /* @__PURE__ */ Symbol("schemaMarkup"), s = /* @__PURE__ */ Symbol("schema"), c = /* @__PURE__ */ Symbol("schemaExpression"), e = /* @__PURE__ */ Symbol("schemaOptions");
2
+ export {
3
+ m as FieldSymbol,
4
+ o as FormSymbol,
5
+ c as SchemaExpressionScopeSymbol,
6
+ S as SchemaMarkupSymbol,
7
+ e as SchemaOptionsSymbol,
8
+ s as SchemaSymbol
9
+ };
10
+ //# sourceMappingURL=context.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.mjs","sources":["../../src/shared/context.ts"],"sourcesContent":["import type { Form, GeneralField } from '@formily/core'\nimport type { Schema } from '@formily/json-schema'\nimport type { InjectionKey, Ref } from 'vue'\nimport type { ISchemaFieldVueFactoryOptions, SchemaExpressionScope } from '../types'\n\nexport const FormSymbol: InjectionKey<Ref<Form>> = Symbol('form')\nexport const FieldSymbol: InjectionKey<Ref<GeneralField>> = Symbol('field')\nexport const SchemaMarkupSymbol: InjectionKey<Ref<Schema>> = Symbol('schemaMarkup')\nexport const SchemaSymbol: InjectionKey<Ref<Schema>> = Symbol('schema')\nexport const SchemaExpressionScopeSymbol: InjectionKey<Ref<SchemaExpressionScope>>\n = Symbol('schemaExpression')\nexport const SchemaOptionsSymbol: InjectionKey<Ref<ISchemaFieldVueFactoryOptions>>\n = Symbol('schemaOptions')\n"],"names":["FormSymbol","FieldSymbol","SchemaMarkupSymbol","SchemaSymbol","SchemaExpressionScopeSymbol","SchemaOptionsSymbol"],"mappings":"AAKO,MAAMA,2BAA6C,MAAM,GACnDC,2BAAsD,OAAO,GAC7DC,2BAAuD,cAAc,GACrEC,2BAAiD,QAAQ,GACzDC,2BACF,kBAAkB,GAChBC,2BACF,eAAe;"}
@@ -0,0 +1,2 @@
1
+ export * from './connect';
2
+ export * from './context';
@@ -0,0 +1,14 @@
1
+ import { connect as e, mapProps as S, mapReadPretty as p } from "./connect.mjs";
2
+ import { FieldSymbol as a, FormSymbol as c, SchemaExpressionScopeSymbol as l, SchemaMarkupSymbol as y, SchemaOptionsSymbol as b, SchemaSymbol as t } from "./context.mjs";
3
+ export {
4
+ a as FieldSymbol,
5
+ c as FormSymbol,
6
+ l as SchemaExpressionScopeSymbol,
7
+ y as SchemaMarkupSymbol,
8
+ b as SchemaOptionsSymbol,
9
+ t as SchemaSymbol,
10
+ e as connect,
11
+ S as mapProps,
12
+ p as mapReadPretty
13
+ };
14
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}