// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import React from 'react'; import { WrappedFieldProps } from 'redux-form'; import { ArvadosTheme } from 'common/custom-theme'; import { CustomStyleRulesCallback } from 'common/custom-theme'; import { TextField as MaterialTextField, PropTypes } from '@mui/material'; import { WithStyles } from '@mui/styles'; import withStyles from '@mui/styles/withStyles'; import RichTextEditor from 'react-rte'; type CssRules = 'textField' | 'rte'; const styles: CustomStyleRulesCallback = (theme: ArvadosTheme) => ({ textField: { marginBottom: theme.spacing(1) }, rte: { fontFamily: 'Arial', '& a': { textDecoration: 'none', color: theme.palette.primary.main, '&:hover': { cursor: 'pointer', textDecoration: 'underline' } } } }); type TextFieldProps = WrappedFieldProps & WithStyles; export const TextField = withStyles(styles)((props: TextFieldProps & { label?: string, autoFocus?: boolean, required?: boolean, select?: boolean, disabled?: boolean, children: React.ReactNode, margin?: any, placeholder?: string, helperText?: string, type?: string, }) => ); interface RichEditorTextFieldData { label?: string; } type RichEditorTextFieldProps = RichEditorTextFieldData & TextFieldProps; export const RichEditorTextField = withStyles(styles)( class RichEditorTextField extends React.Component { state = { value: RichTextEditor.createValueFromString(this.props.input.value, 'html') }; onChange = (value: any) => { this.setState({ value }); this.props.input.onChange( !!value.getEditorState().getCurrentContent().getPlainText().trim() ? value.toString('html') : null ); } render() { return ; } } ); export const DateTextField = withStyles(styles) ((props: TextFieldProps) => );