linear-react-components-ui 0.4.75-beta.10 → 0.4.75-beta.14
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 +21 -10
- package/lib/list/list.spec.js +611 -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/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 +16 -282
- package/lib/treeview/index.js +35 -444
- 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,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,88 +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;
|
|
136
|
+
var parentPropName = _this.props.parentPropName;
|
|
465
137
|
var childrenIds = [];
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
return i.id;
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
if (ids) {
|
|
473
|
-
var idWithChildren = {};
|
|
474
|
-
idWithChildren[node.id] = childrenIds;
|
|
475
|
-
Object.assign(ids, idWithChildren);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
|
|
138
|
+
if (node.itens && node.itens.length > 0) childrenIds = node.itens.map(function (i) {
|
|
139
|
+
return i.id;
|
|
140
|
+
});
|
|
479
141
|
return /*#__PURE__*/_react["default"].createElement(_Node["default"], {
|
|
480
142
|
key: "node-".concat(node.id),
|
|
481
143
|
node: node,
|
|
482
144
|
childrenIds: childrenIds,
|
|
483
|
-
|
|
484
|
-
parentId: parentId,
|
|
485
|
-
nodeRightElements: nodeRightElements,
|
|
486
|
-
nodeToolbarElements: nodeToolbarElements,
|
|
487
|
-
nodeElementsValidations: nodeElementsValidations,
|
|
488
|
-
nodeMenuButtonSize: nodeMenuButtonSize,
|
|
489
|
-
onNodeClick: onNodeClick,
|
|
490
|
-
handlerOnNodeOpen: _this.handleOnNodeOpen
|
|
145
|
+
parentId: parentId
|
|
491
146
|
}, childrenIds.length > 0 && node.itens.map(function (nodeitem) {
|
|
492
|
-
return _this.buildTree(nodeitem,
|
|
147
|
+
return _this.buildTree(nodeitem, nodeitem[parentPropName]);
|
|
493
148
|
}));
|
|
494
149
|
}
|
|
495
|
-
});
|
|
496
|
-
_this.idsWithChildren = {};
|
|
497
|
-
_this.state = {
|
|
498
|
-
data: _this.props.data,
|
|
499
|
-
propSelectedIds: _this.props.selectedIds,
|
|
500
|
-
selectedIds: _this.props.selectedIds,
|
|
501
|
-
isHandlingSelectedIds: false,
|
|
502
|
-
requiredParentsIds: [],
|
|
503
|
-
alreadyOpenedIds: []
|
|
504
|
-
};
|
|
505
|
-
return _this;
|
|
150
|
+
}), _temp));
|
|
506
151
|
}
|
|
507
152
|
|
|
508
153
|
_createClass(TreeView, [{
|
|
509
|
-
key: "componentDidMount",
|
|
510
|
-
value: function componentDidMount() {
|
|
511
|
-
this.buildTree(this.state.data, undefined, this.idsWithChildren);
|
|
512
|
-
}
|
|
513
|
-
}, {
|
|
514
|
-
key: "componentDidUpdate",
|
|
515
|
-
value: function componentDidUpdate(prevProps, prevState) {
|
|
516
|
-
var _this$state3 = this.state,
|
|
517
|
-
selectedIds = _this$state3.selectedIds,
|
|
518
|
-
propSelectedIds = _this$state3.propSelectedIds;
|
|
519
|
-
var allowCheckAllAncestry = this.props.allowCheckAllAncestry;
|
|
520
|
-
|
|
521
|
-
var isSameSelectedIds = _lodash["default"].isEqual(propSelectedIds.sort(), prevState.propSelectedIds.sort());
|
|
522
|
-
|
|
523
|
-
if (allowCheckAllAncestry && !isSameSelectedIds) this.handleNewSelectedIds(selectedIds);
|
|
524
|
-
}
|
|
525
|
-
}, {
|
|
526
154
|
key: "render",
|
|
527
155
|
value: function render() {
|
|
528
|
-
var _this$
|
|
529
|
-
customClass = _this$
|
|
530
|
-
bordered = _this$
|
|
531
|
-
children = _this$
|
|
532
|
-
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;
|
|
533
161
|
var data = this.state.data;
|
|
534
162
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Provider, {
|
|
535
163
|
value: this.getContextValues()
|
|
@@ -540,25 +168,6 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
540
168
|
className: "treeviewcontainer ".concat(bordered && '-bordered')
|
|
541
169
|
}, this.buildTree(data))));
|
|
542
170
|
}
|
|
543
|
-
}], [{
|
|
544
|
-
key: "getDerivedStateFromProps",
|
|
545
|
-
value: function getDerivedStateFromProps(props, state) {
|
|
546
|
-
var data = props.data,
|
|
547
|
-
selectedIds = props.selectedIds;
|
|
548
|
-
var propSelectedIds = state.propSelectedIds;
|
|
549
|
-
|
|
550
|
-
var isSameSelectedIds = _lodash["default"].isEqual(propSelectedIds.sort(), selectedIds.sort());
|
|
551
|
-
|
|
552
|
-
if (data !== state.data || !isSameSelectedIds) {
|
|
553
|
-
return {
|
|
554
|
-
data: data,
|
|
555
|
-
selectedIds: selectedIds,
|
|
556
|
-
propSelectedIds: selectedIds
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
return null;
|
|
561
|
-
}
|
|
562
171
|
}]);
|
|
563
172
|
|
|
564
173
|
return TreeView;
|
|
@@ -577,16 +186,7 @@ TreeView.propTypes = {
|
|
|
577
186
|
showCheckBox: _propTypes["default"].bool,
|
|
578
187
|
onSelectedIdsChange: _propTypes["default"].func,
|
|
579
188
|
children: _propTypes["default"].instanceOf(Object),
|
|
580
|
-
styleForContainer: _propTypes["default"].object
|
|
581
|
-
allowCheckAllChildren: _propTypes["default"].bool,
|
|
582
|
-
allowCheckAllAncestry: _propTypes["default"].bool,
|
|
583
|
-
defaultDisabledTooltip: _propTypes["default"].string,
|
|
584
|
-
nodeRightElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
585
|
-
nodeToolbarElements: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].object), _propTypes["default"].element, _propTypes["default"].object]),
|
|
586
|
-
nodeMenuButtonSize: _propTypes["default"].oneOf(['mini', 'small', 'medium', 'large', 'default']),
|
|
587
|
-
onNodeClick: _propTypes["default"].func,
|
|
588
|
-
onNodeOpen: _propTypes["default"].func,
|
|
589
|
-
nodeElementsValidations: _propTypes["default"].object
|
|
189
|
+
styleForContainer: _propTypes["default"].object
|
|
590
190
|
};
|
|
591
191
|
TreeView.defaultProps = {
|
|
592
192
|
customClass: '',
|
|
@@ -597,16 +197,7 @@ TreeView.defaultProps = {
|
|
|
597
197
|
showCheckBox: false,
|
|
598
198
|
onSelectedIdsChange: undefined,
|
|
599
199
|
children: undefined,
|
|
600
|
-
styleForContainer: {}
|
|
601
|
-
allowCheckAllChildren: false,
|
|
602
|
-
allowCheckAllAncestry: false,
|
|
603
|
-
defaultDisabledTooltip: '',
|
|
604
|
-
nodeRightElements: undefined,
|
|
605
|
-
nodeToolbarElements: undefined,
|
|
606
|
-
nodeMenuButtonSize: 'small',
|
|
607
|
-
onNodeClick: undefined,
|
|
608
|
-
onNodeOpen: undefined,
|
|
609
|
-
nodeElementsValidations: undefined
|
|
200
|
+
styleForContainer: {}
|
|
610
201
|
};
|
|
611
202
|
var _default = TreeView;
|
|
612
203
|
exports["default"] = _default;
|