2021-03-11 11:33:32 +00:00
|
|
|
import React, { useState } from "react";
|
|
|
|
import TextInput from "./";
|
2019-09-08 16:19:17 +00:00
|
|
|
|
2021-03-11 11:33:32 +00:00
|
|
|
export default {
|
|
|
|
title: "Components/TextInput",
|
|
|
|
component: TextInput,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
description: {
|
|
|
|
component: "Input field for single-line strings",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
onBlur: { action: "onBlur" },
|
|
|
|
onFocus: { action: "onFocus" },
|
|
|
|
onChange: { action: "onChange" },
|
|
|
|
},
|
|
|
|
};
|
2019-05-21 13:40:24 +00:00
|
|
|
|
2021-03-11 11:33:32 +00:00
|
|
|
const Template = ({ onChange, value, ...args }) => {
|
|
|
|
const [val, setValue] = useState(value);
|
2019-05-21 13:40:24 +00:00
|
|
|
|
2021-03-11 11:33:32 +00:00
|
|
|
return (
|
|
|
|
<TextInput
|
|
|
|
{...args}
|
|
|
|
value={val}
|
2020-10-16 13:16:01 +00:00
|
|
|
onChange={(e) => {
|
2021-03-11 11:33:32 +00:00
|
|
|
setValue(e.target.value);
|
|
|
|
onChange(e.target.value);
|
2020-10-16 13:16:01 +00:00
|
|
|
}}
|
2021-03-11 11:33:32 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Default = Template.bind({});
|
|
|
|
Default.args = {
|
|
|
|
id: "",
|
|
|
|
name: "",
|
|
|
|
placeholder: "This is placeholder",
|
|
|
|
maxLength: 255,
|
|
|
|
size: "base",
|
|
|
|
isAutoFocussed: false,
|
|
|
|
isDisabled: false,
|
|
|
|
isReadOnly: false,
|
|
|
|
hasError: false,
|
|
|
|
hasWarning: false,
|
|
|
|
scale: false,
|
|
|
|
autoComplete: "off",
|
|
|
|
tabIndex: 1,
|
|
|
|
withBorder: true,
|
|
|
|
mask: null,
|
|
|
|
value: "",
|
|
|
|
};
|