@dktunited-techoff/techoff-suite-ui 0.9.9 → 0.9.11

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.
Files changed (49) hide show
  1. package/esm/components/Inputs/{TextInput/TextInput.css → Input/Input.css} +13 -10
  2. package/esm/components/Inputs/Input/Input.d.ts +4 -0
  3. package/esm/components/Inputs/Input/Input.js +19 -0
  4. package/esm/components/Inputs/Input/Input.js.map +1 -0
  5. package/esm/components/Inputs/Input/Input.tsx +31 -0
  6. package/esm/components/Inputs/Input/Input.types.d.ts +10 -0
  7. package/esm/components/Inputs/Input/Input.types.js +2 -0
  8. package/esm/components/Inputs/Input/Input.types.js.map +1 -0
  9. package/esm/components/Inputs/Input/Input.types.ts +11 -0
  10. package/{src/components/Inputs/TextInput/__stories__/TextInput.stories.mdx → esm/components/Inputs/Input/__stories__/Input.stories.mdx} +10 -18
  11. package/esm/index.d.ts +1 -1
  12. package/esm/index.js +1 -1
  13. package/esm/index.js.map +1 -1
  14. package/{src/components/Inputs/TextInput/TextInput.css → lib/components/Inputs/Input/Input.css} +13 -10
  15. package/lib/components/Inputs/Input/Input.d.ts +4 -0
  16. package/lib/components/Inputs/Input/Input.js +23 -0
  17. package/lib/components/Inputs/Input/Input.js.map +1 -0
  18. package/lib/components/Inputs/Input/Input.tsx +31 -0
  19. package/lib/components/Inputs/Input/Input.types.d.ts +10 -0
  20. package/lib/components/Inputs/{TextInput/TextInput.types.js → Input/Input.types.js} +1 -1
  21. package/lib/components/Inputs/Input/Input.types.js.map +1 -0
  22. package/lib/components/Inputs/Input/Input.types.ts +11 -0
  23. package/lib/components/Inputs/{TextInput/__stories__/TextInput.stories.mdx → Input/__stories__/Input.stories.mdx} +10 -18
  24. package/lib/index.d.ts +1 -1
  25. package/lib/index.js +1 -1
  26. package/lib/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/{lib/components/Inputs/TextInput/TextInput.css → src/components/Inputs/Input/Input.css} +13 -10
  29. package/src/components/Inputs/Input/Input.tsx +31 -0
  30. package/src/components/Inputs/Input/Input.types.ts +11 -0
  31. package/{esm/components/Inputs/TextInput/__stories__/TextInput.stories.mdx → src/components/Inputs/Input/__stories__/Input.stories.mdx} +10 -18
  32. package/src/index.ts +1 -1
  33. package/esm/components/Inputs/TextInput/TextInput.d.ts +0 -4
  34. package/esm/components/Inputs/TextInput/TextInput.js +0 -17
  35. package/esm/components/Inputs/TextInput/TextInput.js.map +0 -1
  36. package/esm/components/Inputs/TextInput/TextInput.tsx +0 -46
  37. package/esm/components/Inputs/TextInput/TextInput.types.d.ts +0 -12
  38. package/esm/components/Inputs/TextInput/TextInput.types.js +0 -2
  39. package/esm/components/Inputs/TextInput/TextInput.types.js.map +0 -1
  40. package/esm/components/Inputs/TextInput/TextInput.types.ts +0 -12
  41. package/lib/components/Inputs/TextInput/TextInput.d.ts +0 -4
  42. package/lib/components/Inputs/TextInput/TextInput.js +0 -21
  43. package/lib/components/Inputs/TextInput/TextInput.js.map +0 -1
  44. package/lib/components/Inputs/TextInput/TextInput.tsx +0 -46
  45. package/lib/components/Inputs/TextInput/TextInput.types.d.ts +0 -12
  46. package/lib/components/Inputs/TextInput/TextInput.types.js.map +0 -1
  47. package/lib/components/Inputs/TextInput/TextInput.types.ts +0 -12
  48. package/src/components/Inputs/TextInput/TextInput.tsx +0 -46
  49. package/src/components/Inputs/TextInput/TextInput.types.ts +0 -12
@@ -1,23 +1,23 @@
1
- .text-input {
1
+ .input {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  }
5
- .text-input > label {
5
+ .input > label {
6
6
  display: block;
7
7
  margin-bottom: 4px;
8
8
  color: #012b49;
9
9
  font-weight: 700;
10
10
  }
11
- .text-input--disabled {
11
+ .input--disabled {
12
12
  opacity: 0.5;
13
13
  }
14
- .text-input--disabled .boolean-input-container > div {
14
+ .input--disabled .boolean-input-container > div {
15
15
  cursor: not-allowed;
16
16
  }
17
- .text-input-container {
17
+ .input-container {
18
18
  position: relative;
19
19
  }
20
- .text-input-container > input {
20
+ .input-container > input {
21
21
  width: 100%;
22
22
  height: 32px;
23
23
  padding: 0 40px 0 12px;
@@ -26,24 +26,27 @@
26
26
  color: #007dbc;
27
27
  font-weight: 700;
28
28
  }
29
- .text-input-container > input::placeholder {
29
+ .input-container > input::placeholder {
30
30
  font-weight: 400;
31
31
  }
32
- .text-input-container > .icon {
32
+ .input-container > .icon {
33
33
  position: absolute;
34
34
  top: 50%;
35
35
  right: 12px;
36
36
  color: #4e5d6b;
37
37
  transform: translateY(-50%);
38
38
  }
39
- .text-input--error {
39
+ .input--error {
40
40
  display: flex;
41
41
  align-items: center;
42
42
  color: #ed6a5e;
43
43
  font-size: 12px;
44
44
  font-weight: 600;
45
45
  }
46
- .text-input-container--error > input {
46
+ .input--error-label {
47
+ margin-left: 4px;
48
+ }
49
+ .input-container--error > input {
47
50
  border: 2px solid #ed6a5e;
48
51
  }
49
52
 
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { InputProps } from './Input.types';
3
+ import './Input.css';
4
+ export declare const Input: ({ errorLabel, icon, label, type, value, disabled, onChange, ...props }: InputProps) => React.JSX.Element;
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { Icon } from '../../Icon/Icon';
3
+ import './Input.css';
4
+ export const Input = ({ errorLabel, icon, label, type = 'text', value, disabled, onChange, ...props }) => {
5
+ // ########
6
+ // Handlers
7
+ const handleChange = (e) => onChange(e.target.value);
8
+ // #########
9
+ // Rendering
10
+ return (React.createElement("div", { className: `input ${disabled ? 'input--disabled' : ''}` },
11
+ label && React.createElement("label", null, label),
12
+ React.createElement("div", { className: `input-container ${errorLabel ? 'input-container--error' : ''}` },
13
+ React.createElement("input", { type: type, value: value, disabled: disabled, onChange: handleChange, ...props }),
14
+ icon && React.createElement(Icon, { name: icon, size: "16" })),
15
+ errorLabel && (React.createElement("div", { className: "input--error" },
16
+ React.createElement(Icon, { name: "alert-circle-filled" }),
17
+ React.createElement("div", { className: "input--error-label" }, errorLabel)))));
18
+ };
19
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Inputs/Input/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc,EAAE,EAAE;IACnH,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,SAAS,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE;QACzD,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAE,mBAAmB,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7E,+BAAO,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,KAAM,KAAK,GAAI;YACzF,IAAI,IAAI,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC;QAEL,UAAU,IAAI,CACb,6BAAK,SAAS,EAAC,cAAc;YAC3B,oBAAC,IAAI,IAAC,IAAI,EAAC,qBAAqB,GAAG;YACnC,6BAAK,SAAS,EAAC,oBAAoB,IAAE,UAAU,CAAO,CAClD,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { ChangeEvent } from 'react';
3
+ import { Icon } from '../../Icon/Icon';
4
+ import { InputProps } from './Input.types';
5
+ import './Input.css';
6
+
7
+ export const Input = ({ errorLabel, icon, label, type = 'text', value, disabled, onChange, ...props }: InputProps) => {
8
+ // ########
9
+ // Handlers
10
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
11
+
12
+ // #########
13
+ // Rendering
14
+ return (
15
+ <div className={`input ${disabled ? 'input--disabled' : ''}`}>
16
+ {label && <label>{label}</label>}
17
+
18
+ <div className={`input-container ${errorLabel ? 'input-container--error' : ''}`}>
19
+ <input type={type} value={value} disabled={disabled} onChange={handleChange} {...props} />
20
+ {icon && <Icon name={icon} size="16" />}
21
+ </div>
22
+
23
+ {errorLabel && (
24
+ <div className="input--error">
25
+ <Icon name="alert-circle-filled" />
26
+ <div className="input--error-label">{errorLabel}</div>
27
+ </div>
28
+ )}
29
+ </div>
30
+ );
31
+ };
@@ -0,0 +1,10 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export type InputProps = {
3
+ errorLabel?: string;
4
+ icon?: string;
5
+ label?: string;
6
+ type?: 'text' | 'number';
7
+ value: string;
8
+ disabled?: boolean;
9
+ onChange: (value: string) => void;
10
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Input.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.types.js","sourceRoot":"","sources":["../../../../src/components/Inputs/Input/Input.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+
3
+ export type InputProps = {
4
+ errorLabel?: string;
5
+ icon?: string;
6
+ label?: string;
7
+ type?: 'text' | 'number';
8
+ value: string;
9
+ disabled?: boolean;
10
+ onChange: (value: string) => void;
11
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
3
- import { TextInput } from '../TextInput';
3
+ import { Input } from '../Input';
4
4
  import { icons } from '../../../Icon/icons';
5
5
 
6
- <Meta title="Components/Inputs/TextInput" />
6
+ <Meta title="Components/Inputs/Input" />
7
7
 
8
8
  export const inputArgTypes = {
9
9
  errorLabel: { control: 'text', description: 'Show error on the input.' },
@@ -20,32 +20,24 @@ export const inputArgTypes = {
20
20
  control: 'text',
21
21
  description: 'Placeholder displayed when the input is empty.',
22
22
  },
23
+ type: {
24
+ control: 'select',
25
+ options: ['text', 'number'],
26
+ description: 'Type of the input.',
27
+ },
23
28
  value: {
24
29
  control: 'text',
25
30
  description: 'Value of the input.',
26
31
  },
27
- autofocus: {
28
- control: 'boolean',
29
- description: 'Auto focus the input once mounted',
30
- table: { defaultValue: { summary: 'false' } },
31
- },
32
32
  disabled: {
33
33
  control: 'boolean',
34
34
  description: 'Auto focus the input once mounted',
35
35
  table: { defaultValue: { summary: 'false' } },
36
36
  },
37
- onBlur: {
38
- control: 'function',
39
- description: 'The handler called when the user blur the input.',
40
- },
41
37
  onChange: {
42
38
  control: 'function',
43
39
  description: 'The handler called when the value of the input changes.',
44
40
  },
45
- onFocus: {
46
- control: 'function',
47
- description: 'The handler called when the user focus the input.',
48
- },
49
41
  };
50
42
 
51
43
  # Text Input
@@ -61,16 +53,16 @@ Text input allows the user to enter content and data when the expected user inpu
61
53
  errorLabel: '',
62
54
  label: 'Label',
63
55
  placeholder: 'This is a placeholder',
56
+ type: 'text',
64
57
  value: '',
65
- autofocus: false,
66
58
  disabled: false,
67
59
  }}
68
60
  argTypes={inputArgTypes}
69
61
  >
70
- {args => <TextInput {...args} />}
62
+ {args => <Input type="number" {...args} />}
71
63
  </Story>
72
64
  </Canvas>
73
65
 
74
66
  ## Props
75
67
 
76
- <ArgsTable story="Overview" of={TextInput} />
68
+ <ArgsTable story="Overview" of={Input} />
package/esm/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from './components/Button/Button';
2
2
  export * from './components/Checkbox/Checkbox';
3
3
  export * from './components/Icon/Icon';
4
4
  export * from './components/Inputs/BooleanInput/BooleanInput';
5
- export * from './components/Inputs/TextInput/TextInput';
5
+ export * from './components/Inputs/Input/Input';
6
6
  export * from './components/Loader/Loader';
7
7
  export * from './components/Select/Select';
8
8
  export * from './layouts/Header/Header';
package/esm/index.js CHANGED
@@ -2,7 +2,7 @@ export * from './components/Button/Button';
2
2
  export * from './components/Checkbox/Checkbox';
3
3
  export * from './components/Icon/Icon';
4
4
  export * from './components/Inputs/BooleanInput/BooleanInput';
5
- export * from './components/Inputs/TextInput/TextInput';
5
+ export * from './components/Inputs/Input/Input';
6
6
  export * from './components/Loader/Loader';
7
7
  export * from './components/Select/Select';
8
8
  export * from './layouts/Header/Header';
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,yCAAyC,CAAC;AACxD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+CAA+C,CAAC;AAC9D,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC"}
@@ -1,23 +1,23 @@
1
- .text-input {
1
+ .input {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  }
5
- .text-input > label {
5
+ .input > label {
6
6
  display: block;
7
7
  margin-bottom: 4px;
8
8
  color: #012b49;
9
9
  font-weight: 700;
10
10
  }
11
- .text-input--disabled {
11
+ .input--disabled {
12
12
  opacity: 0.5;
13
13
  }
14
- .text-input--disabled .boolean-input-container > div {
14
+ .input--disabled .boolean-input-container > div {
15
15
  cursor: not-allowed;
16
16
  }
17
- .text-input-container {
17
+ .input-container {
18
18
  position: relative;
19
19
  }
20
- .text-input-container > input {
20
+ .input-container > input {
21
21
  width: 100%;
22
22
  height: 32px;
23
23
  padding: 0 40px 0 12px;
@@ -26,24 +26,27 @@
26
26
  color: #007dbc;
27
27
  font-weight: 700;
28
28
  }
29
- .text-input-container > input::placeholder {
29
+ .input-container > input::placeholder {
30
30
  font-weight: 400;
31
31
  }
32
- .text-input-container > .icon {
32
+ .input-container > .icon {
33
33
  position: absolute;
34
34
  top: 50%;
35
35
  right: 12px;
36
36
  color: #4e5d6b;
37
37
  transform: translateY(-50%);
38
38
  }
39
- .text-input--error {
39
+ .input--error {
40
40
  display: flex;
41
41
  align-items: center;
42
42
  color: #ed6a5e;
43
43
  font-size: 12px;
44
44
  font-weight: 600;
45
45
  }
46
- .text-input-container--error > input {
46
+ .input--error-label {
47
+ margin-left: 4px;
48
+ }
49
+ .input-container--error > input {
47
50
  border: 2px solid #ed6a5e;
48
51
  }
49
52
 
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { InputProps } from './Input.types';
3
+ import './Input.css';
4
+ export declare const Input: ({ errorLabel, icon, label, type, value, disabled, onChange, ...props }: InputProps) => React.JSX.Element;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Input = void 0;
4
+ const React = require("react");
5
+ const Icon_1 = require("../../Icon/Icon");
6
+ require("./Input.css");
7
+ const Input = ({ errorLabel, icon, label, type = 'text', value, disabled, onChange, ...props }) => {
8
+ // ########
9
+ // Handlers
10
+ const handleChange = (e) => onChange(e.target.value);
11
+ // #########
12
+ // Rendering
13
+ return (React.createElement("div", { className: `input ${disabled ? 'input--disabled' : ''}` },
14
+ label && React.createElement("label", null, label),
15
+ React.createElement("div", { className: `input-container ${errorLabel ? 'input-container--error' : ''}` },
16
+ React.createElement("input", { type: type, value: value, disabled: disabled, onChange: handleChange, ...props }),
17
+ icon && React.createElement(Icon_1.Icon, { name: icon, size: "16" })),
18
+ errorLabel && (React.createElement("div", { className: "input--error" },
19
+ React.createElement(Icon_1.Icon, { name: "alert-circle-filled" }),
20
+ React.createElement("div", { className: "input--error-label" }, errorLabel)))));
21
+ };
22
+ exports.Input = Input;
23
+ //# sourceMappingURL=Input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.js","sourceRoot":"","sources":["../../../../src/components/Inputs/Input/Input.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B,0CAAuC;AAEvC,uBAAqB;AAEd,MAAM,KAAK,GAAG,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAc,EAAE,EAAE;IACnH,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,SAAS,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE;QACzD,KAAK,IAAI,mCAAQ,KAAK,CAAS;QAEhC,6BAAK,SAAS,EAAE,mBAAmB,UAAU,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,EAAE;YAC7E,+BAAO,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,KAAM,KAAK,GAAI;YACzF,IAAI,IAAI,oBAAC,WAAI,IAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAC,IAAI,GAAG,CACnC;QAEL,UAAU,IAAI,CACb,6BAAK,SAAS,EAAC,cAAc;YAC3B,oBAAC,WAAI,IAAC,IAAI,EAAC,qBAAqB,GAAG;YACnC,6BAAK,SAAS,EAAC,oBAAoB,IAAE,UAAU,CAAO,CAClD,CACP,CACG,CACP,CAAC;AACJ,CAAC,CAAC;AAxBW,QAAA,KAAK,SAwBhB"}
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { ChangeEvent } from 'react';
3
+ import { Icon } from '../../Icon/Icon';
4
+ import { InputProps } from './Input.types';
5
+ import './Input.css';
6
+
7
+ export const Input = ({ errorLabel, icon, label, type = 'text', value, disabled, onChange, ...props }: InputProps) => {
8
+ // ########
9
+ // Handlers
10
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
11
+
12
+ // #########
13
+ // Rendering
14
+ return (
15
+ <div className={`input ${disabled ? 'input--disabled' : ''}`}>
16
+ {label && <label>{label}</label>}
17
+
18
+ <div className={`input-container ${errorLabel ? 'input-container--error' : ''}`}>
19
+ <input type={type} value={value} disabled={disabled} onChange={handleChange} {...props} />
20
+ {icon && <Icon name={icon} size="16" />}
21
+ </div>
22
+
23
+ {errorLabel && (
24
+ <div className="input--error">
25
+ <Icon name="alert-circle-filled" />
26
+ <div className="input--error-label">{errorLabel}</div>
27
+ </div>
28
+ )}
29
+ </div>
30
+ );
31
+ };
@@ -0,0 +1,10 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export type InputProps = {
3
+ errorLabel?: string;
4
+ icon?: string;
5
+ label?: string;
6
+ type?: 'text' | 'number';
7
+ value: string;
8
+ disabled?: boolean;
9
+ onChange: (value: string) => void;
10
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TextInput.types.js.map
3
+ //# sourceMappingURL=Input.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Input.types.js","sourceRoot":"","sources":["../../../../src/components/Inputs/Input/Input.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+
3
+ export type InputProps = {
4
+ errorLabel?: string;
5
+ icon?: string;
6
+ label?: string;
7
+ type?: 'text' | 'number';
8
+ value: string;
9
+ disabled?: boolean;
10
+ onChange: (value: string) => void;
11
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
3
- import { TextInput } from '../TextInput';
3
+ import { Input } from '../Input';
4
4
  import { icons } from '../../../Icon/icons';
5
5
 
6
- <Meta title="Components/Inputs/TextInput" />
6
+ <Meta title="Components/Inputs/Input" />
7
7
 
8
8
  export const inputArgTypes = {
9
9
  errorLabel: { control: 'text', description: 'Show error on the input.' },
@@ -20,32 +20,24 @@ export const inputArgTypes = {
20
20
  control: 'text',
21
21
  description: 'Placeholder displayed when the input is empty.',
22
22
  },
23
+ type: {
24
+ control: 'select',
25
+ options: ['text', 'number'],
26
+ description: 'Type of the input.',
27
+ },
23
28
  value: {
24
29
  control: 'text',
25
30
  description: 'Value of the input.',
26
31
  },
27
- autofocus: {
28
- control: 'boolean',
29
- description: 'Auto focus the input once mounted',
30
- table: { defaultValue: { summary: 'false' } },
31
- },
32
32
  disabled: {
33
33
  control: 'boolean',
34
34
  description: 'Auto focus the input once mounted',
35
35
  table: { defaultValue: { summary: 'false' } },
36
36
  },
37
- onBlur: {
38
- control: 'function',
39
- description: 'The handler called when the user blur the input.',
40
- },
41
37
  onChange: {
42
38
  control: 'function',
43
39
  description: 'The handler called when the value of the input changes.',
44
40
  },
45
- onFocus: {
46
- control: 'function',
47
- description: 'The handler called when the user focus the input.',
48
- },
49
41
  };
50
42
 
51
43
  # Text Input
@@ -61,16 +53,16 @@ Text input allows the user to enter content and data when the expected user inpu
61
53
  errorLabel: '',
62
54
  label: 'Label',
63
55
  placeholder: 'This is a placeholder',
56
+ type: 'text',
64
57
  value: '',
65
- autofocus: false,
66
58
  disabled: false,
67
59
  }}
68
60
  argTypes={inputArgTypes}
69
61
  >
70
- {args => <TextInput {...args} />}
62
+ {args => <Input type="number" {...args} />}
71
63
  </Story>
72
64
  </Canvas>
73
65
 
74
66
  ## Props
75
67
 
76
- <ArgsTable story="Overview" of={TextInput} />
68
+ <ArgsTable story="Overview" of={Input} />
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export * from './components/Button/Button';
2
2
  export * from './components/Checkbox/Checkbox';
3
3
  export * from './components/Icon/Icon';
4
4
  export * from './components/Inputs/BooleanInput/BooleanInput';
5
- export * from './components/Inputs/TextInput/TextInput';
5
+ export * from './components/Inputs/Input/Input';
6
6
  export * from './components/Loader/Loader';
7
7
  export * from './components/Select/Select';
8
8
  export * from './layouts/Header/Header';
package/lib/index.js CHANGED
@@ -18,7 +18,7 @@ __exportStar(require("./components/Button/Button"), exports);
18
18
  __exportStar(require("./components/Checkbox/Checkbox"), exports);
19
19
  __exportStar(require("./components/Icon/Icon"), exports);
20
20
  __exportStar(require("./components/Inputs/BooleanInput/BooleanInput"), exports);
21
- __exportStar(require("./components/Inputs/TextInput/TextInput"), exports);
21
+ __exportStar(require("./components/Inputs/Input/Input"), exports);
22
22
  __exportStar(require("./components/Loader/Loader"), exports);
23
23
  __exportStar(require("./components/Select/Select"), exports);
24
24
  __exportStar(require("./layouts/Header/Header"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,gFAA8D;AAC9D,0EAAwD;AACxD,6DAA2C;AAC3C,6DAA2C;AAC3C,0DAAwC;AACxC,iEAA+C;AAC/C,kEAAgD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,gFAA8D;AAC9D,kEAAgD;AAChD,6DAA2C;AAC3C,6DAA2C;AAC3C,0DAAwC;AACxC,iEAA+C;AAC/C,kEAAgD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dktunited-techoff/techoff-suite-ui",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib",
6
6
  "module": "esm/index.js",
@@ -1,23 +1,23 @@
1
- .text-input {
1
+ .input {
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  }
5
- .text-input > label {
5
+ .input > label {
6
6
  display: block;
7
7
  margin-bottom: 4px;
8
8
  color: #012b49;
9
9
  font-weight: 700;
10
10
  }
11
- .text-input--disabled {
11
+ .input--disabled {
12
12
  opacity: 0.5;
13
13
  }
14
- .text-input--disabled .boolean-input-container > div {
14
+ .input--disabled .boolean-input-container > div {
15
15
  cursor: not-allowed;
16
16
  }
17
- .text-input-container {
17
+ .input-container {
18
18
  position: relative;
19
19
  }
20
- .text-input-container > input {
20
+ .input-container > input {
21
21
  width: 100%;
22
22
  height: 32px;
23
23
  padding: 0 40px 0 12px;
@@ -26,24 +26,27 @@
26
26
  color: #007dbc;
27
27
  font-weight: 700;
28
28
  }
29
- .text-input-container > input::placeholder {
29
+ .input-container > input::placeholder {
30
30
  font-weight: 400;
31
31
  }
32
- .text-input-container > .icon {
32
+ .input-container > .icon {
33
33
  position: absolute;
34
34
  top: 50%;
35
35
  right: 12px;
36
36
  color: #4e5d6b;
37
37
  transform: translateY(-50%);
38
38
  }
39
- .text-input--error {
39
+ .input--error {
40
40
  display: flex;
41
41
  align-items: center;
42
42
  color: #ed6a5e;
43
43
  font-size: 12px;
44
44
  font-weight: 600;
45
45
  }
46
- .text-input-container--error > input {
46
+ .input--error-label {
47
+ margin-left: 4px;
48
+ }
49
+ .input-container--error > input {
47
50
  border: 2px solid #ed6a5e;
48
51
  }
49
52
 
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+ import { ChangeEvent } from 'react';
3
+ import { Icon } from '../../Icon/Icon';
4
+ import { InputProps } from './Input.types';
5
+ import './Input.css';
6
+
7
+ export const Input = ({ errorLabel, icon, label, type = 'text', value, disabled, onChange, ...props }: InputProps) => {
8
+ // ########
9
+ // Handlers
10
+ const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
11
+
12
+ // #########
13
+ // Rendering
14
+ return (
15
+ <div className={`input ${disabled ? 'input--disabled' : ''}`}>
16
+ {label && <label>{label}</label>}
17
+
18
+ <div className={`input-container ${errorLabel ? 'input-container--error' : ''}`}>
19
+ <input type={type} value={value} disabled={disabled} onChange={handleChange} {...props} />
20
+ {icon && <Icon name={icon} size="16" />}
21
+ </div>
22
+
23
+ {errorLabel && (
24
+ <div className="input--error">
25
+ <Icon name="alert-circle-filled" />
26
+ <div className="input--error-label">{errorLabel}</div>
27
+ </div>
28
+ )}
29
+ </div>
30
+ );
31
+ };
@@ -0,0 +1,11 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+
3
+ export type InputProps = {
4
+ errorLabel?: string;
5
+ icon?: string;
6
+ label?: string;
7
+ type?: 'text' | 'number';
8
+ value: string;
9
+ disabled?: boolean;
10
+ onChange: (value: string) => void;
11
+ } & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange'>;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { ArgsTable, Canvas, Meta, Story } from '@storybook/blocks';
3
- import { TextInput } from '../TextInput';
3
+ import { Input } from '../Input';
4
4
  import { icons } from '../../../Icon/icons';
5
5
 
6
- <Meta title="Components/Inputs/TextInput" />
6
+ <Meta title="Components/Inputs/Input" />
7
7
 
8
8
  export const inputArgTypes = {
9
9
  errorLabel: { control: 'text', description: 'Show error on the input.' },
@@ -20,32 +20,24 @@ export const inputArgTypes = {
20
20
  control: 'text',
21
21
  description: 'Placeholder displayed when the input is empty.',
22
22
  },
23
+ type: {
24
+ control: 'select',
25
+ options: ['text', 'number'],
26
+ description: 'Type of the input.',
27
+ },
23
28
  value: {
24
29
  control: 'text',
25
30
  description: 'Value of the input.',
26
31
  },
27
- autofocus: {
28
- control: 'boolean',
29
- description: 'Auto focus the input once mounted',
30
- table: { defaultValue: { summary: 'false' } },
31
- },
32
32
  disabled: {
33
33
  control: 'boolean',
34
34
  description: 'Auto focus the input once mounted',
35
35
  table: { defaultValue: { summary: 'false' } },
36
36
  },
37
- onBlur: {
38
- control: 'function',
39
- description: 'The handler called when the user blur the input.',
40
- },
41
37
  onChange: {
42
38
  control: 'function',
43
39
  description: 'The handler called when the value of the input changes.',
44
40
  },
45
- onFocus: {
46
- control: 'function',
47
- description: 'The handler called when the user focus the input.',
48
- },
49
41
  };
50
42
 
51
43
  # Text Input
@@ -61,16 +53,16 @@ Text input allows the user to enter content and data when the expected user inpu
61
53
  errorLabel: '',
62
54
  label: 'Label',
63
55
  placeholder: 'This is a placeholder',
56
+ type: 'text',
64
57
  value: '',
65
- autofocus: false,
66
58
  disabled: false,
67
59
  }}
68
60
  argTypes={inputArgTypes}
69
61
  >
70
- {args => <TextInput {...args} />}
62
+ {args => <Input type="number" {...args} />}
71
63
  </Story>
72
64
  </Canvas>
73
65
 
74
66
  ## Props
75
67
 
76
- <ArgsTable story="Overview" of={TextInput} />
68
+ <ArgsTable story="Overview" of={Input} />
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ export * from './components/Button/Button';
2
2
  export * from './components/Checkbox/Checkbox';
3
3
  export * from './components/Icon/Icon';
4
4
  export * from './components/Inputs/BooleanInput/BooleanInput';
5
- export * from './components/Inputs/TextInput/TextInput';
5
+ export * from './components/Inputs/Input/Input';
6
6
  export * from './components/Loader/Loader';
7
7
  export * from './components/Select/Select';
8
8
  export * from './layouts/Header/Header';
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { TextInputProps } from './TextInput.types';
3
- import './TextInput.css';
4
- export declare const TextInput: ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }: TextInputProps) => React.JSX.Element;
@@ -1,17 +0,0 @@
1
- import * as React from 'react';
2
- import { Icon } from '../../Icon/Icon';
3
- import './TextInput.css';
4
- export const TextInput = ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }) => {
5
- // ########
6
- // Handlers
7
- const handleChange = (e) => onChange(e.target.value);
8
- // #########
9
- // Rendering
10
- return (React.createElement("div", { className: `text-input ${disabled ? 'text-input--disabled' : ''}` },
11
- label && React.createElement("label", null, label),
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)));
16
- };
17
- //# sourceMappingURL=TextInput.js.map
@@ -1 +0,0 @@
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"}
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import { ChangeEvent } from 'react';
3
- import { Icon } from '../../Icon/Icon';
4
- import { TextInputProps } from './TextInput.types';
5
- import './TextInput.css';
6
-
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) => {
19
- // ########
20
- // Handlers
21
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
22
-
23
- // #########
24
- // Rendering
25
- return (
26
- <div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
27
- {label && <label>{label}</label>}
28
-
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
- />
40
- {icon && <Icon name={icon} size="16" />}
41
- </div>
42
-
43
- {errorLabel && <div className="text-input--error">{errorLabel}</div>}
44
- </div>
45
- );
46
- };
@@ -1,12 +0,0 @@
1
- export type TextInputProps = {
2
- errorLabel?: string;
3
- icon?: string;
4
- label?: string;
5
- placeholder?: string;
6
- value: string;
7
- autofocus?: boolean;
8
- disabled?: boolean;
9
- onBlur?: () => void;
10
- onChange: (value: string) => void;
11
- onFocus?: () => void;
12
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TextInput.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextInput.types.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.types.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- export type TextInputProps = {
2
- errorLabel?: string;
3
- icon?: string;
4
- label?: string;
5
- placeholder?: string;
6
- value: string;
7
- autofocus?: boolean;
8
- disabled?: boolean;
9
- onBlur?: () => void;
10
- onChange: (value: string) => void;
11
- onFocus?: () => void;
12
- };
@@ -1,4 +0,0 @@
1
- import * as React from 'react';
2
- import { TextInputProps } from './TextInput.types';
3
- import './TextInput.css';
4
- export declare const TextInput: ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }: TextInputProps) => React.JSX.Element;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextInput = void 0;
4
- const React = require("react");
5
- const Icon_1 = require("../../Icon/Icon");
6
- require("./TextInput.css");
7
- const TextInput = ({ errorLabel, icon, label, placeholder, value, autofocus, disabled, onBlur, onChange, onFocus, }) => {
8
- // ########
9
- // Handlers
10
- const handleChange = (e) => onChange(e.target.value);
11
- // #########
12
- // Rendering
13
- return (React.createElement("div", { className: `text-input ${disabled ? 'text-input--disabled' : ''}` },
14
- label && React.createElement("label", null, label),
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)));
19
- };
20
- exports.TextInput = TextInput;
21
- //# sourceMappingURL=TextInput.js.map
@@ -1 +0,0 @@
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"}
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import { ChangeEvent } from 'react';
3
- import { Icon } from '../../Icon/Icon';
4
- import { TextInputProps } from './TextInput.types';
5
- import './TextInput.css';
6
-
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) => {
19
- // ########
20
- // Handlers
21
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
22
-
23
- // #########
24
- // Rendering
25
- return (
26
- <div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
27
- {label && <label>{label}</label>}
28
-
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
- />
40
- {icon && <Icon name={icon} size="16" />}
41
- </div>
42
-
43
- {errorLabel && <div className="text-input--error">{errorLabel}</div>}
44
- </div>
45
- );
46
- };
@@ -1,12 +0,0 @@
1
- export type TextInputProps = {
2
- errorLabel?: string;
3
- icon?: string;
4
- label?: string;
5
- placeholder?: string;
6
- value: string;
7
- autofocus?: boolean;
8
- disabled?: boolean;
9
- onBlur?: () => void;
10
- onChange: (value: string) => void;
11
- onFocus?: () => void;
12
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextInput.types.js","sourceRoot":"","sources":["../../../../src/components/Inputs/TextInput/TextInput.types.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- export type TextInputProps = {
2
- errorLabel?: string;
3
- icon?: string;
4
- label?: string;
5
- placeholder?: string;
6
- value: string;
7
- autofocus?: boolean;
8
- disabled?: boolean;
9
- onBlur?: () => void;
10
- onChange: (value: string) => void;
11
- onFocus?: () => void;
12
- };
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import { ChangeEvent } from 'react';
3
- import { Icon } from '../../Icon/Icon';
4
- import { TextInputProps } from './TextInput.types';
5
- import './TextInput.css';
6
-
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) => {
19
- // ########
20
- // Handlers
21
- const handleChange = (e: ChangeEvent<HTMLInputElement>) => onChange(e.target.value);
22
-
23
- // #########
24
- // Rendering
25
- return (
26
- <div className={`text-input ${disabled ? 'text-input--disabled' : ''}`}>
27
- {label && <label>{label}</label>}
28
-
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
- />
40
- {icon && <Icon name={icon} size="16" />}
41
- </div>
42
-
43
- {errorLabel && <div className="text-input--error">{errorLabel}</div>}
44
- </div>
45
- );
46
- };
@@ -1,12 +0,0 @@
1
- export type TextInputProps = {
2
- errorLabel?: string;
3
- icon?: string;
4
- label?: string;
5
- placeholder?: string;
6
- value: string;
7
- autofocus?: boolean;
8
- disabled?: boolean;
9
- onBlur?: () => void;
10
- onChange: (value: string) => void;
11
- onFocus?: () => void;
12
- };