@iobroker/json-config 8.3.9 → 8.3.11
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 +60 -50
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.js +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js +2 -1
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js +2 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/build/JsonConfigComponent/index.js +1 -1
- package/build/JsonConfigComponent/index.js.map +1 -1
- package/build/types.d.ts +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -694,6 +694,7 @@ Button that sends a request to the current instance (<https://github.com/iobroke
|
|
|
694
694
|
| `timeout` | timeout for request in ms. Default: none. |
|
|
695
695
|
| `onLoaded` | execute the button logic once initially |
|
|
696
696
|
| `controlStyle` | Styles for the button. |
|
|
697
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
697
698
|
|
|
698
699
|
### `setState`
|
|
699
700
|
|
|
@@ -945,14 +946,15 @@ only Admin6.
|
|
|
945
946
|
|
|
946
947
|
shows the image received from the backend as base64 string
|
|
947
948
|
|
|
948
|
-
| Property | Description
|
|
949
|
-
|
|
950
|
-
| `width` | width of QR code in px
|
|
951
|
-
| `height` | height of QR code in px
|
|
952
|
-
| `command` | sendTo command
|
|
953
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend
|
|
954
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined.
|
|
955
|
-
| `sendFirstByClick` | show image first when clicked. `true` - standard text (Click to show) or specific text
|
|
949
|
+
| Property | Description |
|
|
950
|
+
|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
951
|
+
| `width` | width of QR code in px |
|
|
952
|
+
| `height` | height of QR code in px |
|
|
953
|
+
| `command` | sendTo command |
|
|
954
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend |
|
|
955
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined. |
|
|
956
|
+
| `sendFirstByClick` | show image first when clicked. `true` - standard text (Click to show) or specific text |
|
|
957
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
956
958
|
|
|
957
959
|
#### Example of code in back-end for `imageSendTo`
|
|
958
960
|
|
|
@@ -974,17 +976,18 @@ adapter.on("message", (obj) => {
|
|
|
974
976
|
Sends a command to the adapter instance and displays the response string as a QR code.
|
|
975
977
|
The backend must return a plain string (the data to encode).
|
|
976
978
|
|
|
977
|
-
| Property | Description
|
|
978
|
-
|
|
979
|
-
| `command` | sendTo command (default: `"send"`)
|
|
980
|
-
| `alsoDependsOn` | array of attribute names — the QR code is refreshed whenever any of these attributes change
|
|
981
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend
|
|
982
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined.
|
|
983
|
-
| `sendFirstByClick` | load QR code only after a click. `true` — standard text ("Click to show") or a custom string/translation object used as the button label
|
|
984
|
-
| `size` | size of the QR code in px
|
|
985
|
-
| `fgColor` | foreground color (default: `"#000000"`)
|
|
986
|
-
| `bgColor` | background color (default: `"#ffffff"`)
|
|
987
|
-
| `level` | error correction level: `L`, `M`, `Q`, or `H` (default: `L`)
|
|
979
|
+
| Property | Description |
|
|
980
|
+
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
981
|
+
| `command` | sendTo command (default: `"send"`) |
|
|
982
|
+
| `alsoDependsOn` | array of attribute names — the QR code is refreshed whenever any of these attributes change |
|
|
983
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend |
|
|
984
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined. |
|
|
985
|
+
| `sendFirstByClick` | load QR code only after a click. `true` — standard text ("Click to show") or a custom string/translation object used as the button label |
|
|
986
|
+
| `size` | size of the QR code in px |
|
|
987
|
+
| `fgColor` | foreground color (default: `"#000000"`) |
|
|
988
|
+
| `bgColor` | background color (default: `"#ffffff"`) |
|
|
989
|
+
| `level` | error correction level: `L`, `M`, `Q`, or `H` (default: `L`) |
|
|
990
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
988
991
|
|
|
989
992
|
#### Example of code in back-end for `qrCodeSendTo`
|
|
990
993
|
|
|
@@ -1027,11 +1030,12 @@ Shows an iframe with the specified URL. (from Admin 7.7.28)
|
|
|
1027
1030
|
|
|
1028
1031
|
Shows an iframe with a URL received from the backend. (from Admin 7.7.28)
|
|
1029
1032
|
|
|
1030
|
-
| Property | Description
|
|
1031
|
-
|
|
1032
|
-
| `command` | sendTo command
|
|
1033
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend
|
|
1034
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined.
|
|
1033
|
+
| Property | Description |
|
|
1034
|
+
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
1035
|
+
| `command` | sendTo command |
|
|
1036
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to backend |
|
|
1037
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to backend if jsonData is not defined. |
|
|
1038
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
1035
1039
|
|
|
1036
1040
|
The backend must return a URL as a string.
|
|
1037
1041
|
|
|
@@ -1061,16 +1065,17 @@ adapter.on("message", (obj) => {
|
|
|
1061
1065
|
|
|
1062
1066
|
Shows the drop-down menu with the given from the instance values.
|
|
1063
1067
|
|
|
1064
|
-
| Property | Description
|
|
1065
|
-
|
|
1066
|
-
| `command` | sendTo command
|
|
1067
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend
|
|
1068
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined.
|
|
1069
|
-
| `manual` | allow manual editing. Without drop-down menu (if instance is offline). Default `true`.
|
|
1070
|
-
| `multiple` | Multiple choice select
|
|
1071
|
-
| `showAllValues` | show item even if no label was found for it (by multiple), default=`true`
|
|
1072
|
-
| `noTranslation` | do not translate label of selects. To use this option, your adapter must implement message handler.The result of command must be an array in form `[{"value": 1, "label": "one"}, ...]`
|
|
1073
|
-
| `alsoDependsOn` | by change of which attributes, the command must be resent
|
|
1068
|
+
| Property | Description |
|
|
1069
|
+
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
1070
|
+
| `command` | sendTo command |
|
|
1071
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend |
|
|
1072
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined. |
|
|
1073
|
+
| `manual` | allow manual editing. Without drop-down menu (if instance is offline). Default `true`. |
|
|
1074
|
+
| `multiple` | Multiple choice select |
|
|
1075
|
+
| `showAllValues` | show item even if no label was found for it (by multiple), default=`true` |
|
|
1076
|
+
| `noTranslation` | do not translate label of selects. To use this option, your adapter must implement message handler.The result of command must be an array in form `[{"value": 1, "label": "one"}, ...]` |
|
|
1077
|
+
| `alsoDependsOn` | by change of which attributes, the command must be resent |
|
|
1078
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
1074
1079
|
|
|
1075
1080
|
The backend handler can return items with an optional `description` field: `[{"value": 1, "label": "one", "description": "Some hint"}, ...]`. The description is shown below the label in the dropdown.
|
|
1076
1081
|
|
|
@@ -1132,14 +1137,15 @@ adapter.on("message", (obj) => {
|
|
|
1132
1137
|
|
|
1133
1138
|
Shows autocomplete control with the given from the instance values.
|
|
1134
1139
|
|
|
1135
|
-
| Property | Description
|
|
1136
|
-
|
|
1137
|
-
| `command` | sendTo command
|
|
1138
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend
|
|
1139
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined.
|
|
1140
|
-
| `freeSolo` | Set `freeSolo` to `true`, so the textbox can contain any arbitrary value.
|
|
1141
|
-
| `alsoDependsOn` | by change of which attributes, the command must be resent
|
|
1142
|
-
| `maxLength` | max length of the text in field
|
|
1140
|
+
| Property | Description |
|
|
1141
|
+
|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
1142
|
+
| `command` | sendTo command |
|
|
1143
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend |
|
|
1144
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined. |
|
|
1145
|
+
| `freeSolo` | Set `freeSolo` to `true`, so the textbox can contain any arbitrary value. |
|
|
1146
|
+
| `alsoDependsOn` | by change of which attributes, the command must be resent |
|
|
1147
|
+
| `maxLength` | max length of the text in field |
|
|
1148
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
1143
1149
|
|
|
1144
1150
|
To use this option, your adapter must implement a message handler:
|
|
1145
1151
|
|
|
@@ -1150,14 +1156,15 @@ See `selectSendTo` for handler example
|
|
|
1150
1156
|
|
|
1151
1157
|
Shows readonly control with the given from the instance values.
|
|
1152
1158
|
|
|
1153
|
-
| Property | Description
|
|
1154
|
-
|
|
1155
|
-
| `container` | `div`, `text`, `html`
|
|
1156
|
-
| `copyToClipboard` | if true - show button
|
|
1157
|
-
| `alsoDependsOn` | by change of which attributes, the command must be resent
|
|
1158
|
-
| `command` | sendTo command
|
|
1159
|
-
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend
|
|
1160
|
-
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined.
|
|
1159
|
+
| Property | Description |
|
|
1160
|
+
|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
1161
|
+
| `container` | `div`, `text`, `html` |
|
|
1162
|
+
| `copyToClipboard` | if true - show button |
|
|
1163
|
+
| `alsoDependsOn` | by change of which attributes, the command must be resent |
|
|
1164
|
+
| `command` | sendTo command |
|
|
1165
|
+
| `jsonData` | string - `{"subject1": "${data.subject}", "options1": {"host": "${data.host}"}}`. This data will be sent to the backend |
|
|
1166
|
+
| `data` | object - `{"subject1": 1, "data": "static"}`. You can specify jsonData or data, but not both. This data will be sent to the backend if jsonData is not defined. |
|
|
1167
|
+
| `instance` | Instance where to send the request to (e.g. `"admin.0"`). Overrides `oContext.instance`. If not defined, the request is sent to the current adapter instance. You can use `${data.number}` pattern in the text. |
|
|
1161
1168
|
|
|
1162
1169
|
To use this option, your adapter must implement a message handler:
|
|
1163
1170
|
The result of command must be a string or object with the following parameters:
|
|
@@ -1768,6 +1775,9 @@ The schema is used here: https://github.com/SchemaStore/schemastore/blob/6da29cd
|
|
|
1768
1775
|
### **WORK IN PROGRESS**
|
|
1769
1776
|
-->
|
|
1770
1777
|
## Changelog
|
|
1778
|
+
### 8.3.11 (2026-04-29)
|
|
1779
|
+
- (@GermanBluefox) Added `instance` option for all `sendTo` components to override the target adapter instance
|
|
1780
|
+
|
|
1771
1781
|
### 8.3.9 (2026-04-17)
|
|
1772
1782
|
- (@GermanBluefox) Updated packages
|
|
1773
1783
|
|
|
@@ -28,8 +28,9 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
28
28
|
}
|
|
29
29
|
// Set loading state during sendTo request
|
|
30
30
|
this.setState({ loading: true });
|
|
31
|
+
const instance = this.getPattern(this.props.schema.instance || `${this.props.oContext.adapterName}.${this.props.oContext.instance}`);
|
|
31
32
|
void this.props.oContext.socket
|
|
32
|
-
.sendTo(
|
|
33
|
+
.sendTo(instance, this.props.schema.command || 'send', data)
|
|
33
34
|
.then((list) => {
|
|
34
35
|
if (list && Array.isArray(list)) {
|
|
35
36
|
list.forEach(item => selectOptions.push(typeof item === 'string'
|
|
@@ -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,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YAClC,IAAI,IAAI,KAAK,SAAS,I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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 ?? ''}\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;AAWz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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 const instance = this.getPattern(\n this.props.schema.instance || `${this.props.oContext.adapterName}.${this.props.oContext.instance}`,\n );\n void this.props.oContext.socket\n .sendTo(instance, this.props.schema.command || 'send', data)\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 ?? ''}\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"]}
|