UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,572 lines (1,571 loc) 87.4 kB
var Ye = Object.defineProperty; var Xe = (t, e, n) => e in t ? Ye(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n; var I = (t, e, n) => Xe(t, typeof e != "symbol" ? e + "" : e, n); import { defineComponent as oe, toRefs as pe, createVNode as o, Fragment as ie, createTextVNode as j, ref as $, watch as ne, inject as le, getCurrentInstance as Je, onMounted as fe, onUnmounted as ve, computed as V, reactive as Ze, createApp as Ie, Transition as Ke, mergeProps as et, provide as tt, resolveComponent as te, onBeforeMount as nt } from "vue"; import { cloneDeep as ye, isPlainObject as we } from "lodash-es"; import { useDateFormat as ot, withInstall as rt } from "../common/index.esm.js"; import { useI18n as it } from "vue-i18n"; import { LocaleService as lt } from "../locale/index.esm.js"; import { getSchemaByTypeForDesigner as at } from "../dynamic-resolver/index.esm.js"; const st = { // 是否被选中 checked: { type: Boolean, default: !1 }, // 进度条状态 默认'normal' id: { type: String, default: "" }, // 禁用 disabled: { type: Boolean, default: !1 } }, ut = { // 是否显示进度条信息 showInfo: { type: Boolean, default: !0 }, // 进度条状态 默认'normal' status: { type: String, default: "normal" }, // 已完成的分段百分比 percent: { type: Number, default: 0 }, maxWidth: { type: Number, default: 0 } }, ct = { /** * 按钮文本 */ selectText: { type: String, default: "选择文件" }, /** * 禁用 */ disabled: { type: Boolean, default: !1 }, /** * 启用多选 */ enableMulti: { type: Boolean, default: !0 }, /** * 允许上传类型 */ accept: { type: String, default: "*" }, /** * 配置对象 */ options: { type: Object, default: {} }, /** * 已上传附件个数 */ uploadedCount: { type: Number, default: 0 }, /** * 发起服务器端请求,某个组件使用的特殊的参数 */ extendConfig: { type: Object, default: {} }, /** * 附件服务器端服务注入的Token */ uploadServerToken: { type: String, default: "" } }, dt = /* @__PURE__ */ oe({ name: "FUploadProgress", props: ut, setup(t, e) { const { showInfo: n, status: r, maxWidth: l, percent: i } = pe(t); return () => o("div", { class: ["f-progress upload-progress", "upload-progress-status-" + r.value, "f-progress-status-" + r.value, "upload-progress-line", n.value ? "upload-progress-show-info" : ""] }, [o("div", { class: "upload-progress-outer", style: { "max-width": l.value > 0 ? l.value + "px" : "auto" } }, [o("div", { class: "upload-progress-inner" }, [o("div", { class: "upload-progress-bg f-progress-bg", style: { width: i.value + "%" } }, null)])]), n.value ? o("span", { class: "upload-progress-text" }, [r.value === "error" || r.value === "success" ? o("span", { class: ["upload-progress-text-icon f-icon", "f-icon-" + r.value] }, null) : o(ie, null, [i.value, j("%")])]) : ""]); } }), Ee = /* @__PURE__ */ oe({ name: "FPreviewCheckbox", props: st, emits: ["checkedChange"], setup(t, e) { const { disabled: n } = pe(t), r = $(t.checked), l = (i) => { i.stopPropagation(), n.value || (r.value = !r.value, e.emit("checkedChange", { checked: r.value, id: t.id })); }; return ne(() => t.checked, (i) => { r.value = i; }), () => o("div", { class: "preview-checkbox d-inline-flex align-middle" }, [o("div", { class: "custom-control custom-checkbox f-checkradio-single m-0" }, [o("input", { title: "custom-control-input", class: "custom-control-input", type: "checkbox", disabled: n.value, checked: r.value }, null), o("label", { class: "custom-control-label", onClick: (i) => l(i), onMousedown: (i) => i.stopPropagation() }, null)])]); } }), De = /* @__PURE__ */ oe({ name: "FFileSelect", props: ct, emits: ["change", "stateChange"], setup(t, e) { const n = le("uploaderService"); n.setUploadContext(e); const r = Je(), l = $("*"); let i; const a = () => { i.files && (e.emit("change", i.files), n.handleFiles(i.files), i.value = null); }; function f() { i.value = null, n.reset(); } ne(() => t.disabled, () => { f(); }), ne(() => t.uploadedCount, (m) => { n.setOptions({ uploadedCount: m }); }), ne(() => t.extendConfig, (m) => { n.setExtendServerConfig(m); }); function T(m) { m && m.stopPropagation(), i.click(); } function g(m) { n.handleUploadEvent(m); } return fe(() => { var m, c; i = (m = r == null ? void 0 : r.proxy) == null ? void 0 : m.$refs.uploadInput, f(), n.setOptions(t.options), n.setExtendServerConfig(t.extendConfig), l.value = (((c = t.options) == null ? void 0 : c.allowedContentTypes) || ["*"]).join(","); }), ve(() => { }), e.expose({ handleUploadEvent: g }), () => o(ie, null, [o("input", { ref: "uploadInput", type: "file", class: "ffileupload--browser", disabled: t.disabled, multiple: t.enableMulti, accept: l.value, onChange: () => a(), style: "width: 10px", title: "uploadInput" }, null), o("div", { class: ["upload-container", t.disabled ? "f-state-disabled" : ""], onClick: (m) => T(m), title: t.selectText }, [o("i", { class: "f-icon f-icon-upload upload-icon", style: "top: 2px;position: relative;" }, null), t.selectText])]); } }); function Me(t, e) { let n; function r(c) { const { properties: p, title: y, ignore: u } = c, s = u && Array.isArray(u), v = Object.keys(p).reduce((x, M) => ((!s || !u.find((C) => C === M)) && (x[M] = p[M].type === "object" && p[M].properties ? r(p[M]) : ye(p[M].default)), x), {}); if (y && (!s || !u.find((x) => x === "id"))) { const x = y.toLowerCase().replace(/-/g, "_"); v.id = `${x}_${Math.random().toString().slice(2, 6)}`; } return v; } function l(c) { const { properties: p, title: y, required: u } = c; if (u && Array.isArray(u)) { const s = u.reduce((v, x) => (v[x] = p[x].type === "object" && p[x].properties ? r(p[x]) : ye(p[x].default), v), {}); if (y && u.find((v) => v === "id")) { const v = y.toLowerCase().replace(/-/g, "_"); s.id = `${v}_${Math.random().toString().slice(2, 6)}`; } return s; } return { type: y }; } function i(c, p = {}, y) { const u = t[c]; if (u) { let s = l(u); const v = e[c]; return s = v ? v({ getSchemaByType: i }, s, p, y) : s, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(s), s; } return null; } function a(c, p) { const y = r(p); return Object.keys(y).reduce((u, s) => (Object.prototype.hasOwnProperty.call(c, s) && (u[s] && we(u[s]) && we(c[s] || !c[s]) ? Object.assign(u[s], c[s] || {}) : u[s] = c[s]), u), y), y; } function f(c, p) { return Object.keys(c).filter((u) => c[u] != null).reduce((u, s) => { if (p.has(s)) { const v = p.get(s); if (typeof v == "string") u[v] = c[s]; else { const x = v(s, c[s], c); Object.assign(u, x); } } else u[s] = c[s]; return u; }, {}); } function T(c, p, y = /* @__PURE__ */ new Map()) { const u = a(c, p); return f(u, y); } function g(c) { var y; const p = c.type; if (p) { const u = t[p]; if (!u) return c; const s = a(c, u), v = ((y = c.editor) == null ? void 0 : y.type) || ""; if (v) { const x = t[v], M = a(c.editor, x); s.editor = M; } return s; } return c; } function m(c) { n = c; } return { getSchemaByType: i, resolveSchemaWithDefaultValue: g, resolveSchemaToProps: T, mappingSchemaToProps: f, setDesignerContext: m }; } const Be = {}, Pe = {}, { getSchemaByType: kn, resolveSchemaWithDefaultValue: pt, resolveSchemaToProps: ft, mappingSchemaToProps: vt, setDesignerContext: En } = Me(Be, Pe); function mt(t = {}) { function e(g, m, c, p) { if (typeof c == "number") return p[g].length === c; if (typeof c == "object") { const y = Object.keys(c)[0], u = c[y]; if (y === "not") return Number(p[g].length) !== Number(u); if (y === "moreThan") return Number(p[g].length) >= Number(u); if (y === "lessThan") return Number(p[g].length) <= Number(u); } return !1; } function n(g, m, c, p) { return p[g] && p[g].propertyValue && String(p[g].propertyValue.value) === String(c); } const r = /* @__PURE__ */ new Map([ ["length", e], ["getProperty", n] ]); Object.keys(t).reduce((g, m) => (g.set(m, t[m]), g), r); function l(g, m) { const c = g; return typeof m == "number" ? [{ target: c, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: c, operator: "getProperty", param: g, value: !!m }] : typeof m == "object" ? Object.keys(m).map((p) => { if (p === "length") return { target: c, operator: "length", param: null, value: m[p] }; const y = p, u = m[p]; return { target: c, operator: "getProperty", param: y, value: u }; }) : []; } function i(g) { return Object.keys(g).reduce((c, p) => { const y = l(p, g[p]); return c.push(...y), c; }, []); } function a(g, m) { if (r.has(g.operator)) { const c = r.get(g.operator); return c && c(g.target, g.param, g.value, m) || !1; } return !1; } function f(g, m) { return i(g).reduce((y, u) => y && a(u, m), !0); } function T(g, m) { const c = Object.keys(g), p = c.includes("allOf"), y = c.includes("anyOf"), u = p || y, x = (u ? g[u ? p ? "allOf" : "anyOf" : "allOf"] : [g]).map((C) => f(C, m)); return p ? !x.includes(!1) : x.includes(!0); } return { parseValueSchema: T }; } const ht = { convertTo: (t, e, n, r) => { t.appearance || (t.appearance = {}), t.appearance[e] = n; }, convertFrom: (t, e, n) => t.appearance ? t.appearance[e] : t[e] }, gt = { convertFrom: (t, e, n) => t.buttons && t.buttons.length ? `共 ${t.buttons.length} 项` : "无" }, bt = { convertTo: (t, e, n, r) => { t.editor && (t.editor[e] = n); }, convertFrom: (t, e, n) => t.editor && Object.prototype.hasOwnProperty.call(t.editor, e) ? t.editor[e] : t[e] }, He = { button: { type: "button", name: "按钮" }, "response-toolbar": { type: "response-toolbar", name: "工具栏" }, "response-toolbar-item": { type: "response-toolbar-item", name: "按钮" }, "content-container": { type: "content-container", name: "容器" }, "input-group": { type: "input-group", name: "文本" }, textarea: { type: "textarea", name: "多行文本" }, lookup: { type: "lookup", name: "帮助" }, "number-spinner": { type: "number-spinner", name: "数值" }, "date-picker": { type: "date-picker", name: "日期" }, switch: { type: "switch", name: "开关" }, "radio-group": { type: "radio-group", name: "单选组" }, "check-box": { type: "check-box", name: "复选框" }, "check-group": { type: "check-group", name: "复选框组" }, "combo-list": { type: "combo-list", name: "下拉列表" }, "response-form": { type: "response-form", name: "卡片面板" }, "response-layout": { type: "response-layout", name: "布局容器", icon: "response-layout-3" }, "response-layout-item": { type: "response-layout-item", name: "布局", icon: "response-layout-1" }, "tree-grid": { type: "tree-grid", name: "树表格" }, "tree-grid-column": { type: "tree-grid-column", name: "树表格列" }, "data-grid": { type: "data-grid", name: "表格" }, "data-grid-column": { type: "data-grid-column", name: "表格列" }, module: { type: "Module", name: "模块" }, component: { type: "component", name: "组件" }, tabs: { type: "tabs", name: "标签页" }, "tab-page": { type: "tab-page", name: "标签页项", dependentParentControl: "Tab" }, "tab-toolbar-item": { type: "tab-toolbar-item", name: "标签页工具栏按钮" }, "html-template": { type: "html-template", name: "模板容器" }, "time-picker": { type: "time-picker", name: "时间选择" }, section: { type: "section", name: "分组面板" }, "section-toolbar": { type: "section-toolbar", name: "分组面板工具栏" }, "section-toolbar-item": { type: "section-toolbar-item", name: "分组面板按钮" }, splitter: { type: "splitter", name: "分栏面板" }, "splitter-pane": { type: "splitter-pane", name: "分栏面板项", dependentParentControl: "Splitter" }, "component-ref": { type: "component-ref", name: "组件引用节点" }, uploader: { type: "uploader", name: "附件上传" }, "page-header": { type: "page-header", name: "页头" }, "page-footer": { type: "page-footer", name: "页脚" }, "tab-toolbar": { type: "tab-toolbar", name: "标签页工具栏" }, fieldset: { type: "fieldset", name: "分组" }, "query-solution": { type: "query-solution", name: "筛选方案" }, drawer: { type: "drawer", name: "抽屉" }, "external-container": { type: "external-container", name: "外部容器", icon: "content-container" }, "list-nav": { type: "list-nav", name: "列表导航" }, "list-view": { type: "list-view", name: "列表" }, "filter-bar": { type: "filter-bar", name: "筛选条" }, "language-textbox": { type: "language-textbox", name: "多语输入框" } }, yt = { convertFrom: (t, e, n) => { var l; const r = t.editor && t.editor[e] ? t.editor[e] : t[e]; return ((l = He[r]) == null ? void 0 : l.name) || r; } }, wt = { convertTo: (t, e, n, r) => { t[e] = t[e]; }, convertFrom: (t, e, n) => t.editor ? n.getRealEditorType(t.editor.type) : "" }, St = { convertTo: (t, e, n, r) => { (t.type === "data-grid-column" || t.type === "tree-grid-column") && (t.formatter ? t.formatter[e] = n : t.formatter = { [e]: n }); }, convertFrom: (t, e, n) => { if (t.formatter) { if (e === "trueText") return t.formatter.trueText; if (e === "falseText") return t.formatter.falseText; if (e === "prefix") return t.formatter.prefix; if (e === "suffix") return t.formatter.suffix; if (e === "precision") return t.formatter.precision; if (e === "decimal") return t.formatter.decimal; if (e === "thousand") return t.formatter.thousand; if (e === "tempDateFormat") return t.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : t.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : t.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : t.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : t.formatter.tempDateFormat || t.formatter.dateFormat || "yyyy-MM-dd"; if (e === "customFormat") return t.formatter.customFormat; if (e === "type") return t.formatter.type || "none"; } return "none"; } }, Ft = { convertTo: (t, e, n, r) => { t.command ? t.command[e] = n : t.command = { [e]: n }, e === "enable" && n && (t.command.commands || (t.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (t, e, n) => t.command && e === "enable" ? t.command.enable : "" }, Tt = { convertTo: (t, e, n, r) => { t.column ? t.column[e] = n : t.column = { [e]: n }, e === "fitColumns" && n && (t.column.fitMode || (t.column.fitMode = "average")); }, convertFrom: (t, e, n) => { if (t.column) { if (e === "fitColumns") return t.column.fitColumns; if (e === "fitMode") return t.column.fitMode; } return ""; } }, Ct = { convertTo: (t, e, n, r) => { t.summary ? t.summary[e] = n : t.summary = { [e]: n }, e === "enable" && n && (t.summary ? t.summary.groupFields || (t.summary.groupFields = []) : t.summary = { enable: n, groupFields: [] }); }, convertFrom: (t, e, n) => t.summary && e === "enable" ? t.summary.enable : t.type === "data-grid-column" ? t.enableSummary === void 0 ? !1 : t.enableSummary : "" }, xt = { convertTo: (t, e, n, r) => { t.group ? t.group[e] = n : t.group = { [e]: n }, e === "enable" && n && (t.group ? t.group.groupFields || (t.group.groupFields = []) : t.group = { enable: n, groupFields: [], showSummary: !1 }); }, convertFrom: (t, e, n) => { if (t.group) { if (e === "enable") return t.group.enable; if (e === "showSummary") return t.group.showSummary; } } }, kt = { convertFrom: (t, e) => t.binding ? t.binding.path : "", convertTo: (t, e, n) => { if (n && n.length > 0) { const r = n[0]; t.binding || (t.binding = {}), t.binding.type = "Form", t.binding.path = r.bindingField, t.binding.field = r.id, t.binding.fullPath = r.path, t.path = r.bindingPath; } } }, Et = { convertTo: (t, e, n, r) => { t.pagination || (t.pagination = {}), t.pagination[e] = n; }, convertFrom: (t, e, n) => t.pagination ? t.pagination[e] : t[e] }, Dt = { convertTo: (t, e, n, r) => { t.rowNumber || (t.rowNumber = {}), t.rowNumber[e] = n; }, convertFrom: (t, e, n) => t.rowNumber ? t.rowNumber[e] : t[e] }, Mt = { convertTo: (t, e, n, r) => { t.selection || (t.selection = {}), t.selection[e] = n; }, convertFrom: (t, e, n) => t.selection ? t.selection[e] : t[e] }, Bt = { convertFrom: (t, e, n) => t[e] && t[e].length ? `共 ${t[e].length} 项` : "" }, Pt = { convertFrom: (t, e) => t[e] || "", convertTo: (t, e, n) => { t[e] = n; } }, Ht = { convertTo: (t, e, n, r) => { t.size || (t.size = {}), t.size[e] = n; }, convertFrom: (t, e, n) => t.size ? t.size[e] : t[e] }, At = { convertFrom: (t, e, n) => { var r, l; return (r = t.formatter) != null && r.data && e === "formatterEnumData" && !t.formatterEnumData ? (l = t.formatter) == null ? void 0 : l.data : t.formatterEnumData; } }, Ot = { convertTo: (t, e, n, r) => { t.sort || (t.sort = {}), t.sort[e] = n; }, convertFrom: (t, e, n) => { var r, l; if (e === "mode") return ((r = t.sort) == null ? void 0 : r.mode) || "client"; if (e === "multiSort") return !!((l = t.sort) != null && l.multiSort); } }, Nt = { convertTo: (t, e, n, r) => { t.filter || (t.filter = {}), t.filter[e] = n; }, convertFrom: (t, e, n) => { var r; if (e === "mode") return ((r = t.filter) == null ? void 0 : r.mode) || "client"; } }, Rt = { convertTo: (t, e, n, r) => { t.rowOption ? t.rowOption[e] = n : t.rowOption = { [e]: n }; }, convertFrom: (t, e, n) => { if (t.rowOption) { if (e === "customRowStyle") return t.rowOption.customRowStyle; if (e === "customCellStyle") return t.rowOption.customCellStyle; } return ""; } }; function Ae(t, e, n) { const r = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", ht], ["/converter/buttons.converter", gt], ["/converter/property-editor.converter", bt], ["/converter/items-count.converter", Bt], ["/converter/type.converter", yt], ["/converter/change-editor.converter", wt], ["/converter/change-formatter.converter", St], ["/converter/column-command.converter", Ft], ["/converter/column-option.converter", Tt], ["/converter/summary.converter", Ct], ["/converter/group.converter", xt], ["/converter/form-group-label.converter", Pt], ["/converter/field-selector.converter", kt], ["/converter/pagination.converter", Et], ["/converter/row-number.converter", Dt], ["/converter/grid-selection.converter", Mt], ["/converter/size.converter", Ht], ["/converter/change-formatter-enum.converter", At], ["/converter/grid-sort.converter", Ot], ["/converter/grid-filter.converter", Nt], ["/converter/row-option.converter", Rt] ]), l = /* @__PURE__ */ new Map([ ["string", { type: "input-group", enableClear: !1 }], ["boolean", { type: "combo-list", textField: "name", valueField: "value", idField: "value", enableClear: !1, editable: !1, data: [ { value: !0, name: "是" }, { value: !1, name: "否" } ] }], ["enum", { type: "combo-list", maxHeight: 128, enableClear: !1, editable: !1 }], ["array", { type: "button-edit" }], ["number", { type: "number-spinner", placeholder: "" }], ["events-editor", { type: "events-editor", hide: !0 }] ]), i = mt(); function a(u, s) { return () => i.parseValueSchema(u, s); } function f(u, s, v) { return u.includes("visible") && s.visible !== void 0 ? typeof s.visible == "boolean" ? () => !!s.visible : s.visible === void 0 ? !0 : a(s.visible, v) : () => !0; } function T(u, s, v) { return u.includes("readonly") && s.readonly !== void 0 ? typeof s.readonly == "boolean" ? () => !!s.readonly : a(s.readonly, v) : () => !1; } function g(u, s) { const v = u.$converter || s; return typeof v == "string" && v && r.has(v) ? r.get(v) || null : v || null; } function m(u, s, v, x, M, C = "", k = "") { return Object.keys(u).map((N) => { const q = $(1), _ = N, w = u[N], L = Object.keys(w), W = w.title, b = w.type, B = l.get(b) || { type: "input-group", enableClear: !1 }, P = w.editor ? Object.assign({}, B, w.editor) : Object.assign({}, B), E = f(L, w, s), S = T(L, w, s); P.readonly = P.readonly === void 0 ? S() : P.readonly; const U = w.type === "cascade" ? m(w.properties, s, v, x, M, C, k) : [], G = !0; let R = g(w, k); const X = V({ get() { if (q.value) { if (["class", "style"].find((Y) => Y === _) && !R && (R = r.get("/converter/appearance.converter") || null), R && R.convertFrom) return R.convertFrom(v, N, M, C); const D = v[N]; return Object.prototype.hasOwnProperty.call(w, "defaultValue") && (D === void 0 || typeof D == "string" && D === "") ? w.type === "boolean" ? w.defaultValue : w.defaultValue || "" : D; } return null; }, set(D) { q.value += 1, R && R.convertTo ? (R.convertTo(x, N, D, M, C), R.convertTo(v, N, D, M, C)) : (x[N] = D, v[N] = D); } }), { refreshPanelAfterChanged: Z, description: re, isExpand: d, parentPropertyID: F } = w, O = { propertyID: _, propertyName: W, propertyType: b, propertyValue: X, editor: P, visible: E, readonly: S, cascadeConfig: U, hideCascadeTitle: G, refreshPanelAfterChanged: Z, description: re, isExpand: d, parentPropertyID: F }; return s[_] = O, O; }); } function c(u, s, v = {}) { const x = {}, M = t[u]; return M && M.categories ? Object.keys(M.categories).map((k) => { const A = M.categories[k], N = A == null ? void 0 : A.title, q = m(A.properties || {}, x, {}, v, s); return { categoryId: k, categoryName: N, properties: q }; }) : []; } function p(u, s, v, x, M = "") { const C = s.$ref.schema, k = s.$ref.converter, A = v[C], N = A.type, q = n(A), _ = {}, w = t[N]; if (w && w.categories) { const L = w.categories[u], W = L == null ? void 0 : L.title; k && Object.keys(L.properties).forEach((P) => { L.properties[P].$converter = k; }); const b = (L == null ? void 0 : L.properties) || {}, B = m(b, _, q, A, x, M); return { categoryId: u, categoryName: W, properties: B }; } return { categoryId: u, categoryName: "", properties: [] }; } function y(u, s, v, x, M) { const C = u.type, k = n(u), A = {}; let N = M || t[C]; if (N && Object.keys(N).length === 0 && v && v.getPropConfig && (N = v.getPropConfig(x)), N && N.categories) { const q = []; return Object.keys(N.categories).map((_) => { const w = N.categories[_]; if (w.$ref) { q.push(p(_, w, u, s, x)); return; } const L = w == null ? void 0 : w.title, W = w == null ? void 0 : w.tabId, b = w == null ? void 0 : w.tabName, B = w == null ? void 0 : w.hide, P = w == null ? void 0 : w.hideTitle, E = m(w.properties || {}, A, k, u, s, x, w.$converter), { setPropertyRelates: S } = w, U = w == null ? void 0 : w.parentPropertyID; q.push({ categoryId: _, categoryName: L, tabId: W, tabName: b, hide: B, properties: E, hideTitle: P, setPropertyRelates: S, parentPropertyID: U }); }), q; } return []; } return { getPropertyConfigBySchema: y, getPropertyConfigByType: c, propertyConverterMap: r }; } const Oe = {}, Ne = {}; Ae(Oe, Ne, pt); const Re = {}, je = {}, { getSchemaByType: Dn, resolveSchemaWithDefaultValue: jt, resolveSchemaToProps: Mn, mappingSchemaToProps: Bn, setDesignerContext: Pn } = Me(Re, je), Ue = {}, ze = {}; Ae(Ue, ze, jt); function Ut(t, e, n = /* @__PURE__ */ new Map(), r = (a, f, T, g) => f, l = {}, i = (a) => a) { return Be[e.title] = e, Pe[e.title] = r, Oe[e.title] = l, Ne[e.title] = i, Re[e.title] = e, je[e.title] = r, Ue[e.title] = l, ze[e.title] = i, (a = {}, f = !0) => { if (!f) return vt(a, n); const T = ft(a, e, n), g = Object.keys(t).reduce((m, c) => (m[c] = t[c].default, m), {}); return Object.assign(g, T); }; } const zt = "https://json-schema.org/draft/2020-12/schema", $t = "https://farris-design.gitee.io/uploader.schema.json", Lt = "uploader", qt = "A Farris Component", _t = "object", Vt = { id: { description: "The unique identifier for uploader", type: "string" }, type: { description: "The type string of uploader", type: "string", default: "uploader" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disable: { type: "boolean", default: !1 }, placeholder: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, visible: { description: "", type: "boolean", default: !0 } }, Qt = [ "id", "type" ], Wt = { $schema: zt, $id: $t, title: Lt, description: qt, type: _t, properties: Vt, required: Qt }; function Gt(t, e) { return { customClass: e.class, customStyle: e.style }; } const Yt = /* @__PURE__ */ new Map([ ["appearance", Gt] ]); function Xt(t, e, n) { return e; } const Jt = "uploader", Zt = "A Farris Component", It = "object", Kt = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } }, appearance: { description: "外观", title: "外观", properties: { contentFill: { description: "内容填充", title: "内容填充", type: "boolean" } } }, server: { description: "服务器配置", title: "服务器配置", properties: { rootId: { description: "附件服务器根目录", title: "附件服务器根目录", type: "string" }, formId: { description: "必填,根据【附件信息】业务字段所在位置区分:1、在子表,二级目录建议绑定主表ID。2:在主表:二级目录建议填写当前表数据ID", title: "二级目录", type: "string" } } }, upload: { description: "上传配置", title: "上传配置", properties: { uploadVisible: { description: "上传按钮是否可见", title: "上传是否可见", type: "boolean" }, uploadDisabled: { description: "禁用时,上传按钮可见,但不可用", title: "上传是否禁用", type: "boolean" }, allowEmpty: { description: "运行时是否允许不上传附件", title: "是否允许为空", type: "boolean" }, uploadSelectText: { description: "选择文件按钮文本", title: "选择文件按钮文本", type: "string" }, uploadOptions: { description: "附件上传配置", title: "附件上传配置", type: "cascade", isExpand: !0, properties: { maxUploads: { description: "值为0时表示不限制上传个数", title: "最大上传个数", type: "number" }, maxFileSize: { description: "单个附件最大值(MB)", title: "单个附件最大值(MB)", type: "number" }, allowedContentTypes: { description: "允许上传附件类型", title: "允许上传附件类型", type: "string" }, notAllowedCharsInFileName: { description: "文件名禁用字符", title: "文件名禁用字符", type: "string" } } }, enableUploadedCount: { description: "是否启用已上传个数限制", title: "是否启用已上传个数限制", type: "select", editor: { type: "waiting for modification", enum: [] } }, uploadEnableMulti: { description: "是否启用多选附件上传", title: "是否启用多选附件上传", type: "select", editor: { type: "waiting for modification", enum: [] } }, enableSliceUpload: { description: "是否启用分片上传", title: "是否启用分片上传", type: "select", editor: { type: "waiting for modification", enum: [] } }, chunkSize: { description: "分片上传时,每片的大小。单位:M", title: "分片大小(M)", type: "number" } } }, preview: { description: "附件预览", title: "附件预览", properties: { previewVisible: { description: "预览是否可见", title: "预览是否可见", type: "boolean" }, previewReadonly: { description: "预览是否只读", title: "预览是否只读", type: "boolean" }, fieldIdKey: { description: "附件ID字段", title: "附件ID字段", type: "string", editor: { type: "field-selector" } }, fileNameKey: { description: "附件名称字段", title: "附件名称字段", type: "string", editor: { type: "field-selector" } }, previewEnableMulti: { description: "是否启用批量操作", title: "是否启用批量操作", type: "boolean" }, noDelete: { description: "是否禁止删除附件", title: "是否禁止删除附件", type: "boolean" }, noPreview: { description: "是否禁止预览", title: "是否禁止预览", type: "boolean" }, previewDateFormat: { description: "附件上传时间字段的格式化设置,请注意此属性仅针对附件上传时间一个字段,若有自定义预览列,请在预览列编辑器中单独设置时间格式。", title: "附件上传时间格式化", type: "select", editor: { type: "waiting for modification", enum: [] } }, fileSortOrderKey: { description: "排序字段", title: "排序字段", type: "string" }, orderType: { description: "排序类型", title: "排序类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } } }, en = { title: Jt, description: Zt, type: It, categories: Kt }, me = { /** 内容区域填充 */ contentFill: { type: Boolean, default: !1 }, /** 排序字段 */ orderField: { type: String, default: "createTime" }, previewColumns: { type: Array, default: [ { field: "name", width: 200, title: "文件名", checkbox: !0 }, { field: "size", width: 100, title: "大小" }, { field: "createTime", width: 100, title: "日期" }, { field: "state", width: 100, title: "状态" }, { field: "action", width: 100, title: "操作" } ] }, previewVisible: { type: Boolean, default: !0 }, /** 是否启用批量操作 */ previewEnableMulti: { type: Boolean, default: !0 }, /** 默认重命名 */ previewDefaultRename: { type: String, default: "" }, /** 附件上传部分禁用状态 */ uploadDisabled: { type: Boolean, default: !1 }, // 附件上传部分是否可见 uploadVisible: { type: Boolean, default: !0 }, // 需要重置,通过不断的赋值来改变 // @Input() uploadNeedReset: Observable<any> = new Subject(); /** 选择文件按钮上的文字 */ uploadSelectText: { type: String, default: "选择文件" }, /** 启用多选 */ uploadEnableMulti: { type: Boolean, default: !0 }, /** 已经上传文件 */ uploadedCount: { type: Number, default: 0 }, /** 整个控件禁用 */ disabled: { type: Boolean, default: !1 }, /** 下载按钮是否禁用 */ downloadButtonDisable: { type: Boolean, default: !1 }, /** 预览按钮是否禁用 */ previewButtonDisable: { type: Boolean, default: !1 }, /** 删除按钮是否禁用 */ deleteButtonDisable: { type: Boolean, default: !1 }, /** * 自定义展示信息 */ customInfo: { type: String, default: "" }, /** * 处理传递预览的数据 */ fileInfos: { type: Array, default: [] }, /** * 上传配置 */ uploadOptions: { type: Object, default: null }, /** * 发起服务器端请求,某个组件使用的特殊的参数 */ extendConfig: { type: Object, default: {} }, /** * 附件服务器端服务注入的Token */ uploadServerToken: { type: String, default: "" }, /** * 提示服务注入的Token */ notifyServiceToken: { type: String, default: "" } }, $e = Ut(me, Wt, Yt, Xt, en); var K = /* @__PURE__ */ ((t) => (t[t.Queue = 0] = "Queue", t[t.Uploading = 1] = "Uploading", t[t.Done = 2] = "Done", t[t.Cancelled = 3] = "Cancelled", t[t.Remove = 4] = "Remove", t[t.Error = 5] = "Error", t))(K || {}); class tn { constructor(e = {}, n = {}) { /** * 上传配置 */ I(this, "uploadConfig"); /** * 删除配置 */ I(this, "removeConfig"); const r = { type: "config", url: "", timeout: 0, headers: null, data: {} }; this.uploadConfig = Object.assign({}, r, e), this.removeConfig = Object.assign({}, r, n); } } function he(t, e) { const { formatTo: n } = ot(); return n(t, e); } function Se(t, e) { if (!e) return ""; let n = ""; return t.indexOf(".") === -1 && e.hasOwnProperty(t) ? n = e[t] : n = t.split(".").reduce((r, l) => r ? r[l] : null, e), n; } function nn(t) { return (e, n) => { if (!e.hasOwnProperty(t) || e[t] === void 0 || e[t] === null) return 1; if (!n.hasOwnProperty(t) || n[t] === void 0 || n[t] === null) return -1; if (t !== "createTime") { let i = "", a = ""; return t.indexOf(".") > -1 ? (i = Se(t, e), a = Se(t, n)) : (i = e[t], a = n[t]), i > a ? 1 : -1; } const r = new Date(e[t]), l = new Date(n[t]); return r.getTime() > l.getTime() ? -1 : 1; }; } function Le(t) { return (t || []).findIndex((n) => n === "*") === -1; } function qe(t) { return t !== "0 Byte"; } function ae(t) { if (t === 0) return "0 Byte"; const e = 1024, n = ["Bytes", "KB", "MB", "GB", "TB", "PB"], r = Math.floor(Math.log(t) / Math.log(e)); return parseFloat((t / e ** r).toFixed(2)) + " " + n[r]; } function _e(t, e) { return t && (t.hasOwnProperty("allowedContentTypes") && (e.allowedContentTypes = t.allowedContentTypes || ["*"], e.allowedContentTypes = e.allowedContentTypes && e.allowedContentTypes.length > 0 ? e.allowedContentTypes : ["*"]), t.hasOwnProperty("maxUploads") && (e.maxUploads = t.maxUploads || 0), t.hasOwnProperty("maxFileSize") && (e.maxFileSize = ae(1024 * 1024 * (parseInt(String(t.maxFileSize), 10) || 1)))), e; } function Fe(t) { let e = "ffilepreview--filetype"; if (!t) return e + "-any"; const n = t.lastIndexOf("."); let r = ""; switch (n > -1 && (r = t.substring(n + 1).toLocaleLowerCase()), r) { case "pdf": e += "-pdf"; break; case "jpeg": case "jpg": case "gif": case "svg": case "png": case "bmp": e += "-img"; break; case "ppt": case "pptx": e += "-ppt"; break; case "doc": case "docx": e += "-doc"; break; case "xls": case "xlsx": e += "-xls"; break; case "txt": e += "-txt"; break; case "zip": e += "-zip"; break; case "wps": e += "-wps"; break; case "wpt": e += "-wpt"; break; default: e += "-any"; } return e; } function Te(t) { var e; if (t.type === "done") return 100; if (t.file && t.file.progress) { if (t.file.progress.status === K.Uploading) { const n = ((e = t.file.progress.data) == null ? void 0 : e.percentage) || 5; return n > 5 ? n : 5; } return 5; } return 5; } function on(t) { let e = t; return t ? (typeof t == "string" && (e = parseInt(t, 10)), ae(e)) : "0 Byte"; } const rn = () => Math.random().toString(36).substring(7); function Ce(t, e) { return { fileIndex: e, id: rn(), name: t.name, size: t.size, type: t.type, form: new FormData(), progress: { status: K.Queue, data: { percentage: 0, speed: 0, speedHuman: `${ae(0)}/s`, startTime: null, endTime: null, eta: null, etaHuman: null } }, lastModifiedDate: he(new Date(t.lastModified), "yyyy-MM-dd HH:mm:ss"), nativeFile: t }; } function xe(t) { const e = []; return t.forEach((n) => { const r = { id: "", name: "", size: 0, type: "", extend: null, extendHeaders: null, createTime: "" }; for (const l in r) { const i = l.replace("extend", "response").replace("createTime", "lastModifiedDate"); n.hasOwnProperty(i) && (i === "lastModifiedDate" ? r[l] = he(n[i], "yyyy-MM-dd HH:mm:ss") : r[l] = n[i]); } e.push(r); }), e; } function ln(t, e) { return t ? e <= t * 1024 * 1024 : !0; } function an(t) { return t.find((e) => e === "*") !== void 0; } function sn(t, e) { if (!t || t.length === 0 || an(t)) return !0; if (e.lastIndexOf(".") < 0) return !1; const n = e.substr(e.lastIndexOf(".")); return t.findIndex( (r) => r.toLowerCase() === n.toLowerCase() ) > -1; } function un(t) { if (t) return t.split(` `).map((e) => e.split(/: */, 2)).filter((e) => e[0]).reduce((e, n) => (e[n[0]] = n[1], e), {}); } function ke(t) { return new Date(t * 1e3).toISOString().substr(11, 8); } class cn extends tn { upload(e, n, r, l) { const i = e[0]; return new Promise((a, f) => { var x, M; const T = n.url || r.url || "", g = n.method || "POST", m = n.data || {}, c = n.headers || {}, p = new XMLHttpRequest(), y = (/* @__PURE__ */ new Date()).getTime(); let u = ((x = i.progress) == null ? void 0 : x.data) && i.progress.data.startTime || y, s = 0, v = null; p.upload.addEventListener("progress", (C) => { var k; if (C.lengthComputable) { const A = Math.round(C.loaded * 100 / C.total), N = (/* @__PURE__ */ new Date()).getTime() - y; s = Math.round(C.loaded / N * 1e3), u = ((k = i.progress) == null ? void 0 : k.data) && i.progress.data.startTime || (/* @__PURE__ */ new Date()).getTime(), v = Math.ceil((C.total - C.loaded) / s), i.progress = { status: K.Uploading, data: { percentage: A, speed: s, speedHuman: `${ae(s)}/s`, startTime: u, endTime: null, eta: v, etaHuman: ke(v) } }, l({ type: "uploading", files: [i] }); } }, !1), p.upload.addEventListener("error", (C) => { f(C); }), p.onreadystatechange = () => { if (p.readyState === XMLHttpRequest.DONE) { const C = Math.round(i.size / ((/* @__PURE__ */ new Date()).getTime() - u) * 1e3); i.progress = { status: K.Done, data: { percentage: 100, speed: C, speedHuman: `${ae(C)}/s`, startTime: u, endTime: (/* @__PURE__ */ new Date()).getTime(), eta: v, etaHuman: ke(v || 0) } }, i.responseStatus = p.status; try { i.response = JSON.parse(p.response); } catch { i.response = p.response; } i.responseHeaders = un(p.getAllResponseHeaders()), a({ type: "done", files: [i] }); } }, p.open(g, T, !0), p.withCredentials = !!n.withCredentials; try { const C = i.nativeFile; Object.keys(c).forEach((A) => p.setRequestHeader(A, c[A])); let k; n.includeWebKitFormBoundary !== !1 ? (Object.keys(m).forEach((A) => { var N; return (N = i.form) == null ? void 0 : N.append(A, m[A]); }), (M = i.form) == null || M.append(n.fieldName || "file", C, C.name), k = i.form) : k = C, p.send(k); } catch (C) { f(C); } return () => { p.abort(); }; }); } // 删除附件 remove(e, n, r, l) { return new Promise((i, a) => { i({ type: "removed", files: e }); }); } } const dn = { showCloseButton: { type: Boolean, default: !0 }, position: { type: String, default: "top-center" }, timeout: { type: Number, default: 3e3 }, theme: { type: String, default: "bootstrap" }, left: { type: Number }, right: { type: Number }, top: { type: Number }, bottom: { type: Number }, id: { type: String }, animate: { type: String, default: "fadeIn" }, options: { type: Object }, safeHtml: { type: Boolean, default: !0 } }, pn = { showCloseButton: { type: Boolean, default: !0 }, animate: { type: String, default: "fadeIn" }, options: { type: Object } }, de = /* @__PURE__ */ oe({ name: "Toast", props: pn, emits: ["close", "click"], setup: (t, e) => { const { locale: n, t: r } = it(), l = $(t.animate), i = "fadeOut", a = V(() => t.options), f = $(!1), T = V(() => a.value.title && a.value.message), g = V(() => !a.value.title && a.value.message), m = V(() => { const k = { animated: f.value, toast: !0, "toast--only-content": g.value }; return k[t.animate] = !1, k[i] = f.value, k["toasty-type-" + a.value.type] = !0, a.value.theme && (k[a.value.theme] = !0), k; }), c = V(() => { const N = `f-icon-${a.value && a.value.type ? a.value.type.replace("toasty-type-", "") : "default"}`, q = { "f-icon": !0 }; return q[N] = !0, q; }), p = V(() => a.value.title || a.value.message), y = V(() => t.showCloseButton), u = V(() => !!a.value.buttons || !!e.slots.default), s = V(() => n.value === "en" ? { wordBreak: "keep-all", overflowWrap: "break-word" } : {}); function v(k) { k.stopPropagation(), k.preventDefault(), f.value = !1, setTimeout(() => { e.emit("close", a.value); }, 200); } function x(k, A) { } function M(k) { return `f-preten-link ${k.customClass ? k.customClass : ""}`; } ne(l, () => { l.value; }); const C = () => { var k; return o(ie, null, [o("div", { class: "after-toast-msg text-right" }, [!e.slots.default && ((k = a.value.buttons) == null ? void 0 : k.map((A) => o("span", { class: M(A), onClick: (N) => void 0 }, [A.text]))), e.slots.default && e.slots.default()])]); }; return () => o("div", { class: m.value, style: "min-height:44px" }, [y.value && o("button", { title: r("messageBox.close"), class: "toast-close f-btn-icon f-bare", onClick: v }, [o("span", { class: "f-icon modal_close" }, null)]), p.value && o("section", { class: "modal-tips" }, [o("div", { class: "float-left modal-tips-iconwrap" }, [o("span", { class: c.value }, null)]), o("div", { class: "modal-tips-content" }, [T.value && o(ie, null, [o("h5", { class: "toast-title modal-tips-title", innerHTML: a.value.title }, null), o("p", { class: "toast-msg", innerHTML: a.value.message, style: s.value }, null), u.value && C()]), g.value && (a.value.buttons ? o("div", { class: "toast-title-btns-wrapper d-flex" }, [o("h5", { class: "toast-title modal-tips-title only-toast-msg", style: s.value, innerHTML: a.value.message }, null), o("div", { class: "after-toast-title text-right ml-auto" }, [C()])]) : o("h5", { class: "toast-title modal-tips-title only-toast-msg", style: s.value, innerHTML: a.value.message }, null))])])]); } }), ue = /* @__PURE__ */ oe({ name: "Notify", props: dn, emits: ["close", "empty"], setup(t, e) { const n = V(() => ({ "farris-notify": !0 })), r = { left: 12, right: 12, top: 20, bottom: 12 }, l = $(), i = $(t.options), a = $(t.showCloseButton), f = V(() => t.position || "bottom-right"), T = V(() => t.timeout != null ? t.timeout : 3e3), g = V(() => { const p = t.bottom ? t.bottom : r.bottom, y = t.top ? t.top : r.top, u = { transition: "all 0.2s ease", left: f.value.indexOf("left") > -1 ? `${t.left ? t.left : r.left}px` : "", right: f.value.indexOf("right") > -1 ? `${t.right ? t.right : r.right}px` : "", top: f.value.indexOf("top") > -1 ? `${y}px` : "", bottom: f.value.indexOf("bottom") > -1 ? `${p}px` : "" }; return f.value.indexOf("center") > -1 && (u.left = "50%", u.marginLeft = "calc(-24rem / 2)", f.value === "center-center" && (u.top = "50%", u.transform = "translate(-50%, -50%)")), u; }); function m(p) { e.emit("close"); } T.value && setTimeout(() => { m(); }, T.value), e.expose({ closeToast: m, container: l, notifyPosition: f }); function c(p, y) { m(); } return () => o("div", { class: n.value, style: g.value, ref: l }, [o(de, { options: i.value, showCloseButton: a.value, animate: t.animate, onClose: (p) => c(p, i.value) }, null)]); } }); class Ve { constructor() { I(this, "notifyRefs", []); I(this, "globalConfig", Ze({})); } escapeAllHtml(e) { if (typeof e != "string" || !e) return ""; const n = document.createElement("div"); return n.textContent = e || "", n.innerHTML.replace(/\\n/g, "<br>").replace(/\\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\\r/g, ""); } createNotifyInstance(e) { const n = this, l = Object.assign({ timeout: 3e3, position: "bottom-right", showCloseButton: !0, safeHtml: !0 }, this.globalConfig, { ...e }), i = document.createElement("div"); i.style.display = "contents"; const a = Ie({ setup() { var g; const f = $(); function T() { f.value.container.style.transform = "scale(0)", setTimeout(() => { n.updateNotifyPositionForClose(l, f), a.unmount(); }, 220); } if (l.position.indexOf("top") > -1) { const m = n.getNotifyInstances(l.position), c = m[m.length - 1]; if (c) { const p = c.value.container.getBoundingClientRect(); l.top = p.bottom; } } return l.safeHtml && ((g = l.options) != null && g.message) && (l.options.message = n.escapeAllHtml(l.options.message)), ve(() => { document.body.removeChild(i); }), fe(() => { n.updateNotifyPositionForCreate(l, f); }), () => o(Ke, { mode: "out-in", name: "fade", appear: !0 }, { default: () => [o(ue, et({ ref: f }, l, { onClose: T }), null)] }); } }); return a.provide("NotifyService", this), document.body.appendChild(i), a.use(lt.i18n), a.mount(i), a; } getNotifyInstances(e) { return this.notifyRefs.filter((n) => n.value.notifyPosition === e); } updateNotifyPositionForCreate(e, n) { if (this.notifyRefs && this.notifyRefs.length) { const r = window.innerHeight; e.position.indexOf("bottom") > -1 && this.getNotifyInstances(e.position).forEach((l) => { const i = l.value.container.getBoundingClientRect(); l.value.container.style.bottom = i.height + r - i.bottom + "px"; }); } this.notifyRefs = [...this.notifyRefs, n]; } updateNotifyPositionForClose(e, n) { const r = this.notifyRefs.indexOf(n); if (e.position.indexOf("top") > -1) { const l = this.getNotifyInstances(e.position), i = l.indexOf(n); l.slice(i + 1).forEach((a) => { a.value.container.style.top = a.value.container.offsetTop - a.value.container.offsetHeight + "px"; }); } r > -1 && this.notifyRefs.splice(r, 1); } show(e) { return this.createNotifyInstance(e); } buildNotifyProps(e, n) { let r = "", l = "", i, a, f; typeof n == "string" ? r = n : n && (r = n.message || "", l = n.title || "", a = n.position || null, f = n.showCloseButton != null ? n.showCloseButton : null, i = n.timeout != null ? n.timeout : null); const g = { options: { type: e, message: r, title: l } }; return a != null && (g.position = a), f != null && (g.showCloseButton = f), i != null && (g.timeout = i), g; } info(e) { const n = this.buildNotifyProps("info", e); return this.show(n); } success(e) { const n = this.buildNotifyProps("success", e); return this.show(n); } warning(e) { const n = this.buildNotifyProps("warning", e); return this.show(n); } error(e) { const n = this.buildNotifyProps("error", e); return this.show(n); } close(e) { e && e.unmount(); } closeAll() { this.notifyRefs.forEach((e) => { e == null || e.value.closeToast(); }), this.notifyRefs.length = 0; } } const fn = Symbol("NOTIFY_SERVICE_TOKEN"); ue.install = (t) => { t.component(ue.name, ue), t.component(de.name, de); const e = new Ve(); t.provide(fn, e), t.provide("FNotifyService", e); }; const vn = (t = "") => { let e; return t && le(t, null) && (e = le(t)), e || (e = new Ve()), e; }, mn = (t = "") => { let e; if (t && le(t, null)) { const n = le(t); n && n() && (e = n()); } return e || (e = new cn()), e; }, Qe = { getNotify: vn, getServerAPI: mn }; function We(t, e, n) { const r = Qe.getNotify(t.notifyServiceToken), l = $(t.fileInfos), { disabled: i, uploadVisible: a,