UNPKG

@iobroker/adapter-react-v5

Version:

React components to develop ioBroker interfaces with react.

31 lines 2.25 kB
import React from 'react'; import { Button, TextField, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle } from '@mui/material'; import { Close as IconClose, Check as IconCheck } from '@mui/icons-material'; import { I18n } from '../i18n'; import { withWidth } from '../Components/withWidth'; function TextInputFunc(props) { const [text, setText] = React.useState(props.input || props.value || ''); const [error, setError] = React.useState(''); return (React.createElement(Dialog, { open: !0, onClose: () => props.onClose(null), "aria-labelledby": "form-dialog-title", fullWidth: props.fullWidth !== undefined ? props.fullWidth : false }, React.createElement(DialogTitle, { id: "form-dialog-title" }, props.titleText), React.createElement(DialogContent, null, React.createElement(DialogContentText, null, props.promptText), React.createElement(TextField, { variant: "standard", autoFocus: true, margin: "dense", error: !!error, helperText: error === true || !error ? '' : error, value: text, label: props.labelText || '', type: props.type || 'text', onKeyUp: e => e.code === 'Enter' && text && props.onClose(text), onChange: e => { let _error = ''; if (props.verify) { _error = !props.verify(e.target.value); } if (props.rule) { setText(props.rule(e.target.value)); } else { setText(e.target.value); } setError(_error); }, fullWidth: true })), React.createElement(DialogActions, null, React.createElement(Button, { variant: "contained", disabled: !text || !!error, onClick: () => props.onClose(text), color: "primary", startIcon: React.createElement(IconCheck, null) }, props.applyText || I18n.t('ra_Ok')), React.createElement(Button, { color: "grey", variant: "contained", onClick: () => props.onClose(null), startIcon: React.createElement(IconClose, null) }, props.cancelText || I18n.t('ra_Cancel'))))); } export const DialogTextInput = withWidth()(TextInputFunc); //# sourceMappingURL=TextInput.js.map