@iobroker/adapter-react-v5 2.1.9 → 3.0.0

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.
Files changed (138) hide show
  1. package/Components/404.js.map +1 -1
  2. package/Components/ColorPicker.js.map +1 -1
  3. package/Components/ComplexCron.js.map +1 -1
  4. package/Components/FileBrowser.js +248 -222
  5. package/Components/FileBrowser.js.map +1 -1
  6. package/Components/FileViewer.js +219 -75
  7. package/Components/FileViewer.js.map +1 -1
  8. package/Components/Icon.js.map +1 -1
  9. package/Components/IconPicker.js.map +1 -1
  10. package/Components/IconSelector.js.map +1 -1
  11. package/Components/Image.js.map +1 -1
  12. package/Components/JsonConfigComponent/ChipInput.js +925 -0
  13. package/Components/JsonConfigComponent/ChipInput.js.map +1 -0
  14. package/Components/JsonConfigComponent/ConfigAlive.js +135 -0
  15. package/Components/JsonConfigComponent/ConfigAlive.js.map +1 -0
  16. package/Components/JsonConfigComponent/ConfigAutocomplete.js +204 -0
  17. package/Components/JsonConfigComponent/ConfigAutocomplete.js.map +1 -0
  18. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js +311 -0
  19. package/Components/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -0
  20. package/Components/JsonConfigComponent/ConfigCRON.js +195 -0
  21. package/Components/JsonConfigComponent/ConfigCRON.js.map +1 -0
  22. package/Components/JsonConfigComponent/ConfigCertificateSelect.js +178 -0
  23. package/Components/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -0
  24. package/Components/JsonConfigComponent/ConfigCheckbox.js +112 -0
  25. package/Components/JsonConfigComponent/ConfigCheckbox.js.map +1 -0
  26. package/Components/JsonConfigComponent/ConfigChip.js +149 -0
  27. package/Components/JsonConfigComponent/ConfigChip.js.map +1 -0
  28. package/Components/JsonConfigComponent/ConfigColor.js +156 -0
  29. package/Components/JsonConfigComponent/ConfigColor.js.map +1 -0
  30. package/Components/JsonConfigComponent/ConfigCoordinates.js +165 -0
  31. package/Components/JsonConfigComponent/ConfigCoordinates.js.map +1 -0
  32. package/Components/JsonConfigComponent/ConfigCustomEasyAccess.js +180 -0
  33. package/Components/JsonConfigComponent/ConfigCustomEasyAccess.js.map +1 -0
  34. package/Components/JsonConfigComponent/ConfigDatePicker.js +117 -0
  35. package/Components/JsonConfigComponent/ConfigDatePicker.js.map +1 -0
  36. package/Components/JsonConfigComponent/ConfigGeneric.js +660 -0
  37. package/Components/JsonConfigComponent/ConfigGeneric.js.map +1 -0
  38. package/Components/JsonConfigComponent/ConfigIP.js +151 -0
  39. package/Components/JsonConfigComponent/ConfigIP.js.map +1 -0
  40. package/Components/JsonConfigComponent/ConfigImageUpload.js +215 -0
  41. package/Components/JsonConfigComponent/ConfigImageUpload.js.map +1 -0
  42. package/Components/JsonConfigComponent/ConfigInstanceSelect.js +197 -0
  43. package/Components/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -0
  44. package/Components/JsonConfigComponent/ConfigJsonEditor.js +211 -0
  45. package/Components/JsonConfigComponent/ConfigJsonEditor.js.map +1 -0
  46. package/Components/JsonConfigComponent/ConfigLanguage.js +175 -0
  47. package/Components/JsonConfigComponent/ConfigLanguage.js.map +1 -0
  48. package/Components/JsonConfigComponent/ConfigNumber.js +194 -0
  49. package/Components/JsonConfigComponent/ConfigNumber.js.map +1 -0
  50. package/Components/JsonConfigComponent/ConfigObjectId.js +201 -0
  51. package/Components/JsonConfigComponent/ConfigObjectId.js.map +1 -0
  52. package/Components/JsonConfigComponent/ConfigPanel.js +421 -0
  53. package/Components/JsonConfigComponent/ConfigPanel.js.map +1 -0
  54. package/Components/JsonConfigComponent/ConfigPassword.js +236 -0
  55. package/Components/JsonConfigComponent/ConfigPassword.js.map +1 -0
  56. package/Components/JsonConfigComponent/ConfigPattern.js +94 -0
  57. package/Components/JsonConfigComponent/ConfigPattern.js.map +1 -0
  58. package/Components/JsonConfigComponent/ConfigSelect.js +163 -0
  59. package/Components/JsonConfigComponent/ConfigSelect.js.map +1 -0
  60. package/Components/JsonConfigComponent/ConfigSelectSendTo.js +258 -0
  61. package/Components/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -0
  62. package/Components/JsonConfigComponent/ConfigSendto.js +282 -0
  63. package/Components/JsonConfigComponent/ConfigSendto.js.map +1 -0
  64. package/Components/JsonConfigComponent/ConfigSetState.js +266 -0
  65. package/Components/JsonConfigComponent/ConfigSetState.js.map +1 -0
  66. package/Components/JsonConfigComponent/ConfigStaticDivider.js +88 -0
  67. package/Components/JsonConfigComponent/ConfigStaticDivider.js.map +1 -0
  68. package/Components/JsonConfigComponent/ConfigStaticHeader.js +81 -0
  69. package/Components/JsonConfigComponent/ConfigStaticHeader.js.map +1 -0
  70. package/Components/JsonConfigComponent/ConfigStaticImage.js +88 -0
  71. package/Components/JsonConfigComponent/ConfigStaticImage.js.map +1 -0
  72. package/Components/JsonConfigComponent/ConfigStaticText.js +104 -0
  73. package/Components/JsonConfigComponent/ConfigStaticText.js.map +1 -0
  74. package/Components/JsonConfigComponent/ConfigTable.js +651 -0
  75. package/Components/JsonConfigComponent/ConfigTable.js.map +1 -0
  76. package/Components/JsonConfigComponent/ConfigTabs.js +166 -0
  77. package/Components/JsonConfigComponent/ConfigTabs.js.map +1 -0
  78. package/Components/JsonConfigComponent/ConfigText.js +170 -0
  79. package/Components/JsonConfigComponent/ConfigText.js.map +1 -0
  80. package/Components/JsonConfigComponent/ConfigTextSendTo.js +168 -0
  81. package/Components/JsonConfigComponent/ConfigTextSendTo.js.map +1 -0
  82. package/Components/JsonConfigComponent/ConfigTimePicker.js +111 -0
  83. package/Components/JsonConfigComponent/ConfigTimePicker.js.map +1 -0
  84. package/Components/JsonConfigComponent/ConfigTopic.js +140 -0
  85. package/Components/JsonConfigComponent/ConfigTopic.js.map +1 -0
  86. package/Components/JsonConfigComponent/ConfigUser.js +176 -0
  87. package/Components/JsonConfigComponent/ConfigUser.js.map +1 -0
  88. package/Components/JsonConfigComponent/index.js +511 -0
  89. package/Components/JsonConfigComponent/index.js.map +1 -0
  90. package/Components/Loader.js.map +1 -1
  91. package/Components/Loaders/PT.js.map +1 -1
  92. package/Components/Loaders/Vendor.js.map +1 -1
  93. package/Components/Logo.js.map +1 -1
  94. package/Components/MDUtils.js.map +1 -1
  95. package/Components/ObjectBrowser.js +24 -42
  96. package/Components/ObjectBrowser.js.map +1 -1
  97. package/Components/Router.js.map +1 -1
  98. package/Components/SaveCloseButtons.js.map +1 -1
  99. package/Components/Schedule.js.map +1 -1
  100. package/Components/SelectWithIcon.js.map +1 -1
  101. package/Components/SimpleCron/cronText.js.map +1 -1
  102. package/Components/SimpleCron/index.js.map +1 -1
  103. package/Components/TabContainer.js.map +1 -1
  104. package/Components/TabContent.js.map +1 -1
  105. package/Components/TabHeader.js.map +1 -1
  106. package/Components/TextWithIcon.js.map +1 -1
  107. package/Components/TreeTable.js.map +1 -1
  108. package/Components/Utils.js +25 -0
  109. package/Components/Utils.js.map +1 -1
  110. package/Components/withWidth.js +42 -0
  111. package/Components/withWidth.js.map +1 -0
  112. package/Connection.js.map +1 -1
  113. package/Dialogs/ComplexCron.js.map +1 -1
  114. package/Dialogs/Confirm.js.map +1 -1
  115. package/Dialogs/Cron.js.map +1 -1
  116. package/Dialogs/Error.js.map +1 -1
  117. package/Dialogs/Message.js.map +1 -1
  118. package/Dialogs/SelectID.js.map +1 -1
  119. package/Dialogs/SimpleCron.js.map +1 -1
  120. package/Dialogs/TextInput.js.map +1 -1
  121. package/GenericApp.js.map +1 -1
  122. package/README.md +11 -1
  123. package/Theme.js.map +1 -1
  124. package/icons/IconAdapter.js.map +1 -1
  125. package/icons/IconAlias.js.map +1 -1
  126. package/icons/IconChannel.js.map +1 -1
  127. package/icons/IconClearFilter.js.map +1 -1
  128. package/icons/IconClosed.js.map +1 -1
  129. package/icons/IconCopy.js.map +1 -1
  130. package/icons/IconDevice.js.map +1 -1
  131. package/icons/IconDocument.js.map +1 -1
  132. package/icons/IconExpert.js.map +1 -1
  133. package/icons/IconFx.js.map +1 -1
  134. package/icons/IconInstance.js.map +1 -1
  135. package/icons/IconLogout.js.map +1 -1
  136. package/icons/IconOpen.js.map +1 -1
  137. package/icons/IconState.js.map +1 -1
  138. package/package.json +5 -5
@@ -0,0 +1,651 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports["default"] = void 0;
11
+
12
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
+
20
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
21
+
22
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
23
+
24
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
25
+
26
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
27
+
28
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
29
+
30
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
31
+
32
+ var _react = _interopRequireWildcard(require("react"));
33
+
34
+ var _propTypes = _interopRequireDefault(require("prop-types"));
35
+
36
+ var _styles = require("@mui/styles");
37
+
38
+ var _clsx = _interopRequireDefault(require("clsx"));
39
+
40
+ var _FormHelperText = _interopRequireDefault(require("@mui/material/FormHelperText"));
41
+
42
+ var _material = require("@mui/material");
43
+
44
+ var _Add = _interopRequireDefault(require("@mui/icons-material/Add"));
45
+
46
+ var _Delete = _interopRequireDefault(require("@mui/icons-material/Delete"));
47
+
48
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
49
+
50
+ var _ArrowUpward = _interopRequireDefault(require("@mui/icons-material/ArrowUpward"));
51
+
52
+ var _ArrowDownward = _interopRequireDefault(require("@mui/icons-material/ArrowDownward"));
53
+
54
+ var _i18n = _interopRequireDefault(require("@iobroker/adapter-react-v5/i18n"));
55
+
56
+ var _ConfigGeneric2 = _interopRequireDefault(require("./ConfigGeneric"));
57
+
58
+ var _ConfigPanel = _interopRequireDefault(require("./ConfigPanel"));
59
+
60
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
61
+
62
+ 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; }
63
+
64
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
65
+
66
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
67
+
68
+ var styles = function styles(theme) {
69
+ return {
70
+ fullWidth: {
71
+ width: '100%'
72
+ },
73
+ root: {
74
+ width: '100%'
75
+ },
76
+ paper: {
77
+ width: '100%',
78
+ marginBottom: theme.spacing(2),
79
+ backgroundColor: "rgba(255, 255, 255, 0.1)"
80
+ },
81
+ table: {
82
+ minWidth: 750
83
+ },
84
+ visuallyHidden: {
85
+ border: 0,
86
+ clip: 'rect(0 0 0 0)',
87
+ height: 1,
88
+ margin: -1,
89
+ overflow: 'hidden',
90
+ padding: 0,
91
+ position: 'absolute',
92
+ top: 20,
93
+ width: 1
94
+ },
95
+ addIcon: {
96
+ display: 'flex',
97
+ justifyContent: 'space-between'
98
+ },
99
+ highlight: theme.palette.mode === 'light' ? {
100
+ color: theme.palette.secondary.main // backgroundColor: lighten(theme.palette.secondary.light, 0.85),
101
+
102
+ } : {
103
+ color: theme.palette.text.primary,
104
+ backgroundColor: theme.palette.secondary.dark
105
+ },
106
+ title: {
107
+ flex: '1 1 100%'
108
+ },
109
+ rootTool: {
110
+ paddingLeft: theme.spacing(2),
111
+ paddingRight: theme.spacing(1)
112
+ },
113
+ silver: {
114
+ opacity: 0.2
115
+ },
116
+ flex: {
117
+ display: 'flex'
118
+ },
119
+ filteredOut: {
120
+ padding: 10,
121
+ display: 'flex',
122
+ textAlign: 'center'
123
+ },
124
+ buttonEmpty: {
125
+ width: 30,
126
+ display: 'inline-block'
127
+ },
128
+ buttonCell: {
129
+ whiteSpace: 'nowrap'
130
+ }
131
+ };
132
+ };
133
+
134
+ function objectToArray(object, nameOfFirstAttr, nameOfSecondAttr) {
135
+ nameOfFirstAttr = nameOfFirstAttr || 'key';
136
+ var array = [];
137
+ Object.keys(object).forEach(function (key) {
138
+ var item = {};
139
+ item[nameOfFirstAttr] = key;
140
+
141
+ if (nameOfSecondAttr) {
142
+ item[nameOfSecondAttr] = object[key];
143
+ array.push(item);
144
+ } else {
145
+ array.push(Object.assign(item, object[key]));
146
+ }
147
+ });
148
+ return array;
149
+ }
150
+
151
+ function arrayToObject(array, nameOfFirstAttr, nameOfSecondAttr) {
152
+ nameOfFirstAttr = nameOfFirstAttr || 'key';
153
+ var object = {};
154
+ array.forEach(function (row) {
155
+ var key = row[nameOfFirstAttr];
156
+
157
+ if (key === null || key === undefined) {
158
+ key = '';
159
+ }
160
+
161
+ delete row[nameOfFirstAttr];
162
+
163
+ if (nameOfSecondAttr) {
164
+ object[key] = row[nameOfSecondAttr];
165
+ } else {
166
+ object[key] = row;
167
+ }
168
+ });
169
+ return object;
170
+ }
171
+
172
+ var ConfigTable = /*#__PURE__*/function (_ConfigGeneric) {
173
+ (0, _inherits2["default"])(ConfigTable, _ConfigGeneric);
174
+
175
+ var _super = _createSuper(ConfigTable);
176
+
177
+ function ConfigTable(props) {
178
+ var _this;
179
+
180
+ (0, _classCallCheck2["default"])(this, ConfigTable);
181
+ _this = _super.call(this, props);
182
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleRequestSort", function (property) {
183
+ var orderCheck = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
184
+ var _this$state = _this.state,
185
+ order = _this$state.order,
186
+ orderBy = _this$state.orderBy;
187
+
188
+ if (orderBy) {
189
+ var isAsc = orderBy === property && order === 'asc';
190
+ var newOrder = orderCheck ? order : isAsc ? 'desc' : 'asc';
191
+
192
+ var newValue = _this.stableSort(newOrder, property);
193
+
194
+ _this.setState({
195
+ order: newOrder,
196
+ orderBy: property,
197
+ iteration: _this.state.iteration + 10000
198
+ }, function () {
199
+ return _this.applyFilter(false, newValue);
200
+ });
201
+ }
202
+ });
203
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "stableSort", function (order, orderBy) {
204
+ var value = _this.state.value;
205
+ var comparator = ConfigTable.getComparator(order, orderBy);
206
+ var stabilizedThis = value.map(function (el, index) {
207
+ return [el, index];
208
+ });
209
+ stabilizedThis.sort(function (a, b) {
210
+ var order = comparator(a[0], b[0]);
211
+
212
+ if (order !== 0) {
213
+ return order;
214
+ } else {
215
+ return a[1] - b[1];
216
+ }
217
+ });
218
+ return stabilizedThis.map(function (el) {
219
+ return el[0];
220
+ });
221
+ });
222
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDelete", function (index) {
223
+ return function () {
224
+ var newValue = JSON.parse(JSON.stringify(_this.state.value));
225
+ var visibleValue = JSON.parse(JSON.stringify(_this.state.visibleValue));
226
+ newValue.splice(index, 1);
227
+ var pos = visibleValue.indexOf(index);
228
+
229
+ if (pos !== -1) {
230
+ visibleValue.splice(pos, 1);
231
+ visibleValue = visibleValue.map(function (i) {
232
+ return i > index ? i - 1 : i;
233
+ });
234
+ }
235
+
236
+ _this.setState({
237
+ value: newValue,
238
+ visibleValue: visibleValue,
239
+ iteration: _this.state.iteration + 10000
240
+ }, function () {
241
+ return _this.onChangeWrapper(newValue);
242
+ });
243
+ };
244
+ });
245
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onChangeWrapper", function (newValue) {
246
+ var updateVisible = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
247
+ _this.typingTimer && clearTimeout(_this.typingTimer);
248
+ _this.typingTimer = setTimeout(function (value, updateVisible) {
249
+ _this.typingTimer = null;
250
+
251
+ if (_this.props.schema.objKeyName) {
252
+ var objValue = arrayToObject(JSON.parse(JSON.stringify(value)), _this.props.schema.objKeyName, _this.props.schema.objValueName);
253
+
254
+ _this.onChange(_this.props.attr, objValue);
255
+ } else {
256
+ _this.onChange(_this.props.attr, value);
257
+ }
258
+
259
+ if (updateVisible) {
260
+ _this.applyFilter(false, value);
261
+
262
+ _this.handleRequestSort(_this.state.orderBy, true);
263
+ }
264
+ }, 300, newValue, updateVisible);
265
+ });
266
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onAdd", function () {
267
+ var schema = _this.props.schema;
268
+ var newValue = JSON.parse(JSON.stringify(_this.state.value));
269
+ var visibleValue = JSON.parse(JSON.stringify(_this.state.visibleValue));
270
+ var newItem = schema.items.reduce(function (accumulator, currentValue) {
271
+ accumulator[currentValue.attr] = currentValue["default"] === undefined ? null : currentValue["default"];
272
+ return accumulator;
273
+ }, {});
274
+ newValue.push(newItem);
275
+ visibleValue.push(newValue.length - 1);
276
+
277
+ _this.setState({
278
+ value: newValue,
279
+ visibleValue: visibleValue
280
+ }, function () {
281
+ return _this.onChangeWrapper(newValue);
282
+ });
283
+ });
284
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "applyFilter", function () {
285
+ var clear = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
286
+ var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.state.value;
287
+ var visibleValue = value.map(function (_, i) {
288
+ return i;
289
+ });
290
+ Object.keys(_this.filterRefs).forEach(function (attr) {
291
+ var valueInputRef = _this.filterRefs[attr].current.children[0].children[0].value;
292
+
293
+ if (!clear && valueInputRef) {
294
+ valueInputRef = valueInputRef.toLowerCase();
295
+ visibleValue = visibleValue.filter(function (idx) {
296
+ return value[idx] && value[idx][attr] && value[idx][attr].toLowerCase().includes(valueInputRef);
297
+ });
298
+ } else {
299
+ _this.filterRefs[attr].current.children[0].children[0].value = '';
300
+ }
301
+ });
302
+
303
+ if (JSON.stringify(visibleValue) !== JSON.stringify(_this.state.visibleValue)) {
304
+ _this.setState({
305
+ visibleValue: visibleValue
306
+ });
307
+ }
308
+ });
309
+ _this.filterRefs = {};
310
+
311
+ _this.props.schema.items.forEach(function (el) {
312
+ if (el.filter) {
313
+ _this.filterRefs[el.attr] = /*#__PURE__*/(0, _react.createRef)();
314
+ }
315
+ });
316
+
317
+ return _this;
318
+ }
319
+
320
+ (0, _createClass2["default"])(ConfigTable, [{
321
+ key: "componentDidMount",
322
+ value: function () {
323
+ var _componentDidMount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
324
+ var value, visibleValue;
325
+ return _regenerator["default"].wrap(function _callee$(_context) {
326
+ while (1) {
327
+ switch (_context.prev = _context.next) {
328
+ case 0:
329
+ (0, _get2["default"])((0, _getPrototypeOf2["default"])(ConfigTable.prototype), "componentDidMount", this).call(this);
330
+ value = _ConfigGeneric2["default"].getValue(this.props.data, this.props.attr) || []; // if the list is given as an object
331
+
332
+ if (this.props.schema.objKeyName) {
333
+ value = objectToArray(value, this.props.schema.objKeyName, this.props.schema.objValueName);
334
+ }
335
+
336
+ visibleValue = value.map(function (_, i) {
337
+ return i;
338
+ });
339
+ this.setState({
340
+ value: value,
341
+ visibleValue: visibleValue,
342
+ orderBy:
343
+ /*this.props.schema.items.length ? this.props.schema.items[0].attr : */
344
+ '',
345
+ order: 'asc',
346
+ iteration: 0
347
+ });
348
+
349
+ case 5:
350
+ case "end":
351
+ return _context.stop();
352
+ }
353
+ }
354
+ }, _callee, this);
355
+ }));
356
+
357
+ function componentDidMount() {
358
+ return _componentDidMount.apply(this, arguments);
359
+ }
360
+
361
+ return componentDidMount;
362
+ }()
363
+ }, {
364
+ key: "componentWillUnmount",
365
+ value: function componentWillUnmount() {
366
+ this.typingTimer && clearTimeout(this.typingTimer);
367
+ this.typingTimer = null;
368
+ (0, _get2["default"])((0, _getPrototypeOf2["default"])(ConfigTable.prototype), "componentWillUnmount", this).call(this);
369
+ }
370
+ }, {
371
+ key: "itemTable",
372
+ value: function itemTable(attrItem, data, idx) {
373
+ var _this2 = this;
374
+
375
+ var _this$state2 = this.state,
376
+ value = _this$state2.value,
377
+ systemConfig = _this$state2.systemConfig;
378
+ var schema = this.props.schema;
379
+ var schemaFind = schema.items.find(function (el) {
380
+ return el.attr === attrItem;
381
+ });
382
+
383
+ if (!schemaFind) {
384
+ return null;
385
+ }
386
+
387
+ var schemaItem = {
388
+ items: (0, _defineProperty2["default"])({}, attrItem, schemaFind)
389
+ };
390
+ return /*#__PURE__*/_react["default"].createElement(_ConfigPanel["default"], {
391
+ index: idx + this.state.iteration,
392
+ socket: this.props.socket,
393
+ adapterName: this.props.adapterName,
394
+ instance: this.props.instance,
395
+ common: this.props.common,
396
+ alive: this.props.alive,
397
+ themeType: this.props.themeType,
398
+ themeName: this.props.themeName,
399
+ data: data,
400
+ table: true,
401
+ custom: true,
402
+ schema: schemaItem,
403
+ systemConfig: systemConfig,
404
+ customs: this.props.customs,
405
+ onChange: function onChange(attr, valueChange) {
406
+ var newObj = JSON.parse(JSON.stringify(value));
407
+ newObj[idx][attr] = valueChange;
408
+
409
+ _this2.setState({
410
+ value: newObj
411
+ }, function () {
412
+ return _this2.onChangeWrapper(newObj, true);
413
+ });
414
+ },
415
+ onError: function onError(error, attr) {
416
+ return _this2.onError(error, attr);
417
+ }
418
+ });
419
+ }
420
+ }, {
421
+ key: "enhancedTableHead",
422
+ value: function enhancedTableHead(buttonsWidth) {
423
+ var _this3 = this;
424
+
425
+ var _this$props = this.props,
426
+ schema = _this$props.schema,
427
+ classes = _this$props.classes;
428
+ var _this$state3 = this.state,
429
+ order = _this$state3.order,
430
+ orderBy = _this$state3.orderBy;
431
+ return /*#__PURE__*/_react["default"].createElement(_material.TableHead, null, /*#__PURE__*/_react["default"].createElement(_material.TableRow, null, schema.items.map(function (headCell) {
432
+ var _this3$filterRefs$hea, _this3$filterRefs$hea2, _this3$filterRefs$hea3, _this3$filterRefs$hea4;
433
+
434
+ return /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
435
+ style: {
436
+ width: typeof headCell.width === 'string' && headCell.width.endsWith('%') ? 'auto' : headCell.width
437
+ },
438
+ key: headCell.attr,
439
+ align: "left",
440
+ sortDirection: orderBy === headCell.attr ? order : false
441
+ }, /*#__PURE__*/_react["default"].createElement("div", {
442
+ className: classes.flex
443
+ }, headCell.sort && /*#__PURE__*/_react["default"].createElement(_material.TableSortLabel, {
444
+ active: true,
445
+ className: (0, _clsx["default"])(orderBy !== headCell.attr && classes.silver),
446
+ direction: orderBy === headCell.attr ? order : 'asc',
447
+ onClick: function onClick() {
448
+ return _this3.handleRequestSort(headCell.attr);
449
+ }
450
+ }), headCell.filter ? /*#__PURE__*/_react["default"].createElement(_material.TextField, {
451
+ variant: "standard",
452
+ ref: _this3.filterRefs[headCell.attr],
453
+ onChange: function onChange() {
454
+ return _this3.applyFilter();
455
+ },
456
+ InputProps: {
457
+ endAdornment: ((_this3$filterRefs$hea = _this3.filterRefs[headCell.attr]) === null || _this3$filterRefs$hea === void 0 ? void 0 : (_this3$filterRefs$hea2 = _this3$filterRefs$hea.current) === null || _this3$filterRefs$hea2 === void 0 ? void 0 : (_this3$filterRefs$hea3 = _this3$filterRefs$hea2.children[0]) === null || _this3$filterRefs$hea3 === void 0 ? void 0 : (_this3$filterRefs$hea4 = _this3$filterRefs$hea3.children[0]) === null || _this3$filterRefs$hea4 === void 0 ? void 0 : _this3$filterRefs$hea4.value) && /*#__PURE__*/_react["default"].createElement(_material.InputAdornment, {
458
+ position: "end"
459
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
460
+ size: "small",
461
+ onClick: function onClick() {
462
+ _this3.filterRefs[headCell.attr].current.children[0].children[0].value = '';
463
+
464
+ _this3.applyFilter();
465
+ }
466
+ }, /*#__PURE__*/_react["default"].createElement(_Close["default"], null)))
467
+ },
468
+ fullWidth: true,
469
+ placeholder: _this3.getText(headCell.title)
470
+ }) : _this3.getText(headCell.title)));
471
+ }), !schema.noDelete && /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
472
+ style: {
473
+ paddingLeft: 20,
474
+ width: buttonsWidth
475
+ },
476
+ padding: "checkbox"
477
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
478
+ disabled: true,
479
+ size: "small"
480
+ }, /*#__PURE__*/_react["default"].createElement(_Delete["default"], null)))));
481
+ }
482
+ }, {
483
+ key: "isAnyFilterSet",
484
+ value: function isAnyFilterSet() {
485
+ var _this4 = this;
486
+
487
+ return Object.keys(this.filterRefs).find(function (attr) {
488
+ var _this4$filterRefs$att;
489
+
490
+ return (_this4$filterRefs$att = _this4.filterRefs[attr].current) === null || _this4$filterRefs$att === void 0 ? void 0 : _this4$filterRefs$att.children[0].children[0].value;
491
+ });
492
+ }
493
+ }, {
494
+ key: "onMoveUp",
495
+ value: function onMoveUp(idx) {
496
+ var _this5 = this;
497
+
498
+ var value = JSON.parse(JSON.stringify(this.state.value));
499
+ var item = value[idx];
500
+ value.splice(idx, 1);
501
+ value.splice(idx - 1, 0, item);
502
+ this.setState({
503
+ value: value,
504
+ iteration: this.state.iteration + 10000
505
+ }, function () {
506
+ return _this5.onChangeWrapper(value);
507
+ });
508
+ }
509
+ }, {
510
+ key: "onMoveDown",
511
+ value: function onMoveDown(idx) {
512
+ var _this6 = this;
513
+
514
+ var value = JSON.parse(JSON.stringify(this.state.value));
515
+ var item = value[idx];
516
+ value.splice(idx, 1);
517
+ value.splice(idx + 1, 0, item);
518
+ this.setState({
519
+ value: value,
520
+ iteration: this.state.iteration + 10000
521
+ }, function () {
522
+ return _this6.onChangeWrapper(value);
523
+ });
524
+ }
525
+ }, {
526
+ key: "renderItem",
527
+ value: function renderItem(error, disabled, defaultValue) {
528
+ var _this7 = this;
529
+
530
+ var _this$props2 = this.props,
531
+ classes = _this$props2.classes,
532
+ schema = _this$props2.schema;
533
+ var _this$state4 = this.state,
534
+ value = _this$state4.value,
535
+ visibleValue = _this$state4.visibleValue;
536
+
537
+ if (!value) {
538
+ return null;
539
+ }
540
+
541
+ var doAnyFilterSet = this.isAnyFilterSet();
542
+ return /*#__PURE__*/_react["default"].createElement(_material.Paper, {
543
+ className: classes.paper
544
+ }, /*#__PURE__*/_react["default"].createElement("div", {
545
+ className: classes.addIcon
546
+ }, schema.label ? /*#__PURE__*/_react["default"].createElement(_material.Toolbar, {
547
+ variant: "dense",
548
+ className: classes.rootTool
549
+ }, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
550
+ className: classes.title,
551
+ variant: "h6",
552
+ id: "tableTitle",
553
+ component: "div"
554
+ }, this.getText(schema.label))) : null, !schema.noDelete && !doAnyFilterSet ? /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
555
+ title: _i18n["default"].t('Add row')
556
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
557
+ onClick: this.onAdd
558
+ }, /*#__PURE__*/_react["default"].createElement(_Add["default"], null))) : null), /*#__PURE__*/_react["default"].createElement(_material.TableContainer, null, /*#__PURE__*/_react["default"].createElement(_material.Table, {
559
+ className: classes.table,
560
+ size: "small"
561
+ }, this.enhancedTableHead(!doAnyFilterSet && !this.state.orderBy ? 120 : 64), /*#__PURE__*/_react["default"].createElement(_material.TableBody, null, visibleValue.map(function (idx, i) {
562
+ return /*#__PURE__*/_react["default"].createElement(_material.TableRow, {
563
+ hover: true,
564
+ key: idx
565
+ }, schema.items.map(function (headCell) {
566
+ console.log("KEy: ".concat(headCell.attr + idx, " = ").concat(value[idx][headCell.attr]));
567
+ return /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
568
+ key: headCell.attr + '_' + idx,
569
+ align: "left"
570
+ }, _this7.itemTable(headCell.attr, value[idx], idx));
571
+ }), !schema.noDelete && /*#__PURE__*/_react["default"].createElement(_material.TableCell, {
572
+ align: "left",
573
+ className: classes.buttonCell
574
+ }, !doAnyFilterSet && !_this7.state.orderBy ? i ? /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
575
+ title: _i18n["default"].t('Move up')
576
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
577
+ size: "small",
578
+ onClick: function onClick() {
579
+ return _this7.onMoveUp(idx);
580
+ }
581
+ }, /*#__PURE__*/_react["default"].createElement(_ArrowUpward["default"], null))) : /*#__PURE__*/_react["default"].createElement("div", {
582
+ className: classes.buttonEmpty
583
+ }) : null, !doAnyFilterSet && !_this7.state.orderBy ? i < visibleValue.length - 1 ? /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
584
+ title: _i18n["default"].t('Move down')
585
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
586
+ size: "small",
587
+ onClick: function onClick() {
588
+ return _this7.onMoveDown(idx);
589
+ }
590
+ }, /*#__PURE__*/_react["default"].createElement(_ArrowDownward["default"], null))) : /*#__PURE__*/_react["default"].createElement("div", {
591
+ className: classes.buttonEmpty
592
+ }) : null, /*#__PURE__*/_react["default"].createElement(_material.Tooltip, {
593
+ title: _i18n["default"].t('Delete current row')
594
+ }, /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
595
+ size: "small",
596
+ onClick: _this7.onDelete(idx)
597
+ }, /*#__PURE__*/_react["default"].createElement(_Delete["default"], null)))));
598
+ }))), !visibleValue.length && value.length ? /*#__PURE__*/_react["default"].createElement("div", {
599
+ className: classes.filteredOut
600
+ }, /*#__PURE__*/_react["default"].createElement(_material.Typography, {
601
+ className: classes.title,
602
+ variant: "h6",
603
+ id: "tableTitle",
604
+ component: "div"
605
+ }, _i18n["default"].t('All items are filtered out'), /*#__PURE__*/_react["default"].createElement(_material.IconButton, {
606
+ size: "small",
607
+ onClick: function onClick(e) {
608
+ return _this7.applyFilter(true);
609
+ }
610
+ }, /*#__PURE__*/_react["default"].createElement(_Close["default"], null)))) : null), schema.help ? /*#__PURE__*/_react["default"].createElement(_FormHelperText["default"], null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)) : null);
611
+ }
612
+ }], [{
613
+ key: "descendingComparator",
614
+ value: function descendingComparator(a, b, orderBy) {
615
+ if (b[orderBy] < a[orderBy]) {
616
+ return -1;
617
+ } else if (b[orderBy] > a[orderBy]) {
618
+ return 1;
619
+ } else {
620
+ return 0;
621
+ }
622
+ }
623
+ }, {
624
+ key: "getComparator",
625
+ value: function getComparator(order, orderBy) {
626
+ return order === 'desc' ? function (a, b) {
627
+ return ConfigTable.descendingComparator(a, b, orderBy);
628
+ } : function (a, b) {
629
+ return -ConfigTable.descendingComparator(a, b, orderBy);
630
+ };
631
+ }
632
+ }]);
633
+ return ConfigTable;
634
+ }(_ConfigGeneric2["default"]);
635
+
636
+ ConfigTable.propTypes = {
637
+ socket: _propTypes["default"].object.isRequired,
638
+ themeType: _propTypes["default"].string,
639
+ themeName: _propTypes["default"].string,
640
+ style: _propTypes["default"].object,
641
+ className: _propTypes["default"].string,
642
+ data: _propTypes["default"].object.isRequired,
643
+ schema: _propTypes["default"].object,
644
+ onError: _propTypes["default"].func,
645
+ onChange: _propTypes["default"].func
646
+ };
647
+
648
+ var _default = (0, _styles.withStyles)(styles)(ConfigTable);
649
+
650
+ exports["default"] = _default;
651
+ //# sourceMappingURL=ConfigTable.js.map