diff --git a/.dumi/theme/common/Color/Palette.tsx b/.dumi/theme/common/Color/Palette.tsx index ec4807cc58..2e130ad3a2 100644 --- a/.dumi/theme/common/Color/Palette.tsx +++ b/.dumi/theme/common/Color/Palette.tsx @@ -73,10 +73,10 @@ const Palette: React.FC = (props) => { key={i} ref={(node) => { if (node) { - colorNodesRef.current[`${name}-${i}`] = node; + colorNodesRef.current[`${name}-${i + 1}`] = node; } }} - className={`main-color-item palette-${name}-${i}`} + className={`main-color-item palette-${name}-${i + 1}`} style={{ color: (name === 'yellow' ? i > 6 : i > 5) ? firstColor : lastColor, fontWeight: i === 6 ? 'bold' : 'normal', diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml index 7dc5fd8b9d..29a37f1d93 100644 --- a/.github/workflows/preview-build.yml +++ b/.github/workflows/preview-build.yml @@ -30,7 +30,7 @@ jobs: - name: run e2e test run: ut test:site - name: upload site artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: site path: _site/ @@ -42,7 +42,7 @@ jobs: - name: Upload PR number if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: pr path: ./pr-id.txt diff --git a/.github/workflows/site-deploy.yml b/.github/workflows/site-deploy.yml index 77bed46f12..f0c080f2b3 100644 --- a/.github/workflows/site-deploy.yml +++ b/.github/workflows/site-deploy.yml @@ -45,7 +45,7 @@ jobs: fi - name: upload site artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: real-site path: _site/ @@ -63,7 +63,7 @@ jobs: - uses: utooland/setup-utoo@v1 - name: download site artifact - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 with: name: real-site path: _site @@ -105,7 +105,7 @@ jobs: needs: build-site steps: - name: download site artifact - uses: actions/download-artifact@v5 + uses: actions/download-artifact@v6 with: name: real-site path: _site diff --git a/.github/workflows/test-v6.yml b/.github/workflows/test-v6.yml index f3a79cf9dc..7e1dbf6b68 100644 --- a/.github/workflows/test-v6.yml +++ b/.github/workflows/test-v6.yml @@ -76,7 +76,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -121,7 +121,7 @@ jobs: steps: - uses: actions/checkout@v5 - uses: utooland/setup-utoo@v1 - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: pattern: coverage-artifacts-* merge-multiple: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38ed61bef9..75ff3fd6f4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,7 +79,7 @@ jobs: mkdir persist-coverage mv coverage/coverage-final.json persist-coverage/react-test-${{matrix.module}}-${{strategy.job-index}}.json - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: upload coverages with: name: coverage-artifacts-${{ matrix.module }}-${{ strategy.job-index }} @@ -126,7 +126,7 @@ jobs: - uses: utooland/setup-utoo@v1 - run: ut - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: pattern: coverage-artifacts-* merge-multiple: true @@ -182,7 +182,7 @@ jobs: run: ut test:dekko # Artifact build files - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 if: github.event_name == 'push' && github.ref == 'refs/heads/master' with: name: build artifacts diff --git a/.github/workflows/visual-regression-diff-build.yml b/.github/workflows/visual-regression-diff-build.yml index 24f8190bb3..c15faa011a 100644 --- a/.github/workflows/visual-regression-diff-build.yml +++ b/.github/workflows/visual-regression-diff-build.yml @@ -37,7 +37,7 @@ jobs: env: NODE_OPTIONS: --max_old_space_size=4096 - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v5 name: artifact snapshot with: name: snapshot-artifacts-${{ strategy.job-index }} @@ -54,7 +54,7 @@ jobs: - uses: utooland/setup-utoo@v1 - run: ut - - uses: actions/download-artifact@v5 + - uses: actions/download-artifact@v6 with: pattern: snapshot-artifacts-* merge-multiple: true @@ -71,7 +71,7 @@ jobs: # Upload report in `visualRegressionReport` - name: upload report artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 if: ${{ always() }} with: name: visual-regression-report @@ -85,7 +85,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: visual-regression-diff-ref path: ./visual-regression-pr-id.txt diff --git a/.github/workflows/visual-regression-persist-start.yml b/.github/workflows/visual-regression-persist-start.yml index d88327a285..c30e0cb184 100644 --- a/.github/workflows/visual-regression-persist-start.yml +++ b/.github/workflows/visual-regression-persist-start.yml @@ -31,7 +31,7 @@ jobs: # Upload `imageSnapshots` on master - name: upload report artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: image-snapshots path: imageSnapshots.tar.gz @@ -43,7 +43,7 @@ jobs: - name: Upload persist key if: ${{ always() }} - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v5 with: name: visual-regression-ref path: ./visual-regression-ref.txt diff --git a/components/_util/__tests__/hooks.test.tsx b/components/_util/__tests__/hooks.test.tsx index 9936fb009d..6c43c96b10 100644 --- a/components/_util/__tests__/hooks.test.tsx +++ b/components/_util/__tests__/hooks.test.tsx @@ -2,10 +2,8 @@ import React, { useEffect } from 'react'; import { CloseOutlined } from '@ant-design/icons'; import { render, renderHook } from '@testing-library/react'; -import useClosable, { computeClosable } from '../hooks/useClosable'; -import type { ClosableType } from '../hooks/useClosable'; -import useOrientation from '../hooks/useOrientation'; -import type { Orientation } from '../hooks/useOrientation'; +import { computeClosable, useClosable, useOrientation } from '../hooks'; +import type { ClosableType, Orientation } from '../hooks'; describe('hooks test', () => { const useClosableParams: { diff --git a/components/_util/__tests__/useMergeSemantic.test.tsx b/components/_util/__tests__/useMergeSemantic.test.tsx index 6dc924eac6..b1ab509ab3 100644 --- a/components/_util/__tests__/useMergeSemantic.test.tsx +++ b/components/_util/__tests__/useMergeSemantic.test.tsx @@ -1,6 +1,6 @@ import { renderHook } from '@testing-library/react'; -import useMergeSemantic, { mergeClassNames } from '../hooks/useMergeSemantic'; +import useMergeSemantic, { mergeClassNames } from '../hooks'; const mockSchema = { _default: 'root', diff --git a/components/_util/__tests__/useSyncState.test.tsx b/components/_util/__tests__/useSyncState.test.tsx index 3ba9241567..57b1d0c86b 100644 --- a/components/_util/__tests__/useSyncState.test.tsx +++ b/components/_util/__tests__/useSyncState.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { fireEvent, render } from '../../../tests/utils'; -import useSyncState from '../hooks/useSyncState'; +import { useSyncState } from '../hooks'; describe('Table', () => { it('useSyncState', () => { diff --git a/components/_util/hooks/index.ts b/components/_util/hooks/index.ts new file mode 100644 index 0000000000..fe47f051c2 --- /dev/null +++ b/components/_util/hooks/index.ts @@ -0,0 +1,10 @@ +export * from './useClosable'; +export * from './useForceUpdate'; +export * from './useMergedMask'; +export * from './useMergeSemantic'; +export * from './useMultipleSelect'; +export * from './useOrientation'; +export * from './usePatchElement'; +export * from './useProxyImperativeHandle'; +export * from './useSyncState'; +export * from './useZIndex'; diff --git a/components/_util/hooks/useClosable.tsx b/components/_util/hooks/useClosable.tsx index f6f6e4a642..b35c9d482c 100644 --- a/components/_util/hooks/useClosable.tsx +++ b/components/_util/hooks/useClosable.tsx @@ -15,15 +15,15 @@ export type ContextClosable = Partial< Pick >; -export function pickClosable( +export const pickClosable = ( context?: ContextClosable, -): ContextClosable | undefined { +): ContextClosable | undefined => { if (!context) { return undefined; } const { closable, closeIcon } = context; return { closable, closeIcon }; -} +}; /** Collection contains the all the props related with closable. e.g. `closable`, `closeIcon` */ interface ClosableCollection { @@ -46,10 +46,10 @@ type DataAttributes = { [key: `data-${string}`]: string; }; -function computeClosableConfig( +const computeClosableConfig = ( closable?: ClosableType, closeIcon?: ReactNode, -): ClosableType | boolean | null { +): ClosableType | boolean | null => { if (!closable && (closable === false || closeIcon === false || closeIcon === null)) { return false; } @@ -69,27 +69,35 @@ function computeClosableConfig( }; } return closableConfig; -} +}; -function mergeClosableConfigs( +const mergeClosableConfigs = ( propConfig: ReturnType, contextConfig: ReturnType, fallbackConfig: ClosableCollection & { closeIconRender?: (icon: ReactNode) => ReactNode }, -) { - if (propConfig === false) return false; - if (propConfig) return extendsObject(fallbackConfig, contextConfig, propConfig); +) => { + if (propConfig === false) { + return false; + } + if (propConfig) { + return extendsObject(fallbackConfig, contextConfig, propConfig); + } - if (contextConfig === false) return false; - if (contextConfig) return extendsObject(fallbackConfig, contextConfig); + if (contextConfig === false) { + return false; + } + if (contextConfig) { + return extendsObject(fallbackConfig, contextConfig); + } return fallbackConfig.closable ? fallbackConfig : false; -} +}; -function computeCloseIcon( +const computeCloseIcon = ( mergedConfig: ClosableCollection, fallbackCloseCollection: FallbackCloseCollection, closeLabel: string, -): [ReactNode, React.AriaAttributes & DataAttributes] { +): [ReactNode, React.AriaAttributes & DataAttributes] => { const { closeIconRender } = fallbackCloseCollection; const { closeIcon, ...restConfig } = mergedConfig; @@ -115,9 +123,9 @@ function computeCloseIcon( } return [finalCloseIcon, ariaOrDataProps]; -} +}; -export function computeClosable( +export const computeClosable = ( propCloseCollection?: ClosableCollection, contextCloseCollection?: ClosableCollection | null, fallbackCloseCollection: FallbackCloseCollection = EmptyFallbackCloseCollection, @@ -127,7 +135,7 @@ export function computeClosable( closeIcon: React.ReactNode, closeBtnIsDisabled: boolean, ariaOrDataProps: React.AriaAttributes & DataAttributes, -] { +] => { const propConfig = computeClosableConfig( propCloseCollection?.closable, propCloseCollection?.closeIcon, @@ -151,13 +159,13 @@ export function computeClosable( const [closeIcon, ariaProps] = computeCloseIcon(mergedConfig, mergedFallback, closeLabel); return [true, closeIcon, closeBtnIsDisabled, ariaProps]; -} +}; -function useClosable( +export const useClosable = ( propCloseCollection?: ClosableCollection, contextCloseCollection?: ClosableCollection | null, fallbackCloseCollection: FallbackCloseCollection = EmptyFallbackCloseCollection, -) { +) => { const [contextLocale] = useLocale('global', defaultLocale.global); return React.useMemo(() => { return computeClosable( @@ -170,6 +178,4 @@ function useClosable( contextLocale.close, ); }, [propCloseCollection, contextCloseCollection, fallbackCloseCollection, contextLocale.close]); -} - -export default useClosable; +}; diff --git a/components/_util/hooks/useForceUpdate.ts b/components/_util/hooks/useForceUpdate.ts index d053a1986a..5b69ca4258 100644 --- a/components/_util/hooks/useForceUpdate.ts +++ b/components/_util/hooks/useForceUpdate.ts @@ -1,6 +1,5 @@ -import * as React from 'react'; +import React from 'react'; -export default function useForceUpdate() { - const [, forceUpdate] = React.useReducer((x) => x + 1, 0); - return forceUpdate; -} +export const useForceUpdate = () => { + return React.useReducer((ori) => ori + 1, 0); +}; diff --git a/components/_util/hooks/useMergeSemantic.ts b/components/_util/hooks/useMergeSemantic.ts index 9f668aac1e..bc591cdb7f 100644 --- a/components/_util/hooks/useMergeSemantic.ts +++ b/components/_util/hooks/useMergeSemantic.ts @@ -115,7 +115,7 @@ type ObjectOnly = T extends (...args: any) => any ? never : T; * @desc Merge classNames and styles from multiple sources. When `schema` is provided, it **must** provide the nest object structure. * @descZH 合并来自多个来源的 classNames 和 styles,当提供了 `schema` 时,必须提供嵌套的对象结构。 */ -const useMergeSemantic = < +export const useMergeSemantic = < ClassNamesType extends AnyObject, StylesType extends AnyObject, Props extends AnyObject, @@ -150,5 +150,3 @@ const useMergeSemantic = < ] as const; }, [mergedClassNames, mergedStyles, schema]); }; - -export default useMergeSemantic; diff --git a/components/_util/hooks/useMergedMask.ts b/components/_util/hooks/useMergedMask.ts index d565065c89..c7c96e3c1e 100644 --- a/components/_util/hooks/useMergedMask.ts +++ b/components/_util/hooks/useMergedMask.ts @@ -19,24 +19,19 @@ const normalizeMaskConfig = (mask?: MaskType): MaskConfig => { return {}; }; -function useMergedMask( +export const useMergedMask = ( mask?: MaskType, contextMask?: MaskType, prefixCls?: string, -): [boolean, { [key: string]: string | undefined }] { +): [boolean, { [key: string]: string | undefined }] => { return useMemo(() => { const maskConfig = normalizeMaskConfig(mask); const contextMaskConfig = normalizeMaskConfig(contextMask); - const mergedConfig: MaskConfig = { - ...contextMaskConfig, - ...maskConfig, - }; + const mergedConfig: MaskConfig = { ...contextMaskConfig, ...maskConfig }; const className = mergedConfig.blur !== false ? `${prefixCls}-mask-blur` : undefined; return [mergedConfig.enabled !== false, { mask: className }]; }, [mask, contextMask, prefixCls]); -} - -export default useMergedMask; +}; diff --git a/components/_util/hooks/useMultipleSelect.ts b/components/_util/hooks/useMultipleSelect.ts index 2fd9ff4646..55157e3789 100644 --- a/components/_util/hooks/useMultipleSelect.ts +++ b/components/_util/hooks/useMultipleSelect.ts @@ -6,7 +6,7 @@ export type PrevSelectedIndex = null | number; * @title multipleSelect hooks * @description multipleSelect by hold down shift key */ -export default function useMultipleSelect(getKey: (item: T) => K) { +export const useMultipleSelect = (getKey: (item: T) => K) => { const [prevSelectedIndex, setPrevSelectedIndex] = useState(null); const multipleSelect = useCallback( @@ -44,4 +44,4 @@ export default function useMultipleSelect(getKey: (item: T) => K) { }; return [multipleSelect, updatePrevSelectedIndex] as const; -} +}; diff --git a/components/_util/hooks/useOrientation.ts b/components/_util/hooks/useOrientation.ts index 36bab64934..f697f88f16 100644 --- a/components/_util/hooks/useOrientation.ts +++ b/components/_util/hooks/useOrientation.ts @@ -6,11 +6,11 @@ const isValidOrientation = (orientation?: Orientation) => { return orientation === 'horizontal' || orientation === 'vertical'; }; -export default function useOrientation( +export const useOrientation = ( orientation?: Orientation, vertical?: boolean, legacyDirection?: Orientation, -): [Orientation, boolean] { +): [Orientation, boolean] => { return useMemo(() => { const validOrientation = isValidOrientation(orientation); let mergedOrientation: Orientation; @@ -25,4 +25,4 @@ export default function useOrientation( return [mergedOrientation, mergedOrientation === 'vertical']; }, [legacyDirection, orientation, vertical]); -} +}; diff --git a/components/_util/hooks/usePatchElement.ts b/components/_util/hooks/usePatchElement.ts index 8a946e8582..833e946ab1 100644 --- a/components/_util/hooks/usePatchElement.ts +++ b/components/_util/hooks/usePatchElement.ts @@ -1,9 +1,9 @@ import * as React from 'react'; -export default function usePatchElement(): [ +export const usePatchElement = (): [ React.ReactElement[], (element: React.ReactElement) => () => void, -] { +] => { const [elements, setElements] = React.useState([]); const patchElement = React.useCallback((element: React.ReactElement) => { @@ -18,4 +18,4 @@ export default function usePatchElement(): [ }, []); return [elements, patchElement]; -} +}; diff --git a/components/_util/hooks/useProxyImperativeHandle.ts b/components/_util/hooks/useProxyImperativeHandle.ts index 18691e845b..a115301839 100644 --- a/components/_util/hooks/useProxyImperativeHandle.ts +++ b/components/_util/hooks/useProxyImperativeHandle.ts @@ -4,10 +4,10 @@ import { useImperativeHandle } from 'react'; import type { Ref } from 'react'; -function fillProxy( +const fillProxy = ( element: HTMLElement & { _antProxy?: Record }, handler: Record, -) { +) => { element._antProxy = element._antProxy || {}; Object.keys(handler).forEach((key) => { @@ -20,12 +20,15 @@ function fillProxy( }); return element; -} +}; -export default function useProxyImperativeHandle< +export const useProxyImperativeHandle = < NativeELementType extends HTMLElement, ReturnRefType extends { nativeElement: NativeELementType }, ->(ref: Ref | undefined, init: () => ReturnRefType) { +>( + ref: Ref | undefined, + init: () => ReturnRefType, +) => { return useImperativeHandle(ref, () => { const refObj = init(); const { nativeElement } = refObj; @@ -45,4 +48,4 @@ export default function useProxyImperativeHandle< // Fallback of IE return fillProxy(nativeElement, refObj); }); -} +}; diff --git a/components/_util/hooks/useSyncState.ts b/components/_util/hooks/useSyncState.ts index fe61fac42d..18c84d4ab3 100644 --- a/components/_util/hooks/useSyncState.ts +++ b/components/_util/hooks/useSyncState.ts @@ -1,19 +1,17 @@ import * as React from 'react'; -import useForceUpdate from './useForceUpdate'; +import { useForceUpdate } from './useForceUpdate'; type UseSyncStateProps = readonly [() => T, (newValue: T) => void]; -export default function useSyncState(initialValue: T): UseSyncStateProps { +export const useSyncState = (initialValue: T): UseSyncStateProps => { const ref = React.useRef(initialValue); - const forceUpdate = useForceUpdate(); - + const [, forceUpdate] = useForceUpdate(); return [ () => ref.current, (newValue: T) => { ref.current = newValue; - // re-render forceUpdate(); }, ] as const; -} +}; diff --git a/components/_util/hooks/useZIndex.ts b/components/_util/hooks/useZIndex.ts index 05557ccd32..cc8aa5f86b 100644 --- a/components/_util/hooks/useZIndex.ts +++ b/components/_util/hooks/useZIndex.ts @@ -50,9 +50,9 @@ export const consumerBaseZIndexOffset: Record = { ImagePreview: 1, }; -function isContainerType(type: ZIndexContainer | ZIndexConsumer): type is ZIndexContainer { +const isContainerType = (type: ZIndexContainer | ZIndexConsumer): type is ZIndexContainer => { return type in containerBaseZIndexOffset; -} +}; type ReturnResult = [zIndex: number | undefined, contextZIndex: number]; diff --git a/components/alert/Alert.tsx b/components/alert/Alert.tsx index 4dead1a668..8bd321a70a 100644 --- a/components/alert/Alert.tsx +++ b/components/alert/Alert.tsx @@ -10,9 +10,8 @@ import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { composeRef } from '@rc-component/util/lib/ref'; import { clsx } from 'clsx'; -import type { ClosableType } from '../_util/hooks/useClosable'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import type { ClosableType, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import { replaceElement } from '../_util/reactNode'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; @@ -287,7 +286,7 @@ const Alert = React.forwardRef((props, ref) => { return contextClosable.closeIcon; } return contextCloseIcon; - }, [closeIcon, closable, closeText, contextCloseIcon]); + }, [closeIcon, closable, contextClosable, closeText, contextCloseIcon]); const mergedAriaProps = React.useMemo(() => { const merged = closable ?? contextClosable; diff --git a/components/anchor/Anchor.tsx b/components/anchor/Anchor.tsx index 0901836a0f..73b0544d4f 100644 --- a/components/anchor/Anchor.tsx +++ b/components/anchor/Anchor.tsx @@ -4,13 +4,13 @@ import { clsx } from 'clsx'; import scrollIntoView from 'scroll-into-view-if-needed'; import getScroll from '../_util/getScroll'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import scrollTo from '../_util/scrollTo'; import { devUseWarning } from '../_util/warning'; import Affix from '../affix'; @@ -264,7 +264,7 @@ const Anchor: React.FC = (props) => { ); setCurrentActiveLink(currentActiveLink); - }, [dependencyListItem, targetOffset, offsetTop]); + }, [links, targetOffset, offsetTop, bounds]); const handleScrollTo = React.useCallback<(link: string) => void>( (link) => { diff --git a/components/auto-complete/AutoComplete.tsx b/components/auto-complete/AutoComplete.tsx index e7b427d24e..2bf74c1bcb 100644 --- a/components/auto-complete/AutoComplete.tsx +++ b/components/auto-complete/AutoComplete.tsx @@ -3,13 +3,13 @@ import type { BaseSelectRef } from '@rc-component/select'; import { omit, toArray } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import type { InputStatus } from '../_util/statusUtils'; import { devUseWarning } from '../_util/warning'; import type { ConfigConsumerProps } from '../config-provider'; diff --git a/components/badge/Ribbon.tsx b/components/badge/Ribbon.tsx index df1362c4e2..c5dac17d90 100644 --- a/components/badge/Ribbon.tsx +++ b/components/badge/Ribbon.tsx @@ -3,8 +3,8 @@ import { clsx } from 'clsx'; import type { PresetColorType } from '../_util/colors'; import { isPresetColor } from '../_util/colors'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { LiteralUnion } from '../_util/type'; import { useComponentConfig } from '../config-provider/context'; import useStyle from './style/ribbon'; diff --git a/components/badge/index.tsx b/components/badge/index.tsx index 611acd1a94..9d776530fa 100644 --- a/components/badge/index.tsx +++ b/components/badge/index.tsx @@ -5,8 +5,8 @@ import { clsx } from 'clsx'; import type { PresetStatusColorType } from '../_util/colors'; import { isPresetColor } from '../_util/colors'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { cloneElement } from '../_util/reactNode'; import type { LiteralUnion } from '../_util/type'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 6b4fa08492..26b83d7cda 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -3,8 +3,8 @@ import { toArray } from '@rc-component/util'; import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { cloneElement } from '../_util/reactNode'; import type { AnyObject } from '../_util/type'; import { devUseWarning } from '../_util/warning'; diff --git a/components/breadcrumb/BreadcrumbContext.ts b/components/breadcrumb/BreadcrumbContext.ts index 91734a40ff..76e0981dcd 100644 --- a/components/breadcrumb/BreadcrumbContext.ts +++ b/components/breadcrumb/BreadcrumbContext.ts @@ -1,6 +1,6 @@ import React from 'react'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; export type SemanticName = 'root' | 'item' | 'separator'; diff --git a/components/button/button.tsx b/components/button/button.tsx index c5b7e167b6..5435e38175 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -3,8 +3,8 @@ import { omit, toArray, useComposeRef } from '@rc-component/util'; import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import isValidNode from '../_util/isValidNode'; import { devUseWarning } from '../_util/warning'; import Wave from '../_util/wave'; @@ -172,7 +172,7 @@ const InternalCompoundedButton = React.forwardRef< } return ['default', 'outlined']; - }, [type, color, variant, danger, button?.variant, button?.color]); + }, [color, variant, type, danger, button?.color, button?.variant, mergedType]); const [mergedColor, mergedVariant] = useMemo(() => { if (ghost && parsedVariant === 'solid') { diff --git a/components/calendar/generateCalendar.tsx b/components/calendar/generateCalendar.tsx index 507ad49f18..a957db34d3 100644 --- a/components/calendar/generateCalendar.tsx +++ b/components/calendar/generateCalendar.tsx @@ -6,8 +6,8 @@ import type { CellRenderInfo } from '@rc-component/picker/lib/interface'; import { useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { AnyObject } from '../_util/type'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/card/Card.tsx b/components/card/Card.tsx index 6209753441..d4b2fffd90 100644 --- a/components/card/Card.tsx +++ b/components/card/Card.tsx @@ -3,8 +3,8 @@ import type { Tab, TabBarExtraContent } from '@rc-component/tabs/lib/interface'; import { omit, toArray } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import useSize from '../config-provider/hooks/useSize'; diff --git a/components/card/Meta.tsx b/components/card/Meta.tsx index 7317b21f11..e2929cf7bd 100644 --- a/components/card/Meta.tsx +++ b/components/card/Meta.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; export type SemanticName = 'root' | 'section' | 'avatar' | 'title' | 'description'; diff --git a/components/cascader/index.tsx b/components/cascader/index.tsx index 6911b8e02e..67b3635260 100644 --- a/components/cascader/index.tsx +++ b/components/cascader/index.tsx @@ -11,14 +11,13 @@ import type { Placement } from '@rc-component/select/lib/BaseSelect'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +} from '../_util/hooks'; import type { SelectCommonPlacement } from '../_util/motion'; import { getTransitionName } from '../_util/motion'; import genPurePanel from '../_util/PurePanel'; diff --git a/components/checkbox/Checkbox.tsx b/components/checkbox/Checkbox.tsx index b863fb55db..86109e277a 100644 --- a/components/checkbox/Checkbox.tsx +++ b/components/checkbox/Checkbox.tsx @@ -4,8 +4,8 @@ import RcCheckbox from '@rc-component/checkbox'; import { composeRef } from '@rc-component/util/lib/ref'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import Wave from '../_util/wave'; import { TARGET_CLS } from '../_util/wave/interface'; diff --git a/components/collapse/Collapse.tsx b/components/collapse/Collapse.tsx index 9e4925fd5d..5a915c6b95 100644 --- a/components/collapse/Collapse.tsx +++ b/components/collapse/Collapse.tsx @@ -6,13 +6,13 @@ import type { CSSMotionProps } from '@rc-component/motion'; import { omit, toArray } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; import initCollapseMotion from '../_util/motion'; import { cloneElement } from '../_util/reactNode'; import { devUseWarning } from '../_util/warning'; diff --git a/components/color-picker/ColorPicker.tsx b/components/color-picker/ColorPicker.tsx index af31ea6aa7..b89e9059b9 100644 --- a/components/color-picker/ColorPicker.tsx +++ b/components/color-picker/ColorPicker.tsx @@ -3,7 +3,7 @@ import { useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; import ContextIsolator from '../_util/ContextIsolator'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import genPurePanel from '../_util/PurePanel'; import { getStatusClassNames } from '../_util/statusUtils'; import { devUseWarning } from '../_util/warning'; diff --git a/components/color-picker/components/PanelPicker/index.tsx b/components/color-picker/components/PanelPicker/index.tsx index 2a22e64f41..f3928fc18f 100644 --- a/components/color-picker/components/PanelPicker/index.tsx +++ b/components/color-picker/components/PanelPicker/index.tsx @@ -4,6 +4,7 @@ import RcColorPicker from '@rc-component/color-picker'; import type { Color } from '@rc-component/color-picker'; import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; +import { useForceUpdate } from '../../../_util/hooks'; import Segmented from '../../../segmented'; import { AggregationColor } from '../../color'; import { PanelPickerContext } from '../../context'; @@ -70,7 +71,7 @@ const PanelPicker: FC = () => { if (!isSingle) { setLockedColor(colors[activeIndex]?.color); } - }, [gradientDragging, activeIndex]); + }, [isSingle, colors, gradientDragging, activeIndex]); const activeColor = React.useMemo(() => { if (isSingle) { @@ -83,11 +84,12 @@ const PanelPicker: FC = () => { } return colors[activeIndex]?.color; - }, [value, activeIndex, isSingle, lockedColor, gradientDragging]); + }, [colors, value, activeIndex, isSingle, lockedColor, gradientDragging]); // ========================= Picker Color ========================= const [pickerColor, setPickerColor] = React.useState(activeColor); - const [forceSync, setForceSync] = React.useState(0); + + const [forceSync, setForceSync] = useForceUpdate(); const mergedPickerColor = pickerColor?.equals(activeColor) ? activeColor : pickerColor; @@ -148,7 +150,7 @@ const PanelPicker: FC = () => { // Back of origin color in case in controlled // This will set after `onChangeComplete` to avoid `setState` trigger rerender // which will make `fillColor` get wrong `color.cleared` state - setForceSync((ori) => ori + 1); + setForceSync(); }; const onInputChange = (colorValue: AggregationColor) => { diff --git a/components/color-picker/interface.ts b/components/color-picker/interface.ts index 7b37044fc0..f803daf6d2 100644 --- a/components/color-picker/interface.ts +++ b/components/color-picker/interface.ts @@ -9,7 +9,7 @@ import type { SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; import type { SizeType } from '../config-provider/SizeContext'; import type { PopoverProps } from '../popover'; import type { TooltipPlacement } from '../tooltip'; diff --git a/components/config-provider/__tests__/style.test.tsx b/components/config-provider/__tests__/style.test.tsx index 152939690f..6907c2646f 100644 --- a/components/config-provider/__tests__/style.test.tsx +++ b/components/config-provider/__tests__/style.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Masonry from 'antd/es/masonry'; import ConfigProvider from '..'; -import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks'; import { fireEvent, render } from '../../../tests/utils'; import Alert from '../../alert'; import Anchor from '../../anchor'; diff --git a/components/config-provider/context.ts b/components/config-provider/context.ts index 907b7148ea..210d18c0e0 100644 --- a/components/config-provider/context.ts +++ b/components/config-provider/context.ts @@ -1,6 +1,6 @@ import * as React from 'react'; -import type { MaskType } from '../_util/hooks/useMergedMask'; +import type { MaskType } from '../_util/hooks'; import type { AnyObject } from '../_util/type'; import type { WarningContextProps } from '../_util/warning'; import type { ShowWaveEffect } from '../_util/wave/interface'; diff --git a/components/date-picker/generatePicker/generateRangePicker.tsx b/components/date-picker/generatePicker/generateRangePicker.tsx index 7a78768c38..43002e592f 100644 --- a/components/date-picker/generatePicker/generateRangePicker.tsx +++ b/components/date-picker/generatePicker/generateRangePicker.tsx @@ -7,7 +7,7 @@ import type { GenerateConfig } from '@rc-component/picker/lib/generate/index'; import { clsx } from 'clsx'; import ContextIsolator from '../../_util/ContextIsolator'; -import { useZIndex } from '../../_util/hooks/useZIndex'; +import { useZIndex } from '../../_util/hooks'; import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; import type { AnyObject } from '../../_util/type'; import { devUseWarning } from '../../_util/warning'; diff --git a/components/date-picker/generatePicker/generateSinglePicker.tsx b/components/date-picker/generatePicker/generateSinglePicker.tsx index d1b62bc835..5f5a728388 100644 --- a/components/date-picker/generatePicker/generateSinglePicker.tsx +++ b/components/date-picker/generatePicker/generateSinglePicker.tsx @@ -7,7 +7,7 @@ import type { PickerMode } from '@rc-component/picker/lib/interface'; import { clsx } from 'clsx'; import ContextIsolator from '../../_util/ContextIsolator'; -import { useZIndex } from '../../_util/hooks/useZIndex'; +import { useZIndex } from '../../_util/hooks'; import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; import type { AnyObject } from '../../_util/type'; import { devUseWarning } from '../../_util/warning'; diff --git a/components/date-picker/generatePicker/interface.ts b/components/date-picker/generatePicker/interface.ts index 1ee6d03afc..0469551146 100644 --- a/components/date-picker/generatePicker/interface.ts +++ b/components/date-picker/generatePicker/interface.ts @@ -14,7 +14,7 @@ import type { SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../../_util/hooks/useMergeSemantic'; +} from '../../_util/hooks'; import type { InputStatus } from '../../_util/statusUtils'; import type { AnyObject } from '../../_util/type'; import type { Variant } from '../../config-provider'; diff --git a/components/date-picker/hooks/useMergedPickerSemantic.ts b/components/date-picker/hooks/useMergedPickerSemantic.ts index b8aba871dc..2d9931786f 100644 --- a/components/date-picker/hooks/useMergedPickerSemantic.ts +++ b/components/date-picker/hooks/useMergedPickerSemantic.ts @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../../_util/hooks'; import type { AnyObject } from '../../_util/type'; import { useComponentConfig } from '../../config-provider/context'; import type { RequiredSemanticPicker } from '../generatePicker/interface'; diff --git a/components/descriptions/Cell.tsx b/components/descriptions/Cell.tsx index e50ee00b56..c70a484768 100644 --- a/components/descriptions/Cell.tsx +++ b/components/descriptions/Cell.tsx @@ -3,8 +3,8 @@ import type { JSX } from 'react'; import { clsx } from 'clsx'; import type { DescriptionsClassNamesType, DescriptionsStylesType } from '.'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import DescriptionsContext from './DescriptionsContext'; import type { SemanticName } from './DescriptionsContext'; diff --git a/components/descriptions/DescriptionsContext.ts b/components/descriptions/DescriptionsContext.ts index 55dc2731a1..e8f1cc9d2e 100644 --- a/components/descriptions/DescriptionsContext.ts +++ b/components/descriptions/DescriptionsContext.ts @@ -1,6 +1,6 @@ import React from 'react'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; export type SemanticName = 'label' | 'content'; diff --git a/components/descriptions/Item.ts b/components/descriptions/Item.ts index 0af18d25da..ed20e70f5a 100644 --- a/components/descriptions/Item.ts +++ b/components/descriptions/Item.ts @@ -1,6 +1,6 @@ import type * as React from 'react'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import type { Breakpoint } from '../_util/responsiveObserver'; type SemanticName = 'label' | 'content'; diff --git a/components/descriptions/index.tsx b/components/descriptions/index.tsx index 2ee3c03c67..2c24452004 100644 --- a/components/descriptions/index.tsx +++ b/components/descriptions/index.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { Breakpoint } from '../_util/responsiveObserver'; import { matchScreen } from '../_util/responsiveObserver'; import { devUseWarning } from '../_util/warning'; diff --git a/components/divider/__tests__/index.test.tsx b/components/divider/__tests__/index.test.tsx index bef1ce230f..4985f20e3c 100644 --- a/components/divider/__tests__/index.test.tsx +++ b/components/divider/__tests__/index.test.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { ConfigProvider } from 'antd'; import Divider from '..'; -import type { Orientation } from '../../_util/hooks/useOrientation'; +import type { Orientation } from '../../_util/hooks'; import mountTest from '../../../tests/shared/mountTest'; import { render } from '../../../tests/utils'; import type { TitlePlacement } from '../index'; diff --git a/components/divider/index.tsx b/components/divider/index.tsx index db2ad237f9..227258b5dc 100644 --- a/components/divider/index.tsx +++ b/components/divider/index.tsx @@ -1,10 +1,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useOrientation from '../_util/hooks/useOrientation'; -import type { Orientation } from '../_util/hooks/useOrientation'; +import { useMergeSemantic, useOrientation } from '../_util/hooks'; +import type { Orientation, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import useSize from '../config-provider/hooks/useSize'; diff --git a/components/drawer/DrawerPanel.tsx b/components/drawer/DrawerPanel.tsx index d8021a0a7f..433a663a9a 100644 --- a/components/drawer/DrawerPanel.tsx +++ b/components/drawer/DrawerPanel.tsx @@ -3,10 +3,8 @@ import type { DrawerProps as RCDrawerProps } from '@rc-component/drawer'; import { clsx } from 'clsx'; import type { DrawerProps } from '.'; -import useClosable, { pickClosable } from '../_util/hooks/useClosable'; -import type { ClosableType } from '../_util/hooks/useClosable'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { pickClosable, useClosable, useMergeSemantic } from '../_util/hooks'; +import type { ClosableType, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; import Skeleton from '../skeleton'; diff --git a/components/drawer/__tests__/Drawer.test.tsx b/components/drawer/__tests__/Drawer.test.tsx index 6d779b5c31..1c171f0c7a 100644 --- a/components/drawer/__tests__/Drawer.test.tsx +++ b/components/drawer/__tests__/Drawer.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import type { DrawerProps } from '..'; import Drawer from '..'; -import type { MaskType } from '../../_util/hooks/useMergedMask'; +import type { MaskType } from '../../_util/hooks'; import { resetWarned } from '../../_util/warning'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index 6fa8a43e0c..cb6e3f8e5d 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -7,10 +7,8 @@ import { composeRef } from '@rc-component/util/lib/ref'; import { clsx } from 'clsx'; import ContextIsolator from '../_util/ContextIsolator'; -import type { MaskType } from '../_util/hooks/useMergedMask'; -import useMergedMask from '../_util/hooks/useMergedMask'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergedMask, useMergeSemantic, useZIndex } from '../_util/hooks'; +import type { MaskType } from '../_util/hooks'; import { getTransitionName } from '../_util/motion'; import { devUseWarning } from '../_util/warning'; import zIndexContext from '../_util/zindexContext'; diff --git a/components/dropdown/dropdown.tsx b/components/dropdown/dropdown.tsx index c26c6e64dd..6f0f27814f 100644 --- a/components/dropdown/dropdown.tsx +++ b/components/dropdown/dropdown.tsx @@ -7,9 +7,8 @@ import type { AlignType } from '@rc-component/trigger'; import { omit, useControlledState, useEvent } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import isPrimitive from '../_util/isPrimitive'; import type { AdjustOverflow } from '../_util/placements'; import getPlacements from '../_util/placements'; diff --git a/components/empty/index.tsx b/components/empty/index.tsx index d1528e1d40..7b04883f44 100644 --- a/components/empty/index.tsx +++ b/components/empty/index.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import { useLocale } from '../locale'; diff --git a/components/flex/index.tsx b/components/flex/index.tsx index 2322afc7d4..59cb4bb6fa 100644 --- a/components/flex/index.tsx +++ b/components/flex/index.tsx @@ -3,7 +3,7 @@ import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; import { isPresetSize } from '../_util/gapSize'; -import useOrientation from '../_util/hooks/useOrientation'; +import { useOrientation } from '../_util/hooks'; import { ConfigContext } from '../config-provider'; import type { ConfigConsumerProps } from '../config-provider'; import type { FlexProps } from './interface'; diff --git a/components/flex/interface.ts b/components/flex/interface.ts index 82592502e8..834ac3ae44 100644 --- a/components/flex/interface.ts +++ b/components/flex/interface.ts @@ -1,6 +1,6 @@ import type React from 'react'; -import type { Orientation } from '../_util/hooks/useOrientation'; +import type { Orientation } from '../_util/hooks'; import type { AnyObject, CustomComponent } from '../_util/type'; import type { SizeType } from '../config-provider/SizeContext'; diff --git a/components/float-button/FloatButton.tsx b/components/float-button/FloatButton.tsx index b5aab42d1d..18afbe4153 100644 --- a/components/float-button/FloatButton.tsx +++ b/components/float-button/FloatButton.tsx @@ -4,9 +4,8 @@ import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; import convertToTooltipProps from '../_util/convertToTooltipProps'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import Badge from '../badge'; import type { BadgeProps } from '../badge'; diff --git a/components/float-button/FloatButtonGroup.tsx b/components/float-button/FloatButtonGroup.tsx index 692c2e54b2..16aea89858 100644 --- a/components/float-button/FloatButtonGroup.tsx +++ b/components/float-button/FloatButtonGroup.tsx @@ -5,9 +5,8 @@ import CSSMotion from '@rc-component/motion'; import { useControlledState, useEvent } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import useCSSVarCls from '../config-provider/hooks/useCSSVarCls'; diff --git a/components/float-button/__tests__/semantic.test.tsx b/components/float-button/__tests__/semantic.test.tsx index 0d92429e81..f9fff955b8 100644 --- a/components/float-button/__tests__/semantic.test.tsx +++ b/components/float-button/__tests__/semantic.test.tsx @@ -3,7 +3,7 @@ import type { GetProp } from 'antd/es/_util/type'; import FloatButton from '..'; import type { FloatButtonGroupProps, FloatButtonProps } from '..'; -import type { SemanticClassNames } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames } from '../../_util/hooks'; import { render } from '../../../tests/utils'; import type { FloatButtonSemanticName } from '../FloatButton'; diff --git a/components/form/Form.tsx b/components/form/Form.tsx index 07219ad5ae..1f886de107 100644 --- a/components/form/Form.tsx +++ b/components/form/Form.tsx @@ -8,8 +8,8 @@ import type { } from '@rc-component/form/lib/interface'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { Variant } from '../config-provider'; import { useComponentConfig } from '../config-provider/context'; import DisabledContext, { DisabledContextProvider } from '../config-provider/DisabledContext'; diff --git a/components/form/context.tsx b/components/form/context.tsx index 878e90900d..386d1b407a 100644 --- a/components/form/context.tsx +++ b/components/form/context.tsx @@ -5,7 +5,7 @@ import type { FormProviderProps as RcFormProviderProps } from '@rc-component/for import type { Meta } from '@rc-component/form/lib/interface'; import { omit } from '@rc-component/util'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import type { Variant } from '../config-provider'; import type { ColProps } from '../grid/col'; import type { FormInstance, FormLayout, FormSemanticName, RequiredMark } from './Form'; diff --git a/components/grid/hooks/useBreakpoint.tsx b/components/grid/hooks/useBreakpoint.tsx index e4c6ea74af..126aa2bef7 100644 --- a/components/grid/hooks/useBreakpoint.tsx +++ b/components/grid/hooks/useBreakpoint.tsx @@ -1,7 +1,7 @@ import { useRef } from 'react'; import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; -import useForceUpdate from '../../_util/hooks/useForceUpdate'; +import { useForceUpdate } from '../../_util/hooks'; import type { ScreenMap } from '../../_util/responsiveObserver'; import useResponsiveObserver from '../../_util/responsiveObserver'; @@ -13,7 +13,7 @@ function useBreakpoint( defaultScreens: ScreenMap | null = {} as ScreenMap, ): ScreenMap | null { const screensRef = useRef(defaultScreens); - const forceUpdate = useForceUpdate(); + const [, forceUpdate] = useForceUpdate(); const responsiveObserver = useResponsiveObserver(); useLayoutEffect(() => { diff --git a/components/image/PreviewGroup.tsx b/components/image/PreviewGroup.tsx index aba3dccba8..0f9eca11c1 100644 --- a/components/image/PreviewGroup.tsx +++ b/components/image/PreviewGroup.tsx @@ -11,8 +11,8 @@ import RcImage from '@rc-component/image'; import { clsx } from 'clsx'; import type { DeprecatedPreviewConfig, ImageClassNamesType, ImageStylesType } from '.'; -import type { MaskType } from '../_util/hooks/useMergedMask'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { MaskType } from '../_util/hooks'; import type { GetProps } from '../_util/type'; import { useComponentConfig } from '../config-provider/context'; import useCSSVarCls from '../config-provider/hooks/useCSSVarCls'; @@ -103,6 +103,7 @@ const InternalPreviewGroup: React.FC = ({ getContextPopupContainer, icons, ); + const { mask: mergedMask, blurClassName } = mergedPreview ?? {}; // =========== Merged Props for Semantic =========== diff --git a/components/image/__tests__/index.test.tsx b/components/image/__tests__/index.test.tsx index 252c32244e..61c2226d30 100644 --- a/components/image/__tests__/index.test.tsx +++ b/components/image/__tests__/index.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Modal } from 'antd'; import Image from '..'; -import type { MaskType } from '../../_util/hooks/useMergedMask'; +import type { MaskType } from '../../_util/hooks'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { fireEvent, render } from '../../../tests/utils'; diff --git a/components/image/hooks/useMergedPreviewConfig.ts b/components/image/hooks/useMergedPreviewConfig.ts index 3b251d1fa4..7b247448d1 100644 --- a/components/image/hooks/useMergedPreviewConfig.ts +++ b/components/image/hooks/useMergedPreviewConfig.ts @@ -2,13 +2,12 @@ import React from 'react'; import { clsx } from 'clsx'; import type { PreviewConfig } from '..'; -import useMergedMask from '../../_util/hooks/useMergedMask'; -import type { MaskType } from '../../_util/hooks/useMergedMask'; -import { useZIndex } from '../../_util/hooks/useZIndex'; +import { useMergedMask, useZIndex } from '../../_util/hooks'; +import type { MaskType } from '../../_util/hooks'; import { getTransitionName } from '../../_util/motion'; import type { GroupPreviewConfig } from '../PreviewGroup'; -export default function useMergedPreviewConfig( +const useMergedPreviewConfig = ( previewConfig: T, contextPreviewConfig: T, prefixCls: string, @@ -16,9 +15,7 @@ export default function useMergedPreviewConfig { const [zIndex] = useZIndex('ImagePreview', previewConfig?.zIndex); const [mergedPreviewMask, blurClassName] = useMergedMask( previewConfig?.mask as MaskType, @@ -62,4 +59,6 @@ export default function useMergedPreviewConfig { 'data-testid'?: string; diff --git a/components/notification/style/index.ts b/components/notification/style/index.ts index b1c211f41f..1158d544d4 100644 --- a/components/notification/style/index.ts +++ b/components/notification/style/index.ts @@ -1,7 +1,7 @@ import type { CSSObject } from '@ant-design/cssinjs'; import { Keyframes, unit } from '@ant-design/cssinjs'; -import { CONTAINER_MAX_OFFSET } from '../../_util/hooks/useZIndex'; +import { CONTAINER_MAX_OFFSET } from '../../_util/hooks'; import { genFocusStyle, resetComponent } from '../../style'; import type { AliasToken, FullToken, GenerateStyle, GenStyleFn } from '../../theme/internal'; import { genStyleHooks, mergeToken } from '../../theme/internal'; diff --git a/components/notification/useNotification.tsx b/components/notification/useNotification.tsx index b7a7853450..29489f37f5 100644 --- a/components/notification/useNotification.tsx +++ b/components/notification/useNotification.tsx @@ -10,13 +10,15 @@ import type { } from '@rc-component/notification'; import { clsx } from 'clsx'; -import { computeClosable, pickClosable } from '../_util/hooks/useClosable'; -import useMergeSemantic, { +import { + computeClosable, mergeClassNames, mergeStyles, + pickClosable, resolveStyleOrClass, -} from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; + useMergeSemantic, +} from '../_util/hooks'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { ConfigContext } from '../config-provider'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/pagination/Pagination.tsx b/components/pagination/Pagination.tsx index ad9065a43f..524153de8e 100644 --- a/components/pagination/Pagination.tsx +++ b/components/pagination/Pagination.tsx @@ -11,8 +11,8 @@ import RcPagination from '@rc-component/pagination'; import enUS from '@rc-component/pagination/lib/locale/en_US'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import useSize from '../config-provider/hooks/useSize'; diff --git a/components/popconfirm/PurePanel.tsx b/components/popconfirm/PurePanel.tsx index 02e8d40503..f02b5b66a8 100644 --- a/components/popconfirm/PurePanel.tsx +++ b/components/popconfirm/PurePanel.tsx @@ -5,7 +5,7 @@ import { clsx } from 'clsx'; import type { PopconfirmProps } from '.'; import ActionButton from '../_util/ActionButton'; import { getRenderPropValue } from '../_util/getRenderPropValue'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import Button from '../button'; import { convertLegacyProps } from '../button/buttonHelpers'; import { ConfigContext } from '../config-provider'; diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index 6872b24ff2..40b7dd3b22 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -4,8 +4,8 @@ import { omit, useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; import type { RenderFunction } from '../_util/getRenderPropValue'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import type { ButtonProps, LegacyButtonType } from '../button/button'; import { useComponentConfig } from '../config-provider/context'; import type { PopoverProps, PopoverSemanticName } from '../popover'; diff --git a/components/popover/PurePanel.tsx b/components/popover/PurePanel.tsx index 3229252cc4..5cdab128ee 100644 --- a/components/popover/PurePanel.tsx +++ b/components/popover/PurePanel.tsx @@ -9,8 +9,8 @@ import type { PopoverStylesType, } from '.'; import { getRenderPropValue } from '../_util/getRenderPropValue'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { ConfigContext } from '../config-provider'; import useStyle from './style'; diff --git a/components/popover/index.tsx b/components/popover/index.tsx index 467c9d936b..ae3f3c041a 100644 --- a/components/popover/index.tsx +++ b/components/popover/index.tsx @@ -6,8 +6,8 @@ import { clsx } from 'clsx'; import type { RenderFunction } from '../_util/getRenderPropValue'; import { getRenderPropValue } from '../_util/getRenderPropValue'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import { getTransitionName } from '../_util/motion'; import { cloneElement } from '../_util/reactNode'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/progress/Circle.tsx b/components/progress/Circle.tsx index 12a8ec8350..985bf55df4 100644 --- a/components/progress/Circle.tsx +++ b/components/progress/Circle.tsx @@ -4,7 +4,7 @@ import { Circle as RCCircle } from '@rc-component/progress'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; import Tooltip from '../tooltip'; import type { GapPosition, ProgressGradient, ProgressProps, SemanticName } from './progress'; diff --git a/components/progress/Line.tsx b/components/progress/Line.tsx index 078f0373f8..98d9155956 100644 --- a/components/progress/Line.tsx +++ b/components/progress/Line.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { presetPrimaryColors } from '@ant-design/colors'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import type { DirectionType } from '../config-provider'; import type { diff --git a/components/progress/Steps.tsx b/components/progress/Steps.tsx index 9cc8e11b4f..232203ef21 100644 --- a/components/progress/Steps.tsx +++ b/components/progress/Steps.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import type { ProgressProps, SemanticName } from './progress'; import { getSize } from './utils'; diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index dd2b00ac78..3cf9ff62b7 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -7,13 +7,13 @@ import CloseOutlined from '@ant-design/icons/CloseOutlined'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import Circle from './Circle'; diff --git a/components/qr-code/index.tsx b/components/qr-code/index.tsx index 28b297ec84..c5772fc545 100644 --- a/components/qr-code/index.tsx +++ b/components/qr-code/index.tsx @@ -4,7 +4,7 @@ import { omit } from '@rc-component/util'; import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import { useLocale } from '../locale'; diff --git a/components/qr-code/interface.ts b/components/qr-code/interface.ts index 37922e0605..49895cfc2d 100644 --- a/components/qr-code/interface.ts +++ b/components/qr-code/interface.ts @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import type { QRProps } from '@rc-component/qrcode'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { Locale } from '../locale'; type ImageSettings = QRProps['imageSettings']; diff --git a/components/radio/group.tsx b/components/radio/group.tsx index b7f2ae5642..aad2494d15 100644 --- a/components/radio/group.tsx +++ b/components/radio/group.tsx @@ -4,7 +4,7 @@ import useId from '@rc-component/util/lib/hooks/useId'; import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { clsx } from 'clsx'; -import useOrientation from '../_util/hooks/useOrientation'; +import { useOrientation } from '../_util/hooks'; import { ConfigContext } from '../config-provider'; import useCSSVarCls from '../config-provider/hooks/useCSSVarCls'; import useSize from '../config-provider/hooks/useSize'; diff --git a/components/radio/interface.ts b/components/radio/interface.ts index cfed86cf95..537bc254a4 100644 --- a/components/radio/interface.ts +++ b/components/radio/interface.ts @@ -1,7 +1,6 @@ import type * as React from 'react'; -import type { Orientation } from '../_util/hooks/useOrientation'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import type { Orientation, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { AbstractCheckboxProps } from '../checkbox/Checkbox'; import type { AbstractCheckboxGroupProps } from '../checkbox/Group'; import type { SizeType } from '../config-provider/SizeContext'; diff --git a/components/radio/radio.tsx b/components/radio/radio.tsx index 39c67ab056..1073fa7457 100644 --- a/components/radio/radio.tsx +++ b/components/radio/radio.tsx @@ -3,8 +3,8 @@ import RcCheckbox from '@rc-component/checkbox'; import { composeRef } from '@rc-component/util/lib/ref'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import Wave from '../_util/wave'; import { TARGET_CLS } from '../_util/wave/interface'; diff --git a/components/result/index.tsx b/components/result/index.tsx index 8cb27412e7..ae8c1c3c9f 100644 --- a/components/result/index.tsx +++ b/components/result/index.tsx @@ -5,8 +5,8 @@ import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled'; import WarningFilled from '@ant-design/icons/WarningFilled'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import noFound from './noFound'; diff --git a/components/segmented/index.tsx b/components/segmented/index.tsx index 1afd68faca..5db6bb5cf4 100644 --- a/components/segmented/index.tsx +++ b/components/segmented/index.tsx @@ -9,10 +9,8 @@ import RcSegmented from '@rc-component/segmented'; import useId from '@rc-component/util/lib/hooks/useId'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useOrientation from '../_util/hooks/useOrientation'; -import type { Orientation } from '../_util/hooks/useOrientation'; +import { useMergeSemantic, useOrientation } from '../_util/hooks'; +import type { Orientation, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; import useSize from '../config-provider/hooks/useSize'; import type { SizeType } from '../config-provider/SizeContext'; diff --git a/components/select/index.tsx b/components/select/index.tsx index 7b0fbe6763..cd1a8d4a5e 100755 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -7,14 +7,13 @@ import type { BaseOptionType, DefaultOptionType } from '@rc-component/select/lib import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +} from '../_util/hooks'; import type { SelectCommonPlacement } from '../_util/motion'; import { getTransitionName } from '../_util/motion'; import genPurePanel from '../_util/PurePanel'; diff --git a/components/skeleton/Element.tsx b/components/skeleton/Element.tsx index 2e55a47bb4..ab941441d0 100644 --- a/components/skeleton/Element.tsx +++ b/components/skeleton/Element.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; export type ElementSemanticName = 'root' | 'content'; diff --git a/components/skeleton/Skeleton.tsx b/components/skeleton/Skeleton.tsx index 6138e6833e..c55d41b842 100644 --- a/components/skeleton/Skeleton.tsx +++ b/components/skeleton/Skeleton.tsx @@ -1,8 +1,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; import type { AvatarProps } from './Avatar'; import SkeletonAvatar from './Avatar'; diff --git a/components/skeleton/__tests__/semantic.test.tsx b/components/skeleton/__tests__/semantic.test.tsx index 4810f326cb..50295242aa 100644 --- a/components/skeleton/__tests__/semantic.test.tsx +++ b/components/skeleton/__tests__/semantic.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Skeleton from '..'; import type { SkeletonProps } from '..'; -import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks'; import { render } from '../../../tests/utils'; type SemanticName = 'root' | 'header' | 'section' | 'avatar' | 'title' | 'paragraph'; diff --git a/components/skeleton/demo/_semantic.tsx b/components/skeleton/demo/_semantic.tsx index ae3bd7c389..5309e52357 100644 --- a/components/skeleton/demo/_semantic.tsx +++ b/components/skeleton/demo/_semantic.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Skeleton } from 'antd'; -import type { SemanticClassNames } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames } from '../../_util/hooks'; import useLocale from '../../../.dumi/hooks/useLocale'; import SemanticPreview from '../../../.dumi/theme/common/SemanticPreview'; import type { SemanticName } from '../Skeleton'; diff --git a/components/slider/index.tsx b/components/slider/index.tsx index cab334b99d..becf94e216 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -5,10 +5,8 @@ import type { SliderRef } from '@rc-component/slider/lib/Slider'; import raf from '@rc-component/util/lib/raf'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useOrientation from '../_util/hooks/useOrientation'; -import type { Orientation } from '../_util/hooks/useOrientation'; +import { useMergeSemantic, useOrientation } from '../_util/hooks'; +import type { Orientation, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { GetProp } from '../_util/type'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/space/Compact.tsx b/components/space/Compact.tsx index 4acbabfa00..82f8ac53b4 100644 --- a/components/space/Compact.tsx +++ b/components/space/Compact.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import { toArray } from '@rc-component/util'; import { clsx } from 'clsx'; -import type { Orientation } from '../_util/hooks/useOrientation'; -import useOrientation from '../_util/hooks/useOrientation'; +import { useOrientation } from '../_util/hooks'; +import type { Orientation } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import type { DirectionType } from '../config-provider'; import { ConfigContext } from '../config-provider'; diff --git a/components/space/Item.tsx b/components/space/Item.tsx index 0e0acc89b4..9d72a58987 100644 --- a/components/space/Item.tsx +++ b/components/space/Item.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { SpaceContext } from './context'; import type { SpaceContextType } from './context'; diff --git a/components/space/__tests__/index.test.tsx b/components/space/__tests__/index.test.tsx index 3c1cb8526a..9ff2d17fee 100644 --- a/components/space/__tests__/index.test.tsx +++ b/components/space/__tests__/index.test.tsx @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import Space from '..'; -import type { Orientation } from '../../_util/hooks/useOrientation'; +import type { Orientation } from '../../_util/hooks'; import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; import { fireEvent, render } from '../../../tests/utils'; diff --git a/components/space/index.tsx b/components/space/index.tsx index 529b484cbd..f4c4b1d71b 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -3,10 +3,8 @@ import { toArray } from '@rc-component/util'; import { clsx } from 'clsx'; import { isPresetSize, isValidGapNumber } from '../_util/gapSize'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import type { Orientation } from '../_util/hooks/useOrientation'; -import useOrientation from '../_util/hooks/useOrientation'; +import { useMergeSemantic, useOrientation } from '../_util/hooks'; +import type { Orientation, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import type { SizeType } from '../config-provider/SizeContext'; @@ -133,17 +131,8 @@ const InternalSpace = React.forwardRef((props, ref) const itemClassName = clsx(`${prefixCls}-item`, mergedClassNames.item); - const memoizedLatestIndex = React.useMemo(() => { - return childNodes.reduce((latest, child, i) => { - if (child !== null && child !== undefined) { - return i; - } - return latest; - }, 0); - }, [childNodes]); - // Calculate latest one - const nodes = childNodes.map((child, i) => { + const renderedItems = childNodes.map((child, i) => { const key = child?.key || `${itemClassName}-${i}`; return ( ((props, ref) // ======================== Warning ========================== if (process.env.NODE_ENV !== 'production') { const warning = devUseWarning('Space'); - [ ['direction', 'orientation'], ['split', 'separator'], @@ -173,10 +161,13 @@ const InternalSpace = React.forwardRef((props, ref) }); } - const spaceContext = React.useMemo( - () => ({ latestIndex: memoizedLatestIndex }), - [memoizedLatestIndex], - ); + const memoizedSpaceContext = React.useMemo(() => { + const calcLatestIndex = childNodes.reduce( + (latest, child, i) => (child !== null && child !== undefined ? i : latest), + 0, + ); + return { latestIndex: calcLatestIndex }; + }, [childNodes]); // =========================== Render =========================== if (childNodes.length === 0) { @@ -204,7 +195,7 @@ const InternalSpace = React.forwardRef((props, ref) style={{ ...gapStyle, ...mergedStyles.root, ...contextStyle, ...style }} {...restProps} > - {nodes} + {renderedItems} ); }); diff --git a/components/spin/index.tsx b/components/spin/index.tsx index 32a81b48e7..4628b13a50 100644 --- a/components/spin/index.tsx +++ b/components/spin/index.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import { clsx } from 'clsx'; import { debounce } from 'throttle-debounce'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import Indicator from './Indicator'; diff --git a/components/splitter/Splitter.tsx b/components/splitter/Splitter.tsx index 7cc7564334..751793c2a3 100644 --- a/components/splitter/Splitter.tsx +++ b/components/splitter/Splitter.tsx @@ -4,8 +4,7 @@ import ResizeObserver from '@rc-component/resize-observer'; import { useEvent } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import useOrientation from '../_util/hooks/useOrientation'; +import { useMergeSemantic, useOrientation } from '../_util/hooks'; import type { GetProp } from '../_util/type'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/splitter/__tests__/index.test.tsx b/components/splitter/__tests__/index.test.tsx index 2e3847b1fc..ea02916d2a 100644 --- a/components/splitter/__tests__/index.test.tsx +++ b/components/splitter/__tests__/index.test.tsx @@ -4,7 +4,7 @@ import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook'; import type { GetProps, SplitterProps } from 'antd'; import { ConfigProvider, Splitter } from 'antd'; -import type { Orientation } from '../../_util/hooks/useOrientation'; +import type { Orientation } from '../../_util/hooks'; import { resetWarned } from '../../_util/warning'; import { act, diff --git a/components/splitter/interface.ts b/components/splitter/interface.ts index 511cc3b6ad..e7ce6cecd1 100644 --- a/components/splitter/interface.ts +++ b/components/splitter/interface.ts @@ -1,10 +1,10 @@ import type { + Orientation, SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; -import type { Orientation } from '../_util/hooks/useOrientation'; +} from '../_util/hooks'; import type { ShowCollapsibleIconMode } from './SplitBar'; // ================ outside ================ diff --git a/components/statistic/Statistic.tsx b/components/statistic/Statistic.tsx index 9d9911023b..da88e222ea 100644 --- a/components/statistic/Statistic.tsx +++ b/components/statistic/Statistic.tsx @@ -3,8 +3,8 @@ import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { clsx } from 'clsx'; import type { HTMLAriaDataAttributes } from '../_util/aria-data-attrs'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import Skeleton from '../skeleton'; diff --git a/components/steps/__tests__/semantic.test.tsx b/components/steps/__tests__/semantic.test.tsx index ea3e343d60..e5284695cc 100644 --- a/components/steps/__tests__/semantic.test.tsx +++ b/components/steps/__tests__/semantic.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import Steps from '..'; import type { StepsProps, StepsSemanticName } from '..'; -import type { SemanticClassNames } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames } from '../../_util/hooks'; import { render } from '../../../tests/utils'; describe('Steps.Semantic', () => { diff --git a/components/steps/index.tsx b/components/steps/index.tsx index 77406aadb6..820e5ad9a3 100644 --- a/components/steps/index.tsx +++ b/components/steps/index.tsx @@ -5,8 +5,8 @@ import RcSteps from '@rc-component/steps'; import type { StepsProps as RcStepsProps } from '@rc-component/steps/lib/Steps'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { GetProp } from '../_util/type'; import { devUseWarning } from '../_util/warning'; import Wave from '../_util/wave'; diff --git a/components/switch/index.tsx b/components/switch/index.tsx index 0d1091f8ff..ccd385302c 100755 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -5,8 +5,8 @@ import type { SwitchChangeEventHandler, SwitchClickEventHandler } from '@rc-comp import { useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; +import { useMergeSemantic } from '../_util/hooks'; import Wave from '../_util/wave'; import { useComponentConfig } from '../config-provider/context'; import DisabledContext from '../config-provider/DisabledContext'; diff --git a/components/table/InternalTable.tsx b/components/table/InternalTable.tsx index 6810c66e20..4c761918d2 100644 --- a/components/table/InternalTable.tsx +++ b/components/table/InternalTable.tsx @@ -5,14 +5,13 @@ import { convertChildrenToColumns } from '@rc-component/table/lib/hooks/useColum import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic, useProxyImperativeHandle } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; -import useProxyImperativeHandle from '../_util/hooks/useProxyImperativeHandle'; +} from '../_util/hooks'; import type { Breakpoint } from '../_util/responsiveObserver'; import scrollTo from '../_util/scrollTo'; import type { AnyObject } from '../_util/type'; diff --git a/components/table/hooks/useFilter/FilterDropdown.tsx b/components/table/hooks/useFilter/FilterDropdown.tsx index f48573b727..6764cd8a12 100644 --- a/components/table/hooks/useFilter/FilterDropdown.tsx +++ b/components/table/hooks/useFilter/FilterDropdown.tsx @@ -7,7 +7,7 @@ import { clsx } from 'clsx'; import type { FilterState } from '.'; import extendsObject from '../../../_util/extendsObject'; -import useSyncState from '../../../_util/hooks/useSyncState'; +import { useSyncState } from '../../../_util/hooks'; import { devUseWarning } from '../../../_util/warning'; import Button from '../../../button'; import type { CheckboxChangeEvent } from '../../../checkbox'; diff --git a/components/table/hooks/useSelection.tsx b/components/table/hooks/useSelection.tsx index e5b16e497e..91c54aa349 100644 --- a/components/table/hooks/useSelection.tsx +++ b/components/table/hooks/useSelection.tsx @@ -10,7 +10,7 @@ import { convertDataToEntities } from '@rc-component/tree/lib/utils/treeUtil'; import { useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMultipleSelect from '../../_util/hooks/useMultipleSelect'; +import { useMultipleSelect } from '../../_util/hooks'; import type { AnyObject } from '../../_util/type'; import { devUseWarning } from '../../_util/warning'; import type { CheckboxProps } from '../../checkbox'; diff --git a/components/tabs/index.tsx b/components/tabs/index.tsx index ade39bbe8b..6b7b9cbf76 100755 --- a/components/tabs/index.tsx +++ b/components/tabs/index.tsx @@ -8,13 +8,13 @@ import type { GetIndicatorSize } from '@rc-component/tabs/lib/hooks/useIndicator import type { EditableConfig, MoreProps, Tab } from '@rc-component/tabs/lib/interface'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { ConfigContext } from '../config-provider'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/tag/CheckableTagGroup.tsx b/components/tag/CheckableTagGroup.tsx index 0ba1cf2dae..74b6d434c9 100644 --- a/components/tag/CheckableTagGroup.tsx +++ b/components/tag/CheckableTagGroup.tsx @@ -4,7 +4,7 @@ import { useControlledState } from '@rc-component/util'; import pickAttrs from '@rc-component/util/lib/pickAttrs'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { useComponentConfig } from '../config-provider/context'; import useCSSVarCls from '../config-provider/hooks/useCSSVarCls'; import CheckableTag from './CheckableTag'; diff --git a/components/tag/index.tsx b/components/tag/index.tsx index 620e25bde9..7cdd687a37 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -3,10 +3,8 @@ import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; import type { PresetColorType, PresetStatusColorType } from '../_util/colors'; -import type { ClosableType } from '../_util/hooks/useClosable'; -import useClosable, { pickClosable } from '../_util/hooks/useClosable'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { pickClosable, useClosable, useMergeSemantic } from '../_util/hooks'; +import type { ClosableType, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { cloneElement, replaceElement } from '../_util/reactNode'; import type { LiteralUnion } from '../_util/type'; import { devUseWarning } from '../_util/warning'; diff --git a/components/time-picker/index.tsx b/components/time-picker/index.tsx index 99fc0554c3..de9661bfe7 100644 --- a/components/time-picker/index.tsx +++ b/components/time-picker/index.tsx @@ -8,7 +8,7 @@ import type { SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; import genPurePanel from '../_util/PurePanel'; import type { InputStatus } from '../_util/statusUtils'; import type { AnyObject } from '../_util/type'; diff --git a/components/timeline/Timeline.tsx b/components/timeline/Timeline.tsx index 6e8dbd5e77..4967a50dcb 100644 --- a/components/timeline/Timeline.tsx +++ b/components/timeline/Timeline.tsx @@ -2,8 +2,8 @@ import * as React from 'react'; import { UnstableContext } from '@rc-component/steps'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { GetProp, GetProps, LiteralUnion } from '../_util/type'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/timeline/__tests__/semantic.test.tsx b/components/timeline/__tests__/semantic.test.tsx index 508384ceb3..a6f0f28bb1 100644 --- a/components/timeline/__tests__/semantic.test.tsx +++ b/components/timeline/__tests__/semantic.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import TimeLine from '..'; -import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks'; import { render } from '../../../tests/utils'; type StepsSemanticName = diff --git a/components/tooltip/PurePanel.tsx b/components/tooltip/PurePanel.tsx index 55eb2b5790..0588dcc99a 100644 --- a/components/tooltip/PurePanel.tsx +++ b/components/tooltip/PurePanel.tsx @@ -3,7 +3,7 @@ import { Popup } from '@rc-component/tooltip'; import { clsx } from 'clsx'; import type { TooltipClassNamesType, TooltipProps, TooltipStylesType } from '.'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import { ConfigContext } from '../config-provider'; import useCSSVarCls from '../config-provider/hooks/useCSSVarCls'; import useStyle from './style'; diff --git a/components/tooltip/index.tsx b/components/tooltip/index.tsx index 0a9860c9d1..043390808a 100644 --- a/components/tooltip/index.tsx +++ b/components/tooltip/index.tsx @@ -12,9 +12,8 @@ import { clsx } from 'clsx'; import type { PresetColorType } from '../_util/colors'; import ContextIsolator from '../_util/ContextIsolator'; import type { RenderFunction } from '../_util/getRenderPropValue'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import { getTransitionName } from '../_util/motion'; import type { AdjustOverflow, PlacementsConfig } from '../_util/placements'; import getPlacements from '../_util/placements'; diff --git a/components/tour/PurePanel.tsx b/components/tour/PurePanel.tsx index df02ecf311..a496506d60 100644 --- a/components/tour/PurePanel.tsx +++ b/components/tour/PurePanel.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { clsx } from 'clsx'; -import useClosable from '../_util/hooks/useClosable'; +import { useClosable } from '../_util/hooks'; import { withPureRenderTheme } from '../_util/PurePanel'; import { cloneElement } from '../_util/reactNode'; import { ConfigContext } from '../config-provider'; diff --git a/components/tour/index.tsx b/components/tour/index.tsx index 40c0e9c88f..e3d1f291e5 100644 --- a/components/tour/index.tsx +++ b/components/tour/index.tsx @@ -3,8 +3,7 @@ import RCTour from '@rc-component/tour'; import type { TourProps as RcTourProps } from '@rc-component/tour'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; import getPlacements from '../_util/placements'; import zIndexContext from '../_util/zindexContext'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/tour/interface.ts b/components/tour/interface.ts index cd737c802b..9c60dbe6b9 100644 --- a/components/tour/interface.ts +++ b/components/tour/interface.ts @@ -9,7 +9,7 @@ import type { SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; +} from '../_util/hooks'; export type TourSemanticName = | 'root' diff --git a/components/transfer/ListItem.tsx b/components/transfer/ListItem.tsx index 23e9dc2a52..349d114add 100644 --- a/components/transfer/ListItem.tsx +++ b/components/transfer/ListItem.tsx @@ -3,7 +3,7 @@ import DeleteOutlined from '@ant-design/icons/DeleteOutlined'; import { clsx } from 'clsx'; import type { KeyWiseTransferItem, SemanticName } from '.'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import Checkbox from '../checkbox'; import { useLocale } from '../locale'; import defaultLocale from '../locale/en_US'; diff --git a/components/transfer/Section.tsx b/components/transfer/Section.tsx index 0534743ed2..dde450161b 100644 --- a/components/transfer/Section.tsx +++ b/components/transfer/Section.tsx @@ -3,7 +3,7 @@ import DownOutlined from '@ant-design/icons/DownOutlined'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../_util/hooks'; import { groupKeysMap } from '../_util/transKeys'; import Checkbox from '../checkbox'; import Dropdown from '../dropdown'; diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 3b02ce650b..c02d4f32d5 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -2,10 +2,8 @@ import type { ChangeEvent, CSSProperties } from 'react'; import React, { useCallback, useContext } from 'react'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; -import type { PrevSelectedIndex } from '../_util/hooks/useMultipleSelect'; -import useMultipleSelect from '../_util/hooks/useMultipleSelect'; +import { useMergeSemantic, useMultipleSelect } from '../_util/hooks'; +import type { PrevSelectedIndex, SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import type { InputStatus } from '../_util/statusUtils'; import { getMergedStatus, getStatusClassNames } from '../_util/statusUtils'; import { groupDisabledKeysMap, groupKeysMap } from '../_util/transKeys'; diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index 1967bc49ad..b69ab7d9f8 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -12,14 +12,13 @@ import type { DataNode } from '@rc-component/tree-select/lib/interface'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic, useZIndex } from '../_util/hooks'; import type { SemanticClassNames, SemanticClassNamesType, SemanticStyles, SemanticStylesType, -} from '../_util/hooks/useMergeSemantic'; -import { useZIndex } from '../_util/hooks/useZIndex'; +} from '../_util/hooks'; import type { SelectCommonPlacement } from '../_util/motion'; import { getTransitionName } from '../_util/motion'; import genPurePanel from '../_util/PurePanel'; diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index fe420bddd0..71a15c1601 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -7,8 +7,8 @@ import RcTree from '@rc-component/tree'; import type { DataNode, Key } from '@rc-component/tree/lib/interface'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; -import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; +import type { SemanticClassNamesType, SemanticStylesType } from '../_util/hooks'; import initCollapseMotion from '../_util/motion'; import { ConfigContext } from '../config-provider'; import { useComponentConfig } from '../config-provider/context'; diff --git a/components/upload/Upload.tsx b/components/upload/Upload.tsx index 4226b43d7d..94d0e58cf1 100644 --- a/components/upload/Upload.tsx +++ b/components/upload/Upload.tsx @@ -5,7 +5,7 @@ import RcUpload from '@rc-component/upload'; import { useControlledState } from '@rc-component/util'; import { clsx } from 'clsx'; -import useMergeSemantic from '../_util/hooks/useMergeSemantic'; +import { useMergeSemantic } from '../_util/hooks'; import { devUseWarning } from '../_util/warning'; import { useComponentConfig } from '../config-provider/context'; import DisabledContext from '../config-provider/DisabledContext'; diff --git a/components/upload/UploadList/ListItem.tsx b/components/upload/UploadList/ListItem.tsx index 38a22ce898..7b33b77971 100644 --- a/components/upload/UploadList/ListItem.tsx +++ b/components/upload/UploadList/ListItem.tsx @@ -5,7 +5,7 @@ import EyeOutlined from '@ant-design/icons/EyeOutlined'; import CSSMotion from '@rc-component/motion'; import { clsx } from 'clsx'; -import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks/useMergeSemantic'; +import type { SemanticClassNames, SemanticStyles } from '../../_util/hooks'; import { ConfigContext } from '../../config-provider'; import Progress from '../../progress'; import Tooltip from '../../tooltip'; diff --git a/components/upload/UploadList/index.tsx b/components/upload/UploadList/index.tsx index 816e0512e8..89d699bc24 100644 --- a/components/upload/UploadList/index.tsx +++ b/components/upload/UploadList/index.tsx @@ -8,7 +8,7 @@ import CSSMotion, { CSSMotionList } from '@rc-component/motion'; import { omit } from '@rc-component/util'; import { clsx } from 'clsx'; -import useForceUpdate from '../../_util/hooks/useForceUpdate'; +import { useForceUpdate } from '../../_util/hooks'; import initCollapseMotion from '../../_util/motion'; import { cloneElement } from '../../_util/reactNode'; import type { ButtonProps } from '../../button'; @@ -54,7 +54,7 @@ const InternalUploadList: React.ForwardRefRenderFunction