refactor: extract public methods (#44737)

This commit is contained in:
lijianan 2023-09-10 14:34:22 +08:00 committed by GitHub
parent 4489eec5b1
commit 5b75f3f817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -1,11 +1,10 @@
import type { SpaceSize } from '.';
import type { SizeType } from '../config-provider/SizeContext';
export function isPresetSize(size: SpaceSize): size is SizeType {
export function isPresetSize(size?: SizeType | string | number): size is SizeType {
return ['small', 'middle', 'large'].includes(size as string);
}
export function isValidGapNumber(size: SpaceSize): size is number {
export function isValidGapNumber(size?: SizeType | string | number): size is number {
if (!size) {
// The case of size = 0 is deliberately excluded here, because the default value of the gap attribute in CSS is 0, so if the user passes 0 in, we can directly ignore it.
return false;

View File

@ -2,6 +2,7 @@ import * as React from 'react';
import classNames from 'classnames';
import toArray from 'rc-util/lib/Children/toArray';
import { isPresetSize, isValidGapNumber } from '../_util/gapSize';
import { ConfigContext } from '../config-provider';
import type { SizeType } from '../config-provider/SizeContext';
import Compact from './Compact';
@ -9,7 +10,6 @@ import { SpaceContextProvider } from './context';
import type { SpaceContextType } from './context';
import Item from './Item';
import useStyle from './style';
import { isPresetSize, isValidGapNumber } from './utils';
export { SpaceContext } from './context';