groundfloor-react-ui 1.2.9 → 1.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/index.es.js +432 -422
  2. package/dist/index.js +459 -449
  3. package/package.json +15 -43
  4. package/rollup.config.js +6 -6
  5. package/assets/fonts/Averta/Averta-Black.woff2 +0 -0
  6. package/assets/fonts/Averta/Averta-BlackItalic.woff2 +0 -0
  7. package/assets/fonts/Averta/Averta-Bold.woff2 +0 -0
  8. package/assets/fonts/Averta/Averta-BoldItalic.woff2 +0 -0
  9. package/assets/fonts/Averta/Averta-ExtraBold.woff2 +0 -0
  10. package/assets/fonts/Averta/Averta-ExtraBoldItalic.woff2 +0 -0
  11. package/assets/fonts/Averta/Averta-ExtraThin.woff2 +0 -0
  12. package/assets/fonts/Averta/Averta-ExtraThinItalic.woff2 +0 -0
  13. package/assets/fonts/Averta/Averta-Light.woff2 +0 -0
  14. package/assets/fonts/Averta/Averta-LightItalic.woff2 +0 -0
  15. package/assets/fonts/Averta/Averta-Regular.woff2 +0 -0
  16. package/assets/fonts/Averta/Averta-RegularItalic.woff2 +0 -0
  17. package/assets/fonts/Averta/Averta-SemiBold.woff2 +0 -0
  18. package/assets/fonts/Averta/Averta-SemiBoldItalic.woff2 +0 -0
  19. package/assets/fonts/Averta/Averta-Thin.woff2 +0 -0
  20. package/assets/fonts/Averta/Averta-ThinItalic.woff2 +0 -0
  21. package/assets/fonts/Beauty/BeautyDemo.woff +0 -0
  22. package/assets/icons/app-logo.svg +0 -3
  23. package/assets/icons/arrow-down.svg +0 -3
  24. package/assets/icons/arrow-rotate.svg +0 -1
  25. package/assets/icons/arrow-up.svg +0 -3
  26. package/assets/icons/bell.svg +0 -3
  27. package/assets/icons/check.svg +0 -3
  28. package/assets/icons/checkmark.svg +0 -3
  29. package/assets/icons/chevron-down.svg +0 -3
  30. package/assets/icons/chevron-left.svg +0 -3
  31. package/assets/icons/chevron-right.svg +0 -3
  32. package/assets/icons/cloud-icon.svg +0 -3
  33. package/assets/icons/connection.svg +0 -3
  34. package/assets/icons/cross-icon.svg +0 -3
  35. package/assets/icons/default.svg +0 -1
  36. package/assets/icons/door-internal-active.svg +0 -1
  37. package/assets/icons/edit-icon.svg +0 -3
  38. package/assets/icons/ellipses-horizontal.svg +0 -3
  39. package/assets/icons/ellipses.svg +0 -3
  40. package/assets/icons/email.svg +0 -3
  41. package/assets/icons/eye-hide-view.svg +0 -1
  42. package/assets/icons/eye-hide.svg +0 -1
  43. package/assets/icons/file-attach-white.svg +0 -3
  44. package/assets/icons/file-attach.svg +0 -3
  45. package/assets/icons/file-icon.svg +0 -1
  46. package/assets/icons/file-upload.svg +0 -3
  47. package/assets/icons/functional-equation-regular.svg +0 -147
  48. package/assets/icons/hamburger-menu.svg +0 -3
  49. package/assets/icons/heart.svg +0 -18
  50. package/assets/icons/image.svg +0 -3
  51. package/assets/icons/info.svg +0 -3
  52. package/assets/icons/jpg-icon.svg +0 -3
  53. package/assets/icons/magnifier.svg +0 -3
  54. package/assets/icons/menu-ellipse-two.svg +0 -1
  55. package/assets/icons/menu-ellipse.svg +0 -53
  56. package/assets/icons/pause-all.svg +0 -1
  57. package/assets/icons/pdf-icon.svg +0 -3
  58. package/assets/icons/pen-icon.svg +0 -3
  59. package/assets/icons/plus-outlined.svg +0 -3
  60. package/assets/icons/resume.svg +0 -1
  61. package/assets/icons/sign-icon.svg +0 -3
  62. package/assets/icons/star.svg +0 -3
  63. package/assets/icons/trash-icon.svg +0 -59
  64. package/assets/icons/triangle-down.svg +0 -3
  65. package/assets/icons/users.svg +0 -11
  66. package/assets/icons/view.svg +0 -3
  67. package/assets/icons/watcher.svg +0 -3
  68. package/assets/icons/zoom-in-white.svg +0 -1
  69. package/assets/styles/global.css +0 -0
  70. package/assets/styles/global.scss +0 -0
  71. package/components/Accordion/Accordion.js +0 -167
  72. package/components/Accordion/AccordionSB.js +0 -170
  73. package/components/Accordion/AccordionSBfooter.js +0 -171
  74. package/components/Accordion/index.js +0 -4
  75. package/components/ArrowBar/ArrowBar.js +0 -276
  76. package/components/ArrowBar/index.js +0 -2
  77. package/components/Avatar/Avatar.js +0 -171
  78. package/components/Avatar/AvatarSB.js +0 -255
  79. package/components/Avatar/AvatarSBfooter.js +0 -279
  80. package/components/Avatar/index.js +0 -4
  81. package/components/Banner/Banner.js +0 -70
  82. package/components/Banner/index.js +0 -2
  83. package/components/Breadcrumb/Breadcrumb.js +0 -225
  84. package/components/Breadcrumb/index.js +0 -2
  85. package/components/Button/PrimaryButton.js +0 -167
  86. package/components/Button/SecondaryButton.js +0 -156
  87. package/components/Button/TinyButton.js +0 -101
  88. package/components/Button/index.js +0 -6
  89. package/components/Cards/Card.js +0 -43
  90. package/components/Cards/CardRef.js +0 -71
  91. package/components/Cards/DocumentCard.js +0 -215
  92. package/components/Cards/index.js +0 -5
  93. package/components/Content/Content.js +0 -50
  94. package/components/Content/index.js +0 -1
  95. package/components/DesignComponent/StyledComponent/StyledComponent.js +0 -326
  96. package/components/DesignComponent/StyledComponent/index.js +0 -1
  97. package/components/DesignComponent/index.js +0 -1
  98. package/components/Divider/Divider.js +0 -56
  99. package/components/Divider/index.js +0 -2
  100. package/components/Drawer/Drawer.js +0 -84
  101. package/components/Drawer/index.js +0 -2
  102. package/components/ErrorBoundary/ErrorBoundary.js +0 -44
  103. package/components/ErrorBoundary/index.js +0 -1
  104. package/components/FilterChip/FilterChip.js +0 -70
  105. package/components/FilterChip/index.js +0 -1
  106. package/components/Footer/Footer.js +0 -57
  107. package/components/Footer/FooterContent.js +0 -98
  108. package/components/Footer/index.js +0 -3
  109. package/components/Form/FormComponent.js +0 -244
  110. package/components/Form/HeaderComponent.js +0 -64
  111. package/components/Form/SubmitComponent.js +0 -63
  112. package/components/Form/index.js +0 -5
  113. package/components/GroupAvatars/GroupAvatars.js +0 -139
  114. package/components/GroupAvatars/index.js +0 -1
  115. package/components/GroupButtons/ButtonPopup.js +0 -191
  116. package/components/GroupButtons/GroupButtons.js +0 -150
  117. package/components/GroupButtons/GroupButtonsPopup.js +0 -163
  118. package/components/GroupButtons/index.js +0 -3
  119. package/components/GroupStatusCircle/GroupStatusCircle.js +0 -135
  120. package/components/GroupStatusCircle/index.js +0 -1
  121. package/components/Header/Header.js +0 -58
  122. package/components/Header/index.js +0 -1
  123. package/components/HyperLink/HyperLink.js +0 -114
  124. package/components/HyperLink/index.js +0 -1
  125. package/components/Icon/Icon.js +0 -176
  126. package/components/Icon/index.js +0 -1
  127. package/components/Images/Image.js +0 -107
  128. package/components/Images/index.js +0 -2
  129. package/components/Inputs/CheckBoxInput.js +0 -341
  130. package/components/Inputs/ColorInput.js +0 -145
  131. package/components/Inputs/DateSelect.js +0 -461
  132. package/components/Inputs/DropdownSelect.js +0 -689
  133. package/components/Inputs/DropzoneInput.js +0 -450
  134. package/components/Inputs/NumericInput.js +0 -177
  135. package/components/Inputs/PasswordInput.js +0 -267
  136. package/components/Inputs/RadioInput.js +0 -292
  137. package/components/Inputs/SearchInput.js +0 -19
  138. package/components/Inputs/Signature.js +0 -369
  139. package/components/Inputs/TextArea.js +0 -214
  140. package/components/Inputs/TextInput.js +0 -251
  141. package/components/Inputs/TimeInput.js +0 -186
  142. package/components/Inputs/ToggleSwitch.js +0 -189
  143. package/components/Inputs/index.js +0 -15
  144. package/components/Label/Label.js +0 -48
  145. package/components/Label/index.js +0 -1
  146. package/components/Loaders/Loader.js +0 -179
  147. package/components/Loaders/index.js +0 -2
  148. package/components/Modal/ModalComp.js +0 -216
  149. package/components/Modal/index.js +0 -1
  150. package/components/Overlay/Overlay.js +0 -158
  151. package/components/Overlay/index.js +0 -1
  152. package/components/Pagination/Pagination.js +0 -59
  153. package/components/Pagination/index.js +0 -1
  154. package/components/ProgressBar/ProgressBar.js +0 -101
  155. package/components/ProgressBar/index.js +0 -1
  156. package/components/ProgressSteps/ProgressSteps.js +0 -121
  157. package/components/ProgressSteps/index.js +0 -1
  158. package/components/Rating/Rating.js +0 -258
  159. package/components/Rating/index.js +0 -1
  160. package/components/SecondaryLink/DarkSecondaryLink.js +0 -97
  161. package/components/SecondaryLink/LightSecondaryLink.js +0 -93
  162. package/components/SecondaryLink/index.js +0 -3
  163. package/components/Sidebar/Navbar.js +0 -306
  164. package/components/Sidebar/Sidebar.js +0 -207
  165. package/components/Sidebar/index.js +0 -3
  166. package/components/StatusChip/PrimaryStatusChip.js +0 -78
  167. package/components/StatusChip/SecondaryStatusChip.js +0 -78
  168. package/components/StatusChip/SlimPrimaryStatusChip.js +0 -92
  169. package/components/StatusChip/SlimSecondaryStatusChip.js +0 -93
  170. package/components/StatusChip/index.js +0 -6
  171. package/components/StatusCircle/StatusCircle.js +0 -64
  172. package/components/StatusCircle/index.js +0 -1
  173. package/components/Tables/Table.js +0 -178
  174. package/components/Tables/index.js +0 -1
  175. package/components/Tooltip/Tooltip.js +0 -581
  176. package/components/Tooltip/index.js +0 -1
  177. package/components/Typography/Typography.js +0 -77
  178. package/components/Typography/index.js +0 -2
  179. package/components/constants/colors.js +0 -33
  180. package/components/constants/defaultStyle.js +0 -804
  181. package/components/constants/defaultThemeColor.js +0 -16
  182. package/components/constants/index.js +0 -7
  183. package/components/constants/utils.js +0 -31
  184. package/components/global/FontStyle.js +0 -131
  185. package/components/global/index.js +0 -1
  186. package/index.js +0 -41
@@ -1,450 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React, { createRef, useState } from 'react';
3
- import styled, { useTheme } from 'styled-components';
4
- import defaultStyles from '../constants/defaultStyle';
5
- import defaultThemeColor from '../constants/defaultThemeColor';
6
- import getDefaultStyles, { hexToRGB } from '../constants/utils';
7
-
8
- import { Icon } from '../Icon';
9
- import { Label } from '../Label';
10
-
11
- const ParentDiv = styled.div`
12
- //Set the styles from the default styles object
13
- ${({ inBuiltCss, defaultStyles }) => {
14
- return getDefaultStyles(inBuiltCss, defaultStyles);
15
- }}
16
-
17
- background-color:${({ hover, isValid, fileArr, backgroundColor, theme }) => {
18
- if (!isValid) return 'rgba(215, 0, 0, 0.05)';
19
- else if (isValid && hover && backgroundColor) return backgroundColor;
20
- else if (isValid && hover && !backgroundColor)
21
- return theme.primary['primary-1'];
22
- else if (isValid && !hover && fileArr.length > 0) return theme.bgColor;
23
- else if (isValid && !hover && fileArr.length == 0)
24
- return hexToRGB(theme.primary['primary-1'], 0.05);
25
- }}
26
-
27
- };
28
- border: 1px
29
- ${({ isValid, fileArr, backgroundColor, theme }) =>
30
- !isValid
31
- ? 'dashed ' + theme.ui['error']
32
- : fileArr.length > 0
33
- ? `solid ` +
34
- `${backgroundColor ? backgroundColor : theme.primary['primary-1']}`
35
- : `dashed ` +
36
- `${backgroundColor ? backgroundColor : theme.primary['primary-1']}`};
37
-
38
- &:hover {
39
- cursor: pointer;
40
- }
41
- transition: all 500ms linear;
42
-
43
- // custom styles
44
- ${({ customDropzoneStyles }) => customDropzoneStyles}
45
- `;
46
-
47
- const FileDiv = styled.div`
48
- //Set the styles from the default styles object
49
- ${({ inBuiltCss, defaultStyles }) => {
50
- return getDefaultStyles(inBuiltCss, defaultStyles);
51
- }}
52
-
53
- // custom styles
54
- ${({ customFileStyles }) => customFileStyles}
55
- `;
56
-
57
- const InputFile = styled.input`
58
- display: none;
59
- `;
60
-
61
- const TextDiv = styled.div`
62
- //Set the styles from the default styles object
63
- ${({ inBuiltCss, defaultStyles }) => {
64
- return getDefaultStyles(inBuiltCss, defaultStyles);
65
- }}
66
-
67
- // custom styles
68
- ${({ customTextStyles }) => customTextStyles}
69
- `;
70
-
71
- const FileName = styled.span`
72
- //Set the styles from the default styles object
73
- ${({ inBuiltCss, type }) => {
74
- return getDefaultStyles(inBuiltCss, type);
75
- }}
76
-
77
- // custom styles
78
- ${({ customFileNameStyles }) => customFileNameStyles}
79
- `;
80
-
81
- const CrossDiv = styled.div`
82
- cursor: pointer;
83
- padding-left: 1px;
84
- margin-left: auto;
85
- margin-right: 10px;
86
- display: flex;
87
- justify-content: center;
88
- `;
89
-
90
- const IconDiv = styled.div`
91
- margin-left: 11px;
92
- padding-left: 2px;
93
- `;
94
-
95
- const OtherInfoDiv = styled.div`
96
- color: #494949;
97
- margin-left: 11px;
98
- padding-left: 2px;
99
- `;
100
-
101
- const AdditionalText = styled.p`
102
- color: #494949;
103
- display: flex;
104
- justify-content: center;
105
- align-items: center;
106
- margin: 20px 0px;
107
- font-size: 14px;
108
- `;
109
-
110
- export const DropzoneInput = ({
111
- isValid,
112
- label,
113
- labelStyle,
114
- labelInline,
115
- required,
116
- message,
117
- fileArr,
118
- setFileArr,
119
- deleteFile,
120
- customDropzoneStyles,
121
- customFileStyles,
122
- customTextStyles,
123
- customFileNameStyles,
124
- backgroundColor,
125
- singleFile,
126
- messageSize,
127
- additionalText,
128
- id,
129
- ...props
130
- }) => {
131
- const activeTheme = useTheme() || defaultThemeColor;
132
-
133
- const [hover, setHover] = useState(false);
134
- const fileInputRef = createRef();
135
-
136
- function onFilesAdded(event) {
137
- const { files } = event.target;
138
- setHover(false);
139
- props.onFilesAdded(fileListToArray(files, singleFile));
140
- }
141
-
142
- function onDragOver(event) {
143
- stopEvent(event);
144
- setHover(true);
145
- }
146
-
147
- function onDragLeave(event) {
148
- stopEvent(event);
149
- setHover(false);
150
- }
151
-
152
- function onDrop(event) {
153
- stopEvent(event);
154
-
155
- const { files } = event.dataTransfer;
156
- setHover(true);
157
- props.onFilesAdded(fileListToArray(files, singleFile));
158
- }
159
-
160
- function stopEvent(event) {
161
- event.preventDefault();
162
- event.stopPropagation();
163
- }
164
-
165
- function fileListToArray(list, singleFile) {
166
- let result = singleFile == true ? [] : [...fileArr];
167
- for (let i = 0; i < list.length; i++) {
168
- result.push(list.item(i));
169
- }
170
- if (!singleFile) {
171
- result = result.filter(
172
- (value, index, self) =>
173
- index ===
174
- self.findIndex(
175
- (t) => t.place === value.place && t.name === value.name
176
- )
177
- );
178
- }
179
- setFileArr(result);
180
- setHover(false);
181
- return result;
182
- }
183
-
184
- function deleteItemFromServer(file, i) {
185
- const updateFiles = fileArr.filter((item) => item.name !== file.name);
186
- setFileArr(updateFiles);
187
- deleteFile(file);
188
- }
189
-
190
- function fileRemoveFromArary(file, i) {
191
- if (file instanceof File) {
192
- const updateFiles = fileArr.filter((item) => item.name !== file.name);
193
- setFileArr(updateFiles);
194
- } else {
195
- deleteItemFromServer(file, i);
196
- }
197
- }
198
-
199
- function openFileDialog() {
200
- fileInputRef.current.click();
201
- }
202
-
203
- return (
204
- <div>
205
- <div style={{ display: 'flex', width: 'inherit' }}>
206
- <Label
207
- customStyles={labelStyle}
208
- type={'label-text'}
209
- labelInline={labelInline}
210
- text={label}
211
- style={{
212
- display: 'flex',
213
- marginBottom: `${!labelInline ? '7px' : ''}`,
214
- paddingBottom: '0px',
215
- }}
216
- {...props}
217
- />
218
- {required && (
219
- <div
220
- style={{
221
- marginLeft: '4px',
222
- color: `${activeTheme.variant['error']}`,
223
- }}
224
- >
225
- *
226
- </div>
227
- )}
228
- </div>
229
- <ParentDiv
230
- theme={activeTheme}
231
- inBuiltCss={defaultStyles}
232
- defaultStyles={'dropzone-parent'}
233
- backgroundColor={backgroundColor}
234
- customDropzoneStyles={customDropzoneStyles}
235
- onDragLeave={onDragLeave}
236
- onDragOver={onDragOver}
237
- onDrop={onDrop}
238
- onClick={openFileDialog}
239
- hover={hover}
240
- isValid={isValid}
241
- fileArr={fileArr}
242
- >
243
- <InputFile
244
- ref={fileInputRef}
245
- type='file'
246
- id={id}
247
- multiple={singleFile == true ? false : true}
248
- onChange={onFilesAdded}
249
- onClick={(e) => (e.target.value = null)}
250
- {...props}
251
- />
252
- {isValid ? (
253
- <Icon
254
- icon='file-upload'
255
- color={
256
- hover ? activeTheme.bgColor : activeTheme.primary['primary-1']
257
- }
258
- size={24}
259
- />
260
- ) : null}
261
- <TextDiv
262
- isValid={isValid}
263
- hover={hover}
264
- customTextStyles={customTextStyles}
265
- inBuiltCss={defaultStyles}
266
- defaultStyles={'dropzone-text-div'}
267
- >
268
- {isValid ? (
269
- <div>
270
- <span
271
- style={{
272
- color: hover
273
- ? activeTheme.bgColor
274
- : activeTheme.primary['primary-1'],
275
- }}
276
- >
277
- Choose a file{' '}
278
- </span>
279
- <span
280
- style={{
281
- color: hover
282
- ? activeTheme.bgColor
283
- : activeTheme.neutral['neutral-2'],
284
- }}
285
- >
286
- or{' '}
287
- </span>
288
- <span
289
- style={{
290
- color: hover ? activeTheme.bgColor : activeTheme.textColor,
291
- }}
292
- >
293
- drag {singleFile ? 'it' : 'them'} here
294
- </span>
295
- </div>
296
- ) : (
297
- <div>
298
- <span style={{ color: activeTheme.variant['error'] }}>
299
- Try again!!{' '}
300
- </span>
301
- <span
302
- style={{
303
- color: activeTheme.textColor,
304
- }}
305
- >
306
- {message.length > messageSize
307
- ? message.slice(0, messageSize)
308
- : message}
309
- </span>
310
- </div>
311
- )}
312
- </TextDiv>
313
- </ParentDiv>
314
- {additionalText.length > 0 && (
315
- <AdditionalText>{additionalText}</AdditionalText>
316
- )}{' '}
317
- {fileArr?.map((item, i) => {
318
- return (
319
- <FileDiv
320
- inBuiltCss={defaultStyles}
321
- defaultStyles={'dropzone-file-div'}
322
- key={`${item}-${i}`}
323
- customFileStyles={customFileStyles}
324
- >
325
- <IconDiv>
326
- <Icon icon='file-icon' color={activeTheme.primary['primary-1']} />
327
- </IconDiv>
328
-
329
- {!(item instanceof File) ? (
330
- <a
331
- style={{
332
- color: activeTheme.variant['primary-1'],
333
- marginLeft: '5px',
334
- }}
335
- href={item?.path}
336
- target='_blank'
337
- rel='noreferrer'
338
- >
339
- {' '}
340
- {item.name}
341
- </a>
342
- ) : (
343
- <FileName
344
- inBuiltCss={defaultStyles}
345
- type={'dropzone-file-name'}
346
- customFileNameStyles={customFileNameStyles}
347
- >
348
- {item.name}
349
- </FileName>
350
- )}
351
-
352
- <OtherInfoDiv>{item?.otherInfo}</OtherInfoDiv>
353
-
354
- <CrossDiv
355
- key={(Math.random() * 101) | 0}
356
- onClick={() => fileRemoveFromArary(item, i)}
357
- >
358
- <div style={{ marginRight: '7px' }}>
359
- <Icon
360
- icon={`${!(item instanceof File) && 'cloud-icon'}`}
361
- color={activeTheme.primary['primary-1']}
362
- />
363
- </div>
364
-
365
- <Icon
366
- icon='cross-icon'
367
- color={activeTheme.neutral['neutral-2']}
368
- size={13}
369
- />
370
- </CrossDiv>
371
- </FileDiv>
372
- );
373
- })}
374
- </div>
375
- );
376
- };
377
-
378
- DropzoneInput.propTypes = {
379
- /**
380
- * onFileAdd function
381
- */
382
- onFilesAdded: PropTypes.func,
383
- /**
384
- * is the input file valid
385
- */
386
- isValid: PropTypes.bool,
387
- /**
388
- * invalid error messages (limit 100 characters)
389
- */
390
- message: PropTypes.string,
391
- /**
392
- * files that are added
393
- */
394
- fileArr: PropTypes.array,
395
- /**
396
- * files setter
397
- */
398
- setFileArr: PropTypes.func,
399
- /**
400
- * custom style of the dropzoneInput box
401
- */
402
- customDropzoneStyles: PropTypes.object,
403
- /**
404
- * custom style of the uploaded files
405
- */
406
- customFileStyles: PropTypes.object,
407
- /**
408
- * custom style of the text
409
- */
410
- customTextStyles: PropTypes.object,
411
- /**
412
- * custom style of the file name that are added on the preview
413
- */
414
- customFileNameStyles: PropTypes.object,
415
- /**
416
- * background color (in HEX format) of the dropzoneInput box
417
- */
418
- backgroundColor: PropTypes.string,
419
- /**
420
- * sting length of the message
421
- */
422
- messageSize: PropTypes.number,
423
- /**
424
- * Additional text between dropzone and files
425
- */
426
- additionalText: PropTypes.string,
427
-
428
- /**
429
- * Plus icon after file name is for file from local and cloud icon is for file from server
430
- */
431
- /**
432
- * id of the file input
433
- */
434
- id: PropTypes.string
435
- };
436
-
437
- DropzoneInput.defaultProps = {
438
- onFilesAdded: () => null,
439
- isValid: true,
440
- message: '',
441
- fileArr: [],
442
- setFileArr: () => { },
443
- customDropzoneStyles: {},
444
- customFileStyles: {},
445
- customTextStyles: {},
446
- customFileNameStyles: {},
447
- messageSize: 100,
448
- additionalText: '',
449
- id: ''
450
- };
@@ -1,177 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import styled, { css } from 'styled-components';
4
- import defaultThemeColor from '../constants/defaultThemeColor';
5
-
6
- const TextBox = styled.div`
7
- border: 1px solid
8
- ${({ theme }) =>
9
- theme.border};
10
- border-radius: 4px;
11
- padding: 6.5px 12px;
12
- display: flex;
13
- align-items: center;
14
- background-color: ${({ theme }) => theme.bgColor};
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
- width: 85%;
35
- border: 0;
36
- outline: 0;
37
- color: ${({ theme }) => theme.variant['primary-2']};
38
- margin: 0px;
39
- padding: 0;
40
- font-size: 14px;
41
- flex-grow: 1;
42
- flex-shrink: 0;
43
-
44
- // custom styles
45
- ${({ inputStyle }) => inputStyle}
46
- `;
47
-
48
- Input.defaultProps = {
49
- theme: defaultThemeColor,
50
- };
51
-
52
- const requiredAsterisk = css`
53
- &:after {
54
- content: ' *';
55
- color: ${({ theme }) => theme.variant['error']};
56
- }
57
- `;
58
-
59
- const Label = styled.label`
60
- display: flex;
61
- margin-right: 10px;
62
- align-content: center;
63
- align-items: center;
64
- justify-content: center;
65
- display: block;
66
- margin-bottom: ${({ labelInline }) => (labelInline ? '0' : '7px')};
67
- margin-right: ${({ labelInline }) => (labelInline ? '7px' : '')};
68
- padding-bottom: 0px;
69
- color: ${({ theme }) => theme.variant['neutral-2']};
70
-
71
- ${({ labelStyle }) => labelStyle}
72
- `;
73
-
74
- Label.defaultProps = {
75
- theme: defaultThemeColor,
76
- };
77
-
78
- const inline = css`
79
- display: flex;
80
- align-items: center;
81
- `;
82
-
83
- const Form = styled.div`
84
- ${({ labelInline }) => (labelInline ? inline : null)}
85
-
86
- > div {
87
- flex: 1 0 auto;
88
- }
89
- `;
90
-
91
- Form.defaultProps = {
92
- theme: defaultThemeColor,
93
- };
94
- export const NumericInput = ({
95
- label,
96
- inputValue,
97
- inputStyle,
98
- iconBefore,
99
- iconAfter,
100
- onChange,
101
- theme,
102
- id,
103
- labelStyle,
104
- ...props
105
- }) => {
106
- const handleChange = (e) => {
107
- const re = /^[0-9\b.-]+$/;
108
- const { value } = e.currentTarget;
109
- if (value === '' || re.test(value)) {
110
- onChange(value);
111
- }
112
- };
113
-
114
- console.log(labelStyle);
115
-
116
- return (
117
- <Form {...props}>
118
- {label.length > 0 && <Label labelStyle={labelStyle}
119
- >{label}</Label>}
120
- <div>
121
- <TextBox {...props}>
122
- <div className='input-icon'>{iconBefore}</div>
123
- <Input
124
- {...props}
125
- inputStyle={inputStyle}
126
- value={inputValue}
127
- onChange={handleChange}
128
- type='number'
129
- id={id}
130
- />
131
- <div className='input-icon' style={{ position: 'absolute', right: '7px' }}>{iconAfter}</div>
132
- </TextBox>
133
- </div>
134
- </Form>
135
- );
136
- };
137
-
138
- NumericInput.propTypes = {
139
- /**
140
- * Theme props
141
- */
142
- theme: PropTypes.object,
143
- /**
144
- * Label of Input
145
- */
146
- label: PropTypes.string,
147
- /**
148
- * Should label be inline?
149
- */
150
- labelInline: PropTypes.bool,
151
- /**
152
- * Value Prop
153
- */
154
- inputValue: PropTypes.any,
155
- /**
156
- * custom style of input element
157
- */
158
- inputStyle: PropTypes.object,
159
- /**
160
- * id of the number input
161
- */
162
- id: PropTypes.string,
163
- /**
164
- * custom style of label element
165
- */
166
- labelStyle: PropTypes.object,
167
- };
168
-
169
- NumericInput.defaultProps = {
170
- theme: defaultThemeColor,
171
- label: '',
172
- labelInline: false,
173
- inputStyle: {},
174
- inputValue: null,
175
- id: '',
176
- labelStyle: {},
177
- };