groundfloor-react-ui 1.0.4 → 1.0.7

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,62 +158,66 @@ const Wrapper = styled.div`
155
158
  margin:0px;
156
159
  padding:0px;
157
160
  }
158
- .css-eehvce-Input{
159
- margin:0px;
160
- padding:0px;
161
- line-height:1.3;
162
- }
163
- `
164
-
161
+
162
+ `;
165
163
 
166
164
  const LabelWrapper = styled.div`
167
-
168
- // Default style
169
- display: flex;
170
-
165
+ // Default style
166
+ display: flex;
171
167
 
172
168
  //Set the styles from the default styles object
173
- ${({ theme, labelWrapperStyle }) => {
169
+ ${({ theme, labelWrapperStyle }) => {
174
170
  return getDefaultStyles(theme, labelWrapperStyle);
175
171
  }}
176
- // custom styles
172
+ // custom styles
177
173
  ${({ customLabelStyles }) => customLabelStyles}
178
- `
174
+ `;
179
175
  const IconDiv = styled.div`
180
- margin-left: 6px;
181
- margin-top:-14px;
182
- cursor:pointer;
176
+ margin-left: 6px;
177
+ margin-top: -14px;
178
+ cursor: pointer;
183
179
  `;
184
180
 
185
- export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelStyle, label, isRequired, optionArr, selectedValue, setSelectedValue, placeHolder, dropdownType, isDisabled, isValid, clearSelected, isClearSelected, isLoading, height, placeholderSize, ...props }) => {
186
- 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) => {
187
202
  return (
188
203
  <components.DropdownIndicator {...p}>
189
- {isClearSelected == true ?
190
- <IconDiv onClick={() => { clearSelected() }}>
191
- <Icon icon='cross-icon'
192
- color={'black'}
193
- size={8} />
204
+ {isClearSelected == true ? (
205
+ <IconDiv
206
+ onClick={() => {
207
+ clearSelected();
208
+ }}
209
+ >
210
+ <Icon icon='cross-icon' color={'black'} size={8} />
194
211
  </IconDiv>
195
- : null}
212
+ ) : null}
196
213
  <IconDiv>
197
- <Icon icon='triangle-down'
198
- color={'black'}
199
- size={8} />
214
+ <Icon icon='triangle-down' color={'black'} size={8} />
200
215
  </IconDiv>
201
216
  </components.DropdownIndicator>
202
217
  );
203
218
  };
204
219
 
205
- // const LoadingIndicator = (LoadingIndicatorProps) => {
206
- // return (
207
- // <div className='custom-loader'>
208
- // <Icon icon='arrow-rotate' color='black' />
209
- // </div>
210
- // );
211
- // };
212
-
213
- const Option = p => {
220
+ const Option = (p) => {
214
221
  const checkboxStyle = {
215
222
  width: '15px',
216
223
  height: '15px',
@@ -220,16 +227,28 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
220
227
  lineHeight: '10px',
221
228
  };
222
229
  const checked = (
223
- <div style={{ ...checkboxStyle, backgroundColor: p?.data?.color ?? '#2E56F4' }}>
230
+ <div
231
+ style={{
232
+ ...checkboxStyle,
233
+ backgroundColor: p?.data?.color ?? '#2E56F4',
234
+ }}
235
+ >
224
236
  <Icon icon='check-icon' color='white' />
225
237
  </div>
226
- )
238
+ );
227
239
  const unchecked = (
228
- <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }} ></div>
229
- )
240
+ <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }}></div>
241
+ );
230
242
  return (
231
243
  <components.Option {...p}>
232
- <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
+ >
233
252
  {p.isSelected ? checked : unchecked}
234
253
  <div className='text-main-alt' style={{ marginLeft: '10px' }}>
235
254
  {p.label}
@@ -239,81 +258,53 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
239
258
  );
240
259
  };
241
260
 
242
- // const ValueContainer = p => {
243
- // if (props.value.length < 1) {
244
- // return (
245
- // <components.ValueContainer {...p}>
246
- // {p.children}
247
- // </components.ValueContainer>
248
- // );
249
- // }
250
- // let firstSelected = props.value[0].label;
251
- // let moreComp = (
252
- // <div className='ml-auto'>
253
- // &amp; {props.value.length - 1} more
254
- // </div>
255
- // )
256
- // return (
257
- // <components.ValueContainer {...p}>
258
- // <div className="d-flex w-100">
259
- // <div>
260
- // {firstSelected}
261
- // </div>
262
- // {props.value.length > 1 && moreComp}
263
- // </div>
264
- // </components.ValueContainer>
265
- // );
266
- // };
267
-
268
261
  const MultiValue = ({ getValue, index, ...p }) => {
269
262
  const firstSelected = p?.data?.label || 'Select';
270
- const len = getValue().length
271
- return !index && (
272
- <div className='multiValue-wrapper'>
273
- <div className='text-main-alt'>
274
- {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
+ )}
275
271
  </div>
276
- {len > 1 && <div className={`text-more-alt`}>
277
- &amp; {len - 1} more
278
- </div>}
279
- </div>
280
- )
281
- }
282
-
283
-
272
+ )
273
+ );
274
+ };
284
275
 
285
276
  const stylesComp = {
286
-
287
- control: base => ({
277
+ control: (base) => ({
288
278
  ...base,
289
279
  border: '1px solid #d4d7e3',
290
280
  height: `${height}px`,
291
281
  minHeight: `${height}px`,
292
282
  minWidth: '226px',
293
283
  }),
294
- placeholder: base => ({
284
+ placeholder: (base) => ({
295
285
  ...base,
296
- fontSize: placeholderSize + 'px',
297
- marginLeft: '0px'
286
+ fontSize: fontSize + 'px',
287
+ marginLeft: '0px',
298
288
  }),
299
- dropdownIndicator: base => ({
289
+ dropdownIndicator: (base) => ({
300
290
  ...base,
301
291
  height: `${height}px`,
302
292
  display: 'flex',
303
293
  justifyContent: 'center',
304
294
  alignItems: 'center',
305
295
  }),
306
- valueContainer: base => ({
296
+ valueContainer: (base) => ({
307
297
  ...base,
308
- height: `${height}px`,
309
- padding: '7px 8px'
298
+ // height: `${height}px`,
299
+ // padding: '7px 8px',
300
+ fontSize: fontSize + 'px',
310
301
  }),
311
- indicatorsContainer: base => ({
302
+ indicatorsContainer: (base) => ({
312
303
  ...base,
313
304
  padding: 0,
314
305
  height: `${height}px`,
315
306
  }),
316
- menu: base => ({
307
+ menu: (base) => ({
317
308
  ...base,
318
309
  border: 'none',
319
310
  marginTop: '1px',
@@ -322,47 +313,59 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
322
313
  outline: 'none',
323
314
  boxShadow: '0px 6px 20px rgba(56, 66, 100, 0.15)',
324
315
  borderRadius: '4.32px',
325
- fontSize: '14px'
326
-
316
+ fontSize: fontSize + 'px',
317
+ }),
318
+ singleValue: (base) => ({
319
+ ...base,
320
+ fontSize: fontSize + 'px',
321
+ marginLeft: '0px',
327
322
  }),
328
- singleValue: base => ({
323
+ multiValue: (base) => ({
329
324
  ...base,
330
- fontSize: '14px',
331
- marginLeft: '0px'
325
+ marginLeft: '0px',
332
326
  }),
333
- input: base => ({
327
+ input: (base) => ({
334
328
  ...base,
335
- fontSize: '14px',
329
+ fontSize: fontSize + 'px',
336
330
  }),
337
331
  option: (provided, state) => ({
338
332
  ...provided,
339
- backgroundColor: state.isSelected || state.isFocused ? '#F0F3F8' : 'white',
333
+ backgroundColor:
334
+ state.isSelected || state.isFocused ? '#F0F3F8' : 'white',
340
335
  padding: '10px',
341
336
  cursor: 'pointer',
342
- color: '#081348'
337
+ color: '#081348',
343
338
  }),
344
339
  ...props.styles,
345
- }
340
+ };
346
341
  return (
347
- <Wrapper style={customWrapperStyles} isValid={isValid} placeholderSize={placeholderSize}
348
- >
349
-
350
- {label && <LabelWrapper theme={defaultStyles}
351
- labelWrapperStyle={'selectComp-label-wrapper'} style={customLabelStyles}>
352
- <Label
353
- themeColor={defaultThemeColor}
354
- customStyles={labelStyle}
355
- type={'label-text'}
356
- text={label}
357
- style={{ marginBottom: '7px' }}
358
- />
359
- {isRequired && <div style={{
360
- marginLeft: '4px',
361
- color: `${defaultThemeColor.ui['error']}`
362
- }} >*</div>}
363
- </LabelWrapper>}
364
- {dropdownType === 'multiSelect' ?
365
-
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' ? (
366
369
  <Select
367
370
  components={{
368
371
  DropdownIndicator,
@@ -370,11 +373,11 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
370
373
  Option,
371
374
  // LoadingIndicator: () => null,
372
375
  IndicatorSeparator: () => null,
373
- ClearIndicator: () => null
376
+ ClearIndicator: () => null,
374
377
  }}
375
- className="select-manage-page"
376
- classNamePrefix="new-select"
377
- name={"select-dropdown mb-1"}
378
+ className='select-manage-page'
379
+ classNamePrefix='new-select'
380
+ name={'select-dropdown'}
378
381
  onChange={setSelectedValue}
379
382
  placeholder={placeHolder}
380
383
  value={selectedValue}
@@ -388,38 +391,36 @@ export const DropdownSelect = ({ customWrapperStyles, customLabelStyles, labelSt
388
391
  onMenuClose={props.onMenuClose}
389
392
  isSearchable={false}
390
393
  isLoading={isLoading}
391
-
392
394
  {...props}
393
- /> :
395
+ />
396
+ ) : (
394
397
  <Select
395
398
  components={{
396
399
  DropdownIndicator,
397
400
  // LoadingIndicator,
398
401
  IndicatorSeparator: () => null,
399
- ClearIndicator: () => null
402
+ ClearIndicator: () => null,
400
403
  }}
401
- className="select-manage-page"
404
+ className='select-manage-page'
402
405
  // className="new-select"
403
- classNamePrefix="new-select"
404
- name={"select-dropdown"}
406
+ classNamePrefix='new-select'
407
+ name={'select-dropdown'}
405
408
  options={optionArr}
406
409
  placeholder={placeHolder}
407
410
  isDisabled={isDisabled}
408
411
  value={{
409
412
  value: selectedValue ? selectedValue.value : '',
410
- label: selectedValue ? selectedValue.label : ''
413
+ label: selectedValue ? selectedValue.label : '',
411
414
  }}
412
415
  styles={stylesComp}
413
416
  onChange={setSelectedValue}
414
417
  isLoading={isLoading}
415
418
  {...props}
416
419
  />
417
-
418
-
419
- }
420
+ )}
420
421
  </Wrapper>
421
- )
422
- }
422
+ );
423
+ };
423
424
 
424
425
  DropdownSelect.propTypes = {
425
426
  /**
@@ -435,12 +436,12 @@ DropdownSelect.propTypes = {
435
436
  */
436
437
  optionArr: PropTypes.array,
437
438
  /**
438
- * SelectBox Selected value. This is a array of object must be with this format:
439
- [{
440
- label:string,
441
- value:string
442
- }]
443
- */
439
+ * SelectBox Selected value. This is a array of object must be with this format:
440
+ [{
441
+ label:string,
442
+ value:string
443
+ }]
444
+ */
444
445
  selectedValue: PropTypes.object,
445
446
  /**
446
447
  * Function to set selected value
@@ -451,14 +452,14 @@ DropdownSelect.propTypes = {
451
452
  */
452
453
  placeHolder: PropTypes.string,
453
454
  /**
454
- * SelectBox Placeholder's font size
455
- */
456
- placeholderSize: PropTypes.number,
455
+ * SelectBox Placeholder's font size
456
+ */
457
+ fontSize: PropTypes.number,
457
458
  /**
458
- * This Function will be called if cross button pressed
459
- */
459
+ * This Function will be called if cross button pressed
460
+ */
460
461
  clearSelected: PropTypes.func,
461
- }
462
+ };
462
463
 
463
464
  DropdownSelect.defaultProps = {
464
465
  label: '',
@@ -470,5 +471,5 @@ DropdownSelect.defaultProps = {
470
471
  isValid: true,
471
472
  isClearSelected: false,
472
473
  height: 31,
473
- placeholderSize: 14
474
- }
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
  };