@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.
- package/LICENSE +235 -164
- package/dist/es/Form.js +5 -0
- package/dist/es/Form.vue_vue_type_script_setup_true_lang.js +234 -0
- package/dist/es/FormBox.js +5 -0
- package/dist/es/FormBox.vue_vue_type_script_setup_true_lang.js +117 -0
- package/dist/es/FormDialog.js +5 -0
- package/dist/es/FormDialog.vue_vue_type_script_setup_true_lang.js +222 -0
- package/dist/es/FormDrawer.js +5 -0
- package/dist/es/FormDrawer.vue_vue_type_script_setup_true_lang.js +176 -0
- package/dist/es/_virtual/_rolldown/runtime.js +27 -0
- package/dist/es/containers/Col.js +5 -0
- package/dist/es/containers/Col.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/containers/Container.js +5 -0
- package/dist/es/containers/Container.vue_vue_type_script_setup_true_lang.js +439 -0
- package/dist/es/containers/Fieldset.js +5 -0
- package/dist/es/containers/Fieldset.vue_vue_type_script_setup_true_lang.js +153 -0
- package/dist/es/containers/FlexLayout.js +5 -0
- package/dist/es/containers/FlexLayout.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/es/containers/FormLabel.js +5 -0
- package/dist/es/containers/FormLabel.vue_vue_type_script_setup_true_lang.js +51 -0
- package/dist/es/containers/GroupList.js +5 -0
- package/dist/es/containers/GroupList.vue_vue_type_script_setup_true_lang.js +164 -0
- package/dist/es/containers/GroupListItem.js +5 -0
- package/dist/es/containers/GroupListItem.vue_vue_type_script_setup_true_lang.js +221 -0
- package/dist/es/containers/Panel.js +5 -0
- package/dist/es/containers/Panel.vue_vue_type_script_setup_true_lang.js +130 -0
- package/dist/es/containers/Row.js +5 -0
- package/dist/es/containers/Row.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/es/containers/Step.js +5 -0
- package/dist/es/containers/Step.vue_vue_type_script_setup_true_lang.js +85 -0
- package/dist/es/containers/Tabs.js +5 -0
- package/dist/es/containers/Tabs.vue_vue_type_script_setup_true_lang.js +194 -0
- package/dist/es/fields/Cascader.js +5 -0
- package/dist/es/fields/Cascader.vue_vue_type_script_setup_true_lang.js +123 -0
- package/dist/es/fields/Checkbox.js +5 -0
- package/dist/es/fields/Checkbox.vue_vue_type_script_setup_true_lang.js +61 -0
- package/dist/es/fields/CheckboxGroup.js +5 -0
- package/dist/es/fields/CheckboxGroup.vue_vue_type_script_setup_true_lang.js +63 -0
- package/dist/es/fields/ColorPicker.js +5 -0
- package/dist/es/fields/ColorPicker.vue_vue_type_script_setup_true_lang.js +42 -0
- package/dist/es/fields/Date.js +5 -0
- package/dist/es/fields/Date.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/es/fields/DateTime.js +5 -0
- package/dist/es/fields/DateTime.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/es/fields/Daterange.js +5 -0
- package/dist/es/fields/Daterange.vue_vue_type_script_setup_true_lang.js +99 -0
- package/dist/es/fields/Display.js +5 -0
- package/dist/es/fields/Display.vue_vue_type_script_setup_true_lang.js +36 -0
- package/dist/es/fields/DynamicField.js +5 -0
- package/dist/es/fields/DynamicField.vue_vue_type_script_setup_true_lang.js +91 -0
- package/dist/es/fields/Hidden.js +5 -0
- package/dist/es/fields/Hidden.vue_vue_type_script_setup_true_lang.js +24 -0
- package/dist/es/fields/Link.js +5 -0
- package/dist/es/fields/Link.vue_vue_type_script_setup_true_lang.js +104 -0
- package/dist/es/fields/Number.js +5 -0
- package/dist/es/fields/Number.vue_vue_type_script_setup_true_lang.js +65 -0
- package/dist/es/fields/NumberRange.js +5 -0
- package/dist/es/fields/NumberRange.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/es/fields/RadioGroup.js +5 -0
- package/dist/es/fields/RadioGroup.vue_vue_type_script_setup_true_lang.js +74 -0
- package/dist/es/fields/Select.js +5 -0
- package/dist/es/fields/Select.vue_vue_type_script_setup_true_lang.js +337 -0
- package/dist/es/fields/Switch.js +5 -0
- package/dist/es/fields/Switch.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/es/fields/Text.js +5 -0
- package/dist/es/fields/Text.vue_vue_type_script_setup_true_lang.js +215 -0
- package/dist/es/fields/Textarea.js +5 -0
- package/dist/es/fields/Textarea.vue_vue_type_script_setup_true_lang.js +60 -0
- package/dist/es/fields/Time.js +5 -0
- package/dist/es/fields/Time.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/es/fields/Timerange.js +5 -0
- package/dist/es/fields/Timerange.vue_vue_type_script_setup_true_lang.js +100 -0
- package/dist/es/index.js +41 -0
- package/dist/es/plugin.js +74 -0
- package/dist/es/schema.js +2 -0
- package/dist/es/style.css +325 -0
- package/dist/es/table/ActionsColumn.js +5 -0
- package/dist/es/table/ActionsColumn.vue_vue_type_script_setup_true_lang.js +107 -0
- package/dist/es/table/SortColumn.js +5 -0
- package/dist/es/table/SortColumn.vue_vue_type_script_setup_true_lang.js +88 -0
- package/dist/es/table/Table.js +5 -0
- package/dist/es/table/Table.vue_vue_type_script_setup_true_lang.js +232 -0
- package/dist/es/table/useAdd.js +71 -0
- package/dist/es/table/useFullscreen.js +15 -0
- package/dist/es/table/useImport.js +46 -0
- package/dist/es/table/usePagination.js +26 -0
- package/dist/es/table/useSelection.js +26 -0
- package/dist/es/table/useSortable.js +39 -0
- package/dist/es/table/useTableColumns.js +160 -0
- package/dist/es/utils/config.js +15 -0
- package/dist/es/utils/form.js +173 -0
- package/dist/es/utils/useAddField.js +13 -0
- package/dist/style.css +1 -1
- package/dist/tmagic-form.umd.cjs +7693 -8924
- package/package.json +7 -6
- package/src/containers/Container.vue +16 -10
- package/src/fields/Hidden.vue +6 -2
- package/src/index.ts +8 -82
- package/src/plugin.ts +102 -0
- package/src/table/useSortable.ts +8 -4
- package/src/utils/config.ts +16 -1
- package/types/index.d.ts +1264 -1226
- package/dist/tmagic-form.js +0 -5940
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.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/
|
|
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/
|
|
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.
|
|
55
|
-
"@tmagic/
|
|
56
|
-
"@tmagic/
|
|
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
|
-
<
|
|
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
|
-
|
|
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
|
|
package/src/fields/Hidden.vue
CHANGED
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
|
-
import type {
|
|
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<
|
|
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
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
103
|
-
install(app: App, opt: FormInstallOptions = {}) {
|
|
104
|
-
const option = Object.assign(defaultInstallOpt, opt);
|
|
64
|
+
export type { FormInstallOptions } from './plugin';
|
|
105
65
|
|
|
106
|
-
|
|
107
|
-
setConfig(option);
|
|
66
|
+
export const createForm = <T extends [] = []>(config: FormConfig | T) => config;
|
|
108
67
|
|
|
109
|
-
|
|
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
|
+
};
|
package/src/table/useSortable.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { inject, nextTick, type Ref, type ShallowRef, watchEffect } from 'vue';
|
|
2
|
-
import
|
|
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:
|
|
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
|
-
|
|
31
|
+
|
|
32
|
+
sortable = (await loadSortable()).create(tBodyEl, {
|
|
29
33
|
draggable: '.tmagic-design-table-row',
|
|
30
34
|
filter: 'input', // 表单组件选字操作和触发拖拽会冲突,优先保证选字操作
|
|
31
35
|
preventOnFilter: false, // 允许选字
|
package/src/utils/config.ts
CHANGED
|
@@ -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
|
-
|
|
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 };
|