tms-vue3-ui
Version:
Vue3基础UI库,提供JSONSchema编辑器,支持基于JSONSchema生成表单。
1,491 lines • 468 kB
JavaScript
var Be = Object.defineProperty;
var Fe = (e, t, r) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var V = (e, t, r) => Fe(e, typeof t != "symbol" ? t + "" : t, r);
import { nextTick, createVNode, mergeProps, h, resolveComponent, defineComponent, ref, reactive, onMounted, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, renderList, withDirectives, vModelDynamic, createCommentVNode, vModelText, createTextVNode, toDisplayString, createApp, toRaw, withCtx, createBlock, computed, watch, resolveDynamicComponent, renderSlot, getCurrentInstance } from "vue";
function install$5(e) {
e.component("tms-frame", {
props: {
display: {
type: Object,
default: () => ({
header: !0,
footer: !0,
left: !0,
right: !0
})
},
displaySm: {
type: Object,
default: () => ({
header: !0,
footer: !0,
left: !1,
right: !1
})
},
backColor: {
type: String,
default: "#f0f3f6"
},
headerColor: {
type: String,
default: "#f0f3f6"
},
headerMinHeight: {
type: String,
default: "32px"
},
leftColor: {
type: String,
default: "#f0f3f6"
},
leftWidth: {
type: String,
default: "25%"
},
leftWidthSm: {
type: String,
default: "100%"
},
centerColor: {
type: String,
default: "#fff"
},
centerMargin: {
type: String,
default: "0 8px"
},
centerMarginSm: {
type: String,
default: ""
},
rightColor: {
type: String,
default: "#f0f3f6"
},
rightWidth: {
type: String,
default: "25%"
},
rightWidthSm: {
type: String,
default: "100%"
},
footerColor: {
type: String,
default: "#f0f3f6"
},
footerMinHeight: {
type: String,
default: "32px"
},
mainDirection: {
type: String,
default: "row"
},
mainDirectionSm: {
type: String,
default: "row"
}
},
methods: {
adjust() {
let t = this.$props, r = this.$el.querySelector(".tms-frame__main");
r && (this.isSmallScreen ? (r.classList.remove(`tms-frame__main_${t.mainDirection}`), r.classList.add(`tms-frame__main_${t.mainDirectionSm}`)) : (r.classList.remove(`tms-frame__main_${t.mainDirectionSm}`), r.classList.add(`tms-frame__main_${t.mainDirection}`)));
let n = this.$el.querySelector(".tms-frame__main__center");
n && (this.isSmallScreen ? n.style.margin = t.centerMarginSm : n.style.margin = t.centerMargin);
let i = this.$el.querySelector(".tms-frame__main__left");
i && (i.style.width = this.isSmallScreen ? t.leftWidthSm : t.leftWidth);
let s = this.$el.querySelector(".tms-frame__main__right");
s && (s.style.width = this.isSmallScreen ? t.rightWidthSm : t.rightWidth);
}
},
data: function() {
return {
isSmallScreen: !1
};
},
computed: {
responsiveDisplay: function() {
return this.isSmallScreen ? this.displaySm : this.display;
}
},
mounted() {
this.isSmallScreen = window.screen && window.screen.width <= 768, window.addEventListener("resize", () => {
this.isSmallScreen = window.screen && window.screen.width <= 768, nextTick(() => {
this.adjust();
});
}), nextTick(() => {
this.adjust();
});
},
render() {
var c, l, d, f, o;
let t = this.$slots, r = this.$props, n = {
backgroundColor: r.headerColor
};
n.minHeight = r.headerMinHeight;
let i = {
backgroundColor: r.footerColor
};
i.minHeight = r.footerMinHeight;
let s = this.responsiveDisplay;
return createVNode("div", mergeProps({
class: "tms-frame"
}, {
style: {
backgroundColor: r.backColor
}
}), [s.header ? createVNode("header", mergeProps({
class: "tms-frame__header"
}, {
style: n
}), [(c = t.header) == null ? void 0 : c.call(t)]) : "", createVNode("main", {
class: "tms-frame__main"
}, [s.left ? createVNode("section", mergeProps({
class: "tms-frame__main__left"
}, {
style: {
backgroundColor: r.leftColor,
width: r.leftWidth
}
}), [(l = t.left) == null ? void 0 : l.call(t)]) : "", createVNode("section", mergeProps({
class: "tms-frame__main__center"
}, {
style: {
backgroundColor: r.centerColor,
margin: r.centerMargin
}
}), [(d = t.center) == null ? void 0 : d.call(t)]), s.right ? createVNode("section", mergeProps({
class: "tms-frame__main__right"
}, {
style: {
backgroundColor: r.rightColor,
width: r.rightWidth
}
}), [(f = t.right) == null ? void 0 : f.call(t)]) : ""]), s.footer ? createVNode("footer", mergeProps({
class: "tms-frame__footer"
}, {
style: i
}), [(o = t.footer) == null ? void 0 : o.call(t)]) : ""]);
}
});
}
function install$4(e) {
e.component("tms-text", {
props: {
lines: {
type: Number
},
linesSm: {
type: Number
}
},
render() {
var n;
let t = this.$slots, r = ["tms-text"];
return typeof this.lines == "number" && this.lines > 0 && r.push(`tms-text_lines_${this.lines}`), typeof this.linesSm == "number" && this.linesSm > 0 && r.push(`tms-text_lines-sm_${this.linesSm}`), createVNode("div", {
class: r
}, [(n = t.default) == null ? void 0 : n.call(t)]);
}
});
}
function addStyleClass(e, t, r) {
return e[t] === void 0 ? e[t] = [r] : Array.isArray(e[t]) ? e[t].includes(r) || e[t].push(r) : typeof e[t] == "object" ? e[t][r] = !0 : typeof e[t] == "string" && (new RegExp(r).test(e[t]) || (e[t] += ` ${r}`)), e;
}
function install$3(e) {
e.component("tms-flex", {
props: {
direction: { type: String, default: "row" },
alignItems: { type: String },
elasticItems: { type: Array },
gap: { type: Number, default: 2 }
},
render() {
var i, s;
let t = ["tms-flex"];
t.push(
this.direction === "column" ? "tms-flex_column" : this.direction === "row-reverse" ? "tms-flex_row-reverse" : "tms-flex_row"
), t.push(`tms-flex_gap_${this.gap}`);
const r = this.alignItems ? this.alignItems : this.direction === "column" ? "stretch" : "flex-start", n = (s = (i = this.$slots).default) == null ? void 0 : s.call(i);
return n != null && n.length && n.forEach((c, l) => {
typeof c.type == "string" || typeof c.type == "object" ? (c.props ?? (c.props = {}), addStyleClass(c.props, "class", "tms-flex__item"), this.elasticItems && this.elasticItems.length && this.elasticItems.includes(l) && addStyleClass(c.props, "class", "tms-flex__item_elastic")) : typeof c.type == "symbol" ? typeof c.children.forEach == "function" ? c.children.forEach((d, f) => {
d.props ?? (d.props = {}), addStyleClass(d.props, "class", "tms-flex__item"), this.elasticItems && this.elasticItems.length && this.elasticItems.includes(f) && addStyleClass(d.props, "class", "tms-flex__item_elastic");
}) : console.warn("不支持的vnode.children类型", c.children) : console.warn(`不支持的vnode.type=${c.type}`, c);
}), h("div", { class: t, style: { alignItems: r } }, n);
}
});
}
function index(e) {
e.component("tms-card", {
props: {
thumb: {
type: [String, Boolean]
},
title: {
type: String
},
desc: {
type: String
},
gap: {
type: Number,
default: 2
},
gapMain: {
type: Number,
default: 2
},
gapContent: {
type: Number,
default: 2
},
backColor: {
type: String,
default: "#ffffff"
},
descColor: {
type: String,
default: "#666666"
},
url: {
type: String
},
to: {
type: Object
}
},
render() {
const t = this.$slots, r = this.$props, {
title: n,
desc: i,
backColor: s,
descColor: c,
to: l,
url: d
} = r, f = r.thumb === "" ? null : r.thumb, o = this;
function m() {
d ? location.href = d : l && o.$parent && o.$parent.$router && o.$parent.$router.push(l);
}
return createVNode("div", mergeProps({
class: "tms-card",
onClick: m
}, {
style: {
backgroundColor: s
}
}), [createVNode(resolveComponent("tms-flex"), {
direction: "column",
gap: this.gap
}, {
default: () => {
var p;
return [t.header ? createVNode("header", null, [t.header()]) : "", createVNode("main", null, [createVNode(resolveComponent("tms-flex"), {
elasticItems: [1],
gap: this.gapMain
}, {
default: () => [f === !1 ? "" : createVNode("div", {
class: "tms-card__thumb"
}, [t.thumb ? t.thumb() : createVNode("img", {
src: f
}, null)]), createVNode("div", {
class: "tms-card__content"
}, [createVNode(resolveComponent("tms-flex"), {
direction: "column",
elasticItems: [1],
gap: this.gapContent
}, {
default: () => {
var u;
return [createVNode("div", {
class: "tms-card__title"
}, [t.title ? t.title() : n]), createVNode("div", mergeProps({
class: "tms-card__desc"
}, {
style: {
color: c
}
}), [t.desc ? t.desc() : i]), t.bottom ? createVNode("div", {
class: "tms-card__bottom"
}, [(u = t.bottom) == null ? void 0 : u.call(t)]) : ""];
}
})])]
})]), t.footer ? createVNode("footer", null, [(p = t.footer) == null ? void 0 : p.call(t)]) : ""];
}
})]);
}
});
}
const _hoisted_1$5 = ["placeholder", "type", "onUpdate:modelValue"], _hoisted_2$4 = ["onClick"], _hoisted_3$4 = {
key: 0,
class: "tvu-login__captcha"
}, _hoisted_4$4 = ["placeholder"], _hoisted_5$4 = {
key: 1,
class: "tvu-login__error--tip"
}, _hoisted_6$3 = {
key: 2,
class: "tvu-login__button"
}, _hoisted_7$3 = {
key: 3,
class: "tvu-login__tip"
}, _hoisted_8$3 = {
key: 0,
class: "tvu-login__modal"
}, _sfc_main$9 = /* @__PURE__ */ defineComponent({
__name: "Login",
props: {
schema: Array,
loginTip: Object,
errorTip: { type: Boolean, default: !0 },
fnCaptcha: Function,
fnLogin: Function,
onSuccess: { type: Function, default: () => {
} },
onFail: { type: Function, default: () => {
} },
asDialog: { type: Boolean, default: !1 },
onClose: { type: Function },
closeAfterSuccess: { type: Boolean, default: !1 }
},
setup(e) {
const t = e, r = ref(null), n = ref(null);
let {
schema: i,
loginTip: s,
fnLogin: c,
fnCaptcha: l,
onSuccess: d,
onFail: f,
errorTip: o,
asDialog: m,
onClose: p,
closeAfterSuccess: u
} = t;
const a = reactive({}), g = ref(), v = ref([]), y = reactive({}), b = ref();
i == null || i.forEach((S) => {
S.type === "captcha" ? b.value = S : (y[S.key] = S.type === "password" ? "password" : "text", v.value.push(S));
});
const k = () => {
b.value && (a[b.value.key] = "", n != null && n.value && typeof l == "function" && l().then((S) => {
let { code: E, captcha: $ } = S;
n.value.innerHTML = E !== 0 ? "获取失败" : $;
}));
}, _ = (S) => {
y[S.key] = y[S.key] === "password" ? "text" : "password";
}, C = () => {
if (g.value = "", i && i.length) {
if (i.map(($) => $.key).filter(($) => !a[$]).length)
return g.value = "缺少必填信息", f({ msg: "缺少必填信息" });
typeof c == "function" && c(a).then(($) => {
let { code: N, msg: O } = $;
if (N !== 0)
return k(), g.value = O || "登录失败", f($);
d($), u && w();
});
}
}, w = () => {
var S, E;
typeof p == "function" ? p() : (E = (S = r.value.parentElement) == null ? void 0 : S.parentElement) == null || E.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => {
k();
});
}), (S, E) => {
var $;
return openBlock(), createElementBlock(
Fragment,
null,
[
createElementVNode(
"div",
{
ref_key: "el",
ref: r,
class: normalizeClass(["tvu-login__form", { "tvu-login__form--modal": unref(m) }])
},
[
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(v.value, (N, O) => (openBlock(), createElementBlock("div", {
class: "tvu-login__input",
key: O
}, [
withDirectives(createElementVNode("input", {
placeholder: N.placeholder,
type: y[N.key],
"onUpdate:modelValue": (P) => a[N.key] = P,
required: ""
}, null, 8, _hoisted_1$5), [
[vModelDynamic, a[N.key]]
]),
N.type === "password" ? (openBlock(), createElementBlock("span", {
key: 0,
onClick: (P) => _(N),
class: normalizeClass({
"tvu-login__password--close": y[N.key] === "password",
"tvu-login__password--open": y[N.key] === "text"
})
}, null, 10, _hoisted_2$4)) : createCommentVNode("v-if", !0)
]))),
128
/* KEYED_FRAGMENT */
)),
b.value ? (openBlock(), createElementBlock("div", _hoisted_3$4, [
withDirectives(createElementVNode("input", {
placeholder: b.value.placeholder,
"onUpdate:modelValue": E[0] || (E[0] = (N) => a[b.value.key] = N),
required: ""
}, null, 8, _hoisted_4$4), [
[vModelText, a[b.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", { onClick: k })
])) : createCommentVNode("v-if", !0),
unref(o) && g.value ? (openBlock(), createElementBlock("div", _hoisted_5$4, [
E[1] || (E[1] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(g.value),
1
/* TEXT */
)
])) : createCommentVNode("v-if", !0),
createElementVNode("div", { class: "tvu-login__button" }, [
createElementVNode("button", { onClick: C }, "登录")
]),
unref(m) ? (openBlock(), createElementBlock("div", _hoisted_6$3, [
createElementVNode("button", { onClick: w }, "关闭")
])) : createCommentVNode("v-if", !0),
unref(s) ? (openBlock(), createElementBlock(
"div",
_hoisted_7$3,
toDisplayString(($ = unref(s)) == null ? void 0 : $.text),
1
/* TEXT */
)) : createCommentVNode("v-if", !0)
],
2
/* CLASS */
),
unref(m) ? (openBlock(), createElementBlock("div", _hoisted_8$3)) : createCommentVNode("v-if", !0)
],
64
/* STABLE_FRAGMENT */
);
};
}
});
function showAsDialog$2(e) {
const t = document.createElement("div");
document.body.appendChild(t);
let r = createApp(_sfc_main$9, {
asDialog: !0,
...e,
onClose: () => {
r.unmount(), document.body.removeChild(t);
}
});
r.mount(t);
}
function install$2(e) {
e.component("tms-login", _sfc_main$9);
}
_sfc_main$9.install = install$2;
_sfc_main$9.open = showAsDialog$2;
const _hoisted_1$4 = ["placeholder", "type", "onUpdate:modelValue"], _hoisted_2$3 = ["onClick"], _hoisted_3$3 = {
key: 0,
class: "tvu-register__captcha"
}, _hoisted_4$3 = ["placeholder"], _hoisted_5$3 = {
key: 1,
class: "tvu-register__error--tip"
}, _hoisted_6$2 = {
key: 2,
class: "tvu-register__button"
}, _hoisted_7$2 = {
key: 3,
class: "tvu-register__tip"
}, _hoisted_8$2 = {
key: 0,
class: "tvu-register__modal"
}, _sfc_main$8 = /* @__PURE__ */ defineComponent({
__name: "Register",
props: {
schema: Array,
registerTip: Object,
errorTip: { type: Boolean, default: !1 },
fnCaptcha: Function,
fnRegister: Function,
onSuccess: { type: Function, default: () => {
} },
onFail: { type: Function, default: () => {
} },
asDialog: { type: Boolean, default: !1 },
onClose: { type: Function },
closeAfterSuccess: { type: Boolean, default: !1 }
},
setup(e) {
const t = e, r = ref(null), n = ref(null);
let { schema: i, registerTip: s, fnRegister: c, fnCaptcha: l, onSuccess: d, onFail: f, errorTip: o, asDialog: m, onClose: p } = t;
const u = reactive({}), a = ref(null);
let g = reactive({ password: !1, password2: !1 });
const v = ref(), y = ref([]), b = ref();
i && i.length && i.forEach((S) => {
S.type === "captcha" ? b.value = S : y.value.push(S);
});
const k = () => {
u[b.value.key] = "", n != null && n.value && typeof l == "function" && l().then((S) => {
let { code: E, captcha: $, msg: N } = S;
E !== 0 ? (v.value = N || "获取验证码失败", n.value.innerHTML = "获取失败") : (v.value = "", n.value.innerHTML = $);
});
}, _ = (S) => {
g[S] = !g[S];
const E = toRaw(a.value);
S == "password" ? g[S] ? E[0].previousSibling.type = "text" : E[0].previousSibling.type = "password" : g[S] ? E[1].previousSibling.type = "text" : E[1].previousSibling.type = "password";
}, C = () => {
if (Array.isArray(i) && i.length) {
if (i.map(($) => $.key).filter(($) => !u[$]).length)
return v.value = "缺少必填信息", f({ msg: "缺少必填信息" });
typeof c == "function" && c(u).then(($) => {
let { code: N, msg: O } = $;
if (N !== 0)
return k(), v.value = O || "登录失败", f($);
v.value = "", d($), closeAfterSuccess && w();
});
}
}, w = () => {
var S, E;
typeof p == "function" ? p() : (E = (S = r.value.parentElement) == null ? void 0 : S.parentElement) == null || E.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => k());
}), (S, E) => {
var $;
return openBlock(), createElementBlock(
Fragment,
null,
[
createElementVNode(
"div",
{
ref_key: "el",
ref: r,
class: normalizeClass(["tvu-register__form", { "tvu-register__form--modal": unref(m) }])
},
[
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(y.value, (N, O) => (openBlock(), createElementBlock("div", {
class: "tvu-register__input",
key: O
}, [
withDirectives(createElementVNode("input", {
placeholder: N.placeholder,
type: N.type,
"onUpdate:modelValue": (P) => u[N.key] = P,
required: ""
}, null, 8, _hoisted_1$4), [
[vModelDynamic, u[N.key]]
]),
N.type == "password" ? (openBlock(), createElementBlock("span", {
key: 0,
ref_for: !0,
ref_key: "passwordEle",
ref: a,
onClick: (P) => _(N.key),
class: normalizeClass({ "tvu-register__password--close": !unref(g)[N.key], "tvu-register__password--open": unref(g)[N.key] })
}, null, 10, _hoisted_2$3)) : createCommentVNode("v-if", !0)
]))),
128
/* KEYED_FRAGMENT */
)),
b.value ? (openBlock(), createElementBlock("div", _hoisted_3$3, [
withDirectives(createElementVNode("input", {
placeholder: b.value.placeholder,
"onUpdate:modelValue": E[0] || (E[0] = (N) => u[b.value.key] = N),
required: ""
}, null, 8, _hoisted_4$3), [
[vModelText, u[b.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", { onClick: k })
])) : createCommentVNode("v-if", !0),
unref(o) && v.value ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
E[1] || (E[1] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(v.value),
1
/* TEXT */
)
])) : createCommentVNode("v-if", !0),
createElementVNode("div", { class: "tvu-register__button" }, [
createElementVNode("button", { onClick: C }, "注册")
]),
unref(m) ? (openBlock(), createElementBlock("div", _hoisted_6$2, [
createElementVNode("button", { onClick: w }, "关闭")
])) : createCommentVNode("v-if", !0),
unref(s) ? (openBlock(), createElementBlock(
"div",
_hoisted_7$2,
toDisplayString(($ = unref(s)) == null ? void 0 : $.text),
1
/* TEXT */
)) : createCommentVNode("v-if", !0)
],
2
/* CLASS */
),
unref(m) ? (openBlock(), createElementBlock("div", _hoisted_8$2)) : createCommentVNode("v-if", !0)
],
64
/* STABLE_FRAGMENT */
);
};
}
});
function showAsDialog$1(e) {
const t = document.createElement("div");
document.body.appendChild(t);
let r = createApp(_sfc_main$8, {
asDialog: !0,
...e,
onClose: () => {
r.unmount(), document.body.removeChild(t);
}
});
r.mount(t);
}
function install$1(e) {
e.component("tms-regiser", _sfc_main$8);
}
_sfc_main$8.install = install$1;
_sfc_main$8.open = showAsDialog$1;
const _hoisted_1$3 = ["placeholder", "type", "onUpdate:modelValue"], _hoisted_2$2 = {
key: 0,
class: "tvu-captcha__code"
}, _hoisted_3$2 = ["placeholder"], _hoisted_4$2 = {
key: 1,
class: "tvu-sms-code__code"
}, _hoisted_5$2 = ["placeholder"], _hoisted_6$1 = ["disabled"], _hoisted_7$1 = {
key: 2,
class: "tvu-sms-code__error--tip"
}, _hoisted_8$1 = { class: "tvu-sms-code__button" }, _hoisted_9$1 = {
key: 3,
class: "tvu-sms-code__button"
}, _hoisted_10$1 = {
key: 4,
class: "tvu-sms-code__tip"
}, _hoisted_11 = {
key: 0,
class: "tvu-sms-code__modal"
}, _sfc_main$7 = /* @__PURE__ */ defineComponent({
__name: "SmsCode",
props: {
schema: Array,
actionText: { default: "验证" },
smsCodeTip: Object,
errorTip: { type: Boolean, default: !0 },
fnSendCode: Function,
fnSendSmsCode: Function,
fnVerify: Function,
onSuccess: { type: Function, default: () => {
} },
onFail: { type: Function, default: () => {
} },
asDialog: { type: Boolean, default: !1 },
onClose: { type: Function },
waitInputSmsCodeTime: { type: Number, default: 60 },
closeAfterSuccess: { type: Boolean, default: !1 }
},
setup(e) {
const t = e, r = ref(null), n = ref(null), i = ref(null);
let {
schema: s,
smsCodeTip: c,
fnVerify: l,
fnSendCode: d,
fnSendSmsCode: f,
onSuccess: o,
onFail: m,
errorTip: p,
asDialog: u,
onClose: a,
waitInputSmsCodeTime: g
} = t;
const v = reactive({}), y = ref(), b = ref([]), k = ref(), _ = ref(), C = ref(!1);
s == null || s.forEach((N) => {
N.type === "smscode" ? k.value = N : N.type === "captcha" ? _.value = N : b.value.push(N);
});
const w = () => {
if (y.value = "", typeof f == "function" && k.value) {
v[k.value.key] = "", C.value = !0;
let N = g, O = setInterval(() => {
N == 0 ? (clearInterval(O), C.value = !1, i.value.innerHTML = "获取短信验证码") : (i.value.innerHTML = N + "秒后重发", N--);
}, 1e3);
f(v).then((P) => {
let { code: L, msg: j } = P;
if (L !== 0)
return y.value = j || "获取短信验证码失败", m(P);
});
}
}, S = () => {
_.value && (v[_.value.key] = "", v[k.value.key] = "", n != null && n.value && typeof d == "function" && d().then((N) => {
let { code: O, captcha: P } = N;
n.value.innerHTML = O !== 0 ? "获取失败" : P;
}));
}, E = () => {
if (y.value = "", Array.isArray(s) && s.length) {
if (s.map((P) => P.key).filter((P) => !v[P]).length)
return y.value = "缺少必填信息", m({ msg: "缺少必填信息" });
typeof l == "function" && l(v).then((P) => {
let { code: L, msg: j } = P;
if (L !== 0)
return S(), y.value = j || "验证失败", m(P);
o(P), closeAfterSuccess && $();
});
}
}, $ = () => {
var N, O;
typeof a == "function" ? a() : (O = (N = r.value.parentElement) == null ? void 0 : N.parentElement) == null || O.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => S());
}), (N, O) => {
var P;
return openBlock(), createElementBlock(
Fragment,
null,
[
createElementVNode(
"div",
{
ref_key: "el",
ref: r,
class: normalizeClass(["tvu-sms-code__form", { "tvu-sms-code__form--modal": unref(u) }])
},
[
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(b.value, (L, j) => (openBlock(), createElementBlock("div", {
class: "tvu-sms-code__input",
key: j
}, [
withDirectives(createElementVNode("input", {
placeholder: L.placeholder,
type: L.type,
"onUpdate:modelValue": (U) => v[L.key] = U,
required: ""
}, null, 8, _hoisted_1$3), [
[vModelDynamic, v[L.key]]
])
]))),
128
/* KEYED_FRAGMENT */
)),
_.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
withDirectives(createElementVNode("input", {
placeholder: _.value.placeholder,
"onUpdate:modelValue": O[0] || (O[0] = (L) => v[_.value.key] = L),
required: ""
}, null, 8, _hoisted_3$2), [
[vModelText, v[_.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", {
onClick: O[1] || (O[1] = (L) => S())
})
])) : createCommentVNode("v-if", !0),
k.value ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
withDirectives(createElementVNode("input", {
placeholder: k.value.placeholder,
"onUpdate:modelValue": O[2] || (O[2] = (L) => v[k.value.key] = L),
required: ""
}, null, 8, _hoisted_5$2), [
[vModelText, v[k.value.key]]
]),
createElementVNode("button", {
ref_key: "elSmsCode",
ref: i,
disabled: C.value,
onClick: w
}, " 获取短信验证码 ", 8, _hoisted_6$1)
])) : createCommentVNode("v-if", !0),
unref(p) && y.value ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
O[3] || (O[3] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(y.value || "error"),
1
/* TEXT */
)
])) : createCommentVNode("v-if", !0),
createElementVNode("div", _hoisted_8$1, [
createElementVNode(
"button",
{ onClick: E },
toDisplayString(e.actionText),
1
/* TEXT */
)
]),
unref(u) ? (openBlock(), createElementBlock("div", _hoisted_9$1, [
createElementVNode("button", { onClick: $ }, "关闭")
])) : createCommentVNode("v-if", !0),
unref(c) ? (openBlock(), createElementBlock(
"div",
_hoisted_10$1,
toDisplayString((P = unref(c)) == null ? void 0 : P.text),
1
/* TEXT */
)) : createCommentVNode("v-if", !0)
],
2
/* CLASS */
),
unref(u) ? (openBlock(), createElementBlock("div", _hoisted_11)) : createCommentVNode("v-if", !0)
],
64
/* STABLE_FRAGMENT */
);
};
}
});
function showAsDialog(e) {
const t = document.createElement("div");
document.body.appendChild(t);
let r = createApp(_sfc_main$7, {
asDialog: !0,
...e,
onClose: () => {
r.unmount(), document.body.removeChild(t);
}
});
r.mount(t);
}
function install(e) {
e.component("tms-sms-code", _sfc_main$7);
}
_sfc_main$7.install = install;
_sfc_main$7.open = showAsDialog;
const components$1 = {
formItem: defineComponent({
props: ["label"],
render() {
var e, t;
return h("div", {}, [
h("div", { class: ["tvu-jse__label"] }, this.label),
(t = (e = this.$slots).default) == null ? void 0 : t.call(e)
]);
}
}),
input: defineComponent({
props: ["modelValue"],
emits: ["update:modelValue"],
render() {
return h("input", {
value: this.modelValue,
class: ["tvu-input"],
onInput: (e) => {
this.$emit("update:modelValue", e.target.value);
}
});
}
}),
textarea: defineComponent({
props: ["modelValue"],
emits: ["update:modelValue"],
render() {
return h("textarea", {
value: this.modelValue,
class: ["tvu-input"],
onInput: (e) => {
this.$emit("update:modelValue", e.target.value);
}
});
}
}),
json: defineComponent({
props: ["modelValue"],
emits: ["update:modelValue"],
render() {
return h("textarea", {
value: JSON.stringify(this.modelValue, null, 2),
class: ["tvu-input"],
onInput: (e) => {
try {
let t = JSON.parse(e.target.value);
this.$emit("update:modelValue", t);
} catch {
}
}
});
}
}),
upload: defineComponent({
props: ["fileList", "uploadFile", "removeFile"],
render() {
var t, r, n;
let e = (t = this.fileList) == null ? void 0 : t.map((i) => h("div", { class: "tvu-jse__attachment" }, [
h("div", i.name),
h(
"button",
{
onClick: () => {
this.removeFile(i);
}
},
"删除文件"
)
]));
return e ?? (e = []), h("div", { class: ["tvu-jse__upload"] }, [
...e,
h(
"div",
{
onClick: () => {
const i = document.createElement("input");
i.setAttribute("type", "file"), document.body.appendChild(i), i.addEventListener("change", async (s) => {
const c = s.target;
if (c.files) {
const l = c.files[0];
this.uploadFile(l);
}
}), i.click();
}
},
(n = (r = this.$slots).default) == null ? void 0 : n.call(r)
)
]);
}
}),
checkbox: defineComponent({
props: ["label", "value", "modelValue"],
render() {
let e = {
type: "checkbox",
value: this.value,
onChange: () => {
Array.isArray(this.modelValue) ? this.modelValue.includes(this.value) ? this.modelValue.splice(this.modelValue.indexOf(this.value), 1) : this.modelValue.push(this.value) : typeof this.modelValue == "boolean" ? this.$emit("update:modelValue", !this.modelValue) : this.$emit("update:modelValue", !0);
}
};
return Array.isArray(this.modelValue) ? this.modelValue.includes(this.value) && (e.checked = !0) : this.modelValue === !0 && (e.checked = !0), h("div", { class: ["tvu-jse__checkbox"] }, [
h("div", h("input", e)),
h("div", {}, this.label)
]);
}
}),
select: defineComponent({
props: ["modelValue"],
emits: ["update:modelValue"],
render() {
var e, t;
return h(
"select",
{
value: this.modelValue,
class: ["tvu-input"],
onChange: (r) => {
this.$emit("update:modelValue", r.target.value);
}
},
(t = (e = this.$slots).default) == null ? void 0 : t.call(e)
);
}
}),
option: defineComponent({
render() {
return h("option", {});
}
}),
button: defineComponent({
render() {
var e, t;
return h(
"button",
{ class: ["tvu-button"], ...this.$attrs },
(t = (e = this.$slots).default) == null ? void 0 : t.call(e)
);
}
})
}, BuildinComponents = {
"tvu-form-item": {
...components$1.formItem
},
"tvu-input": {
...components$1.input
},
"tvu-textarea": {
...components$1.textarea
},
"tvu-json": {
...components$1.json
},
"tvu-input-number": {
...components$1.input
},
"tvu-upload": {
...components$1.upload
},
"tvu-checkbox": {
...components$1.checkbox
},
"tvu-select": {
...components$1.select
},
"tvu-option": {
...components$1.option
},
"tvu-button": {
...components$1.button
}
}, _hoisted_1$2 = { class: "tvu-jse__field__file-attrs" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
__name: "File",
props: {
formatAttrs: { type: Object, required: !0 }
},
setup(e) {
return (t, r) => {
const n = resolveComponent("tvu-input"), i = resolveComponent("tvu-form-item");
return openBlock(), createElementBlock("div", _hoisted_1$2, [
createVNode(i, {
class: "tvu-jse__field",
label: "文件类型"
}, {
default: withCtx(() => [
createVNode(n, {
modelValue: e.formatAttrs.accept,
"onUpdate:modelValue": r[0] || (r[0] = (s) => e.formatAttrs.accept = s),
placeholder: "标准格式,如'png,jpeg'"
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}),
createVNode(i, {
class: "tvu-jse__field",
label: "文件最大"
}, {
default: withCtx(() => [
createVNode(n, {
modelValue: e.formatAttrs.size,
"onUpdate:modelValue": r[1] || (r[1] = (s) => e.formatAttrs.size = s),
modelModifiers: { number: !0 },
placeholder: "请输入数字,默认以MB为单位"
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}),
createVNode(i, {
class: "tvu-jse__field",
label: "文件个数"
}, {
default: withCtx(() => [
createVNode(n, {
modelValue: e.formatAttrs.limit,
"onUpdate:modelValue": r[2] || (r[2] = (s) => e.formatAttrs.limit = s),
modelModifiers: { number: !0 },
placeholder: "请输入数字,0无意义"
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
})
]);
};
}
}), _hoisted_1$1 = { class: "tvu-jse__enum-config" }, _hoisted_2$1 = { class: "tvu-jse__enum-groups" }, _hoisted_3$1 = { class: "tvu-jse__enum-options" }, _hoisted_4$1 = { class: "tvu-jse__enum-default" }, _hoisted_5$1 = { class: "tvu-jse__enum-range" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
__name: "EnumConfig",
props: {
fieldAttrs: { type: Object, required: !0 },
fieldAttrsType: { type: String, default: "oneOf", required: !0 }
},
setup(e) {
const t = e, r = ref(t.fieldAttrs.default), n = () => {
r.value ? t.fieldAttrs.default = r.value : delete t.fieldAttrs.default;
}, i = () => {
var f, o, m;
let d = { id: `g${Date.now()}`, label: "newGroup", assocEnum: { property: "", value: "" } };
Array.isArray((f = t.fieldAttrs) == null ? void 0 : f.enumGroups) || (t.fieldAttrs.enumGroups = []), (m = (o = t.fieldAttrs) == null ? void 0 : o.enumGroups) == null || m.push(d);
}, s = (d, f) => {
var o, m;
(m = (o = t.fieldAttrs) == null ? void 0 : o.enumGroups) == null || m.splice(f, 1);
}, c = () => {
var d;
(d = t.fieldAttrs[t.fieldAttrsType]) == null || d.push({
label: "新选项",
value: "newKey"
});
}, l = (d, f) => {
var o;
(o = t.fieldAttrs[t.fieldAttrsType]) == null || o.splice(f, 1);
};
return (d, f) => {
const o = resolveComponent("tvu-input"), m = resolveComponent("tvu-button"), p = resolveComponent("tvu-form-item"), u = resolveComponent("tvu-option"), a = resolveComponent("tvu-select"), g = resolveComponent("tvu-input-number");
return openBlock(), createElementBlock("div", _hoisted_1$1, [
createElementVNode("div", _hoisted_2$1, [
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(e.fieldAttrs.enumGroups, (v, y) => (openBlock(), createBlock(
p,
{
class: "tvu-jse__enum-group tvu-jse__field",
key: y
},
{
default: withCtx(() => [
f[4] || (f[4] = createElementVNode(
"div",
null,
"分组ID",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.id,
"onUpdate:modelValue": (b) => v.id = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[5] || (f[5] = createElementVNode(
"div",
null,
"分组名称",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.label,
"onUpdate:modelValue": (b) => v.label = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[6] || (f[6] = createElementVNode(
"div",
null,
"分组生效属性名",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.assocEnum.property,
"onUpdate:modelValue": (b) => v.assocEnum.property = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[7] || (f[7] = createElementVNode(
"div",
null,
"分组生效属性值",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.assocEnum.value,
"onUpdate:modelValue": (b) => v.assocEnum.value = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
createVNode(m, {
onClick: (b) => s(v, y)
}, {
default: withCtx(() => f[3] || (f[3] = [
createTextVNode("删除分组")
])),
_: 2
/* DYNAMIC */
}, 1032, ["onClick"])
]),
_: 2
/* DYNAMIC */
},
1024
/* DYNAMIC_SLOTS */
))),
128
/* KEYED_FRAGMENT */
)),
createVNode(m, { onClick: i }, {
default: withCtx(() => f[8] || (f[8] = [
createTextVNode("新增分组")
])),
_: 1
/* STABLE */
})
]),
createElementVNode("div", _hoisted_3$1, [
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(e.fieldAttrs[e.fieldAttrsType], (v, y) => (openBlock(), createBlock(
p,
{
class: "tvu-jse__enum-option tvu-jse__field",
key: y
},
{
default: withCtx(() => [
f[10] || (f[10] = createElementVNode(
"div",
null,
"选项值",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.value,
"onUpdate:modelValue": (b) => v.value = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[11] || (f[11] = createElementVNode(
"div",
null,
"选项显示内容",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.label,
"onUpdate:modelValue": (b) => v.label = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[12] || (f[12] = createElementVNode(
"div",
null,
"选项所属分组",
-1
/* HOISTED */
)),
createVNode(o, {
modelValue: v.group,
"onUpdate:modelValue": (b) => v.group = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
createVNode(m, {
onClick: (b) => l(v, y)
}, {
default: withCtx(() => f[9] || (f[9] = [
createTextVNode("删除选项")
])),
_: 2
/* DYNAMIC */
}, 1032, ["onClick"])
]),
_: 2
/* DYNAMIC */
},
1024
/* DYNAMIC_SLOTS */
))),
128
/* KEYED_FRAGMENT */
)),
createVNode(m, { onClick: c }, {
default: withCtx(() => f[13] || (f[13] = [
createTextVNode("新增选项")
])),
_: 1
/* STABLE */
})
]),
createElementVNode("div", _hoisted_4$1, [
createVNode(p, {
class: "tvu-jse__field",
label: "默认选项"
}, {
default: withCtx(() => [
createVNode(a, {
modelValue: r.value,
"onUpdate:modelValue": f[0] || (f[0] = (v) => r.value = v),
onChange: n
}, {
default: withCtx(() => [
createVNode(u, {
label: "无",
value: ""
}),
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(e.fieldAttrs[e.fieldAttrsType], (v, y) => (openBlock(), createBlock(u, {
label: v.label,
value: v.value
}, null, 8, ["label", "value"]))),
256
/* UNKEYED_FRAGMENT */
))
]),
_: 1
/* STABLE */
}, 8, ["modelValue"])
]),
_: 1
/* STABLE */
})
]),
createElementVNode("div", _hoisted_5$1, [
createVNode(p, {
class: "tvu-jse__field",
label: "至少选"
}, {
default: withCtx(() => [
createVNode(g, {
modelValue: e.fieldAttrs.minItems,
"onUpdate:modelValue": f[1] || (f[1] = (v) => e.fieldAttrs.minItems = v),
modelModifiers: { number: !0 }
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}),
createVNode(p, {
class: "tvu-jse__field",
label: "最多选"
}, {
default: withCtx(() => [
createVNode(g, {
modelValue: e.fieldAttrs.maxItems,
"onUpdate:modelValue": f[2] || (f[2] = (v) => e.fieldAttrs.maxItems = v),
modelModifiers: { number: !0 }
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
})
])
]);
};
}
}), _sfc_main$4 = /* @__PURE__ */ defineComponent({
__name: "Attachment",
props: {
schemaProp: { type: Object, required: !0 },
onUpload: { type: Function }
},
setup(e) {
const t = e, { schemaProp: r, onUpload: n } = t, i = (c) => {
let l = r.attachment;
l.splice(
l.indexOf(l.find((d) => d.name === c.name)),
1
);
}, s = (c) => {
var m;
const { accept: l, size: d, limit: f } = (m = r.items) == null ? void 0 : m.formatAttrs, o = c.name.split(".").pop();
if (!l.split(",").includes(o)) {
alert(`不支持文件${c.name}的格式,仅支持${l}`);
return;
}
if (f && r.attachment.length >= f) {
alert(`只允许上传${f}个文件`);
return;
}
if (d && c.size / 1024 / 1024 > d) {
alert(`上传文件大小过大,超过${d}M`);
return;
}
r.attachment || (r.attachment = []), n == null || n(c).then((p) => {
r.attachment.push(p);
});
};
return (c, l) => {
const d = resolveComponent("tvu-button"), f = resolveComponent("tvu-upload"), o = resolveComponent("tvu-form-item");
return openBlock(), createBlock(o, { label: "上传模板" }, {
default: withCtx(() => [
createVNode(f, {
action: "#",
multiple: "",
"file-list": unref(r).attachment,
"upload-file": s,
"remove-file": i
}, {
default: withCtx(() => [
createVNode(d, null, {
default: withCtx(() => l[0] || (l[0] = [
createTextVNode("上传文件")
])),
_: 1
/* STABLE */
})
]),
_: 1
/* STABLE */
}, 8, ["file-list"])
]),
_: 1
/* STABLE */
});
};
}
}), _sfc_main$3 = /* @__PURE__ */ defineComponent({
__name: "Autofill",
props: {
autofill: { type: Object, required: !0 }
},
setup(e) {
return (t, r) => {
const n = resolveComponent("tvu-input"), i = resolveComponent("tvu-form-item"), s = resolveComponent("tvu-option"), c = resolveComponent("tvu-select"), l = resolveComponent("tvu-json");
return openBlock(), createElementBlock(
Fragment,
null,
[
createVNode(i, {
class: "tvu-jse__field",
label: "获取填充值地址"
}, {
default: withCtx(() => [
createVNode(n, {
modelValue: e.autofill.url,
"onUpdate:modelValue": r[0] || (r[0] = (d) => e.autofill.url = d)
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}),
createVNode(i, {
class: "tvu-jse__field",
label: "HTTP方法"
}, {
default: withCtx(() => [
createVNode(c, {
modelValue: e.autofill.method,
"onUpdate:modelValue": r[1] || (r[1] = (d) => e.autofill.method = d)
}, {
default: withCtx(() => [
create