@iobroker/adapter-react-v5 7.2.4 → 7.2.6

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 (375) hide show
  1. package/README.md +6 -6
  2. package/build/AdminConnection.d.ts +1 -0
  3. package/build/AdminConnection.js +2 -0
  4. package/build/AdminConnection.js.map +1 -0
  5. package/{src/Components/404.tsx → build/Components/404.js} +14 -39
  6. package/build/Components/404.js.map +1 -0
  7. package/{Components → build/Components}/ColorPicker.d.ts +2 -2
  8. package/{Components → build/Components}/ColorPicker.js +50 -65
  9. package/build/Components/ColorPicker.js.map +1 -0
  10. package/{Components → build/Components}/ComplexCron.d.ts +2 -2
  11. package/{Components → build/Components}/ComplexCron.js +43 -71
  12. package/build/Components/ComplexCron.js.map +1 -0
  13. package/{Components → build/Components}/CopyToClipboard.d.ts +1 -2
  14. package/{src/Components/CopyToClipboard.tsx → build/Components/CopyToClipboard.js} +20 -38
  15. package/build/Components/CopyToClipboard.js.map +1 -0
  16. package/{Components → build/Components}/CustomModal.d.ts +3 -3
  17. package/build/Components/CustomModal.js +60 -0
  18. package/build/Components/CustomModal.js.map +1 -0
  19. package/{Components → build/Components}/FileBrowser.d.ts +2 -2
  20. package/{Components → build/Components}/FileBrowser.js +229 -236
  21. package/build/Components/FileBrowser.js.map +1 -0
  22. package/build/Components/FileViewer.d.ts +48 -0
  23. package/build/Components/FileViewer.js +277 -0
  24. package/build/Components/FileViewer.js.map +1 -0
  25. package/{Components → build/Components}/Icon.d.ts +1 -1
  26. package/build/Components/Icon.js +140 -0
  27. package/build/Components/Icon.js.map +1 -0
  28. package/{Components → build/Components}/IconPicker.d.ts +2 -2
  29. package/build/Components/IconPicker.js +73 -0
  30. package/build/Components/IconPicker.js.map +1 -0
  31. package/{Components → build/Components}/IconSelector.d.ts +3 -3
  32. package/{Components → build/Components}/IconSelector.js +29 -57
  33. package/build/Components/IconSelector.js.map +1 -0
  34. package/{Components → build/Components}/Image.d.ts +2 -2
  35. package/{Components → build/Components}/Image.js +16 -22
  36. package/build/Components/Image.js.map +1 -0
  37. package/{Components → build/Components}/Loader.d.ts +2 -2
  38. package/{Components → build/Components}/Loader.js +15 -40
  39. package/build/Components/Loader.js.map +1 -0
  40. package/{Components → build/Components}/Loaders/MV.d.ts +2 -2
  41. package/build/Components/Loaders/MV.js +61 -0
  42. package/build/Components/Loaders/MV.js.map +1 -0
  43. package/{Components → build/Components}/Loaders/PT.d.ts +2 -2
  44. package/{Components → build/Components}/Loaders/PT.js +10 -35
  45. package/build/Components/Loaders/PT.js.map +1 -0
  46. package/{Components → build/Components}/Loaders/Vendor.d.ts +2 -2
  47. package/build/Components/Loaders/Vendor.js +52 -0
  48. package/build/Components/Loaders/Vendor.js.map +1 -0
  49. package/{Components → build/Components}/Logo.d.ts +2 -2
  50. package/build/Components/Logo.js +108 -0
  51. package/build/Components/Logo.js.map +1 -0
  52. package/{Components → build/Components}/MDUtils.d.ts +1 -2
  53. package/{Components → build/Components}/MDUtils.js +4 -9
  54. package/build/Components/MDUtils.js.map +1 -0
  55. package/{Components → build/Components}/ObjectBrowser.d.ts +4 -4
  56. package/{Components → build/Components}/ObjectBrowser.js +1152 -1116
  57. package/build/Components/ObjectBrowser.js.map +1 -0
  58. package/{Components → build/Components}/Router.d.ts +1 -2
  59. package/{Components → build/Components}/Router.js +6 -7
  60. package/build/Components/Router.js.map +1 -0
  61. package/{Components → build/Components}/SaveCloseButtons.d.ts +2 -2
  62. package/build/Components/SaveCloseButtons.js +65 -0
  63. package/build/Components/SaveCloseButtons.js.map +1 -0
  64. package/{Components → build/Components}/Schedule.d.ts +2 -2
  65. package/{Components → build/Components}/Schedule.js +242 -257
  66. package/build/Components/Schedule.js.map +1 -0
  67. package/{Components → build/Components}/SelectWithIcon.d.ts +2 -2
  68. package/build/Components/SelectWithIcon.js +135 -0
  69. package/build/Components/SelectWithIcon.js.map +1 -0
  70. package/build/Components/SimpleCron/cronText.js +15 -0
  71. package/build/Components/SimpleCron/cronText.js.map +1 -0
  72. package/{Components → build/Components}/SimpleCron/index.d.ts +2 -2
  73. package/{Components → build/Components}/SimpleCron/index.js +55 -58
  74. package/build/Components/SimpleCron/index.js.map +1 -0
  75. package/{Components → build/Components}/TabContainer.d.ts +2 -2
  76. package/build/Components/TabContainer.js +23 -0
  77. package/build/Components/TabContainer.js.map +1 -0
  78. package/{Components → build/Components}/TabContent.d.ts +3 -2
  79. package/build/Components/TabContent.js +20 -0
  80. package/build/Components/TabContent.js.map +1 -0
  81. package/build/Components/TabHeader.d.ts +6 -0
  82. package/build/Components/TabHeader.js +6 -0
  83. package/build/Components/TabHeader.js.map +1 -0
  84. package/{Components → build/Components}/TableResize.d.ts +2 -2
  85. package/{src/Components/TableResize.tsx → build/Components/TableResize.js} +64 -134
  86. package/build/Components/TableResize.js.map +1 -0
  87. package/{Components → build/Components}/TextWithIcon.d.ts +2 -2
  88. package/{src/Components/TextWithIcon.tsx → build/Components/TextWithIcon.js} +30 -75
  89. package/build/Components/TextWithIcon.js.map +1 -0
  90. package/{Components → build/Components}/ToggleThemeMenu.d.ts +1 -1
  91. package/build/Components/ToggleThemeMenu.js +13 -0
  92. package/build/Components/ToggleThemeMenu.js.map +1 -0
  93. package/{Components → build/Components}/TreeTable.d.ts +3 -3
  94. package/{Components → build/Components}/TreeTable.js +87 -99
  95. package/build/Components/TreeTable.js.map +1 -0
  96. package/{Components → build/Components}/UploadImage.d.ts +2 -2
  97. package/{Components → build/Components}/UploadImage.js +46 -69
  98. package/build/Components/UploadImage.js.map +1 -0
  99. package/{Components → build/Components}/Utils.d.ts +2 -2
  100. package/{Components → build/Components}/Utils.js +47 -60
  101. package/build/Components/Utils.js.map +1 -0
  102. package/build/Components/withWidth.d.ts +2 -0
  103. package/build/Components/withWidth.js +22 -0
  104. package/build/Components/withWidth.js.map +1 -0
  105. package/build/Connection.d.ts +1 -0
  106. package/build/Connection.js +2 -0
  107. package/build/Connection.js.map +1 -0
  108. package/{Dialogs → build/Dialogs}/ComplexCron.d.ts +2 -2
  109. package/build/Dialogs/ComplexCron.js +85 -0
  110. package/build/Dialogs/ComplexCron.js.map +1 -0
  111. package/{Dialogs → build/Dialogs}/Confirm.d.ts +2 -2
  112. package/build/Dialogs/Confirm.js +83 -0
  113. package/build/Dialogs/Confirm.js.map +1 -0
  114. package/{Dialogs → build/Dialogs}/Cron.d.ts +2 -2
  115. package/build/Dialogs/Cron.js +72 -0
  116. package/build/Dialogs/Cron.js.map +1 -0
  117. package/{Dialogs → build/Dialogs}/Error.d.ts +2 -2
  118. package/build/Dialogs/Error.js +27 -0
  119. package/build/Dialogs/Error.js.map +1 -0
  120. package/{Dialogs → build/Dialogs}/Message.d.ts +2 -2
  121. package/build/Dialogs/Message.js +29 -0
  122. package/build/Dialogs/Message.js.map +1 -0
  123. package/{Dialogs → build/Dialogs}/SelectFile.d.ts +2 -2
  124. package/build/Dialogs/SelectFile.js +116 -0
  125. package/build/Dialogs/SelectFile.js.map +1 -0
  126. package/{Dialogs → build/Dialogs}/SelectID.d.ts +3 -3
  127. package/{Dialogs → build/Dialogs}/SelectID.js +28 -53
  128. package/build/Dialogs/SelectID.js.map +1 -0
  129. package/{Dialogs → build/Dialogs}/SimpleCron.d.ts +2 -2
  130. package/build/Dialogs/SimpleCron.js +46 -0
  131. package/build/Dialogs/SimpleCron.js.map +1 -0
  132. package/build/Dialogs/TextInput.d.ts +2 -0
  133. package/build/Dialogs/TextInput.js +31 -0
  134. package/build/Dialogs/TextInput.js.map +1 -0
  135. package/{GenericApp.d.ts → build/GenericApp.d.ts} +2 -3
  136. package/{GenericApp.js → build/GenericApp.js} +162 -176
  137. package/build/GenericApp.js.map +1 -0
  138. package/{LegacyConnection.d.ts → build/LegacyConnection.d.ts} +69 -4
  139. package/{LegacyConnection.js → build/LegacyConnection.js} +106 -99
  140. package/build/LegacyConnection.js.map +1 -0
  141. package/{Prompt.d.ts → build/Prompt.d.ts} +1 -1
  142. package/{Prompt.js → build/Prompt.js} +3 -4
  143. package/build/Prompt.js.map +1 -0
  144. package/build/Theme.d.ts +5 -0
  145. package/{Theme.js → build/Theme.js} +37 -32
  146. package/build/Theme.js.map +1 -0
  147. package/build/assets/devices/parseNames.d.ts +0 -0
  148. package/build/assets/devices/parseNames.js +35 -0
  149. package/build/assets/devices/parseNames.js.map +1 -0
  150. package/build/assets/rooms/parseNames.d.ts +0 -0
  151. package/build/assets/rooms/parseNames.js +35 -0
  152. package/build/assets/rooms/parseNames.js.map +1 -0
  153. package/build/dictionary.d.ts +1 -0
  154. package/build/dictionary.js +25 -0
  155. package/build/dictionary.js.map +1 -0
  156. package/build/i18n/de.json +449 -0
  157. package/build/i18n/en.json +449 -0
  158. package/build/i18n/es.json +449 -0
  159. package/build/i18n/fr.json +449 -0
  160. package/build/i18n/it.json +449 -0
  161. package/build/i18n/nl.json +449 -0
  162. package/build/i18n/pl.json +449 -0
  163. package/build/i18n/pt.json +449 -0
  164. package/build/i18n/ru.json +449 -0
  165. package/build/i18n/uk.json +449 -0
  166. package/build/i18n/zh-cn.json +449 -0
  167. package/{i18n.d.ts → build/i18n.d.ts} +2 -2
  168. package/{i18n.js → build/i18n.js} +9 -11
  169. package/build/i18n.js.map +1 -0
  170. package/build/icons/IconAdapter.d.ts +3 -0
  171. package/build/icons/IconAdapter.js +6 -0
  172. package/build/icons/IconAdapter.js.map +1 -0
  173. package/build/icons/IconAlias.d.ts +3 -0
  174. package/build/icons/IconAlias.js +6 -0
  175. package/build/icons/IconAlias.js.map +1 -0
  176. package/build/icons/IconChannel.d.ts +3 -0
  177. package/build/icons/IconChannel.js +9 -0
  178. package/build/icons/IconChannel.js.map +1 -0
  179. package/build/icons/IconClearFilter.d.ts +3 -0
  180. package/build/icons/IconClearFilter.js +7 -0
  181. package/build/icons/IconClearFilter.js.map +1 -0
  182. package/build/icons/IconClosed.d.ts +3 -0
  183. package/build/icons/IconClosed.js +6 -0
  184. package/build/icons/IconClosed.js.map +1 -0
  185. package/build/icons/IconCopy.d.ts +3 -0
  186. package/build/icons/IconCopy.js +5 -0
  187. package/build/icons/IconCopy.js.map +1 -0
  188. package/build/icons/IconDevice.d.ts +3 -0
  189. package/build/icons/IconDevice.js +15 -0
  190. package/build/icons/IconDevice.js.map +1 -0
  191. package/build/icons/IconDocument.d.ts +3 -0
  192. package/build/icons/IconDocument.js +6 -0
  193. package/build/icons/IconDocument.js.map +1 -0
  194. package/build/icons/IconDocumentReadOnly.d.ts +3 -0
  195. package/build/icons/IconDocumentReadOnly.js +7 -0
  196. package/build/icons/IconDocumentReadOnly.js.map +1 -0
  197. package/build/icons/IconExpert.d.ts +3 -0
  198. package/build/icons/IconExpert.js +6 -0
  199. package/build/icons/IconExpert.js.map +1 -0
  200. package/build/icons/IconFx.d.ts +3 -0
  201. package/build/icons/IconFx.js +5 -0
  202. package/build/icons/IconFx.js.map +1 -0
  203. package/build/icons/IconInstance.d.ts +3 -0
  204. package/build/icons/IconInstance.js +6 -0
  205. package/build/icons/IconInstance.js.map +1 -0
  206. package/build/icons/IconLogout.d.ts +3 -0
  207. package/build/icons/IconLogout.js +6 -0
  208. package/build/icons/IconLogout.js.map +1 -0
  209. package/build/icons/IconNoIcon.d.ts +3 -0
  210. package/build/icons/IconNoIcon.js +5 -0
  211. package/build/icons/IconNoIcon.js.map +1 -0
  212. package/build/icons/IconOpen.d.ts +3 -0
  213. package/build/icons/IconOpen.js +6 -0
  214. package/build/icons/IconOpen.js.map +1 -0
  215. package/{icons → build/icons}/IconProps.d.ts +1 -1
  216. package/build/icons/IconProps.js +2 -0
  217. package/build/icons/IconProps.js.map +1 -0
  218. package/build/icons/IconState.d.ts +3 -0
  219. package/build/icons/IconState.js +6 -0
  220. package/build/icons/IconState.js.map +1 -0
  221. package/build/index.d.ts +67 -0
  222. package/build/index.js +67 -0
  223. package/build/index.js.map +1 -0
  224. package/{types.d.ts → build/types.d.ts} +1 -1
  225. package/package.json +84 -48
  226. package/AdminConnection.d.ts +0 -2
  227. package/AdminConnection.js +0 -4
  228. package/Components/404.js +0 -101
  229. package/Components/CopyToClipboard.js +0 -163
  230. package/Components/CustomModal.js +0 -88
  231. package/Components/FileViewer.d.ts +0 -10
  232. package/Components/FileViewer.js +0 -305
  233. package/Components/Icon.js +0 -148
  234. package/Components/IconPicker.js +0 -98
  235. package/Components/Loaders/MV.js +0 -66
  236. package/Components/Loaders/Vendor.js +0 -77
  237. package/Components/Logo.js +0 -117
  238. package/Components/SaveCloseButtons.js +0 -69
  239. package/Components/SelectWithIcon.js +0 -168
  240. package/Components/SimpleCron/cronText.js +0 -19
  241. package/Components/TabContainer.js +0 -25
  242. package/Components/TabContent.js +0 -21
  243. package/Components/TabHeader.d.ts +0 -6
  244. package/Components/TabHeader.js +0 -11
  245. package/Components/TableResize.js +0 -226
  246. package/Components/TextWithIcon.js +0 -119
  247. package/Components/ToggleThemeMenu.js +0 -18
  248. package/Components/withWidth.d.ts +0 -3
  249. package/Components/withWidth.js +0 -27
  250. package/Connection.d.ts +0 -3
  251. package/Connection.js +0 -8
  252. package/Dialogs/ComplexCron.js +0 -90
  253. package/Dialogs/Confirm.js +0 -111
  254. package/Dialogs/Cron.js +0 -100
  255. package/Dialogs/Error.js +0 -55
  256. package/Dialogs/Message.js +0 -57
  257. package/Dialogs/SelectFile.js +0 -119
  258. package/Dialogs/SimpleCron.js +0 -51
  259. package/Dialogs/TextInput.d.ts +0 -3
  260. package/Dialogs/TextInput.js +0 -35
  261. package/Theme.d.ts +0 -6
  262. package/i18n/de.json +0 -449
  263. package/i18n/en.json +0 -449
  264. package/i18n/es.json +0 -449
  265. package/i18n/fr.json +0 -449
  266. package/i18n/it.json +0 -449
  267. package/i18n/nl.json +0 -449
  268. package/i18n/pl.json +0 -449
  269. package/i18n/pt.json +0 -449
  270. package/i18n/ru.json +0 -449
  271. package/i18n/uk.json +0 -449
  272. package/i18n/zh-cn.json +0 -449
  273. package/icons/IconAdapter.d.ts +0 -4
  274. package/icons/IconAdapter.js +0 -10
  275. package/icons/IconAlias.d.ts +0 -4
  276. package/icons/IconAlias.js +0 -10
  277. package/icons/IconChannel.d.ts +0 -4
  278. package/icons/IconChannel.js +0 -13
  279. package/icons/IconClearFilter.d.ts +0 -4
  280. package/icons/IconClearFilter.js +0 -11
  281. package/icons/IconClosed.d.ts +0 -4
  282. package/icons/IconClosed.js +0 -10
  283. package/icons/IconCopy.d.ts +0 -4
  284. package/icons/IconCopy.js +0 -9
  285. package/icons/IconDevice.d.ts +0 -4
  286. package/icons/IconDevice.js +0 -19
  287. package/icons/IconDocument.d.ts +0 -4
  288. package/icons/IconDocument.js +0 -10
  289. package/icons/IconDocumentReadOnly.d.ts +0 -4
  290. package/icons/IconDocumentReadOnly.js +0 -11
  291. package/icons/IconExpert.d.ts +0 -4
  292. package/icons/IconExpert.js +0 -10
  293. package/icons/IconFx.d.ts +0 -4
  294. package/icons/IconFx.js +0 -9
  295. package/icons/IconInstance.d.ts +0 -4
  296. package/icons/IconInstance.js +0 -10
  297. package/icons/IconLogout.d.ts +0 -4
  298. package/icons/IconLogout.js +0 -10
  299. package/icons/IconNoIcon.d.ts +0 -4
  300. package/icons/IconNoIcon.js +0 -9
  301. package/icons/IconOpen.d.ts +0 -4
  302. package/icons/IconOpen.js +0 -10
  303. package/icons/IconProps.js +0 -2
  304. package/icons/IconState.d.ts +0 -4
  305. package/icons/IconState.js +0 -10
  306. package/index.d.ts +0 -128
  307. package/index.js +0 -215
  308. package/src/AdminConnection.tsx +0 -3
  309. package/src/Components/ColorPicker.tsx +0 -343
  310. package/src/Components/ComplexCron.tsx +0 -561
  311. package/src/Components/CustomModal.tsx +0 -170
  312. package/src/Components/FileBrowser.tsx +0 -2560
  313. package/src/Components/FileViewer.tsx +0 -412
  314. package/src/Components/Icon.tsx +0 -238
  315. package/src/Components/IconPicker.tsx +0 -165
  316. package/src/Components/IconSelector.tsx +0 -2220
  317. package/src/Components/Image.tsx +0 -193
  318. package/src/Components/Loader.tsx +0 -328
  319. package/src/Components/Logo.tsx +0 -176
  320. package/src/Components/MDUtils.tsx +0 -104
  321. package/src/Components/ObjectBrowser.tsx +0 -8947
  322. package/src/Components/Router.tsx +0 -90
  323. package/src/Components/SaveCloseButtons.tsx +0 -117
  324. package/src/Components/Schedule.tsx +0 -1998
  325. package/src/Components/SelectWithIcon.tsx +0 -239
  326. package/src/Components/TabContainer.tsx +0 -57
  327. package/src/Components/TabContent.tsx +0 -38
  328. package/src/Components/TabHeader.tsx +0 -20
  329. package/src/Components/ToggleThemeMenu.tsx +0 -52
  330. package/src/Components/TreeTable.tsx +0 -1002
  331. package/src/Components/UploadImage.tsx +0 -643
  332. package/src/Components/Utils.tsx +0 -1802
  333. package/src/Components/loader.css +0 -231
  334. package/src/Components/withWidth.tsx +0 -32
  335. package/src/Connection.tsx +0 -5
  336. package/src/Dialogs/ComplexCron.tsx +0 -163
  337. package/src/Dialogs/Confirm.tsx +0 -185
  338. package/src/Dialogs/Cron.tsx +0 -192
  339. package/src/Dialogs/Error.tsx +0 -67
  340. package/src/Dialogs/Message.tsx +0 -73
  341. package/src/Dialogs/SelectFile.tsx +0 -280
  342. package/src/Dialogs/SelectID.tsx +0 -310
  343. package/src/Dialogs/SimpleCron.tsx +0 -101
  344. package/src/Dialogs/TextInput.tsx +0 -99
  345. package/src/GenericApp.tsx +0 -1076
  346. package/src/LegacyConnection.tsx +0 -3720
  347. package/src/Prompt.tsx +0 -22
  348. package/src/Theme.tsx +0 -472
  349. package/src/icons/IconAdapter.tsx +0 -22
  350. package/src/icons/IconAlias.tsx +0 -22
  351. package/src/icons/IconChannel.tsx +0 -60
  352. package/src/icons/IconClearFilter.tsx +0 -24
  353. package/src/icons/IconClosed.tsx +0 -22
  354. package/src/icons/IconCopy.tsx +0 -21
  355. package/src/icons/IconDevice.tsx +0 -126
  356. package/src/icons/IconDocument.tsx +0 -22
  357. package/src/icons/IconDocumentReadOnly.tsx +0 -27
  358. package/src/icons/IconExpert.tsx +0 -26
  359. package/src/icons/IconFx.tsx +0 -38
  360. package/src/icons/IconInstance.tsx +0 -22
  361. package/src/icons/IconLogout.tsx +0 -32
  362. package/src/icons/IconNoIcon.tsx +0 -21
  363. package/src/icons/IconOpen.tsx +0 -22
  364. package/src/icons/IconProps.tsx +0 -16
  365. package/src/icons/IconState.tsx +0 -38
  366. package/src/index.css +0 -56
  367. /package/{Components → build/Components}/404.d.ts +0 -0
  368. /package/{Components → build/Components}/SimpleCron/cronText.d.ts +0 -0
  369. /package/{assets → build/assets}/devices.json +0 -0
  370. /package/{assets → build/assets}/lamp_ceiling.svg +0 -0
  371. /package/{assets → build/assets}/lamp_table.svg +0 -0
  372. /package/{assets → build/assets}/no_icon.svg +0 -0
  373. /package/{assets → build/assets}/rooms.json +0 -0
  374. /package/{index.css → build/index.css} +0 -0
  375. /package/{tasks.js → tasksExample.js} +0 -0
@@ -1,643 +0,0 @@
1
- import React, { Component, createRef, type JSX } from 'react';
2
- import Dropzone from 'react-dropzone';
3
- import { Cropper, type ReactCropperElement } from 'react-cropper';
4
-
5
- import { Menu, MenuItem, Tooltip, IconButton } from '@mui/material';
6
-
7
- import { Close as IconClose, Crop as CropIcon } from '@mui/icons-material';
8
- import { FaFileUpload as UploadIcon } from 'react-icons/fa';
9
-
10
- import I18n from '../i18n';
11
- import Icon from './Icon';
12
-
13
- // import 'cropperjs/dist/cropper.css';
14
- const cropperStyles = `
15
- /*!
16
- * Cropper.js v1.5.12
17
- * https://fengyuanchen.github.io/cropperjs
18
- *
19
- * Copyright 2015-present Chen Fengyuan
20
- * Released under the MIT license
21
- *
22
- * Date: 2021-06-12T08:00:11.623Z
23
- */
24
-
25
- .cropper-container {
26
- direction: ltr;
27
- font-size: 0;
28
- line-height: 0;
29
- position: relative;
30
- -ms-touch-action: none;
31
- touch-action: none;
32
- -webkit-user-select: none;
33
- -moz-user-select: none;
34
- -ms-user-select: none;
35
- user-select: none;
36
- }
37
-
38
- .cropper-container img {
39
- display: block;
40
- height: 100%;
41
- image-orientation: 0deg;
42
- max-height: none !important;
43
- max-width: none !important;
44
- min-height: 0 !important;
45
- min-width: 0 !important;
46
- width: 100%;
47
- }
48
-
49
- .cropper-wrap-box,
50
- .cropper-canvas,
51
- .cropper-drag-box,
52
- .cropper-crop-box,
53
- .cropper-modal {
54
- bottom: 0;
55
- left: 0;
56
- position: absolute;
57
- right: 0;
58
- top: 0;
59
- }
60
-
61
- .cropper-wrap-box,
62
- .cropper-canvas {
63
- overflow: hidden;
64
- }
65
-
66
- .cropper-drag-box {
67
- background-color: #fff;
68
- opacity: 0;
69
- }
70
-
71
- .cropper-modal {
72
- background-color: #000;
73
- opacity: 0.5;
74
- }
75
-
76
- .cropper-view-box {
77
- display: block;
78
- height: 100%;
79
- outline: 1px solid #39f;
80
- outline-color: rgba(51, 153, 255, 0.75);
81
- overflow: hidden;
82
- width: 100%;
83
- }
84
-
85
- .cropper-dashed {
86
- border: 0 dashed #eee;
87
- display: block;
88
- opacity: 0.5;
89
- position: absolute;
90
- }
91
-
92
- .cropper-dashed.dashed-h {
93
- border-bottom-width: 1px;
94
- border-top-width: 1px;
95
- height: calc(100% / 3);
96
- left: 0;
97
- top: calc(100% / 3);
98
- width: 100%;
99
- }
100
-
101
- .cropper-dashed.dashed-v {
102
- border-left-width: 1px;
103
- border-right-width: 1px;
104
- height: 100%;
105
- left: calc(100% / 3);
106
- top: 0;
107
- width: calc(100% / 3);
108
- }
109
-
110
- .cropper-center {
111
- display: block;
112
- height: 0;
113
- left: 50%;
114
- opacity: 0.75;
115
- position: absolute;
116
- top: 50%;
117
- width: 0;
118
- }
119
-
120
- .cropper-center::before,
121
- .cropper-center::after {
122
- background-color: #eee;
123
- content: ' ';
124
- display: block;
125
- position: absolute;
126
- }
127
-
128
- .cropper-center::before {
129
- height: 1px;
130
- left: -3px;
131
- top: 0;
132
- width: 7px;
133
- }
134
-
135
- .cropper-center::after {
136
- height: 7px;
137
- left: 0;
138
- top: -3px;
139
- width: 1px;
140
- }
141
-
142
- .cropper-face,
143
- .cropper-line,
144
- .cropper-point {
145
- display: block;
146
- height: 100%;
147
- opacity: 0.1;
148
- position: absolute;
149
- width: 100%;
150
- }
151
-
152
- .cropper-face {
153
- background-color: #fff;
154
- left: 0;
155
- top: 0;
156
- }
157
-
158
- .cropper-line {
159
- background-color: #39f;
160
- }
161
-
162
- .cropper-line.line-e {
163
- cursor: ew-resize;
164
- right: -3px;
165
- top: 0;
166
- width: 5px;
167
- }
168
-
169
- .cropper-line.line-n {
170
- cursor: ns-resize;
171
- height: 5px;
172
- left: 0;
173
- top: -3px;
174
- }
175
-
176
- .cropper-line.line-w {
177
- cursor: ew-resize;
178
- left: -3px;
179
- top: 0;
180
- width: 5px;
181
- }
182
-
183
- .cropper-line.line-s {
184
- bottom: -3px;
185
- cursor: ns-resize;
186
- height: 5px;
187
- left: 0;
188
- }
189
-
190
- .cropper-point {
191
- background-color: #39f;
192
- height: 5px;
193
- opacity: 0.75;
194
- width: 5px;
195
- }
196
-
197
- .cropper-point.point-e {
198
- cursor: ew-resize;
199
- margin-top: -3px;
200
- right: -3px;
201
- top: 50%;
202
- }
203
-
204
- .cropper-point.point-n {
205
- cursor: ns-resize;
206
- left: 50%;
207
- margin-left: -3px;
208
- top: -3px;
209
- }
210
-
211
- .cropper-point.point-w {
212
- cursor: ew-resize;
213
- left: -3px;
214
- margin-top: -3px;
215
- top: 50%;
216
- }
217
-
218
- .cropper-point.point-s {
219
- bottom: -3px;
220
- cursor: s-resize;
221
- left: 50%;
222
- margin-left: -3px;
223
- }
224
-
225
- .cropper-point.point-ne {
226
- cursor: nesw-resize;
227
- right: -3px;
228
- top: -3px;
229
- }
230
-
231
- .cropper-point.point-nw {
232
- cursor: nwse-resize;
233
- left: -3px;
234
- top: -3px;
235
- }
236
-
237
- .cropper-point.point-sw {
238
- bottom: -3px;
239
- cursor: nesw-resize;
240
- left: -3px;
241
- }
242
-
243
- .cropper-point.point-se {
244
- bottom: -3px;
245
- cursor: nwse-resize;
246
- height: 20px;
247
- opacity: 1;
248
- right: -3px;
249
- width: 20px;
250
- }
251
-
252
- @media (min-width: 768px) {
253
- .cropper-point.point-se {
254
- height: 15px;
255
- width: 15px;
256
- }
257
- }
258
-
259
- @media (min-width: 992px) {
260
- .cropper-point.point-se {
261
- height: 10px;
262
- width: 10px;
263
- }
264
- }
265
-
266
- @media (min-width: 1200px) {
267
- .cropper-point.point-se {
268
- height: 5px;
269
- opacity: 0.75;
270
- width: 5px;
271
- }
272
- }
273
-
274
- .cropper-point.point-se::before {
275
- background-color: #39f;
276
- bottom: -50%;
277
- content: ' ';
278
- display: block;
279
- height: 200%;
280
- opacity: 0;
281
- position: absolute;
282
- right: -50%;
283
- width: 200%;
284
- }
285
-
286
- .cropper-invisible {
287
- opacity: 0;
288
- }
289
-
290
- .cropper-bg {
291
- background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
292
- }
293
-
294
- .cropper-hide {
295
- display: block;
296
- height: 0;
297
- position: absolute;
298
- width: 0;
299
- }
300
-
301
- .cropper-hidden {
302
- display: none !important;
303
- }
304
-
305
- .cropper-move {
306
- cursor: move;
307
- }
308
-
309
- .cropper-crop {
310
- cursor: crosshair;
311
- }
312
-
313
- .cropper-disabled .cropper-drag-box,
314
- .cropper-disabled .cropper-face,
315
- .cropper-disabled .cropper-line,
316
- .cropper-disabled .cropper-point {
317
- cursor: not-allowed;
318
- }
319
- `;
320
-
321
- const styles: Record<string, React.CSSProperties> = {
322
- dropZone: {
323
- width: '100%',
324
- height: 100,
325
- position: 'relative',
326
- },
327
- dropZoneEmpty: {},
328
- image: {
329
- objectFit: 'contain',
330
- margin: 'auto',
331
- display: 'flex',
332
- width: '100%',
333
- height: '100%',
334
- },
335
-
336
- uploadDiv: {
337
- position: 'relative',
338
- width: '100%',
339
- height: 300,
340
- opacity: 0.9,
341
- marginTop: 30,
342
- cursor: 'pointer',
343
- outline: 'none',
344
- },
345
- uploadDivDragging: {
346
- opacity: 1,
347
- background: 'rgba(128,255,128,0.1)',
348
- },
349
-
350
- uploadCenterDiv: {
351
- margin: 5,
352
- border: '3px dashed grey',
353
- borderRadius: 5,
354
- width: 'calc(100% - 10px)',
355
- height: 'calc(100% - 10px)',
356
- position: 'relative',
357
- display: 'flex',
358
- },
359
- uploadCenterIcon: {
360
- paddingTop: 10,
361
- width: 48,
362
- height: 48,
363
- },
364
- uploadCenterText: {
365
- fontSize: 16,
366
- },
367
- uploadCenterTextAndIcon: {
368
- textAlign: 'center',
369
- position: 'absolute',
370
- top: 0,
371
- bottom: 0,
372
- left: 0,
373
- right: 0,
374
- display: 'flex',
375
- flexDirection: 'column',
376
- alignItems: 'center',
377
- justifyContent: 'center',
378
- },
379
- disabledOpacity: {
380
- opacity: 0.3,
381
- cursor: 'default',
382
- },
383
- buttonRemoveWrapper: {
384
- position: 'absolute',
385
- zIndex: 222,
386
- right: 0,
387
- },
388
- buttonCropWrapper: {
389
- position: 'absolute',
390
- zIndex: 222,
391
- right: 0,
392
- top: 50,
393
- },
394
- error: {
395
- border: '2px solid red',
396
- boxSizing: 'border-box',
397
- },
398
- };
399
-
400
- interface UploadImageProps {
401
- maxSize?: number;
402
- disabled?: boolean;
403
- crop?: boolean;
404
- error?: boolean;
405
- onChange: (base64: string) => void | undefined;
406
- icon: string | null;
407
- removeIconFunc: () => void | null;
408
- accept?: Record<string, string[]>;
409
- }
410
-
411
- interface UploadImageState {
412
- uploadFile: boolean | 'dragging';
413
- anchorEl: HTMLElement | null;
414
- cropHandler: boolean;
415
- }
416
-
417
- class UploadImage extends Component<UploadImageProps, UploadImageState> {
418
- private readonly cropperRef: React.RefObject<ReactCropperElement>;
419
-
420
- constructor(props: UploadImageProps) {
421
- super(props);
422
-
423
- this.state = {
424
- uploadFile: false,
425
- anchorEl: null,
426
- cropHandler: false,
427
- };
428
- this.cropperRef = createRef();
429
-
430
- if (!window.document.getElementById('cropper-style-json-component')) {
431
- const style = window.document.createElement('style');
432
- style.setAttribute('id', 'cropper-style-json-component');
433
- style.innerHTML = cropperStyles;
434
- window.document.head.appendChild(style);
435
- }
436
- }
437
-
438
- onDrop(acceptedFiles: File[]): void {
439
- const onChange = this.props.onChange;
440
- const maxSize = this.props.maxSize || 10 * 1024;
441
-
442
- const file = acceptedFiles[0];
443
- const reader = new FileReader();
444
-
445
- reader.onabort = () => console.log('file reading was aborted');
446
- reader.onerror = () => console.log('file reading has failed');
447
- reader.onload = () => {
448
- if (!file || !file.name) {
449
- return;
450
- }
451
- const parts = file.name?.split('.');
452
- let ext = parts?.length ? `image/${parts.pop()?.toLowerCase()}` : 'image/jpeg';
453
- if (ext === 'image/jpg') {
454
- ext = 'image/jpeg';
455
- } else if (ext.includes('svg')) {
456
- ext = 'image/svg+xml';
457
- }
458
- if (file.size > maxSize) {
459
- window.alert(I18n.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));
460
- } else {
461
- const base64 = `data:${ext};base64,${btoa(
462
- new Uint8Array(reader.result as ArrayBufferLike).reduce(
463
- (data, byte) => data + String.fromCharCode(byte),
464
- '',
465
- ),
466
- )}`;
467
-
468
- if (onChange) {
469
- onChange(base64);
470
- } else {
471
- console.log(base64);
472
- }
473
- }
474
- };
475
- reader.readAsArrayBuffer(file);
476
- }
477
-
478
- render(): JSX.Element {
479
- const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;
480
- const maxSize = this.props.maxSize || 10 * 1024;
481
- let accept = this.props.accept || { 'image/*': [] };
482
- const { uploadFile, anchorEl, cropHandler } = this.state;
483
-
484
- // covert '"image/png"' to { 'image/*': [] }
485
- if (typeof accept === 'string') {
486
- accept = { [accept]: [] };
487
- } else if (Array.isArray(accept)) {
488
- const result: Record<string, string[]> = {};
489
- accept.forEach(item => {
490
- result[item] = [];
491
- });
492
- accept = result;
493
- }
494
-
495
- return (
496
- <Dropzone
497
- disabled={!!disabled || cropHandler}
498
- key="dropzone"
499
- multiple={false}
500
- accept={accept}
501
- maxSize={maxSize}
502
- onDragEnter={() => this.setState({ uploadFile: 'dragging' })}
503
- onDragLeave={() => this.setState({ uploadFile: true })}
504
- onDrop={(acceptedFiles: File[], errors) => {
505
- this.setState({ uploadFile: false });
506
- if (!acceptedFiles.length) {
507
- window.alert(
508
- (errors &&
509
- errors[0] &&
510
- errors[0].errors &&
511
- errors[0].errors[0] &&
512
- errors[0].errors[0].message) ||
513
- I18n.t('ra_Cannot upload'),
514
- );
515
- } else {
516
- this.onDrop(acceptedFiles);
517
- }
518
- }}
519
- >
520
- {({ getRootProps, getInputProps }) => (
521
- <div
522
- style={{
523
- ...styles.uploadDiv,
524
- ...(uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),
525
- ...styles.dropZone,
526
- ...(disabled ? styles.disabledOpacity : undefined),
527
- ...(!icon ? styles.dropZoneEmpty : undefined),
528
- }}
529
- {...getRootProps()}
530
- >
531
- <input {...getInputProps()} />
532
- <div style={{ ...styles.uploadCenterDiv, ...(error ? styles.error : undefined) }}>
533
- {!icon ? (
534
- <div style={styles.uploadCenterTextAndIcon}>
535
- <UploadIcon style={styles.uploadCenterIcon} />
536
- <div style={styles.uploadCenterText}>
537
- {uploadFile === 'dragging'
538
- ? I18n.t('ra_Drop file here')
539
- : I18n.t(
540
- 'ra_Place your files here or click here to open the browse dialog',
541
- )}
542
- </div>
543
- </div>
544
- ) : (
545
- removeIconFunc &&
546
- !cropHandler && (
547
- <div style={styles.buttonRemoveWrapper}>
548
- <Tooltip
549
- title={I18n.t('ra_Clear')}
550
- slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
551
- >
552
- <IconButton
553
- size="large"
554
- onClick={e => {
555
- removeIconFunc && removeIconFunc();
556
- e.stopPropagation();
557
- }}
558
- >
559
- <IconClose />
560
- </IconButton>
561
- </Tooltip>
562
- </div>
563
- )
564
- )}
565
- {icon && crop && (
566
- <div style={styles.buttonCropWrapper}>
567
- <Tooltip
568
- title={I18n.t('ra_Crop')}
569
- slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}
570
- >
571
- <IconButton
572
- size="large"
573
- onClick={e => {
574
- if (!cropHandler) {
575
- this.setState({ cropHandler: true });
576
- } else {
577
- this.setState({ anchorEl: e.currentTarget });
578
- }
579
- e.stopPropagation();
580
- }}
581
- >
582
- <CropIcon color={cropHandler ? 'primary' : 'inherit'} />
583
- </IconButton>
584
- </Tooltip>
585
- <Menu
586
- anchorEl={anchorEl}
587
- keepMounted
588
- open={Boolean(anchorEl)}
589
- onClose={() => this.setState({ anchorEl: null })}
590
- >
591
- <MenuItem
592
- onClick={() =>
593
- this.setState({ anchorEl: null, cropHandler: false }, () => {
594
- const imageElement = this.cropperRef?.current?.cropper;
595
- if (imageElement) {
596
- if (onChange) {
597
- onChange(imageElement.getCroppedCanvas().toDataURL());
598
- } else {
599
- console.log(imageElement.getCroppedCanvas().toDataURL());
600
- }
601
- }
602
- })
603
- }
604
- >
605
- {I18n.t('ra_Save')}
606
- </MenuItem>
607
- <MenuItem onClick={() => this.setState({ anchorEl: null, cropHandler: false })}>
608
- {I18n.t('ra_Close')}
609
- </MenuItem>
610
- </Menu>
611
- </div>
612
- )}
613
- {icon && !cropHandler ? (
614
- <Icon
615
- src={icon}
616
- style={styles.image}
617
- alt="icon"
618
- />
619
- ) : null}
620
-
621
- {icon && crop && cropHandler ? (
622
- <Cropper
623
- ref={this.cropperRef}
624
- style={styles.image}
625
- src={icon}
626
- initialAspectRatio={1}
627
- viewMode={1}
628
- guides={false}
629
- minCropBoxHeight={10}
630
- minCropBoxWidth={10}
631
- background={false}
632
- checkOrientation={false}
633
- />
634
- ) : null}
635
- </div>
636
- </div>
637
- )}
638
- </Dropzone>
639
- );
640
- }
641
- }
642
-
643
- export default UploadImage;