@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.
- package/README.md +6 -6
- package/build/AdminConnection.d.ts +1 -0
- package/build/AdminConnection.js +2 -0
- package/build/AdminConnection.js.map +1 -0
- package/{src/Components/404.tsx → build/Components/404.js} +14 -39
- package/build/Components/404.js.map +1 -0
- package/{Components → build/Components}/ColorPicker.d.ts +2 -2
- package/{Components → build/Components}/ColorPicker.js +50 -65
- package/build/Components/ColorPicker.js.map +1 -0
- package/{Components → build/Components}/ComplexCron.d.ts +2 -2
- package/{Components → build/Components}/ComplexCron.js +43 -71
- package/build/Components/ComplexCron.js.map +1 -0
- package/{Components → build/Components}/CopyToClipboard.d.ts +1 -2
- package/{src/Components/CopyToClipboard.tsx → build/Components/CopyToClipboard.js} +20 -38
- package/build/Components/CopyToClipboard.js.map +1 -0
- package/{Components → build/Components}/CustomModal.d.ts +3 -3
- package/build/Components/CustomModal.js +60 -0
- package/build/Components/CustomModal.js.map +1 -0
- package/{Components → build/Components}/FileBrowser.d.ts +2 -2
- package/{Components → build/Components}/FileBrowser.js +229 -236
- package/build/Components/FileBrowser.js.map +1 -0
- package/build/Components/FileViewer.d.ts +48 -0
- package/build/Components/FileViewer.js +277 -0
- package/build/Components/FileViewer.js.map +1 -0
- package/{Components → build/Components}/Icon.d.ts +1 -1
- package/build/Components/Icon.js +140 -0
- package/build/Components/Icon.js.map +1 -0
- package/{Components → build/Components}/IconPicker.d.ts +2 -2
- package/build/Components/IconPicker.js +73 -0
- package/build/Components/IconPicker.js.map +1 -0
- package/{Components → build/Components}/IconSelector.d.ts +3 -3
- package/{Components → build/Components}/IconSelector.js +29 -57
- package/build/Components/IconSelector.js.map +1 -0
- package/{Components → build/Components}/Image.d.ts +2 -2
- package/{Components → build/Components}/Image.js +16 -22
- package/build/Components/Image.js.map +1 -0
- package/{Components → build/Components}/Loader.d.ts +2 -2
- package/{Components → build/Components}/Loader.js +15 -40
- package/build/Components/Loader.js.map +1 -0
- package/{Components → build/Components}/Loaders/MV.d.ts +2 -2
- package/build/Components/Loaders/MV.js +61 -0
- package/build/Components/Loaders/MV.js.map +1 -0
- package/{Components → build/Components}/Loaders/PT.d.ts +2 -2
- package/{Components → build/Components}/Loaders/PT.js +10 -35
- package/build/Components/Loaders/PT.js.map +1 -0
- package/{Components → build/Components}/Loaders/Vendor.d.ts +2 -2
- package/build/Components/Loaders/Vendor.js +52 -0
- package/build/Components/Loaders/Vendor.js.map +1 -0
- package/{Components → build/Components}/Logo.d.ts +2 -2
- package/build/Components/Logo.js +108 -0
- package/build/Components/Logo.js.map +1 -0
- package/{Components → build/Components}/MDUtils.d.ts +1 -2
- package/{Components → build/Components}/MDUtils.js +4 -9
- package/build/Components/MDUtils.js.map +1 -0
- package/{Components → build/Components}/ObjectBrowser.d.ts +4 -4
- package/{Components → build/Components}/ObjectBrowser.js +1152 -1116
- package/build/Components/ObjectBrowser.js.map +1 -0
- package/{Components → build/Components}/Router.d.ts +1 -2
- package/{Components → build/Components}/Router.js +6 -7
- package/build/Components/Router.js.map +1 -0
- package/{Components → build/Components}/SaveCloseButtons.d.ts +2 -2
- package/build/Components/SaveCloseButtons.js +65 -0
- package/build/Components/SaveCloseButtons.js.map +1 -0
- package/{Components → build/Components}/Schedule.d.ts +2 -2
- package/{Components → build/Components}/Schedule.js +242 -257
- package/build/Components/Schedule.js.map +1 -0
- package/{Components → build/Components}/SelectWithIcon.d.ts +2 -2
- package/build/Components/SelectWithIcon.js +135 -0
- package/build/Components/SelectWithIcon.js.map +1 -0
- package/build/Components/SimpleCron/cronText.js +15 -0
- package/build/Components/SimpleCron/cronText.js.map +1 -0
- package/{Components → build/Components}/SimpleCron/index.d.ts +2 -2
- package/{Components → build/Components}/SimpleCron/index.js +55 -58
- package/build/Components/SimpleCron/index.js.map +1 -0
- package/{Components → build/Components}/TabContainer.d.ts +2 -2
- package/build/Components/TabContainer.js +23 -0
- package/build/Components/TabContainer.js.map +1 -0
- package/{Components → build/Components}/TabContent.d.ts +3 -2
- 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/{Components → build/Components}/TableResize.d.ts +2 -2
- package/{src/Components/TableResize.tsx → build/Components/TableResize.js} +64 -134
- package/build/Components/TableResize.js.map +1 -0
- package/{Components → build/Components}/TextWithIcon.d.ts +2 -2
- package/{src/Components/TextWithIcon.tsx → build/Components/TextWithIcon.js} +30 -75
- package/build/Components/TextWithIcon.js.map +1 -0
- package/{Components → build/Components}/ToggleThemeMenu.d.ts +1 -1
- package/build/Components/ToggleThemeMenu.js +13 -0
- package/build/Components/ToggleThemeMenu.js.map +1 -0
- package/{Components → build/Components}/TreeTable.d.ts +3 -3
- package/{Components → build/Components}/TreeTable.js +87 -99
- package/build/Components/TreeTable.js.map +1 -0
- package/{Components → build/Components}/UploadImage.d.ts +2 -2
- package/{Components → build/Components}/UploadImage.js +46 -69
- package/build/Components/UploadImage.js.map +1 -0
- package/{Components → build/Components}/Utils.d.ts +2 -2
- package/{Components → build/Components}/Utils.js +47 -60
- 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/{Dialogs → build/Dialogs}/ComplexCron.d.ts +2 -2
- package/build/Dialogs/ComplexCron.js +85 -0
- package/build/Dialogs/ComplexCron.js.map +1 -0
- package/{Dialogs → build/Dialogs}/Confirm.d.ts +2 -2
- package/build/Dialogs/Confirm.js +83 -0
- package/build/Dialogs/Confirm.js.map +1 -0
- package/{Dialogs → build/Dialogs}/Cron.d.ts +2 -2
- package/build/Dialogs/Cron.js +72 -0
- package/build/Dialogs/Cron.js.map +1 -0
- package/{Dialogs → build/Dialogs}/Error.d.ts +2 -2
- package/build/Dialogs/Error.js +27 -0
- package/build/Dialogs/Error.js.map +1 -0
- package/{Dialogs → build/Dialogs}/Message.d.ts +2 -2
- package/build/Dialogs/Message.js +29 -0
- package/build/Dialogs/Message.js.map +1 -0
- package/{Dialogs → build/Dialogs}/SelectFile.d.ts +2 -2
- package/build/Dialogs/SelectFile.js +116 -0
- package/build/Dialogs/SelectFile.js.map +1 -0
- package/{Dialogs → build/Dialogs}/SelectID.d.ts +3 -3
- package/{Dialogs → build/Dialogs}/SelectID.js +28 -53
- package/build/Dialogs/SelectID.js.map +1 -0
- package/{Dialogs → build/Dialogs}/SimpleCron.d.ts +2 -2
- 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/{GenericApp.d.ts → build/GenericApp.d.ts} +2 -3
- package/{GenericApp.js → build/GenericApp.js} +162 -176
- package/build/GenericApp.js.map +1 -0
- package/{LegacyConnection.d.ts → build/LegacyConnection.d.ts} +69 -4
- package/{LegacyConnection.js → build/LegacyConnection.js} +106 -99
- package/build/LegacyConnection.js.map +1 -0
- package/{Prompt.d.ts → build/Prompt.d.ts} +1 -1
- package/{Prompt.js → build/Prompt.js} +3 -4
- package/build/Prompt.js.map +1 -0
- package/build/Theme.d.ts +5 -0
- package/{Theme.js → build/Theme.js} +37 -32
- 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/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/dictionary.d.ts +1 -0
- package/build/dictionary.js +25 -0
- package/build/dictionary.js.map +1 -0
- package/build/i18n/de.json +449 -0
- package/build/i18n/en.json +449 -0
- package/build/i18n/es.json +449 -0
- package/build/i18n/fr.json +449 -0
- package/build/i18n/it.json +449 -0
- package/build/i18n/nl.json +449 -0
- package/build/i18n/pl.json +449 -0
- package/build/i18n/pt.json +449 -0
- package/build/i18n/ru.json +449 -0
- package/build/i18n/uk.json +449 -0
- package/build/i18n/zh-cn.json +449 -0
- package/{i18n.d.ts → build/i18n.d.ts} +2 -2
- package/{i18n.js → build/i18n.js} +9 -11
- package/build/i18n.js.map +1 -0
- package/build/icons/IconAdapter.d.ts +3 -0
- package/build/icons/IconAdapter.js +6 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +6 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +9 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +7 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +6 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +5 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +15 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +6 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +7 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +6 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +5 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +6 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +6 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +5 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +6 -0
- package/build/icons/IconOpen.js.map +1 -0
- package/{icons → build/icons}/IconProps.d.ts +1 -1
- package/build/icons/IconProps.js +2 -0
- package/build/icons/IconProps.js.map +1 -0
- package/build/icons/IconState.d.ts +3 -0
- package/build/icons/IconState.js +6 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/index.d.ts +67 -0
- package/build/index.js +67 -0
- package/build/index.js.map +1 -0
- package/{types.d.ts → build/types.d.ts} +1 -1
- package/package.json +84 -48
- package/AdminConnection.d.ts +0 -2
- package/AdminConnection.js +0 -4
- package/Components/404.js +0 -101
- package/Components/CopyToClipboard.js +0 -163
- package/Components/CustomModal.js +0 -88
- package/Components/FileViewer.d.ts +0 -10
- package/Components/FileViewer.js +0 -305
- package/Components/Icon.js +0 -148
- package/Components/IconPicker.js +0 -98
- package/Components/Loaders/MV.js +0 -66
- package/Components/Loaders/Vendor.js +0 -77
- package/Components/Logo.js +0 -117
- package/Components/SaveCloseButtons.js +0 -69
- package/Components/SelectWithIcon.js +0 -168
- package/Components/SimpleCron/cronText.js +0 -19
- package/Components/TabContainer.js +0 -25
- package/Components/TabContent.js +0 -21
- package/Components/TabHeader.d.ts +0 -6
- package/Components/TabHeader.js +0 -11
- package/Components/TableResize.js +0 -226
- package/Components/TextWithIcon.js +0 -119
- package/Components/ToggleThemeMenu.js +0 -18
- package/Components/withWidth.d.ts +0 -3
- package/Components/withWidth.js +0 -27
- package/Connection.d.ts +0 -3
- package/Connection.js +0 -8
- package/Dialogs/ComplexCron.js +0 -90
- package/Dialogs/Confirm.js +0 -111
- package/Dialogs/Cron.js +0 -100
- package/Dialogs/Error.js +0 -55
- package/Dialogs/Message.js +0 -57
- package/Dialogs/SelectFile.js +0 -119
- package/Dialogs/SimpleCron.js +0 -51
- package/Dialogs/TextInput.d.ts +0 -3
- package/Dialogs/TextInput.js +0 -35
- package/Theme.d.ts +0 -6
- package/i18n/de.json +0 -449
- package/i18n/en.json +0 -449
- package/i18n/es.json +0 -449
- package/i18n/fr.json +0 -449
- package/i18n/it.json +0 -449
- package/i18n/nl.json +0 -449
- package/i18n/pl.json +0 -449
- package/i18n/pt.json +0 -449
- package/i18n/ru.json +0 -449
- package/i18n/uk.json +0 -449
- package/i18n/zh-cn.json +0 -449
- package/icons/IconAdapter.d.ts +0 -4
- package/icons/IconAdapter.js +0 -10
- package/icons/IconAlias.d.ts +0 -4
- package/icons/IconAlias.js +0 -10
- package/icons/IconChannel.d.ts +0 -4
- package/icons/IconChannel.js +0 -13
- package/icons/IconClearFilter.d.ts +0 -4
- package/icons/IconClearFilter.js +0 -11
- package/icons/IconClosed.d.ts +0 -4
- package/icons/IconClosed.js +0 -10
- package/icons/IconCopy.d.ts +0 -4
- package/icons/IconCopy.js +0 -9
- package/icons/IconDevice.d.ts +0 -4
- package/icons/IconDevice.js +0 -19
- package/icons/IconDocument.d.ts +0 -4
- package/icons/IconDocument.js +0 -10
- package/icons/IconDocumentReadOnly.d.ts +0 -4
- package/icons/IconDocumentReadOnly.js +0 -11
- package/icons/IconExpert.d.ts +0 -4
- package/icons/IconExpert.js +0 -10
- package/icons/IconFx.d.ts +0 -4
- package/icons/IconFx.js +0 -9
- package/icons/IconInstance.d.ts +0 -4
- package/icons/IconInstance.js +0 -10
- package/icons/IconLogout.d.ts +0 -4
- package/icons/IconLogout.js +0 -10
- package/icons/IconNoIcon.d.ts +0 -4
- package/icons/IconNoIcon.js +0 -9
- package/icons/IconOpen.d.ts +0 -4
- package/icons/IconOpen.js +0 -10
- package/icons/IconProps.js +0 -2
- package/icons/IconState.d.ts +0 -4
- package/icons/IconState.js +0 -10
- package/index.d.ts +0 -128
- package/index.js +0 -215
- package/src/AdminConnection.tsx +0 -3
- package/src/Components/ColorPicker.tsx +0 -343
- package/src/Components/ComplexCron.tsx +0 -561
- package/src/Components/CustomModal.tsx +0 -170
- package/src/Components/FileBrowser.tsx +0 -2560
- package/src/Components/FileViewer.tsx +0 -412
- package/src/Components/Icon.tsx +0 -238
- package/src/Components/IconPicker.tsx +0 -165
- package/src/Components/IconSelector.tsx +0 -2220
- package/src/Components/Image.tsx +0 -193
- package/src/Components/Loader.tsx +0 -328
- package/src/Components/Logo.tsx +0 -176
- package/src/Components/MDUtils.tsx +0 -104
- package/src/Components/ObjectBrowser.tsx +0 -8947
- package/src/Components/Router.tsx +0 -90
- package/src/Components/SaveCloseButtons.tsx +0 -117
- package/src/Components/Schedule.tsx +0 -1998
- package/src/Components/SelectWithIcon.tsx +0 -239
- package/src/Components/TabContainer.tsx +0 -57
- package/src/Components/TabContent.tsx +0 -38
- package/src/Components/TabHeader.tsx +0 -20
- package/src/Components/ToggleThemeMenu.tsx +0 -52
- package/src/Components/TreeTable.tsx +0 -1002
- package/src/Components/UploadImage.tsx +0 -643
- package/src/Components/Utils.tsx +0 -1802
- package/src/Components/loader.css +0 -231
- package/src/Components/withWidth.tsx +0 -32
- package/src/Connection.tsx +0 -5
- package/src/Dialogs/ComplexCron.tsx +0 -163
- package/src/Dialogs/Confirm.tsx +0 -185
- package/src/Dialogs/Cron.tsx +0 -192
- package/src/Dialogs/Error.tsx +0 -67
- package/src/Dialogs/Message.tsx +0 -73
- package/src/Dialogs/SelectFile.tsx +0 -280
- package/src/Dialogs/SelectID.tsx +0 -310
- package/src/Dialogs/SimpleCron.tsx +0 -101
- package/src/Dialogs/TextInput.tsx +0 -99
- package/src/GenericApp.tsx +0 -1076
- package/src/LegacyConnection.tsx +0 -3720
- package/src/Prompt.tsx +0 -22
- package/src/Theme.tsx +0 -472
- package/src/icons/IconAdapter.tsx +0 -22
- package/src/icons/IconAlias.tsx +0 -22
- package/src/icons/IconChannel.tsx +0 -60
- package/src/icons/IconClearFilter.tsx +0 -24
- package/src/icons/IconClosed.tsx +0 -22
- package/src/icons/IconCopy.tsx +0 -21
- package/src/icons/IconDevice.tsx +0 -126
- package/src/icons/IconDocument.tsx +0 -22
- package/src/icons/IconDocumentReadOnly.tsx +0 -27
- package/src/icons/IconExpert.tsx +0 -26
- package/src/icons/IconFx.tsx +0 -38
- package/src/icons/IconInstance.tsx +0 -22
- package/src/icons/IconLogout.tsx +0 -32
- package/src/icons/IconNoIcon.tsx +0 -21
- package/src/icons/IconOpen.tsx +0 -22
- package/src/icons/IconProps.tsx +0 -16
- package/src/icons/IconState.tsx +0 -38
- package/src/index.css +0 -56
- /package/{Components → build/Components}/404.d.ts +0 -0
- /package/{Components → build/Components}/SimpleCron/cronText.d.ts +0 -0
- /package/{assets → build/assets}/devices.json +0 -0
- /package/{assets → build/assets}/lamp_ceiling.svg +0 -0
- /package/{assets → build/assets}/lamp_table.svg +0 -0
- /package/{assets → build/assets}/no_icon.svg +0 -0
- /package/{assets → build/assets}/rooms.json +0 -0
- /package/{index.css → build/index.css} +0 -0
- /package/{tasks.js → tasksExample.js} +0 -0
|
@@ -1,39 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const react_1 = __importStar(require("react"));
|
|
30
|
-
const react_dropzone_1 = __importDefault(require("react-dropzone"));
|
|
31
|
-
const react_cropper_1 = require("react-cropper");
|
|
32
|
-
const material_1 = require("@mui/material");
|
|
33
|
-
const icons_material_1 = require("@mui/icons-material");
|
|
34
|
-
const fa_1 = require("react-icons/fa");
|
|
35
|
-
const i18n_1 = __importDefault(require("../i18n"));
|
|
36
|
-
const Icon_1 = __importDefault(require("./Icon"));
|
|
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 } from '@mui/icons-material';
|
|
6
|
+
import { FaFileUpload as UploadIcon } from 'react-icons/fa';
|
|
7
|
+
import { I18n } from '../i18n';
|
|
8
|
+
import { Icon } from './Icon';
|
|
37
9
|
// import 'cropperjs/dist/cropper.css';
|
|
38
10
|
const cropperStyles = `
|
|
39
11
|
/*!
|
|
@@ -417,7 +389,8 @@ const styles = {
|
|
|
417
389
|
boxSizing: 'border-box',
|
|
418
390
|
},
|
|
419
391
|
};
|
|
420
|
-
class UploadImage extends
|
|
392
|
+
export class UploadImage extends Component {
|
|
393
|
+
cropperRef;
|
|
421
394
|
constructor(props) {
|
|
422
395
|
super(props);
|
|
423
396
|
this.state = {
|
|
@@ -425,7 +398,7 @@ class UploadImage extends react_1.Component {
|
|
|
425
398
|
anchorEl: null,
|
|
426
399
|
cropHandler: false,
|
|
427
400
|
};
|
|
428
|
-
this.cropperRef =
|
|
401
|
+
this.cropperRef = createRef();
|
|
429
402
|
if (!window.document.getElementById('cropper-style-json-component')) {
|
|
430
403
|
const style = window.document.createElement('style');
|
|
431
404
|
style.setAttribute('id', 'cropper-style-json-component');
|
|
@@ -441,12 +414,11 @@ class UploadImage extends react_1.Component {
|
|
|
441
414
|
reader.onabort = () => console.log('file reading was aborted');
|
|
442
415
|
reader.onerror = () => console.log('file reading has failed');
|
|
443
416
|
reader.onload = () => {
|
|
444
|
-
var _a, _b;
|
|
445
417
|
if (!file || !file.name) {
|
|
446
418
|
return;
|
|
447
419
|
}
|
|
448
|
-
const parts =
|
|
449
|
-
let ext =
|
|
420
|
+
const parts = file.name?.split('.');
|
|
421
|
+
let ext = parts?.length ? `image/${parts.pop()?.toLowerCase()}` : 'image/jpeg';
|
|
450
422
|
if (ext === 'image/jpg') {
|
|
451
423
|
ext = 'image/jpeg';
|
|
452
424
|
}
|
|
@@ -454,7 +426,7 @@ class UploadImage extends react_1.Component {
|
|
|
454
426
|
ext = 'image/svg+xml';
|
|
455
427
|
}
|
|
456
428
|
if (file.size > maxSize) {
|
|
457
|
-
window.alert(
|
|
429
|
+
window.alert(I18n.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));
|
|
458
430
|
}
|
|
459
431
|
else {
|
|
460
432
|
const base64 = `data:${ext};base64,${btoa(new Uint8Array(reader.result).reduce((data, byte) => data + String.fromCharCode(byte), ''))}`;
|
|
@@ -484,7 +456,7 @@ class UploadImage extends react_1.Component {
|
|
|
484
456
|
});
|
|
485
457
|
accept = result;
|
|
486
458
|
}
|
|
487
|
-
return (
|
|
459
|
+
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) => {
|
|
488
460
|
this.setState({ uploadFile: false });
|
|
489
461
|
if (!acceptedFiles.length) {
|
|
490
462
|
window.alert((errors &&
|
|
@@ -492,29 +464,35 @@ class UploadImage extends react_1.Component {
|
|
|
492
464
|
errors[0].errors &&
|
|
493
465
|
errors[0].errors[0] &&
|
|
494
466
|
errors[0].errors[0].message) ||
|
|
495
|
-
|
|
467
|
+
I18n.t('ra_Cannot upload'));
|
|
496
468
|
}
|
|
497
469
|
else {
|
|
498
470
|
this.onDrop(acceptedFiles);
|
|
499
471
|
}
|
|
500
|
-
} }, ({ getRootProps, getInputProps }) => (
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
472
|
+
} }, ({ getRootProps, getInputProps }) => (React.createElement("div", { style: {
|
|
473
|
+
...styles.uploadDiv,
|
|
474
|
+
...(uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),
|
|
475
|
+
...styles.dropZone,
|
|
476
|
+
...(disabled ? styles.disabledOpacity : undefined),
|
|
477
|
+
...(!icon ? styles.dropZoneEmpty : undefined),
|
|
478
|
+
}, ...getRootProps() },
|
|
479
|
+
React.createElement("input", { ...getInputProps() }),
|
|
480
|
+
React.createElement("div", { style: { ...styles.uploadCenterDiv, ...(error ? styles.error : undefined) } },
|
|
481
|
+
!icon ? (React.createElement("div", { style: styles.uploadCenterTextAndIcon },
|
|
482
|
+
React.createElement(UploadIcon, { style: styles.uploadCenterIcon }),
|
|
483
|
+
React.createElement("div", { style: styles.uploadCenterText }, uploadFile === 'dragging'
|
|
484
|
+
? I18n.t('ra_Drop file here')
|
|
485
|
+
: I18n.t('ra_Place your files here or click here to open the browse dialog')))) : (removeIconFunc &&
|
|
486
|
+
!cropHandler && (React.createElement("div", { style: styles.buttonRemoveWrapper },
|
|
487
|
+
React.createElement(Tooltip, { title: I18n.t('ra_Clear'), slotProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
488
|
+
React.createElement(IconButton, { size: "large", onClick: e => {
|
|
511
489
|
removeIconFunc && removeIconFunc();
|
|
512
490
|
e.stopPropagation();
|
|
513
491
|
} },
|
|
514
|
-
|
|
515
|
-
icon && crop && (
|
|
516
|
-
|
|
517
|
-
|
|
492
|
+
React.createElement(IconClose, null)))))),
|
|
493
|
+
icon && crop && (React.createElement("div", { style: styles.buttonCropWrapper },
|
|
494
|
+
React.createElement(Tooltip, { title: I18n.t('ra_Crop'), slotProps: { popper: { sx: { pointerEvents: 'none' } } } },
|
|
495
|
+
React.createElement(IconButton, { size: "large", onClick: e => {
|
|
518
496
|
if (!cropHandler) {
|
|
519
497
|
this.setState({ cropHandler: true });
|
|
520
498
|
}
|
|
@@ -523,11 +501,10 @@ class UploadImage extends react_1.Component {
|
|
|
523
501
|
}
|
|
524
502
|
e.stopPropagation();
|
|
525
503
|
} },
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const imageElement = (_b = (_a = this.cropperRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.cropper;
|
|
504
|
+
React.createElement(CropIcon, { color: cropHandler ? 'primary' : 'inherit' }))),
|
|
505
|
+
React.createElement(Menu, { anchorEl: anchorEl, keepMounted: true, open: Boolean(anchorEl), onClose: () => this.setState({ anchorEl: null }) },
|
|
506
|
+
React.createElement(MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }, () => {
|
|
507
|
+
const imageElement = this.cropperRef?.current?.cropper;
|
|
531
508
|
if (imageElement) {
|
|
532
509
|
if (onChange) {
|
|
533
510
|
onChange(imageElement.getCroppedCanvas().toDataURL());
|
|
@@ -536,10 +513,10 @@ class UploadImage extends react_1.Component {
|
|
|
536
513
|
console.log(imageElement.getCroppedCanvas().toDataURL());
|
|
537
514
|
}
|
|
538
515
|
}
|
|
539
|
-
}) },
|
|
540
|
-
|
|
541
|
-
icon && !cropHandler ? (
|
|
542
|
-
icon && crop && cropHandler ? (
|
|
516
|
+
}) }, I18n.t('ra_Save')),
|
|
517
|
+
React.createElement(MenuItem, { onClick: () => this.setState({ anchorEl: null, cropHandler: false }) }, I18n.t('ra_Close'))))),
|
|
518
|
+
icon && !cropHandler ? (React.createElement(Icon, { src: icon, style: styles.image, alt: "icon" })) : null,
|
|
519
|
+
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)))));
|
|
543
520
|
}
|
|
544
521
|
}
|
|
545
|
-
|
|
522
|
+
//# 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,QAAQ,MAAM,gBAAgB,CAAC;AACtC,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,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,YAAY,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5D,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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Y,EAAE,CAAC;oCACf,IAAI,QAAQ,EAAE,CAAC;wCACX,QAAQ,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;oCAC1D,CAAC;yCAAM,CAAC;wCACJ,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,gBAAgB,EAAE,CAAC,SAAS,EAAE,CAAC,CAAC;oCAC7D,CAAC;gCACL,CAAC;4BACL,CAAC,CAAC,IAGL,IAAI,CAAC,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';\nimport Dropzone from 'react-dropzone';\nimport { Cropper, type ReactCropperElement } from 'react-cropper';\n\nimport { Menu, MenuItem, Tooltip, IconButton } from '@mui/material';\n\nimport { Close as IconClose, Crop as CropIcon } from '@mui/icons-material';\nimport { FaFileUpload as UploadIcon } from 'react-icons/fa';\n\nimport { I18n } from '../i18n';\nimport { Icon } from './Icon';\n\n// import 'cropperjs/dist/cropper.css';\nconst cropperStyles = `\n/*!\n * Cropper.js v1.5.12\n * https://fengyuanchen.github.io/cropperjs\n *\n * Copyright 2015-present Chen Fengyuan\n * Released under the MIT license\n *\n * Date: 2021-06-12T08:00:11.623Z\n */\n\n.cropper-container {\n direction: ltr;\n font-size: 0;\n line-height: 0;\n position: relative;\n -ms-touch-action: none;\n touch-action: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.cropper-container img {\n display: block;\n height: 100%;\n image-orientation: 0deg;\n max-height: none !important;\n max-width: none !important;\n min-height: 0 !important;\n min-width: 0 !important;\n width: 100%;\n}\n\n.cropper-wrap-box,\n.cropper-canvas,\n.cropper-drag-box,\n.cropper-crop-box,\n.cropper-modal {\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.cropper-wrap-box,\n.cropper-canvas {\n overflow: hidden;\n}\n\n.cropper-drag-box {\n background-color: #fff;\n opacity: 0;\n}\n\n.cropper-modal {\n background-color: #000;\n opacity: 0.5;\n}\n\n.cropper-view-box {\n display: block;\n height: 100%;\n outline: 1px solid #39f;\n outline-color: rgba(51, 153, 255, 0.75);\n overflow: hidden;\n width: 100%;\n}\n\n.cropper-dashed {\n border: 0 dashed #eee;\n display: block;\n opacity: 0.5;\n position: absolute;\n}\n\n.cropper-dashed.dashed-h {\n border-bottom-width: 1px;\n border-top-width: 1px;\n height: calc(100% / 3);\n left: 0;\n top: calc(100% / 3);\n width: 100%;\n}\n\n.cropper-dashed.dashed-v {\n border-left-width: 1px;\n border-right-width: 1px;\n height: 100%;\n left: calc(100% / 3);\n top: 0;\n width: calc(100% / 3);\n}\n\n.cropper-center {\n display: block;\n height: 0;\n left: 50%;\n opacity: 0.75;\n position: absolute;\n top: 50%;\n width: 0;\n}\n\n.cropper-center::before,\n.cropper-center::after {\n background-color: #eee;\n content: ' ';\n display: block;\n position: absolute;\n}\n\n.cropper-center::before {\n height: 1px;\n left: -3px;\n top: 0;\n width: 7px;\n}\n\n.cropper-center::after {\n height: 7px;\n left: 0;\n top: -3px;\n width: 1px;\n}\n\n.cropper-face,\n.cropper-line,\n.cropper-point {\n display: block;\n height: 100%;\n opacity: 0.1;\n position: absolute;\n width: 100%;\n}\n\n.cropper-face {\n background-color: #fff;\n left: 0;\n top: 0;\n}\n\n.cropper-line {\n background-color: #39f;\n}\n\n.cropper-line.line-e {\n cursor: ew-resize;\n right: -3px;\n top: 0;\n width: 5px;\n}\n\n.cropper-line.line-n {\n cursor: ns-resize;\n height: 5px;\n left: 0;\n top: -3px;\n}\n\n.cropper-line.line-w {\n cursor: ew-resize;\n left: -3px;\n top: 0;\n width: 5px;\n}\n\n.cropper-line.line-s {\n bottom: -3px;\n cursor: ns-resize;\n height: 5px;\n left: 0;\n}\n\n.cropper-point {\n background-color: #39f;\n height: 5px;\n opacity: 0.75;\n width: 5px;\n}\n\n.cropper-point.point-e {\n cursor: ew-resize;\n margin-top: -3px;\n right: -3px;\n top: 50%;\n}\n\n.cropper-point.point-n {\n cursor: ns-resize;\n left: 50%;\n margin-left: -3px;\n top: -3px;\n}\n\n.cropper-point.point-w {\n cursor: ew-resize;\n left: -3px;\n margin-top: -3px;\n top: 50%;\n}\n\n.cropper-point.point-s {\n bottom: -3px;\n cursor: s-resize;\n left: 50%;\n margin-left: -3px;\n}\n\n.cropper-point.point-ne {\n cursor: nesw-resize;\n right: -3px;\n top: -3px;\n}\n\n.cropper-point.point-nw {\n cursor: nwse-resize;\n left: -3px;\n top: -3px;\n}\n\n.cropper-point.point-sw {\n bottom: -3px;\n cursor: nesw-resize;\n left: -3px;\n}\n\n.cropper-point.point-se {\n bottom: -3px;\n cursor: nwse-resize;\n height: 20px;\n opacity: 1;\n right: -3px;\n width: 20px;\n}\n\n@media (min-width: 768px) {\n .cropper-point.point-se {\n height: 15px;\n width: 15px;\n }\n}\n\n@media (min-width: 992px) {\n .cropper-point.point-se {\n height: 10px;\n width: 10px;\n }\n}\n\n@media (min-width: 1200px) {\n .cropper-point.point-se {\n height: 5px;\n opacity: 0.75;\n width: 5px;\n }\n}\n\n.cropper-point.point-se::before {\n background-color: #39f;\n bottom: -50%;\n content: ' ';\n display: block;\n height: 200%;\n opacity: 0;\n position: absolute;\n right: -50%;\n width: 200%;\n}\n\n.cropper-invisible {\n opacity: 0;\n}\n\n.cropper-bg {\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');\n}\n\n.cropper-hide {\n display: block;\n height: 0;\n position: absolute;\n width: 0;\n}\n\n.cropper-hidden {\n display: none !important;\n}\n\n.cropper-move {\n cursor: move;\n}\n\n.cropper-crop {\n cursor: crosshair;\n}\n\n.cropper-disabled .cropper-drag-box,\n.cropper-disabled .cropper-face,\n.cropper-disabled .cropper-line,\n.cropper-disabled .cropper-point {\n cursor: not-allowed;\n}\n`;\n\nconst styles: Record<string, React.CSSProperties> = {\n dropZone: {\n width: '100%',\n height: 100,\n position: 'relative',\n },\n dropZoneEmpty: {},\n image: {\n objectFit: 'contain',\n margin: 'auto',\n display: 'flex',\n width: '100%',\n height: '100%',\n },\n\n uploadDiv: {\n position: 'relative',\n width: '100%',\n height: 300,\n opacity: 0.9,\n marginTop: 30,\n cursor: 'pointer',\n outline: 'none',\n },\n uploadDivDragging: {\n opacity: 1,\n background: 'rgba(128,255,128,0.1)',\n },\n\n uploadCenterDiv: {\n margin: 5,\n border: '3px dashed grey',\n borderRadius: 5,\n width: 'calc(100% - 10px)',\n height: 'calc(100% - 10px)',\n position: 'relative',\n display: 'flex',\n },\n uploadCenterIcon: {\n paddingTop: 10,\n width: 48,\n height: 48,\n },\n uploadCenterText: {\n fontSize: 16,\n },\n uploadCenterTextAndIcon: {\n textAlign: 'center',\n position: 'absolute',\n top: 0,\n bottom: 0,\n left: 0,\n right: 0,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n },\n disabledOpacity: {\n opacity: 0.3,\n cursor: 'default',\n },\n buttonRemoveWrapper: {\n position: 'absolute',\n zIndex: 222,\n right: 0,\n },\n buttonCropWrapper: {\n position: 'absolute',\n zIndex: 222,\n right: 0,\n top: 50,\n },\n error: {\n border: '2px solid red',\n boxSizing: 'border-box',\n },\n};\n\ninterface UploadImageProps {\n maxSize?: number;\n disabled?: boolean;\n crop?: boolean;\n error?: boolean;\n onChange: (base64: string) => void | undefined;\n icon: string | null;\n removeIconFunc: () => void | null;\n accept?: Record<string, string[]>;\n}\n\ninterface UploadImageState {\n uploadFile: boolean | 'dragging';\n anchorEl: HTMLElement | null;\n cropHandler: boolean;\n}\n\nexport class UploadImage extends Component<UploadImageProps, UploadImageState> {\n private readonly cropperRef: React.RefObject<ReactCropperElement>;\n\n constructor(props: UploadImageProps) {\n super(props);\n\n this.state = {\n uploadFile: false,\n anchorEl: null,\n cropHandler: false,\n };\n this.cropperRef = createRef();\n\n if (!window.document.getElementById('cropper-style-json-component')) {\n const style = window.document.createElement('style');\n style.setAttribute('id', 'cropper-style-json-component');\n style.innerHTML = cropperStyles;\n window.document.head.appendChild(style);\n }\n }\n\n onDrop(acceptedFiles: File[]): void {\n const onChange = this.props.onChange;\n const maxSize = this.props.maxSize || 10 * 1024;\n\n const file = acceptedFiles[0];\n const reader = new FileReader();\n\n reader.onabort = () => console.log('file reading was aborted');\n reader.onerror = () => console.log('file reading has failed');\n reader.onload = () => {\n if (!file || !file.name) {\n return;\n }\n const parts = file.name?.split('.');\n let ext = parts?.length ? `image/${parts.pop()?.toLowerCase()}` : 'image/jpeg';\n if (ext === 'image/jpg') {\n ext = 'image/jpeg';\n } else if (ext.includes('svg')) {\n ext = 'image/svg+xml';\n }\n if (file.size > maxSize) {\n window.alert(I18n.t('ra_File is too big. Max %sk allowed. Try use SVG.', Math.round(maxSize / 1024)));\n } else {\n const base64 = `data:${ext};base64,${btoa(\n new Uint8Array(reader.result as ArrayBufferLike).reduce(\n (data, byte) => data + String.fromCharCode(byte),\n '',\n ),\n )}`;\n\n if (onChange) {\n onChange(base64);\n } else {\n console.log(base64);\n }\n }\n };\n reader.readAsArrayBuffer(file);\n }\n\n render(): JSX.Element {\n const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;\n const maxSize = this.props.maxSize || 10 * 1024;\n let accept = this.props.accept || { 'image/*': [] };\n const { uploadFile, anchorEl, cropHandler } = this.state;\n\n // covert '\"image/png\"' to { 'image/*': [] }\n if (typeof accept === 'string') {\n accept = { [accept]: [] };\n } else if (Array.isArray(accept)) {\n const result: Record<string, string[]> = {};\n accept.forEach(item => {\n result[item] = [];\n });\n accept = result;\n }\n\n return (\n <Dropzone\n disabled={!!disabled || cropHandler}\n key=\"dropzone\"\n multiple={false}\n accept={accept}\n maxSize={maxSize}\n onDragEnter={() => this.setState({ uploadFile: 'dragging' })}\n onDragLeave={() => this.setState({ uploadFile: true })}\n onDrop={(acceptedFiles: File[], errors) => {\n this.setState({ uploadFile: false });\n if (!acceptedFiles.length) {\n window.alert(\n (errors &&\n errors[0] &&\n errors[0].errors &&\n errors[0].errors[0] &&\n errors[0].errors[0].message) ||\n I18n.t('ra_Cannot upload'),\n );\n } else {\n this.onDrop(acceptedFiles);\n }\n }}\n >\n {({ getRootProps, getInputProps }) => (\n <div\n style={{\n ...styles.uploadDiv,\n ...(uploadFile === 'dragging' ? styles.uploadDivDragging : undefined),\n ...styles.dropZone,\n ...(disabled ? styles.disabledOpacity : undefined),\n ...(!icon ? styles.dropZoneEmpty : undefined),\n }}\n {...getRootProps()}\n >\n <input {...getInputProps()} />\n <div style={{ ...styles.uploadCenterDiv, ...(error ? styles.error : undefined) }}>\n {!icon ? (\n <div style={styles.uploadCenterTextAndIcon}>\n <UploadIcon style={styles.uploadCenterIcon} />\n <div style={styles.uploadCenterText}>\n {uploadFile === 'dragging'\n ? I18n.t('ra_Drop file here')\n : I18n.t(\n 'ra_Place your files here or click here to open the browse dialog',\n )}\n </div>\n </div>\n ) : (\n removeIconFunc &&\n !cropHandler && (\n <div style={styles.buttonRemoveWrapper}>\n <Tooltip\n title={I18n.t('ra_Clear')}\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\n >\n <IconButton\n size=\"large\"\n onClick={e => {\n removeIconFunc && removeIconFunc();\n e.stopPropagation();\n }}\n >\n <IconClose />\n </IconButton>\n </Tooltip>\n </div>\n )\n )}\n {icon && crop && (\n <div style={styles.buttonCropWrapper}>\n <Tooltip\n title={I18n.t('ra_Crop')}\n slotProps={{ popper: { sx: { pointerEvents: 'none' } } }}\n >\n <IconButton\n size=\"large\"\n onClick={e => {\n if (!cropHandler) {\n this.setState({ cropHandler: true });\n } else {\n this.setState({ anchorEl: e.currentTarget });\n }\n e.stopPropagation();\n }}\n >\n <CropIcon color={cropHandler ? 'primary' : 'inherit'} />\n </IconButton>\n </Tooltip>\n <Menu\n anchorEl={anchorEl}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={() => this.setState({ anchorEl: null })}\n >\n <MenuItem\n onClick={() =>\n this.setState({ anchorEl: null, cropHandler: false }, () => {\n const imageElement = this.cropperRef?.current?.cropper;\n if (imageElement) {\n if (onChange) {\n onChange(imageElement.getCroppedCanvas().toDataURL());\n } else {\n console.log(imageElement.getCroppedCanvas().toDataURL());\n }\n }\n })\n }\n >\n {I18n.t('ra_Save')}\n </MenuItem>\n <MenuItem onClick={() => this.setState({ anchorEl: null, cropHandler: false })}>\n {I18n.t('ra_Close')}\n </MenuItem>\n </Menu>\n </div>\n )}\n {icon && !cropHandler ? (\n <Icon\n src={icon}\n style={styles.image}\n alt=\"icon\"\n />\n ) : null}\n\n {icon && crop && cropHandler ? (\n <Cropper\n ref={this.cropperRef}\n style={styles.image}\n src={icon}\n initialAspectRatio={1}\n viewMode={1}\n guides={false}\n minCropBoxHeight={10}\n minCropBoxWidth={10}\n background={false}\n checkOrientation={false}\n />\n ) : null}\n </div>\n </div>\n )}\n </Dropzone>\n );\n }\n}\n"]}
|
|
@@ -17,7 +17,7 @@ type SmartName = null | false | string | ({
|
|
|
17
17
|
type ClassDictionary = Record<string, any>;
|
|
18
18
|
type ClassValue = ClassArray | ClassDictionary | string | number | null | boolean | undefined;
|
|
19
19
|
type ClassArray = ClassValue[];
|
|
20
|
-
declare class Utils {
|
|
20
|
+
export declare class Utils {
|
|
21
21
|
static namespace: string;
|
|
22
22
|
static INSTANCES: string;
|
|
23
23
|
static dateFormat: string[];
|
|
@@ -327,4 +327,4 @@ declare class Utils {
|
|
|
327
327
|
static isValidDate(date: any): boolean;
|
|
328
328
|
static getStyle(theme: IobTheme, ...args: (((_theme: IobTheme) => Record<string, any>) | undefined | Record<string, any>)[]): Record<string, any>;
|
|
329
329
|
}
|
|
330
|
-
export
|
|
330
|
+
export {};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
1
|
/**
|
|
7
2
|
* Copyright 2018-2024 Denis Haev <dogafox@gmail.com>
|
|
8
3
|
*
|
|
9
4
|
* MIT License
|
|
10
5
|
*
|
|
11
6
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { copy } from './CopyToClipboard';
|
|
9
|
+
import { I18n } from '../i18n';
|
|
15
10
|
const NAMESPACE = 'material';
|
|
16
11
|
const days = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
17
12
|
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -42,7 +37,11 @@ const SIGNATURES = {
|
|
|
42
37
|
Qk1: 'bmp',
|
|
43
38
|
AAABAA: 'ico', // 00 00 01 00 according to https://en.wikipedia.org/wiki/List_of_file_signatures
|
|
44
39
|
};
|
|
45
|
-
class Utils {
|
|
40
|
+
export class Utils {
|
|
41
|
+
static namespace = NAMESPACE;
|
|
42
|
+
static INSTANCES = 'instances';
|
|
43
|
+
static dateFormat = ['DD', 'MM'];
|
|
44
|
+
static FORBIDDEN_CHARS = /[^._\-/ :!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu;
|
|
46
45
|
/**
|
|
47
46
|
* Capitalize words.
|
|
48
47
|
*/
|
|
@@ -67,7 +66,7 @@ class Utils {
|
|
|
67
66
|
const secondsStr = Math.floor(seconds).toString().padStart(2, '0');
|
|
68
67
|
let text = '';
|
|
69
68
|
if (days_) {
|
|
70
|
-
text += `${days_} ${
|
|
69
|
+
text += `${days_} ${I18n.t('ra_daysShortText')} `;
|
|
71
70
|
}
|
|
72
71
|
text += `${hours}:${minutes}:${secondsStr}`;
|
|
73
72
|
return text;
|
|
@@ -78,7 +77,6 @@ class Utils {
|
|
|
78
77
|
static getObjectName(objects, id, settings, options,
|
|
79
78
|
/** Set to true to get the description. */
|
|
80
79
|
isDesc) {
|
|
81
|
-
var _a;
|
|
82
80
|
const item = objects[id];
|
|
83
81
|
let text;
|
|
84
82
|
if (typeof settings === 'string' && !options) {
|
|
@@ -94,7 +92,7 @@ class Utils {
|
|
|
94
92
|
window.sysLang ||
|
|
95
93
|
'en';
|
|
96
94
|
}
|
|
97
|
-
if (settings
|
|
95
|
+
if (settings?.name) {
|
|
98
96
|
const textObj = settings.name;
|
|
99
97
|
if (typeof textObj === 'object') {
|
|
100
98
|
text = (options.language && textObj[options.language]) || textObj.en;
|
|
@@ -103,7 +101,7 @@ class Utils {
|
|
|
103
101
|
text = textObj;
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
|
-
else if (isDesc &&
|
|
104
|
+
else if (isDesc && item?.common?.desc) {
|
|
107
105
|
const textObj = item.common.desc;
|
|
108
106
|
if (typeof textObj === 'object') {
|
|
109
107
|
text = (options.language && textObj[options.language]) || textObj.en || textObj.de || textObj.ru || '';
|
|
@@ -116,7 +114,7 @@ class Utils {
|
|
|
116
114
|
text = text[0] + text.substring(1).toLowerCase();
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
|
-
else if (!isDesc &&
|
|
117
|
+
else if (!isDesc && item?.common) {
|
|
120
118
|
const textObj = item.common.name || item.common.desc;
|
|
121
119
|
if (textObj && typeof textObj === 'object') {
|
|
122
120
|
text = (options.language && textObj[options.language]) || textObj.en || textObj.de || textObj.ru || '';
|
|
@@ -134,7 +132,7 @@ class Utils {
|
|
|
134
132
|
text = id.substring(pos + 1).replace(/[_.]/g, ' ');
|
|
135
133
|
text = Utils.CapitalWords(text);
|
|
136
134
|
}
|
|
137
|
-
return
|
|
135
|
+
return text?.trim() || '';
|
|
138
136
|
}
|
|
139
137
|
/**
|
|
140
138
|
* Get the name of the object from the name or description.
|
|
@@ -146,7 +144,6 @@ class Utils {
|
|
|
146
144
|
isDesc,
|
|
147
145
|
/** Allow using spaces in name (by edit) */
|
|
148
146
|
noTrim) {
|
|
149
|
-
var _a, _b;
|
|
150
147
|
const item = obj;
|
|
151
148
|
let text = (obj && obj._id) || '';
|
|
152
149
|
if (typeof settings === 'string' && !options) {
|
|
@@ -154,7 +151,7 @@ class Utils {
|
|
|
154
151
|
settings = null;
|
|
155
152
|
}
|
|
156
153
|
options = options || {};
|
|
157
|
-
if (settings
|
|
154
|
+
if (settings?.name) {
|
|
158
155
|
const name = settings.name;
|
|
159
156
|
if (typeof name === 'object') {
|
|
160
157
|
text = (options.language && name[options.language]) || name.en;
|
|
@@ -163,7 +160,7 @@ class Utils {
|
|
|
163
160
|
text = name;
|
|
164
161
|
}
|
|
165
162
|
}
|
|
166
|
-
else if (isDesc &&
|
|
163
|
+
else if (isDesc && item?.common?.desc) {
|
|
167
164
|
const desc = item.common.desc;
|
|
168
165
|
if (typeof desc === 'object') {
|
|
169
166
|
text = (options.language && desc[options.language]) || desc.en;
|
|
@@ -176,7 +173,7 @@ class Utils {
|
|
|
176
173
|
text = text[0] + text.substring(1).toLowerCase();
|
|
177
174
|
}
|
|
178
175
|
}
|
|
179
|
-
else if (!isDesc &&
|
|
176
|
+
else if (!isDesc && item?.common?.name) {
|
|
180
177
|
let name = item.common.name;
|
|
181
178
|
if (!name && item.common.desc) {
|
|
182
179
|
name = item.common.desc;
|
|
@@ -206,7 +203,7 @@ class Utils {
|
|
|
206
203
|
common = obj;
|
|
207
204
|
}
|
|
208
205
|
let settings;
|
|
209
|
-
if (common
|
|
206
|
+
if (common?.custom) {
|
|
210
207
|
settings = common.custom[NAMESPACE];
|
|
211
208
|
const user = options.user || 'admin';
|
|
212
209
|
if (settings && settings[user]) {
|
|
@@ -234,7 +231,7 @@ class Utils {
|
|
|
234
231
|
common = obj;
|
|
235
232
|
}
|
|
236
233
|
let settings;
|
|
237
|
-
if (common
|
|
234
|
+
if (common?.custom) {
|
|
238
235
|
settings = common.custom[NAMESPACE];
|
|
239
236
|
const user = options.user || 'admin';
|
|
240
237
|
if (settings && settings[user]) {
|
|
@@ -264,7 +261,7 @@ class Utils {
|
|
|
264
261
|
*/
|
|
265
262
|
static getSettings(obj, options, defaultEnabling) {
|
|
266
263
|
let settings;
|
|
267
|
-
const id =
|
|
264
|
+
const id = obj?._id || options?.id;
|
|
268
265
|
let common;
|
|
269
266
|
if (obj && Object.prototype.hasOwnProperty.call(obj, 'common')) {
|
|
270
267
|
common = obj.common;
|
|
@@ -272,7 +269,7 @@ class Utils {
|
|
|
272
269
|
else {
|
|
273
270
|
common = obj;
|
|
274
271
|
}
|
|
275
|
-
if (common
|
|
272
|
+
if (common?.custom) {
|
|
276
273
|
settings = common.custom;
|
|
277
274
|
settings =
|
|
278
275
|
settings[NAMESPACE] && settings[NAMESPACE][options.user || 'admin']
|
|
@@ -359,16 +356,16 @@ class Utils {
|
|
|
359
356
|
* Get the icon for the given settings.
|
|
360
357
|
*/
|
|
361
358
|
static getIcon(settings, style) {
|
|
362
|
-
if (settings
|
|
359
|
+
if (settings?.icon) {
|
|
363
360
|
// If UTF-8 icon
|
|
364
361
|
if (settings.icon.length <= 2) {
|
|
365
|
-
return
|
|
362
|
+
return React.createElement("span", { style: style || {} }, settings.icon);
|
|
366
363
|
}
|
|
367
364
|
if (settings.icon.startsWith('data:image')) {
|
|
368
|
-
return (
|
|
365
|
+
return (React.createElement("img", { alt: settings.name, src: settings.icon, style: style || {} }));
|
|
369
366
|
}
|
|
370
367
|
// maybe later some changes for a second type
|
|
371
|
-
return (
|
|
368
|
+
return (React.createElement("img", { alt: settings.name, src: (settings.prefix || '') + settings.icon, style: style }));
|
|
372
369
|
}
|
|
373
370
|
return null;
|
|
374
371
|
}
|
|
@@ -376,13 +373,12 @@ class Utils {
|
|
|
376
373
|
* Get the icon for the given object.
|
|
377
374
|
*/
|
|
378
375
|
static getObjectIcon(id, obj) {
|
|
379
|
-
var _a;
|
|
380
376
|
// If id is Object
|
|
381
377
|
if (typeof id === 'object') {
|
|
382
378
|
obj = id;
|
|
383
|
-
id = obj
|
|
379
|
+
id = obj?._id;
|
|
384
380
|
}
|
|
385
|
-
if (
|
|
381
|
+
if (obj?.common?.icon) {
|
|
386
382
|
let icon = obj.common.icon;
|
|
387
383
|
// If UTF-8 icon
|
|
388
384
|
if (typeof icon === 'string' && icon.length <= 2) {
|
|
@@ -644,8 +640,8 @@ class Utils {
|
|
|
644
640
|
else {
|
|
645
641
|
now = new Date(now);
|
|
646
642
|
}
|
|
647
|
-
let date =
|
|
648
|
-
date += `. ${now.getDate()} ${
|
|
643
|
+
let date = I18n.t(`ra_dow_${days[now.getDay()]}`).replace('ra_dow_', '');
|
|
644
|
+
date += `. ${now.getDate()} ${I18n.t(`ra_month_${months[now.getMonth()]}`).replace('ra_month_', '')}`;
|
|
649
645
|
return date;
|
|
650
646
|
}
|
|
651
647
|
/**
|
|
@@ -659,15 +655,15 @@ class Utils {
|
|
|
659
655
|
do {
|
|
660
656
|
const start = text.substring(0, m.index);
|
|
661
657
|
text = text.substring((m.index || 0) + m[0].length);
|
|
662
|
-
start && result.push(
|
|
658
|
+
start && result.push(React.createElement("span", { key: `a${key++}` }, start));
|
|
663
659
|
if (m[0].startsWith('<b>')) {
|
|
664
|
-
result.push(
|
|
660
|
+
result.push(React.createElement("b", { key: `a${key++}` }, m[0].substring(3, m[0].length - 4)));
|
|
665
661
|
}
|
|
666
662
|
else if (m[0].startsWith('<i>')) {
|
|
667
|
-
result.push(
|
|
663
|
+
result.push(React.createElement("i", { key: `a${key++}` }, m[0].substring(3, m[0].length - 4)));
|
|
668
664
|
}
|
|
669
665
|
else if (m[0].startsWith('<br')) {
|
|
670
|
-
result.push(
|
|
666
|
+
result.push(React.createElement("br", { key: `a${key++}` }));
|
|
671
667
|
}
|
|
672
668
|
else {
|
|
673
669
|
const href = m[0].match(/href="([^"]+)"/) || m[0].match(/href='([^']+)'/);
|
|
@@ -676,11 +672,11 @@ class Utils {
|
|
|
676
672
|
const title = m[0].match(/>([^<]*)</);
|
|
677
673
|
result.push(
|
|
678
674
|
// eslint-disable-next-line react/jsx-no-target-blank
|
|
679
|
-
|
|
675
|
+
React.createElement("a", { key: `a${key++}`, href: href ? href[1] : '', target: target ? target[1] : '_blank', rel: rel ? rel[1] : 'noreferrer', style: { color: 'inherit' } }, title ? title[1] : ''));
|
|
680
676
|
}
|
|
681
677
|
m = text ? text.match(/<a [^<]+<\/a>|<br\/?>|<b>[^<]+<\/b>|<i>[^<]+<\/i>/) : null;
|
|
682
678
|
if (!m) {
|
|
683
|
-
text && result.push(
|
|
679
|
+
text && result.push(React.createElement("span", { key: `a${key++}` }, text));
|
|
684
680
|
}
|
|
685
681
|
} while (m);
|
|
686
682
|
return result;
|
|
@@ -691,7 +687,6 @@ class Utils {
|
|
|
691
687
|
* Get the smart name of the given state.
|
|
692
688
|
*/
|
|
693
689
|
static getSmartName(states, id, instanceId, noCommon) {
|
|
694
|
-
var _a, _b;
|
|
695
690
|
if (!id) {
|
|
696
691
|
if (!noCommon) {
|
|
697
692
|
if (!states.common) {
|
|
@@ -706,7 +701,7 @@ class Utils {
|
|
|
706
701
|
return states.smartName;
|
|
707
702
|
}
|
|
708
703
|
const obj = states;
|
|
709
|
-
return
|
|
704
|
+
return obj?.common?.custom && obj.common.custom[instanceId]
|
|
710
705
|
? obj.common.custom[instanceId].smartName
|
|
711
706
|
: undefined;
|
|
712
707
|
}
|
|
@@ -714,7 +709,7 @@ class Utils {
|
|
|
714
709
|
return states[id].common.smartName;
|
|
715
710
|
}
|
|
716
711
|
const obj = states[id];
|
|
717
|
-
return
|
|
712
|
+
return obj?.common?.custom && obj.common.custom[instanceId]
|
|
718
713
|
? obj.common.custom[instanceId].smartName || null
|
|
719
714
|
: null;
|
|
720
715
|
}
|
|
@@ -722,7 +717,6 @@ class Utils {
|
|
|
722
717
|
* Get the smart name from a state.
|
|
723
718
|
*/
|
|
724
719
|
static getSmartNameFromObj(obj, instanceId, noCommon) {
|
|
725
|
-
var _a, _b;
|
|
726
720
|
if (!noCommon) {
|
|
727
721
|
if (!obj.common) {
|
|
728
722
|
return obj.smartName;
|
|
@@ -735,7 +729,7 @@ class Utils {
|
|
|
735
729
|
if (obj && !obj.common) {
|
|
736
730
|
return obj.smartName;
|
|
737
731
|
}
|
|
738
|
-
const custom =
|
|
732
|
+
const custom = obj?.common?.custom?.[instanceId];
|
|
739
733
|
return custom ? custom.smartName : undefined;
|
|
740
734
|
}
|
|
741
735
|
/**
|
|
@@ -768,7 +762,7 @@ class Utils {
|
|
|
768
762
|
* Update the smart name of a state.
|
|
769
763
|
*/
|
|
770
764
|
static updateSmartName(obj, newSmartName, byON, smartType, instanceId, noCommon) {
|
|
771
|
-
const language =
|
|
765
|
+
const language = I18n.getLanguage();
|
|
772
766
|
// convert the old format
|
|
773
767
|
if (typeof obj.common.smartName === 'string') {
|
|
774
768
|
const nnn = obj.common.smartName;
|
|
@@ -914,7 +908,7 @@ class Utils {
|
|
|
914
908
|
e.stopPropagation();
|
|
915
909
|
e.preventDefault();
|
|
916
910
|
}
|
|
917
|
-
return (
|
|
911
|
+
return copy(text);
|
|
918
912
|
}
|
|
919
913
|
/**
|
|
920
914
|
* Gets the extension of a file name.
|
|
@@ -1365,7 +1359,6 @@ class Utils {
|
|
|
1365
1359
|
}
|
|
1366
1360
|
}
|
|
1367
1361
|
static MDgetTitle(text) {
|
|
1368
|
-
var _a;
|
|
1369
1362
|
const result = Utils.MDextractHeader(text);
|
|
1370
1363
|
const header = result.header;
|
|
1371
1364
|
let body = result.body;
|
|
@@ -1381,7 +1374,7 @@ class Utils {
|
|
|
1381
1374
|
}
|
|
1382
1375
|
return '';
|
|
1383
1376
|
}
|
|
1384
|
-
return
|
|
1377
|
+
return header.title?.toString() || '';
|
|
1385
1378
|
}
|
|
1386
1379
|
static MDextractHeader(text) {
|
|
1387
1380
|
const attrs = {};
|
|
@@ -1480,15 +1473,14 @@ class Utils {
|
|
|
1480
1473
|
* @returns states as an object in form {"value1": "label1", "value2": "label2"} or null
|
|
1481
1474
|
*/
|
|
1482
1475
|
static getStates(obj) {
|
|
1483
|
-
|
|
1484
|
-
const states = (_a = obj === null || obj === void 0 ? void 0 : obj.common) === null || _a === void 0 ? void 0 : _a.states;
|
|
1476
|
+
const states = obj?.common?.states;
|
|
1485
1477
|
let result;
|
|
1486
1478
|
if (states) {
|
|
1487
1479
|
if (typeof states === 'string' && states[0] === '{') {
|
|
1488
1480
|
try {
|
|
1489
1481
|
result = JSON.parse(states);
|
|
1490
1482
|
}
|
|
1491
|
-
catch
|
|
1483
|
+
catch {
|
|
1492
1484
|
console.error(`Cannot parse states: ${states}`);
|
|
1493
1485
|
result = null;
|
|
1494
1486
|
}
|
|
@@ -1504,13 +1496,13 @@ class Utils {
|
|
|
1504
1496
|
}
|
|
1505
1497
|
else if (Array.isArray(states)) {
|
|
1506
1498
|
result = {};
|
|
1507
|
-
if (
|
|
1499
|
+
if (obj?.common.type === 'number') {
|
|
1508
1500
|
states.forEach((value, key) => (result[key] = value));
|
|
1509
1501
|
}
|
|
1510
|
-
else if (
|
|
1502
|
+
else if (obj?.common.type === 'string') {
|
|
1511
1503
|
states.forEach(value => (result[value] = value));
|
|
1512
1504
|
}
|
|
1513
|
-
else if (
|
|
1505
|
+
else if (obj?.common.type === 'boolean') {
|
|
1514
1506
|
result.false = states[0];
|
|
1515
1507
|
result.true = states[1];
|
|
1516
1508
|
}
|
|
@@ -1533,8 +1525,7 @@ class Utils {
|
|
|
1533
1525
|
return new Promise(resolve => {
|
|
1534
1526
|
const reader = new FileReader();
|
|
1535
1527
|
reader.onload = function () {
|
|
1536
|
-
|
|
1537
|
-
resolve(((_a = this.result) === null || _a === void 0 ? void 0 : _a.toString()) || '');
|
|
1528
|
+
resolve(this.result?.toString() || '');
|
|
1538
1529
|
};
|
|
1539
1530
|
reader.readAsDataURL(blob);
|
|
1540
1531
|
});
|
|
@@ -1606,8 +1597,4 @@ class Utils {
|
|
|
1606
1597
|
return result;
|
|
1607
1598
|
}
|
|
1608
1599
|
}
|
|
1609
|
-
Utils.
|
|
1610
|
-
Utils.INSTANCES = 'instances';
|
|
1611
|
-
Utils.dateFormat = ['DD', 'MM'];
|
|
1612
|
-
Utils.FORBIDDEN_CHARS = /[^._\-/ :!#$%&()+=@^{}|~\p{Ll}\p{Lu}\p{Nd}]+/gu;
|
|
1613
|
-
exports.default = Utils;
|
|
1600
|
+
//# sourceMappingURL=Utils.js.map
|