Anchor.d.ts 2.0 KB

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