@middag-io/react 0.45.0 → 0.45.2

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 (320) hide show
  1. package/docs/public/schemas/ai-contract-manifest.json +1820 -0
  2. package/docs/public/schemas/blocks.json +445 -0
  3. package/docs/public/schemas/components.json +166 -0
  4. package/docs/public/schemas/connectors.json +97 -0
  5. package/docs/public/schemas/fragment.json +2329 -0
  6. package/docs/public/schemas/manifest.json +119 -0
  7. package/docs/public/schemas/navigation.json +72 -0
  8. package/docs/public/schemas/page-contract.json +2329 -0
  9. package/docs/public/schemas/shared-props.json +118 -0
  10. package/docs/public/schemas/theme-defaults.json +253 -0
  11. package/docs/public/schemas/theme.json +401 -0
  12. package/package.json +109 -3
  13. package/src/assets/lottie/calendar/schedule-1.json +1 -0
  14. package/src/assets/lottie/calendar/schedule-2.json +1 -0
  15. package/src/assets/lottie/celebration/confetti-1.json +1 -0
  16. package/src/assets/lottie/celebration/confetti-2.json +1 -0
  17. package/src/assets/lottie/celebration/confetti-3.json +1 -0
  18. package/src/assets/lottie/cloud/cloud-1.json +1 -0
  19. package/src/assets/lottie/cloud/cloud-2.json +1 -0
  20. package/src/assets/lottie/connection/network-1.json +1 -0
  21. package/src/assets/lottie/connection/network-2.json +1 -0
  22. package/src/assets/lottie/connection/network-3.json +1 -0
  23. package/src/assets/lottie/dashboard/analytics-1.json +1 -0
  24. package/src/assets/lottie/dashboard/analytics-2.json +1 -0
  25. package/src/assets/lottie/dashboard/analytics-3.json +1 -0
  26. package/src/assets/lottie/email/mail-1.json +1 -0
  27. package/src/assets/lottie/email/mail-2.json +1 -0
  28. package/src/assets/lottie/email/mail-3.json +1 -0
  29. package/src/assets/lottie/empty-state/empty-1.json +1 -0
  30. package/src/assets/lottie/empty-state/empty-2.json +1 -0
  31. package/src/assets/lottie/empty-state/empty-3.json +1 -0
  32. package/src/assets/lottie/error/warning-1.json +1 -0
  33. package/src/assets/lottie/error/warning-2.json +1 -0
  34. package/src/assets/lottie/error/warning-3.json +1 -0
  35. package/src/assets/lottie/index.ts +49 -0
  36. package/src/assets/lottie/loading/spinner-1.json +1 -0
  37. package/src/assets/lottie/loading/spinner-2.json +1 -0
  38. package/src/assets/lottie/loading/spinner-3.json +1 -0
  39. package/src/assets/lottie/maintenance/construction-1.json +1 -0
  40. package/src/assets/lottie/maintenance/construction-2.json +1 -0
  41. package/src/assets/lottie/maintenance/construction-3.json +1 -0
  42. package/src/assets/lottie/not-found/404-1.json +1 -0
  43. package/src/assets/lottie/not-found/404-2.json +1 -0
  44. package/src/assets/lottie/not-found/404-3.json +1 -0
  45. package/src/assets/lottie/notification/bell-1.json +1 -0
  46. package/src/assets/lottie/notification/bell-2.json +1 -0
  47. package/src/assets/lottie/notification/bell-3.json +1 -0
  48. package/src/assets/lottie/onboarding/welcome-1.json +1 -0
  49. package/src/assets/lottie/onboarding/welcome-2.json +1 -0
  50. package/src/assets/lottie/onboarding/welcome-3.json +1 -0
  51. package/src/assets/lottie/payment/wallet-1.json +1 -0
  52. package/src/assets/lottie/payment/wallet-2.json +1 -0
  53. package/src/assets/lottie/payment/wallet-3.json +1 -0
  54. package/src/assets/lottie/search/search-1.json +1 -0
  55. package/src/assets/lottie/search/search-2.json +1 -0
  56. package/src/assets/lottie/search/search-3.json +1 -0
  57. package/src/assets/lottie/security/lock-1.json +1 -0
  58. package/src/assets/lottie/security/lock-2.json +1 -0
  59. package/src/assets/lottie/security/lock-3.json +1 -0
  60. package/src/assets/lottie/settings/gear-1.json +1 -0
  61. package/src/assets/lottie/settings/gear-2.json +1 -0
  62. package/src/assets/lottie/settings/gear-3.json +1 -0
  63. package/src/assets/lottie/success/check-1.json +1 -0
  64. package/src/assets/lottie/success/check-2.json +1 -0
  65. package/src/assets/lottie/success/check-3.json +1 -0
  66. package/src/assets/lottie/upload/upload-1.json +1 -0
  67. package/src/assets/lottie/upload/upload-2.json +1 -0
  68. package/src/assets/lottie/upload/upload-3.json +1 -0
  69. package/src/assets/lottie/user/profile-1.json +1 -0
  70. package/src/assets/lottie/user/profile-2.json +1 -0
  71. package/src/assets/lottie/user/profile-3.json +1 -0
  72. package/src/base/blocks/ActionGridBlock.tsx +151 -0
  73. package/src/base/blocks/ActivityTimelineBlock.tsx +180 -0
  74. package/src/base/blocks/CardGridBlock.tsx +384 -0
  75. package/src/base/blocks/ChartBlock.tsx +81 -0
  76. package/src/base/blocks/DenseTableBlock.tsx +403 -0
  77. package/src/base/blocks/DetailPanelBlock.tsx +189 -0
  78. package/src/base/blocks/EmptyStateBlock.tsx +46 -0
  79. package/src/base/blocks/FormPanelBlock.lazy.tsx +38 -0
  80. package/src/base/blocks/FormPanelBlock.tsx +480 -0
  81. package/src/base/blocks/LinkListBlock.tsx +94 -0
  82. package/src/base/blocks/MarkdownPanelBlock.tsx +60 -0
  83. package/src/base/blocks/MetricCardBlock.tsx +128 -0
  84. package/src/base/blocks/StatusStripBlock.tsx +43 -0
  85. package/src/base/blocks/TabsBlock.tsx +94 -0
  86. package/src/base/form/FormField.tsx +607 -0
  87. package/src/base/form/fields/CheckboxField.tsx +56 -0
  88. package/src/base/form/fields/ColorField.tsx +76 -0
  89. package/src/base/form/fields/CurrencyField.tsx +126 -0
  90. package/src/base/form/fields/DateField.tsx +168 -0
  91. package/src/base/form/fields/DateRangeField.tsx +66 -0
  92. package/src/base/form/fields/DocumentField.tsx +222 -0
  93. package/src/base/form/fields/EntityPickerField.tsx +244 -0
  94. package/src/base/form/fields/FileUploadField.tsx +253 -0
  95. package/src/base/form/fields/MultiSelectField.tsx +286 -0
  96. package/src/base/form/fields/NativeSelectField.tsx +67 -0
  97. package/src/base/form/fields/NumberField.tsx +67 -0
  98. package/src/base/form/fields/OtpField.tsx +88 -0
  99. package/src/base/form/fields/PasswordField.tsx +69 -0
  100. package/src/base/form/fields/PhoneField.tsx +64 -0
  101. package/src/base/form/fields/RadioField.tsx +66 -0
  102. package/src/base/form/fields/RatingField.tsx +52 -0
  103. package/src/base/form/fields/SelectField.tsx +76 -0
  104. package/src/base/form/fields/SliderField.tsx +77 -0
  105. package/src/base/form/fields/SlugField.tsx +114 -0
  106. package/src/base/form/fields/StaticField.tsx +25 -0
  107. package/src/base/form/fields/SwitchField.tsx +56 -0
  108. package/src/base/form/fields/TagsField.tsx +128 -0
  109. package/src/base/form/fields/TextField.tsx +55 -0
  110. package/src/base/form/fields/TextareaField.tsx +55 -0
  111. package/src/base/form/fields/document-validation.ts +126 -0
  112. package/src/base/form/fields/field-registry.ts +53 -0
  113. package/src/base/form/fields/register-default-fields.ts +86 -0
  114. package/src/base/form/form-schema-builder.ts +192 -0
  115. package/src/base/form/form-utils.ts +71 -0
  116. package/src/base/hooks/useIsDark.ts +50 -0
  117. package/src/base/hooks/useLazyTabs.ts +98 -0
  118. package/src/base/hooks/usePolling.ts +43 -0
  119. package/src/base/hooks/useRemember.ts +58 -0
  120. package/src/base/hooks/useToast.ts +27 -0
  121. package/src/base/layout/BlockRegion.tsx +39 -0
  122. package/src/base/layout/DashboardLayout.tsx +110 -0
  123. package/src/base/layout/SidebarLayout.tsx +38 -0
  124. package/src/base/layout/StackLayout.tsx +32 -0
  125. package/src/base/layout/WizardLayout.tsx +49 -0
  126. package/src/base/partials/ActionBar/index.tsx +115 -0
  127. package/src/base/partials/ConfirmationDialog/index.tsx +128 -0
  128. package/src/base/partials/DataTable/cell-registry.ts +50 -0
  129. package/src/base/partials/DataTable/cell-renderers.tsx +372 -0
  130. package/src/base/partials/DataTable/index.tsx +1282 -0
  131. package/src/base/partials/DataTable/register-default-cells.ts +37 -0
  132. package/src/base/partials/DataTable/sanitize-html.ts +45 -0
  133. package/src/base/partials/DataTable/types.ts +229 -0
  134. package/src/base/partials/DetailSection/index.tsx +316 -0
  135. package/src/base/partials/EmptyPlaceholder/index.tsx +162 -0
  136. package/src/base/partials/EntityItem/index.tsx +154 -0
  137. package/src/base/partials/FilterBar/index.tsx +256 -0
  138. package/src/base/partials/FormSection/index.tsx +87 -0
  139. package/src/base/partials/LogViewer/JsonBlock.tsx +39 -0
  140. package/src/base/partials/LogViewer/LogEntry.tsx +68 -0
  141. package/src/base/partials/LogViewer/LogViewerToolbar.tsx +71 -0
  142. package/src/base/partials/LogViewer/index.tsx +110 -0
  143. package/src/base/partials/LogViewer/types.ts +28 -0
  144. package/src/base/partials/MarkdownContent/index.tsx +307 -0
  145. package/src/base/partials/MenuBar/index.tsx +80 -0
  146. package/src/base/partials/QuickRecordSheet/index.tsx +59 -0
  147. package/src/base/partials/ResizableSidebar/index.tsx +70 -0
  148. package/src/base/partials/StatRow/index.tsx +28 -0
  149. package/src/base/partials/StatusBar/index.tsx +126 -0
  150. package/src/base/partials/StatusIndicator/index.tsx +61 -0
  151. package/src/base/partials/StepIndicator/index.tsx +63 -0
  152. package/src/base/partials/TableOfContents/index.tsx +78 -0
  153. package/src/base/partials/TimelineList/index.tsx +273 -0
  154. package/src/base/partials/ToggleGroupControl/index.tsx +100 -0
  155. package/src/base/partials/TreeView/index.tsx +75 -0
  156. package/src/base/partials/index.ts +23 -0
  157. package/src/base/shell/AuthShell.tsx +54 -0
  158. package/src/base/shell/BasicShell.tsx +286 -0
  159. package/src/base/shell/ImmersiveShell.tsx +85 -0
  160. package/src/base/shell/partials/EditablePanelContext.tsx +82 -0
  161. package/src/base/shell/partials/EditablePanelProvider.tsx +122 -0
  162. package/src/base/shell/partials/InlineEditablePanel.tsx +239 -0
  163. package/src/base/shell/partials/InspectorContext.tsx +173 -0
  164. package/src/base/shell/partials/InspectorPanel.tsx +65 -0
  165. package/src/base/shell/partials/NavErrorBoundary.tsx +82 -0
  166. package/src/base/shell/partials/OverlayScreen.tsx +67 -0
  167. package/src/base/shell/partials/PageActionButton.tsx +203 -0
  168. package/src/base/theme/appearance.ts +133 -0
  169. package/src/base/theme/host-layout-detector.ts +119 -0
  170. package/src/base/theme/host-theme-detector.ts +146 -0
  171. package/src/base/theme/sidebar-safelist.txt +20 -0
  172. package/src/base/theme/tailwind-theme.css +136 -0
  173. package/src/base/theme/theme-bridge.css +164 -0
  174. package/src/base/theme/theme-context.tsx +142 -0
  175. package/src/base/theme/themes/classic.css +174 -0
  176. package/src/base/theme/tokens.css +290 -0
  177. package/src/base/theme/useHostTheme.ts +95 -0
  178. package/src/base/utils/clipboard.ts +39 -0
  179. package/src/base/utils/conditions.ts +27 -0
  180. package/src/base/utils/icon-registry.ts +78 -0
  181. package/src/base/utils/icons.ts +31 -0
  182. package/src/base/utils/interpolate.ts +9 -0
  183. package/src/base/utils/register-default-icons.ts +163 -0
  184. package/src/base/utils/storage.ts +65 -0
  185. package/src/base/utils/time.ts +139 -0
  186. package/src/contracts/block-data/actions.ts +73 -0
  187. package/src/contracts/block-data/data-display.ts +343 -0
  188. package/src/contracts/block-data/form.ts +164 -0
  189. package/src/contracts/block-data/index.ts +15 -0
  190. package/src/contracts/block-data/interactive.ts +34 -0
  191. package/src/contracts/block-data/shared.ts +44 -0
  192. package/src/contracts/connectors.ts +60 -0
  193. package/src/contracts/generated/contract-schema.ts +1237 -0
  194. package/src/contracts/generated/contract-types.ts +675 -0
  195. package/src/contracts/generated/index.ts +15 -0
  196. package/src/contracts/navigation.ts +59 -0
  197. package/src/contracts/page-contract-schema.ts +40 -0
  198. package/src/contracts/page-contract.ts +79 -0
  199. package/src/contracts/shared-props.ts +92 -0
  200. package/src/engine/ContractPage.tsx +178 -0
  201. package/src/engine/EntityRoutes.tsx +72 -0
  202. package/src/engine/HostSlot.tsx +126 -0
  203. package/src/engine/LazyBlock.tsx +92 -0
  204. package/src/engine/bootstrap.tsx +20 -0
  205. package/src/engine/providers/auth.tsx +87 -0
  206. package/src/engine/providers/error-reporter.tsx +89 -0
  207. package/src/engine/providers/flash.tsx +44 -0
  208. package/src/engine/providers/index.ts +18 -0
  209. package/src/engine/providers/inertia-error-reporter.tsx +61 -0
  210. package/src/engine/providers/progress.tsx +56 -0
  211. package/src/engine/providers/scope.tsx +51 -0
  212. package/src/engine/register-defaults.ts +88 -0
  213. package/src/engine/registries.ts +96 -0
  214. package/src/i18n/I18nProvider.tsx +53 -0
  215. package/src/i18n/MANIFEST.md +101 -0
  216. package/src/i18n/host-resolver.ts +18 -0
  217. package/src/i18n/instance.ts +69 -0
  218. package/src/i18n/locales/en/ui.json +277 -0
  219. package/src/i18n/locales/en/validators.json +13 -0
  220. package/src/i18n/locales/pt-BR/ui.json +277 -0
  221. package/src/i18n/locales/pt-BR/validators.json +13 -0
  222. package/src/i18n/register-strings.ts +10 -0
  223. package/src/i18n/render-label.ts +33 -0
  224. package/src/i18n/resolve-field-error.ts +29 -0
  225. package/src/i18n/useHostString.ts +50 -0
  226. package/src/i18n/useTranslation.ts +83 -0
  227. package/src/lib/actions/resolve-action-target.ts +151 -0
  228. package/src/lib/hooks/use-copy-to-clipboard.ts +37 -0
  229. package/src/lib/hooks/use-file-upload.ts +406 -0
  230. package/src/lib/hooks/use-mobile.ts +21 -0
  231. package/src/lib/host-pending.ts +76 -0
  232. package/src/lib/portal-container.ts +16 -0
  233. package/src/lib/test-ids.ts +40 -0
  234. package/src/lib/utils.ts +6 -0
  235. package/src/primitives/reui/MANIFEST.md +97 -0
  236. package/src/primitives/reui/accordion.tsx +64 -0
  237. package/src/primitives/reui/alert-dialog.tsx +196 -0
  238. package/src/primitives/reui/alert.tsx +92 -0
  239. package/src/primitives/reui/aspect-ratio.tsx +9 -0
  240. package/src/primitives/reui/autocomplete.tsx +343 -0
  241. package/src/primitives/reui/avatar.tsx +109 -0
  242. package/src/primitives/reui/badge.tsx +94 -0
  243. package/src/primitives/reui/breadcrumb.tsx +109 -0
  244. package/src/primitives/reui/button-group.tsx +83 -0
  245. package/src/primitives/reui/button.tsx +64 -0
  246. package/src/primitives/reui/calendar.tsx +220 -0
  247. package/src/primitives/reui/card.tsx +92 -0
  248. package/src/primitives/reui/carousel.tsx +239 -0
  249. package/src/primitives/reui/chart.tsx +388 -0
  250. package/src/primitives/reui/checkbox.tsx +30 -0
  251. package/src/primitives/reui/collapsible.tsx +31 -0
  252. package/src/primitives/reui/combobox.tsx +308 -0
  253. package/src/primitives/reui/command.tsx +182 -0
  254. package/src/primitives/reui/context-menu.tsx +250 -0
  255. package/src/primitives/reui/data-grid/data-grid-column-filter.tsx +172 -0
  256. package/src/primitives/reui/data-grid/data-grid-column-header.tsx +420 -0
  257. package/src/primitives/reui/data-grid/data-grid-column-visibility.tsx +51 -0
  258. package/src/primitives/reui/data-grid/data-grid-pagination.tsx +235 -0
  259. package/src/primitives/reui/data-grid/data-grid-scroll-area.tsx +427 -0
  260. package/src/primitives/reui/data-grid/data-grid-table-dnd-rows.tsx +308 -0
  261. package/src/primitives/reui/data-grid/data-grid-table-dnd.tsx +318 -0
  262. package/src/primitives/reui/data-grid/data-grid-table-virtual.tsx +491 -0
  263. package/src/primitives/reui/data-grid/data-grid-table.tsx +1430 -0
  264. package/src/primitives/reui/data-grid/data-grid.tsx +269 -0
  265. package/src/primitives/reui/data-grid-pagination.tsx +235 -0
  266. package/src/primitives/reui/date-selector.tsx +1353 -0
  267. package/src/primitives/reui/dialog.tsx +158 -0
  268. package/src/primitives/reui/drawer.tsx +133 -0
  269. package/src/primitives/reui/dropdown-menu.tsx +257 -0
  270. package/src/primitives/reui/empty.tsx +104 -0
  271. package/src/primitives/reui/field.tsx +246 -0
  272. package/src/primitives/reui/filters.tsx +1891 -0
  273. package/src/primitives/reui/frame.tsx +170 -0
  274. package/src/primitives/reui/hover-card.tsx +42 -0
  275. package/src/primitives/reui/icon-placeholder.tsx +39 -0
  276. package/src/primitives/reui/index.ts +98 -0
  277. package/src/primitives/reui/input-group.tsx +170 -0
  278. package/src/primitives/reui/input-otp.tsx +75 -0
  279. package/src/primitives/reui/input.tsx +21 -0
  280. package/src/primitives/reui/item.tsx +193 -0
  281. package/src/primitives/reui/kanban.tsx +743 -0
  282. package/src/primitives/reui/kbd.tsx +28 -0
  283. package/src/primitives/reui/label.tsx +22 -0
  284. package/src/primitives/reui/menubar.tsx +274 -0
  285. package/src/primitives/reui/native-select.tsx +62 -0
  286. package/src/primitives/reui/navigation-menu.tsx +168 -0
  287. package/src/primitives/reui/number-field.tsx +250 -0
  288. package/src/primitives/reui/pagination.tsx +127 -0
  289. package/src/primitives/reui/phone-input.tsx +231 -0
  290. package/src/primitives/reui/popover.tsx +87 -0
  291. package/src/primitives/reui/progress.tsx +31 -0
  292. package/src/primitives/reui/radio-group.tsx +43 -0
  293. package/src/primitives/reui/rating.tsx +177 -0
  294. package/src/primitives/reui/resizable.tsx +51 -0
  295. package/src/primitives/reui/scroll-area.tsx +58 -0
  296. package/src/primitives/reui/scrollspy.tsx +240 -0
  297. package/src/primitives/reui/select.tsx +188 -0
  298. package/src/primitives/reui/separator.tsx +28 -0
  299. package/src/primitives/reui/sheet.tsx +141 -0
  300. package/src/primitives/reui/sidebar.tsx +732 -0
  301. package/src/primitives/reui/skeleton.tsx +13 -0
  302. package/src/primitives/reui/slider.tsx +61 -0
  303. package/src/primitives/reui/sonner.tsx +47 -0
  304. package/src/primitives/reui/sortable.tsx +414 -0
  305. package/src/primitives/reui/spinner.tsx +16 -0
  306. package/src/primitives/reui/stepper.tsx +484 -0
  307. package/src/primitives/reui/svgs/claudeAiIcon.tsx +12 -0
  308. package/src/primitives/reui/svgs/gemini.tsx +171 -0
  309. package/src/primitives/reui/svgs/openai.tsx +9 -0
  310. package/src/primitives/reui/svgs/openaiDark.tsx +12 -0
  311. package/src/primitives/reui/switch.tsx +33 -0
  312. package/src/primitives/reui/table.tsx +114 -0
  313. package/src/primitives/reui/tabs.tsx +91 -0
  314. package/src/primitives/reui/textarea.tsx +18 -0
  315. package/src/primitives/reui/timeline.tsx +219 -0
  316. package/src/primitives/reui/toggle-group.tsx +83 -0
  317. package/src/primitives/reui/toggle.tsx +45 -0
  318. package/src/primitives/reui/tooltip.tsx +55 -0
  319. package/src/primitives/reui/tree.tsx +247 -0
  320. package/src/theme.css +71 -0
@@ -0,0 +1,31 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { Progress as ProgressPrimitive } from "radix-ui";
5
+
6
+ import { cn } from "@/lib/utils";
7
+
8
+ function Progress({
9
+ className,
10
+ value,
11
+ ...props
12
+ }: React.ComponentProps<typeof ProgressPrimitive.Root>) {
13
+ return (
14
+ <ProgressPrimitive.Root
15
+ data-slot="progress"
16
+ className={cn(
17
+ "relative h-2 w-full overflow-hidden rounded-full bg-primary/20",
18
+ className,
19
+ )}
20
+ {...props}
21
+ >
22
+ <ProgressPrimitive.Indicator
23
+ data-slot="progress-indicator"
24
+ className="h-full w-full flex-1 bg-primary transition-all"
25
+ style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
26
+ />
27
+ </ProgressPrimitive.Root>
28
+ );
29
+ }
30
+
31
+ export { Progress };
@@ -0,0 +1,43 @@
1
+ import * as React from "react";
2
+ import { CircleIcon } from "lucide-react";
3
+ import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ function RadioGroup({
8
+ className,
9
+ ...props
10
+ }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
11
+ return (
12
+ <RadioGroupPrimitive.Root
13
+ data-slot="radio-group"
14
+ className={cn("grid gap-3", className)}
15
+ {...props}
16
+ />
17
+ );
18
+ }
19
+
20
+ function RadioGroupItem({
21
+ className,
22
+ ...props
23
+ }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
24
+ return (
25
+ <RadioGroupPrimitive.Item
26
+ data-slot="radio-group-item"
27
+ className={cn(
28
+ "aspect-square size-4 shrink-0 rounded-full border border-input text-primary shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:ring-destructive/40",
29
+ className,
30
+ )}
31
+ {...props}
32
+ >
33
+ <RadioGroupPrimitive.Indicator
34
+ data-slot="radio-group-indicator"
35
+ className="relative flex items-center justify-center"
36
+ >
37
+ <CircleIcon className="absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 fill-primary" />
38
+ </RadioGroupPrimitive.Indicator>
39
+ </RadioGroupPrimitive.Item>
40
+ );
41
+ }
42
+
43
+ export { RadioGroup, RadioGroupItem };
@@ -0,0 +1,177 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { cva, type VariantProps } from "class-variance-authority";
5
+
6
+ import { cn } from "@/lib/utils";
7
+ import { HugeiconsIcon } from "@hugeicons/react";
8
+ import { StarIcon } from "@hugeicons/core-free-icons";
9
+
10
+ const ratingVariants = cva("flex items-center", {
11
+ variants: {
12
+ size: {
13
+ sm: "gap-2",
14
+ default: "gap-2.5",
15
+ lg: "gap-3",
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ size: "default",
20
+ },
21
+ });
22
+
23
+ const starVariants = cva("", {
24
+ variants: {
25
+ size: {
26
+ sm: "w-4 h-4",
27
+ default: "w-5 h-5",
28
+ lg: "w-6 h-6",
29
+ },
30
+ },
31
+ defaultVariants: {
32
+ size: "default",
33
+ },
34
+ });
35
+
36
+ const valueVariants = cva("text-muted-foreground w-5", {
37
+ variants: {
38
+ size: {
39
+ sm: "text-xs",
40
+ default: "text-sm",
41
+ lg: "text-base",
42
+ },
43
+ },
44
+ defaultVariants: {
45
+ size: "default",
46
+ },
47
+ });
48
+
49
+ function Rating({
50
+ rating,
51
+ maxRating = 5,
52
+ size,
53
+ className,
54
+ starClassName,
55
+ showValue = false,
56
+ editable = false,
57
+ onRatingChange,
58
+ ...props
59
+ }: React.ComponentProps<"div"> &
60
+ VariantProps<typeof ratingVariants> & {
61
+ /**
62
+ * Current rating value (supports decimal values for partial stars)
63
+ */
64
+ rating: number;
65
+ /**
66
+ * Maximum rating value (number of stars to show)
67
+ */
68
+ maxRating?: number;
69
+ /**
70
+ * Whether to show the numeric rating value
71
+ */
72
+ showValue?: boolean;
73
+ /**
74
+ * Class name for the value span
75
+ */
76
+ starClassName?: string;
77
+ /**
78
+ * Whether the rating is editable (clickable)
79
+ */
80
+ editable?: boolean;
81
+ /**
82
+ * Callback function called when rating changes
83
+ */
84
+ onRatingChange?: (rating: number) => void;
85
+ }) {
86
+ const [hoveredRating, setHoveredRating] = useState<number | null>(null);
87
+ const displayRating =
88
+ editable && hoveredRating !== null ? hoveredRating : rating;
89
+
90
+ const handleStarClick = (starRating: number) => {
91
+ if (editable && onRatingChange) {
92
+ onRatingChange(starRating);
93
+ }
94
+ };
95
+
96
+ const handleStarMouseEnter = (starRating: number) => {
97
+ if (editable) {
98
+ setHoveredRating(starRating);
99
+ }
100
+ };
101
+
102
+ const handleStarMouseLeave = () => {
103
+ if (editable) {
104
+ setHoveredRating(null);
105
+ }
106
+ };
107
+
108
+ const renderStars = () => {
109
+ const stars = [];
110
+
111
+ for (let i = 1; i <= maxRating; i++) {
112
+ const filled = displayRating >= i;
113
+ const partiallyFilled = displayRating > i - 1 && displayRating < i;
114
+ const fillPercentage = partiallyFilled
115
+ ? (displayRating - (i - 1)) * 100
116
+ : 0;
117
+
118
+ stars.push(
119
+ <div
120
+ key={i}
121
+ className={cn("relative", editable && "cursor-pointer")}
122
+ onClick={() => handleStarClick(i)}
123
+ onMouseEnter={() => handleStarMouseEnter(i)}
124
+ onMouseLeave={handleStarMouseLeave}
125
+ >
126
+ {/* Background star (empty) */}
127
+ <HugeiconsIcon
128
+ icon={StarIcon}
129
+ strokeWidth={2}
130
+ data-slot="rating-star-empty"
131
+ className={cn(starVariants({ size }), "text-muted-foreground/30")}
132
+ />
133
+
134
+ {/* Filled star */}
135
+ <div
136
+ className="absolute inset-0 overflow-hidden"
137
+ style={{
138
+ width: filled ? "100%" : `${fillPercentage}%`,
139
+ }}
140
+ >
141
+ <HugeiconsIcon
142
+ icon={StarIcon}
143
+ strokeWidth={2}
144
+ data-slot="rating-star-filled"
145
+ className={cn(
146
+ starVariants({ size }),
147
+ "fill-yellow-400 text-yellow-400",
148
+ )}
149
+ />
150
+ </div>
151
+ </div>,
152
+ );
153
+ }
154
+
155
+ return stars;
156
+ };
157
+
158
+ return (
159
+ <div
160
+ data-slot="rating"
161
+ className={cn(ratingVariants({ size }), className)}
162
+ {...props}
163
+ >
164
+ <div className="flex items-center">{renderStars()}</div>
165
+ {showValue && (
166
+ <span
167
+ data-slot="rating-value"
168
+ className={cn(valueVariants({ size }), starClassName)}
169
+ >
170
+ {displayRating.toFixed(1)}
171
+ </span>
172
+ )}
173
+ </div>
174
+ );
175
+ }
176
+
177
+ export { Rating };
@@ -0,0 +1,51 @@
1
+ import { GripVerticalIcon } from "lucide-react";
2
+ import * as ResizablePrimitive from "react-resizable-panels";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ function ResizablePanelGroup({
7
+ className,
8
+ ...props
9
+ }: ResizablePrimitive.GroupProps) {
10
+ return (
11
+ <ResizablePrimitive.Group
12
+ data-slot="resizable-panel-group"
13
+ className={cn(
14
+ "flex h-full w-full aria-[orientation=vertical]:flex-col",
15
+ className,
16
+ )}
17
+ {...props}
18
+ />
19
+ );
20
+ }
21
+
22
+ function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
23
+ return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />;
24
+ }
25
+
26
+ function ResizableHandle({
27
+ withHandle,
28
+ className,
29
+ ...props
30
+ }: ResizablePrimitive.SeparatorProps & {
31
+ withHandle?: boolean;
32
+ }) {
33
+ return (
34
+ <ResizablePrimitive.Separator
35
+ data-slot="resizable-handle"
36
+ className={cn(
37
+ "relative flex w-px items-center justify-center bg-border after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",
38
+ className,
39
+ )}
40
+ {...props}
41
+ >
42
+ {withHandle && (
43
+ <div className="z-10 flex h-4 w-3 items-center justify-center rounded-xs border bg-border">
44
+ <GripVerticalIcon className="size-2.5" />
45
+ </div>
46
+ )}
47
+ </ResizablePrimitive.Separator>
48
+ );
49
+ }
50
+
51
+ export { ResizableHandle, ResizablePanel, ResizablePanelGroup };
@@ -0,0 +1,58 @@
1
+ "use client";
2
+
3
+ import * as React from "react";
4
+ import { ScrollArea as ScrollAreaPrimitive } from "radix-ui";
5
+
6
+ import { cn } from "@/lib/utils";
7
+
8
+ function ScrollArea({
9
+ className,
10
+ children,
11
+ ...props
12
+ }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
13
+ return (
14
+ <ScrollAreaPrimitive.Root
15
+ data-slot="scroll-area"
16
+ className={cn("relative", className)}
17
+ {...props}
18
+ >
19
+ <ScrollAreaPrimitive.Viewport
20
+ data-slot="scroll-area-viewport"
21
+ className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1"
22
+ >
23
+ {children}
24
+ </ScrollAreaPrimitive.Viewport>
25
+ <ScrollBar />
26
+ <ScrollAreaPrimitive.Corner />
27
+ </ScrollAreaPrimitive.Root>
28
+ );
29
+ }
30
+
31
+ function ScrollBar({
32
+ className,
33
+ orientation = "vertical",
34
+ ...props
35
+ }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
36
+ return (
37
+ <ScrollAreaPrimitive.ScrollAreaScrollbar
38
+ data-slot="scroll-area-scrollbar"
39
+ orientation={orientation}
40
+ className={cn(
41
+ "flex touch-none p-px transition-colors select-none",
42
+ orientation === "vertical" &&
43
+ "h-full w-2.5 border-l border-l-transparent",
44
+ orientation === "horizontal" &&
45
+ "h-2.5 flex-col border-t border-t-transparent",
46
+ className,
47
+ )}
48
+ {...props}
49
+ >
50
+ <ScrollAreaPrimitive.ScrollAreaThumb
51
+ data-slot="scroll-area-thumb"
52
+ className="relative flex-1 rounded-full bg-border"
53
+ />
54
+ </ScrollAreaPrimitive.ScrollAreaScrollbar>
55
+ );
56
+ }
57
+
58
+ export { ScrollArea, ScrollBar };
@@ -0,0 +1,240 @@
1
+ "use client";
2
+
3
+ import { ReactNode, RefObject, useCallback, useEffect, useRef } from "react";
4
+
5
+ type ScrollspyProps = {
6
+ children: ReactNode;
7
+ targetRef?: RefObject<
8
+ HTMLElement | HTMLDivElement | Document | null | undefined
9
+ >;
10
+ onUpdate?: (id: string) => void;
11
+ offset?: number;
12
+ smooth?: boolean;
13
+ className?: string;
14
+ dataAttribute?: string;
15
+ history?: boolean;
16
+ throttleTime?: number;
17
+ };
18
+
19
+ export function Scrollspy({
20
+ children,
21
+ targetRef,
22
+ onUpdate,
23
+ className,
24
+ offset = 0,
25
+ smooth = true,
26
+ dataAttribute = "scrollspy",
27
+ history = true,
28
+ }: ScrollspyProps) {
29
+ const selfRef = useRef<HTMLDivElement | null>(null);
30
+ const anchorElementsRef = useRef<Element[] | null>(null);
31
+ const prevIdTracker = useRef<string | null>(null);
32
+
33
+ // Sets active nav, hash, prevIdTracker, and calls onUpdate
34
+ const setActiveSection = useCallback(
35
+ (sectionId: string | null, force = false) => {
36
+ if (!sectionId) return;
37
+ anchorElementsRef.current?.forEach((item) => {
38
+ const id = item.getAttribute(`data-${dataAttribute}-anchor`);
39
+ if (id === sectionId) {
40
+ item.setAttribute("data-active", "true");
41
+ } else {
42
+ item.removeAttribute("data-active");
43
+ }
44
+ });
45
+ if (onUpdate) onUpdate(sectionId);
46
+ if (history && (force || prevIdTracker.current !== sectionId)) {
47
+ window.history.replaceState({}, "", `#${sectionId}`);
48
+ }
49
+ prevIdTracker.current = sectionId;
50
+ },
51
+ [anchorElementsRef, dataAttribute, history, onUpdate],
52
+ );
53
+
54
+ const handleScroll = useCallback(() => {
55
+ if (!anchorElementsRef.current || anchorElementsRef.current.length === 0)
56
+ return;
57
+
58
+ let scrollElement =
59
+ targetRef?.current === document
60
+ ? document.documentElement
61
+ : (targetRef?.current as HTMLElement);
62
+
63
+ if (!scrollElement) return;
64
+
65
+ // If the scrollElement has a data-slot="scroll-area-viewport" inside, use that
66
+ const viewport = scrollElement.querySelector(
67
+ '[data-slot="scroll-area-viewport"]',
68
+ );
69
+ if (viewport instanceof HTMLElement) {
70
+ scrollElement = viewport;
71
+ }
72
+
73
+ const scrollTop =
74
+ scrollElement === document.documentElement
75
+ ? window.scrollY || document.documentElement.scrollTop
76
+ : scrollElement.scrollTop;
77
+
78
+ // Find the anchor whose section is closest to but not past the top
79
+ let activeIdx = 0;
80
+ let minDelta = Infinity;
81
+
82
+ anchorElementsRef.current.forEach((anchor, idx) => {
83
+ const sectionId = anchor.getAttribute(`data-${dataAttribute}-anchor`);
84
+ const sectionElement = document.getElementById(sectionId!);
85
+ if (!sectionElement) return;
86
+
87
+ let customOffset = offset;
88
+ const dataOffset = anchor.getAttribute(`data-${dataAttribute}-offset`);
89
+ if (dataOffset) customOffset = parseInt(dataOffset, 10);
90
+
91
+ const delta = Math.abs(
92
+ sectionElement.offsetTop - customOffset - scrollTop,
93
+ );
94
+
95
+ if (
96
+ sectionElement.offsetTop - customOffset <= scrollTop &&
97
+ delta < minDelta
98
+ ) {
99
+ minDelta = delta;
100
+ activeIdx = idx;
101
+ }
102
+ });
103
+
104
+ // If at bottom, force last anchor
105
+ const scrollHeight = (scrollElement as HTMLElement).scrollHeight;
106
+ const clientHeight = (scrollElement as HTMLElement).clientHeight;
107
+
108
+ if (scrollTop + clientHeight >= scrollHeight - 2) {
109
+ activeIdx = anchorElementsRef.current.length - 1;
110
+ }
111
+
112
+ // Set only one anchor active and sync the URL hash
113
+ const activeAnchor = anchorElementsRef.current[activeIdx];
114
+ const sectionId =
115
+ activeAnchor?.getAttribute(`data-${dataAttribute}-anchor`) || null;
116
+
117
+ setActiveSection(sectionId);
118
+ }, [anchorElementsRef, targetRef, dataAttribute, offset, setActiveSection]);
119
+
120
+ const scrollTo = useCallback(
121
+ (anchorElement: HTMLElement) => (event?: Event) => {
122
+ if (event) event.preventDefault();
123
+ const sectionId =
124
+ anchorElement
125
+ .getAttribute(`data-${dataAttribute}-anchor`)
126
+ ?.replace("#", "") || null;
127
+ if (!sectionId) return;
128
+ const sectionElement = document.getElementById(sectionId);
129
+ if (!sectionElement) return;
130
+
131
+ let scrollToElement: HTMLElement | Window | null =
132
+ targetRef?.current === document
133
+ ? window
134
+ : (targetRef?.current as HTMLElement);
135
+
136
+ if (scrollToElement instanceof HTMLElement) {
137
+ const viewport = scrollToElement.querySelector(
138
+ '[data-slot="scroll-area-viewport"]',
139
+ );
140
+ if (viewport instanceof HTMLElement) {
141
+ scrollToElement = viewport;
142
+ }
143
+ }
144
+
145
+ let customOffset = offset;
146
+ const dataOffset = anchorElement.getAttribute(
147
+ `data-${dataAttribute}-offset`,
148
+ );
149
+ if (dataOffset) {
150
+ customOffset = parseInt(dataOffset, 10);
151
+ }
152
+
153
+ const scrollTop = sectionElement.offsetTop - customOffset;
154
+
155
+ if (scrollToElement && "scrollTo" in scrollToElement) {
156
+ scrollToElement.scrollTo({
157
+ top: scrollTop,
158
+ left: 0,
159
+ behavior: smooth ? "smooth" : "auto",
160
+ });
161
+ }
162
+ setActiveSection(sectionId, true);
163
+ },
164
+ [dataAttribute, offset, smooth, targetRef, setActiveSection],
165
+ );
166
+
167
+ // Scroll to the section if the ID is present in the URL hash
168
+ const scrollToHashSection = useCallback(() => {
169
+ const hash = CSS.escape(window.location.hash.replace("#", ""));
170
+
171
+ if (hash) {
172
+ const targetElement = document.querySelector(
173
+ `[data-${dataAttribute}-anchor="${hash}"]`,
174
+ ) as HTMLElement;
175
+ if (targetElement) {
176
+ scrollTo(targetElement)();
177
+ }
178
+ }
179
+ }, [dataAttribute, scrollTo]);
180
+
181
+ useEffect(() => {
182
+ // Query elements and store them in the ref, avoiding unnecessary re-renders
183
+ if (selfRef.current) {
184
+ anchorElementsRef.current = Array.from(
185
+ selfRef.current.querySelectorAll(`[data-${dataAttribute}-anchor]`),
186
+ );
187
+ }
188
+
189
+ const currentAnchors = anchorElementsRef.current;
190
+ currentAnchors?.forEach((item) => {
191
+ item.addEventListener("click", scrollTo(item as HTMLElement));
192
+ });
193
+
194
+ const onScroll = (event: Event) => {
195
+ const scrollElement =
196
+ targetRef?.current === document
197
+ ? window
198
+ : (targetRef?.current as HTMLElement);
199
+ if (!scrollElement) return;
200
+
201
+ if (
202
+ scrollElement === window ||
203
+ (scrollElement instanceof HTMLElement &&
204
+ scrollElement.contains(event.target as Node))
205
+ ) {
206
+ handleScroll();
207
+ }
208
+ };
209
+
210
+ // Use window listener with capture to catch scroll events from targetRef even if set later
211
+ window.addEventListener("scroll", onScroll, true);
212
+
213
+ // Check if there's a hash in the URL and scroll to the corresponding section
214
+ const initialTimeout = setTimeout(() => {
215
+ scrollToHashSection();
216
+ handleScroll();
217
+ }, 100);
218
+
219
+ return () => {
220
+ window.removeEventListener("scroll", onScroll, true);
221
+ currentAnchors?.forEach((item) => {
222
+ item.removeEventListener("click", scrollTo(item as HTMLElement));
223
+ });
224
+ clearTimeout(initialTimeout);
225
+ };
226
+ }, [
227
+ targetRef,
228
+ selfRef,
229
+ handleScroll,
230
+ dataAttribute,
231
+ scrollTo,
232
+ scrollToHashSection,
233
+ ]);
234
+
235
+ return (
236
+ <div data-slot="scrollspy" className={className} ref={selfRef}>
237
+ {children}
238
+ </div>
239
+ );
240
+ }