@tmagic/form 1.4.17 → 1.4.19
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 +53 -2
- package/dist/tmagic-form.js +95 -64
- package/dist/tmagic-form.umd.cjs +95 -65
- package/package.json +6 -4
- package/src/containers/Container.vue +5 -5
- package/src/fields/Text.vue +71 -36
- package/src/theme/form.scss +2 -2
- package/src/theme/text.scss +56 -0
package/dist/style.css
CHANGED
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
.m-form .el-tabs {
|
|
47
47
|
margin-bottom: 10px;
|
|
48
48
|
}
|
|
49
|
-
.m-form .el-form-item.hidden > .el-form-item__label {
|
|
49
|
+
.m-form .el-form-item.tmagic-form-hidden > .el-form-item__label {
|
|
50
50
|
display: none;
|
|
51
51
|
}
|
|
52
|
-
.m-form .t-form__item.hidden > .t-form__label {
|
|
52
|
+
.m-form .t-form__item.tmagic-form-hidden > .t-form__label {
|
|
53
53
|
display: none;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -64,6 +64,57 @@
|
|
|
64
64
|
line-height: 1.4;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
.tmagic-form-text-popper {
|
|
68
|
+
min-width: 150px;
|
|
69
|
+
line-height: 1.4;
|
|
70
|
+
background-color: #fff;
|
|
71
|
+
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
|
72
|
+
color: #606266;
|
|
73
|
+
border: 1px solid #e4e7ed;
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
font-size: 14px;
|
|
76
|
+
overflow-wrap: break-word;
|
|
77
|
+
box-sizing: border-box;
|
|
78
|
+
padding: 10px;
|
|
79
|
+
}
|
|
80
|
+
.tmagic-form-text-popper:focus {
|
|
81
|
+
outline: none;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.tmagic-form-text-popper[data-popper-placement^=top] > .tmagic-form-text-popper-arrow {
|
|
85
|
+
bottom: -4px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.tmagic-form-text-popper[data-popper-placement^=bottom] > .tmagic-form-text-popper-arrow {
|
|
89
|
+
top: -4px;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.tmagic-form-text-popper[data-popper-placement^=left] > .tmagic-form-text-popper-arrow {
|
|
93
|
+
right: -4px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.tmagic-form-text-popper[data-popper-placement^=right] > .tmagic-form-text-popper-arrow {
|
|
97
|
+
left: -4px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.tmagic-form-text-popper-arrow,
|
|
101
|
+
.tmagic-form-text-popper-arrow::before {
|
|
102
|
+
position: absolute;
|
|
103
|
+
width: 8px;
|
|
104
|
+
height: 8px;
|
|
105
|
+
background: inherit;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.tmagic-form-text-popper-arrow {
|
|
109
|
+
visibility: hidden;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.tmagic-form-text-popper-arrow::before {
|
|
113
|
+
visibility: visible;
|
|
114
|
+
content: "";
|
|
115
|
+
transform: rotate(45deg);
|
|
116
|
+
}
|
|
117
|
+
|
|
67
118
|
div.m-fields-link {
|
|
68
119
|
width: fit-content;
|
|
69
120
|
}
|
package/dist/tmagic-form.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
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';
|
|
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, shallowRef, createSlots, withModifiers } from 'vue';
|
|
2
2
|
import { WarningFilled, CaretBottom, CaretRight, Delete, CaretTop, Grid, ArrowUp, ArrowDown, FullScreen } from '@element-plus/icons-vue';
|
|
3
|
-
import { cloneDeep, isEqual, isEmpty } from 'lodash-es';
|
|
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,
|
|
3
|
+
import { cloneDeep, isEqual, isEmpty, debounce } from 'lodash-es';
|
|
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, TMagicTimePicker, TMagicDrawer, TMagicScrollbar } from '@tmagic/design';
|
|
5
5
|
import Sortable from 'sortablejs';
|
|
6
6
|
import { sleep, asyncLoadJs, datetimeFormatter, getValueByKeyPath, isNumber } from '@tmagic/utils';
|
|
7
|
+
import { createPopper } from '@popperjs/core';
|
|
7
8
|
|
|
8
9
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
9
10
|
const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
|
|
@@ -165,10 +166,10 @@ const initValue = async (mForm, { initValues, config }) => {
|
|
|
165
166
|
return valuesTmp || {};
|
|
166
167
|
};
|
|
167
168
|
|
|
168
|
-
const _hoisted_1$d = ["id", "data-
|
|
169
|
+
const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
|
|
169
170
|
const _hoisted_2$8 = ["innerHTML", "title"];
|
|
170
171
|
const _hoisted_3$5 = ["innerHTML"];
|
|
171
|
-
const _hoisted_4$
|
|
172
|
+
const _hoisted_4$5 = ["innerHTML"];
|
|
172
173
|
const _hoisted_5$4 = ["innerHTML"];
|
|
173
174
|
const _hoisted_6$2 = ["innerHTML", "title"];
|
|
174
175
|
const _hoisted_7$1 = ["innerHTML"];
|
|
@@ -319,8 +320,8 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
319
320
|
const _component_Container = resolveComponent("Container", true);
|
|
320
321
|
return _ctx.config ? (openBlock(), createElementBlock("div", {
|
|
321
322
|
key: 0,
|
|
322
|
-
id: _ctx.config.id,
|
|
323
|
-
"data-
|
|
323
|
+
"data-tmagic-id": _ctx.config.id,
|
|
324
|
+
"data-tmagic-form-item-prop": itemProp.value,
|
|
324
325
|
style: normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
|
|
325
326
|
class: normalizeClass(`m-form-container m-container-${type.value || ""} ${_ctx.config.className || ""}`)
|
|
326
327
|
}, [
|
|
@@ -349,7 +350,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
349
350
|
}, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
|
|
350
351
|
createVNode(unref(TMagicFormItem), {
|
|
351
352
|
style: normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
|
|
352
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
353
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
353
354
|
prop: itemProp.value,
|
|
354
355
|
"label-width": itemLabelWidth.value,
|
|
355
356
|
rules: rule.value
|
|
@@ -396,7 +397,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
396
397
|
key: 2,
|
|
397
398
|
innerHTML: extra.value,
|
|
398
399
|
class: "m-form-tip"
|
|
399
|
-
}, null, 8, _hoisted_4$
|
|
400
|
+
}, null, 8, _hoisted_4$5)) : createCommentVNode("", true)
|
|
400
401
|
]),
|
|
401
402
|
_: 1
|
|
402
403
|
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
@@ -422,7 +423,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
422
423
|
], 64)) : type.value && display$1.value && showDiff.value ? (openBlock(), createElementBlock(Fragment, { key: 3 }, [
|
|
423
424
|
createVNode(unref(TMagicFormItem), {
|
|
424
425
|
style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
|
|
425
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
426
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
426
427
|
prop: itemProp.value,
|
|
427
428
|
"label-width": itemLabelWidth.value,
|
|
428
429
|
rules: rule.value
|
|
@@ -490,7 +491,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
490
491
|
})) : createCommentVNode("", true),
|
|
491
492
|
createVNode(unref(TMagicFormItem), {
|
|
492
493
|
style: normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
|
|
493
|
-
class: normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
494
|
+
class: normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
494
495
|
prop: itemProp.value,
|
|
495
496
|
"label-width": itemLabelWidth.value,
|
|
496
497
|
rules: rule.value
|
|
@@ -597,7 +598,7 @@ const _sfc_main$x = /* @__PURE__ */ defineComponent({
|
|
|
597
598
|
const _hoisted_1$c = ["innerHTML"];
|
|
598
599
|
const _hoisted_2$7 = ["innerHTML"];
|
|
599
600
|
const _hoisted_3$4 = { key: 1 };
|
|
600
|
-
const _hoisted_4$
|
|
601
|
+
const _hoisted_4$4 = ["innerHTML"];
|
|
601
602
|
const _hoisted_5$3 = ["innerHTML"];
|
|
602
603
|
const _hoisted_6$1 = {
|
|
603
604
|
key: 2,
|
|
@@ -679,7 +680,7 @@ const _sfc_main$w = /* @__PURE__ */ defineComponent({
|
|
|
679
680
|
})) : (openBlock(), createElementBlock("legend", _hoisted_3$4, [
|
|
680
681
|
createElementVNode("span", {
|
|
681
682
|
innerHTML: _ctx.config.legend
|
|
682
|
-
}, null, 8, _hoisted_4$
|
|
683
|
+
}, null, 8, _hoisted_4$4),
|
|
683
684
|
_ctx.config.extra ? (openBlock(), createElementBlock("span", {
|
|
684
685
|
key: 0,
|
|
685
686
|
innerHTML: _ctx.config.extra,
|
|
@@ -894,9 +895,9 @@ const _hoisted_3$3 = {
|
|
|
894
895
|
key: 1,
|
|
895
896
|
class: "el-table__empty-block"
|
|
896
897
|
};
|
|
897
|
-
const _hoisted_4$
|
|
898
|
+
const _hoisted_4$3 = /* @__PURE__ */ createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
|
|
898
899
|
const _hoisted_5$2 = [
|
|
899
|
-
_hoisted_4$
|
|
900
|
+
_hoisted_4$3
|
|
900
901
|
];
|
|
901
902
|
const _sfc_main$u = /* @__PURE__ */ defineComponent({
|
|
902
903
|
...{
|
|
@@ -1036,7 +1037,7 @@ const _hoisted_3$2 = {
|
|
|
1036
1037
|
key: 0,
|
|
1037
1038
|
style: { "display": "flex" }
|
|
1038
1039
|
};
|
|
1039
|
-
const _hoisted_4$
|
|
1040
|
+
const _hoisted_4$2 = { style: { "flex": "1" } };
|
|
1040
1041
|
const _hoisted_5$1 = ["src"];
|
|
1041
1042
|
const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
1042
1043
|
...{
|
|
@@ -1092,7 +1093,7 @@ const _sfc_main$t = /* @__PURE__ */ defineComponent({
|
|
|
1092
1093
|
createElementVNode("div", null, [
|
|
1093
1094
|
renderSlot(_ctx.$slots, "default"),
|
|
1094
1095
|
_ctx.config.schematic ? (openBlock(), createElementBlock("div", _hoisted_3$2, [
|
|
1095
|
-
createElementVNode("div", _hoisted_4$
|
|
1096
|
+
createElementVNode("div", _hoisted_4$2, [
|
|
1096
1097
|
(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
|
|
1097
1098
|
return openBlock(), createBlock(_sfc_main$x, {
|
|
1098
1099
|
key: item[unref(mForm)?.keyProp || "__key"] ?? index,
|
|
@@ -1319,7 +1320,7 @@ const _sfc_main$q = /* @__PURE__ */ defineComponent({
|
|
|
1319
1320
|
const _hoisted_1$8 = { class: "m-fields-table-wrap" };
|
|
1320
1321
|
const _hoisted_2$3 = ["innerHTML"];
|
|
1321
1322
|
const _hoisted_3$1 = ["innerHTML"];
|
|
1322
|
-
const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
1323
|
+
const _hoisted_4$1 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
1323
1324
|
const _hoisted_5 = { style: { "display": "flex" } };
|
|
1324
1325
|
const _hoisted_6 = {
|
|
1325
1326
|
key: 1,
|
|
@@ -1854,7 +1855,7 @@ const _sfc_main$p = /* @__PURE__ */ defineComponent({
|
|
|
1854
1855
|
_: 3
|
|
1855
1856
|
}, 8, ["disabled"]),
|
|
1856
1857
|
renderSlot(_ctx.$slots, "default"),
|
|
1857
|
-
createElementVNode("div", _hoisted_4, [
|
|
1858
|
+
createElementVNode("div", _hoisted_4$1, [
|
|
1858
1859
|
addable.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
1859
1860
|
key: 0,
|
|
1860
1861
|
size: "small",
|
|
@@ -3860,9 +3861,13 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
|
3860
3861
|
}
|
|
3861
3862
|
});
|
|
3862
3863
|
|
|
3863
|
-
const _hoisted_1$1 = {
|
|
3864
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3864
3865
|
const _hoisted_2 = /* @__PURE__ */ createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1);
|
|
3865
3866
|
const _hoisted_3 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3867
|
+
const _hoisted_4 = /* @__PURE__ */ createElementVNode("span", {
|
|
3868
|
+
class: "tmagic-form-text-popper-arrow",
|
|
3869
|
+
"data-popper-arrow": ""
|
|
3870
|
+
}, null, -1);
|
|
3866
3871
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
3867
3872
|
...{
|
|
3868
3873
|
name: "MFormText"
|
|
@@ -3906,11 +3911,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3906
3911
|
emit("change", props.model[props.name].trim() || "");
|
|
3907
3912
|
popoverVisible.value = false;
|
|
3908
3913
|
};
|
|
3909
|
-
const checkWhiteSpace = (value) => {
|
|
3914
|
+
const checkWhiteSpace = debounce((value) => {
|
|
3910
3915
|
if (typeof value === "string" && !props.config.trim) {
|
|
3911
3916
|
popoverVisible.value = value.trim() !== value;
|
|
3912
3917
|
}
|
|
3913
|
-
};
|
|
3918
|
+
}, 300);
|
|
3914
3919
|
const changeHandler = (value) => {
|
|
3915
3920
|
emit("change", value);
|
|
3916
3921
|
};
|
|
@@ -3977,44 +3982,70 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3977
3982
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
3978
3983
|
emit("change", props.model[props.name]);
|
|
3979
3984
|
};
|
|
3985
|
+
const popoverEl = ref();
|
|
3986
|
+
const input = ref();
|
|
3987
|
+
const instanceRef = shallowRef();
|
|
3988
|
+
watch(popoverEl, (el) => {
|
|
3989
|
+
destroyPopover();
|
|
3990
|
+
if (!input.value?.$el || !el) return;
|
|
3991
|
+
instanceRef.value = createPopper(input.value.$el, el, {
|
|
3992
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
3993
|
+
strategy: "absolute",
|
|
3994
|
+
modifiers: [
|
|
3995
|
+
{
|
|
3996
|
+
name: "offset",
|
|
3997
|
+
options: {
|
|
3998
|
+
offset: [0, 10]
|
|
3999
|
+
}
|
|
4000
|
+
}
|
|
4001
|
+
]
|
|
4002
|
+
});
|
|
4003
|
+
});
|
|
4004
|
+
const destroyPopover = () => {
|
|
4005
|
+
if (!instanceRef.value) return;
|
|
4006
|
+
instanceRef.value.destroy();
|
|
4007
|
+
instanceRef.value = void 0;
|
|
4008
|
+
};
|
|
3980
4009
|
return (_ctx, _cache) => {
|
|
3981
|
-
return openBlock(),
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4010
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
4011
|
+
createVNode(unref(TMagicInput), {
|
|
4012
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4013
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4014
|
+
ref_key: "input",
|
|
4015
|
+
ref: input,
|
|
4016
|
+
clearable: "",
|
|
4017
|
+
size: _ctx.size,
|
|
4018
|
+
placeholder: _ctx.config.placeholder,
|
|
4019
|
+
disabled: _ctx.disabled,
|
|
4020
|
+
onChange: changeHandler,
|
|
4021
|
+
onInput: inputHandler,
|
|
4022
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4023
|
+
}, createSlots({ _: 2 }, [
|
|
4024
|
+
appendConfig.value ? {
|
|
4025
|
+
name: "append",
|
|
4026
|
+
fn: withCtx(() => [
|
|
4027
|
+
appendConfig.value.type === "button" ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4028
|
+
key: 0,
|
|
4029
|
+
style: { "color": "#409eff" },
|
|
4030
|
+
size: _ctx.size,
|
|
4031
|
+
onClick: withModifiers(buttonClickHandler, ["prevent"])
|
|
4032
|
+
}, {
|
|
4033
|
+
default: withCtx(() => [
|
|
4034
|
+
createTextVNode(toDisplayString(appendConfig.value.text), 1)
|
|
4035
|
+
]),
|
|
4036
|
+
_: 1
|
|
4037
|
+
}, 8, ["size"])) : createCommentVNode("", true)
|
|
4038
|
+
]),
|
|
4039
|
+
key: "0"
|
|
4040
|
+
} : void 0
|
|
4041
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4042
|
+
(openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
4043
|
+
popoverVisible.value ? (openBlock(), createElementBlock("div", {
|
|
4044
|
+
key: 0,
|
|
4045
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4046
|
+
ref_key: "popoverEl",
|
|
4047
|
+
ref: popoverEl
|
|
4048
|
+
}, [
|
|
4018
4049
|
_hoisted_2,
|
|
4019
4050
|
createElementVNode("div", _hoisted_3, [
|
|
4020
4051
|
createVNode(unref(TMagicButton), {
|
|
@@ -4037,11 +4068,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
4037
4068
|
]),
|
|
4038
4069
|
_: 1
|
|
4039
4070
|
})
|
|
4040
|
-
])
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4071
|
+
]),
|
|
4072
|
+
_hoisted_4
|
|
4073
|
+
], 512)) : createCommentVNode("", true)
|
|
4074
|
+
]))
|
|
4075
|
+
]);
|
|
4045
4076
|
};
|
|
4046
4077
|
}
|
|
4047
4078
|
});
|
package/dist/tmagic-form.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/design'), require('sortablejs'), require('@tmagic/utils')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', '@tmagic/design', 'sortablejs', '@tmagic/utils'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.lodashEs, global.design, global.Sortable, global.utils));
|
|
5
|
-
})(this, (function (exports, vue, iconsVue, lodashEs, design, Sortable, utils) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@element-plus/icons-vue'), require('lodash-es'), require('@tmagic/design'), require('sortablejs'), require('@tmagic/utils'), require('@popperjs/core')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'vue', '@element-plus/icons-vue', 'lodash-es', '@tmagic/design', 'sortablejs', '@tmagic/utils', '@popperjs/core'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.TMagicForm = {}, global.Vue, global.iconsVue, global.lodashEs, global.design, global.Sortable, global.utils, global.core));
|
|
5
|
+
})(this, (function (exports, vue, iconsVue, lodashEs, design, Sortable, utils, core) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const isTableSelect = (type) => typeof type === "string" && ["table-select", "tableSelect"].includes(type);
|
|
8
8
|
const asyncLoadConfig = (value, initValue2, { asyncLoad, name, type }) => {
|
|
@@ -164,10 +164,10 @@
|
|
|
164
164
|
return valuesTmp || {};
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
const _hoisted_1$d = ["id", "data-
|
|
167
|
+
const _hoisted_1$d = ["data-tmagic-id", "data-tmagic-form-item-prop"];
|
|
168
168
|
const _hoisted_2$8 = ["innerHTML", "title"];
|
|
169
169
|
const _hoisted_3$5 = ["innerHTML"];
|
|
170
|
-
const _hoisted_4$
|
|
170
|
+
const _hoisted_4$5 = ["innerHTML"];
|
|
171
171
|
const _hoisted_5$4 = ["innerHTML"];
|
|
172
172
|
const _hoisted_6$2 = ["innerHTML", "title"];
|
|
173
173
|
const _hoisted_7$1 = ["innerHTML"];
|
|
@@ -318,8 +318,8 @@
|
|
|
318
318
|
const _component_Container = vue.resolveComponent("Container", true);
|
|
319
319
|
return _ctx.config ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
320
320
|
key: 0,
|
|
321
|
-
id: _ctx.config.id,
|
|
322
|
-
"data-
|
|
321
|
+
"data-tmagic-id": _ctx.config.id,
|
|
322
|
+
"data-tmagic-form-item-prop": itemProp.value,
|
|
323
323
|
style: vue.normalizeStyle(_ctx.config.tip ? "display: flex;align-items: baseline;" : ""),
|
|
324
324
|
class: vue.normalizeClass(`m-form-container m-container-${type.value || ""} ${_ctx.config.className || ""}`)
|
|
325
325
|
}, [
|
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
}, null, 40, ["size", "model", "last-values", "is-compare", "config", "disabled", "name", "prop", "step-active", "expand-more", "label-width"])) : type.value && display$1.value && !showDiff.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 2 }, [
|
|
349
349
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
350
350
|
style: vue.normalizeStyle(_ctx.config.tip ? "flex: 1" : ""),
|
|
351
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
351
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
352
352
|
prop: itemProp.value,
|
|
353
353
|
"label-width": itemLabelWidth.value,
|
|
354
354
|
rules: rule.value
|
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
key: 2,
|
|
396
396
|
innerHTML: extra.value,
|
|
397
397
|
class: "m-form-tip"
|
|
398
|
-
}, null, 8, _hoisted_4$
|
|
398
|
+
}, null, 8, _hoisted_4$5)) : vue.createCommentVNode("", true)
|
|
399
399
|
]),
|
|
400
400
|
_: 1
|
|
401
401
|
}, 8, ["style", "class", "prop", "label-width", "rules"]),
|
|
@@ -421,7 +421,7 @@
|
|
|
421
421
|
], 64)) : type.value && display$1.value && showDiff.value ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 3 }, [
|
|
422
422
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
423
423
|
style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#f7dadd" }]),
|
|
424
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
424
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
425
425
|
prop: itemProp.value,
|
|
426
426
|
"label-width": itemLabelWidth.value,
|
|
427
427
|
rules: rule.value
|
|
@@ -489,7 +489,7 @@
|
|
|
489
489
|
})) : vue.createCommentVNode("", true),
|
|
490
490
|
vue.createVNode(vue.unref(design.TMagicFormItem), {
|
|
491
491
|
style: vue.normalizeStyle([_ctx.config.tip ? "flex: 1" : "", { "background": "#def7da" }]),
|
|
492
|
-
class: vue.normalizeClass({ hidden: `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
492
|
+
class: vue.normalizeClass({ "tmagic-form-hidden": `${itemLabelWidth.value}` === "0" || !text.value }),
|
|
493
493
|
prop: itemProp.value,
|
|
494
494
|
"label-width": itemLabelWidth.value,
|
|
495
495
|
rules: rule.value
|
|
@@ -596,7 +596,7 @@
|
|
|
596
596
|
const _hoisted_1$c = ["innerHTML"];
|
|
597
597
|
const _hoisted_2$7 = ["innerHTML"];
|
|
598
598
|
const _hoisted_3$4 = { key: 1 };
|
|
599
|
-
const _hoisted_4$
|
|
599
|
+
const _hoisted_4$4 = ["innerHTML"];
|
|
600
600
|
const _hoisted_5$3 = ["innerHTML"];
|
|
601
601
|
const _hoisted_6$1 = {
|
|
602
602
|
key: 2,
|
|
@@ -678,7 +678,7 @@
|
|
|
678
678
|
})) : (vue.openBlock(), vue.createElementBlock("legend", _hoisted_3$4, [
|
|
679
679
|
vue.createElementVNode("span", {
|
|
680
680
|
innerHTML: _ctx.config.legend
|
|
681
|
-
}, null, 8, _hoisted_4$
|
|
681
|
+
}, null, 8, _hoisted_4$4),
|
|
682
682
|
_ctx.config.extra ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
683
683
|
key: 0,
|
|
684
684
|
innerHTML: _ctx.config.extra,
|
|
@@ -893,9 +893,9 @@
|
|
|
893
893
|
key: 1,
|
|
894
894
|
class: "el-table__empty-block"
|
|
895
895
|
};
|
|
896
|
-
const _hoisted_4$
|
|
896
|
+
const _hoisted_4$3 = /* @__PURE__ */ vue.createElementVNode("span", { class: "el-table__empty-text" }, "暂无数据", -1);
|
|
897
897
|
const _hoisted_5$2 = [
|
|
898
|
-
_hoisted_4$
|
|
898
|
+
_hoisted_4$3
|
|
899
899
|
];
|
|
900
900
|
const _sfc_main$u = /* @__PURE__ */ vue.defineComponent({
|
|
901
901
|
...{
|
|
@@ -1035,7 +1035,7 @@
|
|
|
1035
1035
|
key: 0,
|
|
1036
1036
|
style: { "display": "flex" }
|
|
1037
1037
|
};
|
|
1038
|
-
const _hoisted_4$
|
|
1038
|
+
const _hoisted_4$2 = { style: { "flex": "1" } };
|
|
1039
1039
|
const _hoisted_5$1 = ["src"];
|
|
1040
1040
|
const _sfc_main$t = /* @__PURE__ */ vue.defineComponent({
|
|
1041
1041
|
...{
|
|
@@ -1091,7 +1091,7 @@
|
|
|
1091
1091
|
vue.createElementVNode("div", null, [
|
|
1092
1092
|
vue.renderSlot(_ctx.$slots, "default"),
|
|
1093
1093
|
_ctx.config.schematic ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$2, [
|
|
1094
|
-
vue.createElementVNode("div", _hoisted_4$
|
|
1094
|
+
vue.createElementVNode("div", _hoisted_4$2, [
|
|
1095
1095
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(items.value, (item, index) => {
|
|
1096
1096
|
return vue.openBlock(), vue.createBlock(_sfc_main$x, {
|
|
1097
1097
|
key: item[vue.unref(mForm)?.keyProp || "__key"] ?? index,
|
|
@@ -1318,7 +1318,7 @@
|
|
|
1318
1318
|
const _hoisted_1$8 = { class: "m-fields-table-wrap" };
|
|
1319
1319
|
const _hoisted_2$3 = ["innerHTML"];
|
|
1320
1320
|
const _hoisted_3$1 = ["innerHTML"];
|
|
1321
|
-
const _hoisted_4 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
1321
|
+
const _hoisted_4$1 = { style: { "display": "flex", "justify-content": "space-between", "margin": "10px 0" } };
|
|
1322
1322
|
const _hoisted_5 = { style: { "display": "flex" } };
|
|
1323
1323
|
const _hoisted_6 = {
|
|
1324
1324
|
key: 1,
|
|
@@ -1853,7 +1853,7 @@
|
|
|
1853
1853
|
_: 3
|
|
1854
1854
|
}, 8, ["disabled"]),
|
|
1855
1855
|
vue.renderSlot(_ctx.$slots, "default"),
|
|
1856
|
-
vue.createElementVNode("div", _hoisted_4, [
|
|
1856
|
+
vue.createElementVNode("div", _hoisted_4$1, [
|
|
1857
1857
|
addable.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
1858
1858
|
key: 0,
|
|
1859
1859
|
size: "small",
|
|
@@ -3859,9 +3859,13 @@
|
|
|
3859
3859
|
}
|
|
3860
3860
|
});
|
|
3861
3861
|
|
|
3862
|
-
const _hoisted_1$1 = {
|
|
3862
|
+
const _hoisted_1$1 = { style: { "width": "100%" } };
|
|
3863
3863
|
const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("div", { class: "m-form-validate__warning" }, "输入内容前后有空格,是否移除空格?", -1);
|
|
3864
3864
|
const _hoisted_3 = { style: { "display": "flex", "justify-content": "flex-end" } };
|
|
3865
|
+
const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("span", {
|
|
3866
|
+
class: "tmagic-form-text-popper-arrow",
|
|
3867
|
+
"data-popper-arrow": ""
|
|
3868
|
+
}, null, -1);
|
|
3865
3869
|
const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
|
|
3866
3870
|
...{
|
|
3867
3871
|
name: "MFormText"
|
|
@@ -3905,11 +3909,11 @@
|
|
|
3905
3909
|
emit("change", props.model[props.name].trim() || "");
|
|
3906
3910
|
popoverVisible.value = false;
|
|
3907
3911
|
};
|
|
3908
|
-
const checkWhiteSpace = (value) => {
|
|
3912
|
+
const checkWhiteSpace = lodashEs.debounce((value) => {
|
|
3909
3913
|
if (typeof value === "string" && !props.config.trim) {
|
|
3910
3914
|
popoverVisible.value = value.trim() !== value;
|
|
3911
3915
|
}
|
|
3912
|
-
};
|
|
3916
|
+
}, 300);
|
|
3913
3917
|
const changeHandler = (value) => {
|
|
3914
3918
|
emit("change", value);
|
|
3915
3919
|
};
|
|
@@ -3976,44 +3980,70 @@
|
|
|
3976
3980
|
props.model[props.name] = `${num}${unit || ""}`;
|
|
3977
3981
|
emit("change", props.model[props.name]);
|
|
3978
3982
|
};
|
|
3983
|
+
const popoverEl = vue.ref();
|
|
3984
|
+
const input = vue.ref();
|
|
3985
|
+
const instanceRef = vue.shallowRef();
|
|
3986
|
+
vue.watch(popoverEl, (el) => {
|
|
3987
|
+
destroyPopover();
|
|
3988
|
+
if (!input.value?.$el || !el) return;
|
|
3989
|
+
instanceRef.value = core.createPopper(input.value.$el, el, {
|
|
3990
|
+
placement: props.config.tooltip ? "top" : "bottom",
|
|
3991
|
+
strategy: "absolute",
|
|
3992
|
+
modifiers: [
|
|
3993
|
+
{
|
|
3994
|
+
name: "offset",
|
|
3995
|
+
options: {
|
|
3996
|
+
offset: [0, 10]
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
]
|
|
4000
|
+
});
|
|
4001
|
+
});
|
|
4002
|
+
const destroyPopover = () => {
|
|
4003
|
+
if (!instanceRef.value) return;
|
|
4004
|
+
instanceRef.value.destroy();
|
|
4005
|
+
instanceRef.value = void 0;
|
|
4006
|
+
};
|
|
3979
4007
|
return (_ctx, _cache) => {
|
|
3980
|
-
return vue.openBlock(), vue.
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4008
|
+
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$1, [
|
|
4009
|
+
vue.createVNode(vue.unref(design.TMagicInput), {
|
|
4010
|
+
modelValue: _ctx.model[_ctx.name],
|
|
4011
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.model[_ctx.name] = $event),
|
|
4012
|
+
ref_key: "input",
|
|
4013
|
+
ref: input,
|
|
4014
|
+
clearable: "",
|
|
4015
|
+
size: _ctx.size,
|
|
4016
|
+
placeholder: _ctx.config.placeholder,
|
|
4017
|
+
disabled: _ctx.disabled,
|
|
4018
|
+
onChange: changeHandler,
|
|
4019
|
+
onInput: inputHandler,
|
|
4020
|
+
onKeyup: _cache[1] || (_cache[1] = ($event) => keyUpHandler($event))
|
|
4021
|
+
}, vue.createSlots({ _: 2 }, [
|
|
4022
|
+
appendConfig.value ? {
|
|
4023
|
+
name: "append",
|
|
4024
|
+
fn: vue.withCtx(() => [
|
|
4025
|
+
appendConfig.value.type === "button" ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
4026
|
+
key: 0,
|
|
4027
|
+
style: { "color": "#409eff" },
|
|
4028
|
+
size: _ctx.size,
|
|
4029
|
+
onClick: vue.withModifiers(buttonClickHandler, ["prevent"])
|
|
4030
|
+
}, {
|
|
4031
|
+
default: vue.withCtx(() => [
|
|
4032
|
+
vue.createTextVNode(vue.toDisplayString(appendConfig.value.text), 1)
|
|
4033
|
+
]),
|
|
4034
|
+
_: 1
|
|
4035
|
+
}, 8, ["size"])) : vue.createCommentVNode("", true)
|
|
4036
|
+
]),
|
|
4037
|
+
key: "0"
|
|
4038
|
+
} : void 0
|
|
4039
|
+
]), 1032, ["modelValue", "size", "placeholder", "disabled"]),
|
|
4040
|
+
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: "body" }, [
|
|
4041
|
+
popoverVisible.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
4042
|
+
key: 0,
|
|
4043
|
+
class: "tmagic-form-text-popper m-form-item__content",
|
|
4044
|
+
ref_key: "popoverEl",
|
|
4045
|
+
ref: popoverEl
|
|
4046
|
+
}, [
|
|
4017
4047
|
_hoisted_2,
|
|
4018
4048
|
vue.createElementVNode("div", _hoisted_3, [
|
|
4019
4049
|
vue.createVNode(vue.unref(design.TMagicButton), {
|
|
@@ -4036,11 +4066,11 @@
|
|
|
4036
4066
|
]),
|
|
4037
4067
|
_: 1
|
|
4038
4068
|
})
|
|
4039
|
-
])
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4069
|
+
]),
|
|
4070
|
+
_hoisted_4
|
|
4071
|
+
], 512)) : vue.createCommentVNode("", true)
|
|
4072
|
+
]))
|
|
4073
|
+
]);
|
|
4044
4074
|
};
|
|
4045
4075
|
}
|
|
4046
4076
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.19",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
6
|
+
"dist/style.css",
|
|
6
7
|
"src/theme/*"
|
|
7
8
|
],
|
|
8
9
|
"main": "dist/tmagic-form.umd.cjs",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@element-plus/icons-vue": "^2.3.1",
|
|
40
|
+
"@popperjs/core": "^2.11.8",
|
|
39
41
|
"lodash-es": "^4.17.21",
|
|
40
42
|
"sortablejs": "^1.15.2"
|
|
41
43
|
},
|
|
@@ -52,10 +54,10 @@
|
|
|
52
54
|
"vue-tsc": "^2.0.19"
|
|
53
55
|
},
|
|
54
56
|
"peerDependencies": {
|
|
55
|
-
"vue": "^3.4.35",
|
|
56
57
|
"typescript": "*",
|
|
57
|
-
"
|
|
58
|
-
"@tmagic/
|
|
58
|
+
"vue": "^3.4.35",
|
|
59
|
+
"@tmagic/design": "1.4.19",
|
|
60
|
+
"@tmagic/utils": "1.4.19"
|
|
59
61
|
},
|
|
60
62
|
"peerDependenciesMeta": {
|
|
61
63
|
"typescript": {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
v-if="config"
|
|
4
|
-
:id="config.id"
|
|
5
|
-
:data-
|
|
4
|
+
:data-tmagic-id="config.id"
|
|
5
|
+
:data-tmagic-form-item-prop="itemProp"
|
|
6
6
|
:style="config.tip ? 'display: flex;align-items: baseline;' : ''"
|
|
7
7
|
:class="`m-form-container m-container-${type || ''} ${config.className || ''}`"
|
|
8
8
|
>
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<template v-else-if="type && display && !showDiff">
|
|
38
38
|
<TMagicFormItem
|
|
39
39
|
:style="config.tip ? 'flex: 1' : ''"
|
|
40
|
-
:class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
|
|
40
|
+
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
41
41
|
:prop="itemProp"
|
|
42
42
|
:label-width="itemLabelWidth"
|
|
43
43
|
:rules="rule"
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
<!-- 上次内容 -->
|
|
94
94
|
<TMagicFormItem
|
|
95
95
|
:style="config.tip ? 'flex: 1' : ''"
|
|
96
|
-
:class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
|
|
96
|
+
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
97
97
|
:prop="itemProp"
|
|
98
98
|
:label-width="itemLabelWidth"
|
|
99
99
|
:rules="rule"
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
<!-- 当前内容 -->
|
|
143
143
|
<TMagicFormItem
|
|
144
144
|
:style="config.tip ? 'flex: 1' : ''"
|
|
145
|
-
:class="{ hidden: `${itemLabelWidth}` === '0' || !text }"
|
|
145
|
+
:class="{ 'tmagic-form-hidden': `${itemLabelWidth}` === '0' || !text }"
|
|
146
146
|
:prop="itemProp"
|
|
147
147
|
:label-width="itemLabelWidth"
|
|
148
148
|
:rules="rule"
|
package/src/fields/Text.vue
CHANGED
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
<div style="width: 100%">
|
|
3
|
+
<TMagicInput
|
|
4
|
+
v-model="model[name]"
|
|
5
|
+
ref="input"
|
|
6
|
+
clearable
|
|
7
|
+
:size="size"
|
|
8
|
+
:placeholder="config.placeholder"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
@change="changeHandler"
|
|
11
|
+
@input="inputHandler"
|
|
12
|
+
@keyup="keyUpHandler($event)"
|
|
13
|
+
>
|
|
14
|
+
<template #append v-if="appendConfig">
|
|
15
|
+
<TMagicButton
|
|
16
|
+
v-if="appendConfig.type === 'button'"
|
|
17
|
+
style="color: #409eff"
|
|
18
|
+
:size="size"
|
|
19
|
+
@click.prevent="buttonClickHandler"
|
|
20
|
+
>
|
|
21
|
+
{{ appendConfig.text }}
|
|
22
|
+
</TMagicButton>
|
|
23
|
+
</template>
|
|
24
|
+
</TMagicInput>
|
|
25
|
+
|
|
26
|
+
<Teleport to="body">
|
|
27
|
+
<div v-if="popoverVisible" class="tmagic-form-text-popper m-form-item__content" ref="popoverEl">
|
|
28
|
+
<div class="m-form-validate__warning">输入内容前后有空格,是否移除空格?</div>
|
|
29
|
+
<div style="display: flex; justify-content: flex-end">
|
|
30
|
+
<TMagicButton link size="small" @click="popoverVisible = false">保持原样</TMagicButton>
|
|
31
|
+
<TMagicButton type="primary" size="small" @click="confirmTrimHandler">移除空格</TMagicButton>
|
|
32
|
+
</div>
|
|
33
|
+
<span class="tmagic-form-text-popper-arrow" data-popper-arrow></span>
|
|
32
34
|
</div>
|
|
33
|
-
</
|
|
34
|
-
</
|
|
35
|
+
</Teleport>
|
|
36
|
+
</div>
|
|
35
37
|
</template>
|
|
36
38
|
|
|
37
39
|
<script lang="ts" setup>
|
|
38
|
-
import { computed, inject, ref } from 'vue';
|
|
40
|
+
import { computed, inject, ref, shallowRef, watch } from 'vue';
|
|
41
|
+
import type { Instance } from '@popperjs/core';
|
|
42
|
+
import { createPopper } from '@popperjs/core';
|
|
43
|
+
import { debounce } from 'lodash-es';
|
|
39
44
|
|
|
40
|
-
import { TMagicButton, TMagicInput
|
|
45
|
+
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
41
46
|
import { isNumber } from '@tmagic/utils';
|
|
42
47
|
|
|
43
48
|
import type { FieldProps, FormState, TextConfig } from '../schema';
|
|
@@ -85,11 +90,11 @@ const confirmTrimHandler = () => {
|
|
|
85
90
|
popoverVisible.value = false;
|
|
86
91
|
};
|
|
87
92
|
|
|
88
|
-
const checkWhiteSpace = (value: unknown) => {
|
|
93
|
+
const checkWhiteSpace = debounce((value: unknown) => {
|
|
89
94
|
if (typeof value === 'string' && !props.config.trim) {
|
|
90
95
|
popoverVisible.value = value.trim() !== value;
|
|
91
96
|
}
|
|
92
|
-
};
|
|
97
|
+
}, 300);
|
|
93
98
|
|
|
94
99
|
const changeHandler = (value: string) => {
|
|
95
100
|
emit('change', value);
|
|
@@ -167,4 +172,34 @@ const keyUpHandler = ($event: KeyboardEvent) => {
|
|
|
167
172
|
props.model[props.name] = `${num}${unit || ''}`;
|
|
168
173
|
emit('change', props.model[props.name]);
|
|
169
174
|
};
|
|
175
|
+
|
|
176
|
+
const popoverEl = ref<HTMLDivElement>();
|
|
177
|
+
const input = ref<InstanceType<typeof TMagicInput>>();
|
|
178
|
+
const instanceRef = shallowRef<Instance | undefined>();
|
|
179
|
+
|
|
180
|
+
watch(popoverEl, (el) => {
|
|
181
|
+
destroyPopover();
|
|
182
|
+
|
|
183
|
+
if (!input.value?.$el || !el) return;
|
|
184
|
+
|
|
185
|
+
instanceRef.value = createPopper(input.value.$el, el, {
|
|
186
|
+
placement: props.config.tooltip ? 'top' : 'bottom',
|
|
187
|
+
strategy: 'absolute',
|
|
188
|
+
modifiers: [
|
|
189
|
+
{
|
|
190
|
+
name: 'offset',
|
|
191
|
+
options: {
|
|
192
|
+
offset: [0, 10],
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
],
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const destroyPopover = () => {
|
|
200
|
+
if (!instanceRef.value) return;
|
|
201
|
+
|
|
202
|
+
instanceRef.value.destroy();
|
|
203
|
+
instanceRef.value = undefined;
|
|
204
|
+
};
|
|
170
205
|
</script>
|
package/src/theme/form.scss
CHANGED
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
margin-bottom: 10px;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.el-form-item.hidden {
|
|
32
|
+
.el-form-item.tmagic-form-hidden {
|
|
33
33
|
> .el-form-item__label {
|
|
34
34
|
display: none;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.t-form__item.hidden {
|
|
38
|
+
.t-form__item.tmagic-form-hidden {
|
|
39
39
|
> .t-form__label {
|
|
40
40
|
display: none;
|
|
41
41
|
}
|
package/src/theme/text.scss
CHANGED
|
@@ -4,3 +4,59 @@
|
|
|
4
4
|
width: 100%;
|
|
5
5
|
line-height: 1.4;
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
.tmagic-form-text-popper {
|
|
9
|
+
min-width: 150px;
|
|
10
|
+
line-height: 1.4;
|
|
11
|
+
background-color: #fff;
|
|
12
|
+
box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
|
|
13
|
+
color: #606266;
|
|
14
|
+
border: 1px solid #e4e7ed;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
font-size: 14px;
|
|
17
|
+
overflow-wrap: break-word;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
padding: 10px;
|
|
20
|
+
|
|
21
|
+
&:focus {
|
|
22
|
+
outline: none;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tmagic-form-text-popper[data-popper-placement^="top"]
|
|
27
|
+
> .tmagic-form-text-popper-arrow {
|
|
28
|
+
bottom: -4px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tmagic-form-text-popper[data-popper-placement^="bottom"]
|
|
32
|
+
> .tmagic-form-text-popper-arrow {
|
|
33
|
+
top: -4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.tmagic-form-text-popper[data-popper-placement^="left"]
|
|
37
|
+
> .tmagic-form-text-popper-arrow {
|
|
38
|
+
right: -4px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.tmagic-form-text-popper[data-popper-placement^="right"]
|
|
42
|
+
> .tmagic-form-text-popper-arrow {
|
|
43
|
+
left: -4px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.tmagic-form-text-popper-arrow,
|
|
47
|
+
.tmagic-form-text-popper-arrow::before {
|
|
48
|
+
position: absolute;
|
|
49
|
+
width: 8px;
|
|
50
|
+
height: 8px;
|
|
51
|
+
background: inherit;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.tmagic-form-text-popper-arrow {
|
|
55
|
+
visibility: hidden;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.tmagic-form-text-popper-arrow::before {
|
|
59
|
+
visibility: visible;
|
|
60
|
+
content: "";
|
|
61
|
+
transform: rotate(45deg);
|
|
62
|
+
}
|