@shopify/flash-list 1.1.0 → 1.2.2

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 (83) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +3 -2
  3. package/RNFlashList.podspec +1 -1
  4. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutShadow.kt +5 -0
  5. package/android/src/main/kotlin/com/shopify/reactnative/flash_list/AutoLayoutView.kt +78 -7
  6. package/dist/FlashList.d.ts +2 -1
  7. package/dist/FlashList.d.ts.map +1 -1
  8. package/dist/FlashList.js +38 -17
  9. package/dist/FlashList.js.map +1 -1
  10. package/dist/__tests__/FlashList.test.js +62 -2
  11. package/dist/__tests__/FlashList.test.js.map +1 -1
  12. package/dist/__tests__/PlatformHelper.web.test.js +9 -1
  13. package/dist/__tests__/PlatformHelper.web.test.js.map +1 -1
  14. package/dist/native/auto-layout/AutoLayoutView.d.ts +2 -1
  15. package/dist/native/auto-layout/AutoLayoutView.d.ts.map +1 -1
  16. package/dist/native/auto-layout/AutoLayoutView.js.map +1 -1
  17. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts +4 -0
  18. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.d.ts.map +1 -0
  19. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js +6 -0
  20. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.android.js.map +1 -0
  21. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts +2 -1
  22. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.d.ts.map +1 -1
  23. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts +4 -0
  24. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.d.ts.map +1 -0
  25. package/dist/native/auto-layout/{AutoLayoutViewNativeComponent.web.js → AutoLayoutViewNativeComponent.ios.js} +2 -2
  26. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.ios.js.map +1 -0
  27. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js +1 -1
  28. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.js.map +1 -1
  29. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts +2 -0
  30. package/dist/native/auto-layout/AutoLayoutViewNativeComponentProps.d.ts.map +1 -1
  31. package/dist/native/cell-container/CellContainer.android.d.ts +6 -0
  32. package/dist/native/cell-container/CellContainer.android.d.ts.map +1 -0
  33. package/dist/native/cell-container/CellContainer.android.js +9 -0
  34. package/dist/native/cell-container/CellContainer.android.js.map +1 -0
  35. package/dist/native/cell-container/CellContainer.d.ts +6 -4
  36. package/dist/native/cell-container/CellContainer.d.ts.map +1 -1
  37. package/dist/native/cell-container/CellContainer.ios.d.ts +6 -0
  38. package/dist/native/cell-container/CellContainer.ios.d.ts.map +1 -0
  39. package/dist/native/cell-container/CellContainer.ios.js +9 -0
  40. package/dist/native/cell-container/CellContainer.ios.js.map +1 -0
  41. package/dist/native/cell-container/CellContainer.js +6 -4
  42. package/dist/native/cell-container/CellContainer.js.map +1 -1
  43. package/dist/native/config/PlatformHelper.android.d.ts +16 -0
  44. package/dist/native/config/PlatformHelper.android.d.ts.map +1 -0
  45. package/dist/native/config/PlatformHelper.android.js +20 -0
  46. package/dist/native/config/PlatformHelper.android.js.map +1 -0
  47. package/dist/{utils → native/config}/PlatformHelper.d.ts +3 -1
  48. package/dist/native/config/PlatformHelper.d.ts.map +1 -0
  49. package/dist/{utils/PlatformHelper.web.d.ts → native/config/PlatformHelper.ios.d.ts} +4 -2
  50. package/dist/native/config/PlatformHelper.ios.d.ts.map +1 -0
  51. package/dist/{utils/PlatformHelper.js → native/config/PlatformHelper.ios.js} +6 -2
  52. package/dist/native/config/PlatformHelper.ios.js.map +1 -0
  53. package/dist/native/config/PlatformHelper.js +21 -0
  54. package/dist/native/config/PlatformHelper.js.map +1 -0
  55. package/dist/native/config/PlatformHelper.web.d.ts +17 -0
  56. package/dist/native/config/PlatformHelper.web.d.ts.map +1 -0
  57. package/dist/{utils → native/config}/PlatformHelper.web.js +7 -2
  58. package/dist/native/config/PlatformHelper.web.js.map +1 -0
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/ios/Sources/AutoLayoutView.swift +61 -8
  61. package/package.json +12 -3
  62. package/src/FlashList.tsx +53 -14
  63. package/src/__tests__/FlashList.test.tsx +65 -2
  64. package/src/__tests__/PlatformHelper.web.test.ts +17 -1
  65. package/src/native/auto-layout/AutoLayoutView.tsx +2 -1
  66. package/src/native/auto-layout/{AutoLayoutViewNativeComponent.web.ts → AutoLayoutViewNativeComponent.android.ts} +2 -3
  67. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ios.ts +7 -0
  68. package/src/native/auto-layout/AutoLayoutViewNativeComponent.ts +2 -2
  69. package/src/native/auto-layout/AutoLayoutViewNativeComponentProps.ts +3 -0
  70. package/src/native/cell-container/{CellContainer.ts → CellContainer.android.ts} +0 -0
  71. package/src/native/cell-container/CellContainer.ios.ts +7 -0
  72. package/src/native/cell-container/CellContainer.tsx +14 -0
  73. package/src/{utils/PlatformHelper.ts → native/config/PlatformHelper.android.ts} +12 -2
  74. package/src/native/config/PlatformHelper.ios.ts +26 -0
  75. package/src/native/config/PlatformHelper.ts +27 -0
  76. package/src/{utils → native/config}/PlatformHelper.web.ts +15 -3
  77. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.web.d.ts +0 -5
  78. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.web.d.ts.map +0 -1
  79. package/dist/native/auto-layout/AutoLayoutViewNativeComponent.web.js.map +0 -1
  80. package/dist/utils/PlatformHelper.d.ts.map +0 -1
  81. package/dist/utils/PlatformHelper.js.map +0 -1
  82. package/dist/utils/PlatformHelper.web.d.ts.map +0 -1
  83. package/dist/utils/PlatformHelper.web.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getCellContainerPlatformStyles,
3
3
  getItemAnimator,
4
- } from "../utils/PlatformHelper.web";
4
+ } from "../native/config/PlatformHelper.web";
5
5
 
6
6
  describe("Platform Helper Web", () => {
7
7
  it("can compute right transform for web", () => {
@@ -13,8 +13,18 @@ describe("Platform Helper Web", () => {
13
13
  x: 30,
14
14
  y: 30,
15
15
  });
16
+ const transformHorizontalInvertedStyle = getCellContainerPlatformStyles(
17
+ true,
18
+ {
19
+ x: 30,
20
+ y: 30,
21
+ isHorizontal: true,
22
+ }
23
+ );
16
24
  const expectedTransform = "translate(20px,70px)";
17
25
  const expectedTransformInverted = "translate(30px,30px) scaleY(-1)";
26
+ const expectedTransformHorizontalInverted =
27
+ "translate(30px,30px) scaleX(-1)";
18
28
 
19
29
  expect(transformStyle?.transform).toBe(expectedTransform);
20
30
  expect(transformStyle?.WebkitTransform).toBe(expectedTransform);
@@ -22,6 +32,12 @@ describe("Platform Helper Web", () => {
22
32
  expect(transformInvertedStyle?.WebkitTransform).toBe(
23
33
  expectedTransformInverted
24
34
  );
35
+ expect(transformHorizontalInvertedStyle?.transform).toBe(
36
+ expectedTransformHorizontalInverted
37
+ );
38
+ expect(transformHorizontalInvertedStyle?.WebkitTransform).toBe(
39
+ expectedTransformHorizontalInverted
40
+ );
25
41
  });
26
42
  it("can return an animator", () => {
27
43
  expect(getItemAnimator()!["animateWillMount"]).toBeDefined();
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from "react";
1
+ import React, { useEffect, ReactNode } from "react";
2
2
  import { LayoutChangeEvent } from "react-native";
3
3
 
4
4
  import AutoLayoutViewNativeComponent from "./AutoLayoutViewNativeComponent";
@@ -25,6 +25,7 @@ export interface BlankAreaEvent {
25
25
  }
26
26
 
27
27
  export interface AutoLayoutViewProps {
28
+ children?: ReactNode;
28
29
  onBlankAreaEvent?: BlankAreaEventHandler;
29
30
  onLayout?: (event: LayoutChangeEvent) => void;
30
31
  disableAutoLayout?: boolean;
@@ -1,8 +1,7 @@
1
- import React from "react";
2
- import { View } from "react-native";
1
+ import { requireNativeComponent } from "react-native";
3
2
 
4
3
  import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
5
4
 
6
5
  const AutoLayoutViewNativeComponent =
7
- View as any as React.Component<AutoLayoutViewNativeComponentProps>;
6
+ requireNativeComponent<AutoLayoutViewNativeComponentProps>("AutoLayoutView");
8
7
  export default AutoLayoutViewNativeComponent;
@@ -0,0 +1,7 @@
1
+ import { requireNativeComponent } from "react-native";
2
+
3
+ import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
4
+
5
+ const AutoLayoutViewNativeComponent =
6
+ requireNativeComponent<AutoLayoutViewNativeComponentProps>("AutoLayoutView");
7
+ export default AutoLayoutViewNativeComponent;
@@ -1,7 +1,7 @@
1
- import { requireNativeComponent } from "react-native";
1
+ import { HostComponent, View } from "react-native";
2
2
 
3
3
  import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
4
4
 
5
5
  const AutoLayoutViewNativeComponent =
6
- requireNativeComponent<AutoLayoutViewNativeComponentProps>("AutoLayoutView");
6
+ View as any as HostComponent<AutoLayoutViewNativeComponentProps>;
7
7
  export default AutoLayoutViewNativeComponent;
@@ -1,3 +1,5 @@
1
+ import { ReactNode } from "react";
2
+
1
3
  export interface OnBlankAreaEvent {
2
4
  nativeEvent: {
3
5
  offsetStart: number;
@@ -8,6 +10,7 @@ export interface OnBlankAreaEvent {
8
10
  type OnBlankAreaEventHandler = (event: OnBlankAreaEvent) => void;
9
11
 
10
12
  export interface AutoLayoutViewNativeComponentProps {
13
+ children?: ReactNode;
11
14
  onBlankAreaEvent: OnBlankAreaEventHandler;
12
15
  enableInstrumentation: boolean;
13
16
  disableAutoLayout?: boolean;
@@ -0,0 +1,7 @@
1
+ import { requireNativeComponent } from "react-native";
2
+
3
+ /**
4
+ * Behaves as a regular `View` with an extra `index` prop that is saved in the native layer.
5
+ */
6
+ const CellContainer = requireNativeComponent("CellContainer");
7
+ export default CellContainer;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { View, ViewProps } from "react-native";
3
+
4
+ export interface CellContainerProps extends ViewProps {
5
+ index: number;
6
+ }
7
+
8
+ const CellContainer = React.forwardRef(
9
+ (props: CellContainerProps, ref: any) => {
10
+ return <View ref={ref} {...props} />;
11
+ }
12
+ );
13
+ CellContainer.displayName = "CellContainer";
14
+ export default CellContainer;
@@ -5,7 +5,7 @@ const PlatformConfig = {
5
5
  };
6
6
  const getCellContainerPlatformStyles = (
7
7
  inverted: boolean,
8
- parentProps: { x: number; y: number }
8
+ parentProps: { x: number; y: number; isHorizontal?: boolean }
9
9
  ): { transform: string; WebkitTransform: string } | undefined => {
10
10
  return undefined;
11
11
  };
@@ -13,4 +13,14 @@ const getCellContainerPlatformStyles = (
13
13
  const getItemAnimator = (): BaseItemAnimator | undefined => {
14
14
  return undefined;
15
15
  };
16
- export { PlatformConfig, getCellContainerPlatformStyles, getItemAnimator };
16
+
17
+ const getFooterContainer = (): React.ComponentClass | undefined => {
18
+ return undefined;
19
+ };
20
+
21
+ export {
22
+ PlatformConfig,
23
+ getCellContainerPlatformStyles,
24
+ getItemAnimator,
25
+ getFooterContainer,
26
+ };
@@ -0,0 +1,26 @@
1
+ import { BaseItemAnimator } from "recyclerlistview";
2
+
3
+ const PlatformConfig = {
4
+ defaultDrawDistance: 250,
5
+ };
6
+ const getCellContainerPlatformStyles = (
7
+ inverted: boolean,
8
+ parentProps: { x: number; y: number; isHorizontal?: boolean }
9
+ ): { transform: string; WebkitTransform: string } | undefined => {
10
+ return undefined;
11
+ };
12
+
13
+ const getItemAnimator = (): BaseItemAnimator | undefined => {
14
+ return undefined;
15
+ };
16
+
17
+ const getFooterContainer = (): React.ComponentClass | undefined => {
18
+ return undefined;
19
+ };
20
+
21
+ export {
22
+ PlatformConfig,
23
+ getCellContainerPlatformStyles,
24
+ getItemAnimator,
25
+ getFooterContainer,
26
+ };
@@ -0,0 +1,27 @@
1
+ import { BaseItemAnimator } from "recyclerlistview";
2
+ import { DefaultJSItemAnimator } from "recyclerlistview/dist/reactnative/platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator";
3
+
4
+ const PlatformConfig = {
5
+ defaultDrawDistance: 250,
6
+ };
7
+ const getCellContainerPlatformStyles = (
8
+ inverted: boolean,
9
+ parentProps: { x: number; y: number; isHorizontal?: boolean }
10
+ ): { transform: string; WebkitTransform: string } | undefined => {
11
+ return undefined;
12
+ };
13
+
14
+ const getItemAnimator = (): BaseItemAnimator | undefined => {
15
+ return new DefaultJSItemAnimator();
16
+ };
17
+
18
+ const getFooterContainer = (): React.ComponentClass | undefined => {
19
+ return undefined;
20
+ };
21
+
22
+ export {
23
+ PlatformConfig,
24
+ getCellContainerPlatformStyles,
25
+ getItemAnimator,
26
+ getFooterContainer,
27
+ };
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+ import { View } from "react-native";
1
3
  import { BaseItemAnimator } from "recyclerlistview";
2
4
  import { DefaultJSItemAnimator } from "recyclerlistview/dist/reactnative/platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator";
3
5
 
@@ -6,10 +8,10 @@ const PlatformConfig = {
6
8
  };
7
9
  const getCellContainerPlatformStyles = (
8
10
  inverted: boolean,
9
- parentProps: { x: number; y: number }
11
+ parentProps: { x: number; y: number; isHorizontal?: boolean }
10
12
  ): { transform: string; WebkitTransform: string } | undefined => {
11
13
  const transformValue = `translate(${parentProps.x}px,${parentProps.y}px)${
12
- inverted ? ` scaleY(-1)` : ``
14
+ inverted ? ` ${parentProps.isHorizontal ? `scaleX` : `scaleY`}(-1)` : ``
13
15
  }`;
14
16
  return { transform: transformValue, WebkitTransform: transformValue };
15
17
  };
@@ -17,4 +19,14 @@ const getCellContainerPlatformStyles = (
17
19
  const getItemAnimator = (): BaseItemAnimator | undefined => {
18
20
  return new DefaultJSItemAnimator();
19
21
  };
20
- export { PlatformConfig, getCellContainerPlatformStyles, getItemAnimator };
22
+
23
+ const getFooterContainer = (): React.ComponentClass | undefined => {
24
+ return View;
25
+ };
26
+
27
+ export {
28
+ PlatformConfig,
29
+ getCellContainerPlatformStyles,
30
+ getItemAnimator,
31
+ getFooterContainer,
32
+ };
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { AutoLayoutViewNativeComponentProps } from "./AutoLayoutViewNativeComponentProps";
3
- declare const AutoLayoutViewNativeComponent: React.Component<AutoLayoutViewNativeComponentProps, {}, any>;
4
- export default AutoLayoutViewNativeComponent;
5
- //# sourceMappingURL=AutoLayoutViewNativeComponent.web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoLayoutViewNativeComponent.web.d.ts","sourceRoot":"","sources":["../../../src/native/auto-layout/AutoLayoutViewNativeComponent.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F,QAAA,MAAM,6BAA6B,8DACiC,CAAC;AACrE,eAAe,6BAA6B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutoLayoutViewNativeComponent.web.js","sourceRoot":"","sources":["../../../src/native/auto-layout/AutoLayoutViewNativeComponent.web.ts"],"names":[],"mappings":";;AACA,6CAAoC;AAIpC,IAAM,6BAA6B,GACjC,mBAAkE,CAAC;AACrE,kBAAe,6BAA6B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHelper.d.ts","sourceRoot":"","sources":["../../src/utils/PlatformHelper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,QAAA,MAAM,cAAc;;CAEnB,CAAC;AACF,QAAA,MAAM,8BAA8B,aACxB,OAAO,eACJ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KACpC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GAAG,SAEnD,CAAC;AAEF,QAAA,MAAM,eAAe,QAAO,gBAAgB,GAAG,SAE9C,CAAC;AACF,OAAO,EAAE,cAAc,EAAE,8BAA8B,EAAE,eAAe,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHelper.js","sourceRoot":"","sources":["../../src/utils/PlatformHelper.ts"],"names":[],"mappings":";;;AAEA,IAAM,cAAc,GAAG;IACrB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AAWO,wCAAc;AAVvB,IAAM,8BAA8B,GAAG,UACrC,QAAiB,EACjB,WAAqC;IAErC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAKuB,wEAA8B;AAHvD,IAAM,eAAe,GAAG;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AACuD,0CAAe"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHelper.web.d.ts","sourceRoot":"","sources":["../../src/utils/PlatformHelper.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,QAAA,MAAM,cAAc;;CAEnB,CAAC;AACF,QAAA,MAAM,8BAA8B,aACxB,OAAO,eACJ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KACpC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,GAAG,SAKnD,CAAC;AAEF,QAAA,MAAM,eAAe,QAAO,gBAAgB,GAAG,SAE9C,CAAC;AACF,OAAO,EAAE,cAAc,EAAE,8BAA8B,EAAE,eAAe,EAAE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHelper.web.js","sourceRoot":"","sources":["../../src/utils/PlatformHelper.web.ts"],"names":[],"mappings":";;;AACA,sJAAqJ;AAErJ,IAAM,cAAc,GAAG;IACrB,mBAAmB,EAAE,IAAI;CAC1B,CAAC;AAcO,wCAAc;AAbvB,IAAM,8BAA8B,GAAG,UACrC,QAAiB,EACjB,WAAqC;IAErC,IAAM,cAAc,GAAG,oBAAa,WAAW,CAAC,CAAC,gBAAM,WAAW,CAAC,CAAC,gBAClE,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAC7B,CAAC;IACH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AACxE,CAAC,CAAC;AAKuB,wEAA8B;AAHvD,IAAM,eAAe,GAAG;IACtB,OAAO,IAAI,6CAAqB,EAAE,CAAC;AACrC,CAAC,CAAC;AACuD,0CAAe"}