carbon-react 87.2.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,11 +11,13 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- const FlatTableBody = ({
14
+ const FlatTableBody = /*#__PURE__*/_react.default.forwardRef(({
15
15
  children
16
- }) => {
17
- return /*#__PURE__*/_react.default.createElement("tbody", null, children);
18
- };
16
+ }, ref) => {
17
+ return /*#__PURE__*/_react.default.createElement("tbody", {
18
+ ref: ref
19
+ }, children);
20
+ });
19
21
 
20
22
  FlatTableBody.propTypes = {
21
23
  /** Array of FlatTableRow. */
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactDnd = require("react-dnd");
11
+
12
+ var _reactDndHtml5Backend = _interopRequireDefault(require("react-dnd-html5-backend"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _icon = _interopRequireDefault(require("../../icon/icon.style"));
17
+
18
+ var _flatTableBody = _interopRequireDefault(require("../flat-table-body/flat-table-body.component"));
19
+
20
+ var _flatTableCell = _interopRequireDefault(require("../flat-table-cell/flat-table-cell.component"));
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
25
+
26
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
27
+
28
+ 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); }
29
+
30
+ const DropTarget = ({
31
+ children,
32
+ getOrder,
33
+ ...rest
34
+ }) => {
35
+ const [, drop] = (0, _reactDnd.useDrop)({
36
+ accept: "flatTableRow",
37
+
38
+ drop() {
39
+ getOrder();
40
+ }
41
+
42
+ });
43
+ return /*#__PURE__*/_react.default.createElement(_flatTableBody.default, _extends({
44
+ ref: drop
45
+ }, rest), children);
46
+ };
47
+
48
+ const FlatTableBodyDraggable = ({
49
+ children,
50
+ getOrder
51
+ }) => {
52
+ const [draggableItems, setDraggableItems] = (0, _react.useState)(_react.default.Children.toArray(children));
53
+ const isFirstRender = (0, _react.useRef)(true);
54
+ (0, _react.useEffect)(() => {
55
+ if (!isFirstRender.current) {
56
+ setDraggableItems(_react.default.Children.toArray(children));
57
+ } else {
58
+ isFirstRender.current = false;
59
+ }
60
+ }, [children]);
61
+
62
+ const findItem = id => {
63
+ const draggableItem = draggableItems.filter(item => `${item.props.id}` === id)[0];
64
+ return {
65
+ draggableItem,
66
+ index: draggableItems.indexOf(draggableItem)
67
+ };
68
+ };
69
+
70
+ const moveItem = (id, atIndex) => {
71
+ const {
72
+ draggableItem,
73
+ index
74
+ } = findItem(id);
75
+ const copyOfDraggableItems = [...draggableItems];
76
+ copyOfDraggableItems.splice(index, 1);
77
+ copyOfDraggableItems.splice(atIndex, 0, draggableItem);
78
+ setDraggableItems(copyOfDraggableItems);
79
+ };
80
+
81
+ const getItemsId = () => {
82
+ if (!getOrder) {
83
+ return;
84
+ }
85
+
86
+ const draggableItemIds = draggableItems.map(draggableItem => draggableItem.props.id);
87
+ getOrder(draggableItemIds);
88
+ };
89
+
90
+ return /*#__PURE__*/_react.default.createElement(_reactDnd.DndProvider, {
91
+ backend: _reactDndHtml5Backend.default
92
+ }, /*#__PURE__*/_react.default.createElement(DropTarget, {
93
+ getOrder: getItemsId
94
+ }, draggableItems.map(item => /*#__PURE__*/_react.default.cloneElement(item, {
95
+ id: `${item.props.id}`,
96
+ moveItem,
97
+ findItem,
98
+ draggable: true
99
+ }, [/*#__PURE__*/_react.default.createElement(_flatTableCell.default, {
100
+ key: item.props.id
101
+ }, /*#__PURE__*/_react.default.createElement(_icon.default, {
102
+ type: "drag"
103
+ })), item.props.children]))));
104
+ };
105
+
106
+ FlatTableBodyDraggable.propTypes = {
107
+ getOrder: _propTypes.default.func,
108
+ children: _propTypes.default.node.isRequired
109
+ };
110
+ DropTarget.propTypes = {
111
+ children: _propTypes.default.node.isRequired,
112
+ getOrder: _propTypes.default.func
113
+ };
114
+ var _default = FlatTableBodyDraggable;
115
+ exports.default = _default;
@@ -0,0 +1,12 @@
1
+ import * as React from "react";
2
+
3
+ export interface FlatTableBodyDraggableProps {
4
+ /** Array of FlatTableRow. */
5
+ children: React.ReactNode;
6
+ /** Callback fired when order is changed */
7
+ getOrder?: (draggableItemIds: number[]) => void;
8
+ }
9
+
10
+ declare function FlatTableBodyDraggable(props: FlatTableBodyDraggableProps): JSX.Element;
11
+
12
+ export default FlatTableBodyDraggable;
@@ -0,0 +1,2 @@
1
+ export { default } from "./flat-table-body-draggable";
2
+ export * from "./flat-table-body-draggable";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "default", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _flatTableBodyDraggable.default;
10
+ }
11
+ });
12
+
13
+ var _flatTableBodyDraggable = _interopRequireDefault(require("./flat-table-body-draggable.component"));
14
+
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactDnd = require("react-dnd");
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const FlatTableRowDraggable = ({
17
+ children,
18
+ id,
19
+ findItem,
20
+ moveItem
21
+ }) => {
22
+ const originalIndex = findItem(id).index;
23
+ const [{
24
+ isDragging
25
+ }, drag] = (0, _reactDnd.useDrag)({
26
+ item: {
27
+ type: "flatTableRow",
28
+ id,
29
+ originalIndex
30
+ },
31
+ collect: monitor => ({
32
+ isDragging: monitor.isDragging()
33
+ }),
34
+ end: (dropResult, monitor) => {
35
+ const {
36
+ id: droppedId,
37
+ originalIndex: oIndex
38
+ } = monitor.getItem();
39
+ const didDrop = monitor.didDrop();
40
+
41
+ if (!didDrop) {
42
+ moveItem(droppedId, oIndex);
43
+ }
44
+ }
45
+ });
46
+ const [, drop] = (0, _reactDnd.useDrop)({
47
+ accept: "flatTableRow",
48
+ canDrop: () => false,
49
+
50
+ hover({
51
+ id: draggedId
52
+ }) {
53
+ if (draggedId !== id) {
54
+ const {
55
+ index: overIndex
56
+ } = findItem(id);
57
+ moveItem(draggedId, overIndex);
58
+ }
59
+ }
60
+
61
+ });
62
+ return /*#__PURE__*/_react.default.cloneElement(children, {
63
+ id,
64
+ isDragging,
65
+ ref: node => drag(drop(node))
66
+ });
67
+ };
68
+
69
+ FlatTableRowDraggable.propTypes = {
70
+ /** Array of FlatTableHeader or FlatTableCell. FlatTableRowHeader could also be passed. */
71
+ children: _propTypes.default.node.isRequired,
72
+
73
+ /** ID for use in drag and drop functionality */
74
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
75
+
76
+ /** function to find an item in the list of draggable items */
77
+ findItem: _propTypes.default.func.isRequired,
78
+
79
+ /** function to reposition an item in the list of draggable items */
80
+ moveItem: _propTypes.default.func.isRequired,
81
+
82
+ /** item is draggable */
83
+ draggable: _propTypes.default.bool
84
+ };
85
+ var _default = FlatTableRowDraggable;
86
+ exports.default = _default;
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+
3
+ export interface FlatTableRowDraggableProps {
4
+ /** Array of FlatTableRow. */
5
+ children: React.ReactNode;
6
+ /** ID for use in drag and drop functionality */
7
+ id?: number | string;
8
+ /** function to find an item in the list of draggable items */
9
+ findItem: () => object;
10
+ /** function to reposition an item in the list of draggable items */
11
+ moveItem: () => void;
12
+ /** item is draggable */
13
+ draggable?: boolean;
14
+ }
15
+
16
+ declare function FlatTableRowDraggable(props: FlatTableRowDraggableProps): JSX.Element;
17
+
18
+ export default FlatTableRowDraggable;
@@ -19,6 +19,8 @@ var _flatTableCheckbox = _interopRequireDefault(require("../flat-table-checkbox"
19
19
 
20
20
  var _flatTableRowHeader = _interopRequireDefault(require("../flat-table-row-header"));
21
21
 
22
+ var _flatTableRowDraggable = _interopRequireDefault(require("./__internal__/flat-table-row-draggable.component"));
23
+
22
24
  var _flatTable = require("../flat-table.component");
23
25
 
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -44,7 +46,11 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
44
46
  bgColor,
45
47
  horizontalBorderColor,
46
48
  horizontalBorderSize = "small",
47
- applyBorderLeft
49
+ applyBorderLeft,
50
+ id,
51
+ draggable,
52
+ findItem,
53
+ moveItem
48
54
  }, ref) => {
49
55
  const [isExpanded, setIsExpanded] = (0, _react.useState)(expanded);
50
56
  const rowRef = ref || (0, _react.useRef)();
@@ -123,9 +129,8 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
123
129
  (0, _react.useEffect)(() => {
124
130
  setIsExpanded(expanded);
125
131
  }, [expanded]);
126
- return /*#__PURE__*/_react.default.createElement(_drawer.DrawerSidebarContext.Consumer, null, ({
127
- isInSidebar
128
- }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_flatTableRow.default, _extends({
132
+
133
+ const rowComponent = isInSidebar => /*#__PURE__*/_react.default.createElement(_flatTableRow.default, _extends({
129
134
  isInSidebar: isInSidebar,
130
135
  expandable: expandable,
131
136
  isSubRow: isSubRow,
@@ -143,7 +148,8 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
143
148
  bgColor: bgColor,
144
149
  horizontalBorderColor: horizontalBorderColor,
145
150
  horizontalBorderSize: horizontalBorderSize,
146
- applyBorderLeft: applyBorderLeft
151
+ applyBorderLeft: applyBorderLeft,
152
+ draggable: draggable
147
153
  }, interactiveRowProps), _react.default.Children.map(children, (child, index) => {
148
154
  return child && /*#__PURE__*/_react.default.cloneElement(child, {
149
155
  expandable: expandable && index === firstCellIndex(),
@@ -154,7 +160,17 @@ const FlatTableRow = /*#__PURE__*/_react.default.forwardRef(({
154
160
  leftPosition: leftPositions[index],
155
161
  ...child.props
156
162
  });
157
- })), isExpanded && subRows && _react.default.Children.map(subRows, (child, index) => child && /*#__PURE__*/_react.default.cloneElement(child, {
163
+ }));
164
+
165
+ const draggableComponent = isInSidebar => /*#__PURE__*/_react.default.createElement(_flatTableRowDraggable.default, {
166
+ id: id,
167
+ moveItem: moveItem,
168
+ findItem: findItem
169
+ }, rowComponent(isInSidebar));
170
+
171
+ return /*#__PURE__*/_react.default.createElement(_drawer.DrawerSidebarContext.Consumer, null, ({
172
+ isInSidebar
173
+ }) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, draggable ? draggableComponent(isInSidebar) : rowComponent(isInSidebar), isExpanded && subRows && _react.default.Children.map(subRows, (child, index) => child && /*#__PURE__*/_react.default.cloneElement(child, {
158
174
  isSubRow: true,
159
175
  isFirstSubRow: index === 0,
160
176
  ...child.props
@@ -205,7 +221,28 @@ FlatTableRow.propTypes = {
205
221
  stickyOffset: _propTypes.default.number,
206
222
 
207
223
  /** @ignore @private applies a border-left to the first child */
208
- applyBorderLeft: _propTypes.default.bool
224
+ applyBorderLeft: _propTypes.default.bool,
225
+
226
+ /** ID for use in drag and drop functionality
227
+ * @private
228
+ * @ignore
229
+ */
230
+ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
231
+
232
+ /**
233
+ * @private
234
+ * @ignore
235
+ */
236
+ findItem: _propTypes.default.func,
237
+
238
+ /**
239
+ * @private
240
+ * @ignore
241
+ */
242
+ moveItem: _propTypes.default.func,
243
+
244
+ /** @ignore @private position in header if multiple rows */
245
+ draggable: _propTypes.default.bool
209
246
  };
210
247
  var _default = FlatTableRow;
211
248
  exports.default = _default;
@@ -92,7 +92,9 @@ const StyledFlatTableRow = _styledComponents.default.tr`
92
92
  isFirstSubRow,
93
93
  size,
94
94
  theme,
95
- applyBorderLeft
95
+ applyBorderLeft,
96
+ isDragging,
97
+ draggable
96
98
  }) => {
97
99
  const backgroundColor = bgColor ? (0, _color.toColor)(theme, bgColor) : undefined;
98
100
  const customBorderColor = horizontalBorderColor ? (0, _color.toColor)(theme, horizontalBorderColor) : undefined;
@@ -123,6 +125,9 @@ const StyledFlatTableRow = _styledComponents.default.tr`
123
125
 
124
126
  ${_flatTableHeader.default} {
125
127
  border-bottom: 1px solid ${borderColor(colorTheme, theme)};
128
+ :first-child {
129
+ border-left: 1px solid ${borderColor(colorTheme, theme)};
130
+ }
126
131
  }
127
132
 
128
133
  ${stickyOffset > 0 && (0, _styledComponents.css)`
@@ -255,6 +260,21 @@ const StyledFlatTableRow = _styledComponents.default.tr`
255
260
  }
256
261
  `}
257
262
 
263
+ ${isDragging && (0, _styledComponents.css)`
264
+ border: ${isInSidebar ? theme.palette.slateTint(40) : theme.palette.slateTint(55)}
265
+ 2px solid;
266
+ cursor: grabbing;
267
+ ${allCellTypes} {
268
+ background-color: ${isInSidebar ? theme.palette.slateTint(60) : theme.palette.slateTint(75)};
269
+ }
270
+ `}
271
+
272
+ ${draggable && (0, _styledComponents.css)`
273
+ ${_icon.default}:first-of-type {
274
+ font-size: 16px;
275
+ }
276
+ `}
277
+
258
278
  ${isFirstSubRow && (0, _styledComponents.css)`
259
279
  ${allCellTypes} {
260
280
  box-shadow: inset 0 6px 4px -4px ${theme.flatTable.subRow.shadow};
@@ -5,6 +5,7 @@ export { default as FlatTable } from "./flat-table";
5
5
  export { default as FlatTableHead } from "./flat-table-head";
6
6
  export { default as FlatTableHeader } from "./flat-table-header";
7
7
  export { default as FlatTableBody } from "./flat-table-body";
8
+ export { default as FlatTableBodyDraggable } from "./flat-table-body-draggable";
8
9
  export { default as FlatTableRow } from "./flat-table-row";
9
10
  export { default as FlatTableRowHeader } from "./flat-table-row-header";
10
11
  export { default as FlatTableCell } from "./flat-table-cell";
@@ -14,6 +15,7 @@ export * from "./flat-table";
14
15
  export * from "./flat-table-head";
15
16
  export * from "./flat-table-header";
16
17
  export * from "./flat-table-body";
18
+ export * from "./flat-table-body-draggable";
17
19
  export * from "./flat-table-row";
18
20
  export * from "./flat-table-row-header";
19
21
  export * from "./flat-table-cell";
@@ -51,6 +51,12 @@ Object.defineProperty(exports, "FlatTableCheckbox", {
51
51
  return _flatTableCheckbox.default;
52
52
  }
53
53
  });
54
+ Object.defineProperty(exports, "FlatTableBodyDraggable", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _flatTableBodyDraggable.default;
58
+ }
59
+ });
54
60
  Object.defineProperty(exports, "Sort", {
55
61
  enumerable: true,
56
62
  get: function () {
@@ -74,6 +80,8 @@ var _flatTableCell = _interopRequireDefault(require("./flat-table-cell/flat-tabl
74
80
 
75
81
  var _flatTableCheckbox = _interopRequireDefault(require("./flat-table-checkbox/flat-table-checkbox.component"));
76
82
 
83
+ var _flatTableBodyDraggable = _interopRequireDefault(require("./flat-table-body-draggable/flat-table-body-draggable.component"));
84
+
77
85
  var _sort = _interopRequireDefault(require("./sort/sort.component"));
78
86
 
79
87
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -24,13 +24,17 @@ const NavigationBar = ({
24
24
  isLoading = false,
25
25
  children,
26
26
  ariaLabel,
27
+ stickyOffset = "0",
28
+ stickyPosition,
27
29
  ...props
28
30
  }) => {
29
31
  return /*#__PURE__*/_react.default.createElement(_navigationBar.default, _extends({
30
32
  role: "navigation",
31
33
  "aria-label": ariaLabel,
32
34
  navigationType: navigationType,
33
- "data-component": "navigation-bar"
35
+ "data-component": "navigation-bar",
36
+ stickyOffset: stickyOffset,
37
+ stickyPosition: stickyPosition
34
38
  }, props), !isLoading && children);
35
39
  };
36
40
 
@@ -41,11 +45,17 @@ NavigationBar.propTypes = {
41
45
  children: _propTypes.default.node,
42
46
  ariaLabel: _propTypes.default.string,
43
47
 
44
- /** color scheme of navigation component */
48
+ /** Color scheme of navigation component */
45
49
  navigationType: _propTypes.default.oneOf(["light", "dark"]),
46
50
 
47
- /** if 'true' the children will not be visible */
48
- isLoading: _propTypes.default.bool
51
+ /** If 'true' the children will not be visible */
52
+ isLoading: _propTypes.default.bool,
53
+
54
+ /** Defines the position of sticky navigation bar */
55
+ stickyPosition: _propTypes.default.oneOf(["top", "bottom"]),
56
+
57
+ /** Defines the offset of sticky navigation bar */
58
+ stickyOffset: _propTypes.default.string
49
59
  };
50
60
  var _default = NavigationBar;
51
61
  exports.default = _default;
@@ -7,6 +7,8 @@ export interface NavigationBarProp extends SpaceProps {
7
7
  ariaLabel?: string;
8
8
  navigationType?: "light" | "dark";
9
9
  isLoading?: boolean;
10
+ stickyPosition?: "top" | "bottom";
11
+ stickyOffset?: string;
10
12
  }
11
13
 
12
14
  declare function NavigationBar(props: NavigationBarProp): JSX.Element;
@@ -49,6 +49,14 @@ const StyledNavigationBar = _styledComponents.default.nav`
49
49
  margin-right: 10px;
50
50
  }
51
51
 
52
+ ${({
53
+ stickyPosition,
54
+ stickyOffset
55
+ }) => stickyPosition && (0, _styledComponents.css)`
56
+ position: sticky;
57
+ ${stickyPosition}: ${stickyOffset}
58
+ `};
59
+
52
60
  ${({
53
61
  navigationType,
54
62
  theme
@@ -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
  }
@@ -56,6 +56,7 @@ const TileSelect = ({
56
56
  actionButtonAdornment,
57
57
  footer,
58
58
  prefixAdornment,
59
+ additionalInformation,
59
60
  ...rest
60
61
  }) => {
61
62
  const l = (0, _useLocale.default)();
@@ -125,7 +126,9 @@ const TileSelect = ({
125
126
  mr: 3
126
127
  }, prefixAdornment), /*#__PURE__*/_react.default.createElement(_box.default, {
127
128
  flexGrow: "1"
128
- }, /*#__PURE__*/_react.default.createElement(_tileSelect.StyledTitleContainer, null, title && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledTitle, checkPropTypeIsNode(title), title), subtitle && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledSubtitle, checkPropTypeIsNode(subtitle), subtitle), titleAdornment && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledAdornment, null, titleAdornment)), /*#__PURE__*/_react.default.createElement(_tileSelect.StyledDescription, checkPropTypeIsNode(description), description), footer && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledFooterWrapper, null, footer)), (customActionButton || checked) && renderActionButton()))));
129
+ }, /*#__PURE__*/_react.default.createElement(_tileSelect.StyledTitleContainer, null, title && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledTitle, checkPropTypeIsNode(title), title), subtitle && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledSubtitle, checkPropTypeIsNode(subtitle), subtitle), titleAdornment && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledAdornment, {
130
+ hasAdditionalInformation: !!additionalInformation
131
+ }, titleAdornment)), additionalInformation && /*#__PURE__*/_react.default.createElement("div", null, additionalInformation), /*#__PURE__*/_react.default.createElement(_tileSelect.StyledDescription, checkPropTypeIsNode(description), description), footer && /*#__PURE__*/_react.default.createElement(_tileSelect.StyledFooterWrapper, null, footer)), (customActionButton || checked) && renderActionButton()))));
129
132
  };
130
133
 
131
134
  TileSelect.defaultProps = {
@@ -186,7 +189,10 @@ TileSelect.propTypes = { ...marginPropTypes,
186
189
  footer: _propTypes.default.node,
187
190
 
188
191
  /** Component to render in the top left corner of TileSelect */
189
- prefixAdornment: _propTypes.default.node
192
+ prefixAdornment: _propTypes.default.node,
193
+
194
+ /** Component to render additional information row between title and description */
195
+ additionalInformation: _propTypes.default.node
190
196
  };
191
197
  TileSelect.displayName = "TileSelect";
192
198
  var _default = TileSelect;
@@ -36,6 +36,8 @@ export interface TileSelectProps extends MarginProps {
36
36
  footer?: React.ReactNode;
37
37
  /** Component to render in the top left corner of TileSelect */
38
38
  prefixAdornment?: React.ReactNode;
39
+ /** Component to render additional information row between title and description */
40
+ additionalInformation?: React.ReactNode;
39
41
  }
40
42
 
41
43
  declare function TileSelect(props: TileSelectProps): JSX.Element;
@@ -45,7 +45,9 @@ const StyledSubtitle = _styledComponents.default.h4`
45
45
  exports.StyledSubtitle = StyledSubtitle;
46
46
  const StyledAdornment = _styledComponents.default.div`
47
47
  z-index: 500;
48
- margin-bottom: 8px;
48
+ margin-bottom: ${({
49
+ hasAdditionalInformation
50
+ }) => hasAdditionalInformation ? "4" : "8"}px;
49
51
  `;
50
52
  exports.StyledAdornment = StyledAdornment;
51
53
  const StyledDescription = _styledComponents.default.p`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "87.2.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": {