@hero-design/rn 8.138.0 → 8.138.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/CHANGELOG.md +12 -0
- package/es/index.js +18 -6
- package/lib/index.js +18 -6
- package/package.json +1 -1
- package/src/components/List/ListGroup.tsx +13 -1
- package/src/components/List/ListItem.tsx +3 -1
- package/src/components/List/StyledListItem.tsx +10 -6
- package/types/components/List/StyledListItem.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.138.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5551](https://github.com/Thinkei/hero-design/pull/5551) [`ddfb78e`](https://github.com/Thinkei/hero-design/commit/ddfb78e02e1a5098b0170271e21254e0bb2aa8fe) Thanks [@ttkien](https://github.com/ttkien)! - [List.Group] Fix missing divider between rows wrapped in a Fragment
|
|
8
|
+
|
|
9
|
+
## 8.138.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#5549](https://github.com/Thinkei/hero-design/pull/5549) [`59baec0`](https://github.com/Thinkei/hero-design/commit/59baec09b5e2e744e76b075c54d6613a65025b92) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [List.Item] Fix childrenContainerTopMargin applied unconditionally when title is absent
|
|
14
|
+
|
|
3
15
|
## 8.138.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/es/index.js
CHANGED
|
@@ -15770,13 +15770,15 @@ var StyledContentContainer = index$c(View)(function () {
|
|
|
15770
15770
|
};
|
|
15771
15771
|
});
|
|
15772
15772
|
var StyledChildrenContainer = index$c(View)(function (_ref2) {
|
|
15773
|
-
var theme = _ref2.theme
|
|
15774
|
-
|
|
15773
|
+
var theme = _ref2.theme,
|
|
15774
|
+
themeHasTitle = _ref2.themeHasTitle;
|
|
15775
|
+
return _objectSpread2({
|
|
15775
15776
|
flexDirection: 'column',
|
|
15776
15777
|
justifyContent: 'flex-start',
|
|
15777
|
-
alignItems: 'flex-start'
|
|
15778
|
+
alignItems: 'flex-start'
|
|
15779
|
+
}, themeHasTitle ? {
|
|
15778
15780
|
marginTop: theme.__hd__.list.space.childrenContainerTopMargin
|
|
15779
|
-
};
|
|
15781
|
+
} : {});
|
|
15780
15782
|
});
|
|
15781
15783
|
var StyledLeadingStatus = index$c(View)(function (_ref3) {
|
|
15782
15784
|
var theme = _ref3.theme,
|
|
@@ -15850,7 +15852,9 @@ var ListItem = function ListItem(_ref) {
|
|
|
15850
15852
|
icon: suffix,
|
|
15851
15853
|
intent: disabled ? 'disabled-text' : 'primary',
|
|
15852
15854
|
size: "small"
|
|
15853
|
-
}) : suffix)), children && /*#__PURE__*/React__default.createElement(StyledChildrenContainer,
|
|
15855
|
+
}) : suffix)), children && /*#__PURE__*/React__default.createElement(StyledChildrenContainer, {
|
|
15856
|
+
themeHasTitle: !!title
|
|
15857
|
+
}, children))));
|
|
15854
15858
|
};
|
|
15855
15859
|
|
|
15856
15860
|
var StyledPrefixContainer = index$c(View)(function (_ref) {
|
|
@@ -15931,6 +15935,14 @@ var StyledListGroupContainer = index$c(View)(function (_ref) {
|
|
|
15931
15935
|
};
|
|
15932
15936
|
});
|
|
15933
15937
|
|
|
15938
|
+
var _flattenFragments = function flattenFragments(children) {
|
|
15939
|
+
return React__default.Children.toArray(children).flatMap(function (child) {
|
|
15940
|
+
if (/*#__PURE__*/React__default.isValidElement(child) && child.type === React__default.Fragment) {
|
|
15941
|
+
return _flattenFragments(child.props.children);
|
|
15942
|
+
}
|
|
15943
|
+
return [child];
|
|
15944
|
+
});
|
|
15945
|
+
};
|
|
15934
15946
|
var ERROR_CARD_VARIANT_UNSUPPORTED = 'List.Item with variant="card" is not supported inside List.Group. Use the default full-width variant instead.';
|
|
15935
15947
|
// Typed `<T,>` rather than `ReactNode` so flatMap's inferred element type
|
|
15936
15948
|
// stays narrow instead of widening to plain ReactNode, which broke type-check.
|
|
@@ -15947,7 +15959,7 @@ var ListGroup = function ListGroup(_ref) {
|
|
|
15947
15959
|
style = _ref.style,
|
|
15948
15960
|
marginHorizontal = _ref.marginHorizontal,
|
|
15949
15961
|
testID = _ref.testID;
|
|
15950
|
-
var rows =
|
|
15962
|
+
var rows = _flattenFragments(children);
|
|
15951
15963
|
var lastIndex = rows.length - 1;
|
|
15952
15964
|
var content = rows.flatMap(function (row, index) {
|
|
15953
15965
|
if (/*#__PURE__*/React__default.isValidElement(row) && row.type === ListItem && row.props.variant === 'card') {
|
package/lib/index.js
CHANGED
|
@@ -15799,13 +15799,15 @@ var StyledContentContainer = index$c(reactNative.View)(function () {
|
|
|
15799
15799
|
};
|
|
15800
15800
|
});
|
|
15801
15801
|
var StyledChildrenContainer = index$c(reactNative.View)(function (_ref2) {
|
|
15802
|
-
var theme = _ref2.theme
|
|
15803
|
-
|
|
15802
|
+
var theme = _ref2.theme,
|
|
15803
|
+
themeHasTitle = _ref2.themeHasTitle;
|
|
15804
|
+
return _objectSpread2({
|
|
15804
15805
|
flexDirection: 'column',
|
|
15805
15806
|
justifyContent: 'flex-start',
|
|
15806
|
-
alignItems: 'flex-start'
|
|
15807
|
+
alignItems: 'flex-start'
|
|
15808
|
+
}, themeHasTitle ? {
|
|
15807
15809
|
marginTop: theme.__hd__.list.space.childrenContainerTopMargin
|
|
15808
|
-
};
|
|
15810
|
+
} : {});
|
|
15809
15811
|
});
|
|
15810
15812
|
var StyledLeadingStatus = index$c(reactNative.View)(function (_ref3) {
|
|
15811
15813
|
var theme = _ref3.theme,
|
|
@@ -15879,7 +15881,9 @@ var ListItem = function ListItem(_ref) {
|
|
|
15879
15881
|
icon: suffix,
|
|
15880
15882
|
intent: disabled ? 'disabled-text' : 'primary',
|
|
15881
15883
|
size: "small"
|
|
15882
|
-
}) : suffix)), children && /*#__PURE__*/React__namespace.default.createElement(StyledChildrenContainer,
|
|
15884
|
+
}) : suffix)), children && /*#__PURE__*/React__namespace.default.createElement(StyledChildrenContainer, {
|
|
15885
|
+
themeHasTitle: !!title
|
|
15886
|
+
}, children))));
|
|
15883
15887
|
};
|
|
15884
15888
|
|
|
15885
15889
|
var StyledPrefixContainer = index$c(reactNative.View)(function (_ref) {
|
|
@@ -15960,6 +15964,14 @@ var StyledListGroupContainer = index$c(reactNative.View)(function (_ref) {
|
|
|
15960
15964
|
};
|
|
15961
15965
|
});
|
|
15962
15966
|
|
|
15967
|
+
var _flattenFragments = function flattenFragments(children) {
|
|
15968
|
+
return React__namespace.default.Children.toArray(children).flatMap(function (child) {
|
|
15969
|
+
if (/*#__PURE__*/React__namespace.default.isValidElement(child) && child.type === React__namespace.default.Fragment) {
|
|
15970
|
+
return _flattenFragments(child.props.children);
|
|
15971
|
+
}
|
|
15972
|
+
return [child];
|
|
15973
|
+
});
|
|
15974
|
+
};
|
|
15963
15975
|
var ERROR_CARD_VARIANT_UNSUPPORTED = 'List.Item with variant="card" is not supported inside List.Group. Use the default full-width variant instead.';
|
|
15964
15976
|
// Typed `<T,>` rather than `ReactNode` so flatMap's inferred element type
|
|
15965
15977
|
// stays narrow instead of widening to plain ReactNode, which broke type-check.
|
|
@@ -15976,7 +15988,7 @@ var ListGroup = function ListGroup(_ref) {
|
|
|
15976
15988
|
style = _ref.style,
|
|
15977
15989
|
marginHorizontal = _ref.marginHorizontal,
|
|
15978
15990
|
testID = _ref.testID;
|
|
15979
|
-
var rows =
|
|
15991
|
+
var rows = _flattenFragments(children);
|
|
15980
15992
|
var lastIndex = rows.length - 1;
|
|
15981
15993
|
var content = rows.flatMap(function (row, index) {
|
|
15982
15994
|
if (/*#__PURE__*/React__namespace.default.isValidElement(row) && row.type === ListItem && row.props.variant === 'card') {
|
package/package.json
CHANGED
|
@@ -7,6 +7,18 @@ import type { ListItemProps } from './ListItem';
|
|
|
7
7
|
import { StyledListGroupContainer } from './StyledListGroup';
|
|
8
8
|
import type { MarginHorizontal } from './StyledListGroup';
|
|
9
9
|
|
|
10
|
+
const flattenFragments = (children: ReactNode): ReactNode[] => {
|
|
11
|
+
return React.Children.toArray(children).flatMap((child) => {
|
|
12
|
+
if (
|
|
13
|
+
React.isValidElement<{ children?: ReactNode }>(child) &&
|
|
14
|
+
child.type === React.Fragment
|
|
15
|
+
) {
|
|
16
|
+
return flattenFragments(child.props.children);
|
|
17
|
+
}
|
|
18
|
+
return [child];
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
10
22
|
export const ERROR_CARD_VARIANT_UNSUPPORTED =
|
|
11
23
|
'List.Item with variant="card" is not supported inside List.Group. Use the default full-width variant instead.';
|
|
12
24
|
|
|
@@ -49,7 +61,7 @@ const ListGroup = ({
|
|
|
49
61
|
marginHorizontal,
|
|
50
62
|
testID,
|
|
51
63
|
}: ListGroupProps): ReactElement => {
|
|
52
|
-
const rows =
|
|
64
|
+
const rows = flattenFragments(children);
|
|
53
65
|
const lastIndex = rows.length - 1;
|
|
54
66
|
|
|
55
67
|
const content: ReactNode[] = rows.flatMap((row, index) => {
|
|
@@ -149,7 +149,9 @@ const ListItem = ({
|
|
|
149
149
|
)}
|
|
150
150
|
</View>
|
|
151
151
|
{children && (
|
|
152
|
-
<StyledChildrenContainer
|
|
152
|
+
<StyledChildrenContainer themeHasTitle={!!title}>
|
|
153
|
+
{children}
|
|
154
|
+
</StyledChildrenContainer>
|
|
153
155
|
)}
|
|
154
156
|
</StyledContentContainer>
|
|
155
157
|
</>
|
|
@@ -44,12 +44,16 @@ const StyledContentContainer = styled(View)(() => ({
|
|
|
44
44
|
flexGrow: 2,
|
|
45
45
|
}));
|
|
46
46
|
|
|
47
|
-
const StyledChildrenContainer = styled(View)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const StyledChildrenContainer = styled(View)<{ themeHasTitle: boolean }>(
|
|
48
|
+
({ theme, themeHasTitle }) => ({
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
justifyContent: 'flex-start',
|
|
51
|
+
alignItems: 'flex-start',
|
|
52
|
+
...(themeHasTitle
|
|
53
|
+
? { marginTop: theme.__hd__.list.space.childrenContainerTopMargin }
|
|
54
|
+
: {}),
|
|
55
|
+
})
|
|
56
|
+
);
|
|
53
57
|
|
|
54
58
|
const StyledLeadingStatus = styled(View)<{
|
|
55
59
|
themeLeadingStatusIntent: LeadingStatusIntent;
|
|
@@ -17,6 +17,8 @@ declare const StyledContentContainer: import("@emotion/native").StyledComponent<
|
|
|
17
17
|
declare const StyledChildrenContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
18
18
|
theme?: import("@emotion/react").Theme;
|
|
19
19
|
as?: React.ElementType;
|
|
20
|
+
} & {
|
|
21
|
+
themeHasTitle: boolean;
|
|
20
22
|
}, {}, {
|
|
21
23
|
ref?: import("react").Ref<View> | undefined;
|
|
22
24
|
}>;
|