groundfloor-react-ui 1.0.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 (185) hide show
  1. package/README.md +20 -0
  2. package/assets/fonts/Averta/Averta-Black.woff2 +0 -0
  3. package/assets/fonts/Averta/Averta-BlackItalic.woff2 +0 -0
  4. package/assets/fonts/Averta/Averta-Bold.woff2 +0 -0
  5. package/assets/fonts/Averta/Averta-BoldItalic.woff2 +0 -0
  6. package/assets/fonts/Averta/Averta-ExtraBold.woff2 +0 -0
  7. package/assets/fonts/Averta/Averta-ExtraBoldItalic.woff2 +0 -0
  8. package/assets/fonts/Averta/Averta-ExtraThin.woff2 +0 -0
  9. package/assets/fonts/Averta/Averta-ExtraThinItalic.woff2 +0 -0
  10. package/assets/fonts/Averta/Averta-Light.woff2 +0 -0
  11. package/assets/fonts/Averta/Averta-LightItalic.woff2 +0 -0
  12. package/assets/fonts/Averta/Averta-Regular.woff2 +0 -0
  13. package/assets/fonts/Averta/Averta-RegularItalic.woff2 +0 -0
  14. package/assets/fonts/Averta/Averta-SemiBold.woff2 +0 -0
  15. package/assets/fonts/Averta/Averta-SemiBoldItalic.woff2 +0 -0
  16. package/assets/fonts/Averta/Averta-Thin.woff2 +0 -0
  17. package/assets/fonts/Averta/Averta-ThinItalic.woff2 +0 -0
  18. package/assets/fonts/Beauty/BeautyDemo.woff +0 -0
  19. package/assets/icons/app-logo.svg +3 -0
  20. package/assets/icons/arrow-down.svg +3 -0
  21. package/assets/icons/arrow-rotate.svg +1 -0
  22. package/assets/icons/arrow-up.svg +3 -0
  23. package/assets/icons/bell.svg +3 -0
  24. package/assets/icons/check.svg +3 -0
  25. package/assets/icons/checkmark.svg +3 -0
  26. package/assets/icons/chevron-down.svg +3 -0
  27. package/assets/icons/chevron-left.svg +3 -0
  28. package/assets/icons/chevron-right.svg +3 -0
  29. package/assets/icons/cloud-icon.svg +3 -0
  30. package/assets/icons/connection.svg +3 -0
  31. package/assets/icons/cross-icon.svg +3 -0
  32. package/assets/icons/door-internal-active.svg +1 -0
  33. package/assets/icons/edit-icon.svg +3 -0
  34. package/assets/icons/ellipses-horizontal.svg +3 -0
  35. package/assets/icons/ellipses.svg +3 -0
  36. package/assets/icons/email.svg +3 -0
  37. package/assets/icons/eye-hide-view.svg +1 -0
  38. package/assets/icons/eye-hide.svg +1 -0
  39. package/assets/icons/file-attach-white.svg +3 -0
  40. package/assets/icons/file-attach.svg +3 -0
  41. package/assets/icons/functional-equation-regular.svg +147 -0
  42. package/assets/icons/hamburger-menu.svg +3 -0
  43. package/assets/icons/heart.svg +18 -0
  44. package/assets/icons/image.svg +3 -0
  45. package/assets/icons/info.svg +3 -0
  46. package/assets/icons/jpg-icon.svg +3 -0
  47. package/assets/icons/magnifier.svg +3 -0
  48. package/assets/icons/menu-ellipse-two.svg +1 -0
  49. package/assets/icons/menu-ellipse.svg +53 -0
  50. package/assets/icons/pause-all.svg +1 -0
  51. package/assets/icons/pdf-icon.svg +3 -0
  52. package/assets/icons/pen-icon.svg +3 -0
  53. package/assets/icons/plus-outlined.svg +3 -0
  54. package/assets/icons/resume.svg +1 -0
  55. package/assets/icons/sign-icon.svg +3 -0
  56. package/assets/icons/star.svg +3 -0
  57. package/assets/icons/trash-icon.svg +59 -0
  58. package/assets/icons/triangle-down.svg +3 -0
  59. package/assets/icons/users.svg +11 -0
  60. package/assets/icons/view.svg +3 -0
  61. package/assets/icons/watcher.svg +3 -0
  62. package/assets/icons/zoom-in-white.svg +1 -0
  63. package/assets/styles/global.css +0 -0
  64. package/assets/styles/global.scss +0 -0
  65. package/components/Accordion/Accordion.js +114 -0
  66. package/components/Accordion/AccordionSB.js +168 -0
  67. package/components/Accordion/AccordionSBfooter.js +171 -0
  68. package/components/Accordion/index.js +4 -0
  69. package/components/ArrowBar/ArrowBar.js +293 -0
  70. package/components/ArrowBar/index.js +2 -0
  71. package/components/Avatar/Avatar.js +167 -0
  72. package/components/Avatar/AvatarSB.js +226 -0
  73. package/components/Avatar/AvatarSBfooter.js +226 -0
  74. package/components/Avatar/index.js +4 -0
  75. package/components/Banner/Banner.js +65 -0
  76. package/components/Banner/index.js +2 -0
  77. package/components/Breadcrumb/Breadcrumb.js +192 -0
  78. package/components/Breadcrumb/index.js +2 -0
  79. package/components/Button/PrimaryButton.js +125 -0
  80. package/components/Button/SecondaryButton.js +114 -0
  81. package/components/Button/TinyButton.js +94 -0
  82. package/components/Button/index.js +6 -0
  83. package/components/Cards/Card.js +48 -0
  84. package/components/Cards/CardRef.js +64 -0
  85. package/components/Cards/DocumentCard.js +221 -0
  86. package/components/Cards/index.js +5 -0
  87. package/components/Content/Content.js +51 -0
  88. package/components/Content/index.js +1 -0
  89. package/components/Divider/Divider.js +63 -0
  90. package/components/Divider/index.js +2 -0
  91. package/components/Drawer/Drawer.js +93 -0
  92. package/components/Drawer/index.js +2 -0
  93. package/components/ErrorBoundary/ErrorBoundary.js +44 -0
  94. package/components/ErrorBoundary/index.js +1 -0
  95. package/components/FilterChip/FilterChip.js +68 -0
  96. package/components/FilterChip/index.js +1 -0
  97. package/components/Footer/Footer.js +58 -0
  98. package/components/Footer/FooterContentLev3.js +96 -0
  99. package/components/Footer/index.js +2 -0
  100. package/components/Form/FormComponent.js +273 -0
  101. package/components/Form/HeaderComponent.js +39 -0
  102. package/components/Form/StyledComponent.js +323 -0
  103. package/components/Form/SubmitComponent.js +63 -0
  104. package/components/Form/index.js +4 -0
  105. package/components/GroupAvatars/GroupAvatars.js +143 -0
  106. package/components/GroupAvatars/index.js +1 -0
  107. package/components/GroupButtons/ButtonPopup.js +192 -0
  108. package/components/GroupButtons/GroupButtons.js +150 -0
  109. package/components/GroupButtons/GroupButtonsPopup.js +169 -0
  110. package/components/GroupButtons/index.js +3 -0
  111. package/components/GroupStatusCircle/GroupStatusCircle.js +135 -0
  112. package/components/GroupStatusCircle/index.js +1 -0
  113. package/components/Header/Header.js +58 -0
  114. package/components/Header/index.js +1 -0
  115. package/components/HyperLink/HyperLink.js +114 -0
  116. package/components/HyperLink/index.js +1 -0
  117. package/components/Icon/Icon.js +161 -0
  118. package/components/Icon/index.js +1 -0
  119. package/components/Images/Image.js +112 -0
  120. package/components/Images/index.js +2 -0
  121. package/components/Inputs/CheckBoxEditableInput.js +352 -0
  122. package/components/Inputs/CheckBoxInput.js +195 -0
  123. package/components/Inputs/CheckBoxInputMS.js +160 -0
  124. package/components/Inputs/DateSelect.js +411 -0
  125. package/components/Inputs/DropdownSelect.js +466 -0
  126. package/components/Inputs/DropzoneInput.js +335 -0
  127. package/components/Inputs/NumericInput.js +155 -0
  128. package/components/Inputs/RadioInput.js +205 -0
  129. package/components/Inputs/SearchInput.js +18 -0
  130. package/components/Inputs/Signature.js +278 -0
  131. package/components/Inputs/TextArea.js +196 -0
  132. package/components/Inputs/TextInput.js +182 -0
  133. package/components/Inputs/TextInputClicable.js +198 -0
  134. package/components/Inputs/TextInputClicableMS.js +255 -0
  135. package/components/Inputs/TimeInput.js +181 -0
  136. package/components/Inputs/ToggleSwitch.js +123 -0
  137. package/components/Inputs/index.js +13 -0
  138. package/components/Label/Label.js +48 -0
  139. package/components/Label/index.js +1 -0
  140. package/components/Loaders/Loader.js +179 -0
  141. package/components/Loaders/index.js +2 -0
  142. package/components/Modal/Modal.js +116 -0
  143. package/components/Modal/ModalComp.js +158 -0
  144. package/components/Modal/index.js +2 -0
  145. package/components/Overlay/Overlay.js +159 -0
  146. package/components/Overlay/index.js +1 -0
  147. package/components/Pagination/Pagination.js +83 -0
  148. package/components/Pagination/index.js +1 -0
  149. package/components/ProgressBar/ProgressBar.js +84 -0
  150. package/components/ProgressBar/index.js +1 -0
  151. package/components/ProgressSteps/ProgressSteps.js +121 -0
  152. package/components/ProgressSteps/index.js +1 -0
  153. package/components/Rating/Rating.js +264 -0
  154. package/components/Rating/index.js +1 -0
  155. package/components/SecondaryLink/DarkSecondaryLink.js +97 -0
  156. package/components/SecondaryLink/LightSecondaryLink.js +93 -0
  157. package/components/SecondaryLink/index.js +3 -0
  158. package/components/Sidebar/Navbar.js +328 -0
  159. package/components/Sidebar/Sidebar.js +180 -0
  160. package/components/Sidebar/index.js +3 -0
  161. package/components/StatusChip/PrimaryStatusChip.js +78 -0
  162. package/components/StatusChip/SecondaryStatusChip.js +78 -0
  163. package/components/StatusChip/SlimPrimaryStatusChip.js +92 -0
  164. package/components/StatusChip/SlimSecondaryStatusChip.js +93 -0
  165. package/components/StatusChip/index.js +6 -0
  166. package/components/StatusCircle/StatusCircle.js +64 -0
  167. package/components/StatusCircle/index.js +1 -0
  168. package/components/Tables/Table.js +156 -0
  169. package/components/Tables/index.js +1 -0
  170. package/components/Tooltip/Tooltip.js +479 -0
  171. package/components/Tooltip/index.js +1 -0
  172. package/components/Typography/Typography.js +78 -0
  173. package/components/Typography/index.js +2 -0
  174. package/components/constants/colors.js +33 -0
  175. package/components/constants/defaultStyle.js +781 -0
  176. package/components/constants/defaultThemeColor.js +15 -0
  177. package/components/constants/index.js +7 -0
  178. package/components/constants/utils.js +31 -0
  179. package/components/global/FontStyle.js +131 -0
  180. package/components/global/index.js +1 -0
  181. package/dist/index.es.js +2302 -0
  182. package/dist/index.js +2302 -0
  183. package/index.js +40 -0
  184. package/package.json +67 -0
  185. package/rollup.config.js +53 -0
@@ -0,0 +1,352 @@
1
+ import React, { useRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import defaultThemeColor from '../../constants/defaultThemeColor';
5
+ import tick from '../../assets/icons/checkmark.svg';
6
+ import editIcon from '../../assets/icons/edit-icon.svg';
7
+ import { Icon } from "../Icon";
8
+ import { TextInput, CheckBoxInput } from '../..';
9
+
10
+ const CheckBox = styled.input.attrs({ type: "checkbox" })`
11
+ border: none;
12
+ margin: 0;
13
+ margin-top: -4px;
14
+ width: 10px;
15
+ height: 10px;
16
+ display: inline-block;
17
+ cursor:pointer;
18
+ visibility: hidden;
19
+
20
+ &:focus {
21
+ border: 1.5px solid ${({ theme }) => theme.variant['primary-1']};
22
+ outline: none;
23
+ }
24
+
25
+ &:after {
26
+ background-color: ${({theme})=>theme.bgColor};
27
+ border: 1.5px solid ${({ theme }) => theme.variant['primary-1']};
28
+ border-radius: 2px;
29
+ content: " ";
30
+ display: inline-block;
31
+ visibility: visible;
32
+ width: inherit;
33
+ height: inherit;
34
+ }
35
+ &:checked:before {
36
+ content: '';
37
+ color: ${({theme})=>theme.bgColor};
38
+ }
39
+ &:checked:after {
40
+ background-image: url(${tick});
41
+ background-repeat: no-repeat;
42
+ background-position: center;
43
+ width: 10px;
44
+ height: 10px;
45
+ color: ${({theme})=>theme.bgColor};
46
+ background-color: ${({ theme, variant }) => theme.variant[variant]};
47
+ border: 1.5px solid ${({ theme, variant }) => theme.variant[variant]};
48
+ border-radius: 2px solid ${({ theme, variant }) => theme.variant['primary-1']};
49
+ text-align: center;
50
+ }
51
+
52
+ `;
53
+
54
+ CheckBox.defaultProps = {
55
+ theme: defaultThemeColor,
56
+ }
57
+
58
+ const Label = styled.label`
59
+ display: block;
60
+ margin-bottom: ${({ labelInline }) => !labelInline ? '27px' : ''};
61
+ margin-right: ${({ labelInline }) => labelInline ? '26px' : ''};
62
+ color: ${({ theme }) => theme.variant['neutral-1']};
63
+ `;
64
+ Label.defaultProps = {
65
+ theme: defaultThemeColor,
66
+ }
67
+
68
+ const OptionText = styled.input`
69
+ background-color: ${({theme})=>theme.bgColor};
70
+ border: none;
71
+ outline: none;
72
+ height: inherit;
73
+ width: inherit;
74
+ color: ${defaultThemeColor.textColor};
75
+ font-size: 14px;
76
+ line-height: 16px;
77
+ margin-left: 12px;
78
+ display: none;
79
+
80
+ &:focus-within {
81
+ border: none;
82
+ outline: none;
83
+ }
84
+ `;
85
+
86
+ OptionText.defaultProps = {
87
+ theme: defaultThemeColor,
88
+ }
89
+
90
+ const WrapperDiv = styled.label`
91
+ padding-top: 8px;
92
+ padding-bottom: 8px;
93
+ padding-left:11px;
94
+ padding-right:11px;
95
+ align-items: baseline;
96
+ display: flex;
97
+ gap: 0;
98
+ width: 100%;
99
+ `;
100
+
101
+ const OutterDiv = styled.div`
102
+ display: flex;
103
+ gap: 0;
104
+ background: ${({ theme }) => theme.bgColor};
105
+ border: 1px solid ${({ theme }) => theme.variant['neutral-4']};;
106
+ border-radius: 6px;
107
+ cursor: pointer;
108
+ margin-bottom: 13px;
109
+ width: inherit;
110
+ max-width: 444px;
111
+ `;
112
+
113
+ OutterDiv.defaultProps = {
114
+ theme: defaultThemeColor,
115
+ }
116
+
117
+ WrapperDiv.defaultProps = {
118
+ theme: defaultThemeColor,
119
+ }
120
+
121
+ const ParentDiv = styled.div`
122
+ display: inline-flex;
123
+ width: 100%;
124
+ flex-direction: column;
125
+ flex-wrap: wrap;
126
+ align-content: flex-start;;
127
+ justify-content: center;
128
+ `
129
+
130
+ const IconDiv = styled.span`
131
+ cursor: pointer;
132
+ margin-left: auto;
133
+ display: flex;
134
+ justify-content: center;
135
+ `;
136
+
137
+ const TextDiv = styled.div`
138
+ display: flex;
139
+ align-items: center;
140
+ width: inherit;
141
+ `;
142
+
143
+ const OtherDiv = styled.div`
144
+ display: flex;
145
+ flex-direction: column;
146
+ align-items: flex-start;
147
+ width: calc(100% - 30px) !important;
148
+ `;
149
+
150
+ const OptionSpan = styled.span`
151
+ padding-right: 6px;
152
+ margin-left: 14px;
153
+ font-size: 14px;
154
+ line-height: 17px;
155
+ `;
156
+
157
+
158
+ const CheckBoxEditableInput = ({ theme, label, previewMode, previewModeHeader, options, setOptions, other, setOther, otherValue, setOtherValue, variant, ...props }) => {
159
+ const myRefs = useRef([]);
160
+ const mySpanRefs = useRef([]);
161
+ let newOptions = [];
162
+
163
+ const changeHandler = (i) => {
164
+ console.log("changeHandler");
165
+ myRefs.current[i].disabled = false;
166
+ mySpanRefs.current[i].style.display = 'none';
167
+ myRefs.current[i].style.display = 'block';
168
+ myRefs.current[i].focus();
169
+ };
170
+
171
+ const changeValue = (e, i) => {
172
+ newOptions = [...options]
173
+ newOptions[i].label = e.target.value;
174
+ }
175
+
176
+ const saveValue = (i) => {
177
+ setOptions(newOptions);
178
+ myRefs.current[i].disabled = true;
179
+ mySpanRefs.current[i].style.display = 'inline';
180
+ myRefs.current[i].style.display = 'none';
181
+ }
182
+
183
+ const saveLabel = (e, i) => {
184
+ if (e.key === "Enter") {
185
+ saveValue(i);
186
+ }
187
+ }
188
+
189
+
190
+ const deleteLabel = (i) => {
191
+ setOptions(prevState => {
192
+ const items = [...prevState];
193
+ items.splice(i, 1);
194
+ return items;
195
+ });
196
+ }
197
+
198
+ return (
199
+ <div {...props}>
200
+ {label.length>0 && <Label {...props} >
201
+ {label}
202
+ </Label>}
203
+ <ParentDiv {...props}>
204
+ {options?.map((item, i) => {
205
+ return <OutterDiv key={i} >
206
+ <WrapperDiv
207
+ key={Math.random() * 101 | 0}
208
+ {...props}>
209
+ <CheckBox variant={variant} disabled={true}
210
+ {...props} />
211
+ <TextDiv>
212
+ <OptionText
213
+ ref={(el) => (myRefs.current[i] = el)}
214
+ disabled={true}
215
+ onChange={(e) => changeValue(e, i)}
216
+ onBlur={() => saveValue(i)}
217
+ onKeyPress={(e) => saveLabel(e, i)}
218
+ defaultValue={item.label} />
219
+ <OptionSpan>
220
+ <span
221
+ style={{paddingRight:'4px'}}
222
+ ref={(el) => (mySpanRefs.current[i] = el)}>{item.label}
223
+ </span>
224
+ <img key={Math.random() * 101 | 0}
225
+ style={{ cursor: 'pointer', marginLeft: '10px' }}
226
+ onClick={() => changeHandler(i)}
227
+ src={editIcon}
228
+ alt="Edit" />
229
+ </OptionSpan>
230
+ </TextDiv>
231
+ <IconDiv key={Math.random() * 101 | 0}
232
+ onClick={() => deleteLabel(i)}>
233
+ <Icon icon='cross-icon'
234
+ size={12}
235
+ color={theme.neutral['neutral-2']} />
236
+ </IconDiv>
237
+ </WrapperDiv>
238
+ </OutterDiv>
239
+ })}
240
+
241
+ {other &&
242
+ <OutterDiv>
243
+ <ParentDiv>
244
+ <WrapperDiv style={{ paddingTop: 0 }}>
245
+ <CheckBox style={{ marginTop: '-52px' }} disabled={true} />
246
+ <OtherDiv>
247
+ <div style={{ display: 'flex', alignItems: 'center', width: "100%" }}>
248
+ <span style={{
249
+ paddingTop: '10px',
250
+ marginLeft: '14px',
251
+ fontSize: '14px',
252
+ lineHeight: '16px',
253
+ color: '#6B747F'
254
+ }}>
255
+ Others
256
+ </span>
257
+ <IconDiv style={{ marginTop: 0, marginRight:'3px' }}
258
+ key={Math.random() * 101 | 0}
259
+ onClick={() => setOther(false)}>
260
+ <Icon icon='cross-icon'
261
+ size={12}
262
+ color={theme.neutral['neutral-2']} />
263
+ </IconDiv>
264
+ </div>
265
+ <div style={{
266
+ marginTop: '10px', marginLeft: '8px', width: 'inherit'
267
+ }}>
268
+ <TextInput
269
+ placeholder="Type Something..."
270
+ value={otherValue}
271
+ onChange={(e) => setOtherValue(e.target.value)} />
272
+ </div>
273
+ </OtherDiv>
274
+ </WrapperDiv>
275
+ </ParentDiv>
276
+ </OutterDiv>}
277
+ </ParentDiv>
278
+ {previewMode &&
279
+ <CheckBoxInput
280
+ variant='primary-1'
281
+ label={previewModeHeader}
282
+ options={options}
283
+ setOptions={setOptions}
284
+ inline={false} />
285
+ }
286
+ </div>
287
+ )
288
+ }
289
+
290
+ CheckBoxEditableInput.propTypes = {
291
+ /**
292
+ * Theme props
293
+ */
294
+ theme: PropTypes.object,
295
+ /**
296
+ * Type of color on background of checkbox
297
+ */
298
+ variant: PropTypes.string,
299
+ /**
300
+ * Label of Checkbox editor
301
+ */
302
+ label: PropTypes.string,
303
+ /**
304
+ * Preview mode enable or not
305
+ */
306
+ previewMode: PropTypes.bool,
307
+ /**
308
+ * Preview mode header
309
+ */
310
+ previewModeHeader: PropTypes.string,
311
+ /**
312
+ * Other Value in the textbox
313
+ */
314
+ otherValue: PropTypes.string,
315
+ /**
316
+ * Other Value in the setter
317
+ */
318
+ setOtherValue: PropTypes.func,
319
+ /**
320
+ * Other Value should be showed or not
321
+ */
322
+ other: PropTypes.bool,
323
+ /**
324
+ * Other Value should be showed or not setter
325
+ */
326
+ setOther: PropTypes.func,
327
+ /**
328
+ * Array that will be rendered for checkbox options
329
+ */
330
+ options: PropTypes.array,
331
+ /**
332
+ * CheckBox label changeHandler
333
+ */
334
+ setOptions: PropTypes.func,
335
+
336
+ }
337
+
338
+ CheckBoxEditableInput.defaultProps = {
339
+ theme: defaultThemeColor,
340
+ variant: 'primary-1',
341
+ label: '',
342
+ previewMode:true,
343
+ previewModeHeader:'',
344
+ otherValue:'',
345
+ setOtherValue:()=>{},
346
+ other: false,
347
+ setOther: () => {},
348
+ options:[],
349
+ setOptions: () => {},
350
+ }
351
+
352
+ export default CheckBoxEditableInput;
@@ -0,0 +1,195 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled from 'styled-components';
4
+ import defaultThemeColor from '../constants/defaultThemeColor';
5
+ import defaultStyles from '../constants/defaultStyle';
6
+ import getDefaultStyles from '../constants/utils';
7
+ import { Label } from '../Label';
8
+ import tick from '../../assets/icons/checkmark.svg';
9
+
10
+
11
+ const CheckBoxOuter = styled.div`
12
+ //Set the styles from the default styles object
13
+ ${({ theme, defaultCheckBoxOuterStyle }) => {
14
+ return getDefaultStyles(theme, defaultCheckBoxOuterStyle);
15
+ }}
16
+
17
+ border: 2px solid ${({ checkedCheckBoxColor, defaultBorderColor, checked }) => checked ? checkedCheckBoxColor : defaultBorderColor};
18
+
19
+ // custom styles
20
+ ${({ checkBoxOuterStyle }) => checkBoxOuterStyle}
21
+ `;
22
+
23
+ const CheckBoxInner = styled.div`
24
+ //Set the styles from the default styles object
25
+ ${({ theme, defaultCheckBoxInnerStyle }) => {
26
+ return getDefaultStyles(theme, defaultCheckBoxInnerStyle);
27
+ }}
28
+
29
+ background-image: url(${({ signCheck }) => signCheck});
30
+ background-color: ${({ checked, checkedCheckBoxColor }) => checked ? checkedCheckBoxColor : defaultThemeColor.bgColor};
31
+ border: 2px solid ${({ checkedCheckBoxColor, defaultBorderColor, checked }) => checked ? checkedCheckBoxColor : defaultBorderColor};
32
+
33
+ // custom styles
34
+ ${({ checkBoxInnerStyle }) => checkBoxInnerStyle}
35
+
36
+ `;
37
+ CheckBoxInner.defaultProps = {
38
+ themeColor: defaultThemeColor,
39
+ signCheck: `${tick}`
40
+ }
41
+
42
+ const OptionText = styled.span`
43
+
44
+ //Set the styles from the default styles object
45
+ ${({ theme, type }) => {
46
+ return getDefaultStyles(theme, type);
47
+ }}
48
+
49
+ color: ${({ checked, defaultTextColor, checkedTextColor }) => checked ? checkedTextColor : defaultTextColor};
50
+
51
+ margin-right: ${({ inline }) => inline ? '30px' : '0px'};
52
+
53
+ // custom styles
54
+ ${({ optionTextStyle }) => optionTextStyle}
55
+ `;
56
+
57
+ const WrapperDiv = styled.label`
58
+ width: fit-content;
59
+ margin-bottom: ${({ inline }) => !inline ? '14px !important' : ''};
60
+ cursor: pointer;
61
+ align-items: center;
62
+ display: flex;
63
+ gap: 10px;
64
+
65
+ `
66
+
67
+ const ParentDiv = styled.div`
68
+ flex-direction: ${({ inline }) => inline ? "row" : "column"};
69
+ width: ${({ inline }) => !inline ? "auto" : "initial"};
70
+ `
71
+
72
+
73
+ export const CheckBoxInput = ({ checkBoxOuterStyle, checkBoxInnerStyle, optionTextStyle, defaultBorderColor, defaultTextColor, checkedTextColor, checkedCheckBoxColor, labelStyle, label, options, setOptions, inline, wrapperStyle, ...props }) => {
74
+ const checkBox = (item, i) => {
75
+ let newOptions = [...options]
76
+ newOptions[i].checked = !item.checked;
77
+ setOptions(newOptions);
78
+ }
79
+
80
+ const defaultStyleForWrapper = {
81
+ display: 'flex',
82
+ flexDirection: 'column',
83
+ flexWrap: 'wrap'
84
+ }
85
+ const returnedTarget = Object.assign(defaultStyleForWrapper, wrapperStyle);
86
+
87
+
88
+ return (
89
+ <div style={returnedTarget} {...props}>
90
+ <Label
91
+ themeColor={defaultThemeColor}
92
+ customStyles={labelStyle}
93
+ type={'check-label'}
94
+ text={label}
95
+ {...props} />
96
+ <ParentDiv style={{ display: 'flex', flexWrap: 'wrap' }} inline={inline} {...props}>
97
+ {options?.map((item, i) => {
98
+ return <WrapperDiv inline={inline} key={`${item.name}-${i}`}
99
+ onClick={() => { checkBox(item, i) }} {...props}>
100
+ {item.checked ?
101
+ <CheckBoxInner
102
+ theme={defaultStyles}
103
+ defaultCheckBoxInnerStyle={'checkBox-inner'}
104
+ checkBoxInnerStyle={{ ...checkBoxInnerStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabled && item?.disabledColor }}
105
+ defaultBorderColor={defaultBorderColor}
106
+ checkedCheckBoxColor={checkedCheckBoxColor}
107
+ checked={!item?.disabled && item.checked} {...props} />
108
+ : <CheckBoxOuter
109
+ theme={defaultStyles}
110
+ defaultCheckBoxOuterStyle={'checkBox-outer'}
111
+ checkBoxOuterStyle={{ ...checkBoxOuterStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabledColor }}
112
+ defaultBorderColor={defaultBorderColor}
113
+ {...props} />}
114
+ <OptionText
115
+ inline={inline}
116
+ optionTextStyle={{ ...optionTextStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', color: item?.disabledColor }}
117
+ checked={item.checked}
118
+ defaultTextColor={defaultTextColor}
119
+ checkedTextColor={checkedTextColor}>{item.label}</OptionText>
120
+ </WrapperDiv>
121
+ })}
122
+ </ParentDiv>
123
+ </div>
124
+ )
125
+ }
126
+
127
+ CheckBoxInput.propTypes = {
128
+ /**
129
+ * Style Custom for whole Checkbox Block
130
+ */
131
+ wrapperStyle: PropTypes.object,
132
+ /**
133
+ * Label of CheckBox
134
+ */
135
+ label: PropTypes.string,
136
+ /**
137
+ * Label style of CheckBox
138
+ */
139
+ labelStyle: PropTypes.object,
140
+ /**
141
+ * Outer CheckBox style
142
+ */
143
+ checkBoxOuterStyle: PropTypes.object,
144
+ /**
145
+ * Checked CheckBox style
146
+ */
147
+ checkBoxInnerStyle: PropTypes.object,
148
+ /**
149
+ * Text Style
150
+ */
151
+ optionTextStyle: PropTypes.object,
152
+ /**
153
+ * Default option text color when not selected
154
+ */
155
+ defaultTextColor: PropTypes.string,
156
+ /**
157
+ * checked option text color when selected
158
+ */
159
+ checkedTextColor: PropTypes.string,
160
+ /**
161
+ * Default border color of checkboxes when not selected
162
+ */
163
+ defaultBorderColor: PropTypes.string,
164
+ /**
165
+ * Checked border color of checkboxes when selected
166
+ */
167
+ checkedCheckBoxColor: PropTypes.string,
168
+ /**
169
+ * Should checkboxes be inline?
170
+ */
171
+ inline: PropTypes.bool,
172
+ /**
173
+ * Array that will be rendered for checkbox options
174
+ */
175
+ options: PropTypes.array,
176
+ /**
177
+ * CheckBox value changeHandler
178
+ */
179
+ setOptions: PropTypes.func,
180
+ }
181
+
182
+ CheckBoxInput.defaultProps = {
183
+ label: '',
184
+ inline: false,
185
+ options: [],
186
+ setOptions: () => { },
187
+ labelStyle: {},
188
+ checkBoxOuterStyle: {},
189
+ checkBoxInnerStyle: {},
190
+ defaultTextColor: `${defaultThemeColor.neutral['neutral-2']}`,
191
+ checkedTextColor: `${defaultThemeColor.neutral['neutral-1']}`,
192
+ defaultBorderColor: '#D4D7E3',
193
+ checkedCheckBoxColor: `${defaultThemeColor.primary['primary-1']}`,
194
+ }
195
+
@@ -0,0 +1,160 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled, { useTheme } from 'styled-components';
4
+ import defaultThemeColor from '../../constants/defaultThemeColor';
5
+ import tick from '../../assets/icons/checkmark.svg';
6
+
7
+ const border = `#D4D7E3`;
8
+
9
+ const CheckBox = styled.input.attrs({ type: "checkbox" })`
10
+ width: 15px;
11
+ height: 15px;
12
+ cursor:pointer;
13
+ visibility: hidden;
14
+ margin: 0;
15
+
16
+ &:focus {
17
+ border: 2px solid ${({ theme, variant }) => theme.variant[variant]};
18
+ outline: none;
19
+ }
20
+
21
+ &:after {
22
+ background-color: ${border};
23
+ border-radius: 3px;
24
+ content: " ";
25
+ display: inline-block;
26
+ visibility: visible;
27
+ width: inherit;
28
+ height: inherit;
29
+ }
30
+
31
+ &:checked:before {
32
+ content: '';
33
+ color: white;
34
+ }
35
+
36
+ &:checked:after {
37
+ background-image: url(${tick});
38
+ background-size: 8px 11px;
39
+ background-repeat: no-repeat;
40
+ background-position: center;
41
+ width: 15px;
42
+ height: 15px;
43
+ color: white;
44
+ background-color: ${({ theme, variant, color }) => color ? color : theme.variant[variant]};
45
+ border-radius: 3px;
46
+ text-align: center;
47
+ }
48
+ `;
49
+
50
+ const Label = styled.label`
51
+ display: block;
52
+ margin-bottom: ${({ labelInline }) => !labelInline ? '27px' : ''};
53
+ margin-right: ${({ labelInline }) => labelInline ? '26px' : ''};
54
+ color: ${({ theme }) => theme.variant['neutral-1']};
55
+ `;
56
+ // margin-right: ${({ inline }) => !inline ? '30px' : ''};
57
+ const OptionText = styled.span`
58
+ background-color: transparent;
59
+ color: ${defaultThemeColor.variant['primary-2']};
60
+ font-size: 14px;
61
+ margin-left: 10px;
62
+ margin-right: 0px;
63
+ ${CheckBox}:checked + && {
64
+ color: ${defaultThemeColor.variant['primary-2']};
65
+ }
66
+ white-space: nowrap;
67
+ overflow: hidden;
68
+ text-overflow: ellipsis;
69
+ `;
70
+
71
+ const WrapperDiv = styled.label`
72
+ margin-bottom: ${({ inline }) => !inline ? '0px' : ''};
73
+ align-items: center;
74
+ display: flex;
75
+ line-height: 17.3px;
76
+ `
77
+ const ParentDiv = styled.div`
78
+ display: ${({ inline }) => !inline ? "block" : "inline-flex"};
79
+ width: auto;
80
+ padding: 8px 18.3px;
81
+ `
82
+
83
+ const CheckBoxInputMS = ({ label, options, variant, inline, myKey, color, ...props }) => {
84
+ return (
85
+ <div {...props}>
86
+ <ParentDiv inline={inline} {...props} >
87
+ {options?.map((item, i) => {
88
+ return <WrapperDiv
89
+ key={myKey.concat((Math.random() * 101 | 0).toString())}
90
+ onClick={() => { item.checked = !item.checked }}
91
+ inline={inline} {...props}
92
+ >
93
+ <CheckBox
94
+ variant={variant}
95
+ checked={item.checked}
96
+ color={color}
97
+ {...props}
98
+ />
99
+ <OptionText>{item.label}</OptionText>
100
+ </WrapperDiv>
101
+ })}
102
+ </ParentDiv>
103
+ </div>
104
+ )
105
+ }
106
+
107
+ CheckBox.defaultProps = {
108
+ theme: defaultThemeColor,
109
+ }
110
+
111
+ OptionText.defaultProps = {
112
+ theme: defaultThemeColor,
113
+ }
114
+
115
+ Label.defaultProps = {
116
+ theme: defaultThemeColor,
117
+ }
118
+
119
+ CheckBoxInputMS.propTypes = {
120
+ /**
121
+ * Type of color on background of checkbox
122
+ */
123
+ variant: PropTypes.string,
124
+ /**
125
+ * Label of Checkboxs
126
+ */
127
+ label: PropTypes.string,
128
+ /**
129
+ * Should checkboxes be inline?
130
+ */
131
+ inline: PropTypes.bool,
132
+ /**
133
+ * CheckBox Contents
134
+ */
135
+ options: PropTypes.array,
136
+ /**
137
+ * CheckBox Contents
138
+ */
139
+ onChange: PropTypes.func,
140
+ /**
141
+ * Custom color on background of checkbox if present override the variant
142
+ */
143
+ color: PropTypes.string,
144
+ /**
145
+ * Prefix to use for the key for the element when mapping
146
+ */
147
+ myKey: PropTypes.string,
148
+ }
149
+
150
+ CheckBoxInputMS.defaultProps = {
151
+ variant: 'primary-1',
152
+ label: '',
153
+ inline: false,
154
+ options: [],
155
+ onChange: undefined,
156
+ color: null,
157
+ myKey: null
158
+ }
159
+
160
+ export default CheckBoxInputMS;