react-virtuoso 4.0.4 → 4.0.6

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.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { createContext, forwardRef, useState, useImperativeHandle, createElement, useLayoutEffect, useEffect, useCallback, useContext, useRef, memo } from "react";
3
- import { flushSync } from "react-dom";
1
+ import React from "react";
2
+ import ReactDOM from "react-dom";
4
3
  const PUBLISH = 0;
5
4
  const SUBSCRIBE = 1;
6
5
  const RESET = 2;
@@ -320,13 +319,13 @@ function omit(keys, obj) {
320
319
  }
321
320
  return result;
322
321
  }
323
- const useIsomorphicLayoutEffect$2 = typeof document !== "undefined" ? useLayoutEffect : useEffect;
322
+ const useIsomorphicLayoutEffect$2 = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
324
323
  function systemToComponent(systemSpec, map2, Root) {
325
324
  const requiredPropNames = Object.keys(map2.required || {});
326
325
  const optionalPropNames = Object.keys(map2.optional || {});
327
326
  const methodNames = Object.keys(map2.methods || {});
328
327
  const eventNames = Object.keys(map2.events || {});
329
- const Context = createContext({});
328
+ const Context = React.createContext({});
330
329
  function applyPropsToSystem(system2, props) {
331
330
  if (system2["propsReady"]) {
332
331
  publish(system2["propsReady"], false);
@@ -360,12 +359,12 @@ function systemToComponent(systemSpec, map2, Root) {
360
359
  return handlers;
361
360
  }, {});
362
361
  }
363
- const Component = forwardRef((propsWithChildren, ref) => {
362
+ const Component = React.forwardRef((propsWithChildren, ref) => {
364
363
  const { children, ...props } = propsWithChildren;
365
- const [system2] = useState(() => {
364
+ const [system2] = React.useState(() => {
366
365
  return tap(init(systemSpec), (system22) => applyPropsToSystem(system22, props));
367
366
  });
368
- const [handlers] = useState(curry1to0(buildEventHandlers, system2));
367
+ const [handlers] = React.useState(curry1to0(buildEventHandlers, system2));
369
368
  useIsomorphicLayoutEffect$2(() => {
370
369
  for (const eventName of eventNames) {
371
370
  if (eventName in props) {
@@ -379,11 +378,11 @@ function systemToComponent(systemSpec, map2, Root) {
379
378
  useIsomorphicLayoutEffect$2(() => {
380
379
  applyPropsToSystem(system2, props);
381
380
  });
382
- useImperativeHandle(ref, always(buildMethods(system2)));
383
- return createElement(
381
+ React.useImperativeHandle(ref, always(buildMethods(system2)));
382
+ return React.createElement(
384
383
  Context.Provider,
385
384
  { value: system2 },
386
- Root ? createElement(
385
+ Root ? React.createElement(
387
386
  Root,
388
387
  omit([...requiredPropNames, ...optionalPropNames, ...eventNames], props),
389
388
  children
@@ -391,12 +390,12 @@ function systemToComponent(systemSpec, map2, Root) {
391
390
  );
392
391
  });
393
392
  const usePublisher2 = (key) => {
394
- return useCallback(curry2to1(publish, useContext(Context)[key]), [key]);
393
+ return React.useCallback(curry2to1(publish, React.useContext(Context)[key]), [key]);
395
394
  };
396
395
  const useEmitterValue2 = (key) => {
397
- const system2 = useContext(Context);
396
+ const system2 = React.useContext(Context);
398
397
  const source = system2[key];
399
- const [value, setValue] = useState(curry1to0(getValue, source));
398
+ const [value, setValue] = React.useState(curry1to0(getValue, source));
400
399
  useIsomorphicLayoutEffect$2(
401
400
  () => subscribe(source, (next) => {
402
401
  if (next !== value) {
@@ -408,7 +407,7 @@ function systemToComponent(systemSpec, map2, Root) {
408
407
  return value;
409
408
  };
410
409
  const useEmitter2 = (key, callback) => {
411
- const context = useContext(Context);
410
+ const context = React.useContext(Context);
412
411
  const source = context[key];
413
412
  useIsomorphicLayoutEffect$2(() => subscribe(source, callback), [callback, source]);
414
413
  };
@@ -419,7 +418,7 @@ function systemToComponent(systemSpec, map2, Root) {
419
418
  useEmitter: useEmitter2
420
419
  };
421
420
  }
422
- const useIsomorphicLayoutEffect = typeof document !== "undefined" ? useLayoutEffect : useEffect;
421
+ const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
423
422
  const useIsomorphicLayoutEffect$1 = useIsomorphicLayoutEffect;
424
423
  var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
425
424
  LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
@@ -459,7 +458,7 @@ const loggerSystem = system(
459
458
  { singleton: true }
460
459
  );
461
460
  function useSizeWithElRef(callback, enabled = true) {
462
- const ref = useRef(null);
461
+ const ref = React.useRef(null);
463
462
  let callbackRef = (_el) => {
464
463
  };
465
464
  if (typeof ResizeObserver !== "undefined") {
@@ -553,10 +552,10 @@ function approximatelyEqual(num1, num2) {
553
552
  return Math.abs(num1 - num2) < 1.01;
554
553
  }
555
554
  function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, scrollerElement, scrollerRefCallback = noop, customScrollParent) {
556
- const scrollerRef = useRef(null);
557
- const scrollTopTarget = useRef(null);
558
- const timeoutRef = useRef(null);
559
- const handler = useCallback(
555
+ const scrollerRef = React.useRef(null);
556
+ const scrollTopTarget = React.useRef(null);
557
+ const timeoutRef = React.useRef(null);
558
+ const handler = React.useCallback(
560
559
  (ev) => {
561
560
  const el = ev.target;
562
561
  const windowScroll = el === window || el === document;
@@ -573,7 +572,7 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
573
572
  if (ev.suppressFlushSync) {
574
573
  call2();
575
574
  } else {
576
- flushSync(call2);
575
+ ReactDOM.flushSync(call2);
577
576
  }
578
577
  if (scrollTopTarget.current !== null) {
579
578
  if (scrollTop === scrollTopTarget.current || scrollTop <= 0 || scrollTop === scrollHeight - viewportHeight) {
@@ -588,7 +587,7 @@ function useScrollTop(scrollContainerStateCallback, smoothScrollTargetReached, s
588
587
  },
589
588
  [scrollContainerStateCallback, smoothScrollTargetReached]
590
589
  );
591
- useEffect(() => {
590
+ React.useEffect(() => {
592
591
  const localRef = customScrollParent ? customScrollParent : scrollerRef.current;
593
592
  scrollerRefCallback(customScrollParent ? customScrollParent : scrollerRef.current);
594
593
  handler({ target: localRef, suppressFlushSync: true });
@@ -2670,8 +2669,8 @@ const positionStickyCssValue = simpleMemoize(() => {
2670
2669
  return node.style.position === WEBKIT_STICKY ? WEBKIT_STICKY : STICKY;
2671
2670
  });
2672
2671
  function useWindowViewportRectRef(callback, customScrollParent) {
2673
- const viewportInfo = useRef(null);
2674
- const calculateInfo = useCallback(
2672
+ const viewportInfo = React.useRef(null);
2673
+ const calculateInfo = React.useCallback(
2675
2674
  (element) => {
2676
2675
  if (element === null || !element.offsetParent) {
2677
2676
  return;
@@ -2698,10 +2697,10 @@ function useWindowViewportRectRef(callback, customScrollParent) {
2698
2697
  [callback, customScrollParent]
2699
2698
  );
2700
2699
  const { callbackRef, ref } = useSizeWithElRef(calculateInfo);
2701
- const scrollAndResizeEventHandler = useCallback(() => {
2700
+ const scrollAndResizeEventHandler = React.useCallback(() => {
2702
2701
  calculateInfo(ref.current);
2703
2702
  }, [calculateInfo, ref]);
2704
- useEffect(() => {
2703
+ React.useEffect(() => {
2705
2704
  if (customScrollParent) {
2706
2705
  customScrollParent.addEventListener("scroll", scrollAndResizeEventHandler);
2707
2706
  const observer = new ResizeObserver(scrollAndResizeEventHandler);
@@ -2721,8 +2720,8 @@ function useWindowViewportRectRef(callback, customScrollParent) {
2721
2720
  }, [scrollAndResizeEventHandler, customScrollParent]);
2722
2721
  return callbackRef;
2723
2722
  }
2724
- const VirtuosoMockContext = createContext(void 0);
2725
- const VirtuosoGridMockContext = createContext(void 0);
2723
+ const VirtuosoMockContext = React.createContext(void 0);
2724
+ const VirtuosoGridMockContext = React.createContext(void 0);
2726
2725
  function identity(value) {
2727
2726
  return value;
2728
2727
  }
@@ -2766,10 +2765,10 @@ const listComponentPropsSystem = /* @__PURE__ */ system(() => {
2766
2765
  const combinedSystem$2 = /* @__PURE__ */ system(([listSystem2, propsSystem]) => {
2767
2766
  return { ...listSystem2, ...propsSystem };
2768
2767
  }, tup(listSystem, listComponentPropsSystem));
2769
- const DefaultScrollSeekPlaceholder$1 = ({ height }) => /* @__PURE__ */ jsx("div", { style: { height } });
2768
+ const DefaultScrollSeekPlaceholder$1 = ({ height }) => /* @__PURE__ */ React.createElement("div", { style: { height } });
2770
2769
  const GROUP_STYLE = { position: positionStickyCssValue(), zIndex: 1, overflowAnchor: "none" };
2771
2770
  const ITEM_STYLE = { overflowAnchor: "none" };
2772
- const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = false }) {
2771
+ const Items$1 = /* @__PURE__ */ React.memo(function VirtuosoItems({ showTopList = false }) {
2773
2772
  const listState = useEmitterValue$2("listState");
2774
2773
  const sizeRanges = usePublisher$2("sizeRanges");
2775
2774
  const useWindowScroll = useEmitterValue$2("useWindowScroll");
@@ -2793,7 +2792,7 @@ const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = fals
2793
2792
  listGap,
2794
2793
  customScrollParent
2795
2794
  );
2796
- const [deviation, setDeviation] = useState(0);
2795
+ const [deviation, setDeviation] = React.useState(0);
2797
2796
  useEmitter$2("deviation", (value) => {
2798
2797
  if (deviation !== value) {
2799
2798
  setDeviation(value);
@@ -2815,9 +2814,9 @@ const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = fals
2815
2814
  marginTop: deviation
2816
2815
  };
2817
2816
  if (!showTopList && listState.totalCount === 0 && EmptyPlaceholder) {
2818
- return createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
2817
+ return React.createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
2819
2818
  }
2820
- return createElement(
2819
+ return React.createElement(
2821
2820
  ListComponent,
2822
2821
  {
2823
2822
  ...contextPropIfNotDomElement(ListComponent, context),
@@ -2829,7 +2828,7 @@ const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = fals
2829
2828
  const index = item.originalIndex;
2830
2829
  const key = computeItemKey(index + listState.firstItemIndex, item.data, context);
2831
2830
  if (isSeeking) {
2832
- return createElement(ScrollSeekPlaceholder, {
2831
+ return React.createElement(ScrollSeekPlaceholder, {
2833
2832
  ...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
2834
2833
  key,
2835
2834
  index: item.index,
@@ -2839,7 +2838,7 @@ const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = fals
2839
2838
  });
2840
2839
  }
2841
2840
  if (item.type === "group") {
2842
- return createElement(
2841
+ return React.createElement(
2843
2842
  GroupComponent,
2844
2843
  {
2845
2844
  ...contextPropIfNotDomElement(GroupComponent, context),
@@ -2852,7 +2851,7 @@ const Items$1 = /* @__PURE__ */ memo(function VirtuosoItems({ showTopList = fals
2852
2851
  groupContent(item.index)
2853
2852
  );
2854
2853
  } else {
2855
- return createElement(
2854
+ return React.createElement(
2856
2855
  ItemComponent,
2857
2856
  {
2858
2857
  ...contextPropIfNotDomElement(ItemComponent, context),
@@ -2895,24 +2894,24 @@ function contextPropIfNotDomElement(element, context) {
2895
2894
  }
2896
2895
  return { context };
2897
2896
  }
2898
- const Header$1 = /* @__PURE__ */ memo(function VirtuosoHeader() {
2897
+ const Header$1 = /* @__PURE__ */ React.memo(function VirtuosoHeader() {
2899
2898
  const Header2 = useEmitterValue$2("HeaderComponent");
2900
2899
  const headerHeight = usePublisher$2("headerHeight");
2901
2900
  const headerFooterTag = useEmitterValue$2("headerFooterTag");
2902
2901
  const ref = useSize((el) => headerHeight(correctItemSize(el, "height")));
2903
2902
  const context = useEmitterValue$2("context");
2904
- return Header2 ? createElement(headerFooterTag, { ref }, createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
2903
+ return Header2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
2905
2904
  });
2906
- const Footer$1 = /* @__PURE__ */ memo(function VirtuosoFooter() {
2905
+ const Footer$1 = /* @__PURE__ */ React.memo(function VirtuosoFooter() {
2907
2906
  const Footer2 = useEmitterValue$2("FooterComponent");
2908
2907
  const footerHeight = usePublisher$2("footerHeight");
2909
2908
  const headerFooterTag = useEmitterValue$2("headerFooterTag");
2910
2909
  const ref = useSize((el) => footerHeight(correctItemSize(el, "height")));
2911
2910
  const context = useEmitterValue$2("context");
2912
- return Footer2 ? createElement(headerFooterTag, { ref }, createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
2911
+ return Footer2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
2913
2912
  });
2914
2913
  function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, useEmitterValue: useEmitterValue2 }) {
2915
- const Scroller2 = memo(function VirtuosoScroller({ style, children, ...props }) {
2914
+ const Scroller2 = React.memo(function VirtuosoScroller({ style, children, ...props }) {
2916
2915
  const scrollContainerStateCallback = usePublisher2("scrollContainerState");
2917
2916
  const ScrollerComponent = useEmitterValue2("ScrollerComponent");
2918
2917
  const smoothScrollTargetReached = usePublisher2("smoothScrollTargetReached");
@@ -2926,7 +2925,7 @@ function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, u
2926
2925
  );
2927
2926
  useEmitter2("scrollTo", scrollToCallback);
2928
2927
  useEmitter2("scrollBy", scrollByCallback);
2929
- return createElement(
2928
+ return React.createElement(
2930
2929
  ScrollerComponent,
2931
2930
  {
2932
2931
  ref: scrollerRef,
@@ -2943,7 +2942,7 @@ function buildScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, u
2943
2942
  return Scroller2;
2944
2943
  }
2945
2944
  function buildWindowScroller({ usePublisher: usePublisher2, useEmitter: useEmitter2, useEmitterValue: useEmitterValue2 }) {
2946
- const Scroller2 = memo(function VirtuosoWindowScroller({ style, children, ...props }) {
2945
+ const Scroller2 = React.memo(function VirtuosoWindowScroller({ style, children, ...props }) {
2947
2946
  const scrollContainerStateCallback = usePublisher2("windowScrollContainerState");
2948
2947
  const ScrollerComponent = useEmitterValue2("ScrollerComponent");
2949
2948
  const smoothScrollTargetReached = usePublisher2("smoothScrollTargetReached");
@@ -2966,7 +2965,7 @@ function buildWindowScroller({ usePublisher: usePublisher2, useEmitter: useEmitt
2966
2965
  }, [scrollerRef, customScrollParent]);
2967
2966
  useEmitter2("windowScrollTo", scrollToCallback);
2968
2967
  useEmitter2("scrollBy", scrollByCallback);
2969
- return createElement(
2968
+ return React.createElement(
2970
2969
  ScrollerComponent,
2971
2970
  {
2972
2971
  style: { position: "relative", ...style, ...totalListHeight !== 0 ? { height: totalListHeight + deviation } : {} },
@@ -2980,53 +2979,46 @@ function buildWindowScroller({ usePublisher: usePublisher2, useEmitter: useEmitt
2980
2979
  return Scroller2;
2981
2980
  }
2982
2981
  const Viewport$2 = ({ children }) => {
2983
- const ctx = useContext(VirtuosoMockContext);
2982
+ const ctx = React.useContext(VirtuosoMockContext);
2984
2983
  const viewportHeight = usePublisher$2("viewportHeight");
2985
2984
  const fixedItemHeight = usePublisher$2("fixedItemHeight");
2986
2985
  const viewportRef = useSize(compose(viewportHeight, (el) => correctItemSize(el, "height")));
2987
- useEffect(() => {
2986
+ React.useEffect(() => {
2988
2987
  if (ctx) {
2989
2988
  viewportHeight(ctx.viewportHeight);
2990
2989
  fixedItemHeight(ctx.itemHeight);
2991
2990
  }
2992
2991
  }, [ctx, viewportHeight, fixedItemHeight]);
2993
- return /* @__PURE__ */ jsx("div", { style: viewportStyle, ref: viewportRef, "data-viewport-type": "element", children });
2992
+ return /* @__PURE__ */ React.createElement("div", { style: viewportStyle, ref: viewportRef, "data-viewport-type": "element" }, children);
2994
2993
  };
2995
2994
  const WindowViewport$2 = ({ children }) => {
2996
- const ctx = useContext(VirtuosoMockContext);
2995
+ const ctx = React.useContext(VirtuosoMockContext);
2997
2996
  const windowViewportRect = usePublisher$2("windowViewportRect");
2998
2997
  const fixedItemHeight = usePublisher$2("fixedItemHeight");
2999
2998
  const customScrollParent = useEmitterValue$2("customScrollParent");
3000
2999
  const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3001
- useEffect(() => {
3000
+ React.useEffect(() => {
3002
3001
  if (ctx) {
3003
3002
  fixedItemHeight(ctx.itemHeight);
3004
3003
  windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: 100 });
3005
3004
  }
3006
3005
  }, [ctx, windowViewportRect, fixedItemHeight]);
3007
- return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle, "data-viewport-type": "window", children });
3006
+ return /* @__PURE__ */ React.createElement("div", { ref: viewportRef, style: viewportStyle, "data-viewport-type": "window" }, children);
3008
3007
  };
3009
3008
  const TopItemListContainer = ({ children }) => {
3010
3009
  const TopItemList = useEmitterValue$2("TopItemListComponent");
3011
3010
  const headerHeight = useEmitterValue$2("headerHeight");
3012
3011
  const style = { ...topItemListStyle, marginTop: `${headerHeight}px` };
3013
3012
  const context = useEmitterValue$2("context");
3014
- return createElement(TopItemList || "div", { style, context }, children);
3013
+ return React.createElement(TopItemList || "div", { style, context }, children);
3015
3014
  };
3016
- const ListRoot = /* @__PURE__ */ memo(function VirtuosoRoot(props) {
3015
+ const ListRoot = /* @__PURE__ */ React.memo(function VirtuosoRoot(props) {
3017
3016
  const useWindowScroll = useEmitterValue$2("useWindowScroll");
3018
3017
  const showTopList = useEmitterValue$2("topItemsIndexes").length > 0;
3019
3018
  const customScrollParent = useEmitterValue$2("customScrollParent");
3020
3019
  const TheScroller = customScrollParent || useWindowScroll ? WindowScroller$2 : Scroller$2;
3021
3020
  const TheViewport = customScrollParent || useWindowScroll ? WindowViewport$2 : Viewport$2;
3022
- return /* @__PURE__ */ jsxs(TheScroller, { ...props, children: [
3023
- showTopList && /* @__PURE__ */ jsx(TopItemListContainer, { children: /* @__PURE__ */ jsx(Items$1, { showTopList: true }) }),
3024
- /* @__PURE__ */ jsxs(TheViewport, { children: [
3025
- /* @__PURE__ */ jsx(Header$1, {}),
3026
- /* @__PURE__ */ jsx(Items$1, {}),
3027
- /* @__PURE__ */ jsx(Footer$1, {})
3028
- ] })
3029
- ] });
3021
+ return /* @__PURE__ */ React.createElement(TheScroller, { ...props }, showTopList && /* @__PURE__ */ React.createElement(TopItemListContainer, null, /* @__PURE__ */ React.createElement(Items$1, { showTopList: true })), /* @__PURE__ */ React.createElement(TheViewport, null, /* @__PURE__ */ React.createElement(Header$1, null), /* @__PURE__ */ React.createElement(Items$1, null), /* @__PURE__ */ React.createElement(Footer$1, null)));
3030
3022
  });
3031
3023
  const {
3032
3024
  Component: List,
@@ -3393,7 +3385,7 @@ const gridComponentPropsSystem = /* @__PURE__ */ system(() => {
3393
3385
  const combinedSystem$1 = /* @__PURE__ */ system(([gridSystem2, gridComponentPropsSystem2]) => {
3394
3386
  return { ...gridSystem2, ...gridComponentPropsSystem2 };
3395
3387
  }, tup(gridSystem, gridComponentPropsSystem));
3396
- const GridItems = /* @__PURE__ */ memo(function GridItems2() {
3388
+ const GridItems = /* @__PURE__ */ React.memo(function GridItems2() {
3397
3389
  const gridState = useEmitterValue$1("gridState");
3398
3390
  const listClassName = useEmitterValue$1("listClassName");
3399
3391
  const itemClassName = useEmitterValue$1("itemClassName");
@@ -3420,7 +3412,7 @@ const GridItems = /* @__PURE__ */ memo(function GridItems2() {
3420
3412
  column: resolveGapValue("column-gap", getComputedStyle(el).columnGap, log)
3421
3413
  });
3422
3414
  });
3423
- return createElement(
3415
+ return React.createElement(
3424
3416
  ListComponent,
3425
3417
  {
3426
3418
  ref: listRef,
@@ -3431,13 +3423,13 @@ const GridItems = /* @__PURE__ */ memo(function GridItems2() {
3431
3423
  },
3432
3424
  gridState.items.map((item) => {
3433
3425
  const key = computeItemKey(item.index, item.data, context);
3434
- return isSeeking ? createElement(ScrollSeekPlaceholder, {
3426
+ return isSeeking ? React.createElement(ScrollSeekPlaceholder, {
3435
3427
  key,
3436
3428
  ...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
3437
3429
  index: item.index,
3438
3430
  height: gridState.itemHeight,
3439
3431
  width: gridState.itemWidth
3440
- }) : createElement(
3432
+ }) : React.createElement(
3441
3433
  ItemComponent,
3442
3434
  { ...contextPropIfNotDomElement(ItemComponent, context), className: itemClassName, "data-index": item.index, key },
3443
3435
  itemContent(item.index, item.data, context)
@@ -3445,61 +3437,57 @@ const GridItems = /* @__PURE__ */ memo(function GridItems2() {
3445
3437
  })
3446
3438
  );
3447
3439
  });
3448
- const Header = memo(function VirtuosoHeader2() {
3440
+ const Header = React.memo(function VirtuosoHeader2() {
3449
3441
  const Header2 = useEmitterValue$1("HeaderComponent");
3450
3442
  const headerHeight = usePublisher$1("headerHeight");
3451
3443
  const headerFooterTag = useEmitterValue$1("headerFooterTag");
3452
3444
  const ref = useSize((el) => headerHeight(correctItemSize(el, "height")));
3453
3445
  const context = useEmitterValue$1("context");
3454
- return Header2 ? createElement(headerFooterTag, { ref }, createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
3446
+ return Header2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Header2, contextPropIfNotDomElement(Header2, context))) : null;
3455
3447
  });
3456
- const Footer = memo(function VirtuosoGridFooter() {
3448
+ const Footer = React.memo(function VirtuosoGridFooter() {
3457
3449
  const Footer2 = useEmitterValue$1("FooterComponent");
3458
3450
  const footerHeight = usePublisher$1("footerHeight");
3459
3451
  const headerFooterTag = useEmitterValue$1("headerFooterTag");
3460
3452
  const ref = useSize((el) => footerHeight(correctItemSize(el, "height")));
3461
3453
  const context = useEmitterValue$1("context");
3462
- return Footer2 ? createElement(headerFooterTag, { ref }, createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
3454
+ return Footer2 ? React.createElement(headerFooterTag, { ref }, React.createElement(Footer2, contextPropIfNotDomElement(Footer2, context))) : null;
3463
3455
  });
3464
3456
  const Viewport$1 = ({ children }) => {
3465
- const ctx = useContext(VirtuosoGridMockContext);
3457
+ const ctx = React.useContext(VirtuosoGridMockContext);
3466
3458
  const itemDimensions = usePublisher$1("itemDimensions");
3467
3459
  const viewportDimensions = usePublisher$1("viewportDimensions");
3468
3460
  const viewportRef = useSize((el) => {
3469
3461
  viewportDimensions(el.getBoundingClientRect());
3470
3462
  });
3471
- useEffect(() => {
3463
+ React.useEffect(() => {
3472
3464
  if (ctx) {
3473
3465
  viewportDimensions({ height: ctx.viewportHeight, width: ctx.viewportWidth });
3474
3466
  itemDimensions({ height: ctx.itemHeight, width: ctx.itemWidth });
3475
3467
  }
3476
3468
  }, [ctx, viewportDimensions, itemDimensions]);
3477
- return /* @__PURE__ */ jsx("div", { style: viewportStyle, ref: viewportRef, children });
3469
+ return /* @__PURE__ */ React.createElement("div", { style: viewportStyle, ref: viewportRef }, children);
3478
3470
  };
3479
3471
  const WindowViewport$1 = ({ children }) => {
3480
- const ctx = useContext(VirtuosoGridMockContext);
3472
+ const ctx = React.useContext(VirtuosoGridMockContext);
3481
3473
  const windowViewportRect = usePublisher$1("windowViewportRect");
3482
3474
  const itemDimensions = usePublisher$1("itemDimensions");
3483
3475
  const customScrollParent = useEmitterValue$1("customScrollParent");
3484
3476
  const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3485
- useEffect(() => {
3477
+ React.useEffect(() => {
3486
3478
  if (ctx) {
3487
3479
  itemDimensions({ height: ctx.itemHeight, width: ctx.itemWidth });
3488
3480
  windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: ctx.viewportWidth });
3489
3481
  }
3490
3482
  }, [ctx, windowViewportRect, itemDimensions]);
3491
- return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle, children });
3483
+ return /* @__PURE__ */ React.createElement("div", { ref: viewportRef, style: viewportStyle }, children);
3492
3484
  };
3493
- const GridRoot = /* @__PURE__ */ memo(function GridRoot2({ ...props }) {
3485
+ const GridRoot = /* @__PURE__ */ React.memo(function GridRoot2({ ...props }) {
3494
3486
  const useWindowScroll = useEmitterValue$1("useWindowScroll");
3495
3487
  const customScrollParent = useEmitterValue$1("customScrollParent");
3496
3488
  const TheScroller = customScrollParent || useWindowScroll ? WindowScroller$1 : Scroller$1;
3497
3489
  const TheViewport = customScrollParent || useWindowScroll ? WindowViewport$1 : Viewport$1;
3498
- return /* @__PURE__ */ jsx(TheScroller, { ...props, children: /* @__PURE__ */ jsxs(TheViewport, { children: [
3499
- /* @__PURE__ */ jsx(Header, {}),
3500
- /* @__PURE__ */ jsx(GridItems, {}),
3501
- /* @__PURE__ */ jsx(Footer, {})
3502
- ] }) });
3490
+ return /* @__PURE__ */ React.createElement(TheScroller, { ...props }, /* @__PURE__ */ React.createElement(TheViewport, null, /* @__PURE__ */ React.createElement(Header, null), /* @__PURE__ */ React.createElement(GridItems, null), /* @__PURE__ */ React.createElement(Footer, null)));
3503
3491
  });
3504
3492
  const {
3505
3493
  Component: Grid,
@@ -3555,10 +3543,7 @@ function resolveGapValue(property, value, log) {
3555
3543
  }
3556
3544
  const VirtuosoGrid = Grid;
3557
3545
  const tableComponentPropsSystem = /* @__PURE__ */ system(() => {
3558
- const itemContent = statefulStream((index) => /* @__PURE__ */ jsxs("td", { children: [
3559
- "Item $",
3560
- index
3561
- ] }));
3546
+ const itemContent = statefulStream((index) => /* @__PURE__ */ React.createElement("td", null, "Item $", index));
3562
3547
  const context = statefulStream(null);
3563
3548
  const fixedHeaderContent = statefulStream(null);
3564
3549
  const fixedFooterContent = statefulStream(null);
@@ -3597,9 +3582,9 @@ const tableComponentPropsSystem = /* @__PURE__ */ system(() => {
3597
3582
  const combinedSystem = /* @__PURE__ */ system(([listSystem2, propsSystem]) => {
3598
3583
  return { ...listSystem2, ...propsSystem };
3599
3584
  }, tup(listSystem, tableComponentPropsSystem));
3600
- const DefaultScrollSeekPlaceholder = ({ height }) => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: { height } }) });
3601
- const DefaultFillerRow = ({ height }) => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { style: { height, padding: 0, border: 0 } }) });
3602
- const Items = /* @__PURE__ */ memo(function VirtuosoItems2() {
3585
+ const DefaultScrollSeekPlaceholder = ({ height }) => /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", { style: { height } }));
3586
+ const DefaultFillerRow = ({ height }) => /* @__PURE__ */ React.createElement("tr", null, /* @__PURE__ */ React.createElement("td", { style: { height, padding: 0, border: 0 } }));
3587
+ const Items = /* @__PURE__ */ React.memo(function VirtuosoItems2() {
3603
3588
  const listState = useEmitterValue("listState");
3604
3589
  const sizeRanges = usePublisher("sizeRanges");
3605
3590
  const useWindowScroll = useEmitterValue("useWindowScroll");
@@ -3620,7 +3605,7 @@ const Items = /* @__PURE__ */ memo(function VirtuosoItems2() {
3620
3605
  void 0,
3621
3606
  customScrollParent
3622
3607
  );
3623
- const [deviation, setDeviation] = useState(0);
3608
+ const [deviation, setDeviation] = React.useState(0);
3624
3609
  useEmitter("deviation", (value) => {
3625
3610
  if (deviation !== value) {
3626
3611
  ref.current.style.marginTop = `${value}px`;
@@ -3639,17 +3624,17 @@ const Items = /* @__PURE__ */ memo(function VirtuosoItems2() {
3639
3624
  const statefulTotalCount = useEmitterValue("statefulTotalCount");
3640
3625
  const context = useEmitterValue("context");
3641
3626
  if (statefulTotalCount === 0 && EmptyPlaceholder) {
3642
- return createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
3627
+ return React.createElement(EmptyPlaceholder, contextPropIfNotDomElement(EmptyPlaceholder, context));
3643
3628
  }
3644
3629
  const paddingTop = listState.offsetTop + paddingTopAddition + deviation;
3645
3630
  const paddingBottom = listState.offsetBottom;
3646
- const paddingTopEl = paddingTop > 0 ? /* @__PURE__ */ jsx(FillerRow, { height: paddingTop, context }, "padding-top") : null;
3647
- const paddingBottomEl = paddingBottom > 0 ? /* @__PURE__ */ jsx(FillerRow, { height: paddingBottom, context }, "padding-bottom") : null;
3631
+ const paddingTopEl = paddingTop > 0 ? /* @__PURE__ */ React.createElement(FillerRow, { height: paddingTop, key: "padding-top", context }) : null;
3632
+ const paddingBottomEl = paddingBottom > 0 ? /* @__PURE__ */ React.createElement(FillerRow, { height: paddingBottom, key: "padding-bottom", context }) : null;
3648
3633
  const items = listState.items.map((item) => {
3649
3634
  const index = item.originalIndex;
3650
3635
  const key = computeItemKey(index + firstItemIndex, item.data, context);
3651
3636
  if (isSeeking) {
3652
- return createElement(ScrollSeekPlaceholder, {
3637
+ return React.createElement(ScrollSeekPlaceholder, {
3653
3638
  ...contextPropIfNotDomElement(ScrollSeekPlaceholder, context),
3654
3639
  key,
3655
3640
  index: item.index,
@@ -3657,7 +3642,7 @@ const Items = /* @__PURE__ */ memo(function VirtuosoItems2() {
3657
3642
  type: item.type || "item"
3658
3643
  });
3659
3644
  }
3660
- return createElement(
3645
+ return React.createElement(
3661
3646
  TableRowComponent,
3662
3647
  {
3663
3648
  ...contextPropIfNotDomElement(TableRowComponent, context),
@@ -3671,40 +3656,40 @@ const Items = /* @__PURE__ */ memo(function VirtuosoItems2() {
3671
3656
  itemContent(item.index, item.data, context)
3672
3657
  );
3673
3658
  });
3674
- return createElement(
3659
+ return React.createElement(
3675
3660
  TableBodyComponent,
3676
3661
  { ref: callbackRef, "data-test-id": "virtuoso-item-list", ...contextPropIfNotDomElement(TableBodyComponent, context) },
3677
3662
  [paddingTopEl, ...items, paddingBottomEl]
3678
3663
  );
3679
3664
  });
3680
3665
  const Viewport = ({ children }) => {
3681
- const ctx = useContext(VirtuosoMockContext);
3666
+ const ctx = React.useContext(VirtuosoMockContext);
3682
3667
  const viewportHeight = usePublisher("viewportHeight");
3683
3668
  const fixedItemHeight = usePublisher("fixedItemHeight");
3684
3669
  const viewportRef = useSize(compose(viewportHeight, (el) => correctItemSize(el, "height")));
3685
- useEffect(() => {
3670
+ React.useEffect(() => {
3686
3671
  if (ctx) {
3687
3672
  viewportHeight(ctx.viewportHeight);
3688
3673
  fixedItemHeight(ctx.itemHeight);
3689
3674
  }
3690
3675
  }, [ctx, viewportHeight, fixedItemHeight]);
3691
- return /* @__PURE__ */ jsx("div", { style: viewportStyle, ref: viewportRef, "data-viewport-type": "element", children });
3676
+ return /* @__PURE__ */ React.createElement("div", { style: viewportStyle, ref: viewportRef, "data-viewport-type": "element" }, children);
3692
3677
  };
3693
3678
  const WindowViewport = ({ children }) => {
3694
- const ctx = useContext(VirtuosoMockContext);
3679
+ const ctx = React.useContext(VirtuosoMockContext);
3695
3680
  const windowViewportRect = usePublisher("windowViewportRect");
3696
3681
  const fixedItemHeight = usePublisher("fixedItemHeight");
3697
3682
  const customScrollParent = useEmitterValue("customScrollParent");
3698
3683
  const viewportRef = useWindowViewportRectRef(windowViewportRect, customScrollParent);
3699
- useEffect(() => {
3684
+ React.useEffect(() => {
3700
3685
  if (ctx) {
3701
3686
  fixedItemHeight(ctx.itemHeight);
3702
3687
  windowViewportRect({ offsetTop: 0, visibleHeight: ctx.viewportHeight, visibleWidth: 100 });
3703
3688
  }
3704
3689
  }, [ctx, windowViewportRect, fixedItemHeight]);
3705
- return /* @__PURE__ */ jsx("div", { ref: viewportRef, style: viewportStyle, "data-viewport-type": "window", children });
3690
+ return /* @__PURE__ */ React.createElement("div", { ref: viewportRef, style: viewportStyle, "data-viewport-type": "window" }, children);
3706
3691
  };
3707
- const TableRoot = /* @__PURE__ */ memo(function TableVirtuosoRoot(props) {
3692
+ const TableRoot = /* @__PURE__ */ React.memo(function TableVirtuosoRoot(props) {
3708
3693
  const useWindowScroll = useEmitterValue("useWindowScroll");
3709
3694
  const customScrollParent = useEmitterValue("customScrollParent");
3710
3695
  const fixedHeaderHeight = usePublisher("fixedHeaderHeight");
@@ -3719,7 +3704,7 @@ const TableRoot = /* @__PURE__ */ memo(function TableVirtuosoRoot(props) {
3719
3704
  const TheTable = useEmitterValue("TableComponent");
3720
3705
  const TheTHead = useEmitterValue("TableHeadComponent");
3721
3706
  const TheTFoot = useEmitterValue("TableFooterComponent");
3722
- const theHead = fixedHeaderContent ? createElement(
3707
+ const theHead = fixedHeaderContent ? React.createElement(
3723
3708
  TheTHead,
3724
3709
  {
3725
3710
  key: "TableHead",
@@ -3729,7 +3714,7 @@ const TableRoot = /* @__PURE__ */ memo(function TableVirtuosoRoot(props) {
3729
3714
  },
3730
3715
  fixedHeaderContent()
3731
3716
  ) : null;
3732
- const theFoot = fixedFooterContent ? createElement(
3717
+ const theFoot = fixedFooterContent ? React.createElement(
3733
3718
  TheTFoot,
3734
3719
  {
3735
3720
  key: "TableFoot",
@@ -3739,11 +3724,11 @@ const TableRoot = /* @__PURE__ */ memo(function TableVirtuosoRoot(props) {
3739
3724
  },
3740
3725
  fixedFooterContent()
3741
3726
  ) : null;
3742
- return /* @__PURE__ */ jsx(TheScroller, { ...props, children: /* @__PURE__ */ jsx(TheViewport, { children: createElement(TheTable, { style: { borderSpacing: 0 }, ...contextPropIfNotDomElement(TheTable, context) }, [
3727
+ return /* @__PURE__ */ React.createElement(TheScroller, { ...props }, /* @__PURE__ */ React.createElement(TheViewport, null, React.createElement(TheTable, { style: { borderSpacing: 0 }, ...contextPropIfNotDomElement(TheTable, context) }, [
3743
3728
  theHead,
3744
- /* @__PURE__ */ jsx(Items, {}, "TableBody"),
3729
+ /* @__PURE__ */ React.createElement(Items, { key: "TableBody" }),
3745
3730
  theFoot
3746
- ]) }) });
3731
+ ])));
3747
3732
  });
3748
3733
  const {
3749
3734
  Component: Table,
@@ -27,7 +27,7 @@
27
27
  *
28
28
  * @packageDocumentation
29
29
  */
30
- import { ComponentType, ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
30
+ import React from 'react';
31
31
  import * as u from '../urx';
32
32
  import type { Emitter, Publisher, AnySystemSpec, SR, Stream } from '../urx';
33
33
  /** @internal */
@@ -86,7 +86,7 @@ export type MethodsFromPropMap<E extends AnySystemSpec, M extends SystemPropsMap
86
86
  *
87
87
  * @typeParam T the type of the component
88
88
  */
89
- export type RefHandle<T> = T extends ForwardRefExoticComponent<RefAttributes<infer Handle>> ? Handle : never;
89
+ export type RefHandle<T> = T extends React.ForwardRefExoticComponent<React.RefAttributes<infer Handle>> ? Handle : never;
90
90
  /**
91
91
  * Converts a system spec to React component by mapping the system streams to component properties, events and methods. Returns hooks for querying and modifying
92
92
  * the system streams from the component's child components.
@@ -101,9 +101,9 @@ export type RefHandle<T> = T extends ForwardRefExoticComponent<RefAttributes<inf
101
101
  * <hr />
102
102
  */
103
103
  export declare function systemToComponent<SS extends AnySystemSpec, M extends SystemPropsMap<SS>, S extends SR<SS>, R>(systemSpec: SS, map: M, Root?: R): {
104
- Component: ForwardRefExoticComponent<import("react").PropsWithoutRef<{ [K in Extract<keyof M["required"], string>]: M["required"][K] extends string ? ReturnType<SS["constructor"]>[M["required"][K]] extends Observable<infer R_1> ? R_1 : never : never; } & { [K_1 in Extract<keyof M["optional"], string>]?: (M["optional"][K_1] extends string ? ReturnType<SS["constructor"]>[M["optional"][K_1]] extends Observable<infer R_2> ? R_2 : never : never) | undefined; } & { [K_2 in Extract<keyof M["events"], string>]?: (M["events"][K_2] extends string ? ReturnType<SS["constructor"]>[M["events"][K_2]] extends Observable<infer R_3> ? (value: R_3) => void : never : never) | undefined; } & (R extends ComponentType<infer RP> ? RP : {
105
- children?: ReactNode;
106
- })> & RefAttributes<MethodsFromPropMap<SS, M>>>;
104
+ Component: React.ForwardRefExoticComponent<React.PropsWithoutRef<{ [K in Extract<keyof M["required"], string>]: M["required"][K] extends string ? ReturnType<SS["constructor"]>[M["required"][K]] extends Observable<infer R_1> ? R_1 : never : never; } & { [K_1 in Extract<keyof M["optional"], string>]?: (M["optional"][K_1] extends string ? ReturnType<SS["constructor"]>[M["optional"][K_1]] extends Observable<infer R_2> ? R_2 : never : never) | undefined; } & { [K_2 in Extract<keyof M["events"], string>]?: (M["events"][K_2] extends string ? ReturnType<SS["constructor"]>[M["events"][K_2]] extends Observable<infer R_3> ? (value: R_3) => void : never : never) | undefined; } & (R extends React.ComponentType<infer RP> ? RP : {
105
+ children?: React.ReactNode;
106
+ })> & React.RefAttributes<MethodsFromPropMap<SS, M>>>;
107
107
  usePublisher: <K_3 extends keyof S>(key: K_3) => (value: S[K_3] extends u.Stream<infer R_4> ? R_4 : never) => void;
108
108
  useEmitterValue: <K_4 extends keyof S, V = S[K_4] extends u.StatefulStream<infer R_5> ? R_5 : never>(key: K_4) => V;
109
109
  useEmitter: <K_5 extends keyof S, V_1 = S[K_5] extends u.Stream<infer R_6> ? R_6 : never>(key: K_5, callback: (value: V_1) => void) => void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Petyo Ivanov",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
- "version": "4.0.4",
6
+ "version": "4.0.6",
7
7
  "homepage": "https://virtuoso.dev/",
8
8
  "license": "MIT",
9
9
  "source": "src/index.tsx",
@@ -34,7 +34,7 @@
34
34
  "e2e": "playwright test",
35
35
  "lint": "eslint src test e2e --ext .ts,.tsx",
36
36
  "typecheck": "tsc --noEmit -p tsconfig.typecheck.json",
37
- "dev": "ladle serve",
37
+ "dev": "ladle serve --viteConfig ladle.vite.config.ts",
38
38
  "prepare": "pnpm run build && husky install",
39
39
  "semantic-release": "semantic-release"
40
40
  },