@pinnacle0/web-ui 0.4.19 → 0.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
1
|
+
import "../../internal/polyfill/ResizeObserver";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { VirtualizerOptions, Virtualizer } from "@tanstack/react-virtual";
|
|
3
4
|
import type { ComponentType } from "react";
|
|
4
|
-
import type { StringKey } from "
|
|
5
|
-
|
|
5
|
+
import type { StringKey } from "../../internal/type";
|
|
6
|
+
import "./index.less";
|
|
7
|
+
export type Direction = "horizontal" | "vertical";
|
|
8
|
+
export interface VirtualListHandler extends Pick<Virtualizer<HTMLElement, HTMLElement>, "scrollElement" | "scrollToIndex" | "scrollToOffset" | "measure" | "getVirtualItems" | "range" | "indexFromElement" | "getTotalSize" | "scrollElement"> {
|
|
9
|
+
}
|
|
6
10
|
export interface ItemProps<T extends object> {
|
|
7
11
|
index: number;
|
|
8
12
|
data: T;
|
|
@@ -20,9 +24,10 @@ export interface Props<T extends object> {
|
|
|
20
24
|
overscan?: number;
|
|
21
25
|
observeElementRect?: VirtualizerOptions<HTMLElement, HTMLElement>["observeElementRect"];
|
|
22
26
|
observeElementOffset?: VirtualizerOptions<HTMLElement, HTMLElement>["observeElementOffset"];
|
|
27
|
+
className?: string;
|
|
28
|
+
listRef?: React.Ref<VirtualListHandler>;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* Efficiently rendering large lists and tabular data
|
|
26
32
|
*/
|
|
27
|
-
export declare function VirtualList<T extends object>({ data, rowKey, direction, renderItem: renderData, overscan, initialRect, observeElementOffset, fixedSize, observeElementRect, }: Props<T>): JSX.Element;
|
|
28
|
-
export {};
|
|
33
|
+
export declare function VirtualList<T extends object>({ data, rowKey, direction, renderItem: renderData, overscan, initialRect, observeElementOffset, fixedSize, observeElementRect, className, listRef, }: Props<T>): JSX.Element;
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import "../internal/polyfill/ResizeObserver";
|
|
1
|
+
import "../../internal/polyfill/ResizeObserver";
|
|
13
2
|
import React from "react";
|
|
3
|
+
import { classNames } from "../../util/ClassNames";
|
|
14
4
|
import { useVirtualizer, observeElementOffset as defaultObserveElementOffset, observeElementRect as defaultObserveElementRect } from "@tanstack/react-virtual";
|
|
5
|
+
import "./index.less";
|
|
15
6
|
var DEFAULT_ITEM_SIZE = 100;
|
|
16
7
|
/**
|
|
17
8
|
* Efficiently rendering large lists and tabular data
|
|
18
9
|
*/
|
|
19
10
|
export function VirtualList(_a) {
|
|
20
|
-
var data = _a.data, _b = _a.rowKey, rowKey = _b === void 0 ? "index" : _b, _c = _a.direction, direction = _c === void 0 ? "vertical" : _c, renderData = _a.renderItem, _d = _a.overscan, overscan = _d === void 0 ? 5 : _d, _e = _a.initialRect, initialRect = _e === void 0 ? { width: 0, height: 0 } : _e, observeElementOffset = _a.observeElementOffset, fixedSize = _a.fixedSize, observeElementRect = _a.observeElementRect;
|
|
11
|
+
var data = _a.data, _b = _a.rowKey, rowKey = _b === void 0 ? "index" : _b, _c = _a.direction, direction = _c === void 0 ? "vertical" : _c, renderData = _a.renderItem, _d = _a.overscan, overscan = _d === void 0 ? 5 : _d, _e = _a.initialRect, initialRect = _e === void 0 ? { width: 0, height: 0 } : _e, observeElementOffset = _a.observeElementOffset, fixedSize = _a.fixedSize, observeElementRect = _a.observeElementRect, className = _a.className, listRef = _a.listRef;
|
|
21
12
|
var Item = renderData;
|
|
22
13
|
var parentRef = React.useRef(null);
|
|
23
14
|
var horizontal = direction === "horizontal";
|
|
24
|
-
var sizeStyle = horizontal ? { height: "100%" } : { width: "100%" };
|
|
25
15
|
var virtualizer = useVirtualizer({
|
|
26
16
|
initialRect: initialRect,
|
|
27
17
|
horizontal: horizontal,
|
|
@@ -32,14 +22,20 @@ export function VirtualList(_a) {
|
|
|
32
22
|
observeElementRect: observeElementRect !== null && observeElementRect !== void 0 ? observeElementRect : defaultObserveElementRect,
|
|
33
23
|
overscan: overscan,
|
|
34
24
|
});
|
|
25
|
+
React.useImperativeHandle(listRef, function () { return ({
|
|
26
|
+
getVirtualItems: virtualizer.getVirtualItems,
|
|
27
|
+
scrollElement: virtualizer.scrollElement,
|
|
28
|
+
measure: virtualizer.measure,
|
|
29
|
+
scrollToIndex: virtualizer.scrollToIndex,
|
|
30
|
+
scrollToOffset: virtualizer.scrollToOffset,
|
|
31
|
+
getTotalSize: virtualizer.getTotalSize,
|
|
32
|
+
indexFromElement: virtualizer.indexFromElement,
|
|
33
|
+
range: virtualizer.range,
|
|
34
|
+
}); });
|
|
35
35
|
var getItemKey = function (index) { return (rowKey === "index" ? index : data[index][rowKey]); };
|
|
36
|
-
return (React.createElement("div", { className: "g-virtual-list",
|
|
37
|
-
React.createElement("div", { className: "g-virtual-list-inner", style: {
|
|
38
|
-
|
|
39
|
-
height: horizontal ? "100%" : virtualizer.getTotalSize(),
|
|
40
|
-
width: horizontal ? virtualizer.getTotalSize() : "100%",
|
|
41
|
-
} }, virtualizer.getVirtualItems().map(function (virtualRow) { return (React.createElement("div", { className: "g-virtual-list-item", key: getItemKey(virtualRow.index), ref: virtualizer.measureElement, "data-index": virtualRow.index, style: __assign({ position: "absolute", top: 0, left: 0, transform: horizontal ? "translateX(".concat(virtualRow.start, "px)") : "translateY(".concat(virtualRow.start, "px)") }, sizeStyle) },
|
|
42
|
-
React.createElement("div", { className: "g-virtual-list-item-wrapper", style: __assign({}, sizeStyle) },
|
|
36
|
+
return (React.createElement("div", { className: classNames("g-virtual-list", className, { horizontal: horizontal }), ref: parentRef },
|
|
37
|
+
React.createElement("div", { className: "g-virtual-list-inner", style: horizontal ? { width: virtualizer.getTotalSize() } : { height: virtualizer.getTotalSize() } }, virtualizer.getVirtualItems().map(function (virtualRow) { return (React.createElement("div", { className: "g-virtual-list-item", key: getItemKey(virtualRow.index), ref: virtualizer.measureElement, "data-index": virtualRow.index, style: { transform: horizontal ? "translateX(".concat(virtualRow.start, "px)") : "translateY(".concat(virtualRow.start, "px)") } },
|
|
38
|
+
React.createElement("div", { className: "g-virtual-list-item-wrapper" },
|
|
43
39
|
React.createElement(Item, { data: data[virtualRow.index], index: virtualRow.index })))); }))));
|
|
44
40
|
}
|
|
45
|
-
//# sourceMappingURL=
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/VirtualList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,wCAAwC,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,cAAc,EAAE,oBAAoB,IAAI,2BAA2B,EAAE,kBAAkB,IAAI,yBAAyB,EAAC,MAAM,yBAAyB,CAAC;AAI7J,OAAO,cAAc,CAAC;AAEtB,IAAM,iBAAiB,GAAG,GAAG,CAAC;AA6B9B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAmB,EAYnC;QAXP,IAAI,UAAA,EACJ,cAAgB,EAAhB,MAAM,mBAAG,OAAO,KAAA,EAChB,iBAAsB,EAAtB,SAAS,mBAAG,UAAU,KAAA,EACV,UAAU,gBAAA,EACtB,gBAAY,EAAZ,QAAQ,mBAAG,CAAC,KAAA,EACZ,mBAAmC,EAAnC,WAAW,mBAAG,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EA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{
|
|
12
|
+
position: absolute;
|
|
13
|
+
top: 0;
|
|
14
|
+
left: 0;
|
|
15
|
+
width: 100%;
|
|
16
|
+
|
|
17
|
+
.g-virtual-list-item-wrapper {
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.horizontal {
|
|
24
|
+
.g-virtual-list-inner,
|
|
25
|
+
.g-virtual-list-item,
|
|
26
|
+
.g-virtual-list-item-wrapper {
|
|
27
|
+
width: auto;
|
|
28
|
+
height: 100%;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/package.json
CHANGED
package/core/VirtualList.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualList.js","sourceRoot":"","sources":["../../src/core/VirtualList.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,qCAAqC,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAE,oBAAoB,IAAI,2BAA2B,EAAE,kBAAkB,IAAI,yBAAyB,EAAC,MAAM,yBAAyB,CAAC;AAK7J,IAAM,iBAAiB,GAAG,GAAG,CAAC;AAqB9B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAmB,EAUnC;QATP,IAAI,UAAA,EACJ,cAAgB,EAAhB,MAAM,mBAAG,OAAO,KAAA,EAChB,iBAAsB,EAAtB,SAAS,mBAAG,UAAU,KAAA,EACV,UAAU,gBAAA,EACtB,gBAAY,EAAZ,QAAQ,mBAAG,CAAC,KAAA,EACZ,mBAAmC,EAAnC,WAAW,mBAAG,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,KAAA,EACnC,oBAAoB,0BAAA,EACpB,SAAS,eAAA,EACT,kBAAkB,wBAAA;IAElB,IAAM,IAAI,GAAG,UAAU,CAAC;IACxB,IAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAwB,I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