@react-aria/virtualizer 4.0.4 → 4.1.0

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.
@@ -40,10 +40,7 @@ function $00ca8c0b29e3e07c$var$ScrollView(props, ref) {
40
40
  role: "presentation",
41
41
  ...scrollViewProps,
42
42
  ref: ref
43
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).createElement("div", {
44
- role: "presentation",
45
- ...contentProps
46
- }, props.children));
43
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).createElement("div", contentProps, props.children));
47
44
  }
48
45
  const $00ca8c0b29e3e07c$export$5665e3d6be6adea = /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).forwardRef($00ca8c0b29e3e07c$var$ScrollView);
49
46
  function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
@@ -82,7 +79,7 @@ function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
82
79
  let now = Date.now();
83
80
  if (state.scrollEndTime <= now + 50) {
84
81
  state.scrollEndTime = now + 300;
85
- clearTimeout(state.scrollTimeout);
82
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
86
83
  state.scrollTimeout = setTimeout(()=>{
87
84
  state.isScrolling = false;
88
85
  setScrolling(false);
@@ -103,10 +100,9 @@ function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
103
100
  ]);
104
101
  // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.
105
102
  (0, $kvIfm$reactariautils.useEvent)(ref, 'scroll', onScroll);
106
- // eslint-disable-next-line arrow-body-style
107
103
  (0, $kvIfm$react.useEffect)(()=>{
108
104
  return ()=>{
109
- clearTimeout(state.scrollTimeout);
105
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
110
106
  if (state.isScrolling) window.dispatchEvent(new Event('tk.connect-observer'));
111
107
  };
112
108
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -114,7 +110,7 @@ function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
114
110
  let isUpdatingSize = (0, $kvIfm$react.useRef)(false);
115
111
  let updateSize = (0, $kvIfm$reactariautils.useEffectEvent)((flush)=>{
116
112
  let dom = ref.current;
117
- if (!dom && !isUpdatingSize.current) return;
113
+ if (!dom || isUpdatingSize.current) return;
118
114
  // Prevent reentrancy when resize observer fires, triggers re-layout that results in
119
115
  // content size update, causing below layout effect to fire. This avoids infinite loops.
120
116
  isUpdatingSize.current = true;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,aAAa;;;;;;;AA4Bb,SAAS,iCAAW,KAAsB,EAAE,GAAwC;IAClF,MAAM,CAAA,GAAA,kCAAW,EAAE;IACnB,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG,0CAAc,OAAO;IAE3D,qBACE,0DAAC;QAAI,MAAK;QAAgB,GAAG,eAAe;QAAE,KAAK;qBACjD,0DAAC;QAAI,MAAK;QAAgB,GAAG,YAAY;OACtC,MAAM,QAAQ;AAIvB;AAEA,MAAM,yDAAuB,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAGvC,SAAS,0CAAc,KAAsB,EAAE,GAAkC;IACtF,IAAI,eACF,WAAW,uBACX,mBAAmB,cACnB,UAAU,iBACV,aAAa,eACb,WAAW,mBACX,kBAAkB,QAClB,GAAG,YACJ,GAAG;IAEJ,IAAI,QAAQ,CAAA,GAAA,mBAAK,EAAE;QACjB,WAAW;QACX,YAAY;QACZ,eAAe;QACf,eAAe;QACf,OAAO;QACP,QAAQ;QACR,aAAa;IACf,GAAG,OAAO;IACV,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC3C,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE,CAAC;QAC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I,YAAY,MAAM,GAAG;QACnE,eAAe,cAAc,SAAS;QACtC,UAAU;QACV,GAAG,UAAU;IACf;IAEA,OAAO;QACL,iBAAiB;YACf,GAAG,UAAU;mBACb;QACF;QACA,cAAc;YACZ,MAAM;YACN,OAAO;QACT;IACF;AACF","sources":["packages/@react-aria/virtualizer/src/ScrollView.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n ForwardedRef,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useEffectEvent, useEvent, useLayoutEffect, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children?: ReactNode,\n innerStyle?: CSSProperties,\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {\n ref = useObjectRef(ref);\n let {scrollViewProps, contentProps} = useScrollView(props, ref);\n\n return (\n <div role=\"presentation\" {...scrollViewProps} ref={ref}>\n <div role=\"presentation\" {...contentProps}>\n {props.children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>) {\n let {\n contentSize,\n onVisibleRectChange,\n innerStyle,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n // Pause typekit MutationObserver during scrolling.\n window.dispatchEvent(new Event('tk.disconnect-observer'));\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n clearTimeout(state.scrollTimeout);\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n window.dispatchEvent(new Event('tk.connect-observer'));\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.\n useEvent(ref, 'scroll', onScroll);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(state.scrollTimeout);\n if (state.isScrolling) {\n window.dispatchEvent(new Event('tk.connect-observer'));\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let isUpdatingSize = useRef(false);\n let updateSize = useEffectEvent((flush: typeof flushSync) => {\n let dom = ref.current;\n if (!dom && !isUpdatingSize.current) {\n return;\n }\n\n // Prevent reentrancy when resize observer fires, triggers re-layout that results in\n // content size update, causing below layout effect to fire. This avoids infinite loops.\n isUpdatingSize.current = true;\n\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientHeight');\n let clientWidth = dom.clientWidth;\n let clientHeight = dom.clientHeight;\n let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;\n let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n });\n\n // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as\n // a result of the layout update. In this case, re-layout again to account for the\n // adjusted space. In very specific cases this might result in the scrollbars disappearing\n // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid\n // an infinite loop. This matches how browsers behavior with native CSS grid layout.\n if (!isTestEnv && clientWidth !== dom.clientWidth || clientHeight !== dom.clientHeight) {\n state.width = dom.clientWidth;\n state.height = dom.clientHeight;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n });\n }\n }\n\n isUpdatingSize.current = false;\n });\n\n // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.\n let lastContentSize = useRef<Size | null>(null);\n useLayoutEffect(() => {\n if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {\n // React doesn't allow flushSync inside effects, so queue a microtask.\n // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).\n // If we are in an `act` environment, update immediately without a microtask so you don't need\n // to mock timers in tests. In this case, the update is synchronous already.\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // @ts-ignore\n if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {\n updateSize(fn => fn());\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n let onResize = useCallback(() => {\n updateSize(flushSync);\n }, [updateSize]);\n\n // Watch border-box instead of of content-box so that we don't go into\n // an infinite loop when scrollbars appear or disappear.\n useResizeObserver({ref, box: 'border-box', onResize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical' || contentSize.width === state.width) {\n // Set overflow-x: hidden if content size is equal to the width of the scroll view.\n // This prevents horizontal scrollbars from flickering during resizing due to resize observer\n // firing slower than the frame rate, which may cause an infinite re-render loop.\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n innerStyle = {\n width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,\n height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,\n pointerEvents: isScrolling ? 'none' : 'auto',\n position: 'relative',\n ...innerStyle\n };\n\n return {\n scrollViewProps: {\n ...otherProps,\n style\n },\n contentProps: {\n role: 'presentation',\n style: innerStyle\n }\n };\n}\n"],"names":[],"version":3,"file":"ScrollView.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,a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aAAa;YACb,IAAI,OAAO,6BAA6B,YAAY,2BAA2B,OAAO,SAAS,aAC7F,WAAW,CAAA,KAAM;iBAEjB,eAAe,IAAM,WAAW,CAAA,GAAA,yBAAQ;;QAI5C,gBAAgB,OAAO,GAAG;IAC5B;IAEA,IAAI,WAAW,CAAA,GAAA,wBAAU,EAAE;QACzB,WAAW,CAAA,GAAA,yBAAQ;IACrB,GAAG;QAAC;KAAW;IAEf,sEAAsE;IACtE,wDAAwD;IACxD,CAAA,GAAA,uCAAgB,EAAE;aAAC;QAAK,KAAK;kBAAc;IAAQ;IAEnD,IAAI,QAA6B;QAC/B,iGAAiG;QACjG,SAAS;QACT,GAAG,WAAW,KAAK;IACrB;IAEA,IAAI,oBAAoB,cAAc;QACpC,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OAAO,IAAI,oBAAoB,cAAc,YAAY,KAAK,KAAK,MAAM,KAAK,EAAE;QAC9E,mFAAmF;QACnF,6FAA6F;QAC7F,iFAAiF;QACjF,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OACE,MAAM,QAAQ,GAAG;IAGnB,aAAa;QACX,OAAO,OAAO,QAAQ,CAAC,YAAY,KAAK,IAAI,YAAY,KAAK,GAAG;QAChE,QAAQ,OAAO,QAAQ,CAAC,YAAY,MAAM,IAAI,YAAY,MAAM,GAAG;QACnE,eAAe,cAAc,SAAS;QACtC,UAAU;QACV,GAAG,UAAU;IACf;IAEA,OAAO;QACL,iBAAiB;YACf,GAAG,UAAU;mBACb;QACF;QACA,cAAc;YACZ,MAAM;YACN,OAAO;QACT;IACF;AACF","sources":["packages/@react-aria/virtualizer/src/ScrollView.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n ForwardedRef,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useEffectEvent, useEvent, useLayoutEffect, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children?: ReactNode,\n innerStyle?: CSSProperties,\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {\n ref = useObjectRef(ref);\n let {scrollViewProps, contentProps} = useScrollView(props, ref);\n\n return (\n <div role=\"presentation\" {...scrollViewProps} ref={ref}>\n <div {...contentProps}>\n {props.children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>) {\n let {\n contentSize,\n onVisibleRectChange,\n innerStyle,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null as ReturnType<typeof setTimeout> | null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n // Pause typekit MutationObserver during scrolling.\n window.dispatchEvent(new Event('tk.disconnect-observer'));\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n if (state.scrollTimeout != null) {\n clearTimeout(state.scrollTimeout);\n }\n\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n window.dispatchEvent(new Event('tk.connect-observer'));\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.\n useEvent(ref, 'scroll', onScroll);\n\n \n useEffect(() => {\n return () => {\n if (state.scrollTimeout != null) {\n clearTimeout(state.scrollTimeout);\n }\n\n if (state.isScrolling) {\n window.dispatchEvent(new Event('tk.connect-observer'));\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let isUpdatingSize = useRef(false);\n let updateSize = useEffectEvent((flush: typeof flushSync) => {\n let dom = ref.current;\n if (!dom || isUpdatingSize.current) {\n return;\n }\n\n // Prevent reentrancy when resize observer fires, triggers re-layout that results in\n // content size update, causing below layout effect to fire. This avoids infinite loops.\n isUpdatingSize.current = true;\n\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientHeight');\n let clientWidth = dom.clientWidth;\n let clientHeight = dom.clientHeight;\n let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;\n let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n });\n\n // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as\n // a result of the layout update. In this case, re-layout again to account for the\n // adjusted space. In very specific cases this might result in the scrollbars disappearing\n // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid\n // an infinite loop. This matches how browsers behavior with native CSS grid layout.\n if (!isTestEnv && clientWidth !== dom.clientWidth || clientHeight !== dom.clientHeight) {\n state.width = dom.clientWidth;\n state.height = dom.clientHeight;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n });\n }\n }\n\n isUpdatingSize.current = false;\n });\n\n // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.\n let lastContentSize = useRef<Size | null>(null);\n useLayoutEffect(() => {\n if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {\n // React doesn't allow flushSync inside effects, so queue a microtask.\n // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).\n // If we are in an `act` environment, update immediately without a microtask so you don't need\n // to mock timers in tests. In this case, the update is synchronous already.\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // @ts-ignore\n if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {\n updateSize(fn => fn());\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n let onResize = useCallback(() => {\n updateSize(flushSync);\n }, [updateSize]);\n\n // Watch border-box instead of of content-box so that we don't go into\n // an infinite loop when scrollbars appear or disappear.\n useResizeObserver({ref, box: 'border-box', onResize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical' || contentSize.width === state.width) {\n // Set overflow-x: hidden if content size is equal to the width of the scroll view.\n // This prevents horizontal scrollbars from flickering during resizing due to resize observer\n // firing slower than the frame rate, which may cause an infinite re-render loop.\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n innerStyle = {\n width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,\n height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,\n pointerEvents: isScrolling ? 'none' : 'auto',\n position: 'relative',\n ...innerStyle\n };\n\n return {\n scrollViewProps: {\n ...otherProps,\n style\n },\n contentProps: {\n role: 'presentation',\n style: innerStyle\n }\n };\n}\n"],"names":[],"version":3,"file":"ScrollView.main.js.map"}
@@ -29,10 +29,7 @@ function $44a6ee657928b002$var$ScrollView(props, ref) {
29
29
  role: "presentation",
30
30
  ...scrollViewProps,
31
31
  ref: ref
32
- }, /*#__PURE__*/ (0, $f9kpT$react).createElement("div", {
33
- role: "presentation",
34
- ...contentProps
35
- }, props.children));
32
+ }, /*#__PURE__*/ (0, $f9kpT$react).createElement("div", contentProps, props.children));
36
33
  }
37
34
  const $44a6ee657928b002$export$5665e3d6be6adea = /*#__PURE__*/ (0, $f9kpT$react).forwardRef($44a6ee657928b002$var$ScrollView);
38
35
  function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
@@ -71,7 +68,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
71
68
  let now = Date.now();
72
69
  if (state.scrollEndTime <= now + 50) {
73
70
  state.scrollEndTime = now + 300;
74
- clearTimeout(state.scrollTimeout);
71
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
75
72
  state.scrollTimeout = setTimeout(()=>{
76
73
  state.isScrolling = false;
77
74
  setScrolling(false);
@@ -92,10 +89,9 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
92
89
  ]);
93
90
  // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.
94
91
  (0, $f9kpT$useEvent)(ref, 'scroll', onScroll);
95
- // eslint-disable-next-line arrow-body-style
96
92
  (0, $f9kpT$useEffect)(()=>{
97
93
  return ()=>{
98
- clearTimeout(state.scrollTimeout);
94
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
99
95
  if (state.isScrolling) window.dispatchEvent(new Event('tk.connect-observer'));
100
96
  };
101
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -103,7 +99,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
103
99
  let isUpdatingSize = (0, $f9kpT$useRef)(false);
104
100
  let updateSize = (0, $f9kpT$useEffectEvent)((flush)=>{
105
101
  let dom = ref.current;
106
- if (!dom && !isUpdatingSize.current) return;
102
+ if (!dom || isUpdatingSize.current) return;
107
103
  // Prevent reentrancy when resize observer fires, triggers re-layout that results in
108
104
  // content size update, causing below layout effect to fire. This avoids infinite loops.
109
105
  isUpdatingSize.current = true;
@@ -29,10 +29,7 @@ function $44a6ee657928b002$var$ScrollView(props, ref) {
29
29
  role: "presentation",
30
30
  ...scrollViewProps,
31
31
  ref: ref
32
- }, /*#__PURE__*/ (0, $f9kpT$react).createElement("div", {
33
- role: "presentation",
34
- ...contentProps
35
- }, props.children));
32
+ }, /*#__PURE__*/ (0, $f9kpT$react).createElement("div", contentProps, props.children));
36
33
  }
37
34
  const $44a6ee657928b002$export$5665e3d6be6adea = /*#__PURE__*/ (0, $f9kpT$react).forwardRef($44a6ee657928b002$var$ScrollView);
38
35
  function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
@@ -71,7 +68,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
71
68
  let now = Date.now();
72
69
  if (state.scrollEndTime <= now + 50) {
73
70
  state.scrollEndTime = now + 300;
74
- clearTimeout(state.scrollTimeout);
71
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
75
72
  state.scrollTimeout = setTimeout(()=>{
76
73
  state.isScrolling = false;
77
74
  setScrolling(false);
@@ -92,10 +89,9 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
92
89
  ]);
93
90
  // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.
94
91
  (0, $f9kpT$useEvent)(ref, 'scroll', onScroll);
95
- // eslint-disable-next-line arrow-body-style
96
92
  (0, $f9kpT$useEffect)(()=>{
97
93
  return ()=>{
98
- clearTimeout(state.scrollTimeout);
94
+ if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
99
95
  if (state.isScrolling) window.dispatchEvent(new Event('tk.connect-observer'));
100
96
  };
101
97
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -103,7 +99,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
103
99
  let isUpdatingSize = (0, $f9kpT$useRef)(false);
104
100
  let updateSize = (0, $f9kpT$useEffectEvent)((flush)=>{
105
101
  let dom = ref.current;
106
- if (!dom && !isUpdatingSize.current) return;
102
+ if (!dom || isUpdatingSize.current) return;
107
103
  // Prevent reentrancy when resize observer fires, triggers re-layout that results in
108
104
  // content size update, causing below layout effect to fire. This avoids infinite loops.
109
105
  isUpdatingSize.current = true;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAED,aAAa;;;;;;;AA4Bb,SAAS,iCAAW,KAAsB,EAAE,GAAwC;IAClF,MAAM,CAAA,GAAA,mBAAW,EAAE;IACnB,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AQ;;QAI5C,gBAAgB,OAAO,GAAG;IAC5B;IAEA,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QACzB,WAAW,CAAA,GAAA,gBAAQ;IACrB,GAAG;QAAC;KAAW;IAEf,sEAAsE;IACtE,wDAAwD;IACxD,CAAA,GAAA,wBAAgB,EAAE;aAAC;QAAK,KAAK;kBAAc;IAAQ;IAEnD,IAAI,QAA6B;QAC/B,iGAAiG;QACjG,SAAS;QACT,GAAG,WAAW,KAAK;IACrB;IAEA,IAAI,oBAAoB,cAAc;QACpC,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OAAO,IAAI,oBAAoB,cAAc,YAAY,KAAK,KAAK,MAAM,KAAK,EAAE;QAC9E,mFAAmF;QACnF,6FAA6F;QAC7F,iFAAiF;QACjF,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OACE,MAAM,QAAQ,GAAG;IAGnB,aAAa;QACX,OAAO,OAAO,QAAQ,CAAC,YAAY,KAAK,IAAI,YAAY,KAAK,GAAG;QAChE,QAAQ,OAAO,QAAQ,CAAC,YAAY,MAAM,IAAI,YAAY,MAAM,GAAG;QACnE,eAAe,cAAc,SAAS;QACtC,UAAU;QACV,GAAG,UAAU;IACf;IAEA,OAAO;QACL,iBAAiB;YACf,GAAG,UAAU;mBACb;QACF;QACA,cAAc;YACZ,MAAM;YACN,OAAO;QACT;IACF;AACF","sources":["packages/@react-aria/virtualizer/src/ScrollView.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n ForwardedRef,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useEffectEvent, useEvent, useLayoutEffect, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children?: ReactNode,\n innerStyle?: CSSProperties,\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {\n ref = useObjectRef(ref);\n let {scrollViewProps, contentProps} = useScrollView(props, ref);\n\n return (\n <div role=\"presentation\" {...scrollViewProps} ref={ref}>\n <div role=\"presentation\" {...contentProps}>\n {props.children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>) {\n let {\n contentSize,\n onVisibleRectChange,\n innerStyle,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n // Pause typekit MutationObserver during scrolling.\n window.dispatchEvent(new Event('tk.disconnect-observer'));\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n clearTimeout(state.scrollTimeout);\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n window.dispatchEvent(new Event('tk.connect-observer'));\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.\n useEvent(ref, 'scroll', onScroll);\n\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n clearTimeout(state.scrollTimeout);\n if (state.isScrolling) {\n window.dispatchEvent(new Event('tk.connect-observer'));\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let isUpdatingSize = useRef(false);\n let updateSize = useEffectEvent((flush: typeof flushSync) => {\n let dom = ref.current;\n if (!dom && !isUpdatingSize.current) {\n return;\n }\n\n // Prevent reentrancy when resize observer fires, triggers re-layout that results in\n // content size update, causing below layout effect to fire. This avoids infinite loops.\n isUpdatingSize.current = true;\n\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientHeight');\n let clientWidth = dom.clientWidth;\n let clientHeight = dom.clientHeight;\n let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;\n let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n });\n\n // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as\n // a result of the layout update. In this case, re-layout again to account for the\n // adjusted space. In very specific cases this might result in the scrollbars disappearing\n // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid\n // an infinite loop. This matches how browsers behavior with native CSS grid layout.\n if (!isTestEnv && clientWidth !== dom.clientWidth || clientHeight !== dom.clientHeight) {\n state.width = dom.clientWidth;\n state.height = dom.clientHeight;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n });\n }\n }\n\n isUpdatingSize.current = false;\n });\n\n // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.\n let lastContentSize = useRef<Size | null>(null);\n useLayoutEffect(() => {\n if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {\n // React doesn't allow flushSync inside effects, so queue a microtask.\n // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).\n // If we are in an `act` environment, update immediately without a microtask so you don't need\n // to mock timers in tests. In this case, the update is synchronous already.\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // @ts-ignore\n if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {\n updateSize(fn => fn());\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n let onResize = useCallback(() => {\n updateSize(flushSync);\n }, [updateSize]);\n\n // Watch border-box instead of of content-box so that we don't go into\n // an infinite loop when scrollbars appear or disappear.\n useResizeObserver({ref, box: 'border-box', onResize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical' || contentSize.width === state.width) {\n // Set overflow-x: hidden if content size is equal to the width of the scroll view.\n // This prevents horizontal scrollbars from flickering during resizing due to resize observer\n // firing slower than the frame rate, which may cause an infinite re-render loop.\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n innerStyle = {\n width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,\n height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,\n pointerEvents: isScrolling ? 'none' : 'auto',\n position: 'relative',\n ...innerStyle\n };\n\n return {\n scrollViewProps: {\n ...otherProps,\n style\n },\n contentProps: {\n role: 'presentation',\n style: innerStyle\n }\n };\n}\n"],"names":[],"version":3,"file":"ScrollView.module.js.map"}
1
+ {"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC,GAED,aAAa;;;;;;;AA4Bb,SAAS,iCAAW,KAAsB,EAAE,GAAwC;IAClF,MAAM,CAAA,GAAA,mBAAW,EAAE;IACnB,IAAI,mBAAC,eAAe,gBAAE,YAAY,EAAC,GAAG,0CAAc,OAAO;IAE3D,qBACE,gCAAC;QAAI,MAAK;QAAgB,GAAG,eAAe;QAAE,KAAK;qBACjD,gCAAC,OAAQ,cACN,MAAM,QAAQ;AAIvB;AAEA,MAAM,yDAAuB,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGvC,SAAS,0CAAc,KAAsB,EAAE,GAAkC;IACtF,IAAI,eACF,WAAW,uBACX,mBAAmB,cACnB,UAAU,iBACV,aAAa,eACb,WAAW,mBACX,kBAAkB,QAClB,GAAG,YACJ,GAAG;IAEJ,IAAI,QAAQ,CAAA,GAAA,aAAK,EAAE;QACjB,WAAW;QACX,YAA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KAAK,KAAK,MAAM,KAAK,EAAE;QAC9E,mFAAmF;QACnF,6FAA6F;QAC7F,iFAAiF;QACjF,MAAM,SAAS,GAAG;QAClB,MAAM,SAAS,GAAG;IACpB,OACE,MAAM,QAAQ,GAAG;IAGnB,aAAa;QACX,OAAO,OAAO,QAAQ,CAAC,YAAY,KAAK,IAAI,YAAY,KAAK,GAAG;QAChE,QAAQ,OAAO,QAAQ,CAAC,YAAY,MAAM,IAAI,YAAY,MAAM,GAAG;QACnE,eAAe,cAAc,SAAS;QACtC,UAAU;QACV,GAAG,UAAU;IACf;IAEA,OAAO;QACL,iBAAiB;YACf,GAAG,UAAU;mBACb;QACF;QACA,cAAc;YACZ,MAAM;YACN,OAAO;QACT;IACF;AACF","sources":["packages/@react-aria/virtualizer/src/ScrollView.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// @ts-ignore\nimport {flushSync} from 'react-dom';\nimport {getScrollLeft} from './utils';\nimport React, {\n CSSProperties,\n ForwardedRef,\n HTMLAttributes,\n ReactNode,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {Rect, Size} from '@react-stately/virtualizer';\nimport {useEffectEvent, useEvent, useLayoutEffect, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface ScrollViewProps extends HTMLAttributes<HTMLElement> {\n contentSize: Size,\n onVisibleRectChange: (rect: Rect) => void,\n children?: ReactNode,\n innerStyle?: CSSProperties,\n onScrollStart?: () => void,\n onScrollEnd?: () => void,\n scrollDirection?: 'horizontal' | 'vertical' | 'both'\n}\n\nfunction ScrollView(props: ScrollViewProps, ref: ForwardedRef<HTMLDivElement | null>) {\n ref = useObjectRef(ref);\n let {scrollViewProps, contentProps} = useScrollView(props, ref);\n\n return (\n <div role=\"presentation\" {...scrollViewProps} ref={ref}>\n <div {...contentProps}>\n {props.children}\n </div>\n </div>\n );\n}\n\nconst ScrollViewForwardRef = React.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>) {\n let {\n contentSize,\n onVisibleRectChange,\n innerStyle,\n onScrollStart,\n onScrollEnd,\n scrollDirection = 'both',\n ...otherProps\n } = props;\n\n let state = useRef({\n scrollTop: 0,\n scrollLeft: 0,\n scrollEndTime: 0,\n scrollTimeout: null as ReturnType<typeof setTimeout> | null,\n width: 0,\n height: 0,\n isScrolling: false\n }).current;\n let {direction} = useLocale();\n\n let [isScrolling, setScrolling] = useState(false);\n let onScroll = useCallback((e) => {\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (props.onScroll) {\n props.onScroll(e);\n }\n\n flushSync(() => {\n let scrollTop = e.currentTarget.scrollTop;\n let scrollLeft = getScrollLeft(e.currentTarget, direction);\n\n // Prevent rubber band scrolling from shaking when scrolling out of bounds\n state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));\n state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));\n\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n\n if (!state.isScrolling) {\n state.isScrolling = true;\n setScrolling(true);\n\n // Pause typekit MutationObserver during scrolling.\n window.dispatchEvent(new Event('tk.disconnect-observer'));\n if (onScrollStart) {\n onScrollStart();\n }\n }\n\n // So we don't constantly call clearTimeout and setTimeout,\n // keep track of the current timeout time and only reschedule\n // the timer when it is getting close.\n let now = Date.now();\n if (state.scrollEndTime <= now + 50) {\n state.scrollEndTime = now + 300;\n\n if (state.scrollTimeout != null) {\n clearTimeout(state.scrollTimeout);\n }\n\n state.scrollTimeout = setTimeout(() => {\n state.isScrolling = false;\n setScrolling(false);\n state.scrollTimeout = null;\n\n window.dispatchEvent(new Event('tk.connect-observer'));\n if (onScrollEnd) {\n onScrollEnd();\n }\n }, 300);\n }\n });\n }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]);\n\n // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.\n useEvent(ref, 'scroll', onScroll);\n\n \n useEffect(() => {\n return () => {\n if (state.scrollTimeout != null) {\n clearTimeout(state.scrollTimeout);\n }\n\n if (state.isScrolling) {\n window.dispatchEvent(new Event('tk.connect-observer'));\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n let isUpdatingSize = useRef(false);\n let updateSize = useEffectEvent((flush: typeof flushSync) => {\n let dom = ref.current;\n if (!dom || isUpdatingSize.current) {\n return;\n }\n\n // Prevent reentrancy when resize observer fires, triggers re-layout that results in\n // content size update, causing below layout effect to fire. This avoids infinite loops.\n isUpdatingSize.current = true;\n\n let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;\n let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth');\n let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientHeight');\n let clientWidth = dom.clientWidth;\n let clientHeight = dom.clientHeight;\n let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;\n let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;\n\n if (state.width !== w || state.height !== h) {\n state.width = w;\n state.height = h;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));\n });\n\n // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as\n // a result of the layout update. In this case, re-layout again to account for the\n // adjusted space. In very specific cases this might result in the scrollbars disappearing\n // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid\n // an infinite loop. This matches how browsers behavior with native CSS grid layout.\n if (!isTestEnv && clientWidth !== dom.clientWidth || clientHeight !== dom.clientHeight) {\n state.width = dom.clientWidth;\n state.height = dom.clientHeight;\n flush(() => {\n onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));\n });\n }\n }\n\n isUpdatingSize.current = false;\n });\n\n // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.\n let lastContentSize = useRef<Size | null>(null);\n useLayoutEffect(() => {\n if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {\n // React doesn't allow flushSync inside effects, so queue a microtask.\n // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).\n // If we are in an `act` environment, update immediately without a microtask so you don't need\n // to mock timers in tests. In this case, the update is synchronous already.\n // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.\n // https://github.com/reactwg/react-18/discussions/102\n // @ts-ignore\n if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {\n updateSize(fn => fn());\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n let onResize = useCallback(() => {\n updateSize(flushSync);\n }, [updateSize]);\n\n // Watch border-box instead of of content-box so that we don't go into\n // an infinite loop when scrollbars appear or disappear.\n useResizeObserver({ref, box: 'border-box', onResize});\n\n let style: React.CSSProperties = {\n // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.\n padding: 0,\n ...otherProps.style\n };\n\n if (scrollDirection === 'horizontal') {\n style.overflowX = 'auto';\n style.overflowY = 'hidden';\n } else if (scrollDirection === 'vertical' || contentSize.width === state.width) {\n // Set overflow-x: hidden if content size is equal to the width of the scroll view.\n // This prevents horizontal scrollbars from flickering during resizing due to resize observer\n // firing slower than the frame rate, which may cause an infinite re-render loop.\n style.overflowY = 'auto';\n style.overflowX = 'hidden';\n } else {\n style.overflow = 'auto';\n }\n\n innerStyle = {\n width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,\n height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,\n pointerEvents: isScrolling ? 'none' : 'auto',\n position: 'relative',\n ...innerStyle\n };\n\n return {\n scrollViewProps: {\n ...otherProps,\n style\n },\n contentProps: {\n role: 'presentation',\n style: innerStyle\n }\n };\n}\n"],"names":[],"version":3,"file":"ScrollView.module.js.map"}
@@ -29,19 +29,18 @@ $parcel$export(module.exports, "Virtualizer", () => $e1fb6f3669e1c329$export$89b
29
29
 
30
30
 
31
31
 
32
- function $e1fb6f3669e1c329$var$Virtualizer(props, ref) {
33
- let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
- isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
36
- let fallbackRef = (0, $knrtk$react.useRef)(undefined);
37
- ref = ref || fallbackRef;
32
+ function $e1fb6f3669e1c329$var$Virtualizer(props, forwardedRef) {
33
+ let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: isLoading, onLoadMore: onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
34
+ let ref = (0, $knrtk$reactariautils.useObjectRef)(forwardedRef);
38
35
  let state = (0, $knrtk$reactstatelyvirtualizer.useVirtualizerState)({
39
36
  layout: layout,
40
37
  collection: collection,
41
38
  renderView: renderView,
42
39
  onVisibleRectChange (rect) {
43
- ref.current.scrollLeft = rect.x;
44
- ref.current.scrollTop = rect.y;
40
+ if (ref.current) {
41
+ ref.current.scrollLeft = rect.x;
42
+ ref.current.scrollTop = rect.y;
43
+ }
45
44
  },
46
45
  persistedKeys: persistedKeys,
47
46
  layoutOptions: layoutOptions
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;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AAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,0DAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLoadMore} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n) => ReactElement;\n\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, ref: RefObject<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n scrollDirection,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>(undefined);\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n },\n persistedKeys,\n layoutOptions\n });\n\n useLoadMore({isLoading, onLoadMore, scrollOffset: 1}, ref);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n }, [state]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, {onVisibleRectChange})}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BD,SAAS,kCAAsD,KAAgC,EAAE,YAAiD;IAChJ,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,mBACV,eAAe,aACf,SAAS,cACT,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,kCAAW,EAAE;IAEvB,IAAI,QAAQ,CAAA,GAAA,kDAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,IAAI,OAAO,EAAE;gBACf,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;YAChC;QACF;uBACA;uBACA;IACF;IAEA,CAAA,GAAA,iCAAU,EAAE;mBAAC;oBAAW;QAAY,cAAc;IAAC,GAAG;IACtD,IAAI,sBAAsB,CAAA,GAAA,wBAAU,EAAE,CAAC;QACrC,MAAM,cAAc,CAAC;IACvB,GAAG;QAAC;KAAM;IAEV,qBACE,0DAAC,CAAA,GAAA,oCAAS;QACP,GAAG,CAAA,GAAA,gCAAS,EAAE,YAAY;iCAAC;QAAmB,EAAE;QACjD,KAAK;QACL,aAAa,MAAM,WAAW;QAC9B,eAAe,MAAM,cAAc;QACnC,aAAa,MAAM,YAAY;QAC/B,iBAAiB;OAChB,qCAAe,MAAM,MAAM,YAAY,EAAE,iBAAiB;AAGjE;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAGtC,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,0DAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLoadMore, useObjectRef} from '@react-aria/utils';\nimport React, {ForwardedRef, HTMLAttributes, ReactElement, ReactNode, useCallback} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n) => ReactElement | null;\n\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n scrollDirection,\n isLoading,\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let ref = useObjectRef(forwardedRef);\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n if (ref.current) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n },\n persistedKeys,\n layoutOptions\n });\n\n useLoadMore({isLoading, onLoadMore, scrollOffset: 1}, ref);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n }, [state]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, {onVisibleRectChange})}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo!}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.main.js.map"}
@@ -1,8 +1,8 @@
1
1
  import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea} from "./ScrollView.mjs";
2
2
  import {VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.mjs";
3
3
  import {useVirtualizerState as $9WwqA$useVirtualizerState} from "@react-stately/virtualizer";
4
- import {useLoadMore as $9WwqA$useLoadMore, mergeProps as $9WwqA$mergeProps} from "@react-aria/utils";
5
- import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback} from "react";
4
+ import {useObjectRef as $9WwqA$useObjectRef, useLoadMore as $9WwqA$useLoadMore, mergeProps as $9WwqA$mergeProps} from "@react-aria/utils";
5
+ import $9WwqA$react, {useCallback as $9WwqA$useCallback} from "react";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -19,19 +19,18 @@ import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback
19
19
 
20
20
 
21
21
 
22
- function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
23
- let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
26
- let fallbackRef = (0, $9WwqA$useRef)(undefined);
27
- ref = ref || fallbackRef;
22
+ function $6d0a5c394373ae64$var$Virtualizer(props, forwardedRef) {
23
+ let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: isLoading, onLoadMore: onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
24
+ let ref = (0, $9WwqA$useObjectRef)(forwardedRef);
28
25
  let state = (0, $9WwqA$useVirtualizerState)({
29
26
  layout: layout,
30
27
  collection: collection,
31
28
  renderView: renderView,
32
29
  onVisibleRectChange (rect) {
33
- ref.current.scrollLeft = rect.x;
34
- ref.current.scrollTop = rect.y;
30
+ if (ref.current) {
31
+ ref.current.scrollLeft = rect.x;
32
+ ref.current.scrollTop = rect.y;
33
+ }
35
34
  },
36
35
  persistedKeys: persistedKeys,
37
36
  layoutOptions: layoutOptions
@@ -1,8 +1,8 @@
1
1
  import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea} from "./ScrollView.module.js";
2
2
  import {VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.module.js";
3
3
  import {useVirtualizerState as $9WwqA$useVirtualizerState} from "@react-stately/virtualizer";
4
- import {useLoadMore as $9WwqA$useLoadMore, mergeProps as $9WwqA$mergeProps} from "@react-aria/utils";
5
- import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback} from "react";
4
+ import {useObjectRef as $9WwqA$useObjectRef, useLoadMore as $9WwqA$useLoadMore, mergeProps as $9WwqA$mergeProps} from "@react-aria/utils";
5
+ import $9WwqA$react, {useCallback as $9WwqA$useCallback} from "react";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -19,19 +19,18 @@ import $9WwqA$react, {useRef as $9WwqA$useRef, useCallback as $9WwqA$useCallback
19
19
 
20
20
 
21
21
 
22
- function $6d0a5c394373ae64$var$Virtualizer(props, ref) {
23
- let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- isLoading, onLoadMore: // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
26
- let fallbackRef = (0, $9WwqA$useRef)(undefined);
27
- ref = ref || fallbackRef;
22
+ function $6d0a5c394373ae64$var$Virtualizer(props, forwardedRef) {
23
+ let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: isLoading, onLoadMore: onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
24
+ let ref = (0, $9WwqA$useObjectRef)(forwardedRef);
28
25
  let state = (0, $9WwqA$useVirtualizerState)({
29
26
  layout: layout,
30
27
  collection: collection,
31
28
  renderView: renderView,
32
29
  onVisibleRectChange (rect) {
33
- ref.current.scrollLeft = rect.x;
34
- ref.current.scrollTop = rect.y;
30
+ if (ref.current) {
31
+ ref.current.scrollLeft = rect.x;
32
+ ref.current.scrollTop = rect.y;
33
+ }
35
34
  },
36
35
  persistedKeys: persistedKeys,
37
36
  layoutOptions: layoutOptions
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BD,SAAS,kCAAsD,KAAgC,EAAE,GAAqC;IACpI,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,mBACV,eAAe,aACf,6DAA6D;IAC7D,SAAS,cACT,6DAA6D;IAC7D,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,cAAc,CAAA,GAAA,aAAK,EAAkB;IACzC,MAAM,OAAO;IAEb,IAAI,QAAQ,CAAA,GAAA,0BAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;YAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;QAChC;uBACA;uBACA;IACF;IAEA,CAAA,GAAA,kBAAU,EAAE;mBAAC;oBAAW;QAAY,cAAc;IAAC,GAAG;IACtD,IAAI,sBAAsB,CAAA,GAAA,kBAAU,EAAE,CAAC;QACrC,MAAM,cAAc,CAAC;IACvB,GAAG;QAAC;KAAM;IAEV,qBACE,gCAAC,CAAA,GAAA,wCAAS;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY;iCAAC;QAAmB,EAAE;QACjD,KAAK;QACL,aAAa,MAAM,WAAW;QAC9B,eAAe,MAAM,cAAc;QACnC,aAAa,MAAM,YAAY;QAC/B,iBAAiB;OAChB,qCAAe,MAAM,MAAM,YAAY,EAAE,iBAAiB;AAGjE;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGtC,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,gCAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLoadMore} from '@react-aria/utils';\nimport React, {HTMLAttributes, ReactElement, ReactNode, useCallback, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n) => ReactElement;\n\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, ref: RefObject<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n scrollDirection,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>(undefined);\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n },\n persistedKeys,\n layoutOptions\n });\n\n useLoadMore({isLoading, onLoadMore, scrollOffset: 1}, ref);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n }, [state]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, {onVisibleRectChange})}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA4BD,SAAS,kCAAsD,KAAgC,EAAE,YAAiD;IAChJ,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,mBACV,eAAe,aACf,SAAS,cACT,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IAEvB,IAAI,QAAQ,CAAA,GAAA,0BAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,IAAI,OAAO,EAAE;gBACf,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;YAChC;QACF;uBACA;uBACA;IACF;IAEA,CAAA,GAAA,kBAAU,EAAE;mBAAC;oBAAW;QAAY,cAAc;IAAC,GAAG;IACtD,IAAI,sBAAsB,CAAA,GAAA,kBAAU,EAAE,CAAC;QACrC,MAAM,cAAc,CAAC;IACvB,GAAG;QAAC;KAAM;IAEV,qBACE,gCAAC,CAAA,GAAA,wCAAS;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY;iCAAC;QAAmB,EAAE;QACjD,KAAK;QACL,aAAa,MAAM,WAAW;QAC9B,eAAe,MAAM,cAAc;QACnC,aAAa,MAAM,YAAY;QAC/B,iBAAiB;OAChB,qCAAe,MAAM,MAAM,YAAY,EAAE,iBAAiB;AAGjE;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGtC,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,gCAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLoadMore, useObjectRef} from '@react-aria/utils';\nimport React, {ForwardedRef, HTMLAttributes, ReactElement, ReactNode, useCallback} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n) => ReactElement | null;\n\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n scrollDirection,\n isLoading,\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let ref = useObjectRef(forwardedRef);\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n if (ref.current) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n },\n persistedKeys,\n layoutOptions\n });\n\n useLoadMore({isLoading, onLoadMore, scrollOffset: 1}, ref);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n }, [state]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, {onVisibleRectChange})}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo!}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
@@ -29,7 +29,7 @@ $parcel$export(module.exports, "layoutInfoToStyle", () => $d6a26279cc31826b$expo
29
29
  function $d6a26279cc31826b$export$6796df8ba7398521(props) {
30
30
  let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
31
31
  let { direction: direction } = (0, $eXWCF$reactariai18n.useLocale)();
32
- let ref = (0, $eXWCF$react.useRef)(undefined);
32
+ let ref = (0, $eXWCF$react.useRef)(null);
33
33
  (0, $7d70e069fceb2deb$exports.useVirtualizerItem)({
34
34
  layoutInfo: layoutInfo,
35
35
  virtualizer: virtualizer,
@@ -70,6 +70,7 @@ function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
70
70
  Object.entries(rectStyles).forEach(([key, value])=>{
71
71
  if (!Number.isFinite(value)) rectStyles[key] = undefined;
72
72
  });
73
+ var _layoutInfo_transform;
73
74
  let style = {
74
75
  position: layoutInfo.isSticky ? 'sticky' : 'absolute',
75
76
  // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
@@ -77,7 +78,7 @@ function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
77
78
  overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
78
79
  opacity: layoutInfo.opacity,
79
80
  zIndex: layoutInfo.zIndex,
80
- transform: layoutInfo.transform,
81
+ transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
81
82
  contain: 'size layout style',
82
83
  ...rectStyles
83
84
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAeM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IACjB,CAAA,GAAA,4CAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,0DAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY,WAAW,OAAO;YAAE,GAAG,KAAK;QAAA;OAC3H;AAGP;AAEA,IAAI,8BAAQ,IAAI;AACT,SAAS,0CAAkB,UAAsB,EAAE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MAAM;QACzB,WAAW,WAAW,SAAS;QAC/B,SAAS;QACT,GAAG,UAAU;IACf;IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef(undefined);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAgBM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAyB;IACxC,CAAA,GAAA,4CAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,0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IAPb,IAAI,QAAuB;QACzB,UAAU,WAAW,QAAQ,GAAG,WAAW;QAC3C,qJAAqJ;QACrJ,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,CAAA,wBAAA,WAAW,SAAS,cAApB,mCAAA,wBAAwB;QACnC,SAAS;QACT,GAAG,UAAU;IACf;IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n layoutInfo: LayoutInfo,\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef<HTMLDivElement | null>(null);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles: Record<string, number | undefined> = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform ?? undefined,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.main.js.map"}
@@ -18,7 +18,7 @@ import {useLocale as $ivH3G$useLocale} from "@react-aria/i18n";
18
18
  function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) {
19
19
  let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
20
20
  let { direction: direction } = (0, $ivH3G$useLocale)();
21
- let ref = (0, $ivH3G$useRef)(undefined);
21
+ let ref = (0, $ivH3G$useRef)(null);
22
22
  (0, $47736c1e63ba1c6d$export$1da781778207e0a2)({
23
23
  layoutInfo: layoutInfo,
24
24
  virtualizer: virtualizer,
@@ -59,6 +59,7 @@ function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
59
59
  Object.entries(rectStyles).forEach(([key, value])=>{
60
60
  if (!Number.isFinite(value)) rectStyles[key] = undefined;
61
61
  });
62
+ var _layoutInfo_transform;
62
63
  let style = {
63
64
  position: layoutInfo.isSticky ? 'sticky' : 'absolute',
64
65
  // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
@@ -66,7 +67,7 @@ function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
66
67
  overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
67
68
  opacity: layoutInfo.opacity,
68
69
  zIndex: layoutInfo.zIndex,
69
- transform: layoutInfo.transform,
70
+ transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
70
71
  contain: 'size layout style',
71
72
  ...rectStyles
72
73
  };
@@ -18,7 +18,7 @@ import {useLocale as $ivH3G$useLocale} from "@react-aria/i18n";
18
18
  function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) {
19
19
  let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
20
20
  let { direction: direction } = (0, $ivH3G$useLocale)();
21
- let ref = (0, $ivH3G$useRef)(undefined);
21
+ let ref = (0, $ivH3G$useRef)(null);
22
22
  (0, $47736c1e63ba1c6d$export$1da781778207e0a2)({
23
23
  layoutInfo: layoutInfo,
24
24
  virtualizer: virtualizer,
@@ -59,6 +59,7 @@ function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
59
59
  Object.entries(rectStyles).forEach(([key, value])=>{
60
60
  if (!Number.isFinite(value)) rectStyles[key] = undefined;
61
61
  });
62
+ var _layoutInfo_transform;
62
63
  let style = {
63
64
  position: layoutInfo.isSticky ? 'sticky' : 'absolute',
64
65
  // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
@@ -66,7 +67,7 @@ function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
66
67
  overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
67
68
  opacity: layoutInfo.opacity,
68
69
  zIndex: layoutInfo.zIndex,
69
- transform: layoutInfo.transform,
70
+ transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
70
71
  contain: 'size layout style',
71
72
  ...rectStyles
72
73
  };
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAeM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,CAAA,GAAA,yCAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY,WAAW,OAAO;YAAE,GAAG,KAAK;QAAA;OAC3H;AAGP;AAEA,IAAI,8BAAQ,IAAI;AACT,SAAS,0CAAkB,UAAsB,EAAE,GAAc,EAAE,MAA0B;IAClG,IAAI,YAAY,QAAQ,QAAQ,UAAU;IAC1C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IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef(undefined);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAgBM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,aAAK,EAAyB;IACxC,CAAA,GAAA,yCAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY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,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,CAAA,wBAAA,WAAW,SAAS,cAApB,mCAAA,wBAAwB;QACnC,SAAS;QACT,GAAG,UAAU;IACf;IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n layoutInfo: LayoutInfo,\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef<HTMLDivElement | null>(null);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles: Record<string, number | undefined> = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform ?? undefined,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.module.js.map"}