@tmagic/form 1.4.5 → 1.4.7
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/tmagic-form.js +10 -17
- package/dist/tmagic-form.umd.cjs +9 -16
- package/package.json +12 -7
- package/src/containers/Container.vue +4 -12
- package/src/fields/Cascader.vue +10 -6
- package/src/schema.ts +2 -2
- package/types/schema.d.ts +2 -2
package/dist/tmagic-form.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toRaw, defineComponent, inject, ref, computed,
|
|
1
|
+
import { toRaw, defineComponent, inject, ref, computed, watchEffect, watch, resolveComponent, openBlock, createElementBlock, normalizeStyle, normalizeClass, createBlock, resolveDynamicComponent, Fragment, createVNode, unref, withCtx, createElementVNode, createCommentVNode, renderList, createTextVNode, toDisplayString, withDirectives, vShow, renderSlot, onMounted, Teleport, toRefs, mergeProps, getCurrentInstance, reactive, onBeforeUnmount, vModelText, provide, onBeforeMount, nextTick, resolveDirective, createSlots, withModifiers } from 'vue';
|
|
2
2
|
import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
|
|
3
3
|
import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
|
|
4
4
|
import { TMagicFormItem, TMagicTooltip, TMagicIcon, TMagicButton, TMagicCheckbox, TMagicCard, TMagicCol, TMagicRow, TMagicSteps, TMagicStep, useZIndex, TMagicTable, TMagicTableColumn, TMagicUpload, TMagicPagination, tMagicMessage, getConfig as getConfig$1, TMagicBadge, TMagicCascader, TMagicCheckboxGroup, TMagicColorPicker, TMagicDatePicker, TMagicForm, TMagicInput, TMagicDialog, TMagicInputNumber, TMagicRadioGroup, TMagicRadio, TMagicSelect, TMagicSwitch, TMagicPopover, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
|
|
@@ -227,12 +227,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
227
227
|
}
|
|
228
228
|
return `${props.prop}${props.prop ? "." : ""}${n}`;
|
|
229
229
|
});
|
|
230
|
-
const tagName = computed(() => {
|
|
231
|
-
const component = resolveComponent(`m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
232
|
-
if (typeof component !== "string")
|
|
233
|
-
return component;
|
|
234
|
-
return "m-fields-text";
|
|
235
|
-
});
|
|
230
|
+
const tagName = computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
236
231
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
237
232
|
const text = computed(() => filterFunction(mForm, props.config.text, props));
|
|
238
233
|
const tooltip = computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
@@ -240,11 +235,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
240
235
|
const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
241
236
|
const type = computed(() => {
|
|
242
237
|
let { type: type2 } = props.config;
|
|
243
|
-
|
|
244
|
-
type2 = type2(mForm, {
|
|
245
|
-
model: props.model
|
|
246
|
-
});
|
|
247
|
-
}
|
|
238
|
+
type2 = type2 && filterFunction(mForm, type2, props);
|
|
248
239
|
if (type2 === "form")
|
|
249
240
|
return "";
|
|
250
241
|
if (type2 === "container")
|
|
@@ -2212,17 +2203,19 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
2212
2203
|
const tMagicCascader = ref();
|
|
2213
2204
|
const options = ref([]);
|
|
2214
2205
|
const remoteData = ref(null);
|
|
2206
|
+
const checkStrictly = computed(() => filterFunction(mForm, props.config.checkStrictly, props));
|
|
2207
|
+
const valueSeparator = computed(() => filterFunction(mForm, props.config.valueSeparator, props));
|
|
2215
2208
|
const value = computed({
|
|
2216
2209
|
get() {
|
|
2217
|
-
if (typeof props.model[props.name] === "string" &&
|
|
2218
|
-
return props.model[props.name].split(
|
|
2210
|
+
if (typeof props.model[props.name] === "string" && valueSeparator.value) {
|
|
2211
|
+
return props.model[props.name].split(valueSeparator.value);
|
|
2219
2212
|
}
|
|
2220
2213
|
return props.model[props.name];
|
|
2221
2214
|
},
|
|
2222
2215
|
set(value2) {
|
|
2223
2216
|
let result = value2;
|
|
2224
|
-
if (
|
|
2225
|
-
result = value2.join(
|
|
2217
|
+
if (valueSeparator.value) {
|
|
2218
|
+
result = value2.join(valueSeparator.value);
|
|
2226
2219
|
}
|
|
2227
2220
|
props.model[props.name] = result;
|
|
2228
2221
|
}
|
|
@@ -2299,7 +2292,7 @@ const _sfc_main$n = /* @__PURE__ */ defineComponent({
|
|
|
2299
2292
|
props: {
|
|
2300
2293
|
multiple: _ctx.config.multiple ?? false,
|
|
2301
2294
|
emitPath: _ctx.config.emitPath ?? true,
|
|
2302
|
-
checkStrictly:
|
|
2295
|
+
checkStrictly: checkStrictly.value ?? false
|
|
2303
2296
|
},
|
|
2304
2297
|
onChange: changeHandler
|
|
2305
2298
|
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
|
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -226,12 +226,7 @@
|
|
|
226
226
|
}
|
|
227
227
|
return `${props.prop}${props.prop ? "." : ""}${n}`;
|
|
228
228
|
});
|
|
229
|
-
const tagName = vue.computed(() => {
|
|
230
|
-
const component = vue.resolveComponent(`m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
231
|
-
if (typeof component !== "string")
|
|
232
|
-
return component;
|
|
233
|
-
return "m-fields-text";
|
|
234
|
-
});
|
|
229
|
+
const tagName = vue.computed(() => `m-${items.value ? "form" : "fields"}-${type.value}`);
|
|
235
230
|
const disabled = vue.computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
236
231
|
const text = vue.computed(() => filterFunction(mForm, props.config.text, props));
|
|
237
232
|
const tooltip = vue.computed(() => filterFunction(mForm, props.config.tooltip, props));
|
|
@@ -239,11 +234,7 @@
|
|
|
239
234
|
const rule = vue.computed(() => getRules(mForm, props.config.rules, props));
|
|
240
235
|
const type = vue.computed(() => {
|
|
241
236
|
let { type: type2 } = props.config;
|
|
242
|
-
|
|
243
|
-
type2 = type2(mForm, {
|
|
244
|
-
model: props.model
|
|
245
|
-
});
|
|
246
|
-
}
|
|
237
|
+
type2 = type2 && filterFunction(mForm, type2, props);
|
|
247
238
|
if (type2 === "form")
|
|
248
239
|
return "";
|
|
249
240
|
if (type2 === "container")
|
|
@@ -2211,17 +2202,19 @@
|
|
|
2211
2202
|
const tMagicCascader = vue.ref();
|
|
2212
2203
|
const options = vue.ref([]);
|
|
2213
2204
|
const remoteData = vue.ref(null);
|
|
2205
|
+
const checkStrictly = vue.computed(() => filterFunction(mForm, props.config.checkStrictly, props));
|
|
2206
|
+
const valueSeparator = vue.computed(() => filterFunction(mForm, props.config.valueSeparator, props));
|
|
2214
2207
|
const value = vue.computed({
|
|
2215
2208
|
get() {
|
|
2216
|
-
if (typeof props.model[props.name] === "string" &&
|
|
2217
|
-
return props.model[props.name].split(
|
|
2209
|
+
if (typeof props.model[props.name] === "string" && valueSeparator.value) {
|
|
2210
|
+
return props.model[props.name].split(valueSeparator.value);
|
|
2218
2211
|
}
|
|
2219
2212
|
return props.model[props.name];
|
|
2220
2213
|
},
|
|
2221
2214
|
set(value2) {
|
|
2222
2215
|
let result = value2;
|
|
2223
|
-
if (
|
|
2224
|
-
result = value2.join(
|
|
2216
|
+
if (valueSeparator.value) {
|
|
2217
|
+
result = value2.join(valueSeparator.value);
|
|
2225
2218
|
}
|
|
2226
2219
|
props.model[props.name] = result;
|
|
2227
2220
|
}
|
|
@@ -2298,7 +2291,7 @@
|
|
|
2298
2291
|
props: {
|
|
2299
2292
|
multiple: _ctx.config.multiple ?? false,
|
|
2300
2293
|
emitPath: _ctx.config.emitPath ?? true,
|
|
2301
|
-
checkStrictly:
|
|
2294
|
+
checkStrictly: checkStrictly.value ?? false
|
|
2302
2295
|
},
|
|
2303
2296
|
onChange: changeHandler
|
|
2304
2297
|
}, null, 8, ["modelValue", "size", "placeholder", "disabled", "options", "popper-class", "props"]);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.7",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -35,11 +35,6 @@
|
|
|
35
35
|
"lodash-es": "^4.17.21",
|
|
36
36
|
"sortablejs": "^1.15.2"
|
|
37
37
|
},
|
|
38
|
-
"peerDependencies": {
|
|
39
|
-
"vue": "^3.4.27",
|
|
40
|
-
"@tmagic/design": "1.4.5",
|
|
41
|
-
"@tmagic/utils": "1.4.5"
|
|
42
|
-
},
|
|
43
38
|
"devDependencies": {
|
|
44
39
|
"@types/lodash-es": "^4.17.4",
|
|
45
40
|
"@types/node": "^18.19.0",
|
|
@@ -49,10 +44,20 @@
|
|
|
49
44
|
"@vue/test-utils": "^2.4.6",
|
|
50
45
|
"rimraf": "^3.0.2",
|
|
51
46
|
"sass": "^1.77.0",
|
|
52
|
-
"typescript": "^5.4.2",
|
|
53
47
|
"vite": "^5.2.11",
|
|
54
48
|
"vue-tsc": "^2.0.16"
|
|
55
49
|
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"vue": "^3.4.27",
|
|
52
|
+
"typescript": "*",
|
|
53
|
+
"@tmagic/design": "1.4.7",
|
|
54
|
+
"@tmagic/utils": "1.4.7"
|
|
55
|
+
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"typescript": {
|
|
58
|
+
"optional": true
|
|
59
|
+
}
|
|
60
|
+
},
|
|
56
61
|
"scripts": {
|
|
57
62
|
"build": "npm run build:type && vite build",
|
|
58
63
|
"build:type": "npm run clear:type && vue-tsc --declaration --emitDeclarationOnly --project tsconfig.build.json",
|
|
@@ -220,13 +220,13 @@
|
|
|
220
220
|
</template>
|
|
221
221
|
|
|
222
222
|
<script setup lang="ts">
|
|
223
|
-
import { computed, inject, ref,
|
|
223
|
+
import { computed, inject, ref, watch, watchEffect } from 'vue';
|
|
224
224
|
import { WarningFilled } from '@element-plus/icons-vue';
|
|
225
225
|
import { isEqual } from 'lodash-es';
|
|
226
226
|
|
|
227
227
|
import { TMagicButton, TMagicFormItem, TMagicIcon, TMagicTooltip } from '@tmagic/design';
|
|
228
228
|
|
|
229
|
-
import { ChildConfig, ContainerCommonConfig, FormState, FormValue } from '../schema';
|
|
229
|
+
import { ChildConfig, ContainerCommonConfig, FormState, FormValue, TypeFunction } from '../schema';
|
|
230
230
|
import { display as displayFunction, filterFunction, getRules } from '../utils/form';
|
|
231
231
|
|
|
232
232
|
defineOptions({
|
|
@@ -288,11 +288,7 @@ const itemProp = computed(() => {
|
|
|
288
288
|
return `${props.prop}${props.prop ? '.' : ''}${n}`;
|
|
289
289
|
});
|
|
290
290
|
|
|
291
|
-
const tagName = computed(() => {
|
|
292
|
-
const component = resolveComponent(`m-${items.value ? 'form' : 'fields'}-${type.value}`);
|
|
293
|
-
if (typeof component !== 'string') return component;
|
|
294
|
-
return 'm-fields-text';
|
|
295
|
-
});
|
|
291
|
+
const tagName = computed(() => `m-${items.value ? 'form' : 'fields'}-${type.value}`);
|
|
296
292
|
|
|
297
293
|
const disabled = computed(() => props.disabled || filterFunction(mForm, props.config.disabled, props));
|
|
298
294
|
|
|
@@ -306,11 +302,7 @@ const rule = computed(() => getRules(mForm, props.config.rules, props));
|
|
|
306
302
|
|
|
307
303
|
const type = computed((): string => {
|
|
308
304
|
let { type } = props.config;
|
|
309
|
-
|
|
310
|
-
type = type(mForm, {
|
|
311
|
-
model: props.model,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
305
|
+
type = type && (filterFunction<string | TypeFunction>(mForm, type, props) as string);
|
|
314
306
|
if (type === 'form') return '';
|
|
315
307
|
if (type === 'container') return '';
|
|
316
308
|
return type?.replace(/([A-Z])/g, '-$1').toLowerCase() || (items.value ? '' : 'text');
|
package/src/fields/Cascader.vue
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
:props="{
|
|
14
14
|
multiple: config.multiple ?? false,
|
|
15
15
|
emitPath: config.emitPath ?? true,
|
|
16
|
-
checkStrictly:
|
|
16
|
+
checkStrictly: checkStrictly ?? false,
|
|
17
17
|
}"
|
|
18
18
|
@change="changeHandler"
|
|
19
19
|
></TMagicCascader>
|
|
@@ -26,6 +26,7 @@ import { TMagicCascader } from '@tmagic/design';
|
|
|
26
26
|
|
|
27
27
|
import type { CascaderConfig, CascaderOption, FieldProps, FormState } from '../schema';
|
|
28
28
|
import { getConfig } from '../utils/config';
|
|
29
|
+
import { filterFunction } from '../utils/form';
|
|
29
30
|
import { useAddField } from '../utils/useAddField';
|
|
30
31
|
|
|
31
32
|
defineOptions({
|
|
@@ -36,7 +37,7 @@ const props = defineProps<FieldProps<CascaderConfig>>();
|
|
|
36
37
|
|
|
37
38
|
const emit = defineEmits(['change']);
|
|
38
39
|
|
|
39
|
-
const mForm = inject<FormState |
|
|
40
|
+
const mForm = inject<FormState | undefined>('mForm');
|
|
40
41
|
|
|
41
42
|
useAddField(props.prop);
|
|
42
43
|
|
|
@@ -47,17 +48,20 @@ const tMagicCascader = ref<InstanceType<typeof TMagicCascader>>();
|
|
|
47
48
|
const options = ref<CascaderOption[]>([]);
|
|
48
49
|
const remoteData = ref<any>(null);
|
|
49
50
|
|
|
51
|
+
const checkStrictly = computed(() => filterFunction(mForm, props.config.checkStrictly, props));
|
|
52
|
+
const valueSeparator = computed(() => filterFunction(mForm, props.config.valueSeparator, props));
|
|
53
|
+
|
|
50
54
|
const value = computed({
|
|
51
55
|
get() {
|
|
52
|
-
if (typeof props.model[props.name] === 'string' &&
|
|
53
|
-
return props.model[props.name].split(
|
|
56
|
+
if (typeof props.model[props.name] === 'string' && valueSeparator.value) {
|
|
57
|
+
return props.model[props.name].split(valueSeparator.value);
|
|
54
58
|
}
|
|
55
59
|
return props.model[props.name];
|
|
56
60
|
},
|
|
57
61
|
set(value) {
|
|
58
62
|
let result = value;
|
|
59
|
-
if (
|
|
60
|
-
result = value.join(
|
|
63
|
+
if (valueSeparator.value) {
|
|
64
|
+
result = value.join(valueSeparator.value);
|
|
61
65
|
}
|
|
62
66
|
props.model[props.name] = result;
|
|
63
67
|
},
|
package/src/schema.ts
CHANGED
|
@@ -536,11 +536,11 @@ export interface CascaderConfig extends FormItem, Input {
|
|
|
536
536
|
/** 是否多选,默认 false */
|
|
537
537
|
multiple?: boolean;
|
|
538
538
|
/** 是否严格的遵守父子节点不互相关联,默认 false */
|
|
539
|
-
checkStrictly?: boolean
|
|
539
|
+
checkStrictly?: boolean | FilterFunction<boolean>;
|
|
540
540
|
/** 弹出内容的自定义类名 */
|
|
541
541
|
popperClass?: string;
|
|
542
542
|
/** 合并成字符串时的分隔符 */
|
|
543
|
-
valueSeparator?: string
|
|
543
|
+
valueSeparator?: string | FilterFunction<string>;
|
|
544
544
|
options?:
|
|
545
545
|
| ((
|
|
546
546
|
mForm: FormState | undefined,
|
package/types/schema.d.ts
CHANGED
|
@@ -436,11 +436,11 @@ export interface CascaderConfig extends FormItem, Input {
|
|
|
436
436
|
/** 是否多选,默认 false */
|
|
437
437
|
multiple?: boolean;
|
|
438
438
|
/** 是否严格的遵守父子节点不互相关联,默认 false */
|
|
439
|
-
checkStrictly?: boolean
|
|
439
|
+
checkStrictly?: boolean | FilterFunction<boolean>;
|
|
440
440
|
/** 弹出内容的自定义类名 */
|
|
441
441
|
popperClass?: string;
|
|
442
442
|
/** 合并成字符串时的分隔符 */
|
|
443
|
-
valueSeparator?: string
|
|
443
|
+
valueSeparator?: string | FilterFunction<string>;
|
|
444
444
|
options?: ((mForm: FormState | undefined, data: {
|
|
445
445
|
model: Record<any, any>;
|
|
446
446
|
prop: string;
|