@momo-kits/collapse 0.92.3-tracking.3 → 0.92.6-beta.11

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 CHANGED
@@ -40,15 +40,17 @@ const Collapse: FC<CollapseProps> = ({
40
40
  titleSize = 'medium',
41
41
  useBackgroundCollapseButton = false,
42
42
  headerAlign = 'flex-start',
43
+ expandDefault = false,
43
44
  }) => {
44
45
  const {theme} = useContext(ApplicationContext);
45
- const [expanded, setExpanded] = useState(false);
46
+ const [expanded, setExpanded] = useState(expandDefault);
46
47
 
47
48
  const iconSource = expanded
48
49
  ? 'arrow_chevron_up_small'
49
50
  : 'arrow_chevron_down_small';
50
- const radiusStyle = {borderBottomLeftRadius: 0, borderBottomRightRadius: 0};
51
51
  const borderWidth = showBorder ? 1 : 0;
52
+ const borderColor = theme.colors.border.default;
53
+ const backgroundColor = theme.colors.background.surface;
52
54
 
53
55
  const getTitleTypo = () => {
54
56
  switch (titleSize) {
@@ -133,12 +135,6 @@ const Collapse: FC<CollapseProps> = ({
133
135
  onPress={onPressHeader}
134
136
  style={[
135
137
  styles.header,
136
- {
137
- backgroundColor: theme.colors.background.surface,
138
- borderColor: theme.colors.border.default,
139
- borderWidth,
140
- },
141
- expanded && radiusStyle,
142
138
  {
143
139
  alignItems: headerAlign,
144
140
  },
@@ -186,8 +182,9 @@ const Collapse: FC<CollapseProps> = ({
186
182
  scrollEnabled && {
187
183
  maxHeight: scrollContentMaxHeight,
188
184
  },
189
- {
190
- backgroundColor: theme.colors.background.surface,
185
+ expanded && {
186
+ borderTopWidth: borderWidth,
187
+ borderColor,
191
188
  },
192
189
  ]}>
193
190
  {expanded && children}
@@ -195,7 +192,15 @@ const Collapse: FC<CollapseProps> = ({
195
192
  );
196
193
  };
197
194
  return (
198
- <View>
195
+ <View
196
+ style={[
197
+ styles.root,
198
+ {
199
+ borderWidth,
200
+ borderColor,
201
+ backgroundColor,
202
+ },
203
+ ]}>
199
204
  {renderHeader()}
200
205
  {renderContent()}
201
206
  </View>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/collapse",
3
- "version": "0.92.3-tracking.3",
3
+ "version": "0.92.6-beta.11",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "peerDependencies": {
package/styles.ts CHANGED
@@ -30,4 +30,8 @@ export default StyleSheet.create({
30
30
  icon: {
31
31
  marginLeft: Spacing.S,
32
32
  },
33
+ root: {
34
+ borderRadius: Radius.S,
35
+ overflow: 'hidden',
36
+ },
33
37
  });
package/types.ts CHANGED
@@ -48,4 +48,6 @@ export type CollapseProps = {
48
48
  useBackgroundCollapseButton?: boolean;
49
49
 
50
50
  headerAlign: 'flex-start' | 'flex-end' | 'center';
51
+
52
+ expandDefault?: boolean;
51
53
  };