ninemoon-ui 0.0.27 → 0.1.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/dist/components/alert/alert.d.ts +3 -11
- package/dist/components/alert/alertcomponent.vue.d.ts +22 -11
- package/dist/components/badge/badge.vue.d.ts +2 -0
- package/dist/components/carousel/carousel.vue.d.ts +29 -3
- package/dist/components/{tree/tree.vue.d.ts → carousel/clickbutton.vue.d.ts} +6 -19
- package/dist/components/check/checkbox.vue.d.ts +24 -16
- package/dist/components/check/checkgroup.vue.d.ts +15 -3
- package/dist/components/date/datepicker.vue.d.ts +28 -6
- package/dist/components/date/datepickerRange.vue.d.ts +15 -4
- package/dist/components/form/form.vue.d.ts +7 -20
- package/dist/components/form/formlabel.vue.d.ts +3 -3
- package/dist/components/form/type.d.ts +11 -0
- package/dist/components/icon/add.vue.d.ts +2 -0
- package/dist/components/icon/alertTip.vue.d.ts +2 -0
- package/dist/components/icon/arrow.vue.d.ts +2 -0
- package/dist/components/icon/calendar.vue.d.ts +2 -0
- package/dist/components/icon/close.vue.d.ts +2 -0
- package/dist/components/icon/dateArrow.vue.d.ts +2 -0
- package/dist/components/icon/dateArrowplus.vue.d.ts +2 -0
- package/dist/components/icon/delete.vue.d.ts +2 -0
- package/dist/components/icon/ellipsis.vue.d.ts +2 -0
- package/dist/components/icon/errTip.vue.d.ts +2 -0
- package/dist/components/icon/eye.vue.d.ts +2 -0
- package/dist/components/icon/infoTip.vue.d.ts +2 -0
- package/dist/components/icon/minus.vue.d.ts +2 -0
- package/dist/components/icon/successTip.vue.d.ts +2 -0
- package/dist/components/icon/turnleft.vue.d.ts +2 -0
- package/dist/components/icon/turnright.vue.d.ts +2 -0
- package/dist/components/icon/warnTip.vue.d.ts +2 -0
- package/dist/components/input/input.vue.d.ts +13 -8
- package/dist/components/loadding/loadcomponent.vue.d.ts +24 -4
- package/dist/components/loadding/loadding.d.ts +12 -19
- package/dist/components/menu/menu.vue.d.ts +13 -3
- package/dist/components/message/message.d.ts +68 -14
- package/dist/components/message/messagecomponent.vue.d.ts +5 -13
- package/dist/components/numberInput/numberinput.vue.d.ts +3 -3
- package/dist/components/pagination/pagination.vue.d.ts +24 -0
- package/dist/components/popover/poparrow.d.ts +55 -0
- package/dist/components/popover/popover.vue.d.ts +10 -4
- package/dist/components/radio/radiobox.vue.d.ts +24 -16
- package/dist/components/radio/radiogroup.vue.d.ts +15 -3
- package/dist/components/scrollBar/movebar.vue.d.ts +2 -2
- package/dist/components/scrollBar/scrollBar.vue.d.ts +12 -16
- package/dist/components/scrollloading/scrolllead.d.ts +18 -11
- package/dist/components/select/select.vue.d.ts +15 -1
- package/dist/components/select/selectoption.vue.d.ts +18 -6
- package/dist/components/switch/switch.vue.d.ts +14 -14
- package/dist/components/table/table.vue.d.ts +20 -9
- package/dist/components/table/tableItem.vue.d.ts +10 -4
- package/dist/components/tabs/tabs.vue.d.ts +14 -1
- package/dist/dialog.css +9 -0
- package/dist/directives/arrowKeys.d.ts +10 -0
- package/dist/directives/drag.d.ts +20 -0
- package/dist/directives/escape.d.ts +7 -0
- package/dist/directives/outsideclick.d.ts +14 -0
- package/dist/directives/watchwindow.d.ts +13 -0
- package/dist/directives/wheel.d.ts +12 -0
- package/dist/directives/whitespaceclick.d.ts +12 -0
- package/dist/index.css +1186 -873
- package/dist/index.d.ts +831 -401
- package/dist/index.es.js +22 -23
- package/dist/index.umd.js +4019 -3764
- package/dist/js/arrow/arrow.js +17 -0
- package/dist/js/badge/badge.js +9 -16
- package/dist/js/calendar/calendar.js +87 -0
- package/dist/js/carousel/carousel.js +101 -117
- package/dist/js/carousel/carouselitem.js +1 -7
- package/dist/js/check/checkbox.js +38 -4
- package/dist/js/check/checkgroup.js +40 -51
- package/dist/js/date/datepicker.js +146 -150
- package/dist/js/date/datepickerRange.js +265 -354
- package/dist/js/dateArrowplus/dateArrowplus.js +25 -0
- package/dist/js/delete/delete.js +19 -0
- package/dist/js/dialog/dialog.js +41 -57
- package/dist/js/form/form.js +30 -38
- package/dist/js/form/formlabel.js +99 -130
- package/dist/js/image/image.js +199 -149
- package/dist/js/index/index.js +605 -507
- package/dist/js/input/input.js +60 -43
- package/dist/js/menu/menu.js +47 -20
- package/dist/js/numberInput/numberinput.js +52 -60
- package/dist/js/pagination/pagination.js +125 -156
- package/dist/js/popover/popover.js +238 -134
- package/dist/js/radio/radiobox.js +37 -4
- package/dist/js/radio/radiogroup.js +15 -51
- package/dist/js/scrollBar/scrollBar.js +100 -56
- package/dist/js/select/select.js +155 -70
- package/dist/js/select/selectoption.js +45 -4
- package/dist/js/shapeFlag/shapeFlag.js +17 -0
- package/dist/js/switch/switch.js +14 -14
- package/dist/js/table/table.js +165 -111
- package/dist/js/table/tableItem.js +1 -1
- package/dist/js/tabs/tabs.js +57 -59
- package/dist/js/upload/upload.js +8 -23
- package/dist/tabs.css +3 -3
- package/dist/types/shapeFlag.d.ts +13 -0
- package/dist/{components/utils → utils}/tool.d.ts +11 -4
- package/package.json +1 -1
- package/dist/badge.css +0 -27
- package/dist/carousel.css +0 -13
- package/dist/checkgroup.css +0 -41
- package/dist/datepickerRange.css +0 -79
- package/dist/image.css +0 -8
- package/dist/js/getcalendar/getcalendar.js +0 -48
- package/dist/js/tree/tree.js +0 -72
- package/dist/js/tree/treeleaf.js +0 -116
- package/dist/radiogroup.css +0 -44
- package/dist/scrollBar.css +0 -37
- package/dist/select.css +0 -20
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { openBlock, createElementBlock, createElementVNode } from "vue";
|
|
2
|
+
import { _ as _export_sfc } from "../index/index.js";
|
|
3
|
+
const _sfc_main = {};
|
|
4
|
+
const _hoisted_1 = {
|
|
5
|
+
viewBox: "0 0 1024 1024",
|
|
6
|
+
version: "1.1",
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
"p-id": "669"
|
|
9
|
+
};
|
|
10
|
+
function _sfc_render(_ctx, _cache) {
|
|
11
|
+
return openBlock(), createElementBlock("svg", _hoisted_1, _cache[0] || (_cache[0] = [
|
|
12
|
+
createElementVNode("path", {
|
|
13
|
+
d: "M842.666667 864c-8.533333 0-14.933333-2.133333-21.333334-8.533333l-341.333333-309.333334c-6.4-6.4-10.666667-14.933333-10.666667-23.466666 0-8.533333 4.266667-17.066667 10.666667-23.466667l341.333333-309.333333c12.8-12.8 34.133333-10.666667 44.8 2.133333 12.8 12.8 10.666667 34.133333-2.133333 44.8L548.266667 522.666667l315.733333 285.866666c12.8 10.666667 14.933333 32 2.133333 44.8-6.4 6.4-14.933333 10.666667-23.466666 10.666667z",
|
|
14
|
+
fill: "#666666"
|
|
15
|
+
}, null, -1),
|
|
16
|
+
createElementVNode("path", {
|
|
17
|
+
d: "M512 864c-8.533333 0-14.933333-2.133333-21.333333-8.533333L149.333333 546.133333c-6.4-6.4-10.666667-14.933333-10.666666-23.466666 0-8.533333 4.266667-17.066667 10.666666-23.466667L490.666667 189.866667c12.8-12.8 34.133333-10.666667 44.8 2.133333 12.8 12.8 10.666667 34.133333-2.133334 44.8L217.6 522.666667 533.333333 808.533333c12.8 12.8 14.933333 32 2.133334 44.8-6.4 6.4-14.933333 10.666667-23.466667 10.666667z",
|
|
18
|
+
fill: "#666666"
|
|
19
|
+
}, null, -1)
|
|
20
|
+
]));
|
|
21
|
+
}
|
|
22
|
+
const ArrowPlug = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
23
|
+
export {
|
|
24
|
+
ArrowPlug as A
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { openBlock, createElementBlock, createElementVNode } from "vue";
|
|
2
|
+
import { _ as _export_sfc } from "../index/index.js";
|
|
3
|
+
const _sfc_main = {};
|
|
4
|
+
const _hoisted_1 = {
|
|
5
|
+
viewBox: "64 64 896 896",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
"aria-hidden": "true"
|
|
10
|
+
};
|
|
11
|
+
function _sfc_render(_ctx, _cache) {
|
|
12
|
+
return openBlock(), createElementBlock("svg", _hoisted_1, _cache[0] || (_cache[0] = [
|
|
13
|
+
createElementVNode("path", { d: "M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 00203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z" }, null, -1)
|
|
14
|
+
]));
|
|
15
|
+
}
|
|
16
|
+
const delIcon = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
17
|
+
export {
|
|
18
|
+
delIcon as d
|
|
19
|
+
};
|
package/dist/js/dialog/dialog.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { defineComponent, computed, watch, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives,
|
|
1
|
+
import { defineComponent, computed, watch, openBlock, createBlock, Teleport, createVNode, Transition, withCtx, withDirectives, createElementBlock, withModifiers, createElementVNode, normalizeClass, normalizeStyle, toDisplayString, createCommentVNode, renderSlot, unref } from "vue";
|
|
2
|
+
import { c as createEscapeDirective, C as CloseIcon } from "../index/index.js";
|
|
2
3
|
const _hoisted_1 = {
|
|
3
4
|
key: 0,
|
|
4
|
-
class: "
|
|
5
|
+
class: "flex w-full justify-between p-2"
|
|
5
6
|
};
|
|
7
|
+
const defaultWidth = "500px";
|
|
6
8
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
9
|
__name: "dialog",
|
|
8
10
|
props: {
|
|
@@ -29,21 +31,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
29
31
|
}
|
|
30
32
|
});
|
|
31
33
|
const selfwidth = computed(() => {
|
|
32
|
-
if (props.width)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
return "unset";
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
return "unset";
|
|
34
|
+
if (!props.width)
|
|
35
|
+
return defaultWidth;
|
|
36
|
+
if (typeof props.width === "number") {
|
|
37
|
+
return `${props.width}px`;
|
|
38
|
+
}
|
|
39
|
+
if (typeof props.width === "string") {
|
|
40
|
+
const validUnit = /^(?:\d+(?:\.\d+)?)(?:px|%|em|rem|vw|vh)$/.test(props.width);
|
|
41
|
+
return validUnit ? props.width : `${props.width}px`;
|
|
46
42
|
}
|
|
43
|
+
return defaultWidth;
|
|
47
44
|
});
|
|
48
45
|
const UpdateVisible = __emit;
|
|
49
46
|
const dialogHidden = (cancelflag) => {
|
|
@@ -51,88 +48,75 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
51
48
|
UpdateVisible("update:visible", false);
|
|
52
49
|
}
|
|
53
50
|
};
|
|
54
|
-
const
|
|
51
|
+
const closeDialogHandle = () => {
|
|
55
52
|
if (props.beforeHidden) {
|
|
56
53
|
props.beforeHidden(dialogHidden);
|
|
57
54
|
} else {
|
|
58
55
|
dialogHidden();
|
|
59
56
|
}
|
|
60
|
-
return e;
|
|
61
57
|
};
|
|
62
|
-
const
|
|
58
|
+
const whiteSpaceClick = () => {
|
|
63
59
|
if (props.bodyClickAble) {
|
|
64
|
-
|
|
60
|
+
closeDialogHandle();
|
|
65
61
|
}
|
|
66
|
-
return e;
|
|
67
62
|
};
|
|
68
63
|
watch(
|
|
69
64
|
() => props.visible,
|
|
70
65
|
(val) => {
|
|
71
66
|
if (props.lockScroll) {
|
|
72
67
|
if (val === true) {
|
|
73
|
-
document.body.classList.add("
|
|
68
|
+
document.body.classList.add("overflow-hidden");
|
|
74
69
|
} else {
|
|
75
|
-
document.body.classList.remove("
|
|
70
|
+
document.body.classList.remove("overflow-hidden");
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
}
|
|
79
74
|
);
|
|
75
|
+
const vEsc = createEscapeDirective({
|
|
76
|
+
onEscape: () => {
|
|
77
|
+
closeDialogHandle();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
80
|
return (_ctx, _cache) => {
|
|
81
|
-
return openBlock(), createBlock(Teleport, {
|
|
82
|
-
|
|
83
|
-
disabled: !_ctx.visible
|
|
84
|
-
}, [
|
|
85
|
-
createVNode(Transition, { name: "opecity" }, {
|
|
81
|
+
return openBlock(), createBlock(Teleport, { to: "body" }, [
|
|
82
|
+
createVNode(Transition, { name: "fade" }, {
|
|
86
83
|
default: withCtx(() => [
|
|
87
|
-
withDirectives(
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
_ctx.visible ? withDirectives((openBlock(), createElementBlock("div", {
|
|
85
|
+
key: 0,
|
|
86
|
+
class: "fixed top-0 right-0 left-0 bottom-0 bg-black bg-opacity-30 text-sm z-1000",
|
|
87
|
+
onClick: withModifiers(whiteSpaceClick, ["self"])
|
|
90
88
|
}, [
|
|
91
89
|
createElementVNode("div", {
|
|
92
|
-
class: normalizeClass(["
|
|
90
|
+
class: normalizeClass(["divide-y divide-gray-300 rounded drop-shadow mt-[20vh] mx-auto", { "w-96": !hasselfwidth.value, "bg-white": !_ctx.isDiy }]),
|
|
93
91
|
style: normalizeStyle({ width: selfwidth.value })
|
|
94
92
|
}, [
|
|
95
93
|
showdefaultHand.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
96
94
|
createElementVNode("span", null, toDisplayString(_ctx.title), 1),
|
|
97
95
|
createElementVNode("button", {
|
|
98
96
|
type: "button",
|
|
99
|
-
onClick:
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
width: "24",
|
|
105
|
-
height: "24",
|
|
106
|
-
viewBox: "0 0 24 24",
|
|
107
|
-
fill: "none"
|
|
108
|
-
}, [
|
|
109
|
-
createElementVNode("g", null, [
|
|
110
|
-
createElementVNode("path", {
|
|
111
|
-
"fill-rule": "evenodd",
|
|
112
|
-
"clip-rule": "evenodd",
|
|
113
|
-
d: "M16.7782 7.22943C16.4824 6.93364 16.0046 6.93364 15.7088 7.22943L12 10.9306L8.29124 7.22184C7.99545 6.92605 7.51763 6.92605 7.22184 7.22184C6.92605 7.51763 6.92605 7.99545 7.22184 8.29124L10.9306 12L7.22184 15.7088C6.92605 16.0046 6.92605 16.4824 7.22184 16.7782C7.51763 17.0739 7.99545 17.0739 8.29124 16.7782L12 13.0694L15.7088 16.7782C16.0046 17.0739 16.4824 17.0739 16.7782 16.7782C17.0739 16.4824 17.0739 16.0046 16.7782 15.7088L13.0694 12L16.7782 8.29124C17.0664 8.00303 17.0664 7.51763 16.7782 7.22943Z",
|
|
114
|
-
fill: "inherit"
|
|
115
|
-
})
|
|
116
|
-
])
|
|
117
|
-
], -1)
|
|
118
|
-
]))
|
|
97
|
+
onClick: closeDialogHandle,
|
|
98
|
+
class: "appearance-none fill-gray-600"
|
|
99
|
+
}, [
|
|
100
|
+
createVNode(CloseIcon)
|
|
101
|
+
])
|
|
119
102
|
])) : createCommentVNode("", true),
|
|
120
103
|
createElementVNode("div", {
|
|
121
|
-
class: normalizeClass({ "
|
|
104
|
+
class: normalizeClass({ "p-2": !_ctx.isDiy })
|
|
122
105
|
}, [
|
|
123
106
|
renderSlot(_ctx.$slots, "default")
|
|
124
107
|
], 2)
|
|
125
108
|
], 6)
|
|
126
|
-
]
|
|
127
|
-
[
|
|
128
|
-
])
|
|
109
|
+
])), [
|
|
110
|
+
[unref(vEsc)]
|
|
111
|
+
]) : createCommentVNode("", true)
|
|
129
112
|
]),
|
|
130
113
|
_: 3
|
|
131
114
|
})
|
|
132
|
-
]
|
|
115
|
+
]);
|
|
133
116
|
};
|
|
134
117
|
}
|
|
135
118
|
});
|
|
119
|
+
const dialog_vue_vue_type_style_index_0_lang = "";
|
|
136
120
|
export {
|
|
137
121
|
_sfc_main as default
|
|
138
122
|
};
|
package/dist/js/form/form.js
CHANGED
|
@@ -1,57 +1,45 @@
|
|
|
1
|
-
import { defineComponent, readonly, ref, provide, openBlock, createElementBlock, renderSlot } from "vue";
|
|
1
|
+
import { defineComponent, readonly, reactive, ref, provide, toRef, openBlock, createElementBlock, renderSlot } from "vue";
|
|
2
2
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3
3
|
__name: "form",
|
|
4
4
|
props: {
|
|
5
5
|
rule: {},
|
|
6
6
|
model: {},
|
|
7
|
-
inline: { type: Boolean, default:
|
|
7
|
+
inline: { type: Boolean, default: false }
|
|
8
8
|
},
|
|
9
9
|
setup(__props, { expose: __expose }) {
|
|
10
10
|
const props = __props;
|
|
11
11
|
const staticModel = readonly(Object.assign({}, props.model));
|
|
12
|
-
const
|
|
13
|
-
const pushCheck = (name, fc) => {
|
|
14
|
-
if (name == null)
|
|
15
|
-
return;
|
|
16
|
-
checkList.value.push({
|
|
17
|
-
name,
|
|
18
|
-
fc
|
|
19
|
-
});
|
|
20
|
-
};
|
|
12
|
+
const ruleCheck = reactive(/* @__PURE__ */ new Map());
|
|
21
13
|
const clearList = ref([]);
|
|
22
|
-
const pushClear = (i) => {
|
|
23
|
-
clearList.value.push(i);
|
|
24
|
-
};
|
|
25
14
|
const validate = async (callBack) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
console.warn(msg);
|
|
32
|
-
}
|
|
15
|
+
try {
|
|
16
|
+
const rulePromises = Array.from(ruleCheck.values()).map((rule) => {
|
|
17
|
+
return new Promise(
|
|
18
|
+
(resolve) => rule((result) => resolve(result === true))
|
|
19
|
+
);
|
|
33
20
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
const results = await Promise.all(rulePromises);
|
|
22
|
+
const passedCount = results.filter(Boolean).length;
|
|
23
|
+
const isValid = passedCount === ruleCheck.size;
|
|
24
|
+
callBack(isValid);
|
|
25
|
+
return isValid;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error("Validation error:", error);
|
|
38
28
|
callBack(false);
|
|
29
|
+
return false;
|
|
39
30
|
}
|
|
40
31
|
};
|
|
41
32
|
const validateField = async (propname, callBack) => {
|
|
42
33
|
if (!propname) {
|
|
43
34
|
throw new Error("prop参数为空");
|
|
44
35
|
} else {
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
36
|
+
const checkFc = ruleCheck.get(propname);
|
|
37
|
+
if (!checkFc) {
|
|
47
38
|
throw new Error("没有匹配的检查函数");
|
|
48
39
|
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
callBack(msg);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
40
|
+
await checkFc((msg) => {
|
|
41
|
+
callBack(msg);
|
|
42
|
+
});
|
|
55
43
|
}
|
|
56
44
|
}
|
|
57
45
|
};
|
|
@@ -70,11 +58,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
70
58
|
validateField,
|
|
71
59
|
resetField
|
|
72
60
|
});
|
|
73
|
-
provide("
|
|
74
|
-
provide("
|
|
75
|
-
provide("
|
|
76
|
-
provide("
|
|
77
|
-
|
|
61
|
+
provide("_ParentRules_", props.rule);
|
|
62
|
+
provide("_ParentModels_", readonly(toRef(props, "model")));
|
|
63
|
+
provide("_ParentLineStatus_", toRef(props, "inline"));
|
|
64
|
+
provide("_formRuleCheck_", (item, checkFunction) => {
|
|
65
|
+
ruleCheck.set(item, checkFunction);
|
|
66
|
+
});
|
|
67
|
+
provide("_validateClear_", (i) => {
|
|
68
|
+
clearList.value.push(i);
|
|
69
|
+
});
|
|
78
70
|
return (_ctx, _cache) => {
|
|
79
71
|
return openBlock(), createElementBlock("form", null, [
|
|
80
72
|
renderSlot(_ctx.$slots, "default")
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { defineComponent, inject,
|
|
2
|
-
const _hoisted_1 = { class: "
|
|
3
|
-
const _hoisted_2 = {
|
|
4
|
-
const _hoisted_3 = {
|
|
1
|
+
import { defineComponent, inject, ref, computed, provide, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, renderSlot, createVNode, Transition, withCtx, createCommentVNode } from "vue";
|
|
2
|
+
const _hoisted_1 = { class: "relative flex-1 items-center h-full leading-8 flex" };
|
|
3
|
+
const _hoisted_2 = {
|
|
5
4
|
key: 0,
|
|
6
|
-
class: "
|
|
5
|
+
class: "absolute -bottom-5 left-0 text-xs text-red-600"
|
|
7
6
|
};
|
|
8
7
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
9
8
|
__name: "formlabel",
|
|
@@ -15,23 +14,86 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
15
14
|
},
|
|
16
15
|
setup(__props, { expose: __expose }) {
|
|
17
16
|
const props = __props;
|
|
18
|
-
const Rules = inject("
|
|
19
|
-
const Model = inject("
|
|
20
|
-
const sendCheck = inject("
|
|
21
|
-
const sendClear = inject("
|
|
22
|
-
const
|
|
17
|
+
const Rules = inject("_ParentRules_", {});
|
|
18
|
+
const Model = inject("_ParentModels_", ref());
|
|
19
|
+
const sendCheck = inject("_formRuleCheck_", () => null);
|
|
20
|
+
const sendClear = inject("_validateClear_", () => null);
|
|
21
|
+
const parentLineStatus = inject("_ParentLineStatus_", ref());
|
|
22
|
+
const getThisRule = computed(() => {
|
|
23
|
+
if (!props.prop) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
return Rules[props.prop] || [];
|
|
27
|
+
});
|
|
23
28
|
const isInline = computed(() => {
|
|
24
|
-
if (props.inline
|
|
29
|
+
if (props.inline !== void 0) {
|
|
25
30
|
return props.inline;
|
|
26
31
|
} else {
|
|
27
|
-
return
|
|
32
|
+
return parentLineStatus.value;
|
|
28
33
|
}
|
|
29
34
|
});
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
const checkPropHandle = async (callBack, eventName) => {
|
|
36
|
+
if (!props.prop)
|
|
37
|
+
return;
|
|
38
|
+
const setErrHandle = (errword) => {
|
|
39
|
+
if (errword)
|
|
40
|
+
tip.value = errword;
|
|
41
|
+
showTip.value = true;
|
|
42
|
+
callBack && callBack(false);
|
|
43
|
+
};
|
|
44
|
+
const aimdata = Model.value[props.prop];
|
|
45
|
+
const filterRule = getThisRule.value.filter(
|
|
46
|
+
(rule) => !eventName || rule.trigger === eventName
|
|
47
|
+
);
|
|
48
|
+
let i = 0;
|
|
49
|
+
for (; i < filterRule.length; i++) {
|
|
50
|
+
const { type, min, max, message, validator } = filterRule[i];
|
|
51
|
+
tip.value = message || "";
|
|
52
|
+
if (min || max) {
|
|
53
|
+
const toNum = Number(aimdata);
|
|
54
|
+
if (isNaN(toNum)) {
|
|
55
|
+
setErrHandle("请输入数字");
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (min && toNum < min || max && toNum > max) {
|
|
59
|
+
setErrHandle();
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (type) {
|
|
64
|
+
if (!validateType(aimdata, type)) {
|
|
65
|
+
setErrHandle();
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (validator) {
|
|
70
|
+
const result = await FunctionToPromise(validator, aimdata);
|
|
71
|
+
if (result !== null) {
|
|
72
|
+
setErrHandle();
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (aimdata === null || aimdata === "" || aimdata === void 0) {
|
|
77
|
+
setErrHandle();
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (i === getThisRule.value.length) {
|
|
82
|
+
showTip.value = false;
|
|
83
|
+
tip.value = "";
|
|
84
|
+
callBack && callBack(true);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const validateType = (value, type) => {
|
|
88
|
+
if (type === "array")
|
|
89
|
+
return Array.isArray(value);
|
|
90
|
+
return typeof value === type;
|
|
91
|
+
};
|
|
92
|
+
const tip = ref("");
|
|
93
|
+
const showTip = ref(false);
|
|
33
94
|
const resetField = () => {
|
|
34
|
-
tip.value =
|
|
95
|
+
tip.value = "";
|
|
96
|
+
showTip.value = false;
|
|
35
97
|
};
|
|
36
98
|
const FunctionToPromise = (callBack, receiveData) => {
|
|
37
99
|
return new Promise((resolve) => {
|
|
@@ -40,125 +102,32 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
40
102
|
});
|
|
41
103
|
});
|
|
42
104
|
};
|
|
43
|
-
|
|
44
|
-
if (thisRules instanceof Array) {
|
|
45
|
-
for (let i = 0; i < thisRules.length; i++) {
|
|
46
|
-
const { type, trigger, min, max, message, validator } = thisRules[i];
|
|
47
|
-
if (trigger === "blur" && eventname === "blurevent" || trigger === "input" && eventname === "inputevent" || trigger === "change" && eventname === "changeevent") {
|
|
48
|
-
if (min || max) {
|
|
49
|
-
if (isNaN(Number(receiveData))) {
|
|
50
|
-
tip.value = "请输入数字";
|
|
51
|
-
break;
|
|
52
|
-
} else {
|
|
53
|
-
if (min && Number(receiveData) < min || max && Number(receiveData) > max) {
|
|
54
|
-
tip.value = message;
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} else if (validator) {
|
|
59
|
-
const result = await FunctionToPromise(validator, receiveData);
|
|
60
|
-
tip.value = result;
|
|
61
|
-
if (result != null) {
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
} else if (type == "array") {
|
|
65
|
-
if (!(receiveData instanceof Array)) {
|
|
66
|
-
tip.value = message;
|
|
67
|
-
break;
|
|
68
|
-
} else if (receiveData.length === 0) {
|
|
69
|
-
tip.value = message;
|
|
70
|
-
break;
|
|
71
|
-
} else {
|
|
72
|
-
tip.value = null;
|
|
73
|
-
}
|
|
74
|
-
} else if (receiveData == null || receiveData == "") {
|
|
75
|
-
tip.value = message;
|
|
76
|
-
break;
|
|
77
|
-
} else {
|
|
78
|
-
tip.value = null;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const inputHandle = (data) => mixHandle(data, "inputevent");
|
|
85
|
-
const blurHandle = (data) => mixHandle(data, "blurevent");
|
|
86
|
-
const changeHandle = (data) => mixHandle(data, "changeevent");
|
|
87
|
-
const validateLabel = async (callBack) => {
|
|
88
|
-
let flag = 0;
|
|
89
|
-
const data = Model[props.prop];
|
|
90
|
-
if (thisRules instanceof Array) {
|
|
91
|
-
for (let i = 0; i < thisRules.length; i++) {
|
|
92
|
-
const { type, min, max, message, validator } = thisRules[i];
|
|
93
|
-
if (min || max) {
|
|
94
|
-
if (isNaN(Number(data))) {
|
|
95
|
-
callBack("请输入数字");
|
|
96
|
-
flag += 1;
|
|
97
|
-
break;
|
|
98
|
-
} else {
|
|
99
|
-
if (max && Number(data) > max || min && Number(data) < min) {
|
|
100
|
-
tip.value = message;
|
|
101
|
-
callBack(message);
|
|
102
|
-
flag += 1;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
} else if (validator) {
|
|
107
|
-
const result = await FunctionToPromise(validator, data);
|
|
108
|
-
tip.value = result;
|
|
109
|
-
if (result != null) {
|
|
110
|
-
callBack(result);
|
|
111
|
-
flag += 1;
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
} else if (type == "array") {
|
|
115
|
-
if (!(data instanceof Array)) {
|
|
116
|
-
tip.value = message;
|
|
117
|
-
callBack(message);
|
|
118
|
-
flag += 1;
|
|
119
|
-
break;
|
|
120
|
-
} else if (data.length === 0) {
|
|
121
|
-
tip.value = message;
|
|
122
|
-
callBack(message);
|
|
123
|
-
flag += 1;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
} else if (data == null || data == "") {
|
|
127
|
-
tip.value = message;
|
|
128
|
-
callBack(message);
|
|
129
|
-
flag += 1;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
if (flag === 0) {
|
|
135
|
-
tip.value = null;
|
|
136
|
-
callBack();
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
sendCheck(props.prop, validateLabel);
|
|
105
|
+
sendCheck(props.prop, checkPropHandle);
|
|
140
106
|
sendClear(resetField);
|
|
141
|
-
provide("inputHandle",
|
|
142
|
-
provide("blurHandle",
|
|
143
|
-
provide("
|
|
107
|
+
provide("inputHandle", () => checkPropHandle(void 0, "input"));
|
|
108
|
+
provide("blurHandle", () => checkPropHandle(void 0, "blur"));
|
|
109
|
+
provide("changeHandle", () => checkPropHandle(void 0, "change"));
|
|
144
110
|
__expose({
|
|
145
|
-
validateLabel
|
|
111
|
+
validateLabel: checkPropHandle
|
|
146
112
|
});
|
|
147
113
|
return (_ctx, _cache) => {
|
|
148
|
-
return openBlock(), createElementBlock("div",
|
|
114
|
+
return openBlock(), createElementBlock("div", {
|
|
115
|
+
class: normalizeClass(["mb-5", { "inline-flex mr-5": isInline.value, "flex flex-col": !isInline.value }])
|
|
116
|
+
}, [
|
|
149
117
|
createElementVNode("div", {
|
|
150
|
-
class:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
118
|
+
class: "text-sm flex items-center",
|
|
119
|
+
style: normalizeStyle({ width: `${_ctx.width}px` })
|
|
120
|
+
}, toDisplayString(_ctx.label), 5),
|
|
121
|
+
createElementVNode("div", _hoisted_1, [
|
|
122
|
+
renderSlot(_ctx.$slots, "default"),
|
|
123
|
+
createVNode(Transition, { name: "opecity" }, {
|
|
124
|
+
default: withCtx(() => [
|
|
125
|
+
showTip.value ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(tip.value), 1)) : createCommentVNode("", true)
|
|
126
|
+
]),
|
|
127
|
+
_: 1
|
|
128
|
+
})
|
|
129
|
+
])
|
|
130
|
+
], 2);
|
|
162
131
|
};
|
|
163
132
|
}
|
|
164
133
|
});
|