aboutsummaryrefslogtreecommitdiffstats
path: root/packages/forms
diff options
context:
space:
mode:
Diffstat (limited to 'packages/forms')
-rw-r--r--packages/forms/src/button/index.tsx29
-rw-r--r--packages/forms/src/error/index.tsx13
-rw-r--r--packages/forms/src/input/index.tsx63
-rw-r--r--packages/forms/src/input/scorePassword.ts6
-rw-r--r--packages/forms/src/label/index.tsx13
-rw-r--r--packages/forms/src/select/index.tsx119
-rw-r--r--packages/forms/src/textarea/index.tsx22
-rw-r--r--packages/forms/src/toggle/index.tsx2
-rw-r--r--packages/forms/src/wrapper/index.tsx9
-rw-r--r--packages/forms/tslint.json3
10 files changed, 142 insertions, 137 deletions
diff --git a/packages/forms/src/button/index.tsx b/packages/forms/src/button/index.tsx
index ecb2876ca..c08c4e97d 100644
--- a/packages/forms/src/button/index.tsx
+++ b/packages/forms/src/button/index.tsx
@@ -8,14 +8,24 @@ import Loader from 'react-loader';
8import { IFormField, IWithStyle } from '../typings/generic'; 8import { IFormField, IWithStyle } from '../typings/generic';
9import { Theme } from '../../../theme'; 9import { Theme } from '../../../theme';
10 10
11type ButtonType = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'inverted'; 11type ButtonType =
12 | 'primary'
13 | 'secondary'
14 | 'success'
15 | 'danger'
16 | 'warning'
17 | 'inverted';
12 18
13interface IProps extends IFormField, IWithStyle { 19interface IProps extends IFormField, IWithStyle {
14 className?: string; 20 className?: string;
15 disabled?: boolean; 21 disabled?: boolean;
16 id?: string; 22 id?: string;
17 type?: 'button' | 'reset' | 'submit' | undefined; 23 type?: 'button' | 'reset' | 'submit' | undefined;
18 onClick: (event: React.MouseEvent<HTMLButtonElement> | React.MouseEvent<HTMLAnchorElement>) => void; 24 onClick: (
25 event:
26 | React.MouseEvent<HTMLButtonElement>
27 | React.MouseEvent<HTMLAnchorElement>,
28 ) => void;
19 buttonType?: ButtonType; 29 buttonType?: ButtonType;
20 stretch?: boolean; 30 stretch?: boolean;
21 loaded?: boolean; 31 loaded?: boolean;
@@ -25,10 +35,6 @@ interface IProps extends IFormField, IWithStyle {
25 target?: string; 35 target?: string;
26} 36}
27 37
28interface IState {
29 busy: boolean;
30}
31
32const styles = (theme: Theme) => ({ 38const styles = (theme: Theme) => ({
33 button: { 39 button: {
34 borderRadius: theme.borderRadiusSmall, 40 borderRadius: theme.borderRadiusSmall,
@@ -40,7 +46,8 @@ const styles = (theme: Theme) => ({
40 outline: 'none', 46 outline: 'none',
41 alignItems: 'center', 47 alignItems: 'center',
42 padding: 0, 48 padding: 0,
43 width: (props: IProps) => (props.stretch ? '100%' : 'auto') as Property.Width<string>, 49 width: (props: IProps) =>
50 (props.stretch ? '100%' : 'auto') as Property.Width<string>,
44 fontSize: theme.uiFontSize, 51 fontSize: theme.uiFontSize,
45 textDecoration: 'none', 52 textDecoration: 'none',
46 // height: theme.buttonHeight, 53 // height: theme.buttonHeight,
@@ -125,7 +132,8 @@ const styles = (theme: Theme) => ({
125 transition: 'all 0.3s', 132 transition: 'all 0.3s',
126 marginLeft: (props: IProps): number => (!props.busy ? 10 : 20), 133 marginLeft: (props: IProps): number => (!props.busy ? 10 : 20),
127 marginRight: (props: IProps): number => (!props.busy ? -10 : -20), 134 marginRight: (props: IProps): number => (!props.busy ? -10 : -20),
128 position: (props: IProps): Property.Position => props.stretch ? 'absolute' : 'inherit', 135 position: (props: IProps): Property.Position =>
136 props.stretch ? 'absolute' : 'inherit',
129 }, 137 },
130 icon: { 138 icon: {
131 margin: [1, 10, 0, -5], 139 margin: [1, 10, 0, -5],
@@ -175,7 +183,6 @@ class ButtonComponent extends Component<IProps> {
175 buttonType, 183 buttonType,
176 loaded, 184 loaded,
177 icon, 185 icon,
178 busy: busyProp,
179 href, 186 href,
180 target, 187 target,
181 } = this.props; 188 } = this.props;
@@ -185,7 +192,9 @@ class ButtonComponent extends Component<IProps> {
185 let showLoader = false; 192 let showLoader = false;
186 if (loaded) { 193 if (loaded) {
187 showLoader = !loaded; 194 showLoader = !loaded;
188 console.warn('Ferdi Button prop `loaded` will be deprecated in the future. Please use `busy` instead'); 195 console.warn(
196 'Ferdi Button prop `loaded` will be deprecated in the future. Please use `busy` instead',
197 );
189 } 198 }
190 if (busy) { 199 if (busy) {
191 showLoader = busy; 200 showLoader = busy;
diff --git a/packages/forms/src/error/index.tsx b/packages/forms/src/error/index.tsx
index a487bb281..243321d97 100644
--- a/packages/forms/src/error/index.tsx
+++ b/packages/forms/src/error/index.tsx
@@ -11,18 +11,9 @@ interface IProps {
11 11
12class ErrorComponent extends Component<IProps> { 12class ErrorComponent extends Component<IProps> {
13 render() { 13 render() {
14 const { 14 const { classes, message } = this.props;
15 classes,
16 message,
17 } = this.props;
18 15
19 return ( 16 return <p className={classes.message}>{message}</p>;
20 <p
21 className={classes.message}
22 >
23 {message}
24 </p>
25 );
26 } 17 }
27} 18}
28 19
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx
index b96dbc12d..41751710a 100644
--- a/packages/forms/src/input/index.tsx
+++ b/packages/forms/src/input/index.tsx
@@ -17,7 +17,10 @@ interface IData {
17 [index: string]: string; 17 [index: string]: string;
18} 18}
19 19
20interface IProps extends React.InputHTMLAttributes<HTMLInputElement>, IFormField, IWithStyle { 20interface IProps
21 extends React.InputHTMLAttributes<HTMLInputElement>,
22 IFormField,
23 IWithStyle {
21 focus?: boolean; 24 focus?: boolean;
22 prefix?: string; 25 prefix?: string;
23 suffix?: string; 26 suffix?: string;
@@ -62,23 +65,24 @@ class InputComponent extends Component<IProps, IState> {
62 } 65 }
63 66
64 if (data) { 67 if (data) {
65 Object.keys(data).map(key => this.inputRef.current!.dataset[key] = data[key]); 68 Object.keys(data).map(
69 key => (this.inputRef.current!.dataset[key] = data[key]),
70 );
66 } 71 }
67 } 72 }
68 } 73 }
69 74
70 onChange(e: React.ChangeEvent<HTMLInputElement>) { 75 onChange(e: React.ChangeEvent<HTMLInputElement>) {
71 const { 76 const { scorePassword, onChange } = this.props;
72 scorePassword,
73 onChange,
74 } = this.props;
75 77
76 if (onChange) { 78 if (onChange) {
77 onChange(e); 79 onChange(e);
78 } 80 }
79 81
80 if (this.inputRef && this.inputRef.current && scorePassword) { 82 if (this.inputRef && this.inputRef.current && scorePassword) {
81 this.setState({ passwordScore: scorePasswordFunc(this.inputRef.current.value) }); 83 this.setState({
84 passwordScore: scorePasswordFunc(this.inputRef.current.value),
85 });
82 } 86 }
83 } 87 }
84 88
@@ -117,10 +121,7 @@ class InputComponent extends Component<IProps, IState> {
117 noMargin, 121 noMargin,
118 } = this.props; 122 } = this.props;
119 123
120 const { 124 const { showPassword, passwordScore } = this.state;
121 showPassword,
122 passwordScore,
123 } = this.state;
124 125
125 const inputType = type === 'password' && showPassword ? 'text' : type; 126 const inputType = type === 'password' && showPassword ? 'text' : type;
126 127
@@ -144,12 +145,9 @@ class InputComponent extends Component<IProps, IState> {
144 [`${classes.wrapper}`]: true, 145 [`${classes.wrapper}`]: true,
145 [`${classes.disabled}`]: disabled, 146 [`${classes.disabled}`]: disabled,
146 [`${classes.hasError}`]: error, 147 [`${classes.hasError}`]: error,
147 })}> 148 })}
148 {prefix && ( 149 >
149 <span className={classes.prefix}> 150 {prefix && <span className={classes.prefix}>{prefix}</span>}
150 {prefix}
151 </span>
152 )}
153 <input 151 <input
154 id={id} 152 id={id}
155 type={inputType} 153 type={inputType}
@@ -168,30 +166,29 @@ class InputComponent extends Component<IProps, IState> {
168 max={max} 166 max={max}
169 step={step} 167 step={step}
170 /> 168 />
171 {suffix && ( 169 {suffix && <span className={classes.suffix}>{suffix}</span>}
172 <span className={classes.suffix}>
173 {suffix}
174 </span>
175 )}
176 {showPasswordToggle && ( 170 {showPasswordToggle && (
177 <button 171 <button
178 type="button" 172 type="button"
179 className={classes.formModifier} 173 className={classes.formModifier}
180 onClick={() => this.setState(prevState => ({ showPassword: !prevState.showPassword }))} 174 onClick={() =>
175 this.setState(prevState => ({
176 showPassword: !prevState.showPassword,
177 }))
178 }
181 tabIndex={-1} 179 tabIndex={-1}
182 > 180 >
183 <Icon 181 <Icon path={!showPassword ? mdiEye : mdiEyeOff} size={1} />
184 path={!showPassword ? mdiEye : mdiEyeOff}
185 size={1}
186 />
187 </button> 182 </button>
188 )} 183 )}
189 </div> 184 </div>
190 {scorePassword && ( 185 {scorePassword && (
191 <div className={classnames({ 186 <div
192 [`${classes.passwordScore}`]: true, 187 className={classnames({
193 [`${classes.hasError}`]: error, 188 [`${classes.passwordScore}`]: true,
194 })}> 189 [`${classes.hasError}`]: error,
190 })}
191 >
195 <meter 192 <meter
196 value={passwordScore < 5 ? 5 : passwordScore} 193 value={passwordScore < 5 ? 5 : passwordScore}
197 low={30} 194 low={30}
@@ -202,9 +199,7 @@ class InputComponent extends Component<IProps, IState> {
202 </div> 199 </div>
203 )} 200 )}
204 </Label> 201 </Label>
205 {error && ( 202 {error && <Error message={error} />}
206 <Error message={error} />
207 )}
208 </Wrapper> 203 </Wrapper>
209 ); 204 );
210 } 205 }
diff --git a/packages/forms/src/input/scorePassword.ts b/packages/forms/src/input/scorePassword.ts
index 0b7719ec1..bc30de4b8 100644
--- a/packages/forms/src/input/scorePassword.ts
+++ b/packages/forms/src/input/scorePassword.ts
@@ -11,7 +11,7 @@ interface IVariations {
11} 11}
12 12
13export function scorePasswordFunc(password: string): number { 13export function scorePasswordFunc(password: string): number {
14 let score: number = 0; 14 let score = 0;
15 if (!password) { 15 if (!password) {
16 return score; 16 return score;
17 } 17 }
@@ -32,8 +32,8 @@ export function scorePasswordFunc(password: string): number {
32 }; 32 };
33 33
34 let variationCount = 0; 34 let variationCount = 0;
35 Object.keys(variations).forEach((key) => { 35 Object.keys(variations).forEach(key => {
36 variationCount += (variations[key] === true) ? 1 : 0; 36 variationCount += variations[key] === true ? 1 : 0;
37 }); 37 });
38 38
39 score += (variationCount - 1) * 10; 39 score += (variationCount - 1) * 10;
diff --git a/packages/forms/src/label/index.tsx b/packages/forms/src/label/index.tsx
index 1b33ba22c..ad503b785 100644
--- a/packages/forms/src/label/index.tsx
+++ b/packages/forms/src/label/index.tsx
@@ -7,7 +7,9 @@ import { IFormField } from '../typings/generic';
7 7
8import styles from './styles'; 8import styles from './styles';
9 9
10interface ILabel extends IFormField, React.LabelHTMLAttributes<HTMLLabelElement> { 10interface ILabel
11 extends IFormField,
12 React.LabelHTMLAttributes<HTMLLabelElement> {
11 classes: Classes; 13 classes: Classes;
12 isRequired: boolean; 14 isRequired: boolean;
13} 15}
@@ -38,11 +40,12 @@ class LabelComponent extends Component<ILabel> {
38 htmlFor={htmlFor} 40 htmlFor={htmlFor}
39 > 41 >
40 {showLabel && ( 42 {showLabel && (
41 <span className={classes.label}>{title}{isRequired && ' *'}</span> 43 <span className={classes.label}>
44 {title}
45 {isRequired && ' *'}
46 </span>
42 )} 47 )}
43 <div className={classes.content}> 48 <div className={classes.content}>{children}</div>
44 {children}
45 </div>
46 </label> 49 </label>
47 ); 50 );
48 } 51 }
diff --git a/packages/forms/src/select/index.tsx b/packages/forms/src/select/index.tsx
index e5b59cb19..4a5775579 100644
--- a/packages/forms/src/select/index.tsx
+++ b/packages/forms/src/select/index.tsx
@@ -1,4 +1,8 @@
1import { mdiArrowRightDropCircleOutline, mdiCloseCircle, mdiMagnify } from '@mdi/js'; 1import {
2 mdiArrowRightDropCircleOutline,
3 mdiCloseCircle,
4 mdiMagnify,
5} from '@mdi/js';
2import Icon from '@mdi/react'; 6import Icon from '@mdi/react';
3import classnames from 'classnames'; 7import classnames from 'classnames';
4import React, { Component, createRef } from 'react'; 8import React, { Component, createRef } from 'react';
@@ -58,7 +62,7 @@ const styles = (theme: Theme) => ({
58 label: { 62 label: {
59 '& > div': { 63 '& > div': {
60 marginTop: 5, 64 marginTop: 5,
61 } 65 },
62 }, 66 },
63 popup: { 67 popup: {
64 opacity: 0, 68 opacity: 0,
@@ -153,9 +157,13 @@ class SelectComponent extends Component<IProps> {
153 }; 157 };
154 158
155 private componentRef = createRef<HTMLDivElement>(); 159 private componentRef = createRef<HTMLDivElement>();
160
156 private inputRef = createRef<HTMLInputElement>(); 161 private inputRef = createRef<HTMLInputElement>();
162
157 private searchInputRef = createRef<HTMLInputElement>(); 163 private searchInputRef = createRef<HTMLInputElement>();
164
158 private scrollContainerRef = createRef<HTMLDivElement>(); 165 private scrollContainerRef = createRef<HTMLDivElement>();
166
159 private activeOptionRef = createRef<HTMLDivElement>(); 167 private activeOptionRef = createRef<HTMLDivElement>();
160 168
161 private keyListener: any; 169 private keyListener: any;
@@ -168,7 +176,7 @@ class SelectComponent extends Component<IProps> {
168 } 176 }
169 } 177 }
170 178
171 componentDidUpdate(prevProps: IProps, prevState: IState) { 179 componentDidUpdate() {
172 const { open } = this.state; 180 const { open } = this.state;
173 181
174 if (this.searchInputRef && this.searchInputRef.current) { 182 if (this.searchInputRef && this.searchInputRef.current) {
@@ -183,7 +191,9 @@ class SelectComponent extends Component<IProps> {
183 const { data } = this.props; 191 const { data } = this.props;
184 192
185 if (data) { 193 if (data) {
186 Object.keys(data).map(key => this.inputRef.current!.dataset[key] = data[key]); 194 Object.keys(data).map(
195 key => (this.inputRef.current!.dataset[key] = data[key]),
196 );
187 } 197 }
188 } 198 }
189 199
@@ -194,7 +204,10 @@ class SelectComponent extends Component<IProps> {
194 const { value } = this.props; 204 const { value } = this.props;
195 205
196 if (this.componentRef && this.componentRef.current) { 206 if (this.componentRef && this.componentRef.current) {
197 this.componentRef.current.removeEventListener('keydown', this.keyListener); 207 this.componentRef.current.removeEventListener(
208 'keydown',
209 this.keyListener,
210 );
198 } 211 }
199 212
200 if (value) { 213 if (value) {
@@ -210,13 +223,18 @@ class SelectComponent extends Component<IProps> {
210 window.removeEventListener('keydown', this.arrowKeysHandler.bind(this)); 223 window.removeEventListener('keydown', this.arrowKeysHandler.bind(this));
211 } 224 }
212 225
213 setFilter(needle: string = '') { 226 setFilter(needle = '') {
214 const { options } = this.props; 227 const { options } = this.props;
215 228
216 let filteredOptions = {}; 229 let filteredOptions = {};
217 if (needle) { 230 if (needle) {
218 Object.keys(options).map((key) => { 231 Object.keys(options).map(key => {
219 if (key.toLocaleLowerCase().startsWith(needle.toLocaleLowerCase()) || options[key].toLocaleLowerCase().startsWith(needle.toLocaleLowerCase())) { 232 if (
233 key.toLocaleLowerCase().startsWith(needle.toLocaleLowerCase()) ||
234 options[key]
235 .toLocaleLowerCase()
236 .startsWith(needle.toLocaleLowerCase())
237 ) {
220 Object.assign(filteredOptions, { 238 Object.assign(filteredOptions, {
221 [`${key}`]: options[key], 239 [`${key}`]: options[key],
222 }); 240 });
@@ -234,7 +252,7 @@ class SelectComponent extends Component<IProps> {
234 } 252 }
235 253
236 select(key: string) { 254 select(key: string) {
237 this.setState((state: IState) => ({ 255 this.setState(() => ({
238 value: key, 256 value: key,
239 open: false, 257 open: false,
240 })); 258 }));
@@ -247,11 +265,7 @@ class SelectComponent extends Component<IProps> {
247 } 265 }
248 266
249 arrowKeysHandler(e: KeyboardEvent) { 267 arrowKeysHandler(e: KeyboardEvent) {
250 const { 268 const { selected, open, options } = this.state;
251 selected,
252 open,
253 options,
254 } = this.state;
255 269
256 if (!open) return; 270 if (!open) return;
257 271
@@ -264,7 +278,10 @@ class SelectComponent extends Component<IProps> {
264 this.setState((state: IState) => ({ 278 this.setState((state: IState) => ({
265 selected: state.selected - 1, 279 selected: state.selected - 1,
266 })); 280 }));
267 } else if (e.keyCode === 40 && selected < Object.keys(options!).length - 1) { 281 } else if (
282 e.keyCode === 40 &&
283 selected < Object.keys(options!).length - 1
284 ) {
268 this.setState((state: IState) => ({ 285 this.setState((state: IState) => ({
269 selected: state.selected + 1, 286 selected: state.selected + 1,
270 })); 287 }));
@@ -272,7 +289,12 @@ class SelectComponent extends Component<IProps> {
272 this.select(Object.keys(options!)[selected]); 289 this.select(Object.keys(options!)[selected]);
273 } 290 }
274 291
275 if (this.activeOptionRef && this.activeOptionRef.current && this.scrollContainerRef && this.scrollContainerRef.current) { 292 if (
293 this.activeOptionRef &&
294 this.activeOptionRef.current &&
295 this.scrollContainerRef &&
296 this.scrollContainerRef.current
297 ) {
276 const containerTopOffset = this.scrollContainerRef.current.offsetTop; 298 const containerTopOffset = this.scrollContainerRef.current.offsetTop;
277 const optionTopOffset = this.activeOptionRef.current.offsetTop; 299 const optionTopOffset = this.activeOptionRef.current.offsetTop;
278 300
@@ -282,10 +304,15 @@ class SelectComponent extends Component<IProps> {
282 } 304 }
283 } 305 }
284 306
285 switch (e.keyCode){ 307 switch (e.keyCode) {
286 case 37: case 39: case 38: case 40: // Arrow keys 308 case 37:
287 case 32: break; // Space 309 case 39:
288 default: break; // do not block other keys 310 case 38:
311 case 40: // Arrow keys
312 case 32:
313 break; // Space
314 default:
315 break; // do not block other keys
289 } 316 }
290 } 317 }
291 318
@@ -307,13 +334,7 @@ class SelectComponent extends Component<IProps> {
307 required, 334 required,
308 } = this.props; 335 } = this.props;
309 336
310 const { 337 const { open, needle, value, selected, options } = this.state;
311 open,
312 needle,
313 value,
314 selected,
315 options,
316 } = this.state;
317 338
318 let selection = ''; 339 let selection = '';
319 if (!value && defaultValue && options![defaultValue]) { 340 if (!value && defaultValue && options![defaultValue]) {
@@ -325,10 +346,7 @@ class SelectComponent extends Component<IProps> {
325 } 346 }
326 347
327 return ( 348 return (
328 <Wrapper 349 <Wrapper className={className} identifier="franz-select">
329 className={className}
330 identifier="franz-select"
331 >
332 <Label 350 <Label
333 title={label} 351 title={label}
334 showLabel={showLabel} 352 showLabel={showLabel}
@@ -345,14 +363,19 @@ class SelectComponent extends Component<IProps> {
345 > 363 >
346 <button 364 <button
347 type="button" 365 type="button"
348 className={classnames({ 366 className={classnames({
349 [`${inputClassName}`]: inputClassName, 367 [`${inputClassName}`]: inputClassName,
350 [`${classes.select}`]: true, 368 [`${classes.select}`]: true,
351 [`${classes.hasError}`]: error, 369 [`${classes.hasError}`]: error,
352 })} 370 })}
353 onClick= {!disabled ? () => this.setState((state: IState) => ({ 371 onClick={
354 open: !state.open, 372 !disabled
355 })) : () => {}} 373 ? () =>
374 this.setState((state: IState) => ({
375 open: !state.open,
376 }))
377 : () => {}
378 }
356 > 379 >
357 {selection} 380 {selection}
358 <Icon 381 <Icon
@@ -366,10 +389,7 @@ class SelectComponent extends Component<IProps> {
366 </button> 389 </button>
367 {showSearch && open && ( 390 {showSearch && open && (
368 <div className={classes.searchContainer}> 391 <div className={classes.searchContainer}>
369 <Icon 392 <Icon path={mdiMagnify} size={0.8} />
370 path={mdiMagnify}
371 size={0.8}
372 />
373 <input 393 <input
374 type="text" 394 type="text"
375 value={needle} 395 value={needle}
@@ -384,10 +404,7 @@ class SelectComponent extends Component<IProps> {
384 className={classes.clearNeedle} 404 className={classes.clearNeedle}
385 onClick={() => this.setFilter()} 405 onClick={() => this.setFilter()}
386 > 406 >
387 <Icon 407 <Icon path={mdiCloseCircle} size={0.7} />
388 path={mdiCloseCircle}
389 size={0.7}
390 />
391 </button> 408 </button>
392 )} 409 )}
393 </div> 410 </div>
@@ -399,7 +416,7 @@ class SelectComponent extends Component<IProps> {
399 })} 416 })}
400 ref={this.scrollContainerRef} 417 ref={this.scrollContainerRef}
401 > 418 >
402 {Object.keys(options!).map(((key, i) => ( 419 {Object.keys(options!).map((key, i) => (
403 <div 420 <div
404 key={key} 421 key={key}
405 onClick={() => this.select(key)} 422 onClick={() => this.select(key)}
@@ -413,7 +430,7 @@ class SelectComponent extends Component<IProps> {
413 > 430 >
414 {options![key]} 431 {options![key]}
415 </div> 432 </div>
416 )))} 433 ))}
417 </div> 434 </div>
418 </div> 435 </div>
419 <input 436 <input
@@ -427,9 +444,7 @@ class SelectComponent extends Component<IProps> {
427 ref={this.inputRef} 444 ref={this.inputRef}
428 /> 445 />
429 </Label> 446 </Label>
430 {error && ( 447 {error && <Error message={error} />}
431 <Error message={error} />
432 )}
433 </Wrapper> 448 </Wrapper>
434 ); 449 );
435 } 450 }
diff --git a/packages/forms/src/textarea/index.tsx b/packages/forms/src/textarea/index.tsx
index 31c572d1c..2d89d1c9f 100644
--- a/packages/forms/src/textarea/index.tsx
+++ b/packages/forms/src/textarea/index.tsx
@@ -14,7 +14,10 @@ interface IData {
14 [index: string]: string; 14 [index: string]: string;
15} 15}
16 16
17interface IProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement>, IFormField, IWithStyle { 17interface IProps
18 extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
19 IFormField,
20 IWithStyle {
18 focus?: boolean; 21 focus?: boolean;
19 data: IData; 22 data: IData;
20 textareaClassName?: string; 23 textareaClassName?: string;
@@ -37,14 +40,14 @@ class TextareaComponent extends Component<IProps> {
37 const { data } = this.props; 40 const { data } = this.props;
38 41
39 if (this.textareaRef && this.textareaRef.current && data) { 42 if (this.textareaRef && this.textareaRef.current && data) {
40 Object.keys(data).map(key => this.textareaRef.current!.dataset[key] = data[key]); 43 Object.keys(data).map(
44 key => (this.textareaRef.current!.dataset[key] = data[key]),
45 );
41 } 46 }
42 } 47 }
43 48
44 onChange(e: React.ChangeEvent<HTMLTextAreaElement>) { 49 onChange(e: React.ChangeEvent<HTMLTextAreaElement>) {
45 const { 50 const { onChange } = this.props;
46 onChange,
47 } = this.props;
48 51
49 if (onChange) { 52 if (onChange) {
50 onChange(e); 53 onChange(e);
@@ -57,7 +60,6 @@ class TextareaComponent extends Component<IProps> {
57 className, 60 className,
58 disabled, 61 disabled,
59 error, 62 error,
60 focus,
61 id, 63 id,
62 textareaClassName, 64 textareaClassName,
63 label, 65 label,
@@ -94,9 +96,9 @@ class TextareaComponent extends Component<IProps> {
94 [`${classes.wrapper}`]: true, 96 [`${classes.wrapper}`]: true,
95 [`${classes.disabled}`]: disabled, 97 [`${classes.disabled}`]: disabled,
96 [`${classes.hasError}`]: error, 98 [`${classes.hasError}`]: error,
97 })}> 99 })}
100 >
98 <textarea 101 <textarea
99 autoFocus={focus}
100 id={id} 102 id={id}
101 name={name} 103 name={name}
102 placeholder={placeholder} 104 placeholder={placeholder}
@@ -115,9 +117,7 @@ class TextareaComponent extends Component<IProps> {
115 </textarea> 117 </textarea>
116 </div> 118 </div>
117 </Label> 119 </Label>
118 {error && ( 120 {error && <Error message={error} />}
119 <Error message={error} />
120 )}
121 </Wrapper> 121 </Wrapper>
122 ); 122 );
123 } 123 }
diff --git a/packages/forms/src/toggle/index.tsx b/packages/forms/src/toggle/index.tsx
index b146236df..a9970c8f1 100644
--- a/packages/forms/src/toggle/index.tsx
+++ b/packages/forms/src/toggle/index.tsx
@@ -3,7 +3,7 @@ import { Property } from 'csstype';
3import React, { Component } from 'react'; 3import React, { Component } from 'react';
4import injectStyle from 'react-jss'; 4import injectStyle from 'react-jss';
5 5
6import { IFormField, IWithStyle, Omit } from '../typings/generic'; 6import { IFormField, IWithStyle } from '../typings/generic';
7import { Theme } from '../../../theme'; 7import { Theme } from '../../../theme';
8 8
9import { Error } from '../error'; 9import { Error } from '../error';
diff --git a/packages/forms/src/wrapper/index.tsx b/packages/forms/src/wrapper/index.tsx
index cf179bc5e..3ae551e2c 100644
--- a/packages/forms/src/wrapper/index.tsx
+++ b/packages/forms/src/wrapper/index.tsx
@@ -12,18 +12,13 @@ interface IProps extends IWithStyle {
12 12
13const styles = { 13const styles = {
14 container: { 14 container: {
15 marginBottom: (props: IProps) => props.noMargin ? 0 : 20, 15 marginBottom: (props: IProps) => (props.noMargin ? 0 : 20),
16 }, 16 },
17}; 17};
18 18
19class WrapperComponent extends Component<IProps> { 19class WrapperComponent extends Component<IProps> {
20 render() { 20 render() {
21 const { 21 const { children, classes, className, identifier } = this.props;
22 children,
23 classes,
24 className,
25 identifier,
26 } = this.props;
27 22
28 return ( 23 return (
29 <div 24 <div
diff --git a/packages/forms/tslint.json b/packages/forms/tslint.json
deleted file mode 100644
index 0946f2096..000000000
--- a/packages/forms/tslint.json
+++ /dev/null
@@ -1,3 +0,0 @@
1{
2 "extends": "../../tslint.json"
3}