@dudousxd/adonis-authkit-react 0.1.2 → 0.3.0
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/README.md +26 -0
- package/build/index.d.ts +47 -0
- package/build/index.js +24 -0
- package/build/src/authkit_provider.d.ts +13 -0
- package/build/src/authkit_provider.js +11 -0
- package/build/src/components/authorized_apps.d.ts +8 -0
- package/build/src/components/authorized_apps.js +26 -0
- package/build/src/components/avatar.d.ts +22 -0
- package/build/src/components/avatar.js +15 -0
- package/build/src/components/organization_profile.d.ts +8 -0
- package/build/src/components/organization_profile.js +87 -0
- package/build/src/components/organization_switcher.d.ts +7 -0
- package/build/src/components/organization_switcher.js +57 -0
- package/build/src/components/password_strength_meter.d.ts +11 -0
- package/build/src/components/password_strength_meter.js +39 -0
- package/build/src/components/sign_in_button.d.ts +297 -0
- package/build/src/components/sign_in_button.js +16 -0
- package/build/src/components/sign_out_button.d.ts +296 -0
- package/build/src/components/sign_out_button.js +16 -0
- package/build/src/components/user_button.d.ts +8 -0
- package/build/src/components/user_button.js +31 -0
- package/build/src/components/user_profile.d.ts +6 -0
- package/build/src/components/user_profile.js +27 -0
- package/build/src/config.d.ts +27 -0
- package/build/src/config.js +40 -0
- package/build/src/hooks/use_authorized_apps.d.ts +16 -0
- package/build/src/hooks/use_authorized_apps.js +15 -0
- package/build/src/hooks/use_org_invitations.d.ts +19 -0
- package/build/src/hooks/use_org_invitations.js +20 -0
- package/build/src/hooks/use_organization.d.ts +23 -0
- package/build/src/hooks/use_organization.js +8 -0
- package/build/src/hooks/use_organizations.d.ts +18 -0
- package/build/src/hooks/use_organizations.js +14 -0
- package/build/src/hooks/use_password_strength.d.ts +11 -0
- package/build/src/hooks/use_password_strength.js +34 -0
- package/build/src/hooks/use_profile.d.ts +13 -0
- package/build/src/hooks/use_profile.js +28 -0
- package/build/src/hooks/use_resource.d.ts +11 -0
- package/build/src/hooks/use_resource.js +48 -0
- package/build/src/hooks/use_sessions.d.ts +16 -0
- package/build/src/hooks/use_sessions.js +15 -0
- package/build/src/hooks/use_sign_in.d.ts +6 -0
- package/build/src/hooks/use_sign_in.js +13 -0
- package/build/src/hooks/use_sign_out.d.ts +6 -0
- package/build/src/hooks/use_sign_out.js +11 -0
- package/build/src/hooks/use_switch_organization.d.ts +7 -0
- package/build/src/hooks/use_switch_organization.js +42 -0
- package/build/src/hooks/use_user.d.ts +6 -0
- package/build/src/hooks/use_user.js +5 -0
- package/build/src/use_auth.js +1 -1
- package/build/src/utils.d.ts +2 -0
- package/build/src/utils.js +18 -0
- package/package.json +9 -7
- package/styles.css +294 -0
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/adonis-authkit-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Frontend ergonomics over AuthKit for AdonisJS + Inertia + React apps: a typed useAuth() hook, role-gating hooks and gating components.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "dudousxd",
|
|
7
|
-
"homepage": "https://github.com/DavideCarvalho/
|
|
7
|
+
"homepage": "https://github.com/DavideCarvalho/adonis-authkit/tree/main/packages/authkit-react#readme",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/DavideCarvalho/
|
|
10
|
+
"url": "https://github.com/DavideCarvalho/adonis-authkit.git",
|
|
11
11
|
"directory": "packages/authkit-react"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/DavideCarvalho/
|
|
14
|
+
"url": "https://github.com/DavideCarvalho/adonis-authkit/issues"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"adonisjs",
|
|
@@ -29,11 +29,13 @@
|
|
|
29
29
|
"main": "./build/index.js",
|
|
30
30
|
"types": "./build/index.d.ts",
|
|
31
31
|
"files": [
|
|
32
|
-
"build"
|
|
32
|
+
"build",
|
|
33
|
+
"styles.css"
|
|
33
34
|
],
|
|
34
35
|
"exports": {
|
|
35
36
|
".": "./build/index.js",
|
|
36
|
-
"./types": "./build/index.js"
|
|
37
|
+
"./types": "./build/index.js",
|
|
38
|
+
"./styles.css": "./styles.css"
|
|
37
39
|
},
|
|
38
40
|
"peerDependencies": {
|
|
39
41
|
"@inertiajs/react": "3.3.0",
|
|
@@ -41,7 +43,7 @@
|
|
|
41
43
|
"react-dom": "19.2.6"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
|
-
"@dudousxd/adonis-authkit-core": "0.
|
|
46
|
+
"@dudousxd/adonis-authkit-core": "0.3.0"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
49
|
"@adonisjs/tsconfig": "2.0.0",
|
package/styles.css
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Estilos prontos dos componentes do @dudousxd/adonis-authkit-react.
|
|
3
|
+
* Temáveis via CSS vars `--authkit-*` (defaults Adonis-violet).
|
|
4
|
+
* Importe em algum ponto da app: `import '@dudousxd/adonis-authkit-react/styles.css'`
|
|
5
|
+
*/
|
|
6
|
+
:root {
|
|
7
|
+
--authkit-primary: #5a45ff;
|
|
8
|
+
--authkit-primary-contrast: #ffffff;
|
|
9
|
+
--authkit-danger: #e5484d;
|
|
10
|
+
--authkit-fg: #1a1523;
|
|
11
|
+
--authkit-muted: #6f6e77;
|
|
12
|
+
--authkit-bg: #ffffff;
|
|
13
|
+
--authkit-border: #e4e2e8;
|
|
14
|
+
--authkit-radius: 8px;
|
|
15
|
+
--authkit-gap: 0.5rem;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.authkit-button {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
gap: 0.4rem;
|
|
23
|
+
padding: 0.5rem 0.9rem;
|
|
24
|
+
font: inherit;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
border-radius: var(--authkit-radius);
|
|
27
|
+
border: 1px solid transparent;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
line-height: 1.2;
|
|
30
|
+
}
|
|
31
|
+
.authkit-button:disabled {
|
|
32
|
+
opacity: 0.6;
|
|
33
|
+
cursor: not-allowed;
|
|
34
|
+
}
|
|
35
|
+
.authkit-button--primary {
|
|
36
|
+
background: var(--authkit-primary);
|
|
37
|
+
color: var(--authkit-primary-contrast);
|
|
38
|
+
}
|
|
39
|
+
.authkit-button--ghost {
|
|
40
|
+
background: transparent;
|
|
41
|
+
color: var(--authkit-fg);
|
|
42
|
+
border-color: var(--authkit-border);
|
|
43
|
+
}
|
|
44
|
+
.authkit-button--danger {
|
|
45
|
+
background: transparent;
|
|
46
|
+
color: var(--authkit-danger);
|
|
47
|
+
border-color: var(--authkit-border);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.authkit-avatar {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
border-radius: 50%;
|
|
55
|
+
background: var(--authkit-primary);
|
|
56
|
+
color: var(--authkit-primary-contrast);
|
|
57
|
+
font-weight: 600;
|
|
58
|
+
font-size: 0.85rem;
|
|
59
|
+
object-fit: cover;
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.authkit-userbutton {
|
|
64
|
+
position: relative;
|
|
65
|
+
display: inline-block;
|
|
66
|
+
}
|
|
67
|
+
.authkit-userbutton__trigger {
|
|
68
|
+
background: none;
|
|
69
|
+
border: none;
|
|
70
|
+
padding: 0;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
.authkit-userbutton__menu {
|
|
74
|
+
position: absolute;
|
|
75
|
+
right: 0;
|
|
76
|
+
margin-top: 0.4rem;
|
|
77
|
+
min-width: 12rem;
|
|
78
|
+
background: var(--authkit-bg);
|
|
79
|
+
border: 1px solid var(--authkit-border);
|
|
80
|
+
border-radius: var(--authkit-radius);
|
|
81
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
|
|
82
|
+
padding: 0.3rem;
|
|
83
|
+
z-index: 50;
|
|
84
|
+
}
|
|
85
|
+
.authkit-userbutton__header {
|
|
86
|
+
padding: 0.5rem 0.6rem;
|
|
87
|
+
border-bottom: 1px solid var(--authkit-border);
|
|
88
|
+
margin-bottom: 0.3rem;
|
|
89
|
+
}
|
|
90
|
+
.authkit-userbutton__name {
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
color: var(--authkit-fg);
|
|
93
|
+
}
|
|
94
|
+
.authkit-userbutton__email {
|
|
95
|
+
font-size: 0.8rem;
|
|
96
|
+
color: var(--authkit-muted);
|
|
97
|
+
}
|
|
98
|
+
.authkit-userbutton__item {
|
|
99
|
+
display: block;
|
|
100
|
+
width: 100%;
|
|
101
|
+
text-align: left;
|
|
102
|
+
padding: 0.5rem 0.6rem;
|
|
103
|
+
background: none;
|
|
104
|
+
border: none;
|
|
105
|
+
border-radius: 6px;
|
|
106
|
+
color: var(--authkit-fg);
|
|
107
|
+
text-decoration: none;
|
|
108
|
+
font: inherit;
|
|
109
|
+
cursor: pointer;
|
|
110
|
+
}
|
|
111
|
+
.authkit-userbutton__item:hover {
|
|
112
|
+
background: rgba(90, 69, 255, 0.08);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.authkit-card {
|
|
116
|
+
background: var(--authkit-bg);
|
|
117
|
+
border: 1px solid var(--authkit-border);
|
|
118
|
+
border-radius: var(--authkit-radius);
|
|
119
|
+
padding: 1rem;
|
|
120
|
+
}
|
|
121
|
+
.authkit-profile__header {
|
|
122
|
+
display: flex;
|
|
123
|
+
align-items: center;
|
|
124
|
+
gap: 0.75rem;
|
|
125
|
+
margin-bottom: 1rem;
|
|
126
|
+
}
|
|
127
|
+
.authkit-profile__name {
|
|
128
|
+
font-weight: 600;
|
|
129
|
+
color: var(--authkit-fg);
|
|
130
|
+
}
|
|
131
|
+
.authkit-profile__email {
|
|
132
|
+
font-size: 0.85rem;
|
|
133
|
+
color: var(--authkit-muted);
|
|
134
|
+
}
|
|
135
|
+
.authkit-profile__form {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: var(--authkit-gap);
|
|
139
|
+
}
|
|
140
|
+
.authkit-label {
|
|
141
|
+
font-size: 0.85rem;
|
|
142
|
+
color: var(--authkit-muted);
|
|
143
|
+
}
|
|
144
|
+
.authkit-input {
|
|
145
|
+
padding: 0.5rem 0.6rem;
|
|
146
|
+
border: 1px solid var(--authkit-border);
|
|
147
|
+
border-radius: var(--authkit-radius);
|
|
148
|
+
font: inherit;
|
|
149
|
+
}
|
|
150
|
+
.authkit-error {
|
|
151
|
+
color: var(--authkit-danger);
|
|
152
|
+
font-size: 0.85rem;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.authkit-apps {
|
|
156
|
+
list-style: none;
|
|
157
|
+
margin: 0;
|
|
158
|
+
padding: 0;
|
|
159
|
+
display: flex;
|
|
160
|
+
flex-direction: column;
|
|
161
|
+
gap: var(--authkit-gap);
|
|
162
|
+
}
|
|
163
|
+
.authkit-apps__item {
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
justify-content: space-between;
|
|
167
|
+
padding: 0.6rem 0.75rem;
|
|
168
|
+
border: 1px solid var(--authkit-border);
|
|
169
|
+
border-radius: var(--authkit-radius);
|
|
170
|
+
}
|
|
171
|
+
.authkit-apps__info {
|
|
172
|
+
display: flex;
|
|
173
|
+
align-items: center;
|
|
174
|
+
gap: 0.5rem;
|
|
175
|
+
}
|
|
176
|
+
.authkit-apps__logo {
|
|
177
|
+
width: 24px;
|
|
178
|
+
height: 24px;
|
|
179
|
+
border-radius: 4px;
|
|
180
|
+
}
|
|
181
|
+
.authkit-apps__name {
|
|
182
|
+
font-weight: 500;
|
|
183
|
+
color: var(--authkit-fg);
|
|
184
|
+
}
|
|
185
|
+
.authkit-apps__empty,
|
|
186
|
+
.authkit-apps__loading {
|
|
187
|
+
color: var(--authkit-muted);
|
|
188
|
+
font-size: 0.9rem;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* Medidor de força de senha (PasswordStrengthMeter). */
|
|
192
|
+
.authkit-strength {
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
gap: 0.35rem;
|
|
196
|
+
}
|
|
197
|
+
.authkit-strength__bar {
|
|
198
|
+
display: flex;
|
|
199
|
+
gap: 0.25rem;
|
|
200
|
+
}
|
|
201
|
+
.authkit-strength__segment {
|
|
202
|
+
flex: 1 1 0;
|
|
203
|
+
height: 5px;
|
|
204
|
+
border-radius: 999px;
|
|
205
|
+
background: var(--authkit-border);
|
|
206
|
+
transition: background-color 0.15s ease;
|
|
207
|
+
}
|
|
208
|
+
/* Cor por score, do mais fraco ao mais forte (via data-score no bar). */
|
|
209
|
+
.authkit-strength__bar[data-score='1'] .authkit-strength__segment--filled {
|
|
210
|
+
background: var(--authkit-danger);
|
|
211
|
+
}
|
|
212
|
+
.authkit-strength__bar[data-score='2'] .authkit-strength__segment--filled {
|
|
213
|
+
background: #f5a524;
|
|
214
|
+
}
|
|
215
|
+
.authkit-strength__bar[data-score='3'] .authkit-strength__segment--filled {
|
|
216
|
+
background: #d6c20a;
|
|
217
|
+
}
|
|
218
|
+
.authkit-strength__bar[data-score='4'] .authkit-strength__segment--filled {
|
|
219
|
+
background: #2fb344;
|
|
220
|
+
}
|
|
221
|
+
.authkit-strength__label {
|
|
222
|
+
font-size: 0.8rem;
|
|
223
|
+
color: var(--authkit-muted);
|
|
224
|
+
}
|
|
225
|
+
.authkit-strength__feedback {
|
|
226
|
+
margin: 0;
|
|
227
|
+
padding-left: 1.1rem;
|
|
228
|
+
font-size: 0.8rem;
|
|
229
|
+
color: var(--authkit-muted);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/* ─── OrganizationSwitcher ─────────────────────────────────────────────── */
|
|
233
|
+
.authkit-orgswitcher {
|
|
234
|
+
position: relative;
|
|
235
|
+
display: inline-block;
|
|
236
|
+
}
|
|
237
|
+
.authkit-orgswitcher__trigger {
|
|
238
|
+
display: inline-flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
gap: 0.4rem;
|
|
241
|
+
padding: 0.4rem 0.75rem;
|
|
242
|
+
background: var(--authkit-bg);
|
|
243
|
+
border: 1px solid var(--authkit-border);
|
|
244
|
+
border-radius: var(--authkit-radius);
|
|
245
|
+
cursor: pointer;
|
|
246
|
+
font-size: 0.875rem;
|
|
247
|
+
color: var(--authkit-fg);
|
|
248
|
+
}
|
|
249
|
+
.authkit-orgswitcher__trigger:disabled { opacity: 0.6; cursor: default; }
|
|
250
|
+
.authkit-orgswitcher__chevron { font-size: 0.65rem; color: var(--authkit-muted); }
|
|
251
|
+
.authkit-orgswitcher__menu {
|
|
252
|
+
position: absolute;
|
|
253
|
+
top: calc(100% + 4px);
|
|
254
|
+
left: 0;
|
|
255
|
+
min-width: 180px;
|
|
256
|
+
background: var(--authkit-bg);
|
|
257
|
+
border: 1px solid var(--authkit-border);
|
|
258
|
+
border-radius: var(--authkit-radius);
|
|
259
|
+
box-shadow: 0 4px 16px rgba(0,0,0,.1);
|
|
260
|
+
z-index: 50;
|
|
261
|
+
overflow: hidden;
|
|
262
|
+
}
|
|
263
|
+
.authkit-orgswitcher__item {
|
|
264
|
+
display: flex;
|
|
265
|
+
align-items: center;
|
|
266
|
+
justify-content: space-between;
|
|
267
|
+
width: 100%;
|
|
268
|
+
padding: 0.5rem 1rem;
|
|
269
|
+
background: transparent;
|
|
270
|
+
border: none;
|
|
271
|
+
cursor: pointer;
|
|
272
|
+
font-size: 0.875rem;
|
|
273
|
+
color: var(--authkit-fg);
|
|
274
|
+
text-align: left;
|
|
275
|
+
}
|
|
276
|
+
.authkit-orgswitcher__item:hover { background: color-mix(in srgb, var(--authkit-primary) 8%, transparent); }
|
|
277
|
+
.authkit-orgswitcher__item--active { font-weight: 600; }
|
|
278
|
+
.authkit-orgswitcher__item-name { flex: 1; }
|
|
279
|
+
.authkit-orgswitcher__item-role { font-size: 0.75rem; color: var(--authkit-muted); margin-left: 0.5rem; }
|
|
280
|
+
|
|
281
|
+
/* ─── OrganizationProfile ──────────────────────────────────────────────── */
|
|
282
|
+
.authkit-org-profile { display: flex; flex-direction: column; gap: var(--authkit-gap); }
|
|
283
|
+
.authkit-org-profile__header { margin-bottom: 0.5rem; }
|
|
284
|
+
.authkit-org-profile__name { font-weight: 600; font-size: 1rem; color: var(--authkit-fg); }
|
|
285
|
+
.authkit-org-profile__slug { font-size: 0.8rem; color: var(--authkit-muted); }
|
|
286
|
+
.authkit-org-profile__section-title { font-size: 0.85rem; font-weight: 600; color: var(--authkit-fg); margin-bottom: 0.4rem; }
|
|
287
|
+
.authkit-org-profile__members { display: flex; flex-direction: column; gap: 0.25rem; }
|
|
288
|
+
.authkit-org-profile__member { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--authkit-border); }
|
|
289
|
+
.authkit-org-profile__member:last-child { border-bottom: none; }
|
|
290
|
+
.authkit-org-profile__member-info { display: flex; flex-direction: column; }
|
|
291
|
+
.authkit-org-profile__member-email { font-size: 0.875rem; color: var(--authkit-fg); }
|
|
292
|
+
.authkit-org-profile__member-role { font-size: 0.75rem; color: var(--authkit-muted); }
|
|
293
|
+
.authkit-org-profile__invite-form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.75rem; }
|
|
294
|
+
.authkit-org-profile__empty { font-size: 0.875rem; color: var(--authkit-muted); }
|