UNPKG

element-pro-components

Version:

a component library for Vue 3 base on element-plus

1,934 lines 84.2 kB
var jn = Object.defineProperty, Dn = Object.defineProperties; var zn = Object.getOwnPropertyDescriptors; var ce = Object.getOwnPropertySymbols; var Xe = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable; var Qe = (e, t, n) => t in e ? jn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t) => { for (var n in t || (t = {})) Xe.call(t, n) && Qe(e, n, t[n]); if (ce) for (var n of ce(t)) Ye.call(t, n) && Qe(e, n, t[n]); return e; }, P = (e, t) => Dn(e, zn(t)); var et = (e, t) => { var n = {}; for (var r in e) Xe.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (e != null && ce) for (var r of ce(e)) t.indexOf(r) < 0 && Ye.call(e, r) && (n[r] = e[r]); return n; }; var tt = (e, t, n) => new Promise((r, a) => { var d = (l) => { try { u(n.next(l)); } catch (s) { a(s); } }, o = (l) => { try { u(n.throw(l)); } catch (s) { a(s); } }, u = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(d, o); u((n = n.apply(e, t)).next()); }); import { Fragment as An, computed as x, inject as Se, ref as D, unref as de, getCurrentInstance as $n, reactive as fe, watchEffect as Ln, provide as ke, defineComponent as B, h as i, mergeProps as C, resolveDynamicComponent as lt, toRefs as Ve, watch as me, shallowRef as we, onMounted as he, markRaw as Q, nextTick as rt, resolveComponent as Nn, useSlots as ut, KeepAlive as _n, Transition as Kn } from "vue"; import { useProp as st, useLocale as In, tagProps as Mn, inputProps as Un, useAttrs as oe, useSize as ct, useDisabled as Gn, ElTag as Hn, ElInput as qn, autocompleteProps as Wn, ElAutocomplete as Zn, breadcrumbProps as Jn, ElBreadcrumb as Qn, ElBreadcrumbItem as Xn, rowProps as it, colProps as Yn, cardProps as eo, checkboxGroupProps as dt, ElCheckboxGroup as to, ElCheckbox as no, ElCheckboxButton as oo, ElDropdown as ft, ElButton as I, ElDropdownMenu as mt, ElTree as ht, formProps as ao, ElTabs as gt, ElTabPane as pt, ElCollapse as lo, ElCollapseItem as ro, ElSteps as uo, ElStep as so, ElFormItem as Te, ElForm as co, paginationProps as vt, ElTableColumn as te, ElTable as io, ElPagination as fo, dialogProps as mo, ElDescriptions as ho, ElDescriptionsItem as go, ElDialog as po, ElSelect as bt, ElOptionGroup as vo, ElOption as Pe, menuProps as bo, ElMenu as yo, ElMenuItem as Co, ElMenuItemGroup as xo, ElSubMenu as Po, useId as So, ElScrollbar as ko, radioGroupProps as yt, ElRadioGroup as Vo, ElRadio as wo, ElRadioButton as To, tabsProps as Bo, ElDropdownItem as ie } from "element-plus"; import { get as _, isFunction as L, isObject as $, omit as N, isString as M, isNumber as X, isBoolean as W, pick as ge, set as nt, has as Ro } from "lodash-unified"; import { get as mr, has as hr, isBoolean as gr, isFunction as pr, isNumber as vr, isObject as br, isString as yr, omit as Cr, pick as xr, set as Pr } from "lodash-unified"; import { createSharedComposable as Ct, useBreakpoints as Fo, reactiveComputed as Eo, useResizeObserver as Oo } from "@vueuse/core"; import { useRouter as Be, useRoute as Re, RouterView as jo } from "vue-router"; import { Setting as Do, Plus as zo, Minus as Ao, Refresh as $o, Back as Lo, Right as No, Close as _o } from "@element-plus/icons-vue"; function q(e, t, n = !0, r) { const a = []; for (let d = 0; d < e.length; d++) { const o = v({}, e[d]), u = _(o, t); (n ? u : !u) && (o.children && o.children.length && (o.children = q(o.children, t, n)), a.push(L(r) ? r(o) : o)); } return a; } function Fe(e, t, n = !0, r) { return j(e) ? e.reduce( (a, d) => { const o = v({}, d), u = _(o, t); let l = []; return o.children && o.children.length && (l = Fe(o.children, t, n, r), o.children = void 0), !!u === n && l.unshift(L(r) ? r(o) : o), [...a, ...l]; }, [] ) : []; } function Ul(e = {}) { const { importStyle: t = "js", exclude: n } = e, r = [ "ProArrayForm", "ProCollapseForm", "ProFormComponent", "ProFormItem", "ProFormList", "ProGroupForm", "ProStepsForm", "ProTabsForm", ...e.noStylesComponents || [] ]; return (a) => { if (!(n && n.test(a)) && /^Pro[A-Z]\w+/.test(a)) { const d = a.slice(3).replace(/\B([A-Z])/g, "-$1").toLocaleLowerCase(), o = { from: "element-pro-components", name: a }; return r.includes(a) || (o.sideEffects = `element-pro-components/lib/styles/${d}.${t}`), o; } }; } function ot(e) { return /^((ht|f)tps?):\/\/?/.test(e); } function j(e) { return Array.isArray(e); } function Z(e) { return e === void 0; } function xt(e, t) { return e == null ? void 0 : e.find((n) => { var r; return n.type === An || n.type === "template" ? xt(n.children, t) : ($(n.type) ? (r = n.type) == null ? void 0 : r.name : n.type) === t; }); } function E(e) { const t = e; return t.install = (n) => { n.component(t.name, t); }, t; } function Ee(e) { console.warn(`[ElementProComponents Warn]: ${e}`); } function Pt(e, t) { return `${e}${e && t ? "." : ""}${t}`; } const Ko = Ct(() => Fo({ sm: 768, md: 992, lg: 1200, xl: 1920 })); function Oe() { const e = Ko(), t = e.greater("xl"), n = e.greater("lg"), r = e.greater("md"), a = e.greater("sm"); return x(() => t.value ? "xl" : n.value ? "lg" : r.value ? "md" : a.value ? "sm" : "xs"); } function Io(e) { const t = Oe(), n = Object.assign( { xs: "90%", sm: "80%", md: "70%", lg: "60%", xl: "50%" }, e || {} ); return x(() => n[t.value]); } function St(e) { const { gutter: t } = Se("ElRow", { gutter: D() }), n = x(() => t.value ? { paddingLeft: `${t.value / 2}px`, paddingRight: `${t.value / 2}px` } : {}), r = x(() => { var s, m, c, g; const a = de(e), d = { span: (s = a.span) != null ? s : 24, offset: (m = a.offset) != null ? m : 0, pull: (c = a.pull) != null ? c : 0, push: (g = a.push) != null ? g : 0, xs: a.xs, sm: a.sm, md: a.md, lg: a.lg, xl: a.xl }, o = ["el-col"]; return ["span", "offset", "pull", "push"].forEach((f) => { const h = d[f]; typeof h == "number" && (f === "span" ? o.push(`el-col-${d[f]}`) : h > 0 && o.push(`el-col-${f}-${d[f]}`)); }), ["xs", "sm", "md", "lg", "xl"].forEach((f) => { const h = d[f]; typeof h == "number" ? o.push(`el-col-${f}-${h}`) : $(h) && Object.keys(h).forEach((p) => { const b = p; o.push( b !== "span" ? `el-col-${f}-${b}-${h[b]}` : `el-col-${f}-${h[b]}` ); }); }), t.value && o.push("is-guttered"), o; }); return { colStyle: n, colClass: r, gutter: t }; } function ae() { const e = { value: "value", label: "label", disabled: "disabled", name: "name", children: "children" }, t = st("config"), n = x( () => Object.assign(e, t.value) ); return { config: n, getLabel: (l) => _(l, n.value.label), getValue: (l) => _(l, n.value.value), getDisabled: (l) => _(l, n.value.disabled), getName: (l) => _(l, n.value.name), getChildren: (l) => _(l, n.value.children) }; } const Mo = { name: "en", pro: { form: { submit: "Submit", reset: "Reset", prev: "Prev", next: "Next", ariaAdd: "Add a row of data", ariaDel: "Delete this row of data" }, search: { submit: "Search", reset: "Reset", prev: "Prev", next: "Next" }, crud: { add: "Add", edit: "Edit", detail: "Detail", del: "Delete", submit: "Submit", reset: "Reset", prev: "Prev", next: "Next", search: "Search", searchReset: "Reset", searchPrev: "Prev", searchNext: "Next" }, tabs: { refresh: "Refresh", left: "Close Left", right: "Close Right", others: "Close Others" }, layout: { ariaToggle: "Toggle sidebar menu content" } } }; function Y(e) { const a = In(e), { t } = a, n = et(a, ["t"]); function r(d, o) { let u = t(d, o); return u === d && (u = _(Mo, d, d)), u.replace( /\{(\w+)\}/g, (l, s) => { var m; return `${(m = o == null ? void 0 : o[s]) != null ? m : `{${s}}`}`; } ); } return P(v({}, n), { t: r }); } function kt(e = !1) { const t = de(e), n = D(t); function r() { n.value = !n.value; } return { show: n, toggleShow: r }; } function je(e = "modelValue", t) { const n = $n(), r = t || (n == null ? void 0 : n.emit); function a(d) { r && r(`update:${e}`, d); } return a; } function K(e, ...t) { return t.map( (n) => Eo( () => Object.fromEntries(n.map((r) => [r, e[r]])) ) ); } const Uo = Ct(() => { const e = Be(), t = D([]); return e.options.routes = fe(e.options.routes), Ln(() => { t.value = e.options.routes; }), t; }); function Vt() { const e = st("routes"); return x(() => e.value ? e.value : Uo().value); } function De(e) { const t = x(() => e.gutter); ke("ElRow", { gutter: t }); const n = x(() => { const a = { marginLeft: "", marginRight: "" }; return e.gutter && (a.marginLeft = `-${e.gutter / 2}px`, a.marginRight = a.marginLeft), a; }), r = x(() => [ "el-row", e.justify !== "start" ? `is-justify-${e.justify}` : "", e.align !== "top" ? `is-align-${e.align}` : "" ]); return { rowStyle: n, rowClass: r }; } const wt = N(Mn, "closable"), Go = N( Un, "modelValue", "type", "resize", "autosize", "showPassword" ), Tt = P(v({}, wt), { modelValue: Array, max: Number, trigger: { type: String, default: "enter" } }), at = Object.keys(wt), Ho = v(v({}, Tt), Go), Bt = { "update:modelValue": (e) => j(e), input: (e) => M(e), "tag-add": (e) => M(e), "tag-remove": (e) => M(e) }; function Rt(e, t) { const n = oe(), r = ct(), a = Object.keys(e).filter( (y) => ![...at, "modelValue", "max", "trigger", "size"].includes(y) ), [d, o] = K(e, at, a), u = D(), l = D(""), s = D(!1), m = D(), c = x(() => e.modelValue || []), g = x(() => { const y = e.trigger; return { space: " ", enter: "Enter" }[y]; }), f = x(() => { var y; return !e.disabled && e.max !== void 0 ? (((y = e.modelValue) == null ? void 0 : y.length) || 0) >= e.max : e.disabled; }), h = x(() => { const y = Gn(); return !(e.readonly || y.value); }); function p(y) { if (y === !0 && (s.value = !1, m.value = void 0), l.value.trim()) { const S = [...c.value, l.value]; t("tag-add", l.value), t("update:modelValue", S), l.value = ""; } } function b(y) { l.value = y, m.value = void 0, t("input", y); } function w(y) { var V; (V = u.value) == null || V.focus(), t("tag-remove", c.value[y]); const S = [...c.value]; S.splice(y, 1), t("update:modelValue", S), m.value = void 0; } function F(y) { var S; y.key === "Enter" && m.value !== void 0 ? w(m.value) : y.key === "Backspace" && !l.value && ((S = c.value) != null && S.length) ? m.value === void 0 ? m.value = c.value.length - 1 : w(m.value) : y.key === g.value && p(); } function z() { s.value = !0; } return { attrs: n, size: r, tagProps: d, inputProps: o, inputRef: u, input: l, focused: s, selectedTag: m, list: c, disabled: f, closable: h, add: p, change: b, close: w, keyup: F, focus: z }; } function Ft(e, t) { const n = t.list.value.map( (r, a) => i( Hn, C(t.tagProps, { key: a, size: t.size.value, closable: t.closable.value, class: t.selectedTag.value === a && "is-selecte", onClose: () => t.close(a) }), () => r ) ); return n.push( i( e, C(t.inputProps, t.attrs.value, { ref: t.inputRef, modelValue: t.input.value, size: t.size.value, disabled: t.disabled.value, type: "text", onSelect: t.add, onFocus: t.focus, onBlur: () => t.add(!0), onKeyup: t.keyup, "onUpdate:modelValue": t.change }) ) ), n; } const qo = B({ name: "ProInputTag", props: Ho, emits: Bt, setup(e, { emit: t }) { const n = Rt(e, t); return () => { var r; return i( "div", { class: ["pro-input-tag", n.focused.value && "is-focus"], onClick: (r = n.inputRef.value) == null ? void 0 : r.focus }, Ft(qn, n) ); }; } }), Wo = E(qo), Zo = N(Wn, "modelValue"), Jo = P(v(v({}, Tt), Zo), { placeholder: String, disabled: Boolean, readonly: Boolean, name: String, label: String, suffixIcon: String, prefixIcon: String }), Qo = B({ name: "ProAutocompleteTag", props: Jo, emits: Bt, setup(e, { emit: t }) { const n = Rt(e, t); return () => { var r; return i( "div", { class: [ "pro-input-tag", "pro-autocomplete-tag", n.focused.value && "is-focus" ], onClick: (r = n.inputRef.value) == null ? void 0 : r.focus }, Ft( Zn, n ) ); }; } }), Xo = E(Qo), Yo = { to: String }, ea = B({ name: "ProLink", props: Yo, setup(e, { slots: t }) { const n = x(() => e.to ? ot(e.to) ? "a" : "router-link" : "span"), r = x(() => e.to ? ot(e.to) ? { href: e.to, target: "_blank", rel: "noopener noreferrer" } : { to: e.to } : {}); return () => i( lt(n.value), C(r.value, { class: "pro-link" }), t ); } }), Et = E(ea), ta = B({ name: "ProBreadcrumb", props: Jn, setup(e) { const t = Re(); return () => i( Qn, C(e, { class: "pro-breadcrumb" }), () => t.matched.map( (n, r) => i( Xn, { key: r }, () => i(Et, { to: n.path }, () => { var a; return (a = n.meta) == null ? void 0 : a.title; }) ) ) ); } }), na = E(ta), oa = N(it, "tag"), aa = N(Yn, "tag", "span"), la = P(v(v(v({}, eo), oa), aa), { // Modify the default value to be undefined, which is convenient to determine whether it is a Row span: Number, direction: { type: String, default: "row" }, split: Boolean, ghost: Boolean }), ra = B({ name: "ProCard", props: la, setup(e, { slots: t }) { const { rowStyle: n, rowClass: r } = De(e), { colStyle: a, colClass: d, gutter: o } = St(e), u = x(() => t.default && t.default()), l = x(() => !!xt(u.value, "ProCard")), s = x(() => { const f = /^el-col,el-col-24(,is-guttered)?$/; return !(!e.span && f.test(d.value.join())); }); function m() { if (t.header || e.header) return i( "div", { class: "pro-card__header" }, t.header ? t.header() : e.header ); } function c() { return i( "div", C( { style: e.bodyStyle }, { class: [ "pro-card__body", l.value && r.value, l.value && e.direction && `is-direction-${e.direction}` ], style: l.value && n.value } ), u.value ); } function g() { return i( "div", { class: [ "pro-card", e.ghost && "is-ghost", l.value && e.split && "is-split", e.shadow && `is-${e.shadow}-shadow` ], style: !s.value && o.value && { marginLeft: `${o.value / 2}px`, marginRight: `${o.value / 2}px` } }, [m(), c()] ); } return () => s.value ? i( "div", { class: d.value, style: a.value }, g() ) : g(); } }), ua = E(ra), pe = { data: { type: Array, default: () => [] }, config: { type: Object, default: () => ({}) } }, ze = { name: String, id: String, autocomplete: String, automaticDropdown: Boolean, size: String, disabled: Boolean, clearable: Boolean, filterable: Boolean, allowCreate: Boolean, loading: Boolean, remote: Boolean, loadingText: String, noMatchText: String, noDataText: String, remoteMethod: Function, multiple: Boolean, multipleLimit: { type: Number, default: 0 }, placeholder: String, defaultFirstOption: Boolean, reserveKeyword: Boolean, valueKey: String, collapseTags: Boolean, teleported: { type: Boolean, default: !0 }, clearIcon: [String, Object], fitInputWidth: Boolean, suffixIcon: [String, Object], tagType: { type: String, default: "info" }, effect: { type: String, default: "light" }, collapseTagsTooltip: Boolean, persistent: { type: Boolean, default: !0 }, validateEvent: { type: Boolean, default: !0 } }, Ot = P(v(v({}, pe), ze), { modelValue: [Array, String, Number, Boolean, Object], filterMethod: Function, popperClass: String }), jt = { "update:modelValue": (e) => j(e) || M(e) || X(e) || W(e) || $(e) }, sa = Object.keys(Ot).filter( (e) => !["data", "config"].includes(e) ), ca = Object.keys( dt ), Dt = v(v({}, dt), pe), zt = { "update:modelValue": (e) => j(e) }; function At(e, t, n) { const { getLabel: r, getValue: a, getName: d, getDisabled: o } = ae(), u = je(), [l] = K(e, ca); return () => i( to, C(l, { class: n, "onUpdate:modelValue": u }), () => e.data.map((s) => i( t, { key: a(s), name: d(s), value: a(s), disabled: o(s) }, () => r(s) )) ); } const ia = B({ name: "ProCheckbox", props: Dt, emits: zt, setup(e) { return At(e, no, "pro-checkbox"); } }), da = E(ia), fa = B({ name: "ProCheckboxButton", props: Dt, emits: zt, setup(e) { return At( e, oo, "pro-checkbox-button" ); } }), ma = E(fa), ve = { emptyText: String, renderAfterExpand: Boolean, expandOnClickNode: Boolean, defaultExpandAll: Boolean, checkOnClickNode: Boolean, autoExpandParent: Boolean, allowDrag: Function, allowDrop: Function, accordion: Boolean, indent: Number, icon: [String, Object] }, ha = Object.keys(ve), ga = P(v({}, ve), { modelValue: { type: Array, default: () => [] }, trigger: { type: String, default: "hover" }, placement: { type: String, default: "bottom" }, size: String, highlightCurrent: Boolean, filterNodeMethod: Function }), pa = { "update:modelValue": (e) => j(e) }, va = B({ name: "ProColumnSetting", props: ga, emits: pa, setup(e, { emit: t, slots: n }) { const { modelValue: r } = Ve(e), [a] = K(e, [ ...ha, "highlightCurrent", "filterNodeMethod" ]), d = D(), o = x(() => Fe( e.modelValue, "hide", !1, (c) => c.prop )); me( o, (c) => { var g; (g = d.value) == null || g.setCheckedKeys(c); }, { deep: !0 } ); function u() { t("update:modelValue", r.value); } function l(c) { c.hide = !c.hide, t("update:modelValue", r.value); } function s() { return n.default ? n.default({ size: e.size }) : i(I, { size: e.size, circle: !0, icon: Do }); } function m() { return i( mt, null, () => i( ht, C(a, { ref: d, data: r.value, defaultCheckedKeys: o.value, showCheckbox: !0, checkStrictly: !0, draggable: !0, nodeKey: "prop", class: "pro-column-setting-tree", onNodeDragEnd: u, onCheck: l }) ) ); } return () => i( ft, { placement: e.placement, trigger: e.trigger, class: "pro-column-setting" }, { default: () => s(), dropdown: () => m() } ); } }), ba = E(va), $t = { submit: !0, submitProps: { type: "primary" }, reset: !0 }; function Lt(e) { const { t } = Y(); return x(() => { const n = P(v({}, $t), { submitText: t("pro.form.submit"), resetText: t("pro.form.reset"), prevText: t("pro.form.prev"), nextText: t("pro.form.next") }); return e.menu ? Object.assign({}, n, e.menu) : n; }); } function Ae(e) { const t = we({}), n = fe({}), { show: r, toggleShow: a } = kt(); he(() => { Object.assign(n, t.value); }); function d(l) { e("update:modelValue", l); } function o() { r.value = !0, t.value.validate().then((l) => { e("submit", a, l); }).catch((l) => { e("submit", a, !1, l); }); } function u(l = !1) { var s; W(l) && l && d(void 0), (s = t.value) == null || s.resetFields(), e("reset"); } return { formRef: t, formExpose: n, loading: r, update: d, submitForm: o, resetForm: u }; } const Nt = Symbol("formKey"); function ya(e) { ke(Nt, v(v({}, e), $e(e.emit))); } function $e(e) { function t(o) { e("add-item", o); } function n(o) { e("remove-item", o); } function r(o) { e("tab-change", o); } function a(o) { e("collapse-change", o); } function d(o) { e("step-change", o); } return { addItem: t, removeItem: n, tabsChange: r, collapseChange: a, stepChange: d }; } function H() { return Se(Nt); } function Ca(e, t) { const n = H(), r = x(() => e.max ? e.max > e.modelValue.length : !0); function a(u) { let l = [...e.modelValue]; e.modelValue ? l.push({}) : l = [{}], t("update:modelValue", l), n == null || n.addItem(u); } function d(u, l) { const s = [...e.modelValue]; s.splice(u, 1), t("update:modelValue", s), n == null || n.removeItem(l); } function o(u, l) { const s = [...e.modelValue]; s[l] = u, t("update:modelValue", s); } return { showAdd: r, add: a, remove: d, update: o }; } function le(e) { const t = H(); function n(r) { var a; return t != null && t.slots[`form-${r.prop}-label`] ? (t == null ? void 0 : (a = t.slots)[`form-${r.prop}-label`]).call(a, { item: r, indexes: e.indexes }) : r.label; } return n; } const _t = N(ao, "model"), xa = N(it, "tag"), Pa = Object.keys(_t), Kt = { modelValue: { type: Object, default: () => ({}) }, item: { type: Object, default: () => ({}) }, prefix: { type: String, default: "" }, indexes: { type: Array, default: void 0 } }, Sa = { is: { type: [String, Object], require: !0 }, _ref: [String, Object, Function], slots: [Function, Object, String] }, It = ge(Kt, "prefix", "indexes"), ka = P(v({}, It), { modelValue: { type: Array, default: () => [] }, columns: Array, max: Number }), re = P(v(v(v({}, _t), xa), It), { modelValue: [Object, Array], columns: Array, menu: Object, array: Boolean, max: Number }), Va = P(v({}, re), { type: String }), be = P(v({}, re), { columns: Array }), ue = { "update:modelValue": (e) => $(e) }, Mt = { "update:modelValue": (e) => j(e), "add-item": (e) => j(e), "remove-item": (e) => j(e) }, Ut = P(v({}, ue), { "tab-change": (e) => M(e) || X(e) }), Gt = P(v({}, ue), { "collapse-change": (e) => j(e) }), Ht = P(v({}, ue), { "step-change": (e) => M(e) || X(e) }), ye = P(v(v(v(v({}, Mt), Ut), Gt), Ht), { "update:modelValue": (e) => $(e) || j(e) || Z(e), submit: (e, t, n) => L(e) && W(t) && ($(n) || Z(n)), reset: () => !0 }), wa = B({ name: "ProArrayForm", props: ka, emits: Mt, setup(e, { emit: t }) { const n = H(), { t: r } = Y(), { showAdd: a, add: d, remove: o, update: u } = Ca(e, t); function l(s, m) { const c = [...e.indexes || [], m], g = Pt(e.prefix, String(m)); return i("div", { key: c.join("_"), class: "pro-array-form" }, [ i( "div", { class: [!(n != null && n.props.inline) && "el-row", "form-content"] }, i( J, C(e, { modelValue: s, indexes: c, prefix: g, "onUpdate:modelValue": (f) => u(f, m) }) ) ), i(I, { icon: Q(Ao), type: "danger", circle: !0, class: "form-btn-delete", ariaLabel: r("pro.form.ariaDel"), onClick: () => o(m, c) }) ]); } return () => { let s = []; return j(e.modelValue) && (s = s.concat(e.modelValue.map(l))), a.value && s.push( i(I, { icon: Q(zo), type: "primary", circle: !0, class: "form-btn-add", ariaLabel: r("pro.form.ariaAdd"), onClick: () => d(e.indexes || []) }) ), s; }; } }); function Ta(e) { const t = [ "component", "max", "props", "prop", "children", "span", "offset", "pull", "push", "xs", "sm", "md", "lg", "xl", "show" ]; return $(e) ? N(e, t) : {}; } function Ce(e) { const t = ["prop", "type", "children"]; return $(e) ? N(e, t) : {}; } const Ba = B({ name: "ProGroupForm", props: be, emits: ue, setup(e, { emit: t, attrs: n }) { const r = H(), a = le(e); function d(u) { t("update:modelValue", u); } function o(u, l) { return u.show === !1 ? null : [ i( "div", C(Ce(u), n, { key: u.prop || l, class: ["pro-group-form-title", !(r != null && r.props.inline) && "el-col-24"] }), a(u) ), i( J, C(e, { columns: u.children, "onUpdate:modelValue": d }) ) ]; } return () => { var u; return (u = e.columns) == null ? void 0 : u.map(o); }; } }), Ra = B({ name: "ProTabsForm", props: be, emits: Ut, setup(e, { emit: t }) { var s, m; const n = H(), r = le(e), { rowStyle: a, rowClass: d } = De(e), o = D((m = (s = e.columns) == null ? void 0 : s[0].prop) != null ? m : 0); function u(c) { t("update:modelValue", c); } function l() { var c; return (c = e.columns) == null ? void 0 : c.map((g, f) => g.show === !1 ? null : i( pt, C(Ce(g), { key: g.prop || f, label: g.label, name: g.prop || f, class: !(n != null && n.props.inline) && d.value, style: e.inline ? null : a.value }), { label: () => r(g), default: () => i( J, C(e, { columns: g.children, "onUpdate:modelValue": u }) ) } )); } return () => i( gt, { modelValue: o.value, class: ["pro-tabs-form", !(n != null && n.props.inline) && "el-col-24"], onTabChange: n == null ? void 0 : n.tabsChange, "onUpdate:modelValue": (c) => o.value = c }, () => l() ); } }), Fa = B({ name: "ProCollapseForm", props: be, emits: Gt, setup(e, { emit: t }) { const n = H(), r = le(e), a = D(); function d(u) { t("update:modelValue", u); } function o() { var u; return (u = e.columns) == null ? void 0 : u.map((l, s) => l.show === !1 ? null : i( ro, C(Ce(l), { key: l.prop || s, title: l.label, name: l.prop || s }), { title: () => r(l), default: () => i( J, C(e, { columns: l.children, "onUpdate:modelValue": d }) ) } )); } return () => i( lo, { modelValue: a.value, class: ["pro-collapse-form", !(n != null && n.props.inline) && "el-col-24"], onChange: n == null ? void 0 : n.collapseChange, "onUpdate:modelValue": (u) => a.value = u }, () => o() ); } }), Ea = B({ name: "ProStepsForm", props: be, emits: Ht, setup(e, { emit: t, attrs: n }) { var h; const r = H(), a = le(e), d = Lt((r == null ? void 0 : r.props) || {}), o = D(0), u = x(() => { var p; if (j(e.columns)) return (p = e.columns[o.value].children) == null ? void 0 : p.reduce((b, w) => w.prop ? [...b, w.prop] : b, []); }); r && (((h = e.columns) == null ? void 0 : h.length) || 0) > 1 && (r.disabled.value = !0); function l(p) { p > 0 && j(u.value) ? r == null || r.formRef.value.validateField(u.value, (b) => { b && s(p); }) : (s(p), rt(() => { r == null || r.formRef.value.clearValidate(u.value); })); } function s(p) { var w, F; o.value = o.value + p; const b = (w = e.columns) == null ? void 0 : w[o.value].prop; r && (r.disabled.value = o.value + 1 !== ((F = e.columns) == null ? void 0 : F.length), r.stepChange(b != null ? b : o.value)); } function m(p) { t("update:modelValue", p); } function c() { if (j(e.columns)) return i( uo, C(n, { active: o.value, alignCenter: !0, class: ["pro-steps-form", !(r != null && r.props.inline) && "el-col-24"] }), () => { var p; return (p = e.columns) == null ? void 0 : p.map((b, w) => b.show === !1 ? null : i( so, C(Ce(b), { key: b.prop || w, title: b.label }), { title: () => a(b) } )); } ); } function g() { if (!j(e.columns)) return; const p = e.columns[o.value]; return p.show === !1 ? null : i( J, C(e, { columns: p.children, "onUpdate:modelValue": m }) ); } function f() { if (j(e.columns)) return i(Te, { class: "pro-steps-form-menu" }, () => { var p; return [ i( I, C(d.value.prevProps || {}, { disabled: !o.value, onClick: () => l(-1) }), () => d.value.prevText ), i( I, C(d.value.nextProps || {}, { disabled: o.value + 1 === ((p = e.columns) == null ? void 0 : p.length), onClick: () => l(1) }), () => d.value.nextText ) ]; }); } return () => [c(), g(), f()]; } }), Oa = B({ name: "ProFormComponent", props: Sa, setup(e, { attrs: t, emit: n }) { const r = ["input", "textarea", "select"], a = x(() => M(e.is) && !r.includes(e.is) ? Nn(e.is) : e.is), d = x(() => { const u = C({ ref: e._ref }, t); return M(e.is) && r.includes(e.is) && (e.is === "select" || t.type === "checkbox" || t.type === "radio" ? (u.checked = t.modelValue, u.onChange = (l) => n("update:modelValue", l.target.checked)) : (u.value = t.modelValue, u.onInput = (l) => n("update:modelValue", l.target.value)), u.modelValue = void 0), u; }), o = x(() => { if (L(e.slots)) return e.slots; if ($(e.slots)) { const u = {}; for (const l in e.slots) { const s = e.slots[l]; u[l] = L(s) ? s : () => s; } return u; } else return e.slots ? () => e.slots : void 0; }); return () => i(a.value, d.value, o.value); } }), ja = B({ name: "ProFormItem", props: Kt, emits: ue, setup(e, { emit: t }) { const n = H(), r = ct(), a = le(e), { colStyle: d, colClass: o } = St(e.item), u = x(() => { var g; return ((g = e.item.models) != null ? g : [ e.item.modelKey ? j(e.item.modelKey) ? { prop: e.item.prop, key: e.item.modelKey[0], event: e.item.modelKey[1] } : { prop: e.item.prop, key: e.item.modelKey } : { prop: e.item.prop, key: "modelValue" } ]).reduce((f, h) => { var p; return P(v({}, f), { [h.key]: _(e.modelValue, h.prop, void 0), [(p = h.event) != null ? p : `onUpdate:${h.key}`]: (b) => t("update:modelValue", nt(e.modelValue, h.prop, b)) }); }, {}); }); e.item.modelKey && Ee( "[ProForm] The 'modelKey' attribute will be removed in the next major version, please use 'models' instead" ); function l(c) { t("update:modelValue", nt(e.modelValue, e.item.prop, c)); } function s(c) { var g; if (n != null && n.slots[`form-${e.item.prop}-error`]) return (n == null ? void 0 : (g = n.slots)[`form-${e.item.prop}-error`]).call(g, P(v({}, c), { item: e.item, indexes: e.indexes })); } function m() { var f, h, p; !Ro(e.modelValue, e.item.prop) && l(void 0); const c = _(e.modelValue, e.item.prop, void 0); let g = []; return (f = e.item.children) != null && f.length ? g = g.concat( i(J, { modelValue: c, columns: e.item.children, prefix: e.prefix, indexes: e.indexes, max: e.item.max, type: e.item.type || "array", "onUpdate:modelValue": l }) ) : n != null && n.slots[`form-${e.item.prop}`] ? g = g.concat( (n == null ? void 0 : (h = n.slots)[`form-${e.item.prop}`]).call(h, P(v({}, u.value), { item: e.item, indexes: e.indexes, value: c, setValue: l })) ) : e.item.component && g.push( i( Oa, C(e.item.props || {}, P(v({}, u.value), { is: e.item.component, // Replace ref with _ref to avoid binding to ProFormComponent ref: void 0, _ref: (p = e.item.props) == null ? void 0 : p.ref })) ) ), g; } return () => e.item.show === !1 ? null : i( Te, C({ size: r.value }, Ta(e.item), { prop: e.prefix, style: n != null && n.props.inline ? void 0 : d.value, class: ["pro-form-item", !(n != null && n.props.inline) && o.value] }), { label: () => a(e.item), error: (c) => s(c), default: () => m() } ); } }), J = B({ name: "ProFormList", props: Va, emits: ye, setup(e, { emit: t }) { function n(a) { t("update:modelValue", a); } function r() { if (!e.columns) return; const a = [], d = e.columns.length; let o, u = 0, l = u; const s = () => { if (!e.columns || !o) return; const m = e.columns.slice(u, l), c = { group: Ba, tabs: Ra, collapse: Fa, steps: Ea }; a.push( i(c[o], { key: `${u}__${l}`, modelValue: e.modelValue, columns: m, prefix: e.prefix, indexes: e.indexes, "onUpdate:modelValue": n }) ), o = void 0, u = l; }; for (; u < d && l < d; ) { const m = e.columns[l], c = Pt(e.prefix, m.prop); m != null && m.type && m.type !== "array" ? !o && u + 1 !== d ? (o = m.type, l = u + 1) : o === m.type && l + 1 !== d ? l++ : (o !== m.type && (s(), o = m.type), l++, l === d && s()) : (o && s(), a.push( i(ja, { key: m.prop, modelValue: e.modelValue, item: m, indexes: e.indexes, prefix: c, "onUpdate:modelValue": n }) ), u++, l++); } return a; } return () => e.type === "array" ? (!j(e.modelValue) && !Z(e.modelValue) && n(void 0), i(wa, { modelValue: e.modelValue, columns: e.columns, prefix: e.prefix, indexes: e.indexes, max: e.max, "onUpdate:modelValue": n })) : r(); } }), Da = B({ name: "ProForm", props: re, emits: ye, setup(e, { slots: t, emit: n, expose: r }) { const [a] = K(e, Pa), { formRef: d, formExpose: o, loading: u, update: l, submitForm: s, resetForm: m } = Ae(n), c = Lt(e), { rowStyle: g, rowClass: f } = De(e), h = Oe(), p = D(!1), b = x(() => { const y = h.value === "xs" && !e.inline; return e.labelPosition || (y ? "top" : void 0); }), w = x(() => e.gutter ? { paddingLeft: `${e.gutter / 2}px`, paddingRight: `${e.gutter / 2}px` } : {}); ya({ props: e, emit: n, slots: t, formRef: d, disabled: p }), r(o); function F() { return i( J, C(e, { type: e.array ? "array" : void 0, "onUpdate:modelValue": l }) ); } function z() { let y = []; return t["menu-left"] && (y = y.concat(t["menu-left"]({ loading: u.value }))), c.value.submit && y.push( i( I, C(c.value.submitProps || {}, { loading: u.value, disabled: p.value, onClick: s }), () => c.value.submitText ) ), c.value.reset && y.push( i( I, C(c.value.resetProps || {}, { disabled: u.value, onClick: () => m() }), () => c.value.resetText ) ), t["menu-right"] && (y = y.concat(t["menu-right"]({ loading: u.value }))), i( Te, { class: "pro-form-menu", style: w.value }, () => y ); } return () => i( co, C(a, { ref: d, model: e.modelValue || {}, labelPosition: b.value, style: e.inline ? null : g.value, class: [ "pro-form", !e.inline && f.value, e.array && "is-array" ], onSubmit: (y) => { y.preventDefault(); } }), () => [F(), t.default && t.default(), z()] ); } }); function Gl(e) { return e; } function Hl(e) { return e; } function ql(e) { return e; } const Le = E(Da); function za(e) { return x(() => ({ showOverflowTooltip: e.showOverflowTooltip || !1, align: e.align, headerAlign: e.headerAlign })); } function ne(e, t) { return x(() => { const n = de(e), r = de(t), a = $(n) ? v({}, n) : void 0; return a && (a.slot && delete a.slot, a.children && delete a.children), Object.assign({}, r, a); }); } function qt() { const e = we({}), t = fe({}), n = [ "clearSelection", "getSelectionRows", "toggleRowSelection", "toggleAllSelection", "toggleRowExpansion", "setCurrentRow", "clearSort", "clearFilter", "doLayout", "sort", "scrollTo", "setScrollTop", "setScrollLeft", "columns", "updateKeyChildren" ]; return he(() => { Object.assign(t, ge(e.value, n)); }), { tableRef: e, tableExpose: t }; } function Wt(e) { function t(a) { e("update:pageSize", a); } function n(a) { e("update:currentPage", a); } function r() { e("load"); } return { sizeChange: t, currentChange: n, handleLoad: r }; } const Zt = Object.keys(vt), Ne = P(v({}, vt), { prevIcon: { type: [String, Object, Function], default: void 0 }, nextIcon: { type: [String, Object, Function], default: void 0 }, selection: { type: [Boolean, Object], default: !1 }, expand: { type: [Boolean, Object], default: void 0 }, index: { type: [Boolean, Object], default: !1 }, menu: { type: [Boolean, Object], default: void 0 }, columns: { type: Array, default: void 0 }, data: { type: Array, default: () => [] }, height: [String, Number], maxHeight: [String, Number], fit: { type: Boolean, default: !0 }, stripe: Boolean, border: Boolean, rowKey: [String, Function], showHeader: { type: Boolean, default: !0 }, showSummary: Boolean, sumText: String, summaryMethod: Function, rowClassName: [String, Function], rowStyle: [Object, Function], cellClassName: [String, Function], cellStyle: [Object, Function], headerRowClassName: [String, Function], headerRowStyle: [Object, Function], headerCellClassName: [String, Function], headerCellStyle: [Object, Function], highlightCurrentRow: Boolean, currentRowKey: [String, Number], emptyText: String, expandRowKeys: Array, defaultExpandAll: Boolean, defaultSort: Object, tooltipEffect: String, spanMethod: Function, selectOnIndeterminate: { type: Boolean, default: !0 }, indent: { type: Number, default: 16 }, treeProps: { type: Object, default: () => ({ hasChildren: "hasChildren", children: "children" }) }, lazy: Boolean, load: Function, style: { type: Object, default: () => ({}) }, className: { type: String, default: "" }, tableLayout: { type: String, default: "fixed" }, scrollbarAlwaysOn: Boolean, flexible: Boolean, showOverflowTooltip: Boolean, align: String, headerAlign: String, size: String }), Aa = { item: { type: Object, required: !0, default: () => ({}) }, size: String }, Jt = { "update:currentPage": (e) => X(e), "update:pageSize": (e) => X(e), load: () => !0 }, $a = Object.keys(Ne).filter( (e) => ![ ...Zt.filter((t) => t !== "size"), "showOverflowTooltip", "align", "headerAlign" ].includes(e) ), Qt = B({ name: "ProTableItem", props: Aa, setup(e, { slots: t }) { const n = Se("defaultBind"), r = ne(e.item, n); function a(o) { return t[`table-${e.item.prop}-header`] ? t[`table-${e.item.prop}-header`](P(v({}, o), { size: e.size })) : e.item.label; } function d(o) { const u = []; if (e.item.children && e.item.children.length) { const l = e.item.children.map((s) => i( Qt, { item: s, key: s.prop, size: e.size }, t )); u.push(l); } else t[`table-${e.item.prop}`] ? u.push( t[`table-${e.item.prop}`](P(v({}, o), { size: e.size })) ) : e.item.render ? u.push( L(e.item.render) ? e.item.render(o.row) : String(e.item.render) ) : u.push(_(o.row, e.item.prop, "")); return u; } return () => i(te, r.value, { header: (o) => a(o), default: (o) => d(o) }); } }), La = B({ name: "ProTable", props: Ne, emits: Jt, setup(e, { slots: t, emit: n, expose: r }) { const { selection: a, expand: d, index: o, menu: u } = Ve(e), l = oe(), s = za(e), m = ne( a, s ), c = ne(d, s), g = ne(o, s), f = ne(u, s), { sizeChange: h, currentChange: p, handleLoad: b } = Wt(n), { tableRef: w, tableExpose: F } = qt(), [z, y] = K( e, $a, Zt ); ke("defaultBind", s), r(F); function S() { let T = []; if (a.value && T.push( i( te, C(m.value, { type: "selection" }) ) ), d.value !== !1 && t.expand && T.push( i(te, C(c.value, { type: "expand" }), { default: (A) => t.expand && t.expand(A) }) ), o.value && T.push( i(te, C(g.value, { type: "index" })) ), e.columns) { const A = e.columns.map((U) => U.hide ? null : i( Qt, { item: U, key: U.prop, size: e.size }, t )); T = T.concat(A); } return t.default && (T = T.concat(t.default())), u.value !== !1 && t.menu && T.push( i(te, C(f.value, { type: "menu" }), { default: (A) => t.menu && t.menu(P(v({}, A), { size: e.size })) }) ), T; } function V() { const T = i( io, C(z, l.value, { ref: w }), { default: () => S(), append: t.append } ), A = i( fo, C(y, { "onUpdate:pageSize": h, "onUpdate:currentPage": p, onChange: b }) ); return [ T, !Z(e.total) || !Z(e.pageCount) ? A : null ]; } return () => i("div", { class: "pro-table" }, V()); } }); function Wl(e) { return e; } function Zl(e) { return e; } function Jl(e) { return e; } function Ql(e) { return e; } function Xl(e) { return e; } const Xt = E(La); function Na(e) { const { t } = Y(); return x(() => { const n = P(v({}, $t), { add: !0, addProps: { type: "primary" }, edit: !0, editProps: { link: !0, type: "primary" }, detail: !0, detailProps: { link: !0, type: "info" }, del: !0, delProps: { link: !0, type: "danger" }, search: !0, searchProps: { type: "primary" }, searchReset: !0, addText: t("pro.crud.add"), editText: t("pro.crud.edit"), detailText: t("pro.crud.detail"), delText: t("pro.crud.del"), submitText: t("pro.crud.submit"), resetText: t("pro.crud.reset"), prevText: t("pro.crud.prev"), nextText: t("pro.crud.next"), searchText: t("pro.crud.search"), searchResetText: t("pro.crud.reset"), searchPrevText: t("pro.crud.prev"), searchNextText: t("pro.crud.next") }); return $(e.menu) ? Object.assign({}, n, e.menu) : n; }); } function Yt(e) { const t = x(() => e.searchColumns ? e.searchColumns : e.columns ? q(e.columns, "search") : void 0), n = x(() => e.tableColumns || e.columns), r = x(() => e.addColumns ? e.addColumns : e.columns ? q(e.columns, "add") : void 0), a = x(() => e.editColumns ? e.editColumns : e.columns ? q(e.columns, "edit") : void 0), d = x(() => e.formColumns ? e.formColumns : e.columns ? q(e.columns, "form") : void 0), o = x(() => e.detailColumns ? e.detailColumns : e.columns ? q(e.columns, "detail", !0, (u) => P(v({}, u), { span: u.detailSpan })) : void 0); return { searchColumns: t, tableColumns: n, addColumns: r, editColumns: a, formColumns: d, detailColumns: o }; } function _a({ emit: e, openDialog: t, closeDialog: n }) { const r = D(), { tableRef: a, tableExpose: d } = qt(), { formRef: o, update: u, resetForm: l } = Ae( e ), s = fe({ searchRef: r, formRef: o, openDialog: t, closeDialog: n }); return he(() => { Object.assign(s, d); }), { searchRef: r, tableRef: a, formRef: o, update: u, resetForm: l, crudExpose: s }; } function Ka(e, t, n) { const { addColumns: r, editColumns: a, formColumns: d } = Yt(e), o = $e(t), u = D(!1), l = D("add"), s = x(() => d.value && d.value.length ? d.value : l.value === "add" ? r.value : a.value), m = (f, h, p) => { function b() { f(), n(!0), u.value = !1; } t("submit", b, f, l.value, h, p); }; function c(f, h) { function p() { l.value = f, u.value = !0; } t(f, h), L(e.beforeOpen) ? e.beforeOpen(p, f, h) : p(); } function g() { u.value = !1; } return P(v({}, o), { showDialog: u, type: l, formColumns: s, openDialog: c, closeDialog: g, submitForm: m }); } function Ia(e) { return x(() => ({ submit: e.value.search, submitText: e.value.searchText, submitProps: e.value.searchProps, reset: e.value.searchReset, resetText: e.value.searchResetText, resetProps: e.value.searchResetProps, prevText: e.value.searchPrevText, prevProps: e.value.searchPrevProps, nextText: e.value.searchNextText, nextProps: e.value.searchNextProps })); } function Ma(e) { const t = (a, d, o) => { e("search", a, d, o); }; function n() { e("searchReset"); } function r(a) { e("update:search", a); } return { searchForm: t, searchReset: n, upSearchData: r }; } function Ua() { const e = ut(), t = {}, n = {}, r = {}, a = {}, d = ["search", "search-menu-left", "search-menu-right"], o = ["table", "table-expand", "table-append"], u = ["form", "form-menu-left", "form-menu-right"], l = ["detail", "detail-title", "detail-extra"]; for (const s in e) { const m = e[s]; if (/^search/.test(s)) { const c = d.includes(s) ? s.replace(/^search-?/, "") || "default" : s; t[c] = m; } else if (/^table/.test(s)) { const c = o.includes(s) ? s.replace(/^table-?/, "") || "default" : s; n[c] = m; } else if (/^form/.test(s)) { const c = u.includes(s) ? s.replace(/^form-?/, "") || "default" : s; r[c] = m; } else if (/^detail/.test(s)) { const c = l.includes(s) ? s.replace(/^detail-?/, "") || "default" : s; a[c] = m; } } return { searchSlots: t, tableSlots: n, formSlots: r, detailSlots: a }; } const en = { columns: Array, detail: Object, border: Boolean, column: Number, direction: String, size: String, title: String, extra: String, align: String, labelAlign: String }, tn = N(re, "columns", "menu"), nn = N(Ne, "columns", "menu"), on = N(en, "columns", "title"), an = N(mo, "modelValue"), Ga = Object.keys(tn), Ha = Object.keys(nn), qa = Object.keys( on ), Wa = Object.keys(an), Za = P(v(v(v(v({}, tn), nn), on), an), { columns: Array, addColumns: Array, editColumns: Array, formColumns: Array, searchColumns: Array, tableColumns: Array, detailColumns: Array, menu: [Boolean, Object], search: Object, searchProps: Object, /** * @deprecated The `searchRules` attribute will be removed in the next major version, please use `searchProps` instead */ searchRules: Object, beforeOpen: Function, beforeClose: Function }), Ja = P(v(v({}, ye), Jt), { submit: (e, t, n, r, a) => L(e) && L(t) && M(n) && W(r) && ($(a) || Z(a)), search: (e, t, n) => L(e) && W(t) && ($(n) || Z(n)), searchReset: () => !0, add: () => !0, edit: (e) => $(e), detail: (e) => $(e), delete: (e) => $(e), "update:search": (e) => $(e) }), Qa = P(v({}, re), { config: { type: Object, default: () => ({}) } }), Xa = ye, Ya = { submit: !0, submitProps: { type: "primary" }, reset: !0 }; function el(e) { const { t