@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
|
@@ -2,10 +2,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
4
|
|
|
5
|
-
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; }
|
|
6
|
-
|
|
7
|
-
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; }
|
|
8
|
-
|
|
9
5
|
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; }
|
|
10
6
|
|
|
11
7
|
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; }
|
|
@@ -18,6 +14,10 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
18
14
|
|
|
19
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
20
16
|
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
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; }
|
|
20
|
+
|
|
21
21
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
22
22
|
|
|
23
23
|
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."); }
|
|
@@ -69,6 +69,7 @@ import classNames from 'classnames';
|
|
|
69
69
|
import assign from 'lodash.assign';
|
|
70
70
|
import reject from 'lodash.reject'; // This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)
|
|
71
71
|
|
|
72
|
+
import ColumnResizer from 'column-resizer';
|
|
72
73
|
import checkProps from './check-props';
|
|
73
74
|
import componentDoc from './component.json';
|
|
74
75
|
import { canUseDOM, canUseEventListeners } from '../../utilities/execution-environment';
|
|
@@ -104,7 +105,12 @@ var defaultProps = {
|
|
|
104
105
|
},
|
|
105
106
|
selection: [],
|
|
106
107
|
hasMore: false,
|
|
107
|
-
loadMoreOffset: 20
|
|
108
|
+
loadMoreOffset: 20,
|
|
109
|
+
resizable: false,
|
|
110
|
+
resizableOptions: {
|
|
111
|
+
resizeMode: 'fit',
|
|
112
|
+
draggingClass: 'slds-table-column-resizer'
|
|
113
|
+
}
|
|
108
114
|
};
|
|
109
115
|
/**
|
|
110
116
|
* 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.
|
|
@@ -182,6 +188,22 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
182
188
|
}
|
|
183
189
|
});
|
|
184
190
|
|
|
191
|
+
_defineProperty(_assertThisInitialized(_this), "repositionResizers", function () {
|
|
192
|
+
var headers = [].concat(_this.headerRefs.select, _this.headerRefs.column, _this.headerRefs.action);
|
|
193
|
+
|
|
194
|
+
if (_this.gripRefs && _this.tableRef) {
|
|
195
|
+
var tableOffset = _this.tableRef.getBoundingClientRect();
|
|
196
|
+
|
|
197
|
+
_this.gripRefs.forEach(function (grip, index) {
|
|
198
|
+
var header = headers[index].getBoundingClientRect();
|
|
199
|
+
var relativeOffset = header.left - tableOffset.left;
|
|
200
|
+
var newPosition = relativeOffset + header.width; // eslint-disable-next-line no-param-reassign
|
|
201
|
+
|
|
202
|
+
grip.style.left = "".concat(newPosition, "px");
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
185
207
|
_defineProperty(_assertThisInitialized(_this), "resizeFixedHeaders", function (event) {
|
|
186
208
|
var headerRefs = [].concat(_this.headerRefs.select, _this.headerRefs.column, _this.headerRefs.action);
|
|
187
209
|
|
|
@@ -249,6 +271,8 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
249
271
|
_this.scrollerRef[action]('scroll', _this.resizeFixedHeaders);
|
|
250
272
|
|
|
251
273
|
_this.scrollerRef[action]('scroll', _this.loadMoreIfNeeded);
|
|
274
|
+
|
|
275
|
+
_this.scrollerRef[action]('scroll', _this.repositionResizers);
|
|
252
276
|
}
|
|
253
277
|
}
|
|
254
278
|
});
|
|
@@ -259,7 +283,9 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
259
283
|
column: [],
|
|
260
284
|
select: []
|
|
261
285
|
};
|
|
286
|
+
_this.gripRefs = [];
|
|
262
287
|
_this.scrollerRef = null;
|
|
288
|
+
_this.fixedHeaderContainer = {};
|
|
263
289
|
_this.state = {
|
|
264
290
|
// Currently selected cell
|
|
265
291
|
activeCell: {
|
|
@@ -290,15 +316,19 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
290
316
|
_createClass(DataTable, [{
|
|
291
317
|
key: "componentDidMount",
|
|
292
318
|
value: function componentDidMount() {
|
|
293
|
-
if (this.
|
|
319
|
+
if (this.getFixedHeader()) {
|
|
294
320
|
this.toggleFixedHeaderListeners(true);
|
|
295
321
|
this.resizeFixedHeaders();
|
|
296
322
|
}
|
|
323
|
+
|
|
324
|
+
if (this.isResizable()) {
|
|
325
|
+
this.enableResize();
|
|
326
|
+
}
|
|
297
327
|
}
|
|
298
328
|
}, {
|
|
299
329
|
key: "componentDidUpdate",
|
|
300
330
|
value: function componentDidUpdate(prevProps, prevState) {
|
|
301
|
-
if (this.
|
|
331
|
+
if (this.getFixedHeader()) {
|
|
302
332
|
this.resizeFixedHeaders(); // If the first page of results isn't enough to allow the user to scroll it causes
|
|
303
333
|
// the user to get into a state where they cannot load the second page.
|
|
304
334
|
// Simulating a scroll here will ensure that enough rows are loaded to enable scrolling
|
|
@@ -320,17 +350,63 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
320
350
|
tableHasFocus: true
|
|
321
351
|
});
|
|
322
352
|
}
|
|
353
|
+
|
|
354
|
+
if (this.isResizable()) {
|
|
355
|
+
this.enableResize();
|
|
356
|
+
} else if (this.resizer) {
|
|
357
|
+
this.disableResize();
|
|
358
|
+
}
|
|
323
359
|
}
|
|
324
360
|
}, {
|
|
325
361
|
key: "componentWillUnmount",
|
|
326
362
|
value: function componentWillUnmount() {
|
|
327
363
|
this.toggleFixedHeaderListeners(false);
|
|
364
|
+
|
|
365
|
+
if (this.isResizable()) {
|
|
366
|
+
this.disableResize();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}, {
|
|
370
|
+
key: "onResize",
|
|
371
|
+
value: function onResize() {
|
|
372
|
+
var table = this.tableRef;
|
|
373
|
+
|
|
374
|
+
if (table) {
|
|
375
|
+
var columns = this.getFixedHeader() ? table.getElementsByClassName('slds-cell-fixed') : table.getElementsByTagName('th');
|
|
376
|
+
var columnsWidths = Array.from(columns).map(function (_ref2, index) {
|
|
377
|
+
var id = _ref2.id,
|
|
378
|
+
style = _ref2.style;
|
|
379
|
+
return {
|
|
380
|
+
id: id,
|
|
381
|
+
index: index,
|
|
382
|
+
width: parseInt(style.width, 10)
|
|
383
|
+
};
|
|
384
|
+
});
|
|
385
|
+
return columnsWidths;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return [];
|
|
328
389
|
}
|
|
329
390
|
}, {
|
|
330
391
|
key: "getId",
|
|
331
392
|
value: function getId() {
|
|
332
393
|
return this.props.id || this.generatedId;
|
|
333
394
|
}
|
|
395
|
+
}, {
|
|
396
|
+
key: "getFixedHeader",
|
|
397
|
+
value: function getFixedHeader() {
|
|
398
|
+
return this.props.fixedHeader || this.props.resizable;
|
|
399
|
+
}
|
|
400
|
+
}, {
|
|
401
|
+
key: "getKeyboardNavigation",
|
|
402
|
+
value: function getKeyboardNavigation() {
|
|
403
|
+
return this.props.keyboardNavigation || this.props.resizable;
|
|
404
|
+
}
|
|
405
|
+
}, {
|
|
406
|
+
key: "getFixedLayout",
|
|
407
|
+
value: function getFixedLayout() {
|
|
408
|
+
return this.props.fixedLayout || this.props.resizable;
|
|
409
|
+
}
|
|
334
410
|
}, {
|
|
335
411
|
key: "getFirstInteractiveElement",
|
|
336
412
|
value: function getFirstInteractiveElement(rowIndex, columnIndex) {
|
|
@@ -340,6 +416,86 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
340
416
|
|
|
341
417
|
return null;
|
|
342
418
|
}
|
|
419
|
+
}, {
|
|
420
|
+
key: "isResizable",
|
|
421
|
+
value: function isResizable() {
|
|
422
|
+
return this.props.fixedLayout && this.props.resizable;
|
|
423
|
+
}
|
|
424
|
+
}, {
|
|
425
|
+
key: "resizeGrips",
|
|
426
|
+
value: function resizeGrips() {
|
|
427
|
+
var table = this.fixedHeaderContainer;
|
|
428
|
+
|
|
429
|
+
if (table) {
|
|
430
|
+
var grips = Array.from(table.getElementsByClassName('grip-handle'));
|
|
431
|
+
|
|
432
|
+
if (grips.length) {
|
|
433
|
+
this.gripRefs = grips;
|
|
434
|
+
this.gripRefs.forEach(function (grip) {
|
|
435
|
+
// eslint-disable-next-line no-param-reassign
|
|
436
|
+
grip.style.height = "".concat(parseInt(grip.style.height, 10) + 33, "px");
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "enableResize",
|
|
443
|
+
value: function enableResize() {
|
|
444
|
+
var _this2 = this;
|
|
445
|
+
|
|
446
|
+
if (canUseDOM) {
|
|
447
|
+
var remoteTable = this.tableRef;
|
|
448
|
+
var fixedHeader = this.getFixedHeader();
|
|
449
|
+
var disabledColumns = [];
|
|
450
|
+
|
|
451
|
+
if (this.props.selectRows) {
|
|
452
|
+
// eslint-disable-next-line fp/no-mutating-methods
|
|
453
|
+
disabledColumns.push(0);
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (!this.resizer) {
|
|
457
|
+
var options = _objectSpread(_objectSpread(_objectSpread({}, defaultProps.resizableOptions), {
|
|
458
|
+
disabledColumns: disabledColumns
|
|
459
|
+
}), this.props.resizableOptions);
|
|
460
|
+
|
|
461
|
+
var externalFunction = this.props.resizableOptions.onResize;
|
|
462
|
+
|
|
463
|
+
options.onResize = function (e) {
|
|
464
|
+
if (fixedHeader) {
|
|
465
|
+
_this2.resizeFixedHeaders(e);
|
|
466
|
+
|
|
467
|
+
_this2.repositionResizers();
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
var response = _this2.onResize();
|
|
471
|
+
|
|
472
|
+
if (externalFunction) externalFunction(response);
|
|
473
|
+
|
|
474
|
+
_this2.resizeGrips();
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
if (remoteTable) {
|
|
478
|
+
this.resizer = new ColumnResizer(remoteTable, options);
|
|
479
|
+
remoteTable.classList.remove('grip-padding');
|
|
480
|
+
if (fixedHeader) this.resizeFixedHeaders();
|
|
481
|
+
this.resizeGrips();
|
|
482
|
+
this.repositionResizers();
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
this.setState({}, function () {
|
|
486
|
+
return _this2.state;
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
key: "disableResize",
|
|
493
|
+
value: function disableResize() {
|
|
494
|
+
if (this.resizer) this.resizer.reset({
|
|
495
|
+
disable: true
|
|
496
|
+
});
|
|
497
|
+
this.gripRefs = [];
|
|
498
|
+
}
|
|
343
499
|
}, {
|
|
344
500
|
key: "changeActiveCell",
|
|
345
501
|
value: function changeActiveCell(rowIndex, columnIndex) {
|
|
@@ -362,116 +518,161 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
362
518
|
}, {
|
|
363
519
|
key: "handleKeyDown",
|
|
364
520
|
value: function handleKeyDown(event) {
|
|
365
|
-
var
|
|
521
|
+
var _this3 = this,
|
|
366
522
|
_callbacks;
|
|
367
523
|
|
|
368
524
|
mapKeyEventCallbacks(event, {
|
|
369
525
|
callbacks: (_callbacks = {}, _defineProperty(_callbacks, KEYS.UP, {
|
|
370
526
|
callback: function callback(evt) {
|
|
371
|
-
return
|
|
527
|
+
return _this3.handleKeyDownUp(evt);
|
|
372
528
|
}
|
|
373
529
|
}), _defineProperty(_callbacks, KEYS.DOWN, {
|
|
374
530
|
callback: function callback(evt) {
|
|
375
|
-
return
|
|
531
|
+
return _this3.handleKeyDownDown(evt);
|
|
376
532
|
}
|
|
377
533
|
}), _defineProperty(_callbacks, KEYS.LEFT, {
|
|
378
534
|
callback: function callback(evt) {
|
|
379
|
-
return
|
|
535
|
+
return _this3.handleKeyDownLeft(evt);
|
|
380
536
|
}
|
|
381
537
|
}), _defineProperty(_callbacks, KEYS.RIGHT, {
|
|
382
538
|
callback: function callback(evt) {
|
|
383
|
-
return
|
|
539
|
+
return _this3.handleKeyDownRight(evt);
|
|
384
540
|
}
|
|
385
541
|
}), _defineProperty(_callbacks, KEYS.ENTER, {
|
|
386
542
|
callback: function callback(evt) {
|
|
387
|
-
return
|
|
543
|
+
return _this3.handleKeyDownEnter(evt);
|
|
388
544
|
}
|
|
389
545
|
}), _defineProperty(_callbacks, KEYS.ESCAPE, {
|
|
390
546
|
callback: function callback(evt) {
|
|
391
|
-
return
|
|
547
|
+
return _this3.handleKeyDownEscape(evt);
|
|
392
548
|
}
|
|
393
|
-
}), _callbacks
|
|
549
|
+
}), _defineProperty(_callbacks, KEYS.TAB, this.state.mode === Mode.ACTIONABLE ? {
|
|
550
|
+
callback: function callback(evt) {
|
|
551
|
+
return _this3.handleKeyTabPress(evt);
|
|
552
|
+
}
|
|
553
|
+
} : null), _callbacks)
|
|
394
554
|
});
|
|
395
555
|
}
|
|
396
556
|
}, {
|
|
397
557
|
key: "handleKeyDownUp",
|
|
398
558
|
value: function handleKeyDownUp() {
|
|
399
|
-
|
|
400
|
-
|
|
559
|
+
if (this.state.mode === Mode.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
560
|
+
var newRowIndex = Math.max(this.state.activeCell.rowIndex - 1, 0);
|
|
561
|
+
var activeElement = this.getFirstInteractiveElement(newRowIndex, this.state.activeCell.columnIndex);
|
|
562
|
+
|
|
563
|
+
if (newRowIndex !== this.state.activeCell.rowIndex) {
|
|
564
|
+
this.setState(function (prevState) {
|
|
565
|
+
return {
|
|
566
|
+
activeCell: {
|
|
567
|
+
rowIndex: newRowIndex,
|
|
568
|
+
columnIndex: prevState.activeCell.columnIndex
|
|
569
|
+
},
|
|
570
|
+
activeElement: activeElement
|
|
571
|
+
};
|
|
572
|
+
});
|
|
401
573
|
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
rowIndex: newRowIndex,
|
|
407
|
-
columnIndex: prevState.activeCell.columnIndex
|
|
408
|
-
},
|
|
409
|
-
activeElement: activeElement
|
|
410
|
-
};
|
|
411
|
-
});
|
|
574
|
+
if (this.state.mode === Mode.ACTIONABLE && newRowIndex === 0 && !activeElement) {
|
|
575
|
+
this.makeGripVisible(this.state.activeCell.columnIndex);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
412
578
|
}
|
|
413
579
|
}
|
|
414
580
|
}, {
|
|
415
581
|
key: "handleKeyDownDown",
|
|
416
582
|
value: function handleKeyDownDown() {
|
|
417
|
-
|
|
418
|
-
|
|
583
|
+
if (this.state.mode === Mode.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
584
|
+
var newRowIndex = Math.min(this.state.activeCell.rowIndex + 1, this.props.items.length);
|
|
585
|
+
var activeElement = this.getFirstInteractiveElement(newRowIndex, this.state.activeCell.columnIndex);
|
|
586
|
+
|
|
587
|
+
if (newRowIndex !== this.state.activeCell.rowIndex) {
|
|
588
|
+
this.setState(function (prevState) {
|
|
589
|
+
return {
|
|
590
|
+
activeCell: {
|
|
591
|
+
rowIndex: newRowIndex,
|
|
592
|
+
columnIndex: prevState.activeCell.columnIndex
|
|
593
|
+
},
|
|
594
|
+
activeElement: activeElement
|
|
595
|
+
};
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}, {
|
|
601
|
+
key: "displaceByArrowKey",
|
|
602
|
+
value: function displaceByArrowKey(factor) {
|
|
603
|
+
if (this.state.mode === Mode.ACTIONABLE) {
|
|
604
|
+
var _this$state$activeCel = this.state.activeCell,
|
|
605
|
+
rowIndex = _this$state$activeCel.rowIndex,
|
|
606
|
+
columnIndex = _this$state$activeCel.columnIndex;
|
|
419
607
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
};
|
|
429
|
-
});
|
|
608
|
+
if (rowIndex === 0) {
|
|
609
|
+
var table = this.tableRef;
|
|
610
|
+
var headers = table.getElementsByTagName('th');
|
|
611
|
+
headers[columnIndex].style.width = "".concat(parseInt(headers[columnIndex].style.width, 10) + factor, "px");
|
|
612
|
+
this.resizeFixedHeaders();
|
|
613
|
+
this.repositionResizers();
|
|
614
|
+
this.resizeGrips();
|
|
615
|
+
}
|
|
430
616
|
}
|
|
431
617
|
}
|
|
618
|
+
}, {
|
|
619
|
+
key: "makeGripVisible",
|
|
620
|
+
value: function makeGripVisible(newIndex) {
|
|
621
|
+
this.gripRefs.forEach(function (grip, index) {
|
|
622
|
+
if (index === newIndex) grip.classList.add('grip-handle-active');else grip.classList.remove('grip-handle-active');
|
|
623
|
+
});
|
|
624
|
+
}
|
|
432
625
|
}, {
|
|
433
626
|
key: "handleKeyDownLeft",
|
|
434
627
|
value: function handleKeyDownLeft() {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
this.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
628
|
+
if (this.state.mode === Mode.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
629
|
+
var newColumnIndex = Math.max(this.state.activeCell.columnIndex - 1, 0);
|
|
630
|
+
var activeElement = this.getFirstInteractiveElement(this.state.activeCell.rowIndex, newColumnIndex);
|
|
631
|
+
|
|
632
|
+
if (newColumnIndex !== this.state.activeCell.columnIndex) {
|
|
633
|
+
this.setState(function (prevState) {
|
|
634
|
+
return {
|
|
635
|
+
activeCell: {
|
|
636
|
+
rowIndex: prevState.activeCell.rowIndex,
|
|
637
|
+
columnIndex: newColumnIndex
|
|
638
|
+
},
|
|
639
|
+
activeElement: activeElement
|
|
640
|
+
};
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
} else {
|
|
644
|
+
this.displaceByArrowKey(-10);
|
|
448
645
|
}
|
|
449
646
|
}
|
|
450
647
|
}, {
|
|
451
648
|
key: "handleKeyDownRight",
|
|
452
649
|
value: function handleKeyDownRight() {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
this.
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
650
|
+
if (this.state.mode === Mode.NAVIGATION || this.state.activeCell.rowIndex > 0 || !this.isResizable()) {
|
|
651
|
+
var newColumnIndex = Math.min(this.state.activeCell.columnIndex + 1, this.props.children.length - (this.props.selectRows ? 0 : 1));
|
|
652
|
+
var activeElement = this.getFirstInteractiveElement(this.state.activeCell.rowIndex, newColumnIndex);
|
|
653
|
+
|
|
654
|
+
if (newColumnIndex !== this.state.activeCell.columnIndex) {
|
|
655
|
+
this.setState(function (prevState) {
|
|
656
|
+
return {
|
|
657
|
+
activeCell: {
|
|
658
|
+
rowIndex: prevState.activeCell.rowIndex,
|
|
659
|
+
columnIndex: newColumnIndex
|
|
660
|
+
},
|
|
661
|
+
activeElement: activeElement
|
|
662
|
+
};
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
} else {
|
|
666
|
+
this.displaceByArrowKey(10);
|
|
466
667
|
}
|
|
467
668
|
}
|
|
468
669
|
}, {
|
|
469
670
|
key: "handleKeyDownEnter",
|
|
470
671
|
value: function handleKeyDownEnter() {
|
|
471
672
|
if (this.state.mode === Mode.NAVIGATION) {
|
|
472
|
-
var _this$state$
|
|
473
|
-
rowIndex = _this$state$
|
|
474
|
-
columnIndex = _this$state$
|
|
673
|
+
var _this$state$activeCel2 = this.state.activeCell,
|
|
674
|
+
rowIndex = _this$state$activeCel2.rowIndex,
|
|
675
|
+
columnIndex = _this$state$activeCel2.columnIndex;
|
|
475
676
|
var activeElement = null;
|
|
476
677
|
|
|
477
678
|
if (this.interactiveElements[rowIndex] && this.interactiveElements[rowIndex][columnIndex]) {
|
|
@@ -484,6 +685,10 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
484
685
|
mode: Mode.ACTIONABLE,
|
|
485
686
|
activeElement: activeElement
|
|
486
687
|
});
|
|
688
|
+
|
|
689
|
+
if (rowIndex === 0 && !activeElement) {
|
|
690
|
+
this.makeGripVisible(columnIndex);
|
|
691
|
+
}
|
|
487
692
|
}
|
|
488
693
|
}
|
|
489
694
|
}, {
|
|
@@ -494,6 +699,99 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
494
699
|
mode: Mode.NAVIGATION,
|
|
495
700
|
activeElement: null
|
|
496
701
|
});
|
|
702
|
+
this.makeGripVisible(null);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}, {
|
|
706
|
+
key: "moveNext",
|
|
707
|
+
value: function moveNext(event, rowIndex, columnIndex) {
|
|
708
|
+
var headers = [].concat(this.headerRefs.select, this.headerRefs.column, this.headerRefs.action);
|
|
709
|
+
var newRowIndex = 0;
|
|
710
|
+
var newColumnIndex = 0;
|
|
711
|
+
|
|
712
|
+
if (event.shiftKey) {
|
|
713
|
+
if (columnIndex - 1 >= 0) {
|
|
714
|
+
newColumnIndex = columnIndex - 1;
|
|
715
|
+
newRowIndex = rowIndex;
|
|
716
|
+
} else {
|
|
717
|
+
if (rowIndex > 0) newRowIndex = rowIndex - 1;else newRowIndex = this.props.items.length;
|
|
718
|
+
newColumnIndex = headers.length - 1;
|
|
719
|
+
}
|
|
720
|
+
} else if (columnIndex + 1 < headers.length) {
|
|
721
|
+
newColumnIndex = columnIndex + 1;
|
|
722
|
+
newRowIndex = rowIndex;
|
|
723
|
+
} else {
|
|
724
|
+
if (rowIndex < this.props.items.length) newRowIndex = rowIndex + 1;else newRowIndex = 0;
|
|
725
|
+
newColumnIndex = 0;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
this.changeActiveCell(newRowIndex, newColumnIndex);
|
|
729
|
+
}
|
|
730
|
+
}, {
|
|
731
|
+
key: "handleNextActionable",
|
|
732
|
+
value: function handleNextActionable(event) {
|
|
733
|
+
var _this$state$activeCel3 = this.state.activeCell,
|
|
734
|
+
rowIndex = _this$state$activeCel3.rowIndex,
|
|
735
|
+
columnIndex = _this$state$activeCel3.columnIndex;
|
|
736
|
+
var currentActiveElement = this.state.activeElement;
|
|
737
|
+
var rowActiveElements = this.interactiveElements[rowIndex] && this.interactiveElements[rowIndex][columnIndex] ? this.interactiveElements[rowIndex][columnIndex] : null;
|
|
738
|
+
|
|
739
|
+
if (rowActiveElements) {
|
|
740
|
+
if (currentActiveElement) {
|
|
741
|
+
var index = rowActiveElements.indexOf(currentActiveElement);
|
|
742
|
+
|
|
743
|
+
if (event.shiftKey) {
|
|
744
|
+
return index > 0 ? rowActiveElements[index - 1] : null;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
return index < rowActiveElements.length - 1 ? rowActiveElements[index + 1] : null;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
return !event.shiftKey ? rowActiveElements[0] : rowActiveElements[rowActiveElements.length - 1];
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
return null;
|
|
754
|
+
}
|
|
755
|
+
}, {
|
|
756
|
+
key: "handleKeyTabPress",
|
|
757
|
+
value: function handleKeyTabPress(event) {
|
|
758
|
+
var _this$state$activeCel4 = this.state.activeCell,
|
|
759
|
+
rowIndex = _this$state$activeCel4.rowIndex,
|
|
760
|
+
columnIndex = _this$state$activeCel4.columnIndex;
|
|
761
|
+
|
|
762
|
+
if (this.state.mode === Mode.ACTIONABLE) {
|
|
763
|
+
var nextActionable = this.handleNextActionable(event);
|
|
764
|
+
|
|
765
|
+
if (nextActionable) {
|
|
766
|
+
this.setState({
|
|
767
|
+
activeElement: nextActionable
|
|
768
|
+
});
|
|
769
|
+
if (this.isResizable()) this.makeGripVisible(null);
|
|
770
|
+
} else if (rowIndex === 0) {
|
|
771
|
+
var headers = [].concat(this.headerRefs.select, this.headerRefs.column, this.headerRefs.action);
|
|
772
|
+
var newIndex = 0;
|
|
773
|
+
if (!event.shiftKey) newIndex = columnIndex + 1 < headers.length ? columnIndex + 1 : 0;else newIndex = columnIndex - 1 >= 0 ? columnIndex - 1 : headers.length - 1;
|
|
774
|
+
this.setState({
|
|
775
|
+
mode: Mode.ACTIONABLE,
|
|
776
|
+
activeElement: null
|
|
777
|
+
}); // eslint-disable-next-line no-param-reassign
|
|
778
|
+
|
|
779
|
+
headers.forEach(function (header, index) {
|
|
780
|
+
if (index === newIndex) {
|
|
781
|
+
// eslint-disable-next-line no-param-reassign
|
|
782
|
+
header.tabIndex = 0; // eslint-disable-next-line no-param-reassign
|
|
783
|
+
|
|
784
|
+
header.focus(); // eslint-disable-next-line no-param-reassign
|
|
785
|
+
} else header.tabIndex = -1;
|
|
786
|
+
});
|
|
787
|
+
if (this.isResizable()) this.makeGripVisible(newIndex);
|
|
788
|
+
} else {
|
|
789
|
+
this.moveNext(event, rowIndex, columnIndex);
|
|
790
|
+
this.setState({
|
|
791
|
+
mode: Mode.ACTIONABLE,
|
|
792
|
+
activeElement: null
|
|
793
|
+
});
|
|
794
|
+
}
|
|
497
795
|
}
|
|
498
796
|
}
|
|
499
797
|
}, {
|
|
@@ -504,13 +802,16 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
504
802
|
}
|
|
505
803
|
|
|
506
804
|
var existingElements = this.interactiveElements[rowIndex][columnIndex] || [];
|
|
507
|
-
|
|
805
|
+
|
|
806
|
+
if (!existingElements.includes(elementId)) {
|
|
807
|
+
this.interactiveElements[rowIndex][columnIndex] = [].concat(_toConsumableArray(existingElements), [elementId]);
|
|
808
|
+
}
|
|
508
809
|
} // ### Render
|
|
509
810
|
|
|
510
811
|
}, {
|
|
511
812
|
key: "render",
|
|
512
813
|
value: function render() {
|
|
513
|
-
var
|
|
814
|
+
var _this4 = this;
|
|
514
815
|
|
|
515
816
|
var ariaProps = {};
|
|
516
817
|
var numHeaderRows = 1;
|
|
@@ -530,7 +831,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
530
831
|
children = _child$props.children,
|
|
531
832
|
columnProps = _objectWithoutProperties(_child$props, ["children"]);
|
|
532
833
|
|
|
533
|
-
var props = assign({},
|
|
834
|
+
var props = assign({}, _this4.props); // eslint-disable-next-line fp/no-delete
|
|
534
835
|
|
|
535
836
|
delete props.children;
|
|
536
837
|
assign(props, columnProps);
|
|
@@ -547,13 +848,13 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
547
848
|
columns.push({
|
|
548
849
|
Cell: Cell,
|
|
549
850
|
props: props,
|
|
550
|
-
dataTableProps:
|
|
851
|
+
dataTableProps: _this4.props
|
|
551
852
|
});
|
|
552
853
|
} else if (child && child.type.displayName === DataTableRowActions.displayName) {
|
|
553
854
|
var dropdown = child.props.dropdown;
|
|
554
855
|
var dropdownPropOverrides = {};
|
|
555
856
|
|
|
556
|
-
if (
|
|
857
|
+
if (_this4.getFixedHeader()) {
|
|
557
858
|
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
558
859
|
}
|
|
559
860
|
|
|
@@ -610,8 +911,8 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
610
911
|
registerInteractiveElement: this.registerInteractiveElement,
|
|
611
912
|
allowKeyboardNavigation: this.state.allowKeyboardNavigation,
|
|
612
913
|
setAllowKeyboardNavigation: function setAllowKeyboardNavigation(allowKeyboardNavigation) {
|
|
613
|
-
if (
|
|
614
|
-
|
|
914
|
+
if (_this4.getKeyboardNavigation()) {
|
|
915
|
+
_this4.setState({
|
|
615
916
|
allowKeyboardNavigation: allowKeyboardNavigation
|
|
616
917
|
});
|
|
617
918
|
}
|
|
@@ -621,50 +922,54 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
621
922
|
value: tableContext
|
|
622
923
|
}, /*#__PURE__*/React.createElement("table", _extends({}, ariaProps, {
|
|
623
924
|
className: classNames('slds-table', {
|
|
624
|
-
'slds-table_fixed-layout': this.
|
|
625
|
-
'slds-table_header-fixed': this.
|
|
626
|
-
'slds-table_resizable-cols': this.
|
|
925
|
+
'slds-table_fixed-layout': this.getFixedLayout(),
|
|
926
|
+
'slds-table_header-fixed': this.getFixedHeader(),
|
|
927
|
+
'slds-table_resizable-cols': this.getFixedLayout(),
|
|
627
928
|
'slds-table_bordered': !this.props.unborderedRow,
|
|
628
|
-
'slds-table_cell-buffer': !this.
|
|
929
|
+
'slds-table_cell-buffer': !this.getFixedLayout() && !this.props.unbufferedCell,
|
|
629
930
|
'slds-max-medium-table_stacked': this.props.stacked,
|
|
630
931
|
'slds-max-medium-table_stacked-horizontal': this.props.stackedHorizontal,
|
|
631
932
|
'slds-table_striped': this.props.striped,
|
|
632
933
|
'slds-table_col-bordered': this.props.columnBordered,
|
|
633
|
-
'slds-no-row-hover': this.props.noRowHover
|
|
934
|
+
'slds-no-row-hover': this.props.noRowHover,
|
|
935
|
+
'slds-table_header-hidden': this.props.isHeadless
|
|
634
936
|
}, this.props.className),
|
|
635
937
|
id: this.getId(),
|
|
636
938
|
ref: function ref(node) {
|
|
637
939
|
if (node) {
|
|
638
|
-
|
|
940
|
+
_this4.tableRef = node;
|
|
639
941
|
}
|
|
640
942
|
},
|
|
641
|
-
role: this.
|
|
943
|
+
role: this.getFixedLayout() ? 'grid' : null,
|
|
642
944
|
onBlur: function onBlur(event) {
|
|
643
|
-
if (
|
|
644
|
-
|
|
945
|
+
if (_this4.tableRef && !_this4.tableRef.contains(event.relatedTarget)) {
|
|
946
|
+
_this4.setState({
|
|
645
947
|
tableHasFocus: false,
|
|
646
948
|
mode: Mode.NAVIGATION,
|
|
647
949
|
activeElement: null
|
|
648
950
|
});
|
|
951
|
+
|
|
952
|
+
_this4.makeGripVisible(null);
|
|
649
953
|
}
|
|
650
954
|
},
|
|
651
955
|
style: this.props.style
|
|
652
956
|
}), /*#__PURE__*/React.createElement(DataTableHead, {
|
|
653
957
|
assistiveText: assistiveText,
|
|
654
958
|
allSelected: allSelected,
|
|
655
|
-
fixedHeader: this.
|
|
656
|
-
fixedLayout: this.
|
|
959
|
+
fixedHeader: this.getFixedHeader(),
|
|
960
|
+
fixedLayout: this.getFixedLayout(),
|
|
657
961
|
headerRefs: function headerRefs(ref, index) {
|
|
658
962
|
if (index === 'action' || index === 'select') {
|
|
659
963
|
if (ref) {
|
|
660
|
-
|
|
964
|
+
_this4.headerRefs[index][0] = ref;
|
|
661
965
|
} else {
|
|
662
|
-
|
|
966
|
+
_this4.headerRefs[index] = [];
|
|
663
967
|
}
|
|
664
968
|
} else {
|
|
665
|
-
|
|
969
|
+
_this4.headerRefs.column[index] = ref;
|
|
666
970
|
}
|
|
667
971
|
},
|
|
972
|
+
isHidden: this.props.isHeadless,
|
|
668
973
|
indeterminateSelected: indeterminateSelected,
|
|
669
974
|
canSelectRows: canSelectRows,
|
|
670
975
|
columns: columns,
|
|
@@ -673,33 +978,33 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
673
978
|
onSort: this.props.onSort,
|
|
674
979
|
showRowActions: !!RowActions
|
|
675
980
|
}), /*#__PURE__*/React.createElement("tbody", null, numRows > 0 ? this.props.items.map(function (item, index) {
|
|
676
|
-
var rowId =
|
|
677
|
-
return
|
|
981
|
+
var rowId = _this4.getId() && item.id ? "".concat(_this4.getId(), "-").concat(DATA_TABLE_ROW, "-").concat(item.id) : shortid.generate();
|
|
982
|
+
return _this4.props.onRenderSubHeadingRow && item.type === 'header-row' ? _this4.props.onRenderSubHeadingRow({
|
|
678
983
|
assistiveText: assistiveText,
|
|
679
984
|
classNameRow: item.classNameRow,
|
|
680
985
|
columns: columns,
|
|
681
986
|
key: rowId,
|
|
682
987
|
id: rowId,
|
|
683
|
-
tableId:
|
|
988
|
+
tableId: _this4.getId(),
|
|
684
989
|
item: item
|
|
685
990
|
}) : /*#__PURE__*/React.createElement(DataTableRow, {
|
|
686
991
|
assistiveText: assistiveText,
|
|
687
992
|
canSelectRows: canSelectRows,
|
|
688
993
|
className: item.classNameRow,
|
|
689
994
|
columns: columns,
|
|
690
|
-
fixedLayout:
|
|
995
|
+
fixedLayout: _this4.getFixedLayout(),
|
|
691
996
|
id: rowId,
|
|
692
997
|
index: index,
|
|
693
998
|
item: item,
|
|
694
999
|
key: rowId,
|
|
695
|
-
onToggle:
|
|
696
|
-
selection:
|
|
1000
|
+
onToggle: _this4.handleRowToggle,
|
|
1001
|
+
selection: _this4.props.selection,
|
|
697
1002
|
rowActions: RowActions,
|
|
698
|
-
tableId:
|
|
1003
|
+
tableId: _this4.getId(),
|
|
699
1004
|
rowIndex: index + numHeaderRows
|
|
700
1005
|
});
|
|
701
1006
|
}) : // Someday this should be an element to render when the table is empty
|
|
702
|
-
null))), this.
|
|
1007
|
+
null))), this.getFixedHeader() && this.props.hasMore && /*#__PURE__*/React.createElement("div", {
|
|
703
1008
|
className: "slds-is-relative slds-p-around_large"
|
|
704
1009
|
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
705
1010
|
assistiveText: {
|
|
@@ -710,7 +1015,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
710
1015
|
variant: "brand"
|
|
711
1016
|
})));
|
|
712
1017
|
|
|
713
|
-
if (this.
|
|
1018
|
+
if (this.getFixedHeader()) {
|
|
714
1019
|
var border = "1px solid ".concat(colorGray5);
|
|
715
1020
|
var styles = {
|
|
716
1021
|
borderTop: border,
|
|
@@ -725,8 +1030,22 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
725
1030
|
styles.borderRadius = tableBorderRadius;
|
|
726
1031
|
}
|
|
727
1032
|
|
|
1033
|
+
var fixedScrollerStyle = {
|
|
1034
|
+
height: '100%'
|
|
1035
|
+
};
|
|
1036
|
+
|
|
1037
|
+
if (this.props.resizable) {
|
|
1038
|
+
fixedScrollerStyle.overflowY = 'auto';
|
|
1039
|
+
fixedScrollerStyle.overflowX = 'hidden';
|
|
1040
|
+
} else {
|
|
1041
|
+
fixedScrollerStyle.overflow = 'auto';
|
|
1042
|
+
}
|
|
1043
|
+
|
|
728
1044
|
component = /*#__PURE__*/React.createElement("div", {
|
|
729
1045
|
className: "slds-table_header-fixed_container",
|
|
1046
|
+
ref: function ref(_ref4) {
|
|
1047
|
+
_this4.fixedHeaderContainer = _ref4;
|
|
1048
|
+
},
|
|
730
1049
|
style: styles,
|
|
731
1050
|
onScroll: function onScroll(e) {
|
|
732
1051
|
var containerScrollLeft = e.target.scrollLeft;
|
|
@@ -734,20 +1053,17 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
734
1053
|
if (containerScrollLeft > 0) {
|
|
735
1054
|
e.target.scrollLeft = 0;
|
|
736
1055
|
|
|
737
|
-
if (
|
|
738
|
-
|
|
1056
|
+
if (_this4.scrollerRef) {
|
|
1057
|
+
_this4.scrollerRef.scrollLeft = containerScrollLeft;
|
|
739
1058
|
}
|
|
740
1059
|
}
|
|
741
1060
|
}
|
|
742
1061
|
}, /*#__PURE__*/React.createElement("div", {
|
|
743
1062
|
className: "slds-table_header-fixed_scroller",
|
|
744
|
-
ref: function ref(
|
|
745
|
-
|
|
1063
|
+
ref: function ref(_ref3) {
|
|
1064
|
+
_this4.scrollerRef = _ref3;
|
|
746
1065
|
},
|
|
747
|
-
style:
|
|
748
|
-
height: '100%',
|
|
749
|
-
overflow: 'auto'
|
|
750
|
-
}
|
|
1066
|
+
style: fixedScrollerStyle
|
|
751
1067
|
}, component));
|
|
752
1068
|
}
|
|
753
1069
|
|
|
@@ -887,6 +1203,11 @@ _defineProperty(DataTable, "propTypes", {
|
|
|
887
1203
|
classNameRow: PropTypes.string
|
|
888
1204
|
})).isRequired,
|
|
889
1205
|
|
|
1206
|
+
/**
|
|
1207
|
+
* Removes the header from the data table. Tested with snapshot testing
|
|
1208
|
+
*/
|
|
1209
|
+
isHeadless: PropTypes.bool,
|
|
1210
|
+
|
|
890
1211
|
/**
|
|
891
1212
|
* Makes DataTable joinable with PageHeader by adding appropriate classes/styling
|
|
892
1213
|
*/
|
|
@@ -978,7 +1299,22 @@ _defineProperty(DataTable, "propTypes", {
|
|
|
978
1299
|
/**
|
|
979
1300
|
* A variant which removes horizontal padding. CSS class will be removed if `fixedLayout==true`.
|
|
980
1301
|
*/
|
|
981
|
-
unbufferedCell: PropTypes.bool
|
|
1302
|
+
unbufferedCell: PropTypes.bool,
|
|
1303
|
+
|
|
1304
|
+
/**
|
|
1305
|
+
* A variant which allows column dividers to be grabbed with the mouse. This feature needs
|
|
1306
|
+
* `@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.
|
|
1307
|
+
*/
|
|
1308
|
+
resizable: PropTypes.bool,
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Object with properties to be used in case of resizable: true
|
|
1312
|
+
*
|
|
1313
|
+
* resizeMode: It is used to set how the resize method works. Those are the possible values: 'fit', 'flex' and 'overflow'
|
|
1314
|
+
* onResize: Callback function to be fired when the user has ended dragging a column
|
|
1315
|
+
* `@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.
|
|
1316
|
+
*/
|
|
1317
|
+
resizableOptions: PropTypes.object
|
|
982
1318
|
});
|
|
983
1319
|
|
|
984
1320
|
_defineProperty(DataTable, "defaultProps", defaultProps);
|