Skip to content

Commit

Permalink
style: format
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxinssfd committed Jun 12, 2024
1 parent 3057345 commit c75fa57
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 58 deletions.
4 changes: 2 additions & 2 deletions internal/playground/src/layouts/Error.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<React.Fragment>
<strong>Error {err.status || 500}</strong>:{' '}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TransitionProps } from '../transition';

export type CollapseTransitionProps = TransitionProps & {
export type CollapseTransitionProps = {
width?: boolean;
};
} & TransitionProps;
4 changes: 2 additions & 2 deletions packages/components/src/collapse/collapse.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PropsBase, 'children'> {
onChange?: (item: CollapseGroupItem, index: number, active: boolean) => void;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/config-provider/ConfigProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ConfigContext } from './config.context';
import React from 'react';

export const ConfigProvider: React.FC<
Partial<Context> & {
{
children: React.ReactNode;
}
} & Partial<Context>
> = ({ locale = {}, children }) => {
return (
<ConfigContext.Provider value={{ locale }}>
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/dialog/dialog.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
20 changes: 10 additions & 10 deletions packages/components/src/message/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ import { createRoot } from 'react-dom/client';
import { nextTick } from '@tool-pack/basic';

type Res = readonly [
{
open(
content: MessagePushOptions['content'],
options?: PartialPart<Omit<MessagePushOptions, 'content'>, 'type'>,
): void;
clear(): void;
} & Record<
Record<
MessagePushOptions['type'],
(
content: MessagePushOptions['content'],
options?: Omit<MessagePushOptions, 'content' | 'type'>,
) => void
>,
> & {
open(
content: MessagePushOptions['content'],
options?: PartialPart<Omit<MessagePushOptions, 'content'>, 'type'>,
): void;
clear(): void;
},
React.ReactElement,
];

/**
* @param commonOptions 可以填入公共的duration、icon、showClose参数
*/
export function useMessageHolder(
commonOptions: Omit<MessagePushOptions, 'content' | 'type'> & {
commonOptions: {
containerAttrs?: MessagePushOptions['attrs'];
} = {},
} & Omit<MessagePushOptions, 'content' | 'type'> = {},
): Res {
const { containerAttrs, ...restOptions } = commonOptions;
const ref = useRef<MessageQueueRef>(null);
Expand Down
16 changes: 6 additions & 10 deletions packages/components/src/popover/hooks/useShowController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,12 @@ export function useShowController(
};
}, []);

useImperativeHandle(
visibleControllerRef,
() => {
return {
hide: close,
show: open,
};
},
[],
);
useImperativeHandle(visibleControllerRef, () => {
return {
hide: close,
show: open,
};
}, []);

// 事件触发启动
useEffect(() => {
Expand Down
22 changes: 9 additions & 13 deletions packages/components/src/slider/components/Handlers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,15 @@ export const Handlers: React.FC<Props> = (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;
Expand Down
6 changes: 2 additions & 4 deletions packages/components/src/switch/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/tooltip/tooltip.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PopoverProps } from '../popover';

export type TooltipProps = Omit<PopoverProps, 'content'> & {
export type TooltipProps = {
title?: Required<PopoverProps>['content'];
};
} & Omit<PopoverProps, 'content'>;
12 changes: 10 additions & 2 deletions packages/components/src/transition-group/hooks/useChildMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -206,7 +211,10 @@ function cloneChildren(
return isValidElement(children)
? cloneElement(children as ReactElement, {
ref: (el: HTMLElement) => {
forwardRefs(el, (children as RefAttributes<any>).ref);
forwardRefs(
el,
(children as FunctionComponentElement<HTMLElement>).ref,
);
el && (childMapValue.ref = el);
},
})
Expand Down
10 changes: 5 additions & 5 deletions packages/components/src/transition/hooks/useTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useTransition(
{ attrs = {} }: Partial<TransitionProps> = {},
): React.ReactElement<HTMLElement> | undefined {
const elRef = useForwardRef(
(children as React.RefAttributes<unknown>)?.ref,
(children as React.FunctionComponentElement<HTMLElement>)?.ref,
) as React.MutableRefObject<HTMLElement | null>;

if (!children) elRef.current = null;
Expand Down Expand Up @@ -84,10 +84,10 @@ export function useTransition(
ref: elRef,
className,
style,
} as React.HTMLAttributes<HTMLElement> &
React.DOMAttributes<HTMLElement> & {
attrs: React.HTMLAttributes<HTMLElement>;
};
} as {
attrs: React.HTMLAttributes<HTMLElement>;
} & React.HTMLAttributes<HTMLElement> &
React.DOMAttributes<HTMLElement>;

if (typeof children.props.attrs === 'object') {
props.attrs = { ...children.props.attrs, className, style };
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/utils/numToPx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function numToPx<T>(
return value === undefined
? defValue
: typeof value === 'number'
? `${value}px`
: value;
? `${value}px`
: value;
}

0 comments on commit c75fa57

Please sign in to comment.