UNPKG

e-virt-table

Version:

A powerful data table based on canvas. You can use it as data grid、Microsoft Excel or Google sheets. It supports virtual scroll、cell edit etc.

1,255 lines 250 kB
(function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.appendChild(document.createTextNode(":root{--evt-header-font: 12px normal Arial;--evt-body-font: 12px normal Arial;--evt-color-white: #fff;--evt-color-black: #000000;--evt-color-primary: rgb(82, 146, 247);--evt-text-color-primary: #333;--evt-text-color-regular: #666;--evt-text-color-secondary: #999;--evt-box-shadow: 0 2px 12px 0 #0000001a;--evt-editor-bg-color: #fff;--evt-editor-text-color: #333;--evt-border-color: #e1e6eb;--evt-stripe-color: #fafafa;--evt-placeholder-color: #cdd0dc;--evt-header-bg-color: #f8faff;--evt-body-bg-color: #fff;--evt-header-text-color: #1d2129;--evt-body-text-color: #4e5969;--evt-footer-text-color: #4e5969;--evt-loading-icon-color: #4e5969;--evt-expand-icon-color: #4e5969;--evt-shrink-icon-color: #4e5969;--evt-error-tip-icon-color: red;--evt-cell-hover-icon-bg-color: #fff;--evt-cell-hover-icon-border-color: #dde0ea;--evt-scroller-color: #dee0e3;--evt-scroller-track-color: #fff;--evt-scroller-focus-color: #bbbec4;--evt-select-border-color: var(--evt-color-primary);--evt-select-area-color: rgba(82, 146, 247, .1);--evt-select-row-col-bg-color: transparent;--evt-autofill-point-border-color: #fff;--evt-edit-bg-color: #fcf6ed;--evt-checkbox-color: var(--evt-color-primary);--evt-readonly-color: #fff;--evt-readonly-text-color: var(--evt-body-text-color);--evt-error-tip-color: #ed3f14;--evt-footer-bg-color: #fafafa;--evt-highlight-hover-row-color: rgba(186, 203, 231, .1);--evt-highlight-selected-row-color: rgba(82, 146, 247, .1);--evt-tooltip-bg-color: #303133;--evt-tooltip-text-color: #fff;--evt-resize-row-line-color: #e1e6eb;--evt-resize-column-line-color: #e1e6eb}.dark{--evt-border-color: #363637;--evt-header-bg-color: #141414;--evt-body-bg-color: #141414;--evt-header-text-color: #a3a6ad;--evt-scroller-color: #414243;--evt-scroller-track-color: #141414;--evt-scroller-focus-color: #a3a6ad;--evt-edit-bg-color: #141414;--evt-readonly-text-color: #cfd3dc;--evt-footer-bg-color: #262727;--evt-autofill-point-border-color: #fff;--evt-editor-bg-color: #434343;--evt-editor-text-color: #cfd3dc}.e-virt-table-container{position:relative;outline:none}.e-virt-table-stage{position:relative;overflow:hidden;outline:none;box-sizing:border-box;z-index:10;border-radius:8px;border:1px solid var(--evt-border-color)}.e-virt-table-canvas{position:absolute;left:0;top:0;box-sizing:border-box;border:none;outline:none;z-index:10}.e-virt-table-editor{position:absolute;top:-10000px;left:-10000px;text-align:left;height:auto;line-height:0;z-index:100;overflow:hidden;background-color:var(--evt-editor-bg-color);border:2px solid var(--evt-color-primary);box-sizing:border-box;box-shadow:var(--evt-box-shadow);display:flex;align-items:center}.e-virt-table-overlayer{position:absolute;left:0;top:0;overflow:hidden;z-index:100;pointer-events:none}.e-virt-table-editor-textarea{width:100%;box-sizing:border-box;outline:none;font-weight:400;padding:8px;font-size:12px;color:inherit;white-space:pre-wrap;word-wrap:break-word;word-break:break-all;line-height:1.5;margin:0;border:none;vertical-align:middle;background:var(--evt-editor-bg-color);color:var(--evt-editor-text-color);overflow-y:auto;resize:none}.e-virt-table-context-menu{position:absolute;font-size:14px;color:var(--evt-text-color-regular);background-color:var(--evt-color-white);border-radius:4px;border:1px solid #e4e7ed;box-shadow:var(--evt-box-shadow);width:fit-content;padding:6px 0;z-index:9999;left:-99999px;top:-99999px}.e-virt-table-context-menu-item{cursor:pointer;padding:8px 24px;color:var(--evt-text-color-regular)}.e-virt-table-context-menu-item:hover{color:var(--evt-color-primary);background-color:#f5f7fa}")),document.head.appendChild(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})(); var be = Object.defineProperty; var ve = (a, t, e) => t in a ? be(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e; var l = (a, t, e) => ve(a, typeof t != "symbol" ? t + "" : t, e); function q() { return q = Object.assign ? Object.assign.bind() : function(a) { for (var t = 1; t < arguments.length; t++) { var e = arguments[t]; for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && (a[i] = e[i]); } return a; }, q.apply(this, arguments); } function Re(a, t) { a.prototype = Object.create(t.prototype), a.prototype.constructor = a, st(a, t); } function Et(a) { return Et = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) { return e.__proto__ || Object.getPrototypeOf(e); }, Et(a); } function st(a, t) { return st = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(i, s) { return i.__proto__ = s, i; }, st(a, t); } function _e() { if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; if (typeof Proxy == "function") return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })), !0; } catch { return !1; } } function dt(a, t, e) { return _e() ? dt = Reflect.construct.bind() : dt = function(s, r, o) { var n = [null]; n.push.apply(n, r); var h = Function.bind.apply(s, n), c = new h(); return o && st(c, o.prototype), c; }, dt.apply(null, arguments); } function Ie(a) { return Function.toString.call(a).indexOf("[native code]") !== -1; } function Ct(a) { var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0; return Ct = function(i) { if (i === null || !Ie(i)) return i; if (typeof i != "function") throw new TypeError("Super expression must either be null or a function"); if (typeof t < "u") { if (t.has(i)) return t.get(i); t.set(i, s); } function s() { return dt(i, arguments, Et(this).constructor); } return s.prototype = Object.create(i.prototype, { constructor: { value: s, enumerable: !1, writable: !0, configurable: !0 } }), st(s, i); }, Ct(a); } var Oe = /%[sdj%]/g, Ut = function() { }; typeof process < "u" && process.env && process.env.NODE_ENV !== "production" && typeof window < "u" && typeof document < "u" && (Ut = function(t, e) { typeof console < "u" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING > "u" && e.every(function(i) { return typeof i == "string"; }) && console.warn(t, e); }); function bt(a) { if (!a || !a.length) return null; var t = {}; return a.forEach(function(e) { var i = e.field; t[i] = t[i] || [], t[i].push(e); }), t; } function D(a) { for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++) e[i - 1] = arguments[i]; var s = 0, r = e.length; if (typeof a == "function") return a.apply(null, e); if (typeof a == "string") { var o = a.replace(Oe, function(n) { if (n === "%%") return "%"; if (s >= r) return n; switch (n) { case "%s": return String(e[s++]); case "%d": return Number(e[s++]); case "%j": try { return JSON.stringify(e[s++]); } catch { return "[Circular]"; } break; default: return n; } }); return o; } return a; } function Le(a) { return a === "string" || a === "url" || a === "hex" || a === "email" || a === "date" || a === "pattern"; } function H(a, t) { return !!(a == null || t === "array" && Array.isArray(a) && !a.length || Le(t) && typeof a == "string" && !a); } function Se(a, t, e) { var i = [], s = 0, r = a.length; function o(n) { i.push.apply(i, n || []), s++, s === r && e(i); } a.forEach(function(n) { t(n, o); }); } function Nt(a, t, e) { var i = 0, s = a.length; function r(o) { if (o && o.length) { e(o); return; } var n = i; i = i + 1, n < s ? t(a[n], r) : e([]); } r([]); } function Te(a) { var t = []; return Object.keys(a).forEach(function(e) { t.push.apply(t, a[e] || []); }), t; } var Ft = /* @__PURE__ */ function(a) { Re(t, a); function t(e, i) { var s; return s = a.call(this, "Async Validation Error") || this, s.errors = e, s.fields = i, s; } return t; }(/* @__PURE__ */ Ct(Error)); function Ae(a, t, e, i, s) { if (t.first) { var r = new Promise(function(u, g) { var m = function(p) { return i(p), p.length ? g(new Ft(p, bt(p))) : u(s); }, x = Te(a); Nt(x, e, m); }); return r.catch(function(u) { return u; }), r; } var o = t.firstFields === !0 ? Object.keys(a) : t.firstFields || [], n = Object.keys(a), h = n.length, c = 0, d = [], f = new Promise(function(u, g) { var m = function(w) { if (d.push.apply(d, w), c++, c === h) return i(d), d.length ? g(new Ft(d, bt(d))) : u(s); }; n.length || (i(d), u(s)), n.forEach(function(x) { var w = a[x]; o.indexOf(x) !== -1 ? Nt(w, e, m) : Se(w, e, m); }); }); return f.catch(function(u) { return u; }), f; } function Me(a) { return !!(a && a.message !== void 0); } function He(a, t) { for (var e = a, i = 0; i < t.length; i++) { if (e == null) return e; e = e[t[i]]; } return e; } function Bt(a, t) { return function(e) { var i; return a.fullFields ? i = He(t, a.fullFields) : i = t[e.field || a.fullField], Me(e) ? (e.field = e.field || a.fullField, e.fieldValue = i, e) : { message: typeof e == "function" ? e() : e, fieldValue: i, field: e.field || a.fullField }; }; } function kt(a, t) { if (t) { for (var e in t) if (t.hasOwnProperty(e)) { var i = t[e]; typeof i == "object" && typeof a[e] == "object" ? a[e] = q({}, a[e], i) : a[e] = i; } } return a; } var Zt = function(t, e, i, s, r, o) { t.required && (!i.hasOwnProperty(t.field) || H(e, o || t.type)) && s.push(D(r.messages.required, t.fullField)); }, De = function(t, e, i, s, r) { (/^\s+$/.test(e) || e === "") && s.push(D(r.messages.whitespace, t.fullField)); }, ct, Xe = function() { if (ct) return ct; var a = "[a-fA-F\\d:]", t = function(b) { return b && b.includeBoundaries ? "(?:(?<=\\s|^)(?=" + a + ")|(?<=" + a + ")(?=\\s|$))" : ""; }, e = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}", i = "[a-fA-F\\d]{1,4}", s = (` (?: (?:` + i + ":){7}(?:" + i + `|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8 (?:` + i + ":){6}(?:" + e + "|:" + i + `|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4 (?:` + i + ":){5}(?::" + e + "|(?::" + i + `){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4 (?:` + i + ":){4}(?:(?::" + i + "){0,1}:" + e + "|(?::" + i + `){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4 (?:` + i + ":){3}(?:(?::" + i + "){0,2}:" + e + "|(?::" + i + `){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4 (?:` + i + ":){2}(?:(?::" + i + "){0,3}:" + e + "|(?::" + i + `){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4 (?:` + i + ":){1}(?:(?::" + i + "){0,4}:" + e + "|(?::" + i + `){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4 (?::(?:(?::` + i + "){0,5}:" + e + "|(?::" + i + `){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4 )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1 `).replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim(), r = new RegExp("(?:^" + e + "$)|(?:^" + s + "$)"), o = new RegExp("^" + e + "$"), n = new RegExp("^" + s + "$"), h = function(b) { return b && b.exact ? r : new RegExp("(?:" + t(b) + e + t(b) + ")|(?:" + t(b) + s + t(b) + ")", "g"); }; h.v4 = function(y) { return y && y.exact ? o : new RegExp("" + t(y) + e + t(y), "g"); }, h.v6 = function(y) { return y && y.exact ? n : new RegExp("" + t(y) + s + t(y), "g"); }; var c = "(?:(?:[a-z]+:)?//)", d = "(?:\\S+(?::\\S*)?@)?", f = h.v4().source, u = h.v6().source, g = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)", m = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*", x = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))", w = "(?::\\d{2,5})?", p = '(?:[/?#][^\\s"]*)?', C = "(?:" + c + "|www\\.)" + d + "(?:localhost|" + f + "|" + u + "|" + g + m + x + ")" + w + p; return ct = new RegExp("(?:^" + C + "$)", "i"), ct; }, Kt = { // http://emailregex.com/ email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/, // url: new RegExp( // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', // 'i', // ), hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i }, et = { integer: function(t) { return et.number(t) && parseInt(t, 10) === t; }, float: function(t) { return et.number(t) && !et.integer(t); }, array: function(t) { return Array.isArray(t); }, regexp: function(t) { if (t instanceof RegExp) return !0; try { return !!new RegExp(t); } catch { return !1; } }, date: function(t) { return typeof t.getTime == "function" && typeof t.getMonth == "function" && typeof t.getYear == "function" && !isNaN(t.getTime()); }, number: function(t) { return isNaN(t) ? !1 : typeof t == "number"; }, object: function(t) { return typeof t == "object" && !et.array(t); }, method: function(t) { return typeof t == "function"; }, email: function(t) { return typeof t == "string" && t.length <= 320 && !!t.match(Kt.email); }, url: function(t) { return typeof t == "string" && t.length <= 2048 && !!t.match(Xe()); }, hex: function(t) { return typeof t == "string" && !!t.match(Kt.hex); } }, Ne = function(t, e, i, s, r) { if (t.required && e === void 0) { Zt(t, e, i, s, r); return; } var o = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"], n = t.type; o.indexOf(n) > -1 ? et[n](e) || s.push(D(r.messages.types[n], t.fullField, t.type)) : n && typeof e !== t.type && s.push(D(r.messages.types[n], t.fullField, t.type)); }, Fe = function(t, e, i, s, r) { var o = typeof t.len == "number", n = typeof t.min == "number", h = typeof t.max == "number", c = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, d = e, f = null, u = typeof e == "number", g = typeof e == "string", m = Array.isArray(e); if (u ? f = "number" : g ? f = "string" : m && (f = "array"), !f) return !1; m && (d = e.length), g && (d = e.replace(c, "_").length), o ? d !== t.len && s.push(D(r.messages[f].len, t.fullField, t.len)) : n && !h && d < t.min ? s.push(D(r.messages[f].min, t.fullField, t.min)) : h && !n && d > t.max ? s.push(D(r.messages[f].max, t.fullField, t.max)) : n && h && (d < t.min || d > t.max) && s.push(D(r.messages[f].range, t.fullField, t.min, t.max)); }, j = "enum", Be = function(t, e, i, s, r) { t[j] = Array.isArray(t[j]) ? t[j] : [], t[j].indexOf(e) === -1 && s.push(D(r.messages[j], t.fullField, t[j].join(", "))); }, ke = function(t, e, i, s, r) { if (t.pattern) { if (t.pattern instanceof RegExp) t.pattern.lastIndex = 0, t.pattern.test(e) || s.push(D(r.messages.pattern.mismatch, t.fullField, e, t.pattern)); else if (typeof t.pattern == "string") { var o = new RegExp(t.pattern); o.test(e) || s.push(D(r.messages.pattern.mismatch, t.fullField, e, t.pattern)); } } }, L = { required: Zt, whitespace: De, type: Ne, range: Fe, enum: Be, pattern: ke }, Ke = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e, "string") && !t.required) return i(); L.required(t, e, s, o, r, "string"), H(e, "string") || (L.type(t, e, s, o, r), L.range(t, e, s, o, r), L.pattern(t, e, s, o, r), t.whitespace === !0 && L.whitespace(t, e, s, o, r)); } i(o); }, Ye = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && L.type(t, e, s, o, r); } i(o); }, Ve = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (e === "" && (e = void 0), H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && (L.type(t, e, s, o, r), L.range(t, e, s, o, r)); } i(o); }, We = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && L.type(t, e, s, o, r); } i(o); }, Pe = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), H(e) || L.type(t, e, s, o, r); } i(o); }, ze = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && (L.type(t, e, s, o, r), L.range(t, e, s, o, r)); } i(o); }, $e = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && (L.type(t, e, s, o, r), L.range(t, e, s, o, r)); } i(o); }, qe = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (e == null && !t.required) return i(); L.required(t, e, s, o, r, "array"), e != null && (L.type(t, e, s, o, r), L.range(t, e, s, o, r)); } i(o); }, Ge = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && L.type(t, e, s, o, r); } i(o); }, je = "enum", Ue = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r), e !== void 0 && L[je](t, e, s, o, r); } i(o); }, Ze = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e, "string") && !t.required) return i(); L.required(t, e, s, o, r), H(e, "string") || L.pattern(t, e, s, o, r); } i(o); }, Je = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e, "date") && !t.required) return i(); if (L.required(t, e, s, o, r), !H(e, "date")) { var h; e instanceof Date ? h = e : h = new Date(e), L.type(t, h, s, o, r), h && L.range(t, h.getTime(), s, o, r); } } i(o); }, Qe = function(t, e, i, s, r) { var o = [], n = Array.isArray(e) ? "array" : typeof e; L.required(t, e, s, o, r, n), i(o); }, mt = function(t, e, i, s, r) { var o = t.type, n = [], h = t.required || !t.required && s.hasOwnProperty(t.field); if (h) { if (H(e, o) && !t.required) return i(); L.required(t, e, s, n, r, o), H(e, o) || L.type(t, e, s, n, r); } i(n); }, ti = function(t, e, i, s, r) { var o = [], n = t.required || !t.required && s.hasOwnProperty(t.field); if (n) { if (H(e) && !t.required) return i(); L.required(t, e, s, o, r); } i(o); }, it = { string: Ke, method: Ye, number: Ve, boolean: We, regexp: Pe, integer: ze, float: $e, array: qe, object: Ge, enum: Ue, pattern: Ze, date: Je, url: mt, hex: mt, email: mt, required: Qe, any: ti }; function vt() { return { default: "Validation error on field %s", required: "%s is required", enum: "%s must be one of %s", whitespace: "%s cannot be empty", date: { format: "%s date %s is invalid for format %s", parse: "%s date could not be parsed, %s is invalid ", invalid: "%s date %s is invalid" }, types: { string: "%s is not a %s", method: "%s is not a %s (function)", array: "%s is not an %s", object: "%s is not an %s", number: "%s is not a %s", date: "%s is not a %s", boolean: "%s is not a %s", integer: "%s is not an %s", float: "%s is not a %s", regexp: "%s is not a valid %s", email: "%s is not a valid %s", url: "%s is not a valid %s", hex: "%s is not a valid %s" }, string: { len: "%s must be exactly %s characters", min: "%s must be at least %s characters", max: "%s cannot be longer than %s characters", range: "%s must be between %s and %s characters" }, number: { len: "%s must equal %s", min: "%s cannot be less than %s", max: "%s cannot be greater than %s", range: "%s must be between %s and %s" }, array: { len: "%s must be exactly %s in length", min: "%s cannot be less than %s in length", max: "%s cannot be greater than %s in length", range: "%s must be between %s and %s in length" }, pattern: { mismatch: "%s value %s does not match pattern %s" }, clone: function() { var t = JSON.parse(JSON.stringify(this)); return t.clone = this.clone, t; } }; } var Rt = vt(), nt = /* @__PURE__ */ function() { function a(e) { this.rules = null, this._messages = Rt, this.define(e); } var t = a.prototype; return t.define = function(i) { var s = this; if (!i) throw new Error("Cannot configure a schema with no rules"); if (typeof i != "object" || Array.isArray(i)) throw new Error("Rules must be an object"); this.rules = {}, Object.keys(i).forEach(function(r) { var o = i[r]; s.rules[r] = Array.isArray(o) ? o : [o]; }); }, t.messages = function(i) { return i && (this._messages = kt(vt(), i)), this._messages; }, t.validate = function(i, s, r) { var o = this; s === void 0 && (s = {}), r === void 0 && (r = function() { }); var n = i, h = s, c = r; if (typeof h == "function" && (c = h, h = {}), !this.rules || Object.keys(this.rules).length === 0) return c && c(null, n), Promise.resolve(n); function d(x) { var w = [], p = {}; function C(b) { if (Array.isArray(b)) { var E; w = (E = w).concat.apply(E, b); } else w.push(b); } for (var y = 0; y < x.length; y++) C(x[y]); w.length ? (p = bt(w), c(w, p)) : c(null, n); } if (h.messages) { var f = this.messages(); f === Rt && (f = vt()), kt(f, h.messages), h.messages = f; } else h.messages = this.messages(); var u = {}, g = h.keys || Object.keys(this.rules); g.forEach(function(x) { var w = o.rules[x], p = n[x]; w.forEach(function(C) { var y = C; typeof y.transform == "function" && (n === i && (n = q({}, n)), p = n[x] = y.transform(p)), typeof y == "function" ? y = { validator: y } : y = q({}, y), y.validator = o.getValidationMethod(y), y.validator && (y.field = x, y.fullField = y.fullField || x, y.type = o.getType(y), u[x] = u[x] || [], u[x].push({ rule: y, value: p, source: n, field: x })); }); }); var m = {}; return Ae(u, h, function(x, w) { var p = x.rule, C = (p.type === "object" || p.type === "array") && (typeof p.fields == "object" || typeof p.defaultField == "object"); C = C && (p.required || !p.required && x.value), p.field = x.field; function y(R, O) { return q({}, O, { fullField: p.fullField + "." + R, fullFields: p.fullFields ? [].concat(p.fullFields, [R]) : [R] }); } function b(R) { R === void 0 && (R = []); var O = Array.isArray(R) ? R : [R]; !h.suppressWarning && O.length && a.warning("async-validator:", O), O.length && p.message !== void 0 && (O = [].concat(p.message)); var I = O.map(Bt(p, n)); if (h.first && I.length) return m[p.field] = 1, w(I); if (!C) w(I); else { if (p.required && !x.value) return p.message !== void 0 ? I = [].concat(p.message).map(Bt(p, n)) : h.error && (I = [h.error(p, D(h.messages.required, p.field))]), w(I); var _ = {}; p.defaultField && Object.keys(x.value).map(function(T) { _[T] = p.defaultField; }), _ = q({}, _, x.rule.fields); var v = {}; Object.keys(_).forEach(function(T) { var M = _[T], A = Array.isArray(M) ? M : [M]; v[T] = A.map(y.bind(null, T)); }); var S = new a(v); S.messages(h.messages), x.rule.options && (x.rule.options.messages = h.messages, x.rule.options.error = h.error), S.validate(x.value, x.rule.options || h, function(T) { var M = []; I && I.length && M.push.apply(M, I), T && T.length && M.push.apply(M, T), w(M.length ? M : null); }); } } var E; if (p.asyncValidator) E = p.asyncValidator(p, x.value, b, x.source, h); else if (p.validator) { try { E = p.validator(p, x.value, b, x.source, h); } catch (R) { console.error == null || console.error(R), h.suppressValidatorError || setTimeout(function() { throw R; }, 0), b(R.message); } E === !0 ? b() : E === !1 ? b(typeof p.message == "function" ? p.message(p.fullField || p.field) : p.message || (p.fullField || p.field) + " fails") : E instanceof Array ? b(E) : E instanceof Error && b(E.message); } E && E.then && E.then(function() { return b(); }, function(R) { return b(R); }); }, function(x) { d(x); }, n); }, t.getType = function(i) { if (i.type === void 0 && i.pattern instanceof RegExp && (i.type = "pattern"), typeof i.validator != "function" && i.type && !it.hasOwnProperty(i.type)) throw new Error(D("Unknown rule type %s", i.type)); return i.type || "string"; }, t.getValidationMethod = function(i) { if (typeof i.validator == "function") return i.validator; var s = Object.keys(i), r = s.indexOf("message"); return r !== -1 && s.splice(r, 1), s.length === 1 && s[0] === "required" ? it.required : it[this.getType(i)] || void 0; }, a; }(); nt.register = function(t, e) { if (typeof e != "function") throw new Error("Cannot register a validator by type, validator is not a function"); it[t] = e; }; nt.warning = Ut; nt.messages = Rt; nt.validators = it; function Jt() { return "xxxxxxxxxxxxxxxxxx".replace(/[x]/g, function(a) { const t = Math.random() * 16 | 0; return (a === "x" ? t : t & 3 | 8).toString(16); }); } function Qt(a, t) { let e = 0, i; return function(...s) { const r = (/* @__PURE__ */ new Date()).getTime(), o = r - e; !e || o >= t ? (a.apply(this, s), e = r) : i || (i = setTimeout(() => { a.apply(this, s), e = (/* @__PURE__ */ new Date()).getTime(), i = void 0; }, t - o)); }; } function te(a = []) { return a.length ? a.map((t) => te(t.children) + 1).sort((t, e) => e - t)[0] : 0; } function ei(a = []) { let t = [], e = [], i = []; return a.forEach((s) => { s.fixed === "left" ? t.push(s) : s.fixed === "right" ? i.push(s) : e.push(s); }), [ ...t.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0)), ...e.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0)), ...i.sort((s, r) => (s.sort ?? 0) - (r.sort ?? 0)) ]; } function ee(a = [], t = 1, e = 0) { return a.map((i) => { if (i.children) { let s = 0, r = i.fixed; i.children.forEach((n) => { n.fixed = r; }); const o = ee(i.children, t - 1, e + 1); return o && o.forEach((n) => { s += n.colspan ?? 0; }), { ...i, width: i.width, level: e, rowspan: 1, colspan: s, children: o }; } return { ...i, level: e, rowspan: t, colspan: 1 }; }); } function _t(a = []) { let t = []; return a.forEach((e) => { e.children ? t = t.concat(_t(e.children)) : t.push(e); }), t; } const Yt = /^(\r\n|\n\r|\r|\n)/, ii = /^[^\t\r\n]+/, Vt = /^\t/; function si(a) { let t = [[""]]; if (a.length === 0) return t; let e = 0, i = 0, s; for (; a.length > 0 && s !== a.length; ) if (s = a.length, a.match(Vt)) a = a.replace(Vt, ""), e += 1, t[i][e] = ""; else if (a.match(Yt)) a = a.replace(Yt, ""), e = 0, i += 1, t[i] = [""]; else { let r = ""; if (a.startsWith('"')) { let o = 0, n = !0; for (; n; ) { const h = a.slice(0, 1); h === '"' && (o += 1), r += h, a = a.slice(1), (a.length === 0 || a.match(/^[\t\r\n]/) && o % 2 === 0) && (n = !1); } r = r.replace(/^"/, "").replace(/"$/, "").replace(/["]*/g, (h) => new Array(Math.floor(h.length / 2)).fill('"').join("")); } else { const o = a.match(ii); r = o ? o[0] : "", a = a.slice(r.length); } t[i][e] = r; } return Array.isArray(t) && t.length > 1 && t[t.length - 1].length === 1 && t[t.length - 1][0] === "" && (t = t.slice(0, t.length - 1)), t; } function ri(a) { let t, e, i, s, r = "", o; for (t = 0, e = a.length; t < e; t += 1) { for (s = a[t].length, i = 0; i < s; i += 1) i > 0 && (r += " "), o = a[t][i], typeof o == "string" ? o.indexOf(` `) > -1 ? r += `"${o.replace(/"/g, '""')}"` : r += o : o == null ? r += "" : r += o; t !== e - 1 && (r += ` `); } return r; } function ie(a, t, e = []) { let i = 0; const s = []; return a.forEach((r, o) => { if (o === 0) s.push(1); else { const n = e.reduce((c, d) => `${c}${r[d] ?? ""}`, "") || r[t], h = e.reduce((c, d) => `${c}${a[o - 1][d] ?? ""}`, "") || a[o - 1][t]; n === h ? (s[i] += 1, s.push(0)) : (s.push(1), i = o); } }), s; } function se(a, t) { let e = "", i = ""; const s = {}; return t.forEach((r, o) => { o === 0 ? (e = r.key, i = r.key, s[r.key] = 1) : a[r.key] === a[e] ? (s[r.key] = 0, s[i] += 1) : (s[r.key] = 1, e = r.key, i = r.key); }), s; } function oi(a, t, e = []) { const { visibleRows: i, rowIndex: s, headIndex: r } = a, o = ie(i, t, e); return o[s - r] === 0 ? { rowspan: 0, colspan: 0, relationRowKeys: e, mergeRow: !0 } : { rowspan: o[s - r], colspan: 1, relationRowKeys: e, mergeRow: !0 }; } function ni(a, t = []) { const { column: e, row: i, visibleLeafColumns: s } = a, r = s.filter((o) => t.includes(o.key)); if (t.includes(e.key)) { const o = se(i, r); return o[e.key] === 0 ? { rowspan: 0, colspan: 0, relationColKeys: t, mergeCol: !0 } : { rowspan: 1, colspan: o[e.key], relationColKeys: t, mergeCol: !0 }; } } function ai(a, t = document.documentElement) { const e = a.startsWith("--") ? a : `--${a}`; return getComputedStyle(t).getPropertyValue(e).trim(); } class re { constructor(t, e, i, s, r, o, n) { l(this, "ctx"); l(this, "x", 0); l(this, "y", 0); l(this, "width", 0); l(this, "height", 0); l(this, "fixed"); l(this, "cellType"); this.ctx = t, this.x = e, this.y = i, this.width = s, this.height = r, this.fixed = n, this.cellType = o; } isHorizontalVisible() { if (this.fixed) return !0; const { stageWidth: t, fixedLeftWidth: e, scrollX: i, fixedRightWidth: s } = this.ctx, r = t; return !(this.x + this.width - e - i <= 0 || this.x - i >= r - s); } isVerticalVisible() { const { stageHeight: t, scrollY: e } = this.ctx, i = t; return !(this.y + this.height - e <= 0 || this.y - e >= i); } getDrawX() { if (this.fixed === "left") return this.x; if (this.fixed === "right") { const { stageWidth: t, config: { SCROLLER_TRACK_SIZE: e } } = this.ctx; return t - (this.ctx.header.width - this.x) - e; } return this.x - this.ctx.scrollX; } getDrawY() { return this.cellType === "header" ? this.y : this.cellType === "footer" && this.ctx.config.FOOTER_FIXED ? this.y : this.y - this.ctx.scrollY; } getLeftFixedX() { return this.x - this.ctx.scrollX; } /** * RightFixed时相对StageX * @returns */ getRightFixedX() { } } class At extends re { constructor(e, i, s, r, o, n, h, c, d, f = "body") { super(e, r, o, n, h, f, c.fixed); l(this, "formatter"); l(this, "formatterFooter"); l(this, "hoverIconName", ""); l(this, "operation", !1); l(this, "align"); l(this, "verticalAlign"); l(this, "fixed"); l(this, "type"); l(this, "editorType"); l(this, "editorProps"); l(this, "cellType"); l(this, "level"); l(this, "colspan", 1); l(this, "rowspan", 1); l(this, "mergeRow", !1); l(this, "mergeCol", !1); l(this, "relationRowKeys", []); // 合并单元格关联key l(this, "relationColKeys", []); // 合并单元格关联key l(this, "key"); l(this, "column"); l(this, "rowIndex"); l(this, "colIndex"); l(this, "rowKey"); l(this, "row"); l(this, "value"); l(this, "render"); l(this, "renderFooter"); l(this, "style", {}); l(this, "rules", []); l(this, "message", ""); l(this, "text", ""); l(this, "displayText", ""); l(this, "visibleWidth", 0); l(this, "visibleHeight", 0); l(this, "isHasChanged", !1); l(this, "drawX", 0); l(this, "drawY", 0); l(this, "drawCellBgColor", ""); l(this, "drawCellSkyBgColor", ""); l(this, "drawTextColor", ""); l(this, "drawTextX", 0); l(this, "drawTextY", 0); l(this, "drawImageX", 0); l(this, "drawImageY", 0); l(this, "drawImageWidth", 0); l(this, "drawImageHeight", 0); l(this, "drawImageName", ""); l(this, "drawImageSource"); l(this, "ellipsis", !1); l(this, "rowExpand", !1); l(this, "rowHasChildren", !1); l(this, "overflowTooltipShow", !0); l(this, "overflowTooltipMaxWidth", 500); l(this, "overflowTooltipPlacement", "top"); this.visibleWidth = this.width, this.visibleHeight = this.height, this.colIndex = s, this.rowIndex = i, this.key = c.key, this.type = c.type || "", this.editorType = c.editorType || "text", this.editorProps = c.editorProps || {}, this.cellType = f, this.align = c.align || "center", this.verticalAlign = c.verticalAlign || "middle", this.fixed = c.fixed, this.level = c.level || 0, this.operation = c.operation || !1, this.column = c, this.rules = c.rules || [], this.row = d, this.rowKey = this.cellType === "body" ? this.ctx.database.getRowKeyForRowIndex(i) : `${this.cellType}_${this.rowIndex}`, this.value = this.getValue(), this.render = c.render, this.overflowTooltipShow = c.overflowTooltipShow !== !1, this.overflowTooltipMaxWidth = c.overflowTooltipMaxWidth || 500, this.overflowTooltipPlacement = c.overflowTooltipPlacement || "top", this.renderFooter = c.renderFooter, this.hoverIconName = c.hoverIconName, this.formatter = c.formatter, this.formatterFooter = c.formatterFooter, this.update(); } setWidthHeight(e, i) { this.width = e, this.height = i; } getValidationMessage() { const e = this.ctx.database.getValidationError(this.rowKey, this.key); if (Array.isArray(e) && e.length) { const [i] = e; this.message = i.message || ""; } return this.message; } update() { this.drawX = this.getDrawX(), this.drawY = this.getDrawY(), this.drawTextX = this.drawX, this.drawTextY = this.drawY, this.isHasChanged = this.ctx.database.isHasChangedData(this.rowKey, this.key), this.updateSpan(), this.updateStyle(), this.updateType(), this.updateHoverIcon(), this.updateSelection(), this.updateTree(), this.updateEditor(), this.updateRender(), this.getValidationMessage(), this.updateContainer(), this.text = this.getText(), this.displayText = this.getDisplayText(); } updateSpan() { if (this.cellType === "footer") return; const { SPAN_METHOD: e } = this.ctx.config; if (typeof e == "function") { const i = e, { colspan: s = 1, rowspan: r = 1, relationRowKeys: o, relationColKeys: n, mergeRow: h = !1, mergeCol: c = !1 } = i({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue(), headIndex: this.ctx.body.headIndex, headPosition: this.ctx.database.getPositionForRowIndex(this.ctx.body.headIndex), visibleRows: this.ctx.body.visibleRows, visibleLeafColumns: this.ctx.header.visibleLeafColumns, rows: this.ctx.body.data }) || {}; Array.isArray(o) && o.length > 0 ? this.relationRowKeys = o : this.relationRowKeys = [this.key], Array.isArray(n) && n.length > 0 ? this.relationColKeys = n : this.relationColKeys = [this.key], this.mergeCol = c, this.mergeRow = h, this.colspan = s, this.rowspan = r, this.visibleWidth = this.getWidthByColIndexColSpan(this.colIndex, this.colspan), this.visibleHeight = this.ctx.database.getHeightByRowIndexRowSpan(this.rowIndex, this.rowspan); } } updateSpanInfo() { if (this.mergeRow || this.mergeCol) { const e = this.getSpanInfo(); this.height = e.height, this.width = e.width, this.drawX = this.getDrawX(), this.drawY = this.getDrawY(), this.drawY -= e.offsetTop, this.drawX -= e.offsetLeft; } } updateType() { const { BODY_CELL_TYPE_METHOD: e } = this.ctx.config; if (typeof e == "function") { const s = e({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }); s !== void 0 && (this.type = s); } } updateEditor() { const { BODY_CELL_EDITOR_METHOD: e } = this.ctx.config; if (typeof e == "function") { const s = e({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }); if (s !== void 0) { const { type: r, props: o = {} } = s; this.editorType = r, this.editorProps = o; } } } updateRender() { const { BODY_CELL_RENDER_METHOD: e } = this.ctx.config; if (typeof e == "function") { const s = e({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }); s !== void 0 && (this.render = s); } } validate() { this.ctx.database.getValidator(this.rowKey, this.key).then(() => { this.ctx.database.setValidationError(this.rowKey, this.key, []), this.message = ""; }).catch((e) => { if (Array.isArray(e) && e.length) { const [i] = e; this.message = i.message, this.ctx.database.setValidationError(this.rowKey, this.key, e); } }).finally(() => { this.ctx.emit("draw"); }); } /** * 更新样式 */ updateStyle() { this.style = this.getOverlayerViewsStyle(); } updateTree() { const { CELL_PADDING: e = 0 } = this.ctx.config, { rowKey: i, cellType: s } = this; let r, o = 0, n = ""; if (this.type === "tree" && s === "body") { const h = this.ctx.database.getRowForRowKey(i), { expand: c = !1, hasChildren: d = !1, expandLoading: f = !1, level: u = 0 } = h || {}; if (this.rowExpand = c, this.rowHasChildren = d, f) { const x = this.ctx.icons.get("loading"); n = "loading", r = x, o = u * 8; } else if (d) { const x = this.ctx.icons.get("expand"), w = this.ctx.icons.get("shrink"); r = c ? w : x, n = c ? "shrink" : "expand", o = u * 8; } else o = u * 8; let g = 20, m = 20; if (r) { let x = this.drawX + o + e, w = this.drawY + (this.visibleHeight - m) / 2; this.ctx.paint.drawImage(r, x, w, g, m), this.drawImageX = x, this.drawImageY = w, this.drawImageWidth = g, this.drawImageHeight = m, this.drawImageName = n, this.drawImageSource = r; } this.align = "left", this.drawTextX = o + this.drawX + g - 0.5; } } updateContainer() { const { BODY_BG_COLOR: e, EDIT_BG_COLOR: i, BODY_CELL_STYLE_METHOD: s, FOOTER_CELL_STYLE_METHOD: r, READONLY_TEXT_COLOR: o, BODY_TEXT_COLOR: n, FOOTER_TEXT_COLOR: h, FOOTER_BG_COLOR: c, HIGHLIGHT_SELECTED_ROW: d, HIGHLIGHT_SELECTED_ROW_COLOR: f, HIGHLIGHT_HOVER_ROW: u, HIGHLIGHT_HOVER_ROW_COLOR: g, STRIPE: m, STRIPE_COLOR: x } = this.ctx.config; if (this.cellType === "footer") { let O = c, I = h; if (typeof r == "function") { const _ = r, { backgroundColor: v, color: S } = _({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }) || {}; v && (O = v), S && (I = S); } this.drawCellSkyBgColor = "transparent", this.drawCellBgColor = O, this.drawTextColor = I; return; } let w = "transparent"; const p = this.ctx.focusCell, C = this.ctx.hoverCell; let y = this.rowIndex, b = this.rowIndex; if (this.rowspan !== 1 && (u || d)) { const O = this.getSpanInfo(), { yArr: I } = O; y = I[0], b = I[1]; } u && C && (C.rowKey === this.rowKey && (w = g), C.rowIndex >= y && C.rowIndex <= b && (w = g)), d && p && (p.rowKey === this.rowKey && (w = f), p.rowIndex >= y && p.rowIndex <= b && (w = f)), this.drawCellSkyBgColor = w; let E = e, R = n; if (this.ctx.database.getReadonly(this.rowKey, this.key) || (E = i, R = o), m && (this.rowIndex % 2 ? E = x : E = e), typeof s == "function") { const O = s, { backgroundColor: I, color: _ } = O({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, isHasChanged: this.isHasChanged, value: this.getValue() }) || {}; I && (E = I), _ && (R = _); } this.drawCellBgColor = E, this.drawTextColor = R; } updateSelection() { const { visibleWidth: e, visibleHeight: i, rowspan: s, colspan: r, cellType: o, type: n, rowIndex: h, rowKey: c } = this; if (!(s === 0 || r === 0) && o !== "footer" && ["index-selection", "selection"].includes(n)) { const d = this.ctx.database.getRowSelection(c), f = this.ctx.database.getRowSelectable(c), { CHECKBOX_SIZE: u = 0 } = this.ctx.config, g = this.drawX + (e - u) / 2, m = this.drawY + (i - u) / 2; let x = this.ctx.icons.get("checkbox-uncheck"), w = "checkbox-uncheck"; d && f ? (x = this.ctx.icons.get("checkbox-check"), w = "checkbox-check") : d && f ? (x = this.ctx.icons.get("checkbox-check-disabled"), w = "checkbox-check-disabled") : !d && f ? (x = this.ctx.icons.get("checkbox-uncheck"), w = "checkbox-uncheck") : (x = this.ctx.icons.get("checkbox-disabled"), w = "checkbox-disabled"), x && n == "index-selection" ? (this.ctx.hoverCell && this.ctx.hoverCell.rowIndex === h || ["checkbox-disabled", "checkbox-check"].includes(w)) && (this.drawImageX = g, this.drawImageY = m, this.drawImageWidth = u, this.drawImageHeight = u, this.drawImageName = w, this.drawImageSource = x) : x && n === "selection" && (this.drawImageX = g, this.drawImageY = m, this.drawImageWidth = u, this.drawImageHeight = u, this.drawImageName = w, this.drawImageSource = x); } } updateHoverIcon() { if (this.ctx.database.getReadonly(this.rowKey, this.key)) return; const { BODY_CELL_HOVER_ICON_METHOD: i, CELL_HOVER_ICON_SIZE: s, CELL_PADDING: r, ENABLE_MERGE_CELL_LINK: o } = this.ctx.config; if (typeof i == "function") { const c = i({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }); c !== void 0 && (this.hoverIconName = c); } const { hoverCell: n } = this.ctx; if (this.hoverIconName && !this.ctx.editing && n) { let h = 0, c = 0; if (n.rowKey === this.rowKey && (h = this.drawX + this.width - s - r, c = this.drawY + (this.height - s) / 2), this.rowspan !== 1 && o) { const f = this.getSpanInfo(), { yArr: u } = f, g = u[0], m = u[1]; if (n.rowIndex >= g && n.rowIndex <= m) { const { width: x, height: w, offsetTop: p, offsetLeft: C } = f; h = this.drawX - C + x - s - r, c = this.drawY - p + (w - s) / 2; } } const d = this.ctx.icons.get(this.hoverIconName); this.drawImageX = h, this.drawImageY = c, this.drawImageWidth = s, this.drawImageHeight = s, this.drawImageName = this.hoverIconName, this.drawImageSource = d; } } // 过去跨度配置 getSpanInfo() { return this.ctx.database.getSpanInfo(this); } /** * 获取显示文本 * @returns */ getDisplayText() { return this.cellType === "footer" ? this.renderFooter || this.text === null || this.text === void 0 ? "" : this.text : this.rowspan === 0 || this.colspan === 0 || this.render || this.type === "index-selection" && (this.ctx.hoverCell && this.ctx.hoverCell.rowIndex === this.rowIndex || ["checkbox-disabled", "checkbox-check"].includes(this.drawImageName)) || this.text === null || this.text === void 0 ? "" : `${this.text}`; } /** * 获取文本 * @returns */ getText() { if (this.cellType === "footer") return typeof this.formatterFooter == "function" ? this.formatterFooter({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.row[this.key] }) : this.row[this.key]; if (typeof this.formatter == "function") return this.formatter({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }); const { BODY_CELL_FORMATTER_METHOD: e } = this.ctx.config; return typeof e == "function" ? e({ row: this.row, rowIndex: this.rowIndex, colIndex: this.colIndex, column: this.column, value: this.getValue() }) : ["index-selection", "index"].includes(this.type) ? `${this.rowIndex + 1}` : (this.value = this.ctx.database.getItemValue(this.rowKey, this.key), this.value); } getValue() { return this.ctx.database.getItemValue(this.rowKey, this.key); } // 拓展格子可设置数据 setValue(e) { this.ctx.setItemValueByEditor(this.rowKey, this.key, e); } /** * 获取样式 */ getOverlayerViewsStyle() { let e = `${this.drawX - this.ctx.fixedLeftWidth}px`, i = `${this.drawY - this.ctx.body.y}px`; return this.fixed === "left" ? e = `${this.drawX}px` : this.fixed === "right" && (e = `${this.drawX - (this.ctx.stageWidth - this.ctx.fixedRightWidth)}px`), this.cellType === "footer" && this.ctx.config.FOOTER_FIXED && (i = `${this.drawY - this.ctx.footer.y}px`), { position: "absolute", overflow: "hidden", left: e, top: i, width: `${this.visibleWidth}px`, height: `${this.visibleHeight}px`, pointerEvents: "initial", userSelect: "none" }; } drawContainer() { const { paint: e, config: { BORDER_COLOR: i, BORDER: s } } = this.ctx, { drawX: r, drawY: o } = this; e.drawRect(r, o, this.visibleWidth, this.visibleHeight, { borderColor: s ? i : "transparent", fillColor: this.drawCellBgColor }), e.drawRect(r, o, this.width, this.height, { borderColor: "transparent", fillColor: this.drawCellSkyBgColor }), s || this.ctx.paint.drawLine( [r, o + this.visibleHeight, r + this.visibleWidth, o + this.visibleHeight], { borderColor: i, fillColor: i, borderWidth: 1, lineCap: "round", lineJoin: "round" } ); } drawAutofillPiont() { if (this.cellType === "footer") return; const { SELECT_BORDER_COLOR: e, ENABLE_AUTOFILL: i, ENABLE_SELECTOR: s, AUTOFILL_POINT_BORDER_COLOR: r } = this.ctx.config; if (!s || !i || this.ctx.editing) return; const { xArr: o, yArr: n } = this.ctx.selector, h = o[1], c = n[1], { colIndex: d, rowIndex: f, drawX: u, drawY: g } = this; if (d === h && f === c) { const x = d === this.ctx.maxColIndex || f === this.ctx.maxRowIndex || d === this.ctx.lastCenterColIndex ? 6 : 4; this.ctx.paint.drawRect(u + this.width - x, g + this.height - x, 6, 6, { borderColor: r, fillColor: e }); } } draw() { this.drawText(), this.drawImage(), this.drawSelector(), this.drawAutofillPiont(), this.drawErrorTip(); } /** * 根据列的索引获取列的宽度 * @param {Number} colIndex */ getWidthByColIndexColSpan(e, i) { if (i === 0) return 0; let s = 0; for (let r = e; r < e + i; r++) { const o = this.ctx.header.leafCellHeaders[r]; s += o.width; } return s; } drawText() { const { CELL_PADDING: e, BODY_FONT: i, PLACEHOLDER_COLOR: s } = this.ctx.config; let r = this.visibleWidth; if (this.type === "tree") { const f = this.drawTextX - this.drawX; r = this.visibleWidth - f; } const { ellipsis: o } = this.ctx.paint.handleEllipsis(this.displayText, r, e, i); this.e