@iobroker/json-config 7.3.2 → 7.4.1
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 +64 -31
- package/build/JsonConfigComponent/ConfigAccordion.js.map +1 -1
- package/build/JsonConfigComponent/ConfigCheckLicense.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPanel.js +2 -0
- package/build/JsonConfigComponent/ConfigPanel.js.map +1 -1
- package/build/JsonConfigComponent/ConfigPattern.js +2 -2
- package/build/JsonConfigComponent/ConfigPattern.js.map +1 -1
- package/build/JsonConfigComponent/ConfigState.js +219 -138
- package/build/JsonConfigComponent/ConfigState.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticDivider.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticHeader.js +12 -5
- package/build/JsonConfigComponent/ConfigStaticHeader.js.map +1 -1
- package/build/JsonConfigComponent/ConfigStaticInfo.d.ts +10 -0
- package/build/JsonConfigComponent/ConfigStaticInfo.js +251 -0
- package/build/JsonConfigComponent/ConfigStaticInfo.js.map +1 -0
- package/build/JsonConfigComponent/ConfigStaticText.d.ts +2 -2
- package/build/JsonConfigComponent/ConfigStaticText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTable.js +1 -1
- package/build/JsonConfigComponent/ConfigTable.js.map +1 -1
- package/build/JsonConfigComponent/ConfigText.js +15 -7
- package/build/JsonConfigComponent/ConfigText.js.map +1 -1
- package/build/JsonConfigComponent/ConfigTextSendTo.js +2 -2
- package/build/JsonConfigComponent/ConfigTextSendTo.js.map +1 -1
- package/build/types.d.ts +54 -4
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigText.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,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,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,CAC1D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CACrC;4BAGL,oBAAC,SAAS,OAAG,CACJ,CACA,CACpB,CAAC,CAAC,CAAC,IAAI;iBACf;aACJ,EACD,QAAQ,EAAE,CAAC,CAAC,EAAE;gBACV,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;gBAE7B,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,CAC3F,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CACxC,CAAC;YACN,CAAC,EACD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EACxD,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,UAAU,EACN,IAAI,CAAC,KAAK,CAAC,SAAS;gBAChB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;gBAC3B,CAAC,CAAC,IAAI,CAAC,UAAU,CACX,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EACtB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GAEb,CACL,CAAC;IACN,CAAC;CACJ;AAED,eAAe,UAAU,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, TextareaAutosize, InputAdornment, IconButton } from '@mui/material';\n\nimport { Close as CloseIcon } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemText } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n indeterminate: {\n opacity: 0.5,\n },\n label: {\n width: '100%',\n fontSize: 16,\n },\n helper: {\n width: '100%',\n fontSize: 12,\n },\n error: {\n width: '100%',\n fontSize: 12,\n color: '#FF0000',\n },\n};\n\ninterface ConfigTextProps extends ConfigGenericProps {\n schema: ConfigItemText;\n}\n\ninterface ConfigTextState extends ConfigGenericState {\n oldValue?: string;\n jsonError?: boolean;\n}\n\nclass ConfigText extends ConfigGeneric<ConfigTextProps, ConfigTextState> {\n private updateTimeout: ReturnType<typeof setTimeout> | null = null;\n\n componentDidMount(): void {\n super.componentDidMount();\n let value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (Array.isArray(value) && this.props.multiEdit) {\n value = ConfigGeneric.DIFFERENT_VALUE;\n this.setState({ value, oldValue: value, jsonError: false });\n return;\n }\n\n this.setState({ value, oldValue: value, jsonError: this.validateJson(value) });\n }\n\n validateJson(value: string | null | undefined): boolean {\n let jsonError = false;\n if (this.props.schema.validateJson) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n JSON.parse(value);\n } catch (err: unknown) {\n console.log('Error in JSON', err);\n jsonError = true;\n }\n }\n }\n\n return jsonError;\n }\n\n static getDerivedStateFromProps(props: ConfigTextProps, state: ConfigTextState): Partial<ConfigTextState> | null {\n if (props.multiEdit && state.value === ConfigGeneric.DIFFERENT_VALUE) {\n return { value: ConfigGeneric.DIFFERENT_VALUE };\n }\n\n let value = ConfigGeneric.getValue(props.data, props.attr);\n\n if (value !== null && value !== undefined) {\n value = value.toString();\n }\n\n if (value === null || value === undefined || (value !== state.value && value !== state.oldValue)) {\n return { value };\n }\n return null;\n }\n\n renderItem(error?: boolean, disabled?: boolean): JSX.Element {\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (this.props.schema.time) {\n // show read-only time\n\n let time = '';\n if (typeof this.state.value === 'number') {\n // If the value is a number, it is a timestamp.\n if (this.state.value && this.state.value < 946659600000) {\n // If the value is less than 2000-01-01, it is a timestamp in seconds.\n time = new Date(this.state.value * 1000).toLocaleString();\n } else {\n time = new Date(this.state.value).toLocaleString();\n }\n } else if (typeof this.state.value === 'string') {\n // If the value is a string, it is a date string.\n time = new Date(this.state.value).toLocaleString();\n }\n\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={time}\n error={!!error || !!this.state.jsonError}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n readOnly: true,\n },\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\n if (this.state.oldValue !== null && this.state.oldValue !== undefined) {\n if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n }\n this.updateTimeout = setTimeout(() => {\n this.updateTimeout = null;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = null;\n }\n\n if (isIndeterminate) {\n const autoCompleteOptions = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const arr =\n autoCompleteOptions\n ?.filter((a: any) => a || a === 0)\n .map((item: any) => ({ label: item.toString() || '', value: item })) || [];\n\n arr.unshift({ label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE });\n\n return (\n <Autocomplete\n style={styles.indeterminate}\n fullWidth\n value={arr[0]}\n // getOptionSelected={(option, value) => option.label === value.label}\n onChange={(_, value) => {\n const val = value ? value.value : '';\n const mayBePromise = this.onChange(this.props.attr, val, () => {\n this.setState({ value: val, oldValue: val, jsonError: this.validateJson(value) });\n });\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }}\n options={arr}\n getOptionLabel={option => option.label}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\n slotProps={{\n htmlInput: {\n ...params.inputProps,\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.props.schema.readOnly || false,\n },\n }}\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 if (this.props.schema.minRows > 1) {\n const helper = this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n );\n return (\n <div style={{ width: '100%' }}>\n {this.props.schema.label ? (\n <div style={styles.label}>{this.getText(this.props.schema.label)}</div>\n ) : null}\n <TextareaAutosize\n // variant=\"standard\"\n style={{\n width: '100%',\n resize: 'vertical',\n backgroundColor: this.props.themeType === 'dark' ? '#363636' : '#cccccc',\n color: this.props.themeType === 'dark' ? '#fff' : '#111',\n }}\n minRows={this.props.schema.minRows}\n maxRows={this.props.schema.maxRows}\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n disabled={!!disabled}\n readOnly={this.props.schema.readOnly || false}\n onChange={e => {\n const value = e.target.value;\n this.setState(\n { value, oldValue: this.state.value, jsonError: this.validateJson(value) },\n () => this.onChange(this.props.attr, value || ''),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n />\n {helper || error || this.state.jsonError ? (\n <div style={error ? styles.error : styles.helper}>\n {error || (this.state.jsonError ? I18n.t('ra_Invalid JSON') : helper)}\n </div>\n ) : null}\n </div>\n );\n }\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 || !!this.state.jsonError}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment:\n !this.props.schema.readOnly &&\n !disabled &&\n this.state.value &&\n !this.props.schema.noClearButton ? (\n <InputAdornment position=\"end\">\n <IconButton\n size=\"small\"\n onClick={() =>\n this.setState({ value: '', oldValue: this.state.value }, () =>\n this.onChange(this.props.attr, ''),\n )\n }\n >\n <CloseIcon />\n </IconButton>\n </InputAdornment>\n ) : null,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n\n this.setState({ value, oldValue: this.state.value, jsonError: this.validateJson(value) }, () =>\n this.onChange(this.props.attr, value),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n this.state.jsonError\n ? I18n.t('ra_Invalid JSON')\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n );\n }\n}\n\nexport default ConfigText;\n"]}
|
|
1
|
+
{"version":3,"file":"ConfigText.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigText.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,aAAa,EAAE;QACX,OAAO,EAAE,GAAG;KACf;IACD,KAAK,EAAE;QACH,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,EAAE;KACf;IACD,MAAM,EAAE;QACJ,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,EAAE;KACf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React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, TextareaAutosize, InputAdornment, IconButton } from '@mui/material';\n\nimport { Close as CloseIcon } from '@mui/icons-material';\n\nimport { I18n, IconCopy, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemText } from '#JC/types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n indeterminate: {\n opacity: 0.5,\n },\n label: {\n width: '100%',\n fontSize: 16,\n },\n helper: {\n width: '100%',\n fontSize: 12,\n },\n error: {\n width: '100%',\n fontSize: 12,\n color: '#FF0000',\n },\n};\n\ninterface ConfigTextProps extends ConfigGenericProps {\n schema: ConfigItemText;\n}\n\ninterface ConfigTextState extends ConfigGenericState {\n oldValue?: string;\n jsonError?: boolean;\n}\n\nclass ConfigText extends ConfigGeneric<ConfigTextProps, ConfigTextState> {\n private updateTimeout: ReturnType<typeof setTimeout> | null = null;\n\n componentDidMount(): void {\n super.componentDidMount();\n let value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (Array.isArray(value) && this.props.multiEdit) {\n value = ConfigGeneric.DIFFERENT_VALUE;\n this.setState({ value, oldValue: value, jsonError: false });\n return;\n }\n\n this.setState({ value, oldValue: value, jsonError: this.validateJson(value) });\n }\n\n validateJson(value: string | null | undefined): boolean {\n let jsonError = false;\n if (this.props.schema.validateJson) {\n if (value || !this.props.schema.allowEmpty) {\n try {\n JSON.parse(value);\n } catch (err: unknown) {\n console.log('Error in JSON', err);\n jsonError = true;\n }\n }\n }\n\n return jsonError;\n }\n\n static getDerivedStateFromProps(props: ConfigTextProps, state: ConfigTextState): Partial<ConfigTextState> | null {\n if (props.multiEdit && state.value === ConfigGeneric.DIFFERENT_VALUE) {\n return { value: ConfigGeneric.DIFFERENT_VALUE };\n }\n\n let value = ConfigGeneric.getValue(props.data, props.attr);\n\n if (value !== null && value !== undefined) {\n value = value.toString();\n }\n\n if (value === null || value === undefined || (value !== state.value && value !== state.oldValue)) {\n return { value };\n }\n return null;\n }\n\n renderItem(error?: boolean, disabled?: boolean): JSX.Element {\n const isIndeterminate = Array.isArray(this.state.value) || this.state.value === ConfigGeneric.DIFFERENT_VALUE;\n\n if (this.props.schema.time) {\n // show read-only time\n\n let time = '';\n if (typeof this.state.value === 'number') {\n // If the value is a number, it is a timestamp.\n if (this.state.value && this.state.value < 946659600000) {\n // If the value is less than 2000-01-01, it is a timestamp in seconds.\n time = new Date(this.state.value * 1000).toLocaleString();\n } else {\n time = new Date(this.state.value).toLocaleString();\n }\n } else if (typeof this.state.value === 'string') {\n // If the value is a string, it is a date string.\n time = new Date(this.state.value).toLocaleString();\n }\n\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n value={time}\n error={!!error || !!this.state.jsonError}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n readOnly: true,\n },\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\n if (this.state.oldValue !== null && this.state.oldValue !== undefined) {\n if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n }\n this.updateTimeout = setTimeout(() => {\n this.updateTimeout = null;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = null;\n }\n\n if (isIndeterminate) {\n const autoCompleteOptions = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const arr =\n autoCompleteOptions\n ?.filter((a: any) => a || a === 0)\n .map((item: any) => ({ label: item.toString() || '', value: item })) || [];\n\n arr.unshift({ label: I18n.t(ConfigGeneric.DIFFERENT_LABEL), value: ConfigGeneric.DIFFERENT_VALUE });\n\n return (\n <Autocomplete\n style={styles.indeterminate}\n fullWidth\n value={arr[0]}\n // getOptionSelected={(option, value) => option.label === value.label}\n onChange={(_, value) => {\n const val = value ? value.value : '';\n const mayBePromise = this.onChange(this.props.attr, val, () => {\n this.setState({ value: val, oldValue: val, jsonError: this.validateJson(value) });\n });\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(`Cannot set value: ${e}`));\n }\n }}\n options={arr}\n getOptionLabel={option => option.label}\n renderInput={params => (\n <TextField\n variant=\"standard\"\n {...params}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\n slotProps={{\n htmlInput: {\n ...params.inputProps,\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.props.schema.readOnly || false,\n },\n }}\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 if (this.props.schema.minRows > 1) {\n const helper = this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n );\n return (\n <div style={{ width: '100%' }}>\n {this.props.schema.label ? (\n <div style={styles.label}>{this.getText(this.props.schema.label)}</div>\n ) : null}\n <TextareaAutosize\n // variant=\"standard\"\n style={{\n width: '100%',\n resize: 'vertical',\n backgroundColor: this.props.themeType === 'dark' ? '#363636' : '#cccccc',\n color: this.props.themeType === 'dark' ? '#fff' : '#111',\n }}\n minRows={this.props.schema.minRows}\n maxRows={this.props.schema.maxRows}\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n disabled={!!disabled}\n readOnly={this.props.schema.readOnly || false}\n onChange={e => {\n const value = e.target.value;\n this.setState(\n { value, oldValue: this.state.value, jsonError: this.validateJson(value) },\n () => this.onChange(this.props.attr, value || ''),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n />\n {helper || error || this.state.jsonError ? (\n <div style={error ? styles.error : styles.helper}>\n {error || (this.state.jsonError ? I18n.t('ra_Invalid JSON') : helper)}\n </div>\n ) : null}\n </div>\n );\n }\n let actionButton: React.JSX.Element | undefined;\n if ((this.props.schema.readOnly || disabled) && this.props.schema.copyToClipboard) {\n actionButton = (\n <IconButton\n size=\"small\"\n onClick={() => {\n Utils.copyToClipboard(this.state.value);\n window.alert(I18n.t('ra_Copied'));\n }}\n >\n <IconCopy />\n </IconButton>\n );\n } else if (!this.props.schema.readOnly && !disabled && this.state.value && !this.props.schema.noClearButton) {\n actionButton = (\n <InputAdornment position=\"end\">\n <IconButton\n size=\"small\"\n onClick={() =>\n this.setState({ value: '', oldValue: this.state.value }, () =>\n this.onChange(this.props.attr, ''),\n )\n }\n >\n <CloseIcon />\n </IconButton>\n </InputAdornment>\n );\n }\n\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 || !!this.state.jsonError}\n disabled={!!disabled}\n slotProps={{\n htmlInput: {\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment: actionButton,\n },\n }}\n onChange={e => {\n const value = e.target.value;\n\n this.setState({ value, oldValue: this.state.value, jsonError: this.validateJson(value) }, () =>\n this.onChange(this.props.attr, value),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n this.state.jsonError\n ? I18n.t('ra_Invalid JSON')\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n );\n }\n}\n\nexport default ConfigText;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TextField, IconButton } from '@mui/material';
|
|
3
|
-
import { Icon, IconCopy, Utils } from '@iobroker/adapter-react-v5';
|
|
3
|
+
import { I18n, Icon, IconCopy, Utils } from '@iobroker/adapter-react-v5';
|
|
4
4
|
import getIconByName from './Icons';
|
|
5
5
|
import ConfigGeneric from './ConfigGeneric';
|
|
6
6
|
const styles = {
|
|
@@ -79,7 +79,7 @@ class ConfigTextSendTo extends ConfigGeneric {
|
|
|
79
79
|
input: {
|
|
80
80
|
endAdornment: this.props.schema.copyToClipboard ? (React.createElement(IconButton, { size: "small", onClick: () => {
|
|
81
81
|
Utils.copyToClipboard(this.state.text);
|
|
82
|
-
window.alert('
|
|
82
|
+
window.alert(I18n.t('ra_Copied'));
|
|
83
83
|
} },
|
|
84
84
|
React.createElement(IconCopy, null))) : undefined,
|
|
85
85
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigTextSendTo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigTextSendTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfigTextSendTo.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigTextSendTo.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,aAAa,MAAM,SAAS,CAAC;AACpC,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,SAAS,EAAE;QACP,KAAK,EAAE,MAAM;KAChB;CACJ,CAAC;AAoBF,MAAM,gBAAiB,SAAQ,aAA2D;IAC9E,WAAW,GAAG,KAAK,CAAC;IAEpB,QAAQ,CAAqB;IAErC,WAAW;QACP,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;YAClB,IAAI,IAAI,GAAoC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;YACnE,IA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AK,CAAC,MAAM,CAAC,QAAQ,EAC1B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAClC,GACH,CACL,CAAC;SACL;QACD,OAAO,CACH,6BAAK,KAAK,EAAE,EAAE,GAAG,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,SAAS,CAAC,EAAE;YAClE,IAAI;YACJ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,CACtC,8BAAM,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,GAAI,CACvE,CAAC,CAAC,CAAC,CACA,IAAI,CAAC,KAAK,CAAC,IAAI,CAClB,CACC,CACT,CAAC;IACN,CAAC;CACJ;AAED,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { TextField, IconButton } from '@mui/material';\n\nimport { I18n, Icon, IconCopy, Utils } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemSendTo } from '#JC/types';\nimport getIconByName from './Icons';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n fullWidth: {\n width: '100%',\n },\n};\n\ninterface ConfigTextSendToProps extends ConfigGenericProps {\n schema: ConfigItemSendTo;\n}\n\ninterface ConfigTextSendToState extends ConfigGenericState {\n text?: string;\n style?: React.CSSProperties;\n icon?: string;\n iconStyle?: React.CSSProperties;\n}\n\ninterface Response {\n text: string;\n style?: React.CSSProperties;\n icon?: string;\n iconStyle?: React.CSSProperties;\n}\n\nclass ConfigTextSendTo extends ConfigGeneric<ConfigTextSendToProps, ConfigTextSendToState> {\n private initialized = false;\n\n private _context: string | undefined;\n\n askInstance(): void {\n if (this.props.alive) {\n let data: Record<string, any> | undefined = 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 data = JSON.parse(dataStr);\n } catch {\n console.error(`Cannot parse json data: ${dataStr}`);\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(result => {\n if (typeof result === 'object') {\n const _data: Response = result;\n this.setState({\n text: _data.text || '',\n style: _data.style,\n icon: _data.icon,\n iconStyle: _data.iconStyle,\n });\n } else if (typeof result === 'string') {\n this.setState({ text: result || '' });\n }\n })\n .catch(e => console.error(`Cannot send command: ${e}`));\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, disabled, defaultValue */): JSX.Element {\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 if (this.state.text === undefined) {\n return null;\n }\n\n let icon: JSX.Element | null = null;\n if (this.state.icon) {\n icon = getIconByName(this.state.icon, {\n marginRight: this.state.text ? 8 : undefined,\n ...(this.state.iconStyle || undefined),\n });\n if (!icon) {\n icon = (\n <Icon\n src={this.state.icon}\n style={{ marginRight: this.state.text ? 8 : undefined, ...(this.state.iconStyle || undefined) }}\n />\n );\n }\n }\n\n if (this.props.schema.container === 'text') {\n return (\n <TextField\n variant=\"standard\"\n fullWidth\n slotProps={{\n input: {\n endAdornment: this.props.schema.copyToClipboard ? (\n <IconButton\n size=\"small\"\n onClick={() => {\n Utils.copyToClipboard(this.state.text);\n window.alert(I18n.t('ra_Copied'));\n }}\n >\n <IconCopy />\n </IconButton>\n ) : undefined,\n },\n }}\n value={this.state.text}\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 <div style={{ ...styles.fullWidth, ...(this.state.style || undefined) }}>\n {icon}\n {this.props.schema.container === 'html' ? (\n <span dangerouslySetInnerHTML={{ __html: this.state.text || '' }} />\n ) : (\n this.state.text\n )}\n </div>\n );\n }\n}\n\nexport default ConfigTextSendTo;\n"]}
|
package/build/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type ConfigItemType =
|
|
|
32
32
|
| 'pattern'
|
|
33
33
|
| 'sendto'
|
|
34
34
|
| 'setState'
|
|
35
|
+
| 'staticInfo'
|
|
35
36
|
| 'staticText'
|
|
36
37
|
| 'staticLink'
|
|
37
38
|
| 'staticImage'
|
|
@@ -263,6 +264,8 @@ export interface ConfigItemText extends ConfigItem {
|
|
|
263
264
|
max?: number;
|
|
264
265
|
/** read-only field */
|
|
265
266
|
readOnly?: boolean;
|
|
267
|
+
/** show copy to clipboard button, but only if disabled or read-only */
|
|
268
|
+
copyToClipboard?: boolean;
|
|
266
269
|
/** default is true. Set this attribute to `false` if trim is not desired. */
|
|
267
270
|
trim?: boolean;
|
|
268
271
|
/** default is 1. Set this attribute to `2` or more if you want to have a textarea with more than one row. */
|
|
@@ -418,7 +421,7 @@ export interface ConfigItemStaticImage extends ConfigItem {
|
|
|
418
421
|
export interface ConfigItemStaticText extends Omit<ConfigItem, 'button'> {
|
|
419
422
|
type: 'staticText';
|
|
420
423
|
/** multi-language text */
|
|
421
|
-
text:
|
|
424
|
+
text: ioBroker.StringOrTranslated;
|
|
422
425
|
/** @deprecated use text */
|
|
423
426
|
label?: ioBroker.StringOrTranslated;
|
|
424
427
|
/** link. Link could be dynamic like `#tab-objects/customs/${data.parentId} */
|
|
@@ -436,7 +439,41 @@ export interface ConfigItemStaticText extends Omit<ConfigItem, 'button'> {
|
|
|
436
439
|
/** if icon should be shown: `auth`, `send`, `web`, `warning`, `error`, `info`, `search`, `book`, `help`, `upload`. You can use `base64` icons (it starts with `data:image/svg+xml;base64,...`) or `jpg/png` images (ends with `.png`) . (Request via issue if you need more icons) */
|
|
437
440
|
icon?: ConfigIconType;
|
|
438
441
|
/** styles for the button */
|
|
439
|
-
controlStyle
|
|
442
|
+
controlStyle?: CustomCSSProperties;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export interface ConfigItemStaticInfo extends Omit<ConfigItem, 'data'> {
|
|
446
|
+
type: 'staticInfo';
|
|
447
|
+
/** multi-language text or value */
|
|
448
|
+
data: ioBroker.StringOrTranslated | number | boolean;
|
|
449
|
+
/** Base64 icon */
|
|
450
|
+
labelIcon?: string;
|
|
451
|
+
/** Unit */
|
|
452
|
+
unit?: ioBroker.StringOrTranslated;
|
|
453
|
+
/** 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*/
|
|
454
|
+
narrow?: boolean;
|
|
455
|
+
/** Add to label the colon at the end if not exist in label */
|
|
456
|
+
addColon?: boolean;
|
|
457
|
+
/** Value should blink when updated (true or color) */
|
|
458
|
+
blinkOnUpdate?: boolean | string;
|
|
459
|
+
/** Value should blink continuously (true or color) */
|
|
460
|
+
blink?: boolean | string;
|
|
461
|
+
/** Show copy to clipboard button for value */
|
|
462
|
+
copyToClipboard?: boolean;
|
|
463
|
+
/** Label style */
|
|
464
|
+
styleLabel?: CustomCSSProperties;
|
|
465
|
+
/** Value style */
|
|
466
|
+
styleValue?: CustomCSSProperties;
|
|
467
|
+
/** Unit style */
|
|
468
|
+
styleUnit?: CustomCSSProperties;
|
|
469
|
+
/** Font size */
|
|
470
|
+
size?: number | 'small' | 'normal' | 'large';
|
|
471
|
+
/** Highlight line on mouse over */
|
|
472
|
+
highlight?: boolean;
|
|
473
|
+
/** Show boolean values as checkbox */
|
|
474
|
+
booleanAsCheckbox?: boolean;
|
|
475
|
+
/** Show string values as HTML */
|
|
476
|
+
html?: boolean;
|
|
440
477
|
}
|
|
441
478
|
|
|
442
479
|
export interface ConfigItemRoom extends ConfigItem {
|
|
@@ -621,9 +658,11 @@ export interface ConfigItemSendTo extends Omit<ConfigItem, 'data'> {
|
|
|
621
658
|
|
|
622
659
|
export interface ConfigItemState extends ConfigItem {
|
|
623
660
|
type: 'state';
|
|
624
|
-
/** Describes, which object ID should be taken for the controlling. The ID is without
|
|
661
|
+
/** Describes, which object ID should be taken for the controlling. The ID is without `ADAPTER.I.` prefix */
|
|
625
662
|
oid: string;
|
|
626
|
-
/**
|
|
663
|
+
/** The `oid` is absolute and no need to add `ADAPTER.I` or `system.adapter.ADAPTER.I.` to oid */
|
|
664
|
+
foreign?: boolean;
|
|
665
|
+
/** If true, the state will be taken from `system.adapter.ADAPTER.I` and not from `ADAPTER.I` */
|
|
627
666
|
system?: boolean;
|
|
628
667
|
/** How the value of the state should be shown */
|
|
629
668
|
control?: 'text' | 'html' | 'input' | 'slider' | 'select' | 'button' | 'switch' | 'number';
|
|
@@ -655,6 +694,16 @@ export interface ConfigItemState extends ConfigItem {
|
|
|
655
694
|
variant?: 'contained' | 'outlined' | 'text';
|
|
656
695
|
/** Defines if the control is read-only. Applied only to 'input', 'slider', 'select', 'button', 'switch', 'number' */
|
|
657
696
|
readOnly?: boolean;
|
|
697
|
+
/** Base64 icon */
|
|
698
|
+
labelIcon?: string;
|
|
699
|
+
/** 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*/
|
|
700
|
+
narrow?: boolean;
|
|
701
|
+
/** Add to label the colon at the end if not exist in label */
|
|
702
|
+
addColon?: boolean;
|
|
703
|
+
/** Value should blink when updated (true or color) */
|
|
704
|
+
blinkOnUpdate?: boolean | string;
|
|
705
|
+
/** Font size */
|
|
706
|
+
size?: number | 'small' | 'normal' | 'large';
|
|
658
707
|
}
|
|
659
708
|
|
|
660
709
|
export interface ConfigItemTextSendTo extends Omit<ConfigItem, 'data'> {
|
|
@@ -938,6 +987,7 @@ export type ConfigItemAny =
|
|
|
938
987
|
| ConfigItemSetState
|
|
939
988
|
| ConfigItemStaticDivider
|
|
940
989
|
| ConfigItemStaticHeader
|
|
990
|
+
| ConfigItemStaticInfo
|
|
941
991
|
| ConfigItemStaticImage
|
|
942
992
|
| ConfigItemStaticText
|
|
943
993
|
| ConfigItemTopic
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/json-config",
|
|
3
3
|
"description": "This package contains the ioBroker JSON config UI components",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.4.1",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -10,13 +10,15 @@
|
|
|
10
10
|
"prepublishOnly": "npm run build",
|
|
11
11
|
"build:ts": "tsc -p tsconfig.json",
|
|
12
12
|
"lint": "eslint -c eslint.config.mjs src",
|
|
13
|
-
"prettier": "prettier --write src/**/*.{ts,tsx,js,jsx,json,css,scss,md,html}"
|
|
13
|
+
"prettier": "prettier --write src/**/*.{ts,tsx,js,jsx,json,css,scss,md,html}",
|
|
14
|
+
"test": "tsc -p test/tsconfig.build.json && node test/testSchema.js",
|
|
15
|
+
"tsc-test": "tsc -p test/tsconfig.build.json"
|
|
14
16
|
},
|
|
15
17
|
"publishConfig": {
|
|
16
18
|
"access": "public"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@iobroker/adapter-react-v5": "7.
|
|
21
|
+
"@iobroker/adapter-react-v5": "7.4.1",
|
|
20
22
|
"@mui/x-date-pickers": "^7.22.0",
|
|
21
23
|
"crypto-js": "^4.2.0",
|
|
22
24
|
"react-ace": "^12.0.0",
|
|
@@ -25,11 +27,12 @@
|
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@craco/craco": "^7.1.0",
|
|
27
29
|
"@types/crypto-js": "^4.2.2",
|
|
30
|
+
"ajv": "^8.17.1",
|
|
28
31
|
"tsc-alias": "^1.8.10"
|
|
29
32
|
},
|
|
30
33
|
"files": [
|
|
31
34
|
"build/",
|
|
32
35
|
"LICENSE"
|
|
33
36
|
],
|
|
34
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "aa4b7b2369c0d377fa176c014d295ea191af864c"
|
|
35
38
|
}
|