@iobroker/gui-components 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +1450 -0
- package/build/AdminConnection.d.ts +1 -0
- package/build/AdminConnection.js +2 -0
- package/build/AdminConnection.js.map +1 -0
- package/build/Components/404.d.ts +4 -0
- package/build/Components/404.js +97 -0
- package/build/Components/404.js.map +1 -0
- package/build/Components/ColorPicker.d.ts +86 -0
- package/build/Components/ColorPicker.js +222 -0
- package/build/Components/ColorPicker.js.map +1 -0
- package/build/Components/ComplexCron.d.ts +40 -0
- package/build/Components/ComplexCron.js +401 -0
- package/build/Components/ComplexCron.js.map +1 -0
- package/build/Components/CopyToClipboard.d.ts +14 -0
- package/build/Components/CopyToClipboard.js +160 -0
- package/build/Components/CopyToClipboard.js.map +1 -0
- package/build/Components/CustomModal.d.ts +26 -0
- package/build/Components/CustomModal.js +62 -0
- package/build/Components/CustomModal.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeIcon.d.ts +29 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js +108 -0
- package/build/Components/DeviceType/DeviceTypeIcon.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeOptions.d.ts +2 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js +69 -0
- package/build/Components/DeviceType/DeviceTypeOptions.js.map +1 -0
- package/build/Components/DeviceType/DeviceTypeSelector.d.ts +20 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js +83 -0
- package/build/Components/DeviceType/DeviceTypeSelector.js.map +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.d.ts +1 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js +30 -0
- package/build/Components/DeviceType/deviceTypeTranslations.js.map +1 -0
- package/build/Components/DeviceType/i18n/de.json +46 -0
- package/build/Components/DeviceType/i18n/en.json +46 -0
- package/build/Components/DeviceType/i18n/fr.json +46 -0
- package/build/Components/DeviceType/i18n/it.json +46 -0
- package/build/Components/DeviceType/i18n/nl.json +46 -0
- package/build/Components/DeviceType/i18n/pl.json +46 -0
- package/build/Components/DeviceType/i18n/pt.json +46 -0
- package/build/Components/DeviceType/i18n/ru.json +46 -0
- package/build/Components/DeviceType/i18n/uk.json +46 -0
- package/build/Components/DeviceType/i18n/zh-cn.json +46 -0
- package/build/Components/DeviceType/icons/Cleaner.d.ts +3 -0
- package/build/Components/DeviceType/icons/Cleaner.js +14 -0
- package/build/Components/DeviceType/icons/Cleaner.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorClosed.js +7 -0
- package/build/Components/DeviceType/icons/DoorClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/DoorOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/DoorOpened.js +7 -0
- package/build/Components/DeviceType/icons/DoorOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOff.js +8 -0
- package/build/Components/DeviceType/icons/FireOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FireOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FireOn.js +14 -0
- package/build/Components/DeviceType/icons/FireOn.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOff.js +11 -0
- package/build/Components/DeviceType/icons/FloodOff.js.map +1 -0
- package/build/Components/DeviceType/icons/FloodOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/FloodOn.js +18 -0
- package/build/Components/DeviceType/icons/FloodOn.js.map +1 -0
- package/build/Components/DeviceType/icons/Gate.d.ts +3 -0
- package/build/Components/DeviceType/icons/Gate.js +8 -0
- package/build/Components/DeviceType/icons/Gate.js.map +1 -0
- package/build/Components/DeviceType/icons/HeatValve.d.ts +3 -0
- package/build/Components/DeviceType/icons/HeatValve.js +6 -0
- package/build/Components/DeviceType/icons/HeatValve.js.map +1 -0
- package/build/Components/DeviceType/icons/Home.d.ts +3 -0
- package/build/Components/DeviceType/icons/Home.js +6 -0
- package/build/Components/DeviceType/icons/Home.js.map +1 -0
- package/build/Components/DeviceType/icons/Humidity.d.ts +3 -0
- package/build/Components/DeviceType/icons/Humidity.js +8 -0
- package/build/Components/DeviceType/icons/Humidity.js.map +1 -0
- package/build/Components/DeviceType/icons/IconHome.d.ts +5 -0
- package/build/Components/DeviceType/icons/IconHome.js +21 -0
- package/build/Components/DeviceType/icons/IconHome.js.map +1 -0
- package/build/Components/DeviceType/icons/Jalousie.d.ts +3 -0
- package/build/Components/DeviceType/icons/Jalousie.js +7 -0
- package/build/Components/DeviceType/icons/Jalousie.js.map +1 -0
- package/build/Components/DeviceType/icons/Material.d.ts +3 -0
- package/build/Components/DeviceType/icons/Material.js +8 -0
- package/build/Components/DeviceType/icons/Material.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOff.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOff.js +11 -0
- package/build/Components/DeviceType/icons/MotionOff.js.map +1 -0
- package/build/Components/DeviceType/icons/MotionOn.d.ts +3 -0
- package/build/Components/DeviceType/icons/MotionOn.js +7 -0
- package/build/Components/DeviceType/icons/MotionOn.js.map +1 -0
- package/build/Components/DeviceType/icons/PushButton.d.ts +3 -0
- package/build/Components/DeviceType/icons/PushButton.js +9 -0
- package/build/Components/DeviceType/icons/PushButton.js.map +1 -0
- package/build/Components/DeviceType/icons/RGB.d.ts +3 -0
- package/build/Components/DeviceType/icons/RGB.js +43 -0
- package/build/Components/DeviceType/icons/RGB.js.map +1 -0
- package/build/Components/DeviceType/icons/RepairExpert.d.ts +3 -0
- package/build/Components/DeviceType/icons/RepairExpert.js +6 -0
- package/build/Components/DeviceType/icons/RepairExpert.js.map +1 -0
- package/build/Components/DeviceType/icons/Socket.d.ts +3 -0
- package/build/Components/DeviceType/icons/Socket.js +8 -0
- package/build/Components/DeviceType/icons/Socket.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermometer.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermometer.js +7 -0
- package/build/Components/DeviceType/icons/Thermometer.js.map +1 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.d.ts +3 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js +8 -0
- package/build/Components/DeviceType/icons/ThermometerSimple.js.map +1 -0
- package/build/Components/DeviceType/icons/Thermostat.d.ts +3 -0
- package/build/Components/DeviceType/icons/Thermostat.js +9 -0
- package/build/Components/DeviceType/icons/Thermostat.js.map +1 -0
- package/build/Components/DeviceType/icons/Valve.d.ts +3 -0
- package/build/Components/DeviceType/icons/Valve.js +7 -0
- package/build/Components/DeviceType/icons/Valve.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowClosed.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowClosed.js +8 -0
- package/build/Components/DeviceType/icons/WindowClosed.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowOpened.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowOpened.js +9 -0
- package/build/Components/DeviceType/icons/WindowOpened.js.map +1 -0
- package/build/Components/DeviceType/icons/WindowTilted.d.ts +3 -0
- package/build/Components/DeviceType/icons/WindowTilted.js +8 -0
- package/build/Components/DeviceType/icons/WindowTilted.js.map +1 -0
- package/build/Components/DeviceType/icons/index.d.ts +28 -0
- package/build/Components/DeviceType/icons/index.js +28 -0
- package/build/Components/DeviceType/icons/index.js.map +1 -0
- package/build/Components/FileBrowser.d.ts +187 -0
- package/build/Components/FileBrowser.js +1711 -0
- package/build/Components/FileBrowser.js.map +1 -0
- package/build/Components/FileViewer.d.ts +49 -0
- package/build/Components/FileViewer.js +247 -0
- package/build/Components/FileViewer.js.map +1 -0
- package/build/Components/Icon.d.ts +35 -0
- package/build/Components/Icon.js +140 -0
- package/build/Components/Icon.js.map +1 -0
- package/build/Components/IconPicker.d.ts +25 -0
- package/build/Components/IconPicker.js +72 -0
- package/build/Components/IconPicker.js.map +1 -0
- package/build/Components/IconSelector.d.ts +33 -0
- package/build/Components/IconSelector.js +2086 -0
- package/build/Components/IconSelector.js.map +1 -0
- package/build/Components/Image.d.ts +31 -0
- package/build/Components/Image.js +126 -0
- package/build/Components/Image.js.map +1 -0
- package/build/Components/InfoBox.d.ts +37 -0
- package/build/Components/InfoBox.js +115 -0
- package/build/Components/InfoBox.js.map +1 -0
- package/build/Components/IobUri.d.ts +14 -0
- package/build/Components/IobUri.js +168 -0
- package/build/Components/IobUri.js.map +1 -0
- package/build/Components/Loader.d.ts +31 -0
- package/build/Components/Loader.js +265 -0
- package/build/Components/Loader.js.map +1 -0
- package/build/Components/Loaders/MV.d.ts +17 -0
- package/build/Components/Loaders/MV.js +61 -0
- package/build/Components/Loaders/MV.js.map +1 -0
- package/build/Components/Loaders/PT.d.ts +27 -0
- package/build/Components/Loaders/PT.js +150 -0
- package/build/Components/Loaders/PT.js.map +1 -0
- package/build/Components/Loaders/Vendor.d.ts +22 -0
- package/build/Components/Loaders/Vendor.js +52 -0
- package/build/Components/Loaders/Vendor.js.map +1 -0
- package/build/Components/Logo.d.ts +18 -0
- package/build/Components/Logo.js +109 -0
- package/build/Components/Logo.js.map +1 -0
- package/build/Components/MDUtils.d.ts +11 -0
- package/build/Components/MDUtils.js +99 -0
- package/build/Components/MDUtils.js.map +1 -0
- package/build/Components/ObjectBrowser.d.ts +665 -0
- package/build/Components/ObjectBrowser.js +6245 -0
- package/build/Components/ObjectBrowser.js.map +1 -0
- package/build/Components/Router.d.ts +21 -0
- package/build/Components/Router.js +77 -0
- package/build/Components/Router.js.map +1 -0
- package/build/Components/SaveCloseButtons.d.ts +20 -0
- package/build/Components/SaveCloseButtons.js +65 -0
- package/build/Components/SaveCloseButtons.js.map +1 -0
- package/build/Components/Schedule.d.ts +62 -0
- package/build/Components/Schedule.js +1266 -0
- package/build/Components/Schedule.js.map +1 -0
- package/build/Components/SelectWithIcon.d.ts +37 -0
- package/build/Components/SelectWithIcon.js +139 -0
- package/build/Components/SelectWithIcon.js.map +1 -0
- package/build/Components/SimpleCron/cronText.d.ts +10 -0
- package/build/Components/SimpleCron/cronText.js +14 -0
- package/build/Components/SimpleCron/cronText.js.map +1 -0
- package/build/Components/SimpleCron/index.d.ts +55 -0
- package/build/Components/SimpleCron/index.js +698 -0
- package/build/Components/SimpleCron/index.js.map +1 -0
- package/build/Components/TabContainer.d.ts +15 -0
- package/build/Components/TabContainer.js +23 -0
- package/build/Components/TabContainer.js.map +1 -0
- package/build/Components/TabContent.d.ts +11 -0
- package/build/Components/TabContent.js +20 -0
- package/build/Components/TabContent.js.map +1 -0
- package/build/Components/TabHeader.d.ts +6 -0
- package/build/Components/TabHeader.js +6 -0
- package/build/Components/TabHeader.js.map +1 -0
- package/build/Components/TableResize.d.ts +45 -0
- package/build/Components/TableResize.js +204 -0
- package/build/Components/TableResize.js.map +1 -0
- package/build/Components/TextWithIcon.d.ts +21 -0
- package/build/Components/TextWithIcon.js +113 -0
- package/build/Components/TextWithIcon.js.map +1 -0
- package/build/Components/ToggleThemeMenu.d.ts +12 -0
- package/build/Components/ToggleThemeMenu.js +13 -0
- package/build/Components/ToggleThemeMenu.js.map +1 -0
- package/build/Components/TreeTable.d.ts +79 -0
- package/build/Components/TreeTable.js +538 -0
- package/build/Components/TreeTable.js.map +1 -0
- package/build/Components/UploadImage.d.ts +23 -0
- package/build/Components/UploadImage.js +516 -0
- package/build/Components/UploadImage.js.map +1 -0
- package/build/Components/Utils.d.ts +331 -0
- package/build/Components/Utils.js +1605 -0
- package/build/Components/Utils.js.map +1 -0
- package/build/Components/withWidth.d.ts +2 -0
- package/build/Components/withWidth.js +22 -0
- package/build/Components/withWidth.js.map +1 -0
- package/build/Connection.d.ts +1 -0
- package/build/Connection.js +2 -0
- package/build/Connection.js.map +1 -0
- package/build/Dialogs/ComplexCron.d.ts +24 -0
- package/build/Dialogs/ComplexCron.js +85 -0
- package/build/Dialogs/ComplexCron.js.map +1 -0
- package/build/Dialogs/Confirm.d.ts +39 -0
- package/build/Dialogs/Confirm.js +83 -0
- package/build/Dialogs/Confirm.js.map +1 -0
- package/build/Dialogs/Cron.d.ts +29 -0
- package/build/Dialogs/Cron.js +72 -0
- package/build/Dialogs/Cron.js.map +1 -0
- package/build/Dialogs/Error.d.ts +18 -0
- package/build/Dialogs/Error.js +27 -0
- package/build/Dialogs/Error.js.map +1 -0
- package/build/Dialogs/Message.d.ts +20 -0
- package/build/Dialogs/Message.js +29 -0
- package/build/Dialogs/Message.js.map +1 -0
- package/build/Dialogs/SelectFile.d.ts +85 -0
- package/build/Dialogs/SelectFile.js +115 -0
- package/build/Dialogs/SelectFile.js.map +1 -0
- package/build/Dialogs/SelectID.d.ts +102 -0
- package/build/Dialogs/SelectID.js +151 -0
- package/build/Dialogs/SelectID.js.map +1 -0
- package/build/Dialogs/SimpleCron.d.ts +19 -0
- package/build/Dialogs/SimpleCron.js +46 -0
- package/build/Dialogs/SimpleCron.js.map +1 -0
- package/build/Dialogs/TextInput.d.ts +2 -0
- package/build/Dialogs/TextInput.js +31 -0
- package/build/Dialogs/TextInput.js.map +1 -0
- package/build/GenericApp.d.ts +209 -0
- package/build/GenericApp.js +842 -0
- package/build/GenericApp.js.map +1 -0
- package/build/LegacyConnection.d.ts +938 -0
- package/build/LegacyConnection.js +2849 -0
- package/build/LegacyConnection.js.map +1 -0
- package/build/Prompt.d.ts +5 -0
- package/build/Prompt.js +19 -0
- package/build/Prompt.js.map +1 -0
- package/build/Theme.d.ts +5 -0
- package/build/Theme.js +344 -0
- package/build/Theme.js.map +1 -0
- package/build/assets/devices/parseNames.d.ts +0 -0
- package/build/assets/devices/parseNames.js +35 -0
- package/build/assets/devices/parseNames.js.map +1 -0
- package/build/assets/devices.json +1 -0
- package/build/assets/lamp_ceiling.svg +9 -0
- package/build/assets/lamp_table.svg +8 -0
- package/build/assets/no_icon.svg +9 -0
- package/build/assets/rooms/parseNames.d.ts +0 -0
- package/build/assets/rooms/parseNames.js +35 -0
- package/build/assets/rooms/parseNames.js.map +1 -0
- package/build/assets/rooms.json +1 -0
- package/build/dictionary.d.ts +1 -0
- package/build/dictionary.js +25 -0
- package/build/dictionary.js.map +1 -0
- package/build/globals.d.ts +19 -0
- package/build/i18n/de.json +480 -0
- package/build/i18n/en.json +480 -0
- package/build/i18n/es.json +480 -0
- package/build/i18n/fr.json +480 -0
- package/build/i18n/it.json +475 -0
- package/build/i18n/nl.json +475 -0
- package/build/i18n/pl.json +475 -0
- package/build/i18n/pt.json +475 -0
- package/build/i18n/ru.json +475 -0
- package/build/i18n/uk.json +475 -0
- package/build/i18n/zh-cn.json +475 -0
- package/build/i18n.d.ts +84 -0
- package/build/i18n.js +224 -0
- package/build/i18n.js.map +1 -0
- package/build/icons/IconAdapter.d.ts +3 -0
- package/build/icons/IconAdapter.js +7 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +7 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconButtonImage.d.ts +3 -0
- package/build/icons/IconButtonImage.js +9 -0
- package/build/icons/IconButtonImage.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +10 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +8 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +7 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +6 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +16 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +7 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +8 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +7 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +6 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +7 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +7 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +6 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +7 -0
- package/build/icons/IconOpen.js.map +1 -0
- package/build/icons/IconState.d.ts +3 -0
- package/build/icons/IconState.js +7 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/icons/IconVacuum.d.ts +3 -0
- package/build/icons/IconVacuum.js +12 -0
- package/build/icons/IconVacuum.js.map +1 -0
- package/build/index.css +56 -0
- package/build/index.d.ts +87 -0
- package/build/index.js +85 -0
- package/build/index.js.map +1 -0
- package/build/modulefederation.admin.config.d.ts +13 -0
- package/build/modulefederation.admin.config.js +45 -0
- package/build/modulefederation.admin.config.js.map +1 -0
- package/build/types.d.ts +236 -0
- package/i18n/de.json +480 -0
- package/i18n/en.json +480 -0
- package/i18n/es.json +480 -0
- package/i18n/fr.json +480 -0
- package/i18n/it.json +475 -0
- package/i18n/nl.json +475 -0
- package/i18n/pl.json +475 -0
- package/i18n/pt.json +475 -0
- package/i18n/ru.json +475 -0
- package/i18n/uk.json +475 -0
- package/i18n/zh-cn.json +475 -0
- package/index.css +56 -0
- package/modulefederation.admin.config.d.ts +20 -0
- package/modulefederation.admin.config.js +54 -0
- package/package.json +86 -0
- package/tasksExample.js +91 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import React, { Component, createRef } from 'react';
|
|
2
|
+
import Dropzone from 'react-dropzone';
|
|
3
|
+
import { Cropper } from 'react-cropper';
|
|
4
|
+
import { Menu, MenuItem, Tooltip, IconButton } from '@mui/material';
|
|
5
|
+
import { Close as IconClose, Crop as CropIcon, UploadFileOutlined as UploadIcon } from '@mui/icons-material';
|
|
6
|
+
import { I18n } from '../i18n';
|
|
7
|
+
import { Icon } from './Icon';
|
|
8
|
+
// import 'cropperjs/dist/cropper.css';
|
|
9
|
+
const cropperStyles = `
|
|
10
|
+
/*!
|
|
11
|
+
* Cropper.js v1.5.12
|
|
12
|
+
* https://fengyuanchen.github.io/cropperjs
|
|
13
|
+
*
|
|
14
|
+
* Copyright 2015-present Chen Fengyuan
|
|
15
|
+
* Released under the MIT license
|
|
16
|
+
*
|
|
17
|
+
* Date: 2021-06-12T08:00:11.623Z
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
.cropper-container {
|
|
21
|
+
direction: ltr;
|
|
22
|
+
font-size: 0;
|
|
23
|
+
line-height: 0;
|
|
24
|
+
position: relative;
|
|
25
|
+
-ms-touch-action: none;
|
|
26
|
+
touch-action: none;
|
|
27
|
+
-webkit-user-select: none;
|
|
28
|
+
-moz-user-select: none;
|
|
29
|
+
-ms-user-select: none;
|
|
30
|
+
user-select: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.cropper-container img {
|
|
34
|
+
display: block;
|
|
35
|
+
height: 100%;
|
|
36
|
+
image-orientation: 0deg;
|
|
37
|
+
max-height: none !important;
|
|
38
|
+
max-width: none !important;
|
|
39
|
+
min-height: 0 !important;
|
|
40
|
+
min-width: 0 !important;
|
|
41
|
+
width: 100%;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.cropper-wrap-box,
|
|
45
|
+
.cropper-canvas,
|
|
46
|
+
.cropper-drag-box,
|
|
47
|
+
.cropper-crop-box,
|
|
48
|
+
.cropper-modal {
|
|
49
|
+
bottom: 0;
|
|
50
|
+
left: 0;
|
|
51
|
+
position: absolute;
|
|
52
|
+
right: 0;
|
|
53
|
+
top: 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.cropper-wrap-box,
|
|
57
|
+
.cropper-canvas {
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.cropper-drag-box {
|
|
62
|
+
background-color: #fff;
|
|
63
|
+
opacity: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cropper-modal {
|
|
67
|
+
background-color: #000;
|
|
68
|
+
opacity: 0.5;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.cropper-view-box {
|
|
72
|
+
display: block;
|
|
73
|
+
height: 100%;
|
|
74
|
+
outline: 1px solid #39f;
|
|
75
|
+
outline-color: rgba(51, 153, 255, 0.75);
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
width: 100%;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cropper-dashed {
|
|
81
|
+
border: 0 dashed #eee;
|
|
82
|
+
display: block;
|
|
83
|
+
opacity: 0.5;
|
|
84
|
+
position: absolute;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.cropper-dashed.dashed-h {
|
|
88
|
+
border-bottom-width: 1px;
|
|
89
|
+
border-top-width: 1px;
|
|
90
|
+
height: calc(100% / 3);
|
|
91
|
+
left: 0;
|
|
92
|
+
top: calc(100% / 3);
|
|
93
|
+
width: 100%;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.cropper-dashed.dashed-v {
|
|
97
|
+
border-left-width: 1px;
|
|
98
|
+
border-right-width: 1px;
|
|
99
|
+
height: 100%;
|
|
100
|
+
left: calc(100% / 3);
|
|
101
|
+
top: 0;
|
|
102
|
+
width: calc(100% / 3);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.cropper-center {
|
|
106
|
+
display: block;
|
|
107
|
+
height: 0;
|
|
108
|
+
left: 50%;
|
|
109
|
+
opacity: 0.75;
|
|
110
|
+
position: absolute;
|
|
111
|
+
top: 50%;
|
|
112
|
+
width: 0;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.cropper-center::before,
|
|
116
|
+
.cropper-center::after {
|
|
117
|
+
background-color: #eee;
|
|
118
|
+
content: ' ';
|
|
119
|
+
display: block;
|
|
120
|
+
position: absolute;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.cropper-center::before {
|
|
124
|
+
height: 1px;
|
|
125
|
+
left: -3px;
|
|
126
|
+
top: 0;
|
|
127
|
+
width: 7px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.cropper-center::after {
|
|
131
|
+
height: 7px;
|
|
132
|
+
left: 0;
|
|
133
|
+
top: -3px;
|
|
134
|
+
width: 1px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.cropper-face,
|
|
138
|
+
.cropper-line,
|
|
139
|
+
.cropper-point {
|
|
140
|
+
display: block;
|
|
141
|
+
height: 100%;
|
|
142
|
+
opacity: 0.1;
|
|
143
|
+
position: absolute;
|
|
144
|
+
width: 100%;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.cropper-face {
|
|
148
|
+
background-color: #fff;
|
|
149
|
+
left: 0;
|
|
150
|
+
top: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.cropper-line {
|
|
154
|
+
background-color: #39f;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.cropper-line.line-e {
|
|
158
|
+
cursor: ew-resize;
|
|
159
|
+
right: -3px;
|
|
160
|
+
top: 0;
|
|
161
|
+
width: 5px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.cropper-line.line-n {
|
|
165
|
+
cursor: ns-resize;
|
|
166
|
+
height: 5px;
|
|
167
|
+
left: 0;
|
|
168
|
+
top: -3px;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.cropper-line.line-w {
|
|
172
|
+
cursor: ew-resize;
|
|
173
|
+
left: -3px;
|
|
174
|
+
top: 0;
|
|
175
|
+
width: 5px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.cropper-line.line-s {
|
|
179
|
+
bottom: -3px;
|
|
180
|
+
cursor: ns-resize;
|
|
181
|
+
height: 5px;
|
|
182
|
+
left: 0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.cropper-point {
|
|
186
|
+
background-color: #39f;
|
|
187
|
+
height: 5px;
|
|
188
|
+
opacity: 0.75;
|
|
189
|
+
width: 5px;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.cropper-point.point-e {
|
|
193
|
+
cursor: ew-resize;
|
|
194
|
+
margin-top: -3px;
|
|
195
|
+
right: -3px;
|
|
196
|
+
top: 50%;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.cropper-point.point-n {
|
|
200
|
+
cursor: ns-resize;
|
|
201
|
+
left: 50%;
|
|
202
|
+
margin-left: -3px;
|
|
203
|
+
top: -3px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.cropper-point.point-w {
|
|
207
|
+
cursor: ew-resize;
|
|
208
|
+
left: -3px;
|
|
209
|
+
margin-top: -3px;
|
|
210
|
+
top: 50%;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.cropper-point.point-s {
|
|
214
|
+
bottom: -3px;
|
|
215
|
+
cursor: s-resize;
|
|
216
|
+
left: 50%;
|
|
217
|
+
margin-left: -3px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.cropper-point.point-ne {
|
|
221
|
+
cursor: nesw-resize;
|
|
222
|
+
right: -3px;
|
|
223
|
+
top: -3px;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.cropper-point.point-nw {
|
|
227
|
+
cursor: nwse-resize;
|
|
228
|
+
left: -3px;
|
|
229
|
+
top: -3px;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.cropper-point.point-sw {
|
|
233
|
+
bottom: -3px;
|
|
234
|
+
cursor: nesw-resize;
|
|
235
|
+
left: -3px;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.cropper-point.point-se {
|
|
239
|
+
bottom: -3px;
|
|
240
|
+
cursor: nwse-resize;
|
|
241
|
+
height: 20px;
|
|
242
|
+
opacity: 1;
|
|
243
|
+
right: -3px;
|
|
244
|
+
width: 20px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@media (min-width: 768px) {
|
|
248
|
+
.cropper-point.point-se {
|
|
249
|
+
height: 15px;
|
|
250
|
+
width: 15px;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
@media (min-width: 992px) {
|
|
255
|
+
.cropper-point.point-se {
|
|
256
|
+
height: 10px;
|
|
257
|
+
width: 10px;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
@media (min-width: 1200px) {
|
|
262
|
+
.cropper-point.point-se {
|
|
263
|
+
height: 5px;
|
|
264
|
+
opacity: 0.75;
|
|
265
|
+
width: 5px;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.cropper-point.point-se::before {
|
|
270
|
+
background-color: #39f;
|
|
271
|
+
bottom: -50%;
|
|
272
|
+
content: ' ';
|
|
273
|
+
display: block;
|
|
274
|
+
height: 200%;
|
|
275
|
+
opacity: 0;
|
|
276
|
+
position: absolute;
|
|
277
|
+
right: -50%;
|
|
278
|
+
width: 200%;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.cropper-invisible {
|
|
282
|
+
opacity: 0;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.cropper-bg {
|
|
286
|
+
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.cropper-hide {
|
|
290
|
+
display: block;
|
|
291
|
+
height: 0;
|
|
292
|
+
position: absolute;
|
|
293
|
+
width: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.cropper-hidden {
|
|
297
|
+
display: none !important;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.cropper-move {
|
|
301
|
+
cursor: move;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.cropper-crop {
|
|
305
|
+
cursor: crosshair;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.cropper-disabled .cropper-drag-box,
|
|
309
|
+
.cropper-disabled .cropper-face,
|
|
310
|
+
.cropper-disabled .cropper-line,
|
|
311
|
+
.cropper-disabled .cropper-point {
|
|
312
|
+
cursor: not-allowed;
|
|
313
|
+
}
|
|
314
|
+
`;
|
|
315
|
+
const styles = {
|
|
316
|
+
dropZone: {
|
|
317
|
+
width: '100%',
|
|
318
|
+
height: 100,
|
|
319
|
+
position: 'relative',
|
|
320
|
+
},
|
|
321
|
+
dropZoneEmpty: {},
|
|
322
|
+
image: {
|
|
323
|
+
objectFit: 'contain',
|
|
324
|
+
margin: 'auto',
|
|
325
|
+
display: 'flex',
|
|
326
|
+
width: '100%',
|
|
327
|
+
height: '100%',
|
|
328
|
+
},
|
|
329
|
+
uploadDiv: {
|
|
330
|
+
position: 'relative',
|
|
331
|
+
width: '100%',
|
|
332
|
+
height: 300,
|
|
333
|
+
opacity: 0.9,
|
|
334
|
+
marginTop: 30,
|
|
335
|
+
cursor: 'pointer',
|
|
336
|
+
outline: 'none',
|
|
337
|
+
},
|
|
338
|
+
uploadDivDragging: {
|
|
339
|
+
opacity: 1,
|
|
340
|
+
background: 'rgba(128,255,128,0.1)',
|
|
341
|
+
},
|
|
342
|
+
uploadCenterDiv: {
|
|
343
|
+
margin: 5,
|
|
344
|
+
border: '3px dashed grey',
|
|
345
|
+
borderRadius: 5,
|
|
346
|
+
width: 'calc(100% - 10px)',
|
|
347
|
+
height: 'calc(100% - 10px)',
|
|
348
|
+
position: 'relative',
|
|
349
|
+
display: 'flex',
|
|
350
|
+
},
|
|
351
|
+
uploadCenterIcon: {
|
|
352
|
+
paddingTop: 10,
|
|
353
|
+
width: 48,
|
|
354
|
+
height: 48,
|
|
355
|
+
},
|
|
356
|
+
uploadCenterText: {
|
|
357
|
+
fontSize: 16,
|
|
358
|
+
},
|
|
359
|
+
uploadCenterTextAndIcon: {
|
|
360
|
+
textAlign: 'center',
|
|
361
|
+
position: 'absolute',
|
|
362
|
+
top: 0,
|
|
363
|
+
bottom: 0,
|
|
364
|
+
left: 0,
|
|
365
|
+
right: 0,
|
|
366
|
+
display: 'flex',
|
|
367
|
+
flexDirection: 'column',
|
|
368
|
+
alignItems: 'center',
|
|
369
|
+
justifyContent: 'center',
|
|
370
|
+
},
|
|
371
|
+
disabledOpacity: {
|
|
372
|
+
opacity: 0.3,
|
|
373
|
+
cursor: 'default',
|
|
374
|
+
},
|
|
375
|
+
buttonRemoveWrapper: {
|
|
376
|
+
position: 'absolute',
|
|
377
|
+
zIndex: 222,
|
|
378
|
+
right: 0,
|
|
379
|
+
},
|
|
380
|
+
buttonCropWrapper: {
|
|
381
|
+
position: 'absolute',
|
|
382
|
+
zIndex: 222,
|
|
383
|
+
right: 0,
|
|
384
|
+
top: 50,
|
|
385
|
+
},
|
|
386
|
+
error: {
|
|
387
|
+
border: '2px solid red',
|
|
388
|
+
boxSizing: 'border-box',
|
|
389
|
+
},
|
|
390
|
+
};
|
|
391
|
+
export class UploadImage extends Component {
|
|
392
|
+
cropperRef;
|
|
393
|
+
constructor(props) {
|
|
394
|
+
super(props);
|
|
395
|
+
this.state = {
|
|
396
|
+
uploadFile: false,
|
|
397
|
+
anchorEl: null,
|
|
398
|
+
cropHandler: false,
|
|
399
|
+
};
|
|
400
|
+
this.cropperRef = createRef();
|
|
401
|
+
if (!window.document.getElementById('cropper-style-json-component')) {
|
|
402
|
+
const style = window.document.createElement('style');
|
|
403
|
+
style.setAttribute('id', 'cropper-style-json-component');
|
|
404
|
+
style.innerHTML = cropperStyles;
|
|
405
|
+
window.document.head.appendChild(style);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
onDrop(acceptedFiles) {
|
|
409
|
+
const onChange = this.props.onChange;
|
|
410
|
+
const maxSize = this.props.maxSize || 10 * 1024;
|
|
411
|
+
const file = acceptedFiles[0];
|
|
412
|
+
const reader = new FileReader();
|
|
413
|
+
reader.onabort = () => console.log('file reading was aborted');
|
|
414
|
+
reader.onerror = () => console.log('file reading has failed');
|
|
415
|
+
reader.onload = () => {
|
|
416
|
+
if (!file || !file.name) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const parts = file.name?.split('.');
|
|
420
|
+
let ext = parts?.length ? `image/${parts.pop()?.toLowerCase()}` : 'image/jpeg';
|
|
421
|
+
if (ext === 'image/jpg') {
|
|
422
|
+
ext = 'image/jpeg';
|
|
423
|
+
}
|
|
424
|
+
else if (ext.includes('svg')) {
|
|
425
|
+
ext = 'image/svg+xml';
|
|
426
|
+
}
|
|
427
|
+
if (file.size > maxSize) {
|
|
428
|
+
window.alert(I18n.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
const base64 = `data:${ext};base64,${btoa(new Uint8Array(reader.result).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`;
|
|
432
|
+
if (onChange) {
|
|
433
|
+
onChange(base64);
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
console.log(base64);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
reader.readAsArrayBuffer(file);
|
|
441
|
+
}
|
|
442
|
+
render() {
|
|
443
|
+
const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;
|
|
444
|
+
const maxSize = this.props.maxSize || 10 * 1024;
|
|
445
|
+
let accept = this.props.accept || { 'image/*': [] };
|
|
446
|
+
const { uploadFile, anchorEl, cropHandler } = this.state;
|
|
447
|
+
// covert '"image/png"' to { 'image/*': [] }
|
|
448
|
+
if (typeof accept === 'string') {
|
|
449
|
+
accept = { [accept]: [] };
|
|
450
|
+
}
|
|
451
|
+
else if (Array.isArray(accept)) {
|
|
452
|
+
const result = {};
|
|
453
|
+
accept.forEach(item => {
|
|
454
|
+
result[item] = [];
|
|
455
|
+
});
|
|
456
|
+
accept = result;
|
|
457
|
+
}
|
|
458
|
+
return (React.createElement(Dropzone, { disabled: !!disabled || cropHandler, key: "dropzone", multiple: false, accept: accept, maxSize: maxSize, onDragEnter: () => this.setState({ uploadFile: 'dragging' }), onDragLeave: () => this.setState({ uploadFile: true }), onDrop: (acceptedFiles, errors) => {
|
|
459
|
+
this.setState({ uploadFile: false });
|
|
460
|
+
if (!acceptedFiles.length) {
|
|
461
|
+
window.alert(errors?.[0]?.errors?.[0]?.message || I18n.t('ra_Cannot upload'));
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
this.onDrop(acceptedFiles);
|
|
465
|
+
}
|
|
466
|
+
} }, ({ getRootProps, getInputProps }) => (React.createElement("div", { style: {
|
|
467
|
+
...styles.uploadDiv,
|
|
468
|
+
...(uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),
|
|
469
|
+
...styles.dropZone,
|
|
470
|
+
...(disabled ? styles.disabledOpacity : undefined),
|
|
471
|
+
...(!icon ? styles.dropZoneEmpty : undefined),
|
|
472
|
+
}, ...getRootProps() },
|
|
473
|
+
React.createElement("input", { ...getInputProps() }),
|
|
474
|
+
React.createElement("div", { style: { ...styles.uploadCenterDiv, ...(error ? styles.error : undefined) } },
|
|
475
|
+
!icon ? (React.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
476
|
+
React.createElement(UploadIcon, { style: styles.uploadCenterIcon }),
|
|
477
|
+
React.createElement("div", { style: styles.uploadCenterText }, uploadFile === 'dragging'
|
|
478
|
+
? I18n.t('ra_Drop file here')
|
|
479
|
+
: I18n.t('ra_Place your files here or click here to open the browse dialog')))) : (removeIconFunc &&
|
|
480
|
+
!cropHandler && (React.createElement("div", { style: styles.buttonRemoveWrapper },
|
|
481
|
+
React.createElement(Tooltip, { title: I18n.t('ra_Clear'), slotProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
482
|
+
React.createElement(IconButton, { size: "large", onClick: e => {
|
|
483
|
+
removeIconFunc && removeIconFunc();
|
|
484
|
+
e.stopPropagation();
|
|
485
|
+
} },
|
|
486
|
+
React.createElement(IconClose, null)))))),
|
|
487
|
+
icon && crop && (React.createElement("div", { style: styles.buttonCropWrapper },
|
|
488
|
+
React.createElement(Tooltip, { title: I18n.t('ra_Crop'), slotProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
489
|
+
React.createElement(IconButton, { size: "large", onClick: e => {
|
|
490
|
+
if (!cropHandler) {
|
|
491
|
+
this.setState({ cropHandler: true });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
this.setState({ anchorEl: e.currentTarget });
|
|
495
|
+
}
|
|
496
|
+
e.stopPropagation();
|
|
497
|
+
} },
|
|
498
|
+
React.createElement(CropIcon, { color: cropHandler ? 'primary' : 'inherit' }))),
|
|
499
|
+
React.createElement(Menu, { anchorEl: anchorEl, keepMounted: true, open: Boolean(anchorEl), onClose: () => this.setState({ anchorEl: null }) },
|
|
500
|
+
React.createElement(MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }, () => {
|
|
501
|
+
const imageElement = this.cropperRef?.current?.cropper;
|
|
502
|
+
if (imageElement) {
|
|
503
|
+
if (onChange) {
|
|
504
|
+
onChange(imageElement.getCroppedCanvas().toDataURL());
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
console.log(imageElement.getCroppedCanvas().toDataURL());
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}) }, I18n.t('ra_Save')),
|
|
511
|
+
React.createElement(MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }) }, I18n.t('ra_Close'))))),
|
|
512
|
+
icon && !cropHandler ? (React.createElement(Icon, { src: icon, style: styles.image, alt: "icon" })) : null,
|
|
513
|
+
icon && crop && cropHandler ? (React.createElement(Cropper, { ref: this.cropperRef, style: styles.image, src: icon, initialAspectRatio: 1, viewMode: 1, guides: false, minCropBoxHeight: 10, minCropBoxWidth: 10, background: false, checkOrientation: false })) : null)))));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
//# sourceMappingURL=UploadImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UploadImage.js","sourceRoot":"./src/","sources":["Components/UploadImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAC9D,OAAO,QAAgC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAA4B,MAAM,eAAe,CAAC;AAElE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,IAAI,IAAI,QAAQ,EAAE,kBAAkB,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE7G,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,uCAAuC;AACvC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C,CAAC,CAAC,SAAS,CAAC,CACX;wBACX,oBAAC,QAAQ,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,IACzE,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CACZ,CACR,CACL,CACT;gBACA,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CACpB,oBAAC,IAAI,IACD,GAAG,EAAE,IAAI,EACT,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,GAAG,EAAC,MAAM,GACZ,CACL,CAAC,CAAC,CAAC,IAAI;gBAEP,IAAI,IAAI,IAAI,IAAI,WAAW,CAAC,CAAC,CAAC,CAC3B,oBAAC,OAAO,IACJ,GAAG,EAAE,IAAI,CAAC,UAAU,EACpB,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,GAAG,EAAE,IAAI,EACT,kBAAkB,EAAE,CAAC,EACrB,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,KAAK,EACb,gBAAgB,EAAE,EAAE,EACpB,eAAe,EAAE,EAAE,EACnB,UAAU,EAAE,KAAK,EACjB,gBAAgB,EAAE,KAAK,GACzB,CACL,CAAC,CAAC,CAAC,IAAI,CACN,CACJ,CACT,CACM,CACd,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { Component, createRef, type JSX } from 'react';\r\nimport Dropzone, { type FileRejection } from 'react-dropzone';\r\nimport { Cropper, type ReactCropperElement } from 'react-cropper';\r\n\r\nimport { Menu, MenuItem, Tooltip, IconButton } from '@mui/material';\r\n\r\nimport { Close as IconClose, Crop as CropIcon, UploadFileOutlined as UploadIcon } from '@mui/icons-material';\r\n\r\nimport { I18n } from '../i18n';\r\nimport { Icon } from './Icon';\r\n\r\n// import 'cropperjs/dist/cropper.css';\r\nconst cropperStyles = `\r\n/*!\r\n * Cropper.js v1.5.12\r\n * https://fengyuanchen.github.io/cropperjs\r\n *\r\n * Copyright 2015-present Chen Fengyuan\r\n * Released under the MIT license\r\n *\r\n * Date: 2021-06-12T08:00:11.623Z\r\n */\r\n\r\n.cropper-container {\r\n direction: ltr;\r\n font-size: 0;\r\n line-height: 0;\r\n position: relative;\r\n -ms-touch-action: none;\r\n touch-action: none;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n}\r\n\r\n.cropper-container img {\r\n display: block;\r\n height: 100%;\r\n image-orientation: 0deg;\r\n max-height: none !important;\r\n max-width: none !important;\r\n min-height: 0 !important;\r\n min-width: 0 !important;\r\n width: 100%;\r\n}\r\n\r\n.cropper-wrap-box,\r\n.cropper-canvas,\r\n.cropper-drag-box,\r\n.cropper-crop-box,\r\n.cropper-modal {\r\n bottom: 0;\r\n left: 0;\r\n position: absolute;\r\n right: 0;\r\n top: 0;\r\n}\r\n\r\n.cropper-wrap-box,\r\n.cropper-canvas {\r\n overflow: hidden;\r\n}\r\n\r\n.cropper-drag-box {\r\n background-color: #fff;\r\n opacity: 0;\r\n}\r\n\r\n.cropper-modal {\r\n background-color: #000;\r\n opacity: 0.5;\r\n}\r\n\r\n.cropper-view-box {\r\n display: block;\r\n height: 100%;\r\n outline: 1px solid #39f;\r\n outline-color: rgba(51, 153, 255, 0.75);\r\n overflow: hidden;\r\n width: 100%;\r\n}\r\n\r\n.cropper-dashed {\r\n border: 0 dashed #eee;\r\n display: block;\r\n opacity: 0.5;\r\n position: absolute;\r\n}\r\n\r\n.cropper-dashed.dashed-h {\r\n border-bottom-width: 1px;\r\n border-top-width: 1px;\r\n height: calc(100% / 3);\r\n left: 0;\r\n top: calc(100% / 3);\r\n width: 100%;\r\n}\r\n\r\n.cropper-dashed.dashed-v {\r\n border-left-width: 1px;\r\n border-right-width: 1px;\r\n height: 100%;\r\n left: calc(100% / 3);\r\n top: 0;\r\n width: calc(100% / 3);\r\n}\r\n\r\n.cropper-center {\r\n display: block;\r\n height: 0;\r\n left: 50%;\r\n opacity: 0.75;\r\n position: absolute;\r\n top: 50%;\r\n width: 0;\r\n}\r\n\r\n.cropper-center::before,\r\n.cropper-center::after {\r\n background-color: #eee;\r\n content: ' ';\r\n display: block;\r\n position: absolute;\r\n}\r\n\r\n.cropper-center::before {\r\n height: 1px;\r\n left: -3px;\r\n top: 0;\r\n width: 7px;\r\n}\r\n\r\n.cropper-center::after {\r\n height: 7px;\r\n left: 0;\r\n top: -3px;\r\n width: 1px;\r\n}\r\n\r\n.cropper-face,\r\n.cropper-line,\r\n.cropper-point {\r\n display: block;\r\n height: 100%;\r\n opacity: 0.1;\r\n position: absolute;\r\n width: 100%;\r\n}\r\n\r\n.cropper-face {\r\n background-color: #fff;\r\n left: 0;\r\n top: 0;\r\n}\r\n\r\n.cropper-line {\r\n background-color: #39f;\r\n}\r\n\r\n.cropper-line.line-e {\r\n cursor: ew-resize;\r\n right: -3px;\r\n top: 0;\r\n width: 5px;\r\n}\r\n\r\n.cropper-line.line-n {\r\n cursor: ns-resize;\r\n height: 5px;\r\n left: 0;\r\n top: -3px;\r\n}\r\n\r\n.cropper-line.line-w {\r\n cursor: ew-resize;\r\n left: -3px;\r\n top: 0;\r\n width: 5px;\r\n}\r\n\r\n.cropper-line.line-s {\r\n bottom: -3px;\r\n cursor: ns-resize;\r\n height: 5px;\r\n left: 0;\r\n}\r\n\r\n.cropper-point {\r\n background-color: #39f;\r\n height: 5px;\r\n opacity: 0.75;\r\n width: 5px;\r\n}\r\n\r\n.cropper-point.point-e {\r\n cursor: ew-resize;\r\n margin-top: -3px;\r\n right: -3px;\r\n top: 50%;\r\n}\r\n\r\n.cropper-point.point-n {\r\n cursor: ns-resize;\r\n left: 50%;\r\n margin-left: -3px;\r\n top: -3px;\r\n}\r\n\r\n.cropper-point.point-w {\r\n cursor: ew-resize;\r\n left: -3px;\r\n margin-top: -3px;\r\n top: 50%;\r\n}\r\n\r\n.cropper-point.point-s {\r\n bottom: -3px;\r\n cursor: s-resize;\r\n left: 50%;\r\n margin-left: -3px;\r\n}\r\n\r\n.cropper-point.point-ne {\r\n cursor: nesw-resize;\r\n right: -3px;\r\n top: -3px;\r\n}\r\n\r\n.cropper-point.point-nw {\r\n cursor: nwse-resize;\r\n left: -3px;\r\n top: -3px;\r\n}\r\n\r\n.cropper-point.point-sw {\r\n bottom: -3px;\r\n cursor: nesw-resize;\r\n left: -3px;\r\n}\r\n\r\n.cropper-point.point-se {\r\n bottom: -3px;\r\n cursor: nwse-resize;\r\n height: 20px;\r\n opacity: 1;\r\n right: -3px;\r\n width: 20px;\r\n}\r\n\r\n@media (min-width: 768px) {\r\n .cropper-point.point-se {\r\n height: 15px;\r\n width: 15px;\r\n }\r\n}\r\n\r\n@media (min-width: 992px) {\r\n .cropper-point.point-se {\r\n height: 10px;\r\n width: 10px;\r\n }\r\n}\r\n\r\n@media (min-width: 1200px) {\r\n .cropper-point.point-se {\r\n height: 5px;\r\n opacity: 0.75;\r\n width: 5px;\r\n }\r\n}\r\n\r\n.cropper-point.point-se::before {\r\n background-color: #39f;\r\n bottom: -50%;\r\n content: ' ';\r\n display: block;\r\n height: 200%;\r\n opacity: 0;\r\n position: absolute;\r\n right: -50%;\r\n width: 200%;\r\n}\r\n\r\n.cropper-invisible {\r\n opacity: 0;\r\n}\r\n\r\n.cropper-bg {\r\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');\r\n}\r\n\r\n.cropper-hide {\r\n display: block;\r\n height: 0;\r\n position: absolute;\r\n width: 0;\r\n}\r\n\r\n.cropper-hidden {\r\n display: none !important;\r\n}\r\n\r\n.cropper-move {\r\n cursor: move;\r\n}\r\n\r\n.cropper-crop {\r\n cursor: crosshair;\r\n}\r\n\r\n.cropper-disabled .cropper-drag-box,\r\n.cropper-disabled .cropper-face,\r\n.cropper-disabled .cropper-line,\r\n.cropper-disabled .cropper-point {\r\n cursor: not-allowed;\r\n}\r\n`;\r\n\r\nconst styles: Record<string, React.CSSProperties> = {\r\n dropZone: {\r\n width: '100%',\r\n height: 100,\r\n position: 'relative',\r\n },\r\n dropZoneEmpty: {},\r\n image: {\r\n objectFit: 'contain',\r\n margin: 'auto',\r\n display: 'flex',\r\n width: '100%',\r\n height: '100%',\r\n },\r\n\r\n uploadDiv: {\r\n position: 'relative',\r\n width: '100%',\r\n height: 300,\r\n opacity: 0.9,\r\n marginTop: 30,\r\n cursor: 'pointer',\r\n outline: 'none',\r\n },\r\n uploadDivDragging: {\r\n opacity: 1,\r\n background: 'rgba(128,255,128,0.1)',\r\n },\r\n\r\n uploadCenterDiv: {\r\n margin: 5,\r\n border: '3px dashed grey',\r\n borderRadius: 5,\r\n width: 'calc(100% - 10px)',\r\n height: 'calc(100% - 10px)',\r\n position: 'relative',\r\n display: 'flex',\r\n },\r\n uploadCenterIcon: {\r\n paddingTop: 10,\r\n width: 48,\r\n height: 48,\r\n },\r\n uploadCenterText: {\r\n fontSize: 16,\r\n },\r\n uploadCenterTextAndIcon: {\r\n textAlign: 'center',\r\n position: 'absolute',\r\n top: 0,\r\n bottom: 0,\r\n left: 0,\r\n right: 0,\r\n display: 'flex',\r\n flexDirection: 'column',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n },\r\n disabledOpacity: {\r\n opacity: 0.3,\r\n cursor: 'default',\r\n },\r\n buttonRemoveWrapper: {\r\n position: 'absolute',\r\n zIndex: 222,\r\n right: 0,\r\n },\r\n buttonCropWrapper: {\r\n position: 'absolute',\r\n zIndex: 222,\r\n right: 0,\r\n top: 50,\r\n },\r\n error: {\r\n border: '2px solid red',\r\n boxSizing: 'border-box',\r\n },\r\n};\r\n\r\ninterface UploadImageProps {\r\n maxSize?: number;\r\n disabled?: boolean;\r\n crop?: boolean;\r\n error?: boolean;\r\n onChange: (base64: string) => void | undefined;\r\n icon: string | null;\r\n removeIconFunc: () => void | null;\r\n accept?: Record<string, string[]>;\r\n}\r\n\r\ninterface UploadImageState {\r\n uploadFile: boolean | 'dragging';\r\n anchorEl: HTMLElement | null;\r\n cropHandler: boolean;\r\n}\r\n\r\nexport class UploadImage extends Component<UploadImageProps, UploadImageState> {\r\n private readonly cropperRef: React.RefObject<ReactCropperElement>;\r\n\r\n constructor(props: UploadImageProps) {\r\n super(props);\r\n\r\n this.state = {\r\n uploadFile: false,\r\n anchorEl: null,\r\n cropHandler: false,\r\n };\r\n this.cropperRef = createRef();\r\n\r\n if (!window.document.getElementById('cropper-style-json-component')) {\r\n const style = window.document.createElement('style');\r\n style.setAttribute('id', 'cropper-style-json-component');\r\n style.innerHTML = cropperStyles;\r\n window.document.head.appendChild(style);\r\n }\r\n }\r\n\r\n onDrop(acceptedFiles: File[]): void {\r\n const onChange = this.props.onChange;\r\n const maxSize = this.props.maxSize || 10 * 1024;\r\n\r\n const file = acceptedFiles[0];\r\n const reader = new FileReader();\r\n\r\n reader.onabort = () => console.log('file reading was aborted');\r\n reader.onerror = () => console.log('file reading has failed');\r\n reader.onload = () => {\r\n if (!file || !file.name) {\r\n return;\r\n }\r\n const parts = file.name?.split('.');\r\n let ext = parts?.length ? `image/${parts.pop()?.toLowerCase()}` : 'image/jpeg';\r\n if (ext === 'image/jpg') {\r\n ext = 'image/jpeg';\r\n } else if (ext.includes('svg')) {\r\n ext = 'image/svg+xml';\r\n }\r\n if (file.size > maxSize) {\r\n window.alert(I18n.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));\r\n } else {\r\n const base64 = `data:${ext};base64,${btoa(\r\n new Uint8Array(reader.result as ArrayBufferLike).reduce(\r\n (data, byte) => data + String.fromCharCode(byte),\r\n '',\r\n ),\r\n )}`;\r\n\r\n if (onChange) {\r\n onChange(base64);\r\n } else {\r\n console.log(base64);\r\n }\r\n }\r\n };\r\n reader.readAsArrayBuffer(file);\r\n }\r\n\r\n render(): JSX.Element {\r\n const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;\r\n const maxSize = this.props.maxSize || 10 * 1024;\r\n let accept = this.props.accept || { 'image/*': [] };\r\n const { uploadFile, anchorEl, cropHandler } = this.state;\r\n\r\n // covert '\"image/png\"' to { 'image/*': [] }\r\n if (typeof accept === 'string') {\r\n accept = { [accept]: [] };\r\n } else if (Array.isArray(accept)) {\r\n const result: Record<string, string[]> = {};\r\n accept.forEach(item => {\r\n result[item] = [];\r\n });\r\n accept = result;\r\n }\r\n\r\n return (\r\n <Dropzone\r\n disabled={!!disabled || cropHandler}\r\n key=\"dropzone\"\r\n multiple={false}\r\n accept={accept}\r\n maxSize={maxSize}\r\n onDragEnter={() => this.setState({ uploadFile: 'dragging' })}\r\n onDragLeave={() => this.setState({ uploadFile: true })}\r\n onDrop={(acceptedFiles: File[], errors: FileRejection[]) => {\r\n this.setState({ uploadFile: false });\r\n if (!acceptedFiles.length) {\r\n window.alert(errors?.[0]?.errors?.[0]?.message || I18n.t('ra_Cannot upload'));\r\n } else {\r\n this.onDrop(acceptedFiles);\r\n }\r\n }}\r\n >\r\n {({ getRootProps, getInputProps }) => (\r\n <div\r\n style={{\r\n ...styles.uploadDiv,\r\n ...(uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),\r\n ...styles.dropZone,\r\n ...(disabled ? styles.disabledOpacity : undefined),\r\n ...(!icon ? styles.dropZoneEmpty : undefined),\r\n }}\r\n {...getRootProps()}\r\n >\r\n <input {...getInputProps()} />\r\n <div style={{ ...styles.uploadCenterDiv, ...(error ? styles.error : undefined) }}>\r\n {!icon ? (\r\n <div style={styles.uploadCenterTextAndIcon}>\r\n <UploadIcon style={styles.uploadCenterIcon} />\r\n <div style={styles.uploadCenterText}>\r\n {uploadFile === 'dragging'\r\n ? I18n.t('ra_Drop file here')\r\n : I18n.t(\r\n 'ra_Place your files here or click here to open the browse dialog',\r\n )}\r\n </div>\r\n </div>\r\n ) : (\r\n removeIconFunc &&\r\n !cropHandler && (\r\n <div style={styles.buttonRemoveWrapper}>\r\n <Tooltip\r\n title={I18n.t('ra_Clear')}\r\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\r\n >\r\n <IconButton\r\n size=\"large\"\r\n onClick={e => {\r\n removeIconFunc && removeIconFunc();\r\n e.stopPropagation();\r\n }}\r\n >\r\n <IconClose />\r\n </IconButton>\r\n </Tooltip>\r\n </div>\r\n )\r\n )}\r\n {icon && crop && (\r\n <div style={styles.buttonCropWrapper}>\r\n <Tooltip\r\n title={I18n.t('ra_Crop')}\r\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\r\n >\r\n <IconButton\r\n size=\"large\"\r\n onClick={e => {\r\n if (!cropHandler) {\r\n this.setState({ cropHandler: true });\r\n } else {\r\n this.setState({ anchorEl: e.currentTarget });\r\n }\r\n e.stopPropagation();\r\n }}\r\n >\r\n <CropIcon color={cropHandler ? 'primary' : 'inherit'} />\r\n </IconButton>\r\n </Tooltip>\r\n <Menu\r\n anchorEl={anchorEl}\r\n keepMounted\r\n open={Boolean(anchorEl)}\r\n onClose={() => this.setState({ anchorEl: null })}\r\n >\r\n <MenuItem\r\n onClick={() =>\r\n this.setState({ anchorEl: null, cropHandler: false }, () => {\r\n const imageElement = this.cropperRef?.current?.cropper;\r\n if (imageElement) {\r\n if (onChange) {\r\n onChange(imageElement.getCroppedCanvas().toDataURL());\r\n } else {\r\n console.log(imageElement.getCroppedCanvas().toDataURL());\r\n }\r\n }\r\n })\r\n }\r\n >\r\n {I18n.t('ra_Save')}\r\n </MenuItem>\r\n <MenuItem onClick={() => this.setState({ anchorEl: null, cropHandler: false })}>\r\n {I18n.t('ra_Close')}\r\n </MenuItem>\r\n </Menu>\r\n </div>\r\n )}\r\n {icon && !cropHandler ? (\r\n <Icon\r\n src={icon}\r\n style={styles.image}\r\n alt=\"icon\"\r\n />\r\n ) : null}\r\n\r\n {icon && crop && cropHandler ? (\r\n <Cropper\r\n ref={this.cropperRef}\r\n style={styles.image}\r\n src={icon}\r\n initialAspectRatio={1}\r\n viewMode={1}\r\n guides={false}\r\n minCropBoxHeight={10}\r\n minCropBoxWidth={10}\r\n background={false}\r\n checkOrientation={false}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n )}\r\n </Dropzone>\r\n );\r\n }\r\n}\r\n"]}
|