@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,163 lines (1,162 loc) • 34.4 kB
JavaScript
var _ = Object.defineProperty;
var z = (r, e, t) => e in r ? _(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
var g = (r, e, t) => z(r, typeof e != "symbol" ? e + "" : e, t);
import { defineComponent as A, ref as I, computed as b, watch as D, createVNode as u, createTextVNode as k, inject as N, onMounted as K } from "vue";
import { resolveAppearance as J, resolveToolbar as Q, createPropsResolver as $, createPageHeaderEventHandlerResolver as W, getPropsResolverGenerator as q } from "../dynamic-resolver/index.esm.js";
import X from "../response-toolbar/index.esm.js";
import { getCustomClass as y } from "../common/index.esm.js";
import Y, { responseToolbarResolver as U } from "../../designer/response-toolbar/index.esm.js";
import { DgControl as j, canvasChanged as Z, refreshCanvas as ee, useDesignerComponent as te, FDesignerInnerItem as ne } from "../designer-canvas/index.esm.js";
import { cloneDeep as ie } from "lodash-es";
const V = /* @__PURE__ */ new Map([
["appearance", J],
["toolbar", Q]
]), se = "https://json-schema.org/draft/2020-12/schema", oe = "https://farris-design.gitee.io/page-header.schema.json", re = "page-header", ae = "A Farris Container Component", le = "object", de = {
id: {
description: "The unique identifier for a Page Header",
type: "string"
},
type: {
description: "The type string of Page Header component",
type: "string",
default: "page-header"
},
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string"
},
style: {
type: "string"
}
},
default: {}
},
showIcon: {
description: "",
type: "boolean",
default: !0
},
icon: {
description: "",
type: "string",
default: "f-icon-page-title-record"
},
iconClass: {
description: "",
type: "string",
default: "f-text-orna-bill"
},
title: {
description: "",
type: "string",
default: ""
},
subTitle: {
description: "",
type: "string",
default: ""
},
toolbar: {
description: "",
type: "object",
properties: {
appearance: {
description: "",
type: "object",
properties: {
class: {
type: "string",
default: "col-6"
}
}
},
id: {
description: "",
type: "string"
},
type: {
description: "",
type: "string",
default: "response-toolbar"
},
alignment: {
description: "The alignment of Response Toolbar Button.",
type: "string",
default: "right"
},
buttons: {
description: "The items of Response Toolbar.",
type: "array",
default: []
},
visible: {
description: "",
type: "boolean",
default: !0
}
}
},
titleContentClass: {
description: "",
type: "string",
default: ""
},
contentClass: {
description: "",
type: "string",
default: ""
},
downContentClass: {
description: "",
type: "string",
default: ""
},
showPagination: {
description: "",
type: "boolean",
default: !1
},
prePaginationDisabled: {
description: "",
type: "boolean",
default: !0
},
nextPaginationDisabled: {
description: "",
type: "boolean",
default: !1
},
visible: {
description: "",
type: "boolean",
default: !0
},
titleContentHtml: {
description: "",
type: "string",
default: ""
},
titleRenderFunction: {
description: "",
type: "function",
default: null
},
contentHtml: {
description: "",
type: "string",
default: ""
},
contentRenderFunction: {
description: "",
type: "function",
default: null
},
downContentHtml: {
description: "",
type: "string",
default: ""
},
downContentRenderFunction: {
description: "",
type: "function",
default: null
}
}, ce = [
"id",
"type"
], S = {
$schema: se,
$id: oe,
title: re,
description: ae,
type: le,
properties: de,
required: ce
};
function M(r, e, t) {
return e.title = "标题", e;
}
const R = {
/** 组件自定义样式 */
customClass: { type: String, default: "" },
/** 是否显示图标 */
showIcon: { type: Boolean, default: !0 },
/** 图标的名称 */
icon: { type: String, default: "f-icon-page-title-record" },
/** 图标自定义样式,比如颜色、背景 */
iconClass: { type: String, default: "f-text-orna-bill" },
/** 主标题 */
title: { type: String, default: "" },
/** 副标题 */
subTitle: { type: String, default: "" },
/** 按钮组的样式 */
buttonClass: { type: String, default: "col-6" },
/** 按钮组的标识 */
toolbarId: { type: String, default: "" },
/** 按钮组 */
buttons: { type: Array, default: [] },
/** 标题区域模板自定义样式 */
titleContentClass: { type: String, default: "" },
/** 内容区域模板自定义样式 */
contentClass: { type: String, default: "" },
/** 下方扩展区域模板自定义样式 */
downContentClass: { type: String, default: "" },
/** 是否显示翻页图标 */
showPagination: { type: Boolean, default: !1 },
/** 向前翻页是否禁用 */
prePaginationDisabled: { type: Boolean, default: !0 },
/** 向后翻页是否禁用 */
nextPaginationDisabled: { type: Boolean, default: !1 },
/** 控制是否可见 */
visible: { type: Boolean, default: !0 },
/** 控制按钮是否可见 */
buttonsVisible: { type: Boolean, default: !0 },
/** 标题区域 */
titleRenderFunction: { type: Function },
/** 内容区域 */
contentRenderFunction: { type: Function },
/** 下方扩展区域 */
downContentRenderFunction: { type: Function }
}, B = Object.assign({}, R, {
componentId: { type: String, default: "" },
titleContentHtml: { type: String, default: "" },
contentHtml: { type: String, default: "" },
downContentHtml: { type: String, default: "" }
}), Me = $(R, S, V, M), Re = $(B, S, V, M), ue = W(), pe = q(
R,
S,
V,
M
), ge = q(
B,
S,
V,
M
), O = /* @__PURE__ */ A({
name: "FPageHeader",
props: R,
emits: ["click", "prePaginationClick", "nextPaginationClick"],
setup(r, e) {
const t = I(r.buttons), n = (h, F) => {
e.emit("click", h, F);
}, i = b(() => {
const h = {
"f-page-header": !0,
"d-none": !r.visible
};
return y(h, r.customClass);
}), o = b(() => y({
"f-title-icon": !0
}, r.iconClass)), s = b(() => y({
"f-icon": !0
}, r.icon)), l = b(() => y({
"f-title": !0
}, r.titleContentClass)), a = b(() => y({
"f-content": !0
}, r.contentClass)), d = b(() => y({
"f-page-header-extend": !0
}, r.downContentClass)), c = b(() => ({
"f-icon f-icon-arrow-w": !0,
"f-state-disabled": r.prePaginationDisabled
})), p = b(() => ({
"f-icon f-icon-arrow-e": !0,
"f-state-disabled": r.nextPaginationDisabled
}));
function m(h) {
r.prePaginationDisabled || e.emit("prePaginationClick", h);
}
function x(h) {
r.nextPaginationDisabled || e.emit("nextPaginationClick", h);
}
function C() {
return e.slots.titleContent ? u("div", {
class: l.value
}, [k(" "), e.slots.titleContent()]) : r.titleRenderFunction ? u("div", {
class: l.value
}, [r.titleRenderFunction()]) : u("div", {
class: "f-title"
}, [r.showIcon && r.icon ? u("span", {
class: o.value
}, [u("i", {
class: s.value
}, null)]) : "", u("h4", {
class: "f-title-text"
}, [r.title]), r.subTitle ? u("h5", {
class: "f-title-subtitle"
}, [r.subTitle]) : "", r.showPagination ? u("div", {
class: "f-title-pagination"
}, [u("span", {
class: c.value,
onClick: m
}, null), u("span", {
class: p.value,
onClick: x
}, null)]) : ""]);
}
function w() {
return e.slots.content ? u("div", {
class: a.value
}, [k(" "), e.slots.content()]) : r.contentRenderFunction ? u("div", {
class: a.value
}, [r.contentRenderFunction()]) : null;
}
function v() {
if (r.buttons && r.buttons.length > 0)
return u(X, {
id: r.toolbarId,
customClass: r.buttonClass,
visible: r.buttonsVisible,
items: t.value,
onClick: n
}, null);
}
function T() {
return e.slots.downContent ? u("div", {
class: d.value
}, [k(" "), e.slots.downContent()]) : r.downContentRenderFunction ? u("div", {
class: d.value
}, [r.downContentRenderFunction()]) : null;
}
return D(() => r.buttons, (h) => {
t.value = h;
}, {
deep: !0
}), () => r.visible ? u("div", {
class: i.value
}, [u("nav", {
class: "f-page-header-base"
}, [C(), w(), v()]), T()]) : null;
}
});
function fe(r) {
const { formSchemaUtils: e, formStateMachineUtils: t } = r;
function n(a, d = "") {
return {
path: d + a.code,
field: a.id,
fullPath: a.code
};
}
function i(a, d = "") {
const c = e.getViewModelById(a);
return c ? c.states.map((p) => n(p, d)) : [];
}
function o(a) {
const d = e.getRootViewModelId(), c = i(a);
if (a === d)
return c;
const p = i(d, "root-component.");
return [...c, ...p];
}
function s(a) {
return a.binding && a.binding.path || a.id || "";
}
function l() {
return t && t.getRenderStates() || [];
}
return { getVariables: o, getControlName: s, getStateMachines: l };
}
class me {
constructor(e) {
g(this, "sessionVariables", [
{
key: "CurrentSysOrgName",
name: "当前组织Name",
description: "当前组织Name"
},
// {
// key: "CurrentSysOrgCode",
// name: "当前组织Code",
// description: "当前组织Code"
// },
{
key: "CurrentSysOrgId",
name: "当前组织Id",
description: "当前组织Id"
},
{
key: "CurrentUserName",
name: "当前用户Name",
description: "当前用户Name"
},
{
key: "CurrentUserCode",
name: "当前用户Code",
description: "当前用户Code"
},
{
key: "CurrentUserId",
name: "当前用户Id",
description: "当前用户Id"
},
{
key: "CurrentLanguage",
name: "当前语言编号",
description: "当前登录的语言编号,例如简体中文返回'zh-CHS',英文返回'en',繁体中文'zh-CHT'"
}
]);
g(this, "expressionNames", {
compute: "计算表达式",
dependency: "依赖表达式",
validate: "验证表达式",
dataPicking: "帮助前表达式",
visible: "可见表达式",
readonly: "只读表达式",
required: "必填表达式"
});
g(this, "getExpressionConverter", (e, t) => ({
convertFrom: (n, i, o, s) => {
const l = o.getExpressionRuleValue(e, t || i);
return l && l.value || "";
},
convertTo: (n, i, o, s, l) => {
var a;
if (i === "dataPicking" && (o != null && o.target)) {
const d = `${o.target}_dataPicking`;
((a = o.rules) == null ? void 0 : a.some(
(p) => p.id === d && p.value
)) ? n.dictPickingExpressionId = d : delete n.dictPickingExpressionId;
}
s.updateExpression(o);
}
}));
this.formSchemaService = e;
}
getExpressionRule(e, t) {
const n = this.getExpressionData();
if (!n)
return "";
const i = n.find((s) => s.target === e);
if (!i)
return "";
const o = i.rules.find((s) => s.type === t);
return o || "";
}
// 获取上下文表单变量
getContextFormVariables() {
const { module: e } = this.formSchemaService.getFormSchema();
if (!e.viewmodels || e.viewmodels.length === 0)
return [];
const t = this.formSchemaService.getRootViewModelId(), n = this.formSchemaService.getViewModelById(t);
if (!n || !n.states || n.states.length === 0)
return [];
const i = [];
return n.states.filter((o) => o.category === "remote").forEach((o) => {
i.push({
key: o.code,
name: o.name,
description: o.name,
category: o.category
});
}), i;
}
createTreeNode(e, t, n = "label") {
return {
id: e.id,
name: e.name,
bindingPath: e[n],
parents: t,
type: "field"
};
}
buildEntityFieldsTreeData(e = null, t) {
const n = [];
return e == null || e.forEach((i) => {
var l;
const o = this.createTreeNode(i, t);
let s = [];
(l = i.type) != null && l.fields && (s = this.buildEntityFieldsTreeData(i.type.fields, [...t, i.label])), n.push({
data: o,
children: s,
expanded: !0
});
}), n;
}
buildChildEntityTreeData(e = null, t) {
const n = [];
return e == null || e.forEach((i) => {
var a, d;
const o = this.createTreeNode(i, t);
o.type = "entity";
const s = this.buildEntityFieldsTreeData((a = i.type) == null ? void 0 : a.fields, [...t, i.label]), l = this.buildChildEntityTreeData((d = i.type) == null ? void 0 : d.entities, [...t, i.label]);
l != null && l.length && (s == null || s.push(...l)), n.push({
data: o,
children: s || [],
// 空值回退
expanded: !0
});
}), n;
}
getEntitiesTreeData() {
const e = this.formSchemaService.getSchemaEntities();
if (!(e != null && e.length))
return [];
const t = e[0];
if (!(t != null && t.type))
return [];
const n = this.buildEntityFieldsTreeData(t.type.fields, [t.code]), i = this.buildChildEntityTreeData(t.type.entities, [t.code]);
return i != null && i.length && (n == null || n.push(...i)), {
entityCode: t.code,
fields: [{
data: this.createTreeNode(t, [], "code"),
children: n || []
}]
};
}
getEntitiesAndVariables() {
return {
entities: this.getEntitiesTreeData(),
variables: {
session: {
name: "系统变量",
items: this.sessionVariables,
visible: !1
},
forms: {
name: "表单变量",
items: this.getContextFormVariables(),
visible: !0
}
}
};
}
onBeforeOpenExpression(e, t, n) {
const i = n === "Field" ? e.binding.field : e.id, o = this.getExpressionRule(i, t), s = this.getEntitiesAndVariables(), l = {
message: ["validate", "required", "dataPicking"].includes(t) && o ? o.message : "",
...s
};
return o.messageType != null && (l.messageType = o.messageType), l;
}
buildRule(e, t, n, i) {
const { expression: o, message: s, messageType: l } = t, a = {
id: `${e}_${n}`,
type: n,
value: o
};
return (n === "validate" || n === "dataPicking" || n === "required") && (a.message = s), n === "dataPicking" && (a.messageType = l), n === "validate" && i && (a.elementId = i), a;
}
getExpressionData() {
const { expressions: e } = this.formSchemaService.getFormSchema().module;
return e || [];
}
updateExpression(e, t, n, i) {
const o = t === "Field" ? e.binding.field : e.id, s = this.buildRule(o, n, i, e.type === "form-group" ? e.id : "");
let a = this.getExpressionData().find((c) => c.targetType === t && c.target === o);
const d = (c) => c.value.trim() === "";
if (a) {
const c = a.rules.find((p) => p.id === s.id);
if (c)
d(s) ? a.rules = a.rules.filter((p) => p.id !== s.id) : (Object.assign(c, s), i === "validate" && e.type === "form-group" && (c.elementId = e.id));
else {
if (d(s))
return null;
a.rules = a.rules || [], a.rules.push(s);
}
} else {
if (d(s))
return null;
a = {
target: `${o}`,
rules: [s],
targetType: t
};
}
return a;
}
getExpressionEditorOptions(e, t, n, i) {
return n.reduce((o, s) => {
var a, d;
const l = t === "Field" ? (a = e == null ? void 0 : e.binding) == null ? void 0 : a.field : e.id;
return o[s] = {
hide: t === "Field" ? !!((d = e == null ? void 0 : e.binding) != null && d.field) : !1,
description: "",
title: this.expressionNames[s],
type: "string",
$converter: this.getExpressionConverter(l),
refreshPanelAfterChanged: !0,
editor: {
type: "expression-editor",
singleExpand: !1,
dialogTitle: `${this.expressionNames[s]}编辑器`,
showMessage: s === "validate" || s === "dataPicking" || s === "required",
showMessageType: s === "dataPicking",
beforeOpen: () => this.onBeforeOpenExpression(e, s, t),
onSubmitModal: (c) => {
const p = this.updateExpression(e, t, c, s);
if (i) {
const m = this.buildRule(l, c, s);
i(m);
}
return p;
}
}
}, o;
}, {});
}
getExpressionInfo(e, t, n) {
const i = t === "Field" ? e.binding.field : e.id, o = this.getExpressionRule(i, n), s = {
value: o && o.value,
targetId: i,
targetType: t,
expressionType: n
};
return o && o.message && (s.message = o.message), s;
}
getExpressionConfig(e, t, n = ["compute", "dependency", "validate"], i) {
return {
description: "表达式",
title: "表达式",
hide: !e.binding,
properties: {
...this.getExpressionEditorOptions(e, t, n, i)
}
};
}
getExpressionOptions(e, t, n) {
const i = this.getExpressionInfo(e, t, n);
return {
dialogTitle: `${this.expressionNames[n] || "表达式"}编辑器`,
singleExpand: !1,
showMessage: n === "required",
beforeOpen: () => this.onBeforeOpenExpression(e, n, t),
expressionInfo: i
};
}
}
class he {
constructor(e, t) {
g(this, "componentId");
g(this, "viewModelId");
g(this, "eventsEditorUtils");
g(this, "formSchemaUtils");
g(this, "formMetadataConverter");
g(this, "designViewModelUtils");
g(this, "designViewModelField");
g(this, "controlCreatorUtils");
g(this, "designerHostService");
g(this, "designerContext");
g(this, "modalService", null);
/** 表单规则 */
g(this, "formRule", null);
g(this, "schemaService", null);
g(this, "metadataService", null);
g(this, "propertyConfig", {
type: "object",
categories: {}
});
g(this, "expressionProperty");
var n;
this.componentId = e, this.designerHostService = t, this.eventsEditorUtils = t.eventsEditorUtils, this.formSchemaUtils = t.formSchemaUtils, this.formMetadataConverter = t.formMetadataConverter, this.viewModelId = ((n = this.formSchemaUtils) == null ? void 0 : n.getViewModelIdByComponentId(e)) || "", this.designViewModelUtils = t.designViewModelUtils, this.controlCreatorUtils = t.controlCreatorUtils, this.metadataService = t.metadataService, this.schemaService = t.schemaService, this.designerContext = t.designerContext, this.modalService = t.modalService, this.expressionProperty = new me(this.formSchemaUtils);
}
getFormDesignerInstance() {
var e, t;
return (t = (e = this.designerContext) == null ? void 0 : e.instances) == null ? void 0 : t.formDesigner.value;
}
getTableInfo() {
var e;
return (e = this.schemaService) == null ? void 0 : e.getTableInfoByViewModelId(this.viewModelId);
}
setDesignViewModelField(e) {
var n;
const t = e.binding && e.binding.type === "Form" && e.binding.field;
if (t) {
if (!this.designViewModelField) {
const i = this.designViewModelUtils.getDgViewModel(this.viewModelId);
this.designViewModelField = i.fields.find((o) => o.id === t);
}
e.updateOn = (n = this.designViewModelField) == null ? void 0 : n.updateOn;
}
}
getBasicPropConfig(e) {
return {
description: "Basic Information",
title: "基本信息",
properties: {
id: {
description: "组件标识",
title: "标识",
type: "string",
readonly: !0
},
type: {
description: "组件类型",
title: "控件类型",
type: "select",
editor: {
type: "combo-list",
textField: "name",
valueField: "value",
idField: "value",
editable: !1,
data: [{ value: e.type, name: j[e.type] && j[e.type].name }]
}
}
}
};
}
getAppearanceConfig(e = null, t = {}, n) {
const i = {
title: "外观",
description: "Appearance"
}, o = {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
},
style: {
title: "style样式",
type: "string",
description: "组件的样式",
$converter: "/converter/appearance.converter",
parentPropertyID: "appearance"
}
};
for (const s in t)
o[s] = Object.assign(o[s] || {}, t[s]);
return {
...i,
properties: { ...o },
setPropertyRelates(s, l) {
if (s) {
switch (s && s.propertyID) {
case "class":
case "style": {
Z.value++;
break;
}
}
n && n(s, e, l);
}
}
};
}
/**
*
* @param propertyData
* @param propertyTypes
* @param propertyName
* @param constInfos
* @param variableInfos
* @param expressionType 指定表达式类型,存在属性和表达式类型不一致的情况
* @returns
*/
getPropertyEditorParams(e, t = [], n = "visible", i = {}, o = {}, s = "") {
const { getVariables: l, getControlName: a, getStateMachines: d } = fe(this.designerHostService), c = this.getRealTargetType(e), p = t && t.length > 0 ? t : ["Const", "Variable", "StateMachine", "Expression"], m = {
type: "property-editor",
propertyTypes: p
};
return p.map((x) => {
switch (x) {
case "Const":
Object.assign(m, {
constType: "enum",
constEnums: [{ id: !0, name: "是" }, { id: !1, name: "否" }]
}, i);
break;
case "Expression":
m.expressionConfig = this.getExpressionOptions(e, c, s || n);
break;
case "StateMachine":
m.stateMachines = d();
break;
case "Variable":
Object.assign(m, {
controlName: a(e),
newVariablePrefix: "is",
newVariableType: "Boolean",
variables: l(this.viewModelId),
parentComponentId: this.componentId === "root-component" ? "" : "root-component",
onBeforeOpenVariables: (C) => {
C.value = l(this.viewModelId);
}
}, o), this.designerContext.designerMode === "PC_RTC" && (m.newVariablePrefix = "ext_" + m.newVariablePrefix);
break;
}
}), m;
}
getVisibleProperty(e, t = "") {
var o;
let n = ["Const", "Variable", "StateMachine", "Expression"];
return t === "gridFieldEditor" ? n = ["Const", "Expression"] : t === "form-group" && !((o = e.binding) != null && o.field) && (n = ["Const", "Variable", "StateMachine"]), {
visible: {
title: "是否可见",
type: "boolean",
description: "运行时组件是否可见",
editor: this.getPropertyEditorParams(e, n, "visible")
}
};
}
/**
* 获取行为
* @param propertyData
* @param viewModelId
* @returns
*/
getBehaviorConfig(e, t = "", n = {}, i) {
const o = {
title: "行为",
description: ""
}, s = this.getVisibleProperty(e, t);
for (const a in n)
s[a] = Object.assign(s[a] || {}, n[a]);
const l = this;
return {
...o,
properties: { ...s },
setPropertyRelates(a, d) {
if (a) {
switch (a.propertyID) {
case "disabled":
case "readonly":
case "visible":
l.afterMutilEditorChanged(e, a);
break;
}
i && i(a, d);
}
}
};
}
/**
* 当多值编辑器变更时
* @param propertyData
* @param changeObject
*/
afterMutilEditorChanged(e, t) {
this.addNewVariableToViewModel(t, this.viewModelId), this.updateExpressionValue(t, e), this.clearExpression(t, e);
}
/**
*
* @param propertyId
* @param componentInstance
* @returns
*/
updateElementByParentContainer(e, t) {
const n = t && t.parent && t.parent.schema;
if (!n)
return;
const i = n.contents.findIndex((s) => s.id === e), o = ie(n.contents[i]);
n.contents.splice(i, 1), n.contents.splice(i, 0, o), ee();
}
/**
* 属性编辑器,在编辑过程中会新增变量,此处需要将新增的变量追加到ViewModel中
* @param changeObject
* @param viewModelId
* @returns
*/
addNewVariableToViewModel(e, t) {
const n = e.propertyValue;
if (!(n && typeof n == "object") || !(n.type === "Variable" && n.isNewVariable))
return;
const s = {
id: n.field,
category: "locale",
code: n.fullPath,
name: n.fullPath,
type: n.newVariableType || "String",
isRtcVariable: this.designerContext.designerMode === "PC_RTC" ? !0 : void 0
};
delete n.newVariableType, delete n.isNewVariable, this.formSchemaUtils.getVariableByCode(s.code) || this.formSchemaUtils.getViewModelById("root-viewmodel").states.push(s);
}
getExpressions() {
let e = [];
return this.formRule ? (this.formRule.expressions = this.formRule.expressions || [], e = this.formRule.expressions || []) : e = this.formSchemaUtils.getExpressions(), e;
}
/**
* 更新表达式到expressions节点
* @param changeObject
*/
updateExpressionValue(e, t) {
const n = e.propertyValue;
if (!((n && n.type) === "Expression" && n.expressionInfo))
return;
const { expressionId: s, expressionInfo: l } = n, { targetId: a, targetType: d, expressionType: c, value: p, message: m } = l, x = this.getExpressions();
let C = x.find((v) => v.target === a);
C || (C = { target: a, rules: [], targetType: d }, x.push(C));
const w = C.rules.find((v) => v.type === c);
if (w)
w.value = p, w.message = m, (c === "minDate" || c === "maxDate" || c === "defaultTime") && (w.elementId = t.id);
else {
const v = { id: s, type: c, value: p, message: m, elementId: t.id };
C.rules.push(v);
}
delete n.expressionInfo;
}
/**
* 属性类型切换为非表达式后,清除原表达式
* @param changeObject
* @param propertyData
* @returns
*/
clearExpression(e, t) {
const n = e.propertyValue;
if (n && n.type === "Expression")
return;
const o = e.propertyID, s = this.getExpressions(), l = t.binding ? t.binding.field : t.id, a = s.find((d) => d.target === l);
!a || !a.rules || (a.rules = a.rules.filter((d) => d.type !== o));
}
getExpressionOptions(e, t, n) {
return this.expressionProperty.getExpressionOptions(e, t, n);
}
getRealTargetType(e) {
return ["response-toolbar-item", "tab-toolbar-item", "section-toolbar-item", "drawer-toolbar-item"].indexOf(e.type) > -1 ? "Button" : e.binding && e.binding.field ? "Field" : "Container";
}
createBaseEventProperty(e) {
const t = {};
return t[this.viewModelId] = {
type: "events-editor",
editor: {
initialData: e,
viewSourceHandle: (n) => {
var i;
((i = n.controller) == null ? void 0 : i.label.indexOf(this.formSchemaUtils.getModule().code)) > -1 && this.eventsEditorUtils.jumpToMethod(n);
}
}
}, t;
}
}
class be extends he {
constructor(e, t) {
super(e, t);
}
getPropertyConfig(e) {
return this.propertyConfig.categories.basic = this.getBasicPropConfig(e), this.propertyConfig.categories.appearance = this.getAppearanceProperties(e), this.propertyConfig.categories.template = this.getTemplateConfig(e), this.propertyConfig.categories.behavior = this.getBehaviorConfig(e), this.propertyConfig;
}
getAppearanceProperties(e) {
return {
title: "外观",
description: "",
properties: {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式"
},
icon: {
title: "图标",
type: "string",
description: "图标"
},
title: {
title: "标题",
type: "string",
description: "标题"
}
},
setPropertyRelates(t, n) {
if (t)
switch (t && t.propertyID) {
case "title": {
t.needRefreshControlTree = !0;
break;
}
}
}
};
}
getTemplateConfig(e) {
return {
title: "模板配置",
description: "",
properties: {
titleContentClass: {
title: "标题模板class",
type: "string",
description: "标题模板外层容器的自定义样式"
},
titleContentHtml: {
title: "标题模板",
type: "string",
description: "设置标题HTML模板,替代图标和标题文字区域",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
contentClass: {
title: "内容模板class",
type: "string",
description: "内容模板外层容器的自定义样式"
},
contentHtml: {
title: "内容模板",
type: "string",
description: "设置页头中间区域的模板",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
downContentClass: {
title: "扩展模板class",
type: "string",
description: "扩展模板外层容器的自定义样式"
},
downContentHtml: {
title: "扩展模板",
type: "string",
description: "设置页头下方区域的模板",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
}
}
};
}
}
function Ce(r, e) {
function t(l) {
return !1;
}
function n() {
return !1;
}
function i() {
return !1;
}
function o() {
return !0;
}
function s(l) {
return new be(l, e).getPropertyConfig(r);
}
return {
canAccepts: t,
hideNestedPaddingInDesginerView: o,
getPropsConfig: s,
checkCanDeleteComponent: n,
checkCanMoveComponent: i
};
}
const ve = /* @__PURE__ */ A({
name: "FPageHeaderDesign",
props: B,
emits: ["click"],
setup(r, e) {
const t = I(), n = N("designer-host-service"), i = N("design-item-context"), o = Ce(i.schema, n), s = te(t, i, o), l = I(i.schema.toolbar || {
type: "response-toolbar",
buttons: []
}), a = I(U(l.value));
K(() => {
t.value.componentInstance = s;
}), D(() => i.schema.toolbar, () => {
l.value = i.schema.toolbar || {
type: "response-toolbar",
buttons: []
}, a.value = U(l.value);
}, {
deep: !0
});
const d = b(() => [...a.value.items]);
function c(f, P, H, E) {
i && i.setupContext && i.setupContext.emit("selectionChange", f, P, H, E);
}
e.expose(s.value);
function p(f, P) {
f && P && P.split(" ").reduce((E, G) => (E[G] = !0, E), f);
}
const m = b(() => {
const f = {
"f-title-icon": !0
};
return p(f, r.iconClass), f;
}), x = b(() => {
const f = {
"f-icon": !0
};
return p(f, r.icon), f;
}), C = b(() => {
const f = {
"text-right": !0,
"col-6": !0
};
return p(f, r.buttonClass || ""), f;
}), w = b(() => y({
"f-title": !0
}, r.titleContentClass)), v = b(() => y({
"f-content": !0
}, r.contentClass)), T = b(() => y({
"f-page-header-extend": !0
}, r.downContentClass));
function h() {
return r.titleContentHtml ? u("div", {
class: w.value,
innerHTML: r.titleContentHtml
}, null) : u("div", {
class: "f-title"
}, [r.showIcon && r.icon ? u("span", {
class: m.value
}, [u("i", {
class: x.value
}, null)]) : "", u("h4", {
class: "f-title-text"
}, [r.title])]);
}
function F() {
return r.contentHtml ? u("div", {
class: v.value,
innerHTML: r.contentHtml
}, null) : null;
}
function L() {
return r.downContentHtml ? u("div", {
class: T.value,
innerHTML: r.downContentHtml
}, null) : null;
}
return () => u("div", {
ref: t
}, [u("nav", {
class: "f-page-header-base"
}, [h(), F(), u(ne, {
class: C.value,
modelValue: l.value,
"onUpdate:modelValue": (f) => l.value = f,
canAdd: !1,
childType: "response-toolbar-item",
childLabel: "按钮",
contentKey: "buttons",
id: l.value.id,
componentId: r.componentId,
onSelectionChange: c
}, {
default: () => [u(Y, {
id: l.value.id,
customClass: "w-100",
items: d.value,
componentId: r.componentId
}, null)]
})]), L()]);
}
}), Te = {
install(r) {
r.component(O.name, O);
},
register(r, e, t, n, i) {
r["page-header"] = O, e["page-header"] = pe(i), n["page-header"] = { eventHandlerResolver: ue };
},
registerDesigner(r, e, t, n) {
r["page-header"] = ve, e["page-header"] = ge(n);
}
};
export {
O as PageHeader,
Te as default,
ue as eventHandlerResolver,
B as pageHeaderDesignerProps,
R as pageHeaderProps,
Re as propsDesignResolver,
ge as propsDesignResolverGenerator,
Me as propsResolver,
pe as propsResolverGenerator
};