-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathTextInput.js
More file actions
210 lines (205 loc) · 5.89 KB
/
Copy pathTextInput.js
File metadata and controls
210 lines (205 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import { linkTo } from "@storybook/addon-links";
import { Field } from "redux-form";
import {
withKnobs,
text,
boolean,
select,
array,
number,
object
} from "@storybook/addon-knobs";
import Center from "./Center";
import Redux from "./Redux";
import ReduxForm from "./ReduxForm";
import Locale from "./Locale";
import {
TextField,
TextAreaField,
NumberField,
SliderField,
SwitchField,
CheckboxGroupField,
RadioField,
SelectField
} from "../src/index";
import {
DatePickerField,
TimePickerField,
MonthPickerField
} from "../src/components/DatePicker";
const sizeOptions = {
large: "large",
default: "default",
small: "small"
};
const options = [
{ label: "Apple", value: "Apple" },
{ label: "Pear", value: "Pear" },
{ label: "Orange", value: "Orange" }
];
const modes = ["default", "combobox", "multiple", "tags"];
const commonProps = {
name: "kek2",
warn: v => (v && v.length > 2 ? "" : "too short"),
validate: v => (v ? "" : "Required")
};
storiesOf("TextField", module)
.addDecorator(Redux)
.addDecorator(withKnobs)
.addDecorator(Center)
.addDecorator(Locale)
.add("TextField", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
{...commonProps}
label={text("Label", "Your textfield label")}
placeholder={text("Placeholder", "placeholder")}
component={TextField}
type={text("type", "text")}
size={select("size", sizeOptions, "default")}
labelCol={object("labelCol", { span: 24, offset: 0 })}
wrapperCol={object("wrapperCol", { span: 24, offset: 0 })}
addonBefore={text("addonBefore", "")}
addonAfter={text("addonAfter", "")}
prefix={text("prefix", "")}
suffix={text("suffix", "")}
autosize={object("autosize", { minRows: 2, maxRows: 6 })}
colon={boolean("colon", true)}
required
/>
</div>
</ReduxForm>
))
.add("TextAreaField", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
{...commonProps}
label={text("Label", "Your textareafield label")}
placeholder={text("Placeholder", "placeholder")}
component={TextAreaField}
labelCol={object("labelCol", { span: 24, offset: 0 })}
wrapperCol={object("wrapperCol", { span: 24, offset: 0 })}
autosize={object("autosize", { minRows: 2, maxRows: 6 })}
/>
</div>
</ReduxForm>
))
.add("Number Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
{...commonProps}
component={NumberField}
label={text("Label", "label")}
placeholder={text("Placeholder", "placeholder")}
labelCol={object("labelCol", { span: 24, offset: 0 })}
wrapperCol={object("wrapperCol", { span: 24, offset: 0 })}
/>
</div>
</ReduxForm>
))
.add("Slide Field", () => (
<ReduxForm>
<div style={{ height: 300, width: 300 }}>
<Field
{...commonProps}
component={SliderField}
range={boolean("range", true)}
min={number("min", 0)}
max={number("max", 100)}
step={number("step", 1)}
dots={boolean("dots", false)}
vertical={boolean("vertical", false)}
label={text("Label", "label")}
labelCol={object("labelCol", { span: 24, offset: 0 })}
wrapperCol={object("wrapperCol", { span: 24, offset: 0 })}
/>
</div>
</ReduxForm>
))
.add("Switch Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
name={"kek"}
label={text("Label", "label")}
component={SwitchField}
type={text("type", "text")}
checkedChildren={text("checkedChildren", "+")}
uncheckedChildren={text("uncheckedChildren", "??")}
labelCol={object("labelCol", { span: 24, offset: 0 })}
wrapperCol={object("wrapperCol", { span: 24, offset: 0 })}
size={select("size", sizeOptions, "default")}
/>
</div>
</ReduxForm>
))
.add("Radio Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
name={"kek"}
label={text("Label", "label")}
component={RadioField}
options={object("options", options)}
/>
</div>
</ReduxForm>
))
.add("Select Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
name={"kek"}
label={text("Label", "label")}
component={SelectField}
options={object("options", options)}
mode={select("mode", modes)}
allowClear={boolean("allowClear", false)}
notFoundContent={text("notFoundContent", "not found")}
placeholder={text("placeholder", "nothing selected")}
tokenSeparators={text("tokenSeparators", ",")}
/>
</div>
</ReduxForm>
))
.add("Checkbox Group Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
name={"kek"}
label={text("Label", "label")}
component={CheckboxGroupField}
options={object("options", options)}
/>
</div>
</ReduxForm>
))
.add("Picker Field", () => (
<ReduxForm>
<div style={{ width: 300 }}>
<Field
name={"kek"}
label={text("Label", "label")}
locale={"en"}
placeholder={text("placeholder", "pl")}
component={DatePickerField}
size={select("size", sizeOptions)}
/>
<br />
<Field
name={"kek2"}
label={text("Label", "label")}
placeholder={text("placeholder", "pl")}
component={MonthPickerField}
size={select("size", sizeOptions)}
/>
</div>
</ReduxForm>
));