@react-native/virtualized-lists 0.72.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.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall react_native
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ describe('clamp', () => {
14
+ const clamp = require('../clamp');
15
+
16
+ it('should return the value if the value does not exceed boundaries', () => {
17
+ expect(clamp(0, 5, 10)).toEqual(5);
18
+ expect(clamp(5, 5, 10)).toEqual(5);
19
+ expect(clamp(0, 5, 5)).toEqual(5);
20
+ expect(clamp(5, 5, 5)).toEqual(5);
21
+ });
22
+
23
+ it('should return the min value if the value is too low', () => {
24
+ expect(clamp(10, 5, 20)).toEqual(10);
25
+ expect(clamp(10, 9, 20)).toEqual(10);
26
+ });
27
+
28
+ it('should return the max value if the value is too high', () => {
29
+ expect(clamp(10, 25, 20)).toEqual(20);
30
+ expect(clamp(10, 21, 20)).toEqual(20);
31
+ });
32
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ function clamp(min: number, value: number, max: number): number {
14
+ if (value < min) {
15
+ return min;
16
+ }
17
+ if (value > max) {
18
+ return max;
19
+ }
20
+ return value;
21
+ }
22
+
23
+ module.exports = clamp;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow strict
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ /**
14
+ * Intentional info-level logging for clear separation from ad-hoc console debug logging.
15
+ */
16
+ function infoLog(...args: Array<mixed>): void {
17
+ return console.log(...args);
18
+ }
19
+
20
+ module.exports = infoLog;
package/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ export * from './Lists/VirtualizedList';
package/index.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ import {keyExtractor} from './Lists/VirtualizeUtils';
14
+
15
+ import typeof VirtualizedList from './Lists/VirtualizedList';
16
+ import typeof VirtualizedSectionList from './Lists/VirtualizedSectionList';
17
+ import {typeof VirtualizedListContextResetter} from './Lists/VirtualizedListContext';
18
+ import typeof ViewabilityHelper from './Lists/ViewabilityHelper';
19
+ import typeof FillRateHelper from './Lists/FillRateHelper';
20
+
21
+ export type {
22
+ ViewToken,
23
+ ViewabilityConfig,
24
+ ViewabilityConfigCallbackPair,
25
+ } from './Lists/ViewabilityHelper';
26
+ export type {
27
+ RenderItemProps,
28
+ RenderItemType,
29
+ Separators,
30
+ } from './Lists/VirtualizedListProps';
31
+ export type {
32
+ Props as VirtualizedSectionListProps,
33
+ ScrollToLocationParamsType,
34
+ SectionBase,
35
+ } from './Lists/VirtualizedSectionList';
36
+ export type {FillRateInfo} from './Lists/FillRateHelper';
37
+
38
+ module.exports = {
39
+ keyExtractor,
40
+
41
+ get VirtualizedList(): VirtualizedList {
42
+ return require('./Lists/VirtualizedList');
43
+ },
44
+ get VirtualizedSectionList(): VirtualizedSectionList {
45
+ return require('./Lists/VirtualizedSectionList');
46
+ },
47
+ get VirtualizedListContextResetter(): VirtualizedListContextResetter {
48
+ const VirtualizedListContext = require('./Lists/VirtualizedListContext');
49
+ return VirtualizedListContext.VirtualizedListContextResetter;
50
+ },
51
+ get ViewabilityHelper(): ViewabilityHelper {
52
+ return require('./Lists/ViewabilityHelper');
53
+ },
54
+ get FillRateHelper(): FillRateHelper {
55
+ return require('./Lists/FillRateHelper');
56
+ },
57
+ };
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@react-native/virtualized-lists",
3
+ "version": "0.72.0",
4
+ "description": "Virtualized lists for React Native.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@github.com:facebook/react-native.git",
8
+ "directory": "packages/virtualized-lists"
9
+ },
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "invariant": "^2.2.4"
13
+ },
14
+ "devDependencies": {
15
+ "react-test-renderer": "18.2.0"
16
+ },
17
+ "peerDependencies": {
18
+ "react-native": "*",
19
+ "react-test-renderer": "18.2.0"
20
+ }
21
+ }