@tmagic/form 1.4.8 → 1.4.10
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/dist/style.css +4 -0
- package/dist/tmagic-form.js +13 -12
- package/dist/tmagic-form.umd.cjs +13 -12
- package/package.json +5 -5
- package/src/Form.vue +201 -0
- package/src/FormBox.vue +120 -0
- package/src/FormDialog.vue +173 -0
- package/src/FormDrawer.vue +159 -0
- package/src/containers/Col.vue +52 -0
- package/src/containers/Container.vue +408 -0
- package/src/containers/Fieldset.vue +124 -0
- package/src/containers/GroupList.vue +139 -0
- package/src/containers/GroupListItem.vue +135 -0
- package/src/containers/Panel.vue +99 -0
- package/src/containers/Row.vue +54 -0
- package/src/containers/Step.vue +82 -0
- package/src/containers/Table.vue +648 -0
- package/src/containers/Tabs.vue +226 -0
- package/src/fields/Cascader.vue +131 -0
- package/src/fields/Checkbox.vue +58 -0
- package/src/fields/CheckboxGroup.vue +44 -0
- package/src/fields/ColorPicker.vue +30 -0
- package/src/fields/Date.vue +38 -0
- package/src/fields/DateTime.vue +47 -0
- package/src/fields/Daterange.vue +99 -0
- package/src/fields/Display.vue +21 -0
- package/src/fields/DynamicField.vue +90 -0
- package/src/fields/Hidden.vue +16 -0
- package/src/fields/Link.vue +86 -0
- package/src/fields/Number.vue +49 -0
- package/src/fields/NumberRange.vue +50 -0
- package/src/fields/RadioGroup.vue +28 -0
- package/src/fields/Select.vue +449 -0
- package/src/fields/Switch.vue +59 -0
- package/src/fields/Text.vue +170 -0
- package/src/fields/Textarea.vue +46 -0
- package/src/fields/Time.vue +34 -0
- package/src/fields/Timerange.vue +76 -0
- package/src/index.ts +139 -0
- package/src/schema.ts +758 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/theme/container.scss +5 -0
- package/src/theme/date-time.scss +7 -0
- package/src/theme/fieldset.scss +28 -0
- package/src/theme/form-box.scss +13 -0
- package/src/theme/form-dialog.scss +13 -0
- package/src/theme/form-drawer.scss +11 -0
- package/src/theme/form.scss +43 -0
- package/src/theme/group-list.scss +23 -0
- package/src/theme/index.scss +15 -0
- package/src/theme/link.scss +3 -0
- package/src/theme/number-range.scss +8 -0
- package/src/theme/panel.scss +24 -0
- package/src/theme/select.scss +3 -0
- package/src/theme/table.scss +70 -0
- package/src/theme/tabs.scss +27 -0
- package/src/theme/text.scss +6 -0
- package/src/utils/config.ts +27 -0
- package/src/utils/containerProps.ts +50 -0
- package/src/utils/form.ts +273 -0
- package/src/utils/useAddField.ts +40 -0
- package/types/schema.d.ts +7 -5
- package/types/utils/form.d.ts +2 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Tencent is pleased to support the open source community by making TMagicEditor available.
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 THL A29 Limited, a Tencent company. 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 { ComponentInternalInstance, getCurrentInstance, inject, watch } from 'vue';
|
|
20
|
+
|
|
21
|
+
import { FormState } from '../schema';
|
|
22
|
+
|
|
23
|
+
export const useAddField = (prop?: string) => {
|
|
24
|
+
if (!prop) return;
|
|
25
|
+
const mForm = inject<FormState | null>('mForm');
|
|
26
|
+
const instance = getCurrentInstance() as ComponentInternalInstance;
|
|
27
|
+
watch(
|
|
28
|
+
() => instance?.proxy,
|
|
29
|
+
(vm) => {
|
|
30
|
+
if (vm) {
|
|
31
|
+
mForm?.setField(prop, vm);
|
|
32
|
+
} else {
|
|
33
|
+
mForm?.deleteField(prop);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
immediate: true,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
};
|
package/types/schema.d.ts
CHANGED
|
@@ -130,6 +130,7 @@ export type FilterFunction<T = boolean> = (mForm: FormState | undefined, data: {
|
|
|
130
130
|
formValue: Record<any, any>;
|
|
131
131
|
prop: string;
|
|
132
132
|
config: any;
|
|
133
|
+
index?: number;
|
|
133
134
|
}) => T;
|
|
134
135
|
type OnChangeHandler = (mForm: FormState | undefined, value: any, data: {
|
|
135
136
|
model: Record<any, any>;
|
|
@@ -346,16 +347,17 @@ export interface RadioGroupConfig extends FormItem {
|
|
|
346
347
|
export interface ColorPickConfig extends FormItem {
|
|
347
348
|
type: 'colorPicker';
|
|
348
349
|
}
|
|
350
|
+
export interface CheckboxGroupOption {
|
|
351
|
+
value: any;
|
|
352
|
+
text: string;
|
|
353
|
+
disabled?: boolean;
|
|
354
|
+
}
|
|
349
355
|
/**
|
|
350
356
|
* 多选框组
|
|
351
357
|
*/
|
|
352
358
|
export interface CheckboxGroupConfig extends FormItem {
|
|
353
359
|
type: 'checkbox-group';
|
|
354
|
-
options:
|
|
355
|
-
value: any;
|
|
356
|
-
text: string;
|
|
357
|
-
disabled?: boolean;
|
|
358
|
-
}[] | Function;
|
|
360
|
+
options: CheckboxGroupOption[] | FilterFunction<CheckboxGroupOption[]>;
|
|
359
361
|
}
|
|
360
362
|
/**
|
|
361
363
|
* 下拉选择器
|
package/types/utils/form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FormConfig, FormState, FormValue, Rule, TabPaneConfig } from '../schema';
|
|
1
|
+
import { FilterFunction, FormConfig, FormState, FormValue, Rule, TabPaneConfig } from '../schema';
|
|
2
2
|
export declare const createValues: (mForm: FormState | undefined, config?: FormConfig | TabPaneConfig[], initValue?: FormValue, value?: FormValue) => FormValue;
|
|
3
|
-
export declare const filterFunction: <T = any>(mForm: FormState | undefined, config: T, props: any) =>
|
|
3
|
+
export declare const filterFunction: <T = any>(mForm: FormState | undefined, config: T | FilterFunction<T> | undefined, props: any) => T | undefined;
|
|
4
4
|
export declare const display: (mForm: FormState | undefined, config: any, props: any) => any;
|
|
5
5
|
export declare const getRules: (mForm: FormState | undefined, rules: Rule | Rule[] | undefined, props: any) => Rule[];
|
|
6
6
|
export declare const initValue: (mForm: FormState | undefined, { initValues, config }: {
|