@iobroker/json-config 8.2.7 → 8.2.10
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 +15 -6
- package/build/JsonConfigComponent/ConfigObjectId.d.ts +2 -0
- package/build/JsonConfigComponent/ConfigObjectId.js +51 -3
- package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.d.ts +2 -0
- package/build/JsonConfigComponent/ConfigSelect.js +30 -6
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/types.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -447,6 +447,7 @@ Select function from `enum.func` (With color and icon) - (only Admin6)
|
|
|
447
447
|
| `options` | object with labels, optional translations, optional grouping and values |
|
|
448
448
|
| `multiple` | Multiple choice select (From 7.6.5) |
|
|
449
449
|
| `showAllValues` | show item even if no label was found for it (by multiple), default=`true` |
|
|
450
|
+
| `format` | Render format: `"dropdown"` (default) or `"radio"` to display options as radio buttons instead of a dropdown |
|
|
450
451
|
|
|
451
452
|
Each option in `options` can have:
|
|
452
453
|
|
|
@@ -562,12 +563,13 @@ See also [OAUTH2.md](OAUTH2.md) for more information.
|
|
|
562
563
|
|
|
563
564
|
object ID: show it with name, color and icon
|
|
564
565
|
|
|
565
|
-
| Property | Description
|
|
566
|
-
|
|
567
|
-
| `types` | Desired type: `channel`, `device`, ... (has only `state` by default). It is plural, because `type` is already occupied.
|
|
568
|
-
| `root` | [optional] Show only this root object and its children
|
|
569
|
-
| `customFilter` | [optional] Cannot be used together with `type` settings. It is an object and not a JSON string.
|
|
570
|
-
| `filterFunc` | [optional] Cannot be used together with `type` settings. It is a function that will be called for every object and must return true or false. Example: `obj.common.type === 'number'`
|
|
566
|
+
| Property | Description |
|
|
567
|
+
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
568
|
+
| `types` | Desired type: `channel`, `device`, ... (has only `state` by default). It is plural, because `type` is already occupied. |
|
|
569
|
+
| `root` | [optional] Show only this root object and its children |
|
|
570
|
+
| `customFilter` | [optional] Cannot be used together with `type` settings. It is an object and not a JSON string. |
|
|
571
|
+
| `filterFunc` | [optional] Cannot be used together with `type` settings. It is a function that will be called for every object and must return true or false. Example: `obj.common.type === 'number'` |
|
|
572
|
+
| `fillOnSelect` | [optional] Fill other config fields when an object ID is selected. Format: `pathInObject=>attr,pathInObject=>attr(X)`. Append `(X)` to overwrite non-empty fields. Example: `common.name=>name,common.color=>color(X)` fills the `name` field with the object's name and overwrites `color` with the object's color. |
|
|
571
573
|
|
|
572
574
|
#### Examples for `customFilter`
|
|
573
575
|
|
|
@@ -1745,6 +1747,13 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
|
|
|
1745
1747
|
### **WORK IN PROGRESS**
|
|
1746
1748
|
-->
|
|
1747
1749
|
## Changelog
|
|
1750
|
+
### 8.2.10 (2026-03-20)
|
|
1751
|
+
- (@GermanBluefox) Correcting unit in schema
|
|
1752
|
+
- (@GermanBluefox) Fill other config fields when an object ID is selected
|
|
1753
|
+
|
|
1754
|
+
### 8.2.8 (2026-03-15)
|
|
1755
|
+
- (@GermanBluefox) Added radio button control for the state component ('select')
|
|
1756
|
+
|
|
1748
1757
|
### 8.2.7 (2026-03-14)
|
|
1749
1758
|
- (@GermanBluefox) Made the secondary text in 'select' and 'selectSendTo' smaller, italic and semi-transparent
|
|
1750
1759
|
|
|
@@ -9,7 +9,9 @@ interface ConfigObjectIdState extends ConfigGenericState {
|
|
|
9
9
|
initialized?: boolean;
|
|
10
10
|
}
|
|
11
11
|
declare class ConfigObjectId extends ConfigGeneric<ConfigObjectIdProps, ConfigObjectIdState> {
|
|
12
|
+
private fillOnSelect;
|
|
12
13
|
componentDidMount(): void;
|
|
14
|
+
onObjectChanged: (attr: string, value: string) => void;
|
|
13
15
|
renderItem(error: string, disabled: boolean): JSX.Element;
|
|
14
16
|
}
|
|
15
17
|
export default ConfigObjectId;
|
|
@@ -13,12 +13,56 @@ const styles = {
|
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
class ConfigObjectId extends ConfigGeneric {
|
|
16
|
+
fillOnSelect = [];
|
|
16
17
|
componentDidMount() {
|
|
17
18
|
super.componentDidMount();
|
|
18
19
|
const { data, attr } = this.props;
|
|
19
20
|
const value = ConfigGeneric.getValue(data, attr) || '';
|
|
21
|
+
if (this.props.schema.fillOnSelect) {
|
|
22
|
+
// parse common.name=>name,common.color=>color(X)
|
|
23
|
+
const items = this.props.schema.fillOnSelect.split(',').map(it => it.trim());
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
const parts = item.split('=>');
|
|
26
|
+
if (parts.length === 2) {
|
|
27
|
+
const fillItem = {
|
|
28
|
+
pathInObject: parts[0],
|
|
29
|
+
attr: parts[1],
|
|
30
|
+
};
|
|
31
|
+
if (fillItem.attr.includes('(X)') || fillItem.attr.includes('(x)')) {
|
|
32
|
+
fillItem.overwrite = true;
|
|
33
|
+
fillItem.attr = fillItem.attr.replace(/\(X\)|\(x\)/g, '');
|
|
34
|
+
}
|
|
35
|
+
this.fillOnSelect.push(fillItem);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error(`Invalid format for fillOnSelect: ${this.props.schema.fillOnSelect}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
20
42
|
this.setState({ value, initialized: true });
|
|
21
43
|
}
|
|
44
|
+
onObjectChanged = (attr, value) => {
|
|
45
|
+
void this.onChange(attr, value, async () => {
|
|
46
|
+
if (this.fillOnSelect.length) {
|
|
47
|
+
try {
|
|
48
|
+
const obj = await this.props.oContext.socket.getObject(value);
|
|
49
|
+
for (const item of this.fillOnSelect) {
|
|
50
|
+
if (item.overwrite || !ConfigGeneric.getValue(this.props.data, item.attr)) {
|
|
51
|
+
let objVal = ConfigGeneric.getValue(obj, item.pathInObject);
|
|
52
|
+
// Special case for translated name
|
|
53
|
+
if (typeof objVal === 'object') {
|
|
54
|
+
objVal = this.getText(objVal, true);
|
|
55
|
+
}
|
|
56
|
+
await this.onChange(item.attr, objVal);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.error(e.toString());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
22
66
|
renderItem(error, disabled /* , defaultValue */) {
|
|
23
67
|
if (!this.state.initialized) {
|
|
24
68
|
return null;
|
|
@@ -30,11 +74,15 @@ class ConfigObjectId extends ConfigGeneric {
|
|
|
30
74
|
schema.label ? React.createElement(InputLabel, { shrink: true }, this.getText(schema.label)) : null,
|
|
31
75
|
React.createElement("div", { style: styles.flex },
|
|
32
76
|
React.createElement(TextField, { variant: "standard", fullWidth: true, value: value, error: !!error, disabled: disabled, placeholder: this.getText(schema.placeholder), label: this.getText(schema.label), helperText: this.renderHelp(schema.help, schema.helpLink, schema.noTranslation), onChange: e => {
|
|
33
|
-
|
|
34
|
-
|
|
77
|
+
// Store it to have the possibility to access it in onObjectChanged
|
|
78
|
+
const value = Array.isArray(e.target.value) ? e.target.value[0] : e.target.value;
|
|
79
|
+
this.setState({ value }, () => this.onObjectChanged(attr, value));
|
|
35
80
|
} }),
|
|
36
81
|
React.createElement(Button, { color: "grey", disabled: disabled, style: styles.button, size: "small", variant: "outlined", onClick: () => this.setState({ showSelectId: true }) }, "...")),
|
|
37
|
-
showSelectId ? (React.createElement(DialogSelectID, { imagePrefix: this.props.oContext.imagePrefix === undefined ? '../..' : this.props.oContext.imagePrefix, dialogName: `admin.${this.props.oContext.adapterName}`, filterFunc: schema.filterFunc, themeType: this.props.oContext.themeType, theme: this.props.oContext.theme, types: schema.types ? (Array.isArray(schema.types) ? schema.types : [schema.types]) : undefined, customFilter: schema.customFilter, filters: schema.filters, socket: socket, selected: value, root: schema.root, onClose: () => this.setState({ showSelectId: false }), onOk: value_ =>
|
|
82
|
+
showSelectId ? (React.createElement(DialogSelectID, { imagePrefix: this.props.oContext.imagePrefix === undefined ? '../..' : this.props.oContext.imagePrefix, dialogName: `admin.${this.props.oContext.adapterName}`, filterFunc: schema.filterFunc, themeType: this.props.oContext.themeType, theme: this.props.oContext.theme, types: schema.types ? (Array.isArray(schema.types) ? schema.types : [schema.types]) : undefined, customFilter: schema.customFilter, filters: schema.filters, socket: socket, selected: value, root: schema.root, onClose: () => this.setState({ showSelectId: false }), onOk: value_ => {
|
|
83
|
+
const val = Array.isArray(value_) ? value_[0] : value_;
|
|
84
|
+
this.setState({ showSelectId: false, value: val }, () => this.onObjectChanged(attr, val));
|
|
85
|
+
} })) : null));
|
|
38
86
|
}
|
|
39
87
|
}
|
|
40
88
|
export default ConfigObjectId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigObjectId.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigObjectId.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,OAAO,EAAE,MAAM;KAClB;IACD,MAAM,EAAE;QACJ,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,EAAE;KACf;CACJ,CAAC;AAWF,MAAM,cAAe,SAAQ,aAAuD;IAChF,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAClC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,E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,IAAI,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EACrD,IAAI,EAAE,MAAM,CAAC,EAAE,CACX,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,GAE9F,CACL,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,cAAc,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, FormControl, Button, TextField } from '@mui/material';\n\nimport { DialogSelectID } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemObjectId } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n flex: {\n display: 'flex',\n },\n button: {\n maxHeight: 48,\n marginLeft: 4,\n minWidth: 48,\n },\n};\n\ninterface ConfigObjectIdProps extends ConfigGenericProps {\n schema: ConfigItemObjectId;\n}\n\ninterface ConfigObjectIdState extends ConfigGenericState {\n showSelectId?: boolean;\n initialized?: boolean;\n}\n\nclass ConfigObjectId extends ConfigGeneric<ConfigObjectIdProps, ConfigObjectIdState> {\n componentDidMount(): void {\n super.componentDidMount();\n const { data, attr } = this.props;\n const value = ConfigGeneric.getValue(data, attr) || '';\n this.setState({ value, initialized: true });\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.initialized) {\n return null;\n }\n const socket = this.props.oContext.socket;\n const { schema, attr } = this.props;\n const { value, showSelectId } = this.state;\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n {schema.label ? <InputLabel shrink>{this.getText(schema.label)}</InputLabel> : null}\n <div style={styles.flex}>\n <TextField\n variant=\"standard\"\n fullWidth\n value={value}\n error={!!error}\n disabled={disabled}\n placeholder={this.getText(schema.placeholder)}\n label={this.getText(schema.label)}\n helperText={this.renderHelp(schema.help, schema.helpLink, schema.noTranslation)}\n onChange={e => {\n const value_ = e.target.value;\n this.setState({ value: value_ }, () => this.onChange(attr, value_));\n }}\n />\n <Button\n color=\"grey\"\n disabled={disabled}\n style={styles.button}\n size=\"small\"\n variant=\"outlined\"\n onClick={() => this.setState({ showSelectId: true })}\n >\n ...\n </Button>\n </div>\n {showSelectId ? (\n <DialogSelectID\n imagePrefix={\n this.props.oContext.imagePrefix === undefined ? '../..' : this.props.oContext.imagePrefix\n }\n dialogName={`admin.${this.props.oContext.adapterName}`}\n filterFunc={schema.filterFunc}\n themeType={this.props.oContext.themeType}\n theme={this.props.oContext.theme}\n types={schema.types ? (Array.isArray(schema.types) ? schema.types : [schema.types]) : undefined}\n customFilter={schema.customFilter}\n filters={schema.filters}\n socket={socket}\n selected={value}\n root={schema.root}\n onClose={() => this.setState({ showSelectId: false })}\n onOk={value_ =>\n this.setState({ showSelectId: false, value: value_ }, () => this.onChange(attr, value_))\n }\n />\n ) : null}\n </FormControl>\n );\n }\n}\n\nexport default ConfigObjectId;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigObjectId.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigObjectId.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,OAAO,EAAE,MAAM;KAClB;IACD,MAAM,EAAE;QACJ,SAAS,EAAE,EAAE;QACb,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,EAAE;KACf;CACJ,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AO,EACvB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,KAAK,EACf,IAAI,EAAE,MAAM,CAAC,IAAI,EACjB,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EACrD,IAAI,EAAE,MAAM,CAAC,EAAE;oBACX,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;oBACvD,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;gBAC9F,CAAC,GACH,CACL,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,cAAc,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { InputLabel, FormControl, Button, TextField } from '@mui/material';\n\nimport { DialogSelectID } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemObjectId } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n flex: {\n display: 'flex',\n },\n button: {\n maxHeight: 48,\n marginLeft: 4,\n minWidth: 48,\n },\n};\n\ninterface ConfigObjectIdProps extends ConfigGenericProps {\n schema: ConfigItemObjectId;\n}\n\ninterface ConfigObjectIdState extends ConfigGenericState {\n showSelectId?: boolean;\n initialized?: boolean;\n}\n\nclass ConfigObjectId extends ConfigGeneric<ConfigObjectIdProps, ConfigObjectIdState> {\n private fillOnSelect: { attr: string; pathInObject: string; overwrite?: boolean }[] = [];\n\n componentDidMount(): void {\n super.componentDidMount();\n const { data, attr } = this.props;\n const value = ConfigGeneric.getValue(data, attr) || '';\n if (this.props.schema.fillOnSelect) {\n // parse common.name=>name,common.color=>color(X)\n const items = this.props.schema.fillOnSelect.split(',').map(it => it.trim());\n for (const item of items) {\n const parts = item.split('=>');\n if (parts.length === 2) {\n const fillItem: { attr: string; pathInObject: string; overwrite?: boolean } = {\n pathInObject: parts[0],\n attr: parts[1],\n };\n if (fillItem.attr.includes('(X)') || fillItem.attr.includes('(x)')) {\n fillItem.overwrite = true;\n fillItem.attr = fillItem.attr.replace(/\\(X\\)|\\(x\\)/g, '');\n }\n this.fillOnSelect.push(fillItem);\n } else {\n console.error(`Invalid format for fillOnSelect: ${this.props.schema.fillOnSelect}`);\n }\n }\n }\n\n this.setState({ value, initialized: true });\n }\n\n onObjectChanged = (attr: string, value: string): void => {\n void this.onChange(attr, value, async (): Promise<void> => {\n if (this.fillOnSelect.length) {\n try {\n const obj = await this.props.oContext.socket.getObject(value);\n for (const item of this.fillOnSelect) {\n if (item.overwrite || !ConfigGeneric.getValue(this.props.data, item.attr)) {\n let objVal = ConfigGeneric.getValue(obj, item.pathInObject);\n // Special case for translated name\n if (typeof objVal === 'object') {\n objVal = this.getText(objVal, true);\n }\n await this.onChange(item.attr, objVal);\n }\n }\n } catch (e) {\n console.error(e.toString());\n }\n }\n });\n };\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.initialized) {\n return null;\n }\n const socket = this.props.oContext.socket;\n const { schema, attr } = this.props;\n const { value, showSelectId } = this.state;\n\n return (\n <FormControl\n fullWidth\n variant=\"standard\"\n >\n {schema.label ? <InputLabel shrink>{this.getText(schema.label)}</InputLabel> : null}\n <div style={styles.flex}>\n <TextField\n variant=\"standard\"\n fullWidth\n value={value}\n error={!!error}\n disabled={disabled}\n placeholder={this.getText(schema.placeholder)}\n label={this.getText(schema.label)}\n helperText={this.renderHelp(schema.help, schema.helpLink, schema.noTranslation)}\n onChange={e => {\n // Store it to have the possibility to access it in onObjectChanged\n const value = Array.isArray(e.target.value) ? e.target.value[0] : e.target.value;\n this.setState({ value }, () => this.onObjectChanged(attr, value));\n }}\n />\n <Button\n color=\"grey\"\n disabled={disabled}\n style={styles.button}\n size=\"small\"\n variant=\"outlined\"\n onClick={() => this.setState({ showSelectId: true })}\n >\n ...\n </Button>\n </div>\n {showSelectId ? (\n <DialogSelectID\n imagePrefix={\n this.props.oContext.imagePrefix === undefined ? '../..' : this.props.oContext.imagePrefix\n }\n dialogName={`admin.${this.props.oContext.adapterName}`}\n filterFunc={schema.filterFunc}\n themeType={this.props.oContext.themeType}\n theme={this.props.oContext.theme}\n types={schema.types ? (Array.isArray(schema.types) ? schema.types : [schema.types]) : undefined}\n customFilter={schema.customFilter}\n filters={schema.filters}\n socket={socket}\n selected={value}\n root={schema.root}\n onClose={() => this.setState({ showSelectId: false })}\n onOk={value_ => {\n const val = Array.isArray(value_) ? value_[0] : value_;\n this.setState({ showSelectId: false, value: val }, () => this.onObjectChanged(attr, val));\n }}\n />\n ) : null}\n </FormControl>\n );\n }\n}\n\nexport default ConfigObjectId;\n"]}
|
|
@@ -18,6 +18,8 @@ export default class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProp
|
|
|
18
18
|
private initialValue;
|
|
19
19
|
componentDidMount(): void;
|
|
20
20
|
_getValue(): string | string[];
|
|
21
|
+
_filterOptions(selectOptions: ConfigInstanceSelectState['selectOptions']): ConfigInstanceSelectState['selectOptions'];
|
|
22
|
+
renderRadio(error: string, disabled: boolean): JSX.Element;
|
|
21
23
|
renderItem(error: string, disabled: boolean): JSX.Element;
|
|
22
24
|
}
|
|
23
25
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { InputLabel, FormHelperText, FormControl, Select, MenuItem, ListSubheader, Chip, ListItemText, Checkbox, } from '@mui/material';
|
|
2
|
+
import { InputLabel, FormHelperText, FormControl, FormLabel, Select, MenuItem, ListSubheader, Chip, ListItemText, Checkbox, RadioGroup, Radio, FormControlLabel, Typography, } from '@mui/material';
|
|
3
3
|
import { I18n } from '@iobroker/adapter-react-v5';
|
|
4
4
|
import ConfigGeneric from './ConfigGeneric';
|
|
5
5
|
const styles = {
|
|
@@ -92,11 +92,8 @@ export default class ConfigSelect extends ConfigGeneric {
|
|
|
92
92
|
}
|
|
93
93
|
return value;
|
|
94
94
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
const selectOptions = (this.state.selectOptions || []).filter(item => {
|
|
95
|
+
_filterOptions(selectOptions) {
|
|
96
|
+
return (selectOptions || []).filter(item => {
|
|
100
97
|
// if optgroup or no hidden function
|
|
101
98
|
if (!item.hidden) {
|
|
102
99
|
return true;
|
|
@@ -106,6 +103,33 @@ export default class ConfigSelect extends ConfigGeneric {
|
|
|
106
103
|
}
|
|
107
104
|
return !this.execute(item.hidden, this.props.schema.default, this.props.data, this.props.arrayIndex, this.props.globalData);
|
|
108
105
|
});
|
|
106
|
+
}
|
|
107
|
+
renderRadio(error, disabled) {
|
|
108
|
+
const selectOptions = this._filterOptions(this.state.selectOptions).filter(it => !it.group);
|
|
109
|
+
const value = this._getValue();
|
|
110
|
+
return (React.createElement(FormControl, { fullWidth: true, error: !!error, disabled: !!disabled, id: `jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}` },
|
|
111
|
+
this.props.schema.label ? React.createElement(FormLabel, null, this.getText(this.props.schema.label)) : null,
|
|
112
|
+
React.createElement(RadioGroup, { value: value === undefined || value === null ? '' : value.toString(), onChange: e => {
|
|
113
|
+
// find the original option value to preserve its type (number vs string)
|
|
114
|
+
const opt = selectOptions.find(it => it.value.toString() === e.target.value);
|
|
115
|
+
const newValue = opt ? opt.value : e.target.value;
|
|
116
|
+
this.setState({ value: newValue }, () => {
|
|
117
|
+
const mayBePromise = this.onChange(this.props.attr, newValue);
|
|
118
|
+
if (mayBePromise instanceof Promise) {
|
|
119
|
+
mayBePromise.catch(e => console.error(e));
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
} }, selectOptions.map((it, i) => (React.createElement(FormControlLabel, { key: i, value: it.value.toString(), control: React.createElement(Radio, null), title: it.description || '', label: React.createElement(Typography, { component: "span", style: { color: it.color } }, it.label), style: it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {} })))),
|
|
123
|
+
this.props.schema.help ? (React.createElement(FormHelperText, null, this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation))) : null));
|
|
124
|
+
}
|
|
125
|
+
renderItem(error, disabled /* , defaultValue */) {
|
|
126
|
+
if (!this.state.selectOptions) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (this.props.schema.format === 'radio') {
|
|
130
|
+
return this.renderRadio(error, disabled);
|
|
131
|
+
}
|
|
132
|
+
const selectOptions = this._filterOptions(this.state.selectOptions);
|
|
109
133
|
const value = this._getValue();
|
|
110
134
|
const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let "==" be and not ===
|
|
111
135
|
return (React.createElement(FormControl, { variant: "standard", fullWidth: true, sx: this.props.table !== undefined && styles.noMargin, id: `jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}` },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,UAAU,EACV,cAAc,EACd,WAAW,EACX,MAAM,EACN,QAAQ,EACR,aAAa,EACb,IAAI,EACJ,YAAY,EACZ,QAAQ,GACX,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,QAAQ,EAAE;QACN,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AAE,CAAC,KAAK,EAAE,GAC5B,CACK,CACd,CAAC;YACN,CAAC,CAAC,CACG;YACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n InputLabel,\n FormHelperText,\n FormControl,\n Select,\n MenuItem,\n ListSubheader,\n Chip,\n ListItemText,\n Checkbox,\n} from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSelect, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n noMargin: {\n '&>div': {\n marginTop: 0,\n },\n },\n};\n\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemSelect;\n}\n\ninterface ConfigInstanceSelectState extends ConfigGenericState {\n selectOptions?: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n }[];\n}\n\nexport default class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProps, ConfigInstanceSelectState> {\n private initialValue: string | string[] = '';\n\n componentDidMount(): void {\n super.componentDidMount();\n let value: string | string[] = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n const selectOptions: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n }[] = [];\n\n (this.props.schema.options || []).forEach(item => {\n // if optgroup\n const groupItem: {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n } = item as {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n };\n if (Array.isArray(groupItem.items)) {\n selectOptions.push({\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n group: true,\n color: item.color,\n description: this.getText(item.description),\n });\n groupItem.items.forEach(it =>\n selectOptions.push({\n label: this.getText(it.label, this.props.schema.noTranslation),\n value: it.value,\n hidden: it.hidden,\n color: item.color,\n description: this.getText(item.description),\n }),\n );\n } else {\n selectOptions.push({\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n hidden: item.hidden,\n color: item.color,\n description: this.getText(item.description),\n });\n }\n });\n\n // Report value-to-label mapping to parent table for filtering\n if (this.props.onFilterLabelUpdate && this.props.table) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of selectOptions) {\n if (!opt.group && opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value.toString()] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n\n // if __different\n if (Array.isArray(value) && !this.props.schema.multiple) {\n this.initialValue = [...value];\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n _getValue(): string | string[] {\n let value =\n this.state.value === null || this.state.value === undefined\n ? ConfigGeneric.getValue(this.props.data, this.props.attr)\n : this.state.value;\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n return value;\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.selectOptions) {\n return null;\n }\n\n const selectOptions = (this.state.selectOptions || []).filter(item => {\n // if optgroup or no hidden function\n if (!item.hidden) {\n return true;\n }\n\n if (this.props.custom) {\n return !this.executeCustom(\n item.hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.arrayIndex,\n this.props.globalData,\n );\n }\n return !this.execute(\n item.hidden,\n this.props.schema.default,\n this.props.data,\n this.props.arrayIndex,\n this.props.globalData,\n );\n });\n\n const value = this._getValue();\n\n const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let \"==\" be and not ===\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n sx={this.props.table !== undefined && styles.noMargin}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n multiple={this.props.schema.multiple}\n disabled={!!disabled}\n value={value || '_'}\n renderValue={(val: string | string[]) =>\n this.props.schema.multiple ? (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>\n {(val as string[]).map((v: string) => {\n const it = selectOptions.find(_item => _item.value === v);\n if (it || this.props.schema.showAllValues !== false) {\n const label = it?.label || v;\n return (\n <Chip\n key={v}\n label={label}\n />\n );\n }\n return null;\n })}\n </div>\n ) : item?.color ? (\n <>\n <div style={{ color: item.color }}>{item.label === undefined ? val : item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </>\n ) : item?.label === undefined ? (\n val\n ) : (\n <>\n <div>{item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </>\n )\n }\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () => {\n let mayBePromise: void | Promise<void>;\n if (this.state.value === ConfigGeneric.DIFFERENT_VALUE) {\n mayBePromise = this.onChange(this.props.attr, this.initialValue);\n } else {\n mayBePromise = this.onChange(this.props.attr, this.state.value);\n }\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => {\n if (it.group) {\n return (\n <ListSubheader\n key={i}\n style={{ color: it.color }}\n >\n <div>{it.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </ListSubheader>\n );\n }\n return (\n <MenuItem\n key={i}\n value={it.value}\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.props.schema.multiple ? (\n <Checkbox\n checked={value.includes(it.value as string)}\n onClick={() => {\n const _value = JSON.parse(JSON.stringify(this._getValue()));\n const pos = value.indexOf(it.value as string);\n if (pos !== -1) {\n _value.splice(pos, 1);\n } else {\n _value.push(it.value);\n _value.sort();\n }\n this.setState({ value: _value }, () =>\n this.onChange(this.props.attr, _value),\n );\n }}\n />\n ) : null}\n <ListItemText\n primary={it.label}\n secondary={it.description}\n slotProps={{\n secondary: {\n style: { fontSize: 'smaller', fontStyle: 'italic', opacity: 0.7 },\n },\n }}\n style={{ color: it.color }}\n />\n </MenuItem>\n );\n })}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigSelect.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,UAAU,EACV,cAAc,EACd,WAAW,EACX,SAAS,EACT,MAAM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CAAC;iCAAM,CAAC;gCACJ,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;gCACtB,MAAM,CAAC,IAAI,EAAE,CAAC;4BAClB,CAAC;4BACD,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,CAClC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CACzC,CAAC;wBACN,CAAC,GACH,CACL,CAAC,CAAC,CAAC,IAAI;oBACR,oBAAC,YAAY,IACT,OAAO,EAAE,EAAE,CAAC,KAAK,EACjB,SAAS,EAAE,EAAE,CAAC,WAAW,EACzB,SAAS,EAAE;4BACP,SAAS,EAAE;gCACP,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE;6BACpE;yBACJ,EACD,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,GAC5B,CACK,CACd,CAAC;YACN,CAAC,CAAC,CACG;YACR,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,oBAAC,cAAc,QACV,IAAI,CAAC,UAAU,CACZ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,CACY,CACpB,CAAC,CAAC,CAAC,IAAI,CACE,CACjB,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n InputLabel,\n FormHelperText,\n FormControl,\n FormLabel,\n Select,\n MenuItem,\n ListSubheader,\n Chip,\n ListItemText,\n Checkbox,\n RadioGroup,\n Radio,\n FormControlLabel,\n Typography,\n} from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSelect, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n noMargin: {\n '&>div': {\n marginTop: 0,\n },\n },\n};\n\ninterface ConfigInstanceSelectProps extends ConfigGenericProps {\n schema: ConfigItemSelect;\n}\n\ninterface ConfigInstanceSelectState extends ConfigGenericState {\n selectOptions?: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n }[];\n}\n\nexport default class ConfigSelect extends ConfigGeneric<ConfigInstanceSelectProps, ConfigInstanceSelectState> {\n private initialValue: string | string[] = '';\n\n componentDidMount(): void {\n super.componentDidMount();\n let value: string | string[] = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n const selectOptions: {\n label: string;\n value: number | string;\n group?: boolean;\n hidden?: string | boolean;\n color?: string;\n description?: string;\n }[] = [];\n\n (this.props.schema.options || []).forEach(item => {\n // if optgroup\n const groupItem: {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n } = item as {\n items: ConfigItemSelectOption[];\n label: ioBroker.StringOrTranslated;\n value?: number | string;\n hidden?: string | boolean;\n description?: string;\n };\n if (Array.isArray(groupItem.items)) {\n selectOptions.push({\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n group: true,\n color: item.color,\n description: this.getText(item.description),\n });\n groupItem.items.forEach(it =>\n selectOptions.push({\n label: this.getText(it.label, this.props.schema.noTranslation),\n value: it.value,\n hidden: it.hidden,\n color: item.color,\n description: this.getText(item.description),\n }),\n );\n } else {\n selectOptions.push({\n label: this.getText(item.label, this.props.schema.noTranslation),\n value: item.value,\n hidden: item.hidden,\n color: item.color,\n description: this.getText(item.description),\n });\n }\n });\n\n // Report value-to-label mapping to parent table for filtering\n if (this.props.onFilterLabelUpdate && this.props.table) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of selectOptions) {\n if (!opt.group && opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value.toString()] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n\n // if __different\n if (Array.isArray(value) && !this.props.schema.multiple) {\n this.initialValue = [...value];\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n _getValue(): string | string[] {\n let value =\n this.state.value === null || this.state.value === undefined\n ? ConfigGeneric.getValue(this.props.data, this.props.attr)\n : this.state.value;\n\n if (this.props.schema.multiple) {\n if (typeof value === 'string') {\n value = [value];\n } else if (value === null || value === undefined) {\n value = [];\n }\n }\n\n return value;\n }\n\n _filterOptions(\n selectOptions: ConfigInstanceSelectState['selectOptions'],\n ): ConfigInstanceSelectState['selectOptions'] {\n return (selectOptions || []).filter(item => {\n // if optgroup or no hidden function\n if (!item.hidden) {\n return true;\n }\n\n if (this.props.custom) {\n return !this.executeCustom(\n item.hidden,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n this.props.arrayIndex,\n this.props.globalData,\n );\n }\n return !this.execute(\n item.hidden,\n this.props.schema.default,\n this.props.data,\n this.props.arrayIndex,\n this.props.globalData,\n );\n });\n }\n\n renderRadio(error: string, disabled: boolean): JSX.Element {\n const selectOptions = this._filterOptions(this.state.selectOptions).filter(it => !it.group);\n const value = this._getValue();\n\n return (\n <FormControl\n fullWidth\n error={!!error}\n disabled={!!disabled}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <FormLabel>{this.getText(this.props.schema.label)}</FormLabel> : null}\n <RadioGroup\n value={value === undefined || value === null ? '' : value.toString()}\n onChange={e => {\n // find the original option value to preserve its type (number vs string)\n const opt = selectOptions.find(it => it.value.toString() === e.target.value);\n const newValue = opt ? opt.value : e.target.value;\n this.setState({ value: newValue }, () => {\n const mayBePromise = this.onChange(this.props.attr, newValue);\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => (\n <FormControlLabel\n key={i}\n value={it.value.toString()}\n control={<Radio />}\n title={it.description || ''}\n label={\n <Typography\n component=\"span\"\n style={{ color: it.color }}\n >\n {it.label}\n </Typography>\n }\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n />\n ))}\n </RadioGroup>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n\n renderItem(error: string, disabled: boolean /* , defaultValue */): JSX.Element {\n if (!this.state.selectOptions) {\n return null;\n }\n\n if (this.props.schema.format === 'radio') {\n return this.renderRadio(error, disabled);\n }\n\n const selectOptions = this._filterOptions(this.state.selectOptions);\n\n const value = this._getValue();\n\n const item = this.props.schema.multiple ? null : selectOptions.find(it => it.value == value); // let \"==\" be and not ===\n\n return (\n <FormControl\n variant=\"standard\"\n fullWidth\n sx={this.props.table !== undefined && styles.noMargin}\n id={`jsonSelect_${this.props.attr}_${this.props.index || this.props.index === 0 ? this.props.index : ''}`}\n >\n {this.props.schema.label ? <InputLabel>{this.getText(this.props.schema.label)}</InputLabel> : null}\n <Select\n variant=\"standard\"\n error={!!error}\n multiple={this.props.schema.multiple}\n disabled={!!disabled}\n value={value || '_'}\n renderValue={(val: string | string[]) =>\n this.props.schema.multiple ? (\n <div style={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>\n {(val as string[]).map((v: string) => {\n const it = selectOptions.find(_item => _item.value === v);\n if (it || this.props.schema.showAllValues !== false) {\n const label = it?.label || v;\n return (\n <Chip\n key={v}\n label={label}\n />\n );\n }\n return null;\n })}\n </div>\n ) : item?.color ? (\n <>\n <div style={{ color: item.color }}>{item.label === undefined ? val : item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </>\n ) : item?.label === undefined ? (\n val\n ) : (\n <>\n <div>{item.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </>\n )\n }\n onChange={e => {\n this.setState({ value: e.target.value === '_' ? '' : e.target.value }, () => {\n let mayBePromise: void | Promise<void>;\n if (this.state.value === ConfigGeneric.DIFFERENT_VALUE) {\n mayBePromise = this.onChange(this.props.attr, this.initialValue);\n } else {\n mayBePromise = this.onChange(this.props.attr, this.state.value);\n }\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n });\n }}\n >\n {selectOptions.map((it, i) => {\n if (it.group) {\n return (\n <ListSubheader\n key={i}\n style={{ color: it.color }}\n >\n <div>{it.label}</div>\n {item.description ? (\n <div style={{ opacity: 0.7, fontStyle: 'italic', fontSize: 'smaller' }}>\n {item.description}\n </div>\n ) : null}\n </ListSubheader>\n );\n }\n return (\n <MenuItem\n key={i}\n value={it.value}\n style={it.value === ConfigGeneric.DIFFERENT_VALUE ? { opacity: 0.5 } : {}}\n >\n {this.props.schema.multiple ? (\n <Checkbox\n checked={value.includes(it.value as string)}\n onClick={() => {\n const _value = JSON.parse(JSON.stringify(this._getValue()));\n const pos = value.indexOf(it.value as string);\n if (pos !== -1) {\n _value.splice(pos, 1);\n } else {\n _value.push(it.value);\n _value.sort();\n }\n this.setState({ value: _value }, () =>\n this.onChange(this.props.attr, _value),\n );\n }}\n />\n ) : null}\n <ListItemText\n primary={it.label}\n secondary={it.description}\n slotProps={{\n secondary: {\n style: { fontSize: 'smaller', fontStyle: 'italic', opacity: 0.7 },\n },\n }}\n style={{ color: it.color }}\n />\n </MenuItem>\n );\n })}\n </Select>\n {this.props.schema.help ? (\n <FormHelperText>\n {this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n </FormHelperText>\n ) : null}\n </FormControl>\n );\n }\n}\n"]}
|
package/build/types.d.ts
CHANGED
|
@@ -443,6 +443,8 @@ export interface ConfigItemObjectId extends ConfigItem {
|
|
|
443
443
|
};
|
|
444
444
|
/** Cannot be used together with `type` settings. It is a function that will be called for every object and must return true or false. Example: `obj.common.type === 'number'` */
|
|
445
445
|
filterFunc?: (obj: ioBroker.Object) => boolean;
|
|
446
|
+
/** Special case to fill other field, when the ID is selected. Example "common.name=>name,common.color=>color(X)" - fills the field name and color with object name and colors. The color will be overwritten with the new value event when it is not empty */
|
|
447
|
+
fillOnSelect?: string;
|
|
446
448
|
}
|
|
447
449
|
|
|
448
450
|
export interface ConfigItemSlider extends ConfigItem {
|
|
@@ -603,6 +605,7 @@ export interface ConfigItemSelect extends ConfigItem {
|
|
|
603
605
|
description?: ioBroker.StringOrTranslated;
|
|
604
606
|
}
|
|
605
607
|
)[];
|
|
608
|
+
format: 'dropdown' | 'radio';
|
|
606
609
|
attr?: string;
|
|
607
610
|
/** If multiple selection is possible. In this case, the value will be an array */
|
|
608
611
|
multiple?: boolean;
|