@atlaskit/dynamic-table 14.9.3 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/components/body.js +10 -3
  3. package/dist/cjs/components/loading-container-advanced.js +14 -36
  4. package/dist/cjs/components/managed-pagination.js +1 -0
  5. package/dist/cjs/components/rankable/body.js +15 -3
  6. package/dist/cjs/components/stateless.js +7 -7
  7. package/dist/cjs/hoc/with-sorted-page-rows.js +11 -3
  8. package/dist/cjs/styled/constants.js +0 -2
  9. package/dist/cjs/styled/loading-container-advanced.js +4 -3
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/components/body.js +10 -3
  12. package/dist/es2019/components/loading-container-advanced.js +14 -29
  13. package/dist/es2019/components/managed-pagination.js +1 -0
  14. package/dist/es2019/components/rankable/body.js +15 -3
  15. package/dist/es2019/components/stateless.js +7 -7
  16. package/dist/es2019/hoc/with-sorted-page-rows.js +11 -4
  17. package/dist/es2019/styled/constants.js +0 -2
  18. package/dist/es2019/styled/loading-container-advanced.js +4 -3
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/components/body.js +10 -3
  21. package/dist/esm/components/loading-container-advanced.js +14 -36
  22. package/dist/esm/components/managed-pagination.js +1 -0
  23. package/dist/esm/components/rankable/body.js +15 -3
  24. package/dist/esm/components/stateless.js +7 -7
  25. package/dist/esm/hoc/with-sorted-page-rows.js +11 -3
  26. package/dist/esm/styled/constants.js +0 -2
  27. package/dist/esm/styled/loading-container-advanced.js +4 -3
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/components/body.d.ts +4 -102
  30. package/dist/types/components/loading-container-advanced.d.ts +4 -7
  31. package/dist/types/components/rankable/body.d.ts +5 -103
  32. package/dist/types/components/stateless.d.ts +3 -1
  33. package/dist/types/hoc/with-sorted-page-rows.d.ts +3 -102
  34. package/dist/types/styled/loading-container-advanced.d.ts +1 -2
  35. package/dist/types/types.d.ts +8 -1
  36. package/dist/types-ts4.5/components/body.d.ts +4 -102
  37. package/dist/types-ts4.5/components/loading-container-advanced.d.ts +4 -7
  38. package/dist/types-ts4.5/components/rankable/body.d.ts +5 -103
  39. package/dist/types-ts4.5/components/stateless.d.ts +3 -1
  40. package/dist/types-ts4.5/hoc/with-sorted-page-rows.d.ts +3 -102
  41. package/dist/types-ts4.5/styled/loading-container-advanced.d.ts +1 -2
  42. package/dist/types-ts4.5/types.d.ts +8 -1
  43. package/package.json +3 -3
  44. package/report.api.md +2 -0
  45. package/tmp/api-report-tmp.d.ts +2 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/dynamic-table
2
2
 
3
+ ## 14.11.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`ec1f82f8027`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ec1f82f8027) - Move away from findDOMNode API to refs
8
+
9
+ ## 14.10.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`12d9c63d4c1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/12d9c63d4c1) - [ux] pass pageLabel to dynamic-table component and updat prev label in examples, add description in the types file, update example files
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies
18
+
3
19
  ## 14.9.3
4
20
 
5
21
  ### Patch Changes
@@ -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)(Body);
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,20 +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
- return (0, _reactDom.findDOMNode)(component);
27
- } catch (e) {
28
- return null;
29
- }
30
- };
31
22
  var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
32
23
  (0, _inherits2.default)(LoadingContainerAdvanced, _React$Component);
33
24
  var _super = _createSuper(LoadingContainerAdvanced);
@@ -38,6 +29,8 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
38
29
  args[_key] = arguments[_key];
39
30
  }
40
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());
41
34
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "componentDidMount", function () {
42
35
  if (_this.props.isLoading && _this.hasTargetNode()) {
43
36
  _this.attachListeners();
@@ -66,18 +59,8 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
66
59
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getTargetNode", function () {
67
60
  var nextProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
68
61
  var targetRef = nextProps.targetRef;
69
- // targetRef prop may be defined but it is not guaranteed it returns an element
70
- var targetElement = targetRef ? targetRef() : _this.children;
71
- // @ts-ignore - targetElement is not assignable to type 'ReactInstance'
72
- var targetNode = safeFindDOMNode(targetElement);
73
- return targetNode;
74
- });
75
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getThisNode", function () {
76
- return safeFindDOMNode((0, _assertThisInitialized2.default)(_this));
77
- });
78
- // @ts-ignore - this.spinnerRef is not assignable to type 'ReactInstance'
79
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSpinnerNode", function () {
80
- return safeFindDOMNode(_this.spinnerRef);
62
+ var target = targetRef === null || targetRef === void 0 ? void 0 : targetRef();
63
+ return target || _this.containerRef.current;
81
64
  });
82
65
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasTargetNode", function (nextProps) {
83
66
  return !!_this.getTargetNode(nextProps);
@@ -132,10 +115,11 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
132
115
  }, {
133
116
  key: "updateSpinnerPosition",
134
117
  value: function updateSpinnerPosition() {
118
+ var _this$spinnerRef, _this$containerRef;
135
119
  var viewportHeight = window.innerHeight;
136
120
  var targetNode = this.getTargetNode();
137
- var spinnerNode = this.getSpinnerNode();
138
- 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) {
139
123
  return;
140
124
  }
141
125
  var targetRect = targetNode.getBoundingClientRect();
@@ -179,9 +163,9 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
179
163
  // 1) the element is fully visible
180
164
  // 2) the element is too small for the spinner to follow
181
165
  // 3) the spinner might still be visible while the element isn't
182
- var thisNode = this.getThisNode();
183
- if (thisNode && typeof thisNode.getBoundingClientRect === 'function') {
184
- var thisTop = thisNode.getBoundingClientRect().top;
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;
185
169
  var _y3 = (top - thisTop) / 2;
186
170
  this.translateSpinner(spinnerNode, _y3, false);
187
171
  }
@@ -189,24 +173,18 @@ var LoadingContainerAdvanced = /*#__PURE__*/function (_React$Component) {
189
173
  }, {
190
174
  key: "render",
191
175
  value: function render() {
192
- var _this2 = this;
193
176
  var _this$props2 = this.props,
194
177
  children = _this$props2.children,
195
178
  isLoading = _this$props2.isLoading,
196
179
  spinnerSize = _this$props2.spinnerSize,
197
180
  testId = _this$props2.testId;
198
181
  return /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.Container, {
199
- testId: testId && "".concat(testId, "--loading--container--advanced")
200
- }, /*#__PURE__*/_react.default.cloneElement(children, {
201
- ref: function ref(el) {
202
- _this2.children = el;
203
- }
204
- }), 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, {
205
185
  testId: testId
206
186
  }, /*#__PURE__*/_react.default.createElement(_loadingContainerAdvanced.SpinnerContainer, {
207
- ref: function ref(el) {
208
- return _this2.spinnerRef = el;
209
- }
187
+ ref: this.spinnerRef
210
188
  }, /*#__PURE__*/_react.default.createElement(_spinner.default, {
211
189
  size: spinnerSize,
212
190
  testId: testId && "".concat(testId, "--loadingSpinner")
@@ -52,6 +52,7 @@ var ManagedPagination = /*#__PURE__*/function (_React$Component) {
52
52
  label: i18n === null || i18n === void 0 ? void 0 : i18n.label,
53
53
  nextLabel: i18n === null || i18n === void 0 ? void 0 : i18n.next,
54
54
  previousLabel: i18n === null || i18n === void 0 ? void 0 : i18n.prev,
55
+ pageLabel: i18n === null || i18n === void 0 ? void 0 : i18n.pageLabel,
55
56
  onChange: this.onChange,
56
57
  pages: pages,
57
58
  testId: testId && "".concat(testId, "--pagination")
@@ -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: provided.innerRef
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)(RankableBody);
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.9.3";
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: function ref(el) {
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, {
@@ -265,9 +264,10 @@ exports.DynamicTableWithoutAnalytics = DynamicTable;
265
264
  onRankStart: _noop.default,
266
265
  onRankEnd: _noop.default,
267
266
  paginationi18n: {
268
- prev: 'Prev',
267
+ prev: 'Previous',
269
268
  next: 'Next',
270
- label: 'Pagination'
269
+ label: 'Pagination',
270
+ pageLabel: 'Page'
271
271
  }
272
272
  });
273
273
  var createAndFireEventOnAtlaskit = (0, _analyticsNext.createAndFireEvent)('atlaskit');
@@ -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
- return /*#__PURE__*/function (_React$Component) {
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 Container(props) {
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',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.9.3",
3
+ "version": "14.11.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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(Body);
28
+ export default withSortedPageRows( /*#__PURE__*/React.forwardRef((props, ref) => {
29
+ return /*#__PURE__*/React.createElement(Body, _extends({}, props, {
30
+ forwardedRef: ref
31
+ }));
32
+ }));
@@ -1,21 +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
- return findDOMNode(component);
12
- } catch (e) {
13
- return null;
14
- }
15
- };
16
7
  export default class LoadingContainerAdvanced extends React.Component {
17
8
  constructor(...args) {
18
9
  super(...args);
10
+ _defineProperty(this, "spinnerRef", /*#__PURE__*/React.createRef());
11
+ _defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
19
12
  _defineProperty(this, "componentDidMount", () => {
20
13
  if (this.props.isLoading && this.hasTargetNode()) {
21
14
  this.attachListeners();
@@ -45,15 +38,9 @@ export default class LoadingContainerAdvanced extends React.Component {
45
38
  const {
46
39
  targetRef
47
40
  } = nextProps;
48
- // targetRef prop may be defined but it is not guaranteed it returns an element
49
- const targetElement = targetRef ? targetRef() : this.children;
50
- // @ts-ignore - targetElement is not assignable to type 'ReactInstance'
51
- const targetNode = safeFindDOMNode(targetElement);
52
- return targetNode;
41
+ const target = targetRef === null || targetRef === void 0 ? void 0 : targetRef();
42
+ return target || this.containerRef.current;
53
43
  });
54
- _defineProperty(this, "getThisNode", () => safeFindDOMNode(this));
55
- // @ts-ignore - this.spinnerRef is not assignable to type 'ReactInstance'
56
- _defineProperty(this, "getSpinnerNode", () => safeFindDOMNode(this.spinnerRef));
57
44
  _defineProperty(this, "hasTargetNode", nextProps => !!this.getTargetNode(nextProps));
58
45
  _defineProperty(this, "isVerticallyVisible", (elementRect, viewportHeight) => {
59
46
  const {
@@ -103,10 +90,11 @@ export default class LoadingContainerAdvanced extends React.Component {
103
90
  window.removeEventListener('resize', this.handleResize);
104
91
  }
105
92
  updateSpinnerPosition() {
93
+ var _this$spinnerRef, _this$containerRef;
106
94
  const viewportHeight = window.innerHeight;
107
95
  const targetNode = this.getTargetNode();
108
- const spinnerNode = this.getSpinnerNode();
109
- 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) {
110
98
  return;
111
99
  }
112
100
  const targetRect = targetNode.getBoundingClientRect();
@@ -152,9 +140,9 @@ export default class LoadingContainerAdvanced extends React.Component {
152
140
  // 1) the element is fully visible
153
141
  // 2) the element is too small for the spinner to follow
154
142
  // 3) the spinner might still be visible while the element isn't
155
- const thisNode = this.getThisNode();
156
- if (thisNode && typeof thisNode.getBoundingClientRect === 'function') {
157
- const thisTop = thisNode.getBoundingClientRect().top;
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;
158
146
  const y = (top - thisTop) / 2;
159
147
  this.translateSpinner(spinnerNode, y, false);
160
148
  }
@@ -167,15 +155,12 @@ export default class LoadingContainerAdvanced extends React.Component {
167
155
  testId
168
156
  } = this.props;
169
157
  return /*#__PURE__*/React.createElement(Container, {
170
- testId: testId && `${testId}--loading--container--advanced`
171
- }, /*#__PURE__*/React.cloneElement(children, {
172
- ref: el => {
173
- this.children = el;
174
- }
175
- }), isLoading && /*#__PURE__*/React.createElement(SpinnerBackdrop, {
158
+ testId: testId && `${testId}--loading--container--advanced`,
159
+ ref: this.containerRef
160
+ }, children, isLoading && /*#__PURE__*/React.createElement(SpinnerBackdrop, {
176
161
  testId: testId
177
162
  }, /*#__PURE__*/React.createElement(SpinnerContainer, {
178
- ref: el => this.spinnerRef = el
163
+ ref: this.spinnerRef
179
164
  }, /*#__PURE__*/React.createElement(Spinner, {
180
165
  size: spinnerSize,
181
166
  testId: testId && `${testId}--loadingSpinner`
@@ -24,6 +24,7 @@ export default class ManagedPagination extends React.Component {
24
24
  label: i18n === null || i18n === void 0 ? void 0 : i18n.label,
25
25
  nextLabel: i18n === null || i18n === void 0 ? void 0 : i18n.next,
26
26
  previousLabel: i18n === null || i18n === void 0 ? void 0 : i18n.prev,
27
+ pageLabel: i18n === null || i18n === void 0 ? void 0 : i18n.pageLabel,
27
28
  onChange: this.onChange,
28
29
  pages: pages,
29
30
  testId: testId && `${testId}--pagination`
@@ -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: provided.innerRef
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(RankableBody);
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.9.3";
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: el => {
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,
@@ -236,9 +235,10 @@ _defineProperty(DynamicTable, "defaultProps", {
236
235
  onRankStart: noop,
237
236
  onRankEnd: noop,
238
237
  paginationi18n: {
239
- prev: 'Prev',
238
+ prev: 'Previous',
240
239
  next: 'Next',
241
- label: 'Pagination'
240
+ label: 'Pagination',
241
+ pageLabel: 'Page'
242
242
  }
243
243
  });
244
244
  export { DynamicTable as DynamicTableWithoutAnalytics };
@@ -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
- return class WithSortedPageRows extends React.Component {
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
- // @ts-ignore - Rest types may only be created from object types
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',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/dynamic-table",
3
- "version": "14.9.3",
3
+ "version": "14.11.0",
4
4
  "sideEffects": false
5
5
  }