@bizapps/design-system-testing 1.0.4 → 1.0.6
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/main.cjs +210 -117
- package/dist/main.cjs.map +1 -1
- package/dist/main.css +1 -1
- package/dist/main.d.cts +41 -5
- package/dist/main.d.ts +41 -5
- package/dist/main.js +208 -117
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -405,7 +405,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
405
405
|
secondary: "cursor-pointer bg-secondary text-secondary-foreground hover:bg-[var(--color-orange-700)] focus-visible:ring-secondary/30",
|
|
406
406
|
cancel: "cursor-pointer bg-destructive text-secondary-foreground hover:bg-[var(--color-red-600)] focus-visible:ring-destructive/30",
|
|
407
407
|
outline: " border-2 border-foreground/50 bg-transparent text-muted-foreground hover:bg-foreground/50 hover:text-white",
|
|
408
|
-
ghost: "cursor-pointer bg-transparent text-muted-foreground hover:bg-foreground/10 hover:text-primary focus-visible:ring-ring/30",
|
|
408
|
+
ghost: "cursor-pointer bg-transparent text-muted-foreground hover:bg-foreground/10 hover:text-primary focus-visible:ring-ring/30 border-none",
|
|
409
409
|
cancelGhost: "cursor-pointer bg-destructive/10 text-red-600 hover:bg-destructive/15 hover:text-red-600 focus-visible:ring-ring/30"
|
|
410
410
|
},
|
|
411
411
|
size: {
|
|
@@ -1558,7 +1558,7 @@ function Separator({
|
|
|
1558
1558
|
decorative,
|
|
1559
1559
|
orientation,
|
|
1560
1560
|
className: cn(
|
|
1561
|
-
"bg-foreground/20
|
|
1561
|
+
"bg-foreground/20 shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
|
|
1562
1562
|
className
|
|
1563
1563
|
),
|
|
1564
1564
|
...props
|
|
@@ -1677,12 +1677,12 @@ function Slider({
|
|
|
1677
1677
|
radixUi.Slider.Track,
|
|
1678
1678
|
{
|
|
1679
1679
|
"data-slot": "slider-track",
|
|
1680
|
-
className: "bg-input/90 relative grow overflow-hidden rounded-full data-horizontal:h-2 data-horizontal:w-full data-vertical:h-full data-vertical:w-2",
|
|
1680
|
+
className: "bg-input/90 relative grow overflow-hidden rounded-full data-[orientation=horizontal]:h-2 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2",
|
|
1681
1681
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1682
1682
|
radixUi.Slider.Range,
|
|
1683
1683
|
{
|
|
1684
1684
|
"data-slot": "slider-range",
|
|
1685
|
-
className: "bg-primary absolute select-none data-horizontal:h-full data-vertical:w-full"
|
|
1685
|
+
className: "bg-primary absolute select-none data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"
|
|
1686
1686
|
}
|
|
1687
1687
|
)
|
|
1688
1688
|
}
|
|
@@ -1932,7 +1932,7 @@ function TabsContent({
|
|
|
1932
1932
|
className
|
|
1933
1933
|
),
|
|
1934
1934
|
...props,
|
|
1935
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { mode: "
|
|
1935
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(react$1.AnimatePresence, { mode: "popLayout", initial: false, children: isActive && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1936
1936
|
react$1.motion.div,
|
|
1937
1937
|
{
|
|
1938
1938
|
className: "mt-2",
|
|
@@ -2148,7 +2148,7 @@ function ToggleGroup2({
|
|
|
2148
2148
|
"data-orientation": orientation,
|
|
2149
2149
|
style: { "--gap": spacing },
|
|
2150
2150
|
className: cn(
|
|
2151
|
-
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-vertical:flex-col data-vertical:items-stretch data-[spacing=0]:data-[variant=outline]:rounded-md",
|
|
2151
|
+
"group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch data-[spacing=0]:data-[variant=outline]:rounded-md",
|
|
2152
2152
|
className
|
|
2153
2153
|
),
|
|
2154
2154
|
...props,
|
|
@@ -2172,7 +2172,7 @@ function ToggleGroupItem({
|
|
|
2172
2172
|
"data-size": context.size || size,
|
|
2173
2173
|
"data-spacing": context.spacing,
|
|
2174
2174
|
className: cn(
|
|
2175
|
-
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
|
2175
|
+
"shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-3 group-data-[spacing=0]/toggle-group:shadow-none focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-2.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-2.5 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:first:rounded-l-md group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:first:rounded-t-md group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:last:rounded-r-md group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:last:rounded-b-md group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-[orientation=horizontal]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-[orientation=vertical]/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
|
|
2176
2176
|
toggleVariants({
|
|
2177
2177
|
variant: context.variant || variant,
|
|
2178
2178
|
size: context.size || size
|
|
@@ -2376,10 +2376,7 @@ function DialogPortal({ children, ...props }) {
|
|
|
2376
2376
|
function DialogClose({ ...props }) {
|
|
2377
2377
|
return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Dialog.Close, { "data-slot": "dialog-close", ...props });
|
|
2378
2378
|
}
|
|
2379
|
-
function DialogOverlay({
|
|
2380
|
-
className,
|
|
2381
|
-
...props
|
|
2382
|
-
}) {
|
|
2379
|
+
function DialogOverlay({ className, ...props }) {
|
|
2383
2380
|
return /* @__PURE__ */ jsxRuntime.jsx(radixUi.Dialog.Overlay, { "data-slot": "dialog-overlay", asChild: true, forceMount: true, ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2384
2381
|
react$1.motion.div,
|
|
2385
2382
|
{
|
|
@@ -2452,6 +2449,16 @@ function DialogHeader({ className, ...props }) {
|
|
|
2452
2449
|
}
|
|
2453
2450
|
);
|
|
2454
2451
|
}
|
|
2452
|
+
function DialogBody({ className, ...props }) {
|
|
2453
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2454
|
+
"div",
|
|
2455
|
+
{
|
|
2456
|
+
"data-slot": "dialog-body",
|
|
2457
|
+
className: cn("flex-1 overflow-y-auto px-6 pb-6", className),
|
|
2458
|
+
...props
|
|
2459
|
+
}
|
|
2460
|
+
);
|
|
2461
|
+
}
|
|
2455
2462
|
function DialogFooter({
|
|
2456
2463
|
className,
|
|
2457
2464
|
showCloseButton = false,
|
|
@@ -2790,7 +2797,7 @@ function Combobox({
|
|
|
2790
2797
|
className: cn(
|
|
2791
2798
|
"border-input w-64 justify-between border bg-transparent text-sm font-normal shadow-xs",
|
|
2792
2799
|
"hover:text-foreground focus-visible:ring-ring/30 hover:bg-transparent",
|
|
2793
|
-
|
|
2800
|
+
selected ? "text-foreground" : "text-muted-foreground",
|
|
2794
2801
|
className
|
|
2795
2802
|
),
|
|
2796
2803
|
children: [
|
|
@@ -4329,16 +4336,32 @@ var Navbar = react.forwardRef(
|
|
|
4329
4336
|
utilityLinks = defaultUtilityLinks,
|
|
4330
4337
|
navigationLinks = defaultNavigationLinks,
|
|
4331
4338
|
notificationCount = 1,
|
|
4339
|
+
notifications,
|
|
4332
4340
|
avatarSrc,
|
|
4333
4341
|
avatarFallback,
|
|
4334
4342
|
onNavLinkClick,
|
|
4335
4343
|
onSearchClick,
|
|
4336
4344
|
onHelpClick,
|
|
4337
4345
|
onAvatarClick,
|
|
4346
|
+
onNotificationClick,
|
|
4338
4347
|
...props
|
|
4339
4348
|
}, ref) => {
|
|
4340
4349
|
const containerRef = react.useRef(null);
|
|
4350
|
+
const notifRef = react.useRef(null);
|
|
4341
4351
|
const [isMobile, setIsMobile] = react.useState(false);
|
|
4352
|
+
const [notifOpen, setNotifOpen] = react.useState(false);
|
|
4353
|
+
const notifArray = Array.isArray(notifications) ? notifications : void 0;
|
|
4354
|
+
const unreadCount = notifArray ? notifArray.filter((n) => !n.read).length : notificationCount;
|
|
4355
|
+
react.useEffect(() => {
|
|
4356
|
+
if (!notifOpen) return;
|
|
4357
|
+
const handler = (e) => {
|
|
4358
|
+
if (notifRef.current && !notifRef.current.contains(e.target)) {
|
|
4359
|
+
setNotifOpen(false);
|
|
4360
|
+
}
|
|
4361
|
+
};
|
|
4362
|
+
document.addEventListener("mousedown", handler);
|
|
4363
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
4364
|
+
}, [notifOpen]);
|
|
4342
4365
|
react.useEffect(() => {
|
|
4343
4366
|
const checkWidth = () => {
|
|
4344
4367
|
if (containerRef.current) {
|
|
@@ -4400,17 +4423,64 @@ var Navbar = react.forwardRef(
|
|
|
4400
4423
|
)
|
|
4401
4424
|
] }, i)) }),
|
|
4402
4425
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
4403
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4426
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { ref: notifRef, className: "relative", children: [
|
|
4427
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4428
|
+
"button",
|
|
4429
|
+
{
|
|
4430
|
+
type: "button",
|
|
4431
|
+
onClick: () => notifArray && setNotifOpen((o) => !o),
|
|
4432
|
+
className: "text-muted-foreground hover:text-foreground hover:bg-muted relative flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors",
|
|
4433
|
+
children: [
|
|
4434
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.BellIcon, { className: "size-3.5" }),
|
|
4435
|
+
unreadCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary absolute top-1 right-1 flex size-1.5 rounded-full" })
|
|
4436
|
+
]
|
|
4437
|
+
}
|
|
4438
|
+
),
|
|
4439
|
+
notifArray && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4440
|
+
"div",
|
|
4441
|
+
{
|
|
4442
|
+
className: cn(
|
|
4443
|
+
"border-border bg-popover absolute right-0 top-full z-50 w-80 overflow-hidden rounded-lg border shadow-lg transition-all duration-150",
|
|
4444
|
+
notifOpen ? "pointer-events-auto translate-y-1 opacity-100" : "pointer-events-none -translate-y-1 opacity-0"
|
|
4445
|
+
),
|
|
4446
|
+
children: [
|
|
4447
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-border border-b px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-semibold", children: "Notifications" }) }),
|
|
4448
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-80 overflow-y-auto", children: notifArray.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground px-4 py-6 text-center text-sm", children: "No notifications" }) : notifArray.map((n) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4449
|
+
"button",
|
|
4450
|
+
{
|
|
4451
|
+
type: "button",
|
|
4452
|
+
onClick: () => {
|
|
4453
|
+
onNotificationClick?.(n.id);
|
|
4454
|
+
setNotifOpen(false);
|
|
4455
|
+
},
|
|
4456
|
+
className: cn(
|
|
4457
|
+
"hover:bg-muted flex w-full items-start gap-3 px-4 py-3 text-left transition-colors",
|
|
4458
|
+
!n.read && "bg-muted/40"
|
|
4459
|
+
),
|
|
4460
|
+
children: [
|
|
4461
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
4462
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4463
|
+
"p",
|
|
4464
|
+
{
|
|
4465
|
+
className: cn(
|
|
4466
|
+
"text-sm",
|
|
4467
|
+
!n.read && "font-semibold"
|
|
4468
|
+
),
|
|
4469
|
+
children: n.title
|
|
4470
|
+
}
|
|
4471
|
+
),
|
|
4472
|
+
n.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-0.5 truncate text-xs", children: n.description }),
|
|
4473
|
+
n.timestamp && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-1 text-xs", children: n.timestamp })
|
|
4474
|
+
] }),
|
|
4475
|
+
!n.read && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-secondary mt-1.5 size-2 shrink-0 rounded-full" })
|
|
4476
|
+
]
|
|
4477
|
+
},
|
|
4478
|
+
n.id
|
|
4479
|
+
)) })
|
|
4480
|
+
]
|
|
4481
|
+
}
|
|
4482
|
+
)
|
|
4483
|
+
] }),
|
|
4414
4484
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4415
4485
|
"button",
|
|
4416
4486
|
{
|
|
@@ -4585,6 +4655,84 @@ function NavigationMenuIndicator({
|
|
|
4585
4655
|
}
|
|
4586
4656
|
);
|
|
4587
4657
|
}
|
|
4658
|
+
function matchPermission(pattern, permission) {
|
|
4659
|
+
if (pattern === "*") return true;
|
|
4660
|
+
if (pattern === permission) return true;
|
|
4661
|
+
const patternParts = pattern.split(".");
|
|
4662
|
+
const permParts = permission.split(".");
|
|
4663
|
+
if (patternParts.length !== permParts.length) return false;
|
|
4664
|
+
return patternParts.every((part, i) => part === "*" || part === permParts[i]);
|
|
4665
|
+
}
|
|
4666
|
+
function matchesAny(permissionSet, permission) {
|
|
4667
|
+
if (permissionSet.has(permission)) return true;
|
|
4668
|
+
for (const pattern of permissionSet) {
|
|
4669
|
+
if (matchPermission(pattern, permission)) return true;
|
|
4670
|
+
}
|
|
4671
|
+
return false;
|
|
4672
|
+
}
|
|
4673
|
+
var AbilityContext = react.createContext(void 0);
|
|
4674
|
+
AbilityContext.displayName = "AbilityContext";
|
|
4675
|
+
function AbilityProvider({ children, permissions }) {
|
|
4676
|
+
const [permissionSet, setPermissionSet] = react.useState(
|
|
4677
|
+
() => new Set(permissions ?? [])
|
|
4678
|
+
);
|
|
4679
|
+
const can = react.useCallback(
|
|
4680
|
+
(perms, mode = "any") => {
|
|
4681
|
+
const list = Array.isArray(perms) ? perms : [perms];
|
|
4682
|
+
if (list.length === 0) return false;
|
|
4683
|
+
if (permissionSet.has("*")) return true;
|
|
4684
|
+
if (mode === "all") {
|
|
4685
|
+
return list.every((p) => matchesAny(permissionSet, p));
|
|
4686
|
+
}
|
|
4687
|
+
return list.some((p) => matchesAny(permissionSet, p));
|
|
4688
|
+
},
|
|
4689
|
+
[permissionSet]
|
|
4690
|
+
);
|
|
4691
|
+
const setAbilities = react.useCallback((perms) => {
|
|
4692
|
+
setPermissionSet(new Set(perms));
|
|
4693
|
+
}, []);
|
|
4694
|
+
const clearAbilities = react.useCallback(() => {
|
|
4695
|
+
setPermissionSet(/* @__PURE__ */ new Set());
|
|
4696
|
+
}, []);
|
|
4697
|
+
const syncedKey = react.useRef(permissions ? permissions.join("|") : null);
|
|
4698
|
+
react.useEffect(() => {
|
|
4699
|
+
if (permissions === void 0) return;
|
|
4700
|
+
const key = permissions.join("|");
|
|
4701
|
+
if (key === syncedKey.current) return;
|
|
4702
|
+
syncedKey.current = key;
|
|
4703
|
+
setPermissionSet(new Set(permissions));
|
|
4704
|
+
}, [permissions]);
|
|
4705
|
+
const value = react.useMemo(
|
|
4706
|
+
() => ({ can, setAbilities, clearAbilities }),
|
|
4707
|
+
[can, setAbilities, clearAbilities]
|
|
4708
|
+
);
|
|
4709
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AbilityContext.Provider, { value, children });
|
|
4710
|
+
}
|
|
4711
|
+
function useAbility() {
|
|
4712
|
+
const context = react.useContext(AbilityContext);
|
|
4713
|
+
if (!context) {
|
|
4714
|
+
throw new Error("useAbility must be used within an AbilityProvider");
|
|
4715
|
+
}
|
|
4716
|
+
return context;
|
|
4717
|
+
}
|
|
4718
|
+
function useCan(permissions, mode = "any") {
|
|
4719
|
+
const { can } = useAbility();
|
|
4720
|
+
return can(permissions, mode);
|
|
4721
|
+
}
|
|
4722
|
+
function Can({ permission, mode = "any", negate = false, fallback = null, children }) {
|
|
4723
|
+
const { can } = useAbility();
|
|
4724
|
+
const hasPermission = can(permission, mode);
|
|
4725
|
+
const show = negate ? !hasPermission : hasPermission;
|
|
4726
|
+
if (typeof children === "function") {
|
|
4727
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(show) });
|
|
4728
|
+
}
|
|
4729
|
+
return show ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
|
|
4730
|
+
}
|
|
4731
|
+
Can.displayName = "Can";
|
|
4732
|
+
function CanNot({ permission, mode = "any", fallback = null, children }) {
|
|
4733
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Can, { permission, mode, negate: true, fallback, children });
|
|
4734
|
+
}
|
|
4735
|
+
CanNot.displayName = "CanNot";
|
|
4588
4736
|
var SidebarContext = react.createContext({
|
|
4589
4737
|
open: true,
|
|
4590
4738
|
setOpen: () => {
|
|
@@ -4813,39 +4961,52 @@ function SidebarBrand({ brandName }) {
|
|
|
4813
4961
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-semibold", children: brandName })
|
|
4814
4962
|
] });
|
|
4815
4963
|
}
|
|
4816
|
-
function
|
|
4964
|
+
function AppShell({
|
|
4817
4965
|
items = defaultItems,
|
|
4818
4966
|
activeItem,
|
|
4819
4967
|
onItemClick,
|
|
4820
4968
|
brandName = "Total Portal",
|
|
4821
4969
|
showHeader = true,
|
|
4822
4970
|
className,
|
|
4971
|
+
mainClassName,
|
|
4823
4972
|
children
|
|
4824
4973
|
}) {
|
|
4825
4974
|
return /* @__PURE__ */ jsxRuntime.jsxs(SidebarProvider, { className: cn("min-h-0", className), children: [
|
|
4826
4975
|
/* @__PURE__ */ jsxRuntime.jsxs(Sidebar, { collapsible: "icon", children: [
|
|
4827
4976
|
/* @__PURE__ */ jsxRuntime.jsxs(SidebarHeader, { className: "flex flex-row items-center gap-2 p-2", children: [
|
|
4828
|
-
/* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, { variant: "
|
|
4977
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, { variant: "ghost", className: "size-8 shrink-0" }),
|
|
4829
4978
|
/* @__PURE__ */ jsxRuntime.jsx(SidebarBrand, { brandName })
|
|
4830
4979
|
] }),
|
|
4831
|
-
/* @__PURE__ */ jsxRuntime.jsx(SidebarContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: items.map((item) =>
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4980
|
+
/* @__PURE__ */ jsxRuntime.jsx(SidebarContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: items.map((item) => {
|
|
4981
|
+
const menuItem = /* @__PURE__ */ jsxRuntime.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4982
|
+
SidebarMenuButton,
|
|
4983
|
+
{
|
|
4984
|
+
isActive: activeItem === item.label || item.active,
|
|
4985
|
+
onClick: () => {
|
|
4986
|
+
item.onClick?.();
|
|
4987
|
+
onItemClick?.(item.label);
|
|
4988
|
+
},
|
|
4989
|
+
children: [
|
|
4990
|
+
item.icon,
|
|
4991
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: item.label })
|
|
4992
|
+
]
|
|
4993
|
+
}
|
|
4994
|
+
) }, item.label);
|
|
4995
|
+
if (!item.permission) return menuItem;
|
|
4996
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
4997
|
+
Can,
|
|
4998
|
+
{
|
|
4999
|
+
permission: item.permission,
|
|
5000
|
+
mode: item.permissionMode,
|
|
5001
|
+
children: menuItem
|
|
4838
5002
|
},
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
]
|
|
4843
|
-
}
|
|
4844
|
-
) }, item.label)) }) }) }) })
|
|
5003
|
+
item.label
|
|
5004
|
+
);
|
|
5005
|
+
}) }) }) }) })
|
|
4845
5006
|
] }),
|
|
4846
5007
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
4847
5008
|
showHeader && /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex h-14 items-center justify-between border-b px-4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: brandName }) }),
|
|
4848
|
-
/* @__PURE__ */ jsxRuntime.jsx("main", { className: "overflow-y-auto flex-1 p-6", children })
|
|
5009
|
+
/* @__PURE__ */ jsxRuntime.jsx("main", { className: cn("overflow-y-auto flex-1 p-6", mainClassName), children })
|
|
4849
5010
|
] })
|
|
4850
5011
|
] });
|
|
4851
5012
|
}
|
|
@@ -7349,84 +7510,14 @@ function DataTableSearch({
|
|
|
7349
7510
|
)
|
|
7350
7511
|
] });
|
|
7351
7512
|
}
|
|
7352
|
-
function
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
return
|
|
7359
|
-
}
|
|
7360
|
-
function matchesAny(permissionSet, permission) {
|
|
7361
|
-
if (permissionSet.has(permission)) return true;
|
|
7362
|
-
for (const pattern of permissionSet) {
|
|
7363
|
-
if (matchPermission(pattern, permission)) return true;
|
|
7364
|
-
}
|
|
7365
|
-
return false;
|
|
7366
|
-
}
|
|
7367
|
-
var AbilityContext = react.createContext(void 0);
|
|
7368
|
-
AbilityContext.displayName = "AbilityContext";
|
|
7369
|
-
function AbilityProvider({ children, permissions }) {
|
|
7370
|
-
const [permissionSet, setPermissionSet] = react.useState(
|
|
7371
|
-
() => new Set(permissions ?? [])
|
|
7372
|
-
);
|
|
7373
|
-
const can = react.useCallback(
|
|
7374
|
-
(perms, mode = "any") => {
|
|
7375
|
-
const list = Array.isArray(perms) ? perms : [perms];
|
|
7376
|
-
if (list.length === 0) return false;
|
|
7377
|
-
if (permissionSet.has("*")) return true;
|
|
7378
|
-
if (mode === "all") {
|
|
7379
|
-
return list.every((p) => matchesAny(permissionSet, p));
|
|
7380
|
-
}
|
|
7381
|
-
return list.some((p) => matchesAny(permissionSet, p));
|
|
7382
|
-
},
|
|
7383
|
-
[permissionSet]
|
|
7384
|
-
);
|
|
7385
|
-
const setAbilities = react.useCallback((perms) => {
|
|
7386
|
-
setPermissionSet(new Set(perms));
|
|
7387
|
-
}, []);
|
|
7388
|
-
const clearAbilities = react.useCallback(() => {
|
|
7389
|
-
setPermissionSet(/* @__PURE__ */ new Set());
|
|
7390
|
-
}, []);
|
|
7391
|
-
const syncedKey = react.useRef(permissions ? permissions.join("|") : null);
|
|
7392
|
-
react.useEffect(() => {
|
|
7393
|
-
if (permissions === void 0) return;
|
|
7394
|
-
const key = permissions.join("|");
|
|
7395
|
-
if (key === syncedKey.current) return;
|
|
7396
|
-
syncedKey.current = key;
|
|
7397
|
-
setPermissionSet(new Set(permissions));
|
|
7398
|
-
}, [permissions]);
|
|
7399
|
-
const value = react.useMemo(
|
|
7400
|
-
() => ({ can, setAbilities, clearAbilities }),
|
|
7401
|
-
[can, setAbilities, clearAbilities]
|
|
7402
|
-
);
|
|
7403
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AbilityContext.Provider, { value, children });
|
|
7404
|
-
}
|
|
7405
|
-
function useAbility() {
|
|
7406
|
-
const context = react.useContext(AbilityContext);
|
|
7407
|
-
if (!context) {
|
|
7408
|
-
throw new Error("useAbility must be used within an AbilityProvider");
|
|
7409
|
-
}
|
|
7410
|
-
return context;
|
|
7411
|
-
}
|
|
7412
|
-
function useCan(permissions, mode = "any") {
|
|
7413
|
-
const { can } = useAbility();
|
|
7414
|
-
return can(permissions, mode);
|
|
7415
|
-
}
|
|
7416
|
-
function Can({ permission, mode = "any", negate = false, fallback = null, children }) {
|
|
7417
|
-
const { can } = useAbility();
|
|
7418
|
-
const hasPermission = can(permission, mode);
|
|
7419
|
-
const show = negate ? !hasPermission : hasPermission;
|
|
7420
|
-
if (typeof children === "function") {
|
|
7421
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(show) });
|
|
7422
|
-
}
|
|
7423
|
-
return show ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
|
|
7424
|
-
}
|
|
7425
|
-
Can.displayName = "Can";
|
|
7426
|
-
function CanNot({ permission, mode = "any", fallback = null, children }) {
|
|
7427
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Can, { permission, mode, negate: true, fallback, children });
|
|
7513
|
+
function TCCEProvider({
|
|
7514
|
+
children,
|
|
7515
|
+
permissions,
|
|
7516
|
+
toasterPosition,
|
|
7517
|
+
tooltipDelayDuration
|
|
7518
|
+
}) {
|
|
7519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: tooltipDelayDuration, children: /* @__PURE__ */ jsxRuntime.jsx(AbilityProvider, { permissions, children: /* @__PURE__ */ jsxRuntime.jsx(Toaster, { position: toasterPosition, children }) }) });
|
|
7428
7520
|
}
|
|
7429
|
-
CanNot.displayName = "CanNot";
|
|
7430
7521
|
|
|
7431
7522
|
Object.defineProperty(exports, "Controller", {
|
|
7432
7523
|
enumerable: true,
|
|
@@ -7460,6 +7551,7 @@ exports.AlertDialogPortal = AlertDialogPortal;
|
|
|
7460
7551
|
exports.AlertDialogTitle = AlertDialogTitle;
|
|
7461
7552
|
exports.AlertDialogTrigger = AlertDialogTrigger;
|
|
7462
7553
|
exports.AlertTitle = AlertTitle;
|
|
7554
|
+
exports.AppShell = AppShell;
|
|
7463
7555
|
exports.Avatar = Avatar;
|
|
7464
7556
|
exports.AvatarBadge = AvatarBadge;
|
|
7465
7557
|
exports.AvatarFallback = AvatarFallback;
|
|
@@ -7512,6 +7604,7 @@ exports.DataTableSkeleton = DataTableSkeleton;
|
|
|
7512
7604
|
exports.DataTableToolbar = DataTableToolbar;
|
|
7513
7605
|
exports.DatePicker = DatePicker;
|
|
7514
7606
|
exports.Dialog = Dialog;
|
|
7607
|
+
exports.DialogBody = DialogBody;
|
|
7515
7608
|
exports.DialogClose = DialogClose;
|
|
7516
7609
|
exports.DialogContent = DialogContent;
|
|
7517
7610
|
exports.DialogDescription = DialogDescription;
|
|
@@ -7609,7 +7702,6 @@ exports.SelectSeparator = SelectSeparator;
|
|
|
7609
7702
|
exports.SelectTrigger = SelectTrigger;
|
|
7610
7703
|
exports.SelectValue = SelectValue;
|
|
7611
7704
|
exports.Separator = Separator;
|
|
7612
|
-
exports.SideBar = SideBar;
|
|
7613
7705
|
exports.SidebarProvider = SidebarProvider;
|
|
7614
7706
|
exports.SidebarTrigger = SidebarTrigger;
|
|
7615
7707
|
exports.Skeleton = Skeleton;
|
|
@@ -7621,6 +7713,7 @@ exports.Status = Status;
|
|
|
7621
7713
|
exports.StatusIndicator = StatusIndicator;
|
|
7622
7714
|
exports.StatusLabel = StatusLabel;
|
|
7623
7715
|
exports.Switch = Switch;
|
|
7716
|
+
exports.TCCEProvider = TCCEProvider;
|
|
7624
7717
|
exports.TEXT_SIZES = TEXT_SIZES;
|
|
7625
7718
|
exports.TEXT_WEIGHTS = TEXT_WEIGHTS;
|
|
7626
7719
|
exports.Table = Table;
|