/** * Copyright 2021, SumUp Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type RefObject } from 'react'; import type { ClickEvent } from '../../types/events.js'; export type CollapsibleOptions = { initialOpen?: boolean; duration?: number; id?: string; }; type Overflow = 'visible' | 'hidden'; type ButtonProps = { 'onClick': (event: ClickEvent) => void; 'aria-controls': string; 'aria-expanded': 'true' | 'false'; }; type ContentProps = { 'ref': RefObject; 'id': string; 'style': { overflowY: Overflow; willChange: 'height'; opacity: 1 | 0; height: string | 0; }; 'aria-hidden': undefined | 'true'; }; type Collapsible = { isOpen: boolean; toggleOpen: () => void; isAnimating: boolean; getButtonProps: (props?: { onClick?: (event: ClickEvent) => void; }) => ButtonProps; getContentProps: (props?: { style?: Record; }) => ContentProps; }; /** * A hook to build accessible and smoothly animated collapsible sections. * Based on https://inclusive-components.design/collapsible-sections/ */ export declare function useCollapsible({ initialOpen, duration, id: customId, }?: CollapsibleOptions): Collapsible; export declare function getHeight(element: RefObject): string; export {};