carbon-react 93.0.4 → 94.0.3

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.
Files changed (81) hide show
  1. package/lib/__internal__/checkable-input/checkable-input.component.js +7 -1
  2. package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +11 -1
  3. package/lib/__internal__/checkable-input/hidden-checkable-input.d.ts +5 -1
  4. package/lib/__internal__/form-field/form-field.component.js +9 -8
  5. package/lib/__internal__/form-field/form-field.d.ts +2 -0
  6. package/lib/components/action-popover/action-popover.component.js +28 -20
  7. package/lib/components/action-popover/action-popover.style.js +22 -12
  8. package/lib/components/i18n-provider/i18n-provider.component.js +0 -3
  9. package/lib/locales/en-gb.js +1 -8
  10. package/lib/locales/locale.d.ts +0 -7
  11. package/lib/locales/pl-pl.js +1 -8
  12. package/package.json +1 -6
  13. package/lib/components/action-toolbar/action-toolbar.component.js +0 -213
  14. package/lib/components/action-toolbar/action-toolbar.d.ts +0 -20
  15. package/lib/components/action-toolbar/action-toolbar.style.js +0 -40
  16. package/lib/components/action-toolbar/index.d.ts +0 -1
  17. package/lib/components/action-toolbar/index.js +0 -15
  18. package/lib/components/configurable-items/configurable-item-row/configurable-item-row.component.js +0 -174
  19. package/lib/components/configurable-items/configurable-item-row/configurable-item-row.d.ts +0 -25
  20. package/lib/components/configurable-items/configurable-item-row/configurable-item-row.style.js +0 -73
  21. package/lib/components/configurable-items/configurable-item-row/index.d.ts +0 -1
  22. package/lib/components/configurable-items/configurable-item-row/index.js +0 -15
  23. package/lib/components/configurable-items/configurable-items.component.js +0 -155
  24. package/lib/components/configurable-items/configurable-items.d.ts +0 -20
  25. package/lib/components/configurable-items/configurable-items.style.js +0 -70
  26. package/lib/components/configurable-items/index.d.ts +0 -2
  27. package/lib/components/configurable-items/index.js +0 -23
  28. package/lib/components/drag-and-drop/__internal__/item-target/index.js +0 -15
  29. package/lib/components/drag-and-drop/__internal__/item-target/item-target.js +0 -44
  30. package/lib/components/drag-and-drop/__internal__/item-types/index.js +0 -15
  31. package/lib/components/drag-and-drop/__internal__/item-types/item-types.js +0 -20
  32. package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.js +0 -171
  33. package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.style.js +0 -28
  34. package/lib/components/drag-and-drop/custom-drag-layer/index.js +0 -15
  35. package/lib/components/drag-and-drop/drag-and-drop-test.stories.js +0 -95
  36. package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/index.js +0 -15
  37. package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/scrollable-parent.js +0 -36
  38. package/lib/components/drag-and-drop/draggable-context/draggable-context.js +0 -264
  39. package/lib/components/drag-and-drop/draggable-context/index.js +0 -15
  40. package/lib/components/drag-and-drop/index.js +0 -39
  41. package/lib/components/drag-and-drop/with-drag/index.js +0 -15
  42. package/lib/components/drag-and-drop/with-drag/with-drag.js +0 -176
  43. package/lib/components/drag-and-drop/with-drop/index.js +0 -15
  44. package/lib/components/drag-and-drop/with-drop/with-drop.js +0 -201
  45. package/lib/components/table/draggable-table-cell/draggable-table-cell.component.js +0 -59
  46. package/lib/components/table/draggable-table-cell/draggable-table-cell.style.js +0 -36
  47. package/lib/components/table/draggable-table-cell/index.js +0 -15
  48. package/lib/components/table/index.js +0 -43
  49. package/lib/components/table/table-cell/index.js +0 -15
  50. package/lib/components/table/table-cell/table-cell.component.js +0 -164
  51. package/lib/components/table/table-cell/table-cell.style.js +0 -164
  52. package/lib/components/table/table-header/index.js +0 -15
  53. package/lib/components/table/table-header/table-header.component.js +0 -282
  54. package/lib/components/table/table-header/table-header.style.js +0 -116
  55. package/lib/components/table/table-modern.style.js +0 -110
  56. package/lib/components/table/table-row/index.js +0 -15
  57. package/lib/components/table/table-row/table-row-modern.style.js +0 -70
  58. package/lib/components/table/table-row/table-row.component.js +0 -486
  59. package/lib/components/table/table-row/table-row.style.js +0 -165
  60. package/lib/components/table/table-sizes.style.js +0 -33
  61. package/lib/components/table/table-story-helpers/table-story-wrapper.component.js +0 -189
  62. package/lib/components/table/table-subheader/index.js +0 -15
  63. package/lib/components/table/table-subheader/table-subheader.component.js +0 -35
  64. package/lib/components/table/table-subheader/table-subheader.style.js +0 -33
  65. package/lib/components/table/table.component.js +0 -792
  66. package/lib/components/table/table.config.js +0 -14
  67. package/lib/components/table/table.style.js +0 -139
  68. package/lib/components/table-ajax/__internal__/serialize/package.json +0 -3
  69. package/lib/components/table-ajax/__internal__/serialize/serialize.js +0 -26
  70. package/lib/components/table-ajax/index.js +0 -37
  71. package/lib/components/table-ajax/table-ajax.component.js +0 -602
  72. package/lib/patterns/configurable-items/actions/actions.js +0 -41
  73. package/lib/patterns/configurable-items/actions/package.json +0 -3
  74. package/lib/patterns/configurable-items/configurable-items-content/configurable-items-content.js +0 -140
  75. package/lib/patterns/configurable-items/configurable-items-content/package.json +0 -3
  76. package/lib/patterns/configurable-items/configurable-items.js +0 -216
  77. package/lib/patterns/configurable-items/constants/constants.js +0 -13
  78. package/lib/patterns/configurable-items/constants/package.json +0 -3
  79. package/lib/patterns/configurable-items/package.json +0 -3
  80. package/lib/patterns/configurable-items/store/package.json +0 -3
  81. package/lib/patterns/configurable-items/store/store.js +0 -92
@@ -1,201 +0,0 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _reactDndLegacy = require("react-dnd-legacy");
13
-
14
- var _itemTypes = _interopRequireDefault(require("../__internal__/item-types"));
15
-
16
- var _browser = _interopRequireDefault(require("../../../__internal__/utils/helpers/browser"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
-
22
- 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); } }
23
-
24
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
25
-
26
- 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); }
27
-
28
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
29
-
30
- 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); }; }
31
-
32
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
33
-
34
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
35
-
36
- 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; } }
37
-
38
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
39
-
40
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
41
-
42
- let WithDrop = /*#__PURE__*/function (_React$Component) {
43
- _inherits(WithDrop, _React$Component);
44
-
45
- var _super = _createSuper(WithDrop);
46
-
47
- function WithDrop(...args) {
48
- var _this;
49
-
50
- _classCallCheck(this, WithDrop);
51
-
52
- _this = _super.call(this, ...args);
53
-
54
- _defineProperty(_assertThisInitialized(_this), "state", {
55
- isDraggedElementOver: false,
56
- inDeadZone: false
57
- });
58
-
59
- return _this;
60
- }
61
-
62
- _createClass(WithDrop, [{
63
- key: "UNSAFE_componentWillReceiveProps",
64
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
65
- // eslint-disable-next-line react/prop-types
66
- if (!this.props.isOver && nextProps.isOver) {
67
- // Equivalent of `mouseover` / `mouseenter`
68
- this.setState({
69
- isDraggedElementOver: true
70
- });
71
- } // eslint-disable-next-line react/prop-types
72
-
73
-
74
- if (this.props.isOver && !nextProps.isOver) {
75
- // Equivalent of `mouseout` / `mouseleave`
76
- this.setState({
77
- isDraggedElementOver: false
78
- });
79
- }
80
-
81
- if (this.props.didDrop) {
82
- this.setState({
83
- inDeadZone: false
84
- });
85
- }
86
- }
87
- }, {
88
- key: "render",
89
- value: function render() {
90
- // this.props.connectDragSource comes from react-dnd DragSource higher
91
- // order component, so disable the react/prop-types ESLint rule on the line
92
- // below
93
- const {
94
- children,
95
- connectDropTarget,
96
- droppableNode
97
- } = this.props; // eslint-disable-line react/prop-types
98
-
99
- const childrenWithProps = /*#__PURE__*/_react.default.cloneElement(children, {
100
- isDraggedElementOver: this.state.isDraggedElementOver,
101
- inDeadZone: this.state.inDeadZone
102
- });
103
-
104
- if (droppableNode) {
105
- connectDropTarget(droppableNode());
106
- return childrenWithProps;
107
- }
108
-
109
- return connectDropTarget(childrenWithProps);
110
- }
111
- }]);
112
-
113
- return WithDrop;
114
- }(_react.default.Component);
115
-
116
- WithDrop.propTypes = {
117
- /**
118
- * The component that will have drop enabled
119
- */
120
- children: _propTypes.default.node.isRequired,
121
- // The following prop types are required by react-dnd,
122
- // and aren't used in this component directly. Therefore
123
- // disable the ESLint rule react/no-unused-prop-types
124
-
125
- /* eslint-disable react/no-unused-prop-types */
126
-
127
- /**
128
- * @private
129
- * @ignore
130
- */
131
- identifier: _propTypes.default.string,
132
- // identifies an association between WithDrag and WithDrop
133
-
134
- /**
135
- * @private
136
- * @ignore
137
- */
138
- index: _propTypes.default.number.isRequired,
139
- // identifies the index for this item
140
-
141
- /**
142
- * @private
143
- * @ignore
144
- */
145
- hover: _propTypes.default.func,
146
- // an optional callback to trigger when the item is hovered
147
-
148
- /**
149
- * @private
150
- * @ignore
151
- */
152
- onDrag: _propTypes.default.func,
153
- // an optional callback to trigger when dragging occurs
154
-
155
- /**
156
- * @private
157
- * @ignore
158
- */
159
- canDrop: _propTypes.default.func,
160
- // an optional callback to determine if this item can be dropped on
161
-
162
- /* eslint-enable react/no-unused-prop-types */
163
-
164
- /**
165
- * @private
166
- * @ignore
167
- */
168
- didDrop: _propTypes.default.func
169
- };
170
- WithDrop.contextTypes = {
171
- dragAndDropOnDrag: _propTypes.default.func,
172
- dragAndDropHover: _propTypes.default.func
173
- };
174
- const ItemTarget = {
175
- canDrop(props, monitor) {
176
- return props.canDrop ? props.canDrop(props, monitor) : true;
177
- },
178
-
179
- hover(props, monitor, component) {
180
- if (!monitor.canDrop()) return false;
181
- clearSelection();
182
- const hover = props.hover || component.context.dragAndDropHover;
183
- return hover(props, monitor, component);
184
- }
185
-
186
- };
187
-
188
- function clearSelection() {
189
- const window = _browser.default.getWindow();
190
-
191
- window.getSelection().removeAllRanges();
192
- } // eslint-disable-next-line no-class-assign
193
-
194
-
195
- WithDrop = (0, _reactDndLegacy.DropTarget)(_itemTypes.default.getItemType, ItemTarget, (connect, monitor) => ({
196
- isOver: monitor.isOver(),
197
- connectDropTarget: connect.dropTarget(),
198
- didDrop: monitor.didDrop()
199
- }))(WithDrop);
200
- var _default = WithDrop;
201
- exports.default = _default;
@@ -1,59 +0,0 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _withDrag = _interopRequireDefault(require("../../drag-and-drop/with-drag"));
13
-
14
- var _icon = _interopRequireDefault(require("../../icon"));
15
-
16
- var _draggableTableCell = _interopRequireDefault(require("./draggable-table-cell.style"));
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- /**
21
- * Creates a draggable table cell using WithDrag.
22
- *
23
- */
24
- const DraggableTableCell = props => {
25
- const canDrag = props.canDrag !== false;
26
- /**
27
- * Note: the <div> wrapper is required, otherwise ReactDnD throws an error:
28
- * "Only native element nodes can now be passed to ReactDnD connectors."
29
- */
30
-
31
- const icon = /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_icon.default, {
32
- type: "drag"
33
- }));
34
-
35
- const iconWithDrag = /*#__PURE__*/_react.default.createElement(_withDrag.default, {
36
- identifier: props.identifier,
37
- draggableNode: props.draggableNode,
38
- canDrag: () => {
39
- return canDrag;
40
- }
41
- }, canDrag ? icon : /*#__PURE__*/_react.default.createElement("span", null));
42
-
43
- return /*#__PURE__*/_react.default.createElement(_draggableTableCell.default, {
44
- className: "draggable-table-cell"
45
- }, iconWithDrag);
46
- };
47
-
48
- DraggableTableCell.propTypes = {
49
- /** used to associate WithDrags and WithDrops */
50
- identifier: _propTypes.default.string,
51
-
52
- /** A function that returns the dom node used as the ghost layer when dragging */
53
- draggableNode: _propTypes.default.func,
54
-
55
- /** used to specify whether the dragging is currently allowed */
56
- canDrag: _propTypes.default.bool
57
- };
58
- var _default = DraggableTableCell;
59
- exports.default = _default;
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _styledComponents = _interopRequireDefault(require("styled-components"));
9
-
10
- var _tableCell = _interopRequireDefault(require("../table-cell/table-cell.style"));
11
-
12
- var _icon = _interopRequireDefault(require("../../icon/icon.style"));
13
-
14
- var _base = _interopRequireDefault(require("../../../style/themes/base"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- const StyledDraggableTableCell = (0, _styledComponents.default)(_tableCell.default)`
19
- padding: 0;
20
- width: 21px;
21
- user-select: none;
22
-
23
- ${_tableCell.default}:first-child {
24
- padding-left: 0;
25
- }
26
-
27
- ${_icon.default} {
28
- cursor: move;
29
- cursor: grab;
30
- }
31
- `;
32
- StyledDraggableTableCell.defaultProps = {
33
- theme: _base.default
34
- };
35
- var _default = StyledDraggableTableCell;
36
- exports.default = _default;
@@ -1,15 +0,0 @@
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 _draggableTableCell.default;
10
- }
11
- });
12
-
13
- var _draggableTableCell = _interopRequireDefault(require("./draggable-table-cell.component"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "Table", {
7
- enumerable: true,
8
- get: function () {
9
- return _table.Table;
10
- }
11
- });
12
- Object.defineProperty(exports, "TableRow", {
13
- enumerable: true,
14
- get: function () {
15
- return _table.TableRow;
16
- }
17
- });
18
- Object.defineProperty(exports, "TableCell", {
19
- enumerable: true,
20
- get: function () {
21
- return _table.TableCell;
22
- }
23
- });
24
- Object.defineProperty(exports, "TableHeader", {
25
- enumerable: true,
26
- get: function () {
27
- return _table.TableHeader;
28
- }
29
- });
30
- Object.defineProperty(exports, "TableSubheader", {
31
- enumerable: true,
32
- get: function () {
33
- return _table.TableSubheader;
34
- }
35
- });
36
- Object.defineProperty(exports, "DraggableTableCell", {
37
- enumerable: true,
38
- get: function () {
39
- return _table.DraggableTableCell;
40
- }
41
- });
42
-
43
- var _table = require("./table.component");
@@ -1,15 +0,0 @@
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 _tableCell.default;
10
- }
11
- });
12
-
13
- var _tableCell = _interopRequireDefault(require("./table-cell.component"));
14
-
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -1,164 +0,0 @@
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 _propTypes = _interopRequireDefault(require("prop-types"));
11
-
12
- var _tableCell = _interopRequireDefault(require("./table-cell.style"));
13
-
14
- var _date = _interopRequireDefault(require("../../date"));
15
-
16
- var _textarea = _interopRequireDefault(require("../../textarea"));
17
-
18
- var _ether = require("../../../__internal__/utils/ether");
19
-
20
- var _tags = _interopRequireDefault(require("../../../__internal__/utils/helpers/tags/tags"));
21
-
22
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
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); }
25
-
26
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
27
-
28
- 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); } }
29
-
30
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
31
-
32
- 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); }
33
-
34
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
35
-
36
- 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); }; }
37
-
38
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
39
-
40
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
-
42
- 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; } }
43
-
44
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
45
-
46
- /**
47
- * A TableCell widget.
48
- *
49
- * == How to use a TableCell in a component:
50
- *
51
- * See documentation for Table component.
52
- *
53
- * You can set a property of 'align' which should be a string. This will
54
- * align the content to either "left", "center" or "right".
55
- *
56
- * You can set a property of 'action' which should be a boolean. This will
57
- * set styling options for the cell used for action such as delete.
58
- */
59
- let TableCell = /*#__PURE__*/function (_React$Component) {
60
- _inherits(TableCell, _React$Component);
61
-
62
- var _super = _createSuper(TableCell);
63
-
64
- function TableCell() {
65
- _classCallCheck(this, TableCell);
66
-
67
- return _super.apply(this, arguments);
68
- }
69
-
70
- _createClass(TableCell, [{
71
- key: "childName",
72
- value:
73
- /**
74
- * Returns the child's name if there is one.
75
- */
76
- function childName(child) {
77
- return child && child.type ? child.type.name : null;
78
- }
79
- /**
80
- * Returns if child element is Textarea.
81
- */
82
-
83
- }, {
84
- key: "checkChildrenInputType",
85
- get: function () {
86
- const {
87
- children
88
- } = this.props;
89
- const TYPES = {
90
- isTextArea: "isTextArea",
91
- isDate: "isDate"
92
- };
93
-
94
- if (!Array.isArray(children)) {
95
- if (this.childName(children) === _textarea.default.name) {
96
- return TYPES.isTextArea;
97
- }
98
-
99
- if (this.childName(children) === _date.default.name) {
100
- return TYPES.isDate;
101
- }
102
-
103
- return null;
104
- }
105
-
106
- let result = null;
107
- children.forEach(child => {
108
- if (this.childName(child) === _date.default.name) {
109
- result = result !== TYPES.isTextArea ? TYPES.isDate : result;
110
- }
111
-
112
- if (this.childName(child) === _textarea.default.name) {
113
- result = TYPES.isTextArea;
114
- }
115
- });
116
- return result;
117
- }
118
- /**
119
- * Returns props to be used on the TD element.
120
- */
121
-
122
- }, {
123
- key: "tableCellProps",
124
- get: function () {
125
- const {
126
- children,
127
- ...props
128
- } = (0, _ether.validProps)(this, ["align", "size"]);
129
- const inputType = this.checkChildrenInputType;
130
- if (inputType) props[inputType] = true;
131
- return props;
132
- }
133
- /**
134
- * Renders the component.
135
- */
136
-
137
- }, {
138
- key: "render",
139
- value: function render() {
140
- return /*#__PURE__*/_react.default.createElement(_tableCell.default, _extends({}, this.tableCellProps, (0, _tags.default)("table-cell", this.props)), this.props.children);
141
- }
142
- }]);
143
-
144
- return TableCell;
145
- }(_react.default.Component);
146
-
147
- TableCell.propTypes = {
148
- /** Defines the cell type to be an action - used for the delete cell. */
149
- action: _propTypes.default.bool,
150
-
151
- /** Defines the alignment of the cell (eg "left", "center" or "right"). */
152
- align: _propTypes.default.oneOf(["center", "left", "right"]),
153
-
154
- /** Children elements */
155
- children: _propTypes.default.node,
156
-
157
- /** Defines the height of a cell used to size an input for example */
158
- size: _propTypes.default.oneOf(["compact", "small", "medium", "large"])
159
- };
160
- TableCell.defaultProps = {
161
- align: "left"
162
- };
163
- var _default = TableCell;
164
- exports.default = _default;