UNPKG

2.86 kBTypeScriptView Raw
1/// <reference types="jquery"/>
2
3import BaseComponent from './base-component';
4
5declare class Collapse extends BaseComponent {
6 constructor(element: string | Element, options?: Partial<Collapse.Options>);
7
8 /**
9 * Toggles a collapsible element to shown or hidden. Returns to the caller
10 * before the collapsible element has actually been shown or hidden (i.e.
11 * before the shown.bs.collapse or hidden.bs.collapse event occurs).
12 */
13 toggle(): void;
14
15 /**
16 * Shows a collapsible element. Returns to the caller before the collapsible
17 * element has actually been shown (e.g., before the shown.bs.collapse event
18 * occurs).
19 */
20 show(): void;
21
22 /**
23 * Hides a collapsible element. Returns to the caller before the collapsible
24 * element has actually been hidden (e.g., before the hidden.bs.collapse
25 * event occurs).
26 */
27 hide(): void;
28
29 /**
30 * Static method which allows you to get the collapse instance associated
31 * with a DOM element.
32 */
33 static getInstance(element: Element, options?: Partial<Collapse.Options>): Collapse;
34
35 static jQueryInterface: Collapse.jQueryInterface;
36
37 // static NAME: 'collapse';
38
39 /**
40 * Default settings of this plugin
41 *
42 * @link https://getbootstrap.com/docs/5.0/getting-started/javascript/#default-settings
43 */
44 static Default: Collapse.Options;
45}
46
47declare namespace Collapse {
48 enum Events {
49 /**
50 * This event fires immediately when the show instance method is called.
51 */
52 show = 'show.bs.collapse',
53
54 /**
55 * This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete).
56 */
57 shown = 'shown.bs.collapse',
58
59 /**
60 * This event is fired immediately when the hide method has been called.
61 */
62 hide = 'hide.bs.collapse',
63
64 /**
65 * This event is fired when a collapse element has been hidden from the
66 * user (will wait for CSS transitions to complete).
67 */
68 hidden = 'hidden.bs.collapse',
69 }
70
71 interface Options {
72 /**
73 * If parent is provided, then all collapsible elements under the specified
74 * parent will be closed when this collapsible item is shown. (similar to
75 * traditional accordion behavior - this is dependent on the card class).
76 * The attribute has to be set on the target collapsible area.
77 *
78 * @default false
79 */
80 parent: string | Element | JQuery;
81
82 /**
83 * Toggles the collapsible element on invocation
84 *
85 * @default true
86 */
87 toggle: boolean;
88 }
89
90 type jQueryInterface = (config?: Partial<Options> | 'show' | 'hide' | 'toggle' | 'dispose') => void;
91}
92
93export default Collapse;