@carlonicora/nextjs-jsonapi 1.36.1 → 1.38.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 (190) hide show
  1. package/dist/{BlockNoteEditor-4MDHRUS2.js → BlockNoteEditor-3S2B36O3.js} +15 -15
  2. package/dist/{BlockNoteEditor-4MDHRUS2.js.map → BlockNoteEditor-3S2B36O3.js.map} +1 -1
  3. package/dist/{BlockNoteEditor-SZWO3MDO.mjs → BlockNoteEditor-WQUJTVJL.mjs} +5 -5
  4. package/dist/BlockNoteEditor-WQUJTVJL.mjs.map +1 -0
  5. package/dist/billing/index.d.mts +15 -5
  6. package/dist/billing/index.d.ts +15 -5
  7. package/dist/billing/index.js +750 -520
  8. package/dist/billing/index.js.map +1 -1
  9. package/dist/billing/index.mjs +665 -435
  10. package/dist/billing/index.mjs.map +1 -1
  11. package/dist/{chunk-53IPQJVH.js → chunk-3EZX4G2E.js} +147 -23
  12. package/dist/chunk-3EZX4G2E.js.map +1 -0
  13. package/dist/{chunk-I7DFEJFF.mjs → chunk-4PHADEKA.mjs} +738 -1418
  14. package/dist/chunk-4PHADEKA.mjs.map +1 -0
  15. package/dist/{chunk-E6PQQTWF.js → chunk-T2JCZYWK.js} +999 -1679
  16. package/dist/chunk-T2JCZYWK.js.map +1 -0
  17. package/dist/{chunk-P7R2DPD6.mjs → chunk-TQ5GRRTM.mjs} +125 -1
  18. package/dist/chunk-TQ5GRRTM.mjs.map +1 -0
  19. package/dist/client/index.js +3 -3
  20. package/dist/client/index.mjs +2 -2
  21. package/dist/components/index.d.mts +23 -8
  22. package/dist/components/index.d.ts +23 -8
  23. package/dist/components/index.js +3 -3
  24. package/dist/components/index.mjs +2 -2
  25. package/dist/contexts/index.d.mts +1 -1
  26. package/dist/contexts/index.d.ts +1 -1
  27. package/dist/contexts/index.js +3 -3
  28. package/dist/contexts/index.mjs +2 -2
  29. package/dist/core/index.d.mts +47 -3
  30. package/dist/core/index.d.ts +47 -3
  31. package/dist/core/index.js +8 -2
  32. package/dist/core/index.js.map +1 -1
  33. package/dist/core/index.mjs +7 -1
  34. package/dist/index.d.mts +2 -2
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +8 -2
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +7 -1
  39. package/dist/server/index.js +3 -3
  40. package/dist/server/index.mjs +1 -1
  41. package/dist/{stripe-subscription.interface-DK7BJaNd.d.ts → stripe-promotion-code.interface-BcJty0rv.d.ts} +18 -1
  42. package/dist/{stripe-subscription.interface-C8uhCYIZ.d.mts → stripe-promotion-code.interface-Dnm2DJKQ.d.mts} +18 -1
  43. package/dist/testing/index.js.map +1 -1
  44. package/dist/testing/index.mjs.map +1 -1
  45. package/package.json +2 -2
  46. package/src/billing/index.ts +1 -0
  47. package/src/client/context/JsonApiProvider.tsx +1 -5
  48. package/src/client/hooks/__tests__/useJsonApiGet.test.tsx +9 -9
  49. package/src/client/hooks/__tests__/useJsonApiMutation.test.tsx +11 -11
  50. package/src/client/hooks/__tests__/useRehydration.test.ts +13 -34
  51. package/src/components/editors/BlockNoteEditor.tsx +2 -2
  52. package/src/components/forms/CommonEditorTrigger.tsx +1 -1
  53. package/src/components/forms/FormCheckbox.tsx +2 -12
  54. package/src/components/forms/FormDate.tsx +1 -6
  55. package/src/components/forms/FormInput.tsx +1 -1
  56. package/src/components/forms/FormPassword.tsx +1 -7
  57. package/src/components/forms/FormSelect.tsx +2 -8
  58. package/src/components/forms/FormSlider.tsx +1 -5
  59. package/src/components/forms/FormSwitch.tsx +1 -5
  60. package/src/components/forms/GdprConsentCheckbox.tsx +2 -8
  61. package/src/components/forms/PasswordInput.tsx +28 -26
  62. package/src/components/forms/__tests__/FormCheckbox.test.tsx +16 -18
  63. package/src/components/forms/__tests__/FormDate.test.tsx +14 -30
  64. package/src/components/forms/__tests__/FormInput.test.tsx +21 -37
  65. package/src/components/forms/__tests__/FormSelect.test.tsx +15 -21
  66. package/src/components/tables/ContentListTable.tsx +1 -1
  67. package/src/components/tables/__tests__/ContentListTable.test.tsx +17 -89
  68. package/src/components/tables/cells/cell.component.tsx +1 -1
  69. package/src/contexts/HeaderChildrenContext.tsx +3 -1
  70. package/src/core/endpoint/__tests__/EndpointCreator.test.ts +2 -7
  71. package/src/core/factories/__tests__/JsonApiDataFactory.test.ts +3 -3
  72. package/src/core/factories/__tests__/RehydrationFactory.test.ts +4 -6
  73. package/src/core/index.ts +1 -0
  74. package/src/core/registry/ModuleRegistry.ts +1 -0
  75. package/src/core/registry/__tests__/DataClassRegistry.test.ts +5 -15
  76. package/src/core/registry/__tests__/ModuleRegistrar.test.ts +5 -15
  77. package/src/features/auth/components/GdprConsentSection.tsx +1 -6
  78. package/src/features/auth/components/details/LandingComponent.tsx +6 -1
  79. package/src/features/auth/components/forms/AcceptInvitation.tsx +1 -1
  80. package/src/features/auth/components/forms/ResetPassword.tsx +1 -1
  81. package/src/features/billing/components/cards/PaymentMethodSummaryCard.tsx +13 -18
  82. package/src/features/billing/components/cards/SubscriptionSummaryCard.tsx +12 -17
  83. package/src/features/billing/components/modals/BillingDetailModal.tsx +2 -13
  84. package/src/features/billing/stripe-customer/components/details/PaymentMethodCard.tsx +8 -1
  85. package/src/features/billing/stripe-customer/components/forms/PaymentMethodEditor.tsx +2 -13
  86. package/src/features/billing/stripe-customer/components/forms/PaymentMethodForm.tsx +2 -12
  87. package/src/features/billing/stripe-invoice/components/details/InvoiceDetails.tsx +6 -1
  88. package/src/features/billing/stripe-invoice/data/stripe-invoice.interface.ts +1 -0
  89. package/src/features/billing/stripe-price/components/lists/PricesList.tsx +13 -5
  90. package/src/features/billing/stripe-product/components/lists/ProductsList.tsx +5 -5
  91. package/src/features/billing/stripe-promotion-code/components/PromoCodeInput.tsx +108 -0
  92. package/src/features/billing/stripe-promotion-code/components/index.ts +1 -0
  93. package/src/features/billing/stripe-promotion-code/data/index.ts +3 -0
  94. package/src/features/billing/stripe-promotion-code/data/stripe-promotion-code.interface.ts +14 -0
  95. package/src/features/billing/stripe-promotion-code/data/stripe-promotion-code.service.ts +64 -0
  96. package/src/features/billing/stripe-promotion-code/data/stripe-promotion-code.ts +66 -0
  97. package/src/features/billing/stripe-promotion-code/index.ts +2 -0
  98. package/src/features/billing/stripe-promotion-code/stripe-promotion-code.module.ts +9 -0
  99. package/src/features/billing/stripe-subscription/components/containers/SubscriptionsContainer.tsx +1 -3
  100. package/src/features/billing/stripe-subscription/components/details/SubscriptionDetails.tsx +4 -1
  101. package/src/features/billing/stripe-subscription/components/forms/CancelSubscriptionDialog.tsx +1 -1
  102. package/src/features/billing/stripe-subscription/components/lists/SubscriptionsList.tsx +24 -4
  103. package/src/features/billing/stripe-subscription/components/widgets/PricingCard.tsx +9 -2
  104. package/src/features/billing/stripe-subscription/components/widgets/SubscriptionStatusBadge.tsx +3 -1
  105. package/src/features/billing/stripe-subscription/components/wizards/SubscriptionWizard.tsx +7 -7
  106. package/src/features/billing/stripe-subscription/components/wizards/WizardProgressIndicator.tsx +2 -10
  107. package/src/features/billing/stripe-subscription/components/wizards/WizardStepPaymentMethod.tsx +3 -13
  108. package/src/features/billing/stripe-subscription/components/wizards/WizardStepReview.tsx +134 -23
  109. package/src/features/billing/stripe-subscription/data/stripe-subscription.interface.ts +2 -0
  110. package/src/features/billing/stripe-subscription/data/stripe-subscription.ts +8 -0
  111. package/src/features/billing/stripe-subscription/hooks/useSubscriptionWizard.ts +93 -7
  112. package/src/features/billing/stripe-usage/components/details/UsageSummaryCard.tsx +1 -1
  113. package/src/features/billing/stripe-usage/components/lists/UsageHistoryTable.tsx +1 -1
  114. package/src/features/company/components/details/CompanyDetails.tsx +2 -2
  115. package/src/features/company/components/forms/CompanyConfigurationSecurityForm.tsx +1 -1
  116. package/src/features/index.ts +1 -0
  117. package/src/features/notification/components/containers/NotificationsListContainer.tsx +1 -1
  118. package/src/features/notification/components/modals/NotificationModal.tsx +6 -2
  119. package/src/features/notification/contexts/NotificationContext.tsx +1 -3
  120. package/src/features/oauth/components/OAuthClientCard.tsx +15 -17
  121. package/src/features/oauth/components/OAuthClientDetail.tsx +7 -19
  122. package/src/features/oauth/components/OAuthClientForm.tsx +4 -13
  123. package/src/features/oauth/components/OAuthClientSecretDisplay.tsx +4 -20
  124. package/src/features/oauth/components/OAuthRedirectUriInput.tsx +5 -12
  125. package/src/features/oauth/components/OAuthScopeSelector.tsx +17 -23
  126. package/src/features/oauth/components/consent/OAuthConsentActions.tsx +3 -16
  127. package/src/features/oauth/components/consent/OAuthConsentHeader.tsx +3 -12
  128. package/src/features/oauth/components/consent/OAuthConsentScreen.tsx +5 -20
  129. package/src/features/oauth/components/consent/OAuthScopeList.tsx +3 -18
  130. package/src/features/onboarding/contexts/OnboardingContext.tsx +3 -3
  131. package/src/features/role/components/forms/FormRoles.tsx +1 -7
  132. package/src/features/user/components/containers/UserContainer.tsx +1 -1
  133. package/src/features/user/components/details/UserDetails.tsx +1 -1
  134. package/src/features/user/components/forms/UserDeleter.tsx +1 -1
  135. package/src/features/user/components/forms/UserEditor.tsx +1 -1
  136. package/src/features/user/components/forms/UserMultiSelect.tsx +7 -7
  137. package/src/features/user/components/lists/UserListInAdd.tsx +2 -2
  138. package/src/features/user/components/lists/UsersList.tsx +7 -1
  139. package/src/features/user/contexts/CurrentUserContext.tsx +36 -33
  140. package/src/hooks/__tests__/useDataListRetriever.test.ts +15 -21
  141. package/src/hooks/__tests__/useDebounce.test.ts +2 -7
  142. package/src/hooks/useCustomD3Graph.tsx +2 -2
  143. package/src/shadcnui/custom/multi-select.tsx +28 -2
  144. package/src/shadcnui/ui/accordion.tsx +21 -23
  145. package/src/shadcnui/ui/alert-dialog.tsx +45 -62
  146. package/src/shadcnui/ui/alert.tsx +25 -41
  147. package/src/shadcnui/ui/avatar.tsx +23 -36
  148. package/src/shadcnui/ui/badge.tsx +13 -11
  149. package/src/shadcnui/ui/breadcrumb.tsx +21 -55
  150. package/src/shadcnui/ui/button.tsx +17 -18
  151. package/src/shadcnui/ui/calendar.tsx +44 -93
  152. package/src/shadcnui/ui/carousel.tsx +72 -100
  153. package/src/shadcnui/ui/chart.tsx +102 -161
  154. package/src/shadcnui/ui/checkbox.tsx +8 -9
  155. package/src/shadcnui/ui/combobox.tsx +52 -83
  156. package/src/shadcnui/ui/command.tsx +43 -77
  157. package/src/shadcnui/ui/context-menu.tsx +47 -86
  158. package/src/shadcnui/ui/dialog.tsx +34 -60
  159. package/src/shadcnui/ui/drawer.tsx +32 -53
  160. package/src/shadcnui/ui/dropdown-menu.tsx +48 -65
  161. package/src/shadcnui/ui/field.tsx +39 -48
  162. package/src/shadcnui/ui/hover-card.tsx +9 -14
  163. package/src/shadcnui/ui/input-group.tsx +44 -55
  164. package/src/shadcnui/ui/input-otp.tsx +22 -26
  165. package/src/shadcnui/ui/input.tsx +6 -6
  166. package/src/shadcnui/ui/label.tsx +6 -6
  167. package/src/shadcnui/ui/navigation-menu.tsx +36 -60
  168. package/src/shadcnui/ui/popover.tsx +15 -38
  169. package/src/shadcnui/ui/progress.tsx +12 -29
  170. package/src/shadcnui/ui/radio-group.tsx +9 -15
  171. package/src/shadcnui/ui/resizable.tsx +14 -24
  172. package/src/shadcnui/ui/scroll-area.tsx +12 -27
  173. package/src/shadcnui/ui/select.tsx +41 -65
  174. package/src/shadcnui/ui/separator.tsx +7 -11
  175. package/src/shadcnui/ui/sheet.tsx +30 -55
  176. package/src/shadcnui/ui/sidebar.tsx +141 -189
  177. package/src/shadcnui/ui/skeleton.tsx +3 -9
  178. package/src/shadcnui/ui/slider.tsx +11 -23
  179. package/src/shadcnui/ui/switch.tsx +8 -8
  180. package/src/shadcnui/ui/tabs.tsx +14 -21
  181. package/src/shadcnui/ui/textarea.tsx +5 -5
  182. package/src/shadcnui/ui/toggle.tsx +8 -14
  183. package/src/shadcnui/ui/tooltip.tsx +11 -23
  184. package/src/testing/providers/MockJsonApiProvider.tsx +1 -5
  185. package/src/testing/utils/renderWithProviders.tsx +6 -10
  186. package/dist/BlockNoteEditor-SZWO3MDO.mjs.map +0 -1
  187. package/dist/chunk-53IPQJVH.js.map +0 -1
  188. package/dist/chunk-E6PQQTWF.js.map +0 -1
  189. package/dist/chunk-I7DFEJFF.mjs.map +0 -1
  190. package/dist/chunk-P7R2DPD6.mjs.map +0 -1
@@ -1,15 +1,11 @@
1
- "use client"
1
+ "use client";
2
2
 
3
- import * as React from "react"
4
- import {
5
- DayPicker,
6
- getDefaultClassNames,
7
- type DayButton,
8
- } from "react-day-picker"
3
+ import * as React from "react";
4
+ import { DayPicker, getDefaultClassNames, type DayButton } from "react-day-picker";
9
5
 
10
- import { cn } from "@/lib/utils"
11
- import { Button, buttonVariants } from "@/components/ui/button"
12
- import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react"
6
+ import { cn } from "@/lib/utils";
7
+ import { Button, buttonVariants } from "@/components/ui/button";
8
+ import { ChevronLeftIcon, ChevronRightIcon, ChevronDownIcon } from "lucide-react";
13
9
 
14
10
  function Calendar({
15
11
  className,
@@ -21,9 +17,9 @@ function Calendar({
21
17
  components,
22
18
  ...props
23
19
  }: React.ComponentProps<typeof DayPicker> & {
24
- buttonVariant?: React.ComponentProps<typeof Button>["variant"]
20
+ buttonVariant?: React.ComponentProps<typeof Button>["variant"];
25
21
  }) {
26
- const defaultClassNames = getDefaultClassNames()
22
+ const defaultClassNames = getDefaultClassNames();
27
23
 
28
24
  return (
29
25
  <DayPicker
@@ -32,161 +28,119 @@ function Calendar({
32
28
  "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
29
  String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
34
30
  String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
35
- className
31
+ className,
36
32
  )}
37
33
  captionLayout={captionLayout}
38
34
  formatters={{
39
- formatMonthDropdown: (date) =>
40
- date.toLocaleString("default", { month: "short" }),
35
+ formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
41
36
  ...formatters,
42
37
  }}
43
38
  classNames={{
44
39
  root: cn("w-fit", defaultClassNames.root),
45
- months: cn(
46
- "flex gap-4 flex-col md:flex-row relative",
47
- defaultClassNames.months
48
- ),
40
+ months: cn("flex gap-4 flex-col md:flex-row relative", defaultClassNames.months),
49
41
  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
53
- ),
42
+ nav: cn("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between", defaultClassNames.nav),
54
43
  button_previous: cn(
55
44
  buttonVariants({ variant: buttonVariant }),
56
45
  "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
57
- defaultClassNames.button_previous
46
+ defaultClassNames.button_previous,
58
47
  ),
59
48
  button_next: cn(
60
49
  buttonVariants({ variant: buttonVariant }),
61
50
  "size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
62
- defaultClassNames.button_next
51
+ defaultClassNames.button_next,
63
52
  ),
64
53
  month_caption: cn(
65
54
  "flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
66
- defaultClassNames.month_caption
55
+ defaultClassNames.month_caption,
67
56
  ),
68
57
  dropdowns: cn(
69
58
  "w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
70
- defaultClassNames.dropdowns
59
+ defaultClassNames.dropdowns,
71
60
  ),
72
61
  dropdown_root: cn(
73
62
  "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
63
+ defaultClassNames.dropdown_root,
79
64
  ),
65
+ dropdown: cn("absolute bg-popover inset-0 opacity-0", defaultClassNames.dropdown),
80
66
  caption_label: cn(
81
67
  "select-none font-medium",
82
68
  captionLayout === "label"
83
69
  ? "text-sm"
84
70
  : "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
71
+ defaultClassNames.caption_label,
86
72
  ),
87
73
  table: "w-full border-collapse",
88
74
  weekdays: cn("flex", defaultClassNames.weekdays),
89
75
  weekday: cn(
90
76
  "text-muted-foreground rounded-(--cell-radius) flex-1 font-normal text-[0.8rem] select-none",
91
- defaultClassNames.weekday
77
+ defaultClassNames.weekday,
92
78
  ),
93
79
  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
97
- ),
98
- week_number: cn(
99
- "text-[0.8rem] select-none text-muted-foreground",
100
- defaultClassNames.week_number
101
- ),
80
+ week_number_header: cn("select-none w-(--cell-size)", defaultClassNames.week_number_header),
81
+ week_number: cn("text-[0.8rem] select-none text-muted-foreground", defaultClassNames.week_number),
102
82
  day: cn(
103
83
  "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
84
  props.showWeekNumber
105
85
  ? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)"
106
86
  : "[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)",
107
- defaultClassNames.day
87
+ defaultClassNames.day,
108
88
  ),
109
89
  range_start: cn(
110
90
  "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
91
+ defaultClassNames.range_start,
112
92
  ),
113
93
  range_middle: cn("rounded-none", defaultClassNames.range_middle),
114
94
  range_end: cn(
115
95
  "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
96
+ defaultClassNames.range_end,
117
97
  ),
118
98
  today: cn(
119
99
  "bg-muted text-foreground rounded-(--cell-radius) data-[selected=true]:rounded-none",
120
- defaultClassNames.today
121
- ),
122
- outside: cn(
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
100
+ defaultClassNames.today,
129
101
  ),
102
+ outside: cn("text-muted-foreground aria-selected:text-muted-foreground", defaultClassNames.outside),
103
+ disabled: cn("text-muted-foreground opacity-50", defaultClassNames.disabled),
130
104
  hidden: cn("invisible", defaultClassNames.hidden),
131
105
  ...classNames,
132
106
  }}
133
107
  components={{
134
108
  Root: ({ className, rootRef, ...props }) => {
135
- return (
136
- <div
137
- data-slot="calendar"
138
- ref={rootRef}
139
- className={cn(className)}
140
- {...props}
141
- />
142
- )
109
+ return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
143
110
  },
144
111
  Chevron: ({ className, orientation, ...props }) => {
145
112
  if (orientation === "left") {
146
- return (
147
- <ChevronLeftIcon className={cn("size-4", className)} {...props} />
148
- )
113
+ return <ChevronLeftIcon className={cn("size-4", className)} {...props} />;
149
114
  }
150
115
 
151
116
  if (orientation === "right") {
152
- return (
153
- <ChevronRightIcon className={cn("size-4", className)} {...props} />
154
- )
117
+ return <ChevronRightIcon className={cn("size-4", className)} {...props} />;
155
118
  }
156
119
 
157
- return (
158
- <ChevronDownIcon className={cn("size-4", className)} {...props} />
159
- )
120
+ return <ChevronDownIcon className={cn("size-4", className)} {...props} />;
160
121
  },
161
122
  DayButton: CalendarDayButton,
162
123
  WeekNumber: ({ children, ...props }) => {
163
124
  return (
164
125
  <td {...props}>
165
- <div className="flex size-(--cell-size) items-center justify-center text-center">
166
- {children}
167
- </div>
126
+ <div className="flex size-(--cell-size) items-center justify-center text-center">{children}</div>
168
127
  </td>
169
- )
128
+ );
170
129
  },
171
130
  ...components,
172
131
  }}
173
132
  {...props}
174
133
  />
175
- )
134
+ );
176
135
  }
177
136
 
178
- function CalendarDayButton({
179
- className,
180
- day,
181
- modifiers,
182
- ...props
183
- }: React.ComponentProps<typeof DayButton>) {
184
- const defaultClassNames = getDefaultClassNames()
137
+ function CalendarDayButton({ className, day, modifiers, ...props }: React.ComponentProps<typeof DayButton>) {
138
+ const defaultClassNames = getDefaultClassNames();
185
139
 
186
- const ref = React.useRef<HTMLButtonElement>(null)
140
+ const ref = React.useRef<HTMLButtonElement>(null);
187
141
  React.useEffect(() => {
188
- if (modifiers.focused) ref.current?.focus()
189
- }, [modifiers.focused])
142
+ if (modifiers.focused) ref.current?.focus();
143
+ }, [modifiers.focused]);
190
144
 
191
145
  return (
192
146
  <Button
@@ -194,10 +148,7 @@ function CalendarDayButton({
194
148
  size="icon"
195
149
  data-day={day.date.toLocaleDateString()}
196
150
  data-selected-single={
197
- modifiers.selected &&
198
- !modifiers.range_start &&
199
- !modifiers.range_end &&
200
- !modifiers.range_middle
151
+ modifiers.selected && !modifiers.range_start && !modifiers.range_end && !modifiers.range_middle
201
152
  }
202
153
  data-range-start={modifiers.range_start}
203
154
  data-range-end={modifiers.range_end}
@@ -205,11 +156,11 @@ function CalendarDayButton({
205
156
  className={cn(
206
157
  "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
158
  defaultClassNames.day,
208
- className
159
+ className,
209
160
  )}
210
161
  {...props}
211
162
  />
212
- )
163
+ );
213
164
  }
214
165
 
215
- export { Calendar, CalendarDayButton }
166
+ export { Calendar, CalendarDayButton };
@@ -1,45 +1,43 @@
1
- "use client"
1
+ "use client";
2
2
 
3
- import * as React from "react"
4
- import useEmblaCarousel, {
5
- type UseEmblaCarouselType,
6
- } from "embla-carousel-react"
3
+ import * as React from "react";
4
+ import useEmblaCarousel, { type UseEmblaCarouselType } from "embla-carousel-react";
7
5
 
8
- import { cn } from "@/lib/utils"
9
- import { Button } from "@/components/ui/button"
10
- import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"
6
+ import { cn } from "@/lib/utils";
7
+ import { Button } from "@/components/ui/button";
8
+ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
11
9
 
12
- type CarouselApi = UseEmblaCarouselType[1]
13
- type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
14
- type CarouselOptions = UseCarouselParameters[0]
15
- type CarouselPlugin = UseCarouselParameters[1]
10
+ type CarouselApi = UseEmblaCarouselType[1];
11
+ type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
12
+ type CarouselOptions = UseCarouselParameters[0];
13
+ type CarouselPlugin = UseCarouselParameters[1];
16
14
 
17
15
  type CarouselProps = {
18
- opts?: CarouselOptions
19
- plugins?: CarouselPlugin
20
- orientation?: "horizontal" | "vertical"
21
- setApi?: (api: CarouselApi) => void
22
- }
16
+ opts?: CarouselOptions;
17
+ plugins?: CarouselPlugin;
18
+ orientation?: "horizontal" | "vertical";
19
+ setApi?: (api: CarouselApi) => void;
20
+ };
23
21
 
24
22
  type CarouselContextProps = {
25
- carouselRef: ReturnType<typeof useEmblaCarousel>[0]
26
- api: ReturnType<typeof useEmblaCarousel>[1]
27
- scrollPrev: () => void
28
- scrollNext: () => void
29
- canScrollPrev: boolean
30
- canScrollNext: boolean
31
- } & CarouselProps
23
+ carouselRef: ReturnType<typeof useEmblaCarousel>[0];
24
+ api: ReturnType<typeof useEmblaCarousel>[1];
25
+ scrollPrev: () => void;
26
+ scrollNext: () => void;
27
+ canScrollPrev: boolean;
28
+ canScrollNext: boolean;
29
+ } & CarouselProps;
32
30
 
33
- const CarouselContext = React.createContext<CarouselContextProps | null>(null)
31
+ const CarouselContext = React.createContext<CarouselContextProps | null>(null);
34
32
 
35
33
  function useCarousel() {
36
- const context = React.useContext(CarouselContext)
34
+ const context = React.useContext(CarouselContext);
37
35
 
38
36
  if (!context) {
39
- throw new Error("useCarousel must be used within a <Carousel />")
37
+ throw new Error("useCarousel must be used within a <Carousel />");
40
38
  }
41
39
 
42
- return context
40
+ return context;
43
41
  }
44
42
 
45
43
  function Carousel({
@@ -56,53 +54,53 @@ function Carousel({
56
54
  ...opts,
57
55
  axis: orientation === "horizontal" ? "x" : "y",
58
56
  },
59
- plugins
60
- )
61
- const [canScrollPrev, setCanScrollPrev] = React.useState(false)
62
- const [canScrollNext, setCanScrollNext] = React.useState(false)
57
+ plugins,
58
+ );
59
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false);
60
+ const [canScrollNext, setCanScrollNext] = React.useState(false);
63
61
 
64
62
  const onSelect = React.useCallback((api: CarouselApi) => {
65
- if (!api) return
66
- setCanScrollPrev(api.canScrollPrev())
67
- setCanScrollNext(api.canScrollNext())
68
- }, [])
63
+ if (!api) return;
64
+ setCanScrollPrev(api.canScrollPrev());
65
+ setCanScrollNext(api.canScrollNext());
66
+ }, []);
69
67
 
70
68
  const scrollPrev = React.useCallback(() => {
71
- api?.scrollPrev()
72
- }, [api])
69
+ api?.scrollPrev();
70
+ }, [api]);
73
71
 
74
72
  const scrollNext = React.useCallback(() => {
75
- api?.scrollNext()
76
- }, [api])
73
+ api?.scrollNext();
74
+ }, [api]);
77
75
 
78
76
  const handleKeyDown = React.useCallback(
79
77
  (event: React.KeyboardEvent<HTMLDivElement>) => {
80
78
  if (event.key === "ArrowLeft") {
81
- event.preventDefault()
82
- scrollPrev()
79
+ event.preventDefault();
80
+ scrollPrev();
83
81
  } else if (event.key === "ArrowRight") {
84
- event.preventDefault()
85
- scrollNext()
82
+ event.preventDefault();
83
+ scrollNext();
86
84
  }
87
85
  },
88
- [scrollPrev, scrollNext]
89
- )
86
+ [scrollPrev, scrollNext],
87
+ );
90
88
 
91
89
  React.useEffect(() => {
92
- if (!api || !setApi) return
93
- setApi(api)
94
- }, [api, setApi])
90
+ if (!api || !setApi) return;
91
+ setApi(api);
92
+ }, [api, setApi]);
95
93
 
96
94
  React.useEffect(() => {
97
- if (!api) return
98
- onSelect(api)
99
- api.on("reInit", onSelect)
100
- api.on("select", onSelect)
95
+ if (!api) return;
96
+ onSelect(api);
97
+ api.on("reInit", onSelect);
98
+ api.on("select", onSelect);
101
99
 
102
100
  return () => {
103
- api?.off("select", onSelect)
104
- }
105
- }, [api, onSelect])
101
+ api?.off("select", onSelect);
102
+ };
103
+ }, [api, onSelect]);
106
104
 
107
105
  return (
108
106
  <CarouselContext.Provider
@@ -110,8 +108,7 @@ function Carousel({
110
108
  carouselRef,
111
109
  api: api,
112
110
  opts,
113
- orientation:
114
- orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
111
+ orientation: orientation || (opts?.axis === "y" ? "vertical" : "horizontal"),
115
112
  scrollPrev,
116
113
  scrollNext,
117
114
  canScrollPrev,
@@ -129,46 +126,31 @@ function Carousel({
129
126
  {children}
130
127
  </div>
131
128
  </CarouselContext.Provider>
132
- )
129
+ );
133
130
  }
134
131
 
135
132
  function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
136
- const { carouselRef, orientation } = useCarousel()
133
+ const { carouselRef, orientation } = useCarousel();
137
134
 
138
135
  return (
139
- <div
140
- ref={carouselRef}
141
- className="overflow-hidden"
142
- data-slot="carousel-content"
143
- >
144
- <div
145
- className={cn(
146
- "flex",
147
- orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
148
- className
149
- )}
150
- {...props}
151
- />
136
+ <div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
137
+ <div className={cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className)} {...props} />
152
138
  </div>
153
- )
139
+ );
154
140
  }
155
141
 
156
142
  function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
157
- const { orientation } = useCarousel()
143
+ const { orientation } = useCarousel();
158
144
 
159
145
  return (
160
146
  <div
161
147
  role="group"
162
148
  aria-roledescription="slide"
163
149
  data-slot="carousel-item"
164
- className={cn(
165
- "min-w-0 shrink-0 grow-0 basis-full",
166
- orientation === "horizontal" ? "pl-4" : "pt-4",
167
- className
168
- )}
150
+ className={cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className)}
169
151
  {...props}
170
152
  />
171
- )
153
+ );
172
154
  }
173
155
 
174
156
  function CarouselPrevious({
@@ -177,7 +159,7 @@ function CarouselPrevious({
177
159
  size = "icon-sm",
178
160
  ...props
179
161
  }: React.ComponentProps<typeof Button>) {
180
- const { orientation, scrollPrev, canScrollPrev } = useCarousel()
162
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel();
181
163
 
182
164
  return (
183
165
  <Button
@@ -189,17 +171,16 @@ function CarouselPrevious({
189
171
  orientation === "horizontal"
190
172
  ? "top-1/2 -left-12 -translate-y-1/2"
191
173
  : "-top-12 left-1/2 -translate-x-1/2 rotate-90",
192
- className
174
+ className,
193
175
  )}
194
176
  disabled={!canScrollPrev}
195
177
  onClick={scrollPrev}
196
178
  {...props}
197
179
  >
198
- <ChevronLeftIcon
199
- />
180
+ <ChevronLeftIcon />
200
181
  <span className="sr-only">Previous slide</span>
201
182
  </Button>
202
- )
183
+ );
203
184
  }
204
185
 
205
186
  function CarouselNext({
@@ -208,7 +189,7 @@ function CarouselNext({
208
189
  size = "icon-sm",
209
190
  ...props
210
191
  }: React.ComponentProps<typeof Button>) {
211
- const { orientation, scrollNext, canScrollNext } = useCarousel()
192
+ const { orientation, scrollNext, canScrollNext } = useCarousel();
212
193
 
213
194
  return (
214
195
  <Button
@@ -220,25 +201,16 @@ function CarouselNext({
220
201
  orientation === "horizontal"
221
202
  ? "top-1/2 -right-12 -translate-y-1/2"
222
203
  : "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
223
- className
204
+ className,
224
205
  )}
225
206
  disabled={!canScrollNext}
226
207
  onClick={scrollNext}
227
208
  {...props}
228
209
  >
229
- <ChevronRightIcon
230
- />
210
+ <ChevronRightIcon />
231
211
  <span className="sr-only">Next slide</span>
232
212
  </Button>
233
- )
213
+ );
234
214
  }
235
215
 
236
- export {
237
- type CarouselApi,
238
- Carousel,
239
- CarouselContent,
240
- CarouselItem,
241
- CarouselPrevious,
242
- CarouselNext,
243
- useCarousel,
244
- }
216
+ export { type CarouselApi, Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, useCarousel };