@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.
- package/CHANGELOG.md +10 -0
- package/dist/cjs/components/cell.js +19 -41
- package/dist/cjs/components/header.js +23 -38
- package/dist/cjs/components/headers.js +31 -40
- package/dist/cjs/components/internal/chevron.js +32 -59
- package/dist/cjs/components/internal/item.js +38 -52
- package/dist/cjs/components/internal/items.js +31 -83
- package/dist/cjs/components/internal/loader-item.js +34 -66
- package/dist/cjs/components/internal/with-column-width.js +2 -4
- package/dist/cjs/components/row.js +120 -177
- package/dist/cjs/components/rows.js +17 -37
- package/dist/cjs/components/table-tree.js +75 -119
- package/dist/es2019/components/cell.js +18 -22
- package/dist/es2019/components/header.js +17 -21
- package/dist/es2019/components/headers.js +22 -19
- package/dist/es2019/components/internal/chevron.js +25 -35
- package/dist/es2019/components/internal/item.js +32 -36
- package/dist/es2019/components/internal/items.js +24 -60
- package/dist/es2019/components/internal/loader-item.js +29 -46
- package/dist/es2019/components/internal/with-column-width.js +2 -4
- package/dist/es2019/components/row.js +95 -147
- package/dist/es2019/components/rows.js +17 -17
- package/dist/es2019/components/table-tree.js +66 -90
- package/dist/esm/components/cell.js +19 -38
- package/dist/esm/components/header.js +17 -36
- package/dist/esm/components/headers.js +26 -40
- package/dist/esm/components/internal/chevron.js +29 -57
- package/dist/esm/components/internal/item.js +33 -53
- package/dist/esm/components/internal/items.js +32 -86
- package/dist/esm/components/internal/loader-item.js +33 -68
- package/dist/esm/components/internal/with-column-width.js +2 -4
- package/dist/esm/components/row.js +116 -179
- package/dist/esm/components/rows.js +17 -35
- package/dist/esm/components/table-tree.js +75 -121
- package/dist/types/components/header.d.ts +11 -1
- package/dist/types/components/headers.d.ts +13 -3
- package/dist/types/components/internal/chevron.d.ts +15 -13
- package/dist/types/components/internal/item.d.ts +24 -12
- package/dist/types/components/internal/items.d.ts +12 -23
- package/dist/types/components/internal/loader-item.d.ts +7 -16
- package/dist/types/components/row.d.ts +11 -39
- package/dist/types/components/rows.d.ts +15 -10
- package/dist/types/components/table-tree.d.ts +10 -20
- package/dist/types-ts4.5/components/header.d.ts +11 -1
- package/dist/types-ts4.5/components/headers.d.ts +13 -3
- package/dist/types-ts4.5/components/internal/chevron.d.ts +15 -13
- package/dist/types-ts4.5/components/internal/item.d.ts +24 -12
- package/dist/types-ts4.5/components/internal/items.d.ts +12 -23
- package/dist/types-ts4.5/components/internal/loader-item.d.ts +7 -16
- package/dist/types-ts4.5/components/row.d.ts +11 -39
- package/dist/types-ts4.5/components/rows.d.ts +15 -10
- package/dist/types-ts4.5/components/table-tree.d.ts +10 -20
- 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
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
62
|
-
|
|
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
|
|
2
|
-
import
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
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, {
|
|
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 =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|