linear-react-components-ui 0.4.75-beta.1 → 0.4.75-beta.13
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/.eslintrc.js +2 -5
- package/.vscode/settings.json +9 -9
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +12 -0
- package/config/jest/storageMock.js +40 -0
- package/jest.config.js +18 -0
- package/lib/alerts/alert.spec.js +133 -0
- package/lib/assets/styles/popover.scss +9 -11
- package/lib/assets/styles/treeview.scss +0 -32
- package/lib/avatar/avatar.spec.js +190 -0
- package/lib/avatar/index.js +6 -2
- package/lib/badge/badge.spec.js +127 -0
- package/lib/badge/index.js +3 -5
- package/lib/buttons/DefaultButton.js +1 -7
- package/lib/buttons/buttons.spec.js +504 -0
- package/lib/calendar/calendar.spec.js +171 -0
- package/lib/checkbox/checkbox.spec.js +215 -0
- package/lib/checkbox/index.js +7 -20
- package/lib/dialog/Custom.js +7 -1
- package/lib/dialog/base/index.js +3 -0
- package/lib/dialog/dialog.spec.js +488 -0
- package/lib/dialog/form/index.js +7 -1
- package/lib/drawer/Drawer.js +3 -0
- package/lib/drawer/Drawer.spec.js +258 -0
- package/lib/drawer/Header.js +4 -1
- package/lib/dropdown/Popup.js +1 -0
- package/lib/dropdown/dropdown.spec.js +168 -0
- package/lib/dropdown/withDropdown.js +10 -4
- package/lib/fieldset/fieldset.spec.js +329 -0
- package/lib/form/form.spec.js +285 -0
- package/lib/gridlayout/GridRow.js +1 -1
- package/lib/gridlayout/gridLayout.spec.js +169 -0
- package/lib/icons/icons.spec.js +86 -0
- package/lib/icons/index.js +2 -0
- package/lib/inputs/base/InputTextBase.js +2 -0
- package/lib/inputs/base/base.spec.js +690 -0
- package/lib/inputs/color/color_input.spec.js +174 -0
- package/lib/inputs/color/index.js +2 -2
- package/lib/inputs/date/date.spec.js +344 -0
- package/lib/inputs/date/index.js +7 -6
- package/lib/inputs/mask/Cpf.js +9 -9
- package/lib/inputs/mask/input_mask.spec.js +590 -0
- package/lib/inputs/number/numberfield.spec.js +215 -0
- package/lib/inputs/search/search_input.spec.js +209 -0
- package/lib/inputs/select/select.spec.js +391 -0
- package/lib/inputs/text/textfield.spec.js +215 -0
- package/lib/inputs/textarea/textarea.spec.js +59 -0
- package/lib/labelMessages/index.js +3 -2
- package/lib/labelMessages/labelMessages.spec.js +176 -0
- package/lib/labels/label.spec.js +162 -0
- package/lib/list/Item.js +3 -3
- package/lib/list/index.js +17 -8
- package/lib/list/list.spec.js +609 -0
- package/lib/menus/float/float-menu.spec.js +221 -0
- package/lib/menus/sidenav/sidenav.spec.js +312 -0
- package/lib/noPermission/index.js +2 -1
- package/lib/panel/panel.spec.js +216 -0
- package/lib/permissionValidations.js +1 -1
- package/lib/popover/index.js +2 -1
- package/lib/popover/popover.spec.js +146 -0
- package/lib/progress/progress.spec.js +86 -0
- package/lib/radio/radio.spec.js +189 -0
- package/lib/spinner/SpinnerLoading.js +14 -24
- package/lib/spinner/spinner.spec.js +152 -0
- package/lib/split/Split.js +5 -1
- package/lib/split/split.spec.js +151 -0
- package/lib/table/Header.js +3 -1
- package/lib/table/Row.js +1 -4
- package/lib/table/index.js +1 -4
- package/lib/table/table.spec.js +352 -0
- package/lib/tabs/tabs.spec.js +346 -0
- package/lib/toolbar/toolbar.spec.js +394 -0
- package/lib/tooltip/index.js +1 -0
- package/lib/tooltip/tooltip.spec.js +203 -0
- package/lib/treeview/Node.js +13 -255
- package/lib/treeview/index.js +35 -366
- package/lib/treeview/treeview.spec.js +261 -0
- package/package.json +11 -2
- package/.DS_Store +0 -0
- package/lib/checkbox/Label.js +0 -37
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,73 +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
|
-
nodeRightElements = _this$props3.nodeRightElements,
|
|
419
|
-
onNodeClick = _this$props3.onNodeClick,
|
|
420
|
-
nodeElementsValidations = _this$props3.nodeElementsValidations,
|
|
421
|
-
nodeToolbarElements = _this$props3.nodeToolbarElements,
|
|
422
|
-
nodeMenuButtonSize = _this$props3.nodeMenuButtonSize;
|
|
136
|
+
var parentPropName = _this.props.parentPropName;
|
|
423
137
|
var childrenIds = [];
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return i.id;
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
if (ids) {
|
|
431
|
-
var idWithChildren = {};
|
|
432
|
-
idWithChildren[node.id] = childrenIds;
|
|
433
|
-
Object.assign(ids, idWithChildren);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
138
|
+
if (node.itens && node.itens.length > 0) childrenIds = node.itens.map(function (i) {
|
|
139
|
+
return i.id;
|
|
140
|
+
});
|
|
437
141
|
return /*#__PURE__*/_react["default"].createElement(_Node["default"], {
|
|
438
142
|
key: "node-".concat(node.id),
|
|
439
143
|
node: node,
|
|
440
144
|
childrenIds: childrenIds,
|
|
441
|
-
|
|
442
|
-
parentId: parentId,
|
|
443
|
-
nodeRightElements: nodeRightElements,
|
|
444
|
-
nodeToolbarElements: nodeToolbarElements,
|
|
445
|
-
nodeElementsValidations: nodeElementsValidations,
|
|
446
|
-
nodeMenuButtonSize: nodeMenuButtonSize,
|
|
447
|
-
onNodeClick: onNodeClick
|
|
145
|
+
parentId: parentId
|
|
448
146
|
}, childrenIds.length > 0 && node.itens.map(function (nodeitem) {
|
|
449
|
-
return _this.buildTree(nodeitem,
|
|
147
|
+
return _this.buildTree(nodeitem, nodeitem[parentPropName]);
|
|
450
148
|
}));
|
|
451
149
|
}
|
|
452
|
-
});
|
|
453
|
-
_this.idsWithChildren = {};
|
|
454
|
-
_this.state = {
|
|
455
|
-
data: _this.props.data,
|
|
456
|
-
selectedIds: _this.props.selectedIds,
|
|
457
|
-
isHandlingSelectedIds: false,
|
|
458
|
-
requiredParentsIds: []
|
|
459
|
-
};
|
|
460
|
-
return _this;
|
|
150
|
+
}), _temp));
|
|
461
151
|
}
|
|
462
152
|
|
|
463
153
|
_createClass(TreeView, [{
|
|
464
|
-
key: "componentDidMount",
|
|
465
|
-
value: function componentDidMount() {
|
|
466
|
-
this.buildTree(this.state.data, undefined, this.idsWithChildren);
|
|
467
|
-
}
|
|
468
|
-
}, {
|
|
469
154
|
key: "render",
|
|
470
155
|
value: function render() {
|
|
471
|
-
var _this$
|
|
472
|
-
customClass = _this$
|
|
473
|
-
bordered = _this$
|
|
474
|
-
children = _this$
|
|
475
|
-
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;
|
|
476
161
|
var data = this.state.data;
|
|
477
162
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Provider, {
|
|
478
163
|
value: this.getContextValues()
|
|
@@ -501,15 +186,7 @@ TreeView.propTypes = {
|
|
|
501
186
|
showCheckBox: _propTypes["default"].bool,
|
|
502
187
|
onSelectedIdsChange: _propTypes["default"].func,
|
|
503
188
|
children: _propTypes["default"].instanceOf(Object),
|
|
504
|
-
styleForContainer: _propTypes["default"].object
|
|
505
|
-
allowCheckAllChildren: _propTypes["default"].bool,
|
|
506
|
-
allowCheckAllAncestry: _propTypes["default"].bool,
|
|
507
|
-
defaultDisabledTooltip: _propTypes["default"].string,
|
|
508
|
-
nodeRightElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
509
|
-
nodeToolbarElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
510
|
-
nodeMenuButtonSize: _propTypes["default"].oneOf(['mini', 'small', 'medium', 'large', 'default']),
|
|
511
|
-
onNodeClick: _propTypes["default"].func,
|
|
512
|
-
nodeElementsValidations: _propTypes["default"].object
|
|
189
|
+
styleForContainer: _propTypes["default"].object
|
|
513
190
|
};
|
|
514
191
|
TreeView.defaultProps = {
|
|
515
192
|
customClass: '',
|
|
@@ -520,15 +197,7 @@ TreeView.defaultProps = {
|
|
|
520
197
|
showCheckBox: false,
|
|
521
198
|
onSelectedIdsChange: undefined,
|
|
522
199
|
children: undefined,
|
|
523
|
-
styleForContainer: {}
|
|
524
|
-
allowCheckAllChildren: false,
|
|
525
|
-
allowCheckAllAncestry: false,
|
|
526
|
-
defaultDisabledTooltip: '',
|
|
527
|
-
nodeRightElements: undefined,
|
|
528
|
-
nodeToolbarElements: undefined,
|
|
529
|
-
nodeMenuButtonSize: 'small',
|
|
530
|
-
onNodeClick: undefined,
|
|
531
|
-
nodeElementsValidations: undefined
|
|
200
|
+
styleForContainer: {}
|
|
532
201
|
};
|
|
533
202
|
var _default = TreeView;
|
|
534
203
|
exports["default"] = _default;
|