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,792 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "TableRow", {
7
- enumerable: true,
8
- get: function () {
9
- return _tableRow.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "TableCell", {
13
- enumerable: true,
14
- get: function () {
15
- return _tableCell.default;
16
- }
17
- });
18
- Object.defineProperty(exports, "TableHeader", {
19
- enumerable: true,
20
- get: function () {
21
- return _tableHeader.default;
22
- }
23
- });
24
- Object.defineProperty(exports, "TableSubheader", {
25
- enumerable: true,
26
- get: function () {
27
- return _tableSubheader.default;
28
- }
29
- });
30
- Object.defineProperty(exports, "DraggableTableCell", {
31
- enumerable: true,
32
- get: function () {
33
- return _draggableTableCell.default;
34
- }
35
- });
36
- exports.Table = void 0;
37
-
38
- var _react = _interopRequireDefault(require("react"));
39
-
40
- var _propTypes = _interopRequireDefault(require("prop-types"));
41
-
42
- var _reactTransitionGroup = require("react-transition-group");
43
-
44
- var _immutable = _interopRequireDefault(require("immutable"));
45
-
46
- var _actionToolbar = _interopRequireDefault(require("../action-toolbar"));
47
-
48
- var _icon = _interopRequireDefault(require("../icon"));
49
-
50
- var _link = _interopRequireDefault(require("../link"));
51
-
52
- var _table = _interopRequireWildcard(require("./table.style"));
53
-
54
- var _tableRow = _interopRequireDefault(require("./table-row"));
55
-
56
- var _tableCell = _interopRequireDefault(require("./table-cell"));
57
-
58
- var _tableHeader = _interopRequireDefault(require("./table-header"));
59
-
60
- var _tableSubheader = _interopRequireDefault(require("./table-subheader"));
61
-
62
- var _draggableTableCell = _interopRequireDefault(require("./draggable-table-cell"));
63
-
64
- var _pager = _interopRequireDefault(require("../pager"));
65
-
66
- var _loader = _interopRequireDefault(require("../loader"));
67
-
68
- var _logger = _interopRequireDefault(require("../../__internal__/utils/logger"));
69
-
70
- var _i18nContext = _interopRequireDefault(require("../../__internal__/i18n-context"));
71
-
72
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
73
-
74
- 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; }
75
-
76
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
77
-
78
- 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); }
79
-
80
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
81
-
82
- 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); } }
83
-
84
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
85
-
86
- 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); }
87
-
88
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
89
-
90
- 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); }; }
91
-
92
- function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
93
-
94
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
95
-
96
- 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; } }
97
-
98
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
99
-
100
- 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; }
101
-
102
- let deprecatedWarnTriggered = false;
103
-
104
- let Table = /*#__PURE__*/function (_React$Component) {
105
- _inherits(Table, _React$Component);
106
-
107
- var _super = _createSuper(Table);
108
-
109
- function Table(_props) {
110
- var _this;
111
-
112
- _classCallCheck(this, Table);
113
-
114
- _this = _super.call(this, _props);
115
-
116
- _defineProperty(_assertThisInitialized(_this), "state", {
117
- selectedCount: 0
118
- });
119
-
120
- _defineProperty(_assertThisInitialized(_this), "getChildContext", () => {
121
- return {
122
- attachActionToolbar: _this.attachActionToolbar,
123
- detachActionToolbar: _this.detachActionToolbar,
124
- attachToTable: _this.attachToTable,
125
- detachFromTable: _this.detachFromTable,
126
- checkSelection: _this.checkSelection,
127
- highlightRow: _this.highlightRow,
128
- onSort: _this.onSort,
129
- highlightable: _this.props.highlightable,
130
- selectable: _this.props.selectable,
131
- selectAll: _this.selectAll,
132
- selectRow: _this.selectRow,
133
- sortedColumn: _this.sortedColumn,
134
- sortOrder: _this.sortOrder,
135
- passiveData: _this.isPassive
136
- };
137
- });
138
-
139
- _defineProperty(_assertThisInitialized(_this), "onSort", (sortedColumn, sortOrder) => {
140
- const options = _this.emitOptions();
141
-
142
- options.sortedColumn = sortedColumn;
143
- options.sortOrder = sortOrder;
144
-
145
- _this.emitOnChangeCallback("table", options);
146
- });
147
-
148
- _defineProperty(_assertThisInitialized(_this), "onPagination", (currentPage, pageSize, element) => {
149
- if (_this.props.onPageSizeChange && element === "size") {
150
- _this.props.onPageSizeChange(pageSize);
151
- }
152
-
153
- const options = _this.emitOptions();
154
-
155
- options.currentPage = currentPage;
156
- options.pageSize = pageSize;
157
-
158
- _this.emitOnChangeCallback("pager", options);
159
- });
160
-
161
- _defineProperty(_assertThisInitialized(_this), "emitOnChangeCallback", (element, options) => {
162
- if (_this.selectAllComponent) {
163
- // reset the select all component
164
- _this.selectAllComponent.setState({
165
- selected: false
166
- });
167
-
168
- _this.selectAllComponent = null;
169
- }
170
-
171
- _this.props.onChange(element, options);
172
- });
173
-
174
- _defineProperty(_assertThisInitialized(_this), "attachActionToolbar", comp => {
175
- _this.actionToolbarComponent = comp;
176
- });
177
-
178
- _defineProperty(_assertThisInitialized(_this), "detachActionToolbar", () => {
179
- _this.actionToolbarComponent = null;
180
- });
181
-
182
- _defineProperty(_assertThisInitialized(_this), "attachToTable", (id, row) => {
183
- _this.rows[id] = row;
184
- });
185
-
186
- _defineProperty(_assertThisInitialized(_this), "detachFromTable", id => {
187
- delete _this.rows[id];
188
- });
189
-
190
- _defineProperty(_assertThisInitialized(_this), "refresh", () => {
191
- _this.resetHighlightedRow();
192
-
193
- _this.selectedRows = {};
194
-
195
- if (_this.actionToolbarComponent) {
196
- _this.actionToolbarComponent.setState({
197
- total: 0,
198
- selected: []
199
- });
200
- }
201
-
202
- for (const key in _this.rows) {
203
- const _row = _this.rows[key];
204
-
205
- _row.setState({
206
- selected: false
207
- });
208
- }
209
-
210
- _this.emitOnChangeCallback("refresh", _this.emitOptions());
211
- });
212
-
213
- _defineProperty(_assertThisInitialized(_this), "resetHighlightedRow", () => {
214
- if (_this.highlightedRow.row && _this.rows[_this.highlightedRow.row.rowID]) {
215
- _this.highlightedRow.row.setState({
216
- highlighted: false
217
- });
218
- }
219
-
220
- _this.highlightedRow = {
221
- id: null,
222
- row: null
223
- };
224
- });
225
-
226
- _defineProperty(_assertThisInitialized(_this), "highlightRow", (id, row) => {
227
- let state = true;
228
-
229
- if (_this.highlightedRow.id !== null) {
230
- if (id === _this.highlightedRow.id) {
231
- state = !row.state.highlighted;
232
- } else {
233
- _this.resetHighlightedRow();
234
- }
235
- }
236
-
237
- row.setState({
238
- highlighted: state
239
- });
240
- _this.highlightedRow = {
241
- id,
242
- row
243
- };
244
-
245
- if (_this.props.onHighlight) {
246
- _this.props.onHighlight(id, state, row);
247
- }
248
- });
249
-
250
- _defineProperty(_assertThisInitialized(_this), "selectRow", (id, row, state, skipCallback) => {
251
- const isSelected = _this.selectedRows[id] !== undefined;
252
-
253
- if (state === isSelected) {
254
- return;
255
- }
256
-
257
- if (_this.selectAllComponent) {
258
- _this.selectAllComponent.setState({
259
- selected: false
260
- });
261
-
262
- _this.selectAllComponent = null;
263
- }
264
-
265
- if (!state && isSelected) {
266
- delete _this.selectedRows[id];
267
- } else if (!row.props.selectAll) {
268
- _this.selectedRows[id] = row;
269
- }
270
-
271
- row.setState({
272
- selected: state
273
- });
274
-
275
- if (_this.actionToolbarComponent && !skipCallback) {
276
- const keys = Object.keys(_this.selectedRows);
277
-
278
- _this.actionToolbarComponent.setState({
279
- total: keys.length,
280
- selected: _this.selectedRows
281
- });
282
- }
283
-
284
- if (_this.props.onSelect && !skipCallback) {
285
- _this.props.onSelect(_this.selectedRows);
286
- }
287
- });
288
-
289
- _defineProperty(_assertThisInitialized(_this), "selectAll", row => {
290
- const selectState = !row.state.selected;
291
-
292
- for (const key in _this.rows) {
293
- const _row = _this.rows[key];
294
-
295
- if (_row.shouldHaveMultiSelectColumn) {
296
- _this.selectRow(_row.props.uniqueID, _row, selectState, true);
297
- }
298
- }
299
-
300
- row.setState({
301
- selected: selectState
302
- });
303
- _this.selectAllComponent = selectState ? row : null;
304
-
305
- if (_this.actionToolbarComponent) {
306
- const keys = Object.keys(_this.selectedRows);
307
-
308
- _this.actionToolbarComponent.setState({
309
- total: keys.length,
310
- selected: _this.selectedRows
311
- });
312
- }
313
-
314
- if (_this.props.onSelect) {
315
- _this.props.onSelect(_this.selectedRows);
316
- }
317
- });
318
-
319
- _defineProperty(_assertThisInitialized(_this), "checkSelection", (id, row) => {
320
- const isSelected = _this.selectedRows[id] !== undefined,
321
- isHighlighted = _this.highlightedRow.id === id;
322
-
323
- if (isSelected !== row.state.selected) {
324
- row.setState({
325
- selected: isSelected
326
- });
327
- }
328
-
329
- if (isHighlighted !== row.state.highlighted) {
330
- row.setState({
331
- highlighted: isHighlighted
332
- });
333
- }
334
- });
335
-
336
- _defineProperty(_assertThisInitialized(_this), "selectAllComponent", null);
337
-
338
- _defineProperty(_assertThisInitialized(_this), "actionToolbarComponent", null);
339
-
340
- _defineProperty(_assertThisInitialized(_this), "selectedRows", {});
341
-
342
- _defineProperty(_assertThisInitialized(_this), "highlightedRow", {
343
- id: null,
344
- row: null
345
- });
346
-
347
- _defineProperty(_assertThisInitialized(_this), "rows", {});
348
-
349
- _defineProperty(_assertThisInitialized(_this), "tableHeight", 0);
350
-
351
- _defineProperty(_assertThisInitialized(_this), "emitOptions", (props = _this.props) => {
352
- let currentPage = props.currentPage || 0;
353
-
354
- if (Number(props.currentPage) > Number(props.pageSize)) {
355
- currentPage = 1;
356
- }
357
-
358
- return {
359
- currentPage,
360
- filter: props.filter ? props.filter.toJS() : {},
361
- pageSize: props.pageSize || "",
362
- sortOrder: props.sortOrder || "",
363
- sortedColumn: props.sortedColumn || ""
364
- };
365
- });
366
-
367
- _defineProperty(_assertThisInitialized(_this), "configureLink", onConfigure => {
368
- if (!onConfigure) {
369
- return null;
370
- }
371
-
372
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_link.default, {
373
- href: "#",
374
- onClick: onConfigure
375
- }, /*#__PURE__*/_react.default.createElement(_icon.default, {
376
- type: "settings"
377
- })));
378
- });
379
-
380
- _defineProperty(_assertThisInitialized(_this), "dataState", () => {});
381
-
382
- if (!deprecatedWarnTriggered) {
383
- deprecatedWarnTriggered = true; // eslint-disable-next-line max-len
384
-
385
- _logger.default.deprecate("`Table` component is deprecated and will soon be removed. Please use `FlatTable` instead: https://carbon.sage.com/?path=/story/flat-table--default-story");
386
- }
387
-
388
- return _this;
389
- }
390
-
391
- _createClass(Table, [{
392
- key: "componentDidMount",
393
- value: function componentDidMount() {
394
- this.resizeTable();
395
- }
396
- /**
397
- * Lifecycle for after a update has happened
398
- * If filter has changed then emit the on change event.
399
- */
400
-
401
- }, {
402
- key: "UNSAFE_componentWillReceiveProps",
403
- value: function UNSAFE_componentWillReceiveProps(nextProps) {
404
- // if filter has changed, update the data
405
- if (!_immutable.default.is(this.props.filter, nextProps.filter)) {
406
- this.emitOnChangeCallback("filter", this.emitOptions(nextProps));
407
- }
408
-
409
- if (this.props.highlightable && nextProps.highlightable === false) {
410
- this.resetHighlightedRow();
411
- }
412
-
413
- if (this.props.selectable && nextProps.selectable === false) {
414
- for (const key in this.rows) {
415
- // update all the rows with the new state
416
- const row = this.rows[key];
417
- this.selectRow(row.props.uniqueID, row, false);
418
- }
419
-
420
- this.selectedRows = {};
421
- }
422
- }
423
- }, {
424
- key: "componentDidUpdate",
425
- value: function componentDidUpdate(prevProps) {
426
- if (this.shouldResetTableHeight(prevProps)) {
427
- this.resetTableHeight();
428
- } else {
429
- this.resizeTable();
430
- }
431
- }
432
- }, {
433
- key: "sortedColumn",
434
- get: function () {
435
- return this.props.sortedColumn;
436
- }
437
- }, {
438
- key: "sortOrder",
439
- get: function () {
440
- return this.props.sortOrder;
441
- }
442
- }, {
443
- key: "pageSize",
444
- get: function () {
445
- return this.props.pageSize;
446
- }
447
- }, {
448
- key: "resetTableHeight",
449
- value: function resetTableHeight() {
450
- this._wrapper.style.minHeight = "0";
451
- this.tableHeight = 0;
452
- setTimeout(() => {
453
- this.resizeTable();
454
- }, 0);
455
- }
456
- }, {
457
- key: "resizeTable",
458
- value: function resizeTable() {
459
- if (!this._table) {
460
- return;
461
- }
462
-
463
- const shrink = this.props.shrink && this._table.offsetHeight < this.tableHeight;
464
-
465
- if (shrink || this._table.offsetHeight > this.tableHeight) {
466
- this.tableHeight = this._table.offsetHeight;
467
- this._wrapper.style.minHeight = `${this.tableHeight - 1}px`;
468
- }
469
- }
470
- }, {
471
- key: "shouldResetTableHeight",
472
- value: function shouldResetTableHeight(prevProps) {
473
- return prevProps.size !== this.props.size || prevProps.pageSize > this.pageSize;
474
- }
475
- }, {
476
- key: "pagerProps",
477
- get: function () {
478
- return {
479
- currentPage: this.props.currentPage,
480
- onPagination: this.onPagination,
481
- pageSize: this.defaultPageSize,
482
- pageSizeSelectionOptions: this.props.pageSizeSelectionOptions,
483
- showPageSizeSelection: this.props.showPageSizeSelection,
484
- totalRecords: this.props.totalRecords
485
- };
486
- }
487
- }, {
488
- key: "defaultPageSize",
489
- get: function () {
490
- if (this.props.pageSize) {
491
- return this.props.pageSize;
492
- }
493
-
494
- if (this.props.pageSizeSelectionOptions) {
495
- return this.props.pageSizeSelectionOptions.first().get("id");
496
- }
497
-
498
- return "10";
499
- }
500
- }, {
501
- key: "pager",
502
- get: function () {
503
- if (this.props.paginate) {
504
- return /*#__PURE__*/_react.default.createElement(_pager.default, this.pagerProps);
505
- }
506
-
507
- return null;
508
- }
509
- }, {
510
- key: "isPassive",
511
- get: function () {
512
- return Boolean(this.props.isPassiveData && !this.props.highlightable && !this.props.selectable);
513
- }
514
- }, {
515
- key: "thead",
516
- get: function () {
517
- if (this.props.thead) {
518
- return /*#__PURE__*/_react.default.createElement("thead", null, this.props.thead);
519
- }
520
-
521
- return null;
522
- }
523
- }, {
524
- key: "actionToolbar",
525
- get: function () {
526
- if (!this.props.selectable || !this.props.actions) {
527
- return null;
528
- }
529
-
530
- return /*#__PURE__*/_react.default.createElement(_actionToolbar.default, {
531
- total: this.state.selectedCount,
532
- actions: this.props.actions
533
- }, this.props.actionToolbarChildren);
534
- }
535
- }, {
536
- key: "loadingRow",
537
- get: function () {
538
- return /*#__PURE__*/_react.default.createElement(_tableRow.default, {
539
- key: "__loading__",
540
- selectable: false,
541
- highlightable: false,
542
- hideMultiSelect: true
543
- }, /*#__PURE__*/_react.default.createElement(_tableCell.default, {
544
- colSpan: "42",
545
- align: "center"
546
- }, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.TransitionGroup, null, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
547
- classNames: "table-loading",
548
- timeout: 300,
549
- appear: true
550
- }, /*#__PURE__*/_react.default.createElement(_loader.default, {
551
- size: "small"
552
- })))));
553
- }
554
- }, {
555
- key: "emptyRow",
556
- get: function () {
557
- if (this.props.customEmptyRow) {
558
- return this.props.customEmptyRow;
559
- }
560
-
561
- return /*#__PURE__*/_react.default.createElement(_tableRow.default, {
562
- key: "__loading__",
563
- selectable: false,
564
- highlightable: false
565
- }, /*#__PURE__*/_react.default.createElement(_tableCell.default, {
566
- colSpan: "42",
567
- align: "center"
568
- }, this.context.table.noData()));
569
- }
570
- }, {
571
- key: "tableContent",
572
- get: function () {
573
- let {
574
- children
575
- } = this.props,
576
- hasChildren = children;
577
-
578
- if (children && children.count) {
579
- const numOfChildren = children.count(),
580
- onlyChildIsHeader = numOfChildren === 1 && children.first().props.as === "header";
581
-
582
- if (onlyChildIsHeader) {
583
- if (this._hasRetreivedData) {
584
- children = children.push(this.emptyRow);
585
- } else {
586
- children = children.push(this.loadingRow);
587
- }
588
- } else {
589
- hasChildren = numOfChildren > 0;
590
- }
591
- }
592
-
593
- if (hasChildren) return children;
594
- if (this._hasRetreivedData) return this.emptyRow;
595
- return this.loadingRow;
596
- }
597
- }, {
598
- key: "tbody",
599
- get: function () {
600
- if (this.props.tbody === false) {
601
- return this.tableContent;
602
- }
603
-
604
- return /*#__PURE__*/_react.default.createElement("tbody", null, this.tableContent);
605
- }
606
- }, {
607
- key: "dataComponent",
608
- get: function () {
609
- return "table";
610
- }
611
- }, {
612
- key: "componentTags",
613
- value: function componentTags(props) {
614
- return {
615
- "data-component": this.dataComponent,
616
- "data-element": props["data-element"],
617
- "data-role": props["data-role"],
618
- "data-state": this.dataState(),
619
- "aria-busy": this.state.ariaBusy
620
- };
621
- }
622
- }, {
623
- key: "caption",
624
- get: function () {
625
- if (this.props.caption) {
626
- return /*#__PURE__*/_react.default.createElement("caption", null, this.props.caption);
627
- }
628
-
629
- return null;
630
- }
631
- }, {
632
- key: "render",
633
- value: function render() {
634
- const tableProps = {
635
- tableType: this.props.theme,
636
- size: this.props.size,
637
- isZebra: this.props.isZebra,
638
- paginate: this.props.paginate
639
- };
640
-
641
- if (this.props["aria-describedby"]) {
642
- tableProps["aria-describedby"] = this.props["aria-describedby"];
643
- }
644
-
645
- return /*#__PURE__*/_react.default.createElement("div", this.componentTags(this.props), this.actionToolbar, /*#__PURE__*/_react.default.createElement(_table.StyledInternalTableWrapper, {
646
- ref: wrapper => {
647
- this._wrapper = wrapper;
648
- },
649
- paginate: this.props.paginate,
650
- className: this.props.className
651
- }, this.configureLink(this.props.onConfigure), /*#__PURE__*/_react.default.createElement(_table.default, _extends({
652
- ref: table => {
653
- this._table = table;
654
- }
655
- }, tableProps), this.caption, this.thead, this.tbody)), this.pager);
656
- }
657
- }]);
658
-
659
- return Table;
660
- }(_react.default.Component);
661
-
662
- exports.Table = Table;
663
- Table.contextType = _i18nContext.default;
664
- Table.propTypes = {
665
- /** The actions to display in the toolbar */
666
- actions: _propTypes.default.object,
667
-
668
- /** The extra actions to display in the toolbar */
669
- actionToolbarChildren: _propTypes.default.func,
670
-
671
- /** Children elements */
672
- children: _propTypes.default.node,
673
-
674
- /** Custom className */
675
- className: _propTypes.default.string,
676
-
677
- /** Custom empty row */
678
- customEmptyRow: _propTypes.default.node,
679
-
680
- /** Data used to filter the data */
681
- filter: _propTypes.default.object,
682
-
683
- /** Emitted when table component changes e.g. Pager, sorting, filter */
684
- onChange: _propTypes.default.func,
685
-
686
- /** Enable configure icon that triggers this callback on click */
687
- onConfigure: _propTypes.default.func,
688
-
689
- /** Show the pagination footer */
690
- paginate: _propTypes.default.bool,
691
-
692
- /** Pagination - Current Visible Page */
693
- currentPage: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
694
-
695
- /** Pagination - Page Size of grid (number of visible records) */
696
- pageSize: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
697
-
698
- /** Pagination - Options for pageSize - default: 10, 25, 50 */
699
- pageSizeSelectionOptions: _propTypes.default.object,
700
-
701
- /** Pagination - Is the page size dropdown visible */
702
- showPageSizeSelection: _propTypes.default.bool,
703
-
704
- /** Enables multi-selectable table rows. */
705
- selectable: _propTypes.default.bool,
706
-
707
- /** Enables highlightable table rows. */
708
- highlightable: _propTypes.default.bool,
709
-
710
- /** A callback for when a row is selected. */
711
- onSelect: _propTypes.default.func,
712
-
713
- /** A callback for when a row is highlighted. */
714
- onHighlight: _propTypes.default.func,
715
-
716
- /** A callback for when the page size changes. */
717
- onPageSizeChange: _propTypes.default.func,
718
-
719
- /** Pagination - Total number of records in the grid */
720
- totalRecords: _propTypes.default.number,
721
-
722
- /** Allow table to shrink in size. */
723
- shrink: _propTypes.default.bool,
724
-
725
- /** The currently sorted column. */
726
- sortedColumn: _propTypes.default.string,
727
-
728
- /** The current sort order applied. */
729
- sortOrder: _propTypes.default.string,
730
-
731
- /** TableRows to be wrapped in <thead> */
732
- thead: _propTypes.default.object,
733
-
734
- /** Determines if you want the table to automatically render a tbody. */
735
- tbody: _propTypes.default.bool,
736
-
737
- /** A string to render as the table's caption */
738
- caption: _propTypes.default.string,
739
-
740
- /** The HTML id of the element that contains a description of this table. */
741
- "aria-describedby": _propTypes.default.string,
742
-
743
- /** Renders as 'primary' / 'dark', 'secondary' / 'light', 'tertiary' / 'transparent' */
744
- theme: _propTypes.default.oneOf(["primary", "secondary", "tertiary", "dark", "light", "transparent"]),
745
-
746
- /** Used to define the tables size Renders as: 'compact', 'small', 'medium' and 'large' */
747
- size: _propTypes.default.oneOf(["compact", "small", "medium", "large"]),
748
-
749
- /** Toggles the zebra striping for the table rows */
750
- isZebra: _propTypes.default.bool,
751
-
752
- /** Set if data is passive and requires no hover added styling */
753
- isPassiveData: _propTypes.default.bool
754
- };
755
- Table.childContextTypes = {
756
- /**
757
- * Defines a context object for child components of the table component.
758
- * https://facebook.github.io/react/docs/context.html
759
- */
760
- attachActionToolbar: _propTypes.default.func,
761
- // tracks the action toolbar component
762
- detachActionToolbar: _propTypes.default.func,
763
- // tracks the action toolbar component
764
- attachToTable: _propTypes.default.func,
765
- // attach the row to the table
766
- checkSelection: _propTypes.default.func,
767
- // a function to check if the row is currently selected
768
- detachFromTable: _propTypes.default.func,
769
- // detach the row from the table
770
- highlightRow: _propTypes.default.func,
771
- // highlights the row
772
- selectable: _propTypes.default.bool,
773
- // table can enable all rows to be multi-selectable
774
- onSort: _propTypes.default.func,
775
- // a callback function for when a sort order is updated
776
- selectAll: _propTypes.default.func,
777
- // a callback function for when all visible rows are selected
778
- selectRow: _propTypes.default.func,
779
- // a callback function for when a row is selected
780
- highlightable: _propTypes.default.bool,
781
- // table can enable all rows to be highlightable
782
- sortOrder: _propTypes.default.string,
783
- // the current sort order applied
784
- sortedColumn: _propTypes.default.string,
785
- // the currently sorted column
786
- passiveData: _propTypes.default.bool // Renders data as passive, without hover styling etc
787
-
788
- };
789
- Table.defaultProps = {
790
- theme: "primary",
791
- size: "medium"
792
- };