@draftlab/auth 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/allow.d.ts +58 -1
- package/dist/allow.js +61 -2
- package/dist/client.d.ts +2 -3
- package/dist/client.js +2 -2
- package/dist/core.d.ts +128 -8
- package/dist/core.js +496 -12
- package/dist/error.d.ts +242 -1
- package/dist/error.js +235 -1
- package/dist/index.d.ts +1 -8
- package/dist/index.js +1 -12
- package/dist/keys.d.ts +1 -1
- package/dist/keys.js +138 -3
- package/dist/pkce.js +160 -1
- package/dist/provider/code.d.ts +211 -3
- package/dist/provider/code.js +1 -1
- package/dist/provider/facebook.d.ts +2 -3
- package/dist/provider/facebook.js +1 -5
- package/dist/provider/github.d.ts +2 -3
- package/dist/provider/github.js +1 -5
- package/dist/provider/google.d.ts +2 -3
- package/dist/provider/google.js +1 -5
- package/dist/provider/oauth2.d.ts +175 -3
- package/dist/provider/oauth2.js +153 -5
- package/dist/provider/password.d.ts +384 -3
- package/dist/provider/password.js +4 -4
- package/dist/provider/provider.d.ts +226 -2
- package/dist/random.js +85 -1
- package/dist/storage/memory.d.ts +1 -1
- package/dist/storage/memory.js +1 -1
- package/dist/storage/storage.d.ts +161 -1
- package/dist/storage/storage.js +60 -1
- package/dist/storage/turso.d.ts +1 -1
- package/dist/storage/turso.js +1 -1
- package/dist/storage/unstorage.d.ts +1 -1
- package/dist/storage/unstorage.js +1 -1
- package/dist/subject.d.ts +61 -2
- package/dist/themes/theme.d.ts +208 -1
- package/dist/themes/theme.js +118 -1
- package/dist/ui/base.js +420 -2
- package/dist/ui/code.d.ts +1 -3
- package/dist/ui/code.js +3 -4
- package/dist/ui/form.js +59 -1
- package/dist/ui/icon.js +190 -1
- package/dist/ui/password.d.ts +1 -3
- package/dist/ui/password.js +2 -3
- package/dist/ui/select.js +278 -4
- package/dist/util.d.ts +71 -1
- package/dist/util.js +106 -1
- package/package.json +2 -4
- package/dist/allow-CixonwTW.d.ts +0 -59
- package/dist/allow-DX5cehSc.js +0 -63
- package/dist/base-DRutbxgL.js +0 -422
- package/dist/code-DJxdFR7p.d.ts +0 -212
- package/dist/core-BZHEAefX.d.ts +0 -129
- package/dist/core-CDM5o4rs.js +0 -498
- package/dist/error-CWAdNAzm.d.ts +0 -243
- package/dist/error-DgAKK7b2.js +0 -237
- package/dist/form-6XKM_cOk.js +0 -61
- package/dist/icon-Ci5uqGB_.js +0 -192
- package/dist/keys-EEfxEGfO.js +0 -140
- package/dist/oauth2-B7-6Z7Lc.js +0 -155
- package/dist/oauth2-CXHukHf2.d.ts +0 -176
- package/dist/password-C4KLmO0O.d.ts +0 -385
- package/dist/pkce-276Za_rZ.js +0 -162
- package/dist/provider-tndlqCzp.d.ts +0 -227
- package/dist/random-SXMYlaVr.js +0 -87
- package/dist/select-BjySLL8I.js +0 -280
- package/dist/storage-BEaqEPNQ.js +0 -62
- package/dist/storage-CxKerLlc.d.ts +0 -162
- package/dist/subject-DMIMVtaT.d.ts +0 -62
- package/dist/theme-C9by7VXf.d.ts +0 -209
- package/dist/theme-CswaLtbW.js +0 -120
- package/dist/util-CSdHUFOo.js +0 -108
- package/dist/util-DbSKG1Xm.d.ts +0 -72
package/dist/ui/base.js
CHANGED
|
@@ -1,4 +1,422 @@
|
|
|
1
|
-
import "../theme
|
|
2
|
-
import { Layout } from "../base-DRutbxgL.js";
|
|
1
|
+
import { getTheme } from "../themes/theme.js";
|
|
3
2
|
|
|
3
|
+
//#region src/ui/base.ts
|
|
4
|
+
const css = `@import url("https://unpkg.com/tailwindcss@3.4.15/src/css/preflight.css");
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
--color-background-dark: #0e0e11;
|
|
8
|
+
--color-background-light: #ffffff;
|
|
9
|
+
--color-primary-dark: #6772e5;
|
|
10
|
+
--color-primary-light: #6772e5;
|
|
11
|
+
|
|
12
|
+
--color-background-success-dark: oklch(0.3 0.04 172);
|
|
13
|
+
--color-background-success-light: oklch(
|
|
14
|
+
from var(--color-background-success-dark) 0.83 c h
|
|
15
|
+
);
|
|
16
|
+
--color-success-dark: oklch(
|
|
17
|
+
from var(--color-background-success-dark) 0.92 c h
|
|
18
|
+
);
|
|
19
|
+
--color-success-light: oklch(
|
|
20
|
+
from var(--color-background-success-dark) 0.25 c h
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
--color-background-error-dark: oklch(0.32 0.07 15);
|
|
24
|
+
--color-background-error-light: oklch(
|
|
25
|
+
from var(--color-background-error-dark) 0.92 c h
|
|
26
|
+
);
|
|
27
|
+
--color-error-dark: oklch(from var(--color-background-error-dark) 0.92 c h);
|
|
28
|
+
--color-error-light: oklch(from var(--color-background-error-dark) 0.25 c h);
|
|
29
|
+
|
|
30
|
+
--border-radius: 0;
|
|
31
|
+
|
|
32
|
+
--color-background: var(--color-background-dark);
|
|
33
|
+
--color-primary: var(--color-primary-dark);
|
|
34
|
+
|
|
35
|
+
--color-background-success: var(--color-background-success-dark);
|
|
36
|
+
--color-success: var(--color-success-dark);
|
|
37
|
+
--color-background-error: var(--color-background-error-dark);
|
|
38
|
+
--color-error: var(--color-error-dark);
|
|
39
|
+
|
|
40
|
+
@media (prefers-color-scheme: light) {
|
|
41
|
+
--color-background: var(--color-background-light);
|
|
42
|
+
--color-primary: var(--color-primary-light);
|
|
43
|
+
|
|
44
|
+
--color-background-success: var(--color-background-success-light);
|
|
45
|
+
--color-success: var(--color-success-light);
|
|
46
|
+
--color-background-error: var(--color-background-error-light);
|
|
47
|
+
--color-error: var(--color-error-light);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
--color-high: oklch(
|
|
51
|
+
from var(--color-background) clamp(0, calc((l - 0.714) * -1000), 1) 0 0
|
|
52
|
+
);
|
|
53
|
+
--color-low: oklch(
|
|
54
|
+
from var(--color-background) clamp(0, calc((l - 0.714) * 1000), 1) 0 0
|
|
55
|
+
);
|
|
56
|
+
--lightness-high: color-mix(
|
|
57
|
+
in oklch,
|
|
58
|
+
var(--color-high) 0%,
|
|
59
|
+
oklch(var(--color-high) 0 0)
|
|
60
|
+
);
|
|
61
|
+
--lightness-low: color-mix(
|
|
62
|
+
in oklch,
|
|
63
|
+
var(--color-low) 0%,
|
|
64
|
+
oklch(var(--color-low) 0 0)
|
|
65
|
+
);
|
|
66
|
+
--font-family:
|
|
67
|
+
ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
|
|
68
|
+
"Segoe UI Symbol", "Noto Color Emoji";
|
|
69
|
+
--font-scale: 1;
|
|
70
|
+
|
|
71
|
+
--font-size-xs: calc(0.75rem * var(--font-scale));
|
|
72
|
+
--font-size-sm: calc(0.875rem * var(--font-scale));
|
|
73
|
+
--font-size-md: calc(1rem * var(--font-scale));
|
|
74
|
+
--font-size-lg: calc(1.125rem * var(--font-scale));
|
|
75
|
+
--font-size-xl: calc(1.25rem * var(--font-scale));
|
|
76
|
+
--font-size-2xl: calc(1.5rem * var(--font-scale));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-component="root"] {
|
|
80
|
+
font-family: var(--font-family);
|
|
81
|
+
background-color: var(--color-background);
|
|
82
|
+
padding: 1rem;
|
|
83
|
+
color: white;
|
|
84
|
+
position: absolute;
|
|
85
|
+
inset: 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
user-select: none;
|
|
91
|
+
color: var(--color-high);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[data-component="center"] {
|
|
95
|
+
width: 380px;
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
gap: 1.5rem;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
[data-component="center"][data-size="small"] {
|
|
102
|
+
width: 300px;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
[data-component="link"] {
|
|
106
|
+
text-decoration: underline;
|
|
107
|
+
text-underline-offset: 0.125rem;
|
|
108
|
+
font-weight: 600;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
[data-component="label"] {
|
|
112
|
+
display: flex;
|
|
113
|
+
gap: 0.75rem;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
font-size: var(--font-size-xs);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
[data-component="logo"] {
|
|
119
|
+
margin: 0 auto;
|
|
120
|
+
height: 2.5rem;
|
|
121
|
+
width: auto;
|
|
122
|
+
display: none;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@media (prefers-color-scheme: light) {
|
|
126
|
+
[data-component="logo"][data-mode="light"] {
|
|
127
|
+
display: block;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media (prefers-color-scheme: dark) {
|
|
132
|
+
[data-component="logo"][data-mode="dark"] {
|
|
133
|
+
display: block;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
[data-component="logo-default"] {
|
|
138
|
+
margin: 0 auto;
|
|
139
|
+
height: 2.5rem;
|
|
140
|
+
width: auto;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@media (prefers-color-scheme: light) {
|
|
144
|
+
[data-component="logo-default"] {
|
|
145
|
+
color: var(--color-high);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@media (prefers-color-scheme: dark) {
|
|
150
|
+
[data-component="logo-default"] {
|
|
151
|
+
color: var(--color-high);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[data-component="input"] {
|
|
156
|
+
width: 100%;
|
|
157
|
+
height: 2.5rem;
|
|
158
|
+
padding: 0 1rem;
|
|
159
|
+
border: 1px solid transparent;
|
|
160
|
+
--background: oklch(
|
|
161
|
+
from var(--color-background)
|
|
162
|
+
calc(l + (-0.06 * clamp(0, calc((l - 0.714) * 1000), 1) + 0.03)) c h
|
|
163
|
+
);
|
|
164
|
+
background: var(--background);
|
|
165
|
+
border-color: oklch(
|
|
166
|
+
from var(--color-background)
|
|
167
|
+
calc(
|
|
168
|
+
clamp(
|
|
169
|
+
0.22,
|
|
170
|
+
l +
|
|
171
|
+
(-0.12 * clamp(0, calc((l - 0.714) * 1000), 1) + 0.06),
|
|
172
|
+
0.88
|
|
173
|
+
)
|
|
174
|
+
)
|
|
175
|
+
c h
|
|
176
|
+
);
|
|
177
|
+
border-radius: calc(var(--border-radius) * 0.25rem);
|
|
178
|
+
font-size: var(--font-size-sm);
|
|
179
|
+
outline: none;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[data-component="input"]:focus {
|
|
183
|
+
border-color: oklch(
|
|
184
|
+
from var(--color-background)
|
|
185
|
+
calc(
|
|
186
|
+
clamp(
|
|
187
|
+
0.3,
|
|
188
|
+
l +
|
|
189
|
+
(-0.2 * clamp(0, calc((l - 0.714) * 1000), 1) + 0.1),
|
|
190
|
+
0.7
|
|
191
|
+
)
|
|
192
|
+
)
|
|
193
|
+
c h
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
[data-component="input"]:user-invalid:not(:focus) {
|
|
198
|
+
border-color: oklch(0.4 0.09 7.91);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
[data-component="button"] {
|
|
202
|
+
height: 2.5rem;
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
border: 0;
|
|
205
|
+
font-weight: 500;
|
|
206
|
+
font-size: var(--font-size-sm);
|
|
207
|
+
border-radius: calc(var(--border-radius) * 0.25rem);
|
|
208
|
+
display: flex;
|
|
209
|
+
gap: 0.75rem;
|
|
210
|
+
align-items: center;
|
|
211
|
+
justify-content: center;
|
|
212
|
+
background: var(--color-primary);
|
|
213
|
+
color: oklch(
|
|
214
|
+
from var(--color-primary) clamp(0, calc((l - 0.714) * -1000), 1) 0 0
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
[data-component="button"][data-color="ghost"] {
|
|
219
|
+
background: transparent;
|
|
220
|
+
color: var(--color-high);
|
|
221
|
+
border: 1px solid
|
|
222
|
+
oklch(
|
|
223
|
+
from var(--color-background)
|
|
224
|
+
calc(
|
|
225
|
+
clamp(
|
|
226
|
+
0.22,
|
|
227
|
+
l +
|
|
228
|
+
(-0.12 * clamp(0, calc((l - 0.714) * 1000), 1) + 0.06),
|
|
229
|
+
0.88
|
|
230
|
+
)
|
|
231
|
+
)
|
|
232
|
+
c h
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
[data-component="button"] [data-slot="icon"] {
|
|
237
|
+
width: 16px;
|
|
238
|
+
height: 16px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
[data-component="button"] [data-slot="icon"] svg {
|
|
242
|
+
width: 100%;
|
|
243
|
+
height: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
[data-component="form"] {
|
|
247
|
+
max-width: 100%;
|
|
248
|
+
display: flex;
|
|
249
|
+
flex-direction: column;
|
|
250
|
+
gap: 1rem;
|
|
251
|
+
margin: 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
[data-component="form-alert"] {
|
|
255
|
+
height: 2.5rem;
|
|
256
|
+
display: flex;
|
|
257
|
+
align-items: center;
|
|
258
|
+
padding: 0 1rem;
|
|
259
|
+
border-radius: calc(var(--border-radius) * 0.25rem);
|
|
260
|
+
background: var(--color-background-error);
|
|
261
|
+
color: var(--color-error);
|
|
262
|
+
text-align: left;
|
|
263
|
+
font-size: 0.75rem;
|
|
264
|
+
gap: 0.5rem;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
[data-component="form-alert"][data-color="success"] {
|
|
268
|
+
background: var(--color-background-success);
|
|
269
|
+
color: var(--color-success);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[data-component="form-alert"][data-color="success"] [data-slot="icon-success"] {
|
|
273
|
+
display: block;
|
|
274
|
+
}
|
|
275
|
+
[data-component="form-alert"][data-color="success"] [data-slot="icon-danger"] {
|
|
276
|
+
display: none;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
[data-component="form-alert"]:has([data-slot="message"]:empty) {
|
|
280
|
+
display: none;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
[data-component="form-alert"] [data-slot="icon-success"],
|
|
284
|
+
[data-component="form-alert"] [data-slot="icon-danger"] {
|
|
285
|
+
width: 1rem;
|
|
286
|
+
height: 1rem;
|
|
287
|
+
}
|
|
288
|
+
[data-component="form-alert"] [data-slot="icon-success"] {
|
|
289
|
+
display: none;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
[data-component="form-footer"] {
|
|
293
|
+
display: flex;
|
|
294
|
+
gap: 1rem;
|
|
295
|
+
font-size: 0.75rem;
|
|
296
|
+
align-items: center;
|
|
297
|
+
justify-content: center;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
[data-component="form-footer"]:has(> :nth-child(2)) {
|
|
301
|
+
justify-content: space-between;
|
|
302
|
+
}
|
|
303
|
+
`;
|
|
304
|
+
/**
|
|
305
|
+
* Main layout component that wraps all authentication UI screens.
|
|
306
|
+
* Handles theming, logo display, and provides consistent styling.
|
|
307
|
+
*
|
|
308
|
+
* @param props - Layout props including children and optional size
|
|
309
|
+
* @returns Complete HTML document as a string with theming and branding applied
|
|
310
|
+
*/
|
|
311
|
+
const Layout = (props) => {
|
|
312
|
+
const theme = getTheme();
|
|
313
|
+
/**
|
|
314
|
+
* Gets a theme value for a specific key and color mode.
|
|
315
|
+
* Handles both string values and light/dark object configurations.
|
|
316
|
+
*/
|
|
317
|
+
const getThemeValue = (key, mode) => {
|
|
318
|
+
if (!theme?.[key]) return;
|
|
319
|
+
if (typeof theme[key] === "string") return theme[key];
|
|
320
|
+
return theme[key][mode];
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Calculates border radius value based on theme configuration.
|
|
324
|
+
*/
|
|
325
|
+
const getBorderRadius = () => {
|
|
326
|
+
switch (theme?.radius) {
|
|
327
|
+
case "none": return "0";
|
|
328
|
+
case "sm": return "1";
|
|
329
|
+
case "md": return "1.25";
|
|
330
|
+
case "lg": return "1.5";
|
|
331
|
+
case "full": return "1000000000001";
|
|
332
|
+
default: return "1";
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Checks if both light and dark logo variants are available.
|
|
337
|
+
*/
|
|
338
|
+
const hasCustomLogo = Boolean(getThemeValue("logo", "light") && getThemeValue("logo", "dark"));
|
|
339
|
+
/**
|
|
340
|
+
* CSS custom properties for theming.
|
|
341
|
+
*/
|
|
342
|
+
const themeStyles = [
|
|
343
|
+
`--color-background-light: ${getThemeValue("background", "light") || ""}`,
|
|
344
|
+
`--color-background-dark: ${getThemeValue("background", "dark") || ""}`,
|
|
345
|
+
`--color-primary-light: ${getThemeValue("primary", "light") || ""}`,
|
|
346
|
+
`--color-primary-dark: ${getThemeValue("primary", "dark") || ""}`,
|
|
347
|
+
`--font-family: ${theme?.font?.family || ""}`,
|
|
348
|
+
`--font-scale: ${theme?.font?.scale || ""}`,
|
|
349
|
+
`--border-radius: ${getBorderRadius()}`
|
|
350
|
+
].join("; ");
|
|
351
|
+
const faviconHtml = theme?.favicon ? `<link href="${theme.favicon}" rel="icon" />` : `
|
|
352
|
+
<link href="https://openauth.js.org/favicon.ico" rel="icon" sizes="48x48" />
|
|
353
|
+
<link href="https://openauth.js.org/favicon.svg" media="(prefers-color-scheme: light)" rel="icon" />
|
|
354
|
+
<link href="https://openauth.js.org/favicon-dark.svg" media="(prefers-color-scheme: dark)" rel="icon" />
|
|
355
|
+
<link href="https://openauth.js.org/favicon.svg" rel="shortcut icon" type="image/svg+xml" />
|
|
356
|
+
`;
|
|
357
|
+
const logoHtml = hasCustomLogo ? `
|
|
358
|
+
<img
|
|
359
|
+
alt="Logo Light"
|
|
360
|
+
data-component="logo"
|
|
361
|
+
data-mode="light"
|
|
362
|
+
src="${getThemeValue("logo", "light") || ""}"
|
|
363
|
+
/>
|
|
364
|
+
<img
|
|
365
|
+
alt="Logo Dark"
|
|
366
|
+
data-component="logo"
|
|
367
|
+
data-mode="dark"
|
|
368
|
+
src="${getThemeValue("logo", "dark") || ""}"
|
|
369
|
+
/>
|
|
370
|
+
` : DefaultDraftAuthLogo();
|
|
371
|
+
const childrenHtml = props.children || "";
|
|
372
|
+
return `
|
|
373
|
+
<!DOCTYPE html>
|
|
374
|
+
<html lang="en" style="${themeStyles}">
|
|
375
|
+
<head>
|
|
376
|
+
<title>${theme?.title || "Draft Auth"}</title>
|
|
377
|
+
<meta charset="utf-8" />
|
|
378
|
+
<meta content="width=device-width, initial-scale=1" name="viewport" />
|
|
379
|
+
|
|
380
|
+
${faviconHtml}
|
|
381
|
+
|
|
382
|
+
<!-- Base CSS styles -->
|
|
383
|
+
<style>${css}</style>
|
|
384
|
+
|
|
385
|
+
<!-- Custom theme CSS if provided -->
|
|
386
|
+
${theme?.css ? `<style>${theme.css}</style>` : ""}
|
|
387
|
+
</head>
|
|
388
|
+
<body>
|
|
389
|
+
<div data-component="root">
|
|
390
|
+
<div data-component="center" data-size="${props.size || ""}">
|
|
391
|
+
${logoHtml}
|
|
392
|
+
${childrenHtml}
|
|
393
|
+
</div>
|
|
394
|
+
</div>
|
|
395
|
+
</body>
|
|
396
|
+
</html>
|
|
397
|
+
`;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Default Draft Auth logo component.
|
|
401
|
+
* Used when no custom logo is provided in the theme configuration.
|
|
402
|
+
*/
|
|
403
|
+
const DefaultDraftAuthLogo = () => `
|
|
404
|
+
<svg
|
|
405
|
+
aria-label="Draft Auth Logo"
|
|
406
|
+
data-component="logo-default"
|
|
407
|
+
fill="none"
|
|
408
|
+
height="51"
|
|
409
|
+
viewBox="0 0 51 51"
|
|
410
|
+
width="51"
|
|
411
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
412
|
+
>
|
|
413
|
+
<title>Draft Auth Logo</title>
|
|
414
|
+
<path
|
|
415
|
+
d="M0 50.2303V0.12854H50.1017V50.2303H0ZM3.08002 11.8326H11.7041V3.20856H3.08002V11.8326ZM14.8526 11.8326H23.4766V3.20856H14.8526V11.8326ZM26.5566 11.8326H35.1807V3.20856H26.5566V11.8326ZM38.3292 11.8326H47.0217V3.20856H38.3292V11.8326ZM3.08002 23.6052H11.7041V14.9811H3.08002V23.6052ZM14.8526 23.6052H23.4766V14.9811H14.8526V23.6052ZM26.5566 23.6052H35.1807V14.9811H26.5566V23.6052ZM38.3292 23.6052H47.0217V14.9811H38.3292V23.6052ZM3.08002 35.3092H11.7041V26.6852H3.08002V35.3092ZM14.8526 35.3092H23.4766V26.6852H14.8526V35.3092ZM26.5566 35.3092H35.1807V26.6852H26.5566V35.3092ZM38.3292 35.3092H47.0217V26.6852H38.3292V35.3092ZM3.08002 47.1502H11.7041V38.3893H3.08002V47.1502ZM14.8526 47.1502H23.4766V38.3893H14.8526V47.1502ZM26.5566 47.1502H35.1807V38.3893H26.5566V47.1502ZM38.3292 47.1502H47.0217V38.3893H38.3292V47.1502Z"
|
|
416
|
+
fill="currentColor"
|
|
417
|
+
/>
|
|
418
|
+
</svg>
|
|
419
|
+
`;
|
|
420
|
+
|
|
421
|
+
//#endregion
|
|
4
422
|
export { Layout };
|
package/dist/ui/code.d.ts
CHANGED
package/dist/ui/code.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UnknownStateError } from "../error
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import { FormAlert } from "../form-6XKM_cOk.js";
|
|
1
|
+
import { UnknownStateError } from "../error.js";
|
|
2
|
+
import { Layout } from "./base.js";
|
|
3
|
+
import { FormAlert } from "./form.js";
|
|
5
4
|
|
|
6
5
|
//#region src/ui/code.ts
|
|
7
6
|
/**
|
package/dist/ui/form.js
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/ui/form.ts
|
|
2
|
+
/**
|
|
3
|
+
* Success icon component showing a checkmark in a circle.
|
|
4
|
+
* Used for positive feedback messages.
|
|
5
|
+
*/
|
|
6
|
+
const SuccessIcon = () => `
|
|
7
|
+
<svg
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
data-slot="icon-success"
|
|
10
|
+
fill="none"
|
|
11
|
+
stroke="currentColor"
|
|
12
|
+
stroke-width="1.5"
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
>
|
|
16
|
+
<path
|
|
17
|
+
d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
|
|
18
|
+
stroke-linecap="round"
|
|
19
|
+
stroke-linejoin="round"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
`;
|
|
23
|
+
/**
|
|
24
|
+
* Danger icon component showing an exclamation mark in a circle.
|
|
25
|
+
* Used for error and warning messages.
|
|
26
|
+
*/
|
|
27
|
+
const DangerIcon = () => `
|
|
28
|
+
<svg
|
|
29
|
+
aria-hidden="true"
|
|
30
|
+
data-slot="icon-danger"
|
|
31
|
+
fill="none"
|
|
32
|
+
stroke="currentColor"
|
|
33
|
+
stroke-width="1.5"
|
|
34
|
+
viewBox="0 0 24 24"
|
|
35
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
36
|
+
>
|
|
37
|
+
<path
|
|
38
|
+
d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z"
|
|
39
|
+
stroke-linecap="round"
|
|
40
|
+
stroke-linejoin="round"
|
|
41
|
+
/>
|
|
42
|
+
</svg>
|
|
43
|
+
`;
|
|
44
|
+
/**
|
|
45
|
+
* Form alert component that displays error or success messages.
|
|
46
|
+
* Returns an HTML string for the alert or empty string if no message.
|
|
47
|
+
*/
|
|
48
|
+
const FormAlert = (props) => {
|
|
49
|
+
if (!props.message) return "";
|
|
50
|
+
const alertColor = props.color ?? "danger";
|
|
51
|
+
return `
|
|
52
|
+
<div aria-live="polite" data-color="${alertColor}" data-component="form-alert" role="alert">
|
|
53
|
+
${SuccessIcon()}
|
|
54
|
+
${DangerIcon()}
|
|
55
|
+
<span data-slot="message">${props.message}</span>
|
|
56
|
+
</div>
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
2
59
|
|
|
60
|
+
//#endregion
|
|
3
61
|
export { FormAlert };
|
package/dist/ui/icon.js
CHANGED
|
@@ -1,3 +1,192 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/ui/icon.ts
|
|
2
|
+
/**
|
|
3
|
+
* Icon components for Draft Auth UI.
|
|
4
|
+
* Provides SVG icons for various authentication providers and common UI elements.
|
|
5
|
+
*
|
|
6
|
+
* ## Usage
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { ICON_GITHUB, ICON_GOOGLE, ICON_EMAIL } from "./icon"
|
|
10
|
+
*
|
|
11
|
+
* // In provider buttons
|
|
12
|
+
* const buttonHtml = `
|
|
13
|
+
* <button>
|
|
14
|
+
* ${ICON_GITHUB}
|
|
15
|
+
* Continue with GitHub
|
|
16
|
+
* </button>
|
|
17
|
+
* `
|
|
18
|
+
*
|
|
19
|
+
* // In form elements
|
|
20
|
+
* const formHtml = `
|
|
21
|
+
* <div>
|
|
22
|
+
* ${ICON_EMAIL}
|
|
23
|
+
* Email verification
|
|
24
|
+
* </div>
|
|
25
|
+
* `
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ## Features
|
|
29
|
+
*
|
|
30
|
+
* - **Consistent sizing**: All icons are properly sized and scalable
|
|
31
|
+
* - **Accessibility**: Proper ARIA labels and semantic markup
|
|
32
|
+
* - **Current color**: Icons inherit text color for easy theming
|
|
33
|
+
* - **Optimized SVGs**: Clean, minimal SVG markup for performance
|
|
34
|
+
*
|
|
35
|
+
* @packageDocumentation
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* GitHub brand icon with official logo design.
|
|
39
|
+
* Used for GitHub authentication provider buttons and references.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const buttonHtml = `
|
|
44
|
+
* <button data-component="provider-button">
|
|
45
|
+
* ${ICON_GITHUB}
|
|
46
|
+
* Sign in with GitHub
|
|
47
|
+
* </button>
|
|
48
|
+
* `
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
const ICON_GITHUB = `
|
|
52
|
+
<svg
|
|
53
|
+
aria-label="GitHub"
|
|
54
|
+
fill="currentColor"
|
|
55
|
+
height="250"
|
|
56
|
+
preserveAspectRatio="xMidYMid"
|
|
57
|
+
role="img"
|
|
58
|
+
viewBox="0 0 256 250"
|
|
59
|
+
width="256"
|
|
60
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
61
|
+
>
|
|
62
|
+
<path d="M128.001 0C57.317 0 0 57.307 0 128.001c0 56.554 36.676 104.535 87.535 121.46 6.397 1.185 8.746-2.777 8.746-6.158 0-3.052-.12-13.135-.174-23.83-35.61 7.742-43.124-15.103-43.124-15.103-5.823-14.795-14.213-18.73-14.213-18.73-11.613-7.944.876-7.78.876-7.78 12.853.902 19.621 13.19 19.621 13.19 11.417 19.568 29.945 13.911 37.249 10.64 1.149-8.272 4.466-13.92 8.127-17.116-28.431-3.236-58.318-14.212-58.318-63.258 0-13.975 5-25.394 13.188-34.358-1.329-3.224-5.71-16.242 1.24-33.874 0 0 10.749-3.44 35.21 13.121 10.21-2.836 21.16-4.258 32.038-4.307 10.878.049 21.837 1.47 32.066 4.307 24.431-16.56 35.165-13.12 35.165-13.12 6.967 17.63 2.584 30.65 1.255 33.873 8.207 8.964 13.173 20.383 13.173 34.358 0 49.163-29.944 59.988-58.447 63.157 4.591 3.972 8.682 11.762 8.682 23.704 0 17.126-.148 30.91-.148 35.126 0 3.407 2.304 7.398 8.792 6.14C219.37 232.5 256 184.537 256 128.002 256 57.307 198.691 0 128.001 0Zm-80.06 182.34c-.282.636-1.283.827-2.194.39-.929-.417-1.45-1.284-1.15-1.922.276-.655 1.279-.838 2.205-.399.93.418 1.46 1.293 1.139 1.931Zm6.296 5.618c-.61.566-1.804.303-2.614-.591-.837-.892-.994-2.086-.375-2.66.63-.566 1.787-.301 2.626.591.838.903 1 2.088.363 2.66Zm4.32 7.188c-.785.545-2.067.034-2.86-1.104-.784-1.138-.784-2.503.017-3.05.795-.547 2.058-.055 2.861 1.075.782 1.157.782 2.522-.019 3.08Zm7.304 8.325c-.701.774-2.196.566-3.29-.49-1.119-1.032-1.43-2.496-.726-3.27.71-.776 2.213-.558 3.315.49 1.11 1.03 1.45 2.505.701 3.27Zm9.442 2.81c-.31 1.003-1.75 1.459-3.199 1.033-1.448-.439-2.395-1.613-2.103-2.626.301-1.01 1.747-1.484 3.207-1.028 1.446.436 2.396 1.602 2.095 2.622Zm10.744 1.193c.036 1.055-1.193 1.93-2.715 1.95-1.53.034-2.769-.82-2.786-1.86 0-1.065 1.202-1.932 2.733-1.958 1.522-.03 2.768.818 2.768 1.868Zm10.555-.405c.182 1.03-.875 2.088-2.387 2.37-1.485.271-2.861-.365-3.05-1.386-.184-1.056.893-2.114 2.376-2.387 1.514-.263 2.868.356 3.061 1.403Z" />
|
|
63
|
+
</svg>
|
|
64
|
+
`;
|
|
65
|
+
/**
|
|
66
|
+
* Google brand icon with official multicolor logo design.
|
|
67
|
+
* Used for Google authentication provider buttons and references.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const buttonHtml = `
|
|
72
|
+
* <button data-component="provider-button">
|
|
73
|
+
* ${ICON_GOOGLE}
|
|
74
|
+
* Continue with Google
|
|
75
|
+
* </button>
|
|
76
|
+
* `
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
const ICON_GOOGLE = `
|
|
80
|
+
<svg
|
|
81
|
+
aria-label="Google"
|
|
82
|
+
height="262"
|
|
83
|
+
preserveAspectRatio="xMidYMid"
|
|
84
|
+
role="img"
|
|
85
|
+
viewBox="0 0 256 262"
|
|
86
|
+
width="256"
|
|
87
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
88
|
+
>
|
|
89
|
+
<path
|
|
90
|
+
d="M255.878 133.451c0-10.734-.871-18.567-2.756-26.69H130.55v48.448h71.947c-1.45 12.04-9.283 30.172-26.69 42.356l-.244 1.622 38.755 30.023 2.685.268c24.659-22.774 38.875-56.282 38.875-96.027"
|
|
91
|
+
fill="#4285F4"
|
|
92
|
+
/>
|
|
93
|
+
<path
|
|
94
|
+
d="M130.55 261.1c35.248 0 64.839-11.605 86.453-31.622l-41.196-31.913c-11.024 7.688-25.82 13.055-45.257 13.055-34.523 0-63.824-22.773-74.269-54.25l-1.531.13-40.298 31.187-.527 1.465C35.393 231.798 79.49 261.1 130.55 261.1"
|
|
95
|
+
fill="#34A853"
|
|
96
|
+
/>
|
|
97
|
+
<path
|
|
98
|
+
d="M56.281 156.37c-2.756-8.123-4.351-16.827-4.351-25.82 0-8.994 1.595-17.697 4.206-25.82l-.073-1.73L15.26 71.312l-1.335.635C5.077 89.644 0 109.517 0 130.55s5.077 40.905 13.925 58.602l42.356-32.782"
|
|
99
|
+
fill="#FBBC05"
|
|
100
|
+
/>
|
|
101
|
+
<path
|
|
102
|
+
d="M130.55 50.479c24.514 0 41.05 10.589 50.479 19.438l36.844-35.974C195.245 12.91 165.798 0 130.55 0 79.49 0 35.393 29.301 13.925 71.947l42.211 32.783c10.59-31.477 39.891-54.251 74.414-54.251"
|
|
103
|
+
fill="#EB4335"
|
|
104
|
+
/>
|
|
105
|
+
</svg>
|
|
106
|
+
`;
|
|
107
|
+
/**
|
|
108
|
+
* Email envelope icon for email-related authentication flows.
|
|
109
|
+
* Used in email verification, password reset, and contact forms.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* const inputGroupHtml = `
|
|
114
|
+
* <div data-component="input-group">
|
|
115
|
+
* ${ICON_EMAIL}
|
|
116
|
+
* <input type="email" placeholder="Enter your email" />
|
|
117
|
+
* </div>
|
|
118
|
+
* `
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
const ICON_EMAIL = `
|
|
122
|
+
<svg
|
|
123
|
+
aria-label="Email"
|
|
124
|
+
fill="none"
|
|
125
|
+
role="img"
|
|
126
|
+
stroke="currentColor"
|
|
127
|
+
stroke-width="1.5"
|
|
128
|
+
viewBox="0 0 24 24"
|
|
129
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
130
|
+
>
|
|
131
|
+
<path
|
|
132
|
+
d="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75"
|
|
133
|
+
stroke-linecap="round"
|
|
134
|
+
stroke-linejoin="round"
|
|
135
|
+
/>
|
|
136
|
+
</svg>
|
|
137
|
+
`;
|
|
138
|
+
/**
|
|
139
|
+
* Slack brand icon with official logo design.
|
|
140
|
+
* Used for Slack authentication provider buttons and workplace integrations.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* const buttonHtml = `
|
|
145
|
+
* <button data-component="provider-button">
|
|
146
|
+
* ${ICON_SLACK}
|
|
147
|
+
* Continue with Slack
|
|
148
|
+
* </button>
|
|
149
|
+
* `
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
const ICON_SLACK = `
|
|
153
|
+
<svg
|
|
154
|
+
aria-label="Slack"
|
|
155
|
+
fill="none"
|
|
156
|
+
height="24"
|
|
157
|
+
role="img"
|
|
158
|
+
viewBox="0 0 24 24"
|
|
159
|
+
width="24"
|
|
160
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
161
|
+
>
|
|
162
|
+
<g>
|
|
163
|
+
<path
|
|
164
|
+
clip-rule="evenodd"
|
|
165
|
+
d="M8.79948 0C7.47279 0.000978593 6.39909 1.07547 6.40007 2.39951C6.39909 3.72355 7.47377 4.79804 8.80046 4.79902H11.2009V2.40049C11.2018 1.07645 10.1271 0.00195719 8.79948 0ZM8.79948 6.4H2.40039C1.07371 6.40098 -0.000977873 7.47547 2.67973e-06 8.79951C-0.00195842 10.1235 1.07273 11.198 2.39941 11.2H8.79948C10.1262 11.199 11.2009 10.1245 11.1999 8.80049C11.2009 7.47547 10.1262 6.40098 8.79948 6.4Z"
|
|
166
|
+
fill="currentColor"
|
|
167
|
+
fill-rule="evenodd"
|
|
168
|
+
/>
|
|
169
|
+
<path
|
|
170
|
+
clip-rule="evenodd"
|
|
171
|
+
d="M24.0007 8.79951C24.0016 7.47547 22.9269 6.40098 21.6003 6.4C20.2736 6.40098 19.1989 7.47547 19.1999 8.79951V11.2H21.6003C22.9269 11.199 24.0016 10.1245 24.0007 8.79951ZM17.6006 8.79951V2.39951C17.6016 1.07645 16.5279 0.00195719 15.2012 0C13.8745 0.000978593 12.7998 1.07547 12.8008 2.39951V8.79951C12.7988 10.1235 13.8735 11.198 15.2002 11.2C16.5269 11.199 17.6016 10.1245 17.6006 8.79951Z"
|
|
172
|
+
fill="currentColor"
|
|
173
|
+
fill-rule="evenodd"
|
|
174
|
+
/>
|
|
175
|
+
<path
|
|
176
|
+
clip-rule="evenodd"
|
|
177
|
+
d="M15.1992 23.9998C16.5259 23.9988 17.6006 22.9243 17.5996 21.6003C17.6006 20.2763 16.5259 19.2018 15.1992 19.2008H12.7988V21.6003C12.7978 22.9234 13.8725 23.9978 15.1992 23.9998ZM15.1992 17.5988H21.5993C22.926 17.5978 24.0007 16.5234 23.9997 15.1993C24.0016 13.8753 22.927 12.8008 21.6003 12.7988H15.2002C13.8735 12.7998 12.7988 13.8743 12.7998 15.1983C12.7988 16.5234 13.8725 17.5978 15.1992 17.5988Z"
|
|
178
|
+
fill="currentColor"
|
|
179
|
+
fill-rule="evenodd"
|
|
180
|
+
/>
|
|
181
|
+
<path
|
|
182
|
+
clip-rule="evenodd"
|
|
183
|
+
d="M0 15.1993C-0.000979882 16.5234 1.07371 17.5978 2.40039 17.5988C3.72708 17.5978 4.80177 16.5234 4.80079 15.1993V12.7998H2.40039C1.07371 12.8008 -0.000979882 13.8753 0 15.1993ZM6.40007 15.1993V21.5993C6.3981 22.9234 7.47279 23.9978 8.79948 23.9998C10.1262 23.9988 11.2009 22.9243 11.1999 21.6003V15.2013C11.2018 13.8772 10.1271 12.8027 8.80046 12.8008C7.47279 12.8008 6.39909 13.8753 6.40007 15.1993Z"
|
|
184
|
+
fill="currentColor"
|
|
185
|
+
fill-rule="evenodd"
|
|
186
|
+
/>
|
|
187
|
+
</g>
|
|
188
|
+
</svg>
|
|
189
|
+
`;
|
|
2
190
|
|
|
191
|
+
//#endregion
|
|
3
192
|
export { ICON_EMAIL, ICON_GITHUB, ICON_GOOGLE, ICON_SLACK };
|