UNPKG

3.62 kBTypeScriptView Raw
1import * as React from 'react';
2import { ScrollablePaneBase } from './ScrollablePane.base';
3import { Sticky } from '../Sticky/Sticky';
4import type { IRefObject, IStyleFunctionOrObject } from '../../Utilities';
5import type { IStyle, ITheme } from '../../Styling';
6/**
7 * {@docCategory ScrollablePane}
8 */
9export interface IScrollablePane {
10 /** Triggers a layout update for the pane. */
11 forceLayoutUpdate(): void;
12 /** Gets the current scroll position of the scrollable pane */
13 getScrollPosition(): number;
14}
15/**
16 * {@docCategory ScrollablePane}
17 */
18export interface IScrollablePaneProps extends React.HTMLAttributes<HTMLElement | ScrollablePaneBase> {
19 /**
20 * Optional callback to access the IScrollablePane interface. Use this instead of ref for accessing
21 * the public methods and properties of the component.
22 */
23 componentRef?: IRefObject<IScrollablePane>;
24 /**
25 * Call to provide customized styling that will layer on top of the variant rules
26 */
27 styles?: IStyleFunctionOrObject<IScrollablePaneStyleProps, IScrollablePaneStyles>;
28 /**
29 * Theme provided by HOC.
30 */
31 theme?: ITheme;
32 /**
33 * Additional css class to apply to the ScrollablePane
34 * @defaultvalue undefined
35 */
36 className?: string;
37 /**
38 * Sets the initial scroll position of the ScrollablePane
39 */
40 initialScrollPosition?: number;
41 scrollbarVisibility?: ScrollbarVisibility;
42 /**
43 * Makes the scrollable container focusable, to aid with keyboard-only scrolling
44 * Should only be set to true if the scrollable region will not contain any other focusable items
45 * @defaultvalue false
46 */
47 scrollContainerFocus?: boolean;
48 /**
49 * If scrollContainerFocus is set to true, use this to give the container an accessible name
50 */
51 scrollContainerAriaLabel?: string;
52}
53/**
54 * {@docCategory ScrollablePane}
55 */
56export interface IScrollablePaneStyleProps {
57 /**
58 * Accept theme prop.
59 */
60 theme: ITheme;
61 /**
62 * Accept custom classNames
63 */
64 className?: string;
65 scrollbarVisibility?: IScrollablePaneProps['scrollbarVisibility'];
66}
67/**
68 * {@docCategory ScrollablePane}
69 */
70export interface IScrollablePaneStyles {
71 /**
72 * Style set for the root element.
73 */
74 root: IStyle;
75 /**
76 * Style set for the stickyAbove element.
77 */
78 stickyAbove: IStyle;
79 /**
80 * Style set for the stickyBelow element.
81 */
82 stickyBelow: IStyle;
83 /**
84 * Style set for the stickyBelowItems element.
85 */
86 stickyBelowItems: IStyle;
87 /**
88 * Style set for the contentContainer element.
89 */
90 contentContainer: IStyle;
91}
92/**
93 * {@docCategory ScrollablePane}
94 */
95export declare const ScrollbarVisibility: {
96 auto: "auto";
97 always: "always";
98};
99/**
100 * {@docCategory ScrollablePane}
101 */
102export declare type ScrollbarVisibility = typeof ScrollbarVisibility[keyof typeof ScrollbarVisibility];
103export interface IScrollablePaneContext {
104 scrollablePane?: {
105 subscribe: (handler: (container: HTMLElement, stickyContainer: HTMLElement) => void) => void;
106 unsubscribe: (handler: (container: HTMLElement, stickyContainer: HTMLElement) => void) => void;
107 addSticky: (sticky: Sticky) => void;
108 removeSticky: (sticky: Sticky) => void;
109 updateStickyRefHeights: () => void;
110 sortSticky: (sticky: Sticky, sortAgain?: boolean) => void;
111 notifySubscribers: (sort?: boolean) => void;
112 syncScrollSticky: (sticky: Sticky) => void;
113 };
114}
115export declare const ScrollablePaneContext: React.Context<IScrollablePaneContext>;