@lincros-ui/components 0.2.12 → 0.2.14

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.cjs CHANGED
@@ -4925,6 +4925,139 @@ function useSidebarState(routePaths) {
4925
4925
  isExactMenuItemActive
4926
4926
  };
4927
4927
  }
4928
+ function PasswordResetModal({
4929
+ open,
4930
+ onOpenChange,
4931
+ onSubmit,
4932
+ loading = false,
4933
+ error = null
4934
+ }) {
4935
+ const [formData, setFormData] = React37__namespace.default.useState({
4936
+ oldPassword: "",
4937
+ newPassword: "",
4938
+ confirmPassword: ""
4939
+ });
4940
+ const [validationError, setValidationError] = React37__namespace.default.useState(
4941
+ null
4942
+ );
4943
+ const handleInputChange = (field, value) => {
4944
+ setFormData((prev) => ({ ...prev, [field]: value }));
4945
+ setValidationError(null);
4946
+ };
4947
+ const validateForm = () => {
4948
+ if (!formData.oldPassword) {
4949
+ setValidationError("Senha atual \xE9 obrigat\xF3ria");
4950
+ return false;
4951
+ }
4952
+ if (!formData.newPassword) {
4953
+ setValidationError("Nova senha \xE9 obrigat\xF3ria");
4954
+ return false;
4955
+ }
4956
+ if (formData.newPassword.length < 8) {
4957
+ setValidationError("Nova senha deve ter no m\xEDnimo 8 caracteres");
4958
+ return false;
4959
+ }
4960
+ if (formData.newPassword !== formData.confirmPassword) {
4961
+ setValidationError("As senhas n\xE3o coincidem");
4962
+ return false;
4963
+ }
4964
+ if (formData.oldPassword === formData.newPassword) {
4965
+ setValidationError("Nova senha deve ser diferente da senha atual");
4966
+ return false;
4967
+ }
4968
+ return true;
4969
+ };
4970
+ const handleSubmit = async (e) => {
4971
+ e.preventDefault();
4972
+ if (!validateForm()) return;
4973
+ await onSubmit(formData);
4974
+ };
4975
+ const handleClose = () => {
4976
+ if (!loading) {
4977
+ setFormData({
4978
+ oldPassword: "",
4979
+ newPassword: "",
4980
+ confirmPassword: ""
4981
+ });
4982
+ setValidationError(null);
4983
+ onOpenChange(false);
4984
+ }
4985
+ };
4986
+ const displayError = error || validationError;
4987
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-[425px]", children: [
4988
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
4989
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Redefinir Senha" }),
4990
+ /* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Digite sua senha atual e escolha uma nova senha. A senha deve ter no m\xEDnimo 8 caracteres." })
4991
+ ] }),
4992
+ /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
4993
+ displayError && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 p-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded-md", children: [
4994
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "w-4 h-4 shrink-0" }),
4995
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: displayError })
4996
+ ] }),
4997
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
4998
+ /* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "old-password", children: "Senha Atual" }),
4999
+ /* @__PURE__ */ jsxRuntime.jsx(
5000
+ Input,
5001
+ {
5002
+ id: "old-password",
5003
+ type: "password",
5004
+ value: formData.oldPassword,
5005
+ onChange: (e) => handleInputChange("oldPassword", e.target.value),
5006
+ disabled: loading,
5007
+ leftIcon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "w-4 h-4" }),
5008
+ placeholder: "Digite sua senha atual",
5009
+ required: true
5010
+ }
5011
+ )
5012
+ ] }),
5013
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
5014
+ /* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "new-password", children: "Nova Senha" }),
5015
+ /* @__PURE__ */ jsxRuntime.jsx(
5016
+ Input,
5017
+ {
5018
+ id: "new-password",
5019
+ type: "password",
5020
+ value: formData.newPassword,
5021
+ onChange: (e) => handleInputChange("newPassword", e.target.value),
5022
+ disabled: loading,
5023
+ leftIcon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "w-4 h-4" }),
5024
+ placeholder: "Digite sua nova senha",
5025
+ required: true
5026
+ }
5027
+ )
5028
+ ] }),
5029
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
5030
+ /* @__PURE__ */ jsxRuntime.jsx(Label3, { htmlFor: "confirm-password", children: "Confirmar Nova Senha" }),
5031
+ /* @__PURE__ */ jsxRuntime.jsx(
5032
+ Input,
5033
+ {
5034
+ id: "confirm-password",
5035
+ type: "password",
5036
+ value: formData.confirmPassword,
5037
+ onChange: (e) => handleInputChange("confirmPassword", e.target.value),
5038
+ disabled: loading,
5039
+ leftIcon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { className: "w-4 h-4" }),
5040
+ placeholder: "Confirme sua nova senha",
5041
+ required: true
5042
+ }
5043
+ )
5044
+ ] }),
5045
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { children: [
5046
+ /* @__PURE__ */ jsxRuntime.jsx(
5047
+ Button,
5048
+ {
5049
+ type: "button",
5050
+ variant: "outline",
5051
+ onClick: handleClose,
5052
+ disabled: loading,
5053
+ children: "Cancelar"
5054
+ }
5055
+ ),
5056
+ /* @__PURE__ */ jsxRuntime.jsx(Button, { type: "submit", disabled: loading, children: loading ? "Redefinindo..." : "Redefinir Senha" })
5057
+ ] })
5058
+ ] })
5059
+ ] }) });
5060
+ }
4928
5061
  function filterMenuItems(items, user) {
4929
5062
  return items.filter((item) => menuPermissions.canAccessMenu(user, item.permission)).map((item) => {
4930
5063
  if (item.subItems) {
@@ -5012,6 +5145,9 @@ function ControlSidebar({
5012
5145
  routePaths,
5013
5146
  user,
5014
5147
  onLogout,
5148
+ onResetPassword,
5149
+ resetPasswordLoading = false,
5150
+ resetPasswordError = null,
5015
5151
  getCurrentTenantId,
5016
5152
  logoUrl = "/lovable-uploads/632ebc32-3ae3-4944-8e70-0e9c2539494a.png",
5017
5153
  faviconUrl,
@@ -5027,9 +5163,18 @@ function ControlSidebar({
5027
5163
  const { state } = useSidebar();
5028
5164
  const isCollapsed = state === "collapsed";
5029
5165
  const [internalTime, setInternalTime] = React37__namespace.default.useState(/* @__PURE__ */ new Date());
5166
+ const [isPasswordResetOpen, setIsPasswordResetOpen] = React37__namespace.default.useState(false);
5030
5167
  const currentTenantId = getCurrentTenantId();
5031
5168
  console.log(currentTenantId);
5032
5169
  const isMasterTenant = currentTenantId === "master";
5170
+ const handlePasswordReset = async (data) => {
5171
+ if (onResetPassword) {
5172
+ await onResetPassword(data);
5173
+ if (!resetPasswordError) {
5174
+ setIsPasswordResetOpen(false);
5175
+ }
5176
+ }
5177
+ };
5033
5178
  const menuItems = [
5034
5179
  {
5035
5180
  title: "Dashboard",
@@ -5128,12 +5273,14 @@ function ControlSidebar({
5128
5273
  }
5129
5274
  ]
5130
5275
  },
5131
- ...isMasterTenant ? [] : [{
5132
- title: "Unidades de Neg\xF3cio",
5133
- url: routePaths.UNIDADES_NEGOCIO,
5134
- icon: lucideReact.Building2,
5135
- permission: menuPermissions.MenuPermissionLevel.MANAGER_OR_ADMIN
5136
- }],
5276
+ ...isMasterTenant ? [] : [
5277
+ {
5278
+ title: "Unidades de Neg\xF3cio",
5279
+ url: routePaths.UNIDADES_NEGOCIO,
5280
+ icon: lucideReact.Building2,
5281
+ permission: menuPermissions.MenuPermissionLevel.MANAGER_OR_ADMIN
5282
+ }
5283
+ ],
5137
5284
  ...isMasterTenant ? [
5138
5285
  {
5139
5286
  title: "Tenants",
@@ -5196,7 +5343,7 @@ function ControlSidebar({
5196
5343
  {
5197
5344
  src: faviconUrl || logoUrl,
5198
5345
  alt: `${appName} Logo`,
5199
- className: "w-8 h-8 object-contain"
5346
+ className: "w-10 object-contain"
5200
5347
  }
5201
5348
  ) })
5202
5349
  ] }),
@@ -5256,32 +5403,60 @@ function ControlSidebar({
5256
5403
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium text-gray-700 truncate", children: user.login }),
5257
5404
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-500 truncate", children: user.email })
5258
5405
  ] }),
5259
- /* @__PURE__ */ jsxRuntime.jsx(
5260
- Button,
5261
- {
5262
- variant: "ghost",
5263
- size: "sm",
5264
- onClick: () => onLogout(),
5265
- className: "h-8 w-8 p-0 shrink-0 ml-2",
5266
- title: "Logout",
5267
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "icon-size" })
5268
- }
5269
- )
5270
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
5271
- /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
5272
- Button,
5273
- {
5274
- variant: "ghost",
5275
- size: "sm",
5276
- onClick: () => onLogout(),
5277
- className: "h-8 w-8 p-0",
5278
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "icon-size" })
5279
- }
5280
- ) }),
5281
- /* @__PURE__ */ jsxRuntime.jsxs(TooltipContent, { side: "right", className: "font-medium", children: [
5282
- "Logout (",
5283
- user.login,
5284
- ")"
5406
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1 shrink-0 ml-2", children: [
5407
+ onResetPassword && /* @__PURE__ */ jsxRuntime.jsx(
5408
+ Button,
5409
+ {
5410
+ variant: "ghost",
5411
+ size: "sm",
5412
+ onClick: () => setIsPasswordResetOpen(true),
5413
+ className: "h-8 w-8 p-0",
5414
+ title: "Redefinir Senha",
5415
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings2, { className: "icon-size" })
5416
+ }
5417
+ ),
5418
+ /* @__PURE__ */ jsxRuntime.jsx(
5419
+ Button,
5420
+ {
5421
+ variant: "ghost",
5422
+ size: "sm",
5423
+ onClick: () => onLogout(),
5424
+ className: "h-8 w-8 p-0",
5425
+ title: "Logout",
5426
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "icon-size" })
5427
+ }
5428
+ )
5429
+ ] })
5430
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
5431
+ onResetPassword ? /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
5432
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
5433
+ Button,
5434
+ {
5435
+ variant: "ghost",
5436
+ size: "sm",
5437
+ onClick: () => setIsPasswordResetOpen(true),
5438
+ className: "h-8 w-8 p-0",
5439
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Settings2, { className: "icon-size" })
5440
+ }
5441
+ ) }),
5442
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "right", className: "font-medium", children: "Redefinir Senha" })
5443
+ ] }) : null,
5444
+ /* @__PURE__ */ jsxRuntime.jsxs(Tooltip2, { children: [
5445
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
5446
+ Button,
5447
+ {
5448
+ variant: "ghost",
5449
+ size: "sm",
5450
+ onClick: () => onLogout(),
5451
+ className: "h-8 w-8 p-0",
5452
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "icon-size" })
5453
+ }
5454
+ ) }),
5455
+ /* @__PURE__ */ jsxRuntime.jsxs(TooltipContent, { side: "right", className: "font-medium", children: [
5456
+ "Logout (",
5457
+ user.login,
5458
+ ")"
5459
+ ] })
5285
5460
  ] })
5286
5461
  ] }) }),
5287
5462
  !isCollapsed && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -5304,7 +5479,17 @@ function ControlSidebar({
5304
5479
  /* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "right", className: "font-medium", children: displayTime.toLocaleString("pt-BR") })
5305
5480
  ] })
5306
5481
  ] })
5307
- ] }) })
5482
+ ] }) }),
5483
+ onResetPassword ? /* @__PURE__ */ jsxRuntime.jsx(
5484
+ PasswordResetModal,
5485
+ {
5486
+ open: isPasswordResetOpen,
5487
+ onOpenChange: setIsPasswordResetOpen,
5488
+ onSubmit: handlePasswordReset,
5489
+ loading: resetPasswordLoading,
5490
+ error: resetPasswordError
5491
+ }
5492
+ ) : null
5308
5493
  ] });
5309
5494
  }
5310
5495
  function MainLayout({
@@ -5312,6 +5497,9 @@ function MainLayout({
5312
5497
  routePaths,
5313
5498
  user,
5314
5499
  onLogout,
5500
+ onResetPassword,
5501
+ resetPasswordLoading,
5502
+ resetPasswordError,
5315
5503
  getCurrentTenantId,
5316
5504
  currentTime,
5317
5505
  appName,
@@ -5326,6 +5514,9 @@ function MainLayout({
5326
5514
  routePaths,
5327
5515
  user,
5328
5516
  onLogout,
5517
+ onResetPassword,
5518
+ resetPasswordLoading,
5519
+ resetPasswordError,
5329
5520
  getCurrentTenantId,
5330
5521
  currentTime,
5331
5522
  appName,
@@ -5337,7 +5528,7 @@ function MainLayout({
5337
5528
  /* @__PURE__ */ jsxRuntime.jsx("main", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-auto", children }) })
5338
5529
  ] }) });
5339
5530
  }
5340
- function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, appName, appSubtitle, logoUrl, faviconUrl }) {
5531
+ function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, onResetPassword, resetPasswordLoading, resetPasswordError, appName, appSubtitle, logoUrl, faviconUrl }) {
5341
5532
  const { isAuthenticated, isLoading, logout, user, getCurrentTenantId } = useAuthContext();
5342
5533
  const location = reactRouterDom.useLocation();
5343
5534
  const sso = useSSO(tenantId || void 0);
@@ -5377,6 +5568,9 @@ function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths
5377
5568
  routePaths,
5378
5569
  user,
5379
5570
  onLogout: logout,
5571
+ onResetPassword,
5572
+ resetPasswordLoading,
5573
+ resetPasswordError,
5380
5574
  getCurrentTenantId,
5381
5575
  appName,
5382
5576
  appSubtitle,
@@ -11737,6 +11931,7 @@ exports.ContextMenuSub = ContextMenuSub;
11737
11931
  exports.ContextMenuSubContent = ContextMenuSubContent;
11738
11932
  exports.ContextMenuSubTrigger = ContextMenuSubTrigger;
11739
11933
  exports.ContextMenuTrigger = ContextMenuTrigger;
11934
+ exports.ControlSidebar = ControlSidebar;
11740
11935
  exports.CountBadge = CountBadge;
11741
11936
  exports.CustomSidebarMenuSub = CustomSidebarMenuSub;
11742
11937
  exports.CustomSidebarMenuSubButton = CustomSidebarMenuSubButton;
@@ -11839,6 +12034,7 @@ exports.PaginationItem = PaginationItem;
11839
12034
  exports.PaginationLink = PaginationLink;
11840
12035
  exports.PaginationNext = PaginationNext;
11841
12036
  exports.PaginationPrevious = PaginationPrevious;
12037
+ exports.PasswordResetModal = PasswordResetModal;
11842
12038
  exports.Popover = Popover;
11843
12039
  exports.PopoverContent = PopoverContent;
11844
12040
  exports.PopoverTrigger = PopoverTrigger;