Skip to content

Commit

Permalink
perf: compression code
Browse files Browse the repository at this point in the history
  • Loading branch information
RedJue committed Aug 22, 2023
1 parent f206701 commit bded5e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
26 changes: 3 additions & 23 deletions components/modal/ConfirmDialog.tsx
Expand Up @@ -47,22 +47,15 @@ export function ConfirmContent(
) {
const {
icon,
onCancel,
onOk,
close,
onConfirm,
isSilent,
okText,
okButtonProps,
cancelText,
cancelButtonProps,
confirmPrefixCls,
rootPrefixCls,
type,
okCancel,
footer,
// Legacy for static function usage
locale: staticLocale,
...resetProps
} = props;

warning(
Expand Down Expand Up @@ -94,7 +87,6 @@ export function ConfirmContent(
}
}

const okType = props.okType || 'primary';
// 默认为 true,保持向下兼容
const mergedOkCancel = okCancel ?? type === 'confirm';

Expand All @@ -111,26 +103,14 @@ export function ConfirmContent(
// ================= Context Value =================
const confirmBtnCtxValue: ConfirmOkBtnProps = {
autoFocusButton,
close,
isSilent,
okButtonProps,
rootPrefixCls,
okTextLocale,
okType,
onConfirm,
onOk,
...resetProps,
};

const cancelBtnCtxValue: ConfirmCancelBtnProps = {
autoFocusButton,
cancelButtonProps,
cancelTextLocale,
isSilent,
mergedOkCancel,
rootPrefixCls,
close,
onCancel,
onConfirm,
...resetProps,
};

const confirmBtnCtxValueMemo = React.useMemo(
Expand Down
2 changes: 1 addition & 1 deletion components/modal/components/ConfirmCancelBtn.tsx
Expand Up @@ -9,7 +9,7 @@ export interface ConfirmCancelBtnProps
ConfirmDialogProps,
'cancelButtonProps' | 'isSilent' | 'rootPrefixCls' | 'close' | 'onConfirm' | 'onCancel'
> {
autoFocusButton?: false | 'ok' | 'cancel';
autoFocusButton?: false | 'ok' | 'cancel' | null;
cancelTextLocale?:
| string
| number
Expand Down
4 changes: 2 additions & 2 deletions components/modal/components/ConfirmOkBtn.tsx
Expand Up @@ -9,7 +9,7 @@ export interface ConfirmOkBtnProps
ConfirmDialogProps,
'close' | 'isSilent' | 'okType' | 'okButtonProps' | 'rootPrefixCls' | 'onConfirm' | 'onOk'
> {
autoFocusButton?: false | 'ok' | 'cancel';
autoFocusButton?: false | 'ok' | 'cancel' | null;
okTextLocale?:
| string
| number
Expand All @@ -33,7 +33,7 @@ const ConfirmOkBtn: FC = () => {
return (
<ActionButton
isSilent={isSilent}
type={okType}
type={okType || 'primary'}
actionFn={onOk}
close={(...args: any[]) => {
close?.(...args);
Expand Down

0 comments on commit bded5e8

Please sign in to comment.