1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import withStyles from '../styles/withStyles';
|
7 | import Typography from '../Typography';
|
8 | export const styles = {
|
9 |
|
10 | root: {
|
11 | display: 'flex',
|
12 | alignItems: 'center',
|
13 | padding: 16
|
14 | },
|
15 |
|
16 |
|
17 | avatar: {
|
18 | flex: '0 0 auto',
|
19 | marginRight: 16
|
20 | },
|
21 |
|
22 |
|
23 | action: {
|
24 | flex: '0 0 auto',
|
25 | alignSelf: 'flex-start',
|
26 | marginTop: -8,
|
27 | marginRight: -8
|
28 | },
|
29 |
|
30 |
|
31 | content: {
|
32 | flex: '1 1 auto'
|
33 | },
|
34 |
|
35 |
|
36 | title: {},
|
37 |
|
38 |
|
39 | subheader: {}
|
40 | };
|
41 | const CardHeader = React.forwardRef(function CardHeader(props, ref) {
|
42 | const {
|
43 | action,
|
44 | avatar,
|
45 | classes,
|
46 | className,
|
47 | component: Component = 'div',
|
48 | disableTypography = false,
|
49 | subheader: subheaderProp,
|
50 | subheaderTypographyProps,
|
51 | title: titleProp,
|
52 | titleTypographyProps
|
53 | } = props,
|
54 | other = _objectWithoutPropertiesLoose(props, ["action", "avatar", "classes", "className", "component", "disableTypography", "subheader", "subheaderTypographyProps", "title", "titleTypographyProps"]);
|
55 |
|
56 | let title = titleProp;
|
57 |
|
58 | if (title != null && title.type !== Typography && !disableTypography) {
|
59 | title = React.createElement(Typography, _extends({
|
60 | variant: avatar ? 'body2' : 'h5',
|
61 | className: classes.title,
|
62 | component: "span",
|
63 | display: "block"
|
64 | }, titleTypographyProps), title);
|
65 | }
|
66 |
|
67 | let subheader = subheaderProp;
|
68 |
|
69 | if (subheader != null && subheader.type !== Typography && !disableTypography) {
|
70 | subheader = React.createElement(Typography, _extends({
|
71 | variant: avatar ? 'body2' : 'body1',
|
72 | className: classes.subheader,
|
73 | color: "textSecondary",
|
74 | component: "span",
|
75 | display: "block"
|
76 | }, subheaderTypographyProps), subheader);
|
77 | }
|
78 |
|
79 | return React.createElement(Component, _extends({
|
80 | className: clsx(classes.root, className),
|
81 | ref: ref
|
82 | }, other), avatar && React.createElement("div", {
|
83 | className: classes.avatar
|
84 | }, avatar), React.createElement("div", {
|
85 | className: classes.content
|
86 | }, title, subheader), action && React.createElement("div", {
|
87 | className: classes.action
|
88 | }, action));
|
89 | });
|
90 | process.env.NODE_ENV !== "production" ? CardHeader.propTypes = {
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | |
97 |
|
98 |
|
99 | action: PropTypes.node,
|
100 |
|
101 | |
102 |
|
103 |
|
104 | avatar: PropTypes.node,
|
105 |
|
106 | |
107 |
|
108 |
|
109 | children: PropTypes.node,
|
110 |
|
111 | |
112 |
|
113 |
|
114 |
|
115 | classes: PropTypes.object,
|
116 |
|
117 | |
118 |
|
119 |
|
120 | className: PropTypes.string,
|
121 |
|
122 | |
123 |
|
124 |
|
125 |
|
126 | component: PropTypes
|
127 |
|
128 | .elementType,
|
129 |
|
130 | |
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | disableTypography: PropTypes.bool,
|
137 |
|
138 | |
139 |
|
140 |
|
141 | subheader: PropTypes.node,
|
142 |
|
143 | |
144 |
|
145 |
|
146 |
|
147 | subheaderTypographyProps: PropTypes.object,
|
148 |
|
149 | |
150 |
|
151 |
|
152 | title: PropTypes.node,
|
153 |
|
154 | |
155 |
|
156 |
|
157 |
|
158 | titleTypographyProps: PropTypes.object
|
159 | } : void 0;
|
160 | export default withStyles(styles, {
|
161 | name: 'MuiCardHeader'
|
162 | })(CardHeader); |
\ | No newline at end of file |