@lincros-ui/components 0.2.19 → 0.2.21
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 +36 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -140
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -42,7 +42,6 @@ var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
|
42
42
|
var TogglePrimitive = require('@radix-ui/react-toggle');
|
|
43
43
|
var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
|
|
44
44
|
var reactRouterDom = require('react-router-dom');
|
|
45
|
-
var menuPermissions = require('@/lib/menu-permissions');
|
|
46
45
|
var react = require('@tiptap/react');
|
|
47
46
|
var StarterKit = require('@tiptap/starter-kit');
|
|
48
47
|
var Image2 = require('@tiptap/extension-image');
|
|
@@ -4827,8 +4826,30 @@ var MenuPermissionLevel = /* @__PURE__ */ ((MenuPermissionLevel2) => {
|
|
|
4827
4826
|
MenuPermissionLevel2["ADMIN_ONLY"] = "ADMIN_ONLY";
|
|
4828
4827
|
MenuPermissionLevel2["MANAGER_OR_ADMIN"] = "MANAGER_OR_ADMIN";
|
|
4829
4828
|
MenuPermissionLevel2["MASTER_TENANT_ONLY"] = "MASTER_TENANT_ONLY";
|
|
4829
|
+
MenuPermissionLevel2["NON_MASTER_TENANT_ONLY"] = "NON_MASTER_TENANT_ONLY";
|
|
4830
4830
|
return MenuPermissionLevel2;
|
|
4831
4831
|
})(MenuPermissionLevel || {});
|
|
4832
|
+
|
|
4833
|
+
// src/lib/menu-permissions.ts
|
|
4834
|
+
var MANAGER_PROFILE_ID = 6;
|
|
4835
|
+
function canAccessMenu(user, permission, isMasterTenant) {
|
|
4836
|
+
if (!permission || permission === "ALL" /* ALL */) return true;
|
|
4837
|
+
if (!user) return false;
|
|
4838
|
+
const isAdmin = user.is_admin === true;
|
|
4839
|
+
const isManager = user.perfil_usuario_id === MANAGER_PROFILE_ID;
|
|
4840
|
+
switch (permission) {
|
|
4841
|
+
case "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */:
|
|
4842
|
+
return isAdmin || isManager;
|
|
4843
|
+
case "ADMIN_ONLY" /* ADMIN_ONLY */:
|
|
4844
|
+
return isAdmin;
|
|
4845
|
+
case "MASTER_TENANT_ONLY" /* MASTER_TENANT_ONLY */:
|
|
4846
|
+
return isMasterTenant === true;
|
|
4847
|
+
case "NON_MASTER_TENANT_ONLY" /* NON_MASTER_TENANT_ONLY */:
|
|
4848
|
+
return isMasterTenant !== true;
|
|
4849
|
+
default:
|
|
4850
|
+
return false;
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4832
4853
|
var STORAGE_KEY = "sidebar-expanded-menus";
|
|
4833
4854
|
function useSidebarState(routePaths) {
|
|
4834
4855
|
const location = reactRouterDom.useLocation();
|
|
@@ -5067,12 +5088,13 @@ function PasswordResetModal({
|
|
|
5067
5088
|
] })
|
|
5068
5089
|
] }) });
|
|
5069
5090
|
}
|
|
5070
|
-
function filterMenuItems(items, user) {
|
|
5071
|
-
return items.filter((item) =>
|
|
5091
|
+
function filterMenuItems(items, user, isMasterTenant) {
|
|
5092
|
+
return items.filter((item) => canAccessMenu(user, item.permission, isMasterTenant)).map((item) => {
|
|
5072
5093
|
if (item.subItems) {
|
|
5073
5094
|
const filteredSubItems = filterMenuItems(
|
|
5074
5095
|
item.subItems,
|
|
5075
|
-
user
|
|
5096
|
+
user,
|
|
5097
|
+
isMasterTenant
|
|
5076
5098
|
);
|
|
5077
5099
|
if (filteredSubItems.length === 0) {
|
|
5078
5100
|
return null;
|
|
@@ -5161,7 +5183,8 @@ function ControlSidebar({
|
|
|
5161
5183
|
logoUrl = "/lovable-uploads/632ebc32-3ae3-4944-8e70-0e9c2539494a.png",
|
|
5162
5184
|
faviconUrl,
|
|
5163
5185
|
appName = "App",
|
|
5164
|
-
appSubtitle = "Sistema"
|
|
5186
|
+
appSubtitle = "Sistema",
|
|
5187
|
+
menuItems: menuItemsProp
|
|
5165
5188
|
}) {
|
|
5166
5189
|
const {
|
|
5167
5190
|
toggleSubmenu,
|
|
@@ -5184,136 +5207,6 @@ function ControlSidebar({
|
|
|
5184
5207
|
}
|
|
5185
5208
|
}
|
|
5186
5209
|
};
|
|
5187
|
-
const menuItems = [
|
|
5188
|
-
{
|
|
5189
|
-
title: "Dashboard",
|
|
5190
|
-
url: routePaths.DASHBOARD,
|
|
5191
|
-
icon: lucideReact.Monitor,
|
|
5192
|
-
permission: "ALL" /* ALL */
|
|
5193
|
-
},
|
|
5194
|
-
{
|
|
5195
|
-
title: "Monitoramento de Rotas",
|
|
5196
|
-
url: routePaths.ROUTE_MONITORING,
|
|
5197
|
-
icon: lucideReact.Navigation,
|
|
5198
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5199
|
-
},
|
|
5200
|
-
{
|
|
5201
|
-
title: "Alertas",
|
|
5202
|
-
url: routePaths.ALERTS,
|
|
5203
|
-
icon: lucideReact.Bell,
|
|
5204
|
-
permission: "ALL" /* ALL */
|
|
5205
|
-
},
|
|
5206
|
-
{
|
|
5207
|
-
title: "Relat\xF3rios",
|
|
5208
|
-
url: routePaths.REPORTS,
|
|
5209
|
-
icon: lucideReact.BarChart3,
|
|
5210
|
-
permission: "ALL" /* ALL */
|
|
5211
|
-
},
|
|
5212
|
-
{
|
|
5213
|
-
title: "Configura\xE7\xF5es",
|
|
5214
|
-
icon: lucideReact.Settings,
|
|
5215
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */,
|
|
5216
|
-
subItems: [
|
|
5217
|
-
{
|
|
5218
|
-
title: "Configura\xE7\xF5es Gerais",
|
|
5219
|
-
url: routePaths.SETTINGS,
|
|
5220
|
-
icon: lucideReact.Settings,
|
|
5221
|
-
permission: "ALL" /* ALL */
|
|
5222
|
-
},
|
|
5223
|
-
{
|
|
5224
|
-
title: "Usu\xE1rios",
|
|
5225
|
-
icon: lucideReact.Users,
|
|
5226
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5227
|
-
subItems: [
|
|
5228
|
-
{
|
|
5229
|
-
title: "Gest\xE3o de Usu\xE1rios",
|
|
5230
|
-
url: routePaths.USER_MANAGEMENT,
|
|
5231
|
-
icon: lucideReact.UserCheck,
|
|
5232
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5233
|
-
},
|
|
5234
|
-
{
|
|
5235
|
-
title: "Perfis de Usu\xE1rio",
|
|
5236
|
-
url: routePaths.USER_PROFILES,
|
|
5237
|
-
icon: lucideReact.UserCog,
|
|
5238
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5239
|
-
},
|
|
5240
|
-
{
|
|
5241
|
-
title: "Permiss\xF5es",
|
|
5242
|
-
url: routePaths.PERMISSIONS_MANAGEMENT,
|
|
5243
|
-
icon: lucideReact.Shield,
|
|
5244
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5245
|
-
}
|
|
5246
|
-
]
|
|
5247
|
-
},
|
|
5248
|
-
{
|
|
5249
|
-
title: "Motoristas",
|
|
5250
|
-
url: routePaths.MOTORISTAS,
|
|
5251
|
-
icon: lucideReact.Car,
|
|
5252
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5253
|
-
},
|
|
5254
|
-
{
|
|
5255
|
-
title: "WhatsApp",
|
|
5256
|
-
icon: lucideReact.MessageCircle,
|
|
5257
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5258
|
-
subItems: [
|
|
5259
|
-
{
|
|
5260
|
-
title: "Configura\xE7\xF5es",
|
|
5261
|
-
url: routePaths.WHATSAPP_CONFIG,
|
|
5262
|
-
icon: lucideReact.Settings,
|
|
5263
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5264
|
-
},
|
|
5265
|
-
{
|
|
5266
|
-
title: "Triggers de Fluxo",
|
|
5267
|
-
url: routePaths.WHATSAPP_TRIGGERS,
|
|
5268
|
-
icon: lucideReact.Workflow,
|
|
5269
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5270
|
-
},
|
|
5271
|
-
{
|
|
5272
|
-
title: "Monitoramento",
|
|
5273
|
-
url: routePaths.WHATSAPP_MONITORING,
|
|
5274
|
-
icon: lucideReact.Monitor,
|
|
5275
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5276
|
-
}
|
|
5277
|
-
]
|
|
5278
|
-
},
|
|
5279
|
-
...isMasterTenant ? [] : [
|
|
5280
|
-
{
|
|
5281
|
-
title: "Unidades de Neg\xF3cio",
|
|
5282
|
-
url: routePaths.UNIDADES_NEGOCIO,
|
|
5283
|
-
icon: lucideReact.Building2,
|
|
5284
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5285
|
-
}
|
|
5286
|
-
],
|
|
5287
|
-
...isMasterTenant ? [
|
|
5288
|
-
{
|
|
5289
|
-
title: "Tenants",
|
|
5290
|
-
url: routePaths.TENANT_MANAGEMENT,
|
|
5291
|
-
icon: lucideReact.Database,
|
|
5292
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5293
|
-
}
|
|
5294
|
-
] : []
|
|
5295
|
-
]
|
|
5296
|
-
},
|
|
5297
|
-
{
|
|
5298
|
-
title: "Automa\xE7\xE3o",
|
|
5299
|
-
icon: lucideReact.Bot,
|
|
5300
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5301
|
-
subItems: [
|
|
5302
|
-
{
|
|
5303
|
-
title: "Fluxos de Automa\xE7\xE3o",
|
|
5304
|
-
url: routePaths.FLOWS,
|
|
5305
|
-
icon: lucideReact.Workflow,
|
|
5306
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5307
|
-
},
|
|
5308
|
-
{
|
|
5309
|
-
title: "Credenciais",
|
|
5310
|
-
url: routePaths.CREDENTIALS,
|
|
5311
|
-
icon: lucideReact.Key,
|
|
5312
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5313
|
-
}
|
|
5314
|
-
]
|
|
5315
|
-
}
|
|
5316
|
-
];
|
|
5317
5210
|
React37__namespace.default.useEffect(() => {
|
|
5318
5211
|
if (!currentTime) {
|
|
5319
5212
|
const timer = setInterval(() => {
|
|
@@ -5322,8 +5215,9 @@ function ControlSidebar({
|
|
|
5322
5215
|
return () => clearInterval(timer);
|
|
5323
5216
|
}
|
|
5324
5217
|
}, [currentTime]);
|
|
5218
|
+
const resolvedMenuItems = menuItemsProp ?? [];
|
|
5325
5219
|
const displayTime = currentTime || internalTime;
|
|
5326
|
-
const filteredMenuItems = filterMenuItems(
|
|
5220
|
+
const filteredMenuItems = filterMenuItems(resolvedMenuItems, user, isMasterTenant);
|
|
5327
5221
|
return /* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { className: "border-r border-gray-200", collapsible: "icon", children: [
|
|
5328
5222
|
/* @__PURE__ */ jsxRuntime.jsxs(SidebarHeader, { className: "border-b border-gray-200", children: [
|
|
5329
5223
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between px-2 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, { className: "ml-auto" }) }),
|
|
@@ -5509,7 +5403,8 @@ function MainLayout({
|
|
|
5509
5403
|
appSubtitle,
|
|
5510
5404
|
logoUrl,
|
|
5511
5405
|
faviconUrl,
|
|
5512
|
-
sidebarDefaultOpen
|
|
5406
|
+
sidebarDefaultOpen,
|
|
5407
|
+
menuItems
|
|
5513
5408
|
}) {
|
|
5514
5409
|
return /* @__PURE__ */ jsxRuntime.jsx(SidebarProvider, { defaultOpen: sidebarDefaultOpen, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-screen w-full flex", children: [
|
|
5515
5410
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5526,13 +5421,14 @@ function MainLayout({
|
|
|
5526
5421
|
appName,
|
|
5527
5422
|
appSubtitle,
|
|
5528
5423
|
logoUrl,
|
|
5529
|
-
faviconUrl
|
|
5424
|
+
faviconUrl,
|
|
5425
|
+
menuItems
|
|
5530
5426
|
}
|
|
5531
5427
|
),
|
|
5532
5428
|
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full overflow-y-auto", children }) })
|
|
5533
5429
|
] }) });
|
|
5534
5430
|
}
|
|
5535
|
-
function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, onResetPassword, resetPasswordLoading, resetPasswordError, appName, appSubtitle, logoUrl, faviconUrl, sidebarDefaultOpen }) {
|
|
5431
|
+
function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, onResetPassword, resetPasswordLoading, resetPasswordError, appName, appSubtitle, logoUrl, faviconUrl, sidebarDefaultOpen, menuItems }) {
|
|
5536
5432
|
const { isAuthenticated, isLoading, logout, user, getCurrentTenantId } = useAuthContext();
|
|
5537
5433
|
const location = reactRouterDom.useLocation();
|
|
5538
5434
|
const sso = useSSO(tenantId || void 0);
|
|
@@ -5581,6 +5477,7 @@ function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths
|
|
|
5581
5477
|
logoUrl,
|
|
5582
5478
|
faviconUrl,
|
|
5583
5479
|
sidebarDefaultOpen,
|
|
5480
|
+
menuItems,
|
|
5584
5481
|
children: /* @__PURE__ */ jsxRuntime.jsx(EnsureTenant, { useTenant, tenantService, children })
|
|
5585
5482
|
}
|
|
5586
5483
|
);
|