linear-react-components-ui 0.4.75-beta.11 → 0.4.75-beta.12
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/lib/assets/styles/effects.scss +10 -0
- package/lib/assets/styles/progress.scss +8 -1
- package/lib/assets/styles/treeview.scss +0 -32
- package/lib/buttons/DefaultButton.js +1 -7
- package/lib/checkbox/index.js +6 -20
- package/lib/inputs/select/multiple/index.js +9 -7
- package/lib/progress/Bar.js +40 -9
- package/lib/progress/index.js +12 -4
- package/lib/treeview/Node.js +18 -288
- package/lib/treeview/index.js +35 -448
- package/package.json +1 -1
- package/lib/checkbox/Label.js +0 -37
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
@import "colors.scss";
|
|
2
2
|
@import "commons.scss";
|
|
3
|
+
|
|
3
4
|
.container-progress {
|
|
4
5
|
display: flex;
|
|
5
6
|
overflow: hidden;
|
|
6
|
-
height: 24px;
|
|
7
7
|
margin-bottom: 20px;
|
|
8
8
|
background-color: #f5f5f5;
|
|
9
9
|
border-radius: 4px;
|
|
10
10
|
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
|
|
11
11
|
box-shadow: inset 0 1px 2px rgba(0,0,0,.1);
|
|
12
|
+
position: relative;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
.bar {
|
|
@@ -50,6 +51,12 @@
|
|
|
50
51
|
-o-animation: progress-bar-stripes 2s linear infinite;
|
|
51
52
|
animation: progress-bar-stripes 2s linear infinite;
|
|
52
53
|
}
|
|
54
|
+
&.-indeterminate {
|
|
55
|
+
animation: slideWithPositionFromLeft infinite;
|
|
56
|
+
position: absolute;
|
|
57
|
+
left: -100%;
|
|
58
|
+
top: 0;
|
|
59
|
+
}
|
|
53
60
|
>.progressbar-label {
|
|
54
61
|
display: flex;
|
|
55
62
|
align-items: center;
|
|
@@ -42,25 +42,6 @@
|
|
|
42
42
|
animation: revealelement 0.3s forwards ease-in-out;
|
|
43
43
|
> .label {
|
|
44
44
|
width: auto;
|
|
45
|
-
display: flex;
|
|
46
|
-
justify-content: flex-start;
|
|
47
|
-
align-items: center;
|
|
48
|
-
>.node-menu {
|
|
49
|
-
animation: revealelement 0.3s forwards ease-in-out;
|
|
50
|
-
margin-left: 10px;
|
|
51
|
-
}
|
|
52
|
-
>.node-rightelements {
|
|
53
|
-
animation: revealelement 0.3s forwards ease-in-out;
|
|
54
|
-
display: flex;
|
|
55
|
-
justify-content: flex-start;
|
|
56
|
-
align-items: center;
|
|
57
|
-
}
|
|
58
|
-
>.node-toolbarelements {
|
|
59
|
-
animation: revealelement 0.3s forwards ease-in-out;
|
|
60
|
-
width: auto;
|
|
61
|
-
height: 100%;
|
|
62
|
-
margin-left: 10px;
|
|
63
|
-
}
|
|
64
45
|
&:hover {
|
|
65
46
|
background-color: rgb(209, 209, 209);
|
|
66
47
|
}
|
|
@@ -72,16 +53,3 @@
|
|
|
72
53
|
float: left;
|
|
73
54
|
}
|
|
74
55
|
}
|
|
75
|
-
|
|
76
|
-
.nodelist > .treeviewitem > .label > .node-rightelements > .element,
|
|
77
|
-
.treeview-component > .treeviewcontainer > .treeviewitem > .label > .node-rightelements > .element {
|
|
78
|
-
margin-left: 10px;
|
|
79
|
-
display: flex;
|
|
80
|
-
align-items: center;
|
|
81
|
-
height: 100%;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.nodelist > .treeviewitem > .label > .node-toolbarelements > .toolbar-group > .buttonbar,
|
|
85
|
-
.treeview-component > .treeviewcontainer > .treeviewitem > .label > .node-toolbarelements > .toolbar-group > .buttonbar {
|
|
86
|
-
border: none;
|
|
87
|
-
}
|
|
@@ -69,8 +69,7 @@ var DefaultButton = function DefaultButton(props) {
|
|
|
69
69
|
boxShadow = props.boxShadow,
|
|
70
70
|
transparent = props.transparent,
|
|
71
71
|
round = props.round,
|
|
72
|
-
permissionAttr = props.permissionAttr
|
|
73
|
-
_onBlur = props.onBlur;
|
|
72
|
+
permissionAttr = props.permissionAttr;
|
|
74
73
|
|
|
75
74
|
var _useState = (0, _react.useState)(false),
|
|
76
75
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -148,9 +147,6 @@ var DefaultButton = function DefaultButton(props) {
|
|
|
148
147
|
if (dropdown) showDropdown();
|
|
149
148
|
if (_onClick && toggleable) setActiveButton(!activeButton);
|
|
150
149
|
},
|
|
151
|
-
onBlur: function onBlur(e) {
|
|
152
|
-
if (_onBlur) _onBlur(e);
|
|
153
|
-
},
|
|
154
150
|
disabled: shouldDisable(),
|
|
155
151
|
className: "".concat(getClass(), " ").concat(activeButton ? '-toggleable' : ''),
|
|
156
152
|
ref: function ref(r) {
|
|
@@ -180,7 +176,6 @@ DefaultButton.propTypes = {
|
|
|
180
176
|
boxShadow: _propTypes["default"].bool,
|
|
181
177
|
icon: _propTypes["default"].instanceOf(Object),
|
|
182
178
|
onClick: _propTypes["default"].func,
|
|
183
|
-
onBlur: _propTypes["default"].func,
|
|
184
179
|
targetRef: _propTypes["default"].func,
|
|
185
180
|
tabIndex: _propTypes["default"].string,
|
|
186
181
|
dropdown: _propTypes["default"].bool,
|
|
@@ -216,7 +211,6 @@ DefaultButton.defaultProps = {
|
|
|
216
211
|
icon: null,
|
|
217
212
|
content: null,
|
|
218
213
|
onClick: null,
|
|
219
|
-
onBlur: null,
|
|
220
214
|
targetRef: undefined,
|
|
221
215
|
tabIndex: undefined,
|
|
222
216
|
isLoading: false,
|
package/lib/checkbox/index.js
CHANGED
|
@@ -13,8 +13,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
|
|
14
14
|
var _gridlayout = _interopRequireDefault(require("../gridlayout"));
|
|
15
15
|
|
|
16
|
-
var _Label = _interopRequireDefault(require("./Label"));
|
|
17
|
-
|
|
18
16
|
require("../assets/styles/checkbox.scss");
|
|
19
17
|
|
|
20
18
|
var _permissionValidations = require("../permissionValidations");
|
|
@@ -54,10 +52,7 @@ var CheckBox = function CheckBox(props) {
|
|
|
54
52
|
id = props.id,
|
|
55
53
|
gridLayout = props.gridLayout,
|
|
56
54
|
checked = props.checked,
|
|
57
|
-
permissionAttr = props.permissionAttr
|
|
58
|
-
tooltip = props.tooltip,
|
|
59
|
-
tooltipPosition = props.tooltipPosition,
|
|
60
|
-
tooltipWidth = props.tooltipWidth;
|
|
55
|
+
permissionAttr = props.permissionAttr;
|
|
61
56
|
|
|
62
57
|
var _useState = (0, _react.useState)(checked),
|
|
63
58
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -126,12 +121,9 @@ var CheckBox = function CheckBox(props) {
|
|
|
126
121
|
value: value,
|
|
127
122
|
id: id,
|
|
128
123
|
onChange: function onChange() {}
|
|
129
|
-
}), /*#__PURE__*/_react["default"].createElement("span", null), label && /*#__PURE__*/_react["default"].createElement(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
tooltipWidth: tooltipWidth,
|
|
133
|
-
tooltipPosition: tooltipPosition
|
|
134
|
-
})), hint && /*#__PURE__*/_react["default"].createElement("div", {
|
|
124
|
+
}), /*#__PURE__*/_react["default"].createElement("span", null), label && /*#__PURE__*/_react["default"].createElement("span", {
|
|
125
|
+
className: "checkbox-description"
|
|
126
|
+
}, label)), hint && /*#__PURE__*/_react["default"].createElement("div", {
|
|
135
127
|
className: "checkbox-hint"
|
|
136
128
|
}, hint));
|
|
137
129
|
};
|
|
@@ -156,10 +148,7 @@ CheckBox.propTypes = {
|
|
|
156
148
|
autofocus: _propTypes["default"].bool,
|
|
157
149
|
hint: _propTypes["default"].string,
|
|
158
150
|
gridLayout: _propTypes["default"].string,
|
|
159
|
-
permissionAttr: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].arrayOf(_propTypes["default"].object)])
|
|
160
|
-
tooltip: _propTypes["default"].string,
|
|
161
|
-
tooltipPosition: _propTypes["default"].string,
|
|
162
|
-
tooltipWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])
|
|
151
|
+
permissionAttr: _propTypes["default"].oneOfType([_propTypes["default"].object, _propTypes["default"].arrayOf(_propTypes["default"].object)])
|
|
163
152
|
};
|
|
164
153
|
CheckBox.defaultProps = {
|
|
165
154
|
label: '',
|
|
@@ -174,10 +163,7 @@ CheckBox.defaultProps = {
|
|
|
174
163
|
hint: undefined,
|
|
175
164
|
id: undefined,
|
|
176
165
|
gridLayout: undefined,
|
|
177
|
-
permissionAttr: undefined
|
|
178
|
-
tooltip: '',
|
|
179
|
-
tooltipPosition: 'top',
|
|
180
|
-
tooltipWidth: 'auto'
|
|
166
|
+
permissionAttr: undefined
|
|
181
167
|
};
|
|
182
168
|
var _default = CheckBox;
|
|
183
169
|
exports["default"] = _default;
|
|
@@ -84,6 +84,7 @@ var MultipleSelect = /*#__PURE__*/function (_Component) {
|
|
|
84
84
|
_this.componentId = "select-component".concat(_uuid["default"].v1());
|
|
85
85
|
_this.componentRef = /*#__PURE__*/_react["default"].createRef();
|
|
86
86
|
_this.state = {
|
|
87
|
+
valueFromProps: null,
|
|
87
88
|
dataCombo: props.dataSource,
|
|
88
89
|
currents: [],
|
|
89
90
|
selected: null,
|
|
@@ -385,18 +386,19 @@ Object.defineProperty(MultipleSelect, "getDerivedStateFromProps", {
|
|
|
385
386
|
value = props.value,
|
|
386
387
|
idKey = props.idKey;
|
|
387
388
|
|
|
388
|
-
if (
|
|
389
|
-
var dataCombo = remoteSearch ? dataSource : (0, _helper.getFilteredMultipleDataCombo)(_extends({}, props, state));
|
|
390
|
-
return {
|
|
391
|
-
dataCombo: dataCombo,
|
|
392
|
-
selected: dataSource.length > 0 && remoteSearch ? dataSource[0] : null
|
|
393
|
-
};
|
|
394
|
-
} else if (value !== null && dataSource.length > 0) {
|
|
389
|
+
if (value !== state.valueFromProps && dataSource.length > 0) {
|
|
395
390
|
return {
|
|
391
|
+
valueFromProps: value,
|
|
396
392
|
currents: dataSource.filter(function (item) {
|
|
397
393
|
return value.includes(item[idKey]);
|
|
398
394
|
})
|
|
399
395
|
};
|
|
396
|
+
} else if (dataSource !== state.dataCombo) {
|
|
397
|
+
var dataCombo = remoteSearch ? dataSource : (0, _helper.getFilteredMultipleDataCombo)(_extends({}, props, state));
|
|
398
|
+
return {
|
|
399
|
+
dataCombo: dataCombo,
|
|
400
|
+
selected: dataSource.length > 0 && remoteSearch ? dataSource[0] : null
|
|
401
|
+
};
|
|
400
402
|
}
|
|
401
403
|
|
|
402
404
|
return null;
|
package/lib/progress/Bar.js
CHANGED
|
@@ -18,6 +18,16 @@ var getPercentage = function getPercentage(props) {
|
|
|
18
18
|
return Math.round(percentage * ROUND_PRECISION) / ROUND_PRECISION;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
var getClass = function getClass(props) {
|
|
22
|
+
var style = 'bar';
|
|
23
|
+
if (props.customClass) style += "".concat(props.customClass);
|
|
24
|
+
if (props.type) style += " -".concat(props.type);
|
|
25
|
+
if (props.effect) style += ' -effect';
|
|
26
|
+
if (props.animated) style += ' -animated';
|
|
27
|
+
if (props.indeterminate) style += ' -indeterminate';
|
|
28
|
+
return style;
|
|
29
|
+
};
|
|
30
|
+
|
|
21
31
|
var getLabel = function getLabel(progress) {
|
|
22
32
|
var value = progress.label;
|
|
23
33
|
|
|
@@ -30,43 +40,64 @@ var getLabel = function getLabel(progress) {
|
|
|
30
40
|
}, value);
|
|
31
41
|
};
|
|
32
42
|
|
|
43
|
+
var getStyle = function getStyle(props) {
|
|
44
|
+
if (props.indeterminate) {
|
|
45
|
+
return {
|
|
46
|
+
width: props.progressWidth,
|
|
47
|
+
height: props.height,
|
|
48
|
+
animationDuration: "".concat(props.indeterminateDuration, "s"),
|
|
49
|
+
animationDelay: "".concat(props.indeterminateDelay, "s")
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
width: "".concat(getPercentage(props), "%"),
|
|
55
|
+
height: props.height
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
|
|
33
59
|
var ProgressBar = function ProgressBar(props) {
|
|
34
60
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
35
61
|
role: "progressbar",
|
|
36
|
-
className:
|
|
37
|
-
style:
|
|
38
|
-
width: "".concat(getPercentage(props), "%"),
|
|
39
|
-
height: "".concat(props.height)
|
|
40
|
-
},
|
|
62
|
+
className: getClass(props),
|
|
63
|
+
style: getStyle(props),
|
|
41
64
|
"aria-valuenow": props.value,
|
|
42
65
|
"aria-valuemin": props.min,
|
|
43
66
|
"aria-valuemax": props.max
|
|
44
|
-
}, props.showLabel && getLabel(props));
|
|
67
|
+
}, props.showLabel && !props.indeterminate && getLabel(props));
|
|
45
68
|
};
|
|
46
69
|
|
|
47
70
|
ProgressBar.defaultProps = {
|
|
48
71
|
min: 0,
|
|
49
72
|
max: 100,
|
|
50
73
|
value: 0,
|
|
74
|
+
progressWidth: '100%',
|
|
51
75
|
height: '100%',
|
|
52
76
|
effect: false,
|
|
53
77
|
customClass: '',
|
|
54
78
|
type: '',
|
|
55
79
|
showLabel: true,
|
|
56
80
|
label: '',
|
|
57
|
-
animated: false
|
|
81
|
+
animated: false,
|
|
82
|
+
indeterminate: false,
|
|
83
|
+
indeterminateDuration: 1.5,
|
|
84
|
+
indeterminateDelay: 1
|
|
58
85
|
};
|
|
59
86
|
ProgressBar.propTypes = {
|
|
60
87
|
label: _propTypes["default"].string,
|
|
61
88
|
min: _propTypes["default"].number,
|
|
62
89
|
value: _propTypes["default"].number,
|
|
63
90
|
max: _propTypes["default"].number,
|
|
64
|
-
|
|
91
|
+
progressWidth: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
92
|
+
height: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
65
93
|
showLabel: _propTypes["default"].bool,
|
|
66
94
|
effect: _propTypes["default"].bool,
|
|
67
95
|
type: _propTypes["default"].string,
|
|
68
96
|
customClass: _propTypes["default"].string,
|
|
69
|
-
animated: _propTypes["default"].bool
|
|
97
|
+
animated: _propTypes["default"].bool,
|
|
98
|
+
indeterminate: _propTypes["default"].bool,
|
|
99
|
+
indeterminateDuration: _propTypes["default"].number,
|
|
100
|
+
indeterminateDelay: _propTypes["default"].number
|
|
70
101
|
};
|
|
71
102
|
var _default = ProgressBar;
|
|
72
103
|
exports["default"] = _default;
|
package/lib/progress/index.js
CHANGED
|
@@ -21,24 +21,32 @@ require("../assets/styles/progress.scss");
|
|
|
21
21
|
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
23
|
|
|
24
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
25
|
+
|
|
24
26
|
var ProgressBar = function ProgressBar(props) {
|
|
25
27
|
var style = props.style,
|
|
26
28
|
children = props.children;
|
|
29
|
+
|
|
30
|
+
var getStyle = _extends({}, style, {
|
|
31
|
+
width: props.width,
|
|
32
|
+
height: props.height
|
|
33
|
+
});
|
|
34
|
+
|
|
27
35
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
28
36
|
className: "container-progress",
|
|
29
|
-
style:
|
|
37
|
+
style: getStyle
|
|
30
38
|
}, children || /*#__PURE__*/_react["default"].createElement(_Bar["default"], props));
|
|
31
39
|
};
|
|
32
40
|
|
|
33
41
|
ProgressBar.propTypes = {
|
|
34
|
-
width: _propTypes["default"].string,
|
|
35
|
-
height: _propTypes["default"].string,
|
|
42
|
+
width: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
43
|
+
height: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number]),
|
|
36
44
|
style: _propTypes["default"].object,
|
|
37
45
|
children: _propTypes["default"].any
|
|
38
46
|
};
|
|
39
47
|
ProgressBar.defaultProps = {
|
|
40
48
|
width: '100%',
|
|
41
|
-
height: '
|
|
49
|
+
height: '24px',
|
|
42
50
|
children: null,
|
|
43
51
|
style: {}
|
|
44
52
|
};
|
package/lib/treeview/Node.js
CHANGED
|
@@ -11,42 +11,18 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
14
|
-
var _uuid = _interopRequireDefault(require("uuid"));
|
|
15
|
-
|
|
16
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
|
-
|
|
18
14
|
var _checkbox = _interopRequireDefault(require("../checkbox"));
|
|
19
15
|
|
|
20
16
|
var _icons = _interopRequireDefault(require("../icons"));
|
|
21
17
|
|
|
22
18
|
var _constants = require("./constants");
|
|
23
19
|
|
|
24
|
-
var _buttons = _interopRequireDefault(require("../buttons"));
|
|
25
|
-
|
|
26
|
-
var _list = _interopRequireWildcard(require("../list"));
|
|
27
|
-
|
|
28
|
-
var _toolbar = _interopRequireWildcard(require("../toolbar"));
|
|
29
|
-
|
|
30
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
31
21
|
|
|
32
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
23
|
|
|
34
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
25
|
|
|
36
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
|
-
|
|
38
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
39
|
-
|
|
40
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
41
|
-
|
|
42
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
43
|
-
|
|
44
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
45
|
-
|
|
46
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
47
|
-
|
|
48
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
49
|
-
|
|
50
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
51
27
|
|
|
52
28
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
@@ -83,21 +59,17 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
83
59
|
enumerable: true,
|
|
84
60
|
writable: true,
|
|
85
61
|
value: function value() {
|
|
86
|
-
var
|
|
87
|
-
node = _this$props.node,
|
|
88
|
-
alwaysShowArrow = _this$props.alwaysShowArrow;
|
|
62
|
+
var node = _this.props.node;
|
|
89
63
|
|
|
90
64
|
var span = /*#__PURE__*/_react["default"].createElement("noscript", null);
|
|
91
65
|
|
|
92
|
-
if (node.itens && node.itens.length > 0
|
|
66
|
+
if (node.itens && node.itens.length > 0) {
|
|
93
67
|
span = /*#__PURE__*/_react["default"].createElement("span", {
|
|
94
68
|
onKeyPress: null,
|
|
95
69
|
tabIndex: 0,
|
|
96
70
|
role: "button",
|
|
97
71
|
className: "opencloseicon",
|
|
98
|
-
onClick:
|
|
99
|
-
return _this.openCloseTree(node);
|
|
100
|
-
}
|
|
72
|
+
onClick: _this.openCloseTree
|
|
101
73
|
}, /*#__PURE__*/_react["default"].createElement(_icons["default"], {
|
|
102
74
|
name: _this.state.isVisible ? 'up' : 'down',
|
|
103
75
|
size: 10
|
|
@@ -108,278 +80,52 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
108
80
|
}
|
|
109
81
|
});
|
|
110
82
|
Object.defineProperty(_assertThisInitialized(_this), "openCloseTree", {
|
|
111
|
-
configurable: true,
|
|
112
|
-
enumerable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
value: function value(node) {
|
|
115
|
-
var _this$state = _this.state,
|
|
116
|
-
isVisible = _this$state.isVisible,
|
|
117
|
-
wasOpened = _this$state.wasOpened;
|
|
118
|
-
var handlerOnNodeOpen = _this.props.handlerOnNodeOpen;
|
|
119
|
-
var nextState = {
|
|
120
|
-
isVisible: !isVisible
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (!wasOpened && handlerOnNodeOpen) {
|
|
124
|
-
nextState = _extends({}, nextState, {
|
|
125
|
-
wasOpened: true
|
|
126
|
-
});
|
|
127
|
-
handlerOnNodeOpen(node);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
_this.setState(nextState);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleShowNodeElements", {
|
|
134
|
-
configurable: true,
|
|
135
|
-
enumerable: true,
|
|
136
|
-
writable: true,
|
|
137
|
-
value: function value() {
|
|
138
|
-
var _this$state2 = _this.state,
|
|
139
|
-
showNodeElements = _this$state2.showNodeElements,
|
|
140
|
-
keepMenuOpened = _this$state2.keepMenuOpened;
|
|
141
|
-
if (!showNodeElements) _this.setState({
|
|
142
|
-
showNodeElements: true
|
|
143
|
-
});else if (showNodeElements && !keepMenuOpened) {
|
|
144
|
-
_this.setState({
|
|
145
|
-
showNodeElements: false
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateElements", {
|
|
151
|
-
configurable: true,
|
|
152
|
-
enumerable: true,
|
|
153
|
-
writable: true,
|
|
154
|
-
value: function value(elements) {
|
|
155
|
-
var _this$props2 = _this.props,
|
|
156
|
-
node = _this$props2.node,
|
|
157
|
-
nodeElementsValidations = _this$props2.nodeElementsValidations;
|
|
158
|
-
var updatedElements = [];
|
|
159
|
-
|
|
160
|
-
if (elements) {
|
|
161
|
-
updatedElements = _react["default"].Children.map(elements, function (element) {
|
|
162
|
-
if ( /*#__PURE__*/_react["default"].isValidElement(element) && element.props) {
|
|
163
|
-
var _element$props = element.props,
|
|
164
|
-
validationKey = _element$props.validationKey,
|
|
165
|
-
onNodeElementClick = _element$props.onNodeElementClick;
|
|
166
|
-
var elementBehavior;
|
|
167
|
-
var newProps = {};
|
|
168
|
-
|
|
169
|
-
if (nodeElementsValidations && validationKey) {
|
|
170
|
-
elementBehavior = _this.validateNodeElement(validationKey);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (onNodeElementClick) {
|
|
174
|
-
newProps = _extends({}, newProps, {
|
|
175
|
-
onClick: function onClick(e) {
|
|
176
|
-
onNodeElementClick(node);
|
|
177
|
-
if (e.stopPropagation) e.stopPropagation();
|
|
178
|
-
},
|
|
179
|
-
onNodeElementClick: null
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return /*#__PURE__*/_react["default"].cloneElement(element, _extends({}, elementBehavior, newProps));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return element;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return updatedElements;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnNodeRightElements", {
|
|
194
83
|
configurable: true,
|
|
195
84
|
enumerable: true,
|
|
196
85
|
writable: true,
|
|
197
86
|
value: function value() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
var updatedNodeRightElements = _this.updateElements(nodeRightElements).map(function (element) {
|
|
201
|
-
var unvisible = element.props && 'visible' in element.props && !element.props.visible;
|
|
202
|
-
var style = unvisible ? {
|
|
203
|
-
display: 'none'
|
|
204
|
-
} : {};
|
|
205
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
206
|
-
style: style,
|
|
207
|
-
key: "element-".concat(_uuid["default"].v1()),
|
|
208
|
-
className: "element"
|
|
209
|
-
}, element);
|
|
87
|
+
_this.setState({
|
|
88
|
+
isVisible: !_this.state.isVisible
|
|
210
89
|
});
|
|
211
|
-
|
|
212
|
-
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
213
|
-
className: "node-rightelements"
|
|
214
|
-
}, updatedNodeRightElements) : null;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnNodeToolbarElements", {
|
|
218
|
-
configurable: true,
|
|
219
|
-
enumerable: true,
|
|
220
|
-
writable: true,
|
|
221
|
-
value: function value() {
|
|
222
|
-
var nodeToolbarElements = _this.props.nodeToolbarElements;
|
|
223
|
-
|
|
224
|
-
var updatedNodeRightElements = _this.updateElements(nodeToolbarElements);
|
|
225
|
-
|
|
226
|
-
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement(_toolbar["default"], {
|
|
227
|
-
customClass: "node-toolbarelements"
|
|
228
|
-
}, /*#__PURE__*/_react["default"].createElement(_toolbar.ToolBarGroup, null, updatedNodeRightElements)) : null;
|
|
229
90
|
}
|
|
230
91
|
});
|
|
231
|
-
Object.defineProperty(_assertThisInitialized(_this), "validateNodeElement", {
|
|
232
|
-
configurable: true,
|
|
233
|
-
enumerable: true,
|
|
234
|
-
writable: true,
|
|
235
|
-
value: function value(validationKey) {
|
|
236
|
-
var _this$props3 = _this.props,
|
|
237
|
-
nodeElementsValidations = _this$props3.nodeElementsValidations,
|
|
238
|
-
node = _this$props3.node;
|
|
239
|
-
var validations = nodeElementsValidations[validationKey];
|
|
240
|
-
var options = {
|
|
241
|
-
disabled: {
|
|
242
|
-
disabled: true
|
|
243
|
-
},
|
|
244
|
-
unvisible: {
|
|
245
|
-
visible: false
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var elementBehavior = {};
|
|
249
|
-
|
|
250
|
-
if (validations) {
|
|
251
|
-
validations.forEach(function (validation) {
|
|
252
|
-
var validator = validation.validator,
|
|
253
|
-
applyBehavior = validation.applyBehavior;
|
|
254
|
-
|
|
255
|
-
if (_lodash["default"].isEmpty(elementBehavior) && validator && validator(node)) {
|
|
256
|
-
elementBehavior = options[applyBehavior] || options.unvisible;
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return elementBehavior;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
_this.labelRef = /*#__PURE__*/_react["default"].createRef();
|
|
265
92
|
_this.state = {
|
|
266
|
-
isVisible: context.startNodesOpened
|
|
267
|
-
wasOpened: context.startNodesOpened,
|
|
268
|
-
showNodeElements: false,
|
|
269
|
-
keepMenuOpened: false
|
|
93
|
+
isVisible: context.startNodesOpened
|
|
270
94
|
};
|
|
271
95
|
return _this;
|
|
272
96
|
}
|
|
273
97
|
|
|
274
98
|
_createClass(TreeNode, [{
|
|
275
|
-
key: "componentDidMount",
|
|
276
|
-
value: function componentDidMount() {
|
|
277
|
-
var _this$props4 = this.props,
|
|
278
|
-
isParent = _this$props4.isParent,
|
|
279
|
-
nodeToolbarElements = _this$props4.nodeToolbarElements,
|
|
280
|
-
nodeRightElements = _this$props4.nodeRightElements;
|
|
281
|
-
|
|
282
|
-
if (isParent || nodeRightElements || nodeToolbarElements) {
|
|
283
|
-
this.labelRef.current.addEventListener('mouseenter', this.handleShowNodeElements);
|
|
284
|
-
this.labelRef.current.addEventListener('mouseleave', this.handleShowNodeElements);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}, {
|
|
288
|
-
key: "componentWillUnmount",
|
|
289
|
-
value: function componentWillUnmount() {
|
|
290
|
-
var _this$props5 = this.props,
|
|
291
|
-
isParent = _this$props5.isParent,
|
|
292
|
-
nodeToolbarElements = _this$props5.nodeToolbarElements,
|
|
293
|
-
nodeRightElements = _this$props5.nodeRightElements;
|
|
294
|
-
|
|
295
|
-
if (isParent || nodeRightElements || nodeToolbarElements) {
|
|
296
|
-
this.labelRef.current.removeEventListener('mouseenter', this.handleShowNodeElements);
|
|
297
|
-
this.labelRef.current.removeEventListener('mouseleave', this.handleShowNodeElements);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
99
|
key: "render",
|
|
302
100
|
value: function render() {
|
|
303
101
|
var _this2 = this;
|
|
304
102
|
|
|
305
|
-
var _this$
|
|
306
|
-
node = _this$
|
|
307
|
-
children = _this$
|
|
308
|
-
isParent = _this$props6.isParent,
|
|
309
|
-
onNodeClick = _this$props6.onNodeClick,
|
|
310
|
-
nodeMenuButtonSize = _this$props6.nodeMenuButtonSize;
|
|
311
|
-
var showNodeElements = this.state.showNodeElements;
|
|
103
|
+
var _this$props = this.props,
|
|
104
|
+
node = _this$props.node,
|
|
105
|
+
children = _this$props.children;
|
|
312
106
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Consumer, null, function (_ref) {
|
|
313
107
|
var valuePropName = _ref.valuePropName,
|
|
314
108
|
labelPropName = _ref.labelPropName,
|
|
315
109
|
selectedIds = _ref.selectedIds,
|
|
316
|
-
|
|
110
|
+
updateSelectedIds = _ref.updateSelectedIds,
|
|
317
111
|
showCheckBox = _ref.showCheckBox,
|
|
318
112
|
requiredIds = _ref.requiredIds,
|
|
319
|
-
disabled = _ref.disabled
|
|
320
|
-
|
|
321
|
-
allowCheckAllChildren = _ref.allowCheckAllChildren,
|
|
322
|
-
requiredParentsIds = _ref.requiredParentsIds,
|
|
323
|
-
defaultDisabledTooltip = _ref.defaultDisabledTooltip;
|
|
324
|
-
var requiredNodes = [].concat(_toConsumableArray(requiredIds), _toConsumableArray(requiredParentsIds));
|
|
325
|
-
var required = requiredNodes.includes(node[valuePropName]);
|
|
113
|
+
disabled = _ref.disabled;
|
|
114
|
+
var required = requiredIds.includes(node[valuePropName]);
|
|
326
115
|
var checked = selectedIds.includes(node[valuePropName]) || required;
|
|
327
116
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
328
117
|
className: "treeviewitem"
|
|
329
118
|
}, _this2.getSpan(), /*#__PURE__*/_react["default"].createElement("div", {
|
|
330
|
-
className: "label"
|
|
331
|
-
ref: _this2.labelRef,
|
|
332
|
-
role: "button",
|
|
333
|
-
onKeyPress: null,
|
|
334
|
-
tabIndex: "-1",
|
|
335
|
-
onClick: onNodeClick ? function () {
|
|
336
|
-
return onNodeClick(node);
|
|
337
|
-
} : null
|
|
119
|
+
className: "label"
|
|
338
120
|
}, showCheckBox ? /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
|
|
339
121
|
checked: checked,
|
|
340
122
|
disabled: required || disabled,
|
|
341
123
|
value: "".concat(node[valuePropName]),
|
|
342
124
|
label: node[labelPropName],
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
handlerUpdateSelectedIds(node.id, e.target.checked, isParent);
|
|
346
|
-
}
|
|
347
|
-
}) : node[labelPropName], allowCheckAllChildren && showNodeElements && isParent ? /*#__PURE__*/_react["default"].createElement(_buttons["default"], {
|
|
348
|
-
dropdown: true,
|
|
349
|
-
dropdownAlign: "left",
|
|
350
|
-
size: nodeMenuButtonSize,
|
|
351
|
-
onClick: function onClick() {
|
|
352
|
-
_this2.setState({
|
|
353
|
-
keepMenuOpened: !_this2.state.keepMenuOpened
|
|
354
|
-
});
|
|
355
|
-
},
|
|
356
|
-
showIconDropdown: false,
|
|
357
|
-
iconName: "menu",
|
|
358
|
-
customClass: "node-menu",
|
|
359
|
-
boxShadow: false
|
|
360
|
-
}, /*#__PURE__*/_react["default"].createElement(_list["default"], {
|
|
361
|
-
condensed: true
|
|
362
|
-
}, /*#__PURE__*/_react["default"].createElement(_list.ListItem, {
|
|
363
|
-
text: "Marcar todos",
|
|
364
|
-
onClick: function onClick() {
|
|
365
|
-
handlerToggleCheckChildren(node.id, true);
|
|
366
|
-
|
|
367
|
-
_this2.setState({
|
|
368
|
-
showNodeElements: false,
|
|
369
|
-
keepMenuOpened: false
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}), /*#__PURE__*/_react["default"].createElement(_list.ListItem, {
|
|
373
|
-
text: "Desmarcar todos",
|
|
374
|
-
onClick: function onClick() {
|
|
375
|
-
handlerToggleCheckChildren(node.id, false, required);
|
|
376
|
-
|
|
377
|
-
_this2.setState({
|
|
378
|
-
showNodeElements: false,
|
|
379
|
-
keepMenuOpened: false
|
|
380
|
-
});
|
|
125
|
+
onChange: disabled ? undefined : function (e) {
|
|
126
|
+
updateSelectedIds(node.id, e.target.checked);
|
|
381
127
|
}
|
|
382
|
-
})
|
|
128
|
+
}) : node[labelPropName]), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
383
129
|
className: "nodelist"
|
|
384
130
|
}, _this2.state.isVisible && children));
|
|
385
131
|
});
|
|
@@ -394,28 +140,12 @@ TreeNode.propTypes = {
|
|
|
394
140
|
children: _propTypes["default"].any.isRequired,
|
|
395
141
|
childrenIds: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
396
142
|
parentId: _propTypes["default"].number,
|
|
397
|
-
disabled: _propTypes["default"].bool
|
|
398
|
-
isParent: _propTypes["default"].bool,
|
|
399
|
-
alwaysShowArrow: _propTypes["default"].bool,
|
|
400
|
-
nodeRightElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
401
|
-
nodeToolbarElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
402
|
-
nodeMenuButtonSize: _propTypes["default"].oneOf(['mini', 'small', 'medium', 'large', 'default']),
|
|
403
|
-
onNodeClick: _propTypes["default"].func,
|
|
404
|
-
handlerOnNodeOpen: _propTypes["default"].func,
|
|
405
|
-
nodeElementsValidations: _propTypes["default"].object
|
|
143
|
+
disabled: _propTypes["default"].bool
|
|
406
144
|
};
|
|
407
145
|
TreeNode.defaultProps = {
|
|
408
146
|
childrenIds: [],
|
|
409
147
|
parentId: undefined,
|
|
410
|
-
disabled: false
|
|
411
|
-
isParent: false,
|
|
412
|
-
alwaysShowArrow: false,
|
|
413
|
-
nodeRightElements: undefined,
|
|
414
|
-
nodeToolbarElements: undefined,
|
|
415
|
-
nodeMenuButtonSize: 'small',
|
|
416
|
-
onNodeClick: undefined,
|
|
417
|
-
handlerOnNodeOpen: undefined,
|
|
418
|
-
nodeElementsValidations: undefined
|
|
148
|
+
disabled: false
|
|
419
149
|
};
|
|
420
150
|
TreeNode.contextType = _constants.TreeviewContext;
|
|
421
151
|
var _default = TreeNode;
|
package/lib/treeview/index.js
CHANGED
|
@@ -78,368 +78,47 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
78
78
|
|
|
79
79
|
var _super = _createSuper(TreeView);
|
|
80
80
|
|
|
81
|
-
function TreeView(
|
|
82
|
-
var _this;
|
|
81
|
+
function TreeView() {
|
|
82
|
+
var _temp, _this;
|
|
83
83
|
|
|
84
84
|
_classCallCheck(this, TreeView);
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
enumerable: true,
|
|
90
|
-
writable: true,
|
|
91
|
-
value: function value() {
|
|
92
|
-
return _extends({}, _this.props, _this.state, {
|
|
93
|
-
handlerUpdateSelectedIds: _this.updateSelectedIds,
|
|
94
|
-
handlerToggleCheckChildren: _this.toggleCheckChildren
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleNewSelectedIds", {
|
|
99
|
-
configurable: true,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: function value(selectedIds) {
|
|
103
|
-
var requiredIds = [];
|
|
104
|
-
var newSelectedIds = [];
|
|
105
|
-
selectedIds.forEach(function (id) {
|
|
106
|
-
var _this$checkAllAncestr = _this.checkAllAncestry(id, [], true, false),
|
|
107
|
-
requiredParentsIds = _this$checkAllAncestr.requiredParentsIds,
|
|
108
|
-
updatedIdsWithAncestryIds = _this$checkAllAncestr.updatedIdsWithAncestryIds;
|
|
109
|
-
|
|
110
|
-
newSelectedIds = [].concat(_toConsumableArray(newSelectedIds), _toConsumableArray(updatedIdsWithAncestryIds));
|
|
111
|
-
requiredIds = [].concat(_toConsumableArray(requiredIds), _toConsumableArray(requiredParentsIds));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
_this.setState({
|
|
115
|
-
requiredParentsIds: _lodash["default"].uniq(requiredIds),
|
|
116
|
-
selectedIds: _lodash["default"].uniq(newSelectedIds)
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnParentId", {
|
|
121
|
-
configurable: true,
|
|
122
|
-
enumerable: true,
|
|
123
|
-
writable: true,
|
|
124
|
-
value: function value(nodeId) {
|
|
125
|
-
var parentId = Object.keys(_this.idsWithChildren).find(function (id) {
|
|
126
|
-
return _this.idsWithChildren[id].find(function (childId) {
|
|
127
|
-
return childId === nodeId;
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
return Number(parentId);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnAllAncestryIds", {
|
|
134
|
-
configurable: true,
|
|
135
|
-
enumerable: true,
|
|
136
|
-
writable: true,
|
|
137
|
-
value: function value(nodeId) {
|
|
138
|
-
var ancestryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
139
|
-
|
|
140
|
-
var parentId = _this.returnParentId(nodeId);
|
|
141
|
-
|
|
142
|
-
if (parentId) {
|
|
143
|
-
var currentAncestryIds = [].concat(_toConsumableArray(ancestryIds), [Number(parentId)]);
|
|
144
|
-
return _this.returnAllAncestryIds(Number(parentId), currentAncestryIds);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return ancestryIds;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnChildrenIds", {
|
|
151
|
-
configurable: true,
|
|
152
|
-
enumerable: true,
|
|
153
|
-
writable: true,
|
|
154
|
-
value: function value(nodeId) {
|
|
155
|
-
var returnRequiredIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
156
|
-
var nodeChildrenIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
157
|
-
var requiredIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
158
|
-
|
|
159
|
-
if (_this.idsWithChildren[nodeId] !== undefined) {
|
|
160
|
-
nodeChildrenIds.push(nodeId);
|
|
161
|
-
if (returnRequiredIds) requiredIds.push(nodeId);
|
|
162
|
-
|
|
163
|
-
_this.idsWithChildren[nodeId].forEach(function (childId) {
|
|
164
|
-
return _this.returnChildrenIds(childId, returnRequiredIds, nodeChildrenIds, requiredIds);
|
|
165
|
-
});
|
|
166
|
-
} else nodeChildrenIds.push(nodeId);
|
|
167
|
-
|
|
168
|
-
return returnRequiredIds ? {
|
|
169
|
-
nodeChildrenIds: nodeChildrenIds,
|
|
170
|
-
requiredIds: requiredIds
|
|
171
|
-
} : nodeChildrenIds;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnRequiredAncestryIds", {
|
|
175
|
-
configurable: true,
|
|
176
|
-
enumerable: true,
|
|
177
|
-
writable: true,
|
|
178
|
-
value: function value(nodeId) {
|
|
179
|
-
var requiredAncestryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
180
|
-
var previousParentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
181
|
-
var selectedSiblingsIds = [];
|
|
182
|
-
var selectedIds = _this.state.selectedIds;
|
|
183
|
-
|
|
184
|
-
var parentId = _this.returnParentId(nodeId);
|
|
185
|
-
|
|
186
|
-
if (parentId) {
|
|
187
|
-
var nodeSiblingsIds = _this.idsWithChildren[parentId].filter(function (childId) {
|
|
188
|
-
return childId !== nodeId;
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
var isPreviousParentSelected = selectedIds.includes(previousParentId);
|
|
192
|
-
|
|
193
|
-
if (nodeSiblingsIds && nodeSiblingsIds.length > 0) {
|
|
194
|
-
selectedSiblingsIds = selectedIds.filter(function (id) {
|
|
195
|
-
return nodeSiblingsIds.includes(id);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
var requiredIds = isPreviousParentSelected || selectedSiblingsIds.length > 0 ? _toConsumableArray(requiredAncestryIds) : [].concat(_toConsumableArray(requiredAncestryIds), [parentId]);
|
|
200
|
-
|
|
201
|
-
if (selectedSiblingsIds.length === 0 && !isPreviousParentSelected) {
|
|
202
|
-
return _this.returnRequiredAncestryIds(parentId, requiredIds, parentId);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return requiredAncestryIds;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
Object.defineProperty(_assertThisInitialized(_this), "toggleCheckChildren", {
|
|
210
|
-
configurable: true,
|
|
211
|
-
enumerable: true,
|
|
212
|
-
writable: true,
|
|
213
|
-
value: function value(nodeId, check) {
|
|
214
|
-
var required = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
215
|
-
|
|
216
|
-
_this.setState({
|
|
217
|
-
isHandlingSelectedIds: true
|
|
218
|
-
}, function () {
|
|
219
|
-
_this.updateSelectedIds(nodeId, check, true, required);
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
Object.defineProperty(_assertThisInitialized(_this), "checkAllAncestry", {
|
|
224
|
-
configurable: true,
|
|
225
|
-
enumerable: true,
|
|
226
|
-
writable: true,
|
|
227
|
-
value: function value(nodeId, codigos) {
|
|
228
|
-
var returnRequiredParentsIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
229
|
-
var updateState = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
230
|
-
var selectedIds = _this.state.selectedIds;
|
|
231
|
-
var requiredParentsIds = _this.state.requiredParentsIds;
|
|
232
|
-
|
|
233
|
-
var nodeAncestryIds = _this.returnAllAncestryIds(nodeId);
|
|
234
|
-
|
|
235
|
-
var notRequiredAncestryIds = nodeAncestryIds.filter(function (id) {
|
|
236
|
-
return !requiredParentsIds.includes(id);
|
|
237
|
-
});
|
|
238
|
-
var notSelectedAncestryIds = nodeAncestryIds.filter(function (id) {
|
|
239
|
-
return !selectedIds.includes(id);
|
|
240
|
-
});
|
|
241
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos), _toConsumableArray(notSelectedAncestryIds));
|
|
242
|
-
requiredParentsIds = [].concat(_toConsumableArray(requiredParentsIds), _toConsumableArray(notRequiredAncestryIds));
|
|
243
|
-
if (updateState) _this.setState({
|
|
244
|
-
requiredParentsIds: requiredParentsIds
|
|
245
|
-
});
|
|
246
|
-
return !returnRequiredParentsIds ? selectedIds : {
|
|
247
|
-
updatedIdsWithAncestryIds: selectedIds,
|
|
248
|
-
requiredParentsIds: requiredParentsIds
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateAncestryAndSelectedIds", {
|
|
253
|
-
configurable: true,
|
|
254
|
-
enumerable: true,
|
|
255
|
-
writable: true,
|
|
256
|
-
value: function value(nodeId, codigos, requiredParentsIds) {
|
|
257
|
-
var selectedIds = _this.state.selectedIds;
|
|
258
|
-
|
|
259
|
-
var ancestryIds = _this.returnRequiredAncestryIds(nodeId);
|
|
260
|
-
|
|
261
|
-
var remainRequiredParentsIds = requiredParentsIds.filter(function (id) {
|
|
262
|
-
return !ancestryIds.includes(id);
|
|
263
|
-
});
|
|
264
|
-
selectedIds = selectedIds.filter(function (selectedId) {
|
|
265
|
-
return !codigos.includes(selectedId);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
_this.setState({
|
|
269
|
-
requiredParentsIds: remainRequiredParentsIds
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
return selectedIds;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
Object.defineProperty(_assertThisInitialized(_this), "checkAllChildren", {
|
|
276
|
-
configurable: true,
|
|
277
|
-
enumerable: true,
|
|
278
|
-
writable: true,
|
|
279
|
-
value: function value(nodeId) {
|
|
280
|
-
var returnRequiredIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
281
|
-
var currentRequiredIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
282
|
-
var _this$state = _this.state,
|
|
283
|
-
selectedIds = _this$state.selectedIds,
|
|
284
|
-
requiredParentsIds = _this$state.requiredParentsIds;
|
|
285
|
-
var childrenIds;
|
|
286
|
-
|
|
287
|
-
if (returnRequiredIds) {
|
|
288
|
-
var _this$returnChildrenI = _this.returnChildrenIds(nodeId, returnRequiredIds),
|
|
289
|
-
nodeChildrenIds = _this$returnChildrenI.nodeChildrenIds,
|
|
290
|
-
requiredIds = _this$returnChildrenI.requiredIds;
|
|
291
|
-
|
|
292
|
-
var newRequiredIds = requiredIds.filter(function (id) {
|
|
293
|
-
return !currentRequiredIds.includes(id);
|
|
294
|
-
});
|
|
295
|
-
requiredParentsIds = [].concat(_toConsumableArray(currentRequiredIds), _toConsumableArray(newRequiredIds));
|
|
296
|
-
childrenIds = nodeChildrenIds;
|
|
297
|
-
} else childrenIds = _this.returnChildrenIds(nodeId);
|
|
298
|
-
|
|
299
|
-
var notSelectedChildrenIds = childrenIds.filter(function (id) {
|
|
300
|
-
return !selectedIds.includes(id);
|
|
301
|
-
});
|
|
302
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(notSelectedChildrenIds));
|
|
303
|
-
|
|
304
|
-
_this.setState({
|
|
305
|
-
isHandlingSelectedIds: false,
|
|
306
|
-
requiredParentsIds: requiredParentsIds
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
return selectedIds;
|
|
310
|
-
}
|
|
311
|
-
});
|
|
312
|
-
Object.defineProperty(_assertThisInitialized(_this), "uncheckAllChildren", {
|
|
313
|
-
configurable: true,
|
|
314
|
-
enumerable: true,
|
|
315
|
-
writable: true,
|
|
316
|
-
value: function value(nodeId) {
|
|
317
|
-
var remainSelectedIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
318
|
-
var selectedIds = remainSelectedIds.length > 0 ? remainSelectedIds : _this.state.selectedIds;
|
|
319
|
-
|
|
320
|
-
var childrenIds = _this.returnChildrenIds(nodeId);
|
|
321
|
-
|
|
322
|
-
selectedIds = selectedIds.filter(function (selectedId) {
|
|
323
|
-
return !childrenIds.includes(selectedId);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
_this.setState({
|
|
327
|
-
isHandlingSelectedIds: false
|
|
328
|
-
});
|
|
329
|
-
|
|
330
|
-
return selectedIds;
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
Object.defineProperty(_assertThisInitialized(_this), "uncheckRequiredChildren", {
|
|
334
|
-
configurable: true,
|
|
335
|
-
enumerable: true,
|
|
336
|
-
writable: true,
|
|
337
|
-
value: function value(nodeId, codigos, requiredParentsIds) {
|
|
338
|
-
var childrenIds = _this.returnChildrenIds(nodeId);
|
|
339
|
-
|
|
340
|
-
var remainRequiredIds = requiredParentsIds.filter(function (id) {
|
|
341
|
-
return !childrenIds.includes(id);
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
_this.setState({
|
|
345
|
-
requiredParentsIds: _toConsumableArray(remainRequiredIds)
|
|
346
|
-
}, function () {
|
|
347
|
-
return _this.updateAncestryAndSelectedIds(nodeId, codigos, remainRequiredIds);
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleOnNodeOpen", {
|
|
352
|
-
configurable: true,
|
|
353
|
-
enumerable: true,
|
|
354
|
-
writable: true,
|
|
355
|
-
value: function value(node) {
|
|
356
|
-
var id = node.id;
|
|
357
|
-
var onNodeOpen = _this.props.onNodeOpen;
|
|
358
|
-
var alreadyOpenedIds = _this.state.alreadyOpenedIds;
|
|
359
|
-
|
|
360
|
-
if (!alreadyOpenedIds.includes(id) && onNodeOpen) {
|
|
361
|
-
alreadyOpenedIds = [].concat(_toConsumableArray(alreadyOpenedIds), [id]);
|
|
362
|
-
onNodeOpen(node);
|
|
363
|
-
}
|
|
86
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
|
+
args[_key] = arguments[_key];
|
|
88
|
+
}
|
|
364
89
|
|
|
365
|
-
|
|
366
|
-
alreadyOpenedIds: alreadyOpenedIds
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleCheck", {
|
|
90
|
+
return _possibleConstructorReturn(_this, (_temp = _this = _super.call.apply(_super, [this].concat(args)), Object.defineProperty(_assertThisInitialized(_this), "state", {
|
|
371
91
|
configurable: true,
|
|
372
92
|
enumerable: true,
|
|
373
93
|
writable: true,
|
|
374
|
-
value:
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
var isHandlingSelectedIds = _this.state.isHandlingSelectedIds;
|
|
378
|
-
var _this$props = _this.props,
|
|
379
|
-
allowCheckAllChildren = _this$props.allowCheckAllChildren,
|
|
380
|
-
allowCheckAllAncestry = _this$props.allowCheckAllAncestry;
|
|
381
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos));
|
|
382
|
-
|
|
383
|
-
if (isParent && isHandlingSelectedIds && allowCheckAllChildren) {
|
|
384
|
-
if (allowCheckAllAncestry) {
|
|
385
|
-
var _this$checkAllAncestr2 = _this.checkAllAncestry(nodeId, codigos, true),
|
|
386
|
-
updatedIdsWithAncestryIds = _this$checkAllAncestr2.updatedIdsWithAncestryIds,
|
|
387
|
-
requiredParentsIds = _this$checkAllAncestr2.requiredParentsIds;
|
|
388
|
-
|
|
389
|
-
var updatedIdsWithChidlrenIds = _this.checkAllChildren(nodeId, true, requiredParentsIds);
|
|
390
|
-
|
|
391
|
-
selectedIds = [].concat(_toConsumableArray(updatedIdsWithAncestryIds), _toConsumableArray(updatedIdsWithChidlrenIds));
|
|
392
|
-
} else selectedIds = _this.checkAllChildren(nodeId);
|
|
393
|
-
} else if (allowCheckAllAncestry) {
|
|
394
|
-
selectedIds = _this.checkAllAncestry(nodeId, codigos);
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
return selectedIds;
|
|
94
|
+
value: {
|
|
95
|
+
data: _this.props.data,
|
|
96
|
+
selectedIds: _this.props.selectedIds
|
|
398
97
|
}
|
|
399
|
-
})
|
|
400
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleUncheck", {
|
|
98
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "getContextValues", {
|
|
401
99
|
configurable: true,
|
|
402
100
|
enumerable: true,
|
|
403
101
|
writable: true,
|
|
404
|
-
value: function value(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
isHandlingSelectedIds = _this$state2.isHandlingSelectedIds,
|
|
408
|
-
requiredParentsIds = _this$state2.requiredParentsIds;
|
|
409
|
-
var _this$props2 = _this.props,
|
|
410
|
-
allowCheckAllChildren = _this$props2.allowCheckAllChildren,
|
|
411
|
-
allowCheckAllAncestry = _this$props2.allowCheckAllAncestry;
|
|
412
|
-
var codigos = _lodash["default"].isArray(nodeId) ? nodeId : [nodeId];
|
|
413
|
-
selectedIds = selectedIds.filter(function (id) {
|
|
414
|
-
return !codigos.includes(id);
|
|
102
|
+
value: function value() {
|
|
103
|
+
return _extends({}, _this.props, _this.state, {
|
|
104
|
+
updateSelectedIds: _this.updateSelectedIds
|
|
415
105
|
});
|
|
416
|
-
|
|
417
|
-
if (isParent && isHandlingSelectedIds && allowCheckAllChildren) {
|
|
418
|
-
if (allowCheckAllAncestry) {
|
|
419
|
-
var updatedSelectedIds = _this.updateAncestryAndSelectedIds(nodeId, codigos, requiredParentsIds);
|
|
420
|
-
|
|
421
|
-
selectedIds = _this.uncheckAllChildren(nodeId, updatedSelectedIds);
|
|
422
|
-
if (required) _this.uncheckRequiredChildren(nodeId, codigos, requiredParentsIds);
|
|
423
|
-
} else selectedIds = _this.uncheckAllChildren(nodeId);
|
|
424
|
-
} else if (allowCheckAllAncestry) {
|
|
425
|
-
selectedIds = _this.updateAncestryAndSelectedIds(nodeId, codigos, requiredParentsIds);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
return selectedIds;
|
|
429
106
|
}
|
|
430
|
-
})
|
|
431
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateSelectedIds", {
|
|
107
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "updateSelectedIds", {
|
|
432
108
|
configurable: true,
|
|
433
109
|
enumerable: true,
|
|
434
110
|
writable: true,
|
|
435
|
-
value: function value(
|
|
111
|
+
value: function value(ids, checked) {
|
|
436
112
|
var selectedIds = _this.state.selectedIds;
|
|
437
113
|
var onSelectedIdsChange = _this.props.onSelectedIdsChange;
|
|
114
|
+
var codigos = _lodash["default"].isArray(ids) ? ids : [ids];
|
|
438
115
|
|
|
439
116
|
if (checked) {
|
|
440
|
-
selectedIds =
|
|
117
|
+
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos));
|
|
441
118
|
} else {
|
|
442
|
-
selectedIds =
|
|
119
|
+
selectedIds = selectedIds.filter(function (id) {
|
|
120
|
+
return !codigos.includes(id);
|
|
121
|
+
});
|
|
443
122
|
}
|
|
444
123
|
|
|
445
124
|
_this.setState({
|
|
@@ -448,90 +127,37 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
448
127
|
|
|
449
128
|
if (onSelectedIdsChange) onSelectedIdsChange(selectedIds);
|
|
450
129
|
}
|
|
451
|
-
})
|
|
452
|
-
Object.defineProperty(_assertThisInitialized(_this), "buildTree", {
|
|
130
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "buildTree", {
|
|
453
131
|
configurable: true,
|
|
454
132
|
enumerable: true,
|
|
455
133
|
writable: true,
|
|
456
134
|
value: function value(node) {
|
|
457
135
|
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
458
|
-
var
|
|
459
|
-
var _this$props3 = _this.props,
|
|
460
|
-
nodeRightElements = _this$props3.nodeRightElements,
|
|
461
|
-
onNodeClick = _this$props3.onNodeClick,
|
|
462
|
-
nodeElementsValidations = _this$props3.nodeElementsValidations,
|
|
463
|
-
nodeToolbarElements = _this$props3.nodeToolbarElements,
|
|
464
|
-
nodeMenuButtonSize = _this$props3.nodeMenuButtonSize,
|
|
465
|
-
alwaysShowArrow = _this$props3.alwaysShowArrow;
|
|
136
|
+
var parentPropName = _this.props.parentPropName;
|
|
466
137
|
var childrenIds = [];
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
return i.id;
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
if (ids) {
|
|
474
|
-
var idWithChildren = {};
|
|
475
|
-
idWithChildren[node.id] = childrenIds;
|
|
476
|
-
Object.assign(ids, idWithChildren);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
138
|
+
if (node.itens && node.itens.length > 0) childrenIds = node.itens.map(function (i) {
|
|
139
|
+
return i.id;
|
|
140
|
+
});
|
|
480
141
|
return /*#__PURE__*/_react["default"].createElement(_Node["default"], {
|
|
481
142
|
key: "node-".concat(node.id),
|
|
482
143
|
node: node,
|
|
483
|
-
alwaysShowArrow: alwaysShowArrow,
|
|
484
144
|
childrenIds: childrenIds,
|
|
485
|
-
|
|
486
|
-
parentId: parentId,
|
|
487
|
-
nodeRightElements: nodeRightElements,
|
|
488
|
-
nodeToolbarElements: nodeToolbarElements,
|
|
489
|
-
nodeElementsValidations: nodeElementsValidations,
|
|
490
|
-
nodeMenuButtonSize: nodeMenuButtonSize,
|
|
491
|
-
onNodeClick: onNodeClick,
|
|
492
|
-
handlerOnNodeOpen: _this.handleOnNodeOpen
|
|
145
|
+
parentId: parentId
|
|
493
146
|
}, childrenIds.length > 0 && node.itens.map(function (nodeitem) {
|
|
494
|
-
return _this.buildTree(nodeitem,
|
|
147
|
+
return _this.buildTree(nodeitem, nodeitem[parentPropName]);
|
|
495
148
|
}));
|
|
496
149
|
}
|
|
497
|
-
});
|
|
498
|
-
_this.idsWithChildren = {};
|
|
499
|
-
_this.state = {
|
|
500
|
-
data: _this.props.data,
|
|
501
|
-
propSelectedIds: _this.props.selectedIds,
|
|
502
|
-
selectedIds: _this.props.selectedIds,
|
|
503
|
-
isHandlingSelectedIds: false,
|
|
504
|
-
requiredParentsIds: [],
|
|
505
|
-
alreadyOpenedIds: []
|
|
506
|
-
};
|
|
507
|
-
return _this;
|
|
150
|
+
}), _temp));
|
|
508
151
|
}
|
|
509
152
|
|
|
510
153
|
_createClass(TreeView, [{
|
|
511
|
-
key: "componentDidMount",
|
|
512
|
-
value: function componentDidMount() {
|
|
513
|
-
this.buildTree(this.state.data, undefined, this.idsWithChildren);
|
|
514
|
-
}
|
|
515
|
-
}, {
|
|
516
|
-
key: "componentDidUpdate",
|
|
517
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
518
|
-
var _this$state3 = this.state,
|
|
519
|
-
selectedIds = _this$state3.selectedIds,
|
|
520
|
-
propSelectedIds = _this$state3.propSelectedIds;
|
|
521
|
-
var allowCheckAllAncestry = this.props.allowCheckAllAncestry;
|
|
522
|
-
|
|
523
|
-
var isSameSelectedIds = _lodash["default"].isEqual(propSelectedIds.sort(), prevState.propSelectedIds.sort());
|
|
524
|
-
|
|
525
|
-
if (allowCheckAllAncestry && !isSameSelectedIds) this.handleNewSelectedIds(selectedIds);
|
|
526
|
-
}
|
|
527
|
-
}, {
|
|
528
154
|
key: "render",
|
|
529
155
|
value: function render() {
|
|
530
|
-
var _this$
|
|
531
|
-
customClass = _this$
|
|
532
|
-
bordered = _this$
|
|
533
|
-
children = _this$
|
|
534
|
-
styleForContainer = _this$
|
|
156
|
+
var _this$props = this.props,
|
|
157
|
+
customClass = _this$props.customClass,
|
|
158
|
+
bordered = _this$props.bordered,
|
|
159
|
+
children = _this$props.children,
|
|
160
|
+
styleForContainer = _this$props.styleForContainer;
|
|
535
161
|
var data = this.state.data;
|
|
536
162
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Provider, {
|
|
537
163
|
value: this.getContextValues()
|
|
@@ -542,25 +168,6 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
542
168
|
className: "treeviewcontainer ".concat(bordered && '-bordered')
|
|
543
169
|
}, this.buildTree(data))));
|
|
544
170
|
}
|
|
545
|
-
}], [{
|
|
546
|
-
key: "getDerivedStateFromProps",
|
|
547
|
-
value: function getDerivedStateFromProps(props, state) {
|
|
548
|
-
var data = props.data,
|
|
549
|
-
selectedIds = props.selectedIds;
|
|
550
|
-
var propSelectedIds = state.propSelectedIds;
|
|
551
|
-
|
|
552
|
-
var isSameSelectedIds = _lodash["default"].isEqual(propSelectedIds.sort(), selectedIds.sort());
|
|
553
|
-
|
|
554
|
-
if (data !== state.data || !isSameSelectedIds) {
|
|
555
|
-
return {
|
|
556
|
-
data: data,
|
|
557
|
-
selectedIds: selectedIds,
|
|
558
|
-
propSelectedIds: selectedIds
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
return null;
|
|
563
|
-
}
|
|
564
171
|
}]);
|
|
565
172
|
|
|
566
173
|
return TreeView;
|
|
@@ -574,43 +181,23 @@ TreeView.propTypes = {
|
|
|
574
181
|
labelPropName: _propTypes["default"].string.isRequired,
|
|
575
182
|
parentPropName: _propTypes["default"].string.isRequired,
|
|
576
183
|
startNodesOpened: _propTypes["default"].bool,
|
|
577
|
-
alwaysShowArrow: _propTypes["default"].bool,
|
|
578
184
|
selectedIds: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
579
185
|
requiredIds: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
580
186
|
showCheckBox: _propTypes["default"].bool,
|
|
581
187
|
onSelectedIdsChange: _propTypes["default"].func,
|
|
582
188
|
children: _propTypes["default"].instanceOf(Object),
|
|
583
|
-
styleForContainer: _propTypes["default"].object
|
|
584
|
-
allowCheckAllChildren: _propTypes["default"].bool,
|
|
585
|
-
allowCheckAllAncestry: _propTypes["default"].bool,
|
|
586
|
-
defaultDisabledTooltip: _propTypes["default"].string,
|
|
587
|
-
nodeRightElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
588
|
-
nodeToolbarElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
589
|
-
nodeMenuButtonSize: _propTypes["default"].oneOf(['mini', 'small', 'medium', 'large', 'default']),
|
|
590
|
-
onNodeClick: _propTypes["default"].func,
|
|
591
|
-
onNodeOpen: _propTypes["default"].func,
|
|
592
|
-
nodeElementsValidations: _propTypes["default"].object
|
|
189
|
+
styleForContainer: _propTypes["default"].object
|
|
593
190
|
};
|
|
594
191
|
TreeView.defaultProps = {
|
|
595
192
|
customClass: '',
|
|
596
193
|
bordered: false,
|
|
597
194
|
startNodesOpened: false,
|
|
598
|
-
alwaysShowArrow: false,
|
|
599
195
|
selectedIds: [],
|
|
600
196
|
requiredIds: [],
|
|
601
197
|
showCheckBox: false,
|
|
602
198
|
onSelectedIdsChange: undefined,
|
|
603
199
|
children: undefined,
|
|
604
|
-
styleForContainer: {}
|
|
605
|
-
allowCheckAllChildren: false,
|
|
606
|
-
allowCheckAllAncestry: false,
|
|
607
|
-
defaultDisabledTooltip: '',
|
|
608
|
-
nodeRightElements: undefined,
|
|
609
|
-
nodeToolbarElements: undefined,
|
|
610
|
-
nodeMenuButtonSize: 'small',
|
|
611
|
-
onNodeClick: undefined,
|
|
612
|
-
onNodeOpen: undefined,
|
|
613
|
-
nodeElementsValidations: undefined
|
|
200
|
+
styleForContainer: {}
|
|
614
201
|
};
|
|
615
202
|
var _default = TreeView;
|
|
616
203
|
exports["default"] = _default;
|
package/package.json
CHANGED
package/lib/checkbox/Label.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _withTooltip = _interopRequireDefault(require("../internals/withTooltip"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
var Label = function Label(_ref) {
|
|
17
|
-
var label = _ref.label,
|
|
18
|
-
targetRef = _ref.targetRef;
|
|
19
|
-
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
20
|
-
className: "checkbox-description",
|
|
21
|
-
ref: function ref(r) {
|
|
22
|
-
return targetRef && targetRef(r);
|
|
23
|
-
}
|
|
24
|
-
}, label);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Label.propTypes = {
|
|
28
|
-
label: _propTypes["default"].string.isRequired,
|
|
29
|
-
targetRef: _propTypes["default"].func
|
|
30
|
-
};
|
|
31
|
-
Label.defaultProps = {
|
|
32
|
-
targetRef: undefined
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var _default = (0, _withTooltip["default"])(Label);
|
|
36
|
-
|
|
37
|
-
exports["default"] = _default;
|