UNPKG

@aplus-frontend/ui

Version:

130 lines (129 loc) 3.74 kB
import { isVNode as C, createVNode as i, mergeProps as R, createTextVNode as h, Fragment as I } from "vue"; import { isFunction as c, isArray as T, isBoolean as S, omit as F, isString as x } from "lodash-unified"; import { apTableFormItemMap as q, noRenderAsFormItemValueList as w, apTableRenderItemMap as P } from "../ap-table/constants.mjs"; import { isDef as V } from "../utils/index.mjs"; import { getValueStr as N } from "../ap-field/number/helper.mjs"; import j from "scroll-into-view-if-needed"; import { Typography as v, Tooltip as A } from "@aplus-frontend/antdv"; import "../ap-form/index.mjs"; import { objectToString as M, getTableRenderType as O } from "../ap-table/utils.mjs"; import { QuestionCircleOutlined as W } from "@ant-design/icons-vue"; import y from "../ap-form/item/index.vue.mjs"; function m(e) { return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !C(e); } function _(e) { return q[e]; } function k(e) { if (e.markRequired) return !0; if (!e.fieldProps) return !1; const t = c(e.fieldProps) ? e.fieldProps({}) : e.fieldProps; return V(t.required) ? t.required : (T(t.rules) ? t.rules : t.rules ? [t.rules] : []).some((o) => o.required); } function D(e, t) { if (e.valueType === "text" || e.valueType === "textArea") return t || "--"; if (e.valueType === "number") { const r = e.fieldProps ? c(e.fieldProps) ? e.fieldProps({}) : e.fieldProps : {}; return N(t, r) || "--"; } return M(t); } function $(e, t) { const r = [e]; if (t) { const o = T(t) ? t : [t]; r.unshift(...o); } return r.join(" "); } function ee(e, t = document.body, r = {}) { const o = t.querySelectorAll("tr.ant-table-row")[e]; o && j(o, { scrollMode: "if-needed", block: "nearest", behavior: "smooth", ...r }); } function E(e, t, r) { return w.includes(e.valueType) ? r : e.copyable || e.ellipsis ? i(v.Paragraph, { copyable: e.copyable ? { text: t, tooltip: !1 } : !1, ellipsis: e.ellipsis ? S(e.ellipsis) ? { tooltip: t } : { ...e.ellipsis, tooltip: t } : !1, content: e.ellipsis ? D(e, t) : r }, null) : r; } function te(e, t, r, o, p, n) { if (t) { if (e.customRenderFormItem) { const f = e.customRenderFormItem(e, r.field, t, p); return i(y, F(r, ["field"]), m(f) ? f : { default: () => [f] }); } const a = _(e.valueType); if (a) return i(a, r, null); const l = n?.[e.valueType]?.renderFormItem?.(r.field); return l ? i(y, r, m(l) ? l : { default: () => [l] }) : null; } let s; const u = O(e), d = P[u]; return d ? s = i(d, R(r.field, { mode: "read" }), null) : s = n?.[u]?.render?.(o, p, r.field), s ? E(e, o, s) : null; } function re(e, t, r, o, p) { const n = o?.({ title: e.title, column: e }), s = n?.filter((b) => b.type !== Symbol.for("v-cmt")) || []; if (n && s.length > 0) return n; const d = k(e), g = x(e.title) ? { class: t, title: e.title } : {}, l = i("div", g, [d ? i("span", { class: r }, [h("*")]) : null, e.title]), f = e.tooltip ? c(e.tooltip) ? e.tooltip(e) : i(I, null, [e.tooltip]) : null; return f ? i("span", { style: { display: "inline-flex", alignItems: "center", maxWidth: "100%" } }, [l, i(A, { title: f, placement: "bottom" }, { default: () => [i(W, { style: { padding: "4px", color: p, verticalAlign: "middle" } }, null)] })]) : l; } export { k as getColumnIsRequired, _ as getEditableComponent, re as getEditableTableTitle, te as getFinalNode, D as getRawDisplayValue, $ as mergeClass, ee as scrollToRowIndex };