UNPKG

1.91 kBTypeScriptView Raw
1import * as React from 'react';
2import type { AnchorLinkBaseProps } from './AnchorLink';
3export interface AnchorLinkItemProps extends AnchorLinkBaseProps {
4 key: React.Key;
5 children?: AnchorLinkItemProps[];
6}
7export type AnchorContainer = HTMLElement | Window;
8export interface AnchorProps {
9 prefixCls?: string;
10 className?: string;
11 rootClassName?: string;
12 style?: React.CSSProperties;
13 /**
14 * @deprecated Please use `items` instead.
15 */
16 children?: React.ReactNode;
17 offsetTop?: number;
18 bounds?: number;
19 affix?: boolean;
20 showInkInFixed?: boolean;
21 getContainer?: () => AnchorContainer;
22 /** Return customize highlight anchor */
23 getCurrentAnchor?: (activeLink: string) => string;
24 onClick?: (e: React.MouseEvent<HTMLElement>, link: {
25 title: React.ReactNode;
26 href: string;
27 }) => void;
28 /** Scroll to target offset value, if none, it's offsetTop prop value or 0. */
29 targetOffset?: number;
30 /** Listening event when scrolling change active link */
31 onChange?: (currentActiveLink: string) => void;
32 items?: AnchorLinkItemProps[];
33 direction?: AnchorDirection;
34 replace?: boolean;
35}
36export interface AnchorState {
37 activeLink: null | string;
38}
39export interface AnchorDefaultProps extends AnchorProps {
40 prefixCls: string;
41 affix: boolean;
42 showInkInFixed: boolean;
43 getContainer: () => AnchorContainer;
44}
45export type AnchorDirection = 'vertical' | 'horizontal';
46export interface AntAnchor {
47 registerLink: (link: string) => void;
48 unregisterLink: (link: string) => void;
49 activeLink: string | null;
50 scrollTo: (link: string) => void;
51 onClick?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>, link: {
52 title: React.ReactNode;
53 href: string;
54 }) => void;
55 direction: AnchorDirection;
56}
57declare const Anchor: React.FC<AnchorProps>;
58export default Anchor;