@r0b0t3d/react-native-collapsible 1.3.3 → 1.3.5-alpha.0
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 -3
- package/lib/commonjs/components/CollapsibleContainer.js.map +1 -1
- package/lib/commonjs/components/CollapsibleView.js +15 -5
- package/lib/commonjs/components/CollapsibleView.js.map +1 -1
- package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js +1 -1
- package/lib/commonjs/components/header/CollapsibleHeaderConsumer.js.map +1 -1
- package/lib/commonjs/components/header/CollapsibleHeaderContainer.js +5 -13
- package/lib/commonjs/components/header/CollapsibleHeaderContainer.js.map +1 -1
- package/lib/commonjs/components/header/StickyView.js +2 -1
- package/lib/commonjs/components/header/StickyView.js.map +1 -1
- package/lib/commonjs/components/scrollable/CollapsibleFlatList.js +36 -28
- package/lib/commonjs/components/scrollable/CollapsibleFlatList.js.map +1 -1
- package/lib/commonjs/components/scrollable/CollapsibleScrollView.js +7 -14
- package/lib/commonjs/components/scrollable/CollapsibleScrollView.js.map +1 -1
- package/lib/commonjs/components/scrollable/useAnimatedScroll.js.map +1 -1
- package/lib/commonjs/index.js +0 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/withCollapsibleContext.js +1 -3
- 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 +16 -6
- package/lib/module/components/CollapsibleView.js.map +1 -1
- package/lib/module/components/header/CollapsibleHeaderConsumer.js +1 -1
- package/lib/module/components/header/CollapsibleHeaderConsumer.js.map +1 -1
- package/lib/module/components/header/CollapsibleHeaderContainer.js +6 -13
- package/lib/module/components/header/CollapsibleHeaderContainer.js.map +1 -1
- package/lib/module/components/header/StickyView.js +3 -2
- package/lib/module/components/header/StickyView.js.map +1 -1
- package/lib/module/components/scrollable/CollapsibleFlatList.js +36 -26
- package/lib/module/components/scrollable/CollapsibleFlatList.js.map +1 -1
- package/lib/module/components/scrollable/CollapsibleScrollView.js +6 -12
- package/lib/module/components/scrollable/CollapsibleScrollView.js.map +1 -1
- package/lib/module/components/scrollable/useAnimatedScroll.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/withCollapsibleContext.js +1 -2
- package/lib/module/withCollapsibleContext.js.map +1 -1
- package/lib/typescript/components/CollapsibleView.d.ts +2 -1
- package/lib/typescript/components/header/CollapsibleHeaderContainer.d.ts +2 -2
- package/lib/typescript/components/scrollable/useAnimatedScroll.d.ts +1 -1
- package/lib/typescript/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/CollapsibleContainer.tsx +0 -2
- package/src/components/CollapsibleView.tsx +19 -3
- package/src/components/header/CollapsibleHeaderConsumer.tsx +2 -2
- package/src/components/header/CollapsibleHeaderContainer.tsx +8 -15
- package/src/components/header/StickyView.tsx +2 -1
- package/src/components/scrollable/CollapsibleFlatList.tsx +59 -40
- package/src/components/scrollable/CollapsibleScrollView.tsx +4 -8
- package/src/components/scrollable/useAnimatedScroll.ts +1 -1
- package/src/index.tsx +0 -1
- package/src/withCollapsibleContext.tsx +2 -5
- package/lib/commonjs/components/header/AnimatedTopView.js +0 -29
- package/lib/commonjs/components/header/AnimatedTopView.js.map +0 -1
- package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js +0 -75
- package/lib/commonjs/components/pullToRefresh/PullToRefreshContainer.js.map +0 -1
- package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js +0 -35
- package/lib/commonjs/components/pullToRefresh/PullToRefreshProvider.js.map +0 -1
- package/lib/commonjs/components/pullToRefresh/RefreshControl.js +0 -91
- package/lib/commonjs/components/pullToRefresh/RefreshControl.js.map +0 -1
- package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js +0 -24
- package/lib/commonjs/components/pullToRefresh/usePullToRefreshContext.js.map +0 -1
- package/lib/commonjs/components/pullToRefresh/utils.js +0 -59
- package/lib/commonjs/components/pullToRefresh/utils.js.map +0 -1
- package/lib/module/components/header/AnimatedTopView.js +0 -14
- package/lib/module/components/header/AnimatedTopView.js.map +0 -1
- package/lib/module/components/pullToRefresh/PullToRefreshContainer.js +0 -56
- package/lib/module/components/pullToRefresh/PullToRefreshContainer.js.map +0 -1
- package/lib/module/components/pullToRefresh/PullToRefreshProvider.js +0 -21
- package/lib/module/components/pullToRefresh/PullToRefreshProvider.js.map +0 -1
- package/lib/module/components/pullToRefresh/RefreshControl.js +0 -73
- package/lib/module/components/pullToRefresh/RefreshControl.js.map +0 -1
- package/lib/module/components/pullToRefresh/usePullToRefreshContext.js +0 -13
- package/lib/module/components/pullToRefresh/usePullToRefreshContext.js.map +0 -1
- package/lib/module/components/pullToRefresh/utils.js +0 -42
- package/lib/module/components/pullToRefresh/utils.js.map +0 -1
- package/lib/typescript/components/header/AnimatedTopView.d.ts +0 -6
- package/lib/typescript/components/pullToRefresh/PullToRefreshContainer.d.ts +0 -8
- package/lib/typescript/components/pullToRefresh/PullToRefreshProvider.d.ts +0 -6
- package/lib/typescript/components/pullToRefresh/RefreshControl.d.ts +0 -9
- package/lib/typescript/components/pullToRefresh/usePullToRefreshContext.d.ts +0 -4
- package/lib/typescript/components/pullToRefresh/utils.d.ts +0 -20
- package/src/components/header/AnimatedTopView.tsx +0 -18
- package/src/components/pullToRefresh/PullToRefreshContainer.tsx +0 -66
- package/src/components/pullToRefresh/PullToRefreshProvider.tsx +0 -27
- package/src/components/pullToRefresh/RefreshControl.tsx +0 -100
- package/src/components/pullToRefresh/usePullToRefreshContext.ts +0 -13
- package/src/components/pullToRefresh/utils.ts +0 -49
|
@@ -15,8 +15,6 @@ var _useInternalCollapsibleContext = _interopRequireDefault(require("../hooks/us
|
|
|
15
15
|
|
|
16
16
|
var _useCollapsibleContext = _interopRequireDefault(require("../hooks/useCollapsibleContext"));
|
|
17
17
|
|
|
18
|
-
var _CollapsibleHeaderConsumer = _interopRequireDefault(require("./header/CollapsibleHeaderConsumer"));
|
|
19
|
-
|
|
20
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
19
|
|
|
22
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -73,7 +71,7 @@ function CollapsibleContainer({
|
|
|
73
71
|
style: [styles.container, props.style],
|
|
74
72
|
onLayout: handleContainerLayout,
|
|
75
73
|
collapsable: false
|
|
76
|
-
}), children
|
|
74
|
+
}), children));
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleContainer.tsx"],"names":["CollapsibleContainer","children","keyboardAvoidingViewProps","textInputRefs","props","containerRef","handleContainerHeight","scrollY","scrollTo","containerHeight","some","ref","isFocusedFunc","current","isFocused","measureLayout","_left","top","_width","height","value","extraOffset","keyboardVerticalOffset","handleContainerLayout","layout","nativeEvent","styles","container","style","StyleSheet","create","flex","overflow"],"mappings":";;;;;;;AACA;;AACA;;AAQA;;AACA;;AACA
|
|
1
|
+
{"version":3,"sources":["CollapsibleContainer.tsx"],"names":["CollapsibleContainer","children","keyboardAvoidingViewProps","textInputRefs","props","containerRef","handleContainerHeight","scrollY","scrollTo","containerHeight","some","ref","isFocusedFunc","current","isFocused","measureLayout","_left","top","_width","height","value","extraOffset","keyboardVerticalOffset","handleContainerLayout","layout","nativeEvent","styles","container","style","StyleSheet","create","flex","overflow"],"mappings":";;;;;;;AACA;;AACA;;AAQA;;AACA;;AACA;;;;;;;;;;AAQe,SAASA,oBAAT,CAA8B;AAC3CC,EAAAA,QAD2C;AAE3CC,EAAAA,yBA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AAA,qBAAqB,CAACa,MAAD,CAArB;AACD,GAJ6B,EAI3B,EAJ2B,CAA9B;AAMA,sBACE,6BAAC,iCAAD;AACE,IAAA,KAAK,EAAEO,MAAM,CAACC,SADhB;AAEE,IAAA,QAAQ,EAAC;AAFX,KAGMzB,yBAHN,gBAKE,6BAAC,iBAAD,eACME,KADN;AAEE,IAAA,GAAG,EAAEC,YAFP;AAGE,IAAA,KAAK,EAAE,CAACqB,MAAM,CAACC,SAAR,EAAmBvB,KAAK,CAACwB,KAAzB,CAHT;AAIE,IAAA,QAAQ,EAAEL,qBAJZ;AAKE,IAAA,WAAW,EAAE;AALf,MAOGtB,QAPH,CALF,CADF;AAiBD;;AAED,MAAMyB,MAAM,GAAGG,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AACTI,IAAAA,IAAI,EAAE,CADG;AAETC,IAAAA,QAAQ,EAAE;AAFD;AADoB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useCallback, useRef } from 'react';\nimport {\n KeyboardAvoidingView,\n KeyboardAvoidingViewProps,\n LayoutChangeEvent,\n StyleSheet,\n View,\n ViewProps,\n} from 'react-native';\nimport useKeyboardShowEvent from '../hooks/useKeyboardShowEvent';\nimport useInternalCollapsibleContext from '../hooks/useInternalCollapsibleContext';\nimport useCollapsibleContext from '../hooks/useCollapsibleContext';\n\ntype Props = Omit<ViewProps, 'ref' | 'onLayout'> & {\n children: Element;\n keyboardAvoidingViewProps?: KeyboardAvoidingViewProps;\n textInputRefs?: any[];\n};\n\nexport default function CollapsibleContainer({\n children,\n keyboardAvoidingViewProps,\n textInputRefs = [],\n ...props\n}: Props) {\n const { containerRef, handleContainerHeight } =\n useInternalCollapsibleContext();\n const { scrollY, scrollTo } = useCollapsibleContext();\n\n const containerHeight = useRef(0);\n\n useKeyboardShowEvent(() => {\n textInputRefs.some((ref) => {\n const isFocusedFunc = ref.current.isFocused;\n const isFocused =\n isFocusedFunc && typeof isFocusedFunc === 'function'\n ? isFocusedFunc()\n : isFocusedFunc;\n if (isFocused) {\n ref.current.measureLayout(\n // @ts-ignore\n containerRef.current,\n (_left: number, top: number, _width: number, height: number) => {\n if (top + height - scrollY.value > containerHeight.current) {\n const extraOffset =\n keyboardAvoidingViewProps?.keyboardVerticalOffset ?? 20;\n scrollTo(top + height + extraOffset - containerHeight.current);\n }\n },\n () => {}\n );\n }\n return isFocused;\n });\n });\n\n const handleContainerLayout = useCallback((layout: LayoutChangeEvent) => {\n const height = layout.nativeEvent.layout.height;\n containerHeight.current = height;\n handleContainerHeight(height);\n }, []);\n\n return (\n <KeyboardAvoidingView\n style={styles.container}\n behavior=\"padding\"\n {...keyboardAvoidingViewProps}\n >\n <View\n {...props}\n ref={containerRef}\n style={[styles.container, props.style]}\n onLayout={handleContainerLayout}\n collapsable={false}\n >\n {children}\n </View>\n </KeyboardAvoidingView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n overflow: 'hidden',\n },\n});\n"]}
|
|
@@ -28,7 +28,8 @@ function CollapsibleView({
|
|
|
28
28
|
children,
|
|
29
29
|
containerStyle,
|
|
30
30
|
collapsedBackgroundColor,
|
|
31
|
-
expandedBackgroundColor
|
|
31
|
+
expandedBackgroundColor,
|
|
32
|
+
onToggle
|
|
32
33
|
}) {
|
|
33
34
|
const actualHeight = (0, _reactNativeReanimated.useSharedValue)(11110);
|
|
34
35
|
const contentKey = (0, _react.useMemo)(() => `collapsible-view-${key++}`, []);
|
|
@@ -41,7 +42,7 @@ function CollapsibleView({
|
|
|
41
42
|
|
|
42
43
|
collapseState.value = newValue;
|
|
43
44
|
}, [initialState]);
|
|
44
|
-
const
|
|
45
|
+
const handleToggle = (0, _react.useCallback)(() => {
|
|
45
46
|
collapseState.value = (0, _reactNativeReanimated.withSpring)(collapseState.value === 0 ? 1 : 0, {
|
|
46
47
|
overshootClamping: true
|
|
47
48
|
});
|
|
@@ -60,7 +61,16 @@ function CollapsibleView({
|
|
|
60
61
|
}), [actualHeight, contentKey]);
|
|
61
62
|
const contentHeight = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
62
63
|
height: actualHeight.value > 0 ? actualHeight.value : undefined
|
|
63
|
-
}), [actualHeight, contentKey]);
|
|
64
|
+
}), [actualHeight, contentKey]);
|
|
65
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => collapseState.value === 0 ? 0 : collapseState.value === 1 ? 1 : 0, (result, prev) => {
|
|
66
|
+
if (result === prev) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (onToggle) {
|
|
71
|
+
(0, _reactNativeReanimated.runOnJS)(onToggle)(result === 1);
|
|
72
|
+
}
|
|
73
|
+
}); // @ts-ignore
|
|
64
74
|
|
|
65
75
|
const containerAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
66
76
|
if (collapsedBackgroundColor && expandedBackgroundColor) {
|
|
@@ -72,9 +82,9 @@ function CollapsibleView({
|
|
|
72
82
|
return {};
|
|
73
83
|
}, []);
|
|
74
84
|
const headerProps = (0, _react.useMemo)(() => ({
|
|
75
|
-
onToggle,
|
|
85
|
+
onToggle: handleToggle,
|
|
76
86
|
collapsed: collapseState
|
|
77
|
-
}), [
|
|
87
|
+
}), [handleToggle, collapseState]);
|
|
78
88
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
79
89
|
style: [containerStyle, containerAnimatedStyle],
|
|
80
90
|
pointerEvents: "box-none"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleView.tsx"],"names":["key","CollapsibleView","initialState","collapseState","renderHeader","children","containerStyle","collapsedBackgroundColor","expandedBackgroundColor","actualHeight","contentKey","newValue","value","
|
|
1
|
+
{"version":3,"sources":["CollapsibleView.tsx"],"names":["key","CollapsibleView","initialState","collapseState","renderHeader","children","containerStyle","collapsedBackgroundColor","expandedBackgroundColor","onToggle","actualHeight","contentKey","newValue","value","handleToggle","overshootClamping","handleLayout","event","nativeEvent","layout","height","wrapperStyle","damping","stiffness","contentHeight","undefined","result","prev","containerAnimatedStyle","backgroundColor","headerProps","collapsed","styles","wrapper","content","CollapsibleHeaderText","title","style","titleStyle","icon","iconInitialAngle","iconStyle","rotate","transform","headerContainer","headerTitle","StyleSheet","create","overflow","flexDirection","alignItems","flex"],"mappings":";;;;;;;;AAEA;;AACA;;AAUA;;;;;;AAbA;;AACA;AAuCA,IAAIA,GAAG,GAAG,CAAV;;AACe,SAASC,eAAT,CAAyB;AACtCC,EAAAA,YAAY,GAAG,WADuB;AAEtCC,EAAAA,aAAa,GAAG,2CAAe,CAAf,CAFsB;AAGtCC,EAAAA,YAHsC;AAItCC,EAAAA,QAJsC;AAKtCC,EAAAA,cALsC;AAMtCC,EAAAA,wBANsC;AAOtCC,EAAAA,uBAPsC;AAQtCC,EAAAA;AARsC,CAAzB,EASL;AACR,QAAMC,YAAY,GAAG,2CAAe,KAAf,CAArB;AACA,QAAMC,UAAU,GAAG,oBAAQ,MAAO,oBAAmBX,GAAG,EAAG,EAAxC,EAA2C,EAA3C,CAAnB;AAEA,wBAAU,MAAM;AACd,UAAMY,QAAQ,GAAGV,YAAY,KAAK,WAAjB,GAA+B,CAA/B,GAAmC,CAApD;;AACA,QAAIU,QAAQ,KAAKT,aAAa,CAACU,KAA/B,EAAsC;AACpC;AACD;;AACDV,IAAAA,aAAa,CAACU,KAAd,GAAsBD,QAAtB;AACD,GAND,EAMG,CAACV,YAAD,CANH;AAQA,QAAMY,YAAY,GAAG,wBAAY,MAAM;AACrCX,IAAAA,aAAa,CAACU,KAAd,GAAsB,uCAAWV,aAAa,CAACU,KAAd,KAAwB,CAAxB,GAA4B,CAA5B,GAAgC,CAA3C,EAA8C;AAClEE,MAAAA,iBAAiB,EAAE;AAD+C,KAA9C,CAAtB;AAGD,GAJoB,EAIlB,EAJkB,CAArB;AAMA,QAAMC,YAAY,GAAG,wBAAaC,KAAD,IAA8B;AAC7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AAMC,MAAM,GAAG,wCACbX,SAAS,CAAClB,KADG,EAEb,CAAC,CAAD,EAAI,CAAJ,CAFa,EAGb,CAAC2B,gBAAD,EAAmB,GAAnB,CAHa,CAAf;AAKA,WAAO;AACLG,MAAAA,SAAS,EAAE,CACT;AACED,QAAAA,MAAM,EAAG,GAAEA,MAAO;AADpB,OADS;AADN,KAAP;AAOD,GAbiB,EAaf,CAACF,gBAAD,CAbe,CAAlB;AAeA,sBACE,6BAAC,6BAAD;AAAkB,IAAA,aAAa,EAAE,GAAjC;AAAsC,IAAA,OAAO,EAAE/B,QAA/C;AAAyD,IAAA,KAAK,EAAE4B;AAAhE,kBACE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEL,MAAM,CAACY;AAApB,kBACE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAACZ,MAAM,CAACa,WAAR,EAAqBP,UAArB;AAAb,KAAgDF,KAAhD,CADF,EAEGG,IAAI,iBAAI,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEE;AAAtB,KAAkCF,IAAlC,CAFX,CADF,EAKGlC,QALH,CADF;AASD;;AAED,MAAM2B,MAAM,GAAGc,wBAAWC,MAAX,CAAkB;AAC/Bd,EAAAA,OAAO,EAAE;AACPe,IAAAA,QAAQ,EAAE;AADH,GADsB;AAI/Bd,EAAAA,OAAO,EAAE,EAJsB;AAK/BU,EAAAA,eAAe,EAAE;AACfK,IAAAA,aAAa,EAAE,KADA;AAEfC,IAAAA,UAAU,EAAE;AAFG,GALc;AAS/BL,EAAAA,WAAW,EAAE;AACXM,IAAAA,IAAI,EAAE;AADK;AATkB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable react-hooks/rules-of-hooks */\nimport React, { ReactNode, useCallback, useEffect, useMemo } from 'react';\nimport {\n LayoutChangeEvent,\n StyleProp,\n StyleSheet,\n Text,\n TextStyle,\n TouchableOpacity,\n View,\n ViewStyle,\n} from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n useSharedValue,\n withSpring,\n interpolateColor,\n interpolate,\n useAnimatedReaction,\n runOnJS,\n} from 'react-native-reanimated';\n\nexport type CollapsibleHeaderProps = {\n onToggle: () => void;\n collapsed: Animated.SharedValue<number>;\n};\n\ntype Props = {\n initialState?: 'collapsed' | 'expanded';\n collapseState?: Animated.SharedValue<number>;\n renderHeader: (props: CollapsibleHeaderProps) => ReactNode;\n children: ReactNode;\n containerStyle?: StyleProp<ViewStyle>;\n collapsedBackgroundColor?: string;\n expandedBackgroundColor?: string;\n useDynamicLayout?: boolean;\n onToggle?: (isExpand: boolean) => void;\n};\n\nlet key = 0;\nexport default function CollapsibleView({\n initialState = 'collapsed',\n collapseState = useSharedValue(0),\n renderHeader,\n children,\n containerStyle,\n collapsedBackgroundColor,\n expandedBackgroundColor,\n onToggle,\n}: Props) {\n const actualHeight = useSharedValue(11110);\n const contentKey = useMemo(() => `collapsible-view-${key++}`, []);\n\n useEffect(() => {\n const newValue = initialState === 'collapsed' ? 0 : 1;\n if (newValue === collapseState.value) {\n return;\n }\n collapseState.value = newValue;\n }, [initialState]);\n\n const handleToggle = useCallback(() => {\n collapseState.value = withSpring(collapseState.value === 0 ? 1 : 0, {\n overshootClamping: true,\n });\n }, []);\n\n const handleLayout = useCallback((event: LayoutChangeEvent) => {\n if (event.nativeEvent.layout.height >= 0) {\n actualHeight.value = event.nativeEvent.layout.height;\n }\n }, []);\n\n const wrapperStyle = useAnimatedStyle(\n () => ({\n height: withSpring(collapseState.value === 1 ? actualHeight.value : 0, {\n damping: 5,\n stiffness: 130,\n overshootClamping: true,\n }),\n }),\n [actualHeight, contentKey]\n );\n\n const contentHeight = useAnimatedStyle(\n () => ({\n height: actualHeight.value > 0 ? actualHeight.value : undefined,\n }),\n [actualHeight, contentKey]\n );\n\n useAnimatedReaction(\n () => (collapseState.value === 0 ? 0 : collapseState.value === 1 ? 1 : 0),\n (result, prev) => {\n if (result === prev) {\n return;\n }\n if (onToggle) {\n runOnJS(onToggle)(result === 1);\n }\n }\n );\n\n // @ts-ignore\n const containerAnimatedStyle = useAnimatedStyle(() => {\n if (collapsedBackgroundColor && expandedBackgroundColor) {\n return {\n backgroundColor: interpolateColor(\n collapseState.value,\n [0, 1],\n [collapsedBackgroundColor, expandedBackgroundColor]\n ),\n };\n }\n return {};\n }, []);\n\n const headerProps = useMemo(\n () => ({ onToggle: handleToggle, collapsed: collapseState }),\n [handleToggle, collapseState]\n );\n\n return (\n <Animated.View\n style={[containerStyle, containerAnimatedStyle]}\n pointerEvents=\"box-none\"\n >\n <View pointerEvents=\"box-none\">{renderHeader(headerProps)}</View>\n <Animated.View\n style={[styles.wrapper, wrapperStyle]}\n pointerEvents=\"box-none\"\n >\n <Animated.View\n style={[styles.content, contentHeight]}\n pointerEvents=\"box-none\"\n >\n <View\n key={contentKey}\n onLayout={handleLayout}\n pointerEvents=\"box-none\"\n >\n {children}\n </View>\n </Animated.View>\n </Animated.View>\n </Animated.View>\n );\n}\n\nexport function CollapsibleHeaderText({\n title,\n collapsed,\n onToggle,\n style,\n titleStyle,\n icon,\n iconInitialAngle = 0,\n children,\n}: {\n title: string | Element;\n style?: StyleProp<ViewStyle>;\n titleStyle?: StyleProp<TextStyle>;\n icon?: ReactNode;\n iconInitialAngle?: number;\n children?: ReactNode;\n} & CollapsibleHeaderProps) {\n const iconStyle = useAnimatedStyle(() => {\n const rotate = interpolate(\n collapsed.value,\n [0, 1],\n [iconInitialAngle, 180]\n );\n return {\n transform: [\n {\n rotate: `${rotate}deg`,\n },\n ],\n };\n }, [iconInitialAngle]);\n\n return (\n <TouchableOpacity activeOpacity={0.9} onPress={onToggle} style={style}>\n <View style={styles.headerContainer}>\n <Text style={[styles.headerTitle, titleStyle]}>{title}</Text>\n {icon && <Animated.View style={iconStyle}>{icon}</Animated.View>}\n </View>\n {children}\n </TouchableOpacity>\n );\n}\n\nconst styles = StyleSheet.create({\n wrapper: {\n overflow: 'hidden',\n },\n content: {},\n headerContainer: {\n flexDirection: 'row',\n alignItems: 'center',\n },\n headerTitle: {\n flex: 1,\n },\n});\n"]}
|
|
@@ -35,7 +35,7 @@ function CollapsibleHeaderConsumer() {
|
|
|
35
35
|
headerHeight
|
|
36
36
|
} = (0, _useCollapsibleContext.default)();
|
|
37
37
|
const headerTranslate = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.interpolate)(scrollY.value, // FIXME: can improve by geting maxY value of header and sticky views
|
|
38
|
-
[-
|
|
38
|
+
[-1000, 0, 100000], [-1000, 0, -100000], _reactNativeReanimated.default.Extrapolate.CLAMP), []);
|
|
39
39
|
const headerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
40
40
|
return {
|
|
41
41
|
transform: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleHeaderConsumer.tsx"],"names":["CollapsibleHeaderConsumer","headers","handleHeaderContainerLayout","scrollY","headerHeight","headerTranslate","value","Animated","Extrapolate","CLAMP","headerStyle","transform","translateY","handleHeaderLayout","nativeEvent","layout","height","styles","container","map","item","children","StyleSheet","create","backgroundColor","zIndex"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAKA;;AACA;;;;;;;;AAEe,SAASA,yBAAT,GAAqC;AAClD,QAAM;AAAEC,IAAAA;AAAF,MAAc,2CAApB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAkC,6CAAxC;AACA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAA4B,qCAAlC;AAEA,QAAMC,eAAe,GAAG,4CACtB,MACE,wCACEF,OAAO,CAACG,KADV,EAEE;AACA,GAAC,CAAC,
|
|
1
|
+
{"version":3,"sources":["CollapsibleHeaderConsumer.tsx"],"names":["CollapsibleHeaderConsumer","headers","handleHeaderContainerLayout","scrollY","headerHeight","headerTranslate","value","Animated","Extrapolate","CLAMP","headerStyle","transform","translateY","handleHeaderLayout","nativeEvent","layout","height","styles","container","map","item","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BAAWC,MAAX,CAAkB;AAC/BL,EAAAA,SAAS,EAAE;AACTM,IAAAA,eAAe,EAAE,OADR;AAETC,IAAAA,MAAM,EAAE;AAFC;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useCallback } from 'react';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\nimport useCollapsibleHeaderContext from '../../hooks/useCollapsibleHeaderContext';\nimport Animated, {\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n} from 'react-native-reanimated';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport { LayoutChangeEvent, StyleSheet } from 'react-native';\n\nexport default function CollapsibleHeaderConsumer() {\n const { headers } = useCollapsibleHeaderContext();\n const { handleHeaderContainerLayout } = useInternalCollapsibleContext();\n const { scrollY, headerHeight } = useCollapsibleContext();\n\n const headerTranslate = useDerivedValue(\n () =>\n interpolate(\n scrollY.value,\n // FIXME: can improve by geting maxY value of header and sticky views\n [-1000, 0, 100000],\n [-1000, 0, -100000],\n Animated.Extrapolate.CLAMP\n ),\n []\n );\n\n const headerStyle = useAnimatedStyle(() => {\n return {\n transform: [{ translateY: headerTranslate.value }],\n };\n }, [headerHeight, headerTranslate]);\n\n const handleHeaderLayout = useCallback(\n ({\n nativeEvent: {\n layout: { height },\n },\n }: LayoutChangeEvent) => {\n handleHeaderContainerLayout(height);\n },\n [handleHeaderContainerLayout]\n );\n\n return (\n <Animated.View\n onLayout={handleHeaderLayout}\n style={[styles.container, headerStyle]}\n pointerEvents=\"box-none\"\n >\n {headers.map((item) => item.children)}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: 'white',\n zIndex: 10,\n },\n});\n"]}
|
|
@@ -7,8 +7,6 @@ exports.default = CollapsibleHeaderContainer;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _reactNative = require("react-native");
|
|
11
|
-
|
|
12
10
|
var _useCollapsibleHeaderContext = _interopRequireDefault(require("../../hooks/useCollapsibleHeaderContext"));
|
|
13
11
|
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -21,7 +19,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
19
|
let key = 0;
|
|
22
20
|
|
|
23
21
|
function CollapsibleHeaderContainer({
|
|
24
|
-
children
|
|
22
|
+
children,
|
|
23
|
+
containerStyle
|
|
25
24
|
}) {
|
|
26
25
|
const contentKey = (0, _react.useMemo)(() => `collapsible-header-${key++}`, []);
|
|
27
26
|
const {
|
|
@@ -29,18 +28,11 @@ function CollapsibleHeaderContainer({
|
|
|
29
28
|
unmount,
|
|
30
29
|
update
|
|
31
30
|
} = (0, _useCollapsibleHeaderContext.default)();
|
|
32
|
-
const internalStyle = (0, _react.useMemo)(() => {
|
|
33
|
-
return {
|
|
34
|
-
zIndex: 100000 - key
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
31
|
const content = (0, _react.useMemo)(() => {
|
|
38
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
39
|
-
key: contentKey
|
|
40
|
-
style: internalStyle,
|
|
41
|
-
pointerEvents: "box-none"
|
|
32
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
33
|
+
key: contentKey
|
|
42
34
|
}, children);
|
|
43
|
-
}, [children]);
|
|
35
|
+
}, [children, containerStyle]);
|
|
44
36
|
(0, _react.useEffect)(() => {
|
|
45
37
|
mount(contentKey, content);
|
|
46
38
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleHeaderContainer.tsx"],"names":["key","CollapsibleHeaderContainer","children","contentKey","mount","unmount","update","
|
|
1
|
+
{"version":3,"sources":["CollapsibleHeaderContainer.tsx"],"names":["key","CollapsibleHeaderContainer","children","containerStyle","contentKey","mount","unmount","update","content"],"mappings":";;;;;;;AAEA;;AACA;;;;;;;;AAHA;AAUA,IAAIA,GAAG,GAAG,CAAV;;AAEe,SAASC,0BAAT,CAAoC;AACjDC,EAAAA,QADiD;AAEjDC,EAAAA;AAFiD,CAApC,EAGL;AACR,QAAMC,UAAU,GAAG,oBAAQ,MAAO,sBAAqBJ,GAAG,EAAG,EAA1C,EAA6C,EAA7C,CAAnB;AACA,QAAM;AAAEK,IAAAA,KAAF;AAASC,IAAAA,OAAT;AAAkBC,IAAAA;AAAlB,MAA6B,2CAAnC;AAEA,QAAMC,OAAO,GAAG,oBAAQ,MAAM;AAC5B,wBAAO,6BAAC,eAAD;AAAU,MAAA,GAAG,EAAEJ;AAAf,OAA4BF,QAA5B,CAAP;AACD,GAFe,EAEb,CAACA,QAAD,EAAWC,cAAX,CAFa,CAAhB;AAIA,wBAAU,MAAM;AACdE,IAAAA,KAAK,CAACD,UAAD,EAAaI,OAAb,CAAL;AAEA,WAAO,MAAM;AACXF,MAAAA,OAAO,CAACF,UAAD,CAAP;AACD,KAFD;AAGD,GAND,EAMG,CAACA,UAAD,CANH;AAQA,wBAAU,MAAM;AACdG,IAAAA,MAAM,CAACH,UAAD,EAAaI,OAAb,CAAN;AACD,GAFD,EAEG,CAACA,OAAD,CAFH;AAIA,SAAO,IAAP;AACD","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport React, { Fragment, ReactNode, useEffect, useMemo } from 'react';\nimport useCollapsibleHeaderContext from '../../hooks/useCollapsibleHeaderContext';\n\ntype Props = {\n children: ReactNode;\n containerStyle?: StyleProp<ViewStyle>;\n};\n\nlet key = 0;\n\nexport default function CollapsibleHeaderContainer({\n children,\n containerStyle,\n}: Props) {\n const contentKey = useMemo(() => `collapsible-header-${key++}`, []);\n const { mount, unmount, update } = useCollapsibleHeaderContext();\n\n const content = useMemo(() => {\n return <Fragment key={contentKey}>{children}</Fragment>;\n }, [children, containerStyle]);\n\n useEffect(() => {\n mount(contentKey, content);\n\n return () => {\n unmount(contentKey);\n };\n }, [contentKey]);\n\n useEffect(() => {\n update(contentKey, content);\n }, [content]);\n\n return null;\n}\n"]}
|
|
@@ -72,7 +72,8 @@ function StickyView({
|
|
|
72
72
|
const styles = _reactNative.StyleSheet.create({
|
|
73
73
|
container: {
|
|
74
74
|
backgroundColor: 'white',
|
|
75
|
-
zIndex: 10
|
|
75
|
+
zIndex: 10,
|
|
76
|
+
marginTop: _reactNative.Platform.OS === 'android' ? -1 : 0
|
|
76
77
|
}
|
|
77
78
|
});
|
|
78
79
|
//# sourceMappingURL=StickyView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["StickyView.tsx"],"names":["stickyKey","StickyView","children","style","key","viewRef","handleStickyViewLayout","stickyViewTops","stickyViewPositions","scrollY","undefined","handleLayout","translateY","top","value","layoutValues","inputMid","Extrapolate","CLAMP","animatedStyle","transform","styles","container","StyleSheet","create","backgroundColor","zIndex"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AALA;AAiBA,IAAIA,SAAS,GAAG,CAAhB;;AAEe,SAASC,UAAT,CAAoB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAApB,EAAgD;AAC7D,QAAMC,GAAG,GAAG,oBAAQ,MAAO,UAASJ,SAAS,EAAG,EAApC,EAAuC,EAAvC,CAAZ;AACA,QAAMK,OAAO,GAAG,mBAAa,IAAb,CAAhB;AACA,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA,cAA1B;AAA0CC,IAAAA;AAA1C,MACJ,6CADF;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAc,qCAApB;AAEA,wBAAU,MAAM;AACd,WAAO,MAAMH,sBAAsB,CAACF,GAAD,EAAMM,SAAN,CAAnC;AACD,GAFD,EAEG,EAFH;AAIA,QAAMC,YAAY,GAAG,wBAAY,MAAM;AACrCL,IAAAA,sBAAsB,CAACF,GAAD,EAAMC,OAAN,CAAtB;AACD,GAFoB,EAElB,CAACD,GAAD,CAFkB,CAArB;AAIA,QAAMQ,UAAU,GAAG,4CAAgB,MAAM;AACvC,UAAMC,GAAG,GAAGN,cAAc,CAACO,KAAf,CAAqBV,GAArB,KAA6B,CAAzC;AACA,UAAMW,YAAY,GAAGP,mBAAmB,CAACM,KAApB,CAA0BV,GAA1B,KAAkC;AAAES,MAAAA,GAAG,EAAE;AAAP,KAAvD;AACA,UAAMG,QAAQ,GAAGD,YAAY,CAACF,GAAb,GAAmBA,GAApC;AACA,WAAO,wCACLJ,OAAO,CAACK,KADH,EAEL,CAAC,CAAD,EAAIE,QAAJ,EAAcA,QAAQ,GAAG,MAAzB,CAFK,EAGL,CAAC,CAAD,EAAI,CAAJ,EAAO,MAAP,CAHK,EAILC,mCAAYC,KAJP,CAAP;AAMD,GAVkB,EAUhB,EAVgB,CAAnB;AAYA,QAAMC,aAAa,GAAG,6CAAiB,MAAM;AAC3C,WAAO;AACLC,MAAAA,SAAS,EAAE,CACT;AACER,QAAAA,UAAU,EAAEA,UAAU,CAACE;AADzB,OADS;AADN,KAAP;AAOD,GARqB,EAQnB,EARmB,CAAtB;AAUA,sBACE,6BAAC,8BAAD,CAAU,IAAV;AACE,IAAA,GAAG,EAAEV,GADP,CAEE;AAFF;AAGE,IAAA,GAAG,EAAEC,OAHP;AAIE,IAAA,QAAQ,EAAEM,YAJZ;AAKE,IAAA,KAAK,EAAE,CAACU,MAAM,CAACC,SAAR,EAAmBH,aAAnB,EAAkChB,KAAlC,CALT;AAME,IAAA,aAAa,EAAC;AANhB,KAQGD,QARH,CADF;AAYD;;AAED,MAAMmB,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,eAAe,EAAE,OADR;AAETC,IAAAA,MAAM,EAAE;
|
|
1
|
+
{"version":3,"sources":["StickyView.tsx"],"names":["stickyKey","StickyView","children","style","key","viewRef","handleStickyViewLayout","stickyViewTops","stickyViewPositions","scrollY","undefined","handleLayout","translateY","top","value","layoutValues","inputMid","Extrapolate","CLAMP","animatedStyle","transform","styles","container","StyleSheet","create","backgroundColor","zIndex","marginTop","Platform","OS"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AALA;AAiBA,IAAIA,SAAS,GAAG,CAAhB;;AAEe,SAASC,UAAT,CAAoB;AAAEC,EAAAA,QAAF;AAAYC,EAAAA;AAAZ,CAApB,EAAgD;AAC7D,QAAMC,GAAG,GAAG,oBAAQ,MAAO,UAASJ,SAAS,EAAG,EAApC,EAAuC,EAAvC,CAAZ;AACA,QAAMK,OAAO,GAAG,mBAAa,IAAb,CAAhB;AACA,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA,cAA1B;AAA0CC,IAAAA;AAA1C,MACJ,6CADF;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAc,qCAApB;AAEA,wBAAU,MAAM;AACd,WAAO,MAAMH,sBAAsB,CAACF,GAAD,EAAMM,SAAN,CAAnC;AACD,GAFD,EAEG,EAFH;AAIA,QAAMC,YAAY,GAAG,wBAAY,MAAM;AACrCL,IAAAA,sBAAsB,CAACF,GAAD,EAAMC,OAAN,CAAtB;AACD,GAFoB,EAElB,CAACD,GAAD,CAFkB,CAArB;AAIA,QAAMQ,UAAU,GAAG,4CAAgB,MAAM;AACvC,UAAMC,GAAG,GAAGN,cAAc,CAACO,KAAf,CAAqBV,GAArB,KAA6B,CAAzC;AACA,UAAMW,YAAY,GAAGP,mBAAmB,CAACM,KAApB,CAA0BV,GAA1B,KAAkC;AAAES,MAAAA,GAAG,EAAE;AAAP,KAAvD;AACA,UAAMG,QAAQ,GAAGD,YAAY,CAACF,GAAb,GAAmBA,GAApC;AACA,WAAO,wCACLJ,OAAO,CAACK,KADH,EAEL,CAAC,CAAD,EAAIE,QAAJ,EAAcA,QAAQ,GAAG,MAAzB,CAFK,EAGL,CAAC,CAAD,EAAI,CAAJ,EAAO,MAAP,CAHK,EAILC,mCAAYC,KAJP,CAAP;AAMD,GAVkB,EAUhB,EAVgB,CAAnB;AAYA,QAAMC,aAAa,GAAG,6CAAiB,MAAM;AAC3C,WAAO;AACLC,MAAAA,SAAS,EAAE,CACT;AACER,QAAAA,UAAU,EAAEA,UAAU,CAACE;AADzB,OADS;AADN,KAAP;AAOD,GARqB,EAQnB,EARmB,CAAtB;AAUA,sBACE,6BAAC,8BAAD,CAAU,IAAV;AACE,IAAA,GAAG,EAAEV,GADP,CAEE;AAFF;AAGE,IAAA,GAAG,EAAEC,OAHP;AAIE,IAAA,QAAQ,EAAEM,YAJZ;AAKE,IAAA,KAAK,EAAE,CAACU,MAAM,CAACC,SAAR,EAAmBH,aAAnB,EAAkChB,KAAlC,CALT;AAME,IAAA,aAAa,EAAC;AANhB,KAQGD,QARH,CADF;AAYD;;AAED,MAAMmB,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,SAAS,EAAE;AACTG,IAAAA,eAAe,EAAE,OADR;AAETC,IAAAA,MAAM,EAAE,EAFC;AAGTC,IAAAA,SAAS,EAAEC,sBAASC,EAAT,KAAgB,SAAhB,GAA4B,CAAC,CAA7B,GAAiC;AAHnC;AADoB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react';\nimport { Platform, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\nimport Animated, {\n Extrapolate,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n} from 'react-native-reanimated';\n\ntype Props = {\n style?: StyleProp<ViewStyle>;\n children: Element;\n};\n\nlet stickyKey = 0;\n\nexport default function StickyView({ children, style }: Props) {\n const key = useMemo(() => `sticky_${stickyKey++}`, []);\n const viewRef = useRef<View>(null);\n const { handleStickyViewLayout, stickyViewTops, stickyViewPositions } =\n useInternalCollapsibleContext();\n const { scrollY } = useCollapsibleContext();\n\n useEffect(() => {\n return () => handleStickyViewLayout(key, undefined);\n }, []);\n\n const handleLayout = useCallback(() => {\n handleStickyViewLayout(key, viewRef);\n }, [key]);\n\n const translateY = useDerivedValue(() => {\n const top = stickyViewTops.value[key] || 0;\n const layoutValues = stickyViewPositions.value[key] || { top: 0 };\n const inputMid = layoutValues.top - top;\n return interpolate(\n scrollY.value,\n [0, inputMid, inputMid + 100000],\n [0, 0, 100000],\n Extrapolate.CLAMP\n );\n }, []);\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n transform: [\n {\n translateY: translateY.value,\n },\n ],\n };\n }, []);\n\n return (\n <Animated.View\n key={key}\n // @ts-ignore\n ref={viewRef}\n onLayout={handleLayout}\n style={[styles.container, animatedStyle, style]}\n pointerEvents=\"box-none\"\n >\n {children}\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n backgroundColor: 'white',\n zIndex: 10,\n marginTop: Platform.OS === 'android' ? -1 : 0,\n },\n});\n"]}
|
|
@@ -11,15 +11,11 @@ var _reactNative = require("react-native");
|
|
|
11
11
|
|
|
12
12
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
13
13
|
|
|
14
|
-
var _AnimatedTopView = _interopRequireDefault(require("../header/AnimatedTopView"));
|
|
15
|
-
|
|
16
14
|
var _useAnimatedScroll = _interopRequireDefault(require("./useAnimatedScroll"));
|
|
17
15
|
|
|
18
|
-
var _useCollapsibleContext = _interopRequireDefault(require("../../hooks/useCollapsibleContext"));
|
|
19
|
-
|
|
20
16
|
var _useInternalCollapsibleContext = _interopRequireDefault(require("../../hooks/useInternalCollapsibleContext"));
|
|
21
17
|
|
|
22
|
-
var
|
|
18
|
+
var _CollapsibleHeaderConsumer = _interopRequireDefault(require("../header/CollapsibleHeaderConsumer"));
|
|
23
19
|
|
|
24
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
21
|
|
|
@@ -35,16 +31,15 @@ function CollapsibleFlatList({
|
|
|
35
31
|
headerSnappable = true,
|
|
36
32
|
...props
|
|
37
33
|
}) {
|
|
38
|
-
const {
|
|
39
|
-
headerHeight,
|
|
40
|
-
scrollY
|
|
41
|
-
} = (0, _useCollapsibleContext.default)();
|
|
42
34
|
const {
|
|
43
35
|
contentMinHeight,
|
|
44
|
-
scrollViewRef
|
|
36
|
+
scrollViewRef,
|
|
37
|
+
fixedHeaderHeight
|
|
45
38
|
} = (0, _useInternalCollapsibleContext.default)();
|
|
46
39
|
const mounted = (0, _react.useRef)(true);
|
|
47
40
|
const contentHeight = (0, _react.useRef)(0);
|
|
41
|
+
const [internalContentMinHeight, setInternalContentMinHeight] = (0, _react.useState)(contentMinHeight.value);
|
|
42
|
+
const [internalProgressViewOffset, setInternalProgressViewOffset] = (0, _react.useState)(0);
|
|
48
43
|
(0, _react.useEffect)(() => {
|
|
49
44
|
return () => {
|
|
50
45
|
mounted.current = false;
|
|
@@ -63,11 +58,6 @@ function CollapsibleFlatList({
|
|
|
63
58
|
|
|
64
59
|
(_scrollViewRef$curren2 = scrollViewRef.current) === null || _scrollViewRef$curren2 === void 0 ? void 0 : _scrollViewRef$curren2.scrollToIndex(params);
|
|
65
60
|
}, []);
|
|
66
|
-
const handleInternalContentHeight = (0, _react.useCallback)(value => {
|
|
67
|
-
if (mounted.current) {
|
|
68
|
-
setInternalContentMinHeight(value);
|
|
69
|
-
}
|
|
70
|
-
}, []);
|
|
71
61
|
const {
|
|
72
62
|
scrollHandler
|
|
73
63
|
} = (0, _useAnimatedScroll.default)({
|
|
@@ -75,16 +65,32 @@ function CollapsibleFlatList({
|
|
|
75
65
|
scrollTo,
|
|
76
66
|
scrollToIndex
|
|
77
67
|
});
|
|
78
|
-
const
|
|
68
|
+
const handleInternalContentHeight = (0, _react.useCallback)(value => {
|
|
69
|
+
if (mounted.current) {
|
|
70
|
+
setInternalContentMinHeight(value);
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
const handleInternalProgressViewOffset = (0, _react.useCallback)(value => {
|
|
74
|
+
if (mounted.current) {
|
|
75
|
+
setInternalProgressViewOffset(value);
|
|
76
|
+
}
|
|
77
|
+
}, []);
|
|
79
78
|
(0, _reactNativeReanimated.useAnimatedReaction)(() => {
|
|
80
79
|
return contentMinHeight.value;
|
|
81
80
|
}, (result, previous) => {
|
|
82
81
|
if (result !== previous) {
|
|
83
|
-
if (contentHeight.current <
|
|
84
|
-
(0, _reactNativeReanimated.runOnJS)(handleInternalContentHeight)(
|
|
82
|
+
if (contentHeight.current < result && internalContentMinHeight !== result) {
|
|
83
|
+
(0, _reactNativeReanimated.runOnJS)(handleInternalContentHeight)(result);
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
});
|
|
87
|
+
(0, _reactNativeReanimated.useAnimatedReaction)(() => {
|
|
88
|
+
return fixedHeaderHeight.value;
|
|
89
|
+
}, (result, previous) => {
|
|
90
|
+
if (result !== previous) {
|
|
91
|
+
(0, _reactNativeReanimated.runOnJS)(handleInternalProgressViewOffset)(result);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
88
94
|
const contentContainerStyle = (0, _react.useMemo)(() => [styles.contentContainer, {
|
|
89
95
|
minHeight: internalContentMinHeight
|
|
90
96
|
}, props.contentContainerStyle], [props.contentContainerStyle, internalContentMinHeight]);
|
|
@@ -93,15 +99,13 @@ function CollapsibleFlatList({
|
|
|
93
99
|
}, []);
|
|
94
100
|
const handleScrollToIndexFailed = (0, _react.useCallback)(() => {}, []);
|
|
95
101
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
102
|
+
function renderListHeader() {
|
|
103
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_CollapsibleHeaderConsumer.default, null), props.ListHeaderComponent);
|
|
104
|
+
}
|
|
99
105
|
|
|
100
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
ref: scrollViewRef,
|
|
104
|
-
bounces: false,
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement(AnimatedFlatList, _extends({
|
|
107
|
+
ref: scrollViewRef // bounces={false}
|
|
108
|
+
,
|
|
105
109
|
keyboardDismissMode: "on-drag",
|
|
106
110
|
keyboardShouldPersistTaps: "handled",
|
|
107
111
|
scrollEventThrottle: 1,
|
|
@@ -111,8 +115,12 @@ function CollapsibleFlatList({
|
|
|
111
115
|
contentContainerStyle: contentContainerStyle,
|
|
112
116
|
onScroll: scrollHandler,
|
|
113
117
|
ListHeaderComponent: renderListHeader(),
|
|
114
|
-
onContentSizeChange: handleContentSizeChange
|
|
115
|
-
|
|
118
|
+
onContentSizeChange: handleContentSizeChange //@ts-ignore
|
|
119
|
+
,
|
|
120
|
+
simultaneousHandlers: [],
|
|
121
|
+
stickyHeaderIndices: [0],
|
|
122
|
+
progressViewOffset: internalProgressViewOffset
|
|
123
|
+
}));
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleFlatList.tsx"],"names":["AnimatedFlatList","Animated","createAnimatedComponent","FlatList","CollapsibleFlatList","headerSnappable","props","
|
|
1
|
+
{"version":3,"sources":["CollapsibleFlatList.tsx"],"names":["AnimatedFlatList","Animated","createAnimatedComponent","FlatList","CollapsibleFlatList","headerSnappable","props","contentMinHeight","scrollViewRef","fixedHeaderHeight","mounted","contentHeight","internalContentMinHeight","setInternalContentMinHeight","value","internalProgressViewOffset","setInternalProgressViewOffset","current","scrollTo","yValue","animated","scrollToOffset","offset","scrollToIndex","params","scrollHandler","handleInternalContentHeight","handleInternalProgressViewOffset","result","previous","contentContainerStyle","styles","contentContainer","minHeight","handleContentSizeChange","_","height","handleScrollToIndexFailed","renderListHeader","ListHeaderComponent","container","style","StyleSheet","create","absoluteFillObject","flexGrow","topView","position","top","left","right"],"mappings":";;;;;;;AACA;;AAOA;;AACA;;AAIA;;AACA;;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BACE,6BAAC,kCAAD,OADF,EAEGhC,KAAK,CAACiC,mBAFT,CADF;AAMD;;AAED,sBACE,6BAAC,gBAAD;AACE,IAAA,GAAG,EAAE/B,aADP,CAEE;AAFF;AAGE,IAAA,mBAAmB,EAAC,SAHtB;AAIE,IAAA,yBAAyB,EAAC,SAJ5B;AAKE,IAAA,mBAAmB,EAAE,CALvB;AAME,IAAA,qBAAqB,EAAE6B;AANzB,KAOM/B,KAPN;AAQE,IAAA,KAAK,EAAE,CAACyB,MAAM,CAACS,SAAR,EAAmBlC,KAAK,CAACmC,KAAzB,CART;AASE,IAAA,qBAAqB,EAAEX,qBATzB;AAUE,IAAA,QAAQ,EAAEL,aAVZ;AAWE,IAAA,mBAAmB,EAAEa,gBAAgB,EAXvC;AAYE,IAAA,mBAAmB,EAAEJ,uBAZvB,CAaE;AAbF;AAcE,IAAA,oBAAoB,EAAE,EAdxB;AAeE,IAAA,mBAAmB,EAAE,CAAC,CAAD,CAfvB;AAgBE,IAAA,kBAAkB,EAAEnB;AAhBtB,KADF;AAoBD;;AAED,MAAMgB,MAAM,GAAGW,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE,EACT,GAAGE,wBAAWE;AADL,GADoB;AAI/BZ,EAAAA,gBAAgB,EAAE;AAChBa,IAAAA,QAAQ,EAAE;AADM,GAJa;AAO/BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,QAAQ,EAAE,UADH;AAEPC,IAAAA,GAAG,EAAE,CAFE;AAGPC,IAAAA,IAAI,EAAE,CAHC;AAIPC,IAAAA,KAAK,EAAE;AAJA;AAPsB,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { FlatListProps, View, StyleSheet, FlatList } from 'react-native';\nimport Animated, {\n runOnJS,\n useAnimatedReaction,\n} from 'react-native-reanimated';\nimport useAnimatedScroll from './useAnimatedScroll';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\nimport type { CollapsibleProps } from '../../types';\nimport CollapsibleHeaderConsumer from '../header/CollapsibleHeaderConsumer';\n\nconst AnimatedFlatList = Animated.createAnimatedComponent(FlatList);\n\ntype Props<Data> = Omit<FlatListProps<Data>, 'scrollEnabled'> &\n CollapsibleProps;\n\nexport default function CollapsibleFlatList<Data>({\n headerSnappable = true,\n ...props\n}: Props<Data>) {\n const { contentMinHeight, scrollViewRef, fixedHeaderHeight } =\n useInternalCollapsibleContext();\n const mounted = useRef(true);\n const contentHeight = useRef(0);\n const [internalContentMinHeight, setInternalContentMinHeight] = useState(\n contentMinHeight.value\n );\n const [internalProgressViewOffset, setInternalProgressViewOffset] =\n useState(0);\n\n useEffect(() => {\n return () => {\n mounted.current = false;\n };\n }, []);\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n scrollViewRef.current?.scrollToOffset({\n offset: yValue,\n animated,\n });\n }, []);\n\n const scrollToIndex = useCallback((params) => {\n scrollViewRef.current?.scrollToIndex(params);\n }, []);\n\n const { scrollHandler } = useAnimatedScroll({\n headerSnappable,\n scrollTo,\n scrollToIndex,\n });\n\n const handleInternalContentHeight = useCallback((value: number) => {\n if (mounted.current) {\n setInternalContentMinHeight(value);\n }\n }, []);\n\n const handleInternalProgressViewOffset = useCallback((value: number) => {\n if (mounted.current) {\n setInternalProgressViewOffset(value);\n }\n }, []);\n\n useAnimatedReaction(\n () => {\n return contentMinHeight.value;\n },\n (result, previous) => {\n if (result !== previous) {\n if (\n contentHeight.current < result &&\n internalContentMinHeight !== result\n ) {\n runOnJS(handleInternalContentHeight)(result);\n }\n }\n }\n );\n\n useAnimatedReaction(\n () => {\n return fixedHeaderHeight.value;\n },\n (result, previous) => {\n if (result !== previous) {\n runOnJS(handleInternalProgressViewOffset)(result);\n }\n }\n );\n\n const contentContainerStyle = useMemo(\n () => [\n styles.contentContainer,\n { minHeight: internalContentMinHeight },\n props.contentContainerStyle,\n ],\n [props.contentContainerStyle, internalContentMinHeight]\n );\n\n const handleContentSizeChange = useCallback((_, height) => {\n contentHeight.current = height;\n }, []);\n\n const handleScrollToIndexFailed = useCallback(() => {}, []);\n\n function renderListHeader() {\n return (\n <View>\n <CollapsibleHeaderConsumer />\n {props.ListHeaderComponent}\n </View>\n );\n }\n\n return (\n <AnimatedFlatList\n ref={scrollViewRef}\n // bounces={false}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={1}\n onScrollToIndexFailed={handleScrollToIndexFailed}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n ListHeaderComponent={renderListHeader()}\n onContentSizeChange={handleContentSizeChange}\n //@ts-ignore\n simultaneousHandlers={[]}\n stickyHeaderIndices={[0]}\n progressViewOffset={internalProgressViewOffset}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n ...StyleSheet.absoluteFillObject,\n },\n contentContainer: {\n flexGrow: 1,\n },\n topView: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n },\n});\n"]}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = CollapsibleScrollView;
|
|
7
7
|
|
|
8
|
-
var _AnimatedTopView = _interopRequireDefault(require("../header/AnimatedTopView"));
|
|
9
|
-
|
|
10
8
|
var _useAnimatedScroll = _interopRequireDefault(require("./useAnimatedScroll"));
|
|
11
9
|
|
|
12
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -15,10 +13,10 @@ var _reactNative = require("react-native");
|
|
|
15
13
|
|
|
16
14
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
17
15
|
|
|
18
|
-
var _useCollapsibleContext = _interopRequireDefault(require("../../hooks/useCollapsibleContext"));
|
|
19
|
-
|
|
20
16
|
var _useInternalCollapsibleContext = _interopRequireDefault(require("../../hooks/useInternalCollapsibleContext"));
|
|
21
17
|
|
|
18
|
+
var _CollapsibleHeaderConsumer = _interopRequireDefault(require("../header/CollapsibleHeaderConsumer"));
|
|
19
|
+
|
|
22
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
21
|
|
|
24
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -36,9 +34,6 @@ function CollapsibleScrollView({
|
|
|
36
34
|
contentMinHeight,
|
|
37
35
|
scrollViewRef
|
|
38
36
|
} = (0, _useInternalCollapsibleContext.default)();
|
|
39
|
-
const {
|
|
40
|
-
headerHeight
|
|
41
|
-
} = (0, _useCollapsibleContext.default)();
|
|
42
37
|
const scrollTo = (0, _react.useCallback)((yValue, animated = true) => {
|
|
43
38
|
var _scrollViewRef$curren;
|
|
44
39
|
|
|
@@ -64,20 +59,18 @@ function CollapsibleScrollView({
|
|
|
64
59
|
}, []);
|
|
65
60
|
const contentContainerStyle = (0, _react.useMemo)(() => [styles.contentContainer, props.contentContainerStyle], [props.contentContainerStyle]);
|
|
66
61
|
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.ScrollView, _extends({
|
|
67
|
-
ref: scrollViewRef
|
|
68
|
-
bounces: false
|
|
62
|
+
ref: scrollViewRef
|
|
69
63
|
}, props, {
|
|
70
64
|
style: [styles.container, props.style],
|
|
71
65
|
contentContainerStyle: contentContainerStyle,
|
|
72
66
|
onScroll: scrollHandler,
|
|
73
67
|
keyboardDismissMode: "on-drag",
|
|
74
68
|
keyboardShouldPersistTaps: "handled",
|
|
75
|
-
scrollEventThrottle: 1
|
|
76
|
-
|
|
69
|
+
scrollEventThrottle: 1,
|
|
70
|
+
stickyHeaderIndices: [0]
|
|
71
|
+
}), /*#__PURE__*/_react.default.createElement(_CollapsibleHeaderConsumer.default, null), /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
77
72
|
style: animatedStyle
|
|
78
|
-
},
|
|
79
|
-
height: headerHeight
|
|
80
|
-
}), children));
|
|
73
|
+
}, children));
|
|
81
74
|
}
|
|
82
75
|
|
|
83
76
|
const styles = _reactNative.StyleSheet.create({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CollapsibleScrollView.tsx"],"names":["CollapsibleScrollView","headerSnappable","children","props","contentMinHeight","scrollViewRef","
|
|
1
|
+
{"version":3,"sources":["CollapsibleScrollView.tsx"],"names":["CollapsibleScrollView","headerSnappable","children","props","contentMinHeight","scrollViewRef","scrollTo","yValue","animated","current","y","scrollToIndex","console","warn","scrollHandler","animatedStyle","minHeight","value","contentContainerStyle","styles","contentContainer","container","style","StyleSheet","create","absoluteFillObject","flexGrow"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAOe,SAASA,qBAAT,CAA+B;AAC5CC,EAAAA,eAAe,GAAG,IAD0B;AAE5CC,EAAAA,QAF4C;AAG5C,KAAGC;AAHyC,CAA/B,EAIL;AACR,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAsC,6CAA5C;AAEA,QAAMC,QAAQ,GAAG,wBAAY,CAACC,MAAD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AAgBD;;AAED,MAAMiB,MAAM,GAAGI,wBAAWC,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE,EACT,GAAGE,wBAAWE;AADL,GADoB;AAI/BL,EAAAA,gBAAgB,EAAE;AAChBM,IAAAA,QAAQ,EAAE;AADM;AAJa,CAAlB,CAAf","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport useAnimatedScroll from './useAnimatedScroll';\nimport React, { ReactNode, useCallback, useMemo } from 'react';\nimport { ScrollViewProps, StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport type { CollapsibleProps } from '../../types';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\nimport CollapsibleHeaderConsumer from '../header/CollapsibleHeaderConsumer';\n\ntype Props = ScrollViewProps &\n CollapsibleProps & {\n children?: ReactNode;\n };\n\nexport default function CollapsibleScrollView({\n headerSnappable = true,\n children,\n ...props\n}: Props) {\n const { contentMinHeight, scrollViewRef } = useInternalCollapsibleContext();\n\n const scrollTo = useCallback((yValue: number, animated = true) => {\n scrollViewRef.current?.scrollTo({ y: yValue, animated });\n }, []);\n\n const scrollToIndex = useCallback(() => {\n console.warn(\"CollapsibleScrollView doesn't support scrollToIndex\");\n }, []);\n\n const { scrollHandler } = useAnimatedScroll({\n headerSnappable,\n scrollTo,\n scrollToIndex,\n });\n\n const animatedStyle = useAnimatedStyle(() => {\n return {\n minHeight: contentMinHeight.value,\n };\n }, []);\n\n const contentContainerStyle = useMemo(\n () => [styles.contentContainer, props.contentContainerStyle],\n [props.contentContainerStyle]\n );\n\n return (\n <Animated.ScrollView\n ref={scrollViewRef}\n {...props}\n style={[styles.container, props.style]}\n contentContainerStyle={contentContainerStyle}\n onScroll={scrollHandler}\n keyboardDismissMode=\"on-drag\"\n keyboardShouldPersistTaps=\"handled\"\n scrollEventThrottle={1}\n stickyHeaderIndices={[0]}\n >\n <CollapsibleHeaderConsumer />\n <Animated.View style={animatedStyle}>{children}</Animated.View>\n </Animated.ScrollView>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n ...StyleSheet.absoluteFillObject,\n },\n contentContainer: {\n flexGrow: 1,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useAnimatedScroll.ts"],"names":["height","wHeight","Dimensions","get","useAnimatedScroll","headerSnappable","scrollTo","scrollToIndex","scrollDirection","scrollY","setCollapsibleHandlers","firstStickyViewY","fixedHeaderHeight","value","requestAnimationFrame","collapse","animated","Math","min","expand","scrollHandler","onScroll","event","offset","contentOffset","y","diff","onEndDrag","maxY","delta","abs","yValue"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AAMA;;AACA;;;;AAVA;AAYA,MAAM;AAAEA,EAAAA,MAAM,EAAEC;AAAV,IAAsBC,wBAAWC,GAAX,CAAe,QAAf,CAA5B;;AAQe,SAASC,iBAAT,CAA2B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA,QAFwC;AAGxCC,EAAAA;AAHwC,CAA3B,EAIL;AACR,QAAMC,eAAe,GAAG,2CAAe,SAAf,CAAxB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAc,qCAApB;AACA,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA,gBAA1B;AAA4CC,IAAAA;AAA5C,MACJ,6CADF;AAGA,wBAAU,MAAM;AACd,QAAIH,OAAO,CAACI,KAAR,GAAgB,CAApB,EAAuB;AACrBC,MAAAA,qBAAqB,CAAC,MAAMR,QAAQ,CAACG,OAAO,CAACI,KAAT,EAAgB,KAAhB,CAAf,CAArB;AACD;AACF,GAJD,EAIG,EAJH;AAMA,QAAME,QAAQ,GAAG,wBACf,CAACC,QAAQ,GAAG,IAAZ,KAAqB;AACnBV,IAAAA,QAAQ,CACNW,IAAI,CAACC,GAAL,CAASN,iBAAiB,CAACC,KAAlB,IAA2B,CAApC,EAAuCF,gBAAgB,CAACE,KAAjB,IAA0B,CAAjE,CADM,EAENG,QAFM,CAAR;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vB,eAAe,CAACK,KAAhB,KAA0B,IAA9B,EAAoC;AAClCkB,YAAAA,MAAM,GAAGH,IAAT;AACD;;AACD,8CAAQtB,QAAR,EAAkByB,MAAlB;AACD;AACF;AACF;AAxBH,GADoB,EA2BpB,CAACzB,QAAD,CA3BoB,CAAtB;AA8BA,SAAO;AACLc,IAAAA,aADK;AAELL,IAAAA,QAFK;AAGLI,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect } from 'react';\nimport { Dimensions } from 'react-native';\nimport {\n runOnJS,\n useAnimatedScrollHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport type { ScrollToIndexParams } from '
|
|
1
|
+
{"version":3,"sources":["useAnimatedScroll.ts"],"names":["height","wHeight","Dimensions","get","useAnimatedScroll","headerSnappable","scrollTo","scrollToIndex","scrollDirection","scrollY","setCollapsibleHandlers","firstStickyViewY","fixedHeaderHeight","value","requestAnimationFrame","collapse","animated","Math","min","expand","scrollHandler","onScroll","event","offset","contentOffset","y","diff","onEndDrag","maxY","delta","abs","yValue"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AAMA;;AACA;;;;AAVA;AAYA,MAAM;AAAEA,EAAAA,MAAM,EAAEC;AAAV,IAAsBC,wBAAWC,GAAX,CAAe,QAAf,CAA5B;;AAQe,SAASC,iBAAT,CAA2B;AACxCC,EAAAA,eADwC;AAExCC,EAAAA,QAFwC;AAGxCC,EAAAA;AAHwC,CAA3B,EAIL;AACR,QAAMC,eAAe,GAAG,2CAAe,SAAf,CAAxB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAc,qCAApB;AACA,QAAM;AAAEC,IAAAA,sBAAF;AAA0BC,IAAAA,gBAA1B;AAA4CC,IAAAA;AAA5C,MACJ,6CADF;AAGA,wBAAU,MAAM;AACd,QAAIH,OAAO,CAACI,KAAR,GAAgB,CAApB,EAAuB;AACrBC,MAAAA,qBAAqB,CAAC,MAAMR,QAAQ,CAAC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KADrB,GAEID,iBAAiB,CAACC,KAAlB,IAA2B,CAHjC;;AAKA,UAAIJ,OAAO,CAACI,KAAR,GAAgBe,IAApB,EAA0B;AACxB,cAAMC,KAAK,GAAGZ,IAAI,CAACa,GAAL,CAASrB,OAAO,CAACI,KAAR,GAAgBe,IAAzB,CAAd;;AACA,YAAIC,KAAK,GAAG5B,OAAO,GAAG,CAAtB,EAAyB;AACvB,cAAI8B,MAAM,GAAG,CAAb;;AACA,cAAIvB,eAAe,CAACK,KAAhB,KAA0B,IAA9B,EAAoC;AAClCkB,YAAAA,MAAM,GAAGH,IAAT;AACD;;AACD,8CAAQtB,QAAR,EAAkByB,MAAlB;AACD;AACF;AACF;AAxBH,GADoB,EA2BpB,CAACzB,QAAD,CA3BoB,CAAtB;AA8BA,SAAO;AACLc,IAAAA,aADK;AAELL,IAAAA,QAFK;AAGLI,IAAAA;AAHK,GAAP;AAKD","sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect } from 'react';\nimport { Dimensions } from 'react-native';\nimport {\n runOnJS,\n useAnimatedScrollHandler,\n useSharedValue,\n} from 'react-native-reanimated';\nimport type { ScrollToIndexParams } from '../../types';\nimport useCollapsibleContext from '../../hooks/useCollapsibleContext';\nimport useInternalCollapsibleContext from '../../hooks/useInternalCollapsibleContext';\n\nconst { height: wHeight } = Dimensions.get('window');\n\ntype Props = {\n headerSnappable: boolean;\n scrollTo: (yValue: number, animated?: boolean) => void;\n scrollToIndex: (params: ScrollToIndexParams) => void;\n};\n\nexport default function useAnimatedScroll({\n headerSnappable,\n scrollTo,\n scrollToIndex,\n}: Props) {\n const scrollDirection = useSharedValue('unknown');\n const { scrollY } = useCollapsibleContext();\n const { setCollapsibleHandlers, firstStickyViewY, fixedHeaderHeight } =\n useInternalCollapsibleContext();\n\n useEffect(() => {\n if (scrollY.value > 0) {\n requestAnimationFrame(() => scrollTo(scrollY.value, false));\n }\n }, []);\n\n const collapse = useCallback(\n (animated = true) => {\n scrollTo(\n Math.min(fixedHeaderHeight.value || 0, firstStickyViewY.value || 0),\n animated\n );\n },\n [scrollTo]\n );\n\n const expand = useCallback(() => scrollTo(0), [scrollTo]);\n\n useEffect(() => {\n setCollapsibleHandlers({\n collapse,\n expand,\n scrollTo,\n scrollToIndex,\n });\n }, [setCollapsibleHandlers, collapse, expand, scrollTo, scrollToIndex]);\n\n const scrollHandler = useAnimatedScrollHandler(\n {\n onScroll: (event) => {\n const offset = event.contentOffset.y;\n const diff = scrollY.value - offset;\n scrollDirection.value = diff > 0 ? 'down' : diff < 0 ? 'up' : 'unknown';\n scrollY.value = offset;\n },\n onEndDrag: () => {\n if (!headerSnappable) return;\n const maxY =\n firstStickyViewY.value && firstStickyViewY.value > 0\n ? firstStickyViewY.value\n : fixedHeaderHeight.value || 0;\n\n if (scrollY.value < maxY) {\n const delta = Math.abs(scrollY.value - maxY);\n if (delta < wHeight / 2) {\n let yValue = 0;\n if (scrollDirection.value === 'up') {\n yValue = maxY;\n }\n runOnJS(scrollTo)(yValue);\n }\n }\n },\n },\n [scrollTo]\n );\n\n return {\n scrollHandler,\n collapse,\n expand,\n };\n}\n"]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -11,7 +11,6 @@ var _exportNames = {
|
|
|
11
11
|
CollapsibleScrollView: true,
|
|
12
12
|
CollapsibleHeaderContainer: true,
|
|
13
13
|
StickyView: true,
|
|
14
|
-
RefreshControl: true,
|
|
15
14
|
CollapsibleView: true
|
|
16
15
|
};
|
|
17
16
|
Object.defineProperty(exports, "withCollapsibleContext", {
|
|
@@ -56,12 +55,6 @@ Object.defineProperty(exports, "StickyView", {
|
|
|
56
55
|
return _StickyView.default;
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
|
-
Object.defineProperty(exports, "RefreshControl", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function () {
|
|
62
|
-
return _RefreshControl.default;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
58
|
Object.defineProperty(exports, "CollapsibleView", {
|
|
66
59
|
enumerable: true,
|
|
67
60
|
get: function () {
|
|
@@ -83,8 +76,6 @@ var _CollapsibleHeaderContainer = _interopRequireDefault(require("./components/h
|
|
|
83
76
|
|
|
84
77
|
var _StickyView = _interopRequireDefault(require("./components/header/StickyView"));
|
|
85
78
|
|
|
86
|
-
var _RefreshControl = _interopRequireDefault(require("./components/pullToRefresh/RefreshControl"));
|
|
87
|
-
|
|
88
79
|
var _CollapsibleView = _interopRequireWildcard(require("./components/CollapsibleView"));
|
|
89
80
|
|
|
90
81
|
Object.keys(_CollapsibleView).forEach(function (key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { default as withCollapsibleContext } from './withCollapsibleContext';\nexport { default as useCollapsibleContext } from './hooks/useCollapsibleContext';\n\nexport { default as CollapsibleContainer } from './components/CollapsibleContainer';\nexport { default as CollapsibleFlatList } from './components/scrollable/CollapsibleFlatList';\nexport { default as CollapsibleScrollView } from './components/scrollable/CollapsibleScrollView';\nexport { default as CollapsibleHeaderContainer } from './components/header/CollapsibleHeaderContainer';\nexport { default as StickyView } from './components/header/StickyView';\nexport { default as CollapsibleView } from './components/CollapsibleView';\nexport * from './components/CollapsibleView';\n"]}
|
|
@@ -15,8 +15,6 @@ var _reactNativeReanimated = require("react-native-reanimated");
|
|
|
15
15
|
|
|
16
16
|
var _debounce = require("./utils/debounce");
|
|
17
17
|
|
|
18
|
-
var _PullToRefreshProvider = _interopRequireDefault(require("./components/pullToRefresh/PullToRefreshProvider"));
|
|
19
|
-
|
|
20
18
|
var _CollapsibleHeaderProvider = _interopRequireDefault(require("./components/header/CollapsibleHeaderProvider"));
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -177,7 +175,7 @@ function withCollapsibleContext(Component) {
|
|
|
177
175
|
value: context
|
|
178
176
|
}, /*#__PURE__*/_react.default.createElement(_useInternalCollapsibleContext.InternalCollapsibleContext.Provider, {
|
|
179
177
|
value: internalContext
|
|
180
|
-
}, /*#__PURE__*/_react.default.createElement(_CollapsibleHeaderProvider.default, null, /*#__PURE__*/_react.default.createElement(
|
|
178
|
+
}, /*#__PURE__*/_react.default.createElement(_CollapsibleHeaderProvider.default, null, /*#__PURE__*/_react.default.createElement(Component, props))));
|
|
181
179
|
};
|
|
182
180
|
}
|
|
183
181
|
//# sourceMappingURL=withCollapsibleContext.js.map
|