@carlonicora/nextjs-jsonapi 1.17.0 → 1.19.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 (113) hide show
  1. package/README.md +1 -1
  2. package/dist/{BlockNoteEditor-4Z6TZBJE.mjs → BlockNoteEditor-BQ5WWVUF.mjs} +2 -2
  3. package/dist/{BlockNoteEditor-34T5CY27.js → BlockNoteEditor-IZR6TESC.js} +6 -6
  4. package/dist/{BlockNoteEditor-34T5CY27.js.map → BlockNoteEditor-IZR6TESC.js.map} +1 -1
  5. package/dist/{chunk-D7H7SRWB.js → chunk-FB535VUS.js} +3977 -2496
  6. package/dist/chunk-FB535VUS.js.map +1 -0
  7. package/dist/{chunk-SXPXC2TY.mjs → chunk-MVNVXOC6.mjs} +5809 -4328
  8. package/dist/chunk-MVNVXOC6.mjs.map +1 -0
  9. package/dist/client/index.js +2 -2
  10. package/dist/client/index.mjs +1 -1
  11. package/dist/components/index.d.mts +298 -385
  12. package/dist/components/index.d.ts +298 -385
  13. package/dist/components/index.js +26 -2
  14. package/dist/components/index.js.map +1 -1
  15. package/dist/components/index.mjs +35 -11
  16. package/dist/contexts/index.js +2 -2
  17. package/dist/contexts/index.mjs +1 -1
  18. package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -1
  19. package/dist/scripts/generate-web-module/templates/components/editor.template.js +20 -6
  20. package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
  21. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
  22. package/dist/scripts/generate-web-module/templates/components/selector.template.js +46 -48
  23. package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
  24. package/dist/testing/index.js.map +1 -1
  25. package/dist/testing/index.mjs.map +1 -1
  26. package/package.json +6 -25
  27. package/scripts/generate-web-module/templates/components/editor.template.ts +20 -6
  28. package/scripts/generate-web-module/templates/components/selector.template.ts +46 -48
  29. package/src/components/forms/CommonDeleter.tsx +2 -2
  30. package/src/components/forms/CommonEditorTrigger.tsx +3 -3
  31. package/src/components/forms/DatePickerPopover.tsx +3 -1
  32. package/src/components/forms/DateRangeSelector.tsx +1 -1
  33. package/src/components/forms/FormCheckbox.tsx +1 -1
  34. package/src/components/forms/FormDate.tsx +3 -1
  35. package/src/components/forms/FormDateTime.tsx +5 -3
  36. package/src/components/forms/FormSelect.tsx +1 -1
  37. package/src/components/forms/FormSlider.tsx +4 -1
  38. package/src/components/forms/__tests__/FormCheckbox.test.tsx +5 -1
  39. package/src/components/forms/__tests__/FormDate.test.tsx +5 -1
  40. package/src/components/forms/__tests__/FormSelect.test.tsx +5 -1
  41. package/src/components/navigations/RecentPagesNavigator.tsx +2 -2
  42. package/src/components/tables/ContentListTable.tsx +3 -3
  43. package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +2 -2
  44. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +2 -2
  45. package/src/features/company/components/forms/CompanyDeleter.tsx +1 -1
  46. package/src/features/content/components/lists/ContentsList.tsx +1 -1
  47. package/src/features/notification/components/lists/NotificationsList.tsx +1 -1
  48. package/src/features/notification/components/modals/NotificationModal.tsx +2 -2
  49. package/src/features/role/components/forms/FormRoles.tsx +1 -1
  50. package/src/features/role/components/forms/UserRoleAdd.tsx +1 -1
  51. package/src/features/user/components/forms/UserEditor.tsx +2 -2
  52. package/src/features/user/components/forms/UserReactivator.tsx +1 -1
  53. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -2
  54. package/src/features/user/components/forms/UserSelector.tsx +5 -1
  55. package/src/features/user/components/lists/UserListInAdd.tsx +1 -1
  56. package/src/features/user/components/widgets/UserAvatar.tsx +37 -31
  57. package/src/features/user/components/widgets/UserSearchPopover.tsx +6 -2
  58. package/src/hooks/use-mobile.ts +1 -0
  59. package/src/hooks/useDataListRetriever.ts +1 -0
  60. package/src/lib/utils.ts +2 -0
  61. package/src/shadcnui/custom/multi-select.tsx +68 -76
  62. package/src/shadcnui/ui/accordion.tsx +64 -42
  63. package/src/shadcnui/ui/alert-dialog.tsx +142 -108
  64. package/src/shadcnui/ui/alert.tsx +64 -35
  65. package/src/shadcnui/ui/avatar.tsx +106 -50
  66. package/src/shadcnui/ui/badge.tsx +34 -26
  67. package/src/shadcnui/ui/breadcrumb.tsx +103 -92
  68. package/src/shadcnui/ui/button.tsx +30 -30
  69. package/src/shadcnui/ui/calendar.tsx +192 -50
  70. package/src/shadcnui/ui/card.tsx +94 -43
  71. package/src/shadcnui/ui/carousel.tsx +220 -201
  72. package/src/shadcnui/ui/chart.tsx +244 -190
  73. package/src/shadcnui/ui/checkbox.tsx +25 -25
  74. package/src/shadcnui/ui/collapsible.tsx +10 -4
  75. package/src/shadcnui/ui/combobox.tsx +292 -0
  76. package/src/shadcnui/ui/command.tsx +158 -126
  77. package/src/shadcnui/ui/context-menu.tsx +242 -164
  78. package/src/shadcnui/ui/dialog.tsx +125 -70
  79. package/src/shadcnui/ui/drawer.tsx +106 -70
  80. package/src/shadcnui/ui/dropdown-menu.tsx +231 -182
  81. package/src/shadcnui/ui/field.tsx +227 -0
  82. package/src/shadcnui/ui/hover-card.tsx +45 -23
  83. package/src/shadcnui/ui/input-group.tsx +149 -0
  84. package/src/shadcnui/ui/input-otp.tsx +19 -9
  85. package/src/shadcnui/ui/input.tsx +4 -5
  86. package/src/shadcnui/ui/label.tsx +16 -22
  87. package/src/shadcnui/ui/navigation-menu.tsx +44 -49
  88. package/src/shadcnui/ui/popover.tsx +81 -24
  89. package/src/shadcnui/ui/progress.tsx +77 -22
  90. package/src/shadcnui/ui/radio-group.tsx +30 -28
  91. package/src/shadcnui/ui/resizable.tsx +23 -17
  92. package/src/shadcnui/ui/scroll-area.tsx +50 -35
  93. package/src/shadcnui/ui/select.tsx +163 -135
  94. package/src/shadcnui/ui/separator.tsx +5 -8
  95. package/src/shadcnui/ui/sheet.tsx +40 -50
  96. package/src/shadcnui/ui/sidebar.tsx +317 -271
  97. package/src/shadcnui/ui/skeleton.tsx +2 -2
  98. package/src/shadcnui/ui/slider.tsx +60 -21
  99. package/src/shadcnui/ui/sonner.tsx +25 -1
  100. package/src/shadcnui/ui/switch.tsx +31 -24
  101. package/src/shadcnui/ui/table.tsx +84 -103
  102. package/src/shadcnui/ui/tabs.tsx +82 -55
  103. package/src/shadcnui/ui/textarea.tsx +15 -21
  104. package/src/shadcnui/ui/toggle.tsx +26 -21
  105. package/src/shadcnui/ui/tooltip.tsx +33 -24
  106. package/src/testing/factories/createMockApiData.ts +2 -2
  107. package/src/testing/factories/createMockResponse.ts +3 -8
  108. package/src/testing/factories/createMockService.ts +1 -4
  109. package/src/testing/index.ts +4 -18
  110. package/src/testing/matchers/jsonApiMatchers.ts +14 -16
  111. package/dist/chunk-D7H7SRWB.js.map +0 -1
  112. package/dist/chunk-SXPXC2TY.mjs.map +0 -1
  113. /package/dist/{BlockNoteEditor-4Z6TZBJE.mjs.map → BlockNoteEditor-BQ5WWVUF.mjs.map} +0 -0
@@ -1,130 +1,163 @@
1
- "use client";
1
+ "use client"
2
2
 
3
- import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
4
- import * as React from "react";
3
+ import * as React from "react"
4
+ import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
5
5
 
6
- import { buttonVariants } from "./button";
7
- import { cn } from "../../utils/cn";
6
+ import { cn } from "@/lib/utils"
7
+ import { Button } from "@/components/ui/button"
8
8
 
9
- const AlertDialog = AlertDialogPrimitive.Root;
9
+ function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
10
+ return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
11
+ }
10
12
 
11
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
13
+ function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
14
+ return (
15
+ <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
16
+ )
17
+ }
12
18
 
13
- const AlertDialogPortal = AlertDialogPrimitive.Portal;
19
+ function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
20
+ return (
21
+ <AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
22
+ )
23
+ }
14
24
 
15
- const AlertDialogOverlay = React.forwardRef<
16
- React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
17
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
18
- >(({ className, ...props }, ref) => (
19
- <AlertDialogPrimitive.Overlay
20
- className={cn(
21
- "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",
22
- className,
23
- )}
24
- {...props}
25
- ref={ref}
26
- />
27
- ));
28
- AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
29
-
30
- const AlertDialogContent = React.forwardRef<
31
- React.ElementRef<typeof AlertDialogPrimitive.Content>,
32
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
33
- >(({ className, ...props }, ref) => (
34
- <AlertDialogPortal>
35
- <AlertDialogOverlay />
36
- <AlertDialogPrimitive.Content
37
- ref={ref}
25
+ function AlertDialogOverlay({
26
+ className,
27
+ ...props
28
+ }: AlertDialogPrimitive.Backdrop.Props) {
29
+ return (
30
+ <AlertDialogPrimitive.Backdrop
31
+ data-slot="alert-dialog-overlay"
38
32
  className={cn(
39
- "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",
40
- className,
33
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 bg-black/80 duration-100 supports-backdrop-filter:backdrop-blur-xs fixed inset-0 isolate z-50",
34
+ className
41
35
  )}
42
36
  {...props}
43
37
  />
44
- </AlertDialogPortal>
45
- ));
46
- AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
38
+ )
39
+ }
47
40
 
48
- const AlertDialogHeader = ({
41
+ function AlertDialogContent({
49
42
  className,
43
+ size = "default",
50
44
  ...props
51
- }: React.HTMLAttributes<HTMLDivElement>) => (
52
- <div
53
- className={cn(
54
- "flex flex-col space-y-2 text-center sm:text-left",
55
- className,
56
- )}
57
- {...props}
58
- />
59
- );
60
- AlertDialogHeader.displayName = "AlertDialogHeader";
45
+ }: AlertDialogPrimitive.Popup.Props & {
46
+ size?: "default" | "sm"
47
+ }) {
48
+ return (
49
+ <AlertDialogPortal>
50
+ <AlertDialogOverlay />
51
+ <AlertDialogPrimitive.Popup
52
+ data-slot="alert-dialog-content"
53
+ data-size={size}
54
+ className={cn(
55
+ "data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 bg-background ring-foreground/10 gap-3 rounded-xl p-4 ring-1 duration-100 data-[size=default]:max-w-xs data-[size=sm]:max-w-64 data-[size=default]:sm:max-w-sm group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 outline-none",
56
+ className
57
+ )}
58
+ {...props}
59
+ />
60
+ </AlertDialogPortal>
61
+ )
62
+ }
61
63
 
62
- const AlertDialogFooter = ({
64
+ function AlertDialogHeader({
63
65
  className,
64
66
  ...props
65
- }: React.HTMLAttributes<HTMLDivElement>) => (
66
- <div
67
- className={cn(
68
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
69
- className,
70
- )}
71
- {...props}
72
- />
73
- );
74
- AlertDialogFooter.displayName = "AlertDialogFooter";
67
+ }: React.ComponentProps<"div">) {
68
+ return (
69
+ <div
70
+ data-slot="alert-dialog-header"
71
+ className={cn("grid grid-rows-[auto_1fr] place-items-center gap-1 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", className)}
72
+ {...props}
73
+ />
74
+ )
75
+ }
75
76
 
76
- const AlertDialogTitle = React.forwardRef<
77
- React.ElementRef<typeof AlertDialogPrimitive.Title>,
78
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
79
- >(({ className, ...props }, ref) => (
80
- <AlertDialogPrimitive.Title
81
- ref={ref}
82
- className={cn("text-lg font-semibold", className)}
83
- {...props}
84
- />
85
- ));
86
- AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
77
+ function AlertDialogFooter({
78
+ className,
79
+ ...props
80
+ }: React.ComponentProps<"div">) {
81
+ return (
82
+ <div
83
+ data-slot="alert-dialog-footer"
84
+ className={cn(
85
+ "flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
86
+ className
87
+ )}
88
+ {...props}
89
+ />
90
+ )
91
+ }
87
92
 
88
- const AlertDialogDescription = React.forwardRef<
89
- React.ElementRef<typeof AlertDialogPrimitive.Description>,
90
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
91
- >(({ className, ...props }, ref) => (
92
- <AlertDialogPrimitive.Description
93
- ref={ref}
94
- className={cn("text-sm text-muted-foreground", className)}
95
- {...props}
96
- />
97
- ));
98
- AlertDialogDescription.displayName =
99
- AlertDialogPrimitive.Description.displayName;
93
+ function AlertDialogMedia({
94
+ className,
95
+ ...props
96
+ }: React.ComponentProps<"div">) {
97
+ return (
98
+ <div
99
+ data-slot="alert-dialog-media"
100
+ className={cn("bg-muted mb-2 inline-flex size-8 items-center justify-center rounded-md sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-4", className)}
101
+ {...props}
102
+ />
103
+ )
104
+ }
100
105
 
101
- const AlertDialogAction = React.forwardRef<
102
- React.ElementRef<typeof AlertDialogPrimitive.Action>,
103
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
104
- >(({ className, ...props }, ref) => (
105
- <AlertDialogPrimitive.Action
106
- ref={ref}
107
- className={cn(buttonVariants(), className)}
108
- {...props}
109
- />
110
- ));
111
- AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
106
+ function AlertDialogTitle({
107
+ className,
108
+ ...props
109
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
110
+ return (
111
+ <AlertDialogPrimitive.Title
112
+ data-slot="alert-dialog-title"
113
+ className={cn("text-sm font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", className)}
114
+ {...props}
115
+ />
116
+ )
117
+ }
118
+
119
+ function AlertDialogDescription({
120
+ className,
121
+ ...props
122
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
123
+ return (
124
+ <AlertDialogPrimitive.Description
125
+ data-slot="alert-dialog-description"
126
+ className={cn("text-muted-foreground *:[a]:hover:text-foreground text-xs/relaxed text-balance md:text-pretty *:[a]:underline *:[a]:underline-offset-3", className)}
127
+ {...props}
128
+ />
129
+ )
130
+ }
131
+
132
+ function AlertDialogAction({
133
+ className,
134
+ ...props
135
+ }: React.ComponentProps<typeof Button>) {
136
+ return (
137
+ <Button
138
+ data-slot="alert-dialog-action"
139
+ className={cn(className)}
140
+ {...props}
141
+ />
142
+ )
143
+ }
112
144
 
113
- const AlertDialogCancel = React.forwardRef<
114
- React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
115
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
116
- >(({ className, ...props }, ref) => (
117
- <AlertDialogPrimitive.Cancel
118
- ref={ref}
119
- className={cn(
120
- buttonVariants({ variant: "outline" }),
121
- "mt-2 sm:mt-0",
122
- className,
123
- )}
124
- {...props}
125
- />
126
- ));
127
- AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
145
+ function AlertDialogCancel({
146
+ className,
147
+ variant = "outline",
148
+ size = "default",
149
+ ...props
150
+ }: AlertDialogPrimitive.Close.Props &
151
+ Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
152
+ return (
153
+ <AlertDialogPrimitive.Close
154
+ data-slot="alert-dialog-cancel"
155
+ className={cn(className)}
156
+ render={<Button variant={variant} size={size} />}
157
+ {...props}
158
+ />
159
+ )
160
+ }
128
161
 
129
162
  export {
130
163
  AlertDialog,
@@ -134,8 +167,9 @@ export {
134
167
  AlertDialogDescription,
135
168
  AlertDialogFooter,
136
169
  AlertDialogHeader,
170
+ AlertDialogMedia,
137
171
  AlertDialogOverlay,
138
172
  AlertDialogPortal,
139
173
  AlertDialogTitle,
140
174
  AlertDialogTrigger,
141
- };
175
+ }
@@ -1,43 +1,72 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import * as React from "react";
1
+ import * as React from "react"
2
+ import { cva, type VariantProps } from "class-variance-authority"
3
3
 
4
- import { cn } from "../../utils/cn";
4
+ import { cn } from "@/lib/utils"
5
5
 
6
- const alertVariants = cva(
7
- "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
8
- {
9
- variants: {
10
- variant: {
11
- default: "bg-background text-foreground",
12
- destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
13
- },
14
- },
15
- defaultVariants: {
16
- variant: "default",
6
+ const alertVariants = cva("grid gap-0.5 rounded-lg border px-2 py-1.5 text-left text-xs/relaxed has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-1.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-3.5 w-full relative group/alert", {
7
+ variants: {
8
+ variant: {
9
+ default: "bg-card text-card-foreground",
10
+ destructive: "text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",
17
11
  },
18
12
  },
19
- );
13
+ defaultVariants: {
14
+ variant: "default",
15
+ },
16
+ })
17
+
18
+ function Alert({
19
+ className,
20
+ variant,
21
+ ...props
22
+ }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
23
+ return (
24
+ <div
25
+ data-slot="alert"
26
+ role="alert"
27
+ className={cn(alertVariants({ variant }), className)}
28
+ {...props}
29
+ />
30
+ )
31
+ }
20
32
 
21
- const Alert = React.forwardRef<
22
- HTMLDivElement,
23
- React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
24
- >(({ className, variant, ...props }, ref) => (
25
- <div ref={ref} role="alert" className={cn(alertVariants({ variant }), className)} {...props} />
26
- ));
27
- Alert.displayName = "Alert";
33
+ function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
34
+ return (
35
+ <div
36
+ data-slot="alert-title"
37
+ className={cn(
38
+ "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3",
39
+ className
40
+ )}
41
+ {...props}
42
+ />
43
+ )
44
+ }
28
45
 
29
- const AlertTitle = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLHeadingElement>>(
30
- ({ className, ...props }, ref) => (
31
- <h5 ref={ref} className={cn("mb-1 font-medium leading-none tracking-tight", className)} {...props} />
32
- ),
33
- );
34
- AlertTitle.displayName = "AlertTitle";
46
+ function AlertDescription({
47
+ className,
48
+ ...props
49
+ }: React.ComponentProps<"div">) {
50
+ return (
51
+ <div
52
+ data-slot="alert-description"
53
+ className={cn(
54
+ "text-muted-foreground text-xs/relaxed text-balance md:text-pretty [&_p:not(:last-child)]:mb-4 [&_a]:hover:text-foreground [&_a]:underline [&_a]:underline-offset-3",
55
+ className
56
+ )}
57
+ {...props}
58
+ />
59
+ )
60
+ }
35
61
 
36
- const AlertDescription = React.forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
37
- ({ className, ...props }, ref) => (
38
- <div ref={ref} className={cn("text-sm [&_p]:leading-relaxed", className)} {...props} />
39
- ),
40
- );
41
- AlertDescription.displayName = "AlertDescription";
62
+ function AlertAction({ className, ...props }: React.ComponentProps<"div">) {
63
+ return (
64
+ <div
65
+ data-slot="alert-action"
66
+ className={cn("absolute top-1.5 right-2", className)}
67
+ {...props}
68
+ />
69
+ )
70
+ }
42
71
 
43
- export { Alert, AlertDescription, AlertTitle };
72
+ export { Alert, AlertTitle, AlertDescription, AlertAction }
@@ -1,50 +1,106 @@
1
- "use client";
2
-
3
- import * as AvatarPrimitive from "@radix-ui/react-avatar";
4
- import * as React from "react";
5
-
6
- import { cn } from "../../utils/cn";
7
-
8
- const Avatar = React.forwardRef<
9
- React.ElementRef<typeof AvatarPrimitive.Root>,
10
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
11
- >(({ className, ...props }, ref) => (
12
- <AvatarPrimitive.Root
13
- ref={ref}
14
- className={cn(
15
- "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
16
- className,
17
- )}
18
- {...props}
19
- />
20
- ));
21
- Avatar.displayName = AvatarPrimitive.Root.displayName;
22
-
23
- const AvatarImage = React.forwardRef<
24
- React.ElementRef<typeof AvatarPrimitive.Image>,
25
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
26
- >(({ className, ...props }, ref) => (
27
- <AvatarPrimitive.Image
28
- ref={ref}
29
- className={cn("aspect-square h-full w-full", className)}
30
- {...props}
31
- />
32
- ));
33
- AvatarImage.displayName = AvatarPrimitive.Image.displayName;
34
-
35
- const AvatarFallback = React.forwardRef<
36
- React.ElementRef<typeof AvatarPrimitive.Fallback>,
37
- React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
38
- >(({ className, ...props }, ref) => (
39
- <AvatarPrimitive.Fallback
40
- ref={ref}
41
- className={cn(
42
- "flex h-full w-full items-center justify-center rounded-full bg-muted",
43
- className,
44
- )}
45
- {...props}
46
- />
47
- ));
48
- AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
49
-
50
- export { Avatar, AvatarFallback, AvatarImage };
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ function Avatar({
9
+ className,
10
+ size = "default",
11
+ ...props
12
+ }: AvatarPrimitive.Root.Props & {
13
+ size?: "default" | "sm" | "lg"
14
+ }) {
15
+ return (
16
+ <AvatarPrimitive.Root
17
+ data-slot="avatar"
18
+ data-size={size}
19
+ className={cn(
20
+ "size-8 rounded-full after:rounded-full data-[size=lg]:size-10 data-[size=sm]:size-6 after:border-border group/avatar relative flex shrink-0 select-none after:absolute after:inset-0 after:border after:mix-blend-darken dark:after:mix-blend-lighten",
21
+ className
22
+ )}
23
+ {...props}
24
+ />
25
+ )
26
+ }
27
+
28
+ function AvatarImage({ className, ...props }: AvatarPrimitive.Image.Props) {
29
+ return (
30
+ <AvatarPrimitive.Image
31
+ data-slot="avatar-image"
32
+ className={cn(
33
+ "rounded-full aspect-square size-full object-cover",
34
+ className
35
+ )}
36
+ {...props}
37
+ />
38
+ )
39
+ }
40
+
41
+ function AvatarFallback({
42
+ className,
43
+ ...props
44
+ }: AvatarPrimitive.Fallback.Props) {
45
+ return (
46
+ <AvatarPrimitive.Fallback
47
+ data-slot="avatar-fallback"
48
+ className={cn(
49
+ "bg-muted text-muted-foreground rounded-full flex size-full items-center justify-center text-sm group-data-[size=sm]/avatar:text-xs",
50
+ className
51
+ )}
52
+ {...props}
53
+ />
54
+ )
55
+ }
56
+
57
+ function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) {
58
+ return (
59
+ <span
60
+ data-slot="avatar-badge"
61
+ className={cn(
62
+ "bg-primary text-primary-foreground ring-background absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-blend-color ring-2 select-none",
63
+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",
64
+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",
65
+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",
66
+ className
67
+ )}
68
+ {...props}
69
+ />
70
+ )
71
+ }
72
+
73
+ function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) {
74
+ return (
75
+ <div
76
+ data-slot="avatar-group"
77
+ className={cn(
78
+ "*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2",
79
+ className
80
+ )}
81
+ {...props}
82
+ />
83
+ )
84
+ }
85
+
86
+ function AvatarGroupCount({
87
+ className,
88
+ ...props
89
+ }: React.ComponentProps<"div">) {
90
+ return (
91
+ <div
92
+ data-slot="avatar-group-count"
93
+ className={cn("bg-muted text-muted-foreground size-8 rounded-full text-xs/relaxed group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3 ring-background relative flex shrink-0 items-center justify-center ring-2", className)}
94
+ {...props}
95
+ />
96
+ )
97
+ }
98
+
99
+ export {
100
+ Avatar,
101
+ AvatarImage,
102
+ AvatarFallback,
103
+ AvatarGroup,
104
+ AvatarGroupCount,
105
+ AvatarBadge,
106
+ }
@@ -1,40 +1,48 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import * as React from "react";
1
+ import { mergeProps } from "@base-ui/react/merge-props"
2
+ import { useRender } from "@base-ui/react/use-render"
3
+ import { cva, type VariantProps } from "class-variance-authority"
3
4
 
4
- import { cn } from "../../utils/cn";
5
+ import { cn } from "@/lib/utils"
5
6
 
6
7
  const badgeVariants = cva(
7
- "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",
8
+ "h-5 gap-1 rounded-full border border-transparent px-2 py-0.5 text-[0.625rem] font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-2.5! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",
8
9
  {
9
10
  variants: {
10
11
  variant: {
11
- default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
12
- secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
13
- destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
14
- outline: "text-foreground",
15
-
16
- blue: "border-transparent bg-sky-500 text-primary-foreground rounded-full",
17
- green: "border-transparent bg-emerald-500 text-primary-foreground rounded-full",
18
- red: "border-transparent bg-red-500 text-primary-foreground rounded-full",
19
- yellow: "border-transparent bg-yellow-500 text-primary-foreground rounded-full",
20
- purple: "border-transparent bg-purple-500 text-primary-foreground rounded-full",
21
- pink: "border-transparent bg-pink-500 text-primary-foreground rounded-full",
22
- gray: "border-transparent bg-gray-500 text-primary-foreground rounded-full",
23
- orange: "border-transparent bg-orange-500 text-primary-foreground rounded-full",
24
- teal: "border-transparent bg-teal-500 text-primary-foreground rounded-full",
25
- lime: "border-transparent bg-lime-500 text-primary-foreground rounded-full",
12
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
13
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
14
+ destructive: "bg-destructive/10 [a]:hover:bg-destructive/20 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive dark:bg-destructive/20",
15
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground bg-input/20 dark:bg-input/30",
16
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
17
+ link: "text-primary underline-offset-4 hover:underline",
26
18
  },
27
19
  },
28
20
  defaultVariants: {
29
21
  variant: "default",
30
22
  },
31
- },
32
- );
33
-
34
- export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {}
23
+ }
24
+ )
35
25
 
36
- function Badge({ className, variant, ...props }: BadgeProps) {
37
- return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
26
+ function Badge({
27
+ className,
28
+ variant = "default",
29
+ render,
30
+ ...props
31
+ }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
32
+ return useRender({
33
+ defaultTagName: "span",
34
+ props: mergeProps<"span">(
35
+ {
36
+ className: cn(badgeVariants({ className, variant })),
37
+ },
38
+ props
39
+ ),
40
+ render,
41
+ state: {
42
+ slot: "badge",
43
+ variant,
44
+ },
45
+ })
38
46
  }
39
47
 
40
- export { Badge, badgeVariants };
48
+ export { Badge, badgeVariants }