@scality/core-ui 0.117.0 → 0.119.0

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 (63) hide show
  1. package/dist/components/buttonv2/Buttonv2.component.js +2 -2
  2. package/dist/components/card/Card.component.d.ts +1 -1
  3. package/dist/components/card/Card.component.d.ts.map +1 -1
  4. package/dist/components/card/Card.component.js +7 -13
  5. package/dist/components/checkbox/Checkbox.component.js +2 -2
  6. package/dist/components/dropdown/Dropdown.component.d.ts.map +1 -1
  7. package/dist/components/dropdown/Dropdown.component.js +0 -1
  8. package/dist/components/inputv2/inputv2.d.ts +1 -2
  9. package/dist/components/inputv2/inputv2.d.ts.map +1 -1
  10. package/dist/components/inputv2/inputv2.js +5 -3
  11. package/dist/components/searchinput/SearchInput.component.d.ts +3 -0
  12. package/dist/components/searchinput/SearchInput.component.d.ts.map +1 -1
  13. package/dist/components/searchinput/SearchInput.component.js +33 -52
  14. package/dist/components/sidebar/Sidebar.component.d.ts.map +1 -1
  15. package/dist/components/sidebar/Sidebar.component.js +8 -7
  16. package/dist/components/tablev2/Search.d.ts +1 -1
  17. package/dist/components/tablev2/Search.d.ts.map +1 -1
  18. package/dist/components/tablev2/Search.js +1 -1
  19. package/dist/components/tablev2/SearchWithQueryParams.d.ts +2 -2
  20. package/dist/components/tablev2/SearchWithQueryParams.d.ts.map +1 -1
  21. package/dist/components/tablev2/SearchWithQueryParams.js +1 -1
  22. package/dist/components/tablev2/Tablestyle.js +2 -2
  23. package/dist/components/vegachartv2/VegaChartV2.component.d.ts.map +1 -1
  24. package/dist/components/vegachartv2/VegaChartV2.component.js +44 -42
  25. package/dist/icons/branding-logo.d.ts +4 -0
  26. package/dist/icons/branding-logo.d.ts.map +1 -0
  27. package/dist/icons/branding-logo.js +3 -0
  28. package/dist/index.d.ts +0 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +0 -1
  31. package/dist/style/theme.js +15 -15
  32. package/package.json +16 -16
  33. package/src/lib/components/buttonv2/Buttonv2.component.tsx +2 -2
  34. package/src/lib/components/card/Card.component.tsx +10 -19
  35. package/src/lib/components/checkbox/Checkbox.component.tsx +14 -2
  36. package/src/lib/components/dropdown/Dropdown.component.tsx +0 -1
  37. package/src/lib/components/inputv2/inputv2.tsx +19 -24
  38. package/src/lib/components/searchinput/SearchInput.component.tsx +54 -62
  39. package/src/lib/components/sidebar/Sidebar.component.tsx +8 -9
  40. package/src/lib/components/tablev2/Search.tsx +2 -1
  41. package/src/lib/components/tablev2/SearchWithQueryParams.tsx +4 -3
  42. package/src/lib/components/tablev2/Tablestyle.tsx +2 -2
  43. package/src/lib/components/vegachartv2/VegaChartV2.component.tsx +47 -50
  44. package/src/lib/icons/branding-logo.tsx +47 -0
  45. package/src/lib/index.ts +0 -1
  46. package/src/lib/style/theme.ts +15 -15
  47. package/stories/card.stories.tsx +4 -11
  48. package/stories/color.mdx +3 -3
  49. package/stories/layout.stories.tsx +11 -60
  50. package/stories/navbar.stories.tsx +4 -2
  51. package/stories/searchinput.stories.tsx +21 -1
  52. package/stories/spacing.stories.tsx +8 -8
  53. package/stories/steppers.stories.tsx +14 -15
  54. package/stories/tablev2.stories.tsx +23 -10
  55. package/stories/tabsv2.stories.tsx +0 -2
  56. package/dist/components/input/Input.component.d.ts +0 -24
  57. package/dist/components/input/Input.component.d.ts.map +0 -1
  58. package/dist/components/input/Input.component.js +0 -55
  59. package/dist/components/input/Input.component.style.d.ts +0 -9
  60. package/dist/components/input/Input.component.style.d.ts.map +0 -1
  61. package/dist/components/input/Input.component.style.js +0 -136
  62. package/src/lib/components/input/Input.component.style.ts +0 -141
  63. package/src/lib/components/input/Input.component.tsx +0 -174
@@ -6,7 +6,11 @@ import {
6
6
  Table,
7
7
  } from '../src/lib/components/tablev2/Tablev2.component';
8
8
  import { Wrapper, Title } from './common';
9
- import { BrowserRouter as Router, useLocation } from 'react-router-dom';
9
+ import {
10
+ BrowserRouter,
11
+ BrowserRouter as Router,
12
+ useLocation,
13
+ } from 'react-router-dom';
10
14
  import { CellProps, Row } from 'react-table';
11
15
  import { Box, Button } from '../src/lib/next';
12
16
  import styled from 'styled-components';
@@ -324,15 +328,24 @@ export const asyncTable = {
324
328
  paddingTop: '20px',
325
329
  }}
326
330
  >
327
- <Table columns={columnAsync} data={data} defaultSortingKey={'health'}>
328
- <Table.SingleSelectableContent
329
- rowHeight="h40"
330
- separationLineVariant="backgroundLevel3"
331
- backgroundVariant="backgroundLevel1"
332
- selectedId={'Rodolph Yohann'}
333
- onRowSelected={action('Table Row Clicked')}
334
- />
335
- </Table>
331
+ <BrowserRouter>
332
+ <Table
333
+ columns={columnAsync}
334
+ data={data}
335
+ defaultSortingKey={'health'}
336
+ >
337
+ <Table.SearchWithQueryParams
338
+ displayedName={{ singular: 'user', plural: 'users' }}
339
+ ></Table.SearchWithQueryParams>
340
+ <Table.SingleSelectableContent
341
+ rowHeight="h40"
342
+ separationLineVariant="backgroundLevel3"
343
+ backgroundVariant="backgroundLevel1"
344
+ selectedId={'Rodolph Yohann'}
345
+ onRowSelected={action('Table Row Clicked')}
346
+ />
347
+ </Table>
348
+ </BrowserRouter>
336
349
  </div>
337
350
  </Wrapper>
338
351
  );
@@ -28,8 +28,6 @@ const messages = [
28
28
  'Long',
29
29
  'Really long long long long long',
30
30
  'Hello',
31
- 'Metalk8s',
32
- 'ZENKO-UI',
33
31
  ];
34
32
 
35
33
  const generateTab = (n = 10, selectedIndex = 0) => {
@@ -1,24 +0,0 @@
1
- import { ChangeEvent, HTMLAttributes, HTMLProps } from 'react';
2
- import { DebounceInputProps } from 'react-debounce-input';
3
- export type Item = {
4
- label: string;
5
- value: string | number;
6
- };
7
- type Items = Array<Item>;
8
- export type InputProps = {
9
- value: any;
10
- type?: string;
11
- label?: string;
12
- title?: string;
13
- error?: string;
14
- id?: string;
15
- checked?: boolean;
16
- onChange: (e: ChangeEvent<HTMLInputElement>) => void;
17
- options?: Items;
18
- disabled?: boolean;
19
- min?: string;
20
- max?: string;
21
- } & HTMLProps<HTMLInputElement> & DebounceInputProps<HTMLInputElement, HTMLAttributes<HTMLInputElement>>;
22
- declare const Input: ({ label, id, error, type, disabled, ...rest }: InputProps) => JSX.Element;
23
- export { Input };
24
- //# sourceMappingURL=Input.component.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.component.d.ts","sourceRoot":"","sources":["../../../src/lib/components/input/Input.component.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AACvE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAWzE,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AACF,KAAK,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,KAAK,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,GAAG,SAAS,CAAC,gBAAgB,CAAC,GAC7B,kBAAkB,CAAC,gBAAgB,EAAE,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAoHzE,QAAA,MAAM,KAAK,kDAAmD,UAAU,gBAuBvE,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC"}
@@ -1,55 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // @ts-nocheck
3
- import { useRef } from 'react';
4
- import { DebounceInput } from 'react-debounce-input';
5
- import { Checkbox } from '../checkbox/Checkbox.component';
6
- import { Icon } from '../icon/Icon.component';
7
- import { Select } from '../select/Select.component';
8
- import { TextArea } from '../textarea/TextArea.component';
9
- import { InputContainer, LabelStyle, InputErrorMessage, InputWrapper, } from './Input.component.style';
10
- const InputRenderer = ({ type, id, value, checked, onChange, options = [], min, max, ...rest }) => {
11
- const inputEl = useRef(null);
12
- const handleNumberClick = (e) => {
13
- /*
14
- ** Since react is using Synthetic event we have to do the following to be
15
- ** able to programmatically dispatch the onChange event from the input
16
- */
17
- const valuePropDescriptor = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value');
18
- if (valuePropDescriptor && inputEl.current) {
19
- const nativeInputValueSetter = valuePropDescriptor.set;
20
- if (nativeInputValueSetter) {
21
- if (e.target.dataset.core === 'up')
22
- nativeInputValueSetter.call(inputEl.current, max
23
- ? max && parseInt(value) + 1 <= parseInt(max)
24
- ? parseInt(value) + 1
25
- : parseInt(value)
26
- : parseInt(value) + 1);
27
- else
28
- nativeInputValueSetter.call(inputEl.current, min
29
- ? min && parseInt(value) - 1 >= parseInt(min)
30
- ? parseInt(value) - 1
31
- : parseInt(value)
32
- : parseInt(value) - 1);
33
- }
34
- const event = new Event('input', {
35
- bubbles: true,
36
- });
37
- inputEl.current.dispatchEvent(event);
38
- }
39
- };
40
- const input = {
41
- select: (_jsx(Select, { id: id, value: value, onChange: onChange, options: options, ...rest })),
42
- checkbox: (_jsx(Checkbox, { id: id, value: value, checked: !!checked, onChange: onChange, ...rest })),
43
- textarea: _jsx(TextArea, { id: id, value: value, onChange: onChange, ...rest }),
44
- number: (_jsxs("div", { className: "sc-number-input-wrapper", children: [_jsx("input", { className: "sc-input-type sc-number-input", type: "number", id: id, value: value, onChange: onChange, ref: inputEl, min: min, max: max, ...rest }), _jsxs("div", { className: "carets-wrapper", children: [_jsx(Icon, { name: "Dropdown-up", "data-core": "up", onClick: handleNumberClick }), _jsx(Icon, { name: "Dropdown-down", "data-core": "down", onClick: handleNumberClick })] })] })),
45
- text: (_jsx(DebounceInput, { className: "sc-input-type", minLength: 1, debounceTimeout: 300, id: id, value: value, onChange: onChange, autoComplete: "off", ...rest })),
46
- };
47
- if (type)
48
- return input[type];
49
- else
50
- return input.text;
51
- };
52
- const Input = ({ label, id, error, type, disabled, ...rest }) => {
53
- return (_jsxs(InputContainer, { className: "sc-input", disabled: disabled, error: error, type: type, children: [label && (_jsx(LabelStyle, { htmlFor: id, className: "sc-input-label", children: label })), _jsxs(InputWrapper, { className: "sc-input-wrapper", children: [_jsx(InputRenderer, { id: id, type: type, disabled: disabled, ...rest }), error && (_jsx(InputErrorMessage, { className: "sc-input-error", children: error }))] })] }));
54
- };
55
- export { Input };
@@ -1,9 +0,0 @@
1
- export declare const InputContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
2
- disabled: boolean;
3
- error: string;
4
- type: string;
5
- }, never>;
6
- export declare const LabelStyle: import("styled-components").StyledComponent<"label", import("styled-components").DefaultTheme, {}, never>;
7
- export declare const InputErrorMessage: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {}, never>;
8
- export declare const InputWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
9
- //# sourceMappingURL=Input.component.style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Input.component.style.d.ts","sourceRoot":"","sources":["../../../src/lib/components/input/Input.component.style.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;cACf,OAAO;WACV,MAAM;UACP,MAAM;SAsHb,CAAC;AACF,eAAO,MAAM,UAAU,2GAKtB,CAAC;AACF,eAAO,MAAM,iBAAiB,0GAI7B,CAAC;AACF,eAAO,MAAM,YAAY,yGAGxB,CAAC"}
@@ -1,136 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import { spacing } from '../../spacing';
3
- import { fontSize } from '../../style/theme';
4
- import { getThemePropSelector } from '../../utils';
5
- export const InputContainer = styled.div `
6
- display: inline-flex;
7
- ${(props) => {
8
- if (props.disabled) {
9
- return css `
10
- opacity: 0.3;
11
- input,
12
- textarea,
13
- select,
14
- i {
15
- cursor: not-allowed;
16
- }
17
- `;
18
- }
19
- }}
20
- .sc-checkbox {
21
- margin: ${spacing.r4} 0;
22
- }
23
-
24
- &.sc-select {
25
- width: 200px;
26
- }
27
-
28
- input.sc-input-type {
29
- ${(props) => {
30
- const { backgroundLevel1, statusCritical, textSecondary, border } = props.theme;
31
- return css `
32
- background-color: ${backgroundLevel1};
33
- color: ${textSecondary};
34
- border: 1px solid ${props.error ? statusCritical : border};
35
- `;
36
- }};
37
- padding: 8px ${spacing.r8};
38
- font-size: ${fontSize.base};
39
- display: block;
40
- border-radius: 4px;
41
- }
42
-
43
- input.sc-input-type:focus {
44
- border-color: ${getThemePropSelector('selectedActive')};
45
- outline: none;
46
- }
47
-
48
- input[type='number'] {
49
- /* Adding a padding to make room for the custom absolute postionned arrows */
50
- padding-right: 20px;
51
- -moz-appearance: textfield; /*For FireFox*/
52
-
53
- &::-webkit-inner-spin-button {
54
- /*For Webkits like Chrome and Safari*/
55
- -webkit-appearance: none;
56
- margin: 0;
57
- }
58
- }
59
-
60
- ${(props) => {
61
- if (props.type === 'number')
62
- return css `
63
- .sc-input-wrapper {
64
- .sc-number-input-wrapper {
65
- position: relative;
66
- }
67
- align-items: baseline;
68
- .carets-wrapper {
69
- display: flex;
70
- flex-direction: column;
71
- ${(props) => {
72
- const { textSecondary } = props.theme;
73
- return css `
74
- color: ${textSecondary};
75
- `;
76
- }};
77
- position: absolute;
78
- right: ${spacing.r4};
79
- top: 50%;
80
- transform: translate(-50%, -50%);
81
-
82
- i {
83
- font-size: 0.8em;
84
- cursor: pointer;
85
- }
86
- }
87
- }
88
- `;
89
- }}
90
-
91
- ${(props) => {
92
- if (props.error) {
93
- return css `
94
- @keyframes shake {
95
- from,
96
- to {
97
- transform: translate3d(0, 0, 0);
98
- }
99
-
100
- 10%,
101
- 30%,
102
- 50%,
103
- 70%,
104
- 90% {
105
- transform: translate3d(-5px, 0, 0);
106
- }
107
-
108
- 20%,
109
- 40%,
110
- 60%,
111
- 80% {
112
- transform: translate3d(5px, 0, 0);
113
- }
114
- }
115
- animation-duration: 1s;
116
- animation-fill-mode: both;
117
- animation-name: shake;
118
- `;
119
- }
120
- }};
121
- `;
122
- export const LabelStyle = styled.label `
123
- align-self: flex-start;
124
- padding: ${spacing.r8};
125
- font-size: ${fontSize.base};
126
- color: ${getThemePropSelector('textPrimary')};
127
- `;
128
- export const InputErrorMessage = styled.span `
129
- color: ${getThemePropSelector('statusCritical')};
130
- margin: ${spacing.r4} 0;
131
- font-size: ${fontSize.small};
132
- `;
133
- export const InputWrapper = styled.div `
134
- display: flex;
135
- flex-direction: column;
136
- `;
@@ -1,141 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import { spacing } from '../../spacing';
3
- import { fontSize } from '../../style/theme';
4
- import { getThemePropSelector } from '../../utils';
5
- export const InputContainer = styled.div<{
6
- disabled: boolean;
7
- error: string;
8
- type: string;
9
- }>`
10
- display: inline-flex;
11
- ${(props) => {
12
- if (props.disabled) {
13
- return css`
14
- opacity: 0.3;
15
- input,
16
- textarea,
17
- select,
18
- i {
19
- cursor: not-allowed;
20
- }
21
- `;
22
- }
23
- }}
24
- .sc-checkbox {
25
- margin: ${spacing.r4} 0;
26
- }
27
-
28
- &.sc-select {
29
- width: 200px;
30
- }
31
-
32
- input.sc-input-type {
33
- ${(props) => {
34
- const { backgroundLevel1, statusCritical, textSecondary, border } =
35
- props.theme;
36
- return css`
37
- background-color: ${backgroundLevel1};
38
- color: ${textSecondary};
39
- border: 1px solid ${props.error ? statusCritical : border};
40
- `;
41
- }};
42
- padding: 8px ${spacing.r8};
43
- font-size: ${fontSize.base};
44
- display: block;
45
- border-radius: 4px;
46
- }
47
-
48
- input.sc-input-type:focus {
49
- border-color: ${getThemePropSelector('selectedActive')};
50
- outline: none;
51
- }
52
-
53
- input[type='number'] {
54
- /* Adding a padding to make room for the custom absolute postionned arrows */
55
- padding-right: 20px;
56
- -moz-appearance: textfield; /*For FireFox*/
57
-
58
- &::-webkit-inner-spin-button {
59
- /*For Webkits like Chrome and Safari*/
60
- -webkit-appearance: none;
61
- margin: 0;
62
- }
63
- }
64
-
65
- ${(props) => {
66
- if (props.type === 'number')
67
- return css`
68
- .sc-input-wrapper {
69
- .sc-number-input-wrapper {
70
- position: relative;
71
- }
72
- align-items: baseline;
73
- .carets-wrapper {
74
- display: flex;
75
- flex-direction: column;
76
- ${(props) => {
77
- const { textSecondary } = props.theme;
78
- return css`
79
- color: ${textSecondary};
80
- `;
81
- }};
82
- position: absolute;
83
- right: ${spacing.r4};
84
- top: 50%;
85
- transform: translate(-50%, -50%);
86
-
87
- i {
88
- font-size: 0.8em;
89
- cursor: pointer;
90
- }
91
- }
92
- }
93
- `;
94
- }}
95
-
96
- ${(props) => {
97
- if (props.error) {
98
- return css`
99
- @keyframes shake {
100
- from,
101
- to {
102
- transform: translate3d(0, 0, 0);
103
- }
104
-
105
- 10%,
106
- 30%,
107
- 50%,
108
- 70%,
109
- 90% {
110
- transform: translate3d(-5px, 0, 0);
111
- }
112
-
113
- 20%,
114
- 40%,
115
- 60%,
116
- 80% {
117
- transform: translate3d(5px, 0, 0);
118
- }
119
- }
120
- animation-duration: 1s;
121
- animation-fill-mode: both;
122
- animation-name: shake;
123
- `;
124
- }
125
- }};
126
- `;
127
- export const LabelStyle = styled.label`
128
- align-self: flex-start;
129
- padding: ${spacing.r8};
130
- font-size: ${fontSize.base};
131
- color: ${getThemePropSelector('textPrimary')};
132
- `;
133
- export const InputErrorMessage = styled.span`
134
- color: ${getThemePropSelector('statusCritical')};
135
- margin: ${spacing.r4} 0;
136
- font-size: ${fontSize.small};
137
- `;
138
- export const InputWrapper = styled.div`
139
- display: flex;
140
- flex-direction: column;
141
- `;
@@ -1,174 +0,0 @@
1
- // @ts-nocheck
2
- import { ChangeEvent, HTMLAttributes, HTMLProps, useRef } from 'react';
3
- import { DebounceInput, DebounceInputProps } from 'react-debounce-input';
4
- import { Checkbox } from '../checkbox/Checkbox.component';
5
- import { Icon } from '../icon/Icon.component';
6
- import { Select } from '../select/Select.component';
7
- import { TextArea } from '../textarea/TextArea.component';
8
- import {
9
- InputContainer,
10
- LabelStyle,
11
- InputErrorMessage,
12
- InputWrapper,
13
- } from './Input.component.style';
14
- export type Item = {
15
- label: string;
16
- value: string | number;
17
- };
18
- type Items = Array<Item>;
19
- export type InputProps = {
20
- value: any;
21
- type?: string;
22
- label?: string;
23
- title?: string;
24
- error?: string;
25
- id?: string;
26
- checked?: boolean;
27
- onChange: (e: ChangeEvent<HTMLInputElement>) => void;
28
- options?: Items;
29
- disabled?: boolean;
30
- min?: string;
31
- max?: string;
32
- } & HTMLProps<HTMLInputElement> &
33
- DebounceInputProps<HTMLInputElement, HTMLAttributes<HTMLInputElement>>;
34
-
35
- const InputRenderer = ({
36
- type,
37
- id,
38
- value,
39
- checked,
40
- onChange,
41
- options = [],
42
- min,
43
- max,
44
- ...rest
45
- }) => {
46
- const inputEl = useRef(null);
47
-
48
- const handleNumberClick = (e) => {
49
- /*
50
- ** Since react is using Synthetic event we have to do the following to be
51
- ** able to programmatically dispatch the onChange event from the input
52
- */
53
- const valuePropDescriptor = Object.getOwnPropertyDescriptor(
54
- window.HTMLInputElement.prototype,
55
- 'value',
56
- );
57
-
58
- if (valuePropDescriptor && inputEl.current) {
59
- const nativeInputValueSetter = valuePropDescriptor.set;
60
-
61
- if (nativeInputValueSetter) {
62
- if (e.target.dataset.core === 'up')
63
- nativeInputValueSetter.call(
64
- inputEl.current,
65
- max
66
- ? max && parseInt(value) + 1 <= parseInt(max)
67
- ? parseInt(value) + 1
68
- : parseInt(value)
69
- : parseInt(value) + 1,
70
- );
71
- else
72
- nativeInputValueSetter.call(
73
- inputEl.current,
74
- min
75
- ? min && parseInt(value) - 1 >= parseInt(min)
76
- ? parseInt(value) - 1
77
- : parseInt(value)
78
- : parseInt(value) - 1,
79
- );
80
- }
81
-
82
- const event = new Event('input', {
83
- bubbles: true,
84
- });
85
- inputEl.current.dispatchEvent(event);
86
- }
87
- };
88
-
89
- const input = {
90
- select: (
91
- <Select
92
- id={id}
93
- value={value}
94
- onChange={onChange}
95
- options={options}
96
- {...rest}
97
- />
98
- ),
99
- checkbox: (
100
- <Checkbox
101
- id={id}
102
- value={value}
103
- checked={!!checked}
104
- onChange={onChange}
105
- {...rest}
106
- />
107
- ),
108
- textarea: <TextArea id={id} value={value} onChange={onChange} {...rest} />,
109
- number: (
110
- <div className="sc-number-input-wrapper">
111
- <input
112
- className="sc-input-type sc-number-input"
113
- type="number"
114
- id={id}
115
- value={value}
116
- onChange={onChange}
117
- ref={inputEl}
118
- min={min}
119
- max={max}
120
- {...rest}
121
- />
122
- <div className="carets-wrapper">
123
- <Icon name="Dropdown-up" data-core="up" onClick={handleNumberClick} />
124
- <Icon
125
- name="Dropdown-down"
126
- data-core="down"
127
- onClick={handleNumberClick}
128
- />
129
- </div>
130
- </div>
131
- ),
132
- text: (
133
- <DebounceInput
134
- className="sc-input-type"
135
- minLength={1}
136
- debounceTimeout={300}
137
- id={id}
138
- value={value}
139
- onChange={onChange}
140
- autoComplete="off"
141
- {...rest}
142
- />
143
- ),
144
- };
145
- if (type) return input[type];
146
- else return input.text;
147
- };
148
-
149
- const Input = ({ label, id, error, type, disabled, ...rest }: InputProps) => {
150
- return (
151
- <InputContainer
152
- className="sc-input"
153
- disabled={disabled}
154
- error={error}
155
- type={type}
156
- >
157
- {label && (
158
- <LabelStyle htmlFor={id} className="sc-input-label">
159
- {label}
160
- </LabelStyle>
161
- )}
162
- <InputWrapper className="sc-input-wrapper">
163
- <InputRenderer id={id} type={type} disabled={disabled} {...rest} />
164
- {error && (
165
- <InputErrorMessage className="sc-input-error">
166
- {error}
167
- </InputErrorMessage>
168
- )}
169
- </InputWrapper>
170
- </InputContainer>
171
- );
172
- };
173
-
174
- export { Input };