@panneau/modals 1.0.1-alpha.0 → 1.0.3-alpha.0
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/assets/css/styles.css +2 -0
- package/es/index.js +147 -3
- package/lib/index.js +160 -11
- package/package.json +33 -31
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.panneau-modals-modal-container{display:-webkit-flex;display:-ms-flexbox;display:flex;height:100%;left:0;overflow-y:auto;position:absolute;top:0;width:100%}.panneau-modals-modal-container.panneau-modals-modal-center>.panneau-modals-modal-inner{margin:auto}.panneau-modals-modal-container.panneau-modals-modal-top>.panneau-modals-modal-inner{margin:0 auto;padding:1.75rem 0}
|
|
2
|
+
.panneau-modals-container{position:static}.panneau-modals-modals.panneau-modals-hasModals{background-color:rgba(0,0,0,.2);bottom:0;left:0;position:fixed;right:0;top:0;z-index:1000}
|
package/es/index.js
CHANGED
|
@@ -1,3 +1,147 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, { useMemo, useRef, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { ComponentsProvider, MODALS_NAMESPACE, useModals, withModals } from '@panneau/core/contexts';
|
|
4
|
+
import DialogModal from '@panneau/modal-dialog';
|
|
5
|
+
import UploadModal from '@panneau/modal-upload';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import { getDisplayName } from '@panneau/core/utils';
|
|
9
|
+
import ElementPortal from '@panneau/element-portal';
|
|
10
|
+
import { PropTypes as PropTypes$1 } from '@panneau/core';
|
|
11
|
+
|
|
12
|
+
var modals = {
|
|
13
|
+
DialogModal: DialogModal,
|
|
14
|
+
UploadModal: UploadModal
|
|
15
|
+
};
|
|
16
|
+
Object.keys(modals).map(function (name) {
|
|
17
|
+
return modals[name];
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
21
|
+
var propTypes$3 = {
|
|
22
|
+
children: PropTypes.node
|
|
23
|
+
};
|
|
24
|
+
var defaultProps$3 = {
|
|
25
|
+
children: null
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var ModalsProvider = function ModalsProvider(props) {
|
|
29
|
+
return /*#__PURE__*/React.createElement(ComponentsProvider, Object.assign({
|
|
30
|
+
namespace: MODALS_NAMESPACE,
|
|
31
|
+
components: modals
|
|
32
|
+
}, props));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
ModalsProvider.propTypes = propTypes$3;
|
|
36
|
+
ModalsProvider.defaultProps = defaultProps$3;
|
|
37
|
+
|
|
38
|
+
/* eslint-disable react/no-array-index-key, react/jsx-props-no-spreading */
|
|
39
|
+
var propTypes$2 = {
|
|
40
|
+
id: PropTypes.string,
|
|
41
|
+
data: PropTypes.object,
|
|
42
|
+
// eslint-disable-line react/forbid-prop-types
|
|
43
|
+
children: PropTypes.node
|
|
44
|
+
};
|
|
45
|
+
var defaultProps$2 = {
|
|
46
|
+
id: null,
|
|
47
|
+
data: null,
|
|
48
|
+
children: null
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var ModalPortal = function ModalPortal(_ref) {
|
|
52
|
+
var id = _ref.id,
|
|
53
|
+
data = _ref.data,
|
|
54
|
+
children = _ref.children;
|
|
55
|
+
|
|
56
|
+
var _useModals = useModals(),
|
|
57
|
+
container = _useModals.container,
|
|
58
|
+
_useModals$register = _useModals.register,
|
|
59
|
+
register = _useModals$register === void 0 ? null : _useModals$register,
|
|
60
|
+
_useModals$unregister = _useModals.unregister,
|
|
61
|
+
unregister = _useModals$unregister === void 0 ? null : _useModals$unregister;
|
|
62
|
+
|
|
63
|
+
return /*#__PURE__*/React.createElement(ElementPortal, {
|
|
64
|
+
id: id,
|
|
65
|
+
data: data,
|
|
66
|
+
container: container,
|
|
67
|
+
register: register,
|
|
68
|
+
unregister: unregister
|
|
69
|
+
}, children);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
ModalPortal.propTypes = propTypes$2;
|
|
73
|
+
ModalPortal.defaultProps = defaultProps$2;
|
|
74
|
+
|
|
75
|
+
var styles$1 = {"container":"panneau-modals-modal-container","center":"panneau-modals-modal-center","inner":"panneau-modals-modal-inner","top":"panneau-modals-modal-top"};
|
|
76
|
+
|
|
77
|
+
var propTypes$1 = {
|
|
78
|
+
id: PropTypes.string,
|
|
79
|
+
title: PropTypes.string,
|
|
80
|
+
position: PropTypes.oneOf(['center', 'top']),
|
|
81
|
+
children: PropTypes.node
|
|
82
|
+
};
|
|
83
|
+
var defaultProps$1 = {
|
|
84
|
+
id: null,
|
|
85
|
+
title: null,
|
|
86
|
+
position: 'center',
|
|
87
|
+
children: null
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
var Modal = function Modal(_ref) {
|
|
91
|
+
var id = _ref.id,
|
|
92
|
+
children = _ref.children,
|
|
93
|
+
position = _ref.position,
|
|
94
|
+
title = _ref.title;
|
|
95
|
+
var finalId = useMemo(function () {
|
|
96
|
+
return id || getDisplayName(children.type);
|
|
97
|
+
}, [id, children.type]);
|
|
98
|
+
var data = useMemo(function () {
|
|
99
|
+
return {
|
|
100
|
+
title: title
|
|
101
|
+
};
|
|
102
|
+
}, [title]);
|
|
103
|
+
return /*#__PURE__*/React.createElement(ModalPortal, {
|
|
104
|
+
id: finalId,
|
|
105
|
+
data: data
|
|
106
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: classNames([styles$1.container, _defineProperty({}, styles$1[position], position !== null)])
|
|
108
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: styles$1.inner
|
|
110
|
+
}, children)));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
Modal.propTypes = propTypes$1;
|
|
114
|
+
Modal.defaultProps = defaultProps$1;
|
|
115
|
+
|
|
116
|
+
var styles = {"container":"panneau-modals-container","modals":"panneau-modals-modals","hasModals":"panneau-modals-hasModals"};
|
|
117
|
+
|
|
118
|
+
var propTypes = {
|
|
119
|
+
modals: PropTypes$1.modals.isRequired,
|
|
120
|
+
setModalsContainer: PropTypes.func.isRequired,
|
|
121
|
+
className: PropTypes.string
|
|
122
|
+
};
|
|
123
|
+
var defaultProps = {
|
|
124
|
+
className: null
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var ModalsContainer = function ModalsContainer(_ref) {
|
|
128
|
+
var modals = _ref.modals,
|
|
129
|
+
setModalsContainer = _ref.setModalsContainer,
|
|
130
|
+
className = _ref.className;
|
|
131
|
+
var containerRef = useRef(null);
|
|
132
|
+
useEffect(function () {
|
|
133
|
+
setModalsContainer(containerRef.current);
|
|
134
|
+
}, []);
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
className: classNames([styles.container, _defineProperty({}, className, className)])
|
|
137
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: classNames([styles.modals, _defineProperty({}, styles.hasModals, modals.length > 0)]),
|
|
139
|
+
ref: containerRef
|
|
140
|
+
}));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
ModalsContainer.propTypes = propTypes;
|
|
144
|
+
ModalsContainer.defaultProps = defaultProps;
|
|
145
|
+
var Modals = withModals(ModalsContainer);
|
|
146
|
+
|
|
147
|
+
export { Modal, ModalPortal, Modals, ModalsProvider as default };
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,164 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var PropTypes = require('prop-types');
|
|
7
|
+
var contexts = require('@panneau/core/contexts');
|
|
8
|
+
var DialogModal = require('@panneau/modal-dialog');
|
|
9
|
+
var UploadModal = require('@panneau/modal-upload');
|
|
10
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
+
var classNames = require('classnames');
|
|
12
|
+
var utils = require('@panneau/core/utils');
|
|
13
|
+
var ElementPortal = require('@panneau/element-portal');
|
|
14
|
+
var core = require('@panneau/core');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
20
|
+
var DialogModal__default = /*#__PURE__*/_interopDefaultLegacy(DialogModal);
|
|
21
|
+
var UploadModal__default = /*#__PURE__*/_interopDefaultLegacy(UploadModal);
|
|
22
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
23
|
+
var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
|
|
24
|
+
var ElementPortal__default = /*#__PURE__*/_interopDefaultLegacy(ElementPortal);
|
|
25
|
+
|
|
26
|
+
var modals = {
|
|
27
|
+
DialogModal: DialogModal__default["default"],
|
|
28
|
+
UploadModal: UploadModal__default["default"]
|
|
29
|
+
};
|
|
30
|
+
Object.keys(modals).map(function (name) {
|
|
31
|
+
return modals[name];
|
|
13
32
|
});
|
|
14
33
|
|
|
15
|
-
|
|
34
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
35
|
+
var propTypes$3 = {
|
|
36
|
+
children: PropTypes__default["default"].node
|
|
37
|
+
};
|
|
38
|
+
var defaultProps$3 = {
|
|
39
|
+
children: null
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var ModalsProvider = function ModalsProvider(props) {
|
|
43
|
+
return /*#__PURE__*/React__default["default"].createElement(contexts.ComponentsProvider, Object.assign({
|
|
44
|
+
namespace: contexts.MODALS_NAMESPACE,
|
|
45
|
+
components: modals
|
|
46
|
+
}, props));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ModalsProvider.propTypes = propTypes$3;
|
|
50
|
+
ModalsProvider.defaultProps = defaultProps$3;
|
|
51
|
+
|
|
52
|
+
/* eslint-disable react/no-array-index-key, react/jsx-props-no-spreading */
|
|
53
|
+
var propTypes$2 = {
|
|
54
|
+
id: PropTypes__default["default"].string,
|
|
55
|
+
data: PropTypes__default["default"].object,
|
|
56
|
+
// eslint-disable-line react/forbid-prop-types
|
|
57
|
+
children: PropTypes__default["default"].node
|
|
58
|
+
};
|
|
59
|
+
var defaultProps$2 = {
|
|
60
|
+
id: null,
|
|
61
|
+
data: null,
|
|
62
|
+
children: null
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var ModalPortal = function ModalPortal(_ref) {
|
|
66
|
+
var id = _ref.id,
|
|
67
|
+
data = _ref.data,
|
|
68
|
+
children = _ref.children;
|
|
69
|
+
|
|
70
|
+
var _useModals = contexts.useModals(),
|
|
71
|
+
container = _useModals.container,
|
|
72
|
+
_useModals$register = _useModals.register,
|
|
73
|
+
register = _useModals$register === void 0 ? null : _useModals$register,
|
|
74
|
+
_useModals$unregister = _useModals.unregister,
|
|
75
|
+
unregister = _useModals$unregister === void 0 ? null : _useModals$unregister;
|
|
76
|
+
|
|
77
|
+
return /*#__PURE__*/React__default["default"].createElement(ElementPortal__default["default"], {
|
|
78
|
+
id: id,
|
|
79
|
+
data: data,
|
|
80
|
+
container: container,
|
|
81
|
+
register: register,
|
|
82
|
+
unregister: unregister
|
|
83
|
+
}, children);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
ModalPortal.propTypes = propTypes$2;
|
|
87
|
+
ModalPortal.defaultProps = defaultProps$2;
|
|
88
|
+
|
|
89
|
+
var styles$1 = {"container":"panneau-modals-modal-container","center":"panneau-modals-modal-center","inner":"panneau-modals-modal-inner","top":"panneau-modals-modal-top"};
|
|
90
|
+
|
|
91
|
+
var propTypes$1 = {
|
|
92
|
+
id: PropTypes__default["default"].string,
|
|
93
|
+
title: PropTypes__default["default"].string,
|
|
94
|
+
position: PropTypes__default["default"].oneOf(['center', 'top']),
|
|
95
|
+
children: PropTypes__default["default"].node
|
|
96
|
+
};
|
|
97
|
+
var defaultProps$1 = {
|
|
98
|
+
id: null,
|
|
99
|
+
title: null,
|
|
100
|
+
position: 'center',
|
|
101
|
+
children: null
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
var Modal = function Modal(_ref) {
|
|
105
|
+
var id = _ref.id,
|
|
106
|
+
children = _ref.children,
|
|
107
|
+
position = _ref.position,
|
|
108
|
+
title = _ref.title;
|
|
109
|
+
var finalId = React.useMemo(function () {
|
|
110
|
+
return id || utils.getDisplayName(children.type);
|
|
111
|
+
}, [id, children.type]);
|
|
112
|
+
var data = React.useMemo(function () {
|
|
113
|
+
return {
|
|
114
|
+
title: title
|
|
115
|
+
};
|
|
116
|
+
}, [title]);
|
|
117
|
+
return /*#__PURE__*/React__default["default"].createElement(ModalPortal, {
|
|
118
|
+
id: finalId,
|
|
119
|
+
data: data
|
|
120
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
121
|
+
className: classNames__default["default"]([styles$1.container, _defineProperty__default["default"]({}, styles$1[position], position !== null)])
|
|
122
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
123
|
+
className: styles$1.inner
|
|
124
|
+
}, children)));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
Modal.propTypes = propTypes$1;
|
|
128
|
+
Modal.defaultProps = defaultProps$1;
|
|
129
|
+
|
|
130
|
+
var styles = {"container":"panneau-modals-container","modals":"panneau-modals-modals","hasModals":"panneau-modals-hasModals"};
|
|
131
|
+
|
|
132
|
+
var propTypes = {
|
|
133
|
+
modals: core.PropTypes.modals.isRequired,
|
|
134
|
+
setModalsContainer: PropTypes__default["default"].func.isRequired,
|
|
135
|
+
className: PropTypes__default["default"].string
|
|
136
|
+
};
|
|
137
|
+
var defaultProps = {
|
|
138
|
+
className: null
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
var ModalsContainer = function ModalsContainer(_ref) {
|
|
142
|
+
var modals = _ref.modals,
|
|
143
|
+
setModalsContainer = _ref.setModalsContainer,
|
|
144
|
+
className = _ref.className;
|
|
145
|
+
var containerRef = React.useRef(null);
|
|
146
|
+
React.useEffect(function () {
|
|
147
|
+
setModalsContainer(containerRef.current);
|
|
148
|
+
}, []);
|
|
149
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
150
|
+
className: classNames__default["default"]([styles.container, _defineProperty__default["default"]({}, className, className)])
|
|
151
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
152
|
+
className: classNames__default["default"]([styles.modals, _defineProperty__default["default"]({}, styles.hasModals, modals.length > 0)]),
|
|
153
|
+
ref: containerRef
|
|
154
|
+
}));
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
ModalsContainer.propTypes = propTypes;
|
|
158
|
+
ModalsContainer.defaultProps = defaultProps;
|
|
159
|
+
var Modals = contexts.withModals(ModalsContainer);
|
|
160
|
+
|
|
161
|
+
exports.Modal = Modal;
|
|
162
|
+
exports.ModalPortal = ModalPortal;
|
|
163
|
+
exports.Modals = Modals;
|
|
164
|
+
exports["default"] = ModalsProvider;
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/modals",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.3-alpha.0",
|
|
4
|
+
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"javascript",
|
|
8
|
-
"form",
|
|
9
|
-
"dashboard"
|
|
6
|
+
"javascript"
|
|
10
7
|
],
|
|
11
|
-
"homepage": "https://github.com/folkloreinc/panneau-js
|
|
8
|
+
"homepage": "https://github.com/folkloreinc/panneau-js",
|
|
12
9
|
"repository": {
|
|
13
10
|
"type": "git",
|
|
14
11
|
"url": "git+https://github.com/folkloreinc/panneau-js.git"
|
|
@@ -25,42 +22,47 @@
|
|
|
25
22
|
{
|
|
26
23
|
"name": "Nicolas Roy-Bourdages",
|
|
27
24
|
"email": "nrb@folklore.email"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Julien Carignan",
|
|
28
|
+
"email": "jc@folklore.email"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "Théo Gjini",
|
|
32
|
+
"email": "tg@folklore.email"
|
|
28
33
|
}
|
|
29
34
|
],
|
|
35
|
+
"license": "ISC",
|
|
30
36
|
"main": "lib/index.js",
|
|
31
37
|
"module": "es/index.js",
|
|
32
38
|
"files": [
|
|
33
39
|
"lib",
|
|
34
40
|
"es",
|
|
35
|
-
"
|
|
41
|
+
"assets"
|
|
36
42
|
],
|
|
37
43
|
"scripts": {
|
|
38
|
-
"
|
|
39
|
-
"clean": "rm -rf dist && rm -rf lib && rm -rf es",
|
|
40
|
-
"webpack:dist": "../../node_modules/.bin/webpack --config ./webpack.config.js --progress --colors",
|
|
41
|
-
"webpack": "npm run webpack:dist",
|
|
42
|
-
"babel:es": "BABEL_ENV=es ../../node_modules/.bin/babel src --out-dir es --ignore src/**/*.story.jsx,src/**/*.test.jsx",
|
|
43
|
-
"babel:cjs": "BABEL_ENV=cjs ../../node_modules/.bin/babel src --out-dir lib --ignore src/**/*.story.jsx,src/**/*.test.jsx",
|
|
44
|
-
"babel": "npm run babel:es && npm run babel:cjs",
|
|
45
|
-
"build": "npm run babel",
|
|
46
|
-
"prepare": "npm run clean && npm run build",
|
|
47
|
-
"start": "npm run storybook"
|
|
48
|
-
},
|
|
49
|
-
"dependencies": {
|
|
50
|
-
"@babel/runtime": "^7.5.5",
|
|
51
|
-
"@panneau/core": "^1.0.1-alpha.0",
|
|
52
|
-
"@panneau/modal-popover": "^1.0.1-alpha.0",
|
|
53
|
-
"invariant": "^2.2.2",
|
|
54
|
-
"lodash": "^4.17.4",
|
|
55
|
-
"prop-types": "^15.7.0"
|
|
44
|
+
"prepare": "../../scripts/prepare-package.sh --scss"
|
|
56
45
|
},
|
|
57
46
|
"devDependencies": {
|
|
58
|
-
"react": "^16.
|
|
59
|
-
"react-dom": "^16.
|
|
47
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
48
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
60
49
|
},
|
|
61
50
|
"peerDependencies": {
|
|
62
|
-
"react": "^16.8.0",
|
|
63
|
-
"react-dom": "^16.8.0"
|
|
51
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
52
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@babel/runtime": "^7.12.5",
|
|
56
|
+
"@panneau/core": "^1.0.3-alpha.0",
|
|
57
|
+
"@panneau/element-portal": "^1.0.0-alpha.263",
|
|
58
|
+
"@panneau/modal-dialog": "^1.0.3-alpha.0",
|
|
59
|
+
"@panneau/modal-upload": "^1.0.3-alpha.0",
|
|
60
|
+
"@panneau/themes": "^1.0.3-alpha.0",
|
|
61
|
+
"classnames": "^2.2.6",
|
|
62
|
+
"prop-types": "^15.7.2"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
64
66
|
},
|
|
65
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "7f9c472b97c79a5c81da30730549acdde2de5c9f"
|
|
66
68
|
}
|