@tmagic/form 1.7.7 → 1.7.8-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +235 -164
  2. package/dist/es/Form.js +5 -0
  3. package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +234 -0
  4. package/dist/es/FormBox.js +5 -0
  5. package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +117 -0
  6. package/dist/es/FormDialog.js +5 -0
  7. package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +222 -0
  8. package/dist/es/FormDrawer.js +5 -0
  9. package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +176 -0
  10. package/dist/es/_virtual/_rolldown/runtime.js +27 -0
  11. package/dist/es/containers/Col.js +5 -0
  12. package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +60 -0
  13. package/dist/es/containers/Container.js +5 -0
  14. package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +439 -0
  15. package/dist/es/containers/Fieldset.js +5 -0
  16. package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +153 -0
  17. package/dist/es/containers/FlexLayout.js +5 -0
  18. package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +64 -0
  19. package/dist/es/containers/FormLabel.js +5 -0
  20. package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +51 -0
  21. package/dist/es/containers/GroupList.js +5 -0
  22. package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +164 -0
  23. package/dist/es/containers/GroupListItem.js +5 -0
  24. package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +221 -0
  25. package/dist/es/containers/Panel.js +5 -0
  26. package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +130 -0
  27. package/dist/es/containers/Row.js +5 -0
  28. package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +65 -0
  29. package/dist/es/containers/Step.js +5 -0
  30. package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +85 -0
  31. package/dist/es/containers/Tabs.js +5 -0
  32. package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +194 -0
  33. package/dist/es/fields/Cascader.js +5 -0
  34. package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +123 -0
  35. package/dist/es/fields/Checkbox.js +5 -0
  36. package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +61 -0
  37. package/dist/es/fields/CheckboxGroup.js +5 -0
  38. package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +63 -0
  39. package/dist/es/fields/ColorPicker.js +5 -0
  40. package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +42 -0
  41. package/dist/es/fields/Date.js +5 -0
  42. package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +52 -0
  43. package/dist/es/fields/DateTime.js +5 -0
  44. package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +57 -0
  45. package/dist/es/fields/Daterange.js +5 -0
  46. package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +99 -0
  47. package/dist/es/fields/Display.js +5 -0
  48. package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +36 -0
  49. package/dist/es/fields/DynamicField.js +5 -0
  50. package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +91 -0
  51. package/dist/es/fields/Hidden.js +5 -0
  52. package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +24 -0
  53. package/dist/es/fields/Link.js +5 -0
  54. package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +104 -0
  55. package/dist/es/fields/Number.js +5 -0
  56. package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +65 -0
  57. package/dist/es/fields/NumberRange.js +5 -0
  58. package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +76 -0
  59. package/dist/es/fields/RadioGroup.js +5 -0
  60. package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +74 -0
  61. package/dist/es/fields/Select.js +5 -0
  62. package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +337 -0
  63. package/dist/es/fields/Switch.js +5 -0
  64. package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +59 -0
  65. package/dist/es/fields/Text.js +5 -0
  66. package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +215 -0
  67. package/dist/es/fields/Textarea.js +5 -0
  68. package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +60 -0
  69. package/dist/es/fields/Time.js +5 -0
  70. package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +49 -0
  71. package/dist/es/fields/Timerange.js +5 -0
  72. package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +100 -0
  73. package/dist/es/index.js +41 -0
  74. package/dist/es/plugin.js +74 -0
  75. package/dist/es/schema.js +2 -0
  76. package/dist/es/style.css +325 -0
  77. package/dist/es/table/ActionsColumn.js +5 -0
  78. package/dist/es/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +107 -0
  79. package/dist/es/table/SortColumn.js +5 -0
  80. package/dist/es/table/SortColumn.vue_vue_type_script_setup_true_lang.js +88 -0
  81. package/dist/es/table/Table.js +5 -0
  82. package/dist/es/table/Table.vue_vue_type_script_setup_true_lang.js +232 -0
  83. package/dist/es/table/useAdd.js +71 -0
  84. package/dist/es/table/useFullscreen.js +15 -0
  85. package/dist/es/table/useImport.js +46 -0
  86. package/dist/es/table/usePagination.js +26 -0
  87. package/dist/es/table/useSelection.js +26 -0
  88. package/dist/es/table/useSortable.js +39 -0
  89. package/dist/es/table/useTableColumns.js +160 -0
  90. package/dist/es/utils/config.js +15 -0
  91. package/dist/es/utils/form.js +173 -0
  92. package/dist/es/utils/useAddField.js +13 -0
  93. package/dist/style.css +1 -1
  94. package/dist/tmagic-form.umd.cjs +7693 -8924
  95. package/package.json +7 -6
  96. package/src/containers/Container.vue +16 -10
  97. package/src/fields/Hidden.vue +6 -2
  98. package/src/index.ts +8 -82
  99. package/src/plugin.ts +102 -0
  100. package/src/table/useSortable.ts +8 -4
  101. package/src/utils/config.ts +16 -1
  102. package/types/index.d.ts +1264 -1226
  103. package/dist/tmagic-form.js +0 -5940
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
- "version": "1.7.7",
2
+ "version": "1.7.8-beta.1",
3
3
  "name": "@tmagic/form",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "dist/style.css",
7
+ "dist/es/style.css",
7
8
  "src/theme/*"
8
9
  ],
9
10
  "main": "dist/tmagic-form.umd.cjs",
10
- "module": "dist/tmagic-form.js",
11
+ "module": "dist/es/index.js",
11
12
  "style": "dist/style.css",
12
13
  "types": "types/index.d.ts",
13
14
  "exports": {
14
15
  ".": {
15
16
  "types": "./types/index.d.ts",
16
- "import": "./dist/tmagic-form.js",
17
+ "import": "./dist/es/index.js",
17
18
  "require": "./dist/tmagic-form.umd.cjs"
18
19
  },
19
20
  "./dist/style.css": {
@@ -51,9 +52,9 @@
51
52
  "peerDependencies": {
52
53
  "vue": "^3.5.24",
53
54
  "typescript": "^5.9.3",
54
- "@tmagic/utils": "1.7.7",
55
- "@tmagic/design": "1.7.7",
56
- "@tmagic/form-schema": "1.7.7"
55
+ "@tmagic/utils": "1.7.8-beta.1",
56
+ "@tmagic/form-schema": "1.7.8-beta.1",
57
+ "@tmagic/design": "1.7.8-beta.1"
57
58
  },
58
59
  "peerDependenciesMeta": {
59
60
  "typescript": {
@@ -5,7 +5,7 @@
5
5
  :class="`m-form-container m-container-${type || ''} ${config.className || ''}${config.tip ? ' has-tip' : ''}`"
6
6
  :style="config.style"
7
7
  >
8
- <m-fields-hidden v-if="type === 'hidden'" v-bind="fieldsProps" :model="model"></m-fields-hidden>
8
+ <MHidden v-if="type === 'hidden'" :name="`${name}`" :prop="itemProp" :model="model"></MHidden>
9
9
 
10
10
  <component
11
11
  v-else-if="items && !text && type && display"
@@ -172,6 +172,7 @@ import { isEqual } from 'lodash-es';
172
172
  import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
173
173
  import { getValueByKeyPath } from '@tmagic/utils';
174
174
 
175
+ import MHidden from '../fields/Hidden.vue';
175
176
  import type {
176
177
  ChildConfig,
177
178
  ContainerChangeEventData,
@@ -180,6 +181,7 @@ import type {
180
181
  FormValue,
181
182
  ToolTipConfigType,
182
183
  } from '../schema';
184
+ import { getField } from '../utils/config';
183
185
  import { createObjectProp, display as displayFunction, filterFunction, getRules } from '../utils/form';
184
186
 
185
187
  import FormLabel from './FormLabel.vue';
@@ -248,11 +250,23 @@ const itemProp = computed(() => {
248
250
  return `${n}`;
249
251
  });
250
252
 
253
+ const type = computed((): string => {
254
+ let { type } = props.config;
255
+ type = type && filterFunction<string>(mForm, type, props);
256
+ if (type === 'form') return '';
257
+ if (type === 'container') return '';
258
+ return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
259
+ });
260
+
251
261
  const tagName = computed(() => {
252
262
  if (type.value === 'component' && props.config.component) {
253
263
  return props.config.component;
254
264
  }
255
- return `m-${items.value ? 'form' : 'fields'}-${type.value}`;
265
+
266
+ if (!getField(type.value || 'container')) {
267
+ console.log(type.value, 'type.value');
268
+ }
269
+ return getField(type.value || 'container') || `m-${items.value ? 'form' : 'fields'}-${type.value}`;
256
270
  });
257
271
 
258
272
  const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
@@ -276,14 +290,6 @@ const tooltip = computed(() => {
276
290
 
277
291
  const rule = computed(() => getRules(mForm, props.config.rules, props));
278
292
 
279
- const type = computed((): string => {
280
- let { type } = props.config;
281
- type = type && filterFunction<string>(mForm, type, props);
282
- if (type === 'form') return '';
283
- if (type === 'container') return '';
284
- return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
285
- });
286
-
287
293
  const display = computed((): boolean => {
288
294
  const value = displayFunction(mForm, props.config.display, props);
289
295
 
@@ -3,14 +3,18 @@
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
- import type { FieldProps, HiddenConfig } from '../schema';
6
+ import type { FormValue } from '../schema';
7
7
  import { useAddField } from '../utils/useAddField';
8
8
 
9
9
  defineOptions({
10
10
  name: 'MFormHidden',
11
11
  });
12
12
 
13
- const props = defineProps<FieldProps<HiddenConfig>>();
13
+ const props = defineProps<{
14
+ model: FormValue;
15
+ name: string;
16
+ prop: string;
17
+ }>();
14
18
 
15
19
  useAddField(props.prop);
16
20
  </script>
package/src/index.ts CHANGED
@@ -16,44 +16,8 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import type { App } from 'vue';
20
-
21
- import Container from './containers/Container.vue';
22
- import Fieldset from './containers/Fieldset.vue';
23
- import FlexLayout from './containers/FlexLayout.vue';
24
- import GroupList from './containers/GroupList.vue';
25
- import Panel from './containers/Panel.vue';
26
- import Row from './containers/Row.vue';
27
- import MStep from './containers/Step.vue';
28
- import Tabs from './containers/Tabs.vue';
29
- import Cascader from './fields/Cascader.vue';
30
- import Checkbox from './fields/Checkbox.vue';
31
- import CheckboxGroup from './fields/CheckboxGroup.vue';
32
- import ColorPicker from './fields/ColorPicker.vue';
33
- import Date from './fields/Date.vue';
34
- import Daterange from './fields/Daterange.vue';
35
- import DateTime from './fields/DateTime.vue';
36
- import Display from './fields/Display.vue';
37
- import DynamicField from './fields/DynamicField.vue';
38
- import Hidden from './fields/Hidden.vue';
39
- import Link from './fields/Link.vue';
40
- import Number from './fields/Number.vue';
41
- import NumberRange from './fields/NumberRange.vue';
42
- import RadioGroup from './fields/RadioGroup.vue';
43
- import Select from './fields/Select.vue';
44
- import Switch from './fields/Switch.vue';
45
- import Text from './fields/Text.vue';
46
- import Textarea from './fields/Textarea.vue';
47
- import Time from './fields/Time.vue';
48
- import Timerange from './fields/Timerange.vue';
49
- import Table from './table/Table.vue';
50
- import { setConfig } from './utils/config';
51
- import Form from './Form.vue';
52
- import FormDialog from './FormDialog.vue';
53
19
  import type { FormConfig } from './schema';
54
20
 
55
- import './theme/index.scss';
56
-
57
21
  export * from './schema';
58
22
  export * from './utils/form';
59
23
  export * from './utils/useAddField';
@@ -91,52 +55,14 @@ export { default as MSelect } from './fields/Select.vue';
91
55
  export { default as MCascader } from './fields/Cascader.vue';
92
56
  export { default as MDynamicField } from './fields/DynamicField.vue';
93
57
 
94
- export const createForm = <T extends [] = []>(config: FormConfig | T) => config;
95
-
96
- export interface FormInstallOptions {
97
- [key: string]: any;
98
- }
99
-
100
- const defaultInstallOpt: FormInstallOptions = {};
58
+ export {
59
+ deleteField as deleteFormField,
60
+ getField as getFormField,
61
+ registerField as registerFormField,
62
+ } from './utils/config';
101
63
 
102
- export default {
103
- install(app: App, opt: FormInstallOptions = {}) {
104
- const option = Object.assign(defaultInstallOpt, opt);
64
+ export type { FormInstallOptions } from './plugin';
105
65
 
106
- app.config.globalProperties.$MAGIC_FORM = option;
107
- setConfig(option);
66
+ export const createForm = <T extends [] = []>(config: FormConfig | T) => config;
108
67
 
109
- app.component('m-form', Form);
110
- app.component('m-form-dialog', FormDialog);
111
- app.component('m-form-container', Container);
112
- app.component('m-form-fieldset', Fieldset);
113
- app.component('m-form-group-list', GroupList);
114
- app.component('m-form-panel', Panel);
115
- app.component('m-form-row', Row);
116
- app.component('m-form-step', MStep);
117
- app.component('m-form-table', Table);
118
- app.component('m-form-tab', Tabs);
119
- app.component('m-form-flex-layout', FlexLayout);
120
- app.component('m-fields-text', Text);
121
- app.component('m-fields-img-upload', Text);
122
- app.component('m-fields-number', Number);
123
- app.component('m-fields-number-range', NumberRange);
124
- app.component('m-fields-textarea', Textarea);
125
- app.component('m-fields-hidden', Hidden);
126
- app.component('m-fields-date', Date);
127
- app.component('m-fields-datetime', DateTime);
128
- app.component('m-fields-daterange', Daterange);
129
- app.component('m-fields-timerange', Timerange);
130
- app.component('m-fields-time', Time);
131
- app.component('m-fields-checkbox', Checkbox);
132
- app.component('m-fields-switch', Switch);
133
- app.component('m-fields-color-picker', ColorPicker);
134
- app.component('m-fields-checkbox-group', CheckboxGroup);
135
- app.component('m-fields-radio-group', RadioGroup);
136
- app.component('m-fields-display', Display);
137
- app.component('m-fields-link', Link);
138
- app.component('m-fields-select', Select);
139
- app.component('m-fields-cascader', Cascader);
140
- app.component('m-fields-dynamic-field', DynamicField);
141
- },
142
- };
68
+ export { default } from './plugin';
package/src/plugin.ts ADDED
@@ -0,0 +1,102 @@
1
+ /*
2
+ * Tencent is pleased to support the open source community by making TMagicEditor available.
3
+ *
4
+ * Copyright (C) 2025 Tencent. All rights reserved.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import { type App } from 'vue';
20
+
21
+ import Container from './containers/Container.vue';
22
+ import Fieldset from './containers/Fieldset.vue';
23
+ import FlexLayout from './containers/FlexLayout.vue';
24
+ import GroupList from './containers/GroupList.vue';
25
+ import Panel from './containers/Panel.vue';
26
+ import Row from './containers/Row.vue';
27
+ import MStep from './containers/Step.vue';
28
+ import Tabs from './containers/Tabs.vue';
29
+ import Cascader from './fields/Cascader.vue';
30
+ import Checkbox from './fields/Checkbox.vue';
31
+ import CheckboxGroup from './fields/CheckboxGroup.vue';
32
+ import ColorPicker from './fields/ColorPicker.vue';
33
+ import Date from './fields/Date.vue';
34
+ import Daterange from './fields/Daterange.vue';
35
+ import DateTime from './fields/DateTime.vue';
36
+ import Display from './fields/Display.vue';
37
+ import DynamicField from './fields/DynamicField.vue';
38
+ import Hidden from './fields/Hidden.vue';
39
+ import Link from './fields/Link.vue';
40
+ import Number from './fields/Number.vue';
41
+ import NumberRange from './fields/NumberRange.vue';
42
+ import RadioGroup from './fields/RadioGroup.vue';
43
+ import Select from './fields/Select.vue';
44
+ import Switch from './fields/Switch.vue';
45
+ import Text from './fields/Text.vue';
46
+ import Textarea from './fields/Textarea.vue';
47
+ import Time from './fields/Time.vue';
48
+ import Timerange from './fields/Timerange.vue';
49
+ import Table from './table/Table.vue';
50
+ import { setConfig } from './utils/config';
51
+ import Form from './Form.vue';
52
+ import FormDialog from './FormDialog.vue';
53
+
54
+ import './theme/index.scss';
55
+
56
+ export interface FormInstallOptions {
57
+ [key: string]: any;
58
+ }
59
+
60
+ const defaultInstallOpt: FormInstallOptions = {};
61
+
62
+ export default {
63
+ install(app: App, opt: FormInstallOptions = {}) {
64
+ const option = Object.assign(defaultInstallOpt, opt);
65
+
66
+ app.config.globalProperties.$MAGIC_FORM = option;
67
+ setConfig(option);
68
+
69
+ app.component('m-form', Form);
70
+ app.component('m-form-dialog', FormDialog);
71
+ app.component('m-form-container', Container);
72
+ app.component('m-form-fieldset', Fieldset);
73
+ app.component('m-form-group-list', GroupList);
74
+ app.component('m-form-panel', Panel);
75
+ app.component('m-form-row', Row);
76
+ app.component('m-form-step', MStep);
77
+ app.component('m-form-table', Table);
78
+ app.component('m-form-tab', Tabs);
79
+ app.component('m-form-flex-layout', FlexLayout);
80
+ app.component('m-fields-text', Text);
81
+ app.component('m-fields-img-upload', Text);
82
+ app.component('m-fields-number', Number);
83
+ app.component('m-fields-number-range', NumberRange);
84
+ app.component('m-fields-textarea', Textarea);
85
+ app.component('m-fields-hidden', Hidden);
86
+ app.component('m-fields-date', Date);
87
+ app.component('m-fields-datetime', DateTime);
88
+ app.component('m-fields-daterange', Daterange);
89
+ app.component('m-fields-timerange', Timerange);
90
+ app.component('m-fields-time', Time);
91
+ app.component('m-fields-checkbox', Checkbox);
92
+ app.component('m-fields-switch', Switch);
93
+ app.component('m-fields-color-picker', ColorPicker);
94
+ app.component('m-fields-checkbox-group', CheckboxGroup);
95
+ app.component('m-fields-radio-group', RadioGroup);
96
+ app.component('m-fields-display', Display);
97
+ app.component('m-fields-link', Link);
98
+ app.component('m-fields-select', Select);
99
+ app.component('m-fields-cascader', Cascader);
100
+ app.component('m-fields-dynamic-field', DynamicField);
101
+ },
102
+ };
@@ -1,5 +1,5 @@
1
1
  import { inject, nextTick, type Ref, type ShallowRef, watchEffect } from 'vue';
2
- import Sortable, { type SortableEvent } from 'sortablejs';
2
+ import type { default as SortableType, SortableEvent } from 'sortablejs';
3
3
 
4
4
  import { type TMagicTable } from '@tmagic/design';
5
5
  import type { FormState } from '@tmagic/form-schema';
@@ -8,6 +8,9 @@ import { sortArray } from '../utils/form';
8
8
 
9
9
  import type { TableProps } from './type';
10
10
 
11
+ let SortablePromise: Promise<typeof SortableType> | undefined;
12
+ const loadSortable = () => (SortablePromise ??= import('sortablejs').then((m) => m.default));
13
+
11
14
  export const useSortable = (
12
15
  props: TableProps,
13
16
  emit: (event: 'select' | 'change' | 'addDiffCount', ...args: any[]) => void,
@@ -17,15 +20,16 @@ export const useSortable = (
17
20
  ) => {
18
21
  const mForm = inject<FormState | undefined>('mForm');
19
22
 
20
- let sortable: Sortable | undefined;
21
- const rowDrop = () => {
23
+ let sortable: SortableType | undefined;
24
+ const rowDrop = async () => {
22
25
  sortable?.destroy();
23
26
  const tableEl = tMagicTableRef.value?.getEl();
24
27
  const tBodyEl = tableEl?.querySelector('.el-table__body > tbody') || tableEl?.querySelector('.t-table__body');
25
28
  if (!tBodyEl) {
26
29
  return;
27
30
  }
28
- sortable = Sortable.create(tBodyEl, {
31
+
32
+ sortable = (await loadSortable()).create(tBodyEl, {
29
33
  draggable: '.tmagic-design-table-row',
30
34
  filter: 'input', // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
31
35
  preventOnFilter: false, // 允许选字
@@ -16,6 +16,8 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import type { Component } from 'vue';
20
+
19
21
  let $MAGIC_FORM = {} as any;
20
22
 
21
23
  const setConfig = (option: any): void => {
@@ -24,4 +26,17 @@ const setConfig = (option: any): void => {
24
26
 
25
27
  const getConfig = <T = unknown>(key: string): T => $MAGIC_FORM[key];
26
28
 
27
- export { getConfig, setConfig };
29
+ const fieldRegistry = new Map<string, Component>();
30
+
31
+ const registerField = (tagName: string, component: Component): void => {
32
+ if (fieldRegistry.has(tagName)) {
33
+ return;
34
+ }
35
+ fieldRegistry.set(tagName, component);
36
+ };
37
+
38
+ const getField = (tagName: string): Component | undefined => fieldRegistry.get(tagName);
39
+
40
+ const deleteField = (tagName: string): boolean => fieldRegistry.delete(tagName);
41
+
42
+ export { deleteField, getConfig, getField, registerField, setConfig };