@fabwcie/free-drawing / components/Toast
components/Toast
Classes
Toast
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:16
Short message shown at the top of the drawer (stacked with other toasts), with an icon of its type. Announced by screen readers once shown (live region kept in the page, urgent for problems: drawer._announce), created for one message by drawer.toast.
Extends
Constructors
Constructor
new Toast(
drawer,message,type?,timeout?,showIcon?):Toast
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:36
Create the toast (hidden until show) in the stack of toasts of the drawer, created on first toast
Parameters
drawer
Drawer showing the toast
message
string
Text of the toast (not parsed as HTML)
type?
AvailableTypes = 'neutral'
Kind of message: gives style, icon and role (alert for warning, error, danger)
timeout?
number = 5000
Time in ms before hiding the toast once shown (0: stays until hidden)
showIcon?
boolean = true
Icon of the type before the message (neutral has none)
Returns
Overrides
Properties
_events
_events:
Record<string,Listener[]> ={}
Defined in: packages/free-drawing/src/utils/MicroEvent.ts:44
Listeners by event name, in order of registration
Inherited from
$toastContainer
$toastContainer:
HTMLDivElement
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:18
Element of the toast: icon and message
timeout
timeout:
number=5000
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:20
Time in ms before hiding the toast once shown (0: stays until hidden)
Methods
destroy()
destroy():
void
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:106
Removes the toast from the page at once
Returns
void
hide()
hide():
void
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:97
Hides the toast with an animation, then removes it from the page
Returns
void
off()
off<
K>(events?,fct?):void
Defined in: packages/free-drawing/src/utils/MicroEvent.ts:71
Remove a listener of an event: without listener all listeners of this event, without arguments all listeners
Type Parameters
K
K extends EventName<ToastEventMap>
name of the event
Parameters
events?
K
event name (several separated by spaces in JavaScript)
fct?
EmitterListener<ToastEventMap, K>
listener given to on
Returns
void
Inherited from
on()
on<
K>(events,fct):void
Defined in: packages/free-drawing/src/utils/MicroEvent.ts:57
Listen to an event
Type Parameters
K
K extends EventName<ToastEventMap>
name of the event
Parameters
events
K
event name (several separated by spaces in JavaScript)
fct
EmitterListener<ToastEventMap, K>
listener, called on each trigger with the arguments of the event
Returns
void
Inherited from
show()
show():
void
Defined in: packages/free-drawing/src/components/Toast/Toast.ts:81
Shows the toast and reads its message, hidden after timeout (then toast.hide is triggered)
Returns
void
trigger()
trigger<
K>(events, ...args):void
Defined in: packages/free-drawing/src/utils/MicroEvent.ts:100
Call listeners of an event, in order of registration. A listener may add or remove listeners: the ones added are called from the next trigger, the ones removed (not called yet) are not called, the others are all called.
Type Parameters
K
K extends EventName<ToastEventMap>
name of the event
Parameters
events
K
event name (several separated by spaces in JavaScript)
args
...EventArgs<ToastEventMap, K>
arguments given to listeners, as typed by the event
Returns
void