Update eslint to 8.27.0
This commit is contained in:
parent
c8fb43a846
commit
98ef4c627a
499 changed files with 8995 additions and 8494 deletions
|
@ -57,103 +57,101 @@ function getButtonVariant(
|
|||
return ButtonVariant.Secondary;
|
||||
}
|
||||
|
||||
export const ConfirmationDialog = React.memo(
|
||||
({
|
||||
actions = [],
|
||||
dialogName,
|
||||
cancelButtonVariant,
|
||||
cancelText,
|
||||
children,
|
||||
hasXButton,
|
||||
i18n,
|
||||
moduleClassName,
|
||||
noMouseClose,
|
||||
noDefaultCancelButton,
|
||||
onCancel,
|
||||
onClose,
|
||||
onTopOfEverything,
|
||||
theme,
|
||||
title,
|
||||
}: Props) => {
|
||||
const { close, overlayStyles, modalStyles } = useAnimated(onClose, {
|
||||
getFrom: () => ({ opacity: 0, transform: 'scale(0.25)' }),
|
||||
getTo: isOpen => ({ opacity: isOpen ? 1 : 0, transform: 'scale(1)' }),
|
||||
});
|
||||
export const ConfirmationDialog = React.memo(function ConfirmationDialogInner({
|
||||
actions = [],
|
||||
dialogName,
|
||||
cancelButtonVariant,
|
||||
cancelText,
|
||||
children,
|
||||
hasXButton,
|
||||
i18n,
|
||||
moduleClassName,
|
||||
noMouseClose,
|
||||
noDefaultCancelButton,
|
||||
onCancel,
|
||||
onClose,
|
||||
onTopOfEverything,
|
||||
theme,
|
||||
title,
|
||||
}: Props) {
|
||||
const { close, overlayStyles, modalStyles } = useAnimated(onClose, {
|
||||
getFrom: () => ({ opacity: 0, transform: 'scale(0.25)' }),
|
||||
getTo: isOpen => ({ opacity: isOpen ? 1 : 0, transform: 'scale(1)' }),
|
||||
});
|
||||
|
||||
const cancelAndClose = useCallback(() => {
|
||||
if (onCancel) {
|
||||
onCancel();
|
||||
const cancelAndClose = useCallback(() => {
|
||||
if (onCancel) {
|
||||
onCancel();
|
||||
}
|
||||
close();
|
||||
}, [close, onCancel]);
|
||||
|
||||
const handleCancel = useCallback(
|
||||
(e: MouseEvent) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
cancelAndClose();
|
||||
}
|
||||
close();
|
||||
}, [close, onCancel]);
|
||||
},
|
||||
[cancelAndClose]
|
||||
);
|
||||
|
||||
const handleCancel = useCallback(
|
||||
(e: MouseEvent) => {
|
||||
if (e.target === e.currentTarget) {
|
||||
cancelAndClose();
|
||||
}
|
||||
},
|
||||
[cancelAndClose]
|
||||
);
|
||||
const hasActions = Boolean(actions.length);
|
||||
|
||||
const hasActions = Boolean(actions.length);
|
||||
const footer = (
|
||||
<>
|
||||
{!noDefaultCancelButton ? (
|
||||
<Button
|
||||
onClick={handleCancel}
|
||||
ref={focusRef}
|
||||
variant={
|
||||
cancelButtonVariant ||
|
||||
(hasActions ? ButtonVariant.Secondary : ButtonVariant.Primary)
|
||||
}
|
||||
>
|
||||
{cancelText || i18n('confirmation-dialog--Cancel')}
|
||||
</Button>
|
||||
) : null}
|
||||
{actions.map((action, i) => (
|
||||
<Button
|
||||
key={action.text}
|
||||
onClick={() => {
|
||||
action.action();
|
||||
close();
|
||||
}}
|
||||
data-action={i}
|
||||
variant={getButtonVariant(action.style)}
|
||||
>
|
||||
{action.text}
|
||||
</Button>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
|
||||
const footer = (
|
||||
<>
|
||||
{!noDefaultCancelButton ? (
|
||||
<Button
|
||||
onClick={handleCancel}
|
||||
ref={focusRef}
|
||||
variant={
|
||||
cancelButtonVariant ||
|
||||
(hasActions ? ButtonVariant.Secondary : ButtonVariant.Primary)
|
||||
}
|
||||
>
|
||||
{cancelText || i18n('confirmation-dialog--Cancel')}
|
||||
</Button>
|
||||
) : null}
|
||||
{actions.map((action, i) => (
|
||||
<Button
|
||||
key={action.text}
|
||||
onClick={() => {
|
||||
action.action();
|
||||
close();
|
||||
}}
|
||||
data-action={i}
|
||||
variant={getButtonVariant(action.style)}
|
||||
>
|
||||
{action.text}
|
||||
</Button>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
const modalName = `ConfirmationDialog.${dialogName}`;
|
||||
|
||||
const modalName = `ConfirmationDialog.${dialogName}`;
|
||||
|
||||
return (
|
||||
<ModalHost
|
||||
modalName={modalName}
|
||||
noMouseClose={noMouseClose}
|
||||
onClose={close}
|
||||
onEscape={cancelAndClose}
|
||||
onTopOfEverything={onTopOfEverything}
|
||||
overlayStyles={overlayStyles}
|
||||
theme={theme}
|
||||
>
|
||||
<animated.div style={modalStyles}>
|
||||
<ModalPage
|
||||
modalName={modalName}
|
||||
hasXButton={hasXButton}
|
||||
i18n={i18n}
|
||||
moduleClassName={moduleClassName}
|
||||
onClose={cancelAndClose}
|
||||
title={title}
|
||||
modalFooter={footer}
|
||||
>
|
||||
{children}
|
||||
</ModalPage>
|
||||
</animated.div>
|
||||
</ModalHost>
|
||||
);
|
||||
}
|
||||
);
|
||||
return (
|
||||
<ModalHost
|
||||
modalName={modalName}
|
||||
noMouseClose={noMouseClose}
|
||||
onClose={close}
|
||||
onEscape={cancelAndClose}
|
||||
onTopOfEverything={onTopOfEverything}
|
||||
overlayStyles={overlayStyles}
|
||||
theme={theme}
|
||||
>
|
||||
<animated.div style={modalStyles}>
|
||||
<ModalPage
|
||||
modalName={modalName}
|
||||
hasXButton={hasXButton}
|
||||
i18n={i18n}
|
||||
moduleClassName={moduleClassName}
|
||||
onClose={cancelAndClose}
|
||||
title={title}
|
||||
modalFooter={footer}
|
||||
>
|
||||
{children}
|
||||
</ModalPage>
|
||||
</animated.div>
|
||||
</ModalHost>
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue