tcce-design-system-test 0.3.38 → 0.3.39
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.
|
@@ -855,15 +855,15 @@ export declare type HasIcons<T extends WithIconsProps> = {
|
|
|
855
855
|
/**
|
|
856
856
|
* Checks if the user has at least one of the required permissions.
|
|
857
857
|
*
|
|
858
|
-
* @param {string[]}
|
|
859
|
-
* @param {string[]}
|
|
858
|
+
* @param {string[]} userPermissions - The permissions assigned to the user.
|
|
859
|
+
* @param {string[]} requiredPermissions - The required permissions to check against.
|
|
860
860
|
* @returns {boolean} True if the user has permission, otherwise false.
|
|
861
861
|
*
|
|
862
|
-
* - Returns false if no permissions are provided.
|
|
863
|
-
* - Returns true if 'all' is included in the permissions array.
|
|
864
|
-
* - Returns true if any of the user's
|
|
862
|
+
* - Returns false if no required permissions are provided.
|
|
863
|
+
* - Returns true if 'all' is included in the required permissions array.
|
|
864
|
+
* - Returns true if any of the user's permissions match the required permissions.
|
|
865
865
|
*/
|
|
866
|
-
export declare const hasPermission: (
|
|
866
|
+
export declare const hasPermission: (userPermissions?: string[], requiredPermissions?: string[]) => boolean;
|
|
867
867
|
|
|
868
868
|
/**
|
|
869
869
|
* Main Header component for the application.
|
|
@@ -1048,7 +1048,7 @@ export declare interface LayoutMainContentProps {
|
|
|
1048
1048
|
* Includes navigation config, user info, and event handlers.
|
|
1049
1049
|
* @children - Main content to be rendered within the layout.
|
|
1050
1050
|
* @navigationConfig - Configuration for sidebar navigation items.
|
|
1051
|
-
* @
|
|
1051
|
+
* @userPermissions - Permissions of the current user for permission-based rendering.
|
|
1052
1052
|
* @activePath - Currently active navigation path.
|
|
1053
1053
|
* @user - User information for the header profile section.
|
|
1054
1054
|
* @hasNotifications - Whether to show notification indicator in header.
|
|
@@ -1428,13 +1428,13 @@ export declare type SetDigits = Dispatch<SetStateAction<string[]>>;
|
|
|
1428
1428
|
/**
|
|
1429
1429
|
* Sidebar component for navigation.
|
|
1430
1430
|
* @param navigationConfig - Navigation items configuration.
|
|
1431
|
-
* @param
|
|
1431
|
+
* @param userPermissions - User permissions for access control.
|
|
1432
1432
|
* @param activePath - Currently active navigation path.
|
|
1433
1433
|
* @param logoImgExpanded - Logo when sidebar is expanded.
|
|
1434
1434
|
* @param logoImgCollapsed - Logo when sidebar is collapsed.
|
|
1435
1435
|
*/
|
|
1436
1436
|
export declare const Sidebar: {
|
|
1437
|
-
({ navigationConfig,
|
|
1437
|
+
({ navigationConfig, activePath, logoImgExpanded, logoImgCollapsed, onNavigate, userPermissions, }: SidebarProps): JSX.Element;
|
|
1438
1438
|
displayName: string;
|
|
1439
1439
|
};
|
|
1440
1440
|
|
|
@@ -1466,15 +1466,15 @@ $collapsed: boolean;
|
|
|
1466
1466
|
* Props for the Sidebar component.
|
|
1467
1467
|
*
|
|
1468
1468
|
* @property navigationConfig - Array of NavigationItem objects defining the sidebar structure.
|
|
1469
|
-
* @property
|
|
1469
|
+
* @property userPermissions - Array of permissions assigned to the current user for permission checks.
|
|
1470
1470
|
* @property activePath - Optional string representing the currently active navigation path for highlighting purposes.
|
|
1471
1471
|
* @property logoImgExpanded - Optional React node for the logo when sidebar is expanded.
|
|
1472
1472
|
* @property logoImgCollapsed - Optional React node for the logo when sidebar is collapsed.
|
|
1473
|
-
* @property
|
|
1473
|
+
* @property onNavigate - Optional callback function for handling navigation events.
|
|
1474
1474
|
*/
|
|
1475
1475
|
export declare interface SidebarProps {
|
|
1476
1476
|
navigationConfig: NavigationItem[];
|
|
1477
|
-
|
|
1477
|
+
userPermissions?: Permission[];
|
|
1478
1478
|
activePath?: string;
|
|
1479
1479
|
logoImgExpanded?: ReactNode;
|
|
1480
1480
|
logoImgCollapsed?: ReactNode;
|
|
@@ -9318,7 +9318,7 @@ const yl = Je(void 0), n0 = ({ children: e }) => {
|
|
|
9318
9318
|
if (!e)
|
|
9319
9319
|
throw new Error("useSidebar must be used within a SidebarProvider");
|
|
9320
9320
|
return e;
|
|
9321
|
-
}, ls = (e = [], t = []) => !t || t.length === 0 ? !1 : t.includes("all") ? !0 :
|
|
9321
|
+
}, ls = (e = [], t = []) => !t || t.length === 0 ? !1 : t.includes("all") ? !0 : e.some((n) => t.includes(n)), o0 = b`
|
|
9322
9322
|
display: flex;
|
|
9323
9323
|
align-items: center;
|
|
9324
9324
|
justify-content: center;
|
|
@@ -9410,7 +9410,7 @@ const yl = Je(void 0), n0 = ({ children: e }) => {
|
|
|
9410
9410
|
transform: rotate(${({ $open: e }) => e ? "90deg" : "0deg"});
|
|
9411
9411
|
pointer-events: none;
|
|
9412
9412
|
transition: transform 0.3s ease-out;
|
|
9413
|
-
`, bl = ({ item: e,
|
|
9413
|
+
`, bl = ({ item: e, userPermissions: t, level: n = 0, activePath: o, onNavigate: r }) => {
|
|
9414
9414
|
const [i, s] = Q(!1), { isCollapsed: a, setIsMobileOpen: l, setIsCollapsed: c } = vl(), d = W(
|
|
9415
9415
|
() => (e.children || []).filter((w) => ls(t, w.permissions)),
|
|
9416
9416
|
[e.children, t]
|
|
@@ -9493,7 +9493,7 @@ const yl = Je(void 0), n0 = ({ children: e }) => {
|
|
|
9493
9493
|
bl,
|
|
9494
9494
|
{
|
|
9495
9495
|
item: w,
|
|
9496
|
-
|
|
9496
|
+
userPermissions: t,
|
|
9497
9497
|
level: n + 1,
|
|
9498
9498
|
onNavigate: r,
|
|
9499
9499
|
activePath: o
|
|
@@ -9588,21 +9588,21 @@ const yl = Je(void 0), n0 = ({ children: e }) => {
|
|
|
9588
9588
|
}
|
|
9589
9589
|
`, xl = ({
|
|
9590
9590
|
navigationConfig: e,
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9591
|
+
activePath: t,
|
|
9592
|
+
logoImgExpanded: n,
|
|
9593
|
+
logoImgCollapsed: o,
|
|
9594
|
+
onNavigate: r = () => {
|
|
9595
|
+
},
|
|
9596
|
+
userPermissions: i = []
|
|
9597
9597
|
}) => {
|
|
9598
9598
|
const { isCollapsed: s, setIsCollapsed: a, isMobileOpen: l, setIsMobileOpen: c } = vl(), d = (u) => {
|
|
9599
|
-
|
|
9599
|
+
r(u), typeof window < "u" && window.innerWidth < 768 && c(!1);
|
|
9600
9600
|
};
|
|
9601
9601
|
return /* @__PURE__ */ E(Ze, { children: [
|
|
9602
9602
|
/* @__PURE__ */ g(Zt, { children: l && /* @__PURE__ */ g(f0, { ...gl, onClick: () => c(!1) }) }),
|
|
9603
9603
|
/* @__PURE__ */ E(h0, { $collapsed: l ? !1 : s, $open: l, children: [
|
|
9604
9604
|
/* @__PURE__ */ E(m0, { $collapsed: s, children: [
|
|
9605
|
-
/* @__PURE__ */ g(p0, { children: s ?
|
|
9605
|
+
/* @__PURE__ */ g(p0, { children: s ? o : n }),
|
|
9606
9606
|
/* @__PURE__ */ g(
|
|
9607
9607
|
y0,
|
|
9608
9608
|
{
|
|
@@ -9623,9 +9623,9 @@ const yl = Je(void 0), n0 = ({ children: e }) => {
|
|
|
9623
9623
|
bl,
|
|
9624
9624
|
{
|
|
9625
9625
|
item: u,
|
|
9626
|
-
userRoles: t,
|
|
9627
9626
|
onNavigate: d,
|
|
9628
|
-
activePath:
|
|
9627
|
+
activePath: t,
|
|
9628
|
+
userPermissions: i
|
|
9629
9629
|
},
|
|
9630
9630
|
u.id
|
|
9631
9631
|
)) })
|
|
@@ -13214,7 +13214,7 @@ const Pv = x.div`
|
|
|
13214
13214
|
`, Vv = ({
|
|
13215
13215
|
children: e,
|
|
13216
13216
|
navigationConfig: t,
|
|
13217
|
-
|
|
13217
|
+
userPermissions: n = [],
|
|
13218
13218
|
activePath: o,
|
|
13219
13219
|
user: r,
|
|
13220
13220
|
hasNotifications: i = !1,
|
|
@@ -13232,7 +13232,7 @@ const Pv = x.div`
|
|
|
13232
13232
|
xl,
|
|
13233
13233
|
{
|
|
13234
13234
|
navigationConfig: t,
|
|
13235
|
-
|
|
13235
|
+
userPermissions: n,
|
|
13236
13236
|
activePath: o,
|
|
13237
13237
|
logoImgCollapsed: f,
|
|
13238
13238
|
logoImgExpanded: m,
|
|
@@ -1319,7 +1319,7 @@
|
|
|
1319
1319
|
background-color: var(--color-dark-600);
|
|
1320
1320
|
|
|
1321
1321
|
${({$placement:e})=>u0(e)}
|
|
1322
|
-
`,vl=({content:e,children:t,placement:n="bottom",trigger:o="hover",className:r="",arrowClassName:i="",delay:s=200,showArrow:a=!0})=>{const[l,c]=p.useState(!1),d=p.useRef(null),u=p.useRef(null),h=p.useRef(null);p.useEffect(()=>{if(o!=="click"||!l)return;const w=C=>{u.current&&!u.current.contains(C.target)&&h.current&&!h.current.contains(C.target)&&c(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l,o]),p.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const b=o==="hover"?{onMouseEnter:()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!0),s)},onMouseLeave:()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),100)}}:{onClick:()=>{c(w=>!w)}};return m.jsxs(s0,{children:[m.jsx(a0,{ref:h,...b,children:t}),l&&m.jsxs(c0,{ref:u,$placement:n,className:r,role:"tooltip","aria-hidden":!l,children:[e,a&&m.jsx(d0,{$placement:n,className:i})]})]})};vl.displayName="Tooltip";const lr=p.createContext(void 0),yl=({children:e})=>{const[t,n]=p.useState(!1),[o,r]=p.useState(!1);return m.jsx(lr.Provider,{value:{isCollapsed:t,setIsCollapsed:n,isMobileOpen:o,setIsMobileOpen:r},children:e})},cr=()=>{const e=p.useContext(lr);if(!e)throw new Error("useSidebar must be used within a SidebarProvider");return e},ur=(e=[],t=[])=>!t||t.length===0?!1:t.includes("all")?!0:
|
|
1322
|
+
`,vl=({content:e,children:t,placement:n="bottom",trigger:o="hover",className:r="",arrowClassName:i="",delay:s=200,showArrow:a=!0})=>{const[l,c]=p.useState(!1),d=p.useRef(null),u=p.useRef(null),h=p.useRef(null);p.useEffect(()=>{if(o!=="click"||!l)return;const w=C=>{u.current&&!u.current.contains(C.target)&&h.current&&!h.current.contains(C.target)&&c(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[l,o]),p.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const b=o==="hover"?{onMouseEnter:()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!0),s)},onMouseLeave:()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),100)}}:{onClick:()=>{c(w=>!w)}};return m.jsxs(s0,{children:[m.jsx(a0,{ref:h,...b,children:t}),l&&m.jsxs(c0,{ref:u,$placement:n,className:r,role:"tooltip","aria-hidden":!l,children:[e,a&&m.jsx(d0,{$placement:n,className:i})]})]})};vl.displayName="Tooltip";const lr=p.createContext(void 0),yl=({children:e})=>{const[t,n]=p.useState(!1),[o,r]=p.useState(!1);return m.jsx(lr.Provider,{value:{isCollapsed:t,setIsCollapsed:n,isMobileOpen:o,setIsMobileOpen:r},children:e})},cr=()=>{const e=p.useContext(lr);if(!e)throw new Error("useSidebar must be used within a SidebarProvider");return e},ur=(e=[],t=[])=>!t||t.length===0?!1:t.includes("all")?!0:e.some(n=>t.includes(n)),f0=g.css`
|
|
1323
1323
|
display: flex;
|
|
1324
1324
|
align-items: center;
|
|
1325
1325
|
justify-content: center;
|
|
@@ -1411,7 +1411,7 @@
|
|
|
1411
1411
|
transform: rotate(${({$open:e})=>e?"90deg":"0deg"});
|
|
1412
1412
|
pointer-events: none;
|
|
1413
1413
|
transition: transform 0.3s ease-out;
|
|
1414
|
-
`,bl=({item:e,
|
|
1414
|
+
`,bl=({item:e,userPermissions:t,level:n=0,activePath:o,onNavigate:r})=>{const[i,s]=p.useState(!1),{isCollapsed:a,setIsMobileOpen:l,setIsCollapsed:c}=cr(),d=p.useMemo(()=>(e.children||[]).filter(x=>ur(t,x.permissions)),[e.children,t]);if(!p.useMemo(()=>ur(t,e.permissions),[t,e.permissions]))return null;const h=d.length>0,f=e.href||e.path||"",v=!!(f&&o&&o.startsWith(f)),y=()=>{a&&c(!1),s(x=>!x)},b=()=>{a&&c(!1),e.href&&r?.(e.href)},w=async()=>{if(a&&c(!1),!e.path)return;const x=e.target||"_blank";try{typeof window<"u"&&(x==="_blank"?window.open(e.path,"_blank","noopener,noreferrer"):window.location.href=e.path),l&&l(!1)}catch(k){console.error("Error al navegar a microservicio:",k)}},C=()=>m.jsxs(m.Fragment,{children:[m.jsxs(m0,{children:[n>0&&!a&&m.jsx(w0,{}),e.icon&&m.jsx(U,{component:e.icon,size:n===0?"md":"sm",color:"var(--color-main-blue-primary)"}),!a&&m.jsx(g0,{$level:n,size:n===0?16:n===1?14:12,color:"var(--color-dark-700, #374151)",children:e.label})]}),!a&&h&&m.jsx(b0,{$disabled:a,$open:i,children:m.jsx(U,{component:Pm,size:"sm",color:"var(--color-main-blue-primary)"})})]});return m.jsxs(y0,{$level:n,children:[e.href&&!e.path&&!h?m.jsx(h0,{type:"button",onClick:b,$level:n,$collapsed:a,$active:v,title:a?e.label:"",children:C()}):m.jsx(p0,{type:"button",onClick:h?y:e.path?w:b,$level:n,$collapsed:a,$active:v,$expanded:i&&h,title:a?e.label:"",children:C()}),m.jsx(Lt,{initial:!1,children:!a&&i&&h&&m.jsx(v0,{$level:n+1,...fl,children:d.map(x=>m.jsx(bl,{item:x,userPermissions:t,level:n+1,onNavigate:r,activePath:o},x.id))})})]})},xl=g(Fe.div)`
|
|
1415
1415
|
position: fixed;
|
|
1416
1416
|
inset: 0;
|
|
1417
1417
|
background: rgba(0, 0, 0, 0.5);
|
|
@@ -1496,7 +1496,7 @@
|
|
|
1496
1496
|
@media (min-width: 768px) {
|
|
1497
1497
|
display: none;
|
|
1498
1498
|
}
|
|
1499
|
-
`,dr=({navigationConfig:e,
|
|
1499
|
+
`,dr=({navigationConfig:e,activePath:t,logoImgExpanded:n,logoImgCollapsed:o,onNavigate:r=()=>{},userPermissions:i=[]})=>{const{isCollapsed:s,setIsCollapsed:a,isMobileOpen:l,setIsMobileOpen:c}=cr(),d=u=>{r(u),typeof window<"u"&&window.innerWidth<768&&c(!1)};return m.jsxs(m.Fragment,{children:[m.jsx(Lt,{children:l&&m.jsx(xl,{...ar,onClick:()=>c(!1)})}),m.jsxs(Sl,{$collapsed:l?!1:s,$open:l,children:[m.jsxs(Cl,{$collapsed:s,children:[m.jsx(Tl,{children:s?o:n}),m.jsx(kl,{onClick:()=>a(!s),"aria-label":"Toggle collapse",children:m.jsx(U,{component:Xa,size:"md",color:"var(--color-main-blue-primary)"})})]}),m.jsx($l,{children:e.map(u=>m.jsx(bl,{item:u,onNavigate:d,activePath:t,userPermissions:i},u.id))})]}),m.jsx(Pl,{onClick:()=>{c(!0),a(!1)},$hidden:l,children:m.jsx(U,{component:Xa,size:30})})]})};dr.displayName="Sidebar";const Ml={underlined:g.css`
|
|
1500
1500
|
color: var(--color-main-orange-primary);
|
|
1501
1501
|
text-decoration-thickness: 1px;
|
|
1502
1502
|
text-underline-offset: 2px;
|
|
@@ -2200,7 +2200,7 @@
|
|
|
2200
2200
|
flex-direction: column;
|
|
2201
2201
|
height: 100vh;
|
|
2202
2202
|
overflow: hidden;
|
|
2203
|
-
`,hy=({children:e,navigationConfig:t,
|
|
2203
|
+
`,hy=({children:e,navigationConfig:t,userPermissions:n=[],activePath:o,user:r,hasNotifications:i=!1,notificationCount:s,onNotificationClick:a,onUserProfileClick:l,onNavigate:c,onLogout:d,userMenuItems:u=[],contentClassName:h,logoImgCollapsed:f,logoImgExpanded:v})=>m.jsxs(fy,{children:[m.jsx(dr,{navigationConfig:t,userPermissions:n,activePath:o,logoImgCollapsed:f,logoImgExpanded:v,onNavigate:c}),m.jsx(Ar,{user:r,hasNotifications:i,notificationCount:s,onNotificationClick:a,onUserProfileClick:l,onLogout:d,userMenuItems:u}),m.jsx(Ir,{className:h,children:e})]}),py=e=>m.jsx(yl,{children:m.jsx(hy,{...e})});function my(e,t,n){let o=`${e}=${encodeURIComponent(t)}; path=/; SameSite=Strict; Secure`;if(n){const r=new Date(Date.now()+n*864e5).toUTCString();o+=`; expires=${r}`}document.cookie=o}function gy(e){return document.cookie.split("; ").reduce((t,n)=>{const o=n.split("=");return o[0]===e?decodeURIComponent(o[1]):t},"")}function vy(e){document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`}const jt={sm:{circle:"2rem",fontSize:D[14],line:"2px"},md:{circle:"2.5rem",fontSize:D[18],line:"2px"},lg:{circle:"3.25rem",fontSize:D[20],line:"3px"}},yy=g.div`
|
|
2204
2204
|
display: flex;
|
|
2205
2205
|
width: 100%;
|
|
2206
2206
|
`,wy=g.div`
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.39",
|
|
7
7
|
"description": "This package provides reusable UI components to ensure consistency across all CRM frontend applications",
|
|
8
8
|
"author": "BizAppsTotal <bizapps@tcce.biz>",
|
|
9
9
|
"type": "module",
|