/* eslint-disable */ import './index.less'; const throttleTime = 1; function _interopDefault(e) { return e && "object" == typeof e && "default" in e ? e. default: e } function __rest(e, t) { var r = {}; for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (r[o] = e[o]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) for (var n = 0, o = Object.getOwnPropertySymbols(e); n < o.length; n++) t.indexOf(o[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[n]) && (r[o[n]] = e[o[n]]); return r } function getRawTag(e) { var t = hasOwnProperty.call(e, symToStringTag), r = e[symToStringTag]; try { e[symToStringTag] = void 0; var o = !0 } catch(e) {} var n = nativeObjectToString.call(e); return o && (t ? e[symToStringTag] = r: delete e[symToStringTag]), n } function objectToString(e) { return nativeObjectToString$1.call(e) } function baseGetTag(e) { return null == e ? void 0 === e ? undefinedTag: nullTag: symToStringTag$1 && symToStringTag$1 in Object(e) ? getRawTag(e) : objectToString(e) } function isObjectLike(e) { return null != e && "object" == typeof e } function isSymbol(e) { return "symbol" == typeof e || isObjectLike(e) && baseGetTag(e) == symbolTag } function trimmedEndIndex(e) { for (var t = e.length; t--&&reWhitespace.test(e.charAt(t));); return t } function baseTrim(e) { return e ? e.slice(0, trimmedEndIndex(e) + 1).replace(reTrimStart, "") : e } function isObject(e) { var t = typeof e; return null != e && ("object" == t || "function" == t) } function toNumber(e) { if ("number" == typeof e) return e; if (isSymbol(e)) return NAN; if (isObject(e)) { var t = "function" == typeof e.valueOf ? e.valueOf() : e; e = isObject(t) ? t + "": t } if ("string" != typeof e) return 0 === e ? e: +e; e = baseTrim(e); var r = reIsBinary.test(e); return r || reIsOctal.test(e) ? freeParseInt(e.slice(2), r ? 2 : 8) : reIsBadHex.test(e) ? NAN: +e } function debounce(e, t, r) { function o(t) { var r = f, o = v; return f = v = void 0, T = t, p = e.apply(o, r) } function n(e) { return T = e, b = setTimeout(a, t), y ? o(e) : p } function i(e) { var r = e - T, o = t - (e - h); return _ ? nativeMin(o, g - r) : o } function l(e) { var r = e - h, o = e - T; return void 0 === h || r >= t || r < 0 || _ && o >= g } function a() { var e = now(); if (l(e)) return c(e); b = setTimeout(a, i(e)) } function c(e) { return b = void 0, m && f ? o(e) : (f = v = void 0, p) } function s() { void 0 !== b && clearTimeout(b), T = 0, f = h = v = b = void 0 } function u() { return void 0 === b ? p: c(now()) } function d() { var e = now(), r = l(e); if (f = arguments, v = this, h = e, r) { if (void 0 === b) return n(h); if (_) return clearTimeout(b), b = setTimeout(a, t), o(h) } return void 0 === b && (b = setTimeout(a, t)), p } var f, v, g, p, b, h, T = 0, y = !1, _ = !1, m = !0; if ("function" != typeof e) throw new TypeError(FUNC_ERROR_TEXT); return t = toNumber(t) || 0, isObject(r) && (y = !!r.leading, g = (_ = "maxWait" in r) ? nativeMax(toNumber(r.maxWait) || 0, t) : g, m = "trailing" in r ? !!r.trailing: m), d.cancel = s, d.flush = u, d } function isNumber(e) { return "number" == typeof e || isObjectLike(e) && baseGetTag(e) == numberTag } function throttle(e, t, r) { var o = !0, n = !0; if ("function" != typeof e) throw new TypeError(FUNC_ERROR_TEXT$1); return isObject(r) && (o = "leading" in r ? !!r.leading: o, n = "trailing" in r ? !!r.trailing: n), debounce(e, t, { leading: o, maxWait: t, trailing: n }) } function styleInject(e, t) { void 0 === t && (t = {}); var r = t.insertAt; if (e && "undefined" != typeof document) { var o = document.head || document.getElementsByTagName("head")[0], n = document.createElement("style"); n.type = "text/css", "top" === r && o.firstChild ? o.insertBefore(n, o.firstChild) : o.appendChild(n), n.styleSheet ? n.styleSheet.cssText = e: n.appendChild(document.createTextNode(e)) } } function reducer(e, t) { switch (t.type) { case "changeTrs": var r = t.curScrollTop, o = t.scrollHeight, n = t.tableScrollY; return e.scrollHeight && r > e.scrollHeight && (r = e.scrollHeight), __assign(__assign({}, e), { curScrollTop: r, scrollHeight: o, tableScrollY: n }); case "initHeight": var i = t.rowHeight; return __assign(__assign({}, e), { rowHeight: i }); case "reset": return __assign(__assign({}, e), { curScrollTop: (null === t || void 0 === t ? void 0 : t.ifScrollTopClear) ? 0 : e.curScrollTop, scrollHeight: 0 }); default: throw new Error } } function VCell(e) { var t = e.children, r = __rest(e, ["children"]); return React__default.createElement("td", __assign({}, r), React__default.createElement("div", null, t)) } function VRow(e, t) { var r = React.useContext(ScrollContext), o = r.dispatch, n = r.rowHeight, i = r.totalLen, l = r.vid, a = e.children, c = e.style, s = __rest(e, ["children", "style"]), u = React.useRef(null); return React.useEffect(function() { ! function(e) { var t, r, a; if ((null === (t = null === e || void 0 === e ? void 0 : e.current) || void 0 === t ? void 0 : t.offsetHeight) && !n && i) { var c = null !== (a = null === (r = null === e || void 0 === e ? void 0 : e.current) || void 0 === r ? void 0 : r.offsetHeight) && void 0 !== a ? a: 0; vidMap.set(l, __assign(__assign({}, vidMap.get(l)), { rowItemHeight: c })), o({ type: "initHeight", rowHeight: c }) } } (t.hasOwnProperty("current") ? t: u) }, [u, o, n, i]), React__default.createElement("tr", __assign({}, s, { ref: t.hasOwnProperty("current") ? t: u, style: __assign(__assign({}, c), { height: n || "auto", boxSizing: "border-box" }) }), a) } function VWrapper(e) { var t = e.children, r = __rest(e, ["children"]), o = React.useContext(ScrollContext), n = o.renderLen, i = o.start, l = (o.offsetStart, t[1]), a = null; return a = Array.isArray(l) && l.length ? [t[0], l.slice(i, i + n).map(function(e) { return Array.isArray(e) ? e[0] : e })] : t, React__default.createElement("tbody", __assign({}, r), a) } function VTable(e, t) { var r, o, n, i, l, a, c = e.style, s = e.children, u = __rest(e, ["style", "children"]), d = c.width, f = __rest(c, ["width"]), v = null !== t && void 0 !== t ? t: {}, g = v.vid, p = v.scrollY, b = v.reachEnd, h = v.onScroll, T = React.useReducer(reducer, initialState), y = T[0], _ = T[1], m = React.useRef(null), S = React.useRef(null), w = React.useState(null !== (i = null === (n = null === (o = null === (r = s[1]) || void 0 === r ? void 0 : r.props) || void 0 === o ? void 0 : o.data) || void 0 === n ? void 0 : n.length) && void 0 !== i ? i: 0), R = w[0], O = w[1]; React.useEffect(function() { return function() { vidMap.delete(g) } }, []), React.useEffect(function() { var e, t, r, o, n, i; isNumber(null === (r = null === (t = null === (e = s[1]) || void 0 === e ? void 0 : e.props) || void 0 === t ? void 0 : t.data) || void 0 === r ? void 0 : r.length) && O(null === (i = null === (n = null === (o = s[1]) || void 0 === o ? void 0 : o.props) || void 0 === n ? void 0 : n.data) || void 0 === i ? void 0 : i.length) }, [s]); var j = React.useMemo(function() { var e = "auto"; return y.rowHeight && R && (e = y.rowHeight * R), e }, [y.rowHeight, R]), H = 0; H = "string" == typeof p ? null === (a = null === (l = m.current) || void 0 === l ? void 0 : l.parentNode) || void 0 === a ? void 0 : a.offsetHeight: p, isNumber(j) && j < H && (H = j), H <= 0 && (H = 0); var x = React.useMemo(function() { var e = 1; if (y.rowHeight && R && H) if (H <= 0) e = 0; else { var t = 1 + (H / y.rowHeight | 0) + 2; e = t > R ? R: t } return e }, [y.rowHeight, R, H]), E = y.rowHeight ? y.curScrollTop / y.rowHeight | 0 : 0, N = y.rowHeight ? y.curScrollTop % y.rowHeight: 0; return y.curScrollTop && y.rowHeight && y.curScrollTop > y.rowHeight ? E > R - x || E > 1 && (E -= 1, N += y.rowHeight) : E = 0, React.useEffect(function() { var e, t = null === (e = m.current) || void 0 === e ? void 0 : e.parentNode; vidMap.set(g, __assign(__assign({}, vidMap.get(g)), { scrollNode: t })), b ? _({ type: "reset", ifScrollTopClear: !1 }) : (t && (t.scrollTop = 0), _({ type: "reset", ifScrollTopClear: !0 })) }, [R]), React.useEffect(function() { var e, t = throttle(function(e) { var t, r, o, n, i, l, a = null !== (r = null === (t = null === e || void 0 === e ? void 0 : e.target) || void 0 === t ? void 0 : t.scrollTop) && void 0 !== r ? r: 0, c = null !== (n = null === (o = null === e || void 0 === e ? void 0 : e.target) || void 0 === o ? void 0 : o.scrollHeight) && void 0 !== n ? n: 0, s = null !== (l = null === (i = null === e || void 0 === e ? void 0 : e.target) || void 0 === i ? void 0 : i.clientHeight) && void 0 !== l ? l: 0; a === c || a + s >= c && b && b(), h && h(), _({ type: "changeTrs", curScrollTop: a, scrollHeight: c, tableScrollY: H }) }, throttleTime), r = null === (e = null === m || void 0 === m ? void 0 : m.current) || void 0 === e ? void 0 : e.parentNode; return r && r.addEventListener("scroll", t), function() { r.removeEventListener("scroll", t) } }, [m, H]), React__default.createElement("div", { className: "virtuallist", ref: m, style: { width: "100%", position: "relative", height: j, boxSizing: "border-box", paddingTop: y.curScrollTop } }, React__default.createElement(ScrollContext.Provider, { value: { dispatch: _, rowHeight: y.rowHeight, start: E, offsetStart: N, renderLen: x, totalLen: R, vid: g } }, React__default.createElement("table", __assign({}, u, { ref: S, style: __assign(__assign({}, f), { width: d, position: "relative", transform: "translateY(-" + N + "px)" }) }), s))) } function VList(e) { var t, r, o, n = null !== (t = e.vid) && void 0 !== t ? t: DEFAULT_VID; return vidMap.has(n) ? o = null === (r = vidMap.get(n)) || void 0 === r ? void 0 : r.components: (o = transformTable({ vid: n, scrollY: e.height, reachEnd: e.onReachEnd, onScroll: e.onScroll }), vidMap.set(n, { components: o })), { table: o, body: { wrapper: VWrapper, row: VRow, cell: VCell } } } function scrollTo(e) { var t = e.row, r = e.y, o = e.vid, n = void 0 === o ? DEFAULT_VID: o, i = vidMap.get(n), l = i.scrollNode, a = i.rowItemHeight; l.scrollTop = t ? t - 1 > 0 ? (t - 1) * (null !== a && void 0 !== a ? a: 0) : 0 : null !== r && void 0 !== r ? r: 0 } Object.defineProperty(exports, "__esModule", { value: !0 }); var React = require("react"), React__default = _interopDefault(React), __assign = function() { return (__assign = Object.assign || function(e) { for (var t, r = 1, o = arguments.length; r < o; r++) { t = arguments[r]; for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]) } return e }).apply(this, arguments) }, freeGlobal = "object" == typeof global && global && global.Object === Object && global, freeSelf = "object" == typeof self && self && self.Object === Object && self, root = freeGlobal || freeSelf || Function("return this")(), Symbol = root.Symbol, objectProto = Object.prototype, hasOwnProperty = objectProto.hasOwnProperty, nativeObjectToString = objectProto.toString, symToStringTag = Symbol ? Symbol.toStringTag: void 0, objectProto$1 = Object.prototype, nativeObjectToString$1 = objectProto$1.toString, nullTag = "[object Null]", undefinedTag = "[object Undefined]", symToStringTag$1 = Symbol ? Symbol.toStringTag: void 0, symbolTag = "[object Symbol]", reWhitespace = /\s/, reTrimStart = /^\s+/, NAN = NaN, reIsBadHex = /^[-+]0x[0-9a-f]+$/i, reIsBinary = /^0b[01]+$/i, reIsOctal = /^0o[0-7]+$/i, freeParseInt = parseInt, now = function() { return root.Date.now() }, FUNC_ERROR_TEXT = "Expected a function", nativeMax = Math.max, nativeMin = Math.min, numberTag = "[object Number]", FUNC_ERROR_TEXT$1 = "Expected a function", css_248z = ".virtuallist .ant-table-tbody>tr>td>div{-webkit-box-sizing:border-box;box-sizing:border-box;white-space:nowrap;vertical-align:middle;overflow:hidden;text-overflow:ellipsis;width:100%}.virtuallist .ant-table-tbody>tr>td.ant-table-row-expand-icon-cell>div{overflow:inherit}.ant-table-bordered .virtuallist>table>.ant-table-tbody>tr>td{border-right:1px solid #f0f0f0}"; styleInject(css_248z); var initialState = { rowHeight: 0, curScrollTop: 0, scrollHeight: 0, tableScrollY: 0 }, DEFAULT_VID = "vtable", vidMap = new Map, ScrollContext = React.createContext({ dispatch: void 0, renderLen: 1, start: 0, offsetStart: 0, rowHeight: initialState.rowHeight, totalLen: 0, vid: DEFAULT_VID }), transformTable = function(e) { return function(t) { return VTable(t, e) } }; exports.VList = VList, exports.scrollTo = scrollTo;