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,335 @@
1
+ import React, { useState, createRef } from "react";
2
+ import styled from 'styled-components';
3
+ import defaultThemeColor from '../constants/defaultThemeColor';
4
+ import PropTypes from "prop-types";
5
+ import defaultStyles from '../constants/defaultStyle';
6
+ import getDefaultStyles from "../constants/utils";
7
+ import { hexToRGB } from "../constants/utils";
8
+
9
+ import { Icon } from "../Icon";
10
+ import { Label } from "../Label";
11
+
12
+
13
+ const ParentDiv = styled.div`
14
+
15
+ //Set the styles from the default styles object
16
+ ${({ theme, defaultStyles }) => {
17
+ return getDefaultStyles(theme, defaultStyles);
18
+ }}
19
+
20
+ background-color:${({ hover, isValid, fileArr, backgroundColor }) => !isValid ?
21
+ 'rgba(215, 0, 0, 0.05)' : hover ? backgroundColor :
22
+ fileArr.length > 0 ? defaultThemeColor.bgColor : hexToRGB(backgroundColor, 0.05)};
23
+ border: 1px ${({ isValid, fileArr, backgroundColor }) => !isValid ? 'dashed ' +
24
+ defaultThemeColor.ui['error'] : fileArr.length > 0 ? 'solid ' + backgroundColor : 'dashed ' + backgroundColor};
25
+
26
+ &:hover{
27
+ cursor: pointer;
28
+ }
29
+ transition: all 500ms linear;
30
+
31
+
32
+ // custom styles
33
+ ${({ customDropzoneStyles }) => customDropzoneStyles}
34
+ `;
35
+
36
+
37
+ const FileDiv = styled.div`
38
+ //Set the styles from the default styles object
39
+ ${({ theme, defaultStyles }) => {
40
+ return getDefaultStyles(theme, defaultStyles);
41
+ }}
42
+
43
+ // custom styles
44
+ ${({ customFileStyles }) => customFileStyles}
45
+ `;
46
+
47
+ const InputFile = styled.input`
48
+ display: none;
49
+ `;
50
+
51
+ const TextDiv = styled.div`
52
+ //Set the styles from the default styles object
53
+ ${({ theme, defaultStyles }) => {
54
+ return getDefaultStyles(theme, defaultStyles);
55
+ }}
56
+
57
+ // custom styles
58
+ ${({ customTextStyles }) => customTextStyles}
59
+ `;
60
+
61
+ const FileName = styled.span`
62
+ //Set the styles from the default styles object
63
+ ${({ theme, type }) => {
64
+ return getDefaultStyles(theme, type);
65
+ }}
66
+
67
+ // custom styles
68
+ ${({ customFileNameStyles }) => customFileNameStyles}
69
+ `;
70
+
71
+ const CrossDiv = styled.div`
72
+ cursor: pointer;
73
+ padding-left: 1px;
74
+ margin-left: auto;
75
+ margin-right: 10px;
76
+ display: flex;
77
+ justify-content: center;
78
+ `;
79
+
80
+ const IconDiv = styled.div`
81
+ margin-left: 11px;
82
+ padding-left: 2px;
83
+ display: flex;
84
+ justify-content: center;
85
+ `;
86
+
87
+ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, labelInline, required, message, fileArr, setFileArr, deleteFile, customDropzoneStyles, customFileStyles, customTextStyles, customFileNameStyles, backgroundColor, singleFile, messageSize, ...props }) => {
88
+ const [hover, setHover] = useState(false);
89
+ const fileInputRef = createRef();
90
+
91
+ function onFilesAdded(event) {
92
+ const { files } = event.target;
93
+ setHover(false);
94
+ props.onFilesAdded(fileListToArray(files, singleFile));
95
+ }
96
+
97
+ function onDragOver(event) {
98
+ stopEvent(event);
99
+ setHover(true);
100
+ }
101
+
102
+
103
+ function onDragLeave(event) {
104
+ stopEvent(event);
105
+ setHover(false);
106
+ }
107
+
108
+
109
+ function onDrop(event) {
110
+ stopEvent(event);
111
+
112
+ const { files } = event.dataTransfer;
113
+ setHover(true);
114
+ props.onFilesAdded(fileListToArray(files, singleFile));
115
+ }
116
+
117
+
118
+ function stopEvent(event) {
119
+ event.preventDefault();
120
+ event.stopPropagation();
121
+ }
122
+
123
+
124
+ function fileListToArray(list, singleFile) {
125
+ let result = singleFile == true ? [] : [...fileArr];
126
+ for (let i = 0; i < list.length; i++) {
127
+ result.push(list.item(i));
128
+ }
129
+ if (!singleFile) {
130
+ result = result.filter((value, index, self) =>
131
+ index === self.findIndex((t) => (
132
+ t.place === value.place && t.name === value.name
133
+ ))
134
+ )
135
+ }
136
+ setFileArr(result);
137
+ setHover(false);
138
+ return result;
139
+ }
140
+
141
+ function deleteItemFromServer(file, i) {
142
+ const updateFiles = fileArr.filter(item => item.name !== file.name);
143
+ setFileArr(updateFiles);
144
+ deleteFile(file);
145
+ }
146
+
147
+ function fileRemoveFromArary(file, i) {
148
+ if (file instanceof File) {
149
+ const updateFiles = fileArr.filter(item => item.name !== file.name);
150
+ setFileArr(updateFiles);
151
+ // console.log(updateFiles,fileArr);
152
+ } else {
153
+ deleteItemFromServer(file, i);
154
+ }
155
+ }
156
+
157
+
158
+ function openFileDialog() {
159
+ fileInputRef.current.click();
160
+ }
161
+ return (
162
+ <div style={{
163
+ // display: 'flex',
164
+ // flexDirection: 'column',
165
+ // alignItems: 'center',
166
+ /* align-content: stretch; */
167
+ // width: '532px',
168
+ // boxSizing: 'border-box',
169
+ // maxHeight: 'calc(70vh - 129px)',
170
+ paddingBottom: '5px',
171
+ }}>
172
+ <div style={{ display: 'flex' }}>
173
+ <Label
174
+ themeColor={defaultThemeColor}
175
+ customStyles={labelStyle}
176
+ type={'label-text'}
177
+ labelInline={labelInline}
178
+ text={label}
179
+ style={{
180
+ 'display': 'flex',
181
+ 'paddingBottom': `${!labelInline ? '16.64px' : ''}`,
182
+ }}
183
+ {...props} />
184
+ {required && <div style={{
185
+ marginLeft: '4px',
186
+ color: `${themeColor.variant['error']}`
187
+ }} >*</div>}
188
+ </div>
189
+ <ParentDiv
190
+ theme={defaultStyles}
191
+ themeColor={defaultThemeColor}
192
+ defaultStyles={'dropzone-parent'}
193
+ backgroundColor={backgroundColor}
194
+ customDropzoneStyles={customDropzoneStyles}
195
+ onDragLeave={onDragLeave}
196
+ onDragOver={onDragOver}
197
+ onDrop={onDrop}
198
+ onClick={openFileDialog}
199
+ hover={hover}
200
+ isValid={isValid}
201
+ fileArr={fileArr}
202
+ >
203
+ <InputFile
204
+ ref={fileInputRef}
205
+ type="file"
206
+ multiple={singleFile == true ? false : true}
207
+ onChange={onFilesAdded}
208
+ onClick={(e) => e.target.value = null}
209
+ {...props}
210
+ />
211
+ {isValid ?
212
+ <Icon
213
+ icon='file-attach'
214
+ color={hover ? themeColor.bgColor : backgroundColor}
215
+ size={24} />
216
+ : null}
217
+ <TextDiv isValid={isValid} hover={hover} customTextStyles={customTextStyles}
218
+ theme={defaultStyles}
219
+ defaultStyles={'dropzone-text-div'}>
220
+ {isValid ?
221
+ <div>
222
+ <span style={{ color: hover ? themeColor.bgColor : backgroundColor }}>Choose a file </span>
223
+ <span style={{ color: hover ? themeColor.bgColor : themeColor.neutral['neutral-2'] }}>or </span>
224
+ <span style={{ color: hover ? themeColor.bgColor : themeColor.textColor }}>drag {singleFile ? 'it' : 'them'} here</span>
225
+ </div>
226
+ :
227
+ <div>
228
+ <span style={{ color: themeColor.variant['error'] }}>Try again!! </span>
229
+ <span style={{
230
+ color: theme.textColor,
231
+ }}>{message.length > messageSize ? message.slice(0, messageSize) : message}</span>
232
+ </div>
233
+ }
234
+ </TextDiv>
235
+ </ParentDiv>
236
+ {fileArr?.map((item, i) => {
237
+ // console.log("item", item)
238
+ return <FileDiv
239
+ theme={defaultStyles}
240
+ defaultStyles={'dropzone-file-div'}
241
+ key={`${item}-${i}`}
242
+ customFileStyles={customFileStyles}>
243
+ <IconDiv><Icon icon='pdf-icon' /></IconDiv>
244
+ <FileName
245
+ theme={defaultStyles}
246
+ type={'dropzone-file-name'}
247
+ customFileNameStyles={customFileNameStyles}
248
+ >{item.name}</FileName>
249
+ <IconDiv><Icon
250
+ icon={`${item instanceof File ? 'plus-outlined' : 'cloud-icon'}`}
251
+ />
252
+ </IconDiv>
253
+ <CrossDiv key={Math.random() * 101 | 0}
254
+ onClick={() => fileRemoveFromArary(item, i)}>
255
+ <Icon icon='cross-icon' color={themeColor.neutral['neutral-2']} />
256
+ </CrossDiv>
257
+ </FileDiv>
258
+ })}
259
+ </div>
260
+ )
261
+ }
262
+
263
+ DropzoneInput.propTypes = {
264
+ /**
265
+ * Theme props of the default css style
266
+ */
267
+ theme: PropTypes.object,
268
+ /**
269
+ * onFileAdd function
270
+ */
271
+ onFilesAdded: PropTypes.func,
272
+ /**
273
+ * is the input file valid
274
+ */
275
+ isValid: PropTypes.bool,
276
+ /**
277
+ * invalid error messages (limit 100 characters)
278
+ */
279
+ message: PropTypes.string,
280
+ /**
281
+ * files that are added
282
+ */
283
+ fileArr: PropTypes.array,
284
+ /**
285
+ * files setter
286
+ */
287
+ setFileArr: PropTypes.func,
288
+ /**
289
+ * custom style of the dropzoneInput box
290
+ */
291
+ customDropzoneStyles: PropTypes.object,
292
+ /**
293
+ * custom style of the uploaded files
294
+ */
295
+ customFileStyles: PropTypes.object,
296
+ /**
297
+ * custom style of the text
298
+ */
299
+ customTextStyles: PropTypes.object,
300
+ /**
301
+ * custom style of the file name that are added on the preview
302
+ */
303
+ customFileNameStyles: PropTypes.object,
304
+ /**
305
+ * background color (in HEX format) of the dropzoneInput box
306
+ */
307
+ backgroundColor: PropTypes.string,
308
+ /**
309
+ * sting length of the message
310
+ */
311
+ messageSize: PropTypes.number
312
+
313
+
314
+
315
+ /**
316
+ * Plus icon after file name is for file from local and cloud icon is for file from server
317
+ */
318
+ };
319
+
320
+ DropzoneInput.defaultProps = {
321
+ themeColor: defaultThemeColor,
322
+ theme: defaultStyles,
323
+ onFilesAdded: () => null,
324
+ isValid: true,
325
+ message: '',
326
+ backgroundColor: `${defaultThemeColor.primary['primary-1']}`,
327
+ fileArr: [],
328
+ setFileArr: () => { },
329
+ customDropzoneStyles: {},
330
+ customFileStyles: {},
331
+ customTextStyles: {},
332
+ customFileNameStyles: {},
333
+ messageSize: 100
334
+ };
335
+
@@ -0,0 +1,155 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import styled, { css, useTheme } from 'styled-components';
4
+ import defaultThemeColor from '../constants/defaultThemeColor';
5
+
6
+ const border = `#D4D7E3`;
7
+
8
+ const TextBox = styled.div`
9
+ border: 1px solid ${({ theme }) => theme ? border : theme.variant['primary-1']};
10
+ border-radius: 4px;
11
+ padding: 5px 12px;
12
+ display: flex;
13
+ align-items: center;
14
+
15
+ .input-icon svg path {
16
+ fill: ${({ theme }) => theme.variant['neutral-1']};
17
+ }
18
+
19
+ &:focus-within {
20
+ border: 1px solid ${({ theme }) => theme.variant['primary-1']};
21
+ outline: none;
22
+
23
+ .input-icon svg path {
24
+ fill: ${({ theme }) => theme.variant['primary-1']};
25
+ }
26
+ }
27
+ `;
28
+
29
+ TextBox.defaultProps = {
30
+ theme: defaultThemeColor,
31
+ }
32
+
33
+ const Input = styled.input`
34
+ border: 0;
35
+ outline: 0;
36
+ color: ${({ theme }) => theme.variant['primary-2']};
37
+ margin: 0px;
38
+ padding: 0;
39
+ font-size: 14px;
40
+ flex-grow: 1;
41
+ flex-shrink: 0;
42
+
43
+ // custom styles
44
+ ${({ inputStyle }) => inputStyle}
45
+ `;
46
+
47
+ Input.defaultProps = {
48
+ theme: defaultThemeColor,
49
+ }
50
+
51
+ const requiredAsterisk = css`
52
+ &:after {
53
+ content:" *";
54
+ color: ${({ theme }) => theme.variant['error']};
55
+ }
56
+ `
57
+
58
+ const Label = styled.label`
59
+ display: flex;
60
+ margin-right: 10px;
61
+ color: #929EAC;
62
+ align-content: center;
63
+ align-items: center;
64
+ justify-content: center;
65
+ display: block;
66
+ margin-bottom: ${({ labelInline, }) => (labelInline) ? '0' : '16px'};
67
+ margin-right: ${({ labelInline }) => labelInline ? '10px' : ''};
68
+ color: ${({ theme }) => theme.variant['neutral-2']};
69
+ `;
70
+
71
+ Label.defaultProps = {
72
+ theme: defaultThemeColor,
73
+ }
74
+
75
+ const inline = css`
76
+ display: flex;
77
+ align-items: center;
78
+ `
79
+
80
+ const Form = styled.div`
81
+ ${({ labelInline }) => labelInline ? inline : null}
82
+
83
+ > div {
84
+ flex: 1 0 auto;
85
+ }
86
+ `
87
+
88
+ Form.defaultProps = {
89
+ theme: defaultThemeColor,
90
+ }
91
+
92
+ export const NumericInput = ({ label, inputValue, inputStyle, iconBefore, iconAfter, onChange, ...props }) => {
93
+ const handleChange = (e) => {
94
+ const re = /^[0-9\b.-]+$/;
95
+ const { value } = e.currentTarget;
96
+ if (value === '' || re.test(value)) {
97
+ onChange(value);
98
+ }
99
+ }
100
+
101
+ return (
102
+ <Form {...props}>
103
+ {label.length > 0 && <Label {...props}>{label}</Label>}
104
+ <div>
105
+ <TextBox
106
+ {...props}
107
+ >
108
+ <div className="input-icon">
109
+ {iconBefore}
110
+ </div>
111
+ <Input {...props}
112
+ inputStyle={inputStyle}
113
+ value={inputValue}
114
+ onChange={handleChange}
115
+ type='number'
116
+ />
117
+ <div className="input-icon">
118
+ {iconAfter}
119
+ </div>
120
+ </TextBox>
121
+ </div>
122
+ </Form>
123
+ )
124
+ }
125
+
126
+ NumericInput.propTypes = {
127
+ /**
128
+ * Theme props
129
+ */
130
+ theme: PropTypes.object,
131
+ /**
132
+ * Label of Input
133
+ */
134
+ label: PropTypes.string,
135
+ /**
136
+ * Should label be inline?
137
+ */
138
+ labelInline: PropTypes.bool,
139
+ /**
140
+ * Value Prop
141
+ */
142
+ inputValue: PropTypes.any,
143
+
144
+ inputStyle: PropTypes.object,
145
+
146
+ }
147
+
148
+ NumericInput.defaultProps = {
149
+ theme: defaultThemeColor,
150
+ label: '',
151
+ labelInline: false,
152
+ inputStyle: {},
153
+ inputValue: null,
154
+ }
155
+
@@ -0,0 +1,205 @@
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
+
9
+
10
+ const RadioOuterCircle = styled.div`
11
+
12
+ //Set the styles from the default styles object
13
+ ${({ theme, defaultRadioOuterCircleStyle }) => {
14
+ return getDefaultStyles(theme, defaultRadioOuterCircleStyle);
15
+ }}
16
+
17
+ border: 2px solid ${({ value, selected, selectedCircleColor, defaultBorderColor }) => value !== selected ? defaultBorderColor : selectedCircleColor};
18
+
19
+ // custom styles
20
+ ${({ radioOuterCircleStyle }) => radioOuterCircleStyle}
21
+ `;
22
+
23
+
24
+ const RadioInnerCircle = styled.div`
25
+
26
+ //Set the styles from the default styles object
27
+ ${({ theme, defaultRadioInnerCircleStyle }) => {
28
+ return getDefaultStyles(theme, defaultRadioInnerCircleStyle);
29
+ }}
30
+
31
+ width: ${({ value, selected, width }) => value === selected ? width : 0};
32
+ height: ${({ value, selected, height }) => value === selected ? height : 0};
33
+ background-color: ${({ value, selected, selectedCircleColor }) => value === selected ? selectedCircleColor : 'transparent'};
34
+
35
+ // custom styles
36
+ ${({ radioInnerCircleStyle }) => radioInnerCircleStyle}
37
+ `;
38
+
39
+ const OptionText = styled.div`
40
+ //Set the styles from the default styles object
41
+ ${({ theme, defaultOptionStyle }) => {
42
+ return getDefaultStyles(theme, defaultOptionStyle);
43
+ }}
44
+ margin-right: ${({ inline }) => !inline ? '30px' : ''};
45
+ color: ${({ selected, selectedOptionTextColor, defaultOptionColor }) => selected ?
46
+ selectedOptionTextColor : defaultOptionColor};
47
+
48
+ // custom styles
49
+ ${({ optionStyle }) => optionStyle}
50
+ `;
51
+
52
+ const WrapperDiv = styled.div`
53
+ margin-bottom: ${({ inline }) => !inline ? '14px' : ''};
54
+ cursor: pointer;
55
+ align-items: center;
56
+ display: flex;
57
+ gap: 10px;
58
+ `
59
+
60
+ const ParentDiv = styled.div`
61
+ display: ${({ inline }) => !inline ? "inline-block" : "flex"};
62
+ width: max-content;
63
+ margin: 0;
64
+ `
65
+
66
+ export const RadioInput = ({ radioOuterCircleStyle, radioInnerCircleStyle, labelStyle, label, optionStyle, options, selectedCircleColor, selectedOptionTextColor, onChange, selected, width, height, inline, defaultBorderColor, defaultOptionColor, ...props }) => {
67
+ return (
68
+ <div>
69
+ <Label
70
+ themeColor={defaultThemeColor}
71
+ customStyles={labelStyle}
72
+ type={'radio-label'}
73
+ text={label}
74
+ />
75
+ <ParentDiv inline={inline} >
76
+ {options.map((item, i) => {
77
+ return <WrapperDiv
78
+ key={i + Math.random() * 101}
79
+ inline={inline}
80
+ onClick={() => { !item?.disabled && onChange(item.value) }}>
81
+ <RadioOuterCircle
82
+ theme={defaultStyles}
83
+ themeColor={defaultThemeColor}
84
+ defaultBorderColor={defaultBorderColor}
85
+ selectedCircleColor={selectedCircleColor}
86
+ radioOuterCircleStyle={{ ...radioOuterCircleStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabled && item?.disabledColor }}
87
+ defaultRadioOuterCircleStyle={'radio-outer-circle'}
88
+ value={item.value}
89
+ selected={!item?.disabled && selected}
90
+ >
91
+
92
+ <RadioInnerCircle
93
+ theme={defaultStyles}
94
+ width={width}
95
+ height={height}
96
+ selectedCircleColor={selectedCircleColor}
97
+ radioInnerCircleStyle={{ ...radioInnerCircleStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', backgroundColor: item?.disabled ? 'transparent' : item?.value === selected ?radioInnerCircleStyle?.backgroundColor : 'transparent' }}
98
+ defaultRadioInnerCircleStyle={'radio-inner-circle'}
99
+ value={item.value}
100
+ selected={selected}
101
+ />
102
+ </RadioOuterCircle>
103
+ <OptionText
104
+ defaultOptionColor={defaultOptionColor}
105
+ optionStyle={{ ...optionStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', color: item?.disabled && item?.disabledColor }}
106
+ theme={defaultStyles}
107
+ defaultOptionStyle={'option-text'}
108
+ selectedOptionTextColor={selectedOptionTextColor}
109
+ // selected={item.value === selected}
110
+ selected={!item?.disabled && item.value === selected}
111
+
112
+ >
113
+ {item.label}
114
+ </OptionText>
115
+ </WrapperDiv>
116
+ })}
117
+ </ParentDiv>
118
+ </div>
119
+ )
120
+ }
121
+
122
+ RadioInput.propTypes = {
123
+ /**
124
+ * Label of RadioButtons
125
+ */
126
+ label: PropTypes.string,
127
+ /**
128
+ * Label Style of RadioButtons
129
+ */
130
+ labelStyle: PropTypes.object,
131
+ /**
132
+ * Should RadioButtones be inline?
133
+ */
134
+ inline: PropTypes.bool,
135
+ /**
136
+ * RadioButton Contents i.e:-
137
+ [{ label: "First Radio Button", value: "first", disabled:true, disabledColor: '#ae3232' },
138
+ { label: "Second Radio Button", value: "second" },
139
+ { label: "Third Radio Button", value: "third" }]
140
+ */
141
+ options: PropTypes.array,
142
+ /**
143
+ * RadioButton style object
144
+ */
145
+ optionStyle: PropTypes.object,
146
+ /**
147
+ * RadioButton checked value
148
+ */
149
+ selected: PropTypes.string,
150
+ /**
151
+ * RadioButton function
152
+ */
153
+ onChange: PropTypes.func,
154
+ /**
155
+ * Default option color when not selected
156
+ */
157
+ defaultOptionColor: PropTypes.string,
158
+ /**
159
+ * Default border color when not selectecd
160
+ */
161
+ defaultBorderColor: PropTypes.string,
162
+ /**
163
+ * RadioButton outside design
164
+ */
165
+ radioOuterCircleStyle: PropTypes.object,
166
+ /**
167
+ * RadioButton inner design
168
+ */
169
+ radioInnerCircleStyle: PropTypes.object,
170
+ /**
171
+ * RadioButton selected circle width
172
+ */
173
+ width: PropTypes.string,
174
+ /**
175
+ * RadioButton selected circle height
176
+ */
177
+ height: PropTypes.string,
178
+ /**
179
+ * RadioButton selected circle color
180
+ */
181
+ selectedCircleColor: PropTypes.string,
182
+ /**
183
+ * RadioButton selected option
184
+ */
185
+ selectedOptionTextColor: PropTypes.string,
186
+ }
187
+
188
+ RadioInput.defaultProps = {
189
+ label: '',
190
+ labelStyle: {},
191
+ inline: false,
192
+ options: [],
193
+ optionStyle: {},
194
+ selected: 'one',
195
+ onChange: () => { },
196
+ radioOuterCircleStyle: {},
197
+ radioInnerCircleStyle: {},
198
+ defaultOptionColor: `${defaultThemeColor.neutral['neutral-2']}`,
199
+ defaultBorderColor: '#D4D7E3',
200
+ width: '14px',
201
+ height: '14px',
202
+ selectedCircleColor: `${defaultThemeColor.primary['primary-1']}`,
203
+ selectedOptionTextColor: `${defaultThemeColor.neutral['neutral-1']}`,
204
+ }
205
+