groundfloor-react-ui 1.2.0 → 1.2.2
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.
- package/components/Inputs/DropdownSelect.js +127 -58
- package/dist/index.es.js +69 -69
- package/dist/index.js +18 -18
- package/package.json +1 -1
|
@@ -194,19 +194,26 @@ export const DropdownSelect = ({
|
|
|
194
194
|
|
|
195
195
|
isLoading,
|
|
196
196
|
id,
|
|
197
|
+
iconName,
|
|
198
|
+
iconColor,
|
|
199
|
+
iconSize,
|
|
200
|
+
showIndicator,
|
|
201
|
+
leftIcon,
|
|
202
|
+
leftIconColor,
|
|
203
|
+
leftIconSize,
|
|
197
204
|
...props
|
|
198
205
|
}) => {
|
|
199
|
-
|
|
200
|
-
const activeTheme = useTheme() || defaultThemeColor
|
|
206
|
+
const activeTheme = useTheme() || defaultThemeColor;
|
|
201
207
|
|
|
202
208
|
const DropdownIndicator = (p) => {
|
|
203
|
-
|
|
204
|
-
<components.DropdownIndicator
|
|
209
|
+
const dropdown = (
|
|
210
|
+
<components.DropdownIndicator {...p}>
|
|
205
211
|
<IconDiv>
|
|
206
|
-
<Icon icon=
|
|
212
|
+
<Icon icon={iconName} color={iconColor} size={iconSize} />
|
|
207
213
|
</IconDiv>
|
|
208
214
|
</components.DropdownIndicator>
|
|
209
215
|
);
|
|
216
|
+
return showIndicator === true ? dropdown : null;
|
|
210
217
|
};
|
|
211
218
|
|
|
212
219
|
const ClearIndicator = (p) => {
|
|
@@ -222,11 +229,44 @@ export const DropdownSelect = ({
|
|
|
222
229
|
<Icon icon='cross-icon' color={'black'} size={8} />
|
|
223
230
|
</IconDiv>
|
|
224
231
|
) : null}
|
|
225
|
-
|
|
226
232
|
</components.ClearIndicator>
|
|
227
233
|
);
|
|
228
234
|
};
|
|
229
235
|
|
|
236
|
+
const LeftIcon = ({ getValue, children, ...props }) => {
|
|
237
|
+
const len = getValue().length;
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<components.ValueContainer {...props}>
|
|
241
|
+
{leftIcon === '' ? null : (
|
|
242
|
+
<IconDiv
|
|
243
|
+
style={{
|
|
244
|
+
paddingTop: '10px',
|
|
245
|
+
paddingRight: '8px',
|
|
246
|
+
marginLeft: '0',
|
|
247
|
+
marginTop: '-16px',
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
<Icon icon={leftIcon} color={leftIconColor} size={leftIconSize} />
|
|
251
|
+
</IconDiv>
|
|
252
|
+
)}
|
|
253
|
+
|
|
254
|
+
{children}
|
|
255
|
+
{len > 1 && <div className={`text-more-alt`}>& {len - 1} more</div>}
|
|
256
|
+
</components.ValueContainer>
|
|
257
|
+
);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const ValueContainer = ({ getValue, children, ...props }) => {
|
|
261
|
+
const len = getValue().length;
|
|
262
|
+
return (
|
|
263
|
+
<components.ValueContainer {...props}>
|
|
264
|
+
{children}
|
|
265
|
+
{len > 1 && <div className={`text-more-alt`}>& {len - 1} more</div>}
|
|
266
|
+
</components.ValueContainer>
|
|
267
|
+
);
|
|
268
|
+
};
|
|
269
|
+
|
|
230
270
|
const Option = (p) => {
|
|
231
271
|
const checkboxStyle = {
|
|
232
272
|
width: '15px',
|
|
@@ -235,6 +275,8 @@ export const DropdownSelect = ({
|
|
|
235
275
|
padding: '4px',
|
|
236
276
|
fontSize: '8px',
|
|
237
277
|
lineHeight: '10px',
|
|
278
|
+
minWidth: '15px',
|
|
279
|
+
minHeight: '15px',
|
|
238
280
|
};
|
|
239
281
|
const checked = (
|
|
240
282
|
<div
|
|
@@ -273,24 +315,13 @@ export const DropdownSelect = ({
|
|
|
273
315
|
return !index && <div className='text-main-alt'>{firstSelected}</div>;
|
|
274
316
|
};
|
|
275
317
|
|
|
276
|
-
const ValueContainer = ({ getValue, children, ...props }) => {
|
|
277
|
-
const len = getValue().length;
|
|
278
|
-
return (
|
|
279
|
-
<components.ValueContainer {...props}>
|
|
280
|
-
{children}
|
|
281
|
-
{len > 1 && <div className={`text-more-alt`}>& {len - 1} more</div>}
|
|
282
|
-
</components.ValueContainer>
|
|
283
|
-
);
|
|
284
|
-
};
|
|
285
|
-
|
|
286
318
|
const stylesComp = {
|
|
287
319
|
control: (base, state) => ({
|
|
288
320
|
...base,
|
|
289
321
|
border: !isValid
|
|
290
322
|
? '1px solid ' + activeTheme.ui['error']
|
|
291
323
|
: '1px solid ' + activeTheme.border,
|
|
292
|
-
|
|
293
|
-
|
|
324
|
+
minWidth: '215px',
|
|
294
325
|
height: `${height}px`,
|
|
295
326
|
minHeight: `${height}px`,
|
|
296
327
|
boxShadow: (state.isSelected || state.isFocused) && 'none',
|
|
@@ -315,10 +346,10 @@ export const DropdownSelect = ({
|
|
|
315
346
|
justifyContent: 'center',
|
|
316
347
|
alignItems: 'center',
|
|
317
348
|
paddingLeft: '0px',
|
|
318
|
-
|
|
319
349
|
}),
|
|
320
350
|
valueContainer: (base) => ({
|
|
321
351
|
...base,
|
|
352
|
+
display: 'flex',
|
|
322
353
|
fontSize: fontSize + 'px',
|
|
323
354
|
}),
|
|
324
355
|
indicatorsContainer: (base) => ({
|
|
@@ -336,20 +367,18 @@ export const DropdownSelect = ({
|
|
|
336
367
|
boxShadow: '0px 6px 20px rgba(56, 66, 100, 0.15)',
|
|
337
368
|
borderRadius: '4.32px',
|
|
338
369
|
fontSize: fontSize + 'px',
|
|
339
|
-
width: '100%'
|
|
370
|
+
width: '100%',
|
|
340
371
|
}),
|
|
341
372
|
singleValue: (base) => ({
|
|
342
373
|
...base,
|
|
343
374
|
fontSize: fontSize + 'px',
|
|
344
375
|
marginLeft: '0px',
|
|
345
|
-
width: 'auto'
|
|
346
|
-
|
|
376
|
+
width: 'auto',
|
|
347
377
|
}),
|
|
348
378
|
multiValue: (base) => ({
|
|
349
379
|
...base,
|
|
350
380
|
marginLeft: '0px',
|
|
351
|
-
width: 'auto'
|
|
352
|
-
|
|
381
|
+
width: 'auto',
|
|
353
382
|
}),
|
|
354
383
|
input: (base) => ({
|
|
355
384
|
...base,
|
|
@@ -358,17 +387,24 @@ export const DropdownSelect = ({
|
|
|
358
387
|
option: (provided, state) => ({
|
|
359
388
|
...provided,
|
|
360
389
|
backgroundColor:
|
|
361
|
-
state.isSelected || state.isFocused
|
|
390
|
+
state.isSelected || state.isFocused
|
|
391
|
+
? activeTheme.neutral['neutral-5']
|
|
392
|
+
: activeTheme.bgColor,
|
|
362
393
|
padding: '10px',
|
|
363
394
|
cursor: 'pointer',
|
|
364
395
|
color: '#081348',
|
|
365
|
-
width: '
|
|
366
|
-
|
|
396
|
+
width: 'inherit',
|
|
367
397
|
}),
|
|
398
|
+
|
|
368
399
|
...props.styles,
|
|
369
400
|
};
|
|
370
401
|
return (
|
|
371
|
-
<Wrapper
|
|
402
|
+
<Wrapper
|
|
403
|
+
style={customWrapperStyles}
|
|
404
|
+
isValid={isValid}
|
|
405
|
+
fontSize={fontSize}
|
|
406
|
+
theme={activeTheme}
|
|
407
|
+
>
|
|
372
408
|
{label && (
|
|
373
409
|
<LabelWrapper
|
|
374
410
|
inBuiltCss={defaultStyles}
|
|
@@ -399,14 +435,14 @@ export const DropdownSelect = ({
|
|
|
399
435
|
DropdownIndicator,
|
|
400
436
|
MultiValue,
|
|
401
437
|
Option,
|
|
402
|
-
ValueContainer,
|
|
438
|
+
ValueContainer: LeftIcon,
|
|
439
|
+
// ValueContainer,
|
|
403
440
|
IndicatorSeparator: () => null,
|
|
404
441
|
ClearIndicator,
|
|
405
442
|
}}
|
|
406
443
|
className='select-manage-page'
|
|
407
444
|
classNamePrefix='new-select'
|
|
408
445
|
name={'select-dropdown'}
|
|
409
|
-
id={id}
|
|
410
446
|
onChange={setSelectedValue}
|
|
411
447
|
placeholder={placeHolder}
|
|
412
448
|
value={selectedValue}
|
|
@@ -418,8 +454,8 @@ export const DropdownSelect = ({
|
|
|
418
454
|
closeMenuOnSelect={false}
|
|
419
455
|
isSearchable={true}
|
|
420
456
|
isLoading={isLoading}
|
|
457
|
+
id={id}
|
|
421
458
|
isClearable={isClearable}
|
|
422
|
-
|
|
423
459
|
{...props}
|
|
424
460
|
/>
|
|
425
461
|
) : dropdownType === 'asyncSingleSelect' ? (
|
|
@@ -430,19 +466,20 @@ export const DropdownSelect = ({
|
|
|
430
466
|
styles={stylesComp}
|
|
431
467
|
components={{
|
|
432
468
|
DropdownIndicator,
|
|
469
|
+
ValueContainer: LeftIcon,
|
|
470
|
+
// ValueContainer,
|
|
433
471
|
IndicatorSeparator: () => null,
|
|
434
472
|
ClearIndicator,
|
|
435
473
|
}}
|
|
436
474
|
className='select-manage-page'
|
|
437
475
|
classNamePrefix='new-select'
|
|
438
476
|
name={'select-dropdown'}
|
|
439
|
-
id={id}
|
|
440
477
|
placeholder={placeHolder}
|
|
441
478
|
onChange={setSelectedValue}
|
|
442
479
|
isLoading={isLoading}
|
|
443
480
|
isDisabled={isDisabled}
|
|
481
|
+
id={id}
|
|
444
482
|
isClearable={isClearable}
|
|
445
|
-
|
|
446
483
|
{...props}
|
|
447
484
|
/>
|
|
448
485
|
) : dropdownType === 'asyncMultiSelect' ? (
|
|
@@ -450,7 +487,8 @@ export const DropdownSelect = ({
|
|
|
450
487
|
components={{
|
|
451
488
|
DropdownIndicator,
|
|
452
489
|
MultiValue,
|
|
453
|
-
ValueContainer,
|
|
490
|
+
ValueContainer: LeftIcon,
|
|
491
|
+
// ValueContainer,
|
|
454
492
|
Option,
|
|
455
493
|
IndicatorSeparator: () => null,
|
|
456
494
|
ClearIndicator,
|
|
@@ -458,7 +496,6 @@ export const DropdownSelect = ({
|
|
|
458
496
|
className='select-manage-page'
|
|
459
497
|
classNamePrefix='new-select'
|
|
460
498
|
name={'select-dropdown'}
|
|
461
|
-
id={id}
|
|
462
499
|
onChange={setSelectedValue}
|
|
463
500
|
placeholder={placeHolder}
|
|
464
501
|
styles={stylesComp}
|
|
@@ -471,21 +508,22 @@ export const DropdownSelect = ({
|
|
|
471
508
|
loadOptions={loadOptions}
|
|
472
509
|
defaultOptions
|
|
473
510
|
onInputChange={onInputChange}
|
|
511
|
+
id={id}
|
|
474
512
|
isClearable={isClearable}
|
|
475
|
-
|
|
476
513
|
{...props}
|
|
477
514
|
/>
|
|
478
515
|
) : (
|
|
479
516
|
<Select
|
|
480
517
|
components={{
|
|
481
518
|
DropdownIndicator,
|
|
519
|
+
ValueContainer: LeftIcon,
|
|
520
|
+
// ValueContainer,
|
|
482
521
|
IndicatorSeparator: () => null,
|
|
483
522
|
ClearIndicator,
|
|
484
523
|
}}
|
|
485
524
|
className='select-manage-page'
|
|
486
525
|
classNamePrefix='new-select'
|
|
487
526
|
name={'select-dropdown'}
|
|
488
|
-
id={id}
|
|
489
527
|
options={optionArr}
|
|
490
528
|
placeholder={placeHolder}
|
|
491
529
|
isDisabled={isDisabled}
|
|
@@ -496,8 +534,8 @@ export const DropdownSelect = ({
|
|
|
496
534
|
styles={stylesComp}
|
|
497
535
|
onChange={setSelectedValue}
|
|
498
536
|
isLoading={isLoading}
|
|
537
|
+
id={id}
|
|
499
538
|
isClearable={isClearable}
|
|
500
|
-
|
|
501
539
|
{...props}
|
|
502
540
|
/>
|
|
503
541
|
)}
|
|
@@ -555,42 +593,66 @@ DropdownSelect.propTypes = {
|
|
|
555
593
|
*/
|
|
556
594
|
customWrapperStyles: PropTypes.object,
|
|
557
595
|
/**
|
|
558
|
-
|
|
559
|
-
|
|
596
|
+
* label styles
|
|
597
|
+
*/
|
|
560
598
|
customLabelStyles: PropTypes.object,
|
|
561
599
|
/**
|
|
562
|
-
* Mandatory or not
|
|
563
|
-
*/
|
|
600
|
+
* Mandatory or not
|
|
601
|
+
*/
|
|
564
602
|
isRequired: PropTypes.bool,
|
|
565
603
|
/**
|
|
566
|
-
* default dropdown type
|
|
567
|
-
*/
|
|
604
|
+
* default dropdown type
|
|
605
|
+
*/
|
|
568
606
|
dropdownType: PropTypes.string,
|
|
569
607
|
/**
|
|
570
|
-
* disabled or not
|
|
571
|
-
*/
|
|
608
|
+
* disabled or not
|
|
609
|
+
*/
|
|
572
610
|
isDisabled: PropTypes.bool,
|
|
573
611
|
/**
|
|
574
|
-
* show loader or not
|
|
575
|
-
*/
|
|
612
|
+
* show loader or not
|
|
613
|
+
*/
|
|
576
614
|
isLoading: PropTypes.bool,
|
|
577
615
|
/**
|
|
578
|
-
* valid or not
|
|
579
|
-
*/
|
|
616
|
+
* valid or not
|
|
617
|
+
*/
|
|
580
618
|
isValid: PropTypes.bool,
|
|
581
619
|
/**
|
|
582
|
-
|
|
583
|
-
|
|
620
|
+
* height of the component
|
|
621
|
+
*/
|
|
584
622
|
height: PropTypes.number,
|
|
585
623
|
/**
|
|
586
|
-
* clearable or not
|
|
587
|
-
*/
|
|
624
|
+
* clearable or not
|
|
625
|
+
*/
|
|
588
626
|
isClearable: PropTypes.bool,
|
|
589
627
|
/**
|
|
590
|
-
* id of the select
|
|
591
|
-
*/
|
|
628
|
+
* id of the select
|
|
629
|
+
*/
|
|
592
630
|
id: PropTypes.string,
|
|
593
|
-
|
|
631
|
+
/**
|
|
632
|
+
* iconName of the select
|
|
633
|
+
*/
|
|
634
|
+
iconName: PropTypes.string,
|
|
635
|
+
/**
|
|
636
|
+
* iconColor of the select
|
|
637
|
+
*/
|
|
638
|
+
iconColor: PropTypes.string,
|
|
639
|
+
/**
|
|
640
|
+
* iconSize of the select
|
|
641
|
+
*/
|
|
642
|
+
iconSize: PropTypes.number,
|
|
643
|
+
/**
|
|
644
|
+
* leftIcon of the select
|
|
645
|
+
*/
|
|
646
|
+
leftIcon: PropTypes.string,
|
|
647
|
+
/**
|
|
648
|
+
* iconColor of the select
|
|
649
|
+
*/
|
|
650
|
+
leftIconColor: PropTypes.string,
|
|
651
|
+
/**
|
|
652
|
+
* iconSize of the select
|
|
653
|
+
*/
|
|
654
|
+
leftIconSize: PropTypes.number,
|
|
655
|
+
showIndicator: PropTypes.bool,
|
|
594
656
|
};
|
|
595
657
|
|
|
596
658
|
DropdownSelect.defaultProps = {
|
|
@@ -613,5 +675,12 @@ DropdownSelect.defaultProps = {
|
|
|
613
675
|
dropdownType: 'singleSelect',
|
|
614
676
|
isDisabled: false,
|
|
615
677
|
isLoading: false,
|
|
616
|
-
id: ''
|
|
678
|
+
id: '',
|
|
679
|
+
iconName: 'triangle-down',
|
|
680
|
+
iconColor: 'black',
|
|
681
|
+
iconSize: 8,
|
|
682
|
+
leftIcon: 'magnifier-icon',
|
|
683
|
+
leftIconColor: 'black',
|
|
684
|
+
leftIconSize: 10,
|
|
685
|
+
showIndicator: true,
|
|
617
686
|
};
|