choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
76 lines (75 loc) • 2.37 kB
TypeScript
import React, { Component, CSSProperties, MouseEvent, ReactNode } from 'react';
import AnchorLink from './AnchorLink';
import ConfigContext, { ConfigContextValue } from '../config-provider/ConfigContext';
declare function getDefaultContainer(): Window & typeof globalThis;
export declare type AnchorContainer = HTMLElement | Window;
export interface AnchorProps {
prefixCls?: string;
className?: string;
style?: CSSProperties;
children?: ReactNode;
offsetTop?: number;
bounds?: number;
affix?: boolean;
showInkInFixed?: boolean;
getContainer?: () => AnchorContainer;
/** Return customize highlight anchor */
getCurrentAnchor?: () => string;
onClick?: (e: MouseEvent<HTMLElement>, link: {
title: ReactNode;
href: string;
}) => void;
targetOffset?: number;
}
export interface AnchorState {
activeLink: null | string;
}
export interface AnchorDefaultProps extends AnchorProps {
prefixCls: string;
affix: boolean;
showInkInFixed: boolean;
getContainer: () => AnchorContainer;
}
export interface C7NAnchor {
registerLink: (link: string) => void;
unregisterLink: (link: string) => void;
activeLink: string | null;
scrollTo: (link: string) => void;
onClick?: ((e: React.MouseEvent<HTMLElement>, link: {
title: React.ReactNode;
href: string;
}) => void) | undefined;
}
export default class Anchor extends Component<AnchorProps, AnchorState> {
static displayName: string;
static get contextType(): typeof ConfigContext;
static Link: typeof AnchorLink;
static defaultProps: {
affix: boolean;
showInkInFixed: boolean;
getContainer: typeof getDefaultContainer;
};
context: ConfigContextValue;
state: {
activeLink: null;
};
private inkNode;
private scrollContainer;
private links;
private scrollEvent;
private animating;
getContextValue(): {
c7nAnchor: C7NAnchor;
};
componentDidMount(): void;
componentDidUpdate(): void;
componentWillUnmount(): void;
getCurrentAnchor(offsetTop?: number, bounds?: number): string;
handleScrollTo: (link: string) => void;
saveInkNode: (node: HTMLSpanElement) => void;
handleScroll: () => void;
updateInk: () => void;
getPrefixCls(): string;
render(): JSX.Element;
}
export {};