@iobroker/json-config 7.4.0 → 7.4.2
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 +44 -35
- package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocomplete.js +16 -1
- package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +19 -4
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.js +219 -138
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticDivider.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticHeader.js +12 -5
- package/build/JsonConfigComponent/ConfigStaticHeader.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticInfo.js +53 -15
- package/build/JsonConfigComponent/ConfigStaticInfo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.js +3 -3
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigText.js +35 -15
- package/build/JsonConfigComponent/ConfigText.js.map +1 -1
- package/build/types.d.ts +23 -5
- package/package.json +3 -3
|
@@ -14,19 +14,26 @@ const styles = {
|
|
|
14
14
|
};
|
|
15
15
|
class ConfigStaticHeader extends ConfigGeneric {
|
|
16
16
|
renderItem( /* error: string, disabled: boolean, defaultValue */) {
|
|
17
|
+
let component = 'h5';
|
|
17
18
|
switch ((this.props.schema.size || 5).toString()) {
|
|
18
19
|
case '1':
|
|
19
|
-
|
|
20
|
+
component = 'h1';
|
|
21
|
+
break;
|
|
20
22
|
case '2':
|
|
21
|
-
|
|
23
|
+
component = 'h2';
|
|
24
|
+
break;
|
|
22
25
|
case '3':
|
|
23
|
-
|
|
26
|
+
component = 'h3';
|
|
27
|
+
break;
|
|
24
28
|
case '4':
|
|
25
|
-
|
|
29
|
+
component = 'h4';
|
|
30
|
+
break;
|
|
26
31
|
case '5':
|
|
27
32
|
default:
|
|
28
|
-
|
|
33
|
+
component = 'h5';
|
|
34
|
+
break;
|
|
29
35
|
}
|
|
36
|
+
return (React.createElement(Box, { component: component, sx: styles.header }, this.getText(this.props.schema.label || this.props.schema.text, this.props.schema.noTranslation)));
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
export default ConfigStaticHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigStaticHeader.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,MAAM,EAAE,CAAC,KAAe,
|
|
1
|
+
{"version":3,"file":"ConfigStaticHeader.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAKpC,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,MAAM,EAAE,CAAC,KAAe,EAAuB,EAAE,CAAC,CAAC;QAC/C,KAAK,EAAE,MAAM;QACb,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI;QACtC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY;QACzC,OAAO,EAAE,gBAAgB;QACzB,YAAY,EAAE,KAAK;QACnB,cAAc,EAAE,CAAC;QACjB,gBAAgB,EAAE,CAAC;KACtB,CAAC;CACL,CAAC;AAMF,MAAM,kBAAmB,SAAQ,aAA4D;IACzF,UAAU,EAAC,oDAAoD;QAC3D,IAAI,SAAS,GAAqC,IAAI,CAAC;QACvD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC9C,KAAK,GAAG;gBACJ,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YAEV,KAAK,GAAG;gBACJ,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YAEV,KAAK,GAAG;gBACJ,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YAEV,KAAK,GAAG;gBACJ,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YAEV,KAAK,GAAG,CAAC;YACT;gBACI,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;SACb;QACD,OAAO,CACH,oBAAC,GAAG,IACA,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,CAAC,MAAM,IAEhB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAC/F,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box } from '@mui/material';\n\nimport type { IobTheme } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemStaticHeader } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n header: (theme: IobTheme): React.CSSProperties => ({\n width: '100%',\n background: theme.palette.primary.main,\n color: theme.palette.primary.contrastText,\n padding: '4px !important',\n borderRadius: '3px',\n marginBlockEnd: 0,\n marginBlockStart: 0,\n }),\n};\n\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemStaticHeader;\n}\n\nclass ConfigStaticHeader extends ConfigGeneric<ConfigInstanceSelectProps, ConfigGenericState> {\n renderItem(/* error: string, disabled: boolean, defaultValue */): JSX.Element {\n let component: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' = 'h5';\n switch ((this.props.schema.size || 5).toString()) {\n case '1':\n component = 'h1';\n break;\n\n case '2':\n component = 'h2';\n break;\n\n case '3':\n component = 'h3';\n break;\n\n case '4':\n component = 'h4';\n break;\n\n case '5':\n default:\n component = 'h5';\n break;\n }\n return (\n <Box\n component={component}\n sx={styles.header}\n >\n {this.getText(this.props.schema.label || this.props.schema.text, this.props.schema.noTranslation)}\n </Box>\n );\n }\n}\n\nexport default ConfigStaticHeader;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box } from '@mui/material';
|
|
2
|
+
import { Box, Checkbox } from '@mui/material';
|
|
3
3
|
import { ContentCopy } from '@mui/icons-material';
|
|
4
4
|
import { I18n, Icon, Utils } from '@iobroker/adapter-react-v5';
|
|
5
5
|
import ConfigGeneric from './ConfigGeneric';
|
|
@@ -82,6 +82,7 @@ function valueBlink(theme, color) {
|
|
|
82
82
|
const styles = {
|
|
83
83
|
label: {
|
|
84
84
|
fontWeight: 'bold',
|
|
85
|
+
whiteSpace: 'nowrap',
|
|
85
86
|
},
|
|
86
87
|
valueImage: {
|
|
87
88
|
maxHeight: '100%',
|
|
@@ -147,15 +148,43 @@ class ConfigStaticInfo extends ConfigGeneric {
|
|
|
147
148
|
valueTxt = valueTxt.replace('.', ',');
|
|
148
149
|
}
|
|
149
150
|
}
|
|
150
|
-
else {
|
|
151
|
+
else if (!this.props.schema.booleanAsCheckbox || typeof this.props.schema.data !== 'boolean') {
|
|
151
152
|
valueTxt = this.props.schema.data.toString();
|
|
152
153
|
}
|
|
153
|
-
|
|
154
|
+
let multiLine = false;
|
|
155
|
+
if (this.props.schema.booleanAsCheckbox && typeof this.props.schema.data === 'boolean') {
|
|
156
|
+
value = (React.createElement(Checkbox, { checked: !!value, disabled: true, size: this.props.schema.size === 'small'
|
|
157
|
+
? 'small'
|
|
158
|
+
: this.props.schema.size === 'large'
|
|
159
|
+
? 'large'
|
|
160
|
+
: undefined }));
|
|
161
|
+
}
|
|
162
|
+
else if (valueTxt.startsWith('data:image/')) {
|
|
154
163
|
value = (React.createElement("div", { style: { ...styles.value, ...styles.valueImage, ...(this.props.schema.styleValue || undefined) } },
|
|
155
164
|
React.createElement(Icon, { src: valueTxt })));
|
|
156
165
|
}
|
|
157
166
|
else {
|
|
158
|
-
|
|
167
|
+
const valStyle = { ...styles.value, ...(this.props.schema.styleValue || undefined) };
|
|
168
|
+
if (this.props.schema.html) {
|
|
169
|
+
value = (React.createElement("div", { style: valStyle, dangerouslySetInnerHTML: { __html: valueTxt } }));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
if (Array.isArray(this.props.schema.data)) {
|
|
173
|
+
multiLine = true;
|
|
174
|
+
value = (React.createElement("div", { style: valStyle }, this.props.schema.data.map((it, i) => (React.createElement("div", { key: i }, typeof it === 'object' || it === null || it === undefined
|
|
175
|
+
? JSON.stringify(it)
|
|
176
|
+
: it)))));
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
if (valueTxt.includes('\n')) {
|
|
180
|
+
multiLine = true;
|
|
181
|
+
value = React.createElement("div", { style: valStyle }, Utils.renderTextWithA(valueTxt));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
value = React.createElement("div", { style: valStyle }, valueTxt);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
159
188
|
}
|
|
160
189
|
if (this.props.schema.blinkOnUpdate && this.props.schema.blink) {
|
|
161
190
|
const style1 = valueBlinkOnce(this.props.theme, true, this.props.schema.blinkOnUpdate);
|
|
@@ -191,17 +220,26 @@ class ConfigStaticInfo extends ConfigGeneric {
|
|
|
191
220
|
window.alert(I18n.t('ra_Copied'));
|
|
192
221
|
} }));
|
|
193
222
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
223
|
+
const boxStyle = {
|
|
224
|
+
'& .staticCopyButton': {
|
|
225
|
+
display: 'none',
|
|
226
|
+
},
|
|
227
|
+
'& .staticCopyButton:action': {
|
|
228
|
+
transform: 'scale(0.9)',
|
|
229
|
+
},
|
|
230
|
+
'&:hover .staticCopyButton': {
|
|
231
|
+
display: 'block',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
if (this.props.schema.highlight) {
|
|
235
|
+
boxStyle['&:hover'] = {
|
|
236
|
+
backgroundColor: this.props.themeType === 'dark' ? '#51515180' : '#b8b8b880',
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
if (multiLine) {
|
|
240
|
+
divStyle.alignItems = 'top';
|
|
241
|
+
}
|
|
242
|
+
return (React.createElement(Box, { component: "div", style: divStyle, sx: boxStyle },
|
|
205
243
|
React.createElement("div", { style: { ...styles.label, ...(this.props.schema.styleLabel || undefined) } },
|
|
206
244
|
labelIcon,
|
|
207
245
|
label),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigStaticInfo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAiB,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,SAAS,cAAc,CAAC,KAAe,EAAE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AAC,WAAW,CAAC,CAAC,CAAC;gBACtC,CAAC,GACH,CACL,CAAC;SACL;QAED,OAAO,CACH,oBAAC,GAAG,IACA,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE;gBACA,qBAAqB,EAAE;oBACnB,OAAO,EAAE,MAAM;iBAClB;gBACD,4BAA4B,EAAE;oBAC1B,SAAS,EAAE,YAAY;iBAC1B;gBACD,2BAA2B,EAAE;oBACzB,OAAO,EAAE,OAAO;iBACnB;aACJ;YAED,6BAAK,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,SAAS,CAAC,EAAE;gBAC1E,SAAS;gBACT,KAAK,CACJ;YACL,KAAK;YACL,UAAU,CACT,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box } from '@mui/material';\nimport { ContentCopy } from '@mui/icons-material';\nimport { I18n, Icon, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemStaticInfo } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nfunction valueBlinkOnce(theme: IobTheme, force: boolean, color?: string | boolean): any {\n if (typeof color === 'string') {\n return {\n '@keyframes newValueAnimationOnceColor': {\n '0%': {\n color: force ? `${color} !important` : color,\n },\n '100%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? '#fff !important'\n : '#fff'\n : force\n ? '#000 !important'\n : '#000',\n },\n },\n animation: 'newValueAnimationOnceColor 2s ease-in-out',\n };\n }\n return {\n '@keyframes newValueAnimationOnce': {\n '0%': {\n color: force ? `#00f900 !important` : '#00f900',\n },\n '80%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? `#518851 !important`\n : '#518851'\n : force\n ? `#008000 !important`\n : '#008000',\n },\n '100%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? '#fff !important'\n : '#fff'\n : force\n ? '#000 !important'\n : '#000',\n },\n },\n animation: 'newValueAnimationOnce 2s ease-in-out',\n };\n}\n\nfunction valueBlink(theme: IobTheme, color?: string | boolean): any {\n if (typeof color === 'string') {\n return {\n '@keyframes blinkAnimationColor': {\n '0%': {\n color,\n },\n '100%': {\n color: theme.palette.mode === 'dark' ? '#fff' : '#000',\n },\n },\n animation: 'blinkAnimationColor 2s ease-in-out infinite',\n };\n }\n return {\n '@keyframes blinkAnimation': {\n '0%': {\n color: '#00f900',\n },\n '80%': {\n color: theme.palette.mode === 'dark' ? '#518851' : '#008000',\n },\n '100%': {\n color: theme.palette.mode === 'dark' ? '#fff' : '#000',\n },\n },\n animation: 'blinkAnimation 2s ease-in-out infinite',\n };\n}\n\nconst styles: Record<string, any> = {\n label: {\n fontWeight: 'bold',\n },\n valueImage: {\n maxHeight: '100%',\n },\n valueAndUnit: {\n display: 'flex',\n gap: 4,\n alignItems: 'baseline',\n },\n value: {},\n unit: {\n fontSize: 'smaller',\n opacity: 0.7,\n },\n};\n\ninterface ConfigStaticInfoProps extends ConfigGenericProps {\n schema: ConfigItemStaticInfo;\n}\n\nclass ConfigStaticInfo extends ConfigGeneric<ConfigStaticInfoProps, ConfigGenericState> {\n renderItem(_error: string): JSX.Element {\n let label: string | JSX.Element | JSX.Element[] = this.getText(\n this.props.schema.text || this.props.schema.label,\n this.props.schema.noTranslation,\n );\n if (this.props.schema.addColon && typeof label === 'string' && !label.trim().endsWith(':')) {\n label = `${label.trim()}:`;\n }\n\n if (\n label &&\n (label.includes('<a ') || label.includes('<br') || label.includes('<b>') || label.includes('<i>'))\n ) {\n label = Utils.renderTextWithA(label);\n }\n let fontSize: number | undefined;\n if (this.props.schema.size === 'normal') {\n fontSize = 16;\n } else if (this.props.schema.size === 'large') {\n fontSize = 20;\n } else if (typeof this.props.schema.size === 'number') {\n fontSize = this.props.schema.size;\n }\n\n const divStyle: React.CSSProperties = {\n width: '100%',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n fontSize,\n };\n\n if (this.props.schema.narrow) {\n divStyle.gap = 8;\n } else {\n divStyle.justifyContent = 'space-between';\n }\n\n let value: React.JSX.Element;\n let valueTxt: string;\n if (this.props.schema.data && typeof this.props.schema.data === 'object' && this.props.schema.data.en) {\n valueTxt = this.getText(this.props.schema.data);\n } else if (\n typeof this.props.schema.data === 'object' ||\n this.props.schema.data === undefined ||\n this.props.schema.data === null\n ) {\n valueTxt = JSON.stringify(this.props.schema.data);\n } else if (typeof this.props.schema.data === 'number') {\n valueTxt = this.props.schema.data.toString();\n if (this.props.isFloatComma) {\n valueTxt = valueTxt.replace('.', ',');\n }\n } else {\n valueTxt = this.props.schema.data.toString();\n }\n if (valueTxt.startsWith('data:image/')) {\n value = (\n <div style={{ ...styles.value, ...styles.valueImage, ...(this.props.schema.styleValue || undefined) }}>\n <Icon src={valueTxt} />\n </div>\n );\n } else {\n value = <div style={{ ...styles.value, ...(this.props.schema.styleValue || undefined) }}>{valueTxt}</div>;\n }\n if (this.props.schema.blinkOnUpdate && this.props.schema.blink) {\n const style1 = valueBlinkOnce(this.props.theme, true, this.props.schema.blinkOnUpdate);\n const style2 = valueBlink(this.props.theme, this.props.schema.blink);\n value = (\n <Box\n key={valueTxt}\n sx={{ ...style1, ...style2 }}\n >\n {value}\n </Box>\n );\n } else if (this.props.schema.blinkOnUpdate) {\n const style = valueBlinkOnce(this.props.theme, false, this.props.schema.blinkOnUpdate);\n value = (\n <Box\n key={valueTxt}\n sx={style}\n >\n {value}\n </Box>\n );\n } else if (this.props.schema.blink) {\n const style = valueBlink(this.props.theme, this.props.schema.blink);\n value = <Box sx={style}>{value}</Box>;\n }\n\n if (this.props.schema.unit) {\n value = (\n <div style={styles.valueAndUnit}>\n {value}\n <div style={{ ...styles.unit, ...(this.props.schema.styleUnit || undefined) }}>\n {this.getText(this.props.schema.unit)}\n </div>\n </div>\n );\n }\n\n let labelIcon: React.JSX.Element | undefined;\n if (this.props.schema.labelIcon) {\n labelIcon = (\n <Icon\n src={this.props.schema.labelIcon}\n style={{ marginRight: 4 }}\n />\n );\n }\n let copyButton: React.JSX.Element | undefined;\n if (this.props.schema.copyToClipboard) {\n copyButton = (\n <ContentCopy\n className=\"staticCopyButton\"\n style={{\n position: 'absolute',\n top: 'calc(50% - 12px)',\n right: 0,\n cursor: 'pointer',\n }}\n onClick={() => {\n Utils.copyToClipboard(valueTxt);\n window.alert(I18n.t('ra_Copied'));\n }}\n />\n );\n }\n\n return (\n <Box\n component=\"div\"\n style={divStyle}\n sx={{\n '& .staticCopyButton': {\n display: 'none',\n },\n '& .staticCopyButton:action': {\n transform: 'scale(0.9)',\n },\n '&:hover .staticCopyButton': {\n display: 'block',\n },\n }}\n >\n <div style={{ ...styles.label, ...(this.props.schema.styleLabel || undefined) }}>\n {labelIcon}\n {label}\n </div>\n {value}\n {copyButton}\n </Box>\n );\n }\n}\n\nexport default ConfigStaticInfo;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigStaticInfo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticInfo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAiB,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,SAAS,cAAc,CAAC,KAAe,EAAE,KAAc,EAAE,KAAwB;IAC7E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO;YACH,uCAAuC,EAAE;gBACrC,IAAI,EAAE;oBACF,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAC,KA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AAkB;oBACvB,KAAK,EAAE,CAAC;oBACR,MAAM,EAAE,SAAS;iBACpB,EACD,OAAO,EAAE,GAAG,EAAE;oBACV,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;oBAChC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;gBACtC,CAAC,GACH,CACL,CAAC;SACL;QAED,MAAM,QAAQ,GAAwB;YAClC,qBAAqB,EAAE;gBACnB,OAAO,EAAE,MAAM;aAClB;YACD,4BAA4B,EAAE;gBAC1B,SAAS,EAAE,YAAY;aAC1B;YACD,2BAA2B,EAAE;gBACzB,OAAO,EAAE,OAAO;aACnB;SACJ,CAAC;QACF,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE;YAC7B,QAAQ,CAAC,SAAS,CAAC,GAAG;gBAClB,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW;aAC/E,CAAC;SACL;QACD,IAAI,SAAS,EAAE;YACX,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC;SAC/B;QAED,OAAO,CACH,oBAAC,GAAG,IACA,SAAS,EAAC,KAAK,EACf,KAAK,EAAE,QAAQ,EACf,EAAE,EAAE,QAAQ;YAEZ,6BAAK,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,IAAI,SAAS,CAAC,EAAE;gBAC1E,SAAS;gBACT,KAAK,CACJ;YACL,KAAK;YACL,UAAU,CACT,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box, Checkbox } from '@mui/material';\nimport { ContentCopy } from '@mui/icons-material';\nimport { I18n, Icon, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemStaticInfo } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nfunction valueBlinkOnce(theme: IobTheme, force: boolean, color?: string | boolean): any {\n if (typeof color === 'string') {\n return {\n '@keyframes newValueAnimationOnceColor': {\n '0%': {\n color: force ? `${color} !important` : color,\n },\n '100%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? '#fff !important'\n : '#fff'\n : force\n ? '#000 !important'\n : '#000',\n },\n },\n animation: 'newValueAnimationOnceColor 2s ease-in-out',\n };\n }\n return {\n '@keyframes newValueAnimationOnce': {\n '0%': {\n color: force ? `#00f900 !important` : '#00f900',\n },\n '80%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? `#518851 !important`\n : '#518851'\n : force\n ? `#008000 !important`\n : '#008000',\n },\n '100%': {\n color:\n theme.palette.mode === 'dark'\n ? force\n ? '#fff !important'\n : '#fff'\n : force\n ? '#000 !important'\n : '#000',\n },\n },\n animation: 'newValueAnimationOnce 2s ease-in-out',\n };\n}\n\nfunction valueBlink(theme: IobTheme, color?: string | boolean): any {\n if (typeof color === 'string') {\n return {\n '@keyframes blinkAnimationColor': {\n '0%': {\n color,\n },\n '100%': {\n color: theme.palette.mode === 'dark' ? '#fff' : '#000',\n },\n },\n animation: 'blinkAnimationColor 2s ease-in-out infinite',\n };\n }\n return {\n '@keyframes blinkAnimation': {\n '0%': {\n color: '#00f900',\n },\n '80%': {\n color: theme.palette.mode === 'dark' ? '#518851' : '#008000',\n },\n '100%': {\n color: theme.palette.mode === 'dark' ? '#fff' : '#000',\n },\n },\n animation: 'blinkAnimation 2s ease-in-out infinite',\n };\n}\n\nconst styles: Record<string, any> = {\n label: {\n fontWeight: 'bold',\n whiteSpace: 'nowrap',\n },\n valueImage: {\n maxHeight: '100%',\n },\n valueAndUnit: {\n display: 'flex',\n gap: 4,\n alignItems: 'baseline',\n },\n value: {},\n unit: {\n fontSize: 'smaller',\n opacity: 0.7,\n },\n};\n\ninterface ConfigStaticInfoProps extends ConfigGenericProps {\n schema: ConfigItemStaticInfo;\n}\n\nclass ConfigStaticInfo extends ConfigGeneric<ConfigStaticInfoProps, ConfigGenericState> {\n renderItem(_error: string): JSX.Element {\n let label: string | JSX.Element | JSX.Element[] = this.getText(\n this.props.schema.text || this.props.schema.label,\n this.props.schema.noTranslation,\n );\n if (this.props.schema.addColon && typeof label === 'string' && !label.trim().endsWith(':')) {\n label = `${label.trim()}:`;\n }\n\n if (\n label &&\n (label.includes('<a ') || label.includes('<br') || label.includes('<b>') || label.includes('<i>'))\n ) {\n label = Utils.renderTextWithA(label);\n }\n let fontSize: number | undefined;\n if (this.props.schema.size === 'normal') {\n fontSize = 16;\n } else if (this.props.schema.size === 'large') {\n fontSize = 20;\n } else if (typeof this.props.schema.size === 'number') {\n fontSize = this.props.schema.size;\n }\n\n const divStyle: React.CSSProperties = {\n width: '100%',\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n position: 'relative',\n fontSize,\n };\n\n if (this.props.schema.narrow) {\n divStyle.gap = 8;\n } else {\n divStyle.justifyContent = 'space-between';\n }\n\n let value: React.JSX.Element;\n let valueTxt: string;\n if (this.props.schema.data && typeof this.props.schema.data === 'object' && this.props.schema.data.en) {\n valueTxt = this.getText(this.props.schema.data);\n } else if (\n typeof this.props.schema.data === 'object' ||\n this.props.schema.data === undefined ||\n this.props.schema.data === null\n ) {\n valueTxt = JSON.stringify(this.props.schema.data);\n } else if (typeof this.props.schema.data === 'number') {\n valueTxt = this.props.schema.data.toString();\n if (this.props.isFloatComma) {\n valueTxt = valueTxt.replace('.', ',');\n }\n } else if (!this.props.schema.booleanAsCheckbox || typeof this.props.schema.data !== 'boolean') {\n valueTxt = this.props.schema.data.toString();\n }\n let multiLine = false;\n\n if (this.props.schema.booleanAsCheckbox && typeof this.props.schema.data === 'boolean') {\n value = (\n <Checkbox\n checked={!!value}\n disabled\n size={\n this.props.schema.size === 'small'\n ? 'small'\n : this.props.schema.size === 'large'\n ? 'large'\n : undefined\n }\n />\n );\n } else if (valueTxt.startsWith('data:image/')) {\n value = (\n <div style={{ ...styles.value, ...styles.valueImage, ...(this.props.schema.styleValue || undefined) }}>\n <Icon src={valueTxt} />\n </div>\n );\n } else {\n const valStyle: React.CSSProperties = { ...styles.value, ...(this.props.schema.styleValue || undefined) };\n if (this.props.schema.html) {\n value = (\n <div\n style={valStyle}\n dangerouslySetInnerHTML={{ __html: valueTxt }}\n />\n );\n } else {\n if (Array.isArray(this.props.schema.data)) {\n multiLine = true;\n value = (\n <div style={valStyle}>\n {this.props.schema.data.map((it, i) => (\n <div key={i}>\n {typeof it === 'object' || it === null || it === undefined\n ? JSON.stringify(it)\n : it}\n </div>\n ))}\n </div>\n );\n } else {\n if (valueTxt.includes('\\n')) {\n multiLine = true;\n value = <div style={valStyle}>{Utils.renderTextWithA(valueTxt)}</div>;\n } else {\n value = <div style={valStyle}>{valueTxt}</div>;\n }\n }\n }\n }\n\n if (this.props.schema.blinkOnUpdate && this.props.schema.blink) {\n const style1 = valueBlinkOnce(this.props.theme, true, this.props.schema.blinkOnUpdate);\n const style2 = valueBlink(this.props.theme, this.props.schema.blink);\n value = (\n <Box\n key={valueTxt}\n sx={{ ...style1, ...style2 }}\n >\n {value}\n </Box>\n );\n } else if (this.props.schema.blinkOnUpdate) {\n const style = valueBlinkOnce(this.props.theme, false, this.props.schema.blinkOnUpdate);\n value = (\n <Box\n key={valueTxt}\n sx={style}\n >\n {value}\n </Box>\n );\n } else if (this.props.schema.blink) {\n const style = valueBlink(this.props.theme, this.props.schema.blink);\n value = <Box sx={style}>{value}</Box>;\n }\n\n if (this.props.schema.unit) {\n value = (\n <div style={styles.valueAndUnit}>\n {value}\n <div style={{ ...styles.unit, ...(this.props.schema.styleUnit || undefined) }}>\n {this.getText(this.props.schema.unit)}\n </div>\n </div>\n );\n }\n\n let labelIcon: React.JSX.Element | undefined;\n if (this.props.schema.labelIcon) {\n labelIcon = (\n <Icon\n src={this.props.schema.labelIcon}\n style={{ marginRight: 4 }}\n />\n );\n }\n let copyButton: React.JSX.Element | undefined;\n if (this.props.schema.copyToClipboard) {\n copyButton = (\n <ContentCopy\n className=\"staticCopyButton\"\n style={{\n position: 'absolute',\n top: 'calc(50% - 12px)',\n right: 0,\n cursor: 'pointer',\n }}\n onClick={() => {\n Utils.copyToClipboard(valueTxt);\n window.alert(I18n.t('ra_Copied'));\n }}\n />\n );\n }\n\n const boxStyle: Record<string, any> = {\n '& .staticCopyButton': {\n display: 'none',\n },\n '& .staticCopyButton:action': {\n transform: 'scale(0.9)',\n },\n '&:hover .staticCopyButton': {\n display: 'block',\n },\n };\n if (this.props.schema.highlight) {\n boxStyle['&:hover'] = {\n backgroundColor: this.props.themeType === 'dark' ? '#51515180' : '#b8b8b880',\n };\n }\n if (multiLine) {\n divStyle.alignItems = 'top';\n }\n\n return (\n <Box\n component=\"div\"\n style={divStyle}\n sx={boxStyle}\n >\n <div style={{ ...styles.label, ...(this.props.schema.styleLabel || undefined) }}>\n {labelIcon}\n {label}\n </div>\n {value}\n {copyButton}\n </Box>\n );\n }\n}\n\nexport default ConfigStaticInfo;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigStaticText.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAiB,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KAChB;IACD,IAAI,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC;QACxB,cAAc,EAAE,WAAW;QAC3B,KAAK,EAAE,KAAK,CAAC,OAAO,CA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AAM,IAAI,QAAQ;gCAC5C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;6BACjC,CAAC,CAAC;yBACN;6BAAM;4BACH,MAAM,CACF,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,EACpC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CACrD,CAAC;yBACL;qBACJ;gBACL,CAAC;gBACH,CAAC,CAAC,IAAI,IAGb,IAAI,CACH,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box, Button } from '@mui/material';\n\nimport { type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemStaticText } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n height: '100%',\n width: '100%',\n },\n link: (theme: IobTheme) => ({\n textDecoration: 'underline',\n color: theme.palette.mode === 'dark' ? '#4dabf5' : '#254e72',\n cursor: 'pointer',\n }),\n};\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nfunction onLink(href: string, target: '_blank' | '_self' | string, instanceId: string): void {\n let _target;\n let url = '';\n if (!href) {\n url = `#tab-instances/config/${instanceId}`;\n _target = target || '_self';\n } else if (href.toString().startsWith('#')) {\n _target = target || '_self';\n url = href;\n } else if (href.toString().startsWith('/')) {\n _target = target || '_self';\n url = href;\n } else if (href.startsWith('http://') || href.startsWith('https://')) {\n _target = target || '_blank';\n url = href;\n } else {\n url = `#tab-instances/config/${instanceId}/${href}`;\n _target = target || '_self';\n }\n if (_target === '_self') {\n // close dialog\n setTimeout(\n (_url: string) => {\n if (_url.startsWith('#')) {\n window.location.hash = _url;\n } else if (_url.startsWith('/')) {\n url = `${window.location.protocol}:${window.location.host}${url}`;\n } else if (_url.startsWith('http://') || _url.startsWith('https://')) {\n window.location.href = _url;\n }\n },\n 100,\n url,\n );\n } else {\n if (url.startsWith('#')) {\n url = `${window.location.protocol}:${window.location.host}${window.location.pathname}${url}`;\n } else if (url.startsWith('/')) {\n url = `${window.location.protocol}:${window.location.host}${url}`;\n }\n\n window.open(url, _target);\n }\n}\n\ninterface ConfigStaticTextProps extends ConfigGenericProps {\n schema: ConfigItemStaticText;\n}\n\nclass ConfigStaticText extends ConfigGeneric<ConfigStaticTextProps, ConfigGenericState> {\n renderItem(_error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (this.props.schema.button) {\n const icon = this.getIcon();\n return (\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n style={{ ...styles.fullWidth, ...(this.props.schema.controlStyle || undefined) }}\n disabled={disabled}\n startIcon={icon}\n onClick={\n this.props.schema.href\n ? () => {\n // calculate one more time just before call\n const href = this.props.schema.href\n ? this.getText(this.props.schema.href, true)\n : null;\n if (href) {\n if (this.props.onBackEndCommand) {\n this.props.onBackEndCommand({\n command: 'link',\n url: href,\n target: this.props.schema.target,\n close: this.props.schema.close,\n });\n } else {\n onLink(\n href,\n this.props.schema.target,\n `${this.props.adapterName}.${this.props.instance}`,\n );\n }\n }\n }\n : null\n }\n >\n {this.getText(this.props.schema.text || this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n );\n }\n let text: string | JSX.Element | JSX.Element[] = this.getText(\n this.props.schema.text || this.props.schema.label,\n this.props.schema.noTranslation,\n );\n if (text && (text.includes('<a ') || text.includes('<br') || text.includes('<b>') || text.includes('<i>'))) {\n text = Utils.renderTextWithA(text);\n }\n\n return (\n <Box\n component=\"span\"\n style={{ ...(this.props.schema.controlStyle || undefined) }}\n sx={this.props.schema.href ? styles.link : undefined}\n onClick={\n this.props.schema.href\n ? () => {\n // calculate one more time just before call\n const href = this.props.schema.href ? this.getText(this.props.schema.href, true) : null;\n if (href) {\n if (this.props.onBackEndCommand) {\n this.props.onBackEndCommand({\n command: 'link',\n url: href,\n target: this.props.schema.target || '_blank',\n close: this.props.schema.close,\n });\n } else {\n onLink(\n href,\n this.props.schema.target || '_blank',\n `${this.props.adapterName}.${this.props.instance}`,\n );\n }\n }\n }\n : null\n }\n >\n {text}\n </Box>\n );\n }\n}\n\nexport default ConfigStaticText;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigStaticText.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigStaticText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAiB,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGlE,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,MAAM,EAAE,MAAM;QACd,KAAK,EAAE,MAAM;KAChB;IACD,IAAI,EAAE,CAAC,KAAe,EAAuB,EAAE,CAAC,CAAC;QAC7C,cAAc,EAAE,WAAW;QAC3B,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QAC5D,MAAM,EAAE,SAAS;KACpB,CAAC;CACL,CAAC;AAEF,6EAA6E;AAC7E,SAAS,MAAM,CAAC,IAAY,EAAE,MAAmC,EAAE,UAAkB;IACjF,IAAI,OAAO,CAAC;IACZ,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,CAAC,IAAI,EAAE;QACP,GAAG,GAAG,yBAAyB,UAAU,EAAE,CAAC;QAC5C,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC;KAC/B;SAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACxC,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC;QAC5B,GAAG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AAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,IAAI,SAAS,CAAC,EAAE,EAC3D,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACpD,OAAO,EACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI;gBAClB,CAAC,CAAC,GAAG,EAAE;oBACD,2CAA2C;oBAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;oBACxF,IAAI,IAAI,EAAE;wBACN,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE;4BAC7B,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC;gCACxB,OAAO,EAAE,MAAM;gCACf,GAAG,EAAE,IAAI;gCACT,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ;gCAC5C,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK;6BACjC,CAAC,CAAC;yBACN;6BAAM;4BACH,MAAM,CACF,IAAI,EACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,QAAQ,EACpC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CACrD,CAAC;yBACL;qBACJ;gBACL,CAAC;gBACH,CAAC,CAAC,IAAI,IAGb,IAAI,CACH,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Box, Button } from '@mui/material';\n\nimport { type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemStaticText } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n height: '100%',\n width: '100%',\n },\n link: (theme: IobTheme): React.CSSProperties => ({\n textDecoration: 'underline',\n color: theme.palette.mode === 'dark' ? '#4dabf5' : '#254e72',\n cursor: 'pointer',\n }),\n};\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nfunction onLink(href: string, target: '_blank' | '_self' | string, instanceId: string): void {\n let _target;\n let url = '';\n if (!href) {\n url = `#tab-instances/config/${instanceId}`;\n _target = target || '_self';\n } else if (href.toString().startsWith('#')) {\n _target = target || '_self';\n url = href;\n } else if (href.toString().startsWith('/')) {\n _target = target || '_self';\n url = href;\n } else if (href.startsWith('http://') || href.startsWith('https://')) {\n _target = target || '_blank';\n url = href;\n } else {\n url = `#tab-instances/config/${instanceId}/${href}`;\n _target = target || '_self';\n }\n if (_target === '_self') {\n // close dialog\n setTimeout(\n (_url: string) => {\n if (_url.startsWith('#')) {\n window.location.hash = _url;\n } else if (_url.startsWith('/')) {\n url = `${window.location.protocol}:${window.location.host}${url}`;\n } else if (_url.startsWith('http://') || _url.startsWith('https://')) {\n window.location.href = _url;\n }\n },\n 100,\n url,\n );\n } else {\n if (url.startsWith('#')) {\n url = `${window.location.protocol}:${window.location.host}${window.location.pathname}${url}`;\n } else if (url.startsWith('/')) {\n url = `${window.location.protocol}:${window.location.host}${url}`;\n }\n\n window.open(url, _target);\n }\n}\n\ninterface ConfigStaticTextProps extends ConfigGenericProps {\n schema: ConfigItemStaticText;\n}\n\nclass ConfigStaticText extends ConfigGeneric<ConfigStaticTextProps, ConfigGenericState> {\n renderItem(_error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (this.props.schema.button) {\n const icon = this.getIcon();\n return (\n <Button\n variant={this.props.schema.variant || undefined}\n color={this.props.schema.color || 'grey'}\n style={{ ...styles.fullWidth, ...(this.props.schema.controlStyle || undefined) }}\n disabled={disabled}\n startIcon={icon}\n onClick={\n this.props.schema.href\n ? () => {\n // calculate one more time just before call\n const href = this.props.schema.href\n ? this.getText(this.props.schema.href, true)\n : null;\n if (href) {\n if (this.props.onBackEndCommand) {\n this.props.onBackEndCommand({\n command: 'link',\n url: href,\n target: this.props.schema.target,\n close: this.props.schema.close,\n });\n } else {\n onLink(\n href,\n this.props.schema.target,\n `${this.props.adapterName}.${this.props.instance}`,\n );\n }\n }\n }\n : null\n }\n >\n {this.getText(this.props.schema.text || this.props.schema.label, this.props.schema.noTranslation)}\n </Button>\n );\n }\n let text: string | JSX.Element | JSX.Element[] = this.getText(\n this.props.schema.text || this.props.schema.label,\n this.props.schema.noTranslation,\n );\n if (text && (text.includes('<a ') || text.includes('<br') || text.includes('<b>') || text.includes('<i>'))) {\n text = Utils.renderTextWithA(text);\n }\n\n return (\n <Box\n component=\"span\"\n style={{ ...(this.props.schema.controlStyle || undefined) }}\n sx={this.props.schema.href ? styles.link : undefined}\n onClick={\n this.props.schema.href\n ? () => {\n // calculate one more time just before call\n const href = this.props.schema.href ? this.getText(this.props.schema.href, true) : null;\n if (href) {\n if (this.props.onBackEndCommand) {\n this.props.onBackEndCommand({\n command: 'link',\n url: href,\n target: this.props.schema.target || '_blank',\n close: this.props.schema.close,\n });\n } else {\n onLink(\n href,\n this.props.schema.target || '_blank',\n `${this.props.adapterName}.${this.props.instance}`,\n );\n }\n }\n }\n : null\n }\n >\n {text}\n </Box>\n );\n }\n}\n\nexport default ConfigStaticText;\n"]}
|
|
@@ -39,7 +39,7 @@ const styles = {
|
|
|
39
39
|
display: 'flex',
|
|
40
40
|
justifyContent: 'space-between',
|
|
41
41
|
},
|
|
42
|
-
// highlight: (theme: IobTheme) => (theme.palette.mode === 'light'
|
|
42
|
+
// highlight: (theme: IobTheme): React.CSSProperties => (theme.palette.mode === 'light'
|
|
43
43
|
// ? {
|
|
44
44
|
// color: theme.palette.secondary.main,
|
|
45
45
|
// // backgroundColor: lighten(theme.palette.secondary.light, 0.85),
|
|
@@ -260,14 +260,14 @@ class ConfigTable extends ConfigGeneric {
|
|
|
260
260
|
[attrItem]: schemaForAttribute,
|
|
261
261
|
},
|
|
262
262
|
};
|
|
263
|
-
return (React.createElement(ConfigPanel, {
|
|
263
|
+
return (React.createElement(ConfigPanel, { DeviceManager: this.props.DeviceManager, adapterName: this.props.adapterName, alive: this.props.alive, arrayIndex: idx, changed: this.props.changed, common: this.props.common, custom: true, customs: this.props.customs, data: data, dateFormat: this.props.dateFormat, forceUpdate: this.props.forceUpdate, globalData: this.props.data, imagePrefix: this.props.imagePrefix, index: idx + this.state.iteration, instance: this.props.instance, instanceObj: this.props.instanceObj, isFloatComma: this.props.isFloatComma, onBackEndCommand: this.props.onBackEndCommand, onChange: (attr, valueChange) => {
|
|
264
264
|
const newObj = JSON.parse(JSON.stringify(this.state.value));
|
|
265
265
|
newObj[idx][attr] = valueChange;
|
|
266
266
|
this.setState({ value: newObj }, () => {
|
|
267
267
|
this.validateUniqueProps();
|
|
268
268
|
this.onChangeWrapper(newObj, true);
|
|
269
269
|
});
|
|
270
|
-
}, onError: (error, attr) => this.onError(error, attr),
|
|
270
|
+
}, onCommandRunning: this.props.onCommandRunning, onError: (error, attr) => this.onError(error, attr), originalData: this.props.originalData, schema: schemaItem, socket: this.props.socket, systemConfig: this.props.systemConfig, table: true, theme: this.props.theme, themeName: this.props.themeName, themeType: this.props.themeType }));
|
|
271
271
|
}
|
|
272
272
|
/**
|
|
273
273
|
* Validate that columns configured in `uniqueColumns` have unique values
|