@codebit-programando-solucoes/codebit-web-antd 1.1.23 → 1.1.25

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.
@@ -35,7 +35,9 @@ export interface CodebitConfigContextType {
35
35
  */
36
36
  menuItems: (user?: LoggedUser) => MenuItem[];
37
37
  /** Indicates if the user is currently logged in. */
38
- isLogged: boolean;
38
+ isLogged: boolean | null;
39
+ /** Sets the logged-in state manually. */
40
+ setIsLogged: React.Dispatch<React.SetStateAction<boolean | null>>;
39
41
  /** The current user object, null when not logged in. */
40
42
  user: LoggedUser | null;
41
43
  /** Logs out the current user and resets session state. */
package/dist/index.cjs CHANGED
@@ -294,21 +294,23 @@ var __webpack_exports__ = {};
294
294
  __webpack_require__.d(__webpack_exports__, {
295
295
  TableContainer: ()=>TableContainer,
296
296
  CssTokenBridge: ()=>CssTokenBridge,
297
+ LocalLoginAuthenticationEnum: ()=>LocalLoginAuthenticationEnum,
297
298
  LoggedMainContainer: ()=>LoggedMainContainer,
298
- Login: ()=>Login,
299
299
  CodebitThemeProvider: ()=>CodebitThemeProvider,
300
+ Login: ()=>Login,
300
301
  useErrorModal: ()=>useErrorModal,
302
+ LocalLoginChangePasswordResult: ()=>LocalLoginChangePasswordResult,
301
303
  ErrorRetry: ()=>ErrorRetry,
302
304
  CodebitThemeContext: ()=>CodebitThemeContext,
305
+ ChangePassword: ()=>ChangePassword,
303
306
  CodebitConfigContext: ()=>CodebitConfigContext,
304
- ListCard: ()=>ListCard,
305
307
  ForgotPassword: ()=>ForgotPassword,
308
+ ListCard: ()=>ListCard,
306
309
  LoginContainer: ()=>LoginContainer,
307
310
  useErrorMessage: ()=>useErrorMessage,
308
311
  LocalLoginRecoveryPasswordResult: ()=>LocalLoginRecoveryPasswordResult,
309
312
  FilterContainer: ()=>FilterContainer,
310
313
  HandleError: ()=>HandleError,
311
- LocalLoginAuthenticationResult: ()=>LocalLoginAuthenticationResult,
312
314
  CodebitConfigProvider: ()=>CodebitConfigProvider,
313
315
  ThemeToggle: ()=>ThemeToggle
314
316
  });
@@ -360,6 +362,7 @@ var __webpack_exports__ = {};
360
362
  const contextValue = (0, external_react_.useMemo)(()=>({
361
363
  menuItems,
362
364
  isLogged,
365
+ setIsLogged,
363
366
  user,
364
367
  logout,
365
368
  version,
@@ -453,7 +456,6 @@ var __webpack_exports__ = {};
453
456
  passwordRequired: 'Por favor, insira sua senha!',
454
457
  separator: 'ou',
455
458
  errorTitle: 'Erro ao autenticar',
456
- genericError: 'Ocorreu um erro. Por favor, tente novamente.',
457
459
  invalidPassword: 'A senha está incorreta.',
458
460
  invalidEmailOrPassword: 'O e-mail ou senha estão incorretos.',
459
461
  userDisabled: 'Sua conta foi desativada. Por favor, entre em contato com o suporte.',
@@ -482,7 +484,7 @@ var __webpack_exports__ = {};
482
484
  passwordLowerCase: 'uma letra minúscula',
483
485
  passwordNumbers: 'um número',
484
486
  passwordSpecialChars: 'um caractere especial (!@#$%^&*)',
485
- passwordWeak: 'Senha fraca: Deve ter pelo menos {requirements}',
487
+ passwordWeak: 'Senha fraca: Deve ter pelo menos {{requirements}}',
486
488
  passwordsNotMatch: 'As senhas digitadas não coincidem!',
487
489
  tokenInvalidTitle: 'Token inválido',
488
490
  tokenInvalidOrExpired: 'O token informado é inválido ou está expirado. Inicie o processo de recuperação de senha e tente novamente.',
@@ -505,6 +507,7 @@ var __webpack_exports__ = {};
505
507
  Common: {
506
508
  ok: 'Ok',
507
509
  close: 'Fechar',
510
+ genericError: 'Ocorreu um erro. Por favor, tente novamente.',
508
511
  invalidEmail: 'O e-mail é inválido ou não está registrado.',
509
512
  recaptchaFailed: 'Validação reCAPTCHA falhou. Por favor, tente novamente.'
510
513
  }
@@ -583,7 +586,7 @@ var __webpack_exports__ = {};
583
586
  passwordLowerCase: 'a lowercase letter',
584
587
  passwordNumbers: 'a number',
585
588
  passwordSpecialChars: 'a special character (!@#$%^&*)',
586
- passwordWeak: 'Weak password: Must have at least {requirements}',
589
+ passwordWeak: 'Weak password: Must have at least {{requirements}}',
587
590
  passwordsNotMatch: 'The passwords do not match!',
588
591
  tokenInvalidTitle: 'Invalid Token',
589
592
  tokenInvalidOrExpired: 'The provided token is invalid or expired. Start the password recovery process and try again.',
@@ -1024,7 +1027,7 @@ var __webpack_exports__ = {};
1024
1027
  menuDescription: "menuDescription-d6BFBO",
1025
1028
  menuSpacer: "menuSpacer-RIB3II",
1026
1029
  versionMenu: "versionMenu-NM4uyG",
1027
- logoutMenu: "logoutMenu-_RLfGo",
1030
+ bottomMenu: "bottomMenu-VtOktS",
1028
1031
  header: "header-vgc67L",
1029
1032
  mobile: "mobile-mKGxb5",
1030
1033
  headerSpace: "headerSpace-Fd_iha",
@@ -1033,7 +1036,7 @@ var __webpack_exports__ = {};
1033
1036
  const { Header, Sider, Content } = external_antd_namespaceObject.Layout;
1034
1037
  const { Text } = external_antd_namespaceObject.Typography;
1035
1038
  function LoggedMainContainer({ children }) {
1036
- const [collapsed, setCollapsed] = (0, external_react_.useState)(false);
1039
+ const [collapsed, setCollapsed] = (0, external_react_.useState)(true);
1037
1040
  const [isMobile, setIsMobile] = (0, external_react_.useState)(false);
1038
1041
  const [drawerVisible, setDrawerVisible] = (0, external_react_.useState)(false);
1039
1042
  const [secondarySidebarDrawerVisible, setSecondarySidebarDrawerVisible] = (0, external_react_.useState)(false);
@@ -1048,7 +1051,7 @@ var __webpack_exports__ = {};
1048
1051
  const systemTheme = isDarkMode ? 'dark' : 'light';
1049
1052
  const filteredMenuItems = (0, external_react_.useMemo)(()=>menuItems(user).filter((item)=>{
1050
1053
  if (!item.roles) return true;
1051
- if (!user || !user.roles) return false;
1054
+ if (!user?.roles) return false;
1052
1055
  if (item.roles) return item.roles.some((role)=>user.roles.includes(role));
1053
1056
  return false;
1054
1057
  }), [
@@ -1102,16 +1105,16 @@ var __webpack_exports__ = {};
1102
1105
  disabled: true,
1103
1106
  items: [
1104
1107
  {
1105
- icon: collapsed ? `${t('LoggedMainContainer.version')}: ${version}` : version,
1108
+ icon: collapsed ? version : `${t('LoggedMainContainer.version')}: ${version}`,
1106
1109
  title: ''
1107
1110
  }
1108
1111
  ]
1109
1112
  }),
1110
1113
  /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Menu, {
1111
1114
  theme: systemTheme,
1112
- mode: 'horizontal',
1115
+ mode: 'inline',
1113
1116
  onClick: handleLogout,
1114
- className: LoggedMainContainer_module.logoutMenu,
1117
+ className: LoggedMainContainer_module.bottomMenu,
1115
1118
  items: [
1116
1119
  {
1117
1120
  key: 'logout',
@@ -1123,51 +1126,60 @@ var __webpack_exports__ = {};
1123
1126
  })
1124
1127
  ]
1125
1128
  });
1129
+ console.debug('secondarySidebar', secondarySidebar);
1130
+ const renderMenuContent = ()=>{
1131
+ if (isMobile) return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
1132
+ placement: 'left',
1133
+ onClose: ()=>setDrawerVisible(false),
1134
+ open: drawerVisible,
1135
+ width: 250,
1136
+ className: LoggedMainContainer_module.drawer,
1137
+ classNames: {
1138
+ body: LoggedMainContainer_module.drawerBody
1139
+ },
1140
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Flex, {
1141
+ vertical: true,
1142
+ className: LoggedMainContainer_module.drawerFlex,
1143
+ children: menuContent
1144
+ })
1145
+ });
1146
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
1147
+ theme: systemTheme,
1148
+ trigger: null,
1149
+ collapsible: true,
1150
+ collapsed: collapsed,
1151
+ breakpoint: 'lg',
1152
+ collapsedWidth: 80,
1153
+ className: LoggedMainContainer_module.sider,
1154
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
1155
+ className: LoggedMainContainer_module.siderLayout,
1156
+ children: menuContent
1157
+ })
1158
+ });
1159
+ };
1160
+ const renderSecondarySidebar = ()=>{
1161
+ if (!secondarySidebar) return null;
1162
+ if (isMobile) return /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
1163
+ placement: 'right',
1164
+ onClose: ()=>setSecondarySidebarDrawerVisible(false),
1165
+ open: secondarySidebarDrawerVisible,
1166
+ width: 280,
1167
+ className: LoggedMainContainer_module.drawer,
1168
+ title: null,
1169
+ closeIcon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.CloseOutlined, {}),
1170
+ children: secondarySidebar(user)
1171
+ });
1172
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
1173
+ theme: systemTheme,
1174
+ width: secondarySidebarWidth,
1175
+ children: secondarySidebar(user)
1176
+ });
1177
+ };
1126
1178
  return /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Layout, {
1127
1179
  className: LoggedMainContainer_module.layout,
1128
1180
  children: [
1129
- isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
1130
- placement: 'left',
1131
- onClose: ()=>setDrawerVisible(false),
1132
- open: drawerVisible,
1133
- width: 250,
1134
- className: LoggedMainContainer_module.drawer,
1135
- classNames: {
1136
- body: LoggedMainContainer_module.drawerBody
1137
- },
1138
- children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Flex, {
1139
- vertical: true,
1140
- className: LoggedMainContainer_module.drawerFlex,
1141
- children: menuContent
1142
- })
1143
- }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
1144
- theme: systemTheme,
1145
- trigger: null,
1146
- collapsible: true,
1147
- collapsed: !collapsed,
1148
- breakpoint: 'lg',
1149
- collapsedWidth: 80,
1150
- className: LoggedMainContainer_module.sider,
1151
- children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Layout, {
1152
- className: LoggedMainContainer_module.siderLayout,
1153
- children: menuContent
1154
- })
1155
- }),
1156
- secondarySidebar && !isMobile ? /*#__PURE__*/ (0, jsx_runtime.jsx)(Sider, {
1157
- theme: systemTheme,
1158
- width: secondarySidebarWidth,
1159
- className: `${LoggedMainContainer_module.secondarySidebar} ${isDarkMode ? LoggedMainContainer_module.secondarySidebarDark : ''}`,
1160
- children: secondarySidebar(user)
1161
- }) : /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Drawer, {
1162
- placement: 'right',
1163
- onClose: ()=>setSecondarySidebarDrawerVisible(false),
1164
- open: secondarySidebarDrawerVisible,
1165
- width: 280,
1166
- className: LoggedMainContainer_module.drawer,
1167
- title: null,
1168
- closeIcon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.CloseOutlined, {}),
1169
- children: secondarySidebar(user)
1170
- }),
1181
+ renderMenuContent(),
1182
+ renderSecondarySidebar(),
1171
1183
  /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Layout, {
1172
1184
  children: [
1173
1185
  /*#__PURE__*/ (0, jsx_runtime.jsxs)(Header, {
@@ -1190,7 +1202,7 @@ var __webpack_exports__ = {};
1190
1202
  children: [
1191
1203
  secondarySidebar && isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
1192
1204
  type: 'text',
1193
- icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.MenuOutlined, {}),
1205
+ icon: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.WechatOutlined, {}),
1194
1206
  onClick: ()=>setSecondarySidebarDrawerVisible(true)
1195
1207
  }),
1196
1208
  !isMobile && /*#__PURE__*/ (0, jsx_runtime.jsx)(Text, {
@@ -1286,7 +1298,7 @@ var __webpack_exports__ = {};
1286
1298
  children: external_prop_types_default().node
1287
1299
  };
1288
1300
  const Login_logger = new codebit_web_namespaceObject.Logger('Login');
1289
- const LocalLoginAuthenticationResult = Object.freeze({
1301
+ const LocalLoginAuthenticationEnum = Object.freeze({
1290
1302
  INVALID_EMAIL: 'INVALID_EMAIL',
1291
1303
  INVALID_PASSWORD: 'INVALID_PASSWORD',
1292
1304
  INVALID_EMAIL_OR_PASSWORD: 'INVALID_EMAIL_OR_PASSWORD',
@@ -1297,6 +1309,7 @@ var __webpack_exports__ = {};
1297
1309
  function Login({ title, oauthCallbackUrl, navigateToForgotPassword, submitAuthenticateLocalUser }) {
1298
1310
  const [localLoading, setLocalLoading] = (0, external_react_.useState)(false);
1299
1311
  const [googleLoading, setGoogleLoading] = (0, external_react_.useState)(false);
1312
+ const { setIsLogged } = (0, external_react_.useContext)(CodebitConfigContext);
1300
1313
  const [form] = external_antd_namespaceObject.Form.useForm();
1301
1314
  const { t } = useCodebitWebAntdTranslation();
1302
1315
  const { modal } = external_antd_namespaceObject.App.useApp();
@@ -1317,9 +1330,10 @@ var __webpack_exports__ = {};
1317
1330
  const { email, password } = values;
1318
1331
  const result = await submitAuthenticateLocalUser(email, password, context);
1319
1332
  switch(result){
1320
- case LocalLoginAuthenticationResult.SUCCESS:
1333
+ case LocalLoginAuthenticationEnum.SUCCESS:
1334
+ setIsLogged(null);
1321
1335
  break;
1322
- case LocalLoginAuthenticationResult.INVALID_EMAIL:
1336
+ case LocalLoginAuthenticationEnum.INVALID_EMAIL:
1323
1337
  form.setFields([
1324
1338
  {
1325
1339
  name: 'email',
@@ -1329,7 +1343,7 @@ var __webpack_exports__ = {};
1329
1343
  }
1330
1344
  ]);
1331
1345
  break;
1332
- case LocalLoginAuthenticationResult.INVALID_PASSWORD:
1346
+ case LocalLoginAuthenticationEnum.INVALID_PASSWORD:
1333
1347
  form.setFields([
1334
1348
  {
1335
1349
  name: 'password',
@@ -1339,7 +1353,7 @@ var __webpack_exports__ = {};
1339
1353
  }
1340
1354
  ]);
1341
1355
  break;
1342
- case LocalLoginAuthenticationResult.INVALID_EMAIL_OR_PASSWORD:
1356
+ case LocalLoginAuthenticationEnum.INVALID_EMAIL_OR_PASSWORD:
1343
1357
  form.setFields([
1344
1358
  {
1345
1359
  name: 'email',
@@ -1355,14 +1369,14 @@ var __webpack_exports__ = {};
1355
1369
  }
1356
1370
  ]);
1357
1371
  break;
1358
- case LocalLoginAuthenticationResult.RECAPTCHA_VALIDATION_FAIL:
1372
+ case LocalLoginAuthenticationEnum.RECAPTCHA_VALIDATION_FAIL:
1359
1373
  modal.error({
1360
1374
  title: t('Login.authenticationFailed'),
1361
1375
  content: t('Common.recaptchaFailed'),
1362
1376
  okText: t('Common.ok')
1363
1377
  });
1364
1378
  break;
1365
- case LocalLoginAuthenticationResult.USER_DISABLED:
1379
+ case LocalLoginAuthenticationEnum.USER_DISABLED:
1366
1380
  modal.error({
1367
1381
  title: t('Login.authenticationFailed'),
1368
1382
  content: t('Login.userDisabled'),
@@ -1373,7 +1387,7 @@ var __webpack_exports__ = {};
1373
1387
  Login_logger.warn('Unhandled authentication result:', result);
1374
1388
  modal.error({
1375
1389
  title: t('Login.authenticationFailed'),
1376
- content: t('Common.genericError'),
1390
+ content: result,
1377
1391
  okText: t('Common.ok')
1378
1392
  });
1379
1393
  }
@@ -1401,13 +1415,14 @@ var __webpack_exports__ = {};
1401
1415
  children: t('LoginContainer.signIn')
1402
1416
  }),
1403
1417
  /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Space, {
1404
- direction: 'vertical',
1418
+ orientation: 'vertical',
1405
1419
  size: 'large',
1406
1420
  style: {
1407
1421
  width: '100%'
1408
1422
  },
1409
1423
  children: [
1410
1424
  submitAuthenticateLocalUser && /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Form, {
1425
+ form: form,
1411
1426
  name: 'login-form',
1412
1427
  layout: 'vertical',
1413
1428
  onFinish: handleLocalLogin,
@@ -1699,6 +1714,203 @@ var __webpack_exports__ = {};
1699
1714
  navigateToLogin: external_prop_types_default().func,
1700
1715
  submitRecoveryPassword: external_prop_types_default().func.isRequired
1701
1716
  };
1717
+ const ChangePassword_logger = new codebit_web_namespaceObject.Logger('ChangePassword');
1718
+ const LocalLoginChangePasswordResult = Object.freeze({
1719
+ INVALID_TOKEN: 'INVALID_TOKEN',
1720
+ SUCCESS: 'SUCCESS'
1721
+ });
1722
+ const ChangePassword = ({ navigateToLogin, checkToken, submitChangePassword })=>{
1723
+ const navigate = (0, external_react_router_namespaceObject.useNavigate)();
1724
+ const [form] = external_antd_namespaceObject.Form.useForm();
1725
+ const { modal } = external_antd_namespaceObject.App.useApp();
1726
+ const [loading, setLoading] = (0, external_react_.useState)(false);
1727
+ const [checkingToken, setCheckingToken] = (0, external_react_.useState)(true);
1728
+ const { t } = useCodebitWebAntdTranslation();
1729
+ t('');
1730
+ const params = (0, external_react_router_namespaceObject.useParams)();
1731
+ const context = {
1732
+ navigate,
1733
+ params
1734
+ };
1735
+ const handleChangePassword = async (values)=>{
1736
+ try {
1737
+ setLoading(true);
1738
+ const result = await submitChangePassword(values.password, context);
1739
+ switch(result){
1740
+ case LocalLoginChangePasswordResult.SUCCESS:
1741
+ modal.success({
1742
+ title: t('ForgotPassword.title'),
1743
+ content: t('ChangePassword.passwordChangedSuccess'),
1744
+ onOk: handleNavigateToLogin,
1745
+ okText: t('Common.close')
1746
+ });
1747
+ break;
1748
+ case LocalLoginChangePasswordResult.INVALID_TOKEN:
1749
+ modal.error({
1750
+ title: t('ForgotPassword.title'),
1751
+ content: t('ChangePassword.tokenInvalidRecovery'),
1752
+ onOk: handleNavigateToLogin,
1753
+ okText: t('Common.close')
1754
+ });
1755
+ break;
1756
+ }
1757
+ } catch (error) {
1758
+ ChangePassword_logger.error(error);
1759
+ react_namespaceObject.captureException(error);
1760
+ modal.error({
1761
+ title: t('ForgotPassword.title'),
1762
+ content: t('Common.genericError'),
1763
+ okText: t('Common.ok')
1764
+ });
1765
+ } finally{
1766
+ setLoading(false);
1767
+ }
1768
+ };
1769
+ const handleNavigateToLogin = async ()=>{
1770
+ ChangePassword_logger.debug('Navigate to login.');
1771
+ await navigateToLogin(context);
1772
+ };
1773
+ async function handleCheckToken() {
1774
+ ChangePassword_logger.debug('Processing change password token.');
1775
+ setCheckingToken(false);
1776
+ try {
1777
+ const isValidToken = await checkToken(context);
1778
+ if (!isValidToken) {
1779
+ const message = t('ChangePassword.tokenInvalidOrExpired');
1780
+ modal.warning({
1781
+ title: t('ChangePassword.tokenInvalidTitle'),
1782
+ content: message,
1783
+ onOk: handleNavigateToLogin,
1784
+ okText: t('Common.close')
1785
+ });
1786
+ }
1787
+ } catch (error) {
1788
+ ChangePassword_logger.error(error);
1789
+ react_namespaceObject.captureException(error);
1790
+ modal.error({
1791
+ title: t('ChangePassword.title'),
1792
+ content: t('Common.genericError'),
1793
+ okText: t('Common.ok')
1794
+ });
1795
+ } finally{
1796
+ setCheckingToken(false);
1797
+ }
1798
+ }
1799
+ (0, external_react_.useEffect)(()=>{
1800
+ setCheckingToken(true);
1801
+ handleCheckToken().then();
1802
+ }, []);
1803
+ return /*#__PURE__*/ (0, jsx_runtime.jsx)(LoginContainer, {
1804
+ title: t('ChangePassword.title'),
1805
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Spin, {
1806
+ spinning: checkingToken,
1807
+ children: /*#__PURE__*/ (0, jsx_runtime.jsxs)(external_antd_namespaceObject.Form, {
1808
+ form: form,
1809
+ name: 'change-password-form',
1810
+ onFinish: handleChangePassword,
1811
+ initialValues: {
1812
+ password: '',
1813
+ confirmPassword: ''
1814
+ },
1815
+ style: {
1816
+ width: '100%'
1817
+ },
1818
+ children: [
1819
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Typography.Paragraph, {
1820
+ style: {
1821
+ textAlign: 'center'
1822
+ },
1823
+ children: t('ChangePassword.passwordInstructions')
1824
+ }),
1825
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Form.Item, {
1826
+ name: 'password',
1827
+ rules: [
1828
+ {
1829
+ required: true,
1830
+ message: t('ChangePassword.passwordRequired')
1831
+ },
1832
+ {
1833
+ validator: (_, value)=>{
1834
+ const strengthChecks = {
1835
+ length: value.length >= 8,
1836
+ hasUpperCase: /[A-Z]/.test(value),
1837
+ hasLowerCase: /[a-z]/.test(value),
1838
+ hasNumbers: /\d/.test(value),
1839
+ hasSpecialChars: /[!@#$%^&*(),.?":{}|<>]/.test(value)
1840
+ };
1841
+ const failedChecks = Object.entries(strengthChecks).filter(([, passes])=>!passes).map(([key])=>key);
1842
+ if (0 === failedChecks.length) return Promise.resolve();
1843
+ const errorMessages = {
1844
+ length: t('ChangePassword.passwordLength'),
1845
+ hasUpperCase: t('ChangePassword.passwordUpperCase'),
1846
+ hasLowerCase: t('ChangePassword.passwordLowerCase'),
1847
+ hasNumbers: t('ChangePassword.passwordNumbers'),
1848
+ hasSpecialChars: t('ChangePassword.passwordSpecialChars')
1849
+ };
1850
+ const errorMessage = failedChecks.map((check)=>errorMessages[check]).join(', ');
1851
+ return Promise.reject(new Error(t('ChangePassword.passwordWeak', {
1852
+ requirements: errorMessage
1853
+ })));
1854
+ }
1855
+ }
1856
+ ],
1857
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Input.Password, {
1858
+ prefix: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.LockOutlined, {}),
1859
+ placeholder: t('ChangePassword.newPassword'),
1860
+ size: 'large'
1861
+ })
1862
+ }),
1863
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Form.Item, {
1864
+ name: 'confirmPassword',
1865
+ rules: [
1866
+ {
1867
+ required: true,
1868
+ message: t('ChangePassword.passwordRequired')
1869
+ },
1870
+ ({ getFieldValue })=>({
1871
+ validator (_, value) {
1872
+ if (!value || getFieldValue('password') === value) return Promise.resolve();
1873
+ return Promise.reject(new Error(t('ChangePassword.passwordsNotMatch')));
1874
+ }
1875
+ })
1876
+ ],
1877
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Input.Password, {
1878
+ prefix: /*#__PURE__*/ (0, jsx_runtime.jsx)(icons_namespaceObject.LockOutlined, {}),
1879
+ placeholder: t('ChangePassword.confirmPassword'),
1880
+ size: 'large'
1881
+ })
1882
+ }),
1883
+ /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Form.Item, {
1884
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Button, {
1885
+ type: 'primary',
1886
+ htmlType: 'submit',
1887
+ size: 'large',
1888
+ loading: loading,
1889
+ style: {
1890
+ width: '100%'
1891
+ },
1892
+ children: t('ChangePassword.submit')
1893
+ })
1894
+ }),
1895
+ /*#__PURE__*/ (0, jsx_runtime.jsx)("div", {
1896
+ style: {
1897
+ textAlign: 'center'
1898
+ },
1899
+ children: /*#__PURE__*/ (0, jsx_runtime.jsx)(external_antd_namespaceObject.Typography.Link, {
1900
+ onClick: handleNavigateToLogin,
1901
+ children: t('ChangePassword.backToLogin')
1902
+ })
1903
+ })
1904
+ ]
1905
+ })
1906
+ })
1907
+ });
1908
+ };
1909
+ ChangePassword.propTypes = {
1910
+ navigateToLogin: external_prop_types_default().func.isRequired,
1911
+ checkToken: external_prop_types_default().func.isRequired,
1912
+ submitChangePassword: external_prop_types_default().func.isRequired
1913
+ };
1702
1914
  const useErrorModal_logger = new codebit_web_namespaceObject.Logger('useErrorModal');
1703
1915
  function useErrorModal() {
1704
1916
  const { modal } = external_antd_namespaceObject.App.useApp();
@@ -1727,6 +1939,7 @@ var __webpack_exports__ = {};
1727
1939
  };
1728
1940
  }
1729
1941
  })();
1942
+ exports.ChangePassword = __webpack_exports__.ChangePassword;
1730
1943
  exports.CodebitConfigContext = __webpack_exports__.CodebitConfigContext;
1731
1944
  exports.CodebitConfigProvider = __webpack_exports__.CodebitConfigProvider;
1732
1945
  exports.CodebitThemeContext = __webpack_exports__.CodebitThemeContext;
@@ -1737,7 +1950,8 @@ exports.FilterContainer = __webpack_exports__.FilterContainer;
1737
1950
  exports.ForgotPassword = __webpack_exports__.ForgotPassword;
1738
1951
  exports.HandleError = __webpack_exports__.HandleError;
1739
1952
  exports.ListCard = __webpack_exports__.ListCard;
1740
- exports.LocalLoginAuthenticationResult = __webpack_exports__.LocalLoginAuthenticationResult;
1953
+ exports.LocalLoginAuthenticationEnum = __webpack_exports__.LocalLoginAuthenticationEnum;
1954
+ exports.LocalLoginChangePasswordResult = __webpack_exports__.LocalLoginChangePasswordResult;
1741
1955
  exports.LocalLoginRecoveryPasswordResult = __webpack_exports__.LocalLoginRecoveryPasswordResult;
1742
1956
  exports.LoggedMainContainer = __webpack_exports__.LoggedMainContainer;
1743
1957
  exports.Login = __webpack_exports__.Login;
@@ -1747,6 +1961,7 @@ exports.ThemeToggle = __webpack_exports__.ThemeToggle;
1747
1961
  exports.useErrorMessage = __webpack_exports__.useErrorMessage;
1748
1962
  exports.useErrorModal = __webpack_exports__.useErrorModal;
1749
1963
  for(var __rspack_i in __webpack_exports__)if (-1 === [
1964
+ "ChangePassword",
1750
1965
  "CodebitConfigContext",
1751
1966
  "CodebitConfigProvider",
1752
1967
  "CodebitThemeContext",
@@ -1757,7 +1972,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
1757
1972
  "ForgotPassword",
1758
1973
  "HandleError",
1759
1974
  "ListCard",
1760
- "LocalLoginAuthenticationResult",
1975
+ "LocalLoginAuthenticationEnum",
1976
+ "LocalLoginChangePasswordResult",
1761
1977
  "LocalLoginRecoveryPasswordResult",
1762
1978
  "LoggedMainContainer",
1763
1979
  "Login",
package/dist/index.css CHANGED
@@ -151,13 +151,9 @@ html.dark-theme {
151
151
  display: flex;
152
152
  }
153
153
 
154
- .logoutMenu-_RLfGo {
154
+ .bottomMenu-VtOktS {
155
155
  border-top: 1px solid var(--antd-color-split);
156
156
  background: none;
157
- justify-content: center;
158
- align-items: center;
159
- margin-top: auto;
160
- display: flex;
161
157
  }
162
158
 
163
159
  .header-vgc67L {
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { NavigateFunction } from 'react-router';
2
3
 
3
4
  /** Enumeration of possible authentication result codes. */
4
- export enum LocalLoginAuthenticationResult {
5
+ export enum LocalLoginAuthenticationEnum {
5
6
  INVALID_EMAIL = 'INVALID_EMAIL',
6
7
  INVALID_PASSWORD = 'INVALID_PASSWORD',
7
8
  INVALID_EMAIL_OR_PASSWORD = 'INVALID_EMAIL_OR_PASSWORD',
@@ -10,14 +11,19 @@ export enum LocalLoginAuthenticationResult {
10
11
  SUCCESS = 'SUCCESS',
11
12
  }
12
13
 
14
+ /**
15
+ * Result type for local login authentication.
16
+ *
17
+ * It can be either one of the predefined values from {@link LocalLoginAuthenticationEnum} or a custom string message.
18
+ */
19
+ export type LocalLoginAuthenticationResult =
20
+ | LocalLoginAuthenticationEnum
21
+ | string;
22
+
13
23
  /** Context object passed to navigation and authentication callback functions. */
14
24
  export interface LocalLoginConfContext {
15
- /**
16
- * Function to navigate to another route.
17
- *
18
- * @param path - The path to navigate to.
19
- */
20
- navigate: (path: string) => void;
25
+ /** Function to navigate to another route. */
26
+ navigate: NavigateFunction;
21
27
  }
22
28
 
23
29
  /** Props for the Login component. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebit-programando-solucoes/codebit-web-antd",
3
- "version": "1.1.23",
3
+ "version": "1.1.25",
4
4
  "main": "./dist/index.cjs",
5
5
  "type": "module",
6
6
  "types": "./src/index.d.ts",