tms-vue3-ui
Version:
Vue3基础UI库,提供JSONSchema编辑器,支持基于JSONSchema生成表单。
1,489 lines (1,488 loc) • 480 kB
JavaScript
var ie = Object.defineProperty;
var se = (e, t, r) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var V = (e, t, r) => se(e, typeof t != "symbol" ? t + "" : t, r);
import { createVNode, mergeProps, nextTick, h, resolveComponent, defineComponent, ref, reactive, onMounted, createElementBlock, openBlock, Fragment, createElementVNode, createCommentVNode, normalizeClass, unref, renderList, withDirectives, vModelDynamic, 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 p, a, d, f, l;
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
}), [(p = t.header) == null ? void 0 : p.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
}
}), [(a = t.left) == null ? void 0 : a.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
}), [(l = t.footer) == null ? void 0 : l.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((p, a) => {
typeof p.type == "string" || typeof p.type == "object" ? (p.props ?? (p.props = {}), addStyleClass(p.props, "class", "tms-flex__item"), this.elasticItems && this.elasticItems.length && this.elasticItems.includes(a) && addStyleClass(p.props, "class", "tms-flex__item_elastic")) : typeof p.type == "symbol" ? typeof p.children.forEach == "function" ? p.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类型", p.children) : console.warn(`不支持的vnode.type=${p.type}`, p);
}), 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: p,
to: a,
url: d
} = r, f = r.thumb === "" ? null : r.thumb, l = this;
function m() {
d ? location.href = d : a && l.$parent && l.$parent.$router && l.$parent.$router.push(a);
}
return createVNode("div", mergeProps({
class: "tms-card",
onClick: m
}, {
style: {
backgroundColor: s
}
}), [createVNode(resolveComponent("tms-flex"), {
direction: "column",
gap: this.gap
}, {
default: () => {
var u;
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 c;
return [createVNode("div", {
class: "tms-card__title"
}, [t.title ? t.title() : n]), createVNode("div", mergeProps({
class: "tms-card__desc"
}, {
style: {
color: p
}
}), [t.desc ? t.desc() : i]), t.bottom ? createVNode("div", {
class: "tms-card__bottom"
}, [(c = t.bottom) == null ? void 0 : c.call(t)]) : ""];
}
})])]
})]), t.footer ? createVNode("footer", null, [(u = t.footer) == null ? void 0 : u.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: p,
fnCaptcha: a,
onSuccess: d,
onFail: f,
errorTip: l,
asDialog: m,
onClose: u,
closeAfterSuccess: c
} = t;
const o = reactive({}), v = ref(), g = ref([]), _ = reactive({}), b = ref();
i == null || i.forEach((S) => {
S.type === "captcha" ? b.value = S : (_[S.key] = S.type === "password" ? "password" : "text", g.value.push(S), S.defaultValue && typeof S.defaultValue == "string" && (o[S.key] = S.defaultValue));
});
const k = () => {
b.value && (o[b.value.key] = "", n != null && n.value && typeof a == "function" && a().then((S) => {
let { code: O, captcha: A } = S;
n.value.innerHTML = O !== 0 ? "获取失败" : A;
}));
}, y = (S) => {
_[S.key] = _[S.key] === "password" ? "text" : "password";
}, C = () => {
if (v.value = "", i && i.length) {
if (i.map((A) => A.key).filter((A) => !o[A]).length)
return v.value = "缺少必填信息", f({ msg: "缺少必填信息" });
typeof p == "function" && p(o).then((A) => {
let { code: E, msg: x } = A;
if (E !== 0)
return k(), v.value = x || "登录失败", f(A);
d(A), c && w();
});
}
}, w = () => {
var S, O;
typeof u == "function" ? u() : (O = (S = r.value.parentElement) == null ? void 0 : S.parentElement) == null || O.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => {
k();
});
}), (S, O) => {
var A;
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(g.value, (E, x) => (openBlock(), createElementBlock("div", {
class: "tvu-login__input",
key: x
}, [
withDirectives(createElementVNode("input", {
placeholder: E.placeholder,
type: _[E.key],
"onUpdate:modelValue": (N) => o[E.key] = N,
required: ""
}, null, 8, _hoisted_1$5), [
[vModelDynamic, o[E.key]]
]),
E.type === "password" ? (openBlock(), createElementBlock("span", {
key: 0,
onClick: (N) => y(E),
class: normalizeClass({
"tvu-login__password--close": _[E.key] === "password",
"tvu-login__password--open": _[E.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": O[0] || (O[0] = (E) => o[b.value.key] = E),
required: ""
}, null, 8, _hoisted_4$4), [
[vModelText, o[b.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", { onClick: k })
])) : createCommentVNode("v-if", !0),
unref(l) && v.value ? (openBlock(), createElementBlock("div", _hoisted_5$4, [
O[1] || (O[1] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(v.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((A = unref(s)) == null ? void 0 : A.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: p, fnCaptcha: a, onSuccess: d, onFail: f, errorTip: l, asDialog: m, onClose: u } = t;
const c = reactive({}), o = ref(null);
let v = reactive({ password: !1, password2: !1 });
const g = ref(), _ = ref([]), b = ref();
i && i.length && i.forEach((S) => {
S.type === "captcha" ? b.value = S : _.value.push(S);
});
const k = () => {
c[b.value.key] = "", n != null && n.value && typeof a == "function" && a().then((S) => {
let { code: O, captcha: A, msg: E } = S;
O !== 0 ? (g.value = E || "获取验证码失败", n.value.innerHTML = "获取失败") : (g.value = "", n.value.innerHTML = A);
});
}, y = (S) => {
v[S] = !v[S];
const O = toRaw(o.value);
S == "password" ? v[S] ? O[0].previousSibling.type = "text" : O[0].previousSibling.type = "password" : v[S] ? O[1].previousSibling.type = "text" : O[1].previousSibling.type = "password";
}, C = () => {
if (Array.isArray(i) && i.length) {
if (i.map((A) => A.key).filter((A) => !c[A]).length)
return g.value = "缺少必填信息", f({ msg: "缺少必填信息" });
typeof p == "function" && p(c).then((A) => {
let { code: E, msg: x } = A;
if (E !== 0)
return k(), g.value = x || "登录失败", f(A);
g.value = "", d(A), closeAfterSuccess && w();
});
}
}, w = () => {
var S, O;
typeof u == "function" ? u() : (O = (S = r.value.parentElement) == null ? void 0 : S.parentElement) == null || O.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => k());
}), (S, O) => {
var A;
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(_.value, (E, x) => (openBlock(), createElementBlock("div", {
class: "tvu-register__input",
key: x
}, [
withDirectives(createElementVNode("input", {
placeholder: E.placeholder,
type: E.type,
"onUpdate:modelValue": (N) => c[E.key] = N,
required: ""
}, null, 8, _hoisted_1$4), [
[vModelDynamic, c[E.key]]
]),
E.type == "password" ? (openBlock(), createElementBlock("span", {
key: 0,
ref_for: !0,
ref_key: "passwordEle",
ref: o,
onClick: (N) => y(E.key),
class: normalizeClass({ "tvu-register__password--close": !unref(v)[E.key], "tvu-register__password--open": unref(v)[E.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": O[0] || (O[0] = (E) => c[b.value.key] = E),
required: ""
}, null, 8, _hoisted_4$3), [
[vModelText, c[b.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", { onClick: k })
])) : createCommentVNode("v-if", !0),
unref(l) && g.value ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
O[1] || (O[1] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(g.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((A = unref(s)) == null ? void 0 : A.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: p,
fnVerify: a,
fnSendCode: d,
fnSendSmsCode: f,
onSuccess: l,
onFail: m,
errorTip: u,
asDialog: c,
onClose: o,
waitInputSmsCodeTime: v
} = t;
const g = reactive({}), _ = ref(), b = ref([]), k = ref(), y = ref(), C = ref(!1);
s == null || s.forEach((E) => {
E.type === "smscode" ? k.value = E : E.type === "captcha" ? y.value = E : b.value.push(E);
});
const w = () => {
if (_.value = "", typeof f == "function" && k.value) {
g[k.value.key] = "", C.value = !0;
let E = v, x = setInterval(() => {
E == 0 ? (clearInterval(x), C.value = !1, i.value.innerHTML = "获取短信验证码") : (i.value.innerHTML = E + "秒后重发", E--);
}, 1e3);
f(g).then((N) => {
let { code: q, msg: L } = N;
if (q !== 0)
return _.value = L || "获取短信验证码失败", m(N);
});
}
}, S = () => {
y.value && (g[y.value.key] = "", g[k.value.key] = "", n != null && n.value && typeof d == "function" && d().then((E) => {
let { code: x, captcha: N } = E;
n.value.innerHTML = x !== 0 ? "获取失败" : N;
}));
}, O = () => {
if (_.value = "", Array.isArray(s) && s.length) {
if (s.map((N) => N.key).filter((N) => !g[N]).length)
return _.value = "缺少必填信息", m({ msg: "缺少必填信息" });
typeof a == "function" && a(g).then((N) => {
let { code: q, msg: L } = N;
if (q !== 0)
return S(), _.value = L || "验证失败", m(N);
l(N), closeAfterSuccess && A();
});
}
}, A = () => {
var E, x;
typeof o == "function" ? o() : (x = (E = r.value.parentElement) == null ? void 0 : E.parentElement) == null || x.removeChild(r.value.parentElement);
};
return onMounted(() => {
nextTick(() => S());
}), (E, x) => {
var N;
return openBlock(), createElementBlock(
Fragment,
null,
[
createElementVNode(
"div",
{
ref_key: "el",
ref: r,
class: normalizeClass(["tvu-sms-code__form", { "tvu-sms-code__form--modal": unref(c) }])
},
[
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(b.value, (q, L) => (openBlock(), createElementBlock("div", {
class: "tvu-sms-code__input",
key: L
}, [
withDirectives(createElementVNode("input", {
placeholder: q.placeholder,
type: q.type,
"onUpdate:modelValue": (D) => g[q.key] = D,
required: ""
}, null, 8, _hoisted_1$3), [
[vModelDynamic, g[q.key]]
])
]))),
128
/* KEYED_FRAGMENT */
)),
y.value ? (openBlock(), createElementBlock("div", _hoisted_2$2, [
withDirectives(createElementVNode("input", {
placeholder: y.value.placeholder,
"onUpdate:modelValue": x[0] || (x[0] = (q) => g[y.value.key] = q),
required: ""
}, null, 8, _hoisted_3$2), [
[vModelText, g[y.value.key]]
]),
createElementVNode(
"div",
{
ref_key: "elCaptcha",
ref: n
},
null,
512
/* NEED_PATCH */
),
createElementVNode("button", {
onClick: x[1] || (x[1] = (q) => S())
})
])) : createCommentVNode("v-if", !0),
k.value ? (openBlock(), createElementBlock("div", _hoisted_4$2, [
withDirectives(createElementVNode("input", {
placeholder: k.value.placeholder,
"onUpdate:modelValue": x[2] || (x[2] = (q) => g[k.value.key] = q),
required: ""
}, null, 8, _hoisted_5$2), [
[vModelText, g[k.value.key]]
]),
createElementVNode("button", {
ref_key: "elSmsCode",
ref: i,
disabled: C.value,
onClick: w
}, " 获取短信验证码 ", 8, _hoisted_6$1)
])) : createCommentVNode("v-if", !0),
unref(u) && _.value ? (openBlock(), createElementBlock("div", _hoisted_7$1, [
x[3] || (x[3] = createElementVNode(
"i",
null,
null,
-1
/* HOISTED */
)),
createTextVNode(
toDisplayString(_.value || "error"),
1
/* TEXT */
)
])) : createCommentVNode("v-if", !0),
createElementVNode("div", _hoisted_8$1, [
createElementVNode(
"button",
{ onClick: O },
toDisplayString(e.actionText),
1
/* TEXT */
)
]),
unref(c) ? (openBlock(), createElementBlock("div", _hoisted_9$1, [
createElementVNode("button", { onClick: A }, "关闭")
])) : createCommentVNode("v-if", !0),
unref(p) ? (openBlock(), createElementBlock(
"div",
_hoisted_10$1,
toDisplayString((N = unref(p)) == null ? void 0 : N.text),
1
/* TEXT */
)) : createCommentVNode("v-if", !0)
],
2
/* CLASS */
),
unref(c) ? (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 p = s.target;
if (p.files) {
const a = p.files[0];
this.uploadFile(a);
}
}), 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, l, 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 = (l = t.fieldAttrs) == null ? void 0 : l.enumGroups) == null || m.push(d);
}, s = (d, f) => {
var l, m;
(m = (l = t.fieldAttrs) == null ? void 0 : l.enumGroups) == null || m.splice(f, 1);
}, p = () => {
var d;
(d = t.fieldAttrs[t.fieldAttrsType]) == null || d.push({
label: "新选项",
value: "newKey"
});
}, a = (d, f) => {
var l;
(l = t.fieldAttrs[t.fieldAttrsType]) == null || l.splice(f, 1);
};
return (d, f) => {
const l = resolveComponent("tvu-input"), m = resolveComponent("tvu-button"), u = resolveComponent("tvu-form-item"), c = resolveComponent("tvu-option"), o = resolveComponent("tvu-select"), v = 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, (g, _) => (openBlock(), createBlock(
u,
{
class: "tvu-jse__enum-group tvu-jse__field",
key: _
},
{
default: withCtx(() => [
f[4] || (f[4] = createElementVNode(
"div",
null,
"分组ID",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.id,
"onUpdate:modelValue": (b) => g.id = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[5] || (f[5] = createElementVNode(
"div",
null,
"分组名称",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.label,
"onUpdate:modelValue": (b) => g.label = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[6] || (f[6] = createElementVNode(
"div",
null,
"分组生效属性名",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.assocEnum.property,
"onUpdate:modelValue": (b) => g.assocEnum.property = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[7] || (f[7] = createElementVNode(
"div",
null,
"分组生效属性值",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.assocEnum.value,
"onUpdate:modelValue": (b) => g.assocEnum.value = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
createVNode(m, {
onClick: (b) => s(g, _)
}, {
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], (g, _) => (openBlock(), createBlock(
u,
{
class: "tvu-jse__enum-option tvu-jse__field",
key: _
},
{
default: withCtx(() => [
f[10] || (f[10] = createElementVNode(
"div",
null,
"选项值",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.value,
"onUpdate:modelValue": (b) => g.value = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[11] || (f[11] = createElementVNode(
"div",
null,
"选项显示内容",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.label,
"onUpdate:modelValue": (b) => g.label = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
f[12] || (f[12] = createElementVNode(
"div",
null,
"选项所属分组",
-1
/* HOISTED */
)),
createVNode(l, {
modelValue: g.group,
"onUpdate:modelValue": (b) => g.group = b
}, null, 8, ["modelValue", "onUpdate:modelValue"]),
createVNode(m, {
onClick: (b) => a(g, _)
}, {
default: withCtx(() => f[9] || (f[9] = [
createTextVNode("删除选项")
])),
_: 2
/* DYNAMIC */
}, 1032, ["onClick"])
]),
_: 2
/* DYNAMIC */
},
1024
/* DYNAMIC_SLOTS */
))),
128
/* KEYED_FRAGMENT */
)),
createVNode(m, { onClick: p }, {
default: withCtx(() => f[13] || (f[13] = [
createTextVNode("新增选项")
])),
_: 1
/* STABLE */
})
]),
createElementVNode("div", _hoisted_4$1, [
createVNode(u, {
class: "tvu-jse__field",
label: "默认选项"
}, {
default: withCtx(() => [
createVNode(o, {
modelValue: r.value,
"onUpdate:modelValue": f[0] || (f[0] = (g) => r.value = g),
onChange: n
}, {
default: withCtx(() => [
createVNode(c, {
label: "无",
value: ""
}),
(openBlock(!0), createElementBlock(
Fragment,
null,
renderList(e.fieldAttrs[e.fieldAttrsType], (g, _) => (openBlock(), createBlock(c, {
label: g.label,
value: g.value
}, null, 8, ["label", "value"]))),
256
/* UNKEYED_FRAGMENT */
))
]),
_: 1
/* STABLE */
}, 8, ["modelValue"])
]),
_: 1
/* STABLE */
})
]),
createElementVNode("div", _hoisted_5$1, [
createVNode(u, {
class: "tvu-jse__field",
label: "至少选"
}, {
default: withCtx(() => [
createVNode(v, {
modelValue: e.fieldAttrs.minItems,
"onUpdate:modelValue": f[1] || (f[1] = (g) => e.fieldAttrs.minItems = g),
modelModifiers: { number: !0 }
}, null, 8, ["modelValue"])
]),
_: 1
/* STABLE */
}),
createVNode(u, {
class: "tvu-jse__field",
label: "最多选"
}, {
default: withCtx(() => [
createVNode(v, {
modelValue: e.fieldAttrs.maxItems,
"onUpdate:modelValue": f[2] || (f[2] = (g) => e.fieldAttrs.maxItems = g),
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 = (p) => {
let a = r.attachment;
a.splice(
a.indexOf(a.find((d) => d.name === p.name)),
1
);
}, s = (p) => {
var m;
const { accept: a, size: d, limit: f } = (m = r.items) == null ? void 0 : m.formatAttrs, l = p.name.split(".").pop();
if (!a.split(",").includes(l)) {
alert(`不支持文件${p.name}的格式,仅支持${a}`);
return;
}
if (f && r.attachment.length >= f) {
alert(`只允许上传${f}个文件`);
return;
}
if (d && p.size / 1024 / 1024 > d) {
alert(`上传文件大小过大,超过${d}M`);
return;
}
r.attachment || (r.attachment = []), n == null || n(p).then((u) => {
r.attachment.push(u);
});
};
return (p, a) => {
const d = resolveComponent("tvu-button"), f = resolveComponent("tvu-upload"), l = resolveComponent("tvu-form-item");
return openBlock(), createBlock(l, { 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(() => a[0] || (a[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"), p = resolveComponent("tvu-select"), a = 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(p, {
modelValue: e.autofill.method,
"onUpdate:modelValue": r[1] || (r[1] = (d) => e.autofill.method = d)