@platformatic/ui-components 0.3.3 → 0.3.5
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/package.json +1 -1
- package/src/components/Modal.jsx +22 -13
- package/src/components/ModalDirectional.jsx +10 -4
- package/src/components/forms/Input.jsx +13 -3
- package/src/components/forms/InputWithSeparator.jsx +13 -2
- package/src/components/forms/Password.jsx +13 -3
- package/src/components/forms/RadioGroup.jsx +9 -2
- package/src/components/forms/Select.jsx +13 -3
- package/src/components/forms/SelectWithInput.jsx +13 -3
- package/src/components/forms/TextArea.jsx +25 -3
- package/src/components/forms/ToggleSwitch.jsx +18 -2
- package/src/stories/Modal.stories.jsx +52 -1
package/package.json
CHANGED
package/src/components/Modal.jsx
CHANGED
|
@@ -40,7 +40,8 @@ function Modal ({
|
|
|
40
40
|
backgroundClassName,
|
|
41
41
|
titleClassName,
|
|
42
42
|
childrenClassContainer,
|
|
43
|
-
modalCloseClassName
|
|
43
|
+
modalCloseClassName,
|
|
44
|
+
permanent
|
|
44
45
|
}) {
|
|
45
46
|
let contentFullscreen
|
|
46
47
|
let titleFullscreen
|
|
@@ -96,7 +97,10 @@ function Modal ({
|
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
function closeModal (event) {
|
|
100
|
+
console.log('closeModal', event)
|
|
99
101
|
if (event.target === blurRef.current) {
|
|
102
|
+
event.preventDefault()
|
|
103
|
+
event.stopPropagation()
|
|
100
104
|
setIsOpen(false)
|
|
101
105
|
}
|
|
102
106
|
}
|
|
@@ -105,7 +109,7 @@ function Modal ({
|
|
|
105
109
|
case MODAL_POPUP_V2:
|
|
106
110
|
whichModal = (
|
|
107
111
|
|
|
108
|
-
<div className={`${styles['blur-fixed']}`} onClick={(event) => closeModal(event)} ref={blurRef}>
|
|
112
|
+
<div className={`${styles['blur-fixed']}`} onClick={(event) => permanent ? {} : closeModal(event)} ref={blurRef}>
|
|
109
113
|
<div className={styles.content}>
|
|
110
114
|
<div className={modalClassName}>
|
|
111
115
|
<div className={headerClassName}>
|
|
@@ -124,7 +128,7 @@ function Modal ({
|
|
|
124
128
|
case MODAL_POPUP:
|
|
125
129
|
whichModal = (
|
|
126
130
|
<>
|
|
127
|
-
<div className={styles.blur} onClick={() => setIsOpen(false)} />
|
|
131
|
+
<div className={styles.blur} onClick={() => permanent ? {} : setIsOpen(false)} />
|
|
128
132
|
<div className={`${styles.container} ${styles.centered}`}>
|
|
129
133
|
<div className={modalClassName}>
|
|
130
134
|
<div className={headerClassName}>
|
|
@@ -242,37 +246,41 @@ Modal.propTypes = {
|
|
|
242
246
|
*/
|
|
243
247
|
childrenClassContainer: PropTypes.string,
|
|
244
248
|
/**
|
|
245
|
-
* setIsOpen
|
|
249
|
+
* setIsOpen: function from Parent for close/pen
|
|
246
250
|
*/
|
|
247
251
|
setIsOpen: PropTypes.func,
|
|
248
252
|
/**
|
|
249
|
-
* title
|
|
253
|
+
* title: Title on top for small Modals (check MODAL_LAYOUTS)
|
|
250
254
|
*/
|
|
251
255
|
title: PropTypes.string,
|
|
252
256
|
/**
|
|
253
|
-
* layout
|
|
257
|
+
* layout: type of Layout of the modal
|
|
254
258
|
*/
|
|
255
259
|
layout: PropTypes.oneOf(MODAL_LAYOUTS),
|
|
256
260
|
/**
|
|
257
|
-
* Size
|
|
261
|
+
* Size: of the modal
|
|
258
262
|
*/
|
|
259
263
|
size: PropTypes.oneOf(MODAL_SIZES),
|
|
260
264
|
/**
|
|
261
|
-
* profile
|
|
265
|
+
* profile: deprecated
|
|
262
266
|
*/
|
|
263
267
|
profile: PropTypes.oneOf(PROFILES),
|
|
264
268
|
/**
|
|
265
|
-
* backgroundClassName
|
|
269
|
+
* backgroundClassName: background of the full screen modal
|
|
266
270
|
*/
|
|
267
271
|
backgroundClassName: PropTypes.string,
|
|
268
272
|
/**
|
|
269
|
-
* titleClassName
|
|
273
|
+
* titleClassName: classes of the title
|
|
270
274
|
*/
|
|
271
275
|
titleClassName: PropTypes.string,
|
|
272
276
|
/**
|
|
273
|
-
* modalCloseClassName
|
|
277
|
+
* modalCloseClassName: classes for the closing icon
|
|
274
278
|
*/
|
|
275
|
-
modalCloseClassName: PropTypes.string
|
|
279
|
+
modalCloseClassName: PropTypes.string,
|
|
280
|
+
/**
|
|
281
|
+
* permanent: modal could be closed only with Esc, X or Cancel
|
|
282
|
+
*/
|
|
283
|
+
permanent: PropTypes.bool
|
|
276
284
|
}
|
|
277
285
|
|
|
278
286
|
Modal.defaultProps = {
|
|
@@ -285,7 +293,8 @@ Modal.defaultProps = {
|
|
|
285
293
|
profile: '',
|
|
286
294
|
backgroundClassName: '',
|
|
287
295
|
titleClassName: '',
|
|
288
|
-
modalCloseClassName: ''
|
|
296
|
+
modalCloseClassName: '',
|
|
297
|
+
permanent: false
|
|
289
298
|
}
|
|
290
299
|
|
|
291
300
|
export default Modal
|
|
@@ -17,7 +17,8 @@ function ModalDirectional ({
|
|
|
17
17
|
titleClassName,
|
|
18
18
|
children,
|
|
19
19
|
smallLayout,
|
|
20
|
-
classNameModalLefty
|
|
20
|
+
classNameModalLefty,
|
|
21
|
+
permanent
|
|
21
22
|
}) {
|
|
22
23
|
const className = `${styles.container} ${styles.modalLeftCover} ${smallLayout ? styles.smallLayout : styles.normalLayout}`
|
|
23
24
|
const [modalClassName] = useState(className)
|
|
@@ -39,7 +40,7 @@ function ModalDirectional ({
|
|
|
39
40
|
|
|
40
41
|
return (
|
|
41
42
|
<>
|
|
42
|
-
<div className={styles.blur} onClick={() => closeModal()} />
|
|
43
|
+
<div className={styles.blur} onClick={() => permanent ? {} : closeModal()} />
|
|
43
44
|
<div className={variantModalClassName}>
|
|
44
45
|
<div className={classNameLefty}>
|
|
45
46
|
<div className={styles.headerClassName}>
|
|
@@ -89,7 +90,11 @@ ModalDirectional.propTypes = {
|
|
|
89
90
|
/**
|
|
90
91
|
* classNameLefty
|
|
91
92
|
*/
|
|
92
|
-
classNameLefty: PropTypes.string
|
|
93
|
+
classNameLefty: PropTypes.string,
|
|
94
|
+
/**
|
|
95
|
+
* permanent: modal could be closed only with Esc, X or Cancel
|
|
96
|
+
*/
|
|
97
|
+
permanent: PropTypes.bool
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
ModalDirectional.defaultProps = {
|
|
@@ -98,7 +103,8 @@ ModalDirectional.defaultProps = {
|
|
|
98
103
|
title: '',
|
|
99
104
|
titleClassName: '',
|
|
100
105
|
smallLayout: false,
|
|
101
|
-
classNameLefty: ''
|
|
106
|
+
classNameLefty: '',
|
|
107
|
+
permanent: false
|
|
102
108
|
}
|
|
103
109
|
|
|
104
110
|
export default ModalDirectional
|
|
@@ -12,6 +12,7 @@ function Input ({
|
|
|
12
12
|
name,
|
|
13
13
|
borderColor,
|
|
14
14
|
errorMessage,
|
|
15
|
+
errorMessageTextClassName,
|
|
15
16
|
onChange,
|
|
16
17
|
disabled,
|
|
17
18
|
beforeIcon,
|
|
@@ -27,7 +28,7 @@ function Input ({
|
|
|
27
28
|
let baseInputClassName = `${commonStyles.fullWidth} ${styles.input} ${inputTextClassName} `
|
|
28
29
|
baseInputClassName += verticalPaddingClassName || ` ${styles.inputDefaultVerticalPadding} `
|
|
29
30
|
baseInputClassName += ' ' + commonStyles[`text--${borderColor}`] + ' ' + commonStyles[`background-color-${backgroundColor}`]
|
|
30
|
-
|
|
31
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
31
32
|
const showError = errorMessage.length > 0
|
|
32
33
|
if (disabled) baseInputClassName += ' ' + commonStyles['apply-opacity-30']
|
|
33
34
|
if (beforeIcon) baseInputClassName += ' ' + styles.beforeIconPadding
|
|
@@ -80,7 +81,7 @@ function Input ({
|
|
|
80
81
|
{placeholderApart && <p className={styles.placeholderAPart}>{placeholder}</p>}
|
|
81
82
|
{afterIcon && <div className={styles.afterInputIcon}><PlatformaticIcon iconName={afterIcon.iconName} color={afterIcon.color} data-testid='after-icon' onClick={null} /></div>}
|
|
82
83
|
</div>
|
|
83
|
-
{showError && <span className={
|
|
84
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
84
85
|
</div>
|
|
85
86
|
)
|
|
86
87
|
}
|
|
@@ -157,7 +158,15 @@ Input.propTypes = {
|
|
|
157
158
|
/**
|
|
158
159
|
* readOnly
|
|
159
160
|
*/
|
|
160
|
-
readOnly: PropTypes.bool
|
|
161
|
+
readOnly: PropTypes.bool,
|
|
162
|
+
/**
|
|
163
|
+
* errorMessage
|
|
164
|
+
*/
|
|
165
|
+
errorMessage: PropTypes.string,
|
|
166
|
+
/**
|
|
167
|
+
* errorMessageTextClassName
|
|
168
|
+
*/
|
|
169
|
+
errorMessageTextClassName: PropTypes.string
|
|
161
170
|
}
|
|
162
171
|
|
|
163
172
|
Input.defaultProps = {
|
|
@@ -167,6 +176,7 @@ Input.defaultProps = {
|
|
|
167
176
|
borderColor: MAIN_GREEN,
|
|
168
177
|
backgroundColor: WHITE,
|
|
169
178
|
errorMessage: '',
|
|
179
|
+
errorMessageTextClassName: '',
|
|
170
180
|
onChange: () => {},
|
|
171
181
|
disabled: false,
|
|
172
182
|
beforeIcon: null,
|
|
@@ -14,6 +14,7 @@ function InputWithSeparator ({
|
|
|
14
14
|
borderColor,
|
|
15
15
|
backgroundColor,
|
|
16
16
|
errorMessage,
|
|
17
|
+
errorMessageTextClassName,
|
|
17
18
|
onChange,
|
|
18
19
|
disabled,
|
|
19
20
|
afterIcon,
|
|
@@ -27,6 +28,7 @@ function InputWithSeparator ({
|
|
|
27
28
|
const [focus, setFocus] = useState(false)
|
|
28
29
|
const baseClassName = `${styles.input} ${styles.flexNone} ${styles.smallMargin} ${inputTextClassName} ` + commonStyles[`background-color-${backgroundColor}`]
|
|
29
30
|
const buttonClassName = commonStyles[`background-color-${borderColor}`] + ' ' + commonStyles['background-color-opaque-30']
|
|
31
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
30
32
|
const [chunks, setChunks] = useState([])
|
|
31
33
|
const [inputClassName, setInputClassName] = useState(normalClassName())
|
|
32
34
|
const [inputContainerClassName, setInputContainerClassName] = useState(unFocusedClassName())
|
|
@@ -164,7 +166,7 @@ function InputWithSeparator ({
|
|
|
164
166
|
/>
|
|
165
167
|
)}
|
|
166
168
|
</div>
|
|
167
|
-
{showError && <span className={
|
|
169
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
168
170
|
</div>
|
|
169
171
|
)
|
|
170
172
|
}
|
|
@@ -222,7 +224,15 @@ InputWithSeparator.propTypes = {
|
|
|
222
224
|
color: PropTypes.string,
|
|
223
225
|
handleClick: PropTypes.func,
|
|
224
226
|
disabled: PropTypes.bool
|
|
225
|
-
})
|
|
227
|
+
}),
|
|
228
|
+
/**
|
|
229
|
+
* errorMessage
|
|
230
|
+
*/
|
|
231
|
+
errorMessage: PropTypes.string,
|
|
232
|
+
/**
|
|
233
|
+
* errorMessageTextClassName
|
|
234
|
+
*/
|
|
235
|
+
errorMessageTextClassName: PropTypes.string
|
|
226
236
|
}
|
|
227
237
|
|
|
228
238
|
InputWithSeparator.defaultProps = {
|
|
@@ -234,6 +244,7 @@ InputWithSeparator.defaultProps = {
|
|
|
234
244
|
borderColor: MAIN_GREEN,
|
|
235
245
|
backgroundColor: WHITE,
|
|
236
246
|
errorMessage: '',
|
|
247
|
+
errorMessageTextClassName: '',
|
|
237
248
|
onChange: () => {},
|
|
238
249
|
disabled: false,
|
|
239
250
|
afterIcon: null,
|
|
@@ -6,10 +6,11 @@ import commonStyles from '../Common.module.css'
|
|
|
6
6
|
import PlatformaticIcon from '../PlatformaticIcon'
|
|
7
7
|
import { MAIN_DARK_BLUE, MAIN_GREEN } from '../constants'
|
|
8
8
|
|
|
9
|
-
function Input ({ placeholder, value, name, borderColor, errorMessage, onChange, disabled }) {
|
|
9
|
+
function Input ({ placeholder, value, name, borderColor, errorMessage, errorMessageTextClassName, onChange, disabled }) {
|
|
10
10
|
const [type, setType] = useState('password')
|
|
11
11
|
let passwordClassName = `${commonStyles.fullWidth} ${styles.password} `
|
|
12
12
|
passwordClassName += commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + styles.afterIconPadding
|
|
13
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
13
14
|
const showError = errorMessage.length > 0
|
|
14
15
|
if (showError) passwordClassName += ' ' + commonStyles['bordered--error-red']
|
|
15
16
|
if (disabled) passwordClassName += ' ' + commonStyles['apply-opacity-30']
|
|
@@ -24,7 +25,7 @@ function Input ({ placeholder, value, name, borderColor, errorMessage, onChange,
|
|
|
24
25
|
: <PlatformaticIcon iconName='EyeClosedIcon' color={MAIN_DARK_BLUE} data-testid='after-eye-closed-icon' onClick={() => setType('password')} />}
|
|
25
26
|
</div>
|
|
26
27
|
</div>
|
|
27
|
-
{showError && <span className={
|
|
28
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
28
29
|
</div>
|
|
29
30
|
)
|
|
30
31
|
}
|
|
@@ -61,7 +62,15 @@ Input.propTypes = {
|
|
|
61
62
|
/**
|
|
62
63
|
* placeholderApart
|
|
63
64
|
*/
|
|
64
|
-
placeholderApart: PropTypes.bool
|
|
65
|
+
placeholderApart: PropTypes.bool,
|
|
66
|
+
/**
|
|
67
|
+
* errorMessage
|
|
68
|
+
*/
|
|
69
|
+
errorMessage: PropTypes.string,
|
|
70
|
+
/**
|
|
71
|
+
* errorMessageTextClassName
|
|
72
|
+
*/
|
|
73
|
+
errorMessageTextClassName: PropTypes.string
|
|
65
74
|
}
|
|
66
75
|
|
|
67
76
|
Input.defaultProps = {
|
|
@@ -70,6 +79,7 @@ Input.defaultProps = {
|
|
|
70
79
|
name: '',
|
|
71
80
|
borderColor: MAIN_DARK_BLUE,
|
|
72
81
|
errorMessage: '',
|
|
82
|
+
errorMessageTextClassName: '',
|
|
73
83
|
onChange: () => {},
|
|
74
84
|
disabled: false,
|
|
75
85
|
focused: false,
|
|
@@ -5,8 +5,10 @@ import styles from './RadioGroup.module.css'
|
|
|
5
5
|
import commonStyles from '../Common.module.css'
|
|
6
6
|
import { MAIN_DARK_BLUE, MAIN_GREEN } from '../constants'
|
|
7
7
|
|
|
8
|
-
function RadioGroup ({ name, radios, errorMessage, onChange, disabled, value }) {
|
|
8
|
+
function RadioGroup ({ name, radios, errorMessage, errorMessageTextClassName, onChange, disabled, value }) {
|
|
9
9
|
let radioContainerClass = styles.radioContainer
|
|
10
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
11
|
+
|
|
10
12
|
const showError = errorMessage.length > 0
|
|
11
13
|
if (disabled) radioContainerClass += ' ' + commonStyles['apply-opacity-30']
|
|
12
14
|
|
|
@@ -20,7 +22,7 @@ function RadioGroup ({ name, radios, errorMessage, onChange, disabled, value })
|
|
|
20
22
|
</div>
|
|
21
23
|
))}
|
|
22
24
|
</div>
|
|
23
|
-
{showError && <span className={
|
|
25
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
24
26
|
</div>
|
|
25
27
|
)
|
|
26
28
|
}
|
|
@@ -41,6 +43,10 @@ RadioGroup.propTypes = {
|
|
|
41
43
|
* errorMessage
|
|
42
44
|
*/
|
|
43
45
|
errorMessage: PropTypes.string,
|
|
46
|
+
/**
|
|
47
|
+
* errorMessageTextClassName
|
|
48
|
+
*/
|
|
49
|
+
errorMessageTextClassName: PropTypes.string,
|
|
44
50
|
/**
|
|
45
51
|
* onChange
|
|
46
52
|
*/
|
|
@@ -63,6 +69,7 @@ RadioGroup.defaultProps = {
|
|
|
63
69
|
name: '',
|
|
64
70
|
radios: [],
|
|
65
71
|
errorMessage: '',
|
|
72
|
+
errorMessageTextClassName: '',
|
|
66
73
|
onChange: () => {},
|
|
67
74
|
disabled: false,
|
|
68
75
|
color: MAIN_DARK_BLUE,
|
|
@@ -17,6 +17,7 @@ function Select ({
|
|
|
17
17
|
borderColor,
|
|
18
18
|
borderListColor,
|
|
19
19
|
errorMessage,
|
|
20
|
+
errorMessageTextClassName,
|
|
20
21
|
onSelect,
|
|
21
22
|
disabled,
|
|
22
23
|
mainColor,
|
|
@@ -30,7 +31,7 @@ function Select ({
|
|
|
30
31
|
// eslint-disable-next-line no-unused-vars
|
|
31
32
|
const [isSelected, setIsSelected] = useState(false)
|
|
32
33
|
const [isOnFocus, setIsOnFocus] = useState(false)
|
|
33
|
-
|
|
34
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
34
35
|
const showError = errorMessage.length > 0
|
|
35
36
|
const containerClassName = `${styles.container} ${defaultContainerClassName} `
|
|
36
37
|
let inputClassName = `${commonStyles.fullWidth} ${styles.select} ${inputTextClassName}`
|
|
@@ -165,7 +166,7 @@ function Select ({
|
|
|
165
166
|
</div>
|
|
166
167
|
</div>
|
|
167
168
|
{showOptions && !showError && renderOptions()}
|
|
168
|
-
{showError && <span className={
|
|
169
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
169
170
|
</div>
|
|
170
171
|
)
|
|
171
172
|
}
|
|
@@ -250,7 +251,15 @@ Select.propTypes = {
|
|
|
250
251
|
/**
|
|
251
252
|
* inputTextClassName
|
|
252
253
|
*/
|
|
253
|
-
inputTextClassName: PropTypes.string
|
|
254
|
+
inputTextClassName: PropTypes.string,
|
|
255
|
+
/**
|
|
256
|
+
* errorMessage
|
|
257
|
+
*/
|
|
258
|
+
errorMessage: PropTypes.string,
|
|
259
|
+
/**
|
|
260
|
+
* errorMessageTextClassName
|
|
261
|
+
*/
|
|
262
|
+
errorMessageTextClassName: PropTypes.string
|
|
254
263
|
}
|
|
255
264
|
|
|
256
265
|
Select.defaultProps = {
|
|
@@ -265,6 +274,7 @@ Select.defaultProps = {
|
|
|
265
274
|
borderColor: MAIN_GREEN,
|
|
266
275
|
borderListColor: '',
|
|
267
276
|
errorMessage: '',
|
|
277
|
+
errorMessageTextClassName: '',
|
|
268
278
|
onSelect: () => {},
|
|
269
279
|
disabled: false,
|
|
270
280
|
mainColor: MAIN_DARK_BLUE,
|
|
@@ -17,6 +17,7 @@ function SelectWithInput ({
|
|
|
17
17
|
borderColor,
|
|
18
18
|
borderListColor,
|
|
19
19
|
errorMessage,
|
|
20
|
+
errorMessageTextClassName,
|
|
20
21
|
onChange,
|
|
21
22
|
onSelect,
|
|
22
23
|
onClear,
|
|
@@ -32,7 +33,7 @@ function SelectWithInput ({
|
|
|
32
33
|
const [showOptions, setShowOptions] = useState(false)
|
|
33
34
|
const [isSelected, setIsSelected] = useState(false)
|
|
34
35
|
const [isOnFocus, setIsOnFocus] = useState(false)
|
|
35
|
-
|
|
36
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
36
37
|
const showError = errorMessage.length > 0
|
|
37
38
|
const containerClassName = `${styles.container} ${defaultContainerClassName} `
|
|
38
39
|
let inputClassName = `${commonStyles.fullWidth} ${styles.select} ${inputTextClassName}`
|
|
@@ -194,7 +195,7 @@ function SelectWithInput ({
|
|
|
194
195
|
</div>
|
|
195
196
|
</div>
|
|
196
197
|
{showOptions && !showError && renderOptions()}
|
|
197
|
-
{showError && <span className={
|
|
198
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
198
199
|
</div>
|
|
199
200
|
)
|
|
200
201
|
}
|
|
@@ -297,7 +298,15 @@ SelectWithInput.propTypes = {
|
|
|
297
298
|
/**
|
|
298
299
|
* inputTextClassName
|
|
299
300
|
*/
|
|
300
|
-
inputTextClassName: PropTypes.string
|
|
301
|
+
inputTextClassName: PropTypes.string,
|
|
302
|
+
/**
|
|
303
|
+
* errorMessage
|
|
304
|
+
*/
|
|
305
|
+
errorMessage: PropTypes.string,
|
|
306
|
+
/**
|
|
307
|
+
* errorMessageTextClassName
|
|
308
|
+
*/
|
|
309
|
+
errorMessageTextClassName: PropTypes.string
|
|
301
310
|
}
|
|
302
311
|
|
|
303
312
|
SelectWithInput.defaultProps = {
|
|
@@ -312,6 +321,7 @@ SelectWithInput.defaultProps = {
|
|
|
312
321
|
borderColor: MAIN_GREEN,
|
|
313
322
|
borderListColor: '',
|
|
314
323
|
errorMessage: '',
|
|
324
|
+
errorMessageTextClassName: '',
|
|
315
325
|
onChange: () => {},
|
|
316
326
|
onSelect: () => {},
|
|
317
327
|
onClear: () => {},
|
|
@@ -6,9 +6,22 @@ import commonStyles from '../Common.module.css'
|
|
|
6
6
|
import PlatformaticIcon from '../PlatformaticIcon'
|
|
7
7
|
import { MAIN_DARK_BLUE, MAIN_GREEN } from '../constants'
|
|
8
8
|
|
|
9
|
-
function TextArea ({
|
|
9
|
+
function TextArea ({
|
|
10
|
+
placeholder,
|
|
11
|
+
value,
|
|
12
|
+
name,
|
|
13
|
+
borderColor,
|
|
14
|
+
errorMessage,
|
|
15
|
+
errorMessageTextClassName,
|
|
16
|
+
onChange,
|
|
17
|
+
disabled,
|
|
18
|
+
afterIcon,
|
|
19
|
+
rows,
|
|
20
|
+
cols
|
|
21
|
+
}) {
|
|
10
22
|
let className = styles.textAreaContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`]
|
|
11
23
|
const showError = errorMessage.length > 0
|
|
24
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
12
25
|
if (showError) className += ' ' + commonStyles['bordered--error-red']
|
|
13
26
|
if (disabled) className += ' ' + commonStyles['apply-opacity-30']
|
|
14
27
|
const textAreaClassName = `${commonStyles.fullWidth} ${styles.textarea}`
|
|
@@ -19,7 +32,7 @@ function TextArea ({ placeholder, value, name, borderColor, errorMessage, onChan
|
|
|
19
32
|
<textarea name={name} className={textAreaClassName} onChange={onChange} disabled={disabled} placeholder={placeholder} rows={rows} cols={cols} value={value} />
|
|
20
33
|
{afterIcon && <div className={styles.afterIcon}><PlatformaticIcon iconName={afterIcon.iconName} color={afterIcon.color} data-testid='after-icon' onClick={null} /></div>}
|
|
21
34
|
</div>
|
|
22
|
-
{showError && <span className={
|
|
35
|
+
{showError && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
23
36
|
</div>
|
|
24
37
|
)
|
|
25
38
|
}
|
|
@@ -64,7 +77,15 @@ TextArea.propTypes = {
|
|
|
64
77
|
/**
|
|
65
78
|
* cols
|
|
66
79
|
*/
|
|
67
|
-
cols: PropTypes.number
|
|
80
|
+
cols: PropTypes.number,
|
|
81
|
+
/**
|
|
82
|
+
* errorMessage
|
|
83
|
+
*/
|
|
84
|
+
errorMessage: PropTypes.string,
|
|
85
|
+
/**
|
|
86
|
+
* errorMessageTextClassName
|
|
87
|
+
*/
|
|
88
|
+
errorMessageTextClassName: PropTypes.string
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
TextArea.defaultProps = {
|
|
@@ -73,6 +94,7 @@ TextArea.defaultProps = {
|
|
|
73
94
|
name: '',
|
|
74
95
|
borderColor: MAIN_DARK_BLUE,
|
|
75
96
|
errorMessage: '',
|
|
97
|
+
errorMessageTextClassName: '',
|
|
76
98
|
onChange: () => {},
|
|
77
99
|
disabled: false,
|
|
78
100
|
afterIcon: null,
|
|
@@ -4,10 +4,21 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import styles from './ToggleSwitch.module.css'
|
|
5
5
|
import commonStyles from '../Common.module.css'
|
|
6
6
|
|
|
7
|
-
function ToggleSwitch ({
|
|
7
|
+
function ToggleSwitch ({
|
|
8
|
+
name,
|
|
9
|
+
label,
|
|
10
|
+
labelClassName,
|
|
11
|
+
errorMessage,
|
|
12
|
+
errorMessageTextClassName,
|
|
13
|
+
onChange,
|
|
14
|
+
checked,
|
|
15
|
+
disabled
|
|
16
|
+
}) {
|
|
8
17
|
let className = `${styles.switch} `
|
|
9
18
|
if (disabled) className += styles.disabled
|
|
10
19
|
const styleLabel = labelClassName || styles.defaultLabel
|
|
20
|
+
const errorMessageClassName = errorMessageTextClassName || commonStyles['error-message']
|
|
21
|
+
|
|
11
22
|
return (
|
|
12
23
|
<>
|
|
13
24
|
<div className={styles.container}>
|
|
@@ -17,7 +28,7 @@ function ToggleSwitch ({ name, label, labelClassName, errorMessage, onChange, ch
|
|
|
17
28
|
</label>
|
|
18
29
|
<span className={styleLabel}>{label}</span>
|
|
19
30
|
</div>
|
|
20
|
-
{errorMessage.length > 0 && <span className={
|
|
31
|
+
{errorMessage.length > 0 && <span className={errorMessageClassName}>{errorMessage}</span>}
|
|
21
32
|
</>
|
|
22
33
|
)
|
|
23
34
|
}
|
|
@@ -35,6 +46,10 @@ ToggleSwitch.propTypes = {
|
|
|
35
46
|
* errorMessage
|
|
36
47
|
*/
|
|
37
48
|
errorMessage: PropTypes.string,
|
|
49
|
+
/**
|
|
50
|
+
* errorMessageTextClassName
|
|
51
|
+
*/
|
|
52
|
+
errorMessageTextClassName: PropTypes.string,
|
|
38
53
|
/**
|
|
39
54
|
* checked
|
|
40
55
|
*/
|
|
@@ -58,6 +73,7 @@ ToggleSwitch.defaultProps = {
|
|
|
58
73
|
name: '',
|
|
59
74
|
label: '',
|
|
60
75
|
errorMessage: '',
|
|
76
|
+
errorMessageTextClassName: '',
|
|
61
77
|
checked: false,
|
|
62
78
|
disabled: false,
|
|
63
79
|
onChange: () => {},
|
|
@@ -4,7 +4,7 @@ import Button from '../components/Button'
|
|
|
4
4
|
import BorderedBox from '../components/BorderedBox'
|
|
5
5
|
import DropDown from '../components/DropDown'
|
|
6
6
|
import HorizontalSeparator from '../components/HorizontalSeparator'
|
|
7
|
-
import { FULL_WIDTH, MAIN_DARK_BLUE, MAIN_GREEN, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT, MODAL_LAYOUTS, MODAL_SIZES } from '../components/constants'
|
|
7
|
+
import { FULL_WIDTH, MAIN_DARK_BLUE, MAIN_GREEN, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT, MODAL_LAYOUTS, MODAL_POPUP_V2, MODAL_SIZES } from '../components/constants'
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Platformatic/Modal',
|
|
10
10
|
component: Modal,
|
|
@@ -107,3 +107,54 @@ FullscreenLayoutLight.args = {
|
|
|
107
107
|
size: FULL_WIDTH,
|
|
108
108
|
layout: MODAL_FULL_LIGHT
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
const NestedModalsTemplate = () => {
|
|
112
|
+
const [isOpen1, setIsOpen1] = useState(false)
|
|
113
|
+
const [isOpen2, setIsOpen2] = useState(false)
|
|
114
|
+
const [isOpen3, setIsOpen3] = useState(false)
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<main style={{ height: '1440px', overflow: 'scroll' }}>
|
|
118
|
+
<Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen1(true)} label='Open 1st Modal' />
|
|
119
|
+
{isOpen1 && (
|
|
120
|
+
<Modal
|
|
121
|
+
setIsOpen={setIsOpen1}
|
|
122
|
+
title='Fist One'
|
|
123
|
+
layout={MODAL_POPUP_V2}
|
|
124
|
+
>
|
|
125
|
+
<p style={{ color: 'white' }}>This Is the first</p>
|
|
126
|
+
<Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen2(true)} label='Open 2nd Modal' />
|
|
127
|
+
{isOpen2 && (
|
|
128
|
+
<Modal
|
|
129
|
+
setIsOpen={setIsOpen2}
|
|
130
|
+
title='Second One'
|
|
131
|
+
layout={MODAL_POPUP_V2}
|
|
132
|
+
>
|
|
133
|
+
<p style={{ color: 'white' }}>This Is the second</p>
|
|
134
|
+
<Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen3(true)} label='Open 3rd Modal' />
|
|
135
|
+
{isOpen3 && (
|
|
136
|
+
<Modal
|
|
137
|
+
setIsOpen={setIsOpen3}
|
|
138
|
+
title='Third One'
|
|
139
|
+
layout={MODAL_POPUP_V2}
|
|
140
|
+
>
|
|
141
|
+
<p style={{ color: 'white' }}>This Is the third</p>
|
|
142
|
+
</Modal>
|
|
143
|
+
)}
|
|
144
|
+
</Modal>
|
|
145
|
+
)}
|
|
146
|
+
</Modal>
|
|
147
|
+
)}
|
|
148
|
+
</main>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const NestedModals = NestedModalsTemplate.bind({})
|
|
153
|
+
NestedModals.args = {}
|
|
154
|
+
|
|
155
|
+
export const Permanent = Template.bind({})
|
|
156
|
+
Permanent.args = {
|
|
157
|
+
title: 'Permanent modal',
|
|
158
|
+
text: 'Close clicking on Cancel or X or Esc',
|
|
159
|
+
permanent: true
|
|
160
|
+
}
|