@carlonicora/nextjs-jsonapi 1.16.0 → 1.18.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 (202) hide show
  1. package/README.md +1 -1
  2. package/dist/ApiData-DPKNfY-9.d.mts +10 -0
  3. package/dist/ApiData-DPKNfY-9.d.ts +10 -0
  4. package/dist/ApiRequestDataTypeInterface-DIEOFn9s.d.mts +40 -0
  5. package/dist/ApiRequestDataTypeInterface-DIEOFn9s.d.ts +40 -0
  6. package/dist/{ApiResponseInterface-BvWIeLkq.d.ts → ApiResponseInterface-BKyod24U.d.ts} +2 -11
  7. package/dist/{ApiResponseInterface-CAbw0sv7.d.mts → ApiResponseInterface-Dqvu09tz.d.mts} +2 -11
  8. package/dist/{BlockNoteEditor-HFX7Z5BQ.mjs → BlockNoteEditor-6TWTNHNZ.mjs} +7 -6
  9. package/dist/{BlockNoteEditor-HFX7Z5BQ.mjs.map → BlockNoteEditor-6TWTNHNZ.mjs.map} +1 -1
  10. package/dist/{BlockNoteEditor-MBFDWP7X.js → BlockNoteEditor-C3WWGGT6.js} +17 -16
  11. package/dist/BlockNoteEditor-C3WWGGT6.js.map +1 -0
  12. package/dist/JsonApiContext-Bsm_Q2oe.d.mts +41 -0
  13. package/dist/JsonApiContext-Bsm_Q2oe.d.ts +41 -0
  14. package/dist/JsonApiRequest-54ZBO7WQ.js +24 -0
  15. package/dist/{JsonApiRequest-45CLE65I.js.map → JsonApiRequest-54ZBO7WQ.js.map} +1 -1
  16. package/dist/{JsonApiRequest-6IPS3DZJ.mjs → JsonApiRequest-XWQWTFEQ.mjs} +2 -2
  17. package/dist/chunk-3EPNHTMH.js +26 -0
  18. package/dist/chunk-3EPNHTMH.js.map +1 -0
  19. package/dist/{chunk-BCKYJQ3K.mjs → chunk-3VM3WAOV.mjs} +1 -1
  20. package/dist/{chunk-ONB2DAIV.js → chunk-6U6QCSJK.js} +4224 -2775
  21. package/dist/chunk-6U6QCSJK.js.map +1 -0
  22. package/dist/{chunk-R5QSSISB.js → chunk-7DTKRMYW.js} +21 -14
  23. package/dist/chunk-7DTKRMYW.js.map +1 -0
  24. package/dist/{chunk-BCQSE3EU.mjs → chunk-KUFWHMMY.mjs} +8 -8
  25. package/dist/{chunk-POKIJ56Q.mjs → chunk-KX7YG6LY.mjs} +22 -15
  26. package/dist/chunk-KX7YG6LY.mjs.map +1 -0
  27. package/dist/{chunk-GPGJNTHP.js → chunk-LI6CPNJI.js} +1 -1
  28. package/dist/{chunk-GPGJNTHP.js.map → chunk-LI6CPNJI.js.map} +1 -1
  29. package/dist/{chunk-2AZLCF6D.js → chunk-UYY34W7R.js} +28 -28
  30. package/dist/{chunk-2AZLCF6D.js.map → chunk-UYY34W7R.js.map} +1 -1
  31. package/dist/{chunk-5RAUCUAA.mjs → chunk-UZDAPWJG.mjs} +5645 -4196
  32. package/dist/chunk-UZDAPWJG.mjs.map +1 -0
  33. package/dist/chunk-VOXD3ZLY.mjs +26 -0
  34. package/dist/chunk-VOXD3ZLY.mjs.map +1 -0
  35. package/dist/client/index.d.mts +11 -45
  36. package/dist/client/index.d.ts +11 -45
  37. package/dist/client/index.js +9 -7
  38. package/dist/client/index.js.map +1 -1
  39. package/dist/client/index.mjs +11 -9
  40. package/dist/components/index.d.mts +302 -388
  41. package/dist/components/index.d.ts +302 -388
  42. package/dist/components/index.js +31 -6
  43. package/dist/components/index.js.map +1 -1
  44. package/dist/components/index.mjs +40 -15
  45. package/dist/{config-DEaUbBqR.d.ts → config--nwiW74Z.d.ts} +1 -1
  46. package/dist/{config-CWsTwnsK.d.mts → config-BKSQmUWU.d.mts} +1 -1
  47. package/dist/{content.interface-D_4b4RQt.d.ts → content.interface-4VICFRA0.d.ts} +2 -1
  48. package/dist/{content.interface-Dk4UZcJM.d.mts → content.interface-CFc97-Cj.d.mts} +2 -1
  49. package/dist/contexts/index.d.mts +3 -2
  50. package/dist/contexts/index.d.ts +3 -2
  51. package/dist/contexts/index.js +7 -6
  52. package/dist/contexts/index.js.map +1 -1
  53. package/dist/contexts/index.mjs +6 -5
  54. package/dist/core/index.d.mts +11 -8
  55. package/dist/core/index.d.ts +11 -8
  56. package/dist/core/index.js +4 -4
  57. package/dist/core/index.js.map +1 -1
  58. package/dist/core/index.mjs +3 -3
  59. package/dist/index.d.mts +15 -11
  60. package/dist/index.d.ts +15 -11
  61. package/dist/index.js +5 -5
  62. package/dist/index.js.map +1 -1
  63. package/dist/index.mjs +6 -6
  64. package/dist/{notification.interface-BllkURRm.d.ts → notification.interface-BGaPiCUM.d.mts} +2 -40
  65. package/dist/{notification.interface-BllkURRm.d.mts → notification.interface-CqwaOIgM.d.ts} +2 -40
  66. package/dist/{s3.service-BEfGqho0.d.ts → s3.service-BYs88XEE.d.ts} +3 -2
  67. package/dist/{s3.service-DIQRYe93.d.mts → s3.service-C0BjOdvn.d.mts} +3 -2
  68. package/dist/scripts/generate-web-module/templates/components/editor.template.d.ts.map +1 -1
  69. package/dist/scripts/generate-web-module/templates/components/editor.template.js +20 -6
  70. package/dist/scripts/generate-web-module/templates/components/editor.template.js.map +1 -1
  71. package/dist/scripts/generate-web-module/templates/components/selector.template.d.ts.map +1 -1
  72. package/dist/scripts/generate-web-module/templates/components/selector.template.js +45 -48
  73. package/dist/scripts/generate-web-module/templates/components/selector.template.js.map +1 -1
  74. package/dist/server/index.d.mts +6 -4
  75. package/dist/server/index.d.ts +6 -4
  76. package/dist/server/index.js +13 -13
  77. package/dist/server/index.js.map +1 -1
  78. package/dist/server/index.mjs +3 -3
  79. package/dist/{stripe-subscription.interface-C63L6hVg.d.mts → stripe-subscription.interface-B-TM40Io.d.ts} +1 -1
  80. package/dist/{stripe-subscription.interface-CUvNDvw5.d.ts → stripe-subscription.interface-DDxnpj0F.d.mts} +1 -1
  81. package/dist/testing/index.d.mts +338 -0
  82. package/dist/testing/index.d.ts +338 -0
  83. package/dist/testing/index.js +323 -0
  84. package/dist/testing/index.js.map +1 -0
  85. package/dist/testing/index.mjs +323 -0
  86. package/dist/testing/index.mjs.map +1 -0
  87. package/dist/{useSocket-BpenBR2z.d.mts → useSocket-BNj9PrRw.d.mts} +1 -1
  88. package/dist/{useSocket-D-QYA0Sr.d.ts → useSocket-Dwt8cz1x.d.ts} +1 -1
  89. package/package.json +26 -27
  90. package/scripts/generate-web-module/templates/components/editor.template.ts +20 -6
  91. package/scripts/generate-web-module/templates/components/selector.template.ts +45 -48
  92. package/src/client/hooks/__tests__/useJsonApiGet.test.tsx +229 -0
  93. package/src/client/hooks/__tests__/useJsonApiMutation.test.tsx +348 -0
  94. package/src/client/hooks/__tests__/useRehydration.test.ts +188 -0
  95. package/src/components/forms/CommonDeleter.tsx +2 -2
  96. package/src/components/forms/CommonEditorTrigger.tsx +3 -3
  97. package/src/components/forms/DatePickerPopover.tsx +3 -1
  98. package/src/components/forms/DateRangeSelector.tsx +1 -1
  99. package/src/components/forms/FormCheckbox.tsx +1 -1
  100. package/src/components/forms/FormDate.tsx +3 -1
  101. package/src/components/forms/FormDateTime.tsx +5 -3
  102. package/src/components/forms/FormSelect.tsx +1 -1
  103. package/src/components/forms/FormSlider.tsx +4 -1
  104. package/src/components/forms/__tests__/FormCheckbox.test.tsx +242 -0
  105. package/src/components/forms/__tests__/FormDate.test.tsx +216 -0
  106. package/src/components/forms/__tests__/FormInput.test.tsx +292 -0
  107. package/src/components/forms/__tests__/FormSelect.test.tsx +177 -0
  108. package/src/components/navigations/RecentPagesNavigator.tsx +2 -2
  109. package/src/components/tables/ContentListTable.tsx +3 -3
  110. package/src/components/tables/__tests__/ContentListTable.test.tsx +411 -0
  111. package/src/core/endpoint/__tests__/EndpointCreator.test.ts +168 -0
  112. package/src/core/factories/__tests__/JsonApiDataFactory.test.ts +109 -0
  113. package/src/core/factories/__tests__/RehydrationFactory.test.ts +151 -0
  114. package/src/core/registry/__tests__/DataClassRegistry.test.ts +136 -0
  115. package/src/core/registry/__tests__/ModuleRegistrar.test.ts +159 -0
  116. package/src/features/auth/components/details/LandingComponent.tsx +14 -12
  117. package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +2 -2
  118. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +2 -2
  119. package/src/features/company/components/forms/CompanyDeleter.tsx +1 -1
  120. package/src/features/content/components/lists/ContentsList.tsx +1 -1
  121. package/src/features/notification/components/lists/NotificationsList.tsx +1 -1
  122. package/src/features/notification/components/modals/NotificationModal.tsx +2 -2
  123. package/src/features/role/components/forms/FormRoles.tsx +1 -1
  124. package/src/features/user/components/forms/UserEditor.tsx +2 -2
  125. package/src/features/user/components/forms/UserReactivator.tsx +1 -1
  126. package/src/features/user/components/forms/UserResentInvitationEmail.tsx +2 -2
  127. package/src/features/user/components/widgets/UserAvatar.tsx +37 -31
  128. package/src/features/user/components/widgets/UserSearchPopover.tsx +1 -1
  129. package/src/hooks/__tests__/useDataListRetriever.test.ts +321 -0
  130. package/src/hooks/__tests__/useDebounce.test.ts +170 -0
  131. package/src/hooks/use-mobile.ts +1 -0
  132. package/src/index.ts +4 -1
  133. package/src/lib/utils.ts +2 -0
  134. package/src/login/config.ts +27 -0
  135. package/src/login/index.ts +2 -0
  136. package/src/shadcnui/custom/multi-select.tsx +10 -21
  137. package/src/shadcnui/ui/accordion.tsx +64 -42
  138. package/src/shadcnui/ui/alert-dialog.tsx +142 -108
  139. package/src/shadcnui/ui/alert.tsx +64 -35
  140. package/src/shadcnui/ui/avatar.tsx +106 -50
  141. package/src/shadcnui/ui/badge.tsx +34 -26
  142. package/src/shadcnui/ui/breadcrumb.tsx +103 -92
  143. package/src/shadcnui/ui/button.tsx +30 -30
  144. package/src/shadcnui/ui/calendar.tsx +192 -50
  145. package/src/shadcnui/ui/card.tsx +94 -43
  146. package/src/shadcnui/ui/carousel.tsx +220 -201
  147. package/src/shadcnui/ui/chart.tsx +244 -190
  148. package/src/shadcnui/ui/checkbox.tsx +25 -25
  149. package/src/shadcnui/ui/collapsible.tsx +10 -4
  150. package/src/shadcnui/ui/combobox.tsx +292 -0
  151. package/src/shadcnui/ui/command.tsx +158 -126
  152. package/src/shadcnui/ui/context-menu.tsx +242 -164
  153. package/src/shadcnui/ui/dialog.tsx +125 -70
  154. package/src/shadcnui/ui/drawer.tsx +106 -70
  155. package/src/shadcnui/ui/dropdown-menu.tsx +231 -182
  156. package/src/shadcnui/ui/field.tsx +227 -0
  157. package/src/shadcnui/ui/hover-card.tsx +45 -23
  158. package/src/shadcnui/ui/input-group.tsx +149 -0
  159. package/src/shadcnui/ui/input-otp.tsx +19 -9
  160. package/src/shadcnui/ui/input.tsx +4 -5
  161. package/src/shadcnui/ui/label.tsx +16 -22
  162. package/src/shadcnui/ui/navigation-menu.tsx +44 -49
  163. package/src/shadcnui/ui/popover.tsx +81 -24
  164. package/src/shadcnui/ui/progress.tsx +77 -22
  165. package/src/shadcnui/ui/radio-group.tsx +30 -28
  166. package/src/shadcnui/ui/resizable.tsx +23 -17
  167. package/src/shadcnui/ui/scroll-area.tsx +50 -35
  168. package/src/shadcnui/ui/select.tsx +163 -135
  169. package/src/shadcnui/ui/separator.tsx +5 -8
  170. package/src/shadcnui/ui/sheet.tsx +40 -50
  171. package/src/shadcnui/ui/sidebar.tsx +317 -271
  172. package/src/shadcnui/ui/skeleton.tsx +2 -2
  173. package/src/shadcnui/ui/slider.tsx +60 -21
  174. package/src/shadcnui/ui/sonner.tsx +25 -1
  175. package/src/shadcnui/ui/switch.tsx +31 -24
  176. package/src/shadcnui/ui/table.tsx +84 -103
  177. package/src/shadcnui/ui/tabs.tsx +82 -55
  178. package/src/shadcnui/ui/textarea.tsx +15 -21
  179. package/src/shadcnui/ui/toggle.tsx +26 -21
  180. package/src/shadcnui/ui/tooltip.tsx +33 -24
  181. package/src/testing/factories/createMockApiData.ts +143 -0
  182. package/src/testing/factories/createMockModule.ts +32 -0
  183. package/src/testing/factories/createMockResponse.ts +88 -0
  184. package/src/testing/factories/createMockService.ts +76 -0
  185. package/src/testing/index.ts +56 -0
  186. package/src/testing/matchers/jsonApiMatchers.ts +172 -0
  187. package/src/testing/providers/MockJsonApiProvider.tsx +58 -0
  188. package/src/testing/utils/renderWithProviders.tsx +76 -0
  189. package/src/utils/__tests__/date-formatter.test.ts +161 -0
  190. package/src/utils/__tests__/exists.test.ts +100 -0
  191. package/src/utils/cn.test.ts +44 -0
  192. package/dist/BlockNoteEditor-MBFDWP7X.js.map +0 -1
  193. package/dist/JsonApiRequest-45CLE65I.js +0 -24
  194. package/dist/chunk-5RAUCUAA.mjs.map +0 -1
  195. package/dist/chunk-ONB2DAIV.js.map +0 -1
  196. package/dist/chunk-POKIJ56Q.mjs.map +0 -1
  197. package/dist/chunk-R5QSSISB.js.map +0 -1
  198. package/src/discord/config.ts +0 -15
  199. package/src/discord/index.ts +0 -1
  200. /package/dist/{JsonApiRequest-6IPS3DZJ.mjs.map → JsonApiRequest-XWQWTFEQ.mjs.map} +0 -0
  201. /package/dist/{chunk-BCKYJQ3K.mjs.map → chunk-3VM3WAOV.mjs.map} +0 -0
  202. /package/dist/{chunk-BCQSE3EU.mjs.map → chunk-KUFWHMMY.mjs.map} +0 -0
@@ -1,10 +1,10 @@
1
- import { cn } from "../../utils/cn"
1
+ import { cn } from "@/lib/utils"
2
2
 
3
3
  function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
4
4
  return (
5
5
  <div
6
6
  data-slot="skeleton"
7
- className={cn("bg-accent animate-pulse rounded-md", className)}
7
+ className={cn("bg-muted rounded-md animate-pulse", className)}
8
8
  {...props}
9
9
  />
10
10
  )
@@ -1,25 +1,64 @@
1
- "use client";
1
+ "use client"
2
2
 
3
- import * as SliderPrimitive from "@radix-ui/react-slider";
4
- import * as React from "react";
3
+ import * as React from "react"
4
+ import { Slider as SliderPrimitive } from "@base-ui/react/slider"
5
5
 
6
- import { cn } from "../../utils/cn";
6
+ import { cn } from "@/lib/utils"
7
7
 
8
- const Slider = React.forwardRef<
9
- React.ElementRef<typeof SliderPrimitive.Root>,
10
- React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root>
11
- >(({ className, ...props }, ref) => (
12
- <SliderPrimitive.Root
13
- ref={ref}
14
- className={cn("relative flex w-full touch-none select-none items-center", className)}
15
- {...props}
16
- >
17
- <SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20">
18
- <SliderPrimitive.Range className="absolute h-full bg-primary" />
19
- </SliderPrimitive.Track>
20
- <SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" />
21
- </SliderPrimitive.Root>
22
- ));
23
- Slider.displayName = SliderPrimitive.Root.displayName;
8
+ function Slider({
9
+ className,
10
+ defaultValue,
11
+ value,
12
+ min = 0,
13
+ max = 100,
14
+ ...props
15
+ }: SliderPrimitive.Root.Props) {
16
+ const _values = React.useMemo(
17
+ () =>
18
+ Array.isArray(value)
19
+ ? value
20
+ : Array.isArray(defaultValue)
21
+ ? defaultValue
22
+ : [min, max],
23
+ [value, defaultValue, min, max]
24
+ )
24
25
 
25
- export { Slider };
26
+ return (
27
+ <SliderPrimitive.Root
28
+ className="data-horizontal:w-full data-vertical:h-full"
29
+ data-slot="slider"
30
+ defaultValue={defaultValue}
31
+ value={value}
32
+ min={min}
33
+ max={max}
34
+ thumbAlignment="edge"
35
+ {...props}
36
+ >
37
+ <SliderPrimitive.Control
38
+ className={cn(
39
+ "data-vertical:min-h-40 relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:w-auto data-vertical:flex-col",
40
+ className
41
+ )}
42
+ >
43
+ <SliderPrimitive.Track
44
+ data-slot="slider-track"
45
+ className="bg-muted rounded-md data-horizontal:h-3 data-horizontal:w-full data-vertical:h-full data-vertical:w-3 relative overflow-hidden select-none"
46
+ >
47
+ <SliderPrimitive.Indicator
48
+ data-slot="slider-range"
49
+ className="bg-primary select-none data-horizontal:h-full data-vertical:w-full"
50
+ />
51
+ </SliderPrimitive.Track>
52
+ {Array.from({ length: _values.length }, (_, index) => (
53
+ <SliderPrimitive.Thumb
54
+ data-slot="slider-thumb"
55
+ key={index}
56
+ className="border-primary ring-ring/30 size-4 rounded-md border bg-white shadow-sm transition-colors hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden block shrink-0 select-none disabled:pointer-events-none disabled:opacity-50"
57
+ />
58
+ ))}
59
+ </SliderPrimitive.Control>
60
+ </SliderPrimitive.Root>
61
+ )
62
+ }
63
+
64
+ export { Slider }
@@ -1,7 +1,8 @@
1
1
  "use client"
2
2
 
3
3
  import { useTheme } from "next-themes"
4
- import { Toaster as Sonner, ToasterProps } from "sonner"
4
+ import { Toaster as Sonner, type ToasterProps } from "sonner"
5
+ import { CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon, Loader2Icon } from "lucide-react"
5
6
 
6
7
  const Toaster = ({ ...props }: ToasterProps) => {
7
8
  const { theme = "system" } = useTheme()
@@ -10,13 +11,36 @@ const Toaster = ({ ...props }: ToasterProps) => {
10
11
  <Sonner
11
12
  theme={theme as ToasterProps["theme"]}
12
13
  className="toaster group"
14
+ icons={{
15
+ success: (
16
+ <CircleCheckIcon className="size-4" />
17
+ ),
18
+ info: (
19
+ <InfoIcon className="size-4" />
20
+ ),
21
+ warning: (
22
+ <TriangleAlertIcon className="size-4" />
23
+ ),
24
+ error: (
25
+ <OctagonXIcon className="size-4" />
26
+ ),
27
+ loading: (
28
+ <Loader2Icon className="size-4 animate-spin" />
29
+ ),
30
+ }}
13
31
  style={
14
32
  {
15
33
  "--normal-bg": "var(--popover)",
16
34
  "--normal-text": "var(--popover-foreground)",
17
35
  "--normal-border": "var(--border)",
36
+ "--border-radius": "var(--radius)",
18
37
  } as React.CSSProperties
19
38
  }
39
+ toastOptions={{
40
+ classNames: {
41
+ toast: "cn-toast",
42
+ },
43
+ }}
20
44
  {...props}
21
45
  />
22
46
  )
@@ -1,31 +1,38 @@
1
- "use client";
1
+ "use client"
2
2
 
3
- import * as SwitchPrimitives from "@radix-ui/react-switch";
4
- import * as React from "react";
3
+ import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
5
4
 
6
- import { cn } from "../../utils/cn";
5
+ import { cn } from "@/lib/utils"
7
6
 
8
- const Switch = React.forwardRef<
9
- React.ElementRef<typeof SwitchPrimitives.Root>,
10
- React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
11
- >(({ className, children, ...props }, ref) => (
12
- <SwitchPrimitives.Root
13
- className={cn(
14
- "bg-accent focus-visible:ring-ring focus-visible:ring-offset-background data-[state=checked]:bg-primary data-[state=unchecked]:bg-accent peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
15
- className,
16
- )}
17
- {...props}
18
- ref={ref}
19
- >
20
- <SwitchPrimitives.Thumb
7
+ function Switch({
8
+ className,
9
+ size = "default",
10
+ children,
11
+ ...props
12
+ }: SwitchPrimitive.Root.Props & {
13
+ size?: "sm" | "default"
14
+ }) {
15
+ return (
16
+ <SwitchPrimitive.Root
17
+ data-slot="switch"
18
+ data-size={size}
21
19
  className={cn(
22
- "text-title pointer-events-none block flex h-5 w-5 items-center justify-center rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
20
+ "data-checked:bg-primary data-unchecked:bg-input focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 dark:data-unchecked:bg-input/80 shrink-0 rounded-full border border-transparent focus-visible:ring-[2px] aria-invalid:ring-[2px] data-[size=default]:h-[16.6px] data-[size=default]:w-[28px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] peer group/switch relative inline-flex items-center transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 data-disabled:cursor-not-allowed data-disabled:opacity-50",
21
+ className
23
22
  )}
23
+ {...props}
24
24
  >
25
- {children}
26
- </SwitchPrimitives.Thumb>
27
- </SwitchPrimitives.Root>
28
- ));
29
- Switch.displayName = SwitchPrimitives.Root.displayName;
25
+ <SwitchPrimitive.Thumb
26
+ data-slot="switch-thumb"
27
+ className={cn(
28
+ "bg-background dark:data-unchecked:bg-foreground dark:data-checked:bg-primary-foreground rounded-full group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 pointer-events-none block ring-0 transition-transform",
29
+ children && "flex items-center justify-center"
30
+ )}
31
+ >
32
+ {children}
33
+ </SwitchPrimitive.Thumb>
34
+ </SwitchPrimitive.Root>
35
+ )
36
+ }
30
37
 
31
- export { Switch };
38
+ export { Switch }
@@ -1,120 +1,101 @@
1
- import * as React from "react";
1
+ "use client"
2
2
 
3
- import { cn } from "../../utils/cn";
3
+ import * as React from "react"
4
4
 
5
- const Table = React.forwardRef<
6
- HTMLTableElement,
7
- React.HTMLAttributes<HTMLTableElement>
8
- >(({ className, ...props }, ref) => (
9
- <div className="relative w-full overflow-auto">
10
- <table
11
- ref={ref}
12
- className={cn("w-full caption-bottom text-sm", className)}
5
+ import { cn } from "@/lib/utils"
6
+
7
+ function Table({ className, ...props }: React.ComponentProps<"table">) {
8
+ return (
9
+ <div data-slot="table-container" className="relative w-full overflow-x-auto">
10
+ <table
11
+ data-slot="table"
12
+ className={cn("w-full caption-bottom text-xs", className)}
13
+ {...props}
14
+ />
15
+ </div>
16
+ )
17
+ }
18
+
19
+ function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
20
+ return (
21
+ <thead
22
+ data-slot="table-header"
23
+ className={cn("[&_tr]:border-b", className)}
13
24
  {...props}
14
25
  />
15
- </div>
16
- ));
17
- Table.displayName = "Table";
18
-
19
- const TableHeader = React.forwardRef<
20
- HTMLTableSectionElement,
21
- React.HTMLAttributes<HTMLTableSectionElement>
22
- >(({ className, ...props }, ref) => (
23
- <thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
24
- ));
25
- TableHeader.displayName = "TableHeader";
26
+ )
27
+ }
26
28
 
27
- const TableBody = React.forwardRef<
28
- HTMLTableSectionElement,
29
- React.HTMLAttributes<HTMLTableSectionElement>
30
- >(({ className, ...props }, ref) => (
31
- <tbody
32
- ref={ref}
33
- className={cn("[&_tr:last-child]:border-0", className)}
34
- {...props}
35
- />
36
- ));
37
- TableBody.displayName = "TableBody";
29
+ function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
30
+ return (
31
+ <tbody
32
+ data-slot="table-body"
33
+ className={cn("[&_tr:last-child]:border-0", className)}
34
+ {...props}
35
+ />
36
+ )
37
+ }
38
38
 
39
- const TableFooter = React.forwardRef<
40
- HTMLTableSectionElement,
41
- React.HTMLAttributes<HTMLTableSectionElement>
42
- >(({ className, ...props }, ref) => (
43
- <tfoot
44
- ref={ref}
45
- className={cn(
46
- "border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
47
- className,
48
- )}
49
- {...props}
50
- />
51
- ));
52
- TableFooter.displayName = "TableFooter";
39
+ function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
40
+ return (
41
+ <tfoot
42
+ data-slot="table-footer"
43
+ className={cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className)}
44
+ {...props}
45
+ />
46
+ )
47
+ }
53
48
 
54
- const TableRow = React.forwardRef<
55
- HTMLTableRowElement,
56
- React.HTMLAttributes<HTMLTableRowElement>
57
- >(({ className, ...props }, ref) => (
58
- <tr
59
- ref={ref}
60
- className={cn(
61
- "border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
62
- className,
63
- )}
64
- {...props}
65
- />
66
- ));
67
- TableRow.displayName = "TableRow";
49
+ function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
50
+ return (
51
+ <tr
52
+ data-slot="table-row"
53
+ className={cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className)}
54
+ {...props}
55
+ />
56
+ )
57
+ }
68
58
 
69
- const TableHead = React.forwardRef<
70
- HTMLTableCellElement,
71
- React.ThHTMLAttributes<HTMLTableCellElement>
72
- >(({ className, ...props }, ref) => (
73
- <th
74
- ref={ref}
75
- className={cn(
76
- "h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
77
- className,
78
- )}
79
- {...props}
80
- />
81
- ));
82
- TableHead.displayName = "TableHead";
59
+ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
60
+ return (
61
+ <th
62
+ data-slot="table-head"
63
+ className={cn("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0", className)}
64
+ {...props}
65
+ />
66
+ )
67
+ }
83
68
 
84
- const TableCell = React.forwardRef<
85
- HTMLTableCellElement,
86
- React.TdHTMLAttributes<HTMLTableCellElement>
87
- >(({ className, ...props }, ref) => (
88
- <td
89
- ref={ref}
90
- className={cn(
91
- "p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
92
- className,
93
- )}
94
- {...props}
95
- />
96
- ));
97
- TableCell.displayName = "TableCell";
69
+ function TableCell({ className, ...props }: React.ComponentProps<"td">) {
70
+ return (
71
+ <td
72
+ data-slot="table-cell"
73
+ className={cn("p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0", className)}
74
+ {...props}
75
+ />
76
+ )
77
+ }
98
78
 
99
- const TableCaption = React.forwardRef<
100
- HTMLTableCaptionElement,
101
- React.HTMLAttributes<HTMLTableCaptionElement>
102
- >(({ className, ...props }, ref) => (
103
- <caption
104
- ref={ref}
105
- className={cn("mt-4 text-sm text-muted-foreground", className)}
106
- {...props}
107
- />
108
- ));
109
- TableCaption.displayName = "TableCaption";
79
+ function TableCaption({
80
+ className,
81
+ ...props
82
+ }: React.ComponentProps<"caption">) {
83
+ return (
84
+ <caption
85
+ data-slot="table-caption"
86
+ className={cn("text-muted-foreground mt-4 text-xs", className)}
87
+ {...props}
88
+ />
89
+ )
90
+ }
110
91
 
111
92
  export {
112
93
  Table,
94
+ TableHeader,
113
95
  TableBody,
114
- TableCaption,
115
- TableCell,
116
96
  TableFooter,
117
97
  TableHead,
118
- TableHeader,
119
98
  TableRow,
120
- };
99
+ TableCell,
100
+ TableCaption,
101
+ }
@@ -1,55 +1,82 @@
1
- "use client";
2
-
3
- import * as TabsPrimitive from "@radix-ui/react-tabs";
4
- import * as React from "react";
5
-
6
- import { cn } from "../../utils/cn";
7
-
8
- const Tabs = TabsPrimitive.Root;
9
-
10
- const TabsList = React.forwardRef<
11
- React.ElementRef<typeof TabsPrimitive.List>,
12
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
13
- >(({ className, ...props }, ref) => (
14
- <TabsPrimitive.List
15
- ref={ref}
16
- className={cn(
17
- "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
18
- className,
19
- )}
20
- {...props}
21
- />
22
- ));
23
- TabsList.displayName = TabsPrimitive.List.displayName;
24
-
25
- const TabsTrigger = React.forwardRef<
26
- React.ElementRef<typeof TabsPrimitive.Trigger>,
27
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
28
- >(({ className, ...props }, ref) => (
29
- <TabsPrimitive.Trigger
30
- ref={ref}
31
- className={cn(
32
- "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
33
- className,
34
- )}
35
- {...props}
36
- />
37
- ));
38
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
39
-
40
- const TabsContent = React.forwardRef<
41
- React.ElementRef<typeof TabsPrimitive.Content>,
42
- React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
43
- >(({ className, ...props }, ref) => (
44
- <TabsPrimitive.Content
45
- ref={ref}
46
- className={cn(
47
- "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
48
- className,
49
- )}
50
- {...props}
51
- />
52
- ));
53
- TabsContent.displayName = TabsPrimitive.Content.displayName;
54
-
55
- export { Tabs, TabsContent, TabsList, TabsTrigger };
1
+ "use client"
2
+
3
+ import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
4
+ import { cva, type VariantProps } from "class-variance-authority"
5
+
6
+ import { cn } from "@/lib/utils"
7
+
8
+ function Tabs({
9
+ className,
10
+ orientation = "horizontal",
11
+ ...props
12
+ }: TabsPrimitive.Root.Props) {
13
+ return (
14
+ <TabsPrimitive.Root
15
+ data-slot="tabs"
16
+ data-orientation={orientation}
17
+ className={cn(
18
+ "gap-2 group/tabs flex data-[orientation=horizontal]:flex-col",
19
+ className
20
+ )}
21
+ {...props}
22
+ />
23
+ )
24
+ }
25
+
26
+ const tabsListVariants = cva(
27
+ "rounded-lg p-[3px] group-data-horizontal/tabs:h-8 data-[variant=line]:rounded-none group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col",
28
+ {
29
+ variants: {
30
+ variant: {
31
+ default: "bg-muted",
32
+ line: "gap-1 bg-transparent",
33
+ },
34
+ },
35
+ defaultVariants: {
36
+ variant: "default",
37
+ },
38
+ }
39
+ )
40
+
41
+ function TabsList({
42
+ className,
43
+ variant = "default",
44
+ ...props
45
+ }: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
46
+ return (
47
+ <TabsPrimitive.List
48
+ data-slot="tabs-list"
49
+ data-variant={variant}
50
+ className={cn(tabsListVariants({ variant }), className)}
51
+ {...props}
52
+ />
53
+ )
54
+ }
55
+
56
+ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
57
+ return (
58
+ <TabsPrimitive.Tab
59
+ data-slot="tabs-trigger"
60
+ className={cn(
61
+ "gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-xs font-medium group-data-vertical/tabs:py-[calc(--spacing(1.25))] [&_svg:not([class*='size-'])]:size-3.5 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring text-foreground/60 hover:text-foreground dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
62
+ "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
63
+ "data-active:bg-background dark:data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 data-active:text-foreground",
64
+ "after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
65
+ className
66
+ )}
67
+ {...props}
68
+ />
69
+ )
70
+ }
71
+
72
+ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
73
+ return (
74
+ <TabsPrimitive.Panel
75
+ data-slot="tabs-content"
76
+ className={cn("text-xs/relaxed flex-1 outline-none", className)}
77
+ {...props}
78
+ />
79
+ )
80
+ }
81
+
82
+ export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }
@@ -1,24 +1,18 @@
1
- import * as React from "react";
1
+ import * as React from "react"
2
2
 
3
- import { cn } from "../../utils/cn";
3
+ import { cn } from "@/lib/utils"
4
4
 
5
- export interface TextareaProps
6
- extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
5
+ function Textarea({ className, ...props }: React.ComponentProps<"textarea">) {
6
+ return (
7
+ <textarea
8
+ data-slot="textarea"
9
+ className={cn(
10
+ "border-input bg-input/20 dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 resize-none rounded-md border px-2 py-2 text-sm transition-colors focus-visible:ring-[2px] aria-invalid:ring-[2px] md:text-xs/relaxed placeholder:text-muted-foreground flex field-sizing-content min-h-16 w-full outline-none disabled:cursor-not-allowed disabled:opacity-50",
11
+ className
12
+ )}
13
+ {...props}
14
+ />
15
+ )
16
+ }
7
17
 
8
- const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
9
- ({ className, ...props }, ref) => {
10
- return (
11
- <textarea
12
- className={cn(
13
- "flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
14
- className,
15
- )}
16
- ref={ref}
17
- {...props}
18
- />
19
- );
20
- },
21
- );
22
- Textarea.displayName = "Textarea";
23
-
24
- export { Textarea };
18
+ export { Textarea }