mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-27 20:49:53 +08:00
refactor: convertLegacyProps function moved to buttonHelpers (#44777)
This commit is contained in:
parent
bcf7c924e2
commit
c9e94c26f6
@ -2,7 +2,7 @@ import useState from 'rc-util/lib/hooks/useState';
|
||||
import * as React from 'react';
|
||||
import Button from '../button';
|
||||
import type { ButtonProps, LegacyButtonType } from '../button/button';
|
||||
import { convertLegacyProps } from '../button/button';
|
||||
import { convertLegacyProps } from '../button/buttonHelpers';
|
||||
|
||||
export interface ActionButtonProps {
|
||||
type?: LegacyButtonType;
|
||||
|
@ -29,15 +29,6 @@ import CompactCmp from './style/compactCmp';
|
||||
|
||||
export type LegacyButtonType = ButtonType | 'danger';
|
||||
|
||||
export function convertLegacyProps(
|
||||
type?: LegacyButtonType,
|
||||
): Pick<BaseButtonProps, 'danger' | 'type'> {
|
||||
if (type === 'danger') {
|
||||
return { danger: true };
|
||||
}
|
||||
return { type };
|
||||
}
|
||||
|
||||
export interface BaseButtonProps {
|
||||
type?: ButtonType;
|
||||
icon?: React.ReactNode;
|
||||
|
@ -1,9 +1,19 @@
|
||||
import React from 'react';
|
||||
import { cloneElement, isFragment } from '../_util/reactNode';
|
||||
import type { BaseButtonProps, LegacyButtonType } from './button';
|
||||
|
||||
const rxTwoCNChar = /^[\u4e00-\u9fa5]{2}$/;
|
||||
export const isTwoCNChar = rxTwoCNChar.test.bind(rxTwoCNChar);
|
||||
|
||||
export function convertLegacyProps(
|
||||
type?: LegacyButtonType,
|
||||
): Pick<BaseButtonProps, 'danger' | 'type'> {
|
||||
if (type === 'danger') {
|
||||
return { danger: true };
|
||||
}
|
||||
return { type };
|
||||
}
|
||||
|
||||
export function isString(str: any): str is string {
|
||||
return typeof str === 'string';
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import type { FC } from 'react';
|
||||
import React, { useContext } from 'react';
|
||||
|
||||
import Button from '../../button';
|
||||
import { convertLegacyProps } from '../../button/button';
|
||||
import { convertLegacyProps } from '../../button/buttonHelpers';
|
||||
import { ModalContext } from '../context';
|
||||
import type { ModalProps } from '../interface';
|
||||
|
||||
|
@ -5,7 +5,7 @@ import type { PopconfirmProps } from '.';
|
||||
import ActionButton from '../_util/ActionButton';
|
||||
import { getRenderPropValue } from '../_util/getRenderPropValue';
|
||||
import Button from '../button';
|
||||
import { convertLegacyProps } from '../button/button';
|
||||
import { convertLegacyProps } from '../button/buttonHelpers';
|
||||
import { ConfigContext } from '../config-provider';
|
||||
import { useLocale } from '../locale';
|
||||
import defaultLocale from '../locale/en_US';
|
||||
|
Loading…
Reference in New Issue
Block a user