@atlaskit/table-tree 9.12.2 → 10.0.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 (53) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/components/cell.js +19 -41
  3. package/dist/cjs/components/header.js +23 -38
  4. package/dist/cjs/components/headers.js +31 -40
  5. package/dist/cjs/components/internal/chevron.js +32 -59
  6. package/dist/cjs/components/internal/item.js +38 -52
  7. package/dist/cjs/components/internal/items.js +31 -83
  8. package/dist/cjs/components/internal/loader-item.js +34 -66
  9. package/dist/cjs/components/internal/with-column-width.js +2 -4
  10. package/dist/cjs/components/row.js +120 -177
  11. package/dist/cjs/components/rows.js +17 -37
  12. package/dist/cjs/components/table-tree.js +75 -119
  13. package/dist/es2019/components/cell.js +18 -22
  14. package/dist/es2019/components/header.js +17 -21
  15. package/dist/es2019/components/headers.js +22 -19
  16. package/dist/es2019/components/internal/chevron.js +25 -35
  17. package/dist/es2019/components/internal/item.js +32 -36
  18. package/dist/es2019/components/internal/items.js +24 -60
  19. package/dist/es2019/components/internal/loader-item.js +29 -46
  20. package/dist/es2019/components/internal/with-column-width.js +2 -4
  21. package/dist/es2019/components/row.js +95 -147
  22. package/dist/es2019/components/rows.js +17 -17
  23. package/dist/es2019/components/table-tree.js +66 -90
  24. package/dist/esm/components/cell.js +19 -38
  25. package/dist/esm/components/header.js +17 -36
  26. package/dist/esm/components/headers.js +26 -40
  27. package/dist/esm/components/internal/chevron.js +29 -57
  28. package/dist/esm/components/internal/item.js +33 -53
  29. package/dist/esm/components/internal/items.js +32 -86
  30. package/dist/esm/components/internal/loader-item.js +33 -68
  31. package/dist/esm/components/internal/with-column-width.js +2 -4
  32. package/dist/esm/components/row.js +116 -179
  33. package/dist/esm/components/rows.js +17 -35
  34. package/dist/esm/components/table-tree.js +75 -121
  35. package/dist/types/components/header.d.ts +11 -1
  36. package/dist/types/components/headers.d.ts +13 -3
  37. package/dist/types/components/internal/chevron.d.ts +15 -13
  38. package/dist/types/components/internal/item.d.ts +24 -12
  39. package/dist/types/components/internal/items.d.ts +12 -23
  40. package/dist/types/components/internal/loader-item.d.ts +7 -16
  41. package/dist/types/components/row.d.ts +11 -39
  42. package/dist/types/components/rows.d.ts +15 -10
  43. package/dist/types/components/table-tree.d.ts +10 -20
  44. package/dist/types-ts4.5/components/header.d.ts +11 -1
  45. package/dist/types-ts4.5/components/headers.d.ts +13 -3
  46. package/dist/types-ts4.5/components/internal/chevron.d.ts +15 -13
  47. package/dist/types-ts4.5/components/internal/item.d.ts +24 -12
  48. package/dist/types-ts4.5/components/internal/items.d.ts +12 -23
  49. package/dist/types-ts4.5/components/internal/loader-item.d.ts +7 -16
  50. package/dist/types-ts4.5/components/row.d.ts +11 -39
  51. package/dist/types-ts4.5/components/rows.d.ts +15 -10
  52. package/dist/types-ts4.5/components/table-tree.d.ts +10 -20
  53. package/package.json +5 -9
@@ -1,21 +1,12 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- 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); }; }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
1
  /**
10
2
  * @jsxRuntime classic
11
3
  * @jsx jsx
12
4
  */
13
- import { Component } from 'react';
14
5
 
15
6
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
16
7
  import { css, jsx } from '@emotion/react';
17
8
  import { N300 } from '@atlaskit/theme/colors';
18
- import ColumnCell from './internal/common-cell';
9
+ import CommonCell from './internal/common-cell';
19
10
  import withColumnWidth from './internal/with-column-width';
20
11
  var headerStyles = css({
21
12
  color: "var(--ds-text-subtle, ".concat(N300, ")"),
@@ -31,32 +22,22 @@ var headerStyles = css({
31
22
  *
32
23
  * Defining it here for now lets us provide *something* without much headache.
33
24
  */
34
- var HeaderComponent = /*#__PURE__*/function (_Component) {
35
- _inherits(HeaderComponent, _Component);
36
- var _super = _createSuper(HeaderComponent);
37
- function HeaderComponent() {
38
- _classCallCheck(this, HeaderComponent);
39
- return _super.apply(this, arguments);
40
- }
41
- _createClass(HeaderComponent, [{
42
- key: "render",
43
- value: function render() {
44
- var props = this.props;
45
- return (
46
- // TODO: Determine whether proper `th` elements can be used instead of
47
- // roles (DSP-11588)
48
- jsx(ColumnCell, _extends({
49
- css: headerStyles,
50
- role: "columnheader",
51
- style: {
52
- width: props.width
53
- }
54
- }, props), props.children)
55
- );
56
- }
57
- }]);
58
- return HeaderComponent;
59
- }(Component);
25
+
26
+ var HeaderComponent = function HeaderComponent(_ref) {
27
+ var width = _ref.width,
28
+ children = _ref.children,
29
+ onClick = _ref.onClick,
30
+ id = _ref.id;
31
+ // TODO: Determine whether proper `th` elements can be used instead of
32
+ // roles (DSP-11588)
33
+ return jsx(CommonCell, {
34
+ css: headerStyles,
35
+ role: "columnheader",
36
+ width: width,
37
+ id: id,
38
+ onClick: onClick
39
+ }, children);
40
+ };
60
41
  var Header = withColumnWidth(HeaderComponent);
61
42
 
62
43
  // eslint-disable-next-line @repo/internal/react/require-jsdoc
@@ -1,16 +1,9 @@
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() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
8
1
  /**
9
2
  * @jsxRuntime classic
10
3
  * @jsx jsx
11
4
  */
12
5
  /* eslint-disable @repo/internal/react/no-clone-element */
13
- import { Children, cloneElement, Component } from 'react';
6
+ import { Children, cloneElement } from 'react';
14
7
 
15
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
16
9
  import { css, jsx } from '@emotion/react';
@@ -18,35 +11,28 @@ var containerStyles = css({
18
11
  display: 'flex',
19
12
  borderBlockEnd: "solid 2px ".concat("var(--ds-border, #dfe1e6)")
20
13
  });
21
- var Headers = /*#__PURE__*/function (_Component) {
22
- _inherits(Headers, _Component);
23
- var _super = _createSuper(Headers);
24
- function Headers() {
25
- _classCallCheck(this, Headers);
26
- return _super.apply(this, arguments);
27
- }
28
- _createClass(Headers, [{
29
- key: "render",
30
- value: function render() {
31
- return (
32
- // TODO: Determine whether proper `tr` elements can be used instead of
33
- // roles (DSP-11588)
34
- jsx("div", {
35
- css: containerStyles,
36
- role: "row"
37
- }, Children.map(this.props.children, function (header, index) {
38
- return (
39
- /*#__PURE__*/
40
- // eslint-disable-next-line react/no-array-index-key
41
- cloneElement(header, {
42
- key: index,
43
- columnIndex: index
44
- })
45
- );
46
- }))
47
- );
48
- }
49
- }]);
50
- return Headers;
51
- }(Component);
52
- export { Headers as default };
14
+ /**
15
+ * __Headers__
16
+ *
17
+ * Headers component for advanced composition of data, allowing custom data structures.
18
+ *
19
+ * - [Examples](https://atlassian.design/components/table-tree/examples#advanced)
20
+ * - [Code](https://atlassian.design/components/table-tree/code#headers-props)
21
+ */
22
+ var Headers = function Headers(_ref) {
23
+ var children = _ref.children;
24
+ return (
25
+ // TODO: Determine whether proper `tr` elements can be used instead of
26
+ // roles (DSP-11588)
27
+ jsx("div", {
28
+ css: containerStyles,
29
+ role: "row"
30
+ }, Children.map(children, function (header, index) {
31
+ return /*#__PURE__*/cloneElement(header, {
32
+ key: index,
33
+ columnIndex: index
34
+ });
35
+ }))
36
+ );
37
+ };
38
+ export default Headers;
@@ -1,63 +1,35 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- 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); }; }
9
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
1
  /* eslint-disable @repo/internal/react/consistent-props-definitions */
11
2
  /* eslint-disable react/prop-types */
12
- import React, { Component } from 'react';
3
+ import React from 'react';
13
4
  import { IconButton } from '@atlaskit/button/new';
5
+ import __noop from '@atlaskit/ds-lib/noop';
14
6
  import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
15
7
  import ChevronRightIcon from '@atlaskit/icon/glyph/chevron-right';
16
8
  import { ChevronContainer } from './styled';
17
- var Chevron = /*#__PURE__*/function (_Component) {
18
- _inherits(Chevron, _Component);
19
- var _super = _createSuper(Chevron);
20
- function Chevron() {
21
- var _this;
22
- _classCallCheck(this, Chevron);
23
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24
- args[_key] = arguments[_key];
25
- }
26
- _this = _super.call.apply(_super, [this].concat(args));
27
- _defineProperty(_assertThisInitialized(_this), "handleClick", function () {
28
- if (_this.props.onExpandToggle) {
29
- _this.props.onExpandToggle();
30
- }
31
- });
32
- return _this;
33
- }
34
- _createClass(Chevron, [{
35
- key: "render",
36
- value: function render() {
37
- var _this$props = this.props,
38
- isExpanded = _this$props.isExpanded,
39
- ariaControls = _this$props.ariaControls,
40
- collapseLabel = _this$props.collapseLabel,
41
- expandLabel = _this$props.expandLabel,
42
- rowId = _this$props.rowId,
43
- extendedLabel = _this$props.extendedLabel;
44
- var getLabel = function getLabel(defaultLabel) {
45
- return extendedLabel ? "".concat(defaultLabel, " ").concat(extendedLabel, " row") : "".concat(defaultLabel, " row ").concat(rowId);
46
- };
47
- return /*#__PURE__*/React.createElement(ChevronContainer, null, /*#__PURE__*/React.createElement(IconButton, {
48
- appearance: "subtle",
49
- onClick: this.handleClick,
50
- spacing: "compact",
51
- icon: isExpanded ? ChevronDownIcon : ChevronRightIcon,
52
- "aria-controls": ariaControls,
53
- label: isExpanded ? getLabel(collapseLabel) : getLabel(expandLabel)
54
- }));
55
- }
56
- }]);
57
- return Chevron;
58
- }(Component);
59
- _defineProperty(Chevron, "defaultProps", {
60
- expandLabel: 'Expand',
61
- collapseLabel: 'Collapse'
62
- });
63
- export { Chevron as default };
9
+ /**
10
+ * Internal chevron component.
11
+ */
12
+ var Chevron = function Chevron(_ref) {
13
+ var isExpanded = _ref.isExpanded,
14
+ ariaControls = _ref.ariaControls,
15
+ _ref$collapseLabel = _ref.collapseLabel,
16
+ collapseLabel = _ref$collapseLabel === void 0 ? 'Collapse' : _ref$collapseLabel,
17
+ _ref$expandLabel = _ref.expandLabel,
18
+ expandLabel = _ref$expandLabel === void 0 ? 'Expand' : _ref$expandLabel,
19
+ rowId = _ref.rowId,
20
+ extendedLabel = _ref.extendedLabel,
21
+ _ref$onExpandToggle = _ref.onExpandToggle,
22
+ onExpandToggle = _ref$onExpandToggle === void 0 ? __noop : _ref$onExpandToggle;
23
+ var getLabel = function getLabel(defaultLabel) {
24
+ return extendedLabel ? "".concat(defaultLabel, " ").concat(extendedLabel, " row") : "".concat(defaultLabel, " row ").concat(rowId);
25
+ };
26
+ return /*#__PURE__*/React.createElement(ChevronContainer, null, /*#__PURE__*/React.createElement(IconButton, {
27
+ appearance: "subtle",
28
+ onClick: onExpandToggle,
29
+ spacing: "compact",
30
+ icon: isExpanded ? ChevronDownIcon : ChevronRightIcon,
31
+ "aria-controls": ariaControls,
32
+ label: isExpanded ? getLabel(collapseLabel) : getLabel(expandLabel)
33
+ }));
34
+ };
35
+ export default Chevron;
@@ -1,66 +1,46 @@
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
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- 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); }; }
8
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
9
1
  /**
10
2
  * @jsxRuntime classic
11
3
  * @jsx jsx
12
4
  */
13
5
  /* eslint-disable @repo/internal/react/no-clone-element */
14
- import { cloneElement, Component } from 'react';
6
+ import { cloneElement } from 'react';
15
7
 
16
8
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
17
9
  import { jsx } from '@emotion/react';
18
10
  import toItemId from '../../utils/to-item-id';
19
11
  import Items from './items';
20
- var Item = /*#__PURE__*/function (_Component) {
21
- _inherits(Item, _Component);
22
- var _super = _createSuper(Item);
23
- function Item() {
24
- _classCallCheck(this, Item);
25
- return _super.apply(this, arguments);
12
+ /**
13
+ * __Item__
14
+ * Internal item component.
15
+ */
16
+ function Item(_ref) {
17
+ var _ref$depth = _ref.depth,
18
+ depth = _ref$depth === void 0 ? 0 : _ref$depth,
19
+ data = _ref.data,
20
+ render = _ref.render,
21
+ loadingLabel = _ref.loadingLabel;
22
+ var renderedRow = render(data);
23
+ if (!renderedRow) {
24
+ return null;
26
25
  }
27
- _createClass(Item, [{
28
- key: "render",
29
- value: function render() {
30
- // eslint-disable-next-line react/prop-types
31
- var _this$props = this.props,
32
- depth = _this$props.depth,
33
- data = _this$props.data,
34
- render = _this$props.render,
35
- loadingLabel = _this$props.loadingLabel;
36
- var renderedRow = render(data);
37
- if (!renderedRow) {
38
- return null;
39
- }
40
- var _renderedRow$props = renderedRow.props,
41
- itemId = _renderedRow$props.itemId,
42
- items = _renderedRow$props.items;
43
- return /*#__PURE__*/cloneElement(renderedRow, {
26
+
27
+ // itemId exists on RowProps, but not on RowsProps
28
+ var itemId = 'itemId' in renderedRow.props ? renderedRow.props.itemId : undefined;
29
+ var items = renderedRow.props.items;
30
+ return /*#__PURE__*/cloneElement(renderedRow, {
31
+ depth: depth,
32
+ data: data,
33
+ loadingLabel: loadingLabel,
34
+ renderChildren: function renderChildren() {
35
+ return jsx("div", {
36
+ id: !!itemId ? toItemId(itemId) : undefined
37
+ }, jsx(Items, {
44
38
  depth: depth,
45
- data: data,
46
- loadingLabel: loadingLabel,
47
- renderChildren: function renderChildren() {
48
- return jsx("div", {
49
- id: toItemId(itemId)
50
- }, jsx(Items, {
51
- parentData: data,
52
- depth: depth,
53
- items: items,
54
- render: render,
55
- loadingLabel: loadingLabel
56
- }));
57
- }
58
- });
39
+ items: items,
40
+ render: render,
41
+ loadingLabel: loadingLabel
42
+ }));
59
43
  }
60
- }]);
61
- return Item;
62
- }(Component);
63
- _defineProperty(Item, "defaultProps", {
64
- depth: 0
65
- });
66
- export { Item as default };
44
+ });
45
+ }
46
+ export default Item;
@@ -1,89 +1,35 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- 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); }; }
9
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
- /* eslint-disable react/prop-types */
11
- import React, { Component } from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useState } from 'react';
12
3
  import Item from './item';
13
4
  import LoaderItem from './loader-item';
14
- var Items = /*#__PURE__*/function (_Component) {
15
- _inherits(Items, _Component);
16
- var _super = _createSuper(Items);
17
- function Items() {
18
- var _this;
19
- _classCallCheck(this, Items);
20
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
21
- args[_key] = arguments[_key];
22
- }
23
- _this = _super.call.apply(_super, [this].concat(args));
24
- _defineProperty(_assertThisInitialized(_this), "state", {
25
- isLoaderShown: false
5
+ function Items(_ref) {
6
+ var _ref$depth = _ref.depth,
7
+ depth = _ref$depth === void 0 ? 0 : _ref$depth,
8
+ items = _ref.items,
9
+ loadingLabel = _ref.loadingLabel,
10
+ render = _ref.render;
11
+ var _useState = useState(false),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ isLoaderShown = _useState2[0],
14
+ setIsLoaderShown = _useState2[1];
15
+ var handleLoaderComplete = function handleLoaderComplete() {
16
+ return setIsLoaderShown(false);
17
+ };
18
+ return !items || isLoaderShown ? /*#__PURE__*/React.createElement(LoaderItem, {
19
+ isCompleting: !!(items && items.length),
20
+ onComplete: handleLoaderComplete,
21
+ depth: depth + 1,
22
+ loadingLabel: loadingLabel
23
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, items.map(function (data) {
24
+ return /*#__PURE__*/React.createElement(Item, {
25
+ data: data,
26
+ depth: depth + 1,
27
+ key: data.id,
28
+ render: render,
29
+ loadingLabel: loadingLabel
26
30
  });
27
- _defineProperty(_assertThisInitialized(_this), "handleLoaderComplete", function () {
28
- _this.setState({
29
- isLoaderShown: false
30
- });
31
- });
32
- return _this;
33
- }
34
- _createClass(Items, [{
35
- key: "renderLoader",
36
- value: function renderLoader() {
37
- var _this$props = this.props,
38
- depth = _this$props.depth,
39
- items = _this$props.items,
40
- loadingLabel = _this$props.loadingLabel;
41
- return /*#__PURE__*/React.createElement(LoaderItem, {
42
- isCompleting: !!(items && items.length),
43
- onComplete: this.handleLoaderComplete,
44
- depth: depth + 1,
45
- loadingLabel: loadingLabel
46
- });
47
- }
48
- }, {
49
- key: "renderItems",
50
- value: function renderItems() {
51
- var _this$props2 = this.props,
52
- render = _this$props2.render,
53
- items = _this$props2.items,
54
- loadingLabel = _this$props2.loadingLabel,
55
- _this$props2$depth = _this$props2.depth,
56
- depth = _this$props2$depth === void 0 ? 0 : _this$props2$depth;
57
- return items && items.map(function (itemData, index) {
58
- return /*#__PURE__*/React.createElement(Item, {
59
- data: itemData,
60
- depth: depth + 1,
61
- key: itemData && itemData.id || index,
62
- render: render,
63
- loadingLabel: loadingLabel
64
- });
65
- });
66
- }
67
- }, {
68
- key: "render",
69
- value: function render() {
70
- var isLoaderShown = this.state.isLoaderShown;
71
- return isLoaderShown ? this.renderLoader() : this.renderItems();
72
- }
73
- }], [{
74
- key: "getDerivedStateFromProps",
75
- value: function getDerivedStateFromProps(nextProps, prevState) {
76
- if (!nextProps.items && !prevState.isLoaderShown) {
77
- return {
78
- isLoaderShown: true
79
- };
80
- }
81
- return null;
82
- }
83
- }]);
84
- return Items;
85
- }(Component);
86
- _defineProperty(Items, "defaultProps", {
87
- depth: 0
88
- });
89
- export { Items as default };
31
+ }));
32
+ }
33
+
34
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
35
+ export default Items;
@@ -1,73 +1,38 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- 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); }; }
9
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
10
2
  /* eslint-disable react/prop-types */
11
- import React, { Component } from 'react';
3
+ import React, { useEffect, useState } from 'react';
12
4
  import Spinner from '@atlaskit/spinner';
13
5
  import CommonCell from './common-cell';
14
6
  import { indentBase, LoaderItemContainer, TreeRowContainer } from './styled';
15
- var LoaderItem = /*#__PURE__*/function (_Component) {
16
- _inherits(LoaderItem, _Component);
17
- var _super = _createSuper(LoaderItem);
18
- function LoaderItem() {
19
- var _this;
20
- _classCallCheck(this, LoaderItem);
21
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
22
- args[_key] = arguments[_key];
7
+ var LoaderItem = function LoaderItem(_ref) {
8
+ var _ref$depth = _ref.depth,
9
+ depth = _ref$depth === void 0 ? 1 : _ref$depth,
10
+ loadingLabel = _ref.loadingLabel,
11
+ isCompleting = _ref.isCompleting,
12
+ onComplete = _ref.onComplete;
13
+ var _useState = useState('loading'),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ phase = _useState2[0],
16
+ setPhase = _useState2[1];
17
+ useEffect(function () {
18
+ if (phase === 'loading' && isCompleting) {
19
+ setPhase(function () {
20
+ onComplete();
21
+ return 'complete';
22
+ });
23
23
  }
24
- _this = _super.call.apply(_super, [this].concat(args));
25
- _defineProperty(_assertThisInitialized(_this), "state", {
26
- phase: 'loading'
27
- });
28
- return _this;
29
- }
30
- _createClass(LoaderItem, [{
31
- key: "componentDidUpdate",
32
- value: function componentDidUpdate(prevProps, prevState) {
33
- if (prevState.phase === 'loading' && this.state.phase === 'complete') {
34
- if (this.props.onComplete) {
35
- this.props.onComplete();
36
- }
37
- }
38
- }
39
- }, {
40
- key: "render",
41
- value: function render() {
42
- var _this$props = this.props,
43
- depth = _this$props.depth,
44
- loadingLabel = _this$props.loadingLabel;
45
- var phase = this.state.phase;
46
- return phase === 'loading' ? /*#__PURE__*/React.createElement(TreeRowContainer, null, /*#__PURE__*/React.createElement(CommonCell, {
47
- indent: "calc(".concat(indentBase, " * ").concat(depth, ")"),
48
- width: "100%"
49
- }, /*#__PURE__*/React.createElement(LoaderItemContainer, {
50
- isRoot: depth === 1
51
- }, /*#__PURE__*/React.createElement(Spinner, {
52
- size: "small",
53
- testId: "table-tree-spinner",
54
- label: loadingLabel
55
- })))) : null;
56
- }
57
- }], [{
58
- key: "getDerivedStateFromProps",
59
- value: function getDerivedStateFromProps(nextProps, prevState) {
60
- if (nextProps.isCompleting && prevState.phase === 'loading') {
61
- return {
62
- phase: 'complete'
63
- };
64
- }
65
- return null;
66
- }
67
- }]);
68
- return LoaderItem;
69
- }(Component);
70
- _defineProperty(LoaderItem, "defaultProps", {
71
- depth: 1
72
- });
73
- export { LoaderItem as default };
24
+ }, [isCompleting, onComplete, phase]);
25
+ return phase === 'loading' ? /*#__PURE__*/React.createElement(TreeRowContainer, null, /*#__PURE__*/React.createElement(CommonCell, {
26
+ indent: "calc(".concat(indentBase, " * ").concat(depth, ")"),
27
+ width: "100%"
28
+ }, /*#__PURE__*/React.createElement(LoaderItemContainer, {
29
+ isRoot: depth === 1
30
+ }, /*#__PURE__*/React.createElement(Spinner, {
31
+ size: "small",
32
+ testId: "table-tree-spinner",
33
+ label: loadingLabel
34
+ })))) : null;
35
+ };
36
+
37
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
38
+ export default LoaderItem;
@@ -19,10 +19,8 @@ export default function withColumnWidth(Cell) {
19
19
  var columnWidth;
20
20
  if (width !== null && width !== undefined) {
21
21
  columnWidth = width;
22
- } else {
23
- if (columnIndex !== undefined) {
24
- columnWidth = getColumnWidth(columnIndex);
25
- }
22
+ } else if (columnIndex !== undefined) {
23
+ columnWidth = getColumnWidth(columnIndex);
26
24
  }
27
25
  return /*#__PURE__*/React.createElement(Cell, _extends({
28
26
  width: columnWidth