1 | import * as Popper from "@popperjs/core";
|
2 | import BaseComponent from "./base-component";
|
3 |
|
4 | declare class Dropdown extends BaseComponent {
|
5 | constructor(element: string | Element, options?: Partial<Dropdown.Options>);
|
6 |
|
7 | /**
|
8 | * Toggles the dropdown menu of a given navbar or tabbed navigation.
|
9 | */
|
10 | toggle(): void;
|
11 |
|
12 | /**
|
13 | * Shows the dropdown menu of a given navbar or tabbed navigation.
|
14 | */
|
15 | show(): void;
|
16 |
|
17 | /**
|
18 | * Hides the dropdown menu of a given navbar or tabbed navigation.
|
19 | */
|
20 | hide(): void;
|
21 |
|
22 | /**
|
23 | * Updates the position of an element's dropdown.
|
24 | */
|
25 | update(): void;
|
26 |
|
27 | /**
|
28 | * Static method which allows you to get the dropdown instance associated
|
29 | * with a DOM element.
|
30 | */
|
31 | static getInstance(element: Element, options?: Partial<Dropdown.Options>): Dropdown;
|
32 |
|
33 | static jQueryInterface: Dropdown.jQueryInterface;
|
34 |
|
35 | // static NAME: 'dropdown';
|
36 |
|
37 | /**
|
38 | * Default settings of this plugin
|
39 | *
|
40 | * @link https://getbootstrap.com/docs/5.0/getting-started/javascript/#default-settings
|
41 | */
|
42 | static Default: Dropdown.Options;
|
43 |
|
44 | static DefaultType: Record<keyof Dropdown.Options, string>;
|
45 |
|
46 | static DATA_KEY: string;
|
47 | }
|
48 |
|
49 | declare namespace Dropdown {
|
50 | enum Events {
|
51 | /**
|
52 | * Fires immediately when the show instance method is called.
|
53 | */
|
54 | show = "show.bs.dropdown",
|
55 |
|
56 | /**
|
57 | * Fired when the dropdown has been made visible to the user and CSS
|
58 | * transitions have completed.
|
59 | */
|
60 | shown = "shown.bs.dropdown",
|
61 |
|
62 | /**
|
63 | * Fires immediately when the hide instance method has been called.
|
64 | */
|
65 | hide = "hide.bs.dropdown",
|
66 |
|
67 | /**
|
68 | * Fired when the dropdown has finished being hidden from the user and
|
69 | * CSS transitions have completed.
|
70 | */
|
71 | hidden = "hidden.bs.dropdown",
|
72 | }
|
73 |
|
74 | type Offset = [number, number];
|
75 |
|
76 | type OffsetFunction = () => Offset;
|
77 |
|
78 | type PopperConfigFunction = () => Partial<Popper.Options>;
|
79 |
|
80 | interface Options {
|
81 | /**
|
82 | * Offset of the dropdown relative to its target. You can pass a string
|
83 | * in data attributes with comma separated values like:
|
84 | * data-bs-offset="10,20"
|
85 | *
|
86 | * When a function is used to determine the offset, it is called with an
|
87 | * object containing the popper placement, the reference, and popper
|
88 | * rects as its first argument. The triggering element DOM node is
|
89 | * passed as the second argument. The function must return an array with
|
90 | * two numbers: [skidding, distance].
|
91 | *
|
92 | * For more information refer to Popper's offset docs.
|
93 | *
|
94 | * @default [0, 2]
|
95 | */
|
96 | offset: Offset | string | OffsetFunction;
|
97 |
|
98 | /**
|
99 | * Overflow constraint boundary of the dropdown menu. Accepts the values
|
100 | * of 'viewport', 'window', 'scrollParent', or an HTMLElement reference
|
101 | * (JavaScript only). For more information refer to Popper.js's
|
102 | * preventOverflow docs.
|
103 | *
|
104 | * @see {@link https://popper.js.org/docs/v2/modifiers/prevent-overflow/#boundary}
|
105 | * @default "scrollParent"
|
106 | */
|
107 | boundary: Popper.Boundary | Element;
|
108 |
|
109 | /**
|
110 | * Reference element of the dropdown menu. Accepts the values of
|
111 | * 'toggle', 'parent', an HTMLElement reference or an object providing
|
112 | * getBoundingClientRect. For more information refer to Popper.js's
|
113 | * referenceObject docs.
|
114 | *
|
115 | * @see {@link https://popper.js.org/docs/v2/constructors/#createpopper}
|
116 | * @default "toggle"
|
117 | */
|
118 | reference: "toggle" | "parent" | Element | Popper.Rect;
|
119 |
|
120 | /**
|
121 | * By default, we use Popper.js for dynamic positioning. Disable this
|
122 | * with static.
|
123 | *
|
124 | * @default "dynamic"
|
125 | */
|
126 | display: "dynamic" | "static";
|
127 |
|
128 | /**
|
129 | * To change Bootstrap's default Popper.js config, see Popper.js's
|
130 | * configuration
|
131 | *
|
132 | * When a function is used to create the Popper configuration, it's
|
133 | * called with an object that contains the Bootstrap's default Popper
|
134 | * configuration. It helps you use and merge the default with your own
|
135 | * configuration. The function must return a configuration object for
|
136 | * Popper.
|
137 | *
|
138 | * @see {@link https://popper.js.org/docs/v2}
|
139 | * @default null
|
140 | */
|
141 | popperConfig: Partial<Popper.Options> | PopperConfigFunction | null;
|
142 | }
|
143 |
|
144 | type jQueryInterface = (config?: Partial<Options> | "toggle" | "show" | "hide" | "update" | "dispose") => void;
|
145 | }
|
146 |
|
147 | export default Dropdown;
|