@atlaskit/dynamic-table 14.10.0 → 14.11.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 +6 -0
- package/dist/cjs/components/body.js +10 -3
- package/dist/cjs/components/loading-container-advanced.js +14 -39
- package/dist/cjs/components/rankable/body.js +15 -3
- package/dist/cjs/components/stateless.js +4 -5
- package/dist/cjs/hoc/with-sorted-page-rows.js +11 -3
- package/dist/cjs/styled/constants.js +0 -2
- package/dist/cjs/styled/loading-container-advanced.js +4 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/body.js +10 -3
- package/dist/es2019/components/loading-container-advanced.js +14 -32
- package/dist/es2019/components/rankable/body.js +15 -3
- package/dist/es2019/components/stateless.js +4 -5
- package/dist/es2019/hoc/with-sorted-page-rows.js +11 -4
- package/dist/es2019/styled/constants.js +0 -2
- package/dist/es2019/styled/loading-container-advanced.js +4 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/body.js +10 -3
- package/dist/esm/components/loading-container-advanced.js +14 -39
- package/dist/esm/components/rankable/body.js +15 -3
- package/dist/esm/components/stateless.js +4 -5
- package/dist/esm/hoc/with-sorted-page-rows.js +11 -3
- package/dist/esm/styled/constants.js +0 -2
- package/dist/esm/styled/loading-container-advanced.js +4 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/components/body.d.ts +4 -102
- package/dist/types/components/loading-container-advanced.d.ts +4 -7
- package/dist/types/components/rankable/body.d.ts +5 -103
- package/dist/types/components/stateless.d.ts +1 -1
- package/dist/types/hoc/with-sorted-page-rows.d.ts +3 -102
- package/dist/types/styled/loading-container-advanced.d.ts +1 -2
- package/dist/types-ts4.5/components/body.d.ts +4 -102
- package/dist/types-ts4.5/components/loading-container-advanced.d.ts +4 -7
- package/dist/types-ts4.5/components/rankable/body.d.ts +5 -103
- package/dist/types-ts4.5/components/stateless.d.ts +1 -1
- package/dist/types-ts4.5/hoc/with-sorted-page-rows.d.ts +3 -102
- package/dist/types-ts4.5/styled/loading-container-advanced.d.ts +1 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
@@ -30,9 +31,11 @@ var Body = /*#__PURE__*/function (_React$Component) {
|
|
|
30
31
|
head = _this$props.head,
|
|
31
32
|
isFixedSize = _this$props.isFixedSize,
|
|
32
33
|
highlightedRowIndex = _this$props.highlightedRowIndex,
|
|
33
|
-
testId = _this$props.testId
|
|
34
|
+
testId = _this$props.testId,
|
|
35
|
+
forwardedRef = _this$props.forwardedRef;
|
|
34
36
|
return /*#__PURE__*/_react.default.createElement("tbody", {
|
|
35
|
-
"data-testid": testId && "".concat(testId, "--body")
|
|
37
|
+
"data-testid": testId && "".concat(testId, "--body"),
|
|
38
|
+
ref: forwardedRef
|
|
36
39
|
}, pageRows.map(function (row, rowIndex) {
|
|
37
40
|
return /*#__PURE__*/_react.default.createElement(_tableRow.default, {
|
|
38
41
|
head: head,
|
|
@@ -47,5 +50,9 @@ var Body = /*#__PURE__*/function (_React$Component) {
|
|
|
47
50
|
}]);
|
|
48
51
|
return Body;
|
|
49
52
|
}(_react.default.Component);
|
|
50
|
-
var _default = (0, _withSortedPageRows.default)(
|
|
53
|
+
var _default = (0, _withSortedPageRows.default)( /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(Body, (0, _extends2.default)({}, props, {
|
|
55
|
+
forwardedRef: ref
|
|
56
|
+
}));
|
|
57
|
+
}));
|
|
51
58
|
exports.default = _default;
|
|
@@ -14,23 +14,11 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
|
|
|
14
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
var _reactDom = require("react-dom");
|
|
18
17
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
19
18
|
var _constants = require("../internal/constants");
|
|
20
19
|
var _loadingContainerAdvanced = require("../styled/loading-container-advanced");
|
|
21
20
|
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); }; }
|
|
22
21
|
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; } } /* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
23
|
-
// there is a bug with findDOMNode and Suspense in React < 16.9: https://github.com/facebook/react/issues/14188
|
|
24
|
-
var safeFindDOMNode = function safeFindDOMNode(component) {
|
|
25
|
-
try {
|
|
26
|
-
// DSP-10519 TODO: ReactDOM.findDOMNode is deprecated in React18, consider using alternative solution
|
|
27
|
-
// https://react.dev/reference/react-dom/findDOMNode#alternatives
|
|
28
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
29
|
-
return (0, _reactDom.findDOMNode)(component);
|
|
30
|
-
} catch (e) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
22
|
var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
35
23
|
(0, _inherits2.default)(LoadingContainerAdvanced, _React$Component);
|
|
36
24
|
var _super = _createSuper(LoadingContainerAdvanced);
|
|
@@ -41,6 +29,8 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
|
41
29
|
args[_key] = arguments[_key];
|
|
42
30
|
}
|
|
43
31
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "spinnerRef", /*#__PURE__*/_react.default.createRef());
|
|
33
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "containerRef", /*#__PURE__*/_react.default.createRef());
|
|
44
34
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "componentDidMount", function () {
|
|
45
35
|
if (_this.props.isLoading && _this.hasTargetNode()) {
|
|
46
36
|
_this.attachListeners();
|
|
@@ -69,18 +59,8 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
|
69
59
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTargetNode", function () {
|
|
70
60
|
var nextProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
|
|
71
61
|
var targetRef = nextProps.targetRef;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// @ts-ignore - targetElement is not assignable to type 'ReactInstance'
|
|
75
|
-
var targetNode = safeFindDOMNode(targetElement);
|
|
76
|
-
return targetNode;
|
|
77
|
-
});
|
|
78
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getThisNode", function () {
|
|
79
|
-
return safeFindDOMNode((0, _assertThisInitialized2.default)(_this));
|
|
80
|
-
});
|
|
81
|
-
// @ts-ignore - this.spinnerRef is not assignable to type 'ReactInstance'
|
|
82
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSpinnerNode", function () {
|
|
83
|
-
return safeFindDOMNode(_this.spinnerRef);
|
|
62
|
+
var target = targetRef === null || targetRef === void 0 ? void 0 : targetRef();
|
|
63
|
+
return target || _this.containerRef.current;
|
|
84
64
|
});
|
|
85
65
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasTargetNode", function (nextProps) {
|
|
86
66
|
return !!_this.getTargetNode(nextProps);
|
|
@@ -135,10 +115,11 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
|
135
115
|
}, {
|
|
136
116
|
key: "updateSpinnerPosition",
|
|
137
117
|
value: function updateSpinnerPosition() {
|
|
118
|
+
var _this$spinnerRef, _this$containerRef;
|
|
138
119
|
var viewportHeight = window.innerHeight;
|
|
139
120
|
var targetNode = this.getTargetNode();
|
|
140
|
-
var spinnerNode = this.
|
|
141
|
-
if (!targetNode || !spinnerNode) {
|
|
121
|
+
var spinnerNode = (_this$spinnerRef = this.spinnerRef) === null || _this$spinnerRef === void 0 ? void 0 : _this$spinnerRef.current;
|
|
122
|
+
if (!targetNode || typeof targetNode.getBoundingClientRect !== 'function' || !spinnerNode) {
|
|
142
123
|
return;
|
|
143
124
|
}
|
|
144
125
|
var targetRect = targetNode.getBoundingClientRect();
|
|
@@ -182,9 +163,9 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
|
182
163
|
// 1) the element is fully visible
|
|
183
164
|
// 2) the element is too small for the spinner to follow
|
|
184
165
|
// 3) the spinner might still be visible while the element isn't
|
|
185
|
-
var
|
|
186
|
-
if (
|
|
187
|
-
var thisTop =
|
|
166
|
+
var containerNode = (_this$containerRef = this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.current;
|
|
167
|
+
if (containerNode && typeof containerNode.getBoundingClientRect === 'function') {
|
|
168
|
+
var thisTop = containerNode.getBoundingClientRect().top;
|
|
188
169
|
var _y3 = (top - thisTop) / 2;
|
|
189
170
|
this.translateSpinner(spinnerNode, _y3, false);
|
|
190
171
|
}
|
|
@@ -192,24 +173,18 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
|
|
|
192
173
|
}, {
|
|
193
174
|
key: "render",
|
|
194
175
|
value: function render() {
|
|
195
|
-
var _this2 = this;
|
|
196
176
|
var _this$props2 = this.props,
|
|
197
177
|
children = _this$props2.children,
|
|
198
178
|
isLoading = _this$props2.isLoading,
|
|
199
179
|
spinnerSize = _this$props2.spinnerSize,
|
|
200
180
|
testId = _this$props2.testId;
|
|
201
181
|
return /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.Container, {
|
|
202
|
-
testId: testId && "".concat(testId, "--loading--container--advanced")
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
_this2.children = el;
|
|
206
|
-
}
|
|
207
|
-
}), isLoading && /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.SpinnerBackdrop, {
|
|
182
|
+
testId: testId && "".concat(testId, "--loading--container--advanced"),
|
|
183
|
+
ref: this.containerRef
|
|
184
|
+
}, children, isLoading && /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.SpinnerBackdrop, {
|
|
208
185
|
testId: testId
|
|
209
186
|
}, /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.SpinnerContainer, {
|
|
210
|
-
ref:
|
|
211
|
-
return _this2.spinnerRef = el;
|
|
212
|
-
}
|
|
187
|
+
ref: this.spinnerRef
|
|
213
188
|
}, /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
214
189
|
size: spinnerSize,
|
|
215
190
|
testId: testId && "".concat(testId, "--loadingSpinner")
|
|
@@ -84,7 +84,8 @@ var RankableBody = /*#__PURE__*/function (_React$Component) {
|
|
|
84
84
|
isFixedSize = _this$props2.isFixedSize,
|
|
85
85
|
isRanking = _this$props2.isRanking,
|
|
86
86
|
isRankingDisabled = _this$props2.isRankingDisabled,
|
|
87
|
-
testId = _this$props2.testId
|
|
87
|
+
testId = _this$props2.testId,
|
|
88
|
+
forwardedRef = _this$props2.forwardedRef;
|
|
88
89
|
return /*#__PURE__*/_react.default.createElement(_reactBeautifulDnd.DragDropContext, {
|
|
89
90
|
onBeforeDragStart: this.onBeforeDragStart,
|
|
90
91
|
onDragEnd: this.onDragEnd
|
|
@@ -94,7 +95,14 @@ var RankableBody = /*#__PURE__*/function (_React$Component) {
|
|
|
94
95
|
}, function (provided) {
|
|
95
96
|
return /*#__PURE__*/_react.default.createElement("tbody", (0, _extends2.default)({
|
|
96
97
|
"data-testid": testId,
|
|
97
|
-
ref:
|
|
98
|
+
ref: function ref(_ref) {
|
|
99
|
+
if (provided && typeof provided.innerRef === 'function') {
|
|
100
|
+
provided.innerRef(_ref);
|
|
101
|
+
}
|
|
102
|
+
if (forwardedRef) {
|
|
103
|
+
forwardedRef.current = _ref;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
98
106
|
}, provided.droppableProps), pageRows.map(function (row, rowIndex) {
|
|
99
107
|
return /*#__PURE__*/_react.default.createElement(_tableRow.default, {
|
|
100
108
|
head: head,
|
|
@@ -114,5 +122,9 @@ var RankableBody = /*#__PURE__*/function (_React$Component) {
|
|
|
114
122
|
return RankableBody;
|
|
115
123
|
}(_react.default.Component);
|
|
116
124
|
exports.RankableBody = RankableBody;
|
|
117
|
-
var _default = (0, _withSortedPageRows.default)(
|
|
125
|
+
var _default = (0, _withSortedPageRows.default)( /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
126
|
+
return /*#__PURE__*/_react.default.createElement(RankableBody, (0, _extends2.default)({}, props, {
|
|
127
|
+
forwardedRef: ref
|
|
128
|
+
}));
|
|
129
|
+
}));
|
|
118
130
|
exports.default = _default;
|
|
@@ -29,7 +29,7 @@ var _tableHead = _interopRequireDefault(require("./table-head"));
|
|
|
29
29
|
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
30
|
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
31
|
var packageName = "@atlaskit/dynamic-table";
|
|
32
|
-
var packageVersion = "14.
|
|
32
|
+
var packageVersion = "14.11.0";
|
|
33
33
|
function toggleSortOrder(currentSortOrder) {
|
|
34
34
|
switch (currentSortOrder) {
|
|
35
35
|
case _constants.DESC:
|
|
@@ -50,6 +50,7 @@ var DynamicTable = /*#__PURE__*/function (_React$Component) {
|
|
|
50
50
|
args[_key] = arguments[_key];
|
|
51
51
|
}
|
|
52
52
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
53
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tableBody", /*#__PURE__*/_react.default.createRef());
|
|
53
54
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
54
55
|
isRanking: false
|
|
55
56
|
});
|
|
@@ -200,9 +201,7 @@ var DynamicTable = /*#__PURE__*/function (_React$Component) {
|
|
|
200
201
|
isFixedSize: isFixedSize || false,
|
|
201
202
|
onPageRowsUpdate: onPageRowsUpdate,
|
|
202
203
|
isTotalPagesControlledExternally: isTotalPagesControlledExternally,
|
|
203
|
-
ref:
|
|
204
|
-
_this2.tableBody = el;
|
|
205
|
-
},
|
|
204
|
+
ref: this.tableBody,
|
|
206
205
|
testId: testId
|
|
207
206
|
};
|
|
208
207
|
var rowsExist = !!rowsLength;
|
|
@@ -213,7 +212,7 @@ var DynamicTable = /*#__PURE__*/function (_React$Component) {
|
|
|
213
212
|
isLoading: isLoading && rowsExist,
|
|
214
213
|
spinnerSize: spinnerSize,
|
|
215
214
|
targetRef: function targetRef() {
|
|
216
|
-
return _this2.tableBody;
|
|
215
|
+
return _this2.tableBody.current;
|
|
217
216
|
},
|
|
218
217
|
testId: testId
|
|
219
218
|
}, /*#__PURE__*/_react.default.createElement(_dynamicTable.Table, {
|
|
@@ -18,7 +18,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
18
18
|
var _react = _interopRequireDefault(require("react"));
|
|
19
19
|
var _constants = require("../internal/constants");
|
|
20
20
|
var _helpers = require("../internal/helpers");
|
|
21
|
-
var _excluded = ["rows", "head", "sortKey", "sortOrder", "rowsPerPage", "page"];
|
|
21
|
+
var _excluded = ["rows", "head", "sortKey", "sortOrder", "rowsPerPage", "page", "forwardedRef"];
|
|
22
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
24
|
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); }; }
|
|
@@ -94,7 +94,7 @@ var getSortedRows = function getSortedRows(head, rows, sortKey, sortOrder) {
|
|
|
94
94
|
};
|
|
95
95
|
// get one page of data in table, sorting all rows previously
|
|
96
96
|
function withSortedPageRows(WrappedComponent) {
|
|
97
|
-
|
|
97
|
+
var WithSortedPageRows = /*#__PURE__*/function (_React$Component) {
|
|
98
98
|
(0, _inherits2.default)(WithSortedPageRows, _React$Component);
|
|
99
99
|
var _super = _createSuper(WithSortedPageRows);
|
|
100
100
|
function WithSortedPageRows() {
|
|
@@ -131,13 +131,16 @@ function withSortedPageRows(WrappedComponent) {
|
|
|
131
131
|
sortOrder = _this$props.sortOrder,
|
|
132
132
|
rowsPerPage = _this$props.rowsPerPage,
|
|
133
133
|
page = _this$props.page,
|
|
134
|
+
forwardedRef = _this$props.forwardedRef,
|
|
134
135
|
restProps = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
|
|
135
136
|
return /*#__PURE__*/_react.default.createElement(WrappedComponent
|
|
136
137
|
//@ts-expect-error TODO Fix legit TypeScript 3.9.6 improved inference error
|
|
137
138
|
, (0, _extends2.default)({
|
|
138
139
|
pageRows: this.state.pageRows,
|
|
139
140
|
head: head
|
|
140
|
-
}, restProps
|
|
141
|
+
}, restProps, {
|
|
142
|
+
ref: forwardedRef
|
|
143
|
+
}));
|
|
141
144
|
}
|
|
142
145
|
}], [{
|
|
143
146
|
key: "getDerivedStateFromProps",
|
|
@@ -166,4 +169,9 @@ function withSortedPageRows(WrappedComponent) {
|
|
|
166
169
|
}]);
|
|
167
170
|
return WithSortedPageRows;
|
|
168
171
|
}(_react.default.Component);
|
|
172
|
+
return /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
173
|
+
return /*#__PURE__*/_react.default.createElement(WithSortedPageRows, (0, _extends2.default)({}, props, {
|
|
174
|
+
forwardedRef: ref
|
|
175
|
+
}));
|
|
176
|
+
});
|
|
169
177
|
}
|
|
@@ -31,11 +31,9 @@ var cellStyles = (0, _react.css)({
|
|
|
31
31
|
border: 'none',
|
|
32
32
|
textAlign: 'left',
|
|
33
33
|
'&:first-of-type': {
|
|
34
|
-
// TODO Delete this comment after verifying spacing token -> previous value `0`
|
|
35
34
|
paddingLeft: "var(--ds-space-0, 0px)"
|
|
36
35
|
},
|
|
37
36
|
'&:last-child': {
|
|
38
|
-
// TODO Delete this comment after verifying spacing token -> previous value `0`
|
|
39
37
|
paddingRight: "var(--ds-space-0, 0px)"
|
|
40
38
|
}
|
|
41
39
|
});
|
|
@@ -16,7 +16,7 @@ var containerStyles = (0, _react2.css)({
|
|
|
16
16
|
marginBottom: "var(--ds-space-300, 24px)",
|
|
17
17
|
position: 'relative'
|
|
18
18
|
});
|
|
19
|
-
var Container = function
|
|
19
|
+
var Container = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
20
20
|
var children = props.children,
|
|
21
21
|
testId = props.testId,
|
|
22
22
|
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
@@ -25,10 +25,11 @@ var Container = function Container(props) {
|
|
|
25
25
|
(0, _react2.jsx)("div", (0, _extends2.default)({
|
|
26
26
|
css: containerStyles
|
|
27
27
|
}, rest, {
|
|
28
|
-
"data-testid": testId
|
|
28
|
+
"data-testid": testId,
|
|
29
|
+
ref: ref
|
|
29
30
|
}), children)
|
|
30
31
|
);
|
|
31
|
-
};
|
|
32
|
+
});
|
|
32
33
|
exports.Container = Container;
|
|
33
34
|
var spinnerBackdropStyles = (0, _react2.css)({
|
|
34
35
|
display: 'flex',
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import withSortedPageRows from '../hoc/with-sorted-page-rows';
|
|
3
4
|
import TableRow from './table-row';
|
|
@@ -8,10 +9,12 @@ class Body extends React.Component {
|
|
|
8
9
|
head,
|
|
9
10
|
isFixedSize,
|
|
10
11
|
highlightedRowIndex,
|
|
11
|
-
testId
|
|
12
|
+
testId,
|
|
13
|
+
forwardedRef
|
|
12
14
|
} = this.props;
|
|
13
15
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
14
|
-
"data-testid": testId && `${testId}--body
|
|
16
|
+
"data-testid": testId && `${testId}--body`,
|
|
17
|
+
ref: forwardedRef
|
|
15
18
|
}, pageRows.map((row, rowIndex) => /*#__PURE__*/React.createElement(TableRow, {
|
|
16
19
|
head: head,
|
|
17
20
|
isFixedSize: isFixedSize,
|
|
@@ -22,4 +25,8 @@ class Body extends React.Component {
|
|
|
22
25
|
})));
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
|
-
export default withSortedPageRows(
|
|
28
|
+
export default withSortedPageRows( /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
29
|
+
return /*#__PURE__*/React.createElement(Body, _extends({}, props, {
|
|
30
|
+
forwardedRef: ref
|
|
31
|
+
}));
|
|
32
|
+
}));
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
/* eslint-disable @repo/internal/dom-events/no-unsafe-event-listeners */
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { findDOMNode } from 'react-dom';
|
|
5
4
|
import Spinner from '@atlaskit/spinner';
|
|
6
5
|
import { LARGE, LOADING_CONTENTS_OPACITY } from '../internal/constants';
|
|
7
6
|
import { Container, SpinnerBackdrop, SpinnerContainer } from '../styled/loading-container-advanced';
|
|
8
|
-
// there is a bug with findDOMNode and Suspense in React < 16.9: https://github.com/facebook/react/issues/14188
|
|
9
|
-
const safeFindDOMNode = component => {
|
|
10
|
-
try {
|
|
11
|
-
// DSP-10519 TODO: ReactDOM.findDOMNode is deprecated in React18, consider using alternative solution
|
|
12
|
-
// https://react.dev/reference/react-dom/findDOMNode#alternatives
|
|
13
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
14
|
-
return findDOMNode(component);
|
|
15
|
-
} catch (e) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
7
|
export default class LoadingContainerAdvanced extends React.Component {
|
|
20
8
|
constructor(...args) {
|
|
21
9
|
super(...args);
|
|
10
|
+
_defineProperty(this, "spinnerRef", /*#__PURE__*/React.createRef());
|
|
11
|
+
_defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
|
|
22
12
|
_defineProperty(this, "componentDidMount", () => {
|
|
23
13
|
if (this.props.isLoading && this.hasTargetNode()) {
|
|
24
14
|
this.attachListeners();
|
|
@@ -48,15 +38,9 @@ export default class LoadingContainerAdvanced extends React.Component {
|
|
|
48
38
|
const {
|
|
49
39
|
targetRef
|
|
50
40
|
} = nextProps;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// @ts-ignore - targetElement is not assignable to type 'ReactInstance'
|
|
54
|
-
const targetNode = safeFindDOMNode(targetElement);
|
|
55
|
-
return targetNode;
|
|
41
|
+
const target = targetRef === null || targetRef === void 0 ? void 0 : targetRef();
|
|
42
|
+
return target || this.containerRef.current;
|
|
56
43
|
});
|
|
57
|
-
_defineProperty(this, "getThisNode", () => safeFindDOMNode(this));
|
|
58
|
-
// @ts-ignore - this.spinnerRef is not assignable to type 'ReactInstance'
|
|
59
|
-
_defineProperty(this, "getSpinnerNode", () => safeFindDOMNode(this.spinnerRef));
|
|
60
44
|
_defineProperty(this, "hasTargetNode", nextProps => !!this.getTargetNode(nextProps));
|
|
61
45
|
_defineProperty(this, "isVerticallyVisible", (elementRect, viewportHeight) => {
|
|
62
46
|
const {
|
|
@@ -106,10 +90,11 @@ export default class LoadingContainerAdvanced extends React.Component {
|
|
|
106
90
|
window.removeEventListener('resize', this.handleResize);
|
|
107
91
|
}
|
|
108
92
|
updateSpinnerPosition() {
|
|
93
|
+
var _this$spinnerRef, _this$containerRef;
|
|
109
94
|
const viewportHeight = window.innerHeight;
|
|
110
95
|
const targetNode = this.getTargetNode();
|
|
111
|
-
const spinnerNode = this.
|
|
112
|
-
if (!targetNode || !spinnerNode) {
|
|
96
|
+
const spinnerNode = (_this$spinnerRef = this.spinnerRef) === null || _this$spinnerRef === void 0 ? void 0 : _this$spinnerRef.current;
|
|
97
|
+
if (!targetNode || typeof targetNode.getBoundingClientRect !== 'function' || !spinnerNode) {
|
|
113
98
|
return;
|
|
114
99
|
}
|
|
115
100
|
const targetRect = targetNode.getBoundingClientRect();
|
|
@@ -155,9 +140,9 @@ export default class LoadingContainerAdvanced extends React.Component {
|
|
|
155
140
|
// 1) the element is fully visible
|
|
156
141
|
// 2) the element is too small for the spinner to follow
|
|
157
142
|
// 3) the spinner might still be visible while the element isn't
|
|
158
|
-
const
|
|
159
|
-
if (
|
|
160
|
-
const thisTop =
|
|
143
|
+
const containerNode = (_this$containerRef = this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.current;
|
|
144
|
+
if (containerNode && typeof containerNode.getBoundingClientRect === 'function') {
|
|
145
|
+
const thisTop = containerNode.getBoundingClientRect().top;
|
|
161
146
|
const y = (top - thisTop) / 2;
|
|
162
147
|
this.translateSpinner(spinnerNode, y, false);
|
|
163
148
|
}
|
|
@@ -170,15 +155,12 @@ export default class LoadingContainerAdvanced extends React.Component {
|
|
|
170
155
|
testId
|
|
171
156
|
} = this.props;
|
|
172
157
|
return /*#__PURE__*/React.createElement(Container, {
|
|
173
|
-
testId: testId && `${testId}--loading--container--advanced
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
this.children = el;
|
|
177
|
-
}
|
|
178
|
-
}), isLoading && /*#__PURE__*/React.createElement(SpinnerBackdrop, {
|
|
158
|
+
testId: testId && `${testId}--loading--container--advanced`,
|
|
159
|
+
ref: this.containerRef
|
|
160
|
+
}, children, isLoading && /*#__PURE__*/React.createElement(SpinnerBackdrop, {
|
|
179
161
|
testId: testId
|
|
180
162
|
}, /*#__PURE__*/React.createElement(SpinnerContainer, {
|
|
181
|
-
ref:
|
|
163
|
+
ref: this.spinnerRef
|
|
182
164
|
}, /*#__PURE__*/React.createElement(Spinner, {
|
|
183
165
|
size: spinnerSize,
|
|
184
166
|
testId: testId && `${testId}--loadingSpinner`
|
|
@@ -74,7 +74,8 @@ export class RankableBody extends React.Component {
|
|
|
74
74
|
isFixedSize,
|
|
75
75
|
isRanking,
|
|
76
76
|
isRankingDisabled,
|
|
77
|
-
testId
|
|
77
|
+
testId,
|
|
78
|
+
forwardedRef
|
|
78
79
|
} = this.props;
|
|
79
80
|
return /*#__PURE__*/React.createElement(DragDropContext, {
|
|
80
81
|
onBeforeDragStart: this.onBeforeDragStart,
|
|
@@ -84,7 +85,14 @@ export class RankableBody extends React.Component {
|
|
|
84
85
|
isDropDisabled: isRankingDisabled
|
|
85
86
|
}, provided => /*#__PURE__*/React.createElement("tbody", _extends({
|
|
86
87
|
"data-testid": testId,
|
|
87
|
-
ref:
|
|
88
|
+
ref: ref => {
|
|
89
|
+
if (provided && typeof provided.innerRef === 'function') {
|
|
90
|
+
provided.innerRef(ref);
|
|
91
|
+
}
|
|
92
|
+
if (forwardedRef) {
|
|
93
|
+
forwardedRef.current = ref;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
88
96
|
}, provided.droppableProps), pageRows.map((row, rowIndex) => /*#__PURE__*/React.createElement(TableRow, {
|
|
89
97
|
head: head,
|
|
90
98
|
isRanking: isRanking,
|
|
@@ -98,4 +106,8 @@ export class RankableBody extends React.Component {
|
|
|
98
106
|
})), provided.placeholder)));
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
|
-
export default withSortedPageRows(
|
|
109
|
+
export default withSortedPageRows( /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
110
|
+
return /*#__PURE__*/React.createElement(RankableBody, _extends({}, props, {
|
|
111
|
+
forwardedRef: ref
|
|
112
|
+
}));
|
|
113
|
+
}));
|
|
@@ -14,7 +14,7 @@ import ManagedPagination from './managed-pagination';
|
|
|
14
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.11.0";
|
|
18
18
|
function toggleSortOrder(currentSortOrder) {
|
|
19
19
|
switch (currentSortOrder) {
|
|
20
20
|
case DESC:
|
|
@@ -28,6 +28,7 @@ function toggleSortOrder(currentSortOrder) {
|
|
|
28
28
|
class DynamicTable extends React.Component {
|
|
29
29
|
constructor(...args) {
|
|
30
30
|
super(...args);
|
|
31
|
+
_defineProperty(this, "tableBody", /*#__PURE__*/React.createRef());
|
|
31
32
|
_defineProperty(this, "state", {
|
|
32
33
|
isRanking: false
|
|
33
34
|
});
|
|
@@ -176,9 +177,7 @@ class DynamicTable extends React.Component {
|
|
|
176
177
|
isFixedSize: isFixedSize || false,
|
|
177
178
|
onPageRowsUpdate,
|
|
178
179
|
isTotalPagesControlledExternally,
|
|
179
|
-
ref:
|
|
180
|
-
this.tableBody = el;
|
|
181
|
-
},
|
|
180
|
+
ref: this.tableBody,
|
|
182
181
|
testId
|
|
183
182
|
};
|
|
184
183
|
const rowsExist = !!rowsLength;
|
|
@@ -188,7 +187,7 @@ class DynamicTable extends React.Component {
|
|
|
188
187
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoadingContainerAdvanced, {
|
|
189
188
|
isLoading: isLoading && rowsExist,
|
|
190
189
|
spinnerSize: spinnerSize,
|
|
191
|
-
targetRef: () => this.tableBody,
|
|
190
|
+
targetRef: () => this.tableBody.current,
|
|
192
191
|
testId: testId
|
|
193
192
|
}, /*#__PURE__*/React.createElement(Table, {
|
|
194
193
|
isFixedSize: isFixedSize,
|
|
@@ -74,7 +74,7 @@ const getSortedRows = (head, rows, sortKey, sortOrder) => {
|
|
|
74
74
|
};
|
|
75
75
|
// get one page of data in table, sorting all rows previously
|
|
76
76
|
export default function withSortedPageRows(WrappedComponent) {
|
|
77
|
-
|
|
77
|
+
class WithSortedPageRows extends React.Component {
|
|
78
78
|
constructor(...args) {
|
|
79
79
|
super(...args);
|
|
80
80
|
_defineProperty(this, "state", {
|
|
@@ -122,7 +122,7 @@ export default function withSortedPageRows(WrappedComponent) {
|
|
|
122
122
|
sortOrder,
|
|
123
123
|
rowsPerPage,
|
|
124
124
|
page,
|
|
125
|
-
|
|
125
|
+
forwardedRef,
|
|
126
126
|
...restProps
|
|
127
127
|
} = this.props;
|
|
128
128
|
return /*#__PURE__*/React.createElement(WrappedComponent
|
|
@@ -130,7 +130,14 @@ export default function withSortedPageRows(WrappedComponent) {
|
|
|
130
130
|
, _extends({
|
|
131
131
|
pageRows: this.state.pageRows,
|
|
132
132
|
head: head
|
|
133
|
-
}, restProps
|
|
133
|
+
}, restProps, {
|
|
134
|
+
ref: forwardedRef
|
|
135
|
+
}));
|
|
134
136
|
}
|
|
135
|
-
}
|
|
137
|
+
}
|
|
138
|
+
return /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
139
|
+
return /*#__PURE__*/React.createElement(WithSortedPageRows, _extends({}, props, {
|
|
140
|
+
forwardedRef: ref
|
|
141
|
+
}));
|
|
142
|
+
});
|
|
136
143
|
}
|
|
@@ -20,11 +20,9 @@ export const cellStyles = css({
|
|
|
20
20
|
border: 'none',
|
|
21
21
|
textAlign: 'left',
|
|
22
22
|
'&:first-of-type': {
|
|
23
|
-
// TODO Delete this comment after verifying spacing token -> previous value `0`
|
|
24
23
|
paddingLeft: "var(--ds-space-0, 0px)"
|
|
25
24
|
},
|
|
26
25
|
'&:last-child': {
|
|
27
|
-
// TODO Delete this comment after verifying spacing token -> previous value `0`
|
|
28
26
|
paddingRight: "var(--ds-space-0, 0px)"
|
|
29
27
|
}
|
|
30
28
|
});
|
|
@@ -7,7 +7,7 @@ const containerStyles = css({
|
|
|
7
7
|
marginBottom: "var(--ds-space-300, 24px)",
|
|
8
8
|
position: 'relative'
|
|
9
9
|
});
|
|
10
|
-
export const Container = props => {
|
|
10
|
+
export const Container = /*#__PURE__*/forwardRef((props, ref) => {
|
|
11
11
|
const {
|
|
12
12
|
children,
|
|
13
13
|
testId,
|
|
@@ -18,10 +18,11 @@ export const Container = props => {
|
|
|
18
18
|
jsx("div", _extends({
|
|
19
19
|
css: containerStyles
|
|
20
20
|
}, rest, {
|
|
21
|
-
"data-testid": testId
|
|
21
|
+
"data-testid": testId,
|
|
22
|
+
ref: ref
|
|
22
23
|
}), children)
|
|
23
24
|
);
|
|
24
|
-
};
|
|
25
|
+
});
|
|
25
26
|
const spinnerBackdropStyles = css({
|
|
26
27
|
display: 'flex',
|
|
27
28
|
position: 'absolute',
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
@@ -23,9 +24,11 @@ var Body = /*#__PURE__*/function (_React$Component) {
|
|
|
23
24
|
head = _this$props.head,
|
|
24
25
|
isFixedSize = _this$props.isFixedSize,
|
|
25
26
|
highlightedRowIndex = _this$props.highlightedRowIndex,
|
|
26
|
-
testId = _this$props.testId
|
|
27
|
+
testId = _this$props.testId,
|
|
28
|
+
forwardedRef = _this$props.forwardedRef;
|
|
27
29
|
return /*#__PURE__*/React.createElement("tbody", {
|
|
28
|
-
"data-testid": testId && "".concat(testId, "--body")
|
|
30
|
+
"data-testid": testId && "".concat(testId, "--body"),
|
|
31
|
+
ref: forwardedRef
|
|
29
32
|
}, pageRows.map(function (row, rowIndex) {
|
|
30
33
|
return /*#__PURE__*/React.createElement(TableRow, {
|
|
31
34
|
head: head,
|
|
@@ -40,4 +43,8 @@ var Body = /*#__PURE__*/function (_React$Component) {
|
|
|
40
43
|
}]);
|
|
41
44
|
return Body;
|
|
42
45
|
}(React.Component);
|
|
43
|
-
export default withSortedPageRows(
|
|
46
|
+
export default withSortedPageRows( /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
47
|
+
return /*#__PURE__*/React.createElement(Body, _extends({}, props, {
|
|
48
|
+
forwardedRef: ref
|
|
49
|
+
}));
|
|
50
|
+
}));
|