@iobroker/adapter-react-v5 6.0.12 → 6.0.14
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/Components/ColorPicker.d.ts +2 -1
- package/Components/ColorPicker.js +17 -23
- package/Components/Utils.js +1 -1
- package/GenericApp.js +1 -1
- package/README.md +21 -5
- package/package.json +8 -8
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import React, { Component } from 'react';
|
|
17
17
|
import { type RGBColor } from 'react-color';
|
|
18
|
+
import { IobTheme } from '../types';
|
|
18
19
|
interface ColorPickerProps {
|
|
19
20
|
/** Set to true to disable the color picker. */
|
|
20
21
|
disabled?: boolean;
|
|
@@ -32,11 +33,11 @@ interface ColorPickerProps {
|
|
|
32
33
|
style?: React.CSSProperties;
|
|
33
34
|
/** The CSS class name. */
|
|
34
35
|
className?: string;
|
|
35
|
-
/** Open the color picker above the field? */
|
|
36
36
|
customPalette?: string[];
|
|
37
37
|
noInputField?: boolean;
|
|
38
38
|
barWidth?: number;
|
|
39
39
|
sx?: Record<string, any>;
|
|
40
|
+
theme?: IobTheme;
|
|
40
41
|
}
|
|
41
42
|
interface ColorPickerState {
|
|
42
43
|
displayColorPicker: boolean;
|
|
@@ -53,15 +53,13 @@ const styles = {
|
|
|
53
53
|
borderRadius: 2,
|
|
54
54
|
},
|
|
55
55
|
delButton: {
|
|
56
|
-
// width: 32,
|
|
57
|
-
// height: 32,
|
|
58
56
|
marginTop: 16,
|
|
59
57
|
},
|
|
60
58
|
swatch: {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
borderRadius:
|
|
59
|
+
mt: '16px',
|
|
60
|
+
p: '5px',
|
|
61
|
+
backgroundColor: 'background.paper',
|
|
62
|
+
borderRadius: '1px',
|
|
65
63
|
boxShadow: '0 0 0 1px rgba(0,0,0,.1)',
|
|
66
64
|
display: 'inline-block',
|
|
67
65
|
cursor: 'pointer',
|
|
@@ -72,10 +70,11 @@ const styles = {
|
|
|
72
70
|
cursor: 'default',
|
|
73
71
|
},
|
|
74
72
|
popover: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
'& .MuiPaper-root': {
|
|
74
|
+
textAlign: 'right',
|
|
75
|
+
backgroundColor: '#00000000',
|
|
76
|
+
boxShadow: 'none',
|
|
77
|
+
},
|
|
79
78
|
},
|
|
80
79
|
popoverList: {
|
|
81
80
|
padding: 0,
|
|
@@ -189,30 +188,25 @@ class ColorPicker extends react_1.Component {
|
|
|
189
188
|
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.iconButton), { background: color }) }))));
|
|
190
189
|
}
|
|
191
190
|
render() {
|
|
191
|
+
var _a;
|
|
192
192
|
const style = Object.assign({}, (this.props.style || {}));
|
|
193
193
|
style.position = 'relative';
|
|
194
194
|
const { color } = this.state;
|
|
195
195
|
return react_1.default.createElement(material_1.Box, { component: "div", style: style, sx: this.props.sx || undefined, className: this.props.className || '' },
|
|
196
|
-
this.props.noInputField ? null : react_1.default.createElement(material_1.TextField, { disabled: this.props.disabled, variant: "standard", id: "ar_color_picker_name", label: this.props.label || this.props.name
|
|
196
|
+
this.props.noInputField ? null : react_1.default.createElement(material_1.TextField, { disabled: this.props.disabled, variant: "standard", id: "ar_color_picker_name", label: this.props.label || this.props.name, value: color || '', margin: "dense", sx: {
|
|
197
197
|
'&.MuiFormControl-root': styles.textDense,
|
|
198
198
|
width: color ? 'calc(100% - 80px)' : 'calc(100% - 56px)',
|
|
199
199
|
mr: color ? undefined : 1,
|
|
200
200
|
}, onChange: e => this.handleChange(e.target.value) }),
|
|
201
|
-
!this.props.noInputField && color ? react_1.default.createElement(material_1.IconButton, { disabled: this.props.disabled, onClick: () => this.handleChange(''), size: "small", style: Object.assign(Object.assign({}, styles.delButton), (color ? undefined : { opacity: 0, cursor: 'default' })) },
|
|
201
|
+
!this.props.noInputField && color ? react_1.default.createElement(material_1.IconButton, { disabled: this.props.disabled, onClick: () => this.handleChange(''), size: "small", style: Object.assign(Object.assign({}, (this.props.label || this.props.name ? styles.delButton : undefined)), (color ? undefined : { opacity: 0, cursor: 'default' })) },
|
|
202
202
|
react_1.default.createElement(icons_material_1.Delete, null)) : null,
|
|
203
|
-
react_1.default.createElement("div",
|
|
204
|
-
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.color), { background: ColorPicker.getColor(color), width: this.props.noInputField ? (this.props.barWidth || 16) :
|
|
205
|
-
this.state.displayColorPicker && !this.props.disabled ? react_1.default.createElement(material_1.Menu, {
|
|
206
|
-
react_1.default.createElement(react_color_1.ChromePicker
|
|
207
|
-
// todo
|
|
208
|
-
// sx={styles.picker}
|
|
209
|
-
, {
|
|
210
|
-
// todo
|
|
211
|
-
// sx={styles.picker}
|
|
212
|
-
color: this.state.color || undefined, onChangeComplete: _color => this.handleChange(_color.rgb), styles: {
|
|
203
|
+
react_1.default.createElement(material_1.Box, { component: "div", onClick: e => !this.props.disabled && this.handleClick(e), title: i18n_1.default.t('ra_Select color'), sx: Object.assign(Object.assign(Object.assign({}, styles.swatch), (this.props.disabled ? styles.swatchDisabled : undefined)), { background: color ? undefined : 'transparent', border: color ? undefined : '1px dashed #ccc', boxSizing: 'border-box', marginTop: this.props.noInputField || !(this.props.label || this.props.name) ? 0 : undefined }) },
|
|
204
|
+
react_1.default.createElement("div", { style: Object.assign(Object.assign({}, styles.color), { background: ColorPicker.getColor(color), width: this.props.noInputField ? (this.props.barWidth || 16) : this.props.barWidth || 36 }) })),
|
|
205
|
+
this.state.displayColorPicker && !this.props.disabled ? react_1.default.createElement(material_1.Menu, { sx: Object.assign(Object.assign({}, styles.popover), { '&. MuiMenu-list': styles.popoverList }), anchorEl: this.state.anchorEl, open: !0, onClose: () => this.handleClose() },
|
|
206
|
+
react_1.default.createElement(react_color_1.ChromePicker, { color: this.state.color || undefined, onChangeComplete: (_color) => this.handleChange(_color.rgb), styles: {
|
|
213
207
|
default: {
|
|
214
208
|
picker: {
|
|
215
|
-
backgroundColor: '#
|
|
209
|
+
backgroundColor: ((_a = this.props.theme) === null || _a === void 0 ? void 0 : _a.palette.background.paper) || '#888',
|
|
216
210
|
},
|
|
217
211
|
},
|
|
218
212
|
} }),
|
package/Components/Utils.js
CHANGED
|
@@ -1199,7 +1199,7 @@ class Utils {
|
|
|
1199
1199
|
if (window.vendorPrefix && window.vendorPrefix !== '@@vendorPrefix@@') {
|
|
1200
1200
|
return 'light';
|
|
1201
1201
|
}
|
|
1202
|
-
themeName = themeName ||
|
|
1202
|
+
themeName = themeName || Utils.getThemeName();
|
|
1203
1203
|
return themeName === 'dark' || themeName === 'blue' ? 'dark' : 'light';
|
|
1204
1204
|
}
|
|
1205
1205
|
/**
|
package/GenericApp.js
CHANGED
|
@@ -299,7 +299,7 @@ class GenericApp extends Router_1.default {
|
|
|
299
299
|
console.log('Sentry initialized');
|
|
300
300
|
}
|
|
301
301
|
// read UUID and init sentry with it.
|
|
302
|
-
// for backward compatibility it will be processed separately from above logic: some adapters could still have this.sentryDSN as undefined
|
|
302
|
+
// for backward compatibility it will be processed separately from the above logic: some adapters could still have this.sentryDSN as undefined
|
|
303
303
|
if (!this.sentryInited && sentryEnabled) {
|
|
304
304
|
this.sentryInited = true;
|
|
305
305
|
waitPromise = this.socket.getObject('system.meta.uuid')
|
package/README.md
CHANGED
|
@@ -699,6 +699,11 @@ const styles: Record<string, any> = (theme: IobTheme) => ({
|
|
|
699
699
|
dialog: {
|
|
700
700
|
height: `calc(100% - ${theme.mixins.toolbar.minHeight}px)`,
|
|
701
701
|
padding: theme.spacing(1),
|
|
702
|
+
margin: theme.spacing(2),
|
|
703
|
+
gap: 5,
|
|
704
|
+
borderRadius: 5,
|
|
705
|
+
marginLeft: 10, // marginTop, marginRight, marginBottom
|
|
706
|
+
paddingLeft: 10, // paddingTop, paddingRight, paddingBottom
|
|
702
707
|
},
|
|
703
708
|
...
|
|
704
709
|
});
|
|
@@ -709,7 +714,12 @@ After:
|
|
|
709
714
|
const styles: Record<string, any> = {
|
|
710
715
|
dialog: (theme: IobTheme) => ({
|
|
711
716
|
height: `calc(100% - ${theme => theme.mixins.toolbar.minHeight}px)`,
|
|
712
|
-
p: 1,
|
|
717
|
+
p: 1, // or 8px, padding is OK too
|
|
718
|
+
m: '16px', // or 2, margin is OK too
|
|
719
|
+
gap: '5px',
|
|
720
|
+
borderRadius: '5px',
|
|
721
|
+
ml: '10px', // mt, mr, mb, but marginLeft, marginRight, marginBottom is OK too
|
|
722
|
+
pl: '10px', // pt, pr, pb, but paddingTop, paddingRight, paddingBottom is OK too
|
|
713
723
|
}),
|
|
714
724
|
};
|
|
715
725
|
```
|
|
@@ -717,11 +727,11 @@ const styles: Record<string, any> = {
|
|
|
717
727
|
- Modify `className`:
|
|
718
728
|
Before: `<div className={this.props.classes.box}>`
|
|
719
729
|
|
|
720
|
-
After: `<Box
|
|
730
|
+
After: `<Box sx={styles.box}>`
|
|
721
731
|
|
|
722
|
-
Before: `<
|
|
732
|
+
Before: `<span className={Utils.clsx(this.props.classes.box1, condition && this.props.classes.box2)}>`
|
|
723
733
|
|
|
724
|
-
After: `<Box component="
|
|
734
|
+
After: `<Box component="span" sx={Utils.getStyle(this.props.theme, this.props.classes.box1, condition && this.props.classes.box2)}>`
|
|
725
735
|
Or if no one style is a function: `<Box component="div" sx={{ ...this.props.classes.box1, ...(condition ? this.props.classes.box2 : undefined) }}>`
|
|
726
736
|
|
|
727
737
|
Do not use `sx` if the style is not dynamic (not a function). Use `style` instead.
|
|
@@ -759,7 +769,7 @@ The best practice is to replace `padding` with `p` and `margin` with `m`, so you
|
|
|
759
769
|
Before: `<Tooltip title={this.props.t('ra_Refresh tree')} classes={{ popper: styles.tooltip }}>`
|
|
760
770
|
|
|
761
771
|
After: `<Tooltip title={this.props.t('ra_Refresh tree')} componentsProps={{ popper: { sx: { pointerEvents: 'none' } } }}>`
|
|
762
|
-
Or: `<Tooltip title={this.props.t('ra_Refresh tree')}
|
|
772
|
+
Or: `<Tooltip title={this.props.t('ra_Refresh tree')} componentsProps={{ popper: { sx: styles.tooltip } }}>`
|
|
763
773
|
|
|
764
774
|
Before. `<AccordionSummary classes={{ root: styles.rootStyle, content: styles.content }}>`
|
|
765
775
|
|
|
@@ -771,6 +781,12 @@ The best practice is to replace `padding` with `p` and `margin` with `m`, so you
|
|
|
771
781
|
-->
|
|
772
782
|
|
|
773
783
|
## Changelog
|
|
784
|
+
### 6.0.14 (2024-07-07)
|
|
785
|
+
* (bluefox) Corrected theme type selection
|
|
786
|
+
|
|
787
|
+
### 6.0.13 (2024-06-30)
|
|
788
|
+
* (bluefox) Corrected color picker
|
|
789
|
+
|
|
774
790
|
### 6.0.12 (2024-06-29)
|
|
775
791
|
* (bluefox) Added support for the overrides in the theme
|
|
776
792
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/adapter-react-v5",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.14",
|
|
4
4
|
"description": "React classes to develop admin interfaces for ioBroker with react.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Denis Haev (bluefox)",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"@emotion/react": "^11.11.4",
|
|
31
31
|
"@emotion/styled": "^11.11.5",
|
|
32
32
|
"@iobroker/socket-client": "^2.4.18",
|
|
33
|
-
"@iobroker/types": "^6.0.
|
|
34
|
-
"@iobroker/js-controller-common": "^6.0.
|
|
35
|
-
"@iobroker/js-controller-common-db": "^6.0.
|
|
36
|
-
"@mui/icons-material": "^5.
|
|
37
|
-
"@mui/material": "^5.
|
|
38
|
-
"@mui/x-date-pickers": "^7.
|
|
39
|
-
"@sentry/browser": "^8.
|
|
33
|
+
"@iobroker/types": "^6.0.7-alpha.0-20240702-5c723a4ac",
|
|
34
|
+
"@iobroker/js-controller-common": "^6.0.6",
|
|
35
|
+
"@iobroker/js-controller-common-db": "^6.0.6",
|
|
36
|
+
"@mui/icons-material": "^5.16.0",
|
|
37
|
+
"@mui/material": "^5.16.0",
|
|
38
|
+
"@mui/x-date-pickers": "^7.9.0",
|
|
39
|
+
"@sentry/browser": "^8.15.0",
|
|
40
40
|
"react-color": "^2.19.3",
|
|
41
41
|
"react-colorful": "^5.6.1",
|
|
42
42
|
"react-cropper": "^2.3.3",
|