@iobroker/json-config 7.6.16 → 7.6.18

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
@@ -158,6 +158,7 @@ You can install it via GitHub icon in admin by entering `iobroker.jsonconfig-dem
158
158
  - [**`language`:**](#language) Selects the user interface language
159
159
  - [**`license`:**](#license) shows the license information if not already accepted.
160
160
  - [**`number`:**](#number) Numeric input field with min/max values and step size
161
+ - [**`oauth2`:**](#oauth2) Make OAuth2 authentication for the adapter (Admin 7.6.18 or newer)
161
162
  - [**`objectId`:**](#objectid) Selects an object ID with name, color, and icon
162
163
  - [**`panel`:**](#panel) Tab with items
163
164
  - [**`password`:**](#password) Password input field
@@ -513,6 +514,33 @@ saves image as a file of the `adapter.X` object or as base64 in attribute
513
514
  }
514
515
  ```
515
516
 
517
+ ### `oauth2`
518
+ (admin >= 6.17.18)
519
+
520
+ Shows OAuth2 Authentication button to get the refresh and access tokens for the adapter.
521
+
522
+ To use this, you must first provide the OAuth2 data (client ID, secret, etc.) to ioBroker maintenance team, so they can add it to the cloud.
523
+
524
+ | Property | Description |
525
+ |----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
526
+ | `identifier` | Oauth2 identifier, like `spotify`, `google`, `dropbox`, `microsoft` |
527
+ | `saveTokenIn` | Optional state name where the token will be saved. Default is `oauth2Tokens`. The path is relative to the adapter instance, like `adapterName.X.oauth2Tokens` |
528
+ | `scope` | Optional scopes divided by space, e.g. `user-read-private user-read-email` |
529
+ | `refreshLabel` | Optional button label for refreshing the token |
530
+
531
+ #### Example for `oauth2`
532
+
533
+ ```json
534
+ "_oauth2": {
535
+ "type": "oauth2",
536
+ "identifier": "spotify",
537
+ "label": "Get Spotify OAuth2 Token",
538
+ "label": "Refresh Spotify OAuth2 Token",
539
+ "icon": "data:image/svg+xml;base64,...",
540
+ }
541
+ ```
542
+ See also [OAUTH2.md](OAUTH2.md) for more information.
543
+
516
544
  ### `objectId`
517
545
 
518
546
  object ID: show it with name, color and icon
@@ -49,7 +49,7 @@ class ConfigNumber extends ConfigGeneric {
49
49
  if (value === null || value === undefined) {
50
50
  return null;
51
51
  }
52
- value = value.toString().trim();
52
+ value = value.toString().trim().replace(',', '.');
53
53
  const f = value === '' ? 0 : parseFloat(value);
54
54
  if (value !== '' && Number.isNaN(f)) {
55
55
  return 'ra_Not a number';
@@ -117,7 +117,16 @@ class ConfigNumber extends ConfigGeneric {
117
117
  }
118
118
  }
119
119
  return (React.createElement(FormControl, { variant: "standard", style: styles.control },
120
- React.createElement(TextField, { variant: "standard", type: "number", fullWidth: true, slotProps: {
120
+ React.createElement(TextField, { sx: {
121
+ '& .up-down': {
122
+ display: 'none',
123
+ },
124
+ '&:hover .up-down': {
125
+ display: 'block',
126
+ },
127
+ }, variant: "standard",
128
+ // because some users want to enter "-" first
129
+ type: this.props.schema.min !== undefined && this.props.schema.min >= 0 ? 'number' : 'text', fullWidth: true, slotProps: {
121
130
  htmlInput: {
122
131
  min: this.props.schema.min,
123
132
  max: this.props.schema.max,
@@ -127,7 +136,7 @@ class ConfigNumber extends ConfigGeneric {
127
136
  input: {
128
137
  endAdornment: this.props.schema.unit
129
138
  ? this.getText(this.props.schema.unit, this.props.schema.noTranslation)
130
- : undefined,
139
+ : null,
131
140
  },
132
141
  }, value: this.state._value === null || this.state._value === undefined ? '' : this.state._value, error: !!error, disabled: !!disabled, onChange: e => {
133
142
  const _value = e.target.value; // value is always a string and it is validly formatted
@@ -138,7 +147,7 @@ class ConfigNumber extends ConfigGeneric {
138
147
  else {
139
148
  this.onError(this.props.attr); // clear error
140
149
  }
141
- this.setState({ _value, oldValue: this.state._value }, () => this.onChange(this.props.attr, parseFloat(_value)));
150
+ this.setState({ _value, oldValue: this.state._value }, () => this.onChange(this.props.attr, parseFloat(_value.replace(',', '.'))));
142
151
  }, placeholder: this.getText(this.props.schema.placeholder), label: this.getText(this.props.schema.label), helperText: error && typeof error === 'string'
143
152
  ? error
144
153
  : this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation) })));
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigNumber.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,aAAa,EAAE;QACX,OAAO,EAAE,GAAG;KACf;IACD,OAAO,EAAE;QACL,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,MAAM;KAChB;CACJ,CAAC;AAWF,MAAM,YAAa,SAAQ,aAAmD;IAClE,aAAa,CAAiC;IAEtD,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEtE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACzD,MAAM,GAAG,aAAa,CAAC,eAAe,CAAC;YACvC,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5C,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAA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C,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,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAC9B,CAAC,CAAC,KAAK;oBACP,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,CACQ,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,YAAY,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, FormControl } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemNumber } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n indeterminate: {\n opacity: 0.5,\n },\n control: {\n flexDirection: 'row',\n width: '100%',\n },\n};\n\ninterface ConfigNumberProps extends ConfigGenericProps {\n schema: ConfigItemNumber;\n}\n\ninterface ConfigNumberState extends ConfigGenericState {\n _value: string;\n oldValue: string | null;\n}\n\nclass ConfigNumber extends ConfigGeneric<ConfigNumberProps, ConfigNumberState> {\n private updateTimeout?: ReturnType<typeof setTimeout>;\n\n componentDidMount(): void {\n super.componentDidMount();\n let _value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (_value === null || _value === undefined) {\n _value = '';\n }\n\n if (Array.isArray(_value) && this.props.oContext.multiEdit) {\n _value = ConfigGeneric.DIFFERENT_VALUE;\n this.setState({ _value, oldValue: _value });\n return;\n }\n\n this.setState({ _value: _value.toString(), oldValue: _value.toString() });\n }\n\n static getDerivedStateFromProps(\n props: ConfigNumberProps,\n state: ConfigNumberState,\n ): Partial<ConfigNumberState> | null {\n if (\n (props.schema.min !== undefined && props.schema.min < 0) ||\n (props.schema.max !== undefined && props.schema.max < 0)\n ) {\n return null;\n }\n const _value = ConfigGeneric.getValue(props.data, props.attr);\n\n if (props.oContext.multiEdit && state._value === ConfigGeneric.DIFFERENT_VALUE) {\n return { _value: ConfigGeneric.DIFFERENT_VALUE };\n }\n\n if (\n _value === null ||\n _value === undefined ||\n state.oldValue === null ||\n state.oldValue === undefined ||\n (_value.toString() !== parseFloat(state._value).toString() &&\n _value.toString() !== state.oldValue.toString())\n ) {\n return { _value };\n }\n\n return null;\n }\n\n checkValue(value: string): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n value = value.toString().trim();\n const f = value === '' ? 0 : parseFloat(value);\n\n if (value !== '' && Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n if (value !== '' && window.isFinite(f)) {\n if (this.props.schema.min !== undefined && f < this.props.schema.min) {\n return 'ra_Too small';\n }\n if (this.props.schema.max !== undefined && f > this.props.schema.max) {\n return 'ra_Too big';\n }\n if (value === '' || value === '-' || Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n return null;\n }\n\n return 'ra_Not a number';\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n const isIndeterminate = Array.isArray(this.state._value) || this.state._value === ConfigGeneric.DIFFERENT_VALUE;\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 = undefined;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = undefined;\n }\n\n if (isIndeterminate) {\n const autoCompleteOptions = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const arr =\n autoCompleteOptions\n ?.filter((a: number | null | undefined) => a || a === 0)\n .map((item: number) => ({ 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 freeSolo\n value={arr[0]}\n // @ts-expect-error needs investigation if this really has no effect\n getOptionSelected={(option, value) => option.label === value.label}\n onChange={(_, value: (typeof arr)[number]) => {\n const mayBePromise = this.onChange(this.props.attr, value?.value, () => {\n this.setState({ _value: value?.value, oldValue: this.state._value });\n });\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n }}\n options={arr}\n getOptionLabel={(option: (typeof arr)[number]) => option.label}\n renderInput={params => (\n <TextField\n {...params}\n label={this.getText(this.props.schema.label)}\n variant=\"standard\"\n slotProps={{\n htmlInput: {\n ...params.inputProps,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment: this.props.schema.unit\n ? this.getText(this.props.schema.unit, this.props.schema.noTranslation)\n : undefined,\n },\n }}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\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 (!error && this.state._value !== null && this.state._value !== undefined && this.state._value) {\n error = this.checkValue(this.state._value);\n if (error) {\n error = I18n.t(error as string);\n }\n }\n\n return (\n <FormControl\n variant=\"standard\"\n style={styles.control}\n >\n <TextField\n variant=\"standard\"\n type=\"number\"\n fullWidth\n slotProps={{\n htmlInput: {\n min: this.props.schema.min,\n max: this.props.schema.max,\n step: this.props.schema.step,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment: this.props.schema.unit\n ? this.getText(this.props.schema.unit, this.props.schema.noTranslation)\n : undefined,\n },\n }}\n value={this.state._value === null || this.state._value === undefined ? '' : this.state._value}\n error={!!error}\n disabled={!!disabled}\n onChange={e => {\n const _value = e.target.value; // value is always a string and it is validly formatted\n const _error = this.checkValue(_value);\n if (_error) {\n this.onError(this.props.attr, I18n.t(_error));\n } else {\n this.onError(this.props.attr); // clear error\n }\n\n this.setState({ _value, oldValue: this.state._value }, () =>\n this.onChange(this.props.attr, parseFloat(_value)),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n error && typeof error === 'string'\n ? error\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n </FormControl>\n );\n }\n}\n\nexport default ConfigNumber;\n"]}
1
+ {"version":3,"file":"ConfigNumber.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigNumber.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAGlD,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAElG,MAAM,MAAM,GAAwC;IAChD,aAAa,EAAE;QACX,OAAO,EAAE,GAAG;KACf;IACD,OAAO,EAAE;QACL,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,MAAM;KAChB;CACJ,CAAC;AAWF,MAAM,YAAa,SAAQ,aAAmD;IAClE,aAAa,CAAiC;IAEtD,iBAAiB;QACb,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC1B,IAAI,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEtE,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1C,MAAM,GAAG,EAAE,CAAC;QAChB,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC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C,uDAAuD;oBACtF,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;oBACvC,IAAI,MAAM,EAAE,CAAC;wBACT,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;oBAClD,CAAC;yBAAM,CAAC;wBACJ,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc;oBACjD,CAAC;oBAED,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,CACxD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CACvE,CAAC;gBACN,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,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAC9B,CAAC,CAAC,KAAK;oBACP,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,CACQ,CACjB,CAAC;IACN,CAAC;CACJ;AAED,eAAe,YAAY,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Autocomplete, TextField, FormControl } from '@mui/material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport type { ConfigItemNumber } from '../types';\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\n\nconst styles: Record<string, React.CSSProperties> = {\n indeterminate: {\n opacity: 0.5,\n },\n control: {\n flexDirection: 'row',\n width: '100%',\n },\n};\n\ninterface ConfigNumberProps extends ConfigGenericProps {\n schema: ConfigItemNumber;\n}\n\ninterface ConfigNumberState extends ConfigGenericState {\n _value: string;\n oldValue: string | null;\n}\n\nclass ConfigNumber extends ConfigGeneric<ConfigNumberProps, ConfigNumberState> {\n private updateTimeout?: ReturnType<typeof setTimeout>;\n\n componentDidMount(): void {\n super.componentDidMount();\n let _value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n\n if (_value === null || _value === undefined) {\n _value = '';\n }\n\n if (Array.isArray(_value) && this.props.oContext.multiEdit) {\n _value = ConfigGeneric.DIFFERENT_VALUE;\n this.setState({ _value, oldValue: _value });\n return;\n }\n\n this.setState({ _value: _value.toString(), oldValue: _value.toString() });\n }\n\n static getDerivedStateFromProps(\n props: ConfigNumberProps,\n state: ConfigNumberState,\n ): Partial<ConfigNumberState> | null {\n if (\n (props.schema.min !== undefined && props.schema.min < 0) ||\n (props.schema.max !== undefined && props.schema.max < 0)\n ) {\n return null;\n }\n const _value = ConfigGeneric.getValue(props.data, props.attr);\n\n if (props.oContext.multiEdit && state._value === ConfigGeneric.DIFFERENT_VALUE) {\n return { _value: ConfigGeneric.DIFFERENT_VALUE };\n }\n\n if (\n _value === null ||\n _value === undefined ||\n state.oldValue === null ||\n state.oldValue === undefined ||\n (_value.toString() !== parseFloat(state._value).toString() &&\n _value.toString() !== state.oldValue.toString())\n ) {\n return { _value };\n }\n\n return null;\n }\n\n checkValue(value: string): string | null {\n if (value === null || value === undefined) {\n return null;\n }\n value = value.toString().trim().replace(',', '.');\n const f = value === '' ? 0 : parseFloat(value);\n\n if (value !== '' && Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n if (value !== '' && window.isFinite(f)) {\n if (this.props.schema.min !== undefined && f < this.props.schema.min) {\n return 'ra_Too small';\n }\n if (this.props.schema.max !== undefined && f > this.props.schema.max) {\n return 'ra_Too big';\n }\n if (value === '' || value === '-' || Number.isNaN(f)) {\n return 'ra_Not a number';\n }\n\n return null;\n }\n\n return 'ra_Not a number';\n }\n\n renderItem(error: unknown, disabled: boolean): JSX.Element | null {\n const isIndeterminate = Array.isArray(this.state._value) || this.state._value === ConfigGeneric.DIFFERENT_VALUE;\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 = undefined;\n this.setState({ oldValue: null });\n }, 30);\n } else if (this.updateTimeout) {\n clearTimeout(this.updateTimeout);\n this.updateTimeout = undefined;\n }\n\n if (isIndeterminate) {\n const autoCompleteOptions = ConfigGeneric.getValue(this.props.data, this.props.attr);\n const arr =\n autoCompleteOptions\n ?.filter((a: number | null | undefined) => a || a === 0)\n .map((item: number) => ({ 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 freeSolo\n value={arr[0]}\n // @ts-expect-error needs investigation if this really has no effect\n getOptionSelected={(option, value) => option.label === value.label}\n onChange={(_, value: (typeof arr)[number]) => {\n const mayBePromise = this.onChange(this.props.attr, value?.value, () => {\n this.setState({ _value: value?.value, oldValue: this.state._value });\n });\n if (mayBePromise instanceof Promise) {\n mayBePromise.catch(e => console.error(e));\n }\n }}\n options={arr}\n getOptionLabel={(option: (typeof arr)[number]) => option.label}\n renderInput={params => (\n <TextField\n {...params}\n label={this.getText(this.props.schema.label)}\n variant=\"standard\"\n slotProps={{\n htmlInput: {\n ...params.inputProps,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment: this.props.schema.unit\n ? this.getText(this.props.schema.unit, this.props.schema.noTranslation)\n : undefined,\n },\n }}\n error={!!error}\n placeholder={this.getText(this.props.schema.placeholder)}\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 (!error && this.state._value !== null && this.state._value !== undefined && this.state._value) {\n error = this.checkValue(this.state._value);\n if (error) {\n error = I18n.t(error as string);\n }\n }\n\n return (\n <FormControl\n variant=\"standard\"\n style={styles.control}\n >\n <TextField\n sx={{\n '& .up-down': {\n display: 'none',\n },\n '&:hover .up-down': {\n display: 'block',\n },\n }}\n variant=\"standard\"\n // because some users want to enter \"-\" first\n type={this.props.schema.min !== undefined && this.props.schema.min >= 0 ? 'number' : 'text'}\n fullWidth\n slotProps={{\n htmlInput: {\n min: this.props.schema.min,\n max: this.props.schema.max,\n step: this.props.schema.step,\n readOnly: this.props.schema.readOnly || false,\n },\n input: {\n endAdornment: this.props.schema.unit\n ? this.getText(this.props.schema.unit, this.props.schema.noTranslation)\n : null,\n },\n }}\n value={this.state._value === null || this.state._value === undefined ? '' : this.state._value}\n error={!!error}\n disabled={!!disabled}\n onChange={e => {\n const _value = e.target.value; // value is always a string and it is validly formatted\n const _error = this.checkValue(_value);\n if (_error) {\n this.onError(this.props.attr, I18n.t(_error));\n } else {\n this.onError(this.props.attr); // clear error\n }\n\n this.setState({ _value, oldValue: this.state._value }, () =>\n this.onChange(this.props.attr, parseFloat(_value.replace(',', '.'))),\n );\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={\n error && typeof error === 'string'\n ? error\n : this.renderHelp(\n this.props.schema.help,\n this.props.schema.helpLink,\n this.props.schema.noTranslation,\n )\n }\n />\n </FormControl>\n );\n }\n}\n\nexport default ConfigNumber;\n"]}
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';
3
+ import type { ConfigItemOAuth2 } from '../types';
4
+ declare global {
5
+ interface Window {
6
+ attachEvent: Window['addEventListener'];
7
+ detachEvent: Window['removeEventListener'];
8
+ }
9
+ }
10
+ interface ConfigOAuth2Props extends ConfigGenericProps {
11
+ schema: ConfigItemOAuth2;
12
+ }
13
+ export interface AccessTokens {
14
+ access_token: string;
15
+ expires_in: number;
16
+ access_token_expires_on: string;
17
+ ext_expires_in: number;
18
+ token_type: 'Bearer';
19
+ scope: string;
20
+ refresh_token: string;
21
+ }
22
+ interface ConfigOAuth2State extends ConfigGenericState {
23
+ accessTokens: string;
24
+ success: boolean;
25
+ blocked: boolean;
26
+ running: boolean;
27
+ pressed: boolean;
28
+ }
29
+ export default class ConfigOAuth2 extends ConfigGeneric<ConfigOAuth2Props, ConfigOAuth2State> {
30
+ private authWindow?;
31
+ private readonly oid;
32
+ private readonly url;
33
+ constructor(props: ConfigOAuth2Props);
34
+ componentDidMount(): Promise<void>;
35
+ onTokensUpdated: (_id: string, state: ioBroker.State | null | undefined) => void;
36
+ componentWillUnmount(): void;
37
+ saveToken(accessTokens: string): void;
38
+ onMessage: (event: MessageEvent) => void;
39
+ onOpenUrl(): void;
40
+ renderItem(): React.JSX.Element;
41
+ }
42
+ export {};
@@ -0,0 +1,170 @@
1
+ import React from 'react';
2
+ import { Button, TextField } from '@mui/material';
3
+ import { CloudUpload } from '@mui/icons-material';
4
+ import { I18n } from '@iobroker/adapter-react-v5';
5
+ import ConfigGeneric from './ConfigGeneric';
6
+ export default class ConfigOAuth2 extends ConfigGeneric {
7
+ authWindow;
8
+ oid;
9
+ url;
10
+ constructor(props) {
11
+ super(props);
12
+ this.state = {
13
+ ...this.state,
14
+ accessTokens: '',
15
+ success: false,
16
+ blocked: false,
17
+ running: false,
18
+ pressed: false,
19
+ };
20
+ this.url = `https://oauth2.iobroker.in/${props.schema.identifier}?redirect=true`;
21
+ if (props.schema.scope) {
22
+ this.url += `&scope=${encodeURIComponent(props.schema.scope)}`;
23
+ }
24
+ this.oid = `${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn || 'oauth2Tokens'}`;
25
+ }
26
+ async componentDidMount() {
27
+ super.componentDidMount();
28
+ if (window.addEventListener) {
29
+ window.addEventListener('message', this.onMessage, false);
30
+ }
31
+ else {
32
+ window.attachEvent('onmessage', this.onMessage, false);
33
+ }
34
+ await this.props.oContext.socket.subscribeState(this.oid, this.onTokensUpdated);
35
+ // read tokens
36
+ const tokens = await this.props.oContext.socket.getState(this.oid);
37
+ if (tokens) {
38
+ const accessTokens = JSON.parse(tokens.val);
39
+ if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {
40
+ this.setState({ accessTokens: tokens.val });
41
+ }
42
+ }
43
+ }
44
+ onTokensUpdated = (_id, state) => {
45
+ if (state?.val) {
46
+ const accessTokens = JSON.parse(state.val);
47
+ if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {
48
+ if (this.state.accessTokens !== state.val) {
49
+ this.setState({ accessTokens: state.val });
50
+ }
51
+ return;
52
+ }
53
+ }
54
+ this.setState({ accessTokens: '' });
55
+ };
56
+ componentWillUnmount() {
57
+ super.componentWillUnmount();
58
+ if (window.removeEventListener) {
59
+ window.removeEventListener('message', this.onMessage, false);
60
+ }
61
+ else {
62
+ window.detachEvent('onmessage', this.onMessage, false);
63
+ }
64
+ this.props.oContext.socket.unsubscribeState(this.oid, this.onTokensUpdated);
65
+ }
66
+ saveToken(accessTokens) {
67
+ try {
68
+ if (accessTokens && !accessTokens.startsWith('{')) {
69
+ // convert base64 to string
70
+ accessTokens = atob(accessTokens);
71
+ }
72
+ const accessTokensParsed = JSON.parse(accessTokens);
73
+ if (accessTokensParsed.access_token && accessTokensParsed.refresh_token && accessTokensParsed.expires_in) {
74
+ // Give 10 seconds to user to copy the token
75
+ accessTokensParsed.access_token_expires_on ||= new Date(Date.now() + accessTokensParsed.expires_in * 1000).toISOString();
76
+ this.props.oContext.socket
77
+ .setState(this.oid, JSON.stringify(accessTokensParsed), true)
78
+ .catch((e) => console.log(`Error occurred: ${e.toString()}`));
79
+ }
80
+ }
81
+ catch (e) {
82
+ // ignore
83
+ console.warn(e);
84
+ }
85
+ }
86
+ onMessage = (event) => {
87
+ if (event.origin !== 'https://oauth2.iobroker.in') {
88
+ return;
89
+ }
90
+ if ((typeof event.data === 'string' &&
91
+ event.data.startsWith(`${this.props.schema.identifier}-authentication:`)) ||
92
+ (typeof event.message === 'string' &&
93
+ event.message.startsWith(`${this.props.schema.identifier}-authentication:`))) {
94
+ const parts = (event.data || event.message).split(':');
95
+ if (parts[1] === 'success') {
96
+ this.setState({ accessTokens: parts[2], success: true, pressed: false }, () => this.saveToken(this.state.accessTokens));
97
+ // send message to auth window to close it
98
+ this.authWindow?.postMessage('close', event.origin);
99
+ this.authWindow = null;
100
+ }
101
+ else {
102
+ this.props.onError?.(parts[2]);
103
+ }
104
+ }
105
+ };
106
+ onOpenUrl() {
107
+ this.authWindow = window.open(this.url, this.props.schema.identifier);
108
+ if (!this.authWindow || this.authWindow.closed || typeof this.authWindow.closed === 'undefined') {
109
+ this.setState({ blocked: true });
110
+ }
111
+ else {
112
+ this.setState({ pressed: true });
113
+ }
114
+ }
115
+ renderItem() {
116
+ let validTill = '';
117
+ if (this.state.accessTokens) {
118
+ try {
119
+ const accessTokensParsed = JSON.parse(this.state.accessTokens);
120
+ validTill = new Date(accessTokensParsed.access_token_expires_on).toLocaleString();
121
+ }
122
+ catch {
123
+ // ignore
124
+ }
125
+ }
126
+ let label;
127
+ if (this.state.accessTokens) {
128
+ label = this.props.schema.refreshLabel
129
+ ? this.getText(this.props.schema.refreshLabel)
130
+ : I18n.t('ra_Renew %s access', this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1));
131
+ }
132
+ else {
133
+ label = this.props.schema.label
134
+ ? this.getText(this.props.schema.label)
135
+ : I18n.t('ra_Get %s access', this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1));
136
+ }
137
+ const icon = this.getIcon();
138
+ return (React.createElement("div", { style: { width: '100%', margin: '0 0 1rem 0' } },
139
+ React.createElement(Button, { disabled: this.state.running, endIcon: icon || React.createElement(CloudUpload, null), variant: "contained", onClick: () => this.onOpenUrl() }, label),
140
+ this.state.blocked ? (React.createElement("div", { style: { color: 'red', fontSize: 16, marginTop: 20 } }, I18n.t('ra_Please allow popups in your browser for this page!'))) : null,
141
+ this.state.accessTokens ? (React.createElement("div", { style: { color: 'green', fontSize: 16, marginTop: 20 } }, this.props.alive
142
+ ? I18n.t('ra_Successfully authorized. Token valid till %s and will be automatically renewed.', validTill)
143
+ : I18n.t('ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.', validTill))) : null,
144
+ this.state.pressed ? (React.createElement(React.Fragment, null,
145
+ React.createElement("div", { style: { width: '100%', margin: '1rem 0 1rem 0' } },
146
+ React.createElement("span", { style: { marginRight: 4 } },
147
+ `${I18n.t('ra_If the button above does not work, you can authorize manually this app by visiting this url')}`,
148
+ ":"),
149
+ React.createElement("br", null),
150
+ React.createElement("a", { target: this.props.schema.identifier, href: this.url, rel: "noreferrer" }, this.url)),
151
+ React.createElement(TextField, { value: this.state.accessTokens, label: I18n.t('ra_Enter the code from that page here'), variant: "standard", onChange: e => {
152
+ let accessTokens = e.target.value;
153
+ if (accessTokens && !accessTokens.startsWith('{')) {
154
+ // convert base64 to string
155
+ accessTokens = atob(accessTokens);
156
+ }
157
+ try {
158
+ const accessTokensParsed = JSON.parse(accessTokens);
159
+ if (accessTokensParsed.access_token) {
160
+ accessTokensParsed.access_token_expires_on = new Date(Date.now() + (accessTokensParsed.expires_in - 10) * 1000).toISOString();
161
+ this.setState({ accessTokens: JSON.stringify(accessTokensParsed) }, () => this.saveToken(this.state.accessTokens));
162
+ }
163
+ }
164
+ catch {
165
+ // ignore
166
+ }
167
+ }, fullWidth: true }))) : null));
168
+ }
169
+ }
170
+ //# sourceMappingURL=ConfigOAuth2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AAG,CAAC,EAAE,CAAC;4BAChD,2BAA2B;4BAC3B,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC;wBACtC,CAAC;wBACD,IAAI,CAAC;4BACD,MAAM,kBAAkB,GAAiB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;4BAClE,IAAI,kBAAkB,CAAC,YAAY,EAAE,CAAC;gCAClC,kBAAkB,CAAC,uBAAuB,GAAG,IAAI,IAAI,CACjD,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,kBAAkB,CAAC,UAAU,GAAG,EAAE,CAAC,GAAG,IAAI,CAC3D,CAAC,WAAW,EAAE,CAAC;gCAChB,IAAI,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,EAAE,GAAG,EAAE,CACrE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAC1C,CAAC;4BACN,CAAC;wBACL,CAAC;wBAAC,MAAM,CAAC;4BACL,SAAS;wBACb,CAAC;oBACL,CAAC,EACD,SAAS,SACX,CACH,CACN,CAAC,CAAC,CAAC,IAAI,CACN,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import React from 'react';\n\nimport { Button, TextField } from '@mui/material';\nimport { CloudUpload } from '@mui/icons-material';\n\nimport { I18n } from '@iobroker/adapter-react-v5';\n\nimport ConfigGeneric, { type ConfigGenericProps, type ConfigGenericState } from './ConfigGeneric';\nimport type { ConfigItemOAuth2 } from '../types';\n\ndeclare global {\n interface Window {\n attachEvent: Window['addEventListener'];\n detachEvent: Window['removeEventListener'];\n }\n}\n\ninterface ConfigOAuth2Props extends ConfigGenericProps {\n schema: ConfigItemOAuth2;\n}\n\nexport interface AccessTokens {\n access_token: string;\n expires_in: number;\n access_token_expires_on: string;\n ext_expires_in: number;\n token_type: 'Bearer';\n scope: string;\n refresh_token: string;\n}\n\ninterface ConfigOAuth2State extends ConfigGenericState {\n accessTokens: string;\n success: boolean;\n blocked: boolean;\n running: boolean;\n pressed: boolean;\n}\n\nexport default class ConfigOAuth2 extends ConfigGeneric<ConfigOAuth2Props, ConfigOAuth2State> {\n private authWindow?: WindowProxy | null;\n private readonly oid: string;\n private readonly url: string;\n\n constructor(props: ConfigOAuth2Props) {\n super(props);\n\n this.state = {\n ...this.state,\n accessTokens: '',\n success: false,\n blocked: false,\n running: false,\n pressed: false,\n };\n\n this.url = `https://oauth2.iobroker.in/${props.schema.identifier}?redirect=true`;\n if (props.schema.scope) {\n this.url += `&scope=${encodeURIComponent(props.schema.scope)}`;\n }\n\n this.oid = `${this.props.oContext.adapterName}.${this.props.oContext.instance}.${this.props.schema.saveTokenIn || 'oauth2Tokens'}`;\n }\n\n async componentDidMount(): Promise<void> {\n super.componentDidMount();\n if (window.addEventListener) {\n window.addEventListener('message', this.onMessage as any, false);\n } else {\n window.attachEvent('onmessage', this.onMessage as any, false);\n }\n\n await this.props.oContext.socket.subscribeState(this.oid, this.onTokensUpdated);\n\n // read tokens\n const tokens = await this.props.oContext.socket.getState(this.oid);\n if (tokens) {\n const accessTokens: AccessTokens = JSON.parse(tokens.val as string);\n if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {\n this.setState({ accessTokens: tokens.val as string });\n }\n }\n }\n\n onTokensUpdated = (_id: string, state: ioBroker.State | null | undefined): void => {\n if (state?.val) {\n const accessTokens: AccessTokens = JSON.parse(state.val as string);\n if (new Date(accessTokens.access_token_expires_on).getTime() > Date.now()) {\n if (this.state.accessTokens !== state.val) {\n this.setState({ accessTokens: state.val as string });\n }\n return;\n }\n }\n this.setState({ accessTokens: '' });\n };\n\n componentWillUnmount(): void {\n super.componentWillUnmount();\n if (window.removeEventListener) {\n window.removeEventListener('message', this.onMessage as any, false);\n } else {\n window.detachEvent('onmessage', this.onMessage as any, false);\n }\n this.props.oContext.socket.unsubscribeState(this.oid, this.onTokensUpdated);\n }\n\n saveToken(accessTokens: string): void {\n try {\n if (accessTokens && !accessTokens.startsWith('{')) {\n // convert base64 to string\n accessTokens = atob(accessTokens);\n }\n\n const accessTokensParsed: AccessTokens = JSON.parse(accessTokens);\n if (accessTokensParsed.access_token && accessTokensParsed.refresh_token && accessTokensParsed.expires_in) {\n // Give 10 seconds to user to copy the token\n accessTokensParsed.access_token_expires_on ||= new Date(\n Date.now() + accessTokensParsed.expires_in * 1000,\n ).toISOString();\n\n this.props.oContext.socket\n .setState(this.oid, JSON.stringify(accessTokensParsed), true)\n .catch((e: Error) => console.log(`Error occurred: ${e.toString()}`));\n }\n } catch (e) {\n // ignore\n console.warn(e);\n }\n }\n\n onMessage = (event: MessageEvent): void => {\n if (event.origin !== 'https://oauth2.iobroker.in') {\n return;\n }\n if (\n (typeof event.data === 'string' &&\n event.data.startsWith(`${this.props.schema.identifier}-authentication:`)) ||\n (typeof (event as any).message === 'string' &&\n (event as any).message.startsWith(`${this.props.schema.identifier}-authentication:`))\n ) {\n const parts = (event.data || (event as any).message).split(':');\n if (parts[1] === 'success') {\n this.setState({ accessTokens: parts[2], success: true, pressed: false }, () =>\n this.saveToken(this.state.accessTokens),\n );\n\n // send message to auth window to close it\n this.authWindow?.postMessage('close', event.origin);\n this.authWindow = null;\n } else {\n this.props.onError?.(parts[2]);\n }\n }\n };\n\n onOpenUrl(): void {\n this.authWindow = window.open(this.url, this.props.schema.identifier);\n if (!this.authWindow || this.authWindow.closed || typeof this.authWindow.closed === 'undefined') {\n this.setState({ blocked: true });\n } else {\n this.setState({ pressed: true });\n }\n }\n\n renderItem(): React.JSX.Element {\n let validTill = '';\n if (this.state.accessTokens) {\n try {\n const accessTokensParsed: AccessTokens = JSON.parse(this.state.accessTokens);\n validTill = new Date(accessTokensParsed.access_token_expires_on).toLocaleString();\n } catch {\n // ignore\n }\n }\n\n let label: string;\n if (this.state.accessTokens) {\n label = this.props.schema.refreshLabel\n ? this.getText(this.props.schema.refreshLabel)\n : I18n.t(\n 'ra_Renew %s access',\n this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1),\n );\n } else {\n label = this.props.schema.label\n ? this.getText(this.props.schema.label)\n : I18n.t(\n 'ra_Get %s access',\n this.props.schema.identifier[0].toUpperCase() + this.props.schema.identifier.slice(1),\n );\n }\n const icon = this.getIcon();\n\n return (\n <div style={{ width: '100%', margin: '0 0 1rem 0' }}>\n <Button\n disabled={this.state.running}\n endIcon={icon || <CloudUpload />}\n variant=\"contained\"\n onClick={() => this.onOpenUrl()}\n >\n {label}\n </Button>\n {this.state.blocked ? (\n <div style={{ color: 'red', fontSize: 16, marginTop: 20 }}>\n {I18n.t('ra_Please allow popups in your browser for this page!')}\n </div>\n ) : null}\n {this.state.accessTokens ? (\n <div style={{ color: 'green', fontSize: 16, marginTop: 20 }}>\n {this.props.alive\n ? I18n.t(\n 'ra_Successfully authorized. Token valid till %s and will be automatically renewed.',\n validTill,\n )\n : I18n.t(\n 'ra_Successfully authorized. Token valid till %s but it can expire as the instance is not running.',\n validTill,\n )}\n </div>\n ) : null}\n {this.state.pressed ? (\n <>\n <div style={{ width: '100%', margin: '1rem 0 1rem 0' }}>\n <span style={{ marginRight: 4 }}>\n {`${I18n.t('ra_If the button above does not work, you can authorize manually this app by visiting this url')}`}\n :\n </span>\n <br />\n <a\n target={this.props.schema.identifier}\n href={this.url}\n rel=\"noreferrer\"\n >\n {this.url}\n </a>\n </div>\n <TextField\n value={this.state.accessTokens}\n label={I18n.t('ra_Enter the code from that page here')}\n variant=\"standard\"\n onChange={e => {\n let accessTokens = e.target.value;\n if (accessTokens && !accessTokens.startsWith('{')) {\n // convert base64 to string\n accessTokens = atob(accessTokens);\n }\n try {\n const accessTokensParsed: AccessTokens = JSON.parse(accessTokens);\n if (accessTokensParsed.access_token) {\n accessTokensParsed.access_token_expires_on = new Date(\n Date.now() + (accessTokensParsed.expires_in - 10) * 1000,\n ).toISOString();\n this.setState({ accessTokens: JSON.stringify(accessTokensParsed) }, () =>\n this.saveToken(this.state.accessTokens),\n );\n }\n } catch {\n // ignore\n }\n }}\n fullWidth\n />\n </>\n ) : null}\n </div>\n );\n }\n}\n"]}
@@ -31,6 +31,7 @@ import ConfigJsonEditor from './ConfigJsonEditor';
31
31
  import ConfigLanguage from './ConfigLanguage';
32
32
  import ConfigLicense from './ConfigLicense';
33
33
  import ConfigNumber from './ConfigNumber';
34
+ import ConfigOauth2 from './ConfigOAuth2';
34
35
  import ConfigObjectId from './ConfigObjectId';
35
36
  import ConfigPassword from './ConfigPassword';
36
37
  import ConfigPattern from './ConfigPattern';
@@ -87,6 +88,7 @@ const components = {
87
88
  language: ConfigLanguage,
88
89
  license: ConfigLicense,
89
90
  number: ConfigNumber,
91
+ oauth2: ConfigOauth2,
90
92
  objectId: ConfigObjectId,
91
93
  password: ConfigPassword,
92
94
  pattern: ConfigPattern,
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigPanel.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAuC,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGxF,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,kBAA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,IAAI,CACN,CACN,CAAC;YACN,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Grid2, Accordion, AccordionSummary, AccordionDetails, Typography, Box } from '@mui/material';\n\nimport { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';\n\nimport { type AdminConnection, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemPanel } from '../types';\n\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\nimport ConfigAccordion from './ConfigAccordion';\nimport ConfigAlive from './ConfigAlive';\nimport ConfigAutocomplete from './ConfigAutocomplete';\nimport ConfigAutocompleteSendTo from './ConfigAutocompleteSendTo';\nimport ConfigCRON from './ConfigCRON';\nimport ConfigCertificateSelect from './ConfigCertificateSelect';\nimport ConfigCertificates from './ConfigCertificates';\nimport ConfigCertCollection from './ConfigCertCollection';\nimport ConfigCheckLicense from './ConfigCheckLicense';\nimport ConfigCheckbox from './ConfigCheckbox';\nimport ConfigChip from './ConfigChip';\nimport ConfigColor from './ConfigColor';\nimport ConfigCoordinates from './ConfigCoordinates';\nimport ConfigCustom from './ConfigCustom';\nimport ConfigDatePicker from './ConfigDatePicker';\nimport ConfigDeviceManager from './ConfigDeviceManager';\nimport ConfigFile from './ConfigFile';\nimport ConfigFileSelector from './ConfigFileSelector';\nimport ConfigFunc from './ConfigFunc';\nimport ConfigIP from './ConfigIP';\nimport ConfigImageSendTo from './ConfigImageSendTo';\nimport ConfigImageUpload from './ConfigImageUpload';\nimport ConfigInstanceSelect from './ConfigInstanceSelect';\nimport ConfigInterface from './ConfigInterface';\nimport ConfigJsonEditor from './ConfigJsonEditor';\nimport ConfigLanguage from './ConfigLanguage';\nimport ConfigLicense from './ConfigLicense';\nimport ConfigNumber from './ConfigNumber';\nimport ConfigObjectId from './ConfigObjectId';\nimport ConfigPassword from './ConfigPassword';\nimport ConfigPattern from './ConfigPattern';\nimport ConfigPort from './ConfigPort';\nimport ConfigRoom from './ConfigRoom';\nimport ConfigSelect from './ConfigSelect';\nimport ConfigSelectSendTo from './ConfigSelectSendTo';\nimport ConfigSendTo from './ConfigSendto';\nimport ConfigSetState from './ConfigSetState';\nimport ConfigSlider from './ConfigSlider';\nimport ConfigState from './ConfigState';\nimport ConfigStaticDivider from './ConfigStaticDivider';\nimport ConfigStaticHeader from './ConfigStaticHeader';\nimport ConfigStaticImage from './ConfigStaticImage';\nimport ConfigStaticInfo from './ConfigStaticInfo';\nimport ConfigStaticText from './ConfigStaticText';\nimport ConfigTable from './ConfigTable';\nimport ConfigText from './ConfigText';\nimport ConfigTextSendTo from './ConfigTextSendTo';\nimport ConfigTimePicker from './ConfigTimePicker';\nimport ConfigTopic from './ConfigTopic';\nimport ConfigUUID from './ConfigUUID';\nimport ConfigUser from './ConfigUser';\nimport ConfigQrCode from './ConfigQrCode';\n\nconst components: Record<string, typeof ConfigGeneric<any, any>> = {\n accordion: ConfigAccordion,\n alive: ConfigAlive,\n autocomplete: ConfigAutocomplete,\n autocompleteSendTo: ConfigAutocompleteSendTo,\n certCollection: ConfigCertCollection,\n certificate: ConfigCertificateSelect,\n certificates: ConfigCertificates,\n checkbox: ConfigCheckbox,\n checkLicense: ConfigCheckLicense,\n chip: ConfigChip, // deprecated. Use \"chips\"\n chips: ConfigChip,\n color: ConfigColor,\n coordinates: ConfigCoordinates,\n cron: ConfigCRON,\n custom: ConfigCustom,\n datePicker: ConfigDatePicker,\n deviceManager: ConfigDeviceManager,\n divider: ConfigStaticDivider,\n file: ConfigFile,\n fileSelector: ConfigFileSelector,\n func: ConfigFunc,\n header: ConfigStaticHeader,\n image: ConfigImageUpload,\n imageSendTo: ConfigImageSendTo,\n instance: ConfigInstanceSelect,\n interface: ConfigInterface,\n ip: ConfigIP,\n jsonEditor: ConfigJsonEditor,\n language: ConfigLanguage,\n license: ConfigLicense,\n number: ConfigNumber,\n objectId: ConfigObjectId,\n password: ConfigPassword,\n pattern: ConfigPattern,\n port: ConfigPort,\n qrCode: ConfigQrCode,\n room: ConfigRoom,\n select: ConfigSelect,\n selectSendTo: ConfigSelectSendTo,\n // @deprecated Use \"sendTo\"\n sendto: ConfigSendTo,\n sendTo: ConfigSendTo,\n setState: ConfigSetState,\n slider: ConfigSlider,\n state: ConfigState,\n staticImage: ConfigStaticImage,\n staticInfo: ConfigStaticInfo,\n staticLink: ConfigStaticText,\n staticText: ConfigStaticText,\n table: ConfigTable,\n text: ConfigText,\n textSendTo: ConfigTextSendTo,\n timePicker: ConfigTimePicker,\n topic: ConfigTopic,\n uuid: ConfigUUID,\n user: ConfigUser,\n};\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n // height: '100%',\n },\n paper: {\n margin: 1,\n width: 'auto !important',\n overflowY: 'auto',\n paddingBottom: 1,\n },\n paperWithIcons: {\n height: 'calc(100vh - 259px) !important',\n },\n paperWithoutIcons: {\n height: 'calc(100vh - 235px) !important',\n },\n padding: {\n padding: '10px',\n },\n heading: {},\n primary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.mode === 'dark' ? 'inherit' : '#FFF',\n }),\n secondary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.secondary.main,\n }),\n};\n\ninterface ConfigPanelProps extends ConfigGenericProps {\n schema: ConfigItemPanel;\n withIcons?: boolean;\n withoutSaveButtons?: boolean;\n}\ninterface ConfigPanelState extends ConfigGenericState {\n expanded?: boolean;\n}\n\nclass ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {\n componentDidMount(): void {\n super.componentDidMount();\n if (this.props.schema?.collapsable) {\n this.setState({\n expanded:\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n ) === 'true',\n });\n }\n }\n\n renderItems(items: Record<string, any>, disabled: boolean): JSX.Element[] | null {\n return items\n ? Object.keys(items).map(attr => {\n if (this.props.oContext.multiEdit && items[attr].noMultiEdit) {\n return null;\n }\n\n const type = items[attr].type || 'panel';\n let ItemComponent: typeof ConfigGeneric<ConfigGenericProps, any>;\n let socket: string | AdminConnection = 'Use this.props.oContext.socket!';\n if (type === 'custom') {\n // name\n // url\n if (items[attr].url) {\n ItemComponent = ConfigCustom;\n } else if (this.props.oContext.customs && this.props.oContext.customs[items[attr].component]) {\n ItemComponent = this.props.oContext.customs[items[attr].component];\n } else {\n console.error(`Cannot find custom component: ${items[attr].component}`);\n ItemComponent = ConfigGeneric;\n }\n socket = this.props.oContext.socket;\n } else if (type === 'panel') {\n ItemComponent = ConfigPanel;\n } else {\n ItemComponent = components[type] || ConfigGeneric;\n }\n\n return (\n <ItemComponent\n // @ts-expect-error Temporary work-around, till all custom components will not migrate to oContext\n socket={socket}\n globalData={this.props.globalData}\n oContext={this.props.oContext}\n key={`${attr}_${this.props.index === undefined ? '' : this.props.index}`}\n index={this.props.index}\n changed={this.props.changed}\n arrayIndex={this.props.arrayIndex}\n expertMode={this.props.expertMode}\n commandRunning={this.props.commandRunning}\n style={styles.panel}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onError={this.props.onError}\n onChange={this.props.onChange}\n disabled={disabled}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[attr]}\n attr={attr}\n table={this.props.table}\n />\n );\n })\n : null;\n }\n\n render(): JSX.Element | null {\n const schema = this.props.schema;\n\n if (!schema) {\n return null;\n }\n\n const { disabled, hidden } = this.calculate(schema);\n\n const items = this.props.schema.items;\n const schemaStyle = this.props.schema.style || {};\n\n if (hidden) {\n if (schema.hideOnlyControl) {\n const item = (\n <Grid2\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { marginBottom: 0, textAlign: 'left' /* marginRight: 8, */ },\n schemaStyle,\n this.props.oContext.themeType === 'dark' && schema.darkStyle,\n )}\n />\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return null;\n }\n\n if (this.props.table) {\n return this.renderItems(items, disabled) as any as JSX.Element;\n }\n\n if (this.props.custom) {\n return (\n <Grid2\n key={`${this.props.attr}_${this.props.index}`}\n container\n style={styles.fullWidth}\n columnSpacing={2}\n rowSpacing={1}\n sx={schemaStyle}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n );\n }\n\n let content;\n if (schema.collapsable) {\n content = (\n <Accordion\n key={`${this.props.attr}_${this.props.index}`}\n style={styles.fullWidth}\n expanded={!!this.state.expanded}\n onChange={() => {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n this.state.expanded ? 'false' : 'true',\n );\n this.setState({ expanded: !this.state.expanded });\n }}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n schemaStyle,\n this.props.oContext.themeType && schema.darkStyle,\n schema.color === 'primary'\n ? styles.primary\n : schema.color === 'secondary' && styles.secondary,\n { width: '100%' },\n )}\n >\n <Typography style={styles.heading}>{this.getText(schema.label)}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={{ ...schemaStyle, width: '100%', padding: '10px' }}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </AccordionDetails>\n </Accordion>\n );\n } else {\n const sx = Utils.getStyle(\n this.props.oContext.theme,\n this.props.style,\n schemaStyle,\n { width: '100%' },\n this.props.isParentTab && styles.paper,\n this.props.isParentTab &&\n (this.props.withoutSaveButtons\n ? this.props.withIcons\n ? { height: 'calc(100% - 88px) !important' }\n : { height: 'calc(100% - 64px) !important' }\n : this.props.withIcons\n ? styles.paperWithIcons\n : styles.paperWithoutIcons),\n );\n\n content = (\n <Box\n component=\"div\"\n key={`${this.props.attr}_${this.props.index}`}\n className={this.props.className}\n sx={sx}\n >\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { width: '100%' },\n this.props.isParentTab && styles.padding,\n this.props.schema.innerStyle,\n )}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </Box>\n );\n }\n\n if (!this.props.isParentTab) {\n const item = (\n <Grid2\n title={this.getText(schema.tooltip)}\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={{ marginBottom: 0, /* marginRight: 8, */ textAlign: 'left', ...schemaStyle }}\n >\n {content}\n </Grid2>\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return content;\n }\n}\n\nexport default ConfigPanel;\n"]}
1
+ {"version":3,"file":"ConfigPanel.js","sourceRoot":"./src/","sources":["JsonConfigComponent/ConfigPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEtG,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAuC,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAGxF,OAAO,aAAmE,MAAM,iBAAiB,CAAC;AAClG,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,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AC,SAAS,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,IAE/E,OAAO,CACJ,CACX,CAAC;YAEF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,OAAO,CACH;oBACI,6BAAK,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,GAAI;oBAC/C,IAAI,CACN,CACN,CAAC;YACN,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,eAAe,WAAW,CAAC","sourcesContent":["import React, { type JSX } from 'react';\n\nimport { Grid2, Accordion, AccordionSummary, AccordionDetails, Typography, Box } from '@mui/material';\n\nimport { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';\n\nimport { type AdminConnection, type IobTheme, Utils } from '@iobroker/adapter-react-v5';\nimport type { ConfigItemPanel } from '../types';\n\nimport ConfigGeneric, { type ConfigGenericState, type ConfigGenericProps } from './ConfigGeneric';\nimport ConfigAccordion from './ConfigAccordion';\nimport ConfigAlive from './ConfigAlive';\nimport ConfigAutocomplete from './ConfigAutocomplete';\nimport ConfigAutocompleteSendTo from './ConfigAutocompleteSendTo';\nimport ConfigCRON from './ConfigCRON';\nimport ConfigCertificateSelect from './ConfigCertificateSelect';\nimport ConfigCertificates from './ConfigCertificates';\nimport ConfigCertCollection from './ConfigCertCollection';\nimport ConfigCheckLicense from './ConfigCheckLicense';\nimport ConfigCheckbox from './ConfigCheckbox';\nimport ConfigChip from './ConfigChip';\nimport ConfigColor from './ConfigColor';\nimport ConfigCoordinates from './ConfigCoordinates';\nimport ConfigCustom from './ConfigCustom';\nimport ConfigDatePicker from './ConfigDatePicker';\nimport ConfigDeviceManager from './ConfigDeviceManager';\nimport ConfigFile from './ConfigFile';\nimport ConfigFileSelector from './ConfigFileSelector';\nimport ConfigFunc from './ConfigFunc';\nimport ConfigIP from './ConfigIP';\nimport ConfigImageSendTo from './ConfigImageSendTo';\nimport ConfigImageUpload from './ConfigImageUpload';\nimport ConfigInstanceSelect from './ConfigInstanceSelect';\nimport ConfigInterface from './ConfigInterface';\nimport ConfigJsonEditor from './ConfigJsonEditor';\nimport ConfigLanguage from './ConfigLanguage';\nimport ConfigLicense from './ConfigLicense';\nimport ConfigNumber from './ConfigNumber';\nimport ConfigOauth2 from './ConfigOAuth2';\nimport ConfigObjectId from './ConfigObjectId';\nimport ConfigPassword from './ConfigPassword';\nimport ConfigPattern from './ConfigPattern';\nimport ConfigPort from './ConfigPort';\nimport ConfigRoom from './ConfigRoom';\nimport ConfigSelect from './ConfigSelect';\nimport ConfigSelectSendTo from './ConfigSelectSendTo';\nimport ConfigSendTo from './ConfigSendto';\nimport ConfigSetState from './ConfigSetState';\nimport ConfigSlider from './ConfigSlider';\nimport ConfigState from './ConfigState';\nimport ConfigStaticDivider from './ConfigStaticDivider';\nimport ConfigStaticHeader from './ConfigStaticHeader';\nimport ConfigStaticImage from './ConfigStaticImage';\nimport ConfigStaticInfo from './ConfigStaticInfo';\nimport ConfigStaticText from './ConfigStaticText';\nimport ConfigTable from './ConfigTable';\nimport ConfigText from './ConfigText';\nimport ConfigTextSendTo from './ConfigTextSendTo';\nimport ConfigTimePicker from './ConfigTimePicker';\nimport ConfigTopic from './ConfigTopic';\nimport ConfigUUID from './ConfigUUID';\nimport ConfigUser from './ConfigUser';\nimport ConfigQrCode from './ConfigQrCode';\n\nconst components: Record<string, typeof ConfigGeneric<any, any>> = {\n accordion: ConfigAccordion,\n alive: ConfigAlive,\n autocomplete: ConfigAutocomplete,\n autocompleteSendTo: ConfigAutocompleteSendTo,\n certCollection: ConfigCertCollection,\n certificate: ConfigCertificateSelect,\n certificates: ConfigCertificates,\n checkbox: ConfigCheckbox,\n checkLicense: ConfigCheckLicense,\n chip: ConfigChip, // deprecated. Use \"chips\"\n chips: ConfigChip,\n color: ConfigColor,\n coordinates: ConfigCoordinates,\n cron: ConfigCRON,\n custom: ConfigCustom,\n datePicker: ConfigDatePicker,\n deviceManager: ConfigDeviceManager,\n divider: ConfigStaticDivider,\n file: ConfigFile,\n fileSelector: ConfigFileSelector,\n func: ConfigFunc,\n header: ConfigStaticHeader,\n image: ConfigImageUpload,\n imageSendTo: ConfigImageSendTo,\n instance: ConfigInstanceSelect,\n interface: ConfigInterface,\n ip: ConfigIP,\n jsonEditor: ConfigJsonEditor,\n language: ConfigLanguage,\n license: ConfigLicense,\n number: ConfigNumber,\n oauth2: ConfigOauth2,\n objectId: ConfigObjectId,\n password: ConfigPassword,\n pattern: ConfigPattern,\n port: ConfigPort,\n qrCode: ConfigQrCode,\n room: ConfigRoom,\n select: ConfigSelect,\n selectSendTo: ConfigSelectSendTo,\n // @deprecated Use \"sendTo\"\n sendto: ConfigSendTo,\n sendTo: ConfigSendTo,\n setState: ConfigSetState,\n slider: ConfigSlider,\n state: ConfigState,\n staticImage: ConfigStaticImage,\n staticInfo: ConfigStaticInfo,\n staticLink: ConfigStaticText,\n staticText: ConfigStaticText,\n table: ConfigTable,\n text: ConfigText,\n textSendTo: ConfigTextSendTo,\n timePicker: ConfigTimePicker,\n topic: ConfigTopic,\n uuid: ConfigUUID,\n user: ConfigUser,\n};\n\nconst styles: Record<string, any> = {\n fullWidth: {\n width: '100%',\n // height: '100%',\n },\n paper: {\n margin: 1,\n width: 'auto !important',\n overflowY: 'auto',\n paddingBottom: 1,\n },\n paperWithIcons: {\n height: 'calc(100vh - 259px) !important',\n },\n paperWithoutIcons: {\n height: 'calc(100vh - 235px) !important',\n },\n padding: {\n padding: '10px',\n },\n heading: {},\n primary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.primary.main,\n color: theme.palette.mode === 'dark' ? 'inherit' : '#FFF',\n }),\n secondary: (theme: IobTheme): React.CSSProperties => ({\n backgroundColor: theme.palette.secondary.main,\n }),\n};\n\ninterface ConfigPanelProps extends ConfigGenericProps {\n schema: ConfigItemPanel;\n withIcons?: boolean;\n withoutSaveButtons?: boolean;\n}\ninterface ConfigPanelState extends ConfigGenericState {\n expanded?: boolean;\n}\n\nclass ConfigPanel extends ConfigGeneric<ConfigPanelProps, ConfigPanelState> {\n componentDidMount(): void {\n super.componentDidMount();\n if (this.props.schema?.collapsable) {\n this.setState({\n expanded:\n (((window as any)._localStorage as Storage) || window.localStorage).getItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n ) === 'true',\n });\n }\n }\n\n renderItems(items: Record<string, any>, disabled: boolean): JSX.Element[] | null {\n return items\n ? Object.keys(items).map(attr => {\n if (this.props.oContext.multiEdit && items[attr].noMultiEdit) {\n return null;\n }\n\n const type = items[attr].type || 'panel';\n let ItemComponent: typeof ConfigGeneric<ConfigGenericProps, any>;\n let socket: string | AdminConnection = 'Use this.props.oContext.socket!';\n if (type === 'custom') {\n // name\n // url\n if (items[attr].url) {\n ItemComponent = ConfigCustom;\n } else if (this.props.oContext.customs && this.props.oContext.customs[items[attr].component]) {\n ItemComponent = this.props.oContext.customs[items[attr].component];\n } else {\n console.error(`Cannot find custom component: ${items[attr].component}`);\n ItemComponent = ConfigGeneric;\n }\n socket = this.props.oContext.socket;\n } else if (type === 'panel') {\n ItemComponent = ConfigPanel;\n } else {\n ItemComponent = components[type] || ConfigGeneric;\n }\n\n return (\n <ItemComponent\n // @ts-expect-error Temporary work-around, till all custom components will not migrate to oContext\n socket={socket}\n globalData={this.props.globalData}\n oContext={this.props.oContext}\n key={`${attr}_${this.props.index === undefined ? '' : this.props.index}`}\n index={this.props.index}\n changed={this.props.changed}\n arrayIndex={this.props.arrayIndex}\n expertMode={this.props.expertMode}\n commandRunning={this.props.commandRunning}\n style={styles.panel}\n common={this.props.common}\n alive={this.props.alive}\n themeName={this.props.themeName}\n data={this.props.data}\n originalData={this.props.originalData}\n onError={this.props.onError}\n onChange={this.props.onChange}\n disabled={disabled}\n customObj={this.props.customObj}\n custom={this.props.custom}\n schema={items[attr]}\n attr={attr}\n table={this.props.table}\n />\n );\n })\n : null;\n }\n\n render(): JSX.Element | null {\n const schema = this.props.schema;\n\n if (!schema) {\n return null;\n }\n\n const { disabled, hidden } = this.calculate(schema);\n\n const items = this.props.schema.items;\n const schemaStyle = this.props.schema.style || {};\n\n if (hidden) {\n if (schema.hideOnlyControl) {\n const item = (\n <Grid2\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { marginBottom: 0, textAlign: 'left' /* marginRight: 8, */ },\n schemaStyle,\n this.props.oContext.themeType === 'dark' && schema.darkStyle,\n )}\n />\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return null;\n }\n\n if (this.props.table) {\n return this.renderItems(items, disabled) as any as JSX.Element;\n }\n\n if (this.props.custom) {\n return (\n <Grid2\n key={`${this.props.attr}_${this.props.index}`}\n container\n style={styles.fullWidth}\n columnSpacing={2}\n rowSpacing={1}\n sx={schemaStyle}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n );\n }\n\n let content;\n if (schema.collapsable) {\n content = (\n <Accordion\n key={`${this.props.attr}_${this.props.index}`}\n style={styles.fullWidth}\n expanded={!!this.state.expanded}\n onChange={() => {\n (((window as any)._localStorage as Storage) || window.localStorage).setItem(\n `${this.props.oContext.adapterName}.${this.props.attr}`,\n this.state.expanded ? 'false' : 'true',\n );\n this.setState({ expanded: !this.state.expanded });\n }}\n >\n <AccordionSummary\n expandIcon={<ExpandMoreIcon />}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n schemaStyle,\n this.props.oContext.themeType && schema.darkStyle,\n schema.color === 'primary'\n ? styles.primary\n : schema.color === 'secondary' && styles.secondary,\n { width: '100%' },\n )}\n >\n <Typography style={styles.heading}>{this.getText(schema.label)}</Typography>\n </AccordionSummary>\n <AccordionDetails>\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={{ ...schemaStyle, width: '100%', padding: '10px' }}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </AccordionDetails>\n </Accordion>\n );\n } else {\n const sx = Utils.getStyle(\n this.props.oContext.theme,\n this.props.style,\n schemaStyle,\n { width: '100%' },\n this.props.isParentTab && styles.paper,\n this.props.isParentTab &&\n (this.props.withoutSaveButtons\n ? this.props.withIcons\n ? { height: 'calc(100% - 88px) !important' }\n : { height: 'calc(100% - 64px) !important' }\n : this.props.withIcons\n ? styles.paperWithIcons\n : styles.paperWithoutIcons),\n );\n\n content = (\n <Box\n component=\"div\"\n key={`${this.props.attr}_${this.props.index}`}\n className={this.props.className}\n sx={sx}\n >\n <Grid2\n container\n columnSpacing={2}\n rowSpacing={1}\n sx={Utils.getStyle(\n this.props.oContext.theme,\n { width: '100%' },\n this.props.isParentTab && styles.padding,\n this.props.schema.innerStyle,\n )}\n >\n {this.renderItems(items, disabled)}\n </Grid2>\n </Box>\n );\n }\n\n if (!this.props.isParentTab) {\n const item = (\n <Grid2\n title={this.getText(schema.tooltip)}\n size={{\n xs: schema.xs || undefined,\n sm: schema.sm || undefined,\n md: schema.md || undefined,\n lg: schema.lg || undefined,\n xl: schema.xl || undefined,\n }}\n sx={{ marginBottom: 0, /* marginRight: 8, */ textAlign: 'left', ...schemaStyle }}\n >\n {content}\n </Grid2>\n );\n\n if (schema.newLine) {\n return (\n <>\n <div style={{ flexBasis: '100%', height: 0 }} />\n {item}\n </>\n );\n }\n return item;\n }\n return content;\n }\n}\n\nexport default ConfigPanel;\n"]}
@@ -1,17 +1,12 @@
1
1
  import React from 'react';
2
2
  import { Button } from '@mui/material';
3
3
  import { Warning as IconWarning, Error as IconError, Info as IconInfo } from '@mui/icons-material';
4
- import { DialogConfirm, Icon, I18n } from '@iobroker/adapter-react-v5';
4
+ import { DialogConfirm, I18n } from '@iobroker/adapter-react-v5';
5
5
  import ConfigGeneric from './ConfigGeneric';
6
6
  const styles = {
7
7
  fullWidth: {
8
8
  width: '100%',
9
9
  },
10
- icon: {
11
- width: 24,
12
- height: 24,
13
- marginRight: 4,
14
- },
15
10
  };
16
11
  class ConfigSetState extends ConfigGeneric {
17
12
  async _onClick() {
@@ -61,6 +56,7 @@ class ConfigSetState extends ConfigGeneric {
61
56
  return (React.createElement(DialogConfirm, { title: this.getText(confirm.title) || I18n.t('ra_Please confirm'), text: this.getText(confirm.text), ok: this.getText(confirm.ok) || I18n.t('ra_Ok'), cancel: this.getText(confirm.cancel) || I18n.t('ra_Cancel'), icon: icon, onClose: isOk => this.setState({ confirmDialog: false }, () => isOk && this._onClick()) }));
62
57
  }
63
58
  renderItem(_error, disabled /* , defaultValue */) {
59
+ const icon = this.getIcon();
64
60
  return (React.createElement(Button, { variant: this.props.schema.variant || undefined, color: this.props.schema.color || 'grey', style: styles.fullWidth, disabled: disabled, onClick: async () => {
65
61
  if (this.props.schema.confirm) {
66
62
  this.setState({ confirmDialog: true });
@@ -68,9 +64,7 @@ class ConfigSetState extends ConfigGeneric {
68
64
  else {
69
65
  await this._onClick();
70
66
  }
71
- } },
72
- this.props.schema.icon ? (React.createElement(Icon, { src: this.props.schema.icon, style: styles.icon })) : null,
73
- this.getText(this.props.schema.label, this.props.schema.noTranslation)));
67
+ }, startIcon: icon || undefined }, this.getText(this.props.schema.label, this.props.schema.noTranslation)));
74
68
  }
75
69
  }
76
70
  export default ConfigSetState;