@r0b0t3d/react-native-collapsible 1.3.5-beta.2 → 1.3.5-beta.3
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/lib/commonjs/components/CollapsibleContainer.js +1 -2
- package/lib/commonjs/components/CollapsibleContainer.js.map +1 -1
- package/lib/commonjs/components/CollapsibleView.js +1 -1
- package/lib/commonjs/components/CollapsibleView.js.map +1 -1
- package/lib/commonjs/components/header/CollapsibleHeaderContainer.js +85 -23
- package/lib/commonjs/components/header/CollapsibleHeaderContainer.js.map +1 -1
- package/lib/commonjs/components/header/StickyView.js +30 -19
- package/lib/commonjs/components/header/StickyView.js.map +1 -1
- package/lib/commonjs/components/scrollable/useAnimatedScroll.js +2 -3
- package/lib/commonjs/components/scrollable/useAnimatedScroll.js.map +1 -1
- package/lib/commonjs/hooks/useCollapsibleHeaderContext.js.map +1 -1
- package/lib/commonjs/utils/useSharedValueRef.js +21 -0
- package/lib/commonjs/utils/useSharedValueRef.js.map +1 -0
- package/lib/commonjs/withCollapsibleContext.js +37 -92
- package/lib/commonjs/withCollapsibleContext.js.map +1 -1
- package/lib/module/components/CollapsibleContainer.js +1 -2
- package/lib/module/components/CollapsibleContainer.js.map +1 -1
- package/lib/module/components/CollapsibleView.js +1 -1
- package/lib/module/components/CollapsibleView.js.map +1 -1
- package/lib/module/components/header/CollapsibleHeaderContainer.js +87 -24
- package/lib/module/components/header/CollapsibleHeaderContainer.js.map +1 -1
- package/lib/module/components/header/StickyView.js +31 -20
- package/lib/module/components/header/StickyView.js.map +1 -1
- package/lib/module/components/scrollable/useAnimatedScroll.js +2 -3
- package/lib/module/components/scrollable/useAnimatedScroll.js.map +1 -1
- package/lib/module/hooks/useCollapsibleHeaderContext.js.map +1 -1
- package/lib/module/utils/useSharedValueRef.js +15 -0
- package/lib/module/utils/useSharedValueRef.js.map +1 -0
- package/lib/module/withCollapsibleContext.js +38 -92
- package/lib/module/withCollapsibleContext.js.map +1 -1
- package/lib/typescript/components/CollapsibleContainer.d.ts.map +1 -1
- package/lib/typescript/components/header/CollapsibleHeaderContainer.d.ts +2 -2
- package/lib/typescript/components/header/CollapsibleHeaderContainer.d.ts.map +1 -1
- package/lib/typescript/components/header/StickyView.d.ts.map +1 -1
- package/lib/typescript/components/scrollable/useAnimatedScroll.d.ts.map +1 -1
- package/lib/typescript/hooks/useCollapsibleHeaderContext.d.ts +6 -11
- package/lib/typescript/hooks/useCollapsibleHeaderContext.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +6 -6
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/useSharedValueRef.d.ts +3 -0
- package/lib/typescript/utils/useSharedValueRef.d.ts.map +1 -0
- package/lib/typescript/withCollapsibleContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/CollapsibleContainer.tsx +0 -2
- package/src/components/CollapsibleView.tsx +1 -1
- package/src/components/header/CollapsibleHeaderContainer.tsx +145 -25
- package/src/components/header/StickyView.tsx +32 -17
- package/src/components/scrollable/useAnimatedScroll.ts +3 -9
- package/src/hooks/useCollapsibleHeaderContext.ts +6 -8
- package/src/types.ts +8 -8
- package/src/utils/useSharedValueRef.ts +22 -0
- package/src/withCollapsibleContext.tsx +46 -110
- package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js +0 -59
- package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js.map +0 -1
- package/lib/commonjs/components/header/CollapsibleHeaderProvider.js +0 -58
- package/lib/commonjs/components/header/CollapsibleHeaderProvider.js.map +0 -1
- package/lib/module/components/header/CollapsibleHeaderConsumer.js +0 -50
- package/lib/module/components/header/CollapsibleHeaderConsumer.js.map +0 -1
- package/lib/module/components/header/CollapsibleHeaderProvider.js +0 -49
- package/lib/module/components/header/CollapsibleHeaderProvider.js.map +0 -1
- package/lib/typescript/components/header/CollapsibleHeaderConsumer.d.ts +0 -3
- package/lib/typescript/components/header/CollapsibleHeaderConsumer.d.ts.map +0 -1
- package/lib/typescript/components/header/CollapsibleHeaderProvider.d.ts +0 -5
- package/lib/typescript/components/header/CollapsibleHeaderProvider.d.ts.map +0 -1
- package/src/components/header/CollapsibleHeaderConsumer.tsx +0 -62
- package/src/components/header/CollapsibleHeaderProvider.tsx +0 -70
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","useCallback","useEffect","useMemo","useRef","useState","CollapsibleHeaderContext","CollapsibleHeaderProvider","_ref","children","headers","setHeaders","mounted","current","mount","key","prev","unmount","filter","h","update","map","item","context","createElement","Provider","value"],"sourceRoot":"../../../../src","sources":["components/header/CollapsibleHeaderProvider.tsx"],"mappings":"AAAA;AACA,OAAOA,KAAK,IAEVC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SACEC,wBAAwB,QAEnB,yCAAyC;AAEhD,eAAe,SAASC,yBAAyBA,CAAAC,IAAA,EAI9C;EAAA,IAJ+C;IAChDC;EAGF,CAAC,GAAAD,IAAA;EACC,MAAM,CAACE,OAAO,EAAEC,UAAU,CAAC,GAAGN,QAAQ,CAAe,EAAE,CAAC;EACxD,MAAMO,OAAO,GAAGR,MAAM,CAAC,KAAK,CAAC;EAE7BF,SAAS,CAAC,MAAM;IACdU,OAAO,CAACC,OAAO,GAAG,IAAI;IACtB,OAAO,MAAM;MACXD,OAAO,CAACC,OAAO,GAAG,KAAK;IACzB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,KAAK,GAAGb,WAAW,CAAC,CAACc,GAAW,EAAEN,QAAmB,KAAK;IAC9DE,UAAU,CAAEK,IAAI,IAAK,CAAC,GAAGA,IAAI,EAAE;MAAED,GAAG;MAAEN;IAAS,CAAC,CAAC,CAAC;EACpD,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMQ,OAAO,GAAGhB,WAAW,CAAEc,GAAW,IAAK;IAC3CJ,UAAU,CAAEK,IAAI,IAAKA,IAAI,CAACE,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACJ,GAAG,KAAKA,GAAG,CAAC,CAAC;EACzD,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMK,MAAM,GAAGnB,WAAW,CAAC,CAACc,GAAW,EAAEN,QAAmB,KAAK;IAC/D,IAAI,CAACG,OAAO,CAACC,OAAO,EAAE;MACpB;IACF;IACAF,UAAU,CAAEK,IAAI,IACdA,IAAI,CAACK,GAAG,CAAEC,IAAI,IAAK;MACjB,IAAIA,IAAI,CAACP,GAAG,KAAKA,GAAG,EAAE;QACpB,OAAO;UACL,GAAGO,IAAI;UACPb;QACF,CAAC;MACH;MACA,OAAOa,IAAI;IACb,CAAC,CACH,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,OAAO,GAAGpB,OAAO,CACrB,OAAO;IACLO,OAAO;IACPI,KAAK;IACLG,OAAO;IACPG;EACF,CAAC,CAAC,EACF,CAACV,OAAO,EAAEI,KAAK,EAAEG,OAAO,EAAEG,MAAM,CAClC,CAAC;EAED,oBACEpB,KAAA,CAAAwB,aAAA,CAAClB,wBAAwB,CAACmB,QAAQ;IAACC,KAAK,EAAEH;EAAQ,GAC/Cd,QACgC,CAAC;AAExC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleHeaderConsumer.d.ts","sourceRoot":"","sources":["../../../../src/components/header/CollapsibleHeaderConsumer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAW3C,MAAM,CAAC,OAAO,UAAU,yBAAyB,sBA2ChD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CollapsibleHeaderProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/header/CollapsibleHeaderProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EACZ,SAAS,EAMV,MAAM,OAAO,CAAC;AAMf,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,EAChD,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,qBAmDA"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';
|
|
3
|
-
import useCollapsibleHeaderContext from '../../hooks/useCollapsibleHeaderContext';
|
|
4
|
-
import Animated, {
|
|
5
|
-
interpolate,
|
|
6
|
-
useAnimatedStyle,
|
|
7
|
-
useDerivedValue,
|
|
8
|
-
} from 'react-native-reanimated';
|
|
9
|
-
import useCollapsibleContext from '../../hooks/useCollapsibleContext';
|
|
10
|
-
import { LayoutChangeEvent, StyleSheet } from 'react-native';
|
|
11
|
-
|
|
12
|
-
export default function CollapsibleHeaderConsumer() {
|
|
13
|
-
const { headers } = useCollapsibleHeaderContext();
|
|
14
|
-
const { handleHeaderContainerLayout } = useInternalCollapsibleContext();
|
|
15
|
-
const { scrollY, headerHeight } = useCollapsibleContext();
|
|
16
|
-
|
|
17
|
-
const headerTranslate = useDerivedValue(
|
|
18
|
-
() =>
|
|
19
|
-
interpolate(
|
|
20
|
-
scrollY.value,
|
|
21
|
-
// FIXME: can improve by geting maxY value of header and sticky views
|
|
22
|
-
[-1000, 0, 100000],
|
|
23
|
-
[0, 0, -100000],
|
|
24
|
-
'clamp'
|
|
25
|
-
),
|
|
26
|
-
[]
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const headerStyle = useAnimatedStyle(() => {
|
|
30
|
-
return {
|
|
31
|
-
transform: [{ translateY: headerTranslate.value }],
|
|
32
|
-
};
|
|
33
|
-
}, [headerHeight, headerTranslate]);
|
|
34
|
-
|
|
35
|
-
const handleHeaderLayout = useCallback(
|
|
36
|
-
({
|
|
37
|
-
nativeEvent: {
|
|
38
|
-
layout: { height },
|
|
39
|
-
},
|
|
40
|
-
}: LayoutChangeEvent) => {
|
|
41
|
-
handleHeaderContainerLayout(height);
|
|
42
|
-
},
|
|
43
|
-
[handleHeaderContainerLayout]
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Animated.View
|
|
48
|
-
onLayout={handleHeaderLayout}
|
|
49
|
-
style={[styles.container, headerStyle]}
|
|
50
|
-
pointerEvents="box-none"
|
|
51
|
-
>
|
|
52
|
-
{headers.map((item) => item.children)}
|
|
53
|
-
</Animated.View>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const styles = StyleSheet.create({
|
|
58
|
-
container: {
|
|
59
|
-
zIndex: 10,
|
|
60
|
-
backgroundColor: 'white',
|
|
61
|
-
},
|
|
62
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-shadow */
|
|
2
|
-
import React, {
|
|
3
|
-
ReactNode,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from 'react';
|
|
10
|
-
import {
|
|
11
|
-
CollapsibleHeaderContext,
|
|
12
|
-
HeaderItem,
|
|
13
|
-
} from '../../hooks/useCollapsibleHeaderContext';
|
|
14
|
-
|
|
15
|
-
export default function CollapsibleHeaderProvider({
|
|
16
|
-
children,
|
|
17
|
-
}: {
|
|
18
|
-
children: ReactNode;
|
|
19
|
-
}) {
|
|
20
|
-
const [headers, setHeaders] = useState<HeaderItem[]>([]);
|
|
21
|
-
const mounted = useRef(false);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
mounted.current = true;
|
|
25
|
-
return () => {
|
|
26
|
-
mounted.current = false;
|
|
27
|
-
};
|
|
28
|
-
}, []);
|
|
29
|
-
|
|
30
|
-
const mount = useCallback((key: string, children: ReactNode) => {
|
|
31
|
-
setHeaders((prev) => [...prev, { key, children }]);
|
|
32
|
-
}, []);
|
|
33
|
-
|
|
34
|
-
const unmount = useCallback((key: string) => {
|
|
35
|
-
setHeaders((prev) => prev.filter((h) => h.key !== key));
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
const update = useCallback((key: string, children: ReactNode) => {
|
|
39
|
-
if (!mounted.current) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
setHeaders((prev) =>
|
|
43
|
-
prev.map((item) => {
|
|
44
|
-
if (item.key === key) {
|
|
45
|
-
return {
|
|
46
|
-
...item,
|
|
47
|
-
children,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
return item;
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
const context = useMemo(
|
|
56
|
-
() => ({
|
|
57
|
-
headers,
|
|
58
|
-
mount,
|
|
59
|
-
unmount,
|
|
60
|
-
update,
|
|
61
|
-
}),
|
|
62
|
-
[headers, mount, unmount, update]
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<CollapsibleHeaderContext.Provider value={context}>
|
|
67
|
-
{children}
|
|
68
|
-
</CollapsibleHeaderContext.Provider>
|
|
69
|
-
);
|
|
70
|
-
}
|