@react-aria/virtualizer 4.1.4 → 4.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ScrollView.main.js +14 -2
- package/dist/ScrollView.main.js.map +1 -1
- package/dist/ScrollView.mjs +14 -2
- package/dist/ScrollView.module.js +14 -2
- package/dist/ScrollView.module.js.map +1 -1
- package/dist/VirtualizerItem.main.js.map +1 -1
- package/dist/VirtualizerItem.module.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -8
- package/src/ScrollView.tsx +11 -2
- package/src/VirtualizerItem.tsx +2 -2
package/dist/ScrollView.main.js
CHANGED
|
@@ -144,6 +144,7 @@ function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
|
|
|
144
144
|
});
|
|
145
145
|
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
|
|
146
146
|
let lastContentSize = (0, $kvIfm$react.useRef)(null);
|
|
147
|
+
let [update, setUpdate] = (0, $kvIfm$react.useState)({});
|
|
147
148
|
(0, $kvIfm$reactariautils.useLayoutEffect)(()=>{
|
|
148
149
|
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
|
|
149
150
|
// React doesn't allow flushSync inside effects, so queue a microtask.
|
|
@@ -153,11 +154,22 @@ function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
|
|
|
153
154
|
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.
|
|
154
155
|
// https://github.com/reactwg/react-18/discussions/102
|
|
155
156
|
// @ts-ignore
|
|
156
|
-
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined')
|
|
157
|
-
|
|
157
|
+
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
|
|
158
|
+
// This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
|
|
159
|
+
// due to strict mode.
|
|
160
|
+
setUpdate({});
|
|
161
|
+
lastContentSize.current = contentSize;
|
|
162
|
+
return;
|
|
163
|
+
} else queueMicrotask(()=>updateSize((0, $kvIfm$reactdom.flushSync)));
|
|
158
164
|
}
|
|
159
165
|
lastContentSize.current = contentSize;
|
|
160
166
|
});
|
|
167
|
+
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
|
|
168
|
+
(0, $kvIfm$reactariautils.useLayoutEffect)(()=>{
|
|
169
|
+
updateSize((fn)=>fn());
|
|
170
|
+
}, [
|
|
171
|
+
update
|
|
172
|
+
]);
|
|
161
173
|
let onResize = (0, $kvIfm$react.useCallback)(()=>{
|
|
162
174
|
updateSize((0, $kvIfm$reactdom.flushSync));
|
|
163
175
|
}, [
|
|
@@ -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,OAAQ,cACN,MAAM,QAAQ;AAIvB;AAEA,MAAM,yDAAuB,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAQvC,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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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\ninterface ScrollViewAria {\n scrollViewProps: HTMLAttributes<HTMLElement>,\n contentProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>): ScrollViewAria {\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"}
|
|
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,OAAQ,cACN,MAAM,QAAQ;AAIvB;AAEA,MAAM,yDAAuB,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC;AAQvC,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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ClB,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\ninterface ScrollViewAria {\n scrollViewProps: HTMLAttributes<HTMLElement>,\n contentProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>): ScrollViewAria {\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 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 let [update, setUpdate] = useState({});\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 // This is so we update size in a separate render but within the same act. Needs to be setState instead of refs\n // due to strict mode.\n setUpdate({});\n lastContentSize.current = contentSize;\n return;\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n // Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.\n useLayoutEffect(() => {\n updateSize(fn => fn());\n }, [update]);\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"}
|
package/dist/ScrollView.mjs
CHANGED
|
@@ -133,6 +133,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
|
|
|
133
133
|
});
|
|
134
134
|
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
|
|
135
135
|
let lastContentSize = (0, $f9kpT$useRef)(null);
|
|
136
|
+
let [update, setUpdate] = (0, $f9kpT$useState)({});
|
|
136
137
|
(0, $f9kpT$useLayoutEffect)(()=>{
|
|
137
138
|
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
|
|
138
139
|
// React doesn't allow flushSync inside effects, so queue a microtask.
|
|
@@ -142,11 +143,22 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
|
|
|
142
143
|
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.
|
|
143
144
|
// https://github.com/reactwg/react-18/discussions/102
|
|
144
145
|
// @ts-ignore
|
|
145
|
-
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined')
|
|
146
|
-
|
|
146
|
+
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
|
|
147
|
+
// This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
|
|
148
|
+
// due to strict mode.
|
|
149
|
+
setUpdate({});
|
|
150
|
+
lastContentSize.current = contentSize;
|
|
151
|
+
return;
|
|
152
|
+
} else queueMicrotask(()=>updateSize((0, $f9kpT$flushSync)));
|
|
147
153
|
}
|
|
148
154
|
lastContentSize.current = contentSize;
|
|
149
155
|
});
|
|
156
|
+
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
|
|
157
|
+
(0, $f9kpT$useLayoutEffect)(()=>{
|
|
158
|
+
updateSize((fn)=>fn());
|
|
159
|
+
}, [
|
|
160
|
+
update
|
|
161
|
+
]);
|
|
150
162
|
let onResize = (0, $f9kpT$useCallback)(()=>{
|
|
151
163
|
updateSize((0, $f9kpT$flushSync));
|
|
152
164
|
}, [
|
|
@@ -133,6 +133,7 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
|
|
|
133
133
|
});
|
|
134
134
|
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
|
|
135
135
|
let lastContentSize = (0, $f9kpT$useRef)(null);
|
|
136
|
+
let [update, setUpdate] = (0, $f9kpT$useState)({});
|
|
136
137
|
(0, $f9kpT$useLayoutEffect)(()=>{
|
|
137
138
|
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
|
|
138
139
|
// React doesn't allow flushSync inside effects, so queue a microtask.
|
|
@@ -142,11 +143,22 @@ function $44a6ee657928b002$export$2ea0c4974da4731b(props, ref) {
|
|
|
142
143
|
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.
|
|
143
144
|
// https://github.com/reactwg/react-18/discussions/102
|
|
144
145
|
// @ts-ignore
|
|
145
|
-
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined')
|
|
146
|
-
|
|
146
|
+
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
|
|
147
|
+
// This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
|
|
148
|
+
// due to strict mode.
|
|
149
|
+
setUpdate({});
|
|
150
|
+
lastContentSize.current = contentSize;
|
|
151
|
+
return;
|
|
152
|
+
} else queueMicrotask(()=>updateSize((0, $f9kpT$flushSync)));
|
|
147
153
|
}
|
|
148
154
|
lastContentSize.current = contentSize;
|
|
149
155
|
});
|
|
156
|
+
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
|
|
157
|
+
(0, $f9kpT$useLayoutEffect)(()=>{
|
|
158
|
+
updateSize((fn)=>fn());
|
|
159
|
+
}, [
|
|
160
|
+
update
|
|
161
|
+
]);
|
|
150
162
|
let onResize = (0, $f9kpT$useCallback)(()=>{
|
|
151
163
|
updateSize((0, $f9kpT$flushSync));
|
|
152
164
|
}, [
|
|
@@ -1 +1 @@
|
|
|
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;AAQvC,SAAS,0CAAc,KAAsB,EAAE,GAAkC;IACtF,IAAI,eACF,WAAW,uBACX,mBAAmB,cACnB,UAAU,iBACV,aAAa,eACb,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I,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\ninterface ScrollViewAria {\n scrollViewProps: HTMLAttributes<HTMLElement>,\n contentProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>): ScrollViewAria {\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"}
|
|
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;AAQvC,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,YAAY;QACZ,eAAe;QACf,eAAe;QACf,OAAO;QACP,QAAQ;QACR,aAAa;IACf,GAAG,OAAO;IACV,IAAI,aAAC,SAAS,EAAC,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Q;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\ninterface ScrollViewAria {\n scrollViewProps: HTMLAttributes<HTMLElement>,\n contentProps: HTMLAttributes<HTMLElement>\n}\n\nexport function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement | null>): ScrollViewAria {\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 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 let [update, setUpdate] = useState({});\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 // This is so we update size in a separate render but within the same act. Needs to be setState instead of refs\n // due to strict mode.\n setUpdate({});\n lastContentSize.current = contentSize;\n return;\n } else {\n queueMicrotask(() => updateSize(flushSync));\n }\n }\n\n lastContentSize.current = contentSize;\n });\n\n // Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.\n useLayoutEffect(() => {\n updateSize(fn => fn());\n }, [update]);\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 +1 @@
|
|
|
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,0DAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY,WAAW,OAAO;YAAE,GAAG,KAAK;QAAA;OAC3H;AAGP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AW,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):
|
|
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,q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;QASa;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, JSX, 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): JSX.Element {\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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;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AAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QAC7G,OAAO,WAAW,IAAI,CAAC,KAAK;QAC5B,QAAQ,WAAW,IAAI,CAAC,MAAM;IAChC;IAEA,sEAAsE;IACtE,OAAO,OAAO,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;QAC9C,IAAI,CAAC,OAAO,QAAQ,CAAC,QACnB,UAAU,CAAC,IAAI,GAAG;IAEtB;QASa;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):
|
|
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,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,IAAI,SAAS,4BAAM,GAAG,CAAC;IACvB,IAAI,UAAU,MAAM,CAAC,UAAU,IAAI,MAAM;QACvC,IAAI,CAAC,QACH,OAAO;QAGT,6CAA6C;QAC7C,IAAI,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO,GAAG,KAAK,OAAO,MAAM,CAAC,UAAU,KAAK,GAC9C,OAAO;IAEX;IAEA,IAAI,aAAiD;QACnD,wJAAwJ;QACxJ,sIAAsI;QACtI,mJAAmJ;QACnJ,+BAA+B;QAC/B,KAAK,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QACrG,CAAC,UAAU,EAAE,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QAC7G,OAAO,WAAW,IAAI,CAAC,KAAK;QAC5B,QAAQ,WAAW,IAAI,CAAC,MAAM;IAChC;IAEA,sEAAsE;IACtE,OAAO,OAAO,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;QAC9C,IAAI,CAAC,OAAO,QAAQ,CAAC,QACnB,UAAU,CAAC,IAAI,GAAG;IAEtB;QASa;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, JSX, 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): JSX.Element {\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"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Direction, Key, RefObject, Collection } from "@react-types/shared";
|
|
2
2
|
import { LayoutInfo, Size, Rect, Layout, ReusableView } from "@react-stately/virtualizer";
|
|
3
|
-
import React, { CSSProperties, HTMLAttributes, ReactNode, RefObject as _RefObject1, ReactElement } from "react";
|
|
3
|
+
import React, { CSSProperties, HTMLAttributes, ReactNode, RefObject as _RefObject1, JSX, ReactElement } from "react";
|
|
4
4
|
export type RTLOffsetType = 'negative' | 'positive-descending' | 'positive-ascending';
|
|
5
5
|
export function getRTLOffsetType(recalculate?: boolean): RTLOffsetType;
|
|
6
6
|
export function getScrollLeft(node: Element, direction: Direction): number;
|
|
@@ -38,7 +38,7 @@ interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
|
|
|
38
38
|
className?: string;
|
|
39
39
|
children: ReactNode;
|
|
40
40
|
}
|
|
41
|
-
export function VirtualizerItem(props: VirtualizerItemProps):
|
|
41
|
+
export function VirtualizerItem(props: VirtualizerItemProps): JSX.Element;
|
|
42
42
|
export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties;
|
|
43
43
|
type RenderWrapper<T extends object, V> = (parent: ReusableView<T, V> | null, reusableView: ReusableView<T, V>, children: ReusableView<T, V>[], renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]) => ReactElement | null;
|
|
44
44
|
interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAcA,4BACI,UAAU,GACV,qBAAqB,GACrB,oBAAoB,CAAC;AAezB,iCAAiC,WAAW,GAAE,OAAe,GAAG,aAAa,CAmC5E;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAkBzE;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAiB3F;ACzFD;IACE,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAC3C;AAED;IACE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,YAAY,CAAC;IAC1B,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAA;CACnC;AAED,mCAAmC,OAAO,EAAE,sBAAsB,GAAG;IAAC,UAAU,EAAE,MAAM,IAAI,CAAA;CAAC,CAkB5F;ACfD,yBAA0B,SAAQ,eAAe,WAAW,CAAC;IAC3D,WAAW,EAAE,IAAI,CAAC;IAClB,mBAAmB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAA;CACrD;AAeD,OAAA,MAAM,yGAAmD,CAAC;AAG1D;IACE,eAAe,EAAE,eAAe,WAAW,CAAC,CAAC;IAC7C,YAA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C,CAAC;IAC1B,aAAa,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChC,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,CAAA;CAClB;AAID,OAAO,MAAM,aA8CP,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC","sources":["packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/VirtualizerItem.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/Virtualizer.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/index.ts","packages/@react-aria/virtualizer/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\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\nexport type {RTLOffsetType} from './utils';\nexport type {VirtualizerItemOptions} from './useVirtualizerItem';\nexport {Virtualizer} from './Virtualizer';\nexport {useVirtualizerItem} from './useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';\nexport {ScrollView, useScrollView} from './ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/virtualizer",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.6",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": [
|
|
11
|
+
"./dist/types.d.ts",
|
|
12
|
+
"./src/index.ts"
|
|
13
|
+
],
|
|
10
14
|
"import": "./dist/import.mjs",
|
|
11
15
|
"require": "./dist/main.js"
|
|
12
16
|
},
|
|
@@ -22,11 +26,11 @@
|
|
|
22
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
27
|
},
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.12.
|
|
26
|
-
"@react-aria/interactions": "^3.25.
|
|
27
|
-
"@react-aria/utils": "^3.
|
|
28
|
-
"@react-stately/virtualizer": "^4.
|
|
29
|
-
"@react-types/shared": "^3.
|
|
29
|
+
"@react-aria/i18n": "^3.12.10",
|
|
30
|
+
"@react-aria/interactions": "^3.25.2",
|
|
31
|
+
"@react-aria/utils": "^3.29.1",
|
|
32
|
+
"@react-stately/virtualizer": "^4.4.1",
|
|
33
|
+
"@react-types/shared": "^3.30.0",
|
|
30
34
|
"@swc/helpers": "^0.5.0"
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
@@ -36,5 +40,5 @@
|
|
|
36
40
|
"publishConfig": {
|
|
37
41
|
"access": "public"
|
|
38
42
|
},
|
|
39
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
|
|
40
44
|
}
|
package/src/ScrollView.tsx
CHANGED
|
@@ -98,7 +98,6 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
98
98
|
// Prevent rubber band scrolling from shaking when scrolling out of bounds
|
|
99
99
|
state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));
|
|
100
100
|
state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));
|
|
101
|
-
|
|
102
101
|
onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));
|
|
103
102
|
|
|
104
103
|
if (!state.isScrolling) {
|
|
@@ -199,6 +198,7 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
199
198
|
|
|
200
199
|
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
|
|
201
200
|
let lastContentSize = useRef<Size | null>(null);
|
|
201
|
+
let [update, setUpdate] = useState({});
|
|
202
202
|
useLayoutEffect(() => {
|
|
203
203
|
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
|
|
204
204
|
// React doesn't allow flushSync inside effects, so queue a microtask.
|
|
@@ -209,7 +209,11 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
209
209
|
// https://github.com/reactwg/react-18/discussions/102
|
|
210
210
|
// @ts-ignore
|
|
211
211
|
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
|
|
212
|
-
|
|
212
|
+
// This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
|
|
213
|
+
// due to strict mode.
|
|
214
|
+
setUpdate({});
|
|
215
|
+
lastContentSize.current = contentSize;
|
|
216
|
+
return;
|
|
213
217
|
} else {
|
|
214
218
|
queueMicrotask(() => updateSize(flushSync));
|
|
215
219
|
}
|
|
@@ -218,6 +222,11 @@ export function useScrollView(props: ScrollViewProps, ref: RefObject<HTMLElement
|
|
|
218
222
|
lastContentSize.current = contentSize;
|
|
219
223
|
});
|
|
220
224
|
|
|
225
|
+
// Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
|
|
226
|
+
useLayoutEffect(() => {
|
|
227
|
+
updateSize(fn => fn());
|
|
228
|
+
}, [update]);
|
|
229
|
+
|
|
221
230
|
let onResize = useCallback(() => {
|
|
222
231
|
updateSize(flushSync);
|
|
223
232
|
}, [updateSize]);
|
package/src/VirtualizerItem.tsx
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
import {Direction} from '@react-types/shared';
|
|
14
14
|
import {LayoutInfo} from '@react-stately/virtualizer';
|
|
15
|
-
import React, {CSSProperties, ReactNode, useRef} from 'react';
|
|
15
|
+
import React, {CSSProperties, JSX, ReactNode, useRef} from 'react';
|
|
16
16
|
import {useLocale} from '@react-aria/i18n';
|
|
17
17
|
import {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
|
|
|
24
24
|
children: ReactNode
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export function VirtualizerItem(props: VirtualizerItemProps):
|
|
27
|
+
export function VirtualizerItem(props: VirtualizerItemProps): JSX.Element {
|
|
28
28
|
let {style, className, layoutInfo, virtualizer, parent, children} = props;
|
|
29
29
|
let {direction} = useLocale();
|
|
30
30
|
let ref = useRef<HTMLDivElement | null>(null);
|