@panneau/element-modal 3.0.222 → 3.0.224

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.
Files changed (2) hide show
  1. package/package.json +10 -7
  2. package/lib/index.js +0 -153
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/element-modal",
3
- "version": "3.0.222",
3
+ "version": "3.0.224",
4
4
  "description": "Modal element",
5
5
  "keywords": [
6
6
  "javascript"
@@ -25,8 +25,11 @@
25
25
  }
26
26
  ],
27
27
  "license": "ISC",
28
- "main": "lib/index.js",
28
+ "type": "module",
29
29
  "module": "es/index.js",
30
+ "exports": {
31
+ ".": "./es/index.js"
32
+ },
30
33
  "files": [
31
34
  "lib",
32
35
  "es",
@@ -46,10 +49,10 @@
46
49
  },
47
50
  "dependencies": {
48
51
  "@babel/runtime": "^7.12.5",
49
- "@panneau/core": "^3.0.222",
50
- "@panneau/element-button": "^3.0.222",
51
- "@panneau/element-icon": "^3.0.222",
52
- "@panneau/element-label": "^3.0.222",
52
+ "@panneau/core": "^3.0.224",
53
+ "@panneau/element-button": "^3.0.224",
54
+ "@panneau/element-icon": "^3.0.224",
55
+ "@panneau/element-label": "^3.0.224",
53
56
  "classnames": "^2.5.1",
54
57
  "prop-types": "^15.7.2",
55
58
  "react-intl": "^5.15.8||^6.0.0"
@@ -57,5 +60,5 @@
57
60
  "publishConfig": {
58
61
  "access": "public"
59
62
  },
60
- "gitHead": "1d7f6c2943965c2c26fb6ce1d8f3c85eb88b2146"
63
+ "gitHead": "c95bd465867c4c7d112bf0ed66036574cc05c627"
61
64
  }
package/lib/index.js DELETED
@@ -1,153 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
6
- var classNames = require('classnames');
7
- var PropTypes = require('prop-types');
8
- var React = require('react');
9
- var utils = require('@panneau/core/utils');
10
- var ReactDOM = require('react-dom');
11
- var contexts = require('@panneau/core/contexts');
12
- var hooks = require('@panneau/core/hooks');
13
-
14
- /* eslint-disable react/no-array-index-key, react/jsx-props-no-spreading */
15
-
16
- // import ElementPortal from '@panneau/element-portal';
17
-
18
- var propTypes$2 = {
19
- id: PropTypes.string,
20
- data: PropTypes.object,
21
- // eslint-disable-line react/forbid-prop-types
22
- children: PropTypes.node
23
- };
24
- var defaultProps$2 = {
25
- id: null,
26
- data: null,
27
- children: null
28
- };
29
- var ModalPortal = function ModalPortal(_ref) {
30
- var id = _ref.id,
31
- data = _ref.data,
32
- children = _ref.children;
33
- var _useModal = contexts.useModal(),
34
- _useModal$container = _useModal.container,
35
- container = _useModal$container === void 0 ? null : _useModal$container,
36
- _useModal$register = _useModal.register,
37
- register = _useModal$register === void 0 ? null : _useModal$register,
38
- _useModal$unregister = _useModal.unregister,
39
- unregister = _useModal$unregister === void 0 ? null : _useModal$unregister;
40
- var finalId = React.useMemo(function () {
41
- return id !== null ? id : "modal-".concat(new Date().getTime());
42
- }, [id]);
43
- React.useEffect(function () {
44
- if (register !== null) {
45
- register(finalId, data);
46
- }
47
- return function () {
48
- if (unregister !== null) {
49
- unregister(finalId);
50
- }
51
- };
52
- }, [finalId, data]);
53
- return container !== null ? /*#__PURE__*/ReactDOM.createPortal(children, container) : null;
54
- };
55
- ModalPortal.propTypes = propTypes$2;
56
- ModalPortal.defaultProps = defaultProps$2;
57
- var ModalPortal$1 = ModalPortal;
58
-
59
- var styles = {"modal":"panneau-element-modal-modal","center":"panneau-element-modal-center","inner":"panneau-element-modal-inner","top":"panneau-element-modal-top","button":"panneau-element-modal-button","modalsContainer":"panneau-element-modal-modalsContainer","modals":"panneau-element-modal-modals","hasModals":"panneau-element-modal-hasModals"};
60
-
61
- var propTypes$1 = {
62
- id: PropTypes.string,
63
- title: PropTypes.string,
64
- position: PropTypes.oneOf(['center', 'top']),
65
- children: PropTypes.node
66
- };
67
- var defaultProps$1 = {
68
- id: null,
69
- title: null,
70
- position: 'center',
71
- children: null
72
- };
73
- var Modal = function Modal(_ref) {
74
- var id = _ref.id,
75
- children = _ref.children,
76
- position = _ref.position,
77
- title = _ref.title;
78
- var name = utils.getDisplayName(children);
79
- var finalId = React.useMemo(function () {
80
- return id || name || 'Modal';
81
- }, [id, name]);
82
- var data = React.useMemo(function () {
83
- return {
84
- title: title
85
- };
86
- }, [title]);
87
- return /*#__PURE__*/React.createElement(ModalPortal$1, {
88
- id: finalId,
89
- data: data
90
- }, /*#__PURE__*/React.createElement("div", {
91
- className: classNames([styles.modal, _defineProperty({}, styles[position], position !== null)])
92
- }, /*#__PURE__*/React.createElement("div", {
93
- className: classNames(['modal', 'fade', 'show', 'd-block', styles.inner]),
94
- tabIndex: "-1"
95
- }, children)));
96
- };
97
- Modal.propTypes = propTypes$1;
98
- Modal.defaultProps = defaultProps$1;
99
- var Modal$1 = Modal;
100
-
101
- var propTypes = {
102
- theme: PropTypes.string,
103
- className: PropTypes.string
104
- };
105
- var defaultProps = {
106
- theme: null,
107
- className: null
108
- };
109
- var Modals = function Modals(_ref) {
110
- var theme = _ref.theme,
111
- className = _ref.className;
112
- var _useModal = contexts.useModal(),
113
- _useModal$modals = _useModal.modals,
114
- modals = _useModal$modals === void 0 ? null : _useModal$modals,
115
- _useModal$setContaine = _useModal.setContainer,
116
- setContainer = _useModal$setContaine === void 0 ? null : _useModal$setContaine,
117
- _useModal$closeLastMo = _useModal.closeLastModal,
118
- closeLastModal = _useModal$closeLastMo === void 0 ? null : _useModal$closeLastMo;
119
- var containerRef = React.useRef(null);
120
- React.useEffect(function () {
121
- if (setContainer !== null) {
122
- setContainer(containerRef.current);
123
- }
124
- }, [setContainer]);
125
- React.useEffect(function () {
126
- if (document.body) {
127
- if (modals !== null && modals.length > 0) {
128
- document.body.className = 'modal-open';
129
- } else {
130
- document.body.className = '';
131
- }
132
- }
133
- }, [modals]);
134
- hooks.useKeyboardKeys(_defineProperty({}, hooks.KEYCODES.ESCAPE, closeLastModal));
135
- return /*#__PURE__*/React.createElement("div", {
136
- className: classNames([styles.modalsContainer, _defineProperty({}, className, className)]),
137
- "data-bs-theme": theme !== null ? theme : null,
138
- style: {
139
- color: theme === 'dark' ? '#FFF' : null
140
- }
141
- }, /*#__PURE__*/React.createElement("div", {
142
- className: classNames([styles.modals, _defineProperty({}, styles.hasModals, modals !== null && modals.length > 0)]),
143
- ref: containerRef
144
- }));
145
- };
146
- Modals.propTypes = propTypes;
147
- Modals.defaultProps = defaultProps;
148
- var Modals$1 = Modals;
149
-
150
- exports.Modal = Modal$1;
151
- exports.ModalPortal = ModalPortal$1;
152
- exports.Modals = Modals$1;
153
- exports.default = Modal$1;