tag editor
This commit is contained in:
1 parent
5d9c04072b
commit
104882cb25
10 files changed
+186
-19
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { FC, ReactNode } from "react";
|
||||
import MuiButton from "@mui/material/Button";
|
||||
import MuiButton, { ButtonProps as MuiButtonProps } from "@mui/material/Button";
|
||||
|
||||
export const Button: FC<{
|
||||
className?: string;
|
||||
@@ -7,6 +7,7 @@ export const Button: FC<{
|
||||
disabled?: boolean;
|
||||
children?: ReactNode;
|
||||
onClick?: () => void;
|
||||
color?: MuiButtonProps["color"];
|
||||
}> = (props) => {
|
||||
return (
|
||||
<MuiButton
|
||||
@@ -16,6 +17,7 @@ export const Button: FC<{
|
||||
onClick={props.onClick}
|
||||
variant="outlined"
|
||||
children={props.children}
|
||||
color={props.color}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { Page } from "components/Page";
|
||||
import InputAutoText from "./InputAutoText";
|
||||
|
||||
export default {
|
||||
title: "Inputs/InputAutoText",
|
||||
component: InputAutoText,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
label: "Something",
|
||||
value: "",
|
||||
options: ["test", "usa", "canada"],
|
||||
},
|
||||
} as ComponentMeta<typeof InputAutoText>;
|
||||
|
||||
const Template: ComponentStory<typeof InputAutoText> = (args) => {
|
||||
return (
|
||||
<Page>
|
||||
<InputAutoText {...args} />
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
||||
export const Basic = Template.bind({});
|
||||
export const WithError = Template.bind({});
|
||||
WithError.args = {
|
||||
...WithError.args,
|
||||
error: "Oh no!",
|
||||
};
|
||||
@@ -11,14 +11,12 @@ export interface InputAutoTextProps {
|
||||
required?: boolean;
|
||||
endAdornment?: ReactNode;
|
||||
onChange: (v: string) => void;
|
||||
onEnter?: () => void;
|
||||
}
|
||||
export default function InputAutoText({
|
||||
value = "",
|
||||
label,
|
||||
options = [],
|
||||
onChange,
|
||||
onEnter = () => {},
|
||||
className,
|
||||
required,
|
||||
endAdornment,
|
||||
@@ -27,9 +25,10 @@ export default function InputAutoText({
|
||||
return (
|
||||
<Autocomplete
|
||||
freeSolo
|
||||
className={className}
|
||||
className={["input-autotext", className ?? ""].join(" ")}
|
||||
value={value}
|
||||
options={options}
|
||||
disableClearable
|
||||
onChange={(_e, v) => onChange(v === null ? "" : v)}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
@@ -41,12 +40,12 @@ export default function InputAutoText({
|
||||
helperText={error}
|
||||
fullWidth
|
||||
InputProps={{
|
||||
endAdornment,
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
onEnter();
|
||||
}
|
||||
...params.InputProps,
|
||||
endAdornment: (
|
||||
<>
|
||||
{endAdornment} {params.InputProps.endAdornment}
|
||||
</>
|
||||
),
|
||||
}}
|
||||
onChange={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in new issue
Block a user