Commit b4625f1 1 parent 99057ca commit b4625f1 Copy full SHA for b4625f1
File tree 4 files changed +9
-19
lines changed
4 files changed +9
-19
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,8 @@ function createSnackbarElement(options: SnackbarOptions): SnackbarElement {
46
46
* @param options - Options for configuring the snackbar.
47
47
* @param closeSnackbar - Function to close the snackbar.
48
48
*/
49
- function handleActionButtonClick ( options : SnackbarOptions , closeSnackbar : ( ) => Promise < void > ) : void {
50
- const actionButtonClickHandler = ( event : { id : string } ) => {
51
- if ( event . id !== options . action ! . id ) return ;
49
+ function handleActionButtonClick ( closeSnackbar : ( ) => Promise < void > ) : void {
50
+ const actionButtonClickHandler = ( ) => {
52
51
logger . logOther ?.( 'Snackbar action button clicked.' , event ) ;
53
52
54
53
return closeSnackbar ( ) ;
@@ -84,7 +83,7 @@ async function showSnackbar(options: SnackbarOptions): Promise<void> {
84
83
} ;
85
84
86
85
if ( options . action != null ) {
87
- handleActionButtonClick ( options , closeSnackbar ) ;
86
+ handleActionButtonClick ( closeSnackbar ) ;
88
87
}
89
88
90
89
// Close the last snackbar if it exists
Original file line number Diff line number Diff line change 1
- import { AlwatrSignal } from '@alwatr/flux' ;
1
+ import { AlwatrSignal , AlwatrTrigger } from '@alwatr/flux' ;
2
2
3
3
import type { SnackbarOptions } from './type.js' ;
4
4
5
5
/**
6
- * Signal triggered when the snackbar action button is clicked.
7
- *
8
- * This signal is used to notify listeners that the action button
9
- * on the snackbar component has been clicked. It can be used to
10
- * perform any necessary actions in response to the button click.
11
- *
12
- * @example
13
- * snackbarActionButtonClickedSignal.addListener(() => {
14
- * console.log('Snackbar action button was clicked!');
15
- * });
6
+ * Signal triggered when the snackbar action button is clicked to close snackbar.
16
7
*/
17
- export const snackbarActionButtonClickedSignal = /* @__PURE__ */ new AlwatrSignal < { id : string } > ( {
8
+ export const snackbarActionButtonClickedSignal = /* @__PURE__ */ new AlwatrTrigger ( {
18
9
name : 'snackbar-action-button-clicked' ,
19
10
} ) ;
20
11
Original file line number Diff line number Diff line change @@ -4,14 +4,14 @@ import type {Duration} from '@alwatr/parse-duration';
4
4
* @property content - Content to be displayed in the snackbar.
5
5
* @property [action] - The action button configuration.
6
6
* @property action.label - The label for the action button.
7
- * @property action.handler - The handler function for the action button.
7
+ * @property action.signalId - The signal ID to be emitted when the action button is clicked .
8
8
* @property duration - Duration for which the snackbar is displayed. `infinite` for infinite duration.
9
9
* @property addCloseButton - Whether to add a close button to the snackbar.
10
10
*/
11
11
export type SnackbarOptions = {
12
12
content : string ;
13
13
action ?: {
14
- id : string ;
14
+ signalId : string ;
15
15
label : string ;
16
16
} ;
17
17
duration ?: Duration | 'infinite' ;
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ import {packageTracer} from '@alwatr/package-tracer';
3
3
__dev_mode__: packageTracer . add ( __package_name__ , __package_version__ ) ;
4
4
5
5
export * from './lib/element.js' ;
6
- export * from './lib/handler .js' ;
6
+ export { snackbarSignal } from './lib/signal .js' ;
You can’t perform that action at this time.
0 commit comments