@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,73 +1,215 @@
1
- "use client";
1
+ "use client"
2
2
 
3
- import * as React from "react";
4
- import { DayPicker, getDefaultClassNames } from "react-day-picker";
3
+ import * as React from "react"
4
+ import {
5
+ DayPicker,
6
+ getDefaultClassNames,
7
+ type DayButton,
8
+ } from "react-day-picker"
5
9
 
6
- import { cn } from "../../utils/cn";
7
- import { buttonVariants } from "./button";
8
- // import "react-day-picker/style.css";
10
+ import { cn } from "@/lib/utils"
11
+ import { Button, buttonVariants } from "@/components/ui/button"
12
+ import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
13
+
14
+ function Calendar({
15
+ className,
16
+ classNames,
17
+ showOutsideDays = true,
18
+ captionLayout = "label",
19
+ buttonVariant = "ghost",
20
+ formatters,
21
+ components,
22
+ ...props
23
+ }: React.ComponentProps<typeof DayPicker> & {
24
+ buttonVariant?: React.ComponentProps<typeof Button>["variant"]
25
+ }) {
26
+ const defaultClassNames = getDefaultClassNames()
9
27
 
10
- function Calendar({ className, classNames, showOutsideDays = true, ...props }: React.ComponentProps<typeof DayPicker>) {
11
- const defaultClassNames = getDefaultClassNames();
12
28
  return (
13
29
  <DayPicker
14
30
  showOutsideDays={showOutsideDays}
15
- className={cn("p-3", className)}
31
+ className={cn(
32
+ "p-3 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(6)] bg-background group/calendar [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
33
+ String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
34
+ String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
35
+ className
36
+ )}
37
+ captionLayout={captionLayout}
38
+ formatters={{
39
+ formatMonthDropdown: (date) =>
40
+ date.toLocaleString("default", { month: "short" }),
41
+ ...formatters,
42
+ }}
16
43
  classNames={{
17
- months: `relative flex ${defaultClassNames.month}`,
18
- month_caption: `relative mx-10 flex h-7 items-center justify-center ${defaultClassNames.month_caption}`,
19
- weekdays: cn("flex flex-row", classNames?.weekdays),
20
- weekday: cn("w-8 text-sm font-normal text-muted-foreground", classNames?.weekday),
21
- month: cn("w-full", classNames?.month),
22
-
23
- caption_label: cn("truncate text-sm font-medium", classNames?.caption_label),
24
- button_next: cn(
25
- buttonVariants({ variant: "outline" }),
26
- "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute right-1 [&_svg]:fill-foreground",
27
- classNames?.button_next,
44
+ root: cn("w-fit", defaultClassNames.root),
45
+ months: cn(
46
+ "flex gap-4 flex-col md:flex-row relative",
47
+ defaultClassNames.months
48
+ ),
49
+ month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
50
+ nav: cn(
51
+ "flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
52
+ defaultClassNames.nav
28
53
  ),
29
54
  button_previous: cn(
30
- buttonVariants({ variant: "outline" }),
31
- "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100 absolute left-1 [&_svg]:fill-foreground",
32
- classNames?.button_previous,
33
- ),
34
- nav: cn("flex items-start", classNames?.nav),
35
- month_grid: cn("mx-auto mt-4", classNames?.month_grid),
36
- week: cn("mt-2 flex w-max items-start", classNames?.week),
37
- day: cn("flex size-8 flex-1 items-center justify-center p-0 text-sm", classNames?.day),
38
- day_button: cn(
39
- "size-8 rounded-md p-0 font-normal transition-none aria-selected:opacity-100",
40
- classNames?.day_button,
55
+ buttonVariants({ variant: buttonVariant }),
56
+ "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
57
+ defaultClassNames.button_previous
41
58
  ),
42
- range_start: cn(
43
- "bg-accent [&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground day-range-start rounded-s-md",
44
- classNames?.range_start,
59
+ button_next: cn(
60
+ buttonVariants({ variant: buttonVariant }),
61
+ "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
62
+ defaultClassNames.button_next
63
+ ),
64
+ month_caption: cn(
65
+ "flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
66
+ defaultClassNames.month_caption
67
+ ),
68
+ dropdowns: cn(
69
+ "w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
70
+ defaultClassNames.dropdowns
71
+ ),
72
+ dropdown_root: cn(
73
+ "relative cn-calendar-dropdown-root rounded-(--cell-radius)",
74
+ defaultClassNames.dropdown_root
75
+ ),
76
+ dropdown: cn(
77
+ "absolute bg-popover inset-0 opacity-0",
78
+ defaultClassNames.dropdown
79
+ ),
80
+ caption_label: cn(
81
+ "select-none font-medium",
82
+ captionLayout === "label"
83
+ ? "text-sm"
84
+ : "cn-calendar-caption-label rounded-(--cell-radius) flex items-center gap-1 text-sm [&>svg]:text-muted-foreground [&>svg]:size-3.5",
85
+ defaultClassNames.caption_label
86
+ ),
87
+ table: "w-full border-collapse",
88
+ weekdays: cn("flex", defaultClassNames.weekdays),
89
+ weekday: cn(
90
+ "text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-[0.8rem] select-none",
91
+ defaultClassNames.weekday
92
+ ),
93
+ week: cn("flex w-full mt-2", defaultClassNames.week),
94
+ week_number_header: cn(
95
+ "select-none w-(--cell-size)",
96
+ defaultClassNames.week_number_header
45
97
  ),
46
- range_middle: cn(
47
- "bg-accent !text-foreground [&>button]:bg-transparent [&>button]:!text-foreground [&>button]:hover:bg-transparent [&>button]:hover:!text-foreground",
48
- classNames?.range_middle,
98
+ week_number: cn(
99
+ "text-[0.8rem] select-none text-muted-foreground",
100
+ defaultClassNames.week_number
49
101
  ),
102
+ day: cn(
103
+ "relative w-full rounded-(--cell-radius) h-full p-0 text-center [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius) group/day aspect-square select-none",
104
+ props.showWeekNumber
105
+ ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
106
+ : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
107
+ defaultClassNames.day
108
+ ),
109
+ range_start: cn(
110
+ "rounded-l-(--cell-radius) bg-muted elative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:right-0 -z-0 isolate",
111
+ defaultClassNames.range_start
112
+ ),
113
+ range_middle: cn("rounded-none", defaultClassNames.range_middle),
50
114
  range_end: cn(
51
- "bg-accent [&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground day-range-end rounded-e-md",
52
- classNames?.range_end,
115
+ "rounded-r-(--cell-radius) bg-muted relative after:bg-muted after:absolute after:inset-y-0 after:w-4 after:left-0 -z-0 isolate",
116
+ defaultClassNames.range_end
53
117
  ),
54
- selected: cn(
55
- "[&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground",
56
- classNames?.selected,
118
+ today: cn(
119
+ "bg-muted text-foreground rounded-(--cell-radius) data-[selected=true]:rounded-none",
120
+ defaultClassNames.today
57
121
  ),
58
- today: cn("[&>button]:bg-accent [&>button]:text-accent-foreground", classNames?.today),
59
122
  outside: cn(
60
- "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
61
- classNames?.outside,
123
+ "text-muted-foreground aria-selected:text-muted-foreground",
124
+ defaultClassNames.outside
125
+ ),
126
+ disabled: cn(
127
+ "text-muted-foreground opacity-50",
128
+ defaultClassNames.disabled
62
129
  ),
63
- disabled: cn("text-muted-foreground opacity-50", classNames?.disabled),
64
- hidden: cn("invisible flex-1", classNames?.hidden),
130
+ hidden: cn("invisible", defaultClassNames.hidden),
65
131
  ...classNames,
66
132
  }}
133
+ components={{
134
+ Root: ({ className, rootRef, ...props }) => {
135
+ return (
136
+ <div
137
+ data-slot="calendar"
138
+ ref={rootRef}
139
+ className={cn(className)}
140
+ {...props}
141
+ />
142
+ )
143
+ },
144
+ Chevron: ({ className, orientation, ...props }) => {
145
+ if (orientation === "left") {
146
+ return (
147
+ <ChevronLeftIcon className={cn("size-4", className)} {...props} />
148
+ )
149
+ }
150
+
151
+ if (orientation === "right") {
152
+ return (
153
+ <ChevronRightIcon className={cn("size-4", className)} {...props} />
154
+ )
155
+ }
156
+
157
+ return (
158
+ <ChevronDownIcon className={cn("size-4", className)} {...props} />
159
+ )
160
+ },
161
+ DayButton: CalendarDayButton,
162
+ WeekNumber: ({ children, ...props }) => {
163
+ return (
164
+ <td {...props}>
165
+ <div className="flex size-(--cell-size) items-center justify-center text-center">
166
+ {children}
167
+ </div>
168
+ </td>
169
+ )
170
+ },
171
+ ...components,
172
+ }}
173
+ {...props}
174
+ />
175
+ )
176
+ }
177
+
178
+ function CalendarDayButton({
179
+ className,
180
+ day,
181
+ modifiers,
182
+ ...props
183
+ }: React.ComponentProps<typeof DayButton>) {
184
+ const defaultClassNames = getDefaultClassNames()
185
+
186
+ const ref = React.useRef<HTMLButtonElement>(null)
187
+ React.useEffect(() => {
188
+ if (modifiers.focused) ref.current?.focus()
189
+ }, [modifiers.focused])
190
+
191
+ return (
192
+ <Button
193
+ variant="ghost"
194
+ size="icon"
195
+ data-day={day.date.toLocaleDateString()}
196
+ data-selected-single={
197
+ modifiers.selected &&
198
+ !modifiers.range_start &&
199
+ !modifiers.range_end &&
200
+ !modifiers.range_middle
201
+ }
202
+ data-range-start={modifiers.range_start}
203
+ data-range-end={modifiers.range_end}
204
+ data-range-middle={modifiers.range_middle}
205
+ className={cn(
206
+ "data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-foreground relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) [&>span]:text-xs [&>span]:opacity-70",
207
+ defaultClassNames.day,
208
+ className
209
+ )}
67
210
  {...props}
68
211
  />
69
- );
212
+ )
70
213
  }
71
- Calendar.displayName = "Calendar";
72
214
 
73
- export { Calendar };
215
+ export { Calendar, CalendarDayButton }
@@ -1,43 +1,94 @@
1
- import * as React from "react";
2
-
3
- import { cn } from "../../utils/cn";
4
-
5
- const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(({ className, ...props }, ref) => (
6
- <div ref={ref} className={cn("rounded-xl border bg-card text-card-foreground shadow", className)} {...props} />
7
- ));
8
- Card.displayName = "Card";
9
-
10
- const CardHeader = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
11
- ({ className, ...props }, ref) => (
12
- <div ref={ref} className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />
13
- ),
14
- );
15
- CardHeader.displayName = "CardHeader";
16
-
17
- const CardTitle = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
18
- ({ className, ...props }, ref) => (
19
- <div ref={ref} className={cn("font-semibold leading-none tracking-tight", className)} {...props} />
20
- ),
21
- );
22
- CardTitle.displayName = "CardTitle";
23
-
24
- const CardDescription = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
25
- ({ className, ...props }, ref) => (
26
- <div ref={ref} className={cn("text-sm text-muted-foreground", className)} {...props} />
27
- ),
28
- );
29
- CardDescription.displayName = "CardDescription";
30
-
31
- const CardContent = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
32
- ({ className, ...props }, ref) => <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />,
33
- );
34
- CardContent.displayName = "CardContent";
35
-
36
- const CardFooter = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
37
- ({ className, ...props }, ref) => (
38
- <div ref={ref} className={cn("flex items-center p-6 pt-0", className)} {...props} />
39
- ),
40
- );
41
- CardFooter.displayName = "CardFooter";
42
-
43
- export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle };
1
+ import * as React from "react"
2
+
3
+ import { cn } from "@/lib/utils"
4
+
5
+ function Card({
6
+ className,
7
+ size = "default",
8
+ ...props
9
+ }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
10
+ return (
11
+ <div
12
+ data-slot="card"
13
+ data-size={size}
14
+ className={cn("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-lg py-4 text-xs/relaxed ring-1 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 *:[img:first-child]:rounded-t-lg *:[img:last-child]:rounded-b-lg group/card flex flex-col", className)}
15
+ {...props}
16
+ />
17
+ )
18
+ }
19
+
20
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
21
+ return (
22
+ <div
23
+ data-slot="card-header"
24
+ className={cn(
25
+ "gap-1 rounded-t-lg px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]",
26
+ className
27
+ )}
28
+ {...props}
29
+ />
30
+ )
31
+ }
32
+
33
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
34
+ return (
35
+ <div
36
+ data-slot="card-title"
37
+ className={cn("text-sm font-medium", className)}
38
+ {...props}
39
+ />
40
+ )
41
+ }
42
+
43
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
44
+ return (
45
+ <div
46
+ data-slot="card-description"
47
+ className={cn("text-muted-foreground text-xs/relaxed", className)}
48
+ {...props}
49
+ />
50
+ )
51
+ }
52
+
53
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
54
+ return (
55
+ <div
56
+ data-slot="card-action"
57
+ className={cn(
58
+ "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
59
+ className
60
+ )}
61
+ {...props}
62
+ />
63
+ )
64
+ }
65
+
66
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
67
+ return (
68
+ <div
69
+ data-slot="card-content"
70
+ className={cn("px-4 group-data-[size=sm]/card:px-3", className)}
71
+ {...props}
72
+ />
73
+ )
74
+ }
75
+
76
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
77
+ return (
78
+ <div
79
+ data-slot="card-footer"
80
+ className={cn("rounded-b-lg px-4 group-data-[size=sm]/card:px-3 [.border-t]:pt-4 group-data-[size=sm]/card:[.border-t]:pt-3 flex items-center", className)}
81
+ {...props}
82
+ />
83
+ )
84
+ }
85
+
86
+ export {
87
+ Card,
88
+ CardHeader,
89
+ CardFooter,
90
+ CardTitle,
91
+ CardAction,
92
+ CardDescription,
93
+ CardContent,
94
+ }