@iobroker/adapter-react-v5 3.0.6 → 3.0.9
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/Components/JsonConfigComponent/ConfigCustom.js +156 -0
- package/Components/JsonConfigComponent/ConfigCustom.js.map +1 -0
- package/Components/Loaders/Vendor.js +3 -3
- package/Components/Loaders/Vendor.js.map +1 -1
- package/Components/SaveCloseButtons.js +9 -4
- package/Components/SaveCloseButtons.js.map +1 -1
- package/README.md +6 -0
- package/index.js +1201 -0
- package/index.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = void 0;
|
|
11
|
+
|
|
12
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
13
|
+
|
|
14
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
|
+
|
|
16
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
17
|
+
|
|
18
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
27
|
+
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
+
|
|
30
|
+
var _LinearProgress = _interopRequireDefault(require("@mui/material/LinearProgress"));
|
|
31
|
+
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
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 ConfigCustom = /*#__PURE__*/function (_Component) {
|
|
41
|
+
(0, _inherits2["default"])(ConfigCustom, _Component);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(ConfigCustom);
|
|
44
|
+
|
|
45
|
+
function ConfigCustom(props) {
|
|
46
|
+
var _this;
|
|
47
|
+
|
|
48
|
+
(0, _classCallCheck2["default"])(this, ConfigCustom);
|
|
49
|
+
_this = _super.call(this, props); // schema.url - location of Widget
|
|
50
|
+
// schema.name - Component name
|
|
51
|
+
|
|
52
|
+
_this.state = {
|
|
53
|
+
Component: null,
|
|
54
|
+
error: ''
|
|
55
|
+
};
|
|
56
|
+
return _this;
|
|
57
|
+
} // load component dynamically
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
(0, _createClass2["default"])(ConfigCustom, [{
|
|
61
|
+
key: "componentDidMount",
|
|
62
|
+
value: function () {
|
|
63
|
+
var _componentDidMount = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
64
|
+
var component, keys;
|
|
65
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
66
|
+
while (1) {
|
|
67
|
+
switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
if (this.props.schema.url) {
|
|
70
|
+
_context.next = 4;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
console.error('URL is empty. Cannot load custom component!');
|
|
75
|
+
this.setState({
|
|
76
|
+
error: 'URL is empty. Cannot load custom component!'
|
|
77
|
+
});
|
|
78
|
+
return _context.abrupt("return");
|
|
79
|
+
|
|
80
|
+
case 4:
|
|
81
|
+
if (this.props.schema.url.startsWith('http:') || this.props.schema.url.startsWith('https:')) {
|
|
82
|
+
window._customComponent = this.props.schema.url;
|
|
83
|
+
} else if (this.props.schema.url.startsWith('./')) {
|
|
84
|
+
window._customComponent = "".concat(window.location.protocol, "//").concat(window.location.host).concat(this.props.schema.url.replace(/^\./, ''));
|
|
85
|
+
} else {
|
|
86
|
+
window._customComponent = "".concat(window.location.protocol, "//").concat(window.location.host, "/").concat(this.props.schema.url);
|
|
87
|
+
} // custom component always has constant name
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
_context.next = 7;
|
|
91
|
+
return Promise.resolve().then(function () {
|
|
92
|
+
return _interopRequireWildcard(require('CustomComponent/Components'));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
case 7:
|
|
96
|
+
component = _context.sent;
|
|
97
|
+
|
|
98
|
+
if (!component || !!component["default"] || !component["default"][this.props.schema.name]) {
|
|
99
|
+
keys = Object.keys((component === null || component === void 0 ? void 0 : component["default"]) || {});
|
|
100
|
+
console.error('URL is empty. Cannot load custom component!');
|
|
101
|
+
this.setState({
|
|
102
|
+
error: "Component ".concat(this.props.schema.name, " not found in ").concat(this.props.schema.url, ". Found: ").concat(keys.join(', '))
|
|
103
|
+
});
|
|
104
|
+
} else {
|
|
105
|
+
this.setState({
|
|
106
|
+
Component: component["default"][this.props.schema.name]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
case 9:
|
|
111
|
+
case "end":
|
|
112
|
+
return _context.stop();
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, _callee, this);
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
function componentDidMount() {
|
|
119
|
+
return _componentDidMount.apply(this, arguments);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return componentDidMount;
|
|
123
|
+
}()
|
|
124
|
+
}, {
|
|
125
|
+
key: "render",
|
|
126
|
+
value: function render() {
|
|
127
|
+
var Component = this.state.Component;
|
|
128
|
+
|
|
129
|
+
if (!Component) {
|
|
130
|
+
if (this.state.error) {
|
|
131
|
+
return /*#__PURE__*/_react["default"].createElement("div", null, this.state.error);
|
|
132
|
+
} else {
|
|
133
|
+
return /*#__PURE__*/_react["default"].createElement(_LinearProgress["default"], null);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return /*#__PURE__*/_react["default"].createElement(Component, this.props);
|
|
138
|
+
}
|
|
139
|
+
}]);
|
|
140
|
+
return ConfigCustom;
|
|
141
|
+
}(_react.Component);
|
|
142
|
+
|
|
143
|
+
ConfigCustom.propTypes = {
|
|
144
|
+
socket: _propTypes["default"].object.isRequired,
|
|
145
|
+
themeType: _propTypes["default"].string,
|
|
146
|
+
themeName: _propTypes["default"].string,
|
|
147
|
+
style: _propTypes["default"].object,
|
|
148
|
+
className: _propTypes["default"].string,
|
|
149
|
+
data: _propTypes["default"].object.isRequired,
|
|
150
|
+
schema: _propTypes["default"].object,
|
|
151
|
+
onError: _propTypes["default"].func,
|
|
152
|
+
onChange: _propTypes["default"].func
|
|
153
|
+
};
|
|
154
|
+
var _default = ConfigCustom;
|
|
155
|
+
exports["default"] = _default;
|
|
156
|
+
//# sourceMappingURL=ConfigCustom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigCustom.js","names":["ConfigCustom","props","state","Component","error","schema","url","console","setState","startsWith","window","_customComponent","location","protocol","host","replace","component","name","keys","Object","join","propTypes","socket","PropTypes","object","isRequired","themeType","string","themeName","style","className","data","onError","func","onChange"],"sources":["JsonConfigComponent/ConfigCustom.jsx"],"sourcesContent":["import React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport LinearProgress from \"@mui/material/LinearProgress\";\n\nclass ConfigCustom extends Component {\n constructor(props) {\n super(props);\n // schema.url - location of Widget\n // schema.name - Component name\n\n this.state = {\n Component: null,\n error: '',\n };\n }\n\n // load component dynamically\n async componentDidMount() {\n if (!this.props.schema.url) {\n console.error('URL is empty. Cannot load custom component!');\n this.setState({ error: 'URL is empty. Cannot load custom component!' });\n return;\n }\n\n if (this.props.schema.url.startsWith('http:') || this.props.schema.url.startsWith('https:')) {\n window._customComponent = this.props.schema.url;\n } else if (this.props.schema.url.startsWith('./')) {\n window._customComponent = `${window.location.protocol}//${window.location.host}${this.props.schema.url.replace(/^\\./, '')}`;\n } else {\n window._customComponent = `${window.location.protocol}//${window.location.host}/${this.props.schema.url}`;\n }\n\n // custom component always has constant name\n const component = await import('CustomComponent/Components');\n\n if (!component || !!component.default || !component.default[this.props.schema.name]) {\n const keys = Object.keys(component?.default || {});\n console.error('URL is empty. Cannot load custom component!');\n this.setState({ error: `Component ${this.props.schema.name} not found in ${this.props.schema.url}. Found: ${keys.join(', ')}` });\n } else {\n this.setState({\n Component: component.default[this.props.schema.name]\n });\n }\n }\n\n render() {\n const Component = this.state.Component;\n if (!Component) {\n if (this.state.error) {\n return <div>{this.state.error}</div>;\n } else {\n return <LinearProgress />;\n }\n }\n\n return <Component {...this.props} />;\n }\n}\n\nConfigCustom.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};\n\nexport default ConfigCustom;"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;IAEMA,Y;;;;;EACF,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACf,0BAAMA,KAAN,EADe,CAEf;IACA;;IAEA,MAAKC,KAAL,GAAa;MACTC,SAAS,EAAE,IADF;MAETC,KAAK,EAAE;IAFE,CAAb;IALe;EASlB,C,CAED;;;;;;6GACA;QAAA;QAAA;UAAA;YAAA;cAAA;gBAAA,IACS,KAAKH,KAAL,CAAWI,MAAX,CAAkBC,GAD3B;kBAAA;kBAAA;gBAAA;;gBAEQC,OAAO,CAACH,KAAR,CAAc,6CAAd;gBACA,KAAKI,QAAL,CAAc;kBAAEJ,KAAK,EAAE;gBAAT,CAAd;gBAHR;;cAAA;gBAOI,IAAI,KAAKH,KAAL,CAAWI,MAAX,CAAkBC,GAAlB,CAAsBG,UAAtB,CAAiC,OAAjC,KAA6C,KAAKR,KAAL,CAA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AAV,CAAvF;kBAAP,CAAd;gBACH,CAJD,MAIO;kBACH,KAAKZ,QAAL,CAAc;oBACVL,SAAS,EAAEa,SAAS,WAAT,CAAkB,KAAKf,KAAL,CAAWI,MAAX,CAAkBY,IAApC;kBADD,CAAd;gBAGH;;cA1BL;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WA6BA,kBAAS;MACL,IAAMd,SAAS,GAAG,KAAKD,KAAL,CAAWC,SAA7B;;MACA,IAAI,CAACA,SAAL,EAAgB;QACZ,IAAI,KAAKD,KAAL,CAAWE,KAAf,EAAsB;UAClB,oBAAO,6CAAM,KAAKF,KAAL,CAAWE,KAAjB,CAAP;QACH,CAFD,MAEO;UACH,oBAAO,gCAAC,0BAAD,OAAP;QACH;MACJ;;MAED,oBAAO,gCAAC,SAAD,EAAe,KAAKH,KAApB,CAAP;IACH;;;EArDsBE,gB;;AAwD3BH,YAAY,CAACqB,SAAb,GAAyB;EACrBC,MAAM,EAAEC,qBAAA,CAAUC,MAAV,CAAiBC,UADJ;EAErBC,SAAS,EAAEH,qBAAA,CAAUI,MAFA;EAGrBC,SAAS,EAAEL,qBAAA,CAAUI,MAHA;EAIrBE,KAAK,EAAEN,qBAAA,CAAUC,MAJI;EAKrBM,SAAS,EAAEP,qBAAA,CAAUI,MALA;EAMrBI,IAAI,EAAER,qBAAA,CAAUC,MAAV,CAAiBC,UANF;EAOrBpB,MAAM,EAAEkB,qBAAA,CAAUC,MAPG;EAQrBQ,OAAO,EAAET,qBAAA,CAAUU,IARE;EASrBC,QAAQ,EAAEX,qBAAA,CAAUU;AATC,CAAzB;eAYejC,Y"}
|
|
@@ -30,13 +30,13 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
30
30
|
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; } }
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
|
-
* @typedef {object}
|
|
33
|
+
* @typedef {object} LoaderVendorProps
|
|
34
34
|
* @property {string} [key] The key to identify this component.
|
|
35
35
|
* @property {number} [size] The size in pixels of this loader.
|
|
36
36
|
* @property {string} [themeType] The chosen theme type.
|
|
37
37
|
* @property {string} [theme] The chosen theme.
|
|
38
38
|
*
|
|
39
|
-
* @extends {React.Component<
|
|
39
|
+
* @extends {React.Component<LoaderVendorProps>}
|
|
40
40
|
*/
|
|
41
41
|
var LoaderVendor = /*#__PURE__*/function (_React$Component) {
|
|
42
42
|
(0, _inherits2["default"])(LoaderVendor, _React$Component);
|
|
@@ -44,7 +44,7 @@ var LoaderVendor = /*#__PURE__*/function (_React$Component) {
|
|
|
44
44
|
var _super = _createSuper(LoaderVendor);
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
* @param {
|
|
47
|
+
* @param {LoaderVendorProps} props
|
|
48
48
|
*/
|
|
49
49
|
function LoaderVendor(props) {
|
|
50
50
|
var _this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Vendor.js","names":["LoaderVendor","props","size","theme","themeType","display","flexDirection","height","width","margin","flexGrow","React","Component","propTypes","PropTypes","number","string","_export"],"sources":["Loaders/Vendor.js"],"sourcesContent":["/**\n * Copyright 2021-2022 ioBroker GmbH\n *\n * MIT License\n *\n **/\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport './Vendor.css'\n\n/**\n * @typedef {object}
|
|
1
|
+
{"version":3,"file":"Vendor.js","names":["LoaderVendor","props","size","theme","themeType","display","flexDirection","height","width","margin","flexGrow","React","Component","propTypes","PropTypes","number","string","_export"],"sources":["Loaders/Vendor.js"],"sourcesContent":["/**\n * Copyright 2021-2022 ioBroker GmbH\n *\n * MIT License\n *\n **/\nimport React from 'react';\nimport PropTypes from 'prop-types';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport './Vendor.css'\n\n/**\n * @typedef {object} LoaderVendorProps\n * @property {string} [key] The key to identify this component.\n * @property {number} [size] The size in pixels of this loader.\n * @property {string} [themeType] The chosen theme type.\n * @property {string} [theme] The chosen theme.\n *\n * @extends {React.Component<LoaderVendorProps>}\n */\nclass LoaderVendor extends React.Component {\n /**\n * @param {LoaderVendorProps} props\n */\n constructor(props) {\n super(props);\n this.size = this.props.size || 200;\n }\n\n render() {\n const theme = this.props.themeType || this.props.theme || 'light';\n return <div className={'vendor-logo-back logo-background-' + theme} style={{\n display: 'flex',\n flexDirection: 'column',\n height: '100%',\n width: '10%',\n margin: 'auto'\n }}>\n <div style={{flexGrow: 1}}/>\n <CircularProgress color=\"secondary\" size={200} thickness={5}/>\n <div style={{flexGrow: 1}}/>\n </div>;\n }\n}\n\nLoaderVendor.propTypes = {\n size: PropTypes.number,\n themeType: PropTypes.string\n};\n\n/** @type {typeof LoaderVendor} */\nconst _export = LoaderVendor;\nexport default _export;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACMA,Y;;;;;EACF;AACJ;AACA;EACI,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACf,0BAAMA,KAAN;IACA,MAAKC,IAAL,GAAY,MAAKD,KAAL,CAAWC,IAAX,IAAmB,GAA/B;IAFe;EAGlB;;;;WAED,kBAAS;MACL,IAAMC,KAAK,GAAG,KAAKF,KAAL,CAAWG,SAAX,IAAwB,KAAKH,KAAL,CAAWE,KAAnC,IAA4C,OAA1D;MACA,oBAAO;QAAK,SAAS,EAAE,sCAAsCA,KAAtD;QAA6D,KAAK,EAAE;UACvEE,OAAO,EAAE,MAD8D;UAEvEC,aAAa,EAAE,QAFwD;UAGvEC,MAAM,EAAE,MAH+D;UAIvEC,KAAK,EAAE,KAJgE;UAKvEC,MAAM,EAAE;QAL+D;MAApE,gBAOH;QAAK,KAAK,EAAE;UAACC,QAAQ,EAAE;QAAX;MAAZ,EAPG,eAQH,gCAAC,4BAAD;QAAkB,KAAK,EAAC,WAAxB;QAAoC,IAAI,EAAE,GAA1C;QAA+C,SAAS,EAAE;MAA1D,EARG,eASH;QAAK,KAAK,EAAE;UAACA,QAAQ,EAAE;QAAX;MAAZ,EATG,CAAP;IAWH;;;EAtBsBC,iBAAA,CAAMC,S;;AAyBjCZ,YAAY,CAACa,SAAb,GAAyB;EACrBX,IAAI,EAAEY,qBAAA,CAAUC,MADK;EAErBX,SAAS,EAAEU,qBAAA,CAAUE;AAFA,CAAzB;AAKA;;AACA,IAAMC,OAAO,GAAGjB,YAAhB;eACeiB,O"}
|
|
@@ -45,14 +45,15 @@ var styles = function styles(theme) {
|
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
* @typedef {object}
|
|
48
|
+
* @typedef {object} SaveCloseButtonsProps
|
|
49
49
|
* @property {boolean} noTextOnButtons Are the buttons without text
|
|
50
50
|
* @property {any} theme Theme object (from this.state.theme)
|
|
51
51
|
* @property {boolean} isIFrame bottom position 0 or 38 for iFrame
|
|
52
|
+
* @property {boolean} newReact is used in new react
|
|
52
53
|
* @property {function} onSave on Save handler
|
|
53
54
|
* @property {function} onClose on Close handler
|
|
54
55
|
*
|
|
55
|
-
* @extends {React.Component<
|
|
56
|
+
* @extends {React.Component<SaveCloseButtonsProps>}
|
|
56
57
|
*/
|
|
57
58
|
|
|
58
59
|
|
|
@@ -61,16 +62,20 @@ var SaveCloseButtons = /*#__PURE__*/function (_React$Component) {
|
|
|
61
62
|
|
|
62
63
|
var _super = _createSuper(SaveCloseButtons);
|
|
63
64
|
|
|
65
|
+
/**
|
|
66
|
+
* @param {SaveCloseButtonsProps} props
|
|
67
|
+
*/
|
|
64
68
|
function SaveCloseButtons(props) {
|
|
65
69
|
var _this;
|
|
66
70
|
|
|
67
71
|
(0, _classCallCheck2["default"])(this, SaveCloseButtons);
|
|
68
72
|
_this = _super.call(this, props);
|
|
73
|
+
var newReact = props.newReact === undefined ? true : props.newReact;
|
|
69
74
|
|
|
70
75
|
try {
|
|
71
|
-
_this.isIFrame = !
|
|
76
|
+
_this.isIFrame = !newReact && window.self !== window.top;
|
|
72
77
|
} catch (e) {
|
|
73
|
-
_this.isIFrame = !
|
|
78
|
+
_this.isIFrame = !newReact;
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
return _this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaveCloseButtons.js","names":["styles","theme","buttonIcon","marginRight","SaveCloseButtons","props","
|
|
1
|
+
{"version":3,"file":"SaveCloseButtons.js","names":["styles","theme","buttonIcon","marginRight","SaveCloseButtons","props","newReact","undefined","isIFrame","window","self","top","e","noTextOnButtons","buttonStyle","borderRadius","saveToolbar","button","height","style","bottom","left","paddingLeft","right","position","background","dense","minHeight","error","border","changed","onSave","classes","I18n","t","Object","assign","marginLeft","flexGrow","onClose","React","Component","propTypes","PropTypes","bool","number","object","isRequired","func","_export","withStyles"],"sources":["SaveCloseButtons.js"],"sourcesContent":["// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined\nimport React from 'react';\nimport withStyles from '@mui/styles/withStyles';\nimport Fab from '@mui/material/Fab';\nimport PropTypes from 'prop-types';\n\nimport Toolbar from '@mui/material/Toolbar';\n\nimport I18n from '../i18n';\n\nimport IconSave from '@mui/icons-material/Save';\nimport IconClose from '@mui/icons-material/Close';\n\nconst styles = theme => ({\n buttonIcon: {\n marginRight: 8\n },\n});\n\n/**\n * @typedef {object} SaveCloseButtonsProps\n * @property {boolean} noTextOnButtons Are the buttons without text\n * @property {any} theme Theme object (from this.state.theme)\n * @property {boolean} isIFrame bottom position 0 or 38 for iFrame\n * @property {boolean} newReact is used in new react\n * @property {function} onSave on Save handler\n * @property {function} onClose on Close handler\n *\n * @extends {React.Component<SaveCloseButtonsProps>}\n */\nclass SaveCloseButtons extends React.Component {\n /**\n * @param {SaveCloseButtonsProps} props\n */\n constructor(props) {\n super(props);\n const newReact = props.newReact === undefined ? true : props.newReact;\n\n try {\n this.isIFrame = !newReact && window.self !== window.top;\n } catch (e) {\n this.isIFrame = !newReact;\n }\n }\n\n render() {\n const noTextOnButtons = this.props.noTextOnButtons;\n const buttonStyle = {\n borderRadius: this.props.theme.saveToolbar.button.borderRadius || 3,\n height: this.props.theme.saveToolbar.button.height || 32,\n };\n\n const style = {\n bottom: this.isIFrame ? 38 : 0,\n left: this.props.paddingLeft || 0,\n right: 0,\n position: 'absolute',\n background: this.props.theme.saveToolbar.background\n };\n if (this.props.dense) {\n style.minHeight = 48;\n }\n\n if (this.props.error) {\n buttonStyle.border = '1px solid red';\n }\n\n return <Toolbar position=\"absolute\" style={style}>\n <Fab\n variant=\"extended\"\n aria-label=\"Save\"\n disabled={!this.props.changed || this.props.error}\n onClick={() => this.props.onSave(false)}\n style={buttonStyle}\n >\n <IconSave className={!noTextOnButtons ? this.props.classes.buttonIcon : ''}/>{!noTextOnButtons && I18n.t('ra_Save')}\n </Fab>\n <Fab\n variant=\"extended\"\n aria-label=\"Save and close\"\n disabled={!this.props.changed || this.props.error}\n onClick={() => this.props.onSave(true)}\n style={Object.assign({}, buttonStyle, {marginLeft: 10})}>\n <IconSave className={!noTextOnButtons ? this.props.classes.buttonIcon : ''}/>\n {!noTextOnButtons ? I18n.t('ra_Save and close') : '+'}\n {noTextOnButtons && <IconClose/>}\n </Fab>\n <div style={{flexGrow: 1}}/>\n <Fab variant=\"extended\" aria-label=\"Close\" onClick={() => this.props.onClose()} style={buttonStyle}>\n <IconClose className={!noTextOnButtons ? this.props.classes.buttonIcon : ''}/>{!noTextOnButtons && I18n.t('ra_Close')}\n </Fab>\n </Toolbar>;\n }\n}\n\nSaveCloseButtons.propTypes = {\n dense: PropTypes.bool,\n paddingLeft: PropTypes.number,\n noTextOnButtons: PropTypes.bool,\n theme: PropTypes.object,\n isIFrame: PropTypes.bool,\n changed: PropTypes.bool.isRequired,\n error: PropTypes.bool,\n onSave: PropTypes.func.isRequired,\n onClose: PropTypes.func.isRequired,\n newReact: PropTypes.bool,\n};\n\n/** @type {typeof SaveCloseButtons} */\nconst _export = withStyles(styles)(SaveCloseButtons);\nexport default _export;"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;EAAA,OAAK;IACrBC,UAAU,EAAE;MACRC,WAAW,EAAE;IADL;EADS,CAAL;AAAA,CAApB;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;IACMC,gB;;;;;EACF;AACJ;AACA;EACI,0BAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACf,0BAAMA,KAAN;IACA,IAAMC,QAAQ,GAAGD,KAAK,CAACC,QAAN,KAAmBC,SAAnB,GAA+B,IAA/B,GAAsCF,KAAK,CAACC,QAA7D;;IAEA,IAAI;MACA,MAAKE,QAAL,GAAgB,CAACF,QAAD,IAAaG,MAAM,CAACC,IAAP,KAAgBD,MAAM,CAACE,GAApD;IACH,CAFD,CAEE,OAAOC,CAAP,EAAU;MACR,MAAKJ,QAAL,GAAgB,CAACF,QAAjB;IACH;;IARc;EASlB;;;;WAED,kBAAS;MAAA;;MACL,IAAMO,eAAe,GAAG,KAAKR,KAAL,CAAWQ,eAAnC;MACA,IAAMC,WAAW,GAAG;QAChBC,YAAY,EAAE,KAAKV,KAAL,CAAWJ,KAAX,CAAiBe,WAAjB,CAA6BC,MAA7B,CAAoCF,YAApC,IAAoD,CADlD;QAEhBG,MAAM,EAAQ,KAAKb,KAAL,CAAWJ,KAAX,CAAiBe,WAAjB,CAA6BC,MAA7B,CAAoCC,MAApC,IAAoD;MAFlD,CAApB;MAKA,IAAMC,KAAK,GAAG;QACVC,MAAM,EAAE,KAAKZ,QAAL,GAAgB,EAAhB,GAAqB,CADnB;QAEVa,IAAI,EAAE,KAA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AV,CAAeD,UATC;EAUzBzC,QAAQ,EAAEqC,qBAAA,CAAUC;AAVK,CAA7B;AAaA;;AACA,IAAMK,OAAO,GAAG,IAAAC,sBAAA,EAAWlD,MAAX,EAAmBI,gBAAnB,CAAhB;;eACe6C,O"}
|
package/README.md
CHANGED
|
@@ -641,6 +641,12 @@ If you still have questions, try to find an answer [here](https://mui.com/guides
|
|
|
641
641
|
-->
|
|
642
642
|
|
|
643
643
|
## Changelog
|
|
644
|
+
### 3.0.9 (2022-05-25)
|
|
645
|
+
* (bluefox) Added ConfigGeneric to import
|
|
646
|
+
|
|
647
|
+
### 3.0.7 (2022-05-25)
|
|
648
|
+
* (bluefox) Made the module definitions
|
|
649
|
+
|
|
644
650
|
### 3.0.6 (2022-05-25)
|
|
645
651
|
* (bluefox) Added JsonConfigComponent
|
|
646
652
|
|