1 | import BaseComponent, { GetInstanceFactory, GetOrCreateInstanceFactory } from './base-component';
|
2 |
|
3 | declare class Modal extends BaseComponent {
|
4 | /**
|
5 | * Static method which allows you to get the modal instance associated with
|
6 | * a DOM element
|
7 | */
|
8 | static getInstance: GetInstanceFactory<Modal>;
|
9 |
|
10 | /**
|
11 | * Static method which allows you to get the modal instance associated with
|
12 | * a DOM element, or create a new one in case it wasn’t initialised
|
13 | */
|
14 | static getOrCreateInstance: GetOrCreateInstanceFactory<Modal, Partial<Modal.Options>>;
|
15 |
|
16 | static jQueryInterface: Modal.jQueryInterface;
|
17 |
|
18 | /**
|
19 | * Default settings of this plugin
|
20 | *
|
21 | * @link https://getbootstrap.com/docs/5.0/getting-started/javascript/#default-settings
|
22 | */
|
23 | static Default: Modal.Options;
|
24 |
|
25 | constructor(element: string | Element, options?: Partial<Modal.Options>);
|
26 |
|
27 | /**
|
28 | * Manually toggles a modal. Returns to the caller before the modal has
|
29 | * actually been shown or hidden (i.e. before the shown.bs.modal or
|
30 | * hidden.bs.modal event occurs).
|
31 | */
|
32 | toggle(relatedTarget?: HTMLElement): void;
|
33 |
|
34 | /**
|
35 | * Manually opens a modal. Returns to the caller before the modal has
|
36 | * actually been shown (i.e. before the shown.bs.modal event occurs).
|
37 | */
|
38 | show(relatedTarget?: HTMLElement): void;
|
39 |
|
40 | /**
|
41 | * Manually hides a modal. Returns to the caller before the modal has
|
42 | * actually been hidden (i.e. before the hidden.bs.modal event occurs).
|
43 | */
|
44 | hide(): void;
|
45 |
|
46 | /**
|
47 | * Manually readjust the modal’s position if the height of a modal
|
48 | * changes while it is open (i.e. in case a scrollbar appears).
|
49 | */
|
50 | handleUpdate(): void;
|
51 | }
|
52 |
|
53 | declare namespace Modal {
|
54 | enum Events {
|
55 | /**
|
56 | * This event fires immediately when the show instance method is called.
|
57 | * If caused by a click, the clicked element is available as the
|
58 | * relatedTarget property of the event.
|
59 | */
|
60 | show = 'show.bs.modal',
|
61 |
|
62 | /**
|
63 | * This event is fired when the modal has been made visible to the user
|
64 | * (will wait for CSS transitions to complete). If caused by a click,
|
65 | * the clicked element is available as the relatedTarget property of
|
66 | * the event.
|
67 | */
|
68 | shown = 'shown.bs.modal',
|
69 |
|
70 | /**
|
71 | * This event is fired immediately when the hide instance method has
|
72 | * been called.
|
73 | */
|
74 | hide = 'hide.bs.modal',
|
75 |
|
76 | /**
|
77 | * This event is fired when the modal has finished being hidden from the
|
78 | * user (will wait for CSS transitions to complete).
|
79 | */
|
80 | hidden = 'hidden.bs.modal',
|
81 |
|
82 | /**
|
83 | * This event is fired when the modal is shown, its backdrop is static
|
84 | * and a click outside the modal or an escape key press is performed
|
85 | * with the keyboard option or data-keyboard set to false.
|
86 | */
|
87 | hidePrevented = 'hidePrevented.bs.modal',
|
88 | }
|
89 |
|
90 | interface Options {
|
91 | /**
|
92 | * Includes a modal-backdrop element. Alternatively, specify static for
|
93 | * a backdrop which doesn't close the modal on click.
|
94 | *
|
95 | * @default true
|
96 | */
|
97 | backdrop: 'static' | boolean;
|
98 |
|
99 | /**
|
100 | * Closes the modal when escape key is pressed
|
101 | *
|
102 | * @default true
|
103 | */
|
104 | keyboard: boolean;
|
105 |
|
106 | /**
|
107 | * Puts the focus on the modal when initialized.
|
108 | *
|
109 | * @default true
|
110 | */
|
111 | focus: boolean;
|
112 | }
|
113 |
|
114 | type jQueryInterface = (
|
115 | config?: Partial<Options> | 'toggle' | 'show' | 'hide' | 'handleUpdate' | 'dispose',
|
116 | ) => void;
|
117 | }
|
118 |
|
119 | export default Modal;
|