@react-stately/virtualizer 3.6.9-nightly.4555 → 3.6.9-nightly.4558

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 (66) hide show
  1. package/dist/Layout.main.js +75 -0
  2. package/dist/Layout.main.js.map +1 -0
  3. package/dist/Layout.mjs +70 -0
  4. package/dist/Layout.module.js +70 -0
  5. package/dist/Layout.module.js.map +1 -0
  6. package/dist/LayoutInfo.main.js +51 -0
  7. package/dist/LayoutInfo.main.js.map +1 -0
  8. package/dist/LayoutInfo.mjs +46 -0
  9. package/dist/LayoutInfo.module.js +46 -0
  10. package/dist/LayoutInfo.module.js.map +1 -0
  11. package/dist/OverscanManager.main.js +87 -0
  12. package/dist/OverscanManager.main.js.map +1 -0
  13. package/dist/OverscanManager.mjs +82 -0
  14. package/dist/OverscanManager.module.js +82 -0
  15. package/dist/OverscanManager.module.js.map +1 -0
  16. package/dist/Point.main.js +40 -0
  17. package/dist/Point.main.js.map +1 -0
  18. package/dist/Point.mjs +35 -0
  19. package/dist/Point.module.js +35 -0
  20. package/dist/Point.module.js.map +1 -0
  21. package/dist/Rect.main.js +130 -0
  22. package/dist/Rect.main.js.map +1 -0
  23. package/dist/Rect.mjs +125 -0
  24. package/dist/Rect.module.js +125 -0
  25. package/dist/Rect.module.js.map +1 -0
  26. package/dist/ReusableView.main.js +33 -0
  27. package/dist/ReusableView.main.js.map +1 -0
  28. package/dist/ReusableView.mjs +28 -0
  29. package/dist/ReusableView.module.js +28 -0
  30. package/dist/ReusableView.module.js.map +1 -0
  31. package/dist/Size.main.js +40 -0
  32. package/dist/Size.main.js.map +1 -0
  33. package/dist/Size.mjs +35 -0
  34. package/dist/Size.module.js +35 -0
  35. package/dist/Size.module.js.map +1 -0
  36. package/dist/Transaction.main.js +32 -0
  37. package/dist/Transaction.main.js.map +1 -0
  38. package/dist/Transaction.mjs +27 -0
  39. package/dist/Transaction.module.js +27 -0
  40. package/dist/Transaction.module.js.map +1 -0
  41. package/dist/Virtualizer.main.js +813 -0
  42. package/dist/Virtualizer.main.js.map +1 -0
  43. package/dist/Virtualizer.mjs +808 -0
  44. package/dist/Virtualizer.module.js +808 -0
  45. package/dist/Virtualizer.module.js.map +1 -0
  46. package/dist/import.mjs +7 -1399
  47. package/dist/main.js +14 -1406
  48. package/dist/main.js.map +1 -1
  49. package/dist/module.js +7 -1399
  50. package/dist/module.js.map +1 -1
  51. package/dist/tween.main.js +67 -0
  52. package/dist/tween.main.js.map +1 -0
  53. package/dist/tween.mjs +61 -0
  54. package/dist/tween.module.js +61 -0
  55. package/dist/tween.module.js.map +1 -0
  56. package/dist/useVirtualizerState.main.js +96 -0
  57. package/dist/useVirtualizerState.main.js.map +1 -0
  58. package/dist/useVirtualizerState.mjs +91 -0
  59. package/dist/useVirtualizerState.module.js +91 -0
  60. package/dist/useVirtualizerState.module.js.map +1 -0
  61. package/dist/utils.main.js +53 -0
  62. package/dist/utils.main.js.map +1 -0
  63. package/dist/utils.mjs +46 -0
  64. package/dist/utils.module.js +46 -0
  65. package/dist/utils.module.js.map +1 -0
  66. package/package.json +4 -4
@@ -0,0 +1,82 @@
1
+ import {Point as $3041db3296945e6e$export$baf26146a414f24a} from "./Point.module.js";
2
+ import {Rect as $60423f92c7f9ad87$export$c79fc6492f3af13d} from "./Rect.module.js";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+ class $364191b3decf3697$var$RollingAverage {
17
+ addSample(sample) {
18
+ this.count++;
19
+ this.value += (sample - this.value) / this.count;
20
+ }
21
+ constructor(){
22
+ this.count = 0;
23
+ this.value = 0;
24
+ }
25
+ }
26
+ class $364191b3decf3697$export$4455ee6afb38dcbb {
27
+ setVisibleRect(rect) {
28
+ let time = performance.now() - this.startTime;
29
+ if (time < 500) {
30
+ this.averageTime.addSample(time);
31
+ if (rect.x !== this.visibleRect.x && time > 0) this.velocity.x = (rect.x - this.visibleRect.x) / time;
32
+ if (rect.y !== this.visibleRect.y && time > 0) this.velocity.y = (rect.y - this.visibleRect.y) / time;
33
+ }
34
+ this.startTime = performance.now();
35
+ this.visibleRect = rect;
36
+ }
37
+ collectMetrics() {
38
+ let time = performance.now() - this.startTime;
39
+ if (time < 500) this.averagePerf.addSample(time);
40
+ if (this.visibleRect.height > 0) {
41
+ let o = Math.abs(this.velocity.y * (this.averageTime.value + this.averagePerf.value));
42
+ this.overscanY.addSample(o);
43
+ }
44
+ if (this.visibleRect.width > 0) {
45
+ let o = Math.abs(this.velocity.x * (this.averageTime.value + this.averagePerf.value));
46
+ this.overscanX.addSample(o);
47
+ }
48
+ }
49
+ getOverscannedRect() {
50
+ let overscanned = this.visibleRect.copy();
51
+ let overscanY = Math.round(Math.min(this.visibleRect.height * 2, this.overscanY.value) / 100) * 100;
52
+ if (this.velocity.y > 0) {
53
+ overscanned.y -= overscanY * 0.2;
54
+ overscanned.height += overscanY + overscanY * 0.2;
55
+ } else {
56
+ overscanned.y -= overscanY;
57
+ overscanned.height += overscanY + overscanY * 0.2;
58
+ }
59
+ let overscanX = Math.round(Math.min(this.visibleRect.width * 2, this.overscanX.value) / 100) * 100;
60
+ if (this.velocity.x > 0) {
61
+ overscanned.x -= overscanX * 0.2;
62
+ overscanned.width += overscanX + overscanX * 0.2;
63
+ } else {
64
+ overscanned.x -= overscanX;
65
+ overscanned.width += overscanX + overscanX * 0.2;
66
+ }
67
+ return overscanned;
68
+ }
69
+ constructor(){
70
+ this.startTime = 0;
71
+ this.averagePerf = new $364191b3decf3697$var$RollingAverage();
72
+ this.averageTime = new $364191b3decf3697$var$RollingAverage();
73
+ this.velocity = new (0, $3041db3296945e6e$export$baf26146a414f24a)(5, 5);
74
+ this.overscanX = new $364191b3decf3697$var$RollingAverage();
75
+ this.overscanY = new $364191b3decf3697$var$RollingAverage();
76
+ this.visibleRect = new (0, $60423f92c7f9ad87$export$c79fc6492f3af13d)();
77
+ }
78
+ }
79
+
80
+
81
+ export {$364191b3decf3697$export$4455ee6afb38dcbb as OverscanManager};
82
+ //# sourceMappingURL=OverscanManager.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAKD,MAAM;IAIJ,UAAU,MAAc,EAAE;QACxB,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK,IAAI,AAAC,CAAA,SAAS,IAAI,CAAC,KAAK,AAAD,IAAK,IAAI,CAAC,KAAK;IAClD;;aANQ,QAAgB;aACxB,QAAgB;;AAMlB;AAEO,MAAM;IASX,eAAe,IAAU,EAAE;QACzB,IAAI,OAAO,YAAY,GAAG,KAAK,IAAI,CAAC,SAAS;QAC7C,IAAI,OAAO,KAAK;YACd,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YAE3B,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;YAGpD,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,OAAO,GAC1C,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,AAAC,CAAA,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,AAAD,IAAK;QAEtD;QAEA,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG;QAChC,IAAI,CAAC,WAAW,GAAG;IACrB;IAEA,iBAAiB;QACf,IAAI,OAAO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AAI,YAAY;YAC7B,YAAY,KAAK,IAAI,YAAY,YAAY;QAC/C,OAAO;YACL,YAAY,CAAC,IAAI;YACjB,YAAY,KAAK,IAAI,YAAY,YAAY;QAC/C;QAEA,OAAO;IACT;;aAjEQ,YAAY;aACZ,cAAc,IAAI;aAClB,cAAc,IAAI;aAClB,WAAW,IAAI,CAAA,GAAA,yCAAI,EAAE,GAAG;aACxB,YAAY,IAAI;aAChB,YAAY,IAAI;aAChB,cAAc,IAAI,CAAA,GAAA,yCAAG;;AA4D/B","sources":["packages/@react-stately/virtualizer/src/OverscanManager.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\nimport {Point} from './Point';\nimport {Rect} from './Rect';\n\nclass RollingAverage {\n private count: number = 0;\n value: number = 0;\n \n addSample(sample: number) {\n this.count++;\n this.value += (sample - this.value) / this.count;\n }\n}\n\nexport class OverscanManager {\n private startTime = 0;\n private averagePerf = new RollingAverage();\n private averageTime = new RollingAverage();\n private velocity = new Point(5, 5);\n private overscanX = new RollingAverage();\n private overscanY = new RollingAverage();\n private visibleRect = new Rect();\n \n setVisibleRect(rect: Rect) {\n let time = performance.now() - this.startTime;\n if (time < 500) {\n this.averageTime.addSample(time);\n\n if (rect.x !== this.visibleRect.x && time > 0) {\n this.velocity.x = (rect.x - this.visibleRect.x) / time;\n }\n\n if (rect.y !== this.visibleRect.y && time > 0) {\n this.velocity.y = (rect.y - this.visibleRect.y) / time;\n }\n }\n\n this.startTime = performance.now();\n this.visibleRect = rect;\n }\n\n collectMetrics() {\n let time = performance.now() - this.startTime;\n if (time < 500) {\n this.averagePerf.addSample(time);\n }\n\n if (this.visibleRect.height > 0) {\n let o = Math.abs(this.velocity.y * (this.averageTime.value + this.averagePerf.value)); \n this.overscanY.addSample(o);\n }\n\n if (this.visibleRect.width > 0) {\n let o = Math.abs(this.velocity.x * (this.averageTime.value + this.averagePerf.value)); \n this.overscanX.addSample(o);\n }\n }\n\n getOverscannedRect() {\n let overscanned = this.visibleRect.copy();\n\n let overscanY = Math.round(Math.min(this.visibleRect.height * 2, this.overscanY.value) / 100) * 100;\n if (this.velocity.y > 0) {\n overscanned.y -= overscanY * 0.2;\n overscanned.height += overscanY + overscanY * 0.2;\n } else {\n overscanned.y -= overscanY;\n overscanned.height += overscanY + overscanY * 0.2;\n }\n\n let overscanX = Math.round(Math.min(this.visibleRect.width * 2, this.overscanX.value) / 100) * 100;\n if (this.velocity.x > 0) {\n overscanned.x -= overscanX * 0.2;\n overscanned.width += overscanX + overscanX * 0.2;\n } else {\n overscanned.x -= overscanX;\n overscanned.width += overscanX + overscanX * 0.2;\n }\n\n return overscanned;\n }\n}\n"],"names":[],"version":3,"file":"OverscanManager.module.js.map"}
@@ -0,0 +1,40 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "Point", () => $f89f15d7f52bce29$export$baf26146a414f24a);
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ class $f89f15d7f52bce29$export$baf26146a414f24a {
18
+ /**
19
+ * Returns a copy of this point.
20
+ */ copy() {
21
+ return new $f89f15d7f52bce29$export$baf26146a414f24a(this.x, this.y);
22
+ }
23
+ /**
24
+ * Checks if two points are equal.
25
+ */ equals(point) {
26
+ return this.x === point.x && this.y === point.y;
27
+ }
28
+ /**
29
+ * Returns true if this point is the origin.
30
+ */ isOrigin() {
31
+ return this.x === 0 && this.y === 0;
32
+ }
33
+ constructor(x = 0, y = 0){
34
+ this.x = x;
35
+ this.y = y;
36
+ }
37
+ }
38
+
39
+
40
+ //# sourceMappingURL=Point.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAEM,MAAM;IAYX;;GAEC,GACD,OAAc;QACZ,OAAO,IAAI,0CAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC;IAEA;;GAEC,GACD,OAAO,KAAY,EAAW;QAC5B,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC;IACjD;IAEA;;GAEC,GACD,WAAoB;QAClB,OAAO,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK;IACpC;IAxBA,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,CAAE;QACxB,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,CAAC,GAAG;IACX;AAsBF","sources":["packages/@react-stately/virtualizer/src/Point.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 class Point {\n /** The x-coordinate of the point. */\n x: number;\n\n /** The y-coordinate of the point. */\n y: number;\n\n constructor(x = 0, y = 0) {\n this.x = x;\n this.y = y;\n }\n\n /**\n * Returns a copy of this point.\n */\n copy(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Checks if two points are equal.\n */\n equals(point: Point): boolean {\n return this.x === point.x && this.y === point.y;\n }\n\n /**\n * Returns true if this point is the origin.\n */\n isOrigin(): boolean {\n return this.x === 0 && this.y === 0;\n }\n}\n"],"names":[],"version":3,"file":"Point.main.js.map"}
package/dist/Point.mjs ADDED
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $3041db3296945e6e$export$baf26146a414f24a {
12
+ /**
13
+ * Returns a copy of this point.
14
+ */ copy() {
15
+ return new $3041db3296945e6e$export$baf26146a414f24a(this.x, this.y);
16
+ }
17
+ /**
18
+ * Checks if two points are equal.
19
+ */ equals(point) {
20
+ return this.x === point.x && this.y === point.y;
21
+ }
22
+ /**
23
+ * Returns true if this point is the origin.
24
+ */ isOrigin() {
25
+ return this.x === 0 && this.y === 0;
26
+ }
27
+ constructor(x = 0, y = 0){
28
+ this.x = x;
29
+ this.y = y;
30
+ }
31
+ }
32
+
33
+
34
+ export {$3041db3296945e6e$export$baf26146a414f24a as Point};
35
+ //# sourceMappingURL=Point.mjs.map
@@ -0,0 +1,35 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ class $3041db3296945e6e$export$baf26146a414f24a {
12
+ /**
13
+ * Returns a copy of this point.
14
+ */ copy() {
15
+ return new $3041db3296945e6e$export$baf26146a414f24a(this.x, this.y);
16
+ }
17
+ /**
18
+ * Checks if two points are equal.
19
+ */ equals(point) {
20
+ return this.x === point.x && this.y === point.y;
21
+ }
22
+ /**
23
+ * Returns true if this point is the origin.
24
+ */ isOrigin() {
25
+ return this.x === 0 && this.y === 0;
26
+ }
27
+ constructor(x = 0, y = 0){
28
+ this.x = x;
29
+ this.y = y;
30
+ }
31
+ }
32
+
33
+
34
+ export {$3041db3296945e6e$export$baf26146a414f24a as Point};
35
+ //# sourceMappingURL=Point.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAEM,MAAM;IAYX;;GAEC,GACD,OAAc;QACZ,OAAO,IAAI,0CAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC;IAEA;;GAEC,GACD,OAAO,KAAY,EAAW;QAC5B,OAAO,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,MAAM,CAAC;IACjD;IAEA;;GAEC,GACD,WAAoB;QAClB,OAAO,IAAI,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,KAAK;IACpC;IAxBA,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,CAAE;QACxB,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,CAAC,GAAG;IACX;AAsBF","sources":["packages/@react-stately/virtualizer/src/Point.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 class Point {\n /** The x-coordinate of the point. */\n x: number;\n\n /** The y-coordinate of the point. */\n y: number;\n\n constructor(x = 0, y = 0) {\n this.x = x;\n this.y = y;\n }\n\n /**\n * Returns a copy of this point.\n */\n copy(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * Checks if two points are equal.\n */\n equals(point: Point): boolean {\n return this.x === point.x && this.y === point.y;\n }\n\n /**\n * Returns true if this point is the origin.\n */\n isOrigin(): boolean {\n return this.x === 0 && this.y === 0;\n }\n}\n"],"names":[],"version":3,"file":"Point.module.js.map"}
@@ -0,0 +1,130 @@
1
+ var $f89f15d7f52bce29$exports = require("./Point.main.js");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "Rect", () => $41b7691783731623$export$c79fc6492f3af13d);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ class $41b7691783731623$export$c79fc6492f3af13d {
21
+ /**
22
+ * The maximum x-coordinate in the rectangle.
23
+ */ get maxX() {
24
+ return this.x + this.width;
25
+ }
26
+ /**
27
+ * The maximum y-coordinate in the rectangle.
28
+ */ get maxY() {
29
+ return this.y + this.height;
30
+ }
31
+ /**
32
+ * The area of the rectangle.
33
+ */ get area() {
34
+ return this.width * this.height;
35
+ }
36
+ /**
37
+ * The top left corner of the rectangle.
38
+ */ get topLeft() {
39
+ return new (0, $f89f15d7f52bce29$exports.Point)(this.x, this.y);
40
+ }
41
+ /**
42
+ * The top right corner of the rectangle.
43
+ */ get topRight() {
44
+ return new (0, $f89f15d7f52bce29$exports.Point)(this.maxX, this.y);
45
+ }
46
+ /**
47
+ * The bottom left corner of the rectangle.
48
+ */ get bottomLeft() {
49
+ return new (0, $f89f15d7f52bce29$exports.Point)(this.x, this.maxY);
50
+ }
51
+ /**
52
+ * The bottom right corner of the rectangle.
53
+ */ get bottomRight() {
54
+ return new (0, $f89f15d7f52bce29$exports.Point)(this.maxX, this.maxY);
55
+ }
56
+ /**
57
+ * Returns whether this rectangle intersects another rectangle.
58
+ * @param rect - The rectangle to check.
59
+ */ intersects(rect) {
60
+ return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
61
+ }
62
+ /**
63
+ * Returns whether this rectangle fully contains another rectangle.
64
+ * @param rect - The rectangle to check.
65
+ */ containsRect(rect) {
66
+ return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
67
+ }
68
+ /**
69
+ * Returns whether the rectangle contains the given point.
70
+ * @param point - The point to check.
71
+ */ containsPoint(point) {
72
+ return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
73
+ }
74
+ /**
75
+ * Returns the first corner of this rectangle (from top to bottom, left to right)
76
+ * that is contained in the given rectangle, or null of the rectangles do not intersect.
77
+ * @param rect - The rectangle to check.
78
+ */ getCornerInRect(rect) {
79
+ for (let key of [
80
+ "topLeft",
81
+ "topRight",
82
+ "bottomLeft",
83
+ "bottomRight"
84
+ ]){
85
+ if (rect.containsPoint(this[key])) return key;
86
+ }
87
+ return null;
88
+ }
89
+ equals(rect) {
90
+ return rect.x === this.x && rect.y === this.y && rect.width === this.width && rect.height === this.height;
91
+ }
92
+ pointEquals(point) {
93
+ return this.x === point.x && this.y === point.y;
94
+ }
95
+ sizeEquals(size) {
96
+ return this.width === size.width && this.height === size.height;
97
+ }
98
+ /**
99
+ * Returns the union of this Rect and another.
100
+ */ union(other) {
101
+ let x = Math.min(this.x, other.x);
102
+ let y = Math.min(this.y, other.y);
103
+ let width = Math.max(this.maxX, other.maxX) - x;
104
+ let height = Math.max(this.maxY, other.maxY) - y;
105
+ return new $41b7691783731623$export$c79fc6492f3af13d(x, y, width, height);
106
+ }
107
+ /**
108
+ * Returns the intersection of this Rect with another.
109
+ * If the rectangles do not intersect, an all zero Rect is returned.
110
+ */ intersection(other) {
111
+ if (!this.intersects(other)) return new $41b7691783731623$export$c79fc6492f3af13d(0, 0, 0, 0);
112
+ let x = Math.max(this.x, other.x);
113
+ let y = Math.max(this.y, other.y);
114
+ return new $41b7691783731623$export$c79fc6492f3af13d(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
115
+ }
116
+ /**
117
+ * Returns a copy of this rectangle.
118
+ */ copy() {
119
+ return new $41b7691783731623$export$c79fc6492f3af13d(this.x, this.y, this.width, this.height);
120
+ }
121
+ constructor(x = 0, y = 0, width = 0, height = 0){
122
+ this.x = x;
123
+ this.y = y;
124
+ this.width = width;
125
+ this.height = height;
126
+ }
127
+ }
128
+
129
+
130
+ //# sourceMappingURL=Rect.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAoBX;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;IAC5B;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;IAC7B;IAEA;;GAEC,G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G;QAG3B,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,OAAO,IAAI,0CACT,GACA,GACA,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,GAClC,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;IAEtC;IAEA;;GAEC,GACD,OAAa;QACX,OAAO,IAAI,0CAAK,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;IACzD;IA5JA,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAE;QAC/C,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,KAAK,GAAG;QACb,IAAI,CAAC,MAAM,GAAG;IAChB;AAwJF","sources":["packages/@react-stately/virtualizer/src/Rect.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\nimport {Point} from './Point';\nimport {Size} from './Size';\n\nexport type RectCorner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';\n\n/**\n * Represents a rectangle.\n */\nexport class Rect {\n /** The x-coordinate of the rectangle. */\n x: number;\n\n /** The y-coordinate of the rectangle. */\n y: number;\n\n /** The width of the rectangle. */\n width: number;\n\n /** The height of the rectangle. */\n height: number;\n\n constructor(x = 0, y = 0, width = 0, height = 0) {\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n }\n\n /**\n * The maximum x-coordinate in the rectangle.\n */\n get maxX(): number {\n return this.x + this.width;\n }\n\n /**\n * The maximum y-coordinate in the rectangle.\n */\n get maxY(): number {\n return this.y + this.height;\n }\n\n /**\n * The area of the rectangle.\n */\n get area(): number {\n return this.width * this.height;\n }\n\n /**\n * The top left corner of the rectangle.\n */\n get topLeft(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * The top right corner of the rectangle.\n */\n get topRight(): Point {\n return new Point(this.maxX, this.y);\n }\n\n /**\n * The bottom left corner of the rectangle.\n */\n get bottomLeft(): Point {\n return new Point(this.x, this.maxY);\n }\n\n /**\n * The bottom right corner of the rectangle.\n */\n get bottomRight(): Point {\n return new Point(this.maxX, this.maxY);\n }\n\n /**\n * Returns whether this rectangle intersects another rectangle.\n * @param rect - The rectangle to check.\n */\n intersects(rect: Rect): boolean {\n return this.x <= rect.x + rect.width\n && rect.x <= this.x + this.width\n && this.y <= rect.y + rect.height\n && rect.y <= this.y + this.height;\n }\n\n /**\n * Returns whether this rectangle fully contains another rectangle.\n * @param rect - The rectangle to check.\n */\n containsRect(rect: Rect): boolean {\n return this.x <= rect.x\n && this.y <= rect.y\n && this.maxX >= rect.maxX\n && this.maxY >= rect.maxY;\n }\n\n /**\n * Returns whether the rectangle contains the given point.\n * @param point - The point to check.\n */\n containsPoint(point: Point): boolean {\n return this.x <= point.x\n && this.y <= point.y\n && this.maxX >= point.x\n && this.maxY >= point.y;\n }\n\n /**\n * Returns the first corner of this rectangle (from top to bottom, left to right)\n * that is contained in the given rectangle, or null of the rectangles do not intersect.\n * @param rect - The rectangle to check.\n */\n getCornerInRect(rect: Rect): RectCorner | null {\n for (let key of ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']) {\n if (rect.containsPoint(this[key])) {\n return key as RectCorner;\n }\n }\n\n return null;\n }\n\n equals(rect: Rect) {\n return rect.x === this.x\n && rect.y === this.y\n && rect.width === this.width\n && rect.height === this.height;\n }\n\n pointEquals(point: Point | Rect) {\n return this.x === point.x\n && this.y === point.y;\n }\n\n sizeEquals(size: Size | Rect) {\n return this.width === size.width\n && this.height === size.height;\n }\n\n /**\n * Returns the union of this Rect and another.\n */\n union(other: Rect) {\n let x = Math.min(this.x, other.x);\n let y = Math.min(this.y, other.y);\n let width = Math.max(this.maxX, other.maxX) - x;\n let height = Math.max(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n /**\n * Returns the intersection of this Rect with another.\n * If the rectangles do not intersect, an all zero Rect is returned.\n */\n intersection(other: Rect): Rect {\n if (!this.intersects(other)) {\n return new Rect(0, 0, 0, 0);\n }\n\n let x = Math.max(this.x, other.x);\n let y = Math.max(this.y, other.y);\n return new Rect(\n x,\n y,\n Math.min(this.maxX, other.maxX) - x,\n Math.min(this.maxY, other.maxY) - y\n );\n }\n\n /**\n * Returns a copy of this rectangle.\n */\n copy(): Rect {\n return new Rect(this.x, this.y, this.width, this.height);\n }\n}\n"],"names":[],"version":3,"file":"Rect.main.js.map"}
package/dist/Rect.mjs ADDED
@@ -0,0 +1,125 @@
1
+ import {Point as $3041db3296945e6e$export$baf26146a414f24a} from "./Point.mjs";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ class $60423f92c7f9ad87$export$c79fc6492f3af13d {
15
+ /**
16
+ * The maximum x-coordinate in the rectangle.
17
+ */ get maxX() {
18
+ return this.x + this.width;
19
+ }
20
+ /**
21
+ * The maximum y-coordinate in the rectangle.
22
+ */ get maxY() {
23
+ return this.y + this.height;
24
+ }
25
+ /**
26
+ * The area of the rectangle.
27
+ */ get area() {
28
+ return this.width * this.height;
29
+ }
30
+ /**
31
+ * The top left corner of the rectangle.
32
+ */ get topLeft() {
33
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.x, this.y);
34
+ }
35
+ /**
36
+ * The top right corner of the rectangle.
37
+ */ get topRight() {
38
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.maxX, this.y);
39
+ }
40
+ /**
41
+ * The bottom left corner of the rectangle.
42
+ */ get bottomLeft() {
43
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.x, this.maxY);
44
+ }
45
+ /**
46
+ * The bottom right corner of the rectangle.
47
+ */ get bottomRight() {
48
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.maxX, this.maxY);
49
+ }
50
+ /**
51
+ * Returns whether this rectangle intersects another rectangle.
52
+ * @param rect - The rectangle to check.
53
+ */ intersects(rect) {
54
+ return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
55
+ }
56
+ /**
57
+ * Returns whether this rectangle fully contains another rectangle.
58
+ * @param rect - The rectangle to check.
59
+ */ containsRect(rect) {
60
+ return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
61
+ }
62
+ /**
63
+ * Returns whether the rectangle contains the given point.
64
+ * @param point - The point to check.
65
+ */ containsPoint(point) {
66
+ return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
67
+ }
68
+ /**
69
+ * Returns the first corner of this rectangle (from top to bottom, left to right)
70
+ * that is contained in the given rectangle, or null of the rectangles do not intersect.
71
+ * @param rect - The rectangle to check.
72
+ */ getCornerInRect(rect) {
73
+ for (let key of [
74
+ "topLeft",
75
+ "topRight",
76
+ "bottomLeft",
77
+ "bottomRight"
78
+ ]){
79
+ if (rect.containsPoint(this[key])) return key;
80
+ }
81
+ return null;
82
+ }
83
+ equals(rect) {
84
+ return rect.x === this.x && rect.y === this.y && rect.width === this.width && rect.height === this.height;
85
+ }
86
+ pointEquals(point) {
87
+ return this.x === point.x && this.y === point.y;
88
+ }
89
+ sizeEquals(size) {
90
+ return this.width === size.width && this.height === size.height;
91
+ }
92
+ /**
93
+ * Returns the union of this Rect and another.
94
+ */ union(other) {
95
+ let x = Math.min(this.x, other.x);
96
+ let y = Math.min(this.y, other.y);
97
+ let width = Math.max(this.maxX, other.maxX) - x;
98
+ let height = Math.max(this.maxY, other.maxY) - y;
99
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(x, y, width, height);
100
+ }
101
+ /**
102
+ * Returns the intersection of this Rect with another.
103
+ * If the rectangles do not intersect, an all zero Rect is returned.
104
+ */ intersection(other) {
105
+ if (!this.intersects(other)) return new $60423f92c7f9ad87$export$c79fc6492f3af13d(0, 0, 0, 0);
106
+ let x = Math.max(this.x, other.x);
107
+ let y = Math.max(this.y, other.y);
108
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
109
+ }
110
+ /**
111
+ * Returns a copy of this rectangle.
112
+ */ copy() {
113
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(this.x, this.y, this.width, this.height);
114
+ }
115
+ constructor(x = 0, y = 0, width = 0, height = 0){
116
+ this.x = x;
117
+ this.y = y;
118
+ this.width = width;
119
+ this.height = height;
120
+ }
121
+ }
122
+
123
+
124
+ export {$60423f92c7f9ad87$export$c79fc6492f3af13d as Rect};
125
+ //# sourceMappingURL=Rect.mjs.map
@@ -0,0 +1,125 @@
1
+ import {Point as $3041db3296945e6e$export$baf26146a414f24a} from "./Point.module.js";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ class $60423f92c7f9ad87$export$c79fc6492f3af13d {
15
+ /**
16
+ * The maximum x-coordinate in the rectangle.
17
+ */ get maxX() {
18
+ return this.x + this.width;
19
+ }
20
+ /**
21
+ * The maximum y-coordinate in the rectangle.
22
+ */ get maxY() {
23
+ return this.y + this.height;
24
+ }
25
+ /**
26
+ * The area of the rectangle.
27
+ */ get area() {
28
+ return this.width * this.height;
29
+ }
30
+ /**
31
+ * The top left corner of the rectangle.
32
+ */ get topLeft() {
33
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.x, this.y);
34
+ }
35
+ /**
36
+ * The top right corner of the rectangle.
37
+ */ get topRight() {
38
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.maxX, this.y);
39
+ }
40
+ /**
41
+ * The bottom left corner of the rectangle.
42
+ */ get bottomLeft() {
43
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.x, this.maxY);
44
+ }
45
+ /**
46
+ * The bottom right corner of the rectangle.
47
+ */ get bottomRight() {
48
+ return new (0, $3041db3296945e6e$export$baf26146a414f24a)(this.maxX, this.maxY);
49
+ }
50
+ /**
51
+ * Returns whether this rectangle intersects another rectangle.
52
+ * @param rect - The rectangle to check.
53
+ */ intersects(rect) {
54
+ return this.x <= rect.x + rect.width && rect.x <= this.x + this.width && this.y <= rect.y + rect.height && rect.y <= this.y + this.height;
55
+ }
56
+ /**
57
+ * Returns whether this rectangle fully contains another rectangle.
58
+ * @param rect - The rectangle to check.
59
+ */ containsRect(rect) {
60
+ return this.x <= rect.x && this.y <= rect.y && this.maxX >= rect.maxX && this.maxY >= rect.maxY;
61
+ }
62
+ /**
63
+ * Returns whether the rectangle contains the given point.
64
+ * @param point - The point to check.
65
+ */ containsPoint(point) {
66
+ return this.x <= point.x && this.y <= point.y && this.maxX >= point.x && this.maxY >= point.y;
67
+ }
68
+ /**
69
+ * Returns the first corner of this rectangle (from top to bottom, left to right)
70
+ * that is contained in the given rectangle, or null of the rectangles do not intersect.
71
+ * @param rect - The rectangle to check.
72
+ */ getCornerInRect(rect) {
73
+ for (let key of [
74
+ "topLeft",
75
+ "topRight",
76
+ "bottomLeft",
77
+ "bottomRight"
78
+ ]){
79
+ if (rect.containsPoint(this[key])) return key;
80
+ }
81
+ return null;
82
+ }
83
+ equals(rect) {
84
+ return rect.x === this.x && rect.y === this.y && rect.width === this.width && rect.height === this.height;
85
+ }
86
+ pointEquals(point) {
87
+ return this.x === point.x && this.y === point.y;
88
+ }
89
+ sizeEquals(size) {
90
+ return this.width === size.width && this.height === size.height;
91
+ }
92
+ /**
93
+ * Returns the union of this Rect and another.
94
+ */ union(other) {
95
+ let x = Math.min(this.x, other.x);
96
+ let y = Math.min(this.y, other.y);
97
+ let width = Math.max(this.maxX, other.maxX) - x;
98
+ let height = Math.max(this.maxY, other.maxY) - y;
99
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(x, y, width, height);
100
+ }
101
+ /**
102
+ * Returns the intersection of this Rect with another.
103
+ * If the rectangles do not intersect, an all zero Rect is returned.
104
+ */ intersection(other) {
105
+ if (!this.intersects(other)) return new $60423f92c7f9ad87$export$c79fc6492f3af13d(0, 0, 0, 0);
106
+ let x = Math.max(this.x, other.x);
107
+ let y = Math.max(this.y, other.y);
108
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(x, y, Math.min(this.maxX, other.maxX) - x, Math.min(this.maxY, other.maxY) - y);
109
+ }
110
+ /**
111
+ * Returns a copy of this rectangle.
112
+ */ copy() {
113
+ return new $60423f92c7f9ad87$export$c79fc6492f3af13d(this.x, this.y, this.width, this.height);
114
+ }
115
+ constructor(x = 0, y = 0, width = 0, height = 0){
116
+ this.x = x;
117
+ this.y = y;
118
+ this.width = width;
119
+ this.height = height;
120
+ }
121
+ }
122
+
123
+
124
+ export {$60423f92c7f9ad87$export$c79fc6492f3af13d as Rect};
125
+ //# sourceMappingURL=Rect.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAUM,MAAM;IAoBX;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK;IAC5B;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM;IAC7B;IAEA;;GAEC,GACD,IAAI,OAAe;QACjB,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM;IACjC;IAEA;;GAEC,GACD,IAAI,UAAiB;QACnB,OAAO,IAAI,CAAA,GAAA,yCAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACjC;IAEA;;GAEC,GACD,IAAI,WAAkB;QACpB,OAAO,IAAI,CAAA,GAAA,yCAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC;IAEA;;GAEC,GACD,IAAI,aAAoB;QACtB,OAAO,IAAI,CAAA,GAAA,yCAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI;IACpC;IAEA;;GAEC,GACD,IAAI,cAAqB;QACvB,OAAO,IAAI,CAAA,GAAA,yCAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI;IACvC;IAEA;;;GAGC,GACD,WAAW,IAAU,EAAW;QAC9B,OAAO,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,IAC7B,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,IAC7B,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,MA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CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC9C,IAAI,SAAS,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;QAC/C,OAAO,IAAI,0CAAK,GAAG,GAAG,OAAO;IAC/B;IAEA;;;GAGC,GACD,aAAa,KAAW,EAAQ;QAC9B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QACnB,OAAO,IAAI,0CAAK,GAAG,GAAG,GAAG;QAG3B,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,IAAI,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC;QAChC,OAAO,IAAI,0CACT,GACA,GACA,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI,GAClC,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,IAAI;IAEtC;IAEA;;GAEC,GACD,OAAa;QACX,OAAO,IAAI,0CAAK,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM;IACzD;IA5JA,YAAY,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAE;QAC/C,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,CAAC,GAAG;QACT,IAAI,CAAC,KAAK,GAAG;QACb,IAAI,CAAC,MAAM,GAAG;IAChB;AAwJF","sources":["packages/@react-stately/virtualizer/src/Rect.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\nimport {Point} from './Point';\nimport {Size} from './Size';\n\nexport type RectCorner = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';\n\n/**\n * Represents a rectangle.\n */\nexport class Rect {\n /** The x-coordinate of the rectangle. */\n x: number;\n\n /** The y-coordinate of the rectangle. */\n y: number;\n\n /** The width of the rectangle. */\n width: number;\n\n /** The height of the rectangle. */\n height: number;\n\n constructor(x = 0, y = 0, width = 0, height = 0) {\n this.x = x;\n this.y = y;\n this.width = width;\n this.height = height;\n }\n\n /**\n * The maximum x-coordinate in the rectangle.\n */\n get maxX(): number {\n return this.x + this.width;\n }\n\n /**\n * The maximum y-coordinate in the rectangle.\n */\n get maxY(): number {\n return this.y + this.height;\n }\n\n /**\n * The area of the rectangle.\n */\n get area(): number {\n return this.width * this.height;\n }\n\n /**\n * The top left corner of the rectangle.\n */\n get topLeft(): Point {\n return new Point(this.x, this.y);\n }\n\n /**\n * The top right corner of the rectangle.\n */\n get topRight(): Point {\n return new Point(this.maxX, this.y);\n }\n\n /**\n * The bottom left corner of the rectangle.\n */\n get bottomLeft(): Point {\n return new Point(this.x, this.maxY);\n }\n\n /**\n * The bottom right corner of the rectangle.\n */\n get bottomRight(): Point {\n return new Point(this.maxX, this.maxY);\n }\n\n /**\n * Returns whether this rectangle intersects another rectangle.\n * @param rect - The rectangle to check.\n */\n intersects(rect: Rect): boolean {\n return this.x <= rect.x + rect.width\n && rect.x <= this.x + this.width\n && this.y <= rect.y + rect.height\n && rect.y <= this.y + this.height;\n }\n\n /**\n * Returns whether this rectangle fully contains another rectangle.\n * @param rect - The rectangle to check.\n */\n containsRect(rect: Rect): boolean {\n return this.x <= rect.x\n && this.y <= rect.y\n && this.maxX >= rect.maxX\n && this.maxY >= rect.maxY;\n }\n\n /**\n * Returns whether the rectangle contains the given point.\n * @param point - The point to check.\n */\n containsPoint(point: Point): boolean {\n return this.x <= point.x\n && this.y <= point.y\n && this.maxX >= point.x\n && this.maxY >= point.y;\n }\n\n /**\n * Returns the first corner of this rectangle (from top to bottom, left to right)\n * that is contained in the given rectangle, or null of the rectangles do not intersect.\n * @param rect - The rectangle to check.\n */\n getCornerInRect(rect: Rect): RectCorner | null {\n for (let key of ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']) {\n if (rect.containsPoint(this[key])) {\n return key as RectCorner;\n }\n }\n\n return null;\n }\n\n equals(rect: Rect) {\n return rect.x === this.x\n && rect.y === this.y\n && rect.width === this.width\n && rect.height === this.height;\n }\n\n pointEquals(point: Point | Rect) {\n return this.x === point.x\n && this.y === point.y;\n }\n\n sizeEquals(size: Size | Rect) {\n return this.width === size.width\n && this.height === size.height;\n }\n\n /**\n * Returns the union of this Rect and another.\n */\n union(other: Rect) {\n let x = Math.min(this.x, other.x);\n let y = Math.min(this.y, other.y);\n let width = Math.max(this.maxX, other.maxX) - x;\n let height = Math.max(this.maxY, other.maxY) - y;\n return new Rect(x, y, width, height);\n }\n\n /**\n * Returns the intersection of this Rect with another.\n * If the rectangles do not intersect, an all zero Rect is returned.\n */\n intersection(other: Rect): Rect {\n if (!this.intersects(other)) {\n return new Rect(0, 0, 0, 0);\n }\n\n let x = Math.max(this.x, other.x);\n let y = Math.max(this.y, other.y);\n return new Rect(\n x,\n y,\n Math.min(this.maxX, other.maxX) - x,\n Math.min(this.maxY, other.maxY) - y\n );\n }\n\n /**\n * Returns a copy of this rectangle.\n */\n copy(): Rect {\n return new Rect(this.x, this.y, this.width, this.height);\n }\n}\n"],"names":[],"version":3,"file":"Rect.module.js.map"}