carbon-react 87.5.0 → 88.0.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.
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  var _propTypes2 = _interopRequireDefault(require("@styled-system/prop-types"));
13
13
 
14
- var _classnames = _interopRequireDefault(require("classnames"));
15
-
16
14
  var _ether = require("../../utils/ether/ether");
17
15
 
18
16
  var _tags = _interopRequireDefault(require("../../utils/helpers/tags/tags"));
@@ -25,117 +23,59 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
23
 
26
24
  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); }
27
25
 
28
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
29
-
30
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
31
-
32
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
33
-
34
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
35
-
36
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
37
-
38
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
39
-
40
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
41
-
42
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
43
-
44
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
45
-
46
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
47
-
48
26
  const marginPropTypes = (0, _utils.filterStyledSystemMarginProps)(_propTypes2.default.space);
49
27
 
50
- let Profile = /*#__PURE__*/function (_React$Component) {
51
- _inherits(Profile, _React$Component);
52
-
53
- var _super = _createSuper(Profile);
54
-
55
- function Profile() {
56
- _classCallCheck(this, Profile);
57
-
58
- return _super.apply(this, arguments);
59
- }
60
-
61
- _createClass(Profile, [{
62
- key: "hasSrc",
63
- get:
64
- /** Determines whether a `src` prop has been supplied */
65
- function () {
66
- return Boolean(this.props.src);
67
- }
68
- /** Returns the classes for the component. */
69
-
70
- }, {
71
- key: "classes",
72
- get: function () {
73
- return (0, _classnames.default)(this.props.className);
74
- }
75
- /** Returns the initials for the name. */
76
-
77
- }, {
78
- key: "initials",
79
- get: function () {
80
- if (this.props.initials) return this.props.initials;
81
- return (0, _ether.acronymize)(this.props.name);
82
- }
83
- }, {
84
- key: "marginProps",
85
- get: function () {
86
- return (0, _utils.filterStyledSystemMarginProps)(this.props);
87
- }
88
- /** Returns the avatar portion of the profile. */
89
-
90
- }, {
91
- key: "avatar",
92
- get: function () {
93
- if (this.hasSrc) {
94
- return /*#__PURE__*/_react.default.createElement(_profile.ProfileAvatarStyle, {
95
- src: this.props.src,
96
- alt: this.initials,
97
- initials: this.initials,
98
- size: this.props.size,
99
- shape: "square",
100
- "data-element": "user-image"
101
- });
102
- }
103
-
28
+ const Profile = ({
29
+ src,
30
+ className,
31
+ initials,
32
+ name,
33
+ size,
34
+ email,
35
+ ...props
36
+ }) => {
37
+ const getInitials = () => {
38
+ if (initials) return initials;
39
+ return (0, _ether.acronymize)(name);
40
+ };
41
+
42
+ const avatar = () => {
43
+ if (src) {
104
44
  return /*#__PURE__*/_react.default.createElement(_profile.ProfileAvatarStyle, {
105
- initials: this.initials,
106
- gravatar: this.props.email,
107
- size: this.props.size
45
+ src: src,
46
+ alt: getInitials(),
47
+ initials: getInitials(),
48
+ size: size,
49
+ shape: "square",
50
+ "data-element": "user-image"
108
51
  });
109
52
  }
110
- /** Returns the text portion of the profile. */
111
-
112
- }, {
113
- key: "text",
114
- get: function () {
115
- return /*#__PURE__*/_react.default.createElement(_profile.ProfileDetailsStyle, {
116
- size: this.props.size,
117
- hasSrc: this.hasSrc
118
- }, /*#__PURE__*/_react.default.createElement(_profile.ProfileNameStyle, {
119
- size: this.props.size,
120
- "data-element": "name"
121
- }, this.props.name), /*#__PURE__*/_react.default.createElement(_profile.ProfileEmailStyle, {
122
- size: this.props.size,
123
- "data-element": "email"
124
- }, this.props.email));
125
- }
126
- }, {
127
- key: "render",
128
- value: function render() {
129
- return /*#__PURE__*/_react.default.createElement(_profile.ProfileStyle, _extends({
130
- large: this.props.large,
131
- className: this.classes,
132
- hasSrc: this.hasSrc
133
- }, (0, _tags.default)("profile", this.props), this.marginProps), this.avatar, this.text);
134
- }
135
- }]);
136
53
 
137
- return Profile;
138
- }(_react.default.Component);
54
+ return /*#__PURE__*/_react.default.createElement(_profile.ProfileAvatarStyle, {
55
+ initials: getInitials(),
56
+ gravatar: email,
57
+ size: size
58
+ });
59
+ };
60
+
61
+ const text = () => {
62
+ return /*#__PURE__*/_react.default.createElement(_profile.ProfileDetailsStyle, {
63
+ size: size,
64
+ hasSrc: !!src
65
+ }, /*#__PURE__*/_react.default.createElement(_profile.ProfileNameStyle, {
66
+ size: size,
67
+ "data-element": "name"
68
+ }, name), /*#__PURE__*/_react.default.createElement(_profile.ProfileEmailStyle, {
69
+ size: size,
70
+ "data-element": "email"
71
+ }, email));
72
+ };
73
+
74
+ return /*#__PURE__*/_react.default.createElement(_profile.ProfileStyle, _extends({
75
+ className: className,
76
+ hasSrc: !!src
77
+ }, (0, _tags.default)("profile", props), (0, _utils.filterStyledSystemMarginProps)(props)), avatar(), text());
78
+ };
139
79
 
140
80
  Profile.propTypes = { ...marginPropTypes,
141
81
 
@@ -154,14 +94,8 @@ Profile.propTypes = { ...marginPropTypes,
154
94
  /** Define initials to display if there is no Gravatar image. */
155
95
  initials: _propTypes.default.string,
156
96
 
157
- /** [Legacy] Enable a larger theme for the name. */
158
- large: _propTypes.default.bool,
159
-
160
97
  /** Allow to setup size for the component */
161
98
  size: _propTypes.default.oneOf(["XS", "S", "M", "ML", "L", "XL", "XXL"])
162
99
  };
163
- Profile.defaultProps = {
164
- large: false
165
- };
166
100
  var _default = Profile;
167
101
  exports.default = _default;
@@ -11,8 +11,6 @@ export interface ProfileProps {
11
11
  email: string;
12
12
  /** Define initials to display if there is no Gravatar image. */
13
13
  initials?: string;
14
- /** [Legacy] Enable a larger theme for the name. */
15
- large?: boolean;
16
14
  /** Allow to setup size for the component */
17
15
  size?: "XS" | "S" | "M" | "ML" | "L" | "XL" | "XXL";
18
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "87.5.0",
3
+ "version": "88.0.0",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "engineStrict": true,
6
6
  "engines": {