carbon-react 111.4.2 → 111.5.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/esm/components/box/box.component.js +1 -0
- package/esm/components/card/card-column/card-column.component.d.ts +11 -0
- package/esm/components/card/card-column/card-column.component.js +7 -13
- package/esm/components/card/card-column/card-column.style.d.ts +7 -0
- package/esm/components/card/card-column/card-column.style.js +0 -7
- package/esm/components/card/card-column/index.d.ts +2 -1
- package/esm/components/card/card-footer/card-footer.component.d.ts +11 -0
- package/esm/components/card/card-footer/card-footer.component.js +320 -10
- package/esm/components/card/card-footer/card-footer.style.d.ts +10 -0
- package/esm/components/card/card-footer/card-footer.style.js +0 -10
- package/esm/components/card/card-footer/index.d.ts +2 -1
- package/esm/components/card/card-row/card-row.component.d.ts +11 -0
- package/esm/components/card/card-row/card-row.component.js +161 -17
- package/esm/components/card/card-row/card-row.style.d.ts +11 -0
- package/esm/components/card/card-row/card-row.style.js +16 -8
- package/esm/components/card/card-row/index.d.ts +2 -1
- package/esm/components/card/card.component.d.ts +31 -0
- package/esm/components/card/card.component.js +208 -69
- package/esm/components/card/card.config.d.ts +4 -0
- package/esm/components/card/card.config.js +2 -3
- package/esm/components/card/card.style.d.ts +10 -0
- package/esm/components/card/card.style.js +0 -11
- package/esm/components/card/index.d.ts +5 -1
- package/lib/components/box/box.component.js +1 -0
- package/lib/components/card/card-column/card-column.component.d.ts +11 -0
- package/lib/components/card/card-column/card-column.component.js +7 -13
- package/lib/components/card/card-column/card-column.style.d.ts +7 -0
- package/lib/components/card/card-column/card-column.style.js +0 -8
- package/lib/components/card/card-column/index.d.ts +2 -1
- package/lib/components/card/card-footer/card-footer.component.d.ts +11 -0
- package/lib/components/card/card-footer/card-footer.component.js +320 -10
- package/lib/components/card/card-footer/card-footer.style.d.ts +10 -0
- package/lib/components/card/card-footer/card-footer.style.js +0 -13
- package/lib/components/card/card-footer/index.d.ts +2 -1
- package/lib/components/card/card-row/card-row.component.d.ts +11 -0
- package/lib/components/card/card-row/card-row.component.js +162 -20
- package/lib/components/card/card-row/card-row.style.d.ts +11 -0
- package/lib/components/card/card-row/card-row.style.js +18 -7
- package/lib/components/card/card-row/index.d.ts +2 -1
- package/lib/components/card/card.component.d.ts +31 -0
- package/lib/components/card/card.component.js +213 -71
- package/lib/components/card/card.config.d.ts +4 -0
- package/lib/components/card/card.config.js +4 -5
- package/lib/components/card/card.style.d.ts +10 -0
- package/lib/components/card/card.style.js +0 -13
- package/lib/components/card/index.d.ts +5 -1
- package/package.json +1 -1
- package/esm/components/card/card-column/card-column.d.ts +0 -11
- package/esm/components/card/card-footer/card-footer.d.ts +0 -16
- package/esm/components/card/card-row/card-row.d.ts +0 -16
- package/esm/components/card/card-types.d.ts +0 -1
- package/esm/components/card/card.d.ts +0 -22
- package/lib/components/card/card-column/card-column.d.ts +0 -11
- package/lib/components/card/card-footer/card-footer.d.ts +0 -16
- package/lib/components/card/card-row/card-row.d.ts +0 -16
- package/lib/components/card/card-types.d.ts +0 -1
- package/lib/components/card/card.d.ts +0 -22
|
@@ -1,34 +1,178 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
3
|
import React from "react";
|
|
4
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
5
4
|
import PropTypes from "prop-types";
|
|
6
|
-
import StyledCardRow from "./card-row.style";
|
|
7
5
|
import { filterStyledSystemPaddingProps } from "../../../style/utils";
|
|
8
|
-
|
|
9
|
-
const paddingSizes = {
|
|
10
|
-
small: 2,
|
|
11
|
-
medium: 3,
|
|
12
|
-
large: 4
|
|
13
|
-
};
|
|
6
|
+
import StyledCardRow from "./card-row.style";
|
|
14
7
|
|
|
15
8
|
const CardRow = ({
|
|
16
9
|
children,
|
|
17
10
|
spacing = "medium",
|
|
18
|
-
...
|
|
11
|
+
...rest
|
|
19
12
|
}) => {
|
|
20
13
|
return /*#__PURE__*/React.createElement(StyledCardRow, _extends({
|
|
21
14
|
"data-element": "card-row",
|
|
22
|
-
|
|
23
|
-
},
|
|
15
|
+
spacing: spacing
|
|
16
|
+
}, filterStyledSystemPaddingProps(rest)), children);
|
|
24
17
|
};
|
|
25
18
|
|
|
26
19
|
CardRow.propTypes = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
"children": PropTypes.node,
|
|
21
|
+
"p": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
22
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
23
|
+
"description": PropTypes.string,
|
|
24
|
+
"toString": PropTypes.func.isRequired,
|
|
25
|
+
"valueOf": PropTypes.func.isRequired
|
|
26
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
27
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
28
|
+
"description": PropTypes.string,
|
|
29
|
+
"toString": PropTypes.func.isRequired,
|
|
30
|
+
"valueOf": PropTypes.func.isRequired
|
|
31
|
+
}), PropTypes.string]),
|
|
32
|
+
"padding": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
33
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
34
|
+
"description": PropTypes.string,
|
|
35
|
+
"toString": PropTypes.func.isRequired,
|
|
36
|
+
"valueOf": PropTypes.func.isRequired
|
|
37
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
38
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
39
|
+
"description": PropTypes.string,
|
|
40
|
+
"toString": PropTypes.func.isRequired,
|
|
41
|
+
"valueOf": PropTypes.func.isRequired
|
|
42
|
+
}), PropTypes.string]),
|
|
43
|
+
"paddingBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
44
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
45
|
+
"description": PropTypes.string,
|
|
46
|
+
"toString": PropTypes.func.isRequired,
|
|
47
|
+
"valueOf": PropTypes.func.isRequired
|
|
48
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
49
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
50
|
+
"description": PropTypes.string,
|
|
51
|
+
"toString": PropTypes.func.isRequired,
|
|
52
|
+
"valueOf": PropTypes.func.isRequired
|
|
53
|
+
}), PropTypes.string]),
|
|
54
|
+
"paddingLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
55
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
56
|
+
"description": PropTypes.string,
|
|
57
|
+
"toString": PropTypes.func.isRequired,
|
|
58
|
+
"valueOf": PropTypes.func.isRequired
|
|
59
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
60
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
61
|
+
"description": PropTypes.string,
|
|
62
|
+
"toString": PropTypes.func.isRequired,
|
|
63
|
+
"valueOf": PropTypes.func.isRequired
|
|
64
|
+
}), PropTypes.string]),
|
|
65
|
+
"paddingRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
66
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
67
|
+
"description": PropTypes.string,
|
|
68
|
+
"toString": PropTypes.func.isRequired,
|
|
69
|
+
"valueOf": PropTypes.func.isRequired
|
|
70
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
71
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
72
|
+
"description": PropTypes.string,
|
|
73
|
+
"toString": PropTypes.func.isRequired,
|
|
74
|
+
"valueOf": PropTypes.func.isRequired
|
|
75
|
+
}), PropTypes.string]),
|
|
76
|
+
"paddingTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
77
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
78
|
+
"description": PropTypes.string,
|
|
79
|
+
"toString": PropTypes.func.isRequired,
|
|
80
|
+
"valueOf": PropTypes.func.isRequired
|
|
81
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
82
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
83
|
+
"description": PropTypes.string,
|
|
84
|
+
"toString": PropTypes.func.isRequired,
|
|
85
|
+
"valueOf": PropTypes.func.isRequired
|
|
86
|
+
}), PropTypes.string]),
|
|
87
|
+
"paddingX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
88
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
89
|
+
"description": PropTypes.string,
|
|
90
|
+
"toString": PropTypes.func.isRequired,
|
|
91
|
+
"valueOf": PropTypes.func.isRequired
|
|
92
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
93
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
94
|
+
"description": PropTypes.string,
|
|
95
|
+
"toString": PropTypes.func.isRequired,
|
|
96
|
+
"valueOf": PropTypes.func.isRequired
|
|
97
|
+
}), PropTypes.string]),
|
|
98
|
+
"paddingY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
99
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
100
|
+
"description": PropTypes.string,
|
|
101
|
+
"toString": PropTypes.func.isRequired,
|
|
102
|
+
"valueOf": PropTypes.func.isRequired
|
|
103
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
104
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
105
|
+
"description": PropTypes.string,
|
|
106
|
+
"toString": PropTypes.func.isRequired,
|
|
107
|
+
"valueOf": PropTypes.func.isRequired
|
|
108
|
+
}), PropTypes.string]),
|
|
109
|
+
"pb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
110
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
111
|
+
"description": PropTypes.string,
|
|
112
|
+
"toString": PropTypes.func.isRequired,
|
|
113
|
+
"valueOf": PropTypes.func.isRequired
|
|
114
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
115
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
116
|
+
"description": PropTypes.string,
|
|
117
|
+
"toString": PropTypes.func.isRequired,
|
|
118
|
+
"valueOf": PropTypes.func.isRequired
|
|
119
|
+
}), PropTypes.string]),
|
|
120
|
+
"pl": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
121
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
122
|
+
"description": PropTypes.string,
|
|
123
|
+
"toString": PropTypes.func.isRequired,
|
|
124
|
+
"valueOf": PropTypes.func.isRequired
|
|
125
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
126
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
127
|
+
"description": PropTypes.string,
|
|
128
|
+
"toString": PropTypes.func.isRequired,
|
|
129
|
+
"valueOf": PropTypes.func.isRequired
|
|
130
|
+
}), PropTypes.string]),
|
|
131
|
+
"pr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
132
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
133
|
+
"description": PropTypes.string,
|
|
134
|
+
"toString": PropTypes.func.isRequired,
|
|
135
|
+
"valueOf": PropTypes.func.isRequired
|
|
136
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
137
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
138
|
+
"description": PropTypes.string,
|
|
139
|
+
"toString": PropTypes.func.isRequired,
|
|
140
|
+
"valueOf": PropTypes.func.isRequired
|
|
141
|
+
}), PropTypes.string]),
|
|
142
|
+
"pt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
143
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
144
|
+
"description": PropTypes.string,
|
|
145
|
+
"toString": PropTypes.func.isRequired,
|
|
146
|
+
"valueOf": PropTypes.func.isRequired
|
|
147
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
148
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
149
|
+
"description": PropTypes.string,
|
|
150
|
+
"toString": PropTypes.func.isRequired,
|
|
151
|
+
"valueOf": PropTypes.func.isRequired
|
|
152
|
+
}), PropTypes.string]),
|
|
153
|
+
"px": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
154
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
155
|
+
"description": PropTypes.string,
|
|
156
|
+
"toString": PropTypes.func.isRequired,
|
|
157
|
+
"valueOf": PropTypes.func.isRequired
|
|
158
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
159
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
160
|
+
"description": PropTypes.string,
|
|
161
|
+
"toString": PropTypes.func.isRequired,
|
|
162
|
+
"valueOf": PropTypes.func.isRequired
|
|
163
|
+
}), PropTypes.string]),
|
|
164
|
+
"py": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
165
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
166
|
+
"description": PropTypes.string,
|
|
167
|
+
"toString": PropTypes.func.isRequired,
|
|
168
|
+
"valueOf": PropTypes.func.isRequired
|
|
169
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
170
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
171
|
+
"description": PropTypes.string,
|
|
172
|
+
"toString": PropTypes.func.isRequired,
|
|
173
|
+
"valueOf": PropTypes.func.isRequired
|
|
174
|
+
}), PropTypes.string]),
|
|
175
|
+
"spacing": PropTypes.oneOf(["large", "medium", "small"])
|
|
33
176
|
};
|
|
177
|
+
CardRow.displayName = "CardRow";
|
|
34
178
|
export default CardRow;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PaddingProps } from "styled-system";
|
|
2
|
+
import { CardSpacing } from "../card.config";
|
|
3
|
+
export interface StyledCardRowProps extends PaddingProps {
|
|
4
|
+
/**
|
|
5
|
+
* Spacing prop is set in Card and defines the padding for the CardRow (the first CardRow has no padding by default).
|
|
6
|
+
* For more granular control of CardRow padding these can be over-ridden by Padding props from styled-system.
|
|
7
|
+
*/
|
|
8
|
+
spacing: CardSpacing;
|
|
9
|
+
}
|
|
10
|
+
declare const StyledCardRow: import("styled-components").StyledComponent<"div", any, StyledCardRowProps, never>;
|
|
11
|
+
export default StyledCardRow;
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import styled from "styled-components";
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
2
|
import { padding } from "styled-system";
|
|
3
|
-
import
|
|
4
|
-
|
|
3
|
+
import baseTheme from "../../../style/themes/base";
|
|
4
|
+
const paddingSizes = {
|
|
5
|
+
small: "var(--spacing200)",
|
|
6
|
+
medium: "var(--spacing300)",
|
|
7
|
+
large: "var(--spacing400)"
|
|
8
|
+
};
|
|
5
9
|
const StyledCardRow = styled.div`
|
|
6
|
-
${padding}
|
|
7
10
|
display: flex;
|
|
11
|
+
${({
|
|
12
|
+
spacing
|
|
13
|
+
}) => css`
|
|
14
|
+
padding-top: ${paddingSizes[spacing]};
|
|
15
|
+
padding-bottom: ${paddingSizes[spacing]};
|
|
16
|
+
`}
|
|
17
|
+
|
|
18
|
+
${padding}
|
|
8
19
|
`;
|
|
9
|
-
StyledCardRow.propTypes = {
|
|
10
|
-
theme: PropTypes.object
|
|
11
|
-
};
|
|
12
20
|
StyledCardRow.defaultProps = {
|
|
13
|
-
theme:
|
|
21
|
+
theme: baseTheme
|
|
14
22
|
};
|
|
15
23
|
export default StyledCardRow;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default } from "./card-row";
|
|
1
|
+
export { default } from "./card-row.component";
|
|
2
|
+
export type { CardRowProps } from "./card-row.component";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MarginProps } from "styled-system";
|
|
3
|
+
import { CardSpacing } from "./card.config";
|
|
4
|
+
export interface CardProps extends MarginProps {
|
|
5
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
6
|
+
"data-element"?: string;
|
|
7
|
+
/** Identifier used for testing purposes, applied to the root element of the component. */
|
|
8
|
+
"data-role"?: string;
|
|
9
|
+
/**
|
|
10
|
+
* [DEPRECATED - use `data-role` instead]
|
|
11
|
+
* Identifier used for testing purposes, applied to the root element of the component.
|
|
12
|
+
* */
|
|
13
|
+
dataRole?: string;
|
|
14
|
+
/** Action to be executed when card is clicked or enter pressed */
|
|
15
|
+
action?: (event: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
|
+
/** Style value for width of card */
|
|
17
|
+
cardWidth?: string;
|
|
18
|
+
/** Child nodes */
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
/** Flag to indicate if card is draggable */
|
|
21
|
+
draggable?: boolean;
|
|
22
|
+
/** Flag to indicate if card is interactive */
|
|
23
|
+
interactive?: boolean;
|
|
24
|
+
/** Size of card for applying padding */
|
|
25
|
+
spacing?: CardSpacing;
|
|
26
|
+
}
|
|
27
|
+
declare const Card: {
|
|
28
|
+
({ "data-element": dataElement, "data-role": dataRole, dataRole: oldDataRole, action, children, cardWidth, draggable, interactive, spacing, ...rest }: CardProps): JSX.Element;
|
|
29
|
+
displayName: string;
|
|
30
|
+
};
|
|
31
|
+
export default Card;
|
|
@@ -1,95 +1,234 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
-
import React from "react";
|
|
3
|
+
import React, { useCallback } from "react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
-
import styledSystemPropTypes from "@styled-system/prop-types";
|
|
6
5
|
import { filterStyledSystemMarginProps } from "../../style/utils";
|
|
7
6
|
import StyledCard from "./card.style";
|
|
8
7
|
import Icon from "../icon";
|
|
9
|
-
import CardRow from "
|
|
10
|
-
import
|
|
11
|
-
|
|
8
|
+
import { CardRow, CardFooter } from ".";
|
|
9
|
+
import Logger from "../../__internal__/utils/logger";
|
|
10
|
+
|
|
11
|
+
function hasDisplayName(child, displayName) {
|
|
12
|
+
return child.type.displayName === displayName;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let isDeprecationWarningTriggered = false;
|
|
12
16
|
|
|
13
17
|
const Card = ({
|
|
18
|
+
"data-element": dataElement,
|
|
19
|
+
"data-role": dataRole,
|
|
20
|
+
dataRole: oldDataRole,
|
|
14
21
|
action,
|
|
15
22
|
children,
|
|
16
|
-
cardWidth,
|
|
17
|
-
interactive,
|
|
23
|
+
cardWidth = "500px",
|
|
18
24
|
draggable,
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
interactive,
|
|
26
|
+
spacing = "medium",
|
|
21
27
|
...rest
|
|
22
28
|
}) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const renderChildren = () => {
|
|
30
|
-
return React.Children.map(children, (child, index) => {
|
|
31
|
-
if (child.type === CardRow || child.type === CardFooter) {
|
|
32
|
-
if (index === 0) {
|
|
33
|
-
const childProps = {
|
|
34
|
-
spacing,
|
|
35
|
-
...child.props
|
|
36
|
-
};
|
|
29
|
+
if (!isDeprecationWarningTriggered && oldDataRole) {
|
|
30
|
+
isDeprecationWarningTriggered = true;
|
|
31
|
+
Logger.deprecate("The `dataRole` prop of `Card` is now deprecated. Please use the kebab-case version `data-role` instead.");
|
|
32
|
+
}
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
47
|
-
spacing
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return child;
|
|
34
|
+
const renderChildren = useCallback(() => React.Children.map(children, (child, index) => {
|
|
35
|
+
if (! /*#__PURE__*/React.isValidElement(child) || /*#__PURE__*/React.isValidElement(child) && !hasDisplayName(child, CardRow.displayName) && !hasDisplayName(child, CardFooter.displayName)) return child;
|
|
36
|
+
if (index !== 0) return /*#__PURE__*/React.cloneElement(child, {
|
|
37
|
+
spacing
|
|
52
38
|
});
|
|
53
|
-
|
|
39
|
+
const childProps = {
|
|
40
|
+
spacing,
|
|
41
|
+
...child.props
|
|
42
|
+
};
|
|
54
43
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
if (hasDisplayName(child, CardRow.displayName)) {
|
|
45
|
+
const pad = React.Children.toArray(children).filter(row => /*#__PURE__*/React.isValidElement(row) && hasDisplayName(row, CardRow.displayName)).length === 1 ? "pt" : "py";
|
|
46
|
+
childProps[pad] = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
50
|
+
}), [children, spacing]);
|
|
60
51
|
return /*#__PURE__*/React.createElement(StyledCard, _extends({
|
|
61
52
|
"data-component": "card",
|
|
53
|
+
"data-element": dataElement,
|
|
54
|
+
"data-role": dataRole || oldDataRole,
|
|
62
55
|
cardWidth: cardWidth,
|
|
63
|
-
interactive: interactive,
|
|
64
|
-
draggable: draggable,
|
|
56
|
+
interactive: !!interactive,
|
|
57
|
+
draggable: !!draggable,
|
|
65
58
|
spacing: spacing,
|
|
66
|
-
onClick:
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
onClick: interactive && !draggable ? action : undefined
|
|
60
|
+
}, interactive && {
|
|
61
|
+
tabIndex: 0,
|
|
62
|
+
type: "button"
|
|
63
|
+
}, filterStyledSystemMarginProps(rest)), draggable && /*#__PURE__*/React.createElement(Icon, {
|
|
69
64
|
type: "drag"
|
|
70
65
|
}), renderChildren());
|
|
71
66
|
};
|
|
72
67
|
|
|
73
|
-
Card.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
68
|
+
Card.propTypes = {
|
|
69
|
+
"action": PropTypes.func,
|
|
70
|
+
"cardWidth": PropTypes.string,
|
|
71
|
+
"children": PropTypes.node,
|
|
72
|
+
"data-element": PropTypes.string,
|
|
73
|
+
"data-role": PropTypes.string,
|
|
74
|
+
"dataRole": PropTypes.string,
|
|
75
|
+
"draggable": PropTypes.bool,
|
|
76
|
+
"interactive": PropTypes.bool,
|
|
77
|
+
"m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
78
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
79
|
+
"description": PropTypes.string,
|
|
80
|
+
"toString": PropTypes.func.isRequired,
|
|
81
|
+
"valueOf": PropTypes.func.isRequired
|
|
82
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
83
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
84
|
+
"description": PropTypes.string,
|
|
85
|
+
"toString": PropTypes.func.isRequired,
|
|
86
|
+
"valueOf": PropTypes.func.isRequired
|
|
87
|
+
}), PropTypes.string]),
|
|
88
|
+
"margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
89
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
90
|
+
"description": PropTypes.string,
|
|
91
|
+
"toString": PropTypes.func.isRequired,
|
|
92
|
+
"valueOf": PropTypes.func.isRequired
|
|
93
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
94
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
95
|
+
"description": PropTypes.string,
|
|
96
|
+
"toString": PropTypes.func.isRequired,
|
|
97
|
+
"valueOf": PropTypes.func.isRequired
|
|
98
|
+
}), PropTypes.string]),
|
|
99
|
+
"marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
100
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
101
|
+
"description": PropTypes.string,
|
|
102
|
+
"toString": PropTypes.func.isRequired,
|
|
103
|
+
"valueOf": PropTypes.func.isRequired
|
|
104
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
105
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
106
|
+
"description": PropTypes.string,
|
|
107
|
+
"toString": PropTypes.func.isRequired,
|
|
108
|
+
"valueOf": PropTypes.func.isRequired
|
|
109
|
+
}), PropTypes.string]),
|
|
110
|
+
"marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
111
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
112
|
+
"description": PropTypes.string,
|
|
113
|
+
"toString": PropTypes.func.isRequired,
|
|
114
|
+
"valueOf": PropTypes.func.isRequired
|
|
115
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
116
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
117
|
+
"description": PropTypes.string,
|
|
118
|
+
"toString": PropTypes.func.isRequired,
|
|
119
|
+
"valueOf": PropTypes.func.isRequired
|
|
120
|
+
}), PropTypes.string]),
|
|
121
|
+
"marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
122
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
123
|
+
"description": PropTypes.string,
|
|
124
|
+
"toString": PropTypes.func.isRequired,
|
|
125
|
+
"valueOf": PropTypes.func.isRequired
|
|
126
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
127
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
128
|
+
"description": PropTypes.string,
|
|
129
|
+
"toString": PropTypes.func.isRequired,
|
|
130
|
+
"valueOf": PropTypes.func.isRequired
|
|
131
|
+
}), PropTypes.string]),
|
|
132
|
+
"marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
133
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
134
|
+
"description": PropTypes.string,
|
|
135
|
+
"toString": PropTypes.func.isRequired,
|
|
136
|
+
"valueOf": PropTypes.func.isRequired
|
|
137
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
138
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
139
|
+
"description": PropTypes.string,
|
|
140
|
+
"toString": PropTypes.func.isRequired,
|
|
141
|
+
"valueOf": PropTypes.func.isRequired
|
|
142
|
+
}), PropTypes.string]),
|
|
143
|
+
"marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
144
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
145
|
+
"description": PropTypes.string,
|
|
146
|
+
"toString": PropTypes.func.isRequired,
|
|
147
|
+
"valueOf": PropTypes.func.isRequired
|
|
148
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
149
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
150
|
+
"description": PropTypes.string,
|
|
151
|
+
"toString": PropTypes.func.isRequired,
|
|
152
|
+
"valueOf": PropTypes.func.isRequired
|
|
153
|
+
}), PropTypes.string]),
|
|
154
|
+
"marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
155
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
156
|
+
"description": PropTypes.string,
|
|
157
|
+
"toString": PropTypes.func.isRequired,
|
|
158
|
+
"valueOf": PropTypes.func.isRequired
|
|
159
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
160
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
161
|
+
"description": PropTypes.string,
|
|
162
|
+
"toString": PropTypes.func.isRequired,
|
|
163
|
+
"valueOf": PropTypes.func.isRequired
|
|
164
|
+
}), PropTypes.string]),
|
|
165
|
+
"mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
166
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
167
|
+
"description": PropTypes.string,
|
|
168
|
+
"toString": PropTypes.func.isRequired,
|
|
169
|
+
"valueOf": PropTypes.func.isRequired
|
|
170
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
171
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
172
|
+
"description": PropTypes.string,
|
|
173
|
+
"toString": PropTypes.func.isRequired,
|
|
174
|
+
"valueOf": PropTypes.func.isRequired
|
|
175
|
+
}), PropTypes.string]),
|
|
176
|
+
"ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
177
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
178
|
+
"description": PropTypes.string,
|
|
179
|
+
"toString": PropTypes.func.isRequired,
|
|
180
|
+
"valueOf": PropTypes.func.isRequired
|
|
181
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
182
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
183
|
+
"description": PropTypes.string,
|
|
184
|
+
"toString": PropTypes.func.isRequired,
|
|
185
|
+
"valueOf": PropTypes.func.isRequired
|
|
186
|
+
}), PropTypes.string]),
|
|
187
|
+
"mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
188
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
189
|
+
"description": PropTypes.string,
|
|
190
|
+
"toString": PropTypes.func.isRequired,
|
|
191
|
+
"valueOf": PropTypes.func.isRequired
|
|
192
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
193
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
194
|
+
"description": PropTypes.string,
|
|
195
|
+
"toString": PropTypes.func.isRequired,
|
|
196
|
+
"valueOf": PropTypes.func.isRequired
|
|
197
|
+
}), PropTypes.string]),
|
|
198
|
+
"mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
199
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
200
|
+
"description": PropTypes.string,
|
|
201
|
+
"toString": PropTypes.func.isRequired,
|
|
202
|
+
"valueOf": PropTypes.func.isRequired
|
|
203
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
204
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
205
|
+
"description": PropTypes.string,
|
|
206
|
+
"toString": PropTypes.func.isRequired,
|
|
207
|
+
"valueOf": PropTypes.func.isRequired
|
|
208
|
+
}), PropTypes.string]),
|
|
209
|
+
"mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
210
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
211
|
+
"description": PropTypes.string,
|
|
212
|
+
"toString": PropTypes.func.isRequired,
|
|
213
|
+
"valueOf": PropTypes.func.isRequired
|
|
214
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
215
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
216
|
+
"description": PropTypes.string,
|
|
217
|
+
"toString": PropTypes.func.isRequired,
|
|
218
|
+
"valueOf": PropTypes.func.isRequired
|
|
219
|
+
}), PropTypes.string]),
|
|
220
|
+
"my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
|
|
221
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
222
|
+
"description": PropTypes.string,
|
|
223
|
+
"toString": PropTypes.func.isRequired,
|
|
224
|
+
"valueOf": PropTypes.func.isRequired
|
|
225
|
+
}), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
|
|
226
|
+
"__@toStringTag": PropTypes.string.isRequired,
|
|
227
|
+
"description": PropTypes.string,
|
|
228
|
+
"toString": PropTypes.func.isRequired,
|
|
229
|
+
"valueOf": PropTypes.func.isRequired
|
|
230
|
+
}), PropTypes.string]),
|
|
231
|
+
"spacing": PropTypes.oneOf(["large", "medium", "small"])
|
|
94
232
|
};
|
|
233
|
+
Card.displayName = "Card";
|
|
95
234
|
export default Card;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const CARD_SPACING: readonly ["small", "medium", "large"];
|
|
2
|
+
export declare const CARD_ALIGNS: readonly ["left", "center", "right"];
|
|
3
|
+
export declare type CardAlign = typeof CARD_ALIGNS[number];
|
|
4
|
+
export declare type CardSpacing = typeof CARD_SPACING[number];
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
3
|
-
export const CARD_ALIGNS = ["center", "left", "right"];
|
|
1
|
+
export const CARD_SPACING = ["small", "medium", "large"];
|
|
2
|
+
export const CARD_ALIGNS = ["left", "center", "right"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { MarginProps } from "styled-system";
|
|
2
|
+
import { CardSpacing } from "./card.config";
|
|
3
|
+
export interface StyledCardProps extends MarginProps {
|
|
4
|
+
cardWidth: string;
|
|
5
|
+
interactive: boolean;
|
|
6
|
+
draggable: boolean;
|
|
7
|
+
spacing: CardSpacing;
|
|
8
|
+
}
|
|
9
|
+
declare const StyledCard: import("styled-components").StyledComponent<"div", any, StyledCardProps, never>;
|
|
10
|
+
export default StyledCard;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
-
import PropTypes from "prop-types";
|
|
3
2
|
import { margin } from "styled-system";
|
|
4
3
|
import baseTheme from "../../style/themes/base";
|
|
5
|
-
import { CARD_SIZES } from "./card.config";
|
|
6
4
|
const paddingSizes = {
|
|
7
5
|
small: "0 24px",
|
|
8
6
|
medium: "0 32px",
|
|
@@ -46,15 +44,6 @@ const StyledCard = styled.div`
|
|
|
46
44
|
`}
|
|
47
45
|
`;
|
|
48
46
|
StyledCard.defaultProps = {
|
|
49
|
-
cardWidth: "500px",
|
|
50
|
-
spacing: "medium",
|
|
51
47
|
theme: baseTheme
|
|
52
48
|
};
|
|
53
|
-
StyledCard.propTypes = {
|
|
54
|
-
cardWidth: PropTypes.string,
|
|
55
|
-
interactive: PropTypes.bool,
|
|
56
|
-
draggable: PropTypes.bool,
|
|
57
|
-
spacing: PropTypes.oneOf(CARD_SIZES),
|
|
58
|
-
theme: PropTypes.object
|
|
59
|
-
};
|
|
60
49
|
export default StyledCard;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { default, default as Card } from "./card";
|
|
1
|
+
export { default, default as Card } from "./card.component";
|
|
2
|
+
export type { CardProps } from "./card.component";
|
|
2
3
|
export { default as CardColumn } from "./card-column";
|
|
4
|
+
export type { CardColumnProps } from "./card-column";
|
|
3
5
|
export { default as CardFooter } from "./card-footer";
|
|
6
|
+
export type { CardFooterProps } from "./card-footer";
|
|
4
7
|
export { default as CardRow } from "./card-row";
|
|
8
|
+
export type { CardRowProps } from "./card-row";
|