tycho-components 0.14.1 → 0.14.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/dist/AppModal/AppModal.d.ts +2 -1
- package/dist/AppModal/AppModal.js +5 -19
- package/dist/AppModal/AppModalConfirm.d.ts +2 -1
- package/dist/AppModal/AppModalConfirm.js +16 -2
- package/dist/AppModal/AppModalRemove.d.ts +2 -1
- package/dist/AppModal/AppModalRemove.js +16 -2
- package/dist/AppModal/AppModalUtils.d.ts +2 -0
- package/dist/AppModal/AppModalUtils.js +17 -0
- package/dist/Comments/Comments.js +1 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -20,6 +20,7 @@ type Props = {
|
|
|
20
20
|
};
|
|
21
21
|
alternativeOptions?: React.ReactNode;
|
|
22
22
|
hideBackdrop?: boolean;
|
|
23
|
+
disableBackdropClose?: boolean;
|
|
23
24
|
};
|
|
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;
|
|
25
|
+
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, disableBackdropClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export {};
|
|
@@ -5,24 +5,8 @@ import { useTranslation } from "react-i18next";
|
|
|
5
5
|
import { Button, Icon } from "tycho-storybook";
|
|
6
6
|
import "./style.scss";
|
|
7
7
|
import { useEffect } from "react";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e.preventDefault?.();
|
|
11
|
-
e.stopPropagation?.();
|
|
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, }) {
|
|
8
|
+
import { attachCloseToEscape, stopEventPropagation } from "./AppModalUtils";
|
|
9
|
+
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, disableBackdropClose, }) {
|
|
26
10
|
const { t } = useTranslation("common");
|
|
27
11
|
const getClassNames = cx("modal-container", className);
|
|
28
12
|
useEffect(() => {
|
|
@@ -30,8 +14,10 @@ export default function AppModal({ children, title, subtitle, className, close,
|
|
|
30
14
|
return;
|
|
31
15
|
return attachCloseToEscape(close);
|
|
32
16
|
}, [close, disableClose]);
|
|
33
|
-
return (_jsx(Modal, { open: true, disableEnforceFocus: true, disableAutoFocus: true, disableRestoreFocus: true, hideBackdrop: hideBackdrop, disableEscapeKeyDown: !!disableClose, onClose: (event) => {
|
|
17
|
+
return (_jsx(Modal, { open: true, disableEnforceFocus: true, disableAutoFocus: true, disableRestoreFocus: true, hideBackdrop: hideBackdrop, disableEscapeKeyDown: !!disableClose, onClose: (event, reason) => {
|
|
34
18
|
stopEventPropagation(event);
|
|
19
|
+
if (disableBackdropClose && reason === "backdropClick")
|
|
20
|
+
return;
|
|
35
21
|
if (!disableClose)
|
|
36
22
|
close();
|
|
37
23
|
}, 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) => {
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
onConfirm: () => void;
|
|
7
7
|
closeLabel?: string;
|
|
8
8
|
confirmLabel?: string;
|
|
9
|
+
disableClose?: boolean;
|
|
9
10
|
};
|
|
10
|
-
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -1,11 +1,25 @@
|
|
|
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, }) {
|
|
7
9
|
const { t } = useTranslation('common');
|
|
8
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (disableClose)
|
|
12
|
+
return;
|
|
13
|
+
return attachCloseToEscape(onClose);
|
|
14
|
+
}, [onClose, disableClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableClose, onClose: (event) => {
|
|
16
|
+
stopEventPropagation(event);
|
|
17
|
+
if (!disableClose)
|
|
18
|
+
onClose();
|
|
19
|
+
}, 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) => {
|
|
20
|
+
stopEventPropagation(e);
|
|
21
|
+
onClose();
|
|
22
|
+
}, text: closeLabel || t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: confirmLabel || t('button.confirm') })] })] }) }));
|
|
9
23
|
}
|
|
10
24
|
const style = {
|
|
11
25
|
position: 'absolute',
|
|
@@ -4,8 +4,9 @@ type Props = {
|
|
|
4
4
|
subtitle: string;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onConfirm: () => void;
|
|
7
|
+
disableClose?: boolean;
|
|
7
8
|
};
|
|
8
|
-
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
10
|
export declare const modalRemoveStyle: {
|
|
10
11
|
position: string;
|
|
11
12
|
top: string;
|
|
@@ -1,11 +1,25 @@
|
|
|
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, }) {
|
|
7
9
|
const { t } = useTranslation('common');
|
|
8
|
-
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (disableClose)
|
|
12
|
+
return;
|
|
13
|
+
return attachCloseToEscape(onClose);
|
|
14
|
+
}, [onClose, disableClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableClose, onClose: (event) => {
|
|
16
|
+
stopEventPropagation(event);
|
|
17
|
+
if (!disableClose)
|
|
18
|
+
onClose();
|
|
19
|
+
}, 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) => {
|
|
20
|
+
stopEventPropagation(e);
|
|
21
|
+
onClose();
|
|
22
|
+
}, text: t('button.cancel'), mode: "tonal" }), _jsx(Button, { onClick: onConfirm, text: t('button.confirm') })] })] }) }));
|
|
9
23
|
}
|
|
10
24
|
export const modalRemoveStyle = {
|
|
11
25
|
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();
|
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { default as Unauthorized } from './Base/Unauthorized';
|
|
|
37
37
|
export { default as CommentComponent } from './Comments';
|
|
38
38
|
export { default as HeaderNotifications } from './Comments/HeaderNotifications';
|
|
39
39
|
export type { Comment } from './Comments/types/Comment';
|
|
40
|
+
export { default as CommentService } from './Comments/types/CommentService';
|
|
40
41
|
export { CommonProvider } from './configs/CommonContext';
|
|
41
42
|
export { default as CookieStorage } from './configs/CookieStorage';
|
|
42
43
|
export { commonResources } from './configs/Localization';
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { default as NotFound } from './Base/NotFound';
|
|
|
29
29
|
export { default as Unauthorized } from './Base/Unauthorized';
|
|
30
30
|
export { default as CommentComponent } from './Comments';
|
|
31
31
|
export { default as HeaderNotifications } from './Comments/HeaderNotifications';
|
|
32
|
+
export { default as CommentService } from './Comments/types/CommentService';
|
|
32
33
|
export { CommonProvider } from './configs/CommonContext';
|
|
33
34
|
export { default as CookieStorage } from './configs/CookieStorage';
|
|
34
35
|
export { commonResources } from './configs/Localization';
|