@react-aria/virtualizer 4.1.13 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/import.mjs +6 -6
  2. package/dist/main.js +14 -14
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +7 -0
  7. package/package.json +15 -16
  8. package/src/index.ts +8 -7
  9. package/dist/ScrollView.main.js +0 -228
  10. package/dist/ScrollView.main.js.map +0 -1
  11. package/dist/ScrollView.mjs +0 -218
  12. package/dist/ScrollView.module.js +0 -218
  13. package/dist/ScrollView.module.js.map +0 -1
  14. package/dist/Virtualizer.main.js +0 -84
  15. package/dist/Virtualizer.main.js.map +0 -1
  16. package/dist/Virtualizer.mjs +0 -75
  17. package/dist/Virtualizer.module.js +0 -75
  18. package/dist/Virtualizer.module.js.map +0 -1
  19. package/dist/VirtualizerItem.main.js +0 -90
  20. package/dist/VirtualizerItem.main.js.map +0 -1
  21. package/dist/VirtualizerItem.mjs +0 -80
  22. package/dist/VirtualizerItem.module.js +0 -80
  23. package/dist/VirtualizerItem.module.js.map +0 -1
  24. package/dist/types.d.ts +0 -60
  25. package/dist/types.d.ts.map +0 -1
  26. package/dist/useVirtualizerItem.main.js +0 -54
  27. package/dist/useVirtualizerItem.main.js.map +0 -1
  28. package/dist/useVirtualizerItem.mjs +0 -49
  29. package/dist/useVirtualizerItem.module.js +0 -49
  30. package/dist/useVirtualizerItem.module.js.map +0 -1
  31. package/dist/utils.main.js +0 -80
  32. package/dist/utils.main.js.map +0 -1
  33. package/dist/utils.mjs +0 -73
  34. package/dist/utils.module.js +0 -73
  35. package/dist/utils.module.js.map +0 -1
  36. package/src/ScrollView.tsx +0 -282
  37. package/src/Virtualizer.tsx +0 -113
  38. package/src/VirtualizerItem.tsx +0 -93
  39. package/src/useVirtualizerItem.ts +0 -55
  40. package/src/utils.ts +0 -107
package/dist/import.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import {Virtualizer as $6d0a5c394373ae64$export$89be5a243e59c4b2} from "./Virtualizer.mjs";
2
- import {useVirtualizerItem as $47736c1e63ba1c6d$export$1da781778207e0a2} from "./useVirtualizerItem.mjs";
3
- import {layoutInfoToStyle as $ccf8a0a04e4175ae$export$1481e64fbe01b8b3, VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.mjs";
4
- import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea, useScrollView as $44a6ee657928b002$export$2ea0c4974da4731b} from "./ScrollView.mjs";
5
- import {getRTLOffsetType as $ce415dc67314b753$export$faf7630257ad4304, getScrollLeft as $ce415dc67314b753$export$1389d168952b34b5, setScrollLeft as $ce415dc67314b753$export$ed5fd5ffe5ab0ac} from "./utils.mjs";
1
+ import {Virtualizer as $1c09d0c4731e56b6$re_export$Virtualizer} from "react-aria/private/virtualizer/Virtualizer";
2
+ import {useVirtualizerItem as $1c09d0c4731e56b6$re_export$useVirtualizerItem} from "react-aria/private/virtualizer/useVirtualizerItem";
3
+ import {VirtualizerItem as $1c09d0c4731e56b6$re_export$VirtualizerItem, layoutInfoToStyle as $1c09d0c4731e56b6$re_export$layoutInfoToStyle} from "react-aria/private/virtualizer/VirtualizerItem";
4
+ import {ScrollView as $1c09d0c4731e56b6$re_export$ScrollView, useScrollView as $1c09d0c4731e56b6$re_export$useScrollView} from "react-aria/private/virtualizer/ScrollView";
5
+ import {getRTLOffsetType as $1c09d0c4731e56b6$re_export$getRTLOffsetType, getScrollLeft as $1c09d0c4731e56b6$re_export$getScrollLeft, setScrollLeft as $1c09d0c4731e56b6$re_export$setScrollLeft} from "react-aria/private/virtualizer/utils";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -21,5 +21,5 @@ import {getRTLOffsetType as $ce415dc67314b753$export$faf7630257ad4304, getScroll
21
21
 
22
22
 
23
23
 
24
- export {$6d0a5c394373ae64$export$89be5a243e59c4b2 as Virtualizer, $47736c1e63ba1c6d$export$1da781778207e0a2 as useVirtualizerItem, $ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle, $44a6ee657928b002$export$5665e3d6be6adea as ScrollView, $44a6ee657928b002$export$2ea0c4974da4731b as useScrollView, $ce415dc67314b753$export$faf7630257ad4304 as getRTLOffsetType, $ce415dc67314b753$export$1389d168952b34b5 as getScrollLeft, $ce415dc67314b753$export$ed5fd5ffe5ab0ac as setScrollLeft};
24
+ export {$1c09d0c4731e56b6$re_export$Virtualizer as Virtualizer, $1c09d0c4731e56b6$re_export$useVirtualizerItem as useVirtualizerItem, $1c09d0c4731e56b6$re_export$VirtualizerItem as VirtualizerItem, $1c09d0c4731e56b6$re_export$layoutInfoToStyle as layoutInfoToStyle, $1c09d0c4731e56b6$re_export$ScrollView as ScrollView, $1c09d0c4731e56b6$re_export$useScrollView as useScrollView, $1c09d0c4731e56b6$re_export$getRTLOffsetType as getRTLOffsetType, $1c09d0c4731e56b6$re_export$getScrollLeft as getScrollLeft, $1c09d0c4731e56b6$re_export$setScrollLeft as setScrollLeft};
25
25
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,23 +1,23 @@
1
- var $e1fb6f3669e1c329$exports = require("./Virtualizer.main.js");
2
- var $7d70e069fceb2deb$exports = require("./useVirtualizerItem.main.js");
3
- var $d6a26279cc31826b$exports = require("./VirtualizerItem.main.js");
4
- var $00ca8c0b29e3e07c$exports = require("./ScrollView.main.js");
5
- var $efdd61e59e023a1d$exports = require("./utils.main.js");
1
+ var $jdhM1$reactariaprivatevirtualizerVirtualizer = require("react-aria/private/virtualizer/Virtualizer");
2
+ var $jdhM1$reactariaprivatevirtualizeruseVirtualizerItem = require("react-aria/private/virtualizer/useVirtualizerItem");
3
+ var $jdhM1$reactariaprivatevirtualizerVirtualizerItem = require("react-aria/private/virtualizer/VirtualizerItem");
4
+ var $jdhM1$reactariaprivatevirtualizerScrollView = require("react-aria/private/virtualizer/ScrollView");
5
+ var $jdhM1$reactariaprivatevirtualizerutils = require("react-aria/private/virtualizer/utils");
6
6
 
7
7
 
8
8
  function $parcel$export(e, n, v, s) {
9
9
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
10
  }
11
11
 
12
- $parcel$export(module.exports, "Virtualizer", () => $e1fb6f3669e1c329$exports.Virtualizer);
13
- $parcel$export(module.exports, "useVirtualizerItem", () => $7d70e069fceb2deb$exports.useVirtualizerItem);
14
- $parcel$export(module.exports, "VirtualizerItem", () => $d6a26279cc31826b$exports.VirtualizerItem);
15
- $parcel$export(module.exports, "layoutInfoToStyle", () => $d6a26279cc31826b$exports.layoutInfoToStyle);
16
- $parcel$export(module.exports, "ScrollView", () => $00ca8c0b29e3e07c$exports.ScrollView);
17
- $parcel$export(module.exports, "useScrollView", () => $00ca8c0b29e3e07c$exports.useScrollView);
18
- $parcel$export(module.exports, "getRTLOffsetType", () => $efdd61e59e023a1d$exports.getRTLOffsetType);
19
- $parcel$export(module.exports, "getScrollLeft", () => $efdd61e59e023a1d$exports.getScrollLeft);
20
- $parcel$export(module.exports, "setScrollLeft", () => $efdd61e59e023a1d$exports.setScrollLeft);
12
+ $parcel$export(module.exports, "Virtualizer", function () { return $jdhM1$reactariaprivatevirtualizerVirtualizer.Virtualizer; });
13
+ $parcel$export(module.exports, "useVirtualizerItem", function () { return $jdhM1$reactariaprivatevirtualizeruseVirtualizerItem.useVirtualizerItem; });
14
+ $parcel$export(module.exports, "VirtualizerItem", function () { return $jdhM1$reactariaprivatevirtualizerVirtualizerItem.VirtualizerItem; });
15
+ $parcel$export(module.exports, "layoutInfoToStyle", function () { return $jdhM1$reactariaprivatevirtualizerVirtualizerItem.layoutInfoToStyle; });
16
+ $parcel$export(module.exports, "ScrollView", function () { return $jdhM1$reactariaprivatevirtualizerScrollView.ScrollView; });
17
+ $parcel$export(module.exports, "useScrollView", function () { return $jdhM1$reactariaprivatevirtualizerScrollView.useScrollView; });
18
+ $parcel$export(module.exports, "getRTLOffsetType", function () { return $jdhM1$reactariaprivatevirtualizerutils.getRTLOffsetType; });
19
+ $parcel$export(module.exports, "getScrollLeft", function () { return $jdhM1$reactariaprivatevirtualizerutils.getScrollLeft; });
20
+ $parcel$export(module.exports, "setScrollLeft", function () { return $jdhM1$reactariaprivatevirtualizerutils.setScrollLeft; });
21
21
  /*
22
22
  * Copyright 2020 Adobe. All rights reserved.
23
23
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/virtualizer/src/index.ts"],"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\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":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/virtualizer/src/index.ts"],"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\nexport {Virtualizer} from 'react-aria/private/virtualizer/Virtualizer';\n\nexport {useVirtualizerItem} from 'react-aria/private/virtualizer/useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from 'react-aria/private/virtualizer/VirtualizerItem';\nexport {ScrollView, useScrollView} from 'react-aria/private/virtualizer/ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from 'react-aria/private/virtualizer/utils';\nexport type {RTLOffsetType} from 'react-aria/private/virtualizer/utils';\nexport type {VirtualizerItemOptions} from 'react-aria/private/virtualizer/useVirtualizerItem';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,8 +1,8 @@
1
- import {Virtualizer as $6d0a5c394373ae64$export$89be5a243e59c4b2} from "./Virtualizer.module.js";
2
- import {useVirtualizerItem as $47736c1e63ba1c6d$export$1da781778207e0a2} from "./useVirtualizerItem.module.js";
3
- import {layoutInfoToStyle as $ccf8a0a04e4175ae$export$1481e64fbe01b8b3, VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.module.js";
4
- import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea, useScrollView as $44a6ee657928b002$export$2ea0c4974da4731b} from "./ScrollView.module.js";
5
- import {getRTLOffsetType as $ce415dc67314b753$export$faf7630257ad4304, getScrollLeft as $ce415dc67314b753$export$1389d168952b34b5, setScrollLeft as $ce415dc67314b753$export$ed5fd5ffe5ab0ac} from "./utils.module.js";
1
+ import {Virtualizer as $1c09d0c4731e56b6$re_export$Virtualizer} from "react-aria/private/virtualizer/Virtualizer";
2
+ import {useVirtualizerItem as $1c09d0c4731e56b6$re_export$useVirtualizerItem} from "react-aria/private/virtualizer/useVirtualizerItem";
3
+ import {VirtualizerItem as $1c09d0c4731e56b6$re_export$VirtualizerItem, layoutInfoToStyle as $1c09d0c4731e56b6$re_export$layoutInfoToStyle} from "react-aria/private/virtualizer/VirtualizerItem";
4
+ import {ScrollView as $1c09d0c4731e56b6$re_export$ScrollView, useScrollView as $1c09d0c4731e56b6$re_export$useScrollView} from "react-aria/private/virtualizer/ScrollView";
5
+ import {getRTLOffsetType as $1c09d0c4731e56b6$re_export$getRTLOffsetType, getScrollLeft as $1c09d0c4731e56b6$re_export$getScrollLeft, setScrollLeft as $1c09d0c4731e56b6$re_export$setScrollLeft} from "react-aria/private/virtualizer/utils";
6
6
 
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
@@ -21,5 +21,5 @@ import {getRTLOffsetType as $ce415dc67314b753$export$faf7630257ad4304, getScroll
21
21
 
22
22
 
23
23
 
24
- export {$6d0a5c394373ae64$export$89be5a243e59c4b2 as Virtualizer, $47736c1e63ba1c6d$export$1da781778207e0a2 as useVirtualizerItem, $ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle, $44a6ee657928b002$export$5665e3d6be6adea as ScrollView, $44a6ee657928b002$export$2ea0c4974da4731b as useScrollView, $ce415dc67314b753$export$faf7630257ad4304 as getRTLOffsetType, $ce415dc67314b753$export$1389d168952b34b5 as getScrollLeft, $ce415dc67314b753$export$ed5fd5ffe5ab0ac as setScrollLeft};
24
+ export {$1c09d0c4731e56b6$re_export$Virtualizer as Virtualizer, $1c09d0c4731e56b6$re_export$useVirtualizerItem as useVirtualizerItem, $1c09d0c4731e56b6$re_export$VirtualizerItem as VirtualizerItem, $1c09d0c4731e56b6$re_export$layoutInfoToStyle as layoutInfoToStyle, $1c09d0c4731e56b6$re_export$ScrollView as ScrollView, $1c09d0c4731e56b6$re_export$useScrollView as useScrollView, $1c09d0c4731e56b6$re_export$getRTLOffsetType as getRTLOffsetType, $1c09d0c4731e56b6$re_export$getScrollLeft as getScrollLeft, $1c09d0c4731e56b6$re_export$setScrollLeft as setScrollLeft};
25
25
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/virtualizer/src/index.ts"],"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\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":"module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/virtualizer/src/index.ts"],"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\nexport {Virtualizer} from 'react-aria/private/virtualizer/Virtualizer';\n\nexport {useVirtualizerItem} from 'react-aria/private/virtualizer/useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from 'react-aria/private/virtualizer/VirtualizerItem';\nexport {ScrollView, useScrollView} from 'react-aria/private/virtualizer/ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from 'react-aria/private/virtualizer/utils';\nexport type {RTLOffsetType} from 'react-aria/private/virtualizer/utils';\nexport type {VirtualizerItemOptions} from 'react-aria/private/virtualizer/useVirtualizerItem';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,7 @@
1
+ export { Virtualizer } from 'react-aria/private/virtualizer/Virtualizer';
2
+ export { useVirtualizerItem } from 'react-aria/private/virtualizer/useVirtualizerItem';
3
+ export { VirtualizerItem, layoutInfoToStyle } from 'react-aria/private/virtualizer/VirtualizerItem';
4
+ export { ScrollView, useScrollView } from 'react-aria/private/virtualizer/ScrollView';
5
+ export { getRTLOffsetType, getScrollLeft, setScrollLeft } from 'react-aria/private/virtualizer/utils';
6
+ export type { RTLOffsetType } from 'react-aria/private/virtualizer/utils';
7
+ export type { VirtualizerItemOptions } from 'react-aria/private/virtualizer/useVirtualizerItem';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-aria/virtualizer",
3
- "version": "4.1.13",
3
+ "version": "4.2.0",
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
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -26,12 +26,8 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/i18n": "^3.12.16",
30
- "@react-aria/interactions": "^3.27.1",
31
- "@react-aria/utils": "^3.33.1",
32
- "@react-stately/virtualizer": "^4.4.6",
33
- "@react-types/shared": "^3.33.1",
34
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-aria": "3.48.0"
35
31
  },
36
32
  "peerDependencies": {
37
33
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
@@ -40,5 +36,8 @@
40
36
  "publishConfig": {
41
37
  "access": "public"
42
38
  },
43
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
39
+ "targets": {
40
+ "types": false
41
+ },
42
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
44
43
  }
package/src/index.ts CHANGED
@@ -10,10 +10,11 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export type {RTLOffsetType} from './utils';
14
- export type {VirtualizerItemOptions} from './useVirtualizerItem';
15
- export {Virtualizer} from './Virtualizer';
16
- export {useVirtualizerItem} from './useVirtualizerItem';
17
- export {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';
18
- export {ScrollView, useScrollView} from './ScrollView';
19
- export {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';
13
+ export {Virtualizer} from 'react-aria/private/virtualizer/Virtualizer';
14
+
15
+ export {useVirtualizerItem} from 'react-aria/private/virtualizer/useVirtualizerItem';
16
+ export {VirtualizerItem, layoutInfoToStyle} from 'react-aria/private/virtualizer/VirtualizerItem';
17
+ export {ScrollView, useScrollView} from 'react-aria/private/virtualizer/ScrollView';
18
+ export {getRTLOffsetType, getScrollLeft, setScrollLeft} from 'react-aria/private/virtualizer/utils';
19
+ export type {RTLOffsetType} from 'react-aria/private/virtualizer/utils';
20
+ export type {VirtualizerItemOptions} from 'react-aria/private/virtualizer/useVirtualizerItem';
@@ -1,228 +0,0 @@
1
- var $efdd61e59e023a1d$exports = require("./utils.main.js");
2
- var $kvIfm$reactdom = require("react-dom");
3
- var $kvIfm$reactariautils = require("@react-aria/utils");
4
- var $kvIfm$react = require("react");
5
- var $kvIfm$reactstatelyvirtualizer = require("@react-stately/virtualizer");
6
- var $kvIfm$reactariai18n = require("@react-aria/i18n");
7
-
8
-
9
- function $parcel$interopDefault(a) {
10
- return a && a.__esModule ? a.default : a;
11
- }
12
-
13
- function $parcel$export(e, n, v, s) {
14
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
15
- }
16
-
17
- $parcel$export(module.exports, "useScrollView", () => $00ca8c0b29e3e07c$export$2ea0c4974da4731b);
18
- $parcel$export(module.exports, "ScrollView", () => $00ca8c0b29e3e07c$export$5665e3d6be6adea);
19
- /*
20
- * Copyright 2020 Adobe. All rights reserved.
21
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
- * you may not use this file except in compliance with the License. You may obtain a copy
23
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
24
- *
25
- * Unless required by applicable law or agreed to in writing, software distributed under
26
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
27
- * OF ANY KIND, either express or implied. See the License for the specific language
28
- * governing permissions and limitations under the License.
29
- */ // @ts-ignore
30
-
31
-
32
-
33
-
34
-
35
-
36
- function $00ca8c0b29e3e07c$var$ScrollView(props, ref) {
37
- ref = (0, $kvIfm$reactariautils.useObjectRef)(ref);
38
- let { scrollViewProps: scrollViewProps, contentProps: contentProps } = $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref);
39
- return /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).createElement("div", {
40
- role: "presentation",
41
- ...scrollViewProps,
42
- ref: ref
43
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).createElement("div", contentProps, props.children));
44
- }
45
- const $00ca8c0b29e3e07c$export$5665e3d6be6adea = /*#__PURE__*/ (0, ($parcel$interopDefault($kvIfm$react))).forwardRef($00ca8c0b29e3e07c$var$ScrollView);
46
- function $00ca8c0b29e3e07c$export$2ea0c4974da4731b(props, ref) {
47
- let { contentSize: contentSize, onVisibleRectChange: onVisibleRectChange, innerStyle: innerStyle, onScrollStart: onScrollStart, onScrollEnd: onScrollEnd, scrollDirection: scrollDirection = 'both', ...otherProps } = props;
48
- let state = (0, $kvIfm$react.useRef)({
49
- scrollTop: 0,
50
- scrollLeft: 0,
51
- scrollEndTime: 0,
52
- scrollTimeout: null,
53
- width: 0,
54
- height: 0,
55
- isScrolling: false
56
- }).current;
57
- let { direction: direction } = (0, $kvIfm$reactariai18n.useLocale)();
58
- let [isScrolling, setScrolling] = (0, $kvIfm$react.useState)(false);
59
- let onScroll = (0, $kvIfm$react.useCallback)((e)=>{
60
- if ((0, $kvIfm$reactariautils.getEventTarget)(e) !== e.currentTarget) return;
61
- if (props.onScroll) props.onScroll(e);
62
- (0, $kvIfm$reactdom.flushSync)(()=>{
63
- let scrollTop = e.currentTarget.scrollTop;
64
- let scrollLeft = (0, $efdd61e59e023a1d$exports.getScrollLeft)(e.currentTarget, direction);
65
- // Prevent rubber band scrolling from shaking when scrolling out of bounds
66
- state.scrollTop = Math.max(0, Math.min(scrollTop, contentSize.height - state.height));
67
- state.scrollLeft = Math.max(0, Math.min(scrollLeft, contentSize.width - state.width));
68
- onVisibleRectChange(new (0, $kvIfm$reactstatelyvirtualizer.Rect)(state.scrollLeft, state.scrollTop, state.width, state.height));
69
- if (!state.isScrolling) {
70
- state.isScrolling = true;
71
- setScrolling(true);
72
- // Pause typekit MutationObserver during scrolling.
73
- window.dispatchEvent(new Event('tk.disconnect-observer'));
74
- if (onScrollStart) onScrollStart();
75
- }
76
- // So we don't constantly call clearTimeout and setTimeout,
77
- // keep track of the current timeout time and only reschedule
78
- // the timer when it is getting close.
79
- let now = Date.now();
80
- if (state.scrollEndTime <= now + 50) {
81
- state.scrollEndTime = now + 300;
82
- if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
83
- state.scrollTimeout = setTimeout(()=>{
84
- state.isScrolling = false;
85
- setScrolling(false);
86
- state.scrollTimeout = null;
87
- window.dispatchEvent(new Event('tk.connect-observer'));
88
- if (onScrollEnd) onScrollEnd();
89
- }, 300);
90
- }
91
- });
92
- }, [
93
- props,
94
- direction,
95
- state,
96
- contentSize,
97
- onVisibleRectChange,
98
- onScrollStart,
99
- onScrollEnd
100
- ]);
101
- // Attach event directly to ref so RAC Virtualizer doesn't need to send props upward.
102
- (0, $kvIfm$reactariautils.useEvent)(ref, 'scroll', onScroll);
103
- (0, $kvIfm$react.useEffect)(()=>{
104
- return ()=>{
105
- if (state.scrollTimeout != null) clearTimeout(state.scrollTimeout);
106
- if (state.isScrolling) window.dispatchEvent(new Event('tk.connect-observer'));
107
- };
108
- // eslint-disable-next-line react-hooks/exhaustive-deps
109
- }, []);
110
- let isUpdatingSize = (0, $kvIfm$react.useRef)(false);
111
- let updateSize = (0, $kvIfm$react.useCallback)((flush)=>{
112
- let dom = ref.current;
113
- if (!dom || isUpdatingSize.current) return;
114
- // Prevent reentrancy when resize observer fires, triggers re-layout that results in
115
- // content size update, causing below layout effect to fire. This avoids infinite loops.
116
- isUpdatingSize.current = true;
117
- let isTestEnv = process.env.NODE_ENV === 'test' && !process.env.VIRT_ON;
118
- let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth');
119
- let isClientHeightMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientHeight');
120
- let clientWidth = dom.clientWidth;
121
- let clientHeight = dom.clientHeight;
122
- let w = isTestEnv && !isClientWidthMocked ? Infinity : clientWidth;
123
- let h = isTestEnv && !isClientHeightMocked ? Infinity : clientHeight;
124
- if (state.width !== w || state.height !== h) {
125
- state.width = w;
126
- state.height = h;
127
- flush(()=>{
128
- onVisibleRectChange(new (0, $kvIfm$reactstatelyvirtualizer.Rect)(state.scrollLeft, state.scrollTop, w, h));
129
- });
130
- // If the clientWidth or clientHeight changed, scrollbars appeared or disappeared as
131
- // a result of the layout update. In this case, re-layout again to account for the
132
- // adjusted space. In very specific cases this might result in the scrollbars disappearing
133
- // again, resulting in extra padding. We stop after a maximum of two layout passes to avoid
134
- // an infinite loop. This matches how browsers behavior with native CSS grid layout.
135
- if (!isTestEnv && clientWidth !== dom.clientWidth || clientHeight !== dom.clientHeight) {
136
- state.width = dom.clientWidth;
137
- state.height = dom.clientHeight;
138
- flush(()=>{
139
- onVisibleRectChange(new (0, $kvIfm$reactstatelyvirtualizer.Rect)(state.scrollLeft, state.scrollTop, state.width, state.height));
140
- });
141
- }
142
- }
143
- isUpdatingSize.current = false;
144
- }, [
145
- ref,
146
- state,
147
- onVisibleRectChange
148
- ]);
149
- let updateSizeEvent = (0, $kvIfm$reactariautils.useEffectEvent)(updateSize);
150
- // Update visible rect when the content size changes, in case scrollbars need to appear or disappear.
151
- let lastContentSize = (0, $kvIfm$react.useRef)(null);
152
- let [update, setUpdate] = (0, $kvIfm$react.useState)({});
153
- // We only contain a call to setState in here for testing environments.
154
- // eslint-disable-next-line react-hooks/exhaustive-deps
155
- (0, $kvIfm$reactariautils.useLayoutEffect)(()=>{
156
- if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) {
157
- // React doesn't allow flushSync inside effects, so queue a microtask.
158
- // We also need to wait until all refs are set (e.g. when passing a ref down from a parent).
159
- // If we are in an `act` environment, update immediately without a microtask so you don't need
160
- // to mock timers in tests. In this case, the update is synchronous already.
161
- // IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global.
162
- // https://github.com/reactwg/react-18/discussions/102
163
- // @ts-ignore
164
- if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') {
165
- // This is so we update size in a separate render but within the same act. Needs to be setState instead of refs
166
- // due to strict mode.
167
- setUpdate({});
168
- lastContentSize.current = contentSize;
169
- return;
170
- } else queueMicrotask(()=>updateSizeEvent((0, $kvIfm$reactdom.flushSync)));
171
- }
172
- lastContentSize.current = contentSize;
173
- });
174
- // Will only run in tests, needs to be in separate effect so it is properly run in the next render in strict mode.
175
- (0, $kvIfm$reactariautils.useLayoutEffect)(()=>{
176
- updateSizeEvent((fn)=>fn());
177
- }, [
178
- update
179
- ]);
180
- let onResize = (0, $kvIfm$react.useCallback)(()=>{
181
- updateSize((0, $kvIfm$reactdom.flushSync));
182
- }, [
183
- updateSize
184
- ]);
185
- // Watch border-box instead of of content-box so that we don't go into
186
- // an infinite loop when scrollbars appear or disappear.
187
- (0, $kvIfm$reactariautils.useResizeObserver)({
188
- ref: ref,
189
- box: 'border-box',
190
- onResize: onResize
191
- });
192
- let style = {
193
- // Reset padding so that relative positioning works correctly. Padding will be done in JS layout.
194
- padding: 0,
195
- ...otherProps.style
196
- };
197
- if (scrollDirection === 'horizontal') {
198
- style.overflowX = 'auto';
199
- style.overflowY = 'hidden';
200
- } else if (scrollDirection === 'vertical' || contentSize.width === state.width) {
201
- // Set overflow-x: hidden if content size is equal to the width of the scroll view.
202
- // This prevents horizontal scrollbars from flickering during resizing due to resize observer
203
- // firing slower than the frame rate, which may cause an infinite re-render loop.
204
- style.overflowY = 'auto';
205
- style.overflowX = 'hidden';
206
- } else style.overflow = 'auto';
207
- innerStyle = {
208
- width: Number.isFinite(contentSize.width) ? contentSize.width : undefined,
209
- height: Number.isFinite(contentSize.height) ? contentSize.height : undefined,
210
- pointerEvents: isScrolling ? 'none' : 'auto',
211
- position: 'relative',
212
- ...innerStyle
213
- };
214
- return {
215
- isScrolling: isScrolling,
216
- scrollViewProps: {
217
- ...otherProps,
218
- style: style
219
- },
220
- contentProps: {
221
- role: 'presentation',
222
- style: innerStyle
223
- }
224
- };
225
- }
226
-
227
-
228
- //# sourceMappingURL=ScrollView.main.js.map
@@ -1 +0,0 @@
1
- {"mapp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AI,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;qBACL;QACA,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 {getEventTarget, useEffectEvent, useEvent, useLayoutEffect, useObjectRef, useResizeObserver} from '@react-aria/utils';\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 {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:\n React.ForwardRefExoticComponent<ScrollViewProps & React.RefAttributes<HTMLDivElement | null>> =\nReact.forwardRef(ScrollView);\nexport {ScrollViewForwardRef as ScrollView};\n\ninterface ScrollViewAria {\n isScrolling: boolean,\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\n let onScroll = useCallback((e) => {\n if (getEventTarget(e) !== 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 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 = useCallback((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 }, [ref, state, onVisibleRectChange]);\n let updateSizeEvent = useEffectEvent(updateSize);\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 // We only contain a call to setState in here for testing environments.\n // eslint-disable-next-line react-hooks/exhaustive-deps\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(() => updateSizeEvent(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 updateSizeEvent(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 isScrolling,\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"}