@legendapp/list 0.3.5 → 0.3.6

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 (5) hide show
  1. package/index.d.mts +104 -3
  2. package/index.d.ts +104 -3
  3. package/index.js +518 -381
  4. package/index.mjs +517 -380
  5. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
2
- import { ScrollView, StyleProp, ViewStyle } from 'react-native';
2
+ import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
3
3
 
4
4
  type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset'> & {
5
5
  data: ArrayLike<any> & T[];
@@ -25,7 +25,33 @@ type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset
25
25
  ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
26
26
  ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
27
27
  ItemSeparatorComponent?: React.ComponentType<any>;
28
+ viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
29
+ viewabilityConfig?: ViewabilityConfig;
30
+ onViewableItemsChanged?: OnViewableItemsChanged | undefined;
28
31
  };
32
+ interface InternalState {
33
+ positions: Map<string, number>;
34
+ sizes: Map<string, number>;
35
+ pendingAdjust: number;
36
+ animFrameScroll: number | null;
37
+ animFrameLayout: number | null;
38
+ animFrameTotalSize: number | null;
39
+ isStartReached: boolean;
40
+ isEndReached: boolean;
41
+ isAtBottom: boolean;
42
+ data: any[];
43
+ idsInFirstRender: Set<string>;
44
+ hasScrolled: boolean;
45
+ scrollLength: number;
46
+ startBuffered: number;
47
+ startNoBuffer: number;
48
+ endBuffered: number;
49
+ endNoBuffer: number;
50
+ scroll: number;
51
+ totalSize: number;
52
+ timeouts: Set<number>;
53
+ viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs;
54
+ }
29
55
  interface ViewableRange<T> {
30
56
  startBuffered: number;
31
57
  start: number;
@@ -37,9 +63,84 @@ interface LegendListRenderItemInfo<ItemT> {
37
63
  item: ItemT;
38
64
  index: number;
39
65
  }
66
+ type LegendListRef = {
67
+ /**
68
+ * Displays the scroll indicators momentarily.
69
+ */
70
+ flashScrollIndicators(): void;
71
+ getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
72
+ getScrollResponder(): ScrollResponderMixin;
73
+ getScrollableNode(): any;
74
+ /**
75
+ * A helper function that scrolls to the end of the scrollview;
76
+ * If this is a vertical ScrollView, it scrolls to the bottom.
77
+ * If this is a horizontal ScrollView scrolls to the right.
78
+ *
79
+ * The options object has an animated prop, that enables the scrolling animation or not.
80
+ * The animated prop defaults to true
81
+ */
82
+ scrollToEnd(options?: {
83
+ animated?: boolean | undefined;
84
+ }): void;
85
+ scrollToIndex: (params: {
86
+ index: number;
87
+ animated?: boolean;
88
+ viewOffset?: number;
89
+ viewPosition?: number;
90
+ }) => void;
91
+ scrollToItem(params: {
92
+ animated?: boolean;
93
+ item: any;
94
+ viewPosition?: number;
95
+ }): void;
96
+ scrollToOffset(params: {
97
+ offset: number;
98
+ animated?: boolean;
99
+ }): void;
100
+ };
101
+ interface ViewToken<ItemT = any> {
102
+ item: ItemT;
103
+ key: string;
104
+ index: number;
105
+ isViewable: boolean;
106
+ }
107
+ interface ViewabilityConfigCallbackPair {
108
+ viewabilityConfig: ViewabilityConfig;
109
+ onViewableItemsChanged: OnViewableItemsChanged;
110
+ }
111
+ type ViewabilityConfigCallbackPairs = ViewabilityConfigCallbackPair[];
112
+ type OnViewableItemsChanged = ((info: {
113
+ viewableItems: Array<ViewToken>;
114
+ changed: Array<ViewToken>;
115
+ }) => void) | null;
116
+ interface ViewabilityConfig {
117
+ /**
118
+ * Minimum amount of time (in milliseconds) that an item must be physically viewable before the
119
+ * viewability callback will be fired. A high number means that scrolling through content without
120
+ * stopping will not mark the content as viewable.
121
+ */
122
+ minimumViewTime?: number | undefined;
123
+ /**
124
+ * Percent of viewport that must be covered for a partially occluded item to count as
125
+ * "viewable", 0-100. Fully visible items are always considered viewable. A value of 0 means
126
+ * that a single pixel in the viewport makes the item viewable, and a value of 100 means that
127
+ * an item must be either entirely visible or cover the entire viewport to count as viewable.
128
+ */
129
+ viewAreaCoveragePercentThreshold?: number | undefined;
130
+ /**
131
+ * Similar to `viewAreaCoveragePercentThreshold`, but considers the percent of the item that is visible,
132
+ * rather than the fraction of the viewable area it covers.
133
+ */
134
+ itemVisiblePercentThreshold?: number | undefined;
135
+ /**
136
+ * Nothing is considered viewable until the user scrolls or `recordInteraction` is called after
137
+ * render.
138
+ */
139
+ waitForInteraction?: boolean | undefined;
140
+ }
40
141
 
41
142
  declare const LegendList: <T>(props: LegendListProps<T> & {
42
- ref?: ForwardedRef<ScrollView>;
143
+ ref?: ForwardedRef<LegendListRef>;
43
144
  }) => ReactElement;
44
145
 
45
- export { LegendList, type LegendListProps, type LegendListRenderItemInfo, type ViewableRange };
146
+ export { type InternalState, LegendList, type LegendListProps, type LegendListRef, type LegendListRenderItemInfo, type OnViewableItemsChanged, type ViewToken, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps, ReactNode, ForwardedRef, ReactElement } from 'react';
2
- import { ScrollView, StyleProp, ViewStyle } from 'react-native';
2
+ import { ScrollView, StyleProp, ViewStyle, ScrollViewComponent, ScrollResponderMixin } from 'react-native';
3
3
 
4
4
  type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset'> & {
5
5
  data: ArrayLike<any> & T[];
@@ -25,7 +25,33 @@ type LegendListProps<T> = Omit<ComponentProps<typeof ScrollView>, 'contentOffset
25
25
  ListFooterComponent?: React.ComponentType<any> | React.ReactElement | null | undefined;
26
26
  ListFooterComponentStyle?: StyleProp<ViewStyle> | undefined;
27
27
  ItemSeparatorComponent?: React.ComponentType<any>;
28
+ viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs | undefined;
29
+ viewabilityConfig?: ViewabilityConfig;
30
+ onViewableItemsChanged?: OnViewableItemsChanged | undefined;
28
31
  };
32
+ interface InternalState {
33
+ positions: Map<string, number>;
34
+ sizes: Map<string, number>;
35
+ pendingAdjust: number;
36
+ animFrameScroll: number | null;
37
+ animFrameLayout: number | null;
38
+ animFrameTotalSize: number | null;
39
+ isStartReached: boolean;
40
+ isEndReached: boolean;
41
+ isAtBottom: boolean;
42
+ data: any[];
43
+ idsInFirstRender: Set<string>;
44
+ hasScrolled: boolean;
45
+ scrollLength: number;
46
+ startBuffered: number;
47
+ startNoBuffer: number;
48
+ endBuffered: number;
49
+ endNoBuffer: number;
50
+ scroll: number;
51
+ totalSize: number;
52
+ timeouts: Set<number>;
53
+ viewabilityConfigCallbackPairs: ViewabilityConfigCallbackPairs;
54
+ }
29
55
  interface ViewableRange<T> {
30
56
  startBuffered: number;
31
57
  start: number;
@@ -37,9 +63,84 @@ interface LegendListRenderItemInfo<ItemT> {
37
63
  item: ItemT;
38
64
  index: number;
39
65
  }
66
+ type LegendListRef = {
67
+ /**
68
+ * Displays the scroll indicators momentarily.
69
+ */
70
+ flashScrollIndicators(): void;
71
+ getNativeScrollRef(): React.ElementRef<typeof ScrollViewComponent>;
72
+ getScrollResponder(): ScrollResponderMixin;
73
+ getScrollableNode(): any;
74
+ /**
75
+ * A helper function that scrolls to the end of the scrollview;
76
+ * If this is a vertical ScrollView, it scrolls to the bottom.
77
+ * If this is a horizontal ScrollView scrolls to the right.
78
+ *
79
+ * The options object has an animated prop, that enables the scrolling animation or not.
80
+ * The animated prop defaults to true
81
+ */
82
+ scrollToEnd(options?: {
83
+ animated?: boolean | undefined;
84
+ }): void;
85
+ scrollToIndex: (params: {
86
+ index: number;
87
+ animated?: boolean;
88
+ viewOffset?: number;
89
+ viewPosition?: number;
90
+ }) => void;
91
+ scrollToItem(params: {
92
+ animated?: boolean;
93
+ item: any;
94
+ viewPosition?: number;
95
+ }): void;
96
+ scrollToOffset(params: {
97
+ offset: number;
98
+ animated?: boolean;
99
+ }): void;
100
+ };
101
+ interface ViewToken<ItemT = any> {
102
+ item: ItemT;
103
+ key: string;
104
+ index: number;
105
+ isViewable: boolean;
106
+ }
107
+ interface ViewabilityConfigCallbackPair {
108
+ viewabilityConfig: ViewabilityConfig;
109
+ onViewableItemsChanged: OnViewableItemsChanged;
110
+ }
111
+ type ViewabilityConfigCallbackPairs = ViewabilityConfigCallbackPair[];
112
+ type OnViewableItemsChanged = ((info: {
113
+ viewableItems: Array<ViewToken>;
114
+ changed: Array<ViewToken>;
115
+ }) => void) | null;
116
+ interface ViewabilityConfig {
117
+ /**
118
+ * Minimum amount of time (in milliseconds) that an item must be physically viewable before the
119
+ * viewability callback will be fired. A high number means that scrolling through content without
120
+ * stopping will not mark the content as viewable.
121
+ */
122
+ minimumViewTime?: number | undefined;
123
+ /**
124
+ * Percent of viewport that must be covered for a partially occluded item to count as
125
+ * "viewable", 0-100. Fully visible items are always considered viewable. A value of 0 means
126
+ * that a single pixel in the viewport makes the item viewable, and a value of 100 means that
127
+ * an item must be either entirely visible or cover the entire viewport to count as viewable.
128
+ */
129
+ viewAreaCoveragePercentThreshold?: number | undefined;
130
+ /**
131
+ * Similar to `viewAreaCoveragePercentThreshold`, but considers the percent of the item that is visible,
132
+ * rather than the fraction of the viewable area it covers.
133
+ */
134
+ itemVisiblePercentThreshold?: number | undefined;
135
+ /**
136
+ * Nothing is considered viewable until the user scrolls or `recordInteraction` is called after
137
+ * render.
138
+ */
139
+ waitForInteraction?: boolean | undefined;
140
+ }
40
141
 
41
142
  declare const LegendList: <T>(props: LegendListProps<T> & {
42
- ref?: ForwardedRef<ScrollView>;
143
+ ref?: ForwardedRef<LegendListRef>;
43
144
  }) => ReactElement;
44
145
 
45
- export { LegendList, type LegendListProps, type LegendListRenderItemInfo, type ViewableRange };
146
+ export { type InternalState, LegendList, type LegendListProps, type LegendListRef, type LegendListRenderItemInfo, type OnViewableItemsChanged, type ViewToken, type ViewabilityConfig, type ViewabilityConfigCallbackPair, type ViewabilityConfigCallbackPairs, type ViewableRange };