groundfloor-react-ui 1.0.6 → 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.
- package/components/Button/PrimaryButton.js +63 -34
- package/components/Button/SecondaryButton.js +64 -31
- package/components/Form/FormComponent.js +14 -0
- package/components/Inputs/CheckBoxInput.js +149 -85
- package/components/Inputs/DateSelect.js +274 -227
- package/components/Inputs/DropdownSelect.js +83 -43
- package/components/Inputs/PasswordInput.js +41 -20
- package/components/Modal/ModalComp.js +2 -1
- package/components/constants/defaultStyle.js +2 -0
- package/dist/index.es.js +538 -541
- package/dist/index.js +547 -550
- package/package.json +1 -1
|
@@ -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
|
-
|
|
6
|
-
import getDefaultStyles, { hexToRGB } from
|
|
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 }) =>
|
|
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
|
-
|
|
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
|
-
|
|
34
|
-
border: 1px solid ${
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
50
|
-
|
|
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
|
-
|
|
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=
|
|
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
|
-
{
|
|
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
|
-
|
|
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: '
|
|
14
|
-
padding: '5px 15px'
|
|
14
|
+
fontSize: '14',
|
|
15
|
+
padding: '5px 15px',
|
|
15
16
|
},
|
|
16
17
|
md: {
|
|
17
|
-
fontSize: '
|
|
18
|
-
padding: '5.5px 15px'
|
|
18
|
+
fontSize: '16',
|
|
19
|
+
padding: '5.5px 15px',
|
|
19
20
|
},
|
|
20
21
|
lg: {
|
|
21
|
-
fontSize: '
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
-
|
|
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 = ({
|
|
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=
|
|
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
|
-
{
|
|
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
|
-
|
|
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) => {
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
@@ -6,137 +6,196 @@ import defaultStyles from '../constants/defaultStyle';
|
|
|
6
6
|
import getDefaultStyles from '../constants/utils';
|
|
7
7
|
import { Label } from '../Label';
|
|
8
8
|
// import tick from '../../assets/icons/checkmark.svg';
|
|
9
|
-
import { Icon } from '../Icon'
|
|
9
|
+
import { Icon } from '../Icon';
|
|
10
10
|
|
|
11
11
|
const CheckBoxOuter = styled.div`
|
|
12
|
+
box-sizing: initial;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//Set the styles from the default styles object
|
|
16
|
-
${({ theme, defaultCheckBoxOuterStyle }) => {
|
|
14
|
+
//Set the styles from the default styles object
|
|
15
|
+
${({ theme, defaultCheckBoxOuterStyle }) => {
|
|
17
16
|
return getDefaultStyles(theme, defaultCheckBoxOuterStyle);
|
|
18
17
|
}}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
|
|
19
|
+
border: 2px solid ${({ checkedCheckBoxColor, defaultBorderColor, checked }) =>
|
|
20
|
+
checked ? checkedCheckBoxColor : defaultBorderColor};
|
|
21
|
+
|
|
22
|
+
// custom styles
|
|
23
|
+
${({ checkBoxOuterStyle }) => checkBoxOuterStyle}
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
26
|
const CheckBoxInner = styled.div`
|
|
27
|
-
|
|
28
|
-
box-sizing:initial;
|
|
27
|
+
box-sizing: initial;
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
//Set the styles from the default styles object
|
|
30
|
+
${({ theme, defaultCheckBoxInnerStyle }) => {
|
|
32
31
|
return getDefaultStyles(theme, defaultCheckBoxInnerStyle);
|
|
33
32
|
}}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
background-color: ${({ checked, checkedCheckBoxColor }) =>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
|
|
34
|
+
// background-image: url(${({ signCheck }) => signCheck});
|
|
35
|
+
background-color: ${({ checked, checkedCheckBoxColor }) =>
|
|
36
|
+
checked ? checkedCheckBoxColor : defaultThemeColor.bgColor};
|
|
37
|
+
border: 2px solid
|
|
38
|
+
${({ checkedCheckBoxColor, defaultBorderColor, checked }) =>
|
|
39
|
+
checked ? checkedCheckBoxColor : defaultBorderColor};
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
align-items: center;
|
|
43
|
+
// custom styles
|
|
44
|
+
${({ checkBoxInnerStyle }) => checkBoxInnerStyle}
|
|
44
45
|
`;
|
|
45
46
|
CheckBoxInner.defaultProps = {
|
|
46
47
|
themeColor: defaultThemeColor,
|
|
47
48
|
// signCheck: `${tick}`
|
|
48
|
-
}
|
|
49
|
+
};
|
|
49
50
|
|
|
50
51
|
const OptionText = styled.span`
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
${({ theme, type }) => {
|
|
52
|
+
//Set the styles from the default styles object
|
|
53
|
+
${({ theme, type }) => {
|
|
54
54
|
return getDefaultStyles(theme, type);
|
|
55
55
|
}}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
|
|
57
|
+
color: ${({ checked, defaultTextColor, checkedTextColor }) =>
|
|
58
|
+
checked ? checkedTextColor : defaultTextColor};
|
|
59
|
+
|
|
60
|
+
margin-right: ${({ inline }) => (inline ? '30px' : '0px')};
|
|
61
|
+
|
|
62
|
+
// custom styles
|
|
63
|
+
${({ optionTextStyle }) => optionTextStyle}
|
|
63
64
|
`;
|
|
64
65
|
|
|
65
66
|
const WrapperDiv = styled.label`
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
`
|
|
67
|
+
width: fit-content;
|
|
68
|
+
margin-bottom: ${({ inline }) => (!inline ? '18px !important' : '')};
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
align-items: center;
|
|
71
|
+
display: flex;
|
|
72
|
+
gap: 10px;
|
|
73
|
+
`;
|
|
74
74
|
|
|
75
75
|
const ParentDiv = styled.div`
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
flex-direction: ${({ inline }) => (inline ? 'row' : 'column')};
|
|
77
|
+
width: ${({ inline }) => (!inline ? 'auto' : 'initial')};
|
|
78
|
+
`;
|
|
79
79
|
|
|
80
|
+
export const CheckBoxInput = ({
|
|
81
|
+
getCheckedArr,
|
|
82
|
+
checkBoxOuterStyle,
|
|
83
|
+
checkBoxInnerStyle,
|
|
84
|
+
optionTextStyle,
|
|
85
|
+
defaultBorderColor,
|
|
86
|
+
defaultTextColor,
|
|
87
|
+
checkedTextColor,
|
|
88
|
+
checkedCheckBoxColor,
|
|
89
|
+
labelStyle,
|
|
90
|
+
label,
|
|
91
|
+
options,
|
|
92
|
+
setOptions,
|
|
93
|
+
inline,
|
|
94
|
+
wrapperStyle,
|
|
95
|
+
...props
|
|
96
|
+
}) => {
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
filterCheckedOptions(options);
|
|
99
|
+
}, []);
|
|
80
100
|
|
|
81
|
-
export const CheckBoxInput = ({ checkBoxOuterStyle, checkBoxInnerStyle, optionTextStyle, defaultBorderColor, defaultTextColor, checkedTextColor, checkedCheckBoxColor, labelStyle, label, options, setOptions, inline, wrapperStyle, ...props }) => {
|
|
82
101
|
const checkBox = (item, i) => {
|
|
83
|
-
let newOptions = [...options]
|
|
102
|
+
let newOptions = [...options];
|
|
84
103
|
newOptions[i].checked = !item.checked;
|
|
85
104
|
setOptions(newOptions);
|
|
86
|
-
|
|
105
|
+
filterCheckedOptions(newOptions);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const filterCheckedOptions = (newOptions) => {
|
|
109
|
+
let filteredOptions = newOptions.filter(
|
|
110
|
+
(option) => option.checked !== false
|
|
111
|
+
);
|
|
112
|
+
getCheckedArr(filteredOptions);
|
|
113
|
+
};
|
|
87
114
|
|
|
88
115
|
const defaultStyleForWrapper = {
|
|
89
116
|
display: 'flex',
|
|
90
117
|
flexDirection: 'column',
|
|
91
|
-
flexWrap: 'wrap'
|
|
92
|
-
}
|
|
118
|
+
flexWrap: 'wrap',
|
|
119
|
+
};
|
|
93
120
|
const returnedTarget = Object.assign(defaultStyleForWrapper, wrapperStyle);
|
|
94
121
|
|
|
95
|
-
|
|
96
122
|
return (
|
|
97
|
-
<div style={returnedTarget}
|
|
123
|
+
<div style={returnedTarget} {...props}>
|
|
98
124
|
<Label
|
|
99
125
|
themeColor={defaultThemeColor}
|
|
100
126
|
customStyles={labelStyle}
|
|
101
127
|
type={'check-label'}
|
|
102
128
|
text={label}
|
|
103
|
-
{...props}
|
|
104
|
-
|
|
129
|
+
{...props}
|
|
130
|
+
/>
|
|
131
|
+
<ParentDiv
|
|
132
|
+
style={{ display: 'flex', flexWrap: 'wrap' }}
|
|
133
|
+
inline={inline}
|
|
134
|
+
{...props}
|
|
135
|
+
>
|
|
105
136
|
{options?.map((item, i) => {
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
{item.checked ?
|
|
109
|
-
<CheckBoxInner
|
|
110
|
-
theme={defaultStyles}
|
|
111
|
-
defaultCheckBoxInnerStyle={'checkBox-inner'}
|
|
112
|
-
checkBoxInnerStyle={{ ...checkBoxInnerStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabled && item?.disabledColor }}
|
|
113
|
-
defaultBorderColor={defaultBorderColor}
|
|
114
|
-
checkedCheckBoxColor={checkedCheckBoxColor}
|
|
115
|
-
checked={!item?.disabled && item.checked} {...props} >
|
|
116
|
-
<Icon icon='check-icon' size={18} color='white' />
|
|
117
|
-
</CheckBoxInner>
|
|
118
|
-
: <CheckBoxOuter
|
|
119
|
-
theme={defaultStyles}
|
|
120
|
-
defaultCheckBoxOuterStyle={'checkBox-outer'}
|
|
121
|
-
checkBoxOuterStyle={{ ...checkBoxOuterStyle, cursor: item?.disabled ? 'not-allowed ' : ' pointer', borderColor: item?.disabledColor }}
|
|
122
|
-
defaultBorderColor={defaultBorderColor}
|
|
123
|
-
{...props} />}
|
|
124
|
-
<OptionText
|
|
137
|
+
return (
|
|
138
|
+
<WrapperDiv
|
|
125
139
|
inline={inline}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
key={`${item.name}-${i}`}
|
|
141
|
+
onClick={() => {
|
|
142
|
+
checkBox(item, i);
|
|
143
|
+
}}
|
|
144
|
+
{...props}
|
|
145
|
+
>
|
|
146
|
+
{item.checked ? (
|
|
147
|
+
<CheckBoxInner
|
|
148
|
+
theme={defaultStyles}
|
|
149
|
+
defaultCheckBoxInnerStyle={'checkBox-inner'}
|
|
150
|
+
checkBoxInnerStyle={{
|
|
151
|
+
...checkBoxInnerStyle,
|
|
152
|
+
cursor: item?.disabled ? 'not-allowed ' : ' pointer',
|
|
153
|
+
borderColor: item?.disabled && item?.disabledColor,
|
|
154
|
+
}}
|
|
155
|
+
defaultBorderColor={defaultBorderColor}
|
|
156
|
+
checkedCheckBoxColor={checkedCheckBoxColor}
|
|
157
|
+
checked={!item?.disabled && item.checked}
|
|
158
|
+
{...props}
|
|
159
|
+
>
|
|
160
|
+
<Icon icon='check-icon' size={18} color='white' />
|
|
161
|
+
</CheckBoxInner>
|
|
162
|
+
) : (
|
|
163
|
+
<CheckBoxOuter
|
|
164
|
+
theme={defaultStyles}
|
|
165
|
+
defaultCheckBoxOuterStyle={'checkBox-outer'}
|
|
166
|
+
checkBoxOuterStyle={{
|
|
167
|
+
...checkBoxOuterStyle,
|
|
168
|
+
cursor: item?.disabled ? 'not-allowed ' : ' pointer',
|
|
169
|
+
borderColor: item?.disabledColor,
|
|
170
|
+
}}
|
|
171
|
+
defaultBorderColor={defaultBorderColor}
|
|
172
|
+
{...props}
|
|
173
|
+
/>
|
|
174
|
+
)}
|
|
175
|
+
<OptionText
|
|
176
|
+
inline={inline}
|
|
177
|
+
optionTextStyle={{
|
|
178
|
+
...optionTextStyle,
|
|
179
|
+
cursor: item?.disabled ? 'not-allowed ' : ' pointer',
|
|
180
|
+
color: item?.disabledColor,
|
|
181
|
+
}}
|
|
182
|
+
checked={item.checked}
|
|
183
|
+
defaultTextColor={defaultTextColor}
|
|
184
|
+
checkedTextColor={checkedTextColor}
|
|
185
|
+
>
|
|
186
|
+
{item.label}
|
|
187
|
+
</OptionText>
|
|
188
|
+
</WrapperDiv>
|
|
189
|
+
);
|
|
131
190
|
})}
|
|
132
191
|
</ParentDiv>
|
|
133
192
|
</div>
|
|
134
|
-
)
|
|
135
|
-
}
|
|
193
|
+
);
|
|
194
|
+
};
|
|
136
195
|
|
|
137
196
|
CheckBoxInput.propTypes = {
|
|
138
197
|
/**
|
|
139
|
-
* Style Custom for whole Checkbox Block
|
|
198
|
+
* Style Custom for whole Checkbox Block
|
|
140
199
|
*/
|
|
141
200
|
wrapperStyle: PropTypes.object,
|
|
142
201
|
/**
|
|
@@ -187,13 +246,18 @@ CheckBoxInput.propTypes = {
|
|
|
187
246
|
* CheckBox value changeHandler
|
|
188
247
|
*/
|
|
189
248
|
setOptions: PropTypes.func,
|
|
190
|
-
|
|
249
|
+
/**
|
|
250
|
+
* CheckBox checked value changeHandler
|
|
251
|
+
*/
|
|
252
|
+
getCheckedArr: PropTypes.func,
|
|
253
|
+
};
|
|
191
254
|
|
|
192
255
|
CheckBoxInput.defaultProps = {
|
|
193
256
|
label: '',
|
|
194
257
|
inline: false,
|
|
195
258
|
options: [],
|
|
196
259
|
setOptions: () => { },
|
|
260
|
+
getCheckedArr: () => { },
|
|
197
261
|
labelStyle: {},
|
|
198
262
|
checkBoxOuterStyle: {},
|
|
199
263
|
checkBoxInnerStyle: {},
|
|
@@ -201,4 +265,4 @@ CheckBoxInput.defaultProps = {
|
|
|
201
265
|
checkedTextColor: `${defaultThemeColor.neutral['neutral-1']}`,
|
|
202
266
|
defaultBorderColor: '#D4D7E3',
|
|
203
267
|
checkedCheckBoxColor: `${defaultThemeColor.primary['primary-1']}`,
|
|
204
|
-
}
|
|
268
|
+
};
|