react-virtuoso 4.10.0 → 4.10.2
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.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +62 -62
- package/dist/index.mjs +169 -146
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React, { createElement } from "react";
|
|
2
3
|
import ReactDOM from "react-dom";
|
|
3
4
|
const PUBLISH = 0;
|
|
4
5
|
const SUBSCRIBE = 1;
|
|
@@ -322,7 +323,7 @@ function omit(keys, obj) {
|
|
|
322
323
|
}
|
|
323
324
|
return result;
|
|
324
325
|
}
|
|
325
|
-
const useIsomorphicLayoutEffect$
|
|
326
|
+
const useIsomorphicLayoutEffect$1 = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
326
327
|
function systemToComponent(systemSpec, map2, Root) {
|
|
327
328
|
const requiredPropNames = Object.keys(map2.required || {});
|
|
328
329
|
const optionalPropNames = Object.keys(map2.optional || {});
|
|
@@ -368,7 +369,7 @@ function systemToComponent(systemSpec, map2, Root) {
|
|
|
368
369
|
return tap(init(systemSpec), (system22) => applyPropsToSystem(system22, props));
|
|
369
370
|
});
|
|
370
371
|
const [handlers] = React.useState(curry1to0(buildEventHandlers, system2));
|
|
371
|
-
useIsomorphicLayoutEffect$
|
|
372
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
372
373
|
for (const eventName of eventNames) {
|
|
373
374
|
if (eventName in props) {
|
|
374
375
|
subscribe(handlers[eventName], props[eventName]);
|
|
@@ -378,19 +379,12 @@ function systemToComponent(systemSpec, map2, Root) {
|
|
|
378
379
|
Object.values(handlers).map(reset);
|
|
379
380
|
};
|
|
380
381
|
}, [props, handlers, system2]);
|
|
381
|
-
useIsomorphicLayoutEffect$
|
|
382
|
+
useIsomorphicLayoutEffect$1(() => {
|
|
382
383
|
applyPropsToSystem(system2, props);
|
|
383
384
|
});
|
|
384
385
|
React.useImperativeHandle(ref, always(buildMethods(system2)));
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
{ value: system2 },
|
|
388
|
-
Root ? React.createElement(
|
|
389
|
-
Root,
|
|
390
|
-
omit([...requiredPropNames, ...optionalPropNames, ...eventNames], props),
|
|
391
|
-
children
|
|
392
|
-
) : children
|
|
393
|
-
);
|
|
386
|
+
const RootComponent = Root;
|
|
387
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value: system2, children: Root ? /* @__PURE__ */ jsx(RootComponent, { ...omit([...requiredPropNames, ...optionalPropNames, ...eventNames], props), children }) : children });
|
|
394
388
|
});
|
|
395
389
|
const usePublisher2 = (key) => {
|
|
396
390
|
return React.useCallback(curry2to1(publish, React.useContext(Context)[key]), [key]);
|
|
@@ -414,7 +408,7 @@ function systemToComponent(systemSpec, map2, Root) {
|
|
|
414
408
|
const system2 = React.useContext(Context);
|
|
415
409
|
const source = system2[key];
|
|
416
410
|
const [value, setValue] = React.useState(curry1to0(getValue, source));
|
|
417
|
-
useIsomorphicLayoutEffect$
|
|
411
|
+
useIsomorphicLayoutEffect$1(
|
|
418
412
|
() => subscribe(source, (next) => {
|
|
419
413
|
if (next !== value) {
|
|
420
414
|
setValue(always(next));
|
|
@@ -428,7 +422,7 @@ function systemToComponent(systemSpec, map2, Root) {
|
|
|
428
422
|
const useEmitter2 = (key, callback) => {
|
|
429
423
|
const context = React.useContext(Context);
|
|
430
424
|
const source = context[key];
|
|
431
|
-
useIsomorphicLayoutEffect$
|
|
425
|
+
useIsomorphicLayoutEffect$1(() => subscribe(source, callback), [callback, source]);
|
|
432
426
|
};
|
|
433
427
|
return {
|
|
434
428
|
Component,
|
|
@@ -438,7 +432,6 @@ function systemToComponent(systemSpec, map2, Root) {
|
|
|
438
432
|
};
|
|
439
433
|
}
|
|
440
434
|
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
441
|
-
const useIsomorphicLayoutEffect$1 = useIsomorphicLayoutEffect;
|
|
442
435
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
443
436
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
444
437
|
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
@@ -768,8 +761,7 @@ function newTree() {
|
|
|
768
761
|
return NIL_NODE;
|
|
769
762
|
}
|
|
770
763
|
function remove(node, key) {
|
|
771
|
-
if (empty(node))
|
|
772
|
-
return NIL_NODE;
|
|
764
|
+
if (empty(node)) return NIL_NODE;
|
|
773
765
|
const { k, l, r } = node;
|
|
774
766
|
if (key === k) {
|
|
775
767
|
if (empty(l)) {
|
|
@@ -3085,7 +3077,7 @@ const listComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
|
3085
3077
|
const groupContent = statefulStream((index) => `Group ${index}`);
|
|
3086
3078
|
const components = statefulStream({});
|
|
3087
3079
|
const computeItemKey = statefulStream(identity);
|
|
3088
|
-
const
|
|
3080
|
+
const HeaderFooterTag = statefulStream("div");
|
|
3089
3081
|
const scrollerRef = statefulStream(noop);
|
|
3090
3082
|
const distinctProp = (propName, defaultValue = null) => {
|
|
3091
3083
|
return statefulStreamFromEmitter(
|
|
@@ -3103,7 +3095,7 @@ const listComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
|
3103
3095
|
groupContent,
|
|
3104
3096
|
components,
|
|
3105
3097
|
computeItemKey,
|
|
3106
|
-
|
|
3098
|
+
HeaderFooterTag,
|
|
3107
3099
|
scrollerRef,
|
|
3108
3100
|
FooterComponent: distinctProp("Footer"),
|
|
3109
3101
|
HeaderComponent: distinctProp("Header"),
|
|
@@ -3119,7 +3111,7 @@ const listComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
|
3119
3111
|
const combinedSystem$2 = /* @__PURE__ */ system(([listSystem2, propsSystem]) => {
|
|
3120
3112
|
return { ...listSystem2, ...propsSystem };
|
|
3121
3113
|
}, tup(listSystem, listComponentPropsSystem));
|
|
3122
|
-
const DefaultScrollSeekPlaceholder$1 = ({ height }) => /* @__PURE__ */
|
|
3114
|
+
const DefaultScrollSeekPlaceholder$1 = ({ height }) => /* @__PURE__ */ jsx("div", { style: { height } });
|
|
3123
3115
|
const GROUP_STYLE = { position: positionStickyCssValue(), zIndex: 1, overflowAnchor: "none" };
|
|
3124
3116
|
const ITEM_STYLE$1 = { overflowAnchor: "none" };
|
|
3125
3117
|
const HORIZONTAL_ITEM_STYLE = { ...ITEM_STYLE$1, display: "inline-block", height: "100%" };
|
|
@@ -3183,59 +3175,62 @@ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList
|
|
|
3183
3175
|
...initialItemFinalLocationReached ? {} : { visibility: "hidden" }
|
|
3184
3176
|
};
|
|
3185
3177
|
if (!showTopList && listState.totalCount === 0 && EmptyPlaceholder) {
|
|
3186
|
-
return
|
|
3178
|
+
return /* @__PURE__ */ jsx(EmptyPlaceholder, { ...contextPropIfNotDomElement(EmptyPlaceholder, context) });
|
|
3187
3179
|
}
|
|
3188
|
-
return
|
|
3180
|
+
return /* @__PURE__ */ jsx(
|
|
3189
3181
|
ListComponent,
|
|
3190
3182
|
{
|
|
3191
3183
|
...contextPropIfNotDomElement(ListComponent, context),
|
|
3192
3184
|
ref: callbackRef,
|
|
3193
3185
|
style: containerStyle,
|
|
3194
|
-
"data-testid": showTopList ? "virtuoso-top-item-list" : "virtuoso-item-list"
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3186
|
+
"data-testid": showTopList ? "virtuoso-top-item-list" : "virtuoso-item-list",
|
|
3187
|
+
children: (showTopList ? listState.topItems : listState.items).map((item) => {
|
|
3188
|
+
const index = item.originalIndex;
|
|
3189
|
+
const key = computeItemKey(index + listState.firstItemIndex, item.data, context);
|
|
3190
|
+
if (isSeeking) {
|
|
3191
|
+
return /* @__PURE__ */ createElement(
|
|
3192
|
+
ScrollSeekPlaceholder,
|
|
3193
|
+
{
|
|
3194
|
+
...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
|
|
3195
|
+
key,
|
|
3196
|
+
index: item.index,
|
|
3197
|
+
height: item.size,
|
|
3198
|
+
type: item.type || "item",
|
|
3199
|
+
...item.type === "group" ? {} : { groupIndex: item.groupIndex }
|
|
3200
|
+
}
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
if (item.type === "group") {
|
|
3204
|
+
return /* @__PURE__ */ createElement(
|
|
3205
|
+
GroupComponent,
|
|
3206
|
+
{
|
|
3207
|
+
...contextPropIfNotDomElement(GroupComponent, context),
|
|
3208
|
+
key,
|
|
3209
|
+
"data-index": index,
|
|
3210
|
+
"data-known-size": item.size,
|
|
3211
|
+
"data-item-index": item.index,
|
|
3212
|
+
style: GROUP_STYLE
|
|
3213
|
+
},
|
|
3214
|
+
groupContent(item.index, context)
|
|
3215
|
+
);
|
|
3216
|
+
} else {
|
|
3217
|
+
return /* @__PURE__ */ createElement(
|
|
3218
|
+
ItemComponent,
|
|
3219
|
+
{
|
|
3220
|
+
...contextPropIfNotDomElement(ItemComponent, context),
|
|
3221
|
+
...itemPropIfNotDomElement(ItemComponent, item.data),
|
|
3222
|
+
key,
|
|
3223
|
+
"data-index": index,
|
|
3224
|
+
"data-known-size": item.size,
|
|
3225
|
+
"data-item-index": item.index,
|
|
3226
|
+
"data-item-group-index": item.groupIndex,
|
|
3227
|
+
style: horizontalDirection ? HORIZONTAL_ITEM_STYLE : ITEM_STYLE$1
|
|
3228
|
+
},
|
|
3229
|
+
hasGroups2 ? itemContent(item.index, item.groupIndex, item.data, context) : itemContent(item.index, item.data, context)
|
|
3230
|
+
);
|
|
3231
|
+
}
|
|
3232
|
+
})
|
|
3233
|
+
}
|
|
3239
3234
|
);
|
|
3240
3235
|
});
|
|
3241
3236
|
const scrollerStyle = {
|
|
@@ -3275,26 +3270,26 @@ function itemPropIfNotDomElement(element, item) {
|
|
|
3275
3270
|
const Header$1 = /* @__PURE__ */ React.memo(function VirtuosoHeader() {
|
|
3276
3271
|
const Header2 = useEmitterValue$2("HeaderComponent");
|
|
3277
3272
|
const headerHeight = usePublisher$2("headerHeight");
|
|
3278
|
-
const
|
|
3273
|
+
const HeaderFooterTag = useEmitterValue$2("HeaderFooterTag");
|
|
3279
3274
|
const ref = useSize(
|
|
3280
3275
|
React.useMemo(() => (el) => headerHeight(correctItemSize(el, "height")), [headerHeight]),
|
|
3281
3276
|
true,
|
|
3282
3277
|
useEmitterValue$2("skipAnimationFrameInResizeObserver")
|
|
3283
3278
|
);
|
|
3284
3279
|
const context = useEmitterValue$2("context");
|
|
3285
|
-
return Header2 ?
|
|
3280
|
+
return Header2 ? /* @__PURE__ */ jsx(HeaderFooterTag, { ref, children: /* @__PURE__ */ jsx(Header2, { ...contextPropIfNotDomElement(Header2, context) }) }) : null;
|
|
3286
3281
|
});
|
|
3287
3282
|
const Footer$1 = /* @__PURE__ */ React.memo(function VirtuosoFooter() {
|
|
3288
3283
|
const Footer2 = useEmitterValue$2("FooterComponent");
|
|
3289
3284
|
const footerHeight = usePublisher$2("footerHeight");
|
|
3290
|
-
const
|
|
3285
|
+
const HeaderFooterTag = useEmitterValue$2("HeaderFooterTag");
|
|
3291
3286
|
const ref = useSize(
|
|
3292
3287
|
React.useMemo(() => (el) => footerHeight(correctItemSize(el, "height")), [footerHeight]),
|
|
3293
3288
|
true,
|
|
3294
3289
|
useEmitterValue$2("skipAnimationFrameInResizeObserver")
|
|
3295
3290
|
);
|
|
3296
3291
|
const context = useEmitterValue$2("context");
|
|
3297
|
-
return Footer2 ?
|
|
3292
|
+
return Footer2 ? /* @__PURE__ */ jsx(HeaderFooterTag, { ref, children: /* @__PURE__ */ jsx(Footer2, { ...contextPropIfNotDomElement(Footer2, context) }) }) : null;
|
|
3298
3293
|
});
|
|
3299
3294
|
function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, useEmitterValue: useEmitterValue2 }) {
|
|
3300
3295
|
const Scroller2 = React.memo(function VirtuosoScroller({ style, children, ...props }) {
|
|
@@ -3315,7 +3310,7 @@ function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, u
|
|
|
3315
3310
|
useEmitter2("scrollTo", scrollToCallback);
|
|
3316
3311
|
useEmitter2("scrollBy", scrollByCallback);
|
|
3317
3312
|
const defaultStyle = horizontalDirection ? horizontalScrollerStyle : scrollerStyle;
|
|
3318
|
-
return
|
|
3313
|
+
return /* @__PURE__ */ jsx(
|
|
3319
3314
|
ScrollerComponent,
|
|
3320
3315
|
{
|
|
3321
3316
|
ref: scrollerRef,
|
|
@@ -3324,9 +3319,9 @@ function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, u
|
|
|
3324
3319
|
"data-virtuoso-scroller": true,
|
|
3325
3320
|
tabIndex: 0,
|
|
3326
3321
|
...props,
|
|
3327
|
-
...contextPropIfNotDomElement(ScrollerComponent, context)
|
|
3328
|
-
|
|
3329
|
-
|
|
3322
|
+
...contextPropIfNotDomElement(ScrollerComponent, context),
|
|
3323
|
+
children
|
|
3324
|
+
}
|
|
3330
3325
|
);
|
|
3331
3326
|
});
|
|
3332
3327
|
return Scroller2;
|
|
@@ -3347,7 +3342,7 @@ function buildWindowScroller({ usePublisher: usePublisher2, useEmitter: useEmitt
|
|
|
3347
3342
|
noop,
|
|
3348
3343
|
customScrollParent
|
|
3349
3344
|
);
|
|
3350
|
-
useIsomorphicLayoutEffect
|
|
3345
|
+
useIsomorphicLayoutEffect(() => {
|
|
3351
3346
|
scrollerRef.current = customScrollParent ? customScrollParent : window;
|
|
3352
3347
|
return () => {
|
|
3353
3348
|
scrollerRef.current = null;
|
|
@@ -3355,15 +3350,15 @@ function buildWindowScroller({ usePublisher: usePublisher2, useEmitter: useEmitt
|
|
|
3355
3350
|
}, [scrollerRef, customScrollParent]);
|
|
3356
3351
|
useEmitter2("windowScrollTo", scrollToCallback);
|
|
3357
3352
|
useEmitter2("scrollBy", scrollByCallback);
|
|
3358
|
-
return
|
|
3353
|
+
return /* @__PURE__ */ jsx(
|
|
3359
3354
|
ScrollerComponent,
|
|
3360
3355
|
{
|
|
3361
3356
|
style: { position: "relative", ...style, ...totalListHeight !== 0 ? { height: totalListHeight + deviation } : {} },
|
|
3362
3357
|
"data-virtuoso-scroller": true,
|
|
3363
3358
|
...props,
|
|
3364
|
-
...contextPropIfNotDomElement(ScrollerComponent, context)
|
|
3365
|
-
|
|
3366
|
-
|
|
3359
|
+
...contextPropIfNotDomElement(ScrollerComponent, context),
|
|
3360
|
+
children
|
|
3361
|
+
}
|
|
3367
3362
|
);
|
|
3368
3363
|
});
|
|
3369
3364
|
return Scroller2;
|
|
@@ -3385,7 +3380,7 @@ const Viewport$2 = ({ children }) => {
|
|
|
3385
3380
|
fixedItemHeight(ctx.itemHeight);
|
|
3386
3381
|
}
|
|
3387
3382
|
}, [ctx, viewportHeight, fixedItemHeight]);
|
|
3388
|
-
return /* @__PURE__ */
|
|
3383
|
+
return /* @__PURE__ */ jsx("div", { style: viewportStyle(alignToBottom), ref: viewportRef, "data-viewport-type": "element", children });
|
|
3389
3384
|
};
|
|
3390
3385
|
const WindowViewport$2 = ({ children }) => {
|
|
3391
3386
|
const ctx = React.useContext(VirtuosoMockContext);
|
|
@@ -3404,14 +3399,14 @@ const WindowViewport$2 = ({ children }) => {
|
|
|
3404
3399
|
windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: 100 });
|
|
3405
3400
|
}
|
|
3406
3401
|
}, [ctx, windowViewportRect, fixedItemHeight]);
|
|
3407
|
-
return /* @__PURE__ */
|
|
3402
|
+
return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle(alignToBottom), "data-viewport-type": "window", children });
|
|
3408
3403
|
};
|
|
3409
3404
|
const TopItemListContainer = ({ children }) => {
|
|
3410
3405
|
const TopItemList = useEmitterValue$2("TopItemListComponent") || "div";
|
|
3411
3406
|
const headerHeight = useEmitterValue$2("headerHeight");
|
|
3412
3407
|
const style = { ...topItemListStyle, marginTop: `${headerHeight}px` };
|
|
3413
3408
|
const context = useEmitterValue$2("context");
|
|
3414
|
-
return
|
|
3409
|
+
return /* @__PURE__ */ jsx(TopItemList, { style, ...contextPropIfNotDomElement(TopItemList, context), children });
|
|
3415
3410
|
};
|
|
3416
3411
|
const ListRoot = /* @__PURE__ */ React.memo(function VirtuosoRoot(props) {
|
|
3417
3412
|
const useWindowScroll = useEmitterValue$2("useWindowScroll");
|
|
@@ -3419,7 +3414,14 @@ const ListRoot = /* @__PURE__ */ React.memo(function VirtuosoRoot(props) {
|
|
|
3419
3414
|
const customScrollParent = useEmitterValue$2("customScrollParent");
|
|
3420
3415
|
const TheScroller = customScrollParent || useWindowScroll ? WindowScroller$2 : Scroller$2;
|
|
3421
3416
|
const TheViewport = customScrollParent || useWindowScroll ? WindowViewport$2 : Viewport$2;
|
|
3422
|
-
return /* @__PURE__ */
|
|
3417
|
+
return /* @__PURE__ */ jsxs(TheScroller, { ...props, children: [
|
|
3418
|
+
showTopList && /* @__PURE__ */ jsx(TopItemListContainer, { children: /* @__PURE__ */ jsx(Items$1, { showTopList: true }) }),
|
|
3419
|
+
/* @__PURE__ */ jsxs(TheViewport, { children: [
|
|
3420
|
+
/* @__PURE__ */ jsx(Header$1, {}),
|
|
3421
|
+
/* @__PURE__ */ jsx(Items$1, {}),
|
|
3422
|
+
/* @__PURE__ */ jsx(Footer$1, {})
|
|
3423
|
+
] })
|
|
3424
|
+
] });
|
|
3423
3425
|
});
|
|
3424
3426
|
const {
|
|
3425
3427
|
Component: List,
|
|
@@ -3451,7 +3453,7 @@ const {
|
|
|
3451
3453
|
fixedItemHeight: "fixedItemHeight",
|
|
3452
3454
|
itemSize: "itemSize",
|
|
3453
3455
|
scrollSeekConfiguration: "scrollSeekConfiguration",
|
|
3454
|
-
headerFooterTag: "
|
|
3456
|
+
headerFooterTag: "HeaderFooterTag",
|
|
3455
3457
|
data: "data",
|
|
3456
3458
|
initialItemCount: "initialItemCount",
|
|
3457
3459
|
initialScrollTop: "initialScrollTop",
|
|
@@ -3895,8 +3897,11 @@ const gridComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
|
3895
3897
|
);
|
|
3896
3898
|
};
|
|
3897
3899
|
const readyStateChanged = statefulStream(false);
|
|
3900
|
+
const reportReadyState = statefulStream(false);
|
|
3901
|
+
connect(duc(reportReadyState), readyStateChanged);
|
|
3898
3902
|
return {
|
|
3899
3903
|
readyStateChanged,
|
|
3904
|
+
reportReadyState,
|
|
3900
3905
|
context,
|
|
3901
3906
|
itemContent,
|
|
3902
3907
|
components,
|
|
@@ -3932,7 +3937,7 @@ const GridItems = /* @__PURE__ */ React.memo(function GridItems2() {
|
|
|
3932
3937
|
const gridGap = usePublisher$1("gap");
|
|
3933
3938
|
const log = useEmitterValue$1("log");
|
|
3934
3939
|
const stateRestoreInProgress = useEmitterValue$1("stateRestoreInProgress");
|
|
3935
|
-
const reportReadyState = usePublisher$1("
|
|
3940
|
+
const reportReadyState = usePublisher$1("reportReadyState");
|
|
3936
3941
|
const listRef = useSize(
|
|
3937
3942
|
React.useMemo(
|
|
3938
3943
|
() => (el) => {
|
|
@@ -3956,59 +3961,67 @@ const GridItems = /* @__PURE__ */ React.memo(function GridItems2() {
|
|
|
3956
3961
|
if (stateRestoreInProgress) {
|
|
3957
3962
|
return null;
|
|
3958
3963
|
}
|
|
3959
|
-
useIsomorphicLayoutEffect
|
|
3964
|
+
useIsomorphicLayoutEffect(() => {
|
|
3960
3965
|
if (gridState.itemHeight > 0 && gridState.itemWidth > 0) {
|
|
3961
3966
|
reportReadyState(true);
|
|
3962
3967
|
}
|
|
3963
3968
|
}, [gridState]);
|
|
3964
|
-
return
|
|
3969
|
+
return /* @__PURE__ */ jsx(
|
|
3965
3970
|
ListComponent,
|
|
3966
3971
|
{
|
|
3967
3972
|
ref: listRef,
|
|
3968
3973
|
className: listClassName,
|
|
3969
3974
|
...contextPropIfNotDomElement(ListComponent, context),
|
|
3970
3975
|
style: { paddingTop: gridState.offsetTop, paddingBottom: gridState.offsetBottom },
|
|
3971
|
-
"data-testid": "virtuoso-item-list"
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3976
|
+
"data-testid": "virtuoso-item-list",
|
|
3977
|
+
children: gridState.items.map((item) => {
|
|
3978
|
+
const key = computeItemKey(item.index, item.data, context);
|
|
3979
|
+
return isSeeking ? /* @__PURE__ */ jsx(
|
|
3980
|
+
ScrollSeekPlaceholder,
|
|
3981
|
+
{
|
|
3982
|
+
...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
|
|
3983
|
+
index: item.index,
|
|
3984
|
+
height: gridState.itemHeight,
|
|
3985
|
+
width: gridState.itemWidth
|
|
3986
|
+
},
|
|
3987
|
+
key
|
|
3988
|
+
) : /* @__PURE__ */ createElement(
|
|
3989
|
+
ItemComponent,
|
|
3990
|
+
{
|
|
3991
|
+
...contextPropIfNotDomElement(ItemComponent, context),
|
|
3992
|
+
className: itemClassName,
|
|
3993
|
+
"data-index": item.index,
|
|
3994
|
+
key
|
|
3995
|
+
},
|
|
3996
|
+
itemContent(item.index, item.data, context)
|
|
3997
|
+
);
|
|
3998
|
+
})
|
|
3999
|
+
}
|
|
3987
4000
|
);
|
|
3988
4001
|
});
|
|
3989
4002
|
const Header = React.memo(function VirtuosoHeader2() {
|
|
3990
4003
|
const Header2 = useEmitterValue$1("HeaderComponent");
|
|
3991
4004
|
const headerHeight = usePublisher$1("headerHeight");
|
|
3992
|
-
const
|
|
4005
|
+
const HeaderFooterTag = useEmitterValue$1("headerFooterTag");
|
|
3993
4006
|
const ref = useSize(
|
|
3994
4007
|
React.useMemo(() => (el) => headerHeight(correctItemSize(el, "height")), [headerHeight]),
|
|
3995
4008
|
true,
|
|
3996
4009
|
false
|
|
3997
4010
|
);
|
|
3998
4011
|
const context = useEmitterValue$1("context");
|
|
3999
|
-
return Header2 ?
|
|
4012
|
+
return Header2 ? /* @__PURE__ */ jsx(HeaderFooterTag, { ref, children: /* @__PURE__ */ jsx(Header2, { ...contextPropIfNotDomElement(Header2, context) }) }) : null;
|
|
4000
4013
|
});
|
|
4001
4014
|
const Footer = React.memo(function VirtuosoGridFooter() {
|
|
4002
4015
|
const Footer2 = useEmitterValue$1("FooterComponent");
|
|
4003
4016
|
const footerHeight = usePublisher$1("footerHeight");
|
|
4004
|
-
const
|
|
4017
|
+
const HeaderFooterTag = useEmitterValue$1("headerFooterTag");
|
|
4005
4018
|
const ref = useSize(
|
|
4006
4019
|
React.useMemo(() => (el) => footerHeight(correctItemSize(el, "height")), [footerHeight]),
|
|
4007
4020
|
true,
|
|
4008
4021
|
false
|
|
4009
4022
|
);
|
|
4010
4023
|
const context = useEmitterValue$1("context");
|
|
4011
|
-
return Footer2 ?
|
|
4024
|
+
return Footer2 ? /* @__PURE__ */ jsx(HeaderFooterTag, { ref, children: /* @__PURE__ */ jsx(Footer2, { ...contextPropIfNotDomElement(Footer2, context) }) }) : null;
|
|
4012
4025
|
});
|
|
4013
4026
|
const Viewport$1 = ({ children }) => {
|
|
4014
4027
|
const ctx = React.useContext(VirtuosoGridMockContext);
|
|
@@ -4030,7 +4043,7 @@ const Viewport$1 = ({ children }) => {
|
|
|
4030
4043
|
itemDimensions({ height: ctx.itemHeight, width: ctx.itemWidth });
|
|
4031
4044
|
}
|
|
4032
4045
|
}, [ctx, viewportDimensions, itemDimensions]);
|
|
4033
|
-
return /* @__PURE__ */
|
|
4046
|
+
return /* @__PURE__ */ jsx("div", { style: viewportStyle(false), ref: viewportRef, children });
|
|
4034
4047
|
};
|
|
4035
4048
|
const WindowViewport$1 = ({ children }) => {
|
|
4036
4049
|
const ctx = React.useContext(VirtuosoGridMockContext);
|
|
@@ -4044,14 +4057,18 @@ const WindowViewport$1 = ({ children }) => {
|
|
|
4044
4057
|
windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: ctx.viewportWidth });
|
|
4045
4058
|
}
|
|
4046
4059
|
}, [ctx, windowViewportRect, itemDimensions]);
|
|
4047
|
-
return /* @__PURE__ */
|
|
4060
|
+
return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle(false), children });
|
|
4048
4061
|
};
|
|
4049
4062
|
const GridRoot = /* @__PURE__ */ React.memo(function GridRoot2({ ...props }) {
|
|
4050
4063
|
const useWindowScroll = useEmitterValue$1("useWindowScroll");
|
|
4051
4064
|
const customScrollParent = useEmitterValue$1("customScrollParent");
|
|
4052
4065
|
const TheScroller = customScrollParent || useWindowScroll ? WindowScroller$1 : Scroller$1;
|
|
4053
4066
|
const TheViewport = customScrollParent || useWindowScroll ? WindowViewport$1 : Viewport$1;
|
|
4054
|
-
return /* @__PURE__ */
|
|
4067
|
+
return /* @__PURE__ */ jsx(TheScroller, { ...props, children: /* @__PURE__ */ jsxs(TheViewport, { children: [
|
|
4068
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
4069
|
+
/* @__PURE__ */ jsx(GridItems, {}),
|
|
4070
|
+
/* @__PURE__ */ jsx(Footer, {})
|
|
4071
|
+
] }) });
|
|
4055
4072
|
});
|
|
4056
4073
|
const {
|
|
4057
4074
|
Component: Grid,
|
|
@@ -4112,7 +4129,10 @@ function resolveGapValue(property, value, log) {
|
|
|
4112
4129
|
}
|
|
4113
4130
|
const VirtuosoGrid = Grid;
|
|
4114
4131
|
const tableComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
4115
|
-
const itemContent = statefulStream((index) => /* @__PURE__ */
|
|
4132
|
+
const itemContent = statefulStream((index) => /* @__PURE__ */ jsxs("td", { children: [
|
|
4133
|
+
"Item $",
|
|
4134
|
+
index
|
|
4135
|
+
] }));
|
|
4116
4136
|
const context = statefulStream(null);
|
|
4117
4137
|
const fixedHeaderContent = statefulStream(null);
|
|
4118
4138
|
const fixedFooterContent = statefulStream(null);
|
|
@@ -4151,8 +4171,8 @@ const tableComponentPropsSystem = /* @__PURE__ */ system(() => {
|
|
|
4151
4171
|
const combinedSystem = /* @__PURE__ */ system(([listSystem2, propsSystem]) => {
|
|
4152
4172
|
return { ...listSystem2, ...propsSystem };
|
|
4153
4173
|
}, tup(listSystem, tableComponentPropsSystem));
|
|
4154
|
-
const DefaultScrollSeekPlaceholder = ({ height }) => /* @__PURE__ */
|
|
4155
|
-
const DefaultFillerRow = ({ height }) => /* @__PURE__ */
|
|
4174
|
+
const DefaultScrollSeekPlaceholder = ({ height }) => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: { height } }) });
|
|
4175
|
+
const DefaultFillerRow = ({ height }) => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: { height, padding: 0, border: 0 } }) });
|
|
4156
4176
|
const ITEM_STYLE = { overflowAnchor: "none" };
|
|
4157
4177
|
const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
|
|
4158
4178
|
const listState = useEmitterValue("listState");
|
|
@@ -4196,25 +4216,28 @@ const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
|
|
|
4196
4216
|
const statefulTotalCount = useEmitterValue("statefulTotalCount");
|
|
4197
4217
|
const context = useEmitterValue("context");
|
|
4198
4218
|
if (statefulTotalCount === 0 && EmptyPlaceholder) {
|
|
4199
|
-
return
|
|
4219
|
+
return /* @__PURE__ */ jsx(EmptyPlaceholder, { ...contextPropIfNotDomElement(EmptyPlaceholder, context) });
|
|
4200
4220
|
}
|
|
4201
4221
|
const paddingTop = listState.offsetTop + paddingTopAddition + deviation;
|
|
4202
4222
|
const paddingBottom = listState.offsetBottom;
|
|
4203
|
-
const paddingTopEl = paddingTop > 0 ? /* @__PURE__ */
|
|
4204
|
-
const paddingBottomEl = paddingBottom > 0 ? /* @__PURE__ */
|
|
4223
|
+
const paddingTopEl = paddingTop > 0 ? /* @__PURE__ */ jsx(FillerRow, { height: paddingTop, context }, "padding-top") : null;
|
|
4224
|
+
const paddingBottomEl = paddingBottom > 0 ? /* @__PURE__ */ jsx(FillerRow, { height: paddingBottom, context }, "padding-bottom") : null;
|
|
4205
4225
|
const items = listState.items.map((item) => {
|
|
4206
4226
|
const index = item.originalIndex;
|
|
4207
4227
|
const key = computeItemKey(index + firstItemIndex, item.data, context);
|
|
4208
4228
|
if (isSeeking) {
|
|
4209
|
-
return
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
|
|
4229
|
+
return /* @__PURE__ */ createElement(
|
|
4230
|
+
ScrollSeekPlaceholder,
|
|
4231
|
+
{
|
|
4232
|
+
...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
|
|
4233
|
+
key,
|
|
4234
|
+
index: item.index,
|
|
4235
|
+
height: item.size,
|
|
4236
|
+
type: item.type || "item"
|
|
4237
|
+
}
|
|
4238
|
+
);
|
|
4216
4239
|
}
|
|
4217
|
-
return
|
|
4240
|
+
return /* @__PURE__ */ createElement(
|
|
4218
4241
|
TableRowComponent,
|
|
4219
4242
|
{
|
|
4220
4243
|
...contextPropIfNotDomElement(TableRowComponent, context),
|
|
@@ -4228,11 +4251,11 @@ const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
|
|
|
4228
4251
|
itemContent(item.index, item.data, context)
|
|
4229
4252
|
);
|
|
4230
4253
|
});
|
|
4231
|
-
return
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
);
|
|
4254
|
+
return /* @__PURE__ */ jsxs(TableBodyComponent, { ref: callbackRef, "data-testid": "virtuoso-item-list", ...contextPropIfNotDomElement(TableBodyComponent, context), children: [
|
|
4255
|
+
paddingTopEl,
|
|
4256
|
+
items,
|
|
4257
|
+
paddingBottomEl
|
|
4258
|
+
] });
|
|
4236
4259
|
});
|
|
4237
4260
|
const Viewport = ({ children }) => {
|
|
4238
4261
|
const ctx = React.useContext(VirtuosoMockContext);
|
|
@@ -4249,7 +4272,7 @@ const Viewport = ({ children }) => {
|
|
|
4249
4272
|
fixedItemHeight(ctx.itemHeight);
|
|
4250
4273
|
}
|
|
4251
4274
|
}, [ctx, viewportHeight, fixedItemHeight]);
|
|
4252
|
-
return /* @__PURE__ */
|
|
4275
|
+
return /* @__PURE__ */ jsx("div", { style: viewportStyle(false), ref: viewportRef, "data-viewport-type": "element", children });
|
|
4253
4276
|
};
|
|
4254
4277
|
const WindowViewport = ({ children }) => {
|
|
4255
4278
|
const ctx = React.useContext(VirtuosoMockContext);
|
|
@@ -4267,7 +4290,7 @@ const WindowViewport = ({ children }) => {
|
|
|
4267
4290
|
windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: 100 });
|
|
4268
4291
|
}
|
|
4269
4292
|
}, [ctx, windowViewportRect, fixedItemHeight]);
|
|
4270
|
-
return /* @__PURE__ */
|
|
4293
|
+
return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle(false), "data-viewport-type": "window", children });
|
|
4271
4294
|
};
|
|
4272
4295
|
const TableRoot = /* @__PURE__ */ React.memo(function TableVirtuosoRoot(props) {
|
|
4273
4296
|
const useWindowScroll = useEmitterValue("useWindowScroll");
|
|
@@ -4292,31 +4315,31 @@ const TableRoot = /* @__PURE__ */ React.memo(function TableVirtuosoRoot(props) {
|
|
|
4292
4315
|
const TheTable = useEmitterValue("TableComponent");
|
|
4293
4316
|
const TheTHead = useEmitterValue("TableHeadComponent");
|
|
4294
4317
|
const TheTFoot = useEmitterValue("TableFooterComponent");
|
|
4295
|
-
const theHead = fixedHeaderContent ?
|
|
4318
|
+
const theHead = fixedHeaderContent ? /* @__PURE__ */ jsx(
|
|
4296
4319
|
TheTHead,
|
|
4297
4320
|
{
|
|
4298
|
-
key: "TableHead",
|
|
4299
4321
|
style: { zIndex: 2, position: "sticky", top: 0 },
|
|
4300
4322
|
ref: theadRef,
|
|
4301
|
-
...contextPropIfNotDomElement(TheTHead, context)
|
|
4323
|
+
...contextPropIfNotDomElement(TheTHead, context),
|
|
4324
|
+
children: fixedHeaderContent()
|
|
4302
4325
|
},
|
|
4303
|
-
|
|
4326
|
+
"TableHead"
|
|
4304
4327
|
) : null;
|
|
4305
|
-
const theFoot = fixedFooterContent ?
|
|
4328
|
+
const theFoot = fixedFooterContent ? /* @__PURE__ */ jsx(
|
|
4306
4329
|
TheTFoot,
|
|
4307
4330
|
{
|
|
4308
|
-
key: "TableFoot",
|
|
4309
4331
|
style: { zIndex: 1, position: "sticky", bottom: 0 },
|
|
4310
4332
|
ref: tfootRef,
|
|
4311
|
-
...contextPropIfNotDomElement(TheTFoot, context)
|
|
4333
|
+
...contextPropIfNotDomElement(TheTFoot, context),
|
|
4334
|
+
children: fixedFooterContent()
|
|
4312
4335
|
},
|
|
4313
|
-
|
|
4336
|
+
"TableFoot"
|
|
4314
4337
|
) : null;
|
|
4315
|
-
return /* @__PURE__ */
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
)));
|
|
4338
|
+
return /* @__PURE__ */ jsx(TheScroller, { ...props, children: /* @__PURE__ */ jsx(TheViewport, { children: /* @__PURE__ */ jsxs(TheTable, { style: { borderSpacing: 0, overflowAnchor: "none" }, ...contextPropIfNotDomElement(TheTable, context), children: [
|
|
4339
|
+
theHead,
|
|
4340
|
+
/* @__PURE__ */ jsx(Items, {}, "TableBody"),
|
|
4341
|
+
theFoot
|
|
4342
|
+
] }) }) });
|
|
4320
4343
|
});
|
|
4321
4344
|
const {
|
|
4322
4345
|
Component: Table,
|