@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,078 lines (1,077 loc) • 36.7 kB
JavaScript
import { ref as S, computed as G, defineComponent as I, watch as Q, createVNode as L, withModifiers as V, createTextVNode as _, inject as ve, onMounted as Z } from "vue";
import { cloneDeep as x, isPlainObject as K } from "lodash-es";
import { getSchemaByTypeForDesigner as de } from "../dynamic-resolver/index.esm.js";
import { withInstall as ge } from "../common/index.esm.js";
function ee(e, t) {
let r;
function i(a) {
const { properties: s, title: y, ignore: o } = a, n = o && Array.isArray(o), l = Object.keys(s).reduce((p, v) => ((!n || !o.find((d) => d === v)) && (p[v] = s[v].type === "object" && s[v].properties ? i(s[v]) : x(s[v].default)), p), {});
if (y && (!n || !o.find((p) => p === "id"))) {
const p = y.toLowerCase().replace(/-/g, "_");
l.id = `${p}_${Math.random().toString().slice(2, 6)}`;
}
return l;
}
function w(a) {
const { properties: s, title: y, required: o } = a;
if (o && Array.isArray(o)) {
const n = o.reduce((l, p) => (l[p] = s[p].type === "object" && s[p].properties ? i(s[p]) : x(s[p].default), l), {});
if (y && o.find((l) => l === "id")) {
const l = y.toLowerCase().replace(/-/g, "_");
n.id = `${l}_${Math.random().toString().slice(2, 6)}`;
}
return n;
}
return {
type: y
};
}
function $(a, s = {}, y) {
const o = e[a];
if (o) {
let n = w(o);
const l = t[a];
return n = l ? l({ getSchemaByType: $ }, n, s, y) : n, r != null && r.appendIdentifyForNewControl && r.appendIdentifyForNewControl(n), n;
}
return null;
}
function N(a, s) {
const y = i(s);
return Object.keys(y).reduce((o, n) => (Object.prototype.hasOwnProperty.call(a, n) && (o[n] && K(o[n]) && K(a[n] || !a[n]) ? Object.assign(o[n], a[n] || {}) : o[n] = a[n]), o), y), y;
}
function A(a, s) {
return Object.keys(a).filter((o) => a[o] != null).reduce((o, n) => {
if (s.has(n)) {
const l = s.get(n);
if (typeof l == "string")
o[l] = a[n];
else {
const p = l(n, a[n], a);
Object.assign(o, p);
}
} else
o[n] = a[n];
return o;
}, {});
}
function z(a, s, y = /* @__PURE__ */ new Map()) {
const o = N(a, s);
return A(o, y);
}
function m(a) {
var y;
const s = a.type;
if (s) {
const o = e[s];
if (!o)
return a;
const n = N(a, o), l = ((y = a.editor) == null ? void 0 : y.type) || "";
if (l) {
const p = e[l], v = N(a.editor, p);
n.editor = v;
}
return n;
}
return a;
}
function b(a) {
r = a;
}
return { getSchemaByType: $, resolveSchemaWithDefaultValue: m, resolveSchemaToProps: z, mappingSchemaToProps: A, setDesignerContext: b };
}
const te = {}, re = {}, { getSchemaByType: vt, resolveSchemaWithDefaultValue: be, resolveSchemaToProps: ye, mappingSchemaToProps: Se, setDesignerContext: dt } = ee(te, re);
function he(e = {}) {
function t(m, b, a, s) {
if (typeof a == "number")
return s[m].length === a;
if (typeof a == "object") {
const y = Object.keys(a)[0], o = a[y];
if (y === "not")
return Number(s[m].length) !== Number(o);
if (y === "moreThan")
return Number(s[m].length) >= Number(o);
if (y === "lessThan")
return Number(s[m].length) <= Number(o);
}
return !1;
}
function r(m, b, a, s) {
return s[m] && s[m].propertyValue && String(s[m].propertyValue.value) === String(a);
}
const i = /* @__PURE__ */ new Map([
["length", t],
["getProperty", r]
]);
Object.keys(e).reduce((m, b) => (m.set(b, e[b]), m), i);
function w(m, b) {
const a = m;
return typeof b == "number" ? [{ target: a, operator: "length", param: null, value: Number(b) }] : typeof b == "boolean" ? [{ target: a, operator: "getProperty", param: m, value: !!b }] : typeof b == "object" ? Object.keys(b).map((s) => {
if (s === "length")
return { target: a, operator: "length", param: null, value: b[s] };
const y = s, o = b[s];
return { target: a, operator: "getProperty", param: y, value: o };
}) : [];
}
function $(m) {
return Object.keys(m).reduce((a, s) => {
const y = w(s, m[s]);
return a.push(...y), a;
}, []);
}
function N(m, b) {
if (i.has(m.operator)) {
const a = i.get(m.operator);
return a && a(m.target, m.param, m.value, b) || !1;
}
return !1;
}
function A(m, b) {
return $(m).reduce((y, o) => y && N(o, b), !0);
}
function z(m, b) {
const a = Object.keys(m), s = a.includes("allOf"), y = a.includes("anyOf"), o = s || y, p = (o ? m[o ? s ? "allOf" : "anyOf" : "allOf"] : [m]).map((d) => A(d, b));
return s ? !p.includes(!1) : p.includes(!0);
}
return { parseValueSchema: z };
}
const Te = {
convertTo: (e, t, r, i) => {
e.appearance || (e.appearance = {}), e.appearance[t] = r;
},
convertFrom: (e, t, r) => e.appearance ? e.appearance[t] : e[t]
}, Fe = {
convertFrom: (e, t, r) => e.buttons && e.buttons.length ? `共 ${e.buttons.length} 项` : "无"
}, Me = {
convertTo: (e, t, r, i) => {
e.editor && (e.editor[t] = r);
},
convertFrom: (e, t, r) => e.editor && Object.prototype.hasOwnProperty.call(e.editor, t) ? e.editor[t] : e[t]
}, ne = {
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, r) => {
var w;
const i = e.editor && e.editor[t] ? e.editor[t] : e[t];
return ((w = ne[i]) == null ? void 0 : w.name) || i;
}
}, De = {
convertTo: (e, t, r, i) => {
e[t] = e[t];
},
convertFrom: (e, t, r) => e.editor ? r.getRealEditorType(e.editor.type) : ""
}, Pe = {
convertTo: (e, t, r, i) => {
(e.type === "data-grid-column" || e.type === "tree-grid-column") && (e.formatter ? e.formatter[t] = r : e.formatter = {
[t]: r
});
},
convertFrom: (e, t, r) => {
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";
}
}, ke = {
convertTo: (e, t, r, i) => {
e.command ? e.command[t] = r : e.command = {
[t]: r
}, t === "enable" && r && (e.command.commands || (e.command.commands = [
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
]));
},
convertFrom: (e, t, r) => e.command && t === "enable" ? e.command.enable : ""
}, we = {
convertTo: (e, t, r, i) => {
e.column ? e.column[t] = r : e.column = {
[t]: r
}, t === "fitColumns" && r && (e.column.fitMode || (e.column.fitMode = "average"));
},
convertFrom: (e, t, r) => {
if (e.column) {
if (t === "fitColumns")
return e.column.fitColumns;
if (t === "fitMode")
return e.column.fitMode;
}
return "";
}
}, Ne = {
convertTo: (e, t, r, i) => {
e.summary ? e.summary[t] = r : e.summary = {
[t]: r
}, t === "enable" && r && (e.summary ? e.summary.groupFields || (e.summary.groupFields = []) : e.summary = {
enable: r,
groupFields: []
});
},
convertFrom: (e, t, r) => e.summary && t === "enable" ? e.summary.enable : e.type === "data-grid-column" ? e.enableSummary === void 0 ? !1 : e.enableSummary : ""
}, Ee = {
convertTo: (e, t, r, i) => {
e.group ? e.group[t] = r : e.group = {
[t]: r
}, t === "enable" && r && (e.group ? e.group.groupFields || (e.group.groupFields = []) : e.group = {
enable: r,
groupFields: [],
showSummary: !1
});
},
convertFrom: (e, t, r) => {
if (e.group) {
if (t === "enable")
return e.group.enable;
if (t === "showSummary")
return e.group.showSummary;
}
}
}, je = {
convertFrom: (e, t) => e.binding ? e.binding.path : "",
convertTo: (e, t, r) => {
if (r && r.length > 0) {
const i = r[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;
}
}
}, Be = {
convertTo: (e, t, r, i) => {
e.pagination || (e.pagination = {}), e.pagination[t] = r;
},
convertFrom: (e, t, r) => e.pagination ? e.pagination[t] : e[t]
}, $e = {
convertTo: (e, t, r, i) => {
e.rowNumber || (e.rowNumber = {}), e.rowNumber[t] = r;
},
convertFrom: (e, t, r) => e.rowNumber ? e.rowNumber[t] : e[t]
}, Ce = {
convertTo: (e, t, r, i) => {
e.selection || (e.selection = {}), e.selection[t] = r;
},
convertFrom: (e, t, r) => e.selection ? e.selection[t] : e[t]
}, Re = {
convertFrom: (e, t, r) => e[t] && e[t].length ? `共 ${e[t].length} 项` : ""
}, Ae = {
convertFrom: (e, t) => e[t] || "",
convertTo: (e, t, r) => {
e[t] = r;
}
}, Le = {
convertTo: (e, t, r, i) => {
e.size || (e.size = {}), e.size[t] = r;
},
convertFrom: (e, t, r) => e.size ? e.size[t] : e[t]
}, He = {
convertFrom: (e, t, r) => {
var i, w;
return (i = e.formatter) != null && i.data && t === "formatterEnumData" && !e.formatterEnumData ? (w = e.formatter) == null ? void 0 : w.data : e.formatterEnumData;
}
}, ze = {
convertTo: (e, t, r, i) => {
e.sort || (e.sort = {}), e.sort[t] = r;
},
convertFrom: (e, t, r) => {
var i, w;
if (t === "mode")
return ((i = e.sort) == null ? void 0 : i.mode) || "client";
if (t === "multiSort")
return !!((w = e.sort) != null && w.multiSort);
}
}, We = {
convertTo: (e, t, r, i) => {
e.filter || (e.filter = {}), e.filter[t] = r;
},
convertFrom: (e, t, r) => {
var i;
if (t === "mode")
return ((i = e.filter) == null ? void 0 : i.mode) || "client";
}
}, qe = {
convertTo: (e, t, r, i) => {
e.rowOption ? e.rowOption[t] = r : e.rowOption = {
[t]: r
};
},
convertFrom: (e, t, r) => {
if (e.rowOption) {
if (t === "customRowStyle")
return e.rowOption.customRowStyle;
if (t === "customCellStyle")
return e.rowOption.customCellStyle;
}
return "";
}
};
function oe(e, t, r) {
const i = /* @__PURE__ */ new Map([
["/converter/appearance.converter", Te],
["/converter/buttons.converter", Fe],
["/converter/property-editor.converter", Me],
["/converter/items-count.converter", Re],
["/converter/type.converter", Oe],
["/converter/change-editor.converter", De],
["/converter/change-formatter.converter", Pe],
["/converter/column-command.converter", ke],
["/converter/column-option.converter", we],
["/converter/summary.converter", Ne],
["/converter/group.converter", Ee],
["/converter/form-group-label.converter", Ae],
["/converter/field-selector.converter", je],
["/converter/pagination.converter", Be],
["/converter/row-number.converter", $e],
["/converter/grid-selection.converter", Ce],
["/converter/size.converter", Le],
["/converter/change-formatter-enum.converter", He],
["/converter/grid-sort.converter", ze],
["/converter/grid-filter.converter", We],
["/converter/row-option.converter", qe]
]), w = /* @__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 }]
]), $ = he();
function N(o, n) {
return () => $.parseValueSchema(o, n);
}
function A(o, n, l) {
return o.includes("visible") && n.visible !== void 0 ? typeof n.visible == "boolean" ? () => !!n.visible : n.visible === void 0 ? !0 : N(n.visible, l) : () => !0;
}
function z(o, n, l) {
return o.includes("readonly") && n.readonly !== void 0 ? typeof n.readonly == "boolean" ? () => !!n.readonly : N(n.readonly, l) : () => !1;
}
function m(o, n) {
const l = o.$converter || n;
return typeof l == "string" && l && i.has(l) ? i.get(l) || null : l || null;
}
function b(o, n, l, p, v, d = "", D = "") {
return Object.keys(o).map((F) => {
const E = S(1), j = F, u = o[F], B = Object.keys(u), W = u.title, f = u.type, T = w.get(f) || { type: "input-group", enableClear: !1 }, h = u.editor ? Object.assign({}, T, u.editor) : Object.assign({}, T), M = A(B, u, n), k = z(B, u, n);
h.readonly = h.readonly === void 0 ? k() : h.readonly;
const C = u.type === "cascade" ? b(u.properties, n, l, p, v, d, D) : [], H = !0;
let c = m(u, D);
const O = G({
get() {
if (E.value) {
if (["class", "style"].find((me) => me === j) && !c && (c = i.get("/converter/appearance.converter") || null), c && c.convertFrom)
return c.convertFrom(l, F, v, d);
const q = l[F];
return Object.prototype.hasOwnProperty.call(u, "defaultValue") && (q === void 0 || typeof q == "string" && q === "") ? u.type === "boolean" ? u.defaultValue : u.defaultValue || "" : q;
}
return null;
},
set(q) {
E.value += 1, c && c.convertTo ? (c.convertTo(p, F, q, v, d), c.convertTo(l, F, q, v, d)) : (p[F] = q, l[F] = q);
}
}), { refreshPanelAfterChanged: g, description: R, isExpand: X, parentPropertyID: pe } = u, J = { propertyID: j, propertyName: W, propertyType: f, propertyValue: O, editor: h, visible: M, readonly: k, cascadeConfig: C, hideCascadeTitle: H, refreshPanelAfterChanged: g, description: R, isExpand: X, parentPropertyID: pe };
return n[j] = J, J;
});
}
function a(o, n, l = {}) {
const p = {}, v = e[o];
return v && v.categories ? Object.keys(v.categories).map((D) => {
const P = v.categories[D], F = P == null ? void 0 : P.title, E = b(P.properties || {}, p, {}, l, n);
return { categoryId: D, categoryName: F, properties: E };
}) : [];
}
function s(o, n, l, p, v = "") {
const d = n.$ref.schema, D = n.$ref.converter, P = l[d], F = P.type, E = r(P), j = {}, u = e[F];
if (u && u.categories) {
const B = u.categories[o], W = B == null ? void 0 : B.title;
D && Object.keys(B.properties).forEach((h) => {
B.properties[h].$converter = D;
});
const f = (B == null ? void 0 : B.properties) || {}, T = b(f, j, E, P, p, v);
return { categoryId: o, categoryName: W, properties: T };
}
return { categoryId: o, categoryName: "", properties: [] };
}
function y(o, n, l, p, v) {
const d = o.type, D = r(o), P = {};
let F = v || e[d];
if (F && Object.keys(F).length === 0 && l && l.getPropConfig && (F = l.getPropConfig(p)), F && F.categories) {
const E = [];
return Object.keys(F.categories).map((j) => {
const u = F.categories[j];
if (u.$ref) {
E.push(s(j, u, o, n, p));
return;
}
const B = u == null ? void 0 : u.title, W = u == null ? void 0 : u.tabId, f = u == null ? void 0 : u.tabName, T = u == null ? void 0 : u.hide, h = u == null ? void 0 : u.hideTitle, M = b(u.properties || {}, P, D, o, n, p, u.$converter), { setPropertyRelates: k } = u, C = u == null ? void 0 : u.parentPropertyID;
E.push({ categoryId: j, categoryName: B, tabId: W, tabName: f, hide: T, properties: M, hideTitle: h, setPropertyRelates: k, parentPropertyID: C });
}), E;
}
return [];
}
return {
getPropertyConfigBySchema: y,
getPropertyConfigByType: a,
propertyConverterMap: i
};
}
const ae = {}, le = {};
oe(ae, le, be);
const ie = {}, se = {}, { getSchemaByType: gt, resolveSchemaWithDefaultValue: Ve, resolveSchemaToProps: bt, mappingSchemaToProps: yt, setDesignerContext: St } = ee(ie, se), ce = {}, ue = {};
oe(ce, ue, Ve);
function _e(e, t, r = /* @__PURE__ */ new Map(), i = (N, A, z, m) => A, w = {}, $ = (N) => N) {
return te[t.title] = t, re[t.title] = i, ae[t.title] = w, le[t.title] = $, ie[t.title] = t, se[t.title] = i, ce[t.title] = w, ue[t.title] = $, (N = {}, A = !0) => {
if (!A)
return Se(N, r);
const z = ye(N, t, r), m = Object.keys(e).reduce((b, a) => (b[a] = e[a].default, b), {});
return Object.assign(m, z);
};
}
function Xe(e, t) {
return { customClass: t.class, customStyle: t.style };
}
const Ge = /* @__PURE__ */ new Map([
["appearance", Xe]
]);
function Ue(e, t, r) {
return t;
}
const Ye = "https://json-schema.org/draft/2020-12/schema", Je = "https://farris-design.gitee.io/rate.schema.json", Qe = "rate", Ze = "A Farris Component", xe = "object", Ke = {
id: {
description: "The unique identifier for rate",
type: "string"
},
type: {
description: "The type string of rate",
type: "string",
default: "rate"
},
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
}
}, Ie = [
"id",
"type"
], et = [
"id",
"appearance",
"binding"
], tt = {
$schema: Ye,
$id: Je,
title: Qe,
description: Ze,
type: xe,
properties: Ke,
required: Ie,
ignore: et
}, rt = "rate", nt = "A Farris Component", ot = "object", at = {
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: rt,
description: nt,
type: ot,
categories: at
}, it = ["很不满意", "不满意", "一般", "满意", "非常满意"], Y = {
/** 星星大小 */
size: { type: String, default: "large" },
/** 启用半颗星模式 */
enableHalf: { type: Boolean, default: !1 },
/** 启用再次点击后清除 */
enableClear: { type: Boolean, default: !1 },
/** 只读 */
disabled: { type: Boolean, default: !1 },
/** 分制 */
pointSystem: { type: Number, default: 5 },
/** 星星亮色 */
lightColor: { type: String, default: "" },
/** 星星暗色(底色) */
darkColor: { type: String, default: "" },
/** 图案样式 */
iconClass: { type: String, default: "f-icon-star" },
/** 星星个数 */
numOfStar: { type: Number, default: 5 },
/** 禁用单个星星的文字提示 */
toolTipDisabled: { type: Boolean, default: !0 },
/** 默认的满意度文案 */
toolTipContents: { type: Array, default: it },
/** 启用评分 */
enableScore: { type: Boolean, default: !0 },
/** 启用满意度 */
enableSatisfaction: { type: Boolean, default: !1 },
/**
* 绑定值
*/
modelValue: { type: Number, default: 0 }
}, fe = _e(Y, tt, Ge, Ue, lt), U = /* @__PURE__ */ I({
name: "FRate",
props: Y,
emits: ["selectedValue", "update:modelValue"],
setup(e, t) {
const r = S(e.size), i = S(e.enableHalf), w = S(e.enableClear), $ = S(e.disabled), N = S(e.pointSystem), A = S(e.lightColor), z = S(e.darkColor), m = S(e.iconClass), b = S(e.numOfStar), a = S(e.toolTipDisabled), s = S(e.toolTipContents), y = S(e.enableScore), o = S(e.enableSatisfaction);
let n;
const l = S(0), p = S(0), v = S(0), d = S(e.modelValue);
let D = 1, P, F, E;
const j = 4;
function u() {
const c = b.value;
E = [];
for (let O = 1; O <= c; O++)
E.push({
id: O
});
}
function B() {
let c;
i.value ? c = Math.ceil(d.value / D) : c = d.value, p.value = (n * d.value + Math.floor(d.value) * j) / D, P = s.value[c - 1];
}
function W() {
switch (r.value) {
case "small":
n = 14;
break;
case "middle":
n = 16;
break;
case "large":
n = 18;
break;
case "extraLarge":
n = 24;
break;
}
u(), b.value && (D = N.value / b.value), d.value && B();
}
W();
function f(c) {
return c.className.indexOf("f-icon") !== -1;
}
function T() {
return d.value === v.value && w.value && p.value !== 0 ? (p.value = 0, d.value = 0, F = null, l.value = 0, v.value = 0, t.emit("selectedValue", d.value), t.emit("update:modelValue", d.value), !0) : !1;
}
function h(c, O, g) {
if (!$.value && ((c.movementX || c.movementY) && (o.value && (P = s.value[O - 1]), c.offsetX < n / 2 && i.value === !0 ? (l.value = n * O - n / 2 + j * (O - 1), v.value = D * O - D / 2) : (l.value = n * O + j * (O - 1), v.value = D * O)), g === !0)) {
if (T())
return;
d.value = v.value, p.value = l.value, F = P, t.emit("update:modelValue", d.value), t.emit("selectedValue", d.value);
}
}
function M(c, O) {
var g;
if (f(c.target) && c.target) {
const R = parseInt((g = c.target) == null ? void 0 : g.id);
h(c, R, O);
}
}
const k = G(() => v.value ? v.value + "分" : d.value + "分"), C = G(() => ({
width: (l.value || p.value) + "px"
}));
function H() {
l.value = 0, v.value = d.value;
}
return Q(() => e.modelValue, (c) => {
v.value = c, d.value = c, B();
}), Q(() => [e.disabled, e.enableClear], ([c, O]) => {
$.value = c, w.value = O;
}), () => L("div", {
class: "farris-star-rating",
onMouseover: V((c) => M(c, !1), ["prevent"]),
onMousemove: V((c) => M(c, !1), ["prevent"]),
onMouseleave: V((c) => H(), ["prevent"]),
onClick: V((c) => M(c, !0), ["prevent"])
}, [L("div", {
class: "star-light-area",
style: C.value
}, [E.map((c) => L("span", {
class: ["f-icon default-light-color ", m.value, {
"f-star-sm": r.value === "small"
}, {
"f-star-md": r.value === "middle"
}, {
"f-star-lg": r.value === "large"
}, {
"f-star-exlarge": r.value === "extraLarge"
}, {
disabled: a.value
}],
id: c.id,
style: {
color: A.value
}
}, null))]), L("div", {
class: ["star-dark-area", {
small: r.value === "small"
}, {
middle: r.value === "middle"
}, {
large: r.value === "large"
}]
}, [E.map((c) => L("span", {
class: ["f-icon default-dark-color", m.value, {
"f-star-sm": r.value === "small"
}, {
"f-star-md": r.value === "middle"
}, {
"f-star-lg": r.value === "large"
}, {
"f-star-exlarge": r.value === "extraLarge"
}],
id: c.id,
style: {
color: z.value
}
}, null))]), L("div", {
class: ["f-utils-fill", {
"font-small": r.value === "small"
}, {
"font-middle": r.value === "middle"
}, {
"font-large": r.value === "large"
}, {
"font-exlarge": r.value === "extraLarge"
}]
}, [y.value && L("span", null, [_(" "), k.value, _(" ")]), o.value && (F || P) && L("span", null, [_(" "), P || F])])]);
}
});
function st(e, t, r) {
var W;
const i = "", w = "", $ = S();
let N;
function A() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function z() {
return !1;
}
function m() {
return (t == null ? void 0 : t.schema.componentType) !== "frame";
}
function b() {
return (t == null ? void 0 : t.schema.componentType) === "frame";
}
function a(f) {
if (!f || !f.value)
return null;
if (f.value.schema && f.value.schema.type === "component")
return f.value;
const T = S(f == null ? void 0 : f.value.parent), h = a(T);
return h || null;
}
function s(f = t) {
var k;
const { componentInstance: T, designerItemElementRef: h } = f;
if (!T || !T.value)
return null;
const { getCustomButtons: M } = T.value;
return T.value.canMove || M && ((k = M()) != null && k.length) ? h : s(f.parent);
}
function y(f) {
return !!r;
}
function o() {
return (t == null ? void 0 : t.schema.label) || (t == null ? void 0 : t.schema.title) || (t == null ? void 0 : t.schema.name);
}
function n() {
}
function l(f, T) {
var h;
!f || !T || (h = t == null ? void 0 : t.setupContext) == null || h.emit("dragEnd");
}
function p(f, T) {
const { componentType: h } = f;
let M = de(h, f, T);
const k = h.toLowerCase().replace(/-/g, "_");
return M && !M.id && M.type === h && (M.id = `${k}_${Math.random().toString().slice(2, 6)}`), M;
}
function v(f) {
}
function d(...f) {
}
function D(f) {
if (!f)
return;
const T = t == null ? void 0 : t.schema, { formSchemaUtils: h } = f;
if (T && h.getExpressions().length) {
const M = h.getExpressions().findIndex((k) => k.target === T.id);
M > -1 && h.getExpressions().splice(M, 1);
}
}
function P(f) {
if (!f || !(t != null && t.schema))
return;
const T = t.schema, { formSchemaUtils: h } = f;
h.removeCommunicationInComponent(T);
}
function F(f) {
D(f), P(f), t != null && t.schema.contents && t.schema.contents.map((T) => {
let h = T.id;
T.type === "component-ref" && (h = T.component);
const M = e.value.querySelectorAll(`#${h}-design-item`);
M != null && M.length && Array.from(M).map((k) => {
var C;
(C = k == null ? void 0 : k.componentInstance) != null && C.value.onRemoveComponent && k.componentInstance.value.onRemoveComponent(f);
});
});
}
function E() {
}
function j(f) {
var h, M;
if (!((h = t == null ? void 0 : t.schema) != null && h.id))
return;
!N && f && (N = f.formSchemaUtils);
let T = "";
{
const { text: k, title: C, label: H, mainTitle: c, name: O, type: g } = t.schema;
T = k || C || H || c || O || ((M = ne[g]) == null ? void 0 : M.name);
}
T && N.getControlBasicInfoMap().set(t.schema.id, {
componentTitle: T,
parentPathName: T
});
}
function u(f) {
var k;
const { changeObject: T } = f, { propertyID: h, propertyValue: M } = T;
if (["text", "title", "label", "name", "mainTitle"].includes((k = f == null ? void 0 : f.changeObject) == null ? void 0 : k.propertyID) && h && M && (j(), N)) {
const C = N.getControlBasicInfoMap(), H = C.keys().toArray().filter((c) => {
var O, g;
return ((O = C.get(c)) == null ? void 0 : O.reliedComponentId) === ((g = t == null ? void 0 : t.schema) == null ? void 0 : g.id);
});
H != null && H.length && H.forEach((c) => {
const O = C.get(c).parentPathName.split(" > ");
O[0] = M, C.get(c).parentPathName = O.join(" > ");
});
}
}
function B(f) {
u(f);
}
return $.value = {
canMove: A(),
canSelectParent: z(),
canDelete: m(),
canNested: !b(),
contents: t == null ? void 0 : t.schema.contents,
elementRef: e,
parent: (W = t == null ? void 0 : t.parent) == null ? void 0 : W.componentInstance,
schema: t == null ? void 0 : t.schema,
styles: i,
designerClass: w,
canAccepts: y,
getBelongedComponentInstance: a,
getDraggableDesignItemElement: s,
getDraggingDisplayText: o,
getPropConfig: d,
getDragScopeElement: n,
onAcceptMovedChildElement: l,
onChildElementMovedOut: v,
addNewChildComponentSchema: p,
triggerBelongedComponentToMoveWhenMoved: S(!1),
triggerBelongedComponentToDeleteWhenDeleted: S(!1),
onRemoveComponent: F,
getCustomButtons: E,
onPropertyChanged: B,
setComponentBasicInfoMap: j,
updateContextSchema: t == null ? void 0 : t.updateContextSchema
}, $;
}
const ct = /* @__PURE__ */ I({
name: "FRateDesign",
props: Y,
emits: ["selectedValue"],
setup(e, t) {
const r = S(e.size), i = S(e.enableHalf), w = S(e.enableClear), $ = S(e.disabled), N = S(e.pointSystem), A = S(e.lightColor), z = S(e.darkColor), m = S(e.iconClass), b = S(e.numOfStar), a = S(e.toolTipDisabled), s = S(e.toolTipContents), y = S(e.enableScore), o = S(e.enableSatisfaction);
let n;
const l = S(1);
let p = 0;
const v = S(0), d = S(0);
let D = 1, P, F, E;
const j = 4, u = S(), B = ve("design-item-context"), W = st(u, B);
Z(() => {
u.value.componentInstance = W;
}), t.expose(W.value), Z(() => {
});
function f() {
const g = b.value;
E = [];
for (let R = 1; R <= g; R++)
E.push({
id: R
});
}
function T() {
let g;
i.value ? g = Math.ceil(d.value / D) : g = d.value, p = (n * d.value + Math.floor(d.value) * j) / D, P = s.value[g - 1];
}
function h() {
switch (r.value) {
case "small":
n = 14;
break;
case "middle":
n = 16;
break;
case "large":
n = 18;
break;
case "extraLarge":
n = 24;
break;
}
f(), b.value && (D = N.value / b.value), d.value && T();
}
h();
function M(g) {
return g.className.indexOf("f-icon") !== -1;
}
function k() {
return l.value === p && w && p !== 0 ? (p = 0, d.value = 0, F = null, l.value = 0, v.value = 0, t.emit("selectedValue", d.value), !0) : !1;
}
function C(g, R, X) {
if (g.movementX || g.movementY) {
if ($.value)
return;
o.value && (P = s.value[R - 1]), g.offsetX < n / 2 && i.value === !0 ? (l.value = n * R - n / 2 + j * (R - 1), v.value = D * R - D / 2) : (l.value = n * R + j * (R - 1), v.value = D * R);
}
if (X === !0) {
if (k())
return;
d.value = v.value, p = l.value, F = P, t.emit("selectedValue", d.value);
}
}
function H(g, R) {
if (M(g.target) && g.target) {
const X = parseInt(g.target.id);
C(g, X, R);
}
}
const c = G(() => v.value ? v.value + "分" : d.value + "分"), O = G(() => ({
width: (l.value || p) + "px"
}));
return () => L("div", {
class: "farris-star-rating",
ref: u,
onMouseover: V((g) => H(g, !1), ["prevent"]),
onMousemove: V((g) => H(g, !1), ["prevent"]),
onMouseout: V((g) => H(g, !1), ["prevent"]),
onClick: V((g) => H(g, !0), ["prevent"])
}, [L("div", {
class: "star-light-area",
style: O.value
}, [E.map((g) => L("span", {
class: ["f-icon default-light-color ", m.value, {
"f-star-sm": r.value === "small"
}, {
"f-star-md": r.value === "middle"
}, {
"f-star-lg": r.value === "large"
}, {
"f-star-exlarge": r.value === "extraLarge"
}, {
disabled: a.value
}],
id: g.id,
style: {
color: A.value
}
}, null))]), L("div", {
class: ["star-dark-area", {
small: r.value === "small"
}, {
middle: r.value === "middle"
}, {
large: r.value === "large"
}]
}, [E.map((g) => L("span", {
class: ["f-icon default-dark-color", m.value, {
"f-star-sm": r.value === "small"
}, {
"f-star-md": r.value === "middle"
}, {
"f-star-lg": r.value === "large"
}, {
"f-star-exlarge": r.value === "extraLarge"
}],
id: g.id,
style: {
color: z.value
}
}, null))]), L("div", {
class: ["f-utils-fill", {
"font-small": r.value === "small"
}, {
"font-middle": r.value === "middle"
}, {
"font-large": r.value === "large"
}, {
"font-exlarge": r.value === "extraLarge"
}]
}, [y.value && L("span", null, [_(" "), c.value, _(" ")]), o.value && (F || P) && L("span", null, [_(" "), P || F])])]);
}
});
U.register = (e, t, r, i) => {
e.rate = U, t.rate = fe;
};
U.registerDesigner = (e, t, r) => {
e.rate = ct, t.rate = fe;
};
const ht = ge(U);
export {
U as FRate,
ht as default,
fe as propsResolver,
Y as rateProps
};