@dktunited-techoff/techoff-suite-ui 0.8.13 → 0.8.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/components/Checkbox/__stories__/Checkbox.stories.mdx +4 -1
- package/esm/components/Inputs/BooleanInput/BooleanInput.css +7 -0
- package/esm/components/Inputs/BooleanInput/BooleanInput.d.ts +1 -1
- package/esm/components/Inputs/BooleanInput/BooleanInput.js +4 -4
- package/esm/components/Inputs/BooleanInput/BooleanInput.js.map +1 -1
- package/esm/components/Inputs/BooleanInput/BooleanInput.tsx +4 -4
- package/esm/components/Inputs/BooleanInput/BooleanInput.types.d.ts +3 -2
- package/esm/components/Inputs/BooleanInput/BooleanInput.types.ts +3 -2
- package/esm/components/Inputs/BooleanInput/__stories__/BooleanInput.stories.mdx +10 -1
- package/esm/components/Inputs/TextInput/TextInput.css +16 -0
- package/esm/components/Inputs/TextInput/TextInput.d.ts +1 -1
- package/esm/components/Inputs/TextInput/TextInput.js +6 -5
- package/esm/components/Inputs/TextInput/TextInput.js.map +1 -1
- package/esm/components/Inputs/TextInput/TextInput.tsx +26 -4
- package/esm/components/Inputs/TextInput/TextInput.types.d.ts +4 -0
- package/esm/components/Inputs/TextInput/TextInput.types.ts +4 -0
- package/esm/components/Inputs/TextInput/__stories__/TextInput.stories.mdx +22 -1
- package/lib/components/Checkbox/__stories__/Checkbox.stories.mdx +4 -1
- package/lib/components/Inputs/BooleanInput/BooleanInput.css +7 -0
- package/lib/components/Inputs/BooleanInput/BooleanInput.d.ts +1 -1
- package/lib/components/Inputs/BooleanInput/BooleanInput.js +4 -4
- package/lib/components/Inputs/BooleanInput/BooleanInput.js.map +1 -1
- package/lib/components/Inputs/BooleanInput/BooleanInput.tsx +4 -4
- package/lib/components/Inputs/BooleanInput/BooleanInput.types.d.ts +3 -2
- package/lib/components/Inputs/BooleanInput/BooleanInput.types.ts +3 -2
- package/lib/components/Inputs/BooleanInput/__stories__/BooleanInput.stories.mdx +10 -1
- package/lib/components/Inputs/TextInput/TextInput.css +16 -0
- package/lib/components/Inputs/TextInput/TextInput.d.ts +1 -1
- package/lib/components/Inputs/TextInput/TextInput.js +6 -5
- package/lib/components/Inputs/TextInput/TextInput.js.map +1 -1
- package/lib/components/Inputs/TextInput/TextInput.tsx +26 -4
- package/lib/components/Inputs/TextInput/TextInput.types.d.ts +4 -0
- package/lib/components/Inputs/TextInput/TextInput.types.ts +4 -0
- package/lib/components/Inputs/TextInput/__stories__/TextInput.stories.mdx +22 -1
- package/package.json +1 -1
- package/src/components/Checkbox/__stories__/Checkbox.stories.mdx +4 -1
- package/src/components/Inputs/BooleanInput/BooleanInput.css +7 -0
- package/src/components/Inputs/BooleanInput/BooleanInput.tsx +4 -4
- package/src/components/Inputs/BooleanInput/BooleanInput.types.ts +3 -2
- package/src/components/Inputs/BooleanInput/__stories__/BooleanInput.stories.mdx +10 -1
- package/src/components/Inputs/TextInput/TextInput.css +16 -0
- package/src/components/Inputs/TextInput/TextInput.tsx +26 -4
- package/src/components/Inputs/TextInput/TextInput.types.ts +4 -0
- package/src/components/Inputs/TextInput/__stories__/TextInput.stories.mdx +22 -1
|
@@ -23,6 +23,10 @@ export const checkboxArgTypes = {
|
|
|
23
23
|
description: 'Enable state of the checkbox.',
|
|
24
24
|
table: { defaultValue: { summary: 'false' } },
|
|
25
25
|
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
# Checkbox
|
|
@@ -40,7 +44,6 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
40
44
|
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
41
45
|
checked: false,
|
|
42
46
|
disabled: false,
|
|
43
|
-
onChange: () => {},
|
|
44
47
|
}}
|
|
45
48
|
argTypes={checkboxArgTypes}
|
|
46
49
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BooleanInputProps } from './BooleanInput.types';
|
|
3
3
|
import './BooleanInput.css';
|
|
4
|
-
export declare const BooleanInput: ({ label, labelFalse, labelTrue, value, onChange }: BooleanInputProps) => React.JSX.Element;
|
|
4
|
+
export declare const BooleanInput: ({ label, labelFalse, labelTrue, disabled, value, onChange }: BooleanInputProps) => React.JSX.Element;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import './BooleanInput.css';
|
|
3
|
-
export const BooleanInput = ({ label, labelFalse, labelTrue, value, onChange }) => {
|
|
3
|
+
export const BooleanInput = ({ label, labelFalse, labelTrue, disabled, value, onChange }) => {
|
|
4
4
|
// #########
|
|
5
5
|
// Rendering
|
|
6
|
-
return (React.createElement("div", { className:
|
|
6
|
+
return (React.createElement("div", { className: `boolean-input ${disabled ? 'boolean-input--disabled' : ''}` },
|
|
7
7
|
label && React.createElement("label", null, label),
|
|
8
8
|
React.createElement("div", { className: "boolean-input-container" },
|
|
9
9
|
React.createElement("div", { className: "boolean-input-content" },
|
|
10
|
-
React.createElement("div", { className: value === true ? 'boolean-input--selected' : '', onClick: () => onChange(true) }, labelTrue
|
|
11
|
-
React.createElement("div", { className: value === false ? 'boolean-input--selected' : '', onClick: () => onChange(false) }, labelFalse
|
|
10
|
+
React.createElement("div", { className: value === true ? 'boolean-input--selected' : '', onClick: () => onChange(true) }, labelTrue),
|
|
11
|
+
React.createElement("div", { className: value === false ? 'boolean-input--selected' : '', onClick: () => onChange(false) }, labelFalse)))));
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=BooleanInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/BooleanInput/BooleanInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAqB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"BooleanInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/BooleanInput/BooleanInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,CAAC;AAE5B,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAqB,EAAE,EAAE;IAC7G,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,iBAAiB,QAAQ,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE;QACzE,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAC,yBAAyB;YACtC,6BAAK,SAAS,EAAC,uBAAuB;gBACpC,6BAAK,SAAS,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAC3F,SAAS,CACN;gBACN,6BAAK,SAAS,EAAE,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAC7F,UAAU,CACP,CACF,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,20 +2,20 @@ import * as React from 'react';
|
|
|
2
2
|
import { BooleanInputProps } from './BooleanInput.types';
|
|
3
3
|
import './BooleanInput.css';
|
|
4
4
|
|
|
5
|
-
export const BooleanInput = ({ label, labelFalse, labelTrue, value, onChange }: BooleanInputProps) => {
|
|
5
|
+
export const BooleanInput = ({ label, labelFalse, labelTrue, disabled, value, onChange }: BooleanInputProps) => {
|
|
6
6
|
// #########
|
|
7
7
|
// Rendering
|
|
8
8
|
return (
|
|
9
|
-
<div className=
|
|
9
|
+
<div className={`boolean-input ${disabled ? 'boolean-input--disabled' : ''}`}>
|
|
10
10
|
{label && <label>{label}</label>}
|
|
11
11
|
|
|
12
12
|
<div className="boolean-input-container">
|
|
13
13
|
<div className="boolean-input-content">
|
|
14
14
|
<div className={value === true ? 'boolean-input--selected' : ''} onClick={() => onChange(true)}>
|
|
15
|
-
{labelTrue
|
|
15
|
+
{labelTrue}
|
|
16
16
|
</div>
|
|
17
17
|
<div className={value === false ? 'boolean-input--selected' : ''} onClick={() => onChange(false)}>
|
|
18
|
-
{labelFalse
|
|
18
|
+
{labelFalse}
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
@@ -17,6 +17,11 @@ export const inputArgType = {
|
|
|
17
17
|
control: 'text',
|
|
18
18
|
description: 'Label of the TRUE value.',
|
|
19
19
|
},
|
|
20
|
+
disabled: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Enable state of the input.',
|
|
23
|
+
table: { defaultValue: { summary: 'false' } },
|
|
24
|
+
},
|
|
20
25
|
value: {
|
|
21
26
|
control: 'boolean',
|
|
22
27
|
description: 'Value of the input (can be undefined).',
|
|
@@ -34,7 +39,11 @@ The Boolean input is used to quickly switch between two possible states. It is c
|
|
|
34
39
|
## Overview
|
|
35
40
|
|
|
36
41
|
<Canvas>
|
|
37
|
-
<Story
|
|
42
|
+
<Story
|
|
43
|
+
name="Overview"
|
|
44
|
+
args={{ label: 'Label', labelFalse: 'No', labelTrue: 'Yes', disabled: false }}
|
|
45
|
+
argTypes={inputArgType}
|
|
46
|
+
>
|
|
38
47
|
{args => <BooleanInput {...args} />}
|
|
39
48
|
</Story>
|
|
40
49
|
</Canvas>
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
color: #012b49;
|
|
9
9
|
font-weight: 700;
|
|
10
10
|
}
|
|
11
|
+
.text-input--disabled {
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
}
|
|
14
|
+
.text-input--disabled .boolean-input-container > div {
|
|
15
|
+
cursor: not-allowed;
|
|
16
|
+
}
|
|
11
17
|
.text-input-container {
|
|
12
18
|
position: relative;
|
|
13
19
|
}
|
|
@@ -30,6 +36,16 @@
|
|
|
30
36
|
color: #4e5d6b;
|
|
31
37
|
transform: translateY(-50%);
|
|
32
38
|
}
|
|
39
|
+
.text-input--error {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
color: #ed6a5e;
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
}
|
|
46
|
+
.text-input-container--error > input {
|
|
47
|
+
border: 2px solid #ed6a5e;
|
|
48
|
+
}
|
|
33
49
|
|
|
34
50
|
/* ######### */
|
|
35
51
|
/* GLOBALS */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextInputProps } from './TextInput.types';
|
|
3
3
|
import './TextInput.css';
|
|
4
|
-
export declare const TextInput: ({ icon, label, placeholder, value, autofocus, onChange }: TextInputProps) => React.JSX.Element;
|
|
4
|
+
export declare const TextInput: ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }: TextInputProps) => React.JSX.Element;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Icon } from '../../Icon/Icon';
|
|
3
3
|
import './TextInput.css';
|
|
4
|
-
export const TextInput = ({ icon, label, placeholder, value, autofocus, onChange }) => {
|
|
4
|
+
export const TextInput = ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }) => {
|
|
5
5
|
// ########
|
|
6
6
|
// Handlers
|
|
7
7
|
const handleChange = (e) => onChange(e.target.value);
|
|
8
8
|
// #########
|
|
9
9
|
// Rendering
|
|
10
|
-
return (React.createElement("div", { className:
|
|
10
|
+
return (React.createElement("div", { className: `text-input ${disabled ? 'text-input--disabled' : ''}` },
|
|
11
11
|
label && React.createElement("label", null, label),
|
|
12
|
-
React.createElement("div", { className:
|
|
13
|
-
React.createElement("input", { type: "text", placeholder: placeholder, value: value, autoFocus: autofocus, onChange: handleChange }),
|
|
14
|
-
icon && React.createElement(Icon, { name: icon, size: "16" }))
|
|
12
|
+
React.createElement("div", { className: `text-input-container ${errorLabel ? 'text-input-container--error' : ''}` },
|
|
13
|
+
React.createElement("input", { type: "text", placeholder: placeholder, value: value, autoFocus: autofocus, disabled: disabled, onBlur: onBlur, onChange: handleChange, onFocus: onFocus }),
|
|
14
|
+
icon && React.createElement(Icon, { name: icon, size: "16" })),
|
|
15
|
+
errorLabel && React.createElement("div", { className: "text-input--error" }, errorLabel)));
|
|
15
16
|
};
|
|
16
17
|
//# sourceMappingURL=TextInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,GACQ,EAAE,EAAE;IACnB,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,CAAC,CAAgC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpF,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,cAAc,QAAQ,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAE,wBAAwB,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,EAAE;YACvF,+BACE,IAAI,EAAC,MAAM,EACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,GAChB;YACD,IAAI,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC;QAEL,UAAU,IAAI,6BAAK,SAAS,EAAC,mBAAmB,IAAE,UAAU,CAAO,CAChE,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -4,7 +4,18 @@ import { Icon } from '../../Icon/Icon';
|
|
|
4
4
|
import { TextInputProps } from './TextInput.types';
|
|
5
5
|
import './TextInput.css';
|
|
6
6
|
|
|
7
|
-
export const TextInput = ({
|
|
7
|
+
export const TextInput = ({
|
|
8
|
+
errorLabel,
|
|
9
|
+
icon,
|
|
10
|
+
label,
|
|
11
|
+
placeholder,
|
|
12
|
+
value,
|
|
13
|
+
autofocus,
|
|
14
|
+
disabled,
|
|
15
|
+
onBlur,
|
|
16
|
+
onChange,
|
|
17
|
+
onFocus,
|
|
18
|
+
}: TextInputProps) => {
|
|
8
19
|
// ########
|
|
9
20
|
// Handlers
|
|
10
21
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
|
|
@@ -12,13 +23,24 @@ export const TextInput = ({ icon, label, placeholder, value, autofocus, onChange
|
|
|
12
23
|
// #########
|
|
13
24
|
// Rendering
|
|
14
25
|
return (
|
|
15
|
-
<div className=
|
|
26
|
+
<div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
|
|
16
27
|
{label && <label>{label}</label>}
|
|
17
28
|
|
|
18
|
-
<div className=
|
|
19
|
-
<input
|
|
29
|
+
<div className={`text-input-container ${errorLabel ? 'text-input-container--error' : ''}`}>
|
|
30
|
+
<input
|
|
31
|
+
type="text"
|
|
32
|
+
placeholder={placeholder}
|
|
33
|
+
value={value}
|
|
34
|
+
autoFocus={autofocus}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
onBlur={onBlur}
|
|
37
|
+
onChange={handleChange}
|
|
38
|
+
onFocus={onFocus}
|
|
39
|
+
/>
|
|
20
40
|
{icon && <Icon name={icon} size="16" />}
|
|
21
41
|
</div>
|
|
42
|
+
|
|
43
|
+
{errorLabel && <div className="text-input--error">{errorLabel}</div>}
|
|
22
44
|
</div>
|
|
23
45
|
);
|
|
24
46
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type TextInputProps = {
|
|
2
|
+
errorLabel?: string;
|
|
2
3
|
icon?: string;
|
|
3
4
|
label?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
autofocus?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onBlur: () => void;
|
|
7
10
|
onChange: (value: string) => void;
|
|
11
|
+
onFocus: () => void;
|
|
8
12
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type TextInputProps = {
|
|
2
|
+
errorLabel?: string;
|
|
2
3
|
icon?: string;
|
|
3
4
|
label?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
autofocus?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onBlur: () => void;
|
|
7
10
|
onChange: (value: string) => void;
|
|
11
|
+
onFocus: () => void;
|
|
8
12
|
};
|
|
@@ -6,6 +6,7 @@ import { icons } from '../../../Icon/icons';
|
|
|
6
6
|
<Meta title="Components/Inputs/TextInput" />
|
|
7
7
|
|
|
8
8
|
export const inputArgTypes = {
|
|
9
|
+
errorLabel: { control: 'text', description: 'Show error on the input.' },
|
|
9
10
|
icon: {
|
|
10
11
|
control: 'select',
|
|
11
12
|
options: Object.keys(icons),
|
|
@@ -28,10 +29,23 @@ export const inputArgTypes = {
|
|
|
28
29
|
description: 'Auto focus the input once mounted',
|
|
29
30
|
table: { defaultValue: { summary: 'false' } },
|
|
30
31
|
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Auto focus the input once mounted',
|
|
35
|
+
table: { defaultValue: { summary: 'false' } },
|
|
36
|
+
},
|
|
37
|
+
onBlur: {
|
|
38
|
+
control: 'function',
|
|
39
|
+
description: 'The handler called when the user blur the input.',
|
|
40
|
+
},
|
|
31
41
|
onChange: {
|
|
32
42
|
control: 'function',
|
|
33
43
|
description: 'The handler called when the value of the input changes.',
|
|
34
44
|
},
|
|
45
|
+
onFocus: {
|
|
46
|
+
control: 'function',
|
|
47
|
+
description: 'The handler called when the user focus the input.',
|
|
48
|
+
},
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
# Text Input
|
|
@@ -43,7 +57,14 @@ Text input allows the user to enter content and data when the expected user inpu
|
|
|
43
57
|
<Canvas>
|
|
44
58
|
<Story
|
|
45
59
|
name="Overview"
|
|
46
|
-
args={{
|
|
60
|
+
args={{
|
|
61
|
+
errorLabel: '',
|
|
62
|
+
label: 'Label',
|
|
63
|
+
placeholder: 'This is a placeholder',
|
|
64
|
+
value: '',
|
|
65
|
+
autofocus: false,
|
|
66
|
+
disabled: false,
|
|
67
|
+
}}
|
|
47
68
|
argTypes={inputArgTypes}
|
|
48
69
|
>
|
|
49
70
|
{args => <TextInput {...args} />}
|
|
@@ -23,6 +23,10 @@ export const checkboxArgTypes = {
|
|
|
23
23
|
description: 'Enable state of the checkbox.',
|
|
24
24
|
table: { defaultValue: { summary: 'false' } },
|
|
25
25
|
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
# Checkbox
|
|
@@ -40,7 +44,6 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
40
44
|
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
41
45
|
checked: false,
|
|
42
46
|
disabled: false,
|
|
43
|
-
onChange: () => {},
|
|
44
47
|
}}
|
|
45
48
|
argTypes={checkboxArgTypes}
|
|
46
49
|
>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { BooleanInputProps } from './BooleanInput.types';
|
|
3
3
|
import './BooleanInput.css';
|
|
4
|
-
export declare const BooleanInput: ({ label, labelFalse, labelTrue, value, onChange }: BooleanInputProps) => React.JSX.Element;
|
|
4
|
+
export declare const BooleanInput: ({ label, labelFalse, labelTrue, disabled, value, onChange }: BooleanInputProps) => React.JSX.Element;
|
|
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BooleanInput = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
require("./BooleanInput.css");
|
|
6
|
-
const BooleanInput = ({ label, labelFalse, labelTrue, value, onChange }) => {
|
|
6
|
+
const BooleanInput = ({ label, labelFalse, labelTrue, disabled, value, onChange }) => {
|
|
7
7
|
// #########
|
|
8
8
|
// Rendering
|
|
9
|
-
return (React.createElement("div", { className:
|
|
9
|
+
return (React.createElement("div", { className: `boolean-input ${disabled ? 'boolean-input--disabled' : ''}` },
|
|
10
10
|
label && React.createElement("label", null, label),
|
|
11
11
|
React.createElement("div", { className: "boolean-input-container" },
|
|
12
12
|
React.createElement("div", { className: "boolean-input-content" },
|
|
13
|
-
React.createElement("div", { className: value === true ? 'boolean-input--selected' : '', onClick: () => onChange(true) }, labelTrue
|
|
14
|
-
React.createElement("div", { className: value === false ? 'boolean-input--selected' : '', onClick: () => onChange(false) }, labelFalse
|
|
13
|
+
React.createElement("div", { className: value === true ? 'boolean-input--selected' : '', onClick: () => onChange(true) }, labelTrue),
|
|
14
|
+
React.createElement("div", { className: value === false ? 'boolean-input--selected' : '', onClick: () => onChange(false) }, labelFalse)))));
|
|
15
15
|
};
|
|
16
16
|
exports.BooleanInput = BooleanInput;
|
|
17
17
|
//# sourceMappingURL=BooleanInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/BooleanInput/BooleanInput.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,8BAA4B;AAErB,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAqB,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"BooleanInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/BooleanInput/BooleanInput.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,8BAA4B;AAErB,MAAM,YAAY,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAqB,EAAE,EAAE;IAC7G,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,iBAAiB,QAAQ,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE;QACzE,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAC,yBAAyB;YACtC,6BAAK,SAAS,EAAC,uBAAuB;gBACpC,6BAAK,SAAS,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAC3F,SAAS,CACN;gBACN,6BAAK,SAAS,EAAE,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAC7F,UAAU,CACP,CACF,CACF,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,YAAY,gBAmBvB"}
|
|
@@ -2,20 +2,20 @@ import * as React from 'react';
|
|
|
2
2
|
import { BooleanInputProps } from './BooleanInput.types';
|
|
3
3
|
import './BooleanInput.css';
|
|
4
4
|
|
|
5
|
-
export const BooleanInput = ({ label, labelFalse, labelTrue, value, onChange }: BooleanInputProps) => {
|
|
5
|
+
export const BooleanInput = ({ label, labelFalse, labelTrue, disabled, value, onChange }: BooleanInputProps) => {
|
|
6
6
|
// #########
|
|
7
7
|
// Rendering
|
|
8
8
|
return (
|
|
9
|
-
<div className=
|
|
9
|
+
<div className={`boolean-input ${disabled ? 'boolean-input--disabled' : ''}`}>
|
|
10
10
|
{label && <label>{label}</label>}
|
|
11
11
|
|
|
12
12
|
<div className="boolean-input-container">
|
|
13
13
|
<div className="boolean-input-content">
|
|
14
14
|
<div className={value === true ? 'boolean-input--selected' : ''} onClick={() => onChange(true)}>
|
|
15
|
-
{labelTrue
|
|
15
|
+
{labelTrue}
|
|
16
16
|
</div>
|
|
17
17
|
<div className={value === false ? 'boolean-input--selected' : ''} onClick={() => onChange(false)}>
|
|
18
|
-
{labelFalse
|
|
18
|
+
{labelFalse}
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
@@ -17,6 +17,11 @@ export const inputArgType = {
|
|
|
17
17
|
control: 'text',
|
|
18
18
|
description: 'Label of the TRUE value.',
|
|
19
19
|
},
|
|
20
|
+
disabled: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Enable state of the input.',
|
|
23
|
+
table: { defaultValue: { summary: 'false' } },
|
|
24
|
+
},
|
|
20
25
|
value: {
|
|
21
26
|
control: 'boolean',
|
|
22
27
|
description: 'Value of the input (can be undefined).',
|
|
@@ -34,7 +39,11 @@ The Boolean input is used to quickly switch between two possible states. It is c
|
|
|
34
39
|
## Overview
|
|
35
40
|
|
|
36
41
|
<Canvas>
|
|
37
|
-
<Story
|
|
42
|
+
<Story
|
|
43
|
+
name="Overview"
|
|
44
|
+
args={{ label: 'Label', labelFalse: 'No', labelTrue: 'Yes', disabled: false }}
|
|
45
|
+
argTypes={inputArgType}
|
|
46
|
+
>
|
|
38
47
|
{args => <BooleanInput {...args} />}
|
|
39
48
|
</Story>
|
|
40
49
|
</Canvas>
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
color: #012b49;
|
|
9
9
|
font-weight: 700;
|
|
10
10
|
}
|
|
11
|
+
.text-input--disabled {
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
}
|
|
14
|
+
.text-input--disabled .boolean-input-container > div {
|
|
15
|
+
cursor: not-allowed;
|
|
16
|
+
}
|
|
11
17
|
.text-input-container {
|
|
12
18
|
position: relative;
|
|
13
19
|
}
|
|
@@ -30,6 +36,16 @@
|
|
|
30
36
|
color: #4e5d6b;
|
|
31
37
|
transform: translateY(-50%);
|
|
32
38
|
}
|
|
39
|
+
.text-input--error {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
color: #ed6a5e;
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
}
|
|
46
|
+
.text-input-container--error > input {
|
|
47
|
+
border: 2px solid #ed6a5e;
|
|
48
|
+
}
|
|
33
49
|
|
|
34
50
|
/* ######### */
|
|
35
51
|
/* GLOBALS */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TextInputProps } from './TextInput.types';
|
|
3
3
|
import './TextInput.css';
|
|
4
|
-
export declare const TextInput: ({ icon, label, placeholder, value, autofocus, onChange }: TextInputProps) => React.JSX.Element;
|
|
4
|
+
export declare const TextInput: ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }: TextInputProps) => React.JSX.Element;
|
|
@@ -4,17 +4,18 @@ exports.TextInput = void 0;
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const Icon_1 = require("../../Icon/Icon");
|
|
6
6
|
require("./TextInput.css");
|
|
7
|
-
const TextInput = ({ icon, label, placeholder, value, autofocus, onChange }) => {
|
|
7
|
+
const TextInput = ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }) => {
|
|
8
8
|
// ########
|
|
9
9
|
// Handlers
|
|
10
10
|
const handleChange = (e) => onChange(e.target.value);
|
|
11
11
|
// #########
|
|
12
12
|
// Rendering
|
|
13
|
-
return (React.createElement("div", { className:
|
|
13
|
+
return (React.createElement("div", { className: `text-input ${disabled ? 'text-input--disabled' : ''}` },
|
|
14
14
|
label && React.createElement("label", null, label),
|
|
15
|
-
React.createElement("div", { className:
|
|
16
|
-
React.createElement("input", { type: "text", placeholder: placeholder, value: value, autoFocus: autofocus, onChange: handleChange }),
|
|
17
|
-
icon && React.createElement(Icon_1.Icon, { name: icon, size: "16" }))
|
|
15
|
+
React.createElement("div", { className: `text-input-container ${errorLabel ? 'text-input-container--error' : ''}` },
|
|
16
|
+
React.createElement("input", { type: "text", placeholder: placeholder, value: value, autoFocus: autofocus, disabled: disabled, onBlur: onBlur, onChange: handleChange, onFocus: onFocus }),
|
|
17
|
+
icon && React.createElement(Icon_1.Icon, { name: icon, size: "16" })),
|
|
18
|
+
errorLabel && React.createElement("div", { className: "text-input--error" }, errorLabel)));
|
|
18
19
|
};
|
|
19
20
|
exports.TextInput = TextInput;
|
|
20
21
|
//# sourceMappingURL=TextInput.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,0CAAuC;AAEvC,2BAAyB;AAElB,MAAM,SAAS,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,0CAAuC;AAEvC,2BAAyB;AAElB,MAAM,SAAS,GAAG,CAAC,EACxB,UAAU,EACV,IAAI,EACJ,KAAK,EACL,WAAW,EACX,KAAK,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,GACQ,EAAE,EAAE;IACnB,WAAW;IACX,WAAW;IACX,MAAM,YAAY,GAAG,CAAC,CAAgC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpF,YAAY;IACZ,YAAY;IACZ,OAAO,CACL,6BAAK,SAAS,EAAE,cAAc,QAAQ,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,EAAE,EAAE;QACnE,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAE,wBAAwB,UAAU,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,EAAE;YACvF,+BACE,IAAI,EAAC,MAAM,EACX,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,GAChB;YACD,IAAI,IAAI,oBAAC,WAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC;QAEL,UAAU,IAAI,6BAAK,SAAS,EAAC,mBAAmB,IAAE,UAAU,CAAO,CAChE,CACP,CAAC;AACJ,CAAC,CAAC;AAvCW,QAAA,SAAS,aAuCpB"}
|
|
@@ -4,7 +4,18 @@ import { Icon } from '../../Icon/Icon';
|
|
|
4
4
|
import { TextInputProps } from './TextInput.types';
|
|
5
5
|
import './TextInput.css';
|
|
6
6
|
|
|
7
|
-
export const TextInput = ({
|
|
7
|
+
export const TextInput = ({
|
|
8
|
+
errorLabel,
|
|
9
|
+
icon,
|
|
10
|
+
label,
|
|
11
|
+
placeholder,
|
|
12
|
+
value,
|
|
13
|
+
autofocus,
|
|
14
|
+
disabled,
|
|
15
|
+
onBlur,
|
|
16
|
+
onChange,
|
|
17
|
+
onFocus,
|
|
18
|
+
}: TextInputProps) => {
|
|
8
19
|
// ########
|
|
9
20
|
// Handlers
|
|
10
21
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
|
|
@@ -12,13 +23,24 @@ export const TextInput = ({ icon, label, placeholder, value, autofocus, onChange
|
|
|
12
23
|
// #########
|
|
13
24
|
// Rendering
|
|
14
25
|
return (
|
|
15
|
-
<div className=
|
|
26
|
+
<div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
|
|
16
27
|
{label && <label>{label}</label>}
|
|
17
28
|
|
|
18
|
-
<div className=
|
|
19
|
-
<input
|
|
29
|
+
<div className={`text-input-container ${errorLabel ? 'text-input-container--error' : ''}`}>
|
|
30
|
+
<input
|
|
31
|
+
type="text"
|
|
32
|
+
placeholder={placeholder}
|
|
33
|
+
value={value}
|
|
34
|
+
autoFocus={autofocus}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
onBlur={onBlur}
|
|
37
|
+
onChange={handleChange}
|
|
38
|
+
onFocus={onFocus}
|
|
39
|
+
/>
|
|
20
40
|
{icon && <Icon name={icon} size="16" />}
|
|
21
41
|
</div>
|
|
42
|
+
|
|
43
|
+
{errorLabel && <div className="text-input--error">{errorLabel}</div>}
|
|
22
44
|
</div>
|
|
23
45
|
);
|
|
24
46
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type TextInputProps = {
|
|
2
|
+
errorLabel?: string;
|
|
2
3
|
icon?: string;
|
|
3
4
|
label?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
autofocus?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onBlur: () => void;
|
|
7
10
|
onChange: (value: string) => void;
|
|
11
|
+
onFocus: () => void;
|
|
8
12
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type TextInputProps = {
|
|
2
|
+
errorLabel?: string;
|
|
2
3
|
icon?: string;
|
|
3
4
|
label?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
autofocus?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onBlur: () => void;
|
|
7
10
|
onChange: (value: string) => void;
|
|
11
|
+
onFocus: () => void;
|
|
8
12
|
};
|
|
@@ -6,6 +6,7 @@ import { icons } from '../../../Icon/icons';
|
|
|
6
6
|
<Meta title="Components/Inputs/TextInput" />
|
|
7
7
|
|
|
8
8
|
export const inputArgTypes = {
|
|
9
|
+
errorLabel: { control: 'text', description: 'Show error on the input.' },
|
|
9
10
|
icon: {
|
|
10
11
|
control: 'select',
|
|
11
12
|
options: Object.keys(icons),
|
|
@@ -28,10 +29,23 @@ export const inputArgTypes = {
|
|
|
28
29
|
description: 'Auto focus the input once mounted',
|
|
29
30
|
table: { defaultValue: { summary: 'false' } },
|
|
30
31
|
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Auto focus the input once mounted',
|
|
35
|
+
table: { defaultValue: { summary: 'false' } },
|
|
36
|
+
},
|
|
37
|
+
onBlur: {
|
|
38
|
+
control: 'function',
|
|
39
|
+
description: 'The handler called when the user blur the input.',
|
|
40
|
+
},
|
|
31
41
|
onChange: {
|
|
32
42
|
control: 'function',
|
|
33
43
|
description: 'The handler called when the value of the input changes.',
|
|
34
44
|
},
|
|
45
|
+
onFocus: {
|
|
46
|
+
control: 'function',
|
|
47
|
+
description: 'The handler called when the user focus the input.',
|
|
48
|
+
},
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
# Text Input
|
|
@@ -43,7 +57,14 @@ Text input allows the user to enter content and data when the expected user inpu
|
|
|
43
57
|
<Canvas>
|
|
44
58
|
<Story
|
|
45
59
|
name="Overview"
|
|
46
|
-
args={{
|
|
60
|
+
args={{
|
|
61
|
+
errorLabel: '',
|
|
62
|
+
label: 'Label',
|
|
63
|
+
placeholder: 'This is a placeholder',
|
|
64
|
+
value: '',
|
|
65
|
+
autofocus: false,
|
|
66
|
+
disabled: false,
|
|
67
|
+
}}
|
|
47
68
|
argTypes={inputArgTypes}
|
|
48
69
|
>
|
|
49
70
|
{args => <TextInput {...args} />}
|
package/package.json
CHANGED
|
@@ -23,6 +23,10 @@ export const checkboxArgTypes = {
|
|
|
23
23
|
description: 'Enable state of the checkbox.',
|
|
24
24
|
table: { defaultValue: { summary: 'false' } },
|
|
25
25
|
},
|
|
26
|
+
onChange: {
|
|
27
|
+
control: 'function',
|
|
28
|
+
description: 'The handler called when clicking on the checkbox.',
|
|
29
|
+
},
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
# Checkbox
|
|
@@ -40,7 +44,6 @@ Checkboxes are applied when users can select all, several, or none of the option
|
|
|
40
44
|
'Auctor nisl justo, sed posuere est dignissim nec. Integer ultricies, metus ac imperdiet ullamcorper, est justo viverra nisl, in posuere dui urna eget quam.',
|
|
41
45
|
checked: false,
|
|
42
46
|
disabled: false,
|
|
43
|
-
onChange: () => {},
|
|
44
47
|
}}
|
|
45
48
|
argTypes={checkboxArgTypes}
|
|
46
49
|
>
|
|
@@ -2,20 +2,20 @@ import * as React from 'react';
|
|
|
2
2
|
import { BooleanInputProps } from './BooleanInput.types';
|
|
3
3
|
import './BooleanInput.css';
|
|
4
4
|
|
|
5
|
-
export const BooleanInput = ({ label, labelFalse, labelTrue, value, onChange }: BooleanInputProps) => {
|
|
5
|
+
export const BooleanInput = ({ label, labelFalse, labelTrue, disabled, value, onChange }: BooleanInputProps) => {
|
|
6
6
|
// #########
|
|
7
7
|
// Rendering
|
|
8
8
|
return (
|
|
9
|
-
<div className=
|
|
9
|
+
<div className={`boolean-input ${disabled ? 'boolean-input--disabled' : ''}`}>
|
|
10
10
|
{label && <label>{label}</label>}
|
|
11
11
|
|
|
12
12
|
<div className="boolean-input-container">
|
|
13
13
|
<div className="boolean-input-content">
|
|
14
14
|
<div className={value === true ? 'boolean-input--selected' : ''} onClick={() => onChange(true)}>
|
|
15
|
-
{labelTrue
|
|
15
|
+
{labelTrue}
|
|
16
16
|
</div>
|
|
17
17
|
<div className={value === false ? 'boolean-input--selected' : ''} onClick={() => onChange(false)}>
|
|
18
|
-
{labelFalse
|
|
18
|
+
{labelFalse}
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
21
21
|
</div>
|
|
@@ -17,6 +17,11 @@ export const inputArgType = {
|
|
|
17
17
|
control: 'text',
|
|
18
18
|
description: 'Label of the TRUE value.',
|
|
19
19
|
},
|
|
20
|
+
disabled: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Enable state of the input.',
|
|
23
|
+
table: { defaultValue: { summary: 'false' } },
|
|
24
|
+
},
|
|
20
25
|
value: {
|
|
21
26
|
control: 'boolean',
|
|
22
27
|
description: 'Value of the input (can be undefined).',
|
|
@@ -34,7 +39,11 @@ The Boolean input is used to quickly switch between two possible states. It is c
|
|
|
34
39
|
## Overview
|
|
35
40
|
|
|
36
41
|
<Canvas>
|
|
37
|
-
<Story
|
|
42
|
+
<Story
|
|
43
|
+
name="Overview"
|
|
44
|
+
args={{ label: 'Label', labelFalse: 'No', labelTrue: 'Yes', disabled: false }}
|
|
45
|
+
argTypes={inputArgType}
|
|
46
|
+
>
|
|
38
47
|
{args => <BooleanInput {...args} />}
|
|
39
48
|
</Story>
|
|
40
49
|
</Canvas>
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
color: #012b49;
|
|
9
9
|
font-weight: 700;
|
|
10
10
|
}
|
|
11
|
+
.text-input--disabled {
|
|
12
|
+
opacity: 0.5;
|
|
13
|
+
}
|
|
14
|
+
.text-input--disabled .boolean-input-container > div {
|
|
15
|
+
cursor: not-allowed;
|
|
16
|
+
}
|
|
11
17
|
.text-input-container {
|
|
12
18
|
position: relative;
|
|
13
19
|
}
|
|
@@ -30,6 +36,16 @@
|
|
|
30
36
|
color: #4e5d6b;
|
|
31
37
|
transform: translateY(-50%);
|
|
32
38
|
}
|
|
39
|
+
.text-input--error {
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
color: #ed6a5e;
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
font-weight: 600;
|
|
45
|
+
}
|
|
46
|
+
.text-input-container--error > input {
|
|
47
|
+
border: 2px solid #ed6a5e;
|
|
48
|
+
}
|
|
33
49
|
|
|
34
50
|
/* ######### */
|
|
35
51
|
/* GLOBALS */
|
|
@@ -4,7 +4,18 @@ import { Icon } from '../../Icon/Icon';
|
|
|
4
4
|
import { TextInputProps } from './TextInput.types';
|
|
5
5
|
import './TextInput.css';
|
|
6
6
|
|
|
7
|
-
export const TextInput = ({
|
|
7
|
+
export const TextInput = ({
|
|
8
|
+
errorLabel,
|
|
9
|
+
icon,
|
|
10
|
+
label,
|
|
11
|
+
placeholder,
|
|
12
|
+
value,
|
|
13
|
+
autofocus,
|
|
14
|
+
disabled,
|
|
15
|
+
onBlur,
|
|
16
|
+
onChange,
|
|
17
|
+
onFocus,
|
|
18
|
+
}: TextInputProps) => {
|
|
8
19
|
// ########
|
|
9
20
|
// Handlers
|
|
10
21
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
|
|
@@ -12,13 +23,24 @@ export const TextInput = ({ icon, label, placeholder, value, autofocus, onChange
|
|
|
12
23
|
// #########
|
|
13
24
|
// Rendering
|
|
14
25
|
return (
|
|
15
|
-
<div className=
|
|
26
|
+
<div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
|
|
16
27
|
{label && <label>{label}</label>}
|
|
17
28
|
|
|
18
|
-
<div className=
|
|
19
|
-
<input
|
|
29
|
+
<div className={`text-input-container ${errorLabel ? 'text-input-container--error' : ''}`}>
|
|
30
|
+
<input
|
|
31
|
+
type="text"
|
|
32
|
+
placeholder={placeholder}
|
|
33
|
+
value={value}
|
|
34
|
+
autoFocus={autofocus}
|
|
35
|
+
disabled={disabled}
|
|
36
|
+
onBlur={onBlur}
|
|
37
|
+
onChange={handleChange}
|
|
38
|
+
onFocus={onFocus}
|
|
39
|
+
/>
|
|
20
40
|
{icon && <Icon name={icon} size="16" />}
|
|
21
41
|
</div>
|
|
42
|
+
|
|
43
|
+
{errorLabel && <div className="text-input--error">{errorLabel}</div>}
|
|
22
44
|
</div>
|
|
23
45
|
);
|
|
24
46
|
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export type TextInputProps = {
|
|
2
|
+
errorLabel?: string;
|
|
2
3
|
icon?: string;
|
|
3
4
|
label?: string;
|
|
4
5
|
placeholder?: string;
|
|
5
6
|
value: string;
|
|
6
7
|
autofocus?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onBlur: () => void;
|
|
7
10
|
onChange: (value: string) => void;
|
|
11
|
+
onFocus: () => void;
|
|
8
12
|
};
|
|
@@ -6,6 +6,7 @@ import { icons } from '../../../Icon/icons';
|
|
|
6
6
|
<Meta title="Components/Inputs/TextInput" />
|
|
7
7
|
|
|
8
8
|
export const inputArgTypes = {
|
|
9
|
+
errorLabel: { control: 'text', description: 'Show error on the input.' },
|
|
9
10
|
icon: {
|
|
10
11
|
control: 'select',
|
|
11
12
|
options: Object.keys(icons),
|
|
@@ -28,10 +29,23 @@ export const inputArgTypes = {
|
|
|
28
29
|
description: 'Auto focus the input once mounted',
|
|
29
30
|
table: { defaultValue: { summary: 'false' } },
|
|
30
31
|
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Auto focus the input once mounted',
|
|
35
|
+
table: { defaultValue: { summary: 'false' } },
|
|
36
|
+
},
|
|
37
|
+
onBlur: {
|
|
38
|
+
control: 'function',
|
|
39
|
+
description: 'The handler called when the user blur the input.',
|
|
40
|
+
},
|
|
31
41
|
onChange: {
|
|
32
42
|
control: 'function',
|
|
33
43
|
description: 'The handler called when the value of the input changes.',
|
|
34
44
|
},
|
|
45
|
+
onFocus: {
|
|
46
|
+
control: 'function',
|
|
47
|
+
description: 'The handler called when the user focus the input.',
|
|
48
|
+
},
|
|
35
49
|
};
|
|
36
50
|
|
|
37
51
|
# Text Input
|
|
@@ -43,7 +57,14 @@ Text input allows the user to enter content and data when the expected user inpu
|
|
|
43
57
|
<Canvas>
|
|
44
58
|
<Story
|
|
45
59
|
name="Overview"
|
|
46
|
-
args={{
|
|
60
|
+
args={{
|
|
61
|
+
errorLabel: '',
|
|
62
|
+
label: 'Label',
|
|
63
|
+
placeholder: 'This is a placeholder',
|
|
64
|
+
value: '',
|
|
65
|
+
autofocus: false,
|
|
66
|
+
disabled: false,
|
|
67
|
+
}}
|
|
47
68
|
argTypes={inputArgTypes}
|
|
48
69
|
>
|
|
49
70
|
{args => <TextInput {...args} />}
|