deprecated textarea

This commit is contained in:
ari committed 2022-05-24 21:31:54 -04:00
1 parent 3b7b17021f
commit 334268b5ee
4 files changed
+6 -82

No files matched your search

@@ -2,7 +2,6 @@ import "./AutoInfoBox.css";
import { AutomationMetadata } from "types/automations";
import { InputList } from "components/Inputs/InputList";
import InputText from "components/Inputs/InputText";
import InputTextArea from "components/Inputs/InputTextArea";
import { FC, useRef, useState } from 'react';
import { AddIcon, TrashIcon } from "components/Icons";
import { Button } from "components/Inputs/Button";
@@ -81,7 +80,7 @@ export const AutoInfoBox: FC<Props> = ({
<div className="automation-editor--info-box-inner">
<InputText label="ID" value={metadata.id} onChange={onUpdateMetadata('id')} />
<InputText label="Name" value={metadata.alias ?? ""} onChange={onUpdateMetadata('alias')} />
<InputTextArea label="Description" value={metadata.description ?? ""} onChange={onUpdateMetadata('description')} />
<InputText multiline label="Description" value={metadata.description ?? ""} onChange={onUpdateMetadata('description')} />
<InputList
label="Mode"
current={metadata.mode}
+5 -1
View File
@@ -9,6 +9,8 @@ export interface Props {
onChange: (v: string) => void;
onEnter?: () => void;
additionalTooltipFilters?: Record<string, string>;
multiline?: boolean;
maxRows?: number;
}
export default function InputText({
label,
@@ -17,11 +19,13 @@ export default function InputText({
onChange,
onEnter = () => { },
additionalTooltipFilters = {},
multiline = false,
maxRows = 4,
children,
}: PropsWithChildren<Props>) {
const tooltip = useToolTip();
const [isFocused, setIsFocused] = useState(false)
return <TextField inputMode="text" variant="filled" focused={isFocused} label={label} value={value}
return <TextField multiline={multiline} maxRows={maxRows} fullWidth inputMode="text" variant="filled" focused={isFocused} label={label} value={value}
onKeyDown={e => {
if (e.key === 'Enter') {
onEnter();
@@ -1,25 +0,0 @@
import { ComponentMeta, ComponentStory } from "@storybook/react";
import { Page } from "components/Page";
import { useState } from "react";
import InputTextArea from "./InputTextArea";
export default {
title: 'Inputs/InputTextArea',
component: InputTextArea,
parameters: { actions: { argTypesRegex: '^on.*' } },
} as ComponentMeta<typeof InputTextArea>;
const Template: ComponentStory<typeof InputTextArea> = args => {
const [value, setValue] = useState('')
return <Page>
<InputTextArea {...args} value={value} onChange={setValue} />
</Page>
}
export const SimpleText = Template.bind({})
SimpleText.args = {
label: "Entity ID",
}
@@ -1,54 +0,0 @@
import { useState } from "react";
import { useToolTip } from "tooltip/context";
import InputWrapper from "./InputWrapper";
import { useInputTextAreaStyles } from "./styles";
export interface Props {
textBoxFor?: string;
label: string;
value: string;
onChange: (v: string) => void;
additionalTooltipFilters?: Record<string, string>;
error?: string;
resizable?: boolean;
}
export default function InputTextArea({
label,
textBoxFor,
value = "",
onChange,
error,
additionalTooltipFilters = {},
resizable = false,
}: Props) {
const { classes } = useInputTextAreaStyles({ resizable });
const tooltip = useToolTip();
const [isFocused, setIsFocused] = useState(false)
return <InputWrapper error={error} label={label} labelSize={(value === '') && !isFocused ? 'normal' : 'small'}>
<textarea
className={classes.input}
value={value}
onChange={e => {
e.preventDefault();
onChange(e.target.value)
}}
onBlur={e => {
setIsFocused(false)
}}
onFocus={e => {
setIsFocused(true)
if (textBoxFor) {
tooltip.setFocus(
e.target.getBoundingClientRect(),
{
searchObject: textBoxFor,
searchText: value,
filterObjects: additionalTooltipFilters,
},
onChange
)
}
}}
/>
</InputWrapper>
}