@greatapps/greatauth-ui 0.3.0 → 0.3.2
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/index.d.ts +1 -0
- package/dist/index.js +66 -150
- package/dist/index.js.map +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +2 -0
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/components/login-form.tsx +95 -56
- package/src/types/index.ts +1 -0
- package/src/ui.ts +2 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1150,7 +1150,7 @@ function AppShell({ config, children, renderAbove }) {
|
|
|
1150
1150
|
// src/components/login-form.tsx
|
|
1151
1151
|
import { useState as useState3 } from "react";
|
|
1152
1152
|
import { useRouter as useRouter2, useSearchParams } from "next/navigation";
|
|
1153
|
-
import { Loader2 } from "lucide-react";
|
|
1153
|
+
import { Loader2, Mail, Lock, AlertCircle } from "lucide-react";
|
|
1154
1154
|
|
|
1155
1155
|
// src/components/ui/label.tsx
|
|
1156
1156
|
import { Label as LabelPrimitive } from "radix-ui";
|
|
@@ -1172,115 +1172,8 @@ function Label({
|
|
|
1172
1172
|
);
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
|
-
// src/components/ui/card.tsx
|
|
1176
|
-
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1177
|
-
function Card({
|
|
1178
|
-
className,
|
|
1179
|
-
size = "default",
|
|
1180
|
-
...props
|
|
1181
|
-
}) {
|
|
1182
|
-
return /* @__PURE__ */ jsx18(
|
|
1183
|
-
"div",
|
|
1184
|
-
{
|
|
1185
|
-
"data-slot": "card",
|
|
1186
|
-
"data-size": size,
|
|
1187
|
-
className: cn("ring-foreground/10 bg-card text-card-foreground gap-6 overflow-hidden rounded-xl py-6 text-sm shadow-xs ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl group/card flex flex-col", className),
|
|
1188
|
-
...props
|
|
1189
|
-
}
|
|
1190
|
-
);
|
|
1191
|
-
}
|
|
1192
|
-
function CardHeader({ className, ...props }) {
|
|
1193
|
-
return /* @__PURE__ */ jsx18(
|
|
1194
|
-
"div",
|
|
1195
|
-
{
|
|
1196
|
-
"data-slot": "card-header",
|
|
1197
|
-
className: cn(
|
|
1198
|
-
"gap-1 rounded-t-xl px-6 group-data-[size=sm]/card:px-4 [.border-b]:pb-6 group-data-[size=sm]/card:[.border-b]:pb-4 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
|
|
1199
|
-
className
|
|
1200
|
-
),
|
|
1201
|
-
...props
|
|
1202
|
-
}
|
|
1203
|
-
);
|
|
1204
|
-
}
|
|
1205
|
-
function CardTitle({ className, ...props }) {
|
|
1206
|
-
return /* @__PURE__ */ jsx18(
|
|
1207
|
-
"div",
|
|
1208
|
-
{
|
|
1209
|
-
"data-slot": "card-title",
|
|
1210
|
-
className: cn("text-base leading-normal font-medium group-data-[size=sm]/card:text-sm", className),
|
|
1211
|
-
...props
|
|
1212
|
-
}
|
|
1213
|
-
);
|
|
1214
|
-
}
|
|
1215
|
-
function CardDescription({ className, ...props }) {
|
|
1216
|
-
return /* @__PURE__ */ jsx18(
|
|
1217
|
-
"div",
|
|
1218
|
-
{
|
|
1219
|
-
"data-slot": "card-description",
|
|
1220
|
-
className: cn("text-muted-foreground text-sm", className),
|
|
1221
|
-
...props
|
|
1222
|
-
}
|
|
1223
|
-
);
|
|
1224
|
-
}
|
|
1225
|
-
function CardContent({ className, ...props }) {
|
|
1226
|
-
return /* @__PURE__ */ jsx18(
|
|
1227
|
-
"div",
|
|
1228
|
-
{
|
|
1229
|
-
"data-slot": "card-content",
|
|
1230
|
-
className: cn("px-6 group-data-[size=sm]/card:px-4", className),
|
|
1231
|
-
...props
|
|
1232
|
-
}
|
|
1233
|
-
);
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
// src/components/ui/alert.tsx
|
|
1237
|
-
import { cva as cva4 } from "class-variance-authority";
|
|
1238
|
-
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1239
|
-
var alertVariants = cva4("grid gap-0.5 rounded-lg border px-4 py-3 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 w-full relative group/alert", {
|
|
1240
|
-
variants: {
|
|
1241
|
-
variant: {
|
|
1242
|
-
default: "bg-card text-card-foreground",
|
|
1243
|
-
destructive: "text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"
|
|
1244
|
-
}
|
|
1245
|
-
},
|
|
1246
|
-
defaultVariants: {
|
|
1247
|
-
variant: "default"
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1250
|
-
function Alert({
|
|
1251
|
-
className,
|
|
1252
|
-
variant,
|
|
1253
|
-
...props
|
|
1254
|
-
}) {
|
|
1255
|
-
return /* @__PURE__ */ jsx19(
|
|
1256
|
-
"div",
|
|
1257
|
-
{
|
|
1258
|
-
"data-slot": "alert",
|
|
1259
|
-
role: "alert",
|
|
1260
|
-
className: cn(alertVariants({ variant }), className),
|
|
1261
|
-
...props
|
|
1262
|
-
}
|
|
1263
|
-
);
|
|
1264
|
-
}
|
|
1265
|
-
function AlertDescription({
|
|
1266
|
-
className,
|
|
1267
|
-
...props
|
|
1268
|
-
}) {
|
|
1269
|
-
return /* @__PURE__ */ jsx19(
|
|
1270
|
-
"div",
|
|
1271
|
-
{
|
|
1272
|
-
"data-slot": "alert-description",
|
|
1273
|
-
className: cn(
|
|
1274
|
-
"text-muted-foreground text-sm text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3",
|
|
1275
|
-
className
|
|
1276
|
-
),
|
|
1277
|
-
...props
|
|
1278
|
-
}
|
|
1279
|
-
);
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
1175
|
// src/components/login-form.tsx
|
|
1283
|
-
import { jsx as
|
|
1176
|
+
import { Fragment as Fragment3, jsx as jsx18, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1284
1177
|
function LoginForm({ config }) {
|
|
1285
1178
|
const router = useRouter2();
|
|
1286
1179
|
const searchParams = useSearchParams();
|
|
@@ -1306,7 +1199,7 @@ function LoginForm({ config }) {
|
|
|
1306
1199
|
return;
|
|
1307
1200
|
}
|
|
1308
1201
|
if (config.onPostLoginSuccess) {
|
|
1309
|
-
const gauthToken = data?.user?.gauthToken;
|
|
1202
|
+
const gauthToken = data?.user ? data.user?.gauthToken : void 0;
|
|
1310
1203
|
const redirectUrl = await config.onPostLoginSuccess(data?.user, gauthToken);
|
|
1311
1204
|
if (redirectUrl) {
|
|
1312
1205
|
router.push(redirectUrl);
|
|
@@ -1319,50 +1212,73 @@ function LoginForm({ config }) {
|
|
|
1319
1212
|
setLoading(false);
|
|
1320
1213
|
}
|
|
1321
1214
|
};
|
|
1322
|
-
return /* @__PURE__ */
|
|
1323
|
-
/* @__PURE__ */ jsxs10(
|
|
1324
|
-
/* @__PURE__ */
|
|
1325
|
-
|
|
1326
|
-
/* @__PURE__ */
|
|
1327
|
-
config.appBadge && /* @__PURE__ */
|
|
1215
|
+
return /* @__PURE__ */ jsx18("div", { className: "flex min-h-svh items-center justify-center bg-muted/30 p-4", children: /* @__PURE__ */ jsxs10("div", { className: "w-full max-w-[400px]", children: [
|
|
1216
|
+
/* @__PURE__ */ jsxs10("div", { className: "mb-8 text-center", children: [
|
|
1217
|
+
/* @__PURE__ */ jsx18("div", { className: "mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-xl bg-primary text-primary-foreground shadow-sm", children: config.icon }),
|
|
1218
|
+
/* @__PURE__ */ jsxs10("div", { className: "flex items-center justify-center gap-2", children: [
|
|
1219
|
+
/* @__PURE__ */ jsx18("h1", { className: "text-2xl font-semibold tracking-tight", children: config.appName }),
|
|
1220
|
+
config.appBadge && /* @__PURE__ */ jsx18(Badge, { variant: config.appBadge.variant, className: "text-xs", children: config.appBadge.text })
|
|
1328
1221
|
] }),
|
|
1329
|
-
/* @__PURE__ */
|
|
1222
|
+
/* @__PURE__ */ jsx18("p", { className: "mt-1.5 text-sm text-muted-foreground", children: config.description })
|
|
1330
1223
|
] }),
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
-
error && /* @__PURE__ */
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
/* @__PURE__ */ jsx20(
|
|
1336
|
-
Input,
|
|
1337
|
-
{
|
|
1338
|
-
id: "email",
|
|
1339
|
-
type: "email",
|
|
1340
|
-
placeholder: "email@exemplo.com",
|
|
1341
|
-
value: email,
|
|
1342
|
-
onChange: (e) => setEmail(e.target.value),
|
|
1343
|
-
required: true
|
|
1344
|
-
}
|
|
1345
|
-
)
|
|
1224
|
+
/* @__PURE__ */ jsx18("div", { className: "rounded-xl border bg-card p-6 shadow-sm", children: /* @__PURE__ */ jsxs10("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
1225
|
+
error && /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2.5 text-sm text-destructive", children: [
|
|
1226
|
+
/* @__PURE__ */ jsx18(AlertCircle, { className: "h-4 w-4 shrink-0" }),
|
|
1227
|
+
error
|
|
1346
1228
|
] }),
|
|
1347
|
-
/* @__PURE__ */ jsxs10("div", { className: "
|
|
1348
|
-
/* @__PURE__ */
|
|
1349
|
-
/* @__PURE__ */
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1229
|
+
/* @__PURE__ */ jsxs10("div", { className: "space-y-1.5", children: [
|
|
1230
|
+
/* @__PURE__ */ jsx18(Label, { htmlFor: "login-email", className: "text-sm font-medium", children: "Email" }),
|
|
1231
|
+
/* @__PURE__ */ jsxs10("div", { className: "relative", children: [
|
|
1232
|
+
/* @__PURE__ */ jsx18(Mail, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
1233
|
+
/* @__PURE__ */ jsx18(
|
|
1234
|
+
Input,
|
|
1235
|
+
{
|
|
1236
|
+
id: "login-email",
|
|
1237
|
+
type: "email",
|
|
1238
|
+
placeholder: "email@exemplo.com",
|
|
1239
|
+
value: email,
|
|
1240
|
+
onChange: (e) => setEmail(e.target.value),
|
|
1241
|
+
className: "pl-9",
|
|
1242
|
+
autoComplete: "email",
|
|
1243
|
+
required: true
|
|
1244
|
+
}
|
|
1245
|
+
)
|
|
1246
|
+
] })
|
|
1359
1247
|
] }),
|
|
1360
|
-
/* @__PURE__ */ jsxs10(
|
|
1361
|
-
|
|
1362
|
-
"
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1248
|
+
/* @__PURE__ */ jsxs10("div", { className: "space-y-1.5", children: [
|
|
1249
|
+
/* @__PURE__ */ jsx18(Label, { htmlFor: "login-password", className: "text-sm font-medium", children: "Senha" }),
|
|
1250
|
+
/* @__PURE__ */ jsxs10("div", { className: "relative", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx18(Lock, { className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
|
|
1252
|
+
/* @__PURE__ */ jsx18(
|
|
1253
|
+
Input,
|
|
1254
|
+
{
|
|
1255
|
+
id: "login-password",
|
|
1256
|
+
type: "password",
|
|
1257
|
+
placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
|
|
1258
|
+
value: password,
|
|
1259
|
+
onChange: (e) => setPassword(e.target.value),
|
|
1260
|
+
className: "pl-9",
|
|
1261
|
+
autoComplete: "current-password",
|
|
1262
|
+
required: true
|
|
1263
|
+
}
|
|
1264
|
+
)
|
|
1265
|
+
] })
|
|
1266
|
+
] }),
|
|
1267
|
+
/* @__PURE__ */ jsx18(
|
|
1268
|
+
Button,
|
|
1269
|
+
{
|
|
1270
|
+
type: "submit",
|
|
1271
|
+
className: cn("w-full", loading && "cursor-wait"),
|
|
1272
|
+
disabled: loading,
|
|
1273
|
+
children: loading ? /* @__PURE__ */ jsxs10(Fragment3, { children: [
|
|
1274
|
+
/* @__PURE__ */ jsx18(Loader2, { className: "h-4 w-4 animate-spin" }),
|
|
1275
|
+
"A entrar..."
|
|
1276
|
+
] }) : "Entrar"
|
|
1277
|
+
}
|
|
1278
|
+
)
|
|
1279
|
+
] }) }),
|
|
1280
|
+
/* @__PURE__ */ jsx18("p", { className: "mt-6 text-center text-xs text-muted-foreground", children: config.footerText || "Acesso restrito a utilizadores autorizados" })
|
|
1281
|
+
] }) });
|
|
1366
1282
|
}
|
|
1367
1283
|
export {
|
|
1368
1284
|
AppHeader,
|