groundfloor-react-ui 1.0.11 → 1.0.12

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.
@@ -25,6 +25,7 @@ import {
25
25
  MultiColumnDiv,
26
26
  } from '../DesignComponent';
27
27
  import { Table } from '../Tables';
28
+ import { HeaderComponent } from './HeaderComponent';
28
29
 
29
30
  export const FormComponent = ({ formData, ...props }) => {
30
31
  const header = (item) => {
@@ -150,7 +151,9 @@ export const FormComponent = ({ formData, ...props }) => {
150
151
  const passwordInput = (item) => {
151
152
  return <PasswordInput {...item} {...props} />;
152
153
  };
153
-
154
+ const headerComponentInput = (item) => {
155
+ return <HeaderComponent {...item} {...props} />;
156
+ };
154
157
  const handleSubmit = () => {
155
158
  console.log('form submit');
156
159
  };
@@ -201,6 +204,8 @@ export const FormComponent = ({ formData, ...props }) => {
201
204
  return tableInput(item);
202
205
  case 'passwordInput':
203
206
  return passwordInput(item);
207
+ case 'headerComponent':
208
+ return headerComponentInput(item);
204
209
  default:
205
210
  break;
206
211
  }
@@ -2,7 +2,7 @@ import React from 'react'
2
2
  import defaultThemeColor from '../constants/defaultThemeColor'
3
3
  import userIcon from "../../assets/icons/users.svg";
4
4
 
5
- export const HeaderComponent = ({ title, subtitle, wrapperstyle }) => {
5
+ export const HeaderComponent = ({ title, subtitle, wrapperstyle, imgLink, imgStyle }) => {
6
6
 
7
7
  const titleStyle = {
8
8
  'fontSize': '26px',
@@ -24,11 +24,11 @@ export const HeaderComponent = ({ title, subtitle, wrapperstyle }) => {
24
24
 
25
25
  return <div style={wrapperstyle}>
26
26
  <div style={titleStyle}>
27
- <img src={userIcon} alt="userIcon" srcset="" />
27
+ <img src={imgLink || userIcon} alt="userIcon" srcset="" style={imgStyle} />
28
28
  <h4>{title}</h4>
29
29
  </div>
30
30
  <div style={subtitleStyle}>
31
31
  <p>{subtitle}</p>
32
32
  </div>
33
33
  </div>
34
- }
34
+ }
@@ -1,6 +1,5 @@
1
1
  import React, { useState, useEffect, useRef } from 'react';
2
2
  import DatePicker from 'react-datepicker';
3
- import 'react-datepicker/dist/react-datepicker.css';
4
3
  import PropTypes from 'prop-types';
5
4
  import styled from 'styled-components';
6
5
  import defaultThemeColor from '../constants/defaultThemeColor';
@@ -149,7 +148,7 @@ const Wrapper = styled.div`
149
148
  `;
150
149
 
151
150
  Wrapper.defaultProps = {
152
- theme: defaultThemeColor,
151
+ theme: defaultThemeColor,
153
152
  };
154
153
 
155
154
  const CalendarHeaderDiv = styled.div`
@@ -219,7 +218,7 @@ const DropDownList = styled('ul')`
219
218
  }
220
219
  `;
221
220
  DropDownList.defaultProps = {
222
- theme: defaultThemeColor,
221
+ theme: defaultThemeColor,
223
222
  };
224
223
 
225
224
  const ListItem = styled('li')`
@@ -234,224 +233,224 @@ const ListItem = styled('li')`
234
233
  `;
235
234
 
236
235
  export const DateSelect = ({ startDate, setStartDate, disabled, ...props }) => {
237
- const theme = defaultThemeColor;
238
-
239
- const months = [
240
- 'January',
241
- 'February',
242
- 'March',
243
- 'April',
244
- 'May',
245
- 'June',
246
- 'July',
247
- 'August',
248
- 'September',
249
- 'October',
250
- 'November',
251
- 'December',
252
- ];
253
- var years = [];
254
- for (var i = 2010; i <= new Date().getFullYear() + 10; i++) {
255
- years.push(i);
256
- }
236
+ const theme = defaultThemeColor;
237
+
238
+ const months = [
239
+ 'January',
240
+ 'February',
241
+ 'March',
242
+ 'April',
243
+ 'May',
244
+ 'June',
245
+ 'July',
246
+ 'August',
247
+ 'September',
248
+ 'October',
249
+ 'November',
250
+ 'December',
251
+ ];
252
+ var years = [];
253
+ for (var i = 2010; i <= new Date().getFullYear() + 10; i++) {
254
+ years.push(i);
255
+ }
257
256
 
258
- const refMonth = useRef(null);
259
- const refYear = useRef(null);
260
- const [isOpen, setIsOpen] = useState(false);
261
- const [isOpenYear, setIsOpenYear] = useState(false);
262
- const [hover, setHover] = useState(false);
263
- const [hoverYear, setHoverYear] = useState(false);
264
- const [selectedYear, setSelectedYear] = useState(startDate.getFullYear());
265
- const [selectedMonth, setSelectedMonth] = useState(
266
- months[startDate.getMonth()]
267
- );
268
-
269
- useEffect(() => {
270
- setSelectedMonth(months[startDate.getMonth()]);
271
- setSelectedYear(startDate.getFullYear());
272
- }, [startDate]);
273
-
274
- useEffect(() => {
275
- document.addEventListener('click', handleClickOutsideMonth, true);
276
-
277
- return () => {
278
- document.removeEventListener('click', handleClickOutsideMonth, true);
279
- };
280
- }, []);
281
-
282
- const handleClickOutsideMonth = (event) => {
283
- if (refMonth.current && !refMonth.current.contains(event.target)) {
284
- setIsOpen(false);
285
- }
257
+ const refMonth = useRef(null);
258
+ const refYear = useRef(null);
259
+ const [isOpen, setIsOpen] = useState(false);
260
+ const [isOpenYear, setIsOpenYear] = useState(false);
261
+ const [hover, setHover] = useState(false);
262
+ const [hoverYear, setHoverYear] = useState(false);
263
+ const [selectedYear, setSelectedYear] = useState(startDate.getFullYear());
264
+ const [selectedMonth, setSelectedMonth] = useState(
265
+ months[startDate.getMonth()]
266
+ );
267
+
268
+ useEffect(() => {
269
+ setSelectedMonth(months[startDate.getMonth()]);
270
+ setSelectedYear(startDate.getFullYear());
271
+ }, [startDate]);
272
+
273
+ useEffect(() => {
274
+ document.addEventListener('click', handleClickOutsideMonth, true);
275
+
276
+ return () => {
277
+ document.removeEventListener('click', handleClickOutsideMonth, true);
286
278
  };
279
+ }, []);
287
280
 
288
- const handleClickOutsideYear = (event) => {
289
- if (refYear.current && !refYear.current.contains(event.target)) {
290
- setIsOpenYear(false);
291
- }
292
- };
281
+ const handleClickOutsideMonth = (event) => {
282
+ if (refMonth.current && !refMonth.current.contains(event.target)) {
283
+ setIsOpen(false);
284
+ }
285
+ };
293
286
 
294
- useEffect(() => {
295
- document.addEventListener('click', handleClickOutsideYear, true);
296
-
297
- return () => {
298
- document.removeEventListener('click', handleClickOutsideYear, true);
299
- };
300
- }, []);
301
-
302
- return (
303
- <Wrapper disabled={disabled} {...props}>
304
- <DatePicker
305
- selected={startDate}
306
- dateFormat='dd/MM/yyyy'
307
- useWeekdaysShort={true}
308
- onChange={(date) => setStartDate(date)}
309
- placeholderText={'select date'}
310
- adjustDateOnChange
311
- disabled={disabled}
312
- dropdownMode='select'
313
- renderCustomHeader={({ date, changeYear, changeMonth }) => {
314
- return (
315
- <CalendarHeaderDiv>
316
- <div style={{ display: 'flex' }}>
317
- <DropDownContainer ref={refMonth}>
318
- <DropDownHeader
319
- onClick={() => {
320
- setIsOpen(!isOpen);
321
- setIsOpenYear(false);
322
- }}
323
- >
324
- <span
325
- onMouseEnter={() => setHover(true)}
326
- onMouseLeave={() => setHover(false)}
327
- style={{
328
- color: `${hover ? theme.variant['primary-1'] : theme.textColor
329
- }`,
330
- }}
331
- >
332
- {months[date.getMonth()]}
333
- </span>
334
- <IconDiv>
335
- <Icon
336
- icon='triangle-down'
337
- color={hover ? 'blue' : 'black'}
338
- size={7}
339
- />
340
- </IconDiv>
341
- </DropDownHeader>
342
- {isOpen && (
343
- <DropDownListContainer>
344
- <DropDownList onMouseEnter={() => setHover(true)}>
345
- {months.map((option, index) => (
346
- <ListItem
347
- selectedMonth={selectedMonth}
348
- onClick={() => {
349
- setHover(false);
350
- changeMonth(index);
351
- setIsOpen(false);
352
- setSelectedMonth(months[index]);
353
- }}
354
- key={Math.random()}
355
- >
356
- <span
357
- style={{
358
- color: `${selectedMonth === option
359
- ? theme.variant['primary-1']
360
- : theme.textColor
361
- }`,
362
- }}
363
- >
364
- {option}
365
- </span>
366
- </ListItem>
367
- ))}
368
- </DropDownList>
369
- </DropDownListContainer>
370
- )}
371
- </DropDownContainer>
372
- <DropDownContainer ref={refYear}>
373
- <DropDownHeader
374
- style={{ marginLeft: '28px' }}
375
- onClick={() => {
376
- setIsOpenYear(!isOpenYear);
377
- setIsOpen(false);
378
- }}
379
- >
380
- <span
381
- onMouseEnter={() => setHoverYear(true)}
382
- onMouseLeave={() => setHoverYear(false)}
383
- style={{
384
- color: `${hoverYear
385
- ? theme.variant['primary-1']
386
- : theme.textColor
387
- }`,
388
- }}
389
- >
390
- {date.getFullYear()}
391
- </span>
392
- <IconDiv>
393
- <Icon
394
- icon='triangle-down'
395
- color={hoverYear ? 'blue' : 'black'}
396
- size={7}
397
- />
398
- </IconDiv>
399
- </DropDownHeader>
400
- {isOpenYear && (
401
- <DropDownListContainer>
402
- <DropDownList onMouseEnter={() => setHoverYear(true)}>
403
- {years.map((option, index) => (
404
- <ListItem
405
- onClick={() => {
406
- setHoverYear(false);
407
- changeYear(option);
408
- setSelectedYear(option);
409
- setIsOpenYear(false);
410
- }}
411
- key={Math.random()}
412
- >
413
- <span
414
- style={{
415
- color: `${selectedYear === option
416
- ? theme.variant['primary-1']
417
- : theme.textColor
418
- }`,
419
- }}
420
- >
421
- {option}
422
- </span>
423
- </ListItem>
424
- ))}
425
- </DropDownList>
426
- </DropDownListContainer>
427
- )}
428
- </DropDownContainer>
429
- </div>
430
- </CalendarHeaderDiv>
431
- );
432
- }}
433
- />
434
- </Wrapper>
435
- );
287
+ const handleClickOutsideYear = (event) => {
288
+ if (refYear.current && !refYear.current.contains(event.target)) {
289
+ setIsOpenYear(false);
290
+ }
291
+ };
292
+
293
+ useEffect(() => {
294
+ document.addEventListener('click', handleClickOutsideYear, true);
295
+
296
+ return () => {
297
+ document.removeEventListener('click', handleClickOutsideYear, true);
298
+ };
299
+ }, []);
300
+
301
+ return (
302
+ <Wrapper disabled={disabled} {...props}>
303
+ <DatePicker
304
+ selected={startDate}
305
+ dateFormat='dd/MM/yyyy'
306
+ useWeekdaysShort={true}
307
+ onChange={(date) => setStartDate(date)}
308
+ placeholderText={'select date'}
309
+ adjustDateOnChange
310
+ disabled={disabled}
311
+ dropdownMode='select'
312
+ renderCustomHeader={({ date, changeYear, changeMonth }) => {
313
+ return (
314
+ <CalendarHeaderDiv>
315
+ <div style={{ display: 'flex' }}>
316
+ <DropDownContainer ref={refMonth}>
317
+ <DropDownHeader
318
+ onClick={() => {
319
+ setIsOpen(!isOpen);
320
+ setIsOpenYear(false);
321
+ }}
322
+ >
323
+ <span
324
+ onMouseEnter={() => setHover(true)}
325
+ onMouseLeave={() => setHover(false)}
326
+ style={{
327
+ color: `${hover ? theme.variant['primary-1'] : theme.textColor
328
+ }`,
329
+ }}
330
+ >
331
+ {months[date.getMonth()]}
332
+ </span>
333
+ <IconDiv>
334
+ <Icon
335
+ icon='triangle-down'
336
+ color={hover ? 'blue' : 'black'}
337
+ size={7}
338
+ />
339
+ </IconDiv>
340
+ </DropDownHeader>
341
+ {isOpen && (
342
+ <DropDownListContainer>
343
+ <DropDownList onMouseEnter={() => setHover(true)}>
344
+ {months.map((option, index) => (
345
+ <ListItem
346
+ selectedMonth={selectedMonth}
347
+ onClick={() => {
348
+ setHover(false);
349
+ changeMonth(index);
350
+ setIsOpen(false);
351
+ setSelectedMonth(months[index]);
352
+ }}
353
+ key={Math.random()}
354
+ >
355
+ <span
356
+ style={{
357
+ color: `${selectedMonth === option
358
+ ? theme.variant['primary-1']
359
+ : theme.textColor
360
+ }`,
361
+ }}
362
+ >
363
+ {option}
364
+ </span>
365
+ </ListItem>
366
+ ))}
367
+ </DropDownList>
368
+ </DropDownListContainer>
369
+ )}
370
+ </DropDownContainer>
371
+ <DropDownContainer ref={refYear}>
372
+ <DropDownHeader
373
+ style={{ marginLeft: '28px' }}
374
+ onClick={() => {
375
+ setIsOpenYear(!isOpenYear);
376
+ setIsOpen(false);
377
+ }}
378
+ >
379
+ <span
380
+ onMouseEnter={() => setHoverYear(true)}
381
+ onMouseLeave={() => setHoverYear(false)}
382
+ style={{
383
+ color: `${hoverYear
384
+ ? theme.variant['primary-1']
385
+ : theme.textColor
386
+ }`,
387
+ }}
388
+ >
389
+ {date.getFullYear()}
390
+ </span>
391
+ <IconDiv>
392
+ <Icon
393
+ icon='triangle-down'
394
+ color={hoverYear ? 'blue' : 'black'}
395
+ size={7}
396
+ />
397
+ </IconDiv>
398
+ </DropDownHeader>
399
+ {isOpenYear && (
400
+ <DropDownListContainer>
401
+ <DropDownList onMouseEnter={() => setHoverYear(true)}>
402
+ {years.map((option, index) => (
403
+ <ListItem
404
+ onClick={() => {
405
+ setHoverYear(false);
406
+ changeYear(option);
407
+ setSelectedYear(option);
408
+ setIsOpenYear(false);
409
+ }}
410
+ key={Math.random()}
411
+ >
412
+ <span
413
+ style={{
414
+ color: `${selectedYear === option
415
+ ? theme.variant['primary-1']
416
+ : theme.textColor
417
+ }`,
418
+ }}
419
+ >
420
+ {option}
421
+ </span>
422
+ </ListItem>
423
+ ))}
424
+ </DropDownList>
425
+ </DropDownListContainer>
426
+ )}
427
+ </DropDownContainer>
428
+ </div>
429
+ </CalendarHeaderDiv>
430
+ );
431
+ }}
432
+ />
433
+ </Wrapper>
434
+ );
436
435
  };
437
436
 
438
437
  DateSelect.propTypes = {
439
- /**
440
- * Date Props in GMT Format
441
- */
442
- startDate: PropTypes.any,
443
- /**
444
- * Date onChange Function
445
- */
446
- setStartDate: PropTypes.func,
447
- /**
448
- * Disable property of DateSelect
449
- */
450
- disabled: PropTypes.bool,
438
+ /**
439
+ * Date Props in GMT Format
440
+ */
441
+ startDate: PropTypes.any,
442
+ /**
443
+ * Date onChange Function
444
+ */
445
+ setStartDate: PropTypes.func,
446
+ /**
447
+ * Disable property of DateSelect
448
+ */
449
+ disabled: PropTypes.bool,
451
450
  };
452
451
 
453
452
  DateSelect.defaultProps = {
454
- startDate: '',
455
- setStartDate: () => { },
456
- disabled: false,
453
+ startDate: '',
454
+ setStartDate: () => { },
455
+ disabled: false,
457
456
  };
@@ -7,7 +7,6 @@ import getDefaultStyles from '../constants/utils';
7
7
  import { Label } from '../Label';
8
8
  import { Icon } from '../Icon';
9
9
  import { useState } from 'react';
10
- import { useEffect } from 'react';
11
10
 
12
11
  const TextWrapper = styled.div`
13
12
  //Set the styles from the default styles object
@@ -42,6 +41,8 @@ const TextWrapper = styled.div`
42
41
 
43
42
  const Input = styled.input`
44
43
  width: inherit;
44
+ -webkit-text-security: ${({ showEye }) => showEye ? 'none' : 'disc'} ;
45
+
45
46
  //Set the styles from the default styles object
46
47
  ${({ theme, defaultInputStyle }) => {
47
48
  return getDefaultStyles(theme, defaultInputStyle);
@@ -53,6 +54,7 @@ const Input = styled.input`
53
54
  .sc-furwcr bxRAoq {
54
55
  color: ${defaultThemeColor.variant['neutral-3']};
55
56
  }
57
+
56
58
  `;
57
59
 
58
60
  const inline = css`
@@ -120,7 +122,7 @@ export const PasswordInput = ({
120
122
  <div
121
123
  style={{
122
124
  display: 'flex',
123
- justifyContent: 'center',
125
+ justifyContent: 'start',
124
126
  alignItems: 'start',
125
127
  }}
126
128
  >
@@ -135,7 +137,8 @@ export const PasswordInput = ({
135
137
  >
136
138
  <Input
137
139
  inputStyle={inputStyle}
138
- type={showEye ? 'text' : 'password'}
140
+ type={'text'}
141
+ showEye={showEye}
139
142
  defaultInputStyle={'input-wrapper'}
140
143
  {...props}
141
144
  />
@@ -32,6 +32,8 @@ const TextWrapper = styled.div`
32
32
 
33
33
  // custom styles
34
34
  ${({ textBoxStyle }) => textBoxStyle}
35
+
36
+ background-color: ${({ isDisabled }) => isDisabled ? defaultThemeColor.variant['neutral-5'] : defaultThemeColor.bgColor}
35
37
  `;
36
38
 
37
39
  const Input = styled.input`
@@ -47,6 +49,7 @@ const Input = styled.input`
47
49
  .sc-furwcr bxRAoq {
48
50
  color: ${defaultThemeColor.variant['neutral-3']};
49
51
  }
52
+ background-color: ${({ isDisabled }) => isDisabled ? defaultThemeColor.variant['neutral-5'] : defaultThemeColor.bgColor}
50
53
  `;
51
54
 
52
55
  const inline = css`
@@ -81,6 +84,7 @@ export const TextInput = ({
81
84
  iconAfter,
82
85
  isValid,
83
86
  type,
87
+ isDisabled,
84
88
  ...props
85
89
  }) => {
86
90
  return (
@@ -113,6 +117,7 @@ export const TextInput = ({
113
117
  <TextWrapper
114
118
  required={required}
115
119
  themeColor={defaultThemeColor}
120
+ isDisabled={isDisabled}
116
121
  textBoxStyle={textBoxStyle}
117
122
  isValid={isValid}
118
123
  theme={defaultStyles}
@@ -124,6 +129,8 @@ export const TextInput = ({
124
129
  inputStyle={inputStyle}
125
130
  type={type}
126
131
  defaultInputStyle={'input-wrapper'}
132
+ isDisabled={isDisabled}
133
+ disabled={isDisabled}
127
134
  {...props}
128
135
  />
129
136
  <div className='input-icon'>{iconAfter}</div>
@@ -182,6 +189,10 @@ TextInput.propTypes = {
182
189
  * input type i.e:- text, password
183
190
  */
184
191
  type: PropTypes.string,
192
+ /**
193
+ * input field disabled or not
194
+ */
195
+ isDisabled: PropTypes.bool,
185
196
  };
186
197
 
187
198
  TextInput.defaultProps = {
@@ -198,4 +209,5 @@ TextInput.defaultProps = {
198
209
  labelStyle: {},
199
210
  inputStyle: {},
200
211
  type: 'text',
212
+ isDisabled: false
201
213
  };