@alfalab/core-components-base-modal 4.1.2 → 4.1.5
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/CHANGELOG.md +35 -0
- package/{dist/Component.d.ts → Component.d.ts} +0 -0
- package/{dist/Component.js → Component.js} +35 -28
- package/{dist/cssm → cssm}/Component.d.ts +0 -0
- package/{dist/cssm → cssm}/Component.js +38 -31
- package/{dist/cssm → cssm}/index.d.ts +0 -0
- package/{dist/cssm → cssm}/index.js +4 -4
- package/{dist/cssm → cssm}/index.module.css +0 -0
- package/{dist/cssm → cssm}/utils.d.ts +0 -0
- package/{dist/cssm → cssm}/utils.js +1 -1
- package/{dist/esm → esm}/Component.d.ts +0 -0
- package/{dist/esm → esm}/Component.js +41 -34
- package/{dist/modern → esm}/index.css +13 -13
- package/{dist/esm → esm}/index.d.ts +0 -0
- package/{dist/esm → esm}/index.js +4 -4
- package/{dist/esm → esm}/utils.d.ts +0 -0
- package/{dist/esm → esm}/utils.js +1 -1
- package/{dist/esm/index.css → index.css} +13 -13
- package/{dist/index.d.ts → index.d.ts} +0 -0
- package/{dist/index.js → index.js} +0 -0
- package/{dist/modern → modern}/Component.d.ts +0 -0
- package/{dist/modern → modern}/Component.js +41 -34
- package/{dist → modern}/index.css +13 -13
- package/{dist/modern → modern}/index.d.ts +0 -0
- package/{dist/modern → modern}/index.js +4 -4
- package/{dist/modern → modern}/utils.d.ts +0 -0
- package/{dist/modern → modern}/utils.js +1 -1
- package/package.json +10 -13
- /package/{dist/send-stats.js → send-stats.js} +0 -0
- /package/{dist/utils.d.ts → utils.d.ts} +0 -0
- /package/{dist/utils.js → utils.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,40 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.1.5](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.1.4...@alfalab/core-components-base-modal@4.1.5) (2022-07-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* bump packages version ([#153](https://github.com/core-ds/core-components/issues/153)) ([fd3e082](https://github.com/core-ds/core-components/commit/fd3e08205672129cdce04e1000c673f2cd9c10da))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.1.4](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.1.3...@alfalab/core-components-base-modal@4.1.4) (2022-07-14)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **base-modal:** fix overflow hidden bug ([#128](https://github.com/core-ds/core-components/issues/128)) ([eb953b9](https://github.com/core-ds/core-components/commit/eb953b9866dae8c28bf8265d6884cdf1544ae63c))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [4.1.3](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.1.2...@alfalab/core-components-base-modal@4.1.3) (2022-07-11)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* **base-modal:** fix using resize observer ([#136](https://github.com/core-ds/core-components/issues/136)) ([cb8f03c](https://github.com/core-ds/core-components/commit/cb8f03ca55394316189d1d4529ee3fdb691538d9))
|
|
34
|
+
* fixed 'window is not defined' error ([#126](https://github.com/core-ds/core-components/issues/126)) ([f4e9ca5](https://github.com/core-ds/core-components/commit/f4e9ca54ed52fb328d21c85b7efa8176a90dcb6e))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
6
40
|
## [4.1.2](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.1.1...@alfalab/core-components-base-modal@4.1.2) (2022-07-01)
|
|
7
41
|
|
|
8
42
|
|
|
@@ -239,4 +273,5 @@ remove z-index, add stack component
|
|
|
239
273
|
|
|
240
274
|
### Features
|
|
241
275
|
|
|
276
|
+
|
|
242
277
|
* **backdrop:** add component ([948a6c2](https://github.com/core-ds/core-components/commit/948a6c2fb5ec58edb2d087691ce4713d75da6e35))
|
|
File without changes
|
|
@@ -48,7 +48,7 @@ var __assign = function () {
|
|
|
48
48
|
return __assign.apply(this, arguments);
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
var styles = {"component":"base-
|
|
51
|
+
var styles = {"component":"base-modal__component_1bcmd","wrapper":"base-modal__wrapper_1bcmd","content":"base-modal__content_1bcmd","hidden":"base-modal__hidden_1bcmd","backdrop":"base-modal__backdrop_1bcmd","appear":"base-modal__appear_1bcmd","enter":"base-modal__enter_1bcmd","appearActive":"base-modal__appearActive_1bcmd","enterActive":"base-modal__enterActive_1bcmd","exit":"base-modal__exit_1bcmd","exitActive":"base-modal__exitActive_1bcmd","exitDone":"base-modal__exitDone_1bcmd"};
|
|
52
52
|
require('./index.css')
|
|
53
53
|
|
|
54
54
|
var BaseModalContext = React__default['default'].createContext({
|
|
@@ -64,10 +64,9 @@ var BaseModalContext = React__default['default'].createContext({
|
|
|
64
64
|
setHasFooter: function () { return null; },
|
|
65
65
|
onClose: function () { return null; },
|
|
66
66
|
});
|
|
67
|
-
var ResizeObserver = window.ResizeObserver || resizeObserver.ResizeObserver;
|
|
68
67
|
var BaseModal = React.forwardRef(function (_a, ref) {
|
|
69
68
|
var open = _a.open, container = _a.container, children = _a.children, _b = _a.scrollHandler, scrollHandler = _b === void 0 ? 'wrapper' : _b, _c = _a.Backdrop, Backdrop = _c === void 0 ? coreComponentsBackdrop.Backdrop : _c, _d = _a.backdropProps, backdropProps = _d === void 0 ? {} : _d, _e = _a.transitionProps, transitionProps = _e === void 0 ? {} : _e, disableBackdropClick = _a.disableBackdropClick, _f = _a.disableAutoFocus, disableAutoFocus = _f === void 0 ? false : _f, _g = _a.disableFocusLock, disableFocusLock = _g === void 0 ? false : _g, _h = _a.disableEscapeKeyDown, disableEscapeKeyDown = _h === void 0 ? false : _h, _j = _a.disableRestoreFocus, disableRestoreFocus = _j === void 0 ? false : _j, _k = _a.keepMounted, keepMounted = _k === void 0 ? false : _k, className = _a.className, contentClassName = _a.contentClassName, wrapperClassName = _a.wrapperClassName, onBackdropClick = _a.onBackdropClick, onClose = _a.onClose, onEscapeKeyDown = _a.onEscapeKeyDown, onMount = _a.onMount, onUnmount = _a.onUnmount, dataTestId = _a.dataTestId, _l = _a.zIndex, zIndex = _l === void 0 ? coreComponentsStack.stackingOrder.MODAL : _l, _m = _a.componentRef, componentRef = _m === void 0 ? null : _m;
|
|
70
|
-
var _o = React.useState(
|
|
69
|
+
var _o = React.useState(null), exited = _o[0], setExited = _o[1];
|
|
71
70
|
var _p = React.useState(false), hasScroll = _p[0], setHasScroll = _p[1];
|
|
72
71
|
var _q = React.useState(false), hasHeader = _q[0], setHasHeader = _q[1];
|
|
73
72
|
var _r = React.useState(false), hasFooter = _r[0], setHasFooter = _r[1];
|
|
@@ -80,6 +79,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
80
79
|
var contentNodeRef = React.useRef(null);
|
|
81
80
|
var restoreContainerStylesRef = React.useRef(null);
|
|
82
81
|
var mouseDownTarget = React.useRef();
|
|
82
|
+
var resizeObserverRef = React.useRef();
|
|
83
83
|
var checkToHasScrollBar = function () {
|
|
84
84
|
if (scrollableNodeRef.current) {
|
|
85
85
|
var scrollExists = utils.hasScrollbar(scrollableNodeRef.current);
|
|
@@ -87,27 +87,31 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
87
87
|
setHasScroll(scrollExists);
|
|
88
88
|
}
|
|
89
89
|
};
|
|
90
|
-
var
|
|
90
|
+
var isExited = exited || exited === null;
|
|
91
|
+
var shouldRender = keepMounted || open || !isExited;
|
|
91
92
|
var getContainer = React.useCallback(function () {
|
|
92
93
|
return (container ? container() : document.body);
|
|
93
94
|
}, [container]);
|
|
94
|
-
var resizeObserver = React.useMemo(function () { return new ResizeObserver(checkToHasScrollBar); }, []);
|
|
95
95
|
var addResizeHandle = React.useCallback(function () {
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
if (!resizeObserverRef.current)
|
|
97
|
+
return;
|
|
98
|
+
if (scrollableNodeRef.current) {
|
|
99
|
+
resizeObserverRef.current.observe(scrollableNodeRef.current);
|
|
100
|
+
}
|
|
101
|
+
if (contentNodeRef.current) {
|
|
102
|
+
resizeObserverRef.current.observe(contentNodeRef.current);
|
|
103
|
+
}
|
|
104
|
+
}, []);
|
|
105
|
+
var removeResizeHandle = React.useCallback(function () { var _a; return (_a = resizeObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect(); }, []);
|
|
104
106
|
var contentRef = React.useCallback(function (node) {
|
|
105
107
|
if (node !== null) {
|
|
106
108
|
contentNodeRef.current = node;
|
|
107
|
-
|
|
109
|
+
if (resizeObserverRef.current) {
|
|
110
|
+
resizeObserverRef.current.observe(node);
|
|
111
|
+
}
|
|
108
112
|
checkToHasScrollBar();
|
|
109
113
|
}
|
|
110
|
-
}, [
|
|
114
|
+
}, []);
|
|
111
115
|
var handleScroll = React.useCallback(function () {
|
|
112
116
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
113
117
|
return;
|
|
@@ -196,25 +200,28 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
196
200
|
}, [handleScroll, onUnmount, removeResizeHandle, transitionProps]);
|
|
197
201
|
React.useEffect(function () {
|
|
198
202
|
if (open) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
if (isExited) {
|
|
204
|
+
var el_1 = getContainer();
|
|
205
|
+
utils.handleContainer(el_1);
|
|
206
|
+
restoreContainerStylesRef.current = function () {
|
|
207
|
+
restoreContainerStylesRef.current = null;
|
|
208
|
+
utils.restoreContainerStyles(el_1);
|
|
209
|
+
};
|
|
210
|
+
setExited(false);
|
|
211
|
+
}
|
|
204
212
|
}
|
|
205
|
-
}, [getContainer, open]);
|
|
206
|
-
React.useEffect(function () {
|
|
207
|
-
if (open)
|
|
208
|
-
setExited(false);
|
|
209
|
-
}, [open]);
|
|
213
|
+
}, [getContainer, open, isExited]);
|
|
210
214
|
React.useEffect(function () {
|
|
215
|
+
var ResizeObserver = window.ResizeObserver || resizeObserver.ResizeObserver;
|
|
216
|
+
resizeObserverRef.current = new ResizeObserver(checkToHasScrollBar);
|
|
211
217
|
return function () {
|
|
212
218
|
if (restoreContainerStylesRef.current) {
|
|
213
219
|
restoreContainerStylesRef.current();
|
|
214
220
|
}
|
|
215
|
-
|
|
221
|
+
if (resizeObserverRef.current) {
|
|
222
|
+
resizeObserverRef.current.disconnect();
|
|
223
|
+
}
|
|
216
224
|
};
|
|
217
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
218
225
|
}, []);
|
|
219
226
|
var contextValue = React.useMemo(function () { return ({
|
|
220
227
|
hasHeader: hasHeader,
|
|
@@ -250,7 +257,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
250
257
|
zIndex: computedZIndex,
|
|
251
258
|
} }))),
|
|
252
259
|
React__default['default'].createElement("div", { role: 'dialog', className: cn__default['default'](styles.wrapper, wrapperClassName, (_a = {},
|
|
253
|
-
_a[styles.hidden] = !open &&
|
|
260
|
+
_a[styles.hidden] = !open && isExited,
|
|
254
261
|
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
255
262
|
zIndex: computedZIndex,
|
|
256
263
|
} },
|
|
File without changes
|
|
@@ -8,10 +8,10 @@ var mergeRefs = require('react-merge-refs');
|
|
|
8
8
|
var resizeObserver = require('@juggle/resize-observer');
|
|
9
9
|
var reactTransitionGroup = require('react-transition-group');
|
|
10
10
|
var FocusLock = require('react-focus-lock');
|
|
11
|
-
var coreComponentsPortal = require('@alfalab/core-components-portal/
|
|
12
|
-
var coreComponentsBackdrop = require('@alfalab/core-components-backdrop/
|
|
13
|
-
var coreComponentsStack = require('@alfalab/core-components-stack/
|
|
14
|
-
require('@alfalab/core-components-global-store/
|
|
11
|
+
var coreComponentsPortal = require('@alfalab/core-components-portal/cssm');
|
|
12
|
+
var coreComponentsBackdrop = require('@alfalab/core-components-backdrop/cssm');
|
|
13
|
+
var coreComponentsStack = require('@alfalab/core-components-stack/cssm');
|
|
14
|
+
require('@alfalab/core-components-global-store/cssm');
|
|
15
15
|
var utils = require('./utils.js');
|
|
16
16
|
var styles = require('./index.module.css');
|
|
17
17
|
|
|
@@ -63,10 +63,9 @@ var BaseModalContext = React__default['default'].createContext({
|
|
|
63
63
|
setHasFooter: function () { return null; },
|
|
64
64
|
onClose: function () { return null; },
|
|
65
65
|
});
|
|
66
|
-
var ResizeObserver = window.ResizeObserver || resizeObserver.ResizeObserver;
|
|
67
66
|
var BaseModal = React.forwardRef(function (_a, ref) {
|
|
68
67
|
var open = _a.open, container = _a.container, children = _a.children, _b = _a.scrollHandler, scrollHandler = _b === void 0 ? 'wrapper' : _b, _c = _a.Backdrop, Backdrop = _c === void 0 ? coreComponentsBackdrop.Backdrop : _c, _d = _a.backdropProps, backdropProps = _d === void 0 ? {} : _d, _e = _a.transitionProps, transitionProps = _e === void 0 ? {} : _e, disableBackdropClick = _a.disableBackdropClick, _f = _a.disableAutoFocus, disableAutoFocus = _f === void 0 ? false : _f, _g = _a.disableFocusLock, disableFocusLock = _g === void 0 ? false : _g, _h = _a.disableEscapeKeyDown, disableEscapeKeyDown = _h === void 0 ? false : _h, _j = _a.disableRestoreFocus, disableRestoreFocus = _j === void 0 ? false : _j, _k = _a.keepMounted, keepMounted = _k === void 0 ? false : _k, className = _a.className, contentClassName = _a.contentClassName, wrapperClassName = _a.wrapperClassName, onBackdropClick = _a.onBackdropClick, onClose = _a.onClose, onEscapeKeyDown = _a.onEscapeKeyDown, onMount = _a.onMount, onUnmount = _a.onUnmount, dataTestId = _a.dataTestId, _l = _a.zIndex, zIndex = _l === void 0 ? coreComponentsStack.stackingOrder.MODAL : _l, _m = _a.componentRef, componentRef = _m === void 0 ? null : _m;
|
|
69
|
-
var _o = React.useState(
|
|
68
|
+
var _o = React.useState(null), exited = _o[0], setExited = _o[1];
|
|
70
69
|
var _p = React.useState(false), hasScroll = _p[0], setHasScroll = _p[1];
|
|
71
70
|
var _q = React.useState(false), hasHeader = _q[0], setHasHeader = _q[1];
|
|
72
71
|
var _r = React.useState(false), hasFooter = _r[0], setHasFooter = _r[1];
|
|
@@ -79,6 +78,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
79
78
|
var contentNodeRef = React.useRef(null);
|
|
80
79
|
var restoreContainerStylesRef = React.useRef(null);
|
|
81
80
|
var mouseDownTarget = React.useRef();
|
|
81
|
+
var resizeObserverRef = React.useRef();
|
|
82
82
|
var checkToHasScrollBar = function () {
|
|
83
83
|
if (scrollableNodeRef.current) {
|
|
84
84
|
var scrollExists = utils.hasScrollbar(scrollableNodeRef.current);
|
|
@@ -86,27 +86,31 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
86
86
|
setHasScroll(scrollExists);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
-
var
|
|
89
|
+
var isExited = exited || exited === null;
|
|
90
|
+
var shouldRender = keepMounted || open || !isExited;
|
|
90
91
|
var getContainer = React.useCallback(function () {
|
|
91
92
|
return (container ? container() : document.body);
|
|
92
93
|
}, [container]);
|
|
93
|
-
var resizeObserver = React.useMemo(function () { return new ResizeObserver(checkToHasScrollBar); }, []);
|
|
94
94
|
var addResizeHandle = React.useCallback(function () {
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
if (!resizeObserverRef.current)
|
|
96
|
+
return;
|
|
97
|
+
if (scrollableNodeRef.current) {
|
|
98
|
+
resizeObserverRef.current.observe(scrollableNodeRef.current);
|
|
99
|
+
}
|
|
100
|
+
if (contentNodeRef.current) {
|
|
101
|
+
resizeObserverRef.current.observe(contentNodeRef.current);
|
|
102
|
+
}
|
|
103
|
+
}, []);
|
|
104
|
+
var removeResizeHandle = React.useCallback(function () { var _a; return (_a = resizeObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect(); }, []);
|
|
103
105
|
var contentRef = React.useCallback(function (node) {
|
|
104
106
|
if (node !== null) {
|
|
105
107
|
contentNodeRef.current = node;
|
|
106
|
-
|
|
108
|
+
if (resizeObserverRef.current) {
|
|
109
|
+
resizeObserverRef.current.observe(node);
|
|
110
|
+
}
|
|
107
111
|
checkToHasScrollBar();
|
|
108
112
|
}
|
|
109
|
-
}, [
|
|
113
|
+
}, []);
|
|
110
114
|
var handleScroll = React.useCallback(function () {
|
|
111
115
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
112
116
|
return;
|
|
@@ -195,25 +199,28 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
195
199
|
}, [handleScroll, onUnmount, removeResizeHandle, transitionProps]);
|
|
196
200
|
React.useEffect(function () {
|
|
197
201
|
if (open) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
if (isExited) {
|
|
203
|
+
var el_1 = getContainer();
|
|
204
|
+
utils.handleContainer(el_1);
|
|
205
|
+
restoreContainerStylesRef.current = function () {
|
|
206
|
+
restoreContainerStylesRef.current = null;
|
|
207
|
+
utils.restoreContainerStyles(el_1);
|
|
208
|
+
};
|
|
209
|
+
setExited(false);
|
|
210
|
+
}
|
|
203
211
|
}
|
|
204
|
-
}, [getContainer, open]);
|
|
205
|
-
React.useEffect(function () {
|
|
206
|
-
if (open)
|
|
207
|
-
setExited(false);
|
|
208
|
-
}, [open]);
|
|
212
|
+
}, [getContainer, open, isExited]);
|
|
209
213
|
React.useEffect(function () {
|
|
214
|
+
var ResizeObserver = window.ResizeObserver || resizeObserver.ResizeObserver;
|
|
215
|
+
resizeObserverRef.current = new ResizeObserver(checkToHasScrollBar);
|
|
210
216
|
return function () {
|
|
211
217
|
if (restoreContainerStylesRef.current) {
|
|
212
218
|
restoreContainerStylesRef.current();
|
|
213
219
|
}
|
|
214
|
-
|
|
220
|
+
if (resizeObserverRef.current) {
|
|
221
|
+
resizeObserverRef.current.disconnect();
|
|
222
|
+
}
|
|
215
223
|
};
|
|
216
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
217
224
|
}, []);
|
|
218
225
|
var contextValue = React.useMemo(function () { return ({
|
|
219
226
|
hasHeader: hasHeader,
|
|
@@ -249,7 +256,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
249
256
|
zIndex: computedZIndex,
|
|
250
257
|
} }))),
|
|
251
258
|
React__default['default'].createElement("div", { role: 'dialog', className: cn__default['default'](styles__default['default'].wrapper, wrapperClassName, (_a = {},
|
|
252
|
-
_a[styles__default['default'].hidden] = !open &&
|
|
259
|
+
_a[styles__default['default'].hidden] = !open && isExited,
|
|
253
260
|
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
254
261
|
zIndex: computedZIndex,
|
|
255
262
|
} },
|
|
File without changes
|
|
@@ -9,10 +9,10 @@ require('react-merge-refs');
|
|
|
9
9
|
require('@juggle/resize-observer');
|
|
10
10
|
require('react-transition-group');
|
|
11
11
|
require('react-focus-lock');
|
|
12
|
-
require('@alfalab/core-components-portal/
|
|
13
|
-
require('@alfalab/core-components-backdrop/
|
|
14
|
-
require('@alfalab/core-components-stack/
|
|
15
|
-
require('@alfalab/core-components-global-store/
|
|
12
|
+
require('@alfalab/core-components-portal/cssm');
|
|
13
|
+
require('@alfalab/core-components-backdrop/cssm');
|
|
14
|
+
require('@alfalab/core-components-stack/cssm');
|
|
15
|
+
require('@alfalab/core-components-global-store/cssm');
|
|
16
16
|
var utils = require('./utils.js');
|
|
17
17
|
require('./index.module.css');
|
|
18
18
|
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var coreComponentsGlobalStore = require('@alfalab/core-components-global-store/
|
|
5
|
+
var coreComponentsGlobalStore = require('@alfalab/core-components-global-store/cssm');
|
|
6
6
|
|
|
7
7
|
function isScrolledToTop(target) {
|
|
8
8
|
return target.scrollTop <= 0;
|
|
File without changes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useCallback,
|
|
1
|
+
import React, { forwardRef, useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
|
-
import { ResizeObserver
|
|
4
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
5
5
|
import { CSSTransition } from 'react-transition-group';
|
|
6
6
|
import FocusLock from 'react-focus-lock';
|
|
7
|
-
import { Portal } from '@alfalab/core-components-portal/
|
|
8
|
-
import { Backdrop } from '@alfalab/core-components-backdrop/
|
|
9
|
-
import { stackingOrder, Stack } from '@alfalab/core-components-stack/
|
|
10
|
-
import '@alfalab/core-components-global-store/
|
|
7
|
+
import { Portal } from '@alfalab/core-components-portal/esm';
|
|
8
|
+
import { Backdrop } from '@alfalab/core-components-backdrop/esm';
|
|
9
|
+
import { stackingOrder, Stack } from '@alfalab/core-components-stack/esm';
|
|
10
|
+
import '@alfalab/core-components-global-store/esm';
|
|
11
11
|
import { isScrolledToTop, isScrolledToBottom, handleContainer, restoreContainerStyles, hasScrollbar } from './utils.js';
|
|
12
12
|
|
|
13
13
|
/*! *****************************************************************************
|
|
@@ -37,7 +37,7 @@ var __assign = function () {
|
|
|
37
37
|
return __assign.apply(this, arguments);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
var styles = {"component":"base-
|
|
40
|
+
var styles = {"component":"base-modal__component_1bcmd","wrapper":"base-modal__wrapper_1bcmd","content":"base-modal__content_1bcmd","hidden":"base-modal__hidden_1bcmd","backdrop":"base-modal__backdrop_1bcmd","appear":"base-modal__appear_1bcmd","enter":"base-modal__enter_1bcmd","appearActive":"base-modal__appearActive_1bcmd","enterActive":"base-modal__enterActive_1bcmd","exit":"base-modal__exit_1bcmd","exitActive":"base-modal__exitActive_1bcmd","exitDone":"base-modal__exitDone_1bcmd"};
|
|
41
41
|
require('./index.css')
|
|
42
42
|
|
|
43
43
|
var BaseModalContext = React.createContext({
|
|
@@ -53,10 +53,9 @@ var BaseModalContext = React.createContext({
|
|
|
53
53
|
setHasFooter: function () { return null; },
|
|
54
54
|
onClose: function () { return null; },
|
|
55
55
|
});
|
|
56
|
-
var ResizeObserver = window.ResizeObserver || ResizeObserver$1;
|
|
57
56
|
var BaseModal = forwardRef(function (_a, ref) {
|
|
58
57
|
var open = _a.open, container = _a.container, children = _a.children, _b = _a.scrollHandler, scrollHandler = _b === void 0 ? 'wrapper' : _b, _c = _a.Backdrop, Backdrop$1 = _c === void 0 ? Backdrop : _c, _d = _a.backdropProps, backdropProps = _d === void 0 ? {} : _d, _e = _a.transitionProps, transitionProps = _e === void 0 ? {} : _e, disableBackdropClick = _a.disableBackdropClick, _f = _a.disableAutoFocus, disableAutoFocus = _f === void 0 ? false : _f, _g = _a.disableFocusLock, disableFocusLock = _g === void 0 ? false : _g, _h = _a.disableEscapeKeyDown, disableEscapeKeyDown = _h === void 0 ? false : _h, _j = _a.disableRestoreFocus, disableRestoreFocus = _j === void 0 ? false : _j, _k = _a.keepMounted, keepMounted = _k === void 0 ? false : _k, className = _a.className, contentClassName = _a.contentClassName, wrapperClassName = _a.wrapperClassName, onBackdropClick = _a.onBackdropClick, onClose = _a.onClose, onEscapeKeyDown = _a.onEscapeKeyDown, onMount = _a.onMount, onUnmount = _a.onUnmount, dataTestId = _a.dataTestId, _l = _a.zIndex, zIndex = _l === void 0 ? stackingOrder.MODAL : _l, _m = _a.componentRef, componentRef = _m === void 0 ? null : _m;
|
|
59
|
-
var _o = useState(
|
|
58
|
+
var _o = useState(null), exited = _o[0], setExited = _o[1];
|
|
60
59
|
var _p = useState(false), hasScroll = _p[0], setHasScroll = _p[1];
|
|
61
60
|
var _q = useState(false), hasHeader = _q[0], setHasHeader = _q[1];
|
|
62
61
|
var _r = useState(false), hasFooter = _r[0], setHasFooter = _r[1];
|
|
@@ -69,6 +68,7 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
69
68
|
var contentNodeRef = useRef(null);
|
|
70
69
|
var restoreContainerStylesRef = useRef(null);
|
|
71
70
|
var mouseDownTarget = useRef();
|
|
71
|
+
var resizeObserverRef = useRef();
|
|
72
72
|
var checkToHasScrollBar = function () {
|
|
73
73
|
if (scrollableNodeRef.current) {
|
|
74
74
|
var scrollExists = hasScrollbar(scrollableNodeRef.current);
|
|
@@ -76,27 +76,31 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
76
76
|
setHasScroll(scrollExists);
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
|
-
var
|
|
79
|
+
var isExited = exited || exited === null;
|
|
80
|
+
var shouldRender = keepMounted || open || !isExited;
|
|
80
81
|
var getContainer = useCallback(function () {
|
|
81
82
|
return (container ? container() : document.body);
|
|
82
83
|
}, [container]);
|
|
83
|
-
var resizeObserver = useMemo(function () { return new ResizeObserver(checkToHasScrollBar); }, []);
|
|
84
84
|
var addResizeHandle = useCallback(function () {
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
85
|
+
if (!resizeObserverRef.current)
|
|
86
|
+
return;
|
|
87
|
+
if (scrollableNodeRef.current) {
|
|
88
|
+
resizeObserverRef.current.observe(scrollableNodeRef.current);
|
|
89
|
+
}
|
|
90
|
+
if (contentNodeRef.current) {
|
|
91
|
+
resizeObserverRef.current.observe(contentNodeRef.current);
|
|
92
|
+
}
|
|
93
|
+
}, []);
|
|
94
|
+
var removeResizeHandle = useCallback(function () { var _a; return (_a = resizeObserverRef.current) === null || _a === void 0 ? void 0 : _a.disconnect(); }, []);
|
|
93
95
|
var contentRef = useCallback(function (node) {
|
|
94
96
|
if (node !== null) {
|
|
95
97
|
contentNodeRef.current = node;
|
|
96
|
-
|
|
98
|
+
if (resizeObserverRef.current) {
|
|
99
|
+
resizeObserverRef.current.observe(node);
|
|
100
|
+
}
|
|
97
101
|
checkToHasScrollBar();
|
|
98
102
|
}
|
|
99
|
-
}, [
|
|
103
|
+
}, []);
|
|
100
104
|
var handleScroll = useCallback(function () {
|
|
101
105
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
102
106
|
return;
|
|
@@ -185,25 +189,28 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
185
189
|
}, [handleScroll, onUnmount, removeResizeHandle, transitionProps]);
|
|
186
190
|
useEffect(function () {
|
|
187
191
|
if (open) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
if (isExited) {
|
|
193
|
+
var el_1 = getContainer();
|
|
194
|
+
handleContainer(el_1);
|
|
195
|
+
restoreContainerStylesRef.current = function () {
|
|
196
|
+
restoreContainerStylesRef.current = null;
|
|
197
|
+
restoreContainerStyles(el_1);
|
|
198
|
+
};
|
|
199
|
+
setExited(false);
|
|
200
|
+
}
|
|
193
201
|
}
|
|
194
|
-
}, [getContainer, open]);
|
|
195
|
-
useEffect(function () {
|
|
196
|
-
if (open)
|
|
197
|
-
setExited(false);
|
|
198
|
-
}, [open]);
|
|
202
|
+
}, [getContainer, open, isExited]);
|
|
199
203
|
useEffect(function () {
|
|
204
|
+
var ResizeObserver$1 = window.ResizeObserver || ResizeObserver;
|
|
205
|
+
resizeObserverRef.current = new ResizeObserver$1(checkToHasScrollBar);
|
|
200
206
|
return function () {
|
|
201
207
|
if (restoreContainerStylesRef.current) {
|
|
202
208
|
restoreContainerStylesRef.current();
|
|
203
209
|
}
|
|
204
|
-
|
|
210
|
+
if (resizeObserverRef.current) {
|
|
211
|
+
resizeObserverRef.current.disconnect();
|
|
212
|
+
}
|
|
205
213
|
};
|
|
206
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
207
214
|
}, []);
|
|
208
215
|
var contextValue = useMemo(function () { return ({
|
|
209
216
|
hasHeader: hasHeader,
|
|
@@ -239,7 +246,7 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
239
246
|
zIndex: computedZIndex,
|
|
240
247
|
} }))),
|
|
241
248
|
React.createElement("div", { role: 'dialog', className: cn(styles.wrapper, wrapperClassName, (_a = {},
|
|
242
|
-
_a[styles.hidden] = !open &&
|
|
249
|
+
_a[styles.hidden] = !open && isExited,
|
|
243
250
|
_a)), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
244
251
|
zIndex: computedZIndex,
|
|
245
252
|
} },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1mr4w */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
}
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
/* Hard up */
|
|
12
12
|
}
|
|
13
|
-
.base-
|
|
13
|
+
.base-modal__component_1bcmd {
|
|
14
14
|
position: relative;
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
background: var(--color-light-bg-primary);
|
|
17
17
|
margin: auto;
|
|
18
18
|
flex-shrink: 0;
|
|
19
19
|
}
|
|
20
|
-
.base-
|
|
20
|
+
.base-modal__wrapper_1bcmd {
|
|
21
21
|
position: fixed;
|
|
22
22
|
top: 0;
|
|
23
23
|
left: 0;
|
|
@@ -30,33 +30,33 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
outline: 0;
|
|
32
32
|
}
|
|
33
|
-
.base-
|
|
33
|
+
.base-modal__content_1bcmd {
|
|
34
34
|
width: 100%;
|
|
35
35
|
height: 100%;
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: column;
|
|
38
38
|
flex: 1;
|
|
39
39
|
}
|
|
40
|
-
.base-
|
|
40
|
+
.base-modal__hidden_1bcmd {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_1bcmd {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_1bcmd,
|
|
47
|
+
.base-modal__enter_1bcmd {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_1bcmd,
|
|
51
|
+
.base-modal__enterActive_1bcmd {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_1bcmd {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_1bcmd,
|
|
59
|
+
.base-modal__exitDone_1bcmd {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
|
File without changes
|
|
@@ -5,8 +5,8 @@ import 'react-merge-refs';
|
|
|
5
5
|
import '@juggle/resize-observer';
|
|
6
6
|
import 'react-transition-group';
|
|
7
7
|
import 'react-focus-lock';
|
|
8
|
-
import '@alfalab/core-components-portal/
|
|
9
|
-
import '@alfalab/core-components-backdrop/
|
|
10
|
-
import '@alfalab/core-components-stack/
|
|
11
|
-
import '@alfalab/core-components-global-store/
|
|
8
|
+
import '@alfalab/core-components-portal/esm';
|
|
9
|
+
import '@alfalab/core-components-backdrop/esm';
|
|
10
|
+
import '@alfalab/core-components-stack/esm';
|
|
11
|
+
import '@alfalab/core-components-global-store/esm';
|
|
12
12
|
export { handleContainer, hasScrollbar, isScrolledToBottom, isScrolledToTop, restoreContainerStyles } from './utils.js';
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1mr4w */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
}
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
/* Hard up */
|
|
12
12
|
}
|
|
13
|
-
.base-
|
|
13
|
+
.base-modal__component_1bcmd {
|
|
14
14
|
position: relative;
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
background: var(--color-light-bg-primary);
|
|
17
17
|
margin: auto;
|
|
18
18
|
flex-shrink: 0;
|
|
19
19
|
}
|
|
20
|
-
.base-
|
|
20
|
+
.base-modal__wrapper_1bcmd {
|
|
21
21
|
position: fixed;
|
|
22
22
|
top: 0;
|
|
23
23
|
left: 0;
|
|
@@ -30,33 +30,33 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
outline: 0;
|
|
32
32
|
}
|
|
33
|
-
.base-
|
|
33
|
+
.base-modal__content_1bcmd {
|
|
34
34
|
width: 100%;
|
|
35
35
|
height: 100%;
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: column;
|
|
38
38
|
flex: 1;
|
|
39
39
|
}
|
|
40
|
-
.base-
|
|
40
|
+
.base-modal__hidden_1bcmd {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_1bcmd {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_1bcmd,
|
|
47
|
+
.base-modal__enter_1bcmd {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_1bcmd,
|
|
51
|
+
.base-modal__enterActive_1bcmd {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_1bcmd {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_1bcmd,
|
|
59
|
+
.base-modal__exitDone_1bcmd {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useRef, useCallback,
|
|
1
|
+
import React, { forwardRef, useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
|
-
import { ResizeObserver
|
|
4
|
+
import { ResizeObserver } from '@juggle/resize-observer';
|
|
5
5
|
import { CSSTransition } from 'react-transition-group';
|
|
6
6
|
import FocusLock from 'react-focus-lock';
|
|
7
|
-
import { Portal } from '@alfalab/core-components-portal/
|
|
8
|
-
import { Backdrop } from '@alfalab/core-components-backdrop/
|
|
9
|
-
import { stackingOrder, Stack } from '@alfalab/core-components-stack/
|
|
10
|
-
import '@alfalab/core-components-global-store/
|
|
7
|
+
import { Portal } from '@alfalab/core-components-portal/modern';
|
|
8
|
+
import { Backdrop } from '@alfalab/core-components-backdrop/modern';
|
|
9
|
+
import { stackingOrder, Stack } from '@alfalab/core-components-stack/modern';
|
|
10
|
+
import '@alfalab/core-components-global-store/modern';
|
|
11
11
|
import { isScrolledToTop, isScrolledToBottom, handleContainer, restoreContainerStyles, hasScrollbar } from './utils.js';
|
|
12
12
|
|
|
13
|
-
var styles = {"component":"base-
|
|
13
|
+
var styles = {"component":"base-modal__component_1bcmd","wrapper":"base-modal__wrapper_1bcmd","content":"base-modal__content_1bcmd","hidden":"base-modal__hidden_1bcmd","backdrop":"base-modal__backdrop_1bcmd","appear":"base-modal__appear_1bcmd","enter":"base-modal__enter_1bcmd","appearActive":"base-modal__appearActive_1bcmd","enterActive":"base-modal__enterActive_1bcmd","exit":"base-modal__exit_1bcmd","exitActive":"base-modal__exitActive_1bcmd","exitDone":"base-modal__exitDone_1bcmd"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
@@ -27,9 +27,8 @@ const BaseModalContext = React.createContext({
|
|
|
27
27
|
setHasFooter: () => null,
|
|
28
28
|
onClose: () => null,
|
|
29
29
|
});
|
|
30
|
-
const ResizeObserver = window.ResizeObserver || ResizeObserver$1;
|
|
31
30
|
const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrapper', Backdrop: Backdrop$1 = Backdrop, backdropProps = {}, transitionProps = {}, disableBackdropClick, disableAutoFocus = false, disableFocusLock = false, disableEscapeKeyDown = false, disableRestoreFocus = false, keepMounted = false, className, contentClassName, wrapperClassName, onBackdropClick, onClose, onEscapeKeyDown, onMount, onUnmount, dataTestId, zIndex = stackingOrder.MODAL, componentRef = null, }, ref) => {
|
|
32
|
-
const [exited, setExited] = useState(
|
|
31
|
+
const [exited, setExited] = useState(null);
|
|
33
32
|
const [hasScroll, setHasScroll] = useState(false);
|
|
34
33
|
const [hasHeader, setHasHeader] = useState(false);
|
|
35
34
|
const [hasFooter, setHasFooter] = useState(false);
|
|
@@ -42,6 +41,7 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
42
41
|
const contentNodeRef = useRef(null);
|
|
43
42
|
const restoreContainerStylesRef = useRef(null);
|
|
44
43
|
const mouseDownTarget = useRef();
|
|
44
|
+
const resizeObserverRef = useRef();
|
|
45
45
|
const checkToHasScrollBar = () => {
|
|
46
46
|
if (scrollableNodeRef.current) {
|
|
47
47
|
const scrollExists = hasScrollbar(scrollableNodeRef.current);
|
|
@@ -49,27 +49,31 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
49
49
|
setHasScroll(scrollExists);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
const
|
|
52
|
+
const isExited = exited || exited === null;
|
|
53
|
+
const shouldRender = keepMounted || open || !isExited;
|
|
53
54
|
const getContainer = useCallback(() => {
|
|
54
55
|
return (container ? container() : document.body);
|
|
55
56
|
}, [container]);
|
|
56
|
-
const resizeObserver = useMemo(() => new ResizeObserver(checkToHasScrollBar), []);
|
|
57
57
|
const addResizeHandle = useCallback(() => {
|
|
58
|
-
if (
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
if (!resizeObserverRef.current)
|
|
59
|
+
return;
|
|
60
|
+
if (scrollableNodeRef.current) {
|
|
61
|
+
resizeObserverRef.current.observe(scrollableNodeRef.current);
|
|
62
|
+
}
|
|
63
|
+
if (contentNodeRef.current) {
|
|
64
|
+
resizeObserverRef.current.observe(contentNodeRef.current);
|
|
65
|
+
}
|
|
66
|
+
}, []);
|
|
67
|
+
const removeResizeHandle = useCallback(() => resizeObserverRef.current?.disconnect(), []);
|
|
66
68
|
const contentRef = useCallback((node) => {
|
|
67
69
|
if (node !== null) {
|
|
68
70
|
contentNodeRef.current = node;
|
|
69
|
-
|
|
71
|
+
if (resizeObserverRef.current) {
|
|
72
|
+
resizeObserverRef.current.observe(node);
|
|
73
|
+
}
|
|
70
74
|
checkToHasScrollBar();
|
|
71
75
|
}
|
|
72
|
-
}, [
|
|
76
|
+
}, []);
|
|
73
77
|
const handleScroll = useCallback(() => {
|
|
74
78
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
75
79
|
return;
|
|
@@ -158,25 +162,28 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
158
162
|
}, [handleScroll, onUnmount, removeResizeHandle, transitionProps]);
|
|
159
163
|
useEffect(() => {
|
|
160
164
|
if (open) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
165
|
+
if (isExited) {
|
|
166
|
+
const el = getContainer();
|
|
167
|
+
handleContainer(el);
|
|
168
|
+
restoreContainerStylesRef.current = () => {
|
|
169
|
+
restoreContainerStylesRef.current = null;
|
|
170
|
+
restoreContainerStyles(el);
|
|
171
|
+
};
|
|
172
|
+
setExited(false);
|
|
173
|
+
}
|
|
166
174
|
}
|
|
167
|
-
}, [getContainer, open]);
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
if (open)
|
|
170
|
-
setExited(false);
|
|
171
|
-
}, [open]);
|
|
175
|
+
}, [getContainer, open, isExited]);
|
|
172
176
|
useEffect(() => {
|
|
177
|
+
const ResizeObserver$1 = window.ResizeObserver || ResizeObserver;
|
|
178
|
+
resizeObserverRef.current = new ResizeObserver$1(checkToHasScrollBar);
|
|
173
179
|
return () => {
|
|
174
180
|
if (restoreContainerStylesRef.current) {
|
|
175
181
|
restoreContainerStylesRef.current();
|
|
176
182
|
}
|
|
177
|
-
|
|
183
|
+
if (resizeObserverRef.current) {
|
|
184
|
+
resizeObserverRef.current.disconnect();
|
|
185
|
+
}
|
|
178
186
|
};
|
|
179
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
180
187
|
}, []);
|
|
181
188
|
const contextValue = useMemo(() => ({
|
|
182
189
|
hasHeader,
|
|
@@ -210,7 +217,7 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
210
217
|
zIndex: computedZIndex,
|
|
211
218
|
} }))),
|
|
212
219
|
React.createElement("div", { role: 'dialog', className: cn(styles.wrapper, wrapperClassName, {
|
|
213
|
-
[styles.hidden]: !open &&
|
|
220
|
+
[styles.hidden]: !open && isExited,
|
|
214
221
|
}), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
215
222
|
zIndex: computedZIndex,
|
|
216
223
|
} },
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: 1mr4w */
|
|
2
2
|
:root {
|
|
3
3
|
--color-light-bg-primary: #fff;
|
|
4
4
|
}
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
/* Hard up */
|
|
12
12
|
}
|
|
13
|
-
.base-
|
|
13
|
+
.base-modal__component_1bcmd {
|
|
14
14
|
position: relative;
|
|
15
15
|
box-sizing: border-box;
|
|
16
16
|
background: var(--color-light-bg-primary);
|
|
17
17
|
margin: auto;
|
|
18
18
|
flex-shrink: 0;
|
|
19
19
|
}
|
|
20
|
-
.base-
|
|
20
|
+
.base-modal__wrapper_1bcmd {
|
|
21
21
|
position: fixed;
|
|
22
22
|
top: 0;
|
|
23
23
|
left: 0;
|
|
@@ -30,33 +30,33 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
outline: 0;
|
|
32
32
|
}
|
|
33
|
-
.base-
|
|
33
|
+
.base-modal__content_1bcmd {
|
|
34
34
|
width: 100%;
|
|
35
35
|
height: 100%;
|
|
36
36
|
display: flex;
|
|
37
37
|
flex-direction: column;
|
|
38
38
|
flex: 1;
|
|
39
39
|
}
|
|
40
|
-
.base-
|
|
40
|
+
.base-modal__hidden_1bcmd {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_1bcmd {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_1bcmd,
|
|
47
|
+
.base-modal__enter_1bcmd {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_1bcmd,
|
|
51
|
+
.base-modal__enterActive_1bcmd {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_1bcmd {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_1bcmd,
|
|
59
|
+
.base-modal__exitDone_1bcmd {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
|
File without changes
|
|
@@ -4,9 +4,9 @@ import 'react-merge-refs';
|
|
|
4
4
|
import '@juggle/resize-observer';
|
|
5
5
|
import 'react-transition-group';
|
|
6
6
|
import 'react-focus-lock';
|
|
7
|
-
import '@alfalab/core-components-portal/
|
|
8
|
-
import '@alfalab/core-components-backdrop/
|
|
9
|
-
import '@alfalab/core-components-stack/
|
|
10
|
-
import '@alfalab/core-components-global-store/
|
|
7
|
+
import '@alfalab/core-components-portal/modern';
|
|
8
|
+
import '@alfalab/core-components-backdrop/modern';
|
|
9
|
+
import '@alfalab/core-components-stack/modern';
|
|
10
|
+
import '@alfalab/core-components-global-store/modern';
|
|
11
11
|
export { handleContainer, hasScrollbar, isScrolledToBottom, isScrolledToTop, restoreContainerStyles } from './utils.js';
|
|
12
12
|
export { BaseModal, BaseModalContext } from './Component.js';
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-base-modal",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.5",
|
|
4
4
|
"description": "BaseModal component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"main": "
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
7
|
+
"main": "index.js",
|
|
11
8
|
"scripts": {
|
|
12
|
-
"postinstall": "node ./
|
|
9
|
+
"postinstall": "node ./send-stats.js > /dev/null 2>&1 || exit 0"
|
|
13
10
|
},
|
|
14
11
|
"publishConfig": {
|
|
15
|
-
"access": "public"
|
|
12
|
+
"access": "public",
|
|
13
|
+
"directory": "dist"
|
|
16
14
|
},
|
|
17
15
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-backdrop": "^2.1.
|
|
19
|
-
"@alfalab/core-components-global-store": "^1.1.
|
|
20
|
-
"@alfalab/core-components-portal": "^2.0.
|
|
21
|
-
"@alfalab/core-components-stack": "^3.0.
|
|
16
|
+
"@alfalab/core-components-backdrop": "^2.1.2",
|
|
17
|
+
"@alfalab/core-components-global-store": "^1.1.2",
|
|
18
|
+
"@alfalab/core-components-portal": "^2.0.5",
|
|
19
|
+
"@alfalab/core-components-stack": "^3.0.5",
|
|
22
20
|
"@juggle/resize-observer": "^3.3.1",
|
|
23
21
|
"classnames": "^2.2.6",
|
|
24
22
|
"react-focus-lock": "^2.5.0",
|
|
@@ -30,6 +28,5 @@
|
|
|
30
28
|
},
|
|
31
29
|
"peerDependencies": {
|
|
32
30
|
"react": "^16.9.0 || ^17.0.1"
|
|
33
|
-
}
|
|
34
|
-
"gitHead": "a1e54f5b2894447f4a6c80347706c27f855d5710"
|
|
31
|
+
}
|
|
35
32
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|