diff --git a/internal/playground/src/layouts/Error.layout.tsx b/internal/playground/src/layouts/Error.layout.tsx index e5d75ab8..f6acd04b 100644 --- a/internal/playground/src/layouts/Error.layout.tsx +++ b/internal/playground/src/layouts/Error.layout.tsx @@ -2,10 +2,10 @@ import { useRouteError } from 'react-router-dom'; import React from 'react'; export function ErrorLayout(): JSX.Element { - const err = useRouteError() as Error & { + const err = useRouteError() as { statusText?: string; status?: number; - }; + } & Error; return ( Error {err.status || 500}:{' '} diff --git a/packages/components/src/collapse-transition/collapse-transition.types.ts b/packages/components/src/collapse-transition/collapse-transition.types.ts index 0188a2aa..91dc6df1 100644 --- a/packages/components/src/collapse-transition/collapse-transition.types.ts +++ b/packages/components/src/collapse-transition/collapse-transition.types.ts @@ -1,5 +1,5 @@ import type { TransitionProps } from '../transition'; -export type CollapseTransitionProps = TransitionProps & { +export type CollapseTransitionProps = { width?: boolean; -}; +} & TransitionProps; diff --git a/packages/components/src/collapse/collapse.types.ts b/packages/components/src/collapse/collapse.types.ts index cb84e8f9..d6eef244 100644 --- a/packages/components/src/collapse/collapse.types.ts +++ b/packages/components/src/collapse/collapse.types.ts @@ -14,10 +14,10 @@ export interface CollapseProps extends PropsBase { size?: Size; } -export type CollapseGroupItem = CollapseProps & { +export type CollapseGroupItem = { children: React.ReactNode; key: string | number; -}; +} & CollapseProps; export interface CollapseGroupProps extends Omit { onChange?: (item: CollapseGroupItem, index: number, active: boolean) => void; diff --git a/packages/components/src/config-provider/ConfigProvider.tsx b/packages/components/src/config-provider/ConfigProvider.tsx index 20bbab87..b4160e1e 100644 --- a/packages/components/src/config-provider/ConfigProvider.tsx +++ b/packages/components/src/config-provider/ConfigProvider.tsx @@ -3,9 +3,9 @@ import { ConfigContext } from './config.context'; import React from 'react'; export const ConfigProvider: React.FC< - Partial & { + { children: React.ReactNode; - } + } & Partial > = ({ locale = {}, children }) => { return ( diff --git a/packages/components/src/dialog/dialog.hooks.ts b/packages/components/src/dialog/dialog.hooks.ts index b10310df..ca87a758 100644 --- a/packages/components/src/dialog/dialog.hooks.ts +++ b/packages/components/src/dialog/dialog.hooks.ts @@ -14,8 +14,8 @@ export function useTransitionOrigin(props: DialogProps, show?: boolean) { const top = centered ? `calc(50% + (${-clientSize[1] / 2 + point[1]}px - ${styleTop || 0}))` : styleTop !== undefined - ? `calc(${point[1]}px - ${styleTop})` - : `calc(${point[1]}px - 50%)`; + ? `calc(${point[1]}px - ${styleTop})` + : `calc(${point[1]}px - 50%)`; return `${left} ${top}`; }, [clientSize, point, centered, bodyAttrs]); diff --git a/packages/components/src/message/useMessage.tsx b/packages/components/src/message/useMessage.tsx index 823b41b3..c88cb0b0 100644 --- a/packages/components/src/message/useMessage.tsx +++ b/packages/components/src/message/useMessage.tsx @@ -6,19 +6,19 @@ import { createRoot } from 'react-dom/client'; import { nextTick } from '@tool-pack/basic'; type Res = readonly [ - { - open( - content: MessagePushOptions['content'], - options?: PartialPart, 'type'>, - ): void; - clear(): void; - } & Record< + Record< MessagePushOptions['type'], ( content: MessagePushOptions['content'], options?: Omit, ) => void - >, + > & { + open( + content: MessagePushOptions['content'], + options?: PartialPart, 'type'>, + ): void; + clear(): void; + }, React.ReactElement, ]; @@ -26,9 +26,9 @@ type Res = readonly [ * @param commonOptions 可以填入公共的duration、icon、showClose参数 */ export function useMessageHolder( - commonOptions: Omit & { + commonOptions: { containerAttrs?: MessagePushOptions['attrs']; - } = {}, + } & Omit = {}, ): Res { const { containerAttrs, ...restOptions } = commonOptions; const ref = useRef(null); diff --git a/packages/components/src/popover/hooks/useShowController.ts b/packages/components/src/popover/hooks/useShowController.ts index 870cc31e..c78c8615 100644 --- a/packages/components/src/popover/hooks/useShowController.ts +++ b/packages/components/src/popover/hooks/useShowController.ts @@ -45,16 +45,12 @@ export function useShowController( }; }, []); - useImperativeHandle( - visibleControllerRef, - () => { - return { - hide: close, - show: open, - }; - }, - [], - ); + useImperativeHandle(visibleControllerRef, () => { + return { + hide: close, + show: open, + }; + }, []); // 事件触发启动 useEffect(() => { diff --git a/packages/components/src/slider/components/Handlers.tsx b/packages/components/src/slider/components/Handlers.tsx index 8ac92c65..625b40a9 100644 --- a/packages/components/src/slider/components/Handlers.tsx +++ b/packages/components/src/slider/components/Handlers.tsx @@ -69,19 +69,15 @@ export const Handlers: React.FC = (props) => { const tooltipVisible = tooltip === 'always' ? true : undefined; const tooltipDisabled = tooltip === 'always' ? false : !tooltip; - useImperativeHandle( - controlRef, - () => { - return { - focus(index: number) { - ( - handlersRef.current?.children[index] as HTMLDivElement | undefined - )?.focus(); - }, - }; - }, - [], - ); + useImperativeHandle(controlRef, () => { + return { + focus(index: number) { + ( + handlersRef.current?.children[index] as HTMLDivElement | undefined + )?.focus(); + }, + }; + }, []); // 拖动事件 useEffect(() => { const handlersEl = handlersRef.current; diff --git a/packages/components/src/switch/index.scss b/packages/components/src/switch/index.scss index 354aa97e..5742e62c 100644 --- a/packages/components/src/switch/index.scss +++ b/packages/components/src/switch/index.scss @@ -110,14 +110,12 @@ $r: Name.$switch; // margin-left: 4px; } .#{$r}__handle::before { - inset-inline-end: -30%; - inset-inline-start: 0; + inset-inline: 0 -30%; } } &.#{$r}--checked { .#{$r}__handle::before { - inset-inline-end: 0; - inset-inline-start: -30%; + inset-inline: -30% 0; } .#{$r}__checked { // margin-right: 4px; diff --git a/packages/components/src/tooltip/tooltip.types.ts b/packages/components/src/tooltip/tooltip.types.ts index be8814ac..5c4e2a99 100644 --- a/packages/components/src/tooltip/tooltip.types.ts +++ b/packages/components/src/tooltip/tooltip.types.ts @@ -1,5 +1,5 @@ import type { PopoverProps } from '../popover'; -export type TooltipProps = Omit & { +export type TooltipProps = { title?: Required['content']; -}; +} & Omit; diff --git a/packages/components/src/transition-group/hooks/useChildMap.tsx b/packages/components/src/transition-group/hooks/useChildMap.tsx index 5ee990d1..4d6da3b9 100644 --- a/packages/components/src/transition-group/hooks/useChildMap.tsx +++ b/packages/components/src/transition-group/hooks/useChildMap.tsx @@ -5,12 +5,17 @@ import { useState, Children, } from 'react'; +import type { + FunctionComponentElement, + ReactElement, + ReactNode, + Key, +} from 'react'; import { type TransitionProps, transitionCBAdapter, Transition, } from '~/transition'; -import type { RefAttributes, ReactElement, ReactNode, Key } from 'react'; import type { ChildMapValue, ChildMap } from '../transition-group.types'; import { useIsInitDep, forwardRefs } from '@pkg/shared'; @@ -206,7 +211,10 @@ function cloneChildren( return isValidElement(children) ? cloneElement(children as ReactElement, { ref: (el: HTMLElement) => { - forwardRefs(el, (children as RefAttributes).ref); + forwardRefs( + el, + (children as FunctionComponentElement).ref, + ); el && (childMapValue.ref = el); }, }) diff --git a/packages/components/src/transition/hooks/useTransition.ts b/packages/components/src/transition/hooks/useTransition.ts index 51b0b003..5bc05902 100644 --- a/packages/components/src/transition/hooks/useTransition.ts +++ b/packages/components/src/transition/hooks/useTransition.ts @@ -16,7 +16,7 @@ export function useTransition( { attrs = {} }: Partial = {}, ): React.ReactElement | undefined { const elRef = useForwardRef( - (children as React.RefAttributes)?.ref, + (children as React.FunctionComponentElement)?.ref, ) as React.MutableRefObject; if (!children) elRef.current = null; @@ -84,10 +84,10 @@ export function useTransition( ref: elRef, className, style, - } as React.HTMLAttributes & - React.DOMAttributes & { - attrs: React.HTMLAttributes; - }; + } as { + attrs: React.HTMLAttributes; + } & React.HTMLAttributes & + React.DOMAttributes; if (typeof children.props.attrs === 'object') { props.attrs = { ...children.props.attrs, className, style }; diff --git a/packages/shared/src/utils/numToPx.ts b/packages/shared/src/utils/numToPx.ts index a5803507..cf2263aa 100644 --- a/packages/shared/src/utils/numToPx.ts +++ b/packages/shared/src/utils/numToPx.ts @@ -5,6 +5,6 @@ export function numToPx( return value === undefined ? defValue : typeof value === 'number' - ? `${value}px` - : value; + ? `${value}px` + : value; }