groundfloor-react-ui 1.0.3 → 1.0.6

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.
@@ -1,13 +1,12 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
- import Select, { components } from "react-select";
4
+ import Select, { components } from 'react-select';
5
5
  import defaultThemeColor from '../constants/defaultThemeColor';
6
6
  import defaultStyles from '../constants/defaultStyle';
7
7
  import getDefaultStyles from '../constants/utils';
8
8
  import { Label } from '../Label';
9
- import { Icon } from "../Icon";
10
- // import { LoadingIndicatorProps } from 'react-select';
9
+ import { Icon } from '../Icon';
11
10
 
12
11
  const Wrapper = styled.div`
13
12
 
@@ -56,14 +55,15 @@ const Wrapper = styled.div`
56
55
 
57
56
  .master-dropdown__control,
58
57
  .new-select__control {
59
- border:${({ isValid, }) => !isValid ? '0.5px solid ' + defaultThemeColor.ui['error'] :
60
- '0.5px solid ' + defaultThemeColor.neutral['neutral-4']};
58
+ border:${({ isValid }) =>
59
+ !isValid
60
+ ? '0.5px solid ' + defaultThemeColor.ui['error']
61
+ : '0.5px solid ' + defaultThemeColor.neutral['neutral-4']};
61
62
  }
62
63
 
63
64
  .master-dropdown__option,
64
65
  .new-select__option {
65
66
  color: ${defaultThemeColor.textColor};
66
- font-size: 14px;
67
67
  padding-top: 3px;
68
68
  padding-bottom: 3px;
69
69
  margin: 8px 0;
@@ -83,7 +83,10 @@ const Wrapper = styled.div`
83
83
 
84
84
  .new-select__control:hover,
85
85
  .new-select__control--is-focused {
86
- border: ${({ isValid, }) => !isValid ? '0.5px solid ' + defaultThemeColor.ui['error'] : '0.5px solid ' + defaultThemeColor.primary['primary-1']};
86
+ border: ${({ isValid }) =>
87
+ !isValid
88
+ ? '0.5px solid ' + defaultThemeColor.ui['error']
89
+ : '0.5px solid ' + defaultThemeColor.primary['primary-1']};
87
90
  box-shadow: none;
88
91
  }
89
92
 
@@ -128,7 +131,7 @@ const Wrapper = styled.div`
128
131
 
129
132
  .text-main-alt {
130
133
  color: ${defaultThemeColor.textColor} !important;
131
- font-size:14px;
134
+ // font-size:14px;
132
135
  }
133
136
  .text-more-alt{
134
137
  font-size:12px;
@@ -155,57 +158,66 @@ const Wrapper = styled.div`
155
158
  margin:0px;
156
159
  padding:0px;
157
160
  }
158
- `
159
-
161
+
162
+ `;
160
163
 
161
164
  const LabelWrapper = styled.div`
162
-
163
- // Default style
164
- display: flex;
165
-
165
+ // Default style
166
+ display: flex;
166
167
 
167
168
  //Set the styles from the default styles object
168
- ${({ theme, labelWrapperStyle }) => {
169
+ ${({ theme, labelWrapperStyle }) => {
169
170
  return getDefaultStyles(theme, labelWrapperStyle);
170
171
  }}
171
- // custom styles
172
+ // custom styles
172
173
  ${({ customLabelStyles }) => customLabelStyles}
173
- `
174
+ `;
174
175
  const IconDiv = styled.div`
175
- margin-left: 6px;
176
- margin-top:-14px;
177
- cursor:pointer;
176
+ margin-left: 6px;
177
+ margin-top: -14px;
178
+ cursor: pointer;
178
179
  `;
179
180
 
180
- export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelStyle, label, isRequired, optionArr, selectedValue, setSelectedValue, placeHolder, dropdownType, isDisabled, isValid, clearSelected, isClearSelected, isLoading, height, placeholderSize, ...props }) => {
181
- const DropdownIndicator = p => {
181
+ export const DropdownSelect = ({
182
+ customWrapperStyles,
183
+ customLabelStyles,
184
+ labelStyle,
185
+ label,
186
+ isRequired,
187
+ optionArr,
188
+ selectedValue,
189
+ setSelectedValue,
190
+ placeHolder,
191
+ dropdownType,
192
+ isDisabled,
193
+ isValid,
194
+ clearSelected,
195
+ isClearSelected,
196
+ isLoading,
197
+ height,
198
+ fontSize,
199
+ ...props
200
+ }) => {
201
+ const DropdownIndicator = (p) => {
182
202
  return (
183
203
  <components.DropdownIndicator {...p}>
184
- {isClearSelected == true ?
185
- <IconDiv onClick={() => { clearSelected() }}>
186
- <Icon icon='cross-icon'
187
- color={'black'}
188
- size={8} />
204
+ {isClearSelected == true ? (
205
+ <IconDiv
206
+ onClick={() => {
207
+ clearSelected();
208
+ }}
209
+ >
210
+ <Icon icon='cross-icon' color={'black'} size={8} />
189
211
  </IconDiv>
190
- : null}
212
+ ) : null}
191
213
  <IconDiv>
192
- <Icon icon='triangle-down'
193
- color={'black'}
194
- size={8} />
214
+ <Icon icon='triangle-down' color={'black'} size={8} />
195
215
  </IconDiv>
196
216
  </components.DropdownIndicator>
197
217
  );
198
218
  };
199
219
 
200
- // const LoadingIndicator = (LoadingIndicatorProps) => {
201
- // return (
202
- // <div className='custom-loader'>
203
- // <Icon icon='arrow-rotate' color='black' />
204
- // </div>
205
- // );
206
- // };
207
-
208
- const Option = p => {
220
+ const Option = (p) => {
209
221
  const checkboxStyle = {
210
222
  width: '15px',
211
223
  height: '15px',
@@ -215,16 +227,28 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
215
227
  lineHeight: '10px',
216
228
  };
217
229
  const checked = (
218
- <div style={{ ...checkboxStyle, backgroundColor: p?.data?.color ?? '#2E56F4' }}>
230
+ <div
231
+ style={{
232
+ ...checkboxStyle,
233
+ backgroundColor: p?.data?.color ?? '#2E56F4',
234
+ }}
235
+ >
219
236
  <Icon icon='check-icon' color='white' />
220
237
  </div>
221
- )
238
+ );
222
239
  const unchecked = (
223
- <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }} ></div>
224
- )
240
+ <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }}></div>
241
+ );
225
242
  return (
226
243
  <components.Option {...p}>
227
- <div style={{ display: 'flex', justifyContent: 'start', alignItems: 'center', width: '100%' }}>
244
+ <div
245
+ style={{
246
+ display: 'flex',
247
+ justifyContent: 'start',
248
+ alignItems: 'center',
249
+ width: '100%',
250
+ }}
251
+ >
228
252
  {p.isSelected ? checked : unchecked}
229
253
  <div className='text-main-alt' style={{ marginLeft: '10px' }}>
230
254
  {p.label}
@@ -234,81 +258,53 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
234
258
  );
235
259
  };
236
260
 
237
- // const ValueContainer = p => {
238
- // if (props.value.length < 1) {
239
- // return (
240
- // <components.ValueContainer {...p}>
241
- // {p.children}
242
- // </components.ValueContainer>
243
- // );
244
- // }
245
- // let firstSelected = props.value[0].label;
246
- // let moreComp = (
247
- // <div className='ml-auto'>
248
- // &amp; {props.value.length - 1} more
249
- // </div>
250
- // )
251
- // return (
252
- // <components.ValueContainer {...p}>
253
- // <div className="d-flex w-100">
254
- // <div>
255
- // {firstSelected}
256
- // </div>
257
- // {props.value.length > 1 && moreComp}
258
- // </div>
259
- // </components.ValueContainer>
260
- // );
261
- // };
262
-
263
261
  const MultiValue = ({ getValue, index, ...p }) => {
264
262
  const firstSelected = p?.data?.label || 'Select';
265
- const len = getValue().length
266
- return !index && (
267
- <div className='multiValue-wrapper'>
268
- <div className='text-main-alt'>
269
- {firstSelected}
263
+ const len = getValue().length;
264
+ return (
265
+ !index && (
266
+ <div className='multiValue-wrapper'>
267
+ <div className='text-main-alt'>{firstSelected}</div>
268
+ {len > 1 && (
269
+ <div className={`text-more-alt`}>&amp; {len - 1} more</div>
270
+ )}
270
271
  </div>
271
- {len > 1 && <div className={`text-more-alt`}>
272
- &amp; {len - 1} more
273
- </div>}
274
- </div>
275
- )
276
- }
277
-
278
-
272
+ )
273
+ );
274
+ };
279
275
 
280
276
  const stylesComp = {
281
-
282
- control: base => ({
277
+ control: (base) => ({
283
278
  ...base,
284
279
  border: '1px solid #d4d7e3',
285
280
  height: `${height}px`,
286
281
  minHeight: `${height}px`,
287
282
  minWidth: '226px',
288
283
  }),
289
- placeholder: base => ({
284
+ placeholder: (base) => ({
290
285
  ...base,
291
- fontSize: placeholderSize + 'px',
292
- marginLeft: '0px'
286
+ fontSize: fontSize + 'px',
287
+ marginLeft: '0px',
293
288
  }),
294
- dropdownIndicator: base => ({
289
+ dropdownIndicator: (base) => ({
295
290
  ...base,
296
291
  height: `${height}px`,
297
292
  display: 'flex',
298
293
  justifyContent: 'center',
299
294
  alignItems: 'center',
300
295
  }),
301
- valueContainer: base => ({
296
+ valueContainer: (base) => ({
302
297
  ...base,
303
- height: `${height}px`,
304
- padding: '7px 8px'
298
+ // height: `${height}px`,
299
+ // padding: '7px 8px',
300
+ fontSize: fontSize + 'px',
305
301
  }),
306
- indicatorsContainer: base => ({
302
+ indicatorsContainer: (base) => ({
307
303
  ...base,
308
304
  padding: 0,
309
305
  height: `${height}px`,
310
306
  }),
311
- menu: base => ({
307
+ menu: (base) => ({
312
308
  ...base,
313
309
  border: 'none',
314
310
  marginTop: '1px',
@@ -317,47 +313,59 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
317
313
  outline: 'none',
318
314
  boxShadow: '0px 6px 20px rgba(56, 66, 100, 0.15)',
319
315
  borderRadius: '4.32px',
320
- fontSize: '14px'
321
-
316
+ fontSize: fontSize + 'px',
317
+ }),
318
+ singleValue: (base) => ({
319
+ ...base,
320
+ fontSize: fontSize + 'px',
321
+ marginLeft: '0px',
322
322
  }),
323
- singleValue: base => ({
323
+ multiValue: (base) => ({
324
324
  ...base,
325
- fontSize: '14px',
326
- marginLeft: '0px'
325
+ marginLeft: '0px',
327
326
  }),
328
- input: base => ({
327
+ input: (base) => ({
329
328
  ...base,
330
- fontSize: '14px',
329
+ fontSize: fontSize + 'px',
331
330
  }),
332
331
  option: (provided, state) => ({
333
332
  ...provided,
334
- backgroundColor: state.isSelected || state.isFocused ? '#F0F3F8' : 'white',
333
+ backgroundColor:
334
+ state.isSelected || state.isFocused ? '#F0F3F8' : 'white',
335
335
  padding: '10px',
336
336
  cursor: 'pointer',
337
- color: '#081348'
337
+ color: '#081348',
338
338
  }),
339
339
  ...props.styles,
340
- }
340
+ };
341
341
  return (
342
- <Wrapper style={customWrapperStyles} isValid={isValid} placeholderSize={placeholderSize}
343
- >
344
-
345
- {label && <LabelWrapper theme={defaultStyles}
346
- labelWrapperStyle={'selectComp-label-wrapper'} style={customLabelStyles}>
347
- <Label
348
- themeColor={defaultThemeColor}
349
- customStyles={labelStyle}
350
- type={'label-text'}
351
- text={label}
352
- style={{ marginBottom: '7px' }}
353
- />
354
- {isRequired && <div style={{
355
- marginLeft: '4px',
356
- color: `${defaultThemeColor.ui['error']}`
357
- }} >*</div>}
358
- </LabelWrapper>}
359
- {dropdownType === 'multiSelect' ?
360
-
342
+ <Wrapper style={customWrapperStyles} isValid={isValid} fontSize={fontSize}>
343
+ {label && (
344
+ <LabelWrapper
345
+ theme={defaultStyles}
346
+ labelWrapperStyle={'selectComp-label-wrapper'}
347
+ style={customLabelStyles}
348
+ >
349
+ <Label
350
+ themeColor={defaultThemeColor}
351
+ customStyles={labelStyle}
352
+ type={'label-text'}
353
+ text={label}
354
+ style={{ marginBottom: '7px', paddingBottom: '0px' }}
355
+ />
356
+ {isRequired && (
357
+ <div
358
+ style={{
359
+ marginLeft: '4px',
360
+ color: `${defaultThemeColor.ui['error']}`,
361
+ }}
362
+ >
363
+ *
364
+ </div>
365
+ )}
366
+ </LabelWrapper>
367
+ )}
368
+ {dropdownType === 'multiSelect' ? (
361
369
  <Select
362
370
  components={{
363
371
  DropdownIndicator,
@@ -365,11 +373,11 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
365
373
  Option,
366
374
  // LoadingIndicator: () => null,
367
375
  IndicatorSeparator: () => null,
368
- ClearIndicator: () => null
376
+ ClearIndicator: () => null,
369
377
  }}
370
- className="select-manage-page"
371
- classNamePrefix="new-select"
372
- name={"select-dropdown mb-1"}
378
+ className='select-manage-page'
379
+ classNamePrefix='new-select'
380
+ name={'select-dropdown'}
373
381
  onChange={setSelectedValue}
374
382
  placeholder={placeHolder}
375
383
  value={selectedValue}
@@ -383,38 +391,36 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
383
391
  onMenuClose={props.onMenuClose}
384
392
  isSearchable={false}
385
393
  isLoading={isLoading}
386
-
387
394
  {...props}
388
- /> :
395
+ />
396
+ ) : (
389
397
  <Select
390
398
  components={{
391
399
  DropdownIndicator,
392
400
  // LoadingIndicator,
393
401
  IndicatorSeparator: () => null,
394
- ClearIndicator: () => null
402
+ ClearIndicator: () => null,
395
403
  }}
396
- className="select-manage-page"
404
+ className='select-manage-page'
397
405
  // className="new-select"
398
- classNamePrefix="new-select"
399
- name={"select-dropdown"}
406
+ classNamePrefix='new-select'
407
+ name={'select-dropdown'}
400
408
  options={optionArr}
401
409
  placeholder={placeHolder}
402
410
  isDisabled={isDisabled}
403
411
  value={{
404
412
  value: selectedValue ? selectedValue.value : '',
405
- label: selectedValue ? selectedValue.label : ''
413
+ label: selectedValue ? selectedValue.label : '',
406
414
  }}
407
415
  styles={stylesComp}
408
416
  onChange={setSelectedValue}
409
417
  isLoading={isLoading}
410
418
  {...props}
411
419
  />
412
-
413
-
414
- }
420
+ )}
415
421
  </Wrapper>
416
- )
417
- }
422
+ );
423
+ };
418
424
 
419
425
  DropdownSelect.propTypes = {
420
426
  /**
@@ -430,12 +436,12 @@ DropdownSelect.propTypes = {
430
436
  */
431
437
  optionArr: PropTypes.array,
432
438
  /**
433
- * SelectBox Selected value. This is a array of object must be with this format:
434
- [{
435
- label:string,
436
- value:string
437
- }]
438
- */
439
+ * SelectBox Selected value. This is a array of object must be with this format:
440
+ [{
441
+ label:string,
442
+ value:string
443
+ }]
444
+ */
439
445
  selectedValue: PropTypes.object,
440
446
  /**
441
447
  * Function to set selected value
@@ -446,14 +452,14 @@ DropdownSelect.propTypes = {
446
452
  */
447
453
  placeHolder: PropTypes.string,
448
454
  /**
449
- * SelectBox Placeholder's font size
450
- */
451
- placeholderSize: PropTypes.number,
455
+ * SelectBox Placeholder's font size
456
+ */
457
+ fontSize: PropTypes.number,
452
458
  /**
453
- * This Function will be called if cross button pressed
454
- */
459
+ * This Function will be called if cross button pressed
460
+ */
455
461
  clearSelected: PropTypes.func,
456
- }
462
+ };
457
463
 
458
464
  DropdownSelect.defaultProps = {
459
465
  label: '',
@@ -465,5 +471,5 @@ DropdownSelect.defaultProps = {
465
471
  isValid: true,
466
472
  isClearSelected: false,
467
473
  height: 31,
468
- placeholderSize: 14
469
- }
474
+ fontSize: 14,
475
+ };
@@ -94,16 +94,16 @@ const OtherInfoDiv = styled.div`
94
94
  color: #494949;
95
95
  margin-left: 11px;
96
96
  padding-left: 2px;
97
- `
97
+ `;
98
98
 
99
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
- `
100
+ color: #494949;
101
+ display: flex;
102
+ justify-content: center;
103
+ align-items: center;
104
+ margin: 20px 0px;
105
+ font-size: 14px;
106
+ `;
107
107
 
108
108
  export const DropzoneInput = ({
109
109
  theme,
@@ -198,11 +198,9 @@ export const DropzoneInput = ({
198
198
  }
199
199
  return (
200
200
  <div
201
- style={{
202
- paddingBottom: '5px',
203
- }}
201
+
204
202
  >
205
- <div style={{ display: 'flex' }}>
203
+ <div style={{ display: 'flex', width: 'inherit' }}>
206
204
  <Label
207
205
  themeColor={defaultThemeColor}
208
206
  customStyles={labelStyle}
@@ -211,7 +209,8 @@ export const DropzoneInput = ({
211
209
  text={label}
212
210
  style={{
213
211
  display: 'flex',
214
- paddingBottom: `${!labelInline ? '7px' : ''}`,
212
+ marginBottom: `${!labelInline ? '7px' : ''}`,
213
+ paddingBottom: '0px',
215
214
  }}
216
215
  {...props}
217
216
  />
@@ -304,8 +303,10 @@ export const DropzoneInput = ({
304
303
  )}
305
304
  </TextDiv>
306
305
  </ParentDiv>
307
- {additionalText.length > 0 && <AdditionalText>{additionalText}</AdditionalText>
308
- } {fileArr?.map((item, i) => {
306
+ {additionalText.length > 0 && (
307
+ <AdditionalText>{additionalText}</AdditionalText>
308
+ )}{' '}
309
+ {fileArr?.map((item, i) => {
309
310
  return (
310
311
  <FileDiv
311
312
  theme={defaultStyles}
@@ -314,21 +315,25 @@ export const DropzoneInput = ({
314
315
  customFileStyles={customFileStyles}
315
316
  >
316
317
  <IconDiv>
317
- <Icon icon='pdf-icon' />
318
+ <Icon icon='file-icon' />
318
319
  </IconDiv>
319
- <FileName
320
+
321
+ {!(item instanceof File) ? <a style={{ color: defaultThemeColor.variant['primary-1'], marginLeft: '5px' }} href={item?.path} target="_blank" rel="noreferrer"> {item.name}
322
+ </a> : <FileName
320
323
  theme={defaultStyles}
321
324
  type={'dropzone-file-name'}
322
325
  customFileNameStyles={customFileNameStyles}
323
326
  >
324
327
  {item.name}
325
- </FileName>
328
+ </FileName>}
329
+
330
+
326
331
 
327
332
 
333
+ <OtherInfoDiv>{item?.otherInfo}</OtherInfoDiv>
328
334
  <IconDiv>
329
335
  <Icon icon={`${!(item instanceof File) && 'cloud-icon'}`} />
330
336
  </IconDiv>
331
- <OtherInfoDiv>{item?.otherInfo}</OtherInfoDiv>
332
337
  <CrossDiv
333
338
  key={(Math.random() * 101) | 0}
334
339
  onClick={() => fileRemoveFromArary(item, i)}
@@ -396,8 +401,8 @@ DropzoneInput.propTypes = {
396
401
  */
397
402
  messageSize: PropTypes.number,
398
403
  /**
399
- * Additional text between dropzone and files
400
- */
404
+ * Additional text between dropzone and files
405
+ */
401
406
  additionalText: PropTypes.string,
402
407
 
403
408
  /**
@@ -419,5 +424,5 @@ DropzoneInput.defaultProps = {
419
424
  customTextStyles: {},
420
425
  customFileNameStyles: {},
421
426
  messageSize: 100,
422
- additionalText: ''
427
+ additionalText: '',
423
428
  };