tycho-components 0.14.2 → 0.14.4
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/dist/AppModal/AppModal.d.ts +4 -2
- package/dist/AppModal/AppModal.js +27 -40
- package/dist/AppModal/AppModalConfirm.d.ts +3 -1
- package/dist/AppModal/AppModalConfirm.js +17 -2
- package/dist/AppModal/AppModalRemove.d.ts +3 -1
- package/dist/AppModal/AppModalRemove.js +17 -2
- package/dist/AppModal/AppModalUtils.d.ts +2 -0
- package/dist/AppModal/AppModalUtils.js +17 -0
- package/dist/Comments/Comments.js +1 -3
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './style.scss';
|
|
2
2
|
type Props = {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
title: string;
|
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
hideFooter?: boolean;
|
|
12
12
|
disableCancel?: boolean;
|
|
13
13
|
disableClose?: boolean;
|
|
14
|
+
disableEscapeClose?: boolean;
|
|
14
15
|
confirmLabel?: string;
|
|
15
16
|
closeLabel?: string;
|
|
16
17
|
onEntered?: () => void;
|
|
@@ -20,6 +21,7 @@ type Props = {
|
|
|
20
21
|
};
|
|
21
22
|
alternativeOptions?: React.ReactNode;
|
|
22
23
|
hideBackdrop?: boolean;
|
|
24
|
+
disableBackdropClose?: boolean;
|
|
23
25
|
};
|
|
24
|
-
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableEscapeClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, disableBackdropClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
25
27
|
export {};
|
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Fade, Modal } from
|
|
3
|
-
import cx from
|
|
4
|
-
import { useTranslation } from
|
|
5
|
-
import { Button, Icon } from
|
|
6
|
-
import
|
|
7
|
-
import { useEffect } from
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
e.stopImmediatePropagation?.();
|
|
13
|
-
};
|
|
14
|
-
const attachCloseToEscape = (handleClose) => {
|
|
15
|
-
const closeOnEscape = (e) => {
|
|
16
|
-
if (e.key === "Escape" || e.code === "Escape") {
|
|
17
|
-
stopEventPropagation(e);
|
|
18
|
-
handleClose();
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
// Capture phase makes this resilient if inner components stopPropagation() on Escape.
|
|
22
|
-
window.addEventListener("keydown", closeOnEscape, { capture: true });
|
|
23
|
-
return () => window.removeEventListener("keydown", closeOnEscape, { capture: true });
|
|
24
|
-
};
|
|
25
|
-
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, }) {
|
|
26
|
-
const { t } = useTranslation("common");
|
|
27
|
-
const getClassNames = cx("modal-container", className);
|
|
2
|
+
import { Box, Fade, Modal } from '@mui/material';
|
|
3
|
+
import cx from 'classnames';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Button, Icon } from 'tycho-storybook';
|
|
6
|
+
import './style.scss';
|
|
7
|
+
import { useEffect } from 'react';
|
|
8
|
+
import { attachCloseToEscape, stopEventPropagation } from './AppModalUtils';
|
|
9
|
+
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableEscapeClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, disableBackdropClose, }) {
|
|
10
|
+
const { t } = useTranslation('common');
|
|
11
|
+
const getClassNames = cx('modal-container', className);
|
|
28
12
|
useEffect(() => {
|
|
29
|
-
if (
|
|
13
|
+
if (disableEscapeClose)
|
|
30
14
|
return;
|
|
31
15
|
return attachCloseToEscape(close);
|
|
32
|
-
}, [close,
|
|
33
|
-
return (_jsx(Modal, { open: true, disableEnforceFocus: true, disableAutoFocus: true, disableRestoreFocus: true, hideBackdrop: hideBackdrop, disableEscapeKeyDown: !!
|
|
16
|
+
}, [close, disableEscapeClose]);
|
|
17
|
+
return (_jsx(Modal, { open: true, disableEnforceFocus: true, disableAutoFocus: true, disableRestoreFocus: true, hideBackdrop: hideBackdrop, disableEscapeKeyDown: !!disableEscapeClose, onClose: (event, reason) => {
|
|
34
18
|
stopEventPropagation(event);
|
|
35
|
-
if (
|
|
36
|
-
|
|
19
|
+
if (disableBackdropClose && reason === 'backdropClick')
|
|
20
|
+
return;
|
|
21
|
+
if (disableClose)
|
|
22
|
+
return;
|
|
23
|
+
close();
|
|
37
24
|
}, children: _jsx(Fade, { in: true, onEntered: () => onEntered && onEntered(), children: _jsxs(Box, { className: getClassNames, sx: style, children: [_jsxs("div", { className: "header", children: [_jsxs("div", { className: "titles", children: [_jsx("span", { className: "title", children: title }), subtitle && _jsx("span", { className: "subtitle", children: subtitle })] }), !disableClose && (_jsx(Icon, { name: "close", onClick: (e) => {
|
|
38
25
|
stopEventPropagation(e);
|
|
39
26
|
close();
|
|
40
27
|
}, className: "pointer" }))] }), _jsx("div", { className: "body", children: children }), !hideFooter ? (_jsxs("div", { className: "footer", children: [alternativeOptions && alternativeOptions, alternativeButton && (_jsx(Button, { className: "alternative", color: "white", onClick: alternativeButton.action, text: alternativeButton.title })), !disableCancel && (_jsx(Button, { onClick: (e) => {
|
|
41
28
|
stopEventPropagation(e);
|
|
42
29
|
(cancel || close)();
|
|
43
|
-
}, text: closeLabel || t(
|
|
30
|
+
}, text: closeLabel || t('button.cancel'), color: "danger" })), confirm && (_jsx(Button, { onClick: confirm, disabled: disableConfirm, text: confirmLabel || t('button.confirm') }))] })) : null] }) }) }));
|
|
44
31
|
}
|
|
45
32
|
const style = {
|
|
46
|
-
position:
|
|
47
|
-
top:
|
|
48
|
-
left:
|
|
49
|
-
transform:
|
|
50
|
-
width:
|
|
51
|
-
maxWidth:
|
|
52
|
-
borderRadius:
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
top: '40%',
|
|
35
|
+
left: '50%',
|
|
36
|
+
transform: 'translate(-50%, -50%)',
|
|
37
|
+
width: '50%',
|
|
38
|
+
maxWidth: '1080px',
|
|
39
|
+
borderRadius: 'var(--radius-200)',
|
|
53
40
|
boxShadow: 24,
|
|
54
|
-
bgcolor:
|
|
41
|
+
bgcolor: 'var(--background-default)',
|
|
55
42
|
};
|
|
@@ -6,6 +6,8 @@ type Props = {
|
|
|
6
6
|
onConfirm: () => void;
|
|
7
7
|
closeLabel?: string;
|
|
8
8
|
confirmLabel?: string;
|
|
9
|
+
disableClose?: boolean;
|
|
10
|
+
disableEscapeClose?: boolean;
|
|
9
11
|
};
|
|
10
|
-
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, disableEscapeClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
13
|
export {};
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Modal } from '@mui/material';
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { Button, Icon } from 'tycho-storybook';
|
|
5
6
|
import './style.scss';
|
|
6
|
-
|
|
7
|
+
import { attachCloseToEscape, stopEventPropagation } from './AppModalUtils';
|
|
8
|
+
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, disableEscapeClose, }) {
|
|
7
9
|
const { t } = useTranslation('common');
|
|
8
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (disableEscapeClose)
|
|
12
|
+
return;
|
|
13
|
+
return attachCloseToEscape(onClose);
|
|
14
|
+
}, [onClose, disableEscapeClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableEscapeClose, onClose: (event) => {
|
|
16
|
+
stopEventPropagation(event);
|
|
17
|
+
if (disableClose)
|
|
18
|
+
return;
|
|
19
|
+
onClose();
|
|
20
|
+
}, children: _jsxs(Box, { className: "modal-container modal-confirm", sx: style, children: [_jsxs("div", { className: "body", children: [_jsx(Icon, { name: "warning", size: "large", filled: true }), _jsxs("div", { className: "texts", children: [_jsx("span", { className: "title", children: title }), _jsx("span", { className: "subtitle", children: subtitle })] })] }), _jsxs("div", { className: "footer", children: [_jsx(Button, { onClick: (e) => {
|
|
21
|
+
stopEventPropagation(e);
|
|
22
|
+
onClose();
|
|
23
|
+
}, text: closeLabel || t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: confirmLabel || t('button.confirm') })] })] }) }));
|
|
9
24
|
}
|
|
10
25
|
const style = {
|
|
11
26
|
position: 'absolute',
|
|
@@ -4,8 +4,10 @@ type Props = {
|
|
|
4
4
|
subtitle: string;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onConfirm: () => void;
|
|
7
|
+
disableClose?: boolean;
|
|
8
|
+
disableEscapeClose?: boolean;
|
|
7
9
|
};
|
|
8
|
-
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, disableEscapeClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export declare const modalRemoveStyle: {
|
|
10
12
|
position: string;
|
|
11
13
|
top: string;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Modal } from '@mui/material';
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { useTranslation } from 'react-i18next';
|
|
4
5
|
import { Button, Icon } from 'tycho-storybook';
|
|
5
6
|
import './style.scss';
|
|
6
|
-
|
|
7
|
+
import { attachCloseToEscape, stopEventPropagation } from './AppModalUtils';
|
|
8
|
+
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, disableEscapeClose, }) {
|
|
7
9
|
const { t } = useTranslation('common');
|
|
8
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (disableEscapeClose)
|
|
12
|
+
return;
|
|
13
|
+
return attachCloseToEscape(onClose);
|
|
14
|
+
}, [onClose, disableEscapeClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableEscapeClose, onClose: (event) => {
|
|
16
|
+
stopEventPropagation(event);
|
|
17
|
+
if (disableClose)
|
|
18
|
+
return;
|
|
19
|
+
onClose();
|
|
20
|
+
}, children: _jsxs(Box, { className: "modal-container modal-remove", sx: modalRemoveStyle, children: [_jsxs("div", { className: "body", children: [_jsx(Icon, { name: "warning", size: "large", filled: true }), _jsxs("div", { className: "texts", children: [_jsx("span", { className: "title", children: title }), _jsx("span", { className: "subtitle", children: subtitle })] })] }), _jsxs("div", { className: "footer", children: [_jsx(Button, { onClick: (e) => {
|
|
21
|
+
stopEventPropagation(e);
|
|
22
|
+
onClose();
|
|
23
|
+
}, text: t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: t('button.confirm') })] })] }) }));
|
|
9
24
|
}
|
|
10
25
|
export const modalRemoveStyle = {
|
|
11
26
|
position: 'absolute',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const stopEventPropagation = (event) => {
|
|
2
|
+
const e = event;
|
|
3
|
+
e.preventDefault?.();
|
|
4
|
+
e.stopPropagation?.();
|
|
5
|
+
e.stopImmediatePropagation?.();
|
|
6
|
+
};
|
|
7
|
+
export const attachCloseToEscape = (handleClose) => {
|
|
8
|
+
const closeOnEscape = (e) => {
|
|
9
|
+
if (e.key === "Escape" || e.code === "Escape") {
|
|
10
|
+
stopEventPropagation(e);
|
|
11
|
+
handleClose();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
// Capture phase makes this resilient if inner components stopPropagation() on Escape.
|
|
15
|
+
window.addEventListener("keydown", closeOnEscape, { capture: true });
|
|
16
|
+
return () => window.removeEventListener("keydown", closeOnEscape, { capture: true });
|
|
17
|
+
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Drawer } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Button, IconButton } from 'tycho-storybook';
|
|
6
6
|
import AppLoading from '../AppLoading';
|
|
7
7
|
import AppPlaceholder from '../AppPlaceholder';
|
|
8
|
-
import CommonContext from '../configs/CommonContext';
|
|
9
8
|
import SecurityUtils from '../functions/SecurityUtils';
|
|
10
9
|
import UsabilityUtils from '../functions/UsabilityUtils';
|
|
11
10
|
import CommentAdd from './CommentAdd';
|
|
@@ -14,7 +13,6 @@ import './style.scss';
|
|
|
14
13
|
import CommentService from './types/CommentService';
|
|
15
14
|
export default function Comments({ uid, keywords, references, mode, onClose, onChange, }) {
|
|
16
15
|
const { t } = useTranslation('comments');
|
|
17
|
-
const { state } = useContext(CommonContext);
|
|
18
16
|
const [openAddComment, setOpenAddComment] = useState(false);
|
|
19
17
|
const [comment, setComment] = useState();
|
|
20
18
|
const [comments, setComments] = useState();
|