groundfloor-react-ui 1.0.0 → 1.0.1

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,16 +1,20 @@
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
 
13
+
14
+
15
+
16
+
17
+
14
18
  .master-dropdown,
15
19
  .new-select {
16
20
  .master-dropdown__menu,
@@ -56,8 +60,10 @@ const Wrapper = styled.div`
56
60
 
57
61
  .master-dropdown__control,
58
62
  .new-select__control {
59
- border:${({ isValid, }) => !isValid ? '0.5px solid ' + defaultThemeColor.ui['error'] :
60
- '0.5px solid ' + defaultThemeColor.neutral['neutral-4']};
63
+ border:${({ isValid }) =>
64
+ !isValid
65
+ ? '0.5px solid ' + defaultThemeColor.ui['error']
66
+ : '0.5px solid ' + defaultThemeColor.neutral['neutral-4']};
61
67
  }
62
68
 
63
69
  .master-dropdown__option,
@@ -83,7 +89,10 @@ const Wrapper = styled.div`
83
89
 
84
90
  .new-select__control:hover,
85
91
  .new-select__control--is-focused {
86
- border: ${({ isValid, }) => !isValid ? '0.5px solid ' + defaultThemeColor.ui['error'] : '0.5px solid ' + defaultThemeColor.primary['primary-1']};
92
+ border: ${({ isValid }) =>
93
+ !isValid
94
+ ? '0.5px solid ' + defaultThemeColor.ui['error']
95
+ : '0.5px solid ' + defaultThemeColor.primary['primary-1']};
87
96
  box-shadow: none;
88
97
  }
89
98
 
@@ -102,7 +111,6 @@ const Wrapper = styled.div`
102
111
  .default-select {
103
112
  .default-select__control {
104
113
  height: 39px;
105
- // max-height: 39px;
106
114
  }
107
115
 
108
116
  .default-select__value-container--has-value {
@@ -139,328 +147,326 @@ const Wrapper = styled.div`
139
147
  .css-mohuvp-dummyInput-DummyInput{
140
148
  height:0px;
141
149
  }
142
- .css-14el2xx-placeholder{
143
- font-size: ${({ placeholderSize }) => placeholderSize + 'px'};
144
- }
150
+
145
151
  .css-6j8wv5-Input{
146
152
  margin:0px;
147
153
  padding-top:0px;
148
154
  }
149
- .custom-loader{
150
- animation: loader 3s;
151
-
152
- }
153
- @keyframes loader {
154
- 50% {transform: rotate(0deg);}
155
- 100% {transform: rotate(360deg);}
156
- }
157
-
158
155
  .new-select__menu {
159
156
  z-Index: 2;
160
157
  }
158
+ .css-1n10ic4-Input {
159
+ margin: 0px;
160
+ padding:0px
161
+ }
161
162
 
162
- `
163
-
163
+ `;
164
164
 
165
165
  const LabelWrapper = styled.div`
166
-
167
- // Default style
168
- display: flex;
169
-
166
+ // Default style
167
+ display: flex;
170
168
 
171
169
  //Set the styles from the default styles object
172
- ${({ theme, labelWrapperStyle }) => {
173
- return getDefaultStyles(theme, labelWrapperStyle);
174
- }}
175
- // custom styles
170
+ ${({ theme, labelWrapperStyle }) => {
171
+ return getDefaultStyles(theme, labelWrapperStyle);
172
+ }}
173
+ // custom styles
176
174
  ${({ customLabelStyles }) => customLabelStyles}
177
- `
175
+ `;
178
176
  const IconDiv = styled.div`
179
- margin-left: 6px;
180
- margin-top:-14px;
181
- cursor:pointer;
177
+ margin-left: 6px;
178
+ margin-top: -14px;
179
+ cursor: pointer;
182
180
  `;
183
181
 
184
-
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 => {
187
- return (
188
- <components.DropdownIndicator {...p}>
189
- {isClearSelected == true ?
190
- <IconDiv onClick={() => { clearSelected() }}>
191
- <Icon icon='cross-icon'
192
- color={'black'}
193
- size={8} />
194
- </IconDiv>
195
- : null}
196
- <IconDiv>
197
- <Icon icon='triangle-down'
198
- color={'black'}
199
- size={8} />
200
- </IconDiv>
201
- </components.DropdownIndicator>
202
- );
203
- };
204
-
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 => {
214
- const checkboxStyle = {
215
- width: '15px',
216
- height: '15px',
217
- borderRadius: '2px',
218
- padding: '3px 4px',
219
- fontSize: '8px',
220
- lineHeight: '10px',
221
- };
222
- const checked = (
223
- <div style={{ ...checkboxStyle, backgroundColor: p?.data?.color ?? '#2E56F4' }}>
224
- <Icon icon='check-icon' color='white' />
225
- </div>
226
- )
227
- const unchecked = (
228
- <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }} ></div>
229
- )
230
- return (
231
- <components.Option {...p}>
232
- <div style={{ display: 'flex', justifyContent: 'start', alignItems: 'center', width: '100%' }}>
233
- {p.isSelected ? checked : unchecked}
234
- <div className='text-main-alt' style={{ marginLeft: '10px' }}>
235
- {p.label}
236
- </div>
237
- </div>
238
- </components.Option>
239
- );
182
+ export const DropdownSelect = ({
183
+ customWrapperStyles,
184
+ customLabelStyles,
185
+ labelStyle,
186
+ label,
187
+ isRequired,
188
+ optionArr,
189
+ selectedValue,
190
+ setSelectedValue,
191
+ placeHolder,
192
+ dropdownType,
193
+ isDisabled,
194
+ isValid,
195
+ clearSelected,
196
+ isClearSelected,
197
+ isLoading,
198
+ height,
199
+ placeholderSize,
200
+ ...props
201
+ }) => {
202
+ const DropdownIndicator = (p) => {
203
+ return (
204
+ <components.DropdownIndicator {...p}>
205
+ {isClearSelected == true ? (
206
+ <IconDiv
207
+ onClick={() => {
208
+ clearSelected();
209
+ }}
210
+ >
211
+ <Icon icon='cross-icon' color={'black'} size={8} />
212
+ </IconDiv>
213
+ ) : null}
214
+ <IconDiv>
215
+ <Icon icon='triangle-down' color={'black'} size={8} />
216
+ </IconDiv>
217
+ </components.DropdownIndicator>
218
+ );
219
+ };
220
+
221
+ const Option = (p) => {
222
+ const checkboxStyle = {
223
+ width: '15px',
224
+ height: '15px',
225
+ borderRadius: '2px',
226
+ padding: '4px',
227
+ fontSize: '8px',
228
+ lineHeight: '10px',
240
229
  };
241
-
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
- const MultiValue = ({ getValue, index, ...p }) => {
269
- 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}
275
- </div>
276
- {len > 1 && <div className={`text-more-alt`}>
277
- &amp; {len - 1} more
278
- </div>}
279
- </div>
280
- )
281
- }
282
-
283
-
284
-
285
- const stylesComp = {
286
-
287
- control: base => ({
288
- ...base,
289
- border: '1px solid #d4d7e3',
290
- height: `${height}px`,
291
- minHeight: `${height}px`,
292
- minWidth: '226px',
293
- }),
294
- dropdownIndicator: base => ({
295
- ...base,
296
- height: `${height}px`,
230
+ const checked = (
231
+ <div
232
+ style={{
233
+ ...checkboxStyle,
234
+ backgroundColor: p?.data?.color ?? '#2E56F4',
235
+ }}
236
+ >
237
+ <Icon icon='check-icon' color='white' />
238
+ </div>
239
+ );
240
+ const unchecked = (
241
+ <div style={{ ...checkboxStyle, backgroundColor: '#e0e7ff' }}></div>
242
+ );
243
+ return (
244
+ <components.Option {...p}>
245
+ <div
246
+ style={{
297
247
  display: 'flex',
298
- justifyContent: 'center',
248
+ justifyContent: 'start',
299
249
  alignItems: 'center',
300
- }),
301
- valueContainer: base => ({
302
- ...base,
303
- height: `${height}px`,
304
- padding: '4px 8px'
305
- }),
306
- indicatorsContainer: base => ({
307
- ...base,
308
- padding: 0,
309
- height: `${height}px`,
310
- }),
311
- menu: base => ({
312
- ...base,
313
- border: 'none',
314
- marginTop: '1px',
315
- borderTopRightRadius: '0px',
316
- borderTopLeftRadius: '0px',
317
- outline: 'none',
318
- boxShadow: '0px 6px 20px rgba(56, 66, 100, 0.15)',
319
- borderRadius: '4.32px',
320
- fontSize: '14px'
321
-
322
- }),
323
- singleValue: base => ({
324
- ...base,
325
- fontSize: '14px',
326
- }),
327
- input: base => ({
328
- ...base,
329
- fontSize: '14px',
330
- }),
331
- option: (provided, state) => ({
332
- ...provided,
333
- backgroundColor: state.isSelected ? '#F0F3F8' : 'white',
334
- padding: '10px',
335
- cursor: 'pointer',
336
- color: '#081348'
337
- }),
338
- ...props.styles,
339
- }
250
+ width: '100%',
251
+ }}
252
+ >
253
+ {p.isSelected ? checked : unchecked}
254
+ <div className='text-main-alt' style={{ marginLeft: '10px' }}>
255
+ {p.label}
256
+ </div>
257
+ </div>
258
+ </components.Option>
259
+ );
260
+ };
261
+
262
+ const MultiValue = ({ getValue, index, ...p }) => {
263
+ const firstSelected = p?.data?.label || 'Select';
264
+ const len = getValue().length;
340
265
  return (
341
- <Wrapper style={customWrapperStyles} isValid={isValid} placeholderSize={placeholderSize}
266
+ !index && (
267
+ <div className='multiValue-wrapper'>
268
+ <div className='text-main-alt'>{firstSelected}</div>
269
+ {len > 1 && (
270
+ <div className={`text-more-alt`}>&amp; {len - 1} more</div>
271
+ )}
272
+ </div>
273
+ )
274
+ );
275
+ };
276
+
277
+ const stylesComp = {
278
+ control: (base) => ({
279
+ ...base,
280
+ border: '1px solid #d4d7e3',
281
+ height: `${height}px`,
282
+ minHeight: `${height}px`,
283
+ minWidth: '226px',
284
+ }),
285
+ placeholder: (base) => ({
286
+ ...base,
287
+ fontSize: placeholderSize + 'px',
288
+ marginLeft: '0px',
289
+ }),
290
+ dropdownIndicator: (base) => ({
291
+ ...base,
292
+ height: `${height}px`,
293
+ display: 'flex',
294
+ justifyContent: 'center',
295
+ alignItems: 'center',
296
+ }),
297
+ valueContainer: (base) => ({
298
+ ...base,
299
+ height: `${height}px`,
300
+ padding: '7px 8px',
301
+ }),
302
+ indicatorsContainer: (base) => ({
303
+ ...base,
304
+ padding: 0,
305
+ height: `${height}px`,
306
+ }),
307
+ menu: (base) => ({
308
+ ...base,
309
+ border: 'none',
310
+ marginTop: '1px',
311
+ borderTopRightRadius: '0px',
312
+ borderTopLeftRadius: '0px',
313
+ outline: 'none',
314
+ boxShadow: '0px 6px 20px rgba(56, 66, 100, 0.15)',
315
+ borderRadius: '4.32px',
316
+ fontSize: '14px',
317
+ }),
318
+ singleValue: (base) => ({
319
+ ...base,
320
+ fontSize: '14px',
321
+ marginLeft: '0px',
322
+ }),
323
+ input: (base) => ({
324
+ ...base,
325
+ fontSize: '14px',
326
+ }),
327
+ option: (provided, state) => ({
328
+ ...provided,
329
+ backgroundColor:
330
+ state.isSelected || state.isFocused ? '#F0F3F8' : 'white',
331
+ padding: '10px',
332
+ cursor: 'pointer',
333
+ color: '#081348',
334
+ }),
335
+ ...props.styles,
336
+ };
337
+ return (
338
+ <Wrapper
339
+ style={customWrapperStyles}
340
+ isValid={isValid}
341
+ placeholderSize={placeholderSize}
342
+ >
343
+ {label && (
344
+ <LabelWrapper
345
+ theme={defaultStyles}
346
+ labelWrapperStyle={'selectComp-label-wrapper'}
347
+ style={customLabelStyles}
342
348
  >
343
- {label && <LabelWrapper theme={defaultStyles}
344
- labelWrapperStyle={'selectComp-label-wrapper'} style={customLabelStyles}>
345
- <Label
346
- themeColor={defaultThemeColor}
347
- customStyles={labelStyle}
348
- type={'label-text'}
349
- text={label}
350
- style={{ marginBottom: '10px' }}
351
- />
352
- {isRequired && <div style={{
353
- marginLeft: '4px',
354
- color: `${defaultThemeColor.ui['error']}`
355
- }} >*</div>}
356
- </LabelWrapper>}
357
- {dropdownType === 'singleSelect' ?
358
- <Select
359
- components={{
360
- DropdownIndicator,
361
- // LoadingIndicator,
362
- IndicatorSeparator: () => null,
363
- ClearIndicator: () => null
364
- }}
365
- className="select-manage-page"
366
- // className="new-select"
367
- classNamePrefix="new-select"
368
- name={"select-dropdown mb-1"}
369
- options={optionArr}
370
- placeholder={placeHolder}
371
- isDisabled={isDisabled}
372
- value={{
373
- value: selectedValue ? selectedValue.value : '',
374
- label: selectedValue ? selectedValue.label : ''
375
- }}
376
- styles={stylesComp}
377
- onChange={setSelectedValue}
378
- isLoading={isLoading}
379
- {...props}
380
- />
381
- :
382
- <Select
383
- components={{
384
- DropdownIndicator,
385
- MultiValue,
386
- Option,
387
- // LoadingIndicator: () => null,
388
- IndicatorSeparator: () => null,
389
- ClearIndicator: () => null
390
- }}
391
- className="select-manage-page"
392
- classNamePrefix="new-select"
393
- name={"select-dropdown mb-1"}
394
- onChange={setSelectedValue}
395
- placeholder={placeHolder}
396
- value={selectedValue}
397
- options={optionArr}
398
- styles={stylesComp}
399
- isMulti={true}
400
- isDisabled={isDisabled}
401
- isClearable={props.isClearable}
402
- hideSelectedOptions={false}
403
- closeMenuOnSelect={false}
404
- onMenuClose={props.onMenuClose}
405
- isSearchable={false}
406
- isLoading={isLoading}
407
-
408
- {...props}
409
- />
410
- }
411
- </Wrapper>
412
- )
413
- }
349
+ <Label
350
+ themeColor={defaultThemeColor}
351
+ customStyles={labelStyle}
352
+ type={'label-text'}
353
+ text={label}
354
+ style={{ marginBottom: '10px' }}
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 === 'singleSelect' ? (
369
+ <Select
370
+ components={{
371
+ DropdownIndicator,
372
+ IndicatorSeparator: () => null,
373
+ ClearIndicator: () => null,
374
+ }}
375
+ className='select-manage-page'
376
+ classNamePrefix='new-select'
377
+ name={'select-dropdown mb-1'}
378
+ options={optionArr}
379
+ placeholder={placeHolder}
380
+ isDisabled={isDisabled}
381
+ value={{
382
+ value: selectedValue ? selectedValue.value : '',
383
+ label: selectedValue ? selectedValue.label : '',
384
+ }}
385
+ styles={stylesComp}
386
+ onChange={setSelectedValue}
387
+ isLoading={isLoading}
388
+ {...props}
389
+ />
390
+ ) : (
391
+ <Select
392
+ components={{
393
+ DropdownIndicator,
394
+ MultiValue,
395
+ Option,
396
+ IndicatorSeparator: () => null,
397
+ ClearIndicator: () => null,
398
+ }}
399
+ className='select-manage-page'
400
+ classNamePrefix='new-select'
401
+ name={'select-dropdown mb-1'}
402
+ onChange={setSelectedValue}
403
+ placeholder={placeHolder}
404
+ value={selectedValue}
405
+ options={optionArr}
406
+ styles={stylesComp}
407
+ isMulti={true}
408
+ isDisabled={isDisabled}
409
+ isClearable={props.isClearable}
410
+ hideSelectedOptions={false}
411
+ closeMenuOnSelect={false}
412
+ onMenuClose={props.onMenuClose}
413
+ isSearchable={false}
414
+ isLoading={isLoading}
415
+ {...props}
416
+ />
417
+ )}
418
+ </Wrapper>
419
+ );
420
+ };
414
421
 
415
422
  DropdownSelect.propTypes = {
416
- /**
417
- * Label of SelectBox
418
- */
419
- label: PropTypes.string,
420
- /**
421
- * Label Style of SelectBox
422
- */
423
- labelStyle: PropTypes.object,
424
- /**
425
- * SelectBox Options
426
- */
427
- optionArr: PropTypes.array,
428
- /**
423
+ /**
424
+ * Label of SelectBox
425
+ */
426
+ label: PropTypes.string,
427
+ /**
428
+ * Label Style of SelectBox
429
+ */
430
+ labelStyle: PropTypes.object,
431
+ /**
432
+ * SelectBox Options
433
+ */
434
+ optionArr: PropTypes.array,
435
+ /**
429
436
  * SelectBox Selected value. This is a array of object must be with this format:
430
437
  [{
431
438
  label:string,
432
439
  value:string
433
440
  }]
434
441
  */
435
- selectedValue: PropTypes.object,
436
- /**
437
- * Function to set selected value
438
- */
439
- setSelectedValue: PropTypes.func,
440
- /**
441
- * SelectBox Placeholder
442
- */
443
- placeHolder: PropTypes.string,
444
- /**
445
- * SelectBox Placeholder's font size
446
- */
447
- placeholderSize: PropTypes.number,
448
- /**
449
- * This Function will be called if cross button pressed
450
- */
451
- clearSelected: PropTypes.func,
452
- }
442
+ selectedValue: PropTypes.object,
443
+ /**
444
+ * Function to set selected value
445
+ */
446
+ setSelectedValue: PropTypes.func,
447
+ /**
448
+ * SelectBox Placeholder
449
+ */
450
+ placeHolder: PropTypes.string,
451
+ /**
452
+ * SelectBox Placeholder's font size
453
+ */
454
+ placeholderSize: PropTypes.number,
455
+ /**
456
+ * This Function will be called if cross button pressed
457
+ */
458
+ clearSelected: PropTypes.func,
459
+ };
453
460
 
454
461
  DropdownSelect.defaultProps = {
455
- label: '',
456
- labelStyle: {},
457
- optionArr: [],
458
- selectedValue: {},
459
- setSelectedValue: undefined,
460
- placeHolder: '',
461
- isValid: true,
462
- isClearSelected: false,
463
- height: 31,
464
- placeholderSize: 14
465
- }
466
-
462
+ label: '',
463
+ labelStyle: {},
464
+ optionArr: [],
465
+ selectedValue: {},
466
+ setSelectedValue: undefined,
467
+ placeHolder: 'Select an option',
468
+ isValid: true,
469
+ isClearSelected: false,
470
+ height: 31,
471
+ placeholderSize: 14,
472
+ };