@react-aria/virtualizer 3.3.6-nightly.3036 → 3.3.6-nightly.3047

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/main.js CHANGED
@@ -1,558 +1,463 @@
1
- var {
2
- useLocale
3
- } = require("@react-aria/i18n");
4
-
5
- var {
6
- flushSync
7
- } = require("react-dom");
8
-
9
- var _react2 = require("react");
10
-
11
- var _react = $parcel$interopDefault(_react2);
12
-
13
- var {
14
- useCallback,
15
- useEffect,
16
- useRef,
17
- useState
18
- } = _react2;
19
-
20
- var {
21
- useVirtualizerState,
22
- Rect,
23
- Size
24
- } = require("@react-stately/virtualizer");
25
-
26
- var {
27
- focusWithoutScrolling,
28
- mergeProps,
29
- useLayoutEffect,
30
- useResizeObserver
31
- } = require("@react-aria/utils");
32
-
33
- var _babelRuntimeHelpersObjectWithoutPropertiesLoose = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
1
+ var $55M73$reactariautils = require("@react-aria/utils");
2
+ var $55M73$reactstatelyvirtualizer = require("@react-stately/virtualizer");
3
+ var $55M73$react = require("react");
4
+ var $55M73$reactdom = require("react-dom");
5
+ var $55M73$reactariai18n = require("@react-aria/i18n");
6
+
7
+ function $parcel$exportWildcard(dest, source) {
8
+ Object.keys(source).forEach(function(key) {
9
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
10
+ return;
11
+ }
34
12
 
35
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
13
+ Object.defineProperty(dest, key, {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return source[key];
17
+ }
18
+ });
19
+ });
36
20
 
21
+ return dest;
22
+ }
37
23
  function $parcel$interopDefault(a) {
38
24
  return a && a.__esModule ? a.default : a;
39
25
  }
40
-
41
- /*
42
- * Copyright 2020 Adobe. All rights reserved.
43
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
44
- * you may not use this file except in compliance with the License. You may obtain a copy
45
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
46
- *
47
- * Unless required by applicable law or agreed to in writing, software distributed under
48
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
49
- * OF ANY KIND, either express or implied. See the License for the specific language
50
- * governing permissions and limitations under the License.
51
- */
52
- let $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult = null; // Original licensing for the following methods can be found in the
53
- // NOTICE file in the root directory of this source tree.
54
- // See https://github.com/bvaughn/react-window/blob/master/src/createGridComponent.js
55
- // According to the spec, scrollLeft should be negative for RTL aligned elements.
56
- // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
57
- // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
58
- // The safest way to check this is to intentionally set a negative offset,
59
- // and then verify that the subsequent "scroll" event matches the negative offset.
60
- // If it does not match, then we can assume a non-standard RTL scroll implementation.
61
-
62
- function getRTLOffsetType(recalculate) {
63
- if (recalculate === void 0) {
64
- recalculate = false;
65
- }
66
-
67
- if ($d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult === null || recalculate) {
68
- const outerDiv = document.createElement('div');
69
- const outerStyle = outerDiv.style;
70
- outerStyle.width = '50px';
71
- outerStyle.height = '50px';
72
- outerStyle.overflow = 'scroll';
73
- outerStyle.direction = 'rtl';
74
- const innerDiv = document.createElement('div');
75
- const innerStyle = innerDiv.style;
76
- innerStyle.width = '100px';
77
- innerStyle.height = '100px';
78
- outerDiv.appendChild(innerDiv);
79
- document.body.appendChild(outerDiv);
80
-
81
- if (outerDiv.scrollLeft > 0) {
82
- $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult = 'positive-descending';
83
- } else {
84
- outerDiv.scrollLeft = 1;
85
-
86
- if (outerDiv.scrollLeft === 0) {
87
- $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult = 'negative';
88
- } else {
89
- $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult = 'positive-ascending';
90
- }
91
- }
92
-
93
- document.body.removeChild(outerDiv);
94
- return $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult;
95
- }
96
-
97
- return $d649e158743d5440c2ce6b2da8a4e6c$var$cachedRTLResult;
26
+ function $parcel$export(e, n, v, s) {
27
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
98
28
  }
99
-
100
- exports.getRTLOffsetType = getRTLOffsetType;
101
-
102
- function getScrollLeft(node, direction) {
103
- let {
104
- scrollLeft
105
- } = node; // scrollLeft in rtl locales differs across browsers, so normalize.
106
- // See comment by getRTLOffsetType below for details.
107
-
108
- if (direction === 'rtl') {
109
- let {
110
- scrollWidth,
111
- clientWidth
112
- } = node;
113
-
114
- switch (getRTLOffsetType()) {
115
- case 'negative':
116
- scrollLeft = -scrollLeft;
117
- break;
118
-
119
- case 'positive-descending':
120
- scrollLeft = scrollWidth - clientWidth - scrollLeft;
121
- break;
29
+ var $aea84f7f089eb7a5$exports = {};
30
+
31
+ $parcel$export($aea84f7f089eb7a5$exports, "useVirtualizer", () => $aea84f7f089eb7a5$export$dd6d526d88b5a137);
32
+ $parcel$export($aea84f7f089eb7a5$exports, "Virtualizer", () => $aea84f7f089eb7a5$export$89be5a243e59c4b2);
33
+
34
+
35
+
36
+ var $3e3c2bf282fde6af$exports = {};
37
+
38
+ $parcel$export($3e3c2bf282fde6af$exports, "ScrollView", () => $3e3c2bf282fde6af$export$5665e3d6be6adea);
39
+
40
+ var $8b6aaa6593623080$exports = {};
41
+
42
+ $parcel$export($8b6aaa6593623080$exports, "getRTLOffsetType", () => $8b6aaa6593623080$export$faf7630257ad4304);
43
+ $parcel$export($8b6aaa6593623080$exports, "getScrollLeft", () => $8b6aaa6593623080$export$1389d168952b34b5);
44
+ $parcel$export($8b6aaa6593623080$exports, "setScrollLeft", () => $8b6aaa6593623080$export$ed5fd5ffe5ab0ac);
45
+ let $8b6aaa6593623080$var$cachedRTLResult = null;
46
+ function $8b6aaa6593623080$export$faf7630257ad4304(recalculate = false) {
47
+ if ($8b6aaa6593623080$var$cachedRTLResult === null || recalculate) {
48
+ const outerDiv = document.createElement('div');
49
+ const outerStyle = outerDiv.style;
50
+ outerStyle.width = '50px';
51
+ outerStyle.height = '50px';
52
+ outerStyle.overflow = 'scroll';
53
+ outerStyle.direction = 'rtl';
54
+ const innerDiv = document.createElement('div');
55
+ const innerStyle = innerDiv.style;
56
+ innerStyle.width = '100px';
57
+ innerStyle.height = '100px';
58
+ outerDiv.appendChild(innerDiv);
59
+ document.body.appendChild(outerDiv);
60
+ if (outerDiv.scrollLeft > 0) $8b6aaa6593623080$var$cachedRTLResult = 'positive-descending';
61
+ else {
62
+ outerDiv.scrollLeft = 1;
63
+ if (outerDiv.scrollLeft === 0) $8b6aaa6593623080$var$cachedRTLResult = 'negative';
64
+ else $8b6aaa6593623080$var$cachedRTLResult = 'positive-ascending';
65
+ }
66
+ document.body.removeChild(outerDiv);
67
+ return $8b6aaa6593623080$var$cachedRTLResult;
122
68
  }
123
- }
124
-
125
- return scrollLeft;
69
+ return $8b6aaa6593623080$var$cachedRTLResult;
126
70
  }
127
-
128
- exports.getScrollLeft = getScrollLeft;
129
-
130
- function setScrollLeft(node, direction, scrollLeft) {
131
- if (direction === 'rtl') {
132
- switch (getRTLOffsetType()) {
133
- case 'negative':
134
- scrollLeft = -scrollLeft;
135
- break;
136
-
137
- case 'positive-ascending':
138
- break;
139
-
140
- default:
141
- {
142
- const {
143
- clientWidth,
144
- scrollWidth
145
- } = node;
146
- scrollLeft = scrollWidth - clientWidth - scrollLeft;
147
- break;
71
+ function $8b6aaa6593623080$export$1389d168952b34b5(node, direction) {
72
+ let { scrollLeft: scrollLeft } = node;
73
+ // scrollLeft in rtl locales differs across browsers, so normalize.
74
+ // See comment by getRTLOffsetType below for details.
75
+ if (direction === 'rtl') {
76
+ let { scrollWidth: scrollWidth , clientWidth: clientWidth } = node;
77
+ switch($8b6aaa6593623080$export$faf7630257ad4304()){
78
+ case 'negative':
79
+ scrollLeft = -scrollLeft;
80
+ break;
81
+ case 'positive-descending':
82
+ scrollLeft = scrollWidth - clientWidth - scrollLeft;
83
+ break;
148
84
  }
149
85
  }
150
- }
151
-
152
- node.scrollLeft = scrollLeft;
86
+ return scrollLeft;
153
87
  }
154
-
155
- exports.setScrollLeft = setScrollLeft;
156
-
157
- function $a90951c3d36a11fc98c5f85adae5ad$var$ScrollView(props, ref) {
158
- let {
159
- contentSize,
160
- onVisibleRectChange,
161
- children,
162
- innerStyle,
163
- sizeToFit,
164
- onScrollStart,
165
- onScrollEnd,
166
- scrollDirection = 'both'
167
- } = props,
168
- otherProps = _babelRuntimeHelpersObjectWithoutPropertiesLoose(props, ["contentSize", "onVisibleRectChange", "children", "innerStyle", "sizeToFit", "onScrollStart", "onScrollEnd", "scrollDirection"]);
169
-
170
- let defaultRef = useRef();
171
- ref = ref || defaultRef;
172
- let state = useRef({
173
- scrollTop: 0,
174
- scrollLeft: 0,
175
- scrollEndTime: 0,
176
- scrollTimeout: null,
177
- width: 0,
178
- height: 0,
179
- isScrolling: false
180
- }).current;
181
- let {
182
- direction
183
- } = useLocale();
184
- let [isScrolling, setScrolling] = useState(false);
185
- let onScroll = useCallback(e => {
186
- if (e.target !== e.currentTarget) {
187
- return;
188
- }
189
-
190
- if (props.onScroll) {
191
- props.onScroll(e);
88
+ function $8b6aaa6593623080$export$ed5fd5ffe5ab0ac(node, direction, scrollLeft) {
89
+ if (direction === 'rtl') switch($8b6aaa6593623080$export$faf7630257ad4304()){
90
+ case 'negative':
91
+ scrollLeft = -scrollLeft;
92
+ break;
93
+ case 'positive-ascending':
94
+ break;
95
+ default:
96
+ {
97
+ const { clientWidth: clientWidth , scrollWidth: scrollWidth } = node;
98
+ scrollLeft = scrollWidth - clientWidth - scrollLeft;
99
+ break;
100
+ }
192
101
  }
102
+ node.scrollLeft = scrollLeft;
103
+ }
193
104
 
194
- flushSync(() => {
195
- let scrollTop = e.currentTarget.scrollTop;
196
- let scrollLeft = getScrollLeft(e.currentTarget, direction); // Prevent rubber band scrolling from shaking when scrolling out of bounds
197
-
198
- state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));
199
- state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));
200
- onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, state.width, state.height));
201
105
 
202
- if (!state.isScrolling) {
203
- state.isScrolling = true;
204
- setScrolling(true);
205
106
 
206
- if (onScrollStart) {
207
- onScrollStart();
208
- }
209
- } // So we don't constantly call clearTimeout and setTimeout,
210
- // keep track of the current timeout time and only reschedule
211
- // the timer when it is getting close.
212
107
 
213
108
 
214
- let now = Date.now();
215
109
 
216
- if (state.scrollEndTime <= now + 50) {
217
- state.scrollEndTime = now + 300;
218
- clearTimeout(state.scrollTimeout);
219
- state.scrollTimeout = setTimeout(() => {
220
- state.isScrolling = false;
221
- setScrolling(false);
222
- state.scrollTimeout = null;
223
110
 
224
- if (onScrollEnd) {
225
- onScrollEnd();
226
- }
227
- }, 300);
228
- }
111
+ function $3e3c2bf282fde6af$var$ScrollView(props, ref) {
112
+ let { contentSize: contentSize , onVisibleRectChange: onVisibleRectChange , children: children , innerStyle: innerStyle , sizeToFit: sizeToFit , onScrollStart: onScrollStart , onScrollEnd: onScrollEnd , scrollDirection: scrollDirection = 'both' , ...otherProps } = props;
113
+ let defaultRef = $55M73$react.useRef();
114
+ ref = ref || defaultRef;
115
+ let state = $55M73$react.useRef({
116
+ scrollTop: 0,
117
+ scrollLeft: 0,
118
+ scrollEndTime: 0,
119
+ scrollTimeout: null,
120
+ width: 0,
121
+ height: 0,
122
+ isScrolling: false
123
+ }).current;
124
+ let { direction: direction } = $55M73$reactariai18n.useLocale();
125
+ let [isScrolling, setScrolling] = $55M73$react.useState(false);
126
+ let onScroll = $55M73$react.useCallback((e)=>{
127
+ if (e.target !== e.currentTarget) return;
128
+ if (props.onScroll) props.onScroll(e);
129
+ $55M73$reactdom.flushSync(()=>{
130
+ let scrollTop = e.currentTarget.scrollTop;
131
+ let scrollLeft = $8b6aaa6593623080$export$1389d168952b34b5(e.currentTarget, direction);
132
+ // Prevent rubber band scrolling from shaking when scrolling out of bounds
133
+ state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));
134
+ state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));
135
+ onVisibleRectChange(new $55M73$reactstatelyvirtualizer.Rect(state.scrollLeft, state.scrollTop, state.width, state.height));
136
+ if (!state.isScrolling) {
137
+ state.isScrolling = true;
138
+ setScrolling(true);
139
+ if (onScrollStart) onScrollStart();
140
+ }
141
+ // So we don't constantly call clearTimeout and setTimeout,
142
+ // keep track of the current timeout time and only reschedule
143
+ // the timer when it is getting close.
144
+ let now = Date.now();
145
+ if (state.scrollEndTime <= now + 50) {
146
+ state.scrollEndTime = now + 300;
147
+ clearTimeout(state.scrollTimeout);
148
+ state.scrollTimeout = setTimeout(()=>{
149
+ state.isScrolling = false;
150
+ setScrolling(false);
151
+ state.scrollTimeout = null;
152
+ if (onScrollEnd) onScrollEnd();
153
+ }, 300);
154
+ }
155
+ });
156
+ }, [
157
+ props,
158
+ direction,
159
+ state,
160
+ contentSize,
161
+ onVisibleRectChange,
162
+ onScrollStart,
163
+ onScrollEnd
164
+ ]);
165
+ // eslint-disable-next-line arrow-body-style
166
+ $55M73$react.useEffect(()=>{
167
+ return ()=>{
168
+ clearTimeout(state.scrollTimeout);
169
+ };
170
+ }, []);
171
+ let updateSize = $55M73$react.useCallback(()=>{
172
+ let dom = ref.current;
173
+ if (!dom) return;
174
+ let w = dom.clientWidth;
175
+ let h = dom.clientHeight;
176
+ if (sizeToFit && contentSize.width > 0 && contentSize.height > 0) {
177
+ if (sizeToFit === 'width') w = Math.min(w, contentSize.width);
178
+ else if (sizeToFit === 'height') h = Math.min(h, contentSize.height);
179
+ }
180
+ if (state.width !== w || state.height !== h) {
181
+ state.width = w;
182
+ state.height = h;
183
+ onVisibleRectChange(new $55M73$reactstatelyvirtualizer.Rect(state.scrollLeft, state.scrollTop, w, h));
184
+ }
185
+ }, [
186
+ onVisibleRectChange,
187
+ ref,
188
+ state,
189
+ sizeToFit,
190
+ contentSize
191
+ ]);
192
+ $55M73$reactariautils.useLayoutEffect(()=>{
193
+ updateSize();
194
+ }, [
195
+ updateSize
196
+ ]);
197
+ $55M73$reactariautils.useResizeObserver({
198
+ ref: ref,
199
+ onResize: updateSize
229
200
  });
230
- }, [props, direction, state, contentSize, onVisibleRectChange, onScrollStart, onScrollEnd]); // eslint-disable-next-line arrow-body-style
231
-
232
- useEffect(() => {
233
- return () => {
234
- clearTimeout(state.scrollTimeout);
201
+ let style = {
202
+ // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.
203
+ padding: 0,
204
+ ...otherProps.style
235
205
  };
236
- }, []);
237
- let updateSize = useCallback(() => {
238
- let dom = ref.current;
206
+ if (scrollDirection === 'horizontal') {
207
+ style.overflowX = 'auto';
208
+ style.overflowY = 'hidden';
209
+ } else if (scrollDirection === 'vertical') {
210
+ style.overflowY = 'auto';
211
+ style.overflowX = 'hidden';
212
+ } else style.overflow = 'auto';
213
+ return(/*#__PURE__*/ ($parcel$interopDefault($55M73$react)).createElement("div", {
214
+ ...otherProps,
215
+ style: style,
216
+ ref: ref,
217
+ onScroll: onScroll
218
+ }, /*#__PURE__*/ ($parcel$interopDefault($55M73$react)).createElement("div", {
219
+ role: "presentation",
220
+ style: {
221
+ width: contentSize.width,
222
+ height: contentSize.height,
223
+ pointerEvents: isScrolling ? 'none' : 'auto',
224
+ position: 'relative',
225
+ ...innerStyle
226
+ }
227
+ }, children)));
228
+ }
229
+ const $3e3c2bf282fde6af$export$5665e3d6be6adea = /*#__PURE__*/ ($parcel$interopDefault($55M73$react)).forwardRef($3e3c2bf282fde6af$var$ScrollView);
239
230
 
240
- if (!dom) {
241
- return;
242
- }
243
231
 
244
- let w = dom.clientWidth;
245
- let h = dom.clientHeight;
232
+ var $d8772f25e0f98a8d$exports = {};
246
233
 
247
- if (sizeToFit && contentSize.width > 0 && contentSize.height > 0) {
248
- if (sizeToFit === 'width') {
249
- w = Math.min(w, contentSize.width);
250
- } else if (sizeToFit === 'height') {
251
- h = Math.min(h, contentSize.height);
252
- }
253
- }
234
+ $parcel$export($d8772f25e0f98a8d$exports, "VirtualizerItem", () => $d8772f25e0f98a8d$export$6796df8ba7398521);
235
+ $parcel$export($d8772f25e0f98a8d$exports, "layoutInfoToStyle", () => $d8772f25e0f98a8d$export$1481e64fbe01b8b3);
254
236
 
255
- if (state.width !== w || state.height !== h) {
256
- state.width = w;
257
- state.height = h;
258
- onVisibleRectChange(new Rect(state.scrollLeft, state.scrollTop, w, h));
259
- }
260
- }, [onVisibleRectChange, ref, state, sizeToFit, contentSize]);
261
- useLayoutEffect(() => {
262
- updateSize();
263
- }, [updateSize]);
264
- useResizeObserver({
265
- ref,
266
- onResize: updateSize
267
- });
268
237
 
269
- let style = _babelRuntimeHelpersExtends({
270
- // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.
271
- padding: 0
272
- }, otherProps.style);
273
-
274
- if (scrollDirection === 'horizontal') {
275
- style.overflowX = 'auto';
276
- style.overflowY = 'hidden';
277
- } else if (scrollDirection === 'vertical') {
278
- style.overflowY = 'auto';
279
- style.overflowX = 'hidden';
280
- } else {
281
- style.overflow = 'auto';
282
- }
283
-
284
- return /*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersExtends({}, otherProps, {
285
- style: style,
286
- ref: ref,
287
- onScroll: onScroll
288
- }), /*#__PURE__*/_react.createElement("div", {
289
- role: "presentation",
290
- style: _babelRuntimeHelpersExtends({
291
- width: contentSize.width,
292
- height: contentSize.height,
293
- pointerEvents: isScrolling ? 'none' : 'auto',
294
- position: 'relative'
295
- }, innerStyle)
296
- }, children));
297
- }
238
+ var $f717a8199f2123af$exports = {};
298
239
 
299
- const ScrollView = /*#__PURE__*/_react.forwardRef($a90951c3d36a11fc98c5f85adae5ad$var$ScrollView);
300
-
301
- exports.ScrollView = ScrollView;
302
-
303
- function useVirtualizerItem(options) {
304
- let {
305
- reusableView: {
306
- layoutInfo,
307
- virtualizer
308
- },
309
- ref
310
- } = options;
311
- let updateSize = useCallback(() => {
312
- let size = $f82ecd66628117a18b18263690e81$var$getSize(ref.current);
313
- virtualizer.updateItemSize(layoutInfo.key, size);
314
- }, [virtualizer, layoutInfo.key, ref]);
315
- useLayoutEffect(() => {
316
- if (layoutInfo.estimatedSize) {
317
- updateSize();
318
- }
319
- });
320
- return {
321
- updateSize
322
- };
323
- }
240
+ $parcel$export($f717a8199f2123af$exports, "useVirtualizerItem", () => $f717a8199f2123af$export$1da781778207e0a2);
324
241
 
325
- exports.useVirtualizerItem = useVirtualizerItem;
326
242
 
327
- function $f82ecd66628117a18b18263690e81$var$getSize(node) {
328
- // Reset height before measuring so we get the intrinsic size
329
- let height = node.style.height;
330
- node.style.height = '';
331
- let size = new Size(node.scrollWidth, node.scrollHeight);
332
- node.style.height = height;
333
- return size;
334
- }
335
243
 
336
- function VirtualizerItem(props) {
337
- let {
338
- className,
339
- reusableView,
340
- parent
341
- } = props;
342
- let {
343
- direction
344
- } = useLocale();
345
- let ref = useRef();
346
- useVirtualizerItem({
347
- reusableView,
348
- ref
349
- });
350
- return /*#__PURE__*/_react.createElement("div", {
351
- role: "presentation",
352
- ref: ref,
353
- className: className,
354
- style: layoutInfoToStyle(reusableView.layoutInfo, direction, parent && parent.layoutInfo)
355
- }, reusableView.rendered);
244
+ function $f717a8199f2123af$export$1da781778207e0a2(options) {
245
+ let { reusableView: { layoutInfo: layoutInfo , virtualizer: virtualizer } , ref: ref } = options;
246
+ let updateSize = $55M73$react.useCallback(()=>{
247
+ let size = $f717a8199f2123af$var$getSize(ref.current);
248
+ virtualizer.updateItemSize(layoutInfo.key, size);
249
+ }, [
250
+ virtualizer,
251
+ layoutInfo.key,
252
+ ref
253
+ ]);
254
+ $55M73$reactariautils.useLayoutEffect(()=>{
255
+ if (layoutInfo.estimatedSize) updateSize();
256
+ });
257
+ return {
258
+ updateSize: updateSize
259
+ };
260
+ }
261
+ function $f717a8199f2123af$var$getSize(node) {
262
+ // Reset height before measuring so we get the intrinsic size
263
+ let height = node.style.height;
264
+ node.style.height = '';
265
+ let size = new $55M73$reactstatelyvirtualizer.Size(node.scrollWidth, node.scrollHeight);
266
+ node.style.height = height;
267
+ return size;
356
268
  }
357
269
 
358
- exports.VirtualizerItem = VirtualizerItem;
359
- let $bf262162425aa7028ff507f81a78147$var$cache = new WeakMap();
360
-
361
- function layoutInfoToStyle(layoutInfo, dir, parent) {
362
- let xProperty = dir === 'rtl' ? 'right' : 'left';
363
- let cached = $bf262162425aa7028ff507f81a78147$var$cache.get(layoutInfo);
364
-
365
- if (cached && cached[xProperty] != null) {
366
- if (!parent) {
367
- return cached;
368
- } // Invalidate if the parent position changed.
369
-
370
-
371
- let top = layoutInfo.rect.y - parent.rect.y;
372
- let x = layoutInfo.rect.x - parent.rect.x;
373
270
 
374
- if (cached.top === top && cached[xProperty] === x) {
375
- return cached;
376
- }
377
- }
378
-
379
- let style = {
380
- position: layoutInfo.isSticky ? 'sticky' : 'absolute',
381
- overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
382
- top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
383
- [xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
384
- transition: 'all',
385
- WebkitTransition: 'all',
386
- WebkitTransitionDuration: 'inherit',
387
- transitionDuration: 'inherit',
388
- width: layoutInfo.rect.width,
389
- height: layoutInfo.rect.height,
390
- opacity: layoutInfo.opacity,
391
- zIndex: layoutInfo.zIndex,
392
- transform: layoutInfo.transform,
393
- contain: layoutInfo.allowOverflow ? 'size layout style' : 'size layout style paint'
394
- };
395
- $bf262162425aa7028ff507f81a78147$var$cache.set(layoutInfo, style);
396
- return style;
271
+ function $d8772f25e0f98a8d$export$6796df8ba7398521(props) {
272
+ let { className: className , reusableView: reusableView , parent: parent } = props;
273
+ let { direction: direction } = $55M73$reactariai18n.useLocale();
274
+ let ref = $55M73$react.useRef();
275
+ $f717a8199f2123af$export$1da781778207e0a2({
276
+ reusableView: reusableView,
277
+ ref: ref
278
+ });
279
+ return(/*#__PURE__*/ ($parcel$interopDefault($55M73$react)).createElement("div", {
280
+ role: "presentation",
281
+ ref: ref,
282
+ className: className,
283
+ style: $d8772f25e0f98a8d$export$1481e64fbe01b8b3(reusableView.layoutInfo, direction, parent && parent.layoutInfo)
284
+ }, reusableView.rendered));
397
285
  }
398
-
399
- exports.layoutInfoToStyle = layoutInfoToStyle;
400
-
401
- function $c6087bb500e3bca67ce9dc45886$var$Virtualizer(props, ref) {
402
- let {
403
- children: renderView,
404
- renderWrapper,
405
- layout,
406
- collection,
407
- sizeToFit,
408
- scrollDirection,
409
- transitionDuration,
410
- isLoading,
411
- onLoadMore
412
- } = props,
413
- otherProps = _babelRuntimeHelpersObjectWithoutPropertiesLoose(props, ["children", "renderWrapper", "layout", "collection", "sizeToFit", "scrollDirection", "transitionDuration", "isLoading", "onLoadMore", "focusedKey", "shouldUseVirtualFocus", "scrollToItem"]);
414
-
415
- let fallbackRef = useRef();
416
- ref = ref || fallbackRef;
417
- let state = useVirtualizerState({
418
- transitionDuration,
419
- layout,
420
- collection,
421
- renderView,
422
- renderWrapper: renderWrapper || $c6087bb500e3bca67ce9dc45886$var$defaultRenderWrapper,
423
-
424
- onVisibleRectChange(rect) {
425
- ref.current.scrollLeft = rect.x;
426
- ref.current.scrollTop = rect.y;
286
+ let $d8772f25e0f98a8d$var$cache = new WeakMap();
287
+ function $d8772f25e0f98a8d$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
288
+ let xProperty = dir === 'rtl' ? 'right' : 'left';
289
+ let cached = $d8772f25e0f98a8d$var$cache.get(layoutInfo);
290
+ if (cached && cached[xProperty] != null) {
291
+ if (!parent) return cached;
292
+ // Invalidate if the parent position changed.
293
+ let top = layoutInfo.rect.y - parent.rect.y;
294
+ let x = layoutInfo.rect.x - parent.rect.x;
295
+ if (cached.top === top && cached[xProperty] === x) return cached;
427
296
  }
297
+ let style = {
298
+ position: layoutInfo.isSticky ? 'sticky' : 'absolute',
299
+ overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
300
+ top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
301
+ [xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
302
+ transition: 'all',
303
+ WebkitTransition: 'all',
304
+ WebkitTransitionDuration: 'inherit',
305
+ transitionDuration: 'inherit',
306
+ width: layoutInfo.rect.width,
307
+ height: layoutInfo.rect.height,
308
+ opacity: layoutInfo.opacity,
309
+ zIndex: layoutInfo.zIndex,
310
+ transform: layoutInfo.transform,
311
+ contain: layoutInfo.allowOverflow ? 'size layout style' : 'size layout style paint'
312
+ };
313
+ $d8772f25e0f98a8d$var$cache.set(layoutInfo, style);
314
+ return style;
315
+ }
428
316
 
429
- });
430
- let {
431
- virtualizerProps
432
- } = useVirtualizer(props, state, ref); // Handle scrolling, and call onLoadMore when nearing the bottom.
433
-
434
- let onVisibleRectChange = useCallback(rect => {
435
- state.setVisibleRect(rect);
436
-
437
- if (!isLoading && onLoadMore) {
438
- let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
439
317
 
440
- if (rect.y > scrollOffset) {
441
- onLoadMore();
442
- }
443
- }
444
- }, [isLoading, onLoadMore, state]);
445
- useLayoutEffect(() => {
446
- if (!isLoading && onLoadMore && !state.isAnimating) {
447
- if (state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height) {
448
- onLoadMore();
449
- }
450
- }
451
- }, [state.contentSize, state.isAnimating, state.virtualizer, onLoadMore, isLoading]);
452
- return /*#__PURE__*/_react.createElement(ScrollView, _babelRuntimeHelpersExtends({}, mergeProps(otherProps, virtualizerProps), {
453
- ref: ref,
454
- innerStyle: state.isAnimating ? {
455
- transition: "none " + state.virtualizer.transitionDuration + "ms"
456
- } : undefined,
457
- contentSize: state.contentSize,
458
- onVisibleRectChange: onVisibleRectChange,
459
- onScrollStart: state.startScrolling,
460
- onScrollEnd: state.endScrolling,
461
- sizeToFit: sizeToFit,
462
- scrollDirection: scrollDirection
463
- }), state.visibleViews);
318
+ function $aea84f7f089eb7a5$var$Virtualizer(props, ref) {
319
+ let { children: renderView , renderWrapper: renderWrapper , layout: layout , collection: collection , sizeToFit: sizeToFit , scrollDirection: scrollDirection , transitionDuration: transitionDuration , isLoading: isLoading , onLoadMore: onLoadMore , focusedKey: // eslint-disable-next-line @typescript-eslint/no-unused-vars
320
+ focusedKey , shouldUseVirtualFocus: // eslint-disable-next-line @typescript-eslint/no-unused-vars
321
+ shouldUseVirtualFocus , scrollToItem: // eslint-disable-next-line @typescript-eslint/no-unused-vars
322
+ scrollToItem , ...otherProps } = props;
323
+ let fallbackRef = $55M73$react.useRef();
324
+ ref = ref || fallbackRef;
325
+ let state = $55M73$reactstatelyvirtualizer.useVirtualizerState({
326
+ transitionDuration: transitionDuration,
327
+ layout: layout,
328
+ collection: collection,
329
+ renderView: renderView,
330
+ renderWrapper: renderWrapper || $aea84f7f089eb7a5$var$defaultRenderWrapper,
331
+ onVisibleRectChange (rect) {
332
+ ref.current.scrollLeft = rect.x;
333
+ ref.current.scrollTop = rect.y;
334
+ }
335
+ });
336
+ let { virtualizerProps: virtualizerProps } = $aea84f7f089eb7a5$export$dd6d526d88b5a137(props, state, ref);
337
+ // Handle scrolling, and call onLoadMore when nearing the bottom.
338
+ let onVisibleRectChange = $55M73$react.useCallback((rect)=>{
339
+ state.setVisibleRect(rect);
340
+ if (!isLoading && onLoadMore) {
341
+ let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;
342
+ if (rect.y > scrollOffset) onLoadMore();
343
+ }
344
+ }, [
345
+ isLoading,
346
+ onLoadMore,
347
+ state
348
+ ]);
349
+ $55M73$reactariautils.useLayoutEffect(()=>{
350
+ if (!isLoading && onLoadMore && !state.isAnimating) {
351
+ if (state.contentSize.height > 0 && state.contentSize.height <= state.virtualizer.visibleRect.height) onLoadMore();
352
+ }
353
+ }, [
354
+ state.contentSize,
355
+ state.isAnimating,
356
+ state.virtualizer,
357
+ onLoadMore,
358
+ isLoading
359
+ ]);
360
+ return(/*#__PURE__*/ ($parcel$interopDefault($55M73$react)).createElement($3e3c2bf282fde6af$export$5665e3d6be6adea, {
361
+ ...$55M73$reactariautils.mergeProps(otherProps, virtualizerProps),
362
+ ref: ref,
363
+ innerStyle: state.isAnimating ? {
364
+ transition: `none ${state.virtualizer.transitionDuration}ms`
365
+ } : undefined,
366
+ contentSize: state.contentSize,
367
+ onVisibleRectChange: onVisibleRectChange,
368
+ onScrollStart: state.startScrolling,
369
+ onScrollEnd: state.endScrolling,
370
+ sizeToFit: sizeToFit,
371
+ scrollDirection: scrollDirection
372
+ }, state.visibleViews));
373
+ }
374
+ function $aea84f7f089eb7a5$export$dd6d526d88b5a137(props, state, ref) {
375
+ let { focusedKey: focusedKey , scrollToItem: scrollToItem , shouldUseVirtualFocus: shouldUseVirtualFocus } = props;
376
+ let { virtualizer: virtualizer } = state;
377
+ // Scroll to the focusedKey when it changes. Actually focusing the focusedKey
378
+ // is up to the implementation using Virtualizer since we don't have refs
379
+ // to all of the item DOM nodes.
380
+ let lastFocusedKey = $55M73$react.useRef(null);
381
+ $55M73$react.useEffect(()=>{
382
+ if (virtualizer.visibleRect.height === 0) return;
383
+ if (focusedKey !== lastFocusedKey.current) {
384
+ if (scrollToItem) scrollToItem(focusedKey);
385
+ else virtualizer.scrollToItem(focusedKey, {
386
+ duration: 0
387
+ });
388
+ }
389
+ lastFocusedKey.current = focusedKey;
390
+ }, [
391
+ focusedKey,
392
+ virtualizer.visibleRect.height,
393
+ virtualizer,
394
+ lastFocusedKey,
395
+ scrollToItem
396
+ ]);
397
+ let isFocusWithin = $55M73$react.useRef(false);
398
+ let onFocus = $55M73$react.useCallback((e)=>{
399
+ // If the focused item is scrolled out of view and is not in the DOM, the collection
400
+ // will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.
401
+ // Ignore focus events that bubble through portals (e.g. focus that happens on a menu popover child of the virtualizer)
402
+ if (!isFocusWithin.current && ref.current.contains(e.target)) {
403
+ if (scrollToItem) scrollToItem(focusedKey);
404
+ else virtualizer.scrollToItem(focusedKey, {
405
+ duration: 0
406
+ });
407
+ }
408
+ isFocusWithin.current = e.target !== ref.current;
409
+ }, [
410
+ ref,
411
+ virtualizer,
412
+ focusedKey,
413
+ scrollToItem
414
+ ]);
415
+ let onBlur = $55M73$react.useCallback((e)=>{
416
+ isFocusWithin.current = ref.current.contains(e.relatedTarget);
417
+ }, [
418
+ ref
419
+ ]);
420
+ // When the focused item is scrolled out of view and is removed from the DOM,
421
+ // move focus to the collection view as a whole if focus was within before.
422
+ let focusedView = virtualizer.getView(focusedKey);
423
+ $55M73$react.useEffect(()=>{
424
+ if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) $55M73$reactariautils.focusWithoutScrolling(ref.current);
425
+ });
426
+ // Set tabIndex to -1 if the focused view is in the DOM, otherwise 0 so that the collection
427
+ // itself is tabbable. When the collection receives focus, we scroll the focused item back into
428
+ // view, which will allow it to be properly focused. If using virtual focus, don't set a
429
+ // tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.
430
+ let tabIndex;
431
+ if (!shouldUseVirtualFocus) tabIndex = focusedView ? -1 : 0;
432
+ return {
433
+ virtualizerProps: {
434
+ tabIndex: tabIndex,
435
+ onFocus: onFocus,
436
+ onBlur: onBlur
437
+ }
438
+ };
439
+ }
440
+ // forwardRef doesn't support generic parameters, so cast the result to the correct type
441
+ // https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
442
+ const $aea84f7f089eb7a5$export$89be5a243e59c4b2 = /*#__PURE__*/ ($parcel$interopDefault($55M73$react)).forwardRef($aea84f7f089eb7a5$var$Virtualizer);
443
+ function $aea84f7f089eb7a5$var$defaultRenderWrapper(parent, reusableView) {
444
+ return(/*#__PURE__*/ ($parcel$interopDefault($55M73$react)).createElement($d8772f25e0f98a8d$export$6796df8ba7398521, {
445
+ key: reusableView.key,
446
+ reusableView: reusableView,
447
+ parent: parent
448
+ }));
464
449
  }
465
450
 
466
- function useVirtualizer(props, state, ref) {
467
- let {
468
- focusedKey,
469
- scrollToItem,
470
- shouldUseVirtualFocus
471
- } = props;
472
- let {
473
- virtualizer
474
- } = state; // Scroll to the focusedKey when it changes. Actually focusing the focusedKey
475
- // is up to the implementation using Virtualizer since we don't have refs
476
- // to all of the item DOM nodes.
477
-
478
- let lastFocusedKey = useRef(null);
479
- useEffect(() => {
480
- if (virtualizer.visibleRect.height === 0) {
481
- return;
482
- }
483
-
484
- if (focusedKey !== lastFocusedKey.current) {
485
- if (scrollToItem) {
486
- scrollToItem(focusedKey);
487
- } else {
488
- virtualizer.scrollToItem(focusedKey, {
489
- duration: 0
490
- });
491
- }
492
- }
493
451
 
494
- lastFocusedKey.current = focusedKey;
495
- }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem]);
496
- let isFocusWithin = useRef(false);
497
- let onFocus = useCallback(e => {
498
- // If the focused item is scrolled out of view and is not in the DOM, the collection
499
- // will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.
500
- // Ignore focus events that bubble through portals (e.g. focus that happens on a menu popover child of the virtualizer)
501
- if (!isFocusWithin.current && ref.current.contains(e.target)) {
502
- if (scrollToItem) {
503
- scrollToItem(focusedKey);
504
- } else {
505
- virtualizer.scrollToItem(focusedKey, {
506
- duration: 0
507
- });
508
- }
509
- }
510
452
 
511
- isFocusWithin.current = e.target !== ref.current;
512
- }, [ref, virtualizer, focusedKey, scrollToItem]);
513
- let onBlur = useCallback(e => {
514
- isFocusWithin.current = ref.current.contains(e.relatedTarget);
515
- }, [ref]); // When the focused item is scrolled out of view and is removed from the DOM,
516
- // move focus to the collection view as a whole if focus was within before.
517
-
518
- let focusedView = virtualizer.getView(focusedKey);
519
- useEffect(() => {
520
- if (focusedKey && !focusedView && isFocusWithin.current && document.activeElement !== ref.current) {
521
- focusWithoutScrolling(ref.current);
522
- }
523
- }); // Set tabIndex to -1 if the focused view is in the DOM, otherwise 0 so that the collection
524
- // itself is tabbable. When the collection receives focus, we scroll the focused item back into
525
- // view, which will allow it to be properly focused. If using virtual focus, don't set a
526
- // tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.
527
-
528
- let tabIndex;
529
-
530
- if (!shouldUseVirtualFocus) {
531
- tabIndex = focusedView ? -1 : 0;
532
- }
533
-
534
- return {
535
- virtualizerProps: {
536
- tabIndex,
537
- onFocus,
538
- onBlur
539
- }
540
- };
541
- } // forwardRef doesn't support generic parameters, so cast the result to the correct type
542
- // https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
543
453
 
544
454
 
545
- exports.useVirtualizer = useVirtualizer;
546
455
 
547
- const Virtualizer = /*#__PURE__*/_react.forwardRef($c6087bb500e3bca67ce9dc45886$var$Virtualizer);
456
+ $parcel$exportWildcard(module.exports, $aea84f7f089eb7a5$exports);
457
+ $parcel$exportWildcard(module.exports, $f717a8199f2123af$exports);
458
+ $parcel$exportWildcard(module.exports, $d8772f25e0f98a8d$exports);
459
+ $parcel$exportWildcard(module.exports, $3e3c2bf282fde6af$exports);
460
+ $parcel$exportWildcard(module.exports, $8b6aaa6593623080$exports);
548
461
 
549
- exports.Virtualizer = Virtualizer;
550
462
 
551
- function $c6087bb500e3bca67ce9dc45886$var$defaultRenderWrapper(parent, reusableView) {
552
- return /*#__PURE__*/_react.createElement(VirtualizerItem, {
553
- key: reusableView.key,
554
- reusableView: reusableView,
555
- parent: parent
556
- });
557
- }
558
463
  //# sourceMappingURL=main.js.map