react-science 0.24.1 → 0.24.3
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/README.md +1 -1
- package/lib/components/hooks/useOnClickOutside.js +2 -0
- package/lib/components/modal/ConfirmModal.js +16 -7
- package/lib/components/modal/Modal.js +14 -5
- package/lib/components/modal/useDialog.js +15 -6
- package/lib/components/root-layout/Portal.js +3 -0
- package/lib/components/root-layout/RootLayoutContext.js +2 -4
- package/lib/components/split-pane/SplitPane.js +1 -0
- package/lib-esm/components/hooks/useOnClickOutside.d.ts.map +1 -1
- package/lib-esm/components/hooks/useOnClickOutside.js +2 -0
- package/lib-esm/components/hooks/useOnClickOutside.js.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.d.ts.map +1 -1
- package/lib-esm/components/modal/ConfirmModal.js +16 -7
- package/lib-esm/components/modal/ConfirmModal.js.map +1 -1
- package/lib-esm/components/modal/Modal.d.ts.map +1 -1
- package/lib-esm/components/modal/Modal.js +14 -5
- package/lib-esm/components/modal/Modal.js.map +1 -1
- package/lib-esm/components/modal/useDialog.d.ts +3 -3
- package/lib-esm/components/modal/useDialog.d.ts.map +1 -1
- package/lib-esm/components/modal/useDialog.js +16 -7
- package/lib-esm/components/modal/useDialog.js.map +1 -1
- package/lib-esm/components/root-layout/Portal.d.ts +1 -1
- package/lib-esm/components/root-layout/Portal.d.ts.map +1 -1
- package/lib-esm/components/root-layout/Portal.js +3 -0
- package/lib-esm/components/root-layout/Portal.js.map +1 -1
- package/lib-esm/components/root-layout/RootLayoutContext.d.ts +1 -1
- package/lib-esm/components/root-layout/RootLayoutContext.d.ts.map +1 -1
- package/lib-esm/components/root-layout/RootLayoutContext.js +2 -4
- package/lib-esm/components/root-layout/RootLayoutContext.js.map +1 -1
- package/lib-esm/components/split-pane/SplitPane.d.ts.map +1 -1
- package/lib-esm/components/split-pane/SplitPane.js +1 -0
- package/lib-esm/components/split-pane/SplitPane.js.map +1 -1
- package/package.json +2 -2
- package/src/components/hooks/useOnClickOutside.ts +2 -0
- package/src/components/modal/ConfirmModal.tsx +46 -28
- package/src/components/modal/Modal.tsx +29 -11
- package/src/components/modal/useDialog.ts +20 -7
- package/src/components/root-layout/Portal.tsx +3 -0
- package/src/components/root-layout/RootLayoutContext.tsx +6 -5
- package/src/components/split-pane/SplitPane.tsx +1 -0
package/README.md
CHANGED
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ConfirmModal = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
+
const react_1 = require("react");
|
|
9
10
|
const __1 = require("..");
|
|
10
11
|
const Portal_1 = require("../root-layout/Portal");
|
|
12
|
+
const RootLayoutContext_1 = require("../root-layout/RootLayoutContext");
|
|
11
13
|
const useDialog_1 = require("./useDialog");
|
|
12
14
|
const ConfirmModalDialog = styled_1.default.dialog `
|
|
13
15
|
background-color: transparent;
|
|
@@ -42,21 +44,28 @@ const ConfirmModalFooter = styled_1.default.div `
|
|
|
42
44
|
`;
|
|
43
45
|
function ConfirmModal(props) {
|
|
44
46
|
const { isOpen, saveText = 'Save', cancelText = 'Cancel', headerColor, maxWidth, onRequestClose, onCancel = onRequestClose, onConfirm, requestCloseOnBackdrop = true, requestCloseOnEsc = true, children, } = props;
|
|
47
|
+
const dialogRef = (0, react_1.useRef)(null);
|
|
45
48
|
const dialogProps = (0, useDialog_1.useDialog)({
|
|
49
|
+
dialogRef,
|
|
46
50
|
isOpen,
|
|
47
51
|
requestCloseOnEsc,
|
|
48
52
|
requestCloseOnBackdrop,
|
|
49
53
|
onRequestClose,
|
|
50
54
|
});
|
|
55
|
+
const [portalDomNode, setPortalDomNode] = (0, react_1.useState)(null);
|
|
56
|
+
const dialogCallbackRef = (0, react_1.useCallback)((node) => {
|
|
57
|
+
setPortalDomNode(node);
|
|
58
|
+
}, []);
|
|
59
|
+
(0, react_1.useImperativeHandle)(dialogCallbackRef, () => dialogRef.current);
|
|
51
60
|
if (!isOpen) {
|
|
52
61
|
return null;
|
|
53
62
|
}
|
|
54
|
-
return ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)(ConfirmModalDialog, { ...dialogProps, children: (0, jsx_runtime_1.jsxs)(ConfirmModalContents, { headerColor: headerColor, style: { maxWidth }, children: [(0, jsx_runtime_1.jsx)(ConfirmModalChildrenRoot, { headerColor: headerColor, children: children }), (0, jsx_runtime_1.jsxs)(ConfirmModalFooter, { children: [(0, jsx_runtime_1.jsx)(__1.Button, { onClick: onConfirm, backgroundColor: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)(ConfirmModalDialog, { ...dialogProps, ref: dialogRef, children: (0, jsx_runtime_1.jsx)(RootLayoutContext_1.RootLayoutProvider, { innerRef: portalDomNode, children: (0, jsx_runtime_1.jsxs)(ConfirmModalContents, { headerColor: headerColor, style: { maxWidth }, children: [(0, jsx_runtime_1.jsx)(ConfirmModalChildrenRoot, { headerColor: headerColor, children: children }), (0, jsx_runtime_1.jsxs)(ConfirmModalFooter, { children: [(0, jsx_runtime_1.jsx)(__1.Button, { onClick: onConfirm, backgroundColor: {
|
|
64
|
+
basic: 'hsla(243deg, 75%, 58%, 1)',
|
|
65
|
+
hover: 'hsla(245deg, 58%, 50%, 1)',
|
|
66
|
+
}, color: { basic: 'white' }, children: saveText }), (0, jsx_runtime_1.jsx)(__1.Button, { onClick: onCancel, backgroundColor: {
|
|
67
|
+
basic: 'hsla(0deg, 72%, 50%, 1)',
|
|
68
|
+
hover: 'hsla(0deg, 73%, 42%, 1)',
|
|
69
|
+
}, color: { basic: 'white' }, children: cancelText })] })] }) }) }) }));
|
|
61
70
|
}
|
|
62
71
|
exports.ConfirmModal = ConfirmModal;
|
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Modal = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
9
|
+
const react_1 = require("react");
|
|
9
10
|
const Portal_1 = require("../root-layout/Portal");
|
|
11
|
+
const RootLayoutContext_1 = require("../root-layout/RootLayoutContext");
|
|
10
12
|
const ModalCloseButton_1 = __importDefault(require("./ModalCloseButton"));
|
|
11
13
|
const useDialog_1 = require("./useDialog");
|
|
12
14
|
const DialogRoot = styled_1.default.dialog `
|
|
@@ -44,20 +46,27 @@ const ModalFooterStyled = styled_1.default.div `
|
|
|
44
46
|
`;
|
|
45
47
|
function Modal(props) {
|
|
46
48
|
const { isOpen, onRequestClose, hasCloseButton = true, requestCloseOnBackdrop = true, requestCloseOnEsc = true, children, width, maxWidth, height, } = props;
|
|
49
|
+
const dialogRef = (0, react_1.useRef)(null);
|
|
47
50
|
const dialogProps = (0, useDialog_1.useDialog)({
|
|
51
|
+
dialogRef,
|
|
48
52
|
isOpen,
|
|
49
53
|
requestCloseOnEsc,
|
|
50
54
|
requestCloseOnBackdrop,
|
|
51
55
|
onRequestClose,
|
|
52
56
|
});
|
|
57
|
+
const [portalDomNode, setPortalDomNode] = (0, react_1.useState)(null);
|
|
58
|
+
const dialogCallbackRef = (0, react_1.useCallback)((node) => {
|
|
59
|
+
setPortalDomNode(node);
|
|
60
|
+
}, []);
|
|
61
|
+
(0, react_1.useImperativeHandle)(dialogCallbackRef, () => dialogRef.current);
|
|
53
62
|
if (!isOpen) {
|
|
54
63
|
return null;
|
|
55
64
|
}
|
|
56
|
-
return ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)(DialogRoot, { ...dialogProps, children: (0, jsx_runtime_1.jsxs)(DialogContents, { style: {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)(Portal_1.Portal, { children: (0, jsx_runtime_1.jsx)(DialogRoot, { ...dialogProps, ref: dialogRef, children: (0, jsx_runtime_1.jsx)(RootLayoutContext_1.RootLayoutProvider, { innerRef: portalDomNode, children: (0, jsx_runtime_1.jsxs)(DialogContents, { style: {
|
|
66
|
+
maxWidth,
|
|
67
|
+
height: height || 'max-content',
|
|
68
|
+
width: width || '100%',
|
|
69
|
+
}, children: [children, hasCloseButton && (0, jsx_runtime_1.jsx)(ModalCloseButton_1.default, { onClick: onRequestClose })] }) }) }) }));
|
|
61
70
|
}
|
|
62
71
|
exports.Modal = Modal;
|
|
63
72
|
Modal.Header = function ModalHeader(props) {
|
|
@@ -3,16 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useDialog = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const react_kbs_1 = require("react-kbs");
|
|
6
|
-
function useDialog({ isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }) {
|
|
6
|
+
function useDialog({ dialogRef, isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }) {
|
|
7
7
|
(0, react_kbs_1.useKbsDisableGlobal)(isOpen);
|
|
8
|
-
const dialogRef = (0, react_1.useRef)(null);
|
|
9
8
|
(0, react_1.useEffect)(() => {
|
|
10
9
|
const dialog = dialogRef.current;
|
|
11
10
|
if (dialog && isOpen) {
|
|
12
11
|
dialog.showModal();
|
|
13
12
|
return () => dialog.close();
|
|
14
13
|
}
|
|
15
|
-
}, [isOpen]);
|
|
14
|
+
}, [dialogRef, isOpen]);
|
|
16
15
|
const onCancel = (0, react_1.useCallback)((event) => {
|
|
17
16
|
event.preventDefault();
|
|
18
17
|
if (requestCloseOnEsc && onRequestClose) {
|
|
@@ -20,13 +19,23 @@ function useDialog({ isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onReques
|
|
|
20
19
|
}
|
|
21
20
|
}, [onRequestClose, requestCloseOnEsc]);
|
|
22
21
|
const onClick = (0, react_1.useCallback)((event) => {
|
|
22
|
+
const dialog = dialogRef.current;
|
|
23
|
+
if (!dialog) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// Ref: https://stackoverflow.com/questions/25864259/how-to-close-the-new-html-dialog-tag-by-clicking-on-its-backdrop
|
|
27
|
+
const rect = dialog.getBoundingClientRect();
|
|
28
|
+
const isInDialog = rect.top <= event.clientY &&
|
|
29
|
+
event.clientY <= rect.top + rect.height &&
|
|
30
|
+
rect.left <= event.clientX &&
|
|
31
|
+
event.clientX <= rect.left + rect.width;
|
|
23
32
|
event.stopPropagation();
|
|
24
33
|
// Since the dialog has no size of itself, this condition is only
|
|
25
34
|
// `true` when we click on the backdrop.
|
|
26
|
-
if (
|
|
35
|
+
if (!isInDialog && requestCloseOnBackdrop) {
|
|
27
36
|
onRequestClose?.();
|
|
28
37
|
}
|
|
29
|
-
}, [requestCloseOnBackdrop, onRequestClose]);
|
|
30
|
-
return {
|
|
38
|
+
}, [dialogRef, requestCloseOnBackdrop, onRequestClose]);
|
|
39
|
+
return { onClick, onCancel };
|
|
31
40
|
}
|
|
32
41
|
exports.useDialog = useDialog;
|
|
@@ -5,6 +5,9 @@ const react_dom_1 = require("react-dom");
|
|
|
5
5
|
const RootLayoutContext_1 = require("./RootLayoutContext");
|
|
6
6
|
function Portal(props) {
|
|
7
7
|
const element = (0, RootLayoutContext_1.useRootLayoutContext)();
|
|
8
|
+
if (element === null) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
8
11
|
return (0, react_dom_1.createPortal)(props.children, element);
|
|
9
12
|
}
|
|
10
13
|
exports.Portal = Portal;
|
|
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RootLayoutProvider = exports.useRootLayoutContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const defaultPortalContext = typeof document === 'undefined' ? null : document.body;
|
|
7
|
+
const rootLayoutContext = (0, react_1.createContext)(defaultPortalContext);
|
|
7
8
|
function useRootLayoutContext() {
|
|
8
9
|
const context = (0, react_1.useContext)(rootLayoutContext);
|
|
9
|
-
if (!context) {
|
|
10
|
-
throw new Error('RootLayoutContext was not found');
|
|
11
|
-
}
|
|
12
10
|
return context;
|
|
13
11
|
}
|
|
14
12
|
exports.useRootLayoutContext = useRootLayoutContext;
|
|
@@ -86,6 +86,7 @@ function SplitPane(props) {
|
|
|
86
86
|
display: 'flex',
|
|
87
87
|
height: '100%',
|
|
88
88
|
width: '100%',
|
|
89
|
+
[direction === 'horizontal' ? 'minWidth' : 'minHeight']: 0,
|
|
89
90
|
flexDirection: direction === 'horizontal' ? 'row' : 'column',
|
|
90
91
|
}, children: [(0, jsx_runtime_1.jsx)(SplitSide, { style: getSplitSideStyle('start'), children: children[0] }), (0, jsx_runtime_1.jsx)(Splitter, { onDoubleClick: handleToggle, onMouseDown: isFinalClosed ? undefined : onMouseDown, isFinalClosed: isFinalClosed, direction: direction, splitterRef: splitterRef }), (0, jsx_runtime_1.jsx)(SplitSide, { style: getSplitSideStyle('end'), children: children[1] })] }));
|
|
91
92
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOnClickOutside.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useOnClickOutside.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAI7C,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EACrD,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"useOnClickOutside.d.ts","sourceRoot":"","sources":["../../../src/components/hooks/useOnClickOutside.ts"],"names":[],"mappings":"A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":"useOnClickOutside.js","sourceRoot":"","sources":["../../../src/components/hooks/useOnClickOutside.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,UAAU,iBAAiB,CAC/B,GAAiB,EACjB,OAA+B;IAE/B,MAAM,aAAa,GAAG,oBAAoB,EAAE,CAAC;IAE7C,SAAS,CAAC,GAAG,EAAE;QACb,8DAA8D;QAC9D,MAAM,QAAQ,GAAG,CAAC,KAAU,EAAE,EAAE;YAC9B,8DAA8D;YAC9D,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBACtD,OAAO;aACR;YAED,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC;QAEF,IAAI,aAAa,KAAK,IAAI;YAAE,OAAO;QAEnC,aAAa,CAAC,gBAAgB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACtD,aAAa,CAAC,gBAAgB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,GAAG,EAAE;YACV,aAAa,CAAC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YACzD,aAAa,CAAC,mBAAmB,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmModal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAyCD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kDA0EpD"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
|
+
import { useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
4
|
import { Button } from '..';
|
|
4
5
|
import { Portal } from '../root-layout/Portal';
|
|
6
|
+
import { RootLayoutProvider } from '../root-layout/RootLayoutContext';
|
|
5
7
|
import { useDialog } from './useDialog';
|
|
6
8
|
const ConfirmModalDialog = styled.dialog `
|
|
7
9
|
background-color: transparent;
|
|
@@ -36,21 +38,28 @@ const ConfirmModalFooter = styled.div `
|
|
|
36
38
|
`;
|
|
37
39
|
export function ConfirmModal(props) {
|
|
38
40
|
const { isOpen, saveText = 'Save', cancelText = 'Cancel', headerColor, maxWidth, onRequestClose, onCancel = onRequestClose, onConfirm, requestCloseOnBackdrop = true, requestCloseOnEsc = true, children, } = props;
|
|
41
|
+
const dialogRef = useRef(null);
|
|
39
42
|
const dialogProps = useDialog({
|
|
43
|
+
dialogRef,
|
|
40
44
|
isOpen,
|
|
41
45
|
requestCloseOnEsc,
|
|
42
46
|
requestCloseOnBackdrop,
|
|
43
47
|
onRequestClose,
|
|
44
48
|
});
|
|
49
|
+
const [portalDomNode, setPortalDomNode] = useState(null);
|
|
50
|
+
const dialogCallbackRef = useCallback((node) => {
|
|
51
|
+
setPortalDomNode(node);
|
|
52
|
+
}, []);
|
|
53
|
+
useImperativeHandle(dialogCallbackRef, () => dialogRef.current);
|
|
45
54
|
if (!isOpen) {
|
|
46
55
|
return null;
|
|
47
56
|
}
|
|
48
|
-
return (_jsx(Portal, { children: _jsx(ConfirmModalDialog, { ...dialogProps, children: _jsxs(ConfirmModalContents, { headerColor: headerColor, style: { maxWidth }, children: [_jsx(ConfirmModalChildrenRoot, { headerColor: headerColor, children: children }), _jsxs(ConfirmModalFooter, { children: [_jsx(Button, { onClick: onConfirm, backgroundColor: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
57
|
+
return (_jsx(Portal, { children: _jsx(ConfirmModalDialog, { ...dialogProps, ref: dialogRef, children: _jsx(RootLayoutProvider, { innerRef: portalDomNode, children: _jsxs(ConfirmModalContents, { headerColor: headerColor, style: { maxWidth }, children: [_jsx(ConfirmModalChildrenRoot, { headerColor: headerColor, children: children }), _jsxs(ConfirmModalFooter, { children: [_jsx(Button, { onClick: onConfirm, backgroundColor: {
|
|
58
|
+
basic: 'hsla(243deg, 75%, 58%, 1)',
|
|
59
|
+
hover: 'hsla(245deg, 58%, 50%, 1)',
|
|
60
|
+
}, color: { basic: 'white' }, children: saveText }), _jsx(Button, { onClick: onCancel, backgroundColor: {
|
|
61
|
+
basic: 'hsla(0deg, 72%, 50%, 1)',
|
|
62
|
+
hover: 'hsla(0deg, 73%, 42%, 1)',
|
|
63
|
+
}, color: { basic: 'white' }, children: cancelText })] })] }) }) }) }));
|
|
55
64
|
}
|
|
56
65
|
//# sourceMappingURL=ConfirmModal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmModal.js","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConfirmModal.js","sourceRoot":"","sources":["../../../src/components/modal/ConfirmModal.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgBxC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAA;;;;;;CAMvC,CAAC;AAEF,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAErC;;;;;;;;;;2BAUyB,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;CAC1D,CAAC;AAEF,MAAM,wBAAwB,GAAG,MAAM,CAAC,GAAG,CAAyB;WACzD,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,WAAW;;;CAG1C,CAAC;AAEF,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;CAMpC,CAAC;AAIF,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EACJ,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,UAAU,GAAG,QAAQ,EACrB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,QAAQ,GAAG,cAAc,EACzB,SAAS,EACT,sBAAsB,GAAG,IAAI,EAC7B,iBAAiB,GAAG,IAAI,EACxB,QAAQ,GACT,GAAG,KAAK,C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ACV,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASrD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA0CD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,kDAsDtC;yBAtDe,KAAK"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styled from '@emotion/styled';
|
|
3
|
+
import { useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
4
|
import { Portal } from '../root-layout/Portal';
|
|
5
|
+
import { RootLayoutProvider } from '../root-layout/RootLayoutContext';
|
|
4
6
|
import ModalCloseButton from './ModalCloseButton';
|
|
5
7
|
import { useDialog } from './useDialog';
|
|
6
8
|
const DialogRoot = styled.dialog `
|
|
@@ -38,20 +40,27 @@ const ModalFooterStyled = styled.div `
|
|
|
38
40
|
`;
|
|
39
41
|
export function Modal(props) {
|
|
40
42
|
const { isOpen, onRequestClose, hasCloseButton = true, requestCloseOnBackdrop = true, requestCloseOnEsc = true, children, width, maxWidth, height, } = props;
|
|
43
|
+
const dialogRef = useRef(null);
|
|
41
44
|
const dialogProps = useDialog({
|
|
45
|
+
dialogRef,
|
|
42
46
|
isOpen,
|
|
43
47
|
requestCloseOnEsc,
|
|
44
48
|
requestCloseOnBackdrop,
|
|
45
49
|
onRequestClose,
|
|
46
50
|
});
|
|
51
|
+
const [portalDomNode, setPortalDomNode] = useState(null);
|
|
52
|
+
const dialogCallbackRef = useCallback((node) => {
|
|
53
|
+
setPortalDomNode(node);
|
|
54
|
+
}, []);
|
|
55
|
+
useImperativeHandle(dialogCallbackRef, () => dialogRef.current);
|
|
47
56
|
if (!isOpen) {
|
|
48
57
|
return null;
|
|
49
58
|
}
|
|
50
|
-
return (_jsx(Portal, { children: _jsx(DialogRoot, { ...dialogProps, children: _jsxs(DialogContents, { style: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
return (_jsx(Portal, { children: _jsx(DialogRoot, { ...dialogProps, ref: dialogRef, children: _jsx(RootLayoutProvider, { innerRef: portalDomNode, children: _jsxs(DialogContents, { style: {
|
|
60
|
+
maxWidth,
|
|
61
|
+
height: height || 'max-content',
|
|
62
|
+
width: width || '100%',
|
|
63
|
+
}, children: [children, hasCloseButton && _jsx(ModalCloseButton, { onClick: onRequestClose })] }) }) }) }));
|
|
55
64
|
}
|
|
56
65
|
Modal.Header = function ModalHeader(props) {
|
|
57
66
|
return _jsx(ModalHeaderStyled, { children: props.children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":";AAAA,OA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B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,mBAAmB,CACjB,iBAAiB,EACjB,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CACxB,CAAC;IAEF,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,KAAC,MAAM,cACL,KAAC,UAAU,OAAK,WAAW,EAAE,GAAG,EAAE,SAAS,YACzC,KAAC,kBAAkB,IAAC,QAAQ,EAAE,aAAa,YACzC,MAAC,cAAc,IACb,KAAK,EAAE;wBACL,QAAQ;wBACR,MAAM,EAAE,MAAM,IAAI,aAAa;wBAC/B,KAAK,EAAE,KAAK,IAAI,MAAM;qBACvB,aAEA,QAAQ,EACR,cAAc,IAAI,KAAC,gBAAgB,IAAC,OAAO,EAAE,cAAc,GAAI,IACjD,GACE,GACV,GACN,CACV,CAAC;AACJ,CAAC;AAED,KAAK,CAAC,MAAM,GAAG,SAAS,WAAW,CAAC,KAA8B;IAChE,OAAO,KAAC,iBAAiB,cAAE,KAAK,CAAC,QAAQ,GAAqB,CAAC;AACjE,CAAC,CAAC;AAEF,KAAK,CAAC,IAAI,GAAG,SAAS,SAAS,CAAC,KAA8B;IAC5D,OAAO,KAAC,eAAe,cAAE,KAAK,CAAC,QAAQ,GAAmB,CAAC;AAC7D,CAAC,CAAC;AAEF,KAAK,CAAC,MAAM,GAAG,SAAS,WAAW,CAAC,KAA8B;IAChE,OAAO,KAAC,iBAAiB,cAAE,KAAK,CAAC,QAAQ,GAAqB,CAAC;AACjE,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { MouseEventHandler, ReactEventHandler } from 'react';
|
|
2
|
-
export declare function useDialog({ isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }: {
|
|
1
|
+
import { MouseEventHandler, ReactEventHandler, RefObject } from 'react';
|
|
2
|
+
export declare function useDialog({ dialogRef, isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }: {
|
|
3
|
+
dialogRef: RefObject<HTMLDialogElement>;
|
|
3
4
|
isOpen: boolean;
|
|
4
5
|
requestCloseOnEsc: boolean;
|
|
5
6
|
requestCloseOnBackdrop: boolean;
|
|
6
7
|
onRequestClose?: () => void;
|
|
7
8
|
}): {
|
|
8
|
-
ref: import("react").RefObject<HTMLDialogElement>;
|
|
9
9
|
onClick: MouseEventHandler<HTMLDialogElement>;
|
|
10
10
|
onCancel: ReactEventHandler<HTMLDialogElement>;
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialog.d.ts","sourceRoot":"","sources":["../../../src/components/modal/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useDialog.d.ts","sourceRoot":"","sources":["../../../src/components/modal/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,SAAS,EAGV,MAAM,OAAO,CAAC;AAGf,wBAAgB,SAAS,CAAC,EACxB,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GACf,EAAE;IACD,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACxC,MAAM,EAAE,OAAO,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;;;EA+CA"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { useCallback, useEffect,
|
|
1
|
+
import { useCallback, useEffect, } from 'react';
|
|
2
2
|
import { useKbsDisableGlobal } from 'react-kbs';
|
|
3
|
-
export function useDialog({ isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }) {
|
|
3
|
+
export function useDialog({ dialogRef, isOpen, requestCloseOnEsc, requestCloseOnBackdrop, onRequestClose, }) {
|
|
4
4
|
useKbsDisableGlobal(isOpen);
|
|
5
|
-
const dialogRef = useRef(null);
|
|
6
5
|
useEffect(() => {
|
|
7
6
|
const dialog = dialogRef.current;
|
|
8
7
|
if (dialog && isOpen) {
|
|
9
8
|
dialog.showModal();
|
|
10
9
|
return () => dialog.close();
|
|
11
10
|
}
|
|
12
|
-
}, [isOpen]);
|
|
11
|
+
}, [dialogRef, isOpen]);
|
|
13
12
|
const onCancel = useCallback((event) => {
|
|
14
13
|
event.preventDefault();
|
|
15
14
|
if (requestCloseOnEsc && onRequestClose) {
|
|
@@ -17,13 +16,23 @@ export function useDialog({ isOpen, requestCloseOnEsc, requestCloseOnBackdrop, o
|
|
|
17
16
|
}
|
|
18
17
|
}, [onRequestClose, requestCloseOnEsc]);
|
|
19
18
|
const onClick = useCallback((event) => {
|
|
19
|
+
const dialog = dialogRef.current;
|
|
20
|
+
if (!dialog) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
// Ref: https://stackoverflow.com/questions/25864259/how-to-close-the-new-html-dialog-tag-by-clicking-on-its-backdrop
|
|
24
|
+
const rect = dialog.getBoundingClientRect();
|
|
25
|
+
const isInDialog = rect.top <= event.clientY &&
|
|
26
|
+
event.clientY <= rect.top + rect.height &&
|
|
27
|
+
rect.left <= event.clientX &&
|
|
28
|
+
event.clientX <= rect.left + rect.width;
|
|
20
29
|
event.stopPropagation();
|
|
21
30
|
// Since the dialog has no size of itself, this condition is only
|
|
22
31
|
// `true` when we click on the backdrop.
|
|
23
|
-
if (
|
|
32
|
+
if (!isInDialog && requestCloseOnBackdrop) {
|
|
24
33
|
onRequestClose?.();
|
|
25
34
|
}
|
|
26
|
-
}, [requestCloseOnBackdrop, onRequestClose]);
|
|
27
|
-
return {
|
|
35
|
+
}, [dialogRef, requestCloseOnBackdrop, onRequestClose]);
|
|
36
|
+
return { onClick, onCancel };
|
|
28
37
|
}
|
|
29
38
|
//# sourceMappingURL=useDialog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDialog.js","sourceRoot":"","sources":["../../../src/components/modal/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useDialog.js","sourceRoot":"","sources":["../../../src/components/modal/useDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,SAAS,GACV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAEhD,MAAM,UAAU,SAAS,CAAC,EACxB,SAAS,EACT,MAAM,EACN,iBAAiB,EACjB,sBAAsB,EACtB,cAAc,GAOf;IACC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,MAAM,IAAI,MAAM,EAAE;YACpB,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;SAC7B;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;IAExB,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAAK,EAAE,EAAE;QACR,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,iBAAiB,IAAI,cAAc,EAAE;YACvC,cAAc,EAAE,CAAC;SAClB;IACH,CAAC,EACD,CAAC,cAAc,EAAE,iBAAiB,CAAC,CACpC,CAAC;IAEF,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,KAAK,EAAE,EAAE;QACR,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,MAAM,EAAE;YACX,OAAO;SACR;QAED,qHAAqH;QACrH,MAAM,IAAI,GAAG,MAAM,CAAC,qBAAqB,EAAE,CAAC;QAC5C,MAAM,UAAU,GACd,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO;YACzB,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM;YACvC,IAAI,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO;YAC1B,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QAE1C,KAAK,CAAC,eAAe,EAAE,CAAC;QACxB,iEAAiE;QACjE,wCAAwC;QACxC,IAAI,CAAC,UAAU,IAAI,sBAAsB,EAAE;YACzC,cAAc,EAAE,EAAE,CAAC;SACpB;IACH,CAAC,EACD,CAAC,SAAS,EAAE,sBAAsB,EAAE,cAAc,CAAC,CACpD,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -2,6 +2,6 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
interface PortalProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
}
|
|
5
|
-
export declare function Portal(props: PortalProps): import("react").ReactPortal;
|
|
5
|
+
export declare function Portal(props: PortalProps): import("react").ReactPortal | null;
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=Portal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../../src/components/root-layout/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,UAAU,WAAW;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW
|
|
1
|
+
{"version":3,"file":"Portal.d.ts","sourceRoot":"","sources":["../../../src/components/root-layout/Portal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,UAAU,WAAW;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,sCAMxC"}
|
|
@@ -2,6 +2,9 @@ import { createPortal } from 'react-dom';
|
|
|
2
2
|
import { useRootLayoutContext } from './RootLayoutContext';
|
|
3
3
|
export function Portal(props) {
|
|
4
4
|
const element = useRootLayoutContext();
|
|
5
|
+
if (element === null) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
5
8
|
return createPortal(props.children, element);
|
|
6
9
|
}
|
|
7
10
|
//# sourceMappingURL=Portal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../../src/components/root-layout/Portal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAM3D,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
|
1
|
+
{"version":3,"file":"Portal.js","sourceRoot":"","sources":["../../../src/components/root-layout/Portal.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAM3D,MAAM,UAAU,MAAM,CAAC,KAAkB;IACvC,MAAM,OAAO,GAAG,oBAAoB,EAAE,CAAC;IACvC,IAAI,OAAO,KAAK,IAAI,EAAE;QACpB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,YAAY,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
export declare function useRootLayoutContext(): HTMLElement;
|
|
2
|
+
export declare function useRootLayoutContext(): HTMLElement | null;
|
|
3
3
|
export declare function RootLayoutProvider(props: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
innerRef: HTMLElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootLayoutContext.d.ts","sourceRoot":"","sources":["../../../src/components/root-layout/RootLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RootLayoutContext.d.ts","sourceRoot":"","sources":["../../../src/components/root-layout/RootLayoutContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAc,MAAM,OAAO,CAAC;AAS7D,wBAAgB,oBAAoB,uBAGnC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;CAC9B,2CAMA"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from 'react';
|
|
3
|
-
const
|
|
3
|
+
const defaultPortalContext = typeof document === 'undefined' ? null : document.body;
|
|
4
|
+
const rootLayoutContext = createContext(defaultPortalContext);
|
|
4
5
|
export function useRootLayoutContext() {
|
|
5
6
|
const context = useContext(rootLayoutContext);
|
|
6
|
-
if (!context) {
|
|
7
|
-
throw new Error('RootLayoutContext was not found');
|
|
8
|
-
}
|
|
9
7
|
return context;
|
|
10
8
|
}
|
|
11
9
|
export function RootLayoutProvider(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootLayoutContext.js","sourceRoot":"","sources":["../../../src/components/root-layout/RootLayoutContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAa,UAAU,EAAE,MAAM,OAAO,CAAC;AAE7D,MAAM,
|
|
1
|
+
{"version":3,"file":"RootLayoutContext.js","sourceRoot":"","sources":["../../../src/components/root-layout/RootLayoutContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EA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@ -79,6 +79,7 @@ export function SplitPane(props) {
|
|
|
79
79
|
display: 'flex',
|
|
80
80
|
height: '100%',
|
|
81
81
|
width: '100%',
|
|
82
|
+
[direction === 'horizontal' ? 'minWidth' : 'minHeight']: 0,
|
|
82
83
|
flexDirection: direction === 'horizontal' ? 'row' : 'column',
|
|
83
84
|
}, children: [_jsx(SplitSide, { style: getSplitSideStyle('start'), children: children[0] }), _jsx(Splitter, { onDoubleClick: handleToggle, onMouseDown: isFinalClosed ? undefined : onMouseDown, isFinalClosed: isFinalClosed, direction: direction, splitterRef: splitterRef }), _jsx(SplitSide, { style: getSplitSideStyle('end'), children: children[1] })] }));
|
|
84
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SplitPane.js","sourceRoot":"","sources":["../../../src/components/split-pane/SplitPane.tsx"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAEL,aAAa,EAGb,UAAU,EACV,MAAM,EACN,QAAQ,EAER,UAAU,EACV,SAAS,GACV,MAAM,OAAO,CAAC;AACf,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAqDtD,MAAM,gBAAgB,GAAG,aAAa,CAAU,KAAK,CAAC,CAAC;AAEvD,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EACJ,SAAS,GAAG,YAAY,EACxB,cAAc,GAAG,OAAO,EACxB,IAAI,GAAG,KAAK,EACZ,MAAM,GAAG,KAAK,EACd,QAAQ,EACR,QAAQ,EACR,QAAQ,GACT,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,OAAO,MAAM,K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AAU,IAAI;YAC1B,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;SAC1C;QACD;YACE,eAAe,EAAE,oBAAoB;YACrC,OAAO,EAAE,MAAM;YACf,cAAc,EAAE,QAAQ;YACxB,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,MAAM;YAClB,QAAQ,EAAE,EAAE;YACZ,QAAQ,EAAE;gBACR,eAAe,EAAE,oBAAoB;aACtC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-science",
|
|
3
|
-
"version": "0.24.
|
|
4
|
-
"description": "React components to build
|
|
3
|
+
"version": "0.24.3",
|
|
4
|
+
"description": "React components to build scientific applications UI",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./app": {
|
|
7
7
|
"types": "./lib-esm/app/index.d.ts",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
+
import { useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
4
|
|
|
4
5
|
import { Button } from '..';
|
|
5
6
|
import { Portal } from '../root-layout/Portal';
|
|
7
|
+
import { RootLayoutProvider } from '../root-layout/RootLayoutContext';
|
|
6
8
|
|
|
7
9
|
import { useDialog } from './useDialog';
|
|
8
10
|
|
|
@@ -57,6 +59,8 @@ const ConfirmModalFooter = styled.div`
|
|
|
57
59
|
gap: 10px;
|
|
58
60
|
`;
|
|
59
61
|
|
|
62
|
+
type MaybeHTMLDialogElement = HTMLDialogElement | null;
|
|
63
|
+
|
|
60
64
|
export function ConfirmModal(props: ConfirmModalProps) {
|
|
61
65
|
const {
|
|
62
66
|
isOpen,
|
|
@@ -72,12 +76,24 @@ export function ConfirmModal(props: ConfirmModalProps) {
|
|
|
72
76
|
children,
|
|
73
77
|
} = props;
|
|
74
78
|
|
|
79
|
+
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
75
80
|
const dialogProps = useDialog({
|
|
81
|
+
dialogRef,
|
|
76
82
|
isOpen,
|
|
77
83
|
requestCloseOnEsc,
|
|
78
84
|
requestCloseOnBackdrop,
|
|
79
85
|
onRequestClose,
|
|
80
86
|
});
|
|
87
|
+
const [portalDomNode, setPortalDomNode] =
|
|
88
|
+
useState<MaybeHTMLDialogElement>(null);
|
|
89
|
+
const dialogCallbackRef = useCallback((node: MaybeHTMLDialogElement) => {
|
|
90
|
+
setPortalDomNode(node);
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
useImperativeHandle<MaybeHTMLDialogElement, MaybeHTMLDialogElement>(
|
|
94
|
+
dialogCallbackRef,
|
|
95
|
+
() => dialogRef.current,
|
|
96
|
+
);
|
|
81
97
|
|
|
82
98
|
if (!isOpen) {
|
|
83
99
|
return null;
|
|
@@ -85,35 +101,37 @@ export function ConfirmModal(props: ConfirmModalProps) {
|
|
|
85
101
|
|
|
86
102
|
return (
|
|
87
103
|
<Portal>
|
|
88
|
-
<ConfirmModalDialog {...dialogProps}>
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
{
|
|
92
|
-
|
|
104
|
+
<ConfirmModalDialog {...dialogProps} ref={dialogRef}>
|
|
105
|
+
<RootLayoutProvider innerRef={portalDomNode}>
|
|
106
|
+
<ConfirmModalContents headerColor={headerColor} style={{ maxWidth }}>
|
|
107
|
+
<ConfirmModalChildrenRoot headerColor={headerColor}>
|
|
108
|
+
{children}
|
|
109
|
+
</ConfirmModalChildrenRoot>
|
|
93
110
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
<ConfirmModalFooter>
|
|
112
|
+
<Button
|
|
113
|
+
onClick={onConfirm}
|
|
114
|
+
backgroundColor={{
|
|
115
|
+
basic: 'hsla(243deg, 75%, 58%, 1)',
|
|
116
|
+
hover: 'hsla(245deg, 58%, 50%, 1)',
|
|
117
|
+
}}
|
|
118
|
+
color={{ basic: 'white' }}
|
|
119
|
+
>
|
|
120
|
+
{saveText}
|
|
121
|
+
</Button>
|
|
122
|
+
<Button
|
|
123
|
+
onClick={onCancel}
|
|
124
|
+
backgroundColor={{
|
|
125
|
+
basic: 'hsla(0deg, 72%, 50%, 1)',
|
|
126
|
+
hover: 'hsla(0deg, 73%, 42%, 1)',
|
|
127
|
+
}}
|
|
128
|
+
color={{ basic: 'white' }}
|
|
129
|
+
>
|
|
130
|
+
{cancelText}
|
|
131
|
+
</Button>
|
|
132
|
+
</ConfirmModalFooter>
|
|
133
|
+
</ConfirmModalContents>
|
|
134
|
+
</RootLayoutProvider>
|
|
117
135
|
</ConfirmModalDialog>
|
|
118
136
|
</Portal>
|
|
119
137
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import type { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
3
4
|
|
|
4
5
|
import { Portal } from '../root-layout/Portal';
|
|
6
|
+
import { RootLayoutProvider } from '../root-layout/RootLayoutContext';
|
|
5
7
|
|
|
6
8
|
import ModalCloseButton from './ModalCloseButton';
|
|
7
9
|
import { useDialog } from './useDialog';
|
|
@@ -56,6 +58,8 @@ const ModalFooterStyled = styled.div`
|
|
|
56
58
|
padding: 10px 20px 10px 20px;
|
|
57
59
|
`;
|
|
58
60
|
|
|
61
|
+
type MaybeHTMLDialogElement = HTMLDialogElement | null;
|
|
62
|
+
|
|
59
63
|
export function Modal(props: ModalProps) {
|
|
60
64
|
const {
|
|
61
65
|
isOpen,
|
|
@@ -69,12 +73,24 @@ export function Modal(props: ModalProps) {
|
|
|
69
73
|
height,
|
|
70
74
|
} = props;
|
|
71
75
|
|
|
76
|
+
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
72
77
|
const dialogProps = useDialog({
|
|
78
|
+
dialogRef,
|
|
73
79
|
isOpen,
|
|
74
80
|
requestCloseOnEsc,
|
|
75
81
|
requestCloseOnBackdrop,
|
|
76
82
|
onRequestClose,
|
|
77
83
|
});
|
|
84
|
+
const [portalDomNode, setPortalDomNode] =
|
|
85
|
+
useState<MaybeHTMLDialogElement>(null);
|
|
86
|
+
const dialogCallbackRef = useCallback((node: MaybeHTMLDialogElement) => {
|
|
87
|
+
setPortalDomNode(node);
|
|
88
|
+
}, []);
|
|
89
|
+
|
|
90
|
+
useImperativeHandle<MaybeHTMLDialogElement, MaybeHTMLDialogElement>(
|
|
91
|
+
dialogCallbackRef,
|
|
92
|
+
() => dialogRef.current,
|
|
93
|
+
);
|
|
78
94
|
|
|
79
95
|
if (!isOpen) {
|
|
80
96
|
return null;
|
|
@@ -82,17 +98,19 @@ export function Modal(props: ModalProps) {
|
|
|
82
98
|
|
|
83
99
|
return (
|
|
84
100
|
<Portal>
|
|
85
|
-
<DialogRoot {...dialogProps}>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
<DialogRoot {...dialogProps} ref={dialogRef}>
|
|
102
|
+
<RootLayoutProvider innerRef={portalDomNode}>
|
|
103
|
+
<DialogContents
|
|
104
|
+
style={{
|
|
105
|
+
maxWidth,
|
|
106
|
+
height: height || 'max-content',
|
|
107
|
+
width: width || '100%',
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{children}
|
|
111
|
+
{hasCloseButton && <ModalCloseButton onClick={onRequestClose} />}
|
|
112
|
+
</DialogContents>
|
|
113
|
+
</RootLayoutProvider>
|
|
96
114
|
</DialogRoot>
|
|
97
115
|
</Portal>
|
|
98
116
|
);
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
MouseEventHandler,
|
|
3
3
|
ReactEventHandler,
|
|
4
|
+
RefObject,
|
|
4
5
|
useCallback,
|
|
5
6
|
useEffect,
|
|
6
|
-
useRef,
|
|
7
7
|
} from 'react';
|
|
8
8
|
import { useKbsDisableGlobal } from 'react-kbs';
|
|
9
9
|
|
|
10
10
|
export function useDialog({
|
|
11
|
+
dialogRef,
|
|
11
12
|
isOpen,
|
|
12
13
|
requestCloseOnEsc,
|
|
13
14
|
requestCloseOnBackdrop,
|
|
14
15
|
onRequestClose,
|
|
15
16
|
}: {
|
|
17
|
+
dialogRef: RefObject<HTMLDialogElement>;
|
|
16
18
|
isOpen: boolean;
|
|
17
19
|
requestCloseOnEsc: boolean;
|
|
18
20
|
requestCloseOnBackdrop: boolean;
|
|
@@ -20,15 +22,13 @@ export function useDialog({
|
|
|
20
22
|
}) {
|
|
21
23
|
useKbsDisableGlobal(isOpen);
|
|
22
24
|
|
|
23
|
-
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
24
|
-
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
const dialog = dialogRef.current;
|
|
27
27
|
if (dialog && isOpen) {
|
|
28
28
|
dialog.showModal();
|
|
29
29
|
return () => dialog.close();
|
|
30
30
|
}
|
|
31
|
-
}, [isOpen]);
|
|
31
|
+
}, [dialogRef, isOpen]);
|
|
32
32
|
|
|
33
33
|
const onCancel = useCallback<ReactEventHandler<HTMLDialogElement>>(
|
|
34
34
|
(event) => {
|
|
@@ -42,15 +42,28 @@ export function useDialog({
|
|
|
42
42
|
|
|
43
43
|
const onClick = useCallback<MouseEventHandler<HTMLDialogElement>>(
|
|
44
44
|
(event) => {
|
|
45
|
+
const dialog = dialogRef.current;
|
|
46
|
+
if (!dialog) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Ref: https://stackoverflow.com/questions/25864259/how-to-close-the-new-html-dialog-tag-by-clicking-on-its-backdrop
|
|
51
|
+
const rect = dialog.getBoundingClientRect();
|
|
52
|
+
const isInDialog =
|
|
53
|
+
rect.top <= event.clientY &&
|
|
54
|
+
event.clientY <= rect.top + rect.height &&
|
|
55
|
+
rect.left <= event.clientX &&
|
|
56
|
+
event.clientX <= rect.left + rect.width;
|
|
57
|
+
|
|
45
58
|
event.stopPropagation();
|
|
46
59
|
// Since the dialog has no size of itself, this condition is only
|
|
47
60
|
// `true` when we click on the backdrop.
|
|
48
|
-
if (
|
|
61
|
+
if (!isInDialog && requestCloseOnBackdrop) {
|
|
49
62
|
onRequestClose?.();
|
|
50
63
|
}
|
|
51
64
|
},
|
|
52
|
-
[requestCloseOnBackdrop, onRequestClose],
|
|
65
|
+
[dialogRef, requestCloseOnBackdrop, onRequestClose],
|
|
53
66
|
);
|
|
54
67
|
|
|
55
|
-
return {
|
|
68
|
+
return { onClick, onCancel };
|
|
56
69
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { createContext, ReactNode, useContext } from 'react';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const defaultPortalContext =
|
|
4
|
+
typeof document === 'undefined' ? null : document.body;
|
|
5
|
+
|
|
6
|
+
const rootLayoutContext = createContext<HTMLElement | null>(
|
|
7
|
+
defaultPortalContext,
|
|
8
|
+
);
|
|
4
9
|
|
|
5
10
|
export function useRootLayoutContext() {
|
|
6
11
|
const context = useContext(rootLayoutContext);
|
|
7
|
-
if (!context) {
|
|
8
|
-
throw new Error('RootLayoutContext was not found');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
12
|
return context;
|
|
12
13
|
}
|
|
13
14
|
|