mtrl 0.7.0 → 0.8.0-next.10
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 +3 -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 +2 -2
- package/dist/components/snackbar/config.d.ts +22 -6
- package/dist/components/snackbar/constants.d.ts +88 -44
- package/dist/components/snackbar/features.d.ts +16 -3
- package/dist/components/snackbar/index.d.ts +4 -2
- package/dist/components/snackbar/position.d.ts +2 -1
- package/dist/components/snackbar/queue.d.ts +10 -2
- package/dist/components/snackbar/snackbar.d.ts +9 -0
- package/dist/components/snackbar/types.d.ts +81 -44
- package/dist/index.cjs +20 -10
- package/dist/index.cjs.map +55 -39
- package/dist/index.js +20 -10
- package/dist/index.js.map +55 -39
- package/dist/package.json +2 -2
- package/dist/styles.css +2 -2
- package/package.json +8 -31
- package/src/styles/abstract/_theme.scss +4 -2
- package/src/styles/abstract/_variables.scss +60 -12
- package/src/styles/base/_tokens.scss +46 -0
- package/src/styles/components/_button-group.scss +122 -349
- package/src/styles/components/_button.scss +350 -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/components/_snackbar.scss +153 -167
- package/src/styles/main.scss +3 -10
- package/src/styles/themes/_base-theme.scss +0 -15
- 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";
|
|
@@ -33,6 +35,7 @@ export { createSegment } from "./segmented-button/segment";
|
|
|
33
35
|
export { default as createSheet } from "./sheet";
|
|
34
36
|
export { default as createSlider } from "./slider";
|
|
35
37
|
export { default as createSnackbar } from "./snackbar";
|
|
38
|
+
export { clearSnackbars } from "./snackbar";
|
|
36
39
|
export { default as createSwitch } from "./switch";
|
|
37
40
|
export { default as createTabs } from "./tabs";
|
|
38
41
|
export { createTab } from "./tabs/tab";
|
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BaseComponent, SnackbarComponent, ApiOptions } from
|
|
1
|
+
import { BaseComponent, SnackbarComponent, ApiOptions } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Enhances snackbar component with API methods
|
|
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, config }: ApiOptions) => (component: BaseComponent) => SnackbarComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SnackbarConfig, BaseComponent, ApiOptions } from
|
|
1
|
+
import { SnackbarConfig, SnackbarDuration, BaseComponent, ApiOptions, SnackbarQueue } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Default configuration for the Snackbar component
|
|
4
4
|
*/
|
|
@@ -10,7 +10,20 @@ export declare const defaultConfig: Partial<SnackbarConfig>;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const createBaseConfig: (config: SnackbarConfig) => SnackbarConfig;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Resolves a duration to milliseconds; 0 means the snackbar stays.
|
|
14
|
+
*
|
|
15
|
+
* Without a value, a snackbar with an action stays until acted on and one
|
|
16
|
+
* without goes after 4 s (Compose `SnackbarHostState.showSnackbar`, and the
|
|
17
|
+
* M3 accessibility guidance that actionable snackbars should not
|
|
18
|
+
* auto-dismiss).
|
|
19
|
+
*/
|
|
20
|
+
export declare const durationToMs: (duration: SnackbarDuration | undefined, hasAction: boolean) => number;
|
|
21
|
+
/**
|
|
22
|
+
* Generates element configuration for the Snackbar component.
|
|
23
|
+
*
|
|
24
|
+
* `role="status"` is a polite, atomic live region: the message is announced
|
|
25
|
+
* when it appears, after whatever the user is doing, and focus stays put
|
|
26
|
+
* (M3 snackbar accessibility; Compose sets `LiveRegionMode.Polite`).
|
|
14
27
|
* @param {SnackbarConfig} config - Snackbar configuration
|
|
15
28
|
* @returns {Object} Element configuration object for withElement
|
|
16
29
|
*/
|
|
@@ -43,11 +56,13 @@ export declare const getElementConfig: (config: SnackbarConfig) => {
|
|
|
43
56
|
*/
|
|
44
57
|
export declare const getTextConfig: (config: SnackbarConfig) => {
|
|
45
58
|
text: string;
|
|
46
|
-
variant?: import("./types").SnackbarVariant;
|
|
47
|
-
position?: import("./types").SnackbarPosition;
|
|
48
59
|
message: string;
|
|
49
60
|
action?: string;
|
|
50
|
-
|
|
61
|
+
dismissible?: boolean;
|
|
62
|
+
closeLabel?: string;
|
|
63
|
+
duration?: SnackbarDuration;
|
|
64
|
+
position?: import("./types").SnackbarPosition;
|
|
65
|
+
queueBehavior?: import("./types").SnackbarQueueBehavior;
|
|
51
66
|
onAction?: (event: import("./types").SnackbarEvent) => void;
|
|
52
67
|
onOpen?: (event: import("./types").SnackbarEvent) => void;
|
|
53
68
|
onClose?: (event: import("./types").SnackbarEvent) => void;
|
|
@@ -60,7 +75,8 @@ export declare const getTextConfig: (config: SnackbarConfig) => {
|
|
|
60
75
|
* Creates API configuration for the Snackbar component
|
|
61
76
|
* @param {BaseComponent} comp - Component with lifecycle feature
|
|
62
77
|
* @param {SnackbarQueue} queue - Snackbar queue manager
|
|
78
|
+
* @param {SnackbarConfig} config - The resolved configuration
|
|
63
79
|
* @returns {ApiOptions} API configuration object
|
|
64
80
|
*/
|
|
65
|
-
export declare const getApiConfig: (comp: BaseComponent, queue:
|
|
81
|
+
export declare const getApiConfig: (comp: BaseComponent, queue: SnackbarQueue, config: SnackbarConfig) => ApiOptions;
|
|
66
82
|
export default defaultConfig;
|
|
@@ -1,88 +1,132 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* @category Components
|
|
4
|
-
*/
|
|
5
|
-
export declare const SNACKBAR_VARIANTS: {
|
|
6
|
-
/** Basic snackbar with just text */
|
|
7
|
-
readonly BASIC: "basic";
|
|
8
|
-
/** Snackbar with an action button */
|
|
9
|
-
readonly ACTION: "action";
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Snackbar display positions
|
|
2
|
+
* Where the snackbar sits along the bottom edge
|
|
13
3
|
* @category Components
|
|
14
4
|
*/
|
|
15
5
|
export declare const SNACKBAR_POSITIONS: {
|
|
16
|
-
/**
|
|
6
|
+
/** Centred (default) */
|
|
17
7
|
readonly CENTER: "center";
|
|
18
|
-
/**
|
|
8
|
+
/** Against the leading edge */
|
|
19
9
|
readonly START: "start";
|
|
20
|
-
/**
|
|
10
|
+
/** Against the trailing edge */
|
|
21
11
|
readonly END: "end";
|
|
22
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Duration presets (Compose Material 3 `SnackbarDuration`)
|
|
15
|
+
* @category Components
|
|
16
|
+
*/
|
|
17
|
+
export declare const SNACKBAR_DURATIONS: {
|
|
18
|
+
/** 4 seconds, the default without an action */
|
|
19
|
+
readonly SHORT: "short";
|
|
20
|
+
/** 10 seconds */
|
|
21
|
+
readonly LONG: "long";
|
|
22
|
+
/** Stays until acted on or dismissed, the default with an action */
|
|
23
|
+
readonly INDEFINITE: "indefinite";
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Milliseconds behind the presets; 0 means no auto-dismiss
|
|
27
|
+
* @category Components
|
|
28
|
+
*/
|
|
29
|
+
export declare const SNACKBAR_DURATION_MS: {
|
|
30
|
+
readonly short: 4000;
|
|
31
|
+
readonly long: 10000;
|
|
32
|
+
readonly indefinite: 0;
|
|
33
|
+
};
|
|
23
34
|
/**
|
|
24
35
|
* Snackbar visibility states
|
|
25
36
|
* @category Components
|
|
26
37
|
*/
|
|
27
38
|
export declare const SNACKBAR_STATES: {
|
|
28
|
-
/** Snackbar is visible */
|
|
29
39
|
readonly VISIBLE: "visible";
|
|
30
|
-
/** Snackbar is hidden */
|
|
31
40
|
readonly HIDDEN: "hidden";
|
|
32
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Snackbar queue behaviors
|
|
44
|
+
*
|
|
45
|
+
* Controls how a newly shown snackbar interacts with the one currently on
|
|
46
|
+
* screen and any still waiting in the queue.
|
|
47
|
+
* @category Components
|
|
48
|
+
*/
|
|
49
|
+
export declare const SNACKBAR_QUEUE_BEHAVIORS: {
|
|
50
|
+
/** Wait in line: shown one at a time, in order (default) */
|
|
51
|
+
readonly QUEUE: "queue";
|
|
52
|
+
/** Replace: dismiss the current snackbar, drop any pending ones, and show
|
|
53
|
+
* this snackbar right away (last wins) */
|
|
54
|
+
readonly REPLACE: "replace";
|
|
55
|
+
};
|
|
33
56
|
/**
|
|
34
57
|
* Snackbar event types
|
|
35
58
|
* @category Components
|
|
36
59
|
*/
|
|
37
60
|
export declare const SNACKBAR_EVENTS: {
|
|
38
|
-
/**
|
|
61
|
+
/** The snackbar is on screen */
|
|
39
62
|
readonly OPEN: "open";
|
|
40
|
-
/**
|
|
63
|
+
/** The snackbar is leaving; the event carries the reason */
|
|
41
64
|
readonly CLOSE: "close";
|
|
42
|
-
/**
|
|
65
|
+
/** The action button was clicked */
|
|
43
66
|
readonly ACTION: "action";
|
|
44
|
-
/** Fired
|
|
67
|
+
/** Fired with `close`; the queue listens to it */
|
|
45
68
|
readonly DISMISS: "dismiss";
|
|
46
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Why a snackbar closed
|
|
72
|
+
* @category Components
|
|
73
|
+
*/
|
|
74
|
+
export declare const SNACKBAR_CLOSE_REASONS: {
|
|
75
|
+
/** The duration ran out */
|
|
76
|
+
readonly TIMEOUT: "timeout";
|
|
77
|
+
/** The action was clicked */
|
|
78
|
+
readonly ACTION: "action";
|
|
79
|
+
/** The close icon was clicked */
|
|
80
|
+
readonly CLOSE_BUTTON: "close-button";
|
|
81
|
+
/** Escape was pressed while focus was inside */
|
|
82
|
+
readonly ESCAPE: "escape";
|
|
83
|
+
/** `hide()` was called */
|
|
84
|
+
readonly API: "api";
|
|
85
|
+
/** The queue replaced or cleared it */
|
|
86
|
+
readonly QUEUE: "queue";
|
|
87
|
+
};
|
|
47
88
|
/**
|
|
48
89
|
* Default configuration values for snackbar
|
|
49
90
|
* @category Components
|
|
50
91
|
*/
|
|
51
92
|
export declare const SNACKBAR_DEFAULTS: {
|
|
52
|
-
/** Default visual variant */
|
|
53
|
-
readonly VARIANT: "basic";
|
|
54
93
|
/** Default display position */
|
|
55
94
|
readonly POSITION: "center";
|
|
56
|
-
/** Default
|
|
57
|
-
readonly
|
|
58
|
-
/**
|
|
59
|
-
readonly
|
|
60
|
-
/**
|
|
61
|
-
readonly
|
|
95
|
+
/** Default queue behavior */
|
|
96
|
+
readonly QUEUE_BEHAVIOR: "queue";
|
|
97
|
+
/** Delay in milliseconds between a dismissed snackbar and the next one */
|
|
98
|
+
readonly QUEUE_GAP: 200;
|
|
99
|
+
/** Accessible name of the close icon */
|
|
100
|
+
readonly CLOSE_LABEL: "Dismiss";
|
|
101
|
+
/** The longest of the exit transitions, after which the element is
|
|
102
|
+
* removed whether or not `transitionend` came */
|
|
103
|
+
readonly ANIMATION_DURATION: 425;
|
|
104
|
+
/** An action wider than this moves below the text
|
|
105
|
+
* (`design_snackbar_action_inline_max_width`) */
|
|
106
|
+
readonly ACTION_INLINE_MAX_WIDTH: 128;
|
|
62
107
|
};
|
|
63
108
|
/**
|
|
64
|
-
* CSS class names used by the snackbar component
|
|
109
|
+
* CSS class names used by the snackbar component, without the prefix
|
|
65
110
|
* @category Components
|
|
66
111
|
*/
|
|
67
112
|
export declare const SNACKBAR_CLASSES: {
|
|
68
|
-
/** Root element class */
|
|
69
113
|
readonly ROOT: "snackbar";
|
|
70
|
-
/** Basic variant class */
|
|
71
|
-
readonly BASIC: "snackbar--basic";
|
|
72
|
-
/** Action variant class */
|
|
73
|
-
readonly ACTION: "snackbar--action";
|
|
74
|
-
/** Center position class */
|
|
75
114
|
readonly CENTER: "snackbar--center";
|
|
76
|
-
/** Start position class */
|
|
77
115
|
readonly START: "snackbar--start";
|
|
78
|
-
/** End position class */
|
|
79
116
|
readonly END: "snackbar--end";
|
|
80
|
-
/** Visible state class */
|
|
81
117
|
readonly VISIBLE: "snackbar--visible";
|
|
82
|
-
/**
|
|
83
|
-
readonly
|
|
84
|
-
/**
|
|
85
|
-
readonly
|
|
86
|
-
/**
|
|
87
|
-
readonly
|
|
118
|
+
/** An action is present */
|
|
119
|
+
readonly WITH_ACTION: "snackbar--with-action";
|
|
120
|
+
/** A close icon is present */
|
|
121
|
+
readonly DISMISSIBLE: "snackbar--dismissible";
|
|
122
|
+
/** The action is too wide to sit beside the text */
|
|
123
|
+
readonly ACTION_BELOW: "snackbar--action-below";
|
|
124
|
+
readonly TEXT: "snackbar-text";
|
|
125
|
+
readonly ACTION: "snackbar-action";
|
|
126
|
+
readonly CLOSE: "snackbar-close";
|
|
88
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* The close icon (Material Symbols "close")
|
|
130
|
+
* @category Components
|
|
131
|
+
*/
|
|
132
|
+
export declare const SNACKBAR_CLOSE_ICON: string;
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import { BaseComponent, SnackbarConfig } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* Adds action button
|
|
3
|
+
* Adds the action: a text button, the one M3 allows, coloured inverse-primary
|
|
4
|
+
* by the stylesheet. Reusing the button gives it the state layers, the focus
|
|
5
|
+
* ring and the touch target.
|
|
4
6
|
* @param {SnackbarConfig} config - Component configuration
|
|
5
|
-
* @returns {Function} Higher-order function that adds action button
|
|
7
|
+
* @returns {Function} Higher-order function that adds the action button
|
|
6
8
|
*/
|
|
7
9
|
export declare const withActionButton: (config: SnackbarConfig) => (component: BaseComponent) => BaseComponent;
|
|
8
10
|
/**
|
|
9
|
-
* Adds
|
|
11
|
+
* Adds the optional close affordance: a standard icon button (40dp, 24dp
|
|
12
|
+
* icon; `SnackbarTokens.IconSize`), coloured inverse-on-surface by the
|
|
13
|
+
* stylesheet.
|
|
14
|
+
* @param {SnackbarConfig} config - Component configuration
|
|
15
|
+
* @returns {Function} Higher-order function that adds the close button
|
|
16
|
+
*/
|
|
17
|
+
export declare const withCloseButton: (config: SnackbarConfig) => (component: BaseComponent) => BaseComponent;
|
|
18
|
+
/**
|
|
19
|
+
* Adds the auto-dismiss timer. It emits `timeout` when the duration runs out
|
|
20
|
+
* and holds while the pointer is over the snackbar or focus is inside it:
|
|
21
|
+
* Compose extends the timeout through the accessibility manager, and pausing
|
|
22
|
+
* is the web's equivalent for someone who needs more time (WCAG 2.2.1).
|
|
10
23
|
* @param {SnackbarConfig} config - Component configuration
|
|
11
24
|
* @returns {Function} Higher-order function that adds timer features
|
|
12
25
|
*/
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export {
|
|
1
|
+
export { default } from './snackbar';
|
|
2
|
+
export { clearSnackbars } from './snackbar';
|
|
3
|
+
export type { SnackbarConfig, SnackbarComponent, SnackbarEvent, SnackbarPosition, SnackbarDuration, SnackbarCloseReason, SnackbarQueueBehavior, } from './types';
|
|
4
|
+
export { SNACKBAR_POSITIONS, SNACKBAR_DURATIONS, SNACKBAR_CLOSE_REASONS, SNACKBAR_QUEUE_BEHAVIORS, } from './constants';
|