@iobroker/adapter-react-v5 3.1.5 → 3.1.8

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.
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
14
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
15
+
16
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
+
18
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
+
20
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
+
22
+ var _react = _interopRequireDefault(require("react"));
23
+
24
+ var _propTypes = _interopRequireDefault(require("prop-types"));
25
+
26
+ var _styles = require("@mui/styles");
27
+
28
+ var _Button = _interopRequireDefault(require("@mui/material/Button"));
29
+
30
+ var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
31
+
32
+ var _ConfigGeneric2 = _interopRequireDefault(require("./ConfigGeneric"));
33
+
34
+ var _FileSelect = _interopRequireDefault(require("../../Dialogs/FileSelect"));
35
+
36
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
37
+
38
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
+
40
+ var styles = function styles(theme) {
41
+ return {
42
+ fullWidth: {
43
+ width: '100%'
44
+ },
45
+ fullWidthOneButton: {
46
+ width: 'calc(100% - 65px)'
47
+ }
48
+ };
49
+ };
50
+
51
+ var IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp'];
52
+ var AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];
53
+ var VIDEO_EXT = ['avi', 'mp4', 'mov'];
54
+ var DOC_EXT = ['txt', 'log', 'html', 'htm'];
55
+ var JS_EXT = ['json', 'js', 'ts'];
56
+
57
+ var ConfigFile = /*#__PURE__*/function (_ConfigGeneric) {
58
+ (0, _inherits2["default"])(ConfigFile, _ConfigGeneric);
59
+
60
+ var _super = _createSuper(ConfigFile);
61
+
62
+ function ConfigFile() {
63
+ (0, _classCallCheck2["default"])(this, ConfigFile);
64
+ return _super.apply(this, arguments);
65
+ }
66
+
67
+ (0, _createClass2["default"])(ConfigFile, [{
68
+ key: "componentDidMount",
69
+ value: function componentDidMount() {
70
+ (0, _get2["default"])((0, _getPrototypeOf2["default"])(ConfigFile.prototype), "componentDidMount", this).call(this);
71
+
72
+ var value = _ConfigGeneric2["default"].getValue(this.props.data, this.props.attr);
73
+
74
+ this.setState({
75
+ value: value
76
+ });
77
+ }
78
+ }, {
79
+ key: "renderFileBrowser",
80
+ value: function renderFileBrowser() {
81
+ var _this = this;
82
+
83
+ if (!this.state.showFileBrowser) {
84
+ return null;
85
+ } else {
86
+ return /*#__PURE__*/_react["default"].createElement(_FileSelect["default"], {
87
+ imagePrefix: this.props.imagePrefix,
88
+ socket: this.props.socket,
89
+ selected: this.state.value,
90
+ onClose: function onClose() {
91
+ return _this.setState({
92
+ showFileBrowser: false
93
+ });
94
+ },
95
+ onOk: function onOk(value) {
96
+ _this.setState({
97
+ value: value
98
+ }, function () {
99
+ return _this.onChange(_this.props.attr, _this.props.schema.trim === false ? value : (value || '').trim());
100
+ });
101
+ },
102
+ selectOnlyFolders: this.props.schema.selectOnlyFolders,
103
+ allowUpload: this.props.schema.allowUpload,
104
+ allowDownload: this.props.schema.allowDownload,
105
+ allowCreateFolder: this.props.schema.allowCreateFolder,
106
+ allowView: this.props.schema.allowView,
107
+ showToolbar: this.props.schema.showToolbar,
108
+ limitPath: this.props.schema.limitPath
109
+ });
110
+ }
111
+ }
112
+ }, {
113
+ key: "renderItem",
114
+ value: function renderItem(error, disabled, defaultValue) {
115
+ var _this2 = this;
116
+
117
+ return /*#__PURE__*/_react["default"].createElement("div", {
118
+ className: this.props.classes.fullWidth
119
+ }, /*#__PURE__*/_react["default"].createElement(_TextField["default"], {
120
+ variant: "standard",
121
+ className: this.props.classes.fullWidthOneButton,
122
+ value: this.state.value === null || this.state.value === undefined ? '' : this.state.value,
123
+ error: !!error,
124
+ disabled: !!disabled,
125
+ inputProps: {
126
+ maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,
127
+ readOnly: !!this.props.schema.disableEdit
128
+ },
129
+ onChange: function onChange(e) {
130
+ var value = e.target.value;
131
+
132
+ _this2.setState({
133
+ value: value
134
+ }, function () {
135
+ return _this2.onChange(_this2.props.attr, _this2.props.schema.trim === false ? value : (value || '').trim());
136
+ });
137
+ },
138
+ placeholder: this.getText(this.props.schema.placeholder),
139
+ label: this.getText(this.props.schema.label),
140
+ helperText: this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)
141
+ }), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
142
+ variant: "outlined",
143
+ onClick: function onClick() {
144
+ return _this2.setState({
145
+ showFileBrowser: true
146
+ });
147
+ }
148
+ }, "..."), this.renderFileBrowser());
149
+ }
150
+ }], [{
151
+ key: "getDerivedStateFromProps",
152
+ value: function getDerivedStateFromProps(props, state) {
153
+ var value = _ConfigGeneric2["default"].getValue(props.data, props.attr);
154
+
155
+ if (value === null || value === undefined || value.toString().trim() !== (state.value || '').toString().trim()) {
156
+ return {
157
+ value: value
158
+ };
159
+ } else {
160
+ return null;
161
+ }
162
+ }
163
+ }]);
164
+ return ConfigFile;
165
+ }(_ConfigGeneric2["default"]);
166
+
167
+ ConfigFile.propTypes = {
168
+ socket: _propTypes["default"].object.isRequired,
169
+ themeType: _propTypes["default"].string,
170
+ themeName: _propTypes["default"].string,
171
+ style: _propTypes["default"].object,
172
+ className: _propTypes["default"].string,
173
+ data: _propTypes["default"].object.isRequired,
174
+ schema: _propTypes["default"].object,
175
+ onError: _propTypes["default"].func,
176
+ onChange: _propTypes["default"].func,
177
+ imagePrefix: _propTypes["default"].func
178
+ };
179
+
180
+ var _default = (0, _styles.withStyles)(styles)(ConfigFile);
181
+
182
+ exports["default"] = _default;
183
+ //# sourceMappingURL=ConfigFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConfigFile.js","names":["styles","theme","fullWidth","width","fullWidthOneButton","IMAGE_EXT","AUDIO_EXT","VIDEO_EXT","DOC_EXT","JS_EXT","ConfigFile","value","ConfigGeneric","getValue","props","data","attr","setState","state","showFileBrowser","imagePrefix","socket","onChange","schema","trim","selectOnlyFolders","allowUpload","allowDownload","allowCreateFolder","allowView","showToolbar","limitPath","error","disabled","defaultValue","classes","undefined","maxLength","max","readOnly","disableEdit","e","target","getText","placeholder","label","renderHelp","help","helpLink","noTranslation","renderFileBrowser","toString","propTypes","PropTypes","object","isRequired","themeType","string","themeName","style","className","onError","func","withStyles"],"sources":["JsonConfigComponent/ConfigFile.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@mui/styles';\n\nimport Button from '@mui/material/Button';\nimport TextField from '@mui/material/TextField';\n\nimport ConfigGeneric from './ConfigGeneric';\nimport FileSelectDialog from '../../Dialogs/FileSelect';\n\nconst styles = theme => ({\n fullWidth: {\n width: '100%'\n },\n fullWidthOneButton: {\n width: 'calc(100% - 65px)'\n },\n\n});\n\nconst IMAGE_EXT = ['jpg', 'jpeg', 'svg', 'png', 'webp'];\nconst AUDIO_EXT = ['mp3', 'ogg', 'wav', 'aac'];\nconst VIDEO_EXT = ['avi', 'mp4', 'mov'];\nconst DOC_EXT = ['txt', 'log', 'html', 'htm'];\nconst JS_EXT = ['json', 'js', 'ts'];\n\nclass ConfigFile extends ConfigGeneric {\n componentDidMount() {\n super.componentDidMount();\n const value = ConfigGeneric.getValue(this.props.data, this.props.attr);\n this.setState({ value });\n }\n\n static getDerivedStateFromProps(props, state) {\n const value = ConfigGeneric.getValue(props.data, props.attr);\n if (value === null || value === undefined || value.toString().trim() !== (state.value || '').toString().trim()) {\n return { value };\n } else {\n return null;\n }\n }\n\n renderFileBrowser() {\n if (!this.state.showFileBrowser) {\n return null;\n } else {\n return <FileSelectDialog\n imagePrefix={this.props.imagePrefix}\n socket={this.props.socket}\n selected={this.state.value}\n onClose={() => this.setState({ showFileBrowser: false})}\n onOk={value => {\n this.setState({ value }, () =>\n this.onChange(this.props.attr, this.props.schema.trim === false ? value : (value || '').trim()));\n }}\n selectOnlyFolders={this.props.schema.selectOnlyFolders}\n allowUpload={this.props.schema.allowUpload}\n allowDownload={this.props.schema.allowDownload}\n allowCreateFolder={this.props.schema.allowCreateFolder}\n allowView={this.props.schema.allowView}\n showToolbar={this.props.schema.showToolbar}\n limitPath={this.props.schema.limitPath}\n />;\n }\n }\n\n renderItem(error, disabled, defaultValue) {\n return <div className={this.props.classes.fullWidth}>\n <TextField\n variant=\"standard\"\n className={this.props.classes.fullWidthOneButton}\n value={this.state.value === null || this.state.value === undefined ? '' : this.state.value}\n error={!!error}\n disabled={!!disabled}\n inputProps={{\n maxLength: this.props.schema.maxLength || this.props.schema.max || undefined,\n readOnly: !!this.props.schema.disableEdit\n }}\n onChange={e => {\n const value = e.target.value;\n this.setState({ value }, () =>\n this.onChange(this.props.attr, this.props.schema.trim === false ? value : (value || '').trim()));\n }}\n placeholder={this.getText(this.props.schema.placeholder)}\n label={this.getText(this.props.schema.label)}\n helperText={this.renderHelp(this.props.schema.help, this.props.schema.helpLink, this.props.schema.noTranslation)}\n />\n <Button variant=\"outlined\" onClick={() => this.setState({ showFileBrowser: true })}>...</Button>\n {this.renderFileBrowser()}\n </div>;\n }\n}\n\nConfigFile.propTypes = {\n socket: PropTypes.object.isRequired,\n themeType: PropTypes.string,\n themeName: PropTypes.string,\n style: PropTypes.object,\n className: PropTypes.string,\n data: PropTypes.object.isRequired,\n schema: PropTypes.object,\n onError: PropTypes.func,\n onChange: PropTypes.func,\n imagePrefix: PropTypes.func,\n};\n\nexport default withStyles(styles)(ConfigFile);"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,SAAS,EAAE;MACPC,KAAK,EAAE;IADA,CADU;IAIrBC,kBAAkB,EAAE;MAChBD,KAAK,EAAE;IADS;EAJC,CAAL;AAAA,CAApB;;AAUA,IAAME,SAAS,GAAG,CAAC,KAAD,EAAQ,MAAR,EAAgB,KAAhB,EAAuB,KAAvB,EAA8B,MAA9B,CAAlB;AACA,IAAMC,SAAS,GAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,EAAsB,KAAtB,CAAlB;AACA,IAAMC,SAAS,GAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,KAAf,CAAlB;AACA,IAAMC,OAAO,GAAG,CAAC,KAAD,EAAQ,KAAR,EAAe,MAAf,EAAuB,KAAvB,CAAhB;AACA,IAAMC,MAAM,GAAG,CAAC,MAAD,EAAS,IAAT,EAAe,IAAf,CAAf;;IAEMC,U;;;;;;;;;;;;WACF,6BAAoB;MAChB;;MACA,IAAMC,KAAK,GAAGC,0BAAA,CAAcC,QAAd,CAAuB,KAAKC,KAAL,CAAWC,IAAlC,EAAwC,KAAKD,KAAL,CAAWE,IAAnD,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