groundfloor-react-ui 1.0.8 → 1.0.9

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.
@@ -8,6 +8,7 @@ import {
8
8
  DropdownSelect,
9
9
  DropzoneInput,
10
10
  NumericInput,
11
+ PasswordInput,
11
12
  RadioInput,
12
13
  SearchInput,
13
14
  SignatureInput,
@@ -23,6 +24,7 @@ import {
23
24
  MultiColumnWrapper,
24
25
  MultiColumnDiv,
25
26
  } from '../DesignComponent';
27
+ import { Table } from '../Tables';
26
28
 
27
29
  export const FormComponent = ({ formData, ...props }) => {
28
30
  const header = (item) => {
@@ -133,6 +135,14 @@ export const FormComponent = ({ formData, ...props }) => {
133
135
  return <SearchInput {...item} {...props} />;
134
136
  };
135
137
 
138
+ const tableInput = (item) => {
139
+ return <Table {...item} {...props} />;
140
+ };
141
+
142
+ const passwordInput = (item) => {
143
+ return <PasswordInput {...item} {...props} />;
144
+ };
145
+
136
146
  const handleSubmit = () => {
137
147
  console.log('form submit');
138
148
  };
@@ -175,6 +185,10 @@ export const FormComponent = ({ formData, ...props }) => {
175
185
  return tinyButton(item);
176
186
  case 'search':
177
187
  return searchInput(item);
188
+ case 'table':
189
+ return tableInput(item);
190
+ case 'passwordInput':
191
+ return passwordInput(item);
178
192
  default:
179
193
  break;
180
194
  }
@@ -7,6 +7,7 @@ import defaultStyles from '../constants/defaultStyle';
7
7
  import getDefaultStyles from '../constants/utils';
8
8
  import { Label } from '../Label';
9
9
  import { Icon } from '../Icon';
10
+ import AsyncSelect from 'react-select/async';
10
11
 
11
12
  const Wrapper = styled.div`
12
13
 
@@ -23,7 +24,6 @@ const Wrapper = styled.div`
23
24
  border-top-left-radius: 0;
24
25
  border-top-right-radius: 0;
25
26
  width: 100%;
26
- border: 0.5px solid ${defaultThemeColor.neutral['neutral-4']};
27
27
  }
28
28
 
29
29
  .new-select__dropdown-indicator{
@@ -53,13 +53,7 @@ const Wrapper = styled.div`
53
53
  max-height: 110px;
54
54
  }
55
55
 
56
- .master-dropdown__control,
57
- .new-select__control {
58
- border:${({ isValid }) =>
59
- !isValid
60
- ? '0.5px solid ' + defaultThemeColor.ui['error']
61
- : '0.5px solid ' + defaultThemeColor.neutral['neutral-4']};
62
- }
56
+
63
57
 
64
58
  .master-dropdown__option,
65
59
  .new-select__option {
@@ -83,10 +77,7 @@ const Wrapper = styled.div`
83
77
 
84
78
  .new-select__control:hover,
85
79
  .new-select__control--is-focused {
86
- border: ${({ isValid }) =>
87
- !isValid
88
- ? '0.5px solid ' + defaultThemeColor.ui['error']
89
- : '0.5px solid ' + defaultThemeColor.primary['primary-1']};
80
+
90
81
  box-shadow: none;
91
82
  }
92
83
 
@@ -117,21 +108,15 @@ const Wrapper = styled.div`
117
108
  }
118
109
 
119
110
  .default-select__control--is-focused {
120
- border-width: 1px;
121
111
  outline: none;
122
112
  }
123
113
  }
124
114
 
125
- .multiValue-wrapper{
126
- width:100%;
127
- display:flex;
128
- justify-content: space-between;
129
- align-items: center;
130
- }
115
+
131
116
 
132
117
  .text-main-alt {
133
118
  color: ${defaultThemeColor.textColor} !important;
134
- // font-size:14px;
119
+ margin-right: 2px;
135
120
  }
136
121
  .text-more-alt{
137
122
  font-size:12px;
@@ -192,19 +177,22 @@ export const DropdownSelect = ({
192
177
  isDisabled,
193
178
  isValid,
194
179
  clearSelected,
195
- isClearSelected,
180
+ isClearable,
196
181
  isLoading,
197
182
  height,
198
183
  fontSize,
184
+ loadOptions,
185
+ onInputChange,
199
186
  ...props
200
187
  }) => {
201
188
  const DropdownIndicator = (p) => {
202
189
  return (
203
190
  <components.DropdownIndicator {...p}>
204
- {isClearSelected == true ? (
191
+ {true ? (
205
192
  <IconDiv
206
193
  onClick={() => {
207
194
  clearSelected();
195
+ p.clearValue();
208
196
  }}
209
197
  >
210
198
  <Icon icon='cross-icon' color={'black'} size={8} />
@@ -258,28 +246,30 @@ export const DropdownSelect = ({
258
246
  );
259
247
  };
260
248
 
261
- const MultiValue = ({ getValue, index, ...p }) => {
249
+ const MultiValue = ({ index, ...p }) => {
262
250
  const firstSelected = p?.data?.label || 'Select';
251
+ return !index && <div className='text-main-alt'>{firstSelected}</div>;
252
+ };
253
+
254
+ const ValueContainer = ({ getValue, children, ...props }) => {
263
255
  const len = getValue().length;
264
256
  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
- )}
271
- </div>
272
- )
257
+ <components.ValueContainer {...props}>
258
+ {children}
259
+ {len > 1 && <div className={`text-more-alt`}>&amp; {len - 1} more</div>}
260
+ </components.ValueContainer>
273
261
  );
274
262
  };
275
263
 
276
264
  const stylesComp = {
277
- control: (base) => ({
265
+ control: (base, state) => ({
278
266
  ...base,
279
- border: '1px solid #d4d7e3',
267
+ border: !isValid
268
+ ? '1px solid ' + defaultThemeColor.ui['error']
269
+ : '1px solid ' + defaultThemeColor.border,
280
270
  height: `${height}px`,
281
271
  minHeight: `${height}px`,
282
- minWidth: '226px',
272
+ boxShadow: (state.isSelected || state.isFocused) && 'none',
283
273
  }),
284
274
  placeholder: (base) => ({
285
275
  ...base,
@@ -295,8 +285,6 @@ export const DropdownSelect = ({
295
285
  }),
296
286
  valueContainer: (base) => ({
297
287
  ...base,
298
- // height: `${height}px`,
299
- // padding: '7px 8px',
300
288
  fontSize: fontSize + 'px',
301
289
  }),
302
290
  indicatorsContainer: (base) => ({
@@ -371,7 +359,7 @@ export const DropdownSelect = ({
371
359
  DropdownIndicator,
372
360
  MultiValue,
373
361
  Option,
374
- // LoadingIndicator: () => null,
362
+ ValueContainer,
375
363
  IndicatorSeparator: () => null,
376
364
  ClearIndicator: () => null,
377
365
  }}
@@ -385,24 +373,65 @@ export const DropdownSelect = ({
385
373
  styles={stylesComp}
386
374
  isMulti={true}
387
375
  isDisabled={isDisabled}
388
- isClearable={props.isClearable}
389
376
  hideSelectedOptions={false}
390
377
  closeMenuOnSelect={false}
391
- onMenuClose={props.onMenuClose}
392
- isSearchable={false}
378
+ isSearchable={true}
393
379
  isLoading={isLoading}
394
380
  {...props}
395
381
  />
382
+ ) : dropdownType === 'asyncSingleSelect' ? (
383
+ <AsyncSelect
384
+ loadOptions={loadOptions}
385
+ defaultOptions
386
+ onInputChange={onInputChange}
387
+ styles={stylesComp}
388
+ components={{
389
+ DropdownIndicator,
390
+ IndicatorSeparator: () => null,
391
+ ClearIndicator: () => null,
392
+ }}
393
+ className='select-manage-page'
394
+ classNamePrefix='new-select'
395
+ name={'select-dropdown'}
396
+ placeholder={placeHolder}
397
+ onChange={setSelectedValue}
398
+ isLoading={isLoading}
399
+ {...props}
400
+ />
401
+ ) : dropdownType === 'asyncMultiSelect' ? (
402
+ <AsyncSelect
403
+ components={{
404
+ DropdownIndicator,
405
+ MultiValue,
406
+ ValueContainer,
407
+ Option,
408
+ IndicatorSeparator: () => null,
409
+ ClearIndicator: () => null,
410
+ }}
411
+ className='select-manage-page'
412
+ classNamePrefix='new-select'
413
+ name={'select-dropdown'}
414
+ onChange={setSelectedValue}
415
+ placeholder={placeHolder}
416
+ styles={stylesComp}
417
+ isMulti={true}
418
+ hideSelectedOptions={false}
419
+ closeMenuOnSelect={false}
420
+ isSearchable={true}
421
+ isLoading={isLoading}
422
+ loadOptions={loadOptions}
423
+ defaultOptions
424
+ onInputChange={onInputChange}
425
+ {...props}
426
+ />
396
427
  ) : (
397
428
  <Select
398
429
  components={{
399
430
  DropdownIndicator,
400
- // LoadingIndicator,
401
431
  IndicatorSeparator: () => null,
402
432
  ClearIndicator: () => null,
403
433
  }}
404
434
  className='select-manage-page'
405
- // className="new-select"
406
435
  classNamePrefix='new-select'
407
436
  name={'select-dropdown'}
408
437
  options={optionArr}
@@ -459,6 +488,14 @@ DropdownSelect.propTypes = {
459
488
  * This Function will be called if cross button pressed
460
489
  */
461
490
  clearSelected: PropTypes.func,
491
+ /**
492
+ * callback function to get value
493
+ */
494
+ loadOptions: PropTypes.func,
495
+ /**
496
+ * onchange function
497
+ */
498
+ onInputChange: PropTypes.func,
462
499
  };
463
500
 
464
501
  DropdownSelect.defaultProps = {
@@ -469,7 +506,10 @@ DropdownSelect.defaultProps = {
469
506
  setSelectedValue: undefined,
470
507
  placeHolder: 'Select an option',
471
508
  isValid: true,
472
- isClearSelected: false,
509
+ isClearable: false,
473
510
  height: 31,
474
511
  fontSize: 14,
512
+ loadOptions: () => { },
513
+ onInputChange: () => { },
514
+ clearSelected: () => { },
475
515
  };
@@ -58,7 +58,7 @@ const Input = styled.input`
58
58
  const inline = css`
59
59
  display: flex;
60
60
  gap: 7px;
61
- align-items: center;
61
+ align-items: start;
62
62
  `;
63
63
 
64
64
  const Form = styled.div`
@@ -76,6 +76,7 @@ Form.defaultProps = {
76
76
 
77
77
  export const PasswordInput = ({
78
78
  themeColor,
79
+ passwordRules,
79
80
  textBoxStyle,
80
81
  labelStyle,
81
82
  inputStyle,
@@ -84,6 +85,7 @@ export const PasswordInput = ({
84
85
  label,
85
86
  labelInline,
86
87
  isValid,
88
+ rulesStyle,
87
89
  ...props
88
90
  }) => {
89
91
  const [showEye, setShowEye] = useState(false);
@@ -94,12 +96,11 @@ export const PasswordInput = ({
94
96
  <Label
95
97
  customStyles={labelStyle}
96
98
  type={'label-text'}
97
- labelInline={labelInline}
98
99
  text={label}
99
100
  errMsg={errMsg}
100
101
  style={{
101
102
  display: 'flex',
102
- marginBottom: `${!labelInline ? '7px' : ''}`,
103
+ marginBottom: `${!labelInline ? '7px' : '0px'}`,
103
104
  paddingBottom: '0px',
104
105
  }}
105
106
  {...props}
@@ -108,6 +109,7 @@ export const PasswordInput = ({
108
109
  <div
109
110
  style={{
110
111
  marginLeft: '4px',
112
+ marginRight: '5px',
111
113
  color: `${themeColor.variant['error']}`,
112
114
  }}
113
115
  >
@@ -115,25 +117,34 @@ export const PasswordInput = ({
115
117
  </div>
116
118
  )}
117
119
  </div>
118
- <TextWrapper
119
- required={required}
120
- themeColor={defaultThemeColor}
121
- textBoxStyle={textBoxStyle}
122
- isValid={isValid}
123
- theme={defaultStyles}
124
- defaultWrapperStyle={'textbox-wrapper'}
125
- {...props}
120
+ <div
121
+ style={{
122
+ display: 'flex',
123
+ justifyContent: 'center',
124
+ alignItems: 'start',
125
+ }}
126
126
  >
127
- <Input
128
- inputStyle={inputStyle}
129
- type={showEye ? 'text' : 'password'}
130
- defaultInputStyle={'input-wrapper'}
127
+ <TextWrapper
128
+ required={required}
129
+ themeColor={defaultThemeColor}
130
+ textBoxStyle={textBoxStyle}
131
+ isValid={isValid}
132
+ theme={defaultStyles}
133
+ defaultWrapperStyle={'textbox-wrapper'}
131
134
  {...props}
132
- />
133
- <div className='input-icon' onClick={() => setShowEye(!showEye)}>
134
- {showEye ? <Icon icon='eye-show' /> : <Icon icon='eye-hide' />}
135
- </div>
136
- </TextWrapper>
135
+ >
136
+ <Input
137
+ inputStyle={inputStyle}
138
+ type={showEye ? 'text' : 'password'}
139
+ defaultInputStyle={'input-wrapper'}
140
+ {...props}
141
+ />
142
+ <div className='input-icon' onClick={() => setShowEye(!showEye)}>
143
+ {showEye ? <Icon icon='eye-show' /> : <Icon icon='eye-hide' />}
144
+ </div>
145
+ </TextWrapper>
146
+ <div style={{ ...rulesStyle, marginLeft: '5px' }}>{passwordRules}</div>
147
+ </div>
137
148
  {errMsg.length > 0 && <div className='err-text'>{errMsg}</div>}
138
149
  </Form>
139
150
  );
@@ -177,6 +188,14 @@ PasswordInput.propTypes = {
177
188
  * custom style of textbox label
178
189
  */
179
190
  inputStyle: PropTypes.object,
191
+ /**
192
+ * rules of password
193
+ */
194
+ passwordRules: PropTypes.string,
195
+ /**
196
+ * styles of password rules
197
+ */
198
+ rulesStyle: PropTypes.object,
180
199
  };
181
200
 
182
201
  PasswordInput.defaultProps = {
@@ -190,4 +209,6 @@ PasswordInput.defaultProps = {
190
209
  textBoxStyle: {},
191
210
  labelStyle: {},
192
211
  inputStyle: {},
212
+ passwordRules: '',
213
+ rulesStyle: {},
193
214
  };
@@ -185,6 +185,8 @@ const defaultStyles = {
185
185
  'font-size': '14px',
186
186
  color: `${defaultThemeColor.variant['neutral-2']}`,
187
187
  display: 'flex',
188
+ 'align-items': 'center',
189
+ 'justify-content': 'center',
188
190
  width: 'max-content',
189
191
  'background-color': 'transparent',
190
192
  'margin-bottom': '0px',