@salesforce/design-system-react 0.10.35 → 0.10.39
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/assets/styles/table.css +70 -0
- package/components/builder-header/utilities.d.ts +20 -0
- package/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
- package/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
- package/components/combobox/__tests__/combobox.browser-test.jsx +4 -5
- package/components/combobox/combobox.jsx +20 -18
- package/components/component-docs.json +160 -0
- package/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
- package/components/data-table/__docs__/storybook-stories.jsx +5 -1
- package/components/data-table/__examples__/advanced-single-select-fixed-header.jsx +1 -0
- package/components/data-table/__examples__/basic-fluid-headless.jsx +105 -0
- package/components/data-table/__examples__/interactive-elements.jsx +14 -0
- package/components/data-table/__examples__/joined-with-page-header.jsx +11 -18
- package/components/data-table/__examples__/resizable-columns.jsx +237 -0
- package/components/data-table/__tests__/data-table.browser-test.jsx +133 -0
- package/components/data-table/column.resizer.d.ts +1 -0
- package/components/data-table/component.json +11 -7
- package/components/data-table/index.jsx +431 -80
- package/components/data-table/private/head.jsx +8 -3
- package/components/data-table/private/header-cell.jsx +9 -1
- package/components/data-table.d.ts +8 -0
- package/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
- package/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
- package/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
- package/components/index.d.ts +2 -0
- package/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
- package/components/menu-dropdown/__docs__/storybook-stories.jsx +4 -16
- package/components/menu-dropdown/__examples__/checkmark.jsx +48 -31
- package/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +12 -7
- package/components/modal/__tests__/modal.browser-test.jsx +4 -10
- package/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
- package/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
- package/components/progress-indicator/private/step-vertical.jsx +28 -2
- package/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
- package/components/site-stories.js +16 -4
- package/components/utilities/menu-list/index.jsx +3 -0
- package/components/utilities/menu-list/item.jsx +5 -2
- package/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
- package/components/vertical-navigation/__docs__/storybook-stories.jsx +4 -0
- package/components/vertical-navigation/__examples__/icons.jsx +70 -0
- package/components/vertical-navigation/__examples__/notifications.jsx +66 -0
- package/components/vertical-navigation/component.json +8 -0
- package/components/vertical-navigation/private/item.d.ts +2 -0
- package/components/vertical-navigation/private/item.jsx +23 -1
- package/docs/PULL_REQUEST_TEMPLATE.md +1 -1
- package/lib/assets/styles/table.css +70 -0
- package/lib/components/builder-header/utilities.d.ts +20 -0
- package/lib/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
- package/lib/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
- package/lib/components/combobox/__tests__/combobox.browser-test.jsx +4 -5
- package/lib/components/combobox/combobox.js +27 -23
- package/lib/components/component-docs.json +160 -0
- package/lib/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
- package/lib/components/data-table/__docs__/storybook-stories.jsx +5 -1
- package/lib/components/data-table/__examples__/advanced-single-select-fixed-header.jsx +1 -0
- package/lib/components/data-table/__examples__/basic-fluid-headless.jsx +105 -0
- package/lib/components/data-table/__examples__/interactive-elements.jsx +14 -0
- package/lib/components/data-table/__examples__/joined-with-page-header.jsx +11 -18
- package/lib/components/data-table/__examples__/resizable-columns.jsx +237 -0
- package/lib/components/data-table/__tests__/data-table.browser-test.jsx +133 -0
- package/lib/components/data-table/column.resizer.d.ts +1 -0
- package/lib/components/data-table/component.json +11 -7
- package/lib/components/data-table/index.js +444 -107
- package/lib/components/data-table/private/head.js +8 -3
- package/lib/components/data-table/private/header-cell.js +3 -1
- package/lib/components/data-table.d.ts +8 -0
- package/lib/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
- package/lib/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
- package/lib/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
- package/lib/components/index.d.ts +2 -0
- package/lib/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
- package/lib/components/menu-dropdown/__docs__/storybook-stories.jsx +4 -16
- package/lib/components/menu-dropdown/__examples__/checkmark.jsx +48 -31
- package/lib/components/menu-dropdown/__tests__/dropdown.browser-test.jsx +12 -7
- package/lib/components/modal/__tests__/modal.browser-test.jsx +4 -10
- package/lib/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
- package/lib/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
- package/lib/components/progress-indicator/private/step-vertical.js +18 -4
- package/lib/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
- package/lib/components/site-stories.js +12 -3
- package/lib/components/utilities/menu-list/index.js +5 -2
- package/lib/components/utilities/menu-list/item.js +3 -2
- package/lib/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
- package/lib/components/vertical-navigation/__docs__/storybook-stories.jsx +4 -0
- package/lib/components/vertical-navigation/__examples__/icons.jsx +70 -0
- package/lib/components/vertical-navigation/__examples__/notifications.jsx +66 -0
- package/lib/components/vertical-navigation/component.json +8 -0
- package/lib/components/vertical-navigation/private/item.d.ts +2 -0
- package/lib/components/vertical-navigation/private/item.js +5 -1
- package/lib/docs/PULL_REQUEST_TEMPLATE.md +1 -1
- package/lib/package.json +19 -6
- package/module/assets/styles/table.css +70 -0
- package/module/components/builder-header/utilities.d.ts +20 -0
- package/module/components/card/__docs__/__snapshots__/storybook-stories.storyshot +20 -5
- package/module/components/combobox/__docs__/__snapshots__/storybook-stories.storyshot +178 -169
- package/module/components/combobox/__tests__/combobox.browser-test.js +5 -6
- package/module/components/combobox/__tests__/combobox.browser-test.js.map +1 -1
- package/module/components/combobox/combobox.js +27 -23
- package/module/components/combobox/combobox.js.map +1 -1
- package/module/components/component-docs.json +160 -0
- package/module/components/data-table/__docs__/__snapshots__/storybook-stories.storyshot +17997 -11862
- package/module/components/data-table/__docs__/storybook-stories.js +6 -0
- package/module/components/data-table/__docs__/storybook-stories.js.map +1 -1
- package/module/components/data-table/__examples__/advanced-single-select-fixed-header.js +1 -0
- package/module/components/data-table/__examples__/advanced-single-select-fixed-header.js.map +1 -1
- package/module/components/data-table/__examples__/basic-fluid-headless.js +152 -0
- package/module/components/data-table/__examples__/basic-fluid-headless.js.map +1 -0
- package/module/components/data-table/__examples__/interactive-elements.js +9 -0
- package/module/components/data-table/__examples__/interactive-elements.js.map +1 -1
- package/module/components/data-table/__examples__/joined-with-page-header.js +9 -20
- package/module/components/data-table/__examples__/joined-with-page-header.js.map +1 -1
- package/module/components/data-table/__examples__/resizable-columns.js +266 -0
- package/module/components/data-table/__examples__/resizable-columns.js.map +1 -0
- package/module/components/data-table/__tests__/data-table.browser-test.js +99 -0
- package/module/components/data-table/__tests__/data-table.browser-test.js.map +1 -1
- package/module/components/data-table/column.resizer.d.ts +1 -0
- package/module/components/data-table/component.json +11 -7
- package/module/components/data-table/index.js +443 -107
- package/module/components/data-table/index.js.map +1 -1
- package/module/components/data-table/private/head.js +8 -3
- package/module/components/data-table/private/head.js.map +1 -1
- package/module/components/data-table/private/header-cell.js +3 -1
- package/module/components/data-table/private/header-cell.js.map +1 -1
- package/module/components/data-table.d.ts +8 -0
- package/module/components/date-picker/__tests__/__snapshots__/datepicker.dom-snapshot-test.jsx.snap +17 -17
- package/module/components/expression/__docs__/__snapshots__/storybook-stories.storyshot +90 -90
- package/module/components/global-header/__docs__/__snapshots__/storybook-stories.storyshot +9 -9
- package/module/components/index.d.ts +2 -0
- package/module/components/menu-dropdown/__docs__/__snapshots__/storybook-stories.storyshot +552 -26
- package/module/components/menu-dropdown/__docs__/storybook-stories.js +9 -15
- package/module/components/menu-dropdown/__docs__/storybook-stories.js.map +1 -1
- package/module/components/menu-dropdown/__examples__/checkmark.js +53 -33
- package/module/components/menu-dropdown/__examples__/checkmark.js.map +1 -1
- package/module/components/menu-dropdown/__tests__/dropdown.browser-test.js +7 -4
- package/module/components/menu-dropdown/__tests__/dropdown.browser-test.js.map +1 -1
- package/module/components/modal/__tests__/modal.browser-test.js +4 -10
- package/module/components/modal/__tests__/modal.browser-test.js.map +1 -1
- package/module/components/portal-settings/__docs__/__snapshots__/storybook-stories.storyshot +6 -6
- package/module/components/progress-indicator/__docs__/__snapshots__/storybook-stories.storyshot +161 -14
- package/module/components/progress-indicator/private/step-vertical.js +18 -4
- package/module/components/progress-indicator/private/step-vertical.js.map +1 -1
- package/module/components/setup-assistant/__docs__/__snapshots__/storybook-stories.storyshot +180 -13
- package/module/components/site-stories.js +12 -3
- package/module/components/site-stories.js.map +1 -1
- package/module/components/utilities/menu-list/index.js +5 -2
- package/module/components/utilities/menu-list/index.js.map +1 -1
- package/module/components/utilities/menu-list/item.js +3 -2
- package/module/components/utilities/menu-list/item.js.map +1 -1
- package/module/components/vertical-navigation/__docs__/__snapshots__/storybook-stories.storyshot +326 -0
- package/module/components/vertical-navigation/__docs__/storybook-stories.js +10 -0
- package/module/components/vertical-navigation/__docs__/storybook-stories.js.map +1 -1
- package/module/components/vertical-navigation/__examples__/icons.js +149 -0
- package/module/components/vertical-navigation/__examples__/icons.js.map +1 -0
- package/module/components/vertical-navigation/__examples__/notifications.js +143 -0
- package/module/components/vertical-navigation/__examples__/notifications.js.map +1 -0
- package/module/components/vertical-navigation/component.json +8 -0
- package/module/components/vertical-navigation/private/item.d.ts +2 -0
- package/module/components/vertical-navigation/private/item.js +5 -1
- package/module/components/vertical-navigation/private/item.js.map +1 -1
- package/package.json +19 -6
- package/design-system-react-components.js +0 -62702
- package/design-system-react-components.js.map +0 -1
- package/design-system-react-components.min.js +0 -3
- package/design-system-react-components.min.js.LICENSE.txt +0 -83
- package/design-system-react-components.min.js.map +0 -1
- package/design-system-react.js +0 -73487
- package/design-system-react.js.map +0 -1
- package/design-system-react.min.js +0 -3
- package/design-system-react.min.js.LICENSE.txt +0 -83
- package/design-system-react.min.js.map +0 -1
- package/lib/design-system-react-components.min.js.LICENSE.txt +0 -83
- package/lib/design-system-react.min.js.LICENSE.txt +0 -83
|
@@ -19,6 +19,8 @@ var _lodash = _interopRequireDefault(require("lodash.assign"));
|
|
|
19
19
|
|
|
20
20
|
var _lodash2 = _interopRequireDefault(require("lodash.reject"));
|
|
21
21
|
|
|
22
|
+
var _columnResizer = _interopRequireDefault(require("column-resizer"));
|
|
23
|
+
|
|
22
24
|
var _checkProps = _interopRequireDefault(require("./check-props"));
|
|
23
25
|
|
|
24
26
|
var _component = _interopRequireDefault(require("./component.json"));
|
|
@@ -55,10 +57,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
55
57
|
|
|
56
58
|
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); }
|
|
57
59
|
|
|
58
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
59
|
-
|
|
60
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
61
|
-
|
|
62
60
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
63
61
|
|
|
64
62
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -71,6 +69,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
71
69
|
|
|
72
70
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
73
71
|
|
|
72
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
73
|
+
|
|
74
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
75
|
+
|
|
74
76
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
75
77
|
|
|
76
78
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -123,7 +125,12 @@ var defaultProps = {
|
|
|
123
125
|
},
|
|
124
126
|
selection: [],
|
|
125
127
|
hasMore: false,
|
|
126
|
-
loadMoreOffset: 20
|
|
128
|
+
loadMoreOffset: 20,
|
|
129
|
+
resizable: false,
|
|
130
|
+
resizableOptions: {
|
|
131
|
+
resizeMode: 'fit',
|
|
132
|
+
draggingClass: 'slds-table-column-resizer'
|
|
133
|
+
}
|
|
127
134
|
};
|
|
128
135
|
/**
|
|
129
136
|
* DataTables support the display of structured data in rows and columns with an HTML table. To sort, filter or paginate the table, simply update the data passed in the items to the table and it will re-render itself appropriately. The table will throw a sort event as needed, and helper components for paging and filtering are coming soon.
|
|
@@ -201,6 +208,22 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
201
208
|
}
|
|
202
209
|
});
|
|
203
210
|
|
|
211
|
+
_defineProperty(_assertThisInitialized(_this), "repositionResizers", function () {
|
|
212
|
+
var headers = [].concat(_this.headerRefs.select, _this.headerRefs.column, _this.headerRefs.action);
|
|
213
|
+
|
|
214
|
+
if (_this.gripRefs && _this.tableRef) {
|
|
215
|
+
var tableOffset = _this.tableRef.getBoundingClientRect();
|
|
216
|
+
|
|
217
|
+
_this.gripRefs.forEach(function (grip, index) {
|
|
218
|
+
var header = headers[index].getBoundingClientRect();
|
|
219
|
+
var relativeOffset = header.left - tableOffset.left;
|
|
220
|
+
var newPosition = relativeOffset + header.width; // eslint-disable-next-line no-param-reassign
|
|
221
|
+
|
|
222
|
+
grip.style.left = "".concat(newPosition, "px");
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
|
|
204
227
|
_defineProperty(_assertThisInitialized(_this), "resizeFixedHeaders", function (event) {
|
|
205
228
|
var headerRefs = [].concat(_this.headerRefs.select, _this.headerRefs.column, _this.headerRefs.action);
|
|
206
229
|
|
|
@@ -268,6 +291,8 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
268
291
|
_this.scrollerRef[action]('scroll', _this.resizeFixedHeaders);
|
|
269
292
|
|
|
270
293
|
_this.scrollerRef[action]('scroll', _this.loadMoreIfNeeded);
|
|
294
|
+
|
|
295
|
+
_this.scrollerRef[action]('scroll', _this.repositionResizers);
|
|
271
296
|
}
|
|
272
297
|
}
|
|
273
298
|
});
|
|
@@ -278,7 +303,9 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
278
303
|
column: [],
|
|
279
304
|
select: []
|
|
280
305
|
};
|
|
306
|
+
_this.gripRefs = [];
|
|
281
307
|
_this.scrollerRef = null;
|
|
308
|
+
_this.fixedHeaderContainer = {};
|
|
282
309
|
_this.state = {
|
|
283
310
|
// Currently selected cell
|
|
284
311
|
activeCell: {
|
|
@@ -309,15 +336,19 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
309
336
|
_createClass(DataTable, [{
|
|
310
337
|
key: "componentDidMount",
|
|
311
338
|
value: function componentDidMount() {
|
|
312
|
-
if (this.
|
|
339
|
+
if (this.getFixedHeader()) {
|
|
313
340
|
this.toggleFixedHeaderListeners(true);
|
|
314
341
|
this.resizeFixedHeaders();
|
|
315
342
|
}
|
|
343
|
+
|
|
344
|
+
if (this.isResizable()) {
|
|
345
|
+
this.enableResize();
|
|
346
|
+
}
|
|
316
347
|
}
|
|
317
348
|
}, {
|
|
318
349
|
key: "componentDidUpdate",
|
|
319
350
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
320
|
-
if (this.
|
|
351
|
+
if (this.getFixedHeader()) {
|
|
321
352
|
this.resizeFixedHeaders(); // If the first page of results isn't enough to allow the user to scroll it causes
|
|
322
353
|
// the user to get into a state where they cannot load the second page.
|
|
323
354
|
// Simulating a scroll here will ensure that enough rows are loaded to enable scrolling
|
|
@@ -339,17 +370,63 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
339
370
|
tableHasFocus: true
|
|
340
371
|
});
|
|
341
372
|
}
|
|
373
|
+
|
|
374
|
+
if (this.isResizable()) {
|
|
375
|
+
this.enableResize();
|
|
376
|
+
} else if (this.resizer) {
|
|
377
|
+
this.disableResize();
|
|
378
|
+
}
|
|
342
379
|
}
|
|
343
380
|
}, {
|
|
344
381
|
key: "componentWillUnmount",
|
|
345
382
|
value: function componentWillUnmount() {
|
|
346
383
|
this.toggleFixedHeaderListeners(false);
|
|
384
|
+
|
|
385
|
+
if (this.isResizable()) {
|
|
386
|
+
this.disableResize();
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}, {
|
|
390
|
+
key: "onResize",
|
|
391
|
+
value: function onResize() {
|
|
392
|
+
var table = this.tableRef;
|
|
393
|
+
|
|
394
|
+
if (table) {
|
|
395
|
+
var columns = this.getFixedHeader() ? table.getElementsByClassName('slds-cell-fixed') : table.getElementsByTagName('th');
|
|
396
|
+
var columnsWidths = Array.from(columns).map(function (_ref2, index) {
|
|
397
|
+
var id = _ref2.id,
|
|
398
|
+
style = _ref2.style;
|
|
399
|
+
return {
|
|
400
|
+
id: id,
|
|
401
|
+
index: index,
|
|
402
|
+
width: parseInt(style.width, 10)
|
|
403
|
+
};
|
|
404
|
+
});
|
|
405
|
+
return columnsWidths;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return [];
|
|
347
409
|
}
|
|
348
410
|
}, {
|
|
349
411
|
key: "getId",
|
|
350
412
|
value: function getId() {
|
|
351
413
|
return this.props.id || this.generatedId;
|
|
352
414
|
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "getFixedHeader",
|
|
417
|
+
value: function getFixedHeader() {
|
|
418
|
+
return this.props.fixedHeader || this.props.resizable;
|
|
419
|
+
}
|
|
420
|
+
}, {
|
|
421
|
+
key: "getKeyboardNavigation",
|
|
422
|
+
value: function getKeyboardNavigation() {
|
|
423
|
+
return this.props.keyboardNavigation || this.props.resizable;
|
|
424
|
+
}
|
|
425
|
+
}, {
|
|
426
|
+
key: "getFixedLayout",
|
|
427
|
+
value: function getFixedLayout() {
|
|
428
|
+
return this.props.fixedLayout || this.props.resizable;
|
|
429
|
+
}
|
|
353
430
|
}, {
|
|
354
431
|
key: "getFirstInteractiveElement",
|
|
355
432
|
value: function getFirstInteractiveElement(rowIndex, columnIndex) {
|
|
@@ -359,6 +436,86 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
359
436
|
|
|
360
437
|
return null;
|
|
361
438
|
}
|
|
439
|
+
}, {
|
|
440
|
+
key: "isResizable",
|
|
441
|
+
value: function isResizable() {
|
|
442
|
+
return this.props.fixedLayout && this.props.resizable;
|
|
443
|
+
}
|
|
444
|
+
}, {
|
|
445
|
+
key: "resizeGrips",
|
|
446
|
+
value: function resizeGrips() {
|
|
447
|
+
var table = this.fixedHeaderContainer;
|
|
448
|
+
|
|
449
|
+
if (table) {
|
|
450
|
+
var grips = Array.from(table.getElementsByClassName('grip-handle'));
|
|
451
|
+
|
|
452
|
+
if (grips.length) {
|
|
453
|
+
this.gripRefs = grips;
|
|
454
|
+
this.gripRefs.forEach(function (grip) {
|
|
455
|
+
// eslint-disable-next-line no-param-reassign
|
|
456
|
+
grip.style.height = "".concat(parseInt(grip.style.height, 10) + 33, "px");
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}, {
|
|
462
|
+
key: "enableResize",
|
|
463
|
+
value: function enableResize() {
|
|
464
|
+
var _this2 = this;
|
|
465
|
+
|
|
466
|
+
if (_executionEnvironment.canUseDOM) {
|
|
467
|
+
var remoteTable = this.tableRef;
|
|
468
|
+
var fixedHeader = this.getFixedHeader();
|
|
469
|
+
var disabledColumns = [];
|
|
470
|
+
|
|
471
|
+
if (this.props.selectRows) {
|
|
472
|
+
// eslint-disable-next-line fp/no-mutating-methods
|
|
473
|
+
disabledColumns.push(0);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (!this.resizer) {
|
|
477
|
+
var options = _objectSpread(_objectSpread(_objectSpread({}, defaultProps.resizableOptions), {
|
|
478
|
+
disabledColumns: disabledColumns
|
|
479
|
+
}), this.props.resizableOptions);
|
|
480
|
+
|
|
481
|
+
var externalFunction = this.props.resizableOptions.onResize;
|
|
482
|
+
|
|
483
|
+
options.onResize = function (e) {
|
|
484
|
+
if (fixedHeader) {
|
|
485
|
+
_this2.resizeFixedHeaders(e);
|
|
486
|
+
|
|
487
|
+
_this2.repositionResizers();
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
var response = _this2.onResize();
|
|
491
|
+
|
|
492
|
+
if (externalFunction) externalFunction(response);
|
|
493
|
+
|
|
494
|
+
_this2.resizeGrips();
|
|
495
|
+
};
|
|
496
|
+
|
|
497
|
+
if (remoteTable) {
|
|
498
|
+
this.resizer = new _columnResizer.default(remoteTable, options);
|
|
499
|
+
remoteTable.classList.remove('grip-padding');
|
|
500
|
+
if (fixedHeader) this.resizeFixedHeaders();
|
|
501
|
+
this.resizeGrips();
|
|
502
|
+
this.repositionResizers();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
this.setState({}, function () {
|
|
506
|
+
return _this2.state;
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}, {
|
|
512
|
+
key: "disableResize",
|
|
513
|
+
value: function disableResize() {
|
|
514
|
+
if (this.resizer) this.resizer.reset({
|
|
515
|
+
disable: true
|
|
516
|
+
});
|
|
517
|
+
this.gripRefs = [];
|
|
518
|
+
}
|
|
362
519
|
}, {
|
|
363
520
|
key: "changeActiveCell",
|
|
364
521
|
value: function changeActiveCell(rowIndex, columnIndex) {
|
|
@@ -381,116 +538,161 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
381
538
|
}, {
|
|
382
539
|
key: "handleKeyDown",
|
|
383
540
|
value: function handleKeyDown(event) {
|
|
384
|
-
var
|
|
541
|
+
var _this3 = this,
|
|
385
542
|
_callbacks;
|
|
386
543
|
|
|
387
544
|
(0, _keyCallbacks.default)(event, {
|
|
388
545
|
callbacks: (_callbacks = {}, _defineProperty(_callbacks, _keyCode.default.UP, {
|
|
389
546
|
callback: function callback(evt) {
|
|
390
|
-
return
|
|
547
|
+
return _this3.handleKeyDownUp(evt);
|
|
391
548
|
}
|
|
392
549
|
}), _defineProperty(_callbacks, _keyCode.default.DOWN, {
|
|
393
550
|
callback: function callback(evt) {
|
|
394
|
-
return
|
|
551
|
+
return _this3.handleKeyDownDown(evt);
|
|
395
552
|
}
|
|
396
553
|
}), _defineProperty(_callbacks, _keyCode.default.LEFT, {
|
|
397
554
|
callback: function callback(evt) {
|
|
398
|
-
return
|
|
555
|
+
return _this3.handleKeyDownLeft(evt);
|
|
399
556
|
}
|
|
400
557
|
}), _defineProperty(_callbacks, _keyCode.default.RIGHT, {
|
|
401
558
|
callback: function callback(evt) {
|
|
402
|
-
return
|
|
559
|
+
return _this3.handleKeyDownRight(evt);
|
|
403
560
|
}
|
|
404
561
|
}), _defineProperty(_callbacks, _keyCode.default.ENTER, {
|
|
405
562
|
callback: function callback(evt) {
|
|
406
|
-
return
|
|
563
|
+
return _this3.handleKeyDownEnter(evt);
|
|
407
564
|
}
|
|
408
565
|
}), _defineProperty(_callbacks, _keyCode.default.ESCAPE, {
|
|
409
566
|
callback: function callback(evt) {
|
|
410
|
-
return
|
|
567
|
+
return _this3.handleKeyDownEscape(evt);
|
|
568
|
+
}
|
|
569
|
+
}), _defineProperty(_callbacks, _keyCode.default.TAB, this.state.mode === _mode.default.ACTIONABLE ? {
|
|
570
|
+
callback: function callback(evt) {
|
|
571
|
+
return _this3.handleKeyTabPress(evt);
|
|
411
572
|
}
|
|
412
|
-
}), _callbacks)
|
|
573
|
+
} : null), _callbacks)
|
|
413
574
|
});
|
|
414
575
|
}
|
|
415
576
|
}, {
|
|
416
577
|
key: "handleKeyDownUp",
|
|
417
578
|
value: function handleKeyDownUp() {
|
|
418
|
-
|
|
419
|
-
|
|
579
|
+
if (this.state.mode === _mode.default.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
580
|
+
var newRowIndex = Math.max(this.state.activeCell.rowIndex - 1, 0);
|
|
581
|
+
var activeElement = this.getFirstInteractiveElement(newRowIndex, this.state.activeCell.columnIndex);
|
|
582
|
+
|
|
583
|
+
if (newRowIndex !== this.state.activeCell.rowIndex) {
|
|
584
|
+
this.setState(function (prevState) {
|
|
585
|
+
return {
|
|
586
|
+
activeCell: {
|
|
587
|
+
rowIndex: newRowIndex,
|
|
588
|
+
columnIndex: prevState.activeCell.columnIndex
|
|
589
|
+
},
|
|
590
|
+
activeElement: activeElement
|
|
591
|
+
};
|
|
592
|
+
});
|
|
420
593
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
rowIndex: newRowIndex,
|
|
426
|
-
columnIndex: prevState.activeCell.columnIndex
|
|
427
|
-
},
|
|
428
|
-
activeElement: activeElement
|
|
429
|
-
};
|
|
430
|
-
});
|
|
594
|
+
if (this.state.mode === _mode.default.ACTIONABLE && newRowIndex === 0 && !activeElement) {
|
|
595
|
+
this.makeGripVisible(this.state.activeCell.columnIndex);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
431
598
|
}
|
|
432
599
|
}
|
|
433
600
|
}, {
|
|
434
601
|
key: "handleKeyDownDown",
|
|
435
602
|
value: function handleKeyDownDown() {
|
|
436
|
-
|
|
437
|
-
|
|
603
|
+
if (this.state.mode === _mode.default.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
604
|
+
var newRowIndex = Math.min(this.state.activeCell.rowIndex + 1, this.props.items.length);
|
|
605
|
+
var activeElement = this.getFirstInteractiveElement(newRowIndex, this.state.activeCell.columnIndex);
|
|
606
|
+
|
|
607
|
+
if (newRowIndex !== this.state.activeCell.rowIndex) {
|
|
608
|
+
this.setState(function (prevState) {
|
|
609
|
+
return {
|
|
610
|
+
activeCell: {
|
|
611
|
+
rowIndex: newRowIndex,
|
|
612
|
+
columnIndex: prevState.activeCell.columnIndex
|
|
613
|
+
},
|
|
614
|
+
activeElement: activeElement
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
key: "displaceByArrowKey",
|
|
622
|
+
value: function displaceByArrowKey(factor) {
|
|
623
|
+
if (this.state.mode === _mode.default.ACTIONABLE) {
|
|
624
|
+
var _this$state$activeCel = this.state.activeCell,
|
|
625
|
+
rowIndex = _this$state$activeCel.rowIndex,
|
|
626
|
+
columnIndex = _this$state$activeCel.columnIndex;
|
|
438
627
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
};
|
|
448
|
-
});
|
|
628
|
+
if (rowIndex === 0) {
|
|
629
|
+
var table = this.tableRef;
|
|
630
|
+
var headers = table.getElementsByTagName('th');
|
|
631
|
+
headers[columnIndex].style.width = "".concat(parseInt(headers[columnIndex].style.width, 10) + factor, "px");
|
|
632
|
+
this.resizeFixedHeaders();
|
|
633
|
+
this.repositionResizers();
|
|
634
|
+
this.resizeGrips();
|
|
635
|
+
}
|
|
449
636
|
}
|
|
450
637
|
}
|
|
638
|
+
}, {
|
|
639
|
+
key: "makeGripVisible",
|
|
640
|
+
value: function makeGripVisible(newIndex) {
|
|
641
|
+
this.gripRefs.forEach(function (grip, index) {
|
|
642
|
+
if (index === newIndex) grip.classList.add('grip-handle-active');else grip.classList.remove('grip-handle-active');
|
|
643
|
+
});
|
|
644
|
+
}
|
|
451
645
|
}, {
|
|
452
646
|
key: "handleKeyDownLeft",
|
|
453
647
|
value: function handleKeyDownLeft() {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
this.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
648
|
+
if (this.state.mode === _mode.default.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
649
|
+
var newColumnIndex = Math.max(this.state.activeCell.columnIndex - 1, 0);
|
|
650
|
+
var activeElement = this.getFirstInteractiveElement(this.state.activeCell.rowIndex, newColumnIndex);
|
|
651
|
+
|
|
652
|
+
if (newColumnIndex !== this.state.activeCell.columnIndex) {
|
|
653
|
+
this.setState(function (prevState) {
|
|
654
|
+
return {
|
|
655
|
+
activeCell: {
|
|
656
|
+
rowIndex: prevState.activeCell.rowIndex,
|
|
657
|
+
columnIndex: newColumnIndex
|
|
658
|
+
},
|
|
659
|
+
activeElement: activeElement
|
|
660
|
+
};
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
} else {
|
|
664
|
+
this.displaceByArrowKey(-10);
|
|
467
665
|
}
|
|
468
666
|
}
|
|
469
667
|
}, {
|
|
470
668
|
key: "handleKeyDownRight",
|
|
471
669
|
value: function handleKeyDownRight() {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
this.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
670
|
+
if (this.state.mode === _mode.default.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
671
|
+
var newColumnIndex = Math.min(this.state.activeCell.columnIndex + 1, this.props.children.length - (this.props.selectRows ? 0 : 1));
|
|
672
|
+
var activeElement = this.getFirstInteractiveElement(this.state.activeCell.rowIndex, newColumnIndex);
|
|
673
|
+
|
|
674
|
+
if (newColumnIndex !== this.state.activeCell.columnIndex) {
|
|
675
|
+
this.setState(function (prevState) {
|
|
676
|
+
return {
|
|
677
|
+
activeCell: {
|
|
678
|
+
rowIndex: prevState.activeCell.rowIndex,
|
|
679
|
+
columnIndex: newColumnIndex
|
|
680
|
+
},
|
|
681
|
+
activeElement: activeElement
|
|
682
|
+
};
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
} else {
|
|
686
|
+
this.displaceByArrowKey(10);
|
|
485
687
|
}
|
|
486
688
|
}
|
|
487
689
|
}, {
|
|
488
690
|
key: "handleKeyDownEnter",
|
|
489
691
|
value: function handleKeyDownEnter() {
|
|
490
692
|
if (this.state.mode === _mode.default.NAVIGATION) {
|
|
491
|
-
var _this$state$
|
|
492
|
-
rowIndex = _this$state$
|
|
493
|
-
columnIndex = _this$state$
|
|
693
|
+
var _this$state$activeCel2 = this.state.activeCell,
|
|
694
|
+
rowIndex = _this$state$activeCel2.rowIndex,
|
|
695
|
+
columnIndex = _this$state$activeCel2.columnIndex;
|
|
494
696
|
var activeElement = null;
|
|
495
697
|
|
|
496
698
|
if (this.interactiveElements[rowIndex] && this.interactiveElements[rowIndex][columnIndex]) {
|
|
@@ -503,6 +705,10 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
503
705
|
mode: _mode.default.ACTIONABLE,
|
|
504
706
|
activeElement: activeElement
|
|
505
707
|
});
|
|
708
|
+
|
|
709
|
+
if (rowIndex === 0 && !activeElement) {
|
|
710
|
+
this.makeGripVisible(columnIndex);
|
|
711
|
+
}
|
|
506
712
|
}
|
|
507
713
|
}
|
|
508
714
|
}, {
|
|
@@ -513,6 +719,99 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
513
719
|
mode: _mode.default.NAVIGATION,
|
|
514
720
|
activeElement: null
|
|
515
721
|
});
|
|
722
|
+
this.makeGripVisible(null);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}, {
|
|
726
|
+
key: "moveNext",
|
|
727
|
+
value: function moveNext(event, rowIndex, columnIndex) {
|
|
728
|
+
var headers = [].concat(this.headerRefs.select, this.headerRefs.column, this.headerRefs.action);
|
|
729
|
+
var newRowIndex = 0;
|
|
730
|
+
var newColumnIndex = 0;
|
|
731
|
+
|
|
732
|
+
if (event.shiftKey) {
|
|
733
|
+
if (columnIndex - 1 >= 0) {
|
|
734
|
+
newColumnIndex = columnIndex - 1;
|
|
735
|
+
newRowIndex = rowIndex;
|
|
736
|
+
} else {
|
|
737
|
+
if (rowIndex > 0) newRowIndex = rowIndex - 1;else newRowIndex = this.props.items.length;
|
|
738
|
+
newColumnIndex = headers.length - 1;
|
|
739
|
+
}
|
|
740
|
+
} else if (columnIndex + 1 < headers.length) {
|
|
741
|
+
newColumnIndex = columnIndex + 1;
|
|
742
|
+
newRowIndex = rowIndex;
|
|
743
|
+
} else {
|
|
744
|
+
if (rowIndex < this.props.items.length) newRowIndex = rowIndex + 1;else newRowIndex = 0;
|
|
745
|
+
newColumnIndex = 0;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
this.changeActiveCell(newRowIndex, newColumnIndex);
|
|
749
|
+
}
|
|
750
|
+
}, {
|
|
751
|
+
key: "handleNextActionable",
|
|
752
|
+
value: function handleNextActionable(event) {
|
|
753
|
+
var _this$state$activeCel3 = this.state.activeCell,
|
|
754
|
+
rowIndex = _this$state$activeCel3.rowIndex,
|
|
755
|
+
columnIndex = _this$state$activeCel3.columnIndex;
|
|
756
|
+
var currentActiveElement = this.state.activeElement;
|
|
757
|
+
var rowActiveElements = this.interactiveElements[rowIndex] && this.interactiveElements[rowIndex][columnIndex] ? this.interactiveElements[rowIndex][columnIndex] : null;
|
|
758
|
+
|
|
759
|
+
if (rowActiveElements) {
|
|
760
|
+
if (currentActiveElement) {
|
|
761
|
+
var index = rowActiveElements.indexOf(currentActiveElement);
|
|
762
|
+
|
|
763
|
+
if (event.shiftKey) {
|
|
764
|
+
return index > 0 ? rowActiveElements[index - 1] : null;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
return index < rowActiveElements.length - 1 ? rowActiveElements[index + 1] : null;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
return !event.shiftKey ? rowActiveElements[0] : rowActiveElements[rowActiveElements.length - 1];
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
}, {
|
|
776
|
+
key: "handleKeyTabPress",
|
|
777
|
+
value: function handleKeyTabPress(event) {
|
|
778
|
+
var _this$state$activeCel4 = this.state.activeCell,
|
|
779
|
+
rowIndex = _this$state$activeCel4.rowIndex,
|
|
780
|
+
columnIndex = _this$state$activeCel4.columnIndex;
|
|
781
|
+
|
|
782
|
+
if (this.state.mode === _mode.default.ACTIONABLE) {
|
|
783
|
+
var nextActionable = this.handleNextActionable(event);
|
|
784
|
+
|
|
785
|
+
if (nextActionable) {
|
|
786
|
+
this.setState({
|
|
787
|
+
activeElement: nextActionable
|
|
788
|
+
});
|
|
789
|
+
if (this.isResizable()) this.makeGripVisible(null);
|
|
790
|
+
} else if (rowIndex === 0) {
|
|
791
|
+
var headers = [].concat(this.headerRefs.select, this.headerRefs.column, this.headerRefs.action);
|
|
792
|
+
var newIndex = 0;
|
|
793
|
+
if (!event.shiftKey) newIndex = columnIndex + 1 < headers.length ? columnIndex + 1 : 0;else newIndex = columnIndex - 1 >= 0 ? columnIndex - 1 : headers.length - 1;
|
|
794
|
+
this.setState({
|
|
795
|
+
mode: _mode.default.ACTIONABLE,
|
|
796
|
+
activeElement: null
|
|
797
|
+
}); // eslint-disable-next-line no-param-reassign
|
|
798
|
+
|
|
799
|
+
headers.forEach(function (header, index) {
|
|
800
|
+
if (index === newIndex) {
|
|
801
|
+
// eslint-disable-next-line no-param-reassign
|
|
802
|
+
header.tabIndex = 0; // eslint-disable-next-line no-param-reassign
|
|
803
|
+
|
|
804
|
+
header.focus(); // eslint-disable-next-line no-param-reassign
|
|
805
|
+
} else header.tabIndex = -1;
|
|
806
|
+
});
|
|
807
|
+
if (this.isResizable()) this.makeGripVisible(newIndex);
|
|
808
|
+
} else {
|
|
809
|
+
this.moveNext(event, rowIndex, columnIndex);
|
|
810
|
+
this.setState({
|
|
811
|
+
mode: _mode.default.ACTIONABLE,
|
|
812
|
+
activeElement: null
|
|
813
|
+
});
|
|
814
|
+
}
|
|
516
815
|
}
|
|
517
816
|
}
|
|
518
817
|
}, {
|
|
@@ -523,13 +822,16 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
523
822
|
}
|
|
524
823
|
|
|
525
824
|
var existingElements = this.interactiveElements[rowIndex][columnIndex] || [];
|
|
526
|
-
|
|
825
|
+
|
|
826
|
+
if (!existingElements.includes(elementId)) {
|
|
827
|
+
this.interactiveElements[rowIndex][columnIndex] = [].concat(_toConsumableArray(existingElements), [elementId]);
|
|
828
|
+
}
|
|
527
829
|
} // ### Render
|
|
528
830
|
|
|
529
831
|
}, {
|
|
530
832
|
key: "render",
|
|
531
833
|
value: function render() {
|
|
532
|
-
var
|
|
834
|
+
var _this4 = this;
|
|
533
835
|
|
|
534
836
|
var ariaProps = {};
|
|
535
837
|
var numHeaderRows = 1;
|
|
@@ -550,7 +852,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
550
852
|
children = _child$props.children,
|
|
551
853
|
columnProps = _objectWithoutProperties(_child$props, ["children"]);
|
|
552
854
|
|
|
553
|
-
var props = (0, _lodash.default)({},
|
|
855
|
+
var props = (0, _lodash.default)({}, _this4.props); // eslint-disable-next-line fp/no-delete
|
|
554
856
|
|
|
555
857
|
delete props.children;
|
|
556
858
|
(0, _lodash.default)(props, columnProps);
|
|
@@ -567,13 +869,13 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
567
869
|
columns.push({
|
|
568
870
|
Cell: Cell,
|
|
569
871
|
props: props,
|
|
570
|
-
dataTableProps:
|
|
872
|
+
dataTableProps: _this4.props
|
|
571
873
|
});
|
|
572
874
|
} else if (child && child.type.displayName === _rowActions.default.displayName) {
|
|
573
875
|
var dropdown = child.props.dropdown;
|
|
574
876
|
var dropdownPropOverrides = {};
|
|
575
877
|
|
|
576
|
-
if (
|
|
878
|
+
if (_this4.getFixedHeader()) {
|
|
577
879
|
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
578
880
|
}
|
|
579
881
|
|
|
@@ -630,8 +932,8 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
630
932
|
registerInteractiveElement: this.registerInteractiveElement,
|
|
631
933
|
allowKeyboardNavigation: this.state.allowKeyboardNavigation,
|
|
632
934
|
setAllowKeyboardNavigation: function setAllowKeyboardNavigation(allowKeyboardNavigation) {
|
|
633
|
-
if (
|
|
634
|
-
|
|
935
|
+
if (_this4.getKeyboardNavigation()) {
|
|
936
|
+
_this4.setState({
|
|
635
937
|
allowKeyboardNavigation: allowKeyboardNavigation
|
|
636
938
|
});
|
|
637
939
|
}
|
|
@@ -642,50 +944,54 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
642
944
|
value: tableContext
|
|
643
945
|
}, /*#__PURE__*/_react.default.createElement("table", _extends({}, ariaProps, {
|
|
644
946
|
className: (0, _classnames.default)('slds-table', {
|
|
645
|
-
'slds-table_fixed-layout': this.
|
|
646
|
-
'slds-table_header-fixed': this.
|
|
647
|
-
'slds-table_resizable-cols': this.
|
|
947
|
+
'slds-table_fixed-layout': this.getFixedLayout(),
|
|
948
|
+
'slds-table_header-fixed': this.getFixedHeader(),
|
|
949
|
+
'slds-table_resizable-cols': this.getFixedLayout(),
|
|
648
950
|
'slds-table_bordered': !this.props.unborderedRow,
|
|
649
|
-
'slds-table_cell-buffer': !this.
|
|
951
|
+
'slds-table_cell-buffer': !this.getFixedLayout() && !this.props.unbufferedCell,
|
|
650
952
|
'slds-max-medium-table_stacked': this.props.stacked,
|
|
651
953
|
'slds-max-medium-table_stacked-horizontal': this.props.stackedHorizontal,
|
|
652
954
|
'slds-table_striped': this.props.striped,
|
|
653
955
|
'slds-table_col-bordered': this.props.columnBordered,
|
|
654
|
-
'slds-no-row-hover': this.props.noRowHover
|
|
956
|
+
'slds-no-row-hover': this.props.noRowHover,
|
|
957
|
+
'slds-table_header-hidden': this.props.isHeadless
|
|
655
958
|
}, this.props.className),
|
|
656
959
|
id: this.getId(),
|
|
657
960
|
ref: function ref(node) {
|
|
658
961
|
if (node) {
|
|
659
|
-
|
|
962
|
+
_this4.tableRef = node;
|
|
660
963
|
}
|
|
661
964
|
},
|
|
662
|
-
role: this.
|
|
965
|
+
role: this.getFixedLayout() ? 'grid' : null,
|
|
663
966
|
onBlur: function onBlur(event) {
|
|
664
|
-
if (
|
|
665
|
-
|
|
967
|
+
if (_this4.tableRef && !_this4.tableRef.contains(event.relatedTarget)) {
|
|
968
|
+
_this4.setState({
|
|
666
969
|
tableHasFocus: false,
|
|
667
970
|
mode: _mode.default.NAVIGATION,
|
|
668
971
|
activeElement: null
|
|
669
972
|
});
|
|
973
|
+
|
|
974
|
+
_this4.makeGripVisible(null);
|
|
670
975
|
}
|
|
671
976
|
},
|
|
672
977
|
style: this.props.style
|
|
673
978
|
}), /*#__PURE__*/_react.default.createElement(_head.default, {
|
|
674
979
|
assistiveText: assistiveText,
|
|
675
980
|
allSelected: allSelected,
|
|
676
|
-
fixedHeader: this.
|
|
677
|
-
fixedLayout: this.
|
|
981
|
+
fixedHeader: this.getFixedHeader(),
|
|
982
|
+
fixedLayout: this.getFixedLayout(),
|
|
678
983
|
headerRefs: function headerRefs(ref, index) {
|
|
679
984
|
if (index === 'action' || index === 'select') {
|
|
680
985
|
if (ref) {
|
|
681
|
-
|
|
986
|
+
_this4.headerRefs[index][0] = ref;
|
|
682
987
|
} else {
|
|
683
|
-
|
|
988
|
+
_this4.headerRefs[index] = [];
|
|
684
989
|
}
|
|
685
990
|
} else {
|
|
686
|
-
|
|
991
|
+
_this4.headerRefs.column[index] = ref;
|
|
687
992
|
}
|
|
688
993
|
},
|
|
994
|
+
isHidden: this.props.isHeadless,
|
|
689
995
|
indeterminateSelected: indeterminateSelected,
|
|
690
996
|
canSelectRows: canSelectRows,
|
|
691
997
|
columns: columns,
|
|
@@ -694,33 +1000,33 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
694
1000
|
onSort: this.props.onSort,
|
|
695
1001
|
showRowActions: !!RowActions
|
|
696
1002
|
}), /*#__PURE__*/_react.default.createElement("tbody", null, numRows > 0 ? this.props.items.map(function (item, index) {
|
|
697
|
-
var rowId =
|
|
698
|
-
return
|
|
1003
|
+
var rowId = _this4.getId() && item.id ? "".concat(_this4.getId(), "-").concat(_constants.DATA_TABLE_ROW, "-").concat(item.id) : _shortid.default.generate();
|
|
1004
|
+
return _this4.props.onRenderSubHeadingRow && item.type === 'header-row' ? _this4.props.onRenderSubHeadingRow({
|
|
699
1005
|
assistiveText: assistiveText,
|
|
700
1006
|
classNameRow: item.classNameRow,
|
|
701
1007
|
columns: columns,
|
|
702
1008
|
key: rowId,
|
|
703
1009
|
id: rowId,
|
|
704
|
-
tableId:
|
|
1010
|
+
tableId: _this4.getId(),
|
|
705
1011
|
item: item
|
|
706
1012
|
}) : /*#__PURE__*/_react.default.createElement(_row.default, {
|
|
707
1013
|
assistiveText: assistiveText,
|
|
708
1014
|
canSelectRows: canSelectRows,
|
|
709
1015
|
className: item.classNameRow,
|
|
710
1016
|
columns: columns,
|
|
711
|
-
fixedLayout:
|
|
1017
|
+
fixedLayout: _this4.getFixedLayout(),
|
|
712
1018
|
id: rowId,
|
|
713
1019
|
index: index,
|
|
714
1020
|
item: item,
|
|
715
1021
|
key: rowId,
|
|
716
|
-
onToggle:
|
|
717
|
-
selection:
|
|
1022
|
+
onToggle: _this4.handleRowToggle,
|
|
1023
|
+
selection: _this4.props.selection,
|
|
718
1024
|
rowActions: RowActions,
|
|
719
|
-
tableId:
|
|
1025
|
+
tableId: _this4.getId(),
|
|
720
1026
|
rowIndex: index + numHeaderRows
|
|
721
1027
|
});
|
|
722
1028
|
}) : // Someday this should be an element to render when the table is empty
|
|
723
|
-
null))), this.
|
|
1029
|
+
null))), this.getFixedHeader() && this.props.hasMore && /*#__PURE__*/_react.default.createElement("div", {
|
|
724
1030
|
className: "slds-is-relative slds-p-around_large"
|
|
725
1031
|
}, /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
726
1032
|
assistiveText: {
|
|
@@ -731,7 +1037,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
731
1037
|
variant: "brand"
|
|
732
1038
|
})));
|
|
733
1039
|
|
|
734
|
-
if (this.
|
|
1040
|
+
if (this.getFixedHeader()) {
|
|
735
1041
|
var border = "1px solid ".concat(_paletteColors.colorGray5);
|
|
736
1042
|
var styles = {
|
|
737
1043
|
borderTop: border,
|
|
@@ -746,8 +1052,22 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
746
1052
|
styles.borderRadius = _salesforceSkin.tableBorderRadius;
|
|
747
1053
|
}
|
|
748
1054
|
|
|
1055
|
+
var fixedScrollerStyle = {
|
|
1056
|
+
height: '100%'
|
|
1057
|
+
};
|
|
1058
|
+
|
|
1059
|
+
if (this.props.resizable) {
|
|
1060
|
+
fixedScrollerStyle.overflowY = 'auto';
|
|
1061
|
+
fixedScrollerStyle.overflowX = 'hidden';
|
|
1062
|
+
} else {
|
|
1063
|
+
fixedScrollerStyle.overflow = 'auto';
|
|
1064
|
+
}
|
|
1065
|
+
|
|
749
1066
|
component = /*#__PURE__*/_react.default.createElement("div", {
|
|
750
1067
|
className: "slds-table_header-fixed_container",
|
|
1068
|
+
ref: function ref(_ref4) {
|
|
1069
|
+
_this4.fixedHeaderContainer = _ref4;
|
|
1070
|
+
},
|
|
751
1071
|
style: styles,
|
|
752
1072
|
onScroll: function onScroll(e) {
|
|
753
1073
|
var containerScrollLeft = e.target.scrollLeft;
|
|
@@ -755,20 +1075,17 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
755
1075
|
if (containerScrollLeft > 0) {
|
|
756
1076
|
e.target.scrollLeft = 0;
|
|
757
1077
|
|
|
758
|
-
if (
|
|
759
|
-
|
|
1078
|
+
if (_this4.scrollerRef) {
|
|
1079
|
+
_this4.scrollerRef.scrollLeft = containerScrollLeft;
|
|
760
1080
|
}
|
|
761
1081
|
}
|
|
762
1082
|
}
|
|
763
1083
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
764
1084
|
className: "slds-table_header-fixed_scroller",
|
|
765
|
-
ref: function ref(
|
|
766
|
-
|
|
1085
|
+
ref: function ref(_ref3) {
|
|
1086
|
+
_this4.scrollerRef = _ref3;
|
|
767
1087
|
},
|
|
768
|
-
style:
|
|
769
|
-
height: '100%',
|
|
770
|
-
overflow: 'auto'
|
|
771
|
-
}
|
|
1088
|
+
style: fixedScrollerStyle
|
|
772
1089
|
}, component));
|
|
773
1090
|
}
|
|
774
1091
|
|
|
@@ -908,6 +1225,11 @@ _defineProperty(DataTable, "propTypes", {
|
|
|
908
1225
|
classNameRow: _propTypes.default.string
|
|
909
1226
|
})).isRequired,
|
|
910
1227
|
|
|
1228
|
+
/**
|
|
1229
|
+
* Removes the header from the data table. Tested with snapshot testing
|
|
1230
|
+
*/
|
|
1231
|
+
isHeadless: _propTypes.default.bool,
|
|
1232
|
+
|
|
911
1233
|
/**
|
|
912
1234
|
* Makes DataTable joinable with PageHeader by adding appropriate classes/styling
|
|
913
1235
|
*/
|
|
@@ -999,7 +1321,22 @@ _defineProperty(DataTable, "propTypes", {
|
|
|
999
1321
|
/**
|
|
1000
1322
|
* A variant which removes horizontal padding. CSS class will be removed if `fixedLayout==true`.
|
|
1001
1323
|
*/
|
|
1002
|
-
unbufferedCell: _propTypes.default.bool
|
|
1324
|
+
unbufferedCell: _propTypes.default.bool,
|
|
1325
|
+
|
|
1326
|
+
/**
|
|
1327
|
+
* A variant which allows column dividers to be grabbed with the mouse. This feature needs
|
|
1328
|
+
* `@salesforce/design-system-react/assets/styles/table.css` to be loaded. This prop is in prototype` state. a) It may change within a minor release. (b) Web Content Accessibility Guidelines may not be met. (c) CSS imports may be required.
|
|
1329
|
+
*/
|
|
1330
|
+
resizable: _propTypes.default.bool,
|
|
1331
|
+
|
|
1332
|
+
/**
|
|
1333
|
+
* Object with properties to be used in case of resizable: true
|
|
1334
|
+
*
|
|
1335
|
+
* resizeMode: It is used to set how the resize method works. Those are the possible values: 'fit', 'flex' and 'overflow'
|
|
1336
|
+
* onResize: Callback function to be fired when the user has ended dragging a column
|
|
1337
|
+
* `@salesforce/design-system-react/assets/styles/table.css` to be loaded. This prop is in prototype` state. a) It may change within a minor release. (b) Web Content Accessibility Guidelines may not be met. (c) CSS imports may be required.
|
|
1338
|
+
*/
|
|
1339
|
+
resizableOptions: _propTypes.default.object
|
|
1003
1340
|
});
|
|
1004
1341
|
|
|
1005
1342
|
_defineProperty(DataTable, "defaultProps", defaultProps);
|