UNPKG

@freshworks/crayons

Version:
82 lines (78 loc) 2.2 kB
import { attachShadow, h, Host, proxyCustomElement } from '@stencil/core/internal/client'; import { d as createToastStack, e as createToastNotification } from './crayons.js'; import { d as defineCustomElement$2, a as defineCustomElement$4 } from './icon.js'; import { d as defineCustomElement$3 } from './spinner.js'; let Toast = class extends HTMLElement { constructor() { super(); this.__registerHost(); attachShadow(this); /** * position of the toast notification in screen */ this.position = 'top-center'; /** * Time duration of the toast visibility */ this.timeout = 4000; /** * Type of the toast - success,failure, warning, inprogress */ this.type = 'warning'; /** * The Content of the action link */ this.actionLinkText = ''; /** * won't close automatically */ this.sticky = false; } componentWillLoad() { this.toastContainer = createToastStack(this); } async trigger(opts) { createToastNotification(opts, this.toastContainer, this); } render() { return (h(Host, null, h("slot", null))); } }; Toast = /*@__PURE__*/ proxyCustomElement(Toast, [1, "fw-toast", { "position": [1], "timeout": [2], "type": [1], "content": [1], "actionLinkText": [1, "action-link-text"], "sticky": [4], "pauseOnHover": [4, "pause-on-hover"], "trigger": [64] }]); function defineCustomElement$1() { const components = ["fw-toast", "fw-icon", "fw-spinner", "fw-toast-message"]; components.forEach(tagName => { switch (tagName) { case "fw-toast": if (!customElements.get(tagName)) { customElements.define(tagName, Toast); } break; case "fw-icon": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "fw-spinner": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "fw-toast-message": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; } }); } const FwToast = Toast; const defineCustomElement = defineCustomElement$1; export { FwToast, defineCustomElement };