@vervstack/chures 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chures.js +135 -135
- package/dist/chures.umd.cjs +2 -2
- package/dist/hooks/toaster/useToaster.d.ts +2 -1
- package/package.json +2 -2
package/dist/chures.js
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { AnimatePresence as
|
|
5
|
-
import { create as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const { botId:
|
|
9
|
-
|
|
10
|
-
const
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--chures-accent: #229ED9;--chures-btn-from: #2AABEE;--chures-btn-to: #229ED9;--chures-error: #ef4444;--chures-warn: #f59e0b;--chures-fg: #ffffff;--chures-fg-muted: #9ca3af;--chures-surface: #000000;--chures-font-sm: .875rem;--chures-font-xs: .75rem}._TelegramSignInButtonContainer_10wun_1{display:inline-flex;align-items:center;justify-content:center;gap:.625rem;width:100%;padding:1rem 1.375rem;background:linear-gradient(180deg,var(--chures-btn-from, #2AABEE) 0%,var(--chures-btn-to, #229ED9) 100%);border:0;border-radius:.875rem;color:#fff;font-family:Comfortaa,sans-serif;font-weight:600;font-size:1rem;letter-spacing:-.005em;cursor:pointer;box-shadow:inset 0 .0625rem #ffffff26,0 .75rem 2rem -.75rem #2aabee8c;transition:transform .14s ease,box-shadow .2s ease,filter .16s ease}._TelegramSignInButtonContainer_10wun_1:hover{transform:translateY(-.0625rem);box-shadow:inset 0 .0625rem #ffffff2e,0 1.125rem 2.375rem -.75rem #2aabeea6;filter:brightness(1.05)}._TelegramSignInButtonContainer_10wun_1:active{transform:translateY(0);filter:brightness(.97)}._TelegramSignInButtonContainer_10wun_1:focus-visible{outline:.125rem solid rgba(255,255,255,.8);outline-offset:.125rem}._TelegramSignInButtonContainer_10wun_1:disabled{opacity:.6;cursor:not-allowed}._FullSize_10wun_46{height:100%}._Icon_10wun_50{flex-shrink:0}._ToastContainer_1tme2_1{position:fixed;right:1.5rem;top:1.5rem;width:clamp(25vw,24.5rem,95vw);display:flex;flex-direction:column;gap:1rem;z-index:9999}._Toast_1tme2_1{min-height:4rem;border:var(--chures-accent, #229ED9) 1px solid;border-radius:1rem;padding:1rem;box-sizing:border-box;position:relative;background:var(--chures-surface, #000000);display:flex;flex-direction:column}._Toast_1tme2_1>div:first-child{font-weight:700;font-size:var(--chures-font-sm, .875rem);color:var(--chures-fg, #ffffff)}._Toast_1tme2_1._error_1tme2_33{border-color:var(--chures-error, #ef4444)}._Toast_1tme2_1._error_1tme2_33>div:first-child{color:var(--chures-error, #ef4444)}._Toast_1tme2_1._warn_1tme2_41{border-color:var(--chures-warn, #f59e0b)}._Toast_1tme2_1._warn_1tme2_41>div:first-child{color:var(--chures-warn, #f59e0b)}._Toast_1tme2_1._info_1tme2_49{border-color:var(--chures-accent, #229ED9)}._Toast_1tme2_1 ._Description_1tme2_53{color:var(--chures-fg-muted, #9ca3af);font-size:var(--chures-font-xs, .75rem);margin-top:.125rem}._Toast_1tme2_1 ._DismissButton_1tme2_59{position:absolute;width:1rem;height:1rem;display:flex;justify-content:center;align-items:center;top:0;right:1%;cursor:pointer;font-size:1.5rem;color:var(--chures-fg-muted, #9ca3af)}._slideIn_1tme2_79{animation:_slideIn_1tme2_79 .2s ease forwards}._slideOut_1tme2_83{animation:_slideOut_1tme2_83 .2s ease forwards}@keyframes _slideIn_1tme2_79{0%{opacity:0;transform:translate(2rem)}to{opacity:1;transform:translate(0)}}@keyframes _slideOut_1tme2_83{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:translate(2rem)}}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
import { jsxs as S, jsx as a, Fragment as B } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as w, useState as h, useEffect as y } from "react";
|
|
4
|
+
import { AnimatePresence as L, motion as x } from "framer-motion";
|
|
5
|
+
import { create as R } from "zustand";
|
|
6
|
+
const E = "https://oauth.telegram.org/js/telegram-login.js?3";
|
|
7
|
+
function b(e) {
|
|
8
|
+
const { botId: s, redirectUri: r, requestAccess: o = "write" } = e, i = w(e.onSuccess);
|
|
9
|
+
i.current = e.onSuccess;
|
|
10
|
+
const t = w(!1), [n, c] = h(!1), [f, u] = h(!1);
|
|
11
11
|
y(function() {
|
|
12
|
-
if (!
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
{ client_id:
|
|
20
|
-
function(
|
|
21
|
-
|
|
12
|
+
if (!s) return;
|
|
13
|
+
const p = r ?? window.location.origin;
|
|
14
|
+
u(!0), c(!1);
|
|
15
|
+
const l = document.createElement("script");
|
|
16
|
+
return l.src = E, l.async = !0, l.onload = function() {
|
|
17
|
+
const _ = window.Telegram;
|
|
18
|
+
_ && (_.Login.init(
|
|
19
|
+
{ client_id: s, redirect_uri: p },
|
|
20
|
+
function(v) {
|
|
21
|
+
t.current || (t.current = !0, i.current(v));
|
|
22
22
|
}
|
|
23
|
-
),
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
}, document.head.appendChild(
|
|
27
|
-
document.head.contains(
|
|
23
|
+
), c(!0)), u(!1);
|
|
24
|
+
}, l.onerror = function() {
|
|
25
|
+
u(!1);
|
|
26
|
+
}, document.head.appendChild(l), function() {
|
|
27
|
+
document.head.contains(l) && document.head.removeChild(l), c(!1), u(!1);
|
|
28
28
|
};
|
|
29
|
-
}, [
|
|
29
|
+
}, [s, r]);
|
|
30
30
|
function m() {
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const p = window.Telegram;
|
|
32
|
+
if (!n || !p) return;
|
|
33
|
+
t.current = !1;
|
|
34
|
+
const l = r ?? window.location.origin;
|
|
35
|
+
p.Login.auth(
|
|
36
|
+
{ client_id: s, redirect_uri: l, request_access: o },
|
|
37
|
+
function(_) {
|
|
38
|
+
t.current || (t.current = !0, i.current(_));
|
|
38
39
|
}
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
|
-
return { login: m, isReady:
|
|
42
|
+
return { login: m, isReady: n, isLoading: f };
|
|
42
43
|
}
|
|
43
|
-
const
|
|
44
|
-
TelegramSignInButtonContainer:
|
|
45
|
-
FullSize:
|
|
46
|
-
Icon:
|
|
47
|
-
},
|
|
44
|
+
const j = "_TelegramSignInButtonContainer_10wun_1", D = "_FullSize_10wun_46", O = "_Icon_10wun_50", T = {
|
|
45
|
+
TelegramSignInButtonContainer: j,
|
|
46
|
+
FullSize: D,
|
|
47
|
+
Icon: O
|
|
48
|
+
}, N = {
|
|
48
49
|
en: "Continue with Telegram",
|
|
49
50
|
ru: "Войти через Telegram"
|
|
50
51
|
};
|
|
51
|
-
function
|
|
52
|
+
function A() {
|
|
52
53
|
return /* @__PURE__ */ a(
|
|
53
54
|
"svg",
|
|
54
55
|
{
|
|
@@ -57,160 +58,159 @@ function N() {
|
|
|
57
58
|
height: "20",
|
|
58
59
|
fill: "currentColor",
|
|
59
60
|
"aria-hidden": "true",
|
|
60
|
-
className:
|
|
61
|
+
className: T.Icon,
|
|
61
62
|
children: /* @__PURE__ */ a("path", { d: "M22 3.5L2.5 11l5 1.7L18 6 9.7 14l-.4 5.5 3.4-3.2 5.5 4c.9.5 1.5.2 1.7-.8L22 4.3c.2-.7-.2-1.1-.9-.8z" })
|
|
62
63
|
}
|
|
63
64
|
);
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
-
onClick:
|
|
67
|
-
disabled:
|
|
68
|
-
lang:
|
|
69
|
-
title:
|
|
70
|
-
label:
|
|
66
|
+
function F({
|
|
67
|
+
onClick: e,
|
|
68
|
+
disabled: s,
|
|
69
|
+
lang: r = "en",
|
|
70
|
+
title: o,
|
|
71
|
+
label: i,
|
|
71
72
|
fullSize: t,
|
|
72
|
-
className:
|
|
73
|
+
className: n
|
|
73
74
|
}) {
|
|
74
75
|
y(function() {
|
|
75
|
-
const
|
|
76
|
-
if (document.getElementById(
|
|
77
|
-
const
|
|
78
|
-
|
|
76
|
+
const u = "comfortaa-font";
|
|
77
|
+
if (document.getElementById(u)) return;
|
|
78
|
+
const m = document.createElement("link");
|
|
79
|
+
m.id = u, m.rel = "stylesheet", m.href = "https://fonts.googleapis.com/css2?family=Comfortaa:wght@600&display=swap", document.head.appendChild(m);
|
|
79
80
|
}, []);
|
|
80
|
-
const c =
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
/* @__PURE__ */ a(
|
|
81
|
+
const c = i ?? o ?? N[r], f = [T.TelegramSignInButtonContainer, t && T.FullSize, n].filter(Boolean).join(" ");
|
|
82
|
+
return /* @__PURE__ */ S("button", { type: "button", className: f, onClick: e, disabled: s, children: [
|
|
83
|
+
/* @__PURE__ */ a(A, {}),
|
|
83
84
|
c
|
|
84
85
|
] });
|
|
85
86
|
}
|
|
86
|
-
function
|
|
87
|
-
botId:
|
|
88
|
-
onSuccess:
|
|
89
|
-
lang:
|
|
90
|
-
title:
|
|
91
|
-
redirectUri:
|
|
87
|
+
function nt({
|
|
88
|
+
botId: e,
|
|
89
|
+
onSuccess: s,
|
|
90
|
+
lang: r,
|
|
91
|
+
title: o,
|
|
92
|
+
redirectUri: i,
|
|
92
93
|
requestAccess: t,
|
|
93
|
-
children:
|
|
94
|
+
children: n,
|
|
94
95
|
className: c
|
|
95
96
|
}) {
|
|
96
|
-
const { login:
|
|
97
|
-
return
|
|
98
|
-
|
|
97
|
+
const { login: f, isReady: u } = b({ botId: e, onSuccess: s, redirectUri: i, requestAccess: t });
|
|
98
|
+
return n ? /* @__PURE__ */ a(B, { children: n({ login: f, isReady: u }) }) : /* @__PURE__ */ a(
|
|
99
|
+
F,
|
|
99
100
|
{
|
|
100
|
-
onClick:
|
|
101
|
-
disabled: !
|
|
102
|
-
lang:
|
|
103
|
-
title:
|
|
101
|
+
onClick: f,
|
|
102
|
+
disabled: !u,
|
|
103
|
+
lang: r,
|
|
104
|
+
title: o,
|
|
104
105
|
className: c
|
|
105
106
|
}
|
|
106
107
|
);
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
109
|
+
function z(e) {
|
|
110
|
+
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
110
111
|
}
|
|
111
|
-
var
|
|
112
|
-
var
|
|
113
|
-
function
|
|
114
|
-
return
|
|
112
|
+
var g = { exports: {} };
|
|
113
|
+
var I;
|
|
114
|
+
function q() {
|
|
115
|
+
return I || (I = 1, (function(e) {
|
|
115
116
|
(function() {
|
|
116
|
-
var
|
|
117
|
-
function
|
|
118
|
-
for (var t = "",
|
|
119
|
-
var c = arguments[
|
|
120
|
-
c && (t =
|
|
117
|
+
var s = {}.hasOwnProperty;
|
|
118
|
+
function r() {
|
|
119
|
+
for (var t = "", n = 0; n < arguments.length; n++) {
|
|
120
|
+
var c = arguments[n];
|
|
121
|
+
c && (t = i(t, o(c)));
|
|
121
122
|
}
|
|
122
123
|
return t;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function o(t) {
|
|
125
126
|
if (typeof t == "string" || typeof t == "number")
|
|
126
127
|
return t;
|
|
127
128
|
if (typeof t != "object")
|
|
128
129
|
return "";
|
|
129
130
|
if (Array.isArray(t))
|
|
130
|
-
return
|
|
131
|
+
return r.apply(null, t);
|
|
131
132
|
if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
|
|
132
133
|
return t.toString();
|
|
133
|
-
var
|
|
134
|
+
var n = "";
|
|
134
135
|
for (var c in t)
|
|
135
|
-
|
|
136
|
-
return
|
|
136
|
+
s.call(t, c) && t[c] && (n = i(n, c));
|
|
137
|
+
return n;
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
139
|
+
function i(t, n) {
|
|
140
|
+
return n ? t ? t + " " + n : t + n : t;
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
+
e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
|
|
142
143
|
})();
|
|
143
|
-
})(
|
|
144
|
+
})(g)), g.exports;
|
|
144
145
|
}
|
|
145
|
-
var
|
|
146
|
-
const
|
|
146
|
+
var P = q();
|
|
147
|
+
const k = /* @__PURE__ */ z(P);
|
|
148
|
+
let M = 0;
|
|
149
|
+
const C = R((e, s) => ({
|
|
147
150
|
toasts: [],
|
|
148
|
-
bake: (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
n((s) => ({ toasts: [...s.toasts, e] })), setTimeout(() => {
|
|
154
|
-
o().dismiss(e.title);
|
|
151
|
+
bake: (r) => {
|
|
152
|
+
const o = M++;
|
|
153
|
+
e((i) => ({ toasts: [...i.toasts, { ...r, id: o }] })), setTimeout(() => {
|
|
154
|
+
s().dismiss(o);
|
|
155
155
|
}, 5e3);
|
|
156
156
|
},
|
|
157
|
-
dismiss: (
|
|
158
|
-
|
|
159
|
-
toasts:
|
|
157
|
+
dismiss: (r) => {
|
|
158
|
+
e((o) => ({
|
|
159
|
+
toasts: o.toasts.filter((i) => i.id !== r)
|
|
160
160
|
}));
|
|
161
161
|
}
|
|
162
|
-
})),
|
|
163
|
-
ToastContainer:
|
|
164
|
-
Toast:
|
|
165
|
-
error:
|
|
166
|
-
warn:
|
|
167
|
-
info:
|
|
168
|
-
Description:
|
|
169
|
-
DismissButton:
|
|
170
|
-
slideIn:
|
|
171
|
-
slideOut:
|
|
162
|
+
})), U = "_ToastContainer_1tme2_1", G = "_Toast_1tme2_1", V = "_error_1tme2_33", W = "_warn_1tme2_41", $ = "_info_1tme2_49", H = "_Description_1tme2_53", J = "_DismissButton_1tme2_59", K = "_slideIn_1tme2_79", Q = "_slideOut_1tme2_83", d = {
|
|
163
|
+
ToastContainer: U,
|
|
164
|
+
Toast: G,
|
|
165
|
+
error: V,
|
|
166
|
+
warn: W,
|
|
167
|
+
info: $,
|
|
168
|
+
Description: H,
|
|
169
|
+
DismissButton: J,
|
|
170
|
+
slideIn: K,
|
|
171
|
+
slideOut: Q
|
|
172
172
|
};
|
|
173
|
-
function
|
|
174
|
-
const { toasts:
|
|
175
|
-
return /* @__PURE__ */ a("div", { className:
|
|
176
|
-
|
|
173
|
+
function rt() {
|
|
174
|
+
const { toasts: e } = C();
|
|
175
|
+
return /* @__PURE__ */ a("div", { className: d.ToastContainer, children: /* @__PURE__ */ a(L, { children: e.map((s) => /* @__PURE__ */ a(
|
|
176
|
+
x.div,
|
|
177
177
|
{
|
|
178
178
|
layout: !0,
|
|
179
179
|
initial: { opacity: 0, x: 100, y: 50 },
|
|
180
180
|
animate: { opacity: 1, x: 0, y: 0 },
|
|
181
181
|
exit: { opacity: 0, y: -50 },
|
|
182
182
|
transition: { type: "spring", stiffness: 300, damping: 20 },
|
|
183
|
-
children: /* @__PURE__ */ a(
|
|
183
|
+
children: /* @__PURE__ */ a(X, { ...s })
|
|
184
184
|
},
|
|
185
|
-
|
|
185
|
+
s.id
|
|
186
186
|
)) }) });
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
const [
|
|
188
|
+
function X({ id: e, title: s, description: r, level: o, isDismissable: i }) {
|
|
189
|
+
const [t, n] = h(!1), c = C();
|
|
190
190
|
return y(() => () => {
|
|
191
|
-
|
|
192
|
-
}, []), /* @__PURE__ */
|
|
191
|
+
n(!0);
|
|
192
|
+
}, []), /* @__PURE__ */ S(
|
|
193
193
|
"div",
|
|
194
194
|
{
|
|
195
|
-
className:
|
|
196
|
-
[
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[
|
|
195
|
+
className: k(d.Toast, {
|
|
196
|
+
[d.error]: o === "Error",
|
|
197
|
+
[d.warn]: o === "Warn",
|
|
198
|
+
[d.info]: o == null || o === "Info",
|
|
199
|
+
[d.slideIn]: !t,
|
|
200
|
+
[d.slideOut]: t
|
|
201
201
|
}),
|
|
202
202
|
children: [
|
|
203
|
-
/* @__PURE__ */ a("div", { children:
|
|
204
|
-
/* @__PURE__ */ a("div", { className:
|
|
205
|
-
e && /* @__PURE__ */ a("div", { className:
|
|
203
|
+
/* @__PURE__ */ a("div", { children: s }),
|
|
204
|
+
/* @__PURE__ */ a("div", { className: d.Description, children: r }),
|
|
205
|
+
i && e !== void 0 && /* @__PURE__ */ a("div", { className: d.DismissButton, onClick: () => c.dismiss(e), children: "×" })
|
|
206
206
|
]
|
|
207
207
|
}
|
|
208
208
|
);
|
|
209
209
|
}
|
|
210
210
|
export {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
nt as TelegramAuth,
|
|
212
|
+
F as TelegramSignInButton,
|
|
213
|
+
rt as Toaster,
|
|
214
|
+
b as useTelegramLogin,
|
|
215
|
+
C as useToaster
|
|
216
216
|
};
|
package/dist/chures.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("
|
|
2
|
-
(function(
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(":root{--chures-accent: #229ED9;--chures-btn-from: #2AABEE;--chures-btn-to: #229ED9;--chures-error: #ef4444;--chures-warn: #f59e0b;--chures-fg: #ffffff;--chures-fg-muted: #9ca3af;--chures-surface: #000000;--chures-font-sm: .875rem;--chures-font-xs: .75rem}._TelegramSignInButtonContainer_10wun_1{display:inline-flex;align-items:center;justify-content:center;gap:.625rem;width:100%;padding:1rem 1.375rem;background:linear-gradient(180deg,var(--chures-btn-from, #2AABEE) 0%,var(--chures-btn-to, #229ED9) 100%);border:0;border-radius:.875rem;color:#fff;font-family:Comfortaa,sans-serif;font-weight:600;font-size:1rem;letter-spacing:-.005em;cursor:pointer;box-shadow:inset 0 .0625rem #ffffff26,0 .75rem 2rem -.75rem #2aabee8c;transition:transform .14s ease,box-shadow .2s ease,filter .16s ease}._TelegramSignInButtonContainer_10wun_1:hover{transform:translateY(-.0625rem);box-shadow:inset 0 .0625rem #ffffff2e,0 1.125rem 2.375rem -.75rem #2aabeea6;filter:brightness(1.05)}._TelegramSignInButtonContainer_10wun_1:active{transform:translateY(0);filter:brightness(.97)}._TelegramSignInButtonContainer_10wun_1:focus-visible{outline:.125rem solid rgba(255,255,255,.8);outline-offset:.125rem}._TelegramSignInButtonContainer_10wun_1:disabled{opacity:.6;cursor:not-allowed}._FullSize_10wun_46{height:100%}._Icon_10wun_50{flex-shrink:0}._ToastContainer_1tme2_1{position:fixed;right:1.5rem;top:1.5rem;width:clamp(25vw,24.5rem,95vw);display:flex;flex-direction:column;gap:1rem;z-index:9999}._Toast_1tme2_1{min-height:4rem;border:var(--chures-accent, #229ED9) 1px solid;border-radius:1rem;padding:1rem;box-sizing:border-box;position:relative;background:var(--chures-surface, #000000);display:flex;flex-direction:column}._Toast_1tme2_1>div:first-child{font-weight:700;font-size:var(--chures-font-sm, .875rem);color:var(--chures-fg, #ffffff)}._Toast_1tme2_1._error_1tme2_33{border-color:var(--chures-error, #ef4444)}._Toast_1tme2_1._error_1tme2_33>div:first-child{color:var(--chures-error, #ef4444)}._Toast_1tme2_1._warn_1tme2_41{border-color:var(--chures-warn, #f59e0b)}._Toast_1tme2_1._warn_1tme2_41>div:first-child{color:var(--chures-warn, #f59e0b)}._Toast_1tme2_1._info_1tme2_49{border-color:var(--chures-accent, #229ED9)}._Toast_1tme2_1 ._Description_1tme2_53{color:var(--chures-fg-muted, #9ca3af);font-size:var(--chures-font-xs, .75rem);margin-top:.125rem}._Toast_1tme2_1 ._DismissButton_1tme2_59{position:absolute;width:1rem;height:1rem;display:flex;justify-content:center;align-items:center;top:0;right:1%;cursor:pointer;font-size:1.5rem;color:var(--chures-fg-muted, #9ca3af)}._slideIn_1tme2_79{animation:_slideIn_1tme2_79 .2s ease forwards}._slideOut_1tme2_83{animation:_slideOut_1tme2_83 .2s ease forwards}@keyframes _slideIn_1tme2_79{0%{opacity:0;transform:translate(2rem)}to{opacity:1;transform:translate(0)}}@keyframes _slideOut_1tme2_83{0%{opacity:1;transform:translate(0)}to{opacity:0;transform:translate(2rem)}}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
(function(u,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("react/jsx-runtime"),require("react"),require("framer-motion"),require("zustand")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","framer-motion","zustand"],s):(u=typeof globalThis<"u"?globalThis:u||self,s(u.Chures={},u.ReactJSXRuntime,u.React,u.FramerMotion,u.Zustand))})(this,(function(u,s,m,I,B){"use strict";const L="https://oauth.telegram.org/js/telegram-login.js?3";function w(t){const{botId:o,redirectUri:r,requestAccess:i="write"}=t,c=m.useRef(t.onSuccess);c.current=t.onSuccess;const e=m.useRef(!1),[n,a]=m.useState(!1),[p,l]=m.useState(!1);m.useEffect(function(){if(!o)return;const _=r??window.location.origin;l(!0),a(!1);const f=document.createElement("script");return f.src=L,f.async=!0,f.onload=function(){const h=window.Telegram;h&&(h.Login.init({client_id:o,redirect_uri:_},function(N){e.current||(e.current=!0,c.current(N))}),a(!0)),l(!1)},f.onerror=function(){l(!1)},document.head.appendChild(f),function(){document.head.contains(f)&&document.head.removeChild(f),a(!1),l(!1)}},[o,r]);function g(){const _=window.Telegram;if(!n||!_)return;e.current=!1;const f=r??window.location.origin;_.Login.auth({client_id:o,redirect_uri:f,request_access:i},function(h){e.current||(e.current=!0,c.current(h))})}return{login:g,isReady:n,isLoading:p}}const T={TelegramSignInButtonContainer:"_TelegramSignInButtonContainer_10wun_1",FullSize:"_FullSize_10wun_46",Icon:"_Icon_10wun_50"},E={en:"Continue with Telegram",ru:"Войти через Telegram"};function j(){return s.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20",fill:"currentColor","aria-hidden":"true",className:T.Icon,children:s.jsx("path",{d:"M22 3.5L2.5 11l5 1.7L18 6 9.7 14l-.4 5.5 3.4-3.2 5.5 4c.9.5 1.5.2 1.7-.8L22 4.3c.2-.7-.2-1.1-.9-.8z"})})}function C({onClick:t,disabled:o,lang:r="en",title:i,label:c,fullSize:e,className:n}){m.useEffect(function(){const l="comfortaa-font";if(document.getElementById(l))return;const g=document.createElement("link");g.id=l,g.rel="stylesheet",g.href="https://fonts.googleapis.com/css2?family=Comfortaa:wght@600&display=swap",document.head.appendChild(g)},[]);const a=c??i??E[r],p=[T.TelegramSignInButtonContainer,e&&T.FullSize,n].filter(Boolean).join(" ");return s.jsxs("button",{type:"button",className:p,onClick:t,disabled:o,children:[s.jsx(j,{}),a]})}function D({botId:t,onSuccess:o,lang:r,title:i,redirectUri:c,requestAccess:e,children:n,className:a}){const{login:p,isReady:l}=w({botId:t,onSuccess:o,redirectUri:c,requestAccess:e});return n?s.jsx(s.Fragment,{children:n({login:p,isReady:l})}):s.jsx(C,{onClick:p,disabled:!l,lang:r,title:i,className:a})}function O(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y={exports:{}};var v;function x(){return v||(v=1,(function(t){(function(){var o={}.hasOwnProperty;function r(){for(var e="",n=0;n<arguments.length;n++){var a=arguments[n];a&&(e=c(e,i(a)))}return e}function i(e){if(typeof e=="string"||typeof e=="number")return e;if(typeof e!="object")return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var n="";for(var a in e)o.call(e,a)&&e[a]&&(n=c(n,a));return n}function c(e,n){return n?e?e+" "+n:e+n:e}t.exports?(r.default=r,t.exports=r):window.classNames=r})()})(y)),y.exports}var F=x();const b=O(F);let q=0;const S=B.create((t,o)=>({toasts:[],bake:r=>{const i=q++;t(c=>({toasts:[...c.toasts,{...r,id:i}]})),setTimeout(()=>{o().dismiss(i)},5e3)},dismiss:r=>{t(i=>({toasts:i.toasts.filter(c=>c.id!==r)}))}})),d={ToastContainer:"_ToastContainer_1tme2_1",Toast:"_Toast_1tme2_1",error:"_error_1tme2_33",warn:"_warn_1tme2_41",info:"_info_1tme2_49",Description:"_Description_1tme2_53",DismissButton:"_DismissButton_1tme2_59",slideIn:"_slideIn_1tme2_79",slideOut:"_slideOut_1tme2_83"};function z(){const{toasts:t}=S();return s.jsx("div",{className:d.ToastContainer,children:s.jsx(I.AnimatePresence,{children:t.map(o=>s.jsx(I.motion.div,{layout:!0,initial:{opacity:0,x:100,y:50},animate:{opacity:1,x:0,y:0},exit:{opacity:0,y:-50},transition:{type:"spring",stiffness:300,damping:20},children:s.jsx(A,{...o})},o.id))})})}function A({id:t,title:o,description:r,level:i,isDismissable:c}){const[e,n]=m.useState(!1),a=S();return m.useEffect(()=>()=>{n(!0)},[]),s.jsxs("div",{className:b(d.Toast,{[d.error]:i==="Error",[d.warn]:i==="Warn",[d.info]:i==null||i==="Info",[d.slideIn]:!e,[d.slideOut]:e}),children:[s.jsx("div",{children:o}),s.jsx("div",{className:d.Description,children:r}),c&&t!==void 0&&s.jsx("div",{className:d.DismissButton,onClick:()=>a.dismiss(t),children:"×"})]})}u.TelegramAuth=D,u.TelegramSignInButton=C,u.Toaster=z,u.useTelegramLogin=w,u.useToaster=S,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface Toast {
|
|
2
|
+
id?: number;
|
|
2
3
|
title: string;
|
|
3
4
|
description: string;
|
|
4
5
|
level?: 'Error' | 'Warn' | 'Info';
|
|
@@ -7,6 +8,6 @@ export interface Toast {
|
|
|
7
8
|
export interface ToasterStore {
|
|
8
9
|
toasts: Toast[];
|
|
9
10
|
bake: (t: Toast) => void;
|
|
10
|
-
dismiss: (
|
|
11
|
+
dismiss: (id: number) => void;
|
|
11
12
|
}
|
|
12
13
|
export declare const useToaster: import('zustand').UseBoundStore<import('zustand').StoreApi<ToasterStore>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vervstack/chures",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "React components and hooks for Telegram OAuth login and toast notifications",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"demo": "vite",
|
|
39
39
|
"build:demo": "vite build --config vite.config.demo.ts",
|
|
40
40
|
"type-check": "tsc --noEmit",
|
|
41
|
-
"patch": "npm version patch && npm publish --access public"
|
|
41
|
+
"patch": "npm run build && npm version patch && npm publish --access public"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": "^18.0.0 || ^19.0.0",
|