@iobroker/adapter-react-v5 6.1.3 → 6.1.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 -0
- package/craco-module-federation.js +1 -1
- package/package.json +1 -1
- package/src/AdminConnection.tsx +3 -0
- package/src/Components/404.tsx +121 -0
- package/src/Components/ColorPicker.tsx +315 -0
- package/src/Components/ComplexCron.tsx +507 -0
- package/src/Components/CopyToClipboard.tsx +165 -0
- package/src/Components/CustomModal.tsx +163 -0
- package/src/Components/FileBrowser.tsx +2394 -0
- package/src/Components/FileViewer.tsx +384 -0
- package/src/Components/Icon.tsx +210 -0
- package/src/Components/IconPicker.tsx +149 -0
- package/src/Components/IconSelector.tsx +2202 -0
- package/src/Components/Image.tsx +176 -0
- package/src/Components/Loader.tsx +304 -0
- package/src/Components/Logo.tsx +166 -0
- package/src/Components/MDUtils.tsx +100 -0
- package/src/Components/ObjectBrowser.tsx +7915 -0
- package/src/Components/Router.tsx +90 -0
- package/src/Components/SaveCloseButtons.tsx +113 -0
- package/src/Components/Schedule.tsx +1724 -0
- package/src/Components/SelectWithIcon.tsx +197 -0
- package/src/Components/TabContainer.tsx +55 -0
- package/src/Components/TabContent.tsx +37 -0
- package/src/Components/TabHeader.tsx +19 -0
- package/src/Components/TableResize.tsx +259 -0
- package/src/Components/TextWithIcon.tsx +148 -0
- package/src/Components/ToggleThemeMenu.tsx +34 -0
- package/src/Components/TreeTable.tsx +919 -0
- package/src/Components/UploadImage.tsx +599 -0
- package/src/Components/Utils.tsx +1794 -0
- package/src/Components/loader.css +222 -0
- package/src/Components/withWidth.tsx +21 -0
- package/src/Connection.tsx +7 -0
- package/src/Dialogs/ComplexCron.tsx +129 -0
- package/src/Dialogs/Confirm.tsx +162 -0
- package/src/Dialogs/Cron.tsx +182 -0
- package/src/Dialogs/Error.tsx +72 -0
- package/src/Dialogs/Message.tsx +71 -0
- package/src/Dialogs/SelectFile.tsx +270 -0
- package/src/Dialogs/SelectID.tsx +298 -0
- package/src/Dialogs/SimpleCron.tsx +100 -0
- package/src/Dialogs/TextInput.tsx +107 -0
- package/src/GenericApp.tsx +976 -0
- package/src/LegacyConnection.tsx +3589 -0
- package/src/Prompt.tsx +20 -0
- package/src/Theme.tsx +479 -0
- package/src/icons/IconAdapter.tsx +20 -0
- package/src/icons/IconAlias.tsx +20 -0
- package/src/icons/IconChannel.tsx +21 -0
- package/src/icons/IconClearFilter.tsx +22 -0
- package/src/icons/IconClosed.tsx +17 -0
- package/src/icons/IconCopy.tsx +16 -0
- package/src/icons/IconDevice.tsx +27 -0
- package/src/icons/IconDocument.tsx +17 -0
- package/src/icons/IconDocumentReadOnly.tsx +18 -0
- package/src/icons/IconExpert.tsx +18 -0
- package/src/icons/IconFx.tsx +36 -0
- package/src/icons/IconInstance.tsx +20 -0
- package/src/icons/IconLogout.tsx +30 -0
- package/src/icons/IconNoIcon.tsx +19 -0
- package/src/icons/IconOpen.tsx +17 -0
- package/src/icons/IconProps.tsx +15 -0
- package/src/icons/IconState.tsx +17 -0
- package/src/index.css +55 -0
- package/assets/devices/list.json +0 -994
- package/assets/devices/names.txt +0 -63
- package/assets/devices/parseNames.d.ts +0 -0
- package/assets/devices/parseNames.js +0 -34
- package/assets/rooms/list.json +0 -946
- package/assets/rooms/names.txt +0 -60
- package/assets/rooms/parseNames.d.ts +0 -0
- package/assets/rooms/parseNames.js +0 -34
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useDropzone } from 'react-dropzone';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
InputLabel,
|
|
6
|
+
FormControl,
|
|
7
|
+
IconButton,
|
|
8
|
+
} from '@mui/material';
|
|
9
|
+
import { Clear as ClearIcon } from '@mui/icons-material';
|
|
10
|
+
|
|
11
|
+
import IconSelector from './IconSelector';
|
|
12
|
+
import Icon from './Icon';
|
|
13
|
+
import I18n from '../i18n';
|
|
14
|
+
import Utils from './Utils';
|
|
15
|
+
|
|
16
|
+
const styles: Record<string, React.CSSProperties> = {
|
|
17
|
+
formContainer : {
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'left',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
},
|
|
22
|
+
formControl : {
|
|
23
|
+
display: 'flex',
|
|
24
|
+
padding: 24,
|
|
25
|
+
flexGrow: 1000,
|
|
26
|
+
},
|
|
27
|
+
divContainer: {
|
|
28
|
+
width: 32 + 24,
|
|
29
|
+
height: 32,
|
|
30
|
+
whiteSpace: 'nowrap',
|
|
31
|
+
lineHeight: '32px',
|
|
32
|
+
marginRight: 8,
|
|
33
|
+
},
|
|
34
|
+
dragField: {
|
|
35
|
+
textAlign: 'center',
|
|
36
|
+
display: 'table',
|
|
37
|
+
minHeight: 90,
|
|
38
|
+
width: 'calc(100% - 60px)',
|
|
39
|
+
border: '2px dashed #777',
|
|
40
|
+
borderRadius: 10,
|
|
41
|
+
padding: 4,
|
|
42
|
+
},
|
|
43
|
+
formIcon : {
|
|
44
|
+
margin: 10,
|
|
45
|
+
opacity: 0.6,
|
|
46
|
+
},
|
|
47
|
+
text: {
|
|
48
|
+
display: 'table-cell',
|
|
49
|
+
verticalAlign: 'middle',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
interface IconPickerProps {
|
|
54
|
+
previewStyle?: React.CSSProperties;
|
|
55
|
+
previewClassName?: string;
|
|
56
|
+
/** Custom icon element. */
|
|
57
|
+
icon?: React.FC<{ style?: React.CSSProperties }>;
|
|
58
|
+
customStyles?: Record<string, React.CSSProperties>;
|
|
59
|
+
customClasses?: Record<string, string>;
|
|
60
|
+
/** The label. */
|
|
61
|
+
label?: string;
|
|
62
|
+
/** The value. */
|
|
63
|
+
value?: any;
|
|
64
|
+
/** Set to true to disable the icon picker. */
|
|
65
|
+
disabled?: boolean;
|
|
66
|
+
/** The icon change callback. */
|
|
67
|
+
onChange: (icon: string) => void;
|
|
68
|
+
icons?: {
|
|
69
|
+
icon?: string;
|
|
70
|
+
src?: string;
|
|
71
|
+
href?: string;
|
|
72
|
+
name?: ioBroker.StringOrTranslated;
|
|
73
|
+
_id?: string;
|
|
74
|
+
}[];
|
|
75
|
+
onlyRooms?: boolean;
|
|
76
|
+
onlyDevices?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const IconPicker = (props: IconPickerProps) => {
|
|
80
|
+
const IconCustom = props.icon;
|
|
81
|
+
|
|
82
|
+
const onDrop = useCallback((acceptedFiles: File[]) => {
|
|
83
|
+
const reader = new FileReader();
|
|
84
|
+
|
|
85
|
+
reader.addEventListener('load', () =>
|
|
86
|
+
props.onChange(reader.result as string), false);
|
|
87
|
+
|
|
88
|
+
if (acceptedFiles[0]) {
|
|
89
|
+
reader.readAsDataURL(acceptedFiles[0]);
|
|
90
|
+
}
|
|
91
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
92
|
+
|
|
93
|
+
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop });
|
|
94
|
+
|
|
95
|
+
return <div style={styles.formContainer}>
|
|
96
|
+
{IconCustom ? <IconCustom style={styles.formIcon} /> : null}
|
|
97
|
+
<FormControl variant="standard" style={{ ...styles.formControl, padding: 3 }}>
|
|
98
|
+
<InputLabel
|
|
99
|
+
shrink
|
|
100
|
+
sx={props.customStyles?.label ? { '&.MuiInputLabel-root': props.customStyles.label } : undefined}
|
|
101
|
+
classes={{ root: props.customClasses?.label }}
|
|
102
|
+
>
|
|
103
|
+
{props.label}
|
|
104
|
+
</InputLabel>
|
|
105
|
+
<div style={styles.formContainer}>
|
|
106
|
+
{props.value ?
|
|
107
|
+
<div style={styles.divContainer}>
|
|
108
|
+
<Icon
|
|
109
|
+
style={{ ...props.previewStyle, ...(props.customStyles?.icon || undefined) }}
|
|
110
|
+
src={props.value}
|
|
111
|
+
className={Utils.clsx(props.previewClassName, props.customClasses?.icon)}
|
|
112
|
+
/>
|
|
113
|
+
{!props.disabled && <IconButton
|
|
114
|
+
style={{ verticalAlign: 'top' }}
|
|
115
|
+
title={I18n.t('ra_Clear icon')}
|
|
116
|
+
size="small"
|
|
117
|
+
onClick={() => props.onChange('')}
|
|
118
|
+
>
|
|
119
|
+
<ClearIcon />
|
|
120
|
+
</IconButton>}
|
|
121
|
+
</div>
|
|
122
|
+
:
|
|
123
|
+
(!props.disabled && <IconSelector
|
|
124
|
+
icons={props.icons}
|
|
125
|
+
onlyRooms={props.onlyRooms}
|
|
126
|
+
onlyDevices={props.onlyDevices}
|
|
127
|
+
onSelect={(base64: string) => props.onChange(base64)}
|
|
128
|
+
t={I18n.t}
|
|
129
|
+
lang={I18n.getLanguage()}
|
|
130
|
+
/>)}
|
|
131
|
+
|
|
132
|
+
{!props.disabled && <div
|
|
133
|
+
{...getRootProps()}
|
|
134
|
+
style={{
|
|
135
|
+
...styles.dragField,
|
|
136
|
+
...(isDragActive ? { backgroundColor: 'rgba(0, 255, 0, 0.1)' } : { cursor: 'pointer' }),
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<input {...getInputProps()} />
|
|
140
|
+
{isDragActive ?
|
|
141
|
+
<span style={styles.text}>{I18n.t('ra_Drop the files here...')}</span> :
|
|
142
|
+
<span style={styles.text}>{I18n.t('ra_Drag \'n\' drop some files here, or click to select files')}</span>}
|
|
143
|
+
</div>}
|
|
144
|
+
</div>
|
|
145
|
+
</FormControl>
|
|
146
|
+
</div>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default IconPicker;
|