DEV: Add option to float-kit toast to force auto-close (#24022)

This commit is contained in:
Mark VanLandingham
2023-10-19 10:14:49 -05:00
committed by GitHub
parent 00aa81a271
commit cfbe16f9cc
3 changed files with 8 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ import DDefaultToast from "float-kit/components/d-default-toast";
export const TOAST = {
options: {
autoClose: true,
forceAutoClose: false,
duration: 3000,
component: DDefaultToast,
},

View File

@@ -46,6 +46,11 @@ export default class DToastInstance {
@action
cancelAutoClose() {
if (this.options.forceAutoClose) {
// Return early so that we do not cancel the autoClose timer.
return;
}
cancel(this.autoCloseHandler);
}
}

View File

@@ -14,6 +14,8 @@ export default class Toasts extends Service {
*
* @param {Object} [options] - options passed to the toast component as `@toast` argument
* @param {String} [options.duration] - The duration (ms) of the toast, will be closed after this time
* @param {Boolean} [options.autoClose=true] - When true, the toast will autoClose after the duration
* @param {Boolean} [options.forceAutoClose=false] - When true, toast will still autoClose following mouseover event
* @param {ComponentClass} [options.component] - A component to render, will use `DDefaultToast` if not provided
* @param {String} [options.class] - A class added to the d-toast element
* @param {Object} [options.data] - An object which will be passed as the `@data` argument to the component