groundfloor-react-ui 1.0.7 → 1.0.10

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.
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled, { useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
- // import { Loader } from '../Loaders';
6
- import getDefaultStyles, { hexToRGB } from "../constants/utils";
5
+ import { Loader } from '../Loaders';
6
+ import getDefaultStyles, { hexToRGB } from '../constants/utils';
7
7
 
8
8
  /**
9
9
  * Primary UI component for user interaction
@@ -12,61 +12,85 @@ import getDefaultStyles, { hexToRGB } from "../constants/utils";
12
12
  const sizes = {
13
13
  sm: {
14
14
  fontSize: '14px',
15
- padding: '5px 15px'
15
+ padding: '5px 15px',
16
16
  },
17
17
  md: {
18
18
  fontSize: '16px',
19
- padding: '5.5px 15px'
19
+ padding: '5.5px 15px',
20
20
  },
21
21
  lg: {
22
22
  fontSize: '18px',
23
- padding: '8px 20px'
23
+ padding: '8px 20px',
24
24
  },
25
- }
25
+ };
26
26
 
27
- const buttonDisabledBg = ({ theme, variant }) => hexToRGB(theme.variant[variant], 0.6);
27
+ const buttonDisabledBg = ({ theme, variant }) =>
28
+ hexToRGB(theme.variant[variant], 0.6);
28
29
  const fontColor = defaultThemeColor.bgColor;
29
30
 
30
31
  const StyledButton = styled.button`
31
- background: ${({ theme, variant }) => theme.variant[variant]};
32
+ background: ${({ theme, variant }) => theme.variant[variant]};
33
+ color: ${fontColor};
34
+ padding: ${({ size }) => sizes[size].padding};
35
+ border: 1px solid ${({ theme, variant }) => theme.variant[variant]};
36
+ border-radius: 5px;
37
+ font-size: ${({ size }) => sizes[size].fontSize};
38
+ display: flex;
39
+ align-items: center;
40
+ width: ${({ block }) => (block ? '100%' : 'auto')};
41
+ cursor: pointer;
42
+ line-height: 18px;
43
+ &:disabled {
32
44
  color: ${fontColor};
33
- padding: ${({ size }) => sizes[size].padding};
34
- border: 1px solid ${({ theme, variant }) => theme.variant[variant]};
35
- border-radius: 5px;
36
- font-size: ${({ size }) => sizes[size].fontSize};
37
- display: flex;
38
- align-items: center;
39
- width: ${({ block }) => block ? '100%' : 'auto'};
40
- cursor: pointer;
41
- line-height: 18px;
42
- &:disabled {
43
- color: ${fontColor};
44
- background: ${buttonDisabledBg};
45
- border: 1px solid ${buttonDisabledBg};
46
- cursor: not-allowed;
47
- }
45
+ background: ${buttonDisabledBg};
46
+ border: 1px solid ${buttonDisabledBg};
47
+ cursor: not-allowed;
48
+ }
48
49
 
49
- //Set the styles from the default styles object
50
- ${({ theme, defaultStyle }) => {
50
+ //Set the styles from the default styles object
51
+ ${({ theme, defaultStyle }) => {
51
52
  return getDefaultStyles(theme, defaultStyle);
52
53
  }}
53
- `;
54
- // console.log(fontColor)
55
54
 
56
- export const PrimaryButton = ({ block, size, style, variant, disabled, isLoading, type, ...props }) => {
55
+ // custom styles
56
+ ${({ btnStyle }) => btnStyle}
57
+ `;
57
58
 
59
+ export const PrimaryButton = ({
60
+ btnStyle,
61
+ block,
62
+ size,
63
+ style,
64
+ variant,
65
+ disabled,
66
+ isLoading,
67
+ type,
68
+ ...props
69
+ }) => {
58
70
  return (
59
71
  <StyledButton
60
72
  block={block}
61
73
  variant={variant}
62
- defaultStyle="button"
74
+ defaultStyle='button'
63
75
  type={type}
64
76
  style={style}
65
77
  size={size}
66
78
  disabled={disabled}
79
+ btnStyle={btnStyle}
67
80
  {...props}
68
81
  >
69
- {/* {isLoading && <div style={{ paddingRight: '10px', marginTop: '6px' }}><Loader customStyles={{ 'background-color': fontColor }} size={16} /></div>} */}
82
+ {isLoading && (
83
+ <div
84
+ style={{
85
+ paddingRight: '10px',
86
+ display: 'flex',
87
+ justifyContent: 'center',
88
+ alignItems: 'center',
89
+ }}
90
+ >
91
+ <Loader customStyles={{ 'background-color': fontColor }} size={16} />
92
+ </div>
93
+ )}
70
94
  {props.children}
71
95
  </StyledButton>
72
96
  );
@@ -102,14 +126,18 @@ PrimaryButton.propTypes = {
102
126
  */
103
127
  theme: PropTypes.object,
104
128
  /**
105
- * Type of the btn i.e: button or submit etc.
106
- */
129
+ * Type of the btn i.e: button or submit etc.
130
+ */
107
131
  type: PropTypes.string,
132
+ /**
133
+ * custome style of button
134
+ */
135
+ btnStyle: PropTypes.object,
108
136
  };
109
137
 
110
138
  StyledButton.defaultProps = {
111
139
  theme: defaultThemeColor,
112
- }
140
+ };
113
141
 
114
142
  PrimaryButton.defaultProps = {
115
143
  theme: defaultThemeColor,
@@ -119,4 +147,5 @@ PrimaryButton.defaultProps = {
119
147
  disabled: false,
120
148
  size: 'md',
121
149
  onClick: undefined,
122
- };
150
+ btnStyle: {},
151
+ };
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import styled, { useTheme } from 'styled-components';
4
4
  import defaultThemeColor from '../constants/defaultThemeColor';
5
5
  import getDefaultStyles from '../constants/utils';
6
+ import { Loader } from '../Loaders';
6
7
 
7
8
  /**
8
9
  * Secondary UI component for user interaction
@@ -10,60 +11,87 @@ import getDefaultStyles from '../constants/utils';
10
11
 
11
12
  const sizes = {
12
13
  sm: {
13
- fontSize: '14px',
14
- padding: '5px 15px'
14
+ fontSize: '14',
15
+ padding: '5px 15px',
15
16
  },
16
17
  md: {
17
- fontSize: '16px',
18
- padding: '5.5px 15px'
18
+ fontSize: '16',
19
+ padding: '5.5px 15px',
19
20
  },
20
21
  lg: {
21
- fontSize: '18px',
22
- padding: '8px 20px'
22
+ fontSize: '18',
23
+ padding: '8px 20px',
23
24
  },
24
- }
25
+ };
25
26
 
26
27
  const buttonDisabledBg = '#BBC4CF';
28
+ const fontColor = defaultThemeColor.primary['primary-1'];
27
29
 
28
30
  const StyledButton = styled.button`
29
- color: ${({ theme, variant }) => theme.variant[variant]};
30
- background: ${({ theme }) => theme.bgColor};
31
- padding: ${({ size }) => sizes[size].padding};
32
- border: 1px solid ${({ theme, variant }) => theme.variant[variant]};
33
- font-size: ${({ size }) => sizes[size].fontSize};
34
- border-radius: 5px;
35
- display: flex;
36
- align-items: center;
37
- width: ${({ block }) => block ? '100%' : 'auto'};
38
- cursor: pointer;
39
- line-height: 18px;
40
- &:disabled {
41
- color: #929EAC;
42
- border: 1px solid ${buttonDisabledBg};
43
- cursor: not-allowed;
44
- }
31
+ color: ${({ theme, variant }) => theme.variant[variant]};
32
+ background: ${({ theme }) => theme.bgColor};
33
+ padding: ${({ size }) => sizes[size].padding};
34
+ border: 1px solid ${({ theme, variant }) => theme.variant[variant]};
35
+ font-size: ${({ size }) => sizes[size].fontSize};
36
+ border-radius: 5px;
37
+ display: flex;
38
+ align-items: center;
39
+ width: ${({ block }) => (block ? '100%' : 'auto')};
40
+ cursor: pointer;
41
+ line-height: 18px;
42
+ &:disabled {
43
+ color: #929eac;
44
+ border: 1px solid ${buttonDisabledBg};
45
+ cursor: not-allowed;
46
+ }
45
47
 
46
- //Set the styles from the default styles object
47
- ${({ theme, defaultStyle }) => {
48
+ //Set the styles from the default styles object
49
+ ${({ theme, defaultStyle }) => {
48
50
  return getDefaultStyles(theme, defaultStyle);
49
51
  }}
52
+ // custom styles
53
+ ${({ btnStyle }) => btnStyle}
50
54
  `;
51
55
 
52
- export const SecondaryButton = ({ block, size, style, variant, disabled, type, ...props }) => {
56
+ export const SecondaryButton = ({
57
+ btnStyle,
58
+ isLoading,
59
+ block,
60
+ size,
61
+ style,
62
+ variant,
63
+ disabled,
64
+ type,
65
+ ...props
66
+ }) => {
53
67
  const theme = useTheme() || defaultThemeColor;
54
68
 
55
69
  return (
56
70
  <StyledButton
57
71
  block={block}
58
72
  variant={variant}
59
- defaultStyle="button"
73
+ defaultStyle='button'
60
74
  style={style}
61
75
  size={size}
62
76
  disabled={disabled}
63
77
  type={type}
78
+ btnStyle={btnStyle}
79
+ isLoading={isLoading}
64
80
  {...props}
65
81
  >
66
- {props.children}
82
+ {isLoading && (
83
+ <div
84
+ style={{
85
+ paddingRight: '10px',
86
+ display: 'flex',
87
+ justifyContent: 'center',
88
+ alignItems: 'center',
89
+ }}
90
+ >
91
+ <Loader customStyles={{ 'background-color': fontColor }} size={16} />
92
+ </div>
93
+ )}
94
+ {props.children}{' '}
67
95
  </StyledButton>
68
96
  );
69
97
  };
@@ -94,14 +122,18 @@ SecondaryButton.propTypes = {
94
122
  */
95
123
  theme: PropTypes.object,
96
124
  /**
97
- * Type of the btn i.e: button or submit etc.
98
- */
125
+ * Type of the btn i.e: button or submit etc.
126
+ */
99
127
  type: PropTypes.string,
128
+ /**
129
+ * custome style of button
130
+ */
131
+ btnStyle: PropTypes.object,
100
132
  };
101
133
 
102
134
  StyledButton.defaultProps = {
103
135
  theme: defaultThemeColor,
104
- }
136
+ };
105
137
 
106
138
  SecondaryButton.defaultProps = {
107
139
  theme: defaultThemeColor,
@@ -110,4 +142,5 @@ SecondaryButton.defaultProps = {
110
142
  disabled: false,
111
143
  size: 'md',
112
144
  onClick: undefined,
145
+ btnStyle: {},
113
146
  };
@@ -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) => {
@@ -94,7 +96,15 @@ export const FormComponent = ({ formData, ...props }) => {
94
96
  };
95
97
 
96
98
  const MultiDropdownInput = (item) => {
97
- return <DropdownSelect {...item} {...props} />;
99
+ return <DropdownSelect dropdownType={'multiSelect'} {...item} {...props} />;
100
+ };
101
+
102
+ const AsyncMultiDropdownInput = (item) => {
103
+ return <DropdownSelect dropdownType={'asyncMultiSelect'} {...item} {...props} />;
104
+ };
105
+
106
+ const AsyncSingleDropdownInput = (item) => {
107
+ return <DropdownSelect dropdownType={'asyncSingleSelect'} {...item} {...props} />;
98
108
  };
99
109
 
100
110
  const signatureInput = (item) => {
@@ -133,6 +143,14 @@ export const FormComponent = ({ formData, ...props }) => {
133
143
  return <SearchInput {...item} {...props} />;
134
144
  };
135
145
 
146
+ const tableInput = (item) => {
147
+ return <Table {...item} {...props} />;
148
+ };
149
+
150
+ const passwordInput = (item) => {
151
+ return <PasswordInput {...item} {...props} />;
152
+ };
153
+
136
154
  const handleSubmit = () => {
137
155
  console.log('form submit');
138
156
  };
@@ -157,6 +175,10 @@ export const FormComponent = ({ formData, ...props }) => {
157
175
  return SingleDropdownInput(item);
158
176
  case 'multiSelect':
159
177
  return MultiDropdownInput(item);
178
+ case 'asyncSingleSelect':
179
+ return AsyncSingleDropdownInput(item);
180
+ case 'asyncMultiSelect':
181
+ return AsyncMultiDropdownInput(item);
160
182
  case 'signature':
161
183
  return signatureInput(item);
162
184
  case 'fileUpload':
@@ -175,6 +197,10 @@ export const FormComponent = ({ formData, ...props }) => {
175
197
  return tinyButton(item);
176
198
  case 'search':
177
199
  return searchInput(item);
200
+ case 'table':
201
+ return tableInput(item);
202
+ case 'passwordInput':
203
+ return passwordInput(item);
178
204
  default:
179
205
  break;
180
206
  }
@@ -205,4 +231,4 @@ export const FormComponent = ({ formData, ...props }) => {
205
231
  </FormContainer>
206
232
  </Fragment>
207
233
  );
208
- };
234
+ };