linear-react-components-ui 0.4.76-beta.8 → 0.4.76-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/lib/assets/styles/dropdown.scss +3 -0
- package/lib/assets/styles/tabs.scss +0 -1
- package/lib/dialog/base/index.js +1 -1
- package/lib/form/index.js +194 -273
- package/lib/form/withFormSecurity.js +8 -8
- package/lib/internals/withTooltip.js +13 -10
- package/lib/tabs/index.js +14 -16
- package/lib/tabs/tabs.spec.js +8 -5
- package/lib/tooltip/index.js +8 -7
- package/lib/treeview/Node.js +210 -199
- package/lib/treeview/index.js +11 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -53,8 +53,18 @@ Caso queira gerar uma build com versão beta e fazer a publicação no npm rode
|
|
|
53
53
|
|
|
54
54
|
`npm run publish:npm --tag beta`
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
Caso queira gerar uma build com versão candidata e fazer a publicação no npm rode os comandos da seguinte forma:
|
|
57
|
+
|
|
58
|
+
`npm version <versão>`
|
|
59
|
+
|
|
60
|
+
`npm run publish:npm --tag rc`
|
|
61
|
+
|
|
62
|
+
no local onde esta denominado o campo versão, você deverá colocar a nova versão do pacote, alguns exemplos para o campo versão:
|
|
63
|
+
- release: 0.4.75
|
|
64
|
+
- beta: 0.4.75-beta.0
|
|
65
|
+
- candidata: 0.4.75-rc.0
|
|
66
|
+
|
|
67
|
+
ficando da seguinte maneira:
|
|
58
68
|
|
|
59
69
|
`npm version 0.4.75`
|
|
60
70
|
|
package/lib/dialog/base/index.js
CHANGED
|
@@ -52,7 +52,7 @@ var BaseDialog = function BaseDialog(props) {
|
|
|
52
52
|
var dialogAlert = document.getElementsByClassName('dialog-alert-wrapper');
|
|
53
53
|
|
|
54
54
|
if (wrapperEl !== null && wrapperEl.current !== null && target !== wrapperEl.current && !wrapperEl.current.contains(target)) {
|
|
55
|
-
if (dialogAlert.length > 0 && dialogAlert[dialogAlert.length - 1].contains(target) || target.
|
|
55
|
+
if (dialogAlert.length > 0 && dialogAlert[dialogAlert.length - 1].contains(target) || target.classList.contains('button-component')) return;
|
|
56
56
|
handlerClose();
|
|
57
57
|
}
|
|
58
58
|
};
|
package/lib/form/index.js
CHANGED
|
@@ -51,317 +51,238 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
51
51
|
|
|
52
52
|
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; }
|
|
53
53
|
|
|
54
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
55
|
+
|
|
56
|
+
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); }
|
|
57
|
+
|
|
54
58
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
55
59
|
|
|
56
60
|
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."); }
|
|
57
61
|
|
|
58
|
-
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); }
|
|
59
|
-
|
|
60
62
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
61
63
|
|
|
62
64
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
63
65
|
|
|
64
|
-
function
|
|
66
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
65
67
|
|
|
66
|
-
function
|
|
68
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
67
69
|
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
70
|
+
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); }
|
|
71
71
|
|
|
72
|
-
function
|
|
72
|
+
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; }
|
|
73
73
|
|
|
74
|
-
function
|
|
74
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
75
|
+
|
|
76
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
77
|
+
|
|
78
|
+
var Form = function Form(_ref) {
|
|
79
|
+
var submitOnPressEnterKey = _ref.submitOnPressEnterKey,
|
|
80
|
+
dataSource = _ref.dataSource,
|
|
81
|
+
securityBeforeUnload = _ref.securityBeforeUnload,
|
|
82
|
+
handlerReset = _ref.handlerReset,
|
|
83
|
+
handlerSubmit = _ref.handlerSubmit,
|
|
84
|
+
children = _ref.children,
|
|
85
|
+
handlerValidates = _ref.handlerValidates,
|
|
86
|
+
style = _ref.style,
|
|
87
|
+
customClass = _ref.customClass,
|
|
88
|
+
securityTitle = _ref.securityTitle,
|
|
89
|
+
securityText = _ref.securityText,
|
|
90
|
+
onDataChange = _ref.onDataChange,
|
|
91
|
+
onValidateForm = _ref.onValidateForm,
|
|
92
|
+
externalFieldErrors = _ref.externalFieldErrors,
|
|
93
|
+
onSubmit = _ref.onSubmit;
|
|
94
|
+
|
|
95
|
+
var _useState = (0, _react.useState)(dataSource),
|
|
96
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
97
|
+
data = _useState2[0],
|
|
98
|
+
setData = _useState2[1];
|
|
99
|
+
|
|
100
|
+
var _useState3 = (0, _react.useState)(dataSource),
|
|
101
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
102
|
+
originalData = _useState4[0],
|
|
103
|
+
setOriginalData = _useState4[1];
|
|
104
|
+
|
|
105
|
+
var _useState5 = (0, _react.useState)(submitOnPressEnterKey),
|
|
106
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
107
|
+
submitFormOnEnter = _useState6[0],
|
|
108
|
+
setSubmitFormOnEnter = _useState6[1];
|
|
109
|
+
|
|
110
|
+
var _useState7 = (0, _react.useState)({}),
|
|
111
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
112
|
+
fieldErrors = _useState8[0],
|
|
113
|
+
setFieldErrors = _useState8[1];
|
|
114
|
+
|
|
115
|
+
var _useState9 = (0, _react.useState)({}),
|
|
116
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
117
|
+
fieldsValidators = _useState10[0],
|
|
118
|
+
setFieldsValidators = _useState10[1];
|
|
119
|
+
|
|
120
|
+
var context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
121
|
+
|
|
122
|
+
var getValidatesErrorMessages = function getValidatesErrorMessages(validators, fieldValue) {
|
|
123
|
+
var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
124
|
+
var errors = [];
|
|
125
|
+
validatorsArray.forEach(function (validator) {
|
|
126
|
+
var result = validator(fieldValue);
|
|
127
|
+
if (result) errors = [].concat(_toConsumableArray(errors), [result]);
|
|
128
|
+
});
|
|
129
|
+
return errors;
|
|
130
|
+
};
|
|
75
131
|
|
|
76
|
-
|
|
132
|
+
var checkIsValid = function checkIsValid(value) {
|
|
133
|
+
var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
134
|
+
var dataValidate = value || data;
|
|
135
|
+
var currentFieldErrors = {};
|
|
77
136
|
|
|
78
|
-
|
|
137
|
+
_lodash["default"].forEach(fieldsValidators, function (validators, fieldName) {
|
|
138
|
+
var fieldValue = _lodash["default"].get(dataValidate, fieldName);
|
|
79
139
|
|
|
80
|
-
|
|
140
|
+
var messages = getValidatesErrorMessages(validators, fieldValue);
|
|
81
141
|
|
|
82
|
-
|
|
142
|
+
if (messages.length > 0) {
|
|
143
|
+
currentFieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, messages));
|
|
144
|
+
}
|
|
145
|
+
});
|
|
83
146
|
|
|
84
|
-
|
|
147
|
+
if (updateState) setFieldErrors(currentFieldErrors);
|
|
148
|
+
return _lodash["default"].isEmpty(currentFieldErrors);
|
|
149
|
+
};
|
|
85
150
|
|
|
86
|
-
|
|
151
|
+
var onFieldChange = function onFieldChange(e) {
|
|
152
|
+
var _e$target = e.target,
|
|
153
|
+
name = _e$target.name,
|
|
154
|
+
value = _e$target.value;
|
|
87
155
|
|
|
88
|
-
|
|
156
|
+
_lodash["default"].set(data, name, value);
|
|
89
157
|
|
|
90
|
-
var
|
|
91
|
-
_inherits(Form, _Component);
|
|
158
|
+
var newData = _extends({}, data);
|
|
92
159
|
|
|
93
|
-
|
|
160
|
+
if (context && context.onChangedData) {
|
|
161
|
+
var onChangedData = context.onChangedData;
|
|
94
162
|
|
|
95
|
-
|
|
96
|
-
|
|
163
|
+
if (!_lodash["default"].isEqual(newData, originalData)) {
|
|
164
|
+
onChangedData(true);
|
|
165
|
+
} else {
|
|
166
|
+
onChangedData(false);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
97
169
|
|
|
98
|
-
|
|
170
|
+
setData(newData); // TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
99
171
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
enumerable: true,
|
|
104
|
-
writable: true,
|
|
105
|
-
value: function value(e) {
|
|
106
|
-
e.preventDefault();
|
|
172
|
+
if (onValidateForm) onValidateForm(checkIsValid(newData, false));
|
|
173
|
+
if (onDataChange) onDataChange(newData);
|
|
174
|
+
};
|
|
107
175
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
176
|
+
var onValidate = function onValidate(fieldName, fieldValue, validators) {
|
|
177
|
+
if (validators) {
|
|
178
|
+
var currentFieldErrors = fieldErrors;
|
|
179
|
+
var errors = getValidatesErrorMessages(validators, fieldValue);
|
|
111
180
|
|
|
112
|
-
|
|
181
|
+
if (errors.length === 0) {
|
|
182
|
+
currentFieldErrors = _lodash["default"].omit(currentFieldErrors, fieldName);
|
|
183
|
+
} else {
|
|
184
|
+
currentFieldErrors = _extends({}, currentFieldErrors, _defineProperty({}, fieldName, errors));
|
|
113
185
|
}
|
|
114
|
-
});
|
|
115
|
-
Object.defineProperty(_assertThisInitialized(_this), "onFieldChange", {
|
|
116
|
-
configurable: true,
|
|
117
|
-
enumerable: true,
|
|
118
|
-
writable: true,
|
|
119
|
-
value: function value(e) {
|
|
120
|
-
var _this$props = _this.props,
|
|
121
|
-
onValidateForm = _this$props.onValidateForm,
|
|
122
|
-
onDataChange = _this$props.onDataChange;
|
|
123
|
-
var data = _this.state.data;
|
|
124
|
-
var _e$target = e.target,
|
|
125
|
-
name = _e$target.name,
|
|
126
|
-
value = _e$target.value;
|
|
127
|
-
var onChangedData = _this.context.onChangedData;
|
|
128
|
-
|
|
129
|
-
_lodash["default"].set(data, name, value);
|
|
130
|
-
|
|
131
|
-
_this.setState({
|
|
132
|
-
data: data
|
|
133
|
-
});
|
|
134
186
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
onChangedData(false);
|
|
139
|
-
} // TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
187
|
+
setFieldErrors(currentFieldErrors);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
140
190
|
|
|
191
|
+
var onFormSubmit = function onFormSubmit(event) {
|
|
192
|
+
if (event) event.preventDefault();
|
|
193
|
+
if (checkIsValid(data)) onSubmit(data);
|
|
194
|
+
};
|
|
141
195
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Object.defineProperty(_assertThisInitialized(_this), "onValidate", {
|
|
147
|
-
configurable: true,
|
|
148
|
-
enumerable: true,
|
|
149
|
-
writable: true,
|
|
150
|
-
value: function value(fieldName, fieldValue, validators) {
|
|
151
|
-
if (validators) {
|
|
152
|
-
var fieldErrors = _this.state.fieldErrors;
|
|
153
|
-
|
|
154
|
-
var errors = _this.getValidatesErrorMessages(validators, fieldValue);
|
|
155
|
-
|
|
156
|
-
if (errors.length === 0) {
|
|
157
|
-
fieldErrors = _lodash["default"].omit(fieldErrors, fieldName);
|
|
158
|
-
} else {
|
|
159
|
-
fieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, errors));
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
_this.setState({
|
|
163
|
-
fieldErrors: fieldErrors
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
Object.defineProperty(_assertThisInitialized(_this), "onSubmit", {
|
|
169
|
-
configurable: true,
|
|
170
|
-
enumerable: true,
|
|
171
|
-
writable: true,
|
|
172
|
-
value: function value(event) {
|
|
173
|
-
if (event) event.preventDefault();
|
|
174
|
-
var data = _this.state.data;
|
|
175
|
-
if (_this.checkIsValid(data)) _this.props.onSubmit(data);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
Object.defineProperty(_assertThisInitialized(_this), "onReset", {
|
|
179
|
-
configurable: true,
|
|
180
|
-
enumerable: true,
|
|
181
|
-
writable: true,
|
|
182
|
-
value: function value() {
|
|
183
|
-
_this.setState({
|
|
184
|
-
data: JSON.parse(JSON.stringify(_this.state.originalData)),
|
|
185
|
-
fieldErrors: {}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
Object.defineProperty(_assertThisInitialized(_this), "onRemoveFieldValidators", {
|
|
190
|
-
configurable: true,
|
|
191
|
-
enumerable: true,
|
|
192
|
-
writable: true,
|
|
193
|
-
value: function value(fieldName) {
|
|
194
|
-
_this.fieldsValidators = _lodash["default"].omit(_this.fieldsValidators, fieldName);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
Object.defineProperty(_assertThisInitialized(_this), "getValidatesErrorMessages", {
|
|
198
|
-
configurable: true,
|
|
199
|
-
enumerable: true,
|
|
200
|
-
writable: true,
|
|
201
|
-
value: function value(validators, fieldValue) {
|
|
202
|
-
var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
203
|
-
var errors = [];
|
|
204
|
-
validatorsArray.forEach(function (validator) {
|
|
205
|
-
var result = validator(fieldValue);
|
|
206
|
-
if (result) errors = [].concat(_toConsumableArray(errors), [result]);
|
|
207
|
-
});
|
|
208
|
-
return errors;
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
Object.defineProperty(_assertThisInitialized(_this), "getContextValue", {
|
|
212
|
-
configurable: true,
|
|
213
|
-
enumerable: true,
|
|
214
|
-
writable: true,
|
|
215
|
-
value: function value() {
|
|
216
|
-
return {
|
|
217
|
-
handlerFieldChange: _this.onFieldChange,
|
|
218
|
-
handlerFieldValidade: _this.onValidate,
|
|
219
|
-
handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
|
|
220
|
-
_this.fieldsValidators = _extends({}, _this.fieldsValidators, _defineProperty({}, fieldName, fieldValidates));
|
|
221
|
-
},
|
|
222
|
-
handlerRemoveValidators: _this.onRemoveFieldValidators,
|
|
223
|
-
data: _this.state.data,
|
|
224
|
-
fieldErrors: _this.state.fieldErrors,
|
|
225
|
-
externalFieldErrors: _this.props.externalFieldErrors
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
Object.defineProperty(_assertThisInitialized(_this), "checkIsValid", {
|
|
230
|
-
configurable: true,
|
|
231
|
-
enumerable: true,
|
|
232
|
-
writable: true,
|
|
233
|
-
value: function value(data) {
|
|
234
|
-
var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
235
|
-
var dataValidate = data || _this.state.data;
|
|
236
|
-
var fieldErrors = {};
|
|
237
|
-
|
|
238
|
-
_lodash["default"].forEach(_this.fieldsValidators, function (validators, fieldName) {
|
|
239
|
-
var fieldValue = _lodash["default"].get(dataValidate, fieldName);
|
|
240
|
-
|
|
241
|
-
var messages = _this.getValidatesErrorMessages(validators, fieldValue);
|
|
242
|
-
|
|
243
|
-
if (messages.length > 0) {
|
|
244
|
-
fieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, messages));
|
|
245
|
-
}
|
|
246
|
-
});
|
|
196
|
+
var onReset = function onReset() {
|
|
197
|
+
setData(JSON.parse(JSON.stringify(originalData)));
|
|
198
|
+
setFieldErrors({});
|
|
199
|
+
};
|
|
247
200
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
});
|
|
251
|
-
return _lodash["default"].isEmpty(fieldErrors);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
Object.defineProperty(_assertThisInitialized(_this), "submitOnEnter", {
|
|
255
|
-
configurable: true,
|
|
256
|
-
enumerable: true,
|
|
257
|
-
writable: true,
|
|
258
|
-
value: function value(event) {
|
|
259
|
-
if (event.key === 'Enter') {
|
|
260
|
-
event.preventDefault();
|
|
261
|
-
if (_this.state.submitFormOnEnter) _this.onSubmit();
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
_this.fieldsValidators = {};
|
|
266
|
-
var dataSource = props.dataSource,
|
|
267
|
-
submitOnPressEnterKey = props.submitOnPressEnterKey;
|
|
268
|
-
_this.state = {
|
|
269
|
-
data: dataSource,
|
|
270
|
-
originalData: dataSource,
|
|
271
|
-
fieldErrors: {},
|
|
272
|
-
submitFormOnEnter: submitOnPressEnterKey
|
|
273
|
-
};
|
|
274
|
-
return _this;
|
|
275
|
-
}
|
|
201
|
+
var onRemoveFieldValidators = function onRemoveFieldValidators(fieldName) {
|
|
202
|
+
var newFieldsValidators = _lodash["default"].omit(fieldsValidators, fieldName);
|
|
276
203
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var setSecurityBeforeUnload = this.context.setSecurityBeforeUnload;
|
|
286
|
-
handlerSubmit(this.onSubmit);
|
|
287
|
-
if (handlerReset) handlerReset(this.onReset);
|
|
288
|
-
if (handlerValidates) handlerValidates(this.checkIsValid);
|
|
289
|
-
|
|
290
|
-
if (securityBeforeUnload) {
|
|
291
|
-
setSecurityBeforeUnload(true);
|
|
292
|
-
window.addEventListener('beforeunload', this.onBeforeUnload);
|
|
293
|
-
}
|
|
204
|
+
setFieldsValidators(newFieldsValidators);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var onBeforeUnload = function onBeforeUnload(e) {
|
|
208
|
+
e.preventDefault();
|
|
209
|
+
|
|
210
|
+
if (_lodash["default"].isEqual(data, originalData)) {
|
|
211
|
+
return;
|
|
294
212
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
213
|
+
|
|
214
|
+
e.returnValue = true;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
var submitOnEnter = function submitOnEnter(event) {
|
|
218
|
+
if (event.key === 'Enter') {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
if (submitFormOnEnter) onFormSubmit();
|
|
299
221
|
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
className: "form-component ".concat(customClass)
|
|
328
|
-
}, children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
329
|
-
zIndex: "99999999",
|
|
330
|
-
customClassName: "classTeste",
|
|
331
|
-
title: securityTitle || 'Dados Alterados',
|
|
332
|
-
text: securityText || 'Vocẽ possui dados alterados, confirma o fechamento?',
|
|
333
|
-
visible: securityBeforeUnload && showQuestion,
|
|
334
|
-
onConfirmClick: onConfirmClick,
|
|
335
|
-
onUnconfirmClick: onUnconfirmClick
|
|
336
|
-
}));
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
var getContextValue = function getContextValue() {
|
|
225
|
+
return {
|
|
226
|
+
handlerFieldChange: onFieldChange,
|
|
227
|
+
handlerFieldValidade: onValidate,
|
|
228
|
+
handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
|
|
229
|
+
setFieldsValidators(function (prevState) {
|
|
230
|
+
return _extends({}, prevState, _defineProperty({}, fieldName, fieldValidates));
|
|
231
|
+
});
|
|
232
|
+
},
|
|
233
|
+
handlerRemoveValidators: onRemoveFieldValidators,
|
|
234
|
+
data: data,
|
|
235
|
+
fieldErrors: fieldErrors,
|
|
236
|
+
externalFieldErrors: externalFieldErrors
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
(0, _react.useEffect)(function () {
|
|
241
|
+
handlerSubmit(onFormSubmit);
|
|
242
|
+
if (handlerReset) handlerReset(onReset);
|
|
243
|
+
if (handlerValidates) handlerValidates(checkIsValid);
|
|
244
|
+
}, [data]);
|
|
245
|
+
(0, _react.useEffect)(function () {
|
|
246
|
+
if (securityBeforeUnload) {
|
|
247
|
+
if (context) context.setSecurityBeforeUnload(true);
|
|
248
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
337
249
|
}
|
|
338
|
-
}], [{
|
|
339
|
-
key: "getDerivedStateFromProps",
|
|
340
|
-
value: function getDerivedStateFromProps(props, state) {
|
|
341
|
-
var submitOnPressEnterKey = props.submitOnPressEnterKey,
|
|
342
|
-
dataSource = props.dataSource;
|
|
343
|
-
|
|
344
|
-
if (submitOnPressEnterKey !== state.submitFormOnEnter || dataSource !== state.originalData) {
|
|
345
|
-
return {
|
|
346
|
-
submitFormOnEnter: submitOnPressEnterKey,
|
|
347
|
-
data: dataSource,
|
|
348
|
-
originalData: state.originalData || dataSource
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
250
|
|
|
352
|
-
|
|
251
|
+
return function () {
|
|
252
|
+
return window.removeEventListener('beforeunload', onBeforeUnload);
|
|
253
|
+
};
|
|
254
|
+
}, [securityBeforeUnload, onBeforeUnload]);
|
|
255
|
+
(0, _react.useEffect)(function () {
|
|
256
|
+
if (submitOnPressEnterKey !== submitFormOnEnter || dataSource !== originalData) {
|
|
257
|
+
setData(dataSource);
|
|
258
|
+
setOriginalData(function (prevState) {
|
|
259
|
+
return prevState || dataSource;
|
|
260
|
+
});
|
|
261
|
+
setSubmitFormOnEnter(submitOnPressEnterKey);
|
|
353
262
|
}
|
|
354
|
-
}]);
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
263
|
+
}, [submitOnPressEnterKey, dataSource]);
|
|
264
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_helpers.FormContext.Provider, {
|
|
265
|
+
value: getContextValue()
|
|
266
|
+
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
267
|
+
style: style,
|
|
268
|
+
onSubmit: function onSubmit(e) {
|
|
269
|
+
return e.preventDefault();
|
|
270
|
+
},
|
|
271
|
+
onKeyPress: function onKeyPress(e) {
|
|
272
|
+
return submitOnEnter(e);
|
|
273
|
+
},
|
|
274
|
+
role: "presentation",
|
|
275
|
+
className: "form-component ".concat(customClass)
|
|
276
|
+
}, children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
277
|
+
zIndex: "99999999",
|
|
278
|
+
title: securityTitle || 'Dados Alterados',
|
|
279
|
+
text: securityText || 'Você possui dados alterados, confirma o fechamento?',
|
|
280
|
+
visible: !!context && context.showQuestion,
|
|
281
|
+
onConfirmClick: context ? context.onConfirmClick : function () {},
|
|
282
|
+
onUnconfirmClick: context ? context.onUnconfirmClick : function () {}
|
|
283
|
+
}));
|
|
284
|
+
};
|
|
358
285
|
|
|
359
|
-
Object.defineProperty(Form, "contextType", {
|
|
360
|
-
configurable: true,
|
|
361
|
-
enumerable: true,
|
|
362
|
-
writable: true,
|
|
363
|
-
value: _withFormSecurity.FormSecurityContext
|
|
364
|
-
});
|
|
365
286
|
Form.propTypes = {
|
|
366
287
|
dataSource: _propTypes["default"].object.isRequired,
|
|
367
288
|
children: _propTypes["default"].any.isRequired,
|
|
@@ -47,19 +47,15 @@ var withFormSecurity = function withFormSecurity(WrappedComponent) {
|
|
|
47
47
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
48
48
|
|
|
49
49
|
var changedData = (0, _react.useRef)(false);
|
|
50
|
+
var securityBeforeUnload = (0, _react.useRef)(false);
|
|
50
51
|
|
|
51
52
|
var _useState = (0, _react.useState)(false),
|
|
52
53
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var _useState3 = (0, _react.useState)(false),
|
|
57
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
58
|
-
showQuestion = _useState4[0],
|
|
59
|
-
setShowQuestion = _useState4[1];
|
|
54
|
+
showQuestion = _useState2[0],
|
|
55
|
+
setShowQuestion = _useState2[1];
|
|
60
56
|
|
|
61
57
|
var newHandlerClose = function newHandlerClose() {
|
|
62
|
-
if (changedData.current && securityBeforeUnload) {
|
|
58
|
+
if (changedData.current && securityBeforeUnload.current) {
|
|
63
59
|
setShowQuestion(true);
|
|
64
60
|
} else {
|
|
65
61
|
handlerClose();
|
|
@@ -78,6 +74,10 @@ var withFormSecurity = function withFormSecurity(WrappedComponent) {
|
|
|
78
74
|
changedData.current = value;
|
|
79
75
|
};
|
|
80
76
|
|
|
77
|
+
var setSecurityBeforeUnload = function setSecurityBeforeUnload(value) {
|
|
78
|
+
securityBeforeUnload.current = value;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
81
|
return /*#__PURE__*/_react["default"].createElement(FormSecurityContext.Provider, {
|
|
82
82
|
value: {
|
|
83
83
|
onChangedData: onChangedData,
|
|
@@ -73,10 +73,11 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
73
73
|
tooltipDimensions = _useState8[0],
|
|
74
74
|
setTooltipDimensions = _useState8[1];
|
|
75
75
|
|
|
76
|
-
var targetElement = (0, _react.useRef)();
|
|
76
|
+
var targetElement = (0, _react.useRef)(null);
|
|
77
|
+
var tooltipElement = (0, _react.useRef)(null);
|
|
77
78
|
|
|
78
79
|
var onMouseOver = function onMouseOver(e) {
|
|
79
|
-
if (targetElement.current.contains(e.target)) {
|
|
80
|
+
if (targetElement && targetElement.current && targetElement.current.contains(e.target)) {
|
|
80
81
|
setShowTooltip(true);
|
|
81
82
|
} else setShowTooltip(false);
|
|
82
83
|
};
|
|
@@ -116,9 +117,10 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
116
117
|
height = tooltipDimensions.height;
|
|
117
118
|
var targetDimensions = targetElement.current.getBoundingClientRect();
|
|
118
119
|
var targetVerticalCenter = (targetDimensions.top + targetDimensions.bottom) / 2;
|
|
119
|
-
var
|
|
120
|
-
var
|
|
121
|
-
left =
|
|
120
|
+
var tooltipClientWidth = tooltipElement.current && tooltipElement.current.clientWidth;
|
|
121
|
+
var style = "width: ".concat(typeof width === 'string' ? width : "".concat(width, "px"));
|
|
122
|
+
var left = targetDimensions.left + targetDimensions.width / 2 - tooltipClientWidth / 2;
|
|
123
|
+
left = Math.min(left, document.body.clientWidth - tooltipClientWidth - space);
|
|
122
124
|
style += "; left: ".concat(Math.max(space, left), "px");
|
|
123
125
|
|
|
124
126
|
switch (tooltipPosition) {
|
|
@@ -141,17 +143,17 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
141
143
|
break;
|
|
142
144
|
|
|
143
145
|
case 'left':
|
|
144
|
-
if (targetDimensions.left <
|
|
146
|
+
if (targetDimensions.left < tooltipClientWidth) {
|
|
145
147
|
setTooltipPosition('right');
|
|
146
148
|
} else {
|
|
147
149
|
style += "; top: ".concat(targetVerticalCenter + window.scrollY - height / 2, "px");
|
|
148
|
-
style += "; left: ".concat(targetDimensions.left -
|
|
150
|
+
style += "; left: ".concat(targetDimensions.left - tooltipClientWidth - 6, "px");
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
break;
|
|
152
154
|
|
|
153
155
|
case 'right':
|
|
154
|
-
if (window.innerWidth - targetDimensions.right <
|
|
156
|
+
if (window.innerWidth - targetDimensions.right < tooltipClientWidth) {
|
|
155
157
|
setTooltipPosition('left');
|
|
156
158
|
} else {
|
|
157
159
|
style += "; top: ".concat(targetVerticalCenter + window.scrollY - height / 2, "px");
|
|
@@ -166,7 +168,7 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
166
168
|
|
|
167
169
|
setTooltipStyle(style);
|
|
168
170
|
}
|
|
169
|
-
}, [tooltipDimensions, targetElement.current, tooltipPosition]);
|
|
171
|
+
}, [tooltipDimensions, tooltipElement.current, targetElement.current, tooltipPosition]);
|
|
170
172
|
(0, _react.useEffect)(function () {
|
|
171
173
|
setTooltipPosition(props.tooltipPosition);
|
|
172
174
|
}, [window.scrollY, window.scrollX, window.innerWidth]);
|
|
@@ -175,6 +177,7 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
175
177
|
if (tooltip) {
|
|
176
178
|
return /*#__PURE__*/_react["default"].createElement(_tooltip["default"], {
|
|
177
179
|
text: tooltip,
|
|
180
|
+
tooltipRef: tooltipElement,
|
|
178
181
|
style: tooltipStyle,
|
|
179
182
|
className: tooltipPosition,
|
|
180
183
|
tooltipDimensions: tooltipDimensions,
|
|
@@ -202,7 +205,7 @@ var withTooltip = function withTooltip(WrappedComponent) {
|
|
|
202
205
|
tooltipPosition: _propTypes["default"].string
|
|
203
206
|
};
|
|
204
207
|
EnhancedComponent.defaultProps = {
|
|
205
|
-
tooltipWidth:
|
|
208
|
+
tooltipWidth: 'auto',
|
|
206
209
|
space: 20,
|
|
207
210
|
tooltip: '',
|
|
208
211
|
tooltipPosition: 'bottom'
|
package/lib/tabs/index.js
CHANGED
|
@@ -133,32 +133,30 @@ var Tabs = function Tabs(props) {
|
|
|
133
133
|
var getTabsList = function getTabsList() {
|
|
134
134
|
var tabsListWidth = getTabListWidth();
|
|
135
135
|
|
|
136
|
-
var
|
|
136
|
+
var newDropdownPanels = _toConsumableArray(dropdownPanels);
|
|
137
137
|
|
|
138
|
-
var
|
|
138
|
+
var newCurrentPanels = _toConsumableArray(panels);
|
|
139
139
|
|
|
140
|
-
if (
|
|
141
|
-
var
|
|
140
|
+
if (newDropdownPanels.length) {
|
|
141
|
+
var newDropdownPanelsIds = newDropdownPanels.map(function (dd) {
|
|
142
142
|
return dd.props.id;
|
|
143
143
|
});
|
|
144
|
-
|
|
145
|
-
return !
|
|
144
|
+
newCurrentPanels = newCurrentPanels.filter(function (tab) {
|
|
145
|
+
return !newDropdownPanelsIds.includes(tab.props.id);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
console.log(tabsListWidth, tabsContentWidth);
|
|
150
|
-
|
|
151
149
|
if (tabsListWidth > tabsContentWidth) {
|
|
152
|
-
var lastPanel =
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
} else if (tabsListWidth + 110 < tabsContentWidth &&
|
|
156
|
-
|
|
157
|
-
|
|
150
|
+
var lastPanel = newCurrentPanels[newCurrentPanels.length - 1];
|
|
151
|
+
newDropdownPanels.push(lastPanel);
|
|
152
|
+
newCurrentPanels.pop();
|
|
153
|
+
} else if (tabsListWidth + 110 < tabsContentWidth && newDropdownPanels.length) {
|
|
154
|
+
newCurrentPanels.push(newDropdownPanels[0]);
|
|
155
|
+
newDropdownPanels.shift();
|
|
158
156
|
}
|
|
159
157
|
|
|
160
|
-
setCurrentPanels(
|
|
161
|
-
setDropdownPanels(
|
|
158
|
+
setCurrentPanels(newCurrentPanels);
|
|
159
|
+
setDropdownPanels(newDropdownPanels);
|
|
162
160
|
};
|
|
163
161
|
|
|
164
162
|
var onMenuClick = function onMenuClick(tabId) {
|
package/lib/tabs/tabs.spec.js
CHANGED
|
@@ -135,7 +135,7 @@ describe('Tabs', function () {
|
|
|
135
135
|
container = _render10.container;
|
|
136
136
|
|
|
137
137
|
expect(container.querySelector('.tabs-component')).toHaveClass('menu-bottom');
|
|
138
|
-
expect(container.querySelector('.tabs-component').lastChild).toHaveClass('
|
|
138
|
+
expect(container.querySelector('.tabs-component').lastChild).toHaveClass('menucontainer');
|
|
139
139
|
});
|
|
140
140
|
it('should apply tabMenuAlign', function () {
|
|
141
141
|
var _render11 = (0, _react2.render)(tabsMockRender({
|
|
@@ -328,7 +328,8 @@ describe('Tabs', function () {
|
|
|
328
328
|
})),
|
|
329
329
|
container = _render23.container;
|
|
330
330
|
|
|
331
|
-
|
|
331
|
+
var noPermissionComponent = container.querySelector('.no-permission-component');
|
|
332
|
+
expect(noPermissionComponent).toBeFalsy();
|
|
332
333
|
});
|
|
333
334
|
it('should check permission and be unavailable', function () {
|
|
334
335
|
Object.defineProperty(window, 'sessionStorage', {
|
|
@@ -336,11 +337,13 @@ describe('Tabs', function () {
|
|
|
336
337
|
});
|
|
337
338
|
|
|
338
339
|
var _render24 = (0, _react2.render)(tabsMockRender({}, {
|
|
339
|
-
permissionAttr: (0, _storageMock.permissionAttrMockUnauthorized)('
|
|
340
|
+
permissionAttr: (0, _storageMock.permissionAttrMockUnauthorized)('hideContent')
|
|
340
341
|
})),
|
|
341
|
-
container = _render24.container;
|
|
342
|
+
container = _render24.container; // debug();
|
|
342
343
|
|
|
343
|
-
|
|
344
|
+
|
|
345
|
+
var noPermissionComponent = container.querySelector('.no-permission-component');
|
|
346
|
+
expect(noPermissionComponent).toBeTruthy();
|
|
344
347
|
});
|
|
345
348
|
});
|
|
346
349
|
});
|
package/lib/tooltip/index.js
CHANGED
|
@@ -28,15 +28,13 @@ var Tooltip = function Tooltip(props) {
|
|
|
28
28
|
tooltipDimensions = props.tooltipDimensions,
|
|
29
29
|
handlerSetDimensions = props.handlerSetDimensions,
|
|
30
30
|
style = props.style,
|
|
31
|
-
text = props.text
|
|
31
|
+
text = props.text,
|
|
32
|
+
tooltipRef = props.tooltipRef;
|
|
32
33
|
var tooltipComponent = (0, _react.useRef)(document.createElement('div'));
|
|
33
|
-
tooltipComponent.current.id = "tooltip-".concat(_uuid["default"].v1());
|
|
34
|
-
tooltipComponent.current.className = "tooltip-component ".concat(className, " ");
|
|
35
|
-
tooltipComponent.current.dataset.testid = 'tooltip-component';
|
|
36
|
-
tooltipComponent.current.style = style;
|
|
37
34
|
(0, _react.useEffect)(function () {
|
|
38
35
|
tooltipComponent.current.id = "tooltip-".concat(_uuid["default"].v1());
|
|
39
36
|
tooltipComponent.current.className = "tooltip-component ".concat(className, " ");
|
|
37
|
+
tooltipComponent.current.dataset.testid = 'tooltip-component';
|
|
40
38
|
tooltipComponent.current.style = style;
|
|
41
39
|
document.body.appendChild(tooltipComponent.current);
|
|
42
40
|
var tooltipEl = document.querySelector("div#".concat(tooltipComponent.current.id));
|
|
@@ -51,6 +49,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
51
49
|
width: width,
|
|
52
50
|
height: height
|
|
53
51
|
});
|
|
52
|
+
if (tooltipRef) tooltipRef.current = tooltipEl;
|
|
54
53
|
return function () {
|
|
55
54
|
return document.body.removeChild(tooltipComponent.current);
|
|
56
55
|
};
|
|
@@ -75,13 +74,15 @@ Tooltip.propTypes = {
|
|
|
75
74
|
text: _propTypes["default"].string,
|
|
76
75
|
style: _propTypes["default"].string,
|
|
77
76
|
className: _propTypes["default"].string,
|
|
78
|
-
handlerSetDimensions: _propTypes["default"].func
|
|
77
|
+
handlerSetDimensions: _propTypes["default"].func,
|
|
78
|
+
tooltipRef: _propTypes["default"].object
|
|
79
79
|
};
|
|
80
80
|
Tooltip.defaultProps = {
|
|
81
81
|
text: undefined,
|
|
82
82
|
className: 'bottom',
|
|
83
83
|
style: '',
|
|
84
|
-
handlerSetDimensions: undefined
|
|
84
|
+
handlerSetDimensions: undefined,
|
|
85
|
+
tooltipRef: null
|
|
85
86
|
};
|
|
86
87
|
var _default = Tooltip;
|
|
87
88
|
exports["default"] = _default;
|
package/lib/treeview/Node.js
CHANGED
|
@@ -33,6 +33,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
33
33
|
|
|
34
34
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
35
|
|
|
36
|
+
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); }
|
|
37
|
+
|
|
36
38
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
37
39
|
|
|
38
40
|
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."); }
|
|
@@ -45,8 +47,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
45
47
|
|
|
46
48
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
47
49
|
|
|
48
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
49
|
-
|
|
50
50
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
51
51
|
|
|
52
52
|
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); } }
|
|
@@ -78,193 +78,16 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
78
78
|
_classCallCheck(this, TreeNode);
|
|
79
79
|
|
|
80
80
|
_this = _super.call(this, props);
|
|
81
|
-
Object.defineProperty(_assertThisInitialized(_this), "getSpan", {
|
|
82
|
-
configurable: true,
|
|
83
|
-
enumerable: true,
|
|
84
|
-
writable: true,
|
|
85
|
-
value: function value() {
|
|
86
|
-
var _this$props = _this.props,
|
|
87
|
-
node = _this$props.node,
|
|
88
|
-
alwaysShowArrow = _this$props.alwaysShowArrow;
|
|
89
|
-
|
|
90
|
-
var span = /*#__PURE__*/_react["default"].createElement("noscript", null);
|
|
91
|
-
|
|
92
|
-
if (node.itens && node.itens.length > 0 || alwaysShowArrow) {
|
|
93
|
-
span = /*#__PURE__*/_react["default"].createElement("span", {
|
|
94
|
-
onKeyPress: null,
|
|
95
|
-
tabIndex: 0,
|
|
96
|
-
role: "button",
|
|
97
|
-
className: "opencloseicon",
|
|
98
|
-
onClick: function onClick() {
|
|
99
|
-
return _this.openCloseTree(node);
|
|
100
|
-
}
|
|
101
|
-
}, /*#__PURE__*/_react["default"].createElement(_icons["default"], {
|
|
102
|
-
name: _this.state.isVisible ? 'up' : 'down',
|
|
103
|
-
size: 10
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return span;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(_assertThisInitialized(_this), "openCloseTree", {
|
|
111
|
-
configurable: true,
|
|
112
|
-
enumerable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
value: function value(node) {
|
|
115
|
-
var _this$state = _this.state,
|
|
116
|
-
isVisible = _this$state.isVisible,
|
|
117
|
-
wasOpened = _this$state.wasOpened;
|
|
118
|
-
var handlerOnNodeOpen = _this.props.handlerOnNodeOpen;
|
|
119
|
-
var nextState = {
|
|
120
|
-
isVisible: !isVisible
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
if (!wasOpened && handlerOnNodeOpen) {
|
|
124
|
-
nextState = _extends({}, nextState, {
|
|
125
|
-
wasOpened: true
|
|
126
|
-
});
|
|
127
|
-
handlerOnNodeOpen(node);
|
|
128
|
-
}
|
|
129
81
|
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(_assertThisInitialized(_this), "handleShowNodeElements", {
|
|
134
|
-
configurable: true,
|
|
135
|
-
enumerable: true,
|
|
136
|
-
writable: true,
|
|
137
|
-
value: function value() {
|
|
138
|
-
var _this$state2 = _this.state,
|
|
139
|
-
showNodeElements = _this$state2.showNodeElements,
|
|
140
|
-
keepMenuOpened = _this$state2.keepMenuOpened;
|
|
141
|
-
if (!showNodeElements) _this.setState({
|
|
142
|
-
showNodeElements: true
|
|
143
|
-
});else if (showNodeElements && !keepMenuOpened) {
|
|
144
|
-
_this.setState({
|
|
145
|
-
showNodeElements: false
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
Object.defineProperty(_assertThisInitialized(_this), "updateElements", {
|
|
151
|
-
configurable: true,
|
|
152
|
-
enumerable: true,
|
|
153
|
-
writable: true,
|
|
154
|
-
value: function value(elements) {
|
|
155
|
-
var _this$props2 = _this.props,
|
|
156
|
-
node = _this$props2.node,
|
|
157
|
-
nodeElementsValidations = _this$props2.nodeElementsValidations;
|
|
158
|
-
var updatedElements = [];
|
|
159
|
-
|
|
160
|
-
if (elements) {
|
|
161
|
-
updatedElements = _react["default"].Children.map(elements, function (element) {
|
|
162
|
-
if ( /*#__PURE__*/_react["default"].isValidElement(element) && element.props) {
|
|
163
|
-
var _element$props = element.props,
|
|
164
|
-
validationKey = _element$props.validationKey,
|
|
165
|
-
onNodeElementClick = _element$props.onNodeElementClick;
|
|
166
|
-
var elementBehavior;
|
|
167
|
-
var newProps = {};
|
|
168
|
-
|
|
169
|
-
if (nodeElementsValidations && validationKey) {
|
|
170
|
-
elementBehavior = _this.validateNodeElement(validationKey);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (onNodeElementClick) {
|
|
174
|
-
newProps = _extends({}, newProps, {
|
|
175
|
-
onClick: function onClick(e) {
|
|
176
|
-
onNodeElementClick(node);
|
|
177
|
-
if (e.stopPropagation) e.stopPropagation();
|
|
178
|
-
},
|
|
179
|
-
onNodeElementClick: null
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return /*#__PURE__*/_react["default"].cloneElement(element, _extends({}, elementBehavior, newProps));
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return element;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return updatedElements;
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnNodeRightElements", {
|
|
194
|
-
configurable: true,
|
|
195
|
-
enumerable: true,
|
|
196
|
-
writable: true,
|
|
197
|
-
value: function value() {
|
|
198
|
-
var nodeRightElements = _this.props.nodeRightElements;
|
|
199
|
-
|
|
200
|
-
var updatedNodeRightElements = _this.updateElements(nodeRightElements).map(function (element) {
|
|
201
|
-
var unvisible = element.props && 'visible' in element.props && !element.props.visible;
|
|
202
|
-
var style = unvisible ? {
|
|
203
|
-
display: 'none'
|
|
204
|
-
} : {};
|
|
205
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
206
|
-
style: style,
|
|
207
|
-
key: "element-".concat(_uuid["default"].v1()),
|
|
208
|
-
className: "element"
|
|
209
|
-
}, element);
|
|
210
|
-
});
|
|
82
|
+
_initialiseProps.call(_assertThisInitialized(_this));
|
|
211
83
|
|
|
212
|
-
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
213
|
-
className: "node-rightelements"
|
|
214
|
-
}, updatedNodeRightElements) : null;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
Object.defineProperty(_assertThisInitialized(_this), "returnNodeToolbarElements", {
|
|
218
|
-
configurable: true,
|
|
219
|
-
enumerable: true,
|
|
220
|
-
writable: true,
|
|
221
|
-
value: function value() {
|
|
222
|
-
var nodeToolbarElements = _this.props.nodeToolbarElements;
|
|
223
|
-
|
|
224
|
-
var updatedNodeRightElements = _this.updateElements(nodeToolbarElements);
|
|
225
|
-
|
|
226
|
-
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement(_toolbar["default"], {
|
|
227
|
-
customClass: "node-toolbarelements"
|
|
228
|
-
}, /*#__PURE__*/_react["default"].createElement(_toolbar.ToolBarGroup, null, updatedNodeRightElements)) : null;
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
Object.defineProperty(_assertThisInitialized(_this), "validateNodeElement", {
|
|
232
|
-
configurable: true,
|
|
233
|
-
enumerable: true,
|
|
234
|
-
writable: true,
|
|
235
|
-
value: function value(validationKey) {
|
|
236
|
-
var _this$props3 = _this.props,
|
|
237
|
-
nodeElementsValidations = _this$props3.nodeElementsValidations,
|
|
238
|
-
node = _this$props3.node;
|
|
239
|
-
var validations = nodeElementsValidations[validationKey];
|
|
240
|
-
var options = {
|
|
241
|
-
disabled: {
|
|
242
|
-
disabled: true
|
|
243
|
-
},
|
|
244
|
-
unvisible: {
|
|
245
|
-
visible: false
|
|
246
|
-
}
|
|
247
|
-
};
|
|
248
|
-
var elementBehavior = {};
|
|
249
|
-
|
|
250
|
-
if (validations) {
|
|
251
|
-
validations.forEach(function (validation) {
|
|
252
|
-
var validator = validation.validator,
|
|
253
|
-
applyBehavior = validation.applyBehavior;
|
|
254
|
-
|
|
255
|
-
if (_lodash["default"].isEmpty(elementBehavior) && validator && validator(node)) {
|
|
256
|
-
elementBehavior = options[applyBehavior] || options.unvisible;
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return elementBehavior;
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
84
|
_this.labelRef = /*#__PURE__*/_react["default"].createRef();
|
|
85
|
+
var node = props.node;
|
|
86
|
+
var startNodesOpened = context.startNodesOpened;
|
|
87
|
+
var nodeHasItens = node.itens && node.itens.length > 0;
|
|
265
88
|
_this.state = {
|
|
266
|
-
isVisible:
|
|
267
|
-
wasOpened:
|
|
89
|
+
isVisible: nodeHasItens && startNodesOpened,
|
|
90
|
+
wasOpened: nodeHasItens && startNodesOpened,
|
|
268
91
|
showNodeElements: false,
|
|
269
92
|
keepMenuOpened: false
|
|
270
93
|
};
|
|
@@ -274,10 +97,10 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
274
97
|
_createClass(TreeNode, [{
|
|
275
98
|
key: "componentDidMount",
|
|
276
99
|
value: function componentDidMount() {
|
|
277
|
-
var _this$
|
|
278
|
-
isParent = _this$
|
|
279
|
-
nodeToolbarElements = _this$
|
|
280
|
-
nodeRightElements = _this$
|
|
100
|
+
var _this$props = this.props,
|
|
101
|
+
isParent = _this$props.isParent,
|
|
102
|
+
nodeToolbarElements = _this$props.nodeToolbarElements,
|
|
103
|
+
nodeRightElements = _this$props.nodeRightElements;
|
|
281
104
|
|
|
282
105
|
if (isParent || nodeRightElements || nodeToolbarElements) {
|
|
283
106
|
this.labelRef.current.addEventListener('mouseenter', this.handleShowNodeElements);
|
|
@@ -287,10 +110,10 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
287
110
|
}, {
|
|
288
111
|
key: "componentWillUnmount",
|
|
289
112
|
value: function componentWillUnmount() {
|
|
290
|
-
var _this$
|
|
291
|
-
isParent = _this$
|
|
292
|
-
nodeToolbarElements = _this$
|
|
293
|
-
nodeRightElements = _this$
|
|
113
|
+
var _this$props2 = this.props,
|
|
114
|
+
isParent = _this$props2.isParent,
|
|
115
|
+
nodeToolbarElements = _this$props2.nodeToolbarElements,
|
|
116
|
+
nodeRightElements = _this$props2.nodeRightElements;
|
|
294
117
|
|
|
295
118
|
if (isParent || nodeRightElements || nodeToolbarElements) {
|
|
296
119
|
this.labelRef.current.removeEventListener('mouseenter', this.handleShowNodeElements);
|
|
@@ -302,12 +125,12 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
302
125
|
value: function render() {
|
|
303
126
|
var _this2 = this;
|
|
304
127
|
|
|
305
|
-
var _this$
|
|
306
|
-
node = _this$
|
|
307
|
-
children = _this$
|
|
308
|
-
isParent = _this$
|
|
309
|
-
onNodeClick = _this$
|
|
310
|
-
nodeMenuButtonSize = _this$
|
|
128
|
+
var _this$props3 = this.props,
|
|
129
|
+
node = _this$props3.node,
|
|
130
|
+
children = _this$props3.children,
|
|
131
|
+
isParent = _this$props3.isParent,
|
|
132
|
+
onNodeClick = _this$props3.onNodeClick,
|
|
133
|
+
nodeMenuButtonSize = _this$props3.nodeMenuButtonSize;
|
|
311
134
|
var showNodeElements = this.state.showNodeElements;
|
|
312
135
|
return /*#__PURE__*/_react["default"].createElement(_constants.TreeviewContext.Consumer, null, function (_ref) {
|
|
313
136
|
var valuePropName = _ref.valuePropName,
|
|
@@ -389,6 +212,194 @@ var TreeNode = /*#__PURE__*/function (_Component) {
|
|
|
389
212
|
return TreeNode;
|
|
390
213
|
}(_react.Component);
|
|
391
214
|
|
|
215
|
+
var _initialiseProps = function _initialiseProps() {
|
|
216
|
+
var _this3 = this;
|
|
217
|
+
|
|
218
|
+
Object.defineProperty(this, "getSpan", {
|
|
219
|
+
configurable: true,
|
|
220
|
+
enumerable: true,
|
|
221
|
+
writable: true,
|
|
222
|
+
value: function value() {
|
|
223
|
+
var _this3$props = _this3.props,
|
|
224
|
+
node = _this3$props.node,
|
|
225
|
+
alwaysShowArrow = _this3$props.alwaysShowArrow;
|
|
226
|
+
|
|
227
|
+
var span = /*#__PURE__*/_react["default"].createElement("noscript", null);
|
|
228
|
+
|
|
229
|
+
if (node.itens && node.itens.length > 0 || alwaysShowArrow) {
|
|
230
|
+
span = /*#__PURE__*/_react["default"].createElement("span", {
|
|
231
|
+
onKeyPress: null,
|
|
232
|
+
tabIndex: 0,
|
|
233
|
+
role: "button",
|
|
234
|
+
className: "opencloseicon",
|
|
235
|
+
onClick: function onClick() {
|
|
236
|
+
return _this3.openCloseTree(node);
|
|
237
|
+
}
|
|
238
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons["default"], {
|
|
239
|
+
name: _this3.state.isVisible ? 'up' : 'down',
|
|
240
|
+
size: 10
|
|
241
|
+
}));
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return span;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(this, "openCloseTree", {
|
|
248
|
+
configurable: true,
|
|
249
|
+
enumerable: true,
|
|
250
|
+
writable: true,
|
|
251
|
+
value: function value(node) {
|
|
252
|
+
var _this3$state = _this3.state,
|
|
253
|
+
isVisible = _this3$state.isVisible,
|
|
254
|
+
wasOpened = _this3$state.wasOpened;
|
|
255
|
+
var handlerOnNodeOpen = _this3.props.handlerOnNodeOpen;
|
|
256
|
+
var nextState = {
|
|
257
|
+
isVisible: !isVisible
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
if (!wasOpened && handlerOnNodeOpen) {
|
|
261
|
+
nextState = _extends({}, nextState, {
|
|
262
|
+
wasOpened: true
|
|
263
|
+
});
|
|
264
|
+
handlerOnNodeOpen(node);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
_this3.setState(nextState);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
Object.defineProperty(this, "handleShowNodeElements", {
|
|
271
|
+
configurable: true,
|
|
272
|
+
enumerable: true,
|
|
273
|
+
writable: true,
|
|
274
|
+
value: function value() {
|
|
275
|
+
var _this3$state2 = _this3.state,
|
|
276
|
+
showNodeElements = _this3$state2.showNodeElements,
|
|
277
|
+
keepMenuOpened = _this3$state2.keepMenuOpened;
|
|
278
|
+
if (!showNodeElements) _this3.setState({
|
|
279
|
+
showNodeElements: true
|
|
280
|
+
});else if (showNodeElements && !keepMenuOpened) {
|
|
281
|
+
_this3.setState({
|
|
282
|
+
showNodeElements: false
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
Object.defineProperty(this, "updateElements", {
|
|
288
|
+
configurable: true,
|
|
289
|
+
enumerable: true,
|
|
290
|
+
writable: true,
|
|
291
|
+
value: function value(elements) {
|
|
292
|
+
var _this3$props2 = _this3.props,
|
|
293
|
+
node = _this3$props2.node,
|
|
294
|
+
nodeElementsValidations = _this3$props2.nodeElementsValidations;
|
|
295
|
+
var updatedElements = [];
|
|
296
|
+
|
|
297
|
+
if (elements) {
|
|
298
|
+
updatedElements = _react["default"].Children.map(elements, function (element) {
|
|
299
|
+
if ( /*#__PURE__*/_react["default"].isValidElement(element) && element.props) {
|
|
300
|
+
var _element$props = element.props,
|
|
301
|
+
validationKey = _element$props.validationKey,
|
|
302
|
+
onNodeElementClick = _element$props.onNodeElementClick;
|
|
303
|
+
var elementBehavior;
|
|
304
|
+
var newProps = {};
|
|
305
|
+
|
|
306
|
+
if (nodeElementsValidations && validationKey) {
|
|
307
|
+
elementBehavior = _this3.validateNodeElement(validationKey);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (onNodeElementClick) {
|
|
311
|
+
newProps = _extends({}, newProps, {
|
|
312
|
+
onClick: function onClick(e) {
|
|
313
|
+
onNodeElementClick(node);
|
|
314
|
+
if (e.stopPropagation) e.stopPropagation();
|
|
315
|
+
},
|
|
316
|
+
onNodeElementClick: null
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return /*#__PURE__*/_react["default"].cloneElement(element, _extends({}, elementBehavior, newProps));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return element;
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return updatedElements;
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
Object.defineProperty(this, "returnNodeRightElements", {
|
|
331
|
+
configurable: true,
|
|
332
|
+
enumerable: true,
|
|
333
|
+
writable: true,
|
|
334
|
+
value: function value() {
|
|
335
|
+
var nodeRightElements = _this3.props.nodeRightElements;
|
|
336
|
+
|
|
337
|
+
var updatedNodeRightElements = _this3.updateElements(nodeRightElements).map(function (element) {
|
|
338
|
+
var unvisible = element.props && 'visible' in element.props && !element.props.visible;
|
|
339
|
+
var style = unvisible ? {
|
|
340
|
+
display: 'none'
|
|
341
|
+
} : {};
|
|
342
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
343
|
+
style: style,
|
|
344
|
+
key: "element-".concat(_uuid["default"].v1()),
|
|
345
|
+
className: "element"
|
|
346
|
+
}, element);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
350
|
+
className: "node-rightelements"
|
|
351
|
+
}, updatedNodeRightElements) : null;
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
Object.defineProperty(this, "returnNodeToolbarElements", {
|
|
355
|
+
configurable: true,
|
|
356
|
+
enumerable: true,
|
|
357
|
+
writable: true,
|
|
358
|
+
value: function value() {
|
|
359
|
+
var nodeToolbarElements = _this3.props.nodeToolbarElements;
|
|
360
|
+
|
|
361
|
+
var updatedNodeRightElements = _this3.updateElements(nodeToolbarElements);
|
|
362
|
+
|
|
363
|
+
return updatedNodeRightElements.length > 0 ? /*#__PURE__*/_react["default"].createElement(_toolbar["default"], {
|
|
364
|
+
customClass: "node-toolbarelements"
|
|
365
|
+
}, /*#__PURE__*/_react["default"].createElement(_toolbar.ToolBarGroup, null, updatedNodeRightElements)) : null;
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
Object.defineProperty(this, "validateNodeElement", {
|
|
369
|
+
configurable: true,
|
|
370
|
+
enumerable: true,
|
|
371
|
+
writable: true,
|
|
372
|
+
value: function value(validationKey) {
|
|
373
|
+
var _this3$props3 = _this3.props,
|
|
374
|
+
nodeElementsValidations = _this3$props3.nodeElementsValidations,
|
|
375
|
+
node = _this3$props3.node;
|
|
376
|
+
var validations = nodeElementsValidations[validationKey];
|
|
377
|
+
var options = {
|
|
378
|
+
disabled: {
|
|
379
|
+
disabled: true
|
|
380
|
+
},
|
|
381
|
+
unvisible: {
|
|
382
|
+
visible: false
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var elementBehavior = {};
|
|
386
|
+
|
|
387
|
+
if (validations) {
|
|
388
|
+
validations.forEach(function (validation) {
|
|
389
|
+
var validator = validation.validator,
|
|
390
|
+
applyBehavior = validation.applyBehavior;
|
|
391
|
+
|
|
392
|
+
if (_lodash["default"].isEmpty(elementBehavior) && validator && validator(node)) {
|
|
393
|
+
elementBehavior = options[applyBehavior] || options.unvisible;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return elementBehavior;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
|
|
392
403
|
TreeNode.propTypes = {
|
|
393
404
|
node: _propTypes["default"].object.isRequired,
|
|
394
405
|
children: _propTypes["default"].any.isRequired,
|
package/lib/treeview/index.js
CHANGED
|
@@ -546,14 +546,18 @@ var TreeView = /*#__PURE__*/function (_Component) {
|
|
|
546
546
|
key: "getDerivedStateFromProps",
|
|
547
547
|
value: function getDerivedStateFromProps(props, state) {
|
|
548
548
|
var data = props.data,
|
|
549
|
-
selectedIds = props.selectedIds
|
|
549
|
+
selectedIds = props.selectedIds,
|
|
550
|
+
enableDynamicData = props.enableDynamicData;
|
|
550
551
|
var propSelectedIds = state.propSelectedIds;
|
|
551
552
|
|
|
552
553
|
var isSameSelectedIds = _lodash["default"].isEqual(propSelectedIds.sort(), selectedIds.sort());
|
|
553
554
|
|
|
554
|
-
if (data !== state.data
|
|
555
|
+
if (enableDynamicData && data !== state.data) {
|
|
556
|
+
return {
|
|
557
|
+
data: data
|
|
558
|
+
};
|
|
559
|
+
} else if (!isSameSelectedIds) {
|
|
555
560
|
return {
|
|
556
|
-
data: data,
|
|
557
561
|
selectedIds: selectedIds,
|
|
558
562
|
propSelectedIds: selectedIds
|
|
559
563
|
};
|
|
@@ -589,7 +593,8 @@ TreeView.propTypes = {
|
|
|
589
593
|
nodeMenuButtonSize: _propTypes["default"].oneOf(['mini', 'small', 'medium', 'large', 'default']),
|
|
590
594
|
onNodeClick: _propTypes["default"].func,
|
|
591
595
|
onNodeOpen: _propTypes["default"].func,
|
|
592
|
-
nodeElementsValidations: _propTypes["default"].object
|
|
596
|
+
nodeElementsValidations: _propTypes["default"].object,
|
|
597
|
+
enableDynamicData: _propTypes["default"].bool
|
|
593
598
|
};
|
|
594
599
|
TreeView.defaultProps = {
|
|
595
600
|
customClass: '',
|
|
@@ -610,7 +615,8 @@ TreeView.defaultProps = {
|
|
|
610
615
|
nodeMenuButtonSize: 'small',
|
|
611
616
|
onNodeClick: undefined,
|
|
612
617
|
onNodeOpen: undefined,
|
|
613
|
-
nodeElementsValidations: undefined
|
|
618
|
+
nodeElementsValidations: undefined,
|
|
619
|
+
enableDynamicData: false
|
|
614
620
|
};
|
|
615
621
|
var _default = TreeView;
|
|
616
622
|
exports["default"] = _default;
|