@pinnacle0/web-ui 0.6.32 → 0.6.34
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,12 +1,10 @@
|
|
|
1
1
|
import "../../internal/polyfill/ResizeObserver";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
4
4
|
import type { ComponentType } from "react";
|
|
5
5
|
import type { StringKey } from "../../internal/type";
|
|
6
6
|
import "./index.less";
|
|
7
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
|
-
}
|
|
10
8
|
export interface ItemProps<T extends object> {
|
|
11
9
|
index: number;
|
|
12
10
|
data: T;
|
|
@@ -22,13 +20,11 @@ export interface Props<T extends object> {
|
|
|
22
20
|
direction?: Direction;
|
|
23
21
|
fixedSize?: (index: number) => number;
|
|
24
22
|
overscan?: number;
|
|
25
|
-
observeElementRect?: VirtualizerOptions<HTMLElement, HTMLElement>["observeElementRect"];
|
|
26
|
-
observeElementOffset?: VirtualizerOptions<HTMLElement, HTMLElement>["observeElementOffset"];
|
|
27
23
|
id?: string;
|
|
28
24
|
className?: string;
|
|
29
|
-
listRef?: React.Ref<
|
|
25
|
+
listRef?: React.Ref<Virtualizer<HTMLElement, HTMLElement>>;
|
|
30
26
|
}
|
|
31
27
|
/**
|
|
32
28
|
* Efficiently rendering large lists and tabular data
|
|
33
29
|
*/
|
|
34
|
-
export declare function VirtualList<T extends object>({ data, rowKey, direction, renderItem: renderData, overscan, initialRect,
|
|
30
|
+
export declare function VirtualList<T extends object>({ data, rowKey, direction, renderItem: renderData, overscan, initialRect, fixedSize, id, className, }: Props<T>): React.JSX.Element;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "../../internal/polyfill/ResizeObserver";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { classNames } from "../../util/ClassNames";
|
|
4
|
-
import { useVirtualizer
|
|
4
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
5
5
|
import "./index.less";
|
|
6
6
|
const DEFAULT_ITEM_SIZE = 100;
|
|
7
7
|
/**
|
|
8
8
|
* Efficiently rendering large lists and tabular data
|
|
9
9
|
*/
|
|
10
|
-
export function VirtualList({ data, rowKey = "index", direction = "vertical", renderItem: renderData, overscan = 5, initialRect = { width: 0, height: 0 },
|
|
10
|
+
export function VirtualList({ data, rowKey = "index", direction = "vertical", renderItem: renderData, overscan = 5, initialRect = { width: 0, height: 0 }, fixedSize, id, className, }) {
|
|
11
11
|
const Item = renderData;
|
|
12
12
|
const parentRef = React.useRef(null);
|
|
13
13
|
const horizontal = direction === "horizontal";
|
|
@@ -17,20 +17,8 @@ export function VirtualList({ data, rowKey = "index", direction = "vertical", re
|
|
|
17
17
|
count: data.length,
|
|
18
18
|
getScrollElement: () => parentRef.current,
|
|
19
19
|
estimateSize: fixedSize ?? (() => DEFAULT_ITEM_SIZE),
|
|
20
|
-
observeElementOffset: observeElementOffset ?? defaultObserveElementOffset,
|
|
21
|
-
observeElementRect: observeElementRect ?? defaultObserveElementRect,
|
|
22
20
|
overscan,
|
|
23
21
|
});
|
|
24
|
-
React.useImperativeHandle(listRef, () => ({
|
|
25
|
-
getVirtualItems: virtualizer.getVirtualItems,
|
|
26
|
-
scrollElement: virtualizer.scrollElement,
|
|
27
|
-
measure: virtualizer.measure,
|
|
28
|
-
scrollToIndex: virtualizer.scrollToIndex,
|
|
29
|
-
scrollToOffset: virtualizer.scrollToOffset,
|
|
30
|
-
getTotalSize: virtualizer.getTotalSize,
|
|
31
|
-
indexFromElement: virtualizer.indexFromElement,
|
|
32
|
-
range: virtualizer.range,
|
|
33
|
-
}));
|
|
34
22
|
const getItemKey = (index) => (rowKey === "index" ? index : data[index][rowKey]);
|
|
35
23
|
return (React.createElement("div", { id: id, className: classNames("g-virtual-list", className, { horizontal }), ref: parentRef },
|
|
36
24
|
React.createElement("div", { className: "g-virtual-list-inner", style: horizontal ? { width: virtualizer.getTotalSize() } : { height: virtualizer.getTotalSize() } }, virtualizer.getVirtualItems().map(virtualRow => (React.createElement("div", { className: "g-virtual-list-item", key: getItemKey(virtualRow.index), ref: virtualizer.measureElement, "data-index": virtualRow.index, style: { transform: horizontal ? `translateX(${virtualRow.start}px)` : `translateY(${virtualRow.start}px)` } },
|
|
@@ -1 +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,
|
|
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,EAAC,MAAM,yBAAyB,CAAC;AAIvD,OAAO,cAAc,CAAC;AAEtB,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAsB9B;;GAEG;AACH,MAAM,UAAU,WAAW,CAAmB,EAC1C,IAAI,EACJ,MAAM,GAAG,OAAO,EAChB,SAAS,GAAG,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,GAAG,CAAC,EACZ,WAAW,GAAG,EAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAC,EACnC,SAAS,EACT,EAAE,EACF,SAAS,GACF;IACP,MAAM,IAAI,GAAG,UAAU,CAAC;IACxB,MAAM,SAAS,GAAG,KAA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BAAK,SAAS,EAAC,6BAA6B;gBACxC,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,GAAI,CAC7D,CACJ,CACT,CAAC,CACA,CACJ,CACT,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation
|
|
9
9
|
*
|
|
10
10
|
* For iOS 26.0+ PWA, it does not dispatch any event when the orientation changes,
|
|
11
|
-
* For
|
|
11
|
+
* For iOS,
|
|
12
12
|
* Use media queries to check the orientation of the screen for iOS.
|
|
13
13
|
*
|
|
14
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
|
|
14
15
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries
|
|
15
16
|
*/
|
|
16
17
|
export type OrientationType = "portrait" | "landscape";
|
|
@@ -8,20 +8,17 @@
|
|
|
8
8
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation
|
|
9
9
|
*
|
|
10
10
|
* For iOS 26.0+ PWA, it does not dispatch any event when the orientation changes,
|
|
11
|
-
* For
|
|
11
|
+
* For iOS,
|
|
12
12
|
* Use media queries to check the orientation of the screen for iOS.
|
|
13
13
|
*
|
|
14
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
|
|
14
15
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries
|
|
15
16
|
*/
|
|
16
17
|
import { BrowserUtil } from "../BrowserUtil";
|
|
17
18
|
const supportScreenOrientationAPI = typeof window.screen.orientation !== "undefined";
|
|
18
|
-
// DO NOT USE matchMedia for non-safari browsers, because it can be incorrect if keyboard is popped up
|
|
19
|
-
// Tested on iOS safari: 26.0-15.2
|
|
20
|
-
// See Note from: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
|
|
21
|
-
const isIOSSafari = BrowserUtil.os() === "ios" && navigator.userAgent.includes("Safari");
|
|
22
19
|
function subscribe(subscriber) {
|
|
23
20
|
const handler = () => subscriber(current());
|
|
24
|
-
if (
|
|
21
|
+
if (BrowserUtil.os() === "ios") {
|
|
25
22
|
window.matchMedia("(orientation: portrait)").addEventListener("change", handler);
|
|
26
23
|
return () => window.matchMedia("(orientation: portrait)").removeEventListener("change", handler);
|
|
27
24
|
}
|
|
@@ -36,7 +33,7 @@ function subscribe(subscriber) {
|
|
|
36
33
|
}
|
|
37
34
|
function current() {
|
|
38
35
|
try {
|
|
39
|
-
if (
|
|
36
|
+
if (BrowserUtil.os() === "ios") {
|
|
40
37
|
return window.matchMedia("(orientation: portrait)").matches ? "portrait" : "landscape";
|
|
41
38
|
}
|
|
42
39
|
else if (supportScreenOrientationAPI) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/OrientationUtil/index.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/OrientationUtil/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,2BAA2B,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,KAAK,WAAW,CAAC;AAMrF,SAAS,SAAS,CAAC,UAAsB;IACrC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,IAAI,WAAW,CAAC,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjF,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAy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