@fluentui/react-northstar
Version:
A themable React component library.
89 lines (88 loc) • 4.05 kB
TypeScript
import { Accessibility, AccordionBehaviorProps } from '@fluentui/accessibility';
import * as PropTypes from 'prop-types';
import * as React from 'react';
import { UIComponentProps, ChildrenComponentProps } from '../../utils';
import { AccordionTitle, AccordionTitleProps } from './AccordionTitle';
import { AccordionContent, AccordionContentProps } from './AccordionContent';
import { ComponentEventHandler, ShorthandValue, ShorthandRenderFunction, FluentComponentStaticProps } from '../../types';
export interface AccordionSlotClassNames {
content: string;
title: string;
}
export interface AccordionProps extends UIComponentProps, ChildrenComponentProps {
/** Index of the currently active panel. */
activeIndex?: number[] | number;
/** Initial activeIndex value. */
defaultActiveIndex?: number[] | number;
/** Only allow one panel to be expanded at a time. */
exclusive?: boolean;
/** At least one panel should be expanded at any time. */
expanded?: boolean;
/**
* Called when the active index of the Accordion changes.
* @param event - React's original SyntheticEvent.
* @param data - All props, with `activeIndex` reflecting the new state.
*/
onActiveIndexChange?: ComponentEventHandler<AccordionProps>;
/**
* Called when a panel title is clicked.
*
* @param event - React's original SyntheticEvent.
* @param data - All item props.
*/
onTitleClick?: ComponentEventHandler<AccordionProps>;
/** Shorthand array of props for Accordion. */
panels?: {
content: ShorthandValue<AccordionContentProps>;
title: ShorthandValue<AccordionTitleProps>;
}[];
/**
* A custom renderer for each Accordion's panel title.
*
* @param Component - The panel's component type.
* @param props - The panel's computed props.
*/
renderPanelTitle?: ShorthandRenderFunction<AccordionTitleProps>;
/**
* A custom renderer for each Accordion's panel content.
*
* @param Component - The panel's component type.
* @param props - The panel's computed props.
*/
renderPanelContent?: ShorthandRenderFunction<AccordionContentProps>;
/**
* Accessibility behavior if overridden by the user.
*/
accessibility?: Accessibility<AccordionBehaviorProps>;
/** Manage if panels should be rendered always or based on their state. */
alwaysRenderPanels?: boolean;
}
export declare type AccordionStylesProps = never;
export declare const accordionClassName = "ui-accordion";
export declare const accordionSlotClassNames: AccordionSlotClassNames;
/**
* An Accordion represents stacked set of content sections, with action elements to toggle the display of these sections.
*
* @accessibility
* Implements [ARIA Accordion](https://www.w3.org/TR/wai-aria-practices-1.1/#accordion) design pattern (keyboard navigation not yet supported).
*/
export declare const Accordion: (<TExtendedElementType extends React.ElementType<any> = "dl">(props: React.RefAttributes<HTMLDListElement> & Omit<import("@fluentui/react-bindings").PropsOfElement<TExtendedElementType>, "as" | keyof AccordionProps> & {
as?: TExtendedElementType;
} & AccordionProps) => JSX.Element) & {
propTypes?: React.WeakValidationMap<AccordionProps> & {
as: React.Requireable<string | ((props: any, context?: any) => any) | (new (props: any, context?: any) => any)>;
};
contextTypes?: PropTypes.ValidationMap<any>;
defaultProps?: Partial<AccordionProps & {
as: "dl";
}>;
displayName?: string;
readonly __PRIVATE_PROPS?: React.RefAttributes<HTMLDListElement> & Omit<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDListElement>, HTMLDListElement>, "key" | keyof React.HTMLAttributes<HTMLDListElement>> & {
ref?: React.Ref<HTMLDListElement>;
}, "as" | keyof AccordionProps> & {
as?: "dl";
} & AccordionProps;
} & FluentComponentStaticProps<AccordionProps> & {
Title: typeof AccordionTitle;
Content: typeof AccordionContent;
};