@atlaskit/dynamic-table 14.12.0 → 14.13.0
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/CHANGELOG.md +18 -0
- package/dist/cjs/components/error-boundary.js +47 -0
- package/dist/cjs/components/stateless.js +56 -6
- package/dist/cjs/styled/rankable/table-row.js +1 -1
- package/dist/cjs/styled/table-head.js +1 -1
- package/dist/cjs/styled/table-row.js +1 -1
- package/dist/es2019/components/error-boundary.js +22 -0
- package/dist/es2019/components/stateless.js +43 -6
- package/dist/es2019/styled/rankable/table-row.js +1 -1
- package/dist/es2019/styled/table-head.js +1 -1
- package/dist/es2019/styled/table-row.js +1 -1
- package/dist/esm/components/error-boundary.js +40 -0
- package/dist/esm/components/stateless.js +51 -6
- package/dist/esm/styled/rankable/table-row.js +1 -1
- package/dist/esm/styled/table-head.js +1 -1
- package/dist/esm/styled/table-row.js +1 -1
- package/dist/types/components/error-boundary.d.ts +16 -0
- package/dist/types-ts4.5/components/error-boundary.d.ts +16 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/dynamic-table
|
|
2
2
|
|
|
3
|
+
## 14.13.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#66438](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66438) [`334df1af360b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/334df1af360b) - [ux] `react-beautiful-dnd` is now lazy loaded for rankable tables. It will no longer be loaded for non-rankable tables.
|
|
8
|
+
|
|
9
|
+
Tests relying on ranking being synchronously available may need to be modified.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 14.12.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#66234](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66234) [`eca303e7af0a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eca303e7af0a) - Changed :focus selector with :focus-visible
|
|
20
|
+
|
|
3
21
|
## 14.12.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ErrorBoundary = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
11
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
12
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _react = _interopRequireDefault(require("react"));
|
|
14
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
15
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
|
+
var ErrorBoundary = exports.ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
17
|
+
(0, _inherits2.default)(ErrorBoundary, _React$Component);
|
|
18
|
+
var _super = _createSuper(ErrorBoundary);
|
|
19
|
+
function ErrorBoundary(props) {
|
|
20
|
+
var _this;
|
|
21
|
+
(0, _classCallCheck2.default)(this, ErrorBoundary);
|
|
22
|
+
_this = _super.call(this, props);
|
|
23
|
+
_this.state = {
|
|
24
|
+
hasError: false
|
|
25
|
+
};
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
(0, _createClass2.default)(ErrorBoundary, [{
|
|
29
|
+
key: "render",
|
|
30
|
+
value: function render() {
|
|
31
|
+
if (this.state.hasError) {
|
|
32
|
+
// You can render any custom fallback UI
|
|
33
|
+
return this.props.fallback;
|
|
34
|
+
}
|
|
35
|
+
return this.props.children;
|
|
36
|
+
}
|
|
37
|
+
}], [{
|
|
38
|
+
key: "getDerivedStateFromError",
|
|
39
|
+
value: function getDerivedStateFromError() {
|
|
40
|
+
// Update state so the next render will show the fallback UI.
|
|
41
|
+
return {
|
|
42
|
+
hasError: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}]);
|
|
46
|
+
return ErrorBoundary;
|
|
47
|
+
}(_react.default.Component);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = exports.DynamicTableWithoutAnalytics = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
8
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -13,7 +16,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
13
16
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
17
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react =
|
|
19
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
20
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
18
21
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
19
22
|
var _constants = require("../internal/constants");
|
|
@@ -21,15 +24,18 @@ var _helpers = require("../internal/helpers");
|
|
|
21
24
|
var _dynamicTable = require("../styled/dynamic-table");
|
|
22
25
|
var _emptyBody = require("../styled/empty-body");
|
|
23
26
|
var _body = _interopRequireDefault(require("./body"));
|
|
27
|
+
var _errorBoundary = require("./error-boundary");
|
|
24
28
|
var _loadingContainer = _interopRequireDefault(require("./loading-container"));
|
|
25
29
|
var _loadingContainerAdvanced = _interopRequireDefault(require("./loading-container-advanced"));
|
|
26
30
|
var _managedPagination = _interopRequireDefault(require("./managed-pagination"));
|
|
27
|
-
var _body2 = _interopRequireDefault(require("./rankable/body"));
|
|
28
31
|
var _tableHead = _interopRequireDefault(require("./table-head"));
|
|
32
|
+
var _excluded = ["isRankable", "isRanking", "onRankStart", "onRankEnd", "isRankingDisabled"];
|
|
33
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
35
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
30
36
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
37
|
var packageName = "@atlaskit/dynamic-table";
|
|
32
|
-
var packageVersion = "14.
|
|
38
|
+
var packageVersion = "14.13.0";
|
|
33
39
|
function toggleSortOrder(currentSortOrder) {
|
|
34
40
|
switch (currentSortOrder) {
|
|
35
41
|
case _constants.DESC:
|
|
@@ -207,7 +213,6 @@ var DynamicTable = exports.DynamicTableWithoutAnalytics = /*#__PURE__*/function
|
|
|
207
213
|
var rowsExist = !!rowsLength;
|
|
208
214
|
var spinnerSize = this.getSpinnerSize();
|
|
209
215
|
var emptyBody = this.renderEmptyBody();
|
|
210
|
-
var canRank = isRankable && !sortKey;
|
|
211
216
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.default, {
|
|
212
217
|
isLoading: isLoading && rowsExist,
|
|
213
218
|
spinnerSize: spinnerSize,
|
|
@@ -228,12 +233,13 @@ var DynamicTable = exports.DynamicTableWithoutAnalytics = /*#__PURE__*/function
|
|
|
228
233
|
isRanking: this.state.isRanking,
|
|
229
234
|
isRankable: isRankable,
|
|
230
235
|
testId: testId
|
|
231
|
-
}), rowsExist &&
|
|
236
|
+
}), rowsExist && /*#__PURE__*/_react.default.createElement(TableBody, (0, _extends2.default)({}, bodyProps, {
|
|
237
|
+
isRankable: this.props.isRankable,
|
|
232
238
|
isRanking: this.state.isRanking,
|
|
233
239
|
onRankStart: this.onRankStartHandler,
|
|
234
240
|
onRankEnd: this.onRankEndHandler,
|
|
235
241
|
isRankingDisabled: isRankingDisabled || isLoading || false
|
|
236
|
-
}))
|
|
242
|
+
})))), totalPages <= 1 ? null :
|
|
237
243
|
/*#__PURE__*/
|
|
238
244
|
// only show pagination if there's MORE than 1 page
|
|
239
245
|
_react.default.createElement(_dynamicTable.PaginationWrapper, null, /*#__PURE__*/_react.default.createElement(_managedPagination.default, {
|
|
@@ -269,6 +275,50 @@ var DynamicTable = exports.DynamicTableWithoutAnalytics = /*#__PURE__*/function
|
|
|
269
275
|
pageLabel: 'Page'
|
|
270
276
|
}
|
|
271
277
|
});
|
|
278
|
+
var RankableTableBody = /*#__PURE__*/(0, _react.lazy)(function () {
|
|
279
|
+
return Promise.resolve().then(function () {
|
|
280
|
+
return _interopRequireWildcard(require( /* webpackChunkName: '@atlaskit-internal_dynamic-table' */'./rankable/body'));
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
var TableBody = /*#__PURE__*/(0, _react.forwardRef)(function TableBody(_ref, ref) {
|
|
284
|
+
var _ref$isRankable = _ref.isRankable,
|
|
285
|
+
isRankable = _ref$isRankable === void 0 ? false : _ref$isRankable,
|
|
286
|
+
isRanking = _ref.isRanking,
|
|
287
|
+
onRankStart = _ref.onRankStart,
|
|
288
|
+
onRankEnd = _ref.onRankEnd,
|
|
289
|
+
isRankingDisabled = _ref.isRankingDisabled,
|
|
290
|
+
bodyProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
291
|
+
var canRank = isRankable && !bodyProps.sortKey;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* React 16 does not support SSR for lazy components,
|
|
295
|
+
* so we avoid rendering the `Suspense` on the server.
|
|
296
|
+
*/
|
|
297
|
+
var _useState = (0, _react.useState)(false),
|
|
298
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
299
|
+
canRenderRankable = _useState2[0],
|
|
300
|
+
setCanRenderRankable = _useState2[1];
|
|
301
|
+
(0, _react.useEffect)(function () {
|
|
302
|
+
if (canRank) {
|
|
303
|
+
setCanRenderRankable(true);
|
|
304
|
+
}
|
|
305
|
+
}, [canRank]);
|
|
306
|
+
var nonRankableBody = /*#__PURE__*/_react.default.createElement(_body.default, (0, _extends2.default)({
|
|
307
|
+
ref: ref
|
|
308
|
+
}, bodyProps));
|
|
309
|
+
return canRank && canRenderRankable ? /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
310
|
+
fallback: nonRankableBody
|
|
311
|
+
}, /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
312
|
+
fallback: nonRankableBody
|
|
313
|
+
}, /*#__PURE__*/_react.default.createElement(RankableTableBody, (0, _extends2.default)({
|
|
314
|
+
ref: ref
|
|
315
|
+
}, bodyProps, {
|
|
316
|
+
isRanking: isRanking,
|
|
317
|
+
onRankStart: onRankStart,
|
|
318
|
+
onRankEnd: onRankEnd,
|
|
319
|
+
isRankingDisabled: isRankingDisabled
|
|
320
|
+
})))) : nonRankableBody;
|
|
321
|
+
});
|
|
272
322
|
var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
|
|
273
323
|
var _default = exports.default = (0, _analyticsNext.withAnalyticsContext)({
|
|
274
324
|
componentName: 'dynamicTable',
|
|
@@ -23,7 +23,7 @@ var rankingItemStyles = (0, _react2.css)({
|
|
|
23
23
|
});
|
|
24
24
|
var draggableStyles = (0, _react2.css)({
|
|
25
25
|
outlineWidth: "var(--ds-border-width, 2px)",
|
|
26
|
-
'&:focus': {
|
|
26
|
+
'&:focus-visible': {
|
|
27
27
|
outlineColor: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
|
|
28
28
|
outlineStyle: 'solid'
|
|
29
29
|
}
|
|
@@ -47,7 +47,7 @@ var headCellStyles = (0, _react2.css)([_constants2.cellStyles, {
|
|
|
47
47
|
fontWeight: 600,
|
|
48
48
|
textAlign: 'left',
|
|
49
49
|
verticalAlign: 'top',
|
|
50
|
-
'&:focus': {
|
|
50
|
+
'&:focus-visible': {
|
|
51
51
|
outline: "solid 2px ".concat("var(--ds-border-focused, ".concat(_colors.B100, ")"))
|
|
52
52
|
}
|
|
53
53
|
}]);
|
|
@@ -14,7 +14,7 @@ var _excluded = ["isHighlighted", "children", "style", "testId"];
|
|
|
14
14
|
/** @jsx jsx */
|
|
15
15
|
var rowStyles = (0, _react2.css)({
|
|
16
16
|
backgroundColor: "var(--ds-background-neutral-subtle, transparent)",
|
|
17
|
-
'&:focus': {
|
|
17
|
+
'&:focus-visible': {
|
|
18
18
|
outline: "2px solid ".concat("var(--ds-border-focused, ".concat("var(".concat(_dynamicTable.tableRowCSSVars.CSS_VAR_HOVER_BACKGROUND, ")"), ")")),
|
|
19
19
|
outlineOffset: "-2px"
|
|
20
20
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export class ErrorBoundary extends React.Component {
|
|
3
|
+
constructor(props) {
|
|
4
|
+
super(props);
|
|
5
|
+
this.state = {
|
|
6
|
+
hasError: false
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
// Update state so the next render will show the fallback UI.
|
|
11
|
+
return {
|
|
12
|
+
hasError: true
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
if (this.state.hasError) {
|
|
17
|
+
// You can render any custom fallback UI
|
|
18
|
+
return this.props.fallback;
|
|
19
|
+
}
|
|
20
|
+
return this.props.children;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { forwardRef, lazy, Suspense, useEffect, useState } from 'react';
|
|
4
4
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
5
|
import noop from '@atlaskit/ds-lib/noop';
|
|
6
6
|
import { ASC, DESC, LARGE, SMALL } from '../internal/constants';
|
|
@@ -8,13 +8,13 @@ import { assertIsSortable, getPageRows, validateSortKey } from '../internal/help
|
|
|
8
8
|
import { Caption, PaginationWrapper, Table } from '../styled/dynamic-table';
|
|
9
9
|
import { EmptyViewContainer, EmptyViewWithFixedHeight } from '../styled/empty-body';
|
|
10
10
|
import Body from './body';
|
|
11
|
+
import { ErrorBoundary } from './error-boundary';
|
|
11
12
|
import LoadingContainer from './loading-container';
|
|
12
13
|
import LoadingContainerAdvanced from './loading-container-advanced';
|
|
13
14
|
import ManagedPagination from './managed-pagination';
|
|
14
|
-
import RankableTableBody from './rankable/body';
|
|
15
15
|
import TableHead from './table-head';
|
|
16
16
|
const packageName = "@atlaskit/dynamic-table";
|
|
17
|
-
const packageVersion = "14.
|
|
17
|
+
const packageVersion = "14.13.0";
|
|
18
18
|
function toggleSortOrder(currentSortOrder) {
|
|
19
19
|
switch (currentSortOrder) {
|
|
20
20
|
case DESC:
|
|
@@ -183,7 +183,6 @@ class DynamicTable extends React.Component {
|
|
|
183
183
|
const rowsExist = !!rowsLength;
|
|
184
184
|
const spinnerSize = this.getSpinnerSize();
|
|
185
185
|
const emptyBody = this.renderEmptyBody();
|
|
186
|
-
const canRank = isRankable && !sortKey;
|
|
187
186
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingContainerAdvanced, {
|
|
188
187
|
isLoading: isLoading && rowsExist,
|
|
189
188
|
spinnerSize: spinnerSize,
|
|
@@ -202,12 +201,13 @@ class DynamicTable extends React.Component {
|
|
|
202
201
|
isRanking: this.state.isRanking,
|
|
203
202
|
isRankable: isRankable,
|
|
204
203
|
testId: testId
|
|
205
|
-
}), rowsExist &&
|
|
204
|
+
}), rowsExist && /*#__PURE__*/React.createElement(TableBody, _extends({}, bodyProps, {
|
|
205
|
+
isRankable: this.props.isRankable,
|
|
206
206
|
isRanking: this.state.isRanking,
|
|
207
207
|
onRankStart: this.onRankStartHandler,
|
|
208
208
|
onRankEnd: this.onRankEndHandler,
|
|
209
209
|
isRankingDisabled: isRankingDisabled || isLoading || false
|
|
210
|
-
}))
|
|
210
|
+
})))), totalPages <= 1 ? null :
|
|
211
211
|
/*#__PURE__*/
|
|
212
212
|
// only show pagination if there's MORE than 1 page
|
|
213
213
|
React.createElement(PaginationWrapper, null, /*#__PURE__*/React.createElement(ManagedPagination, {
|
|
@@ -241,6 +241,43 @@ _defineProperty(DynamicTable, "defaultProps", {
|
|
|
241
241
|
pageLabel: 'Page'
|
|
242
242
|
}
|
|
243
243
|
});
|
|
244
|
+
const RankableTableBody = /*#__PURE__*/lazy(() => import( /* webpackChunkName: '@atlaskit-internal_dynamic-table' */'./rankable/body'));
|
|
245
|
+
const TableBody = /*#__PURE__*/forwardRef(function TableBody({
|
|
246
|
+
isRankable = false,
|
|
247
|
+
isRanking,
|
|
248
|
+
onRankStart,
|
|
249
|
+
onRankEnd,
|
|
250
|
+
isRankingDisabled,
|
|
251
|
+
...bodyProps
|
|
252
|
+
}, ref) {
|
|
253
|
+
const canRank = isRankable && !bodyProps.sortKey;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* React 16 does not support SSR for lazy components,
|
|
257
|
+
* so we avoid rendering the `Suspense` on the server.
|
|
258
|
+
*/
|
|
259
|
+
const [canRenderRankable, setCanRenderRankable] = useState(false);
|
|
260
|
+
useEffect(() => {
|
|
261
|
+
if (canRank) {
|
|
262
|
+
setCanRenderRankable(true);
|
|
263
|
+
}
|
|
264
|
+
}, [canRank]);
|
|
265
|
+
const nonRankableBody = /*#__PURE__*/React.createElement(Body, _extends({
|
|
266
|
+
ref: ref
|
|
267
|
+
}, bodyProps));
|
|
268
|
+
return canRank && canRenderRankable ? /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
269
|
+
fallback: nonRankableBody
|
|
270
|
+
}, /*#__PURE__*/React.createElement(Suspense, {
|
|
271
|
+
fallback: nonRankableBody
|
|
272
|
+
}, /*#__PURE__*/React.createElement(RankableTableBody, _extends({
|
|
273
|
+
ref: ref
|
|
274
|
+
}, bodyProps, {
|
|
275
|
+
isRanking: isRanking,
|
|
276
|
+
onRankStart: onRankStart,
|
|
277
|
+
onRankEnd: onRankEnd,
|
|
278
|
+
isRankingDisabled: isRankingDisabled
|
|
279
|
+
})))) : nonRankableBody;
|
|
280
|
+
});
|
|
244
281
|
export { DynamicTable as DynamicTableWithoutAnalytics };
|
|
245
282
|
const createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
246
283
|
export default withAnalyticsContext({
|
|
@@ -5,7 +5,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
5
5
|
import { tableRowCSSVars as cssVars } from './dynamic-table';
|
|
6
6
|
const rowStyles = css({
|
|
7
7
|
backgroundColor: "var(--ds-background-neutral-subtle, transparent)",
|
|
8
|
-
'&:focus': {
|
|
8
|
+
'&:focus-visible': {
|
|
9
9
|
outline: `2px solid ${`var(--ds-border-focused, ${`var(${cssVars.CSS_VAR_HOVER_BACKGROUND})`})`}`,
|
|
10
10
|
outlineOffset: `-2px`
|
|
11
11
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
7
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(ErrorBoundary, _React$Component);
|
|
11
|
+
var _super = _createSuper(ErrorBoundary);
|
|
12
|
+
function ErrorBoundary(props) {
|
|
13
|
+
var _this;
|
|
14
|
+
_classCallCheck(this, ErrorBoundary);
|
|
15
|
+
_this = _super.call(this, props);
|
|
16
|
+
_this.state = {
|
|
17
|
+
hasError: false
|
|
18
|
+
};
|
|
19
|
+
return _this;
|
|
20
|
+
}
|
|
21
|
+
_createClass(ErrorBoundary, [{
|
|
22
|
+
key: "render",
|
|
23
|
+
value: function render() {
|
|
24
|
+
if (this.state.hasError) {
|
|
25
|
+
// You can render any custom fallback UI
|
|
26
|
+
return this.props.fallback;
|
|
27
|
+
}
|
|
28
|
+
return this.props.children;
|
|
29
|
+
}
|
|
30
|
+
}], [{
|
|
31
|
+
key: "getDerivedStateFromError",
|
|
32
|
+
value: function getDerivedStateFromError() {
|
|
33
|
+
// Update state so the next render will show the fallback UI.
|
|
34
|
+
return {
|
|
35
|
+
hasError: true
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}]);
|
|
39
|
+
return ErrorBoundary;
|
|
40
|
+
}(React.Component);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
1
3
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -6,9 +8,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
8
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
9
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
10
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
+
var _excluded = ["isRankable", "isRanking", "onRankStart", "onRankEnd", "isRankingDisabled"];
|
|
9
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
|
-
import React from 'react';
|
|
14
|
+
import React, { forwardRef, lazy, Suspense, useEffect, useState } from 'react';
|
|
12
15
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
16
|
import noop from '@atlaskit/ds-lib/noop';
|
|
14
17
|
import { ASC, DESC, LARGE, SMALL } from '../internal/constants';
|
|
@@ -16,13 +19,13 @@ import { assertIsSortable, getPageRows, validateSortKey } from '../internal/help
|
|
|
16
19
|
import { Caption, PaginationWrapper, Table } from '../styled/dynamic-table';
|
|
17
20
|
import { EmptyViewContainer, EmptyViewWithFixedHeight } from '../styled/empty-body';
|
|
18
21
|
import Body from './body';
|
|
22
|
+
import { ErrorBoundary } from './error-boundary';
|
|
19
23
|
import LoadingContainer from './loading-container';
|
|
20
24
|
import LoadingContainerAdvanced from './loading-container-advanced';
|
|
21
25
|
import ManagedPagination from './managed-pagination';
|
|
22
|
-
import RankableTableBody from './rankable/body';
|
|
23
26
|
import TableHead from './table-head';
|
|
24
27
|
var packageName = "@atlaskit/dynamic-table";
|
|
25
|
-
var packageVersion = "14.
|
|
28
|
+
var packageVersion = "14.13.0";
|
|
26
29
|
function toggleSortOrder(currentSortOrder) {
|
|
27
30
|
switch (currentSortOrder) {
|
|
28
31
|
case DESC:
|
|
@@ -200,7 +203,6 @@ var DynamicTable = /*#__PURE__*/function (_React$Component) {
|
|
|
200
203
|
var rowsExist = !!rowsLength;
|
|
201
204
|
var spinnerSize = this.getSpinnerSize();
|
|
202
205
|
var emptyBody = this.renderEmptyBody();
|
|
203
|
-
var canRank = isRankable && !sortKey;
|
|
204
206
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingContainerAdvanced, {
|
|
205
207
|
isLoading: isLoading && rowsExist,
|
|
206
208
|
spinnerSize: spinnerSize,
|
|
@@ -221,12 +223,13 @@ var DynamicTable = /*#__PURE__*/function (_React$Component) {
|
|
|
221
223
|
isRanking: this.state.isRanking,
|
|
222
224
|
isRankable: isRankable,
|
|
223
225
|
testId: testId
|
|
224
|
-
}), rowsExist &&
|
|
226
|
+
}), rowsExist && /*#__PURE__*/React.createElement(TableBody, _extends({}, bodyProps, {
|
|
227
|
+
isRankable: this.props.isRankable,
|
|
225
228
|
isRanking: this.state.isRanking,
|
|
226
229
|
onRankStart: this.onRankStartHandler,
|
|
227
230
|
onRankEnd: this.onRankEndHandler,
|
|
228
231
|
isRankingDisabled: isRankingDisabled || isLoading || false
|
|
229
|
-
}))
|
|
232
|
+
})))), totalPages <= 1 ? null :
|
|
230
233
|
/*#__PURE__*/
|
|
231
234
|
// only show pagination if there's MORE than 1 page
|
|
232
235
|
React.createElement(PaginationWrapper, null, /*#__PURE__*/React.createElement(ManagedPagination, {
|
|
@@ -262,6 +265,48 @@ _defineProperty(DynamicTable, "defaultProps", {
|
|
|
262
265
|
pageLabel: 'Page'
|
|
263
266
|
}
|
|
264
267
|
});
|
|
268
|
+
var RankableTableBody = /*#__PURE__*/lazy(function () {
|
|
269
|
+
return import( /* webpackChunkName: '@atlaskit-internal_dynamic-table' */'./rankable/body');
|
|
270
|
+
});
|
|
271
|
+
var TableBody = /*#__PURE__*/forwardRef(function TableBody(_ref, ref) {
|
|
272
|
+
var _ref$isRankable = _ref.isRankable,
|
|
273
|
+
isRankable = _ref$isRankable === void 0 ? false : _ref$isRankable,
|
|
274
|
+
isRanking = _ref.isRanking,
|
|
275
|
+
onRankStart = _ref.onRankStart,
|
|
276
|
+
onRankEnd = _ref.onRankEnd,
|
|
277
|
+
isRankingDisabled = _ref.isRankingDisabled,
|
|
278
|
+
bodyProps = _objectWithoutProperties(_ref, _excluded);
|
|
279
|
+
var canRank = isRankable && !bodyProps.sortKey;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* React 16 does not support SSR for lazy components,
|
|
283
|
+
* so we avoid rendering the `Suspense` on the server.
|
|
284
|
+
*/
|
|
285
|
+
var _useState = useState(false),
|
|
286
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
287
|
+
canRenderRankable = _useState2[0],
|
|
288
|
+
setCanRenderRankable = _useState2[1];
|
|
289
|
+
useEffect(function () {
|
|
290
|
+
if (canRank) {
|
|
291
|
+
setCanRenderRankable(true);
|
|
292
|
+
}
|
|
293
|
+
}, [canRank]);
|
|
294
|
+
var nonRankableBody = /*#__PURE__*/React.createElement(Body, _extends({
|
|
295
|
+
ref: ref
|
|
296
|
+
}, bodyProps));
|
|
297
|
+
return canRank && canRenderRankable ? /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
298
|
+
fallback: nonRankableBody
|
|
299
|
+
}, /*#__PURE__*/React.createElement(Suspense, {
|
|
300
|
+
fallback: nonRankableBody
|
|
301
|
+
}, /*#__PURE__*/React.createElement(RankableTableBody, _extends({
|
|
302
|
+
ref: ref
|
|
303
|
+
}, bodyProps, {
|
|
304
|
+
isRanking: isRanking,
|
|
305
|
+
onRankStart: onRankStart,
|
|
306
|
+
onRankEnd: onRankEnd,
|
|
307
|
+
isRankingDisabled: isRankingDisabled
|
|
308
|
+
})))) : nonRankableBody;
|
|
309
|
+
});
|
|
265
310
|
export { DynamicTable as DynamicTableWithoutAnalytics };
|
|
266
311
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
267
312
|
export default withAnalyticsContext({
|
|
@@ -7,7 +7,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
7
7
|
import { tableRowCSSVars as cssVars } from './dynamic-table';
|
|
8
8
|
var rowStyles = css({
|
|
9
9
|
backgroundColor: "var(--ds-background-neutral-subtle, transparent)",
|
|
10
|
-
'&:focus': {
|
|
10
|
+
'&:focus-visible': {
|
|
11
11
|
outline: "2px solid ".concat("var(--ds-border-focused, ".concat("var(".concat(cssVars.CSS_VAR_HOVER_BACKGROUND, ")"), ")")),
|
|
12
12
|
outlineOffset: "-2px"
|
|
13
13
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
type ErrorBoundaryProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
fallback: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
type ErrorBoundaryState = {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
10
|
+
constructor(props: ErrorBoundaryProps);
|
|
11
|
+
static getDerivedStateFromError(): {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
};
|
|
14
|
+
render(): React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
type ErrorBoundaryProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
fallback: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
type ErrorBoundaryState = {
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
10
|
+
constructor(props: ErrorBoundaryProps);
|
|
11
|
+
static getDerivedStateFromError(): {
|
|
12
|
+
hasError: boolean;
|
|
13
|
+
};
|
|
14
|
+
render(): React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/dynamic-table",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.13.0",
|
|
4
4
|
"description": "A dynamic table displays rows of data with built-in pagination, sorting, and re-ordering functionality.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@atlaskit/pagination": "^14.4.0",
|
|
42
42
|
"@atlaskit/spinner": "^16.0.0",
|
|
43
43
|
"@atlaskit/theme": "^12.6.0",
|
|
44
|
-
"@atlaskit/tokens": "^1.
|
|
44
|
+
"@atlaskit/tokens": "^1.34.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@emotion/react": "^11.7.1",
|
|
47
47
|
"react-beautiful-dnd": "^12.1.1"
|