@iobroker/json-config 8.2.2 → 8.2.5
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 +37 -6
- package/build/JsonConfigComponent/ConfigAutocomplete.js +10 -0
- package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.d.ts +5 -0
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +15 -0
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +2 -0
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigQrCode.js +13 -1
- package/build/JsonConfigComponent/ConfigQrCode.js.map +1 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +14 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js +10 -0
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +5 -0
- package/build/JsonConfigComponent/ConfigSelectSendTo.js +16 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticText.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigStaticText.js +16 -3
- package/build/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigTable.js +28 -2
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/wrapper/Components/Editor.d.ts +2 -2
- package/build/JsonConfigComponent/wrapper/Components/Editor.js +1 -2
- package/build/JsonConfigComponent/wrapper/Components/Editor.js.map +1 -1
- package/build/types.d.ts +6 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -693,12 +693,13 @@ button that sets instance's state
|
|
|
693
693
|
|
|
694
694
|
### `staticText`
|
|
695
695
|
|
|
696
|
-
|
|
696
|
+
Static text like description
|
|
697
697
|
|
|
698
|
-
| Property | Description
|
|
699
|
-
|
|
700
|
-
| `label` | multi-language text
|
|
701
|
-
| `text` | same as label
|
|
698
|
+
| Property | Description |
|
|
699
|
+
|----------|-----------------------------------------------------|
|
|
700
|
+
| `label` | multi-language text |
|
|
701
|
+
| `text` | same as label |
|
|
702
|
+
| `format` | `text` (default), `html` (from admin version 7.8.4) |
|
|
702
703
|
|
|
703
704
|
exactly one of `label` or `text` must be specified - not both
|
|
704
705
|
|
|
@@ -1600,6 +1601,30 @@ The following variables are available in JS function in custom settings:
|
|
|
1600
1601
|
- `arrayIndex` - used only in table and represent current line in an array
|
|
1601
1602
|
- `globalData` - used only in table for all settings and not only one table line
|
|
1602
1603
|
|
|
1604
|
+
```json5
|
|
1605
|
+
{
|
|
1606
|
+
"general": {
|
|
1607
|
+
// ....
|
|
1608
|
+
"customSettingsValidator": "customObj.common.type === 'boolean' && data.options.myType == 2",
|
|
1609
|
+
// ....
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
```
|
|
1613
|
+
|
|
1614
|
+
You can limit the application of the custom settings only to specific states by defining the `statesFilter` on the root (`panel` or `tabs`) element of the custom settings:
|
|
1615
|
+
|
|
1616
|
+
`jsonCustom.json`:
|
|
1617
|
+
```json5
|
|
1618
|
+
{
|
|
1619
|
+
"i18n": true,
|
|
1620
|
+
"type": "panel",
|
|
1621
|
+
"statesFilter": true, // or "^hm-rpc\\.\\d\\..*\\.STATE$" - apply on "hm-rpc.X.*.STATE" states only
|
|
1622
|
+
"items": {
|
|
1623
|
+
// ...
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
```
|
|
1627
|
+
|
|
1603
1628
|
## Custom component
|
|
1604
1629
|
|
|
1605
1630
|
```jsx
|
|
@@ -1708,9 +1733,15 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
|
|
|
1708
1733
|
### **WORK IN PROGRESS**
|
|
1709
1734
|
-->
|
|
1710
1735
|
## Changelog
|
|
1736
|
+
### 8.2.5 (2026-03-12)
|
|
1737
|
+
- (@GermanBluefox) Extended the staticText component with HTML and JSON visualization
|
|
1738
|
+
|
|
1739
|
+
### 8.2.3 (2026-03-04)
|
|
1740
|
+
- (@GermanBluefox) Increased the QR code padding
|
|
1741
|
+
|
|
1711
1742
|
### 8.2.2 (2026-03-03)
|
|
1712
1743
|
- (@GermanBluefox) Added option `sendFirstByClick` to `imageSendTo`
|
|
1713
|
-
- (@GermanBluefox) Added new component: `qrCodeSendTo`
|
|
1744
|
+
- (@GermanBluefox) Added a new component: `qrCodeSendTo`
|
|
1714
1745
|
- (@GermanBluefox) Added option `digits` to `state` component
|
|
1715
1746
|
- (@GermanBluefox) Trying to fix indication of the problems in the table
|
|
1716
1747
|
|
|
@@ -7,6 +7,16 @@ class ConfigAutocomplete extends ConfigGeneric {
|
|
|
7
7
|
super.componentDidMount();
|
|
8
8
|
const value = ConfigGeneric.getValue(this.props.data, this.props.attr);
|
|
9
9
|
const selectOptions = this.props.schema.options.map((item) => typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)));
|
|
10
|
+
// Report value-to-label mapping to parent table for filtering
|
|
11
|
+
if (this.props.onFilterLabelUpdate && this.props.table) {
|
|
12
|
+
const valueToLabel = {};
|
|
13
|
+
for (const opt of selectOptions) {
|
|
14
|
+
if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {
|
|
15
|
+
valueToLabel[opt.value] = opt.label;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);
|
|
19
|
+
}
|
|
10
20
|
// if __different
|
|
11
21
|
if (Array.isArray(value)) {
|
|
12
22
|
selectOptions.unshift({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigAutocomplete.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAutocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAUlG,MAAM,kBAAmB,SAAQ,aAA+D;IAC5F,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEvE,MAAM,aAAa,GAAuC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CACnF,CAAC,IAA+C,EAAE,EAAE,CAChD,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CACjG,CAAC;QAEF,iBAAiB;QACjB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACvB,aAAa,CAAC,OAAO,CAAC;gBAClB,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,eAAe,CAAC;gBAC5C,KAAK,EAAE,aAAa,CAAC,eAAe;aACvC,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,eAAe,EAAE,aAAa,EAAE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AC,CAAC,CAAC,KAAK,CAAC;gBAC3E,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;oBAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;gBAC7E,CAAC;YACL,CAAC,EACD,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACnF,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CACnB,oBAAC,SAAS,IACN,OAAO,EAAC,UAAU,KACd,MAAM,EACV,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,uDAAuD;gBACvD,8FAA8F;gBAC9F,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,EACD,QAAQ,EAAE,QAAQ,GACpB,CACL,GACH,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocomplete, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\n\nexport interface ConfigAutocompleteProps extends ConfigGenericProps {\n schema: ConfigItemAutocomplete;\n}\n\nexport interface ConfigAutocompleteState extends ConfigGenericState {\n selectOptions: { value: string; label: string }[];\n}\n\nclass ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {\n componentDidMount(): void {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions: { label: string; value: string }[] = this.props.schema.options.map(\n (item: { label: string; value: string } | string) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\n );\n\n // if __different\n if (Array.isArray(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 renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n let item;\n const options: ConfigItemSelectOption[] = JSON.parse(JSON.stringify(this.state.selectOptions));\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find(it => (typeof it === 'object' ? it.value === val : it === val)))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find(_item =>\n typeof _item === 'object' ? _item.value == this.state.value : _item == this.state.value,\n ); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n }\n\n return (\n <Autocomplete\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n value={item}\n options={options}\n isOptionEqualToValue={(option, value) => option.value === value.value}\n filterOptions={(options: { value: string; label: string }[], params) => {\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n return (\n option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||\n option.value.toLowerCase().includes(params.inputValue.toLowerCase())\n );\n });\n\n if (this.props.schema.freeSolo && params.inputValue !== '') {\n filtered.push({\n label: params.inputValue,\n value: params.inputValue,\n });\n }\n\n return filtered;\n }}\n // autoComplete\n onInputChange={e => {\n if (!e || !this.props.schema.freeSolo) {\n return;\n }\n\n const val = (e.target as HTMLInputElement).value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n onChange={(_, value) => {\n const val = typeof value === 'object' ? (value ? value.value : '') : value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n getOptionLabel={option => (typeof option === 'object' ? (option?.label ?? '') : '')}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n // inputProps are important and will be given in params\n // inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n disabled={disabled}\n />\n )}\n />\n );\n }\n}\n\nexport default ConfigAutocomplete;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigAutocomplete.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAutocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;A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from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocomplete, ConfigItemSelectOption } from '../types';\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\n\nexport interface ConfigAutocompleteProps extends ConfigGenericProps {\n schema: ConfigItemAutocomplete;\n}\n\nexport interface ConfigAutocompleteState extends ConfigGenericState {\n selectOptions: { value: string; label: string }[];\n}\n\nclass ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {\n componentDidMount(): void {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions: { label: string; value: string }[] = this.props.schema.options.map(\n (item: { label: string; value: string } | string) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\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.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n\n // if __different\n if (Array.isArray(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 renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n let item;\n const options: ConfigItemSelectOption[] = JSON.parse(JSON.stringify(this.state.selectOptions));\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find(it => (typeof it === 'object' ? it.value === val : it === val)))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find(_item =>\n typeof _item === 'object' ? _item.value == this.state.value : _item == this.state.value,\n ); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n }\n\n return (\n <Autocomplete\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n value={item}\n options={options}\n isOptionEqualToValue={(option, value) => option.value === value.value}\n filterOptions={(options: { value: string; label: string }[], params) => {\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n return (\n option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||\n option.value.toLowerCase().includes(params.inputValue.toLowerCase())\n );\n });\n\n if (this.props.schema.freeSolo && params.inputValue !== '') {\n filtered.push({\n label: params.inputValue,\n value: params.inputValue,\n });\n }\n\n return filtered;\n }}\n // autoComplete\n onInputChange={e => {\n if (!e || !this.props.schema.freeSolo) {\n return;\n }\n\n const val = (e.target as HTMLInputElement).value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n onChange={(_, value) => {\n const val = typeof value === 'object' ? (value ? value.value : '') : value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n getOptionLabel={option => (typeof option === 'object' ? (option?.label ?? '') : '')}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n // inputProps are important and will be given in params\n // inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n disabled={disabled}\n />\n )}\n />\n );\n }\n}\n\nexport default ConfigAutocomplete;\n"]}
|
|
@@ -12,6 +12,11 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric<ConfigAutoco
|
|
|
12
12
|
private initialized;
|
|
13
13
|
private localContext;
|
|
14
14
|
askInstance(): void;
|
|
15
|
+
/** Report value-to-label mapping to parent table for filtering */
|
|
16
|
+
reportFilterLabels(options: {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[]): void;
|
|
15
20
|
getContext(): string;
|
|
16
21
|
renderItem(error: unknown, disabled: boolean): JSX.Element | null;
|
|
17
22
|
}
|
|
@@ -36,6 +36,7 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
36
36
|
? { label: item, value: item }
|
|
37
37
|
: JSON.parse(JSON.stringify(item))));
|
|
38
38
|
}
|
|
39
|
+
this.reportFilterLabels(selectOptions);
|
|
39
40
|
// if __different
|
|
40
41
|
if (Array.isArray(value)) {
|
|
41
42
|
selectOptions.unshift({
|
|
@@ -60,12 +61,26 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
60
61
|
label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),
|
|
61
62
|
value: ConfigGeneric.DIFFERENT_VALUE,
|
|
62
63
|
});
|
|
64
|
+
this.reportFilterLabels(selectOptions);
|
|
63
65
|
this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });
|
|
64
66
|
}
|
|
65
67
|
else {
|
|
68
|
+
this.reportFilterLabels(selectOptions);
|
|
66
69
|
this.setState({ value, selectOptions });
|
|
67
70
|
}
|
|
68
71
|
}
|
|
72
|
+
/** Report value-to-label mapping to parent table for filtering */
|
|
73
|
+
reportFilterLabels(options) {
|
|
74
|
+
if (this.props.onFilterLabelUpdate && this.props.table) {
|
|
75
|
+
const valueToLabel = {};
|
|
76
|
+
for (const opt of options) {
|
|
77
|
+
if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {
|
|
78
|
+
valueToLabel[opt.value] = opt.label;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
69
84
|
getContext() {
|
|
70
85
|
const localContext = {};
|
|
71
86
|
if (Array.isArray(this.props.schema.alsoDependsOn)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigAutocompleteSendTo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAutocompleteSendTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAA0C,MAAM,iBAAiB,CAAC;AAWzE,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,aAGrD;IACW,WAAW,GAAG,KAAK,CAAC;IAEpB,YAAY,CAAqB;IAEzC,WAAW;QACP,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;YAC3C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CACxC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAC7F;YACH,CAAC,CAAC,EAAE,CAAC;QAET,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,IAAI,GAAG,I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,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;gBAC7E,CAAC;YACL,CAAC,EACD,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CACnB,oBAAC,SAAS,IACN,OAAO,EAAC,UAAU,KACd,MAAM;gBACV,uDAAuD;gBACvD,8FAA8F;gBAC9F,KAAK,EAAE,CAAC,CAAC,KAAK,EACd,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,EACD,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE;oBACP,KAAK,EAAE;wBACH,GAAG,MAAM,CAAC,UAAU;wBACpB,YAAY,EAAE,CACV;4BACK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAClB,oBAAC,cAAc,IAAC,QAAQ,EAAC,KAAK;gCAC1B,oBAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,GAAI,CACjB,CACpB,CAAC,CAAC,CAAC,IAAI;4BACP,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAClD,CACN;qBACJ;iBACJ,GACH,CACL,GACH,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, CircularProgress, InputAdornment } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocompleteSendTo } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps } from './ConfigGeneric';\nimport type { ConfigAutocompleteState } from './ConfigAutocomplete';\n\ninterface ConfigAutocompleteSendToProps extends ConfigGenericProps {\n schema: ConfigItemAutocompleteSendTo;\n}\n\ninterface ConfigAutocompleteSendToState extends ConfigAutocompleteState {\n loading?: boolean;\n}\n\nexport default class ConfigAutocompleteSendTo extends ConfigGeneric<\n ConfigAutocompleteSendToProps,\n ConfigAutocompleteSendToState\n> {\n private initialized = false;\n\n private localContext: string | undefined;\n\n askInstance(): void {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const selectOptions = this.props.schema.options\n ? this.props.schema.options.map((item: any) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\n )\n : [];\n\n if (this.props.alive) {\n let data = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr: string = this.getPattern(this.props.schema.jsonData, null, true);\n try {\n if (typeof dataStr === 'string') {\n data = JSON.parse(dataStr);\n }\n } catch {\n console.error(`Cannot parse json data: ${JSON.stringify(data)}`);\n }\n }\n\n if (data === undefined) {\n data = null;\n }\n\n // Set loading state during sendTo request\n this.setState({ loading: true });\n\n void this.props.oContext.socket\n .sendTo(\n `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n this.props.schema.command || 'send',\n data,\n )\n .then((list: unknown) => {\n if (list && Array.isArray(list)) {\n list.forEach(item =>\n selectOptions.push(\n typeof item === 'string'\n ? { label: item, value: item }\n : JSON.parse(JSON.stringify(item)),\n ),\n );\n }\n\n // if __different\n if (Array.isArray(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, loading: false });\n } else {\n this.setState({ value, selectOptions, loading: false });\n }\n })\n .catch(error => {\n console.error('Error in autocompleteSendTo:', error);\n // Clear loading state on error\n this.setState({ loading: false });\n });\n } else if (Array.isArray(value)) {\n // if __different\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 getContext(): string {\n const localContext: Record<string, any> = {};\n if (Array.isArray(this.props.schema.alsoDependsOn)) {\n this.props.schema.alsoDependsOn.forEach(\n attr => (localContext[attr] = ConfigGeneric.getValue(this.props.data, attr)),\n );\n }\n return JSON.stringify(localContext);\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (this.props.alive) {\n const localContext = this.getContext();\n if (localContext !== this.localContext || !this.initialized) {\n this.localContext = localContext;\n setTimeout(() => this.askInstance(), this.initialized ? 300 : 50);\n this.initialized = true;\n }\n }\n\n let item;\n const options: { value: string; label: string }[] = this.state.selectOptions\n ? JSON.parse(JSON.stringify(this.state.selectOptions))\n : [];\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_LABEL;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find((it: any) => it.value === val))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find((item: any) => item.value == this.state.value); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n item = item || null;\n }\n\n if (!options.length) {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={disabled}\n slotProps={{\n htmlInput: { maxLength: this.props.schema.maxLength || this.props.schema.max || undefined },\n input: {\n endAdornment: this.state.loading ? (\n <InputAdornment position=\"end\">\n <CircularProgress size={20} />\n </InputAdornment>\n ) : null,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n );\n }\n return (\n <Autocomplete\n value={item}\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n options={options}\n disabled={disabled}\n isOptionEqualToValue={(option, value) => option.value === value.value}\n filterOptions={(options: { value: string; label: string }[], params) => {\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n return (\n option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||\n option.value.toLowerCase().includes(params.inputValue.toLowerCase())\n );\n });\n\n if (this.props.schema.freeSolo && params.inputValue !== '') {\n filtered.push({\n label: params.inputValue,\n value: params.inputValue,\n });\n }\n\n return filtered;\n }}\n getOptionLabel={(option: { value: string; label: string }): string => option?.label ?? ''}\n onInputChange={e => {\n if (!e || !this.props.schema.freeSolo) {\n return;\n }\n\n const val = (e.target as HTMLInputElement).value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n onChange={(_, value) => {\n const val = typeof value === 'object' ? (value ? value.value : '') : value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n // inputProps are important and will be given in params\n // inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n disabled={disabled}\n slotProps={{\n input: {\n ...params.InputProps,\n endAdornment: (\n <>\n {this.state.loading ? (\n <InputAdornment position=\"end\">\n <CircularProgress size={20} />\n </InputAdornment>\n ) : null}\n {disabled ? null : params.InputProps.endAdornment}\n </>\n ),\n },\n }}\n />\n )}\n />\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigAutocompleteSendTo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAutocompleteSendTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAA0C,MAAM,iBAAiB,CAAC;AAWzE,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,aAGrD;IACW,WAAW,GAAG,KAAK,CAAC;IAEpB,YAAY,CAAqB;IAEzC,WAAW;QACP,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACvE,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO;YAC3C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CACxC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAC7F;YACH,CAAC,CAAC,EAAE,CAAC;QAET,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YAClC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,EACD,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE;oBACP,KAAK,EAAE;wBACH,GAAG,MAAM,CAAC,UAAU;wBACpB,YAAY,EAAE,CACV;4BACK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAClB,oBAAC,cAAc,IAAC,QAAQ,EAAC,KAAK;gCAC1B,oBAAC,gBAAgB,IAAC,IAAI,EAAE,EAAE,GAAI,CACjB,CACpB,CAAC,CAAC,CAAC,IAAI;4BACP,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAClD,CACN;qBACJ;iBACJ,GACH,CACL,GACH,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, CircularProgress, InputAdornment } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocompleteSendTo } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps } from './ConfigGeneric';\nimport type { ConfigAutocompleteState } from './ConfigAutocomplete';\n\ninterface ConfigAutocompleteSendToProps extends ConfigGenericProps {\n schema: ConfigItemAutocompleteSendTo;\n}\n\ninterface ConfigAutocompleteSendToState extends ConfigAutocompleteState {\n loading?: boolean;\n}\n\nexport default class ConfigAutocompleteSendTo extends ConfigGeneric<\n ConfigAutocompleteSendToProps,\n ConfigAutocompleteSendToState\n> {\n private initialized = false;\n\n private localContext: string | undefined;\n\n askInstance(): void {\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const selectOptions = this.props.schema.options\n ? this.props.schema.options.map((item: any) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\n )\n : [];\n\n if (this.props.alive) {\n let data = this.props.schema.data;\n if (data === undefined && this.props.schema.jsonData) {\n const dataStr: string = this.getPattern(this.props.schema.jsonData, null, true);\n try {\n if (typeof dataStr === 'string') {\n data = JSON.parse(dataStr);\n }\n } catch {\n console.error(`Cannot parse json data: ${JSON.stringify(data)}`);\n }\n }\n\n if (data === undefined) {\n data = null;\n }\n\n // Set loading state during sendTo request\n this.setState({ loading: true });\n\n void this.props.oContext.socket\n .sendTo(\n `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n this.props.schema.command || 'send',\n data,\n )\n .then((list: unknown) => {\n if (list && Array.isArray(list)) {\n list.forEach(item =>\n selectOptions.push(\n typeof item === 'string'\n ? { label: item, value: item }\n : JSON.parse(JSON.stringify(item)),\n ),\n );\n }\n\n this.reportFilterLabels(selectOptions);\n\n // if __different\n if (Array.isArray(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, loading: false });\n } else {\n this.setState({ value, selectOptions, loading: false });\n }\n })\n .catch(error => {\n console.error('Error in autocompleteSendTo:', error);\n // Clear loading state on error\n this.setState({ loading: false });\n });\n } else if (Array.isArray(value)) {\n // if __different\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.reportFilterLabels(selectOptions);\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.reportFilterLabels(selectOptions);\n this.setState({ value, selectOptions });\n }\n }\n\n /** Report value-to-label mapping to parent table for filtering */\n reportFilterLabels(options: { value: string; label: string }[]): void {\n if (this.props.onFilterLabelUpdate && this.props.table) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of options) {\n if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value] = opt.label;\n }\n }\n this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);\n }\n }\n\n getContext(): string {\n const localContext: Record<string, any> = {};\n if (Array.isArray(this.props.schema.alsoDependsOn)) {\n this.props.schema.alsoDependsOn.forEach(\n attr => (localContext[attr] = ConfigGeneric.getValue(this.props.data, attr)),\n );\n }\n return JSON.stringify(localContext);\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (this.props.alive) {\n const localContext = this.getContext();\n if (localContext !== this.localContext || !this.initialized) {\n this.localContext = localContext;\n setTimeout(() => this.askInstance(), this.initialized ? 300 : 50);\n this.initialized = true;\n }\n }\n\n let item;\n const options: { value: string; label: string }[] = this.state.selectOptions\n ? JSON.parse(JSON.stringify(this.state.selectOptions))\n : [];\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_LABEL;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find((it: any) => it.value === val))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find((item: any) => item.value == this.state.value); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n item = item || null;\n }\n\n if (!options.length) {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={disabled}\n slotProps={{\n htmlInput: { maxLength: this.props.schema.maxLength || this.props.schema.max || undefined },\n input: {\n endAdornment: this.state.loading ? (\n <InputAdornment position=\"end\">\n <CircularProgress size={20} />\n </InputAdornment>\n ) : null,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n />\n );\n }\n return (\n <Autocomplete\n value={item}\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n options={options}\n disabled={disabled}\n isOptionEqualToValue={(option, value) => option.value === value.value}\n filterOptions={(options: { value: string; label: string }[], params) => {\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n return (\n option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||\n option.value.toLowerCase().includes(params.inputValue.toLowerCase())\n );\n });\n\n if (this.props.schema.freeSolo && params.inputValue !== '') {\n filtered.push({\n label: params.inputValue,\n value: params.inputValue,\n });\n }\n\n return filtered;\n }}\n getOptionLabel={(option: { value: string; label: string }): string => option?.label ?? ''}\n onInputChange={e => {\n if (!e || !this.props.schema.freeSolo) {\n return;\n }\n\n const val = (e.target as HTMLInputElement).value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n onChange={(_, value) => {\n const val = typeof value === 'object' ? (value ? value.value : '') : value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n // inputProps are important and will be given in params\n // inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n disabled={disabled}\n slotProps={{\n input: {\n ...params.InputProps,\n endAdornment: (\n <>\n {this.state.loading ? (\n <InputAdornment position=\"end\">\n <CircularProgress size={20} />\n </InputAdornment>\n ) : null}\n {disabled ? null : params.InputProps.endAdornment}\n </>\n ),\n },\n }}\n />\n )}\n />\n );\n }\n}\n"]}
|
|
@@ -44,6 +44,8 @@ export interface ConfigGenericProps {
|
|
|
44
44
|
onChange: (attrOrData: string | Record<string, any>, val?: any, cb?: () => void, saveConfig?: boolean) => void;
|
|
45
45
|
onError: (attr: string, error?: string) => void;
|
|
46
46
|
onHiddenChanged?: (attr: string, hidden?: boolean) => void;
|
|
47
|
+
/** Filled only by table: components with value/label options report their label mappings for table filtering */
|
|
48
|
+
onFilterLabelUpdate?: (attr: string, valueToLabel: Record<string, string>) => void;
|
|
47
49
|
originalData: Record<string, any>;
|
|
48
50
|
/** This indicates that the component is the very firsts one - root */
|
|
49
51
|
root?: boolean;
|