linear-react-components-ui 0.4.75-beta.0 → 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 -21
- 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/permissionValidations.js +1 -1
- package/lib/progress/Bar.js +40 -9
- package/lib/progress/index.js +12 -4
- package/lib/treeview/Node.js +13 -168
- package/lib/treeview/index.js +35 -354
- package/package.json +1 -1
- package/.DS_Store +0 -0
- 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,19 +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-elements {
|
|
53
|
-
animation: revealelement 0.3s forwards ease-in-out;
|
|
54
|
-
display: flex;
|
|
55
|
-
justify-content: flex-start;
|
|
56
|
-
align-items: center;
|
|
57
|
-
}
|
|
58
45
|
&:hover {
|
|
59
46
|
background-color: rgb(209, 209, 209);
|
|
60
47
|
}
|
|
@@ -66,11 +53,3 @@
|
|
|
66
53
|
float: left;
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
|
-
|
|
70
|
-
.nodelist > .treeviewitem > .label > .node-elements > .element,
|
|
71
|
-
.treeview-component > .treeviewcontainer > .treeviewitem > .label > .node-elements > .element {
|
|
72
|
-
margin-left: 10px;
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
height: 100%;
|
|
76
|
-
}
|
|
@@ -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;
|
|
@@ -59,7 +59,7 @@ var actionsOnPermissionDenied = function actionsOnPermissionDenied(permissionAtt
|
|
|
59
59
|
|
|
60
60
|
var result = {};
|
|
61
61
|
options.forEach(function (option) {
|
|
62
|
-
result[option] = hasPermission ? false : option ===
|
|
62
|
+
result[option] = hasPermission ? false : option === permissionsAttr[0].onDenied;
|
|
63
63
|
});
|
|
64
64
|
return result;
|
|
65
65
|
};
|
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,36 +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
14
|
var _checkbox = _interopRequireDefault(require("../checkbox"));
|
|
17
15
|
|
|
18
16
|
var _icons = _interopRequireDefault(require("../icons"));
|
|
19
17
|
|
|
20
18
|
var _constants = require("./constants");
|
|
21
19
|
|
|
22
|
-
var _buttons = _interopRequireDefault(require("../buttons"));
|
|
23
|
-
|
|
24
|
-
var _list = _interopRequireWildcard(require("../list"));
|
|
25
|
-
|
|
26
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
21
|
|
|
28
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); }
|
|
29
23
|
|
|
30
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; }
|
|
31
25
|
|
|
32
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
33
|
-
|
|
34
|
-
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."); }
|
|
35
|
-
|
|
36
|
-
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); }
|
|
37
|
-
|
|
38
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
39
|
-
|
|
40
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
-
|
|
42
|
-
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; }
|
|
43
|
-
|
|
44
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
45
27
|
|
|
46
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); } }
|
|
@@ -107,174 +89,43 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
107
89
|
});
|
|
108
90
|
}
|
|
109
91
|
});
|
|
110
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleShowNodeElements", {
|
|
111
|
-
configurable: true,
|
|
112
|
-
enumerable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
value: function value() {
|
|
115
|
-
var _this$state = _this.state,
|
|
116
|
-
showNodeElements = _this$state.showNodeElements,
|
|
117
|
-
keepMenuOpened = _this$state.keepMenuOpened;
|
|
118
|
-
if (!showNodeElements) _this.setState({
|
|
119
|
-
showNodeElements: true
|
|
120
|
-
});else if (showNodeElements && !keepMenuOpened) {
|
|
121
|
-
_this.setState({
|
|
122
|
-
showNodeElements: false
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnNodeElements", {
|
|
128
|
-
configurable: true,
|
|
129
|
-
enumerable: true,
|
|
130
|
-
writable: true,
|
|
131
|
-
value: function value() {
|
|
132
|
-
var _this$props = _this.props,
|
|
133
|
-
nodeElements = _this$props.nodeElements,
|
|
134
|
-
node = _this$props.node;
|
|
135
|
-
var result;
|
|
136
|
-
|
|
137
|
-
if (nodeElements) {
|
|
138
|
-
result = _react["default"].Children.map(nodeElements, function (element) {
|
|
139
|
-
if ( /*#__PURE__*/_react["default"].isValidElement(element) && element.props && element.props.onNodeElementClick) {
|
|
140
|
-
var onNodeElementClick = element.props.onNodeElementClick;
|
|
141
|
-
return /*#__PURE__*/_react["default"].cloneElement(element, {
|
|
142
|
-
onClick: function onClick() {
|
|
143
|
-
return onNodeElementClick(node);
|
|
144
|
-
},
|
|
145
|
-
onNodeElementClick: null
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return element;
|
|
150
|
-
}).map(function (element) {
|
|
151
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
152
|
-
key: "element-".concat(_uuid["default"].v1()),
|
|
153
|
-
className: "element"
|
|
154
|
-
}, element);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
159
|
-
className: "node-elements"
|
|
160
|
-
}, result);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
_this.labelRef = /*#__PURE__*/_react["default"].createRef();
|
|
164
92
|
_this.state = {
|
|
165
|
-
isVisible: context.startNodesOpened
|
|
166
|
-
showNodeElements: false,
|
|
167
|
-
keepMenuOpened: false
|
|
93
|
+
isVisible: context.startNodesOpened
|
|
168
94
|
};
|
|
169
95
|
return _this;
|
|
170
96
|
}
|
|
171
97
|
|
|
172
98
|
_createClass(TreeNode, [{
|
|
173
|
-
key: "componentDidMount",
|
|
174
|
-
value: function componentDidMount() {
|
|
175
|
-
var _this$props2 = this.props,
|
|
176
|
-
isParent = _this$props2.isParent,
|
|
177
|
-
nodeElements = _this$props2.nodeElements;
|
|
178
|
-
|
|
179
|
-
if (isParent || nodeElements) {
|
|
180
|
-
this.labelRef.current.addEventListener('mouseenter', this.handleShowNodeElements);
|
|
181
|
-
this.labelRef.current.addEventListener('mouseleave', this.handleShowNodeElements);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}, {
|
|
185
|
-
key: "componentWillUnmount",
|
|
186
|
-
value: function componentWillUnmount() {
|
|
187
|
-
var _this$props3 = this.props,
|
|
188
|
-
isParent = _this$props3.isParent,
|
|
189
|
-
nodeElements = _this$props3.nodeElements;
|
|
190
|
-
|
|
191
|
-
if (isParent || nodeElements) {
|
|
192
|
-
this.labelRef.current.removeEventListener('mouseenter', this.handleShowNodeElements);
|
|
193
|
-
this.labelRef.current.removeEventListener('mouseleave', this.handleShowNodeElements);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
99
|
key: "render",
|
|
198
100
|
value: function render() {
|
|
199
101
|
var _this2 = this;
|
|
200
102
|
|
|
201
|
-
var _this$
|
|
202
|
-
node = _this$
|
|
203
|
-
children = _this$
|
|
204
|
-
isParent = _this$props4.isParent,
|
|
205
|
-
onNodeClick = _this$props4.onNodeClick;
|
|
206
|
-
var showNodeElements = this.state.showNodeElements;
|
|
103
|
+
var _this$props = this.props,
|
|
104
|
+
node = _this$props.node,
|
|
105
|
+
children = _this$props.children;
|
|
207
106
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Consumer, null, function (_ref) {
|
|
208
107
|
var valuePropName = _ref.valuePropName,
|
|
209
108
|
labelPropName = _ref.labelPropName,
|
|
210
109
|
selectedIds = _ref.selectedIds,
|
|
211
|
-
|
|
110
|
+
updateSelectedIds = _ref.updateSelectedIds,
|
|
212
111
|
showCheckBox = _ref.showCheckBox,
|
|
213
112
|
requiredIds = _ref.requiredIds,
|
|
214
|
-
disabled = _ref.disabled
|
|
215
|
-
|
|
216
|
-
allowCheckAllChildren = _ref.allowCheckAllChildren,
|
|
217
|
-
requiredParentsIds = _ref.requiredParentsIds,
|
|
218
|
-
defaultDisabledTooltip = _ref.defaultDisabledTooltip;
|
|
219
|
-
var requiredNodes = [].concat(_toConsumableArray(requiredIds), _toConsumableArray(requiredParentsIds));
|
|
220
|
-
var required = requiredNodes.includes(node[valuePropName]);
|
|
113
|
+
disabled = _ref.disabled;
|
|
114
|
+
var required = requiredIds.includes(node[valuePropName]);
|
|
221
115
|
var checked = selectedIds.includes(node[valuePropName]) || required;
|
|
222
116
|
return /*#__PURE__*/_react["default"].createElement("li", {
|
|
223
117
|
className: "treeviewitem"
|
|
224
118
|
}, _this2.getSpan(), /*#__PURE__*/_react["default"].createElement("div", {
|
|
225
|
-
className: "label"
|
|
226
|
-
ref: _this2.labelRef,
|
|
227
|
-
role: "button",
|
|
228
|
-
onKeyPress: null,
|
|
229
|
-
tabIndex: "-1",
|
|
230
|
-
onClick: onNodeClick ? function () {
|
|
231
|
-
return onNodeClick(node);
|
|
232
|
-
} : null
|
|
119
|
+
className: "label"
|
|
233
120
|
}, showCheckBox ? /*#__PURE__*/_react["default"].createElement(_checkbox["default"], {
|
|
234
121
|
checked: checked,
|
|
235
122
|
disabled: required || disabled,
|
|
236
123
|
value: "".concat(node[valuePropName]),
|
|
237
124
|
label: node[labelPropName],
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
handlerUpdateSelectedIds(node.id, e.target.checked, isParent);
|
|
241
|
-
}
|
|
242
|
-
}) : node[labelPropName], allowCheckAllChildren && showNodeElements && isParent ? /*#__PURE__*/_react["default"].createElement(_buttons["default"], {
|
|
243
|
-
dropdown: true,
|
|
244
|
-
dropdownAlign: "left",
|
|
245
|
-
size: "mini",
|
|
246
|
-
onClick: function onClick() {
|
|
247
|
-
_this2.setState({
|
|
248
|
-
keepMenuOpened: !_this2.state.keepMenuOpened
|
|
249
|
-
});
|
|
250
|
-
},
|
|
251
|
-
showIconDropdown: false,
|
|
252
|
-
iconName: "menu",
|
|
253
|
-
customClass: "node-menu",
|
|
254
|
-
boxShadow: false
|
|
255
|
-
}, /*#__PURE__*/_react["default"].createElement(_list["default"], {
|
|
256
|
-
condensed: true
|
|
257
|
-
}, /*#__PURE__*/_react["default"].createElement(_list.ListItem, {
|
|
258
|
-
text: "Marcar todos",
|
|
259
|
-
onClick: function onClick() {
|
|
260
|
-
handlerToggleCheckChildren(node.id, true);
|
|
261
|
-
|
|
262
|
-
_this2.setState({
|
|
263
|
-
showNodeElements: false,
|
|
264
|
-
keepMenuOpened: false
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}), /*#__PURE__*/_react["default"].createElement(_list.ListItem, {
|
|
268
|
-
text: "Desmarcar todos",
|
|
269
|
-
onClick: function onClick() {
|
|
270
|
-
handlerToggleCheckChildren(node.id, false, required);
|
|
271
|
-
|
|
272
|
-
_this2.setState({
|
|
273
|
-
showNodeElements: false,
|
|
274
|
-
keepMenuOpened: false
|
|
275
|
-
});
|
|
125
|
+
onChange: disabled ? undefined : function (e) {
|
|
126
|
+
updateSelectedIds(node.id, e.target.checked);
|
|
276
127
|
}
|
|
277
|
-
})
|
|
128
|
+
}) : node[labelPropName]), /*#__PURE__*/_react["default"].createElement("ul", {
|
|
278
129
|
className: "nodelist"
|
|
279
130
|
}, _this2.state.isVisible && children));
|
|
280
131
|
});
|
|
@@ -289,18 +140,12 @@ TreeNode.propTypes = {
|
|
|
289
140
|
children: _propTypes["default"].any.isRequired,
|
|
290
141
|
childrenIds: _propTypes["default"].arrayOf(_propTypes["default"].number),
|
|
291
142
|
parentId: _propTypes["default"].number,
|
|
292
|
-
disabled: _propTypes["default"].bool
|
|
293
|
-
isParent: _propTypes["default"].bool,
|
|
294
|
-
nodeElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
295
|
-
onNodeClick: _propTypes["default"].func
|
|
143
|
+
disabled: _propTypes["default"].bool
|
|
296
144
|
};
|
|
297
145
|
TreeNode.defaultProps = {
|
|
298
146
|
childrenIds: [],
|
|
299
147
|
parentId: undefined,
|
|
300
|
-
disabled: false
|
|
301
|
-
isParent: false,
|
|
302
|
-
nodeElements: undefined,
|
|
303
|
-
onNodeClick: undefined
|
|
148
|
+
disabled: false
|
|
304
149
|
};
|
|
305
150
|
TreeNode.contextType = _constants.TreeviewContext;
|
|
306
151
|
var _default = TreeNode;
|
package/lib/treeview/index.js
CHANGED
|
@@ -78,326 +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), "returnParentId", {
|
|
99
|
-
configurable: true,
|
|
100
|
-
enumerable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: function value(nodeId) {
|
|
103
|
-
var parentId = Object.keys(_this.idsWithChildren).find(function (id) {
|
|
104
|
-
return _this.idsWithChildren[id].find(function (childId) {
|
|
105
|
-
return childId === nodeId;
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
return Number(parentId);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnAllAncestryIds", {
|
|
112
|
-
configurable: true,
|
|
113
|
-
enumerable: true,
|
|
114
|
-
writable: true,
|
|
115
|
-
value: function value(nodeId) {
|
|
116
|
-
var ancestryIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
117
|
-
|
|
118
|
-
var parentId = _this.returnParentId(nodeId);
|
|
119
|
-
|
|
120
|
-
if (parentId) {
|
|
121
|
-
var currentAncestryIds = [].concat(_toConsumableArray(ancestryIds), [Number(parentId)]);
|
|
122
|
-
return _this.returnAllAncestryIds(Number(parentId), currentAncestryIds);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return ancestryIds;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnChildrenIds", {
|
|
129
|
-
configurable: true,
|
|
130
|
-
enumerable: true,
|
|
131
|
-
writable: true,
|
|
132
|
-
value: function value(nodeId) {
|
|
133
|
-
var returnRequiredIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
134
|
-
var nodeChildrenIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
135
|
-
var requiredIds = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
136
|
-
|
|
137
|
-
if (_this.idsWithChildren[nodeId] !== undefined) {
|
|
138
|
-
nodeChildrenIds.push(nodeId);
|
|
139
|
-
if (returnRequiredIds) requiredIds.push(nodeId);
|
|
140
|
-
|
|
141
|
-
_this.idsWithChildren[nodeId].forEach(function (childId) {
|
|
142
|
-
return _this.returnChildrenIds(childId, returnRequiredIds, nodeChildrenIds, requiredIds);
|
|
143
|
-
});
|
|
144
|
-
} else nodeChildrenIds.push(nodeId);
|
|
145
|
-
|
|
146
|
-
return returnRequiredIds ? {
|
|
147
|
-
nodeChildrenIds: nodeChildrenIds,
|
|
148
|
-
requiredIds: requiredIds
|
|
149
|
-
} : nodeChildrenIds;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnAncestryIdsAllowedToUncheck", {
|
|
153
|
-
configurable: true,
|
|
154
|
-
enumerable: true,
|
|
155
|
-
writable: true,
|
|
156
|
-
value: function value(nodeId) {
|
|
157
|
-
var parentsIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
158
|
-
var previousParentId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
159
|
-
var selectedSiblingsIds;
|
|
160
|
-
var selectedIds = _this.state.selectedIds;
|
|
161
|
-
|
|
162
|
-
var parentId = _this.returnParentId(nodeId);
|
|
163
|
-
|
|
164
|
-
if (parentId) {
|
|
165
|
-
var nodeSiblingsIds = _this.idsWithChildren[parentId].filter(function (childId) {
|
|
166
|
-
return childId !== nodeId;
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
if (nodeSiblingsIds && nodeSiblingsIds.length > 0) {
|
|
170
|
-
selectedSiblingsIds = selectedIds.filter(function (id) {
|
|
171
|
-
return nodeSiblingsIds.includes(id);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
var result = selectedSiblingsIds && selectedSiblingsIds.length > 0 ? _toConsumableArray(parentsIds) : [].concat(_toConsumableArray(parentsIds), [parentId]);
|
|
176
|
-
|
|
177
|
-
if (!selectedSiblingsIds || selectedSiblingsIds && selectedSiblingsIds.length === 0 && !selectedIds.includes(previousParentId)) {
|
|
178
|
-
return _this.returnAncestryIdsAllowedToUncheck(parentId, result, parentId);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return parentsIds;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
Object.defineProperty(_assertThisInitialized(_this), "toggleCheckChildren", {
|
|
186
|
-
configurable: true,
|
|
187
|
-
enumerable: true,
|
|
188
|
-
writable: true,
|
|
189
|
-
value: function value(nodeId, check) {
|
|
190
|
-
var required = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
191
|
-
|
|
192
|
-
_this.setState({
|
|
193
|
-
isHandlingSelectedIds: true
|
|
194
|
-
}, function () {
|
|
195
|
-
_this.updateSelectedIds(nodeId, check, true, required);
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
Object.defineProperty(_assertThisInitialized(_this), "checkAllAncestry", {
|
|
200
|
-
configurable: true,
|
|
201
|
-
enumerable: true,
|
|
202
|
-
writable: true,
|
|
203
|
-
value: function value(nodeId, codigos) {
|
|
204
|
-
var returnRequiredParentsIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
205
|
-
var selectedIds = _this.state.selectedIds;
|
|
206
|
-
var requiredParentsIds = _this.state.requiredParentsIds;
|
|
207
|
-
|
|
208
|
-
var nodeAncestryIds = _this.returnAllAncestryIds(nodeId);
|
|
209
|
-
|
|
210
|
-
var notRequiredAncestryIds = nodeAncestryIds.filter(function (id) {
|
|
211
|
-
return !requiredParentsIds.includes(id);
|
|
212
|
-
});
|
|
213
|
-
var notSelectedAncestryIds = nodeAncestryIds.filter(function (id) {
|
|
214
|
-
return !selectedIds.includes(id);
|
|
215
|
-
});
|
|
216
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos), _toConsumableArray(notSelectedAncestryIds));
|
|
217
|
-
requiredParentsIds = [].concat(_toConsumableArray(requiredParentsIds), _toConsumableArray(notRequiredAncestryIds));
|
|
218
|
-
|
|
219
|
-
_this.setState({
|
|
220
|
-
requiredParentsIds: requiredParentsIds
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return !returnRequiredParentsIds ? selectedIds : {
|
|
224
|
-
updatedIdsWithAncestryIds: selectedIds,
|
|
225
|
-
requiredParentsIds: requiredParentsIds
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateAncestryAndSelectedIds", {
|
|
230
|
-
configurable: true,
|
|
231
|
-
enumerable: true,
|
|
232
|
-
writable: true,
|
|
233
|
-
value: function value(nodeId, codigos, requiredParentsIds) {
|
|
234
|
-
var selectedIds = _this.state.selectedIds;
|
|
235
|
-
|
|
236
|
-
var ancestryIds = _this.returnAncestryIdsAllowedToUncheck(nodeId);
|
|
237
|
-
|
|
238
|
-
var remainRequiredParentsIds = requiredParentsIds.filter(function (id) {
|
|
239
|
-
return !ancestryIds.includes(id);
|
|
240
|
-
});
|
|
241
|
-
selectedIds = selectedIds.filter(function (selectedId) {
|
|
242
|
-
return !codigos.includes(selectedId);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
_this.setState({
|
|
246
|
-
requiredParentsIds: remainRequiredParentsIds
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
return selectedIds;
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
Object.defineProperty(_assertThisInitialized(_this), "checkAllChildren", {
|
|
253
|
-
configurable: true,
|
|
254
|
-
enumerable: true,
|
|
255
|
-
writable: true,
|
|
256
|
-
value: function value(nodeId) {
|
|
257
|
-
var returnRequiredIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
258
|
-
var currentRequiredIds = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
259
|
-
var _this$state = _this.state,
|
|
260
|
-
selectedIds = _this$state.selectedIds,
|
|
261
|
-
requiredParentsIds = _this$state.requiredParentsIds;
|
|
262
|
-
var childrenIds;
|
|
263
|
-
|
|
264
|
-
if (returnRequiredIds) {
|
|
265
|
-
var _this$returnChildrenI = _this.returnChildrenIds(nodeId, returnRequiredIds),
|
|
266
|
-
nodeChildrenIds = _this$returnChildrenI.nodeChildrenIds,
|
|
267
|
-
requiredIds = _this$returnChildrenI.requiredIds;
|
|
268
|
-
|
|
269
|
-
var newRequiredIds = requiredIds.filter(function (id) {
|
|
270
|
-
return !currentRequiredIds.includes(id);
|
|
271
|
-
});
|
|
272
|
-
requiredParentsIds = [].concat(_toConsumableArray(currentRequiredIds), _toConsumableArray(newRequiredIds));
|
|
273
|
-
childrenIds = nodeChildrenIds;
|
|
274
|
-
} else childrenIds = _this.returnChildrenIds(nodeId);
|
|
275
|
-
|
|
276
|
-
var notSelectedChildrenIds = childrenIds.filter(function (id) {
|
|
277
|
-
return !selectedIds.includes(id);
|
|
278
|
-
});
|
|
279
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(notSelectedChildrenIds));
|
|
280
|
-
|
|
281
|
-
_this.setState({
|
|
282
|
-
isHandlingSelectedIds: false,
|
|
283
|
-
requiredParentsIds: requiredParentsIds
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
return selectedIds;
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
Object.defineProperty(_assertThisInitialized(_this), "uncheckAllChildren", {
|
|
290
|
-
configurable: true,
|
|
291
|
-
enumerable: true,
|
|
292
|
-
writable: true,
|
|
293
|
-
value: function value(nodeId) {
|
|
294
|
-
var remainSelectedIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
295
|
-
var selectedIds = remainSelectedIds.length > 0 ? remainSelectedIds : _this.state.selectedIds;
|
|
296
|
-
|
|
297
|
-
var childrenIds = _this.returnChildrenIds(nodeId);
|
|
298
|
-
|
|
299
|
-
selectedIds = selectedIds.filter(function (selectedId) {
|
|
300
|
-
return !childrenIds.includes(selectedId);
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
_this.setState({
|
|
304
|
-
isHandlingSelectedIds: false
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
return selectedIds;
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
Object.defineProperty(_assertThisInitialized(_this), "uncheckRequiredChildren", {
|
|
311
|
-
configurable: true,
|
|
312
|
-
enumerable: true,
|
|
313
|
-
writable: true,
|
|
314
|
-
value: function value(nodeId, codigos, requiredParentsIds) {
|
|
315
|
-
var childrenIds = _this.returnChildrenIds(nodeId);
|
|
316
|
-
|
|
317
|
-
var remainRequiredIds = requiredParentsIds.filter(function (id) {
|
|
318
|
-
return !childrenIds.includes(id);
|
|
319
|
-
});
|
|
86
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
87
|
+
args[_key] = arguments[_key];
|
|
88
|
+
}
|
|
320
89
|
|
|
321
|
-
|
|
322
|
-
requiredParentsIds: _toConsumableArray(remainRequiredIds)
|
|
323
|
-
}, function () {
|
|
324
|
-
return _this.updateAncestryAndSelectedIds(nodeId, codigos, remainRequiredIds);
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleCheck", {
|
|
90
|
+
return _possibleConstructorReturn(_this, (_temp = _this = _super.call.apply(_super, [this].concat(args)), Object.defineProperty(_assertThisInitialized(_this), "state", {
|
|
329
91
|
configurable: true,
|
|
330
92
|
enumerable: true,
|
|
331
93
|
writable: true,
|
|
332
|
-
value:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
var isHandlingSelectedIds = _this.state.isHandlingSelectedIds;
|
|
336
|
-
var _this$props = _this.props,
|
|
337
|
-
allowCheckAllChildren = _this$props.allowCheckAllChildren,
|
|
338
|
-
allowCheckAllAncestry = _this$props.allowCheckAllAncestry;
|
|
339
|
-
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos));
|
|
340
|
-
|
|
341
|
-
if (isParent && isHandlingSelectedIds && allowCheckAllChildren) {
|
|
342
|
-
if (allowCheckAllAncestry) {
|
|
343
|
-
var _this$checkAllAncestr = _this.checkAllAncestry(nodeId, codigos, true),
|
|
344
|
-
updatedIdsWithAncestryIds = _this$checkAllAncestr.updatedIdsWithAncestryIds,
|
|
345
|
-
requiredParentsIds = _this$checkAllAncestr.requiredParentsIds;
|
|
346
|
-
|
|
347
|
-
var updatedIdsWithChidlrenIds = _this.checkAllChildren(nodeId, true, requiredParentsIds);
|
|
348
|
-
|
|
349
|
-
selectedIds = [].concat(_toConsumableArray(updatedIdsWithAncestryIds), _toConsumableArray(updatedIdsWithChidlrenIds));
|
|
350
|
-
} else selectedIds = _this.checkAllChildren(nodeId);
|
|
351
|
-
} else if (allowCheckAllAncestry) {
|
|
352
|
-
selectedIds = _this.checkAllAncestry(nodeId, codigos);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
return selectedIds;
|
|
94
|
+
value: {
|
|
95
|
+
data: _this.props.data,
|
|
96
|
+
selectedIds: _this.props.selectedIds
|
|
356
97
|
}
|
|
357
|
-
})
|
|
358
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleUncheck", {
|
|
98
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "getContextValues", {
|
|
359
99
|
configurable: true,
|
|
360
100
|
enumerable: true,
|
|
361
101
|
writable: true,
|
|
362
|
-
value: function value(
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
isHandlingSelectedIds = _this$state2.isHandlingSelectedIds,
|
|
366
|
-
requiredParentsIds = _this$state2.requiredParentsIds;
|
|
367
|
-
var _this$props2 = _this.props,
|
|
368
|
-
allowCheckAllChildren = _this$props2.allowCheckAllChildren,
|
|
369
|
-
allowCheckAllAncestry = _this$props2.allowCheckAllAncestry;
|
|
370
|
-
var codigos = _lodash["default"].isArray(nodeId) ? nodeId : [nodeId];
|
|
371
|
-
selectedIds = selectedIds.filter(function (id) {
|
|
372
|
-
return !codigos.includes(id);
|
|
102
|
+
value: function value() {
|
|
103
|
+
return _extends({}, _this.props, _this.state, {
|
|
104
|
+
updateSelectedIds: _this.updateSelectedIds
|
|
373
105
|
});
|
|
374
|
-
|
|
375
|
-
if (isParent && isHandlingSelectedIds && allowCheckAllChildren) {
|
|
376
|
-
if (allowCheckAllAncestry) {
|
|
377
|
-
var updatedSelectedIds = _this.updateAncestryAndSelectedIds(nodeId, codigos, requiredParentsIds);
|
|
378
|
-
|
|
379
|
-
selectedIds = _this.uncheckAllChildren(nodeId, updatedSelectedIds);
|
|
380
|
-
if (required) _this.uncheckRequiredChildren(nodeId, codigos, requiredParentsIds);
|
|
381
|
-
} else selectedIds = _this.uncheckAllChildren(nodeId);
|
|
382
|
-
} else if (allowCheckAllAncestry) {
|
|
383
|
-
selectedIds = _this.updateAncestryAndSelectedIds(nodeId, codigos, requiredParentsIds);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return selectedIds;
|
|
387
106
|
}
|
|
388
|
-
})
|
|
389
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateSelectedIds", {
|
|
107
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "updateSelectedIds", {
|
|
390
108
|
configurable: true,
|
|
391
109
|
enumerable: true,
|
|
392
110
|
writable: true,
|
|
393
|
-
value: function value(
|
|
111
|
+
value: function value(ids, checked) {
|
|
394
112
|
var selectedIds = _this.state.selectedIds;
|
|
395
113
|
var onSelectedIdsChange = _this.props.onSelectedIdsChange;
|
|
114
|
+
var codigos = _lodash["default"].isArray(ids) ? ids : [ids];
|
|
396
115
|
|
|
397
116
|
if (checked) {
|
|
398
|
-
selectedIds =
|
|
117
|
+
selectedIds = [].concat(_toConsumableArray(selectedIds), _toConsumableArray(codigos));
|
|
399
118
|
} else {
|
|
400
|
-
selectedIds =
|
|
119
|
+
selectedIds = selectedIds.filter(function (id) {
|
|
120
|
+
return !codigos.includes(id);
|
|
121
|
+
});
|
|
401
122
|
}
|
|
402
123
|
|
|
403
124
|
_this.setState({
|
|
@@ -406,67 +127,37 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
406
127
|
|
|
407
128
|
if (onSelectedIdsChange) onSelectedIdsChange(selectedIds);
|
|
408
129
|
}
|
|
409
|
-
})
|
|
410
|
-
Object.defineProperty(_assertThisInitialized(_this), "buildTree", {
|
|
130
|
+
}), Object.defineProperty(_assertThisInitialized(_this), "buildTree", {
|
|
411
131
|
configurable: true,
|
|
412
132
|
enumerable: true,
|
|
413
133
|
writable: true,
|
|
414
134
|
value: function value(node) {
|
|
415
135
|
var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
416
|
-
var
|
|
417
|
-
var _this$props3 = _this.props,
|
|
418
|
-
nodeElements = _this$props3.nodeElements,
|
|
419
|
-
onNodeClick = _this$props3.onNodeClick;
|
|
136
|
+
var parentPropName = _this.props.parentPropName;
|
|
420
137
|
var childrenIds = [];
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
return i.id;
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
if (ids) {
|
|
428
|
-
var idWithChildren = {};
|
|
429
|
-
idWithChildren[node.id] = childrenIds;
|
|
430
|
-
Object.assign(ids, idWithChildren);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
138
|
+
if (node.itens && node.itens.length > 0) childrenIds = node.itens.map(function (i) {
|
|
139
|
+
return i.id;
|
|
140
|
+
});
|
|
434
141
|
return /*#__PURE__*/_react["default"].createElement(_Node["default"], {
|
|
435
142
|
key: "node-".concat(node.id),
|
|
436
143
|
node: node,
|
|
437
144
|
childrenIds: childrenIds,
|
|
438
|
-
|
|
439
|
-
parentId: parentId,
|
|
440
|
-
nodeElements: nodeElements,
|
|
441
|
-
onNodeClick: onNodeClick
|
|
145
|
+
parentId: parentId
|
|
442
146
|
}, childrenIds.length > 0 && node.itens.map(function (nodeitem) {
|
|
443
|
-
return _this.buildTree(nodeitem,
|
|
147
|
+
return _this.buildTree(nodeitem, nodeitem[parentPropName]);
|
|
444
148
|
}));
|
|
445
149
|
}
|
|
446
|
-
});
|
|
447
|
-
_this.idsWithChildren = {};
|
|
448
|
-
_this.state = {
|
|
449
|
-
data: _this.props.data,
|
|
450
|
-
selectedIds: _this.props.selectedIds,
|
|
451
|
-
isHandlingSelectedIds: false,
|
|
452
|
-
requiredParentsIds: []
|
|
453
|
-
};
|
|
454
|
-
return _this;
|
|
150
|
+
}), _temp));
|
|
455
151
|
}
|
|
456
152
|
|
|
457
153
|
_createClass(TreeView, [{
|
|
458
|
-
key: "componentDidMount",
|
|
459
|
-
value: function componentDidMount() {
|
|
460
|
-
this.buildTree(this.state.data, undefined, this.idsWithChildren);
|
|
461
|
-
}
|
|
462
|
-
}, {
|
|
463
154
|
key: "render",
|
|
464
155
|
value: function render() {
|
|
465
|
-
var _this$
|
|
466
|
-
customClass = _this$
|
|
467
|
-
bordered = _this$
|
|
468
|
-
children = _this$
|
|
469
|
-
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;
|
|
470
161
|
var data = this.state.data;
|
|
471
162
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Provider, {
|
|
472
163
|
value: this.getContextValues()
|
|
@@ -495,12 +186,7 @@ TreeView.propTypes = {
|
|
|
495
186
|
showCheckBox: _propTypes["default"].bool,
|
|
496
187
|
onSelectedIdsChange: _propTypes["default"].func,
|
|
497
188
|
children: _propTypes["default"].instanceOf(Object),
|
|
498
|
-
styleForContainer: _propTypes["default"].object
|
|
499
|
-
allowCheckAllChildren: _propTypes["default"].bool,
|
|
500
|
-
allowCheckAllAncestry: _propTypes["default"].bool,
|
|
501
|
-
defaultDisabledTooltip: _propTypes["default"].string,
|
|
502
|
-
nodeElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
503
|
-
onNodeClick: _propTypes["default"].func
|
|
189
|
+
styleForContainer: _propTypes["default"].object
|
|
504
190
|
};
|
|
505
191
|
TreeView.defaultProps = {
|
|
506
192
|
customClass: '',
|
|
@@ -511,12 +197,7 @@ TreeView.defaultProps = {
|
|
|
511
197
|
showCheckBox: false,
|
|
512
198
|
onSelectedIdsChange: undefined,
|
|
513
199
|
children: undefined,
|
|
514
|
-
styleForContainer: {}
|
|
515
|
-
allowCheckAllChildren: false,
|
|
516
|
-
allowCheckAllAncestry: false,
|
|
517
|
-
defaultDisabledTooltip: '',
|
|
518
|
-
nodeElements: undefined,
|
|
519
|
-
onNodeClick: undefined
|
|
200
|
+
styleForContainer: {}
|
|
520
201
|
};
|
|
521
202
|
var _default = TreeView;
|
|
522
203
|
exports["default"] = _default;
|
package/package.json
CHANGED
package/.DS_Store
DELETED
|
Binary file
|
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;
|