@panneau/element-modal 3.0.68 → 3.0.70
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/es/index.js +3 -16
- package/lib/index.js +2 -15
- package/package.json +2 -2
package/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import React, { useMemo, useEffect,
|
|
4
|
+
import React, { useMemo, useEffect, useRef } from 'react';
|
|
5
5
|
import { getDisplayName } from '@panneau/core/utils';
|
|
6
6
|
import ReactDOM from 'react-dom';
|
|
7
7
|
import { useModal } from '@panneau/core/contexts';
|
|
@@ -57,22 +57,19 @@ var propTypes$1 = {
|
|
|
57
57
|
id: PropTypes.string,
|
|
58
58
|
title: PropTypes.string,
|
|
59
59
|
position: PropTypes.oneOf(['center', 'top']),
|
|
60
|
-
onClose: PropTypes.func,
|
|
61
60
|
children: PropTypes.node
|
|
62
61
|
};
|
|
63
62
|
var defaultProps$1 = {
|
|
64
63
|
id: null,
|
|
65
64
|
title: null,
|
|
66
65
|
position: 'center',
|
|
67
|
-
onClose: null,
|
|
68
66
|
children: null
|
|
69
67
|
};
|
|
70
68
|
var Modal = function Modal(_ref) {
|
|
71
69
|
var id = _ref.id,
|
|
72
70
|
children = _ref.children,
|
|
73
71
|
position = _ref.position,
|
|
74
|
-
title = _ref.title
|
|
75
|
-
onClose = _ref.onClose;
|
|
72
|
+
title = _ref.title;
|
|
76
73
|
var name = getDisplayName(children);
|
|
77
74
|
var finalId = useMemo(function () {
|
|
78
75
|
return id || name || 'Modal';
|
|
@@ -82,22 +79,12 @@ var Modal = function Modal(_ref) {
|
|
|
82
79
|
title: title
|
|
83
80
|
};
|
|
84
81
|
}, [title]);
|
|
85
|
-
var onClick = useCallback(function () {
|
|
86
|
-
if (onClose !== null) {
|
|
87
|
-
onClose();
|
|
88
|
-
}
|
|
89
|
-
}, [onClose]);
|
|
90
82
|
return /*#__PURE__*/React.createElement(ModalPortal$1, {
|
|
91
83
|
id: finalId,
|
|
92
84
|
data: data
|
|
93
85
|
}, /*#__PURE__*/React.createElement("div", {
|
|
94
86
|
className: classNames([styles.modal, _defineProperty({}, styles[position], position !== null)])
|
|
95
|
-
},
|
|
96
|
-
type: "button",
|
|
97
|
-
className: classNames(['modal', 'fade', 'show', 'd-block', styles.inner, styles.button]),
|
|
98
|
-
tabIndex: "-1",
|
|
99
|
-
onClick: onClick
|
|
100
|
-
}, children) : /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
101
88
|
className: classNames(['modal', 'fade', 'show', 'd-block', styles.inner]),
|
|
102
89
|
tabIndex: "-1"
|
|
103
90
|
}, children)));
|
package/lib/index.js
CHANGED
|
@@ -69,22 +69,19 @@ var propTypes$1 = {
|
|
|
69
69
|
id: PropTypes__default["default"].string,
|
|
70
70
|
title: PropTypes__default["default"].string,
|
|
71
71
|
position: PropTypes__default["default"].oneOf(['center', 'top']),
|
|
72
|
-
onClose: PropTypes__default["default"].func,
|
|
73
72
|
children: PropTypes__default["default"].node
|
|
74
73
|
};
|
|
75
74
|
var defaultProps$1 = {
|
|
76
75
|
id: null,
|
|
77
76
|
title: null,
|
|
78
77
|
position: 'center',
|
|
79
|
-
onClose: null,
|
|
80
78
|
children: null
|
|
81
79
|
};
|
|
82
80
|
var Modal = function Modal(_ref) {
|
|
83
81
|
var id = _ref.id,
|
|
84
82
|
children = _ref.children,
|
|
85
83
|
position = _ref.position,
|
|
86
|
-
title = _ref.title
|
|
87
|
-
onClose = _ref.onClose;
|
|
84
|
+
title = _ref.title;
|
|
88
85
|
var name = utils.getDisplayName(children);
|
|
89
86
|
var finalId = React.useMemo(function () {
|
|
90
87
|
return id || name || 'Modal';
|
|
@@ -94,22 +91,12 @@ var Modal = function Modal(_ref) {
|
|
|
94
91
|
title: title
|
|
95
92
|
};
|
|
96
93
|
}, [title]);
|
|
97
|
-
var onClick = React.useCallback(function () {
|
|
98
|
-
if (onClose !== null) {
|
|
99
|
-
onClose();
|
|
100
|
-
}
|
|
101
|
-
}, [onClose]);
|
|
102
94
|
return /*#__PURE__*/React__default["default"].createElement(ModalPortal$1, {
|
|
103
95
|
id: finalId,
|
|
104
96
|
data: data
|
|
105
97
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
106
98
|
className: classNames__default["default"]([styles.modal, _defineProperty__default["default"]({}, styles[position], position !== null)])
|
|
107
|
-
},
|
|
108
|
-
type: "button",
|
|
109
|
-
className: classNames__default["default"](['modal', 'fade', 'show', 'd-block', styles.inner, styles.button]),
|
|
110
|
-
tabIndex: "-1",
|
|
111
|
-
onClick: onClick
|
|
112
|
-
}, children) : /*#__PURE__*/React__default["default"].createElement("div", {
|
|
99
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
113
100
|
className: classNames__default["default"](['modal', 'fade', 'show', 'd-block', styles.inner]),
|
|
114
101
|
tabIndex: "-1"
|
|
115
102
|
}, children)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/element-modal",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.70",
|
|
4
4
|
"description": "Modal element",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e60b571a9dfbc4e4ab3709f1dced63039dd3091a"
|
|
60
60
|
}
|