@bizapps/design-system-testing 1.0.5 → 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 +119 -102
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +8 -5
- package/dist/main.d.ts +8 -5
- package/dist/main.js +118 -102
- 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: {
|
|
@@ -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,
|
|
@@ -4648,6 +4655,84 @@ function NavigationMenuIndicator({
|
|
|
4648
4655
|
}
|
|
4649
4656
|
);
|
|
4650
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";
|
|
4651
4736
|
var SidebarContext = react.createContext({
|
|
4652
4737
|
open: true,
|
|
4653
4738
|
setOpen: () => {
|
|
@@ -4876,7 +4961,7 @@ function SidebarBrand({ brandName }) {
|
|
|
4876
4961
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm font-semibold", children: brandName })
|
|
4877
4962
|
] });
|
|
4878
4963
|
}
|
|
4879
|
-
function
|
|
4964
|
+
function AppShell({
|
|
4880
4965
|
items = defaultItems,
|
|
4881
4966
|
activeItem,
|
|
4882
4967
|
onItemClick,
|
|
@@ -4892,20 +4977,32 @@ function SideBar({
|
|
|
4892
4977
|
/* @__PURE__ */ jsxRuntime.jsx(SidebarTrigger, { variant: "ghost", className: "size-8 shrink-0" }),
|
|
4893
4978
|
/* @__PURE__ */ jsxRuntime.jsx(SidebarBrand, { brandName })
|
|
4894
4979
|
] }),
|
|
4895
|
-
/* @__PURE__ */ jsxRuntime.jsx(SidebarContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroup, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarGroupContent, { children: /* @__PURE__ */ jsxRuntime.jsx(SidebarMenu, { children: items.map((item) =>
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
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
|
|
4902
5002
|
},
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
]
|
|
4907
|
-
}
|
|
4908
|
-
) }, item.label)) }) }) }) })
|
|
5003
|
+
item.label
|
|
5004
|
+
);
|
|
5005
|
+
}) }) }) }) })
|
|
4909
5006
|
] }),
|
|
4910
5007
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col", children: [
|
|
4911
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 }) }),
|
|
@@ -7413,94 +7510,13 @@ function DataTableSearch({
|
|
|
7413
7510
|
)
|
|
7414
7511
|
] });
|
|
7415
7512
|
}
|
|
7416
|
-
function matchPermission(pattern, permission) {
|
|
7417
|
-
if (pattern === "*") return true;
|
|
7418
|
-
if (pattern === permission) return true;
|
|
7419
|
-
const patternParts = pattern.split(".");
|
|
7420
|
-
const permParts = permission.split(".");
|
|
7421
|
-
if (patternParts.length !== permParts.length) return false;
|
|
7422
|
-
return patternParts.every((part, i) => part === "*" || part === permParts[i]);
|
|
7423
|
-
}
|
|
7424
|
-
function matchesAny(permissionSet, permission) {
|
|
7425
|
-
if (permissionSet.has(permission)) return true;
|
|
7426
|
-
for (const pattern of permissionSet) {
|
|
7427
|
-
if (matchPermission(pattern, permission)) return true;
|
|
7428
|
-
}
|
|
7429
|
-
return false;
|
|
7430
|
-
}
|
|
7431
|
-
var AbilityContext = react.createContext(void 0);
|
|
7432
|
-
AbilityContext.displayName = "AbilityContext";
|
|
7433
|
-
function AbilityProvider({ children, permissions }) {
|
|
7434
|
-
const [permissionSet, setPermissionSet] = react.useState(
|
|
7435
|
-
() => new Set(permissions ?? [])
|
|
7436
|
-
);
|
|
7437
|
-
const can = react.useCallback(
|
|
7438
|
-
(perms, mode = "any") => {
|
|
7439
|
-
const list = Array.isArray(perms) ? perms : [perms];
|
|
7440
|
-
if (list.length === 0) return false;
|
|
7441
|
-
if (permissionSet.has("*")) return true;
|
|
7442
|
-
if (mode === "all") {
|
|
7443
|
-
return list.every((p) => matchesAny(permissionSet, p));
|
|
7444
|
-
}
|
|
7445
|
-
return list.some((p) => matchesAny(permissionSet, p));
|
|
7446
|
-
},
|
|
7447
|
-
[permissionSet]
|
|
7448
|
-
);
|
|
7449
|
-
const setAbilities = react.useCallback((perms) => {
|
|
7450
|
-
setPermissionSet(new Set(perms));
|
|
7451
|
-
}, []);
|
|
7452
|
-
const clearAbilities = react.useCallback(() => {
|
|
7453
|
-
setPermissionSet(/* @__PURE__ */ new Set());
|
|
7454
|
-
}, []);
|
|
7455
|
-
const syncedKey = react.useRef(permissions ? permissions.join("|") : null);
|
|
7456
|
-
react.useEffect(() => {
|
|
7457
|
-
if (permissions === void 0) return;
|
|
7458
|
-
const key = permissions.join("|");
|
|
7459
|
-
if (key === syncedKey.current) return;
|
|
7460
|
-
syncedKey.current = key;
|
|
7461
|
-
setPermissionSet(new Set(permissions));
|
|
7462
|
-
}, [permissions]);
|
|
7463
|
-
const value = react.useMemo(
|
|
7464
|
-
() => ({ can, setAbilities, clearAbilities }),
|
|
7465
|
-
[can, setAbilities, clearAbilities]
|
|
7466
|
-
);
|
|
7467
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AbilityContext.Provider, { value, children });
|
|
7468
|
-
}
|
|
7469
|
-
function useAbility() {
|
|
7470
|
-
const context = react.useContext(AbilityContext);
|
|
7471
|
-
if (!context) {
|
|
7472
|
-
throw new Error("useAbility must be used within an AbilityProvider");
|
|
7473
|
-
}
|
|
7474
|
-
return context;
|
|
7475
|
-
}
|
|
7476
|
-
function useCan(permissions, mode = "any") {
|
|
7477
|
-
const { can } = useAbility();
|
|
7478
|
-
return can(permissions, mode);
|
|
7479
|
-
}
|
|
7480
|
-
function Can({ permission, mode = "any", negate = false, fallback = null, children }) {
|
|
7481
|
-
const { can } = useAbility();
|
|
7482
|
-
const hasPermission = can(permission, mode);
|
|
7483
|
-
const show = negate ? !hasPermission : hasPermission;
|
|
7484
|
-
if (typeof children === "function") {
|
|
7485
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: children(show) });
|
|
7486
|
-
}
|
|
7487
|
-
return show ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) : /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: fallback });
|
|
7488
|
-
}
|
|
7489
|
-
Can.displayName = "Can";
|
|
7490
|
-
function CanNot({ permission, mode = "any", fallback = null, children }) {
|
|
7491
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Can, { permission, mode, negate: true, fallback, children });
|
|
7492
|
-
}
|
|
7493
|
-
CanNot.displayName = "CanNot";
|
|
7494
7513
|
function TCCEProvider({
|
|
7495
7514
|
children,
|
|
7496
7515
|
permissions,
|
|
7497
7516
|
toasterPosition,
|
|
7498
7517
|
tooltipDelayDuration
|
|
7499
7518
|
}) {
|
|
7500
|
-
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: tooltipDelayDuration, children: /* @__PURE__ */ jsxRuntime.
|
|
7501
|
-
children,
|
|
7502
|
-
/* @__PURE__ */ jsxRuntime.jsx(Toaster, { position: toasterPosition })
|
|
7503
|
-
] }) });
|
|
7519
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: tooltipDelayDuration, children: /* @__PURE__ */ jsxRuntime.jsx(AbilityProvider, { permissions, children: /* @__PURE__ */ jsxRuntime.jsx(Toaster, { position: toasterPosition, children }) }) });
|
|
7504
7520
|
}
|
|
7505
7521
|
|
|
7506
7522
|
Object.defineProperty(exports, "Controller", {
|
|
@@ -7535,6 +7551,7 @@ exports.AlertDialogPortal = AlertDialogPortal;
|
|
|
7535
7551
|
exports.AlertDialogTitle = AlertDialogTitle;
|
|
7536
7552
|
exports.AlertDialogTrigger = AlertDialogTrigger;
|
|
7537
7553
|
exports.AlertTitle = AlertTitle;
|
|
7554
|
+
exports.AppShell = AppShell;
|
|
7538
7555
|
exports.Avatar = Avatar;
|
|
7539
7556
|
exports.AvatarBadge = AvatarBadge;
|
|
7540
7557
|
exports.AvatarFallback = AvatarFallback;
|
|
@@ -7587,6 +7604,7 @@ exports.DataTableSkeleton = DataTableSkeleton;
|
|
|
7587
7604
|
exports.DataTableToolbar = DataTableToolbar;
|
|
7588
7605
|
exports.DatePicker = DatePicker;
|
|
7589
7606
|
exports.Dialog = Dialog;
|
|
7607
|
+
exports.DialogBody = DialogBody;
|
|
7590
7608
|
exports.DialogClose = DialogClose;
|
|
7591
7609
|
exports.DialogContent = DialogContent;
|
|
7592
7610
|
exports.DialogDescription = DialogDescription;
|
|
@@ -7684,7 +7702,6 @@ exports.SelectSeparator = SelectSeparator;
|
|
|
7684
7702
|
exports.SelectTrigger = SelectTrigger;
|
|
7685
7703
|
exports.SelectValue = SelectValue;
|
|
7686
7704
|
exports.Separator = Separator;
|
|
7687
|
-
exports.SideBar = SideBar;
|
|
7688
7705
|
exports.SidebarProvider = SidebarProvider;
|
|
7689
7706
|
exports.SidebarTrigger = SidebarTrigger;
|
|
7690
7707
|
exports.Skeleton = Skeleton;
|