@iobroker/json-config 7.4.0 → 7.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -170,8 +170,9 @@ You can install it via GitHub icon in admin by entering `iobroker.jsonconfig-dem
170
170
  - [**`sendTo`:**](#sendto) Button that sends a request to an instance
171
171
  - [**`setState`:**](#setstate) Button that sets an instance's state
172
172
  - [**`slider`:**](#slider) Slider for selecting a value within a range (Admin 6 only)
173
- - [**`state`:**](#state) (admin >= 7.1.0) Show control or information from the state
173
+ - [**`state`:**](#state) Show control or information from the state (admin >= 7.1.0)
174
174
  - [**`staticImage`:**](#staticimage) Displays a static image
175
+ - [**`staticInfo`:**](#staticinfo) Shows static information in preformatted form, like "Title: value unit" (admin >= 7.3.3)
175
176
  - [**`staticLink`:**](#staticlink) Creates a static link
176
177
  - [**`staticText`:**](#statictext) Displays static text (e.g., description)
177
178
  - [**`coordinates`:**](#coordinates) Determines current location and used `system.config` coordinates if not possible in form "latitude,longitude"
@@ -1084,46 +1085,54 @@ Special input for ports. It checks automatically if port is used by other instan
1084
1085
 
1085
1086
  (admin >= 7.1.0) Show control or information from the state
1086
1087
 
1087
- | Property | Description |
1088
- |------------------|-------------------------------------------------------------------------------------------------------------------------------|
1089
- | `oid` | Which object ID should be taken for the controlling. The ID is without "adapter.X." prefix |
1090
- | `system` | If true, the state will be taken from system.adapter.XX.I. and not from XX.I |
1091
- | `control` | How the value of the state should be shown: `text`, `html`, `input`, `slider`, `select`, `button`, `switch`, `number` |
1092
- | `controlled` | If true, the state will be shown as switch, select, button, slider or text input. Used only if no control property is defined |
1093
- | `unit` | Add unit to the value |
1094
- | `trueText` | this text will be shown if the value is true |
1095
- | `trueTextStyle` | Style of the text if the value is true |
1096
- | `falseText` | this text will be shown if the value is false or if the control is a "button" |
1097
- | `falseTextStyle` | Style of the text if the value is false or if the control is a "button" |
1098
- | `trueImage` | This image will be shown if the value is true |
1099
- | `falseImage` | This image will be shown if the value is false or if the control is a "button" |
1100
- | `min` | Minimum value for control type slider or number |
1101
- | `max` | Maximum value for control type slider or number |
1102
- | `step` | Step value for control type slider or number |
1103
- | `controlDelay` | delay in ms for slider or number |
1104
- | `variant` | Variant of button: `contained`, `outlined`, `text` |
1105
- | `readOnly` | Defines if the control is read-only |
1088
+ | Property | Description |
1089
+ |------------------|--------------------------------------------------------------------------------------------------------------------------------------|
1090
+ | `oid` | Which object ID should be taken for the controlling. The ID is without `adapter.X.` prefix |
1091
+ | `system` | If true, the state will be taken from `system.adapter.X.` and not from `adapter.X` |
1092
+ | `foreign` | The `oid` is absolute and no need to add `adapter.X` or `system.adapter.X.` to oid |
1093
+ | `control` | How the value of the state should be shown: `text`, `html`, `input`, `slider`, `select`, `button`, `switch`, `number` |
1094
+ | `controlled` | If true, the state will be shown as switch, select, button, slider or text input. Used only if no control property is defined |
1095
+ | `unit` | Add unit to the value |
1096
+ | `trueText` | this text will be shown if the value is true |
1097
+ | `trueTextStyle` | Style of the text if the value is true |
1098
+ | `falseText` | this text will be shown if the value is false or if the control is a "button" |
1099
+ | `falseTextStyle` | Style of the text if the value is false or if the control is a "button" |
1100
+ | `trueImage` | This image will be shown if the value is true |
1101
+ | `falseImage` | This image will be shown if the value is false or if the control is a "button" |
1102
+ | `min` | Minimum value for control type slider or number |
1103
+ | `max` | Maximum value for control type slider or number |
1104
+ | `step` | Step value for control type slider or number |
1105
+ | `controlDelay` | delay in ms for slider or number |
1106
+ | `variant` | Variant of button: `contained`, `outlined`, `text` |
1107
+ | `readOnly` | Defines if the control is read-only |
1108
+ | `narrow` | Normally the title and value are shown on the left and right of the line. With this flag, the value will appear just after the label |
1109
+ | `blinkOnUpdate` | Value should blink when updated (true or color) |
1110
+ | `size` | Font size: small, normal, large or number |
1111
+ | `addColon` | Add to label the colon at the end if not exist in label |
1112
+ | `labelIcon` | Base64 icon for label |
1106
1113
 
1107
1114
  ### `staticInfo`
1108
1115
 
1109
1116
  (admin >= 7.3.3) Shows static information in preformatted form, like "Title: value unit"
1110
1117
  This control is used mostly in dynamic forms
1111
1118
 
1112
- | Property | Description |
1113
- |-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
1114
- | `data` | Value to be shown |
1115
- | `label` | Label for the value (could be multi-language) |
1116
- | `unit` | (optional) unit (could be multi-language) |
1117
- | `narrow` | (optional) Normally the title and value are shown on the left and right of the line. With this flag, the value will appear just after the label |
1118
- | `addColon` | (optional) Add to label the colon at the end if not exist in label |
1119
- | `blinkOnUpdate` | (optional) Value should blink when updated (true or color) |
1120
- | `blink` | (optional) Value should blink continuously (true or color) |
1121
- | `styleLabel` | (optional) React CSS Styles |
1122
- | `styleValue` | (optional) React CSS Styles |
1123
- | `styleUnit` | (optional) React CSS Styles |
1124
- | `copyToClipboard` | (optional) Show copy to clipboard button for value |
1125
- | `labelIcon` | (optional) base64 icon for label |
1126
- | `size` | (optional) font size: small, normal, large or number |
1119
+ | Property | Description |
1120
+ |---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
1121
+ | `data` | Value to be shown |
1122
+ | `label` | Label for the value (could be multi-language) |
1123
+ | `unit` | (optional) unit (could be multi-language) |
1124
+ | `narrow` | (optional) Normally the title and value are shown on the left and right of the line. With this flag, the value will appear just after the label |
1125
+ | `addColon` | (optional) Add to label the colon at the end if not exist in label |
1126
+ | `blinkOnUpdate` | (optional) Value should blink when updated (true or color) |
1127
+ | `blink` | (optional) Value should blink continuously (true or color) |
1128
+ | `styleLabel` | (optional) React CSS Styles |
1129
+ | `styleValue` | (optional) React CSS Styles |
1130
+ | `styleUnit` | (optional) React CSS Styles |
1131
+ | `copyToClipboard` | (optional) Show copy to clipboard button for value |
1132
+ | `labelIcon` | (optional) base64 icon for label |
1133
+ | `size` | (optional) font size: small, normal, large or number |
1134
+ | `highlight` | (optional) Highlight line on mouse over |
1135
+ | `booleanAsCheckbox` | (optional) Show boolean values as checkbox |
1127
1136
 
1128
1137
  ### `deviceManager`
1129
1138
 
@@ -1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,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} 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} from '@mui/icons-material';\n\nimport { I18n, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAccordion, ConfigItemAny, ConfigItemIndexed, ConfigItemPanel } from '#JC/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) => ({\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) => ({\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}\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 = this.props.schema.items || [];\n }\n\n componentDidMount(): void {\n 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 });\n }\n\n componentWillUnmount(): void {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n this.typingTimer = null;\n }\n super.componentWillUnmount();\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 index={idx + this.state.iteration}\n arrayIndex={idx}\n changed={this.props.changed}\n globalData={this.props.data}\n socket={this.props.socket}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n common={this.props.common}\n alive={this.props.alive}\n themeType={this.props.themeType}\n themeName={this.props.themeName}\n data={data}\n custom\n schema={schemaItem}\n systemConfig={this.props.systemConfig}\n originalData={this.props.originalData}\n customs={this.props.customs}\n dateFormat={this.props.dateFormat}\n isFloatComma={this.props.isFloatComma}\n forceUpdate={this.props.forceUpdate}\n imagePrefix={this.props.imagePrefix}\n onCommandRunning={this.props.onCommandRunning}\n onChange={(attr, valueChange) => {\n const newObj = JSON.parse(JSON.stringify(value));\n (newObj[idx] as Record<string, any>)[attr as string] = valueChange;\n this.setState({ value: newObj }, () => this.onChangeWrapper(newObj));\n }}\n onError={(error, attr) => this.onError(error, attr)}\n onBackEndCommand={this.props.onBackEndCommand}\n table={this.props.table}\n DeviceManager={this.props.DeviceManager}\n theme={this.props.theme}\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 = (): void => {\n const { schema } = this.props;\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const newItem: Record<string, any> =\n schema.items &&\n schema.items.reduce((accumulator: Record<string, any>, currentValue: ConfigItemIndexed) => {\n let defaultValue;\n if (currentValue.defaultFunc) {\n if (this.props.custom) {\n defaultValue = currentValue.defaultFunc\n ? this.executeCustom(\n currentValue.defaultFunc,\n this.props.data,\n this.props.customObj,\n this.props.instanceObj,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n } else {\n defaultValue = currentValue.defaultFunc\n ? 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 === undefined ? null : currentValue.default;\n }\n\n accumulator[currentValue.attr] = defaultValue;\n return accumulator;\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 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 <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\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.theme, styles.fullWidth, styles.accordionSummary)}\n >\n <Typography style={styles.accordionTitle}>{idx[schema.titleAttr]}</Typography>\n </AccordionSummary>\n <AccordionDetails\n style={{ ...schema.style, ...(this.props.themeType ? schema.darkStyle : undefined) }}\n >\n {this.itemAccordion(value[i], i)}\n <Toolbar sx={styles.toolbar}>\n {i ? (\n <Tooltip\n title={I18n.t('ra_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('ra_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('ra_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('ra_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,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,GAAG,IAAI,OAAO,EACd,MAAM,IAAI,UAAU,EACpB,WAAW,IAAI,MAAM,EACrB,aAAa,IAAI,QAAQ,EACzB,WAAW,IAAI,eAAe,EAC9B,UAAU,IAAI,cAAc,GAC/B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,IAAI,EAAiB,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC,MAAM,MAAM,GAAwB;IAChC,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;IACD,gBAAgB,EAAE,CAAC,KAAe,EAAuB,EAAE,CAAC,CAAC;QACzD,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,qBAAqB;KACvG,CAAC;IACF,cAAc,EAAE;IACZ,sBAAsB;KACzB;IACD,OAAO,EAAE,CAAC,KAAe,EAAuB,EAAE,CAAC,CAAC;QAChD,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,MAAM,CA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,CAAC,CAAC,CAAC,CACpC,oBAAC,OAAO,IACJ,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} 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} from '@mui/icons-material';\n\nimport { I18n, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAccordion, ConfigItemAny, ConfigItemIndexed, ConfigItemPanel } from '#JC/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}\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 = this.props.schema.items || [];\n }\n\n componentDidMount(): void {\n 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 });\n }\n\n componentWillUnmount(): void {\n if (this.typingTimer) {\n clearTimeout(this.typingTimer);\n this.typingTimer = null;\n }\n super.componentWillUnmount();\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 index={idx + this.state.iteration}\n arrayIndex={idx}\n changed={this.props.changed}\n globalData={this.props.data}\n socket={this.props.socket}\n adapterName={this.props.adapterName}\n instance={this.props.instance}\n common={this.props.common}\n alive={this.props.alive}\n themeType={this.props.themeType}\n themeName={this.props.themeName}\n data={data}\n custom\n schema={schemaItem}\n systemConfig={this.props.systemConfig}\n originalData={this.props.originalData}\n customs={this.props.customs}\n dateFormat={this.props.dateFormat}\n isFloatComma={this.props.isFloatComma}\n forceUpdate={this.props.forceUpdate}\n imagePrefix={this.props.imagePrefix}\n onCommandRunning={this.props.onCommandRunning}\n onChange={(attr, valueChange) => {\n const newObj = JSON.parse(JSON.stringify(value));\n (newObj[idx] as Record<string, any>)[attr as string] = valueChange;\n this.setState({ value: newObj }, () => this.onChangeWrapper(newObj));\n }}\n onError={(error, attr) => this.onError(error, attr)}\n onBackEndCommand={this.props.onBackEndCommand}\n table={this.props.table}\n DeviceManager={this.props.DeviceManager}\n theme={this.props.theme}\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 = (): void => {\n const { schema } = this.props;\n const newValue = JSON.parse(JSON.stringify(this.state.value));\n const newItem: Record<string, any> =\n schema.items &&\n schema.items.reduce((accumulator: Record<string, any>, currentValue: ConfigItemIndexed) => {\n let defaultValue;\n if (currentValue.defaultFunc) {\n if (this.props.custom) {\n defaultValue = currentValue.defaultFunc\n ? this.executeCustom(\n currentValue.defaultFunc,\n this.props.data,\n this.props.customObj,\n this.props.instanceObj,\n newValue.length,\n this.props.data,\n )\n : this.props.schema.default;\n } else {\n defaultValue = currentValue.defaultFunc\n ? 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 === undefined ? null : currentValue.default;\n }\n\n accumulator[currentValue.attr] = defaultValue;\n return accumulator;\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 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 <IconButton\n size=\"small\"\n color=\"primary\"\n onClick={this.onAdd}\n >\n <AddIcon />\n </IconButton>\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.theme, styles.fullWidth, styles.accordionSummary)}\n >\n <Typography style={styles.accordionTitle}>{idx[schema.titleAttr]}</Typography>\n </AccordionSummary>\n <AccordionDetails\n style={{ ...schema.style, ...(this.props.themeType ? schema.darkStyle : undefined) }}\n >\n {this.itemAccordion(value[i], i)}\n <Toolbar sx={styles.toolbar}>\n {i ? (\n <Tooltip\n title={I18n.t('ra_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('ra_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('ra_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('ra_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"]}
@@ -43,7 +43,22 @@ class ConfigAutocomplete extends ConfigGeneric {
43
43
  options.push(item);
44
44
  }
45
45
  }
46
- return (React.createElement(Autocomplete, { fullWidth: true, freeSolo: !!this.props.schema.freeSolo, value: item, options: options,
46
+ return (React.createElement(Autocomplete, { fullWidth: true, freeSolo: !!this.props.schema.freeSolo, value: item, options: options, isOptionEqualToValue: (option, value) => option.value === value.value, filterOptions: (options, params) => {
47
+ const filtered = options.filter(option => {
48
+ if (params.inputValue === '') {
49
+ return true;
50
+ }
51
+ return (option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||
52
+ option.value.toLowerCase().includes(params.inputValue.toLowerCase()));
53
+ });
54
+ if (this.props.schema.freeSolo && params.inputValue !== '') {
55
+ filtered.push({
56
+ label: params.inputValue,
57
+ value: params.inputValue,
58
+ });
59
+ }
60
+ return filtered;
61
+ },
47
62
  // autoComplete
48
63
  onInputChange: e => {
49
64
  if (!e || !this.props.schema.freeSolo) {
@@ -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,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C,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC3E,IAAI,GAAG,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;oBAC1B,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;iBAC5E;YACL,CAAC,EACD,cAAc,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACnF,WAAW,EAAE,MAAM,CAAC,EAAE,CAAC,CACnB,oBAAC,SAAS,IACN,OAAO,EAAC,UAAU,KACd,MAAM,EACV,KAAK,EAAE,CAAC,CAAC,KAAK;gBACd,uDAAuD;gBACvD,8FAA8F;gBAC9F,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EAAE,IAAI,CAAC,UAAU,CACvB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,EACD,QAAQ,EAAE,QAAQ,GACpB,CACL,GACH,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocomplete, ConfigItemSelectOption } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\n\nexport interface ConfigAutocompleteProps extends ConfigGenericProps {\n schema: ConfigItemAutocomplete;\n}\n\nexport interface ConfigAutocompleteState extends ConfigGenericState {\n selectOptions: { value: string; label: string }[];\n}\n\nclass ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {\n componentDidMount(): void {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions = this.props.schema.options.map((item: any) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\n );\n\n // if __different\n if (Array.isArray(value)) {\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n let item;\n const options: (string | ConfigItemSelectOption)[] = JSON.parse(JSON.stringify(this.state.selectOptions));\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find(it => (typeof it === 'object' ? it.value === val : it === val)))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find(_item =>\n typeof _item === 'object' ? _item.value == this.state.value : _item == this.state.value,\n ); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n }\n\n return (\n <Autocomplete\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n value={item}\n options={options}\n // 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,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEvE,MAAM,aAAa,GAAuC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CACnF,CAAC,IAA+C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AAI,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 '#JC/types';\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\n\nexport interface ConfigAutocompleteProps extends ConfigGenericProps {\n schema: ConfigItemAutocomplete;\n}\n\nexport interface ConfigAutocompleteState extends ConfigGenericState {\n selectOptions: { value: string; label: string }[];\n}\n\nclass ConfigAutocomplete extends ConfigGeneric<ConfigAutocompleteProps, ConfigAutocompleteState> {\n componentDidMount(): void {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n const selectOptions: { label: string; value: string }[] = this.props.schema.options.map(\n (item: { label: string; value: string } | string) =>\n typeof item === 'string' ? { label: item, value: item } : JSON.parse(JSON.stringify(item)),\n );\n\n // if __different\n if (Array.isArray(value)) {\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (!this.state.selectOptions) {\n return null;\n }\n\n let item;\n const options: ConfigItemSelectOption[] = JSON.parse(JSON.stringify(this.state.selectOptions));\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find(it => (typeof it === 'object' ? it.value === val : it === val)))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find(_item =>\n typeof _item === 'object' ? _item.value == this.state.value : _item == this.state.value,\n ); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n }\n\n return (\n <Autocomplete\n fullWidth\n freeSolo={!!this.props.schema.freeSolo}\n value={item}\n options={options}\n isOptionEqualToValue={(option, value) => option.value === value.value}\n filterOptions={(options: { value: string; label: string }[], params) => {\n const filtered = options.filter(option => {\n if (params.inputValue === '') {\n return true;\n }\n return (\n option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||\n option.value.toLowerCase().includes(params.inputValue.toLowerCase())\n );\n });\n\n if (this.props.schema.freeSolo && params.inputValue !== '') {\n filtered.push({\n label: params.inputValue,\n value: params.inputValue,\n });\n }\n\n return filtered;\n }}\n // autoComplete\n onInputChange={e => {\n if (!e || !this.props.schema.freeSolo) {\n return;\n }\n\n const val = (e.target as HTMLInputElement).value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n onChange={(_, value) => {\n const val = typeof value === 'object' ? (value ? value.value : '') : value;\n if (val !== this.state.value) {\n this.setState({ value: val }, () => this.onChange(this.props.attr, val));\n }\n }}\n getOptionLabel={option => (typeof option === 'object' ? (option?.label ?? '') : '')}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n // inputProps are important and will be given in params\n // inputProps={{maxLength: this.props.schema.maxLength || this.props.schema.max || undefined}}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )}\n disabled={disabled}\n />\n )}\n />\n );\n }\n}\n\nexport default ConfigAutocomplete;\n"]}
@@ -76,7 +76,9 @@ class ConfigAutocompleteSendTo extends ConfigGeneric {
76
76
  }
77
77
  }
78
78
  let item;
79
- const options = this.state.selectOptions ? JSON.parse(JSON.stringify(this.state.selectOptions)) : [];
79
+ const options = this.state.selectOptions
80
+ ? JSON.parse(JSON.stringify(this.state.selectOptions))
81
+ : [];
80
82
  const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_LABEL;
81
83
  if (isIndeterminate) {
82
84
  [...this.state.value]
@@ -106,9 +108,22 @@ class ConfigAutocompleteSendTo extends ConfigGeneric {
106
108
  this.setState({ value }, () => this.onChange(this.props.attr, (value || '').trim()));
107
109
  }, 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) }));
108
110
  }
109
- return (React.createElement(Autocomplete, { value: item, fullWidth: true, freeSolo: !!this.props.schema.freeSolo, options: options,
110
- // autoComplete
111
- getOptionLabel: option => option?.label ?? '', onInputChange: e => {
111
+ return (React.createElement(Autocomplete, { value: item, fullWidth: true, freeSolo: !!this.props.schema.freeSolo, options: options, isOptionEqualToValue: (option, value) => option.value === value.value, filterOptions: (options, params) => {
112
+ const filtered = options.filter(option => {
113
+ if (params.inputValue === '') {
114
+ return true;
115
+ }
116
+ return (option.label.toLowerCase().includes(params.inputValue.toLowerCase()) ||
117
+ option.value.toLowerCase().includes(params.inputValue.toLowerCase()));
118
+ });
119
+ if (this.props.schema.freeSolo && params.inputValue !== '') {
120
+ filtered.push({
121
+ label: params.inputValue,
122
+ value: params.inputValue,
123
+ });
124
+ }
125
+ return filtered;
126
+ }, getOptionLabel: (option) => option?.label ?? '', onInputChange: e => {
112
127
  if (!e || !this.props.schema.freeSolo) {
113
128
  return;
114
129
  }
@@ -1 +1 @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material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemAutocompleteSendTo } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps } from './ConfigGeneric';\nimport type { ConfigAutocompleteState } from './ConfigAutocomplete';\n\ninterface ConfigAutocompleteSendToProps extends ConfigGenericProps {\n schema: ConfigItemAutocompleteSendTo;\n}\n\nclass ConfigAutocompleteSendTo extends ConfigGeneric<ConfigAutocompleteSendToProps, ConfigAutocompleteState> {\n private initialized = false;\n\n private _context: 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);\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 void this.props.socket\n .sendTo(`${this.props.adapterName}.${this.props.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 // 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 } else if (Array.isArray(value)) {\n // if __different\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n getContext(): string {\n const context: Record<string, any> = {};\n if (Array.isArray(this.props.schema.alsoDependsOn)) {\n this.props.schema.alsoDependsOn.forEach(\n attr => (context[attr] = ConfigGeneric.getValue(this.props.data, attr)),\n );\n }\n return JSON.stringify(context);\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (this.props.alive) {\n const context = this.getContext();\n if (context !== this._context || !this.initialized) {\n this._context = context;\n setTimeout(() => this.askInstance(), this.initialized ? 300 : 50);\n this.initialized = true;\n }\n }\n\n let item;\n const options = this.state.selectOptions ? JSON.parse(JSON.stringify(this.state.selectOptions)) : [];\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_LABEL;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find((it: any) => it.value === val))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find((item: any) => item.value == this.state.value); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n item = item || null;\n }\n\n if (!options.length) {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\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 // autoComplete\n getOptionLabel={option => 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 />\n )}\n />\n );\n }\n}\n\nexport default ConfigAutocompleteSendTo;\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,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAA0C,MAAM,iBAAiB,CAAC;AAOzE,MAAM,wBAAyB,SAAQ,aAAqE;IAChG,WAAW,GAAG,KAAK,CAAC;IAEpB,QAAQ,CAAqB;IAErC,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,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AC,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,wBAAwB,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 { ConfigItemAutocompleteSendTo } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps } from './ConfigGeneric';\nimport type { ConfigAutocompleteState } from './ConfigAutocomplete';\n\ninterface ConfigAutocompleteSendToProps extends ConfigGenericProps {\n schema: ConfigItemAutocompleteSendTo;\n}\n\nclass ConfigAutocompleteSendTo extends ConfigGeneric<ConfigAutocompleteSendToProps, ConfigAutocompleteState> {\n private initialized = false;\n\n private _context: 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);\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 void this.props.socket\n .sendTo(`${this.props.adapterName}.${this.props.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 // 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 } else if (Array.isArray(value)) {\n // if __different\n selectOptions.unshift({\n label: I18n.t(ConfigGeneric.DIFFERENT_LABEL),\n value: ConfigGeneric.DIFFERENT_VALUE,\n });\n this.setState({ value: ConfigGeneric.DIFFERENT_VALUE, selectOptions });\n } else {\n this.setState({ value, selectOptions });\n }\n }\n\n getContext(): string {\n const context: Record<string, any> = {};\n if (Array.isArray(this.props.schema.alsoDependsOn)) {\n this.props.schema.alsoDependsOn.forEach(\n attr => (context[attr] = ConfigGeneric.getValue(this.props.data, attr)),\n );\n }\n return JSON.stringify(context);\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n if (this.props.alive) {\n const context = this.getContext();\n if (context !== this._context || !this.initialized) {\n this._context = context;\n setTimeout(() => this.askInstance(), this.initialized ? 300 : 50);\n this.initialized = true;\n }\n }\n\n let item;\n const options: { value: string; label: string }[] = this.state.selectOptions\n ? JSON.parse(JSON.stringify(this.state.selectOptions))\n : [];\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_LABEL;\n\n if (isIndeterminate) {\n [...this.state.value]\n .filter(val => !options.find((it: any) => it.value === val))\n .forEach(it => options.push({ label: it.toString(), value: it }));\n\n item = { label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE };\n options.unshift(item);\n } else {\n item =\n this.state.value !== null &&\n this.state.value !== undefined &&\n options.find((item: any) => item.value == this.state.value); // let \"==\" be and not ===\n\n if (this.state.value !== null && this.state.value !== undefined && !item && this.props.schema.freeSolo) {\n item = { value: this.state.value, label: this.state.value };\n options.push(item);\n }\n item = item || null;\n }\n\n if (!options.length) {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\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 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 />\n )}\n />\n );\n }\n}\n\nexport default ConfigAutocompleteSendTo;\n"]}