Skip to content

Commit c75fa57

Browse files
committed
style: format
1 parent 3057345 commit c75fa57

File tree

13 files changed

+56
-58
lines changed

13 files changed

+56
-58
lines changed

internal/playground/src/layouts/Error.layout.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { useRouteError } from 'react-router-dom';
22
import React from 'react';
33

44
export function ErrorLayout(): JSX.Element {
5-
const err = useRouteError() as Error & {
5+
const err = useRouteError() as {
66
statusText?: string;
77
status?: number;
8-
};
8+
} & Error;
99
return (
1010
<React.Fragment>
1111
<strong>Error {err.status || 500}</strong>:{' '}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { TransitionProps } from '../transition';
22

3-
export type CollapseTransitionProps = TransitionProps & {
3+
export type CollapseTransitionProps = {
44
width?: boolean;
5-
};
5+
} & TransitionProps;

packages/components/src/collapse/collapse.types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export interface CollapseProps extends PropsBase {
1414
size?: Size;
1515
}
1616

17-
export type CollapseGroupItem = CollapseProps & {
17+
export type CollapseGroupItem = {
1818
children: React.ReactNode;
1919
key: string | number;
20-
};
20+
} & CollapseProps;
2121

2222
export interface CollapseGroupProps extends Omit<PropsBase, 'children'> {
2323
onChange?: (item: CollapseGroupItem, index: number, active: boolean) => void;

packages/components/src/config-provider/ConfigProvider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { ConfigContext } from './config.context';
33
import React from 'react';
44

55
export const ConfigProvider: React.FC<
6-
Partial<Context> & {
6+
{
77
children: React.ReactNode;
8-
}
8+
} & Partial<Context>
99
> = ({ locale = {}, children }) => {
1010
return (
1111
<ConfigContext.Provider value={{ locale }}>

packages/components/src/dialog/dialog.hooks.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export function useTransitionOrigin(props: DialogProps, show?: boolean) {
1414
const top = centered
1515
? `calc(50% + (${-clientSize[1] / 2 + point[1]}px - ${styleTop || 0}))`
1616
: styleTop !== undefined
17-
? `calc(${point[1]}px - ${styleTop})`
18-
: `calc(${point[1]}px - 50%)`;
17+
? `calc(${point[1]}px - ${styleTop})`
18+
: `calc(${point[1]}px - 50%)`;
1919
return `${left} ${top}`;
2020
}, [clientSize, point, centered, bodyAttrs]);
2121

packages/components/src/message/useMessage.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ import { createRoot } from 'react-dom/client';
66
import { nextTick } from '@tool-pack/basic';
77

88
type Res = readonly [
9-
{
10-
open(
11-
content: MessagePushOptions['content'],
12-
options?: PartialPart<Omit<MessagePushOptions, 'content'>, 'type'>,
13-
): void;
14-
clear(): void;
15-
} & Record<
9+
Record<
1610
MessagePushOptions['type'],
1711
(
1812
content: MessagePushOptions['content'],
1913
options?: Omit<MessagePushOptions, 'content' | 'type'>,
2014
) => void
21-
>,
15+
> & {
16+
open(
17+
content: MessagePushOptions['content'],
18+
options?: PartialPart<Omit<MessagePushOptions, 'content'>, 'type'>,
19+
): void;
20+
clear(): void;
21+
},
2222
React.ReactElement,
2323
];
2424

2525
/**
2626
* @param commonOptions 可以填入公共的duration、icon、showClose参数
2727
*/
2828
export function useMessageHolder(
29-
commonOptions: Omit<MessagePushOptions, 'content' | 'type'> & {
29+
commonOptions: {
3030
containerAttrs?: MessagePushOptions['attrs'];
31-
} = {},
31+
} & Omit<MessagePushOptions, 'content' | 'type'> = {},
3232
): Res {
3333
const { containerAttrs, ...restOptions } = commonOptions;
3434
const ref = useRef<MessageQueueRef>(null);

packages/components/src/popover/hooks/useShowController.ts

+6-10
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ export function useShowController(
4545
};
4646
}, []);
4747

48-
useImperativeHandle(
49-
visibleControllerRef,
50-
() => {
51-
return {
52-
hide: close,
53-
show: open,
54-
};
55-
},
56-
[],
57-
);
48+
useImperativeHandle(visibleControllerRef, () => {
49+
return {
50+
hide: close,
51+
show: open,
52+
};
53+
}, []);
5854

5955
// 事件触发启动
6056
useEffect(() => {

packages/components/src/slider/components/Handlers.tsx

+9-13
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,15 @@ export const Handlers: React.FC<Props> = (props) => {
6969
const tooltipVisible = tooltip === 'always' ? true : undefined;
7070
const tooltipDisabled = tooltip === 'always' ? false : !tooltip;
7171

72-
useImperativeHandle(
73-
controlRef,
74-
() => {
75-
return {
76-
focus(index: number) {
77-
(
78-
handlersRef.current?.children[index] as HTMLDivElement | undefined
79-
)?.focus();
80-
},
81-
};
82-
},
83-
[],
84-
);
72+
useImperativeHandle(controlRef, () => {
73+
return {
74+
focus(index: number) {
75+
(
76+
handlersRef.current?.children[index] as HTMLDivElement | undefined
77+
)?.focus();
78+
},
79+
};
80+
}, []);
8581
// 拖动事件
8682
useEffect(() => {
8783
const handlersEl = handlersRef.current;

packages/components/src/switch/index.scss

+2-4
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,12 @@ $r: Name.$switch;
110110
// margin-left: 4px;
111111
}
112112
.#{$r}__handle::before {
113-
inset-inline-end: -30%;
114-
inset-inline-start: 0;
113+
inset-inline: 0 -30%;
115114
}
116115
}
117116
&.#{$r}--checked {
118117
.#{$r}__handle::before {
119-
inset-inline-end: 0;
120-
inset-inline-start: -30%;
118+
inset-inline: -30% 0;
121119
}
122120
.#{$r}__checked {
123121
// margin-right: 4px;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { PopoverProps } from '../popover';
22

3-
export type TooltipProps = Omit<PopoverProps, 'content'> & {
3+
export type TooltipProps = {
44
title?: Required<PopoverProps>['content'];
5-
};
5+
} & Omit<PopoverProps, 'content'>;

packages/components/src/transition-group/hooks/useChildMap.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import {
55
useState,
66
Children,
77
} from 'react';
8+
import type {
9+
FunctionComponentElement,
10+
ReactElement,
11+
ReactNode,
12+
Key,
13+
} from 'react';
814
import {
915
type TransitionProps,
1016
transitionCBAdapter,
1117
Transition,
1218
} from '~/transition';
13-
import type { RefAttributes, ReactElement, ReactNode, Key } from 'react';
1419
import type { ChildMapValue, ChildMap } from '../transition-group.types';
1520
import { useIsInitDep, forwardRefs } from '@pkg/shared';
1621

@@ -206,7 +211,10 @@ function cloneChildren(
206211
return isValidElement(children)
207212
? cloneElement(children as ReactElement, {
208213
ref: (el: HTMLElement) => {
209-
forwardRefs(el, (children as RefAttributes<any>).ref);
214+
forwardRefs(
215+
el,
216+
(children as FunctionComponentElement<HTMLElement>).ref,
217+
);
210218
el && (childMapValue.ref = el);
211219
},
212220
})

packages/components/src/transition/hooks/useTransition.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function useTransition(
1616
{ attrs = {} }: Partial<TransitionProps> = {},
1717
): React.ReactElement<HTMLElement> | undefined {
1818
const elRef = useForwardRef(
19-
(children as React.RefAttributes<unknown>)?.ref,
19+
(children as React.FunctionComponentElement<HTMLElement>)?.ref,
2020
) as React.MutableRefObject<HTMLElement | null>;
2121

2222
if (!children) elRef.current = null;
@@ -84,10 +84,10 @@ export function useTransition(
8484
ref: elRef,
8585
className,
8686
style,
87-
} as React.HTMLAttributes<HTMLElement> &
88-
React.DOMAttributes<HTMLElement> & {
89-
attrs: React.HTMLAttributes<HTMLElement>;
90-
};
87+
} as {
88+
attrs: React.HTMLAttributes<HTMLElement>;
89+
} & React.HTMLAttributes<HTMLElement> &
90+
React.DOMAttributes<HTMLElement>;
9191

9292
if (typeof children.props.attrs === 'object') {
9393
props.attrs = { ...children.props.attrs, className, style };

packages/shared/src/utils/numToPx.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export function numToPx<T>(
55
return value === undefined
66
? defValue
77
: typeof value === 'number'
8-
? `${value}px`
9-
: value;
8+
? `${value}px`
9+
: value;
1010
}

0 commit comments

Comments
 (0)