mtrl 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +15 -0
- package/CONTRIBUTING.md +8 -8
- package/DOCS.md +3 -3
- package/README.md +43 -20
- package/TESTING.md +128 -18
- package/dist/index.js +14865 -0
- package/git-user-stats.js +545 -0
- package/index.ts +9 -69
- package/package.json +10 -3
- package/src/components/badge/api.ts +15 -1
- package/src/components/badge/badge.ts +43 -4
- package/src/components/badge/config.ts +40 -8
- package/src/components/badge/index.ts +64 -3
- package/src/components/badge/types.ts +175 -33
- package/src/components/button/api.ts +63 -1
- package/src/components/button/button.ts +39 -3
- package/src/components/button/config.ts +21 -4
- package/src/components/button/index.ts +26 -1
- package/src/components/button/types.ts +7 -1
- package/src/components/card/api.ts +78 -9
- package/src/components/card/card.ts +58 -3
- package/src/components/card/config.ts +41 -11
- package/src/components/card/features.ts +39 -12
- package/src/components/card/index.ts +84 -19
- package/src/components/card/types.ts +218 -29
- package/src/components/carousel/carousel.ts +92 -28
- package/src/components/carousel/constants.ts +107 -21
- package/src/components/carousel/index.ts +31 -13
- package/src/components/checkbox/checkbox.ts +83 -16
- package/src/components/checkbox/index.ts +43 -1
- package/src/components/checkbox/types.ts +219 -32
- package/src/components/chips/api.ts +194 -0
- package/src/components/{chip → chips/chip}/api.ts +42 -2
- package/src/components/chips/chip/chip.ts +131 -0
- package/src/components/{chip → chips/chip}/config.ts +3 -3
- package/src/components/chips/chip/index.ts +3 -0
- package/src/components/chips/chips.md +481 -0
- package/src/components/chips/chips.ts +75 -0
- package/src/components/chips/config.ts +109 -0
- package/src/components/chips/constants.ts +61 -0
- package/src/components/chips/features/chip-items.ts +33 -0
- package/src/components/chips/features/container.ts +77 -0
- package/src/components/chips/features/controller.ts +448 -0
- package/src/components/chips/features/index.ts +5 -0
- package/src/components/chips/features/label.ts +108 -0
- package/src/components/chips/index.ts +11 -0
- package/src/components/chips/schema.ts +61 -0
- package/src/components/{chip → chips}/types.ts +203 -92
- package/src/components/dialog/dialog.ts +99 -16
- package/src/components/dialog/index.ts +97 -1
- package/src/components/dialog/types.ts +375 -69
- package/src/components/divider/config.ts +90 -6
- package/src/components/divider/divider.ts +32 -2
- package/src/components/divider/features.ts +26 -0
- package/src/components/divider/index.ts +30 -0
- package/src/components/divider/types.ts +86 -9
- package/src/components/extended-fab/api.ts +53 -1
- package/src/components/extended-fab/config.ts +29 -1
- package/src/components/extended-fab/extended-fab.ts +28 -0
- package/src/components/extended-fab/index.ts +36 -0
- package/src/components/extended-fab/types.ts +458 -13
- package/src/components/fab/api.ts +42 -2
- package/src/components/fab/config.ts +29 -1
- package/src/components/fab/fab.ts +16 -2
- package/src/components/fab/index.ts +35 -0
- package/src/components/fab/types.ts +374 -10
- package/src/components/list/api.ts +12 -2
- package/src/components/list/config.ts +21 -0
- package/src/components/list/features.ts +6 -0
- package/src/components/list/index.ts +56 -1
- package/src/components/list/list-item.ts +46 -2
- package/src/components/list/list.ts +73 -2
- package/src/components/list/types.ts +172 -0
- package/src/components/list/utils.ts +26 -2
- package/src/components/menu/api.ts +217 -20
- package/src/components/menu/config.ts +27 -0
- package/src/components/menu/features/visibility.ts +55 -6
- package/src/components/menu/index.ts +64 -0
- package/src/components/menu/menu-item.ts +46 -3
- package/src/components/menu/menu.ts +77 -1
- package/src/components/menu/types.ts +404 -39
- package/src/components/navigation/index.ts +4 -1
- package/src/components/navigation/types.ts +33 -0
- package/src/components/sheet/config.ts +1 -2
- package/src/components/sheet/features/gestures.ts +1 -1
- package/src/components/sheet/features/position.ts +1 -2
- package/src/components/sheet/features/state.ts +1 -1
- package/src/components/sheet/index.ts +10 -2
- package/src/components/sheet/sheet.ts +1 -2
- package/src/components/sheet/types.ts +29 -1
- package/src/components/slider/api.ts +1 -1
- package/src/components/slider/config.ts +1 -1
- package/src/components/slider/features/controller.ts +1 -1
- package/src/components/slider/features/handlers.ts +1 -1
- package/src/components/slider/features/states.ts +1 -1
- package/src/components/slider/index.ts +12 -5
- package/src/components/slider/schema.ts +1 -1
- package/src/components/slider/types.ts +31 -0
- package/src/components/snackbar/index.ts +7 -1
- package/src/components/snackbar/types.ts +25 -0
- package/src/components/switch/index.ts +5 -1
- package/src/components/switch/types.ts +13 -0
- package/src/components/tabs/tab-api.ts +1 -1
- package/src/components/tabs/types.ts +1 -1
- package/src/components/textfield/index.ts +7 -1
- package/src/components/textfield/types.ts +36 -0
- package/src/components/tooltip/api.ts +6 -2
- package/src/components/tooltip/config.ts +9 -28
- package/src/components/tooltip/index.ts +10 -1
- package/src/components/tooltip/types.ts +38 -3
- package/src/index.ts +129 -31
- package/src/styles/abstract/_mixins.scss +23 -9
- package/src/styles/abstract/_variables.scss +14 -4
- package/src/styles/components/_card.scss +1 -1
- package/src/styles/components/_chip.scss +323 -113
- package/src/styles/components/_tabs.scss +1 -1
- package/src/components/checkbox/constants.ts +0 -37
- package/src/components/chip/chip-set.ts +0 -225
- package/src/components/chip/chip.ts +0 -118
- package/src/components/chip/constants.ts +0 -28
- package/src/components/chip/index.ts +0 -12
- package/src/components/list/constants.ts +0 -116
- package/src/components/sheet/constants.ts +0 -20
- package/src/components/slider/constants.ts +0 -32
- package/src/components/snackbar/constants.ts +0 -26
- package/src/components/tooltip/constants.ts +0 -27
- package/test/components/button.test.js +0 -170
- package/test/components/checkbox.test.js +0 -238
- package/test/components/list.test.js +0 -105
- package/test/components/menu.test.js +0 -385
- package/test/components/navigation.test.js +0 -227
- package/test/components/snackbar.test.js +0 -234
- package/test/components/switch.test.js +0 -186
- package/test/components/textfield.test.js +0 -314
- package/test/core/emitter.test.js +0 -141
- package/test/core/ripple.test.js +0 -66
- package/test/setup.js +0 -371
- package/tsconfig.json +0 -22
- package/typedoc.json +0 -28
- package/typedoc.simple.json +0 -14
|
@@ -1,91 +1,195 @@
|
|
|
1
1
|
// src/components/dialog/types.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Dialog size types
|
|
4
|
+
* Dialog size types - determines the width and height of the dialog
|
|
5
|
+
*
|
|
5
6
|
* @category Components
|
|
7
|
+
* @remarks
|
|
8
|
+
* - small: 320px width, for simple messages or choices
|
|
9
|
+
* - medium: 560px width, for standard forms or content (default)
|
|
10
|
+
* - large: 800px width, for complex forms or rich content
|
|
11
|
+
* - fullwidth: Spans the full width of the viewport with margins
|
|
12
|
+
* - fullscreen: Takes up the entire viewport (similar to a new page)
|
|
6
13
|
*/
|
|
7
14
|
export type DialogSize = 'small' | 'medium' | 'large' | 'fullwidth' | 'fullscreen';
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
|
-
* Dialog animation types
|
|
17
|
+
* Dialog animation types - controls how the dialog appears and disappears
|
|
18
|
+
*
|
|
11
19
|
* @category Components
|
|
20
|
+
* @remarks
|
|
21
|
+
* - scale: Scale up/down animation from center (default)
|
|
22
|
+
* - slide-up: Slide in from bottom, slide out to bottom
|
|
23
|
+
* - slide-down: Slide in from top, slide out to top
|
|
24
|
+
* - fade: Simple fade in/out animation
|
|
12
25
|
*/
|
|
13
26
|
export type DialogAnimation = 'scale' | 'slide-up' | 'slide-down' | 'fade';
|
|
14
27
|
|
|
15
28
|
/**
|
|
16
|
-
* Dialog footer alignment types
|
|
29
|
+
* Dialog footer alignment types - controls how buttons in the footer are aligned
|
|
30
|
+
*
|
|
17
31
|
* @category Components
|
|
32
|
+
* @remarks
|
|
33
|
+
* - right: Align buttons to the right (default, follows Material Design guidelines)
|
|
34
|
+
* - left: Align buttons to the left
|
|
35
|
+
* - center: Center buttons in footer
|
|
36
|
+
* - space-between: Space buttons evenly, with first button at left, last at right
|
|
18
37
|
*/
|
|
19
38
|
export type DialogFooterAlignment = 'right' | 'left' | 'center' | 'space-between';
|
|
20
39
|
|
|
21
40
|
/**
|
|
22
|
-
* Dialog event types
|
|
41
|
+
* Dialog event types - events that can be listened to with the on() method
|
|
42
|
+
*
|
|
23
43
|
* @category Components
|
|
44
|
+
* @remarks
|
|
45
|
+
* - open: Fired when the dialog begins opening
|
|
46
|
+
* - close: Fired when the dialog begins closing
|
|
47
|
+
* - beforeopen: Fired before the dialog starts opening (can be prevented)
|
|
48
|
+
* - beforeclose: Fired before the dialog starts closing (can be prevented)
|
|
49
|
+
* - afteropen: Fired after the dialog has fully opened (animation complete)
|
|
50
|
+
* - afterclose: Fired after the dialog has fully closed (animation complete)
|
|
24
51
|
*/
|
|
25
52
|
export type DialogEventType = 'open' | 'close' | 'beforeopen' | 'beforeclose' | 'afteropen' | 'afterclose';
|
|
26
53
|
|
|
27
54
|
/**
|
|
28
55
|
* Configuration interface for the Dialog component
|
|
56
|
+
*
|
|
57
|
+
* @category Components
|
|
58
|
+
* @description
|
|
59
|
+
* Defines the appearance and behavior of a dialog component.
|
|
60
|
+
* All properties are optional with sensible defaults.
|
|
29
61
|
*/
|
|
30
62
|
export interface DialogConfig {
|
|
31
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Dialog title text - appears in the header
|
|
65
|
+
* @example "Settings"
|
|
66
|
+
*/
|
|
32
67
|
title?: string;
|
|
33
68
|
|
|
34
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Dialog subtitle text - appears below title in smaller text
|
|
71
|
+
* @example "Configure your preferences"
|
|
72
|
+
*/
|
|
35
73
|
subtitle?: string;
|
|
36
74
|
|
|
37
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Dialog content (text or HTML)
|
|
77
|
+
* Can include rich content like forms, images, etc.
|
|
78
|
+
* @example "This action cannot be undone."
|
|
79
|
+
*/
|
|
38
80
|
content?: string;
|
|
39
81
|
|
|
40
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Whether to show close button (X) in the header
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
41
86
|
closeButton?: boolean;
|
|
42
87
|
|
|
43
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Additional CSS classes to apply to the dialog
|
|
90
|
+
* @example "settings-dialog important-dialog"
|
|
91
|
+
*/
|
|
44
92
|
class?: string;
|
|
45
93
|
|
|
46
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Dialog size variant
|
|
96
|
+
* Controls the width and height of the dialog
|
|
97
|
+
* @default "medium"
|
|
98
|
+
*/
|
|
47
99
|
size?: DialogSize | string;
|
|
48
100
|
|
|
49
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Dialog animation variant
|
|
103
|
+
* Controls how the dialog appears and disappears
|
|
104
|
+
* @default "scale"
|
|
105
|
+
*/
|
|
50
106
|
animation?: DialogAnimation | string;
|
|
51
107
|
|
|
52
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Footer buttons alignment
|
|
110
|
+
* Controls how buttons in the footer are positioned
|
|
111
|
+
* @default "right"
|
|
112
|
+
*/
|
|
53
113
|
footerAlignment?: DialogFooterAlignment | string;
|
|
54
114
|
|
|
55
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Whether dialog is initially open
|
|
117
|
+
* @default false
|
|
118
|
+
*/
|
|
56
119
|
open?: boolean;
|
|
57
120
|
|
|
58
|
-
/**
|
|
121
|
+
/**
|
|
122
|
+
* Whether to close when clicking overlay background
|
|
123
|
+
* When true, allows users to dismiss by clicking outside
|
|
124
|
+
* @default true
|
|
125
|
+
*/
|
|
59
126
|
closeOnOverlayClick?: boolean;
|
|
60
127
|
|
|
61
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Whether to close when Escape key is pressed
|
|
130
|
+
* @default true
|
|
131
|
+
*/
|
|
62
132
|
closeOnEscape?: boolean;
|
|
63
133
|
|
|
64
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Whether dialog should be modal
|
|
136
|
+
* When true, prevents interaction with background content
|
|
137
|
+
* @default true
|
|
138
|
+
*/
|
|
65
139
|
modal?: boolean;
|
|
66
140
|
|
|
67
|
-
/**
|
|
141
|
+
/**
|
|
142
|
+
* Whether to focus the first focusable element when opened
|
|
143
|
+
* Important for accessibility and keyboard navigation
|
|
144
|
+
* @default true
|
|
145
|
+
*/
|
|
68
146
|
autofocus?: boolean;
|
|
69
147
|
|
|
70
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Whether to trap focus within dialog when opened
|
|
150
|
+
* Prevents tabbing outside the dialog, improving accessibility
|
|
151
|
+
* @default true
|
|
152
|
+
*/
|
|
71
153
|
trapFocus?: boolean;
|
|
72
154
|
|
|
73
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* Parent element to append dialog to
|
|
157
|
+
* @default document.body
|
|
158
|
+
*/
|
|
74
159
|
container?: HTMLElement;
|
|
75
160
|
|
|
76
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Footer buttons configuration
|
|
163
|
+
* Array of button objects to display in the footer
|
|
164
|
+
*/
|
|
77
165
|
buttons?: DialogButton[];
|
|
78
166
|
|
|
79
|
-
/**
|
|
167
|
+
/**
|
|
168
|
+
* Whether to show a divider between header and content
|
|
169
|
+
* @default false
|
|
170
|
+
*/
|
|
80
171
|
divider?: boolean;
|
|
81
172
|
|
|
82
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Dialog z-index - controls stacking order
|
|
175
|
+
* @default 1000
|
|
176
|
+
*/
|
|
83
177
|
zIndex?: number;
|
|
84
178
|
|
|
85
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Duration of open/close animations in milliseconds
|
|
181
|
+
* @default 300
|
|
182
|
+
*/
|
|
86
183
|
animationDuration?: number;
|
|
87
184
|
|
|
88
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Event handlers for dialog events
|
|
187
|
+
* Register event handlers during initialization
|
|
188
|
+
* @example
|
|
189
|
+
* {
|
|
190
|
+
* afteropen: (event) => { console.log('Dialog opened'); }
|
|
191
|
+
* }
|
|
192
|
+
*/
|
|
89
193
|
on?: {
|
|
90
194
|
[key in DialogEventType]?: (event: DialogEvent) => void;
|
|
91
195
|
};
|
|
@@ -93,155 +197,357 @@ export interface DialogConfig {
|
|
|
93
197
|
|
|
94
198
|
/**
|
|
95
199
|
* Dialog button configuration
|
|
200
|
+
*
|
|
201
|
+
* Defines the appearance and behavior of buttons in the dialog footer.
|
|
202
|
+
*
|
|
203
|
+
* @category Components
|
|
96
204
|
*/
|
|
97
205
|
export interface DialogButton {
|
|
98
|
-
/**
|
|
206
|
+
/**
|
|
207
|
+
* Button text label
|
|
208
|
+
* @example "Save" | "Cancel" | "Delete"
|
|
209
|
+
*/
|
|
99
210
|
text: string;
|
|
100
211
|
|
|
101
|
-
/**
|
|
212
|
+
/**
|
|
213
|
+
* Button variant (uses button component variants)
|
|
214
|
+
* @default "text"
|
|
215
|
+
* @example "filled" | "text" | "outlined" | "tonal"
|
|
216
|
+
*/
|
|
102
217
|
variant?: string;
|
|
103
218
|
|
|
104
|
-
/**
|
|
219
|
+
/**
|
|
220
|
+
* Button color
|
|
221
|
+
* @example "primary" | "error"
|
|
222
|
+
*/
|
|
105
223
|
color?: string;
|
|
106
224
|
|
|
107
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* Button size
|
|
227
|
+
* @default "medium"
|
|
228
|
+
* @example "small" | "medium" | "large"
|
|
229
|
+
*/
|
|
108
230
|
size?: string;
|
|
109
231
|
|
|
110
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* Button click handler
|
|
234
|
+
* Return false to prevent dialog closing
|
|
235
|
+
* @param event - The click event
|
|
236
|
+
* @param dialog - The dialog component instance
|
|
237
|
+
* @returns Optional boolean, false prevents dialog from closing
|
|
238
|
+
*/
|
|
111
239
|
onClick?: (event: MouseEvent, dialog: DialogComponent) => void | boolean;
|
|
112
240
|
|
|
113
|
-
/**
|
|
241
|
+
/**
|
|
242
|
+
* Whether to close the dialog when this button is clicked
|
|
243
|
+
* Set to false for validation or multi-step flows
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
114
246
|
closeDialog?: boolean;
|
|
115
247
|
|
|
116
|
-
/**
|
|
248
|
+
/**
|
|
249
|
+
* Whether to autofocus this button when the dialog opens
|
|
250
|
+
* Typically used for primary action buttons
|
|
251
|
+
* @default false
|
|
252
|
+
*/
|
|
117
253
|
autofocus?: boolean;
|
|
118
254
|
|
|
119
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Additional button attributes to pass to the button element
|
|
257
|
+
* @example { 'data-id': 'save-button', 'form': 'profile-form' }
|
|
258
|
+
*/
|
|
120
259
|
attrs?: Record<string, any>;
|
|
121
260
|
}
|
|
122
261
|
|
|
123
262
|
/**
|
|
124
263
|
* Dialog event object
|
|
264
|
+
*
|
|
265
|
+
* Passed to event handlers registered with the on() method.
|
|
266
|
+
*
|
|
267
|
+
* @category Components
|
|
125
268
|
*/
|
|
126
269
|
export interface DialogEvent {
|
|
127
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* Dialog component instance that triggered the event
|
|
272
|
+
*/
|
|
128
273
|
dialog: DialogComponent;
|
|
129
274
|
|
|
130
|
-
/**
|
|
275
|
+
/**
|
|
276
|
+
* Original browser event if applicable
|
|
277
|
+
* May be undefined for programmatic events
|
|
278
|
+
*/
|
|
131
279
|
originalEvent?: Event;
|
|
132
280
|
|
|
133
|
-
/**
|
|
281
|
+
/**
|
|
282
|
+
* Call this method to prevent the default action
|
|
283
|
+
* For example, to prevent a dialog from closing
|
|
284
|
+
*/
|
|
134
285
|
preventDefault: () => void;
|
|
135
286
|
|
|
136
|
-
/**
|
|
287
|
+
/**
|
|
288
|
+
* Whether the default action was prevented
|
|
289
|
+
* Will be true if preventDefault() was called
|
|
290
|
+
*/
|
|
137
291
|
defaultPrevented: boolean;
|
|
138
292
|
}
|
|
139
293
|
|
|
140
294
|
/**
|
|
141
295
|
* Dialog component interface
|
|
296
|
+
*
|
|
297
|
+
* Provides methods for controlling a Material Design 3 dialog
|
|
298
|
+
*
|
|
299
|
+
* @category Components
|
|
142
300
|
*/
|
|
143
301
|
export interface DialogComponent {
|
|
144
|
-
/**
|
|
302
|
+
/**
|
|
303
|
+
* The dialog's root DOM element
|
|
304
|
+
*/
|
|
145
305
|
element: HTMLElement;
|
|
146
306
|
|
|
147
|
-
/**
|
|
307
|
+
/**
|
|
308
|
+
* The dialog's overlay/backdrop element
|
|
309
|
+
*/
|
|
148
310
|
overlay: HTMLElement;
|
|
149
311
|
|
|
150
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Opens the dialog
|
|
314
|
+
* Displays the dialog with animation
|
|
315
|
+
* @returns Dialog component for method chaining
|
|
316
|
+
*/
|
|
151
317
|
open: () => DialogComponent;
|
|
152
318
|
|
|
153
|
-
/**
|
|
319
|
+
/**
|
|
320
|
+
* Closes the dialog
|
|
321
|
+
* Hides the dialog with animation
|
|
322
|
+
* @returns Dialog component for method chaining
|
|
323
|
+
*/
|
|
154
324
|
close: () => DialogComponent;
|
|
155
325
|
|
|
156
|
-
/**
|
|
326
|
+
/**
|
|
327
|
+
* Toggles dialog open/closed state
|
|
328
|
+
* @param open - Optional boolean to force specific state
|
|
329
|
+
* @returns Dialog component for method chaining
|
|
330
|
+
* @example
|
|
331
|
+
* dialog.toggle(); // Toggle current state
|
|
332
|
+
* dialog.toggle(true); // Force open
|
|
333
|
+
*/
|
|
157
334
|
toggle: (open?: boolean) => DialogComponent;
|
|
158
335
|
|
|
159
|
-
/**
|
|
336
|
+
/**
|
|
337
|
+
* Checks if dialog is currently open
|
|
338
|
+
* @returns True if dialog is open, false otherwise
|
|
339
|
+
*/
|
|
160
340
|
isOpen: () => boolean;
|
|
161
341
|
|
|
162
|
-
/**
|
|
342
|
+
/**
|
|
343
|
+
* Sets dialog title text
|
|
344
|
+
* @param title - New title to display in header
|
|
345
|
+
* @returns Dialog component for method chaining
|
|
346
|
+
*/
|
|
163
347
|
setTitle: (title: string) => DialogComponent;
|
|
164
348
|
|
|
165
|
-
/**
|
|
349
|
+
/**
|
|
350
|
+
* Gets dialog current title text
|
|
351
|
+
* @returns Current title text
|
|
352
|
+
*/
|
|
166
353
|
getTitle: () => string;
|
|
167
354
|
|
|
168
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Sets dialog subtitle text
|
|
357
|
+
* @param subtitle - New subtitle to display below title
|
|
358
|
+
* @returns Dialog component for method chaining
|
|
359
|
+
*/
|
|
169
360
|
setSubtitle: (subtitle: string) => DialogComponent;
|
|
170
361
|
|
|
171
|
-
/**
|
|
362
|
+
/**
|
|
363
|
+
* Gets dialog current subtitle text
|
|
364
|
+
* @returns Current subtitle text
|
|
365
|
+
*/
|
|
172
366
|
getSubtitle: () => string;
|
|
173
367
|
|
|
174
|
-
/**
|
|
368
|
+
/**
|
|
369
|
+
* Sets dialog content
|
|
370
|
+
* @param content - New content (text or HTML)
|
|
371
|
+
* @returns Dialog component for method chaining
|
|
372
|
+
*/
|
|
175
373
|
setContent: (content: string) => DialogComponent;
|
|
176
374
|
|
|
177
|
-
/**
|
|
375
|
+
/**
|
|
376
|
+
* Gets dialog content
|
|
377
|
+
* @returns Current content text/HTML
|
|
378
|
+
*/
|
|
178
379
|
getContent: () => string;
|
|
179
380
|
|
|
180
|
-
/**
|
|
381
|
+
/**
|
|
382
|
+
* Adds a button to the dialog footer
|
|
383
|
+
* @param button - Button configuration object
|
|
384
|
+
* @returns Dialog component for method chaining
|
|
385
|
+
*/
|
|
181
386
|
addButton: (button: DialogButton) => DialogComponent;
|
|
182
387
|
|
|
183
|
-
/**
|
|
388
|
+
/**
|
|
389
|
+
* Removes a button by index or text
|
|
390
|
+
* @param indexOrText - Button index or text content
|
|
391
|
+
* @returns Dialog component for method chaining
|
|
392
|
+
* @example
|
|
393
|
+
* dialog.removeButton(0); // Remove first button
|
|
394
|
+
* dialog.removeButton('Cancel'); // Remove button with text 'Cancel'
|
|
395
|
+
*/
|
|
184
396
|
removeButton: (indexOrText: number | string) => DialogComponent;
|
|
185
397
|
|
|
186
|
-
/**
|
|
398
|
+
/**
|
|
399
|
+
* Gets all footer buttons
|
|
400
|
+
* @returns Array of button configuration objects
|
|
401
|
+
*/
|
|
187
402
|
getButtons: () => DialogButton[];
|
|
188
403
|
|
|
189
|
-
/**
|
|
404
|
+
/**
|
|
405
|
+
* Sets footer button alignment
|
|
406
|
+
* @param alignment - Alignment value
|
|
407
|
+
* @returns Dialog component for method chaining
|
|
408
|
+
*/
|
|
190
409
|
setFooterAlignment: (alignment: DialogFooterAlignment | string) => DialogComponent;
|
|
191
410
|
|
|
192
|
-
/**
|
|
411
|
+
/**
|
|
412
|
+
* Sets dialog size
|
|
413
|
+
* @param size - Size variant
|
|
414
|
+
* @returns Dialog component for method chaining
|
|
415
|
+
*/
|
|
193
416
|
setSize: (size: DialogSize | string) => DialogComponent;
|
|
194
417
|
|
|
195
|
-
/**
|
|
418
|
+
/**
|
|
419
|
+
* Adds an event listener to the dialog
|
|
420
|
+
* @param event - Event name
|
|
421
|
+
* @param handler - Event handler function
|
|
422
|
+
* @returns Dialog component for method chaining
|
|
423
|
+
* @example
|
|
424
|
+
* dialog.on('beforeclose', (event) => {
|
|
425
|
+
* // Prevent dialog from closing if form is invalid
|
|
426
|
+
* if (!isFormValid()) {
|
|
427
|
+
* event.preventDefault();
|
|
428
|
+
* }
|
|
429
|
+
* });
|
|
430
|
+
*/
|
|
196
431
|
on: (event: DialogEventType | string, handler: (event: DialogEvent) => void) => DialogComponent;
|
|
197
432
|
|
|
198
|
-
/**
|
|
433
|
+
/**
|
|
434
|
+
* Removes an event listener from the dialog
|
|
435
|
+
* @param event - Event name
|
|
436
|
+
* @param handler - Event handler function
|
|
437
|
+
* @returns Dialog component for method chaining
|
|
438
|
+
*/
|
|
199
439
|
off: (event: DialogEventType | string, handler: (event: DialogEvent) => void) => DialogComponent;
|
|
200
440
|
|
|
201
|
-
/**
|
|
441
|
+
/**
|
|
442
|
+
* Gets dialog header element
|
|
443
|
+
* @returns Header element or null if not present
|
|
444
|
+
*/
|
|
202
445
|
getHeaderElement: () => HTMLElement | null;
|
|
203
446
|
|
|
204
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* Gets dialog content element
|
|
449
|
+
* @returns Content element or null if not present
|
|
450
|
+
*/
|
|
205
451
|
getContentElement: () => HTMLElement | null;
|
|
206
452
|
|
|
207
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* Gets dialog footer element
|
|
455
|
+
* @returns Footer element or null if not present
|
|
456
|
+
*/
|
|
208
457
|
getFooterElement: () => HTMLElement | null;
|
|
209
458
|
|
|
210
|
-
/**
|
|
459
|
+
/**
|
|
460
|
+
* Shows or hides the divider between header and content
|
|
461
|
+
* @param show - Whether to show or hide divider
|
|
462
|
+
* @returns Dialog component for method chaining
|
|
463
|
+
*/
|
|
211
464
|
toggleDivider: (show: boolean) => DialogComponent;
|
|
212
465
|
|
|
213
|
-
/**
|
|
466
|
+
/**
|
|
467
|
+
* Checks if the dialog has a divider visible
|
|
468
|
+
* @returns True if divider is visible, false otherwise
|
|
469
|
+
*/
|
|
214
470
|
hasDivider: () => boolean;
|
|
215
471
|
|
|
216
|
-
/**
|
|
472
|
+
/**
|
|
473
|
+
* Creates a confirmation dialog with Yes/No buttons
|
|
474
|
+
* Returns a promise that resolves to true if confirmed, false otherwise
|
|
475
|
+
*
|
|
476
|
+
* @param options - Confirmation dialog options
|
|
477
|
+
* @returns Promise resolving to boolean result
|
|
478
|
+
* @example
|
|
479
|
+
* const result = await dialog.confirm({
|
|
480
|
+
* title: 'Delete Item',
|
|
481
|
+
* message: 'Are you sure you want to delete this item?'
|
|
482
|
+
* });
|
|
483
|
+
*
|
|
484
|
+
* if (result) {
|
|
485
|
+
* deleteItem();
|
|
486
|
+
* }
|
|
487
|
+
*/
|
|
217
488
|
confirm: (options?: DialogConfirmOptions) => Promise<boolean>;
|
|
218
489
|
|
|
219
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* Destroys the dialog and removes it from DOM
|
|
492
|
+
* Cleans up all event listeners and references
|
|
493
|
+
*/
|
|
220
494
|
destroy: () => void;
|
|
221
495
|
}
|
|
222
496
|
|
|
223
497
|
/**
|
|
224
498
|
* Options for confirmation dialog
|
|
499
|
+
*
|
|
500
|
+
* Used with the dialog.confirm() method to create a simple
|
|
501
|
+
* confirmation dialog with customizable options.
|
|
502
|
+
*
|
|
503
|
+
* @category Components
|
|
225
504
|
*/
|
|
226
505
|
export interface DialogConfirmOptions {
|
|
227
|
-
/**
|
|
506
|
+
/**
|
|
507
|
+
* Confirmation dialog title
|
|
508
|
+
* @default "Confirm"
|
|
509
|
+
* @example "Delete Item"
|
|
510
|
+
*/
|
|
228
511
|
title?: string;
|
|
229
512
|
|
|
230
|
-
/**
|
|
513
|
+
/**
|
|
514
|
+
* Confirmation message/question to display
|
|
515
|
+
* Required field for the confirmation dialog
|
|
516
|
+
* @example "Are you sure you want to delete this item?"
|
|
517
|
+
*/
|
|
231
518
|
message: string;
|
|
232
519
|
|
|
233
|
-
/**
|
|
520
|
+
/**
|
|
521
|
+
* Confirm button text
|
|
522
|
+
* @default "Yes"
|
|
523
|
+
* @example "Delete" | "Confirm" | "Yes, I'm sure"
|
|
524
|
+
*/
|
|
234
525
|
confirmText?: string;
|
|
235
526
|
|
|
236
|
-
/**
|
|
527
|
+
/**
|
|
528
|
+
* Cancel button text
|
|
529
|
+
* @default "No"
|
|
530
|
+
* @example "Cancel" | "No, go back"
|
|
531
|
+
*/
|
|
237
532
|
cancelText?: string;
|
|
238
533
|
|
|
239
|
-
/**
|
|
534
|
+
/**
|
|
535
|
+
* Confirm button variant
|
|
536
|
+
* @default "filled"
|
|
537
|
+
* @example "filled" | "tonal"
|
|
538
|
+
*/
|
|
240
539
|
confirmVariant?: string;
|
|
241
540
|
|
|
242
|
-
/**
|
|
541
|
+
/**
|
|
542
|
+
* Cancel button variant
|
|
543
|
+
* @default "text"
|
|
544
|
+
* @example "text" | "outlined"
|
|
545
|
+
*/
|
|
243
546
|
cancelVariant?: string;
|
|
244
547
|
|
|
245
|
-
/**
|
|
548
|
+
/**
|
|
549
|
+
* Dialog size for the confirmation dialog
|
|
550
|
+
* @default "small"
|
|
551
|
+
*/
|
|
246
552
|
size?: DialogSize | string;
|
|
247
553
|
}
|