v1 of service editor
This commit is contained in:
1 parent
0cecae5faa
commit
7b816c3fbf
16 files changed
+1185
-435
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import { PropsWithChildren, useState } from "react";
|
||||
import React, { PropsWithChildren, ReactNode, useState } from "react";
|
||||
import { useToolTip } from "tooltip/context";
|
||||
import TextField from '@mui/material/TextField';
|
||||
import TextField from "@mui/material/TextField";
|
||||
import InputWrapper from "./InputWrapper";
|
||||
|
||||
export interface Props {
|
||||
textBoxFor?: string;
|
||||
label: string;
|
||||
label: string | JSX.Element;
|
||||
value: string;
|
||||
onChange: (v: string) => void;
|
||||
onEnter?: () => void;
|
||||
@@ -13,50 +13,77 @@ export interface Props {
|
||||
multiline?: boolean;
|
||||
maxRows?: number;
|
||||
className?: string;
|
||||
placeholder?: any;
|
||||
title?: string;
|
||||
helperText?: string;
|
||||
endAdornment?: ReactNode;
|
||||
required?: boolean;
|
||||
}
|
||||
export default function InputText({
|
||||
label,
|
||||
title,
|
||||
helperText,
|
||||
textBoxFor,
|
||||
value = "",
|
||||
onChange,
|
||||
onEnter = () => { },
|
||||
endAdornment,
|
||||
onEnter = () => {},
|
||||
additionalTooltipFilters = {},
|
||||
multiline = false,
|
||||
maxRows = 4,
|
||||
children,
|
||||
className,
|
||||
placeholder,
|
||||
required,
|
||||
}: PropsWithChildren<Props>) {
|
||||
const tooltip = useToolTip();
|
||||
const [isFocused, setIsFocused] = useState(false)
|
||||
return <InputWrapper className={className} label="">
|
||||
<TextField multiline={multiline} maxRows={maxRows} fullWidth inputMode="text" variant="filled" focused={isFocused} label={label} value={value}
|
||||
onKeyDown={e => {
|
||||
if (e.key === 'Enter') {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={e => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value)
|
||||
}}
|
||||
onBlur={() => {
|
||||
setIsFocused(false)
|
||||
}}
|
||||
onFocus={e => {
|
||||
setIsFocused(true)
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
)
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{children}
|
||||
</InputWrapper>
|
||||
const [isFocused, setIsFocused] = useState(false);
|
||||
return (
|
||||
<InputWrapper className={className} label="">
|
||||
<TextField
|
||||
multiline={multiline}
|
||||
maxRows={maxRows}
|
||||
fullWidth
|
||||
inputMode="text"
|
||||
variant="filled"
|
||||
focused={isFocused}
|
||||
label={label}
|
||||
value={value}
|
||||
title={title}
|
||||
helperText={helperText}
|
||||
placeholder={placeholder}
|
||||
InputProps={{
|
||||
endAdornment,
|
||||
}}
|
||||
required={required}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
onEnter();
|
||||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
e.preventDefault();
|
||||
onChange(e.target.value);
|
||||
}}
|
||||
onBlur={() => {
|
||||
setIsFocused(false);
|
||||
}}
|
||||
onFocus={(e) => {
|
||||
setIsFocused(true);
|
||||
if (textBoxFor) {
|
||||
tooltip.setFocus(
|
||||
e.target.getBoundingClientRect(),
|
||||
{
|
||||
searchObject: textBoxFor,
|
||||
searchText: value,
|
||||
filterObjects: additionalTooltipFilters,
|
||||
},
|
||||
onChange
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{children}
|
||||
</InputWrapper>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user