UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

947 lines (946 loc) 32.7 kB
var ye = Object.defineProperty; var he = (e, t, a) => t in e ? ye(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a; var Z = (e, t, a) => he(e, typeof t != "symbol" ? t + "" : t, a); import { defineComponent as X, ref as S, computed as M, watch as be, createVNode as f, Fragment as de, reactive as ve, createApp as Fe, onUnmounted as Se, onMounted as ue, Transition as Te, mergeProps as we, onBeforeMount as Ce, createTextVNode as D } from "vue"; import Pe from "../button-edit/index.esm.js"; import xe from "../tree-grid/index.esm.js"; import Ne from "../radio-group/index.esm.js"; import { FormSchemaEntityField$Type as fe, FormSchemaEntityFieldTypeName as ee } from "../common/index.esm.js"; import { createPropsResolver as Be } from "../dynamic-resolver/index.esm.js"; import { LocaleService as te } from "../locale/index.esm.js"; import "bignumber.js"; import { merge as ce } from "lodash-es"; import { FormBindingType as W, SchemaDOMMapping as Ve } from "../property-panel/index.esm.js"; import { FNotifyService as Me } from "../notify/index.esm.js"; import { FDataGrid as Ie } from "../data-grid/index.esm.js"; const Oe = "https://json-schema.org/draft/2020-12/schema", Ee = "https://farris-design.gitee.io/binding-selector.schema.json", ke = "binding-selector", Re = "字段绑定选择器", Le = "object", $e = { disabled: { description: "", type: "boolean", default: !1 }, readonly: { description: "", type: "boolean", default: !1 }, bindingType: { description: "", type: "object", default: {} }, idField: { description: "", type: "string", default: "id" }, title: { description: "", type: "string", default: "字段选择器" }, modalWidth: { description: "", type: "number", default: 800 }, modalHeight: { description: "", type: "number", default: 600 }, separator: { description: "", type: "string", default: "," }, bindingData: { description: "", type: "array", default: [] }, textField: { description: "", type: "string", default: "code" }, editorParams: { description: "", type: "object", default: {} } }, He = { $schema: Oe, $id: Ee, title: ke, description: Re, type: Le, properties: $e }, Ae = [ { field: "name", title: "名称" }, { field: "bindingField", title: "绑定字段" }, { field: "fieldType", title: "字段类型" } ], je = [ { field: "name", title: "名称" }, { field: "code", title: "编号" }, { field: "displayTypeName", title: "变量类型" }, { field: "fromSource", title: "来源" } ], _e = [ { value: "Form", text: "绑定字段" }, { value: "Variable", text: "绑定变量" } ], ie = { disabled: { type: Boolean, default: !1 }, readonly: { type: Boolean, default: !1 }, modelValue: { type: Object, default: null }, bindingType: { type: Object, default: { enable: !0, value: "Form", textField: "text", valueField: "value" } }, data: { type: Array, default: [] }, idField: { type: String, default: "id" }, title: { type: String, default: "字段选择器" }, modalWidth: { type: Number, default: 800 }, modalHeight: { type: Number, default: 600 }, multiSelect: { type: Boolean, default: !1 }, /** * 可选,分隔符 * 默认`,` */ separator: { type: String, default: "," }, bindingData: { type: Array, default: [] }, textField: { type: String, default: "code" }, beforeOpenDialog: { type: Function, default: null }, editorParams: { type: Object, default: null }, onFieldSelected: { type: Function, default: null }, /** 是否显示自定义的底部按钮区域 */ showCustomFooter: { type: Boolean, default: !1 }, /** 是否支持清除绑定 */ enableClear: { type: Boolean, default: !1 }, /** 是否可以变更字段类型 */ canChangeFieldType: { type: Boolean, default: !1 } }, qe = Be(ie, He), Ge = { 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 } }, Ue = { showCloseButton: { type: Boolean, default: !0 }, animate: { type: String, default: "fadeIn" }, options: { type: Object } }, ne = /* @__PURE__ */ X({ name: "Toast", props: Ue, emits: ["close", "click"], setup: (e, t) => { const a = S(e.animate), s = "fadeOut", i = M(() => e.options), c = S(!1), u = M(() => i.value.title && i.value.message), y = M(() => !i.value.title && i.value.message), v = M(() => { const h = { animated: c.value, toast: !0, "toast--only-content": !u.value }; return h[e.animate] = !1, h[s] = c.value, h["toasty-type-" + i.value.type] = !0, i.value.theme && (h[i.value.theme] = !0), h; }), T = M(() => { const H = `f-icon-${i.value && i.value.type ? i.value.type.replace("toasty-type-", "") : "default"}`, $ = { "f-icon": !0 }; return $[H] = !0, $; }), F = M(() => i.value.title || i.value.message), x = M(() => e.showCloseButton), E = M(() => !!i.value.buttons || !!t.slots.default), I = M(() => te.getLocale() === "en" ? { wordBreak: "keep-all", overflowWrap: "break-word" } : {}); function L(h) { h.stopPropagation(), h.preventDefault(), c.value = !1, setTimeout(() => { t.emit("close", i.value); }, 200); } function O(h, k) { } function N(h) { return `f-preten-link ${h.customClass ? h.customClass : ""}`; } be(a, () => { a.value; }); const P = () => { var h; return f(de, null, [f("div", { class: "after-toast-msg text-right" }, [!t.slots.default && ((h = i.value.buttons) == null ? void 0 : h.map((k) => f("span", { class: N(k), onClick: (H) => void 0 }, [k.text]))), t.slots.default && t.slots.default()])]); }; return () => f("div", { class: v.value, style: "min-height:44px" }, [x.value && f("button", { title: te.getLocaleValue("messageBox.close"), class: "toast-close f-btn-icon f-bare", onClick: L }, [f("span", { class: "f-icon modal_close" }, null)]), F.value && f("section", { class: "modal-tips" }, [!u.value && f("div", { class: "float-left modal-tips-iconwrap" }, [f("span", { class: T.value }, null)]), f("div", { class: "modal-tips-content" }, [u.value && f(de, null, [f("h5", { class: "toast-title modal-tips-title", innerHTML: i.value.title }, null), f("p", { class: "toast-msg", innerHTML: i.value.message, style: I.value }, null), E.value && P()]), y.value && (i.value.buttons ? f("div", { class: "toast-title-btns-wrapper d-flex" }, [f("h5", { class: "toast-title modal-tips-title only-toast-msg", style: I.value, innerHTML: i.value.message }, null), f("div", { class: "after-toast-title text-right ml-auto" }, [P()])]) : f("h5", { class: "toast-title modal-tips-title only-toast-msg", style: I.value, innerHTML: i.value.message }, null))])])]); } }), We = ["moz", "ms", "webkit"]; function Ke() { let e = 0; return (t) => { const a = (/* @__PURE__ */ new Date()).getTime(), s = Math.max(0, 16 - (a - e)), i = setTimeout(() => { t(a + s); }, s); return e = a + s, i; }; } function ze() { if (typeof window > "u") return () => 0; if (window.requestAnimationFrame) return window.requestAnimationFrame.bind(window); const e = We.filter((t) => `${t}RequestAnimationFrame` in window)[0]; return e ? window[`${e}RequestAnimationFrame`] : Ke(); } ze(); S(""); function me() { if (typeof window > "u" || typeof navigator > "u") return !1; const e = navigator.userAgent || navigator.vendor || window.opera, t = [ /iPhone/i, /iPod/i, /Android.*Mobile/i, // Android 手机通常包含 "Mobile" 字样,而平板不包含 /webOS/i, /BlackBerry/i, /IEMobile/i, /Opera Mini/i, /Harmony/i ], a = [ /iPad/i, /Android(?!.*Mobile)/i, // Android 平板通常不含 "Mobile" /Tablet/i, /PlayBook/i, /Kindle/i, /Silk/i ]; for (const v of a) if (v.test(e)) return !1; for (const v of t) if (v.test(e)) return !0; if (typeof screen > "u") return !1; const s = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = screen.width, c = screen.height, u = Math.min(i, c); return !!(s && u <= 768); } function Xe() { const e = me(); return e && document.body.classList.add("f-mobile"), e; } typeof document < "u" && Xe(); const z = /* @__PURE__ */ X({ name: "Notify", props: Ge, emits: ["close", "empty"], setup(e, t) { var O; const a = me(), i = `farris-notify-${(O = e.options) != null && O.type ? e.options.type : "info"}}`, c = M(() => ({ "farris-notify": !0, [i]: a })), u = { left: 12, right: 12, top: 20, bottom: 12 }, y = S(), v = S(e.options), T = S(e.showCloseButton), F = M(() => e.position || "bottom-right"), x = M(() => e.timeout != null ? e.timeout : 3e3), E = M(() => { const N = e.bottom ? e.bottom : u.bottom, P = e.top ? e.top : u.top, h = { transition: "all 0.2s ease", left: F.value.indexOf("left") > -1 ? `${e.left ? e.left : u.left}px` : "", right: F.value.indexOf("right") > -1 ? `${e.right ? e.right : u.right}px` : "", top: F.value.indexOf("top") > -1 ? `${P}px` : "", bottom: F.value.indexOf("bottom") > -1 ? `${N}px` : "" }; return F.value.indexOf("center") > -1 && (h.left = "50%", h.marginLeft = "calc(-24rem / 2)", F.value === "center-center" && (h.top = "50%", h.transform = "translate(-50%, -50%)")), h; }); function I(N) { t.emit("close"); } x.value && setTimeout(() => { I(); }, x.value), t.expose({ closeToast: I, container: y, notifyPosition: F }); function L(N, P) { I(); } return () => { var N; return a ? f("div", { class: c.value, ref: y }, [(N = e.options) == null ? void 0 : N.message]) : f("div", { class: c.value, style: E.value, ref: y }, [f(ne, { options: v.value, showCloseButton: T.value, animate: e.animate, onClose: (P) => L(P, v.value) }, null)]); }; } }); class ge { constructor() { Z(this, "notifyRefs", []); Z(this, "globalConfig", ve({})); } escapeAllHtml(t) { if (typeof t != "string" || !t) return ""; const a = document.createElement("div"); return a.textContent = t || "", a.innerHTML.replace(/\\n/g, "<br>").replace(/\\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;").replace(/\\r/g, ""); } createNotifyInstance(t) { const a = this, i = Object.assign({ timeout: 3e3, position: "bottom-right", showCloseButton: !0, safeHtml: !0 }, this.globalConfig, { ...t }), c = document.createElement("div"); c.style.display = "contents"; const u = Fe({ setup() { var T; const y = S(); function v() { y.value.container.style.transform = "scale(0)", setTimeout(() => { a.updateNotifyPositionForClose(i, y), u.unmount(); }, 220); } if (i.position.indexOf("top") > -1) { const F = a.getNotifyInstances(i.position), x = F[F.length - 1]; if (x) { const E = x.value.container.getBoundingClientRect(); i.top = E.bottom; } } return i.safeHtml && ((T = i.options) != null && T.message) && (i.options.message = a.escapeAllHtml(i.options.message)), Se(() => { document.body.removeChild(c); }), ue(() => { a.updateNotifyPositionForCreate(i, y); }), () => f(Te, { mode: "out-in", name: "fade", appear: !0 }, { default: () => [f(z, we({ ref: y }, i, { onClose: v }), null)] }); } }); return u.provide("NotifyService", this), document.body.appendChild(c), u.use(te.i18n), u.mount(c), u; } getNotifyInstances(t) { return this.notifyRefs.filter((a) => a.value.notifyPosition === t); } updateNotifyPositionForCreate(t, a) { if (this.notifyRefs && this.notifyRefs.length) { const s = window.innerHeight; t.position.indexOf("bottom") > -1 && this.getNotifyInstances(t.position).forEach((i) => { const c = i.value.container.getBoundingClientRect(); i.value.container.style.bottom = c.height + s - c.bottom + "px"; }); } this.notifyRefs = [...this.notifyRefs, a]; } updateNotifyPositionForClose(t, a) { const s = this.notifyRefs.indexOf(a); if (t.position.indexOf("top") > -1) { const i = this.getNotifyInstances(t.position), c = i.indexOf(a); i.slice(c + 1).forEach((u) => { u.value.container.style.top = u.value.container.offsetTop - u.value.container.offsetHeight + "px"; }); } s > -1 && this.notifyRefs.splice(s, 1); } show(t) { return this.createNotifyInstance(t); } buildNotifyProps(t, a) { let s = "", i = "", c, u, y; typeof a == "string" ? s = a : a && (s = a.message || "", i = a.title || "", u = a.position || null, y = a.showCloseButton != null ? a.showCloseButton : null, c = a.timeout != null ? a.timeout : null); const T = { options: { type: t, message: s, title: i } }; return u != null && (T.position = u), y != null && (T.showCloseButton = y), c != null && (T.timeout = c), T; } info(t) { const a = this.buildNotifyProps("info", t); return this.show(a); } success(t) { const a = this.buildNotifyProps("success", t); return this.show(a); } warning(t) { const a = this.buildNotifyProps("warning", t); return this.show(a); } error(t) { const a = this.buildNotifyProps("error", t); return this.show(a); } close(t) { t && t.unmount(); } closeAll() { this.notifyRefs.forEach((t) => { t == null || t.value.closeToast(); }), this.notifyRefs.length = 0; } } const Ye = Symbol("NOTIFY_SERVICE_TOKEN"); z.install = (e) => { e.component(z.name, z), e.component(ne.name, ne); const t = new ge(); e.provide(Ye, t), e.provide("FNotifyService", t); }; function pe(e) { const { designViewModelUtils: t, schemaService: a, formSchemaUtils: s, designerContext: i } = e.editorParams.designerHostService, { viewModelId: c } = e.editorParams; let u = [], y = [], v = []; const T = S(!1), F = new ge(); F.globalConfig = { position: "top-center" }; function x(n) { switch (n) { case "LocaleVariable": return y; case "RemoteVariable": return v; default: return u; } } function E() { u = t.getAllFields2TreeByVMId(c); } function I() { const n = s.getViewModelById(c); if (n.parent) { const r = s.getLocaleVariablesByViewModelId(n.parent); r && r.length && (r[0].data.name = "根组件", y = y.concat(r)); } const l = s.getLocaleVariablesByViewModelId(c); return y = y.concat(l), y || []; } function L() { return v = s.getRemoteVariables(), v || []; } function O(n, l = null) { const r = []; return n && n.forEach((m) => { var p; if (!m.nodeType && (!m.children || !m.children.length)) m.data && r.push({ ...m.data, fromSource: (p = l == null ? void 0 : l.data) == null ? void 0 : p.name }); else if (m.children) { const o = O(m.children, m); r.push(...o); } }), r; } function N() { const n = O(I()), l = L().map((r) => ({ ...r.data, fromSource: "视图对象" })); return [...n, ...l]; } function P(n) { var o, d, g, b; const l = ce({}, n.rawData, { groupId: null, groupName: null }), r = (o = e.editorParams.componentSchema) == null ? void 0 : o.binding, m = (d = e.editorParams.componentSchema) == null ? void 0 : d.label, p = t.getDgViewModel(c); if (r != null && r.field) { const B = p.fields.find((C) => C.id === r.field); if (p.removeField([r.field]), B) { const { groupId: C, groupName: j, editor: V } = B; ce(l, { editor: V, groupId: C, groupName: j }); } } p.addField(l), (b = (g = e.editorParams.componentSchema) == null ? void 0 : g.editor) != null && b.type && p.changeField(l.id, { editor: l.editor }), m && p.changeField(l.id, { name: m }); } function h(n) { var p; const l = (p = e.editorParams.componentSchema) == null ? void 0 : p.binding, r = t.getDgViewModel(c), m = { type: "Variable", id: n.id, fieldName: n.code, groupId: "", groupName: "" }; if (l != null && l.field) { const o = s.getViewModelById(c), d = o == null ? void 0 : o.fields.find((g) => g.id === (l == null ? void 0 : l.field)); d && (m.groupName = d.groupName, m.groupId = d.groupId), r.removeField([l == null ? void 0 : l.field]); } s.addViewModelField(c, m); } function k(n, l) { if (!e.editorParams.needSyncToViewModel || !e.editorParams.viewModelId || !e.editorParams.designerHostService) return; const r = e.editorParams.componentSchema.binding; r && r.field === n.id || (l === "Form" ? P(n) : h(n)); } function H(n) { if (!e.editorParams.needSyncToViewModel || !e.editorParams.viewModelId || !e.editorParams.designerHostService) return; const l = e.editorParams.componentSchema.binding; if (!(!l || l.field === (n == null ? void 0 : n.id)) && s.getExpressions().length) { const { componentSchema: r } = e.editorParams, m = s.getExpressions().findIndex((p) => p.target === l.field); m > -1 && (s.getExpressions().splice(m, 1), F.warning("切换绑定后,请重新配置表达式"), Object.keys(r).forEach((p) => { r[p] && r[p].type === "Expression" && (r[p].expressionId = ""), r.editor && Object.keys(r.editor).forEach((o) => { r.editor[o] && r.editor[o].type === "Expression" && (r.editor[o].expressionId = ""); }); })); } } function $(n) { var r; [ee.Number, ee.String, ee.Text].includes(n.type.name) && ((r = n.type) == null ? void 0 : r.length) && e.editorParams.componentSchema.editor && !Object.prototype.hasOwnProperty.call(e.editorParams.componentSchema.editor, "maxLength") && (e.editorParams.componentSchema.editor.maxLength = n.type.length); } function _(n, l) { if (e.editorParams.componentSchema) return e.editorParams.componentSchema.binding || (e.editorParams.componentSchema.binding = {}), l === "Form" ? (e.editorParams.componentSchema.binding.path = n.bindingField, e.editorParams.componentSchema.binding.field = n.id, e.editorParams.componentSchema.binding.fullPath = n.path) : n.category === "locale" ? (e.editorParams.componentSchema.binding.path = n.viewModelId === c ? n.code : "root-component." + n.code, e.editorParams.componentSchema.binding.field = n.id, e.editorParams.componentSchema.binding.fullPath = n.code) : (e.editorParams.componentSchema.binding.path = "root-component." + n.code, e.editorParams.componentSchema.binding.field = n.id, e.editorParams.componentSchema.binding.fullPath = n.code), e.editorParams.componentSchema.binding.type = l, e.editorParams.componentSchema.path = n.bindingPath, $(n), e.editorParams.componentSchema.binding; } function q(n) { const l = n == null ? void 0 : n.field, r = /* @__PURE__ */ new Set(), m = s.getFormSchema().module, p = s.getViewModelById(c), o = m.components.find((b) => b.viewModel === c), d = s.checkComponentExistInDrawer(o.id); let g = o.componentType; return (g === "frame" || g === "table") && (g = "form"), m.viewmodels.forEach((b) => { if (!b.fields || b.fields.length === 0) return; const B = m.components.find((V) => V.viewModel === b.id); let { componentType: C } = B; if ((C === "frame" || C === "table") && (C = "form"), C !== g || b.bindTo !== p.bindTo) return; const j = s.checkComponentExistInDrawer(B.id); d && j && b.fields.forEach((V) => { V.id !== l && r.add(V.id); }), !d && !j && b.fields.forEach((V) => { V.id !== l && r.add(V.id); }); }), r; } function A(n) { if (!n) return []; const l = {}, r = i && i.schemaDOMMapping ? i.schemaDOMMapping : Ve, { fieldControlTypeMapping: m } = r; for (const p in m) { const o = m[p]; !o || !o.length || o.forEach((d) => { l[d.key] = l[d.key] || [], l[d.key].push(p); }); } return l["language-textbox"] = ["multiLanguage"], l[n]; } function w() { E(); } function R(n, l) { if (n.multiLanguage) return { fieldType: "multiLanguage", fieldTypeName: "多语言" }; const r = l === W.Form ? n.type.name : n.type, m = l === W.Form ? n.type.displayName : n.displayTypeName; return { fieldType: r, fieldTypeName: m }; } function G() { var p; const n = (p = e.editorParams) == null ? void 0 : p.componentSchema, l = n == null ? void 0 : n.binding; if (!l) return { originalFieldType: "", isOriginalBindComplexField: !1 }; let r, m = !1; if (l.type === W.Form) { const o = a.getFieldByID(l.field); o && (r = R(o, W.Form).fieldType, o.$type === fe.ComplexField && (m = !0)); } else { const o = s.getVariableById(l.field); o && (r = o.type); } return { originalFieldType: r, isOriginalBindComplexField: m }; } function Y(n, l) { var ae, le, re, se; if (!(n != null && n.length)) return F.warning({ message: "请先选择数据" }), !1; const r = (ae = e.editorParams) == null ? void 0 : ae.componentSchema; if (!(r == null ? void 0 : r.binding)) return !0; let p = !0; T.value = !1; const { originalFieldType: o, isOriginalBindComplexField: d } = G(), g = n[0], { fieldType: b, fieldTypeName: B } = R(g, l), C = "不可以切换成", j = "类型字段,请重新选择!", V = (se = (re = (le = e.editorParams) == null ? void 0 : le.componentSchema) == null ? void 0 : re.editor) == null ? void 0 : se.type, U = A(V); return d || !o ? (T.value = !0, U != null && U.length && !U.includes(b) && (F.warning(`${C}${B}${j}`), p = !1), p) : o && o !== b ? e.editorParams.canChangeFieldType ? (T.value = !0, !0) : V === "combo-list" || V === "lookup" || V === "radio-group" ? l === W.Form ? U.includes(b) : b === "String" || b === "Object" : (F.warning(`${C}${B}${j}`), !1) : p; } function J() { var r; if (!e.editorParams.needSyncToViewModel || !e.editorParams.viewModelId || !e.editorParams.designerHostService) return; const n = (r = e.editorParams.componentSchema) == null ? void 0 : r.binding; if (!(n != null && n.field)) return; t.getDgViewModel(c).removeField([n.field]); } function Q() { const { componentSchema: n } = e.editorParams; n && (n.binding = null, n.path = ""); } return { initTreeData: w, getTreeDataSource: x, updateViewModel: k, updateComponentSchema: _, resolveOccupiedFields: q, resolveFieldTypesByEditorType: A, checkFieldValiation: Y, clearExpresssionConfig: H, getOriginalFieldType: G, getVariableData: N, fieldTypeChanged: T, clearViewModel: J, clearComponentSchema: Q }; } const oe = /* @__PURE__ */ X({ name: "FBindingSelectorContainer", props: ie, emits: ["selected", "bindingTypeChange", "cancel", "submit", "skip"], setup(e, t) { var r, m, p; const a = S(e.data), s = S(((r = e.modelValue) == null ? void 0 : r.type) || "Form"), i = S(e.bindingData), c = S(), u = S(), y = S(), v = S(), { getTreeDataSource: T, initTreeData: F, resolveOccupiedFields: x, resolveFieldTypesByEditorType: E, getOriginalFieldType: I, getVariableData: L } = pe(e), { originalFieldType: O, isOriginalBindComplexField: N } = I(), P = S([]), h = {}; Ce(() => { var o, d, g, b, B, C; F(), P.value = L(), a.value = T(s.value), (o = e.editorParams) != null && o.disableOccupiedFields && (y.value = x((g = (d = e.editorParams) == null ? void 0 : d.componentSchema) == null ? void 0 : g.binding)), v.value = E((C = (B = (b = e.editorParams) == null ? void 0 : b.componentSchema) == null ? void 0 : B.editor) == null ? void 0 : C.type); }), ue(() => { setTimeout(() => { var d, g, b; const o = (b = (g = (d = e.editorParams) == null ? void 0 : d.componentSchema) == null ? void 0 : g.binding) == null ? void 0 : b.field; o && (s.value === "Form" ? (c.value.selectItemById(o), i.value = c.value.getSelectedItems()) : (u.value.selectItemById(o), u.value.activeRowById(o), i.value = u.value.getSelectedItems()), h[s.value] = i.value, t.emit("selected", i.value)); }); }); const k = { "f-utils-fill": !0, "m-2": (m = e.bindingType) == null ? void 0 : m.enable, "mx-2": !((p = e.bindingType) != null && p.enable), border: !0 }; function H(o) { t.emit("selected", h[o] || []), t.emit("bindingTypeChange", o); } function $(o) { i.value = o, h[s.value] = o, t.emit("selected", o); } function _() { return f("div", { class: "px-3" }, [f(Ne, { name: "bindingType", textField: e.bindingType.textField || "text", valueField: e.bindingType.valueField || "value", data: _e, modelValue: s.value, "onUpdate:modelValue": (o) => s.value = o, onChangeValue: H }, null)]); } function q(o, d = "Form") { var g; return o.raw.multiLanguage ? "multiLanguage" : d === "Form" ? (g = o.raw.type) == null ? void 0 : g.name : o.raw.type; } const A = () => { var o, d, g; return ((g = (d = (o = e.editorParams) == null ? void 0 : o.componentSchema) == null ? void 0 : d.editor) == null ? void 0 : g.type) || ""; }, w = M(() => { var o, d, g; return (((g = (d = (o = e.editorParams) == null ? void 0 : o.componentSchema) == null ? void 0 : d.editor) == null ? void 0 : g.type) || "") === "language-textbox"; }), R = (o) => ({ customRowStatus: (d) => { var B, C; if (d.raw.$type && d.raw.$type !== fe.SimpleField || y.value && y.value.has(d.raw.id)) return d.disabled = !0, d; if ((B = e.editorParams) != null && B.canChangeFieldType) return d.disabled = !1, d; const g = q(d, o), b = A(); if (b === "combo-list" || b === "lookup") return o !== "Form" ? (d.disabled = g !== "Object", d) : (d.disabled = !v.value.includes(g), d); if (b === "radio-group") return o !== "Form" ? d.disabled = g !== "String" : d.disabled = !v.value.includes(g), d; if (N || !O) { if (g && ((C = v.value) != null && C.length) && !v.value.includes(g)) return d.disabled = !0, d; } else if (O && O !== g) return d.disabled = !0, d; return d.disabled = !1, d; } }); function G() { return f(xe, { ref: c, fit: !0, data: a.value, idField: e.idField, columns: Ae, rowNumber: { enable: !1 }, columnOption: { fitColumns: !0 }, onSelectionChange: $, "row-option": R("Form") }, null); } function Y() { return f(Ie, { ref: u, fit: !0, data: P.value, idField: e.idField, columns: je, rowNumber: { enable: !1 }, columnOption: { fitColumns: !0 }, onSelectionChange: $, "row-option": R("Variable") }, null); } function J() { t.emit("cancel"); } function Q() { if (!i.value || !i.value.length) { const o = new Me(); return o.globalConfig = { position: "top-center" }, o.warning({ message: "请先选择数据" }), !1; } return !0; } function n() { Q() && t.emit("submit", { selectedData: i.value[0], bindingType: s.value }); } function l() { t.emit("skip"); } return () => f("div", { class: "h-100 d-flex flex-column" }, [e.bindingType.enable && !w.value && _(), f("div", { class: k, style: "position:relative;border-radius:10px;" }, [f("div", { class: { "h-100": !0, "d-none": s.value !== "Form" } }, [G()]), f("div", { class: { "h-100": !0, "d-none": s.value === "Form" } }, [Y()])]), e.showCustomFooter ? f("div", { class: "modal-footer" }, [f("button", { type: "button", class: "btn btn-secondary", onClick: J }, [D("取消")]), f("button", { type: "button", class: "btn btn-secondary", onClick: l }, [D("跳过绑定")]), f("button", { type: "button", class: "btn btn-primary", onClick: n }, [D("确定")])]) : ""]); } }), K = /* @__PURE__ */ X({ name: "FBindingSelector", props: ie, emits: ["selected", "bindingTypeChanged"], setup(e, t) { var _, q, A; const a = '<i class="f-icon f-icon-lookup"></i>', s = S(e.bindingData), i = S(e.data), c = S(), u = S(((_ = e.modelValue) == null ? void 0 : _.type) || "Form"), y = S(u.value === "Form" ? (q = e.modelValue) == null ? void 0 : q.path : (A = e.modelValue) == null ? void 0 : A.fullPath), { updateViewModel: v, updateComponentSchema: T, checkFieldValiation: F, clearExpresssionConfig: x, fieldTypeChanged: E, clearViewModel: I, clearComponentSchema: L } = pe(e); function O(w) { s.value = w; } function N(w) { u.value = w; } function P(w) { if (!w) { y.value = ""; return; } y.value = (w == null ? void 0 : w.type) === "Form" ? w.path : w.fullPath; } function h() { return f(oe, { ref: c, data: i.value, onSelected: O, modelValue: e.modelValue, idField: e.idField, bindingData: s.value, onBindingTypeChange: N, editorParams: e.editorParams, bindingType: e.bindingType, showCustomFooter: !1, canChangeFieldType: e.editorParams.canChangeFieldType }, null); } function k() { return !!F(s.value, u.value); } const H = { title: e.title, fitContent: !1, height: e.modalHeight, width: e.modalWidth, buttons: [{ name: "cancel", text: "取消", class: "btn btn-secondary", handle: (w) => (s.value = [], !0) }, { name: "accept", text: "确定", class: "btn btn-primary", handle: (w) => { if (!k()) return !1; v(s.value[0], u.value), x(s.value[0]); const R = T(s.value[0], u.value); if (P(R), e.onFieldSelected && typeof e.onFieldSelected == "function") { const G = { fieldTypeChanged: E.value, ...s.value[0] }; e.onFieldSelected(R, void 0, G); } return !0; } }], resizeable: !1, draggable: !0 }; function $() { I(), x(), L(), P(null), e.onFieldSelected(void 0, void 0); } return () => { var w; return f(Pe, { modelValue: y.value, "onUpdate:modelValue": (R) => y.value = R, editable: !1, disabled: e.disabled, readonly: e.readonly, inputType: "text", enableClear: (w = e.editorParams) == null ? void 0 : w.enableClear, buttonContent: a, buttonBehavior: "Modal", modalOptions: H, enableTitle: !0, onClear: $ }, { default: () => [f("div", { class: "h-100 d-flex flex-column" }, [h()])] }); }; } }); K.install = (e) => { e.component(K.name, K), e.component(oe.name, oe); }; K.register = (e, t, a, s) => { e["binding-selector"] = K, t["binding-selector"] = qe; }; export { K as BindingSelector, oe as FBindingSelectorContainer, ie as bindingSelectorProps, _e as bindingTypes, K as default, Ae as fieldColumns, qe as propsResolver, je as variableColumns };