@iobroker/adapter-react-v5 7.2.4 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -15
- 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 +5 -3
- package/{Components → build/Components}/FileBrowser.js +230 -236
- 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/{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 +1159 -1122
- 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 +45 -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} +36 -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 +5 -0
- package/build/icons/IconAdapter.js.map +1 -0
- package/build/icons/IconAlias.d.ts +3 -0
- package/build/icons/IconAlias.js +5 -0
- package/build/icons/IconAlias.js.map +1 -0
- package/build/icons/IconChannel.d.ts +3 -0
- package/build/icons/IconChannel.js +8 -0
- package/build/icons/IconChannel.js.map +1 -0
- package/build/icons/IconClearFilter.d.ts +3 -0
- package/build/icons/IconClearFilter.js +6 -0
- package/build/icons/IconClearFilter.js.map +1 -0
- package/build/icons/IconClosed.d.ts +3 -0
- package/build/icons/IconClosed.js +5 -0
- package/build/icons/IconClosed.js.map +1 -0
- package/build/icons/IconCopy.d.ts +3 -0
- package/build/icons/IconCopy.js +4 -0
- package/build/icons/IconCopy.js.map +1 -0
- package/build/icons/IconDevice.d.ts +3 -0
- package/build/icons/IconDevice.js +14 -0
- package/build/icons/IconDevice.js.map +1 -0
- package/build/icons/IconDocument.d.ts +3 -0
- package/build/icons/IconDocument.js +5 -0
- package/build/icons/IconDocument.js.map +1 -0
- package/build/icons/IconDocumentReadOnly.d.ts +3 -0
- package/build/icons/IconDocumentReadOnly.js +6 -0
- package/build/icons/IconDocumentReadOnly.js.map +1 -0
- package/build/icons/IconExpert.d.ts +3 -0
- package/build/icons/IconExpert.js +5 -0
- package/build/icons/IconExpert.js.map +1 -0
- package/build/icons/IconFx.d.ts +3 -0
- package/build/icons/IconFx.js +4 -0
- package/build/icons/IconFx.js.map +1 -0
- package/build/icons/IconInstance.d.ts +3 -0
- package/build/icons/IconInstance.js +5 -0
- package/build/icons/IconInstance.js.map +1 -0
- package/build/icons/IconLogout.d.ts +3 -0
- package/build/icons/IconLogout.js +5 -0
- package/build/icons/IconLogout.js.map +1 -0
- package/build/icons/IconNoIcon.d.ts +3 -0
- package/build/icons/IconNoIcon.js +4 -0
- package/build/icons/IconNoIcon.js.map +1 -0
- package/build/icons/IconOpen.d.ts +3 -0
- package/build/icons/IconOpen.js +5 -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 +5 -0
- package/build/icons/IconState.js.map +1 -0
- package/build/index.d.ts +76 -0
- package/build/index.js +75 -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,343 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright 2018-2024 Denis Haev (bluefox) <dogafox@gmail.com>
|
|
3
|
-
*
|
|
4
|
-
* Licensed under the Creative Commons Attribution-NonCommercial License, Version 4.0 (the "License");
|
|
5
|
-
* you may not use this file except in compliance with the License.
|
|
6
|
-
* You may obtain a copy of the License at
|
|
7
|
-
*
|
|
8
|
-
* https://creativecommons.org/licenses/by-nc/4.0/legalcode.txt
|
|
9
|
-
*
|
|
10
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
* See the License for the specific language governing permissions and
|
|
14
|
-
* limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
import React, { Component, type CSSProperties } from 'react';
|
|
17
|
-
import { ChromePicker, type RGBColor } from 'react-color';
|
|
18
|
-
|
|
19
|
-
import { TextField, Menu, IconButton, Button, Box } from '@mui/material';
|
|
20
|
-
|
|
21
|
-
import { Delete as IconDelete, Close as IconClose } from '@mui/icons-material';
|
|
22
|
-
|
|
23
|
-
import I18n from '../i18n';
|
|
24
|
-
|
|
25
|
-
import type { IobTheme } from '../types';
|
|
26
|
-
|
|
27
|
-
const styles: Record<string, any> = {
|
|
28
|
-
color: {
|
|
29
|
-
width: 36,
|
|
30
|
-
height: 14,
|
|
31
|
-
borderRadius: 2,
|
|
32
|
-
},
|
|
33
|
-
delButton: {
|
|
34
|
-
marginTop: 16,
|
|
35
|
-
},
|
|
36
|
-
swatch: {
|
|
37
|
-
mt: '16px',
|
|
38
|
-
p: '5px',
|
|
39
|
-
backgroundColor: 'background.paper',
|
|
40
|
-
borderRadius: '1px',
|
|
41
|
-
boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
|
|
42
|
-
display: 'inline-block',
|
|
43
|
-
cursor: 'pointer',
|
|
44
|
-
verticalAlign: 'middle',
|
|
45
|
-
},
|
|
46
|
-
swatchDisabled: {
|
|
47
|
-
opacity: 0.5,
|
|
48
|
-
cursor: 'default',
|
|
49
|
-
},
|
|
50
|
-
popover: {
|
|
51
|
-
'& .MuiPaper-root': {
|
|
52
|
-
textAlign: 'right',
|
|
53
|
-
backgroundColor: '#00000000',
|
|
54
|
-
boxShadow: 'none',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
popoverList: {
|
|
58
|
-
padding: 0,
|
|
59
|
-
},
|
|
60
|
-
closeButton: (theme: IobTheme) => ({
|
|
61
|
-
backgroundColor: `${theme.palette.background.paper} !important`,
|
|
62
|
-
borderRadius: '0 0 25% 25%',
|
|
63
|
-
'&:hover': {
|
|
64
|
-
backgroundColor: `${theme.palette.secondary.main} !important`,
|
|
65
|
-
},
|
|
66
|
-
}),
|
|
67
|
-
cover: {
|
|
68
|
-
position: 'fixed',
|
|
69
|
-
top: 0,
|
|
70
|
-
right: 0,
|
|
71
|
-
bottom: 0,
|
|
72
|
-
left: 0,
|
|
73
|
-
},
|
|
74
|
-
textDense: {
|
|
75
|
-
mt: 0,
|
|
76
|
-
mb: 0,
|
|
77
|
-
},
|
|
78
|
-
picker: (theme: IobTheme) => ({
|
|
79
|
-
background: `${theme.palette.background.paper} !important`,
|
|
80
|
-
}),
|
|
81
|
-
iconButton: {
|
|
82
|
-
width: 16,
|
|
83
|
-
height: 16,
|
|
84
|
-
},
|
|
85
|
-
button: {
|
|
86
|
-
width: 32,
|
|
87
|
-
height: 32,
|
|
88
|
-
minWidth: 32,
|
|
89
|
-
minHeight: 32,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
interface ColorPickerProps {
|
|
94
|
-
/** Set to true to disable the color picker. */
|
|
95
|
-
disabled?: boolean;
|
|
96
|
-
/** The currently selected color. */
|
|
97
|
-
value?: string;
|
|
98
|
-
/** @deprecated The currently selected color use value */
|
|
99
|
-
color?: string;
|
|
100
|
-
/** The color change callback. */
|
|
101
|
-
onChange: (rgba: string) => void;
|
|
102
|
-
/** Label of the color picker. */
|
|
103
|
-
label?: string;
|
|
104
|
-
/** @deprecated TLabel of the color picker use label */
|
|
105
|
-
name?: string;
|
|
106
|
-
/** Additional styling for this component. */
|
|
107
|
-
style?: CSSProperties;
|
|
108
|
-
/** The CSS class name. */
|
|
109
|
-
className?: string;
|
|
110
|
-
customPalette?: string[];
|
|
111
|
-
noInputField?: boolean;
|
|
112
|
-
barWidth?: number;
|
|
113
|
-
sx?: Record<string, any>;
|
|
114
|
-
theme?: IobTheme;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface ColorPickerState {
|
|
118
|
-
displayColorPicker: boolean;
|
|
119
|
-
color: string | RGBColor;
|
|
120
|
-
anchorEl: HTMLDivElement | null;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* A color picker component.
|
|
125
|
-
*/
|
|
126
|
-
class ColorPicker extends Component<ColorPickerProps, ColorPickerState> {
|
|
127
|
-
/**
|
|
128
|
-
* Constructor for the color picker.
|
|
129
|
-
*
|
|
130
|
-
* @param props The properties.
|
|
131
|
-
*/
|
|
132
|
-
constructor(props: ColorPickerProps) {
|
|
133
|
-
super(props);
|
|
134
|
-
this.state = {
|
|
135
|
-
displayColorPicker: false,
|
|
136
|
-
color: this.props.value || this.props.color || '',
|
|
137
|
-
anchorEl: null,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private handleClick = (e: React.MouseEvent<HTMLDivElement>): void => {
|
|
142
|
-
this.setState({
|
|
143
|
-
displayColorPicker: !this.state.displayColorPicker,
|
|
144
|
-
anchorEl: this.state.displayColorPicker ? null : e.currentTarget,
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
private handleClose = (): void => {
|
|
149
|
-
this.setState({ displayColorPicker: false, anchorEl: null });
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Convert the given color to hex ('#rrggbb') or rgba ('rgba(r,g,b,a)') format.
|
|
154
|
-
*
|
|
155
|
-
* @param color The color to convert.
|
|
156
|
-
* @param isHex If true, the color will be converted to hex format.
|
|
157
|
-
* @returns the hex or rgba representation of the given color.
|
|
158
|
-
*/
|
|
159
|
-
static getColor(color: string | { rgb: RGBColor } | RGBColor, isHex?: boolean): string {
|
|
160
|
-
if (color && typeof color === 'object') {
|
|
161
|
-
const oColor = color as { rgb: RGBColor };
|
|
162
|
-
if (oColor.rgb) {
|
|
163
|
-
if (isHex) {
|
|
164
|
-
return `#${oColor.rgb.r.toString(16).padStart(2, '0')}${oColor.rgb.g.toString(16).padStart(2, '0')}${oColor.rgb.b.toString(16).padStart(2, '0')}`;
|
|
165
|
-
}
|
|
166
|
-
return `rgba(${oColor.rgb.r},${oColor.rgb.g},${oColor.rgb.b},${oColor.rgb.a})`;
|
|
167
|
-
}
|
|
168
|
-
const rColor = color as RGBColor;
|
|
169
|
-
if (isHex) {
|
|
170
|
-
return `#${rColor.r.toString(16).padStart(2, '0')}${rColor.g.toString(16).padStart(2, '0')}${rColor.b.toString(16).padStart(2, '0')}`;
|
|
171
|
-
}
|
|
172
|
-
return `rgba(${rColor.r},${rColor.g},${rColor.b},${rColor.a})`;
|
|
173
|
-
}
|
|
174
|
-
if (typeof color === 'string') {
|
|
175
|
-
return isHex ? ColorPicker.rgb2hex(color || '') : color || '';
|
|
176
|
-
}
|
|
177
|
-
return '';
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Convert rgb() or rgba() format to hex format #rrggbb.
|
|
182
|
-
*
|
|
183
|
-
* @param rgb The color in rgb() or rgba() format. if not in this format, the color will be returned as is.
|
|
184
|
-
*/
|
|
185
|
-
static rgb2hex(rgb: string): string {
|
|
186
|
-
const m = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
|
187
|
-
|
|
188
|
-
if (m) {
|
|
189
|
-
const r = parseInt(m[1], 10).toString(16).padStart(2, '0');
|
|
190
|
-
const g = parseInt(m[2], 10).toString(16).padStart(2, '0');
|
|
191
|
-
const b = parseInt(m[3], 10).toString(16).padStart(2, '0');
|
|
192
|
-
|
|
193
|
-
return m?.length === 4 ? `#${r}${g}${b}` : rgb;
|
|
194
|
-
}
|
|
195
|
-
return rgb;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private handleChange = (color: string | RGBColor): void => {
|
|
199
|
-
this.setState({ color }, () => this.props.onChange && this.props.onChange(ColorPicker.getColor(color)));
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* If the props are updated from outside, they should override the state
|
|
204
|
-
*
|
|
205
|
-
* @param _prevProps The previous properties.
|
|
206
|
-
* @param prevState The previous state.
|
|
207
|
-
*/
|
|
208
|
-
componentDidUpdate(_prevProps: ColorPickerProps, prevState: ColorPickerState): void {
|
|
209
|
-
const color = ColorPicker.getColor(this.props.color || this.props.value || '');
|
|
210
|
-
|
|
211
|
-
if (color !== prevState.color) {
|
|
212
|
-
this.setState({ color });
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
renderCustomPalette(): React.JSX.Element | null {
|
|
217
|
-
if (!this.props.customPalette) {
|
|
218
|
-
return null;
|
|
219
|
-
}
|
|
220
|
-
return (
|
|
221
|
-
<div style={{ width: '100%', display: 'flex', flexWrap: 'wrap' }}>
|
|
222
|
-
{this.props.customPalette.map(color => (
|
|
223
|
-
<Button
|
|
224
|
-
style={styles.button}
|
|
225
|
-
key={color}
|
|
226
|
-
onClick={() => {
|
|
227
|
-
this.handleChange(color);
|
|
228
|
-
setTimeout(() => this.handleClose(), 300);
|
|
229
|
-
}}
|
|
230
|
-
>
|
|
231
|
-
<div style={{ ...styles.iconButton, background: color }} />
|
|
232
|
-
</Button>
|
|
233
|
-
))}
|
|
234
|
-
</div>
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
render(): React.JSX.Element {
|
|
239
|
-
const style = { ...(this.props.style || {}) };
|
|
240
|
-
style.position = 'relative';
|
|
241
|
-
const { color } = this.state;
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<Box
|
|
245
|
-
component="div"
|
|
246
|
-
style={style}
|
|
247
|
-
sx={this.props.sx || undefined}
|
|
248
|
-
className={this.props.className || ''}
|
|
249
|
-
>
|
|
250
|
-
{this.props.noInputField ? null : (
|
|
251
|
-
<TextField
|
|
252
|
-
disabled={this.props.disabled}
|
|
253
|
-
variant="standard"
|
|
254
|
-
id="ar_color_picker_name"
|
|
255
|
-
label={this.props.label || this.props.name}
|
|
256
|
-
value={color || ''}
|
|
257
|
-
margin="dense"
|
|
258
|
-
sx={{
|
|
259
|
-
'&.MuiFormControl-root': styles.textDense,
|
|
260
|
-
width: color ? 'calc(100% - 80px)' : 'calc(100% - 56px)',
|
|
261
|
-
mr: color ? undefined : 1,
|
|
262
|
-
}}
|
|
263
|
-
onChange={e => this.handleChange(e.target.value)}
|
|
264
|
-
/>
|
|
265
|
-
)}
|
|
266
|
-
{!this.props.noInputField && color ? (
|
|
267
|
-
<IconButton
|
|
268
|
-
disabled={this.props.disabled}
|
|
269
|
-
onClick={() => this.handleChange('')}
|
|
270
|
-
size="small"
|
|
271
|
-
style={{
|
|
272
|
-
...(this.props.label || this.props.name ? styles.delButton : undefined),
|
|
273
|
-
...(color ? undefined : { opacity: 0, cursor: 'default' }),
|
|
274
|
-
}}
|
|
275
|
-
>
|
|
276
|
-
<IconDelete />
|
|
277
|
-
</IconButton>
|
|
278
|
-
) : null}
|
|
279
|
-
<Box
|
|
280
|
-
component="div"
|
|
281
|
-
onClick={e => !this.props.disabled && this.handleClick(e)}
|
|
282
|
-
title={I18n.t('ra_Select color')}
|
|
283
|
-
sx={{
|
|
284
|
-
...styles.swatch,
|
|
285
|
-
...(this.props.disabled ? styles.swatchDisabled : undefined),
|
|
286
|
-
background: color ? undefined : 'transparent',
|
|
287
|
-
border: color ? undefined : '1px dashed #ccc',
|
|
288
|
-
boxSizing: 'border-box',
|
|
289
|
-
marginTop: this.props.noInputField || !(this.props.label || this.props.name) ? 0 : undefined,
|
|
290
|
-
}}
|
|
291
|
-
>
|
|
292
|
-
<div
|
|
293
|
-
style={{
|
|
294
|
-
...styles.color,
|
|
295
|
-
background: ColorPicker.getColor(color),
|
|
296
|
-
width: this.props.noInputField ? this.props.barWidth || 16 : this.props.barWidth || 36,
|
|
297
|
-
}}
|
|
298
|
-
/>
|
|
299
|
-
</Box>
|
|
300
|
-
{this.state.displayColorPicker && !this.props.disabled ? (
|
|
301
|
-
<Menu
|
|
302
|
-
sx={{
|
|
303
|
-
...styles.popover,
|
|
304
|
-
'&. MuiMenu-list': styles.popoverList,
|
|
305
|
-
}}
|
|
306
|
-
anchorEl={this.state.anchorEl}
|
|
307
|
-
open={!0}
|
|
308
|
-
onClose={() => this.handleClose()}
|
|
309
|
-
>
|
|
310
|
-
<ChromePicker
|
|
311
|
-
color={this.state.color || undefined}
|
|
312
|
-
onChangeComplete={(_color: { rgb: RGBColor }) => this.handleChange(_color.rgb)}
|
|
313
|
-
styles={{
|
|
314
|
-
default: {
|
|
315
|
-
picker: {
|
|
316
|
-
backgroundColor: this.props.theme?.palette.background.paper || '#888',
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
}}
|
|
320
|
-
/>
|
|
321
|
-
{color && this.props.noInputField ? (
|
|
322
|
-
<IconButton
|
|
323
|
-
sx={styles.closeButton}
|
|
324
|
-
onClick={() => this.handleChange('')}
|
|
325
|
-
>
|
|
326
|
-
<IconDelete />
|
|
327
|
-
</IconButton>
|
|
328
|
-
) : null}
|
|
329
|
-
<IconButton
|
|
330
|
-
sx={styles.closeButton}
|
|
331
|
-
onClick={() => this.handleClose()}
|
|
332
|
-
>
|
|
333
|
-
<IconClose />
|
|
334
|
-
</IconButton>
|
|
335
|
-
{this.renderCustomPalette()}
|
|
336
|
-
</Menu>
|
|
337
|
-
) : null}
|
|
338
|
-
</Box>
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export default ColorPicker;
|