@platformatic/ui-components 0.1.147 → 0.1.148

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.1.147",
4
+ "version": "0.1.148",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -1,5 +1,5 @@
1
1
  'use strict'
2
- import React from 'react'
2
+ import React, { useRef } from 'react'
3
3
  import PropTypes from 'prop-types'
4
4
  import ButtonFullRounded from './ButtonFullRounded'
5
5
  import useEscapeKey from '../hooks/useEscapeKey'
@@ -41,8 +41,8 @@ function Modal ({
41
41
  let modalClassName = `${styles.modal}`
42
42
  modalClassName += ' ' + styles[`modal--${layout}`]
43
43
  modalClassName += ' ' + styles[`modal--${size}`]
44
-
45
44
  let buttonFullRoundedClassName
45
+ const blurRef = useRef()
46
46
 
47
47
  const headerClassName = styles[`header--${layout}`]
48
48
  let modalCoverClassName = `${styles.container} ${styles.fullscreen} `
@@ -66,7 +66,6 @@ function Modal ({
66
66
  default:
67
67
  break
68
68
  }
69
-
70
69
  useEscapeKey(() => setIsOpen(false))
71
70
  let whichModal = <></>
72
71
 
@@ -80,10 +79,17 @@ function Modal ({
80
79
  return <Logo width={100} heigth={80} color={MAIN_DARK_BLUE} />
81
80
  }
82
81
 
82
+ function closeModal (event) {
83
+ if (event.target === blurRef.current) {
84
+ setIsOpen(false)
85
+ }
86
+ }
87
+
83
88
  switch (layout) {
84
89
  case MODAL_POPUP_V2:
85
90
  whichModal = (
86
- <div className={`${styles['blur-fixed']}`} onClick={() => setIsOpen(false)}>
91
+
92
+ <div className={`${styles['blur-fixed']}`} onClick={(event) => closeModal(event)} ref={blurRef}>
87
93
  <div className={styles.content}>
88
94
  <div className={modalClassName}>
89
95
  <div className={headerClassName}>
@@ -96,6 +102,7 @@ function Modal ({
96
102
  </div>
97
103
  </div>
98
104
  </div>
105
+
99
106
  )
100
107
  break
101
108
  case MODAL_POPUP: