@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.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React37 from 'react';
|
|
2
2
|
import React37__default, { memo, useMemo, useCallback, useState, useRef, useEffect } from 'react';
|
|
3
3
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
4
|
-
import { ChevronDown, ArrowLeft, ArrowRight, Check, X, Search, ChevronRight, Circle, Minimize2, Maximize2, Dot, ChevronUp, PanelLeft, Clock, AlertCircle, CheckCircle, Shield, AlertTriangle, Users, RefreshCw, Home, ExternalLink, LogIn, Server, Key, MoreHorizontal, ChevronLeft, Phone, Video, Info, MoreVertical, Paperclip, Smile, Mic, Send, GripVertical, Lock,
|
|
4
|
+
import { ChevronDown, ArrowLeft, ArrowRight, Check, X, Search, ChevronRight, Circle, Minimize2, Maximize2, Dot, ChevronUp, PanelLeft, Clock, AlertCircle, CheckCircle, Shield, AlertTriangle, Users, RefreshCw, Home, ExternalLink, LogIn, Server, Key, MoreHorizontal, ChevronLeft, Phone, Video, Info, MoreVertical, Paperclip, Smile, Mic, Send, GripVertical, Lock, Settings2, LogOut, Loader2, Bot, User, Building2, UserCheck, ClipboardList, Filter, ChevronsLeft, ChevronsRight, Bold, Italic, List, ListOrdered, Quote, Code, Link2, Image, Plus, LayoutGrid, MessageSquare, FileJson, Activity, Database, Hash, Copy, Zap, Network, Timer, Eye, Workflow, GitBranch, Terminal, Pause, Play, Trash2, Download, FileText, History, MessageCircle, QrCode, TrendingUp, TrendingDown, BarChart3, XCircle, CheckCircle2, Wifi, WifiOff, TestTube, Save, Bug, MapPin, CheckCheck } from 'lucide-react';
|
|
5
5
|
import { clsx } from 'clsx';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -42,7 +42,6 @@ import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
|
42
42
|
import * as TogglePrimitive from '@radix-ui/react-toggle';
|
|
43
43
|
import * as ToggleGroupPrimitive from '@radix-ui/react-toggle-group';
|
|
44
44
|
import { Link, useLocation, Navigate, useNavigate } from 'react-router-dom';
|
|
45
|
-
import { canAccessMenu } from '@/lib/menu-permissions';
|
|
46
45
|
import { useEditor, EditorContent } from '@tiptap/react';
|
|
47
46
|
import StarterKit from '@tiptap/starter-kit';
|
|
48
47
|
import Image2 from '@tiptap/extension-image';
|
|
@@ -4770,8 +4769,30 @@ var MenuPermissionLevel = /* @__PURE__ */ ((MenuPermissionLevel2) => {
|
|
|
4770
4769
|
MenuPermissionLevel2["ADMIN_ONLY"] = "ADMIN_ONLY";
|
|
4771
4770
|
MenuPermissionLevel2["MANAGER_OR_ADMIN"] = "MANAGER_OR_ADMIN";
|
|
4772
4771
|
MenuPermissionLevel2["MASTER_TENANT_ONLY"] = "MASTER_TENANT_ONLY";
|
|
4772
|
+
MenuPermissionLevel2["NON_MASTER_TENANT_ONLY"] = "NON_MASTER_TENANT_ONLY";
|
|
4773
4773
|
return MenuPermissionLevel2;
|
|
4774
4774
|
})(MenuPermissionLevel || {});
|
|
4775
|
+
|
|
4776
|
+
// src/lib/menu-permissions.ts
|
|
4777
|
+
var MANAGER_PROFILE_ID = 6;
|
|
4778
|
+
function canAccessMenu(user, permission, isMasterTenant) {
|
|
4779
|
+
if (!permission || permission === "ALL" /* ALL */) return true;
|
|
4780
|
+
if (!user) return false;
|
|
4781
|
+
const isAdmin = user.is_admin === true;
|
|
4782
|
+
const isManager = user.perfil_usuario_id === MANAGER_PROFILE_ID;
|
|
4783
|
+
switch (permission) {
|
|
4784
|
+
case "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */:
|
|
4785
|
+
return isAdmin || isManager;
|
|
4786
|
+
case "ADMIN_ONLY" /* ADMIN_ONLY */:
|
|
4787
|
+
return isAdmin;
|
|
4788
|
+
case "MASTER_TENANT_ONLY" /* MASTER_TENANT_ONLY */:
|
|
4789
|
+
return isMasterTenant === true;
|
|
4790
|
+
case "NON_MASTER_TENANT_ONLY" /* NON_MASTER_TENANT_ONLY */:
|
|
4791
|
+
return isMasterTenant !== true;
|
|
4792
|
+
default:
|
|
4793
|
+
return false;
|
|
4794
|
+
}
|
|
4795
|
+
}
|
|
4775
4796
|
var STORAGE_KEY = "sidebar-expanded-menus";
|
|
4776
4797
|
function useSidebarState(routePaths) {
|
|
4777
4798
|
const location = useLocation();
|
|
@@ -5010,12 +5031,13 @@ function PasswordResetModal({
|
|
|
5010
5031
|
] })
|
|
5011
5032
|
] }) });
|
|
5012
5033
|
}
|
|
5013
|
-
function filterMenuItems(items, user) {
|
|
5014
|
-
return items.filter((item) => canAccessMenu(user, item.permission)).map((item) => {
|
|
5034
|
+
function filterMenuItems(items, user, isMasterTenant) {
|
|
5035
|
+
return items.filter((item) => canAccessMenu(user, item.permission, isMasterTenant)).map((item) => {
|
|
5015
5036
|
if (item.subItems) {
|
|
5016
5037
|
const filteredSubItems = filterMenuItems(
|
|
5017
5038
|
item.subItems,
|
|
5018
|
-
user
|
|
5039
|
+
user,
|
|
5040
|
+
isMasterTenant
|
|
5019
5041
|
);
|
|
5020
5042
|
if (filteredSubItems.length === 0) {
|
|
5021
5043
|
return null;
|
|
@@ -5104,7 +5126,8 @@ function ControlSidebar({
|
|
|
5104
5126
|
logoUrl = "/lovable-uploads/632ebc32-3ae3-4944-8e70-0e9c2539494a.png",
|
|
5105
5127
|
faviconUrl,
|
|
5106
5128
|
appName = "App",
|
|
5107
|
-
appSubtitle = "Sistema"
|
|
5129
|
+
appSubtitle = "Sistema",
|
|
5130
|
+
menuItems: menuItemsProp
|
|
5108
5131
|
}) {
|
|
5109
5132
|
const {
|
|
5110
5133
|
toggleSubmenu,
|
|
@@ -5127,136 +5150,6 @@ function ControlSidebar({
|
|
|
5127
5150
|
}
|
|
5128
5151
|
}
|
|
5129
5152
|
};
|
|
5130
|
-
const menuItems = [
|
|
5131
|
-
{
|
|
5132
|
-
title: "Dashboard",
|
|
5133
|
-
url: routePaths.DASHBOARD,
|
|
5134
|
-
icon: Monitor,
|
|
5135
|
-
permission: "ALL" /* ALL */
|
|
5136
|
-
},
|
|
5137
|
-
{
|
|
5138
|
-
title: "Monitoramento de Rotas",
|
|
5139
|
-
url: routePaths.ROUTE_MONITORING,
|
|
5140
|
-
icon: Navigation,
|
|
5141
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5142
|
-
},
|
|
5143
|
-
{
|
|
5144
|
-
title: "Alertas",
|
|
5145
|
-
url: routePaths.ALERTS,
|
|
5146
|
-
icon: Bell,
|
|
5147
|
-
permission: "ALL" /* ALL */
|
|
5148
|
-
},
|
|
5149
|
-
{
|
|
5150
|
-
title: "Relat\xF3rios",
|
|
5151
|
-
url: routePaths.REPORTS,
|
|
5152
|
-
icon: BarChart3,
|
|
5153
|
-
permission: "ALL" /* ALL */
|
|
5154
|
-
},
|
|
5155
|
-
{
|
|
5156
|
-
title: "Configura\xE7\xF5es",
|
|
5157
|
-
icon: Settings,
|
|
5158
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */,
|
|
5159
|
-
subItems: [
|
|
5160
|
-
{
|
|
5161
|
-
title: "Configura\xE7\xF5es Gerais",
|
|
5162
|
-
url: routePaths.SETTINGS,
|
|
5163
|
-
icon: Settings,
|
|
5164
|
-
permission: "ALL" /* ALL */
|
|
5165
|
-
},
|
|
5166
|
-
{
|
|
5167
|
-
title: "Usu\xE1rios",
|
|
5168
|
-
icon: Users,
|
|
5169
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5170
|
-
subItems: [
|
|
5171
|
-
{
|
|
5172
|
-
title: "Gest\xE3o de Usu\xE1rios",
|
|
5173
|
-
url: routePaths.USER_MANAGEMENT,
|
|
5174
|
-
icon: UserCheck,
|
|
5175
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5176
|
-
},
|
|
5177
|
-
{
|
|
5178
|
-
title: "Perfis de Usu\xE1rio",
|
|
5179
|
-
url: routePaths.USER_PROFILES,
|
|
5180
|
-
icon: UserCog,
|
|
5181
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5182
|
-
},
|
|
5183
|
-
{
|
|
5184
|
-
title: "Permiss\xF5es",
|
|
5185
|
-
url: routePaths.PERMISSIONS_MANAGEMENT,
|
|
5186
|
-
icon: Shield,
|
|
5187
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5188
|
-
}
|
|
5189
|
-
]
|
|
5190
|
-
},
|
|
5191
|
-
{
|
|
5192
|
-
title: "Motoristas",
|
|
5193
|
-
url: routePaths.MOTORISTAS,
|
|
5194
|
-
icon: Car,
|
|
5195
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5196
|
-
},
|
|
5197
|
-
{
|
|
5198
|
-
title: "WhatsApp",
|
|
5199
|
-
icon: MessageCircle,
|
|
5200
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5201
|
-
subItems: [
|
|
5202
|
-
{
|
|
5203
|
-
title: "Configura\xE7\xF5es",
|
|
5204
|
-
url: routePaths.WHATSAPP_CONFIG,
|
|
5205
|
-
icon: Settings,
|
|
5206
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5207
|
-
},
|
|
5208
|
-
{
|
|
5209
|
-
title: "Triggers de Fluxo",
|
|
5210
|
-
url: routePaths.WHATSAPP_TRIGGERS,
|
|
5211
|
-
icon: Workflow,
|
|
5212
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5213
|
-
},
|
|
5214
|
-
{
|
|
5215
|
-
title: "Monitoramento",
|
|
5216
|
-
url: routePaths.WHATSAPP_MONITORING,
|
|
5217
|
-
icon: Monitor,
|
|
5218
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5219
|
-
}
|
|
5220
|
-
]
|
|
5221
|
-
},
|
|
5222
|
-
...isMasterTenant ? [] : [
|
|
5223
|
-
{
|
|
5224
|
-
title: "Unidades de Neg\xF3cio",
|
|
5225
|
-
url: routePaths.UNIDADES_NEGOCIO,
|
|
5226
|
-
icon: Building2,
|
|
5227
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5228
|
-
}
|
|
5229
|
-
],
|
|
5230
|
-
...isMasterTenant ? [
|
|
5231
|
-
{
|
|
5232
|
-
title: "Tenants",
|
|
5233
|
-
url: routePaths.TENANT_MANAGEMENT,
|
|
5234
|
-
icon: Database,
|
|
5235
|
-
permission: "ADMIN_ONLY" /* ADMIN_ONLY */
|
|
5236
|
-
}
|
|
5237
|
-
] : []
|
|
5238
|
-
]
|
|
5239
|
-
},
|
|
5240
|
-
{
|
|
5241
|
-
title: "Automa\xE7\xE3o",
|
|
5242
|
-
icon: Bot,
|
|
5243
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */,
|
|
5244
|
-
subItems: [
|
|
5245
|
-
{
|
|
5246
|
-
title: "Fluxos de Automa\xE7\xE3o",
|
|
5247
|
-
url: routePaths.FLOWS,
|
|
5248
|
-
icon: Workflow,
|
|
5249
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5250
|
-
},
|
|
5251
|
-
{
|
|
5252
|
-
title: "Credenciais",
|
|
5253
|
-
url: routePaths.CREDENTIALS,
|
|
5254
|
-
icon: Key,
|
|
5255
|
-
permission: "MANAGER_OR_ADMIN" /* MANAGER_OR_ADMIN */
|
|
5256
|
-
}
|
|
5257
|
-
]
|
|
5258
|
-
}
|
|
5259
|
-
];
|
|
5260
5153
|
React37__default.useEffect(() => {
|
|
5261
5154
|
if (!currentTime) {
|
|
5262
5155
|
const timer = setInterval(() => {
|
|
@@ -5265,8 +5158,9 @@ function ControlSidebar({
|
|
|
5265
5158
|
return () => clearInterval(timer);
|
|
5266
5159
|
}
|
|
5267
5160
|
}, [currentTime]);
|
|
5161
|
+
const resolvedMenuItems = menuItemsProp ?? [];
|
|
5268
5162
|
const displayTime = currentTime || internalTime;
|
|
5269
|
-
const filteredMenuItems = filterMenuItems(
|
|
5163
|
+
const filteredMenuItems = filterMenuItems(resolvedMenuItems, user, isMasterTenant);
|
|
5270
5164
|
return /* @__PURE__ */ jsxs(Sidebar, { className: "border-r border-gray-200", collapsible: "icon", children: [
|
|
5271
5165
|
/* @__PURE__ */ jsxs(SidebarHeader, { className: "border-b border-gray-200", children: [
|
|
5272
5166
|
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between px-2 py-2", children: /* @__PURE__ */ jsx(SidebarTrigger, { className: "ml-auto" }) }),
|
|
@@ -5452,7 +5346,8 @@ function MainLayout({
|
|
|
5452
5346
|
appSubtitle,
|
|
5453
5347
|
logoUrl,
|
|
5454
5348
|
faviconUrl,
|
|
5455
|
-
sidebarDefaultOpen
|
|
5349
|
+
sidebarDefaultOpen,
|
|
5350
|
+
menuItems
|
|
5456
5351
|
}) {
|
|
5457
5352
|
return /* @__PURE__ */ jsx(SidebarProvider, { defaultOpen: sidebarDefaultOpen, children: /* @__PURE__ */ jsxs("div", { className: "h-screen w-full flex", children: [
|
|
5458
5353
|
/* @__PURE__ */ jsx(
|
|
@@ -5469,13 +5364,14 @@ function MainLayout({
|
|
|
5469
5364
|
appName,
|
|
5470
5365
|
appSubtitle,
|
|
5471
5366
|
logoUrl,
|
|
5472
|
-
faviconUrl
|
|
5367
|
+
faviconUrl,
|
|
5368
|
+
menuItems
|
|
5473
5369
|
}
|
|
5474
5370
|
),
|
|
5475
5371
|
/* @__PURE__ */ jsx("main", { className: "flex-1 overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full overflow-y-auto", children }) })
|
|
5476
5372
|
] }) });
|
|
5477
5373
|
}
|
|
5478
|
-
function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, onResetPassword, resetPasswordLoading, resetPasswordError, appName, appSubtitle, logoUrl, faviconUrl, sidebarDefaultOpen }) {
|
|
5374
|
+
function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths, useTenant, tenantService, onResetPassword, resetPasswordLoading, resetPasswordError, appName, appSubtitle, logoUrl, faviconUrl, sidebarDefaultOpen, menuItems }) {
|
|
5479
5375
|
const { isAuthenticated, isLoading, logout, user, getCurrentTenantId } = useAuthContext();
|
|
5480
5376
|
const location = useLocation();
|
|
5481
5377
|
const sso = useSSO(tenantId || void 0);
|
|
@@ -5524,6 +5420,7 @@ function ProtectedRoute({ children, useAuthContext, tenantId, useSSO, routePaths
|
|
|
5524
5420
|
logoUrl,
|
|
5525
5421
|
faviconUrl,
|
|
5526
5422
|
sidebarDefaultOpen,
|
|
5423
|
+
menuItems,
|
|
5527
5424
|
children: /* @__PURE__ */ jsx(EnsureTenant, { useTenant, tenantService, children })
|
|
5528
5425
|
}
|
|
5529
5426
|
);
|