@sublimee/auth-ui 0.1.1 → 0.1.13
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/AI_INDEX.md +64 -0
- package/README.md +80 -120
- package/dist/animations.css +52 -0
- package/dist/index.d.mts +59 -42
- package/dist/index.d.ts +59 -42
- package/dist/index.js +443 -56
- package/dist/index.mjs +441 -54
- package/package.json +9 -6
- package/src/animations.css +52 -0
- package/src/base-button.stories.tsx +96 -0
- package/src/base-button.tsx +124 -0
- package/src/button-loading-indicator.tsx +33 -0
- package/src/icons.tsx +17 -24
- package/src/index.ts +25 -19
- package/src/oauth-button.stories.tsx +72 -333
- package/src/oauth-button.tsx +34 -79
- package/src/runtime-styles.ts +225 -0
- package/src/types.ts +66 -10
- package/src/use-button-animation.ts +114 -0
package/dist/index.js
CHANGED
|
@@ -23,12 +23,15 @@ __export(index_exports, {
|
|
|
23
23
|
DiscordIcon: () => DiscordIcon,
|
|
24
24
|
GoogleIcon: () => GoogleIcon,
|
|
25
25
|
OAuthButton: () => OAuthButton,
|
|
26
|
-
|
|
26
|
+
useButtonAnimation: () => useButtonAnimation
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(index_exports);
|
|
29
29
|
|
|
30
30
|
// src/oauth-button.tsx
|
|
31
|
-
var
|
|
31
|
+
var import_react4 = require("react");
|
|
32
|
+
|
|
33
|
+
// src/base-button.tsx
|
|
34
|
+
var import_react3 = require("react");
|
|
32
35
|
var import_button = require("@base-ui/react/button");
|
|
33
36
|
|
|
34
37
|
// src/icons.tsx
|
|
@@ -36,7 +39,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
36
39
|
function getSafeSize(size, defaultSize = 24) {
|
|
37
40
|
return Math.max(1, size ?? defaultSize);
|
|
38
41
|
}
|
|
39
|
-
function GoogleIcon({ size }) {
|
|
42
|
+
function GoogleIcon({ size, className }) {
|
|
40
43
|
const safeSize = getSafeSize(size);
|
|
41
44
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
42
45
|
"svg",
|
|
@@ -47,6 +50,7 @@ function GoogleIcon({ size }) {
|
|
|
47
50
|
fill: "none",
|
|
48
51
|
xmlns: "http://www.w3.org/2000/svg",
|
|
49
52
|
"aria-hidden": "true",
|
|
53
|
+
className,
|
|
50
54
|
children: [
|
|
51
55
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
52
56
|
"path",
|
|
@@ -80,7 +84,7 @@ function GoogleIcon({ size }) {
|
|
|
80
84
|
}
|
|
81
85
|
);
|
|
82
86
|
}
|
|
83
|
-
function DiscordIcon({ size }) {
|
|
87
|
+
function DiscordIcon({ size, className }) {
|
|
84
88
|
const safeSize = getSafeSize(size);
|
|
85
89
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
86
90
|
"svg",
|
|
@@ -91,6 +95,7 @@ function DiscordIcon({ size }) {
|
|
|
91
95
|
fill: "none",
|
|
92
96
|
xmlns: "http://www.w3.org/2000/svg",
|
|
93
97
|
"aria-hidden": "true",
|
|
98
|
+
className,
|
|
94
99
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
95
100
|
"path",
|
|
96
101
|
{
|
|
@@ -101,7 +106,7 @@ function DiscordIcon({ size }) {
|
|
|
101
106
|
}
|
|
102
107
|
);
|
|
103
108
|
}
|
|
104
|
-
function SpinnerIcon({ size }) {
|
|
109
|
+
function SpinnerIcon({ size, className }) {
|
|
105
110
|
const safeSize = getSafeSize(size, 20);
|
|
106
111
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
107
112
|
"svg",
|
|
@@ -112,39 +117,26 @@ function SpinnerIcon({ size }) {
|
|
|
112
117
|
fill: "none",
|
|
113
118
|
xmlns: "http://www.w3.org/2000/svg",
|
|
114
119
|
"aria-hidden": "true",
|
|
120
|
+
className,
|
|
115
121
|
children: [
|
|
116
122
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
117
123
|
"circle",
|
|
118
124
|
{
|
|
119
125
|
cx: "12",
|
|
120
126
|
cy: "12",
|
|
121
|
-
r: "
|
|
127
|
+
r: "9",
|
|
122
128
|
stroke: "currentColor",
|
|
123
|
-
strokeWidth: "
|
|
124
|
-
|
|
125
|
-
strokeDasharray: "60",
|
|
126
|
-
strokeDashoffset: "20",
|
|
127
|
-
opacity: "0.25"
|
|
129
|
+
strokeWidth: "3",
|
|
130
|
+
opacity: "0.22"
|
|
128
131
|
}
|
|
129
132
|
),
|
|
130
133
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
131
134
|
"path",
|
|
132
135
|
{
|
|
133
|
-
d: "M12
|
|
136
|
+
d: "M12 3a9 9 0 0 1 9 9",
|
|
134
137
|
stroke: "currentColor",
|
|
135
|
-
strokeWidth: "
|
|
136
|
-
strokeLinecap: "round"
|
|
137
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
138
|
-
"animateTransform",
|
|
139
|
-
{
|
|
140
|
-
attributeName: "transform",
|
|
141
|
-
type: "rotate",
|
|
142
|
-
from: "0 12 12",
|
|
143
|
-
to: "360 12 12",
|
|
144
|
-
dur: "1s",
|
|
145
|
-
repeatCount: "indefinite"
|
|
146
|
-
}
|
|
147
|
-
)
|
|
138
|
+
strokeWidth: "3",
|
|
139
|
+
strokeLinecap: "round"
|
|
148
140
|
}
|
|
149
141
|
)
|
|
150
142
|
]
|
|
@@ -152,8 +144,408 @@ function SpinnerIcon({ size }) {
|
|
|
152
144
|
);
|
|
153
145
|
}
|
|
154
146
|
|
|
155
|
-
// src/
|
|
147
|
+
// src/button-loading-indicator.tsx
|
|
156
148
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
149
|
+
function SpinnerLoadingIndicator({ size }) {
|
|
150
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SpinnerIcon, { size, className: "sublime-button__spinner" });
|
|
151
|
+
}
|
|
152
|
+
var LOADING_INDICATORS = {
|
|
153
|
+
spinner: SpinnerLoadingIndicator
|
|
154
|
+
};
|
|
155
|
+
function ButtonLoadingIndicator({
|
|
156
|
+
animation = "spinner",
|
|
157
|
+
size = 18
|
|
158
|
+
}) {
|
|
159
|
+
const LoadingIndicator = LOADING_INDICATORS[animation];
|
|
160
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(LoadingIndicator, { size });
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/use-button-animation.ts
|
|
164
|
+
var import_react = require("react");
|
|
165
|
+
var PRESS_RELEASE_DURATION = 180;
|
|
166
|
+
function useButtonAnimation(animation = "press") {
|
|
167
|
+
const [phase, setPhase] = (0, import_react.useState)("idle");
|
|
168
|
+
const timeoutRef = (0, import_react.useRef)(null);
|
|
169
|
+
const clearExistingTimeout = (0, import_react.useCallback)(() => {
|
|
170
|
+
if (timeoutRef.current) {
|
|
171
|
+
clearTimeout(timeoutRef.current);
|
|
172
|
+
timeoutRef.current = null;
|
|
173
|
+
}
|
|
174
|
+
}, []);
|
|
175
|
+
(0, import_react.useEffect)(() => {
|
|
176
|
+
return () => {
|
|
177
|
+
clearExistingTimeout();
|
|
178
|
+
};
|
|
179
|
+
}, [clearExistingTimeout]);
|
|
180
|
+
const handlePressStart = (0, import_react.useCallback)(() => {
|
|
181
|
+
if (!animation) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
clearExistingTimeout();
|
|
185
|
+
setPhase("pressed");
|
|
186
|
+
}, [animation, clearExistingTimeout]);
|
|
187
|
+
const handlePressEnd = (0, import_react.useCallback)(() => {
|
|
188
|
+
if (!animation || phase !== "pressed") {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
setPhase("releasing");
|
|
192
|
+
timeoutRef.current = setTimeout(() => {
|
|
193
|
+
setPhase("idle");
|
|
194
|
+
}, PRESS_RELEASE_DURATION);
|
|
195
|
+
}, [animation, phase]);
|
|
196
|
+
const handleBlur = (0, import_react.useCallback)(() => {
|
|
197
|
+
clearExistingTimeout();
|
|
198
|
+
setPhase("idle");
|
|
199
|
+
}, [clearExistingTimeout]);
|
|
200
|
+
const handleKeyDown = (0, import_react.useCallback)(
|
|
201
|
+
(event) => {
|
|
202
|
+
if (event.repeat) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (event.key === " " || event.key === "Enter") {
|
|
206
|
+
handlePressStart();
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
[handlePressStart]
|
|
210
|
+
);
|
|
211
|
+
const handleKeyUp = (0, import_react.useCallback)(
|
|
212
|
+
(event) => {
|
|
213
|
+
if (event.key === " " || event.key === "Enter") {
|
|
214
|
+
handlePressEnd();
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[handlePressEnd]
|
|
218
|
+
);
|
|
219
|
+
const getAnimationClass = () => {
|
|
220
|
+
if (!animation) {
|
|
221
|
+
return "";
|
|
222
|
+
}
|
|
223
|
+
if (phase === "pressed") {
|
|
224
|
+
return "sublime-button-pressed";
|
|
225
|
+
}
|
|
226
|
+
if (phase === "releasing") {
|
|
227
|
+
return "animate-sublime-button-press-release";
|
|
228
|
+
}
|
|
229
|
+
return "";
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
animationClassName: getAnimationClass(),
|
|
233
|
+
eventHandlers: {
|
|
234
|
+
onBlur: handleBlur,
|
|
235
|
+
onKeyDown: handleKeyDown,
|
|
236
|
+
onKeyUp: handleKeyUp,
|
|
237
|
+
onMouseDown: handlePressStart,
|
|
238
|
+
onMouseLeave: handlePressEnd,
|
|
239
|
+
onMouseUp: handlePressEnd,
|
|
240
|
+
onTouchEnd: handlePressEnd,
|
|
241
|
+
onTouchStart: handlePressStart
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// src/runtime-styles.ts
|
|
247
|
+
var import_react2 = require("react");
|
|
248
|
+
var AUTH_UI_RUNTIME_STYLE_ID = "sublime-auth-ui-runtime-styles";
|
|
249
|
+
var AUTH_UI_RUNTIME_STYLES = `
|
|
250
|
+
.sublime-button {
|
|
251
|
+
--sublime-button-gap: var(--sublime-space-3, 0.75rem);
|
|
252
|
+
--sublime-button-padding-x: var(--sublime-space-button-x, 1rem);
|
|
253
|
+
--sublime-button-padding-y: var(--sublime-space-button-y, 0.75rem);
|
|
254
|
+
--sublime-button-height: var(--sublime-size-button-height-md, 2.75rem);
|
|
255
|
+
--sublime-button-radius: var(--sublime-radius-button, 0.875rem);
|
|
256
|
+
--sublime-button-font-family: var(--sublime-font-family-sans, ui-sans-serif, system-ui, sans-serif);
|
|
257
|
+
--sublime-button-font-size: var(--sublime-font-size-sm, 0.875rem);
|
|
258
|
+
--sublime-button-font-weight: var(--sublime-font-weight-medium, 500);
|
|
259
|
+
--sublime-button-line-height: var(--sublime-line-height-tight, 1.15);
|
|
260
|
+
--sublime-button-visual-size: 1.25rem;
|
|
261
|
+
--sublime-button-transition: var(--sublime-transition-button, background-color 160ms cubic-bezier(0.4, 0, 0.2, 1), border-color 160ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 160ms cubic-bezier(0.4, 0, 0.2, 1), color 160ms cubic-bezier(0.4, 0, 0.2, 1), transform 160ms cubic-bezier(0.4, 0, 0.2, 1));
|
|
262
|
+
--sublime-button-bg: var(--sublime-color-surface-1, #ffffff);
|
|
263
|
+
--sublime-button-bg-hover: var(--sublime-color-surface-1-hover, #f8fafc);
|
|
264
|
+
--sublime-button-bg-active: var(--sublime-color-surface-1-active, #eef2f7);
|
|
265
|
+
--sublime-button-color: var(--sublime-color-text-primary, #111827);
|
|
266
|
+
--sublime-button-color-hover: var(--sublime-color-text-primary, #111827);
|
|
267
|
+
--sublime-button-border: var(--sublime-color-border-primary, #d1d5db);
|
|
268
|
+
--sublime-button-border-hover: var(--sublime-color-border-primary-hover, #9ca3af);
|
|
269
|
+
--sublime-button-border-active: var(--sublime-color-border-primary-active, #6b7280);
|
|
270
|
+
--sublime-button-shadow: var(--sublime-shadow-button, 0 1px 2px rgb(15 23 42 / 0.08));
|
|
271
|
+
--sublime-button-shadow-hover: var(--sublime-shadow-button-hover, 0 8px 20px rgb(15 23 42 / 0.12));
|
|
272
|
+
--sublime-button-shadow-active: var(--sublime-shadow-button-active, inset 0 1px 2px rgb(15 23 42 / 0.14));
|
|
273
|
+
--sublime-button-focus-ring: var(--sublime-color-focus-ring, var(--sublime-color-interactive-accent, #2563eb));
|
|
274
|
+
--sublime-button-focus-ring-offset: var(--sublime-color-focus-ring-offset, var(--sublime-color-surface-0, #ffffff));
|
|
275
|
+
position: relative;
|
|
276
|
+
display: inline-flex;
|
|
277
|
+
min-height: var(--sublime-button-height);
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
gap: var(--sublime-button-gap);
|
|
281
|
+
padding: var(--sublime-button-padding-y) var(--sublime-button-padding-x);
|
|
282
|
+
border: 1px solid var(--sublime-button-border);
|
|
283
|
+
border-radius: var(--sublime-button-radius);
|
|
284
|
+
background: var(--sublime-button-bg);
|
|
285
|
+
color: var(--sublime-button-color);
|
|
286
|
+
box-shadow: var(--sublime-button-shadow);
|
|
287
|
+
font-family: var(--sublime-button-font-family);
|
|
288
|
+
font-size: var(--sublime-button-font-size);
|
|
289
|
+
font-weight: var(--sublime-button-font-weight);
|
|
290
|
+
line-height: var(--sublime-button-line-height);
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
user-select: none;
|
|
293
|
+
text-decoration: none;
|
|
294
|
+
white-space: nowrap;
|
|
295
|
+
vertical-align: middle;
|
|
296
|
+
isolation: isolate;
|
|
297
|
+
overflow: hidden;
|
|
298
|
+
appearance: none;
|
|
299
|
+
-webkit-tap-highlight-color: transparent;
|
|
300
|
+
transition: var(--sublime-button-transition);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.sublime-button:hover:not(:disabled) {
|
|
304
|
+
background: var(--sublime-button-bg-hover);
|
|
305
|
+
color: var(--sublime-button-color-hover);
|
|
306
|
+
border-color: var(--sublime-button-border-hover);
|
|
307
|
+
box-shadow: var(--sublime-button-shadow-hover);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.sublime-button:active:not(:disabled) {
|
|
311
|
+
background: var(--sublime-button-bg-active);
|
|
312
|
+
border-color: var(--sublime-button-border-active);
|
|
313
|
+
box-shadow: var(--sublime-button-shadow-active);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.sublime-button:focus {
|
|
317
|
+
outline: none;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.sublime-button:focus-visible {
|
|
321
|
+
box-shadow:
|
|
322
|
+
0 0 0 2px var(--sublime-button-focus-ring-offset),
|
|
323
|
+
0 0 0 4px var(--sublime-button-focus-ring),
|
|
324
|
+
var(--sublime-button-shadow-hover);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.sublime-button:disabled {
|
|
328
|
+
cursor: not-allowed;
|
|
329
|
+
opacity: 0.6;
|
|
330
|
+
box-shadow: none;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.sublime-button[data-loading='true'] {
|
|
334
|
+
cursor: progress;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.sublime-button[data-loading='true']:disabled {
|
|
338
|
+
opacity: 0.78;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.sublime-button[data-icon-only='true'] {
|
|
342
|
+
min-width: var(--sublime-button-height);
|
|
343
|
+
padding-inline: calc(var(--sublime-button-padding-y) + 0.125rem);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.sublime-button__content {
|
|
347
|
+
display: inline-flex;
|
|
348
|
+
width: 100%;
|
|
349
|
+
align-items: center;
|
|
350
|
+
justify-content: center;
|
|
351
|
+
gap: inherit;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.sublime-button__visual,
|
|
355
|
+
.sublime-button__label {
|
|
356
|
+
display: inline-flex;
|
|
357
|
+
align-items: center;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.sublime-button__visual {
|
|
361
|
+
flex-shrink: 0;
|
|
362
|
+
justify-content: center;
|
|
363
|
+
min-width: var(--sublime-button-visual-size);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.sublime-button__visual svg {
|
|
367
|
+
display: block;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.sublime-button__label {
|
|
371
|
+
min-width: 0;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.sublime-button--primary {
|
|
375
|
+
--sublime-button-bg: var(--sublime-color-interactive-primary, #111827);
|
|
376
|
+
--sublime-button-bg-hover: var(--sublime-color-interactive-primary-hover, #1f2937);
|
|
377
|
+
--sublime-button-bg-active: var(--sublime-color-interactive-primary-active, #0f172a);
|
|
378
|
+
--sublime-button-color: var(--sublime-color-interactive-primary-text, #f9fafb);
|
|
379
|
+
--sublime-button-color-hover: var(--sublime-color-interactive-primary-text, #f9fafb);
|
|
380
|
+
--sublime-button-border: var(--sublime-color-interactive-primary, #111827);
|
|
381
|
+
--sublime-button-border-hover: var(--sublime-color-interactive-primary-hover, #1f2937);
|
|
382
|
+
--sublime-button-border-active: var(--sublime-color-interactive-primary-active, #0f172a);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.sublime-button--secondary {
|
|
386
|
+
--sublime-button-bg: var(--sublime-color-surface-1, #ffffff);
|
|
387
|
+
--sublime-button-bg-hover: var(--sublime-color-surface-1-hover, #f8fafc);
|
|
388
|
+
--sublime-button-bg-active: var(--sublime-color-surface-1-active, #eef2f7);
|
|
389
|
+
--sublime-button-color: var(--sublime-color-text-primary, #111827);
|
|
390
|
+
--sublime-button-color-hover: var(--sublime-color-text-primary, #111827);
|
|
391
|
+
--sublime-button-border: var(--sublime-color-border-primary, #d1d5db);
|
|
392
|
+
--sublime-button-border-hover: var(--sublime-color-border-primary-hover, #9ca3af);
|
|
393
|
+
--sublime-button-border-active: var(--sublime-color-border-primary-active, #6b7280);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.sublime-auth-button[data-provider='discord'] .sublime-button__visual {
|
|
397
|
+
color: #5865f2;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.sublime-auth-button[data-loading='true'] .sublime-button__visual {
|
|
401
|
+
color: currentColor;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
@keyframes sublime-button-press-release {
|
|
405
|
+
0% {
|
|
406
|
+
transform: translateY(1px) scale(0.985);
|
|
407
|
+
box-shadow: var(--sublime-button-shadow-active);
|
|
408
|
+
}
|
|
409
|
+
100% {
|
|
410
|
+
transform: translateY(0) scale(1);
|
|
411
|
+
box-shadow: var(--sublime-button-shadow);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@keyframes sublime-button-spinner {
|
|
416
|
+
from {
|
|
417
|
+
transform: rotate(0deg);
|
|
418
|
+
}
|
|
419
|
+
to {
|
|
420
|
+
transform: rotate(360deg);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.sublime-button-pressed {
|
|
425
|
+
transform: translateY(1px) scale(0.985);
|
|
426
|
+
box-shadow: var(--sublime-button-shadow-active);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.animate-sublime-button-press-release {
|
|
430
|
+
animation: sublime-button-press-release 180ms var(--sublime-ease-out, cubic-bezier(0, 0, 0.2, 1));
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.sublime-button__spinner {
|
|
434
|
+
animation: sublime-button-spinner 720ms linear infinite;
|
|
435
|
+
transform-origin: center;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
@media (prefers-reduced-motion: reduce) {
|
|
439
|
+
.sublime-button,
|
|
440
|
+
.animate-sublime-button-press-release {
|
|
441
|
+
animation-duration: 0.01ms !important;
|
|
442
|
+
animation-iteration-count: 1 !important;
|
|
443
|
+
transition-duration: 0.01ms !important;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
.sublime-button__spinner {
|
|
447
|
+
animation-duration: 1.6s !important;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
`;
|
|
451
|
+
function useAuthUiRuntimeStyles() {
|
|
452
|
+
(0, import_react2.useInsertionEffect)(() => {
|
|
453
|
+
if (typeof document === "undefined") {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
if (document.getElementById(AUTH_UI_RUNTIME_STYLE_ID)) {
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const styleElement = document.createElement("style");
|
|
460
|
+
styleElement.id = AUTH_UI_RUNTIME_STYLE_ID;
|
|
461
|
+
styleElement.textContent = AUTH_UI_RUNTIME_STYLES;
|
|
462
|
+
document.head.prepend(styleElement);
|
|
463
|
+
}, []);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/base-button.tsx
|
|
467
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
468
|
+
function mergeClassNames(...classNames) {
|
|
469
|
+
return classNames.filter(Boolean).join(" ");
|
|
470
|
+
}
|
|
471
|
+
function composeEventHandlers(internalHandler, externalHandler) {
|
|
472
|
+
if (!internalHandler) {
|
|
473
|
+
return externalHandler;
|
|
474
|
+
}
|
|
475
|
+
if (!externalHandler) {
|
|
476
|
+
return internalHandler;
|
|
477
|
+
}
|
|
478
|
+
return (event) => {
|
|
479
|
+
internalHandler(event);
|
|
480
|
+
externalHandler(event);
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
var BaseButton = (0, import_react3.forwardRef)(
|
|
484
|
+
function BaseButton2(props, forwardedRef) {
|
|
485
|
+
const {
|
|
486
|
+
animation = "press",
|
|
487
|
+
"aria-busy": ariaBusy,
|
|
488
|
+
children,
|
|
489
|
+
className,
|
|
490
|
+
disabled = false,
|
|
491
|
+
isIconOnly = false,
|
|
492
|
+
leadingVisual,
|
|
493
|
+
loading = false,
|
|
494
|
+
loadingAnimation = "spinner",
|
|
495
|
+
type = "button",
|
|
496
|
+
variant = "secondary",
|
|
497
|
+
onBlur,
|
|
498
|
+
onKeyDown,
|
|
499
|
+
onKeyUp,
|
|
500
|
+
onMouseDown,
|
|
501
|
+
onMouseLeave,
|
|
502
|
+
onMouseUp,
|
|
503
|
+
onTouchEnd,
|
|
504
|
+
onTouchStart,
|
|
505
|
+
...otherProps
|
|
506
|
+
} = props;
|
|
507
|
+
useAuthUiRuntimeStyles();
|
|
508
|
+
const { animationClassName, eventHandlers } = useButtonAnimation(
|
|
509
|
+
disabled || loading ? null : animation
|
|
510
|
+
);
|
|
511
|
+
const mergedClassName = mergeClassNames(
|
|
512
|
+
"sublime-button",
|
|
513
|
+
`sublime-button--${variant}`,
|
|
514
|
+
animationClassName,
|
|
515
|
+
className
|
|
516
|
+
);
|
|
517
|
+
const visualContent = loading ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ButtonLoadingIndicator, { animation: loadingAnimation, size: 18 }) : leadingVisual ?? (isIconOnly ? children : void 0);
|
|
518
|
+
const labelContent = isIconOnly ? null : children;
|
|
519
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
520
|
+
import_button.Button,
|
|
521
|
+
{
|
|
522
|
+
ref: forwardedRef,
|
|
523
|
+
type,
|
|
524
|
+
disabled: disabled || loading,
|
|
525
|
+
className: mergedClassName,
|
|
526
|
+
"data-icon-only": isIconOnly ? "true" : void 0,
|
|
527
|
+
"data-loading": loading ? "true" : void 0,
|
|
528
|
+
"aria-busy": loading ? true : ariaBusy,
|
|
529
|
+
...otherProps,
|
|
530
|
+
onBlur: composeEventHandlers(eventHandlers.onBlur, onBlur),
|
|
531
|
+
onKeyDown: composeEventHandlers(eventHandlers.onKeyDown, onKeyDown),
|
|
532
|
+
onKeyUp: composeEventHandlers(eventHandlers.onKeyUp, onKeyUp),
|
|
533
|
+
onMouseDown: composeEventHandlers(eventHandlers.onMouseDown, onMouseDown),
|
|
534
|
+
onMouseLeave: composeEventHandlers(eventHandlers.onMouseLeave, onMouseLeave),
|
|
535
|
+
onMouseUp: composeEventHandlers(eventHandlers.onMouseUp, onMouseUp),
|
|
536
|
+
onTouchEnd: composeEventHandlers(eventHandlers.onTouchEnd, onTouchEnd),
|
|
537
|
+
onTouchStart: composeEventHandlers(eventHandlers.onTouchStart, onTouchStart),
|
|
538
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: "sublime-button__content", children: [
|
|
539
|
+
visualContent ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sublime-button__visual", children: visualContent }) : null,
|
|
540
|
+
labelContent !== null && labelContent !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sublime-button__label", children: labelContent }) : null
|
|
541
|
+
] })
|
|
542
|
+
}
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
);
|
|
546
|
+
|
|
547
|
+
// src/oauth-button.tsx
|
|
548
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
157
549
|
var PROVIDER_NAMES = {
|
|
158
550
|
google: "Google",
|
|
159
551
|
discord: "Discord"
|
|
@@ -162,51 +554,46 @@ var PROVIDER_ICONS = {
|
|
|
162
554
|
google: GoogleIcon,
|
|
163
555
|
discord: DiscordIcon
|
|
164
556
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
const userClasses = userClassName?.trim() ?? "";
|
|
168
|
-
const neededDefaults = SENSIBLE_DEFAULTS.filter(
|
|
169
|
-
(defaultClass) => !userClasses.includes(defaultClass)
|
|
170
|
-
);
|
|
171
|
-
if (isDisabled && !userClasses.includes("cursor-not-allowed")) {
|
|
172
|
-
neededDefaults.push("cursor-not-allowed");
|
|
173
|
-
}
|
|
174
|
-
if (neededDefaults.length === 0) {
|
|
175
|
-
return userClasses;
|
|
176
|
-
}
|
|
177
|
-
return `${neededDefaults.join(" ")} ${userClasses}`.trim();
|
|
557
|
+
function mergeClassNames2(...classNames) {
|
|
558
|
+
return classNames.filter(Boolean).join(" ");
|
|
178
559
|
}
|
|
179
|
-
var OAuthButton = (0,
|
|
560
|
+
var OAuthButton = (0, import_react4.forwardRef)(
|
|
180
561
|
function OAuthButton2(props, forwardedRef) {
|
|
181
562
|
const {
|
|
563
|
+
"aria-label": ariaLabel,
|
|
182
564
|
provider,
|
|
183
565
|
onClick,
|
|
184
566
|
loading = false,
|
|
567
|
+
loadingAnimation = "spinner",
|
|
568
|
+
disabled = false,
|
|
569
|
+
variant = "secondary",
|
|
570
|
+
animation = "press",
|
|
185
571
|
className,
|
|
186
572
|
children,
|
|
187
|
-
disabled = false,
|
|
188
573
|
...otherProps
|
|
189
574
|
} = props;
|
|
190
|
-
const
|
|
575
|
+
const isIconOnly = children === null;
|
|
191
576
|
const Icon = PROVIDER_ICONS[provider];
|
|
192
577
|
const defaultText = `Continuar con ${PROVIDER_NAMES[provider]}`;
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
578
|
+
const buttonLabel = loading ? children ?? "Conectando..." : children ?? defaultText;
|
|
579
|
+
const resolvedAriaLabel = ariaLabel ?? (isIconOnly ? defaultText : void 0);
|
|
580
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
581
|
+
BaseButton,
|
|
196
582
|
{
|
|
197
583
|
ref: forwardedRef,
|
|
198
584
|
onClick,
|
|
199
|
-
disabled
|
|
200
|
-
|
|
201
|
-
|
|
585
|
+
disabled,
|
|
586
|
+
animation,
|
|
587
|
+
variant,
|
|
588
|
+
loading,
|
|
589
|
+
loadingAnimation,
|
|
590
|
+
isIconOnly,
|
|
591
|
+
leadingVisual: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { size: 20 }),
|
|
592
|
+
className: mergeClassNames2("sublime-auth-button", className),
|
|
593
|
+
"data-provider": provider,
|
|
594
|
+
"aria-label": resolvedAriaLabel,
|
|
202
595
|
...otherProps,
|
|
203
|
-
children:
|
|
204
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SpinnerIcon, {}),
|
|
205
|
-
children !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: children ?? "Conectando..." })
|
|
206
|
-
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
207
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, {}),
|
|
208
|
-
children !== null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: children ?? defaultText })
|
|
209
|
-
] })
|
|
596
|
+
children: buttonLabel
|
|
210
597
|
}
|
|
211
598
|
);
|
|
212
599
|
}
|
|
@@ -216,5 +603,5 @@ var OAuthButton = (0, import_react.forwardRef)(
|
|
|
216
603
|
DiscordIcon,
|
|
217
604
|
GoogleIcon,
|
|
218
605
|
OAuthButton,
|
|
219
|
-
|
|
606
|
+
useButtonAnimation
|
|
220
607
|
});
|