From 5b75f3f817f74564da407ba40d7aaf5f980a4884 Mon Sep 17 00:00:00 2001 From: lijianan <574980606@qq.com> Date: Sun, 10 Sep 2023 14:34:22 +0800 Subject: [PATCH] refactor: extract public methods (#44737) --- components/{space/utils.ts => _util/gapSize.ts} | 5 ++--- components/space/index.tsx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) rename components/{space/utils.ts => _util/gapSize.ts} (70%) diff --git a/components/space/utils.ts b/components/_util/gapSize.ts similarity index 70% rename from components/space/utils.ts rename to components/_util/gapSize.ts index 71c50037d8..f4f35ec380 100644 --- a/components/space/utils.ts +++ b/components/_util/gapSize.ts @@ -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; diff --git a/components/space/index.tsx b/components/space/index.tsx index 8e0eed67b2..af596a001a 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -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';