@atlaskit/table-tree 9.2.7 → 9.2.9
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 +12 -0
- package/dist/cjs/components/cell.js +6 -31
- package/dist/cjs/components/header.js +0 -21
- package/dist/cjs/components/headers.js +0 -16
- package/dist/cjs/components/internal/chevron.js +4 -31
- package/dist/cjs/components/internal/common-cell.js +2 -11
- package/dist/cjs/components/internal/item.js +5 -25
- package/dist/cjs/components/internal/items.js +6 -32
- package/dist/cjs/components/internal/loader-item.js +0 -26
- package/dist/cjs/components/internal/overflow-container.js +4 -9
- package/dist/cjs/components/internal/styled.js +13 -20
- package/dist/cjs/components/internal/with-column-width.js +3 -25
- package/dist/cjs/components/row.js +7 -46
- package/dist/cjs/components/rows.js +2 -20
- package/dist/cjs/components/table-tree.js +10 -45
- package/dist/cjs/index.js +0 -8
- package/dist/cjs/utils/table-tree-data-helper.js +20 -50
- package/dist/cjs/utils/to-item-id.js +0 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/cell.js +0 -3
- package/dist/es2019/components/header.js +0 -4
- package/dist/es2019/components/headers.js +0 -2
- package/dist/es2019/components/internal/chevron.js +0 -6
- package/dist/es2019/components/internal/common-cell.js +1 -3
- package/dist/es2019/components/internal/item.js +0 -6
- package/dist/es2019/components/internal/items.js +0 -10
- package/dist/es2019/components/internal/loader-item.js +0 -8
- package/dist/es2019/components/internal/overflow-container.js +4 -4
- package/dist/es2019/components/internal/styled.js +13 -10
- package/dist/es2019/components/internal/with-column-width.js +0 -6
- package/dist/es2019/components/row.js +1 -19
- package/dist/es2019/components/rows.js +0 -1
- package/dist/es2019/components/table-tree.js +2 -14
- package/dist/es2019/utils/table-tree-data-helper.js +9 -19
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/cell.js +6 -17
- package/dist/esm/components/header.js +0 -10
- package/dist/esm/components/headers.js +0 -11
- package/dist/esm/components/internal/chevron.js +4 -20
- package/dist/esm/components/internal/common-cell.js +3 -6
- package/dist/esm/components/internal/item.js +5 -19
- package/dist/esm/components/internal/items.js +6 -23
- package/dist/esm/components/internal/loader-item.js +0 -16
- package/dist/esm/components/internal/overflow-container.js +5 -6
- package/dist/esm/components/internal/styled.js +14 -12
- package/dist/esm/components/internal/with-column-width.js +3 -13
- package/dist/esm/components/row.js +7 -31
- package/dist/esm/components/rows.js +2 -12
- package/dist/esm/components/table-tree.js +10 -32
- package/dist/esm/utils/table-tree-data-helper.js +20 -48
- package/dist/esm/version.json +1 -1
- package/package.json +5 -4
- package/report.api.md +14 -1
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["isSingleLine"];
|
|
4
|
-
|
|
5
4
|
/** @jsx jsx */
|
|
5
|
+
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
var overflowContainerStyles = css({
|
|
8
8
|
overflow: 'hidden',
|
|
9
9
|
textOverflow: 'ellipsis',
|
|
10
10
|
whiteSpace: 'nowrap'
|
|
11
11
|
});
|
|
12
|
+
|
|
12
13
|
/**
|
|
13
14
|
* __Overflow container__
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
16
|
var OverflowContainer = function OverflowContainer(_ref) {
|
|
17
17
|
var isSingleLine = _ref.isSingleLine,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
return (
|
|
20
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
21
21
|
jsx("span", _extends({
|
|
22
22
|
css: isSingleLine && overflowContainerStyles
|
|
23
23
|
}, props))
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
|
-
|
|
27
26
|
export default OverflowContainer;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
var _excluded = ["isRoot"];
|
|
4
|
-
|
|
5
4
|
/** @jsx jsx */
|
|
5
|
+
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { N30, N800 } from '@atlaskit/theme/colors';
|
|
8
8
|
export var iconColor = "var(--ds-text, ".concat(N800, ")");
|
|
@@ -11,12 +11,13 @@ var treeRowContainerStyles = css({
|
|
|
11
11
|
display: 'flex',
|
|
12
12
|
borderBottom: "1px solid ".concat("var(--ds-border, ".concat(N30, ")"))
|
|
13
13
|
});
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* __Tree row container__
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
18
|
export var TreeRowContainer = function TreeRowContainer(props) {
|
|
19
|
-
return (
|
|
19
|
+
return (
|
|
20
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
20
21
|
jsx("div", _extends({
|
|
21
22
|
css: treeRowContainerStyles
|
|
22
23
|
}, props))
|
|
@@ -30,11 +31,12 @@ var commonChevronContainerStyles = css({
|
|
|
30
31
|
top: 7,
|
|
31
32
|
alignItems: 'center'
|
|
32
33
|
});
|
|
34
|
+
|
|
33
35
|
/**
|
|
34
36
|
* __Chevron container__
|
|
35
37
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
export var ChevronContainer = function ChevronContainer(props
|
|
39
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
38
40
|
) {
|
|
39
41
|
return jsx("span", _extends({}, props, {
|
|
40
42
|
css: commonChevronContainerStyles
|
|
@@ -44,13 +46,14 @@ var chevronIconContainerStyles = css({
|
|
|
44
46
|
position: 'relative',
|
|
45
47
|
top: 1
|
|
46
48
|
});
|
|
49
|
+
|
|
47
50
|
/**
|
|
48
51
|
* __Chevron icon container__
|
|
49
52
|
*
|
|
50
53
|
* A chevron icon container.
|
|
51
54
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
export var ChevronIconContainer = function ChevronIconContainer(props
|
|
56
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
54
57
|
) {
|
|
55
58
|
return jsx("span", _extends({}, props, {
|
|
56
59
|
css: chevronIconContainerStyles
|
|
@@ -65,18 +68,17 @@ var paddingLeftStyles = css({
|
|
|
65
68
|
// eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage-spacing
|
|
66
69
|
paddingLeft: '50%'
|
|
67
70
|
});
|
|
71
|
+
|
|
68
72
|
/**
|
|
69
73
|
* __Loader item container__
|
|
70
74
|
*
|
|
71
75
|
* A loader item container.
|
|
72
76
|
*/
|
|
73
|
-
|
|
74
77
|
export var LoaderItemContainer = function LoaderItemContainer(_ref) {
|
|
75
78
|
var isRoot = _ref.isRoot,
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
78
80
|
return jsx("span", _extends({
|
|
79
|
-
css: [commonChevronContainerStyles, loadingItemContainerStyles, isRoot && paddingLeftStyles]
|
|
80
|
-
|
|
81
|
+
css: [commonChevronContainerStyles, loadingItemContainerStyles, isRoot && paddingLeftStyles]
|
|
82
|
+
// eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
|
|
81
83
|
}, props));
|
|
82
84
|
};
|
|
@@ -7,28 +7,20 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
var _excluded = ["width", "columnIndex"];
|
|
10
|
-
|
|
11
10
|
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); }; }
|
|
12
|
-
|
|
13
11
|
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; } }
|
|
14
|
-
|
|
15
12
|
/* eslint-disable react/prop-types */
|
|
16
13
|
import React, { Component } from 'react';
|
|
17
14
|
import PropTypes from 'prop-types';
|
|
18
15
|
export default function withColumnWidth(Cell) {
|
|
19
16
|
var _class;
|
|
20
|
-
|
|
21
17
|
return _class = /*#__PURE__*/function (_Component) {
|
|
22
18
|
_inherits(CellWithColumnWidth, _Component);
|
|
23
|
-
|
|
24
19
|
var _super = _createSuper(CellWithColumnWidth);
|
|
25
|
-
|
|
26
20
|
function CellWithColumnWidth() {
|
|
27
21
|
_classCallCheck(this, CellWithColumnWidth);
|
|
28
|
-
|
|
29
22
|
return _super.apply(this, arguments);
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
_createClass(CellWithColumnWidth, [{
|
|
33
25
|
key: "UNSAFE_componentWillMount",
|
|
34
26
|
value: function UNSAFE_componentWillMount() {
|
|
@@ -50,17 +42,15 @@ export default function withColumnWidth(Cell) {
|
|
|
50
42
|
key: "render",
|
|
51
43
|
value: function render() {
|
|
52
44
|
var _this$props = this.props,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
width = _this$props.width,
|
|
46
|
+
columnIndex = _this$props.columnIndex,
|
|
47
|
+
other = _objectWithoutProperties(_this$props, _excluded);
|
|
57
48
|
var columnWidth = width !== null && width !== undefined ? width : this.context.tableTree.getColumnWidth(columnIndex);
|
|
58
49
|
return /*#__PURE__*/React.createElement(Cell, _extends({
|
|
59
50
|
width: columnWidth
|
|
60
51
|
}, other));
|
|
61
52
|
}
|
|
62
53
|
}]);
|
|
63
|
-
|
|
64
54
|
return CellWithColumnWidth;
|
|
65
55
|
}(Component), _defineProperty(_class, "contextTypes", {
|
|
66
56
|
tableTree: PropTypes.object.isRequired
|
|
@@ -6,11 +6,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
9
|
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); }; }
|
|
11
|
-
|
|
12
10
|
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; } }
|
|
13
|
-
|
|
14
11
|
/* eslint-disable @repo/internal/react/no-clone-element */
|
|
15
12
|
import React, { Component, Fragment } from 'react';
|
|
16
13
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
@@ -18,52 +15,39 @@ import toItemId from '../utils/to-item-id';
|
|
|
18
15
|
import Chevron from './internal/chevron';
|
|
19
16
|
import { TreeRowContainer } from './internal/styled';
|
|
20
17
|
var packageName = "@atlaskit/table-tree";
|
|
21
|
-
var packageVersion = "9.2.
|
|
22
|
-
|
|
18
|
+
var packageVersion = "9.2.9";
|
|
23
19
|
var Row = /*#__PURE__*/function (_Component) {
|
|
24
20
|
_inherits(Row, _Component);
|
|
25
|
-
|
|
26
21
|
var _super = _createSuper(Row);
|
|
27
|
-
|
|
28
22
|
function Row() {
|
|
29
23
|
var _this;
|
|
30
|
-
|
|
31
24
|
_classCallCheck(this, Row);
|
|
32
|
-
|
|
33
25
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
34
26
|
args[_key] = arguments[_key];
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
38
|
-
|
|
39
29
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
40
30
|
isExpanded: _this.props.isDefaultExpanded || false
|
|
41
31
|
});
|
|
42
|
-
|
|
43
32
|
_defineProperty(_assertThisInitialized(_this), "onExpandToggle", function () {
|
|
44
33
|
var isExpanded = _this.props.isExpanded;
|
|
45
|
-
|
|
46
34
|
if (isExpanded !== undefined) {
|
|
47
35
|
_this.onExpandStateChange(!isExpanded);
|
|
48
36
|
} else {
|
|
49
37
|
_this.setState({
|
|
50
38
|
isExpanded: !_this.state.isExpanded
|
|
51
39
|
});
|
|
52
|
-
|
|
53
40
|
_this.onExpandStateChange(!_this.state.isExpanded);
|
|
54
41
|
}
|
|
55
42
|
});
|
|
56
|
-
|
|
57
43
|
return _this;
|
|
58
44
|
}
|
|
59
|
-
|
|
60
45
|
_createClass(Row, [{
|
|
61
46
|
key: "componentDidUpdate",
|
|
62
47
|
value: function componentDidUpdate(prevProps) {
|
|
63
48
|
var _this$props = this.props,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
49
|
+
isDefaultExpanded = _this$props.isDefaultExpanded,
|
|
50
|
+
isExpanded = _this$props.isExpanded;
|
|
67
51
|
if (isExpanded === undefined && isDefaultExpanded !== undefined && prevProps.isDefaultExpanded !== isDefaultExpanded && this.state.isExpanded !== isDefaultExpanded) {
|
|
68
52
|
// eslint-disable-next-line react/no-did-update-set-state
|
|
69
53
|
this.setState({
|
|
@@ -94,11 +78,10 @@ var Row = /*#__PURE__*/function (_Component) {
|
|
|
94
78
|
var props = this.props;
|
|
95
79
|
var isExpanded = this.isExpanded();
|
|
96
80
|
var hasChildren = props.hasChildren,
|
|
97
|
-
|
|
81
|
+
depth = props.depth;
|
|
98
82
|
var isFirstCell = cellIndex === 0;
|
|
99
83
|
var indentLevel = isFirstCell ? depth : 0;
|
|
100
84
|
var cellContent = cell.props.children || [];
|
|
101
|
-
|
|
102
85
|
if (isFirstCell && hasChildren) {
|
|
103
86
|
cellContent = [/*#__PURE__*/React.createElement(Chevron, {
|
|
104
87
|
key: "chevron",
|
|
@@ -109,7 +92,6 @@ var Row = /*#__PURE__*/function (_Component) {
|
|
|
109
92
|
ariaControls: toItemId(props.itemId)
|
|
110
93
|
})].concat(cellContent);
|
|
111
94
|
}
|
|
112
|
-
|
|
113
95
|
return /*#__PURE__*/React.cloneElement(cell, {
|
|
114
96
|
key: cellIndex,
|
|
115
97
|
columnIndex: cellIndex,
|
|
@@ -120,22 +102,18 @@ var Row = /*#__PURE__*/function (_Component) {
|
|
|
120
102
|
key: "render",
|
|
121
103
|
value: function render() {
|
|
122
104
|
var _this2 = this;
|
|
123
|
-
|
|
124
105
|
var _this$props2 = this.props,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
106
|
+
hasChildren = _this$props2.hasChildren,
|
|
107
|
+
depth = _this$props2.depth,
|
|
108
|
+
renderChildren = _this$props2.renderChildren;
|
|
128
109
|
var isExpanded = this.isExpanded();
|
|
129
110
|
var ariaAttrs = {};
|
|
130
|
-
|
|
131
111
|
if (hasChildren) {
|
|
132
112
|
ariaAttrs['aria-expanded'] = isExpanded;
|
|
133
113
|
}
|
|
134
|
-
|
|
135
114
|
if (depth !== undefined) {
|
|
136
115
|
ariaAttrs['aria-level'] = depth;
|
|
137
116
|
}
|
|
138
|
-
|
|
139
117
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(TreeRowContainer, _extends({
|
|
140
118
|
role: "row"
|
|
141
119
|
}, ariaAttrs), React.Children.map(this.props.children, function (cell, index) {
|
|
@@ -143,10 +121,8 @@ var Row = /*#__PURE__*/function (_Component) {
|
|
|
143
121
|
})), hasChildren && isExpanded && renderChildren && renderChildren());
|
|
144
122
|
}
|
|
145
123
|
}]);
|
|
146
|
-
|
|
147
124
|
return Row;
|
|
148
125
|
}(Component);
|
|
149
|
-
|
|
150
126
|
export { Row as RowWithoutAnalytics };
|
|
151
127
|
var createAndFireEventOnAtlaskit = createAndFireEvent('atlaskit');
|
|
152
128
|
export default withAnalyticsContext({
|
|
@@ -3,39 +3,29 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
4
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
5
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
-
|
|
7
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); }; }
|
|
8
|
-
|
|
9
7
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
10
|
-
|
|
11
8
|
import React, { Component } from 'react';
|
|
12
9
|
import Items from './internal/items';
|
|
13
|
-
|
|
14
10
|
var Rows = /*#__PURE__*/function (_Component) {
|
|
15
11
|
_inherits(Rows, _Component);
|
|
16
|
-
|
|
17
12
|
var _super = _createSuper(Rows);
|
|
18
|
-
|
|
19
13
|
function Rows() {
|
|
20
14
|
_classCallCheck(this, Rows);
|
|
21
|
-
|
|
22
15
|
return _super.apply(this, arguments);
|
|
23
16
|
}
|
|
24
|
-
|
|
25
17
|
_createClass(Rows, [{
|
|
26
18
|
key: "render",
|
|
27
19
|
value: function render() {
|
|
28
20
|
var _this$props = this.props,
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
items = _this$props.items,
|
|
22
|
+
render = _this$props.render;
|
|
31
23
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Items, {
|
|
32
24
|
items: items,
|
|
33
25
|
render: render
|
|
34
26
|
}));
|
|
35
27
|
}
|
|
36
28
|
}]);
|
|
37
|
-
|
|
38
29
|
return Rows;
|
|
39
30
|
}(Component);
|
|
40
|
-
|
|
41
31
|
export { Rows as default };
|
|
@@ -5,11 +5,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
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); }; }
|
|
10
|
-
|
|
11
9
|
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; } }
|
|
12
|
-
|
|
13
10
|
/* eslint-disable react/prop-types */
|
|
14
11
|
import React, { Component } from 'react';
|
|
15
12
|
import PropTypes from 'prop-types';
|
|
@@ -18,53 +15,38 @@ import Header from './header';
|
|
|
18
15
|
import Headers from './headers';
|
|
19
16
|
import Row from './row';
|
|
20
17
|
import Rows from './rows';
|
|
21
|
-
|
|
22
18
|
var TableTree = /*#__PURE__*/function (_Component) {
|
|
23
19
|
_inherits(TableTree, _Component);
|
|
24
|
-
|
|
25
20
|
var _super = _createSuper(TableTree);
|
|
26
|
-
|
|
27
21
|
function TableTree() {
|
|
28
22
|
var _this;
|
|
29
|
-
|
|
30
23
|
_classCallCheck(this, TableTree);
|
|
31
|
-
|
|
32
24
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
25
|
args[_key] = arguments[_key];
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
37
|
-
|
|
38
28
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
39
29
|
columnWidths: []
|
|
40
30
|
});
|
|
41
|
-
|
|
42
31
|
_defineProperty(_assertThisInitialized(_this), "setColumnWidth", function (columnIndex, width) {
|
|
43
32
|
var columnWidths = _this.state.columnWidths;
|
|
44
|
-
|
|
45
33
|
if (width === columnWidths[columnIndex]) {
|
|
46
34
|
return;
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
columnWidths[columnIndex] = width;
|
|
50
|
-
|
|
51
37
|
_this.setState({
|
|
52
38
|
columnWidths: columnWidths
|
|
53
39
|
});
|
|
54
40
|
});
|
|
55
|
-
|
|
56
41
|
_defineProperty(_assertThisInitialized(_this), "getColumnWidth", function (columnIndex) {
|
|
57
42
|
return _this.state && _this.state.columnWidths[columnIndex] || null;
|
|
58
43
|
});
|
|
59
|
-
|
|
60
44
|
return _this;
|
|
61
45
|
}
|
|
62
|
-
|
|
63
46
|
_createClass(TableTree, [{
|
|
64
47
|
key: "componentDidMount",
|
|
65
48
|
value: function componentDidMount() {
|
|
66
49
|
var widths = this.props.columnWidths;
|
|
67
|
-
|
|
68
50
|
if (widths) {
|
|
69
51
|
this.setState({
|
|
70
52
|
columnWidths: widths
|
|
@@ -86,11 +68,11 @@ var TableTree = /*#__PURE__*/function (_Component) {
|
|
|
86
68
|
key: "render",
|
|
87
69
|
value: function render() {
|
|
88
70
|
var _this$props = this.props,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
71
|
+
items = _this$props.items,
|
|
72
|
+
headers = _this$props.headers,
|
|
73
|
+
columns = _this$props.columns,
|
|
74
|
+
_this$props$columnWid = _this$props.columnWidths,
|
|
75
|
+
columnWidths = _this$props$columnWid === void 0 ? [] : _this$props$columnWid;
|
|
94
76
|
var heads = headers && /*#__PURE__*/React.createElement(Headers, null, headers.map(function (header, index) {
|
|
95
77
|
return (
|
|
96
78
|
/*#__PURE__*/
|
|
@@ -103,21 +85,21 @@ var TableTree = /*#__PURE__*/function (_Component) {
|
|
|
103
85
|
);
|
|
104
86
|
}));
|
|
105
87
|
var rows = null;
|
|
106
|
-
|
|
107
88
|
if (columns && items) {
|
|
108
89
|
rows = /*#__PURE__*/React.createElement(Rows, {
|
|
109
90
|
items: items,
|
|
110
91
|
render: function render(_ref) {
|
|
111
92
|
var id = _ref.id,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
children = _ref.children,
|
|
94
|
+
hasChildren = _ref.hasChildren,
|
|
95
|
+
content = _ref.content;
|
|
115
96
|
return /*#__PURE__*/React.createElement(Row, {
|
|
116
97
|
itemId: id,
|
|
117
98
|
items: children,
|
|
118
99
|
hasChildren: hasChildren
|
|
119
100
|
}, columns.map(function (CellContent, index) {
|
|
120
|
-
return /*#__PURE__*/React.createElement(Cell
|
|
101
|
+
return /*#__PURE__*/React.createElement(Cell
|
|
102
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
121
103
|
, {
|
|
122
104
|
key: index,
|
|
123
105
|
columnIndex: index,
|
|
@@ -127,19 +109,15 @@ var TableTree = /*#__PURE__*/function (_Component) {
|
|
|
127
109
|
}
|
|
128
110
|
});
|
|
129
111
|
}
|
|
130
|
-
|
|
131
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
132
113
|
role: "treegrid",
|
|
133
114
|
"aria-readonly": true
|
|
134
115
|
}, heads, rows, this.props.children);
|
|
135
116
|
}
|
|
136
117
|
}]);
|
|
137
|
-
|
|
138
118
|
return TableTree;
|
|
139
119
|
}(Component);
|
|
140
|
-
|
|
141
120
|
_defineProperty(TableTree, "childContextTypes", {
|
|
142
121
|
tableTree: PropTypes.object.isRequired
|
|
143
122
|
});
|
|
144
|
-
|
|
145
123
|
export { TableTree as default };
|
|
@@ -2,30 +2,22 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
|
|
6
5
|
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; }
|
|
7
|
-
|
|
8
6
|
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) { _defineProperty(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; }
|
|
9
|
-
|
|
10
7
|
import get from 'lodash/get';
|
|
11
8
|
import set from 'lodash/set';
|
|
12
|
-
|
|
13
9
|
function updateRootItems(rootItems) {
|
|
14
10
|
var allItems = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
15
|
-
|
|
16
11
|
var _ref = arguments.length > 2 ? arguments[2] : undefined,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
key = _ref.key,
|
|
13
|
+
keysCache = _ref.keysCache,
|
|
14
|
+
operation = _ref.operation;
|
|
15
|
+
var newKeysCache = _objectSpread({}, keysCache);
|
|
16
|
+
// If it is not an append operation we can ignore allItems as they will be swaped with new items
|
|
24
17
|
var allBaseItems = operation === 'UPDATE' ? [] : _toConsumableArray(allItems);
|
|
25
18
|
var startIndexWith = allBaseItems.length;
|
|
26
19
|
rootItems.forEach(function (rootItem, index) {
|
|
27
20
|
var rootItemKey = rootItem[key];
|
|
28
|
-
|
|
29
21
|
if (rootItemKey === undefined) {
|
|
30
22
|
throw new Error("[ERROR] Property '".concat(key, "' not found in rootItem[").concat(index, "]"));
|
|
31
23
|
} else {
|
|
@@ -37,28 +29,22 @@ function updateRootItems(rootItems) {
|
|
|
37
29
|
items: allBaseItems.concat(rootItems)
|
|
38
30
|
};
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
|
|
42
33
|
var key = _ref2.key,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
keysCache = _ref2.keysCache,
|
|
35
|
+
operation = _ref2.operation;
|
|
46
36
|
var newKeysCache = _objectSpread({}, keysCache);
|
|
47
|
-
|
|
48
37
|
var parentCacheKey = itemParent[key];
|
|
49
|
-
|
|
50
38
|
if (parentCacheKey === undefined) {
|
|
51
39
|
throw new Error("[Table Tree] Property '".concat(key, "' not found in parent item"));
|
|
52
40
|
}
|
|
53
|
-
|
|
54
41
|
var parentLocation = newKeysCache[parentCacheKey];
|
|
55
|
-
|
|
56
42
|
var allItemsCopy = _toConsumableArray(allTableItems);
|
|
57
|
-
|
|
58
43
|
var objectToChange = get(allItemsCopy, parentLocation);
|
|
59
44
|
var baseChildrenOfObjectToChange = operation === 'UPDATE' ? [] : get(objectToChange, 'children', []);
|
|
60
|
-
objectToChange.children = baseChildrenOfObjectToChange.concat(newitems);
|
|
45
|
+
objectToChange.children = baseChildrenOfObjectToChange.concat(newitems);
|
|
61
46
|
|
|
47
|
+
// Update cache
|
|
62
48
|
newitems.forEach(function (item, index) {
|
|
63
49
|
newKeysCache[item[key]] = "".concat(parentLocation, ".children[").concat(index + baseChildrenOfObjectToChange.length, "]");
|
|
64
50
|
});
|
|
@@ -67,6 +53,7 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
|
|
|
67
53
|
items: set(allItemsCopy, parentLocation, objectToChange)
|
|
68
54
|
};
|
|
69
55
|
}
|
|
56
|
+
|
|
70
57
|
/**
|
|
71
58
|
* This helper class will create a cache of all the id's in the items object and
|
|
72
59
|
* path to the object.
|
|
@@ -83,20 +70,15 @@ function updateChildItems(newitems, allTableItems, itemParent, _ref2) {
|
|
|
83
70
|
* Cache will look something like:
|
|
84
71
|
* {1: 0, 2: '0.children[0]'}
|
|
85
72
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
73
|
var TableTreeDataHelper = /*#__PURE__*/function () {
|
|
89
74
|
function TableTreeDataHelper() {
|
|
90
75
|
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
76
|
+
_ref3$key = _ref3.key,
|
|
77
|
+
key = _ref3$key === void 0 ? 'key' : _ref3$key;
|
|
94
78
|
_classCallCheck(this, TableTreeDataHelper);
|
|
95
|
-
|
|
96
79
|
this.key = key;
|
|
97
80
|
this.keysCache = {};
|
|
98
81
|
}
|
|
99
|
-
|
|
100
82
|
_createClass(TableTreeDataHelper, [{
|
|
101
83
|
key: "updateItems",
|
|
102
84
|
value: function updateItems(items) {
|
|
@@ -107,20 +89,16 @@ var TableTreeDataHelper = /*#__PURE__*/function () {
|
|
|
107
89
|
keysCache: this.keysCache,
|
|
108
90
|
operation: 'UPDATE'
|
|
109
91
|
};
|
|
110
|
-
|
|
111
92
|
if (!parentItem) {
|
|
112
93
|
var _updateRootItems = updateRootItems(items, allItems, options),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
94
|
+
_keysCache = _updateRootItems.keysCache,
|
|
95
|
+
updatedRootItems = _updateRootItems.items;
|
|
116
96
|
this.keysCache = _keysCache;
|
|
117
97
|
return updatedRootItems;
|
|
118
98
|
}
|
|
119
|
-
|
|
120
99
|
var _updateChildItems = updateChildItems(items, allItems, parentItem, options),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
100
|
+
keysCache = _updateChildItems.keysCache,
|
|
101
|
+
updatedItems = _updateChildItems.items;
|
|
124
102
|
this.keysCache = keysCache;
|
|
125
103
|
return updatedItems;
|
|
126
104
|
}
|
|
@@ -134,26 +112,20 @@ var TableTreeDataHelper = /*#__PURE__*/function () {
|
|
|
134
112
|
keysCache: this.keysCache,
|
|
135
113
|
operation: 'APPEND'
|
|
136
114
|
};
|
|
137
|
-
|
|
138
115
|
if (!parentItem) {
|
|
139
116
|
var _updateRootItems2 = updateRootItems(items, allItems, options),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
117
|
+
_keysCache2 = _updateRootItems2.keysCache,
|
|
118
|
+
updatedRootItems = _updateRootItems2.items;
|
|
143
119
|
this.keysCache = _keysCache2;
|
|
144
120
|
return updatedRootItems;
|
|
145
121
|
}
|
|
146
|
-
|
|
147
122
|
var _updateChildItems2 = updateChildItems(items, allItems, parentItem, options),
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
keysCache = _updateChildItems2.keysCache,
|
|
124
|
+
updatedItems = _updateChildItems2.items;
|
|
151
125
|
this.keysCache = keysCache;
|
|
152
126
|
return updatedItems;
|
|
153
127
|
}
|
|
154
128
|
}]);
|
|
155
|
-
|
|
156
129
|
return TableTreeDataHelper;
|
|
157
130
|
}();
|
|
158
|
-
|
|
159
131
|
export { TableTreeDataHelper as default };
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/table-tree",
|
|
3
|
-
"version": "9.2.
|
|
3
|
+
"version": "9.2.9",
|
|
4
4
|
"description": "A table tree is an expandable table for showing nested hierarchies of information.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@atlaskit/icon": "^21.11.0",
|
|
34
34
|
"@atlaskit/spinner": "^15.3.0",
|
|
35
35
|
"@atlaskit/theme": "^12.2.0",
|
|
36
|
-
"@atlaskit/tokens": "^0.
|
|
36
|
+
"@atlaskit/tokens": "^1.0.0",
|
|
37
37
|
"@babel/runtime": "^7.0.0",
|
|
38
38
|
"@emotion/react": "^11.7.1",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
@@ -47,12 +47,13 @@
|
|
|
47
47
|
"@atlaskit/ds-lib": "^2.0.1",
|
|
48
48
|
"@atlaskit/empty-state": "^7.4.0",
|
|
49
49
|
"@atlaskit/section-message": "^6.3.0",
|
|
50
|
-
"@atlaskit/select": "^16.
|
|
50
|
+
"@atlaskit/select": "^16.1.0",
|
|
51
51
|
"@atlaskit/ssr": "*",
|
|
52
52
|
"@atlaskit/visual-regression": "*",
|
|
53
53
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
54
54
|
"@emotion/styled": "^11.0.0",
|
|
55
|
-
"
|
|
55
|
+
"@testing-library/react": "^12.1.5",
|
|
56
|
+
"@testing-library/user-event": "^14.4.3",
|
|
56
57
|
"exenv": "^1.2.2",
|
|
57
58
|
"react-dom": "^16.8.0",
|
|
58
59
|
"react-redux": "^5.1.2",
|