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.
- package/lib/__internal__/checkable-input/checkable-input.component.js +7 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +11 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.d.ts +5 -1
- package/lib/__internal__/form-field/form-field.component.js +9 -8
- package/lib/__internal__/form-field/form-field.d.ts +2 -0
- package/lib/components/action-popover/action-popover.component.js +28 -20
- package/lib/components/action-popover/action-popover.style.js +22 -12
- package/lib/components/i18n-provider/i18n-provider.component.js +0 -3
- package/lib/locales/en-gb.js +1 -8
- package/lib/locales/locale.d.ts +0 -7
- package/lib/locales/pl-pl.js +1 -8
- package/package.json +1 -6
- package/lib/components/action-toolbar/action-toolbar.component.js +0 -213
- package/lib/components/action-toolbar/action-toolbar.d.ts +0 -20
- package/lib/components/action-toolbar/action-toolbar.style.js +0 -40
- package/lib/components/action-toolbar/index.d.ts +0 -1
- package/lib/components/action-toolbar/index.js +0 -15
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.component.js +0 -174
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.d.ts +0 -25
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.style.js +0 -73
- package/lib/components/configurable-items/configurable-item-row/index.d.ts +0 -1
- package/lib/components/configurable-items/configurable-item-row/index.js +0 -15
- package/lib/components/configurable-items/configurable-items.component.js +0 -155
- package/lib/components/configurable-items/configurable-items.d.ts +0 -20
- package/lib/components/configurable-items/configurable-items.style.js +0 -70
- package/lib/components/configurable-items/index.d.ts +0 -2
- package/lib/components/configurable-items/index.js +0 -23
- package/lib/components/drag-and-drop/__internal__/item-target/index.js +0 -15
- package/lib/components/drag-and-drop/__internal__/item-target/item-target.js +0 -44
- package/lib/components/drag-and-drop/__internal__/item-types/index.js +0 -15
- package/lib/components/drag-and-drop/__internal__/item-types/item-types.js +0 -20
- package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.js +0 -171
- package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.style.js +0 -28
- package/lib/components/drag-and-drop/custom-drag-layer/index.js +0 -15
- package/lib/components/drag-and-drop/drag-and-drop-test.stories.js +0 -95
- package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/index.js +0 -15
- package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/scrollable-parent.js +0 -36
- package/lib/components/drag-and-drop/draggable-context/draggable-context.js +0 -264
- package/lib/components/drag-and-drop/draggable-context/index.js +0 -15
- package/lib/components/drag-and-drop/index.js +0 -39
- package/lib/components/drag-and-drop/with-drag/index.js +0 -15
- package/lib/components/drag-and-drop/with-drag/with-drag.js +0 -176
- package/lib/components/drag-and-drop/with-drop/index.js +0 -15
- package/lib/components/drag-and-drop/with-drop/with-drop.js +0 -201
- package/lib/components/table/draggable-table-cell/draggable-table-cell.component.js +0 -59
- package/lib/components/table/draggable-table-cell/draggable-table-cell.style.js +0 -36
- package/lib/components/table/draggable-table-cell/index.js +0 -15
- package/lib/components/table/index.js +0 -43
- package/lib/components/table/table-cell/index.js +0 -15
- package/lib/components/table/table-cell/table-cell.component.js +0 -164
- package/lib/components/table/table-cell/table-cell.style.js +0 -164
- package/lib/components/table/table-header/index.js +0 -15
- package/lib/components/table/table-header/table-header.component.js +0 -282
- package/lib/components/table/table-header/table-header.style.js +0 -116
- package/lib/components/table/table-modern.style.js +0 -110
- package/lib/components/table/table-row/index.js +0 -15
- package/lib/components/table/table-row/table-row-modern.style.js +0 -70
- package/lib/components/table/table-row/table-row.component.js +0 -486
- package/lib/components/table/table-row/table-row.style.js +0 -165
- package/lib/components/table/table-sizes.style.js +0 -33
- package/lib/components/table/table-story-helpers/table-story-wrapper.component.js +0 -189
- package/lib/components/table/table-subheader/index.js +0 -15
- package/lib/components/table/table-subheader/table-subheader.component.js +0 -35
- package/lib/components/table/table-subheader/table-subheader.style.js +0 -33
- package/lib/components/table/table.component.js +0 -792
- package/lib/components/table/table.config.js +0 -14
- package/lib/components/table/table.style.js +0 -139
- package/lib/components/table-ajax/__internal__/serialize/package.json +0 -3
- package/lib/components/table-ajax/__internal__/serialize/serialize.js +0 -26
- package/lib/components/table-ajax/index.js +0 -37
- package/lib/components/table-ajax/table-ajax.component.js +0 -602
- package/lib/patterns/configurable-items/actions/actions.js +0 -41
- package/lib/patterns/configurable-items/actions/package.json +0 -3
- package/lib/patterns/configurable-items/configurable-items-content/configurable-items-content.js +0 -140
- package/lib/patterns/configurable-items/configurable-items-content/package.json +0 -3
- package/lib/patterns/configurable-items/configurable-items.js +0 -216
- package/lib/patterns/configurable-items/constants/constants.js +0 -13
- package/lib/patterns/configurable-items/constants/package.json +0 -3
- package/lib/patterns/configurable-items/package.json +0 -3
- package/lib/patterns/configurable-items/store/package.json +0 -3
- package/lib/patterns/configurable-items/store/store.js +0 -92
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyModernRowStyling = applyModernRowStyling;
|
|
7
|
-
exports.applyModernSelectedStyling = applyModernSelectedStyling;
|
|
8
|
-
exports.applyModernDropTargetStyling = applyModernDropTargetStyling;
|
|
9
|
-
|
|
10
|
-
var _styledComponents = require("styled-components");
|
|
11
|
-
|
|
12
|
-
var _tableCell = _interopRequireDefault(require("../table-cell/table-cell.style"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function applyModernRowStyling({
|
|
17
|
-
theme: {
|
|
18
|
-
colors,
|
|
19
|
-
table
|
|
20
|
-
},
|
|
21
|
-
isPassive
|
|
22
|
-
}) {
|
|
23
|
-
return (0, _styledComponents.css)`
|
|
24
|
-
${_tableCell.default} {
|
|
25
|
-
background-color: ${colors.white};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.custom-drag-layer && {
|
|
29
|
-
background-color: ${table.dragging};
|
|
30
|
-
display: block;
|
|
31
|
-
|
|
32
|
-
${_tableCell.default} {
|
|
33
|
-
background-color: ${table.dragging};
|
|
34
|
-
border: none;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
${!isPassive && (0, _styledComponents.css)`
|
|
39
|
-
&:hover {
|
|
40
|
-
${_tableCell.default} {
|
|
41
|
-
background-color: ${table.primary};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
`}
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function applyModernSelectedStyling({
|
|
49
|
-
table
|
|
50
|
-
}) {
|
|
51
|
-
return `
|
|
52
|
-
background-color: ${table.selected};
|
|
53
|
-
border-bottom-color: ${table.selected};
|
|
54
|
-
`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function applyModernDropTargetStyling() {
|
|
58
|
-
const border = "1px solid transparent";
|
|
59
|
-
return (0, _styledComponents.css)`
|
|
60
|
-
border-top: ${border};
|
|
61
|
-
|
|
62
|
-
&:first-child {
|
|
63
|
-
border-left: ${border};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
&:last-child {
|
|
67
|
-
border-right: ${border};
|
|
68
|
-
}
|
|
69
|
-
`;
|
|
70
|
-
}
|
|
@@ -1,486 +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"));
|
|
13
|
-
|
|
14
|
-
var _tableHeader = _interopRequireDefault(require("../table-header"));
|
|
15
|
-
|
|
16
|
-
var _checkbox = require("../../checkbox");
|
|
17
|
-
|
|
18
|
-
var _guid = _interopRequireDefault(require("../../../__internal__/utils/helpers/guid"));
|
|
19
|
-
|
|
20
|
-
var _withDrop = _interopRequireDefault(require("../../drag-and-drop/with-drop"));
|
|
21
|
-
|
|
22
|
-
var _draggableTableCell = _interopRequireDefault(require("../draggable-table-cell"));
|
|
23
|
-
|
|
24
|
-
var _tableRow = _interopRequireDefault(require("./table-row.style"));
|
|
25
|
-
|
|
26
|
-
var _ether = require("../../../__internal__/utils/ether");
|
|
27
|
-
|
|
28
|
-
var _tags = _interopRequireDefault(require("../../../__internal__/utils/helpers/tags/tags"));
|
|
29
|
-
|
|
30
|
-
var _actionPopover = require("../../action-popover");
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
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); }
|
|
35
|
-
|
|
36
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
|
|
38
|
-
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); } }
|
|
39
|
-
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
41
|
-
|
|
42
|
-
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); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
-
|
|
46
|
-
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); }; }
|
|
47
|
-
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
49
|
-
|
|
50
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
51
|
-
|
|
52
|
-
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; } }
|
|
53
|
-
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
56
|
-
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; }
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A TableRow widget.
|
|
60
|
-
*
|
|
61
|
-
* == How to use a TableRow in a component:
|
|
62
|
-
*
|
|
63
|
-
* See documentation for Table component.
|
|
64
|
-
*
|
|
65
|
-
* If you add an onClick event to a Table Row, will display the cursor as a pointer
|
|
66
|
-
* when hovering over the row.
|
|
67
|
-
*/
|
|
68
|
-
let TableRow = /*#__PURE__*/function (_React$Component) {
|
|
69
|
-
_inherits(TableRow, _React$Component);
|
|
70
|
-
|
|
71
|
-
var _super = _createSuper(TableRow);
|
|
72
|
-
|
|
73
|
-
function TableRow(props) {
|
|
74
|
-
var _this;
|
|
75
|
-
|
|
76
|
-
_classCallCheck(this, TableRow);
|
|
77
|
-
|
|
78
|
-
_this = _super.call(this, props);
|
|
79
|
-
|
|
80
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
81
|
-
/**
|
|
82
|
-
* Internal state to store this table row's DOM node (for drag-and-drop functionality).
|
|
83
|
-
*/
|
|
84
|
-
rowNode: null,
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Internal state to track if the row is currently highlighted.
|
|
88
|
-
*/
|
|
89
|
-
highlighted: false,
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Internal state to track if the row is currently selected.
|
|
93
|
-
*/
|
|
94
|
-
selected: false
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
_defineProperty(_assertThisInitialized(_this), "onSelectAll", () => {
|
|
98
|
-
_this.context.selectAll(_assertThisInitialized(_this));
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
_defineProperty(_assertThisInitialized(_this), "onRowClick", (...args) => {
|
|
102
|
-
if (_this.props.onHighlight) {
|
|
103
|
-
// trigger onHighlight callback if defined
|
|
104
|
-
_this.props.onHighlight(_this.props.uniqueID, !_this.state.highlighted, _assertThisInitialized(_this));
|
|
105
|
-
} else {
|
|
106
|
-
// trigger highlightRow method on the table
|
|
107
|
-
_this.context.highlightRow(_this.props.uniqueID, _assertThisInitialized(_this));
|
|
108
|
-
} // trigger any custom onClick event the developer may have set
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (_this.props.onClick) {
|
|
112
|
-
_this.props.onClick(...args);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
_defineProperty(_assertThisInitialized(_this), "onSelect", ev => {
|
|
117
|
-
if (_this.props.onSelect) {
|
|
118
|
-
// trigger onSelect callback if defined
|
|
119
|
-
_this.props.onSelect(_this.props.uniqueID, ev.target.value, _assertThisInitialized(_this));
|
|
120
|
-
} else {
|
|
121
|
-
// trigger selectRow method on the table
|
|
122
|
-
_this.context.selectRow(_this.props.uniqueID, _assertThisInitialized(_this), !_this.state.selected);
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
_defineProperty(_assertThisInitialized(_this), "draggingIsOccurring", () => {
|
|
127
|
-
return typeof _this.context.dragAndDropActiveIndex === "number";
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
_defineProperty(_assertThisInitialized(_this), "renderDraggableCell", () => {
|
|
131
|
-
if (!_this.context.dragDropManager || _this.isHeader) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return /*#__PURE__*/_react.default.createElement(_draggableTableCell.default, {
|
|
136
|
-
identifier: _this.props.dragAndDropIdentifier,
|
|
137
|
-
draggableNode: () => {
|
|
138
|
-
return _this.state.rowNode;
|
|
139
|
-
},
|
|
140
|
-
canDrag: !_this.props.hideDrag
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
_defineProperty(_assertThisInitialized(_this), "renderDraggableRow", row => {
|
|
145
|
-
if (!_this.context.dragDropManager || _this.isHeader) {
|
|
146
|
-
return row;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return /*#__PURE__*/_react.default.createElement(_withDrop.default, {
|
|
150
|
-
identifier: _this.props.dragAndDropIdentifier,
|
|
151
|
-
index: _this.props.index,
|
|
152
|
-
canDrop: () => {
|
|
153
|
-
return !_this.props.hideDrag;
|
|
154
|
-
},
|
|
155
|
-
droppableNode: () => {
|
|
156
|
-
return _this.state.rowNode;
|
|
157
|
-
}
|
|
158
|
-
}, row);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
_this._row = /*#__PURE__*/_react.default.createRef();
|
|
162
|
-
return _this;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
_createClass(TableRow, [{
|
|
166
|
-
key: "UNSAFE_componentWillMount",
|
|
167
|
-
value: function UNSAFE_componentWillMount() {
|
|
168
|
-
if (this.context.dragDropManager) {
|
|
169
|
-
if (this.props.as !== "header" && this.props.index === undefined) {
|
|
170
|
-
throw new Error("You need to provide an index for rows that are draggable");
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (this.requiresUniqueID && !this.props.uniqueID) {
|
|
175
|
-
throw new Error("A TableRow which is selectable or highlightable should provide a uniqueID.");
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (this.context.attachToTable && this.props.uniqueID && !this.props.selectAll && !this.isHeader) {
|
|
179
|
-
// generate row id
|
|
180
|
-
this.rowID = (0, _guid.default)(); // only attach to the table if we have a unique id
|
|
181
|
-
|
|
182
|
-
this.context.attachToTable(this.rowID, this); // also check if row is already selected/highlighted
|
|
183
|
-
|
|
184
|
-
this.context.checkSelection(this.props.uniqueID, this);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (this.props.selected) {
|
|
188
|
-
// if developer is controlling selected state - set it
|
|
189
|
-
this.setState({
|
|
190
|
-
selected: true
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if (this.props.highlighted) {
|
|
195
|
-
// if developer is controlling highlighted state - set it
|
|
196
|
-
this.setState({
|
|
197
|
-
highlighted: true
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}, {
|
|
202
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
203
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
204
|
-
if (this.props.uniqueID !== nextProps.uniqueID) {
|
|
205
|
-
// if unique id has changed, check if the table has the new id as selected or not
|
|
206
|
-
this.context.checkSelection(nextProps.uniqueID, this);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (this.props.selected !== nextProps.selected) {
|
|
210
|
-
// if developer is controlling selected state - set it
|
|
211
|
-
this.setState({
|
|
212
|
-
selected: nextProps.selected
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (this.props.highlighted !== nextProps.highlighted) {
|
|
217
|
-
// if developer is controlling highlighted state - set it
|
|
218
|
-
this.setState({
|
|
219
|
-
highlighted: nextProps.highlighted
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}, {
|
|
224
|
-
key: "componentWillUnmount",
|
|
225
|
-
value: function componentWillUnmount() {
|
|
226
|
-
if (this.context.detachFromTable) {
|
|
227
|
-
this.context.detachFromTable(this.rowID);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
key: "componentDidMount",
|
|
232
|
-
value: function componentDidMount() {
|
|
233
|
-
if (this._row.current) this.setState({
|
|
234
|
-
rowNode: this._row.current
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Call the selectAll callback.
|
|
239
|
-
*/
|
|
240
|
-
|
|
241
|
-
}, {
|
|
242
|
-
key: "rowProps",
|
|
243
|
-
get:
|
|
244
|
-
/**
|
|
245
|
-
* Sets additional props to the row.
|
|
246
|
-
*/
|
|
247
|
-
function () {
|
|
248
|
-
const { ...props
|
|
249
|
-
} = (0, _ether.validProps)(this);
|
|
250
|
-
props.isClickable = this.props.onClick || this.props.highlightable || this.context.highlightable;
|
|
251
|
-
props.isDragged = this.draggingIsOccurring() && this.context.dragAndDropActiveIndex === this.props.index;
|
|
252
|
-
props.isDragging = this.draggingIsOccurring();
|
|
253
|
-
props.isHighlighted = this.state.highlighted;
|
|
254
|
-
props.isPassive = this.context.passiveData;
|
|
255
|
-
props.isSelected = this.state.selected;
|
|
256
|
-
props.isSelectable = this.shouldHaveMultiSelectColumn;
|
|
257
|
-
|
|
258
|
-
if (this.context.highlightable || this.props.highlightable) {
|
|
259
|
-
props.onClick = this.onRowClick;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
return props;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Determines if the developer has flagged this row as a header.
|
|
266
|
-
*/
|
|
267
|
-
|
|
268
|
-
}, {
|
|
269
|
-
key: "isHeader",
|
|
270
|
-
get: function () {
|
|
271
|
-
return this.props.as === "header";
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Determines what kind of cell to render for the checkbox.
|
|
275
|
-
*/
|
|
276
|
-
|
|
277
|
-
}, {
|
|
278
|
-
key: "multiSelectCell",
|
|
279
|
-
get: function () {
|
|
280
|
-
// renders a TableHeader if row is flagged as a header.
|
|
281
|
-
const cell = this.isHeader ? _tableHeader.default : _tableCell.default;
|
|
282
|
-
return /*#__PURE__*/_react.default.createElement(cell, {
|
|
283
|
-
key: "select",
|
|
284
|
-
"data-component": "selectable-cell"
|
|
285
|
-
}, this.multiSelect);
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Returns the checkbox for the select action.
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
}, {
|
|
292
|
-
key: "multiSelect",
|
|
293
|
-
get: function () {
|
|
294
|
-
if (this.props.hideMultiSelect) {
|
|
295
|
-
return null;
|
|
296
|
-
} // determines which action to use (multi-select or select-all)
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const action = this.props.selectAll || this.isHeader ? this.onSelectAll : this.onSelect;
|
|
300
|
-
return /*#__PURE__*/_react.default.createElement(_checkbox.Checkbox, {
|
|
301
|
-
onClick: ev => ev.stopPropagation(),
|
|
302
|
-
onChange: action,
|
|
303
|
-
checked: this.state.selected
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
/**
|
|
307
|
-
* Determines if the row should have a multi select column.
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
}, {
|
|
311
|
-
key: "shouldHaveMultiSelectColumn",
|
|
312
|
-
get: function () {
|
|
313
|
-
// if component specifically disables selectable, don't put the cell in
|
|
314
|
-
if (this.props.selectable !== false) {
|
|
315
|
-
// if multi-seletable, add the checkbox cell
|
|
316
|
-
if (this.props.selectAll || this.context.selectable || this.props.selectable) {
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return false;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Determines if the row requires a unique ID.
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
}, {
|
|
328
|
-
key: "requiresUniqueID",
|
|
329
|
-
get: function () {
|
|
330
|
-
const highlightable = this.props.highlightable !== false && (this.props.highlightable || this.context.highlightable),
|
|
331
|
-
selectable = this.props.selectable !== false && (this.props.selectable || this.context.selectable);
|
|
332
|
-
return highlightable || selectable;
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Determines if dragging is occurring within the current draggable context.
|
|
336
|
-
*/
|
|
337
|
-
|
|
338
|
-
}, {
|
|
339
|
-
key: "highlighted",
|
|
340
|
-
set: function (highlighted) {
|
|
341
|
-
this.setState({
|
|
342
|
-
highlighted
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
}, {
|
|
346
|
-
key: "getChildrenWithStateUpdaters",
|
|
347
|
-
value: function getChildrenWithStateUpdaters() {
|
|
348
|
-
return _react.default.Children.map(this.props.children, td => {
|
|
349
|
-
let hasActionPopover = false;
|
|
350
|
-
|
|
351
|
-
if (!td) {
|
|
352
|
-
return td;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const childrenWithProps = _react.default.Children.map(td.props.children, child => {
|
|
356
|
-
// When a table has an ActionPopover, the opening and closing the ActionPopover should control the highlight
|
|
357
|
-
// state of the row
|
|
358
|
-
if (child && child.type === _actionPopover.ActionPopover) {
|
|
359
|
-
hasActionPopover = true;
|
|
360
|
-
const props = {
|
|
361
|
-
onOpen: () => {
|
|
362
|
-
this.highlighted = true;
|
|
363
|
-
child.props.onOpen();
|
|
364
|
-
},
|
|
365
|
-
onClose: () => {
|
|
366
|
-
this.highlighted = false;
|
|
367
|
-
child.props.onClose();
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
return /*#__PURE__*/_react.default.cloneElement(child, props);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
return child;
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
return hasActionPopover ? /*#__PURE__*/_react.default.cloneElement(td, {
|
|
377
|
-
children: childrenWithProps
|
|
378
|
-
}) : td;
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Renders the component
|
|
383
|
-
*/
|
|
384
|
-
|
|
385
|
-
}, {
|
|
386
|
-
key: "render",
|
|
387
|
-
value: function render() {
|
|
388
|
-
const content = [this.getChildrenWithStateUpdaters()];
|
|
389
|
-
|
|
390
|
-
if (this.shouldHaveMultiSelectColumn) {
|
|
391
|
-
content.unshift(this.multiSelectCell);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return this.renderDraggableRow( /*#__PURE__*/_react.default.createElement(_tableRow.default, _extends({}, this.rowProps, (0, _tags.default)("table-row", this.props), {
|
|
395
|
-
ref: this._row
|
|
396
|
-
}), this.renderDraggableCell(), content));
|
|
397
|
-
}
|
|
398
|
-
}]);
|
|
399
|
-
|
|
400
|
-
return TableRow;
|
|
401
|
-
}(_react.default.Component);
|
|
402
|
-
|
|
403
|
-
TableRow.propTypes = {
|
|
404
|
-
theme: _propTypes.default.object,
|
|
405
|
-
|
|
406
|
-
/** Children elements */
|
|
407
|
-
children: _propTypes.default.node,
|
|
408
|
-
|
|
409
|
-
/** A custom class name for the component. */
|
|
410
|
-
className: _propTypes.default.string,
|
|
411
|
-
|
|
412
|
-
/** Allows developers to specify a callback after the row is clicked. */
|
|
413
|
-
onClick: _propTypes.default.func,
|
|
414
|
-
|
|
415
|
-
/** Enables multi-selectable table rows. */
|
|
416
|
-
selectable: _propTypes.default.bool,
|
|
417
|
-
|
|
418
|
-
/** Enables highlightable table rows. */
|
|
419
|
-
highlightable: _propTypes.default.bool,
|
|
420
|
-
|
|
421
|
-
/** Allows developers to manually control selected state for the row. */
|
|
422
|
-
selected: _propTypes.default.bool,
|
|
423
|
-
|
|
424
|
-
/** Allows developers to manually control highlighted state for the row. */
|
|
425
|
-
highlighted: _propTypes.default.bool,
|
|
426
|
-
|
|
427
|
-
/** Define a unique ID so the table can track the row (useful for highlightable or selectable rows). */
|
|
428
|
-
uniqueID: _propTypes.default.string,
|
|
429
|
-
|
|
430
|
-
/** What the row should be displayed as, set to 'header' to display as header */
|
|
431
|
-
as: _propTypes.default.string,
|
|
432
|
-
|
|
433
|
-
/** Whether to hide the multiSelect */
|
|
434
|
-
hideMultiSelect: _propTypes.default.bool,
|
|
435
|
-
|
|
436
|
-
/** Whether to select all */
|
|
437
|
-
selectAll: _propTypes.default.bool,
|
|
438
|
-
|
|
439
|
-
/** Callback for when a row is highlighted */
|
|
440
|
-
onHighlight: _propTypes.default.func,
|
|
441
|
-
|
|
442
|
-
/** Callback for when a row is selected */
|
|
443
|
-
onSelect: _propTypes.default.func,
|
|
444
|
-
|
|
445
|
-
/** Used if this row is within a draggable context */
|
|
446
|
-
index: _propTypes.default.number,
|
|
447
|
-
|
|
448
|
-
/** Optional to associate the drag and drag context. */
|
|
449
|
-
dragAndDropIdentifier: _propTypes.default.string,
|
|
450
|
-
|
|
451
|
-
/** Used to determine if line is empty or not */
|
|
452
|
-
hideDrag: _propTypes.default.bool,
|
|
453
|
-
|
|
454
|
-
/** Used to determine if line is dragged */
|
|
455
|
-
dragged: _propTypes.default.bool,
|
|
456
|
-
|
|
457
|
-
/** Used to determine if line is empty is dragging */
|
|
458
|
-
dragging: _propTypes.default.func
|
|
459
|
-
};
|
|
460
|
-
TableRow.safeProps = ["onClick", "theme"];
|
|
461
|
-
TableRow.contextTypes = {
|
|
462
|
-
attachToTable: _propTypes.default.func,
|
|
463
|
-
// attach the row to the table
|
|
464
|
-
detachFromTable: _propTypes.default.func,
|
|
465
|
-
// detach the row from the table
|
|
466
|
-
checkSelection: _propTypes.default.func,
|
|
467
|
-
// a function to check if the row is currently selected
|
|
468
|
-
highlightRow: _propTypes.default.func,
|
|
469
|
-
// highlights the row
|
|
470
|
-
selectAll: _propTypes.default.func,
|
|
471
|
-
// a callback function for when all visible rows are selected
|
|
472
|
-
highlightable: _propTypes.default.bool,
|
|
473
|
-
// table can enable all rows to be highlightable
|
|
474
|
-
selectable: _propTypes.default.bool,
|
|
475
|
-
// table can enable all rows to be multi-selectable
|
|
476
|
-
selectRow: _propTypes.default.func,
|
|
477
|
-
// a callback function for when a row is selected
|
|
478
|
-
dragDropManager: _propTypes.default.object,
|
|
479
|
-
// the React DND DragDropManager
|
|
480
|
-
dragAndDropActiveIndex: _propTypes.default.number,
|
|
481
|
-
// tracks the currently active index
|
|
482
|
-
passiveData: _propTypes.default.bool // tracks if the data should be rendered passively
|
|
483
|
-
|
|
484
|
-
};
|
|
485
|
-
var _default = TableRow;
|
|
486
|
-
exports.default = _default;
|