index.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. var __rest = (this && this.__rest) || function (s, e) {
  2. var t = {};
  3. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4. t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  6. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  8. t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { getInstance } from '../common/utils';
  13. function Toast(options) {
  14. var _a;
  15. const { context, selector = '#t-toast' } = options, Options = __rest(options, ["context", "selector"]);
  16. const instance = getInstance(context, selector);
  17. if (instance) {
  18. instance.show(Object.assign(Object.assign({}, Options), { duration: (_a = Options.duration) !== null && _a !== void 0 ? _a : 2000 }));
  19. }
  20. }
  21. function showToast(options = {}) {
  22. Toast(options);
  23. }
  24. function hideToast(options = {}) {
  25. const { context, selector = '#t-toast' } = options;
  26. const instance = getInstance(context, selector);
  27. if (instance) {
  28. instance.hide();
  29. }
  30. }
  31. export { Toast as default, showToast, hideToast };