@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,096 lines (1,095 loc) • 36.6 kB
JavaScript
import { useTextBoxDesign as ne, useClear as oe, withInstall as re } from "../../components/common/index.esm.js";
import { createPropsResolver as ie } from "../../components/dynamic-resolver/index.esm.js";
import ae, { inputGroupProps as se } from "../../components/input-group/index.esm.js";
import { ref as O, computed as A, watch as le, createVNode as D, defineComponent as ue, inject as G, onMounted as ce } from "vue";
import { useDesignerComponent as de } from "../../components/designer-canvas/index.esm.js";
import { InputBaseProperty as pe } from "../../components/property-panel/index.esm.js";
import { cloneDeep as Z, isPlainObject as L } from "lodash-es";
const fe = {
id: { Type: String, default: "" },
/** 是否自动完成 */
autocomplete: { Type: String, default: "off" },
/** 自定义CLASS */
customClass: { Type: String, default: "" },
/** 禁用 */
disabled: { Type: Boolean, default: !1 },
/** 允许编辑 */
editable: { Type: Boolean, default: !0 },
/** 启用清除按钮 */
enableClear: { Type: Boolean, default: !0 },
/** 启用提示文本 */
enableTitle: { Type: Boolean, default: !0 },
/** 启用密码 */
enableViewPassword: { Type: Boolean, default: !0 },
/** 始终显示占位符文本 */
forcePlaceholder: { Type: Boolean, default: !1 },
/** 扩展按钮 */
groupText: { Type: String, default: "" },
/** 密码模式 */
type: { Type: String, default: "text" },
/** 最大值 */
max: { type: [Number, String] },
/** 最小值 */
min: { type: [Number, String] },
/** 最大长度 */
maxLength: { Type: Number || void 0, default: void 0 },
/** 最小长度 */
minLength: { Type: Number || void 0, default: void 0 },
/** 组件值 */
modelValue: { Type: String || Boolean, default: "" },
/** 隐藏边线 */
showBorder: { Type: Boolean, default: !0 },
/** 步长 */
step: { Type: Number, default: 1 },
/** 启用提示信息 */
placeholder: { Type: String, default: "" },
precision: { Type: Number, default: 0 },
/** 只读 */
readonly: { Type: Boolean, default: !1 },
/** 当组件禁用或只读时显示后边的按钮 */
showButtonWhenDisabled: { Type: Boolean, default: !1 },
/** tab索引 */
tabIndex: { Type: Number, default: 0 },
/** 文本在输入框中的对齐方式 */
textAlign: { Type: String, default: "left" },
/** 是否启用前置扩展信息;在输入框前面 显示 ① 图标鼠标滑过后显示 */
useExtendInfo: { Type: Boolean, default: !1 },
/** 前置扩展信息 */
extendInfo: { Type: String, default: "" },
/** 输入值 */
value: { Type: String, default: "" },
/** 是否撑开高度 */
autoHeight: { type: Boolean, default: !1 },
/** 自动聚焦 */
autofocus: { type: Boolean, default: !1 },
/** 文本区域可见的行数 */
rows: { type: Number, default: 2 },
/** 展示输入文本数量 */
showCount: { type: Boolean, default: !1 },
showZero: { type: Boolean, default: !1 },
/**
* 作为内嵌编辑器被创建后默认获得焦点
*/
focusOnCreated: { type: Boolean, default: !1 },
/**
* 作为内嵌编辑器被创建后默认选中文本
*/
selectOnCreated: { type: Boolean, default: !1 },
/**
* modelValue 更新时机, 默认 blur; 可选值:blur | input
* - blur: 离开焦点时更新
* - change: 输入时更新
*/
updateOn: { type: String, default: "blur" },
formatValidation: { type: Object, default: {} },
/**
* 是否启用快捷键
*/
keyboard: { type: Boolean, default: !0 }
};
function me(e, t) {
const n = O(e.groupText), i = A(() => e.showButtonWhenDisabled && (e.readonly || e.disabled)), p = A(() => e.type === "password" || e.enableClear || !!e.groupText || i.value);
return { appendedButtonClass: A(() => ({
"input-group-append": !0,
"append-force-show": i.value
})), appendedContent: n, shouldShowAppendedButton: p };
}
function ge(e, t, n, i) {
const { appendedContent: p } = i, y = O(e.enableViewPassword), C = A(() => e.type === "password"), P = '<span class="f-icon f-icon-eye" style="color: rgb(56, 143, 255);"></span>', S = '<span class="f-icon f-icon-eye"></span>', c = O(!1);
le(() => [e.readonly, e.disabled], ([s, d]) => {
C.value && (n.value = s || d ? "password" : n.value, p.value = s || d ? S : p.value);
});
function m() {
return c.value = !c.value, n.value = c.value ? "text" : "password", p.value = c.value ? P : S, !1;
}
function a() {
n.value = C.value ? "password" : "text", p.value = C.value ? y.value ? S : "" : p.value;
}
return a(), { isPassword: C, onClickAppendedButton: m };
}
function ve(e, t, n, i, p) {
const {
appendedButtonClass: y,
appendedContent: C
} = n, P = A(() => e.showButtonWhenDisabled && (!e.editable || !e.readonly) && !e.disabled), S = A(() => C.value && !t.slots.groupTextTemplate), c = A(() => !!t.slots.groupTextTemplate), {
clearButtonClass: m,
clearButtonStyle: a,
onClearValue: s,
shouldShowClearButton: d
} = i;
function o() {
return D("span", {
id: "clearIcon",
class: m.value,
style: a.value,
onClick: (v) => s(v)
}, [D("i", {
class: "f-icon modal_close"
}, null)]);
}
function r(v) {
t.emit("iconMouseEnter", v);
}
function l(v) {
t.emit("iconMouseLeave", v);
}
function f(v) {
P.value && t.emit("clickHandle", {
originalEvent: v
}), v.stopPropagation();
}
const g = e.type === "password" ? p.onClickAppendedButton : f;
function T() {
return D("span", {
class: "input-group-text",
onMouseenter: (v) => r(v),
onMouseleave: (v) => l(v),
innerHTML: C.value,
onClick: (v) => g(v)
}, null);
}
function h() {
return t.slots.groupTextTemplate && t.slots.groupTextTemplate();
}
function w() {
return S.value ? T : c.value ? h : "";
}
const b = w();
return () => D("div", {
class: y.value
}, [d.value && o(), b && b()]);
}
const q = [
{ key: "none", value: "无" },
{ key: "cellNumber", value: "手机号" },
{ key: "tel", value: "座机号/传真号" },
{ key: "telOrCell", value: "手机号/座机号/传真号" },
{ key: "postCode", value: "邮编" },
{ key: "email", value: "电子邮箱" },
{ key: "idCode", value: "身份证号" },
{ key: "carCode", value: "车牌号" },
{ key: "subjectCode", value: "10位数字会计科目代码" },
{ key: "custom", value: "自定义" }
];
function ye(e) {
switch (e) {
case "none":
return "";
case "cellNumber":
return "^1[0-9]{10}$";
case "tel":
return "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,4})?$";
case "telOrCell":
return "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,4})?$|^1[0-9]{10}$";
case "postCode":
return "^[1-9]\\d{5}(?!\\d)$";
case "workCode":
return "^\\d{8}$";
case "email":
return "^[A-Za-z\\d]+([-_.][A-Za-z\\d]+)*@([A-Za-z\\d]+[-.])+[A-Za-z]{2,5}$";
case "idCode":
return "^[1-9]\\d{5}[1-9]\\d{3}((0[1-9])|(1[0-2]))(0[1-9]|([1|2][0-9])|3[0-1])((\\d{4})|\\d{3}X)$";
case "carCode":
return "^([京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-Z][·\\s]?[A-HJ-NP-Z0-9]{4,5}[挂学警港澳]?|粤[Z港澳][·\\s]?[港澳][0-9A-HJ-NP-Z]{4}|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼][A-Z][·\\s]?([DF][0-9A-HJ-NP-Z][0-9]{4}|[0-9]{5}[DF])[挂港澳]?|[使领][0-9]{3}[·\\s]?[0-9]{3}|临[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼][A-Z][·\\s]?[0-9A-Z]{4,5}|[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼][A-Z]?[·\\s]?警[0-9A-Z]{4}|[军海空][A-Z][·\\s]?[0-9]{4,5}|WJ(?:[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼]|\\d{2})[·\\s]?[0-9A-Z]{4,5})$";
case "carCodeNew":
return "^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF])|([DF][A-HJ-NP-Z0-9][0-9]{4}))$";
case "subjectCode":
return "^\\d{10}$";
}
return "";
}
function be(e) {
var t;
return "请输入正确的" + ((t = q.find((n) => n.key === e)) == null ? void 0 : t.value);
}
const Ce = {
convertTo: (e, t, n, i) => {
e.editor.formatValidation || (e.editor.formatValidation = { type: "none" }), e.editor.formatValidation.type = n, e.editor.formatValidation.expression = ye(n), e.editor.formatValidation.message = be(n);
},
convertFrom: (e, t, n) => e.editor.formatValidation ? t === "type" ? e.editor.formatValidation[t] || "none" : e.editor.formatValidation[t] : "none"
}, z = {
convertTo: (e, t, n, i) => {
e.editor.formatValidation || (e.editor.formatValidation = { type: "none" }), e.editor.formatValidation[t] = n;
},
convertFrom: (e, t, n) => e.editor.formatValidation ? e.editor.formatValidation[t] : e.editor[t]
};
class Te extends pe {
constructor(t, n) {
super(t, n);
}
getPropertyConfig(t, n) {
return super.getPropertyConfig(t, n), this.propertyConfig.categories.formatValidation = this.getFormatValidation(t), this.propertyConfig;
}
getEditorProperties(t) {
var i, p;
let n;
if (((i = t == null ? void 0 : t.binding) == null ? void 0 : i.type) === "Form") {
const y = this.schemaService.getFieldByIDAndVMID(t.binding.field, this.viewModelId);
(p = y == null ? void 0 : y.schemaField) != null && p.type && (n = y.schemaField.type.length);
}
return this.getComponentConfig(t, {}, {
maxLength: {
description: "文本字数最大长度",
title: "最大长度",
type: "number",
editor: {
nullable: !0,
min: 0,
useThousands: !1,
max: n
}
},
enableViewPassword: {
description: "",
title: "启用密码",
visible: !1,
type: "boolean"
}
});
}
getFormatValidation(t) {
var i, p, y;
const n = {
title: "输入格式校验",
description: "输入格式校验",
properties: {
type: {
title: "输入类型",
type: "enum",
description: "输入类型",
defaultValue: "",
editor: {
type: "combo-list",
textField: "value",
valueField: "key",
idField: "key",
editable: !1,
data: q
},
refreshPanelAfterChanged: !0,
$converter: Ce,
parentPropertyID: "formatValidation"
}
}
};
return (i = t.editor.formatValidation) != null && i.type && ((p = t.editor.formatValidation) == null ? void 0 : p.type) !== "none" && (n.properties.message = {
title: "输入错误提示",
type: "string",
description: "输入错误提示",
$converter: z,
parentPropertyID: "formatValidation"
}), ((y = t.editor.formatValidation) == null ? void 0 : y.type) === "custom" && (n.properties.expression = {
title: "匹配正则",
type: "string",
description: "匹配正则",
$converter: z,
parentPropertyID: "formatValidation"
}), n;
}
}
function Se(e, t) {
const n = e.schema;
function i(p, y) {
return new Te(p, t).getPropertyConfig(n, y);
}
return { getPropsConfig: i };
}
const V = /* @__PURE__ */ ue({
name: "FInputGroupDesign",
props: fe,
emits: ["updateExtendInfo", "clear", "valueChange", "clickHandle", "blurHandle", "focusHandle", "enterHandle", "iconMouseEnter", "iconMouseLeave", "keyupHandle", "keydownHandle", "inputClick"],
setup(e, t) {
const n = O(e.modelValue), i = O(e.modelValue), p = ne(e, t, n, i), {
inputGroupClass: y,
inputType: C,
inputGroupStyle: P
} = p, S = me(e), {
shouldShowAppendedButton: c
} = S, m = oe(e, t, p), {
onMouseEnter: a,
onMouseLeave: s
} = m, d = ge(e, t, C, S), o = O(), r = G("designer-host-service"), l = G("design-item-context"), f = Se(l, r), g = de(o, l, f);
ce(() => {
o.value.componentInstance = g;
}), t.expose(g.value);
const T = ve(e, t, S, m, d), h = O();
return () => D("div", {
id: "inputGroup",
ref: o,
class: y.value,
style: P.value,
onMouseenter: a,
onMouseleave: s
}, [D("input", {
ref: h,
class: "form-control",
readonly: !0,
placeholder: e.placeholder
}, null), c.value && T()]);
}
});
function W(e, t) {
let n;
function i(a) {
const { properties: s, title: d, ignore: o } = a, r = o && Array.isArray(o), l = Object.keys(s).reduce((f, g) => ((!r || !o.find((T) => T === g)) && (f[g] = s[g].type === "object" && s[g].properties ? i(s[g]) : Z(s[g].default)), f), {});
if (d && (!r || !o.find((f) => f === "id"))) {
const f = d.toLowerCase().replace(/-/g, "_");
l.id = `${f}_${Math.random().toString().slice(2, 6)}`;
}
return l;
}
function p(a) {
const { properties: s, title: d, required: o } = a;
if (o && Array.isArray(o)) {
const r = o.reduce((l, f) => (l[f] = s[f].type === "object" && s[f].properties ? i(s[f]) : Z(s[f].default), l), {});
if (d && o.find((l) => l === "id")) {
const l = d.toLowerCase().replace(/-/g, "_");
r.id = `${l}_${Math.random().toString().slice(2, 6)}`;
}
return r;
}
return {
type: d
};
}
function y(a, s = {}, d) {
const o = e[a];
if (o) {
let r = p(o);
const l = t[a];
return r = l ? l({ getSchemaByType: y }, r, s, d) : r, n != null && n.appendIdentifyForNewControl && n.appendIdentifyForNewControl(r), r;
}
return null;
}
function C(a, s) {
const d = i(s);
return Object.keys(d).reduce((o, r) => (Object.prototype.hasOwnProperty.call(a, r) && (o[r] && L(o[r]) && L(a[r] || !a[r]) ? Object.assign(o[r], a[r] || {}) : o[r] = a[r]), o), d), d;
}
function P(a, s) {
return Object.keys(a).filter((o) => a[o] != null).reduce((o, r) => {
if (s.has(r)) {
const l = s.get(r);
if (typeof l == "string")
o[l] = a[r];
else {
const f = l(r, a[r], a);
Object.assign(o, f);
}
} else
o[r] = a[r];
return o;
}, {});
}
function S(a, s, d = /* @__PURE__ */ new Map()) {
const o = C(a, s);
return P(o, d);
}
function c(a) {
var d;
const s = a.type;
if (s) {
const o = e[s];
if (!o)
return a;
const r = C(a, o), l = ((d = a.editor) == null ? void 0 : d.type) || "";
if (l) {
const f = e[l], g = C(a.editor, f);
r.editor = g;
}
return r;
}
return a;
}
function m(a) {
n = a;
}
return { getSchemaByType: y, resolveSchemaWithDefaultValue: c, resolveSchemaToProps: S, mappingSchemaToProps: P, setDesignerContext: m };
}
const he = {}, we = {}, { getSchemaByType: Tt, resolveSchemaWithDefaultValue: Fe, resolveSchemaToProps: St, mappingSchemaToProps: ht, setDesignerContext: wt } = W(he, we);
function Pe(e = {}) {
function t(c, m, a, s) {
if (typeof a == "number")
return s[c].length === a;
if (typeof a == "object") {
const d = Object.keys(a)[0], o = a[d];
if (d === "not")
return Number(s[c].length) !== Number(o);
if (d === "moreThan")
return Number(s[c].length) >= Number(o);
if (d === "lessThan")
return Number(s[c].length) <= Number(o);
}
return !1;
}
function n(c, m, a, s) {
return s[c] && s[c].propertyValue && String(s[c].propertyValue.value) === String(a);
}
const i = /* @__PURE__ */ new Map([
["length", t],
["getProperty", n]
]);
Object.keys(e).reduce((c, m) => (c.set(m, e[m]), c), i);
function p(c, m) {
const a = c;
return typeof m == "number" ? [{ target: a, operator: "length", param: null, value: Number(m) }] : typeof m == "boolean" ? [{ target: a, operator: "getProperty", param: c, value: !!m }] : typeof m == "object" ? Object.keys(m).map((s) => {
if (s === "length")
return { target: a, operator: "length", param: null, value: m[s] };
const d = s, o = m[s];
return { target: a, operator: "getProperty", param: d, value: o };
}) : [];
}
function y(c) {
return Object.keys(c).reduce((a, s) => {
const d = p(s, c[s]);
return a.push(...d), a;
}, []);
}
function C(c, m) {
if (i.has(c.operator)) {
const a = i.get(c.operator);
return a && a(c.target, c.param, c.value, m) || !1;
}
return !1;
}
function P(c, m) {
return y(c).reduce((d, o) => d && C(o, m), !0);
}
function S(c, m) {
const a = Object.keys(c), s = a.includes("allOf"), d = a.includes("anyOf"), o = s || d, f = (o ? c[o ? s ? "allOf" : "anyOf" : "allOf"] : [c]).map((T) => P(T, m));
return s ? !f.includes(!1) : f.includes(!0);
}
return { parseValueSchema: S };
}
const Be = {
convertTo: (e, t, n, i) => {
e.appearance || (e.appearance = {}), e.appearance[t] = n;
},
convertFrom: (e, t, n) => e.appearance ? e.appearance[t] : e[t]
}, xe = {
convertFrom: (e, t, n) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Me = {
convertTo: (e, t, n, i) => {
e.editor && (e.editor[t] = n);
},
convertFrom: (e, t, n) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, ke = {
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: "多语输入框" }
}, Oe = {
convertFrom: (e, t, n) => {
var p;
const i = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((p = ke[i]) == null ? void 0 : p.name) || i;
}
}, Ae = {
convertTo: (e, t, n, i) => {
e[t] = e[t];
},
convertFrom: (e, t, n) => e.editor ? n.getRealEditorType(e.editor.type) : ""
}, Ee = {
convertTo: (e, t, n, i) => {
(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";
}
}, $e = {
convertTo: (e, t, n, i) => {
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 : ""
}, De = {
convertTo: (e, t, n, i) => {
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 "";
}
}, Ne = {
convertTo: (e, t, n, i) => {
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 : ""
}, je = {
convertTo: (e, t, n, i) => {
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;
}
}
}, Ve = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, n) => {
if (n && n.length > 0) {
const i = n[0];
e.binding || (e.binding = {}), e.binding.type = "Form", e.binding.path = i.bindingField, e.binding.field = i.id, e.binding.fullPath = i.path, e.path = i.bindingPath;
}
}
}, He = {
convertTo: (e, t, n, i) => {
e.pagination || (e.pagination = {}), e.pagination[t] = n;
},
convertFrom: (e, t, n) => e.pagination ? e.pagination[t] : e[t]
}, Ie = {
convertTo: (e, t, n, i) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = n;
},
convertFrom: (e, t, n) => e.rowNumber ? e.rowNumber[t] : e[t]
}, Re = {
convertTo: (e, t, n, i) => {
e.selection || (e.selection = {}), e.selection[t] = n;
},
convertFrom: (e, t, n) => e.selection ? e.selection[t] : e[t]
}, Ge = {
convertFrom: (e, t, n) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, Ze = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, n) => {
e[t] = n;
}
}, Le = {
convertTo: (e, t, n, i) => {
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 i, p;
return (i = e.formatter) != null && i.data && t === "formatterEnumData" && !e.formatterEnumData ? (p = e.formatter) == null ? void 0 : p.data : e.formatterEnumData;
}
}, qe = {
convertTo: (e, t, n, i) => {
e.sort || (e.sort = {}), e.sort[t] = n;
},
convertFrom: (e, t, n) => {
var i, p;
if (t === "mode")
return ((i = e.sort) == null ? void 0 : i.mode) || "client";
if (t === "multiSort")
return !!((p = e.sort) != null && p.multiSort);
}
}, We = {
convertTo: (e, t, n, i) => {
e.filter || (e.filter = {}), e.filter[t] = n;
},
convertFrom: (e, t, n) => {
var i;
if (t === "mode")
return ((i = e.filter) == null ? void 0 : i.mode) || "client";
}
}, _e = {
convertTo: (e, t, n, i) => {
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 _(e, t, n) {
const i = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Be],
["/converter/buttons.converter", xe],
["/converter/property-editor.converter", Me],
["/converter/items-count.converter", Ge],
["/converter/type.converter", Oe],
["/converter/change-editor.converter", Ae],
["/converter/change-formatter.converter", Ee],
["/converter/column-command.converter", $e],
["/converter/column-option.converter", De],
["/converter/summary.converter", Ne],
["/converter/group.converter", je],
["/converter/form-group-label.converter", Ze],
["/converter/field-selector.converter", Ve],
["/converter/pagination.converter", He],
["/converter/row-number.converter", Ie],
["/converter/grid-selection.converter", Re],
["/converter/size.converter", Le],
["/converter/change-formatter-enum.converter", ze],
["/converter/grid-sort.converter", qe],
["/converter/grid-filter.converter", We],
["/converter/row-option.converter", _e]
]), p = /* @__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 }]
]), y = Pe();
function C(o, r) {
return () => y.parseValueSchema(o, r);
}
function P(o, r, l) {
return o.includes("visible") && r.visible !== void 0 ? typeof r.visible == "boolean" ? () => !!r.visible : r.visible === void 0 ? !0 : C(r.visible, l) : () => !0;
}
function S(o, r, l) {
return o.includes("readonly") && r.readonly !== void 0 ? typeof r.readonly == "boolean" ? () => !!r.readonly : C(r.readonly, l) : () => !1;
}
function c(o, r) {
const l = o.$converter || r;
return typeof l == "string" && l && i.has(l) ? i.get(l) || null : l || null;
}
function m(o, r, l, f, g, T = "", h = "") {
return Object.keys(o).map((b) => {
const v = O(1), B = b, u = o[b], F = Object.keys(u), N = u.title, E = u.type, $ = p.get(E) || { type: "input-group", enableClear: !1 }, k = u.editor ? Object.assign({}, $, u.editor) : Object.assign({}, $), H = P(F, u, r), j = S(F, u, r);
k.readonly = k.readonly === void 0 ? j() : k.readonly;
const I = u.type === "cascade" ? m(u.properties, r, l, f, g, T, h) : [], U = !0;
let x = c(u, h);
const X = A({
get() {
if (v.value) {
if (["class", "style"].find((te) => te === B) && !x && (x = i.get("/converter/appearance.converter") || null), x && x.convertFrom)
return x.convertFrom(l, b, g, T);
const M = l[b];
return Object.prototype.hasOwnProperty.call(u, "defaultValue") && (M === void 0 || typeof M == "string" && M === "") ? u.type === "boolean" ? u.defaultValue : u.defaultValue || "" : M;
}
return null;
},
set(M) {
v.value += 1, x && x.convertTo ? (x.convertTo(f, b, M, g, T), x.convertTo(l, b, M, g, T)) : (f[b] = M, l[b] = M);
}
}), { refreshPanelAfterChanged: Q, description: Y, isExpand: K, parentPropertyID: ee } = u, R = { propertyID: B, propertyName: N, propertyType: E, propertyValue: X, editor: k, visible: H, readonly: j, cascadeConfig: I, hideCascadeTitle: U, refreshPanelAfterChanged: Q, description: Y, isExpand: K, parentPropertyID: ee };
return r[B] = R, R;
});
}
function a(o, r, l = {}) {
const f = {}, g = e[o];
return g && g.categories ? Object.keys(g.categories).map((h) => {
const w = g.categories[h], b = w == null ? void 0 : w.title, v = m(w.properties || {}, f, {}, l, r);
return { categoryId: h, categoryName: b, properties: v };
}) : [];
}
function s(o, r, l, f, g = "") {
const T = r.$ref.schema, h = r.$ref.converter, w = l[T], b = w.type, v = n(w), B = {}, u = e[b];
if (u && u.categories) {
const F = u.categories[o], N = F == null ? void 0 : F.title;
h && Object.keys(F.properties).forEach((k) => {
F.properties[k].$converter = h;
});
const E = (F == null ? void 0 : F.properties) || {}, $ = m(E, B, v, w, f, g);
return { categoryId: o, categoryName: N, properties: $ };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function d(o, r, l, f, g) {
const T = o.type, h = n(o), w = {};
let b = g || e[T];
if (b && Object.keys(b).length === 0 && l && l.getPropConfig && (b = l.getPropConfig(f)), b && b.categories) {
const v = [];
return Object.keys(b.categories).map((B) => {
const u = b.categories[B];
if (u.$ref) {
v.push(s(B, u, o, r, f));
return;
}
const F = u == null ? void 0 : u.title, N = u == null ? void 0 : u.tabId, E = u == null ? void 0 : u.tabName, $ = u == null ? void 0 : u.hide, k = u == null ? void 0 : u.hideTitle, H = m(u.properties || {}, w, h, o, r, f, u.$converter), { setPropertyRelates: j } = u, I = u == null ? void 0 : u.parentPropertyID;
v.push({ categoryId: B, categoryName: F, tabId: N, tabName: E, hide: $, properties: H, hideTitle: k, setPropertyRelates: j, parentPropertyID: I });
}), v;
}
return [];
}
return {
getPropertyConfigBySchema: d,
getPropertyConfigByType: a,
propertyConverterMap: i
};
}
const Je = {}, Ue = {};
_(Je, Ue, Fe);
const Xe = {}, Qe = {}, { getSchemaByType: Ft, resolveSchemaWithDefaultValue: Ye, resolveSchemaToProps: Pt, mappingSchemaToProps: Bt, setDesignerContext: xt } = W(Xe, Qe), Ke = {}, et = {};
_(Ke, et, Ye);
function tt(e, t) {
return { customClass: t.class, customStyle: t.style };
}
const nt = /* @__PURE__ */ new Map([
["appearance", tt]
]);
function ot(e, t, n) {
return t;
}
const rt = "https://json-schema.org/draft/2020-12/schema", it = "https://farris-design.gitee.io/input-group.schema.json", at = "input-group", st = "A Farris Input Component", lt = "object", ut = {
id: {
description: "The unique identifier for a Input Group",
type: "string"
},
type: {
description: "The type string of Input Group component",
type: "string",
default: "input-group"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
binding: {
description: "",
type: "object",
default: {}
},
formatValidation: {
description: "",
type: "object",
default: {}
},
editable: {
description: "",
type: "boolean",
default: !0
},
enableLinkLabel: {
description: "",
type: "boolean",
default: !1
},
label: {
description: "",
type: "string",
default: ""
},
labelWidth: {
description: "",
type: "number"
},
placeholder: {
description: "",
type: "string",
default: ""
},
readonly: {
description: "",
type: "boolean",
default: !1
},
disabled: {
description: "",
type: "boolean",
default: !1
},
required: {
description: "",
type: "boolean",
default: !1
},
tabIndex: {
description: "",
type: "number",
default: -1
},
maxLength: {
description: "",
type: "number",
default: ""
},
textAlign: {
description: "",
type: "enum",
enum: [
"left",
"middle",
"right"
],
default: "left"
},
visible: {
description: "",
type: "boolean",
default: !0
},
onBlur: {
description: "",
type: "string",
default: ""
},
onClickLinkLabel: {
description: "",
type: "sting",
default: ""
},
addonDisabled: {
description: "",
type: "boolean",
default: !1
},
addonContent: {
description: "",
type: "string",
default: ""
},
autoHeight: {
description: "",
type: "boolean",
default: !1
},
enableAddon: {
description: "",
type: "boolean",
default: !1
},
addonType: {
description: "",
type: "string",
enum: [
"button",
"static"
],
default: "button"
},
enableClear: {
description: "",
type: "boolean",
default: !0
},
enableViewPassword: {
description: "",
type: "boolean",
default: !1
},
inputType: {
description: "",
type: "string",
enum: [
"input",
"password",
"text"
],
default: "input"
},
maxHeight: {
description: "",
type: "number",
default: 500
},
popUp: {
description: "",
type: "object",
properties: {
footerButtons: {
type: "array",
default: []
},
height: {
type: "number",
default: 600
},
dataMapping: {
type: "object"
},
contents: {
type: "array",
default: []
},
showMaxButton: {
type: "boolean",
default: !0
},
showCloseButton: {
type: "boolean",
default: !0
},
showFooter: {
type: "boolean",
default: !0
},
title: {
type: "string",
default: ""
},
width: {
type: "number",
default: 800
}
}
},
groupText: {
description: "",
type: "string",
default: ""
},
onClickHandle: {
description: "",
type: "string",
default: ""
},
showButtonWhenDisabled: {
description: "",
type: "boolean",
default: !1
},
onClear: {
description: "",
type: "string",
default: ""
},
updateOn: {
description: "",
type: "string",
default: "blur"
}
}, ct = [
"type"
], dt = [
"id",
"appearance",
"binding",
"visible"
], pt = {
$schema: rt,
$id: it,
title: at,
description: st,
type: lt,
properties: ut,
required: ct,
ignore: dt
}, J = ie(se, pt, nt, ot);
V.register = (e, t, n, i) => {
e["input-group"] = ae, t["input-group"] = J;
};
V.registerDesigner = (e, t, n) => {
e["input-group"] = V, t["input-group"] = J;
};
const Mt = re(V);
export {
V as FInputGroupDesgin,
Mt as default,
J as propsResolver
};