2020-10-16 13:16:01 +00:00
|
|
|
import React from "react";
|
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
import { action } from "@storybook/addon-actions";
|
|
|
|
import { StringValue } from "react-values";
|
|
|
|
import {
|
|
|
|
withKnobs,
|
|
|
|
boolean,
|
|
|
|
text,
|
|
|
|
select,
|
|
|
|
number,
|
|
|
|
} from "@storybook/addon-knobs/react";
|
|
|
|
import withReadme from "storybook-readme/with-readme";
|
|
|
|
import Readme from "./README.md";
|
|
|
|
import TextInput from ".";
|
2019-09-08 16:19:17 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
import Section from "../../../.storybook/decorators/section";
|
2019-05-21 13:40:24 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
const sizeOptions = ["base", "middle", "big", "huge", "large"];
|
2019-05-21 13:40:24 +00:00
|
|
|
|
2020-10-16 13:16:01 +00:00
|
|
|
storiesOf("Components|Input", module)
|
2019-05-21 13:40:24 +00:00
|
|
|
.addDecorator(withKnobs)
|
|
|
|
.addDecorator(withReadme(Readme))
|
2020-10-16 13:16:01 +00:00
|
|
|
.add("text", () => (
|
2019-06-27 14:54:01 +00:00
|
|
|
<StringValue
|
2020-10-16 13:16:01 +00:00
|
|
|
onChange={(e) => {
|
|
|
|
action("onChange")(e);
|
|
|
|
}}
|
2019-06-27 14:54:01 +00:00
|
|
|
>
|
|
|
|
{({ value, set }) => (
|
|
|
|
<Section>
|
2019-05-24 13:17:36 +00:00
|
|
|
<TextInput
|
2020-10-16 13:16:01 +00:00
|
|
|
id={text("id", "")}
|
|
|
|
name={text("name", "")}
|
|
|
|
placeholder={text("placeholder", "This is placeholder")}
|
|
|
|
maxLength={number("maxLength", 255)}
|
|
|
|
size={select("size", sizeOptions, "base")}
|
|
|
|
onBlur={action("onBlur")}
|
|
|
|
onFocus={action("onFocus")}
|
|
|
|
isAutoFocussed={boolean("isAutoFocussed", false)}
|
|
|
|
isDisabled={boolean("isDisabled", false)}
|
|
|
|
isReadOnly={boolean("isReadOnly", false)}
|
|
|
|
hasError={boolean("hasError", false)}
|
|
|
|
hasWarning={boolean("hasWarning", false)}
|
|
|
|
scale={boolean("scale", false)}
|
|
|
|
autoComplete={text("autoComplete", "off")}
|
|
|
|
tabIndex={number("tabIndex", 1)}
|
|
|
|
withBorder={boolean("withBorder", true)}
|
2019-09-06 08:54:19 +00:00
|
|
|
mask={text("mask", null)}
|
2019-06-27 14:54:01 +00:00
|
|
|
value={value}
|
2020-10-16 13:16:01 +00:00
|
|
|
onChange={(e) => {
|
2019-06-27 14:54:01 +00:00
|
|
|
set(e.target.value);
|
|
|
|
}}
|
2019-05-24 13:17:36 +00:00
|
|
|
/>
|
2019-06-27 14:54:01 +00:00
|
|
|
</Section>
|
|
|
|
)}
|
|
|
|
</StringValue>
|
2019-05-21 13:40:24 +00:00
|
|
|
));
|