UNPKG

@visactor/react-vtable

Version:
1,339 lines (1,272 loc) 858 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@visactor/vtable'), require('react')) : typeof define === 'function' && define.amd ? define(['exports', '@visactor/vtable', 'react'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactVTable = {}, global.VTable, global.React)); })(this, (function (exports, vtable, React) { 'use strict'; function withContainer(Comp, name = 'TableContainer', getProps) { const Cls = React.forwardRef((props, ref) => { const container = React.useRef(); const [inited, setInited] = React.useState(false); const { className, style, width, ...options } = props; React.useLayoutEffect(() => { setInited(true); }, []); return (React.createElement("div", { ref: container, className: className, style: { position: 'relative', height: props.height || '100%', width: props.width || '100%', ...style } }, inited ? (React.createElement(Comp, { ref: ref, container: container.current, ...(getProps ? getProps(options) : options) })) : (React.createElement(React.Fragment, null)))); }); Cls.displayName = name || Comp.name; return Cls; } const TableContext = React.createContext(null); TableContext.displayName = 'TableContext'; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } var eventemitter3 = {exports: {}}; (function (module) { var has = Object.prototype.hasOwnProperty, prefix = '~'; /** * Constructor to create a storage for our `EE` objects. * An `Events` instance is a plain object whose properties are event names. * * @constructor * @private */ function Events() {} // // We try to not inherit from `Object.prototype`. In some engines creating an // instance in this way is faster than calling `Object.create(null)` directly. // If `Object.create(null)` is not supported we prefix the event names with a // character to make sure that the built-in object properties are not // overridden or used as an attack vector. // if (Object.create) { Events.prototype = Object.create(null); // // This hack is needed because the `__proto__` property is still inherited in // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5. // if (!new Events().__proto__) prefix = false; } /** * Representation of a single event listener. * * @param {Function} fn The listener function. * @param {*} context The context to invoke the listener with. * @param {Boolean} [once=false] Specify if the listener is a one-time listener. * @constructor * @private */ function EE(fn, context, once) { this.fn = fn; this.context = context; this.once = once || false; } /** * Add a listener for a given event. * * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} context The context to invoke the listener with. * @param {Boolean} once Specify if the listener is a one-time listener. * @returns {EventEmitter} * @private */ function addListener(emitter, event, fn, context, once) { if (typeof fn !== 'function') { throw new TypeError('The listener must be a function'); } var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event; if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);else emitter._events[evt] = [emitter._events[evt], listener]; return emitter; } /** * Clear event by name. * * @param {EventEmitter} emitter Reference to the `EventEmitter` instance. * @param {(String|Symbol)} evt The Event name. * @private */ function clearEvent(emitter, evt) { if (--emitter._eventsCount === 0) emitter._events = new Events();else delete emitter._events[evt]; } /** * Minimal `EventEmitter` interface that is molded against the Node.js * `EventEmitter` interface. * * @constructor * @public */ function EventEmitter() { this._events = new Events(); this._eventsCount = 0; } /** * Return an array listing the events for which the emitter has registered * listeners. * * @returns {Array} * @public */ EventEmitter.prototype.eventNames = function eventNames() { var names = [], events, name; if (this._eventsCount === 0) return names; for (name in events = this._events) { if (has.call(events, name)) names.push(prefix ? name.slice(1) : name); } if (Object.getOwnPropertySymbols) { return names.concat(Object.getOwnPropertySymbols(events)); } return names; }; /** * Return the listeners registered for a given event. * * @param {(String|Symbol)} event The event name. * @returns {Array} The registered listeners. * @public */ EventEmitter.prototype.listeners = function listeners(event) { var evt = prefix ? prefix + event : event, handlers = this._events[evt]; if (!handlers) return []; if (handlers.fn) return [handlers.fn]; for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) { ee[i] = handlers[i].fn; } return ee; }; /** * Return the number of listeners listening to a given event. * * @param {(String|Symbol)} event The event name. * @returns {Number} The number of listeners. * @public */ EventEmitter.prototype.listenerCount = function listenerCount(event) { var evt = prefix ? prefix + event : event, listeners = this._events[evt]; if (!listeners) return 0; if (listeners.fn) return 1; return listeners.length; }; /** * Calls each of the listeners registered for a given event. * * @param {(String|Symbol)} event The event name. * @returns {Boolean} `true` if the event had listeners, else `false`. * @public */ EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return false; var listeners = this._events[evt], len = arguments.length, args, i; if (listeners.fn) { if (listeners.once) this.removeListener(event, listeners.fn, undefined, true); switch (len) { case 1: return listeners.fn.call(listeners.context), true; case 2: return listeners.fn.call(listeners.context, a1), true; case 3: return listeners.fn.call(listeners.context, a1, a2), true; case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true; case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true; case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true; } for (i = 1, args = new Array(len - 1); i < len; i++) { args[i - 1] = arguments[i]; } listeners.fn.apply(listeners.context, args); } else { var length = listeners.length, j; for (i = 0; i < length; i++) { if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true); switch (len) { case 1: listeners[i].fn.call(listeners[i].context); break; case 2: listeners[i].fn.call(listeners[i].context, a1); break; case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break; case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break; default: if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) { args[j - 1] = arguments[j]; } listeners[i].fn.apply(listeners[i].context, args); } } } return true; }; /** * Add a listener for a given event. * * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} [context=this] The context to invoke the listener with. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.on = function on(event, fn, context) { return addListener(this, event, fn, context, false); }; /** * Add a one-time listener for a given event. * * @param {(String|Symbol)} event The event name. * @param {Function} fn The listener function. * @param {*} [context=this] The context to invoke the listener with. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.once = function once(event, fn, context) { return addListener(this, event, fn, context, true); }; /** * Remove the listeners of a given event. * * @param {(String|Symbol)} event The event name. * @param {Function} fn Only remove the listeners that match this function. * @param {*} context Only remove the listeners that have this context. * @param {Boolean} once Only remove one-time listeners. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) { var evt = prefix ? prefix + event : event; if (!this._events[evt]) return this; if (!fn) { clearEvent(this, evt); return this; } var listeners = this._events[evt]; if (listeners.fn) { if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) { clearEvent(this, evt); } } else { for (var i = 0, events = [], length = listeners.length; i < length; i++) { if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) { events.push(listeners[i]); } } // // Reset the array, or remove it completely if we have no more listeners. // if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;else clearEvent(this, evt); } return this; }; /** * Remove all listeners, or those of the specified event. * * @param {(String|Symbol)} [event] The event name. * @returns {EventEmitter} `this`. * @public */ EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) { var evt; if (event) { evt = prefix ? prefix + event : event; if (this._events[evt]) clearEvent(this, evt); } else { this._events = new Events(); this._eventsCount = 0; } return this; }; // // Alias methods names because people roll like that. // EventEmitter.prototype.off = EventEmitter.prototype.removeListener; EventEmitter.prototype.addListener = EventEmitter.prototype.on; // // Expose the prefix. // EventEmitter.prefixed = prefix; // // Allow `EventEmitter` to be imported as module namespace. // EventEmitter.EventEmitter = EventEmitter; // // Expose the module. // { module.exports = EventEmitter; } })(eventemitter3); var eventemitter3Exports = eventemitter3.exports; var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports); const isType = (value, type) => Object.prototype.toString.call(value) === `[object ${type}]`; var isType$1 = isType; const isBoolean = (value, fuzzy = !1) => fuzzy ? "boolean" == typeof value : !0 === value || !1 === value || isType$1(value, "Boolean"); var isBoolean$1 = isBoolean; const isFunction = value => "function" == typeof value; var isFunction$1 = isFunction; const isNil = value => null == value; var isNil$1 = isNil; const isValid = value => null != value; var isValid$1 = isValid; const isObject = value => { const type = typeof value; return null !== value && "object" === type || "function" === type; }; var isObject$1 = isObject; const isObjectLike = value => "object" == typeof value && null !== value; var isObjectLike$1 = isObjectLike; const isPlainObject = function (value) { if (!isObjectLike$1(value) || !isType$1(value, "Object")) return !1; if (null === Object.getPrototypeOf(value)) return !0; let proto = value; for (; null !== Object.getPrototypeOf(proto);) proto = Object.getPrototypeOf(proto); return Object.getPrototypeOf(value) === proto; }; var isPlainObject$1 = isPlainObject; const isString = (value, fuzzy = !1) => { const type = typeof value; return fuzzy ? "string" === type : "string" === type || isType$1(value, "String"); }; var isString$1 = isString; const isArray = value => Array.isArray ? Array.isArray(value) : isType$1(value, "Array"); var isArray$1 = isArray; const isArrayLike = function (value) { return null !== value && "function" != typeof value && Number.isFinite(value.length); }; var isArrayLike$1 = isArrayLike; const isNumber = (value, fuzzy = !1) => { const type = typeof value; return fuzzy ? "number" === type : "number" === type || isType$1(value, "Number"); }; var isNumber$1 = isNumber; const isValidNumber = value => isNumber$1(value) && Number.isFinite(value); var isValidNumber$1 = isValidNumber; const isValidUrl = value => new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(value); var isValidUrl$1 = isValidUrl; const isBase64 = value => new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(value); var isBase64$1 = isBase64; const getType = value => ({}).toString.call(value).replace(/^\[object /, "").replace(/]$/, ""); var getType$1 = getType; const objectProto = Object.prototype, isPrototype = function (value) { const Ctor = value && value.constructor; return value === ("function" == typeof Ctor && Ctor.prototype || objectProto); }; var isPrototype$1 = isPrototype; const hasOwnProperty = Object.prototype.hasOwnProperty; function isEmpty(value) { if (isNil$1(value)) return !0; if (isArrayLike$1(value)) return !value.length; const type = getType$1(value); if ("Map" === type || "Set" === type) return !value.size; if (isPrototype$1(value)) return !Object.keys(value).length; for (const key in value) if (hasOwnProperty.call(value, key)) return !1; return !0; } function baseMerge(target, source, shallowArray = !1, skipTargetArray = !1) { if (source) { if (target === source) return; if (isValid$1(source) && "object" == typeof source) { const iterable = Object(source), props = []; for (const key in iterable) props.push(key); let { length: length } = props, propIndex = -1; for (; length--;) { const key = props[++propIndex]; !isValid$1(iterable[key]) || "object" != typeof iterable[key] || skipTargetArray && isArray$1(target[key]) ? assignMergeValue(target, key, iterable[key]) : baseMergeDeep(target, source, key, shallowArray, skipTargetArray); } } } } function baseMergeDeep(target, source, key, shallowArray = !1, skipTargetArray = !1) { const objValue = target[key], srcValue = source[key]; let newValue = source[key], isCommon = !0; if (isArray$1(srcValue)) { if (shallowArray) newValue = [];else if (isArray$1(objValue)) newValue = objValue;else if (isArrayLike$1(objValue)) { newValue = new Array(objValue.length); let index = -1; const length = objValue.length; for (; ++index < length;) newValue[index] = objValue[index]; } } else isPlainObject$1(srcValue) ? (newValue = null != objValue ? objValue : {}, "function" != typeof objValue && "object" == typeof objValue || (newValue = {})) : isCommon = !1; isCommon && baseMerge(newValue, srcValue, shallowArray, skipTargetArray), assignMergeValue(target, key, newValue); } function assignMergeValue(target, key, value) { (void 0 !== value && !eq(target[key], value) || void 0 === value && !(key in target)) && (target[key] = value); } function eq(value, other) { return value === other || Number.isNaN(value) && Number.isNaN(other); } function merge(target, ...sources) { let sourceIndex = -1; const length = sources.length; for (; ++sourceIndex < length;) { baseMerge(target, sources[sourceIndex], !0); } return target; } function pickWithout(obj, keys) { if (!obj || !isPlainObject$1(obj)) return obj; const result = {}; return Object.keys(obj).forEach(k => { const v = obj[k]; let match = !1; keys.forEach(itKey => { (isString$1(itKey) && itKey === k || itKey instanceof RegExp && k.match(itKey)) && (match = !0); }), match || (result[k] = v); }), result; } function objToString(obj) { return Object.prototype.toString.call(obj); } function objectKeys(obj) { return Object.keys(obj); } function isEqual(a, b, options) { if (a === b) return !0; if (typeof a != typeof b) return !1; if (null == a || null == b) return !1; if (Number.isNaN(a) && Number.isNaN(b)) return !0; if (objToString(a) !== objToString(b)) return !1; if (isFunction$1(a)) return !!(null == options ? void 0 : options.skipFunction); if ("object" != typeof a) return !1; if (isArray$1(a)) { if (a.length !== b.length) return !1; for (let i = a.length - 1; i >= 0; i--) if (!isEqual(a[i], b[i], options)) return !1; return !0; } if (!isPlainObject$1(a)) return !1; const ka = objectKeys(a), kb = objectKeys(b); if (ka.length !== kb.length) return !1; ka.sort(), kb.sort(); for (let i = ka.length - 1; i >= 0; i--) if (ka[i] != kb[i]) return !1; for (let i = ka.length - 1; i >= 0; i--) { const key = ka[i]; if (!isEqual(a[key], b[key], options)) return !1; } return !0; } function array(arr) { return isValid$1(arr) ? isArray$1(arr) ? arr : [arr] : []; } function arrayEqual(a, b) { if (!isArray$1(a) || !isArray$1(b)) return !1; if (a.length !== b.length) return !1; for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return !1; return !0; } const hasConsole = "undefined" != typeof console; function log(method, level, input) { const args = [level].concat([].slice.call(input)); hasConsole && console[method].apply(console, args); } var LoggerLevel; !function (LoggerLevel) { LoggerLevel[LoggerLevel.None = 0] = "None", LoggerLevel[LoggerLevel.Error = 1] = "Error", LoggerLevel[LoggerLevel.Warn = 2] = "Warn", LoggerLevel[LoggerLevel.Info = 3] = "Info", LoggerLevel[LoggerLevel.Debug = 4] = "Debug"; }(LoggerLevel || (LoggerLevel = {})); class Logger { static getInstance(level, method) { return Logger._instance && isNumber$1(level) ? Logger._instance.level(level) : Logger._instance || (Logger._instance = new Logger(level, method)), Logger._instance; } static setInstance(logger) { return Logger._instance = logger; } static setInstanceLevel(level) { Logger._instance ? Logger._instance.level(level) : Logger._instance = new Logger(level); } static clearInstance() { Logger._instance = null; } constructor(level = LoggerLevel.None, method) { this._onErrorHandler = [], this._level = level, this._method = method; } addErrorHandler(handler) { this._onErrorHandler.find(h => h === handler) || this._onErrorHandler.push(handler); } removeErrorHandler(handler) { const index = this._onErrorHandler.findIndex(h => h === handler); index < 0 || this._onErrorHandler.splice(index, 1); } callErrorHandler(...args) { this._onErrorHandler.forEach(h => h(...args)); } canLogInfo() { return this._level >= LoggerLevel.Info; } canLogDebug() { return this._level >= LoggerLevel.Debug; } canLogError() { return this._level >= LoggerLevel.Error; } canLogWarn() { return this._level >= LoggerLevel.Warn; } level(levelValue) { return arguments.length ? (this._level = +levelValue, this) : this._level; } error(...args) { var _a; return this._level >= LoggerLevel.Error && (this._onErrorHandler.length ? this.callErrorHandler(...args) : log(null !== (_a = this._method) && void 0 !== _a ? _a : "error", "ERROR", args)), this; } warn(...args) { return this._level >= LoggerLevel.Warn && log(this._method || "warn", "WARN", args), this; } info(...args) { return this._level >= LoggerLevel.Info && log(this._method || "log", "INFO", args), this; } debug(...args) { return this._level >= LoggerLevel.Debug && log(this._method || "log", "DEBUG", args), this; } } Logger._instance = null; const epsilon = 1e-12; const pi = Math.PI; const halfPi$1 = pi / 2; const tau = 2 * pi; const pi2 = 2 * Math.PI; const abs = Math.abs; const atan2 = Math.atan2; const cos = Math.cos; const max = Math.max; const min = Math.min; const sin = Math.sin; const sqrt = Math.sqrt; const pow = Math.pow; function asin(x) { return x >= 1 ? halfPi$1 : x <= -1 ? -halfPi$1 : Math.asin(x); } class Point { constructor(x = 0, y = 0, x1, y1) { this.x = 0, this.y = 0, this.x = x, this.y = y, this.x1 = x1, this.y1 = y1; } clone() { return new Point(this.x, this.y); } copyFrom(p) { return this.x = p.x, this.y = p.y, this.x1 = p.x1, this.y1 = p.y1, this.defined = p.defined, this.context = p.context, this; } set(x, y) { return this.x = x, this.y = y, this; } add(point) { return isNumber$1(point) ? (this.x += point, void (this.y += point)) : (this.x += point.x, this.y += point.y, this); } sub(point) { return isNumber$1(point) ? (this.x -= point, void (this.y -= point)) : (this.x -= point.x, this.y -= point.y, this); } multi(point) { throw new Error("暂不支持"); } div(point) { throw new Error("暂不支持"); } } class PointService { static distancePP(p1, p2) { return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)); } static distanceNN(x, y, x1, y1) { return sqrt(pow(x - x1, 2) + pow(y - y1, 2)); } static distancePN(point, x, y) { return sqrt(pow(x - point.x, 2) + pow(y - point.y, 2)); } static pointAtPP(p1, p2, t) { return new Point((p2.x - p1.x) * t + p1.x, (p2.y - p1.y) * t + p1.y); } } function degreeToRadian(degree) { return degree * (Math.PI / 180); } function radianToDegree(radian) { return 180 * radian / Math.PI; } const clampRadian = (angle = 0) => { if (angle < 0) for (; angle < -tau;) angle += tau;else if (angle > 0) for (; angle > tau;) angle -= tau; return angle; }; const clampAngleByRadian = clampRadian; var InnerBBox; !function (InnerBBox) { InnerBBox[InnerBBox.NONE = 0] = "NONE", InnerBBox[InnerBBox.BBOX1 = 1] = "BBOX1", InnerBBox[InnerBBox.BBOX2 = 2] = "BBOX2"; }(InnerBBox || (InnerBBox = {})); function getProjectionRadius(checkAxis, axis) { return Math.abs(axis[0] * checkAxis[0] + axis[1] * checkAxis[1]); } function rotatePoint({ x: x, y: y }, rad, origin = { x: 0, y: 0 }) { return { x: (x - origin.x) * Math.cos(rad) - (y - origin.y) * Math.sin(rad) + origin.x, y: (x - origin.x) * Math.sin(rad) + (y - origin.y) * Math.cos(rad) + origin.y }; } function getCenterPoint(box) { return { x: (box.x1 + box.x2) / 2, y: (box.y1 + box.y2) / 2 }; } function toRect(box, isDeg) { const deg = isDeg ? degreeToRadian(box.angle) : box.angle, cp = getCenterPoint(box); return [rotatePoint({ x: box.x1, y: box.y1 }, deg, cp), rotatePoint({ x: box.x2, y: box.y1 }, deg, cp), rotatePoint({ x: box.x2, y: box.y2 }, deg, cp), rotatePoint({ x: box.x1, y: box.y2 }, deg, cp)]; } function isRotateAABBIntersect(box1, box2, isDeg = !1) { const rect1 = toRect(box1, isDeg), rect2 = toRect(box2, isDeg), vector = (start, end) => [end.x - start.x, end.y - start.y], vp1p2 = vector(getCenterPoint(box1), getCenterPoint(box2)), AB = vector(rect1[0], rect1[1]), BC = vector(rect1[1], rect1[2]), A1B1 = vector(rect2[0], rect2[1]), B1C1 = vector(rect2[1], rect2[2]), deg11 = isDeg ? degreeToRadian(box1.angle) : box1.angle; let deg12 = isDeg ? degreeToRadian(90 - box1.angle) : box1.angle + halfPi$1; const deg21 = isDeg ? degreeToRadian(box2.angle) : box2.angle; let deg22 = isDeg ? degreeToRadian(90 - box2.angle) : box2.angle + halfPi$1; deg12 > pi2 && (deg12 -= pi2), deg22 > pi2 && (deg22 -= pi2); const isCover = (checkAxisRadius, deg, targetAxis1, targetAxis2) => { const checkAxis = [Math.cos(deg), Math.sin(deg)]; return checkAxisRadius + (getProjectionRadius(checkAxis, targetAxis1) + getProjectionRadius(checkAxis, targetAxis2)) / 2 > getProjectionRadius(checkAxis, vp1p2); }; return isCover((box1.x2 - box1.x1) / 2, deg11, A1B1, B1C1) && isCover((box1.y2 - box1.y1) / 2, deg12, A1B1, B1C1) && isCover((box2.x2 - box2.x1) / 2, deg21, AB, BC) && isCover((box2.y2 - box2.y1) / 2, deg22, AB, BC); } function isPointInLine(x0, y0, x1, y1, x, y) { if (y > y0 && y > y1 || y < y0 && y < y1) return 0; if (y1 === y0) return 0; const t = (y - y0) / (y1 - y0); let dir = y1 < y0 ? 1 : -1; 1 !== t && 0 !== t || (dir = y1 < y0 ? .5 : -.5); const x_ = t * (x1 - x0) + x0; return x_ === x ? 1 / 0 : x_ > x ? dir : 0; } function getContextFont(text, defaultAttr = {}, fontSizeScale) { fontSizeScale || (fontSizeScale = 1); const { fontStyle = defaultAttr.fontStyle, fontVariant = defaultAttr.fontVariant, fontWeight = defaultAttr.fontWeight, fontSize = defaultAttr.fontSize, fontFamily = defaultAttr.fontFamily } = text; return (fontStyle ? fontStyle + " " : "") + (fontVariant ? fontVariant + " " : "") + (fontWeight ? fontWeight + " " : "") + fontSize * fontSizeScale + "px " + (fontFamily || "sans-serif"); } const calculateAnchorOfBounds = (bounds, anchorType) => { const { x1: x1, x2: x2, y1: y1, y2: y2 } = bounds, rectWidth = Math.abs(x2 - x1), rectHeight = Math.abs(y2 - y1); let anchorX = (x1 + x2) / 2, anchorY = (y1 + y2) / 2, sx = 0, sy = 0; switch (anchorType) { case "top": case "inside-top": sy = -.5; break; case "bottom": case "inside-bottom": sy = .5; break; case "left": case "inside-left": sx = -.5; break; case "right": case "inside-right": sx = .5; break; case "top-right": sx = .5, sy = -.5; break; case "top-left": sx = -.5, sy = -.5; break; case "bottom-right": sx = .5, sy = .5; break; case "bottom-left": sx = -.5, sy = .5; } return anchorX += sx * rectWidth, anchorY += sy * rectHeight, { x: anchorX, y: anchorY }; }; function transformBoundsWithMatrix(out, bounds, matrix) { const { x1: x1, y1: y1, x2: x2, y2: y2 } = bounds; return matrix.onlyTranslate() ? (out !== bounds && out.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2), out.translate(matrix.e, matrix.f), bounds) : (out.clear(), out.add(matrix.a * x1 + matrix.c * y1 + matrix.e, matrix.b * x1 + matrix.d * y1 + matrix.f), out.add(matrix.a * x2 + matrix.c * y1 + matrix.e, matrix.b * x2 + matrix.d * y1 + matrix.f), out.add(matrix.a * x2 + matrix.c * y2 + matrix.e, matrix.b * x2 + matrix.d * y2 + matrix.f), out.add(matrix.a * x1 + matrix.c * y2 + matrix.e, matrix.b * x1 + matrix.d * y2 + matrix.f), bounds); } class Bounds { constructor(bounds) { bounds ? this.setValue(bounds.x1, bounds.y1, bounds.x2, bounds.y2) : this.clear(); } clone() { return new Bounds(this); } clear() { return this.x1 = +Number.MAX_VALUE, this.y1 = +Number.MAX_VALUE, this.x2 = -Number.MAX_VALUE, this.y2 = -Number.MAX_VALUE, this; } empty() { return this.x1 === +Number.MAX_VALUE && this.y1 === +Number.MAX_VALUE && this.x2 === -Number.MAX_VALUE && this.y2 === -Number.MAX_VALUE; } equals(b) { return this.x1 === b.x1 && this.y1 === b.y1 && this.x2 === b.x2 && this.y2 === b.y2; } setValue(x1 = 0, y1 = 0, x2 = 0, y2 = 0) { return this.x1 = x1, this.y1 = y1, this.x2 = x2, this.y2 = y2, this; } set(x1 = 0, y1 = 0, x2 = 0, y2 = 0) { return x2 < x1 ? (this.x2 = x1, this.x1 = x2) : (this.x1 = x1, this.x2 = x2), y2 < y1 ? (this.y2 = y1, this.y1 = y2) : (this.y1 = y1, this.y2 = y2), this; } add(x = 0, y = 0) { return x < this.x1 && (this.x1 = x), y < this.y1 && (this.y1 = y), x > this.x2 && (this.x2 = x), y > this.y2 && (this.y2 = y), this; } expand(d = 0) { return isArray$1(d) ? (this.y1 -= d[0], this.x2 += d[1], this.y2 += d[2], this.x1 -= d[3]) : (this.x1 -= d, this.y1 -= d, this.x2 += d, this.y2 += d), this; } round() { return this.x1 = Math.floor(this.x1), this.y1 = Math.floor(this.y1), this.x2 = Math.ceil(this.x2), this.y2 = Math.ceil(this.y2), this; } translate(dx = 0, dy = 0) { return this.x1 += dx, this.x2 += dx, this.y1 += dy, this.y2 += dy, this; } rotate(angle = 0, x = 0, y = 0) { const p = this.rotatedPoints(angle, x, y); return this.clear().add(p[0], p[1]).add(p[2], p[3]).add(p[4], p[5]).add(p[6], p[7]); } scale(sx = 0, sy = 0, x = 0, y = 0) { const p = this.scalePoints(sx, sy, x, y); return this.clear().add(p[0], p[1]).add(p[2], p[3]); } union(b) { return b.x1 < this.x1 && (this.x1 = b.x1), b.y1 < this.y1 && (this.y1 = b.y1), b.x2 > this.x2 && (this.x2 = b.x2), b.y2 > this.y2 && (this.y2 = b.y2), this; } intersect(b) { return b.x1 > this.x1 && (this.x1 = b.x1), b.y1 > this.y1 && (this.y1 = b.y1), b.x2 < this.x2 && (this.x2 = b.x2), b.y2 < this.y2 && (this.y2 = b.y2), this; } encloses(b) { return b && this.x1 <= b.x1 && this.x2 >= b.x2 && this.y1 <= b.y1 && this.y2 >= b.y2; } alignsWith(b) { return b && (this.x1 === b.x1 || this.x2 === b.x2 || this.y1 === b.y1 || this.y2 === b.y2); } intersects(b) { return b && !(this.x2 < b.x1 || this.x1 > b.x2 || this.y2 < b.y1 || this.y1 > b.y2); } contains(x = 0, y = 0) { return !(x < this.x1 || x > this.x2 || y < this.y1 || y > this.y2); } containsPoint(p) { return !(p.x < this.x1 || p.x > this.x2 || p.y < this.y1 || p.y > this.y2); } width() { return this.empty() ? 0 : this.x2 - this.x1; } height() { return this.empty() ? 0 : this.y2 - this.y1; } scaleX(s = 0) { return this.x1 *= s, this.x2 *= s, this; } scaleY(s = 0) { return this.y1 *= s, this.y2 *= s, this; } transformWithMatrix(matrix) { return transformBoundsWithMatrix(this, this, matrix), this; } copy(b) { return this.x1 = b.x1, this.y1 = b.y1, this.x2 = b.x2, this.y2 = b.y2, this; } rotatedPoints(angle, x, y) { const { x1: x1, y1: y1, x2: x2, y2: y2 } = this, cos = Math.cos(angle), sin = Math.sin(angle), cx = x - x * cos + y * sin, cy = y - x * sin - y * cos; return [cos * x1 - sin * y1 + cx, sin * x1 + cos * y1 + cy, cos * x1 - sin * y2 + cx, sin * x1 + cos * y2 + cy, cos * x2 - sin * y1 + cx, sin * x2 + cos * y1 + cy, cos * x2 - sin * y2 + cx, sin * x2 + cos * y2 + cy]; } scalePoints(sx, sy, x, y) { const { x1: x1, y1: y1, x2: x2, y2: y2 } = this; return [sx * x1 + (1 - sx) * x, sy * y1 + (1 - sy) * y, sx * x2 + (1 - sx) * x, sy * y2 + (1 - sy) * y]; } } class AABBBounds extends Bounds {} class OBBBounds extends Bounds { constructor(bounds, angle = 0) { var _a; super(bounds), bounds && (this.angle = null !== (_a = bounds.angle) && void 0 !== _a ? _a : angle); } intersects(b) { return isRotateAABBIntersect(this, b); } setValue(x1 = 0, y1 = 0, x2 = 0, y2 = 0, angle = 0) { return super.setValue(x1, y1, x2, y2), this.angle = angle, this; } clone() { return new OBBBounds(this); } getRotatedCorners() { const originPoint = { x: (this.x1 + this.x2) / 2, y: (this.y1 + this.y2) / 2 }; return [rotatePoint({ x: this.x1, y: this.y1 }, this.angle, originPoint), rotatePoint({ x: this.x2, y: this.y1 }, this.angle, originPoint), rotatePoint({ x: this.x1, y: this.y2 }, this.angle, originPoint), rotatePoint({ x: this.x2, y: this.y2 }, this.angle, originPoint)]; } } class Matrix { constructor(a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) { this.a = a, this.b = b, this.c = c, this.d = d, this.e = e, this.f = f; } equalToMatrix(m2) { return !(this.e !== m2.e || this.f !== m2.f || this.a !== m2.a || this.d !== m2.d || this.b !== m2.b || this.c !== m2.c); } equalTo(a, b, c, d, e, f) { return !(this.e !== e || this.f !== f || this.a !== a || this.d !== d || this.b !== b || this.c !== c); } setValue(a, b, c, d, e, f) { return this.a = a, this.b = b, this.c = c, this.d = d, this.e = e, this.f = f, this; } reset() { return this.a = 1, this.b = 0, this.c = 0, this.d = 1, this.e = 0, this.f = 0, this; } getInverse() { const a = this.a, b = this.b, c = this.c, d = this.d, e = this.e, f = this.f, m = new Matrix(), dt = a * d - b * c; return m.a = d / dt, m.b = -b / dt, m.c = -c / dt, m.d = a / dt, m.e = (c * f - d * e) / dt, m.f = -(a * f - b * e) / dt, m; } rotate(rad) { const c = Math.cos(rad), s = Math.sin(rad), m11 = this.a * c + this.c * s, m12 = this.b * c + this.d * s, m21 = this.a * -s + this.c * c, m22 = this.b * -s + this.d * c; return this.a = m11, this.b = m12, this.c = m21, this.d = m22, this; } rotateByCenter(rad, cx, cy) { const cos = Math.cos(rad), sin = Math.sin(rad), rotateM13 = (1 - cos) * cx + sin * cy, rotateM23 = (1 - cos) * cy - sin * cx, m11 = cos * this.a - sin * this.b, m21 = sin * this.a + cos * this.b, m12 = cos * this.c - sin * this.d, m22 = sin * this.c + cos * this.d, m13 = cos * this.e - sin * this.f + rotateM13, m23 = sin * this.e + cos * this.f + rotateM23; return this.a = m11, this.b = m21, this.c = m12, this.d = m22, this.e = m13, this.f = m23, this; } scale(sx, sy) { return this.a *= sx, this.b *= sx, this.c *= sy, this.d *= sy, this; } setScale(sx, sy) { return this.b = this.b / this.a * sx, this.c = this.c / this.d * sy, this.a = sx, this.d = sy, this; } transform(a, b, c, d, e, f) { return this.multiply(a, b, c, d, e, f), this; } translate(x, y) { return this.e += this.a * x + this.c * y, this.f += this.b * x + this.d * y, this; } transpose() { const { a: a, b: b, c: c, d: d, e: e, f: f } = this; return this.a = b, this.b = a, this.c = d, this.d = c, this.e = f, this.f = e, this; } multiply(a2, b2, c2, d2, e2, f2) { const a1 = this.a, b1 = this.b, c1 = this.c, d1 = this.d, m11 = a1 * a2 + c1 * b2, m12 = b1 * a2 + d1 * b2, m21 = a1 * c2 + c1 * d2, m22 = b1 * c2 + d1 * d2, dx = a1 * e2 + c1 * f2 + this.e, dy = b1 * e2 + d1 * f2 + this.f; return this.a = m11, this.b = m12, this.c = m21, this.d = m22, this.e = dx, this.f = dy, this; } interpolate(m2, t) { const m = new Matrix(); return m.a = this.a + (m2.a - this.a) * t, m.b = this.b + (m2.b - this.b) * t, m.c = this.c + (m2.c - this.c) * t, m.d = this.d + (m2.d - this.d) * t, m.e = this.e + (m2.e - this.e) * t, m.f = this.f + (m2.f - this.f) * t, m; } transformPoint(source, target) { const { a: a, b: b, c: c, d: d, e: e, f: f } = this, dt = a * d - b * c, nextA = d / dt, nextB = -b / dt, nextC = -c / dt, nextD = a / dt, nextE = (c * f - d * e) / dt, nextF = -(a * f - b * e) / dt, { x: x, y: y } = source; target.x = x * nextA + y * nextC + nextE, target.y = x * nextB + y * nextD + nextF; } onlyTranslate(scale = 1) { return this.a === scale && 0 === this.b && 0 === this.c && this.d === scale; } clone() { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); } toTransformAttrs() { const a = this.a, b = this.b, c = this.c, d = this.d, delta = a * d - b * c, result = { x: this.e, y: this.f, rotateDeg: 0, scaleX: 0, scaleY: 0, skewX: 0, skewY: 0 }; if (0 !== a || 0 !== b) { const r = Math.sqrt(a * a + b * b); result.rotateDeg = b > 0 ? Math.acos(a / r) : -Math.acos(a / r), result.scaleX = r, result.scaleY = delta / r, result.skewX = (a * c + b * d) / delta, result.skewY = 0; } else if (0 !== c || 0 !== d) { const s = Math.sqrt(c * c + d * d); result.rotateDeg = Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s)), result.scaleX = delta / s, result.scaleY = s, result.skewX = 0, result.skewY = (a * c + b * d) / delta; } return result.rotateDeg = radianToDegree(result.rotateDeg), result; } } function normalTransform(out, origin, x, y, scaleX, scaleY, angle, rotateCenter) { const oa = origin.a, ob = origin.b, oc = origin.c, od = origin.d, oe = origin.e, of = origin.f, cosTheta = cos(angle), sinTheta = sin(angle); let rotateCenterX, rotateCenterY; rotateCenter ? (rotateCenterX = rotateCenter[0], rotateCenterY = rotateCenter[1]) : (rotateCenterX = x, rotateCenterY = y); const offsetX = rotateCenterX - x, offsetY = rotateCenterY - y, a1 = oa * cosTheta + oc * sinTheta, b1 = ob * cosTheta + od * sinTheta, c1 = oc * cosTheta - oa * sinTheta, d1 = od * cosTheta - ob * sinTheta; out.a = scaleX * a1, out.b = scaleX * b1, out.c = scaleY * c1, out.d = scaleY * d1, out.e = oe + oa * rotateCenterX + oc * rotateCenterY - a1 * offsetX - c1 * offsetY, out.f = of + ob * rotateCenterX + od * rotateCenterY - b1 * offsetX - d1 * offsetY; } function normalizePadding(padding) { if (isValidNumber$1(padding)) return [padding, padding, padding, padding]; if (isArray$1(padding)) { const length = padding.length; if (1 === length) { const paddingValue = padding[0]; return [paddingValue, paddingValue, paddingValue, paddingValue]; } if (2 === length) { const [vertical, horizontal] = padding; return [vertical, horizontal, vertical, horizontal]; } if (3 === length) { const [top, horizontal, bottom] = padding; return [top, horizontal, bottom, horizontal]; } if (4 === length) return padding; } if (isObject$1(padding)) { const { top = 0, right = 0, bottom = 0, left = 0 } = padding; return [top, right, bottom, left]; } return [0, 0, 0, 0]; } const styleStringToObject = (styleStr = "") => { const res = {}; return styleStr.split(";").forEach(item => { if (item) { const arr = item.split(":"); if (2 === arr.length) { const key = arr[0].trim(), value = arr[1].trim(); key && value && (res[key] = value); } } }), res; }; const lowerCamelCaseToMiddle = str => str.replace(/([A-Z])/g, "-$1").toLowerCase(); var reactIs = {exports: {}}; var reactIs_production_min = {}; /** * @license React * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var hasRequiredReactIs_production_min; function requireReactIs_production_min() { if (hasRequiredReactIs_production_min) return reactIs_production_min; hasRequiredReactIs_production_min = 1; var b = Symbol.for("react.element"), c = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), e = Symbol.for("react.strict_mode"), f = Symbol.for("react.profiler"), g = Symbol.for("react.provider"), h = Symbol.for("react.context"), k = Symbol.for("react.server_context"), l = Symbol.for("react.forward_ref"), m = Symbol.for("react.suspense"), n = Symbol.for("react.suspense_list"), p = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), t = Symbol.for("react.offscreen"), u; u = Symbol.for("react.module.reference"); function v(a) { if ("object" === typeof a && null !== a) { var r = a.$$typeof; switch (r) { case b: switch (a = a.type, a) { case d: case f: case e: case m: case n: return a; default: switch (a = a && a.$$typeof, a) { case k: case h: case l: case q: case p: case g: return a; default: return r; } } case c: return r; } } } reactIs_production_min.ContextConsumer = h; reactIs_production_min.ContextProvider = g; reactIs_production_min.Element = b; reactIs_production_min.ForwardRef = l; reactIs_production_min.Fragment = d; reactIs_production_min.Lazy = q; reactIs_production_min.Memo = p; reactIs_production_min.Portal = c; reactIs_production_min.Profiler = f; reactIs_production_min.StrictMode = e; reactIs_production_min.Suspense = m; reactIs_production_min.SuspenseList = n; reactIs_production_min.isAsyncMode = function () { return !1; }; reactIs_production_min.isConcurrentMode = function () { return !1; }; reactIs_production_min.isContextConsumer = function (a) { return v(a) === h; }; reactIs_production_min.isContextProvider = function (a) { return v(a) === g; }; reactIs_production_min.isElement = function (a) { return "object" === typeof a && null !== a && a.$$typeof === b; }; reactIs_production_min.isForwardRef = function (a) { return v(a) === l; }; reactIs_production_min.isFragment = function (a) { return v(a) === d; }; reactIs_production_min.isLazy = function (a) { return v(a) === q; }; reactIs_production_min.isMemo = function (a) { return v(a) === p; }; reactIs_production_min.isPortal = function (a) { return v(a) === c; }; reactIs_production_min.isProfiler = function (a) { return v(a) === f; }; reactIs_production_min.isStrictMode = function (a) { return v(a) === e; }; reactIs_production_min.isSuspense = function (a) { return v(a) === m; }; reactIs_production_min.isSuspenseList = function (a) { return v(a) === n; }; reactIs_production_min.isValidElementType = function (a) { return "string" === typeof a || "function" === typeof a || a === d || a === f || a === e || a === m || a === n || a === t || "object" === typeof a && null !== a && (a.$$typeof === q || a.$$typeof === p || a.$$typeof === g || a.$$typeof === h || a.$$typeof === l || a.$$typeof === u || void 0 !== a.getModuleId) ? !0 : !1; }; reactIs_production_min.typeOf = v; return reactIs_production_min; } { reactIs.exports = requireReactIs_production_min(); } var reactIsExports = reactIs.exports; const toArray = (children) => { let result = []; React.Children.forEach(children, child => { if (isNil$1(child)) { return; } if (reactIsExports.isFragment(child)) { result = result.concat(toArray(child.props.children)); } else { result.push(child); } }); return result; }; const REACT_PRIVATE_PROPS = ['children', 'hooks', 'ref']; const EVENT_TYPE = { ...vtable.TABLE_EVENT_TYPE, ...vtable.PIVOT_TABLE_EVENT_TYPE, ...vtable.PIVOT_CHART_EVENT_TYPE }; const TABLE_EVENTS = { onClickCell: EVENT_TYPE.CLICK_CELL, onDblClickCell: EVENT_TYPE.DBLCLICK_CELL, onMouseDownCell: EVENT_TYPE.MOUSEDOWN_CELL, onMouseUpCell: EVENT_TYPE.MOUSEUP_CELL, onSelectedCell: EVENT_TYPE.SELECTED_CELL, onSelectedClear: EVENT_TYPE.SELECTED_CLEAR, onKeyDown: EVENT_TYPE.KEYDOWN, onMouseEnterTable: EVENT_TYPE.MOUSEENTER_TABLE, onMouseLeaveTable: EVENT_TYPE.MOUSELEAVE_TABLE, onMouseDownTable: EVENT_TYPE.MOUSEDOWN_TABLE, onMouseMoveCell: EVENT_TYPE.MOUSEMOVE_CELL, onMouseMoveTable: EVENT_TYPE.MOUSEMOVE_TABLE, onMouseEnterCell: EVENT_TYPE.MOUSEENTER_CELL, onMouseLeaveCell: EVENT_TYPE.MOUSELEAVE_CELL, onContextMenuCell: EVENT_TYPE.CONTEXTMENU_CELL, onContextMenuCanvas: EVENT_TYPE.CONTEXTMENU_CANVAS, onResizeColumn: EVENT_TYPE.RESIZE_COLUMN, onResizeColumnEnd: EVENT_TYPE.RESIZE_COLUMN_END, onResizeRow: EVENT_TYPE.RESIZE_ROW, onResizeRowEnd: EVENT_TYPE.RESIZE_ROW_END, onChangeHeaderPositionStart: EVENT_TYPE.CHANGE_HEADER_POSITION_START, onChangeHeaderPosition: EVENT_TYPE.CHANGE_HEADER_POSITION, onChangeHeaderPositionFail: EVENT_TYPE.CHANGE_HEADER_POSITION_FAIL, onSortClick: EVENT_TYPE.SORT_CLICK, onAfterSort: EVENT_TYPE.AFTER_SORT, onFreezeClick: EVENT_TYPE.FREEZE_CLICK, onScr