Skip to content

Commit

Permalink
chore: fix renderPanel types
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Mar 8, 2024
1 parent 4e2a06c commit 52dfc98
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 67 deletions.
2 changes: 1 addition & 1 deletion src/TourStep/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import DefaultPanel, { DefaultPanelProps } from './DefaultPanel';
import DefaultPanel, { type DefaultPanelProps } from './DefaultPanel';
import type { TourStepProps, TourStepInfo } from '../interface';

export type {
Expand Down
133 changes: 67 additions & 66 deletions src/interface.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,71 @@
import type { TriggerProps } from "@rc-component/trigger";
import type { PlacementType } from "./placements";
import type { CSSProperties, ReactNode } from "react";
import type { Gap } from "./hooks/useTarget";

import type { TriggerProps } from '@rc-component/trigger';
import type { PlacementType } from './placements';
import type { CSSProperties, ReactNode } from 'react';
import type { Gap } from './hooks/useTarget';
import { type DefaultPanelProps } from './TourStep/DefaultPanel';

export interface TourStepInfo {
arrow?: boolean | { pointAtCenter: boolean };
target?: HTMLElement | (() => HTMLElement) | null | (() => null);
title: ReactNode;
description?: ReactNode;
placement?: PlacementType;
mask?: boolean | {
style?: React.CSSProperties;
// to fill mask color, e.g. rgba(80,0,0,0.5)
color?: string;
};
className?: string;
style?: CSSProperties;
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
closeIcon?: ReactNode;
closable?: boolean | ({ closeIcon?: ReactNode } & React.AriaAttributes);
}

export interface TourStepProps extends TourStepInfo {
prefixCls?: string;
total?: number;
current?: number;
onClose?: () => void;
onFinish?: () => void;
renderPanel?: (step: TourStepProps, current: number) => ReactNode;
onPrev?: () => void;
onNext?: () => void;
}

arrow?: boolean | { pointAtCenter: boolean };
target?: HTMLElement | (() => HTMLElement) | null | (() => null);
title: ReactNode;
description?: ReactNode;
placement?: PlacementType;
mask?:
| boolean
| {
style?: React.CSSProperties;
// to fill mask color, e.g. rgba(80,0,0,0.5)
color?: string;
};
className?: string;
style?: CSSProperties;
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
closeIcon?: ReactNode;
closable?: boolean | ({ closeIcon?: ReactNode } & React.AriaAttributes);
}

export interface TourStepProps extends TourStepInfo {
prefixCls?: string;
total?: number;
current?: number;
onClose?: () => void;
onFinish?: () => void;
renderPanel?: (step: TourStepProps, current: number) => ReactNode;
onPrev?: () => void;
onNext?: () => void;
}

export interface TourProps extends Pick<TriggerProps, 'onPopupAlign'> {
steps?: TourStepInfo[];
open?: boolean;
defaultCurrent?: number;
current?: number;
onChange?: (current: number) => void;
onClose?: (current: number) => void;
onFinish?: () => void;
closeIcon?: TourStepProps['closeIcon'];
closable?: TourStepProps['closable'];
mask?:
| boolean
| {
style?: React.CSSProperties;
// to fill mask color, e.g. rgba(80,0,0,0.5)
color?: string;
};
arrow?: boolean | { pointAtCenter: boolean };
rootClassName?: string;
placement?: PlacementType;
prefixCls?: string;
renderPanel?: (props: TourStepProps, current: number) => ReactNode;
gap?: Gap;
animated?: boolean | { placeholder: boolean };
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
zIndex?: number;
getPopupContainer?: TriggerProps['getPopupContainer'];
builtinPlacements?:
| TriggerProps['builtinPlacements']
| ((config?: {
arrowPointAtCenter?: boolean;
}) => TriggerProps['builtinPlacements']);
disabledInteraction?: boolean;
}
steps?: TourStepInfo[];
open?: boolean;
defaultCurrent?: number;
current?: number;
onChange?: (current: number) => void;
onClose?: (current: number) => void;
onFinish?: () => void;
closeIcon?: TourStepProps['closeIcon'];
closable?: TourStepProps['closable'];
mask?:
| boolean
| {
style?: React.CSSProperties;
// to fill mask color, e.g. rgba(80,0,0,0.5)
color?: string;
};
arrow?: boolean | { pointAtCenter: boolean };
rootClassName?: string;
placement?: PlacementType;
prefixCls?: string;
renderPanel?: (props: DefaultPanelProps, current: number) => ReactNode;
gap?: Gap;
animated?: boolean | { placeholder: boolean };
scrollIntoViewOptions?: boolean | ScrollIntoViewOptions;
zIndex?: number;
getPopupContainer?: TriggerProps['getPopupContainer'];
builtinPlacements?:
| TriggerProps['builtinPlacements']
| ((config?: {
arrowPointAtCenter?: boolean;
}) => TriggerProps['builtinPlacements']);
disabledInteraction?: boolean;
}

0 comments on commit 52dfc98

Please sign in to comment.