@legendapp/list 3.0.0-beta.20 → 3.0.0-beta.22

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,18 @@
1
+ import * as React from 'react';
2
+ import { ComponentProps } from 'react';
3
+ import Reanimated from 'react-native-reanimated';
4
+ import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
5
+
6
+ type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
7
+ type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
8
+ interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
9
+ refScrollView?: React.Ref<Reanimated.ScrollView>;
10
+ }
11
+ type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
12
+ type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
13
+ type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
14
+ ref?: React.Ref<LegendListRef>;
15
+ }) => React.ReactElement | null;
16
+ declare const AnimatedLegendList: AnimatedLegendListDefinition;
17
+
18
+ export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import { ComponentProps } from 'react';
3
+ import Reanimated from 'react-native-reanimated';
4
+ import { LegendListPropsBase, LegendListRef } from '@legendapp/list';
5
+
6
+ type KeysToOmit = "getEstimatedItemSize" | "getFixedItemSize" | "getItemType" | "keyExtractor" | "animatedProps" | "renderItem" | "onItemSizeChanged" | "itemsAreEqual" | "ItemSeparatorComponent";
7
+ type PropsBase<ItemT> = LegendListPropsBase<ItemT, ComponentProps<typeof Reanimated.ScrollView>>;
8
+ interface AnimatedLegendListPropsBase<ItemT> extends Omit<PropsBase<ItemT>, KeysToOmit> {
9
+ refScrollView?: React.Ref<Reanimated.ScrollView>;
10
+ }
11
+ type OtherAnimatedLegendListProps<ItemT> = Pick<PropsBase<ItemT>, KeysToOmit>;
12
+ type AnimatedLegendListProps<ItemT> = Omit<AnimatedLegendListPropsBase<ItemT>, "refLegendList" | "ref"> & OtherAnimatedLegendListProps<ItemT>;
13
+ type AnimatedLegendListDefinition = <ItemT>(props: AnimatedLegendListProps<ItemT> & {
14
+ ref?: React.Ref<LegendListRef>;
15
+ }) => React.ReactElement | null;
16
+ declare const AnimatedLegendList: AnimatedLegendListDefinition;
17
+
18
+ export { AnimatedLegendList, type AnimatedLegendListProps, type AnimatedLegendListPropsBase };
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var Reanimated = require('react-native-reanimated');
5
+ var list = require('@legendapp/list');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+ var Reanimated__default = /*#__PURE__*/_interopDefault(Reanimated);
29
+
30
+ // src/integrations/reanimated.tsx
31
+
32
+ // src/utils/helpers.ts
33
+ function isFunction(obj) {
34
+ return typeof obj === "function";
35
+ }
36
+
37
+ // src/hooks/useCombinedRef.ts
38
+ var useCombinedRef = (...refs) => {
39
+ const callback = React.useCallback((element) => {
40
+ for (const ref of refs) {
41
+ if (!ref) {
42
+ continue;
43
+ }
44
+ if (isFunction(ref)) {
45
+ ref(element);
46
+ } else {
47
+ ref.current = element;
48
+ }
49
+ }
50
+ }, refs);
51
+ return callback;
52
+ };
53
+
54
+ // src/integrations/reanimated.tsx
55
+ var typedMemo = React.memo;
56
+ var LegendListForwardedRef = typedMemo(
57
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
58
+ React__namespace.forwardRef(function LegendListForwardedRef2(props, ref) {
59
+ const { refLegendList, ...rest } = props;
60
+ const refFn = React.useCallback(
61
+ (r) => {
62
+ refLegendList(r);
63
+ },
64
+ [refLegendList]
65
+ );
66
+ return /* @__PURE__ */ React__namespace.createElement(list.LegendList, { ref: refFn, refScrollView: ref, ...rest });
67
+ })
68
+ );
69
+ var AnimatedLegendListComponent = Reanimated__default.default.createAnimatedComponent(LegendListForwardedRef);
70
+ var AnimatedLegendList = typedMemo(
71
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
72
+ React__namespace.forwardRef(function AnimatedLegendList2(props, ref) {
73
+ const { refScrollView, ...rest } = props;
74
+ const { animatedProps } = props;
75
+ const refLegendList = React__namespace.useRef(null);
76
+ const combinedRef = useCombinedRef(refLegendList, ref);
77
+ return /* @__PURE__ */ React__namespace.createElement(
78
+ AnimatedLegendListComponent,
79
+ {
80
+ animatedPropsInternal: animatedProps,
81
+ ref: refScrollView,
82
+ refLegendList: combinedRef,
83
+ ...rest
84
+ }
85
+ );
86
+ })
87
+ );
88
+
89
+ exports.AnimatedLegendList = AnimatedLegendList;
@@ -0,0 +1,65 @@
1
+ import * as React from 'react';
2
+ import { useCallback, memo } from 'react';
3
+ import Reanimated from 'react-native-reanimated';
4
+ import { LegendList } from '@legendapp/list';
5
+
6
+ // src/integrations/reanimated.tsx
7
+
8
+ // src/utils/helpers.ts
9
+ function isFunction(obj) {
10
+ return typeof obj === "function";
11
+ }
12
+
13
+ // src/hooks/useCombinedRef.ts
14
+ var useCombinedRef = (...refs) => {
15
+ const callback = useCallback((element) => {
16
+ for (const ref of refs) {
17
+ if (!ref) {
18
+ continue;
19
+ }
20
+ if (isFunction(ref)) {
21
+ ref(element);
22
+ } else {
23
+ ref.current = element;
24
+ }
25
+ }
26
+ }, refs);
27
+ return callback;
28
+ };
29
+
30
+ // src/integrations/reanimated.tsx
31
+ var typedMemo = memo;
32
+ var LegendListForwardedRef = typedMemo(
33
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
34
+ React.forwardRef(function LegendListForwardedRef2(props, ref) {
35
+ const { refLegendList, ...rest } = props;
36
+ const refFn = useCallback(
37
+ (r) => {
38
+ refLegendList(r);
39
+ },
40
+ [refLegendList]
41
+ );
42
+ return /* @__PURE__ */ React.createElement(LegendList, { ref: refFn, refScrollView: ref, ...rest });
43
+ })
44
+ );
45
+ var AnimatedLegendListComponent = Reanimated.createAnimatedComponent(LegendListForwardedRef);
46
+ var AnimatedLegendList = typedMemo(
47
+ // biome-ignore lint/nursery/noShadow: const function name shadowing is intentional
48
+ React.forwardRef(function AnimatedLegendList2(props, ref) {
49
+ const { refScrollView, ...rest } = props;
50
+ const { animatedProps } = props;
51
+ const refLegendList = React.useRef(null);
52
+ const combinedRef = useCombinedRef(refLegendList, ref);
53
+ return /* @__PURE__ */ React.createElement(
54
+ AnimatedLegendListComponent,
55
+ {
56
+ animatedPropsInternal: animatedProps,
57
+ ref: refScrollView,
58
+ refLegendList: combinedRef,
59
+ ...rest
60
+ }
61
+ );
62
+ })
63
+ );
64
+
65
+ export { AnimatedLegendList };
@@ -0,0 +1,112 @@
1
+ import * as react_native from 'react-native';
2
+ import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
3
+ import * as React from 'react';
4
+ import { LegendListRef, LegendListProps } from '@legendapp/list';
5
+
6
+ type SectionListSeparatorProps<ItemT, SectionT> = {
7
+ leadingItem?: ItemT;
8
+ leadingSection?: SectionListData<ItemT, SectionT>;
9
+ section: SectionListData<ItemT, SectionT>;
10
+ trailingItem?: ItemT;
11
+ trailingSection?: SectionListData<ItemT, SectionT>;
12
+ };
13
+ type SectionHeaderItem<SectionT> = {
14
+ kind: "header";
15
+ key: string;
16
+ section: SectionT;
17
+ sectionIndex: number;
18
+ };
19
+ type SectionFooterItem<SectionT> = {
20
+ kind: "footer";
21
+ key: string;
22
+ section: SectionT;
23
+ sectionIndex: number;
24
+ };
25
+ type SectionBodyItem<ItemT, SectionT> = {
26
+ kind: "item";
27
+ key: string;
28
+ section: SectionT;
29
+ sectionIndex: number;
30
+ item: ItemT;
31
+ itemIndex: number;
32
+ absoluteItemIndex: number;
33
+ };
34
+ type SectionItemSeparator<ItemT, SectionT> = {
35
+ kind: "item-separator";
36
+ key: string;
37
+ section: SectionT;
38
+ sectionIndex: number;
39
+ leadingItem: ItemT;
40
+ leadingItemIndex: number;
41
+ trailingItem?: ItemT;
42
+ };
43
+ type SectionSeparator<SectionT> = {
44
+ kind: "section-separator";
45
+ key: string;
46
+ leadingSection: SectionT;
47
+ leadingSectionIndex: number;
48
+ trailingSection?: SectionT;
49
+ };
50
+ type FlatSectionListItem<ItemT, SectionT> = SectionHeaderItem<SectionT> | SectionFooterItem<SectionT> | SectionBodyItem<ItemT, SectionT> | SectionItemSeparator<ItemT, SectionT> | SectionSeparator<SectionT>;
51
+ type SectionMeta = {
52
+ header?: number;
53
+ footer?: number;
54
+ items: number[];
55
+ };
56
+ type BuildSectionListDataResult<ItemT, SectionT> = {
57
+ data: Array<FlatSectionListItem<ItemT, SectionT>>;
58
+ sectionMeta: SectionMeta[];
59
+ stickyHeaderIndices: number[];
60
+ };
61
+
62
+ type SectionListViewToken<ItemT, SectionT> = {
63
+ item: ItemT;
64
+ key: string;
65
+ index: number;
66
+ isViewable: boolean;
67
+ section: SectionListData<ItemT, SectionT>;
68
+ };
69
+ type SectionListOnViewableItemsChanged<ItemT, SectionT> = ((info: {
70
+ viewableItems: Array<SectionListViewToken<ItemT, SectionT>>;
71
+ changed: Array<SectionListViewToken<ItemT, SectionT>>;
72
+ }) => void) | null;
73
+ type SectionListLegendProps<ItemT, SectionT> = Omit<LegendListProps<FlatSectionListItem<ItemT, SectionT>>, "data" | "children" | "renderItem" | "keyExtractor" | "ItemSeparatorComponent" | "getItemType" | "getFixedItemSize" | "stickyHeaderIndices" | "numColumns" | "columnWrapperStyle" | "onViewableItemsChanged">;
74
+ type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<ItemT>> = SectionListLegendProps<ItemT, SectionT> & {
75
+ sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
76
+ extraData?: any;
77
+ renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null;
78
+ renderSectionHeader?: (info: {
79
+ section: SectionListData<ItemT, SectionT>;
80
+ }) => React.ReactElement | null;
81
+ renderSectionFooter?: (info: {
82
+ section: SectionListData<ItemT, SectionT>;
83
+ }) => React.ReactElement | null;
84
+ ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null;
85
+ SectionSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | React.ReactElement | null;
86
+ keyExtractor?: (item: ItemT, index: number) => string;
87
+ stickySectionHeadersEnabled?: boolean;
88
+ onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT>;
89
+ };
90
+ type SectionListRef = LegendListRef & {
91
+ scrollToLocation(params: SectionListScrollParams): void;
92
+ };
93
+ declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_native.DefaultSectionT>>(props: SectionListLegendProps<ItemT, SectionT> & {
94
+ sections: readonly SectionListData<ItemT, SectionT>[];
95
+ extraData?: any;
96
+ renderItem?: ((info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null) | undefined;
97
+ renderSectionHeader?: ((info: {
98
+ section: SectionListData<ItemT, SectionT>;
99
+ }) => React.ReactElement | null) | undefined;
100
+ renderSectionFooter?: ((info: {
101
+ section: SectionListData<ItemT, SectionT>;
102
+ }) => React.ReactElement | null) | undefined;
103
+ ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
104
+ SectionSeparatorComponent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
105
+ keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
106
+ stickySectionHeadersEnabled?: boolean;
107
+ onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT> | undefined;
108
+ } & React.RefAttributes<SectionListRef>) => React.ReactNode) & {
109
+ displayName?: string;
110
+ };
111
+
112
+ export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };
@@ -0,0 +1,112 @@
1
+ import * as react_native from 'react-native';
2
+ import { SectionListData, SectionBase, SectionListRenderItemInfo, SectionListScrollParams } from 'react-native';
3
+ import * as React from 'react';
4
+ import { LegendListRef, LegendListProps } from '@legendapp/list';
5
+
6
+ type SectionListSeparatorProps<ItemT, SectionT> = {
7
+ leadingItem?: ItemT;
8
+ leadingSection?: SectionListData<ItemT, SectionT>;
9
+ section: SectionListData<ItemT, SectionT>;
10
+ trailingItem?: ItemT;
11
+ trailingSection?: SectionListData<ItemT, SectionT>;
12
+ };
13
+ type SectionHeaderItem<SectionT> = {
14
+ kind: "header";
15
+ key: string;
16
+ section: SectionT;
17
+ sectionIndex: number;
18
+ };
19
+ type SectionFooterItem<SectionT> = {
20
+ kind: "footer";
21
+ key: string;
22
+ section: SectionT;
23
+ sectionIndex: number;
24
+ };
25
+ type SectionBodyItem<ItemT, SectionT> = {
26
+ kind: "item";
27
+ key: string;
28
+ section: SectionT;
29
+ sectionIndex: number;
30
+ item: ItemT;
31
+ itemIndex: number;
32
+ absoluteItemIndex: number;
33
+ };
34
+ type SectionItemSeparator<ItemT, SectionT> = {
35
+ kind: "item-separator";
36
+ key: string;
37
+ section: SectionT;
38
+ sectionIndex: number;
39
+ leadingItem: ItemT;
40
+ leadingItemIndex: number;
41
+ trailingItem?: ItemT;
42
+ };
43
+ type SectionSeparator<SectionT> = {
44
+ kind: "section-separator";
45
+ key: string;
46
+ leadingSection: SectionT;
47
+ leadingSectionIndex: number;
48
+ trailingSection?: SectionT;
49
+ };
50
+ type FlatSectionListItem<ItemT, SectionT> = SectionHeaderItem<SectionT> | SectionFooterItem<SectionT> | SectionBodyItem<ItemT, SectionT> | SectionItemSeparator<ItemT, SectionT> | SectionSeparator<SectionT>;
51
+ type SectionMeta = {
52
+ header?: number;
53
+ footer?: number;
54
+ items: number[];
55
+ };
56
+ type BuildSectionListDataResult<ItemT, SectionT> = {
57
+ data: Array<FlatSectionListItem<ItemT, SectionT>>;
58
+ sectionMeta: SectionMeta[];
59
+ stickyHeaderIndices: number[];
60
+ };
61
+
62
+ type SectionListViewToken<ItemT, SectionT> = {
63
+ item: ItemT;
64
+ key: string;
65
+ index: number;
66
+ isViewable: boolean;
67
+ section: SectionListData<ItemT, SectionT>;
68
+ };
69
+ type SectionListOnViewableItemsChanged<ItemT, SectionT> = ((info: {
70
+ viewableItems: Array<SectionListViewToken<ItemT, SectionT>>;
71
+ changed: Array<SectionListViewToken<ItemT, SectionT>>;
72
+ }) => void) | null;
73
+ type SectionListLegendProps<ItemT, SectionT> = Omit<LegendListProps<FlatSectionListItem<ItemT, SectionT>>, "data" | "children" | "renderItem" | "keyExtractor" | "ItemSeparatorComponent" | "getItemType" | "getFixedItemSize" | "stickyHeaderIndices" | "numColumns" | "columnWrapperStyle" | "onViewableItemsChanged">;
74
+ type SectionListProps<ItemT, SectionT extends SectionBase<ItemT> = SectionBase<ItemT>> = SectionListLegendProps<ItemT, SectionT> & {
75
+ sections: ReadonlyArray<SectionListData<ItemT, SectionT>>;
76
+ extraData?: any;
77
+ renderItem?: (info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null;
78
+ renderSectionHeader?: (info: {
79
+ section: SectionListData<ItemT, SectionT>;
80
+ }) => React.ReactElement | null;
81
+ renderSectionFooter?: (info: {
82
+ section: SectionListData<ItemT, SectionT>;
83
+ }) => React.ReactElement | null;
84
+ ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null;
85
+ SectionSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | React.ReactElement | null;
86
+ keyExtractor?: (item: ItemT, index: number) => string;
87
+ stickySectionHeadersEnabled?: boolean;
88
+ onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT>;
89
+ };
90
+ type SectionListRef = LegendListRef & {
91
+ scrollToLocation(params: SectionListScrollParams): void;
92
+ };
93
+ declare const SectionList: (<ItemT, SectionT extends SectionBase<ItemT, react_native.DefaultSectionT>>(props: SectionListLegendProps<ItemT, SectionT> & {
94
+ sections: readonly SectionListData<ItemT, SectionT>[];
95
+ extraData?: any;
96
+ renderItem?: ((info: SectionListRenderItemInfo<ItemT, SectionT>) => React.ReactElement | null) | undefined;
97
+ renderSectionHeader?: ((info: {
98
+ section: SectionListData<ItemT, SectionT>;
99
+ }) => React.ReactElement | null) | undefined;
100
+ renderSectionFooter?: ((info: {
101
+ section: SectionListData<ItemT, SectionT>;
102
+ }) => React.ReactElement | null) | undefined;
103
+ ItemSeparatorComponent?: React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
104
+ SectionSeparatorComponent?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ComponentType<SectionListSeparatorProps<ItemT, SectionT>> | null | undefined;
105
+ keyExtractor?: ((item: ItemT, index: number) => string) | undefined;
106
+ stickySectionHeadersEnabled?: boolean;
107
+ onViewableItemsChanged?: SectionListOnViewableItemsChanged<ItemT, SectionT> | undefined;
108
+ } & React.RefAttributes<SectionListRef>) => React.ReactNode) & {
109
+ displayName?: string;
110
+ };
111
+
112
+ export { type BuildSectionListDataResult, type FlatSectionListItem, SectionList, type SectionListOnViewableItemsChanged, type SectionListProps, type SectionListRef, type SectionListSeparatorProps, type SectionListViewToken, type SectionMeta };