groundfloor-react-ui 1.0.0 → 1.0.3

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 (34) hide show
  1. package/README.md +9 -2
  2. package/assets/icons/eye-hide.svg +1 -1
  3. package/assets/icons/file-upload.svg +3 -0
  4. package/components/Accordion/Accordion.js +2 -2
  5. package/components/Button/PrimaryButton.js +4 -7
  6. package/components/Button/SecondaryButton.js +7 -8
  7. package/components/Footer/{FooterContentLev3.js → FooterContent.js} +6 -2
  8. package/components/Footer/index.js +1 -1
  9. package/components/Form/FormComponent.js +5 -2
  10. package/components/Form/HeaderComponent.js +1 -6
  11. package/components/Icon/Icon.js +16 -6
  12. package/components/Inputs/CheckBoxInput.js +1 -1
  13. package/components/Inputs/DateSelect.js +3 -4
  14. package/components/Inputs/DropdownSelect.js +292 -289
  15. package/components/Inputs/DropzoneInput.js +225 -137
  16. package/components/Inputs/NumericInput.js +6 -11
  17. package/components/Inputs/PasswordInput.js +192 -0
  18. package/components/Inputs/Signature.js +142 -109
  19. package/components/Inputs/TextArea.js +3 -4
  20. package/components/Inputs/TextInput.js +6 -7
  21. package/components/Inputs/TimeInput.js +5 -6
  22. package/components/Inputs/index.js +1 -0
  23. package/components/Modal/ModalComp.js +80 -46
  24. package/components/Modal/index.js +0 -1
  25. package/components/constants/defaultStyle.js +28 -33
  26. package/components/constants/defaultThemeColor.js +2 -1
  27. package/dist/index.es.js +538 -493
  28. package/dist/index.js +388 -343
  29. package/package.json +1 -1
  30. package/components/Inputs/CheckBoxEditableInput.js +0 -352
  31. package/components/Inputs/CheckBoxInputMS.js +0 -160
  32. package/components/Inputs/TextInputClicable.js +0 -198
  33. package/components/Inputs/TextInputClicableMS.js +0 -255
  34. package/components/Modal/Modal.js +0 -116
@@ -1,90 +1,132 @@
1
- import React, { useState, createRef } from "react";
1
+ import React, { useState, createRef } from 'react';
2
2
  import styled from 'styled-components';
3
3
  import defaultThemeColor from '../constants/defaultThemeColor';
4
- import PropTypes from "prop-types";
4
+ import PropTypes from 'prop-types';
5
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";
6
+ import getDefaultStyles from '../constants/utils';
7
+ import { hexToRGB } from '../constants/utils';
11
8
 
9
+ import { Icon } from '../Icon';
10
+ import { Label } from '../Label';
12
11
 
13
12
  const ParentDiv = styled.div`
14
-
15
- //Set the styles from the default styles object
16
- ${({ theme, defaultStyles }) => {
13
+ //Set the styles from the default styles object
14
+ ${({ theme, defaultStyles }) => {
17
15
  return getDefaultStyles(theme, defaultStyles);
18
16
  }}
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
17
 
31
-
32
- // custom styles
33
- ${({ customDropzoneStyles }) => customDropzoneStyles}
34
- `;
18
+ background-color:${({ hover, isValid, fileArr, backgroundColor }) =>
19
+ !isValid
20
+ ? 'rgba(215, 0, 0, 0.05)'
21
+ : hover
22
+ ? backgroundColor
23
+ : fileArr.length > 0
24
+ ? defaultThemeColor.bgColor
25
+ : hexToRGB(backgroundColor, 0.05)};
26
+ border: 1px
27
+ ${({ isValid, fileArr, backgroundColor }) =>
28
+ !isValid
29
+ ? 'dashed ' + defaultThemeColor.ui['error']
30
+ : fileArr.length > 0
31
+ ? 'solid ' + backgroundColor
32
+ : 'dashed ' + backgroundColor};
33
+
34
+ &:hover {
35
+ cursor: pointer;
36
+ }
37
+ transition: all 500ms linear;
35
38
 
39
+ // custom styles
40
+ ${({ customDropzoneStyles }) => customDropzoneStyles}
41
+ `;
36
42
 
37
43
  const FileDiv = styled.div`
38
- //Set the styles from the default styles object
39
- ${({ theme, defaultStyles }) => {
44
+ //Set the styles from the default styles object
45
+ ${({ theme, defaultStyles }) => {
40
46
  return getDefaultStyles(theme, defaultStyles);
41
47
  }}
42
-
43
- // custom styles
48
+
49
+ // custom styles
44
50
  ${({ customFileStyles }) => customFileStyles}
45
51
  `;
46
52
 
47
53
  const InputFile = styled.input`
48
- display: none;
54
+ display: none;
49
55
  `;
50
56
 
51
57
  const TextDiv = styled.div`
52
- //Set the styles from the default styles object
53
- ${({ theme, defaultStyles }) => {
58
+ //Set the styles from the default styles object
59
+ ${({ theme, defaultStyles }) => {
54
60
  return getDefaultStyles(theme, defaultStyles);
55
61
  }}
56
-
57
- // custom styles
62
+
63
+ // custom styles
58
64
  ${({ customTextStyles }) => customTextStyles}
59
65
  `;
60
66
 
61
67
  const FileName = styled.span`
62
- //Set the styles from the default styles object
63
- ${({ theme, type }) => {
68
+ //Set the styles from the default styles object
69
+ ${({ theme, type }) => {
64
70
  return getDefaultStyles(theme, type);
65
71
  }}
66
-
67
- // custom styles
72
+
73
+ // custom styles
68
74
  ${({ customFileNameStyles }) => customFileNameStyles}
69
75
  `;
70
76
 
71
77
  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
+ cursor: pointer;
79
+ padding-left: 1px;
80
+ margin-left: auto;
81
+ margin-right: 10px;
82
+ display: flex;
83
+ justify-content: center;
78
84
  `;
79
85
 
80
86
  const IconDiv = styled.div`
81
- margin-left: 11px;
82
- padding-left: 2px;
83
- display: flex;
84
- justify-content: center;
87
+ margin-left: 11px;
88
+ padding-left: 2px;
89
+ display: flex;
90
+ justify-content: center;
85
91
  `;
86
92
 
87
- export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, labelInline, required, message, fileArr, setFileArr, deleteFile, customDropzoneStyles, customFileStyles, customTextStyles, customFileNameStyles, backgroundColor, singleFile, messageSize, ...props }) => {
93
+ const OtherInfoDiv = styled.div`
94
+ color: #494949;
95
+ margin-left: 11px;
96
+ padding-left: 2px;
97
+ `
98
+
99
+ const AdditionalText = styled.p`
100
+ color: #494949;
101
+ display: flex;
102
+ justify-content: center;
103
+ align-items: center;
104
+ margin:20px 0px;
105
+ font-size: 14px;
106
+ `
107
+
108
+ export const DropzoneInput = ({
109
+ theme,
110
+ themeColor,
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
+ ...props
129
+ }) => {
88
130
  const [hover, setHover] = useState(false);
89
131
  const fileInputRef = createRef();
90
132
 
@@ -99,13 +141,11 @@ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, l
99
141
  setHover(true);
100
142
  }
101
143
 
102
-
103
144
  function onDragLeave(event) {
104
145
  stopEvent(event);
105
146
  setHover(false);
106
147
  }
107
148
 
108
-
109
149
  function onDrop(event) {
110
150
  stopEvent(event);
111
151
 
@@ -114,24 +154,24 @@ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, l
114
154
  props.onFilesAdded(fileListToArray(files, singleFile));
115
155
  }
116
156
 
117
-
118
157
  function stopEvent(event) {
119
158
  event.preventDefault();
120
159
  event.stopPropagation();
121
160
  }
122
161
 
123
-
124
162
  function fileListToArray(list, singleFile) {
125
163
  let result = singleFile == true ? [] : [...fileArr];
126
164
  for (let i = 0; i < list.length; i++) {
127
165
  result.push(list.item(i));
128
166
  }
129
167
  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
- )
168
+ result = result.filter(
169
+ (value, index, self) =>
170
+ index ===
171
+ self.findIndex(
172
+ (t) => t.place === value.place && t.name === value.name
173
+ )
174
+ );
135
175
  }
136
176
  setFileArr(result);
137
177
  setHover(false);
@@ -139,36 +179,29 @@ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, l
139
179
  }
140
180
 
141
181
  function deleteItemFromServer(file, i) {
142
- const updateFiles = fileArr.filter(item => item.name !== file.name);
182
+ const updateFiles = fileArr.filter((item) => item.name !== file.name);
143
183
  setFileArr(updateFiles);
144
184
  deleteFile(file);
145
185
  }
146
186
 
147
187
  function fileRemoveFromArary(file, i) {
148
188
  if (file instanceof File) {
149
- const updateFiles = fileArr.filter(item => item.name !== file.name);
189
+ const updateFiles = fileArr.filter((item) => item.name !== file.name);
150
190
  setFileArr(updateFiles);
151
- // console.log(updateFiles,fileArr);
152
191
  } else {
153
192
  deleteItemFromServer(file, i);
154
193
  }
155
194
  }
156
195
 
157
-
158
196
  function openFileDialog() {
159
197
  fileInputRef.current.click();
160
198
  }
161
199
  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
- }}>
200
+ <div
201
+ style={{
202
+ paddingBottom: '5px',
203
+ }}
204
+ >
172
205
  <div style={{ display: 'flex' }}>
173
206
  <Label
174
207
  themeColor={defaultThemeColor}
@@ -177,14 +210,21 @@ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, l
177
210
  labelInline={labelInline}
178
211
  text={label}
179
212
  style={{
180
- 'display': 'flex',
181
- 'paddingBottom': `${!labelInline ? '16.64px' : ''}`,
213
+ display: 'flex',
214
+ paddingBottom: `${!labelInline ? '7px' : ''}`,
182
215
  }}
183
- {...props} />
184
- {required && <div style={{
185
- marginLeft: '4px',
186
- color: `${themeColor.variant['error']}`
187
- }} >*</div>}
216
+ {...props}
217
+ />
218
+ {required && (
219
+ <div
220
+ style={{
221
+ marginLeft: '4px',
222
+ color: `${themeColor.variant['error']}`,
223
+ }}
224
+ >
225
+ *
226
+ </div>
227
+ )}
188
228
  </div>
189
229
  <ParentDiv
190
230
  theme={defaultStyles}
@@ -202,63 +242,109 @@ export const DropzoneInput = ({ theme, themeColor, isValid, label, labelStyle, l
202
242
  >
203
243
  <InputFile
204
244
  ref={fileInputRef}
205
- type="file"
245
+ type='file'
206
246
  multiple={singleFile == true ? false : true}
207
247
  onChange={onFilesAdded}
208
- onClick={(e) => e.target.value = null}
248
+ onClick={(e) => (e.target.value = null)}
209
249
  {...props}
210
250
  />
211
- {isValid ?
251
+ {isValid ? (
212
252
  <Icon
213
- icon='file-attach'
253
+ icon='file-upload'
214
254
  color={hover ? themeColor.bgColor : backgroundColor}
215
- size={24} />
216
- : null}
217
- <TextDiv isValid={isValid} hover={hover} customTextStyles={customTextStyles}
255
+ size={24}
256
+ />
257
+ ) : null}
258
+ <TextDiv
259
+ isValid={isValid}
260
+ hover={hover}
261
+ customTextStyles={customTextStyles}
218
262
  theme={defaultStyles}
219
- defaultStyles={'dropzone-text-div'}>
220
- {isValid ?
263
+ defaultStyles={'dropzone-text-div'}
264
+ >
265
+ {isValid ? (
221
266
  <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>
267
+ <span
268
+ style={{ color: hover ? themeColor.bgColor : backgroundColor }}
269
+ >
270
+ Choose a file{' '}
271
+ </span>
272
+ <span
273
+ style={{
274
+ color: hover
275
+ ? themeColor.bgColor
276
+ : themeColor.neutral['neutral-2'],
277
+ }}
278
+ >
279
+ or{' '}
280
+ </span>
281
+ <span
282
+ style={{
283
+ color: hover ? themeColor.bgColor : themeColor.textColor,
284
+ }}
285
+ >
286
+ drag {singleFile ? 'it' : 'them'} here
287
+ </span>
225
288
  </div>
226
- :
289
+ ) : (
227
290
  <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>
291
+ <span style={{ color: themeColor.variant['error'] }}>
292
+ Try again!!{' '}
293
+ </span>
294
+ <span
295
+ style={{
296
+ color: theme.textColor,
297
+ }}
298
+ >
299
+ {message.length > messageSize
300
+ ? message.slice(0, messageSize)
301
+ : message}
302
+ </span>
232
303
  </div>
233
- }
304
+ )}
234
305
  </TextDiv>
235
306
  </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
307
+ {additionalText.length > 0 && <AdditionalText>{additionalText}</AdditionalText>
308
+ } {fileArr?.map((item, i) => {
309
+ return (
310
+ <FileDiv
245
311
  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>
312
+ defaultStyles={'dropzone-file-div'}
313
+ key={`${item}-${i}`}
314
+ customFileStyles={customFileStyles}
315
+ >
316
+ <IconDiv>
317
+ <Icon icon='pdf-icon' />
318
+ </IconDiv>
319
+ <FileName
320
+ theme={defaultStyles}
321
+ type={'dropzone-file-name'}
322
+ customFileNameStyles={customFileNameStyles}
323
+ >
324
+ {item.name}
325
+ </FileName>
326
+
327
+
328
+ <IconDiv>
329
+ <Icon icon={`${!(item instanceof File) && 'cloud-icon'}`} />
330
+ </IconDiv>
331
+ <OtherInfoDiv>{item?.otherInfo}</OtherInfoDiv>
332
+ <CrossDiv
333
+ key={(Math.random() * 101) | 0}
334
+ onClick={() => fileRemoveFromArary(item, i)}
335
+ >
336
+ <Icon
337
+ icon='cross-icon'
338
+ color={themeColor.neutral['neutral-2']}
339
+ size={13}
340
+ />
341
+ </CrossDiv>
342
+ </FileDiv>
343
+ );
258
344
  })}
259
345
  </div>
260
- )
261
- }
346
+ );
347
+ };
262
348
 
263
349
  DropzoneInput.propTypes = {
264
350
  /**
@@ -275,46 +361,48 @@ DropzoneInput.propTypes = {
275
361
  isValid: PropTypes.bool,
276
362
  /**
277
363
  * invalid error messages (limit 100 characters)
278
- */
364
+ */
279
365
  message: PropTypes.string,
280
366
  /**
281
367
  * files that are added
282
- */
368
+ */
283
369
  fileArr: PropTypes.array,
284
370
  /**
285
371
  * files setter
286
- */
372
+ */
287
373
  setFileArr: PropTypes.func,
288
374
  /**
289
375
  * custom style of the dropzoneInput box
290
- */
376
+ */
291
377
  customDropzoneStyles: PropTypes.object,
292
378
  /**
293
379
  * custom style of the uploaded files
294
- */
380
+ */
295
381
  customFileStyles: PropTypes.object,
296
382
  /**
297
383
  * custom style of the text
298
- */
384
+ */
299
385
  customTextStyles: PropTypes.object,
300
386
  /**
301
387
  * custom style of the file name that are added on the preview
302
- */
388
+ */
303
389
  customFileNameStyles: PropTypes.object,
304
390
  /**
305
391
  * background color (in HEX format) of the dropzoneInput box
306
- */
392
+ */
307
393
  backgroundColor: PropTypes.string,
308
394
  /**
309
- * sting length of the message
310
- */
311
- messageSize: PropTypes.number
312
-
313
-
395
+ * sting length of the message
396
+ */
397
+ messageSize: PropTypes.number,
398
+ /**
399
+ * Additional text between dropzone and files
400
+ */
401
+ additionalText: PropTypes.string,
314
402
 
315
403
  /**
316
404
  * Plus icon after file name is for file from local and cloud icon is for file from server
317
- */
405
+ */
318
406
  };
319
407
 
320
408
  DropzoneInput.defaultProps = {
@@ -330,6 +418,6 @@ DropzoneInput.defaultProps = {
330
418
  customFileStyles: {},
331
419
  customTextStyles: {},
332
420
  customFileNameStyles: {},
333
- messageSize: 100
334
- };
335
-
421
+ messageSize: 100,
422
+ additionalText: ''
423
+ };
@@ -3,15 +3,13 @@ import PropTypes from 'prop-types';
3
3
  import styled, { css, useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
 
6
- const border = `#D4D7E3`;
7
-
8
6
  const TextBox = styled.div`
9
- border: 1px solid ${({ theme }) => theme ? border : theme.variant['primary-1']};
7
+ border: 1px solid ${({ theme }) => theme ? defaultThemeColor.border : theme.variant['primary-1']};
10
8
  border-radius: 4px;
11
- padding: 5px 12px;
9
+ padding: 6.5px 12px;
12
10
  display: flex;
13
11
  align-items: center;
14
-
12
+ background-color: ${({ theme }) => theme.bgColor};
15
13
  .input-icon svg path {
16
14
  fill: ${({ theme }) => theme.variant['neutral-1']};
17
15
  }
@@ -58,13 +56,12 @@ const requiredAsterisk = css`
58
56
  const Label = styled.label`
59
57
  display: flex;
60
58
  margin-right: 10px;
61
- color: #929EAC;
62
59
  align-content: center;
63
60
  align-items: center;
64
61
  justify-content: center;
65
62
  display: block;
66
- margin-bottom: ${({ labelInline, }) => (labelInline) ? '0' : '16px'};
67
- margin-right: ${({ labelInline }) => labelInline ? '10px' : ''};
63
+ margin-bottom: ${({ labelInline, }) => (labelInline) ? '0' : '7px'};
64
+ margin-right: ${({ labelInline }) => labelInline ? '7px' : ''};
68
65
  color: ${({ theme }) => theme.variant['neutral-2']};
69
66
  `;
70
67
 
@@ -88,7 +85,6 @@ const Form = styled.div`
88
85
  Form.defaultProps = {
89
86
  theme: defaultThemeColor,
90
87
  }
91
-
92
88
  export const NumericInput = ({ label, inputValue, inputStyle, iconBefore, iconAfter, onChange, ...props }) => {
93
89
  const handleChange = (e) => {
94
90
  const re = /^[0-9\b.-]+$/;
@@ -151,5 +147,4 @@ NumericInput.defaultProps = {
151
147
  labelInline: false,
152
148
  inputStyle: {},
153
149
  inputValue: null,
154
- }
155
-
150
+ }