UNPKG

@farris/ui-vue

Version:

Farris Vue, a Farris Design based Vue3 component library.

1,027 lines (1,026 loc) 34 kB
import { ref as M, computed as U, defineComponent as W, watch as _, createVNode as V, Fragment as pe, inject as de, onMounted as me, resolveComponent as ve } from "vue"; import ge from "../button-edit/index.esm.js"; import { cloneDeep as X, isPlainObject as J } from "lodash-es"; import be from "../list-view/index.esm.js"; import ye from "../loading/index.esm.js"; import { getSchemaByTypeForDesigner as he } from "../dynamic-resolver/index.esm.js"; function Q(e, t) { let n; function c(o) { const { properties: u, title: a, ignore: r } = o, i = r && Array.isArray(r), f = Object.keys(u).reduce((v, S) => ((!i || !r.find((D) => D === S)) && (v[S] = u[S].type === "object" && u[S].properties ? c(u[S]) : X(u[S].default)), v), {}); if (a && (!i || !r.find((v) => v === "id"))) { const v = a.toLowerCase().replace(/-/g, "_"); f.id = `${v}_${Math.random().toString().slice(2, 6)}`; } return f; } function b(o) { const { properties: u, title: a, required: r } = o; if (r && Array.isArray(r)) { const i = r.reduce((f, v) => (f[v] = u[v].type === "object" && u[v].properties ? c(u[v]) : X(u[v].default), f), {}); if (a && r.find((f) => f === "id")) { const f = a.toLowerCase().replace(/-/g, "_"); i.id = `${f}_${Math.random().toString().slice(2, 6)}`; } return i; } return { type: a }; } function P(o, u = {}, a) { const r = e[o]; if (r) { let i = b(r); const f = t[o]; return i = f ? f({ getSchemaByType: P }, i, u, a) : i, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(i), i; } return null; } function y(o, u) { const a = c(u); return Object.keys(a).reduce((r, i) => (Object.prototype.hasOwnProperty.call(o, i) && (r[i] && J(r[i]) && J(o[i] || !o[i]) ? Object.assign(r[i], o[i] || {}) : r[i] = o[i]), r), a), a; } function F(o, u) { return Object.keys(o).filter((r) => o[r] != null).reduce((r, i) => { if (u.has(i)) { const f = u.get(i); if (typeof f == "string") r[f] = o[i]; else { const v = f(i, o[i], o); Object.assign(r, v); } } else r[i] = o[i]; return r; }, {}); } function O(o, u, a = /* @__PURE__ */ new Map()) { const r = y(o, u); return F(r, a); } function d(o) { var a; const u = o.type; if (u) { const r = e[u]; if (!r) return o; const i = y(o, r), f = ((a = o.editor) == null ? void 0 : a.type) || ""; if (f) { const v = e[f], S = y(o.editor, v); i.editor = S; } return i; } return o; } function l(o) { n = o; } return { getSchemaByType: P, resolveSchemaWithDefaultValue: d, resolveSchemaToProps: O, mappingSchemaToProps: F, setDesignerContext: l }; } const Y = {}, Z = {}, { getSchemaByType: yt, resolveSchemaWithDefaultValue: Se, resolveSchemaToProps: Fe, mappingSchemaToProps: Te, setDesignerContext: ht } = Q(Y, Z); function Be(e = {}) { function t(d, l, o, u) { if (typeof o == "number") return u[d].length === o; if (typeof o == "object") { const a = Object.keys(o)[0], r = o[a]; if (a === "not") return Number(u[d].length) !== Number(r); if (a === "moreThan") return Number(u[d].length) >= Number(r); if (a === "lessThan") return Number(u[d].length) <= Number(r); } return !1; } function n(d, l, o, u) { return u[d] && u[d].propertyValue && String(u[d].propertyValue.value) === String(o); } const c = /* @__PURE__ */ new Map([ ["length", t], ["getProperty", n] ]); Object.keys(e).reduce((d, l) => (d.set(l, e[l]), d), c); function b(d, l) { const o = d; return typeof l == "number" ? [{ target: o, operator: "length", param: null, value: Number(l) }] : typeof l == "boolean" ? [{ target: o, operator: "getProperty", param: d, value: !!l }] : typeof l == "object" ? Object.keys(l).map((u) => { if (u === "length") return { target: o, operator: "length", param: null, value: l[u] }; const a = u, r = l[u]; return { target: o, operator: "getProperty", param: a, value: r }; }) : []; } function P(d) { return Object.keys(d).reduce((o, u) => { const a = b(u, d[u]); return o.push(...a), o; }, []); } function y(d, l) { if (c.has(d.operator)) { const o = c.get(d.operator); return o && o(d.target, d.param, d.value, l) || !1; } return !1; } function F(d, l) { return P(d).reduce((a, r) => a && y(r, l), !0); } function O(d, l) { const o = Object.keys(d), u = o.includes("allOf"), a = o.includes("anyOf"), r = u || a, v = (r ? d[r ? u ? "allOf" : "anyOf" : "allOf"] : [d]).map((D) => F(D, l)); return u ? !v.includes(!1) : v.includes(!0); } return { parseValueSchema: O }; } const Me = { convertTo: (e, t, n, c) => { e.appearance || (e.appearance = {}), e.appearance[t] = n; }, convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t] }, Pe = { convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无" }, Oe = { convertTo: (e, t, n, c) => { e.editor && (e.editor[t] = n); }, convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t] }, K = { 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: "多语输入框" } }, we = { convertFrom: (e, t, n) => { var b; const c = e.editor && e.editor[t] ? e.editor[t] : e[t]; return ((b = K[c]) == null ? void 0 : b.name) || c; } }, De = { convertTo: (e, t, n, c) => { e[t] = e[t]; }, convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : "" }, Ee = { convertTo: (e, t, n, c) => { (e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = n : e.formatter = { [t]: n }); }, convertFrom: (e, t, n) => { if (e.formatter) { if (t === "trueText") return e.formatter.trueText; if (t === "falseText") return e.formatter.falseText; if (t === "prefix") return e.formatter.prefix; if (t === "suffix") return e.formatter.suffix; if (t === "precision") return e.formatter.precision; if (t === "decimal") return e.formatter.decimal; if (t === "thousand") return e.formatter.thousand; if (t === "tempDateFormat") return e.formatter.dateFormat === "yyyy年MM月dd日" ? "yearMonthDay" : e.formatter.dateFormat === "yyyy-MM-dd HH:mm:ss" ? "yyyy-MM-ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy/MM/dd HH:mm:ss" ? "yyyy/MM/ddTHH:mm:ss" : e.formatter.dateFormat === "yyyy年MM月dd日 HH时mm分ss秒" ? "yearMonthDayHourMinuteSecond" : e.formatter.tempDateFormat || e.formatter.dateFormat || "yyyy-MM-dd"; if (t === "customFormat") return e.formatter.customFormat; if (t === "type") return e.formatter.type || "none"; } return "none"; } }, Re = { convertTo: (e, t, n, c) => { e.command ? e.command[t] = n : e.command = { [t]: n }, t === "enable" && n && (e.command.commands || (e.command.commands = [ { text: "编辑", type: "primary", command: "edit" }, { text: "删除", type: "danger", command: "remove" } ])); }, convertFrom: (e, t, n) => e.command && t === "enable" ? e.command.enable : "" }, je = { convertTo: (e, t, n, c) => { e.column ? e.column[t] = n : e.column = { [t]: n }, t === "fitColumns" && n && (e.column.fitMode || (e.column.fitMode = "average")); }, convertFrom: (e, t, n) => { if (e.column) { if (t === "fitColumns") return e.column.fitColumns; if (t === "fitMode") return e.column.fitMode; } return ""; } }, ke = { convertTo: (e, t, n, c) => { e.summary ? e.summary[t] = n : e.summary = { [t]: n }, t === "enable" && n && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = { enable: n, groupFields: [] }); }, convertFrom: (e, t, n) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : "" }, Ne = { convertTo: (e, t, n, c) => { e.group ? e.group[t] = n : e.group = { [t]: n }, t === "enable" && n && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = { enable: n, groupFields: [], showSummary: !1 }); }, convertFrom: (e, t, n) => { if (e.group) { if (t === "enable") return e.group.enable; if (t === "showSummary") return e.group.showSummary; } } }, $e = { convertFrom: (e, t) => e.binding ? e.binding.path : "", convertTo: (e, t, n) => { if (n && n.length > 0) { const c = n[0]; e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = c.bindingField, e.binding.field = c.id, e.binding.fullPath = c.path, e.path = c.bindingPath; } } }, Ve = { convertTo: (e, t, n, c) => { e.pagination || (e.pagination = {}), e.pagination[t] = n; }, convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t] }, Ce = { convertTo: (e, t, n, c) => { e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n; }, convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t] }, He = { convertTo: (e, t, n, c) => { e.selection || (e.selection = {}), e.selection[t] = n; }, convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t] }, Ae = { convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : "" }, qe = { convertFrom: (e, t) => e[t] || "", convertTo: (e, t, n) => { e[t] = n; } }, Le = { convertTo: (e, t, n, c) => { e.size || (e.size = {}), e.size[t] = n; }, convertFrom: (e, t, n) => e.size ? e.size[t] : e[t] }, ze = { convertFrom: (e, t, n) => { var c, b; return (c = e.formatter) != null && c.data && t === "formatterEnumData" && !e.formatterEnumData ? (b = e.formatter) == null ? void 0 : b.data : e.formatterEnumData; } }, _e = { convertTo: (e, t, n, c) => { e.sort || (e.sort = {}), e.sort[t] = n; }, convertFrom: (e, t, n) => { var c, b; if (t === "mode") return ((c = e.sort) == null ? void 0 : c.mode) || "client"; if (t === "multiSort") return !!((b = e.sort) != null && b.multiSort); } }, Ue = { convertTo: (e, t, n, c) => { e.filter || (e.filter = {}), e.filter[t] = n; }, convertFrom: (e, t, n) => { var c; if (t === "mode") return ((c = e.filter) == null ? void 0 : c.mode) || "client"; } }, We = { convertTo: (e, t, n, c) => { e.rowOption ? e.rowOption[t] = n : e.rowOption = { [t]: n }; }, convertFrom: (e, t, n) => { if (e.rowOption) { if (t === "customRowStyle") return e.rowOption.customRowStyle; if (t === "customCellStyle") return e.rowOption.customCellStyle; } return ""; } }; function I(e, t, n) { const c = /* @__PURE__ */ new Map([ ["/converter/appearance.converter", Me], ["/converter/buttons.converter", Pe], ["/converter/property-editor.converter", Oe], ["/converter/items-count.converter", Ae], ["/converter/type.converter", we], ["/converter/change-editor.converter", De], ["/converter/change-formatter.converter", Ee], ["/converter/column-command.converter", Re], ["/converter/column-option.converter", je], ["/converter/summary.converter", ke], ["/converter/group.converter", Ne], ["/converter/form-group-label.converter", qe], ["/converter/field-selector.converter", $e], ["/converter/pagination.converter", Ve], ["/converter/row-number.converter", Ce], ["/converter/grid-selection.converter", He], ["/converter/size.converter", Le], ["/converter/change-formatter-enum.converter", ze], ["/converter/grid-sort.converter", _e], ["/converter/grid-filter.converter", Ue], ["/converter/row-option.converter", We] ]), b = /* @__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 }] ]), P = Be(); function y(r, i) { return () => P.parseValueSchema(r, i); } function F(r, i, f) { return r.includes("visible") && i.visible !== void 0 ? typeof i.visible == "boolean" ? () => !!i.visible : i.visible === void 0 ? !0 : y(i.visible, f) : () => !0; } function O(r, i, f) { return r.includes("readonly") && i.readonly !== void 0 ? typeof i.readonly == "boolean" ? () => !!i.readonly : y(i.readonly, f) : () => !1; } function d(r, i) { const f = r.$converter || i; return typeof f == "string" && f && c.has(f) ? c.get(f) || null : f || null; } function l(r, i, f, v, S, D = "", k = "") { return Object.keys(r).map((T) => { const N = M(1), $ = T, p = r[T], E = Object.keys(p), A = p.title, s = p.type, g = b.get(s) || { type: "input-group", enableClear: !1 }, m = p.editor ? Object.assign({}, g, p.editor) : Object.assign({}, g), h = F(E, p, i), B = O(E, p, i); m.readonly = m.readonly === void 0 ? B() : m.readonly; const j = p.type === "cascade" ? l(p.properties, i, f, v, S, D, k) : [], q = !0; let w = d(p, k); const C = U({ get() { if (N.value) { if (["class", "style"].find((fe) => fe === $) && !w && (w = c.get("/converter/appearance.converter") || null), w && w.convertFrom) return w.convertFrom(f, T, S, D); const H = f[T]; return Object.prototype.hasOwnProperty.call(p, "defaultValue") && (H === void 0 || typeof H == "string" && H === "") ? p.type === "boolean" ? p.defaultValue : p.defaultValue || "" : H; } return null; }, set(H) { N.value += 1, w && w.convertTo ? (w.convertTo(v, T, H, S, D), w.convertTo(f, T, H, S, D)) : (v[T] = H, f[T] = H); } }), { refreshPanelAfterChanged: L, description: le, isExpand: ue, parentPropertyID: se } = p, G = { propertyID: $, propertyName: A, propertyType: s, propertyValue: C, editor: m, visible: h, readonly: B, cascadeConfig: j, hideCascadeTitle: q, refreshPanelAfterChanged: L, description: le, isExpand: ue, parentPropertyID: se }; return i[$] = G, G; }); } function o(r, i, f = {}) { const v = {}, S = e[r]; return S && S.categories ? Object.keys(S.categories).map((k) => { const R = S.categories[k], T = R == null ? void 0 : R.title, N = l(R.properties || {}, v, {}, f, i); return { categoryId: k, categoryName: T, properties: N }; }) : []; } function u(r, i, f, v, S = "") { const D = i.$ref.schema, k = i.$ref.converter, R = f[D], T = R.type, N = n(R), $ = {}, p = e[T]; if (p && p.categories) { const E = p.categories[r], A = E == null ? void 0 : E.title; k && Object.keys(E.properties).forEach((m) => { E.properties[m].$converter = k; }); const s = (E == null ? void 0 : E.properties) || {}, g = l(s, $, N, R, v, S); return { categoryId: r, categoryName: A, properties: g }; } return { categoryId: r, categoryName: "", properties: [] }; } function a(r, i, f, v, S) { const D = r.type, k = n(r), R = {}; let T = S || e[D]; if (T && Object.keys(T).length === 0 && f && f.getPropConfig && (T = f.getPropConfig(v)), T && T.categories) { const N = []; return Object.keys(T.categories).map(($) => { const p = T.categories[$]; if (p.$ref) { N.push(u($, p, r, i, v)); return; } const E = p == null ? void 0 : p.title, A = p == null ? void 0 : p.tabId, s = p == null ? void 0 : p.tabName, g = p == null ? void 0 : p.hide, m = p == null ? void 0 : p.hideTitle, h = l(p.properties || {}, R, k, r, i, v, p.$converter), { setPropertyRelates: B } = p, j = p == null ? void 0 : p.parentPropertyID; N.push({ categoryId: $, categoryName: E, tabId: A, tabName: s, hide: g, properties: h, hideTitle: m, setPropertyRelates: B, parentPropertyID: j }); }), N; } return []; } return { getPropertyConfigBySchema: a, getPropertyConfigByType: o, propertyConverterMap: c }; } const ee = {}, te = {}; I(ee, te, Se); const ne = {}, re = {}, { getSchemaByType: St, resolveSchemaWithDefaultValue: xe, resolveSchemaToProps: Ft, mappingSchemaToProps: Tt, setDesignerContext: Bt } = Q(ne, re), oe = {}, ie = {}; I(oe, ie, xe); function Ge(e, t, n = /* @__PURE__ */ new Map(), c = (y, F, O, d) => F, b = {}, P = (y) => y) { return Y[t.title] = t, Z[t.title] = c, ee[t.title] = b, te[t.title] = P, ne[t.title] = t, re[t.title] = c, oe[t.title] = b, ie[t.title] = P, (y = {}, F = !0) => { if (!F) return Te(y, n); const O = Fe(y, t, n), d = Object.keys(e).reduce((l, o) => (l[o] = e[o].default, l), {}); return Object.assign(d, O); }; } function Xe(e, t) { return { customClass: t.class, customStyle: t.style }; } const Je = /* @__PURE__ */ new Map([ ["appearance", Xe] ]), Qe = "https://json-schema.org/draft/2020-12/schema", Ye = "https://farris-design.gitee.io/search-box.schema.json", Ze = "search-box", Ke = "A Farris Component", Ie = "object", et = { id: { description: "The unique identifier for a search-box", type: "string" }, type: { description: "The type string of search-box component", type: "string", default: "search-box" }, appearance: { description: "", type: "object", properties: { class: { type: "string" }, style: { type: "string" } }, default: {} }, binding: { description: "", type: "object", default: {} }, disable: { type: "string", default: !1 }, editable: { description: "", type: "boolean", default: !0 }, placeholder: { description: "", type: "string", default: "" }, readonly: { description: "", type: "boolean", default: !1 }, require: { description: "", type: "boolean", default: !1 }, tabindex: { description: "", type: "number", default: -1 }, visible: { description: "", type: "boolean", default: !0 } }, tt = [ "id", "type" ], nt = { $schema: Qe, $id: Ye, title: Ze, description: Ke, type: Ie, properties: et, required: tt }; function rt(e, t, n) { return t; } const ot = "search-box", it = "A Farris Component", at = "object", ct = { basic: { description: "Basic Infomation", title: "基本信息", properties: { id: { description: "组件标识", title: "标识", type: "string", readonly: !0 }, type: { description: "组件类型", title: "控件类型", type: "select", editor: { type: "waiting for modification", enum: [] } } } } }, lt = { title: ot, description: it, type: at, categories: ct }, x = { /** * 自定义图标 */ buttonContent: { type: String, default: '<i class="f-icon f-icon-search"></i>' }, /** 自定义样式 */ customClass: { type: String, default: "" }, /** 组件初始搜索值 */ modelValue: { type: String, default: "" }, popupHost: { type: Object }, /** */ popupRightBoundary: { type: Object }, popupOffsetX: { type: Object }, /** 搜索框数据 */ data: { type: Array, default: [] }, placeholder: { type: String, default: "请输入关键词" }, /** * 可选,数据源id字段 * 默认为`id` */ idField: { default: "id", type: String }, /** * 可选,数据源的title * 默认为`name` */ textField: { default: "name", type: String }, /** * 可选,最大高度 * 默认`350` */ maxHeight: { default: 350, type: Number }, /** * 是否处于加载状态 */ loading: { default: !1, type: Boolean }, /** * 是否处于只读状态 */ disable: { default: !1, type: Boolean }, /** * 是否展示搜索结果面板 */ showDropdown: { default: !0, type: Boolean }, /** * popupOnFoucs TODO */ /** * 值变化事件触发时机 */ updateOn: { default: "blur", type: String } }, ae = Ge(x, nt, Je, rt, lt), ut = { data: { type: Array, default: [] }, /** 确认结果事件 */ onConfirmResult: { type: Function, default: () => { } }, /** 搜索点击后返回值 */ onSearchedValue: { type: Function, default: () => { } }, /** * 可选,数据源id字段 * 默认为`id` */ idField: { default: "id", type: String }, /** * 可选,数据源的title * 默认为`name` */ textField: { default: "name", type: String }, /** * 可选,最大高度 * 默认`350` */ maxHeight: { default: 350, type: Number }, loading: { default: !1, type: Boolean } }, ce = /* @__PURE__ */ W({ name: "FSearchBoxContainer", props: ut, emits: ["confirmResult", "searchedValue"], setup(e, t) { const n = M(e.data), c = M(), { slots: b } = t, P = U(() => ({ "search-box-container": !0, "f-utils-overflow-xhya": !0, "position-relative": !0 })); function y(l) { var o; (o = c.value) == null || o.search(l); } function F(l) { l.length && (t.emit("confirmResult", l[0].name), t.emit("searchedValue", l)); } function O(l) { return b.default ? V(pe, null, [b.default(l)]) : V("span", null, [l.item[e.textField]]); } const d = U(() => { const l = {}; return l.padding = "8px", e.maxHeight !== void 0 && e.maxHeight > 0 && (l.maxHeight = `${e.maxHeight}px`), l; }); return _(() => e.loading, (l) => { }), _(() => e.data, (l) => { l !== n.value && (n.value = l), c.value.updateDataSource(l); }), t.expose({ search: y }), () => { const l = { content: O }; return V("div", { class: P.value, style: d.value }, [V(ye, { ref: "loadingInstance", isActive: e.loading }, null), V(be, { ref: c, itemClass: "dropdown-item", data: n.value, view: "ContentView", onClickItem: (o) => F(o.data), idField: e.idField, textField: e.textField, titleField: e.textField, valueField: e.idField }, l)]); }; } }), z = /* @__PURE__ */ W({ name: "FSearchBox", props: x, emits: ["update:modelValue", "change", "selectedValue", "clickButton"], setup(e, t) { M(e.data); const n = M(), c = M(), b = M(e.placeholder), P = '<i class="f-icon f-icon-clockwise f-icon-spin"></i>', y = U(() => e.loading ? P : e.buttonContent); M(e.editable); const F = M(e.modelValue); _(F, (a) => { var r; (r = c.value) == null || r.search(a), t.emit("update:modelValue", a); }), _(() => e.modelValue, (a) => { F.value = a; }); function O(a) { n.value.commitValue(a); } function d(a) { t.emit("change", a); } function l(a) { t.emit("selectedValue", a); } function o(a) { t.emit("clickButton", a); } function u() { n.value.togglePopup(); } return t.expose({ togglePopup: u }), () => { const a = { default: t.slots.default }; return V(ge, { ref: n, "button-content": y.value, "custom-class": e.customClass, updateOn: e.updateOn, placeholder: b.value, onChange: (r) => d(r), onClickButton: (r) => o(r), disable: e.disable, "enable-clear": !0, "button-behavior": "Execute", modelValue: F.value, "onUpdate:modelValue": (r) => F.value = r, "popup-host": e.popupHost, "popup-right-boundary": e.popupRightBoundary, "popup-offset-x": e.popupOffsetX, "popup-on-input": e.showDropdown, "popup-on-focus": e.showDropdown, limitContentBySpace: !0, placement: "auto" }, { default: () => [e.showDropdown && V(ce, { ref: c, data: e.data, idField: e.idField, textField: e.textField, onConfirmResult: O, onSearchedValue: (r) => l(r), loading: e.loading, maxHeight: e.maxHeight }, a)], ...t.slots }); }; } }); function st(e, t, n) { var A; const c = "", b = "", P = M(); let y; function F() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function O() { return !1; } function d() { return (t == null ? void 0 : t.schema.componentType) !== "frame"; } function l() { return (t == null ? void 0 : t.schema.componentType) === "frame"; } function o(s) { if (!s || !s.value) return null; if (s.value.schema && s.value.schema.type === "component") return s.value; const g = M(s == null ? void 0 : s.value.parent), m = o(g); return m || null; } function u(s = t) { var B; const { componentInstance: g, designerItemElementRef: m } = s; if (!g || !g.value) return null; const { getCustomButtons: h } = g.value; return g.value.canMove || h && ((B = h()) != null && B.length) ? m : u(s.parent); } function a(s) { return !!n; } function r() { return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name); } function i() { } function f(s, g) { var m; !s || !g || (m = t == null ? void 0 : t.setupContext) == null || m.emit("dragEnd"); } function v(s, g) { const { componentType: m } = s; let h = he(m, s, g); const B = m.toLowerCase().replace(/-/g, "_"); return h && !h.id && h.type === m && (h.id = `${B}_${Math.random().toString().slice(2, 6)}`), h; } function S(s) { } function D(...s) { } function k(s) { if (!s) return; const g = t == null ? void 0 : t.schema, { formSchemaUtils: m } = s; if (g && m.getExpressions().length) { const h = m.getExpressions().findIndex((B) => B.target === g.id); h > -1 && m.getExpressions().splice(h, 1); } } function R(s) { if (!s || !(t != null && t.schema)) return; const g = t.schema, { formSchemaUtils: m } = s; m.removeCommunicationInComponent(g); } function T(s) { k(s), R(s), t != null && t.schema.contents && t.schema.contents.map((g) => { let m = g.id; g.type === "component-ref" && (m = g.component); const h = e.value.querySelectorAll(`#${m}-design-item`); h != null && h.length && Array.from(h).map((B) => { var j; (j = B == null ? void 0 : B.componentInstance) != null && j.value.onRemoveComponent && B.componentInstance.value.onRemoveComponent(s); }); }); } function N() { } function $(s) { var m, h; if (!((m = t == null ? void 0 : t.schema) != null && m.id)) return; !y && s && (y = s.formSchemaUtils); let g = ""; { const { text: B, title: j, label: q, mainTitle: w, name: C, type: L } = t.schema; g = B || j || q || w || C || ((h = K[L]) == null ? void 0 : h.name); } g && y.getControlBasicInfoMap().set(t.schema.id, { componentTitle: g, parentPathName: g }); } function p(s) { var B; const { changeObject: g } = s, { propertyID: m, propertyValue: h } = g; if (["text", "title", "label", "name", "mainTitle"].includes((B = s == null ? void 0 : s.changeObject) == null ? void 0 : B.propertyID) && m && h && ($(), y)) { const j = y.getControlBasicInfoMap(), q = j.keys().toArray().filter((w) => { var C, L; return ((C = j.get(w)) == null ? void 0 : C.reliedComponentId) === ((L = t == null ? void 0 : t.schema) == null ? void 0 : L.id); }); q != null && q.length && q.forEach((w) => { const C = j.get(w).parentPathName.split(" > "); C[0] = h, j.get(w).parentPathName = C.join(" > "); }); } } function E(s) { p(s); } return P.value = { canMove: F(), canSelectParent: O(), canDelete: d(), canNested: !l(), contents: t == null ? void 0 : t.schema.contents, elementRef: e, parent: (A = t == null ? void 0 : t.parent) == null ? void 0 : A.componentInstance, schema: t == null ? void 0 : t.schema, styles: c, designerClass: b, canAccepts: a, getBelongedComponentInstance: o, getDraggableDesignItemElement: u, getDraggingDisplayText: r, getPropConfig: D, getDragScopeElement: i, onAcceptMovedChildElement: f, onChildElementMovedOut: S, addNewChildComponentSchema: v, triggerBelongedComponentToMoveWhenMoved: M(!1), triggerBelongedComponentToDeleteWhenDeleted: M(!1), onRemoveComponent: T, getCustomButtons: N, onPropertyChanged: E, setComponentBasicInfoMap: $, updateContextSchema: t == null ? void 0 : t.updateContextSchema }, P; } const ft = /* @__PURE__ */ W({ name: "FSearchBoxDesign", props: x, emits: ["update:modelValue", "change"], setup(e, t) { const n = M(e.data), c = M(), b = M(), P = M("请输入关键词"), y = M('<i class="f-icon f-icon-search"></i>'), F = M(e.modelValue), O = M(), d = de("design-item-context"), l = st(O, d); me(() => { O.value.componentInstance = l; }), t.expose(l.value), _(F, (a) => { var r; (r = b.value) == null || r.search(a), t.emit("update:modelValue", a); }), _(() => e.modelValue, (a) => { F.value = a; }); function o(a) { c.value.commitValue(a); } function u(a) { t.emit("change", a); } return () => V("div", { ref: O }, [V(ve("f-button-edit"), { ref: c, "button-content": y.value, placeholder: P.value, onChange: u, "enable-clear": !0, "button-behavior": "Execute", modelValue: F.value, "onUpdate:modelValue": (a) => F.value = a, "popup-host": e.popupHost, "popup-right-boundary": e.popupRightBoundary, "popup-offset-x": e.popupOffsetX, "popup-on-input": !0, "popup-on-focus": !0 }, { default: () => [V(ce, { ref: b, data: n.value, onConfirmResult: o }, null)] })]); } }); z.install = (e) => { e.component(z.name, z); }; z.register = (e, t, n, c) => { e["search-box"] = z, t["search-box"] = ae; }; z.registerDesigner = (e, t, n) => { e["search-box"] = ft, t["search-box"] = ae; }; export { z as FSearchBox, z as default, ae as propsResolver, x as searchBoxProps };