norma-library 0.6.6 → 0.6.62

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 (164) hide show
  1. package/.babelrc.json +18 -18
  2. package/.prettierignore +10 -10
  3. package/.prettierrc.json +20 -20
  4. package/.storybook/main.ts +20 -20
  5. package/.storybook/preview.ts +15 -15
  6. package/README.md +43 -43
  7. package/commitlint.config.js +1 -1
  8. package/dist/esm/helpers/colors.js +1 -1
  9. package/docs/index.md +118 -118
  10. package/package.json +136 -136
  11. package/src/components/Accordion.tsx +39 -39
  12. package/src/components/Avatar.tsx +17 -17
  13. package/src/components/Badge.tsx +14 -14
  14. package/src/components/Box/index.tsx +12 -12
  15. package/src/components/Box/interfaces.ts +3 -3
  16. package/src/components/Box/styles.tsx +22 -22
  17. package/src/components/Breadcrumb/index.tsx +27 -27
  18. package/src/components/Breadcrumb/interface.ts +8 -8
  19. package/src/components/Breadcrumb/styles.tsx +32 -32
  20. package/src/components/Button.tsx +26 -26
  21. package/src/components/Card.tsx +37 -37
  22. package/src/components/ChatMessage.tsx +87 -87
  23. package/src/components/ChatMessageBalloon/ChatMessageBalloon.style.ts +56 -56
  24. package/src/components/ChatMessageBalloon/ChatMessageBalloon.tsx +55 -55
  25. package/src/components/CheckBox.tsx +21 -21
  26. package/src/components/DateInput/index.tsx +34 -34
  27. package/src/components/DateInput/interface.ts +13 -13
  28. package/src/components/DateInput/styles.tsx +27 -27
  29. package/src/components/DatePicker.tsx +67 -67
  30. package/src/components/DropDown.tsx +24 -24
  31. package/src/components/IconButton.tsx +37 -37
  32. package/src/components/Icons.tsx +82 -82
  33. package/src/components/Modal.tsx +103 -103
  34. package/src/components/MultiSelectInput/components/MultiValue/index.tsx +44 -44
  35. package/src/components/MultiSelectInput/components/Option/index.tsx +62 -62
  36. package/src/components/MultiSelectInput/components/Option/styles.tsx +8 -8
  37. package/src/components/MultiSelectInput/index.tsx +60 -60
  38. package/src/components/MultiSelectInput/interfaces.ts +15 -15
  39. package/src/components/MultiSelectInput/styles.tsx +43 -43
  40. package/src/components/Paper.tsx +12 -12
  41. package/src/components/ProgressBar.tsx +71 -71
  42. package/src/components/RadioGroup.tsx +43 -43
  43. package/src/components/RangerSlider.tsx +65 -65
  44. package/src/components/Select.tsx +74 -74
  45. package/src/components/SelectInput/components/Option/index.tsx +61 -61
  46. package/src/components/SelectInput/components/Option/styles.tsx +8 -8
  47. package/src/components/SelectInput/index.tsx +45 -45
  48. package/src/components/SelectInput/interfaces.ts +15 -15
  49. package/src/components/SelectInput/styles.tsx +31 -31
  50. package/src/components/StatusModal/StatusModal.style.tsx +75 -75
  51. package/src/components/StatusModal/StatusModal.tsx +58 -58
  52. package/src/components/Svgs.tsx +506 -506
  53. package/src/components/Table/components/header/index.tsx +86 -86
  54. package/src/components/Table/components/header/styles.tsx +59 -59
  55. package/src/components/Table/components/index.tsx +8 -8
  56. package/src/components/Table/components/pagination/index.tsx +39 -39
  57. package/src/components/Table/components/pagination/styles.tsx +28 -28
  58. package/src/components/Table/components/tbody/index.tsx +30 -30
  59. package/src/components/Table/components/tbody/styles.tsx +4 -4
  60. package/src/components/Table/index.tsx +317 -317
  61. package/src/components/Table/interface.ts +23 -23
  62. package/src/components/Table/styles.tsx +117 -117
  63. package/src/components/Tabs.tsx +105 -105
  64. package/src/components/Tag.tsx +33 -33
  65. package/src/components/TextField.tsx +19 -19
  66. package/src/components/TextInput/index.tsx +37 -37
  67. package/src/components/TextInput/interface.ts +9 -9
  68. package/src/components/TextInput/styles.tsx +23 -23
  69. package/src/components/TimeLine.tsx +89 -89
  70. package/src/components/TimePicker.tsx +78 -78
  71. package/src/components/Typography/Text/index.tsx +20 -20
  72. package/src/components/Typography/Text/interfaces.ts +5 -5
  73. package/src/components/Typography/Text/styles.tsx +40 -40
  74. package/src/components/Typography/Title/index.tsx +22 -22
  75. package/src/components/Typography/Title/interfaces.ts +6 -6
  76. package/src/components/Typography/Title/styles.tsx +40 -40
  77. package/src/components/Typography/index.tsx +6 -6
  78. package/src/components/UncontrolledTable/components/header/index.tsx +72 -72
  79. package/src/components/UncontrolledTable/components/header/styles.tsx +66 -66
  80. package/src/components/UncontrolledTable/components/index.tsx +8 -8
  81. package/src/components/UncontrolledTable/components/pagination/index.tsx +43 -43
  82. package/src/components/UncontrolledTable/components/pagination/styles.tsx +28 -28
  83. package/src/components/UncontrolledTable/components/tbody/index.tsx +33 -33
  84. package/src/components/UncontrolledTable/components/tbody/styles.tsx +32 -32
  85. package/src/components/UncontrolledTable/index.tsx +223 -223
  86. package/src/components/UncontrolledTable/interface.ts +46 -46
  87. package/src/components/UncontrolledTable/styles.tsx +123 -123
  88. package/src/components/UncontrolledTabs/UncontrolledTabs.style.tsx +58 -58
  89. package/src/components/UncontrolledTabs/UncontrolledTabs.tsx +71 -71
  90. package/src/components/UncontrolledTabs/UncontrolledTabsInfo.style.ts +8 -8
  91. package/src/components/index.ts +24 -24
  92. package/src/helpers/alignments.ts +14 -14
  93. package/src/helpers/borders.ts +18 -18
  94. package/src/helpers/colors.ts +258 -258
  95. package/src/helpers/index.ts +5 -5
  96. package/src/helpers/radios.ts +24 -24
  97. package/src/helpers/sizes.ts +72 -72
  98. package/src/hooks/useClickOutside.tsx +18 -18
  99. package/src/index.ts +70 -70
  100. package/src/interfaces/Accordion.ts +12 -12
  101. package/src/interfaces/Avatar.tsx +15 -15
  102. package/src/interfaces/Badge.ts +19 -19
  103. package/src/interfaces/Button.ts +22 -22
  104. package/src/interfaces/Card.ts +11 -11
  105. package/src/interfaces/ChatMessage.ts +12 -12
  106. package/src/interfaces/ChatMessageBalloon.ts +17 -17
  107. package/src/interfaces/CheckBox.ts +27 -27
  108. package/src/interfaces/DatePicker.ts +13 -13
  109. package/src/interfaces/DropDown.ts +14 -14
  110. package/src/interfaces/IconButton.ts +22 -22
  111. package/src/interfaces/Icons.ts +17 -17
  112. package/src/interfaces/Modal.ts +18 -18
  113. package/src/interfaces/Paper.ts +12 -12
  114. package/src/interfaces/ProgressBar.ts +29 -29
  115. package/src/interfaces/RadioGroup.ts +23 -23
  116. package/src/interfaces/RangerSlider.ts +21 -21
  117. package/src/interfaces/Select.ts +17 -17
  118. package/src/interfaces/Tabs.ts +19 -19
  119. package/src/interfaces/Tag.ts +17 -17
  120. package/src/interfaces/TextField.ts +44 -44
  121. package/src/interfaces/TimeLine.ts +11 -11
  122. package/src/interfaces/TimePicker.ts +13 -13
  123. package/src/interfaces/index.ts +23 -23
  124. package/src/providers/NormaProvider.tsx +13 -13
  125. package/src/sample-data-2.json +178 -178
  126. package/src/sample-data.json +177 -177
  127. package/src/stories/Accordion.stories.tsx +65 -65
  128. package/src/stories/Avatar.stories.tsx +123 -123
  129. package/src/stories/Badge.stories.tsx +39 -39
  130. package/src/stories/Box.stories.tsx +35 -35
  131. package/src/stories/Breadcrumb.stories.tsx +44 -44
  132. package/src/stories/Button.stories.tsx +93 -93
  133. package/src/stories/Card.stories.tsx +39 -39
  134. package/src/stories/ChatMessage.stories.tsx +84 -84
  135. package/src/stories/ChatMessageBalloon.stories.tsx +108 -108
  136. package/src/stories/CheckBox.stories.tsx +88 -88
  137. package/src/stories/DateInput.stories.tsx +51 -51
  138. package/src/stories/DatePicker.stories.tsx +50 -50
  139. package/src/stories/DropDown.stories.tsx +57 -57
  140. package/src/stories/IconButton.stories.tsx +78 -78
  141. package/src/stories/Modal.stories.tsx +246 -246
  142. package/src/stories/ModalStatus.stories.tsx +46 -46
  143. package/src/stories/MultiSelectInput.stories.tsx +90 -90
  144. package/src/stories/Paper.stories.tsx +53 -53
  145. package/src/stories/ProgressBar.stories.tsx +116 -116
  146. package/src/stories/RadioGroup.stories.tsx +87 -87
  147. package/src/stories/RangerSlider.stories.tsx +149 -149
  148. package/src/stories/Select.stories.tsx +100 -100
  149. package/src/stories/SelectInput.stories.tsx +78 -78
  150. package/src/stories/Table.stories.tsx +372 -372
  151. package/src/stories/Tabs.stories.tsx +61 -61
  152. package/src/stories/Tag.stories.tsx +56 -56
  153. package/src/stories/Text.stories.tsx +37 -37
  154. package/src/stories/TextField.stories.tsx +310 -310
  155. package/src/stories/TextInput.stories.tsx +52 -52
  156. package/src/stories/TimeLine.stories.tsx +35 -35
  157. package/src/stories/TimePicker.stories.tsx +87 -87
  158. package/src/stories/Title.stories.tsx +43 -43
  159. package/src/stories/UncontrolledTable.stories.tsx +315 -315
  160. package/src/stories/UncontrolledTabs.stories.tsx +74 -74
  161. package/src/styles/globals.scss +17 -17
  162. package/src/types/index.ts +207 -207
  163. package/src/utils/styledBreakpoints.ts +25 -25
  164. package/vite.config.ts +15 -15
@@ -1,103 +1,103 @@
1
- import React from 'react';
2
- import { Modal as MuiModal, Paper, Box, Typography } from '@mui/material';
3
- import { ModalBaseProps } from '../interfaces';
4
- import { styled } from '@mui/material/styles';
5
- import { IconButton } from './IconButton';
6
- import { Button } from './Button';
7
-
8
- const ModalStyled = styled(MuiModal)({});
9
-
10
- const ModalContentStyled = styled(Paper)<{ $w?: string }>`
11
- border: 1px solid #00000033;
12
- border-radius: 4px;
13
- position: absolute;
14
- top: 50%;
15
- left: 50%;
16
- width: ${props => props.$w || '421px'};
17
- transform: translate(-50%, -50%);
18
- background-color: #fff;
19
- `;
20
-
21
- const ModalHeaderStyled = styled(Box)`
22
- text-align: left;
23
- box-sizing: border-box;
24
- margin: 0;
25
- position: relative;
26
- padding: 22px 26px 15px 26px;
27
- justify-content: space-between;
28
- display: flex;
29
-
30
- & h2 {
31
- font-style: normal;
32
- font-weight: 600;
33
- font-size: 18px;
34
- color: #1D1D1D;
35
- }
36
- `;
37
-
38
- const ModalFooterStyled = styled(Box)<{$spaceBetween?: boolean}>`
39
- box-sizing: border-box;
40
- position: relative;
41
- padding: 24px;
42
- display: flex;
43
- justify-content: ${props => props.$spaceBetween ? 'space-between' : 'flex-end'};
44
- gap: 24px;
45
- `;
46
-
47
- const ModalContainerChildrenStyled = styled(Box)`
48
- box-sizing: border-box;
49
- padding: 24px;
50
- `;
51
-
52
- export function Close() {
53
- return (
54
- <svg
55
- fill="#808080"
56
- viewBox="0 0 24 24"
57
- xmlns="http://www.w3.org/2000/svg"
58
- aria-hidden="true"
59
- height="24"
60
- width="24"
61
- >
62
- <path
63
- clipRule="evenodd"
64
- fillRule="evenodd"
65
- d="M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z"
66
- />
67
- </svg>
68
- );
69
- }
70
-
71
- export const Modal = ({ open, children, paperProps, ...props }: ModalBaseProps) => {
72
- return (
73
- <ModalStyled open {...props}>
74
- <ModalContentStyled {...paperProps} $w={props.width}>
75
- {props.title && (
76
- <ModalHeaderStyled>
77
- <Typography variant="h2">{props.title}</Typography>
78
- <IconButton
79
- onClick={props.onClose}
80
- size="small"
81
- color="inherit"
82
- variant="text"
83
- cursor="pointer"
84
- sx={{ padding: '0' }}
85
- >
86
- <Close />
87
- </IconButton>
88
- </ModalHeaderStyled>
89
- )}
90
- <ModalContainerChildrenStyled>{children}</ModalContainerChildrenStyled>
91
- {!!props.action?.length && (
92
- <ModalFooterStyled $spaceBetween={props.actionSpaceBetween}>
93
- {props.action.map(({ color, variant, action, size, label, ...rest }, key) => (
94
- <Button color={color} variant={variant} key={key} onClick={action} size={size} {...rest}>
95
- {label}
96
- </Button>
97
- ))}
98
- </ModalFooterStyled>
99
- )}
100
- </ModalContentStyled>
101
- </ModalStyled>
102
- );
103
- };
1
+ import React from 'react';
2
+ import { Modal as MuiModal, Paper, Box, Typography } from '@mui/material';
3
+ import { ModalBaseProps } from '../interfaces';
4
+ import { styled } from '@mui/material/styles';
5
+ import { IconButton } from './IconButton';
6
+ import { Button } from './Button';
7
+
8
+ const ModalStyled = styled(MuiModal)({});
9
+
10
+ const ModalContentStyled = styled(Paper)<{ $w?: string }>`
11
+ border: 1px solid #00000033;
12
+ border-radius: 4px;
13
+ position: absolute;
14
+ top: 50%;
15
+ left: 50%;
16
+ width: ${props => props.$w || '421px'};
17
+ transform: translate(-50%, -50%);
18
+ background-color: #fff;
19
+ `;
20
+
21
+ const ModalHeaderStyled = styled(Box)`
22
+ text-align: left;
23
+ box-sizing: border-box;
24
+ margin: 0;
25
+ position: relative;
26
+ padding: 22px 26px 15px 26px;
27
+ justify-content: space-between;
28
+ display: flex;
29
+
30
+ & h2 {
31
+ font-style: normal;
32
+ font-weight: 600;
33
+ font-size: 18px;
34
+ color: #1D1D1D;
35
+ }
36
+ `;
37
+
38
+ const ModalFooterStyled = styled(Box)<{$spaceBetween?: boolean}>`
39
+ box-sizing: border-box;
40
+ position: relative;
41
+ padding: 24px;
42
+ display: flex;
43
+ justify-content: ${props => props.$spaceBetween ? 'space-between' : 'flex-end'};
44
+ gap: 24px;
45
+ `;
46
+
47
+ const ModalContainerChildrenStyled = styled(Box)`
48
+ box-sizing: border-box;
49
+ padding: 24px;
50
+ `;
51
+
52
+ export function Close() {
53
+ return (
54
+ <svg
55
+ fill="#808080"
56
+ viewBox="0 0 24 24"
57
+ xmlns="http://www.w3.org/2000/svg"
58
+ aria-hidden="true"
59
+ height="24"
60
+ width="24"
61
+ >
62
+ <path
63
+ clipRule="evenodd"
64
+ fillRule="evenodd"
65
+ d="M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z"
66
+ />
67
+ </svg>
68
+ );
69
+ }
70
+
71
+ export const Modal = ({ open, children, paperProps, ...props }: ModalBaseProps) => {
72
+ return (
73
+ <ModalStyled open {...props}>
74
+ <ModalContentStyled {...paperProps} $w={props.width}>
75
+ {props.title && (
76
+ <ModalHeaderStyled>
77
+ <Typography variant="h2">{props.title}</Typography>
78
+ <IconButton
79
+ onClick={props.onClose}
80
+ size="small"
81
+ color="inherit"
82
+ variant="text"
83
+ cursor="pointer"
84
+ sx={{ padding: '0' }}
85
+ >
86
+ <Close />
87
+ </IconButton>
88
+ </ModalHeaderStyled>
89
+ )}
90
+ <ModalContainerChildrenStyled>{children}</ModalContainerChildrenStyled>
91
+ {!!props.action?.length && (
92
+ <ModalFooterStyled $spaceBetween={props.actionSpaceBetween}>
93
+ {props.action.map(({ color, variant, action, size, label, ...rest }, key) => (
94
+ <Button color={color} variant={variant} key={key} onClick={action} size={size} {...rest}>
95
+ {label}
96
+ </Button>
97
+ ))}
98
+ </ModalFooterStyled>
99
+ )}
100
+ </ModalContentStyled>
101
+ </ModalStyled>
102
+ );
103
+ };
@@ -1,44 +1,44 @@
1
- import React from 'react'
2
- import { components } from "react-select"
3
-
4
- const MoreSelectedBadge = ({ items }: any) => {
5
- const style = {
6
- marginLeft: "auto",
7
- background: "#F8F9FA",
8
- color: "#666666",
9
- borderRadius: "4px",
10
- fontFamily: "Open Sans",
11
- fontSize: "11px",
12
- padding: "3px",
13
- order: 99
14
- };
15
-
16
- const title = items.join(", ");
17
- const length = items.length;
18
- const label = `+ ${length}`;
19
-
20
- return (
21
- <div style={style} title={title}>
22
- {label}
23
- </div>
24
- );
25
- };
26
-
27
- const MultiValue:React.FC<any> = ({
28
- index,
29
- getValue,
30
- ...props
31
- }) => {
32
- const maxToShow = 3;
33
- const overflow = getValue()
34
- .slice(maxToShow)
35
- .map((x: any) => x.label);
36
-
37
- return index < maxToShow ? (
38
- <components.MultiValue {...props} />
39
- ) : index === maxToShow ? (
40
- <MoreSelectedBadge items={overflow} />
41
- ) : null;
42
- }
43
-
44
- export default MultiValue
1
+ import React from 'react'
2
+ import { components } from "react-select"
3
+
4
+ const MoreSelectedBadge = ({ items }: any) => {
5
+ const style = {
6
+ marginLeft: "auto",
7
+ background: "#F8F9FA",
8
+ color: "#666666",
9
+ borderRadius: "4px",
10
+ fontFamily: "Open Sans",
11
+ fontSize: "11px",
12
+ padding: "3px",
13
+ order: 99
14
+ };
15
+
16
+ const title = items.join(", ");
17
+ const length = items.length;
18
+ const label = `+ ${length}`;
19
+
20
+ return (
21
+ <div style={style} title={title}>
22
+ {label}
23
+ </div>
24
+ );
25
+ };
26
+
27
+ const MultiValue:React.FC<any> = ({
28
+ index,
29
+ getValue,
30
+ ...props
31
+ }) => {
32
+ const maxToShow = 3;
33
+ const overflow = getValue()
34
+ .slice(maxToShow)
35
+ .map((x: any) => x.label);
36
+
37
+ return index < maxToShow ? (
38
+ <components.MultiValue {...props} />
39
+ ) : index === maxToShow ? (
40
+ <MoreSelectedBadge items={overflow} />
41
+ ) : null;
42
+ }
43
+
44
+ export default MultiValue
@@ -1,63 +1,63 @@
1
- import React, { useState } from "react"
2
- import { components } from "react-select"
3
- import * as S from "./styles";
4
-
5
- const Option:React.FC<any> = ({
6
- isFocused,
7
- isSelected,
8
- innerProps,
9
- children,
10
- getStyles,
11
- isDisabled,
12
- ...rest
13
- }) => {
14
- const [isActive, setIsActive] = useState(false);
15
- const onMouseDown = () => setIsActive(true);
16
- const onMouseUp = () => setIsActive(false);
17
- const onMouseLeave = () => setIsActive(false);
18
-
19
- let bg = "transparent"
20
- let color = "#000"
21
-
22
- if (isFocused) {
23
- bg = "#f1f1f1"
24
- };
25
- if (isActive) {
26
- bg = "#F8F9FA"
27
- };
28
-
29
- const style = {
30
- alignItems: "center",
31
- transition: "0.3s",
32
- backgroundColor: bg,
33
- color: color,
34
- display: "flex ",
35
- gap: '8px'
36
- };
37
-
38
- const props = {
39
- ...innerProps,
40
- onMouseDown,
41
- onMouseUp,
42
- onMouseLeave,
43
- style,
44
- ...rest
45
- };
46
-
47
- return (
48
- <S.Container>
49
- <components.Option
50
- {...rest}
51
- isDisabled={isDisabled}
52
- isFocused={isFocused}
53
- isSelected={isSelected}
54
- getStyles={getStyles}
55
- innerProps={props}>
56
- <input type="checkbox" checked={isSelected} onChange={() => null}/>
57
- {children}
58
- </components.Option>
59
- </S.Container>
60
- );
61
- };
62
-
1
+ import React, { useState } from "react"
2
+ import { components } from "react-select"
3
+ import * as S from "./styles";
4
+
5
+ const Option:React.FC<any> = ({
6
+ isFocused,
7
+ isSelected,
8
+ innerProps,
9
+ children,
10
+ getStyles,
11
+ isDisabled,
12
+ ...rest
13
+ }) => {
14
+ const [isActive, setIsActive] = useState(false);
15
+ const onMouseDown = () => setIsActive(true);
16
+ const onMouseUp = () => setIsActive(false);
17
+ const onMouseLeave = () => setIsActive(false);
18
+
19
+ let bg = "transparent"
20
+ let color = "#000"
21
+
22
+ if (isFocused) {
23
+ bg = "#f1f1f1"
24
+ };
25
+ if (isActive) {
26
+ bg = "#F8F9FA"
27
+ };
28
+
29
+ const style = {
30
+ alignItems: "center",
31
+ transition: "0.3s",
32
+ backgroundColor: bg,
33
+ color: color,
34
+ display: "flex ",
35
+ gap: '8px'
36
+ };
37
+
38
+ const props = {
39
+ ...innerProps,
40
+ onMouseDown,
41
+ onMouseUp,
42
+ onMouseLeave,
43
+ style,
44
+ ...rest
45
+ };
46
+
47
+ return (
48
+ <S.Container>
49
+ <components.Option
50
+ {...rest}
51
+ isDisabled={isDisabled}
52
+ isFocused={isFocused}
53
+ isSelected={isSelected}
54
+ getStyles={getStyles}
55
+ innerProps={props}>
56
+ <input type="checkbox" checked={isSelected} onChange={() => null}/>
57
+ {children}
58
+ </components.Option>
59
+ </S.Container>
60
+ );
61
+ };
62
+
63
63
  export default Option
@@ -1,9 +1,9 @@
1
- import styled from "styled-components";
2
-
3
- export const Container = styled.div`
4
- font-size: 16px;
5
- color: #666666;
6
- &:nth-child(even) {
7
- background: #F8F9FA;
8
- }
1
+ import styled from "styled-components";
2
+
3
+ export const Container = styled.div`
4
+ font-size: 16px;
5
+ color: #666666;
6
+ &:nth-child(even) {
7
+ background: #F8F9FA;
8
+ }
9
9
  `
@@ -1,61 +1,61 @@
1
- import React, { useState } from "react"
2
- import Select from "react-select"
3
- import { MultiSelectProps } from "./interfaces"
4
- import * as S from "./styles"
5
- import Option from "./components/Option"
6
- import MultiValue from "./components/MultiValue"
7
-
8
- const MultiSelectInput:React.FC<MultiSelectProps> = ({
9
- className,
10
- label,
11
- onChange,
12
- placeholder,
13
- disabled,
14
- options,
15
- value,
16
- isSearchable,
17
- isClearable,
18
- }) => {
19
- const [valueSelected, setValueSelected] = useState(value)
20
-
21
- const components = {
22
- MultiValueContainer: ({ selectProps, data }: any) => {
23
- const values = selectProps.value;
24
- if (values) {
25
- const separator = values.length > 1 ? ', ' : ''
26
- return values[values.length - 1]?.label === data?.label
27
- ? data?.label
28
- : data?.label + `${separator}`;
29
- }
30
- return
31
- },
32
- Option,
33
- MultiValue
34
- };
35
-
36
- return (
37
- <S.Container className={className}>
38
- { label ? <S.Label>{label}</S.Label> : null }
39
- <Select
40
- placeholder={placeholder}
41
- className="react-select-container"
42
- classNamePrefix="react-select"
43
- defaultValue={valueSelected || []}
44
- options={options}
45
- isMulti
46
- closeMenuOnSelect={false}
47
- hideSelectedOptions={false}
48
- isDisabled={disabled}
49
- isSearchable={isSearchable}
50
- isClearable={isClearable}
51
- components={components}
52
- onChange={(values: any) => {
53
- setValueSelected(values)
54
- onChange(values)
55
- }}
56
- />
57
- </S.Container>
58
- )
59
- }
60
-
1
+ import React, { useState } from "react"
2
+ import Select from "react-select"
3
+ import { MultiSelectProps } from "./interfaces"
4
+ import * as S from "./styles"
5
+ import Option from "./components/Option"
6
+ import MultiValue from "./components/MultiValue"
7
+
8
+ const MultiSelectInput:React.FC<MultiSelectProps> = ({
9
+ className,
10
+ label,
11
+ onChange,
12
+ placeholder,
13
+ disabled,
14
+ options,
15
+ value,
16
+ isSearchable,
17
+ isClearable,
18
+ }) => {
19
+ const [valueSelected, setValueSelected] = useState(value)
20
+
21
+ const components = {
22
+ MultiValueContainer: ({ selectProps, data }: any) => {
23
+ const values = selectProps.value;
24
+ if (values) {
25
+ const separator = values.length > 1 ? ', ' : ''
26
+ return values[values.length - 1]?.label === data?.label
27
+ ? data?.label
28
+ : data?.label + `${separator}`;
29
+ }
30
+ return
31
+ },
32
+ Option,
33
+ MultiValue
34
+ };
35
+
36
+ return (
37
+ <S.Container className={className}>
38
+ { label ? <S.Label>{label}</S.Label> : null }
39
+ <Select
40
+ placeholder={placeholder}
41
+ className="react-select-container"
42
+ classNamePrefix="react-select"
43
+ defaultValue={valueSelected || []}
44
+ options={options}
45
+ isMulti
46
+ closeMenuOnSelect={false}
47
+ hideSelectedOptions={false}
48
+ isDisabled={disabled}
49
+ isSearchable={isSearchable}
50
+ isClearable={isClearable}
51
+ components={components}
52
+ onChange={(values: any) => {
53
+ setValueSelected(values)
54
+ onChange(values)
55
+ }}
56
+ />
57
+ </S.Container>
58
+ )
59
+ }
60
+
61
61
  export default MultiSelectInput
@@ -1,16 +1,16 @@
1
- export interface Option {
2
- value: string | number,
3
- label: string
4
- }
5
-
6
- export interface MultiSelectProps {
7
- className?: string
8
- label?: string
9
- onChange: Function
10
- placeholder?: string
11
- disabled?: boolean
12
- options: Option[]
13
- value: Option
14
- isSearchable?: boolean
15
- isClearable?: boolean
1
+ export interface Option {
2
+ value: string | number,
3
+ label: string
4
+ }
5
+
6
+ export interface MultiSelectProps {
7
+ className?: string
8
+ label?: string
9
+ onChange: Function
10
+ placeholder?: string
11
+ disabled?: boolean
12
+ options: Option[]
13
+ value: Option
14
+ isSearchable?: boolean
15
+ isClearable?: boolean
16
16
  }
@@ -1,44 +1,44 @@
1
- import styled from "styled-components";
2
-
3
- export const Container = styled.div`
4
- width: 100%;
5
- display: flex;
6
- flex-direction: column;
7
- .react-select {
8
- &__control {
9
- border-radius: 0;
10
- border: none;
11
- border-bottom: 1px solid #00000033;
12
- }
13
- &__control--is-focused {
14
- border-bottom: 1px solid #00000033;
15
- box-shadow: none;
16
- }
17
- &__control:hover {
18
- border: none;
19
- border-bottom: 1px solid #00000033 !important;
20
- box-shadow: 0 0 0 #fff;
21
- }
22
- &__indicator-separator {
23
- background: #fff;
24
- }
25
- &__multi-value {
26
- background: transparent;
27
- border-radius: 4px;
28
- &__label {
29
- color: #4D4F5C;
30
- font-size: 18px;
31
- padding: 0;
32
- }
33
- &__remove {
34
- display: none;
35
- }
36
- }
37
- }
38
- `
39
-
40
- export const Label = styled.label`
41
- font-size: 14px;
42
- margin: 0 0 4px 0;
43
- color: #4D4F5C;
1
+ import styled from "styled-components";
2
+
3
+ export const Container = styled.div`
4
+ width: 100%;
5
+ display: flex;
6
+ flex-direction: column;
7
+ .react-select {
8
+ &__control {
9
+ border-radius: 0;
10
+ border: none;
11
+ border-bottom: 1px solid #00000033;
12
+ }
13
+ &__control--is-focused {
14
+ border-bottom: 1px solid #00000033;
15
+ box-shadow: none;
16
+ }
17
+ &__control:hover {
18
+ border: none;
19
+ border-bottom: 1px solid #00000033 !important;
20
+ box-shadow: 0 0 0 #fff;
21
+ }
22
+ &__indicator-separator {
23
+ background: #fff;
24
+ }
25
+ &__multi-value {
26
+ background: transparent;
27
+ border-radius: 4px;
28
+ &__label {
29
+ color: #4D4F5C;
30
+ font-size: 18px;
31
+ padding: 0;
32
+ }
33
+ &__remove {
34
+ display: none;
35
+ }
36
+ }
37
+ }
38
+ `
39
+
40
+ export const Label = styled.label`
41
+ font-size: 14px;
42
+ margin: 0 0 4px 0;
43
+ color: #4D4F5C;
44
44
  `