@iobroker/adapter-react-v5 7.0.2 → 7.1.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 (307) hide show
  1. package/Components/404.d.ts +3 -2
  2. package/Components/404.js +3 -2
  3. package/Components/ColorPicker.d.ts +22 -8
  4. package/Components/ColorPicker.js +34 -17
  5. package/Components/ComplexCron.js +24 -24
  6. package/Components/CopyToClipboard.d.ts +10 -1
  7. package/Components/CopyToClipboard.js +17 -8
  8. package/Components/CustomModal.d.ts +1 -1
  9. package/Components/CustomModal.js +8 -8
  10. package/Components/FileBrowser.d.ts +11 -11
  11. package/Components/FileBrowser.js +135 -152
  12. package/Components/FileViewer.js +34 -23
  13. package/Components/Icon.d.ts +16 -2
  14. package/Components/Icon.js +19 -8
  15. package/Components/IconPicker.js +10 -14
  16. package/Components/IconSelector.d.ts +1 -1
  17. package/Components/IconSelector.js +64 -74
  18. package/Components/Image.d.ts +8 -4
  19. package/Components/Image.js +13 -32
  20. package/Components/Loader.d.ts +2 -2
  21. package/Components/Loader.js +21 -18
  22. package/Components/Loaders/MV.d.ts +6 -1
  23. package/Components/Loaders/MV.js +23 -7
  24. package/Components/Loaders/PT.d.ts +7 -2
  25. package/Components/Loaders/PT.js +20 -7
  26. package/Components/Loaders/Vendor.d.ts +2 -2
  27. package/Components/Loaders/Vendor.js +15 -7
  28. package/Components/Logo.js +16 -18
  29. package/Components/MDUtils.d.ts +1 -1
  30. package/Components/MDUtils.js +8 -4
  31. package/Components/ObjectBrowser.d.ts +40 -39
  32. package/Components/ObjectBrowser.js +550 -435
  33. package/Components/Router.d.ts +1 -3
  34. package/Components/Router.js +3 -1
  35. package/Components/SaveCloseButtons.d.ts +3 -3
  36. package/Components/SaveCloseButtons.js +3 -3
  37. package/Components/Schedule.d.ts +15 -15
  38. package/Components/Schedule.js +177 -154
  39. package/Components/SelectWithIcon.d.ts +2 -2
  40. package/Components/SelectWithIcon.js +45 -34
  41. package/Components/SimpleCron/index.js +83 -43
  42. package/Components/TabContainer.js +2 -2
  43. package/Components/TabContent.js +1 -1
  44. package/Components/TabHeader.js +1 -1
  45. package/Components/TableResize.d.ts +2 -2
  46. package/Components/TableResize.js +5 -5
  47. package/Components/TextWithIcon.d.ts +1 -1
  48. package/Components/TextWithIcon.js +10 -8
  49. package/Components/ToggleThemeMenu.d.ts +2 -2
  50. package/Components/ToggleThemeMenu.js +3 -3
  51. package/Components/TreeTable.d.ts +18 -18
  52. package/Components/TreeTable.js +76 -72
  53. package/Components/UploadImage.d.ts +2 -2
  54. package/Components/UploadImage.js +25 -21
  55. package/Components/Utils.d.ts +42 -22
  56. package/Components/Utils.js +66 -65
  57. package/Components/withWidth.d.ts +2 -2
  58. package/Components/withWidth.js +10 -6
  59. package/Dialogs/ComplexCron.d.ts +2 -2
  60. package/Dialogs/ComplexCron.js +3 -3
  61. package/Dialogs/Confirm.d.ts +4 -4
  62. package/Dialogs/Confirm.js +18 -8
  63. package/Dialogs/Cron.d.ts +3 -3
  64. package/Dialogs/Cron.js +21 -17
  65. package/Dialogs/Error.d.ts +3 -3
  66. package/Dialogs/Error.js +6 -4
  67. package/Dialogs/Message.d.ts +3 -3
  68. package/Dialogs/Message.js +6 -4
  69. package/Dialogs/SelectFile.d.ts +4 -4
  70. package/Dialogs/SelectFile.js +6 -4
  71. package/Dialogs/SelectID.d.ts +12 -10
  72. package/Dialogs/SelectID.js +12 -8
  73. package/Dialogs/SimpleCron.d.ts +2 -2
  74. package/Dialogs/SimpleCron.js +2 -2
  75. package/Dialogs/TextInput.d.ts +2 -2
  76. package/Dialogs/TextInput.js +3 -3
  77. package/GenericApp.d.ts +19 -13
  78. package/GenericApp.js +128 -85
  79. package/LegacyConnection.d.ts +240 -248
  80. package/LegacyConnection.js +500 -525
  81. package/README.md +1234 -1170
  82. package/Theme.d.ts +1 -1
  83. package/Theme.js +9 -12
  84. package/assets/devices.json +1 -0
  85. package/assets/rooms.json +1 -0
  86. package/craco-module-federation.js +3 -12
  87. package/i18n/de.json +434 -434
  88. package/i18n/en.json +434 -434
  89. package/i18n/es.json +434 -434
  90. package/i18n/fr.json +434 -434
  91. package/i18n/it.json +434 -434
  92. package/i18n/nl.json +434 -434
  93. package/i18n/pl.json +434 -434
  94. package/i18n/pt.json +434 -434
  95. package/i18n/ru.json +434 -434
  96. package/i18n/uk.json +434 -434
  97. package/i18n/zh-cn.json +434 -434
  98. package/i18n.d.ts +26 -19
  99. package/i18n.js +28 -22
  100. package/icons/IconAdapter.js +2 -2
  101. package/icons/IconAlias.js +2 -2
  102. package/icons/IconChannel.js +2 -2
  103. package/icons/IconClearFilter.js +2 -2
  104. package/icons/IconClosed.js +2 -2
  105. package/icons/IconCopy.js +2 -2
  106. package/icons/IconDevice.js +2 -2
  107. package/icons/IconDocument.js +2 -2
  108. package/icons/IconDocumentReadOnly.js +2 -2
  109. package/icons/IconExpert.js +2 -2
  110. package/icons/IconFx.js +2 -2
  111. package/icons/IconInstance.js +2 -2
  112. package/icons/IconLogout.js +2 -2
  113. package/icons/IconNoIcon.js +2 -2
  114. package/icons/IconOpen.d.ts +2 -2
  115. package/icons/IconOpen.js +2 -2
  116. package/icons/IconProps.d.ts +4 -3
  117. package/icons/IconState.d.ts +2 -2
  118. package/icons/IconState.js +2 -2
  119. package/index.css +3 -2
  120. package/package.json +1 -1
  121. package/src/Components/404.tsx +32 -31
  122. package/src/Components/ColorPicker.tsx +142 -114
  123. package/src/Components/ComplexCron.tsx +174 -137
  124. package/src/Components/CopyToClipboard.tsx +22 -9
  125. package/src/Components/CustomModal.tsx +76 -69
  126. package/src/Components/FileBrowser.tsx +959 -852
  127. package/src/Components/FileViewer.tsx +146 -127
  128. package/src/Components/Icon.tsx +80 -52
  129. package/src/Components/IconPicker.tsx +83 -67
  130. package/src/Components/IconSelector.tsx +159 -141
  131. package/src/Components/Image.tsx +43 -26
  132. package/src/Components/Loader.tsx +56 -32
  133. package/src/Components/Logo.tsx +62 -52
  134. package/src/Components/MDUtils.tsx +10 -6
  135. package/src/Components/ObjectBrowser.tsx +3198 -2478
  136. package/src/Components/Router.tsx +11 -11
  137. package/src/Components/SaveCloseButtons.tsx +43 -39
  138. package/src/Components/Schedule.tsx +1091 -853
  139. package/src/Components/SelectWithIcon.tsx +135 -93
  140. package/src/Components/TabContainer.tsx +21 -19
  141. package/src/Components/TabContent.tsx +13 -12
  142. package/src/Components/TabHeader.tsx +10 -9
  143. package/src/Components/TableResize.tsx +52 -37
  144. package/src/Components/TextWithIcon.tsx +30 -19
  145. package/src/Components/ToggleThemeMenu.tsx +31 -13
  146. package/src/Components/TreeTable.tsx +468 -385
  147. package/src/Components/UploadImage.tsx +153 -121
  148. package/src/Components/Utils.tsx +135 -127
  149. package/src/Components/loader.css +40 -31
  150. package/src/Components/withWidth.tsx +23 -12
  151. package/src/Connection.tsx +1 -3
  152. package/src/Dialogs/ComplexCron.tsx +55 -61
  153. package/src/Dialogs/Confirm.tsx +88 -65
  154. package/src/Dialogs/Cron.tsx +122 -112
  155. package/src/Dialogs/Error.tsx +37 -42
  156. package/src/Dialogs/Message.tsx +39 -37
  157. package/src/Dialogs/SelectFile.tsx +95 -85
  158. package/src/Dialogs/SelectID.tsx +141 -129
  159. package/src/Dialogs/SimpleCron.tsx +44 -44
  160. package/src/Dialogs/TextInput.tsx +60 -68
  161. package/src/GenericApp.tsx +342 -242
  162. package/src/LegacyConnection.tsx +972 -842
  163. package/src/Prompt.tsx +3 -1
  164. package/src/Theme.tsx +19 -26
  165. package/src/icons/IconAdapter.tsx +16 -14
  166. package/src/icons/IconAlias.tsx +16 -14
  167. package/src/icons/IconChannel.tsx +55 -16
  168. package/src/icons/IconClearFilter.tsx +17 -15
  169. package/src/icons/IconClosed.tsx +16 -11
  170. package/src/icons/IconCopy.tsx +16 -11
  171. package/src/icons/IconDevice.tsx +121 -22
  172. package/src/icons/IconDocument.tsx +16 -11
  173. package/src/icons/IconDocumentReadOnly.tsx +21 -12
  174. package/src/icons/IconExpert.tsx +20 -12
  175. package/src/icons/IconFx.tsx +16 -14
  176. package/src/icons/IconInstance.tsx +16 -14
  177. package/src/icons/IconLogout.tsx +20 -18
  178. package/src/icons/IconNoIcon.tsx +16 -14
  179. package/src/icons/IconOpen.tsx +17 -12
  180. package/src/icons/IconProps.tsx +4 -3
  181. package/src/icons/IconState.tsx +34 -13
  182. package/src/index.css +3 -2
  183. package/tasks.js +91 -0
  184. package/types.d.ts +141 -0
  185. package/Components/Loaders/PT.css +0 -109
  186. package/Components/Loaders/Vendor.css +0 -13
  187. package/Components/loader.css +0 -222
  188. package/Components/types.d.ts +0 -82
  189. package/assets/devices/Alarm Systems.svg +0 -19
  190. package/assets/devices/Amplifier.svg +0 -22
  191. package/assets/devices/Awnings.svg +0 -5
  192. package/assets/devices/Battery Status.svg +0 -5
  193. package/assets/devices/Ceiling Spotlights.svg +0 -16
  194. package/assets/devices/Chandelier.svg +0 -7
  195. package/assets/devices/Climate.svg +0 -12
  196. package/assets/devices/Coffee Makers.svg +0 -6
  197. package/assets/devices/Cold Water.svg +0 -31
  198. package/assets/devices/Computer.svg +0 -21
  199. package/assets/devices/Consumption.svg +0 -8
  200. package/assets/devices/Curtains.svg +0 -43
  201. package/assets/devices/Dishwashers.svg +0 -12
  202. package/assets/devices/Doors.svg +0 -6
  203. package/assets/devices/Doorstep.svg +0 -35
  204. package/assets/devices/Dryer.svg +0 -14
  205. package/assets/devices/Fan.svg +0 -20
  206. package/assets/devices/Floor Lamps.svg +0 -5
  207. package/assets/devices/Garage Doors.svg +0 -9
  208. package/assets/devices/Gates.svg +0 -32
  209. package/assets/devices/Hairdryer.svg +0 -23
  210. package/assets/devices/Handle.svg +0 -6
  211. package/assets/devices/Hanging Lamps.svg +0 -9
  212. package/assets/devices/Heater.svg +0 -44
  213. package/assets/devices/Hoods.svg +0 -12
  214. package/assets/devices/Hot Water.svg +0 -10
  215. package/assets/devices/Humidity.svg +0 -41
  216. package/assets/devices/Iron.svg +0 -5
  217. package/assets/devices/Irrigation.svg +0 -23
  218. package/assets/devices/Led Strip.svg +0 -31
  219. package/assets/devices/Light.svg +0 -30
  220. package/assets/devices/Lightings.svg +0 -46
  221. package/assets/devices/Lock.svg +0 -19
  222. package/assets/devices/Louvre.svg +0 -7
  223. package/assets/devices/Mowing Machine.svg +0 -9
  224. package/assets/devices/Music.svg +0 -13
  225. package/assets/devices/Outdoor Blinds.svg +0 -7
  226. package/assets/devices/People.svg +0 -19
  227. package/assets/devices/Pool.svg +0 -8
  228. package/assets/devices/Power Consumption.svg +0 -13
  229. package/assets/devices/Printer.svg +0 -10
  230. package/assets/devices/Pump.svg +0 -10
  231. package/assets/devices/Receiver.svg +0 -19
  232. package/assets/devices/Sconces.svg +0 -10
  233. package/assets/devices/Security.svg +0 -34
  234. package/assets/devices/Shading.svg +0 -5
  235. package/assets/devices/Shutters.svg +0 -11
  236. package/assets/devices/SmokeDetector.svg +0 -13
  237. package/assets/devices/Sockets.svg +0 -13
  238. package/assets/devices/Speaker.svg +0 -35
  239. package/assets/devices/Stove.svg +0 -12
  240. package/assets/devices/Table Lamps.svg +0 -12
  241. package/assets/devices/Temperature Sensors.svg +0 -28
  242. package/assets/devices/Tv.svg +0 -8
  243. package/assets/devices/Vacuum Cleaner.svg +0 -16
  244. package/assets/devices/Ventilation.svg +0 -12
  245. package/assets/devices/Washing Machines.svg +0 -16
  246. package/assets/devices/Water Consumption.svg +0 -6
  247. package/assets/devices/Water Heater.svg +0 -8
  248. package/assets/devices/Water.svg +0 -40
  249. package/assets/devices/Weather.svg +0 -28
  250. package/assets/devices/Window.svg +0 -8
  251. package/assets/rooms/Anteroom.svg +0 -53
  252. package/assets/rooms/Attic.svg +0 -21
  253. package/assets/rooms/Balcony.svg +0 -13
  254. package/assets/rooms/Barn.svg +0 -6
  255. package/assets/rooms/Basement.svg +0 -5
  256. package/assets/rooms/Bathroom.svg +0 -38
  257. package/assets/rooms/Bedroom.svg +0 -5
  258. package/assets/rooms/Boiler Room.svg +0 -13
  259. package/assets/rooms/Carport.svg +0 -17
  260. package/assets/rooms/Cellar.svg +0 -89
  261. package/assets/rooms/Chamber.svg +0 -9
  262. package/assets/rooms/Corridor.svg +0 -53
  263. package/assets/rooms/Dining Area.svg +0 -37
  264. package/assets/rooms/Dining Room.svg +0 -37
  265. package/assets/rooms/Dining.svg +0 -37
  266. package/assets/rooms/Dressing Room.svg +0 -5
  267. package/assets/rooms/Driveway.svg +0 -15
  268. package/assets/rooms/Entrance.svg +0 -44
  269. package/assets/rooms/Equipment Room.svg +0 -15
  270. package/assets/rooms/Front Yard.svg +0 -64
  271. package/assets/rooms/Gallery.svg +0 -14
  272. package/assets/rooms/Garage.svg +0 -20
  273. package/assets/rooms/Garden.svg +0 -13
  274. package/assets/rooms/Ground Floor.svg +0 -95
  275. package/assets/rooms/Guest Bathroom.svg +0 -33
  276. package/assets/rooms/Guest Room.svg +0 -5
  277. package/assets/rooms/Gym.svg +0 -5
  278. package/assets/rooms/Hall.svg +0 -19
  279. package/assets/rooms/Home Theater.svg +0 -8
  280. package/assets/rooms/Kitchen.svg +0 -18
  281. package/assets/rooms/Laundry Room.svg +0 -12
  282. package/assets/rooms/Living Area.svg +0 -11
  283. package/assets/rooms/Living Room.svg +0 -10
  284. package/assets/rooms/Locker Room.svg +0 -17
  285. package/assets/rooms/Nursery.svg +0 -5
  286. package/assets/rooms/Office.svg +0 -8
  287. package/assets/rooms/Outdoors.svg +0 -7
  288. package/assets/rooms/Playroom.svg +0 -6
  289. package/assets/rooms/Pool.svg +0 -8
  290. package/assets/rooms/Rear Wall.svg +0 -30
  291. package/assets/rooms/Second Floor.svg +0 -95
  292. package/assets/rooms/Shed.svg +0 -16
  293. package/assets/rooms/Sleeping Area.svg +0 -22
  294. package/assets/rooms/Stairway.svg +0 -5
  295. package/assets/rooms/Stairwell.svg +0 -15
  296. package/assets/rooms/Storeroom.svg +0 -5
  297. package/assets/rooms/Summer House.svg +0 -27
  298. package/assets/rooms/Swimming Pool.svg +0 -21
  299. package/assets/rooms/Terrace.svg +0 -7
  300. package/assets/rooms/Toilet.svg +0 -10
  301. package/assets/rooms/Upstairs.svg +0 -6
  302. package/assets/rooms/Wardrobe.svg +0 -60
  303. package/assets/rooms/Washroom.svg +0 -20
  304. package/assets/rooms/Wc.svg +0 -10
  305. package/assets/rooms/Windscreen.svg +0 -60
  306. package/assets/rooms/Workshop.svg +0 -23
  307. package/assets/rooms/Workspace.svg +0 -8
@@ -87,7 +87,7 @@ class FileViewer extends react_1.Component {
87
87
  constructor(props) {
88
88
  super(props);
89
89
  this.timeout = null;
90
- this.onFileChanged = (id, fileName, size) => {
90
+ this.onFileChanged = (_id, _fileName, size) => {
91
91
  if (!this.state.changed) {
92
92
  if (this.timeout) {
93
93
  clearTimeout(this.timeout);
@@ -140,13 +140,17 @@ class FileViewer extends react_1.Component {
140
140
  parts.splice(0, 2);
141
141
  const adapter = parts[0];
142
142
  const name = parts.splice(1).join('/');
143
- this.props.socket.readFile(adapter, name)
143
+ this.props.socket
144
+ .readFile(adapter, name)
144
145
  .then((data) => {
145
146
  let fileData = '';
146
147
  if (data.file !== undefined) {
147
148
  fileData = data.file;
148
149
  }
149
- const newState = { copyPossible: this.state.copyPossible, ext: this.state.ext };
150
+ const newState = {
151
+ copyPossible: this.state.copyPossible,
152
+ ext: this.state.ext,
153
+ };
150
154
  // try to detect valid extension
151
155
  if (data.type === 'Buffer') {
152
156
  if (name.toLowerCase().endsWith('.json5')) {
@@ -190,7 +194,9 @@ class FileViewer extends react_1.Component {
190
194
  const adapter = parts[0];
191
195
  const name = parts.splice(1).join('/');
192
196
  if (this.props.supportSubscribes) {
193
- this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
197
+ this.props.socket
198
+ .subscribeFiles(adapter, name, this.onFileChanged)
199
+ .catch(e => window.alert(`Cannot subscribe on file: ${e}`));
194
200
  }
195
201
  }
196
202
  componentWillUnmount() {
@@ -203,7 +209,9 @@ class FileViewer extends react_1.Component {
203
209
  const adapter = parts[0];
204
210
  const name = parts.splice(1).join('/');
205
211
  if (this.props.supportSubscribes) {
206
- this.props.socket.subscribeFiles(adapter, name, this.onFileChanged);
212
+ this.props.socket
213
+ .subscribeFiles(adapter, name, this.onFileChanged)
214
+ .catch(e => window.alert(`Cannot subscribe on file: ${e}`));
207
215
  }
208
216
  }
209
217
  static getEditFile(ext) {
@@ -228,20 +236,20 @@ class FileViewer extends react_1.Component {
228
236
  if (this.state.imgError) {
229
237
  return react_1.default.createElement(IconNoIcon_1.default, { style: Object.assign(Object.assign({}, styles.img), this.props.getStyleBackgroundImage()) });
230
238
  }
231
- return react_1.default.createElement(Icon_1.default, { onError: e => {
239
+ return (react_1.default.createElement(Icon_1.default, { onError: e => {
232
240
  e.target.onerror = null;
233
241
  this.setState({ imgError: true });
234
- }, style: Object.assign(Object.assign({}, styles.img), this.props.getStyleBackgroundImage()), src: `${this.props.href}?ts=${this.state.forceUpdate}`, alt: this.props.href });
242
+ }, style: Object.assign(Object.assign({}, styles.img), this.props.getStyleBackgroundImage()), src: `${this.props.href}?ts=${this.state.forceUpdate}`, alt: this.props.href }));
235
243
  }
236
244
  if (this.state.ext && exports.EXTENSIONS.audio.includes(this.state.ext)) {
237
- return react_1.default.createElement("div", { style: {
245
+ return (react_1.default.createElement("div", { style: {
238
246
  width: '100%',
239
247
  height: '100%',
240
248
  display: 'flex',
241
249
  justifyContent: 'center',
242
250
  alignItems: 'center',
243
251
  } },
244
- react_1.default.createElement("audio", { style: { width: '100%' }, src: this.props.href, controls: true }));
252
+ react_1.default.createElement("audio", { style: { width: '100%' }, src: this.props.href, controls: true })));
245
253
  }
246
254
  if (this.state.ext && exports.EXTENSIONS.video.includes(this.state.ext)) {
247
255
  return (react_1.default.createElement("div", { style: {
@@ -262,33 +270,36 @@ class FileViewer extends react_1.Component {
262
270
  // value={this.state.editingValue || this.state.code || this.state.text}
263
271
  // onChange={this.state.editing ? newValue => this.setState({ editingValue: newValue, changed: true }) : undefined}
264
272
  // />;
265
- return react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.textarea, multiline: true, value: this.state.editingValue || this.state.code || this.state.text,
273
+ return (react_1.default.createElement(material_1.TextField, { variant: "standard", style: styles.textarea, multiline: true, value: this.state.editingValue || this.state.code || this.state.text,
266
274
  // onChange={newValue => this.setState({ editingValue: newValue, changed: true })}
267
- InputProps: { readOnly: !this.state.editing } });
275
+ slotProps: {
276
+ htmlInput: {
277
+ readOnly: !this.state.editing,
278
+ },
279
+ } }));
268
280
  }
269
281
  return null;
270
282
  }
271
283
  render() {
272
- return react_1.default.createElement(material_1.Dialog, { sx: {
284
+ return (react_1.default.createElement(material_1.Dialog, { sx: {
273
285
  '&.MuiDialog-scrollPaper': styles.dialog,
274
286
  '& .MuiDialog-paper': styles.paper,
275
287
  }, scroll: "paper", open: !!this.props.href, onClose: () => this.props.onClose(), fullWidth: true, maxWidth: "xl", "aria-labelledby": "ar_dialog_file_view_title" },
276
288
  react_1.default.createElement("div", { style: styles.dialogTitle },
277
289
  react_1.default.createElement(material_1.DialogTitle, { id: "ar_dialog_file_view_title" }, `${this.props.t(this.state.editing ? 'Edit' : 'View')}: ${this.props.href}`),
278
- this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext) && react_1.default.createElement("div", null,
290
+ this.state.ext && exports.EXTENSIONS.images.includes(this.state.ext) && (react_1.default.createElement("div", null,
279
291
  react_1.default.createElement(material_1.IconButton, { size: "large", color: "inherit", onClick: this.props.setStateBackgroundImage },
280
- react_1.default.createElement(icons_material_1.Brightness6, null)))),
292
+ react_1.default.createElement(icons_material_1.Brightness6, null))))),
281
293
  react_1.default.createElement(material_1.DialogContent, { style: styles.content }, this.getContent()),
282
294
  react_1.default.createElement(material_1.DialogActions, null,
283
- this.state.copyPossible ?
284
- react_1.default.createElement(material_1.Button, { color: "grey", onClick: e => {
285
- e.stopPropagation();
286
- e.preventDefault();
287
- Utils_1.default.copyToClipboard(this.state.text || this.state.code || '');
288
- }, startIcon: react_1.default.createElement(fa_1.FaCopy, null) }, this.props.t('Copy content')) : null,
289
- this.state.editing ?
290
- react_1.default.createElement(material_1.Button, { color: "grey", disabled: this.state.editingValue === this.state.code || this.state.editingValue === this.state.text, variant: "contained", onClick: this.writeFile64, startIcon: react_1.default.createElement(icons_material_1.Save, null) }, this.props.t('Save')) : null,
291
- react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.props.onClose(), color: "primary", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('Close'))));
295
+ this.state.copyPossible ? (react_1.default.createElement(material_1.Button, { color: "grey", onClick: e => {
296
+ e.stopPropagation();
297
+ e.preventDefault();
298
+ Utils_1.default.copyToClipboard(this.state.text || this.state.code || '');
299
+ }, startIcon: react_1.default.createElement(fa_1.FaCopy, null) }, this.props.t('Copy content'))) : null,
300
+ this.state.editing ? (react_1.default.createElement(material_1.Button, { color: "grey", disabled: this.state.editingValue === this.state.code ||
301
+ this.state.editingValue === this.state.text, variant: "contained", onClick: this.writeFile64, startIcon: react_1.default.createElement(icons_material_1.Save, null) }, this.props.t('Save'))) : null,
302
+ react_1.default.createElement(material_1.Button, { variant: "contained", onClick: () => this.props.onClose(), color: "primary", startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('Close')))));
292
303
  }
293
304
  }
294
305
  exports.default = (0, withWidth_1.default)()(FileViewer);
@@ -1,5 +1,16 @@
1
- import React, { ReactEventHandler } from 'react';
1
+ import React, { type ReactEventHandler } from 'react';
2
+ /**
3
+ * Get icon by object type (state, channel, device, ...).
4
+ *
5
+ * @param obj Object
6
+ */
2
7
  export declare function getSystemIcon(obj: ioBroker.Object | null): React.JSX.Element | null;
8
+ /**
9
+ * Get icon from the object.
10
+ *
11
+ * @param obj Object
12
+ * @param imagePrefix Prefix for image
13
+ */
3
14
  export declare function getSelectIdIcon(obj: ioBroker.Object | null, imagePrefix?: string): string | null;
4
15
  interface IconProps {
5
16
  /** URL, UTF-8 character, or svg code (data:image/svg...) */
@@ -8,15 +19,18 @@ interface IconProps {
8
19
  className?: string;
9
20
  /** Style for image */
10
21
  style?: React.CSSProperties;
22
+ /** Styles for mui */
11
23
  sx?: Record<string, any>;
12
24
  /** Tooltip */
13
25
  title?: string;
14
26
  /** Styles for utf-8 characters */
15
27
  styleUTF8?: React.CSSProperties;
28
+ /** On error handler */
16
29
  onError?: ReactEventHandler<HTMLImageElement>;
30
+ /** Reference to image */
17
31
  ref?: React.RefObject<HTMLImageElement>;
18
32
  /** Alternative text for image */
19
33
  alt?: string;
20
34
  }
21
- export default function Icon(props: IconProps): React.JSX.Element;
35
+ export default function Icon(props: IconProps): React.JSX.Element | null;
22
36
  export {};
@@ -12,6 +12,11 @@ const material_1 = require("@mui/material");
12
12
  const icons_material_1 = require("@mui/icons-material");
13
13
  const IconAlias_1 = __importDefault(require("../icons/IconAlias"));
14
14
  const Utils_1 = __importDefault(require("./Utils"));
15
+ /**
16
+ * Get icon by object type (state, channel, device, ...).
17
+ *
18
+ * @param obj Object
19
+ */
15
20
  function getSystemIcon(obj) {
16
21
  let icon;
17
22
  const id = obj === null || obj === void 0 ? void 0 : obj._id;
@@ -19,7 +24,7 @@ function getSystemIcon(obj) {
19
24
  return null;
20
25
  }
21
26
  // system or design has special icons
22
- if (id.startsWith('_design/') || (id === 'system')) {
27
+ if (id.startsWith('_design/') || id === 'system') {
23
28
  icon = react_1.default.createElement(icons_material_1.SettingsApplications, { className: "iconOwn" });
24
29
  }
25
30
  else if (id === '0_userdata' || id === '0_userdata.0') {
@@ -51,6 +56,12 @@ function getSystemIcon(obj) {
51
56
  }
52
57
  return icon || null;
53
58
  }
59
+ /**
60
+ * Get icon from the object.
61
+ *
62
+ * @param obj Object
63
+ * @param imagePrefix Prefix for image
64
+ */
54
65
  function getSelectIdIcon(obj, imagePrefix) {
55
66
  imagePrefix = imagePrefix || '.'; // http://localhost:8081';
56
67
  let src = '';
@@ -106,12 +117,12 @@ function Icon(props) {
106
117
  if (props.src.length < 3) {
107
118
  // utf-8 char
108
119
  if (props.sx) {
109
- return react_1.default.createElement(material_1.Box, { component: "span", sx: props.sx, title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src);
120
+ return (react_1.default.createElement(material_1.Box, { component: "span", sx: props.sx, title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src));
110
121
  }
111
- return react_1.default.createElement("span", { title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src);
122
+ return (react_1.default.createElement("span", { title: props.title || undefined, style: Object.assign({ height: 27, marginTop: -8 }, (props.styleUTF8 || props.style)), className: Utils_1.default.clsx(props.className, 'iconOwn') }, props.src));
112
123
  }
113
124
  if (props.src.startsWith('data:image/svg')) {
114
- return react_1.default.createElement(react_inlinesvg_1.default, { title: props.title || undefined, src: props.src, className: Utils_1.default.clsx(props.className, 'iconOwn'), width: ((_a = props.style) === null || _a === void 0 ? void 0 : _a.width) || 28, height: ((_b = props.style) === null || _b === void 0 ? void 0 : _b.height) || ((_c = props.style) === null || _c === void 0 ? void 0 : _c.width) || 28, style: props.style || {} });
125
+ return (react_1.default.createElement(react_inlinesvg_1.default, { title: props.title || undefined, src: props.src, className: Utils_1.default.clsx(props.className, 'iconOwn'), width: ((_a = props.style) === null || _a === void 0 ? void 0 : _a.width) || 28, height: ((_b = props.style) === null || _b === void 0 ? void 0 : _b.height) || ((_c = props.style) === null || _c === void 0 ? void 0 : _c.width) || 28, style: props.style || {} }));
115
126
  }
116
127
  if (REMOTE_SERVER && !props.src.startsWith('http://') && !props.src.startsWith('https://')) {
117
128
  let src = props.src;
@@ -122,14 +133,14 @@ function Icon(props) {
122
133
  src = REMOTE_PREFIX + src;
123
134
  }
124
135
  if (props.sx) {
125
- return react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) });
136
+ return (react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) }));
126
137
  }
127
- return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) });
138
+ return (react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: `https://remote-files.iobroker.in${src}`, alt: props.alt || undefined, ref: props.ref, onError: e => props.onError && props.onError(e) }));
128
139
  }
129
140
  if (props.sx) {
130
- return react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError });
141
+ return (react_1.default.createElement(material_1.Box, { component: "img", sx: props.sx, title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError }));
131
142
  }
132
- return react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError });
143
+ return (react_1.default.createElement("img", { title: props.title || undefined, style: props.style || {}, className: Utils_1.default.clsx(props.className, 'iconOwn'), src: props.src, alt: props.alt || undefined, ref: props.ref, onError: props.onError }));
133
144
  }
134
145
  return props.src;
135
146
  }
@@ -73,30 +73,26 @@ const styles = {
73
73
  const IconPicker = (props) => {
74
74
  var _a, _b, _c, _d;
75
75
  const IconCustom = props.icon;
76
+ const onChange = props.onChange;
76
77
  const onDrop = (0, react_1.useCallback)((acceptedFiles) => {
77
78
  const reader = new FileReader();
78
- reader.addEventListener('load', () => props.onChange(reader.result), false);
79
+ reader.addEventListener('load', () => onChange(reader.result), false);
79
80
  if (acceptedFiles[0]) {
80
81
  reader.readAsDataURL(acceptedFiles[0]);
81
82
  }
82
- }, []); // eslint-disable-line react-hooks/exhaustive-deps
83
+ }, [onChange]);
83
84
  const { getRootProps, getInputProps, isDragActive } = (0, react_dropzone_1.useDropzone)({ onDrop });
84
- return react_1.default.createElement("div", { style: styles.formContainer },
85
+ return (react_1.default.createElement("div", { style: styles.formContainer },
85
86
  IconCustom ? react_1.default.createElement(IconCustom, { style: styles.formIcon }) : null,
86
87
  react_1.default.createElement(material_1.FormControl, { variant: "standard", style: Object.assign(Object.assign({}, styles.formControl), { padding: 3 }) },
87
88
  react_1.default.createElement(material_1.InputLabel, { shrink: true, sx: ((_a = props.customStyles) === null || _a === void 0 ? void 0 : _a.label) ? { '&.MuiInputLabel-root': props.customStyles.label } : undefined, classes: { root: (_b = props.customClasses) === null || _b === void 0 ? void 0 : _b.label } }, props.label),
88
89
  react_1.default.createElement("div", { style: styles.formContainer },
89
- props.value ?
90
- react_1.default.createElement("div", { style: styles.divContainer },
91
- react_1.default.createElement(Icon_1.default, { style: Object.assign(Object.assign({}, props.previewStyle), (((_c = props.customStyles) === null || _c === void 0 ? void 0 : _c.icon) || undefined)), src: props.value, className: Utils_1.default.clsx(props.previewClassName, (_d = props.customClasses) === null || _d === void 0 ? void 0 : _d.icon) }),
92
- !props.disabled && react_1.default.createElement(material_1.IconButton, { style: { verticalAlign: 'top' }, title: i18n_1.default.t('ra_Clear icon'), size: "small", onClick: () => props.onChange('') },
93
- react_1.default.createElement(icons_material_1.Clear, null)))
94
- :
95
- (!props.disabled && react_1.default.createElement(IconSelector_1.default, { icons: props.icons, onlyRooms: props.onlyRooms, onlyDevices: props.onlyDevices, onSelect: (base64) => props.onChange(base64), t: i18n_1.default.t, lang: i18n_1.default.getLanguage() })),
96
- !props.disabled && react_1.default.createElement("div", Object.assign({}, getRootProps(), { style: Object.assign(Object.assign({}, styles.dragField), (isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' })) }),
90
+ props.value ? (react_1.default.createElement("div", { style: styles.divContainer },
91
+ react_1.default.createElement(Icon_1.default, { style: Object.assign(Object.assign({}, props.previewStyle), (((_c = props.customStyles) === null || _c === void 0 ? void 0 : _c.icon) || undefined)), src: props.value, className: Utils_1.default.clsx(props.previewClassName, (_d = props.customClasses) === null || _d === void 0 ? void 0 : _d.icon) }),
92
+ !props.disabled && (react_1.default.createElement(material_1.IconButton, { style: { verticalAlign: 'top' }, title: i18n_1.default.t('ra_Clear icon'), size: "small", onClick: () => props.onChange('') },
93
+ react_1.default.createElement(icons_material_1.Clear, null))))) : (!props.disabled && (react_1.default.createElement(IconSelector_1.default, { icons: props.icons, onlyRooms: props.onlyRooms, onlyDevices: props.onlyDevices, onSelect: (base64) => props.onChange(base64), t: i18n_1.default.t, lang: i18n_1.default.getLanguage() }))),
94
+ !props.disabled && (react_1.default.createElement("div", Object.assign({}, getRootProps(), { style: Object.assign(Object.assign({}, styles.dragField), (isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' })) }),
97
95
  react_1.default.createElement("input", Object.assign({}, getInputProps())),
98
- isDragActive ?
99
- react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t('ra_Drop the files here...')) :
100
- react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t('ra_Drag \'n\' drop some files here, or click to select files'))))));
96
+ isDragActive ? (react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t('ra_Drop the files here...'))) : (react_1.default.createElement("span", { style: styles.text }, i18n_1.default.t("ra_Drag 'n' drop some files here, or click to select files")))))))));
101
97
  };
102
98
  exports.default = IconPicker;
@@ -1,5 +1,5 @@
1
1
  import React, { Component } from 'react';
2
- import { Translate } from '../types';
2
+ import { type Translate } from '../types';
3
3
  interface IconSelectorProps {
4
4
  icons?: {
5
5
  icon?: string;
@@ -31,6 +31,8 @@ const material_1 = require("@mui/material");
31
31
  const icons_material_1 = require("@mui/icons-material");
32
32
  const Icon_1 = __importDefault(require("./Icon"));
33
33
  const Utils_1 = __importDefault(require("./Utils"));
34
+ const devices_json_1 = __importDefault(require("../assets/devices.json"));
35
+ const rooms_json_1 = __importDefault(require("../assets/rooms.json"));
34
36
  // import devices from '../assets/devices/list.json';
35
37
  const devices = [
36
38
  {
@@ -55,7 +57,7 @@ const devices = [
55
57
  en: 'Alarm System',
56
58
  ru: 'Сигнализация',
57
59
  de: 'Alarmanlage',
58
- fr: 'Systèmes D\'Alarme',
60
+ fr: "Systèmes D'Alarme",
59
61
  it: 'Sistemi Di Allarme',
60
62
  nl: 'Alarm Systems',
61
63
  pl: 'Systemy Alarmowe',
@@ -151,7 +153,7 @@ const devices = [
151
153
  en: 'Computer',
152
154
  ru: 'Компьютер',
153
155
  de: 'Rechner',
154
- fr: 'L\'Ordinateur',
156
+ fr: "L'Ordinateur",
155
157
  it: 'Computer',
156
158
  nl: 'Computer',
157
159
  pl: 'Komputer',
@@ -199,7 +201,7 @@ const devices = [
199
201
  en: 'Power Consumption',
200
202
  ru: 'Потребляемая мощность',
201
203
  de: 'Stromverbrauch',
202
- fr: 'Consommation D\'Énergie',
204
+ fr: "Consommation D'Énergie",
203
205
  it: 'Consumo Di Energia',
204
206
  nl: 'Energieverbruik',
205
207
  pl: 'Pobór Energii',
@@ -775,7 +777,7 @@ const devices = [
775
777
  en: 'Power Consumption',
776
778
  ru: 'Потребляемая мощность',
777
779
  de: 'Stromverbrauch',
778
- fr: 'Consommation D\'Énergie',
780
+ fr: "Consommation D'Énergie",
779
781
  it: 'Consumo Di Energia',
780
782
  nl: 'Energieverbruik',
781
783
  pl: 'Pobór Energii',
@@ -967,7 +969,7 @@ const devices = [
967
969
  en: 'Water',
968
970
  ru: 'Вода',
969
971
  de: 'Wasser',
970
- fr: 'L\'Eau',
972
+ fr: "L'Eau",
971
973
  it: 'Acqua',
972
974
  nl: 'Water',
973
975
  pl: 'Woda',
@@ -999,8 +1001,8 @@ const devices = [
999
1001
  en: 'Water Consumption',
1000
1002
  ru: 'Потребление воды',
1001
1003
  de: 'Wasserverbrauch',
1002
- fr: 'Consommation D\'Eau',
1003
- it: 'Consumo D\'Acqua',
1004
+ fr: "Consommation D'Eau",
1005
+ it: "Consumo D'Acqua",
1004
1006
  nl: 'Waterverbruik',
1005
1007
  pl: 'Konsumpcja Wody',
1006
1008
  pt: 'Consumo De Água',
@@ -1115,7 +1117,7 @@ const rooms = [
1115
1117
  ru: 'На Улице',
1116
1118
  de: 'Außenbereich',
1117
1119
  fr: 'En Plein Air',
1118
- it: 'All\'Aperto',
1120
+ it: "All'Aperto",
1119
1121
  nl: 'Buitenshuis',
1120
1122
  pl: 'Na Dworze',
1121
1123
  pt: 'Ao Ar Livre',
@@ -1370,7 +1372,7 @@ const rooms = [
1370
1372
  en: 'Summer House',
1371
1373
  ru: 'Дача',
1372
1374
  de: 'Gartenhaus',
1373
- fr: 'Maison D\'Été',
1375
+ fr: "Maison D'Été",
1374
1376
  it: 'Casa Estiva',
1375
1377
  nl: 'Zomerhuis',
1376
1378
  pl: 'Domek Letniskowy',
@@ -1402,7 +1404,7 @@ const rooms = [
1402
1404
  en: 'Guest Room',
1403
1405
  ru: 'Гостевая Комната',
1404
1406
  de: 'Gästezimmer',
1405
- fr: 'Chambre D\'Amis',
1407
+ fr: "Chambre D'Amis",
1406
1408
  it: 'Stanza Degli Ospiti',
1407
1409
  nl: 'Guest Room',
1408
1410
  pl: 'Pokój Gościnny',
@@ -1738,7 +1740,7 @@ const rooms = [
1738
1740
  en: 'Equipment Room',
1739
1741
  ru: 'Оборудование Номера',
1740
1742
  de: 'Technikraum',
1741
- fr: 'Salle D\'Équipement',
1743
+ fr: "Salle D'Équipement",
1742
1744
  it: 'Stanza Degli Attrezzi',
1743
1745
  nl: 'Technische Ruimte',
1744
1746
  pl: 'Wyposażenie Pokoi',
@@ -1786,7 +1788,7 @@ const rooms = [
1786
1788
  en: 'Stairwell',
1787
1789
  ru: 'Лестничная клетка',
1788
1790
  de: 'Treppenhaus',
1789
- fr: 'Cage D\'Escalier',
1791
+ fr: "Cage D'Escalier",
1790
1792
  it: 'Tromba Delle Scale',
1791
1793
  nl: 'Trappenhuis',
1792
1794
  pl: 'Klatka Schodowa',
@@ -1993,8 +1995,8 @@ class IconSelector extends react_1.Component {
1993
1995
  const icons = [];
1994
1996
  const names = [];
1995
1997
  if (!this.props.icons) {
1998
+ // load rooms
1996
1999
  let templates = this.props.onlyRooms || (!this.props.onlyRooms && !this.props.onlyDevices) ? rooms : null;
1997
- const promises = [];
1998
2000
  if (templates) {
1999
2001
  templates.forEach(item => {
2000
2002
  if (item.name && typeof item.name === 'object') {
@@ -2004,59 +2006,46 @@ class IconSelector extends react_1.Component {
2004
2006
  });
2005
2007
  templates = templates.filter((item, i) => !(templates === null || templates === void 0 ? void 0 : templates.find((_item, _i) => i !== _i && _item.icon === item.icon && _item.name === item.name)));
2006
2008
  templates.forEach((template, i) => {
2007
- let image;
2008
- try {
2009
- image = require(`../assets/rooms/${template.icon}`);
2010
- }
2011
- catch (e) {
2012
- return;
2013
- }
2014
2009
  names[i] = template.name;
2015
- promises.push(Utils_1.default.getSvg(image)
2016
- .then(icon => {
2017
- icons[i] = icon;
2018
- }));
2010
+ icons[i] =
2011
+ `data:image/svg+xml;base64,${rooms_json_1.default[template.icon.replace(/\.svg$/, '')]}`;
2019
2012
  });
2020
2013
  }
2021
- templates = this.props.onlyDevices || (!this.props.onlyRooms && !this.props.onlyDevices) ? devices : null;
2014
+ // load devices
2015
+ templates =
2016
+ this.props.onlyDevices || (!this.props.onlyRooms && !this.props.onlyDevices) ? devices : null;
2022
2017
  if (templates) {
2023
- const offset = promises.length;
2024
- templates && templates.forEach(item => {
2025
- if (item.name && typeof item.name === 'object') {
2026
- item.name = item.name[this.props.lang] || item.name.en || item._id;
2027
- }
2028
- item.name = item.name || item._id;
2029
- });
2018
+ const offset = icons.length;
2019
+ templates &&
2020
+ templates.forEach(item => {
2021
+ if (item.name && typeof item.name === 'object') {
2022
+ item.name = item.name[this.props.lang] || item.name.en || item._id;
2023
+ }
2024
+ item.name = item.name || item._id;
2025
+ });
2030
2026
  templates = templates.filter((item, i) => !(templates === null || templates === void 0 ? void 0 : templates.find((_item, _i) => i !== _i && _item.icon === item.icon && _item.name === item.name)));
2031
2027
  templates.forEach((template, i) => {
2032
- let image;
2033
- try {
2034
- image = require(`../assets/devices/${template.icon}`);
2035
- }
2036
- catch (e) {
2037
- return;
2038
- }
2039
2028
  names[i + offset] = template.name;
2040
- promises.push(Utils_1.default.getSvg(image)
2041
- .then(icon => {
2042
- icons[i + offset] = icon;
2043
- }));
2029
+ icons[i + offset] =
2030
+ `data:image/svg+xml;base64,${devices_json_1.default[template.icon.replace(/\.svg$/, '')]}`;
2044
2031
  });
2045
2032
  }
2046
- Promise.all(promises)
2047
- .then(() => this.setState({
2033
+ this.setState({
2048
2034
  icons,
2049
2035
  loading: false,
2050
2036
  names,
2051
2037
  isAnyName: !!names.find(i => i),
2052
- }));
2038
+ });
2053
2039
  }
2054
2040
  else {
2055
2041
  const promises = this.props.icons.map((item, i) => {
2056
2042
  let href;
2057
2043
  if (typeof item === 'object') {
2058
2044
  href = item.icon || item.src || item.href || '';
2059
- names[i] = typeof item.name === 'object' ? item.name[this.props.lang] || item.name.en || item._id || '' : (item.name || '');
2045
+ names[i] =
2046
+ typeof item.name === 'object'
2047
+ ? item.name[this.props.lang] || item.name.en || item._id || ''
2048
+ : item.name || '';
2060
2049
  if (!names[i]) {
2061
2050
  const parts = href.split('.');
2062
2051
  parts.pop();
@@ -2071,12 +2060,12 @@ class IconSelector extends react_1.Component {
2071
2060
  icons[i] = href;
2072
2061
  return Promise.resolve();
2073
2062
  }
2074
- return Utils_1.default.getSvg(href)
2075
- .then(icon => icons[i] = icon);
2063
+ return Utils_1.default.getSvg(href).then(icon => (icons[i] = icon));
2076
2064
  }
2077
2065
  return Promise.resolve();
2078
2066
  });
2079
- Promise.all(promises)
2067
+ void Promise.all(promises)
2068
+ .catch((e) => console.error(e))
2080
2069
  .then(() => this.setState({
2081
2070
  icons,
2082
2071
  loading: false,
@@ -2090,35 +2079,36 @@ class IconSelector extends react_1.Component {
2090
2079
  if (this.state.loading) {
2091
2080
  return react_1.default.createElement(material_1.CircularProgress, null);
2092
2081
  }
2093
- return react_1.default.createElement(react_1.default.Fragment, null,
2082
+ return (react_1.default.createElement(react_1.default.Fragment, null,
2094
2083
  react_1.default.createElement(material_1.Button, { color: "grey", variant: "outlined", title: this.props.t('ra_Select predefined icon'), onClick: () => this.setState({ opened: true }, () => this.loadAllIcons()), style: { minWidth: 40, marginRight: 8 } }, "..."),
2095
- this.state.opened ? react_1.default.createElement(material_1.Dialog, { onClose: () => this.setState({ opened: false }), open: !0 },
2084
+ this.state.opened ? (react_1.default.createElement(material_1.Dialog, { onClose: () => this.setState({ opened: false }), open: !0 },
2096
2085
  react_1.default.createElement(material_1.DialogTitle, null,
2097
2086
  this.props.t('ra_Select predefined icon'),
2098
- this.state.isAnyName ? react_1.default.createElement(material_1.TextField, { variant: "standard", margin: "dense", style: { marginLeft: 20 }, value: this.state.filter, onChange: e => this.setState({ filter: e.target.value.toLowerCase() }), placeholder: this.props.t('ra_Filter'), InputProps: {
2099
- endAdornment: this.state.filter
2100
- ?
2101
- react_1.default.createElement(material_1.IconButton, { size: "small", onClick: () => this.setState({ filter: '' }) },
2102
- react_1.default.createElement(icons_material_1.Clear, null))
2103
- :
2104
- undefined,
2105
- } }) : null),
2087
+ this.state.isAnyName ? (react_1.default.createElement(material_1.TextField, { variant: "standard", margin: "dense", style: { marginLeft: 20 }, value: this.state.filter, onChange: e => this.setState({ filter: e.target.value.toLowerCase() }), placeholder: this.props.t('ra_Filter'), slotProps: {
2088
+ input: {
2089
+ endAdornment: this.state.filter ? (react_1.default.createElement(material_1.IconButton, { size: "small", onClick: () => this.setState({ filter: '' }) },
2090
+ react_1.default.createElement(icons_material_1.Clear, null))) : undefined,
2091
+ },
2092
+ } })) : null),
2106
2093
  react_1.default.createElement(material_1.DialogContent, null,
2107
- react_1.default.createElement("div", { style: { width: '100%', textAlign: 'center' } }, this.state.icons && this.state.icons.map((icon, i) => {
2108
- if (!this.state.filter || (this.state.names[i] && this.state.names[i].toLowerCase().includes(this.state.filter))) {
2109
- return react_1.default.createElement(material_1.Tooltip, { title: this.state.names[i] || '', key: i, componentsProps: { popper: { sx: { pointerEvents: 'none' } } } },
2110
- react_1.default.createElement(material_1.IconButton, { onClick: () => this.setState({ opened: false }, () => {
2111
- const onApply = this.props.onSelect || this.props.onChange;
2112
- if (onApply) {
2113
- onApply(icon);
2114
- }
2115
- }), size: "large" },
2116
- react_1.default.createElement(Icon_1.default, { src: icon, alt: i.toString(), style: { width: 32, height: 32, borderRadius: 5 } })));
2117
- }
2118
- return null;
2119
- }))),
2094
+ react_1.default.createElement("div", { style: { width: '100%', textAlign: 'center' } }, this.state.icons &&
2095
+ this.state.icons.map((icon, i) => {
2096
+ if (!this.state.filter ||
2097
+ (this.state.names[i] &&
2098
+ this.state.names[i].toLowerCase().includes(this.state.filter))) {
2099
+ return (react_1.default.createElement(material_1.Tooltip, { title: this.state.names[i] || '', key: i, slotProps: { popper: { sx: { pointerEvents: 'none' } } } },
2100
+ react_1.default.createElement(material_1.IconButton, { onClick: () => this.setState({ opened: false }, () => {
2101
+ const onApply = this.props.onSelect || this.props.onChange;
2102
+ if (onApply) {
2103
+ onApply(icon);
2104
+ }
2105
+ }), size: "large" },
2106
+ react_1.default.createElement(Icon_1.default, { src: icon, alt: i.toString(), style: { width: 32, height: 32, borderRadius: 5 } }))));
2107
+ }
2108
+ return null;
2109
+ }))),
2120
2110
  react_1.default.createElement(material_1.DialogActions, null,
2121
- react_1.default.createElement(material_1.Button, { color: "grey", variant: "contained", onClick: () => this.setState({ opened: false }), startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('ra_Close')))) : null);
2111
+ react_1.default.createElement(material_1.Button, { color: "grey", variant: "contained", onClick: () => this.setState({ opened: false }), startIcon: react_1.default.createElement(icons_material_1.Close, null) }, this.props.t('ra_Close'))))) : null));
2122
2112
  }
2123
2113
  }
2124
2114
  exports.default = IconSelector;
@@ -1,4 +1,5 @@
1
- import React, { Component } from 'react';
1
+ import { type JSX } from 'react';
2
+ import { Component } from 'react';
2
3
  interface ImageProps {
3
4
  color?: string;
4
5
  src?: string;
@@ -14,13 +15,16 @@ interface ImageState {
14
15
  imgError?: boolean;
15
16
  showError?: boolean;
16
17
  }
18
+ /**
19
+ * A component for displaying an image.
20
+ */
17
21
  declare class Image extends Component<ImageProps, ImageState> {
18
22
  private svg;
19
23
  static REMOTE_SERVER: boolean;
20
24
  static REMOTE_PREFIX: string;
21
25
  constructor(props: ImageProps);
22
- static getDerivedStateFromProps(props: ImageProps, state: ImageState): ImageState;
23
- getSvgFromData(src: string): React.JSX.Element | null;
24
- render(): React.JSX.Element;
26
+ static getDerivedStateFromProps(props: ImageProps, state: ImageState): Partial<ImageState> | null;
27
+ getSvgFromData(src: string): JSX.Element | null;
28
+ render(): JSX.Element | null;
25
29
  }
26
30
  export default Image;