Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

solid-toast

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solid-toast - npm Package Compare versions

Comparing version 0.1.7-alpha.1 to 0.1.7-alpha.2

625

dist/cjs/index.js

@@ -1,625 +0,2 @@

"use strict";
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
Object.defineProperty(exports, "__esModule", {
value: !0
});
var t = require("solid-js"),
e = require("solid-js/store"),
o = require("solid-js/web"),
s = require("goober");
var r = function r(t, e) {
return function (t) {
return "function" == typeof t;
}(t) ? t(e) : t;
};
var i;
exports.ActionType = void 0, (i = exports.ActionType || (exports.ActionType = {}))[i.ADD_TOAST = 0] = "ADD_TOAST", i[i.UPDATE_TOAST = 1] = "UPDATE_TOAST", i[i.UPSERT_TOAST = 2] = "UPSERT_TOAST", i[i.DISMISS_TOAST = 3] = "DISMISS_TOAST", i[i.REMOVE_TOAST = 4] = "REMOVE_TOAST", i[i.START_PAUSE = 5] = "START_PAUSE", i[i.END_PAUSE = 6] = "END_PAUSE";
var _e$createStore = e.createStore({
toasts: [],
pausedAt: void 0
}),
_e$createStore2 = _slicedToArray(_e$createStore, 2),
n = _e$createStore2[0],
a = _e$createStore2[1],
c = new Map(),
l = function l(t, e) {
if (c.has(t)) return;
var o = setTimeout(function () {
c["delete"](t), p({
type: exports.ActionType.REMOVE_TOAST,
toastId: t
});
}, e);
c.set(t, o);
},
p = function p(t) {
switch (t.type) {
case exports.ActionType.ADD_TOAST:
a("toasts", function (e) {
var o = e;
return [t.toast].concat(_toConsumableArray(o));
});
break;
case exports.ActionType.DISMISS_TOAST:
var _o = t.toastId,
_s2 = n.toasts;
if (_o) {
var _t = _s2.find(function (t) {
return t.id === _o;
});
_t && l(_o, _t.unmountDelay);
} else _s2.forEach(function (t) {
l(t.id, t.unmountDelay);
});
a("toasts", function (t) {
return t.id === _o;
}, e.produce(function (t) {
return t.visible = !1;
}));
break;
case exports.ActionType.REMOVE_TOAST:
if (!t.toastId) {
a("toasts", []);
break;
}
a("toasts", function (e) {
return e.filter(function (e) {
return e.id !== t.toastId;
});
});
break;
case exports.ActionType.UPDATE_TOAST:
t.toast.id && function (t) {
var e = c.get(t);
c["delete"](t), e && clearTimeout(e);
}(t.toast.id), a("toasts", function (e) {
return e.id === t.toast.id;
}, function (e) {
return _objectSpread(_objectSpread({}, e), t.toast);
});
break;
case exports.ActionType.UPSERT_TOAST:
n.toasts.find(function (e) {
return e.id === t.toast.id;
}) ? p({
type: exports.ActionType.UPDATE_TOAST,
toast: t.toast
}) : p({
type: exports.ActionType.ADD_TOAST,
toast: t.toast
});
break;
case exports.ActionType.START_PAUSE:
a("pausedAt", Date.now());
break;
case exports.ActionType.END_PAUSE:
var _r = t.time - (n.pausedAt || 0);
a(e.produce(function (t) {
t.pausedAt = void 0, t.toasts.forEach(function (t) {
t.pauseDuration += _r;
});
}));
}
},
d = {
blank: 4e3,
error: 4e3,
success: 2e3,
loading: 1 / 0,
custom: 4e3
},
y = {
id: "",
icon: "",
unmountDelay: 500,
duration: 3e3,
ariaProps: {
role: "status",
"aria-live": "polite"
},
className: "",
style: {},
position: "top-right",
iconTheme: {}
},
u = {
position: "top-right",
toastOptions: y,
gutter: 8,
containerStyle: {},
containerClassName: ""
},
m = {
position: "fixed",
"z-index": 9999,
top: "16px",
bottom: "16px",
left: "16px",
right: "16px",
"pointer-events": "none"
},
f = function () {
var t = 0;
return function () {
return String(++t);
};
}(),
v = function v(t, e) {
return (t.position || e).includes("top") ? 1 : -1;
},
T = {
display: "flex",
"align-items": "center",
background: "white",
color: "#363636",
"box-shadow": "0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)",
"max-width": "350px",
"pointer-events": "auto",
padding: "8px 10px",
"border-radius": "4px",
"line-height": "1.3",
"will-change": "transform"
},
g = {
display: "flex",
"align-items": "center",
flex: "1 1 auto",
margin: "4px 10px",
"white-space": "pre-line"
},
A = {
"flex-shrink": 0,
"min-width": "20px",
"min-height": "20px",
display: "flex",
"align-items": "center",
"justify-content": "center",
"text-align": "center"
},
_ = s.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["from{transform:scale(0)rotate(45deg);opacity:0;}to{transform:scale(1)rotate(45deg);opacity:1;}"]))),
h = s.keyframes(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["75%,100%{transform: scale(2.25);opacity:0;}"]))),
S = s.keyframes(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["to{stroke-dashoffset: 0;}"]))),
x = s.keyframes(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["0%{transform:translate3d(0,0,0);opacity:1;}100%{transform:translate3d(0,7px,0)scale(1);opacity:1;}"]))),
$ = s.keyframes(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["from{transform: rotate(0deg);}to{transform: rotate(360deg);}"]))),
_t$createSignal = t.createSignal(u),
_t$createSignal2 = _slicedToArray(_t$createSignal, 2),
b = _t$createSignal2[0],
P = _t$createSignal2[1],
E = function E(t) {
return function (e) {
var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var s = n.toasts.find(function (t) {
return t.id === o.id;
}),
r = function (t) {
var _b$toastOptions, _b$toastOptions2, _b$toastOptions3;
var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "blank";
var o = arguments.length > 2 ? arguments[2] : undefined;
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, y), b().toastOptions), o), {}, {
type: e,
message: t,
pauseDuration: 0,
createdAt: Date.now(),
visible: !0,
id: o.id || f(),
style: _objectSpread(_objectSpread(_objectSpread({}, y.style), (_b$toastOptions = b().toastOptions) === null || _b$toastOptions === void 0 ? void 0 : _b$toastOptions.style), o.style),
duration: o.duration || ((_b$toastOptions2 = b().toastOptions) === null || _b$toastOptions2 === void 0 ? void 0 : _b$toastOptions2.duration) || d[e],
position: o.position || ((_b$toastOptions3 = b().toastOptions) === null || _b$toastOptions3 === void 0 ? void 0 : _b$toastOptions3.position) || b().position || y.position
});
}(e, t, _objectSpread(_objectSpread({}, s), {}, {
duration: void 0
}, o));
return p({
type: exports.ActionType.UPSERT_TOAST,
toast: r
}), r.id;
};
},
k = function k(t, e) {
return E("blank")(t, e);
};
k.error = E("error"), k.success = E("success"), k.loading = E("loading"), k.custom = E("custom"), k.dismiss = function (t) {
p({
type: exports.ActionType.DISMISS_TOAST,
toastId: t
});
}, k.promise = function (t, e, o) {
var s = k.loading(e.loading, _objectSpread({}, o));
return t.then(function (t) {
return k.success(r(e.success, t), _objectSpread({
id: s
}, o)), t;
})["catch"](function (t) {
k.error(r(e.error, t), _objectSpread({
id: s
}, o));
}), t;
}, k.remove = function (t) {
p({
type: exports.ActionType.REMOVE_TOAST,
toastId: t
});
};
var w = o.template("<div></div>", 2),
O = o.template("<div></div>", 2),
D = o.template("<div><div></div></div>", 4),
C = function C(e) {
var _t$createSignal3 = t.createSignal(""),
_t$createSignal4 = _slicedToArray(_t$createSignal3, 2),
i = _t$createSignal4[0],
n = _t$createSignal4[1];
return t.createEffect(function () {
var t;
e.toast.visible ? n("".concat(s.keyframes((t = v(e.toast, e.position), "\n0% {transform: translate3d(0,".concat(-200 * t, "%,0) scale(.6); opacity:.5;}\n100% {transform: translate3d(0,0,0) scale(1); opacity:1;}\n"))), " 0.35s cubic-bezier(.21,1.02,.73,1) forwards")) : n("".concat(s.keyframes(function (t) {
return "\n0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}\n100% {transform: translate3d(0,".concat(-150 * t, "%,-1px) scale(.4); opacity:0;}\n");
}(v(e.toast, e.position))), " 0.4s forwards cubic-bezier(.06,.71,.55,1)"));
}), function () {
var s = D.cloneNode(!0),
n = s.firstChild;
return o.insert(s, o.createComponent(t.Switch, {
get children() {
return [o.createComponent(t.Match, {
get when() {
return e.toast.icon;
},
get children() {
var t = O.cloneNode(!0);
return o.insert(t, function () {
return e.toast.icon;
}), o.effect(function (e) {
return o.style(t, A, e);
}), t;
}
}), o.createComponent(t.Match, {
get when() {
return "loading" === e.toast.type;
},
get children() {
var t = O.cloneNode(!0);
return o.insert(t, o.createComponent(B, o.mergeProps(function () {
return e.toast.iconTheme;
}))), o.effect(function (e) {
return o.style(t, A, e);
}), t;
}
}), o.createComponent(t.Match, {
get when() {
return "success" === e.toast.type;
},
get children() {
var t = O.cloneNode(!0);
return o.insert(t, o.createComponent(U, o.mergeProps(function () {
return e.toast.iconTheme;
}))), o.effect(function (e) {
return o.style(t, A, e);
}), t;
}
}), o.createComponent(t.Match, {
get when() {
return "error" === e.toast.type;
},
get children() {
var t = O.cloneNode(!0);
return o.insert(t, o.createComponent(z, o.mergeProps(function () {
return e.toast.iconTheme;
}))), o.effect(function (e) {
return o.style(t, A, e);
}), t;
}
})];
}
}), n), o.spread(n, function () {
return e.toast.ariaProps;
}, !1, !0), o.insert(n, function () {
return r(e.toast.message, e.toast);
}), o.effect(function (t) {
var r = e.toast.className,
a = _objectSpread(_objectSpread({}, T), {}, {
animation: i()
}, e.toast.style),
c = g;
return r !== t._v$ && o.className(s, t._v$ = r), t._v$2 = o.style(s, a, t._v$2), t._v$3 = o.style(n, c, t._v$3), t;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0
}), s;
}();
},
N = o.template("<div></div>", 2),
M = s.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["z-index: 9999;> * { pointer-events: auto;}"]))),
I = function I(e) {
var s = function s() {
var t = e.toast.position || y.position,
o = function (t, e) {
var o = n.toasts,
s = b().gutter || u.gutter || 8,
r = o.filter(function (t) {
return (t.position || e) === e && t.height;
}),
i = r.findIndex(function (e) {
return e.id === t.id;
}),
a = r.filter(function (t, e) {
return e < i && t.visible;
}).length;
return r.slice(0, a).reduce(function (t, e) {
return t + s + (e.height || 0);
}, 0);
}(e.toast, t),
s = function (t, e) {
var o = t.includes("top");
return _objectSpread(_objectSpread({
left: 0,
right: 0,
display: "flex",
position: "absolute",
transition: "all 230ms cubic-bezier(.21,1.02,.73,1)",
transform: "translateY(".concat(e * (o ? 1 : -1), "px)")
}, o ? {
top: 0
} : {
bottom: 0
}), t.includes("center") ? {
"justify-content": "center"
} : t.includes("right") ? {
"justify-content": "flex-end"
} : {});
}(t, o);
return s;
},
_t$createSignal5 = t.createSignal(s()),
_t$createSignal6 = _slicedToArray(_t$createSignal5, 2),
i = _t$createSignal6[0],
a = _t$createSignal6[1];
var c;
return t.createEffect(function () {
var t = s();
a(t);
}), t.onMount(function () {
c && function (t, e) {
var o = t.getBoundingClientRect();
o.height !== e.height && p({
type: exports.ActionType.UPDATE_TOAST,
toast: {
id: e.id,
height: o.height
}
});
}(c, e.toast);
}), function () {
var t = N.cloneNode(!0);
t.addEventListener("mouseleave", function () {
return p({
type: exports.ActionType.END_PAUSE,
time: Date.now()
});
}), t.addEventListener("mouseenter", function () {
return p({
type: exports.ActionType.START_PAUSE,
time: Date.now()
});
});
return "function" == typeof c ? c(t) : c = t, o.insert(t, function () {
var t = o.memo(function () {
return "custom" === e.toast.type;
}, !0);
return function () {
return t() ? r(e.toast.message, e.toast) : o.createComponent(C, {
get toast() {
return e.toast;
},
get position() {
return e.toast.position || y.position;
}
});
};
}()), o.effect(function (s) {
var r = i(),
n = e.toast.visible ? M : "";
return s._v$ = o.style(t, r, s._v$), n !== s._v$2 && o.className(t, s._v$2 = n), s;
}, {
_v$: void 0,
_v$2: void 0
}), t;
}();
},
F = o.template('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7"></path></svg>', 8),
U = function U(t) {
var e = "".concat(_, " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),
s = "".concat(h, " 1s cubic-bezier(0, 0, 0.2, 1) forwards"),
r = "".concat(S, " 0.2s ease-out forwards");
return function () {
var i = F.cloneNode(!0),
n = i.firstChild,
a = n.nextSibling,
c = a.nextSibling;
return i.style.setProperty("overflow", "visible"), n.style.setProperty("animation", e), n.style.setProperty("transform-origin", "50% 50%"), n.style.setProperty("animation-delay", "100ms"), n.style.setProperty("opacity", "0"), a.style.setProperty("animation", s), a.style.setProperty("transform-origin", "50% 50%"), a.style.setProperty("animation-delay", "250ms"), c.style.setProperty("animation", r), c.style.setProperty("stroke-dasharray", "22"), c.style.setProperty("stroke-dashoffset", "22"), c.style.setProperty("animation-delay", "250ms"), o.effect(function (e) {
var s = t.primary || "#34C759",
r = t.primary || "#34C759",
i = t.secondary || "#FCFCFC";
return s !== e._v$ && o.setAttribute(n, "fill", e._v$ = s), r !== e._v$2 && o.setAttribute(a, "fill", e._v$2 = r), i !== e._v$3 && o.setAttribute(c, "stroke", e._v$3 = i), e;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0
}), i;
}();
},
R = o.template('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" d="M16,7l0,9"></path><circle cx="16" cy="16" r="2.5"></circle></svg>', 10),
z = function z(t) {
var e = "".concat(_, " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),
s = "".concat(h, " 1s cubic-bezier(0, 0, 0.2, 1) forwards"),
r = "".concat(S, " 0.1s ease-in forwards"),
i = "".concat(x, " 0.2s ease-out forwards");
return function () {
var n = R.cloneNode(!0),
a = n.firstChild,
c = a.nextSibling,
l = c.nextSibling,
p = l.nextSibling;
return n.style.setProperty("overflow", "visible"), a.style.setProperty("animation", e), a.style.setProperty("transform-origin", "50% 50%"), a.style.setProperty("animation-delay", "100ms"), a.style.setProperty("opacity", "0"), c.style.setProperty("animation", s), c.style.setProperty("transform-origin", "50% 50%"), c.style.setProperty("animation-delay", "320ms"), l.style.setProperty("animation", r), l.style.setProperty("stroke-dasharray", "9"), l.style.setProperty("stroke-dashoffset", "9"), l.style.setProperty("animation-delay", "200ms"), p.style.setProperty("animation", i), p.style.setProperty("animation-delay", "320ms"), p.style.setProperty("opacity", "0"), o.effect(function (e) {
var s = t.primary || "#FF3B30",
r = t.primary || "#FF3B30",
i = t.secondary || "#FFFFFF",
n = t.secondary || "#FFFFFF";
return s !== e._v$ && o.setAttribute(a, "fill", e._v$ = s), r !== e._v$2 && o.setAttribute(c, "fill", e._v$2 = r), i !== e._v$3 && o.setAttribute(l, "stroke", e._v$3 = i), n !== e._v$4 && o.setAttribute(p, "fill", e._v$4 = n), e;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0,
_v$4: void 0
}), n;
}();
},
j = o.template('<svg viewBox="0 0 32 32"><path fill="none" stroke-width="4" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z"></path><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2"></path></svg>', 6),
B = function B(t) {
var e = "".concat($, " 0.75s linear infinite");
return function () {
var s = j.cloneNode(!0),
r = s.firstChild,
i = r.nextSibling;
return s.style.setProperty("overflow", "visible"), i.style.setProperty("animation", e), i.style.setProperty("transform-origin", "50% 50%"), o.effect(function (e) {
var s = t.primary || "#E5E7EB",
n = t.secondary || "#4b5563";
return s !== e._v$ && o.setAttribute(r, "stroke", e._v$ = s), n !== e._v$2 && o.setAttribute(i, "stroke", e._v$2 = n), e;
}, {
_v$: void 0,
_v$2: void 0
}), s;
}();
};
var V = k;
exports.Toaster = function (e) {
return t.createEffect(function () {
(function (t) {
P(function (e) {
var _t$containerClassName, _t$containerStyle, _t$gutter, _t$position;
return {
containerClassName: (_t$containerClassName = t.containerClassName) !== null && _t$containerClassName !== void 0 ? _t$containerClassName : e.containerClassName,
containerStyle: (_t$containerStyle = t.containerStyle) !== null && _t$containerStyle !== void 0 ? _t$containerStyle : e.containerStyle,
gutter: (_t$gutter = t.gutter) !== null && _t$gutter !== void 0 ? _t$gutter : e.gutter,
position: (_t$position = t.position) !== null && _t$position !== void 0 ? _t$position : e.position,
toastOptions: _objectSpread({}, t.toastOptions)
};
});
})(e);
}), t.createEffect(function () {
var e = function () {
var t = n.pausedAt,
e = n.toasts;
if (t) return;
var o = Date.now(),
s = e.map(function (t) {
if (t.duration === 1 / 0) return;
var e = (t.duration || 0) + t.pauseDuration - (o - t.createdAt);
if (!(e <= 0)) return setTimeout(function () {
p({
type: exports.ActionType.DISMISS_TOAST,
toastId: t.id
});
}, e);
t.visible && p({
type: exports.ActionType.DISMISS_TOAST,
toastId: t.id
});
});
return s;
}();
t.onCleanup(function () {
e && e.forEach(function (t) {
return t && clearTimeout(t);
});
});
}), function () {
var s = w.cloneNode(!0);
return o.insert(s, o.createComponent(t.For, {
get each() {
return n.toasts;
},
children: function children(t) {
return o.createComponent(I, {
toast: t
});
}
})), o.effect(function (t) {
var r = _objectSpread(_objectSpread({}, m), e.containerStyle),
i = e.containerClassName;
return t._v$ = o.style(s, r, t._v$), i !== t._v$2 && o.className(s, t._v$2 = i), t;
}, {
_v$: void 0,
_v$2: void 0
}), s;
}();
}, exports["default"] = V, exports.resolveValue = r, exports.toast = k;
"use strict";var _templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6;function _taggedTemplateLiteral(t,e){return e=e||t.slice(0),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function ownKeys(e,t){var r,o=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)),o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(r="Object"===r&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o,n,i=[],a=!0,s=!1;try{for(r=r.call(t);!(a=(o=r.next()).done)&&(i.push(o.value),!e||i.length!==e);a=!0);}catch(t){s=!0,n=t}finally{try{a||null==r.return||r.return()}finally{if(s)throw n}}return i}}function _arrayWithHoles(t){if(Array.isArray(t))return t}Object.defineProperty(exports,"__esModule",{value:!0});var i,t=require("solid-js"),e=require("solid-js/store"),o=require("solid-js/web"),s=require("goober"),r=function(t,e){return"function"==typeof t?t(e):t},_e$createStore=(exports.ActionType=void 0,(i=exports.ActionType||(exports.ActionType={}))[i.ADD_TOAST=0]="ADD_TOAST",i[i.UPDATE_TOAST=1]="UPDATE_TOAST",i[i.UPSERT_TOAST=2]="UPSERT_TOAST",i[i.DISMISS_TOAST=3]="DISMISS_TOAST",i[i.REMOVE_TOAST=4]="REMOVE_TOAST",i[i.START_PAUSE=5]="START_PAUSE",i[i.END_PAUSE=6]="END_PAUSE",e.createStore({toasts:[],pausedAt:void 0})),_e$createStore2=_slicedToArray(_e$createStore,2),n=_e$createStore2[0],a=_e$createStore2[1],c=new Map,l=function(t,e){c.has(t)||(e=setTimeout(function(){c.delete(t),p({type:exports.ActionType.REMOVE_TOAST,toastId:t})},e),c.set(t,e))},p=function t(r){switch(r.type){case exports.ActionType.ADD_TOAST:a("toasts",function(t){return[r.toast].concat(_toConsumableArray(t))});break;case exports.ActionType.DISMISS_TOAST:var o=r.toastId,i=n.toasts;o?(p=i.find(function(t){return t.id===o}))&&l(o,p.unmountDelay):i.forEach(function(t){l(t.id,t.unmountDelay)}),a("toasts",function(t){return t.id===o},e.produce(function(t){return t.visible=!1}));break;case exports.ActionType.REMOVE_TOAST:if(!r.toastId){a("toasts",[]);break}a("toasts",function(t){return t.filter(function(t){return t.id!==r.toastId})});break;case exports.ActionType.UPDATE_TOAST:r.toast.id&&(p=r.toast.id,i=c.get(p),c.delete(p),i&&clearTimeout(i)),a("toasts",function(t){return t.id===r.toast.id},function(t){return _objectSpread(_objectSpread({},t),r.toast)});break;case exports.ActionType.UPSERT_TOAST:n.toasts.find(function(t){return t.id===r.toast.id})?t({type:exports.ActionType.UPDATE_TOAST,toast:r.toast}):t({type:exports.ActionType.ADD_TOAST,toast:r.toast});break;case exports.ActionType.START_PAUSE:a("pausedAt",Date.now());break;case exports.ActionType.END_PAUSE:var s=r.time-(n.pausedAt||0);a(e.produce(function(t){t.pausedAt=void 0,t.toasts.forEach(function(t){t.pauseDuration+=s})}))}var p},d={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},y={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},u={position:"top-right",toastOptions:y,gutter:8,containerStyle:{},containerClassName:""},m={position:"fixed","z-index":9999,top:"16px",bottom:"16px",left:"16px",right:"16px","pointer-events":"none"},f=function(){var t=0;return function(){return String(++t)}}(),v=function(t,e){return(t.position||e).includes("top")?1:-1},T={display:"flex","align-items":"center",background:"white",color:"#363636","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},g={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},A={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},_=s.keyframes(_templateObject=_templateObject||_taggedTemplateLiteral(["from{transform:scale(0)rotate(45deg);opacity:0;}to{transform:scale(1)rotate(45deg);opacity:1;}"])),h=s.keyframes(_templateObject2=_templateObject2||_taggedTemplateLiteral(["75%,100%{transform: scale(2.25);opacity:0;}"])),S=s.keyframes(_templateObject3=_templateObject3||_taggedTemplateLiteral(["to{stroke-dashoffset: 0;}"])),x=s.keyframes(_templateObject4=_templateObject4||_taggedTemplateLiteral(["0%{transform:translate3d(0,0,0);opacity:1;}100%{transform:translate3d(0,7px,0)scale(1);opacity:1;}"])),$=s.keyframes(_templateObject5=_templateObject5||_taggedTemplateLiteral(["from{transform: rotate(0deg);}to{transform: rotate(360deg);}"])),_t$createSignal=t.createSignal(u),_t$createSignal2=_slicedToArray(_t$createSignal,2),b=_t$createSignal2[0],P=_t$createSignal2[1],E=function(o){return function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=n.toasts.find(function(t){return t.id===e.id}),t=function(t,e,r){e=1<arguments.length&&void 0!==e?e:"blank",r=2<arguments.length?r:void 0;return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},y),b().toastOptions),r),{},{type:e,message:t,pauseDuration:0,createdAt:Date.now(),visible:!0,id:r.id||f(),style:_objectSpread(_objectSpread(_objectSpread({},y.style),null==(t=b().toastOptions)?void 0:t.style),r.style),duration:r.duration||(null==(t=b().toastOptions)?void 0:t.duration)||d[e],position:r.position||(null==(t=b().toastOptions)?void 0:t.position)||b().position||y.position})}(t,o,_objectSpread(_objectSpread({},r),{},{duration:void 0},e));return p({type:exports.ActionType.UPSERT_TOAST,toast:t}),t.id}},k=function(t,e){return E("blank")(t,e)},w=(k.error=E("error"),k.success=E("success"),k.loading=E("loading"),k.custom=E("custom"),k.dismiss=function(t){p({type:exports.ActionType.DISMISS_TOAST,toastId:t})},k.promise=function(t,e,o){var n=k.loading(e.loading,_objectSpread({},o));return t.then(function(t){return k.success(r(e.success,t),_objectSpread({id:n},o)),t}).catch(function(t){k.error(r(e.error,t),_objectSpread({id:n},o))}),t},k.remove=function(t){p({type:exports.ActionType.REMOVE_TOAST,toastId:t})},o.template("<div></div>",2)),O=o.template("<div></div>",2),D=o.template("<div><div></div></div>",4),C=function(i){var a,c,e=_slicedToArray(t.createSignal(""),2),l=e[0],n=e[1];return t.createEffect(function(){var t;i.toast.visible?n("".concat(s.keyframes((t=v(i.toast,i.position),"\n0% {transform: translate3d(0,".concat(-200*t,"%,0) scale(.6); opacity:.5;}\n100% {transform: translate3d(0,0,0) scale(1); opacity:1;}\n")))," 0.35s cubic-bezier(.21,1.02,.73,1) forwards")):n("".concat(s.keyframes("\n0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}\n100% {transform: translate3d(0,".concat(-150*v(i.toast,i.position),"%,-1px) scale(.4); opacity:0;}\n"))," 0.4s forwards cubic-bezier(.06,.71,.55,1)"))}),a=D.cloneNode(!0),c=a.firstChild,o.insert(a,o.createComponent(t.Switch,{get children(){return[o.createComponent(t.Match,{get when(){return i.toast.icon},get children(){var e=O.cloneNode(!0);return o.insert(e,function(){return i.toast.icon}),o.effect(function(t){return o.style(e,A,t)}),e}}),o.createComponent(t.Match,{get when(){return"loading"===i.toast.type},get children(){var e=O.cloneNode(!0);return o.insert(e,o.createComponent(B,o.mergeProps(function(){return i.toast.iconTheme}))),o.effect(function(t){return o.style(e,A,t)}),e}}),o.createComponent(t.Match,{get when(){return"success"===i.toast.type},get children(){var e=O.cloneNode(!0);return o.insert(e,o.createComponent(U,o.mergeProps(function(){return i.toast.iconTheme}))),o.effect(function(t){return o.style(e,A,t)}),e}}),o.createComponent(t.Match,{get when(){return"error"===i.toast.type},get children(){var e=O.cloneNode(!0);return o.insert(e,o.createComponent(z,o.mergeProps(function(){return i.toast.iconTheme}))),o.effect(function(t){return o.style(e,A,t)}),e}})]}}),c),o.spread(c,function(){return i.toast.ariaProps},!1,!0),o.insert(c,function(){return r(i.toast.message,i.toast)}),o.effect(function(t){var e=i.toast.className,r=_objectSpread(_objectSpread({},T),{},{animation:l()},i.toast.style),n=g;return e!==t._v$&&o.className(a,t._v$=e),t._v$2=o.style(a,r,t._v$2),t._v$3=o.style(c,n,t._v$3),t},{_v$:void 0,_v$2:void 0,_v$3:void 0}),a},N=o.template("<div></div>",2),M=s.css(_templateObject6=_templateObject6||_taggedTemplateLiteral(["z-index: 9999;> * { pointer-events: auto;}"])),I=function(c){function e(){var e,r,o,i,t,a,s=c.toast.position||y.position;return e=c.toast,r=s,a=n.toasts,o=b().gutter||u.gutter||8,a=a.filter(function(t){return(t.position||r)===r&&t.height}),i=a.findIndex(function(t){return t.id===e.id}),t=a.filter(function(t,e){return e<i&&t.visible}).length,t=a=a.slice(0,t).reduce(function(t,e){return t+o+(e.height||0)},0),s=(a=s).includes("top"),_objectSpread(_objectSpread({left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:"translateY(".concat(t*(s?1:-1),"px)")},s?{top:0}:{bottom:0}),a.includes("center")?{"justify-content":"center"}:a.includes("right")?{"justify-content":"flex-end"}:{})}var i,a,s,l=_slicedToArray(t.createSignal(e()),2),d=l[0],f=l[1];return t.createEffect(function(){var t=e();f(t)}),t.onMount(function(){var t,e;i&&(t=i,e=c.toast,(t=t.getBoundingClientRect()).height!==e.height&&p({type:exports.ActionType.UPDATE_TOAST,toast:{id:e.id,height:t.height}}))}),(s=N.cloneNode(!0)).addEventListener("mouseleave",function(){return p({type:exports.ActionType.END_PAUSE,time:Date.now()})}),s.addEventListener("mouseenter",function(){return p({type:exports.ActionType.START_PAUSE,time:Date.now()})}),"function"==typeof i?i(s):i=s,o.insert(s,(a=o.memo(function(){return"custom"===c.toast.type},!0),function(){return a()?r(c.toast.message,c.toast):o.createComponent(C,{get toast(){return c.toast},get position(){return c.toast.position||y.position}})})),o.effect(function(t){var e=d(),r=c.toast.visible?M:"";return t._v$=o.style(s,e,t._v$),r!==t._v$2&&o.className(s,t._v$2=r),t},{_v$:void 0,_v$2:void 0}),s},F=o.template('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7"></path></svg>',8),U=function(i){var t,a,s,c,e="".concat(_," 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),r="".concat(h," 1s cubic-bezier(0, 0, 0.2, 1) forwards"),n="".concat(S," 0.2s ease-out forwards");return t=F.cloneNode(!0),a=t.firstChild,s=a.nextSibling,c=s.nextSibling,t.style.setProperty("overflow","visible"),a.style.setProperty("animation",e),a.style.setProperty("transform-origin","50% 50%"),a.style.setProperty("animation-delay","100ms"),a.style.setProperty("opacity","0"),s.style.setProperty("animation",r),s.style.setProperty("transform-origin","50% 50%"),s.style.setProperty("animation-delay","250ms"),c.style.setProperty("animation",n),c.style.setProperty("stroke-dasharray","22"),c.style.setProperty("stroke-dashoffset","22"),c.style.setProperty("animation-delay","250ms"),o.effect(function(t){var e=i.primary||"#34C759",r=i.primary||"#34C759",n=i.secondary||"#FCFCFC";return e!==t._v$&&o.setAttribute(a,"fill",t._v$=e),r!==t._v$2&&o.setAttribute(s,"fill",t._v$2=r),n!==t._v$3&&o.setAttribute(c,"stroke",t._v$3=n),t},{_v$:void 0,_v$2:void 0,_v$3:void 0}),t},R=o.template('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" d="M16,7l0,9"></path><circle cx="16" cy="16" r="2.5"></circle></svg>',10),z=function(a){var t,s,c,l,p,e="".concat(_," 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),r="".concat(h," 1s cubic-bezier(0, 0, 0.2, 1) forwards"),n="".concat(S," 0.1s ease-in forwards"),i="".concat(x," 0.2s ease-out forwards");return t=R.cloneNode(!0),s=t.firstChild,c=s.nextSibling,l=c.nextSibling,p=l.nextSibling,t.style.setProperty("overflow","visible"),s.style.setProperty("animation",e),s.style.setProperty("transform-origin","50% 50%"),s.style.setProperty("animation-delay","100ms"),s.style.setProperty("opacity","0"),c.style.setProperty("animation",r),c.style.setProperty("transform-origin","50% 50%"),c.style.setProperty("animation-delay","320ms"),l.style.setProperty("animation",n),l.style.setProperty("stroke-dasharray","9"),l.style.setProperty("stroke-dashoffset","9"),l.style.setProperty("animation-delay","200ms"),p.style.setProperty("animation",i),p.style.setProperty("animation-delay","320ms"),p.style.setProperty("opacity","0"),o.effect(function(t){var e=a.primary||"#FF3B30",r=a.primary||"#FF3B30",n=a.secondary||"#FFFFFF",i=a.secondary||"#FFFFFF";return e!==t._v$&&o.setAttribute(s,"fill",t._v$=e),r!==t._v$2&&o.setAttribute(c,"fill",t._v$2=r),n!==t._v$3&&o.setAttribute(l,"stroke",t._v$3=n),i!==t._v$4&&o.setAttribute(p,"fill",t._v$4=i),t},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),t},j=o.template('<svg viewBox="0 0 32 32"><path fill="none" stroke-width="4" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z"></path><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2"></path></svg>',6),B=function(n){var t,i,a,e="".concat($," 0.75s linear infinite");return t=j.cloneNode(!0),i=t.firstChild,a=i.nextSibling,t.style.setProperty("overflow","visible"),a.style.setProperty("animation",e),a.style.setProperty("transform-origin","50% 50%"),o.effect(function(t){var e=n.primary||"#E5E7EB",r=n.secondary||"#4b5563";return e!==t._v$&&o.setAttribute(i,"stroke",t._v$=e),r!==t._v$2&&o.setAttribute(a,"stroke",t._v$2=r),t},{_v$:void 0,_v$2:void 0}),t},V=k;exports.Toaster=function(i){return t.createEffect(function(){var r;r=i,P(function(t){var e;return{containerClassName:null!=(e=r.containerClassName)?e:t.containerClassName,containerStyle:null!=(e=r.containerStyle)?e:t.containerStyle,gutter:null!=(e=r.gutter)?e:t.gutter,position:null!=(e=r.position)?e:t.position,toastOptions:_objectSpread({},r.toastOptions)}})}),t.createEffect(function(){var e=function(){var r,t=n.pausedAt,e=n.toasts;if(!t)return r=Date.now(),e.map(function(t){var e;if(t.duration!==1/0)return e=(t.duration||0)+t.pauseDuration-(r-t.createdAt),e<=0?void(t.visible&&p({type:exports.ActionType.DISMISS_TOAST,toastId:t.id})):setTimeout(function(){p({type:exports.ActionType.DISMISS_TOAST,toastId:t.id})},e)})}();t.onCleanup(function(){e&&e.forEach(function(t){return t&&clearTimeout(t)})})}),a=w.cloneNode(!0),o.insert(a,o.createComponent(t.For,{get each(){return n.toasts},children:function(t){return o.createComponent(I,{toast:t})}})),o.effect(function(t){var e=_objectSpread(_objectSpread({},m),i.containerStyle),r=i.containerClassName;return t._v$=o.style(a,e,t._v$),r!==t._v$2&&o.className(a,t._v$2=r),t},{_v$:void 0,_v$2:void 0}),a;var a},exports.default=V,exports.resolveValue=r,exports.toast=k;
//# sourceMappingURL=index.js.map

@@ -1,623 +0,2 @@

var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { createSignal as t, createEffect as e, onCleanup as o, For as s, Switch as r, Match as i, onMount as n } from "solid-js";
import { createStore as a, produce as c } from "solid-js/store";
import { insert as l, createComponent as d, effect as p, style as y, className as u, template as v, mergeProps as m, spread as f, memo as _, setAttribute as g } from "solid-js/web";
import { keyframes as T, css as h } from "goober";
var S = function S(t, e) {
return function (t) {
return "function" == typeof t;
}(t) ? t(e) : t;
};
var $;
!function (t) {
t[t.ADD_TOAST = 0] = "ADD_TOAST", t[t.UPDATE_TOAST = 1] = "UPDATE_TOAST", t[t.UPSERT_TOAST = 2] = "UPSERT_TOAST", t[t.DISMISS_TOAST = 3] = "DISMISS_TOAST", t[t.REMOVE_TOAST = 4] = "REMOVE_TOAST", t[t.START_PAUSE = 5] = "START_PAUSE", t[t.END_PAUSE = 6] = "END_PAUSE";
}($ || ($ = {}));
var _a = a({
toasts: [],
pausedAt: void 0
}),
_a2 = _slicedToArray(_a, 2),
A = _a2[0],
b = _a2[1],
x = new Map(),
P = function P(t, e) {
if (x.has(t)) return;
var o = setTimeout(function () {
x["delete"](t), E({
type: $.REMOVE_TOAST,
toastId: t
});
}, e);
x.set(t, o);
},
E = function E(t) {
switch (t.type) {
case $.ADD_TOAST:
b("toasts", function (e) {
var o = e;
return [t.toast].concat(_toConsumableArray(o));
});
break;
case $.DISMISS_TOAST:
var _e2 = t.toastId,
_o = A.toasts;
if (_e2) {
var _t3 = _o.find(function (t) {
return t.id === _e2;
});
_t3 && P(_e2, _t3.unmountDelay);
} else _o.forEach(function (t) {
P(t.id, t.unmountDelay);
});
b("toasts", function (t) {
return t.id === _e2;
}, c(function (t) {
return t.visible = !1;
}));
break;
case $.REMOVE_TOAST:
if (!t.toastId) {
b("toasts", []);
break;
}
b("toasts", function (e) {
return e.filter(function (e) {
return e.id !== t.toastId;
});
});
break;
case $.UPDATE_TOAST:
t.toast.id && function (t) {
var e = x.get(t);
x["delete"](t), e && clearTimeout(e);
}(t.toast.id), b("toasts", function (e) {
return e.id === t.toast.id;
}, function (e) {
return _objectSpread(_objectSpread({}, e), t.toast);
});
break;
case $.UPSERT_TOAST:
A.toasts.find(function (e) {
return e.id === t.toast.id;
}) ? E({
type: $.UPDATE_TOAST,
toast: t.toast
}) : E({
type: $.ADD_TOAST,
toast: t.toast
});
break;
case $.START_PAUSE:
b("pausedAt", Date.now());
break;
case $.END_PAUSE:
var _s2 = t.time - (A.pausedAt || 0);
b(c(function (t) {
t.pausedAt = void 0, t.toasts.forEach(function (t) {
t.pauseDuration += _s2;
});
}));
}
},
w = {
blank: 4e3,
error: 4e3,
success: 2e3,
loading: 1 / 0,
custom: 4e3
},
O = {
id: "",
icon: "",
unmountDelay: 500,
duration: 3e3,
ariaProps: {
role: "status",
"aria-live": "polite"
},
className: "",
style: {},
position: "top-right",
iconTheme: {}
},
D = {
position: "top-right",
toastOptions: O,
gutter: 8,
containerStyle: {},
containerClassName: ""
},
k = {
position: "fixed",
"z-index": 9999,
top: "16px",
bottom: "16px",
left: "16px",
right: "16px",
"pointer-events": "none"
},
I = function () {
var t = 0;
return function () {
return String(++t);
};
}(),
N = function N(t, e) {
return (t.position || e).includes("top") ? 1 : -1;
},
F = {
display: "flex",
"align-items": "center",
background: "white",
color: "#363636",
"box-shadow": "0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)",
"max-width": "350px",
"pointer-events": "auto",
padding: "8px 10px",
"border-radius": "4px",
"line-height": "1.3",
"will-change": "transform"
},
U = {
display: "flex",
"align-items": "center",
flex: "1 1 auto",
margin: "4px 10px",
"white-space": "pre-line"
},
M = {
"flex-shrink": 0,
"min-width": "20px",
"min-height": "20px",
display: "flex",
"align-items": "center",
"justify-content": "center",
"text-align": "center"
},
C = T(_templateObject || (_templateObject = _taggedTemplateLiteral(["from{transform:scale(0)rotate(45deg);opacity:0;}to{transform:scale(1)rotate(45deg);opacity:1;}"]))),
R = T(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["75%,100%{transform: scale(2.25);opacity:0;}"]))),
z = T(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["to{stroke-dashoffset: 0;}"]))),
B = T(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["0%{transform:translate3d(0,0,0);opacity:1;}100%{transform:translate3d(0,7px,0)scale(1);opacity:1;}"]))),
j = T(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["from{transform: rotate(0deg);}to{transform: rotate(360deg);}"]))),
_t = t(D),
_t2 = _slicedToArray(_t, 2),
V = _t2[0],
L = _t2[1],
Y = function Y(t) {
return function (e) {
var o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var s = A.toasts.find(function (t) {
return t.id === o.id;
}),
r = function (t) {
var _V$toastOptions, _V$toastOptions2, _V$toastOptions3;
var e = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "blank";
var o = arguments.length > 2 ? arguments[2] : undefined;
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, O), V().toastOptions), o), {}, {
type: e,
message: t,
pauseDuration: 0,
createdAt: Date.now(),
visible: !0,
id: o.id || I(),
style: _objectSpread(_objectSpread(_objectSpread({}, O.style), (_V$toastOptions = V().toastOptions) === null || _V$toastOptions === void 0 ? void 0 : _V$toastOptions.style), o.style),
duration: o.duration || ((_V$toastOptions2 = V().toastOptions) === null || _V$toastOptions2 === void 0 ? void 0 : _V$toastOptions2.duration) || w[e],
position: o.position || ((_V$toastOptions3 = V().toastOptions) === null || _V$toastOptions3 === void 0 ? void 0 : _V$toastOptions3.position) || V().position || O.position
});
}(e, t, _objectSpread(_objectSpread({}, s), {}, {
duration: void 0
}, o));
return E({
type: $.UPSERT_TOAST,
toast: r
}), r.id;
};
},
q = function q(t, e) {
return Y("blank")(t, e);
};
q.error = Y("error"), q.success = Y("success"), q.loading = Y("loading"), q.custom = Y("custom"), q.dismiss = function (t) {
E({
type: $.DISMISS_TOAST,
toastId: t
});
}, q.promise = function (t, e, o) {
var s = q.loading(e.loading, _objectSpread({}, o));
return t.then(function (t) {
return q.success(S(e.success, t), _objectSpread({
id: s
}, o)), t;
})["catch"](function (t) {
q.error(S(e.error, t), _objectSpread({
id: s
}, o));
}), t;
}, q.remove = function (t) {
E({
type: $.REMOVE_TOAST,
toastId: t
});
};
var G = v("<div></div>", 2),
H = function H(t) {
return e(function () {
(function (t) {
L(function (e) {
var _t$containerClassName, _t$containerStyle, _t$gutter, _t$position;
return {
containerClassName: (_t$containerClassName = t.containerClassName) !== null && _t$containerClassName !== void 0 ? _t$containerClassName : e.containerClassName,
containerStyle: (_t$containerStyle = t.containerStyle) !== null && _t$containerStyle !== void 0 ? _t$containerStyle : e.containerStyle,
gutter: (_t$gutter = t.gutter) !== null && _t$gutter !== void 0 ? _t$gutter : e.gutter,
position: (_t$position = t.position) !== null && _t$position !== void 0 ? _t$position : e.position,
toastOptions: _objectSpread({}, t.toastOptions)
};
});
})(t);
}), e(function () {
var t = function () {
var t = A.pausedAt,
e = A.toasts;
if (t) return;
var o = Date.now(),
s = e.map(function (t) {
if (t.duration === 1 / 0) return;
var e = (t.duration || 0) + t.pauseDuration - (o - t.createdAt);
if (!(e <= 0)) return setTimeout(function () {
E({
type: $.DISMISS_TOAST,
toastId: t.id
});
}, e);
t.visible && E({
type: $.DISMISS_TOAST,
toastId: t.id
});
});
return s;
}();
o(function () {
t && t.forEach(function (t) {
return t && clearTimeout(t);
});
});
}), function () {
var e = G.cloneNode(!0);
return l(e, d(s, {
get each() {
return A.toasts;
},
children: function children(t) {
return d(Z, {
toast: t
});
}
})), p(function (o) {
var s = _objectSpread(_objectSpread({}, k), t.containerStyle),
r = t.containerClassName;
return o._v$ = y(e, s, o._v$), r !== o._v$2 && u(e, o._v$2 = r), o;
}, {
_v$: void 0,
_v$2: void 0
}), e;
}();
},
J = v("<div></div>", 2),
K = v("<div><div></div></div>", 4),
Q = function Q(o) {
var _t4 = t(""),
_t5 = _slicedToArray(_t4, 2),
s = _t5[0],
n = _t5[1];
return e(function () {
var t;
o.toast.visible ? n("".concat(T((t = N(o.toast, o.position), "\n0% {transform: translate3d(0,".concat(-200 * t, "%,0) scale(.6); opacity:.5;}\n100% {transform: translate3d(0,0,0) scale(1); opacity:1;}\n"))), " 0.35s cubic-bezier(.21,1.02,.73,1) forwards")) : n("".concat(T(function (t) {
return "\n0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}\n100% {transform: translate3d(0,".concat(-150 * t, "%,-1px) scale(.4); opacity:0;}\n");
}(N(o.toast, o.position))), " 0.4s forwards cubic-bezier(.06,.71,.55,1)"));
}), function () {
var t = K.cloneNode(!0),
e = t.firstChild;
return l(t, d(r, {
get children() {
return [d(i, {
get when() {
return o.toast.icon;
},
get children() {
var t = J.cloneNode(!0);
return l(t, function () {
return o.toast.icon;
}), p(function (e) {
return y(t, M, e);
}), t;
}
}), d(i, {
get when() {
return "loading" === o.toast.type;
},
get children() {
var t = J.cloneNode(!0);
return l(t, d(it, m(function () {
return o.toast.iconTheme;
}))), p(function (e) {
return y(t, M, e);
}), t;
}
}), d(i, {
get when() {
return "success" === o.toast.type;
},
get children() {
var t = J.cloneNode(!0);
return l(t, d(et, m(function () {
return o.toast.iconTheme;
}))), p(function (e) {
return y(t, M, e);
}), t;
}
}), d(i, {
get when() {
return "error" === o.toast.type;
},
get children() {
var t = J.cloneNode(!0);
return l(t, d(st, m(function () {
return o.toast.iconTheme;
}))), p(function (e) {
return y(t, M, e);
}), t;
}
})];
}
}), e), f(e, function () {
return o.toast.ariaProps;
}, !1, !0), l(e, function () {
return S(o.toast.message, o.toast);
}), p(function (r) {
var i = o.toast.className,
n = _objectSpread(_objectSpread({}, F), {}, {
animation: s()
}, o.toast.style),
a = U;
return i !== r._v$ && u(t, r._v$ = i), r._v$2 = y(t, n, r._v$2), r._v$3 = y(e, a, r._v$3), r;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0
}), t;
}();
},
W = v("<div></div>", 2),
X = h(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["z-index: 9999;> * { pointer-events: auto;}"]))),
Z = function Z(o) {
var s = function s() {
var t = o.toast.position || O.position,
e = function (t, e) {
var o = A.toasts,
s = V().gutter || D.gutter || 8,
r = o.filter(function (t) {
return (t.position || e) === e && t.height;
}),
i = r.findIndex(function (e) {
return e.id === t.id;
}),
n = r.filter(function (t, e) {
return e < i && t.visible;
}).length;
return r.slice(0, n).reduce(function (t, e) {
return t + s + (e.height || 0);
}, 0);
}(o.toast, t),
s = function (t, e) {
var o = t.includes("top");
return _objectSpread(_objectSpread({
left: 0,
right: 0,
display: "flex",
position: "absolute",
transition: "all 230ms cubic-bezier(.21,1.02,.73,1)",
transform: "translateY(".concat(e * (o ? 1 : -1), "px)")
}, o ? {
top: 0
} : {
bottom: 0
}), t.includes("center") ? {
"justify-content": "center"
} : t.includes("right") ? {
"justify-content": "flex-end"
} : {});
}(t, e);
return s;
},
_t6 = t(s()),
_t7 = _slicedToArray(_t6, 2),
r = _t7[0],
i = _t7[1];
var a;
return e(function () {
var t = s();
i(t);
}), n(function () {
a && function (t, e) {
var o = t.getBoundingClientRect();
o.height !== e.height && E({
type: $.UPDATE_TOAST,
toast: {
id: e.id,
height: o.height
}
});
}(a, o.toast);
}), function () {
var t = W.cloneNode(!0);
t.addEventListener("mouseleave", function () {
return E({
type: $.END_PAUSE,
time: Date.now()
});
}), t.addEventListener("mouseenter", function () {
return E({
type: $.START_PAUSE,
time: Date.now()
});
});
return "function" == typeof a ? a(t) : a = t, l(t, function () {
var t = _(function () {
return "custom" === o.toast.type;
}, !0);
return function () {
return t() ? S(o.toast.message, o.toast) : d(Q, {
get toast() {
return o.toast;
},
get position() {
return o.toast.position || O.position;
}
});
};
}()), p(function (e) {
var s = r(),
i = o.toast.visible ? X : "";
return e._v$ = y(t, s, e._v$), i !== e._v$2 && u(t, e._v$2 = i), e;
}, {
_v$: void 0,
_v$2: void 0
}), t;
}();
},
tt = v('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7"></path></svg>', 8),
et = function et(t) {
var e = "".concat(C, " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),
o = "".concat(R, " 1s cubic-bezier(0, 0, 0.2, 1) forwards"),
s = "".concat(z, " 0.2s ease-out forwards");
return function () {
var r = tt.cloneNode(!0),
i = r.firstChild,
n = i.nextSibling,
a = n.nextSibling;
return r.style.setProperty("overflow", "visible"), i.style.setProperty("animation", e), i.style.setProperty("transform-origin", "50% 50%"), i.style.setProperty("animation-delay", "100ms"), i.style.setProperty("opacity", "0"), n.style.setProperty("animation", o), n.style.setProperty("transform-origin", "50% 50%"), n.style.setProperty("animation-delay", "250ms"), a.style.setProperty("animation", s), a.style.setProperty("stroke-dasharray", "22"), a.style.setProperty("stroke-dashoffset", "22"), a.style.setProperty("animation-delay", "250ms"), p(function (e) {
var o = t.primary || "#34C759",
s = t.primary || "#34C759",
r = t.secondary || "#FCFCFC";
return o !== e._v$ && g(i, "fill", e._v$ = o), s !== e._v$2 && g(n, "fill", e._v$2 = s), r !== e._v$3 && g(a, "stroke", e._v$3 = r), e;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0
}), r;
}();
},
ot = v('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" d="M16,7l0,9"></path><circle cx="16" cy="16" r="2.5"></circle></svg>', 10),
st = function st(t) {
var e = "".concat(C, " 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),
o = "".concat(R, " 1s cubic-bezier(0, 0, 0.2, 1) forwards"),
s = "".concat(z, " 0.1s ease-in forwards"),
r = "".concat(B, " 0.2s ease-out forwards");
return function () {
var i = ot.cloneNode(!0),
n = i.firstChild,
a = n.nextSibling,
c = a.nextSibling,
l = c.nextSibling;
return i.style.setProperty("overflow", "visible"), n.style.setProperty("animation", e), n.style.setProperty("transform-origin", "50% 50%"), n.style.setProperty("animation-delay", "100ms"), n.style.setProperty("opacity", "0"), a.style.setProperty("animation", o), a.style.setProperty("transform-origin", "50% 50%"), a.style.setProperty("animation-delay", "320ms"), c.style.setProperty("animation", s), c.style.setProperty("stroke-dasharray", "9"), c.style.setProperty("stroke-dashoffset", "9"), c.style.setProperty("animation-delay", "200ms"), l.style.setProperty("animation", r), l.style.setProperty("animation-delay", "320ms"), l.style.setProperty("opacity", "0"), p(function (e) {
var o = t.primary || "#FF3B30",
s = t.primary || "#FF3B30",
r = t.secondary || "#FFFFFF",
i = t.secondary || "#FFFFFF";
return o !== e._v$ && g(n, "fill", e._v$ = o), s !== e._v$2 && g(a, "fill", e._v$2 = s), r !== e._v$3 && g(c, "stroke", e._v$3 = r), i !== e._v$4 && g(l, "fill", e._v$4 = i), e;
}, {
_v$: void 0,
_v$2: void 0,
_v$3: void 0,
_v$4: void 0
}), i;
}();
},
rt = v('<svg viewBox="0 0 32 32"><path fill="none" stroke-width="4" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z"></path><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2"></path></svg>', 6),
it = function it(t) {
var e = "".concat(j, " 0.75s linear infinite");
return function () {
var o = rt.cloneNode(!0),
s = o.firstChild,
r = s.nextSibling;
return o.style.setProperty("overflow", "visible"), r.style.setProperty("animation", e), r.style.setProperty("transform-origin", "50% 50%"), p(function (e) {
var o = t.primary || "#E5E7EB",
i = t.secondary || "#4b5563";
return o !== e._v$ && g(s, "stroke", e._v$ = o), i !== e._v$2 && g(r, "stroke", e._v$2 = i), e;
}, {
_v$: void 0,
_v$2: void 0
}), o;
}();
};
var nt = q;
export { $ as ActionType, H as Toaster, nt as default, S as resolveValue, q as toast };
var _templateObject,_templateObject2,_templateObject3,_templateObject4,_templateObject5,_templateObject6;function _taggedTemplateLiteral(t,e){return e=e||t.slice(0),Object.freeze(Object.defineProperties(t,{raw:{value:Object.freeze(e)}}))}function ownKeys(e,t){var r,o=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)),o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _slicedToArray(t,e){return _arrayWithHoles(t)||_iterableToArrayLimit(t,e)||_unsupportedIterableToArray(t,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Map"===(r="Object"===r&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function _iterableToArrayLimit(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var o,n,a=[],i=!0,s=!1;try{for(r=r.call(t);!(i=(o=r.next()).done)&&(a.push(o.value),!e||a.length!==e);i=!0);}catch(t){s=!0,n=t}finally{try{i||null==r.return||r.return()}finally{if(s)throw n}}return a}}function _arrayWithHoles(t){if(Array.isArray(t))return t}import{createSignal as t,createEffect as e,onCleanup as o,For as s,Switch as r,Match as i,onMount as n}from"solid-js";import{createStore as a,produce as c}from"solid-js/store";import{insert as l,createComponent as d,effect as p,style as y,className as u,template as v,mergeProps as m,spread as f,memo as _,setAttribute as g}from"solid-js/web";import{keyframes as T,css as h}from"goober";var $,S=function(t,e){return"function"==typeof t?t(e):t},_a=(!function(t){t[t.ADD_TOAST=0]="ADD_TOAST",t[t.UPDATE_TOAST=1]="UPDATE_TOAST",t[t.UPSERT_TOAST=2]="UPSERT_TOAST",t[t.DISMISS_TOAST=3]="DISMISS_TOAST",t[t.REMOVE_TOAST=4]="REMOVE_TOAST",t[t.START_PAUSE=5]="START_PAUSE",t[t.END_PAUSE=6]="END_PAUSE"}($=$||{}),a({toasts:[],pausedAt:void 0})),_a2=_slicedToArray(_a,2),A=_a2[0],b=_a2[1],x=new Map,P=function(t,e){x.has(t)||(e=setTimeout(function(){x.delete(t),E({type:$.REMOVE_TOAST,toastId:t})},e),x.set(t,e))},E=function t(e){switch(e.type){case $.ADD_TOAST:b("toasts",function(t){return[e.toast].concat(_toConsumableArray(t))});break;case $.DISMISS_TOAST:var r=e.toastId,o=A.toasts;r?(a=o.find(function(t){return t.id===r}))&&P(r,a.unmountDelay):o.forEach(function(t){P(t.id,t.unmountDelay)}),b("toasts",function(t){return t.id===r},c(function(t){return t.visible=!1}));break;case $.REMOVE_TOAST:if(!e.toastId){b("toasts",[]);break}b("toasts",function(t){return t.filter(function(t){return t.id!==e.toastId})});break;case $.UPDATE_TOAST:e.toast.id&&(a=e.toast.id,o=x.get(a),x.delete(a),o&&clearTimeout(o)),b("toasts",function(t){return t.id===e.toast.id},function(t){return _objectSpread(_objectSpread({},t),e.toast)});break;case $.UPSERT_TOAST:A.toasts.find(function(t){return t.id===e.toast.id})?t({type:$.UPDATE_TOAST,toast:e.toast}):t({type:$.ADD_TOAST,toast:e.toast});break;case $.START_PAUSE:b("pausedAt",Date.now());break;case $.END_PAUSE:var n=e.time-(A.pausedAt||0);b(c(function(t){t.pausedAt=void 0,t.toasts.forEach(function(t){t.pauseDuration+=n})}))}var a},w={blank:4e3,error:4e3,success:2e3,loading:1/0,custom:4e3},O={id:"",icon:"",unmountDelay:500,duration:3e3,ariaProps:{role:"status","aria-live":"polite"},className:"",style:{},position:"top-right",iconTheme:{}},D={position:"top-right",toastOptions:O,gutter:8,containerStyle:{},containerClassName:""},k={position:"fixed","z-index":9999,top:"16px",bottom:"16px",left:"16px",right:"16px","pointer-events":"none"},I=function(){var t=0;return function(){return String(++t)}}(),N=function(t,e){return(t.position||e).includes("top")?1:-1},F={display:"flex","align-items":"center",background:"white",color:"#363636","box-shadow":"0 3px 10px rgba(0, 0, 0, 0.1), 0 3px 3px rgba(0, 0, 0, 0.05)","max-width":"350px","pointer-events":"auto",padding:"8px 10px","border-radius":"4px","line-height":"1.3","will-change":"transform"},U={display:"flex","align-items":"center",flex:"1 1 auto",margin:"4px 10px","white-space":"pre-line"},M={"flex-shrink":0,"min-width":"20px","min-height":"20px",display:"flex","align-items":"center","justify-content":"center","text-align":"center"},C=T(_templateObject=_templateObject||_taggedTemplateLiteral(["from{transform:scale(0)rotate(45deg);opacity:0;}to{transform:scale(1)rotate(45deg);opacity:1;}"])),R=T(_templateObject2=_templateObject2||_taggedTemplateLiteral(["75%,100%{transform: scale(2.25);opacity:0;}"])),z=T(_templateObject3=_templateObject3||_taggedTemplateLiteral(["to{stroke-dashoffset: 0;}"])),B=T(_templateObject4=_templateObject4||_taggedTemplateLiteral(["0%{transform:translate3d(0,0,0);opacity:1;}100%{transform:translate3d(0,7px,0)scale(1);opacity:1;}"])),j=T(_templateObject5=_templateObject5||_taggedTemplateLiteral(["from{transform: rotate(0deg);}to{transform: rotate(360deg);}"])),_t=t(D),_t2=_slicedToArray(_t,2),V=_t2[0],L=_t2[1],Y=function(o){return function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},r=A.toasts.find(function(t){return t.id===e.id}),r=function(t,e,r){var o,n=1<arguments.length&&void 0!==e?e:"blank",a=2<arguments.length?r:void 0;return _objectSpread(_objectSpread(_objectSpread(_objectSpread({},O),V().toastOptions),a),{},{type:n,message:t,pauseDuration:0,createdAt:Date.now(),visible:!0,id:a.id||I(),style:_objectSpread(_objectSpread(_objectSpread({},O.style),null==(o=V().toastOptions)?void 0:o.style),a.style),duration:a.duration||(null==(o=V().toastOptions)?void 0:o.duration)||w[n],position:a.position||(null==(o=V().toastOptions)?void 0:o.position)||V().position||O.position})}(t,o,_objectSpread(_objectSpread({},r),{},{duration:void 0},e));return E({type:$.UPSERT_TOAST,toast:r}),r.id}},q=function(t,e){return Y("blank")(t,e)},G=(q.error=Y("error"),q.success=Y("success"),q.loading=Y("loading"),q.custom=Y("custom"),q.dismiss=function(t){E({type:$.DISMISS_TOAST,toastId:t})},q.promise=function(t,e,r){var o=q.loading(e.loading,_objectSpread({},r));return t.then(function(t){return q.success(S(e.success,t),_objectSpread({id:o},r)),t}).catch(function(t){q.error(S(e.error,t),_objectSpread({id:o},r))}),t},q.remove=function(t){E({type:$.REMOVE_TOAST,toastId:t})},v("<div></div>",2)),H=function(n){return e(function(){var r;r=n,L(function(t){var e;return{containerClassName:null!=(e=r.containerClassName)?e:t.containerClassName,containerStyle:null!=(e=r.containerStyle)?e:t.containerStyle,gutter:null!=(e=r.gutter)?e:t.gutter,position:null!=(e=r.position)?e:t.position,toastOptions:_objectSpread({},r.toastOptions)}})}),e(function(){var t=function(){var r,t=A.pausedAt,e=A.toasts;if(!t)return r=Date.now(),e.map(function(t){var e;if(t.duration!==1/0)return e=(t.duration||0)+t.pauseDuration-(r-t.createdAt),e<=0?void(t.visible&&E({type:$.DISMISS_TOAST,toastId:t.id})):setTimeout(function(){E({type:$.DISMISS_TOAST,toastId:t.id})},e)})}();o(function(){t&&t.forEach(function(t){return t&&clearTimeout(t)})})}),a=G.cloneNode(!0),l(a,d(s,{get each(){return A.toasts},children:function(t){return d(Z,{toast:t})}})),p(function(t){var e=_objectSpread(_objectSpread({},k),n.containerStyle),r=n.containerClassName;return t._v$=y(a,e,t._v$),r!==t._v$2&&u(a,t._v$2=r),t},{_v$:void 0,_v$2:void 0}),a;var a},J=v("<div></div>",2),K=v("<div><div></div></div>",4),Q=function(n){var a,s,o=_slicedToArray(t(""),2),c=o[0],v=o[1];return e(function(){var t;n.toast.visible?v("".concat(T((t=N(n.toast,n.position),"\n0% {transform: translate3d(0,".concat(-200*t,"%,0) scale(.6); opacity:.5;}\n100% {transform: translate3d(0,0,0) scale(1); opacity:1;}\n")))," 0.35s cubic-bezier(.21,1.02,.73,1) forwards")):v("".concat(T("\n0% {transform: translate3d(0,0,-1px) scale(1); opacity:1;}\n100% {transform: translate3d(0,".concat(-150*N(n.toast,n.position),"%,-1px) scale(.4); opacity:0;}\n"))," 0.4s forwards cubic-bezier(.06,.71,.55,1)"))}),a=K.cloneNode(!0),s=a.firstChild,l(a,d(r,{get children(){return[d(i,{get when(){return n.toast.icon},get children(){var e=J.cloneNode(!0);return l(e,function(){return n.toast.icon}),p(function(t){return y(e,M,t)}),e}}),d(i,{get when(){return"loading"===n.toast.type},get children(){var e=J.cloneNode(!0);return l(e,d(it,m(function(){return n.toast.iconTheme}))),p(function(t){return y(e,M,t)}),e}}),d(i,{get when(){return"success"===n.toast.type},get children(){var e=J.cloneNode(!0);return l(e,d(et,m(function(){return n.toast.iconTheme}))),p(function(t){return y(e,M,t)}),e}}),d(i,{get when(){return"error"===n.toast.type},get children(){var e=J.cloneNode(!0);return l(e,d(st,m(function(){return n.toast.iconTheme}))),p(function(t){return y(e,M,t)}),e}})]}}),s),f(s,function(){return n.toast.ariaProps},!1,!0),l(s,function(){return S(n.toast.message,n.toast)}),p(function(t){var e=n.toast.className,r=_objectSpread(_objectSpread({},F),{},{animation:c()},n.toast.style),o=U;return e!==t._v$&&u(a,t._v$=e),t._v$2=y(a,r,t._v$2),t._v$3=y(s,o,t._v$3),t},{_v$:void 0,_v$2:void 0,_v$3:void 0}),a},W=v("<div></div>",2),X=h(_templateObject6=_templateObject6||_taggedTemplateLiteral(["z-index: 9999;> * { pointer-events: auto;}"])),Z=function(s){function r(){var e,r,o,n,t,a,i=s.toast.position||O.position;return e=s.toast,r=i,a=A.toasts,o=V().gutter||D.gutter||8,a=a.filter(function(t){return(t.position||r)===r&&t.height}),n=a.findIndex(function(t){return t.id===e.id}),t=a.filter(function(t,e){return e<n&&t.visible}).length,t=a=a.slice(0,t).reduce(function(t,e){return t+o+(e.height||0)},0),i=(a=i).includes("top"),_objectSpread(_objectSpread({left:0,right:0,display:"flex",position:"absolute",transition:"all 230ms cubic-bezier(.21,1.02,.73,1)",transform:"translateY(".concat(t*(i?1:-1),"px)")},i?{top:0}:{bottom:0}),a.includes("center")?{"justify-content":"center"}:a.includes("right")?{"justify-content":"flex-end"}:{})}var o,a,i,c=_slicedToArray(t(r()),2),f=c[0],v=c[1];return e(function(){var t=r();v(t)}),n(function(){var t,e;o&&(t=o,e=s.toast,(t=t.getBoundingClientRect()).height!==e.height&&E({type:$.UPDATE_TOAST,toast:{id:e.id,height:t.height}}))}),(i=W.cloneNode(!0)).addEventListener("mouseleave",function(){return E({type:$.END_PAUSE,time:Date.now()})}),i.addEventListener("mouseenter",function(){return E({type:$.START_PAUSE,time:Date.now()})}),"function"==typeof o?o(i):o=i,l(i,(a=_(function(){return"custom"===s.toast.type},!0),function(){return a()?S(s.toast.message,s.toast):d(Q,{get toast(){return s.toast},get position(){return s.toast.position||O.position}})})),p(function(t){var e=f(),r=s.toast.visible?X:"";return t._v$=y(i,e,t._v$),r!==t._v$2&&u(i,t._v$2=r),t},{_v$:void 0,_v$2:void 0}),i},tt=v('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M9.8,17.2l3.8,3.6c0.1,0.1,0.3,0.1,0.4,0l9.6-9.7"></path></svg>',8),et=function(n){var t,a,i,s,e="".concat(C," 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),r="".concat(R," 1s cubic-bezier(0, 0, 0.2, 1) forwards"),o="".concat(z," 0.2s ease-out forwards");return t=tt.cloneNode(!0),a=t.firstChild,i=a.nextSibling,s=i.nextSibling,t.style.setProperty("overflow","visible"),a.style.setProperty("animation",e),a.style.setProperty("transform-origin","50% 50%"),a.style.setProperty("animation-delay","100ms"),a.style.setProperty("opacity","0"),i.style.setProperty("animation",r),i.style.setProperty("transform-origin","50% 50%"),i.style.setProperty("animation-delay","250ms"),s.style.setProperty("animation",o),s.style.setProperty("stroke-dasharray","22"),s.style.setProperty("stroke-dashoffset","22"),s.style.setProperty("animation-delay","250ms"),p(function(t){var e=n.primary||"#34C759",r=n.primary||"#34C759",o=n.secondary||"#FCFCFC";return e!==t._v$&&g(a,"fill",t._v$=e),r!==t._v$2&&g(i,"fill",t._v$2=r),o!==t._v$3&&g(s,"stroke",t._v$3=o),t},{_v$:void 0,_v$2:void 0,_v$3:void 0}),t},ot=v('<svg viewBox="0 0 32 32"><circle cx="16" cy="16" r="16"></circle><circle cx="16" cy="16" r="12"></circle><path fill="none" stroke-width="4" stroke-linecap="round" d="M16,7l0,9"></path><circle cx="16" cy="16" r="2.5"></circle></svg>',10),st=function(a){var t,i,s,c,l,e="".concat(C," 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards"),r="".concat(R," 1s cubic-bezier(0, 0, 0.2, 1) forwards"),o="".concat(z," 0.1s ease-in forwards"),n="".concat(B," 0.2s ease-out forwards");return t=ot.cloneNode(!0),i=t.firstChild,s=i.nextSibling,c=s.nextSibling,l=c.nextSibling,t.style.setProperty("overflow","visible"),i.style.setProperty("animation",e),i.style.setProperty("transform-origin","50% 50%"),i.style.setProperty("animation-delay","100ms"),i.style.setProperty("opacity","0"),s.style.setProperty("animation",r),s.style.setProperty("transform-origin","50% 50%"),s.style.setProperty("animation-delay","320ms"),c.style.setProperty("animation",o),c.style.setProperty("stroke-dasharray","9"),c.style.setProperty("stroke-dashoffset","9"),c.style.setProperty("animation-delay","200ms"),l.style.setProperty("animation",n),l.style.setProperty("animation-delay","320ms"),l.style.setProperty("opacity","0"),p(function(t){var e=a.primary||"#FF3B30",r=a.primary||"#FF3B30",o=a.secondary||"#FFFFFF",n=a.secondary||"#FFFFFF";return e!==t._v$&&g(i,"fill",t._v$=e),r!==t._v$2&&g(s,"fill",t._v$2=r),o!==t._v$3&&g(c,"stroke",t._v$3=o),n!==t._v$4&&g(l,"fill",t._v$4=n),t},{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),t},rt=v('<svg viewBox="0 0 32 32"><path fill="none" stroke-width="4" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c1.5,1.8,2.5,4,2.5,6.6c0,5.5-4.5,10-10,10S6,21.6,6,16S10.5,6,16,6z"></path><path fill="none" stroke-width="4" stroke-linecap="round" stroke-miterlimit="10" d="M16,6c3,0,5.7,1.3,7.5,3.4c0.6,0.7,1.1,1.4,1.5,2.2"></path></svg>',6),it=function(o){var t,n,a,e="".concat(j," 0.75s linear infinite");return t=rt.cloneNode(!0),n=t.firstChild,a=n.nextSibling,t.style.setProperty("overflow","visible"),a.style.setProperty("animation",e),a.style.setProperty("transform-origin","50% 50%"),p(function(t){var e=o.primary||"#E5E7EB",r=o.secondary||"#4b5563";return e!==t._v$&&g(n,"stroke",t._v$=e),r!==t._v$2&&g(a,"stroke",t._v$2=r),t},{_v$:void 0,_v$2:void 0}),t},nt=q;export{$ as ActionType,H as Toaster,nt as default,S as resolveValue,q as toast};
//# sourceMappingURL=index.js.map

3

package.json
{
"name": "solid-toast",
"version": "0.1.7-alpha.1",
"version": "0.1.7-alpha.2",
"description": "Customizable Toast Notifications for SolidJS",

@@ -54,2 +54,3 @@ "source": "./src/index.tsx",

"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-uglify": "^6.0.4",
"rollup-preset-solid": "^1.4.0",

@@ -56,0 +57,0 @@ "typescript": "^4.6.4",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc