@alfalab/core-components-base-modal 4.0.2 → 4.1.2
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 +33 -0
- package/dist/Component.js +23 -14
- package/dist/cssm/Component.js +22 -13
- package/dist/cssm/index.js +1 -1
- package/dist/esm/Component.js +14 -5
- package/dist/esm/index.css +13 -13
- package/dist/esm/index.js +1 -1
- package/dist/index.css +13 -13
- package/dist/index.js +1 -1
- package/dist/modern/Component.js +14 -5
- package/dist/modern/index.css +13 -13
- package/dist/modern/index.js +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Performance Improvements
|
|
10
|
+
|
|
11
|
+
* refuse to use a resize-observer polyfill if it is not needed ([#120](https://github.com/core-ds/core-components/issues/120)) ([f2abcb2](https://github.com/core-ds/core-components/commit/f2abcb2888dd5906b345f5fc64b1624eef56ac13))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [4.1.1](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.1.0...@alfalab/core-components-base-modal@4.1.1) (2022-06-30)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **base-modal:** fixed outside modal click ([#115](https://github.com/core-ds/core-components/issues/115)) ([6a08f72](https://github.com/core-ds/core-components/commit/6a08f726521dcd9a310b0e06345950429eac246a))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [4.1.0](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@4.0.2...@alfalab/core-components-base-modal@4.1.0) (2022-06-28)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* circumflexus retrieval ([#57](https://github.com/core-ds/core-components/issues/57)) ([3820da8](https://github.com/core-ds/core-components/commit/3820da818bcdcbee6904c648b3e29c3c828fe202))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [4.0.0](https://github.com/core-ds/core-components/compare/@alfalab/core-components-base-modal@3.2.0...@alfalab/core-components-base-modal@4.0.0) (2022-03-24)
|
|
7
40
|
|
|
8
41
|
|
package/dist/Component.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var cn = require('classnames');
|
|
7
7
|
var mergeRefs = require('react-merge-refs');
|
|
8
|
-
var resizeObserver = require('resize-observer');
|
|
8
|
+
var resizeObserver = require('@juggle/resize-observer');
|
|
9
9
|
var reactTransitionGroup = require('react-transition-group');
|
|
10
10
|
var FocusLock = require('react-focus-lock');
|
|
11
11
|
var coreComponentsPortal = require('@alfalab/core-components-portal');
|
|
@@ -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_8t6ig","wrapper":"base-modal__wrapper_8t6ig","content":"base-modal__content_8t6ig","hidden":"base-modal__hidden_8t6ig","backdrop":"base-modal__backdrop_8t6ig","appear":"base-modal__appear_8t6ig","enter":"base-modal__enter_8t6ig","appearActive":"base-modal__appearActive_8t6ig","enterActive":"base-modal__enterActive_8t6ig","exit":"base-modal__exit_8t6ig","exitActive":"base-modal__exitActive_8t6ig","exitDone":"base-modal__exitDone_8t6ig"};
|
|
52
52
|
require('./index.css')
|
|
53
53
|
|
|
54
54
|
var BaseModalContext = React__default['default'].createContext({
|
|
@@ -64,6 +64,7 @@ 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;
|
|
67
68
|
var BaseModal = React.forwardRef(function (_a, ref) {
|
|
68
69
|
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
70
|
var _o = React.useState(!open), exited = _o[0], setExited = _o[1];
|
|
@@ -78,6 +79,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
78
79
|
var scrollableNodeRef = React.useRef(null);
|
|
79
80
|
var contentNodeRef = React.useRef(null);
|
|
80
81
|
var restoreContainerStylesRef = React.useRef(null);
|
|
82
|
+
var mouseDownTarget = React.useRef();
|
|
81
83
|
var checkToHasScrollBar = function () {
|
|
82
84
|
if (scrollableNodeRef.current) {
|
|
83
85
|
var scrollExists = utils.hasScrollbar(scrollableNodeRef.current);
|
|
@@ -89,23 +91,23 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
89
91
|
var getContainer = React.useCallback(function () {
|
|
90
92
|
return (container ? container() : document.body);
|
|
91
93
|
}, [container]);
|
|
92
|
-
var resizeObserver
|
|
94
|
+
var resizeObserver = React.useMemo(function () { return new ResizeObserver(checkToHasScrollBar); }, []);
|
|
93
95
|
var addResizeHandle = React.useCallback(function () {
|
|
94
96
|
if (scrollableNodeRef.current)
|
|
95
|
-
resizeObserver
|
|
97
|
+
resizeObserver.observe(scrollableNodeRef.current);
|
|
96
98
|
if (contentNodeRef.current)
|
|
97
|
-
resizeObserver
|
|
98
|
-
}, [resizeObserver
|
|
99
|
+
resizeObserver.observe(contentNodeRef.current);
|
|
100
|
+
}, [resizeObserver]);
|
|
99
101
|
var removeResizeHandle = React.useCallback(function () {
|
|
100
|
-
resizeObserver
|
|
101
|
-
}, [resizeObserver
|
|
102
|
+
resizeObserver.disconnect();
|
|
103
|
+
}, [resizeObserver]);
|
|
102
104
|
var contentRef = React.useCallback(function (node) {
|
|
103
105
|
if (node !== null) {
|
|
104
106
|
contentNodeRef.current = node;
|
|
105
|
-
resizeObserver
|
|
107
|
+
resizeObserver.observe(node);
|
|
106
108
|
checkToHasScrollBar();
|
|
107
109
|
}
|
|
108
|
-
}, [resizeObserver
|
|
110
|
+
}, [resizeObserver]);
|
|
109
111
|
var handleScroll = React.useCallback(function () {
|
|
110
112
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
111
113
|
return;
|
|
@@ -131,8 +133,15 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
131
133
|
}
|
|
132
134
|
return null;
|
|
133
135
|
}, [onBackdropClick, onClose, onEscapeKeyDown]);
|
|
134
|
-
var
|
|
135
|
-
if (!disableBackdropClick
|
|
136
|
+
var handleBackdropMouseDown = function (event) {
|
|
137
|
+
if (!disableBackdropClick) {
|
|
138
|
+
mouseDownTarget.current = event.target;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var handleBackdropMouseUp = function (event) {
|
|
142
|
+
if (!disableBackdropClick &&
|
|
143
|
+
event.target === wrapperRef.current &&
|
|
144
|
+
mouseDownTarget.current === wrapperRef.current) {
|
|
136
145
|
handleClose(event, 'backdropClick');
|
|
137
146
|
}
|
|
138
147
|
};
|
|
@@ -203,7 +212,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
203
212
|
if (restoreContainerStylesRef.current) {
|
|
204
213
|
restoreContainerStylesRef.current();
|
|
205
214
|
}
|
|
206
|
-
resizeObserver
|
|
215
|
+
resizeObserver.disconnect();
|
|
207
216
|
};
|
|
208
217
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
209
218
|
}, []);
|
|
@@ -242,7 +251,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
242
251
|
} }))),
|
|
243
252
|
React__default['default'].createElement("div", { role: 'dialog', className: cn__default['default'](styles.wrapper, wrapperClassName, (_a = {},
|
|
244
253
|
_a[styles.hidden] = !open && exited,
|
|
245
|
-
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown,
|
|
254
|
+
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
246
255
|
zIndex: computedZIndex,
|
|
247
256
|
} },
|
|
248
257
|
React__default['default'].createElement(reactTransitionGroup.CSSTransition, __assign({ appear: true, timeout: 200, classNames: styles }, transitionProps, { in: open, onEntered: handleEntered, onExited: handleExited }),
|
package/dist/cssm/Component.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var cn = require('classnames');
|
|
7
7
|
var mergeRefs = require('react-merge-refs');
|
|
8
|
-
var resizeObserver = require('resize-observer');
|
|
8
|
+
var resizeObserver = require('@juggle/resize-observer');
|
|
9
9
|
var reactTransitionGroup = require('react-transition-group');
|
|
10
10
|
var FocusLock = require('react-focus-lock');
|
|
11
11
|
var coreComponentsPortal = require('@alfalab/core-components-portal/dist/cssm');
|
|
@@ -63,6 +63,7 @@ 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;
|
|
66
67
|
var BaseModal = React.forwardRef(function (_a, ref) {
|
|
67
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;
|
|
68
69
|
var _o = React.useState(!open), exited = _o[0], setExited = _o[1];
|
|
@@ -77,6 +78,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
77
78
|
var scrollableNodeRef = React.useRef(null);
|
|
78
79
|
var contentNodeRef = React.useRef(null);
|
|
79
80
|
var restoreContainerStylesRef = React.useRef(null);
|
|
81
|
+
var mouseDownTarget = React.useRef();
|
|
80
82
|
var checkToHasScrollBar = function () {
|
|
81
83
|
if (scrollableNodeRef.current) {
|
|
82
84
|
var scrollExists = utils.hasScrollbar(scrollableNodeRef.current);
|
|
@@ -88,23 +90,23 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
88
90
|
var getContainer = React.useCallback(function () {
|
|
89
91
|
return (container ? container() : document.body);
|
|
90
92
|
}, [container]);
|
|
91
|
-
var resizeObserver
|
|
93
|
+
var resizeObserver = React.useMemo(function () { return new ResizeObserver(checkToHasScrollBar); }, []);
|
|
92
94
|
var addResizeHandle = React.useCallback(function () {
|
|
93
95
|
if (scrollableNodeRef.current)
|
|
94
|
-
resizeObserver
|
|
96
|
+
resizeObserver.observe(scrollableNodeRef.current);
|
|
95
97
|
if (contentNodeRef.current)
|
|
96
|
-
resizeObserver
|
|
97
|
-
}, [resizeObserver
|
|
98
|
+
resizeObserver.observe(contentNodeRef.current);
|
|
99
|
+
}, [resizeObserver]);
|
|
98
100
|
var removeResizeHandle = React.useCallback(function () {
|
|
99
|
-
resizeObserver
|
|
100
|
-
}, [resizeObserver
|
|
101
|
+
resizeObserver.disconnect();
|
|
102
|
+
}, [resizeObserver]);
|
|
101
103
|
var contentRef = React.useCallback(function (node) {
|
|
102
104
|
if (node !== null) {
|
|
103
105
|
contentNodeRef.current = node;
|
|
104
|
-
resizeObserver
|
|
106
|
+
resizeObserver.observe(node);
|
|
105
107
|
checkToHasScrollBar();
|
|
106
108
|
}
|
|
107
|
-
}, [resizeObserver
|
|
109
|
+
}, [resizeObserver]);
|
|
108
110
|
var handleScroll = React.useCallback(function () {
|
|
109
111
|
if (!scrollableNodeRef.current || !componentNodeRef.current)
|
|
110
112
|
return;
|
|
@@ -130,8 +132,15 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
130
132
|
}
|
|
131
133
|
return null;
|
|
132
134
|
}, [onBackdropClick, onClose, onEscapeKeyDown]);
|
|
133
|
-
var
|
|
134
|
-
if (!disableBackdropClick
|
|
135
|
+
var handleBackdropMouseDown = function (event) {
|
|
136
|
+
if (!disableBackdropClick) {
|
|
137
|
+
mouseDownTarget.current = event.target;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var handleBackdropMouseUp = function (event) {
|
|
141
|
+
if (!disableBackdropClick &&
|
|
142
|
+
event.target === wrapperRef.current &&
|
|
143
|
+
mouseDownTarget.current === wrapperRef.current) {
|
|
135
144
|
handleClose(event, 'backdropClick');
|
|
136
145
|
}
|
|
137
146
|
};
|
|
@@ -202,7 +211,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
202
211
|
if (restoreContainerStylesRef.current) {
|
|
203
212
|
restoreContainerStylesRef.current();
|
|
204
213
|
}
|
|
205
|
-
resizeObserver
|
|
214
|
+
resizeObserver.disconnect();
|
|
206
215
|
};
|
|
207
216
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
208
217
|
}, []);
|
|
@@ -241,7 +250,7 @@ var BaseModal = React.forwardRef(function (_a, ref) {
|
|
|
241
250
|
} }))),
|
|
242
251
|
React__default['default'].createElement("div", { role: 'dialog', className: cn__default['default'](styles__default['default'].wrapper, wrapperClassName, (_a = {},
|
|
243
252
|
_a[styles__default['default'].hidden] = !open && exited,
|
|
244
|
-
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown,
|
|
253
|
+
_a)), ref: mergeRefs__default['default']([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
245
254
|
zIndex: computedZIndex,
|
|
246
255
|
} },
|
|
247
256
|
React__default['default'].createElement(reactTransitionGroup.CSSTransition, __assign({ appear: true, timeout: 200, classNames: styles__default['default'] }, transitionProps, { in: open, onEntered: handleEntered, onExited: handleExited }),
|
package/dist/cssm/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var Component = require('./Component.js');
|
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('react-merge-refs');
|
|
9
|
-
require('resize-observer');
|
|
9
|
+
require('@juggle/resize-observer');
|
|
10
10
|
require('react-transition-group');
|
|
11
11
|
require('react-focus-lock');
|
|
12
12
|
require('@alfalab/core-components-portal/dist/cssm');
|
package/dist/esm/Component.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useState, useRef, useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
|
-
import { ResizeObserver } from 'resize-observer';
|
|
4
|
+
import { ResizeObserver as ResizeObserver$1 } from '@juggle/resize-observer';
|
|
5
5
|
import { CSSTransition } from 'react-transition-group';
|
|
6
6
|
import FocusLock from 'react-focus-lock';
|
|
7
7
|
import { Portal } from '@alfalab/core-components-portal/dist/esm';
|
|
@@ -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_8t6ig","wrapper":"base-modal__wrapper_8t6ig","content":"base-modal__content_8t6ig","hidden":"base-modal__hidden_8t6ig","backdrop":"base-modal__backdrop_8t6ig","appear":"base-modal__appear_8t6ig","enter":"base-modal__enter_8t6ig","appearActive":"base-modal__appearActive_8t6ig","enterActive":"base-modal__enterActive_8t6ig","exit":"base-modal__exit_8t6ig","exitActive":"base-modal__exitActive_8t6ig","exitDone":"base-modal__exitDone_8t6ig"};
|
|
41
41
|
require('./index.css')
|
|
42
42
|
|
|
43
43
|
var BaseModalContext = React.createContext({
|
|
@@ -53,6 +53,7 @@ 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;
|
|
56
57
|
var BaseModal = forwardRef(function (_a, ref) {
|
|
57
58
|
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;
|
|
58
59
|
var _o = useState(!open), exited = _o[0], setExited = _o[1];
|
|
@@ -67,6 +68,7 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
67
68
|
var scrollableNodeRef = useRef(null);
|
|
68
69
|
var contentNodeRef = useRef(null);
|
|
69
70
|
var restoreContainerStylesRef = useRef(null);
|
|
71
|
+
var mouseDownTarget = useRef();
|
|
70
72
|
var checkToHasScrollBar = function () {
|
|
71
73
|
if (scrollableNodeRef.current) {
|
|
72
74
|
var scrollExists = hasScrollbar(scrollableNodeRef.current);
|
|
@@ -120,8 +122,15 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
120
122
|
}
|
|
121
123
|
return null;
|
|
122
124
|
}, [onBackdropClick, onClose, onEscapeKeyDown]);
|
|
123
|
-
var
|
|
124
|
-
if (!disableBackdropClick
|
|
125
|
+
var handleBackdropMouseDown = function (event) {
|
|
126
|
+
if (!disableBackdropClick) {
|
|
127
|
+
mouseDownTarget.current = event.target;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
var handleBackdropMouseUp = function (event) {
|
|
131
|
+
if (!disableBackdropClick &&
|
|
132
|
+
event.target === wrapperRef.current &&
|
|
133
|
+
mouseDownTarget.current === wrapperRef.current) {
|
|
125
134
|
handleClose(event, 'backdropClick');
|
|
126
135
|
}
|
|
127
136
|
};
|
|
@@ -231,7 +240,7 @@ var BaseModal = forwardRef(function (_a, ref) {
|
|
|
231
240
|
} }))),
|
|
232
241
|
React.createElement("div", { role: 'dialog', className: cn(styles.wrapper, wrapperClassName, (_a = {},
|
|
233
242
|
_a[styles.hidden] = !open && exited,
|
|
234
|
-
_a)), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown,
|
|
243
|
+
_a)), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
235
244
|
zIndex: computedZIndex,
|
|
236
245
|
} },
|
|
237
246
|
React.createElement(CSSTransition, __assign({ appear: true, timeout: 200, classNames: styles }, transitionProps, { in: open, onEntered: handleEntered, onExited: handleExited }),
|
package/dist/esm/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: a8jqp */
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_8t6ig {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_8t6ig,
|
|
47
|
+
.base-modal__enter_8t6ig {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_8t6ig,
|
|
51
|
+
.base-modal__enterActive_8t6ig {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_8t6ig {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_8t6ig,
|
|
59
|
+
.base-modal__exitDone_8t6ig {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { BaseModal, BaseModalContext } from './Component.js';
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
import 'react-merge-refs';
|
|
5
|
-
import 'resize-observer';
|
|
5
|
+
import '@juggle/resize-observer';
|
|
6
6
|
import 'react-transition-group';
|
|
7
7
|
import 'react-focus-lock';
|
|
8
8
|
import '@alfalab/core-components-portal/dist/esm';
|
package/dist/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: a8jqp */
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_8t6ig {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_8t6ig,
|
|
47
|
+
.base-modal__enter_8t6ig {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_8t6ig,
|
|
51
|
+
.base-modal__enterActive_8t6ig {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_8t6ig {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_8t6ig,
|
|
59
|
+
.base-modal__exitDone_8t6ig {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var Component = require('./Component.js');
|
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('react-merge-refs');
|
|
9
|
-
require('resize-observer');
|
|
9
|
+
require('@juggle/resize-observer');
|
|
10
10
|
require('react-transition-group');
|
|
11
11
|
require('react-focus-lock');
|
|
12
12
|
require('@alfalab/core-components-portal');
|
package/dist/modern/Component.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useState, useRef, useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
|
-
import { ResizeObserver } from 'resize-observer';
|
|
4
|
+
import { ResizeObserver as ResizeObserver$1 } from '@juggle/resize-observer';
|
|
5
5
|
import { CSSTransition } from 'react-transition-group';
|
|
6
6
|
import FocusLock from 'react-focus-lock';
|
|
7
7
|
import { Portal } from '@alfalab/core-components-portal/dist/modern';
|
|
@@ -10,7 +10,7 @@ import { stackingOrder, Stack } from '@alfalab/core-components-stack/dist/modern
|
|
|
10
10
|
import '@alfalab/core-components-global-store/dist/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_8t6ig","wrapper":"base-modal__wrapper_8t6ig","content":"base-modal__content_8t6ig","hidden":"base-modal__hidden_8t6ig","backdrop":"base-modal__backdrop_8t6ig","appear":"base-modal__appear_8t6ig","enter":"base-modal__enter_8t6ig","appearActive":"base-modal__appearActive_8t6ig","enterActive":"base-modal__enterActive_8t6ig","exit":"base-modal__exit_8t6ig","exitActive":"base-modal__exitActive_8t6ig","exitDone":"base-modal__exitDone_8t6ig"};
|
|
14
14
|
require('./index.css')
|
|
15
15
|
|
|
16
16
|
/* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
|
|
@@ -27,6 +27,7 @@ const BaseModalContext = React.createContext({
|
|
|
27
27
|
setHasFooter: () => null,
|
|
28
28
|
onClose: () => null,
|
|
29
29
|
});
|
|
30
|
+
const ResizeObserver = window.ResizeObserver || ResizeObserver$1;
|
|
30
31
|
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) => {
|
|
31
32
|
const [exited, setExited] = useState(!open);
|
|
32
33
|
const [hasScroll, setHasScroll] = useState(false);
|
|
@@ -40,6 +41,7 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
40
41
|
const scrollableNodeRef = useRef(null);
|
|
41
42
|
const contentNodeRef = useRef(null);
|
|
42
43
|
const restoreContainerStylesRef = useRef(null);
|
|
44
|
+
const mouseDownTarget = useRef();
|
|
43
45
|
const checkToHasScrollBar = () => {
|
|
44
46
|
if (scrollableNodeRef.current) {
|
|
45
47
|
const scrollExists = hasScrollbar(scrollableNodeRef.current);
|
|
@@ -93,8 +95,15 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
93
95
|
}
|
|
94
96
|
return null;
|
|
95
97
|
}, [onBackdropClick, onClose, onEscapeKeyDown]);
|
|
96
|
-
const
|
|
97
|
-
if (!disableBackdropClick
|
|
98
|
+
const handleBackdropMouseDown = (event) => {
|
|
99
|
+
if (!disableBackdropClick) {
|
|
100
|
+
mouseDownTarget.current = event.target;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const handleBackdropMouseUp = (event) => {
|
|
104
|
+
if (!disableBackdropClick &&
|
|
105
|
+
event.target === wrapperRef.current &&
|
|
106
|
+
mouseDownTarget.current === wrapperRef.current) {
|
|
98
107
|
handleClose(event, 'backdropClick');
|
|
99
108
|
}
|
|
100
109
|
};
|
|
@@ -202,7 +211,7 @@ const BaseModal = forwardRef(({ open, container, children, scrollHandler = 'wrap
|
|
|
202
211
|
} }))),
|
|
203
212
|
React.createElement("div", { role: 'dialog', className: cn(styles.wrapper, wrapperClassName, {
|
|
204
213
|
[styles.hidden]: !open && exited,
|
|
205
|
-
}), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown,
|
|
214
|
+
}), ref: mergeRefs([ref, wrapperRef]), onKeyDown: handleKeyDown, onMouseDown: handleBackdropMouseDown, onMouseUp: handleBackdropMouseUp, tabIndex: -1, "data-test-id": dataTestId, style: {
|
|
206
215
|
zIndex: computedZIndex,
|
|
207
216
|
} },
|
|
208
217
|
React.createElement(CSSTransition, Object.assign({ appear: true, timeout: 200, classNames: styles }, transitionProps, { in: open, onEntered: handleEntered, onExited: handleExited }),
|
package/dist/modern/index.css
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* hash:
|
|
1
|
+
/* hash: a8jqp */
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
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_8t6ig {
|
|
41
41
|
display: none;
|
|
42
42
|
}
|
|
43
|
-
.base-
|
|
43
|
+
.base-modal__backdrop_8t6ig {
|
|
44
44
|
z-index: 0;
|
|
45
45
|
}
|
|
46
|
-
.base-
|
|
47
|
-
.base-
|
|
46
|
+
.base-modal__appear_8t6ig,
|
|
47
|
+
.base-modal__enter_8t6ig {
|
|
48
48
|
opacity: 0;
|
|
49
49
|
}
|
|
50
|
-
.base-
|
|
51
|
-
.base-
|
|
50
|
+
.base-modal__appearActive_8t6ig,
|
|
51
|
+
.base-modal__enterActive_8t6ig {
|
|
52
52
|
opacity: 1;
|
|
53
53
|
transition: opacity 200ms ease-in;
|
|
54
54
|
}
|
|
55
|
-
.base-
|
|
55
|
+
.base-modal__exit_8t6ig {
|
|
56
56
|
opacity: 1;
|
|
57
57
|
}
|
|
58
|
-
.base-
|
|
59
|
-
.base-
|
|
58
|
+
.base-modal__exitActive_8t6ig,
|
|
59
|
+
.base-modal__exitDone_8t6ig {
|
|
60
60
|
opacity: 0;
|
|
61
61
|
transition: opacity 200ms ease-out;
|
|
62
62
|
}
|
package/dist/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-base-modal",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "BaseModal component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-backdrop": "^2.0
|
|
18
|
+
"@alfalab/core-components-backdrop": "^2.1.0",
|
|
19
19
|
"@alfalab/core-components-global-store": "^1.1.1",
|
|
20
|
-
"@alfalab/core-components-portal": "^2.0.
|
|
21
|
-
"@alfalab/core-components-stack": "^3.0.
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"react-
|
|
25
|
-
"react-
|
|
26
|
-
"
|
|
20
|
+
"@alfalab/core-components-portal": "^2.0.3",
|
|
21
|
+
"@alfalab/core-components-stack": "^3.0.3",
|
|
22
|
+
"@juggle/resize-observer": "^3.3.1",
|
|
23
|
+
"classnames": "^2.2.6",
|
|
24
|
+
"react-focus-lock": "^2.5.0",
|
|
25
|
+
"react-merge-refs": "^1.1.0",
|
|
26
|
+
"react-transition-group": "^4.4.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/react-transition-group": "^4.2.4"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.9.0 || ^17.0.1"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "a1e54f5b2894447f4a6c80347706c27f855d5710"
|
|
35
35
|
}
|