@iobroker/adapter-react-v5
Version:
React components to develop ioBroker interfaces with react.
65 lines • 2.99 kB
JavaScript
// please do not delete React, as without it other projects could not be compiled: ReferenceError: React is not defined
import React from 'react';
import { Fab, Toolbar } from '@mui/material';
import { Save as IconSave, Close as IconClose } from '@mui/icons-material';
import { I18n } from '../i18n';
const styles = {
buttonIcon: {
marginRight: 8,
},
};
export class SaveCloseButtons extends React.Component {
isIFrame;
constructor(props) {
super(props);
const newReact = props.newReact === undefined ? true : props.newReact;
if (props.isIFrame !== undefined) {
this.isIFrame = props.isIFrame;
}
else {
try {
this.isIFrame = !newReact && window.self !== window.top;
}
catch {
this.isIFrame = !newReact;
}
}
}
render() {
const noTextOnButtons = this.props.noTextOnButtons;
const buttonStyle = {
borderRadius: this.props.theme.saveToolbar.button.borderRadius || 3,
height: this.props.theme.saveToolbar.button.height || 32,
};
const style = {
bottom: this.isIFrame ? 38 : 0,
left: this.props.paddingLeft || 0,
right: 0,
position: 'absolute',
background: this.props.theme.saveToolbar.background,
};
if (this.props.dense) {
style.minHeight = 48;
}
if (this.props.error) {
buttonStyle.border = '1px solid red';
}
return (React.createElement(Toolbar
// position="absolute"
, {
// position="absolute"
style: style },
React.createElement(Fab, { variant: "extended", "aria-label": "Save", disabled: !this.props.changed || this.props.error, onClick: () => this.props.onSave(false), style: buttonStyle },
React.createElement(IconSave, { style: !noTextOnButtons ? styles.buttonIcon : undefined }),
!noTextOnButtons && I18n.t('ra_Save')),
React.createElement(Fab, { variant: "extended", "aria-label": "Save and close", disabled: !this.props.changed || this.props.error, onClick: () => this.props.onSave(true), style: { ...buttonStyle, ...{ marginLeft: 10 } } },
React.createElement(IconSave, { style: !noTextOnButtons ? styles.buttonIcon : undefined }),
!noTextOnButtons ? I18n.t('ra_Save and close') : '+',
noTextOnButtons && React.createElement(IconClose, null)),
React.createElement("div", { style: { flexGrow: 1 } }),
React.createElement(Fab, { variant: "extended", "aria-label": "Close", onClick: () => this.props.onClose(), style: buttonStyle },
React.createElement(IconClose, { style: !noTextOnButtons ? styles.buttonIcon : undefined }),
!noTextOnButtons && I18n.t('ra_Close'))));
}
}
//# sourceMappingURL=SaveCloseButtons.js.map