groundfloor-react-ui 1.0.0 → 1.0.1
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/README.md +2 -2
- package/assets/icons/file-upload.svg +3 -0
- package/components/Accordion/Accordion.js +2 -2
- package/components/Form/FormComponent.js +1 -1
- package/components/Form/HeaderComponent.js +1 -6
- package/components/Icon/Icon.js +6 -6
- package/components/Inputs/DateSelect.js +2 -2
- package/components/Inputs/DropdownSelect.js +307 -301
- package/components/Inputs/DropzoneInput.js +226 -136
- package/components/Inputs/NumericInput.js +1 -2
- package/components/Inputs/Signature.js +142 -109
- package/components/Inputs/TextArea.js +1 -2
- package/components/Inputs/TextInput.js +3 -6
- package/components/Inputs/TimeInput.js +3 -4
- package/components/Modal/ModalComp.js +68 -46
- package/components/Modal/index.js +0 -1
- package/components/constants/defaultStyle.js +16 -20
- package/components/constants/defaultThemeColor.js +2 -1
- package/dist/index.es.js +421 -436
- package/dist/index.js +284 -299
- package/package.json +1 -1
- package/components/Inputs/CheckBoxEditableInput.js +0 -352
- package/components/Inputs/CheckBoxInputMS.js +0 -160
- package/components/Inputs/TextInputClicable.js +0 -198
- package/components/Inputs/TextInputClicableMS.js +0 -255
- package/components/Modal/Modal.js +0 -116
|
@@ -1,120 +1,134 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from
|
|
2
|
-
import SignaturePad from 'react-signature-pad-wrapper'
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import SignaturePad from 'react-signature-pad-wrapper';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
5
|
import defaultStyle from '../constants/defaultStyle';
|
|
6
6
|
import getDefaultStyles from '../constants/utils';
|
|
7
|
-
import PropTypes from
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
|
-
import { Icon } from
|
|
9
|
+
import { Icon } from '../Icon';
|
|
10
10
|
|
|
11
11
|
const ParentDiv = styled.div`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
${({ theme, defaultParentDivStyle }) => {
|
|
12
|
+
//Set the styles from the default styles object
|
|
13
|
+
${({ theme, defaultParentDivStyle }) => {
|
|
15
14
|
return getDefaultStyles(theme, defaultParentDivStyle);
|
|
16
15
|
}}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
16
|
+
|
|
17
|
+
border: 1px solid ${({ isMyInputFocused, activeColor, defaultColor }) =>
|
|
18
|
+
isMyInputFocused ? activeColor : defaultColor};
|
|
19
|
+
|
|
20
|
+
&:focus-within {
|
|
21
|
+
border-color: ${({ activeColor }) => activeColor};
|
|
22
|
+
}
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
25
|
const WrapperDiv = styled.div`
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
${({ theme, defaultWrapperDivStyle }) => {
|
|
26
|
+
//Set the styles from the default styles object
|
|
27
|
+
${({ theme, defaultWrapperDivStyle }) => {
|
|
29
28
|
return getDefaultStyles(theme, defaultWrapperDivStyle);
|
|
30
29
|
}}
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
flex-direction: ${({ signIcon }) => (signIcon ? 'column' : 'initial')};
|
|
32
|
+
width: ${({ signIcon }) =>
|
|
33
|
+
signIcon ? 'min-content' : 'calc(100% - 50px) !important'};
|
|
34
|
+
max-width: ${({ signIcon }) => (signIcon ? '42px' : '490px')};
|
|
35
|
+
border-right: 1px solid
|
|
36
|
+
${({ activeColor, defaultColor, isMyInputFocused, signIcon }) =>
|
|
37
|
+
signIcon ? (isMyInputFocused ? activeColor : defaultColor) : 'none'};
|
|
38
|
+
border-left: ${({ signIcon }) => (!signIcon ? 'none' : '')};
|
|
39
|
+
margin-left: ${({ signIcon }) => (!signIcon ? '42px' : '')};
|
|
40
|
+
position: ${({ signIcon }) => (!signIcon ? '' : 'absolute')};
|
|
42
41
|
`;
|
|
43
42
|
|
|
44
43
|
const ControllerDiv = styled.div`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
penIcon
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
width: 39px;
|
|
45
|
+
height: 44px;
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: row;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
align-items: center;
|
|
50
|
+
border-bottom: ${({ penIcon, isMyInputFocused, activeColor, defaultColor }) =>
|
|
51
|
+
penIcon
|
|
52
|
+
? isMyInputFocused
|
|
53
|
+
? '1px solid ' + activeColor
|
|
54
|
+
: '1px solid ' + defaultColor
|
|
55
|
+
: ''};
|
|
56
|
+
background-color: rgba(255, 255, 255, 0.05);
|
|
57
|
+
cursor: pointer;
|
|
55
58
|
`;
|
|
56
59
|
|
|
57
|
-
|
|
58
60
|
const InputText = styled.input`
|
|
59
|
-
|
|
61
|
+
${({ theme, defaultInputStyle }) => {
|
|
60
62
|
return getDefaultStyles(theme, defaultInputStyle);
|
|
61
63
|
}}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
value.length > 0 ? 'none' :
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
64
|
+
|
|
65
|
+
border-bottom: ${({ value, defaultColor }) =>
|
|
66
|
+
value.length > 0 ? 'none' : '1px solid ' + defaultColor};
|
|
67
|
+
|
|
68
|
+
&::placeholder {
|
|
69
|
+
font-size: 17px;
|
|
70
|
+
text-align: center;
|
|
71
|
+
color: ${({ placeholderColor }) => placeholderColor};
|
|
72
|
+
font-family: 'Averta';
|
|
73
|
+
font-style: normal;
|
|
74
|
+
font-weight: normal;
|
|
75
|
+
line-height: 22px;
|
|
76
|
+
}
|
|
77
|
+
&:focus-within {
|
|
78
|
+
border: none;
|
|
79
|
+
outline: none;
|
|
80
|
+
|
|
81
|
+
::placeholder {
|
|
82
|
+
color: transparent;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// custom styles
|
|
87
|
+
${({ customInputStyle }) => customInputStyle}
|
|
86
88
|
`;
|
|
87
89
|
|
|
88
90
|
const SignaturePadDiv = styled.div`
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
position: relative;
|
|
92
|
+
width: inherit;
|
|
93
|
+
display: flex;
|
|
94
|
+
margin: 4px;
|
|
93
95
|
`;
|
|
94
96
|
|
|
95
97
|
const IconDiv = styled.div`
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
margin-left: ${({ selected }) => selected === 'sign' ? '' : 'auto'};
|
|
98
|
+
padding-left: 2px;
|
|
99
|
+
display: flex;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
cursor: pointer;
|
|
101
102
|
`;
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
export const SignatureInput = ({
|
|
105
|
+
onChange,
|
|
106
|
+
activeColor,
|
|
107
|
+
defaultColor,
|
|
108
|
+
placeholderColor,
|
|
109
|
+
placeholderText,
|
|
110
|
+
customInputStyle,
|
|
111
|
+
pointsArray,
|
|
112
|
+
setPointsArray,
|
|
113
|
+
value,
|
|
114
|
+
setValue,
|
|
115
|
+
valueForSignatureDrawing,
|
|
116
|
+
setValueForSignatureDrawing,
|
|
117
|
+
imageURL,
|
|
118
|
+
setImageURL,
|
|
119
|
+
...props
|
|
120
|
+
}) => {
|
|
105
121
|
const [selected, setSelected] = useState('default');
|
|
106
122
|
const [isMyInputFocused, setIsMyInputFocused] = useState(false);
|
|
107
123
|
const [dirty, setDirty] = useState(false);
|
|
108
124
|
const pad = useRef(null);
|
|
109
125
|
|
|
110
|
-
// const theme = defaultStyle;
|
|
111
|
-
|
|
112
126
|
useEffect(() => {
|
|
113
127
|
if (dirty) {
|
|
114
128
|
save();
|
|
115
129
|
setValueForSignatureDrawing(pad.current);
|
|
116
130
|
}
|
|
117
|
-
}, [dirty === true])
|
|
131
|
+
}, [dirty === true]);
|
|
118
132
|
|
|
119
133
|
const onClear = () => {
|
|
120
134
|
setValue('');
|
|
@@ -124,13 +138,13 @@ export const SignatureInput = ({ onChange, activeColor, defaultColor, placeholde
|
|
|
124
138
|
}
|
|
125
139
|
setIsMyInputFocused(false);
|
|
126
140
|
setDirty(false);
|
|
127
|
-
}
|
|
141
|
+
};
|
|
128
142
|
|
|
129
143
|
const save = () => {
|
|
130
144
|
setPointsArray(pad.current.toData());
|
|
131
|
-
setImageURL(pad.current.toDataURL(
|
|
145
|
+
setImageURL(pad.current.toDataURL('image/png'));
|
|
132
146
|
return [imageURL, pointsArray];
|
|
133
|
-
}
|
|
147
|
+
};
|
|
134
148
|
|
|
135
149
|
return (
|
|
136
150
|
<ParentDiv
|
|
@@ -139,7 +153,8 @@ export const SignatureInput = ({ onChange, activeColor, defaultColor, placeholde
|
|
|
139
153
|
isMyInputFocused={isMyInputFocused}
|
|
140
154
|
selected={selected}
|
|
141
155
|
activeColor={activeColor}
|
|
142
|
-
defaultColor={defaultColor}
|
|
156
|
+
defaultColor={defaultColor}
|
|
157
|
+
>
|
|
143
158
|
<WrapperDiv
|
|
144
159
|
theme={defaultStyle}
|
|
145
160
|
defaultWrapperDivStyle={'signature-wrapper-div'}
|
|
@@ -147,27 +162,37 @@ export const SignatureInput = ({ onChange, activeColor, defaultColor, placeholde
|
|
|
147
162
|
defaultColor={defaultColor}
|
|
148
163
|
selected={selected}
|
|
149
164
|
isMyInputFocused={isMyInputFocused}
|
|
150
|
-
signIcon={true}
|
|
165
|
+
signIcon={true}
|
|
166
|
+
>
|
|
151
167
|
<ControllerDiv
|
|
152
168
|
activeColor={activeColor}
|
|
153
169
|
defaultColor={defaultColor}
|
|
154
170
|
isMyInputFocused={isMyInputFocused}
|
|
155
171
|
penIcon={true}
|
|
156
|
-
onClick={() => {
|
|
172
|
+
onClick={() => {
|
|
173
|
+
setSelected('default');
|
|
174
|
+
onClear();
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
157
177
|
<Icon
|
|
158
178
|
icon='pen-icon'
|
|
159
|
-
color={selected === 'default' ?
|
|
160
|
-
|
|
179
|
+
color={selected === 'default' ? activeColor : 'black'}
|
|
180
|
+
/>
|
|
161
181
|
</ControllerDiv>
|
|
162
182
|
<ControllerDiv
|
|
163
|
-
activeColor={activeColor}
|
|
183
|
+
activeColor={activeColor}
|
|
184
|
+
defaultColor={defaultColor}
|
|
164
185
|
isMyInputFocused={isMyInputFocused}
|
|
165
186
|
penIcon={false}
|
|
166
|
-
onClick={() => {
|
|
187
|
+
onClick={() => {
|
|
188
|
+
setSelected('sign');
|
|
189
|
+
onClear();
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
167
192
|
<Icon
|
|
168
193
|
icon='sign-icon'
|
|
169
|
-
color={selected !== 'default' ?
|
|
170
|
-
|
|
194
|
+
color={selected !== 'default' ? activeColor : 'black'}
|
|
195
|
+
/>
|
|
171
196
|
</ControllerDiv>
|
|
172
197
|
</WrapperDiv>
|
|
173
198
|
<WrapperDiv
|
|
@@ -178,10 +203,14 @@ export const SignatureInput = ({ onChange, activeColor, defaultColor, placeholde
|
|
|
178
203
|
selected={selected}
|
|
179
204
|
isMyInputFocused={isMyInputFocused}
|
|
180
205
|
signIcon={false}
|
|
181
|
-
onTouchStart={() => {
|
|
182
|
-
|
|
206
|
+
onTouchStart={() => {
|
|
207
|
+
console.log('touchstart');
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{selected === 'default' ? (
|
|
183
211
|
<InputText
|
|
184
|
-
theme={defaultStyle}
|
|
212
|
+
theme={defaultStyle}
|
|
213
|
+
defaultInputStyle={'signature-input-text'}
|
|
185
214
|
placeholder={placeholderText}
|
|
186
215
|
placeholderColor={placeholderColor}
|
|
187
216
|
customInputStyle={customInputStyle}
|
|
@@ -189,29 +218,34 @@ export const SignatureInput = ({ onChange, activeColor, defaultColor, placeholde
|
|
|
189
218
|
onFocus={() => setIsMyInputFocused(true)}
|
|
190
219
|
value={value}
|
|
191
220
|
defaultColor={defaultColor}
|
|
192
|
-
onChange={(e) => setValue(e.target.value)}
|
|
193
|
-
|
|
221
|
+
onChange={(e) => setValue(e.target.value)}
|
|
222
|
+
/>
|
|
223
|
+
) : (
|
|
224
|
+
<SignaturePadDiv
|
|
194
225
|
onMouseEnter={() => setIsMyInputFocused(true)}
|
|
195
226
|
onMouseLeave={() => setIsMyInputFocused(false)}
|
|
196
|
-
onClick={() => {
|
|
227
|
+
onClick={() => {
|
|
228
|
+
setDirty(true);
|
|
229
|
+
save();
|
|
230
|
+
}}
|
|
231
|
+
>
|
|
197
232
|
<SignaturePad
|
|
198
233
|
ref={pad}
|
|
199
234
|
redrawOnResize
|
|
200
235
|
height={75}
|
|
201
|
-
options={{ minWidth: 1, maxWidth: 1, penColor: '#444444' }}
|
|
236
|
+
options={{ minWidth: 1, maxWidth: 1, penColor: '#444444' }}
|
|
237
|
+
/>
|
|
202
238
|
</SignaturePadDiv>
|
|
203
|
-
}
|
|
204
|
-
{(value || dirty) &&
|
|
205
|
-
<
|
|
206
|
-
icon='cross-icon'
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
</IconDiv>
|
|
210
|
-
}
|
|
239
|
+
)}
|
|
240
|
+
{(value || dirty) && (
|
|
241
|
+
<IconDiv selected={selected} onClick={() => onClear()}>
|
|
242
|
+
<Icon icon='cross-icon' color={defaultColor} />
|
|
243
|
+
</IconDiv>
|
|
244
|
+
)}
|
|
211
245
|
</WrapperDiv>
|
|
212
246
|
</ParentDiv>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
247
|
+
);
|
|
248
|
+
};
|
|
215
249
|
|
|
216
250
|
SignatureInput.propTypes = {
|
|
217
251
|
/**
|
|
@@ -257,9 +291,8 @@ SignatureInput.propTypes = {
|
|
|
257
291
|
/**
|
|
258
292
|
* Function that sets Image url of the Signature drawing
|
|
259
293
|
*/
|
|
260
|
-
setImageURL: PropTypes.func
|
|
261
|
-
|
|
262
|
-
}
|
|
294
|
+
setImageURL: PropTypes.func,
|
|
295
|
+
};
|
|
263
296
|
|
|
264
297
|
SignatureInput.defaultProps = {
|
|
265
298
|
activeColor: `${defaultThemeColor.primary['primary-1']}`,
|
|
@@ -269,10 +302,10 @@ SignatureInput.defaultProps = {
|
|
|
269
302
|
placeholderText: 'Type your signature here',
|
|
270
303
|
pointsArray: null,
|
|
271
304
|
setPointsArray: () => { },
|
|
272
|
-
value:
|
|
305
|
+
value: '',
|
|
273
306
|
setValue: () => { },
|
|
274
307
|
imageURL: '',
|
|
275
308
|
setImageURL: () => { },
|
|
276
309
|
setValueForSignatureDrawing: () => { },
|
|
277
|
-
}
|
|
310
|
+
};
|
|
278
311
|
|
|
@@ -6,7 +6,6 @@ import defaultStyles from '../constants/defaultStyle';
|
|
|
6
6
|
import getDefaultStyles from '../constants/utils';
|
|
7
7
|
import { Label } from '../Label';
|
|
8
8
|
|
|
9
|
-
const border = `#D4D7E3`;
|
|
10
9
|
|
|
11
10
|
const TextWrapper = styled.div`
|
|
12
11
|
//Set the styles from the default styles object
|
|
@@ -15,7 +14,7 @@ const TextWrapper = styled.div`
|
|
|
15
14
|
}}
|
|
16
15
|
|
|
17
16
|
border: ${({ isValid, themeColor }) => !isValid ? '1px solid ' + themeColor.variant['error'] :
|
|
18
|
-
'1px solid ' + border};
|
|
17
|
+
'1px solid ' + defaultThemeColor.border};
|
|
19
18
|
|
|
20
19
|
.input-icon svg path {
|
|
21
20
|
fill: ${({ themeColor }) => themeColor.variant['neutral-1']};
|
|
@@ -6,7 +6,6 @@ import defaultStyles from '../constants/defaultStyle';
|
|
|
6
6
|
import getDefaultStyles from '../constants/utils';
|
|
7
7
|
import { Label } from '../Label';
|
|
8
8
|
|
|
9
|
-
const border = `#D4D7E3`;
|
|
10
9
|
|
|
11
10
|
const TextWrapper = styled.div`
|
|
12
11
|
//Set the styles from the default styles object
|
|
@@ -15,7 +14,7 @@ const TextWrapper = styled.div`
|
|
|
15
14
|
}}
|
|
16
15
|
|
|
17
16
|
border: ${({ isValid, themeColor }) => !isValid ? '1px solid ' + themeColor.variant['error'] :
|
|
18
|
-
'1px solid ' + border};
|
|
17
|
+
'1px solid ' + defaultThemeColor.border};
|
|
19
18
|
|
|
20
19
|
.input-icon svg path {
|
|
21
20
|
fill: ${({ themeColor }) => themeColor.variant['neutral-1']};
|
|
@@ -69,13 +68,11 @@ Form.defaultProps = {
|
|
|
69
68
|
themeColor: defaultThemeColor,
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
|
|
73
71
|
export const TextInput = ({ themeColor, textBoxStyle, labelStyle, inputStyle, errMsg, required, label, labelInline, iconBefore, iconAfter, isValid, type, ...props }) => {
|
|
74
72
|
return (
|
|
75
73
|
<Form labelInline={labelInline} {...props}>
|
|
76
74
|
<div style={{ display: 'flex' }}>
|
|
77
75
|
<Label
|
|
78
|
-
themeColor={defaultThemeColor}
|
|
79
76
|
customStyles={labelStyle}
|
|
80
77
|
type={'label-text'}
|
|
81
78
|
labelInline={labelInline}
|
|
@@ -83,7 +80,7 @@ export const TextInput = ({ themeColor, textBoxStyle, labelStyle, inputStyle, er
|
|
|
83
80
|
errMsg={errMsg}
|
|
84
81
|
style={{
|
|
85
82
|
'display': 'flex',
|
|
86
|
-
'
|
|
83
|
+
'marginBottom': `${!labelInline ? '10px' : ''}`,
|
|
87
84
|
}}
|
|
88
85
|
{...props} />
|
|
89
86
|
{required && <div style={{
|
|
@@ -179,4 +176,4 @@ TextInput.defaultProps = {
|
|
|
179
176
|
labelStyle: {},
|
|
180
177
|
inputStyle: {},
|
|
181
178
|
type: 'text'
|
|
182
|
-
}
|
|
179
|
+
}
|
|
@@ -3,12 +3,11 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import styled, { css, useTheme } from 'styled-components';
|
|
4
4
|
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
5
5
|
|
|
6
|
-
const border = `#D4D7E3`;
|
|
7
6
|
|
|
8
7
|
const TextBox = styled.div`
|
|
9
8
|
color: #A9B1B8;
|
|
10
9
|
font-size: 21px;
|
|
11
|
-
border: 1px solid ${({ theme, isValid }) => isValid ? border : theme.variant['error']};
|
|
10
|
+
border: 1px solid ${({ theme, isValid }) => isValid ? defaultThemeColor.border : theme.variant['error']};
|
|
12
11
|
border-radius: 4px;
|
|
13
12
|
padding: 5px;
|
|
14
13
|
display: inline-block;
|
|
@@ -98,13 +97,13 @@ export const TimeInput = ({ label, errMsg, hour, minute, period, onChange, ...pr
|
|
|
98
97
|
const theme = useTheme() || defaultThemeColor;
|
|
99
98
|
|
|
100
99
|
function hourChange(evt) {
|
|
101
|
-
const num = evt.currentTarget.value>12? 12: parseFloat(evt.currentTarget.value) || 0;
|
|
100
|
+
const num = evt.currentTarget.value > 12 ? 12 : parseFloat(evt.currentTarget.value) || 0;
|
|
102
101
|
onChange({ hour: num, minute, period });
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
function minuteChange(evt) {
|
|
106
105
|
console.log('minute change', evt.currentTarget.value);
|
|
107
|
-
const num = evt.currentTarget.value>59?59: parseFloat(evt.currentTarget.value) || 0;
|
|
106
|
+
const num = evt.currentTarget.value > 59 ? 59 : parseFloat(evt.currentTarget.value) || 0;
|
|
108
107
|
onChange({ hour, minute: num, period });
|
|
109
108
|
}
|
|
110
109
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import Modal from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Modal from 'react-modal';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import defaultStyles from '../constants/defaultStyle';
|
|
5
5
|
import getDefaultStyles from '../constants/utils';
|
|
6
|
-
import PropTypes from
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
7
|
import { Icon } from '../Icon';
|
|
8
|
+
import defaultThemeColor from '../constants/defaultThemeColor';
|
|
8
9
|
|
|
9
10
|
const customStyles = {
|
|
10
11
|
overlay: {
|
|
11
|
-
zIndex: '999'
|
|
12
|
+
zIndex: '999',
|
|
12
13
|
},
|
|
13
14
|
content: {
|
|
14
15
|
top: '50%',
|
|
@@ -16,89 +17,110 @@ const customStyles = {
|
|
|
16
17
|
right: 'auto',
|
|
17
18
|
bottom: 'auto',
|
|
18
19
|
marginRight: '-50%',
|
|
19
|
-
padding: '
|
|
20
|
+
padding: '1rem 3rem 0.8rem 3rem',
|
|
20
21
|
transform: 'translate(-50%, -50%)',
|
|
22
|
+
maxHeight: '90vh',
|
|
21
23
|
},
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const ModalClose = styled.button`
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
//Set the styles from the default styles object
|
|
28
|
+
${({ theme, type }) => {
|
|
27
29
|
return getDefaultStyles(theme, type);
|
|
28
30
|
}}
|
|
29
|
-
|
|
31
|
+
// custom styles
|
|
30
32
|
${({ customModalCloseStyle }) => customModalCloseStyle}
|
|
31
33
|
${'' /* background: transparent; */}
|
|
32
|
-
|
|
34
|
+
`;
|
|
33
35
|
|
|
34
36
|
const ModalHeader = styled.div`
|
|
35
|
-
.header-title{
|
|
37
|
+
.header-title {
|
|
36
38
|
display: flex;
|
|
37
39
|
gap: 10px;
|
|
38
40
|
align-items: center;
|
|
39
41
|
}
|
|
40
|
-
.header-description{
|
|
42
|
+
.header-description {
|
|
41
43
|
margin-top: 5px;
|
|
42
44
|
}
|
|
43
45
|
h4 {
|
|
44
46
|
margin-bottom: 0;
|
|
45
47
|
}
|
|
46
48
|
// custom styles
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
${({ customModalHeaderStyle }) => customModalHeaderStyle}
|
|
50
|
+
`;
|
|
49
51
|
const ModalBody = styled.div`
|
|
50
52
|
//Set the styles from the default styles object
|
|
51
|
-
|
|
53
|
+
${({ theme, type }) => {
|
|
52
54
|
return getDefaultStyles(theme, type);
|
|
53
55
|
}}
|
|
54
|
-
|
|
56
|
+
// custom styles
|
|
55
57
|
${({ customModalBodyStyle }) => customModalBodyStyle}
|
|
56
|
-
|
|
58
|
+
`;
|
|
57
59
|
|
|
58
60
|
const ModalFooter = styled.div`
|
|
59
61
|
//Set the styles from the default styles object
|
|
60
|
-
|
|
62
|
+
${({ theme, type }) => {
|
|
61
63
|
return getDefaultStyles(theme, type);
|
|
62
64
|
}}
|
|
63
|
-
|
|
65
|
+
// custom styles
|
|
64
66
|
${({ customModalFooterStyle }) => customModalFooterStyle}
|
|
65
|
-
|
|
67
|
+
`;
|
|
66
68
|
|
|
67
|
-
Modal.setAppElement(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export const ModalComp = ({ modalIsOpen, toggleModal, closeOnOutsideClick, headerContent, bodyContent, footerContent, customModalCloseStyle, customModalHeaderStyle, customModalBodyStyle, customModalFooterStyle, ...props }) => {
|
|
69
|
+
Modal.setAppElement('#root');
|
|
71
70
|
|
|
71
|
+
export const ModalComp = ({
|
|
72
|
+
modalIsOpen,
|
|
73
|
+
toggleModal,
|
|
74
|
+
closeOnOutsideClick,
|
|
75
|
+
headerContent,
|
|
76
|
+
bodyContent,
|
|
77
|
+
footerContent,
|
|
78
|
+
customModalCloseStyle,
|
|
79
|
+
customModalHeaderStyle,
|
|
80
|
+
customModalBodyStyle,
|
|
81
|
+
customModalFooterStyle,
|
|
82
|
+
...props
|
|
83
|
+
}) => {
|
|
72
84
|
return (
|
|
73
85
|
<Modal
|
|
74
86
|
isOpen={modalIsOpen}
|
|
75
|
-
// onAfterOpen={afterOpenModal}
|
|
76
87
|
onRequestClose={closeOnOutsideClick ? toggleModal : undefined}
|
|
77
88
|
style={customStyles}
|
|
78
|
-
contentLabel=
|
|
89
|
+
contentLabel='Modal'
|
|
79
90
|
{...props}
|
|
80
91
|
>
|
|
81
|
-
<ModalClose
|
|
82
|
-
|
|
83
|
-
|
|
92
|
+
<ModalClose
|
|
93
|
+
theme={defaultStyles}
|
|
94
|
+
type={'modalComp-modal-close'}
|
|
95
|
+
style={customModalCloseStyle}
|
|
96
|
+
onClick={toggleModal}
|
|
97
|
+
>
|
|
98
|
+
<Icon
|
|
99
|
+
icon='cross-icon'
|
|
100
|
+
color={defaultThemeColor.neutral['neutral-2']}
|
|
101
|
+
size={15}
|
|
102
|
+
/>
|
|
84
103
|
</ModalClose>
|
|
85
104
|
|
|
86
|
-
<ModalHeader style={customModalHeaderStyle}>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
<ModalHeader style={customModalHeaderStyle}>{headerContent}</ModalHeader>
|
|
106
|
+
<ModalBody
|
|
107
|
+
theme={defaultStyles}
|
|
108
|
+
type={'modalComp-modal-body'}
|
|
109
|
+
style={customModalBodyStyle}
|
|
110
|
+
>
|
|
91
111
|
{bodyContent}
|
|
92
112
|
</ModalBody>
|
|
93
113
|
|
|
94
|
-
<ModalFooter
|
|
95
|
-
|
|
96
|
-
{
|
|
114
|
+
<ModalFooter
|
|
115
|
+
theme={defaultStyles}
|
|
116
|
+
type={'modalComp-modal-footer'}
|
|
117
|
+
style={customModalFooterStyle}
|
|
118
|
+
>
|
|
97
119
|
{footerContent}
|
|
98
120
|
</ModalFooter>
|
|
99
121
|
</Modal>
|
|
100
122
|
);
|
|
101
|
-
}
|
|
123
|
+
};
|
|
102
124
|
|
|
103
125
|
ModalComp.propTypes = {
|
|
104
126
|
/**
|
|
@@ -111,7 +133,7 @@ ModalComp.propTypes = {
|
|
|
111
133
|
toggleModal: PropTypes.func,
|
|
112
134
|
/**
|
|
113
135
|
* Close modal on clicking outside
|
|
114
|
-
|
|
136
|
+
*/
|
|
115
137
|
closeOnOutsideClick: PropTypes.bool,
|
|
116
138
|
/**
|
|
117
139
|
* Modal Header Content
|
|
@@ -127,21 +149,21 @@ ModalComp.propTypes = {
|
|
|
127
149
|
footerContent: PropTypes.any,
|
|
128
150
|
/**
|
|
129
151
|
* Modal Close icon custom styles
|
|
130
|
-
|
|
152
|
+
*/
|
|
131
153
|
customModalCloseStyle: PropTypes.object,
|
|
132
154
|
/**
|
|
133
155
|
* Modal Header custom styles
|
|
134
|
-
|
|
156
|
+
*/
|
|
135
157
|
customModalHeaderStyle: PropTypes.object,
|
|
136
158
|
/**
|
|
137
159
|
* Modal Body custom styles
|
|
138
|
-
|
|
160
|
+
*/
|
|
139
161
|
customModalBodyStyle: PropTypes.object,
|
|
140
162
|
/**
|
|
141
163
|
* Modal Footer custom styles
|
|
142
|
-
|
|
143
|
-
customModalFooterStyle: PropTypes.object
|
|
144
|
-
}
|
|
164
|
+
*/
|
|
165
|
+
customModalFooterStyle: PropTypes.object,
|
|
166
|
+
};
|
|
145
167
|
|
|
146
168
|
ModalComp.defaultProps = {
|
|
147
169
|
modalIsOpen: false,
|
|
@@ -153,6 +175,6 @@ ModalComp.defaultProps = {
|
|
|
153
175
|
customModalCloseStyle: {},
|
|
154
176
|
customModalHeaderStyle: {},
|
|
155
177
|
customModalBodyStyle: {},
|
|
156
|
-
customModalFooterStyle: {}
|
|
157
|
-
}
|
|
178
|
+
customModalFooterStyle: {},
|
|
179
|
+
};
|
|
158
180
|
|