@momo-kits/collapse 0.102.3-beta.0 → 0.102.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.tsx +28 -8
- package/package.json +2 -2
- package/publish.sh +5 -5
- package/types.ts +11 -1
package/index.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
LayoutAnimation,
|
|
5
5
|
Platform,
|
|
6
6
|
Text as RNText,
|
|
7
|
+
ScrollView,
|
|
7
8
|
TouchableOpacity,
|
|
8
9
|
UIManager,
|
|
9
10
|
View,
|
|
@@ -43,6 +44,7 @@ const Collapse = React.forwardRef<CollapseHandle, CollapseProps>(
|
|
|
43
44
|
useBackgroundCollapseButton = false,
|
|
44
45
|
headerAlign = 'flex-start',
|
|
45
46
|
expandDefault = false,
|
|
47
|
+
disabledAnimated = false,
|
|
46
48
|
},
|
|
47
49
|
ref
|
|
48
50
|
) => {
|
|
@@ -106,7 +108,7 @@ const Collapse = React.forwardRef<CollapseHandle, CollapseProps>(
|
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
const onPressHeader = () => {
|
|
109
|
-
onPress?.();
|
|
111
|
+
onPress?.(expanded);
|
|
110
112
|
|
|
111
113
|
LayoutAnimation.configureNext({
|
|
112
114
|
duration: 300,
|
|
@@ -183,21 +185,39 @@ const Collapse = React.forwardRef<CollapseHandle, CollapseProps>(
|
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
const renderContent = () => {
|
|
188
|
+
if (scrollEnabled) {
|
|
189
|
+
const ParentComponent = disabledAnimated
|
|
190
|
+
? ScrollView
|
|
191
|
+
: Animated.ScrollView;
|
|
192
|
+
return (
|
|
193
|
+
<ParentComponent
|
|
194
|
+
scrollEnabled={scrollEnabled}
|
|
195
|
+
showsVerticalScrollIndicator={false}
|
|
196
|
+
style={[
|
|
197
|
+
scrollEnabled && {
|
|
198
|
+
maxHeight: scrollContentMaxHeight,
|
|
199
|
+
},
|
|
200
|
+
expanded && {
|
|
201
|
+
borderTopWidth: borderWidth,
|
|
202
|
+
borderColor,
|
|
203
|
+
},
|
|
204
|
+
]}>
|
|
205
|
+
{expanded && children}
|
|
206
|
+
</ParentComponent>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const ParentComponent = disabledAnimated ? View : Animated.View;
|
|
186
211
|
return (
|
|
187
|
-
<
|
|
188
|
-
scrollEnabled={scrollEnabled}
|
|
189
|
-
showsVerticalScrollIndicator={false}
|
|
212
|
+
<ParentComponent
|
|
190
213
|
style={[
|
|
191
|
-
scrollEnabled && {
|
|
192
|
-
maxHeight: scrollContentMaxHeight,
|
|
193
|
-
},
|
|
194
214
|
expanded && {
|
|
195
215
|
borderTopWidth: borderWidth,
|
|
196
216
|
borderColor,
|
|
197
217
|
},
|
|
198
218
|
]}>
|
|
199
219
|
{expanded && children}
|
|
200
|
-
</
|
|
220
|
+
</ParentComponent>
|
|
201
221
|
);
|
|
202
222
|
};
|
|
203
223
|
return (
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -7,15 +7,15 @@ rsync -r --exclude=/dist ./* dist
|
|
|
7
7
|
cd dist
|
|
8
8
|
|
|
9
9
|
if [ "$1" == "stable" ]; then
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
npm version $(npm view @momo-kits/foundation@stable version)
|
|
11
|
+
npm version patch
|
|
12
12
|
npm publish --tag stable --access=public
|
|
13
13
|
elif [ "$1" == "latest" ]; then
|
|
14
|
-
|
|
14
|
+
npm version $(npm view @momo-kits/foundation@latest version)
|
|
15
15
|
npm publish --tag latest --access=public
|
|
16
16
|
else
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
npm version $(npm view @momo-kits/collapse@beta version)
|
|
18
|
+
npm version prerelease --preid=beta
|
|
19
19
|
npm publish --tag beta --access=public
|
|
20
20
|
fi
|
|
21
21
|
|
package/types.ts
CHANGED
|
@@ -27,8 +27,9 @@ export type CollapseProps = {
|
|
|
27
27
|
/**
|
|
28
28
|
* Optional. A callback function that is triggered when the collapse component is pressed or
|
|
29
29
|
* selected. This function is typically used to toggle the view state of the collapsible content.
|
|
30
|
+
* Add isExpanded as a parameter to know the current state of the collapse, for tracking.
|
|
30
31
|
*/
|
|
31
|
-
onPress?: () => void;
|
|
32
|
+
onPress?: (isExpanded: boolean) => void;
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Optional. If `true`, a border is displayed around the collapse component, visually separating
|
|
@@ -52,6 +53,15 @@ export type CollapseProps = {
|
|
|
52
53
|
expandDefault?: boolean;
|
|
53
54
|
|
|
54
55
|
children?: React.ReactNode;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Optional. If `true`, the collapse component will not use Animated.View for the transition
|
|
59
|
+
* effect when expanding or collapsing. This is useful when the component is nested within
|
|
60
|
+
* another collapsible component that already has an animated transition effect.
|
|
61
|
+
* Can be use to fix the iseue: If WebView is the children of Collapse, the WebView will be blank when collapse is expanded.
|
|
62
|
+
* Defaults to `false` if not provided.
|
|
63
|
+
*/
|
|
64
|
+
disabledAnimated?: boolean;
|
|
55
65
|
};
|
|
56
66
|
|
|
57
67
|
export type CollapseHandle = {
|