mtrl 0.7.0 → 0.8.0-next.4
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/dist/components/button/api.d.ts +4 -0
- package/dist/components/button/features/toggle.d.ts +42 -0
- package/dist/components/button/types.d.ts +30 -0
- package/dist/components/button-group/button-group.d.ts +6 -4
- package/dist/components/button-group/config.d.ts +15 -7
- package/dist/components/button-group/constants.d.ts +85 -17
- package/dist/components/button-group/index.d.ts +1 -1
- package/dist/components/button-group/types.d.ts +68 -4
- package/dist/components/carousel/api.d.ts +11 -30
- package/dist/components/carousel/arrangement.d.ts +23 -0
- package/dist/components/carousel/carousel.d.ts +13 -63
- package/dist/components/carousel/config.d.ts +2 -31
- package/dist/components/carousel/constants.d.ts +25 -151
- package/dist/components/carousel/features/index.d.ts +2 -5
- package/dist/components/carousel/features/scroll.d.ts +19 -0
- package/dist/components/carousel/features/slides.d.ts +18 -8
- package/dist/components/carousel/index.d.ts +3 -37
- package/dist/components/carousel/keylines.d.ts +65 -0
- package/dist/components/carousel/strategy.d.ts +36 -0
- package/dist/components/carousel/types.d.ts +36 -242
- package/dist/components/dialog/api.d.ts +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/slider/constants.d.ts +8 -8
- package/dist/components/slider/types.d.ts +4 -1
- package/dist/components/snackbar/api.d.ts +1 -1
- package/dist/components/snackbar/config.d.ts +2 -1
- package/dist/components/snackbar/constants.d.ts +18 -0
- package/dist/components/snackbar/index.d.ts +2 -1
- package/dist/components/snackbar/queue.d.ts +10 -2
- package/dist/components/snackbar/types.d.ts +37 -1
- package/dist/index.cjs +20 -10
- package/dist/index.cjs.map +54 -38
- package/dist/index.js +20 -10
- package/dist/index.js.map +54 -38
- package/dist/package.json +1 -1
- package/dist/styles.css +2 -2
- package/package.json +3 -6
- package/src/styles/abstract/_theme.scss +4 -2
- package/src/styles/abstract/_variables.scss +59 -12
- package/src/styles/components/_button-group.scss +122 -349
- package/src/styles/components/_button.scss +333 -591
- package/src/styles/components/_carousel.scss +131 -611
- package/src/styles/components/_icon-button.scss +23 -23
- package/src/styles/components/_select.scss +9 -1
- package/src/styles/components/_slider.scss +10 -9
- package/src/styles/themes/_index.scss +1 -0
- package/src/styles/themes/_legacy.scss +73 -0
- package/dist/components/carousel/features/drag.d.ts +0 -8
|
@@ -1,276 +1,70 @@
|
|
|
1
|
+
export type CarouselVariant = "multi-browse" | "uncontained" | "hero" | "hero-center" | "full-screen";
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type CarouselLayout =
|
|
6
|
-
/** Best for browsing many visual items at once (photos, event feeds) */
|
|
7
|
-
'multi-browse'
|
|
8
|
-
/** For highly customized or text-heavy carousels (traditional behavior) */
|
|
9
|
-
| 'uncontained'
|
|
10
|
-
/** For spotlighting very large visual items (featured content) */
|
|
11
|
-
| 'hero'
|
|
12
|
-
/** For immersive vertical-scrolling experiences */
|
|
13
|
-
| 'full-screen';
|
|
14
|
-
/**
|
|
15
|
-
* Carousel Scrolling Behaviors
|
|
16
|
-
* @category Components
|
|
17
|
-
*/
|
|
18
|
-
export type CarouselScrollBehavior =
|
|
19
|
-
/** Standard scrolling without snapping, recommended for uncontained layouts */
|
|
20
|
-
'default'
|
|
21
|
-
/** Items snap to carousel layout, recommended for multi-browse, hero, and full-screen layouts */
|
|
22
|
-
| 'snap';
|
|
23
|
-
/**
|
|
24
|
-
* Slide data interface
|
|
25
|
-
* @category Components
|
|
3
|
+
* Content of one carousel item. Either an image with optional text and a
|
|
4
|
+
* call to action, or arbitrary content.
|
|
26
5
|
*/
|
|
27
6
|
export interface CarouselSlide {
|
|
28
|
-
|
|
29
|
-
image
|
|
30
|
-
|
|
7
|
+
image?: string;
|
|
8
|
+
/** Alternative text for the image; empty when the image is decorative */
|
|
9
|
+
alt?: string;
|
|
31
10
|
title?: string;
|
|
32
|
-
/** Optional accent color in hexadecimal or RGB format */
|
|
33
|
-
accent?: string;
|
|
34
|
-
/** Optional description text */
|
|
35
11
|
description?: string;
|
|
36
|
-
/** Optional action button text */
|
|
37
12
|
buttonText?: string;
|
|
38
|
-
/** Optional action button URL */
|
|
39
13
|
buttonUrl?: string;
|
|
40
|
-
/**
|
|
41
|
-
|
|
14
|
+
/** Custom content, replaces the image and text */
|
|
15
|
+
content?: HTMLElement | string;
|
|
42
16
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Configuration interface for the Carousel component
|
|
45
|
-
* @category Components
|
|
46
|
-
*/
|
|
47
17
|
export interface CarouselConfig {
|
|
48
|
-
/**
|
|
49
|
-
|
|
50
|
-
* @default 0
|
|
51
|
-
*/
|
|
52
|
-
initialSlide?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Whether to loop the carousel
|
|
55
|
-
* @default true
|
|
56
|
-
*/
|
|
57
|
-
loop?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Transition effect for slide changes
|
|
60
|
-
* @default 'slide'
|
|
61
|
-
*/
|
|
62
|
-
transition?: 'slide' | 'fade' | 'none';
|
|
63
|
-
/**
|
|
64
|
-
* Transition duration in milliseconds
|
|
65
|
-
* @default 300
|
|
66
|
-
*/
|
|
67
|
-
transitionDuration?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Slides configuration for the carousel
|
|
70
|
-
* @example [{ image: 'image1.jpg', title: 'Title', accent: '#E6E1E5' }]
|
|
71
|
-
*/
|
|
18
|
+
/** Layout, "multi-browse" by default */
|
|
19
|
+
variant?: CarouselVariant;
|
|
72
20
|
slides?: CarouselSlide[];
|
|
73
21
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
borderRadius?: number;
|
|
78
|
-
/**
|
|
79
|
-
* Gap between slides in pixels
|
|
80
|
-
* @default 8
|
|
22
|
+
* Width of a large item in px. Multi-browse and uncontained layouts
|
|
23
|
+
* treat it as the preferred width, hero layouts as a maximum (the
|
|
24
|
+
* container width by default).
|
|
81
25
|
*/
|
|
26
|
+
itemWidth?: number;
|
|
27
|
+
/** Space between items, 8 by default (16 for full-screen) */
|
|
82
28
|
gap?: number;
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
29
|
+
/** Space between the container edges and the items, 16 by default (0 for full-screen) */
|
|
30
|
+
padding?: number;
|
|
31
|
+
/** Corner radius of the items, 28 by default */
|
|
32
|
+
cornerRadius?: number;
|
|
33
|
+
/** Snap to items after scrolling; on by default except for uncontained layouts */
|
|
34
|
+
snap?: boolean;
|
|
35
|
+
initialSlide?: number;
|
|
36
|
+
minSmallItemWidth?: number;
|
|
37
|
+
maxSmallItemWidth?: number;
|
|
38
|
+
/** Accessible name of the carousel */
|
|
39
|
+
ariaLabel?: string;
|
|
92
40
|
prefix?: string;
|
|
93
|
-
/**
|
|
94
|
-
* Component name used in class generation
|
|
95
|
-
* @default 'carousel'
|
|
96
|
-
*/
|
|
97
41
|
componentName?: string;
|
|
98
|
-
|
|
99
|
-
* Callback for "Show all" action when present
|
|
100
|
-
*/
|
|
101
|
-
onShowAll?: () => void;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to show a "Show all" link at the end
|
|
104
|
-
* MD3 recommends adding this for accessibility on vertical scrolling pages
|
|
105
|
-
* @default true
|
|
106
|
-
*/
|
|
107
|
-
showAllLink?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* MD3 carousel layout type
|
|
110
|
-
* @default 'multi-browse'
|
|
111
|
-
*/
|
|
112
|
-
layout?: CarouselLayout;
|
|
113
|
-
/**
|
|
114
|
-
* Scrolling behavior for the carousel
|
|
115
|
-
* @default depends on layout (snap for multi-browse, hero, full-screen; default for uncontained)
|
|
116
|
-
*/
|
|
117
|
-
scrollBehavior?: CarouselScrollBehavior;
|
|
118
|
-
/**
|
|
119
|
-
* Whether to center the carousel items (applies to hero layout)
|
|
120
|
-
* @default false
|
|
121
|
-
*/
|
|
122
|
-
centered?: boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Maximum width of large items (affects how many items fit on screen)
|
|
125
|
-
* Large items should remain big enough to be easily recognizable
|
|
126
|
-
*/
|
|
127
|
-
largeItemMaxWidth?: number;
|
|
128
|
-
/**
|
|
129
|
-
* Width for small items in pixels
|
|
130
|
-
* @default 40-56dp range as per MD3 guidelines
|
|
131
|
-
*/
|
|
132
|
-
smallItemWidth?: number;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Slides API interface for carousel
|
|
136
|
-
* @category Components
|
|
137
|
-
*/
|
|
138
|
-
export interface SlidesAPI {
|
|
139
|
-
/**
|
|
140
|
-
* Adds a new slide to the carousel
|
|
141
|
-
* @param slide - CarouselSlide object with slide data
|
|
142
|
-
* @param index - Optional position to insert the slide
|
|
143
|
-
* @returns The slides API for chaining
|
|
144
|
-
*/
|
|
145
|
-
addSlide: (slide: CarouselSlide, index?: number) => SlidesAPI;
|
|
146
|
-
/**
|
|
147
|
-
* Removes a slide at the specified index
|
|
148
|
-
* @param index - Index of the slide to remove
|
|
149
|
-
* @returns The slides API for chaining
|
|
150
|
-
*/
|
|
151
|
-
removeSlide: (index: number) => SlidesAPI;
|
|
152
|
-
/**
|
|
153
|
-
* Updates an existing slide
|
|
154
|
-
* @param index - Index of the slide to update
|
|
155
|
-
* @param slide - Updated CarouselSlide object
|
|
156
|
-
* @returns The slides API for chaining
|
|
157
|
-
*/
|
|
158
|
-
updateSlide: (index: number, slide: CarouselSlide) => SlidesAPI;
|
|
159
|
-
/**
|
|
160
|
-
* Gets a slide at the specified index
|
|
161
|
-
* @param index - Index of the slide
|
|
162
|
-
* @returns CarouselSlide object or null if not found
|
|
163
|
-
*/
|
|
164
|
-
getSlide: (index: number) => CarouselSlide | null;
|
|
165
|
-
/**
|
|
166
|
-
* Gets the total number of slides
|
|
167
|
-
* @returns Number of slides
|
|
168
|
-
*/
|
|
169
|
-
getCount: () => number;
|
|
170
|
-
/**
|
|
171
|
-
* Gets all slide elements
|
|
172
|
-
* @returns Array of slide elements
|
|
173
|
-
*/
|
|
174
|
-
getElements: () => HTMLElement[];
|
|
42
|
+
class?: string;
|
|
175
43
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Carousel component interface
|
|
178
|
-
* @category Components
|
|
179
|
-
*/
|
|
180
44
|
export interface CarouselComponent {
|
|
181
|
-
/** The carousel's root DOM element */
|
|
182
45
|
element: HTMLElement;
|
|
183
|
-
/** API for managing carousel slides */
|
|
184
46
|
slides: SlidesAPI;
|
|
185
|
-
/** API for managing component lifecycle */
|
|
186
47
|
lifecycle: {
|
|
187
|
-
/** Destroys the component and cleans up resources */
|
|
188
48
|
destroy: () => void;
|
|
189
49
|
};
|
|
190
|
-
/**
|
|
191
|
-
* Gets a class name with the component's prefix
|
|
192
|
-
* @param name - Base class name
|
|
193
|
-
* @returns Prefixed class name
|
|
194
|
-
*/
|
|
195
50
|
getClass: (name: string) => string;
|
|
196
|
-
/**
|
|
197
|
-
* Goes to the next slide
|
|
198
|
-
* @returns The carousel component for chaining
|
|
199
|
-
*/
|
|
200
51
|
next: () => CarouselComponent;
|
|
201
|
-
/**
|
|
202
|
-
* Goes to the previous slide
|
|
203
|
-
* @returns The carousel component for chaining
|
|
204
|
-
*/
|
|
205
52
|
prev: () => CarouselComponent;
|
|
206
|
-
/**
|
|
207
|
-
* Goes to a specific slide
|
|
208
|
-
* @param index - Slide index
|
|
209
|
-
* @returns The carousel component for chaining
|
|
210
|
-
*/
|
|
211
53
|
goTo: (index: number) => CarouselComponent;
|
|
212
|
-
/**
|
|
213
|
-
* Gets the current slide index
|
|
214
|
-
* @returns Current slide index
|
|
215
|
-
*/
|
|
216
54
|
getCurrentSlide: () => number;
|
|
217
|
-
|
|
218
|
-
* Adds a new slide
|
|
219
|
-
* @param slide - CarouselSlide object with slide data
|
|
220
|
-
* @param index - Optional position to insert the slide
|
|
221
|
-
* @returns The carousel component for chaining
|
|
222
|
-
*/
|
|
55
|
+
getVariant: () => CarouselVariant;
|
|
223
56
|
addSlide: (slide: CarouselSlide, index?: number) => CarouselComponent;
|
|
224
|
-
/**
|
|
225
|
-
* Removes a slide
|
|
226
|
-
* @param index - Index of the slide to remove
|
|
227
|
-
* @returns The carousel component for chaining
|
|
228
|
-
*/
|
|
229
57
|
removeSlide: (index: number) => CarouselComponent;
|
|
230
|
-
/**
|
|
231
|
-
* Enables the loop mode
|
|
232
|
-
* @returns The carousel component for chaining
|
|
233
|
-
*/
|
|
234
|
-
enableLoop: () => CarouselComponent;
|
|
235
|
-
/**
|
|
236
|
-
* Disables the loop mode
|
|
237
|
-
* @returns The carousel component for chaining
|
|
238
|
-
*/
|
|
239
|
-
disableLoop: () => CarouselComponent;
|
|
240
|
-
/**
|
|
241
|
-
* Sets the carousel border radius
|
|
242
|
-
* @param radius - Border radius in pixels
|
|
243
|
-
* @returns The carousel component for chaining
|
|
244
|
-
*/
|
|
245
|
-
setBorderRadius: (radius: number) => CarouselComponent;
|
|
246
|
-
/**
|
|
247
|
-
* Sets the gap between slides
|
|
248
|
-
* @param gap - Gap size in pixels
|
|
249
|
-
* @returns The carousel component for chaining
|
|
250
|
-
*/
|
|
251
|
-
setGap: (gap: number) => CarouselComponent;
|
|
252
|
-
/**
|
|
253
|
-
* Destroys the carousel component and cleans up resources
|
|
254
|
-
*/
|
|
255
58
|
destroy: () => void;
|
|
256
|
-
/**
|
|
257
|
-
* Adds an event listener to the carousel
|
|
258
|
-
* @param event - Event name
|
|
259
|
-
* @param handler - Event handler function
|
|
260
|
-
* @returns The carousel component for chaining
|
|
261
|
-
*/
|
|
262
59
|
on: (event: string, handler: Function) => CarouselComponent;
|
|
263
|
-
/**
|
|
264
|
-
* Removes an event listener from the carousel
|
|
265
|
-
* @param event - Event name
|
|
266
|
-
* @param handler - Event handler function
|
|
267
|
-
* @returns The carousel component for chaining
|
|
268
|
-
*/
|
|
269
60
|
off: (event: string, handler: Function) => CarouselComponent;
|
|
270
|
-
/**
|
|
271
|
-
* Adds CSS classes to the carousel element
|
|
272
|
-
* @param classes - One or more class names to add
|
|
273
|
-
* @returns The carousel component for chaining
|
|
274
|
-
*/
|
|
275
61
|
addClass: (...classes: string[]) => CarouselComponent;
|
|
276
62
|
}
|
|
63
|
+
export interface SlidesAPI {
|
|
64
|
+
addSlide: (slide: CarouselSlide, index?: number) => SlidesAPI;
|
|
65
|
+
removeSlide: (index: number) => SlidesAPI;
|
|
66
|
+
updateSlide: (index: number, slide: CarouselSlide) => SlidesAPI;
|
|
67
|
+
getSlide: (index: number) => CarouselSlide | null;
|
|
68
|
+
getCount: () => number;
|
|
69
|
+
getElements: () => HTMLElement[];
|
|
70
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DialogComponent, DialogButton, DialogConfirmOptions, DialogFooterAlignment, DialogSize } from
|
|
1
|
+
import { DialogComponent, DialogButton, DialogConfirmOptions, DialogFooterAlignment, DialogSize } from "./types";
|
|
2
2
|
interface ApiOptions {
|
|
3
3
|
visibility: {
|
|
4
4
|
open: () => void;
|
|
@@ -24,6 +24,8 @@ export { default as createExtendedFab } from "./extended-fab";
|
|
|
24
24
|
export { default as createIconButton } from "./icon-button";
|
|
25
25
|
export { default as createList } from "./list";
|
|
26
26
|
export { default as createMenu } from "./menu";
|
|
27
|
+
export { default as createNavigation } from "./navigation";
|
|
28
|
+
export { default as createNavigationSystem } from "./navigation/system";
|
|
27
29
|
export { default as createProgress } from "./progress";
|
|
28
30
|
export { default as createRadios } from "./radios";
|
|
29
31
|
export { default as createSearch } from "./search";
|
|
@@ -26,7 +26,7 @@ export declare const SLIDER_SIZES: {
|
|
|
26
26
|
/** Large size - 56px track height */
|
|
27
27
|
readonly L: 56;
|
|
28
28
|
/** Extra large size - 96px track height */
|
|
29
|
-
readonly XL:
|
|
29
|
+
readonly XL: 96;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Slider component size type
|
|
@@ -40,12 +40,12 @@ export type SliderSize = keyof typeof SLIDER_SIZES | number;
|
|
|
40
40
|
export declare const SLIDER_MEASUREMENTS: {
|
|
41
41
|
/** Handle size in pixels */
|
|
42
42
|
readonly HANDLE_SIZE: 16;
|
|
43
|
-
/** Handle height for XS and S sizes in pixels */
|
|
44
|
-
readonly SMALL_HANDLE_HEIGHT:
|
|
45
|
-
/** Handle height offset for M, L, XL sizes (added to track height) */
|
|
46
|
-
readonly HANDLE_HEIGHT_OFFSET:
|
|
47
|
-
/** Minimum container height in pixels */
|
|
48
|
-
readonly MIN_HEIGHT:
|
|
43
|
+
/** Handle height for XS and S sizes in pixels (M3: 44dp) */
|
|
44
|
+
readonly SMALL_HANDLE_HEIGHT: 44;
|
|
45
|
+
/** Handle height offset for M, L, XL sizes (added to track height: 52, 68, 108dp) */
|
|
46
|
+
readonly HANDLE_HEIGHT_OFFSET: 12;
|
|
47
|
+
/** Minimum container height in pixels (M3 minimum touch target) */
|
|
48
|
+
readonly MIN_HEIGHT: 48;
|
|
49
49
|
/** Track border radius in pixels */
|
|
50
50
|
readonly TRACK_RADIUS: 3;
|
|
51
51
|
/** External track radius for XS and S sizes in pixels */
|
|
@@ -57,7 +57,7 @@ export declare const SLIDER_MEASUREMENTS: {
|
|
|
57
57
|
/** Dot size in pixels */
|
|
58
58
|
readonly DOT_SIZE: 4;
|
|
59
59
|
/** Handle gap pixels */
|
|
60
|
-
readonly HANDLE_GAP:
|
|
60
|
+
readonly HANDLE_GAP: 6;
|
|
61
61
|
/** Handle gap reduction when pressed in pixels */
|
|
62
62
|
readonly HANDLE_GAP_PRESSED_REDUCTION: 2;
|
|
63
63
|
/** Center gap pixels for centered sliders */
|
|
@@ -26,7 +26,10 @@ export interface SliderConfig extends BaseComponentConfig {
|
|
|
26
26
|
step?: number;
|
|
27
27
|
/** Whether the slider is disabled */
|
|
28
28
|
disabled?: boolean;
|
|
29
|
-
/** Color variant of the slider
|
|
29
|
+
/** Color variant of the slider *
|
|
30
|
+
* A stylesheet can override the drawn colours per slider with the custom
|
|
31
|
+
* properties --mtrl-slider-color and --mtrl-slider-on-color.
|
|
32
|
+
*/
|
|
30
33
|
color?: SliderColor;
|
|
31
34
|
/** Size variant of the slider */
|
|
32
35
|
size?: SliderSize;
|
|
@@ -4,4 +4,4 @@ import { BaseComponent, SnackbarComponent, ApiOptions } from "./types";
|
|
|
4
4
|
* @param {ApiOptions} options - API configuration
|
|
5
5
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
6
6
|
*/
|
|
7
|
-
export declare const withAPI: ({ lifecycle, queue }: ApiOptions) => (component: BaseComponent) => SnackbarComponent;
|
|
7
|
+
export declare const withAPI: ({ lifecycle, queue, queueBehavior }: ApiOptions) => (component: BaseComponent) => SnackbarComponent;
|
|
@@ -48,6 +48,7 @@ export declare const getTextConfig: (config: SnackbarConfig) => {
|
|
|
48
48
|
message: string;
|
|
49
49
|
action?: string;
|
|
50
50
|
duration?: number;
|
|
51
|
+
queueBehavior?: import("./types").SnackbarQueueBehavior;
|
|
51
52
|
onAction?: (event: import("./types").SnackbarEvent) => void;
|
|
52
53
|
onOpen?: (event: import("./types").SnackbarEvent) => void;
|
|
53
54
|
onClose?: (event: import("./types").SnackbarEvent) => void;
|
|
@@ -62,5 +63,5 @@ export declare const getTextConfig: (config: SnackbarConfig) => {
|
|
|
62
63
|
* @param {SnackbarQueue} queue - Snackbar queue manager
|
|
63
64
|
* @returns {ApiOptions} API configuration object
|
|
64
65
|
*/
|
|
65
|
-
export declare const getApiConfig: (comp: BaseComponent, queue: any) => ApiOptions;
|
|
66
|
+
export declare const getApiConfig: (comp: BaseComponent, queue: any, config?: SnackbarConfig) => ApiOptions;
|
|
66
67
|
export default defaultConfig;
|
|
@@ -30,6 +30,20 @@ export declare const SNACKBAR_STATES: {
|
|
|
30
30
|
/** Snackbar is hidden */
|
|
31
31
|
readonly HIDDEN: "hidden";
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Snackbar queue behaviors
|
|
35
|
+
*
|
|
36
|
+
* Controls how a newly shown snackbar interacts with the one currently on
|
|
37
|
+
* screen and any still waiting in the queue.
|
|
38
|
+
* @category Components
|
|
39
|
+
*/
|
|
40
|
+
export declare const SNACKBAR_QUEUE_BEHAVIORS: {
|
|
41
|
+
/** Wait in line — shown one at a time, in order (default) */
|
|
42
|
+
readonly QUEUE: "queue";
|
|
43
|
+
/** Replace — immediately dismiss the current snackbar, drop any pending
|
|
44
|
+
* ones, and show this snackbar right away (last-wins) */
|
|
45
|
+
readonly REPLACE: "replace";
|
|
46
|
+
};
|
|
33
47
|
/**
|
|
34
48
|
* Snackbar event types
|
|
35
49
|
* @category Components
|
|
@@ -55,6 +69,10 @@ export declare const SNACKBAR_DEFAULTS: {
|
|
|
55
69
|
readonly POSITION: "center";
|
|
56
70
|
/** Default display duration in milliseconds (4 seconds) */
|
|
57
71
|
readonly DURATION: 4000;
|
|
72
|
+
/** Default queue behavior */
|
|
73
|
+
readonly QUEUE_BEHAVIOR: "queue";
|
|
74
|
+
/** Delay in milliseconds between a dismissed snackbar and the next one */
|
|
75
|
+
readonly QUEUE_GAP: 200;
|
|
58
76
|
/** Default z-index for snackbars */
|
|
59
77
|
readonly Z_INDEX: 1000;
|
|
60
78
|
/** Default animation duration in milliseconds */
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { SnackbarQueue } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a queue manager for snackbars
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* Ensures only one snackbar is visible at a time. Supports two behaviors when
|
|
6
|
+
* a new snackbar is added (see {@link SnackbarQueueAddOptions}):
|
|
7
|
+
* - `'queue'` (default): the snackbar waits its turn and is shown in order.
|
|
8
|
+
* - `'replace'`: the snackbar evicts whatever is currently on screen, drops any
|
|
9
|
+
* still-pending snackbars, and shows immediately. This keeps rapid, repeated
|
|
10
|
+
* actions snappy instead of serializing a long backlog.
|
|
11
|
+
*
|
|
12
|
+
* @param {number} gap - Delay in ms between a dismissed snackbar and the next
|
|
5
13
|
* @returns {SnackbarQueue} Queue manager with add/clear methods
|
|
6
14
|
*/
|
|
7
|
-
export declare const createSnackbarQueue: () => SnackbarQueue;
|
|
15
|
+
export declare const createSnackbarQueue: (gap?: number) => SnackbarQueue;
|
|
@@ -21,6 +21,19 @@ export declare const SNACKBAR_POSITIONS: {
|
|
|
21
21
|
readonly START: "start";
|
|
22
22
|
readonly END: "end";
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Available snackbar queue behaviors
|
|
26
|
+
*/
|
|
27
|
+
export type SnackbarQueueBehavior = 'queue' | 'replace';
|
|
28
|
+
/**
|
|
29
|
+
* Snackbar queue behaviors
|
|
30
|
+
*/
|
|
31
|
+
export declare const SNACKBAR_QUEUE_BEHAVIORS: {
|
|
32
|
+
/** Shown one at a time, in order (default) */
|
|
33
|
+
readonly QUEUE: "queue";
|
|
34
|
+
/** Replace the current snackbar and drop pending ones (last-wins) */
|
|
35
|
+
readonly REPLACE: "replace";
|
|
36
|
+
};
|
|
24
37
|
/**
|
|
25
38
|
* Snackbar visibility states
|
|
26
39
|
*/
|
|
@@ -65,6 +78,14 @@ export interface SnackbarConfig {
|
|
|
65
78
|
action?: string;
|
|
66
79
|
/** Duration in milliseconds to show the snackbar (0 for indefinite) */
|
|
67
80
|
duration?: number;
|
|
81
|
+
/**
|
|
82
|
+
* How this snackbar interacts with the queue when shown.
|
|
83
|
+
* - `'queue'` (default): wait in line and show one at a time, in order.
|
|
84
|
+
* - `'replace'`: immediately dismiss the current snackbar, drop any pending
|
|
85
|
+
* ones, and show this snackbar right away. Useful for rapid, repeated
|
|
86
|
+
* actions where only the latest message matters.
|
|
87
|
+
*/
|
|
88
|
+
queueBehavior?: SnackbarQueueBehavior;
|
|
68
89
|
/** Action button callback function */
|
|
69
90
|
onAction?: (event: SnackbarEvent) => void;
|
|
70
91
|
/** Callback function when the snackbar opens */
|
|
@@ -144,20 +165,33 @@ export interface BaseComponent {
|
|
|
144
165
|
export interface SnackbarTimer {
|
|
145
166
|
start: () => void;
|
|
146
167
|
stop: () => void;
|
|
168
|
+
/** Sets the auto-dismiss duration in milliseconds */
|
|
169
|
+
setDuration: (duration: number) => void;
|
|
170
|
+
/** Gets the current auto-dismiss duration in milliseconds */
|
|
171
|
+
getDuration: () => number;
|
|
147
172
|
}
|
|
148
173
|
/**
|
|
149
174
|
* Interface for snackbars managed by the queue
|
|
150
175
|
*/
|
|
151
176
|
export interface QueuedSnackbar {
|
|
152
177
|
_show: () => void;
|
|
178
|
+
/** Visually dismisses the snackbar without advancing the queue */
|
|
179
|
+
_hide?: () => void;
|
|
153
180
|
on: (event: string, handler: () => void) => void;
|
|
154
181
|
off: (event: string, handler: () => void) => void;
|
|
155
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Options controlling how a snackbar is added to the queue
|
|
185
|
+
*/
|
|
186
|
+
export interface SnackbarQueueAddOptions {
|
|
187
|
+
/** Behavior to apply when adding this snackbar (defaults to `'queue'`) */
|
|
188
|
+
behavior?: SnackbarQueueBehavior;
|
|
189
|
+
}
|
|
156
190
|
/**
|
|
157
191
|
* Interface for the snackbar queue manager
|
|
158
192
|
*/
|
|
159
193
|
export interface SnackbarQueue {
|
|
160
|
-
add: (snackbar: QueuedSnackbar) => void;
|
|
194
|
+
add: (snackbar: QueuedSnackbar, options?: SnackbarQueueAddOptions) => void;
|
|
161
195
|
clear: () => void;
|
|
162
196
|
getLength: () => number;
|
|
163
197
|
}
|
|
@@ -169,4 +203,6 @@ export interface ApiOptions {
|
|
|
169
203
|
destroy: () => void;
|
|
170
204
|
};
|
|
171
205
|
queue: SnackbarQueue;
|
|
206
|
+
/** Queue behavior applied when the snackbar is shown */
|
|
207
|
+
queueBehavior?: SnackbarQueueBehavior;
|
|
172
208
|
}
|