tycho-components 0.14.3 → 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 +3 -2
- package/dist/AppModal/AppModal.js +26 -25
- package/dist/AppModal/AppModalConfirm.d.ts +2 -1
- package/dist/AppModal/AppModalConfirm.js +7 -6
- package/dist/AppModal/AppModalRemove.d.ts +2 -1
- package/dist/AppModal/AppModalRemove.js +7 -6
- 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;
|
|
@@ -22,5 +23,5 @@ type Props = {
|
|
|
22
23
|
hideBackdrop?: boolean;
|
|
23
24
|
disableBackdropClose?: boolean;
|
|
24
25
|
};
|
|
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;
|
|
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;
|
|
26
27
|
export {};
|
|
@@ -1,41 +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
|
-
import { attachCloseToEscape, stopEventPropagation } from
|
|
9
|
-
export default function AppModal({ children, title, subtitle, className, close, confirm, disableConfirm, hideFooter, disableClose, disableCancel, confirmLabel, closeLabel, cancel, onEntered, alternativeButton, hideBackdrop, alternativeOptions, disableBackdropClose, }) {
|
|
10
|
-
const { t } = useTranslation(
|
|
11
|
-
const getClassNames = cx(
|
|
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);
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
if (
|
|
13
|
+
if (disableEscapeClose)
|
|
14
14
|
return;
|
|
15
15
|
return attachCloseToEscape(close);
|
|
16
|
-
}, [close,
|
|
17
|
-
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) => {
|
|
18
18
|
stopEventPropagation(event);
|
|
19
|
-
if (disableBackdropClose && reason ===
|
|
19
|
+
if (disableBackdropClose && reason === 'backdropClick')
|
|
20
20
|
return;
|
|
21
|
-
if (
|
|
22
|
-
|
|
21
|
+
if (disableClose)
|
|
22
|
+
return;
|
|
23
|
+
close();
|
|
23
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) => {
|
|
24
25
|
stopEventPropagation(e);
|
|
25
26
|
close();
|
|
26
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) => {
|
|
27
28
|
stopEventPropagation(e);
|
|
28
29
|
(cancel || close)();
|
|
29
|
-
}, text: closeLabel || t(
|
|
30
|
+
}, text: closeLabel || t('button.cancel'), color: "danger" })), confirm && (_jsx(Button, { onClick: confirm, disabled: disableConfirm, text: confirmLabel || t('button.confirm') }))] })) : null] }) }) }));
|
|
30
31
|
}
|
|
31
32
|
const style = {
|
|
32
|
-
position:
|
|
33
|
-
top:
|
|
34
|
-
left:
|
|
35
|
-
transform:
|
|
36
|
-
width:
|
|
37
|
-
maxWidth:
|
|
38
|
-
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)',
|
|
39
40
|
boxShadow: 24,
|
|
40
|
-
bgcolor:
|
|
41
|
+
bgcolor: 'var(--background-default)',
|
|
41
42
|
};
|
|
@@ -7,6 +7,7 @@ type Props = {
|
|
|
7
7
|
closeLabel?: string;
|
|
8
8
|
confirmLabel?: string;
|
|
9
9
|
disableClose?: boolean;
|
|
10
|
+
disableEscapeClose?: boolean;
|
|
10
11
|
};
|
|
11
|
-
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, }: 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;
|
|
12
13
|
export {};
|
|
@@ -5,17 +5,18 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { Button, Icon } from 'tycho-storybook';
|
|
6
6
|
import './style.scss';
|
|
7
7
|
import { attachCloseToEscape, stopEventPropagation } from './AppModalUtils';
|
|
8
|
-
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, }) {
|
|
8
|
+
export default function AppModalConfirm({ title, subtitle, onClose, onConfirm, closeLabel, confirmLabel, disableClose, disableEscapeClose, }) {
|
|
9
9
|
const { t } = useTranslation('common');
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
if (
|
|
11
|
+
if (disableEscapeClose)
|
|
12
12
|
return;
|
|
13
13
|
return attachCloseToEscape(onClose);
|
|
14
|
-
}, [onClose,
|
|
15
|
-
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!
|
|
14
|
+
}, [onClose, disableEscapeClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableEscapeClose, onClose: (event) => {
|
|
16
16
|
stopEventPropagation(event);
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (disableClose)
|
|
18
|
+
return;
|
|
19
|
+
onClose();
|
|
19
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) => {
|
|
20
21
|
stopEventPropagation(e);
|
|
21
22
|
onClose();
|
|
@@ -5,8 +5,9 @@ type Props = {
|
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onConfirm: () => void;
|
|
7
7
|
disableClose?: boolean;
|
|
8
|
+
disableEscapeClose?: boolean;
|
|
8
9
|
};
|
|
9
|
-
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, }: 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;
|
|
10
11
|
export declare const modalRemoveStyle: {
|
|
11
12
|
position: string;
|
|
12
13
|
top: string;
|
|
@@ -5,17 +5,18 @@ import { useTranslation } from 'react-i18next';
|
|
|
5
5
|
import { Button, Icon } from 'tycho-storybook';
|
|
6
6
|
import './style.scss';
|
|
7
7
|
import { attachCloseToEscape, stopEventPropagation } from './AppModalUtils';
|
|
8
|
-
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, }) {
|
|
8
|
+
export default function AppModalRemove({ title, subtitle, onClose, onConfirm, disableClose, disableEscapeClose, }) {
|
|
9
9
|
const { t } = useTranslation('common');
|
|
10
10
|
useEffect(() => {
|
|
11
|
-
if (
|
|
11
|
+
if (disableEscapeClose)
|
|
12
12
|
return;
|
|
13
13
|
return attachCloseToEscape(onClose);
|
|
14
|
-
}, [onClose,
|
|
15
|
-
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!
|
|
14
|
+
}, [onClose, disableEscapeClose]);
|
|
15
|
+
return (_jsx(Modal, { open: true, disableEscapeKeyDown: !!disableEscapeClose, onClose: (event) => {
|
|
16
16
|
stopEventPropagation(event);
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if (disableClose)
|
|
18
|
+
return;
|
|
19
|
+
onClose();
|
|
19
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) => {
|
|
20
21
|
stopEventPropagation(e);
|
|
21
22
|
onClose();
|