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