@iobroker/adapter-react-v5 0.0.2

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 (264) hide show
  1. package/Components/404.js +155 -0
  2. package/Components/404.js.map +1 -0
  3. package/Components/ColorPicker.js +313 -0
  4. package/Components/ColorPicker.js.map +1 -0
  5. package/Components/ComplexCron.js +606 -0
  6. package/Components/ComplexCron.js.map +1 -0
  7. package/Components/FileBrowser.js +2147 -0
  8. package/Components/FileBrowser.js.map +1 -0
  9. package/Components/FileViewer.js +245 -0
  10. package/Components/FileViewer.js.map +1 -0
  11. package/Components/Icon.js +234 -0
  12. package/Components/Icon.js.map +1 -0
  13. package/Components/IconPicker.js +188 -0
  14. package/Components/IconPicker.js.map +1 -0
  15. package/Components/IconSelector.js +337 -0
  16. package/Components/IconSelector.js.map +1 -0
  17. package/Components/Image.js +215 -0
  18. package/Components/Image.js.map +1 -0
  19. package/Components/Loader.js +134 -0
  20. package/Components/Loader.js.map +1 -0
  21. package/Components/Loaders/PT.css +109 -0
  22. package/Components/Loaders/PT.js +104 -0
  23. package/Components/Loaders/PT.js.map +1 -0
  24. package/Components/Loaders/Vendor.css +13 -0
  25. package/Components/Loaders/Vendor.js +108 -0
  26. package/Components/Loaders/Vendor.js.map +1 -0
  27. package/Components/Logo.js +230 -0
  28. package/Components/Logo.js.map +1 -0
  29. package/Components/MDUtils.js +141 -0
  30. package/Components/MDUtils.js.map +1 -0
  31. package/Components/ObjectBrowser.js +6119 -0
  32. package/Components/ObjectBrowser.js.map +1 -0
  33. package/Components/Router.js +152 -0
  34. package/Components/Router.js.map +1 -0
  35. package/Components/SaveCloseButtons.js +177 -0
  36. package/Components/SaveCloseButtons.js.map +1 -0
  37. package/Components/Schedule.js +1891 -0
  38. package/Components/Schedule.js.map +1 -0
  39. package/Components/SelectWithIcon.js +235 -0
  40. package/Components/SelectWithIcon.js.map +1 -0
  41. package/Components/SimpleCron/cron2text.js +563 -0
  42. package/Components/SimpleCron/cron2text.js.map +1 -0
  43. package/Components/SimpleCron/cronText.js +60 -0
  44. package/Components/SimpleCron/cronText.js.map +1 -0
  45. package/Components/SimpleCron/index.js +861 -0
  46. package/Components/SimpleCron/index.js.map +1 -0
  47. package/Components/SimpleCron/jquery.cron.locale.js +322 -0
  48. package/Components/SimpleCron/jquery.cron.locale.js.map +1 -0
  49. package/Components/TabContainer.js +108 -0
  50. package/Components/TabContainer.js.map +1 -0
  51. package/Components/TabContent.js +96 -0
  52. package/Components/TabContent.js.map +1 -0
  53. package/Components/TabHeader.js +72 -0
  54. package/Components/TabHeader.js.map +1 -0
  55. package/Components/TextWithIcon.js +148 -0
  56. package/Components/TextWithIcon.js.map +1 -0
  57. package/Components/ToggleThemeMenu.js +49 -0
  58. package/Components/ToggleThemeMenu.js.map +1 -0
  59. package/Components/TreeTable.js +1030 -0
  60. package/Components/TreeTable.js.map +1 -0
  61. package/Components/Utils.js +1763 -0
  62. package/Components/Utils.js.map +1 -0
  63. package/Components/copy-to-clipboard.js +183 -0
  64. package/Components/copy-to-clipboard.js.map +1 -0
  65. package/Components/loader.css +222 -0
  66. package/Components/types.d.ts +121 -0
  67. package/Connection.js +3334 -0
  68. package/Connection.js.map +1 -0
  69. package/Dialogs/ComplexCron.js +193 -0
  70. package/Dialogs/ComplexCron.js.map +1 -0
  71. package/Dialogs/Confirm.js +211 -0
  72. package/Dialogs/Confirm.js.map +1 -0
  73. package/Dialogs/Cron.js +254 -0
  74. package/Dialogs/Cron.js.map +1 -0
  75. package/Dialogs/Error.js +137 -0
  76. package/Dialogs/Error.js.map +1 -0
  77. package/Dialogs/Message.js +118 -0
  78. package/Dialogs/Message.js.map +1 -0
  79. package/Dialogs/SelectID.js +313 -0
  80. package/Dialogs/SelectID.js.map +1 -0
  81. package/Dialogs/SimpleCron.js +177 -0
  82. package/Dialogs/SimpleCron.js.map +1 -0
  83. package/Dialogs/TextInput.js +194 -0
  84. package/Dialogs/TextInput.js.map +1 -0
  85. package/GenericApp.js +1022 -0
  86. package/GenericApp.js.map +1 -0
  87. package/LICENSE +22 -0
  88. package/Prompt.js +21 -0
  89. package/Prompt.js.map +1 -0
  90. package/README.md +645 -0
  91. package/Theme.js +422 -0
  92. package/Theme.js.map +1 -0
  93. package/assets/devices/Alarm Systems.svg +19 -0
  94. package/assets/devices/Amplifier.svg +22 -0
  95. package/assets/devices/Awnings.svg +5 -0
  96. package/assets/devices/Battery Status.svg +5 -0
  97. package/assets/devices/Ceiling Spotlights.svg +16 -0
  98. package/assets/devices/Chandelier.svg +7 -0
  99. package/assets/devices/Climate.svg +12 -0
  100. package/assets/devices/Coffee Makers.svg +6 -0
  101. package/assets/devices/Cold Water.svg +31 -0
  102. package/assets/devices/Computer.svg +21 -0
  103. package/assets/devices/Consumption.svg +8 -0
  104. package/assets/devices/Curtains.svg +43 -0
  105. package/assets/devices/Dishwashers.svg +12 -0
  106. package/assets/devices/Doors.svg +6 -0
  107. package/assets/devices/Doorstep.svg +35 -0
  108. package/assets/devices/Dryer.svg +14 -0
  109. package/assets/devices/Fan.svg +20 -0
  110. package/assets/devices/Floor Lamps.svg +5 -0
  111. package/assets/devices/Garage Doors.svg +9 -0
  112. package/assets/devices/Gates.svg +32 -0
  113. package/assets/devices/Hairdryer.svg +23 -0
  114. package/assets/devices/Handle.svg +6 -0
  115. package/assets/devices/Hanging Lamps.svg +9 -0
  116. package/assets/devices/Heater.svg +44 -0
  117. package/assets/devices/Hoods.svg +12 -0
  118. package/assets/devices/Hot Water.svg +10 -0
  119. package/assets/devices/Humidity.svg +41 -0
  120. package/assets/devices/Iron.svg +5 -0
  121. package/assets/devices/Irrigation.svg +42 -0
  122. package/assets/devices/Led Strip.svg +31 -0
  123. package/assets/devices/Light.svg +30 -0
  124. package/assets/devices/Lightings.svg +46 -0
  125. package/assets/devices/Lock.svg +19 -0
  126. package/assets/devices/Louvre.svg +7 -0
  127. package/assets/devices/Mowing Machine.svg +9 -0
  128. package/assets/devices/Music.svg +13 -0
  129. package/assets/devices/Outdoor Blinds.svg +7 -0
  130. package/assets/devices/People.svg +19 -0
  131. package/assets/devices/Pool.svg +8 -0
  132. package/assets/devices/Power Consumption.svg +13 -0
  133. package/assets/devices/Printer.svg +10 -0
  134. package/assets/devices/Pump.svg +10 -0
  135. package/assets/devices/Receiver.svg +19 -0
  136. package/assets/devices/Sconces.svg +10 -0
  137. package/assets/devices/Security.svg +34 -0
  138. package/assets/devices/Shading.svg +5 -0
  139. package/assets/devices/Shutters.svg +11 -0
  140. package/assets/devices/SmokeDetector.svg +13 -0
  141. package/assets/devices/Sockets.svg +13 -0
  142. package/assets/devices/Speaker.svg +35 -0
  143. package/assets/devices/Stove.svg +12 -0
  144. package/assets/devices/Table Lamps.svg +12 -0
  145. package/assets/devices/Temperature Sensors.svg +28 -0
  146. package/assets/devices/Tv.svg +8 -0
  147. package/assets/devices/Vacuum Cleaner.svg +16 -0
  148. package/assets/devices/Ventilation.svg +12 -0
  149. package/assets/devices/Washing Machines.svg +16 -0
  150. package/assets/devices/Water Consumption.svg +6 -0
  151. package/assets/devices/Water Heater.svg +8 -0
  152. package/assets/devices/Water.svg +40 -0
  153. package/assets/devices/Weather.svg +28 -0
  154. package/assets/devices/Window.svg +8 -0
  155. package/assets/devices/list.json +994 -0
  156. package/assets/devices/names.txt +63 -0
  157. package/assets/devices/parseNames.js +34 -0
  158. package/assets/lamp_ceiling.svg +9 -0
  159. package/assets/lamp_table.svg +8 -0
  160. package/assets/no_icon.svg +9 -0
  161. package/assets/rooms/Anteroom.svg +53 -0
  162. package/assets/rooms/Attic.svg +21 -0
  163. package/assets/rooms/Balcony.svg +13 -0
  164. package/assets/rooms/Barn.svg +6 -0
  165. package/assets/rooms/Basement.svg +5 -0
  166. package/assets/rooms/Bathroom.svg +38 -0
  167. package/assets/rooms/Bedroom.svg +5 -0
  168. package/assets/rooms/Boiler Room.svg +13 -0
  169. package/assets/rooms/Carport.svg +17 -0
  170. package/assets/rooms/Cellar.svg +89 -0
  171. package/assets/rooms/Chamber.svg +9 -0
  172. package/assets/rooms/Corridor.svg +53 -0
  173. package/assets/rooms/Dining Area.svg +37 -0
  174. package/assets/rooms/Dining Room.svg +37 -0
  175. package/assets/rooms/Dining.svg +37 -0
  176. package/assets/rooms/Dressing Room.svg +5 -0
  177. package/assets/rooms/Driveway.svg +15 -0
  178. package/assets/rooms/Entrance.svg +44 -0
  179. package/assets/rooms/Equipment Room.svg +15 -0
  180. package/assets/rooms/Front Yard.svg +64 -0
  181. package/assets/rooms/Gallery.svg +14 -0
  182. package/assets/rooms/Garage.svg +20 -0
  183. package/assets/rooms/Garden.svg +13 -0
  184. package/assets/rooms/Ground Floor.svg +95 -0
  185. package/assets/rooms/Guest Bathroom.svg +33 -0
  186. package/assets/rooms/Guest Room.svg +5 -0
  187. package/assets/rooms/Gym.svg +5 -0
  188. package/assets/rooms/Hall.svg +19 -0
  189. package/assets/rooms/Home Theater.svg +8 -0
  190. package/assets/rooms/Kitchen.svg +18 -0
  191. package/assets/rooms/Laundry Room.svg +12 -0
  192. package/assets/rooms/Living Area.svg +11 -0
  193. package/assets/rooms/Living Room.svg +10 -0
  194. package/assets/rooms/Locker Room.svg +17 -0
  195. package/assets/rooms/Nursery.svg +5 -0
  196. package/assets/rooms/Office.svg +8 -0
  197. package/assets/rooms/Outdoors.svg +7 -0
  198. package/assets/rooms/Playroom.svg +6 -0
  199. package/assets/rooms/Pool.svg +8 -0
  200. package/assets/rooms/Rear Wall.svg +30 -0
  201. package/assets/rooms/Second Floor.svg +95 -0
  202. package/assets/rooms/Shed.svg +16 -0
  203. package/assets/rooms/Sleeping Area.svg +22 -0
  204. package/assets/rooms/Stairway.svg +5 -0
  205. package/assets/rooms/Stairwell.svg +15 -0
  206. package/assets/rooms/Storeroom.svg +5 -0
  207. package/assets/rooms/Summer House.svg +27 -0
  208. package/assets/rooms/Swimming Pool.svg +21 -0
  209. package/assets/rooms/Terrace.svg +7 -0
  210. package/assets/rooms/Toilet.svg +10 -0
  211. package/assets/rooms/Upstairs.svg +6 -0
  212. package/assets/rooms/Wardrobe.svg +60 -0
  213. package/assets/rooms/Washroom.svg +20 -0
  214. package/assets/rooms/Wc.svg +10 -0
  215. package/assets/rooms/Windscreen.svg +60 -0
  216. package/assets/rooms/Workshop.svg +23 -0
  217. package/assets/rooms/Workspace.svg +8 -0
  218. package/assets/rooms/list.json +946 -0
  219. package/assets/rooms/names.txt +60 -0
  220. package/assets/rooms/parseNames.js +34 -0
  221. package/gulpfile.js +113 -0
  222. package/i18n/de.json +280 -0
  223. package/i18n/en.json +280 -0
  224. package/i18n/es.json +267 -0
  225. package/i18n/fr.json +267 -0
  226. package/i18n/it.json +267 -0
  227. package/i18n/nl.json +267 -0
  228. package/i18n/pl.json +267 -0
  229. package/i18n/pt.json +267 -0
  230. package/i18n/ru.json +280 -0
  231. package/i18n/zh-cn.json +267 -0
  232. package/i18n.js +171 -0
  233. package/i18n.js.map +1 -0
  234. package/icons/IconAdapter.js +39 -0
  235. package/icons/IconAdapter.js.map +1 -0
  236. package/icons/IconAlias.js +39 -0
  237. package/icons/IconAlias.js.map +1 -0
  238. package/icons/IconChannel.js +80 -0
  239. package/icons/IconChannel.js.map +1 -0
  240. package/icons/IconClearFilter.js +41 -0
  241. package/icons/IconClearFilter.js.map +1 -0
  242. package/icons/IconClosed.js +39 -0
  243. package/icons/IconClosed.js.map +1 -0
  244. package/icons/IconCopy.js +48 -0
  245. package/icons/IconCopy.js.map +1 -0
  246. package/icons/IconDevice.js +147 -0
  247. package/icons/IconDevice.js.map +1 -0
  248. package/icons/IconDocument.js +39 -0
  249. package/icons/IconDocument.js.map +1 -0
  250. package/icons/IconExpert.js +50 -0
  251. package/icons/IconExpert.js.map +1 -0
  252. package/icons/IconFx.js +39 -0
  253. package/icons/IconFx.js.map +1 -0
  254. package/icons/IconInstance.js +39 -0
  255. package/icons/IconInstance.js.map +1 -0
  256. package/icons/IconLogout.js +50 -0
  257. package/icons/IconLogout.js.map +1 -0
  258. package/icons/IconOpen.js +39 -0
  259. package/icons/IconOpen.js.map +1 -0
  260. package/icons/IconState.js +58 -0
  261. package/icons/IconState.js.map +1 -0
  262. package/index.css +55 -0
  263. package/package.json +42 -0
  264. package/types.d.ts +84 -0
package/GenericApp.js ADDED
@@ -0,0 +1,1022 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _Connection = _interopRequireWildcard(require("./Connection"));
11
+
12
+ var _propTypes = _interopRequireDefault(require("prop-types"));
13
+
14
+ var Sentry = _interopRequireWildcard(require("@sentry/browser"));
15
+
16
+ var SentryIntegrations = _interopRequireWildcard(require("@sentry/integrations"));
17
+
18
+ var _Error = _interopRequireDefault(require("./Dialogs/Error"));
19
+
20
+ var _Snackbar = _interopRequireDefault(require("@mui/material/Snackbar"));
21
+
22
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
23
+
24
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
25
+
26
+ var _Prompt = _interopRequireDefault(require("./Prompt"));
27
+
28
+ var _Theme = _interopRequireDefault(require("./Theme"));
29
+
30
+ var _Loader = _interopRequireDefault(require("./Components/Loader"));
31
+
32
+ var _Router2 = _interopRequireDefault(require("./Components/Router"));
33
+
34
+ var _Utils = _interopRequireDefault(require("./Components/Utils"));
35
+
36
+ var _SaveCloseButtons = _interopRequireDefault(require("./Components/SaveCloseButtons"));
37
+
38
+ var _i18n = _interopRequireDefault(require("./i18n"));
39
+
40
+ require("./index.css");
41
+
42
+ 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); }
43
+
44
+ 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; }
45
+
46
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
47
+
48
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
49
+
50
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
51
+
52
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
53
+
54
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
55
+
56
+ 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); } }
57
+
58
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
59
+
60
+ function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
61
+
62
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
63
+
64
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
65
+
66
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
67
+
68
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
69
+
70
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
71
+
72
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
73
+
74
+ 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; } }
75
+
76
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
77
+
78
+ 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; }
79
+
80
+ if (!window.localStorage) {
81
+ window.localStorage = {
82
+ getItem: function getItem() {
83
+ return null;
84
+ },
85
+ setItem: function setItem() {
86
+ return null;
87
+ }
88
+ };
89
+ }
90
+ /**
91
+ * @extends {Router<import('./types').GenericAppProps, import('./types').GenericAppState>}
92
+ */
93
+
94
+
95
+ var GenericApp = /*#__PURE__*/function (_Router) {
96
+ _inherits(GenericApp, _Router);
97
+
98
+ var _super = _createSuper(GenericApp);
99
+
100
+ /**
101
+ * @param {import('./types').GenericAppProps} props
102
+ * @param {import('./types').GenericAppSettings | undefined} settings
103
+ */
104
+ function GenericApp(props, settings) {
105
+ var _this;
106
+
107
+ _classCallCheck(this, GenericApp);
108
+
109
+ // Remove `!Connection.isWeb() && window.adapterName !== 'material'` when iobroker.socket will support native ws
110
+ if (!_Connection["default"].isWeb() && window.io && window.location.port === '3000') {
111
+ try {
112
+ var io = new window.SocketClient();
113
+ delete window.io;
114
+ window.io = io;
115
+ } catch (e) {// ignore
116
+ }
117
+ }
118
+
119
+ _this = _super.call(this, props);
120
+
121
+ _defineProperty(_assertThisInitialized(_this), "onSystemConfigChanged", function (id, obj) {
122
+ if (obj && id === 'system.config') {
123
+ var _obj$common;
124
+
125
+ if (_this.socket.systemLang !== (obj === null || obj === void 0 ? void 0 : obj.common.language)) {
126
+ _this.socket.systemLang = (obj === null || obj === void 0 ? void 0 : obj.common.language) || 'en';
127
+
128
+ _i18n["default"].setLanguage(_this.socket.systemLang);
129
+ }
130
+
131
+ if (_this._systemConfig.expertMode !== !!(obj !== null && obj !== void 0 && (_obj$common = obj.common) !== null && _obj$common !== void 0 && _obj$common.expertMode)) {
132
+ _this._systemConfig = (obj === null || obj === void 0 ? void 0 : obj.common) || {};
133
+
134
+ _this.setState({
135
+ expertMode: _this.getExpertMode()
136
+ });
137
+ } else {
138
+ _this._systemConfig = (obj === null || obj === void 0 ? void 0 : obj.common) || {};
139
+ }
140
+ }
141
+ });
142
+
143
+ _defineProperty(_assertThisInitialized(_this), "onReceiveMessage", function (message) {
144
+ if (message !== null && message !== void 0 && message.data) {
145
+ if (message.data === 'updateTheme') {
146
+ var newThemeName = _Utils["default"].getThemeName();
147
+
148
+ _Utils["default"].setThemeName(_Utils["default"].getThemeName());
149
+
150
+ var _theme = _this.createTheme(newThemeName);
151
+
152
+ _this.setState({
153
+ theme: _theme,
154
+ themeName: _this.getThemeName(_theme),
155
+ themeType: _this.getThemeType(_theme)
156
+ }, function () {
157
+ _this.props.onThemeChange && _this.props.onThemeChange(newThemeName);
158
+ _this.onThemeChanged && _this.onThemeChanged(newThemeName);
159
+ });
160
+ } else if (message.data === 'updateExpertMode') {
161
+ _this.onToggleExpertMode && _this.onToggleExpertMode(_this.getExpertMode());
162
+ } else {
163
+ console.warn('Received unknown message: ' + JSON.stringify(message.data));
164
+ }
165
+ }
166
+ });
167
+
168
+ _defineProperty(_assertThisInitialized(_this), "onResize", function () {
169
+ _this.resizeTimer && clearTimeout(_this.resizeTimer);
170
+ _this.resizeTimer = setTimeout(function () {
171
+ _this.resizeTimer = null;
172
+
173
+ _this.setState({
174
+ width: GenericApp.getWidth()
175
+ });
176
+ }, 200);
177
+ });
178
+
179
+ (0, _Prompt["default"])();
180
+ var query = (window.location.search || '').replace(/^\?/, '').replace(/#.*$/, '');
181
+ var args = {};
182
+ query.trim().split('&').filter(function (t) {
183
+ return t.trim();
184
+ }).forEach(function (b) {
185
+ var parts = b.split('=');
186
+ args[parts[0]] = parts.length === 2 ? parts[1] : true;
187
+
188
+ if (args[parts[0]] === 'true') {
189
+ args[parts[0]] = true;
190
+ } else if (args[parts[0]] === 'false') {
191
+ args[parts[0]] = false;
192
+ }
193
+ }); // extract instance from URL
194
+
195
+ _this.instance = args.instance !== undefined ? parseInt(args.instance, 10) || 0 : parseInt(window.location.search.slice(1), 10) || 0; // extract adapter name from URL
196
+
197
+ var tmp = window.location.pathname.split('/');
198
+ _this.adapterName = (settings === null || settings === void 0 ? void 0 : settings.adapterName) || props.adapterName || window.adapterName || tmp[tmp.length - 2] || 'iot';
199
+ _this.instanceId = "system.adapter.".concat(_this.adapterName, ".").concat(_this.instance);
200
+ _this.newReact = args.newReact === true; // it is admin5
201
+
202
+ var location = _Router2["default"].getLocation();
203
+
204
+ location.tab = location.tab || window.localStorage.getItem(_this.adapterName + '-adapter') || '';
205
+
206
+ var themeInstance = _this.createTheme();
207
+
208
+ _this.state = {
209
+ selectedTab: window.localStorage.getItem(_this.adapterName + '-adapter') || '',
210
+ selectedTabNum: -1,
211
+ "native": {},
212
+ errorText: '',
213
+ changed: false,
214
+ connected: false,
215
+ loaded: false,
216
+ isConfigurationError: '',
217
+ expertMode: false,
218
+ toast: '',
219
+ theme: themeInstance,
220
+ themeName: _this.getThemeName(themeInstance),
221
+ themeType: _this.getThemeType(themeInstance),
222
+ bottomButtons: (settings && settings.bottomButtons) === false ? false : (props && props.bottomButtons) === false ? false : true,
223
+ width: GenericApp.getWidth()
224
+ }; // init translations
225
+
226
+ var translations = {
227
+ 'en': require('./i18n/en.json'),
228
+ 'de': require('./i18n/de.json'),
229
+ 'ru': require('./i18n/ru.json'),
230
+ 'pt': require('./i18n/pt.json'),
231
+ 'nl': require('./i18n/nl.json'),
232
+ 'fr': require('./i18n/fr.json'),
233
+ 'it': require('./i18n/it.json'),
234
+ 'es': require('./i18n/es.json'),
235
+ 'pl': require('./i18n/pl.json'),
236
+ 'zh-cn': require('./i18n/zh-cn.json')
237
+ }; // merge together
238
+
239
+ if (settings && settings.translations) {
240
+ Object.keys(settings.translations).forEach(function (lang) {
241
+ return translations[lang] = Object.assign(translations[lang], settings.translations[lang]);
242
+ });
243
+ } else if (props.translations) {
244
+ Object.keys(props.translations).forEach(function (lang) {
245
+ return translations[lang] = Object.assign(translations[lang], props.translations[lang]);
246
+ });
247
+ }
248
+
249
+ _i18n["default"].setTranslations(translations);
250
+
251
+ _this.savedNative = {}; // to detect if the config changed
252
+
253
+ _this.encryptedFields = props.encryptedFields || (settings === null || settings === void 0 ? void 0 : settings.encryptedFields) || [];
254
+ _this.sentryDSN = settings && settings.sentryDSN || props.sentryDSN;
255
+ _this.socket = new _Connection["default"](_objectSpread(_objectSpread({}, (props === null || props === void 0 ? void 0 : props.socket) || (settings === null || settings === void 0 ? void 0 : settings.socket)), {}, {
256
+ name: _this.adapterName,
257
+ doNotLoadAllObjects: settings === null || settings === void 0 ? void 0 : settings.doNotLoadAllObjects,
258
+ onProgress: function onProgress(progress) {
259
+ if (progress === _Connection.PROGRESS.CONNECTING) {
260
+ _this.setState({
261
+ connected: false
262
+ });
263
+ } else if (progress === _Connection.PROGRESS.READY) {
264
+ _this.setState({
265
+ connected: true
266
+ });
267
+ } else {
268
+ _this.setState({
269
+ connected: true
270
+ });
271
+ }
272
+ },
273
+ onReady: function onReady(objects, scripts) {
274
+ _i18n["default"].setLanguage(_this.socket.systemLang); // subscribe because of language and expert mode
275
+
276
+
277
+ _this.socket.subscribeObject('system.config', _this.onSystemConfigChanged).then(function () {
278
+ return _this.getSystemConfig();
279
+ }).then(function (obj) {
280
+ _this._secret = typeof obj !== 'undefined' && obj["native"] && obj["native"].secret || 'Zgfr56gFe87jJOM';
281
+ _this._systemConfig = (obj === null || obj === void 0 ? void 0 : obj.common) || {};
282
+ return _this.socket.getObject(_this.instanceId);
283
+ }).then(function (instanceObj) {
284
+ var waitPromise;
285
+ var sentryEnabled = _this._systemConfig.diag !== 'none' && instanceObj && instanceObj.common && instanceObj.common.name && instanceObj.common.version && !instanceObj.common.disableDataReporting && window.location.host !== 'localhost:3000'; // activate sentry plugin
286
+
287
+ if (!_this.sentryStarted && _this.sentryDSN && sentryEnabled) {
288
+ _this.sentryStarted = true;
289
+ Sentry.init({
290
+ dsn: _this.sentryDSN,
291
+ release: "iobroker.".concat(instanceObj.common.name, "@").concat(instanceObj.common.version),
292
+ integrations: [new SentryIntegrations.Dedupe()]
293
+ });
294
+ } // read UUID and init sentry with it.
295
+ // for backward compatibility it will be processed separately from above logic: some adapters could still have this.sentryDSN as undefined
296
+
297
+
298
+ if (!_this.sentryInited && sentryEnabled) {
299
+ _this.sentryInited = true;
300
+ waitPromise = _this.socket.getObject('system.meta.uuid').then(function (uuidObj) {
301
+ if (uuidObj && uuidObj["native"] && uuidObj["native"].uuid) {
302
+ Sentry.configureScope(function (scope) {
303
+ return scope.setUser({
304
+ id: uuidObj["native"].uuid
305
+ });
306
+ });
307
+ }
308
+ });
309
+ }
310
+
311
+ waitPromise = waitPromise || Promise.resolve();
312
+ waitPromise.then(function () {
313
+ if (instanceObj) {
314
+ _this.common = instanceObj === null || instanceObj === void 0 ? void 0 : instanceObj.common;
315
+
316
+ _this.onPrepareLoad(instanceObj["native"], instanceObj.encryptedNative); // decode all secrets
317
+
318
+
319
+ _this.savedNative = JSON.parse(JSON.stringify(instanceObj["native"]));
320
+
321
+ _this.setState({
322
+ "native": instanceObj["native"],
323
+ loaded: true,
324
+ expertMode: _this.getExpertMode()
325
+ }, function () {
326
+ return _this.onConnectionReady && _this.onConnectionReady();
327
+ });
328
+ } else {
329
+ console.warn('Cannot load instance settings');
330
+
331
+ _this.setState({
332
+ "native": {},
333
+ loaded: true,
334
+ expertMode: _this.getExpertMode()
335
+ }, function () {
336
+ return _this.onConnectionReady && _this.onConnectionReady();
337
+ });
338
+ }
339
+ });
340
+ });
341
+ },
342
+ onError: function onError(err) {
343
+ console.error(err);
344
+
345
+ _this.showError(err);
346
+ }
347
+ }));
348
+ return _this;
349
+ }
350
+
351
+ _createClass(GenericApp, [{
352
+ key: "componentDidMount",
353
+ value:
354
+ /**
355
+ * Called immediately after a component is mounted. Setting state here will trigger re-rendering.
356
+ */
357
+ function componentDidMount() {
358
+ window.addEventListener('resize', this.onResize, true);
359
+ window.addEventListener('message', this.onReceiveMessage, false);
360
+
361
+ _get(_getPrototypeOf(GenericApp.prototype), "componentDidMount", this).call(this);
362
+ }
363
+ /**
364
+ * Called immediately before a component is destroyed.
365
+ */
366
+
367
+ }, {
368
+ key: "componentWillUnmount",
369
+ value: function componentWillUnmount() {
370
+ window.removeEventListener('resize', this.onResize, true);
371
+ window.removeEventListener('message', this.onReceiveMessage, false);
372
+
373
+ _get(_getPrototypeOf(GenericApp.prototype), "componentWillUnmount", this).call(this);
374
+ }
375
+ }, {
376
+ key: "createTheme",
377
+ value:
378
+ /**
379
+ * Get a theme
380
+ * @param {string} name Theme name
381
+ * @returns {import('./types').Theme}
382
+ */
383
+ function createTheme() {
384
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
385
+ return (0, _Theme["default"])(_Utils["default"].getThemeName(name));
386
+ }
387
+ /**
388
+ * Get the theme name
389
+ * @param {import('./types').Theme} theme Theme
390
+ * @returns {string} Theme name
391
+ */
392
+
393
+ }, {
394
+ key: "getThemeName",
395
+ value: function getThemeName(theme) {
396
+ return theme.name;
397
+ }
398
+ /**
399
+ * Get the theme type
400
+ * @param {import('./types').Theme} theme Theme
401
+ * @returns {string} Theme type
402
+ */
403
+
404
+ }, {
405
+ key: "getThemeType",
406
+ value: function getThemeType(theme) {
407
+ return theme.palette.mode;
408
+ }
409
+ /**
410
+ * Changes the current theme
411
+ */
412
+
413
+ }, {
414
+ key: "toggleTheme",
415
+ value: function toggleTheme() {
416
+ var _this2 = this;
417
+
418
+ var themeName = this.state.themeName; // dark => blue => colored => light => dark
419
+
420
+ var newThemeName = themeName === 'dark' ? 'blue' : themeName === 'blue' ? 'colored' : themeName === 'colored' ? 'light' : 'dark';
421
+
422
+ _Utils["default"].setThemeName(newThemeName);
423
+
424
+ var theme = this.createTheme(newThemeName);
425
+ this.setState({
426
+ theme: theme,
427
+ themeName: this.getThemeName(theme),
428
+ themeType: this.getThemeType(theme)
429
+ }, function () {
430
+ _this2.props.onThemeChange && _this2.props.onThemeChange(newThemeName);
431
+ _this2.onThemeChanged && _this2.onThemeChanged(newThemeName);
432
+ });
433
+ }
434
+ /**
435
+ * Gets the system configuration.
436
+ * @returns {Promise<ioBroker.OtherObject>}
437
+ */
438
+
439
+ }, {
440
+ key: "getSystemConfig",
441
+ value: function getSystemConfig() {
442
+ return this.socket.getSystemConfig();
443
+ }
444
+ /**
445
+ * Get current expert mode
446
+ * @returns {boolean}
447
+ */
448
+
449
+ }, {
450
+ key: "getExpertMode",
451
+ value: function getExpertMode() {
452
+ return window.sessionStorage.getItem('App.expertMode') === 'true' || !!this._systemConfig.expertMode;
453
+ }
454
+ /**
455
+ * Gets called when the socket.io connection is ready.
456
+ * You can overload this function to execute own commands.
457
+ */
458
+
459
+ }, {
460
+ key: "onConnectionReady",
461
+ value: function onConnectionReady() {}
462
+ /**
463
+ * Encrypts a string.
464
+ * @param {string} value
465
+ * @returns {string}
466
+ */
467
+
468
+ }, {
469
+ key: "encrypt",
470
+ value: function encrypt(value) {
471
+ var result = '';
472
+
473
+ for (var i = 0; i < value.length; i++) {
474
+ result += String.fromCharCode(this._secret[i % this._secret.length].charCodeAt(0) ^ value.charCodeAt(i));
475
+ }
476
+
477
+ return result;
478
+ }
479
+ /**
480
+ * Decrypts a string.
481
+ * @param {string} value
482
+ * @returns {string}
483
+ */
484
+
485
+ }, {
486
+ key: "decrypt",
487
+ value: function decrypt(value) {
488
+ var result = '';
489
+
490
+ for (var i = 0; i < value.length; i++) {
491
+ result += String.fromCharCode(this._secret[i % this._secret.length].charCodeAt(0) ^ value.charCodeAt(i));
492
+ }
493
+
494
+ return result;
495
+ }
496
+ /**
497
+ * Gets called when the navigation hash changes.
498
+ * You may override this if needed.
499
+ */
500
+
501
+ }, {
502
+ key: "onHashChanged",
503
+ value: function onHashChanged() {
504
+ var location = _Router2["default"].getLocation();
505
+
506
+ if (location.tab !== this.state.selectedTab) {
507
+ this.selectTab(location.tab);
508
+ }
509
+ }
510
+ /**
511
+ * Selects the given tab.
512
+ * @param {string} tab
513
+ * @param {number} [index]
514
+ */
515
+
516
+ }, {
517
+ key: "selectTab",
518
+ value: function selectTab(tab, index) {
519
+ window.localStorage[this.adapterName + '-adapter'] = tab;
520
+ this.setState({
521
+ selectedTab: tab,
522
+ selectedTabNum: index
523
+ });
524
+ }
525
+ /**
526
+ * Gets called before the settings are saved.
527
+ * You may override this if needed.
528
+ * @param {Record<string, any>} settings
529
+ */
530
+
531
+ }, {
532
+ key: "onPrepareSave",
533
+ value: function onPrepareSave(settings) {
534
+ var _this3 = this;
535
+
536
+ // here you can encode values
537
+ this.encryptedFields && this.encryptedFields.forEach(function (attr) {
538
+ if (settings[attr]) {
539
+ settings[attr] = _this3.encrypt(settings[attr]);
540
+ }
541
+ });
542
+ return true;
543
+ }
544
+ /**
545
+ * Gets called after the settings are loaded.
546
+ * You may override this if needed.
547
+ * @param {Record<string, any>} settings
548
+ * @param {string[]} encryptedNative optional list of fields to be decrypted
549
+ */
550
+
551
+ }, {
552
+ key: "onPrepareLoad",
553
+ value: function onPrepareLoad(settings, encryptedNative) {
554
+ var _this4 = this;
555
+
556
+ // here you can encode values
557
+ this.encryptedFields && this.encryptedFields.forEach(function (attr) {
558
+ if (settings[attr]) {
559
+ settings[attr] = _this4.decrypt(settings[attr]);
560
+ }
561
+ });
562
+ encryptedNative && encryptedNative.forEach(function (attr) {
563
+ _this4.encryptedFields = _this4.encryptedFields || [];
564
+ !_this4.encryptedFields.includes(attr) && _this4.encryptedFields.push(attr);
565
+
566
+ if (settings[attr]) {
567
+ settings[attr] = _this4.decrypt(settings[attr]);
568
+ }
569
+ });
570
+ }
571
+ /**
572
+ * Gets the extendable instances.
573
+ * @returns {Promise<any[]>}
574
+ */
575
+
576
+ }, {
577
+ key: "getExtendableInstances",
578
+ value: function getExtendableInstances() {
579
+ var _this5 = this;
580
+
581
+ return new Promise(function (resolve) {
582
+ _this5.socket._socket.emit('getObjectView', 'system', 'instance', null, function (err, doc) {
583
+ if (err) {
584
+ resolve([]);
585
+ } else {
586
+ resolve(doc.rows.filter(function (item) {
587
+ return item.value.common.webExtendable;
588
+ }).map(function (item) {
589
+ return item.value;
590
+ }));
591
+ }
592
+ });
593
+ });
594
+ }
595
+ /**
596
+ * Gets the IP addresses of the given host.
597
+ * @param {string} host
598
+ */
599
+
600
+ }, {
601
+ key: "getIpAddresses",
602
+ value: function getIpAddresses(host) {
603
+ var _this6 = this;
604
+
605
+ return new Promise(function (resolve, reject) {
606
+ _this6.socket._socket.emit('getHostByIp', host || _this6.common.host, function (ip, _host) {
607
+ var IPs4 = [{
608
+ name: '[IPv4] 0.0.0.0 - ' + _i18n["default"].t('ra_Listen on all IPs'),
609
+ address: '0.0.0.0',
610
+ family: 'ipv4'
611
+ }];
612
+ var IPs6 = [{
613
+ name: '[IPv6] ::',
614
+ address: '::',
615
+ family: 'ipv6'
616
+ }];
617
+
618
+ if (_host) {
619
+ host = _host;
620
+
621
+ if (host["native"].hardware && host["native"].hardware.networkInterfaces) {
622
+ Object.keys(host["native"].hardware.networkInterfaces).forEach(function (eth) {
623
+ return host["native"].hardware.networkInterfaces[eth].forEach(function (inter) {
624
+ if (inter.family !== 'IPv6') {
625
+ IPs4.push({
626
+ name: '[' + inter.family + '] ' + inter.address + ' - ' + eth,
627
+ address: inter.address,
628
+ family: 'ipv4'
629
+ });
630
+ } else {
631
+ IPs6.push({
632
+ name: '[' + inter.family + '] ' + inter.address + ' - ' + eth,
633
+ address: inter.address,
634
+ family: 'ipv6'
635
+ });
636
+ }
637
+ });
638
+ });
639
+ }
640
+
641
+ IPs6.forEach(function (ip) {
642
+ return IPs4.push(ip);
643
+ });
644
+ }
645
+
646
+ resolve(IPs4);
647
+ });
648
+ });
649
+ }
650
+ /**
651
+ * Saves the settings to the server.
652
+ * @param {boolean} isClose True if the user is closing the dialog.
653
+ */
654
+
655
+ }, {
656
+ key: "onSave",
657
+ value: function onSave(isClose) {
658
+ var _this7 = this;
659
+
660
+ var oldObj;
661
+
662
+ if (this.state.isConfigurationError) {
663
+ this.setState({
664
+ errorText: this.state.isConfigurationError
665
+ });
666
+ return;
667
+ }
668
+
669
+ this.socket.getObject(this.instanceId).then(function (_oldObj) {
670
+ oldObj = _oldObj || {};
671
+
672
+ for (var a in _this7.state["native"]) {
673
+ if (_this7.state["native"].hasOwnProperty(a)) {
674
+ if (_this7.state["native"][a] === null) {
675
+ oldObj["native"][a] = null;
676
+ } else if (_this7.state["native"][a] !== undefined) {
677
+ oldObj["native"][a] = JSON.parse(JSON.stringify(_this7.state["native"][a]));
678
+ } else {
679
+ delete oldObj["native"][a];
680
+ }
681
+ }
682
+ }
683
+
684
+ if (_this7.state.common) {
685
+ for (var b in _this7.state.common) {
686
+ if (_this7.state.common[b] === null) {
687
+ oldObj.common[b] = null;
688
+ } else if (_this7.state.common[b] !== undefined) {
689
+ oldObj.common[b] = JSON.parse(JSON.stringify(_this7.state.common[b]));
690
+ } else {
691
+ delete oldObj.common[b];
692
+ }
693
+ }
694
+ }
695
+
696
+ if (_this7.onPrepareSave(oldObj["native"]) !== false) {
697
+ return _this7.socket.setObject(_this7.instanceId, oldObj);
698
+ } else {
699
+ return Promise.reject('Invalid configuration');
700
+ }
701
+ }).then(function () {
702
+ _this7.savedNative = oldObj["native"];
703
+ globalThis.changed = false;
704
+
705
+ _this7.setState({
706
+ changed: false
707
+ });
708
+
709
+ isClose && GenericApp.onClose();
710
+ })["catch"](function (e) {
711
+ console.error("Cannot save configuration: ".concat(e));
712
+ });
713
+ }
714
+ /**
715
+ * Renders the toast.
716
+ * @returns {JSX.Element | null} The JSX element.
717
+ */
718
+
719
+ }, {
720
+ key: "renderToast",
721
+ value: function renderToast() {
722
+ var _this8 = this;
723
+
724
+ if (!this.state.toast) return null;
725
+ return /*#__PURE__*/_react["default"].createElement(_Snackbar["default"], {
726
+ anchorOrigin: {
727
+ vertical: 'bottom',
728
+ horizontal: 'left'
729
+ },
730
+ open: true,
731
+ autoHideDuration: 6000,
732
+ onClose: function onClose() {
733
+ return _this8.setState({
734
+ toast: ''
735
+ });
736
+ },
737
+ ContentProps: {
738
+ 'aria-describedby': 'message-id'
739
+ },
740
+ message: /*#__PURE__*/_react["default"].createElement("span", {
741
+ id: "message-id"
742
+ }, this.state.toast),
743
+ action: [/*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
744
+ key: "close",
745
+ "aria-label": "Close",
746
+ color: "inherit",
747
+ className: this.props.classes.close,
748
+ onClick: function onClick() {
749
+ return _this8.setState({
750
+ toast: ''
751
+ });
752
+ },
753
+ size: "large"
754
+ }, /*#__PURE__*/_react["default"].createElement(_Close["default"], null))]
755
+ });
756
+ }
757
+ /**
758
+ * Closes the dialog.
759
+ * @private
760
+ */
761
+
762
+ }, {
763
+ key: "renderError",
764
+ value:
765
+ /**
766
+ * Renders the error dialog.
767
+ * @returns {JSX.Element | null} The JSX element.
768
+ */
769
+ function renderError() {
770
+ var _this9 = this;
771
+
772
+ if (!this.state.errorText) {
773
+ return null;
774
+ } else {
775
+ return /*#__PURE__*/_react["default"].createElement(_Error["default"], {
776
+ text: this.state.errorText,
777
+ onClose: function onClose() {
778
+ return _this9.setState({
779
+ errorText: ''
780
+ });
781
+ }
782
+ });
783
+ }
784
+ }
785
+ /**
786
+ * Checks if the configuration has changed.
787
+ * @param {Record<string, any>} [native] the new state
788
+ */
789
+
790
+ }, {
791
+ key: "getIsChanged",
792
+ value: function getIsChanged(_native) {
793
+ _native = _native || this.state["native"];
794
+ var isChanged = JSON.stringify(_native) !== JSON.stringify(this.savedNative);
795
+
796
+ if (isChanged) {
797
+ globalThis.changed = true;
798
+ } else {
799
+ globalThis.changed = false;
800
+ }
801
+
802
+ return isChanged;
803
+ }
804
+ /**
805
+ * Gets called when loading the configuration.
806
+ * @param {Record<string, any>} newNative The new configuration object.
807
+ */
808
+
809
+ }, {
810
+ key: "onLoadConfig",
811
+ value: function onLoadConfig(newNative) {
812
+ if (JSON.stringify(newNative) !== JSON.stringify(this.state["native"])) {
813
+ this.setState({
814
+ "native": newNative,
815
+ changed: this.getIsChanged(newNative)
816
+ });
817
+ }
818
+ }
819
+ /**
820
+ * Sets the configuration error.
821
+ * @param {string} errorText
822
+ */
823
+
824
+ }, {
825
+ key: "setConfigurationError",
826
+ value: function setConfigurationError(errorText) {
827
+ if (this.state.isConfigurationError !== errorText) {
828
+ this.setState({
829
+ isConfigurationError: errorText
830
+ });
831
+ }
832
+ }
833
+ /**
834
+ * Renders the save and close buttons.
835
+ * @returns {JSX.Element | undefined} The JSX element.
836
+ */
837
+
838
+ }, {
839
+ key: "renderSaveCloseButtons",
840
+ value: function renderSaveCloseButtons() {
841
+ var _this10 = this;
842
+
843
+ if (this.state.bottomButtons) {
844
+ return /*#__PURE__*/_react["default"].createElement(_SaveCloseButtons["default"], {
845
+ theme: this.state.theme,
846
+ newReact: this.newReact,
847
+ noTextOnButtons: this.state.width === 'xs' || this.state.width === 'sm' || this.state.width === 'md',
848
+ changed: this.state.changed,
849
+ onSave: function onSave(isClose) {
850
+ return _this10.onSave(isClose);
851
+ },
852
+ onClose: function onClose() {
853
+ return GenericApp.onClose();
854
+ }
855
+ });
856
+ } else {
857
+ return null;
858
+ }
859
+ }
860
+ /**
861
+ * @private
862
+ * @param {Record<string, any>} obj
863
+ * @param {any} attrs
864
+ * @param {any} value
865
+ * @returns {boolean | undefined}
866
+ */
867
+
868
+ }, {
869
+ key: "_updateNativeValue",
870
+ value: function _updateNativeValue(obj, attrs, value) {
871
+ if (_typeof(attrs) !== 'object') {
872
+ attrs = attrs.split('.');
873
+ }
874
+
875
+ var attr = attrs.shift();
876
+
877
+ if (!attrs.length) {
878
+ if (value && _typeof(value) === 'object') {
879
+ if (JSON.stringify(obj[attr]) !== JSON.stringify(value)) {
880
+ obj[attr] = value;
881
+ return true;
882
+ }
883
+ } else if (obj[attr] !== value) {
884
+ obj[attr] = value;
885
+ return true;
886
+ } else {
887
+ return false;
888
+ }
889
+ } else {
890
+ obj[attr] = obj[attr] || {};
891
+
892
+ if (_typeof(obj[attr]) !== 'object') {
893
+ throw new Error('attribute ' + attr + ' is no object, but ' + _typeof(obj[attr]));
894
+ }
895
+
896
+ return this._updateNativeValue(obj[attr], attrs, value);
897
+ }
898
+ }
899
+ /**
900
+ * Update the native value
901
+ * @param {string} attr The attribute name with dots as delimiter.
902
+ * @param {any} value The new value.
903
+ * @param {(() => void)} [cb] Callback which will be called upon completion.
904
+ */
905
+
906
+ }, {
907
+ key: "updateNativeValue",
908
+ value: function updateNativeValue(attr, value, cb) {
909
+ var _native2 = JSON.parse(JSON.stringify(this.state["native"]));
910
+
911
+ if (this._updateNativeValue(_native2, attr, value)) {
912
+ var changed = this.getIsChanged(_native2);
913
+ this.setState({
914
+ "native": _native2,
915
+ changed: changed
916
+ }, cb);
917
+ }
918
+ }
919
+ /**
920
+ * Set the error text to be shown.
921
+ * @param {string | JSX.Element} text
922
+ */
923
+
924
+ }, {
925
+ key: "showError",
926
+ value: function showError(text) {
927
+ this.setState({
928
+ errorText: text
929
+ });
930
+ }
931
+ /**
932
+ * Sets the toast to be shown.
933
+ * @param {string} toast
934
+ */
935
+
936
+ }, {
937
+ key: "showToast",
938
+ value: function showToast(toast) {
939
+ this.setState({
940
+ toast: toast
941
+ });
942
+ }
943
+ /**
944
+ * Renders this component.
945
+ * @returns {JSX.Element} The JSX element.
946
+ */
947
+
948
+ }, {
949
+ key: "render",
950
+ value: function render() {
951
+ if (!this.state.loaded) {
952
+ return /*#__PURE__*/_react["default"].createElement(_Loader["default"], {
953
+ theme: this.state.themeType
954
+ });
955
+ }
956
+
957
+ return /*#__PURE__*/_react["default"].createElement("div", {
958
+ className: "App"
959
+ }, this.renderError(), this.renderToast(), this.renderSaveCloseButtons());
960
+ }
961
+ }], [{
962
+ key: "getWidth",
963
+ value:
964
+ /**
965
+ * Gets the width depending on the window inner width.
966
+ * @returns {import('./types').Width}
967
+ */
968
+ function getWidth() {
969
+ /**
970
+ * innerWidth |xs sm md lg xl
971
+ * |-------|-------|-------|-------|------>
972
+ * width | xs | sm | md | lg | xl
973
+ */
974
+ var SIZES = {
975
+ xs: 0,
976
+ sm: 600,
977
+ md: 960,
978
+ lg: 1280,
979
+ xl: 1920
980
+ };
981
+ var width = window.innerWidth;
982
+ var keys = Object.keys(SIZES).reverse();
983
+ var widthComputed = keys.find(function (key) {
984
+ return width >= SIZES[key];
985
+ });
986
+ return widthComputed || 'xs';
987
+ }
988
+ }, {
989
+ key: "onClose",
990
+ value: function onClose() {
991
+ if (typeof window.parent !== 'undefined' && window.parent) {
992
+ try {
993
+ if (window.parent.$iframeDialog && typeof window.parent.$iframeDialog.close === 'function') {
994
+ window.parent.$iframeDialog.close();
995
+ } else {
996
+ window.parent.postMessage('close', '*');
997
+ }
998
+ } catch (e) {
999
+ window.parent.postMessage('close', '*');
1000
+ }
1001
+ }
1002
+ }
1003
+ }]);
1004
+
1005
+ return GenericApp;
1006
+ }(_Router2["default"]);
1007
+
1008
+ GenericApp.propTypes = {
1009
+ adapterName: _propTypes["default"].string,
1010
+ // (optional) name of adapter
1011
+ onThemeChange: _propTypes["default"].func,
1012
+ // (optional) called by theme change
1013
+ socket: _propTypes["default"].object,
1014
+ // (optional) socket information (host, port)
1015
+ encryptedFields: _propTypes["default"].array,
1016
+ // (optional) list of native attributes, that must be encrypted
1017
+ bottomButtons: _propTypes["default"].bool // If the bottom buttons (Save/Close) must be shown
1018
+
1019
+ };
1020
+ var _default = GenericApp;
1021
+ exports["default"] = _default;
1022
+ //# sourceMappingURL=GenericApp.js.map