@platformatic/ui-components 0.8.6 → 0.8.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/package.json +1 -1
- package/src/components/Checkbox.module.css +1 -1
- package/src/components/Modal.jsx +9 -3
- package/src/components/Modal.module.css +5 -1
- package/src/components/forms/InputFileUpload.jsx +25 -3
- package/src/components/forms/Select.jsx +25 -3
- package/src/components/forms/ToggleSwitch.module.css +1 -1
- package/src/stories/forms/Select.stories.jsx +2 -1
package/package.json
CHANGED
package/src/components/Modal.jsx
CHANGED
|
@@ -42,13 +42,15 @@ function Modal ({
|
|
|
42
42
|
childrenClassContainer = '',
|
|
43
43
|
modalCloseClassName = '',
|
|
44
44
|
permanent = false,
|
|
45
|
-
showCloseButtonOnTop = true
|
|
45
|
+
showCloseButtonOnTop = true,
|
|
46
|
+
additionalModalClassName = ''
|
|
46
47
|
}) {
|
|
47
48
|
let contentFullscreen
|
|
48
49
|
let titleFullscreen
|
|
49
|
-
let modalClassName = `${styles.modal}`
|
|
50
|
+
let modalClassName = `${styles.modal} `
|
|
50
51
|
modalClassName += ' ' + styles[`modal--${layout}`]
|
|
51
52
|
modalClassName += ' ' + styles[`modal--${size}`]
|
|
53
|
+
modalClassName += ` ${additionalModalClassName || styles.modalDefaultFlex}`
|
|
52
54
|
let buttonFullRoundedClassName
|
|
53
55
|
const blurRef = useRef()
|
|
54
56
|
|
|
@@ -309,7 +311,11 @@ Modal.propTypes = {
|
|
|
309
311
|
/**
|
|
310
312
|
* showCloseButtonOnTop: show button on X
|
|
311
313
|
*/
|
|
312
|
-
showCloseButtonOnTop: PropTypes.bool
|
|
314
|
+
showCloseButtonOnTop: PropTypes.bool,
|
|
315
|
+
/**
|
|
316
|
+
* additionalModalClassName: show button on X
|
|
317
|
+
*/
|
|
318
|
+
additionalModalClassName: PropTypes.string
|
|
313
319
|
}
|
|
314
320
|
|
|
315
321
|
export default Modal
|
|
@@ -25,8 +25,12 @@
|
|
|
25
25
|
.modal {
|
|
26
26
|
@apply p-4 rounded-md mx-auto my-auto max-h-[85vh] overflow-y-auto;
|
|
27
27
|
}
|
|
28
|
+
.modalDefaultFlex {
|
|
29
|
+
@apply flex flex-col gap-y-2;
|
|
30
|
+
}
|
|
28
31
|
.modal--popup-v2 {
|
|
29
|
-
@apply bg-rich-black border border-solid
|
|
32
|
+
@apply bg-rich-black border border-solid;
|
|
33
|
+
border-color: rgba(255, 255, 255, .3);
|
|
30
34
|
}
|
|
31
35
|
.modal--popup {
|
|
32
36
|
@apply bg-light-blue;
|
|
@@ -5,7 +5,7 @@ import styles from './InputFileUpload.module.css'
|
|
|
5
5
|
import commonStyles from '../Common.module.css'
|
|
6
6
|
import PlatformaticIcon from '../PlatformaticIcon'
|
|
7
7
|
import Button from '../Button'
|
|
8
|
-
import { ERROR_RED, MAIN_DARK_BLUE, MAIN_GREEN, RICH_BLACK, TRANSPARENT, WHITE } from '../constants'
|
|
8
|
+
import { ACTIVE_AND_INACTIVE_STATUS, ERROR_RED, MAIN_DARK_BLUE, MAIN_GREEN, RICH_BLACK, TRANSPARENT, WHITE } from '../constants'
|
|
9
9
|
|
|
10
10
|
function InputFileUpload ({
|
|
11
11
|
idInputFile = 'fileUpload',
|
|
@@ -19,12 +19,13 @@ function InputFileUpload ({
|
|
|
19
19
|
afterIcon = null,
|
|
20
20
|
backgroundColor = WHITE,
|
|
21
21
|
inputTextClassName = '',
|
|
22
|
-
detailTextClassName = '',
|
|
23
22
|
verticalPaddingClassName = '',
|
|
24
23
|
dataAttrName = '',
|
|
25
24
|
dataAttrValue = '',
|
|
26
25
|
readOnly = false,
|
|
27
26
|
removeFileButton = {},
|
|
27
|
+
showDetailButton = true,
|
|
28
|
+
detailFileButton = {},
|
|
28
29
|
onClickDetail = () => {},
|
|
29
30
|
acceptFiles = '*'
|
|
30
31
|
}) {
|
|
@@ -108,7 +109,20 @@ function InputFileUpload ({
|
|
|
108
109
|
>
|
|
109
110
|
{file !== null ? file.name : <span className={styles.inputPlaceholderClassName}>{inputPlaceholder}</span>}
|
|
110
111
|
</label>
|
|
111
|
-
{file !== null &&
|
|
112
|
+
{file !== null && showDetailButton && (
|
|
113
|
+
<div className={styles.afterInputDetail}>
|
|
114
|
+
<Button
|
|
115
|
+
textClass={detailFileButton?.textClass ?? ''}
|
|
116
|
+
paddingClass={detailFileButton?.paddingClass ?? ''}
|
|
117
|
+
label={detailFileButton?.label ?? 'Details'}
|
|
118
|
+
color={detailFileButton?.color ?? WHITE}
|
|
119
|
+
type='button'
|
|
120
|
+
onClick={() => onClickDetail()}
|
|
121
|
+
bordered={false}
|
|
122
|
+
hoverEffect={ACTIVE_AND_INACTIVE_STATUS}
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
112
126
|
</div>
|
|
113
127
|
{file !== null && (
|
|
114
128
|
<Button
|
|
@@ -211,6 +225,14 @@ InputFileUpload.propTypes = {
|
|
|
211
225
|
* removeFileButton
|
|
212
226
|
*/
|
|
213
227
|
removeFileButton: PropTypes.object,
|
|
228
|
+
/**
|
|
229
|
+
* showDetailButton
|
|
230
|
+
*/
|
|
231
|
+
showDetailButton: PropTypes.bool,
|
|
232
|
+
/**
|
|
233
|
+
* detailFileButton
|
|
234
|
+
*/
|
|
235
|
+
detailFileButton: PropTypes.object,
|
|
214
236
|
/**
|
|
215
237
|
* onClickDetail
|
|
216
238
|
*/
|
|
@@ -28,8 +28,10 @@ function Select ({
|
|
|
28
28
|
backgroundColor = WHITE,
|
|
29
29
|
inputTextClassName = '',
|
|
30
30
|
beforeIcon = {},
|
|
31
|
-
paddingClass = ''
|
|
31
|
+
paddingClass = '',
|
|
32
|
+
handleClickOutside = false
|
|
32
33
|
}) {
|
|
34
|
+
const wrapperRef = useRef(null)
|
|
33
35
|
const inputRef = useRef()
|
|
34
36
|
const [showOptions, setShowOptions] = useState(false)
|
|
35
37
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -105,6 +107,22 @@ function Select ({
|
|
|
105
107
|
}
|
|
106
108
|
}, [value])
|
|
107
109
|
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
if (showOptions && handleClickOutside) {
|
|
112
|
+
function innerHandleClickOutside (event) {
|
|
113
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
114
|
+
setShowOptions(false)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Bind the event listener
|
|
118
|
+
document.addEventListener('mousedown', innerHandleClickOutside)
|
|
119
|
+
return () => {
|
|
120
|
+
// Unbind the event listener on clean up
|
|
121
|
+
document.removeEventListener('mousedown', innerHandleClickOutside)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, [handleClickOutside, showOptions])
|
|
125
|
+
|
|
108
126
|
useEffect(() => {
|
|
109
127
|
if (disabled) {
|
|
110
128
|
const className = normalClassName() + ' ' + commonStyles['apply-opacity-30']
|
|
@@ -170,7 +188,7 @@ function Select ({
|
|
|
170
188
|
}
|
|
171
189
|
|
|
172
190
|
return (
|
|
173
|
-
<div className={containerClassName} {...dataProps}>
|
|
191
|
+
<div className={containerClassName} {...dataProps} ref={wrapperRef}>
|
|
174
192
|
<div className={wrapperClassName}>
|
|
175
193
|
{beforeIcon?.iconName && getBeforeIcon()}
|
|
176
194
|
<input type='text' name={name} value={value} className={inputClassName} ref={inputRef} disabled={disabled} placeholder={placeholder} onFocus={() => handleFocus()} onBlur={(e) => handleBlur(e)} readOnly />
|
|
@@ -285,7 +303,11 @@ Select.propTypes = {
|
|
|
285
303
|
/**
|
|
286
304
|
* paddingClass
|
|
287
305
|
*/
|
|
288
|
-
paddingClass: PropTypes.string
|
|
306
|
+
paddingClass: PropTypes.string,
|
|
307
|
+
/**
|
|
308
|
+
* handleClickOutside
|
|
309
|
+
*/
|
|
310
|
+
handleClickOutside: PropTypes.bool
|
|
289
311
|
}
|
|
290
312
|
|
|
291
313
|
export default Select
|