diff options
Diffstat (limited to 'packages/forms/src')
-rw-r--r-- | packages/forms/src/input/index.tsx | 2 | ||||
-rw-r--r-- | packages/forms/src/label/index.tsx | 4 | ||||
-rw-r--r-- | packages/forms/src/select/index.tsx | 2 | ||||
-rw-r--r-- | packages/forms/src/typings/generic.ts | 1 |
4 files changed, 8 insertions, 1 deletions
diff --git a/packages/forms/src/input/index.tsx b/packages/forms/src/input/index.tsx index ab1c33315..5178904d3 100644 --- a/packages/forms/src/input/index.tsx +++ b/packages/forms/src/input/index.tsx | |||
@@ -105,6 +105,7 @@ class InputComponent extends Component<IProps, IState> { | |||
105 | min, | 105 | min, |
106 | max, | 106 | max, |
107 | step, | 107 | step, |
108 | required, | ||
108 | } = this.props; | 109 | } = this.props; |
109 | 110 | ||
110 | const { | 111 | const { |
@@ -123,6 +124,7 @@ class InputComponent extends Component<IProps, IState> { | |||
123 | title={label} | 124 | title={label} |
124 | showLabel={showLabel} | 125 | showLabel={showLabel} |
125 | htmlFor={id} | 126 | htmlFor={id} |
127 | isRequired={required} | ||
126 | > | 128 | > |
127 | <div | 129 | <div |
128 | className={classnames({ | 130 | className={classnames({ |
diff --git a/packages/forms/src/label/index.tsx b/packages/forms/src/label/index.tsx index 590270a06..1b33ba22c 100644 --- a/packages/forms/src/label/index.tsx +++ b/packages/forms/src/label/index.tsx | |||
@@ -9,6 +9,7 @@ import styles from './styles'; | |||
9 | 9 | ||
10 | interface ILabel extends IFormField, React.LabelHTMLAttributes<HTMLLabelElement> { | 10 | interface ILabel extends IFormField, React.LabelHTMLAttributes<HTMLLabelElement> { |
11 | classes: Classes; | 11 | classes: Classes; |
12 | isRequired: boolean; | ||
12 | } | 13 | } |
13 | 14 | ||
14 | class LabelComponent extends Component<ILabel> { | 15 | class LabelComponent extends Component<ILabel> { |
@@ -24,6 +25,7 @@ class LabelComponent extends Component<ILabel> { | |||
24 | className, | 25 | className, |
25 | children, | 26 | children, |
26 | htmlFor, | 27 | htmlFor, |
28 | isRequired, | ||
27 | } = this.props; | 29 | } = this.props; |
28 | 30 | ||
29 | if (!showLabel) return children; | 31 | if (!showLabel) return children; |
@@ -36,7 +38,7 @@ class LabelComponent extends Component<ILabel> { | |||
36 | htmlFor={htmlFor} | 38 | htmlFor={htmlFor} |
37 | > | 39 | > |
38 | {showLabel && ( | 40 | {showLabel && ( |
39 | <span className={classes.label}>{title}</span> | 41 | <span className={classes.label}>{title}{isRequired && ' *'}</span> |
40 | )} | 42 | )} |
41 | <div className={classes.content}> | 43 | <div className={classes.content}> |
42 | {children} | 44 | {children} |
diff --git a/packages/forms/src/select/index.tsx b/packages/forms/src/select/index.tsx index 4a9e3c56e..f419d0351 100644 --- a/packages/forms/src/select/index.tsx +++ b/packages/forms/src/select/index.tsx | |||
@@ -306,6 +306,7 @@ class SelectComponent extends Component<IProps> { | |||
306 | showLabel, | 306 | showLabel, |
307 | showSearch, | 307 | showSearch, |
308 | onChange, | 308 | onChange, |
309 | required, | ||
309 | } = this.props; | 310 | } = this.props; |
310 | 311 | ||
311 | const { | 312 | const { |
@@ -334,6 +335,7 @@ class SelectComponent extends Component<IProps> { | |||
334 | title={label} | 335 | title={label} |
335 | showLabel={showLabel} | 336 | showLabel={showLabel} |
336 | htmlFor={id} | 337 | htmlFor={id} |
338 | isRequired={required} | ||
337 | > | 339 | > |
338 | <div | 340 | <div |
339 | className={classnames({ | 341 | className={classnames({ |
diff --git a/packages/forms/src/typings/generic.ts b/packages/forms/src/typings/generic.ts index b7f2fc452..9688ce2c7 100644 --- a/packages/forms/src/typings/generic.ts +++ b/packages/forms/src/typings/generic.ts | |||
@@ -5,6 +5,7 @@ export interface IFormField { | |||
5 | showLabel?: boolean; | 5 | showLabel?: boolean; |
6 | label?: string; | 6 | label?: string; |
7 | error?: string; | 7 | error?: string; |
8 | required?: boolean; | ||
8 | } | 9 | } |
9 | 10 | ||
10 | export interface IWithStyle { | 11 | export interface IWithStyle { |