@legendapp/list 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -1,6 +1,4 @@
1
- import * as React from 'react';
2
- import { ComponentProps, ReactNode } from 'react';
3
- import * as react_native from 'react-native';
1
+ import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
4
2
  import { ScrollView, StyleProp, ViewStyle } from 'react-native';
5
3
 
6
4
  type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset'> & {
@@ -25,6 +23,7 @@ type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset
25
23
  ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
26
24
  ListFooterComponent?: ReactNode;
27
25
  ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
26
+ ItemSeparatorComponent?: ReactNode;
28
27
  };
29
28
  interface ViewableRange<T> {
30
29
  startBuffered: number;
@@ -38,28 +37,8 @@ interface LegendListRenderItemInfo<ItemT> {
38
37
  index: number;
39
38
  }
40
39
 
41
- declare const LegendList: React.ForwardRefExoticComponent<Omit<react_native.ScrollViewProps, "contentOffset"> & {
42
- data: ArrayLike<any> & unknown[];
43
- initialScrollOffset?: number;
44
- initialScrollIndex?: number;
45
- drawDistance?: number;
46
- initialContainers?: number;
47
- recycleItems?: boolean;
48
- onEndReachedThreshold?: number | null | undefined;
49
- autoScrollToBottom?: boolean;
50
- autoScrollToBottomThreshold?: number;
51
- startAtBottom?: boolean;
52
- estimatedItemLength: (index: number) => number;
53
- onEndReached?: ((info: {
54
- distanceFromEnd: number;
55
- }) => void) | null | undefined;
56
- keyExtractor?: ((item: unknown, index: number) => string) | undefined;
57
- renderItem?: ((props: LegendListRenderItemInfo<unknown>) => React.ReactNode) | undefined;
58
- onViewableRangeChanged?: ((range: ViewableRange<unknown>) => void) | undefined;
59
- ListHeaderComponent?: React.ReactNode;
60
- ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
61
- ListFooterComponent?: React.ReactNode;
62
- ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
63
- } & React.RefAttributes<ScrollView>>;
40
+ declare const LegendList: <T>(props: LegendListProps<T> & {
41
+ ref?: ForwardedRef<ScrollView>;
42
+ }) => ReactElement;
64
43
 
65
44
  export { LegendList, type LegendListProps, type LegendListRenderItemInfo, type ViewableRange };
package/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- import * as React from 'react';
2
- import { ComponentProps, ReactNode } from 'react';
3
- import * as react_native from 'react-native';
1
+ import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
4
2
  import { ScrollView, StyleProp, ViewStyle } from 'react-native';
5
3
 
6
4
  type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset'> & {
@@ -25,6 +23,7 @@ type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset
25
23
  ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
26
24
  ListFooterComponent?: ReactNode;
27
25
  ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
26
+ ItemSeparatorComponent?: ReactNode;
28
27
  };
29
28
  interface ViewableRange<T> {
30
29
  startBuffered: number;
@@ -38,28 +37,8 @@ interface LegendListRenderItemInfo<ItemT> {
38
37
  index: number;
39
38
  }
40
39
 
41
- declare const LegendList: React.ForwardRefExoticComponent<Omit<react_native.ScrollViewProps, "contentOffset"> & {
42
- data: ArrayLike<any> & unknown[];
43
- initialScrollOffset?: number;
44
- initialScrollIndex?: number;
45
- drawDistance?: number;
46
- initialContainers?: number;
47
- recycleItems?: boolean;
48
- onEndReachedThreshold?: number | null | undefined;
49
- autoScrollToBottom?: boolean;
50
- autoScrollToBottomThreshold?: number;
51
- startAtBottom?: boolean;
52
- estimatedItemLength: (index: number) => number;
53
- onEndReached?: ((info: {
54
- distanceFromEnd: number;
55
- }) => void) | null | undefined;
56
- keyExtractor?: ((item: unknown, index: number) => string) | undefined;
57
- renderItem?: ((props: LegendListRenderItemInfo<unknown>) => React.ReactNode) | undefined;
58
- onViewableRangeChanged?: ((range: ViewableRange<unknown>) => void) | undefined;
59
- ListHeaderComponent?: React.ReactNode;
60
- ListHeaderComponentStyle?: StyleProp<ViewStyle> | undefined;
61
- ListFooterComponent?: React.ReactNode;
62
- ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
63
- } & React.RefAttributes<ScrollView>>;
40
+ declare const LegendList: <T>(props: LegendListProps<T> & {
41
+ ref?: ForwardedRef<ScrollView>;
42
+ }) => ReactElement;
64
43
 
65
44
  export { LegendList, type LegendListProps, type LegendListRenderItemInfo, type ViewableRange };
package/index.js CHANGED
@@ -33,13 +33,15 @@ var Container = ({
33
33
  recycleItems,
34
34
  listProps,
35
35
  getRenderedItem,
36
- onLayout
36
+ onLayout,
37
+ ItemSeparatorComponent
37
38
  }) => {
38
39
  const { horizontal } = listProps;
39
40
  const { id } = $container.peek();
40
41
  const itemIndex = react.use$($container.itemIndex);
41
42
  const key = recycleItems ? void 0 : itemIndex;
42
43
  const createStyle = () => horizontal ? {
44
+ flexDirection: "row",
43
45
  position: "absolute",
44
46
  top: 0,
45
47
  bottom: 0,
@@ -63,7 +65,8 @@ var Container = ({
63
65
  onLayout(index, length);
64
66
  }
65
67
  },
66
- /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { key }, getRenderedItem(itemIndex))
68
+ /* @__PURE__ */ React2__namespace.createElement(reactNative.View, { key }, getRenderedItem(itemIndex)),
69
+ ItemSeparatorComponent && itemIndex !== listProps.data.length - 1 && /* @__PURE__ */ React2__namespace.createElement(react.Reactive.View, null, ItemSeparatorComponent)
67
70
  );
68
71
  };
69
72
 
@@ -95,6 +98,7 @@ var LegendList = React2.forwardRef(function LegendList2(props, forwardedRef) {
95
98
  ListHeaderComponentStyle,
96
99
  ListFooterComponent,
97
100
  ListFooterComponentStyle,
101
+ ItemSeparatorComponent,
98
102
  ...rest
99
103
  } = props;
100
104
  const internalRef = React2.useRef(null);
@@ -415,7 +419,8 @@ var LegendList = React2.forwardRef(function LegendList2(props, forwardedRef) {
415
419
  $container: containers$[i],
416
420
  listProps: props,
417
421
  getRenderedItem,
418
- onLayout: updateItemLength
422
+ onLayout: updateItemLength,
423
+ ItemSeparatorComponent
419
424
  }
420
425
  ))
421
426
  ),
package/index.mjs CHANGED
@@ -12,13 +12,15 @@ var Container = ({
12
12
  recycleItems,
13
13
  listProps,
14
14
  getRenderedItem,
15
- onLayout
15
+ onLayout,
16
+ ItemSeparatorComponent
16
17
  }) => {
17
18
  const { horizontal } = listProps;
18
19
  const { id } = $container.peek();
19
20
  const itemIndex = use$($container.itemIndex);
20
21
  const key = recycleItems ? void 0 : itemIndex;
21
22
  const createStyle = () => horizontal ? {
23
+ flexDirection: "row",
22
24
  position: "absolute",
23
25
  top: 0,
24
26
  bottom: 0,
@@ -42,7 +44,8 @@ var Container = ({
42
44
  onLayout(index, length);
43
45
  }
44
46
  },
45
- /* @__PURE__ */ React2.createElement(View, { key }, getRenderedItem(itemIndex))
47
+ /* @__PURE__ */ React2.createElement(View, { key }, getRenderedItem(itemIndex)),
48
+ ItemSeparatorComponent && itemIndex !== listProps.data.length - 1 && /* @__PURE__ */ React2.createElement(Reactive.View, null, ItemSeparatorComponent)
46
49
  );
47
50
  };
48
51
 
@@ -74,6 +77,7 @@ var LegendList = forwardRef(function LegendList2(props, forwardedRef) {
74
77
  ListHeaderComponentStyle,
75
78
  ListFooterComponent,
76
79
  ListFooterComponentStyle,
80
+ ItemSeparatorComponent,
77
81
  ...rest
78
82
  } = props;
79
83
  const internalRef = useRef(null);
@@ -394,7 +398,8 @@ var LegendList = forwardRef(function LegendList2(props, forwardedRef) {
394
398
  $container: containers$[i],
395
399
  listProps: props,
396
400
  getRenderedItem,
397
- onLayout: updateItemLength
401
+ onLayout: updateItemLength,
402
+ ItemSeparatorComponent
398
403
  }
399
404
  ))
400
405
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "legend-list",
5
5
  "sideEffects": false,
6
6
  "private": false,