From 470e631d5657c9eb50ba0e13fadf3452e77ff499 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Fri, 5 Apr 2019 11:36:04 +0200 Subject: Add asterisk if input is required --- packages/forms/src/input/index.tsx | 2 ++ packages/forms/src/label/index.tsx | 4 +++- packages/forms/src/select/index.tsx | 2 ++ packages/forms/src/typings/generic.ts | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) 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 { min, max, step, + required, } = this.props; const { @@ -123,6 +124,7 @@ class InputComponent extends Component { title={label} showLabel={showLabel} htmlFor={id} + isRequired={required} >
{ classes: Classes; + isRequired: boolean; } class LabelComponent extends Component { @@ -24,6 +25,7 @@ class LabelComponent extends Component { className, children, htmlFor, + isRequired, } = this.props; if (!showLabel) return children; @@ -36,7 +38,7 @@ class LabelComponent extends Component { htmlFor={htmlFor} > {showLabel && ( - {title} + {title}{isRequired && ' *'} )}
{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 { showLabel, showSearch, onChange, + required, } = this.props; const { @@ -334,6 +335,7 @@ class SelectComponent extends Component { title={label} showLabel={showLabel} htmlFor={id} + isRequired={required} >