@telus-uds/components-base 3.26.0 → 3.27.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/CHANGELOG.md +19 -2
- package/lib/cjs/Card/Card.js +34 -13
- package/lib/cjs/Card/CardBase.js +78 -11
- package/lib/cjs/Card/PressableCardBase.js +147 -8
- package/lib/cjs/Carousel/Carousel.js +105 -50
- package/lib/cjs/Carousel/CarouselContext.js +10 -4
- package/lib/cjs/Carousel/CarouselItem/CarouselItem.js +11 -7
- package/lib/cjs/Carousel/Constants.js +11 -2
- package/lib/cjs/Checkbox/Checkbox.js +43 -13
- package/lib/cjs/List/List.js +24 -9
- package/lib/cjs/List/ListItem.js +18 -1
- package/lib/cjs/List/ListItemBase.js +27 -8
- package/lib/cjs/List/ListItemMark.js +33 -62
- package/lib/cjs/List/PressableListItemBase.js +1 -0
- package/lib/esm/Card/Card.js +34 -13
- package/lib/esm/Card/CardBase.js +78 -11
- package/lib/esm/Card/PressableCardBase.js +148 -9
- package/lib/esm/Carousel/Carousel.js +106 -51
- package/lib/esm/Carousel/CarouselContext.js +10 -4
- package/lib/esm/Carousel/CarouselItem/CarouselItem.js +11 -7
- package/lib/esm/Carousel/Constants.js +10 -1
- package/lib/esm/Checkbox/Checkbox.js +43 -13
- package/lib/esm/List/List.js +24 -9
- package/lib/esm/List/ListItem.js +19 -2
- package/lib/esm/List/ListItemBase.js +27 -8
- package/lib/esm/List/ListItemMark.js +33 -62
- package/lib/esm/List/PressableListItemBase.js +1 -0
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/src/Card/Card.jsx +29 -7
- package/src/Card/CardBase.jsx +88 -8
- package/src/Card/PressableCardBase.jsx +135 -9
- package/src/Carousel/Carousel.jsx +119 -64
- package/src/Carousel/CarouselContext.jsx +12 -4
- package/src/Carousel/CarouselItem/CarouselItem.jsx +10 -6
- package/src/Carousel/Constants.js +10 -0
- package/src/Checkbox/Checkbox.jsx +29 -7
- package/src/List/List.jsx +33 -9
- package/src/List/ListItem.jsx +33 -11
- package/src/List/ListItemBase.jsx +33 -9
- package/src/List/ListItemMark.jsx +32 -53
- package/src/List/PressableListItemBase.jsx +1 -0
|
@@ -17,6 +17,12 @@ var _ThemeProvider = require("../ThemeProvider");
|
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
19
|
const [selectProps, selectedSystemPropTypes] = (0, _utils.selectSystemProps)([_utils.a11yProps, _utils.viewProps]);
|
|
20
|
+
const VERTICAL_CENTERING_DIVISOR = 2;
|
|
21
|
+
const alignmentMap = {
|
|
22
|
+
top: 'flex-start',
|
|
23
|
+
center: 'center',
|
|
24
|
+
bottom: 'flex-end'
|
|
25
|
+
};
|
|
20
26
|
const selectItemBlockStyles = _ref => {
|
|
21
27
|
let {
|
|
22
28
|
interItemMargin
|
|
@@ -38,10 +44,16 @@ const selectDividerStyles = _ref2 => {
|
|
|
38
44
|
paddingBottom: interItemMarginWithDivider
|
|
39
45
|
};
|
|
40
46
|
};
|
|
47
|
+
const selectAlignmentStyles = iconVerticalAlign => ({
|
|
48
|
+
alignItems: alignmentMap[iconVerticalAlign]
|
|
49
|
+
});
|
|
41
50
|
|
|
42
51
|
/**
|
|
43
52
|
* ListItem is responsible for rendering icon or a bullet as side item
|
|
44
53
|
*/
|
|
54
|
+
const calculateIconMarginTop = (itemIconSize, fontSize, lineHeightRatio) => {
|
|
55
|
+
return (fontSize * lineHeightRatio - itemIconSize) / VERTICAL_CENTERING_DIVISOR;
|
|
56
|
+
};
|
|
45
57
|
const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
46
58
|
let {
|
|
47
59
|
tokens,
|
|
@@ -52,6 +64,7 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
52
64
|
children,
|
|
53
65
|
title,
|
|
54
66
|
isLastItem,
|
|
67
|
+
iconVerticalAlign = 'top',
|
|
55
68
|
accessibilityRole = _Platform.default.select({
|
|
56
69
|
web: 'listitem',
|
|
57
70
|
default: undefined
|
|
@@ -65,7 +78,6 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
65
78
|
iconMarginTop,
|
|
66
79
|
itemIconSize
|
|
67
80
|
} = themeTokens;
|
|
68
|
-
let adjustedIconMarginTop = iconMarginTop;
|
|
69
81
|
const {
|
|
70
82
|
fontSize,
|
|
71
83
|
lineHeight: lineHeightRatio
|
|
@@ -73,9 +85,8 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
73
85
|
size: 'h4',
|
|
74
86
|
bold: true
|
|
75
87
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
88
|
+
const adjustedIconMarginTop = title ? calculateIconMarginTop(itemIconSize, fontSize, lineHeightRatio) : iconMarginTop;
|
|
89
|
+
|
|
79
90
|
/**
|
|
80
91
|
* Function responsible returning styling, in case the item is the last shouldn't
|
|
81
92
|
* add extra margin on the bottom, if "showDivider" is true it should add a divider
|
|
@@ -102,7 +113,7 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
102
113
|
iconSize,
|
|
103
114
|
isLastItem
|
|
104
115
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
105
|
-
style: staticStyles.
|
|
116
|
+
style: [staticStyles.innerContainer, selectAlignmentStyles(iconVerticalAlign)],
|
|
106
117
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemMark.default, {
|
|
107
118
|
tokens: {
|
|
108
119
|
...tokens,
|
|
@@ -112,7 +123,7 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
112
123
|
iconColor: iconColor,
|
|
113
124
|
iconSize: iconSize
|
|
114
125
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_View.default, {
|
|
115
|
-
style: staticStyles.titleAndContentContainer,
|
|
126
|
+
style: [staticStyles.titleAndContentContainer],
|
|
116
127
|
children: [Boolean(title) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
117
128
|
variant: {
|
|
118
129
|
size: 'h4',
|
|
@@ -128,15 +139,21 @@ const ListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
|
128
139
|
});
|
|
129
140
|
});
|
|
130
141
|
ListItemBase.displayName = 'ListItem';
|
|
142
|
+
ListItemBase.__UDS_COMPONENT_TYPE__ = 'ListItem';
|
|
131
143
|
const staticStyles = _StyleSheet.default.create({
|
|
132
144
|
container: {
|
|
145
|
+
flexDirection: 'row',
|
|
146
|
+
width: '100%'
|
|
147
|
+
},
|
|
148
|
+
innerContainer: {
|
|
133
149
|
flex: 1,
|
|
134
150
|
flexDirection: 'row'
|
|
135
151
|
},
|
|
136
152
|
titleAndContentContainer: {
|
|
137
153
|
flexDirection: 'column',
|
|
138
|
-
|
|
139
|
-
flexGrow: 1
|
|
154
|
+
flex: 1,
|
|
155
|
+
flexGrow: 1,
|
|
156
|
+
flexShrink: 1
|
|
140
157
|
}
|
|
141
158
|
});
|
|
142
159
|
ListItemBase.propTypes = {
|
|
@@ -144,6 +161,8 @@ ListItemBase.propTypes = {
|
|
|
144
161
|
tokens: (0, _utils.getTokensPropType)('List'),
|
|
145
162
|
variant: _utils.variantProp.propType,
|
|
146
163
|
children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
|
164
|
+
/** Controls the vertical alignment of the icon */
|
|
165
|
+
iconVerticalAlign: _propTypes.default.oneOf(['top', 'center', 'bottom']),
|
|
147
166
|
/**
|
|
148
167
|
* Renders side item icon
|
|
149
168
|
*/
|
|
@@ -7,7 +7,6 @@ exports.tokenTypes = exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _View = _interopRequireDefault(require("react-native-web/dist/cjs/exports/View"));
|
|
10
|
-
var _StyleSheet = _interopRequireDefault(require("react-native-web/dist/cjs/exports/StyleSheet"));
|
|
11
10
|
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
12
11
|
var _utils = require("../utils");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -16,49 +15,29 @@ const tokenTypes = exports.tokenTypes = {
|
|
|
16
15
|
itemIconSize: _propTypes.default.number.isRequired,
|
|
17
16
|
itemIconColor: _propTypes.default.string.isRequired,
|
|
18
17
|
listGutter: _propTypes.default.number.isRequired,
|
|
19
|
-
iconMarginTop: _propTypes.default.number.isRequired
|
|
18
|
+
iconMarginTop: _propTypes.default.number.isRequired,
|
|
19
|
+
bulletIcon: _propTypes.default.elementType.isRequired
|
|
20
20
|
};
|
|
21
|
-
const
|
|
21
|
+
const selectContainerStyles = _ref => {
|
|
22
22
|
let {
|
|
23
|
-
|
|
24
|
-
itemIconColor
|
|
23
|
+
listGutter
|
|
25
24
|
} = _ref;
|
|
26
25
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
const selectSideItemContainerStyles = _ref2 => {
|
|
32
|
-
let {
|
|
33
|
-
listGutter,
|
|
34
|
-
iconMarginTop
|
|
35
|
-
} = _ref2;
|
|
36
|
-
return {
|
|
37
|
-
marginTop: iconMarginTop,
|
|
38
|
-
marginRight: listGutter
|
|
26
|
+
marginInlineEnd: listGutter,
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'flex-start'
|
|
39
29
|
};
|
|
40
30
|
};
|
|
41
|
-
|
|
42
|
-
// Align bullets with the top line of text the same way icons are aligned
|
|
43
|
-
const selectBulletPositioningStyles = _ref3 => {
|
|
31
|
+
const selectBulletStyles = _ref2 => {
|
|
44
32
|
let {
|
|
45
33
|
itemIconSize
|
|
46
|
-
} =
|
|
34
|
+
} = _ref2;
|
|
47
35
|
return {
|
|
48
36
|
width: itemIconSize,
|
|
49
|
-
height: itemIconSize
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let {
|
|
54
|
-
itemBulletContainerWidth,
|
|
55
|
-
itemBulletContainerHeight,
|
|
56
|
-
itemBulletContainerAlign
|
|
57
|
-
} = _ref4;
|
|
58
|
-
return {
|
|
59
|
-
width: itemBulletContainerWidth,
|
|
60
|
-
height: itemBulletContainerHeight,
|
|
61
|
-
alignItems: itemBulletContainerAlign
|
|
37
|
+
height: itemIconSize,
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
justifyContent: 'center',
|
|
40
|
+
flexShrink: 0
|
|
62
41
|
};
|
|
63
42
|
};
|
|
64
43
|
const getIconColorVariants = iconVariants => iconVariants?.filter(variant => variant[0] === 'color').map(variant => variant[1]);
|
|
@@ -70,31 +49,31 @@ const getIconColorVariants = iconVariants => iconVariants?.filter(variant => var
|
|
|
70
49
|
* It's the responsibility of themes to make sure that the supplied tokens align the
|
|
71
50
|
* icon or bullet nicely against the first line of text in a ListIconContent.
|
|
72
51
|
*/
|
|
73
|
-
const ListItemMark = /*#__PURE__*/_react.default.forwardRef((
|
|
52
|
+
const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
74
53
|
let {
|
|
75
54
|
icon,
|
|
76
55
|
iconColor,
|
|
77
56
|
iconSize,
|
|
78
57
|
tokens = {}
|
|
79
|
-
} =
|
|
58
|
+
} = _ref3;
|
|
80
59
|
const themeTokens = typeof tokens === 'function' ? tokens() : tokens;
|
|
81
|
-
const
|
|
82
|
-
const bulletContainerStyles = selectBulletContainerStyles(themeTokens);
|
|
83
|
-
|
|
84
|
-
// TODO: Remove it when iconColor custom colors are deprecated.
|
|
60
|
+
const containerStyles = selectContainerStyles(themeTokens);
|
|
85
61
|
const iconVariants = (0, _utils.useVariants)('Icon');
|
|
86
62
|
const iconColorVariants = getIconColorVariants(iconVariants);
|
|
87
63
|
if (icon) {
|
|
88
|
-
const
|
|
64
|
+
const {
|
|
65
|
+
itemIconSize,
|
|
66
|
+
itemIconColor
|
|
67
|
+
} = themeTokens;
|
|
68
|
+
const finalIconSize = iconSize ?? itemIconSize;
|
|
69
|
+
const finalIconColor = iconColor && !iconColorVariants?.includes(iconColor) ? iconColor : itemIconColor;
|
|
89
70
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
90
|
-
style:
|
|
71
|
+
style: containerStyles,
|
|
91
72
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
92
73
|
icon: icon,
|
|
93
74
|
tokens: {
|
|
94
|
-
size:
|
|
95
|
-
|
|
96
|
-
color: iconColor && !iconColorVariants?.includes(iconColor) ? iconColor : iconTokens.color
|
|
97
|
-
})
|
|
75
|
+
size: finalIconSize,
|
|
76
|
+
color: finalIconColor
|
|
98
77
|
},
|
|
99
78
|
variant: {
|
|
100
79
|
...(iconColorVariants?.includes(iconColor) && {
|
|
@@ -104,23 +83,21 @@ const ListItemMark = /*#__PURE__*/_react.default.forwardRef((_ref5, ref) => {
|
|
|
104
83
|
})
|
|
105
84
|
});
|
|
106
85
|
}
|
|
107
|
-
const bulletColor = themeTokens.itemBulletColor;
|
|
108
86
|
const {
|
|
109
|
-
|
|
87
|
+
itemIconSize,
|
|
88
|
+
itemIconColor
|
|
110
89
|
} = themeTokens;
|
|
111
|
-
const
|
|
112
|
-
const itemBulletPositioningStyles = selectBulletPositioningStyles(themeTokens);
|
|
90
|
+
const bulletStyles = selectBulletStyles(themeTokens);
|
|
113
91
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
114
|
-
style:
|
|
92
|
+
style: containerStyles,
|
|
115
93
|
ref: ref,
|
|
116
94
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_View.default, {
|
|
117
|
-
style:
|
|
118
|
-
testID: "unordered-item-bullet",
|
|
95
|
+
style: bulletStyles,
|
|
119
96
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
|
|
120
|
-
icon: bulletIcon,
|
|
97
|
+
icon: themeTokens.bulletIcon,
|
|
121
98
|
tokens: {
|
|
122
|
-
color:
|
|
123
|
-
size:
|
|
99
|
+
color: itemIconColor,
|
|
100
|
+
size: itemIconSize
|
|
124
101
|
}
|
|
125
102
|
})
|
|
126
103
|
})
|
|
@@ -142,10 +119,4 @@ ListItemMark.propTypes = {
|
|
|
142
119
|
*/
|
|
143
120
|
iconSize: _propTypes.default.number
|
|
144
121
|
};
|
|
145
|
-
const staticStyles = _StyleSheet.default.create({
|
|
146
|
-
bulletPositioning: {
|
|
147
|
-
alignItems: 'center',
|
|
148
|
-
justifyContent: 'center'
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
122
|
var _default = exports.default = ListItemMark;
|
|
@@ -98,6 +98,7 @@ const PressableListItemBase = /*#__PURE__*/_react.default.forwardRef((_ref2, ref
|
|
|
98
98
|
});
|
|
99
99
|
});
|
|
100
100
|
PressableListItemBase.displayName = 'PressableListItemBase';
|
|
101
|
+
PressableListItemBase.__UDS_COMPONENT_TYPE__ = 'ListItem';
|
|
101
102
|
const staticStyles = _StyleSheet.default.create({
|
|
102
103
|
itemContainer: {
|
|
103
104
|
flexDirection: 'row',
|
package/lib/esm/Card/Card.js
CHANGED
|
@@ -16,18 +16,26 @@ const SelectionType = {
|
|
|
16
16
|
Radio: 'radiogroup',
|
|
17
17
|
None: undefined
|
|
18
18
|
};
|
|
19
|
-
const selectInputStyle = _ref => {
|
|
19
|
+
const selectInputStyle = (_ref, _ref2) => {
|
|
20
20
|
let {
|
|
21
21
|
paddingTop,
|
|
22
|
-
paddingRight
|
|
22
|
+
paddingRight,
|
|
23
|
+
paddingLeft
|
|
23
24
|
} = _ref;
|
|
25
|
+
let {
|
|
26
|
+
inputPositionProp
|
|
27
|
+
} = _ref2;
|
|
24
28
|
return {
|
|
25
29
|
position: 'absolute',
|
|
26
30
|
top: paddingTop,
|
|
27
|
-
|
|
31
|
+
...(inputPositionProp === 'left' ? {
|
|
32
|
+
left: paddingLeft
|
|
33
|
+
} : {
|
|
34
|
+
right: paddingRight
|
|
35
|
+
})
|
|
28
36
|
};
|
|
29
37
|
};
|
|
30
|
-
const getInputProps =
|
|
38
|
+
const getInputProps = _ref3 => {
|
|
31
39
|
let {
|
|
32
40
|
id,
|
|
33
41
|
checkColor,
|
|
@@ -37,7 +45,7 @@ const getInputProps = _ref2 => {
|
|
|
37
45
|
isChecked,
|
|
38
46
|
isInactive,
|
|
39
47
|
handleChange
|
|
40
|
-
} =
|
|
48
|
+
} = _ref3;
|
|
41
49
|
return {
|
|
42
50
|
inputId: id,
|
|
43
51
|
tokens: {
|
|
@@ -100,7 +108,7 @@ const getInputProps = _ref2 => {
|
|
|
100
108
|
* you automatically make inaccessible its children, which may or may not be appropriate
|
|
101
109
|
* depending on what you are trying to achieve.
|
|
102
110
|
*/
|
|
103
|
-
const Card = /*#__PURE__*/React.forwardRef((
|
|
111
|
+
const Card = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
104
112
|
let {
|
|
105
113
|
children,
|
|
106
114
|
tokens,
|
|
@@ -110,8 +118,9 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
110
118
|
id,
|
|
111
119
|
interactiveCard,
|
|
112
120
|
backgroundImage,
|
|
121
|
+
testID,
|
|
113
122
|
...rest
|
|
114
|
-
} =
|
|
123
|
+
} = _ref4;
|
|
115
124
|
const viewport = useViewport();
|
|
116
125
|
const {
|
|
117
126
|
themeOptions
|
|
@@ -182,8 +191,8 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
182
191
|
let cardStyles;
|
|
183
192
|
let mediaIds;
|
|
184
193
|
if (enableMediaQueryStyleSheet) {
|
|
185
|
-
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc,
|
|
186
|
-
let [vp, viewportTokens] =
|
|
194
|
+
const transformedThemeTokens = Object.entries(themeTokens).reduce((acc, _ref5) => {
|
|
195
|
+
let [vp, viewportTokens] = _ref5;
|
|
187
196
|
const tokensToTransform = selectionType ? selectStyles({
|
|
188
197
|
...viewportTokens,
|
|
189
198
|
paddingTop: 0,
|
|
@@ -210,13 +219,18 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
210
219
|
cardStyles = themeTokens;
|
|
211
220
|
}
|
|
212
221
|
const renderInputPerSelectionType = props => {
|
|
222
|
+
const containerStyle = selectInputStyle(getThemeTokens(), {
|
|
223
|
+
inputPositionProp: interactiveCard?.inputPosition
|
|
224
|
+
});
|
|
225
|
+
const inputTestID = testID && `${testID}-selection-input`;
|
|
213
226
|
if (!isControl) {
|
|
214
227
|
return null;
|
|
215
228
|
}
|
|
216
229
|
switch (selectionType) {
|
|
217
230
|
case SelectionType.Checkbox:
|
|
218
231
|
return /*#__PURE__*/_jsx(View, {
|
|
219
|
-
style:
|
|
232
|
+
style: containerStyle,
|
|
233
|
+
testID: inputTestID,
|
|
220
234
|
children: /*#__PURE__*/_jsx(CheckboxButton, {
|
|
221
235
|
...props,
|
|
222
236
|
tokens: {
|
|
@@ -227,7 +241,8 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
227
241
|
});
|
|
228
242
|
case SelectionType.Radio:
|
|
229
243
|
return /*#__PURE__*/_jsx(View, {
|
|
230
|
-
style:
|
|
244
|
+
style: containerStyle,
|
|
245
|
+
testID: inputTestID,
|
|
231
246
|
children: /*#__PURE__*/_jsx(RadioButton, {
|
|
232
247
|
...props,
|
|
233
248
|
tokens: {
|
|
@@ -248,6 +263,7 @@ const Card = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
248
263
|
dataSet: mediaIds && {
|
|
249
264
|
media: mediaIds
|
|
250
265
|
},
|
|
266
|
+
testID: testID,
|
|
251
267
|
...selectProps(rest),
|
|
252
268
|
children: [interactiveCard?.body && /*#__PURE__*/_jsx(PressableCardBase, {
|
|
253
269
|
ref: ref,
|
|
@@ -326,7 +342,8 @@ Card.propTypes = {
|
|
|
326
342
|
selectionType: PropTypes.oneOf(Object.values(SelectionType)),
|
|
327
343
|
variant: variantProp.propType,
|
|
328
344
|
href: PropTypes.string,
|
|
329
|
-
hrefAttrs: PropTypes.shape(hrefAttrsProp.types)
|
|
345
|
+
hrefAttrs: PropTypes.shape(hrefAttrsProp.types),
|
|
346
|
+
inputPosition: PropTypes.oneOf(['left', 'right'])
|
|
330
347
|
}),
|
|
331
348
|
/**
|
|
332
349
|
* Apply background image to the card.
|
|
@@ -343,6 +360,10 @@ Card.propTypes = {
|
|
|
343
360
|
/**
|
|
344
361
|
* Data set for the card.
|
|
345
362
|
*/
|
|
346
|
-
dataSet: PropTypes.object
|
|
363
|
+
dataSet: PropTypes.object,
|
|
364
|
+
/**
|
|
365
|
+
* Test ID used for e2e testing.
|
|
366
|
+
*/
|
|
367
|
+
testID: PropTypes.string
|
|
347
368
|
};
|
|
348
369
|
export default Card;
|
package/lib/esm/Card/CardBase.js
CHANGED
|
@@ -107,9 +107,51 @@ const setBackgroundImage = _ref => {
|
|
|
107
107
|
children: content
|
|
108
108
|
});
|
|
109
109
|
};
|
|
110
|
+
const selectPaddedContentStyles = _ref2 => {
|
|
111
|
+
let {
|
|
112
|
+
paddingTop,
|
|
113
|
+
paddingBottom,
|
|
114
|
+
paddingLeft,
|
|
115
|
+
paddingRight,
|
|
116
|
+
borderWidth,
|
|
117
|
+
borderColor,
|
|
118
|
+
borderRadius,
|
|
119
|
+
hasInteractiveBorder
|
|
120
|
+
} = _ref2;
|
|
121
|
+
return {
|
|
122
|
+
paddingTop,
|
|
123
|
+
paddingBottom,
|
|
124
|
+
paddingLeft,
|
|
125
|
+
paddingRight,
|
|
126
|
+
...(hasInteractiveBorder ? {
|
|
127
|
+
borderWidth,
|
|
128
|
+
borderColor,
|
|
129
|
+
borderRadius
|
|
130
|
+
} : {})
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const selectInteractiveOverlayStyles = _ref3 => {
|
|
134
|
+
let {
|
|
135
|
+
backgroundColor,
|
|
136
|
+
borderRadius,
|
|
137
|
+
borderWidth
|
|
138
|
+
} = _ref3;
|
|
139
|
+
const adjustedBorderRadius = Math.max(0, borderRadius - borderWidth);
|
|
140
|
+
return {
|
|
141
|
+
position: 'absolute',
|
|
142
|
+
top: 0,
|
|
143
|
+
left: 0,
|
|
144
|
+
right: 0,
|
|
145
|
+
bottom: 0,
|
|
146
|
+
backgroundColor,
|
|
147
|
+
borderRadius: adjustedBorderRadius,
|
|
148
|
+
pointerEvents: 'none',
|
|
149
|
+
zIndex: 1
|
|
150
|
+
};
|
|
151
|
+
};
|
|
110
152
|
|
|
111
153
|
// Ensure explicit selection of tokens
|
|
112
|
-
export const selectStyles =
|
|
154
|
+
export const selectStyles = _ref4 => {
|
|
113
155
|
let {
|
|
114
156
|
flex,
|
|
115
157
|
backgroundColor,
|
|
@@ -130,7 +172,7 @@ export const selectStyles = _ref2 => {
|
|
|
130
172
|
gradient,
|
|
131
173
|
maxHeight,
|
|
132
174
|
overflowY
|
|
133
|
-
} =
|
|
175
|
+
} = _ref4;
|
|
134
176
|
const hasGradient = (gradient || backgroundGradient) && Platform.OS === 'web';
|
|
135
177
|
let backgroundImageValue = null;
|
|
136
178
|
if (hasGradient) {
|
|
@@ -176,7 +218,7 @@ export const selectStyles = _ref2 => {
|
|
|
176
218
|
* A themeless base component for Card which components can apply theme tokens to. Not
|
|
177
219
|
* intended to be used in apps or sites directly: build themed components on top of this.
|
|
178
220
|
*/
|
|
179
|
-
const CardBase = /*#__PURE__*/React.forwardRef((
|
|
221
|
+
const CardBase = /*#__PURE__*/React.forwardRef((_ref5, ref) => {
|
|
180
222
|
let {
|
|
181
223
|
children,
|
|
182
224
|
tokens,
|
|
@@ -185,7 +227,7 @@ const CardBase = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
185
227
|
fullBleedContent,
|
|
186
228
|
cardState,
|
|
187
229
|
...rest
|
|
188
|
-
} =
|
|
230
|
+
} = _ref5;
|
|
189
231
|
const cardStyle = selectStyles(typeof tokens === 'function' ? tokens(cardState) : tokens);
|
|
190
232
|
const props = selectProps(rest);
|
|
191
233
|
let content = children;
|
|
@@ -212,26 +254,51 @@ const CardBase = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
|
212
254
|
paddingBottom,
|
|
213
255
|
paddingLeft,
|
|
214
256
|
paddingRight,
|
|
257
|
+
borderWidth,
|
|
258
|
+
borderColor,
|
|
259
|
+
borderRadius,
|
|
260
|
+
backgroundColor,
|
|
215
261
|
...containerStyle
|
|
216
262
|
} = cardStyle;
|
|
217
263
|
const hasPadding = paddingTop || paddingBottom || paddingLeft || paddingRight;
|
|
218
|
-
const
|
|
219
|
-
|
|
264
|
+
const hasInteractiveBorder = borderWidth && borderWidth > 0;
|
|
265
|
+
const hasInteractiveOverlay = isOverlayColor(backgroundColor);
|
|
266
|
+
const paddedContent = hasPadding || hasInteractiveBorder ? /*#__PURE__*/_jsx(View, {
|
|
267
|
+
style: selectPaddedContentStyles({
|
|
220
268
|
paddingTop,
|
|
221
269
|
paddingBottom,
|
|
222
270
|
paddingLeft,
|
|
223
|
-
paddingRight
|
|
224
|
-
|
|
271
|
+
paddingRight,
|
|
272
|
+
borderWidth,
|
|
273
|
+
borderColor,
|
|
274
|
+
borderRadius,
|
|
275
|
+
hasInteractiveBorder
|
|
276
|
+
}),
|
|
225
277
|
children: children
|
|
226
278
|
}) : children;
|
|
279
|
+
const contentWithOverlay = /*#__PURE__*/_jsxs(_Fragment, {
|
|
280
|
+
children: [hasInteractiveOverlay && Platform.OS === 'web' && /*#__PURE__*/_jsx(View, {
|
|
281
|
+
style: selectInteractiveOverlayStyles({
|
|
282
|
+
backgroundColor,
|
|
283
|
+
borderRadius,
|
|
284
|
+
borderWidth
|
|
285
|
+
})
|
|
286
|
+
}), /*#__PURE__*/_jsx(View, {
|
|
287
|
+
style: staticStyles.contentOverlay,
|
|
288
|
+
children: paddedContent
|
|
289
|
+
})]
|
|
290
|
+
});
|
|
227
291
|
content = setBackgroundImage({
|
|
228
292
|
src: imageSourceViewport,
|
|
229
293
|
alt,
|
|
230
294
|
backgroundImageResizeMode,
|
|
231
295
|
backgroundImagePosition,
|
|
232
296
|
backgroundImageAlign,
|
|
233
|
-
content:
|
|
234
|
-
cardStyle:
|
|
297
|
+
content: contentWithOverlay,
|
|
298
|
+
cardStyle: {
|
|
299
|
+
...containerStyle,
|
|
300
|
+
borderRadius
|
|
301
|
+
}
|
|
235
302
|
});
|
|
236
303
|
return /*#__PURE__*/_jsx(View, {
|
|
237
304
|
style: containerStyle,
|
|
@@ -313,7 +380,7 @@ const staticStyles = StyleSheet.create({
|
|
|
313
380
|
position: 'relative',
|
|
314
381
|
width: '100%',
|
|
315
382
|
height: '100%',
|
|
316
|
-
zIndex:
|
|
383
|
+
zIndex: 2
|
|
317
384
|
},
|
|
318
385
|
containContainer: {
|
|
319
386
|
width: '100%',
|