@iobroker/json-config 8.4.15 → 8.5.4
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 +10 -0
- package/build/JsonConfig.d.ts +3 -3
- package/build/JsonConfig.js +11 -7
- package/build/JsonConfig.js.map +1 -1
- package/build/JsonConfigComponent/ChipInput.js +3 -3
- package/build/JsonConfigComponent/ChipInput.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAccordion.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigAccordion.js +28 -18
- package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAlive.js +8 -4
- package/build/JsonConfigComponent/ConfigAlive.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocomplete.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigAutocomplete.js +6 -6
- package/build/JsonConfigComponent/ConfigAutocomplete.js.map +1 -1
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js +5 -5
- package/build/JsonConfigComponent/ConfigAutocompleteSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCRON.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigCRON.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCertCollection.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificateSelect.d.ts +1 -0
- package/build/JsonConfigComponent/ConfigCertificateSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js +1 -1
- package/build/JsonConfigComponent/ConfigCertificates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckDocker.js +4 -2
- package/build/JsonConfigComponent/ConfigCheckDocker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.js +14 -11
- package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckbox.js +12 -10
- package/build/JsonConfigComponent/ConfigCheckbox.js.map +1 -1
- package/build/JsonConfigComponent/ConfigChip.js +22 -18
- package/build/JsonConfigComponent/ConfigChip.js.map +1 -1
- package/build/JsonConfigComponent/ConfigColor.js +5 -8
- package/build/JsonConfigComponent/ConfigColor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js +1 -1
- package/build/JsonConfigComponent/ConfigCoordinates.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCredentialSelect.d.ts +2 -0
- package/build/JsonConfigComponent/ConfigCredentialSelect.js +3 -0
- package/build/JsonConfigComponent/ConfigCredentialSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCustom.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigCustom.js +1 -1
- package/build/JsonConfigComponent/ConfigCustom.js.map +1 -1
- package/build/JsonConfigComponent/ConfigDatePicker.js +4 -2
- package/build/JsonConfigComponent/ConfigDatePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFile.js +4 -2
- package/build/JsonConfigComponent/ConfigFile.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFileSelector.d.ts +3 -2
- package/build/JsonConfigComponent/ConfigFileSelector.js +10 -8
- package/build/JsonConfigComponent/ConfigFileSelector.js.map +1 -1
- package/build/JsonConfigComponent/ConfigFunc.js +1 -1
- package/build/JsonConfigComponent/ConfigFunc.js.map +1 -1
- package/build/JsonConfigComponent/ConfigGeneric.d.ts +16 -13
- package/build/JsonConfigComponent/ConfigGeneric.js +68 -46
- package/build/JsonConfigComponent/ConfigGeneric.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigIFrameSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigIP.js +4 -1
- package/build/JsonConfigComponent/ConfigIP.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigImageSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigImageSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigImageUpload.js +26 -22
- package/build/JsonConfigComponent/ConfigImageUpload.js.map +1 -1
- package/build/JsonConfigComponent/ConfigInstanceSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigInstanceSelect.js +5 -5
- package/build/JsonConfigComponent/ConfigInstanceSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigInterface.js +16 -12
- package/build/JsonConfigComponent/ConfigInterface.js.map +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js +1 -1
- package/build/JsonConfigComponent/ConfigJsonEditor.js.map +1 -1
- package/build/JsonConfigComponent/ConfigLanguage.js +7 -9
- package/build/JsonConfigComponent/ConfigLanguage.js.map +1 -1
- package/build/JsonConfigComponent/ConfigLicense.js +5 -3
- package/build/JsonConfigComponent/ConfigLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigNumber.js +7 -5
- package/build/JsonConfigComponent/ConfigNumber.js.map +1 -1
- package/build/JsonConfigComponent/ConfigOAuth2.js +2 -2
- package/build/JsonConfigComponent/ConfigOAuth2.js.map +1 -1
- package/build/JsonConfigComponent/ConfigObjectId.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigObjectId.js +12 -10
- package/build/JsonConfigComponent/ConfigObjectId.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPanel.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js +5 -4
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPassword.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigPassword.js.map +1 -1
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js +1 -3
- package/build/JsonConfigComponent/ConfigQrCodeSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigRoom.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigRoom.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelect.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelect.js +4 -4
- package/build/JsonConfigComponent/ConfigSelect.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSelectSendTo.js +14 -16
- package/build/JsonConfigComponent/ConfigSelectSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSendto.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigSendto.js +6 -5
- package/build/JsonConfigComponent/ConfigSendto.js.map +1 -1
- package/build/JsonConfigComponent/ConfigSetState.js +4 -1
- package/build/JsonConfigComponent/ConfigSetState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigState.js +34 -23
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticImage.js +1 -1
- package/build/JsonConfigComponent/ConfigStaticImage.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticInfo.js +2 -2
- package/build/JsonConfigComponent/ConfigStaticInfo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticText.js +2 -2
- package/build/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.d.ts +4 -4
- package/build/JsonConfigComponent/ConfigTable.js +80 -75
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTabs.d.ts +17 -9
- package/build/JsonConfigComponent/ConfigTabs.js +85 -67
- package/build/JsonConfigComponent/ConfigTabs.js.map +1 -1
- package/build/JsonConfigComponent/ConfigText.js +6 -6
- package/build/JsonConfigComponent/ConfigText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.d.ts +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTimePicker.js +2 -5
- package/build/JsonConfigComponent/ConfigTimePicker.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js +1 -1
- package/build/JsonConfigComponent/ConfigUUID.js.map +1 -1
- package/build/JsonConfigComponent/ConfigUser.js +2 -2
- package/build/JsonConfigComponent/ConfigUser.js.map +1 -1
- package/build/JsonConfigComponent/ConfigYamlEditor.js +2 -2
- package/build/JsonConfigComponent/ConfigYamlEditor.js.map +1 -1
- package/build/JsonConfigComponent/Icons.d.ts +1 -1
- package/build/JsonConfigComponent/Icons.js.map +1 -1
- package/build/JsonConfigComponent/index.d.ts +4 -4
- package/build/JsonConfigComponent/index.js +21 -16
- package/build/JsonConfigComponent/index.js.map +1 -1
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.d.ts +2 -3
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.js +2 -7
- package/build/JsonConfigComponent/wrapper/Components/CustomModal.js.map +1 -1
- package/package.json +3 -2
|
@@ -53,22 +53,24 @@ class ConfigAccordion extends ConfigGeneric {
|
|
|
53
53
|
if (!newAccordionErrors[accordionIndex]) {
|
|
54
54
|
newAccordionErrors[accordionIndex] = {};
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
if (attr) {
|
|
57
|
+
if (!error) {
|
|
58
|
+
delete newAccordionErrors[accordionIndex][attr];
|
|
59
|
+
// Clean up empty accordion error objects
|
|
60
|
+
if (Object.keys(newAccordionErrors[accordionIndex]).length === 0) {
|
|
61
|
+
delete newAccordionErrors[accordionIndex];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
newAccordionErrors[accordionIndex][attr] = error;
|
|
61
66
|
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
newAccordionErrors[accordionIndex][attr] = error;
|
|
65
67
|
}
|
|
66
68
|
this.setState({ accordionErrors: newAccordionErrors });
|
|
67
69
|
// Also forward to parent
|
|
68
70
|
this.props.onError(attr, error);
|
|
69
71
|
};
|
|
70
72
|
hasAccordionErrors = (accordionIndex) => {
|
|
71
|
-
return !!
|
|
73
|
+
return (!!this.state.accordionErrors[accordionIndex] &&
|
|
72
74
|
Object.keys(this.state.accordionErrors[accordionIndex]).length > 0);
|
|
73
75
|
};
|
|
74
76
|
itemAccordion(data, idx) {
|
|
@@ -77,15 +79,19 @@ class ConfigAccordion extends ConfigGeneric {
|
|
|
77
79
|
const schemaItem = {
|
|
78
80
|
type: 'panel',
|
|
79
81
|
items: schema.items.reduce((accumulator, currentValue) => {
|
|
80
|
-
|
|
82
|
+
if (currentValue.attr) {
|
|
83
|
+
accumulator[currentValue.attr] = currentValue;
|
|
84
|
+
}
|
|
81
85
|
return accumulator;
|
|
82
86
|
}, {}),
|
|
83
87
|
style: { marginLeft: '-8px', marginTop: '10px', marginBottom: '10px' },
|
|
84
88
|
};
|
|
85
89
|
return (React.createElement(ConfigPanel, { oContext: this.props.oContext, index: idx + this.state.iteration, arrayIndex: idx, changed: this.props.changed, expertMode: this.props.expertMode, globalData: this.props.data, common: this.props.common, alive: this.props.alive, themeName: this.props.themeName, data: data, custom: true, schema: schemaItem, originalData: this.props.originalData, onChange: (attr, valueChange) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
if (typeof attr === 'string' && attr) {
|
|
91
|
+
const newObj = JSON.parse(JSON.stringify(value));
|
|
92
|
+
newObj[idx][attr] = valueChange;
|
|
93
|
+
this.setState({ value: newObj }, () => this.onChangeWrapper(newObj));
|
|
94
|
+
}
|
|
89
95
|
}, onError: this.onAccordionError(idx), onHiddenChanged: this.props.onHiddenChanged, table: this.props.table, customComponents: this.props.customComponents }));
|
|
90
96
|
}
|
|
91
97
|
onDelete = (index) => () => {
|
|
@@ -125,9 +131,11 @@ class ConfigAccordion extends ConfigGeneric {
|
|
|
125
131
|
}
|
|
126
132
|
this.typingTimer = setTimeout(value => {
|
|
127
133
|
this.typingTimer = null;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
if (this.props.attr) {
|
|
135
|
+
const mayByPromise = this.onChange(this.props.attr, value);
|
|
136
|
+
if (mayByPromise instanceof Promise) {
|
|
137
|
+
void mayByPromise.catch(e => this.onError(e));
|
|
138
|
+
}
|
|
131
139
|
}
|
|
132
140
|
}, 300, newValue);
|
|
133
141
|
};
|
|
@@ -153,7 +161,9 @@ class ConfigAccordion extends ConfigGeneric {
|
|
|
153
161
|
else {
|
|
154
162
|
defaultValue = currentValue.default ?? null;
|
|
155
163
|
}
|
|
156
|
-
|
|
164
|
+
if (currentValue.attr) {
|
|
165
|
+
newItem[currentValue.attr] = defaultValue;
|
|
166
|
+
}
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
newValue.push(newItem);
|
|
@@ -243,7 +253,7 @@ class ConfigAccordion extends ConfigGeneric {
|
|
|
243
253
|
value.map((idx, i) => (React.createElement(Accordion, { key: `${idx}_${i}`, expanded: this.state.activeIndex === i, onChange: (_e, expanded) => this.setState({ activeIndex: expanded ? i : -1 }) },
|
|
244
254
|
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, null), sx: Utils.getStyle(this.props.oContext.theme, styles.fullWidth, styles.accordionSummary) },
|
|
245
255
|
React.createElement(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, width: '100%' } },
|
|
246
|
-
React.createElement(Typography, { style: styles.accordionTitle }, idx[schema.titleAttr]),
|
|
256
|
+
schema.titleAttr && (React.createElement(Typography, { style: styles.accordionTitle }, idx[schema.titleAttr])),
|
|
247
257
|
this.hasAccordionErrors(i) && React.createElement(ErrorIcon, { sx: { fontSize: 20, color: 'error.main' } }))),
|
|
248
258
|
React.createElement(AccordionDetails, { style: {
|
|
249
259
|
...schema.style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigAccordion.js","sourceRoot":"./src/","sources":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ACJ,OAAO,EAAC,OAAO,EACf,EAAE,EAAE,MAAM,CAAC,QAAQ;gBAEnB,oBAAC,UAAU,IACP,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,KAAK;oBAEnB,oBAAC,OAAO,OAAG,CACF,CACP,CACb,CAAC,CAAC,CAAC,IAAI;YACP,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACX,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,CACJ,CACX,CAAC;IACN,CAAC;CACJ;AAED,eAAe,eAAe,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n FormHelperText,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n IconButton,\n Paper,\n Toolbar,\n Tooltip,\n Typography,\n Box,\n} from '@mui/material';\n\nimport {\n Add as AddIcon,\n Delete as DeleteIcon,\n ArrowUpward as UpIcon,\n ArrowDownward as DownIcon,\n ContentCopy as CopyContentIcon,\n ExpandMore as ExpandMoreIcon,\n Error as ErrorIcon,\n FileDownload as FileDownloadIcon,\n FileUpload as FileUploadIcon,\n AddCircle as AddCircleIcon,\n} from '@mui/icons-material';\n\nimport { I18n, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAccordion, ConfigItemAny, ConfigItemIndexed, ConfigItemPanel } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n accordionSummary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255, 255, 255, 0.08)' : 'rgba(0, 0, 0, 0.08)',\n }),\n accordionTitle: {\n // fontWeight: 'bold',\n },\n toolbar: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255, 255, 255, 0.08)' : 'rgba(0, 0, 0, 0.08)',\n borderRadius: '3px',\n }),\n tooltip: {\n pointerEvents: 'none',\n },\n};\n\ninterface ConfigAccordionProps extends ConfigGenericProps {\n schema: ConfigItemAccordion;\n}\n\ninterface ConfigAccordionState extends ConfigGenericState {\n value: Record<string, any>[];\n activeIndex: number;\n iteration: number;\n accordionErrors: Record<number, Record<string, string>>; // accordion index -> attr -> error\n}\n\nclass ConfigAccordion extends ConfigGeneric<ConfigAccordionProps, ConfigAccordionState> {\n private typingTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(props: ConfigAccordionProps) {\n super(props);\n this.props.schema.items ||= [];\n }\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n let value = ConfigGeneric.getValue(this.props.data, this.props.attr) || [];\n\n if (!Array.isArray(value)) {\n value = [];\n }\n\n this.setState({\n value,\n activeIndex: -1,\n iteration: 0,\n accordionErrors: {},\n });\n }\n\n componentWillUnmount(): void {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n this.typingTimer = null;\n }\n super.componentWillUnmount();\n }\n\n onAccordionError =\n (accordionIndex: number) =>\n (attr: string, error?: string): void => {\n const newAccordionErrors = { ...this.state.accordionErrors };\n\n if (!newAccordionErrors[accordionIndex]) {\n newAccordionErrors[accordionIndex] = {};\n }\n\n if (!error) {\n delete newAccordionErrors[accordionIndex][attr];\n // Clean up empty accordion error objects\n if (Object.keys(newAccordionErrors[accordionIndex]).length === 0) {\n delete newAccordionErrors[accordionIndex];\n }\n } else {\n newAccordionErrors[accordionIndex][attr] = error;\n }\n\n this.setState({ accordionErrors: newAccordionErrors });\n\n // Also forward to parent\n this.props.onError(attr, error);\n };\n\n hasAccordionErrors = (accordionIndex: number): boolean => {\n return !!(\n this.state.accordionErrors[accordionIndex] &&\n Object.keys(this.state.accordionErrors[accordionIndex]).length > 0\n );\n };\n\n itemAccordion(data: Record<string, any>, idx: number): JSX.Element {\n const { value } = this.state;\n const { schema } = this.props;\n\n const schemaItem: ConfigItemPanel = {\n type: 'panel',\n items: schema.items.reduce(\n (accumulator: Record<string, ConfigItemIndexed>, currentValue: ConfigItemIndexed) => {\n accumulator[currentValue.attr] = currentValue;\n return accumulator;\n },\n {},\n ) as Record<string, ConfigItemAny>,\n style: { marginLeft: '-8px', marginTop: '10px', marginBottom: '10px' },\n };\n\n return (\n <ConfigPanel\n oContext={this.props.oContext}\n index={idx + this.state.iteration}\n arrayIndex={idx}\n changed={this.props.changed}\n expertMode={this.props.expertMode}\n globalData={this.props.data}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={data}\n custom\n schema={schemaItem}\n originalData={this.props.originalData}\n onChange={(attr: string, valueChange: any): void => {\n const newObj: Record<string, any> = JSON.parse(JSON.stringify(value));\n newObj[idx][attr] = valueChange;\n this.setState({ value: newObj } as ConfigAccordionState, () => this.onChangeWrapper(newObj));\n }}\n onError={this.onAccordionError(idx)}\n onHiddenChanged={this.props.onHiddenChanged}\n table={this.props.table}\n customComponents={this.props.customComponents}\n />\n );\n }\n\n onDelete = (index: number) => (): void => {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n newValue.splice(index, 1);\n\n this.setState({ value: newValue, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n };\n\n onClone = (index: number) => (): void => {\n const newValue = JSON.parse(JSON.stringify(this.state.value)) as Record<string, any>[];\n const cloned = JSON.parse(JSON.stringify(newValue[index]));\n if (typeof this.props.schema.clone === 'string' && typeof cloned[this.props.schema.clone] === 'string') {\n let i = 1;\n let text = cloned[this.props.schema.clone];\n const pattern = text.match(/(\\d+)$/);\n if (pattern) {\n text = text.replace(pattern[0], '');\n i = parseInt(pattern[0], 10) + 1;\n } else {\n text += '_';\n }\n while (newValue.find(it => it[this.props.schema.clone as string] === text + i.toString())) {\n i++;\n }\n cloned[this.props.schema.clone] = `${cloned[this.props.schema.clone]}_${i}`;\n }\n\n newValue.splice(index, 0, cloned);\n\n this.setState(\n {\n value: newValue,\n activeIndex: -1,\n iteration: this.state.iteration + 10000,\n },\n () => this.onChangeWrapper(newValue),\n );\n };\n\n onChangeWrapper = (newValue: any): void => {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n }\n\n this.typingTimer = setTimeout(\n value => {\n this.typingTimer = null;\n\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n void mayByPromise.catch(e => this.onError(e));\n }\n },\n 300,\n newValue,\n );\n };\n\n onAdd = async (): Promise<void> => {\n const { schema } = this.props;\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const newItem: Record<string, any> = {};\n\n if (schema.items) {\n for (const currentValue of schema.items) {\n let defaultValue;\n if (currentValue.defaultFunc) {\n if (this.props.custom) {\n defaultValue = currentValue.defaultFunc\n ? await this.executeCustom(\n currentValue.defaultFunc,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n } else {\n defaultValue = currentValue.defaultFunc\n ? await this.execute(\n currentValue.defaultFunc,\n this.props.schema.default,\n this.props.data,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n }\n } else {\n defaultValue = currentValue.default ?? null;\n }\n\n newItem[currentValue.attr] = defaultValue;\n }\n }\n\n newValue.push(newItem);\n\n this.setState({ value: newValue, activeIndex: newValue.length - 1 }, () => this.onChangeWrapper(newValue));\n };\n\n onMoveUp(idx: number): void {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const item = newValue[idx];\n newValue.splice(idx, 1);\n newValue.splice(idx - 1, 0, item);\n\n const newIndex = this.state.activeIndex - 1;\n this.setState({ value: newValue, activeIndex: newIndex, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n }\n\n onMoveDown(idx: number): void {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const item = newValue[idx];\n newValue.splice(idx, 1);\n newValue.splice(idx + 1, 0, item);\n\n const newIndex = this.state.activeIndex + 1;\n this.setState({ value: newValue, activeIndex: newIndex, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n }\n\n onExport = (): void => {\n const { value } = this.state;\n const dataStr = JSON.stringify(value, null, 2);\n const dataUri = `data:application/json;charset=utf-8,${encodeURIComponent(dataStr)}`;\n\n const exportFileDefaultName = `config_section_${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.json`;\n\n const linkElement = document.createElement('a');\n linkElement.setAttribute('href', dataUri);\n linkElement.setAttribute('download', exportFileDefaultName);\n linkElement.click();\n };\n\n onImport = (replace: boolean): void => {\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = '.json';\n input.onchange = (event: Event) => {\n const file = (event.target as HTMLInputElement).files?.[0];\n if (!file) {\n return;\n }\n\n const reader = new FileReader();\n reader.onload = e => {\n try {\n const jsonData = JSON.parse(e.target?.result as string);\n\n if (!Array.isArray(jsonData)) {\n alert(I18n.t('jc_Invalid JSON format. Expected an array.'));\n return;\n }\n\n let newValue: Record<string, any>[];\n if (replace) {\n newValue = jsonData;\n } else {\n newValue = [...this.state.value, ...jsonData];\n }\n\n this.setState({ value: newValue, activeIndex: -1 }, () => this.onChangeWrapper(newValue));\n } catch {\n alert(I18n.t('jc_Invalid JSON file.'));\n }\n };\n reader.readAsText(file);\n };\n input.click();\n };\n\n renderItem(/* error, disabled, defaultValue */): JSX.Element | null {\n const { schema } = this.props;\n const { value } = this.state;\n\n if (!value) {\n return null;\n }\n\n return (\n <Paper>\n {schema.label || !schema.noDelete ? (\n <Toolbar variant=\"dense\">\n {schema.label ? (\n <Typography\n variant=\"h6\"\n id=\"tableTitle\"\n component=\"div\"\n >\n {this.getText(schema.label)}\n </Typography>\n ) : null}\n {!schema.noDelete ? (\n <>\n <Tooltip title={I18n.t('jc_Export configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onExport}\n >\n <FileDownloadIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title={I18n.t('jc_Import and replace configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={() => this.onImport(true)}\n >\n <FileUploadIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title={I18n.t('jc_Import and add configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={() => this.onImport(false)}\n >\n <AddCircleIcon />\n </IconButton>\n </Tooltip>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\n </>\n ) : null}\n </Toolbar>\n ) : null}\n {value.map((idx, i) => (\n <Accordion\n key={`${idx as unknown as string}_${i}`}\n expanded={this.state.activeIndex === i}\n onChange={(_e, expanded) => this.setState({ activeIndex: expanded ? i : -1 })}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(this.props.oContext.theme, styles.fullWidth, styles.accordionSummary)}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}>\n <Typography style={styles.accordionTitle}>{idx[schema.titleAttr]}</Typography>\n {this.hasAccordionErrors(i) && <ErrorIcon sx={{ fontSize: 20, color: 'error.main' }} />}\n </Box>\n </AccordionSummary>\n <AccordionDetails\n style={{\n ...schema.style,\n ...(this.props.oContext.themeType ? schema.darkStyle : undefined),\n }}\n >\n {this.itemAccordion(value[i], i)}\n <Toolbar sx={styles.toolbar}>\n {i ? (\n <Tooltip\n title={I18n.t('jc_Move up')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={() => this.onMoveUp(i)}\n >\n <UpIcon />\n </IconButton>\n </Tooltip>\n ) : (\n <div style={styles.buttonEmpty} />\n )}\n {i < value.length - 1 ? (\n <Tooltip\n title={I18n.t('jc_Move down')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={() => this.onMoveDown(i)}\n >\n <DownIcon />\n </IconButton>\n </Tooltip>\n ) : (\n <div style={styles.buttonEmpty} />\n )}\n {!schema.noDelete ? (\n <Tooltip\n title={I18n.t('jc_Delete current row')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={this.onDelete(i)}\n >\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n ) : null}\n {schema.clone ? (\n <Tooltip\n title={I18n.t('jc_Clone current row')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={this.onClone(i)}\n >\n <CopyContentIcon />\n </IconButton>\n </Tooltip>\n ) : null}\n </Toolbar>\n </AccordionDetails>\n </Accordion>\n ))}\n {!schema.noDelete && value.length > 0 ? (\n <Toolbar\n variant=\"dense\"\n sx={styles.rootTool}\n >\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\n </Toolbar>\n ) : null}\n {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 </Paper>\n );\n }\n}\n\nexport default ConfigAccordion;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigAccordion.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAccordion.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EACH,cAAc,EACd,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,KAAK,EACL,OAAO,EACP,OAAO,EACP,UAAU,EACV,GAAG,GACN,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,GAAG,IAAI,OAAO,EACd,MAAM,IAAI,UAAU,EACpB,WAAW,IAAI,MAAM,EACrB,aAAa,IAAI,QAAQ,EAC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O,EAAC,OAAO,EACf,EAAE,EAAE,MAAM,CAAC,QAAQ;gBAEnB,oBAAC,UAAU,IACP,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,IAAI,CAAC,KAAK;oBAEnB,oBAAC,OAAO,OAAG,CACF,CACP,CACb,CAAC,CAAC,CAAC,IAAI;YACP,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CACX,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,CACJ,CACX,CAAC;IACN,CAAC;CACJ;AAED,eAAe,eAAe,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport {\n FormHelperText,\n Accordion,\n AccordionSummary,\n AccordionDetails,\n IconButton,\n Paper,\n Toolbar,\n Tooltip,\n Typography,\n Box,\n} from '@mui/material';\n\nimport {\n Add as AddIcon,\n Delete as DeleteIcon,\n ArrowUpward as UpIcon,\n ArrowDownward as DownIcon,\n ContentCopy as CopyContentIcon,\n ExpandMore as ExpandMoreIcon,\n Error as ErrorIcon,\n FileDownload as FileDownloadIcon,\n FileUpload as FileUploadIcon,\n AddCircle as AddCircleIcon,\n} from '@mui/icons-material';\n\nimport { I18n, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAccordion, ConfigItemAny, ConfigItemIndexed, ConfigItemPanel } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nimport ConfigPanel from './ConfigPanel';\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n },\n accordionSummary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255, 255, 255, 0.08)' : 'rgba(0, 0, 0, 0.08)',\n }),\n accordionTitle: {\n // fontWeight: 'bold',\n },\n toolbar: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255, 255, 255, 0.08)' : 'rgba(0, 0, 0, 0.08)',\n borderRadius: '3px',\n }),\n tooltip: {\n pointerEvents: 'none',\n },\n};\n\ninterface ConfigAccordionProps extends ConfigGenericProps {\n schema: ConfigItemAccordion;\n}\n\ninterface ConfigAccordionState extends ConfigGenericState {\n value: Record<string, any>[];\n activeIndex: number;\n iteration: number;\n accordionErrors: Record<number, Record<string, string>>; // accordion index -> attr -> error\n}\n\nclass ConfigAccordion extends ConfigGeneric<ConfigAccordionProps, ConfigAccordionState> {\n private typingTimer: ReturnType<typeof setTimeout> | null = null;\n\n constructor(props: ConfigAccordionProps) {\n super(props);\n this.props.schema.items ||= [];\n }\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n let value = ConfigGeneric.getValue(this.props.data, this.props.attr) || [];\n\n if (!Array.isArray(value)) {\n value = [];\n }\n\n this.setState({\n value,\n activeIndex: -1,\n iteration: 0,\n accordionErrors: {},\n });\n }\n\n componentWillUnmount(): void {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n this.typingTimer = null;\n }\n super.componentWillUnmount();\n }\n\n onAccordionError =\n (accordionIndex: number) =>\n (attr?: string, error?: string): void => {\n const newAccordionErrors = { ...this.state.accordionErrors };\n\n if (!newAccordionErrors[accordionIndex]) {\n newAccordionErrors[accordionIndex] = {};\n }\n\n if (attr) {\n if (!error) {\n delete newAccordionErrors[accordionIndex][attr];\n // Clean up empty accordion error objects\n if (Object.keys(newAccordionErrors[accordionIndex]).length === 0) {\n delete newAccordionErrors[accordionIndex];\n }\n } else {\n newAccordionErrors[accordionIndex][attr] = error;\n }\n }\n\n this.setState({ accordionErrors: newAccordionErrors });\n\n // Also forward to parent\n this.props.onError(attr, error);\n };\n\n hasAccordionErrors = (accordionIndex: number): boolean => {\n return (\n !!this.state.accordionErrors[accordionIndex] &&\n Object.keys(this.state.accordionErrors[accordionIndex]).length > 0\n );\n };\n\n itemAccordion(data: Record<string, any>, idx: number): JSX.Element {\n const { value } = this.state;\n const { schema } = this.props;\n\n const schemaItem: ConfigItemPanel = {\n type: 'panel',\n items: schema.items.reduce(\n (accumulator: Record<string, ConfigItemIndexed>, currentValue: ConfigItemIndexed) => {\n if (currentValue.attr) {\n accumulator[currentValue.attr] = currentValue;\n }\n return accumulator;\n },\n {},\n ) as Record<string, ConfigItemAny>,\n style: { marginLeft: '-8px', marginTop: '10px', marginBottom: '10px' },\n };\n\n return (\n <ConfigPanel\n oContext={this.props.oContext}\n index={idx + this.state.iteration}\n arrayIndex={idx}\n changed={this.props.changed}\n expertMode={this.props.expertMode}\n globalData={this.props.data}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={data}\n custom\n schema={schemaItem}\n originalData={this.props.originalData}\n onChange={(attr: string | Record<string, any> | undefined, valueChange?: any): void => {\n if (typeof attr === 'string' && attr) {\n const newObj: Record<string, any> = JSON.parse(JSON.stringify(value));\n newObj[idx][attr] = valueChange;\n this.setState({ value: newObj } as ConfigAccordionState, () => this.onChangeWrapper(newObj));\n }\n }}\n onError={this.onAccordionError(idx)}\n onHiddenChanged={this.props.onHiddenChanged}\n table={this.props.table}\n customComponents={this.props.customComponents}\n />\n );\n }\n\n onDelete = (index: number) => (): void => {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n newValue.splice(index, 1);\n\n this.setState({ value: newValue, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n };\n\n onClone = (index: number) => (): void => {\n const newValue = JSON.parse(JSON.stringify(this.state.value)) as Record<string, any>[];\n const cloned = JSON.parse(JSON.stringify(newValue[index]));\n if (typeof this.props.schema.clone === 'string' && typeof cloned[this.props.schema.clone] === 'string') {\n let i = 1;\n let text = cloned[this.props.schema.clone];\n const pattern = text.match(/(\\d+)$/);\n if (pattern) {\n text = text.replace(pattern[0], '');\n i = parseInt(pattern[0], 10) + 1;\n } else {\n text += '_';\n }\n while (newValue.find(it => it[this.props.schema.clone as string] === text + i.toString())) {\n i++;\n }\n cloned[this.props.schema.clone] = `${cloned[this.props.schema.clone]}_${i}`;\n }\n\n newValue.splice(index, 0, cloned);\n\n this.setState(\n {\n value: newValue,\n activeIndex: -1,\n iteration: this.state.iteration + 10000,\n },\n () => this.onChangeWrapper(newValue),\n );\n };\n\n onChangeWrapper = (newValue: any): void => {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n }\n\n this.typingTimer = setTimeout(\n value => {\n this.typingTimer = null;\n if (this.props.attr) {\n const mayByPromise = this.onChange(this.props.attr, value);\n if (mayByPromise instanceof Promise) {\n void mayByPromise.catch(e => this.onError(e));\n }\n }\n },\n 300,\n newValue,\n );\n };\n\n onAdd = async (): Promise<void> => {\n const { schema } = this.props;\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const newItem: Record<string, any> = {};\n\n if (schema.items) {\n for (const currentValue of schema.items) {\n let defaultValue;\n if (currentValue.defaultFunc) {\n if (this.props.custom) {\n defaultValue = currentValue.defaultFunc\n ? await this.executeCustom(\n currentValue.defaultFunc,\n this.props.data,\n this.props.customObj,\n this.props.oContext.instanceObj,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n } else {\n defaultValue = currentValue.defaultFunc\n ? await this.execute(\n currentValue.defaultFunc,\n this.props.schema.default,\n this.props.data,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n }\n } else {\n defaultValue = currentValue.default ?? null;\n }\n\n if (currentValue.attr) {\n newItem[currentValue.attr] = defaultValue;\n }\n }\n }\n\n newValue.push(newItem);\n\n this.setState({ value: newValue, activeIndex: newValue.length - 1 }, () => this.onChangeWrapper(newValue));\n };\n\n onMoveUp(idx: number): void {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const item = newValue[idx];\n newValue.splice(idx, 1);\n newValue.splice(idx - 1, 0, item);\n\n const newIndex = this.state.activeIndex - 1;\n this.setState({ value: newValue, activeIndex: newIndex, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n }\n\n onMoveDown(idx: number): void {\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const item = newValue[idx];\n newValue.splice(idx, 1);\n newValue.splice(idx + 1, 0, item);\n\n const newIndex = this.state.activeIndex + 1;\n this.setState({ value: newValue, activeIndex: newIndex, iteration: this.state.iteration + 10000 }, () =>\n this.onChangeWrapper(newValue),\n );\n }\n\n onExport = (): void => {\n const { value } = this.state;\n const dataStr = JSON.stringify(value, null, 2);\n const dataUri = `data:application/json;charset=utf-8,${encodeURIComponent(dataStr)}`;\n\n const exportFileDefaultName = `config_section_${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.json`;\n\n const linkElement = document.createElement('a');\n linkElement.setAttribute('href', dataUri);\n linkElement.setAttribute('download', exportFileDefaultName);\n linkElement.click();\n };\n\n onImport = (replace: boolean): void => {\n const input = document.createElement('input');\n input.type = 'file';\n input.accept = '.json';\n input.onchange = (event: Event) => {\n const file = (event.target as HTMLInputElement).files?.[0];\n if (!file) {\n return;\n }\n\n const reader = new FileReader();\n reader.onload = e => {\n try {\n const jsonData = JSON.parse(e.target?.result as string);\n\n if (!Array.isArray(jsonData)) {\n alert(I18n.t('jc_Invalid JSON format. Expected an array.'));\n return;\n }\n\n let newValue: Record<string, any>[];\n if (replace) {\n newValue = jsonData;\n } else {\n newValue = [...this.state.value, ...jsonData];\n }\n\n this.setState({ value: newValue, activeIndex: -1 }, () => this.onChangeWrapper(newValue));\n } catch {\n alert(I18n.t('jc_Invalid JSON file.'));\n }\n };\n reader.readAsText(file);\n };\n input.click();\n };\n\n renderItem(/* error, disabled, defaultValue */): JSX.Element | null {\n const { schema } = this.props;\n const { value } = this.state;\n\n if (!value) {\n return null;\n }\n\n return (\n <Paper>\n {schema.label || !schema.noDelete ? (\n <Toolbar variant=\"dense\">\n {schema.label ? (\n <Typography\n variant=\"h6\"\n id=\"tableTitle\"\n component=\"div\"\n >\n {this.getText(schema.label)}\n </Typography>\n ) : null}\n {!schema.noDelete ? (\n <>\n <Tooltip title={I18n.t('jc_Export configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onExport}\n >\n <FileDownloadIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title={I18n.t('jc_Import and replace configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={() => this.onImport(true)}\n >\n <FileUploadIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title={I18n.t('jc_Import and add configuration section')}>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={() => this.onImport(false)}\n >\n <AddCircleIcon />\n </IconButton>\n </Tooltip>\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\n </>\n ) : null}\n </Toolbar>\n ) : null}\n {value.map((idx, i) => (\n <Accordion\n key={`${idx as unknown as string}_${i}`}\n expanded={this.state.activeIndex === i}\n onChange={(_e, expanded) => this.setState({ activeIndex: expanded ? i : -1 })}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(this.props.oContext.theme, styles.fullWidth, styles.accordionSummary)}\n >\n <Box sx={{ display: 'flex', alignItems: 'center', gap: 1, width: '100%' }}>\n {schema.titleAttr && (\n <Typography style={styles.accordionTitle}>{idx[schema.titleAttr]}</Typography>\n )}\n {this.hasAccordionErrors(i) && <ErrorIcon sx={{ fontSize: 20, color: 'error.main' }} />}\n </Box>\n </AccordionSummary>\n <AccordionDetails\n style={{\n ...schema.style,\n ...(this.props.oContext.themeType ? schema.darkStyle : undefined),\n }}\n >\n {this.itemAccordion(value[i], i)}\n <Toolbar sx={styles.toolbar}>\n {i ? (\n <Tooltip\n title={I18n.t('jc_Move up')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={() => this.onMoveUp(i)}\n >\n <UpIcon />\n </IconButton>\n </Tooltip>\n ) : (\n <div style={styles.buttonEmpty} />\n )}\n {i < value.length - 1 ? (\n <Tooltip\n title={I18n.t('jc_Move down')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={() => this.onMoveDown(i)}\n >\n <DownIcon />\n </IconButton>\n </Tooltip>\n ) : (\n <div style={styles.buttonEmpty} />\n )}\n {!schema.noDelete ? (\n <Tooltip\n title={I18n.t('jc_Delete current row')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={this.onDelete(i)}\n >\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n ) : null}\n {schema.clone ? (\n <Tooltip\n title={I18n.t('jc_Clone current row')}\n slotProps={{ popper: { sx: styles.tooltip } }}\n >\n <IconButton\n size=\"small\"\n onClick={this.onClone(i)}\n >\n <CopyContentIcon />\n </IconButton>\n </Tooltip>\n ) : null}\n </Toolbar>\n </AccordionDetails>\n </Accordion>\n ))}\n {!schema.noDelete && value.length > 0 ? (\n <Toolbar\n variant=\"dense\"\n sx={styles.rootTool}\n >\n <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\n </Toolbar>\n ) : null}\n {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 </Paper>\n );\n }\n}\n\nexport default ConfigAccordion;\n"]}
|
|
@@ -17,8 +17,10 @@ export default class ConfigAlive extends ConfigGeneric {
|
|
|
17
17
|
const instance = await this.getInstance();
|
|
18
18
|
this.aliveId = `${instance}.alive`;
|
|
19
19
|
const state = await this.props.oContext.socket.getState(this.aliveId);
|
|
20
|
-
this.setState({ alive: !!
|
|
21
|
-
|
|
20
|
+
this.setState({ alive: !!state?.val, instance }, async () => {
|
|
21
|
+
if (this.aliveId) {
|
|
22
|
+
await this.props.oContext.socket.subscribeState(this.aliveId, this.onAliveChanged);
|
|
23
|
+
}
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
componentWillUnmount() {
|
|
@@ -26,7 +28,9 @@ export default class ConfigAlive extends ConfigGeneric {
|
|
|
26
28
|
clearTimeout(this.checkTimeout);
|
|
27
29
|
this.checkTimeout = null;
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
if (this.aliveId) {
|
|
32
|
+
this.props.oContext.socket.unsubscribeState(this.aliveId, this.onAliveChanged);
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
onAliveChanged = (id, state) => {
|
|
32
36
|
if (id === this.aliveId && this.state.alive !== !!state?.val) {
|
|
@@ -67,7 +71,7 @@ export default class ConfigAlive extends ConfigGeneric {
|
|
|
67
71
|
if (this.state.alive !== false && this.state.alive !== true) {
|
|
68
72
|
return null;
|
|
69
73
|
}
|
|
70
|
-
const instance = this.state.instance
|
|
74
|
+
const instance = this.state.instance?.replace(/^system\.adapter\./, '');
|
|
71
75
|
return (React.createElement("div", { style: { ...styles.root, ...(!this.state.alive ? styles.notAlive : undefined) } }, this.state.alive
|
|
72
76
|
? this.props.schema.textAlive !== undefined
|
|
73
77
|
? this.props.schema.textAlive
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigAlive.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigAlive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAElD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,IAAI,EAAE;QACF,KAAK,EAAE,MAAM;KAChB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,SAAS;KACnB;CACJ,CAAC;AAWF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,aAAiD;IAC9E,OAAO,GAAkB,IAAI,CA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AAK,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;QACxE,OAAO,CACH,6BAAK,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,IAC/E,IAAI,CAAC,KAAK,CAAC,KAAK;YACb,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS;gBACvC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS;oBACzB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC;oBAC/C,CAAC,CAAC,EAAE;gBACR,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,yBAAyB,EAAE,QAAQ,CAAC;YACjD,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,KAAK,SAAS;gBAC5C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY;oBAC5B,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC;oBAClD,CAAC,CAAC,EAAE;gBACR,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,6BAA6B,EAAE,QAAQ,CAAC,CACrD,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemAlive } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n root: {\n width: '100%',\n },\n notAlive: {\n color: '#a30000',\n },\n};\n\ninterface ConfigAliveProps extends ConfigGenericProps {\n schema: ConfigItemAlive;\n}\n\ninterface ConfigAliveState extends ConfigGenericState {\n alive?: boolean | null;\n instance?: string;\n}\n\nexport default class ConfigAlive extends ConfigGeneric<ConfigAliveProps, ConfigAliveState> {\n private aliveId: string | null = null;\n private checkTimeout: ReturnType<typeof setTimeout> | null = null;\n\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n\n const instance = await this.getInstance();\n this.aliveId = `${instance}.alive`;\n const state = await this.props.oContext.socket.getState(this.aliveId);\n this.setState({ alive: !!state?.val, instance }, async (): Promise<void> => {\n if (this.aliveId) {\n await this.props.oContext.socket.subscribeState(this.aliveId, this.onAliveChanged);\n }\n });\n }\n\n componentWillUnmount(): void {\n if (this.checkTimeout) {\n clearTimeout(this.checkTimeout);\n this.checkTimeout = null;\n }\n if (this.aliveId) {\n this.props.oContext.socket.unsubscribeState(this.aliveId, this.onAliveChanged);\n }\n }\n\n onAliveChanged = (id: string, state: ioBroker.State | null | undefined): void => {\n if (id === this.aliveId && this.state.alive !== !!state?.val) {\n this.setState({ alive: !!state?.val });\n }\n };\n\n async getInstance(): Promise<string> {\n let instance =\n this.props.schema.instance || `${this.props.oContext.adapterName}.${this.props.oContext.instance}`;\n if (instance.includes('${')) {\n instance = await this.getPatternAsync(instance, null, true);\n }\n if (instance && !instance.startsWith('system.adapter.')) {\n instance = `system.adapter.${instance}`;\n }\n return instance;\n }\n\n checkIfInstanceChanged(): void {\n if (this.checkTimeout) {\n clearTimeout(this.checkTimeout);\n }\n this.checkTimeout = setTimeout(async () => {\n this.checkTimeout = null;\n const instance = await this.getInstance();\n if (instance !== this.state.instance) {\n if (instance) {\n void this.props.oContext.socket\n .getState(`${instance}.alive`)\n .then(state => this.setState({ alive: !!(state && state.val), instance }));\n } else {\n this.setState({ alive: null, instance });\n }\n }\n }, 200);\n }\n\n renderItem(): JSX.Element | null {\n this.checkIfInstanceChanged();\n\n if (this.state.alive !== false && this.state.alive !== true) {\n return null;\n }\n\n const instance = this.state.instance?.replace(/^system\\.adapter\\./, '');\n return (\n <div style={{ ...styles.root, ...(!this.state.alive ? styles.notAlive : undefined) }}>\n {this.state.alive\n ? this.props.schema.textAlive !== undefined\n ? this.props.schema.textAlive\n ? I18n.t(this.props.schema.textAlive, instance)\n : ''\n : I18n.t('jc_Instance %s is alive', instance)\n : this.props.schema.textNotAlive !== undefined\n ? this.props.schema.textNotAlive\n ? I18n.t(this.props.schema.textNotAlive, instance)\n : ''\n : I18n.t('jc_Instance %s is not alive', instance)}\n </div>\n );\n }\n}\n"]}
|
|
@@ -6,8 +6,8 @@ export interface ConfigAutocompleteProps extends ConfigGenericProps {
|
|
|
6
6
|
}
|
|
7
7
|
export interface ConfigAutocompleteState extends ConfigGenericState {
|
|
8
8
|
selectOptions: {
|
|
9
|
-
value: string;
|
|
10
|
-
label:
|
|
9
|
+
value: string | number;
|
|
10
|
+
label: ioBroker.StringOrTranslated;
|
|
11
11
|
}[];
|
|
12
12
|
}
|
|
13
13
|
declare class ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {
|
|
@@ -8,11 +8,11 @@ class ConfigAutocomplete extends ConfigGeneric {
|
|
|
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
10
|
// Report value-to-label mapping to parent table for filtering
|
|
11
|
-
if (this.props.onFilterLabelUpdate && this.props.table) {
|
|
11
|
+
if (this.props.onFilterLabelUpdate && this.props.table && this.props.attr) {
|
|
12
12
|
const valueToLabel = {};
|
|
13
13
|
for (const opt of selectOptions) {
|
|
14
14
|
if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {
|
|
15
|
-
valueToLabel[opt.value] = opt.label;
|
|
15
|
+
valueToLabel[opt.value] = this.getText(opt.label);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
this.props.onFilterLabelUpdate(this.props.attr, valueToLabel);
|
|
@@ -63,7 +63,7 @@ class ConfigAutocomplete extends ConfigGeneric {
|
|
|
63
63
|
}
|
|
64
64
|
// label/value may be numbers (or null/undefined), so coerce to string before comparing
|
|
65
65
|
// see https://github.com/ioBroker/ioBroker.admin/issues/3507
|
|
66
|
-
return (
|
|
66
|
+
return (this.getText(option.label ?? '')
|
|
67
67
|
.toLowerCase()
|
|
68
68
|
.includes(inputValue) ||
|
|
69
69
|
String(option.value ?? '')
|
|
@@ -85,14 +85,14 @@ class ConfigAutocomplete extends ConfigGeneric {
|
|
|
85
85
|
}
|
|
86
86
|
const val = e.target.value;
|
|
87
87
|
if (val !== this.state.value) {
|
|
88
|
-
this.setState({ value: val }, () => this.onChange(this.props.attr, val));
|
|
88
|
+
this.setState({ value: val }, () => this.props.attr && this.onChange(this.props.attr, val));
|
|
89
89
|
}
|
|
90
90
|
}, onChange: (_, value) => {
|
|
91
91
|
const val = typeof value === 'object' ? (value ? value.value : '') : value;
|
|
92
92
|
if (val !== this.state.value) {
|
|
93
|
-
this.setState({ value: val }, () => this.onChange(this.props.attr, val));
|
|
93
|
+
this.setState({ value: val }, () => this.props.attr && this.onChange(this.props.attr, val));
|
|
94
94
|
}
|
|
95
|
-
}, getOptionLabel: option => (typeof option === 'object' ? (option?.label ?? '') : ''), renderInput: params => (React.createElement(TextField, { variant: "standard", ...params, error: !!error,
|
|
95
|
+
}, getOptionLabel: option => (typeof option === 'object' ? this.getText(option?.label ?? '') : ''), renderInput: params => (React.createElement(TextField, { variant: "standard", ...params, error: !!error,
|
|
96
96
|
// inputProps are important and will be given in params
|
|
97
97
|
// inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}
|
|
98
98
|
placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation), disabled: disabled })) }));
|
|
@@ -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,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,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,8DAA8D;QAC9D,IAAI,IAAI,CAAC,KAAK,CAAC,mBAAmB,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACrD,MAAM,YAAY,GAA2B,EAAE,CAAC;YAChD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;gBAC9B,IAAI,GAAG,CAAC,KAAK,KAAK,aAAa,CAAC,eAAe,EAAE,CAAC;oBAC9C,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C,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 async componentDidMount(): Promise<void> {\n await 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 // never pass `false`/`undefined` as a controlled value to the Autocomplete (would switch it to uncontrolled)\n item ||= null;\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 inputValue = params.inputValue.toLowerCase();\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n // label/value may be numbers (or null/undefined), so coerce to string before comparing\n // see https://github.com/ioBroker/ioBroker.admin/issues/3507\n return (\n String(option.label ?? '')\n .toLowerCase()\n .includes(inputValue) ||\n String(option.value ?? '')\n .toLowerCase()\n .includes(inputValue)\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;AAUlG,MAAM,kBAAmB,SAAQ,aAA+D;IAC5F,KAAK,CAAC,iBAAiB;QACnB,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI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E,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 | number; label: ioBroker.StringOrTranslated }[];\n}\n\nclass ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {\n async componentDidMount(): Promise<void> {\n await super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions: { label: ioBroker.StringOrTranslated; value: string | number }[] =\n this.props.schema.options.map(\n (item: { label: ioBroker.StringOrTranslated; value: string | number } | 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 && this.props.attr) {\n const valueToLabel: Record<string, string> = {};\n for (const opt of selectOptions) {\n if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {\n valueToLabel[opt.value] = this.getText(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 // never pass `false`/`undefined` as a controlled value to the Autocomplete (would switch it to uncontrolled)\n item ||= null;\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 | number; label: ioBroker.StringOrTranslated }[], params) => {\n const inputValue = params.inputValue.toLowerCase();\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n // label/value may be numbers (or null/undefined), so coerce to string before comparing\n // see https://github.com/ioBroker/ioBroker.admin/issues/3507\n return (\n this.getText(option.label ?? '')\n .toLowerCase()\n .includes(inputValue) ||\n String(option.value ?? '')\n .toLowerCase()\n .includes(inputValue)\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.props.attr && 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.props.attr && this.onChange(this.props.attr, val));\n }\n }}\n getOptionLabel={option => (typeof option === 'object' ? this.getText(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"]}
|
|
@@ -80,7 +80,7 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
80
80
|
}
|
|
81
81
|
/** Report value-to-label mapping to parent table for filtering */
|
|
82
82
|
reportFilterLabels(options) {
|
|
83
|
-
if (this.props.onFilterLabelUpdate && this.props.table) {
|
|
83
|
+
if (this.props.onFilterLabelUpdate && this.props.table && this.props.attr) {
|
|
84
84
|
const valueToLabel = {};
|
|
85
85
|
for (const opt of options) {
|
|
86
86
|
if (opt.value !== ConfigGeneric.DIFFERENT_VALUE) {
|
|
@@ -138,7 +138,7 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
138
138
|
},
|
|
139
139
|
}, onChange: e => {
|
|
140
140
|
const value = e.target.value;
|
|
141
|
-
this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));
|
|
141
|
+
this.setState({ value }, () => this.props.attr && this.onChange(this.props.attr, (value || '').trim()));
|
|
142
142
|
}, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) }));
|
|
143
143
|
}
|
|
144
144
|
return (React.createElement(Autocomplete, { value: item, fullWidth: true, freeSolo: !!this.props.schema.freeSolo, options: options, disabled: disabled, isOptionEqualToValue: (option, value) => option.value === value.value, filterOptions: (options, params) => {
|
|
@@ -163,18 +163,18 @@ export default class ConfigAutocompleteSendTo extends ConfigGeneric {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
return filtered;
|
|
166
|
-
}, getOptionLabel: (option) => option?.label ?? '', onInputChange: e => {
|
|
166
|
+
}, getOptionLabel: (option) => this.getText(typeof option === 'object' ? (option?.label ?? '') : option), onInputChange: e => {
|
|
167
167
|
if (!e || !this.props.schema.freeSolo) {
|
|
168
168
|
return;
|
|
169
169
|
}
|
|
170
170
|
const val = e.target.value;
|
|
171
171
|
if (val !== this.state.value) {
|
|
172
|
-
this.setState({ value: val }, () => this.onChange(this.props.attr, val));
|
|
172
|
+
this.setState({ value: val }, () => this.props.attr && this.onChange(this.props.attr, val));
|
|
173
173
|
}
|
|
174
174
|
}, onChange: (_, value) => {
|
|
175
175
|
const val = typeof value === 'object' ? (value ? value.value : '') : value;
|
|
176
176
|
if (val !== this.state.value) {
|
|
177
|
-
this.setState({ value: val }, () => this.onChange(this.props.attr, val));
|
|
177
|
+
this.setState({ value: val }, () => this.props.attr && this.onChange(this.props.attr, val));
|
|
178
178
|
}
|
|
179
179
|
}, renderInput: params => (React.createElement(TextField, { variant: "standard", ...params,
|
|
180
180
|
// inputProps are important and will be given in params
|