@riligar/auth-react 1.11.0 → 1.13.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/dist/index.esm.js +184 -55
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +183 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useMemo, useEffect, createContext, useState, useRef } from 'react';
|
|
|
3
3
|
import { useShallow } from 'zustand/react/shallow';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { Navigate, Outlet, useNavigate } from 'react-router-dom';
|
|
6
|
-
import {
|
|
6
|
+
import { Modal, Stack, Text, Image, Title, Paper, TextInput, PasswordInput, Anchor, Button, Divider, Group, Center, Loader, Box, Avatar, Collapse, Card, Tooltip, ThemeIcon } from '@mantine/core';
|
|
7
7
|
import { useForm } from '@mantine/form';
|
|
8
8
|
import { IconMail, IconLock, IconArrowRight, IconBrandGoogle, IconBrandGithub, IconUser, IconSend, IconCheck, IconX, IconRefresh, IconPhoto, IconTrash, IconPencil, IconShield, IconKey, IconUserCircle } from '@tabler/icons-react';
|
|
9
9
|
import { notifications } from '@mantine/notifications';
|
|
@@ -939,8 +939,68 @@ function AuthCard({
|
|
|
939
939
|
logo,
|
|
940
940
|
logoHeight = 28,
|
|
941
941
|
width = 350,
|
|
942
|
+
// Variant props
|
|
943
|
+
variant = 'card',
|
|
944
|
+
opened,
|
|
945
|
+
onClose,
|
|
946
|
+
modalProps = {},
|
|
942
947
|
...props
|
|
943
948
|
}) {
|
|
949
|
+
// Conteúdo interno compartilhado entre Card e Modal
|
|
950
|
+
const content = /*#__PURE__*/jsxs(Stack, {
|
|
951
|
+
gap: "sm",
|
|
952
|
+
children: [(logo || title || subtitle) && /*#__PURE__*/jsxs(Stack, {
|
|
953
|
+
gap: "xs",
|
|
954
|
+
children: [logo && /*#__PURE__*/jsx(Image, {
|
|
955
|
+
src: logo,
|
|
956
|
+
alt: "Auth",
|
|
957
|
+
h: logoHeight,
|
|
958
|
+
fit: "contain"
|
|
959
|
+
}), title && /*#__PURE__*/jsx(Title, {
|
|
960
|
+
order: 3,
|
|
961
|
+
children: title
|
|
962
|
+
}), subtitle && /*#__PURE__*/jsx(Text, {
|
|
963
|
+
size: "sm",
|
|
964
|
+
c: "dimmed",
|
|
965
|
+
children: subtitle
|
|
966
|
+
})]
|
|
967
|
+
}), children]
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
// Renderizar como Modal
|
|
971
|
+
if (variant === 'modal') {
|
|
972
|
+
return /*#__PURE__*/jsx(Modal, {
|
|
973
|
+
opened: opened,
|
|
974
|
+
onClose: onClose,
|
|
975
|
+
size: width + 50,
|
|
976
|
+
withCloseButton: true,
|
|
977
|
+
radius: "md",
|
|
978
|
+
overlayProps: {
|
|
979
|
+
backgroundOpacity: 0.55,
|
|
980
|
+
blur: 3
|
|
981
|
+
},
|
|
982
|
+
title: logo ? /*#__PURE__*/jsx(Image, {
|
|
983
|
+
src: logo,
|
|
984
|
+
alt: "Auth",
|
|
985
|
+
h: logoHeight,
|
|
986
|
+
fit: "contain"
|
|
987
|
+
}) : title ? /*#__PURE__*/jsx(Title, {
|
|
988
|
+
order: 4,
|
|
989
|
+
children: title
|
|
990
|
+
}) : null,
|
|
991
|
+
...modalProps,
|
|
992
|
+
children: /*#__PURE__*/jsxs(Stack, {
|
|
993
|
+
gap: "sm",
|
|
994
|
+
children: [subtitle && /*#__PURE__*/jsx(Text, {
|
|
995
|
+
size: "sm",
|
|
996
|
+
c: "dimmed",
|
|
997
|
+
children: subtitle
|
|
998
|
+
}), children]
|
|
999
|
+
})
|
|
1000
|
+
});
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
// Renderizar como Card (default)
|
|
944
1004
|
return /*#__PURE__*/jsx(Paper, {
|
|
945
1005
|
withBorder: true,
|
|
946
1006
|
shadow: "md",
|
|
@@ -948,25 +1008,7 @@ function AuthCard({
|
|
|
948
1008
|
w: width,
|
|
949
1009
|
radius: "md",
|
|
950
1010
|
...props,
|
|
951
|
-
children:
|
|
952
|
-
gap: "sm",
|
|
953
|
-
children: [(logo || title || subtitle) && /*#__PURE__*/jsxs(Stack, {
|
|
954
|
-
gap: "xs",
|
|
955
|
-
children: [logo && /*#__PURE__*/jsx(Image, {
|
|
956
|
-
src: logo,
|
|
957
|
-
alt: "Auth",
|
|
958
|
-
h: logoHeight,
|
|
959
|
-
fit: "contain"
|
|
960
|
-
}), title && /*#__PURE__*/jsx(Title, {
|
|
961
|
-
order: 3,
|
|
962
|
-
children: title
|
|
963
|
-
}), subtitle && /*#__PURE__*/jsx(Text, {
|
|
964
|
-
size: "sm",
|
|
965
|
-
c: "dimmed",
|
|
966
|
-
children: subtitle
|
|
967
|
-
})]
|
|
968
|
-
}), children]
|
|
969
|
-
})
|
|
1011
|
+
children: content
|
|
970
1012
|
});
|
|
971
1013
|
}
|
|
972
1014
|
|
|
@@ -978,6 +1020,11 @@ function SignIn({
|
|
|
978
1020
|
// Removido default, será calculado abaixo
|
|
979
1021
|
title = 'Entrar',
|
|
980
1022
|
subtitle = 'Acesse sua conta para continuar',
|
|
1023
|
+
// Variant
|
|
1024
|
+
variant = 'card',
|
|
1025
|
+
opened,
|
|
1026
|
+
onClose,
|
|
1027
|
+
modalProps = {},
|
|
981
1028
|
// Features
|
|
982
1029
|
showMagicLink = true,
|
|
983
1030
|
showForgotPassword = true,
|
|
@@ -1052,6 +1099,10 @@ function SignIn({
|
|
|
1052
1099
|
logo: finalLogo,
|
|
1053
1100
|
title: title,
|
|
1054
1101
|
subtitle: subtitle,
|
|
1102
|
+
variant: variant,
|
|
1103
|
+
opened: opened,
|
|
1104
|
+
onClose: onClose,
|
|
1105
|
+
modalProps: modalProps,
|
|
1055
1106
|
...cardProps,
|
|
1056
1107
|
children: [/*#__PURE__*/jsx("form", {
|
|
1057
1108
|
onSubmit: form.onSubmit(handleSubmit),
|
|
@@ -1145,6 +1196,11 @@ function SignUp({
|
|
|
1145
1196
|
logo,
|
|
1146
1197
|
title = 'Criar Conta',
|
|
1147
1198
|
subtitle = 'Preencha os dados para se cadastrar',
|
|
1199
|
+
// Variant
|
|
1200
|
+
variant = 'card',
|
|
1201
|
+
opened,
|
|
1202
|
+
onClose,
|
|
1203
|
+
modalProps = {},
|
|
1148
1204
|
// Features
|
|
1149
1205
|
requireName = true,
|
|
1150
1206
|
showSignInLink = true,
|
|
@@ -1191,6 +1247,10 @@ function SignUp({
|
|
|
1191
1247
|
logo: finalLogo,
|
|
1192
1248
|
title: title,
|
|
1193
1249
|
subtitle: subtitle,
|
|
1250
|
+
variant: variant,
|
|
1251
|
+
opened: opened,
|
|
1252
|
+
onClose: onClose,
|
|
1253
|
+
modalProps: modalProps,
|
|
1194
1254
|
...cardProps,
|
|
1195
1255
|
children: [/*#__PURE__*/jsx("form", {
|
|
1196
1256
|
onSubmit: form.onSubmit(handleSubmit),
|
|
@@ -1279,6 +1339,11 @@ function MagicLink({
|
|
|
1279
1339
|
logo,
|
|
1280
1340
|
title = 'Login sem Senha',
|
|
1281
1341
|
subtitle = 'Receba um link de acesso no seu email',
|
|
1342
|
+
// Variant
|
|
1343
|
+
variant = 'card',
|
|
1344
|
+
opened,
|
|
1345
|
+
onClose,
|
|
1346
|
+
modalProps = {},
|
|
1282
1347
|
// Features
|
|
1283
1348
|
showSignInLink = true,
|
|
1284
1349
|
// Links
|
|
@@ -1316,6 +1381,10 @@ function MagicLink({
|
|
|
1316
1381
|
logo: finalLogo,
|
|
1317
1382
|
title: title,
|
|
1318
1383
|
subtitle: subtitle,
|
|
1384
|
+
variant: variant,
|
|
1385
|
+
opened: opened,
|
|
1386
|
+
onClose: onClose,
|
|
1387
|
+
modalProps: modalProps,
|
|
1319
1388
|
...cardProps,
|
|
1320
1389
|
children: [/*#__PURE__*/jsx("form", {
|
|
1321
1390
|
onSubmit: form.onSubmit(handleSubmit),
|
|
@@ -1467,6 +1536,11 @@ function ForgotPassword({
|
|
|
1467
1536
|
logo,
|
|
1468
1537
|
title = 'Recuperar Senha',
|
|
1469
1538
|
subtitle = 'Enviaremos um link para redefinir sua senha',
|
|
1539
|
+
// Variant
|
|
1540
|
+
variant = 'card',
|
|
1541
|
+
opened,
|
|
1542
|
+
onClose,
|
|
1543
|
+
modalProps = {},
|
|
1470
1544
|
// Features
|
|
1471
1545
|
showSignInLink = true,
|
|
1472
1546
|
// Links
|
|
@@ -1504,6 +1578,10 @@ function ForgotPassword({
|
|
|
1504
1578
|
logo: finalLogo,
|
|
1505
1579
|
title: title,
|
|
1506
1580
|
subtitle: subtitle,
|
|
1581
|
+
variant: variant,
|
|
1582
|
+
opened: opened,
|
|
1583
|
+
onClose: onClose,
|
|
1584
|
+
modalProps: modalProps,
|
|
1507
1585
|
...cardProps,
|
|
1508
1586
|
children: [/*#__PURE__*/jsx("form", {
|
|
1509
1587
|
onSubmit: form.onSubmit(handleSubmit),
|
|
@@ -1844,7 +1922,8 @@ function VerifyEmail({
|
|
|
1844
1922
|
}
|
|
1845
1923
|
|
|
1846
1924
|
function UserProfile({
|
|
1847
|
-
//
|
|
1925
|
+
// Variant
|
|
1926
|
+
variant = 'modal',
|
|
1848
1927
|
opened,
|
|
1849
1928
|
onClose,
|
|
1850
1929
|
// Callbacks
|
|
@@ -1861,11 +1940,14 @@ function UserProfile({
|
|
|
1861
1940
|
labels = {},
|
|
1862
1941
|
title = 'Account',
|
|
1863
1942
|
subtitle = 'Manage your account info.',
|
|
1943
|
+
logo,
|
|
1944
|
+
logoHeight = 28,
|
|
1945
|
+
width = 500,
|
|
1864
1946
|
// Avatar config
|
|
1865
1947
|
maxAvatarSize = 500 * 1024,
|
|
1866
1948
|
// 500KB
|
|
1867
1949
|
|
|
1868
|
-
...
|
|
1950
|
+
...containerProps
|
|
1869
1951
|
}) {
|
|
1870
1952
|
// Local state - which section is expanded
|
|
1871
1953
|
const [editingSection, setEditingSection] = useState(null); // 'password' | 'email' | 'name' | 'avatar' | null
|
|
@@ -2179,39 +2261,10 @@ function UserProfile({
|
|
|
2179
2261
|
})]
|
|
2180
2262
|
})
|
|
2181
2263
|
});
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
withCloseButton: true,
|
|
2187
|
-
radius: "lg",
|
|
2188
|
-
overlayProps: {
|
|
2189
|
-
backgroundOpacity: 0.55,
|
|
2190
|
-
blur: 3
|
|
2191
|
-
},
|
|
2192
|
-
title: /*#__PURE__*/jsxs(Group, {
|
|
2193
|
-
gap: "md",
|
|
2194
|
-
children: [/*#__PURE__*/jsx(ThemeIcon, {
|
|
2195
|
-
size: 44,
|
|
2196
|
-
variant: "light",
|
|
2197
|
-
children: /*#__PURE__*/jsx(IconUserCircle, {
|
|
2198
|
-
size: 24
|
|
2199
|
-
})
|
|
2200
|
-
}), /*#__PURE__*/jsxs(Box, {
|
|
2201
|
-
children: [/*#__PURE__*/jsx(Title, {
|
|
2202
|
-
order: 4,
|
|
2203
|
-
children: title
|
|
2204
|
-
}), /*#__PURE__*/jsx(Text, {
|
|
2205
|
-
size: "sm",
|
|
2206
|
-
c: "dimmed",
|
|
2207
|
-
children: subtitle
|
|
2208
|
-
})]
|
|
2209
|
-
})]
|
|
2210
|
-
}),
|
|
2211
|
-
...modalProps,
|
|
2212
|
-
children: [/*#__PURE__*/jsx(Divider, {
|
|
2213
|
-
mb: "md"
|
|
2214
|
-
}), (showAvatar || showName || showEmail) && /*#__PURE__*/jsxs(Box, {
|
|
2264
|
+
|
|
2265
|
+
// Conteúdo interno compartilhado
|
|
2266
|
+
const profileContent = /*#__PURE__*/jsxs(Fragment, {
|
|
2267
|
+
children: [(showAvatar || showName || showEmail) && /*#__PURE__*/jsxs(Box, {
|
|
2215
2268
|
mb: "xl",
|
|
2216
2269
|
children: [/*#__PURE__*/jsx(SectionHeader, {
|
|
2217
2270
|
icon: IconUser,
|
|
@@ -2516,6 +2569,82 @@ function UserProfile({
|
|
|
2516
2569
|
})]
|
|
2517
2570
|
})]
|
|
2518
2571
|
});
|
|
2572
|
+
|
|
2573
|
+
// Renderizar como Modal
|
|
2574
|
+
if (variant === 'modal') {
|
|
2575
|
+
return /*#__PURE__*/jsxs(Modal, {
|
|
2576
|
+
opened: opened,
|
|
2577
|
+
onClose: onClose,
|
|
2578
|
+
size: width + 50,
|
|
2579
|
+
withCloseButton: true,
|
|
2580
|
+
radius: "md",
|
|
2581
|
+
overlayProps: {
|
|
2582
|
+
backgroundOpacity: 0.55,
|
|
2583
|
+
blur: 3
|
|
2584
|
+
},
|
|
2585
|
+
title: /*#__PURE__*/jsxs(Group, {
|
|
2586
|
+
gap: "md",
|
|
2587
|
+
children: [/*#__PURE__*/jsx(ThemeIcon, {
|
|
2588
|
+
size: 44,
|
|
2589
|
+
variant: "light",
|
|
2590
|
+
children: /*#__PURE__*/jsx(IconUserCircle, {
|
|
2591
|
+
size: 24
|
|
2592
|
+
})
|
|
2593
|
+
}), /*#__PURE__*/jsxs(Box, {
|
|
2594
|
+
children: [/*#__PURE__*/jsx(Title, {
|
|
2595
|
+
order: 4,
|
|
2596
|
+
children: title
|
|
2597
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
2598
|
+
size: "sm",
|
|
2599
|
+
c: "dimmed",
|
|
2600
|
+
children: subtitle
|
|
2601
|
+
})]
|
|
2602
|
+
})]
|
|
2603
|
+
}),
|
|
2604
|
+
...containerProps,
|
|
2605
|
+
children: [/*#__PURE__*/jsx(Divider, {
|
|
2606
|
+
mb: "md"
|
|
2607
|
+
}), profileContent]
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
// Renderizar como Card
|
|
2612
|
+
return /*#__PURE__*/jsx(Paper, {
|
|
2613
|
+
withBorder: true
|
|
2614
|
+
// shadow="md"
|
|
2615
|
+
,
|
|
2616
|
+
p: "md",
|
|
2617
|
+
w: width,
|
|
2618
|
+
radius: "md",
|
|
2619
|
+
...containerProps,
|
|
2620
|
+
children: /*#__PURE__*/jsxs(Stack, {
|
|
2621
|
+
gap: "sm",
|
|
2622
|
+
children: [/*#__PURE__*/jsxs(Group, {
|
|
2623
|
+
gap: "md",
|
|
2624
|
+
children: [logo ? /*#__PURE__*/jsx(Image, {
|
|
2625
|
+
src: logo,
|
|
2626
|
+
alt: "Auth",
|
|
2627
|
+
h: logoHeight,
|
|
2628
|
+
fit: "contain"
|
|
2629
|
+
}) : /*#__PURE__*/jsx(ThemeIcon, {
|
|
2630
|
+
size: 44,
|
|
2631
|
+
variant: "light",
|
|
2632
|
+
children: /*#__PURE__*/jsx(IconUserCircle, {
|
|
2633
|
+
size: 24
|
|
2634
|
+
})
|
|
2635
|
+
}), /*#__PURE__*/jsxs(Box, {
|
|
2636
|
+
children: [/*#__PURE__*/jsx(Title, {
|
|
2637
|
+
order: 4,
|
|
2638
|
+
children: title
|
|
2639
|
+
}), /*#__PURE__*/jsx(Text, {
|
|
2640
|
+
size: "sm",
|
|
2641
|
+
c: "dimmed",
|
|
2642
|
+
children: subtitle
|
|
2643
|
+
})]
|
|
2644
|
+
})]
|
|
2645
|
+
}), /*#__PURE__*/jsx(Divider, {}), profileContent]
|
|
2646
|
+
})
|
|
2647
|
+
});
|
|
2519
2648
|
}
|
|
2520
2649
|
|
|
2521
2650
|
/**
|