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