chowa
Version:
UI component library based on React
56 lines (55 loc) • 1.8 kB
TypeScript
/**
* @license chowa v1.1.3
*
* Copyright (c) Chowa Techonlogies Co.,Ltd.(http://www.chowa.cn).
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import * as PropTypes from 'prop-types';
import AnchorLink, { AnchorLinkProps } from './anchor-link';
export interface AnchorProps {
className?: string;
style?: React.CSSProperties;
affixed?: boolean;
offsetTop?: number;
offsetBottom?: number;
scrollTarget?: () => Window | HTMLElement;
onSelect?: (link: AnchorLinkProps) => void;
bounds?: number;
}
export interface AnchorState {
links: AnchorLinkProps[];
anchorTops: number[];
activeIndex: number;
}
declare class Anchor extends React.PureComponent<AnchorProps, AnchorState> {
static propTypes: {
className: PropTypes.Requireable<string>;
style: PropTypes.Requireable<object>;
affixed: PropTypes.Requireable<boolean>;
offsetTop: PropTypes.Requireable<number>;
offsetBottom: PropTypes.Requireable<number>;
scrollTarget: PropTypes.Requireable<(...args: any[]) => any>;
onSelect: PropTypes.Requireable<(...args: any[]) => any>;
bounds: PropTypes.Requireable<number>;
};
static defaultProps: {
affixed: boolean;
offsetTop: number;
bounds: number;
scrollTarget: () => Window & typeof globalThis;
};
static Link: typeof AnchorLink;
private resizeObserver;
constructor(props: AnchorProps & {
children: React.ReactElement<any>;
});
componentDidMount(): void;
componentWillUnmount(): void;
private computedAnchorTops;
private onScrollHandler;
render(): JSX.Element;
}
export default Anchor;