@gearbox-protocol/permissionless-ui 1.0.0

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.
Files changed (104) hide show
  1. package/README.md +7 -0
  2. package/dist/cjs/components/alert-dialog.js +160 -0
  3. package/dist/cjs/components/back-button.js +57 -0
  4. package/dist/cjs/components/badge.js +61 -0
  5. package/dist/cjs/components/buttons/button.js +88 -0
  6. package/dist/cjs/components/buttons/copy-button.js +62 -0
  7. package/dist/cjs/components/buttons/external-button.js +62 -0
  8. package/dist/cjs/components/buttons/tab-button.js +60 -0
  9. package/dist/cjs/components/card.js +103 -0
  10. package/dist/cjs/components/checkbox.js +61 -0
  11. package/dist/cjs/components/danger-zone.js +35 -0
  12. package/dist/cjs/components/dialog.js +137 -0
  13. package/dist/cjs/components/dropdown-menu.js +200 -0
  14. package/dist/cjs/components/editable-table/edit-button.js +46 -0
  15. package/dist/cjs/components/editable-table/editable-table.js +93 -0
  16. package/dist/cjs/components/editable-table/updated-value.js +73 -0
  17. package/dist/cjs/components/index.js +72 -0
  18. package/dist/cjs/components/input.js +69 -0
  19. package/dist/cjs/components/label.js +54 -0
  20. package/dist/cjs/components/page-layout.js +36 -0
  21. package/dist/cjs/components/search-bar.js +66 -0
  22. package/dist/cjs/components/select.js +167 -0
  23. package/dist/cjs/components/skeleton.js +51 -0
  24. package/dist/cjs/components/table.js +121 -0
  25. package/dist/cjs/components/tabs.js +84 -0
  26. package/dist/cjs/components/textarea.js +56 -0
  27. package/dist/cjs/components/token-icon.js +57 -0
  28. package/dist/cjs/components/tooltip.js +63 -0
  29. package/dist/cjs/configs/index.js +38 -0
  30. package/dist/cjs/configs/tailwind.config.js +84 -0
  31. package/dist/cjs/index.js +24 -0
  32. package/dist/cjs/package.json +1 -0
  33. package/dist/cjs/utils/cn.js +32 -0
  34. package/dist/cjs/utils/copy.js +35 -0
  35. package/dist/cjs/utils/index.js +32 -0
  36. package/dist/esm/components/alert-dialog.js +116 -0
  37. package/dist/esm/components/back-button.js +23 -0
  38. package/dist/esm/components/badge.js +26 -0
  39. package/dist/esm/components/buttons/button.js +53 -0
  40. package/dist/esm/components/buttons/copy-button.js +28 -0
  41. package/dist/esm/components/buttons/external-button.js +28 -0
  42. package/dist/esm/components/buttons/tab-button.js +26 -0
  43. package/dist/esm/components/card.js +64 -0
  44. package/dist/esm/components/checkbox.js +27 -0
  45. package/dist/esm/components/danger-zone.js +11 -0
  46. package/dist/esm/components/dialog.js +97 -0
  47. package/dist/esm/components/dropdown-menu.js +152 -0
  48. package/dist/esm/components/editable-table/edit-button.js +22 -0
  49. package/dist/esm/components/editable-table/editable-table.js +68 -0
  50. package/dist/esm/components/editable-table/updated-value.js +49 -0
  51. package/dist/esm/components/index.js +26 -0
  52. package/dist/esm/components/input.js +35 -0
  53. package/dist/esm/components/label.js +20 -0
  54. package/dist/esm/components/page-layout.js +12 -0
  55. package/dist/esm/components/search-bar.js +42 -0
  56. package/dist/esm/components/select.js +124 -0
  57. package/dist/esm/components/skeleton.js +17 -0
  58. package/dist/esm/components/table.js +80 -0
  59. package/dist/esm/components/tabs.js +47 -0
  60. package/dist/esm/components/textarea.js +22 -0
  61. package/dist/esm/components/token-icon.js +23 -0
  62. package/dist/esm/components/tooltip.js +26 -0
  63. package/dist/esm/configs/index.js +4 -0
  64. package/dist/esm/configs/tailwind.config.js +64 -0
  65. package/dist/esm/index.js +2 -0
  66. package/dist/esm/package.json +1 -0
  67. package/dist/esm/utils/cn.js +8 -0
  68. package/dist/esm/utils/copy.js +11 -0
  69. package/dist/esm/utils/index.js +6 -0
  70. package/dist/globals.css +88 -0
  71. package/dist/types/components/alert-dialog.d.ts +20 -0
  72. package/dist/types/components/back-button.d.ts +7 -0
  73. package/dist/types/components/badge.d.ts +9 -0
  74. package/dist/types/components/buttons/button.d.ts +11 -0
  75. package/dist/types/components/buttons/copy-button.d.ts +8 -0
  76. package/dist/types/components/buttons/external-button.d.ts +7 -0
  77. package/dist/types/components/buttons/tab-button.d.ts +8 -0
  78. package/dist/types/components/card.d.ts +8 -0
  79. package/dist/types/components/checkbox.d.ts +4 -0
  80. package/dist/types/components/danger-zone.d.ts +5 -0
  81. package/dist/types/components/dialog.d.ts +16 -0
  82. package/dist/types/components/dropdown-menu.d.ts +27 -0
  83. package/dist/types/components/editable-table/edit-button.d.ts +7 -0
  84. package/dist/types/components/editable-table/editable-table.d.ts +31 -0
  85. package/dist/types/components/editable-table/updated-value.d.ts +12 -0
  86. package/dist/types/components/index.d.ts +26 -0
  87. package/dist/types/components/input.d.ts +7 -0
  88. package/dist/types/components/label.d.ts +5 -0
  89. package/dist/types/components/page-layout.d.ts +10 -0
  90. package/dist/types/components/search-bar.d.ts +8 -0
  91. package/dist/types/components/select.d.ts +13 -0
  92. package/dist/types/components/skeleton.d.ts +2 -0
  93. package/dist/types/components/table.d.ts +10 -0
  94. package/dist/types/components/tabs.d.ts +7 -0
  95. package/dist/types/components/textarea.d.ts +4 -0
  96. package/dist/types/components/token-icon.d.ts +6 -0
  97. package/dist/types/components/tooltip.d.ts +7 -0
  98. package/dist/types/configs/index.d.ts +1 -0
  99. package/dist/types/configs/tailwind.config.d.ts +3 -0
  100. package/dist/types/index.d.ts +2 -0
  101. package/dist/types/utils/cn.d.ts +2 -0
  102. package/dist/types/utils/copy.d.ts +4 -0
  103. package/dist/types/utils/index.d.ts +3 -0
  104. package/package.json +93 -0
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import cn from "../utils/index.js";
4
+ const badgeVariants = cva(
5
+ "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
6
+ {
7
+ variants: {
8
+ variant: {
9
+ default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
10
+ secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
11
+ destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
12
+ outline: "text-foreground"
13
+ }
14
+ },
15
+ defaultVariants: {
16
+ variant: "default"
17
+ }
18
+ }
19
+ );
20
+ function Badge({ className, variant, ...props }) {
21
+ return /* @__PURE__ */ jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
22
+ }
23
+ export {
24
+ Badge,
25
+ badgeVariants
26
+ };
@@ -0,0 +1,53 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Slot } from "@radix-ui/react-slot";
3
+ import { cva } from "class-variance-authority";
4
+ import * as React from "react";
5
+ import cn from "../../utils/index.js";
6
+ const buttonVariants = cva(
7
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
12
+ destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
13
+ outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
14
+ secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
15
+ ghost: "hover:bg-accent hover:text-accent-foreground",
16
+ link: "text-primary underline-offset-4 hover:underline",
17
+ pink: "bg-pink-700 hover:bg-pink-600 disabled:bg-pink-700 text-white",
18
+ "pink-outline": "border border-pink-700 hover:border-pink-600 disabled:border-pink-700 text-white",
19
+ blue: "bg-blue-800 hover:bg-blue-700 disabled:bg-blue-700 text-white",
20
+ "blue-outline": "border border-blue-800 hover:border-blue-700 disabled:border-blue-800 text-white"
21
+ },
22
+ size: {
23
+ xs: "rounded-full px-3 py-0.5 text-xs",
24
+ sm: "h-8 rounded-md px-3 text-xs",
25
+ default: "h-9 px-4 py-2",
26
+ lg: "h-10 rounded-md px-8",
27
+ icon: "h-9 w-9"
28
+ }
29
+ },
30
+ defaultVariants: {
31
+ variant: "default",
32
+ size: "default"
33
+ }
34
+ }
35
+ );
36
+ const Button = React.forwardRef(
37
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
38
+ const Comp = asChild ? Slot : "button";
39
+ return /* @__PURE__ */ jsx(
40
+ Comp,
41
+ {
42
+ className: cn(buttonVariants({ variant, size, className })),
43
+ ref,
44
+ ...props
45
+ }
46
+ );
47
+ }
48
+ );
49
+ Button.displayName = "Button";
50
+ export {
51
+ Button,
52
+ buttonVariants
53
+ };
@@ -0,0 +1,28 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Copy } from "lucide-react";
3
+ import * as React from "react";
4
+ import cn, { copyToClipboard } from "../../utils/index.js";
5
+ import { Button } from "./button.js";
6
+ const CopyButton = React.forwardRef(
7
+ ({ text, name, className, size = "3", ...props }, ref) => {
8
+ return /* @__PURE__ */ jsx(
9
+ Button,
10
+ {
11
+ ref,
12
+ variant: "ghost",
13
+ size: "sm",
14
+ className: cn(
15
+ "text-muted-foreground hover:text-white p-0 h-auto",
16
+ className
17
+ ),
18
+ onClick: () => copyToClipboard({ text, name }),
19
+ ...props,
20
+ children: /* @__PURE__ */ jsx(Copy, { className: `h-${size} w-${size}` })
21
+ }
22
+ );
23
+ }
24
+ );
25
+ CopyButton.displayName = "CopyButton";
26
+ export {
27
+ CopyButton
28
+ };
@@ -0,0 +1,28 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ExternalLink } from "lucide-react";
3
+ import * as React from "react";
4
+ import cn from "../../utils/index.js";
5
+ import { Button } from "./button.js";
6
+ const ExternalButton = React.forwardRef(
7
+ ({ url, className, size = "3", ...props }, ref) => {
8
+ return /* @__PURE__ */ jsx(
9
+ Button,
10
+ {
11
+ ref,
12
+ variant: "ghost",
13
+ size: "sm",
14
+ className: cn(
15
+ "text-muted-foreground hover:text-white p-0 h-auto",
16
+ className
17
+ ),
18
+ onClick: () => window.open(url, "_blank"),
19
+ ...props,
20
+ children: /* @__PURE__ */ jsx(ExternalLink, { className: `h-${size} w-${size}` })
21
+ }
22
+ );
23
+ }
24
+ );
25
+ ExternalButton.displayName = "CopyButton";
26
+ export {
27
+ ExternalButton
28
+ };
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import cn from "../../utils/index.js";
4
+ import { Button } from "./button.js";
5
+ const TabButton = React.forwardRef(
6
+ ({ className, children, size = "sm", ...props }, ref) => {
7
+ return /* @__PURE__ */ jsx(
8
+ Button,
9
+ {
10
+ ref,
11
+ variant: "outline",
12
+ size,
13
+ className: cn(
14
+ "bg-gray-900 text-gray-100 border-gray-700 hover:bg-gray-800 border-gray-300",
15
+ className
16
+ ),
17
+ ...props,
18
+ children
19
+ }
20
+ );
21
+ }
22
+ );
23
+ TabButton.displayName = "TabButton";
24
+ export {
25
+ TabButton
26
+ };
@@ -0,0 +1,64 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import cn from "../utils/index.js";
4
+ const Card = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5
+ "div",
6
+ {
7
+ ref,
8
+ className: cn(
9
+ "rounded-xl border bg-card text-card-foreground shadow",
10
+ className
11
+ ),
12
+ ...props
13
+ }
14
+ ));
15
+ Card.displayName = "Card";
16
+ const CardHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
17
+ "div",
18
+ {
19
+ ref,
20
+ className: cn("flex flex-col space-y-1.5 p-6", className),
21
+ ...props
22
+ }
23
+ ));
24
+ CardHeader.displayName = "CardHeader";
25
+ const CardTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
26
+ "div",
27
+ {
28
+ ref,
29
+ className: cn(
30
+ "font-semibold leading-none tracking-tight text-2xl",
31
+ className
32
+ ),
33
+ ...props
34
+ }
35
+ ));
36
+ CardTitle.displayName = "CardTitle";
37
+ const CardDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
38
+ "div",
39
+ {
40
+ ref,
41
+ className: cn("text-sm text-muted-foreground", className),
42
+ ...props
43
+ }
44
+ ));
45
+ CardDescription.displayName = "CardDescription";
46
+ const CardContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
47
+ CardContent.displayName = "CardContent";
48
+ const CardFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
49
+ "div",
50
+ {
51
+ ref,
52
+ className: cn("flex items-center p-6 pt-0", className),
53
+ ...props
54
+ }
55
+ ));
56
+ CardFooter.displayName = "CardFooter";
57
+ export {
58
+ Card,
59
+ CardContent,
60
+ CardDescription,
61
+ CardFooter,
62
+ CardHeader,
63
+ CardTitle
64
+ };
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
3
+ import { Check } from "lucide-react";
4
+ import * as React from "react";
5
+ import cn from "../utils/index.js";
6
+ const Checkbox = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
7
+ CheckboxPrimitive.Root,
8
+ {
9
+ ref,
10
+ className: cn(
11
+ "peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
12
+ className
13
+ ),
14
+ ...props,
15
+ children: /* @__PURE__ */ jsx(
16
+ CheckboxPrimitive.Indicator,
17
+ {
18
+ className: cn("flex items-center justify-center text-current"),
19
+ children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
20
+ }
21
+ )
22
+ }
23
+ ));
24
+ Checkbox.displayName = CheckboxPrimitive.Root.displayName;
25
+ export {
26
+ Checkbox
27
+ };
@@ -0,0 +1,11 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Card, CardContent, CardHeader, CardTitle } from "./card.js";
3
+ function DangerZone({ children }) {
4
+ return /* @__PURE__ */ jsxs(Card, { className: "border-destructive", children: [
5
+ /* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(CardTitle, { className: "text-destructive", children: "Danger Zone" }) }),
6
+ /* @__PURE__ */ jsx(CardContent, { children })
7
+ ] });
8
+ }
9
+ export {
10
+ DangerZone
11
+ };
@@ -0,0 +1,97 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ import { X } from "lucide-react";
4
+ import * as React from "react";
5
+ import cn from "../utils/index.js";
6
+ const Dialog = DialogPrimitive.Root;
7
+ const DialogTrigger = DialogPrimitive.Trigger;
8
+ const DialogPortal = DialogPrimitive.Portal;
9
+ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
10
+ DialogPrimitive.Overlay,
11
+ {
12
+ ref,
13
+ className: cn(
14
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
15
+ className
16
+ ),
17
+ ...props
18
+ }
19
+ ));
20
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
21
+ const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
22
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
23
+ /* @__PURE__ */ jsxs(
24
+ DialogPrimitive.Content,
25
+ {
26
+ ref,
27
+ className: cn(
28
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
29
+ className
30
+ ),
31
+ ...props,
32
+ children: [
33
+ children,
34
+ /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
35
+ /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
36
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
37
+ ] })
38
+ ]
39
+ }
40
+ )
41
+ ] }));
42
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
43
+ const DialogHeader = ({
44
+ className,
45
+ ...props
46
+ }) => /* @__PURE__ */ jsx(
47
+ "div",
48
+ {
49
+ className: cn(
50
+ "flex flex-col space-y-1.5 text-center sm:text-left",
51
+ className
52
+ ),
53
+ ...props
54
+ }
55
+ );
56
+ DialogHeader.displayName = "DialogHeader";
57
+ const DialogFooter = ({
58
+ className,
59
+ ...props
60
+ }) => /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ className: cn(
64
+ "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
65
+ className
66
+ ),
67
+ ...props
68
+ }
69
+ );
70
+ DialogFooter.displayName = "DialogFooter";
71
+ const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
72
+ DialogPrimitive.Title,
73
+ {
74
+ ref,
75
+ className: cn("text-3xl font-bold mb-6 text-white", className),
76
+ ...props
77
+ }
78
+ ));
79
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
80
+ const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
81
+ DialogPrimitive.Description,
82
+ {
83
+ ref,
84
+ className: cn("text-sm text-muted-foreground", className),
85
+ ...props
86
+ }
87
+ ));
88
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
89
+ export {
90
+ Dialog,
91
+ DialogContent,
92
+ DialogDescription,
93
+ DialogFooter,
94
+ DialogHeader,
95
+ DialogTitle,
96
+ DialogTrigger
97
+ };
@@ -0,0 +1,152 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
3
+ import { Check, ChevronRight, Circle } from "lucide-react";
4
+ import * as React from "react";
5
+ import cn from "../utils/index.js";
6
+ const DropdownMenu = DropdownMenuPrimitive.Root;
7
+ const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
8
+ const DropdownMenuGroup = DropdownMenuPrimitive.Group;
9
+ const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
10
+ const DropdownMenuSub = DropdownMenuPrimitive.Sub;
11
+ const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
12
+ const DropdownMenuSubTrigger = React.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ jsxs(
13
+ DropdownMenuPrimitive.SubTrigger,
14
+ {
15
+ ref,
16
+ className: cn(
17
+ "flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
18
+ inset && "pl-8",
19
+ className
20
+ ),
21
+ ...props,
22
+ children: [
23
+ children,
24
+ /* @__PURE__ */ jsx(ChevronRight, { className: "ml-auto" })
25
+ ]
26
+ }
27
+ ));
28
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
29
+ const DropdownMenuSubContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
30
+ DropdownMenuPrimitive.SubContent,
31
+ {
32
+ ref,
33
+ className: cn(
34
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
35
+ className
36
+ ),
37
+ ...props
38
+ }
39
+ ));
40
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
41
+ const DropdownMenuContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
42
+ DropdownMenuPrimitive.Content,
43
+ {
44
+ ref,
45
+ sideOffset,
46
+ className: cn(
47
+ "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
48
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
49
+ className
50
+ ),
51
+ ...props
52
+ }
53
+ ) }));
54
+ DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
55
+ const DropdownMenuItem = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
56
+ DropdownMenuPrimitive.Item,
57
+ {
58
+ ref,
59
+ className: cn(
60
+ "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",
61
+ inset && "pl-8",
62
+ className
63
+ ),
64
+ ...props
65
+ }
66
+ ));
67
+ DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
68
+ const DropdownMenuCheckboxItem = React.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ jsxs(
69
+ DropdownMenuPrimitive.CheckboxItem,
70
+ {
71
+ ref,
72
+ className: cn(
73
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
74
+ className
75
+ ),
76
+ checked,
77
+ ...props,
78
+ children: [
79
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" }) }) }),
80
+ children
81
+ ]
82
+ }
83
+ ));
84
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
85
+ const DropdownMenuRadioItem = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(
86
+ DropdownMenuPrimitive.RadioItem,
87
+ {
88
+ ref,
89
+ className: cn(
90
+ "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
91
+ className
92
+ ),
93
+ ...props,
94
+ children: [
95
+ /* @__PURE__ */ jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(Circle, { className: "h-2 w-2 fill-current" }) }) }),
96
+ children
97
+ ]
98
+ }
99
+ ));
100
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
101
+ const DropdownMenuLabel = React.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ jsx(
102
+ DropdownMenuPrimitive.Label,
103
+ {
104
+ ref,
105
+ className: cn(
106
+ "px-2 py-1.5 text-sm font-semibold",
107
+ inset && "pl-8",
108
+ className
109
+ ),
110
+ ...props
111
+ }
112
+ ));
113
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
114
+ const DropdownMenuSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
115
+ DropdownMenuPrimitive.Separator,
116
+ {
117
+ ref,
118
+ className: cn("-mx-1 my-1 h-px bg-muted", className),
119
+ ...props
120
+ }
121
+ ));
122
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
123
+ const DropdownMenuShortcut = ({
124
+ className,
125
+ ...props
126
+ }) => {
127
+ return /* @__PURE__ */ jsx(
128
+ "span",
129
+ {
130
+ className: cn("ml-auto text-xs tracking-widest opacity-60", className),
131
+ ...props
132
+ }
133
+ );
134
+ };
135
+ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
136
+ export {
137
+ DropdownMenu,
138
+ DropdownMenuCheckboxItem,
139
+ DropdownMenuContent,
140
+ DropdownMenuGroup,
141
+ DropdownMenuItem,
142
+ DropdownMenuLabel,
143
+ DropdownMenuPortal,
144
+ DropdownMenuRadioGroup,
145
+ DropdownMenuRadioItem,
146
+ DropdownMenuSeparator,
147
+ DropdownMenuShortcut,
148
+ DropdownMenuSub,
149
+ DropdownMenuSubContent,
150
+ DropdownMenuSubTrigger,
151
+ DropdownMenuTrigger
152
+ };
@@ -0,0 +1,22 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Edit } from "lucide-react";
3
+ import { Button } from "../buttons/button.js";
4
+ function EditButton({
5
+ onClick,
6
+ customButton,
7
+ disabled
8
+ }) {
9
+ return /* @__PURE__ */ jsx("div", { className: customButton ? "px-4 py-2" : "px-2", children: /* @__PURE__ */ jsx(
10
+ Button,
11
+ {
12
+ className: customButton ? "p-0 h-fit hover:bg-accent/0" : "p-2 h-fit",
13
+ variant: "ghost",
14
+ onClick,
15
+ disabled,
16
+ children: customButton ?? /* @__PURE__ */ jsx(Edit, { className: "h-4 w-4" })
17
+ }
18
+ ) });
19
+ }
20
+ export {
21
+ EditButton
22
+ };
@@ -0,0 +1,68 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { TabButton } from "../buttons/tab-button.js";
3
+ import { Table, TableCell } from "../table.js";
4
+ import { UpdatedValue } from "./updated-value.js";
5
+ function TableCellUpdatable({
6
+ oldValue,
7
+ newValue,
8
+ onEdit,
9
+ isEditable = true,
10
+ className,
11
+ align = "right",
12
+ customButton,
13
+ postfix,
14
+ disabled,
15
+ nowrap
16
+ }) {
17
+ const alignmentClass = {
18
+ left: "justify-start",
19
+ right: "justify-end",
20
+ center: "justify-center"
21
+ }[align];
22
+ return /* @__PURE__ */ jsx(TableCell, { className, children: /* @__PURE__ */ jsx("div", { className: `flex ${alignmentClass} w-full text-${align}`, children: /* @__PURE__ */ jsx(
23
+ UpdatedValue,
24
+ {
25
+ oldValue,
26
+ newValue,
27
+ onEdit,
28
+ isEditable,
29
+ customButton,
30
+ postfix,
31
+ disabled,
32
+ nowrap
33
+ }
34
+ ) }) });
35
+ }
36
+ function TableEditable({
37
+ title,
38
+ onNew,
39
+ newButtonText = "New",
40
+ buttonLoadingText = "Adding...",
41
+ isLoading,
42
+ actions,
43
+ children,
44
+ disabled = false
45
+ }) {
46
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
47
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center", children: [
48
+ /* @__PURE__ */ jsx("h2", { className: "text-2xl font-bold", children: title }),
49
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
50
+ onNew && /* @__PURE__ */ jsx(TabButton, { onClick: onNew, disabled: isLoading || disabled, children: isLoading ? buttonLoadingText : newButtonText }),
51
+ actions?.map((action, index) => /* @__PURE__ */ jsx(
52
+ TabButton,
53
+ {
54
+ onClick: action.onClick,
55
+ disabled: action.isLoading || disabled,
56
+ children: action.isLoading ? action.loadingText || "Loading..." : action.text
57
+ },
58
+ index
59
+ ))
60
+ ] })
61
+ ] }),
62
+ /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsx(Table, { children }) })
63
+ ] });
64
+ }
65
+ export {
66
+ TableCellUpdatable,
67
+ TableEditable
68
+ };
@@ -0,0 +1,49 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { EditButton } from "./edit-button.js";
3
+ function UpdatedValue({
4
+ oldValue,
5
+ newValue,
6
+ onEdit,
7
+ isEditable = true,
8
+ customButton,
9
+ postfix,
10
+ disabled = false,
11
+ nowrap = false
12
+ }) {
13
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center ", children: [
14
+ /* @__PURE__ */ jsx("span", { className: "flex items-center gap-2", children: oldValue !== void 0 && oldValue !== newValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
15
+ /* @__PURE__ */ jsx(
16
+ "span",
17
+ {
18
+ className: `line-through text-muted-foreground ${nowrap ? "whitespace-nowrap" : ""}`,
19
+ children: oldValue
20
+ }
21
+ ),
22
+ " \u2192 ",
23
+ /* @__PURE__ */ jsxs("span", { className: nowrap ? "whitespace-nowrap" : "", children: [
24
+ newValue,
25
+ postfix && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
26
+ " ",
27
+ postfix
28
+ ] })
29
+ ] })
30
+ ] }) : /* @__PURE__ */ jsxs("span", { className: nowrap ? "whitespace-nowrap" : "", children: [
31
+ newValue,
32
+ postfix && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground", children: [
33
+ " ",
34
+ postfix
35
+ ] })
36
+ ] }) }),
37
+ isEditable && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(
38
+ EditButton,
39
+ {
40
+ onClick: onEdit,
41
+ customButton,
42
+ disabled
43
+ }
44
+ ) })
45
+ ] });
46
+ }
47
+ export {
48
+ UpdatedValue
49
+ };