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
|
@@ -7,7 +7,8 @@ interface PositionConfig {
|
|
|
7
7
|
position?: SnackbarPosition;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* Adds position handling to snackbar
|
|
10
|
+
* Adds position handling to snackbar. The position is a class; the
|
|
11
|
+
* stylesheet does the rest, so nothing here touches inline styles.
|
|
11
12
|
* @param {PositionConfig} config - Position configuration
|
|
12
13
|
* @returns {Function} Higher-order function that adds position features
|
|
13
14
|
*/
|
|
@@ -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;
|
|
@@ -5,4 +5,13 @@ import { SnackbarConfig, SnackbarComponent } from './types';
|
|
|
5
5
|
* @returns {SnackbarComponent} Snackbar component instance
|
|
6
6
|
*/
|
|
7
7
|
declare const createSnackbar: (config: SnackbarConfig) => SnackbarComponent;
|
|
8
|
+
/**
|
|
9
|
+
* Dismisses the snackbar on screen and drops the ones still waiting.
|
|
10
|
+
*
|
|
11
|
+
* Messages belong to the thing that raised them: a drawer that closes, an
|
|
12
|
+
* account that signs out. Without this the queue outlives them, so a message
|
|
13
|
+
* about a list nobody is looking at any more stays on screen, and, because the
|
|
14
|
+
* queue shows one at a time, the next message waits behind it.
|
|
15
|
+
*/
|
|
16
|
+
export declare const clearSnackbars: () => void;
|
|
8
17
|
export default createSnackbar;
|
|
@@ -1,41 +1,33 @@
|
|
|
1
|
+
import type { ButtonComponent } from '../button/types';
|
|
2
|
+
import type { IconButtonComponent } from '../icon-button/types';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Where the snackbar sits along the bottom edge
|
|
3
5
|
*/
|
|
4
|
-
export type
|
|
6
|
+
export type SnackbarPosition = 'center' | 'start' | 'end';
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Duration presets: 4 s, 10 s, or until dismissed
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
9
|
-
readonly BASIC: "basic";
|
|
10
|
-
readonly ACTION: "action";
|
|
11
|
-
};
|
|
10
|
+
export type SnackbarDurationPreset = 'short' | 'long' | 'indefinite';
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* A preset or a number of milliseconds (0 for indefinite)
|
|
14
13
|
*/
|
|
15
|
-
export type
|
|
14
|
+
export type SnackbarDuration = SnackbarDurationPreset | number;
|
|
16
15
|
/**
|
|
17
|
-
*
|
|
16
|
+
* Available snackbar queue behaviors
|
|
18
17
|
*/
|
|
19
|
-
export
|
|
20
|
-
readonly CENTER: "center";
|
|
21
|
-
readonly START: "start";
|
|
22
|
-
readonly END: "end";
|
|
23
|
-
};
|
|
18
|
+
export type SnackbarQueueBehavior = 'queue' | 'replace';
|
|
24
19
|
/**
|
|
25
20
|
* Snackbar visibility states
|
|
26
21
|
*/
|
|
27
22
|
export type SnackbarState = 'visible' | 'hidden';
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
24
|
+
* Why a snackbar closed
|
|
30
25
|
*/
|
|
31
|
-
export
|
|
32
|
-
readonly VISIBLE: "visible";
|
|
33
|
-
readonly HIDDEN: "hidden";
|
|
34
|
-
};
|
|
26
|
+
export type SnackbarCloseReason = 'timeout' | 'action' | 'close-button' | 'escape' | 'api' | 'queue';
|
|
35
27
|
/**
|
|
36
28
|
* Available snackbar event types
|
|
37
29
|
*/
|
|
38
|
-
export type SnackbarEventType = 'open' | 'close' | 'action';
|
|
30
|
+
export type SnackbarEventType = 'open' | 'close' | 'action' | 'dismiss';
|
|
39
31
|
/**
|
|
40
32
|
* Snackbar event data
|
|
41
33
|
* @interface SnackbarEvent
|
|
@@ -43,28 +35,41 @@ export type SnackbarEventType = 'open' | 'close' | 'action';
|
|
|
43
35
|
export interface SnackbarEvent {
|
|
44
36
|
/** The snackbar component that triggered the event */
|
|
45
37
|
snackbar: SnackbarComponent;
|
|
46
|
-
/**
|
|
38
|
+
/** Why the snackbar closed (`close` and `dismiss` events) */
|
|
39
|
+
reason?: SnackbarCloseReason;
|
|
40
|
+
/** Original DOM event if there was one */
|
|
47
41
|
originalEvent: Event | null;
|
|
48
|
-
/** Function to prevent default behavior */
|
|
49
|
-
preventDefault: () => void;
|
|
50
|
-
/** Whether default behavior was prevented */
|
|
51
|
-
defaultPrevented: boolean;
|
|
52
42
|
}
|
|
53
43
|
/**
|
|
54
44
|
* Configuration options for the snackbar component
|
|
55
45
|
* @interface SnackbarConfig
|
|
56
46
|
*/
|
|
57
47
|
export interface SnackbarConfig {
|
|
58
|
-
/**
|
|
59
|
-
variant?: SnackbarVariant;
|
|
60
|
-
/** Position of the snackbar on screen */
|
|
61
|
-
position?: SnackbarPosition;
|
|
62
|
-
/** Text message to display */
|
|
48
|
+
/** Text message to display; up to two lines */
|
|
63
49
|
message: string;
|
|
64
|
-
/**
|
|
50
|
+
/** Label of the single text-button action, if any */
|
|
65
51
|
action?: string;
|
|
66
|
-
/**
|
|
67
|
-
|
|
52
|
+
/** Adds a close icon button */
|
|
53
|
+
dismissible?: boolean;
|
|
54
|
+
/** Accessible name of the close icon (default "Dismiss") */
|
|
55
|
+
closeLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* How long the snackbar stays: `'short'` (4 s), `'long'` (10 s),
|
|
58
|
+
* `'indefinite'`, or milliseconds (0 for indefinite). Defaults to
|
|
59
|
+
* `'short'` without an action and `'indefinite'` with one: an actionable
|
|
60
|
+
* snackbar should not go away on its own.
|
|
61
|
+
*/
|
|
62
|
+
duration?: SnackbarDuration;
|
|
63
|
+
/** Position of the snackbar along the bottom edge */
|
|
64
|
+
position?: SnackbarPosition;
|
|
65
|
+
/**
|
|
66
|
+
* How this snackbar interacts with the queue when shown.
|
|
67
|
+
* - `'queue'` (default): wait in line and show one at a time, in order.
|
|
68
|
+
* - `'replace'`: immediately dismiss the current snackbar, drop any pending
|
|
69
|
+
* ones, and show this snackbar right away. Useful for rapid, repeated
|
|
70
|
+
* actions where only the latest message matters.
|
|
71
|
+
*/
|
|
72
|
+
queueBehavior?: SnackbarQueueBehavior;
|
|
68
73
|
/** Action button callback function */
|
|
69
74
|
onAction?: (event: SnackbarEvent) => void;
|
|
70
75
|
/** Callback function when the snackbar opens */
|
|
@@ -93,13 +98,10 @@ export interface SnackbarComponent {
|
|
|
93
98
|
state: SnackbarState;
|
|
94
99
|
/** The action button element (if present) */
|
|
95
100
|
actionButton?: HTMLElement;
|
|
101
|
+
/** The close icon button element (if present) */
|
|
102
|
+
closeButton?: HTMLElement;
|
|
96
103
|
/** Timer for auto-dismissal */
|
|
97
104
|
timer?: SnackbarTimer;
|
|
98
|
-
/** Position management functions */
|
|
99
|
-
position?: {
|
|
100
|
-
getPosition: () => SnackbarPosition;
|
|
101
|
-
setPosition: (position: SnackbarPosition) => BaseComponent;
|
|
102
|
-
};
|
|
103
105
|
/** Displays the snackbar */
|
|
104
106
|
show: () => SnackbarComponent;
|
|
105
107
|
/** Hides the snackbar */
|
|
@@ -112,9 +114,9 @@ export interface SnackbarComponent {
|
|
|
112
114
|
setAction: (text: string) => SnackbarComponent;
|
|
113
115
|
/** Gets the action button text */
|
|
114
116
|
getAction: () => string;
|
|
115
|
-
/** Sets the display duration */
|
|
116
|
-
setDuration: (duration:
|
|
117
|
-
/** Gets the display duration */
|
|
117
|
+
/** Sets the display duration: a preset or milliseconds (0 for indefinite) */
|
|
118
|
+
setDuration: (duration: SnackbarDuration) => SnackbarComponent;
|
|
119
|
+
/** Gets the display duration in milliseconds (0 for indefinite) */
|
|
118
120
|
getDuration: () => number;
|
|
119
121
|
/** Sets the snackbar position */
|
|
120
122
|
setPosition: (position: SnackbarPosition) => SnackbarComponent;
|
|
@@ -128,36 +130,69 @@ export interface SnackbarComponent {
|
|
|
128
130
|
destroy: () => void;
|
|
129
131
|
}
|
|
130
132
|
/**
|
|
131
|
-
*
|
|
133
|
+
* The component as it passes through the enhancers
|
|
132
134
|
*/
|
|
133
135
|
export interface BaseComponent {
|
|
134
136
|
element: HTMLElement;
|
|
135
137
|
emit?: (event: string, data?: any) => void;
|
|
138
|
+
on?: (event: string, handler: (...args: any[]) => void) => any;
|
|
139
|
+
off?: (event: string, handler: (...args: any[]) => void) => any;
|
|
140
|
+
getClass?: (name: string) => string;
|
|
136
141
|
lifecycle?: {
|
|
137
142
|
destroy?: () => void;
|
|
138
143
|
};
|
|
144
|
+
text?: {
|
|
145
|
+
setText: (text: string) => any;
|
|
146
|
+
getText: () => string;
|
|
147
|
+
};
|
|
148
|
+
position?: {
|
|
149
|
+
getPosition: () => SnackbarPosition;
|
|
150
|
+
setPosition: (position: SnackbarPosition) => any;
|
|
151
|
+
};
|
|
152
|
+
action?: ButtonComponent;
|
|
153
|
+
actionButton?: HTMLElement;
|
|
154
|
+
close?: IconButtonComponent;
|
|
155
|
+
closeButton?: HTMLElement;
|
|
156
|
+
timer?: SnackbarTimer;
|
|
139
157
|
[key: string]: any;
|
|
140
158
|
}
|
|
141
159
|
/**
|
|
142
160
|
* Timer interface for snackbar auto-dismissal
|
|
143
161
|
*/
|
|
144
162
|
export interface SnackbarTimer {
|
|
163
|
+
/** Starts the countdown from the full duration */
|
|
145
164
|
start: () => void;
|
|
165
|
+
/** Cancels the countdown */
|
|
146
166
|
stop: () => void;
|
|
167
|
+
/** Sets the auto-dismiss duration in milliseconds (0 for none) */
|
|
168
|
+
setDuration: (duration: number) => void;
|
|
169
|
+
/** Gets the current auto-dismiss duration in milliseconds */
|
|
170
|
+
getDuration: () => number;
|
|
147
171
|
}
|
|
148
172
|
/**
|
|
149
173
|
* Interface for snackbars managed by the queue
|
|
150
174
|
*/
|
|
151
175
|
export interface QueuedSnackbar {
|
|
152
176
|
_show: () => void;
|
|
177
|
+
/** Visually dismisses the snackbar without advancing the queue */
|
|
178
|
+
_hide?: () => void;
|
|
179
|
+
/** The snackbar's own element, so the queue can tell whether it is still on screen */
|
|
180
|
+
element?: HTMLElement;
|
|
153
181
|
on: (event: string, handler: () => void) => void;
|
|
154
182
|
off: (event: string, handler: () => void) => void;
|
|
155
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Options controlling how a snackbar is added to the queue
|
|
186
|
+
*/
|
|
187
|
+
export interface SnackbarQueueAddOptions {
|
|
188
|
+
/** Behavior to apply when adding this snackbar (defaults to `'queue'`) */
|
|
189
|
+
behavior?: SnackbarQueueBehavior;
|
|
190
|
+
}
|
|
156
191
|
/**
|
|
157
192
|
* Interface for the snackbar queue manager
|
|
158
193
|
*/
|
|
159
194
|
export interface SnackbarQueue {
|
|
160
|
-
add: (snackbar: QueuedSnackbar) => void;
|
|
195
|
+
add: (snackbar: QueuedSnackbar, options?: SnackbarQueueAddOptions) => void;
|
|
161
196
|
clear: () => void;
|
|
162
197
|
getLength: () => number;
|
|
163
198
|
}
|
|
@@ -169,4 +204,6 @@ export interface ApiOptions {
|
|
|
169
204
|
destroy: () => void;
|
|
170
205
|
};
|
|
171
206
|
queue: SnackbarQueue;
|
|
207
|
+
/** The resolved configuration */
|
|
208
|
+
config: SnackbarConfig;
|
|
172
209
|
}
|