Skip to content

Instantly share code, notes, and snippets.

View lucaszmoraes's full-sized avatar

Lucas Moraes lucaszmoraes

View GitHub Profile
(function(e,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("@hotwired/stimulus"),require("stimulus-use")):typeof define=="function"&&define.amd?define(["@hotwired/stimulus","stimulus-use"],i):(e=typeof globalThis<"u"?globalThis:e||self,e.StimulusNotification=i(e.Stimulus,e.useTransition))})(this,function(e,i){"use strict";class t extends e.Controller{initialize(){this.hide=this.hide.bind(this)}connect(){i.useTransition(this),this.hiddenValue===!1&&this.show()}show(){this.enter(),this.timeout=setTimeout(this.hide,this.delayValue)}async hide(){this.timeout&&clearTimeout(this.timeout),await this.leave(),this.element.remove()}}return t.values={delay:{type:Number,default:3e3},hidden:{type:Boolean,default:!1}},t});